locize-cli 9.0.2 → 9.1.1
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 +14 -0
- package/bin/locize +45 -1
- package/convertToDesiredFormat.js +4 -2
- package/package.json +1 -1
- package/removeVersion.js +64 -0
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
|
+
## [9.1.1](https://github.com/locize/locize-cli/compare/v9.1.0...v9.1.1) - 2025-05-08
|
|
9
|
+
|
|
10
|
+
- xlsx: fix for longer namespace names
|
|
11
|
+
|
|
12
|
+
## [9.1.0](https://github.com/locize/locize-cli/compare/v9.0.2...v9.1.0) - 2025-05-07
|
|
13
|
+
|
|
14
|
+
- introduce `remove-version` command
|
|
15
|
+
|
|
8
16
|
## [9.0.2](https://github.com/locize/locize-cli/compare/v9.0.1...v9.0.2) - 2025-04-25
|
|
9
17
|
|
|
10
18
|
- Hint: `Using the "--auto-translate true" option together with the "--reference-language-only false" option might result in inconsistent target language translations (automatic translation vs. what is sent direcly to locize).`
|
package/README.md
CHANGED
|
@@ -237,6 +237,20 @@ locize publish-version --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --projec
|
|
|
237
237
|
```
|
|
238
238
|
|
|
239
239
|
|
|
240
|
+
## Delete version
|
|
241
|
+
|
|
242
|
+
*It uses this [API endpoint](https://www.locize.com/docs/api#remove-version).*
|
|
243
|
+
|
|
244
|
+
### Step 1: execute
|
|
245
|
+
|
|
246
|
+
Add your api-key and your project-id and let's go...
|
|
247
|
+
|
|
248
|
+
```sh
|
|
249
|
+
# this will remove version tmp-ver
|
|
250
|
+
locize remove-version tmp-ver --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
|
|
240
254
|
## Delete namespace
|
|
241
255
|
### Step 1: execute
|
|
242
256
|
|
package/bin/locize
CHANGED
|
@@ -22,6 +22,7 @@ const get = require('../get');
|
|
|
22
22
|
const sync = require('../sync');
|
|
23
23
|
const missing = require('../missing');
|
|
24
24
|
const copyVersion = require('../copyVersion');
|
|
25
|
+
const removeVersion = require('../removeVersion.js');
|
|
25
26
|
const publishVersion = require('../publishVersion');
|
|
26
27
|
const deleteNamespace = require('../deleteNamespace');
|
|
27
28
|
const formatFn = require('../format');
|
|
@@ -588,7 +589,50 @@ program
|
|
|
588
589
|
console.log();
|
|
589
590
|
console.log(' $ locize copy-version latest"');
|
|
590
591
|
console.log(' $ locize copy-version latest --ver production"');
|
|
591
|
-
console.log(' $ locize copy-version latest
|
|
592
|
+
console.log(' $ locize copy-version latest --api-key <apiKey> --project-id <projectId> --ver <version>');
|
|
593
|
+
console.log();
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
program
|
|
597
|
+
.command('remove-version <version>')
|
|
598
|
+
.alias('rv')
|
|
599
|
+
.description('remove version')
|
|
600
|
+
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
601
|
+
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
602
|
+
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
603
|
+
.action((version, options) => {
|
|
604
|
+
try {
|
|
605
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
|
|
606
|
+
} catch (e) {}
|
|
607
|
+
|
|
608
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
|
|
609
|
+
if (!apiKey) {
|
|
610
|
+
console.error(' error: missing required argument `apiKey`');
|
|
611
|
+
process.exit(1);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID;
|
|
616
|
+
if (!projectId) {
|
|
617
|
+
console.error(' error: missing required argument `projectId`');
|
|
618
|
+
process.exit(1);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const getPath = options.getPath || config.getPath || getPathUrl;
|
|
623
|
+
|
|
624
|
+
removeVersion({
|
|
625
|
+
apiKey: apiKey,
|
|
626
|
+
projectId: projectId,
|
|
627
|
+
apiPath: url.parse(getPath).protocol + '//' + url.parse(getPath).host,
|
|
628
|
+
version: version
|
|
629
|
+
});
|
|
630
|
+
})
|
|
631
|
+
.on('--help', () => {
|
|
632
|
+
console.log(' Examples:');
|
|
633
|
+
console.log();
|
|
634
|
+
console.log(' $ locize remove-version tmp-ver"');
|
|
635
|
+
console.log(' $ locize remove-version tmp-ver --api-key <apiKey> --project-id <projectId>');
|
|
592
636
|
console.log();
|
|
593
637
|
});
|
|
594
638
|
|
|
@@ -130,8 +130,10 @@ const convertToDesiredFormat = (
|
|
|
130
130
|
|
|
131
131
|
const worksheet = xlsx.utils.json_to_sheet(js2XlsxData);
|
|
132
132
|
const workbook = xlsx.utils.book_new();
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
let workSheetName = namespace;
|
|
134
|
+
if (workSheetName.length > 31) workSheetName = workSheetName.substring(0, 31);
|
|
135
|
+
workbook.SheetNames.push(workSheetName);
|
|
136
|
+
workbook.Sheets[workSheetName] = worksheet;
|
|
135
137
|
|
|
136
138
|
const wbout = xlsx.write(workbook, { type: 'buffer' });
|
|
137
139
|
|
package/package.json
CHANGED
package/removeVersion.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const colors = require('colors');
|
|
2
|
+
const request = require('./request');
|
|
3
|
+
const getJob = require('./getJob');
|
|
4
|
+
|
|
5
|
+
const removeVersion = (opt, cb) => {
|
|
6
|
+
request(opt.apiPath + '/version/' + opt.projectId + '/' + opt.version, {
|
|
7
|
+
method: 'delete',
|
|
8
|
+
headers: {
|
|
9
|
+
'Authorization': opt.apiKey
|
|
10
|
+
}
|
|
11
|
+
}, (err, res, obj) => {
|
|
12
|
+
if (err || (obj && (obj.errorMessage || obj.message))) {
|
|
13
|
+
if (!cb) console.log(colors.red(`remove failed for version ${opt.version}...`));
|
|
14
|
+
|
|
15
|
+
if (err) {
|
|
16
|
+
if (!cb) { console.error(colors.red(err.message)); process.exit(1); }
|
|
17
|
+
if (cb) cb(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (obj && (obj.errorMessage || obj.message)) {
|
|
21
|
+
if (!cb) { console.error(colors.red((obj.errorMessage || obj.message))); process.exit(1); }
|
|
22
|
+
if (cb) cb(new Error((obj.errorMessage || obj.message)));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (res.status >= 300) {
|
|
27
|
+
if (!cb) { console.error(colors.red(res.statusText + ' (' + res.status + ')')); process.exit(1); }
|
|
28
|
+
if (cb) cb(new Error(res.statusText + ' (' + res.status + ')'));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!obj || !obj.jobId) {
|
|
33
|
+
if (!cb) { console.error(colors.red('No jobId! Something went wrong!')); process.exit(1); }
|
|
34
|
+
if (cb) cb(new Error('No jobId! Something went wrong!'));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
(function waitForJob() {
|
|
39
|
+
getJob(opt, obj.jobId, (err, job) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
if (!cb) { console.error(colors.red(err.message)); process.exit(1); }
|
|
42
|
+
if (cb) cb(err);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (job && !job.timeouted) {
|
|
47
|
+
setTimeout(waitForJob, 2000);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (job && job.timeouted) {
|
|
52
|
+
if (!cb) { console.error(colors.red('Job timeouted!')); process.exit(1); }
|
|
53
|
+
if (cb) cb(new Error('Job timeouted!'));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!cb) console.log(colors.green(`remove version ${opt.version} succesfully requested`));
|
|
58
|
+
if (cb) cb(null);
|
|
59
|
+
});
|
|
60
|
+
})();
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = removeVersion;
|