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