@commercetools-frontend/application-cli 2.3.1 → 2.3.2

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.
@@ -9,11 +9,12 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
9
9
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
10
10
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
11
11
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
12
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
12
13
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
13
14
  import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
14
15
  import _Set from '@babel/runtime-corejs3/core-js-stable/set';
15
16
  import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
16
- import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts } from '../../dist/storage-buckets-config-705b6341.esm.js';
17
+ import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts } from '../../dist/storage-buckets-config-f41d07bc.esm.js';
17
18
  import fs from 'node:fs';
18
19
  import path$1 from 'node:path';
19
20
  import { Listr } from 'listr2';
@@ -21,7 +22,6 @@ import execa from 'execa';
21
22
  import { findRootSync } from '@manypkg/find-root';
22
23
  import path from 'path';
23
24
  import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
24
- import _assertThisInitialized from '@babel/runtime-corejs3/helpers/esm/assertThisInitialized';
25
25
  import _get from '@babel/runtime-corejs3/helpers/esm/get';
26
26
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
27
27
  import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
@@ -30,8 +30,8 @@ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
30
30
  import _classPrivateFieldLooseBase from '@babel/runtime-corejs3/helpers/esm/classPrivateFieldLooseBase';
31
31
  import _classPrivateFieldLooseKey from '@babel/runtime-corejs3/helpers/esm/classPrivateFieldLooseKey';
32
32
  import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
33
- import fs$1 from 'fs';
34
33
  import dotenv from 'dotenv';
34
+ import fs$1 from 'fs';
35
35
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
36
36
  import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
37
37
  import { processConfig } from '@commercetools-frontend/application-config';
@@ -55,7 +55,7 @@ function isCI() {
55
55
  }
56
56
 
57
57
  function ownKeys$4(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; }
58
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$4(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$4(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
58
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys$4(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys$4(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
59
59
  function _callSuper(_this, derived, args) {
60
60
  function isNativeReflectConstruct() {
61
61
  if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
@@ -95,12 +95,12 @@ let StorageProvider = /*#__PURE__*/function () {
95
95
  * This allows all cloud environments sharing the same static assets while each application's index
96
96
  * is uploaded with different headers (e.g. CSP rules).
97
97
  */
98
- _createClass(StorageProvider, [{
98
+ return _createClass(StorageProvider, [{
99
99
  key: "getBucketNamespace",
100
100
  value: function getBucketNamespace(prNumber) {
101
101
  if (!prNumber) return;
102
102
  if (prNumber === 'merchant-center-preview') return prNumber;
103
- return `mc-${prNumber}`;
103
+ return "mc-".concat(prNumber);
104
104
  }
105
105
 
106
106
  /**
@@ -109,7 +109,7 @@ let StorageProvider = /*#__PURE__*/function () {
109
109
  }, {
110
110
  key: "getAssetsBucketUrl",
111
111
  value: function getAssetsBucketUrl(_ref) {
112
- var _context;
112
+ var _storageProvider$urls, _storageProvider$urls2, _context, _context2;
113
113
  let applicationName = _ref.applicationName,
114
114
  bucketProtocol = _ref.bucketProtocol,
115
115
  bucketNamespace = _ref.bucketNamespace,
@@ -118,13 +118,14 @@ let StorageProvider = /*#__PURE__*/function () {
118
118
  throw new Error("'bucketRegion' is not defined. Required to determine 'assetsBucketUrl'.");
119
119
  }
120
120
  const storageProvider = storageProviders[tag];
121
- const assetBuketUrl = storageProvider.urls.bucket?.[_classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1]] ?? _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1];
121
+ const assetBuketUrl = (_storageProvider$urls = (_storageProvider$urls2 = storageProvider.urls.bucket) === null || _storageProvider$urls2 === void 0 ? void 0 : _storageProvider$urls2[_classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1]]) !== null && _storageProvider$urls !== void 0 ? _storageProvider$urls : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1];
122
122
  const assetsBucketUrl = _filterInstanceProperty(_context = [assetBuketUrl, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
123
- return `${bucketProtocol}${assetsBucketUrl}`;
123
+ return _concatInstanceProperty(_context2 = "".concat(bucketProtocol)).call(_context2, assetsBucketUrl);
124
124
  }
125
125
  }, {
126
126
  key: "getApplicationIndexBucketUrl",
127
127
  value: function getApplicationIndexBucketUrl(_ref2) {
128
+ var _context3;
128
129
  let tag = _ref2.tag,
129
130
  prNumber = _ref2.prNumber,
130
131
  applicationName = _ref2.applicationName,
@@ -137,53 +138,53 @@ let StorageProvider = /*#__PURE__*/function () {
137
138
  bucketProtocol,
138
139
  bucketNamespace
139
140
  });
140
- const applicationIndexBucketUrl = `${applicationAssetsBucketUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]}`;
141
+ const applicationIndexBucketUrl = _concatInstanceProperty(_context3 = "".concat(applicationAssetsBucketUrl, "/")).call(_context3, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]);
141
142
  return applicationIndexBucketUrl;
142
143
  }
143
144
  }, {
144
145
  key: "getCdnUrl",
145
146
  value: function getCdnUrl(_ref3) {
146
- var _context2;
147
+ var _context4;
147
148
  let applicationName = _ref3.applicationName,
148
149
  prNumber = _ref3.prNumber,
149
150
  publicBaseUrl = _ref3.publicBaseUrl,
150
151
  excludeBucketRegion = _ref3.excludeBucketRegion;
151
- return _filterInstanceProperty(_context2 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context2, Boolean).join('/');
152
+ return _filterInstanceProperty(_context4 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context4, Boolean).join('/');
152
153
  }
153
154
  }, {
154
155
  key: "getPublicBaseUrl",
155
156
  value: function getPublicBaseUrl(tag) {
157
+ var _storageProvider$urls3;
156
158
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
157
159
  throw new Error("'bucketEnvironment' is not defined. Required to determine 'publicBaseUrl'.");
158
160
  }
159
161
  const storageProvider = storageProviders[tag];
160
- const publicBaseUrl = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]] ?? storageProvider.urls.public.default;
162
+ const publicBaseUrl = (_storageProvider$urls3 = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]) !== null && _storageProvider$urls3 !== void 0 ? _storageProvider$urls3 : storageProvider.urls.public.default;
161
163
  return publicBaseUrl;
162
164
  }
163
165
  }]);
164
- return StorageProvider;
165
166
  }();
166
167
  var _bucketRegion2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
167
168
  var _bucketEnvironment2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
168
- let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
169
- _inherits(GoogleStorageProvider, _StorageProvider);
169
+ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
170
170
  function GoogleStorageProvider(config) {
171
- var _this;
171
+ var _this2;
172
172
  _classCallCheck(this, GoogleStorageProvider);
173
- _this = _callSuper(this, GoogleStorageProvider, [config]);
174
- _Object$defineProperty(_assertThisInitialized(_this), _bucketRegion2$1, {
173
+ _this2 = _callSuper(this, GoogleStorageProvider, [config]);
174
+ _Object$defineProperty(_this2, _bucketRegion2$1, {
175
175
  writable: true,
176
176
  value: void 0
177
177
  });
178
- _Object$defineProperty(_assertThisInitialized(_this), _bucketEnvironment2$1, {
178
+ _Object$defineProperty(_this2, _bucketEnvironment2$1, {
179
179
  writable: true,
180
180
  value: void 0
181
181
  });
182
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
183
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
184
- return _this;
182
+ _classPrivateFieldLooseBase(_this2, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
183
+ _classPrivateFieldLooseBase(_this2, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
184
+ return _this2;
185
185
  }
186
- _createClass(GoogleStorageProvider, [{
186
+ _inherits(GoogleStorageProvider, _StorageProvider2);
187
+ return _createClass(GoogleStorageProvider, [{
187
188
  key: "getTag",
188
189
  value: function getTag() {
189
190
  return 'gs';
@@ -234,29 +235,28 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
234
235
  }, config));
235
236
  }
236
237
  }]);
237
- return GoogleStorageProvider;
238
238
  }(StorageProvider);
239
239
  var _bucketRegion3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
240
240
  var _bucketEnvironment3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
241
- let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
242
- _inherits(AwsStorageProvider, _StorageProvider2);
241
+ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider3) {
243
242
  function AwsStorageProvider(config) {
244
- var _this2;
243
+ var _this3;
245
244
  _classCallCheck(this, AwsStorageProvider);
246
- _this2 = _callSuper(this, AwsStorageProvider, [config]);
247
- _Object$defineProperty(_assertThisInitialized(_this2), _bucketRegion3, {
245
+ _this3 = _callSuper(this, AwsStorageProvider, [config]);
246
+ _Object$defineProperty(_this3, _bucketRegion3, {
248
247
  writable: true,
249
248
  value: void 0
250
249
  });
251
- _Object$defineProperty(_assertThisInitialized(_this2), _bucketEnvironment3, {
250
+ _Object$defineProperty(_this3, _bucketEnvironment3, {
252
251
  writable: true,
253
252
  value: void 0
254
253
  });
255
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
256
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
257
- return _this2;
254
+ _classPrivateFieldLooseBase(_this3, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
255
+ _classPrivateFieldLooseBase(_this3, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
256
+ return _this3;
258
257
  }
259
- _createClass(AwsStorageProvider, [{
258
+ _inherits(AwsStorageProvider, _StorageProvider3);
259
+ return _createClass(AwsStorageProvider, [{
260
260
  key: "getTag",
261
261
  value: function getTag() {
262
262
  return 's3';
@@ -308,7 +308,6 @@ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
308
308
  }, config));
309
309
  }
310
310
  }]);
311
- return AwsStorageProvider;
312
311
  }(StorageProvider);
313
312
  function getStorageProvider(storageProvider, config) {
314
313
  switch (storageProvider) {
@@ -317,7 +316,7 @@ function getStorageProvider(storageProvider, config) {
317
316
  case 's3':
318
317
  return new AwsStorageProvider(config);
319
318
  default:
320
- throw new Error(`Storage provider ${storageProvider} not supported`);
319
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
321
320
  }
322
321
  }
323
322
 
@@ -337,9 +336,10 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
337
336
  _classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion] = config.bucketRegion;
338
337
  _classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment] = config.bucketEnvironment;
339
338
  }
340
- _createClass(GoogleStorageUploadScriptsGenerator, [{
339
+ return _createClass(GoogleStorageUploadScriptsGenerator, [{
341
340
  key: "getApplicationIndexUploadScript",
342
341
  value: function getApplicationIndexUploadScript(_ref) {
342
+ var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10;
343
343
  let packageManagerName = _ref.packageManagerName,
344
344
  bucketUrl = _ref.bucketUrl,
345
345
  cdnUrl = _ref.cdnUrl,
@@ -349,109 +349,18 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
349
349
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
350
350
  throw new Error("Missing 'bucketEnvironment' when generating application index.");
351
351
  }
352
- return `
353
- #!/usr/bin/env bash
354
-
355
- set -e
356
-
357
- echo "Uploading compiled ${applicationIndexOutFile} to Google Storage bucket ${bucketUrl}"
358
-
359
- gcloud storage cp \\
360
- "$(dirname "$0")/${applicationIndexOutFile}" \\
361
- "${bucketUrl}/" \\
362
- -z html \\
363
- --content-type="text/html" \\
364
- --cache-control="public,max-age=0,no-transform"
365
-
366
- echo "Creating version.json and uploading it to bucket ${bucketUrl}"
367
-
368
- NODE_ENV=production ${packageManagerName} application-cli create-version \\
369
- --version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
370
- --build-revision=${buildRevision} \\
371
- --build-number=${buildNumber} \\
372
- --out-file=$(dirname "$0")/version.json
373
-
374
- gcloud storage cp \\
375
- "$(dirname "$0")/version.json" \\
376
- "${bucketUrl}/" \\
377
- -z json \\
378
- --content-type="application/json" \\
379
- --cache-control="public,max-age=0,no-transform"
380
- `;
352
+ return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "\n#!/usr/bin/env bash\n\nset -e\n\necho \"Uploading compiled ".concat(applicationIndexOutFile, " to Google Storage bucket ")).call(_context10, bucketUrl, "\"\n\ngcloud storage cp \\\n \"$(dirname \"$0\")/")).call(_context9, applicationIndexOutFile, "\" \\\n \"")).call(_context8, bucketUrl, "/\" \\\n -z html \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\"\n\necho \"Creating version.json and uploading it to bucket ")).call(_context7, bucketUrl, "\"\n\nNODE_ENV=production ")).call(_context6, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context5, cdnUrl, "/")).call(_context4, _classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment], "/version.json \\\n --build-revision=")).call(_context3, buildRevision, " \\\n --build-number=")).call(_context2, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\ngcloud storage cp \\\n \"$(dirname \"$0\")/version.json\" \\\n \"")).call(_context, bucketUrl, "/\" \\\n -z json \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\"\n");
381
353
  }
382
354
  }, {
383
355
  key: "getProductionBundlesUploadScript",
384
356
  value: function getProductionBundlesUploadScript(_ref2) {
357
+ var _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18;
385
358
  let bucketUrl = _ref2.bucketUrl,
386
359
  assetsPath = _ref2.assetsPath,
387
360
  skipMenu = _ref2.skipMenu;
388
- return `
389
- #!/usr/bin/env bash
390
-
391
- set -e
392
-
393
- # NOTES:
394
- # https://cloud.google.com/sdk/gcloud/reference/storage/cp
395
- # 1. The '-z' option triggers compressing the assets before
396
- # uploading them and sets the 'Content-Encoding' to 'gzip'.
397
- # 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.
398
- # 3. The 'max-age' is set to 1 year which is considered the maximum
399
- # "valid" lifetime of an asset to be cached.
400
- # 4. The '-n' will skip uploading existing files and prevents them to
401
- # be overwritten
402
- echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
403
-
404
- gcloud storage cp \\
405
- ${assetsPath}/public/{*.css,*.js,*.js.map,*.html} \\
406
- "${bucketUrl}" \\
407
- -n \\
408
- -z js,css \\
409
- --cache-control="public,max-age=31536000,no-transform"
410
-
411
- # We need to upload the PNG and HTML files separately because we want them
412
- # to be able to overwrite the existing files (if any). For instance, the
413
- # file or the favicons.
414
- # This is controlled with the '-n' option (which is used for the JS and CSS
415
- # as we don't want to overwrite them)
416
- gcloud storage cp \\
417
- ${assetsPath}/public/{*.png,robots.txt} \\
418
- "${bucketUrl}" \\
419
- -z txt \\
420
- --cache-control="public,max-age=31536000,no-transform"
421
-
422
- if ${skipMenu}; then
423
- echo "Skipping menu.json upload"
424
- else
425
- echo "Uploading menu.json to bucket ${bucketUrl}"
426
- # NOTE: somehow the 'cache-control:private' doesn't work.
427
- # I mean, the file is uploaded with the correct metadata but when I fetch
428
- # the file the response contains the header
429
- # 'cache-control: public,max-age=31536000,no-transform', even though the
430
- # documentation clearly states that by marking the header as 'private' will
431
- # disable the cache (for publicly readable objects).
432
- # https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
433
- # However, I found out that, by requesting the file with any RANDOM
434
- # query parameter, will instruct the storage to return a 'fresh' object
435
- # (without any cache control).
436
- # Unofficial source: https://stackoverflow.com/a/49052895
437
- # This seems to be the 'easiest' option to 'disable' the cache for public
438
- # objects. Other alternative approaces are:
439
- # * make the object private with some simple ACL (private objects are not cached)
440
- # * suffix the file name with e.g. the git SHA, so we have different files
441
- # for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
442
- # the git SHA on runtime and can get the correct file when it starts.
443
- # * find out why the 'private' cache control does not work
444
- gcloud storage cp \\
445
- ${assetsPath}/menu.json \\
446
- ${bucketUrl} \\
447
- -z json \\
448
- --content-type="application/json" \\
449
- --cache-control="public,max-age=0,no-transform"
450
- fi
451
- `;
361
+ return _concatInstanceProperty(_context11 = _concatInstanceProperty(_context12 = _concatInstanceProperty(_context13 = _concatInstanceProperty(_context14 = _concatInstanceProperty(_context15 = _concatInstanceProperty(_context16 = _concatInstanceProperty(_context17 = _concatInstanceProperty(_context18 = "\n#!/usr/bin/env bash\n\nset -e\n\n# NOTES:\n# https://cloud.google.com/sdk/gcloud/reference/storage/cp\n# 1. The '-z' option triggers compressing the assets before\n# uploading them and sets the 'Content-Encoding' to 'gzip'.\n# 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.\n# 3. The 'max-age' is set to 1 year which is considered the maximum\n# \"valid\" lifetime of an asset to be cached.\n# 4. The '-n' will skip uploading existing files and prevents them to\n# be overwritten\necho \"Uploading static assets to Google Storage bucket ".concat(bucketUrl, "\"\n\ngcloud storage cp \\\n ")).call(_context18, assetsPath, "/public/{*.css,*.js,*.js.map,*.html} \\\n \"")).call(_context17, bucketUrl, "\" \\\n -n \\\n -z js,css \\\n --cache-control=\"public,max-age=31536000,no-transform\"\n\n# We need to upload the PNG and HTML files separately because we want them\n# to be able to overwrite the existing files (if any). For instance, the\n# file or the favicons.\n# This is controlled with the '-n' option (which is used for the JS and CSS\n# as we don't want to overwrite them)\ngcloud storage cp \\\n ")).call(_context16, assetsPath, "/public/{*.png,robots.txt} \\\n \"")).call(_context15, bucketUrl, "\" \\\n -z txt \\\n --cache-control=\"public,max-age=31536000,no-transform\"\n\nif ")).call(_context14, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context13, bucketUrl, "\"\n # NOTE: somehow the 'cache-control:private' doesn't work.\n # I mean, the file is uploaded with the correct metadata but when I fetch\n # the file the response contains the header\n # 'cache-control: public,max-age=31536000,no-transform', even though the\n # documentation clearly states that by marking the header as 'private' will\n # disable the cache (for publicly readable objects).\n # https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control\n # However, I found out that, by requesting the file with any RANDOM\n # query parameter, will instruct the storage to return a 'fresh' object\n # (without any cache control).\n # Unofficial source: https://stackoverflow.com/a/49052895\n # This seems to be the 'easiest' option to 'disable' the cache for public\n # objects. Other alternative approaces are:\n # * make the object private with some simple ACL (private objects are not cached)\n # * suffix the file name with e.g. the git SHA, so we have different files\n # for each upload ('index.html.template-${CIRCLE_SHA1}'). The server knows\n # the git SHA on runtime and can get the correct file when it starts.\n # * find out why the 'private' cache control does not work\n gcloud storage cp \\\n ")).call(_context12, assetsPath, "/menu.json \\\n ")).call(_context11, bucketUrl, " \\\n -z json \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\"\nfi\n");
452
362
  }
453
363
  }]);
454
- return GoogleStorageUploadScriptsGenerator;
455
364
  }();
456
365
  var _bucketEnvironment2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
457
366
  var _bucketRegion2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
@@ -469,105 +378,28 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
469
378
  _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2] = config.bucketRegion;
470
379
  _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2] = config.bucketEnvironment;
471
380
  }
472
- _createClass(AwsStorageUploadScriptsGenerator, [{
381
+ return _createClass(AwsStorageUploadScriptsGenerator, [{
473
382
  key: "getApplicationIndexUploadScript",
474
383
  value: function getApplicationIndexUploadScript(_ref3) {
384
+ var _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
475
385
  let packageManagerName = _ref3.packageManagerName,
476
386
  bucketUrl = _ref3.bucketUrl,
477
387
  cdnUrl = _ref3.cdnUrl,
478
388
  buildRevision = _ref3.buildRevision,
479
389
  buildNumber = _ref3.buildNumber,
480
390
  applicationIndexOutFile = _ref3.applicationIndexOutFile;
481
- return `
482
- #!/usr/bin/env bash
483
-
484
- echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
485
-
486
- set -e
487
-
488
- aws s3 cp "$(dirname "$0")/${applicationIndexOutFile}" \\
489
- "${bucketUrl}/" \\
490
- --content-type="text/html" \\
491
- --cache-control="public,max-age=0,no-transform" \\
492
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
493
-
494
- echo "Creating version.json and uploading it to bucket ${bucketUrl}"
495
-
496
- NODE_ENV=production ${packageManagerName} application-cli create-version \\
497
- --version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2]}/version.json \\
498
- --build-revision=${buildRevision} \\
499
- --build-number=${buildNumber} \\
500
- --out-file=$(dirname "$0")/version.json
501
-
502
- aws s3 cp "$(dirname "$0")" \\
503
- "${bucketUrl}/" \\
504
- --exclude "*" \\
505
- --include "version.json" \\
506
- --content-type="application/json" \\
507
- --cache-control="public,max-age=0,no-transform" \\
508
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
509
- `;
391
+ return _concatInstanceProperty(_context19 = _concatInstanceProperty(_context20 = _concatInstanceProperty(_context21 = _concatInstanceProperty(_context22 = _concatInstanceProperty(_context23 = _concatInstanceProperty(_context24 = _concatInstanceProperty(_context25 = _concatInstanceProperty(_context26 = _concatInstanceProperty(_context27 = _concatInstanceProperty(_context28 = _concatInstanceProperty(_context29 = "\n #!/usr/bin/env bash\n\n echo \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\n set -e\n\n aws s3 cp \"$(dirname \"$0\")/")).call(_context29, applicationIndexOutFile, "\" \\\n \"")).call(_context28, bucketUrl, "/\" \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context27, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n echo \"Creating version.json and uploading it to bucket ")).call(_context26, bucketUrl, "\"\n\n NODE_ENV=production ")).call(_context25, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context24, cdnUrl, "/")).call(_context23, _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2], "/version.json \\\n --build-revision=")).call(_context22, buildRevision, " \\\n --build-number=")).call(_context21, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\n aws s3 cp \"$(dirname \"$0\")\" \\\n \"")).call(_context20, bucketUrl, "/\" \\\n --exclude \"*\" \\\n --include \"version.json\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context19, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n");
510
392
  }
511
393
  }, {
512
394
  key: "getProductionBundlesUploadScript",
513
395
  value: function getProductionBundlesUploadScript(_ref4) {
396
+ var _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40;
514
397
  let bucketUrl = _ref4.bucketUrl,
515
398
  assetsPath = _ref4.assetsPath,
516
399
  skipMenu = _ref4.skipMenu;
517
- return `
518
- #!/usr/bin/env bash
519
-
520
- echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
521
-
522
- set -e
523
-
524
- # NOTE:
525
- # The sync command on the AWS CLI is different to the -n option on the gcloud CLI.
526
- # Sync will only upload files that are not already in the bucket, but it will skip existing ones
527
- # that have been changed locally.
528
- # The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.
529
- # https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
530
- # https://cloud.google.com/sdk/gcloud/reference/storage/cp
531
- #
532
- # Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.
533
- # https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring
534
- aws s3 sync ${assetsPath}/public \\
535
- "${bucketUrl}" \\
536
- --exclude "*" \\
537
- --include "*.css" \\
538
- --include "*.js" \\
539
- --include "*.js.map" \\
540
- --include "*.html" \\
541
- --cache-control="public,max-age=31536000,no-transform" \\
542
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
543
-
544
- # We need to upload the PNG and HTML files separately because we want them
545
- # to be able to overwrite the existing files (if any). For instance, the
546
- # file or the favicons.
547
- aws s3 cp ${assetsPath}/public \\
548
- "${bucketUrl}" \\
549
- --recursive \\
550
- --exclude "*" \\
551
- --include "*.png" \\
552
- --include "robots.txt" \\
553
- --cache-control="public,max-age=31536000,no-transform" \\
554
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
555
-
556
- if ${skipMenu}; then
557
- echo "Skipping menu.json upload"
558
- else
559
- echo "Uploading menu.json to bucket ${bucketUrl}"
560
-
561
- aws s3 cp ${assetsPath}/menu.json \\
562
- "${bucketUrl}/" \\
563
- --content-type="application/json" \\
564
- --cache-control="public,max-age=0,no-transform" \\
565
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
566
- fi
567
- `;
400
+ return _concatInstanceProperty(_context30 = _concatInstanceProperty(_context31 = _concatInstanceProperty(_context32 = _concatInstanceProperty(_context33 = _concatInstanceProperty(_context34 = _concatInstanceProperty(_context35 = _concatInstanceProperty(_context36 = _concatInstanceProperty(_context37 = _concatInstanceProperty(_context38 = _concatInstanceProperty(_context39 = _concatInstanceProperty(_context40 = "\n#!/usr/bin/env bash\n\necho \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\nset -e\n\n# NOTE:\n# The sync command on the AWS CLI is different to the -n option on the gcloud CLI.\n# Sync will only upload files that are not already in the bucket, but it will skip existing ones\n# that have been changed locally.\n# The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.\n# https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html\n# https://cloud.google.com/sdk/gcloud/reference/storage/cp\n#\n# Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.\n# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring\naws s3 sync ")).call(_context40, assetsPath, "/public \\\n \"")).call(_context39, bucketUrl, "\" \\\n --exclude \"*\" \\\n --include \"*.css\" \\\n --include \"*.js\" \\\n --include \"*.js.map\" \\\n --include \"*.html\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context38, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n# We need to upload the PNG and HTML files separately because we want them\n# to be able to overwrite the existing files (if any). For instance, the\n# file or the favicons.\naws s3 cp ")).call(_context37, assetsPath, "/public \\\n \"")).call(_context36, bucketUrl, "\" \\\n --recursive \\\n --exclude \"*\" \\\n --include \"*.png\" \\\n --include \"robots.txt\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context35, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\nif ")).call(_context34, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context33, bucketUrl, "\"\n\n aws s3 cp ")).call(_context32, assetsPath, "/menu.json \\\n \"")).call(_context31, bucketUrl, "/\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context30, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\nfi\n");
568
401
  }
569
402
  }]);
570
- return AwsStorageUploadScriptsGenerator;
571
403
  }();
572
404
  function getUploadScriptsGenerator(storageProvider, config) {
573
405
  switch (storageProvider) {
@@ -576,12 +408,21 @@ function getUploadScriptsGenerator(storageProvider, config) {
576
408
  case 's3':
577
409
  return new AwsStorageUploadScriptsGenerator(config);
578
410
  default:
579
- throw new Error(`Storage provider ${storageProvider} not supported`);
411
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
412
+ }
413
+ }
414
+
415
+ function doesFileExist(filePath) {
416
+ try {
417
+ fs$1.accessSync(filePath);
418
+ return true;
419
+ } catch (e) {
420
+ return false;
580
421
  }
581
422
  }
582
423
 
583
424
  function ownKeys$3(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; }
584
- function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
425
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$3(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$3(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
585
426
  function loadDotenvFiles(_ref) {
586
427
  let dotenvPath = _ref.dotenvPath,
587
428
  cloudEnvironment = _ref.cloudEnvironment;
@@ -591,13 +432,13 @@ function loadDotenvFiles(_ref) {
591
432
  }
592
433
 
593
434
  // Check if the given path exists.
594
- if (!fs$1.existsSync(dotenvPath)) {
595
- throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
435
+ if (!doesFileExist(dotenvPath)) {
436
+ throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
596
437
  }
597
438
 
598
439
  // Load the environment values
599
440
  const sharedDotenvFile = '.env.production';
600
- const cloudDotenvFile = `.env.${cloudEnvironment}`;
441
+ const cloudDotenvFile = ".env.".concat(cloudEnvironment);
601
442
 
602
443
  // The shared dotenv file across environments is optional
603
444
  const sharedProductionEnvironment = dotenv.config({
@@ -609,16 +450,18 @@ function loadDotenvFiles(_ref) {
609
450
  path: path.join(dotenvPath, cloudDotenvFile)
610
451
  });
611
452
  if (cloudSpecificProductionEnvironment.error) {
612
- throw new Error(`Failed loading '${cloudDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
453
+ var _context;
454
+ throw new Error(_concatInstanceProperty(_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
613
455
  }
614
456
  if (sharedProductionEnvironment.error) {
615
- throw new Error(`Failed loading '${sharedDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
457
+ var _context2;
458
+ throw new Error(_concatInstanceProperty(_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
616
459
  }
617
460
  return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
618
461
  }
619
462
 
620
463
  function ownKeys$2(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; }
621
- function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$2(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$2(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
464
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys$2(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys$2(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
622
465
  function writeUploadScriptFile(_ref) {
623
466
  let fileName = _ref.fileName,
624
467
  fileContent = _ref.fileContent,
@@ -630,6 +473,7 @@ function writeUploadScriptFile(_ref) {
630
473
  });
631
474
  }
632
475
  async function compileApplicationAssets(_ref2) {
476
+ var _context, _context2;
633
477
  let cliFlags = _ref2.cliFlags,
634
478
  storageProvider = _ref2.storageProvider,
635
479
  uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
@@ -644,7 +488,7 @@ async function compileApplicationAssets(_ref2) {
644
488
  skipMenu: cliFlags.skipMenu
645
489
  });
646
490
  const parsedApplicationAssetsUploadScriptFile = path$1.parse(cliFlags.applicationAssetsUploadScriptOutFile);
647
- const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${storageProvider.getBucketRegion()}${parsedApplicationAssetsUploadScriptFile.ext}`;
491
+ const applicationAssetsUploadScriptFileName = _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
648
492
  writeUploadScriptFile({
649
493
  fileName: applicationAssetsUploadScriptFileName,
650
494
  fileContent: applicationAssetsUploadScriptContent,
@@ -677,7 +521,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
677
521
  })), {}, {
678
522
  // The trailing slash is important to indicate to the CSP directive that all the resources
679
523
  // under that path should be allowed.
680
- MC_CDN_URL: `${cdnUrl}/`
524
+ MC_CDN_URL: "".concat(cdnUrl, "/")
681
525
  }, cliFlags.mcUrl ? {
682
526
  MC_URL: cliFlags.mcUrl
683
527
  } : {}), cliFlags.mcApiUrl ? {
@@ -734,7 +578,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
734
578
  }
735
579
  }
736
580
  async function command$3(cliFlags, cwd) {
737
- var _context;
581
+ var _context3;
738
582
  const storageBucketConfig = await loadStorageBucketsConfig();
739
583
  const applicationDirectory = getApplicationDirectory(cwd);
740
584
  let assetsPath;
@@ -751,12 +595,12 @@ async function command$3(cliFlags, cwd) {
751
595
  assetsPath
752
596
  };
753
597
  const defaultStorageProviders = [storageProviders.gs.tag];
754
- const taskList = new Listr(_mapInstanceProperty(_context = _Object$entries(storageBucketConfig)).call(_context, _ref4 => {
598
+ const taskList = new Listr(_mapInstanceProperty(_context3 = _Object$entries(storageBucketConfig)).call(_context3, _ref4 => {
755
599
  let _ref5 = _slicedToArray(_ref4, 2),
756
600
  bucketRegion = _ref5[0],
757
601
  bucketEnvironmentConfigs = _ref5[1];
758
602
  return {
759
- title: `Compiling for bucket region ${bucketRegion}`,
603
+ title: "Compiling for bucket region ".concat(bucketRegion),
760
604
  task: (_bucketRegionCtx, bucketRegionTask) => {
761
605
  // NOTE: Application assets need to be compiled
762
606
  // for all storage providers once per region.
@@ -771,7 +615,7 @@ async function command$3(cliFlags, cwd) {
771
615
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
772
616
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
773
617
  return {
774
- title: `Compiling application assets for '${storageProviderTag}'`,
618
+ title: "Compiling application assets for '".concat(storageProviderTag, "'"),
775
619
  task: () => compileApplicationAssets({
776
620
  cliFlags,
777
621
  storageProvider,
@@ -789,14 +633,14 @@ async function command$3(cliFlags, cwd) {
789
633
  bucketEnvironment
790
634
  };
791
635
  return {
792
- title: `Compiling for cloud environment '${cloudEnvironment}'`,
636
+ title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
793
637
  task: (_storageProviderCtx, storageProviderTask) => {
794
- var _context2;
795
- const applicationIndexTasksForStorageProviders = _mapInstanceProperty(_context2 = storageProviders || defaultStorageProviders).call(_context2, storageProviderTag => {
638
+ var _context4;
639
+ const applicationIndexTasksForStorageProviders = _mapInstanceProperty(_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
796
640
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
797
641
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
798
642
  return {
799
- title: `Compiling application index for storage provider '${storageProviderTag}'`,
643
+ title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
800
644
  task: () => {
801
645
  return compileEnvironmentApplicationIndexes({
802
646
  cliFlags,
@@ -852,52 +696,58 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
852
696
  */
853
697
 
854
698
  const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
855
- var _context2;
699
+ var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
856
700
  const entryPointUriPath = config.env.entryPointUriPath;
857
701
 
858
702
  // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
859
- const accountLinks = config.env.__DEVELOPMENT__?.accountLinks ?? [];
703
+ const accountLinks = (_ref = (_config$env$__DEVELOP = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP === void 0 ? void 0 : _config$env$__DEVELOP.accountLinks) !== null && _ref !== void 0 ? _ref : [];
860
704
  if (accountLinks.length > 0) {
861
- return _mapInstanceProperty(accountLinks).call(accountLinks, menuLink => ({
862
- key: menuLink.uriPath,
863
- uriPath: menuLink.uriPath,
864
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
865
- permissions: menuLink.permissions ?? [],
866
- // @ts-ignore: not defined in schema, as it's only used internally.
867
- featureToggle: menuLink.featureToggle ?? null
868
- }));
705
+ return _mapInstanceProperty(accountLinks).call(accountLinks, menuLink => {
706
+ var _menuLink$permissions, _menuLink$featureTogg;
707
+ return {
708
+ key: menuLink.uriPath,
709
+ uriPath: menuLink.uriPath,
710
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
711
+ permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
712
+ // @ts-ignore: not defined in schema, as it's only used internally.
713
+ featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
714
+ };
715
+ });
869
716
  }
870
- const menuLinks = config.env.__DEVELOPMENT__?.menuLinks;
717
+ const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
871
718
  return {
872
719
  key: entryPointUriPath,
873
720
  uriPath: entryPointUriPath,
874
721
  icon: menuLinks.icon,
875
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks?.labelAllLocales, menuLinks?.defaultLabel),
722
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
876
723
  permissions: menuLinks.permissions,
877
724
  // @ts-ignore: not defined in schema, as it's only used internally.
878
- featureToggle: menuLinks.featureToggle ?? null,
725
+ featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
879
726
  // @ts-ignore: not defined in schema, as it's only used internally.
880
- menuVisibility: menuLinks.menuVisibility ?? null,
727
+ menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
881
728
  // @ts-ignore: not defined in schema, as it's only used internally.
882
- actionRights: menuLinks.actionRights ?? null,
729
+ actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
883
730
  // @ts-ignore: not defined in schema, as it's only used internally.
884
- dataFences: menuLinks.dataFences ?? null,
885
- submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => ({
886
- key: submenuLink.uriPath.replace('/', '-'),
887
- uriPath: submenuLink.uriPath,
888
- labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
889
- permissions: submenuLink.permissions,
890
- // @ts-ignore: not defined in schema, as it's only used internally.
891
- featureToggle: submenuLink.featureToggle ?? null,
892
- // @ts-ignore: not defined in schema, as it's only used internally.
893
- menuVisibility: submenuLink.menuVisibility ?? null,
894
- // @ts-ignore: not defined in schema, as it's only used internally.
895
- actionRights: submenuLink.actionRights ?? null,
896
- // @ts-ignore: not defined in schema, as it's only used internally.
897
- dataFences: submenuLink.dataFences ?? null
898
- })),
731
+ dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
732
+ submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
733
+ var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
734
+ return {
735
+ key: submenuLink.uriPath.replace('/', '-'),
736
+ uriPath: submenuLink.uriPath,
737
+ labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
738
+ permissions: submenuLink.permissions,
739
+ // @ts-ignore: not defined in schema, as it's only used internally.
740
+ featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
741
+ // @ts-ignore: not defined in schema, as it's only used internally.
742
+ menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
743
+ // @ts-ignore: not defined in schema, as it's only used internally.
744
+ actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
745
+ // @ts-ignore: not defined in schema, as it's only used internally.
746
+ dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
747
+ };
748
+ }),
899
749
  // @ts-ignore: not defined in schema, as it's only used internally.
900
- shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
750
+ shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
901
751
  };
902
752
  };
903
753
  async function command$2(cliFlags, cwd) {
@@ -1079,15 +929,15 @@ function validateMenu(menuJson) {
1079
929
  async function command(cliFlags) {
1080
930
  const menuJsonPath = cliFlags.inputFile;
1081
931
  const isAppbarMenu = cliFlags.navigation === 'top';
1082
- if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
1083
- if (!fs$1.existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
932
+ if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
933
+ if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
1084
934
  const menuJson = fs$1.readFileSync(menuJsonPath, 'utf-8');
1085
935
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
1086
936
  }
1087
937
 
1088
938
  var pkgJson = {
1089
939
  name: "@commercetools-frontend/application-cli",
1090
- version: "2.3.1",
940
+ version: "2.3.2",
1091
941
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
1092
942
  keywords: [
1093
943
  "commercetools",
@@ -1112,22 +962,22 @@ var pkgJson = {
1112
962
  "@babel/core": "^7.22.11",
1113
963
  "@babel/runtime": "^7.21.0",
1114
964
  "@babel/runtime-corejs3": "^7.21.0",
1115
- "@commercetools-frontend/application-config": "22.22.0",
1116
- "@commercetools-frontend/constants": "22.22.0",
1117
- "@commercetools-frontend/l10n": "22.22.0",
965
+ "@commercetools-frontend/application-config": "22.23.3",
966
+ "@commercetools-frontend/constants": "22.23.3",
967
+ "@commercetools-frontend/l10n": "22.23.3",
1118
968
  "@manypkg/find-root": "2.2.1",
1119
969
  cac: "^6.7.14",
1120
970
  cosmiconfig: "9.0.0",
1121
- dotenv: "16.4.2",
971
+ dotenv: "16.4.5",
1122
972
  execa: "5.1.1",
1123
973
  jsonschema: "^1.4.1",
1124
- listr2: "8.0.2",
974
+ listr2: "8.2.0",
1125
975
  "node-fetch": "2.7.0",
1126
976
  "ts-deepmerge": "7.0.0"
1127
977
  },
1128
978
  devDependencies: {
1129
- "@tsconfig/node20": "20.1.2",
1130
- "@types/node": "20.12.2",
979
+ "@tsconfig/node20": "20.1.4",
980
+ "@types/node": "20.12.7",
1131
981
  typescript: "5.2.2"
1132
982
  },
1133
983
  engines: {
@@ -1159,7 +1009,7 @@ const run = async () => {
1159
1009
  // Default command
1160
1010
  cli.command('').usage('\n\n Compile deployments and menus and create versions for MC applications').action(cli.outputHelp);
1161
1011
  const usageCompileDeployment = 'Compile the deployments for an application for all environments.';
1162
- cli.command('compile-deployments', usageCompileDeployment).usage(`compile-deployments \n\n ${usageCompileDeployment}`).option('--application-name <string>', '(required) The name of the application being compiled for example application-products.').option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file ".env.production" and a cloud-environment specific dotenv file (for example ".env.gcp-production-eu"). Those values are parsed and merged together to be used by the `mc-scripts compile-html` command.').option('--pr-number [string]', '(optional) A pull request number determining a scoped storage bucket for the deployment. Please use it carefully.').option('--mc-url [string]', '(optional) The MC URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--mc-api-url [string]', '(optional) The MC API URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--application-index-out-file [path]', '(optional) The name of the application index file.', {
1012
+ cli.command('compile-deployments', usageCompileDeployment).usage("compile-deployments \n\n ".concat(usageCompileDeployment)).option('--application-name <string>', '(required) The name of the application being compiled for example application-products.').option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file ".env.production" and a cloud-environment specific dotenv file (for example ".env.gcp-production-eu"). Those values are parsed and merged together to be used by the `mc-scripts compile-html` command.').option('--pr-number [string]', '(optional) A pull request number determining a scoped storage bucket for the deployment. Please use it carefully.').option('--mc-url [string]', '(optional) The MC URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--mc-api-url [string]', '(optional) The MC API URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--application-index-out-file [path]', '(optional) The name of the application index file.', {
1163
1013
  default: 'application.html'
1164
1014
  }).option('--application-index-upload-script-out-file [path]', '(optional) The name of the the application index upload script file.', {
1165
1015
  default: 'upload-index.sh'
@@ -1171,15 +1021,15 @@ const run = async () => {
1171
1021
  await command$3(options, cwd);
1172
1022
  });
1173
1023
  const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
1174
- cli.command('compile-menu', usageCompileMenu).usage(`compile-menu \n\n ${usageCompileMenu}`).option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file `.env.production` and a cloud-environment specific dotenv file (for example `.env.gcp-production-eu`). Those values are parsed and merged together to be used by the application config.').action(async options => {
1024
+ cli.command('compile-menu', usageCompileMenu).usage("compile-menu \n\n ".concat(usageCompileMenu)).option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file `.env.production` and a cloud-environment specific dotenv file (for example `.env.gcp-production-eu`). Those values are parsed and merged together to be used by the application config.').action(async options => {
1175
1025
  await command$2(options, cwd);
1176
1026
  });
1177
1027
  const usageValidateMenu = 'Validate compiled `menu.json` file';
1178
- cli.command('validate-menu', usageValidateMenu).usage(`validate-menu \n\n ${usageValidateMenu}`).option('--input-file <path>', '(required) The path to the `menu.json` file to be validated.').option('--navigation [string]', '(optional) Location of the menu navigation. Possible values are `top`.').action(async options => {
1028
+ cli.command('validate-menu', usageValidateMenu).usage("validate-menu \n\n ".concat(usageValidateMenu)).option('--input-file <path>', '(required) The path to the `menu.json` file to be validated.').option('--navigation [string]', '(optional) Location of the menu navigation. Possible values are `top`.').action(async options => {
1179
1029
  await command(options);
1180
1030
  });
1181
1031
  const usageCreateVersion = 'Output a JSON string about the information in the `version.json` for a deployment, including the updated list of rollbacks.';
1182
- cli.command('create-version', usageCreateVersion).usage(`create-version \n\n ${usageCreateVersion}`).option('--version-url <url>', "(required) The path of an application's current `version.json` within the storage bucket.").option('--rollbacks [int]', '(optional) The number of max rollbacks to keep', {
1032
+ cli.command('create-version', usageCreateVersion).usage("create-version \n\n ".concat(usageCreateVersion)).option('--version-url <url>', "(required) The path of an application's current `version.json` within the storage bucket.").option('--rollbacks [int]', '(optional) The number of max rollbacks to keep', {
1183
1033
  default: 15
1184
1034
  }).option('--out-file [path]', '(optional) The path to the file where to write the JSON. If not specified, the JSON is printed to stdout.').action(async options => {
1185
1035
  await command$1(options);