@kununu/phraseapp-cli 4.0.1 → 4.0.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/check-translations.js +9 -6
- package/index.js +0 -2
- package/package.json +1 -1
package/check-translations.js
CHANGED
|
@@ -10,6 +10,8 @@ const {parse} = require('@babel/parser');
|
|
|
10
10
|
const traverse = require('@babel/traverse');
|
|
11
11
|
const {sync} = require('glob');
|
|
12
12
|
|
|
13
|
+
const colors = require('colors'); // eslint-disable-line no-unused-vars
|
|
14
|
+
|
|
13
15
|
const FOLDER_REPORT_CHECK_TRANSLATIONS = `${process.cwd()}/report-check-translations`;
|
|
14
16
|
const UNUSED_KEYS_FILE = `${FOLDER_REPORT_CHECK_TRANSLATIONS}/not_used_keys.json`;
|
|
15
17
|
const MISSING_KEYS_FILE = `${FOLDER_REPORT_CHECK_TRANSLATIONS}/missing_keys.json`;
|
|
@@ -113,9 +115,8 @@ function compareKeys() {
|
|
|
113
115
|
|
|
114
116
|
const allValidKeys = new Set(Object.keys(translations));
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
missingKeys = missingKeys.filter(key => key != null && key !== undefined);
|
|
118
|
+
const missingKeys = [...appKeys].filter(key => !allValidKeys.has(key))
|
|
119
|
+
.filter(key => key != null && key !== undefined);
|
|
119
120
|
|
|
120
121
|
// Check if there are keys in dynamicKeys that are missing from allValidKeys.
|
|
121
122
|
dynamicKeys.forEach(key => {
|
|
@@ -131,9 +132,10 @@ function compareKeys() {
|
|
|
131
132
|
|
|
132
133
|
if (missingKeys.length > 0) {
|
|
133
134
|
writeFileSync(MISSING_KEYS_FILE, JSON.stringify(missingKeys, null, 2));
|
|
134
|
-
console.
|
|
135
|
-
`${missingKeys.length} missing keys were
|
|
135
|
+
console.error(
|
|
136
|
+
`${missingKeys.length} missing keys were found. Please check ${MISSING_KEYS_FILE} for details.`.red.bold,
|
|
136
137
|
);
|
|
138
|
+
process.exit(1);
|
|
137
139
|
} else if (existsSync(MISSING_KEYS_FILE)) {
|
|
138
140
|
unlinkSync(MISSING_KEYS_FILE);
|
|
139
141
|
console.log(
|
|
@@ -153,7 +155,8 @@ function compareKeys() {
|
|
|
153
155
|
);
|
|
154
156
|
}
|
|
155
157
|
} catch (error) {
|
|
156
|
-
console.error(error);
|
|
158
|
+
console.error(`Error: ${error.message}`.red.bold);
|
|
159
|
+
process.exit(1);
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
|
package/index.js
CHANGED