locize-cli 7.14.8 → 7.14.10

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.10](https://github.com/locize/locize-cli/compare/v7.14.9...v7.14.10) - 2023-10-08
9
+
10
+ - fix opening of files provided with --config-path [#88](https://github.com/locize/locize-cli/pull/88)
11
+
12
+ ## [7.14.9](https://github.com/locize/locize-cli/compare/v7.14.8...v7.14.9) - 2023-10-06
13
+
14
+ - update some deps and add additional logs for json parse error
15
+
8
16
  ## [7.14.8](https://github.com/locize/locize-cli/compare/v7.14.7...v7.14.8) - 2023-08-01
9
17
 
10
18
  - sync: log path if passing custom path argument
package/README.md CHANGED
@@ -196,6 +196,9 @@ Navigate to your locize project and check the results => [www.locize.app](https:
196
196
 
197
197
 
198
198
  ## Copy version
199
+
200
+ *It uses this [API endpoint](https://docs.locize.com/integration/api#copy-version) and it's the same behavior like [overwriting](https://github.com/more/versioning#a-overwrite-with-data-from) via the UI.*
201
+
199
202
  ### Step 1: execute
200
203
 
201
204
  Add your api-key (of target version) and your project-id and let's go...
package/bin/locize CHANGED
@@ -55,7 +55,7 @@ program
55
55
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
56
56
  .action((options) => {
57
57
  try {
58
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
58
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
59
59
  } catch (e) {}
60
60
 
61
61
  const addPath = options.addPath || config.addPath || addPathUrl;
@@ -113,7 +113,7 @@ program
113
113
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
114
114
  .action((namespace, key, value, options) => {
115
115
  try {
116
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
116
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
117
117
  } catch (e) {}
118
118
 
119
119
  const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
@@ -172,7 +172,7 @@ program
172
172
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
173
173
  .action((namespace, key, options) => {
174
174
  try {
175
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
175
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
176
176
  } catch (e) {}
177
177
 
178
178
  const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
@@ -240,7 +240,7 @@ program
240
240
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
241
241
  .action((options) => {
242
242
  try {
243
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
243
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
244
244
  } catch (e) {}
245
245
 
246
246
  const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID;
@@ -309,7 +309,7 @@ program
309
309
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
310
310
  .action((namespace, key, options) => {
311
311
  try {
312
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
312
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
313
313
  } catch (e) {}
314
314
 
315
315
  const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID;
@@ -376,7 +376,7 @@ program
376
376
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
377
377
  .action((options) => {
378
378
  try {
379
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
379
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
380
380
  } catch (e) {}
381
381
 
382
382
  const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
@@ -470,7 +470,7 @@ program
470
470
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
471
471
  .action((options) => {
472
472
  try {
473
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
473
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
474
474
  } catch (e) {}
475
475
 
476
476
  const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
@@ -542,7 +542,7 @@ program
542
542
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
543
543
  .action((fromVersion, options) => {
544
544
  try {
545
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
545
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
546
546
  } catch (e) {}
547
547
 
548
548
  const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
@@ -590,7 +590,7 @@ program
590
590
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
591
591
  .action((options) => {
592
592
  try {
593
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
593
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
594
594
  } catch (e) {}
595
595
 
596
596
  const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
@@ -637,7 +637,7 @@ program
637
637
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
638
638
  .action((namespace, options) => {
639
639
  try {
640
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
640
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
641
641
  } catch (e) {}
642
642
 
643
643
  const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
@@ -685,7 +685,7 @@ program
685
685
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
686
686
  .action((fileOrDirectory, options) => {
687
687
  try {
688
- config = ini.parse(fs.readFileSync(options.configPath)) || config;
688
+ config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
689
689
  } catch (e) {}
690
690
 
691
691
  fileOrDirectory = fileOrDirectory || '.';
@@ -23,7 +23,16 @@ const convertToFlatFormat = (opt, data, lng, cb) => {
23
23
  }
24
24
  try {
25
25
  if (opt.format === 'json' || opt.format === 'flat') {
26
- cb(null, flatten(JSON.parse(data.toString())));
26
+ const dataString = data.toString().trim();
27
+ if (dataString[0] !== '{' && dataString[0] !== '[') {
28
+ return cb(new Error(`Not a valid json file: Content starts with "${dataString[0]}" but should start with "{"`));
29
+ }
30
+ try {
31
+ const jsonParsed = JSON.parse(dataString);
32
+ cb(null, flatten(jsonParsed));
33
+ } catch (err) {
34
+ return cb(err);
35
+ }
27
36
  return;
28
37
  }
29
38
  if (opt.format === 'po' || opt.format === 'gettext') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "7.14.8",
3
+ "version": "7.14.10",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -25,7 +25,7 @@
25
25
  "laravelphp": "2.0.3",
26
26
  "lodash.clonedeep": "4.5.0",
27
27
  "mkdirp": "2.1.6",
28
- "node-fetch": "2.6.8",
28
+ "node-fetch": "2.7.0",
29
29
  "resx": "2.0.4",
30
30
  "rimraf": "3.0.2",
31
31
  "strings-file": "0.0.5",
@@ -34,7 +34,7 @@
34
34
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz"
35
35
  },
36
36
  "devDependencies": {
37
- "eslint": "8.45.0",
37
+ "eslint": "8.50.0",
38
38
  "gh-release": "7.0.2",
39
39
  "pkg": "5.8.1"
40
40
  },
package/sync.js CHANGED
@@ -28,9 +28,9 @@ const getDownloads = (opt, cb) => {
28
28
  if (!opt.unpublished) {
29
29
  request(opt.apiPath + '/download/' + opt.projectId + '/' + opt.version, {
30
30
  method: 'get',
31
- headers: opt.apiKey ? {
32
- 'Authorization': opt.apiKey
33
- } : undefined
31
+ // headers: opt.apiKey ? {
32
+ // 'Authorization': opt.apiKey
33
+ // } : undefined
34
34
  }, (err, res, obj) => {
35
35
  if (err) return cb(err);
36
36
  if (res.status >= 300) {