@commercetools-frontend/application-cli 7.0.0 → 7.2.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.
@@ -13,12 +13,11 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
13
13
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
14
14
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
15
15
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
16
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
17
16
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
18
17
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
19
18
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
20
19
  var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
21
- var storageBucketsConfig = require('../../dist/storage-buckets-config-eb422a27.cjs.prod.js');
20
+ var storageBucketsConfig = require('../../dist/storage-buckets-config-09739a58.cjs.prod.js');
22
21
  var fs = require('node:fs');
23
22
  var path$1 = require('node:path');
24
23
  var listr2 = require('listr2');
@@ -49,6 +48,7 @@ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/i
49
48
  var micromatch = require('micromatch');
50
49
  var snakeCase = require('lodash/snakeCase');
51
50
  var jsonschema = require('jsonschema');
51
+ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
52
52
  require('cosmiconfig');
53
53
  require('ts-deepmerge');
54
54
  require('lodash');
@@ -63,7 +63,6 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
63
63
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
64
64
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
65
65
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
66
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
67
66
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
68
67
  var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
69
68
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
@@ -100,7 +99,7 @@ function isCI() {
100
99
  }
101
100
 
102
101
  function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
103
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$4(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$4(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
102
+ 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__default["default"](_context3 = ownKeys$4(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$4(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
104
103
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
105
104
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
106
105
  function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
@@ -134,7 +133,7 @@ let StorageProvider = /*#__PURE__*/function () {
134
133
  value: function getBucketNamespace(prNumber) {
135
134
  if (!prNumber) return;
136
135
  if (prNumber === 'merchant-center-preview') return prNumber;
137
- return "mc-".concat(prNumber);
136
+ return `mc-${prNumber}`;
138
137
  }
139
138
 
140
139
  /**
@@ -143,7 +142,7 @@ let StorageProvider = /*#__PURE__*/function () {
143
142
  }, {
144
143
  key: "getAssetsBucketUrl",
145
144
  value: function getAssetsBucketUrl(_ref) {
146
- var _storageProvider$urls, _storageProvider$urls2, _context, _context2;
145
+ var _context;
147
146
  let applicationName = _ref.applicationName,
148
147
  bucketProtocol = _ref.bucketProtocol,
149
148
  bucketNamespace = _ref.bucketNamespace,
@@ -152,14 +151,13 @@ let StorageProvider = /*#__PURE__*/function () {
152
151
  throw new Error("'bucketRegion' is not defined. Required to determine 'assetsBucketUrl'.");
153
152
  }
154
153
  const storageProvider = storageBucketsConfig.storageProviders[tag];
155
- 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];
154
+ const assetBuketUrl = storageProvider.urls.bucket?.[_classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1]] ?? _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1];
156
155
  const assetsBucketUrl = _filterInstanceProperty__default["default"](_context = [assetBuketUrl, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
157
- return _concatInstanceProperty__default["default"](_context2 = "".concat(bucketProtocol)).call(_context2, assetsBucketUrl);
156
+ return `${bucketProtocol}${assetsBucketUrl}`;
158
157
  }
159
158
  }, {
160
159
  key: "getApplicationIndexBucketUrl",
161
160
  value: function getApplicationIndexBucketUrl(_ref2) {
162
- var _context3;
163
161
  let tag = _ref2.tag,
164
162
  prNumber = _ref2.prNumber,
165
163
  applicationName = _ref2.applicationName,
@@ -172,31 +170,29 @@ let StorageProvider = /*#__PURE__*/function () {
172
170
  bucketProtocol,
173
171
  bucketNamespace
174
172
  });
175
- const applicationIndexBucketUrl = _concatInstanceProperty__default["default"](_context3 = "".concat(applicationAssetsBucketUrl, "/")).call(_context3, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]);
173
+ const applicationIndexBucketUrl = `${applicationAssetsBucketUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]}`;
176
174
  return applicationIndexBucketUrl;
177
175
  }
178
176
  }, {
179
177
  key: "getCdnUrl",
180
178
  value: function getCdnUrl(_ref3) {
181
- var _context4;
179
+ var _context2;
182
180
  let applicationName = _ref3.applicationName,
183
181
  prNumber = _ref3.prNumber,
184
182
  publicBaseUrl = _ref3.publicBaseUrl,
185
183
  excludeBucketRegion = _ref3.excludeBucketRegion;
186
- return _filterInstanceProperty__default["default"](_context4 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context4, Boolean).join('/');
184
+ return _filterInstanceProperty__default["default"](_context2 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context2, Boolean).join('/');
187
185
  }
188
186
  }, {
189
187
  key: "getPublicBaseUrl",
190
188
  value: function getPublicBaseUrl(tag) {
191
- var _storageProvider$urls3;
192
189
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
193
190
  throw new Error("'bucketEnvironment' is not defined. Required to determine 'publicBaseUrl'.");
194
191
  }
195
192
  const storageProvider = storageBucketsConfig.storageProviders[tag];
196
- const publicBaseUrl = (_storageProvider$urls3 = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]) !== null && _storageProvider$urls3 !== void 0 ? _storageProvider$urls3 : storageProvider.urls.public.default;
193
+ const publicBaseUrl = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]] ?? storageProvider.urls.public.default;
197
194
  if (!publicBaseUrl) {
198
- var _context5;
199
- throw new Error(_concatInstanceProperty__default["default"](_context5 = "'publicBaseUrl' is not defined for '".concat(tag, "' storage provider for ")).call(_context5, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1], " or as default."));
195
+ throw new Error(`'publicBaseUrl' is not defined for '${tag}' storage provider for ${_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]} or as default.`);
200
196
  }
201
197
  return publicBaseUrl;
202
198
  }
@@ -354,7 +350,7 @@ function getStorageProvider(storageProvider, config) {
354
350
  case 's3':
355
351
  return new AwsStorageProvider(config);
356
352
  default:
357
- throw new Error("Storage provider ".concat(storageProvider, " not supported"));
353
+ throw new Error(`Storage provider ${storageProvider} not supported`);
358
354
  }
359
355
  }
360
356
 
@@ -377,7 +373,6 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
377
373
  return _createClass(GoogleStorageUploadScriptsGenerator, [{
378
374
  key: "getApplicationIndexUploadScript",
379
375
  value: function getApplicationIndexUploadScript(_ref) {
380
- var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context0;
381
376
  let packageManagerName = _ref.packageManagerName,
382
377
  bucketUrl = _ref.bucketUrl,
383
378
  cdnUrl = _ref.cdnUrl,
@@ -387,16 +382,138 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
387
382
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
388
383
  throw new Error("Missing 'bucketEnvironment' when generating application index.");
389
384
  }
390
- return _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = _concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = _concatInstanceProperty__default["default"](_context0 = "\n#!/usr/bin/env bash\n\nset -e\n\necho \"Uploading compiled ".concat(applicationIndexOutFile, " to Google Storage bucket ")).call(_context0, 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");
385
+ return `
386
+ #!/usr/bin/env bash
387
+
388
+ set -e
389
+
390
+ echo "Uploading compiled ${applicationIndexOutFile} to Google Storage bucket ${bucketUrl}"
391
+
392
+ gcloud storage cp \\
393
+ "$(dirname "$0")/${applicationIndexOutFile}" \\
394
+ "${bucketUrl}/" \\
395
+ -z html \\
396
+ --content-type="text/html" \\
397
+ --cache-control="public,max-age=0,no-transform"
398
+
399
+ echo "Creating version.json and uploading it to bucket ${bucketUrl}"
400
+
401
+ NODE_ENV=production ${packageManagerName} application-cli create-version \\
402
+ --version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
403
+ --build-revision=${buildRevision} \\
404
+ --build-number=${buildNumber} \\
405
+ --out-file=$(dirname "$0")/version.json
406
+
407
+ gcloud storage cp \\
408
+ "$(dirname "$0")/version.json" \\
409
+ "${bucketUrl}/" \\
410
+ -z json \\
411
+ --content-type="application/json" \\
412
+ --cache-control="public,max-age=0,no-transform"
413
+ `;
391
414
  }
392
415
  }, {
393
416
  key: "getProductionBundlesUploadScript",
394
417
  value: function getProductionBundlesUploadScript(_ref2) {
395
- var _context1, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19;
396
418
  let bucketUrl = _ref2.bucketUrl,
397
419
  assetsPath = _ref2.assetsPath,
398
420
  skipMenu = _ref2.skipMenu;
399
- return _concatInstanceProperty__default["default"](_context1 = _concatInstanceProperty__default["default"](_context10 = _concatInstanceProperty__default["default"](_context11 = _concatInstanceProperty__default["default"](_context12 = _concatInstanceProperty__default["default"](_context13 = _concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = _concatInstanceProperty__default["default"](_context16 = _concatInstanceProperty__default["default"](_context17 = _concatInstanceProperty__default["default"](_context18 = _concatInstanceProperty__default["default"](_context19 = "\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\n# List of required file types\nrequired_files=(\"*.css\" \"*.js\" \"*.js.map\" \"*.html\")\n\n# List of optional file types\noptional_files=(\"*.svg\")\n\n# Check for the existence of required files\nfor file_pattern in \"${required_files[@]}\"; do\n if ! find \"")).call(_context19, assetsPath, "/public\" -type f -name \"$file_pattern\" -print -quit | grep -q .; then\n echo \"Error: No required files matching $file_pattern found in ")).call(_context18, assetsPath, "/public.\"\n exit 1\n fi\ndone\n\n# Initialize source_pattern with required files\nsource_pattern=\"")).call(_context17, assetsPath, "/public/{$(IFS=,; echo \"${required_files[*]}\")\"\n\n# Check for optional files and add them to the source_pattern if they exist\nfor file_pattern in \"${optional_files[@]}\"; do\n if find \"")).call(_context16, assetsPath, "/public\" -type f -name \"$file_pattern\" -print -quit | grep -q .; then\n source_pattern+=\",${file_pattern}\"\n fi\ndone\n\n# Close the brace in source_pattern\nsource_pattern+=\"}\"\n\necho \"Uploading files using the following pattern: ${source_pattern}\"\n\n# Expand the source_pattern variable as the below command will not work if the variable is a string\nexpanded_source_pattern=$(eval echo $source_pattern)\n\ngcloud storage cp \\\n $expanded_source_pattern \\\n \"")).call(_context15, 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(_context14, assetsPath, "/public/{*.png,robots.txt} \\\n \"")).call(_context13, bucketUrl, "\" \\\n -z txt \\\n --cache-control=\"public,max-age=31536000,no-transform\"\n\nif ")).call(_context12, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context11, 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(_context10, assetsPath, "/menu.json \\\n ")).call(_context1, bucketUrl, " \\\n -z json \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\"\nfi\n");
421
+ return `
422
+ #!/usr/bin/env bash
423
+
424
+ set -e
425
+
426
+ # NOTES:
427
+ # https://cloud.google.com/sdk/gcloud/reference/storage/cp
428
+ # 1. The '-z' option triggers compressing the assets before
429
+ # uploading them and sets the 'Content-Encoding' to 'gzip'.
430
+ # 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.
431
+ # 3. The 'max-age' is set to 1 year which is considered the maximum
432
+ # "valid" lifetime of an asset to be cached.
433
+ # 4. The '-n' will skip uploading existing files and prevents them to
434
+ # be overwritten
435
+ echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
436
+
437
+ # List of required file types
438
+ required_files=("*.css" "*.js" "*.js.map" "*.html")
439
+
440
+ # List of optional file types
441
+ optional_files=("*.svg")
442
+
443
+ # Check for the existence of required files
444
+ for file_pattern in "\${required_files[@]}"; do
445
+ if ! find "${assetsPath}/public" -type f -name "$file_pattern" -print -quit | grep -q .; then
446
+ echo "Error: No required files matching $file_pattern found in ${assetsPath}/public."
447
+ exit 1
448
+ fi
449
+ done
450
+
451
+ # Initialize source_pattern with required files
452
+ source_pattern="${assetsPath}/public/{$(IFS=,; echo "\${required_files[*]}")"
453
+
454
+ # Check for optional files and add them to the source_pattern if they exist
455
+ for file_pattern in "\${optional_files[@]}"; do
456
+ if find "${assetsPath}/public" -type f -name "$file_pattern" -print -quit | grep -q .; then
457
+ source_pattern+=",\${file_pattern}"
458
+ fi
459
+ done
460
+
461
+ # Close the brace in source_pattern
462
+ source_pattern+="}"
463
+
464
+ echo "Uploading files using the following pattern: \${source_pattern}"
465
+
466
+ # Expand the source_pattern variable as the below command will not work if the variable is a string
467
+ expanded_source_pattern=$(eval echo $source_pattern)
468
+
469
+ gcloud storage cp \\
470
+ $expanded_source_pattern \\
471
+ "${bucketUrl}" \\
472
+ -n \\
473
+ -z js,css \\
474
+ --cache-control="public,max-age=31536000,no-transform"
475
+
476
+ # We need to upload the PNG and HTML files separately because we want them
477
+ # to be able to overwrite the existing files (if any). For instance, the
478
+ # file or the favicons.
479
+ # This is controlled with the '-n' option (which is used for the JS and CSS
480
+ # as we don't want to overwrite them)
481
+ gcloud storage cp \\
482
+ ${assetsPath}/public/{*.png,robots.txt} \\
483
+ "${bucketUrl}" \\
484
+ -z txt \\
485
+ --cache-control="public,max-age=31536000,no-transform"
486
+
487
+ if ${skipMenu}; then
488
+ echo "Skipping menu.json upload"
489
+ else
490
+ echo "Uploading menu.json to bucket ${bucketUrl}"
491
+ # NOTE: somehow the 'cache-control:private' doesn't work.
492
+ # I mean, the file is uploaded with the correct metadata but when I fetch
493
+ # the file the response contains the header
494
+ # 'cache-control: public,max-age=31536000,no-transform', even though the
495
+ # documentation clearly states that by marking the header as 'private' will
496
+ # disable the cache (for publicly readable objects).
497
+ # https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
498
+ # However, I found out that, by requesting the file with any RANDOM
499
+ # query parameter, will instruct the storage to return a 'fresh' object
500
+ # (without any cache control).
501
+ # Unofficial source: https://stackoverflow.com/a/49052895
502
+ # This seems to be the 'easiest' option to 'disable' the cache for public
503
+ # objects. Other alternative approaces are:
504
+ # * make the object private with some simple ACL (private objects are not cached)
505
+ # * suffix the file name with e.g. the git SHA, so we have different files
506
+ # for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
507
+ # the git SHA on runtime and can get the correct file when it starts.
508
+ # * find out why the 'private' cache control does not work
509
+ gcloud storage cp \\
510
+ ${assetsPath}/menu.json \\
511
+ ${bucketUrl} \\
512
+ -z json \\
513
+ --content-type="application/json" \\
514
+ --cache-control="public,max-age=0,no-transform"
515
+ fi
516
+ `;
400
517
  }
401
518
  }]);
402
519
  }();
@@ -419,23 +536,104 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
419
536
  return _createClass(AwsStorageUploadScriptsGenerator, [{
420
537
  key: "getApplicationIndexUploadScript",
421
538
  value: function getApplicationIndexUploadScript(_ref3) {
422
- var _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30;
423
539
  let packageManagerName = _ref3.packageManagerName,
424
540
  bucketUrl = _ref3.bucketUrl,
425
541
  cdnUrl = _ref3.cdnUrl,
426
542
  buildRevision = _ref3.buildRevision,
427
543
  buildNumber = _ref3.buildNumber,
428
544
  applicationIndexOutFile = _ref3.applicationIndexOutFile;
429
- return _concatInstanceProperty__default["default"](_context20 = _concatInstanceProperty__default["default"](_context21 = _concatInstanceProperty__default["default"](_context22 = _concatInstanceProperty__default["default"](_context23 = _concatInstanceProperty__default["default"](_context24 = _concatInstanceProperty__default["default"](_context25 = _concatInstanceProperty__default["default"](_context26 = _concatInstanceProperty__default["default"](_context27 = _concatInstanceProperty__default["default"](_context28 = _concatInstanceProperty__default["default"](_context29 = _concatInstanceProperty__default["default"](_context30 = "\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(_context30, applicationIndexOutFile, "\" \\\n \"")).call(_context29, bucketUrl, "/\" \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context28, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n echo \"Creating version.json and uploading it to bucket ")).call(_context27, bucketUrl, "\"\n\n NODE_ENV=production ")).call(_context26, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context25, cdnUrl, "/")).call(_context24, _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2], "/version.json \\\n --build-revision=")).call(_context23, buildRevision, " \\\n --build-number=")).call(_context22, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\n aws s3 cp \"$(dirname \"$0\")/version.json\" \\\n \"")).call(_context21, bucketUrl, "/\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context20, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n");
545
+ return `
546
+ #!/usr/bin/env bash
547
+
548
+ echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
549
+
550
+ set -e
551
+
552
+ aws s3 cp "$(dirname "$0")/${applicationIndexOutFile}" \\
553
+ "${bucketUrl}/" \\
554
+ --content-type="text/html" \\
555
+ --cache-control="public,max-age=0,no-transform" \\
556
+ --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
557
+
558
+ echo "Creating version.json and uploading it to bucket ${bucketUrl}"
559
+
560
+ NODE_ENV=production ${packageManagerName} application-cli create-version \\
561
+ --version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2]}/version.json \\
562
+ --build-revision=${buildRevision} \\
563
+ --build-number=${buildNumber} \\
564
+ --out-file=$(dirname "$0")/version.json
565
+
566
+ aws s3 cp "$(dirname "$0")/version.json" \\
567
+ "${bucketUrl}/" \\
568
+ --content-type="application/json" \\
569
+ --cache-control="public,max-age=0,no-transform" \\
570
+ --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
571
+ `;
430
572
  }
431
573
  }, {
432
574
  key: "getProductionBundlesUploadScript",
433
575
  value: function getProductionBundlesUploadScript(_ref4) {
434
- var _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40, _context41, _context42, _context43;
435
576
  let bucketUrl = _ref4.bucketUrl,
436
577
  assetsPath = _ref4.assetsPath,
437
578
  skipMenu = _ref4.skipMenu;
438
- return _concatInstanceProperty__default["default"](_context31 = _concatInstanceProperty__default["default"](_context32 = _concatInstanceProperty__default["default"](_context33 = _concatInstanceProperty__default["default"](_context34 = _concatInstanceProperty__default["default"](_context35 = _concatInstanceProperty__default["default"](_context36 = _concatInstanceProperty__default["default"](_context37 = _concatInstanceProperty__default["default"](_context38 = _concatInstanceProperty__default["default"](_context39 = _concatInstanceProperty__default["default"](_context40 = _concatInstanceProperty__default["default"](_context41 = _concatInstanceProperty__default["default"](_context42 = _concatInstanceProperty__default["default"](_context43 = "\n#!/usr/bin/env bash\n\necho \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\nset -e\n\n# Check for the existence of the application required files types\nif ! find \"")).call(_context43, assetsPath, "\" -type f -regex \".*\\.\\(css\\|js\\|html\\)\" | grep -q .; then\n echo \"Error: No CSS, JS, or HTML files found in ")).call(_context42, assetsPath, ".\"\n exit 1\nfi\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(_context41, assetsPath, "/public \\\n \"")).call(_context40, bucketUrl, "\" \\\n --exclude \"*\" \\\n --include \"*.css\" \\\n --include \"*.js\" \\\n --include \"*.js.map\" \\\n --include \"*.html\" \\\n --include \"*.svg\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context39, _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(_context38, assetsPath, "/public \\\n \"")).call(_context37, bucketUrl, "\" \\\n --recursive \\\n --exclude \"*\" \\\n --include \"*.png\" \\\n --include \"robots.txt\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context36, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\nif ")).call(_context35, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context34, bucketUrl, "\"\n\n aws s3 cp ")).call(_context33, assetsPath, "/menu.json \\\n \"")).call(_context32, bucketUrl, "/\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context31, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\nfi\n");
579
+ return `
580
+ #!/usr/bin/env bash
581
+
582
+ echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
583
+
584
+ set -e
585
+
586
+ # Check for the existence of the application required files types
587
+ if ! find "${assetsPath}" -type f -regex ".*\\.\\(css\\|js\\|html\\)" | grep -q .; then
588
+ echo "Error: No CSS, JS, or HTML files found in ${assetsPath}."
589
+ exit 1
590
+ fi
591
+
592
+ # NOTE:
593
+ # The sync command on the AWS CLI is different to the -n option on the gcloud CLI.
594
+ # Sync will only upload files that are not already in the bucket, but it will skip existing ones
595
+ # that have been changed locally.
596
+ # The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.
597
+ # https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
598
+ # https://cloud.google.com/sdk/gcloud/reference/storage/cp
599
+ #
600
+ # Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.
601
+ # https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring
602
+ aws s3 sync ${assetsPath}/public \\
603
+ "${bucketUrl}" \\
604
+ --exclude "*" \\
605
+ --include "*.css" \\
606
+ --include "*.js" \\
607
+ --include "*.js.map" \\
608
+ --include "*.html" \\
609
+ --include "*.svg" \\
610
+ --cache-control="public,max-age=31536000,no-transform" \\
611
+ --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
612
+
613
+ # We need to upload the PNG and HTML files separately because we want them
614
+ # to be able to overwrite the existing files (if any). For instance, the
615
+ # file or the favicons.
616
+ aws s3 cp ${assetsPath}/public \\
617
+ "${bucketUrl}" \\
618
+ --recursive \\
619
+ --exclude "*" \\
620
+ --include "*.png" \\
621
+ --include "robots.txt" \\
622
+ --cache-control="public,max-age=31536000,no-transform" \\
623
+ --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
624
+
625
+ if ${skipMenu}; then
626
+ echo "Skipping menu.json upload"
627
+ else
628
+ echo "Uploading menu.json to bucket ${bucketUrl}"
629
+
630
+ aws s3 cp ${assetsPath}/menu.json \\
631
+ "${bucketUrl}/" \\
632
+ --content-type="application/json" \\
633
+ --cache-control="public,max-age=0,no-transform" \\
634
+ --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
635
+ fi
636
+ `;
439
637
  }
440
638
  }]);
441
639
  }();
@@ -446,7 +644,7 @@ function getUploadScriptsGenerator(storageProvider, config) {
446
644
  case 's3':
447
645
  return new AwsStorageUploadScriptsGenerator(config);
448
646
  default:
449
- throw new Error("Storage provider ".concat(storageProvider, " not supported"));
647
+ throw new Error(`Storage provider ${storageProvider} not supported`);
450
648
  }
451
649
  }
452
650
 
@@ -460,7 +658,7 @@ function doesFileExist(filePath) {
460
658
  }
461
659
 
462
660
  function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
463
- 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__default["default"](_context3 = ownKeys$3(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$3(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
661
+ 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__default["default"](_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
464
662
  function loadDotenvFiles(_ref) {
465
663
  let dotenvPath = _ref.dotenvPath,
466
664
  cloudEnvironment = _ref.cloudEnvironment;
@@ -471,12 +669,12 @@ function loadDotenvFiles(_ref) {
471
669
 
472
670
  // Check if the given path exists.
473
671
  if (!doesFileExist(dotenvPath)) {
474
- throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
672
+ throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
475
673
  }
476
674
 
477
675
  // Load the environment values
478
676
  const sharedDotenvFile = '.env.production';
479
- const cloudDotenvFile = ".env.".concat(cloudEnvironment);
677
+ const cloudDotenvFile = `.env.${cloudEnvironment}`;
480
678
 
481
679
  // The shared dotenv file across environments is optional
482
680
  const sharedProductionEnvironment = dotenv__default["default"].config({
@@ -488,18 +686,16 @@ function loadDotenvFiles(_ref) {
488
686
  path: path__default["default"].join(dotenvPath, cloudDotenvFile)
489
687
  });
490
688
  if (cloudSpecificProductionEnvironment.error) {
491
- var _context;
492
- throw new Error(_concatInstanceProperty__default["default"](_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
689
+ throw new Error(`Failed loading '${cloudDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
493
690
  }
494
691
  if (sharedProductionEnvironment.error) {
495
- var _context2;
496
- throw new Error(_concatInstanceProperty__default["default"](_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
692
+ throw new Error(`Failed loading '${sharedDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
497
693
  }
498
694
  return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
499
695
  }
500
696
 
501
697
  function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
502
- 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__default["default"](_context5 = ownKeys$2(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$2(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
698
+ 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__default["default"](_context3 = ownKeys$2(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$2(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
503
699
  function writeUploadScriptFile(_ref) {
504
700
  let fileName = _ref.fileName,
505
701
  fileContent = _ref.fileContent,
@@ -511,7 +707,6 @@ function writeUploadScriptFile(_ref) {
511
707
  });
512
708
  }
513
709
  async function compileApplicationAssets(_ref2) {
514
- var _context, _context2;
515
710
  let cliFlags = _ref2.cliFlags,
516
711
  storageProvider = _ref2.storageProvider,
517
712
  uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
@@ -526,7 +721,7 @@ async function compileApplicationAssets(_ref2) {
526
721
  skipMenu: cliFlags.skipMenu
527
722
  });
528
723
  const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
529
- const applicationAssetsUploadScriptFileName = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
724
+ const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${storageProvider.getBucketRegion()}${parsedApplicationAssetsUploadScriptFile.ext}`;
530
725
  writeUploadScriptFile({
531
726
  fileName: applicationAssetsUploadScriptFileName,
532
727
  fileContent: applicationAssetsUploadScriptContent,
@@ -559,7 +754,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
559
754
  })), {}, {
560
755
  // The trailing slash is important to indicate to the CSP directive that all the resources
561
756
  // under that path should be allowed.
562
- MC_CDN_URL: "".concat(cdnUrl, "/")
757
+ MC_CDN_URL: `${cdnUrl}/`
563
758
  }, cliFlags.mcUrl ? {
564
759
  MC_URL: cliFlags.mcUrl
565
760
  } : {}), cliFlags.mcApiUrl ? {
@@ -616,7 +811,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
616
811
  }
617
812
  }
618
813
  async function command$4(cliFlags, cwd) {
619
- var _context3;
814
+ var _context;
620
815
  const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
621
816
  const applicationDirectory = getApplicationDirectory(cwd);
622
817
  let assetsPath;
@@ -633,12 +828,12 @@ async function command$4(cliFlags, cwd) {
633
828
  assetsPath
634
829
  };
635
830
  const defaultStorageProviders = [storageBucketsConfig.storageProviders.gs.tag];
636
- const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](storageBucketConfig)).call(_context3, _ref4 => {
831
+ const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](storageBucketConfig)).call(_context, _ref4 => {
637
832
  let _ref5 = _slicedToArray(_ref4, 2),
638
833
  bucketRegion = _ref5[0],
639
834
  bucketEnvironmentConfigs = _ref5[1];
640
835
  return {
641
- title: "Compiling for bucket region ".concat(bucketRegion),
836
+ title: `Compiling for bucket region ${bucketRegion}`,
642
837
  task: (_bucketRegionCtx, bucketRegionTask) => {
643
838
  // NOTE: Application assets need to be compiled
644
839
  // for all storage providers once per region.
@@ -653,7 +848,7 @@ async function command$4(cliFlags, cwd) {
653
848
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
654
849
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
655
850
  return {
656
- title: "Compiling application assets for '".concat(storageProviderTag, "'"),
851
+ title: `Compiling application assets for '${storageProviderTag}'`,
657
852
  task: () => compileApplicationAssets({
658
853
  cliFlags,
659
854
  storageProvider,
@@ -671,14 +866,14 @@ async function command$4(cliFlags, cwd) {
671
866
  bucketEnvironment
672
867
  };
673
868
  return {
674
- title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
869
+ title: `Compiling for cloud environment '${cloudEnvironment}'`,
675
870
  task: (_storageProviderCtx, storageProviderTask) => {
676
- var _context4;
677
- const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
871
+ var _context2;
872
+ const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context2 = storageProviders || defaultStorageProviders).call(_context2, storageProviderTag => {
678
873
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
679
874
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
680
875
  return {
681
- title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
876
+ title: `Compiling application index for storage provider '${storageProviderTag}'`,
682
877
  task: () => {
683
878
  return compileEnvironmentApplicationIndexes({
684
879
  cliFlags,
@@ -734,58 +929,48 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
734
929
  */
735
930
 
736
931
  const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
737
- var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
932
+ var _context2;
738
933
  const entryPointUriPath = config.env.entryPointUriPath;
739
934
 
740
935
  // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
741
- 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 : [];
936
+ const accountLinks = config.env.__DEVELOPMENT__?.accountLinks ?? [];
742
937
  if (accountLinks.length > 0) {
743
- return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => {
744
- var _menuLink$permissions, _menuLink$featureTogg;
745
- return {
746
- key: menuLink.uriPath,
747
- uriPath: menuLink.uriPath,
748
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
749
- permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
750
- // @ts-ignore: not defined in schema, as it's only used internally.
751
- featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
752
- };
753
- });
938
+ return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => ({
939
+ key: menuLink.uriPath,
940
+ uriPath: menuLink.uriPath,
941
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
942
+ permissions: menuLink.permissions ?? [],
943
+ // @ts-ignore: not defined in schema, as it's only used internally.
944
+ featureToggle: menuLink.featureToggle ?? null
945
+ }));
754
946
  }
755
- const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
947
+ const menuLinks = config.env.__DEVELOPMENT__?.menuLinks;
756
948
  return {
757
949
  key: entryPointUriPath,
758
950
  uriPath: entryPointUriPath,
759
951
  icon: menuLinks.icon,
760
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
952
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks?.labelAllLocales, menuLinks?.defaultLabel),
761
953
  permissions: menuLinks.permissions,
762
954
  // @ts-ignore: not defined in schema, as it's only used internally.
763
- featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
764
- // @ts-ignore: not defined in schema, as it's only used internally.
765
- menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
955
+ featureToggle: menuLinks.featureToggle ?? null,
766
956
  // @ts-ignore: not defined in schema, as it's only used internally.
767
- actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
957
+ actionRights: menuLinks.actionRights ?? null,
768
958
  // @ts-ignore: not defined in schema, as it's only used internally.
769
- dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
770
- submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
771
- var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
772
- return {
773
- key: submenuLink.uriPath.replace('/', '-'),
774
- uriPath: submenuLink.uriPath,
775
- labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
776
- permissions: submenuLink.permissions,
777
- // @ts-ignore: not defined in schema, as it's only used internally.
778
- featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
779
- // @ts-ignore: not defined in schema, as it's only used internally.
780
- menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
781
- // @ts-ignore: not defined in schema, as it's only used internally.
782
- actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
783
- // @ts-ignore: not defined in schema, as it's only used internally.
784
- dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
785
- };
786
- }),
959
+ dataFences: menuLinks.dataFences ?? null,
960
+ submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => ({
961
+ key: submenuLink.uriPath.replace('/', '-'),
962
+ uriPath: submenuLink.uriPath,
963
+ labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
964
+ permissions: submenuLink.permissions,
965
+ // @ts-ignore: not defined in schema, as it's only used internally.
966
+ featureToggle: submenuLink.featureToggle ?? null,
967
+ // @ts-ignore: not defined in schema, as it's only used internally.
968
+ actionRights: submenuLink.actionRights ?? null,
969
+ // @ts-ignore: not defined in schema, as it's only used internally.
970
+ dataFences: submenuLink.dataFences ?? null
971
+ })),
787
972
  // @ts-ignore: not defined in schema, as it's only used internally.
788
- shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
973
+ shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
789
974
  };
790
975
  };
791
976
  async function command$3(cliFlags, cwd) {
@@ -865,51 +1050,43 @@ async function command$2(cliFlags) {
865
1050
  */
866
1051
  const git = {
867
1052
  // https://git-scm.com/docs/git-merge-base
868
- base: (baseBranch, headRevision) => {
869
- var _context;
870
- return _concatInstanceProperty__default["default"](_context = "git merge-base ".concat(baseBranch, " ")).call(_context, headRevision);
871
- },
1053
+ base: (baseBranch, headRevision) => `git merge-base ${baseBranch} ${headRevision}`,
872
1054
  // https://git-scm.com/docs/git-diff
873
- changedFiles: (mergeRevision, headRevision) => {
874
- var _context2;
875
- return _concatInstanceProperty__default["default"](_context2 = "git diff --name-only ".concat(mergeRevision, " ")).call(_context2, headRevision);
876
- },
877
- commitMessage: headRevision => "git log --format=oneline -n 1 ".concat(headRevision)
1055
+ changedFiles: (mergeRevision, headRevision) => `git diff --name-only ${mergeRevision} ${headRevision}`,
1056
+ commitMessage: headRevision => `git log --format=oneline -n 1 ${headRevision}`
878
1057
  };
879
1058
  const helpers = {
880
1059
  async writeOutDotEnvFile(cliFlags, cwd, matchingTriggers) {
881
- var _context3;
1060
+ var _context;
882
1061
  // If desired read the env file and write out the matching triggers.
883
1062
  if (!cliFlags.outEnvFile) {
884
1063
  return;
885
1064
  }
886
1065
  const filePath = path__default$1["default"].join(fs__default["default"].realpathSync(cwd), cliFlags.outEnvFile);
887
- const fileContents = _mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](matchingTriggers)).call(_context3, _ref => {
888
- var _context5;
1066
+ const fileContents = _mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](matchingTriggers)).call(_context, _ref => {
889
1067
  let _ref2 = _slicedToArray(_ref, 2),
890
1068
  triggerName = _ref2[0],
891
1069
  triggerValue = _ref2[1];
892
- const triggerNameForEnvFile = "".concat(snakeCase__default["default"](triggerName).toUpperCase());
1070
+ const triggerNameForEnvFile = `${snakeCase__default["default"](triggerName).toUpperCase()}`;
893
1071
 
894
1072
  // General pipeline optimization hints are not transformed
895
1073
  if (_startsWithInstanceProperty__default["default"](triggerName).call(triggerName, 'allowPipelineOptimizations')) {
896
- var _context4;
897
- return _concatInstanceProperty__default["default"](_context4 = "".concat(triggerNameForEnvFile, "=")).call(_context4, triggerValue);
1074
+ return `${triggerNameForEnvFile}=${triggerValue}`;
898
1075
  }
899
- return _concatInstanceProperty__default["default"](_context5 = "DID_".concat(triggerNameForEnvFile, "_CHANGE=")).call(_context5, triggerValue);
1076
+ return `DID_${triggerNameForEnvFile}_CHANGE=${triggerValue}`;
900
1077
  }).join('\n');
901
1078
  await fs__default["default"].promises.writeFile(filePath, fileContents);
902
1079
  if (!cliFlags.silent) {
903
- console.log("\uD83D\uDCDD Wrote out file to '".concat(filePath, "' with contents:"));
1080
+ console.log(`📝 Wrote out file to '${filePath}' with contents:`);
904
1081
  console.log(fileContents);
905
1082
  }
906
1083
  },
907
1084
  async getChangedFiles(cliFlags) {
908
- var _context6, _context7;
1085
+ var _context2, _context3;
909
1086
  const baseCmdResult = await execa.command(git.base(cliFlags.baseBranch, cliFlags.headRevision));
910
1087
  const mergeRevision = baseCmdResult.stdout;
911
1088
  const changedFilesCmdResult = await execa.command(git.changedFiles(mergeRevision, cliFlags.headRevision));
912
- const changedFiles = _filterInstanceProperty__default["default"](_context6 = _mapInstanceProperty__default["default"](_context7 = changedFilesCmdResult.stdout.split('\n')).call(_context7, filePath => _trimInstanceProperty__default["default"](filePath).call(filePath))).call(_context6, filePath => filePath.length > 0);
1089
+ const changedFiles = _filterInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](_context3 = changedFilesCmdResult.stdout.split('\n')).call(_context3, filePath => _trimInstanceProperty__default["default"](filePath).call(filePath))).call(_context2, filePath => filePath.length > 0);
913
1090
  return changedFiles;
914
1091
  },
915
1092
  async matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles) {
@@ -917,7 +1094,6 @@ const helpers = {
917
1094
 
918
1095
  // Evaluate each trigger against each file.
919
1096
  _forEachInstanceProperty__default["default"](config).call(config, async trigger => {
920
- var _trigger$exclude;
921
1097
  const hasTriggerBeenInitialized = typeof matchedTriggers[trigger.name] === 'number';
922
1098
 
923
1099
  // Given the trigger with this name was never evaluated it has to be defaulted to 0.
@@ -935,10 +1111,10 @@ const helpers = {
935
1111
  ignore: trigger.ignore
936
1112
  });
937
1113
  if (!cliFlags.silent && anyFileChangedForTrigger) {
938
- console.log("\u2139\uFE0F Files for trigger ".concat(trigger.name, " changed."));
1114
+ console.log(`ℹ️ Files for trigger ${trigger.name} changed.`);
939
1115
  }
940
1116
  let onlyExcludedFilesChangedForTrigger = false;
941
- if (((_trigger$exclude = trigger.exclude) === null || _trigger$exclude === void 0 ? void 0 : _trigger$exclude.length) > 0) {
1117
+ if (trigger.exclude?.length > 0) {
942
1118
  // NOTE: `micromatch.every` evaluates if every file matches
943
1119
  // every pattern.
944
1120
  // We need to evaluate if every file matches some pattern.
@@ -949,7 +1125,7 @@ const helpers = {
949
1125
  });
950
1126
  }
951
1127
  if (!cliFlags.silent && onlyExcludedFilesChangedForTrigger) {
952
- console.log("\u2139\uFE0F Only excluded files for trigger ".concat(trigger.name, " changed."));
1128
+ console.log(`ℹ️ Only excluded files for trigger ${trigger.name} changed.`);
953
1129
  }
954
1130
  if (onlyExcludedFilesChangedForTrigger) {
955
1131
  matchedTriggers[trigger.name] = 0;
@@ -966,19 +1142,18 @@ async function command$1(cliFlags, config, cwd) {
966
1142
  const isDevelopmentBranch = cliFlags.branch !== cliFlags.baseBranch;
967
1143
  const triggersContainingSharedFiles = _filterInstanceProperty__default["default"](config).call(config, trigger => trigger.containsSharedFiles);
968
1144
  if (!cliFlags.silent) {
969
- var _context8;
970
- console.log("\u2139\uFE0F Pipeline optimizations are ".concat(enablePipelineOptimizations ? 'enabled' : 'disabled', "."));
971
- console.log("\u2139\uFE0F Changes have been commited to the ".concat(isDevelopmentBranch ? 'a development' : 'the main', " branch."));
972
- console.log(_concatInstanceProperty__default["default"](_context8 = "\uD83D\uDEA7 Comparing '".concat(cliFlags.baseBranch, "' against '")).call(_context8, cliFlags.headRevision, "' to determine changed files."));
1145
+ console.log(`ℹ️ Pipeline optimizations are ${enablePipelineOptimizations ? 'enabled' : 'disabled'}.`);
1146
+ console.log(`ℹ️ Changes have been commited to the ${isDevelopmentBranch ? 'a development' : 'the main'} branch.`);
1147
+ console.log(`🚧 Comparing '${cliFlags.baseBranch}' against '${cliFlags.headRevision}' to determine changed files.`);
973
1148
  }
974
1149
 
975
1150
  // Collect and parse changed files from git comparing base and head revision.
976
1151
  const changedFiles = await helpers.getChangedFiles(cliFlags);
977
1152
  if (!cliFlags.silent) {
978
1153
  if (changedFiles.length === 0) {
979
- console.log("\u2139\uFE0F No changes found.");
1154
+ console.log(`ℹ️ No changes found.`);
980
1155
  } else {
981
- console.log("\u2139\uFE0F ".concat(changedFiles.length, " changes found."));
1156
+ console.log(`ℹ️ ${changedFiles.length} changes found.`);
982
1157
  }
983
1158
  }
984
1159
 
@@ -989,17 +1164,17 @@ async function command$1(cliFlags, config, cwd) {
989
1164
  const hasCommitMessageTrigger = commitMessage && _includesInstanceProperty__default["default"](commitMessage).call(commitMessage, '[ci all]');
990
1165
  const doesSharedTriggerMatch = _someInstanceProperty__default["default"](triggersContainingSharedFiles).call(triggersContainingSharedFiles, triggerContainingSharedFiles => matchedTriggers[triggerContainingSharedFiles.name] === 1);
991
1166
  if (!cliFlags.silent) {
992
- console.log("\u2139\uFE0F The git commit message ".concat(hasCommitMessageTrigger ? 'does' : 'does not', " contain a [ci all] trigger."));
1167
+ console.log(`ℹ️ The git commit message ${hasCommitMessageTrigger ? 'does' : 'does not'} contain a [ci all] trigger.`);
993
1168
  }
994
1169
  const doesPackageFolderTriggerMatch = matchedTriggers[cliFlags.triggerName] === 1;
995
1170
  if (enablePipelineOptimizations && isDevelopmentBranch && !hasCommitMessageTrigger && !doesSharedTriggerMatch && !doesPackageFolderTriggerMatch) {
996
1171
  if (!cliFlags.silent) {
997
- console.log("\u2139\uFE0F No relevant changes found for ".concat(cliFlags.triggerName, "."));
1172
+ console.log(`ℹ️ No relevant changes found for ${cliFlags.triggerName}.`);
998
1173
  }
999
1174
  matchedTriggers['allowPipelineOptimizationsForTrigger'] = 1;
1000
1175
  } else {
1001
1176
  if (!cliFlags.silent) {
1002
- console.log("\u2139\uFE0F Relevant changes found for ".concat(cliFlags.triggerName, "."));
1177
+ console.log(`ℹ️ Relevant changes found for ${cliFlags.triggerName}.`);
1003
1178
  }
1004
1179
  matchedTriggers['allowPipelineOptimizationsForTrigger'] = 0;
1005
1180
  }
@@ -1037,9 +1212,6 @@ const baseMenuProperties = {
1037
1212
  required: ['locale', 'value']
1038
1213
  }]
1039
1214
  },
1040
- menuVisibility: {
1041
- type: ['string', 'null']
1042
- },
1043
1215
  permissions: {
1044
1216
  type: 'array',
1045
1217
  items: {
@@ -1119,15 +1291,15 @@ function validateMenu(menuJson) {
1119
1291
  async function command(cliFlags) {
1120
1292
  const menuJsonPath = cliFlags.inputFile;
1121
1293
  const isAppbarMenu = cliFlags.navigation === 'top';
1122
- if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
1123
- if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
1294
+ if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
1295
+ if (!doesFileExist(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
1124
1296
  const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
1125
1297
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
1126
1298
  }
1127
1299
 
1128
1300
  var pkgJson = {
1129
1301
  name: "@commercetools-frontend/application-cli",
1130
- version: "7.0.0",
1302
+ version: "7.2.0",
1131
1303
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
1132
1304
  keywords: [
1133
1305
  "commercetools",
@@ -1152,13 +1324,13 @@ var pkgJson = {
1152
1324
  dependencies: {
1153
1325
  "@babel/core": "^7.22.11",
1154
1326
  "@babel/runtime-corejs3": "^7.21.0",
1155
- "@commercetools-frontend/application-config": "24.11.0",
1156
- "@commercetools-frontend/constants": "24.11.0",
1157
- "@commercetools-frontend/l10n": "24.11.0",
1327
+ "@commercetools-frontend/application-config": "25.1.0",
1328
+ "@commercetools-frontend/constants": "25.1.0",
1329
+ "@commercetools-frontend/l10n": "25.1.0",
1158
1330
  "@manypkg/find-root": "2.2.3",
1159
1331
  commander: "^13.1.0",
1160
1332
  cosmiconfig: "9.0.0",
1161
- dotenv: "16.6.1",
1333
+ dotenv: "17.2.3",
1162
1334
  execa: "5.1.1",
1163
1335
  jsonschema: "^1.4.1",
1164
1336
  listr2: "8.3.3",
@@ -1168,11 +1340,11 @@ var pkgJson = {
1168
1340
  "ts-deepmerge": "7.0.3"
1169
1341
  },
1170
1342
  devDependencies: {
1171
- "@tsconfig/node20": "20.1.6",
1343
+ "@tsconfig/node24": "24.0.0",
1172
1344
  "@types/lodash": "^4.14.198",
1173
1345
  "@types/micromatch": "4.0.9",
1174
- "@types/node": "22.19.1",
1175
- typescript: "5.2.2"
1346
+ "@types/node": "24.10.6",
1347
+ typescript: "5.7.2"
1176
1348
  },
1177
1349
  engines: {
1178
1350
  node: ">=21",