locize-cli 7.13.2 → 7.14.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/CHANGELOG.md +4 -0
- package/README.md +4 -2
- package/bin/locize +45 -80
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
Project versioning adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
7
7
|
|
|
8
|
+
## [7.14.0](https://github.com/locize/locize-cli/compare/v7.13.2...v7.14.0) - 2023-03-11
|
|
9
|
+
|
|
10
|
+
- support for .env file [#83](https://github.com/locize/locize-cli/pull/83)
|
|
11
|
+
|
|
8
12
|
## [7.13.2](https://github.com/locize/locize-cli/compare/v7.13.1...v7.13.2) - 2023-01-24
|
|
9
13
|
|
|
10
14
|
- update dependencies to fix reported vulnerabilities [#81](https://github.com/locize/locize-cli/issues/81)
|
package/README.md
CHANGED
|
@@ -315,7 +315,7 @@ or
|
|
|
315
315
|
locize add common title "the title of my cool app"
|
|
316
316
|
```
|
|
317
317
|
|
|
318
|
-
### Additionally if these environment variables
|
|
318
|
+
### Additionally if these environment variables can be set:
|
|
319
319
|
|
|
320
320
|
- LOCIZE_PROJECTID or LOCIZE_PID
|
|
321
321
|
- LOCIZE_API_KEY or LOCIZE_KEY
|
|
@@ -326,4 +326,6 @@ they will also be considered with this priority:
|
|
|
326
326
|
|
|
327
327
|
1. argument as part of command (i.e. locize sync --project-id ...)
|
|
328
328
|
2. config value in .locize file (i.e. projectId = ...)
|
|
329
|
-
3. env variable (i.e. LOCIZE_PROJECTID)
|
|
329
|
+
3. env variable (i.e. LOCIZE_PROJECTID) / or .env file
|
|
330
|
+
|
|
331
|
+
In case you have a .env file in the current working directory, it will be used to load environment variables from that .env file into process.env.
|
package/bin/locize
CHANGED
|
@@ -8,8 +8,10 @@ const os = require('os');
|
|
|
8
8
|
const url = require('url');
|
|
9
9
|
const ini = require('ini');
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const configInHome = path.join(os.homedir(), '.locize');
|
|
12
|
+
const configInWorkingDirectory = path.join(process.cwd(), '.locize');
|
|
13
|
+
const dotEnvFile = path.join(process.cwd(), '.env');
|
|
14
|
+
if (fs.existsSync(dotEnvFile)) require('dotenv').config();
|
|
13
15
|
const addPathUrl = 'https://api.locize.app/update/{{projectId}}/{{version}}/{{lng}}/{{ns}}';
|
|
14
16
|
const getPathUrl = 'https://api.locize.app/{{projectId}}/{{version}}/{{lng}}/{{ns}}';
|
|
15
17
|
|
|
@@ -25,11 +27,18 @@ const deleteNamespace = require('../deleteNamespace');
|
|
|
25
27
|
const formatFn = require('../format');
|
|
26
28
|
|
|
27
29
|
var config = {};
|
|
30
|
+
try {
|
|
31
|
+
config = ini.parse(fs.readFileSync(configInWorkingDirectory, 'utf-8'));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
try {
|
|
34
|
+
config = ini.parse(fs.readFileSync(configInHome, 'utf-8'));
|
|
35
|
+
} catch (e) {}
|
|
36
|
+
}
|
|
28
37
|
|
|
29
38
|
program
|
|
30
39
|
.version(require('../package.json').version)
|
|
31
40
|
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`);
|
|
32
|
-
// .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
41
|
+
// .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`);
|
|
33
42
|
|
|
34
43
|
program
|
|
35
44
|
.command('migrate')
|
|
@@ -43,15 +52,11 @@ program
|
|
|
43
52
|
.option('-L, --parse-language <true|false>', 'Parse folders as language (default: true)', 'true')
|
|
44
53
|
.option('-f, --format <json>', 'File format of namespaces (default: json)', 'json')
|
|
45
54
|
.option('-r, --replace <true|false>', 'This will empty the optionally existing namespace before saving the new translations. (default: false)', 'false')
|
|
46
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
55
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
47
56
|
.action((options) => {
|
|
48
57
|
try {
|
|
49
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
50
|
-
} catch (e) {
|
|
51
|
-
try {
|
|
52
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
53
|
-
} catch (e) {}
|
|
54
|
-
}
|
|
58
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
59
|
+
} catch (e) {}
|
|
55
60
|
|
|
56
61
|
const addPath = options.addPath || config.addPath || addPathUrl;
|
|
57
62
|
|
|
@@ -105,15 +110,11 @@ program
|
|
|
105
110
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
106
111
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
107
112
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
108
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
113
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
109
114
|
.action((namespace, key, value, options) => {
|
|
110
115
|
try {
|
|
111
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
112
|
-
} catch (e) {
|
|
113
|
-
try {
|
|
114
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
115
|
-
} catch (e) {}
|
|
116
|
-
}
|
|
116
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
117
|
+
} catch (e) {}
|
|
117
118
|
|
|
118
119
|
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
|
|
119
120
|
if (!apiKey) {
|
|
@@ -168,15 +169,11 @@ program
|
|
|
168
169
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
169
170
|
.option('-l, --language <lng>', 'The language that should be targeted (omitting this attribute will result in removing the key from all languages)')
|
|
170
171
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
171
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
172
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
172
173
|
.action((namespace, key, options) => {
|
|
173
174
|
try {
|
|
174
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
175
|
-
} catch (e) {
|
|
176
|
-
try {
|
|
177
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
178
|
-
} catch (e) {}
|
|
179
|
-
}
|
|
175
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
176
|
+
} catch (e) {}
|
|
180
177
|
|
|
181
178
|
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
|
|
182
179
|
if (!apiKey) {
|
|
@@ -240,15 +237,11 @@ program
|
|
|
240
237
|
.option('-m, --path-mask <mask>', 'This will define the folder and file structure; do not add a file extension (default: {{language}}/{{namespace}})', `{{language}}${path.sep}{{namespace}}`)
|
|
241
238
|
.option('-c, --clean <true|false>', 'Removes all local files by removing the whole folder (default: false)', 'false')
|
|
242
239
|
.option('-up, --unpublished <true|false>', 'Downloads the current (unpublished) translations. This will generate private download costs (default: false)', 'false')
|
|
243
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
240
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
244
241
|
.action((options) => {
|
|
245
242
|
try {
|
|
246
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
247
|
-
} catch (e) {
|
|
248
|
-
try {
|
|
249
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
250
|
-
} catch (e) {}
|
|
251
|
-
}
|
|
243
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
244
|
+
} catch (e) {}
|
|
252
245
|
|
|
253
246
|
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID;
|
|
254
247
|
if (!projectId) {
|
|
@@ -313,15 +306,11 @@ program
|
|
|
313
306
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
314
307
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
315
308
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
316
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
309
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
317
310
|
.action((namespace, key, options) => {
|
|
318
311
|
try {
|
|
319
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
320
|
-
} catch (e) {
|
|
321
|
-
try {
|
|
322
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
323
|
-
} catch (e) {}
|
|
324
|
-
}
|
|
312
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
313
|
+
} catch (e) {}
|
|
325
314
|
|
|
326
315
|
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID;
|
|
327
316
|
if (!projectId) {
|
|
@@ -383,15 +372,11 @@ program
|
|
|
383
372
|
.option('-n, --namespace <ns>', 'The namespace that should be targeted')
|
|
384
373
|
.option('-g, --get-path <url>', `Specify the get-path url that should be used (default: ${getPathUrl})`)
|
|
385
374
|
.option('-up, --unpublished <true|false>', 'Downloads the current (unpublished) translations. This will generate private download costs (default: false)', 'false')
|
|
386
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
375
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
387
376
|
.action((options) => {
|
|
388
377
|
try {
|
|
389
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
390
|
-
} catch (e) {
|
|
391
|
-
try {
|
|
392
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
393
|
-
} catch (e) {}
|
|
394
|
-
}
|
|
378
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
379
|
+
} catch (e) {}
|
|
395
380
|
|
|
396
381
|
const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
|
|
397
382
|
|
|
@@ -479,15 +464,11 @@ program
|
|
|
479
464
|
.option('-R, --reference-language-only <true|false>', 'Check for changes in reference language only. (default: true)', 'true')
|
|
480
465
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
481
466
|
.option('-n, --namespace <ns>', 'The namespace that should be targeted')
|
|
482
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
467
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
483
468
|
.action((options) => {
|
|
484
469
|
try {
|
|
485
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
486
|
-
} catch (e) {
|
|
487
|
-
try {
|
|
488
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
489
|
-
} catch (e) {}
|
|
490
|
-
}
|
|
470
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
471
|
+
} catch (e) {}
|
|
491
472
|
|
|
492
473
|
const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
|
|
493
474
|
|
|
@@ -555,15 +536,11 @@ program
|
|
|
555
536
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
556
537
|
.option('-v, --ver <version>', 'The target version to be used to copy to (default: latest)')
|
|
557
538
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
558
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
539
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
559
540
|
.action((fromVersion, options) => {
|
|
560
541
|
try {
|
|
561
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
562
|
-
} catch (e) {
|
|
563
|
-
try {
|
|
564
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
565
|
-
} catch (e) {}
|
|
566
|
-
}
|
|
542
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
543
|
+
} catch (e) {}
|
|
567
544
|
|
|
568
545
|
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
|
|
569
546
|
if (!apiKey) {
|
|
@@ -607,15 +584,11 @@ program
|
|
|
607
584
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
608
585
|
.option('-v, --ver <version>', 'The version to be used to publish (default: latest)')
|
|
609
586
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
610
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
587
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
611
588
|
.action((options) => {
|
|
612
589
|
try {
|
|
613
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
614
|
-
} catch (e) {
|
|
615
|
-
try {
|
|
616
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
617
|
-
} catch (e) {}
|
|
618
|
-
}
|
|
590
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
591
|
+
} catch (e) {}
|
|
619
592
|
|
|
620
593
|
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
|
|
621
594
|
if (!apiKey) {
|
|
@@ -658,15 +631,11 @@ program
|
|
|
658
631
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
659
632
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
660
633
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
661
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
634
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
662
635
|
.action((namespace, options) => {
|
|
663
636
|
try {
|
|
664
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
665
|
-
} catch (e) {
|
|
666
|
-
try {
|
|
667
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
668
|
-
} catch (e) {}
|
|
669
|
-
}
|
|
637
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
638
|
+
} catch (e) {}
|
|
670
639
|
|
|
671
640
|
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
|
|
672
641
|
if (!apiKey) {
|
|
@@ -710,15 +679,11 @@ program
|
|
|
710
679
|
.option('-f, --format <json>', 'File format of namespaces (default: json; [flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
|
|
711
680
|
.option('-l, --reference-language <lng>', 'Some format conversions need to know the reference language.', 'en')
|
|
712
681
|
.option('-d, --dry <true|false>', 'Dry run (default: false)', 'false')
|
|
713
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${
|
|
682
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
714
683
|
.action((fileOrDirectory, options) => {
|
|
715
684
|
try {
|
|
716
|
-
config = ini.parse(fs.readFileSync(options.configPath ||
|
|
717
|
-
} catch (e) {
|
|
718
|
-
try {
|
|
719
|
-
config = ini.parse(fs.readFileSync(options.configPath || home, 'utf-8'));
|
|
720
|
-
} catch (e) {}
|
|
721
|
-
}
|
|
685
|
+
config = ini.parse(fs.readFileSync(options.configPath)) || config;
|
|
686
|
+
} catch (e) {}
|
|
722
687
|
|
|
723
688
|
fileOrDirectory = fileOrDirectory || '.';
|
|
724
689
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "locize-cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0",
|
|
4
4
|
"description": "locize cli to import locales",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"commander": "9.5.0",
|
|
16
16
|
"csvjson": "5.1.0",
|
|
17
17
|
"diff": "5.1.0",
|
|
18
|
+
"dotenv": "16.0.3",
|
|
18
19
|
"flat": "5.0.2",
|
|
19
20
|
"fluent_conv": "3.1.0",
|
|
20
21
|
"gettext-converter": "1.2.3",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"js-yaml": "4.1.0",
|
|
24
25
|
"laravelphp": "2.0.3",
|
|
25
26
|
"lodash.clonedeep": "4.5.0",
|
|
26
|
-
"mkdirp": "2.1.
|
|
27
|
+
"mkdirp": "2.1.5",
|
|
27
28
|
"node-fetch": "2.6.8",
|
|
28
29
|
"resx": "2.0.3",
|
|
29
30
|
"rimraf": "3.0.2",
|
|
@@ -33,9 +34,9 @@
|
|
|
33
34
|
"xlsx": "0.18.5"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"eslint": "8.
|
|
37
|
+
"eslint": "8.36.0",
|
|
37
38
|
"gh-release": "7.0.2",
|
|
38
|
-
"pkg": "5.8.
|
|
39
|
+
"pkg": "5.8.1"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"lint": "eslint .",
|