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/bin/locize
CHANGED
|
@@ -1,47 +1,63 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const program = require('commander')
|
|
4
|
-
const colors = require('colors')
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const fs = require('fs')
|
|
7
|
-
const os = require('os')
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const configInHome = path.join(os.homedir(), '.locize')
|
|
12
|
-
const configInWorkingDirectory = path.join(process.cwd(), '.locize')
|
|
13
|
-
const dotEnvFile = path.join(process.cwd(), '.env')
|
|
14
|
-
if (fs.existsSync(dotEnvFile)) require('dotenv').config()
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
3
|
+
const program = require('commander')
|
|
4
|
+
const colors = require('colors')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const fs = require('fs')
|
|
7
|
+
const os = require('os')
|
|
8
|
+
const ini = require('ini')
|
|
9
|
+
const { URL } = require('url')
|
|
10
|
+
|
|
11
|
+
const configInHome = path.join(os.homedir(), '.locize')
|
|
12
|
+
const configInWorkingDirectory = path.join(process.cwd(), '.locize')
|
|
13
|
+
const dotEnvFile = path.join(process.cwd(), '.env')
|
|
14
|
+
if (fs.existsSync(dotEnvFile)) require('dotenv').config()
|
|
15
|
+
// TODO: change this to 'standard' on next major version
|
|
16
|
+
const defaultCdnType = 'pro'
|
|
17
|
+
// TODO: remove this on next major version
|
|
18
|
+
const getApiPath = (cdnType) => `https://api${(cdnType || defaultCdnType) === 'standard' ? '.lite' : ''}.locize.app`
|
|
19
|
+
const getAddPath = (cdnType) => `${getApiPath(cdnType || defaultCdnType)}/update/{{projectId}}/{{version}}/{{lng}}/{{ns}}`
|
|
20
|
+
const getGetPath = (cdnType) => `${getApiPath(cdnType || defaultCdnType)}/{{projectId}}/{{version}}/{{lng}}/{{ns}}`
|
|
21
|
+
const addPathUrl = getAddPath(defaultCdnType)
|
|
22
|
+
const getPathUrl = getGetPath(defaultCdnType)
|
|
23
|
+
|
|
24
|
+
const fixApiPath = (p, cdnType) => {
|
|
25
|
+
if (p.indexOf('.locize.app') < 0) return p
|
|
26
|
+
if (p.indexOf('.lite.locize.app') > 0) {
|
|
27
|
+
return p.replace('.lite.locize.app', `${(cdnType || defaultCdnType) === 'standard' ? '.lite' : ''}.locize.app`)
|
|
28
|
+
} else {
|
|
29
|
+
return p.replace('.locize.app', `${(cdnType || defaultCdnType) === 'standard' ? '.lite' : ''}.locize.app`)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const defaultApiEndpoint = fixApiPath('https://api.locize.app', defaultCdnType)
|
|
33
|
+
|
|
34
|
+
const migrate = require('../migrate')
|
|
35
|
+
const add = require('../add')
|
|
36
|
+
const download = require('../download')
|
|
37
|
+
const get = require('../get')
|
|
38
|
+
const sync = require('../sync')
|
|
39
|
+
const missing = require('../missing')
|
|
40
|
+
const copyVersion = require('../copyVersion')
|
|
41
|
+
const removeVersion = require('../removeVersion.js')
|
|
42
|
+
const publishVersion = require('../publishVersion')
|
|
43
|
+
const deleteNamespace = require('../deleteNamespace')
|
|
44
|
+
const formatFn = require('../format')
|
|
45
|
+
const createBranch = require('../createBranch')
|
|
46
|
+
const mergeBranch = require('../mergeBranch')
|
|
47
|
+
const deleteBranch = require('../deleteBranch')
|
|
48
|
+
|
|
49
|
+
let config = {}
|
|
34
50
|
try {
|
|
35
|
-
config = ini.parse(fs.readFileSync(configInWorkingDirectory, 'utf-8'))
|
|
51
|
+
config = ini.parse(fs.readFileSync(configInWorkingDirectory, 'utf-8'))
|
|
36
52
|
} catch (e) {
|
|
37
53
|
try {
|
|
38
|
-
config = ini.parse(fs.readFileSync(configInHome, 'utf-8'))
|
|
54
|
+
config = ini.parse(fs.readFileSync(configInHome, 'utf-8'))
|
|
39
55
|
} catch (e) {}
|
|
40
56
|
}
|
|
41
57
|
|
|
42
58
|
program
|
|
43
59
|
.version(require('../package.json').version)
|
|
44
|
-
|
|
60
|
+
// .option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`);
|
|
45
61
|
// .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`);
|
|
46
62
|
|
|
47
63
|
program
|
|
@@ -56,55 +72,79 @@ program
|
|
|
56
72
|
.option('-L, --parse-language <true|false>', 'Parse folders as language (default: true)', 'true')
|
|
57
73
|
.option('-f, --format <json>', 'File format of namespaces (default: json)', 'json')
|
|
58
74
|
.option('-r, --replace <true|false>', 'This will empty the optionally existing namespace before saving the new translations. (default: false)', 'false')
|
|
75
|
+
// TODO: remove this on next major version
|
|
76
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
77
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
59
78
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
79
|
+
.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})`)
|
|
60
80
|
.action((options) => {
|
|
61
81
|
try {
|
|
62
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
82
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
63
83
|
} catch (e) {}
|
|
64
84
|
|
|
65
|
-
const
|
|
85
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
86
|
+
// TODO: remove this on next major version
|
|
87
|
+
if (!cdnType) {
|
|
88
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
89
|
+
}
|
|
90
|
+
// TODO: remove this on next major version
|
|
91
|
+
let addPath = options.addPath || config.addPath
|
|
92
|
+
if (addPath) {
|
|
93
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
94
|
+
}
|
|
95
|
+
// TODO: remove this on next major version
|
|
96
|
+
if (!addPath) {
|
|
97
|
+
addPath = getAddPath(cdnType) || addPathUrl
|
|
98
|
+
} else if (cdnType) {
|
|
99
|
+
addPath = fixApiPath(addPath, cdnType)
|
|
100
|
+
}
|
|
66
101
|
|
|
67
|
-
|
|
102
|
+
// TODO: remove and adjust this on next major version
|
|
103
|
+
const apiPath = new URL(addPath)
|
|
104
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
105
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
106
|
+
|
|
107
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
68
108
|
if (!apiKey) {
|
|
69
|
-
console.error(' error: missing required argument `apiKey`')
|
|
70
|
-
process.exit(1)
|
|
71
|
-
return
|
|
109
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
110
|
+
process.exit(1)
|
|
111
|
+
return
|
|
72
112
|
}
|
|
73
113
|
|
|
74
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
114
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
75
115
|
if (!projectId) {
|
|
76
|
-
console.error(' error: missing required argument `projectId`')
|
|
77
|
-
process.exit(1)
|
|
78
|
-
return
|
|
116
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
117
|
+
process.exit(1)
|
|
118
|
+
return
|
|
79
119
|
}
|
|
80
120
|
|
|
81
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
121
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
82
122
|
|
|
83
123
|
if (!path.isAbsolute(options.path)) {
|
|
84
|
-
options.path = path.join(process.cwd(), options.path)
|
|
124
|
+
options.path = path.join(process.cwd(), options.path)
|
|
85
125
|
}
|
|
86
126
|
|
|
87
127
|
migrate({
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
128
|
+
cdnType: cdnType || defaultCdnType,
|
|
129
|
+
apiKey,
|
|
130
|
+
projectId,
|
|
131
|
+
apiEndpoint,
|
|
92
132
|
path: options.path,
|
|
93
133
|
language: options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG,
|
|
94
|
-
version
|
|
134
|
+
version,
|
|
95
135
|
parseLanguage: options.parseLanguage === 'true',
|
|
96
136
|
format: options.format,
|
|
97
137
|
replace: options.replace === 'true'
|
|
98
|
-
})
|
|
138
|
+
})
|
|
99
139
|
})
|
|
100
140
|
.on('--help', () => {
|
|
101
|
-
console.log(' Examples:')
|
|
102
|
-
console.log()
|
|
103
|
-
console.log(' $ locize migrate')
|
|
104
|
-
console.log(' $ locize migrate --path ./en --language en')
|
|
105
|
-
console.log(' $ locize migrate --api-key <apiKey> --project-id <projectId> --path ./en --language en')
|
|
106
|
-
console.log()
|
|
107
|
-
})
|
|
141
|
+
console.log(' Examples:')
|
|
142
|
+
console.log()
|
|
143
|
+
console.log(' $ locize migrate')
|
|
144
|
+
console.log(' $ locize migrate --path ./en --language en')
|
|
145
|
+
console.log(' $ locize migrate --api-key <apiKey> --project-id <projectId> --path ./en --language en')
|
|
146
|
+
console.log()
|
|
147
|
+
})
|
|
108
148
|
|
|
109
149
|
program
|
|
110
150
|
.command('add <namespace> <key> <value>')
|
|
@@ -114,56 +154,81 @@ program
|
|
|
114
154
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
115
155
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
116
156
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
157
|
+
// TODO: remove this on next major version
|
|
158
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
159
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
117
160
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
161
|
+
.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})`)
|
|
118
162
|
.action((namespace, key, value, options) => {
|
|
119
163
|
try {
|
|
120
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
164
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
121
165
|
} catch (e) {}
|
|
122
166
|
|
|
123
|
-
const
|
|
167
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
168
|
+
// TODO: remove this on next major version
|
|
169
|
+
if (!cdnType) {
|
|
170
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
171
|
+
}
|
|
172
|
+
// TODO: remove this on next major version
|
|
173
|
+
let addPath = options.addPath || config.addPath
|
|
174
|
+
if (addPath) {
|
|
175
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
176
|
+
}
|
|
177
|
+
// TODO: remove this on next major version
|
|
178
|
+
if (!addPath) {
|
|
179
|
+
addPath = getAddPath(cdnType) || addPathUrl
|
|
180
|
+
} else if (cdnType) {
|
|
181
|
+
addPath = fixApiPath(addPath, cdnType)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// TODO: remove and adjust this on next major version
|
|
185
|
+
const apiPath = new URL(addPath)
|
|
186
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
187
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
188
|
+
|
|
189
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
124
190
|
if (!apiKey) {
|
|
125
|
-
console.error(' error: missing required argument `apiKey`')
|
|
126
|
-
process.exit(1)
|
|
127
|
-
return
|
|
191
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
192
|
+
process.exit(1)
|
|
193
|
+
return
|
|
128
194
|
}
|
|
129
195
|
|
|
130
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
196
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
131
197
|
if (!projectId) {
|
|
132
|
-
console.error(' error: missing required argument `projectId`')
|
|
133
|
-
process.exit(1)
|
|
134
|
-
return
|
|
198
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
199
|
+
process.exit(1)
|
|
200
|
+
return
|
|
135
201
|
}
|
|
136
202
|
|
|
137
|
-
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
203
|
+
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
138
204
|
if (!language) {
|
|
139
|
-
console.error(' error: missing required argument `language`')
|
|
140
|
-
process.exit(1)
|
|
141
|
-
return
|
|
205
|
+
console.error(colors.red(' error: missing required argument `language`'))
|
|
206
|
+
process.exit(1)
|
|
207
|
+
return
|
|
142
208
|
}
|
|
143
209
|
|
|
144
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
145
|
-
|
|
146
|
-
const addPath = options.addPath || config.addPath || addPathUrl;
|
|
210
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
147
211
|
|
|
148
212
|
add({
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
213
|
+
cdnType: cdnType || defaultCdnType,
|
|
214
|
+
apiKey,
|
|
215
|
+
projectId,
|
|
216
|
+
apiEndpoint,
|
|
217
|
+
language,
|
|
218
|
+
version,
|
|
219
|
+
namespace,
|
|
220
|
+
key,
|
|
221
|
+
value
|
|
222
|
+
})
|
|
158
223
|
})
|
|
159
224
|
.on('--help', () => {
|
|
160
|
-
console.log(' Examples:')
|
|
161
|
-
console.log()
|
|
162
|
-
console.log(' $ locize add common title "the title of my cool app"')
|
|
163
|
-
console.log(' $ locize add common title "the title of my cool app" --language en')
|
|
164
|
-
console.log(' $ locize add common title "the title of my cool app" --api-key <apiKey> --project-id <projectId> --language en')
|
|
165
|
-
console.log()
|
|
166
|
-
})
|
|
225
|
+
console.log(' Examples:')
|
|
226
|
+
console.log()
|
|
227
|
+
console.log(' $ locize add common title "the title of my cool app"')
|
|
228
|
+
console.log(' $ locize add common title "the title of my cool app" --language en')
|
|
229
|
+
console.log(' $ locize add common title "the title of my cool app" --api-key <apiKey> --project-id <projectId> --language en')
|
|
230
|
+
console.log()
|
|
231
|
+
})
|
|
167
232
|
|
|
168
233
|
program
|
|
169
234
|
.command('remove <namespace> <key>')
|
|
@@ -173,56 +238,80 @@ program
|
|
|
173
238
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
174
239
|
.option('-l, --language <lng>', 'The language that should be targeted (omitting this attribute will result in removing the key from all languages)')
|
|
175
240
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
241
|
+
// TODO: remove this on next major version
|
|
242
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
243
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
176
244
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
245
|
+
.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})`)
|
|
177
246
|
.action((namespace, key, options) => {
|
|
178
247
|
try {
|
|
179
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
248
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
180
249
|
} catch (e) {}
|
|
181
250
|
|
|
182
|
-
const
|
|
251
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
252
|
+
// TODO: remove this on next major version
|
|
253
|
+
if (!cdnType) {
|
|
254
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
255
|
+
}
|
|
256
|
+
// TODO: remove this on next major version
|
|
257
|
+
let addPath = options.addPath || config.addPath
|
|
258
|
+
if (addPath) {
|
|
259
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
260
|
+
}
|
|
261
|
+
// TODO: remove this on next major version
|
|
262
|
+
if (!addPath) {
|
|
263
|
+
addPath = getAddPath(cdnType) || addPathUrl
|
|
264
|
+
} else if (cdnType) {
|
|
265
|
+
addPath = fixApiPath(addPath, cdnType)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// TODO: remove and adjust this on next major version
|
|
269
|
+
const apiPath = new URL(addPath)
|
|
270
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
271
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
272
|
+
|
|
273
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
183
274
|
if (!apiKey) {
|
|
184
|
-
console.error(' error: missing required argument `apiKey`')
|
|
185
|
-
process.exit(1)
|
|
186
|
-
return
|
|
275
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
276
|
+
process.exit(1)
|
|
277
|
+
return
|
|
187
278
|
}
|
|
188
279
|
|
|
189
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
280
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
190
281
|
if (!projectId) {
|
|
191
|
-
console.error(' error: missing required argument `projectId`')
|
|
192
|
-
process.exit(1)
|
|
193
|
-
return
|
|
282
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
283
|
+
process.exit(1)
|
|
284
|
+
return
|
|
194
285
|
}
|
|
195
286
|
|
|
196
|
-
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
287
|
+
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
197
288
|
// if (!language) {
|
|
198
|
-
// console.error(' error: missing required argument `language`');
|
|
289
|
+
// console.error(colors.red(' error: missing required argument `language`');
|
|
199
290
|
// process.exit(1);
|
|
200
291
|
// return;
|
|
201
292
|
// }
|
|
202
293
|
|
|
203
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
204
|
-
|
|
205
|
-
const addPath = options.addPath || config.addPath || addPathUrl;
|
|
294
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
206
295
|
|
|
207
296
|
add({
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
297
|
+
cdnType: cdnType || defaultCdnType,
|
|
298
|
+
apiKey,
|
|
299
|
+
projectId,
|
|
300
|
+
apiEndpoint,
|
|
301
|
+
language,
|
|
302
|
+
version,
|
|
303
|
+
namespace,
|
|
304
|
+
key
|
|
305
|
+
})
|
|
216
306
|
})
|
|
217
307
|
.on('--help', () => {
|
|
218
|
-
console.log(' Examples:')
|
|
219
|
-
console.log()
|
|
220
|
-
console.log(' $ locize remove common title')
|
|
221
|
-
console.log(' $ locize remove common title --language en')
|
|
222
|
-
console.log(' $ locize remove common title --api-key <apiKey> --project-id <projectId> --language en')
|
|
223
|
-
console.log()
|
|
224
|
-
})
|
|
225
|
-
|
|
308
|
+
console.log(' Examples:')
|
|
309
|
+
console.log()
|
|
310
|
+
console.log(' $ locize remove common title')
|
|
311
|
+
console.log(' $ locize remove common title --language en')
|
|
312
|
+
console.log(' $ locize remove common title --api-key <apiKey> --project-id <projectId> --language en')
|
|
313
|
+
console.log()
|
|
314
|
+
})
|
|
226
315
|
|
|
227
316
|
program
|
|
228
317
|
.command('download')
|
|
@@ -244,75 +333,100 @@ program
|
|
|
244
333
|
.option('-up, --unpublished <true|false>', 'Downloads the current (unpublished) translations. This will generate private download costs (default: false)', 'false')
|
|
245
334
|
.option('-oo, --overridden-only <true|false>', 'Downloads only the current overridden (unpublished) translations of a tenant or branch project. This will generate private download costs (default: false)', 'false')
|
|
246
335
|
.option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
|
|
336
|
+
// TODO: remove this on next major version
|
|
337
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
338
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
247
339
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
340
|
+
.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})`)
|
|
248
341
|
.action((options) => {
|
|
249
342
|
try {
|
|
250
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
343
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
251
344
|
} catch (e) {}
|
|
252
345
|
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
346
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
347
|
+
// TODO: remove this on next major version
|
|
348
|
+
if (!cdnType) {
|
|
349
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
350
|
+
}
|
|
351
|
+
// TODO: remove this on next major version
|
|
352
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
353
|
+
if (getPath) {
|
|
354
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
258
355
|
}
|
|
356
|
+
// TODO: remove this on next major version
|
|
357
|
+
if (!getPath) {
|
|
358
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
359
|
+
} else if (cdnType) {
|
|
360
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// TODO: remove and adjust this on next major version
|
|
364
|
+
const apiPath = new URL(getPath)
|
|
365
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
366
|
+
|
|
367
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
259
368
|
|
|
260
|
-
const
|
|
369
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
370
|
+
if (!projectId) {
|
|
371
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
372
|
+
process.exit(1)
|
|
373
|
+
return
|
|
374
|
+
}
|
|
261
375
|
|
|
262
|
-
const
|
|
263
|
-
const languages = options.languages || config.languages || config.lngs || process.env.LOCIZE_LANGUAGES || process.env.LOCIZE_LANGS || process.env.LOCIZE_LNGS;
|
|
376
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
264
377
|
|
|
265
|
-
const
|
|
378
|
+
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
379
|
+
const languages = options.languages || config.languages || config.lngs || process.env.LOCIZE_LANGUAGES || process.env.LOCIZE_LANGS || process.env.LOCIZE_LNGS
|
|
266
380
|
|
|
267
|
-
const
|
|
381
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
268
382
|
|
|
269
|
-
const
|
|
383
|
+
const namespace = options.namespace
|
|
270
384
|
|
|
271
|
-
const format = options.format
|
|
385
|
+
const format = options.format
|
|
272
386
|
|
|
273
|
-
const skipEmpty = options.skipEmpty === 'true'
|
|
387
|
+
const skipEmpty = options.skipEmpty === 'true'
|
|
274
388
|
|
|
275
|
-
const clean = options.clean === 'true'
|
|
389
|
+
const clean = options.clean === 'true'
|
|
276
390
|
|
|
277
|
-
const unpublished = options.unpublished === 'true'
|
|
391
|
+
const unpublished = options.unpublished === 'true'
|
|
278
392
|
|
|
279
|
-
const overriddenOnly = options.overriddenOnly === 'true'
|
|
393
|
+
const overriddenOnly = options.overriddenOnly === 'true'
|
|
280
394
|
|
|
281
|
-
const languageFolderPrefix = options.languageFolderPrefix || ''
|
|
395
|
+
const languageFolderPrefix = options.languageFolderPrefix || ''
|
|
282
396
|
|
|
283
|
-
const pathMask = options.pathMask
|
|
397
|
+
const pathMask = options.pathMask
|
|
284
398
|
|
|
285
|
-
const branch = options.branch
|
|
399
|
+
const branch = options.branch
|
|
286
400
|
|
|
287
401
|
download({
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
402
|
+
cdnType: cdnType || defaultCdnType,
|
|
403
|
+
apiKey,
|
|
404
|
+
projectId,
|
|
405
|
+
apiEndpoint,
|
|
406
|
+
language,
|
|
292
407
|
languages: languages && languages.split(','),
|
|
293
|
-
version
|
|
294
|
-
namespace
|
|
408
|
+
version,
|
|
409
|
+
namespace,
|
|
295
410
|
path: options.path,
|
|
296
|
-
format
|
|
297
|
-
skipEmpty
|
|
298
|
-
clean
|
|
299
|
-
languageFolderPrefix
|
|
300
|
-
pathMask
|
|
301
|
-
unpublished
|
|
302
|
-
branch
|
|
303
|
-
overriddenOnly
|
|
304
|
-
})
|
|
411
|
+
format,
|
|
412
|
+
skipEmpty,
|
|
413
|
+
clean,
|
|
414
|
+
languageFolderPrefix,
|
|
415
|
+
pathMask,
|
|
416
|
+
unpublished,
|
|
417
|
+
branch,
|
|
418
|
+
overriddenOnly
|
|
419
|
+
})
|
|
305
420
|
})
|
|
306
421
|
.on('--help', () => {
|
|
307
|
-
console.log(' Examples:')
|
|
308
|
-
console.log()
|
|
309
|
-
console.log(' $ locize download')
|
|
310
|
-
console.log(' $ locize download --ver latest')
|
|
311
|
-
console.log(' $ locize download --project-id <projectId> --ver latest --language en --namespace common')
|
|
312
|
-
console.log(' $ locize download --project-id <projectId> --ver latest --language en --namespace common --format flat')
|
|
313
|
-
console.log()
|
|
314
|
-
})
|
|
315
|
-
|
|
422
|
+
console.log(' Examples:')
|
|
423
|
+
console.log()
|
|
424
|
+
console.log(' $ locize download')
|
|
425
|
+
console.log(' $ locize download --ver latest')
|
|
426
|
+
console.log(' $ locize download --project-id <projectId> --ver latest --language en --namespace common')
|
|
427
|
+
console.log(' $ locize download --project-id <projectId> --ver latest --language en --namespace common --format flat')
|
|
428
|
+
console.log()
|
|
429
|
+
})
|
|
316
430
|
|
|
317
431
|
program
|
|
318
432
|
.command('get <namespace> <key>')
|
|
@@ -321,47 +435,73 @@ program
|
|
|
321
435
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
322
436
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
323
437
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
438
|
+
// TODO: remove this on next major version
|
|
439
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
440
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
324
441
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
442
|
+
.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})`)
|
|
325
443
|
.action((namespace, key, options) => {
|
|
326
444
|
try {
|
|
327
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
445
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
328
446
|
} catch (e) {}
|
|
329
447
|
|
|
330
|
-
const
|
|
448
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
449
|
+
// TODO: remove this on next major version
|
|
450
|
+
if (!cdnType) {
|
|
451
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
452
|
+
}
|
|
453
|
+
// TODO: remove this on next major version
|
|
454
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
455
|
+
if (getPath) {
|
|
456
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
457
|
+
}
|
|
458
|
+
// TODO: remove this on next major version
|
|
459
|
+
if (!getPath) {
|
|
460
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
461
|
+
} else if (cdnType) {
|
|
462
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// TODO: remove and adjust this on next major version
|
|
466
|
+
const apiPath = new URL(getPath)
|
|
467
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
468
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
469
|
+
|
|
470
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
331
471
|
if (!projectId) {
|
|
332
|
-
console.error(' error: missing required argument `projectId`')
|
|
333
|
-
process.exit(1)
|
|
334
|
-
return
|
|
472
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
473
|
+
process.exit(1)
|
|
474
|
+
return
|
|
335
475
|
}
|
|
336
476
|
|
|
337
|
-
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
477
|
+
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
338
478
|
if (!language) {
|
|
339
|
-
console.error(' error: missing required argument `language`')
|
|
340
|
-
process.exit(1)
|
|
341
|
-
return
|
|
479
|
+
console.error(colors.red(' error: missing required argument `language`'))
|
|
480
|
+
process.exit(1)
|
|
481
|
+
return
|
|
342
482
|
}
|
|
343
483
|
|
|
344
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
345
|
-
|
|
346
|
-
const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
|
|
484
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
347
485
|
|
|
348
486
|
get({
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
487
|
+
cdnType: cdnType || defaultCdnType,
|
|
488
|
+
apiEndpoint,
|
|
489
|
+
projectId,
|
|
490
|
+
apiPath,
|
|
491
|
+
language,
|
|
492
|
+
version,
|
|
493
|
+
namespace,
|
|
494
|
+
key
|
|
495
|
+
})
|
|
356
496
|
})
|
|
357
497
|
.on('--help', () => {
|
|
358
|
-
console.log(' Examples:')
|
|
359
|
-
console.log()
|
|
360
|
-
console.log(' $ locize get common title')
|
|
361
|
-
console.log(' $ locize get common title --language en')
|
|
362
|
-
console.log(' $ locize get common title --api-key <apiKey> --project-id <projectId> --language en')
|
|
363
|
-
console.log()
|
|
364
|
-
})
|
|
498
|
+
console.log(' Examples:')
|
|
499
|
+
console.log()
|
|
500
|
+
console.log(' $ locize get common title')
|
|
501
|
+
console.log(' $ locize get common title --language en')
|
|
502
|
+
console.log(' $ locize get common title --api-key <apiKey> --project-id <projectId> --language en')
|
|
503
|
+
console.log()
|
|
504
|
+
})
|
|
365
505
|
|
|
366
506
|
program
|
|
367
507
|
.command('sync')
|
|
@@ -393,94 +533,119 @@ program
|
|
|
393
533
|
.option('-up, --unpublished <true|false>', 'Downloads the current (unpublished) translations. This will generate private download costs (default: false)', 'false')
|
|
394
534
|
.option('-oo, --overridden-only <true|false>', 'Downloads only the current overridden (unpublished) translations of a tenant or branch project. This will generate private download costs (default: false)', 'false')
|
|
395
535
|
.option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
|
|
536
|
+
// TODO: remove this on next major version
|
|
537
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
538
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
396
539
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
540
|
+
.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})`)
|
|
397
541
|
.action((options) => {
|
|
398
542
|
try {
|
|
399
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
543
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
400
544
|
} catch (e) {}
|
|
401
545
|
|
|
402
|
-
const
|
|
546
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
547
|
+
// TODO: remove this on next major version
|
|
548
|
+
if (!cdnType) {
|
|
549
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
550
|
+
}
|
|
551
|
+
// TODO: remove this on next major version
|
|
552
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
553
|
+
if (getPath) {
|
|
554
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
555
|
+
}
|
|
556
|
+
// TODO: remove this on next major version
|
|
557
|
+
if (!getPath) {
|
|
558
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
559
|
+
} else if (cdnType) {
|
|
560
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// TODO: remove and adjust this on next major version
|
|
564
|
+
const apiPath = new URL(getPath)
|
|
565
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
566
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
403
567
|
|
|
404
|
-
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
568
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
405
569
|
if (!apiKey) {
|
|
406
|
-
console.error(' error: missing required argument `apiKey`')
|
|
407
|
-
process.exit(1)
|
|
408
|
-
return
|
|
570
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
571
|
+
process.exit(1)
|
|
572
|
+
return
|
|
409
573
|
}
|
|
410
574
|
|
|
411
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
575
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
412
576
|
if (!projectId) {
|
|
413
|
-
console.error(' error: missing required argument `projectId`')
|
|
414
|
-
process.exit(1)
|
|
415
|
-
return
|
|
577
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
578
|
+
process.exit(1)
|
|
579
|
+
return
|
|
416
580
|
}
|
|
417
581
|
|
|
418
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
582
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
419
583
|
|
|
420
|
-
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
421
|
-
const languages = options.languages || config.languages || config.lngs || process.env.LOCIZE_LANGUAGES || process.env.LOCIZE_LANGS || process.env.LOCIZE_LNGS
|
|
584
|
+
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
585
|
+
const languages = options.languages || config.languages || config.lngs || process.env.LOCIZE_LANGUAGES || process.env.LOCIZE_LANGS || process.env.LOCIZE_LNGS
|
|
422
586
|
|
|
423
|
-
const namespace = options.namespace
|
|
587
|
+
const namespace = options.namespace
|
|
424
588
|
|
|
425
589
|
if (!path.isAbsolute(options.path)) {
|
|
426
|
-
options.path = path.join(process.cwd(), options.path)
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
const clean = options.clean === 'true'
|
|
430
|
-
const cleanLocalFiles = options.cleanLocalFiles === 'true'
|
|
431
|
-
const dry = options.dry === 'true'
|
|
432
|
-
const updateValues = options.updateValues === 'true'
|
|
433
|
-
const autoTranslate = options.autoTranslate === 'true'
|
|
434
|
-
const skipDelete = options.skipDelete === 'true'
|
|
435
|
-
const deleteRemoteNamespace = options.deleteRemoteNamespace === 'true'
|
|
436
|
-
const languageFolderPrefix = options.languageFolderPrefix || ''
|
|
437
|
-
const skipEmpty = options.skipEmpty === 'true'
|
|
438
|
-
const referenceLanguageOnly = options.referenceLanguageOnly
|
|
439
|
-
const compareModificationTime = options.compareModificationTime === 'true'
|
|
440
|
-
const pathMask = options.pathMask
|
|
441
|
-
const unpublished = options.unpublished === 'true'
|
|
442
|
-
const overriddenOnly = options.overriddenOnly === 'true'
|
|
443
|
-
const autoCreatePath = options.autoCreatePath === 'true'
|
|
444
|
-
const backupDeletedPath = options.backupDeletedPath
|
|
445
|
-
const branch = options.branch
|
|
590
|
+
options.path = path.join(process.cwd(), options.path)
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
const clean = options.clean === 'true'
|
|
594
|
+
const cleanLocalFiles = options.cleanLocalFiles === 'true'
|
|
595
|
+
const dry = options.dry === 'true'
|
|
596
|
+
const updateValues = options.updateValues === 'true'
|
|
597
|
+
const autoTranslate = options.autoTranslate === 'true'
|
|
598
|
+
const skipDelete = options.skipDelete === 'true'
|
|
599
|
+
const deleteRemoteNamespace = options.deleteRemoteNamespace === 'true'
|
|
600
|
+
const languageFolderPrefix = options.languageFolderPrefix || ''
|
|
601
|
+
const skipEmpty = options.skipEmpty === 'true'
|
|
602
|
+
const referenceLanguageOnly = options.referenceLanguageOnly !== 'false'
|
|
603
|
+
const compareModificationTime = options.compareModificationTime === 'true'
|
|
604
|
+
const pathMask = options.pathMask
|
|
605
|
+
const unpublished = options.unpublished === 'true'
|
|
606
|
+
const overriddenOnly = options.overriddenOnly === 'true'
|
|
607
|
+
const autoCreatePath = options.autoCreatePath === 'true'
|
|
608
|
+
const backupDeletedPath = options.backupDeletedPath
|
|
609
|
+
const branch = options.branch
|
|
446
610
|
|
|
447
611
|
sync({
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
612
|
+
cdnType: cdnType || defaultCdnType,
|
|
613
|
+
apiEndpoint,
|
|
614
|
+
apiKey,
|
|
615
|
+
projectId,
|
|
616
|
+
version,
|
|
452
617
|
path: options.path,
|
|
453
618
|
format: options.format,
|
|
454
|
-
updateValues
|
|
455
|
-
autoTranslate
|
|
456
|
-
skipDelete
|
|
457
|
-
deleteRemoteNamespace
|
|
458
|
-
languageFolderPrefix
|
|
459
|
-
clean
|
|
460
|
-
cleanLocalFiles
|
|
461
|
-
skipEmpty
|
|
462
|
-
referenceLanguageOnly
|
|
463
|
-
compareModificationTime
|
|
464
|
-
language
|
|
619
|
+
updateValues,
|
|
620
|
+
autoTranslate,
|
|
621
|
+
skipDelete,
|
|
622
|
+
deleteRemoteNamespace,
|
|
623
|
+
languageFolderPrefix,
|
|
624
|
+
clean,
|
|
625
|
+
cleanLocalFiles,
|
|
626
|
+
skipEmpty,
|
|
627
|
+
referenceLanguageOnly,
|
|
628
|
+
compareModificationTime,
|
|
629
|
+
language,
|
|
465
630
|
languages: languages && languages.split(','),
|
|
466
|
-
namespace
|
|
467
|
-
dry
|
|
468
|
-
pathMask
|
|
469
|
-
unpublished
|
|
470
|
-
autoCreatePath
|
|
471
|
-
backupDeletedPath
|
|
472
|
-
branch
|
|
473
|
-
overriddenOnly
|
|
474
|
-
})
|
|
631
|
+
namespace,
|
|
632
|
+
dry,
|
|
633
|
+
pathMask,
|
|
634
|
+
unpublished,
|
|
635
|
+
autoCreatePath,
|
|
636
|
+
backupDeletedPath,
|
|
637
|
+
branch,
|
|
638
|
+
overriddenOnly
|
|
639
|
+
})
|
|
475
640
|
})
|
|
476
641
|
.on('--help', () => {
|
|
477
|
-
console.log(' Examples:')
|
|
478
|
-
console.log()
|
|
479
|
-
console.log(' $ locize sync')
|
|
480
|
-
console.log(' $ locize sync --path ./locales --version production')
|
|
481
|
-
console.log(' $ locize sync --api-key <apiKey> --project-id <projectId> --path ./locales --version production --format flat')
|
|
482
|
-
console.log()
|
|
483
|
-
})
|
|
642
|
+
console.log(' Examples:')
|
|
643
|
+
console.log()
|
|
644
|
+
console.log(' $ locize sync')
|
|
645
|
+
console.log(' $ locize sync --path ./locales --version production')
|
|
646
|
+
console.log(' $ locize sync --api-key <apiKey> --project-id <projectId> --path ./locales --version production --format flat')
|
|
647
|
+
console.log()
|
|
648
|
+
})
|
|
484
649
|
|
|
485
650
|
program
|
|
486
651
|
.command('save-missing')
|
|
@@ -497,70 +662,95 @@ program
|
|
|
497
662
|
.option('-R, --reference-language-only <true|false>', 'Check for changes in reference language only. (default: true)', 'true')
|
|
498
663
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
499
664
|
.option('-n, --namespace <ns>', 'The namespace that should be targeted (you can also pass a comma separated list)')
|
|
665
|
+
// TODO: remove this on next major version
|
|
666
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
667
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
500
668
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
669
|
+
.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})`)
|
|
501
670
|
.action((options) => {
|
|
502
671
|
try {
|
|
503
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
672
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
504
673
|
} catch (e) {}
|
|
505
674
|
|
|
506
|
-
const
|
|
675
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
676
|
+
// TODO: remove this on next major version
|
|
677
|
+
if (!cdnType) {
|
|
678
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
679
|
+
}
|
|
680
|
+
// TODO: remove this on next major version
|
|
681
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
682
|
+
if (getPath) {
|
|
683
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
684
|
+
}
|
|
685
|
+
// TODO: remove this on next major version
|
|
686
|
+
if (!getPath) {
|
|
687
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
688
|
+
} else if (cdnType) {
|
|
689
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// TODO: remove and adjust this on next major version
|
|
693
|
+
const apiPath = new URL(getPath)
|
|
694
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
695
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
507
696
|
|
|
508
|
-
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
697
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
509
698
|
if (!apiKey) {
|
|
510
|
-
console.error(' error: missing required argument `apiKey`')
|
|
511
|
-
process.exit(1)
|
|
512
|
-
return
|
|
699
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
700
|
+
process.exit(1)
|
|
701
|
+
return
|
|
513
702
|
}
|
|
514
703
|
|
|
515
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
704
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
516
705
|
if (!projectId) {
|
|
517
|
-
console.error(' error: missing required argument `projectId`')
|
|
518
|
-
process.exit(1)
|
|
519
|
-
return
|
|
706
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
707
|
+
process.exit(1)
|
|
708
|
+
return
|
|
520
709
|
}
|
|
521
710
|
|
|
522
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
711
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
523
712
|
|
|
524
|
-
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
713
|
+
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG
|
|
525
714
|
|
|
526
|
-
const namespace = options.namespace
|
|
715
|
+
const namespace = options.namespace
|
|
527
716
|
|
|
528
717
|
if (!path.isAbsolute(options.path)) {
|
|
529
|
-
options.path = path.join(process.cwd(), options.path)
|
|
718
|
+
options.path = path.join(process.cwd(), options.path)
|
|
530
719
|
}
|
|
531
720
|
|
|
532
|
-
const dry = options.dry === 'true'
|
|
533
|
-
const updateValues = options.updateValues === 'true'
|
|
534
|
-
const skipDelete = options.skipDelete === 'true'
|
|
535
|
-
const languageFolderPrefix = options.languageFolderPrefix || ''
|
|
536
|
-
const referenceLanguageOnly = options.referenceLanguageOnly
|
|
537
|
-
const pathMask = options.pathMask
|
|
721
|
+
const dry = options.dry === 'true'
|
|
722
|
+
const updateValues = options.updateValues === 'true'
|
|
723
|
+
const skipDelete = options.skipDelete === 'true'
|
|
724
|
+
const languageFolderPrefix = options.languageFolderPrefix || ''
|
|
725
|
+
const referenceLanguageOnly = options.referenceLanguageOnly !== 'false'
|
|
726
|
+
const pathMask = options.pathMask
|
|
538
727
|
|
|
539
728
|
missing({
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
729
|
+
cdnType: cdnType || defaultCdnType,
|
|
730
|
+
apiEndpoint,
|
|
731
|
+
apiKey,
|
|
732
|
+
projectId,
|
|
733
|
+
version,
|
|
544
734
|
path: options.path,
|
|
545
735
|
format: options.format,
|
|
546
|
-
updateValues
|
|
547
|
-
skipDelete
|
|
548
|
-
languageFolderPrefix
|
|
549
|
-
referenceLanguageOnly
|
|
550
|
-
language
|
|
551
|
-
namespace
|
|
552
|
-
dry
|
|
553
|
-
pathMask
|
|
554
|
-
})
|
|
736
|
+
updateValues,
|
|
737
|
+
skipDelete,
|
|
738
|
+
languageFolderPrefix,
|
|
739
|
+
referenceLanguageOnly,
|
|
740
|
+
language,
|
|
741
|
+
namespace,
|
|
742
|
+
dry,
|
|
743
|
+
pathMask
|
|
744
|
+
})
|
|
555
745
|
})
|
|
556
746
|
.on('--help', () => {
|
|
557
|
-
console.log(' Examples:')
|
|
558
|
-
console.log()
|
|
559
|
-
console.log(' $ locize save-missing')
|
|
560
|
-
console.log(' $ locize save-missing --path ./locales --version production')
|
|
561
|
-
console.log(' $ locize save-missing --api-key <apiKey> --project-id <projectId> --path ./locales --version production --format flat')
|
|
562
|
-
console.log()
|
|
563
|
-
})
|
|
747
|
+
console.log(' Examples:')
|
|
748
|
+
console.log()
|
|
749
|
+
console.log(' $ locize save-missing')
|
|
750
|
+
console.log(' $ locize save-missing --path ./locales --version production')
|
|
751
|
+
console.log(' $ locize save-missing --api-key <apiKey> --project-id <projectId> --path ./locales --version production --format flat')
|
|
752
|
+
console.log()
|
|
753
|
+
})
|
|
564
754
|
|
|
565
755
|
program
|
|
566
756
|
.command('copy-version <fromVersion>')
|
|
@@ -570,49 +760,74 @@ program
|
|
|
570
760
|
.option('-v, --ver <version>', 'The target version to be used to copy to (default: latest)')
|
|
571
761
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
572
762
|
.option('-iv, --ignore-if-version-exists <true|false>', 'The project-id that should be used (default: false)', 'false')
|
|
763
|
+
// TODO: remove this on next major version
|
|
764
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
765
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
573
766
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
767
|
+
.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})`)
|
|
574
768
|
.action((fromVersion, options) => {
|
|
575
769
|
try {
|
|
576
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
770
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
577
771
|
} catch (e) {}
|
|
578
772
|
|
|
579
|
-
const
|
|
773
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
774
|
+
// TODO: remove this on next major version
|
|
775
|
+
if (!cdnType) {
|
|
776
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
777
|
+
}
|
|
778
|
+
// TODO: remove this on next major version
|
|
779
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
780
|
+
if (getPath) {
|
|
781
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
782
|
+
}
|
|
783
|
+
// TODO: remove this on next major version
|
|
784
|
+
if (!getPath) {
|
|
785
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
786
|
+
} else if (cdnType) {
|
|
787
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// TODO: remove and adjust this on next major version
|
|
791
|
+
const apiPath = new URL(getPath)
|
|
792
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
793
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
794
|
+
|
|
795
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
580
796
|
if (!apiKey) {
|
|
581
|
-
console.error(' error: missing required argument `apiKey`')
|
|
582
|
-
process.exit(1)
|
|
583
|
-
return
|
|
797
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
798
|
+
process.exit(1)
|
|
799
|
+
return
|
|
584
800
|
}
|
|
585
801
|
|
|
586
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
802
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
587
803
|
if (!projectId) {
|
|
588
|
-
console.error(' error: missing required argument `projectId`')
|
|
589
|
-
process.exit(1)
|
|
590
|
-
return
|
|
804
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
805
|
+
process.exit(1)
|
|
806
|
+
return
|
|
591
807
|
}
|
|
592
808
|
|
|
593
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
809
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
594
810
|
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
const ignoreIfVersionExists = options.ignoreIfVersionExists === 'true';
|
|
811
|
+
const ignoreIfVersionExists = options.ignoreIfVersionExists === 'true'
|
|
598
812
|
|
|
599
813
|
copyVersion({
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
814
|
+
cdnType: cdnType || defaultCdnType,
|
|
815
|
+
apiKey,
|
|
816
|
+
projectId,
|
|
817
|
+
apiEndpoint,
|
|
818
|
+
fromVersion,
|
|
604
819
|
toVersion: version,
|
|
605
|
-
ignoreIfVersionExists
|
|
606
|
-
})
|
|
820
|
+
ignoreIfVersionExists
|
|
821
|
+
})
|
|
607
822
|
})
|
|
608
823
|
.on('--help', () => {
|
|
609
|
-
console.log(' Examples:')
|
|
610
|
-
console.log()
|
|
611
|
-
console.log(' $ locize copy-version latest')
|
|
612
|
-
console.log(' $ locize copy-version latest --ver production')
|
|
613
|
-
console.log(' $ locize copy-version latest --api-key <apiKey> --project-id <projectId> --ver <version>')
|
|
614
|
-
console.log()
|
|
615
|
-
})
|
|
824
|
+
console.log(' Examples:')
|
|
825
|
+
console.log()
|
|
826
|
+
console.log(' $ locize copy-version latest')
|
|
827
|
+
console.log(' $ locize copy-version latest --ver production')
|
|
828
|
+
console.log(' $ locize copy-version latest --api-key <apiKey> --project-id <projectId> --ver <version>')
|
|
829
|
+
console.log()
|
|
830
|
+
})
|
|
616
831
|
|
|
617
832
|
program
|
|
618
833
|
.command('remove-version <version>')
|
|
@@ -620,42 +835,67 @@ program
|
|
|
620
835
|
.description('remove version')
|
|
621
836
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
622
837
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
838
|
+
// TODO: remove this on next major version
|
|
839
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
840
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
623
841
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
842
|
+
.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})`)
|
|
624
843
|
.action((version, options) => {
|
|
625
844
|
try {
|
|
626
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
845
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
627
846
|
} catch (e) {}
|
|
628
847
|
|
|
629
|
-
const
|
|
848
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
849
|
+
// TODO: remove this on next major version
|
|
850
|
+
if (!cdnType) {
|
|
851
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
852
|
+
}
|
|
853
|
+
// TODO: remove this on next major version
|
|
854
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
855
|
+
if (getPath) {
|
|
856
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
857
|
+
}
|
|
858
|
+
// TODO: remove this on next major version
|
|
859
|
+
if (!getPath) {
|
|
860
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
861
|
+
} else if (cdnType) {
|
|
862
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// TODO: remove and adjust this on next major version
|
|
866
|
+
const apiPath = new URL(getPath)
|
|
867
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
868
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
869
|
+
|
|
870
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
630
871
|
if (!apiKey) {
|
|
631
|
-
console.error(' error: missing required argument `apiKey`')
|
|
632
|
-
process.exit(1)
|
|
633
|
-
return
|
|
872
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
873
|
+
process.exit(1)
|
|
874
|
+
return
|
|
634
875
|
}
|
|
635
876
|
|
|
636
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
877
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
637
878
|
if (!projectId) {
|
|
638
|
-
console.error(' error: missing required argument `projectId`')
|
|
639
|
-
process.exit(1)
|
|
640
|
-
return
|
|
879
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
880
|
+
process.exit(1)
|
|
881
|
+
return
|
|
641
882
|
}
|
|
642
883
|
|
|
643
|
-
const getPath = options.getPath || config.getPath || getPathUrl;
|
|
644
|
-
|
|
645
884
|
removeVersion({
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
885
|
+
cdnType: cdnType || defaultCdnType,
|
|
886
|
+
apiKey,
|
|
887
|
+
projectId,
|
|
888
|
+
apiEndpoint,
|
|
889
|
+
version
|
|
890
|
+
})
|
|
651
891
|
})
|
|
652
892
|
.on('--help', () => {
|
|
653
|
-
console.log(' Examples:')
|
|
654
|
-
console.log()
|
|
655
|
-
console.log(' $ locize remove-version tmp-ver')
|
|
656
|
-
console.log(' $ locize remove-version tmp-ver --api-key <apiKey> --project-id <projectId>')
|
|
657
|
-
console.log()
|
|
658
|
-
})
|
|
893
|
+
console.log(' Examples:')
|
|
894
|
+
console.log()
|
|
895
|
+
console.log(' $ locize remove-version tmp-ver')
|
|
896
|
+
console.log(' $ locize remove-version tmp-ver --api-key <apiKey> --project-id <projectId>')
|
|
897
|
+
console.log()
|
|
898
|
+
})
|
|
659
899
|
|
|
660
900
|
program
|
|
661
901
|
.command('publish-version')
|
|
@@ -665,48 +905,73 @@ program
|
|
|
665
905
|
.option('-v, --ver <version>', 'The version to be used to publish (default: latest)')
|
|
666
906
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
667
907
|
.option('-t, --tenants <true|false>', 'Publish also tenants (if using multi-tenant setup) (default: false)', 'false')
|
|
908
|
+
// TODO: remove this on next major version
|
|
909
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
910
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
668
911
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
912
|
+
.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})`)
|
|
669
913
|
.action((options) => {
|
|
670
914
|
try {
|
|
671
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
915
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
672
916
|
} catch (e) {}
|
|
673
917
|
|
|
674
|
-
const
|
|
918
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
919
|
+
// TODO: remove this on next major version
|
|
920
|
+
if (!cdnType) {
|
|
921
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
922
|
+
}
|
|
923
|
+
// TODO: remove this on next major version
|
|
924
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
925
|
+
if (getPath) {
|
|
926
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
927
|
+
}
|
|
928
|
+
// TODO: remove this on next major version
|
|
929
|
+
if (!getPath) {
|
|
930
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
931
|
+
} else if (cdnType) {
|
|
932
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// TODO: remove and adjust this on next major version
|
|
936
|
+
const apiPath = new URL(getPath)
|
|
937
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
938
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
939
|
+
|
|
940
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
675
941
|
if (!apiKey) {
|
|
676
|
-
console.error(' error: missing required argument `apiKey`')
|
|
677
|
-
process.exit(1)
|
|
678
|
-
return
|
|
942
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
943
|
+
process.exit(1)
|
|
944
|
+
return
|
|
679
945
|
}
|
|
680
946
|
|
|
681
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
947
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
682
948
|
if (!projectId) {
|
|
683
|
-
console.error(' error: missing required argument `projectId`')
|
|
684
|
-
process.exit(1)
|
|
685
|
-
return
|
|
949
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
950
|
+
process.exit(1)
|
|
951
|
+
return
|
|
686
952
|
}
|
|
687
953
|
|
|
688
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
689
|
-
|
|
690
|
-
const getPath = options.getPath || config.getPath || getPathUrl;
|
|
954
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
691
955
|
|
|
692
|
-
const tenants = options.tenants === 'true'
|
|
956
|
+
const tenants = options.tenants === 'true'
|
|
693
957
|
|
|
694
958
|
publishVersion({
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
959
|
+
cdnType: cdnType || defaultCdnType,
|
|
960
|
+
apiKey,
|
|
961
|
+
projectId,
|
|
962
|
+
apiEndpoint,
|
|
963
|
+
version,
|
|
964
|
+
tenants
|
|
965
|
+
})
|
|
701
966
|
})
|
|
702
967
|
.on('--help', () => {
|
|
703
|
-
console.log(' Examples:')
|
|
704
|
-
console.log()
|
|
705
|
-
console.log(' $ locize publish-version')
|
|
706
|
-
console.log(' $ locize publish-version --ver production')
|
|
707
|
-
console.log(' $ locize publish-version --api-key <apiKey> --project-id <projectId> --ver <version>')
|
|
708
|
-
console.log()
|
|
709
|
-
})
|
|
968
|
+
console.log(' Examples:')
|
|
969
|
+
console.log()
|
|
970
|
+
console.log(' $ locize publish-version')
|
|
971
|
+
console.log(' $ locize publish-version --ver production')
|
|
972
|
+
console.log(' $ locize publish-version --api-key <apiKey> --project-id <projectId> --ver <version>')
|
|
973
|
+
console.log()
|
|
974
|
+
})
|
|
710
975
|
|
|
711
976
|
program
|
|
712
977
|
.command('delete-namespace <namespace>')
|
|
@@ -715,46 +980,70 @@ program
|
|
|
715
980
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
716
981
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
717
982
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
983
|
+
// TODO: remove this on next major version
|
|
984
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
985
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
718
986
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
987
|
+
.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})`)
|
|
719
988
|
.action((namespace, options) => {
|
|
720
989
|
try {
|
|
721
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
990
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
722
991
|
} catch (e) {}
|
|
723
992
|
|
|
724
|
-
const
|
|
993
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
994
|
+
// TODO: remove this on next major version
|
|
995
|
+
if (!cdnType) {
|
|
996
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
997
|
+
}
|
|
998
|
+
// TODO: remove this on next major version
|
|
999
|
+
let addPath = options.addPath || config.addPath
|
|
1000
|
+
if (addPath) {
|
|
1001
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
1002
|
+
}
|
|
1003
|
+
// TODO: remove this on next major version
|
|
1004
|
+
if (!addPath) {
|
|
1005
|
+
addPath = getAddPath(cdnType) || addPathUrl
|
|
1006
|
+
} else if (cdnType) {
|
|
1007
|
+
addPath = fixApiPath(addPath, cdnType)
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// TODO: remove and adjust this on next major version
|
|
1011
|
+
const apiPath = new URL(addPath)
|
|
1012
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
1013
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
1014
|
+
|
|
1015
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
725
1016
|
if (!apiKey) {
|
|
726
|
-
console.error(' error: missing required argument `apiKey`')
|
|
727
|
-
process.exit(1)
|
|
728
|
-
return
|
|
1017
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
1018
|
+
process.exit(1)
|
|
1019
|
+
return
|
|
729
1020
|
}
|
|
730
1021
|
|
|
731
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
1022
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
732
1023
|
if (!projectId) {
|
|
733
|
-
console.error(' error: missing required argument `projectId`')
|
|
734
|
-
process.exit(1)
|
|
735
|
-
return
|
|
1024
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
1025
|
+
process.exit(1)
|
|
1026
|
+
return
|
|
736
1027
|
}
|
|
737
1028
|
|
|
738
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
739
|
-
|
|
740
|
-
const addPath = options.addPath || config.addPath || addPathUrl;
|
|
1029
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
741
1030
|
|
|
742
1031
|
deleteNamespace({
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
1032
|
+
cdnType: cdnType || defaultCdnType,
|
|
1033
|
+
apiKey,
|
|
1034
|
+
projectId,
|
|
1035
|
+
apiEndpoint,
|
|
1036
|
+
version,
|
|
1037
|
+
namespace
|
|
1038
|
+
})
|
|
749
1039
|
})
|
|
750
1040
|
.on('--help', () => {
|
|
751
|
-
console.log(' Examples:')
|
|
752
|
-
console.log()
|
|
753
|
-
console.log(' $ locize delete-namespace common')
|
|
754
|
-
console.log(' $ locize delete-namespace common --api-key <apiKey> --project-id <projectId>')
|
|
755
|
-
console.log()
|
|
756
|
-
})
|
|
757
|
-
|
|
1041
|
+
console.log(' Examples:')
|
|
1042
|
+
console.log()
|
|
1043
|
+
console.log(' $ locize delete-namespace common')
|
|
1044
|
+
console.log(' $ locize delete-namespace common --api-key <apiKey> --project-id <projectId>')
|
|
1045
|
+
console.log()
|
|
1046
|
+
})
|
|
758
1047
|
|
|
759
1048
|
program
|
|
760
1049
|
.command('format [fileOrDirectory]')
|
|
@@ -763,40 +1052,35 @@ program
|
|
|
763
1052
|
.option('-f, --format <json>', 'File format of namespaces (default: 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])', 'json')
|
|
764
1053
|
.option('-l, --reference-language <lng>', 'Some format conversions need to know the reference language.', 'en')
|
|
765
1054
|
.option('-d, --dry <true|false>', 'Dry run (default: false)', 'false')
|
|
766
|
-
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
767
1055
|
.action((fileOrDirectory, options) => {
|
|
768
|
-
|
|
769
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
|
|
770
|
-
} catch (e) {}
|
|
771
|
-
|
|
772
|
-
fileOrDirectory = fileOrDirectory || '.';
|
|
1056
|
+
fileOrDirectory = fileOrDirectory || '.'
|
|
773
1057
|
|
|
774
1058
|
if (!path.isAbsolute(fileOrDirectory)) {
|
|
775
|
-
fileOrDirectory = path.join(process.cwd(), fileOrDirectory)
|
|
1059
|
+
fileOrDirectory = path.join(process.cwd(), fileOrDirectory)
|
|
776
1060
|
}
|
|
777
1061
|
|
|
778
|
-
const format = options.format
|
|
779
|
-
const dry = options.dry === 'true'
|
|
780
|
-
const referenceLanguage = options.referenceLanguage
|
|
1062
|
+
const format = options.format
|
|
1063
|
+
const dry = options.dry === 'true'
|
|
1064
|
+
const referenceLanguage = options.referenceLanguage
|
|
781
1065
|
|
|
782
1066
|
formatFn({
|
|
783
|
-
fileOrDirectory
|
|
784
|
-
format
|
|
785
|
-
referenceLanguage
|
|
786
|
-
dry
|
|
787
|
-
})
|
|
1067
|
+
fileOrDirectory,
|
|
1068
|
+
format,
|
|
1069
|
+
referenceLanguage,
|
|
1070
|
+
dry
|
|
1071
|
+
})
|
|
788
1072
|
})
|
|
789
1073
|
.on('--help', () => {
|
|
790
|
-
console.log(' Examples:')
|
|
791
|
-
console.log()
|
|
792
|
-
console.log(' $ locize format')
|
|
793
|
-
console.log(' $ locize format path/to/file')
|
|
794
|
-
console.log(' $ locize format path/to/dictionary')
|
|
795
|
-
console.log(' $ locize format path/to/dictionary --format android')
|
|
796
|
-
console.log(' $ locize format path/to/dictionary --format android --dry true')
|
|
797
|
-
console.log(' $ locize format path/to/dictionary --format xliff2 --reference-language en')
|
|
798
|
-
console.log()
|
|
799
|
-
})
|
|
1074
|
+
console.log(' Examples:')
|
|
1075
|
+
console.log()
|
|
1076
|
+
console.log(' $ locize format')
|
|
1077
|
+
console.log(' $ locize format path/to/file')
|
|
1078
|
+
console.log(' $ locize format path/to/dictionary')
|
|
1079
|
+
console.log(' $ locize format path/to/dictionary --format android')
|
|
1080
|
+
console.log(' $ locize format path/to/dictionary --format android --dry true')
|
|
1081
|
+
console.log(' $ locize format path/to/dictionary --format xliff2 --reference-language en')
|
|
1082
|
+
console.log()
|
|
1083
|
+
})
|
|
800
1084
|
|
|
801
1085
|
program
|
|
802
1086
|
.command('create-branch <branch>')
|
|
@@ -805,46 +1089,71 @@ program
|
|
|
805
1089
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
806
1090
|
.option('-v, --ver <version>', 'The target version to be used to copy to (default: latest)')
|
|
807
1091
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
1092
|
+
// TODO: remove this on next major version
|
|
1093
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
1094
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
808
1095
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
1096
|
+
.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})`)
|
|
809
1097
|
.action((branch, options) => {
|
|
810
1098
|
try {
|
|
811
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
1099
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
812
1100
|
} catch (e) {}
|
|
813
1101
|
|
|
814
|
-
const
|
|
1102
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
1103
|
+
// TODO: remove this on next major version
|
|
1104
|
+
if (!cdnType) {
|
|
1105
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
1106
|
+
}
|
|
1107
|
+
// TODO: remove this on next major version
|
|
1108
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
1109
|
+
if (getPath) {
|
|
1110
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
1111
|
+
}
|
|
1112
|
+
// TODO: remove this on next major version
|
|
1113
|
+
if (!getPath) {
|
|
1114
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
1115
|
+
} else if (cdnType) {
|
|
1116
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
// TODO: remove and adjust this on next major version
|
|
1120
|
+
const apiPath = new URL(getPath)
|
|
1121
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
1122
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
1123
|
+
|
|
1124
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
815
1125
|
if (!apiKey) {
|
|
816
|
-
console.error(' error: missing required argument `apiKey`')
|
|
817
|
-
process.exit(1)
|
|
818
|
-
return
|
|
1126
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
1127
|
+
process.exit(1)
|
|
1128
|
+
return
|
|
819
1129
|
}
|
|
820
1130
|
|
|
821
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
1131
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
822
1132
|
if (!projectId) {
|
|
823
|
-
console.error(' error: missing required argument `projectId`')
|
|
824
|
-
process.exit(1)
|
|
825
|
-
return
|
|
1133
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
1134
|
+
process.exit(1)
|
|
1135
|
+
return
|
|
826
1136
|
}
|
|
827
1137
|
|
|
828
|
-
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
829
|
-
|
|
830
|
-
const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
|
|
1138
|
+
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest'
|
|
831
1139
|
|
|
832
1140
|
createBranch({
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
1141
|
+
cdnType: cdnType || defaultCdnType,
|
|
1142
|
+
apiKey,
|
|
1143
|
+
projectId,
|
|
1144
|
+
apiEndpoint,
|
|
1145
|
+
version,
|
|
1146
|
+
branch
|
|
1147
|
+
})
|
|
839
1148
|
})
|
|
840
1149
|
.on('--help', () => {
|
|
841
|
-
console.log(' Examples:')
|
|
842
|
-
console.log()
|
|
843
|
-
console.log(' $ locize create-branch featureX')
|
|
844
|
-
console.log(' $ locize create-branch featureX --ver production')
|
|
845
|
-
console.log(' $ locize create-branch featureX --api-key <apiKey> --project-id <projectId> --ver <version>')
|
|
846
|
-
console.log()
|
|
847
|
-
})
|
|
1150
|
+
console.log(' Examples:')
|
|
1151
|
+
console.log()
|
|
1152
|
+
console.log(' $ locize create-branch featureX')
|
|
1153
|
+
console.log(' $ locize create-branch featureX --ver production')
|
|
1154
|
+
console.log(' $ locize create-branch featureX --api-key <apiKey> --project-id <projectId> --ver <version>')
|
|
1155
|
+
console.log()
|
|
1156
|
+
})
|
|
848
1157
|
|
|
849
1158
|
program
|
|
850
1159
|
.command('merge-branch <branch>')
|
|
@@ -853,45 +1162,70 @@ program
|
|
|
853
1162
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
854
1163
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
855
1164
|
.option('-d, --delete <true|false>', 'This will delete the branch after merging. (default: false)', 'false')
|
|
1165
|
+
// TODO: remove this on next major version
|
|
1166
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
1167
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
856
1168
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
1169
|
+
.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})`)
|
|
857
1170
|
.action((branch, options) => {
|
|
858
1171
|
try {
|
|
859
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
1172
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
860
1173
|
} catch (e) {}
|
|
861
1174
|
|
|
862
|
-
const
|
|
1175
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
1176
|
+
// TODO: remove this on next major version
|
|
1177
|
+
if (!cdnType) {
|
|
1178
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
1179
|
+
}
|
|
1180
|
+
// TODO: remove this on next major version
|
|
1181
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
1182
|
+
if (getPath) {
|
|
1183
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
1184
|
+
}
|
|
1185
|
+
// TODO: remove this on next major version
|
|
1186
|
+
if (!getPath) {
|
|
1187
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
1188
|
+
} else if (cdnType) {
|
|
1189
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// TODO: remove and adjust this on next major version
|
|
1193
|
+
const apiPath = new URL(getPath)
|
|
1194
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
1195
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
1196
|
+
|
|
1197
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
863
1198
|
if (!apiKey) {
|
|
864
|
-
console.error(' error: missing required argument `apiKey`')
|
|
865
|
-
process.exit(1)
|
|
866
|
-
return
|
|
1199
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
1200
|
+
process.exit(1)
|
|
1201
|
+
return
|
|
867
1202
|
}
|
|
868
1203
|
|
|
869
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
1204
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
870
1205
|
if (!projectId) {
|
|
871
|
-
console.error(' error: missing required argument `projectId`')
|
|
872
|
-
process.exit(1)
|
|
873
|
-
return
|
|
1206
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
1207
|
+
process.exit(1)
|
|
1208
|
+
return
|
|
874
1209
|
}
|
|
875
1210
|
|
|
876
|
-
const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
|
|
877
|
-
|
|
878
1211
|
mergeBranch({
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1212
|
+
cdnType: cdnType || defaultCdnType,
|
|
1213
|
+
apiKey,
|
|
1214
|
+
projectId,
|
|
1215
|
+
apiEndpoint,
|
|
882
1216
|
delete: options.delete === 'true',
|
|
883
|
-
branch
|
|
884
|
-
})
|
|
1217
|
+
branch
|
|
1218
|
+
})
|
|
885
1219
|
})
|
|
886
1220
|
.on('--help', () => {
|
|
887
|
-
console.log(' Examples:')
|
|
888
|
-
console.log()
|
|
889
|
-
console.log(' $ locize merge-branch featureX')
|
|
890
|
-
console.log(' $ locize merge-branch <projectId-of-branch>')
|
|
891
|
-
console.log(' $ locize merge-branch featureX --delete true')
|
|
892
|
-
console.log(' $ locize merge-branch featureX --api-key <apiKey> --project-id <projectId> --delete true')
|
|
893
|
-
console.log()
|
|
894
|
-
})
|
|
1221
|
+
console.log(' Examples:')
|
|
1222
|
+
console.log()
|
|
1223
|
+
console.log(' $ locize merge-branch featureX')
|
|
1224
|
+
console.log(' $ locize merge-branch <projectId-of-branch>')
|
|
1225
|
+
console.log(' $ locize merge-branch featureX --delete true')
|
|
1226
|
+
console.log(' $ locize merge-branch featureX --api-key <apiKey> --project-id <projectId> --delete true')
|
|
1227
|
+
console.log()
|
|
1228
|
+
})
|
|
895
1229
|
|
|
896
1230
|
program
|
|
897
1231
|
.command('delete-branch <branch>')
|
|
@@ -899,45 +1233,70 @@ program
|
|
|
899
1233
|
.description('delete branch')
|
|
900
1234
|
.option('-k, --api-key <apiKey>', 'The api-key that should be used')
|
|
901
1235
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
1236
|
+
// TODO: remove this on next major version
|
|
1237
|
+
.option('-a, --add-path <url>', `Specify the add-path url that should be used (default: ${addPathUrl})`)
|
|
1238
|
+
.option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
|
|
902
1239
|
.option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
|
|
1240
|
+
.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})`)
|
|
903
1241
|
.action((branch, options) => {
|
|
904
1242
|
try {
|
|
905
|
-
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
1243
|
+
config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config
|
|
906
1244
|
} catch (e) {}
|
|
907
1245
|
|
|
908
|
-
const
|
|
1246
|
+
const cdnType = options.cdnType || config.cdnType || process.env.LOCIZE_CDN_TYPE
|
|
1247
|
+
// TODO: remove this on next major version
|
|
1248
|
+
if (!cdnType) {
|
|
1249
|
+
console.error(colors.red('In the next major version, the default \'cdnType\' will be \'standard\'. Please set \'cdnType\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
1250
|
+
}
|
|
1251
|
+
// TODO: remove this on next major version
|
|
1252
|
+
let getPath = options.getPath || config.getPath || options.addPath || config.addPath
|
|
1253
|
+
if (getPath) {
|
|
1254
|
+
console.error(colors.red('In the next major version, the \'addPath\' / \'--add-path\' option will be removed. Please set \'apiEndpoint\' / \'--api-endpoint\' explicitly in your config or environment variables or via cli parameter to avoid issues.'))
|
|
1255
|
+
}
|
|
1256
|
+
// TODO: remove this on next major version
|
|
1257
|
+
if (!getPath) {
|
|
1258
|
+
getPath = getAddPath(cdnType) || getPathUrl
|
|
1259
|
+
} else if (cdnType) {
|
|
1260
|
+
getPath = fixApiPath(getPath, cdnType)
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
// TODO: remove and adjust this on next major version
|
|
1264
|
+
const apiPath = new URL(getPath)
|
|
1265
|
+
let apiEndpoint = options.apiEndpoint || config.apiEndpoint || process.env.LOCIZE_API_ENDPOINT || (apiPath.protocol + '//' + apiPath.host) || defaultApiEndpoint
|
|
1266
|
+
if (cdnType) apiEndpoint = fixApiPath(apiEndpoint, cdnType)
|
|
1267
|
+
|
|
1268
|
+
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY
|
|
909
1269
|
if (!apiKey) {
|
|
910
|
-
console.error(' error: missing required argument `apiKey`')
|
|
911
|
-
process.exit(1)
|
|
912
|
-
return
|
|
1270
|
+
console.error(colors.red(' error: missing required argument `apiKey`'))
|
|
1271
|
+
process.exit(1)
|
|
1272
|
+
return
|
|
913
1273
|
}
|
|
914
1274
|
|
|
915
|
-
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
1275
|
+
const projectId = options.projectId || config.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID
|
|
916
1276
|
if (!projectId) {
|
|
917
|
-
console.error(' error: missing required argument `projectId`')
|
|
918
|
-
process.exit(1)
|
|
919
|
-
return
|
|
1277
|
+
console.error(colors.red(' error: missing required argument `projectId`'))
|
|
1278
|
+
process.exit(1)
|
|
1279
|
+
return
|
|
920
1280
|
}
|
|
921
1281
|
|
|
922
|
-
const getPath = options.getPath || config.getPath || options.addPath || config.addPath || getPathUrl;
|
|
923
|
-
|
|
924
1282
|
deleteBranch({
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1283
|
+
cdnType: cdnType || defaultCdnType,
|
|
1284
|
+
apiKey,
|
|
1285
|
+
projectId,
|
|
1286
|
+
apiEndpoint,
|
|
1287
|
+
branch
|
|
1288
|
+
})
|
|
930
1289
|
})
|
|
931
1290
|
.on('--help', () => {
|
|
932
|
-
console.log(' Examples:')
|
|
933
|
-
console.log()
|
|
934
|
-
console.log(' $ locize delete-branch featureX')
|
|
935
|
-
console.log(' $ locize delete-branch featureX --api-key <apiKey> --project-id <projectId>')
|
|
936
|
-
console.log()
|
|
937
|
-
})
|
|
1291
|
+
console.log(' Examples:')
|
|
1292
|
+
console.log()
|
|
1293
|
+
console.log(' $ locize delete-branch featureX')
|
|
1294
|
+
console.log(' $ locize delete-branch featureX --api-key <apiKey> --project-id <projectId>')
|
|
1295
|
+
console.log()
|
|
1296
|
+
})
|
|
938
1297
|
|
|
939
|
-
program.parse(process.argv)
|
|
1298
|
+
program.parse(process.argv)
|
|
940
1299
|
|
|
941
1300
|
if (!process.argv.slice(2).length) {
|
|
942
|
-
|
|
1301
|
+
program.outputHelp(colors.red)
|
|
943
1302
|
}
|