locize-cli 7.12.1 → 7.12.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 +13 -0
- package/download.js +4 -2
- package/package.json +7 -7
- package/sync.js +12 -10
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ 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.12.4](https://github.com/locize/locize-cli/compare/v7.12.3...v7.12.4) - 2022-07-20
|
|
9
|
+
|
|
10
|
+
- optimize update handling
|
|
11
|
+
- update dependencies
|
|
12
|
+
|
|
13
|
+
## [7.12.3](https://github.com/locize/locize-cli/compare/v7.12.2...v7.12.3) - 2022-07-20
|
|
14
|
+
|
|
15
|
+
- update dependencies
|
|
16
|
+
|
|
17
|
+
## [7.12.2](https://github.com/locize/locize-cli/compare/v7.12.1...v7.12.2) - 2022-07-12
|
|
18
|
+
|
|
19
|
+
- limit parallel downloads
|
|
20
|
+
|
|
8
21
|
## [7.12.1](https://github.com/locize/locize-cli/compare/v7.12.0...v7.12.1) - 2022-07-12
|
|
9
22
|
|
|
10
23
|
- limit parallel downloads
|
package/download.js
CHANGED
|
@@ -34,7 +34,7 @@ function handleDownload(opt, url, err, res, downloads, cb) {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
async.eachLimit(downloads,
|
|
37
|
+
async.eachLimit(downloads, 20, (download, clb) => {
|
|
38
38
|
const splitted = download.key.split('/');
|
|
39
39
|
const version = splitted[download.isPrivate ? 2 : 1];
|
|
40
40
|
const lng = splitted[download.isPrivate ? 3 : 2];
|
|
@@ -95,7 +95,7 @@ function handleDownload(opt, url, err, res, downloads, cb) {
|
|
|
95
95
|
|
|
96
96
|
function handlePull(opt, toDownload, cb) {
|
|
97
97
|
const url = opt.apiPath + '/pull/' + opt.projectId + '/' + opt.version;
|
|
98
|
-
async.eachLimit(toDownload,
|
|
98
|
+
async.eachLimit(toDownload, 5, (download, clb) => {
|
|
99
99
|
const lng = download.language;
|
|
100
100
|
const namespace = download.namespace;
|
|
101
101
|
|
|
@@ -203,11 +203,13 @@ const download = (opt, cb) => {
|
|
|
203
203
|
'Authorization': opt.apiKey
|
|
204
204
|
} : undefined
|
|
205
205
|
}, (err, res, obj) => {
|
|
206
|
+
obj = obj || [];
|
|
206
207
|
if (res && res.status === 401) {
|
|
207
208
|
opt.apiKey = null;
|
|
208
209
|
request(url, {
|
|
209
210
|
method: 'get',
|
|
210
211
|
}, (err, res, obj) => {
|
|
212
|
+
obj = obj || [];
|
|
211
213
|
if (opt.skipEmpty) obj = obj.filter((d) => d.size > 2);
|
|
212
214
|
handleDownload(opt, url, err, res, obj, cb);
|
|
213
215
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "locize-cli",
|
|
3
|
-
"version": "7.12.
|
|
3
|
+
"version": "7.12.4",
|
|
4
4
|
"description": "locize cli to import locales",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"@js.properties/properties": "0.5.4",
|
|
11
11
|
"android-string-resource": "2.3.4",
|
|
12
12
|
"async": "3.2.4",
|
|
13
|
-
"cacheable-lookup": "6.0
|
|
13
|
+
"cacheable-lookup": "6.1.0",
|
|
14
14
|
"colors": "1.4.0",
|
|
15
|
-
"commander": "9.
|
|
15
|
+
"commander": "9.4.0",
|
|
16
16
|
"csvjson": "5.1.0",
|
|
17
17
|
"diff": "5.1.0",
|
|
18
18
|
"flat": "5.0.2",
|
|
19
19
|
"fluent_conv": "3.1.0",
|
|
20
|
-
"gettext-converter": "1.2.
|
|
20
|
+
"gettext-converter": "1.2.3",
|
|
21
21
|
"https-proxy-agent": "5.0.1",
|
|
22
22
|
"ini": "3.0.0",
|
|
23
23
|
"js-yaml": "4.1.0",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"rimraf": "3.0.2",
|
|
30
30
|
"strings-file": "0.0.5",
|
|
31
31
|
"tmexchange": "2.0.4",
|
|
32
|
-
"xliff": "6.0
|
|
32
|
+
"xliff": "6.1.0",
|
|
33
33
|
"xlsx": "0.18.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"eslint": "8.
|
|
36
|
+
"eslint": "8.21.0",
|
|
37
37
|
"gh-release": "6.0.4",
|
|
38
|
-
"pkg": "5.
|
|
38
|
+
"pkg": "5.8.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"lint": "eslint .",
|
package/sync.js
CHANGED
|
@@ -205,7 +205,7 @@ const downloadAll = (opt, remoteLanguages, omitRef, manipulate, cb) => {
|
|
|
205
205
|
return lng !== opt.referenceLanguage;
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
|
-
async.eachLimit(downloads,
|
|
208
|
+
async.eachLimit(downloads, opt.unpublished ? 5 : 20, (download, clb) => {
|
|
209
209
|
const splitted = download.key.split('/');
|
|
210
210
|
const lng = splitted[download.isPrivate ? 3 : 2];
|
|
211
211
|
const namespace = splitted[download.isPrivate ? 4 : 3];
|
|
@@ -254,14 +254,15 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
|
|
|
254
254
|
ns.diff.toUpdate.forEach((k) => data[k] = ns.content[k]);
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
var keysToSend = Object.keys(data).length;
|
|
258
|
+
if (keysToSend === 0) return cb(null);
|
|
258
259
|
|
|
259
260
|
if (opt.dry) return cb(null);
|
|
260
261
|
|
|
261
262
|
var payloadKeysLimit = 1000;
|
|
262
263
|
|
|
263
|
-
function send(d, clb, isRetrying) {
|
|
264
|
-
request(opt.apiPath + '/update/' + opt.projectId + '/' + opt.version + '/' + lng + '/' + ns.namespace + (
|
|
264
|
+
function send(d, so, clb, isRetrying) {
|
|
265
|
+
request(opt.apiPath + '/update/' + opt.projectId + '/' + opt.version + '/' + lng + '/' + ns.namespace + (so ? '?omitstatsgeneration=true' : ''), {
|
|
265
266
|
method: 'post',
|
|
266
267
|
body: d,
|
|
267
268
|
headers: {
|
|
@@ -270,7 +271,7 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
|
|
|
270
271
|
}, (err, res, obj) => {
|
|
271
272
|
if (err) return clb(err);
|
|
272
273
|
if (res.status === 504 && !isRetrying) {
|
|
273
|
-
return setTimeout(() => send(d, clb, true), 3000);
|
|
274
|
+
return setTimeout(() => send(d, so, clb, true), 3000);
|
|
274
275
|
}
|
|
275
276
|
if (res.status >= 300 && res.status !== 412) {
|
|
276
277
|
if (obj && (obj.errorMessage || obj.message)) {
|
|
@@ -282,7 +283,7 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
|
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
|
|
285
|
-
if (
|
|
286
|
+
if (keysToSend > payloadKeysLimit) {
|
|
286
287
|
var tasks = [];
|
|
287
288
|
var keysInObj = Object.keys(data);
|
|
288
289
|
|
|
@@ -290,7 +291,8 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
|
|
|
290
291
|
(function() {
|
|
291
292
|
var pagedData = {};
|
|
292
293
|
keysInObj.splice(0, payloadKeysLimit).forEach((k) => pagedData[k] = data[k]);
|
|
293
|
-
|
|
294
|
+
var hasMoreKeys = keysInObj.length > 0;
|
|
295
|
+
tasks.push((c) => send(pagedData, hasMoreKeys ? true : shouldOmit, c));
|
|
294
296
|
})();
|
|
295
297
|
}
|
|
296
298
|
|
|
@@ -298,13 +300,13 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
|
|
|
298
300
|
|
|
299
301
|
var finalPagedData = {};
|
|
300
302
|
keysInObj.splice(0, keysInObj.length).forEach((k) => finalPagedData[k] = data[k]);
|
|
301
|
-
tasks.push((c) => send(finalPagedData, c));
|
|
303
|
+
tasks.push((c) => send(finalPagedData, shouldOmit, c));
|
|
302
304
|
|
|
303
305
|
async.series(tasks, cb);
|
|
304
306
|
return;
|
|
305
307
|
}
|
|
306
308
|
|
|
307
|
-
send(data, cb);
|
|
309
|
+
send(data, shouldOmit, cb);
|
|
308
310
|
};
|
|
309
311
|
|
|
310
312
|
const cleanupLanguages = (opt, remoteLanguages) => {
|
|
@@ -509,7 +511,7 @@ const handleSync = (opt, remoteLanguages, localNamespaces, cb) => {
|
|
|
509
511
|
|
|
510
512
|
if (opt.deleteRemoteNamespace && localMissingNamespaces.length > 0) {
|
|
511
513
|
wasThereSomethingToUpdate = true;
|
|
512
|
-
async.eachLimit(localMissingNamespaces,
|
|
514
|
+
async.eachLimit(localMissingNamespaces, 20, (n, clb) => {
|
|
513
515
|
if (opt.dry) {
|
|
514
516
|
console.log(colors.red(`would delete complete namespace ${n.namespace}...`));
|
|
515
517
|
return clb();
|