feat(repo): add checks for lock files (#5854)
This commit is contained in:
parent
f01bd0cfdc
commit
57785b5336
1
.github/workflows/npm-audit.yml
vendored
1
.github/workflows/npm-audit.yml
vendored
@ -3,6 +3,7 @@ name: NPM Audit
|
|||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 * * *"
|
- cron: "0 0 * * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
audit:
|
audit:
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
yarn check-lock-files
|
||||||
yarn check-commit
|
yarn check-commit
|
||||||
yarn documentation
|
yarn documentation
|
||||||
yarn pretty-quick --check
|
yarn pretty-quick --check
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"check-commit": "node ./scripts/commit-lint.js",
|
"check-commit": "node ./scripts/commit-lint.js",
|
||||||
"check-format": "nx format:check --all",
|
"check-format": "nx format:check --all",
|
||||||
"check-imports": "node ./scripts/check-imports.js",
|
"check-imports": "node ./scripts/check-imports.js",
|
||||||
|
"check-lock-files": "node ./scripts/check-lock-files.js",
|
||||||
"check-internal-links": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts",
|
"check-internal-links": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts",
|
||||||
"check-versions": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/check-versions.ts",
|
"check-versions": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/check-versions.ts",
|
||||||
"check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts",
|
"check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts",
|
||||||
|
|||||||
34
scripts/check-lock-files.js
Normal file
34
scripts/check-lock-files.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
function checkLockFiles() {
|
||||||
|
const errors = [];
|
||||||
|
if (fs.existsSync('package-lock.json')) {
|
||||||
|
errors.push(
|
||||||
|
'Invalid occurence of "package-lock.json" file. Please remove it and use only "yarn.lock"'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (fs.existsSync('pnpm-lock.yaml')) {
|
||||||
|
errors.push(
|
||||||
|
'Invalid occurence of "pnpm-lock.yaml" file. Please remove it and use only "yarn.lock"'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const content = fs.readFileSync('yarn.lock', 'utf-8');
|
||||||
|
if (content.match(/localhost:487/)) {
|
||||||
|
errors.push(
|
||||||
|
'The "yarn.lock" has reference to local yarn repository ("localhost:4873"). Please use "registry.yarnpkg.com" in "yarn.lock"'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
errors.push('The "yarn.lock" does not exist or cannot be read');
|
||||||
|
}
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
const invalid = checkLockFiles();
|
||||||
|
if (invalid.length > 0) {
|
||||||
|
invalid.forEach((e) => console.log(e));
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user