locize-cli 7.13.1 → 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 CHANGED
@@ -5,6 +5,14 @@ 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
+
12
+ ## [7.13.2](https://github.com/locize/locize-cli/compare/v7.13.1...v7.13.2) - 2023-01-24
13
+
14
+ - update dependencies to fix reported vulnerabilities [#81](https://github.com/locize/locize-cli/issues/81)
15
+
8
16
  ## [7.13.1](https://github.com/locize/locize-cli/compare/v7.13.0...v7.13.1) - 2022-12-08
9
17
 
10
18
  - optimize migrate command
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 locize
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -86,6 +86,10 @@ or add a format like (json, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, y
86
86
  locize download --project-id my-project-id-93e1-442a-ab35-24331fa294ba --ver latest --language en --namespace namespace1 --path ./backup --format android
87
87
  ```
88
88
 
89
+ ### GitHub Action
90
+
91
+ There's also a [GitHub Action](https://github.com/marketplace/actions/locize-download) that handles the download in your CI/CD workflow.
92
+
89
93
 
90
94
  ## Synchronize locize with your repository (or any other local directory)
91
95
  By using the sync command, you can keep your existing code setup and synchronize the translations with locize.
@@ -311,7 +315,7 @@ or
311
315
  locize add common title "the title of my cool app"
312
316
  ```
313
317
 
314
- ### Additionally if these environment variables are set:
318
+ ### Additionally if these environment variables can be set:
315
319
 
316
320
  - LOCIZE_PROJECTID or LOCIZE_PID
317
321
  - LOCIZE_API_KEY or LOCIZE_KEY
@@ -322,4 +326,6 @@ they will also be considered with this priority:
322
326
 
323
327
  1. argument as part of command (i.e. locize sync --project-id ...)
324
328
  2. config value in .locize file (i.e. projectId = ...)
325
- 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 home = path.join(os.homedir(), '.locize');
12
- const workingDirectory = path.join(process.cwd(), '.locize');
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: ${workingDirectory} or ${home})`);
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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: ${workingDirectory} or ${home})`)
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 || workingDirectory, 'utf-8'));
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.13.1",
3
+ "version": "7.14.0",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -8,13 +8,14 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@js.properties/properties": "0.5.4",
11
- "android-string-resource": "2.3.8",
11
+ "android-string-resource": "2.3.9",
12
12
  "async": "3.2.4",
13
13
  "cacheable-lookup": "6.1.0",
14
14
  "colors": "1.4.0",
15
- "commander": "9.4.1",
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,8 +24,8 @@
23
24
  "js-yaml": "4.1.0",
24
25
  "laravelphp": "2.0.3",
25
26
  "lodash.clonedeep": "4.5.0",
26
- "mkdirp": "1.0.4",
27
- "node-fetch": "2.6.7",
27
+ "mkdirp": "2.1.5",
28
+ "node-fetch": "2.6.8",
28
29
  "resx": "2.0.3",
29
30
  "rimraf": "3.0.2",
30
31
  "strings-file": "0.0.5",
@@ -33,9 +34,9 @@
33
34
  "xlsx": "0.18.5"
34
35
  },
35
36
  "devDependencies": {
36
- "eslint": "8.29.0",
37
- "gh-release": "6.0.4",
38
- "pkg": "5.8.0"
37
+ "eslint": "8.36.0",
38
+ "gh-release": "7.0.2",
39
+ "pkg": "5.8.1"
39
40
  },
40
41
  "scripts": {
41
42
  "lint": "eslint .",