@commercetools-frontend/create-mc-app 21.23.10 → 21.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,22 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
6
- var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
7
5
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
6
  var cac = require('cac');
9
7
  var listr2 = require('listr2');
10
- var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
11
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
12
- var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
13
- var fs = require('fs');
14
- var os = require('os');
15
- var path = require('path');
16
8
  var execa = require('execa');
17
- var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
9
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
18
10
  var semver = require('semver');
11
+ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
12
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
13
+ var crypto = require('crypto');
14
+ var path = require('path');
15
+ var readline = require('readline');
19
16
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
17
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
20
18
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
19
+ var fs = require('fs');
20
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
21
+ var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
22
+ var os = require('os');
21
23
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
22
24
  var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
23
25
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
@@ -30,28 +32,27 @@ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
30
32
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
31
33
  var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
32
34
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
33
- var prettier = require('prettier');
34
35
  var core = require('@babel/core');
35
- var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
36
- var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
37
- var readline = require('readline');
38
- var crypto = require('crypto');
36
+ var prettier = require('prettier');
39
37
 
40
38
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
41
39
 
42
- var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
43
40
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
44
- var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
45
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
46
- var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
47
- var fs__default = /*#__PURE__*/_interopDefault(fs);
48
- var os__default = /*#__PURE__*/_interopDefault(os);
49
- var path__default = /*#__PURE__*/_interopDefault(path);
50
41
  var execa__default = /*#__PURE__*/_interopDefault(execa);
51
- var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
42
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
52
43
  var semver__default = /*#__PURE__*/_interopDefault(semver);
44
+ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
45
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
46
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
47
+ var path__default = /*#__PURE__*/_interopDefault(path);
48
+ var readline__default = /*#__PURE__*/_interopDefault(readline);
53
49
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
50
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
54
51
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
52
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
53
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
54
+ var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
55
+ var os__default = /*#__PURE__*/_interopDefault(os);
55
56
  var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
56
57
  var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
57
58
  var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
@@ -63,18 +64,75 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
63
64
  var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
64
65
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
65
66
  var prettier__default = /*#__PURE__*/_interopDefault(prettier);
66
- var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
67
- var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
68
- var readline__default = /*#__PURE__*/_interopDefault(readline);
69
- var crypto__default = /*#__PURE__*/_interopDefault(crypto);
70
67
 
71
- var isSemVer = function isSemVer(version) {
72
- return /^(v?)([0-9].[0-9].[0-9])+/.test(version);
68
+ var pkgJson = {
69
+ name: "@commercetools-frontend/create-mc-app",
70
+ version: "21.24.0",
71
+ description: "Create Merchant Center applications to quickly get up and running",
72
+ bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
73
+ repository: {
74
+ type: "git",
75
+ url: "https://github.com/commercetools/merchant-center-application-kit.git",
76
+ directory: "packages/create-mc-app"
77
+ },
78
+ homepage: "https://docs.commercetools.com/custom-applications",
79
+ keywords: [
80
+ "javascript",
81
+ "frontend",
82
+ "react",
83
+ "toolkit"
84
+ ],
85
+ license: "MIT",
86
+ publishConfig: {
87
+ access: "public"
88
+ },
89
+ main: "dist/commercetools-frontend-create-mc-app.cjs.js",
90
+ module: "dist/commercetools-frontend-create-mc-app.esm.js",
91
+ bin: "./bin/cli.js",
92
+ dependencies: {
93
+ "@babel/core": "^7.20.12",
94
+ "@babel/runtime": "^7.20.13",
95
+ "@babel/runtime-corejs3": "^7.20.13",
96
+ cac: "6.7.14",
97
+ execa: "5.1.1",
98
+ listr2: "5.0.8",
99
+ prettier: "2.8.4",
100
+ semver: "7.3.8"
101
+ },
102
+ engines: {
103
+ node: "14.x || >=16.0.0"
104
+ }
73
105
  };
74
106
 
75
- var shouldUseYarn = function shouldUseYarn() {
107
+ async function getLatestReleaseVersion() {
108
+ const commandResult = await execa__default["default"].command('npm view @commercetools-frontend/create-mc-app --json', {
109
+ encoding: 'utf-8'
110
+ });
111
+ const packageInfoForTagLatest = JSON.parse(commandResult.stdout);
112
+ return packageInfoForTagLatest.version;
113
+ }
114
+
115
+ function hintOutdatedVersion(currentVersion, releaseVersion) {
116
+ var _context;
117
+
118
+ const hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
119
+
120
+ const hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && "".concat(releaseVersion)]).call(_context, Boolean).join(', ');
121
+
122
+ if (hintNewerVersions.length > 0) {
123
+ var _context2;
124
+
125
+ console.log('');
126
+ console.log(_concatInstanceProperty__default["default"](_context2 = "New version available! ".concat(currentVersion, " -> ")).call(_context2, hintNewerVersions));
127
+ console.log('');
128
+ }
129
+ }
130
+
131
+ const isSemVer = version => /^(v?)([0-9].[0-9].[0-9])+/.test(version);
132
+
133
+ const shouldUseYarn = () => {
76
134
  try {
77
- var result = execa__default["default"].commandSync('yarn --version', {
135
+ const result = execa__default["default"].commandSync('yarn --version', {
78
136
  stdio: 'ignore'
79
137
  });
80
138
  return !result.failed;
@@ -83,29 +141,23 @@ var shouldUseYarn = function shouldUseYarn() {
83
141
  }
84
142
  };
85
143
 
86
- var slugify = function slugify(name) {
87
- return name.toLowerCase().replace(/_/gi, '-');
88
- };
144
+ const slugify = name => name.toLowerCase().replace(/_/gi, '-');
89
145
 
90
- var upperFirst = function upperFirst(value) {
91
- return value.charAt(0).toUpperCase() + _sliceInstanceProperty__default["default"](value).call(value, 1);
92
- };
146
+ const upperFirst = value => value.charAt(0).toUpperCase() + _sliceInstanceProperty__default["default"](value).call(value, 1);
93
147
 
94
- var wordify = function wordify(slug) {
148
+ const wordify = slug => {
95
149
  var _context;
96
150
 
97
- return _mapInstanceProperty__default["default"](_context = slug.split('-')).call(_context, function (word) {
98
- return upperFirst(word);
99
- }).join(' ');
151
+ return _mapInstanceProperty__default["default"](_context = slug.split('-')).call(_context, word => upperFirst(word)).join(' ');
100
152
  };
101
153
 
102
- var resolveFilePathByExtension = function resolveFilePathByExtension(requestedModule) {
154
+ const resolveFilePathByExtension = requestedModule => {
103
155
  var _context2, _context4;
104
156
 
105
- var fileExtension = _findInstanceProperty__default["default"](_context2 = ['.js', '.ts', '.mjs', '.cjs']).call(_context2, function (ext) {
157
+ const fileExtension = _findInstanceProperty__default["default"](_context2 = ['.js', '.ts', '.mjs', '.cjs']).call(_context2, ext => {
106
158
  var _context3;
107
159
 
108
- var filePath = _concatInstanceProperty__default["default"](_context3 = "".concat(requestedModule)).call(_context3, ext);
160
+ const filePath = _concatInstanceProperty__default["default"](_context3 = "".concat(requestedModule)).call(_context3, ext);
109
161
 
110
162
  return fs__default["default"].existsSync(filePath);
111
163
  });
@@ -113,12 +165,12 @@ var resolveFilePathByExtension = function resolveFilePathByExtension(requestedMo
113
165
  return _concatInstanceProperty__default["default"](_context4 = "".concat(requestedModule)).call(_context4, fileExtension);
114
166
  };
115
167
 
116
- var availableTemplates = {
168
+ const availableTemplates = {
117
169
  starter: 'starter',
118
170
  'starter-typescript': 'starter-typescript'
119
171
  };
120
172
 
121
- var throwIfTemplateIsNotSupported = function throwIfTemplateIsNotSupported(templateName) {
173
+ const throwIfTemplateIsNotSupported = templateName => {
122
174
  var _context;
123
175
 
124
176
  switch (templateName) {
@@ -127,13 +179,13 @@ var throwIfTemplateIsNotSupported = function throwIfTemplateIsNotSupported(templ
127
179
  break;
128
180
 
129
181
  default:
130
- var templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
182
+ const templateNamesList = _Object$keys__default["default"](availableTemplates).toString();
131
183
 
132
184
  throw new Error(_concatInstanceProperty__default["default"](_context = "The provided template name \"".concat(templateName, "\" does not exist. Available templates are \"")).call(_context, templateNamesList, "\". Make sure you are also using the latest version of \"@commercetools-frontend/create-mc-app\"."));
133
185
  }
134
186
  };
135
187
 
136
- var throwIfProjectDirectoryExists = function throwIfProjectDirectoryExists(dirName, dirPath) {
188
+ const throwIfProjectDirectoryExists = (dirName, dirPath) => {
137
189
  if (fs__default["default"].existsSync(dirPath)) {
138
190
  var _context2;
139
191
 
@@ -141,7 +193,7 @@ var throwIfProjectDirectoryExists = function throwIfProjectDirectoryExists(dirNa
141
193
  }
142
194
  };
143
195
 
144
- var throwIfTemplateVersionDoesNotExist = function throwIfTemplateVersionDoesNotExist(templateName, templateFolderPath, versionToCheck) {
196
+ const throwIfTemplateVersionDoesNotExist = (templateName, templateFolderPath, versionToCheck) => {
145
197
  if (!fs__default["default"].existsSync(templateFolderPath)) {
146
198
  var _context3;
147
199
 
@@ -151,10 +203,10 @@ var throwIfTemplateVersionDoesNotExist = function throwIfTemplateVersionDoesNotE
151
203
 
152
204
 
153
205
  if (isSemVer(versionToCheck)) {
154
- var templatePackageJson = JSON.parse(fs__default["default"].readFileSync(path__default["default"].join(templateFolderPath, 'package.json'), {
206
+ const templatePackageJson = JSON.parse(fs__default["default"].readFileSync(path__default["default"].join(templateFolderPath, 'package.json'), {
155
207
  encoding: 'utf8'
156
208
  }));
157
- var versionAsNumber = versionToCheck.replace('v', '');
209
+ const versionAsNumber = versionToCheck.replace('v', '');
158
210
 
159
211
  if (templatePackageJson.version !== versionAsNumber) {
160
212
  var _context4, _context5;
@@ -164,14 +216,14 @@ var throwIfTemplateVersionDoesNotExist = function throwIfTemplateVersionDoesNotE
164
216
  }
165
217
  };
166
218
 
167
- var throwIfInitialProjectKeyIsMissing = function throwIfInitialProjectKeyIsMissing(initialProjectKey) {
219
+ const throwIfInitialProjectKeyIsMissing = initialProjectKey => {
168
220
  if (!initialProjectKey) {
169
221
  throw new Error("Provide a valid project key that you have access to.");
170
222
  }
171
223
  };
172
224
 
173
- var throwIfNodeVersionIsNotSupported = function throwIfNodeVersionIsNotSupported(currentNodeVersion, expectedVersionRange) {
174
- var hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
225
+ const throwIfNodeVersionIsNotSupported = (currentNodeVersion, expectedVersionRange) => {
226
+ const hasValidNodeVersion = semver__default["default"].satisfies(currentNodeVersion, expectedVersionRange);
175
227
 
176
228
  if (!hasValidNodeVersion) {
177
229
  var _context6;
@@ -180,158 +232,129 @@ var throwIfNodeVersionIsNotSupported = function throwIfNodeVersionIsNotSupported
180
232
  }
181
233
  };
182
234
 
183
- var filesToBeRemoved = ['CHANGELOG.md'];
235
+ const question = (rl, value) => new _Promise__default["default"](resolve => rl.question(value, resolve));
236
+
237
+ const getEntryPointUriPath = async (rl, options) => {
238
+ var _context;
239
+
240
+ if (options.entryPointUriPath) {
241
+ return options.entryPointUriPath;
242
+ }
243
+
244
+ const randomEntryPointUriPath = _concatInstanceProperty__default["default"](_context = "".concat(options.template, "-")).call(_context, crypto__default["default"].randomBytes(3).toString('hex'));
245
+
246
+ if (options.yes) {
247
+ return randomEntryPointUriPath;
248
+ }
249
+
250
+ const answerEntryPointUriPath = await question(rl, "Provide the Custom Application entryPointUriPath (default \"".concat(randomEntryPointUriPath, "\"): "));
251
+ return answerEntryPointUriPath || randomEntryPointUriPath;
252
+ };
253
+
254
+ const getInitialProjectKey = async (rl, options) => {
255
+ if (options.initialProjectKey) {
256
+ return options.initialProjectKey;
257
+ }
258
+
259
+ const initialProjectKey = await question(rl, "Provide the initial project key for local development: ");
260
+ throwIfInitialProjectKeyIsMissing(initialProjectKey);
261
+ return initialProjectKey;
262
+ };
263
+
264
+ async function processOptions(projectDirectoryName, options) {
265
+ if (!projectDirectoryName) {
266
+ throw new Error('Missing required argument "[project-directory]"');
267
+ }
268
+
269
+ const projectDirectoryPath = path__default["default"].resolve(projectDirectoryName); // Parse options
270
+
271
+ let tagOrBranchVersion = options.templateVersion || 'main';
272
+ tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? "v".concat(tagOrBranchVersion) : tagOrBranchVersion;
273
+ const templateName = options.template; // Validate options
274
+
275
+ throwIfProjectDirectoryExists(projectDirectoryName, projectDirectoryPath);
276
+ throwIfTemplateIsNotSupported(templateName); // Read prompts
277
+
278
+ const rl = readline__default["default"].createInterface({
279
+ input: process.stdin,
280
+ output: process.stdout
281
+ });
282
+ const entryPointUriPath = await getEntryPointUriPath(rl, options);
283
+ const initialProjectKey = await getInitialProjectKey(rl, options);
284
+ rl.close();
285
+ return {
286
+ projectDirectoryName,
287
+ projectDirectoryPath,
288
+ templateName,
289
+ tagOrBranchVersion,
290
+ entryPointUriPath,
291
+ initialProjectKey
292
+ };
293
+ }
294
+
295
+ const filesToBeRemoved = ['CHANGELOG.md'];
184
296
 
185
297
  function downloadTemplate(options) {
186
298
  return {
187
299
  title: 'Downloading template',
188
- task: function task() {
189
- var _context2;
300
+ task: () => {
301
+ var _context;
190
302
 
191
- var tmpDir = os__default["default"].tmpdir();
192
- var tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default["default"]().toString()].join('');
193
- var clonedRepositoryPath = path__default["default"].join(tmpDir, tmpFolderNameForClonedRepository);
194
- var templateFolderPath = path__default["default"].join(clonedRepositoryPath, 'application-templates', options.templateName);
303
+ const tmpDir = os__default["default"].tmpdir();
304
+ const tmpFolderNameForClonedRepository = ['merchant-center-application-kit', '--', options.tagOrBranchVersion, '--', _Date$now__default["default"]().toString()].join('');
305
+ const clonedRepositoryPath = path__default["default"].join(tmpDir, tmpFolderNameForClonedRepository);
306
+ const templateFolderPath = path__default["default"].join(clonedRepositoryPath, 'application-templates', options.templateName);
195
307
  return new listr2.Listr([{
196
308
  title: "Cloning repository using branch ".concat(options.tagOrBranchVersion),
197
- task: function () {
198
- var _task = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
199
- var result;
200
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
201
- while (1) {
202
- switch (_context.prev = _context.next) {
203
- case 0:
204
- _context.next = 2;
205
- return execa__default["default"]('git', ['clone', "--branch=".concat(options.tagOrBranchVersion), '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
206
- cwd: tmpDir,
207
- encoding: 'utf-8'
208
- });
209
-
210
- case 2:
211
- result = _context.sent;
212
-
213
- if (!result.failed) {
214
- _context.next = 5;
215
- break;
216
- }
217
-
218
- throw new Error(result.stderr);
219
-
220
- case 5:
221
- throwIfTemplateVersionDoesNotExist(options.templateName, clonedRepositoryPath, options.tagOrBranchVersion);
222
- return _context.abrupt("return", result.stdout);
223
-
224
- case 7:
225
- case "end":
226
- return _context.stop();
227
- }
228
- }
229
- }, _callee);
230
- }));
231
-
232
- function task() {
233
- return _task.apply(this, arguments);
309
+ task: async () => {
310
+ // Shallow clone repository
311
+ const result = await execa__default["default"]('git', ['clone', "--branch=".concat(options.tagOrBranchVersion), '--depth=1', 'https://github.com/commercetools/merchant-center-application-kit.git', tmpFolderNameForClonedRepository], {
312
+ cwd: tmpDir,
313
+ encoding: 'utf-8'
314
+ });
315
+
316
+ if (result.failed) {
317
+ throw new Error(result.stderr);
234
318
  }
235
319
 
236
- return task;
237
- }()
320
+ throwIfTemplateVersionDoesNotExist(options.templateName, clonedRepositoryPath, options.tagOrBranchVersion);
321
+ return result.stdout;
322
+ }
238
323
  }, {
239
- title: _concatInstanceProperty__default["default"](_context2 = "Copying template ".concat(options.templateName, " into project directory ")).call(_context2, options.projectDirectoryPath),
240
- task: function () {
241
- var _task2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
242
- var command, result, templatePackageJsonPath;
243
- return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context3) {
244
- while (1) {
245
- switch (_context3.prev = _context3.next) {
246
- case 0:
247
- command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
248
- _context3.next = 3;
249
- return execa__default["default"](command, [templateFolderPath, // Wrap folder path in quotes to avoid issues with empty spaces in the folder names.
250
- options.projectDirectoryPath], {
251
- encoding: 'utf-8'
252
- });
253
-
254
- case 3:
255
- result = _context3.sent;
256
-
257
- if (!result.failed) {
258
- _context3.next = 6;
259
- break;
260
- }
261
-
262
- throw new Error(result.stderr);
263
-
264
- case 6:
265
- templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
266
-
267
- if (fs__default["default"].existsSync(templatePackageJsonPath)) {
268
- _context3.next = 9;
269
- break;
270
- }
271
-
272
- throw new Error("Unable to verify that the template application has a package.json at \"".concat(templatePackageJsonPath, "\""));
273
-
274
- case 9:
275
- return _context3.abrupt("return", result.stdout);
276
-
277
- case 10:
278
- case "end":
279
- return _context3.stop();
280
- }
281
- }
282
- }, _callee2);
283
- }));
324
+ title: _concatInstanceProperty__default["default"](_context = "Copying template ".concat(options.templateName, " into project directory ")).call(_context, options.projectDirectoryPath),
325
+ task: async () => {
326
+ const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'move' : 'mv';
327
+ const result = await execa__default["default"](command, [templateFolderPath, // Wrap folder path in quotes to avoid issues with empty spaces in the folder names.
328
+ options.projectDirectoryPath], {
329
+ encoding: 'utf-8'
330
+ });
331
+
332
+ if (result.failed) {
333
+ throw new Error(result.stderr);
334
+ }
335
+
336
+ const templatePackageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
284
337
 
285
- function task() {
286
- return _task2.apply(this, arguments);
338
+ if (!fs__default["default"].existsSync(templatePackageJsonPath)) {
339
+ throw new Error("Unable to verify that the template application has a package.json at \"".concat(templatePackageJsonPath, "\""));
287
340
  }
288
341
 
289
- return task;
290
- }()
342
+ return result.stdout;
343
+ }
291
344
  }, {
292
345
  title: "Cleaning up project directory",
293
- task: function () {
294
- var _task3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3() {
295
- var command, result;
296
- return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context4) {
297
- while (1) {
298
- switch (_context4.prev = _context4.next) {
299
- case 0:
300
- command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
301
- _context4.next = 3;
302
- return execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, function (filePath) {
303
- return path__default["default"].join(options.projectDirectoryPath, filePath);
304
- }), {
305
- encoding: 'utf-8'
306
- });
307
-
308
- case 3:
309
- result = _context4.sent;
310
-
311
- if (!result.failed) {
312
- _context4.next = 6;
313
- break;
314
- }
315
-
316
- throw new Error(result.stderr);
317
-
318
- case 6:
319
- return _context4.abrupt("return", result.stdout);
320
-
321
- case 7:
322
- case "end":
323
- return _context4.stop();
324
- }
325
- }
326
- }, _callee3);
327
- }));
328
-
329
- function task() {
330
- return _task3.apply(this, arguments);
346
+ task: async () => {
347
+ const command = process.platform === 'win32' || process.platform === 'cygwin' ? 'del' : 'rm';
348
+ const result = await execa__default["default"](command, _mapInstanceProperty__default["default"](filesToBeRemoved).call(filesToBeRemoved, filePath => path__default["default"].join(options.projectDirectoryPath, filePath)), {
349
+ encoding: 'utf-8'
350
+ });
351
+
352
+ if (result.failed) {
353
+ throw new Error(result.stderr);
331
354
  }
332
355
 
333
- return task;
334
- }()
356
+ return result.stdout;
357
+ }
335
358
  }]);
336
359
  }
337
360
  };
@@ -340,9 +363,9 @@ function downloadTemplate(options) {
340
363
  function installDependencies(options) {
341
364
  return {
342
365
  title: 'Installing dependencies (this might take a while)',
343
- task: function task() {
344
- var useYarn = shouldUseYarn();
345
- var packageManager = useYarn ? 'yarn' : 'npm'; // TODO: we could check for min yarn/npm versions
366
+ task: () => {
367
+ const useYarn = shouldUseYarn();
368
+ const packageManager = useYarn ? 'yarn' : 'npm'; // TODO: we could check for min yarn/npm versions
346
369
  // See https://github.com/facebook/create-react-app/blob/0f4781e8507249ce29a9ac1409fece67c1a53c38/packages/create-react-app/createReactApp.js#L225-L254
347
370
 
348
371
  return execa__default["default"](packageManager, ['install'], {
@@ -357,30 +380,32 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
357
380
 
358
381
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
359
382
 
360
- var replaceApplicationKitPackageVersionWith = function replaceApplicationKitPackageVersionWith(releaseVersion) {
383
+ const replaceApplicationKitPackageVersionWith = function (releaseVersion) {
361
384
  var _context;
362
385
 
363
- var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
364
- return _reduceInstanceProperty__default["default"](_context = _Object$entries__default["default"](dependencies)).call(_context, function (updatedDependencies, _ref) {
365
- var _ref2 = _slicedToArray(_ref, 2),
386
+ let dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
387
+ return _reduceInstanceProperty__default["default"](_context = _Object$entries__default["default"](dependencies)).call(_context, (updatedDependencies, _ref) => {
388
+ let _ref2 = _slicedToArray(_ref, 2),
366
389
  dependencyName = _ref2[0],
367
390
  dependencyVersion = _ref2[1];
368
391
 
369
- var updatedVersion = dependencyVersion === 'workspace:*' ? releaseVersion : dependencyVersion;
370
- return _objectSpread(_objectSpread({}, updatedDependencies), {}, _defineProperty({}, dependencyName, updatedVersion));
392
+ const updatedVersion = dependencyVersion === 'workspace:*' ? releaseVersion : dependencyVersion;
393
+ return _objectSpread(_objectSpread({}, updatedDependencies), {}, {
394
+ [dependencyName]: updatedVersion
395
+ });
371
396
  }, {});
372
397
  };
373
398
 
374
399
  function updatePackageJson(options, releaseVersion) {
375
400
  return {
376
401
  title: 'Updating package.json',
377
- task: function task() {
378
- var packageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
379
- var appPackageJson = JSON.parse(fs__default["default"].readFileSync(packageJsonPath, {
402
+ task: () => {
403
+ const packageJsonPath = path__default["default"].join(options.projectDirectoryPath, 'package.json');
404
+ const appPackageJson = JSON.parse(fs__default["default"].readFileSync(packageJsonPath, {
380
405
  encoding: 'utf8'
381
406
  }));
382
407
 
383
- var updatedAppPackageJson = _Object$assign__default["default"]({}, appPackageJson, {
408
+ const updatedAppPackageJson = _Object$assign__default["default"]({}, appPackageJson, {
384
409
  version: '1.0.0',
385
410
  // Given the package name is derived from the `projectDirectoryName`
386
411
  // the latter needs to be sanitised to have a ensure a valid package name.
@@ -401,12 +426,12 @@ function updatePackageJson(options, releaseVersion) {
401
426
  }
402
427
 
403
428
  function replaceApplicationInfoInCustomApplicationConfig(filePath, options) {
404
- var appName = wordify(options.entryPointUriPath);
405
- var result = core.transformFileSync(filePath, {
429
+ const appName = wordify(options.entryPointUriPath);
430
+ const result = core.transformFileSync(filePath, {
406
431
  plugins: [function replaceCustomApplicationConfig() {
407
432
  return {
408
433
  visitor: {
409
- Identifier: function Identifier(nodePath) {
434
+ Identifier(nodePath) {
410
435
  if (nodePath.isIdentifier({
411
436
  name: 'name'
412
437
  }) && nodePath.parent.type === 'ObjectProperty') {
@@ -422,17 +447,16 @@ function replaceApplicationInfoInCustomApplicationConfig(filePath, options) {
422
447
  if (nodePath.isIdentifier({
423
448
  name: 'defaultLabel'
424
449
  })) {
425
- var isMainMenuLinkParent = nodePath.findParent(function (parentPath) {
426
- return parentPath.isIdentifier({
427
- name: 'mainMenuLink'
428
- });
429
- });
450
+ const isMainMenuLinkParent = nodePath.findParent(parentPath => parentPath.isIdentifier({
451
+ name: 'mainMenuLink'
452
+ }));
430
453
 
431
454
  if (isMainMenuLinkParent && nodePath.parent.type === 'ObjectProperty') {
432
455
  nodePath.parent.value = core.types.stringLiteral(appName);
433
456
  }
434
457
  }
435
458
  }
459
+
436
460
  }
437
461
  };
438
462
  }],
@@ -440,8 +464,8 @@ function replaceApplicationInfoInCustomApplicationConfig(filePath, options) {
440
464
  });
441
465
 
442
466
  if (result !== null && result !== void 0 && result.code) {
443
- var prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
444
- var formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
467
+ const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
468
+ const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
445
469
  fs__default["default"].writeFileSync(filePath, formattedData, {
446
470
  encoding: 'utf8'
447
471
  });
@@ -451,23 +475,24 @@ function replaceApplicationInfoInCustomApplicationConfig(filePath, options) {
451
475
  function updateCustomApplicationConfig(options) {
452
476
  return {
453
477
  title: 'Updating Custom Applications config',
454
- task: function task() {
455
- var customApplicationConfigPath = resolveFilePathByExtension(path__default["default"].join(options.projectDirectoryPath, 'custom-application-config'));
478
+ task: () => {
479
+ const customApplicationConfigPath = resolveFilePathByExtension(path__default["default"].join(options.projectDirectoryPath, 'custom-application-config'));
456
480
  replaceApplicationInfoInCustomApplicationConfig(customApplicationConfigPath, options);
457
481
  }
458
482
  };
459
483
  }
460
484
 
461
485
  function replaceEntryPointUriPathInConstants(filePath, options) {
462
- var result = core.transformFileSync(filePath, {
486
+ const result = core.transformFileSync(filePath, {
463
487
  plugins: [function replaceConstants() {
464
488
  return {
465
489
  visitor: {
466
- VariableDeclarator: function VariableDeclarator(nodePath) {
490
+ VariableDeclarator(nodePath) {
467
491
  if (nodePath.node.id.type === 'Identifier' && nodePath.node.id.name === 'entryPointUriPath') {
468
492
  nodePath.node.init = core.types.stringLiteral(options.entryPointUriPath);
469
493
  }
470
494
  }
495
+
471
496
  }
472
497
  };
473
498
  }],
@@ -475,8 +500,8 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
475
500
  });
476
501
 
477
502
  if (result !== null && result !== void 0 && result.code) {
478
- var prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
479
- var formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
503
+ const prettierConfig = prettier__default["default"].resolveConfig.sync(options.projectDirectoryPath);
504
+ const formattedData = prettier__default["default"].format(result.code + os__default["default"].EOL, prettierConfig !== null && prettierConfig !== void 0 ? prettierConfig : undefined);
480
505
  fs__default["default"].writeFileSync(filePath, formattedData, {
481
506
  encoding: 'utf8'
482
507
  });
@@ -486,260 +511,23 @@ function replaceEntryPointUriPathInConstants(filePath, options) {
486
511
  function updateApplicationConstants(options) {
487
512
  return {
488
513
  title: 'Updating application constants',
489
- task: function task() {
490
- var applicationConstantsPath = resolveFilePathByExtension(path__default["default"].join(options.projectDirectoryPath, 'src/constants'));
514
+ task: () => {
515
+ const applicationConstantsPath = resolveFilePathByExtension(path__default["default"].join(options.projectDirectoryPath, 'src/constants'));
491
516
  replaceEntryPointUriPathInConstants(applicationConstantsPath, options);
492
517
  }
493
518
  };
494
519
  }
495
520
 
496
- function getLatestReleaseVersion() {
497
- return _getLatestReleaseVersion.apply(this, arguments);
498
- }
499
-
500
- function _getLatestReleaseVersion() {
501
- _getLatestReleaseVersion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
502
- var commandResult, packageInfoForTagLatest;
503
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
504
- while (1) {
505
- switch (_context.prev = _context.next) {
506
- case 0:
507
- _context.next = 2;
508
- return execa__default["default"].command('npm view @commercetools-frontend/create-mc-app --json', {
509
- encoding: 'utf-8'
510
- });
511
-
512
- case 2:
513
- commandResult = _context.sent;
514
- packageInfoForTagLatest = JSON.parse(commandResult.stdout);
515
- return _context.abrupt("return", packageInfoForTagLatest.version);
516
-
517
- case 5:
518
- case "end":
519
- return _context.stop();
520
- }
521
- }
522
- }, _callee);
523
- }));
524
- return _getLatestReleaseVersion.apply(this, arguments);
525
- }
526
-
527
- function hintOutdatedVersion(currentVersion, releaseVersion) {
528
- var _context;
529
-
530
- var hasBeenReleastedInLatestTag = semver__default["default"].gt(releaseVersion, currentVersion);
531
-
532
- var hintNewerVersions = _filterInstanceProperty__default["default"](_context = [hasBeenReleastedInLatestTag && "".concat(releaseVersion)]).call(_context, Boolean).join(', ');
533
-
534
- if (hintNewerVersions.length > 0) {
535
- var _context2;
536
-
537
- console.log('');
538
- console.log(_concatInstanceProperty__default["default"](_context2 = "New version available! ".concat(currentVersion, " -> ")).call(_context2, hintNewerVersions));
539
- console.log('');
540
- }
541
- }
542
-
543
- var question = function question(rl, value) {
544
- return new _Promise__default["default"](function (resolve) {
545
- return rl.question(value, resolve);
546
- });
547
- };
548
-
549
- var getEntryPointUriPath = /*#__PURE__*/function () {
550
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(rl, options) {
551
- var _context;
552
-
553
- var randomEntryPointUriPath, answerEntryPointUriPath;
554
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context2) {
555
- while (1) {
556
- switch (_context2.prev = _context2.next) {
557
- case 0:
558
- if (!options.entryPointUriPath) {
559
- _context2.next = 2;
560
- break;
561
- }
562
-
563
- return _context2.abrupt("return", options.entryPointUriPath);
564
-
565
- case 2:
566
- randomEntryPointUriPath = _concatInstanceProperty__default["default"](_context = "".concat(options.template, "-")).call(_context, crypto__default["default"].randomBytes(3).toString('hex'));
567
-
568
- if (!options.yes) {
569
- _context2.next = 5;
570
- break;
571
- }
572
-
573
- return _context2.abrupt("return", randomEntryPointUriPath);
574
-
575
- case 5:
576
- _context2.next = 7;
577
- return question(rl, "Provide the Custom Application entryPointUriPath (default \"".concat(randomEntryPointUriPath, "\"): "));
578
-
579
- case 7:
580
- answerEntryPointUriPath = _context2.sent;
581
- return _context2.abrupt("return", answerEntryPointUriPath || randomEntryPointUriPath);
582
-
583
- case 9:
584
- case "end":
585
- return _context2.stop();
586
- }
587
- }
588
- }, _callee);
589
- }));
590
-
591
- return function getEntryPointUriPath(_x, _x2) {
592
- return _ref.apply(this, arguments);
593
- };
594
- }();
595
-
596
- var getInitialProjectKey = /*#__PURE__*/function () {
597
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(rl, options) {
598
- var initialProjectKey;
599
- return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context3) {
600
- while (1) {
601
- switch (_context3.prev = _context3.next) {
602
- case 0:
603
- if (!options.initialProjectKey) {
604
- _context3.next = 2;
605
- break;
606
- }
607
-
608
- return _context3.abrupt("return", options.initialProjectKey);
609
-
610
- case 2:
611
- _context3.next = 4;
612
- return question(rl, "Provide the initial project key for local development: ");
613
-
614
- case 4:
615
- initialProjectKey = _context3.sent;
616
- throwIfInitialProjectKeyIsMissing(initialProjectKey);
617
- return _context3.abrupt("return", initialProjectKey);
618
-
619
- case 7:
620
- case "end":
621
- return _context3.stop();
622
- }
623
- }
624
- }, _callee2);
625
- }));
626
-
627
- return function getInitialProjectKey(_x3, _x4) {
628
- return _ref2.apply(this, arguments);
629
- };
630
- }();
631
-
632
- function processOptions(_x5, _x6) {
633
- return _processOptions.apply(this, arguments);
634
- }
635
-
636
- function _processOptions() {
637
- _processOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(projectDirectoryName, options) {
638
- var projectDirectoryPath, tagOrBranchVersion, templateName, rl, entryPointUriPath, initialProjectKey;
639
- return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context4) {
640
- while (1) {
641
- switch (_context4.prev = _context4.next) {
642
- case 0:
643
- if (projectDirectoryName) {
644
- _context4.next = 2;
645
- break;
646
- }
647
-
648
- throw new Error('Missing required argument "[project-directory]"');
649
-
650
- case 2:
651
- projectDirectoryPath = path__default["default"].resolve(projectDirectoryName); // Parse options
652
-
653
- tagOrBranchVersion = options.templateVersion || 'main';
654
- tagOrBranchVersion = isSemVer(tagOrBranchVersion) && !_startsWithInstanceProperty__default["default"](tagOrBranchVersion).call(tagOrBranchVersion, 'v') ? "v".concat(tagOrBranchVersion) : tagOrBranchVersion;
655
- templateName = options.template; // Validate options
656
-
657
- throwIfProjectDirectoryExists(projectDirectoryName, projectDirectoryPath);
658
- throwIfTemplateIsNotSupported(templateName); // Read prompts
659
-
660
- rl = readline__default["default"].createInterface({
661
- input: process.stdin,
662
- output: process.stdout
663
- });
664
- _context4.next = 11;
665
- return getEntryPointUriPath(rl, options);
666
-
667
- case 11:
668
- entryPointUriPath = _context4.sent;
669
- _context4.next = 14;
670
- return getInitialProjectKey(rl, options);
671
-
672
- case 14:
673
- initialProjectKey = _context4.sent;
674
- rl.close();
675
- return _context4.abrupt("return", {
676
- projectDirectoryName: projectDirectoryName,
677
- projectDirectoryPath: projectDirectoryPath,
678
- templateName: templateName,
679
- tagOrBranchVersion: tagOrBranchVersion,
680
- entryPointUriPath: entryPointUriPath,
681
- initialProjectKey: initialProjectKey
682
- });
683
-
684
- case 17:
685
- case "end":
686
- return _context4.stop();
687
- }
688
- }
689
- }, _callee3);
690
- }));
691
- return _processOptions.apply(this, arguments);
692
- }
693
-
694
- var pkgJson = {
695
- name: "@commercetools-frontend/create-mc-app",
696
- version: "21.23.10",
697
- description: "Create Merchant Center applications to quickly get up and running",
698
- bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
699
- repository: {
700
- type: "git",
701
- url: "https://github.com/commercetools/merchant-center-application-kit.git",
702
- directory: "packages/create-mc-app"
703
- },
704
- homepage: "https://docs.commercetools.com/custom-applications",
705
- keywords: [
706
- "javascript",
707
- "frontend",
708
- "react",
709
- "toolkit"
710
- ],
711
- license: "MIT",
712
- publishConfig: {
713
- access: "public"
714
- },
715
- main: "dist/commercetools-frontend-create-mc-app.cjs.js",
716
- module: "dist/commercetools-frontend-create-mc-app.esm.js",
717
- bin: "./bin/cli.js",
718
- dependencies: {
719
- "@babel/core": "^7.20.12",
720
- "@babel/runtime": "^7.20.13",
721
- "@babel/runtime-corejs3": "^7.20.13",
722
- cac: "6.7.14",
723
- execa: "5.1.1",
724
- listr2: "5.0.7",
725
- prettier: "2.8.4",
726
- semver: "7.3.8"
727
- },
728
- engines: {
729
- node: "14.x || >=16.0.0"
730
- }
731
- };
732
-
733
521
  throwIfNodeVersionIsNotSupported(process.versions.node, pkgJson.engines.node);
734
- var cli = cac.cac('create-mc-app'); // Makes the script crash on unhandled rejections instead of silently
522
+ const cli = cac.cac('create-mc-app'); // Makes the script crash on unhandled rejections instead of silently
735
523
  // ignoring them. In the future, promise rejections that are not handled will
736
524
  // terminate the Node.js process with a non-zero exit code.
737
525
 
738
- process.on('unhandledRejection', function (err) {
526
+ process.on('unhandledRejection', err => {
739
527
  throw err;
740
528
  });
741
529
 
742
- var run = function run() {
530
+ const run = () => {
743
531
  // Default command
744
532
  cli.command('[project-directory]').usage('[project-directory]\n\n Bootstraps a new Custom Application project using one of the predefined templates.').option('--template <name>', '(optional) The name of the template to install.', {
745
533
  default: 'starter'
@@ -749,70 +537,37 @@ var run = function run() {
749
537
  default: false
750
538
  }).option('--yes', '(optional) If set, the prompt options with default values will be skipped.', {
751
539
  default: false
752
- }).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').action( /*#__PURE__*/function () {
753
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(projectDirectory, options) {
754
- var _context;
755
-
756
- var releaseVersion, taskOptions, taskList, useYarn;
757
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context2) {
758
- while (1) {
759
- switch (_context2.prev = _context2.next) {
760
- case 0:
761
- if (projectDirectory) {
762
- _context2.next = 3;
763
- break;
764
- }
540
+ }).option('--entry-point-uri-path <value>', '(optional) The version of the template to install. (default: starter-<hash>)').option('--initial-project-key <value>', '(optional) A commercetools project key used for the initial login in development. By default, the value is prompted in the terminal.').action(async (projectDirectory, options) => {
541
+ var _context;
765
542
 
766
- cli.outputHelp();
767
- return _context2.abrupt("return");
768
-
769
- case 3:
770
- _context2.next = 5;
771
- return getLatestReleaseVersion();
772
-
773
- case 5:
774
- releaseVersion = _context2.sent;
775
- hintOutdatedVersion(pkgJson.version, releaseVersion);
776
- console.log('');
777
- console.log("Documentation available at https://docs.commercetools.com/custom-applications");
778
- console.log('');
779
- _context2.next = 12;
780
- return processOptions(projectDirectory, options);
781
-
782
- case 12:
783
- taskOptions = _context2.sent;
784
- taskList = new listr2.Listr(_filterInstanceProperty__default["default"](_context = [downloadTemplate(taskOptions), updatePackageJson(taskOptions, releaseVersion), updateCustomApplicationConfig(taskOptions), updateApplicationConstants(taskOptions), !options.skipInstall && installDependencies(taskOptions)]).call(_context, Boolean));
785
- _context2.next = 16;
786
- return taskList.run();
787
-
788
- case 16:
789
- useYarn = shouldUseYarn();
790
- console.log('');
791
- console.log("\uD83C\uDF89 \uD83C\uDF89 \uD83C\uDF89 The Custom Application has been created in the \"".concat(taskOptions.projectDirectoryName, "\" folder."));
792
- console.log('');
793
- console.log("To get started:");
794
- console.log("$ cd ".concat(taskOptions.projectDirectoryName));
795
-
796
- if (options.skipInstall) {
797
- console.log("$ ".concat(useYarn ? 'yarn' : 'npm', " install"));
798
- }
543
+ if (!projectDirectory) {
544
+ cli.outputHelp();
545
+ return;
546
+ }
799
547
 
800
- console.log("$ ".concat(useYarn ? 'yarn' : 'npm', " start"));
801
- console.log('');
802
- console.log("Visit https://docs.commercetools.com/custom-applications for more info about developing Custom Applications. Enjoy \uD83D\uDE80");
548
+ const releaseVersion = await getLatestReleaseVersion();
549
+ hintOutdatedVersion(pkgJson.version, releaseVersion);
550
+ console.log('');
551
+ console.log("Documentation available at https://docs.commercetools.com/custom-applications");
552
+ console.log('');
553
+ const taskOptions = await processOptions(projectDirectory, options);
554
+ const taskList = new listr2.Listr(_filterInstanceProperty__default["default"](_context = [downloadTemplate(taskOptions), updatePackageJson(taskOptions, releaseVersion), updateCustomApplicationConfig(taskOptions), updateApplicationConstants(taskOptions), !options.skipInstall && installDependencies(taskOptions)]).call(_context, Boolean));
555
+ await taskList.run();
556
+ const useYarn = shouldUseYarn();
557
+ console.log('');
558
+ console.log("\uD83C\uDF89 \uD83C\uDF89 \uD83C\uDF89 The Custom Application has been created in the \"".concat(taskOptions.projectDirectoryName, "\" folder."));
559
+ console.log('');
560
+ console.log("To get started:");
561
+ console.log("$ cd ".concat(taskOptions.projectDirectoryName));
803
562
 
804
- case 26:
805
- case "end":
806
- return _context2.stop();
807
- }
808
- }
809
- }, _callee);
810
- }));
563
+ if (options.skipInstall) {
564
+ console.log("$ ".concat(useYarn ? 'yarn' : 'npm', " install"));
565
+ }
811
566
 
812
- return function (_x, _x2) {
813
- return _ref.apply(this, arguments);
814
- };
815
- }());
567
+ console.log("$ ".concat(useYarn ? 'yarn' : 'npm', " start"));
568
+ console.log('');
569
+ console.log("Visit https://docs.commercetools.com/custom-applications for more info about developing Custom Applications. Enjoy \uD83D\uDE80");
570
+ });
816
571
  cli.help();
817
572
  cli.version(pkgJson.version);
818
573
  cli.parse();