locize-cli 10.3.2 → 11.0.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 +8 -0
- package/README.md +8 -0
- package/add.js +46 -51
- package/bin/locize +852 -493
- package/combineSubkeyPreprocessor.js +86 -85
- package/convertToDesiredFormat.js +125 -125
- package/convertToFlatFormat.js +154 -154
- package/copyVersion.js +37 -37
- package/createBranch.js +33 -33
- package/deleteBranch.js +52 -52
- package/deleteNamespace.js +20 -20
- package/download.js +286 -284
- package/filterNamespaces.js +5 -5
- package/format.js +101 -101
- package/formats.js +10 -10
- package/get.js +40 -37
- package/getBranches.js +22 -22
- package/getJob.js +22 -22
- package/getProjectStats.js +22 -22
- package/getRemoteLanguages.js +19 -19
- package/getRemoteNamespace.js +60 -56
- package/index.js +1 -1
- package/isValidUuid.js +2 -2
- package/mergeBranch.js +55 -55
- package/migrate.js +147 -149
- package/missing.js +90 -90
- package/package.json +4 -2
- package/parseLocalLanguage.js +110 -110
- package/parseLocalLanguages.js +14 -14
- package/parseLocalReference.js +6 -6
- package/publishVersion.js +34 -34
- package/removeUndefinedFromArrays.js +8 -8
- package/removeVersion.js +34 -34
- package/request.js +32 -32
- package/shouldUnflatten.js +11 -11
- package/sortFlatResources.js +7 -7
- package/sync.js +425 -421
- package/unflatten.js +40 -40
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
|
+
## [11.0.0](https://github.com/locize/locize-cli/compare/v10.4.0...v11.0.0) - 2025-12-10
|
|
9
|
+
|
|
10
|
+
- log/error is shown if cdnType is not defined, because of changing default to 'standard' instead of 'pro'
|
|
11
|
+
- internals: use apiEndpoint instead of addPath, getPath, etc...
|
|
12
|
+
|
|
13
|
+
## [10.4.0](https://github.com/locize/locize-cli/compare/v10.3.2...v10.4.0) - 2025-12-09
|
|
14
|
+
|
|
15
|
+
- introducing --cdn-type option
|
|
8
16
|
|
|
9
17
|
## [10.3.2](https://github.com/locize/locize-cli/compare/v10.3.1...v10.3.2) - 2025-09-03
|
|
10
18
|
|
package/README.md
CHANGED
|
@@ -99,6 +99,8 @@ or
|
|
|
99
99
|
|
|
100
100
|
```sh
|
|
101
101
|
locize download
|
|
102
|
+
locize download --cdn-type standard
|
|
103
|
+
locize download --cdn-type pro
|
|
102
104
|
```
|
|
103
105
|
|
|
104
106
|
or add a format like (json, nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-rails-ns, yaml-nested, yml, yml-rails, yml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties, xcstrings)
|
|
@@ -152,6 +154,8 @@ Add your api-key and your project-id and let's go...
|
|
|
152
154
|
|
|
153
155
|
```sh
|
|
154
156
|
locize sync --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
|
|
157
|
+
locize sync --cdn-type standard --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
|
|
158
|
+
locize sync --cdn-type pro --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
|
|
155
159
|
```
|
|
156
160
|
|
|
157
161
|
or add a format like (json, nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-rails-ns, yaml-nested, yml, yml-rails, yml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties, xcstrings)
|
|
@@ -216,6 +220,8 @@ Add your api-key and your project-id and let's go...
|
|
|
216
220
|
|
|
217
221
|
```sh
|
|
218
222
|
locize save-missing --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
|
|
223
|
+
locize save-missing --cdn-type standard --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
|
|
224
|
+
locize save-missing --cdn-type pro --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
|
|
219
225
|
```
|
|
220
226
|
|
|
221
227
|
or add a format like (json, nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-rails-ns, yaml-nested, yml, yml-rails, yml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties, xcstrings)
|
|
@@ -382,6 +388,7 @@ apiKey = my-api-key-d9de-4f55-9855-a9ef0ed44672
|
|
|
382
388
|
projectId = my-project-id-93e1-442a-ab35-24331fa294ba
|
|
383
389
|
language = en
|
|
384
390
|
version = latest
|
|
391
|
+
cdnType = standard
|
|
385
392
|
```
|
|
386
393
|
|
|
387
394
|
like this you can just work like this:
|
|
@@ -402,6 +409,7 @@ locize add common title "the title of my cool app"
|
|
|
402
409
|
- LOCIZE_API_KEY or LOCIZE_KEY
|
|
403
410
|
- LOCIZE_VERSION or LOCIZE_VER
|
|
404
411
|
- LOCIZE_LANGUAGE or LOCIZE_LANG or LOCIZE_LNG
|
|
412
|
+
- LOCIZE_CDN_TYPE
|
|
405
413
|
|
|
406
414
|
they will also be considered with this priority:
|
|
407
415
|
|
package/add.js
CHANGED
|
@@ -1,110 +1,105 @@
|
|
|
1
|
-
const colors = require('colors')
|
|
2
|
-
const flatten = require('flat')
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const request = require('./request');
|
|
1
|
+
const colors = require('colors')
|
|
2
|
+
const flatten = require('flat')
|
|
3
|
+
const async = require('async')
|
|
4
|
+
const getRemoteLanguages = require('./getRemoteLanguages')
|
|
5
|
+
const request = require('./request')
|
|
7
6
|
|
|
8
7
|
const _add = (opt, cb) => {
|
|
9
|
-
const url = opt.
|
|
8
|
+
const url = `${opt.apiEndpoint}/update/{{projectId}}/{{version}}/{{lng}}/{{ns}}`
|
|
10
9
|
.replace('{{projectId}}', opt.projectId)
|
|
11
10
|
.replace('{{ver}}', opt.version)
|
|
12
11
|
.replace('{{version}}', opt.version)
|
|
13
12
|
.replace('{{language}}', opt.language)
|
|
14
13
|
.replace('{{lng}}', opt.language)
|
|
15
14
|
.replace('{{ns}}', opt.namespace)
|
|
16
|
-
.replace('{{namespace}}', opt.namespace)
|
|
15
|
+
.replace('{{namespace}}', opt.namespace)
|
|
17
16
|
|
|
18
17
|
if (!cb) {
|
|
19
18
|
if (!opt.data && (opt.value === undefined || opt.value === null)) {
|
|
20
|
-
console.log(colors.yellow(`removing ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
19
|
+
console.log(colors.yellow(`removing ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
21
20
|
} else {
|
|
22
|
-
console.log(colors.yellow(`adding ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
21
|
+
console.log(colors.yellow(`adding ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
const data = flatten(opt.data || {})
|
|
27
26
|
if (!opt.data) {
|
|
28
|
-
data[opt.key] = opt.value || null
|
|
27
|
+
data[opt.key] = opt.value || null // null will remove the key
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
request(url, {
|
|
32
31
|
method: 'post',
|
|
33
32
|
headers: {
|
|
34
|
-
|
|
33
|
+
Authorization: opt.apiKey
|
|
35
34
|
},
|
|
36
35
|
body: data
|
|
37
36
|
}, (err, res, obj) => {
|
|
38
37
|
if (err) {
|
|
39
38
|
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}...`))
|
|
39
|
+
console.log(colors.red(`remove failed for ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
41
40
|
} else {
|
|
42
|
-
console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
41
|
+
console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
43
42
|
}
|
|
44
|
-
if (!cb) { console.error(colors.red(err.message)); process.exit(1)
|
|
45
|
-
if (cb) cb(err)
|
|
46
|
-
return
|
|
43
|
+
if (!cb) { console.error(colors.red(err.message)); process.exit(1) }
|
|
44
|
+
if (cb) cb(err)
|
|
45
|
+
return
|
|
47
46
|
}
|
|
48
47
|
if (res.status >= 300 && res.status !== 412) {
|
|
49
48
|
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}...`))
|
|
49
|
+
console.log(colors.red(`remove failed for ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
51
50
|
} else {
|
|
52
|
-
console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
51
|
+
console.log(colors.red(`add failed for ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
53
52
|
}
|
|
54
53
|
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
|
|
54
|
+
if (!cb) { console.error(colors.red((obj.errorMessage || obj.message))); process.exit(1) }
|
|
55
|
+
if (cb) cb(new Error((obj.errorMessage || obj.message)))
|
|
56
|
+
return
|
|
58
57
|
} 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
|
|
58
|
+
if (!cb) { console.error(colors.red(res.statusText + ' (' + res.status + ')')); process.exit(1) }
|
|
59
|
+
if (cb) cb(new Error(res.statusText + ' (' + res.status + ')'))
|
|
60
|
+
return
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
if (!cb) {
|
|
65
64
|
if (!opt.data && (opt.value === undefined || opt.value === null)) {
|
|
66
|
-
console.log(colors.green(`removed ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
65
|
+
console.log(colors.green(`removed ${opt.key} from ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
67
66
|
} else {
|
|
68
|
-
console.log(colors.green(`added ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
67
|
+
console.log(colors.green(`added ${opt.key} to ${opt.version}/${opt.language}/${opt.namespace}...`))
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
if (cb) cb(null)
|
|
72
|
-
})
|
|
73
|
-
}
|
|
70
|
+
if (cb) cb(null)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
74
73
|
|
|
75
74
|
const add = (opt, cb) => {
|
|
76
|
-
if (opt.language) return _add(opt, cb)
|
|
77
|
-
|
|
78
|
-
if (!opt.apiPath) {
|
|
79
|
-
opt.apiPath = url.parse(opt.addPath).protocol + '//' + url.parse(opt.addPath).host;
|
|
80
|
-
}
|
|
75
|
+
if (opt.language) return _add(opt, cb)
|
|
81
76
|
|
|
82
77
|
getRemoteLanguages(opt, (err, lngs) => {
|
|
83
78
|
if (err) {
|
|
84
|
-
if (!cb) { console.error(colors.red(err.message)); process.exit(1)
|
|
85
|
-
if (cb) cb(err)
|
|
86
|
-
return
|
|
79
|
+
if (!cb) { console.error(colors.red(err.message)); process.exit(1) }
|
|
80
|
+
if (cb) cb(err)
|
|
81
|
+
return
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
async.forEachSeries(lngs, (lng, clb) => {
|
|
90
|
-
opt.language = lng
|
|
91
|
-
_add(opt, clb)
|
|
85
|
+
opt.language = lng
|
|
86
|
+
_add(opt, clb)
|
|
92
87
|
}, (err) => {
|
|
93
88
|
if (err) {
|
|
94
|
-
if (!cb) { console.error(colors.red(err.message)); process.exit(1)
|
|
95
|
-
if (cb) cb(err)
|
|
96
|
-
return
|
|
89
|
+
if (!cb) { console.error(colors.red(err.message)); process.exit(1) }
|
|
90
|
+
if (cb) cb(err)
|
|
91
|
+
return
|
|
97
92
|
}
|
|
98
93
|
if (!cb) {
|
|
99
94
|
if (!opt.data && (opt.value === undefined || opt.value === null)) {
|
|
100
|
-
console.log(colors.green(`removed ${opt.namespace}/${opt.key} (${opt.version}) from all languages...`))
|
|
95
|
+
console.log(colors.green(`removed ${opt.namespace}/${opt.key} (${opt.version}) from all languages...`))
|
|
101
96
|
} else {
|
|
102
|
-
console.log(colors.green(`added ${opt.namespace}/${opt.key} (${opt.version}) in all languages...`))
|
|
97
|
+
console.log(colors.green(`added ${opt.namespace}/${opt.key} (${opt.version}) in all languages...`))
|
|
103
98
|
}
|
|
104
99
|
}
|
|
105
|
-
if (cb) cb(null)
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
}
|
|
100
|
+
if (cb) cb(null)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
}
|
|
109
104
|
|
|
110
|
-
module.exports = add
|
|
105
|
+
module.exports = add
|