locize-cli 12.0.6 → 12.0.8

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
+ ## [12.0.8](https://github.com/locize/locize-cli/compare/v12.0.7...v12.0.8) - 2026-03-02
9
+
10
+ - --download option for migrate command
11
+
12
+ ## [12.0.7](https://github.com/locize/locize-cli/compare/v12.0.6...v12.0.7) - 2026-03-02
13
+
14
+ - improve migrate command
15
+
8
16
  ## [12.0.6](https://github.com/locize/locize-cli/compare/v12.0.5...v12.0.6) - 2026-03-02
9
17
 
10
18
  - improve error message when detecting wrong cdnType usage
package/dist/cjs/cli.js CHANGED
@@ -50,7 +50,7 @@ const program = new commander.Command();
50
50
 
51
51
  program
52
52
  .description('The official locize CLI.')
53
- .version('12.0.6'); // This string is replaced with the actual version at build time by rollup
53
+ .version('12.0.8'); // This string is replaced with the actual version at build time by rollup
54
54
  // .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
55
55
  // .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`);
56
56
 
@@ -66,6 +66,7 @@ program
66
66
  .option('-L, --parse-language <true|false>', 'Parse folders as language (default: true)', 'true')
67
67
  .option('-f, --format <json>', 'File format of namespaces (default: json)', 'json')
68
68
  .option('-r, --replace <true|false>', 'This will empty the optionally existing namespace before saving the new translations. (default: false)', 'false')
69
+ .option('-d, --download <true|false>', 'Download all translations after migration. (default: false)', 'false')
69
70
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
70
71
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
71
72
  .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
@@ -109,7 +110,8 @@ program
109
110
  version,
110
111
  parseLanguage: options.parseLanguage === 'true',
111
112
  format: options.format,
112
- replace: options.replace === 'true'
113
+ replace: options.replace === 'true',
114
+ download: options.download === 'true'
113
115
  });
114
116
  })
115
117
  .on('--help', () => {
@@ -8,6 +8,7 @@ var request = require('./request.js');
8
8
  var getRemoteLanguages = require('./getRemoteLanguages.js');
9
9
  var os = require('node:os');
10
10
  var mapLimit = require('./mapLimit.js');
11
+ var download = require('./download.js');
11
12
 
12
13
  const getDirectories = (srcpath) => {
13
14
  return fs.readdirSync(srcpath).filter(function (file) {
@@ -26,6 +27,10 @@ const load = async (namespaces) => {
26
27
  try {
27
28
  const data = await fs.promises.readFile(ns.path, 'utf8');
28
29
  ns.value = flatten(JSON.parse(data));
30
+ // remove all empty strings for migrate (i.e. used via i18next-cli)
31
+ Object.keys(ns.value).forEach((k) => {
32
+ if (ns.value[k] === '') delete ns.value[k];
33
+ });
29
34
  } catch (err) {
30
35
  console.error(colors.red(err.stack));
31
36
  ns.value = {};
@@ -161,6 +166,20 @@ const addLanguage = async (opt, l) => {
161
166
  }
162
167
  };
163
168
 
169
+ const downloadAfterMigrate = async (opt) => {
170
+ console.log(colors.yellow('downloading translations after migration...'));
171
+ await new Promise((resolve) => setTimeout(resolve, 10000));
172
+ await download({
173
+ apiKey: opt.apiKey,
174
+ projectId: opt.projectId,
175
+ apiEndpoint: opt.apiEndpoint,
176
+ version: opt.version,
177
+ path: opt.path,
178
+ format: opt.format,
179
+ cdnType: opt.cdnType
180
+ });
181
+ };
182
+
164
183
  const migrate = async (opt) => {
165
184
  if (opt.format !== 'json') {
166
185
  throw new Error(`Format ${opt.format} is not accepted!`)
@@ -184,6 +203,7 @@ const migrate = async (opt) => {
184
203
  }
185
204
  try {
186
205
  await upload(opt, nss);
206
+ if (opt.download) await downloadAfterMigrate(opt);
187
207
  console.log(colors.green('FINISHED'));
188
208
  } catch (err) {
189
209
  console.error(colors.red(err.stack));
@@ -215,6 +235,7 @@ const migrate = async (opt) => {
215
235
  if (notExistingLanguages.length === 0) {
216
236
  try {
217
237
  await upload(opt, nss);
238
+ if (opt.download) await downloadAfterMigrate(opt);
218
239
  console.log(colors.green('FINISHED'));
219
240
  } catch (err) {
220
241
  console.error(colors.red(err.stack));
@@ -228,6 +249,7 @@ const migrate = async (opt) => {
228
249
  }
229
250
  await new Promise(resolve => setTimeout(resolve, 5000));
230
251
  await upload(opt, nss);
252
+ if (opt.download) await downloadAfterMigrate(opt);
231
253
  console.log(colors.green('FINISHED'));
232
254
  } catch (err) {
233
255
  console.error(colors.red(err.stack));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "12.0.6",
3
+ "version": "12.0.8",
4
4
  "type": "commonjs"
5
5
  }
@@ -39,7 +39,7 @@ async function request (url, options) {
39
39
  }
40
40
 
41
41
  options.headers = options.headers || {};
42
- options.headers['User-Agent'] = `locize-cli/v12.0.6 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
42
+ options.headers['User-Agent'] = `locize-cli/v12.0.8 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
43
43
  options.headers['X-User-Agent'] = options.headers['User-Agent'];
44
44
  if (options.body || options.method !== 'get') options.headers['Content-Type'] = 'application/json';
45
45
  if (options.body) {
package/dist/esm/cli.js CHANGED
@@ -48,7 +48,7 @@ const program = new Command();
48
48
 
49
49
  program
50
50
  .description('The official locize CLI.')
51
- .version('12.0.6'); // This string is replaced with the actual version at build time by rollup
51
+ .version('12.0.8'); // This string is replaced with the actual version at build time by rollup
52
52
  // .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
53
53
  // .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`);
54
54
 
@@ -64,6 +64,7 @@ program
64
64
  .option('-L, --parse-language <true|false>', 'Parse folders as language (default: true)', 'true')
65
65
  .option('-f, --format <json>', 'File format of namespaces (default: json)', 'json')
66
66
  .option('-r, --replace <true|false>', 'This will empty the optionally existing namespace before saving the new translations. (default: false)', 'false')
67
+ .option('-d, --download <true|false>', 'Download all translations after migration. (default: false)', 'false')
67
68
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
68
69
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
69
70
  .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
@@ -107,7 +108,8 @@ program
107
108
  version,
108
109
  parseLanguage: options.parseLanguage === 'true',
109
110
  format: options.format,
110
- replace: options.replace === 'true'
111
+ replace: options.replace === 'true',
112
+ download: options.download === 'true'
111
113
  });
112
114
  })
113
115
  .on('--help', () => {
@@ -6,6 +6,7 @@ import request from './request.js';
6
6
  import getRemoteLanguages from './getRemoteLanguages.js';
7
7
  import os from 'node:os';
8
8
  import mapLimit from './mapLimit.js';
9
+ import download from './download.js';
9
10
 
10
11
  const getDirectories = (srcpath) => {
11
12
  return fs.readdirSync(srcpath).filter(function (file) {
@@ -24,6 +25,10 @@ const load = async (namespaces) => {
24
25
  try {
25
26
  const data = await fs.promises.readFile(ns.path, 'utf8');
26
27
  ns.value = flatten(JSON.parse(data));
28
+ // remove all empty strings for migrate (i.e. used via i18next-cli)
29
+ Object.keys(ns.value).forEach((k) => {
30
+ if (ns.value[k] === '') delete ns.value[k];
31
+ });
27
32
  } catch (err) {
28
33
  console.error(colors.red(err.stack));
29
34
  ns.value = {};
@@ -159,6 +164,20 @@ const addLanguage = async (opt, l) => {
159
164
  }
160
165
  };
161
166
 
167
+ const downloadAfterMigrate = async (opt) => {
168
+ console.log(colors.yellow('downloading translations after migration...'));
169
+ await new Promise((resolve) => setTimeout(resolve, 10000));
170
+ await download({
171
+ apiKey: opt.apiKey,
172
+ projectId: opt.projectId,
173
+ apiEndpoint: opt.apiEndpoint,
174
+ version: opt.version,
175
+ path: opt.path,
176
+ format: opt.format,
177
+ cdnType: opt.cdnType
178
+ });
179
+ };
180
+
162
181
  const migrate = async (opt) => {
163
182
  if (opt.format !== 'json') {
164
183
  throw new Error(`Format ${opt.format} is not accepted!`)
@@ -182,6 +201,7 @@ const migrate = async (opt) => {
182
201
  }
183
202
  try {
184
203
  await upload(opt, nss);
204
+ if (opt.download) await downloadAfterMigrate(opt);
185
205
  console.log(colors.green('FINISHED'));
186
206
  } catch (err) {
187
207
  console.error(colors.red(err.stack));
@@ -213,6 +233,7 @@ const migrate = async (opt) => {
213
233
  if (notExistingLanguages.length === 0) {
214
234
  try {
215
235
  await upload(opt, nss);
236
+ if (opt.download) await downloadAfterMigrate(opt);
216
237
  console.log(colors.green('FINISHED'));
217
238
  } catch (err) {
218
239
  console.error(colors.red(err.stack));
@@ -226,6 +247,7 @@ const migrate = async (opt) => {
226
247
  }
227
248
  await new Promise(resolve => setTimeout(resolve, 5000));
228
249
  await upload(opt, nss);
250
+ if (opt.download) await downloadAfterMigrate(opt);
229
251
  console.log(colors.green('FINISHED'));
230
252
  } catch (err) {
231
253
  console.error(colors.red(err.stack));
@@ -37,7 +37,7 @@ async function request (url, options) {
37
37
  }
38
38
 
39
39
  options.headers = options.headers || {};
40
- options.headers['User-Agent'] = `locize-cli/v12.0.6 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
40
+ options.headers['User-Agent'] = `locize-cli/v12.0.8 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
41
41
  options.headers['X-User-Agent'] = options.headers['User-Agent'];
42
42
  if (options.body || options.method !== 'get') options.headers['Content-Type'] = 'application/json';
43
43
  if (options.body) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "12.0.6",
3
+ "version": "12.0.8",
4
4
  "description": "locize cli to import locales",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",