MOBILE-4616: Count circular dependencies in CI

main
Noel De Martin 2024-07-03 13:01:47 +02:00
parent 7f4189cead
commit 3594277050
5 changed files with 27743 additions and 27703 deletions

View File

@ -62,6 +62,14 @@ jobs:
run: | run: |
npm run build:prod npm run build:prod
npm run prod --prefix cordova-plugin-moodleapp npm run prod --prefix cordova-plugin-moodleapp
env:
MOODLE_APP_CIRCULAR_DEPENDENCIES: true
- name: Circular dependencies
run: |
cat circular-dependencies
lines=$(cat circular-dependencies | wc -l)
echo "Total circular dependencies: $lines"
test $lines -eq 204
- name: JavaScript code compatibility - name: JavaScript code compatibility
run: | run: |
npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Array.prototype.flatMap,Array.prototype.flat,Array.prototype.includes,globalThis,Object.fromEntries,Object.hasOwn,Promise.prototype.finally,String.prototype.matchAll,String.prototype.trimRight" | grep "No issues found. Files are compatible with the target runtimes." npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Array.prototype.flatMap,Array.prototype.flat,Array.prototype.includes,globalThis,Object.fromEntries,Object.hasOwn,Promise.prototype.finally,String.prototype.matchAll,String.prototype.trimRight" | grep "No issues found. Files are compatible with the target runtimes."

1
.gitignore vendored
View File

@ -62,6 +62,7 @@ yarn-error.log
/libpeerconnection.log /libpeerconnection.log
testem.log testem.log
/typings /typings
circular-dependencies
# System files # System files
.DS_Store .DS_Store

55419
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -152,6 +152,7 @@
"@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0", "@typescript-eslint/parser": "^6.0.0",
"check-es-compat": "3.2.0", "check-es-compat": "3.2.0",
"circular-dependency-plugin": "^5.2.2",
"concurrently": "^8.2.0", "concurrently": "^8.2.0",
"cordova-plugin-moodleapp": "file:cordova-plugin-moodleapp", "cordova-plugin-moodleapp": "file:cordova-plugin-moodleapp",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",

View File

@ -13,6 +13,8 @@
// limitations under the License. // limitations under the License.
const TerserPlugin = require('terser-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const { appendFileSync } = require('fs');
module.exports = config => { module.exports = config => {
config.optimization.minimizer.push( config.optimization.minimizer.push(
@ -46,5 +48,20 @@ module.exports = config => {
}); });
} }
if (process.env.MOODLE_APP_CIRCULAR_DEPENDENCIES) {
config.plugins.push(
new CircularDependencyPlugin({
exclude: /node_modules/,
cwd: process.cwd(),
onDetected({ paths }) {
appendFileSync(
`${process.cwd()}/circular-dependencies`,
paths.join(' -> ') + '\n',
);
},
}),
);
}
return config; return config;
}; };