@commercetools-frontend/create-mc-app 22.30.2 → 22.31.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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @commercetools-frontend/create-mc-app
|
|
2
2
|
|
|
3
|
+
## 22.31.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`2fe2e11`](https://github.com/commercetools/merchant-center-application-kit/commit/2fe2e119982c7fa347f70ac8e203eb1f1e1743b7)]:
|
|
8
|
+
- @commercetools-frontend/application-config@22.31.0
|
|
9
|
+
|
|
10
|
+
## 22.30.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies []:
|
|
15
|
+
- @commercetools-frontend/application-config@22.30.3
|
|
16
|
+
|
|
3
17
|
## 22.30.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
7
6
|
var cac = require('cac');
|
|
8
7
|
var listr2 = require('listr2');
|
|
9
8
|
var execa = require('execa');
|
|
@@ -41,7 +40,6 @@ var prettier = require('prettier');
|
|
|
41
40
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
42
41
|
|
|
43
42
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
44
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
45
43
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
46
44
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
47
45
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
@@ -72,7 +70,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
72
70
|
|
|
73
71
|
var pkgJson = {
|
|
74
72
|
name: "@commercetools-frontend/create-mc-app",
|
|
75
|
-
version: "22.
|
|
73
|
+
version: "22.31.0",
|
|
76
74
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
77
75
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
78
76
|
repository: {
|
|
@@ -98,7 +96,7 @@ var pkgJson = {
|
|
|
98
96
|
"@babel/core": "^7.22.17",
|
|
99
97
|
"@babel/runtime": "^7.22.15",
|
|
100
98
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
101
|
-
"@commercetools-frontend/application-config": "^22.
|
|
99
|
+
"@commercetools-frontend/application-config": "^22.31.0",
|
|
102
100
|
"@types/babel__core": "^7.20.1",
|
|
103
101
|
"@types/semver": "^7.5.1",
|
|
104
102
|
cac: "6.7.14",
|
|
@@ -135,11 +133,10 @@ async function getLatestReleaseVersion() {
|
|
|
135
133
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
136
134
|
var _context;
|
|
137
135
|
const hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
|
|
138
|
-
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag &&
|
|
136
|
+
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
139
137
|
if (hintNewerVersions.length > 0) {
|
|
140
|
-
var _context2;
|
|
141
138
|
console.log('');
|
|
142
|
-
console.log(
|
|
139
|
+
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
143
140
|
console.log('');
|
|
144
141
|
}
|
|
145
142
|
}
|
|
@@ -180,7 +177,7 @@ const getInstallCommand = options => {
|
|
|
180
177
|
case 'npm':
|
|
181
178
|
return 'npm install --legacy-peer-deps';
|
|
182
179
|
default:
|
|
183
|
-
return
|
|
180
|
+
return `${packageManager} install`;
|
|
184
181
|
}
|
|
185
182
|
};
|
|
186
183
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -190,21 +187,19 @@ const wordify = slug => {
|
|
|
190
187
|
return _mapInstanceProperty__default["default"](_context = slug.split('-')).call(_context, word => upperFirst(word)).join(' ');
|
|
191
188
|
};
|
|
192
189
|
const resolveFilePathByExtension = requestedModule => {
|
|
193
|
-
var _context2
|
|
190
|
+
var _context2;
|
|
194
191
|
const fileExtension = _findInstanceProperty__default["default"](_context2 = ['.js', '.ts', '.mjs', '.cjs']).call(_context2, ext => {
|
|
195
|
-
|
|
196
|
-
const filePath = _concatInstanceProperty__default["default"](_context3 = "".concat(requestedModule)).call(_context3, ext);
|
|
192
|
+
const filePath = `${requestedModule}${ext}`;
|
|
197
193
|
return doesFileExist(filePath);
|
|
198
194
|
});
|
|
199
|
-
return
|
|
195
|
+
return `${requestedModule}${fileExtension}`;
|
|
200
196
|
};
|
|
201
197
|
|
|
202
198
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
203
199
|
var _context;
|
|
204
200
|
const applicationTypesList = _Object$keys__default["default"](applicationTypes);
|
|
205
201
|
if (!_includesInstanceProperty__default["default"](_context = _Object$values__default["default"](applicationTypesList)).call(_context, applicationType)) {
|
|
206
|
-
|
|
207
|
-
throw new Error(_concatInstanceProperty__default["default"](_context2 = "The provided application type \"".concat(applicationType.toString(), "\" does not exist. Available types are \"")).call(_context2, applicationTypesList, "\". Make sure you are also using the latest version of \"@commercetools-frontend/create-mc-app\"."));
|
|
202
|
+
throw new Error(`The provided application type "${applicationType.toString()}" does not exist. Available types are "${applicationTypesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`);
|
|
208
203
|
}
|
|
209
204
|
};
|
|
210
205
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -214,22 +209,19 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
214
209
|
break;
|
|
215
210
|
default:
|
|
216
211
|
{
|
|
217
|
-
var _context3;
|
|
218
212
|
const templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
|
|
219
|
-
throw new Error(
|
|
213
|
+
throw new Error(`The provided template name "${templateName}" does not exist. Available templates are "${templateNamesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`);
|
|
220
214
|
}
|
|
221
215
|
}
|
|
222
216
|
};
|
|
223
217
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
224
218
|
if (doesFileExist(dirPath)) {
|
|
225
|
-
|
|
226
|
-
throw new Error(_concatInstanceProperty__default["default"](_context4 = "A directory named \"".concat(dirName, "\" already exists at this location \"")).call(_context4, dirPath, "\". Please choose a different project name or remove the directory, then try running the command again."));
|
|
219
|
+
throw new Error(`A directory named "${dirName}" already exists at this location "${dirPath}". Please choose a different project name or remove the directory, then try running the command again.`);
|
|
227
220
|
}
|
|
228
221
|
};
|
|
229
222
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
230
223
|
if (!doesFileExist(templateFolderPath)) {
|
|
231
|
-
|
|
232
|
-
throw new Error(_concatInstanceProperty__default["default"](_context5 = "The downloaded template \"".concat(templateName, "\" does not exist for the given version \"")).call(_context5, versionToCheck, "\". Check the releases page if you are looking for a specific version: https://github.com/commercetools/merchant-center-application-kit/releases"));
|
|
224
|
+
throw new Error(`The downloaded template "${templateName}" does not exist for the given version "${versionToCheck}". Check the releases page if you are looking for a specific version: https://github.com/commercetools/merchant-center-application-kit/releases`);
|
|
233
225
|
}
|
|
234
226
|
// In case the version is semver (usually release tags) we check that
|
|
235
227
|
// the cloned repository contains the template matching the given version
|
|
@@ -239,52 +231,48 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
239
231
|
}));
|
|
240
232
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
241
233
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
242
|
-
|
|
243
|
-
throw new Error(_concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = "The downloaded template \"".concat(templateName, "\" does not match the version \"")).call(_context7, versionAsNumber, "\", instead got \"")).call(_context6, templatePackageJson.version, "\". Check the releases page if you want to provide a specific version: https://github.com/commercetools/merchant-center-application-kit/releases"));
|
|
234
|
+
throw new Error(`The downloaded template "${templateName}" does not match the version "${versionAsNumber}", instead got "${templatePackageJson.version}". Check the releases page if you want to provide a specific version: https://github.com/commercetools/merchant-center-application-kit/releases`);
|
|
244
235
|
}
|
|
245
236
|
}
|
|
246
237
|
};
|
|
247
238
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
248
239
|
if (!initialProjectKey) {
|
|
249
|
-
throw new Error(
|
|
240
|
+
throw new Error(`Provide a valid project key that you have access to.`);
|
|
250
241
|
}
|
|
251
242
|
};
|
|
252
243
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
253
244
|
const hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
|
|
254
245
|
if (!hasValidNodeVersion) {
|
|
255
|
-
|
|
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."));
|
|
246
|
+
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
257
247
|
}
|
|
258
248
|
};
|
|
259
249
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
260
250
|
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
261
251
|
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
262
|
-
|
|
263
|
-
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
252
|
+
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
264
253
|
}
|
|
265
254
|
};
|
|
266
255
|
|
|
267
256
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
268
257
|
const getEntryPointUriPath = async (rl, options) => {
|
|
269
|
-
var _context;
|
|
270
258
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
271
259
|
return;
|
|
272
260
|
}
|
|
273
261
|
if (options.entryPointUriPath) {
|
|
274
262
|
return options.entryPointUriPath;
|
|
275
263
|
}
|
|
276
|
-
const randomEntryPointUriPath =
|
|
264
|
+
const randomEntryPointUriPath = `${options.template}-${crypto__default["default"].randomBytes(3).toString('hex')}`;
|
|
277
265
|
if (options.yes) {
|
|
278
266
|
return randomEntryPointUriPath;
|
|
279
267
|
}
|
|
280
|
-
const answerEntryPointUriPath = await question(rl,
|
|
268
|
+
const answerEntryPointUriPath = await question(rl, `Provide the Custom Application entryPointUriPath (default "${randomEntryPointUriPath}"): `);
|
|
281
269
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
282
270
|
};
|
|
283
271
|
const getInitialProjectKey = async (rl, options) => {
|
|
284
272
|
if (options.initialProjectKey) {
|
|
285
273
|
return options.initialProjectKey;
|
|
286
274
|
}
|
|
287
|
-
const initialProjectKey = await question(rl,
|
|
275
|
+
const initialProjectKey = await question(rl, `Provide the initial project key for local development: `);
|
|
288
276
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
289
277
|
return initialProjectKey;
|
|
290
278
|
};
|
|
@@ -311,7 +299,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
311
299
|
|
|
312
300
|
// Parse options
|
|
313
301
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
314
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
302
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
315
303
|
const templateName = options.template;
|
|
316
304
|
|
|
317
305
|
// Validate options
|
|
@@ -346,16 +334,15 @@ function downloadTemplate(options) {
|
|
|
346
334
|
return {
|
|
347
335
|
title: 'Downloading template',
|
|
348
336
|
task: () => {
|
|
349
|
-
var _context;
|
|
350
337
|
const tmpDir = os__default["default"].tmpdir();
|
|
351
338
|
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default["default"]().toString()].join('');
|
|
352
339
|
const clonedRepositoryPath = path__default["default"].join(tmpDir, tmpFolderNameForClonedRepository);
|
|
353
340
|
const templateFolderPath = path__default["default"].join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
354
341
|
return new listr2.Listr([{
|
|
355
|
-
title:
|
|
342
|
+
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
356
343
|
task: async () => {
|
|
357
344
|
// Shallow clone repository
|
|
358
|
-
const result = await execa__default["default"]('git', ['clone',
|
|
345
|
+
const result = await execa__default["default"]('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
359
346
|
cwd: tmpDir,
|
|
360
347
|
encoding: 'utf-8'
|
|
361
348
|
});
|
|
@@ -366,7 +353,7 @@ function downloadTemplate(options) {
|
|
|
366
353
|
return result.stdout;
|
|
367
354
|
}
|
|
368
355
|
}, {
|
|
369
|
-
title:
|
|
356
|
+
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
370
357
|
task: async () => {
|
|
371
358
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
372
359
|
const result = await execa__default["default"](command, [templateFolderPath,
|
|
@@ -379,12 +366,12 @@ function downloadTemplate(options) {
|
|
|
379
366
|
}
|
|
380
367
|
const templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
|
|
381
368
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
382
|
-
throw new Error(
|
|
369
|
+
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
383
370
|
}
|
|
384
371
|
return result.stdout;
|
|
385
372
|
}
|
|
386
373
|
}, {
|
|
387
|
-
title:
|
|
374
|
+
title: `Cleaning up project directory`,
|
|
388
375
|
task: async () => {
|
|
389
376
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
390
377
|
const result = await execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, filePath => path__default["default"].join(options.projectDirectoryPath, filePath)), {
|
|
@@ -465,8 +452,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
465
452
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
466
453
|
const result = core.transformFileSync(filePath, {
|
|
467
454
|
plugins: [function replaceConfig() {
|
|
468
|
-
|
|
469
|
-
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
455
|
+
const appName = wordify(options.entryPointUriPath ?? options.projectDirectoryName);
|
|
470
456
|
return {
|
|
471
457
|
visitor: {
|
|
472
458
|
Identifier(nodePath) {
|
|
@@ -501,9 +487,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
501
487
|
}],
|
|
502
488
|
retainLines: true
|
|
503
489
|
});
|
|
504
|
-
if (result
|
|
490
|
+
if (result?.code) {
|
|
505
491
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
506
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
492
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
507
493
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
508
494
|
encoding: 'utf8'
|
|
509
495
|
});
|
|
@@ -516,7 +502,7 @@ function getApplicationConfigName(options) {
|
|
|
516
502
|
case applicationTypes['custom-view']:
|
|
517
503
|
return 'custom-view-config';
|
|
518
504
|
default:
|
|
519
|
-
throw new Error(
|
|
505
|
+
throw new Error(`Unknown application type ${options.applicationType}`);
|
|
520
506
|
}
|
|
521
507
|
}
|
|
522
508
|
function updateApplicationConfig(options) {
|
|
@@ -544,9 +530,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
544
530
|
}],
|
|
545
531
|
retainLines: true
|
|
546
532
|
});
|
|
547
|
-
if (result
|
|
533
|
+
if (result?.code) {
|
|
548
534
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
549
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
535
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
550
536
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
551
537
|
encoding: 'utf8'
|
|
552
538
|
});
|
|
@@ -593,7 +579,7 @@ const run = () => {
|
|
|
593
579
|
}).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', {
|
|
594
580
|
default: false
|
|
595
581
|
}).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) => {
|
|
596
|
-
var _context
|
|
582
|
+
var _context;
|
|
597
583
|
if (!projectDirectory) {
|
|
598
584
|
cli.outputHelp();
|
|
599
585
|
return;
|
|
@@ -612,16 +598,16 @@ const run = () => {
|
|
|
612
598
|
await taskList.run();
|
|
613
599
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
614
600
|
console.log('');
|
|
615
|
-
console.log(
|
|
601
|
+
console.log(`🎉 🎉 🎉 The ${messages.featureName} has been created in the "${taskOptions.projectDirectoryName}" folder.`);
|
|
616
602
|
console.log('');
|
|
617
|
-
console.log(
|
|
618
|
-
console.log(
|
|
603
|
+
console.log(`To get started:`);
|
|
604
|
+
console.log(`$ cd ${taskOptions.projectDirectoryName}`);
|
|
619
605
|
if (!shouldInstallDependencies) {
|
|
620
|
-
console.log(
|
|
606
|
+
console.log(`$ ${packageManager} install`);
|
|
621
607
|
}
|
|
622
|
-
console.log(
|
|
608
|
+
console.log(`$ ${packageManager} start`);
|
|
623
609
|
console.log('');
|
|
624
|
-
console.log(
|
|
610
|
+
console.log(`Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ${messages.featureName}. Enjoy 🚀`);
|
|
625
611
|
});
|
|
626
612
|
cli.help();
|
|
627
613
|
cli.version(pkgJson.version);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
7
6
|
var cac = require('cac');
|
|
8
7
|
var listr2 = require('listr2');
|
|
9
8
|
var execa = require('execa');
|
|
@@ -41,7 +40,6 @@ var prettier = require('prettier');
|
|
|
41
40
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
42
41
|
|
|
43
42
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
44
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
45
43
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
46
44
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
47
45
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
@@ -72,7 +70,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
72
70
|
|
|
73
71
|
var pkgJson = {
|
|
74
72
|
name: "@commercetools-frontend/create-mc-app",
|
|
75
|
-
version: "22.
|
|
73
|
+
version: "22.31.0",
|
|
76
74
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
77
75
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
78
76
|
repository: {
|
|
@@ -98,7 +96,7 @@ var pkgJson = {
|
|
|
98
96
|
"@babel/core": "^7.22.17",
|
|
99
97
|
"@babel/runtime": "^7.22.15",
|
|
100
98
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
101
|
-
"@commercetools-frontend/application-config": "^22.
|
|
99
|
+
"@commercetools-frontend/application-config": "^22.31.0",
|
|
102
100
|
"@types/babel__core": "^7.20.1",
|
|
103
101
|
"@types/semver": "^7.5.1",
|
|
104
102
|
cac: "6.7.14",
|
|
@@ -135,11 +133,10 @@ async function getLatestReleaseVersion() {
|
|
|
135
133
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
136
134
|
var _context;
|
|
137
135
|
const hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
|
|
138
|
-
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag &&
|
|
136
|
+
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
139
137
|
if (hintNewerVersions.length > 0) {
|
|
140
|
-
var _context2;
|
|
141
138
|
console.log('');
|
|
142
|
-
console.log(
|
|
139
|
+
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
143
140
|
console.log('');
|
|
144
141
|
}
|
|
145
142
|
}
|
|
@@ -180,7 +177,7 @@ const getInstallCommand = options => {
|
|
|
180
177
|
case 'npm':
|
|
181
178
|
return 'npm install --legacy-peer-deps';
|
|
182
179
|
default:
|
|
183
|
-
return
|
|
180
|
+
return `${packageManager} install`;
|
|
184
181
|
}
|
|
185
182
|
};
|
|
186
183
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -190,21 +187,19 @@ const wordify = slug => {
|
|
|
190
187
|
return _mapInstanceProperty__default["default"](_context = slug.split('-')).call(_context, word => upperFirst(word)).join(' ');
|
|
191
188
|
};
|
|
192
189
|
const resolveFilePathByExtension = requestedModule => {
|
|
193
|
-
var _context2
|
|
190
|
+
var _context2;
|
|
194
191
|
const fileExtension = _findInstanceProperty__default["default"](_context2 = ['.js', '.ts', '.mjs', '.cjs']).call(_context2, ext => {
|
|
195
|
-
|
|
196
|
-
const filePath = _concatInstanceProperty__default["default"](_context3 = "".concat(requestedModule)).call(_context3, ext);
|
|
192
|
+
const filePath = `${requestedModule}${ext}`;
|
|
197
193
|
return doesFileExist(filePath);
|
|
198
194
|
});
|
|
199
|
-
return
|
|
195
|
+
return `${requestedModule}${fileExtension}`;
|
|
200
196
|
};
|
|
201
197
|
|
|
202
198
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
203
199
|
var _context;
|
|
204
200
|
const applicationTypesList = _Object$keys__default["default"](applicationTypes);
|
|
205
201
|
if (!_includesInstanceProperty__default["default"](_context = _Object$values__default["default"](applicationTypesList)).call(_context, applicationType)) {
|
|
206
|
-
|
|
207
|
-
throw new Error(_concatInstanceProperty__default["default"](_context2 = "The provided application type \"".concat(applicationType.toString(), "\" does not exist. Available types are \"")).call(_context2, applicationTypesList, "\". Make sure you are also using the latest version of \"@commercetools-frontend/create-mc-app\"."));
|
|
202
|
+
throw new Error(`The provided application type "${applicationType.toString()}" does not exist. Available types are "${applicationTypesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`);
|
|
208
203
|
}
|
|
209
204
|
};
|
|
210
205
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -214,22 +209,19 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
214
209
|
break;
|
|
215
210
|
default:
|
|
216
211
|
{
|
|
217
|
-
var _context3;
|
|
218
212
|
const templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
|
|
219
|
-
throw new Error(
|
|
213
|
+
throw new Error(`The provided template name "${templateName}" does not exist. Available templates are "${templateNamesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`);
|
|
220
214
|
}
|
|
221
215
|
}
|
|
222
216
|
};
|
|
223
217
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
224
218
|
if (doesFileExist(dirPath)) {
|
|
225
|
-
|
|
226
|
-
throw new Error(_concatInstanceProperty__default["default"](_context4 = "A directory named \"".concat(dirName, "\" already exists at this location \"")).call(_context4, dirPath, "\". Please choose a different project name or remove the directory, then try running the command again."));
|
|
219
|
+
throw new Error(`A directory named "${dirName}" already exists at this location "${dirPath}". Please choose a different project name or remove the directory, then try running the command again.`);
|
|
227
220
|
}
|
|
228
221
|
};
|
|
229
222
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
230
223
|
if (!doesFileExist(templateFolderPath)) {
|
|
231
|
-
|
|
232
|
-
throw new Error(_concatInstanceProperty__default["default"](_context5 = "The downloaded template \"".concat(templateName, "\" does not exist for the given version \"")).call(_context5, versionToCheck, "\". Check the releases page if you are looking for a specific version: https://github.com/commercetools/merchant-center-application-kit/releases"));
|
|
224
|
+
throw new Error(`The downloaded template "${templateName}" does not exist for the given version "${versionToCheck}". Check the releases page if you are looking for a specific version: https://github.com/commercetools/merchant-center-application-kit/releases`);
|
|
233
225
|
}
|
|
234
226
|
// In case the version is semver (usually release tags) we check that
|
|
235
227
|
// the cloned repository contains the template matching the given version
|
|
@@ -239,52 +231,48 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
239
231
|
}));
|
|
240
232
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
241
233
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
242
|
-
|
|
243
|
-
throw new Error(_concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = "The downloaded template \"".concat(templateName, "\" does not match the version \"")).call(_context7, versionAsNumber, "\", instead got \"")).call(_context6, templatePackageJson.version, "\". Check the releases page if you want to provide a specific version: https://github.com/commercetools/merchant-center-application-kit/releases"));
|
|
234
|
+
throw new Error(`The downloaded template "${templateName}" does not match the version "${versionAsNumber}", instead got "${templatePackageJson.version}". Check the releases page if you want to provide a specific version: https://github.com/commercetools/merchant-center-application-kit/releases`);
|
|
244
235
|
}
|
|
245
236
|
}
|
|
246
237
|
};
|
|
247
238
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
248
239
|
if (!initialProjectKey) {
|
|
249
|
-
throw new Error(
|
|
240
|
+
throw new Error(`Provide a valid project key that you have access to.`);
|
|
250
241
|
}
|
|
251
242
|
};
|
|
252
243
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
253
244
|
const hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
|
|
254
245
|
if (!hasValidNodeVersion) {
|
|
255
|
-
|
|
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."));
|
|
246
|
+
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
257
247
|
}
|
|
258
248
|
};
|
|
259
249
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
260
250
|
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
261
251
|
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
262
|
-
|
|
263
|
-
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
252
|
+
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
264
253
|
}
|
|
265
254
|
};
|
|
266
255
|
|
|
267
256
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
268
257
|
const getEntryPointUriPath = async (rl, options) => {
|
|
269
|
-
var _context;
|
|
270
258
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
271
259
|
return;
|
|
272
260
|
}
|
|
273
261
|
if (options.entryPointUriPath) {
|
|
274
262
|
return options.entryPointUriPath;
|
|
275
263
|
}
|
|
276
|
-
const randomEntryPointUriPath =
|
|
264
|
+
const randomEntryPointUriPath = `${options.template}-${crypto__default["default"].randomBytes(3).toString('hex')}`;
|
|
277
265
|
if (options.yes) {
|
|
278
266
|
return randomEntryPointUriPath;
|
|
279
267
|
}
|
|
280
|
-
const answerEntryPointUriPath = await question(rl,
|
|
268
|
+
const answerEntryPointUriPath = await question(rl, `Provide the Custom Application entryPointUriPath (default "${randomEntryPointUriPath}"): `);
|
|
281
269
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
282
270
|
};
|
|
283
271
|
const getInitialProjectKey = async (rl, options) => {
|
|
284
272
|
if (options.initialProjectKey) {
|
|
285
273
|
return options.initialProjectKey;
|
|
286
274
|
}
|
|
287
|
-
const initialProjectKey = await question(rl,
|
|
275
|
+
const initialProjectKey = await question(rl, `Provide the initial project key for local development: `);
|
|
288
276
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
289
277
|
return initialProjectKey;
|
|
290
278
|
};
|
|
@@ -311,7 +299,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
311
299
|
|
|
312
300
|
// Parse options
|
|
313
301
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
314
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
302
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
315
303
|
const templateName = options.template;
|
|
316
304
|
|
|
317
305
|
// Validate options
|
|
@@ -346,16 +334,15 @@ function downloadTemplate(options) {
|
|
|
346
334
|
return {
|
|
347
335
|
title: 'Downloading template',
|
|
348
336
|
task: () => {
|
|
349
|
-
var _context;
|
|
350
337
|
const tmpDir = os__default["default"].tmpdir();
|
|
351
338
|
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default["default"]().toString()].join('');
|
|
352
339
|
const clonedRepositoryPath = path__default["default"].join(tmpDir, tmpFolderNameForClonedRepository);
|
|
353
340
|
const templateFolderPath = path__default["default"].join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
354
341
|
return new listr2.Listr([{
|
|
355
|
-
title:
|
|
342
|
+
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
356
343
|
task: async () => {
|
|
357
344
|
// Shallow clone repository
|
|
358
|
-
const result = await execa__default["default"]('git', ['clone',
|
|
345
|
+
const result = await execa__default["default"]('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
359
346
|
cwd: tmpDir,
|
|
360
347
|
encoding: 'utf-8'
|
|
361
348
|
});
|
|
@@ -366,7 +353,7 @@ function downloadTemplate(options) {
|
|
|
366
353
|
return result.stdout;
|
|
367
354
|
}
|
|
368
355
|
}, {
|
|
369
|
-
title:
|
|
356
|
+
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
370
357
|
task: async () => {
|
|
371
358
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
372
359
|
const result = await execa__default["default"](command, [templateFolderPath,
|
|
@@ -379,12 +366,12 @@ function downloadTemplate(options) {
|
|
|
379
366
|
}
|
|
380
367
|
const templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
|
|
381
368
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
382
|
-
throw new Error(
|
|
369
|
+
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
383
370
|
}
|
|
384
371
|
return result.stdout;
|
|
385
372
|
}
|
|
386
373
|
}, {
|
|
387
|
-
title:
|
|
374
|
+
title: `Cleaning up project directory`,
|
|
388
375
|
task: async () => {
|
|
389
376
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
390
377
|
const result = await execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, filePath => path__default["default"].join(options.projectDirectoryPath, filePath)), {
|
|
@@ -465,8 +452,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
465
452
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
466
453
|
const result = core.transformFileSync(filePath, {
|
|
467
454
|
plugins: [function replaceConfig() {
|
|
468
|
-
|
|
469
|
-
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
455
|
+
const appName = wordify(options.entryPointUriPath ?? options.projectDirectoryName);
|
|
470
456
|
return {
|
|
471
457
|
visitor: {
|
|
472
458
|
Identifier(nodePath) {
|
|
@@ -501,9 +487,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
501
487
|
}],
|
|
502
488
|
retainLines: true
|
|
503
489
|
});
|
|
504
|
-
if (result
|
|
490
|
+
if (result?.code) {
|
|
505
491
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
506
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
492
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
507
493
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
508
494
|
encoding: 'utf8'
|
|
509
495
|
});
|
|
@@ -516,7 +502,7 @@ function getApplicationConfigName(options) {
|
|
|
516
502
|
case applicationTypes['custom-view']:
|
|
517
503
|
return 'custom-view-config';
|
|
518
504
|
default:
|
|
519
|
-
throw new Error(
|
|
505
|
+
throw new Error(`Unknown application type ${options.applicationType}`);
|
|
520
506
|
}
|
|
521
507
|
}
|
|
522
508
|
function updateApplicationConfig(options) {
|
|
@@ -544,9 +530,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
544
530
|
}],
|
|
545
531
|
retainLines: true
|
|
546
532
|
});
|
|
547
|
-
if (result
|
|
533
|
+
if (result?.code) {
|
|
548
534
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
549
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
535
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
550
536
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
551
537
|
encoding: 'utf8'
|
|
552
538
|
});
|
|
@@ -593,7 +579,7 @@ const run = () => {
|
|
|
593
579
|
}).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', {
|
|
594
580
|
default: false
|
|
595
581
|
}).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) => {
|
|
596
|
-
var _context
|
|
582
|
+
var _context;
|
|
597
583
|
if (!projectDirectory) {
|
|
598
584
|
cli.outputHelp();
|
|
599
585
|
return;
|
|
@@ -612,16 +598,16 @@ const run = () => {
|
|
|
612
598
|
await taskList.run();
|
|
613
599
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
614
600
|
console.log('');
|
|
615
|
-
console.log(
|
|
601
|
+
console.log(`🎉 🎉 🎉 The ${messages.featureName} has been created in the "${taskOptions.projectDirectoryName}" folder.`);
|
|
616
602
|
console.log('');
|
|
617
|
-
console.log(
|
|
618
|
-
console.log(
|
|
603
|
+
console.log(`To get started:`);
|
|
604
|
+
console.log(`$ cd ${taskOptions.projectDirectoryName}`);
|
|
619
605
|
if (!shouldInstallDependencies) {
|
|
620
|
-
console.log(
|
|
606
|
+
console.log(`$ ${packageManager} install`);
|
|
621
607
|
}
|
|
622
|
-
console.log(
|
|
608
|
+
console.log(`$ ${packageManager} start`);
|
|
623
609
|
console.log('');
|
|
624
|
-
console.log(
|
|
610
|
+
console.log(`Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ${messages.featureName}. Enjoy 🚀`);
|
|
625
611
|
});
|
|
626
612
|
cli.help();
|
|
627
613
|
cli.version(pkgJson.version);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
2
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
3
2
|
import { cac } from 'cac';
|
|
4
3
|
import { Listr } from 'listr2';
|
|
5
4
|
import execa from 'execa';
|
|
@@ -36,7 +35,7 @@ import prettier from 'prettier';
|
|
|
36
35
|
|
|
37
36
|
var pkgJson = {
|
|
38
37
|
name: "@commercetools-frontend/create-mc-app",
|
|
39
|
-
version: "22.
|
|
38
|
+
version: "22.31.0",
|
|
40
39
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
41
40
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
42
41
|
repository: {
|
|
@@ -62,7 +61,7 @@ var pkgJson = {
|
|
|
62
61
|
"@babel/core": "^7.22.17",
|
|
63
62
|
"@babel/runtime": "^7.22.15",
|
|
64
63
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
65
|
-
"@commercetools-frontend/application-config": "^22.
|
|
64
|
+
"@commercetools-frontend/application-config": "^22.31.0",
|
|
66
65
|
"@types/babel__core": "^7.20.1",
|
|
67
66
|
"@types/semver": "^7.5.1",
|
|
68
67
|
cac: "6.7.14",
|
|
@@ -99,11 +98,10 @@ async function getLatestReleaseVersion() {
|
|
|
99
98
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
100
99
|
var _context;
|
|
101
100
|
const hasBeenReleastedInLatestTag = semver.gt(releaseVersion, currentVersion);
|
|
102
|
-
const hintNewerVersions = _filterInstanceProperty(_context = [hasBeenReleastedInLatestTag &&
|
|
101
|
+
const hintNewerVersions = _filterInstanceProperty(_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
103
102
|
if (hintNewerVersions.length > 0) {
|
|
104
|
-
var _context2;
|
|
105
103
|
console.log('');
|
|
106
|
-
console.log(
|
|
104
|
+
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
107
105
|
console.log('');
|
|
108
106
|
}
|
|
109
107
|
}
|
|
@@ -144,7 +142,7 @@ const getInstallCommand = options => {
|
|
|
144
142
|
case 'npm':
|
|
145
143
|
return 'npm install --legacy-peer-deps';
|
|
146
144
|
default:
|
|
147
|
-
return
|
|
145
|
+
return `${packageManager} install`;
|
|
148
146
|
}
|
|
149
147
|
};
|
|
150
148
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -154,21 +152,19 @@ const wordify = slug => {
|
|
|
154
152
|
return _mapInstanceProperty(_context = slug.split('-')).call(_context, word => upperFirst(word)).join(' ');
|
|
155
153
|
};
|
|
156
154
|
const resolveFilePathByExtension = requestedModule => {
|
|
157
|
-
var _context2
|
|
155
|
+
var _context2;
|
|
158
156
|
const fileExtension = _findInstanceProperty(_context2 = ['.js', '.ts', '.mjs', '.cjs']).call(_context2, ext => {
|
|
159
|
-
|
|
160
|
-
const filePath = _concatInstanceProperty(_context3 = "".concat(requestedModule)).call(_context3, ext);
|
|
157
|
+
const filePath = `${requestedModule}${ext}`;
|
|
161
158
|
return doesFileExist(filePath);
|
|
162
159
|
});
|
|
163
|
-
return
|
|
160
|
+
return `${requestedModule}${fileExtension}`;
|
|
164
161
|
};
|
|
165
162
|
|
|
166
163
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
167
164
|
var _context;
|
|
168
165
|
const applicationTypesList = _Object$keys(applicationTypes);
|
|
169
166
|
if (!_includesInstanceProperty(_context = _Object$values(applicationTypesList)).call(_context, applicationType)) {
|
|
170
|
-
|
|
171
|
-
throw new Error(_concatInstanceProperty(_context2 = "The provided application type \"".concat(applicationType.toString(), "\" does not exist. Available types are \"")).call(_context2, applicationTypesList, "\". Make sure you are also using the latest version of \"@commercetools-frontend/create-mc-app\"."));
|
|
167
|
+
throw new Error(`The provided application type "${applicationType.toString()}" does not exist. Available types are "${applicationTypesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`);
|
|
172
168
|
}
|
|
173
169
|
};
|
|
174
170
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -178,22 +174,19 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
178
174
|
break;
|
|
179
175
|
default:
|
|
180
176
|
{
|
|
181
|
-
var _context3;
|
|
182
177
|
const templateNamesList = _Object$keys(availableTemplates).toString();
|
|
183
|
-
throw new Error(
|
|
178
|
+
throw new Error(`The provided template name "${templateName}" does not exist. Available templates are "${templateNamesList}". Make sure you are also using the latest version of "@commercetools-frontend/create-mc-app".`);
|
|
184
179
|
}
|
|
185
180
|
}
|
|
186
181
|
};
|
|
187
182
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
188
183
|
if (doesFileExist(dirPath)) {
|
|
189
|
-
|
|
190
|
-
throw new Error(_concatInstanceProperty(_context4 = "A directory named \"".concat(dirName, "\" already exists at this location \"")).call(_context4, dirPath, "\". Please choose a different project name or remove the directory, then try running the command again."));
|
|
184
|
+
throw new Error(`A directory named "${dirName}" already exists at this location "${dirPath}". Please choose a different project name or remove the directory, then try running the command again.`);
|
|
191
185
|
}
|
|
192
186
|
};
|
|
193
187
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
194
188
|
if (!doesFileExist(templateFolderPath)) {
|
|
195
|
-
|
|
196
|
-
throw new Error(_concatInstanceProperty(_context5 = "The downloaded template \"".concat(templateName, "\" does not exist for the given version \"")).call(_context5, versionToCheck, "\". Check the releases page if you are looking for a specific version: https://github.com/commercetools/merchant-center-application-kit/releases"));
|
|
189
|
+
throw new Error(`The downloaded template "${templateName}" does not exist for the given version "${versionToCheck}". Check the releases page if you are looking for a specific version: https://github.com/commercetools/merchant-center-application-kit/releases`);
|
|
197
190
|
}
|
|
198
191
|
// In case the version is semver (usually release tags) we check that
|
|
199
192
|
// the cloned repository contains the template matching the given version
|
|
@@ -203,52 +196,48 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
203
196
|
}));
|
|
204
197
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
205
198
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
206
|
-
|
|
207
|
-
throw new Error(_concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "The downloaded template \"".concat(templateName, "\" does not match the version \"")).call(_context7, versionAsNumber, "\", instead got \"")).call(_context6, templatePackageJson.version, "\". Check the releases page if you want to provide a specific version: https://github.com/commercetools/merchant-center-application-kit/releases"));
|
|
199
|
+
throw new Error(`The downloaded template "${templateName}" does not match the version "${versionAsNumber}", instead got "${templatePackageJson.version}". Check the releases page if you want to provide a specific version: https://github.com/commercetools/merchant-center-application-kit/releases`);
|
|
208
200
|
}
|
|
209
201
|
}
|
|
210
202
|
};
|
|
211
203
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
212
204
|
if (!initialProjectKey) {
|
|
213
|
-
throw new Error(
|
|
205
|
+
throw new Error(`Provide a valid project key that you have access to.`);
|
|
214
206
|
}
|
|
215
207
|
};
|
|
216
208
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
217
209
|
const hasValidNodeVersion = semver.satisfies(currentNodeVersion, expectedVersionRange);
|
|
218
210
|
if (!hasValidNodeVersion) {
|
|
219
|
-
|
|
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."));
|
|
211
|
+
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
221
212
|
}
|
|
222
213
|
};
|
|
223
214
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
224
215
|
const allowedCloudIdentifiers = _Object$values(CLOUD_IDENTIFIERS);
|
|
225
216
|
if (!_includesInstanceProperty(allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
226
|
-
|
|
227
|
-
throw new Error(_concatInstanceProperty(_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
217
|
+
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
228
218
|
}
|
|
229
219
|
};
|
|
230
220
|
|
|
231
221
|
const question = (rl, value) => new _Promise(resolve => rl.question(value, resolve));
|
|
232
222
|
const getEntryPointUriPath = async (rl, options) => {
|
|
233
|
-
var _context;
|
|
234
223
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
235
224
|
return;
|
|
236
225
|
}
|
|
237
226
|
if (options.entryPointUriPath) {
|
|
238
227
|
return options.entryPointUriPath;
|
|
239
228
|
}
|
|
240
|
-
const randomEntryPointUriPath =
|
|
229
|
+
const randomEntryPointUriPath = `${options.template}-${crypto.randomBytes(3).toString('hex')}`;
|
|
241
230
|
if (options.yes) {
|
|
242
231
|
return randomEntryPointUriPath;
|
|
243
232
|
}
|
|
244
|
-
const answerEntryPointUriPath = await question(rl,
|
|
233
|
+
const answerEntryPointUriPath = await question(rl, `Provide the Custom Application entryPointUriPath (default "${randomEntryPointUriPath}"): `);
|
|
245
234
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
246
235
|
};
|
|
247
236
|
const getInitialProjectKey = async (rl, options) => {
|
|
248
237
|
if (options.initialProjectKey) {
|
|
249
238
|
return options.initialProjectKey;
|
|
250
239
|
}
|
|
251
|
-
const initialProjectKey = await question(rl,
|
|
240
|
+
const initialProjectKey = await question(rl, `Provide the initial project key for local development: `);
|
|
252
241
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
253
242
|
return initialProjectKey;
|
|
254
243
|
};
|
|
@@ -275,7 +264,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
275
264
|
|
|
276
265
|
// Parse options
|
|
277
266
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
278
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
267
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
279
268
|
const templateName = options.template;
|
|
280
269
|
|
|
281
270
|
// Validate options
|
|
@@ -310,16 +299,15 @@ function downloadTemplate(options) {
|
|
|
310
299
|
return {
|
|
311
300
|
title: 'Downloading template',
|
|
312
301
|
task: () => {
|
|
313
|
-
var _context;
|
|
314
302
|
const tmpDir = os.tmpdir();
|
|
315
303
|
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now().toString()].join('');
|
|
316
304
|
const clonedRepositoryPath = path.join(tmpDir, tmpFolderNameForClonedRepository);
|
|
317
305
|
const templateFolderPath = path.join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
318
306
|
return new Listr([{
|
|
319
|
-
title:
|
|
307
|
+
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
320
308
|
task: async () => {
|
|
321
309
|
// Shallow clone repository
|
|
322
|
-
const result = await execa('git', ['clone',
|
|
310
|
+
const result = await execa('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
323
311
|
cwd: tmpDir,
|
|
324
312
|
encoding: 'utf-8'
|
|
325
313
|
});
|
|
@@ -330,7 +318,7 @@ function downloadTemplate(options) {
|
|
|
330
318
|
return result.stdout;
|
|
331
319
|
}
|
|
332
320
|
}, {
|
|
333
|
-
title:
|
|
321
|
+
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
334
322
|
task: async () => {
|
|
335
323
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
336
324
|
const result = await execa(command, [templateFolderPath,
|
|
@@ -343,12 +331,12 @@ function downloadTemplate(options) {
|
|
|
343
331
|
}
|
|
344
332
|
const templatePackageJsonPath = path.join(options.projectDirectoryPath, 'package.json');
|
|
345
333
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
346
|
-
throw new Error(
|
|
334
|
+
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
347
335
|
}
|
|
348
336
|
return result.stdout;
|
|
349
337
|
}
|
|
350
338
|
}, {
|
|
351
|
-
title:
|
|
339
|
+
title: `Cleaning up project directory`,
|
|
352
340
|
task: async () => {
|
|
353
341
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
354
342
|
const result = await execa(command, _mapInstanceProperty(filesToBeRemoved).call(filesToBeRemoved, filePath => path.join(options.projectDirectoryPath, filePath)), {
|
|
@@ -429,8 +417,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
429
417
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
430
418
|
const result = transformFileSync(filePath, {
|
|
431
419
|
plugins: [function replaceConfig() {
|
|
432
|
-
|
|
433
|
-
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
420
|
+
const appName = wordify(options.entryPointUriPath ?? options.projectDirectoryName);
|
|
434
421
|
return {
|
|
435
422
|
visitor: {
|
|
436
423
|
Identifier(nodePath) {
|
|
@@ -465,9 +452,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
465
452
|
}],
|
|
466
453
|
retainLines: true
|
|
467
454
|
});
|
|
468
|
-
if (result
|
|
455
|
+
if (result?.code) {
|
|
469
456
|
const prettierConfig = prettier.resolveConfig.sync(options.projectDirectoryPath);
|
|
470
|
-
const formattedData = prettier.format(result.code + os.EOL, prettierConfig
|
|
457
|
+
const formattedData = prettier.format(result.code + os.EOL, prettierConfig ?? undefined);
|
|
471
458
|
fs.writeFileSync(filePath, formattedData, {
|
|
472
459
|
encoding: 'utf8'
|
|
473
460
|
});
|
|
@@ -480,7 +467,7 @@ function getApplicationConfigName(options) {
|
|
|
480
467
|
case applicationTypes['custom-view']:
|
|
481
468
|
return 'custom-view-config';
|
|
482
469
|
default:
|
|
483
|
-
throw new Error(
|
|
470
|
+
throw new Error(`Unknown application type ${options.applicationType}`);
|
|
484
471
|
}
|
|
485
472
|
}
|
|
486
473
|
function updateApplicationConfig(options) {
|
|
@@ -508,9 +495,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
508
495
|
}],
|
|
509
496
|
retainLines: true
|
|
510
497
|
});
|
|
511
|
-
if (result
|
|
498
|
+
if (result?.code) {
|
|
512
499
|
const prettierConfig = prettier.resolveConfig.sync(options.projectDirectoryPath);
|
|
513
|
-
const formattedData = prettier.format(result.code + os.EOL, prettierConfig
|
|
500
|
+
const formattedData = prettier.format(result.code + os.EOL, prettierConfig ?? undefined);
|
|
514
501
|
fs.writeFileSync(filePath, formattedData, {
|
|
515
502
|
encoding: 'utf8'
|
|
516
503
|
});
|
|
@@ -557,7 +544,7 @@ const run = () => {
|
|
|
557
544
|
}).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', {
|
|
558
545
|
default: false
|
|
559
546
|
}).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) => {
|
|
560
|
-
var _context
|
|
547
|
+
var _context;
|
|
561
548
|
if (!projectDirectory) {
|
|
562
549
|
cli.outputHelp();
|
|
563
550
|
return;
|
|
@@ -576,16 +563,16 @@ const run = () => {
|
|
|
576
563
|
await taskList.run();
|
|
577
564
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
578
565
|
console.log('');
|
|
579
|
-
console.log(
|
|
566
|
+
console.log(`🎉 🎉 🎉 The ${messages.featureName} has been created in the "${taskOptions.projectDirectoryName}" folder.`);
|
|
580
567
|
console.log('');
|
|
581
|
-
console.log(
|
|
582
|
-
console.log(
|
|
568
|
+
console.log(`To get started:`);
|
|
569
|
+
console.log(`$ cd ${taskOptions.projectDirectoryName}`);
|
|
583
570
|
if (!shouldInstallDependencies) {
|
|
584
|
-
console.log(
|
|
571
|
+
console.log(`$ ${packageManager} install`);
|
|
585
572
|
}
|
|
586
|
-
console.log(
|
|
573
|
+
console.log(`$ ${packageManager} start`);
|
|
587
574
|
console.log('');
|
|
588
|
-
console.log(
|
|
575
|
+
console.log(`Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ${messages.featureName}. Enjoy 🚀`);
|
|
589
576
|
});
|
|
590
577
|
cli.help();
|
|
591
578
|
cli.version(pkgJson.version);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/create-mc-app",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.31.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,7 +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.
|
|
29
|
+
"@commercetools-frontend/application-config": "^22.31.0",
|
|
30
30
|
"@types/babel__core": "^7.20.1",
|
|
31
31
|
"@types/semver": "^7.5.1",
|
|
32
32
|
"cac": "6.7.14",
|