@commercetools-frontend/create-mc-app 27.5.1 → 27.5.3
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,41 @@
|
|
|
1
1
|
# @commercetools-frontend/create-mc-app
|
|
2
2
|
|
|
3
|
+
## 27.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3989](https://github.com/commercetools/merchant-center-application-kit/pull/3989) [`222259a`](https://github.com/commercetools/merchant-center-application-kit/commit/222259a810691eaf7904e89acddca444ac8bd0b6) Thanks [@misama-ct](https://github.com/misama-ct)! - Bump transitive dependencies via pnpm overrides to address 46 high-severity Dependabot alerts. Updated dependencies:
|
|
8
|
+
|
|
9
|
+
- `@isaacs/brace-expansion` >= 5.0.1
|
|
10
|
+
- `@remix-run/router` >= 1.23.2
|
|
11
|
+
- `@xmldom/xmldom` >= 0.8.13
|
|
12
|
+
- `axios` >= 1.15.2
|
|
13
|
+
- `immutable` >= 3.8.3
|
|
14
|
+
- `lodash-es` >= 4.17.21
|
|
15
|
+
- `minimatch@^3` ^3.1.4
|
|
16
|
+
- `minimatch@^4` ^4.2.5
|
|
17
|
+
- `minimatch@^9` ^9.0.7
|
|
18
|
+
- `minimatch@^10` ^10.2.3
|
|
19
|
+
- `path-to-regexp@^6` ^6.3.0
|
|
20
|
+
- `picomatch@^4` ^4.0.4
|
|
21
|
+
- `rollup` ^4.59.0
|
|
22
|
+
- `semver@^6` ^6.3.1
|
|
23
|
+
- `svgo` >= 2.8.1
|
|
24
|
+
- `systeminformation` >= 5.31.0
|
|
25
|
+
- `tar` >= 7.5.11
|
|
26
|
+
- `tar-fs` >= 3.1.1
|
|
27
|
+
- `undici` >= 6.24.0
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`222259a`](https://github.com/commercetools/merchant-center-application-kit/commit/222259a810691eaf7904e89acddca444ac8bd0b6)]:
|
|
30
|
+
- @commercetools-frontend/application-config@27.5.3
|
|
31
|
+
|
|
32
|
+
## 27.5.2
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`241d4b2`](https://github.com/commercetools/merchant-center-application-kit/commit/241d4b2ee47dcea78b436111b3dbc76213dcafca)]:
|
|
37
|
+
- @commercetools-frontend/application-config@27.5.2
|
|
38
|
+
|
|
3
39
|
## 27.5.1
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
4
|
var commander = require('commander');
|
|
7
5
|
var listr2 = require('listr2');
|
|
@@ -38,7 +36,7 @@ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/string
|
|
|
38
36
|
var core = require('@babel/core');
|
|
39
37
|
var prettier = require('prettier');
|
|
40
38
|
|
|
41
|
-
function _interopDefault (e) { return e && e.__esModule ? e : {
|
|
39
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
42
40
|
|
|
43
41
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
44
42
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
@@ -71,46 +69,7 @@ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
|
71
69
|
var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
72
70
|
|
|
73
71
|
var pkgJson = {
|
|
74
|
-
|
|
75
|
-
version: "27.5.1",
|
|
76
|
-
description: "Create Merchant Center applications to quickly get up and running",
|
|
77
|
-
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
78
|
-
repository: {
|
|
79
|
-
type: "git",
|
|
80
|
-
url: "https://github.com/commercetools/merchant-center-application-kit.git",
|
|
81
|
-
directory: "packages/create-mc-app"
|
|
82
|
-
},
|
|
83
|
-
homepage: "https://docs.commercetools.com/merchant-center-customizations",
|
|
84
|
-
keywords: [
|
|
85
|
-
"javascript",
|
|
86
|
-
"frontend",
|
|
87
|
-
"react",
|
|
88
|
-
"toolkit"
|
|
89
|
-
],
|
|
90
|
-
license: "MIT",
|
|
91
|
-
publishConfig: {
|
|
92
|
-
access: "public"
|
|
93
|
-
},
|
|
94
|
-
main: "dist/commercetools-frontend-create-mc-app.cjs.js",
|
|
95
|
-
module: "dist/commercetools-frontend-create-mc-app.esm.js",
|
|
96
|
-
bin: "./bin/cli.js",
|
|
97
|
-
dependencies: {
|
|
98
|
-
"@babel/core": "^7.22.17",
|
|
99
|
-
"@babel/runtime": "^7.22.15",
|
|
100
|
-
"@babel/runtime-corejs3": "^7.22.15",
|
|
101
|
-
"@commercetools-frontend/application-config": "^27.5.1",
|
|
102
|
-
"@types/babel__core": "^7.20.1",
|
|
103
|
-
"@types/semver": "^7.5.1",
|
|
104
|
-
commander: "^13.1.0",
|
|
105
|
-
execa: "5.1.1",
|
|
106
|
-
listr2: "5.0.8",
|
|
107
|
-
prettier: "2.8.8",
|
|
108
|
-
semver: "7.7.2"
|
|
109
|
-
},
|
|
110
|
-
devDependencies: {
|
|
111
|
-
"@tsconfig/node22": "^22.0.0",
|
|
112
|
-
"@types/prettier": "2.7.3"
|
|
113
|
-
},
|
|
72
|
+
version: "27.5.3",
|
|
114
73
|
engines: {
|
|
115
74
|
node: "18.x || 20.x || >=22.0.0"
|
|
116
75
|
}
|
|
@@ -126,7 +85,7 @@ const availableTemplates = {
|
|
|
126
85
|
};
|
|
127
86
|
|
|
128
87
|
async function getLatestReleaseVersion() {
|
|
129
|
-
const commandResult = await execa__default
|
|
88
|
+
const commandResult = await execa__default.default.command('npm view @commercetools-frontend/create-mc-app --json', {
|
|
130
89
|
encoding: 'utf-8'
|
|
131
90
|
});
|
|
132
91
|
const packageInfoForTagLatest = JSON.parse(commandResult.stdout);
|
|
@@ -135,8 +94,8 @@ async function getLatestReleaseVersion() {
|
|
|
135
94
|
|
|
136
95
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
137
96
|
var _context;
|
|
138
|
-
const hasBeenReleastedInLatestTag = semver__default
|
|
139
|
-
const hintNewerVersions = _filterInstanceProperty__default
|
|
97
|
+
const hasBeenReleastedInLatestTag = semver__default.default.gt(releaseVersion, currentVersion);
|
|
98
|
+
const hintNewerVersions = _filterInstanceProperty__default.default(_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
140
99
|
if (hintNewerVersions.length > 0) {
|
|
141
100
|
console.log('');
|
|
142
101
|
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
@@ -147,7 +106,7 @@ function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
|
147
106
|
const isSemVer = version => /^(v?)([0-9].[0-9].[0-9])+/.test(version);
|
|
148
107
|
const doesFileExist = path => {
|
|
149
108
|
try {
|
|
150
|
-
fs__default
|
|
109
|
+
fs__default.default.accessSync(path);
|
|
151
110
|
return true;
|
|
152
111
|
} catch (error) {
|
|
153
112
|
return false;
|
|
@@ -155,7 +114,7 @@ const doesFileExist = path => {
|
|
|
155
114
|
};
|
|
156
115
|
const shouldUseYarn = () => {
|
|
157
116
|
try {
|
|
158
|
-
const result = execa__default
|
|
117
|
+
const result = execa__default.default.commandSync('yarn --version', {
|
|
159
118
|
stdio: 'ignore'
|
|
160
119
|
});
|
|
161
120
|
return !result.failed;
|
|
@@ -166,10 +125,10 @@ const shouldUseYarn = () => {
|
|
|
166
125
|
const getYarnVersion = () => {
|
|
167
126
|
try {
|
|
168
127
|
var _context;
|
|
169
|
-
const result = execa__default
|
|
128
|
+
const result = execa__default.default.commandSync('yarn --version', {
|
|
170
129
|
encoding: 'utf-8'
|
|
171
130
|
});
|
|
172
|
-
return _trimInstanceProperty__default
|
|
131
|
+
return _trimInstanceProperty__default.default(_context = result.stdout).call(_context);
|
|
173
132
|
} catch (error) {
|
|
174
133
|
return null;
|
|
175
134
|
}
|
|
@@ -179,14 +138,14 @@ const configureYarn = projectDirectoryPath => {
|
|
|
179
138
|
if (!yarnVersion) return;
|
|
180
139
|
|
|
181
140
|
// Check if Yarn version is 2 or higher. Plug'n'Play was introduced in Yarn v2
|
|
182
|
-
if (semver__default
|
|
141
|
+
if (semver__default.default.gte(yarnVersion, '2.0.0')) {
|
|
183
142
|
// Sanitize and resolve the path
|
|
184
|
-
const normalizedProjectPath = path__default
|
|
143
|
+
const normalizedProjectPath = path__default.default.resolve(projectDirectoryPath);
|
|
185
144
|
|
|
186
145
|
// Create .yarnrc.yml to use node_modules
|
|
187
|
-
const yarnrcPath = path__default
|
|
146
|
+
const yarnrcPath = path__default.default.join(normalizedProjectPath, '.yarnrc.yml');
|
|
188
147
|
const yarnrcContent = 'nodeLinker: "node-modules"';
|
|
189
|
-
fs__default
|
|
148
|
+
fs__default.default.writeFileSync(yarnrcPath, yarnrcContent);
|
|
190
149
|
}
|
|
191
150
|
};
|
|
192
151
|
const getPreferredPackageManager = options => {
|
|
@@ -210,14 +169,14 @@ const getInstallCommand = options => {
|
|
|
210
169
|
}
|
|
211
170
|
};
|
|
212
171
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
213
|
-
const upperFirst = value => value.charAt(0).toUpperCase() + _sliceInstanceProperty__default
|
|
172
|
+
const upperFirst = value => value.charAt(0).toUpperCase() + _sliceInstanceProperty__default.default(value).call(value, 1);
|
|
214
173
|
const wordify = slug => {
|
|
215
174
|
var _context2;
|
|
216
|
-
return _mapInstanceProperty__default
|
|
175
|
+
return _mapInstanceProperty__default.default(_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
217
176
|
};
|
|
218
177
|
const resolveFilePathByExtension = requestedModule => {
|
|
219
178
|
var _context3;
|
|
220
|
-
const fileExtension = _findInstanceProperty__default
|
|
179
|
+
const fileExtension = _findInstanceProperty__default.default(_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
221
180
|
const filePath = `${requestedModule}${ext}`;
|
|
222
181
|
return doesFileExist(filePath);
|
|
223
182
|
});
|
|
@@ -226,8 +185,8 @@ const resolveFilePathByExtension = requestedModule => {
|
|
|
226
185
|
|
|
227
186
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
228
187
|
var _context;
|
|
229
|
-
const applicationTypesList = _Object$keys__default
|
|
230
|
-
if (!_includesInstanceProperty__default
|
|
188
|
+
const applicationTypesList = _Object$keys__default.default(applicationTypes);
|
|
189
|
+
if (!_includesInstanceProperty__default.default(_context = _Object$values__default.default(applicationTypesList)).call(_context, applicationType)) {
|
|
231
190
|
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".`);
|
|
232
191
|
}
|
|
233
192
|
};
|
|
@@ -238,7 +197,7 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
238
197
|
break;
|
|
239
198
|
default:
|
|
240
199
|
{
|
|
241
|
-
const templateNamesList = _Object$keys__default
|
|
200
|
+
const templateNamesList = _Object$keys__default.default(availableTemplates).toString();
|
|
242
201
|
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".`);
|
|
243
202
|
}
|
|
244
203
|
}
|
|
@@ -255,7 +214,7 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
255
214
|
// In case the version is semver (usually release tags) we check that
|
|
256
215
|
// the cloned repository contains the template matching the given version
|
|
257
216
|
if (isSemVer(versionToCheck)) {
|
|
258
|
-
const templatePackageJson = JSON.parse(fs__default
|
|
217
|
+
const templatePackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(templateFolderPath, 'package.json'), {
|
|
259
218
|
encoding: 'utf8'
|
|
260
219
|
}));
|
|
261
220
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
@@ -270,19 +229,19 @@ const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
|
270
229
|
}
|
|
271
230
|
};
|
|
272
231
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
273
|
-
const hasValidNodeVersion = semver__default
|
|
232
|
+
const hasValidNodeVersion = semver__default.default.satisfies(currentNodeVersion, expectedVersionRange);
|
|
274
233
|
if (!hasValidNodeVersion) {
|
|
275
234
|
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
276
235
|
}
|
|
277
236
|
};
|
|
278
237
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
279
|
-
const allowedCloudIdentifiers = _Object$values__default
|
|
280
|
-
if (!_includesInstanceProperty__default
|
|
238
|
+
const allowedCloudIdentifiers = _Object$values__default.default(applicationConfig.CLOUD_IDENTIFIERS);
|
|
239
|
+
if (!_includesInstanceProperty__default.default(allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
281
240
|
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
282
241
|
}
|
|
283
242
|
};
|
|
284
243
|
|
|
285
|
-
const question = (rl, value) => new _Promise__default
|
|
244
|
+
const question = (rl, value) => new _Promise__default.default(resolve => rl.question(value, resolve));
|
|
286
245
|
const getEntryPointUriPath = async (rl, options) => {
|
|
287
246
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
288
247
|
return;
|
|
@@ -290,7 +249,7 @@ const getEntryPointUriPath = async (rl, options) => {
|
|
|
290
249
|
if (options.entryPointUriPath) {
|
|
291
250
|
return options.entryPointUriPath;
|
|
292
251
|
}
|
|
293
|
-
const randomEntryPointUriPath = `${options.template}-${crypto__default
|
|
252
|
+
const randomEntryPointUriPath = `${options.template}-${crypto__default.default.randomBytes(3).toString('hex')}`;
|
|
294
253
|
if (options.yes) {
|
|
295
254
|
return randomEntryPointUriPath;
|
|
296
255
|
}
|
|
@@ -324,11 +283,11 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
324
283
|
if (!projectDirectoryName) {
|
|
325
284
|
throw new Error('Missing required argument "[project-directory]"');
|
|
326
285
|
}
|
|
327
|
-
const projectDirectoryPath = path__default
|
|
286
|
+
const projectDirectoryPath = path__default.default.resolve(projectDirectoryName);
|
|
328
287
|
|
|
329
288
|
// Parse options
|
|
330
289
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
331
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default
|
|
290
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default.default(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
332
291
|
const templateName = options.template;
|
|
333
292
|
|
|
334
293
|
// Validate options
|
|
@@ -337,7 +296,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
337
296
|
throwIfTemplateIsNotSupported(templateName);
|
|
338
297
|
|
|
339
298
|
// Read prompts
|
|
340
|
-
const rl = readline__default
|
|
299
|
+
const rl = readline__default.default.createInterface({
|
|
341
300
|
input: process.stdin,
|
|
342
301
|
output: process.stdout
|
|
343
302
|
});
|
|
@@ -363,15 +322,15 @@ function downloadTemplate(options) {
|
|
|
363
322
|
return {
|
|
364
323
|
title: 'Downloading template',
|
|
365
324
|
task: () => {
|
|
366
|
-
const tmpDir = os__default
|
|
367
|
-
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default
|
|
368
|
-
const clonedRepositoryPath = path__default
|
|
369
|
-
const templateFolderPath = path__default
|
|
325
|
+
const tmpDir = os__default.default.tmpdir();
|
|
326
|
+
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default.default().toString()].join('');
|
|
327
|
+
const clonedRepositoryPath = path__default.default.join(tmpDir, tmpFolderNameForClonedRepository);
|
|
328
|
+
const templateFolderPath = path__default.default.join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
370
329
|
return new listr2.Listr([{
|
|
371
330
|
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
372
331
|
task: async () => {
|
|
373
332
|
// Shallow clone repository
|
|
374
|
-
const result = await execa__default
|
|
333
|
+
const result = await execa__default.default('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
375
334
|
cwd: tmpDir,
|
|
376
335
|
encoding: 'utf-8'
|
|
377
336
|
});
|
|
@@ -385,7 +344,7 @@ function downloadTemplate(options) {
|
|
|
385
344
|
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
386
345
|
task: async () => {
|
|
387
346
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
388
|
-
const result = await execa__default
|
|
347
|
+
const result = await execa__default.default(command, [templateFolderPath,
|
|
389
348
|
// Wrap folder path in quotes to avoid issues with empty spaces in the folder names.
|
|
390
349
|
options.projectDirectoryPath], {
|
|
391
350
|
encoding: 'utf-8'
|
|
@@ -393,7 +352,7 @@ function downloadTemplate(options) {
|
|
|
393
352
|
if (result.failed) {
|
|
394
353
|
throw new Error(result.stderr);
|
|
395
354
|
}
|
|
396
|
-
const templatePackageJsonPath = path__default
|
|
355
|
+
const templatePackageJsonPath = path__default.default.join(options.projectDirectoryPath, 'package.json');
|
|
397
356
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
398
357
|
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
399
358
|
}
|
|
@@ -403,7 +362,7 @@ function downloadTemplate(options) {
|
|
|
403
362
|
title: `Cleaning up project directory`,
|
|
404
363
|
task: async () => {
|
|
405
364
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
406
|
-
const result = await execa__default
|
|
365
|
+
const result = await execa__default.default(command, _mapInstanceProperty__default.default(filesToBeRemoved).call(filesToBeRemoved, filePath => path__default.default.join(options.projectDirectoryPath, filePath)), {
|
|
407
366
|
encoding: 'utf-8'
|
|
408
367
|
});
|
|
409
368
|
if (result.failed) {
|
|
@@ -430,7 +389,7 @@ function installDependencies(options) {
|
|
|
430
389
|
|
|
431
390
|
// TODO: we could check for min yarn/npm versions
|
|
432
391
|
// See https://github.com/facebook/create-react-app/blob/0f4781e8507249ce29a9ac1409fece67c1a53c38/packages/create-react-app/createReactApp.js#L225-L254
|
|
433
|
-
return execa__default
|
|
392
|
+
return execa__default.default.command(installCommand, {
|
|
434
393
|
cwd: options.projectDirectoryPath,
|
|
435
394
|
encoding: 'utf-8'
|
|
436
395
|
});
|
|
@@ -438,12 +397,12 @@ function installDependencies(options) {
|
|
|
438
397
|
};
|
|
439
398
|
}
|
|
440
399
|
|
|
441
|
-
function ownKeys(e, r) { var t = _Object$keys__default
|
|
442
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default
|
|
400
|
+
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; }
|
|
401
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default.default(_context2 = ownKeys(Object(t), true)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default.default ? _Object$defineProperties__default.default(e, _Object$getOwnPropertyDescriptors__default.default(t)) : _forEachInstanceProperty__default.default(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default.default(e, r, _Object$getOwnPropertyDescriptor__default.default(t, r)); }); } return e; }
|
|
443
402
|
const replaceApplicationKitPackageVersionWith = function (releaseVersion) {
|
|
444
403
|
var _context;
|
|
445
404
|
let dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
446
|
-
return _reduceInstanceProperty__default
|
|
405
|
+
return _reduceInstanceProperty__default.default(_context = _Object$entries__default.default(dependencies)).call(_context, (updatedDependencies, _ref) => {
|
|
447
406
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
448
407
|
dependencyName = _ref2[0],
|
|
449
408
|
dependencyVersion = _ref2[1];
|
|
@@ -457,12 +416,12 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
457
416
|
return {
|
|
458
417
|
title: 'Updating package.json',
|
|
459
418
|
task: () => {
|
|
460
|
-
const packageJsonPath = path__default
|
|
461
|
-
const appPackageJson = JSON.parse(fs__default
|
|
419
|
+
const packageJsonPath = path__default.default.join(options.projectDirectoryPath, 'package.json');
|
|
420
|
+
const appPackageJson = JSON.parse(fs__default.default.readFileSync(packageJsonPath, {
|
|
462
421
|
encoding: 'utf8'
|
|
463
422
|
}));
|
|
464
423
|
const packageManager = getPreferredPackageManager(options);
|
|
465
|
-
const updatedAppPackageJson = _Object$assign__default
|
|
424
|
+
const updatedAppPackageJson = _Object$assign__default.default({}, appPackageJson, {
|
|
466
425
|
version: '1.0.0',
|
|
467
426
|
// Given the package name is derived from the `projectDirectoryName`
|
|
468
427
|
// the latter needs to be sanitised to have a ensure a valid package name.
|
|
@@ -477,7 +436,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
477
436
|
'start:prod:local': appPackageJson.scripts['start:prod:local'].replace('yarn', packageManager)
|
|
478
437
|
})
|
|
479
438
|
});
|
|
480
|
-
fs__default
|
|
439
|
+
fs__default.default.writeFileSync(packageJsonPath, _JSON$stringify__default.default(updatedAppPackageJson, null, 2) + os__default.default.EOL, {
|
|
481
440
|
encoding: 'utf8'
|
|
482
441
|
});
|
|
483
442
|
}
|
|
@@ -523,9 +482,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
523
482
|
retainLines: true
|
|
524
483
|
});
|
|
525
484
|
if (result?.code) {
|
|
526
|
-
const prettierConfig = prettier__default
|
|
527
|
-
const formattedData = prettier__default
|
|
528
|
-
fs__default
|
|
485
|
+
const prettierConfig = prettier__default.default.resolveConfig.sync(options.projectDirectoryPath);
|
|
486
|
+
const formattedData = prettier__default.default.format(result.code + os__default.default.EOL, prettierConfig ?? undefined);
|
|
487
|
+
fs__default.default.writeFileSync(filePath, formattedData, {
|
|
529
488
|
encoding: 'utf8'
|
|
530
489
|
});
|
|
531
490
|
}
|
|
@@ -544,7 +503,7 @@ function updateApplicationConfig(options) {
|
|
|
544
503
|
return {
|
|
545
504
|
title: 'Updating application config file',
|
|
546
505
|
task: () => {
|
|
547
|
-
const configPath = resolveFilePathByExtension(path__default
|
|
506
|
+
const configPath = resolveFilePathByExtension(path__default.default.join(options.projectDirectoryPath, getApplicationConfigName(options)));
|
|
548
507
|
replaceApplicationInfoInApplicationConfig(configPath, options);
|
|
549
508
|
}
|
|
550
509
|
};
|
|
@@ -566,9 +525,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
566
525
|
retainLines: true
|
|
567
526
|
});
|
|
568
527
|
if (result?.code) {
|
|
569
|
-
const prettierConfig = prettier__default
|
|
570
|
-
const formattedData = prettier__default
|
|
571
|
-
fs__default
|
|
528
|
+
const prettierConfig = prettier__default.default.resolveConfig.sync(options.projectDirectoryPath);
|
|
529
|
+
const formattedData = prettier__default.default.format(result.code + os__default.default.EOL, prettierConfig ?? undefined);
|
|
530
|
+
fs__default.default.writeFileSync(filePath, formattedData, {
|
|
572
531
|
encoding: 'utf8'
|
|
573
532
|
});
|
|
574
533
|
}
|
|
@@ -578,7 +537,7 @@ function updateApplicationConstants(options) {
|
|
|
578
537
|
title: 'Updating application constants',
|
|
579
538
|
enabled: options.applicationType === applicationTypes['custom-application'],
|
|
580
539
|
task: () => {
|
|
581
|
-
const applicationConstantsPath = resolveFilePathByExtension(path__default
|
|
540
|
+
const applicationConstantsPath = resolveFilePathByExtension(path__default.default.join(options.projectDirectoryPath, 'src/constants'));
|
|
582
541
|
replaceEntryPointUriPathInConstants(applicationConstantsPath, options);
|
|
583
542
|
}
|
|
584
543
|
};
|
|
@@ -615,7 +574,7 @@ const run = () => {
|
|
|
615
574
|
const shouldInstallDependencies = !options.skipInstall ||
|
|
616
575
|
// TODO: remove once we manage to ensure the package manager is installed, for example via Corepack.
|
|
617
576
|
options.packageManager === 'pnpm';
|
|
618
|
-
const taskList = new listr2.Listr(_filterInstanceProperty__default
|
|
577
|
+
const taskList = new listr2.Listr(_filterInstanceProperty__default.default(_context = [downloadTemplate(taskOptions), updatePackageJson(taskOptions, releaseVersion), updateApplicationConfig(taskOptions), updateApplicationConstants(taskOptions), shouldInstallDependencies && installDependencies(taskOptions)]).call(_context, Boolean));
|
|
619
578
|
await taskList.run();
|
|
620
579
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
621
580
|
console.log('');
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
4
|
var commander = require('commander');
|
|
7
5
|
var listr2 = require('listr2');
|
|
@@ -38,7 +36,7 @@ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/string
|
|
|
38
36
|
var core = require('@babel/core');
|
|
39
37
|
var prettier = require('prettier');
|
|
40
38
|
|
|
41
|
-
function _interopDefault (e) { return e && e.__esModule ? e : {
|
|
39
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
42
40
|
|
|
43
41
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
44
42
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
@@ -71,46 +69,7 @@ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
|
71
69
|
var prettier__default = /*#__PURE__*/_interopDefault(prettier);
|
|
72
70
|
|
|
73
71
|
var pkgJson = {
|
|
74
|
-
|
|
75
|
-
version: "27.5.1",
|
|
76
|
-
description: "Create Merchant Center applications to quickly get up and running",
|
|
77
|
-
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
78
|
-
repository: {
|
|
79
|
-
type: "git",
|
|
80
|
-
url: "https://github.com/commercetools/merchant-center-application-kit.git",
|
|
81
|
-
directory: "packages/create-mc-app"
|
|
82
|
-
},
|
|
83
|
-
homepage: "https://docs.commercetools.com/merchant-center-customizations",
|
|
84
|
-
keywords: [
|
|
85
|
-
"javascript",
|
|
86
|
-
"frontend",
|
|
87
|
-
"react",
|
|
88
|
-
"toolkit"
|
|
89
|
-
],
|
|
90
|
-
license: "MIT",
|
|
91
|
-
publishConfig: {
|
|
92
|
-
access: "public"
|
|
93
|
-
},
|
|
94
|
-
main: "dist/commercetools-frontend-create-mc-app.cjs.js",
|
|
95
|
-
module: "dist/commercetools-frontend-create-mc-app.esm.js",
|
|
96
|
-
bin: "./bin/cli.js",
|
|
97
|
-
dependencies: {
|
|
98
|
-
"@babel/core": "^7.22.17",
|
|
99
|
-
"@babel/runtime": "^7.22.15",
|
|
100
|
-
"@babel/runtime-corejs3": "^7.22.15",
|
|
101
|
-
"@commercetools-frontend/application-config": "^27.5.1",
|
|
102
|
-
"@types/babel__core": "^7.20.1",
|
|
103
|
-
"@types/semver": "^7.5.1",
|
|
104
|
-
commander: "^13.1.0",
|
|
105
|
-
execa: "5.1.1",
|
|
106
|
-
listr2: "5.0.8",
|
|
107
|
-
prettier: "2.8.8",
|
|
108
|
-
semver: "7.7.2"
|
|
109
|
-
},
|
|
110
|
-
devDependencies: {
|
|
111
|
-
"@tsconfig/node22": "^22.0.0",
|
|
112
|
-
"@types/prettier": "2.7.3"
|
|
113
|
-
},
|
|
72
|
+
version: "27.5.3",
|
|
114
73
|
engines: {
|
|
115
74
|
node: "18.x || 20.x || >=22.0.0"
|
|
116
75
|
}
|
|
@@ -126,7 +85,7 @@ const availableTemplates = {
|
|
|
126
85
|
};
|
|
127
86
|
|
|
128
87
|
async function getLatestReleaseVersion() {
|
|
129
|
-
const commandResult = await execa__default
|
|
88
|
+
const commandResult = await execa__default.default.command('npm view @commercetools-frontend/create-mc-app --json', {
|
|
130
89
|
encoding: 'utf-8'
|
|
131
90
|
});
|
|
132
91
|
const packageInfoForTagLatest = JSON.parse(commandResult.stdout);
|
|
@@ -135,8 +94,8 @@ async function getLatestReleaseVersion() {
|
|
|
135
94
|
|
|
136
95
|
function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
137
96
|
var _context;
|
|
138
|
-
const hasBeenReleastedInLatestTag = semver__default
|
|
139
|
-
const hintNewerVersions = _filterInstanceProperty__default
|
|
97
|
+
const hasBeenReleastedInLatestTag = semver__default.default.gt(releaseVersion, currentVersion);
|
|
98
|
+
const hintNewerVersions = _filterInstanceProperty__default.default(_context = [hasBeenReleastedInLatestTag && `${releaseVersion}`]).call(_context, Boolean).join(', ');
|
|
140
99
|
if (hintNewerVersions.length > 0) {
|
|
141
100
|
console.log('');
|
|
142
101
|
console.log(`New version available! ${currentVersion} -> ${hintNewerVersions}`);
|
|
@@ -147,7 +106,7 @@ function hintOutdatedVersion(currentVersion, releaseVersion) {
|
|
|
147
106
|
const isSemVer = version => /^(v?)([0-9].[0-9].[0-9])+/.test(version);
|
|
148
107
|
const doesFileExist = path => {
|
|
149
108
|
try {
|
|
150
|
-
fs__default
|
|
109
|
+
fs__default.default.accessSync(path);
|
|
151
110
|
return true;
|
|
152
111
|
} catch (error) {
|
|
153
112
|
return false;
|
|
@@ -155,7 +114,7 @@ const doesFileExist = path => {
|
|
|
155
114
|
};
|
|
156
115
|
const shouldUseYarn = () => {
|
|
157
116
|
try {
|
|
158
|
-
const result = execa__default
|
|
117
|
+
const result = execa__default.default.commandSync('yarn --version', {
|
|
159
118
|
stdio: 'ignore'
|
|
160
119
|
});
|
|
161
120
|
return !result.failed;
|
|
@@ -166,10 +125,10 @@ const shouldUseYarn = () => {
|
|
|
166
125
|
const getYarnVersion = () => {
|
|
167
126
|
try {
|
|
168
127
|
var _context;
|
|
169
|
-
const result = execa__default
|
|
128
|
+
const result = execa__default.default.commandSync('yarn --version', {
|
|
170
129
|
encoding: 'utf-8'
|
|
171
130
|
});
|
|
172
|
-
return _trimInstanceProperty__default
|
|
131
|
+
return _trimInstanceProperty__default.default(_context = result.stdout).call(_context);
|
|
173
132
|
} catch (error) {
|
|
174
133
|
return null;
|
|
175
134
|
}
|
|
@@ -179,14 +138,14 @@ const configureYarn = projectDirectoryPath => {
|
|
|
179
138
|
if (!yarnVersion) return;
|
|
180
139
|
|
|
181
140
|
// Check if Yarn version is 2 or higher. Plug'n'Play was introduced in Yarn v2
|
|
182
|
-
if (semver__default
|
|
141
|
+
if (semver__default.default.gte(yarnVersion, '2.0.0')) {
|
|
183
142
|
// Sanitize and resolve the path
|
|
184
|
-
const normalizedProjectPath = path__default
|
|
143
|
+
const normalizedProjectPath = path__default.default.resolve(projectDirectoryPath);
|
|
185
144
|
|
|
186
145
|
// Create .yarnrc.yml to use node_modules
|
|
187
|
-
const yarnrcPath = path__default
|
|
146
|
+
const yarnrcPath = path__default.default.join(normalizedProjectPath, '.yarnrc.yml');
|
|
188
147
|
const yarnrcContent = 'nodeLinker: "node-modules"';
|
|
189
|
-
fs__default
|
|
148
|
+
fs__default.default.writeFileSync(yarnrcPath, yarnrcContent);
|
|
190
149
|
}
|
|
191
150
|
};
|
|
192
151
|
const getPreferredPackageManager = options => {
|
|
@@ -210,14 +169,14 @@ const getInstallCommand = options => {
|
|
|
210
169
|
}
|
|
211
170
|
};
|
|
212
171
|
const slugify = name => name.toLowerCase().replace(/_/gi, '-');
|
|
213
|
-
const upperFirst = value => value.charAt(0).toUpperCase() + _sliceInstanceProperty__default
|
|
172
|
+
const upperFirst = value => value.charAt(0).toUpperCase() + _sliceInstanceProperty__default.default(value).call(value, 1);
|
|
214
173
|
const wordify = slug => {
|
|
215
174
|
var _context2;
|
|
216
|
-
return _mapInstanceProperty__default
|
|
175
|
+
return _mapInstanceProperty__default.default(_context2 = slug.split('-')).call(_context2, word => upperFirst(word)).join(' ');
|
|
217
176
|
};
|
|
218
177
|
const resolveFilePathByExtension = requestedModule => {
|
|
219
178
|
var _context3;
|
|
220
|
-
const fileExtension = _findInstanceProperty__default
|
|
179
|
+
const fileExtension = _findInstanceProperty__default.default(_context3 = ['.js', '.ts', '.mjs', '.cjs']).call(_context3, ext => {
|
|
221
180
|
const filePath = `${requestedModule}${ext}`;
|
|
222
181
|
return doesFileExist(filePath);
|
|
223
182
|
});
|
|
@@ -226,8 +185,8 @@ const resolveFilePathByExtension = requestedModule => {
|
|
|
226
185
|
|
|
227
186
|
const throwIfApplicationTypeIsNotSupported = applicationType => {
|
|
228
187
|
var _context;
|
|
229
|
-
const applicationTypesList = _Object$keys__default
|
|
230
|
-
if (!_includesInstanceProperty__default
|
|
188
|
+
const applicationTypesList = _Object$keys__default.default(applicationTypes);
|
|
189
|
+
if (!_includesInstanceProperty__default.default(_context = _Object$values__default.default(applicationTypesList)).call(_context, applicationType)) {
|
|
231
190
|
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".`);
|
|
232
191
|
}
|
|
233
192
|
};
|
|
@@ -238,7 +197,7 @@ const throwIfTemplateIsNotSupported = templateName => {
|
|
|
238
197
|
break;
|
|
239
198
|
default:
|
|
240
199
|
{
|
|
241
|
-
const templateNamesList = _Object$keys__default
|
|
200
|
+
const templateNamesList = _Object$keys__default.default(availableTemplates).toString();
|
|
242
201
|
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".`);
|
|
243
202
|
}
|
|
244
203
|
}
|
|
@@ -255,7 +214,7 @@ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, ve
|
|
|
255
214
|
// In case the version is semver (usually release tags) we check that
|
|
256
215
|
// the cloned repository contains the template matching the given version
|
|
257
216
|
if (isSemVer(versionToCheck)) {
|
|
258
|
-
const templatePackageJson = JSON.parse(fs__default
|
|
217
|
+
const templatePackageJson = JSON.parse(fs__default.default.readFileSync(path__default.default.join(templateFolderPath, 'package.json'), {
|
|
259
218
|
encoding: 'utf8'
|
|
260
219
|
}));
|
|
261
220
|
const versionAsNumber = versionToCheck.replace('v', '');
|
|
@@ -270,19 +229,19 @@ const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
|
|
|
270
229
|
}
|
|
271
230
|
};
|
|
272
231
|
const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
|
|
273
|
-
const hasValidNodeVersion = semver__default
|
|
232
|
+
const hasValidNodeVersion = semver__default.default.satisfies(currentNodeVersion, expectedVersionRange);
|
|
274
233
|
if (!hasValidNodeVersion) {
|
|
275
234
|
throw new Error(`You are running Node ${currentNodeVersion} but create-mc-app requires Node ${expectedVersionRange}. Please update your version of Node.`);
|
|
276
235
|
}
|
|
277
236
|
};
|
|
278
237
|
const throwIfCloudIdentifierIsNotSupported = cloudIdentifier => {
|
|
279
|
-
const allowedCloudIdentifiers = _Object$values__default
|
|
280
|
-
if (!_includesInstanceProperty__default
|
|
238
|
+
const allowedCloudIdentifiers = _Object$values__default.default(applicationConfig.CLOUD_IDENTIFIERS);
|
|
239
|
+
if (!_includesInstanceProperty__default.default(allowedCloudIdentifiers).call(allowedCloudIdentifiers, cloudIdentifier)) {
|
|
281
240
|
throw new Error(`The cloud region "${cloudIdentifier}" is not supported. Supported regions are: ${allowedCloudIdentifiers.join(', ')}.`);
|
|
282
241
|
}
|
|
283
242
|
};
|
|
284
243
|
|
|
285
|
-
const question = (rl, value) => new _Promise__default
|
|
244
|
+
const question = (rl, value) => new _Promise__default.default(resolve => rl.question(value, resolve));
|
|
286
245
|
const getEntryPointUriPath = async (rl, options) => {
|
|
287
246
|
if (options.applicationType === applicationTypes['custom-view']) {
|
|
288
247
|
return;
|
|
@@ -290,7 +249,7 @@ const getEntryPointUriPath = async (rl, options) => {
|
|
|
290
249
|
if (options.entryPointUriPath) {
|
|
291
250
|
return options.entryPointUriPath;
|
|
292
251
|
}
|
|
293
|
-
const randomEntryPointUriPath = `${options.template}-${crypto__default
|
|
252
|
+
const randomEntryPointUriPath = `${options.template}-${crypto__default.default.randomBytes(3).toString('hex')}`;
|
|
294
253
|
if (options.yes) {
|
|
295
254
|
return randomEntryPointUriPath;
|
|
296
255
|
}
|
|
@@ -324,11 +283,11 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
324
283
|
if (!projectDirectoryName) {
|
|
325
284
|
throw new Error('Missing required argument "[project-directory]"');
|
|
326
285
|
}
|
|
327
|
-
const projectDirectoryPath = path__default
|
|
286
|
+
const projectDirectoryPath = path__default.default.resolve(projectDirectoryName);
|
|
328
287
|
|
|
329
288
|
// Parse options
|
|
330
289
|
let tagOrBranchVersion = options.templateVersion || 'main';
|
|
331
|
-
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default
|
|
290
|
+
tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default.default(tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? `v${tagOrBranchVersion}` : tagOrBranchVersion;
|
|
332
291
|
const templateName = options.template;
|
|
333
292
|
|
|
334
293
|
// Validate options
|
|
@@ -337,7 +296,7 @@ async function processOptions(projectDirectoryName, options) {
|
|
|
337
296
|
throwIfTemplateIsNotSupported(templateName);
|
|
338
297
|
|
|
339
298
|
// Read prompts
|
|
340
|
-
const rl = readline__default
|
|
299
|
+
const rl = readline__default.default.createInterface({
|
|
341
300
|
input: process.stdin,
|
|
342
301
|
output: process.stdout
|
|
343
302
|
});
|
|
@@ -363,15 +322,15 @@ function downloadTemplate(options) {
|
|
|
363
322
|
return {
|
|
364
323
|
title: 'Downloading template',
|
|
365
324
|
task: () => {
|
|
366
|
-
const tmpDir = os__default
|
|
367
|
-
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default
|
|
368
|
-
const clonedRepositoryPath = path__default
|
|
369
|
-
const templateFolderPath = path__default
|
|
325
|
+
const tmpDir = os__default.default.tmpdir();
|
|
326
|
+
const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default.default().toString()].join('');
|
|
327
|
+
const clonedRepositoryPath = path__default.default.join(tmpDir, tmpFolderNameForClonedRepository);
|
|
328
|
+
const templateFolderPath = path__default.default.join(clonedRepositoryPath, options.applicationType === applicationTypes['custom-view'] ? 'custom-views-templates' : 'application-templates', options.templateName);
|
|
370
329
|
return new listr2.Listr([{
|
|
371
330
|
title: `Cloning repository using branch ${options.tagOrBranchVersion}`,
|
|
372
331
|
task: async () => {
|
|
373
332
|
// Shallow clone repository
|
|
374
|
-
const result = await execa__default
|
|
333
|
+
const result = await execa__default.default('git', ['clone', `--branch=${options.tagOrBranchVersion}`, '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
|
|
375
334
|
cwd: tmpDir,
|
|
376
335
|
encoding: 'utf-8'
|
|
377
336
|
});
|
|
@@ -385,7 +344,7 @@ function downloadTemplate(options) {
|
|
|
385
344
|
title: `Copying template ${options.templateName} into project directory ${options.projectDirectoryPath}`,
|
|
386
345
|
task: async () => {
|
|
387
346
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
|
|
388
|
-
const result = await execa__default
|
|
347
|
+
const result = await execa__default.default(command, [templateFolderPath,
|
|
389
348
|
// Wrap folder path in quotes to avoid issues with empty spaces in the folder names.
|
|
390
349
|
options.projectDirectoryPath], {
|
|
391
350
|
encoding: 'utf-8'
|
|
@@ -393,7 +352,7 @@ function downloadTemplate(options) {
|
|
|
393
352
|
if (result.failed) {
|
|
394
353
|
throw new Error(result.stderr);
|
|
395
354
|
}
|
|
396
|
-
const templatePackageJsonPath = path__default
|
|
355
|
+
const templatePackageJsonPath = path__default.default.join(options.projectDirectoryPath, 'package.json');
|
|
397
356
|
if (!doesFileExist(templatePackageJsonPath)) {
|
|
398
357
|
throw new Error(`Unable to verify that the template application has a package.json at "${templatePackageJsonPath}"`);
|
|
399
358
|
}
|
|
@@ -403,7 +362,7 @@ function downloadTemplate(options) {
|
|
|
403
362
|
title: `Cleaning up project directory`,
|
|
404
363
|
task: async () => {
|
|
405
364
|
const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
|
|
406
|
-
const result = await execa__default
|
|
365
|
+
const result = await execa__default.default(command, _mapInstanceProperty__default.default(filesToBeRemoved).call(filesToBeRemoved, filePath => path__default.default.join(options.projectDirectoryPath, filePath)), {
|
|
407
366
|
encoding: 'utf-8'
|
|
408
367
|
});
|
|
409
368
|
if (result.failed) {
|
|
@@ -430,7 +389,7 @@ function installDependencies(options) {
|
|
|
430
389
|
|
|
431
390
|
// TODO: we could check for min yarn/npm versions
|
|
432
391
|
// See https://github.com/facebook/create-react-app/blob/0f4781e8507249ce29a9ac1409fece67c1a53c38/packages/create-react-app/createReactApp.js#L225-L254
|
|
433
|
-
return execa__default
|
|
392
|
+
return execa__default.default.command(installCommand, {
|
|
434
393
|
cwd: options.projectDirectoryPath,
|
|
435
394
|
encoding: 'utf-8'
|
|
436
395
|
});
|
|
@@ -438,12 +397,12 @@ function installDependencies(options) {
|
|
|
438
397
|
};
|
|
439
398
|
}
|
|
440
399
|
|
|
441
|
-
function ownKeys(e, r) { var t = _Object$keys__default
|
|
442
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default
|
|
400
|
+
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; }
|
|
401
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default.default(_context2 = ownKeys(Object(t), true)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default.default ? _Object$defineProperties__default.default(e, _Object$getOwnPropertyDescriptors__default.default(t)) : _forEachInstanceProperty__default.default(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default.default(e, r, _Object$getOwnPropertyDescriptor__default.default(t, r)); }); } return e; }
|
|
443
402
|
const replaceApplicationKitPackageVersionWith = function (releaseVersion) {
|
|
444
403
|
var _context;
|
|
445
404
|
let dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
446
|
-
return _reduceInstanceProperty__default
|
|
405
|
+
return _reduceInstanceProperty__default.default(_context = _Object$entries__default.default(dependencies)).call(_context, (updatedDependencies, _ref) => {
|
|
447
406
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
448
407
|
dependencyName = _ref2[0],
|
|
449
408
|
dependencyVersion = _ref2[1];
|
|
@@ -457,12 +416,12 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
457
416
|
return {
|
|
458
417
|
title: 'Updating package.json',
|
|
459
418
|
task: () => {
|
|
460
|
-
const packageJsonPath = path__default
|
|
461
|
-
const appPackageJson = JSON.parse(fs__default
|
|
419
|
+
const packageJsonPath = path__default.default.join(options.projectDirectoryPath, 'package.json');
|
|
420
|
+
const appPackageJson = JSON.parse(fs__default.default.readFileSync(packageJsonPath, {
|
|
462
421
|
encoding: 'utf8'
|
|
463
422
|
}));
|
|
464
423
|
const packageManager = getPreferredPackageManager(options);
|
|
465
|
-
const updatedAppPackageJson = _Object$assign__default
|
|
424
|
+
const updatedAppPackageJson = _Object$assign__default.default({}, appPackageJson, {
|
|
466
425
|
version: '1.0.0',
|
|
467
426
|
// Given the package name is derived from the `projectDirectoryName`
|
|
468
427
|
// the latter needs to be sanitised to have a ensure a valid package name.
|
|
@@ -477,7 +436,7 @@ function updatePackageJson(options, releaseVersion) {
|
|
|
477
436
|
'start:prod:local': appPackageJson.scripts['start:prod:local'].replace('yarn', packageManager)
|
|
478
437
|
})
|
|
479
438
|
});
|
|
480
|
-
fs__default
|
|
439
|
+
fs__default.default.writeFileSync(packageJsonPath, _JSON$stringify__default.default(updatedAppPackageJson, null, 2) + os__default.default.EOL, {
|
|
481
440
|
encoding: 'utf8'
|
|
482
441
|
});
|
|
483
442
|
}
|
|
@@ -523,9 +482,9 @@ function replaceApplicationInfoInApplicationConfig(filePath, options) {
|
|
|
523
482
|
retainLines: true
|
|
524
483
|
});
|
|
525
484
|
if (result?.code) {
|
|
526
|
-
const prettierConfig = prettier__default
|
|
527
|
-
const formattedData = prettier__default
|
|
528
|
-
fs__default
|
|
485
|
+
const prettierConfig = prettier__default.default.resolveConfig.sync(options.projectDirectoryPath);
|
|
486
|
+
const formattedData = prettier__default.default.format(result.code + os__default.default.EOL, prettierConfig ?? undefined);
|
|
487
|
+
fs__default.default.writeFileSync(filePath, formattedData, {
|
|
529
488
|
encoding: 'utf8'
|
|
530
489
|
});
|
|
531
490
|
}
|
|
@@ -544,7 +503,7 @@ function updateApplicationConfig(options) {
|
|
|
544
503
|
return {
|
|
545
504
|
title: 'Updating application config file',
|
|
546
505
|
task: () => {
|
|
547
|
-
const configPath = resolveFilePathByExtension(path__default
|
|
506
|
+
const configPath = resolveFilePathByExtension(path__default.default.join(options.projectDirectoryPath, getApplicationConfigName(options)));
|
|
548
507
|
replaceApplicationInfoInApplicationConfig(configPath, options);
|
|
549
508
|
}
|
|
550
509
|
};
|
|
@@ -566,9 +525,9 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
|
|
|
566
525
|
retainLines: true
|
|
567
526
|
});
|
|
568
527
|
if (result?.code) {
|
|
569
|
-
const prettierConfig = prettier__default
|
|
570
|
-
const formattedData = prettier__default
|
|
571
|
-
fs__default
|
|
528
|
+
const prettierConfig = prettier__default.default.resolveConfig.sync(options.projectDirectoryPath);
|
|
529
|
+
const formattedData = prettier__default.default.format(result.code + os__default.default.EOL, prettierConfig ?? undefined);
|
|
530
|
+
fs__default.default.writeFileSync(filePath, formattedData, {
|
|
572
531
|
encoding: 'utf8'
|
|
573
532
|
});
|
|
574
533
|
}
|
|
@@ -578,7 +537,7 @@ function updateApplicationConstants(options) {
|
|
|
578
537
|
title: 'Updating application constants',
|
|
579
538
|
enabled: options.applicationType === applicationTypes['custom-application'],
|
|
580
539
|
task: () => {
|
|
581
|
-
const applicationConstantsPath = resolveFilePathByExtension(path__default
|
|
540
|
+
const applicationConstantsPath = resolveFilePathByExtension(path__default.default.join(options.projectDirectoryPath, 'src/constants'));
|
|
582
541
|
replaceEntryPointUriPathInConstants(applicationConstantsPath, options);
|
|
583
542
|
}
|
|
584
543
|
};
|
|
@@ -615,7 +574,7 @@ const run = () => {
|
|
|
615
574
|
const shouldInstallDependencies = !options.skipInstall ||
|
|
616
575
|
// TODO: remove once we manage to ensure the package manager is installed, for example via Corepack.
|
|
617
576
|
options.packageManager === 'pnpm';
|
|
618
|
-
const taskList = new listr2.Listr(_filterInstanceProperty__default
|
|
577
|
+
const taskList = new listr2.Listr(_filterInstanceProperty__default.default(_context = [downloadTemplate(taskOptions), updatePackageJson(taskOptions, releaseVersion), updateApplicationConfig(taskOptions), updateApplicationConstants(taskOptions), shouldInstallDependencies && installDependencies(taskOptions)]).call(_context, Boolean));
|
|
619
578
|
await taskList.run();
|
|
620
579
|
const packageManager = getPreferredPackageManager(taskOptions);
|
|
621
580
|
console.log('');
|
|
@@ -35,46 +35,7 @@ import { transformFileSync, types } from '@babel/core';
|
|
|
35
35
|
import prettier from 'prettier';
|
|
36
36
|
|
|
37
37
|
var pkgJson = {
|
|
38
|
-
|
|
39
|
-
version: "27.5.1",
|
|
40
|
-
description: "Create Merchant Center applications to quickly get up and running",
|
|
41
|
-
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
42
|
-
repository: {
|
|
43
|
-
type: "git",
|
|
44
|
-
url: "https://github.com/commercetools/merchant-center-application-kit.git",
|
|
45
|
-
directory: "packages/create-mc-app"
|
|
46
|
-
},
|
|
47
|
-
homepage: "https://docs.commercetools.com/merchant-center-customizations",
|
|
48
|
-
keywords: [
|
|
49
|
-
"javascript",
|
|
50
|
-
"frontend",
|
|
51
|
-
"react",
|
|
52
|
-
"toolkit"
|
|
53
|
-
],
|
|
54
|
-
license: "MIT",
|
|
55
|
-
publishConfig: {
|
|
56
|
-
access: "public"
|
|
57
|
-
},
|
|
58
|
-
main: "dist/commercetools-frontend-create-mc-app.cjs.js",
|
|
59
|
-
module: "dist/commercetools-frontend-create-mc-app.esm.js",
|
|
60
|
-
bin: "./bin/cli.js",
|
|
61
|
-
dependencies: {
|
|
62
|
-
"@babel/core": "^7.22.17",
|
|
63
|
-
"@babel/runtime": "^7.22.15",
|
|
64
|
-
"@babel/runtime-corejs3": "^7.22.15",
|
|
65
|
-
"@commercetools-frontend/application-config": "^27.5.1",
|
|
66
|
-
"@types/babel__core": "^7.20.1",
|
|
67
|
-
"@types/semver": "^7.5.1",
|
|
68
|
-
commander: "^13.1.0",
|
|
69
|
-
execa: "5.1.1",
|
|
70
|
-
listr2: "5.0.8",
|
|
71
|
-
prettier: "2.8.8",
|
|
72
|
-
semver: "7.7.2"
|
|
73
|
-
},
|
|
74
|
-
devDependencies: {
|
|
75
|
-
"@tsconfig/node22": "^22.0.0",
|
|
76
|
-
"@types/prettier": "2.7.3"
|
|
77
|
-
},
|
|
38
|
+
version: "27.5.3",
|
|
78
39
|
engines: {
|
|
79
40
|
node: "18.x || 20.x || >=22.0.0"
|
|
80
41
|
}
|
|
@@ -403,7 +364,7 @@ function installDependencies(options) {
|
|
|
403
364
|
}
|
|
404
365
|
|
|
405
366
|
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; }
|
|
406
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t),
|
|
367
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), true)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
407
368
|
const replaceApplicationKitPackageVersionWith = function (releaseVersion) {
|
|
408
369
|
var _context;
|
|
409
370
|
let dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/create-mc-app",
|
|
3
|
-
"version": "27.5.
|
|
3
|
+
"version": "27.5.3",
|
|
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": "^27.5.
|
|
29
|
+
"@commercetools-frontend/application-config": "^27.5.3",
|
|
30
30
|
"@types/babel__core": "^7.20.1",
|
|
31
31
|
"@types/semver": "^7.5.1",
|
|
32
32
|
"commander": "^13.1.0",
|