-
Notifications
You must be signed in to change notification settings - Fork 3
/
crowdin-helper.js
executable file
·81 lines (65 loc) · 3.28 KB
/
crowdin-helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env node
// node crowdin-helper [options] [command]
// COMMANDS
// up - Uploads source file to the current branch in crowdin (evaluated from GIT branch)
// down - Downloads translations from the current branch in crowdin (evaluated from GIT branch)
// (it will fail if the last commit in source file from the master is not merged
// to the current branch)
// down --force - Same as previous, but without master merge checking (less safe, not recommended)
// progress - Shows progress status on current branch. Exit with error if incomplete
// pre-push - Checks if source file differs from master and if yes, uploads source file to crowdin
// purge - Delete all unused branches from crowdin (each branch without relevant GIT branch)
// auto-translate - Trigger auto-translation (from TM, with perfect-match)
//
// OPTIONS
// -c, --config - Path to config file
// -b, --branch - Set branch name to work on (instead of taking current one from git)
const configOptionMatches = process.argv.join(' ').match(/((?:\-c|\-\-config)[\s=]+)(\S*)/i);
require('./lib/utilities/config-manager').init(configOptionMatches && configOptionMatches[2]);
const downloadTranslations = require('./lib/commands/download-translations');
const uploadSources = require('./lib/commands/upload-sources');
const checkProgressOnBranch = require('./lib/commands/check-progress-on-branch');
const triggerAutoTranslation = require('./lib/commands/trigger-auto-translation');
const deleteOldBranches = require('./lib/commands/delete-old-branches');
switch(process.argv[2]) {
case 'purge':
deleteOldBranches();
break;
case 'up':
uploadSources();
break;
case 'down':
const shouldIgnoreUnmergedMaster = process.argv.includes('--force');
if (shouldIgnoreUnmergedMaster) {
console.log('Force mode: skip checking unmerged master');
}
downloadTranslations(shouldIgnoreUnmergedMaster);
break;
case 'progress':
checkProgressOnBranch();
break;
case 'auto-translate':
triggerAutoTranslation();
break;
case 'pre-push':
uploadSources(true);
break;
default:
console.log(`
Crowdin Helper
node crowdin-helper [options] [command]
COMMANDS
up - Uploads source file to the current branch in crowdin (evaluated from GIT branch)
down - Downloads translations from the current branch in crowdin (evaluated from GIT branch)
(it will fail if the last commit in source file from the master is not merged
to the current branch)
down --force - Same as previous, but without master merge checking (less safe, not recommended)
progress - Shows progress status on current branch. Exit with error if incomplete
pre-push - Checks if source file differs from master and if yes, uploads source file to crowdin
purge - Delete all unused branches from crowdin (each branch without relevant GIT branch)
auto-translate - Trigger auto-translation (from TM, with perfect-match)
OPTIONS
-c, --config - Path to config file
-b, --branch - Set branch name to work on (instead of taking current one from git)
`);
}