locize-cli 7.14.2 → 7.14.4

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.4](https://github.com/locize/locize-cli/compare/v7.14.3...v7.14.4) - 2023-05-09
9
+
10
+ - sync: introduce --auto-create-path option
11
+
12
+ ## [7.14.3](https://github.com/locize/locize-cli/compare/v7.14.2...v7.14.3) - 2023-05-09
13
+
14
+ - optimize unflatten algorithm
15
+
8
16
  ## [7.14.2](https://github.com/locize/locize-cli/compare/v7.14.1...v7.14.2) - 2023-05-09
9
17
 
10
18
  - optimize unflatten algorithm
package/bin/locize CHANGED
@@ -356,6 +356,7 @@ program
356
356
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
357
357
  .option('-v, --ver <version>', 'Found namespaces will be matched to this version (default: latest)')
358
358
  .option('-p, --path <path>', `Specify the path that should be used (default: ${process.cwd()})`, process.cwd())
359
+ .option('-A, --auto-create-path <true|false>', 'This will automatically make sure the --path is created. (default: true)', 'true')
359
360
  .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')
360
361
  .option('-s, --skip-empty <true|false>', 'Skips to download empty files (default: false)', 'false')
361
362
  .option('-c, --clean <true|false>', 'Removes all local files by removing the whole folder (default: false)', 'false')
@@ -416,6 +417,7 @@ program
416
417
  const compareModificationTime = options.compareModificationTime === 'true';
417
418
  const pathMask = options.pathMask;
418
419
  const unpublished = options.unpublished === 'true';
420
+ const autoCreatePath = options.autoCreatePath === 'true';
419
421
 
420
422
  sync({
421
423
  apiPath: url.parse(getPath).protocol + '//' + url.parse(getPath).host,
@@ -437,7 +439,8 @@ program
437
439
  namespace: namespace,
438
440
  dry: dry,
439
441
  pathMask: pathMask,
440
- unpublished: unpublished
442
+ unpublished: unpublished,
443
+ autoCreatePath: autoCreatePath
441
444
  });
442
445
  })
443
446
  .on('--help', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "7.14.2",
3
+ "version": "7.14.4",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
package/sync.js CHANGED
@@ -545,6 +545,16 @@ const sync = (opt, cb) => {
545
545
  opt.apiPath = opt.apiPath || 'https://api.locize.app';
546
546
 
547
547
  if (!opt.dry && opt.clean) rimraf.sync(path.join(opt.path, '*'));
548
+
549
+ if (opt.autoCreatePath === false) {
550
+ var directoryExists = false;
551
+ try {
552
+ directoryExists = fs.statSync(opt.path).isDirectory();
553
+ } catch (e) {}
554
+ if (!directoryExists) {
555
+ return handleError(new Error(`${opt.path} does not exist!`), cb);
556
+ }
557
+ }
548
558
  if (!opt.dry) mkdirp.sync(opt.path);
549
559
 
550
560
  if (opt.namespace && opt.namespace.indexOf(',') > 0) {
package/unflatten.js CHANGED
@@ -58,7 +58,7 @@ module.exports = (data) => {
58
58
  const parts = arrToConvert.split('.');
59
59
  let pr = result;
60
60
  parts.forEach((part, ind) => {
61
- if (ind === parts.length - 1) {
61
+ if (ind === parts.length - 1 && Array.isArray(pr[part])) {
62
62
  pr[part] = pr[part].reduce((mem, item, ind) => {
63
63
  mem[ind] = item;
64
64
  return mem;