@kununu/phraseapp-cli 4.0.0 → 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.
@@ -18,6 +18,15 @@ Add to ```package.json```
18
18
  "check-translations": "SOURCE_DIR=src node ./node_modules/@kununu/phraseapp-cli/check-translations.js",
19
19
  ```
20
20
 
21
+ ### Add `report-check-translations` in .gitignore
22
+
23
+ Add to ```.gitignore````
24
+
25
+ ```json
26
+ # Check Translations Report Folder
27
+ report-check-translations/*
28
+ ```
29
+
21
30
  ## Configuration file
22
31
 
23
32
  You have to add to the ```.phraseapp.json``` file a new var dynamicKeys
@@ -54,8 +63,7 @@ You have to add to the ```.phraseapp.json``` file a new var dynamicKeys
54
63
 
55
64
  ```
56
65
  /
57
- ├─ check-translations.js # Initial file
58
- ├─ dynamic_keys.json # Add all dynamic keys that we have in the app or keys that we get from Ambassador/BE.
66
+ ├─ check-translations.js # Initial file
59
67
  ├─ possible_dynamic_keys.json # Automatically created file indicating in which files we might have dynamic keys.
60
68
  ├─ missing_keys.json # Automatically created file indicating the keys that exist in the app but are not translated.
61
69
  ├─ not_used_keys.json # Automatically created file indicating the keys that are not being used in the app.
@@ -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
- let missingKeys = [...appKeys].filter(key => !allValidKeys.has(key));
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.log(
135
- `${missingKeys.length} missing keys were saved in ${MISSING_KEYS_FILE}`,
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
@@ -6,8 +6,6 @@ const fs = require('fs');
6
6
 
7
7
  require('dotenv').config();
8
8
 
9
- const colors = require('colors'); // eslint-disable-line no-unused-vars
10
-
11
9
  /**
12
10
  * Splits array into smaller chunks
13
11
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kununu/phraseapp-cli",
3
- "version": "4.0.0",
3
+ "version": "4.0.3-beta.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "kununu",