@commercetools-frontend/create-mc-app 25.0.0 → 25.2.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,25 @@
|
|
|
1
1
|
# @commercetools-frontend/create-mc-app
|
|
2
2
|
|
|
3
|
+
## 25.2.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3923](https://github.com/commercetools/merchant-center-application-kit/pull/3923) [`3b47e62`](https://github.com/commercetools/merchant-center-application-kit/commit/3b47e62fc0d7f63ac9fbf05fba907e4ac5705f41) Thanks [@tylermorrisford](https://github.com/tylermorrisford)! - Adds overrides for two transient dependencies.
|
|
8
|
+
|
|
9
|
+
- [#3922](https://github.com/commercetools/merchant-center-application-kit/pull/3922) [`4d19484`](https://github.com/commercetools/merchant-center-application-kit/commit/4d19484452f0955c84ecd4d13f1949bdfbdeadbf) Thanks [@tylermorrisford](https://github.com/tylermorrisford)! - Adds override for transient dependency security issue.
|
|
10
|
+
|
|
11
|
+
- [#3924](https://github.com/commercetools/merchant-center-application-kit/pull/3924) [`a19546c`](https://github.com/commercetools/merchant-center-application-kit/commit/a19546c7d145da501b8e6d922664c2adaafad524) Thanks [@tylermorrisford](https://github.com/tylermorrisford)! - Adds override for tar package version.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`3b47e62`](https://github.com/commercetools/merchant-center-application-kit/commit/3b47e62fc0d7f63ac9fbf05fba907e4ac5705f41), [`4d19484`](https://github.com/commercetools/merchant-center-application-kit/commit/4d19484452f0955c84ecd4d13f1949bdfbdeadbf), [`08c578c`](https://github.com/commercetools/merchant-center-application-kit/commit/08c578c9e956392f5c4e1c0c3c6a7f6fee1806c0), [`a19546c`](https://github.com/commercetools/merchant-center-application-kit/commit/a19546c7d145da501b8e6d922664c2adaafad524), [`d817733`](https://github.com/commercetools/merchant-center-application-kit/commit/d8177335fb7d007e7bd798d9752becfb1cf3c055)]:
|
|
14
|
+
- @commercetools-frontend/application-config@25.2.0
|
|
15
|
+
|
|
16
|
+
## 25.1.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies []:
|
|
21
|
+
- @commercetools-frontend/application-config@25.1.0
|
|
22
|
+
|
|
3
23
|
## 25.0.0
|
|
4
24
|
|
|
5
25
|
### 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 commander = require('commander');
|
|
8
7
|
var listr2 = require('listr2');
|
|
9
8
|
var execa = require('execa');
|
|
@@ -42,7 +41,6 @@ var prettier = require('prettier');
|
|
|
42
41
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
43
42
|
|
|
44
43
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
45
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
46
44
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
47
45
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
48
46
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
@@ -74,7 +72,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
74
72
|
|
|
75
73
|
var pkgJson = {
|
|
76
74
|
name: "@commercetools-frontend/create-mc-app",
|
|
77
|
-
version: "25.
|
|
75
|
+
version: "25.2.0",
|
|
78
76
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
79
77
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
80
78
|
repository: {
|
|
@@ -100,7 +98,7 @@ var pkgJson = {
|
|
|
100
98
|
"@babel/core": "^7.22.17",
|
|
101
99
|
"@babel/runtime": "^7.22.15",
|
|
102
100
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
103
|
-
"@commercetools-frontend/application-config": "^25.
|
|
101
|
+
"@commercetools-frontend/application-config": "^25.2.0",
|
|
104
102
|
"@types/babel__core": "^7.20.1",
|
|
105
103
|
"@types/semver": "^7.5.1",
|
|
106
104
|
commander: "^13.1.0",
|
|
@@ -138,11 +136,10 @@ async function getLatestReleaseVersion() {
|
|
|
138
136
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
139
137
|
var _context;
|
|
140
138
|
const hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
|
|
141
|
-
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag &&
|
|
139
|
+
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
142
140
|
if (hintNewerVersions.length > 0) {
|
|
143
|
-
var _context2;
|
|
144
141
|
console.log('');
|
|
145
|
-
console.log(
|
|
142
|
+
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
146
143
|
console.log('');
|
|
147
144
|
}
|
|
148
145
|
}
|
|
@@ -209,7 +206,7 @@ const getInstallCommand = options => {
|
|
|
209
206
|
case 'npm':
|
|
210
207
|
return 'npm install --legacy-peer-deps';
|
|
211
208
|
default:
|
|
212
|
-
return
|
|
209
|
+
return `${packageManager} install`;
|
|
213
210
|
}
|
|
214
211
|
};
|
|
215
212
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -219,21 +216,19 @@ const wordify = slug => {
|
|
|
219
216
|
return _mapInstanceProperty__default["default"](_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
220
217
|
};
|
|
221
218
|
const resolveFilePathByExtension = requestedModule => {
|
|
222
|
-
var _context3
|
|
219
|
+
var _context3;
|
|
223
220
|
const fileExtension = _findInstanceProperty__default["default"](_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
224
|
-
|
|
225
|
-
const filePath = _concatInstanceProperty__default["default"](_context4 = "".concat(requestedModule)).call(_context4, ext);
|
|
221
|
+
const filePath = `${requestedModule}${ext}`;
|
|
226
222
|
return doesFileExist(filePath);
|
|
227
223
|
});
|
|
228
|
-
return
|
|
224
|
+
return `${requestedModule}${fileExtension}`;
|
|
229
225
|
};
|
|
230
226
|
|
|
231
227
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
232
228
|
var _context;
|
|
233
229
|
const applicationTypesList = _Object$keys__default["default"](applicationTypes);
|
|
234
230
|
if (!_includesInstanceProperty__default["default"](_context = _Object$values__default["default"](applicationTypesList)).call(_context, applicationType)) {
|
|
235
|
-
|
|
236
|
-
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\"."));
|
|
231
|
+
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".`);
|
|
237
232
|
}
|
|
238
233
|
};
|
|
239
234
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -243,22 +238,19 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
243
238
|
break;
|
|
244
239
|
default:
|
|
245
240
|
{
|
|
246
|
-
var _context3;
|
|
247
241
|
const templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
|
|
248
|
-
throw new Error(
|
|
242
|
+
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".`);
|
|
249
243
|
}
|
|
250
244
|
}
|
|
251
245
|
};
|
|
252
246
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
253
247
|
if (doesFileExist(dirPath)) {
|
|
254
|
-
|
|
255
|
-
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."));
|
|
248
|
+
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.`);
|
|
256
249
|
}
|
|
257
250
|
};
|
|
258
251
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
259
252
|
if (!doesFileExist(templateFolderPath)) {
|
|
260
|
-
|
|
261
|
-
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"));
|
|
253
|
+
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`);
|
|
262
254
|
}
|
|
263
255
|
// In case the version is semver (usually release tags) we check that
|
|
264
256
|
// the cloned repository contains the template matching the given version
|
|
@@ -268,52 +260,48 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
268
260
|
}));
|
|
269
261
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
270
262
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
271
|
-
|
|
272
|
-
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"));
|
|
263
|
+
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`);
|
|
273
264
|
}
|
|
274
265
|
}
|
|
275
266
|
};
|
|
276
267
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
277
268
|
if (!initialProjectKey) {
|
|
278
|
-
throw new Error(
|
|
269
|
+
throw new Error(`Provide a valid project key that you have access to.`);
|
|
279
270
|
}
|
|
280
271
|
};
|
|
281
272
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
282
273
|
const hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
|
|
283
274
|
if (!hasValidNodeVersion) {
|
|
284
|
-
|
|
285
|
-
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."));
|
|
275
|
+
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
286
276
|
}
|
|
287
277
|
};
|
|
288
278
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
289
279
|
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
290
280
|
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
291
|
-
|
|
292
|
-
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
281
|
+
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
293
282
|
}
|
|
294
283
|
};
|
|
295
284
|
|
|
296
285
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
297
286
|
const getEntryPointUriPath = async (rl, options) => {
|
|
298
|
-
var _context;
|
|
299
287
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
300
288
|
return;
|
|
301
289
|
}
|
|
302
290
|
if (options.entryPointUriPath) {
|
|
303
291
|
return options.entryPointUriPath;
|
|
304
292
|
}
|
|
305
|
-
const randomEntryPointUriPath =
|
|
293
|
+
const randomEntryPointUriPath = `${options.template}-${crypto__default["default"].randomBytes(3).toString('hex')}`;
|
|
306
294
|
if (options.yes) {
|
|
307
295
|
return randomEntryPointUriPath;
|
|
308
296
|
}
|
|
309
|
-
const answerEntryPointUriPath = await question(rl,
|
|
297
|
+
const answerEntryPointUriPath = await question(rl, `Provide the Custom Application entryPointUriPath (default "${randomEntryPointUriPath}"): `);
|
|
310
298
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
311
299
|
};
|
|
312
300
|
const getInitialProjectKey = async (rl, options) => {
|
|
313
301
|
if (options.initialProjectKey) {
|
|
314
302
|
return options.initialProjectKey;
|
|
315
303
|
}
|
|
316
|
-
const initialProjectKey = await question(rl,
|
|
304
|
+
const initialProjectKey = await question(rl, `Provide the initial project key for local development: `);
|
|
317
305
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
318
306
|
return initialProjectKey;
|
|
319
307
|
};
|
|
@@ -340,7 +328,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
340
328
|
|
|
341
329
|
// Parse options
|
|
342
330
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
343
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
331
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
344
332
|
const templateName = options.template;
|
|
345
333
|
|
|
346
334
|
// Validate options
|
|
@@ -375,16 +363,15 @@ function downloadTemplate(options) {
|
|
|
375
363
|
return {
|
|
376
364
|
title: 'Downloading template',
|
|
377
365
|
task: () => {
|
|
378
|
-
var _context;
|
|
379
366
|
const tmpDir = os__default["default"].tmpdir();
|
|
380
367
|
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default["default"]().toString()].join('');
|
|
381
368
|
const clonedRepositoryPath = path__default["default"].join(tmpDir, tmpFolderNameForClonedRepository);
|
|
382
369
|
const templateFolderPath = path__default["default"].join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
383
370
|
return new listr2.Listr([{
|
|
384
|
-
title:
|
|
371
|
+
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
385
372
|
task: async () => {
|
|
386
373
|
// Shallow clone repository
|
|
387
|
-
const result = await execa__default["default"]('git', ['clone',
|
|
374
|
+
const result = await execa__default["default"]('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
388
375
|
cwd: tmpDir,
|
|
389
376
|
encoding: 'utf-8'
|
|
390
377
|
});
|
|
@@ -395,7 +382,7 @@ function downloadTemplate(options) {
|
|
|
395
382
|
return result.stdout;
|
|
396
383
|
}
|
|
397
384
|
}, {
|
|
398
|
-
title:
|
|
385
|
+
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
399
386
|
task: async () => {
|
|
400
387
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
401
388
|
const result = await execa__default["default"](command, [templateFolderPath,
|
|
@@ -408,12 +395,12 @@ function downloadTemplate(options) {
|
|
|
408
395
|
}
|
|
409
396
|
const templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
|
|
410
397
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
411
|
-
throw new Error(
|
|
398
|
+
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
412
399
|
}
|
|
413
400
|
return result.stdout;
|
|
414
401
|
}
|
|
415
402
|
}, {
|
|
416
|
-
title:
|
|
403
|
+
title: `Cleaning up project directory`,
|
|
417
404
|
task: async () => {
|
|
418
405
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
419
406
|
const result = await execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, filePath => path__default["default"].join(options.projectDirectoryPath, filePath)), {
|
|
@@ -500,8 +487,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
500
487
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
501
488
|
const result = core.transformFileSync(filePath, {
|
|
502
489
|
plugins: [function replaceConfig() {
|
|
503
|
-
|
|
504
|
-
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
490
|
+
const appName = wordify(options.entryPointUriPath ?? options.projectDirectoryName);
|
|
505
491
|
return {
|
|
506
492
|
visitor: {
|
|
507
493
|
Identifier(nodePath) {
|
|
@@ -536,9 +522,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
536
522
|
}],
|
|
537
523
|
retainLines: true
|
|
538
524
|
});
|
|
539
|
-
if (result
|
|
525
|
+
if (result?.code) {
|
|
540
526
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
541
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
527
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
542
528
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
543
529
|
encoding: 'utf8'
|
|
544
530
|
});
|
|
@@ -551,7 +537,7 @@ function getApplicationConfigName(options) {
|
|
|
551
537
|
case applicationTypes['custom-view']:
|
|
552
538
|
return 'custom-view-config';
|
|
553
539
|
default:
|
|
554
|
-
throw new Error(
|
|
540
|
+
throw new Error(`Unknown application type ${options.applicationType}`);
|
|
555
541
|
}
|
|
556
542
|
}
|
|
557
543
|
function updateApplicationConfig(options) {
|
|
@@ -579,9 +565,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
579
565
|
}],
|
|
580
566
|
retainLines: true
|
|
581
567
|
});
|
|
582
|
-
if (result
|
|
568
|
+
if (result?.code) {
|
|
583
569
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
584
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
570
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
585
571
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
586
572
|
encoding: 'utf8'
|
|
587
573
|
});
|
|
@@ -618,7 +604,7 @@ const messagesByApplicationType = {
|
|
|
618
604
|
const run = () => {
|
|
619
605
|
// Default command
|
|
620
606
|
commander.program.argument('<project-directory>').option('--application-type <type>', '(optional) The type of the application to create: custom-application (default) or custom-view.', applicationTypes['custom-application']).option('--template <name>', '(optional) The name of the template to install.', availableTemplates.starter).option('--template-version <version>', '(optional) The version of the template to install (either a git tag or a git branch of the "commercetools/merchant-center-application-kit" repository).', 'main').option('--skip-install', '(optional) Skip installing the dependencies after cloning the template.', false).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', false).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. 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) => {
|
|
621
|
-
var _context
|
|
607
|
+
var _context;
|
|
622
608
|
const releaseVersion = await getLatestReleaseVersion();
|
|
623
609
|
hintOutdatedVersion(pkgJson.version, releaseVersion);
|
|
624
610
|
const taskOptions = await processOptions(projectDirectory, options);
|
|
@@ -633,16 +619,16 @@ const run = () => {
|
|
|
633
619
|
await taskList.run();
|
|
634
620
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
635
621
|
console.log('');
|
|
636
|
-
console.log(
|
|
622
|
+
console.log(`🎉 🎉 🎉 The ${messages.featureName} has been created in the "${taskOptions.projectDirectoryName}" folder.`);
|
|
637
623
|
console.log('');
|
|
638
|
-
console.log(
|
|
639
|
-
console.log(
|
|
624
|
+
console.log(`To get started:`);
|
|
625
|
+
console.log(`$ cd ${taskOptions.projectDirectoryName}`);
|
|
640
626
|
if (!shouldInstallDependencies) {
|
|
641
|
-
console.log(
|
|
627
|
+
console.log(`$ ${packageManager} install`);
|
|
642
628
|
}
|
|
643
|
-
console.log(
|
|
629
|
+
console.log(`$ ${packageManager} start`);
|
|
644
630
|
console.log('');
|
|
645
|
-
console.log(
|
|
631
|
+
console.log(`Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ${messages.featureName}. Enjoy 🚀`);
|
|
646
632
|
});
|
|
647
633
|
commander.program.parse();
|
|
648
634
|
};
|
|
@@ -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 commander = require('commander');
|
|
8
7
|
var listr2 = require('listr2');
|
|
9
8
|
var execa = require('execa');
|
|
@@ -42,7 +41,6 @@ var prettier = require('prettier');
|
|
|
42
41
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
43
42
|
|
|
44
43
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
45
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
46
44
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
47
45
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
48
46
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
@@ -74,7 +72,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
74
72
|
|
|
75
73
|
var pkgJson = {
|
|
76
74
|
name: "@commercetools-frontend/create-mc-app",
|
|
77
|
-
version: "25.
|
|
75
|
+
version: "25.2.0",
|
|
78
76
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
79
77
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
80
78
|
repository: {
|
|
@@ -100,7 +98,7 @@ var pkgJson = {
|
|
|
100
98
|
"@babel/core": "^7.22.17",
|
|
101
99
|
"@babel/runtime": "^7.22.15",
|
|
102
100
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
103
|
-
"@commercetools-frontend/application-config": "^25.
|
|
101
|
+
"@commercetools-frontend/application-config": "^25.2.0",
|
|
104
102
|
"@types/babel__core": "^7.20.1",
|
|
105
103
|
"@types/semver": "^7.5.1",
|
|
106
104
|
commander: "^13.1.0",
|
|
@@ -138,11 +136,10 @@ async function getLatestReleaseVersion() {
|
|
|
138
136
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
139
137
|
var _context;
|
|
140
138
|
const hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
|
|
141
|
-
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag &&
|
|
139
|
+
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
142
140
|
if (hintNewerVersions.length > 0) {
|
|
143
|
-
var _context2;
|
|
144
141
|
console.log('');
|
|
145
|
-
console.log(
|
|
142
|
+
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
146
143
|
console.log('');
|
|
147
144
|
}
|
|
148
145
|
}
|
|
@@ -209,7 +206,7 @@ const getInstallCommand = options => {
|
|
|
209
206
|
case 'npm':
|
|
210
207
|
return 'npm install --legacy-peer-deps';
|
|
211
208
|
default:
|
|
212
|
-
return
|
|
209
|
+
return `${packageManager} install`;
|
|
213
210
|
}
|
|
214
211
|
};
|
|
215
212
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -219,21 +216,19 @@ const wordify = slug => {
|
|
|
219
216
|
return _mapInstanceProperty__default["default"](_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
220
217
|
};
|
|
221
218
|
const resolveFilePathByExtension = requestedModule => {
|
|
222
|
-
var _context3
|
|
219
|
+
var _context3;
|
|
223
220
|
const fileExtension = _findInstanceProperty__default["default"](_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
224
|
-
|
|
225
|
-
const filePath = _concatInstanceProperty__default["default"](_context4 = "".concat(requestedModule)).call(_context4, ext);
|
|
221
|
+
const filePath = `${requestedModule}${ext}`;
|
|
226
222
|
return doesFileExist(filePath);
|
|
227
223
|
});
|
|
228
|
-
return
|
|
224
|
+
return `${requestedModule}${fileExtension}`;
|
|
229
225
|
};
|
|
230
226
|
|
|
231
227
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
232
228
|
var _context;
|
|
233
229
|
const applicationTypesList = _Object$keys__default["default"](applicationTypes);
|
|
234
230
|
if (!_includesInstanceProperty__default["default"](_context = _Object$values__default["default"](applicationTypesList)).call(_context, applicationType)) {
|
|
235
|
-
|
|
236
|
-
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\"."));
|
|
231
|
+
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".`);
|
|
237
232
|
}
|
|
238
233
|
};
|
|
239
234
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -243,22 +238,19 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
243
238
|
break;
|
|
244
239
|
default:
|
|
245
240
|
{
|
|
246
|
-
var _context3;
|
|
247
241
|
const templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
|
|
248
|
-
throw new Error(
|
|
242
|
+
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".`);
|
|
249
243
|
}
|
|
250
244
|
}
|
|
251
245
|
};
|
|
252
246
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
253
247
|
if (doesFileExist(dirPath)) {
|
|
254
|
-
|
|
255
|
-
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."));
|
|
248
|
+
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.`);
|
|
256
249
|
}
|
|
257
250
|
};
|
|
258
251
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
259
252
|
if (!doesFileExist(templateFolderPath)) {
|
|
260
|
-
|
|
261
|
-
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"));
|
|
253
|
+
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`);
|
|
262
254
|
}
|
|
263
255
|
// In case the version is semver (usually release tags) we check that
|
|
264
256
|
// the cloned repository contains the template matching the given version
|
|
@@ -268,52 +260,48 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
268
260
|
}));
|
|
269
261
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
270
262
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
271
|
-
|
|
272
|
-
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"));
|
|
263
|
+
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`);
|
|
273
264
|
}
|
|
274
265
|
}
|
|
275
266
|
};
|
|
276
267
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
277
268
|
if (!initialProjectKey) {
|
|
278
|
-
throw new Error(
|
|
269
|
+
throw new Error(`Provide a valid project key that you have access to.`);
|
|
279
270
|
}
|
|
280
271
|
};
|
|
281
272
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
282
273
|
const hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
|
|
283
274
|
if (!hasValidNodeVersion) {
|
|
284
|
-
|
|
285
|
-
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."));
|
|
275
|
+
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
286
276
|
}
|
|
287
277
|
};
|
|
288
278
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
289
279
|
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
290
280
|
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
291
|
-
|
|
292
|
-
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
281
|
+
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
293
282
|
}
|
|
294
283
|
};
|
|
295
284
|
|
|
296
285
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
297
286
|
const getEntryPointUriPath = async (rl, options) => {
|
|
298
|
-
var _context;
|
|
299
287
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
300
288
|
return;
|
|
301
289
|
}
|
|
302
290
|
if (options.entryPointUriPath) {
|
|
303
291
|
return options.entryPointUriPath;
|
|
304
292
|
}
|
|
305
|
-
const randomEntryPointUriPath =
|
|
293
|
+
const randomEntryPointUriPath = `${options.template}-${crypto__default["default"].randomBytes(3).toString('hex')}`;
|
|
306
294
|
if (options.yes) {
|
|
307
295
|
return randomEntryPointUriPath;
|
|
308
296
|
}
|
|
309
|
-
const answerEntryPointUriPath = await question(rl,
|
|
297
|
+
const answerEntryPointUriPath = await question(rl, `Provide the Custom Application entryPointUriPath (default "${randomEntryPointUriPath}"): `);
|
|
310
298
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
311
299
|
};
|
|
312
300
|
const getInitialProjectKey = async (rl, options) => {
|
|
313
301
|
if (options.initialProjectKey) {
|
|
314
302
|
return options.initialProjectKey;
|
|
315
303
|
}
|
|
316
|
-
const initialProjectKey = await question(rl,
|
|
304
|
+
const initialProjectKey = await question(rl, `Provide the initial project key for local development: `);
|
|
317
305
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
318
306
|
return initialProjectKey;
|
|
319
307
|
};
|
|
@@ -340,7 +328,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
340
328
|
|
|
341
329
|
// Parse options
|
|
342
330
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
343
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
331
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
344
332
|
const templateName = options.template;
|
|
345
333
|
|
|
346
334
|
// Validate options
|
|
@@ -375,16 +363,15 @@ function downloadTemplate(options) {
|
|
|
375
363
|
return {
|
|
376
364
|
title: 'Downloading template',
|
|
377
365
|
task: () => {
|
|
378
|
-
var _context;
|
|
379
366
|
const tmpDir = os__default["default"].tmpdir();
|
|
380
367
|
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default["default"]().toString()].join('');
|
|
381
368
|
const clonedRepositoryPath = path__default["default"].join(tmpDir, tmpFolderNameForClonedRepository);
|
|
382
369
|
const templateFolderPath = path__default["default"].join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
383
370
|
return new listr2.Listr([{
|
|
384
|
-
title:
|
|
371
|
+
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
385
372
|
task: async () => {
|
|
386
373
|
// Shallow clone repository
|
|
387
|
-
const result = await execa__default["default"]('git', ['clone',
|
|
374
|
+
const result = await execa__default["default"]('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
388
375
|
cwd: tmpDir,
|
|
389
376
|
encoding: 'utf-8'
|
|
390
377
|
});
|
|
@@ -395,7 +382,7 @@ function downloadTemplate(options) {
|
|
|
395
382
|
return result.stdout;
|
|
396
383
|
}
|
|
397
384
|
}, {
|
|
398
|
-
title:
|
|
385
|
+
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
399
386
|
task: async () => {
|
|
400
387
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
401
388
|
const result = await execa__default["default"](command, [templateFolderPath,
|
|
@@ -408,12 +395,12 @@ function downloadTemplate(options) {
|
|
|
408
395
|
}
|
|
409
396
|
const templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
|
|
410
397
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
411
|
-
throw new Error(
|
|
398
|
+
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
412
399
|
}
|
|
413
400
|
return result.stdout;
|
|
414
401
|
}
|
|
415
402
|
}, {
|
|
416
|
-
title:
|
|
403
|
+
title: `Cleaning up project directory`,
|
|
417
404
|
task: async () => {
|
|
418
405
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
419
406
|
const result = await execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, filePath => path__default["default"].join(options.projectDirectoryPath, filePath)), {
|
|
@@ -500,8 +487,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
500
487
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
501
488
|
const result = core.transformFileSync(filePath, {
|
|
502
489
|
plugins: [function replaceConfig() {
|
|
503
|
-
|
|
504
|
-
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
490
|
+
const appName = wordify(options.entryPointUriPath ?? options.projectDirectoryName);
|
|
505
491
|
return {
|
|
506
492
|
visitor: {
|
|
507
493
|
Identifier(nodePath) {
|
|
@@ -536,9 +522,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
536
522
|
}],
|
|
537
523
|
retainLines: true
|
|
538
524
|
});
|
|
539
|
-
if (result
|
|
525
|
+
if (result?.code) {
|
|
540
526
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
541
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
527
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
542
528
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
543
529
|
encoding: 'utf8'
|
|
544
530
|
});
|
|
@@ -551,7 +537,7 @@ function getApplicationConfigName(options) {
|
|
|
551
537
|
case applicationTypes['custom-view']:
|
|
552
538
|
return 'custom-view-config';
|
|
553
539
|
default:
|
|
554
|
-
throw new Error(
|
|
540
|
+
throw new Error(`Unknown application type ${options.applicationType}`);
|
|
555
541
|
}
|
|
556
542
|
}
|
|
557
543
|
function updateApplicationConfig(options) {
|
|
@@ -579,9 +565,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
579
565
|
}],
|
|
580
566
|
retainLines: true
|
|
581
567
|
});
|
|
582
|
-
if (result
|
|
568
|
+
if (result?.code) {
|
|
583
569
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
584
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
570
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig ?? undefined);
|
|
585
571
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
586
572
|
encoding: 'utf8'
|
|
587
573
|
});
|
|
@@ -618,7 +604,7 @@ const messagesByApplicationType = {
|
|
|
618
604
|
const run = () => {
|
|
619
605
|
// Default command
|
|
620
606
|
commander.program.argument('<project-directory>').option('--application-type <type>', '(optional) The type of the application to create: custom-application (default) or custom-view.', applicationTypes['custom-application']).option('--template <name>', '(optional) The name of the template to install.', availableTemplates.starter).option('--template-version <version>', '(optional) The version of the template to install (either a git tag or a git branch of the "commercetools/merchant-center-application-kit" repository).', 'main').option('--skip-install', '(optional) Skip installing the dependencies after cloning the template.', false).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', false).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. 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) => {
|
|
621
|
-
var _context
|
|
607
|
+
var _context;
|
|
622
608
|
const releaseVersion = await getLatestReleaseVersion();
|
|
623
609
|
hintOutdatedVersion(pkgJson.version, releaseVersion);
|
|
624
610
|
const taskOptions = await processOptions(projectDirectory, options);
|
|
@@ -633,16 +619,16 @@ const run = () => {
|
|
|
633
619
|
await taskList.run();
|
|
634
620
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
635
621
|
console.log('');
|
|
636
|
-
console.log(
|
|
622
|
+
console.log(`🎉 🎉 🎉 The ${messages.featureName} has been created in the "${taskOptions.projectDirectoryName}" folder.`);
|
|
637
623
|
console.log('');
|
|
638
|
-
console.log(
|
|
639
|
-
console.log(
|
|
624
|
+
console.log(`To get started:`);
|
|
625
|
+
console.log(`$ cd ${taskOptions.projectDirectoryName}`);
|
|
640
626
|
if (!shouldInstallDependencies) {
|
|
641
|
-
console.log(
|
|
627
|
+
console.log(`$ ${packageManager} install`);
|
|
642
628
|
}
|
|
643
|
-
console.log(
|
|
629
|
+
console.log(`$ ${packageManager} start`);
|
|
644
630
|
console.log('');
|
|
645
|
-
console.log(
|
|
631
|
+
console.log(`Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ${messages.featureName}. Enjoy 🚀`);
|
|
646
632
|
});
|
|
647
633
|
commander.program.parse();
|
|
648
634
|
};
|
|
@@ -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 { program } from 'commander';
|
|
4
3
|
import { Listr } from 'listr2';
|
|
5
4
|
import execa from 'execa';
|
|
@@ -37,7 +36,7 @@ import prettier from 'prettier';
|
|
|
37
36
|
|
|
38
37
|
var pkgJson = {
|
|
39
38
|
name: "@commercetools-frontend/create-mc-app",
|
|
40
|
-
version: "25.
|
|
39
|
+
version: "25.2.0",
|
|
41
40
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
42
41
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
43
42
|
repository: {
|
|
@@ -63,7 +62,7 @@ var pkgJson = {
|
|
|
63
62
|
"@babel/core": "^7.22.17",
|
|
64
63
|
"@babel/runtime": "^7.22.15",
|
|
65
64
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
66
|
-
"@commercetools-frontend/application-config": "^25.
|
|
65
|
+
"@commercetools-frontend/application-config": "^25.2.0",
|
|
67
66
|
"@types/babel__core": "^7.20.1",
|
|
68
67
|
"@types/semver": "^7.5.1",
|
|
69
68
|
commander: "^13.1.0",
|
|
@@ -101,11 +100,10 @@ async function getLatestReleaseVersion() {
|
|
|
101
100
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
102
101
|
var _context;
|
|
103
102
|
const hasBeenReleastedInLatestTag = semver.gt(releaseVersion, currentVersion);
|
|
104
|
-
const hintNewerVersions = _filterInstanceProperty(_context = [hasBeenReleastedInLatestTag &&
|
|
103
|
+
const hintNewerVersions = _filterInstanceProperty(_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
105
104
|
if (hintNewerVersions.length > 0) {
|
|
106
|
-
var _context2;
|
|
107
105
|
console.log('');
|
|
108
|
-
console.log(
|
|
106
|
+
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
109
107
|
console.log('');
|
|
110
108
|
}
|
|
111
109
|
}
|
|
@@ -172,7 +170,7 @@ const getInstallCommand = options => {
|
|
|
172
170
|
case 'npm':
|
|
173
171
|
return 'npm install --legacy-peer-deps';
|
|
174
172
|
default:
|
|
175
|
-
return
|
|
173
|
+
return `${packageManager} install`;
|
|
176
174
|
}
|
|
177
175
|
};
|
|
178
176
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -182,21 +180,19 @@ const wordify = slug => {
|
|
|
182
180
|
return _mapInstanceProperty(_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
183
181
|
};
|
|
184
182
|
const resolveFilePathByExtension = requestedModule => {
|
|
185
|
-
var _context3
|
|
183
|
+
var _context3;
|
|
186
184
|
const fileExtension = _findInstanceProperty(_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
187
|
-
|
|
188
|
-
const filePath = _concatInstanceProperty(_context4 = "".concat(requestedModule)).call(_context4, ext);
|
|
185
|
+
const filePath = `${requestedModule}${ext}`;
|
|
189
186
|
return doesFileExist(filePath);
|
|
190
187
|
});
|
|
191
|
-
return
|
|
188
|
+
return `${requestedModule}${fileExtension}`;
|
|
192
189
|
};
|
|
193
190
|
|
|
194
191
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
195
192
|
var _context;
|
|
196
193
|
const applicationTypesList = _Object$keys(applicationTypes);
|
|
197
194
|
if (!_includesInstanceProperty(_context = _Object$values(applicationTypesList)).call(_context, applicationType)) {
|
|
198
|
-
|
|
199
|
-
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\"."));
|
|
195
|
+
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".`);
|
|
200
196
|
}
|
|
201
197
|
};
|
|
202
198
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -206,22 +202,19 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
206
202
|
break;
|
|
207
203
|
default:
|
|
208
204
|
{
|
|
209
|
-
var _context3;
|
|
210
205
|
const templateNamesList = _Object$keys(availableTemplates).toString();
|
|
211
|
-
throw new Error(
|
|
206
|
+
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".`);
|
|
212
207
|
}
|
|
213
208
|
}
|
|
214
209
|
};
|
|
215
210
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
216
211
|
if (doesFileExist(dirPath)) {
|
|
217
|
-
|
|
218
|
-
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."));
|
|
212
|
+
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.`);
|
|
219
213
|
}
|
|
220
214
|
};
|
|
221
215
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
222
216
|
if (!doesFileExist(templateFolderPath)) {
|
|
223
|
-
|
|
224
|
-
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"));
|
|
217
|
+
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`);
|
|
225
218
|
}
|
|
226
219
|
// In case the version is semver (usually release tags) we check that
|
|
227
220
|
// the cloned repository contains the template matching the given version
|
|
@@ -231,52 +224,48 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
231
224
|
}));
|
|
232
225
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
233
226
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
234
|
-
|
|
235
|
-
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"));
|
|
227
|
+
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`);
|
|
236
228
|
}
|
|
237
229
|
}
|
|
238
230
|
};
|
|
239
231
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
240
232
|
if (!initialProjectKey) {
|
|
241
|
-
throw new Error(
|
|
233
|
+
throw new Error(`Provide a valid project key that you have access to.`);
|
|
242
234
|
}
|
|
243
235
|
};
|
|
244
236
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
245
237
|
const hasValidNodeVersion = semver.satisfies(currentNodeVersion, expectedVersionRange);
|
|
246
238
|
if (!hasValidNodeVersion) {
|
|
247
|
-
|
|
248
|
-
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."));
|
|
239
|
+
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
249
240
|
}
|
|
250
241
|
};
|
|
251
242
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
252
243
|
const allowedCloudIdentifiers = _Object$values(CLOUD_IDENTIFIERS);
|
|
253
244
|
if (!_includesInstanceProperty(allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
254
|
-
|
|
255
|
-
throw new Error(_concatInstanceProperty(_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
245
|
+
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
256
246
|
}
|
|
257
247
|
};
|
|
258
248
|
|
|
259
249
|
const question = (rl, value) => new _Promise(resolve => rl.question(value, resolve));
|
|
260
250
|
const getEntryPointUriPath = async (rl, options) => {
|
|
261
|
-
var _context;
|
|
262
251
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
263
252
|
return;
|
|
264
253
|
}
|
|
265
254
|
if (options.entryPointUriPath) {
|
|
266
255
|
return options.entryPointUriPath;
|
|
267
256
|
}
|
|
268
|
-
const randomEntryPointUriPath =
|
|
257
|
+
const randomEntryPointUriPath = `${options.template}-${crypto.randomBytes(3).toString('hex')}`;
|
|
269
258
|
if (options.yes) {
|
|
270
259
|
return randomEntryPointUriPath;
|
|
271
260
|
}
|
|
272
|
-
const answerEntryPointUriPath = await question(rl,
|
|
261
|
+
const answerEntryPointUriPath = await question(rl, `Provide the Custom Application entryPointUriPath (default "${randomEntryPointUriPath}"): `);
|
|
273
262
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
274
263
|
};
|
|
275
264
|
const getInitialProjectKey = async (rl, options) => {
|
|
276
265
|
if (options.initialProjectKey) {
|
|
277
266
|
return options.initialProjectKey;
|
|
278
267
|
}
|
|
279
|
-
const initialProjectKey = await question(rl,
|
|
268
|
+
const initialProjectKey = await question(rl, `Provide the initial project key for local development: `);
|
|
280
269
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
281
270
|
return initialProjectKey;
|
|
282
271
|
};
|
|
@@ -303,7 +292,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
303
292
|
|
|
304
293
|
// Parse options
|
|
305
294
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
306
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
295
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
307
296
|
const templateName = options.template;
|
|
308
297
|
|
|
309
298
|
// Validate options
|
|
@@ -338,16 +327,15 @@ function downloadTemplate(options) {
|
|
|
338
327
|
return {
|
|
339
328
|
title: 'Downloading template',
|
|
340
329
|
task: () => {
|
|
341
|
-
var _context;
|
|
342
330
|
const tmpDir = os.tmpdir();
|
|
343
331
|
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now().toString()].join('');
|
|
344
332
|
const clonedRepositoryPath = path.join(tmpDir, tmpFolderNameForClonedRepository);
|
|
345
333
|
const templateFolderPath = path.join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
346
334
|
return new Listr([{
|
|
347
|
-
title:
|
|
335
|
+
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
348
336
|
task: async () => {
|
|
349
337
|
// Shallow clone repository
|
|
350
|
-
const result = await execa('git', ['clone',
|
|
338
|
+
const result = await execa('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
351
339
|
cwd: tmpDir,
|
|
352
340
|
encoding: 'utf-8'
|
|
353
341
|
});
|
|
@@ -358,7 +346,7 @@ function downloadTemplate(options) {
|
|
|
358
346
|
return result.stdout;
|
|
359
347
|
}
|
|
360
348
|
}, {
|
|
361
|
-
title:
|
|
349
|
+
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
362
350
|
task: async () => {
|
|
363
351
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
364
352
|
const result = await execa(command, [templateFolderPath,
|
|
@@ -371,12 +359,12 @@ function downloadTemplate(options) {
|
|
|
371
359
|
}
|
|
372
360
|
const templatePackageJsonPath = path.join(options.projectDirectoryPath, 'package.json');
|
|
373
361
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
374
|
-
throw new Error(
|
|
362
|
+
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
375
363
|
}
|
|
376
364
|
return result.stdout;
|
|
377
365
|
}
|
|
378
366
|
}, {
|
|
379
|
-
title:
|
|
367
|
+
title: `Cleaning up project directory`,
|
|
380
368
|
task: async () => {
|
|
381
369
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
382
370
|
const result = await execa(command, _mapInstanceProperty(filesToBeRemoved).call(filesToBeRemoved, filePath => path.join(options.projectDirectoryPath, filePath)), {
|
|
@@ -463,8 +451,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
463
451
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
464
452
|
const result = transformFileSync(filePath, {
|
|
465
453
|
plugins: [function replaceConfig() {
|
|
466
|
-
|
|
467
|
-
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
454
|
+
const appName = wordify(options.entryPointUriPath ?? options.projectDirectoryName);
|
|
468
455
|
return {
|
|
469
456
|
visitor: {
|
|
470
457
|
Identifier(nodePath) {
|
|
@@ -499,9 +486,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
499
486
|
}],
|
|
500
487
|
retainLines: true
|
|
501
488
|
});
|
|
502
|
-
if (result
|
|
489
|
+
if (result?.code) {
|
|
503
490
|
const prettierConfig = prettier.resolveConfig.sync(options.projectDirectoryPath);
|
|
504
|
-
const formattedData = prettier.format(result.code + os.EOL, prettierConfig
|
|
491
|
+
const formattedData = prettier.format(result.code + os.EOL, prettierConfig ?? undefined);
|
|
505
492
|
fs.writeFileSync(filePath, formattedData, {
|
|
506
493
|
encoding: 'utf8'
|
|
507
494
|
});
|
|
@@ -514,7 +501,7 @@ function getApplicationConfigName(options) {
|
|
|
514
501
|
case applicationTypes['custom-view']:
|
|
515
502
|
return 'custom-view-config';
|
|
516
503
|
default:
|
|
517
|
-
throw new Error(
|
|
504
|
+
throw new Error(`Unknown application type ${options.applicationType}`);
|
|
518
505
|
}
|
|
519
506
|
}
|
|
520
507
|
function updateApplicationConfig(options) {
|
|
@@ -542,9 +529,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
542
529
|
}],
|
|
543
530
|
retainLines: true
|
|
544
531
|
});
|
|
545
|
-
if (result
|
|
532
|
+
if (result?.code) {
|
|
546
533
|
const prettierConfig = prettier.resolveConfig.sync(options.projectDirectoryPath);
|
|
547
|
-
const formattedData = prettier.format(result.code + os.EOL, prettierConfig
|
|
534
|
+
const formattedData = prettier.format(result.code + os.EOL, prettierConfig ?? undefined);
|
|
548
535
|
fs.writeFileSync(filePath, formattedData, {
|
|
549
536
|
encoding: 'utf8'
|
|
550
537
|
});
|
|
@@ -581,7 +568,7 @@ const messagesByApplicationType = {
|
|
|
581
568
|
const run = () => {
|
|
582
569
|
// Default command
|
|
583
570
|
program.argument('<project-directory>').option('--application-type <type>', '(optional) The type of the application to create: custom-application (default) or custom-view.', applicationTypes['custom-application']).option('--template <name>', '(optional) The name of the template to install.', availableTemplates.starter).option('--template-version <version>', '(optional) The version of the template to install (either a git tag or a git branch of the "commercetools/merchant-center-application-kit" repository).', 'main').option('--skip-install', '(optional) Skip installing the dependencies after cloning the template.', false).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', false).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. 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) => {
|
|
584
|
-
var _context
|
|
571
|
+
var _context;
|
|
585
572
|
const releaseVersion = await getLatestReleaseVersion();
|
|
586
573
|
hintOutdatedVersion(pkgJson.version, releaseVersion);
|
|
587
574
|
const taskOptions = await processOptions(projectDirectory, options);
|
|
@@ -596,16 +583,16 @@ const run = () => {
|
|
|
596
583
|
await taskList.run();
|
|
597
584
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
598
585
|
console.log('');
|
|
599
|
-
console.log(
|
|
586
|
+
console.log(`🎉 🎉 🎉 The ${messages.featureName} has been created in the "${taskOptions.projectDirectoryName}" folder.`);
|
|
600
587
|
console.log('');
|
|
601
|
-
console.log(
|
|
602
|
-
console.log(
|
|
588
|
+
console.log(`To get started:`);
|
|
589
|
+
console.log(`$ cd ${taskOptions.projectDirectoryName}`);
|
|
603
590
|
if (!shouldInstallDependencies) {
|
|
604
|
-
console.log(
|
|
591
|
+
console.log(`$ ${packageManager} install`);
|
|
605
592
|
}
|
|
606
|
-
console.log(
|
|
593
|
+
console.log(`$ ${packageManager} start`);
|
|
607
594
|
console.log('');
|
|
608
|
-
console.log(
|
|
595
|
+
console.log(`Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ${messages.featureName}. Enjoy 🚀`);
|
|
609
596
|
});
|
|
610
597
|
program.parse();
|
|
611
598
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/create-mc-app",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.2.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": "^25.
|
|
29
|
+
"@commercetools-frontend/application-config": "^25.2.0",
|
|
30
30
|
"@types/babel__core": "^7.20.1",
|
|
31
31
|
"@types/semver": "^7.5.1",
|
|
32
32
|
"commander": "^13.1.0",
|