locize-cli 10.3.2 → 10.4.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,9 @@ 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
+ ## [10.4.0](https://github.com/locize/locize-cli/compare/v10.3.2...v10.4.0) - 2025-12-09
9
+
10
+ - introducing --cdn-type option
8
11
 
9
12
  ## [10.3.2](https://github.com/locize/locize-cli/compare/v10.3.1...v10.3.2) - 2025-09-03
10
13
 
package/README.md CHANGED
@@ -382,6 +382,7 @@ apiKey = my-api-key-d9de-4f55-9855-a9ef0ed44672
382
382
  projectId = my-project-id-93e1-442a-ab35-24331fa294ba
383
383
  language = en
384
384
  version = latest
385
+ cdnType = standard
385
386
  ```
386
387
 
387
388
  like this you can just work like this:
@@ -402,6 +403,7 @@ locize add common title "the title of my cool app"
402
403
  - LOCIZE_API_KEY or LOCIZE_KEY
403
404
  - LOCIZE_VERSION or LOCIZE_VER
404
405
  - LOCIZE_LANGUAGE or LOCIZE_LANG or LOCIZE_LNG
406
+ - LOCIZE_CDN_TYPE
405
407
 
406
408
  they will also be considered with this priority:
407
409
 
package/add.js CHANGED
@@ -1,11 +1,12 @@
1
- const colors = require('colors');
2
- const flatten = require('flat');
3
- const url = require('url');
4
- const async = require('async');
5
- const getRemoteLanguages = require('./getRemoteLanguages');
6
- const request = require('./request');
1
+ const colors = require('colors')
2
+ const flatten = require('flat')
3
+ const { URL } = require('url')
4
+ const async = require('async')
5
+ const getRemoteLanguages = require('./getRemoteLanguages')
6
+ const request = require('./request')
7
7
 
8
8
  const _add = (opt, cb) => {
9
+ if (!opt.addPath) opt.addPath = `${opt.apiPath}/update/{{projectId}}/{{version}}/{{lng}}/{{ns}}`
9
10
  const url = opt.addPath
10
11
  .replace('{{projectId}}', opt.projectId)
11
12
  .replace('{{ver}}', opt.version)
@@ -13,98 +14,99 @@ const _add = (opt, cb) => {
13
14
  .replace('{{language}}', opt.language)
14
15
  .replace('{{lng}}', opt.language)
15
16
  .replace('{{ns}}', opt.namespace)
16
- .replace('{{namespace}}', opt.namespace);
17
+ .replace('{{namespace}}', opt.namespace)
17
18
 
18
19
  if (!cb) {
19
20
  if (!opt.data && (opt.value === undefined || opt.value === null)) {
20
- console.log(colors.yellow(`removing ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`));
21
+ console.log(colors.yellow(`removing ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
21
22
  } else {
22
- console.log(colors.yellow(`adding ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`));
23
+ console.log(colors.yellow(`adding ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
23
24
  }
24
25
  }
25
26
 
26
- var data = flatten(opt.data || {});
27
+ const data = flatten(opt.data || {})
27
28
  if (!opt.data) {
28
- data[opt.key] = opt.value || null; // null will remove the key
29
+ data[opt.key] = opt.value || null // null will remove the key
29
30
  }
30
31
 
31
32
  request(url, {
32
33
  method: 'post',
33
34
  headers: {
34
- 'Authorization': opt.apiKey
35
+ Authorization: opt.apiKey
35
36
  },
36
37
  body: data
37
38
  }, (err, res, obj) => {
38
39
  if (err) {
39
40
  if (!opt.data && (opt.value === undefined || opt.value === null)) {
40
- console.log(colors.red(`remove failed for ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`));
41
+ console.log(colors.red(`remove failed for ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
41
42
  } else {
42
- console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`));
43
+ console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
43
44
  }
44
- if (!cb) { console.error(colors.red(err.message)); process.exit(1); }
45
- if (cb) cb(err);
46
- return;
45
+ if (!cb) { console.error(colors.red(err.message)); process.exit(1) }
46
+ if (cb) cb(err)
47
+ return
47
48
  }
48
49
  if (res.status >= 300 && res.status !== 412) {
49
50
  if (!opt.data && (opt.value === undefined || opt.value === null)) {
50
- console.log(colors.red(`remove failed for ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`));
51
+ console.log(colors.red(`remove failed for ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
51
52
  } else {
52
- console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`));
53
+ console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
53
54
  }
54
55
  if (obj && (obj.errorMessage || obj.message)) {
55
- if (!cb) { console.error(colors.red((obj.errorMessage || obj.message))); process.exit(1); }
56
- if (cb) cb(new Error((obj.errorMessage || obj.message)));
57
- return;
56
+ if (!cb) { console.error(colors.red((obj.errorMessage || obj.message))); process.exit(1) }
57
+ if (cb) cb(new Error((obj.errorMessage || obj.message)))
58
+ return
58
59
  } else {
59
- if (!cb) { console.error(colors.red(res.statusText + ' (' + res.status + ')')); process.exit(1); }
60
- if (cb) cb(new Error(res.statusText + ' (' + res.status + ')'));
61
- return;
60
+ if (!cb) { console.error(colors.red(res.statusText + ' (' + res.status + ')')); process.exit(1) }
61
+ if (cb) cb(new Error(res.statusText + ' (' + res.status + ')'))
62
+ return
62
63
  }
63
64
  }
64
65
  if (!cb) {
65
66
  if (!opt.data && (opt.value === undefined || opt.value === null)) {
66
- console.log(colors.green(`removed ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`));
67
+ console.log(colors.green(`removed ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
67
68
  } else {
68
- console.log(colors.green(`added ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`));
69
+ console.log(colors.green(`added ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
69
70
  }
70
71
  }
71
- if (cb) cb(null);
72
- });
73
- };
72
+ if (cb) cb(null)
73
+ })
74
+ }
74
75
 
75
76
  const add = (opt, cb) => {
76
- if (opt.language) return _add(opt, cb);
77
+ if (opt.language) return _add(opt, cb)
77
78
 
78
79
  if (!opt.apiPath) {
79
- opt.apiPath = url.parse(opt.addPath).protocol + '//' + url.parse(opt.addPath).host;
80
+ const parsed = new URL(opt.addPath)
81
+ opt.apiPath = parsed.protocol + '//' + parsed.host
80
82
  }
81
83
 
82
84
  getRemoteLanguages(opt, (err, lngs) => {
83
85
  if (err) {
84
- if (!cb) { console.error(colors.red(err.message)); process.exit(1); }
85
- if (cb) cb(err);
86
- return;
86
+ if (!cb) { console.error(colors.red(err.message)); process.exit(1) }
87
+ if (cb) cb(err)
88
+ return
87
89
  }
88
90
 
89
91
  async.forEachSeries(lngs, (lng, clb) => {
90
- opt.language = lng;
91
- _add(opt, clb);
92
+ opt.language = lng
93
+ _add(opt, clb)
92
94
  }, (err) => {
93
95
  if (err) {
94
- if (!cb) { console.error(colors.red(err.message)); process.exit(1); }
95
- if (cb) cb(err);
96
- return;
96
+ if (!cb) { console.error(colors.red(err.message)); process.exit(1) }
97
+ if (cb) cb(err)
98
+ return
97
99
  }
98
100
  if (!cb) {
99
101
  if (!opt.data && (opt.value === undefined || opt.value === null)) {
100
- console.log(colors.green(`removed ${opt.namespace}/${opt.key} (${opt.version}) from all languages...`));
102
+ console.log(colors.green(`removed ${opt.namespace}/${opt.key} (${opt.version}) from all languages...`))
101
103
  } else {
102
- console.log(colors.green(`added ${opt.namespace}/${opt.key} (${opt.version}) in all languages...`));
104
+ console.log(colors.green(`added ${opt.namespace}/${opt.key} (${opt.version}) in all languages...`))
103
105
  }
104
106
  }
105
- if (cb) cb(null);
106
- });
107
- });
108
- };
107
+ if (cb) cb(null)
108
+ })
109
+ })
110
+ }
109
111
 
110
- module.exports = add;
112
+ module.exports = add