@commercetools-frontend/create-mc-app 22.28.0 → 22.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/commercetools-frontend-create-mc-app.cjs.dev.js +33 -2
- package/dist/commercetools-frontend-create-mc-app.cjs.prod.js +33 -2
- package/dist/commercetools-frontend-create-mc-app.esm.js +33 -2
- package/dist/declarations/src/types.d.ts +2 -0
- package/dist/declarations/src/validations.d.ts +2 -1
- package/package.json +2 -1
- package/src/cli.ts +4 -0
- package/src/process-options.ts +28 -0
- package/src/tasks/update-application-config.ts +8 -0
- package/src/types.ts +2 -0
- package/src/validations.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @commercetools-frontend/create-mc-app
|
|
2
2
|
|
|
3
|
+
## 22.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3564](https://github.com/commercetools/merchant-center-application-kit/pull/3564) [`96eb231`](https://github.com/commercetools/merchant-center-application-kit/commit/96eb231e0738ce152d2a792e8248466b32e3a0c8) Thanks [@mustafaasif2](https://github.com/mustafaasif2)! - Added a `--cloud-identifier` option to the `create-mc-app` CLI, allowing to specify the [cloudIdentifier](https://docs.commercetools.com/merchant-center-customizations/api-reference/custom-application-config#cloudidentifier) in the customization configuration file.
|
|
8
|
+
|
|
9
|
+
Example usage:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @commercetools-frontend/create-mc-app@latest \
|
|
13
|
+
my-new-custom-application-project \
|
|
14
|
+
--template starter \
|
|
15
|
+
--cloud-identifier gcp-us
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies []:
|
|
21
|
+
- @commercetools-frontend/application-config@22.30.0
|
|
22
|
+
|
|
23
|
+
## 22.29.0
|
|
24
|
+
|
|
3
25
|
## 22.28.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -13,6 +13,7 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
|
|
|
13
13
|
var crypto = require('node:crypto');
|
|
14
14
|
var path = require('node:path');
|
|
15
15
|
var readline = require('node:readline');
|
|
16
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
16
17
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
17
18
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
18
19
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
@@ -71,7 +72,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
71
72
|
|
|
72
73
|
var pkgJson = {
|
|
73
74
|
name: "@commercetools-frontend/create-mc-app",
|
|
74
|
-
version: "22.
|
|
75
|
+
version: "22.30.0",
|
|
75
76
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
76
77
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
77
78
|
repository: {
|
|
@@ -97,6 +98,7 @@ var pkgJson = {
|
|
|
97
98
|
"@babel/core": "^7.22.17",
|
|
98
99
|
"@babel/runtime": "^7.22.15",
|
|
99
100
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
101
|
+
"@commercetools-frontend/application-config": "^22.30.0",
|
|
100
102
|
"@types/babel__core": "^7.20.1",
|
|
101
103
|
"@types/semver": "^7.5.1",
|
|
102
104
|
cac: "6.7.14",
|
|
@@ -254,6 +256,13 @@ const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRan
|
|
|
254
256
|
throw new Error(_concatInstanceProperty__default["default"](_context8 = "You are running Node ".concat(currentNodeVersion, " but create-mc-app requires Node ")).call(_context8, expectedVersionRange, ". Please update your version of Node."));
|
|
255
257
|
}
|
|
256
258
|
};
|
|
259
|
+
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
260
|
+
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
261
|
+
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
262
|
+
var _context9;
|
|
263
|
+
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
264
|
+
}
|
|
265
|
+
};
|
|
257
266
|
|
|
258
267
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
259
268
|
const getEntryPointUriPath = async (rl, options) => {
|
|
@@ -279,6 +288,21 @@ const getInitialProjectKey = async (rl, options) => {
|
|
|
279
288
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
280
289
|
return initialProjectKey;
|
|
281
290
|
};
|
|
291
|
+
const getCloudIdentifier = async (rl, options) => {
|
|
292
|
+
if (options.cloudIdentifier) {
|
|
293
|
+
throwIfCloudIdentifierIsNotSupported(options.cloudIdentifier);
|
|
294
|
+
return options.cloudIdentifier;
|
|
295
|
+
}
|
|
296
|
+
if (options.yes) {
|
|
297
|
+
return applicationConfig.CLOUD_IDENTIFIERS.GCP_EU;
|
|
298
|
+
}
|
|
299
|
+
const cloudIdentifier = await question(rl, 'Provide the cloudIdentifier (default "gcp-eu"): ');
|
|
300
|
+
if (!cloudIdentifier) {
|
|
301
|
+
return applicationConfig.CLOUD_IDENTIFIERS.GCP_EU;
|
|
302
|
+
}
|
|
303
|
+
throwIfCloudIdentifierIsNotSupported(cloudIdentifier);
|
|
304
|
+
return cloudIdentifier;
|
|
305
|
+
};
|
|
282
306
|
async function processOptions(projectDirectoryName, options) {
|
|
283
307
|
if (!projectDirectoryName) {
|
|
284
308
|
throw new Error('Missing required argument "[project-directory]"');
|
|
@@ -302,6 +326,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
302
326
|
});
|
|
303
327
|
const entryPointUriPath = await getEntryPointUriPath(rl, options);
|
|
304
328
|
const initialProjectKey = await getInitialProjectKey(rl, options);
|
|
329
|
+
const cloudIdentifier = await getCloudIdentifier(rl, options);
|
|
305
330
|
rl.close();
|
|
306
331
|
return {
|
|
307
332
|
applicationType: options.applicationType,
|
|
@@ -311,6 +336,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
311
336
|
tagOrBranchVersion,
|
|
312
337
|
entryPointUriPath,
|
|
313
338
|
initialProjectKey,
|
|
339
|
+
cloudIdentifier,
|
|
314
340
|
packageManager: options.packageManager
|
|
315
341
|
};
|
|
316
342
|
}
|
|
@@ -454,6 +480,11 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
454
480
|
}) && nodePath.parent.type === 'ObjectProperty') {
|
|
455
481
|
nodePath.parent.value = core.types.stringLiteral(options.initialProjectKey);
|
|
456
482
|
}
|
|
483
|
+
if (nodePath.isIdentifier({
|
|
484
|
+
name: 'cloudIdentifier'
|
|
485
|
+
}) && nodePath.parent.type === 'ObjectProperty') {
|
|
486
|
+
nodePath.parent.value = core.types.stringLiteral(options.cloudIdentifier);
|
|
487
|
+
}
|
|
457
488
|
if (options.applicationType === applicationTypes['custom-application'] && nodePath.isIdentifier({
|
|
458
489
|
name: 'defaultLabel'
|
|
459
490
|
})) {
|
|
@@ -561,7 +592,7 @@ const run = () => {
|
|
|
561
592
|
default: false
|
|
562
593
|
}).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', {
|
|
563
594
|
default: false
|
|
564
|
-
}).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').option('--package-manager <value>', '(optional) The preferred package manager to use: npm, yarn, pnpm.').action(async (projectDirectory, options) => {
|
|
595
|
+
}).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').option('--cloud-identifier <value>', '(optional) Cloud region identifier. (default: gcp-eu)').option('--package-manager <value>', '(optional) The preferred package manager to use: npm, yarn, pnpm.').action(async (projectDirectory, options) => {
|
|
565
596
|
var _context, _context2;
|
|
566
597
|
if (!projectDirectory) {
|
|
567
598
|
cli.outputHelp();
|
|
@@ -13,6 +13,7 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
|
|
|
13
13
|
var crypto = require('node:crypto');
|
|
14
14
|
var path = require('node:path');
|
|
15
15
|
var readline = require('node:readline');
|
|
16
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
16
17
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
17
18
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
18
19
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
@@ -71,7 +72,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
71
72
|
|
|
72
73
|
var pkgJson = {
|
|
73
74
|
name: "@commercetools-frontend/create-mc-app",
|
|
74
|
-
version: "22.
|
|
75
|
+
version: "22.30.0",
|
|
75
76
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
76
77
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
77
78
|
repository: {
|
|
@@ -97,6 +98,7 @@ var pkgJson = {
|
|
|
97
98
|
"@babel/core": "^7.22.17",
|
|
98
99
|
"@babel/runtime": "^7.22.15",
|
|
99
100
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
101
|
+
"@commercetools-frontend/application-config": "^22.30.0",
|
|
100
102
|
"@types/babel__core": "^7.20.1",
|
|
101
103
|
"@types/semver": "^7.5.1",
|
|
102
104
|
cac: "6.7.14",
|
|
@@ -254,6 +256,13 @@ const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRan
|
|
|
254
256
|
throw new Error(_concatInstanceProperty__default["default"](_context8 = "You are running Node ".concat(currentNodeVersion, " but create-mc-app requires Node ")).call(_context8, expectedVersionRange, ". Please update your version of Node."));
|
|
255
257
|
}
|
|
256
258
|
};
|
|
259
|
+
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
260
|
+
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
261
|
+
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
262
|
+
var _context9;
|
|
263
|
+
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
264
|
+
}
|
|
265
|
+
};
|
|
257
266
|
|
|
258
267
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
259
268
|
const getEntryPointUriPath = async (rl, options) => {
|
|
@@ -279,6 +288,21 @@ const getInitialProjectKey = async (rl, options) => {
|
|
|
279
288
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
280
289
|
return initialProjectKey;
|
|
281
290
|
};
|
|
291
|
+
const getCloudIdentifier = async (rl, options) => {
|
|
292
|
+
if (options.cloudIdentifier) {
|
|
293
|
+
throwIfCloudIdentifierIsNotSupported(options.cloudIdentifier);
|
|
294
|
+
return options.cloudIdentifier;
|
|
295
|
+
}
|
|
296
|
+
if (options.yes) {
|
|
297
|
+
return applicationConfig.CLOUD_IDENTIFIERS.GCP_EU;
|
|
298
|
+
}
|
|
299
|
+
const cloudIdentifier = await question(rl, 'Provide the cloudIdentifier (default "gcp-eu"): ');
|
|
300
|
+
if (!cloudIdentifier) {
|
|
301
|
+
return applicationConfig.CLOUD_IDENTIFIERS.GCP_EU;
|
|
302
|
+
}
|
|
303
|
+
throwIfCloudIdentifierIsNotSupported(cloudIdentifier);
|
|
304
|
+
return cloudIdentifier;
|
|
305
|
+
};
|
|
282
306
|
async function processOptions(projectDirectoryName, options) {
|
|
283
307
|
if (!projectDirectoryName) {
|
|
284
308
|
throw new Error('Missing required argument "[project-directory]"');
|
|
@@ -302,6 +326,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
302
326
|
});
|
|
303
327
|
const entryPointUriPath = await getEntryPointUriPath(rl, options);
|
|
304
328
|
const initialProjectKey = await getInitialProjectKey(rl, options);
|
|
329
|
+
const cloudIdentifier = await getCloudIdentifier(rl, options);
|
|
305
330
|
rl.close();
|
|
306
331
|
return {
|
|
307
332
|
applicationType: options.applicationType,
|
|
@@ -311,6 +336,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
311
336
|
tagOrBranchVersion,
|
|
312
337
|
entryPointUriPath,
|
|
313
338
|
initialProjectKey,
|
|
339
|
+
cloudIdentifier,
|
|
314
340
|
packageManager: options.packageManager
|
|
315
341
|
};
|
|
316
342
|
}
|
|
@@ -454,6 +480,11 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
454
480
|
}) && nodePath.parent.type === 'ObjectProperty') {
|
|
455
481
|
nodePath.parent.value = core.types.stringLiteral(options.initialProjectKey);
|
|
456
482
|
}
|
|
483
|
+
if (nodePath.isIdentifier({
|
|
484
|
+
name: 'cloudIdentifier'
|
|
485
|
+
}) && nodePath.parent.type === 'ObjectProperty') {
|
|
486
|
+
nodePath.parent.value = core.types.stringLiteral(options.cloudIdentifier);
|
|
487
|
+
}
|
|
457
488
|
if (options.applicationType === applicationTypes['custom-application'] && nodePath.isIdentifier({
|
|
458
489
|
name: 'defaultLabel'
|
|
459
490
|
})) {
|
|
@@ -561,7 +592,7 @@ const run = () => {
|
|
|
561
592
|
default: false
|
|
562
593
|
}).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', {
|
|
563
594
|
default: false
|
|
564
|
-
}).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').option('--package-manager <value>', '(optional) The preferred package manager to use: npm, yarn, pnpm.').action(async (projectDirectory, options) => {
|
|
595
|
+
}).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').option('--cloud-identifier <value>', '(optional) Cloud region identifier. (default: gcp-eu)').option('--package-manager <value>', '(optional) The preferred package manager to use: npm, yarn, pnpm.').action(async (projectDirectory, options) => {
|
|
565
596
|
var _context, _context2;
|
|
566
597
|
if (!projectDirectory) {
|
|
567
598
|
cli.outputHelp();
|
|
@@ -9,6 +9,7 @@ import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/i
|
|
|
9
9
|
import crypto from 'node:crypto';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import readline from 'node:readline';
|
|
12
|
+
import { CLOUD_IDENTIFIERS } from '@commercetools-frontend/application-config';
|
|
12
13
|
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
13
14
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
14
15
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
@@ -35,7 +36,7 @@ import prettier from 'prettier';
|
|
|
35
36
|
|
|
36
37
|
var pkgJson = {
|
|
37
38
|
name: "@commercetools-frontend/create-mc-app",
|
|
38
|
-
version: "22.
|
|
39
|
+
version: "22.30.0",
|
|
39
40
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
40
41
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
41
42
|
repository: {
|
|
@@ -61,6 +62,7 @@ var pkgJson = {
|
|
|
61
62
|
"@babel/core": "^7.22.17",
|
|
62
63
|
"@babel/runtime": "^7.22.15",
|
|
63
64
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
65
|
+
"@commercetools-frontend/application-config": "^22.30.0",
|
|
64
66
|
"@types/babel__core": "^7.20.1",
|
|
65
67
|
"@types/semver": "^7.5.1",
|
|
66
68
|
cac: "6.7.14",
|
|
@@ -218,6 +220,13 @@ const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRan
|
|
|
218
220
|
throw new Error(_concatInstanceProperty(_context8 = "You are running Node ".concat(currentNodeVersion, " but create-mc-app requires Node ")).call(_context8, expectedVersionRange, ". Please update your version of Node."));
|
|
219
221
|
}
|
|
220
222
|
};
|
|
223
|
+
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
224
|
+
const allowedCloudIdentifiers = _Object$values(CLOUD_IDENTIFIERS);
|
|
225
|
+
if (!_includesInstanceProperty(allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
226
|
+
var _context9;
|
|
227
|
+
throw new Error(_concatInstanceProperty(_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
228
|
+
}
|
|
229
|
+
};
|
|
221
230
|
|
|
222
231
|
const question = (rl, value) => new _Promise(resolve => rl.question(value, resolve));
|
|
223
232
|
const getEntryPointUriPath = async (rl, options) => {
|
|
@@ -243,6 +252,21 @@ const getInitialProjectKey = async (rl, options) => {
|
|
|
243
252
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
244
253
|
return initialProjectKey;
|
|
245
254
|
};
|
|
255
|
+
const getCloudIdentifier = async (rl, options) => {
|
|
256
|
+
if (options.cloudIdentifier) {
|
|
257
|
+
throwIfCloudIdentifierIsNotSupported(options.cloudIdentifier);
|
|
258
|
+
return options.cloudIdentifier;
|
|
259
|
+
}
|
|
260
|
+
if (options.yes) {
|
|
261
|
+
return CLOUD_IDENTIFIERS.GCP_EU;
|
|
262
|
+
}
|
|
263
|
+
const cloudIdentifier = await question(rl, 'Provide the cloudIdentifier (default "gcp-eu"): ');
|
|
264
|
+
if (!cloudIdentifier) {
|
|
265
|
+
return CLOUD_IDENTIFIERS.GCP_EU;
|
|
266
|
+
}
|
|
267
|
+
throwIfCloudIdentifierIsNotSupported(cloudIdentifier);
|
|
268
|
+
return cloudIdentifier;
|
|
269
|
+
};
|
|
246
270
|
async function processOptions(projectDirectoryName, options) {
|
|
247
271
|
if (!projectDirectoryName) {
|
|
248
272
|
throw new Error('Missing required argument "[project-directory]"');
|
|
@@ -266,6 +290,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
266
290
|
});
|
|
267
291
|
const entryPointUriPath = await getEntryPointUriPath(rl, options);
|
|
268
292
|
const initialProjectKey = await getInitialProjectKey(rl, options);
|
|
293
|
+
const cloudIdentifier = await getCloudIdentifier(rl, options);
|
|
269
294
|
rl.close();
|
|
270
295
|
return {
|
|
271
296
|
applicationType: options.applicationType,
|
|
@@ -275,6 +300,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
275
300
|
tagOrBranchVersion,
|
|
276
301
|
entryPointUriPath,
|
|
277
302
|
initialProjectKey,
|
|
303
|
+
cloudIdentifier,
|
|
278
304
|
packageManager: options.packageManager
|
|
279
305
|
};
|
|
280
306
|
}
|
|
@@ -418,6 +444,11 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
418
444
|
}) && nodePath.parent.type === 'ObjectProperty') {
|
|
419
445
|
nodePath.parent.value = types.stringLiteral(options.initialProjectKey);
|
|
420
446
|
}
|
|
447
|
+
if (nodePath.isIdentifier({
|
|
448
|
+
name: 'cloudIdentifier'
|
|
449
|
+
}) && nodePath.parent.type === 'ObjectProperty') {
|
|
450
|
+
nodePath.parent.value = types.stringLiteral(options.cloudIdentifier);
|
|
451
|
+
}
|
|
421
452
|
if (options.applicationType === applicationTypes['custom-application'] && nodePath.isIdentifier({
|
|
422
453
|
name: 'defaultLabel'
|
|
423
454
|
})) {
|
|
@@ -525,7 +556,7 @@ const run = () => {
|
|
|
525
556
|
default: false
|
|
526
557
|
}).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', {
|
|
527
558
|
default: false
|
|
528
|
-
}).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').option('--package-manager <value>', '(optional) The preferred package manager to use: npm, yarn, pnpm.').action(async (projectDirectory, options) => {
|
|
559
|
+
}).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').option('--cloud-identifier <value>', '(optional) Cloud region identifier. (default: gcp-eu)').option('--package-manager <value>', '(optional) The preferred package manager to use: npm, yarn, pnpm.').action(async (projectDirectory, options) => {
|
|
529
560
|
var _context, _context2;
|
|
530
561
|
if (!projectDirectory) {
|
|
531
562
|
cli.outputHelp();
|
|
@@ -13,6 +13,7 @@ export type TCliCommandOptions = {
|
|
|
13
13
|
yes: boolean;
|
|
14
14
|
entryPointUriPath?: string;
|
|
15
15
|
initialProjectKey?: string;
|
|
16
|
+
cloudIdentifier?: string;
|
|
16
17
|
packageManager?: TPackageManager;
|
|
17
18
|
};
|
|
18
19
|
export type TCliTaskOptions = {
|
|
@@ -23,5 +24,6 @@ export type TCliTaskOptions = {
|
|
|
23
24
|
tagOrBranchVersion: string;
|
|
24
25
|
entryPointUriPath?: string;
|
|
25
26
|
initialProjectKey: string;
|
|
27
|
+
cloudIdentifier: string;
|
|
26
28
|
packageManager: TCliCommandOptions['packageManager'];
|
|
27
29
|
};
|
|
@@ -5,4 +5,5 @@ declare const throwIfProjectDirectoryExists: (dirName: string, dirPath: string)
|
|
|
5
5
|
declare const throwIfTemplateVersionDoesNotExist: (templateName: string, templateFolderPath: string, versionToCheck: string) => void;
|
|
6
6
|
declare const throwIfInitialProjectKeyIsMissing: (initialProjectKey?: string) => void;
|
|
7
7
|
declare const throwIfNodeVersionIsNotSupported: (currentNodeVersion: string, expectedVersionRange: string) => void;
|
|
8
|
-
|
|
8
|
+
declare const throwIfCloudIdentifierIsNotSupported: (cloudIdentifier: string) => void;
|
|
9
|
+
export { throwIfApplicationTypeIsNotSupported, throwIfTemplateIsNotSupported, throwIfProjectDirectoryExists, throwIfTemplateVersionDoesNotExist, throwIfInitialProjectKeyIsMissing, throwIfNodeVersionIsNotSupported, throwIfCloudIdentifierIsNotSupported, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/create-mc-app",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.30.0",
|
|
4
4
|
"description": "Create Merchant Center applications to quickly get up and running",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@babel/core": "^7.22.17",
|
|
27
27
|
"@babel/runtime": "^7.22.15",
|
|
28
28
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
29
|
+
"@commercetools-frontend/application-config": "^22.30.0",
|
|
29
30
|
"@types/babel__core": "^7.20.1",
|
|
30
31
|
"@types/semver": "^7.5.1",
|
|
31
32
|
"cac": "6.7.14",
|
package/src/cli.ts
CHANGED
|
@@ -70,6 +70,10 @@ const run = () => {
|
|
|
70
70
|
'--initial-project-key <value>',
|
|
71
71
|
'(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.'
|
|
72
72
|
)
|
|
73
|
+
.option(
|
|
74
|
+
'--cloud-identifier <value>',
|
|
75
|
+
'(optional) Cloud region identifier. (default: gcp-eu)'
|
|
76
|
+
)
|
|
73
77
|
.option(
|
|
74
78
|
'--package-manager <value>',
|
|
75
79
|
'(optional) The preferred package manager to use: npm, yarn, pnpm.'
|
package/src/process-options.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import readline, { type Interface } from 'node:readline';
|
|
4
|
+
import { CLOUD_IDENTIFIERS } from '@commercetools-frontend/application-config';
|
|
4
5
|
import { applicationTypes } from './constants';
|
|
5
6
|
import type { TCliCommandOptions, TCliTaskOptions } from './types';
|
|
6
7
|
import { isSemVer } from './utils';
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
throwIfProjectDirectoryExists,
|
|
10
11
|
throwIfInitialProjectKeyIsMissing,
|
|
11
12
|
throwIfApplicationTypeIsNotSupported,
|
|
13
|
+
throwIfCloudIdentifierIsNotSupported,
|
|
12
14
|
} from './validations';
|
|
13
15
|
|
|
14
16
|
const question = (rl: Interface, value: string) =>
|
|
@@ -59,6 +61,30 @@ const getInitialProjectKey = async (
|
|
|
59
61
|
return initialProjectKey;
|
|
60
62
|
};
|
|
61
63
|
|
|
64
|
+
const getCloudIdentifier = async (
|
|
65
|
+
rl: Interface,
|
|
66
|
+
options: TCliCommandOptions
|
|
67
|
+
) => {
|
|
68
|
+
if (options.cloudIdentifier) {
|
|
69
|
+
throwIfCloudIdentifierIsNotSupported(options.cloudIdentifier);
|
|
70
|
+
return options.cloudIdentifier;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (options.yes) {
|
|
74
|
+
return CLOUD_IDENTIFIERS.GCP_EU;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const cloudIdentifier = await question(
|
|
78
|
+
rl,
|
|
79
|
+
'Provide the cloudIdentifier (default "gcp-eu"): '
|
|
80
|
+
);
|
|
81
|
+
if (!cloudIdentifier) {
|
|
82
|
+
return CLOUD_IDENTIFIERS.GCP_EU;
|
|
83
|
+
}
|
|
84
|
+
throwIfCloudIdentifierIsNotSupported(cloudIdentifier);
|
|
85
|
+
return cloudIdentifier;
|
|
86
|
+
};
|
|
87
|
+
|
|
62
88
|
async function processOptions(
|
|
63
89
|
projectDirectoryName: string,
|
|
64
90
|
options: TCliCommandOptions
|
|
@@ -89,6 +115,7 @@ async function processOptions(
|
|
|
89
115
|
});
|
|
90
116
|
const entryPointUriPath = await getEntryPointUriPath(rl, options);
|
|
91
117
|
const initialProjectKey = await getInitialProjectKey(rl, options);
|
|
118
|
+
const cloudIdentifier = await getCloudIdentifier(rl, options);
|
|
92
119
|
rl.close();
|
|
93
120
|
|
|
94
121
|
return {
|
|
@@ -99,6 +126,7 @@ async function processOptions(
|
|
|
99
126
|
tagOrBranchVersion,
|
|
100
127
|
entryPointUriPath,
|
|
101
128
|
initialProjectKey,
|
|
129
|
+
cloudIdentifier,
|
|
102
130
|
packageManager: options.packageManager,
|
|
103
131
|
};
|
|
104
132
|
}
|
|
@@ -35,6 +35,14 @@ function replaceApplicationInfoInApplicationConfig(
|
|
|
35
35
|
options.initialProjectKey
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
+
if (
|
|
39
|
+
nodePath.isIdentifier({ name: 'cloudIdentifier' }) &&
|
|
40
|
+
nodePath.parent.type === 'ObjectProperty'
|
|
41
|
+
) {
|
|
42
|
+
nodePath.parent.value = types.stringLiteral(
|
|
43
|
+
options.cloudIdentifier
|
|
44
|
+
);
|
|
45
|
+
}
|
|
38
46
|
if (
|
|
39
47
|
options.applicationType ===
|
|
40
48
|
applicationTypes['custom-application'] &&
|
package/src/types.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type TCliCommandOptions = {
|
|
|
16
16
|
yes: boolean;
|
|
17
17
|
entryPointUriPath?: string;
|
|
18
18
|
initialProjectKey?: string;
|
|
19
|
+
cloudIdentifier?: string;
|
|
19
20
|
packageManager?: TPackageManager;
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -27,5 +28,6 @@ export type TCliTaskOptions = {
|
|
|
27
28
|
tagOrBranchVersion: string;
|
|
28
29
|
entryPointUriPath?: string;
|
|
29
30
|
initialProjectKey: string;
|
|
31
|
+
cloudIdentifier: string;
|
|
30
32
|
packageManager: TCliCommandOptions['packageManager'];
|
|
31
33
|
};
|
package/src/validations.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import semver from 'semver';
|
|
4
|
+
import { CLOUD_IDENTIFIERS } from '@commercetools-frontend/application-config';
|
|
4
5
|
import { applicationTypes, availableTemplates } from './constants';
|
|
5
6
|
import type { TApplicationType, TTemplate } from './types';
|
|
6
7
|
import { isSemVer, doesFileExist } from './utils';
|
|
@@ -87,6 +88,18 @@ const throwIfNodeVersionIsNotSupported = (
|
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
90
|
|
|
91
|
+
const throwIfCloudIdentifierIsNotSupported = (cloudIdentifier: string) => {
|
|
92
|
+
const allowedCloudIdentifiers = Object.values(CLOUD_IDENTIFIERS) as string[];
|
|
93
|
+
|
|
94
|
+
if (!allowedCloudIdentifiers.includes(cloudIdentifier)) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(
|
|
97
|
+
', '
|
|
98
|
+
)}.`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
90
103
|
export {
|
|
91
104
|
throwIfApplicationTypeIsNotSupported,
|
|
92
105
|
throwIfTemplateIsNotSupported,
|
|
@@ -94,4 +107,5 @@ export {
|
|
|
94
107
|
throwIfTemplateVersionDoesNotExist,
|
|
95
108
|
throwIfInitialProjectKeyIsMissing,
|
|
96
109
|
throwIfNodeVersionIsNotSupported,
|
|
110
|
+
throwIfCloudIdentifierIsNotSupported,
|
|
97
111
|
};
|