@kununu/phraseapp-cli 4.0.0-beta.1 → 4.0.0-beta.3

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.
@@ -0,0 +1,55 @@
1
+ # phraseapp-cli
2
+ >
3
+ > phraseapp-cli for <https://phraseapp.com/>
4
+
5
+ ## Installation
6
+
7
+ ### Add `@kununu/phraseapp-cli` to your project
8
+
9
+ ```bash
10
+ npm install @kununu/phraseapp-cli --save
11
+ ```
12
+
13
+ ### Add `check-translations` to your project
14
+
15
+ Add to ```package.json```
16
+
17
+ ```json
18
+ "check-translations": "SOURCE_DIR=src node ./node_modules/@kununu/phraseapp-cli/check-translations.js",
19
+ ```
20
+
21
+ ## Configuration file
22
+
23
+ You have to add to the ```.phraseapp.json``` file a new var dynamicKeys
24
+
25
+ **For example**:
26
+
27
+ ```json
28
+ {
29
+ "project_id": "YOUR_PROJECT_ID",
30
+ "path": "YOUR_TRANSLATIONS_PATH",
31
+ "locales": [
32
+ {
33
+ "locale_id": "de_DE",
34
+ "tags": [
35
+ "TAG1",
36
+ "TAG2",
37
+ "TAG3"
38
+ ]
39
+ },
40
+ {
41
+ "locale_id": "de_AT",
42
+ "tags": [
43
+ (...)
44
+ ],
45
+ "fallback_locale_id": "de_DE"
46
+ },
47
+ (...)
48
+ ],
49
+ "dynamicKeys": []
50
+ }
51
+ ```
52
+
53
+ ## License
54
+
55
+ Apache-2.0 © [kununu](https://kununu.com)
@@ -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 UNUSED_KEYS_FILE = 'not_used_keys.json';
7
- const MISSING_KEYS_FILE = 'missing_keys.json';
8
- const POSSIBLE_DYNAMIC_KEYS_FILE = 'possible_dynamic_keys.json';
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kununu/phraseapp-cli",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "kununu",
@@ -10,11 +10,7 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "colors": "1.4.0",
13
- "dotenv": "16.4.5",
14
- "@babel/parser": "^7.26.9",
15
- "@babel/traverse": "^7.26.9",
16
- "fs": "^0.0.1-security",
17
- "glob": "^11.0.1"
13
+ "dotenv": "16.4.5"
18
14
  },
19
15
  "devDependencies": {
20
16
  "@kununu/eslint-config": "5.0.1"