locize-cli 8.1.1 → 8.3.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
+ ## [8.3.0](https://github.com/locize/locize-cli/compare/v8.2.0...v8.3.0) - 2024-11-25
9
+
10
+ - update some deprecated dependencies (#100)
11
+
12
+ ## [8.2.0](https://github.com/locize/locize-cli/compare/v8.1.1...v8.2.0) - 2024-11-12
13
+
14
+ - introduce `--backup-deleted-path` argument (#98)
15
+
8
16
  ## [8.1.1](https://github.com/locize/locize-cli/compare/v8.1.0...v8.1.1) - 2024-10-29
9
17
 
10
18
  - improve some error logs
package/bin/locize CHANGED
@@ -359,6 +359,7 @@ program
359
359
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
360
360
  .option('-v, --ver <version>', 'Found namespaces will be matched to this version (default: latest)')
361
361
  .option('-p, --path <path>', `Specify the path that should be used (default: ${process.cwd()})`, process.cwd())
362
+ .option('-B, --backup-deleted-path <path>', 'Saves the segments that will be deleted in this path')
362
363
  .option('-A, --auto-create-path <true|false>', 'This will automatically make sure the --path is created. (default: true)', 'true')
363
364
  .option('-f, --format <json>', 'File format of namespaces (default: json; [nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
364
365
  .option('-s, --skip-empty <true|false>', 'Skips to download empty files (default: false)', 'false')
@@ -423,6 +424,7 @@ program
423
424
  const pathMask = options.pathMask;
424
425
  const unpublished = options.unpublished === 'true';
425
426
  const autoCreatePath = options.autoCreatePath === 'true';
427
+ const backupDeletedPath = options.backupDeletedPath;
426
428
 
427
429
  sync({
428
430
  apiPath: url.parse(getPath).protocol + '//' + url.parse(getPath).host,
@@ -446,7 +448,8 @@ program
446
448
  dry: dry,
447
449
  pathMask: pathMask,
448
450
  unpublished: unpublished,
449
- autoCreatePath: autoCreatePath
451
+ autoCreatePath: autoCreatePath,
452
+ backupDeletedPath: backupDeletedPath
450
453
  });
451
454
  })
452
455
  .on('--help', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "8.1.1",
3
+ "version": "8.3.0",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,17 +9,17 @@
9
9
  "dependencies": {
10
10
  "@js.properties/properties": "0.5.4",
11
11
  "android-string-resource": "2.3.10",
12
- "async": "3.2.5",
12
+ "async": "3.2.6",
13
13
  "cacheable-lookup": "6.1.0",
14
14
  "colors": "1.4.0",
15
15
  "commander": "9.5.0",
16
16
  "csvjson": "5.1.0",
17
- "diff": "5.2.0",
17
+ "diff": "7.0.0",
18
18
  "dotenv": "16.4.5",
19
19
  "flat": "5.0.2",
20
20
  "fluent_conv": "3.3.0",
21
21
  "gettext-converter": "1.3.0",
22
- "https-proxy-agent": "5.0.1",
22
+ "https-proxy-agent": "7.0.5",
23
23
  "ini": "4.1.3",
24
24
  "js-yaml": "4.1.0",
25
25
  "laravelphp": "2.0.4",
@@ -27,7 +27,7 @@
27
27
  "mkdirp": "3.0.1",
28
28
  "node-fetch": "2.7.0",
29
29
  "resx": "2.0.4",
30
- "rimraf": "3.0.2",
30
+ "rimraf": "4.4.1",
31
31
  "strings-file": "0.0.5",
32
32
  "tmexchange": "2.0.5",
33
33
  "xliff": "6.2.1",
@@ -36,12 +36,12 @@
36
36
  "devDependencies": {
37
37
  "eslint": "8.56.0",
38
38
  "gh-release": "7.0.2",
39
- "pkg": "5.8.1"
39
+ "@yao-pkg/pkg": "6.1.1"
40
40
  },
41
41
  "scripts": {
42
42
  "lint": "eslint .",
43
43
  "test": "npm run lint",
44
- "pkg": "mkdir -p ./bins && pkg ./bin/locize --out-path ./bins --targets node18-linux-x64,node18-macos-x64,node18-win-x64,node18-alpine-x64",
44
+ "pkg": "mkdir -p ./bins && pkg ./bin/locize --out-path ./bins --targets node20-linux-x64,node20-macos-x64,node20-win-x64,node20-alpine-x64",
45
45
  "release": "gh-release --assets ./bins/locize-linux,./bins/locize-macos,./bins/locize-win.exe,./bins/locize-alpine",
46
46
  "version": "npm run pkg",
47
47
  "postversion": "git push && npm run release"
@@ -52,7 +52,7 @@
52
52
  ],
53
53
  "author": "adrai",
54
54
  "license": "MIT",
55
- "homepage": "http://locize.com",
55
+ "homepage": "https://locize.com",
56
56
  "repository": {
57
57
  "type": "git",
58
58
  "url": "git+https://github.com/locize/locize-cli.git"
package/request.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const package = require('./package.json');
2
2
  const fetch = require('node-fetch');
3
- const HttpsProxyAgent = require('https-proxy-agent');
3
+ const { HttpsProxyAgent } = require('https-proxy-agent');
4
4
  const https = require('https');
5
5
  const CacheableLookup = require('cacheable-lookup');
6
6
  const cacheable = new CacheableLookup();
@@ -11,6 +11,8 @@ const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY || process.en
11
11
  const isRetriableError = (err) => {
12
12
  return err && err.message && (
13
13
  err.message.indexOf('ETIMEDOUT') > -1 || // on timeout retry
14
+ err.message.indexOf('FetchError') > -1 ||
15
+ err.code === 'ETIMEDOUT' ||
14
16
  // on dns errors
15
17
  err.message.indexOf('ENOTFOUND') > -1 ||
16
18
  err.message.indexOf('ENODATA') > -1 ||
package/sync.js CHANGED
@@ -138,7 +138,7 @@ const compareNamespace = (local, remote, lastModifiedLocal, lastModifiedRemote)
138
138
  };
139
139
 
140
140
  const compareNamespaces = (opt, localNamespaces, cb) => {
141
- async.map(localNamespaces, (ns, clb) => {
141
+ async.mapLimit(localNamespaces, 20, (ns, clb) => {
142
142
  getRemoteNamespace(opt, ns.language, ns.namespace, (err, remoteNamespace, lastModified) => {
143
143
  if (err) return clb(err);
144
144
 
@@ -381,6 +381,28 @@ const checkForMissingLocalNamespaces = (downloads, localNamespaces, opt) => {
381
381
  return localMissingNamespaces;
382
382
  };
383
383
 
384
+ const backupDeleted = (opt, ns, now) => {
385
+ if (opt.dry || ns.diff.toRemove.length === 0) return;
386
+ var m = now.getMonth() + 1;
387
+ if (m < 10) m = `0${m}`;
388
+ var d = now.getDate();
389
+ if (d < 10) d = `0${d}`;
390
+ var h = now.getHours();
391
+ if (h < 10) h = `0${h}`;
392
+ var mi = now.getMinutes();
393
+ if (mi < 10) mi = `0${mi}`;
394
+ var s = now.getSeconds();
395
+ if (s < 10) s = `0${s}`;
396
+ const currentBackupPath = path.join(opt.backupDeletedPath, `${now.getFullYear()}${m}${d}-${h}${mi}${s}`);
397
+ mkdirp.sync(currentBackupPath);
398
+ const removingRemote = ns.diff.toRemove.reduce((prev, k) => {
399
+ prev[k] = ns.remoteContent[k];
400
+ return prev;
401
+ }, {});
402
+ mkdirp.sync(path.join(currentBackupPath, ns.language));
403
+ fs.writeFileSync(path.join(currentBackupPath, ns.language, `${ns.namespace}.json`), JSON.stringify(removingRemote, null, 2));
404
+ };
405
+
384
406
  const handleSync = (opt, remoteLanguages, localNamespaces, cb) => {
385
407
  if (!localNamespaces || localNamespaces.length === 0) {
386
408
  downloadAll(opt, remoteLanguages, (err) => {
@@ -418,6 +440,7 @@ const handleSync = (opt, remoteLanguages, localNamespaces, cb) => {
418
440
  var wasThereSomethingToUpdate = false;
419
441
 
420
442
  function updateComparedNamespaces() {
443
+ const now = new Date();
421
444
  async.eachLimit(compared, Math.round(require('os').cpus().length / 2), (ns, clb) => {
422
445
  if (!cb) {
423
446
  if (ns.diff.toRemove.length > 0) {
@@ -427,6 +450,7 @@ const handleSync = (opt, remoteLanguages, localNamespaces, cb) => {
427
450
  } else {
428
451
  console.log(colors.red(`removing ${ns.diff.toRemove.length} keys in ${ns.language}/${ns.namespace}...`));
429
452
  if (opt.dry) console.log(colors.red(`would remove ${ns.diff.toRemove.join(', ')} in ${ns.language}/${ns.namespace}...`));
453
+ if (!opt.dry && opt.backupDeletedPath) backupDeleted(opt, ns, now);
430
454
  }
431
455
  }
432
456
  if (ns.diff.toRemoveLocally.length > 0) {