added locale-check to ci/cd

This commit is contained in:
Deepak Prabhakara 2024-02-21 21:54:43 +00:00
parent 2e6fa98888
commit 8086541dc1
3 changed files with 12 additions and 1 deletions

View File

@ -141,6 +141,7 @@ jobs:
- run: npm install
- run: npm run check-lint
- run: npm run check-format
- run: npm run locale-check
- run: npm run build
- run: npm run test
working-directory: ./npm

View File

@ -10,6 +10,8 @@ const localeFile = require('./locales/en/common.json');
const files = fs.readdirSync('./', { recursive: true, withFileTypes: true });
//console.log('files:', files);
let error = false;
files.forEach((file) => {
if (file.isDirectory()) {
return;
@ -26,6 +28,7 @@ files.forEach((file) => {
// console.log('match:', match);
allStrings[id] = true;
if (!localeFile[id]) {
error = true;
console.error(`Missing key: ${path.join(file.path, file.name)} - ${id}`);
}
});
@ -35,6 +38,7 @@ files.forEach((file) => {
// console.log('match:', match, id);
allStrings[id] = true;
if (!localeFile[id]) {
error = true;
console.error(`Missing key: ${path.join(file.path, file.name)} - ${id}`);
}
});
@ -43,6 +47,11 @@ files.forEach((file) => {
Object.keys(localeFile).forEach((key) => {
if (!allStrings[key]) {
error = true;
console.error(`Unused key: ${key}`);
}
});
if (error) {
process.exit(1);
}

View File

@ -51,7 +51,8 @@
"check-types": "tsc --pretty --noEmit",
"check-format": "prettier --check .",
"check-lint": "next lint && eslint -c .eslintrc.js --ext ts --ext tsx --ext js ./",
"format": "prettier --write ."
"format": "prettier --write .",
"locale-check": "node locale-check.js"
},
"dependencies": {
"@boxyhq/metrics": "0.2.6",