locize-cli 10.1.0 → 10.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 +4 -0
- package/createBranch.js +48 -28
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ 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.1.1](https://github.com/locize/locize-cli/compare/v10.1.0...v10.1.1) - 2025-07-12
|
|
9
|
+
|
|
10
|
+
- create-branch: nicer feedback, if branch already exists
|
|
11
|
+
|
|
8
12
|
## [10.1.0](https://github.com/locize/locize-cli/compare/v10.0.3...v10.1.0) - 2025-07-10
|
|
9
13
|
|
|
10
14
|
- introduce branching features
|
package/createBranch.js
CHANGED
|
@@ -1,40 +1,60 @@
|
|
|
1
1
|
const colors = require('colors');
|
|
2
2
|
const request = require('./request');
|
|
3
|
+
const getBranches = require('./getBranches');
|
|
4
|
+
|
|
5
|
+
const handleError = (err, cb) => {
|
|
6
|
+
if (!cb && err) {
|
|
7
|
+
console.error(colors.red(err.stack));
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
if (cb) cb(err);
|
|
11
|
+
};
|
|
3
12
|
|
|
4
13
|
const createBranch = (opt, cb) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
getBranches(opt, (err, branches) => {
|
|
15
|
+
if (err) return handleError(err, cb);
|
|
16
|
+
|
|
17
|
+
const b = branches.find((br) => br.name === opt.branch);
|
|
18
|
+
if (b) {
|
|
19
|
+
if (!cb) console.log(colors.green('creating branch "' + b.name + '" (' + b.id + ') not necessary, because already existing'));
|
|
20
|
+
if (cb) cb(null, b);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
request(opt.apiPath + '/branch/create/' + opt.projectId + '/' + opt.version, {
|
|
25
|
+
method: 'post',
|
|
26
|
+
headers: {
|
|
27
|
+
'Authorization': opt.apiKey
|
|
28
|
+
},
|
|
29
|
+
body: { name: opt.branch }
|
|
30
|
+
}, (err, res, obj) => {
|
|
31
|
+
if (err || (obj && (obj.errorMessage || obj.message))) {
|
|
32
|
+
if (!cb) console.log(colors.red('creating branch failed...'));
|
|
14
33
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
if (err) {
|
|
35
|
+
if (!cb) { console.error(colors.red(err.message)); process.exit(1); }
|
|
36
|
+
if (cb) cb(err);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (obj && (obj.errorMessage || obj.message)) {
|
|
40
|
+
if (!cb) { console.error(colors.red((obj.errorMessage || obj.message))); process.exit(1); }
|
|
41
|
+
if (cb) cb(new Error((obj.errorMessage || obj.message)));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (res.status === 404) {
|
|
46
|
+
if (!cb) { console.error(colors.yellow(res.statusText + ' (' + res.status + ')')); process.exit(1); }
|
|
47
|
+
if (cb) cb(null, null);
|
|
18
48
|
return;
|
|
19
49
|
}
|
|
20
|
-
if (
|
|
21
|
-
if (!cb) { console.error(colors.red((
|
|
22
|
-
if (cb) cb(new Error((
|
|
50
|
+
if (res.status >= 300) {
|
|
51
|
+
if (!cb) { console.error(colors.red(res.statusText + ' (' + res.status + ')')); process.exit(1); }
|
|
52
|
+
if (cb) cb(new Error(res.statusText + ' (' + res.status + ')'));
|
|
23
53
|
return;
|
|
24
54
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (cb) cb(null, null);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (res.status >= 300) {
|
|
32
|
-
if (!cb) { console.error(colors.red(res.statusText + ' (' + res.status + ')')); process.exit(1); }
|
|
33
|
-
if (cb) cb(new Error(res.statusText + ' (' + res.status + ')'));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (!cb) console.log(colors.green('creating branch "' + obj.name + '" (' + obj.id + ') successful'));
|
|
37
|
-
if (cb) cb(null, obj);
|
|
55
|
+
if (!cb) console.log(colors.green('creating branch "' + obj.name + '" (' + obj.id + ') successful'));
|
|
56
|
+
if (cb) cb(null, obj);
|
|
57
|
+
});
|
|
38
58
|
});
|
|
39
59
|
};
|
|
40
60
|
|