@kununu/phraseapp-cli 4.0.0-beta.1 → 4.0.0-beta.2
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 +10 -5
- package/package.json +1 -1
package/check-translations.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
const { readFileSync, writeFileSync, unlinkSync, existsSync } = require('fs');
|
|
1
|
+
const { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync } = require('fs');
|
|
2
2
|
const {sync} = require('glob');
|
|
3
3
|
const {parse} = require('@babel/parser');
|
|
4
4
|
const traverse = require('@babel/traverse');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const FOLDER_REPORT_CHECK_TRANSLATIONS = `${process.cwd()}/report-check-translations`;
|
|
7
|
+
const UNUSED_KEYS_FILE = `${FOLDER_REPORT_CHECK_TRANSLATIONS}/not_used_keys.json`;
|
|
8
|
+
const MISSING_KEYS_FILE = `${FOLDER_REPORT_CHECK_TRANSLATIONS}/missing_keys.json`;
|
|
9
|
+
const POSSIBLE_DYNAMIC_KEYS_FILE = `${FOLDER_REPORT_CHECK_TRANSLATIONS}/possible_dynamic_keys.json`;
|
|
9
10
|
|
|
10
11
|
function extractTranslationKeys() {
|
|
11
12
|
const files = sync(`${process.cwd()}/${process.env.SOURCE_DIR}/**/**/*.{js,jsx,ts,tsx}`);
|
|
@@ -47,7 +48,7 @@ function extractTranslationKeys() {
|
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
if (Object.keys(possibleDynamicKeys).length > 0) {
|
|
50
|
-
console.log(`${Object.keys(possibleDynamicKeys).length} files contain possible dynamic keys
|
|
51
|
+
console.log(`${Object.keys(possibleDynamicKeys).length} files contain possible dynamic keys were saved in ${POSSIBLE_DYNAMIC_KEYS_FILE}`);
|
|
51
52
|
writeFileSync(POSSIBLE_DYNAMIC_KEYS_FILE, JSON.stringify(possibleDynamicKeys, null, 2));
|
|
52
53
|
} else if (existsSync(POSSIBLE_DYNAMIC_KEYS_FILE)) {
|
|
53
54
|
unlinkSync(POSSIBLE_DYNAMIC_KEYS_FILE);
|
|
@@ -58,6 +59,10 @@ function extractTranslationKeys() {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
function compareKeys() {
|
|
62
|
+
// create folder for report
|
|
63
|
+
if (!existsSync(FOLDER_REPORT_CHECK_TRANSLATIONS)) {
|
|
64
|
+
mkdirSync(FOLDER_REPORT_CHECK_TRANSLATIONS, { recursive: true });
|
|
65
|
+
}
|
|
61
66
|
const configPath = `${process.cwd()}/.phraseapp.json`;
|
|
62
67
|
const appKeys = extractTranslationKeys();
|
|
63
68
|
|