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