@commercetools-frontend/application-cli 2.3.1 → 2.4.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.
@@ -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-2fc2b441.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 _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$4(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$4(Object(t))).call(_context7, 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,57 @@ 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;
163
+ if (!publicBaseUrl) {
164
+ var _context5;
165
+ throw new Error(_concatInstanceProperty(_context5 = "'publicBaseUrl' is not defined for '".concat(tag, "' storage provider for ")).call(_context5, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1], " or as default."));
166
+ }
161
167
  return publicBaseUrl;
162
168
  }
163
169
  }]);
164
- return StorageProvider;
165
170
  }();
166
171
  var _bucketRegion2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
167
172
  var _bucketEnvironment2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
168
- let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
169
- _inherits(GoogleStorageProvider, _StorageProvider);
173
+ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
170
174
  function GoogleStorageProvider(config) {
171
- var _this;
175
+ var _this2;
172
176
  _classCallCheck(this, GoogleStorageProvider);
173
- _this = _callSuper(this, GoogleStorageProvider, [config]);
174
- _Object$defineProperty(_assertThisInitialized(_this), _bucketRegion2$1, {
177
+ _this2 = _callSuper(this, GoogleStorageProvider, [config]);
178
+ _Object$defineProperty(_this2, _bucketRegion2$1, {
175
179
  writable: true,
176
180
  value: void 0
177
181
  });
178
- _Object$defineProperty(_assertThisInitialized(_this), _bucketEnvironment2$1, {
182
+ _Object$defineProperty(_this2, _bucketEnvironment2$1, {
179
183
  writable: true,
180
184
  value: void 0
181
185
  });
182
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
183
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
184
- return _this;
186
+ _classPrivateFieldLooseBase(_this2, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
187
+ _classPrivateFieldLooseBase(_this2, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
188
+ return _this2;
185
189
  }
186
- _createClass(GoogleStorageProvider, [{
190
+ _inherits(GoogleStorageProvider, _StorageProvider2);
191
+ return _createClass(GoogleStorageProvider, [{
187
192
  key: "getTag",
188
193
  value: function getTag() {
189
194
  return 'gs';
@@ -234,29 +239,28 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
234
239
  }, config));
235
240
  }
236
241
  }]);
237
- return GoogleStorageProvider;
238
242
  }(StorageProvider);
239
243
  var _bucketRegion3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
240
244
  var _bucketEnvironment3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
241
- let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
242
- _inherits(AwsStorageProvider, _StorageProvider2);
245
+ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider3) {
243
246
  function AwsStorageProvider(config) {
244
- var _this2;
247
+ var _this3;
245
248
  _classCallCheck(this, AwsStorageProvider);
246
- _this2 = _callSuper(this, AwsStorageProvider, [config]);
247
- _Object$defineProperty(_assertThisInitialized(_this2), _bucketRegion3, {
249
+ _this3 = _callSuper(this, AwsStorageProvider, [config]);
250
+ _Object$defineProperty(_this3, _bucketRegion3, {
248
251
  writable: true,
249
252
  value: void 0
250
253
  });
251
- _Object$defineProperty(_assertThisInitialized(_this2), _bucketEnvironment3, {
254
+ _Object$defineProperty(_this3, _bucketEnvironment3, {
252
255
  writable: true,
253
256
  value: void 0
254
257
  });
255
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
256
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
257
- return _this2;
258
+ _classPrivateFieldLooseBase(_this3, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
259
+ _classPrivateFieldLooseBase(_this3, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
260
+ return _this3;
258
261
  }
259
- _createClass(AwsStorageProvider, [{
262
+ _inherits(AwsStorageProvider, _StorageProvider3);
263
+ return _createClass(AwsStorageProvider, [{
260
264
  key: "getTag",
261
265
  value: function getTag() {
262
266
  return 's3';
@@ -308,7 +312,6 @@ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
308
312
  }, config));
309
313
  }
310
314
  }]);
311
- return AwsStorageProvider;
312
315
  }(StorageProvider);
313
316
  function getStorageProvider(storageProvider, config) {
314
317
  switch (storageProvider) {
@@ -317,7 +320,7 @@ function getStorageProvider(storageProvider, config) {
317
320
  case 's3':
318
321
  return new AwsStorageProvider(config);
319
322
  default:
320
- throw new Error(`Storage provider ${storageProvider} not supported`);
323
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
321
324
  }
322
325
  }
323
326
 
@@ -337,9 +340,10 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
337
340
  _classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion] = config.bucketRegion;
338
341
  _classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment] = config.bucketEnvironment;
339
342
  }
340
- _createClass(GoogleStorageUploadScriptsGenerator, [{
343
+ return _createClass(GoogleStorageUploadScriptsGenerator, [{
341
344
  key: "getApplicationIndexUploadScript",
342
345
  value: function getApplicationIndexUploadScript(_ref) {
346
+ var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10;
343
347
  let packageManagerName = _ref.packageManagerName,
344
348
  bucketUrl = _ref.bucketUrl,
345
349
  cdnUrl = _ref.cdnUrl,
@@ -349,109 +353,18 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
349
353
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
350
354
  throw new Error("Missing 'bucketEnvironment' when generating application index.");
351
355
  }
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
- `;
356
+ 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
357
  }
382
358
  }, {
383
359
  key: "getProductionBundlesUploadScript",
384
360
  value: function getProductionBundlesUploadScript(_ref2) {
361
+ var _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18;
385
362
  let bucketUrl = _ref2.bucketUrl,
386
363
  assetsPath = _ref2.assetsPath,
387
364
  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
- `;
365
+ 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
366
  }
453
367
  }]);
454
- return GoogleStorageUploadScriptsGenerator;
455
368
  }();
456
369
  var _bucketEnvironment2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
457
370
  var _bucketRegion2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
@@ -469,105 +382,28 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
469
382
  _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2] = config.bucketRegion;
470
383
  _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2] = config.bucketEnvironment;
471
384
  }
472
- _createClass(AwsStorageUploadScriptsGenerator, [{
385
+ return _createClass(AwsStorageUploadScriptsGenerator, [{
473
386
  key: "getApplicationIndexUploadScript",
474
387
  value: function getApplicationIndexUploadScript(_ref3) {
388
+ var _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
475
389
  let packageManagerName = _ref3.packageManagerName,
476
390
  bucketUrl = _ref3.bucketUrl,
477
391
  cdnUrl = _ref3.cdnUrl,
478
392
  buildRevision = _ref3.buildRevision,
479
393
  buildNumber = _ref3.buildNumber,
480
394
  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
- `;
395
+ 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\")/version.json\" \\\n \"")).call(_context20, bucketUrl, "/\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context19, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n");
510
396
  }
511
397
  }, {
512
398
  key: "getProductionBundlesUploadScript",
513
399
  value: function getProductionBundlesUploadScript(_ref4) {
400
+ var _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40;
514
401
  let bucketUrl = _ref4.bucketUrl,
515
402
  assetsPath = _ref4.assetsPath,
516
403
  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
- `;
404
+ 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
405
  }
569
406
  }]);
570
- return AwsStorageUploadScriptsGenerator;
571
407
  }();
572
408
  function getUploadScriptsGenerator(storageProvider, config) {
573
409
  switch (storageProvider) {
@@ -576,12 +412,21 @@ function getUploadScriptsGenerator(storageProvider, config) {
576
412
  case 's3':
577
413
  return new AwsStorageUploadScriptsGenerator(config);
578
414
  default:
579
- throw new Error(`Storage provider ${storageProvider} not supported`);
415
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
416
+ }
417
+ }
418
+
419
+ function doesFileExist(filePath) {
420
+ try {
421
+ fs$1.accessSync(filePath);
422
+ return true;
423
+ } catch (e) {
424
+ return false;
580
425
  }
581
426
  }
582
427
 
583
428
  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; }
429
+ 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
430
  function loadDotenvFiles(_ref) {
586
431
  let dotenvPath = _ref.dotenvPath,
587
432
  cloudEnvironment = _ref.cloudEnvironment;
@@ -591,13 +436,13 @@ function loadDotenvFiles(_ref) {
591
436
  }
592
437
 
593
438
  // Check if the given path exists.
594
- if (!fs$1.existsSync(dotenvPath)) {
595
- throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
439
+ if (!doesFileExist(dotenvPath)) {
440
+ throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
596
441
  }
597
442
 
598
443
  // Load the environment values
599
444
  const sharedDotenvFile = '.env.production';
600
- const cloudDotenvFile = `.env.${cloudEnvironment}`;
445
+ const cloudDotenvFile = ".env.".concat(cloudEnvironment);
601
446
 
602
447
  // The shared dotenv file across environments is optional
603
448
  const sharedProductionEnvironment = dotenv.config({
@@ -609,16 +454,18 @@ function loadDotenvFiles(_ref) {
609
454
  path: path.join(dotenvPath, cloudDotenvFile)
610
455
  });
611
456
  if (cloudSpecificProductionEnvironment.error) {
612
- throw new Error(`Failed loading '${cloudDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
457
+ var _context;
458
+ throw new Error(_concatInstanceProperty(_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
613
459
  }
614
460
  if (sharedProductionEnvironment.error) {
615
- throw new Error(`Failed loading '${sharedDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
461
+ var _context2;
462
+ throw new Error(_concatInstanceProperty(_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
616
463
  }
617
464
  return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
618
465
  }
619
466
 
620
467
  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; }
468
+ 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
469
  function writeUploadScriptFile(_ref) {
623
470
  let fileName = _ref.fileName,
624
471
  fileContent = _ref.fileContent,
@@ -630,6 +477,7 @@ function writeUploadScriptFile(_ref) {
630
477
  });
631
478
  }
632
479
  async function compileApplicationAssets(_ref2) {
480
+ var _context, _context2;
633
481
  let cliFlags = _ref2.cliFlags,
634
482
  storageProvider = _ref2.storageProvider,
635
483
  uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
@@ -644,7 +492,7 @@ async function compileApplicationAssets(_ref2) {
644
492
  skipMenu: cliFlags.skipMenu
645
493
  });
646
494
  const parsedApplicationAssetsUploadScriptFile = path$1.parse(cliFlags.applicationAssetsUploadScriptOutFile);
647
- const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${storageProvider.getBucketRegion()}${parsedApplicationAssetsUploadScriptFile.ext}`;
495
+ const applicationAssetsUploadScriptFileName = _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
648
496
  writeUploadScriptFile({
649
497
  fileName: applicationAssetsUploadScriptFileName,
650
498
  fileContent: applicationAssetsUploadScriptContent,
@@ -677,7 +525,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
677
525
  })), {}, {
678
526
  // The trailing slash is important to indicate to the CSP directive that all the resources
679
527
  // under that path should be allowed.
680
- MC_CDN_URL: `${cdnUrl}/`
528
+ MC_CDN_URL: "".concat(cdnUrl, "/")
681
529
  }, cliFlags.mcUrl ? {
682
530
  MC_URL: cliFlags.mcUrl
683
531
  } : {}), cliFlags.mcApiUrl ? {
@@ -734,7 +582,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
734
582
  }
735
583
  }
736
584
  async function command$3(cliFlags, cwd) {
737
- var _context;
585
+ var _context3;
738
586
  const storageBucketConfig = await loadStorageBucketsConfig();
739
587
  const applicationDirectory = getApplicationDirectory(cwd);
740
588
  let assetsPath;
@@ -751,12 +599,12 @@ async function command$3(cliFlags, cwd) {
751
599
  assetsPath
752
600
  };
753
601
  const defaultStorageProviders = [storageProviders.gs.tag];
754
- const taskList = new Listr(_mapInstanceProperty(_context = _Object$entries(storageBucketConfig)).call(_context, _ref4 => {
602
+ const taskList = new Listr(_mapInstanceProperty(_context3 = _Object$entries(storageBucketConfig)).call(_context3, _ref4 => {
755
603
  let _ref5 = _slicedToArray(_ref4, 2),
756
604
  bucketRegion = _ref5[0],
757
605
  bucketEnvironmentConfigs = _ref5[1];
758
606
  return {
759
- title: `Compiling for bucket region ${bucketRegion}`,
607
+ title: "Compiling for bucket region ".concat(bucketRegion),
760
608
  task: (_bucketRegionCtx, bucketRegionTask) => {
761
609
  // NOTE: Application assets need to be compiled
762
610
  // for all storage providers once per region.
@@ -771,7 +619,7 @@ async function command$3(cliFlags, cwd) {
771
619
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
772
620
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
773
621
  return {
774
- title: `Compiling application assets for '${storageProviderTag}'`,
622
+ title: "Compiling application assets for '".concat(storageProviderTag, "'"),
775
623
  task: () => compileApplicationAssets({
776
624
  cliFlags,
777
625
  storageProvider,
@@ -789,14 +637,14 @@ async function command$3(cliFlags, cwd) {
789
637
  bucketEnvironment
790
638
  };
791
639
  return {
792
- title: `Compiling for cloud environment '${cloudEnvironment}'`,
640
+ title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
793
641
  task: (_storageProviderCtx, storageProviderTask) => {
794
- var _context2;
795
- const applicationIndexTasksForStorageProviders = _mapInstanceProperty(_context2 = storageProviders || defaultStorageProviders).call(_context2, storageProviderTag => {
642
+ var _context4;
643
+ const applicationIndexTasksForStorageProviders = _mapInstanceProperty(_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
796
644
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
797
645
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
798
646
  return {
799
- title: `Compiling application index for storage provider '${storageProviderTag}'`,
647
+ title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
800
648
  task: () => {
801
649
  return compileEnvironmentApplicationIndexes({
802
650
  cliFlags,
@@ -852,52 +700,58 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
852
700
  */
853
701
 
854
702
  const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
855
- var _context2;
703
+ var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
856
704
  const entryPointUriPath = config.env.entryPointUriPath;
857
705
 
858
706
  // @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 ?? [];
707
+ 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
708
  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
- }));
709
+ return _mapInstanceProperty(accountLinks).call(accountLinks, menuLink => {
710
+ var _menuLink$permissions, _menuLink$featureTogg;
711
+ return {
712
+ key: menuLink.uriPath,
713
+ uriPath: menuLink.uriPath,
714
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
715
+ permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
716
+ // @ts-ignore: not defined in schema, as it's only used internally.
717
+ featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
718
+ };
719
+ });
869
720
  }
870
- const menuLinks = config.env.__DEVELOPMENT__?.menuLinks;
721
+ const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
871
722
  return {
872
723
  key: entryPointUriPath,
873
724
  uriPath: entryPointUriPath,
874
725
  icon: menuLinks.icon,
875
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks?.labelAllLocales, menuLinks?.defaultLabel),
726
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
876
727
  permissions: menuLinks.permissions,
877
728
  // @ts-ignore: not defined in schema, as it's only used internally.
878
- featureToggle: menuLinks.featureToggle ?? null,
729
+ featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
879
730
  // @ts-ignore: not defined in schema, as it's only used internally.
880
- menuVisibility: menuLinks.menuVisibility ?? null,
731
+ menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
881
732
  // @ts-ignore: not defined in schema, as it's only used internally.
882
- actionRights: menuLinks.actionRights ?? null,
733
+ actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
883
734
  // @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
- })),
735
+ dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
736
+ submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
737
+ var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
738
+ return {
739
+ key: submenuLink.uriPath.replace('/', '-'),
740
+ uriPath: submenuLink.uriPath,
741
+ labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
742
+ permissions: submenuLink.permissions,
743
+ // @ts-ignore: not defined in schema, as it's only used internally.
744
+ featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
745
+ // @ts-ignore: not defined in schema, as it's only used internally.
746
+ menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
747
+ // @ts-ignore: not defined in schema, as it's only used internally.
748
+ actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
749
+ // @ts-ignore: not defined in schema, as it's only used internally.
750
+ dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
751
+ };
752
+ }),
899
753
  // @ts-ignore: not defined in schema, as it's only used internally.
900
- shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
754
+ shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
901
755
  };
902
756
  };
903
757
  async function command$2(cliFlags, cwd) {
@@ -1079,15 +933,15 @@ function validateMenu(menuJson) {
1079
933
  async function command(cliFlags) {
1080
934
  const menuJsonPath = cliFlags.inputFile;
1081
935
  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}`);
936
+ if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
937
+ if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
1084
938
  const menuJson = fs$1.readFileSync(menuJsonPath, 'utf-8');
1085
939
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
1086
940
  }
1087
941
 
1088
942
  var pkgJson = {
1089
943
  name: "@commercetools-frontend/application-cli",
1090
- version: "2.3.1",
944
+ version: "2.4.0",
1091
945
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
1092
946
  keywords: [
1093
947
  "commercetools",
@@ -1112,22 +966,22 @@ var pkgJson = {
1112
966
  "@babel/core": "^7.22.11",
1113
967
  "@babel/runtime": "^7.21.0",
1114
968
  "@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",
969
+ "@commercetools-frontend/application-config": "22.23.3",
970
+ "@commercetools-frontend/constants": "22.23.3",
971
+ "@commercetools-frontend/l10n": "22.23.3",
1118
972
  "@manypkg/find-root": "2.2.1",
1119
973
  cac: "^6.7.14",
1120
974
  cosmiconfig: "9.0.0",
1121
- dotenv: "16.4.2",
975
+ dotenv: "16.4.5",
1122
976
  execa: "5.1.1",
1123
977
  jsonschema: "^1.4.1",
1124
- listr2: "8.0.2",
978
+ listr2: "8.2.0",
1125
979
  "node-fetch": "2.7.0",
1126
980
  "ts-deepmerge": "7.0.0"
1127
981
  },
1128
982
  devDependencies: {
1129
- "@tsconfig/node20": "20.1.2",
1130
- "@types/node": "20.12.2",
983
+ "@tsconfig/node20": "20.1.4",
984
+ "@types/node": "20.12.7",
1131
985
  typescript: "5.2.2"
1132
986
  },
1133
987
  engines: {
@@ -1159,7 +1013,7 @@ const run = async () => {
1159
1013
  // Default command
1160
1014
  cli.command('').usage('\n\n Compile deployments and menus and create versions for MC applications').action(cli.outputHelp);
1161
1015
  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.', {
1016
+ 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
1017
  default: 'application.html'
1164
1018
  }).option('--application-index-upload-script-out-file [path]', '(optional) The name of the the application index upload script file.', {
1165
1019
  default: 'upload-index.sh'
@@ -1171,15 +1025,15 @@ const run = async () => {
1171
1025
  await command$3(options, cwd);
1172
1026
  });
1173
1027
  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 => {
1028
+ 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
1029
  await command$2(options, cwd);
1176
1030
  });
1177
1031
  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 => {
1032
+ 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
1033
  await command(options);
1180
1034
  });
1181
1035
  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', {
1036
+ 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
1037
  default: 15
1184
1038
  }).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
1039
  await command$1(options);