@kununu/phraseapp-cli 4.2.0 → 5.0.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/.nvmrc +1 -0
- package/check-translations.js +7 -7
- package/eslint.config.mjs +11 -0
- package/index.js +14 -15
- package/package.json +9 -4
- package/.eslintignore +0 -11
- package/.eslintrc +0 -6
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v24.13.1
|
package/check-translations.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import {parse} from '@babel/parser';
|
|
2
|
+
import traverse from '@babel/traverse';
|
|
3
|
+
// eslint-disable-next-line sonarjs/unused-import, @typescript-eslint/no-unused-vars
|
|
4
|
+
import colors from 'colors';
|
|
5
|
+
import {
|
|
2
6
|
existsSync,
|
|
3
7
|
mkdirSync,
|
|
4
8
|
readFileSync,
|
|
5
9
|
unlinkSync,
|
|
6
10
|
writeFileSync,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const {parse} = require('@babel/parser');
|
|
10
|
-
const traverse = require('@babel/traverse');
|
|
11
|
-
const colors = require('colors'); // eslint-disable-line no-unused-vars
|
|
12
|
-
const {sync} = require('glob');
|
|
11
|
+
} from 'fs';
|
|
12
|
+
import {sync} from 'glob';
|
|
13
13
|
|
|
14
14
|
const FOLDER_REPORT_CHECK_TRANSLATIONS = `${process.cwd()}/report-check-translations`;
|
|
15
15
|
const UNUSED_KEYS_FILE = `${FOLDER_REPORT_CHECK_TRANSLATIONS}/not_used_keys.json`;
|
package/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require('dotenv').config();
|
|
8
|
-
|
|
9
|
-
const colors = require('colors'); // eslint-disable-line no-unused-vars
|
|
3
|
+
// eslint-disable-next-line sonarjs/unused-import, @typescript-eslint/no-unused-vars
|
|
4
|
+
import colors from 'colors';
|
|
5
|
+
import 'dotenv/config';
|
|
6
|
+
import {existsSync, mkdirSync, readFileSync, writeFileSync} from 'fs';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* Splits array into smaller chunks
|
|
@@ -27,14 +24,14 @@ function logErrorsAndExitProcess(errors) {
|
|
|
27
24
|
function loadConfig() {
|
|
28
25
|
const configPath = `${process.cwd()}/.phraseapp.json`;
|
|
29
26
|
|
|
30
|
-
if (!
|
|
31
|
-
logErrorsAndExitProcess([
|
|
27
|
+
if (!existsSync(configPath)) {
|
|
28
|
+
logErrorsAndExitProcess(['Error: pharaseapp config file doesn\'t exist.']);
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
const errors = [];
|
|
35
32
|
|
|
36
33
|
try {
|
|
37
|
-
const phrase = JSON.parse(
|
|
34
|
+
const phrase = JSON.parse(readFileSync(configPath));
|
|
38
35
|
|
|
39
36
|
// override access token with env var, if available
|
|
40
37
|
if (process.env.PHRASEAPP_ACCESS_TOKEN) {
|
|
@@ -61,7 +58,7 @@ function loadConfig() {
|
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
if (!errors.length) return phrase;
|
|
64
|
-
} catch
|
|
61
|
+
} catch {
|
|
65
62
|
errors.push('Error: Your pharaseapp config file is incorrect .');
|
|
66
63
|
}
|
|
67
64
|
|
|
@@ -89,6 +86,7 @@ function getPhraseAppQueryParams(tags, fallbackLocale, branch) {
|
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
const getFileName = (filePrefix, localeId) =>
|
|
89
|
+
// eslint-disable-next-line sonarjs/no-nested-template-literals
|
|
92
90
|
`${filePrefix ? `${filePrefix}-` : ''}${localeId}.json`;
|
|
93
91
|
|
|
94
92
|
const getFilePath = (path, filePrefix, localeId) =>
|
|
@@ -140,15 +138,17 @@ function downloadLocaleFile(phrase, locale) {
|
|
|
140
138
|
if (!response.ok) {
|
|
141
139
|
throw new Error(response);
|
|
142
140
|
}
|
|
141
|
+
|
|
143
142
|
return response.json();
|
|
144
143
|
})
|
|
145
144
|
.then(data => {
|
|
146
145
|
// Handle the JSON response
|
|
147
|
-
|
|
146
|
+
writeFileSync(filepath, JSON.stringify(data));
|
|
148
147
|
console.info(
|
|
149
148
|
`Success: locale file ${getFileName(filePrefix, localeId)} was updated`
|
|
150
149
|
.green.bold,
|
|
151
150
|
);
|
|
151
|
+
|
|
152
152
|
return resolve();
|
|
153
153
|
})
|
|
154
154
|
.catch(error => {
|
|
@@ -179,7 +179,6 @@ async function loadLocale(phrase) {
|
|
|
179
179
|
downloadLocaleFile(phrase, locale),
|
|
180
180
|
);
|
|
181
181
|
|
|
182
|
-
// eslint-disable-next-line no-await-in-loop
|
|
183
182
|
await Promise.all(downloads);
|
|
184
183
|
}
|
|
185
184
|
|
|
@@ -191,8 +190,8 @@ function loadLocalesFromConfig() {
|
|
|
191
190
|
const phrase = loadConfig();
|
|
192
191
|
|
|
193
192
|
// make sure dir to load files into exists
|
|
194
|
-
if (!
|
|
195
|
-
|
|
193
|
+
if (!existsSync(phrase.path)) {
|
|
194
|
+
mkdirSync(phrase.path);
|
|
196
195
|
}
|
|
197
196
|
|
|
198
197
|
// Update configs from phraseapp cli
|
package/package.json
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kununu/phraseapp-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "kununu",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": "24.13.1",
|
|
10
|
+
"npm": "11.8.0"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/kununu/kununu-phraseapp-cli#readme",
|
|
8
13
|
"scripts": {
|
|
9
|
-
"lint": "eslint . --ext jsx --ext js --ext tsx --ext ts --
|
|
14
|
+
"lint": "eslint . --ext jsx --ext js --ext tsx --ext ts --max-warnings 10"
|
|
10
15
|
},
|
|
11
16
|
"dependencies": {
|
|
12
17
|
"@babel/parser": "7.29.0",
|
|
13
18
|
"@babel/traverse": "7.29.0",
|
|
14
19
|
"colors": "1.4.0",
|
|
15
20
|
"dotenv": "17.3.1",
|
|
16
|
-
"glob": "13.0.
|
|
21
|
+
"glob": "13.0.6"
|
|
17
22
|
},
|
|
18
23
|
"devDependencies": {
|
|
19
|
-
"@kununu/eslint-config": "
|
|
24
|
+
"@kununu/eslint-config": "7.0.0"
|
|
20
25
|
}
|
|
21
26
|
}
|
package/.eslintignore
DELETED