@commercetools-frontend/create-mc-app 27.8.0 → 27.9.1
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,64 @@
|
|
|
1
1
|
# @commercetools-frontend/create-mc-app
|
|
2
2
|
|
|
3
|
+
## 27.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4077](https://github.com/commercetools/merchant-center-application-kit/pull/4077) [`959d69e`](https://github.com/commercetools/merchant-center-application-kit/commit/959d69e609263f5a6486c1060954ec5a379f0cb5) Thanks [@ByronDWall](https://github.com/ByronDWall)! - Batch-consolidated patch/minor Renovate dependency updates (rate-limited dashboard backlog, ~116 items reviewed).
|
|
8
|
+
|
|
9
|
+
The `@flopflip/*` 15.1.7 → 15.1.11 bump pulls in `@launchdarkly/js-client-sdk` v4 as a
|
|
10
|
+
transitive dependency, replacing the unscoped `launchdarkly-js-client-sdk` v3. This is a
|
|
11
|
+
breaking change for `SetupFlopFlipProvider` in `application-shell`:
|
|
12
|
+
|
|
13
|
+
- The LaunchDarkly user context type now requires either a `key` or `anonymous: true`,
|
|
14
|
+
never an optional `key`. `getUserContextForLaunchDarklyAdapter` now returns an
|
|
15
|
+
anonymous context when there's no authenticated user, instead of a context with an
|
|
16
|
+
undefined `key`.
|
|
17
|
+
- `sdk.clientOptions.sendEventsOnlyForVariation` was removed; the new SDK's `allFlags`
|
|
18
|
+
no longer sends analytics events by default, which was the entire point of that option.
|
|
19
|
+
|
|
20
|
+
`@commercetools/composable-commerce-test-data` 13.12.0 → 13.13.1 pulling in
|
|
21
|
+
`@faker-js/faker` v10 (which dropped its CJS build) was previously allowlisted in the
|
|
22
|
+
root `jest.test.config.js`'s `transformIgnorePatterns`, but `jest-preset-mc-app`'s own
|
|
23
|
+
preset — the one actually consumed by the standalone starter templates
|
|
24
|
+
(`application-templates/starter{,-typescript}`, `custom-views-templates/starter{,-typescript}`)
|
|
25
|
+
— has its own separate `transformIgnorePatterns` and was missed, so their CI jobs kept
|
|
26
|
+
failing with `Cannot use import statement outside a module`. Added `@faker-js/faker`
|
|
27
|
+
to that preset's allowlist too.
|
|
28
|
+
|
|
29
|
+
Bumped the following, each a real `dependencies` entry (not `devDependencies`) of the listed package(s), so each gets a version bump here:
|
|
30
|
+
|
|
31
|
+
- `@flopflip/*` (combine-adapters, http-adapter, launchdarkly-adapter, memory-adapter, react-broadcast, types) 15.1.7 → 15.1.11 — `application-shell` (all six), `application-components` (`react-broadcast`)
|
|
32
|
+
- `@pmmmwh/react-refresh-webpack-plugin` 0.6.1 → 0.6.2 — `mc-scripts`
|
|
33
|
+
- `@radix-ui/react-dialog` 1.1.14 → 1.1.23, `@types/react-dom` ^19.0.2 → ^19.2.4 — `application-components`
|
|
34
|
+
- `semver` 7.7.2 → 7.8.5, `uuid` 14.0.0 → 14.0.1 — `cypress`
|
|
35
|
+
- `@rollup/pluginutils` 5.2.0 → 5.4.0, `graphql` 16.11.0 → 16.14.2, `html-webpack-plugin` 5.6.3 → 5.6.8, `mini-css-extract-plugin` 2.9.4 → 2.10.2, `postcss` 8.5.23 → 8.5.26, `react-refresh` 0.17.0 → 0.18.0 — `mc-scripts` (`webpack` 5.105.1 → 5.109.2 was reverted; see below)
|
|
36
|
+
- `graphql` 16.11.0 → 16.14.2, `uuid` 14.0.0 → 14.0.1 — `application-shell-connectors`
|
|
37
|
+
- `cosmiconfig` 9.0.0 → 9.0.2, `graphql` 16.11.0 → 16.14.2 — `jest-preset-mc-app` (the `jest`/`babel-jest`/`babel-preset-jest`/`jest-environment-jsdom`/`jest-mock` bump was reverted; see the pnpm-regression/typecheck fix commits on this branch for why)
|
|
38
|
+
- `@types/react-dom` ^19.0.2 → ^19.2.4 — `react-notifications`, `application-shell` (also `@reduxjs/toolkit` 2.9.0 → 2.12.0, `graphql` 16.11.0 → 16.14.2, `uuid` 14.0.0 → 14.0.1)
|
|
39
|
+
- `typescript` 5.9.2 → 5.9.3 — `eslint-config-mc-app`, `eslint-config-node`
|
|
40
|
+
- `semver` 7.7.2 → 7.8.5 — `create-mc-app`
|
|
41
|
+
- `uuid` 14.0.0 → 14.0.1 — `sdk`
|
|
42
|
+
- `@formatjs/icu-messageformat-parser` 2.11.2 → 2.11.4 — `i18n`
|
|
43
|
+
- `@sentry/browser`, `@sentry/react`, `@sentry/types` 8.55.0 → 8.55.2 — `sentry`
|
|
44
|
+
- `serialize-javascript` 7.0.5 → 7.0.7 — `mc-html-template`
|
|
45
|
+
- `ajv` 8.18.0 → 8.20.0, `cosmiconfig` 9.0.0 → 9.0.2, `cosmiconfig-typescript-loader` 6.1.0 → 6.3.0 — `application-config`
|
|
46
|
+
- `winston` 3.17.0 → 3.19.0 — `loggers`
|
|
47
|
+
|
|
48
|
+
Other updates in this batch (`@testing-library/*`, `@manypkg/cli`, `@percy/cypress`, `@percy/puppeteer`, `@preconstruct/cli`, `@apollo/client`, `jest`, `jest-each`, `react`, `react-dom`, `react-redux`, `@commercetools/nimbus`, `@commercetools/composable-commerce-test-data`, `@percy/cli`, `@percy/core`, `@changesets/*`, `rimraf`, `sentry-testkit`, `start-server-and-test`, `fflate`, `formik`, `qs`, `node`, `pnpm`, and GitHub Actions digest/version pins) only touch devDependencies, `peerDependencies`, root-level repo tooling, CI configuration, or private template/playground packages, so they don't require a version bump here.
|
|
49
|
+
|
|
50
|
+
`webpack` 5.105.1 → 5.109.2 was reverted: webpack's `ProgressPlugin` now defers option-schema validation from the constructor to a `compiler.hooks.validate` tap, reading `this.options` at that later point instead of validating the raw constructor args immediately. `webpackbar@5.0.2` (unmaintained, used by `mc-scripts`'s dev config via `new WebpackBar()`) calls `super({ activeModules: true })` and then immediately overwrites `this.options` with its own `name`/`color`/`reporters`/`reporter` keys — none of which are in `ProgressPlugin`'s schema. With eager validation this was masked; with the new deferred validation it fails every `mc-scripts start`/dev build with "Invalid options object. Progress Plugin has been initialized using an options object that does not match the API schema." Held back at 5.105.1 until `webpackbar` is fixed/replaced or dropped in favor of webpack's now-built-in progress bar.
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [[`959d69e`](https://github.com/commercetools/merchant-center-application-kit/commit/959d69e609263f5a6486c1060954ec5a379f0cb5)]:
|
|
53
|
+
- @commercetools-frontend/application-config@27.9.1
|
|
54
|
+
|
|
55
|
+
## 27.9.0
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies []:
|
|
60
|
+
- @commercetools-frontend/application-config@27.9.0
|
|
61
|
+
|
|
3
62
|
## 27.8.0
|
|
4
63
|
|
|
5
64
|
### Patch Changes
|
|
@@ -3,6 +3,7 @@
|
|
|
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');
|
|
6
7
|
var commander = require('commander');
|
|
7
8
|
var listr2 = require('listr2');
|
|
8
9
|
var execa = require('execa');
|
|
@@ -41,6 +42,7 @@ var prettier = require('prettier');
|
|
|
41
42
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
42
43
|
|
|
43
44
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
45
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
44
46
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
45
47
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
46
48
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
@@ -71,7 +73,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
71
73
|
|
|
72
74
|
var pkgJson = {
|
|
73
75
|
name: "@commercetools-frontend/create-mc-app",
|
|
74
|
-
version: "27.
|
|
76
|
+
version: "27.9.1",
|
|
75
77
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
76
78
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
77
79
|
repository: {
|
|
@@ -108,7 +110,7 @@ var pkgJson = {
|
|
|
108
110
|
yaml: "catalog:"
|
|
109
111
|
},
|
|
110
112
|
devDependencies: {
|
|
111
|
-
"@tsconfig/
|
|
113
|
+
"@tsconfig/node24": "catalog:",
|
|
112
114
|
"@types/prettier": "catalog:"
|
|
113
115
|
},
|
|
114
116
|
engines: {
|
|
@@ -136,10 +138,11 @@ async function getLatestReleaseVersion() {
|
|
|
136
138
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
137
139
|
var _context;
|
|
138
140
|
const hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
|
|
139
|
-
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag &&
|
|
141
|
+
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && "".concat(releaseVersion)]).call(_context, Boolean).join(', ');
|
|
140
142
|
if (hintNewerVersions.length > 0) {
|
|
143
|
+
var _context2;
|
|
141
144
|
console.log('');
|
|
142
|
-
console.log(
|
|
145
|
+
console.log(_concatInstanceProperty__default["default"](_context2 = "New version available! ".concat(currentVersion, " -> ")).call(_context2, hintNewerVersions));
|
|
143
146
|
console.log('');
|
|
144
147
|
}
|
|
145
148
|
}
|
|
@@ -206,7 +209,7 @@ const getInstallCommand = options => {
|
|
|
206
209
|
case 'npm':
|
|
207
210
|
return 'npm install --legacy-peer-deps';
|
|
208
211
|
default:
|
|
209
|
-
return
|
|
212
|
+
return "".concat(packageManager, " install");
|
|
210
213
|
}
|
|
211
214
|
};
|
|
212
215
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -216,19 +219,21 @@ const wordify = slug => {
|
|
|
216
219
|
return _mapInstanceProperty__default["default"](_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
217
220
|
};
|
|
218
221
|
const resolveFilePathByExtension = requestedModule => {
|
|
219
|
-
var _context3;
|
|
222
|
+
var _context3, _context5;
|
|
220
223
|
const fileExtension = _findInstanceProperty__default["default"](_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
221
|
-
|
|
224
|
+
var _context4;
|
|
225
|
+
const filePath = _concatInstanceProperty__default["default"](_context4 = "".concat(requestedModule)).call(_context4, ext);
|
|
222
226
|
return doesFileExist(filePath);
|
|
223
227
|
});
|
|
224
|
-
return
|
|
228
|
+
return _concatInstanceProperty__default["default"](_context5 = "".concat(requestedModule)).call(_context5, fileExtension);
|
|
225
229
|
};
|
|
226
230
|
|
|
227
231
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
228
232
|
var _context;
|
|
229
233
|
const applicationTypesList = _Object$keys__default["default"](applicationTypes);
|
|
230
234
|
if (!_includesInstanceProperty__default["default"](_context = _Object$values__default["default"](applicationTypesList)).call(_context, applicationType)) {
|
|
231
|
-
|
|
235
|
+
var _context2;
|
|
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\"."));
|
|
232
237
|
}
|
|
233
238
|
};
|
|
234
239
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -238,19 +243,22 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
238
243
|
break;
|
|
239
244
|
default:
|
|
240
245
|
{
|
|
246
|
+
var _context3;
|
|
241
247
|
const templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
|
|
242
|
-
throw new Error(
|
|
248
|
+
throw new Error(_concatInstanceProperty__default["default"](_context3 = "The provided template name \"".concat(templateName, "\" does not exist. Available templates are \"")).call(_context3, templateNamesList, "\". Make sure you are also using the latest version of \"@commercetools-frontend/create-mc-app\"."));
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
};
|
|
246
252
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
247
253
|
if (doesFileExist(dirPath)) {
|
|
248
|
-
|
|
254
|
+
var _context4;
|
|
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."));
|
|
249
256
|
}
|
|
250
257
|
};
|
|
251
258
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
252
259
|
if (!doesFileExist(templateFolderPath)) {
|
|
253
|
-
|
|
260
|
+
var _context5;
|
|
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"));
|
|
254
262
|
}
|
|
255
263
|
// In case the version is semver (usually release tags) we check that
|
|
256
264
|
// the cloned repository contains the template matching the given version
|
|
@@ -260,48 +268,52 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
260
268
|
}));
|
|
261
269
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
262
270
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
263
|
-
|
|
271
|
+
var _context6, _context7;
|
|
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"));
|
|
264
273
|
}
|
|
265
274
|
}
|
|
266
275
|
};
|
|
267
276
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
268
277
|
if (!initialProjectKey) {
|
|
269
|
-
throw new Error(
|
|
278
|
+
throw new Error("Provide a valid project key that you have access to.");
|
|
270
279
|
}
|
|
271
280
|
};
|
|
272
281
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
273
282
|
const hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
|
|
274
283
|
if (!hasValidNodeVersion) {
|
|
275
|
-
|
|
284
|
+
var _context8;
|
|
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."));
|
|
276
286
|
}
|
|
277
287
|
};
|
|
278
288
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
279
289
|
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
280
290
|
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
281
|
-
|
|
291
|
+
var _context9;
|
|
292
|
+
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
282
293
|
}
|
|
283
294
|
};
|
|
284
295
|
|
|
285
296
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
286
297
|
const getEntryPointUriPath = async (rl, options) => {
|
|
298
|
+
var _context;
|
|
287
299
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
288
300
|
return;
|
|
289
301
|
}
|
|
290
302
|
if (options.entryPointUriPath) {
|
|
291
303
|
return options.entryPointUriPath;
|
|
292
304
|
}
|
|
293
|
-
const randomEntryPointUriPath =
|
|
305
|
+
const randomEntryPointUriPath = _concatInstanceProperty__default["default"](_context = "".concat(options.template, "-")).call(_context, crypto__default["default"].randomBytes(3).toString('hex'));
|
|
294
306
|
if (options.yes) {
|
|
295
307
|
return randomEntryPointUriPath;
|
|
296
308
|
}
|
|
297
|
-
const answerEntryPointUriPath = await question(rl,
|
|
309
|
+
const answerEntryPointUriPath = await question(rl, "Provide the Custom Application entryPointUriPath (default \"".concat(randomEntryPointUriPath, "\"): "));
|
|
298
310
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
299
311
|
};
|
|
300
312
|
const getInitialProjectKey = async (rl, options) => {
|
|
301
313
|
if (options.initialProjectKey) {
|
|
302
314
|
return options.initialProjectKey;
|
|
303
315
|
}
|
|
304
|
-
const initialProjectKey = await question(rl,
|
|
316
|
+
const initialProjectKey = await question(rl, "Provide the initial project key for local development: ");
|
|
305
317
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
306
318
|
return initialProjectKey;
|
|
307
319
|
};
|
|
@@ -328,7 +340,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
328
340
|
|
|
329
341
|
// Parse options
|
|
330
342
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
331
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
343
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? "v".concat(tagOrBranchVersion) : tagOrBranchVersion;
|
|
332
344
|
const templateName = options.template;
|
|
333
345
|
|
|
334
346
|
// Validate options
|
|
@@ -373,15 +385,16 @@ function downloadTemplate(options) {
|
|
|
373
385
|
return {
|
|
374
386
|
title: 'Downloading template',
|
|
375
387
|
task: () => {
|
|
388
|
+
var _context;
|
|
376
389
|
const clonedRepositoryPath = options.clonedRepositoryPath;
|
|
377
390
|
const tmpDir = path__default["default"].dirname(clonedRepositoryPath);
|
|
378
391
|
const tmpFolderNameForClonedRepository = path__default["default"].basename(clonedRepositoryPath);
|
|
379
392
|
const templateFolderPath = path__default["default"].join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
380
393
|
return new listr2.Listr([{
|
|
381
|
-
title:
|
|
394
|
+
title: "Cloning repository using branch ".concat(options.tagOrBranchVersion),
|
|
382
395
|
task: async () => {
|
|
383
396
|
// Shallow clone repository
|
|
384
|
-
const result = await execa__default["default"]('git', ['clone',
|
|
397
|
+
const result = await execa__default["default"]('git', ['clone', "--branch=".concat(options.tagOrBranchVersion), '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
385
398
|
cwd: tmpDir,
|
|
386
399
|
encoding: 'utf-8'
|
|
387
400
|
});
|
|
@@ -392,7 +405,7 @@ function downloadTemplate(options) {
|
|
|
392
405
|
return result.stdout;
|
|
393
406
|
}
|
|
394
407
|
}, {
|
|
395
|
-
title:
|
|
408
|
+
title: _concatInstanceProperty__default["default"](_context = "Copying template ".concat(options.templateName, " into project directory ")).call(_context, options.projectDirectoryPath),
|
|
396
409
|
task: async () => {
|
|
397
410
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
398
411
|
const result = await execa__default["default"](command, [templateFolderPath,
|
|
@@ -405,12 +418,12 @@ function downloadTemplate(options) {
|
|
|
405
418
|
}
|
|
406
419
|
const templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
|
|
407
420
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
408
|
-
throw new Error(
|
|
421
|
+
throw new Error("Unable to verify that the template application has a package.json at \"".concat(templatePackageJsonPath, "\""));
|
|
409
422
|
}
|
|
410
423
|
return result.stdout;
|
|
411
424
|
}
|
|
412
425
|
}, {
|
|
413
|
-
title:
|
|
426
|
+
title: "Cleaning up project directory",
|
|
414
427
|
task: async () => {
|
|
415
428
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
416
429
|
const result = await execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, filePath => path__default["default"].join(options.projectDirectoryPath, filePath)), {
|
|
@@ -449,7 +462,7 @@ function installDependencies(options) {
|
|
|
449
462
|
}
|
|
450
463
|
|
|
451
464
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
452
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
465
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
453
466
|
|
|
454
467
|
// Catalog references in workspace package.json files point at entries in
|
|
455
468
|
// pnpm-workspace.yaml. They have to be flattened to concrete version
|
|
@@ -461,12 +474,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
|
|
|
461
474
|
// share one code path.
|
|
462
475
|
|
|
463
476
|
function parseCatalogs(yamlText) {
|
|
464
|
-
|
|
477
|
+
var _parseYaml;
|
|
478
|
+
const doc = (_parseYaml = yaml.parse(yamlText)) !== null && _parseYaml !== void 0 ? _parseYaml : {};
|
|
465
479
|
const out = new _Map__default["default"]();
|
|
466
480
|
if (doc.catalog) {
|
|
467
481
|
out.set('default', new _Map__default["default"](_Object$entries__default["default"](doc.catalog)));
|
|
468
482
|
}
|
|
469
|
-
for (const _ref of _Object$entries__default["default"](doc.catalogs
|
|
483
|
+
for (const _ref of _Object$entries__default["default"]((_doc$catalogs = doc.catalogs) !== null && _doc$catalogs !== void 0 ? _doc$catalogs : {})) {
|
|
484
|
+
var _doc$catalogs;
|
|
470
485
|
var _ref2 = _slicedToArray(_ref, 2);
|
|
471
486
|
const name = _ref2[0];
|
|
472
487
|
const entries = _ref2[1];
|
|
@@ -480,8 +495,8 @@ function parseCatalogs(yamlText) {
|
|
|
480
495
|
// logic — extend the table to handle new protocol additions.
|
|
481
496
|
const WORKSPACE_REWRITERS = {
|
|
482
497
|
'workspace:*': v => v,
|
|
483
|
-
'workspace:^': v =>
|
|
484
|
-
'workspace:~': v =>
|
|
498
|
+
'workspace:^': v => "^".concat(v),
|
|
499
|
+
'workspace:~': v => "~".concat(v)
|
|
485
500
|
};
|
|
486
501
|
|
|
487
502
|
/**
|
|
@@ -498,12 +513,14 @@ function resolveCatalogRef(spec, depName, catalogs) {
|
|
|
498
513
|
const name = spec === 'catalog:' || spec === 'catalog:default' ? 'default' : _sliceInstanceProperty__default["default"](spec).call(spec, 'catalog:'.length);
|
|
499
514
|
const block = catalogs.get(name);
|
|
500
515
|
if (!block) {
|
|
501
|
-
|
|
516
|
+
var _context, _context2;
|
|
517
|
+
throw new Error(_concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "Unable to resolve catalog reference \"".concat(spec, "\" for \"")).call(_context2, depName, "\": catalog \"")).call(_context, name, "\" is not declared in the template's pnpm-workspace.yaml."));
|
|
502
518
|
}
|
|
503
519
|
const resolved = block.get(depName);
|
|
504
520
|
if (!resolved) {
|
|
505
|
-
|
|
506
|
-
|
|
521
|
+
var _context3, _context4;
|
|
522
|
+
const where = name === 'default' ? 'the default catalog' : "catalogs.".concat(name);
|
|
523
|
+
throw new Error(_concatInstanceProperty__default["default"](_context3 = _concatInstanceProperty__default["default"](_context4 = "Unable to resolve catalog reference \"".concat(spec, "\" for \"")).call(_context4, depName, "\": dep is not declared under ")).call(_context3, where, " in the template's pnpm-workspace.yaml."));
|
|
507
524
|
}
|
|
508
525
|
return resolved;
|
|
509
526
|
}
|
|
@@ -583,7 +600,8 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
583
600
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
584
601
|
const result = core.transformFileSync(filePath, {
|
|
585
602
|
plugins: [function replaceConfig() {
|
|
586
|
-
|
|
603
|
+
var _options$entryPointUr;
|
|
604
|
+
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
587
605
|
return {
|
|
588
606
|
visitor: {
|
|
589
607
|
Identifier(nodePath) {
|
|
@@ -618,9 +636,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
618
636
|
}],
|
|
619
637
|
retainLines: true
|
|
620
638
|
});
|
|
621
|
-
if (result
|
|
639
|
+
if (result !== null && result !== void 0 && result.code) {
|
|
622
640
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
623
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
641
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
|
|
624
642
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
625
643
|
encoding: 'utf8'
|
|
626
644
|
});
|
|
@@ -633,7 +651,7 @@ function getApplicationConfigName(options) {
|
|
|
633
651
|
case applicationTypes['custom-view']:
|
|
634
652
|
return 'custom-view-config';
|
|
635
653
|
default:
|
|
636
|
-
throw new Error(
|
|
654
|
+
throw new Error("Unknown application type ".concat(options.applicationType));
|
|
637
655
|
}
|
|
638
656
|
}
|
|
639
657
|
function updateApplicationConfig(options) {
|
|
@@ -661,9 +679,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
661
679
|
}],
|
|
662
680
|
retainLines: true
|
|
663
681
|
});
|
|
664
|
-
if (result
|
|
682
|
+
if (result !== null && result !== void 0 && result.code) {
|
|
665
683
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
666
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
684
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
|
|
667
685
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
668
686
|
encoding: 'utf8'
|
|
669
687
|
});
|
|
@@ -700,7 +718,7 @@ const messagesByApplicationType = {
|
|
|
700
718
|
const run = () => {
|
|
701
719
|
// Default command
|
|
702
720
|
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) => {
|
|
703
|
-
var _context;
|
|
721
|
+
var _context, _context2;
|
|
704
722
|
const releaseVersion = await getLatestReleaseVersion();
|
|
705
723
|
hintOutdatedVersion(pkgJson.version, releaseVersion);
|
|
706
724
|
const taskOptions = await processOptions(projectDirectory, options);
|
|
@@ -715,16 +733,16 @@ const run = () => {
|
|
|
715
733
|
await taskList.run();
|
|
716
734
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
717
735
|
console.log('');
|
|
718
|
-
console.log(
|
|
736
|
+
console.log(_concatInstanceProperty__default["default"](_context2 = "\uD83C\uDF89 \uD83C\uDF89 \uD83C\uDF89 The ".concat(messages.featureName, " has been created in the \"")).call(_context2, taskOptions.projectDirectoryName, "\" folder."));
|
|
719
737
|
console.log('');
|
|
720
|
-
console.log(
|
|
721
|
-
console.log(
|
|
738
|
+
console.log("To get started:");
|
|
739
|
+
console.log("$ cd ".concat(taskOptions.projectDirectoryName));
|
|
722
740
|
if (!shouldInstallDependencies) {
|
|
723
|
-
console.log(
|
|
741
|
+
console.log("$ ".concat(packageManager, " install"));
|
|
724
742
|
}
|
|
725
|
-
console.log(
|
|
743
|
+
console.log("$ ".concat(packageManager, " start"));
|
|
726
744
|
console.log('');
|
|
727
|
-
console.log(
|
|
745
|
+
console.log("Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ".concat(messages.featureName, ". Enjoy \uD83D\uDE80"));
|
|
728
746
|
});
|
|
729
747
|
commander.program.parse();
|
|
730
748
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
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');
|
|
6
7
|
var commander = require('commander');
|
|
7
8
|
var listr2 = require('listr2');
|
|
8
9
|
var execa = require('execa');
|
|
@@ -41,6 +42,7 @@ var prettier = require('prettier');
|
|
|
41
42
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
42
43
|
|
|
43
44
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
45
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
44
46
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
45
47
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
46
48
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
@@ -71,7 +73,7 @@ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
|
71
73
|
|
|
72
74
|
var pkgJson = {
|
|
73
75
|
name: "@commercetools-frontend/create-mc-app",
|
|
74
|
-
version: "27.
|
|
76
|
+
version: "27.9.1",
|
|
75
77
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
76
78
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
77
79
|
repository: {
|
|
@@ -108,7 +110,7 @@ var pkgJson = {
|
|
|
108
110
|
yaml: "catalog:"
|
|
109
111
|
},
|
|
110
112
|
devDependencies: {
|
|
111
|
-
"@tsconfig/
|
|
113
|
+
"@tsconfig/node24": "catalog:",
|
|
112
114
|
"@types/prettier": "catalog:"
|
|
113
115
|
},
|
|
114
116
|
engines: {
|
|
@@ -136,10 +138,11 @@ async function getLatestReleaseVersion() {
|
|
|
136
138
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
137
139
|
var _context;
|
|
138
140
|
const hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
|
|
139
|
-
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag &&
|
|
141
|
+
const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && "".concat(releaseVersion)]).call(_context, Boolean).join(', ');
|
|
140
142
|
if (hintNewerVersions.length > 0) {
|
|
143
|
+
var _context2;
|
|
141
144
|
console.log('');
|
|
142
|
-
console.log(
|
|
145
|
+
console.log(_concatInstanceProperty__default["default"](_context2 = "New version available! ".concat(currentVersion, " -> ")).call(_context2, hintNewerVersions));
|
|
143
146
|
console.log('');
|
|
144
147
|
}
|
|
145
148
|
}
|
|
@@ -206,7 +209,7 @@ const getInstallCommand = options => {
|
|
|
206
209
|
case 'npm':
|
|
207
210
|
return 'npm install --legacy-peer-deps';
|
|
208
211
|
default:
|
|
209
|
-
return
|
|
212
|
+
return "".concat(packageManager, " install");
|
|
210
213
|
}
|
|
211
214
|
};
|
|
212
215
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -216,19 +219,21 @@ const wordify = slug => {
|
|
|
216
219
|
return _mapInstanceProperty__default["default"](_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
217
220
|
};
|
|
218
221
|
const resolveFilePathByExtension = requestedModule => {
|
|
219
|
-
var _context3;
|
|
222
|
+
var _context3, _context5;
|
|
220
223
|
const fileExtension = _findInstanceProperty__default["default"](_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
221
|
-
|
|
224
|
+
var _context4;
|
|
225
|
+
const filePath = _concatInstanceProperty__default["default"](_context4 = "".concat(requestedModule)).call(_context4, ext);
|
|
222
226
|
return doesFileExist(filePath);
|
|
223
227
|
});
|
|
224
|
-
return
|
|
228
|
+
return _concatInstanceProperty__default["default"](_context5 = "".concat(requestedModule)).call(_context5, fileExtension);
|
|
225
229
|
};
|
|
226
230
|
|
|
227
231
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
228
232
|
var _context;
|
|
229
233
|
const applicationTypesList = _Object$keys__default["default"](applicationTypes);
|
|
230
234
|
if (!_includesInstanceProperty__default["default"](_context = _Object$values__default["default"](applicationTypesList)).call(_context, applicationType)) {
|
|
231
|
-
|
|
235
|
+
var _context2;
|
|
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\"."));
|
|
232
237
|
}
|
|
233
238
|
};
|
|
234
239
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -238,19 +243,22 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
238
243
|
break;
|
|
239
244
|
default:
|
|
240
245
|
{
|
|
246
|
+
var _context3;
|
|
241
247
|
const templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
|
|
242
|
-
throw new Error(
|
|
248
|
+
throw new Error(_concatInstanceProperty__default["default"](_context3 = "The provided template name \"".concat(templateName, "\" does not exist. Available templates are \"")).call(_context3, templateNamesList, "\". Make sure you are also using the latest version of \"@commercetools-frontend/create-mc-app\"."));
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
};
|
|
246
252
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
247
253
|
if (doesFileExist(dirPath)) {
|
|
248
|
-
|
|
254
|
+
var _context4;
|
|
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."));
|
|
249
256
|
}
|
|
250
257
|
};
|
|
251
258
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
252
259
|
if (!doesFileExist(templateFolderPath)) {
|
|
253
|
-
|
|
260
|
+
var _context5;
|
|
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"));
|
|
254
262
|
}
|
|
255
263
|
// In case the version is semver (usually release tags) we check that
|
|
256
264
|
// the cloned repository contains the template matching the given version
|
|
@@ -260,48 +268,52 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
260
268
|
}));
|
|
261
269
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
262
270
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
263
|
-
|
|
271
|
+
var _context6, _context7;
|
|
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"));
|
|
264
273
|
}
|
|
265
274
|
}
|
|
266
275
|
};
|
|
267
276
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
268
277
|
if (!initialProjectKey) {
|
|
269
|
-
throw new Error(
|
|
278
|
+
throw new Error("Provide a valid project key that you have access to.");
|
|
270
279
|
}
|
|
271
280
|
};
|
|
272
281
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
273
282
|
const hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
|
|
274
283
|
if (!hasValidNodeVersion) {
|
|
275
|
-
|
|
284
|
+
var _context8;
|
|
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."));
|
|
276
286
|
}
|
|
277
287
|
};
|
|
278
288
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
279
289
|
const allowedCloudIdentifiers = _Object$values__default["default"](applicationConfig.CLOUD_IDENTIFIERS);
|
|
280
290
|
if (!_includesInstanceProperty__default["default"](allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
281
|
-
|
|
291
|
+
var _context9;
|
|
292
|
+
throw new Error(_concatInstanceProperty__default["default"](_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
282
293
|
}
|
|
283
294
|
};
|
|
284
295
|
|
|
285
296
|
const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
|
|
286
297
|
const getEntryPointUriPath = async (rl, options) => {
|
|
298
|
+
var _context;
|
|
287
299
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
288
300
|
return;
|
|
289
301
|
}
|
|
290
302
|
if (options.entryPointUriPath) {
|
|
291
303
|
return options.entryPointUriPath;
|
|
292
304
|
}
|
|
293
|
-
const randomEntryPointUriPath =
|
|
305
|
+
const randomEntryPointUriPath = _concatInstanceProperty__default["default"](_context = "".concat(options.template, "-")).call(_context, crypto__default["default"].randomBytes(3).toString('hex'));
|
|
294
306
|
if (options.yes) {
|
|
295
307
|
return randomEntryPointUriPath;
|
|
296
308
|
}
|
|
297
|
-
const answerEntryPointUriPath = await question(rl,
|
|
309
|
+
const answerEntryPointUriPath = await question(rl, "Provide the Custom Application entryPointUriPath (default \"".concat(randomEntryPointUriPath, "\"): "));
|
|
298
310
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
299
311
|
};
|
|
300
312
|
const getInitialProjectKey = async (rl, options) => {
|
|
301
313
|
if (options.initialProjectKey) {
|
|
302
314
|
return options.initialProjectKey;
|
|
303
315
|
}
|
|
304
|
-
const initialProjectKey = await question(rl,
|
|
316
|
+
const initialProjectKey = await question(rl, "Provide the initial project key for local development: ");
|
|
305
317
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
306
318
|
return initialProjectKey;
|
|
307
319
|
};
|
|
@@ -328,7 +340,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
328
340
|
|
|
329
341
|
// Parse options
|
|
330
342
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
331
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
343
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? "v".concat(tagOrBranchVersion) : tagOrBranchVersion;
|
|
332
344
|
const templateName = options.template;
|
|
333
345
|
|
|
334
346
|
// Validate options
|
|
@@ -373,15 +385,16 @@ function downloadTemplate(options) {
|
|
|
373
385
|
return {
|
|
374
386
|
title: 'Downloading template',
|
|
375
387
|
task: () => {
|
|
388
|
+
var _context;
|
|
376
389
|
const clonedRepositoryPath = options.clonedRepositoryPath;
|
|
377
390
|
const tmpDir = path__default["default"].dirname(clonedRepositoryPath);
|
|
378
391
|
const tmpFolderNameForClonedRepository = path__default["default"].basename(clonedRepositoryPath);
|
|
379
392
|
const templateFolderPath = path__default["default"].join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
380
393
|
return new listr2.Listr([{
|
|
381
|
-
title:
|
|
394
|
+
title: "Cloning repository using branch ".concat(options.tagOrBranchVersion),
|
|
382
395
|
task: async () => {
|
|
383
396
|
// Shallow clone repository
|
|
384
|
-
const result = await execa__default["default"]('git', ['clone',
|
|
397
|
+
const result = await execa__default["default"]('git', ['clone', "--branch=".concat(options.tagOrBranchVersion), '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
385
398
|
cwd: tmpDir,
|
|
386
399
|
encoding: 'utf-8'
|
|
387
400
|
});
|
|
@@ -392,7 +405,7 @@ function downloadTemplate(options) {
|
|
|
392
405
|
return result.stdout;
|
|
393
406
|
}
|
|
394
407
|
}, {
|
|
395
|
-
title:
|
|
408
|
+
title: _concatInstanceProperty__default["default"](_context = "Copying template ".concat(options.templateName, " into project directory ")).call(_context, options.projectDirectoryPath),
|
|
396
409
|
task: async () => {
|
|
397
410
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
398
411
|
const result = await execa__default["default"](command, [templateFolderPath,
|
|
@@ -405,12 +418,12 @@ function downloadTemplate(options) {
|
|
|
405
418
|
}
|
|
406
419
|
const templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
|
|
407
420
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
408
|
-
throw new Error(
|
|
421
|
+
throw new Error("Unable to verify that the template application has a package.json at \"".concat(templatePackageJsonPath, "\""));
|
|
409
422
|
}
|
|
410
423
|
return result.stdout;
|
|
411
424
|
}
|
|
412
425
|
}, {
|
|
413
|
-
title:
|
|
426
|
+
title: "Cleaning up project directory",
|
|
414
427
|
task: async () => {
|
|
415
428
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
416
429
|
const result = await execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, filePath => path__default["default"].join(options.projectDirectoryPath, filePath)), {
|
|
@@ -449,7 +462,7 @@ function installDependencies(options) {
|
|
|
449
462
|
}
|
|
450
463
|
|
|
451
464
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
452
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
465
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
453
466
|
|
|
454
467
|
// Catalog references in workspace package.json files point at entries in
|
|
455
468
|
// pnpm-workspace.yaml. They have to be flattened to concrete version
|
|
@@ -461,12 +474,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
|
|
|
461
474
|
// share one code path.
|
|
462
475
|
|
|
463
476
|
function parseCatalogs(yamlText) {
|
|
464
|
-
|
|
477
|
+
var _parseYaml;
|
|
478
|
+
const doc = (_parseYaml = yaml.parse(yamlText)) !== null && _parseYaml !== void 0 ? _parseYaml : {};
|
|
465
479
|
const out = new _Map__default["default"]();
|
|
466
480
|
if (doc.catalog) {
|
|
467
481
|
out.set('default', new _Map__default["default"](_Object$entries__default["default"](doc.catalog)));
|
|
468
482
|
}
|
|
469
|
-
for (const _ref of _Object$entries__default["default"](doc.catalogs
|
|
483
|
+
for (const _ref of _Object$entries__default["default"]((_doc$catalogs = doc.catalogs) !== null && _doc$catalogs !== void 0 ? _doc$catalogs : {})) {
|
|
484
|
+
var _doc$catalogs;
|
|
470
485
|
var _ref2 = _slicedToArray(_ref, 2);
|
|
471
486
|
const name = _ref2[0];
|
|
472
487
|
const entries = _ref2[1];
|
|
@@ -480,8 +495,8 @@ function parseCatalogs(yamlText) {
|
|
|
480
495
|
// logic — extend the table to handle new protocol additions.
|
|
481
496
|
const WORKSPACE_REWRITERS = {
|
|
482
497
|
'workspace:*': v => v,
|
|
483
|
-
'workspace:^': v =>
|
|
484
|
-
'workspace:~': v =>
|
|
498
|
+
'workspace:^': v => "^".concat(v),
|
|
499
|
+
'workspace:~': v => "~".concat(v)
|
|
485
500
|
};
|
|
486
501
|
|
|
487
502
|
/**
|
|
@@ -498,12 +513,14 @@ function resolveCatalogRef(spec, depName, catalogs) {
|
|
|
498
513
|
const name = spec === 'catalog:' || spec === 'catalog:default' ? 'default' : _sliceInstanceProperty__default["default"](spec).call(spec, 'catalog:'.length);
|
|
499
514
|
const block = catalogs.get(name);
|
|
500
515
|
if (!block) {
|
|
501
|
-
|
|
516
|
+
var _context, _context2;
|
|
517
|
+
throw new Error(_concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "Unable to resolve catalog reference \"".concat(spec, "\" for \"")).call(_context2, depName, "\": catalog \"")).call(_context, name, "\" is not declared in the template's pnpm-workspace.yaml."));
|
|
502
518
|
}
|
|
503
519
|
const resolved = block.get(depName);
|
|
504
520
|
if (!resolved) {
|
|
505
|
-
|
|
506
|
-
|
|
521
|
+
var _context3, _context4;
|
|
522
|
+
const where = name === 'default' ? 'the default catalog' : "catalogs.".concat(name);
|
|
523
|
+
throw new Error(_concatInstanceProperty__default["default"](_context3 = _concatInstanceProperty__default["default"](_context4 = "Unable to resolve catalog reference \"".concat(spec, "\" for \"")).call(_context4, depName, "\": dep is not declared under ")).call(_context3, where, " in the template's pnpm-workspace.yaml."));
|
|
507
524
|
}
|
|
508
525
|
return resolved;
|
|
509
526
|
}
|
|
@@ -583,7 +600,8 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
583
600
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
584
601
|
const result = core.transformFileSync(filePath, {
|
|
585
602
|
plugins: [function replaceConfig() {
|
|
586
|
-
|
|
603
|
+
var _options$entryPointUr;
|
|
604
|
+
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
587
605
|
return {
|
|
588
606
|
visitor: {
|
|
589
607
|
Identifier(nodePath) {
|
|
@@ -618,9 +636,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
618
636
|
}],
|
|
619
637
|
retainLines: true
|
|
620
638
|
});
|
|
621
|
-
if (result
|
|
639
|
+
if (result !== null && result !== void 0 && result.code) {
|
|
622
640
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
623
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
641
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
|
|
624
642
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
625
643
|
encoding: 'utf8'
|
|
626
644
|
});
|
|
@@ -633,7 +651,7 @@ function getApplicationConfigName(options) {
|
|
|
633
651
|
case applicationTypes['custom-view']:
|
|
634
652
|
return 'custom-view-config';
|
|
635
653
|
default:
|
|
636
|
-
throw new Error(
|
|
654
|
+
throw new Error("Unknown application type ".concat(options.applicationType));
|
|
637
655
|
}
|
|
638
656
|
}
|
|
639
657
|
function updateApplicationConfig(options) {
|
|
@@ -661,9 +679,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
661
679
|
}],
|
|
662
680
|
retainLines: true
|
|
663
681
|
});
|
|
664
|
-
if (result
|
|
682
|
+
if (result !== null && result !== void 0 && result.code) {
|
|
665
683
|
const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
|
|
666
|
-
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig
|
|
684
|
+
const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
|
|
667
685
|
fs__default["default"].writeFileSync(filePath, formattedData, {
|
|
668
686
|
encoding: 'utf8'
|
|
669
687
|
});
|
|
@@ -700,7 +718,7 @@ const messagesByApplicationType = {
|
|
|
700
718
|
const run = () => {
|
|
701
719
|
// Default command
|
|
702
720
|
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) => {
|
|
703
|
-
var _context;
|
|
721
|
+
var _context, _context2;
|
|
704
722
|
const releaseVersion = await getLatestReleaseVersion();
|
|
705
723
|
hintOutdatedVersion(pkgJson.version, releaseVersion);
|
|
706
724
|
const taskOptions = await processOptions(projectDirectory, options);
|
|
@@ -715,16 +733,16 @@ const run = () => {
|
|
|
715
733
|
await taskList.run();
|
|
716
734
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
717
735
|
console.log('');
|
|
718
|
-
console.log(
|
|
736
|
+
console.log(_concatInstanceProperty__default["default"](_context2 = "\uD83C\uDF89 \uD83C\uDF89 \uD83C\uDF89 The ".concat(messages.featureName, " has been created in the \"")).call(_context2, taskOptions.projectDirectoryName, "\" folder."));
|
|
719
737
|
console.log('');
|
|
720
|
-
console.log(
|
|
721
|
-
console.log(
|
|
738
|
+
console.log("To get started:");
|
|
739
|
+
console.log("$ cd ".concat(taskOptions.projectDirectoryName));
|
|
722
740
|
if (!shouldInstallDependencies) {
|
|
723
|
-
console.log(
|
|
741
|
+
console.log("$ ".concat(packageManager, " install"));
|
|
724
742
|
}
|
|
725
|
-
console.log(
|
|
743
|
+
console.log("$ ".concat(packageManager, " start"));
|
|
726
744
|
console.log('');
|
|
727
|
-
console.log(
|
|
745
|
+
console.log("Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ".concat(messages.featureName, ". Enjoy \uD83D\uDE80"));
|
|
728
746
|
});
|
|
729
747
|
commander.program.parse();
|
|
730
748
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
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';
|
|
2
3
|
import { program } from 'commander';
|
|
3
4
|
import { Listr } from 'listr2';
|
|
4
5
|
import execa from 'execa';
|
|
@@ -36,7 +37,7 @@ import prettier from 'prettier';
|
|
|
36
37
|
|
|
37
38
|
var pkgJson = {
|
|
38
39
|
name: "@commercetools-frontend/create-mc-app",
|
|
39
|
-
version: "27.
|
|
40
|
+
version: "27.9.1",
|
|
40
41
|
description: "Create Merchant Center applications to quickly get up and running",
|
|
41
42
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
42
43
|
repository: {
|
|
@@ -73,7 +74,7 @@ var pkgJson = {
|
|
|
73
74
|
yaml: "catalog:"
|
|
74
75
|
},
|
|
75
76
|
devDependencies: {
|
|
76
|
-
"@tsconfig/
|
|
77
|
+
"@tsconfig/node24": "catalog:",
|
|
77
78
|
"@types/prettier": "catalog:"
|
|
78
79
|
},
|
|
79
80
|
engines: {
|
|
@@ -101,10 +102,11 @@ async function getLatestReleaseVersion() {
|
|
|
101
102
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
102
103
|
var _context;
|
|
103
104
|
const hasBeenReleastedInLatestTag = semver.gt(releaseVersion, currentVersion);
|
|
104
|
-
const hintNewerVersions = _filterInstanceProperty(_context = [hasBeenReleastedInLatestTag &&
|
|
105
|
+
const hintNewerVersions = _filterInstanceProperty(_context = [hasBeenReleastedInLatestTag && "".concat(releaseVersion)]).call(_context, Boolean).join(', ');
|
|
105
106
|
if (hintNewerVersions.length > 0) {
|
|
107
|
+
var _context2;
|
|
106
108
|
console.log('');
|
|
107
|
-
console.log(
|
|
109
|
+
console.log(_concatInstanceProperty(_context2 = "New version available! ".concat(currentVersion, " -> ")).call(_context2, hintNewerVersions));
|
|
108
110
|
console.log('');
|
|
109
111
|
}
|
|
110
112
|
}
|
|
@@ -171,7 +173,7 @@ const getInstallCommand = options => {
|
|
|
171
173
|
case 'npm':
|
|
172
174
|
return 'npm install --legacy-peer-deps';
|
|
173
175
|
default:
|
|
174
|
-
return
|
|
176
|
+
return "".concat(packageManager, " install");
|
|
175
177
|
}
|
|
176
178
|
};
|
|
177
179
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
@@ -181,19 +183,21 @@ const wordify = slug => {
|
|
|
181
183
|
return _mapInstanceProperty(_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
182
184
|
};
|
|
183
185
|
const resolveFilePathByExtension = requestedModule => {
|
|
184
|
-
var _context3;
|
|
186
|
+
var _context3, _context5;
|
|
185
187
|
const fileExtension = _findInstanceProperty(_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
186
|
-
|
|
188
|
+
var _context4;
|
|
189
|
+
const filePath = _concatInstanceProperty(_context4 = "".concat(requestedModule)).call(_context4, ext);
|
|
187
190
|
return doesFileExist(filePath);
|
|
188
191
|
});
|
|
189
|
-
return
|
|
192
|
+
return _concatInstanceProperty(_context5 = "".concat(requestedModule)).call(_context5, fileExtension);
|
|
190
193
|
};
|
|
191
194
|
|
|
192
195
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
193
196
|
var _context;
|
|
194
197
|
const applicationTypesList = _Object$keys(applicationTypes);
|
|
195
198
|
if (!_includesInstanceProperty(_context = _Object$values(applicationTypesList)).call(_context, applicationType)) {
|
|
196
|
-
|
|
199
|
+
var _context2;
|
|
200
|
+
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\"."));
|
|
197
201
|
}
|
|
198
202
|
};
|
|
199
203
|
const throwIfTemplateIsNotSupported = templateName => {
|
|
@@ -203,19 +207,22 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
203
207
|
break;
|
|
204
208
|
default:
|
|
205
209
|
{
|
|
210
|
+
var _context3;
|
|
206
211
|
const templateNamesList = _Object$keys(availableTemplates).toString();
|
|
207
|
-
throw new Error(
|
|
212
|
+
throw new Error(_concatInstanceProperty(_context3 = "The provided template name \"".concat(templateName, "\" does not exist. Available templates are \"")).call(_context3, templateNamesList, "\". Make sure you are also using the latest version of \"@commercetools-frontend/create-mc-app\"."));
|
|
208
213
|
}
|
|
209
214
|
}
|
|
210
215
|
};
|
|
211
216
|
const throwIfProjectDirectoryExists = (dirName, dirPath) => {
|
|
212
217
|
if (doesFileExist(dirPath)) {
|
|
213
|
-
|
|
218
|
+
var _context4;
|
|
219
|
+
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."));
|
|
214
220
|
}
|
|
215
221
|
};
|
|
216
222
|
const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
|
|
217
223
|
if (!doesFileExist(templateFolderPath)) {
|
|
218
|
-
|
|
224
|
+
var _context5;
|
|
225
|
+
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"));
|
|
219
226
|
}
|
|
220
227
|
// In case the version is semver (usually release tags) we check that
|
|
221
228
|
// the cloned repository contains the template matching the given version
|
|
@@ -225,48 +232,52 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
225
232
|
}));
|
|
226
233
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
227
234
|
if (templatePackageJson.version !== versionAsNumber) {
|
|
228
|
-
|
|
235
|
+
var _context6, _context7;
|
|
236
|
+
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"));
|
|
229
237
|
}
|
|
230
238
|
}
|
|
231
239
|
};
|
|
232
240
|
const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
233
241
|
if (!initialProjectKey) {
|
|
234
|
-
throw new Error(
|
|
242
|
+
throw new Error("Provide a valid project key that you have access to.");
|
|
235
243
|
}
|
|
236
244
|
};
|
|
237
245
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
238
246
|
const hasValidNodeVersion = semver.satisfies(currentNodeVersion, expectedVersionRange);
|
|
239
247
|
if (!hasValidNodeVersion) {
|
|
240
|
-
|
|
248
|
+
var _context8;
|
|
249
|
+
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."));
|
|
241
250
|
}
|
|
242
251
|
};
|
|
243
252
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
244
253
|
const allowedCloudIdentifiers = _Object$values(CLOUD_IDENTIFIERS);
|
|
245
254
|
if (!_includesInstanceProperty(allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
246
|
-
|
|
255
|
+
var _context9;
|
|
256
|
+
throw new Error(_concatInstanceProperty(_context9 = "The cloud region \"".concat(cloudIdentifier, "\" is not supported. Supported regions are: ")).call(_context9, allowedCloudIdentifiers.join(', '), "."));
|
|
247
257
|
}
|
|
248
258
|
};
|
|
249
259
|
|
|
250
260
|
const question = (rl, value) => new _Promise(resolve => rl.question(value, resolve));
|
|
251
261
|
const getEntryPointUriPath = async (rl, options) => {
|
|
262
|
+
var _context;
|
|
252
263
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
253
264
|
return;
|
|
254
265
|
}
|
|
255
266
|
if (options.entryPointUriPath) {
|
|
256
267
|
return options.entryPointUriPath;
|
|
257
268
|
}
|
|
258
|
-
const randomEntryPointUriPath =
|
|
269
|
+
const randomEntryPointUriPath = _concatInstanceProperty(_context = "".concat(options.template, "-")).call(_context, crypto.randomBytes(3).toString('hex'));
|
|
259
270
|
if (options.yes) {
|
|
260
271
|
return randomEntryPointUriPath;
|
|
261
272
|
}
|
|
262
|
-
const answerEntryPointUriPath = await question(rl,
|
|
273
|
+
const answerEntryPointUriPath = await question(rl, "Provide the Custom Application entryPointUriPath (default \"".concat(randomEntryPointUriPath, "\"): "));
|
|
263
274
|
return answerEntryPointUriPath || randomEntryPointUriPath;
|
|
264
275
|
};
|
|
265
276
|
const getInitialProjectKey = async (rl, options) => {
|
|
266
277
|
if (options.initialProjectKey) {
|
|
267
278
|
return options.initialProjectKey;
|
|
268
279
|
}
|
|
269
|
-
const initialProjectKey = await question(rl,
|
|
280
|
+
const initialProjectKey = await question(rl, "Provide the initial project key for local development: ");
|
|
270
281
|
throwIfInitialProjectKeyIsMissing(initialProjectKey);
|
|
271
282
|
return initialProjectKey;
|
|
272
283
|
};
|
|
@@ -293,7 +304,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
293
304
|
|
|
294
305
|
// Parse options
|
|
295
306
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
296
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ?
|
|
307
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? "v".concat(tagOrBranchVersion) : tagOrBranchVersion;
|
|
297
308
|
const templateName = options.template;
|
|
298
309
|
|
|
299
310
|
// Validate options
|
|
@@ -338,15 +349,16 @@ function downloadTemplate(options) {
|
|
|
338
349
|
return {
|
|
339
350
|
title: 'Downloading template',
|
|
340
351
|
task: () => {
|
|
352
|
+
var _context;
|
|
341
353
|
const clonedRepositoryPath = options.clonedRepositoryPath;
|
|
342
354
|
const tmpDir = path.dirname(clonedRepositoryPath);
|
|
343
355
|
const tmpFolderNameForClonedRepository = path.basename(clonedRepositoryPath);
|
|
344
356
|
const templateFolderPath = path.join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
345
357
|
return new Listr([{
|
|
346
|
-
title:
|
|
358
|
+
title: "Cloning repository using branch ".concat(options.tagOrBranchVersion),
|
|
347
359
|
task: async () => {
|
|
348
360
|
// Shallow clone repository
|
|
349
|
-
const result = await execa('git', ['clone',
|
|
361
|
+
const result = await execa('git', ['clone', "--branch=".concat(options.tagOrBranchVersion), '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
350
362
|
cwd: tmpDir,
|
|
351
363
|
encoding: 'utf-8'
|
|
352
364
|
});
|
|
@@ -357,7 +369,7 @@ function downloadTemplate(options) {
|
|
|
357
369
|
return result.stdout;
|
|
358
370
|
}
|
|
359
371
|
}, {
|
|
360
|
-
title:
|
|
372
|
+
title: _concatInstanceProperty(_context = "Copying template ".concat(options.templateName, " into project directory ")).call(_context, options.projectDirectoryPath),
|
|
361
373
|
task: async () => {
|
|
362
374
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
363
375
|
const result = await execa(command, [templateFolderPath,
|
|
@@ -370,12 +382,12 @@ function downloadTemplate(options) {
|
|
|
370
382
|
}
|
|
371
383
|
const templatePackageJsonPath = path.join(options.projectDirectoryPath, 'package.json');
|
|
372
384
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
373
|
-
throw new Error(
|
|
385
|
+
throw new Error("Unable to verify that the template application has a package.json at \"".concat(templatePackageJsonPath, "\""));
|
|
374
386
|
}
|
|
375
387
|
return result.stdout;
|
|
376
388
|
}
|
|
377
389
|
}, {
|
|
378
|
-
title:
|
|
390
|
+
title: "Cleaning up project directory",
|
|
379
391
|
task: async () => {
|
|
380
392
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
381
393
|
const result = await execa(command, _mapInstanceProperty(filesToBeRemoved).call(filesToBeRemoved, filePath => path.join(options.projectDirectoryPath, filePath)), {
|
|
@@ -414,7 +426,7 @@ function installDependencies(options) {
|
|
|
414
426
|
}
|
|
415
427
|
|
|
416
428
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
417
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
429
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
418
430
|
|
|
419
431
|
// Catalog references in workspace package.json files point at entries in
|
|
420
432
|
// pnpm-workspace.yaml. They have to be flattened to concrete version
|
|
@@ -426,12 +438,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
|
|
|
426
438
|
// share one code path.
|
|
427
439
|
|
|
428
440
|
function parseCatalogs(yamlText) {
|
|
429
|
-
|
|
441
|
+
var _parseYaml;
|
|
442
|
+
const doc = (_parseYaml = parse(yamlText)) !== null && _parseYaml !== void 0 ? _parseYaml : {};
|
|
430
443
|
const out = new _Map();
|
|
431
444
|
if (doc.catalog) {
|
|
432
445
|
out.set('default', new _Map(_Object$entries(doc.catalog)));
|
|
433
446
|
}
|
|
434
|
-
for (const _ref of _Object$entries(doc.catalogs
|
|
447
|
+
for (const _ref of _Object$entries((_doc$catalogs = doc.catalogs) !== null && _doc$catalogs !== void 0 ? _doc$catalogs : {})) {
|
|
448
|
+
var _doc$catalogs;
|
|
435
449
|
var _ref2 = _slicedToArray(_ref, 2);
|
|
436
450
|
const name = _ref2[0];
|
|
437
451
|
const entries = _ref2[1];
|
|
@@ -445,8 +459,8 @@ function parseCatalogs(yamlText) {
|
|
|
445
459
|
// logic — extend the table to handle new protocol additions.
|
|
446
460
|
const WORKSPACE_REWRITERS = {
|
|
447
461
|
'workspace:*': v => v,
|
|
448
|
-
'workspace:^': v =>
|
|
449
|
-
'workspace:~': v =>
|
|
462
|
+
'workspace:^': v => "^".concat(v),
|
|
463
|
+
'workspace:~': v => "~".concat(v)
|
|
450
464
|
};
|
|
451
465
|
|
|
452
466
|
/**
|
|
@@ -463,12 +477,14 @@ function resolveCatalogRef(spec, depName, catalogs) {
|
|
|
463
477
|
const name = spec === 'catalog:' || spec === 'catalog:default' ? 'default' : _sliceInstanceProperty(spec).call(spec, 'catalog:'.length);
|
|
464
478
|
const block = catalogs.get(name);
|
|
465
479
|
if (!block) {
|
|
466
|
-
|
|
480
|
+
var _context, _context2;
|
|
481
|
+
throw new Error(_concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "Unable to resolve catalog reference \"".concat(spec, "\" for \"")).call(_context2, depName, "\": catalog \"")).call(_context, name, "\" is not declared in the template's pnpm-workspace.yaml."));
|
|
467
482
|
}
|
|
468
483
|
const resolved = block.get(depName);
|
|
469
484
|
if (!resolved) {
|
|
470
|
-
|
|
471
|
-
|
|
485
|
+
var _context3, _context4;
|
|
486
|
+
const where = name === 'default' ? 'the default catalog' : "catalogs.".concat(name);
|
|
487
|
+
throw new Error(_concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "Unable to resolve catalog reference \"".concat(spec, "\" for \"")).call(_context4, depName, "\": dep is not declared under ")).call(_context3, where, " in the template's pnpm-workspace.yaml."));
|
|
472
488
|
}
|
|
473
489
|
return resolved;
|
|
474
490
|
}
|
|
@@ -548,7 +564,8 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
548
564
|
function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
549
565
|
const result = transformFileSync(filePath, {
|
|
550
566
|
plugins: [function replaceConfig() {
|
|
551
|
-
|
|
567
|
+
var _options$entryPointUr;
|
|
568
|
+
const appName = wordify((_options$entryPointUr = options.entryPointUriPath) !== null && _options$entryPointUr !== void 0 ? _options$entryPointUr : options.projectDirectoryName);
|
|
552
569
|
return {
|
|
553
570
|
visitor: {
|
|
554
571
|
Identifier(nodePath) {
|
|
@@ -583,9 +600,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
583
600
|
}],
|
|
584
601
|
retainLines: true
|
|
585
602
|
});
|
|
586
|
-
if (result
|
|
603
|
+
if (result !== null && result !== void 0 && result.code) {
|
|
587
604
|
const prettierConfig = prettier.resolveConfig.sync(options.projectDirectoryPath);
|
|
588
|
-
const formattedData = prettier.format(result.code + os.EOL, prettierConfig
|
|
605
|
+
const formattedData = prettier.format(result.code + os.EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
|
|
589
606
|
fs.writeFileSync(filePath, formattedData, {
|
|
590
607
|
encoding: 'utf8'
|
|
591
608
|
});
|
|
@@ -598,7 +615,7 @@ function getApplicationConfigName(options) {
|
|
|
598
615
|
case applicationTypes['custom-view']:
|
|
599
616
|
return 'custom-view-config';
|
|
600
617
|
default:
|
|
601
|
-
throw new Error(
|
|
618
|
+
throw new Error("Unknown application type ".concat(options.applicationType));
|
|
602
619
|
}
|
|
603
620
|
}
|
|
604
621
|
function updateApplicationConfig(options) {
|
|
@@ -626,9 +643,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
626
643
|
}],
|
|
627
644
|
retainLines: true
|
|
628
645
|
});
|
|
629
|
-
if (result
|
|
646
|
+
if (result !== null && result !== void 0 && result.code) {
|
|
630
647
|
const prettierConfig = prettier.resolveConfig.sync(options.projectDirectoryPath);
|
|
631
|
-
const formattedData = prettier.format(result.code + os.EOL, prettierConfig
|
|
648
|
+
const formattedData = prettier.format(result.code + os.EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
|
|
632
649
|
fs.writeFileSync(filePath, formattedData, {
|
|
633
650
|
encoding: 'utf8'
|
|
634
651
|
});
|
|
@@ -665,7 +682,7 @@ const messagesByApplicationType = {
|
|
|
665
682
|
const run = () => {
|
|
666
683
|
// Default command
|
|
667
684
|
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) => {
|
|
668
|
-
var _context;
|
|
685
|
+
var _context, _context2;
|
|
669
686
|
const releaseVersion = await getLatestReleaseVersion();
|
|
670
687
|
hintOutdatedVersion(pkgJson.version, releaseVersion);
|
|
671
688
|
const taskOptions = await processOptions(projectDirectory, options);
|
|
@@ -680,16 +697,16 @@ const run = () => {
|
|
|
680
697
|
await taskList.run();
|
|
681
698
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
682
699
|
console.log('');
|
|
683
|
-
console.log(
|
|
700
|
+
console.log(_concatInstanceProperty(_context2 = "\uD83C\uDF89 \uD83C\uDF89 \uD83C\uDF89 The ".concat(messages.featureName, " has been created in the \"")).call(_context2, taskOptions.projectDirectoryName, "\" folder."));
|
|
684
701
|
console.log('');
|
|
685
|
-
console.log(
|
|
686
|
-
console.log(
|
|
702
|
+
console.log("To get started:");
|
|
703
|
+
console.log("$ cd ".concat(taskOptions.projectDirectoryName));
|
|
687
704
|
if (!shouldInstallDependencies) {
|
|
688
|
-
console.log(
|
|
705
|
+
console.log("$ ".concat(packageManager, " install"));
|
|
689
706
|
}
|
|
690
|
-
console.log(
|
|
707
|
+
console.log("$ ".concat(packageManager, " start"));
|
|
691
708
|
console.log('');
|
|
692
|
-
console.log(
|
|
709
|
+
console.log("Visit https://docs.commercetools.com/merchant-center-customizations/ for more info about developing ".concat(messages.featureName, ". Enjoy \uD83D\uDE80"));
|
|
693
710
|
});
|
|
694
711
|
program.parse();
|
|
695
712
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/create-mc-app",
|
|
3
|
-
"version": "27.
|
|
3
|
+
"version": "27.9.1",
|
|
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": {
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
},
|
|
22
22
|
"main": "dist/commercetools-frontend-create-mc-app.cjs.js",
|
|
23
23
|
"module": "dist/commercetools-frontend-create-mc-app.esm.js",
|
|
24
|
-
"bin": "./bin/cli.js",
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"@babel/core": "^7.22.17",
|
|
27
26
|
"@babel/runtime": "^7.22.15",
|
|
@@ -32,15 +31,18 @@
|
|
|
32
31
|
"execa": "5.1.1",
|
|
33
32
|
"listr2": "5.0.8",
|
|
34
33
|
"prettier": "2.8.8",
|
|
35
|
-
"semver": "7.
|
|
34
|
+
"semver": "7.8.5",
|
|
36
35
|
"yaml": "^2.6.1",
|
|
37
|
-
"@commercetools-frontend/application-config": "^27.
|
|
36
|
+
"@commercetools-frontend/application-config": "^27.9.1"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@tsconfig/
|
|
39
|
+
"@tsconfig/node24": "^24.0.0",
|
|
41
40
|
"@types/prettier": "2.7.3"
|
|
42
41
|
},
|
|
43
42
|
"engines": {
|
|
44
43
|
"node": "18.x || 20.x || >=22.0.0"
|
|
44
|
+
},
|
|
45
|
+
"bin": {
|
|
46
|
+
"create-mc-app": "./bin/cli.js"
|
|
45
47
|
}
|
|
46
48
|
}
|
package/tsconfig.json
CHANGED