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: |
npm run build:prod
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
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."

1
.gitignore vendored
View File

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

13
package-lock.json generated
View File

@ -118,6 +118,7 @@
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"check-es-compat": "3.2.0",
"circular-dependency-plugin": "^5.2.2",
"concurrently": "^8.2.0",
"cordova-plugin-moodleapp": "file:cordova-plugin-moodleapp",
"cross-env": "^7.0.3",
@ -9929,6 +9930,18 @@
"node": ">=8"
}
},
"node_modules/circular-dependency-plugin": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/circular-dependency-plugin/-/circular-dependency-plugin-5.2.2.tgz",
"integrity": "sha512-g38K9Cm5WRwlaH6g03B9OEz/0qRizI+2I7n+Gz+L5DxXJAPAiWQvwlYNm1V1jkdpUv95bOe/ASm2vfi/G560jQ==",
"dev": true,
"engines": {
"node": ">=6.0.0"
},
"peerDependencies": {
"webpack": ">=4.0.1"
}
},
"node_modules/cjs-module-lexer": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.3.1.tgz",

View File

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

View File

@ -13,6 +13,8 @@
// limitations under the License.
const TerserPlugin = require('terser-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const { appendFileSync } = require('fs');
module.exports = config => {
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;
};