@commercetools-frontend/application-cli 2.3.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,11 +13,12 @@ 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');
16
17
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
17
18
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
18
19
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
19
20
  var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
20
- var storageBucketsConfig = require('../../dist/storage-buckets-config-28a1d76e.cjs.dev.js');
21
+ var storageBucketsConfig = require('../../dist/storage-buckets-config-8e7abeff.cjs.dev.js');
21
22
  var fs = require('node:fs');
22
23
  var path$1 = require('node:path');
23
24
  var listr2 = require('listr2');
@@ -25,7 +26,6 @@ var execa = require('execa');
25
26
  var findRoot = require('@manypkg/find-root');
26
27
  var path = require('path');
27
28
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
28
- var _assertThisInitialized = require('@babel/runtime-corejs3/helpers/assertThisInitialized');
29
29
  var _get = require('@babel/runtime-corejs3/helpers/get');
30
30
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
31
31
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
@@ -34,8 +34,8 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
34
34
  var _classPrivateFieldLooseBase = require('@babel/runtime-corejs3/helpers/classPrivateFieldLooseBase');
35
35
  var _classPrivateFieldLooseKey = require('@babel/runtime-corejs3/helpers/classPrivateFieldLooseKey');
36
36
  var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
37
- var fs$1 = require('fs');
38
37
  var dotenv = require('dotenv');
38
+ var fs$1 = require('fs');
39
39
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
40
40
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
41
41
  var applicationConfig = require('@commercetools-frontend/application-config');
@@ -55,6 +55,7 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
55
55
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
56
56
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
57
57
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
58
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
58
59
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
59
60
  var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
60
61
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
@@ -64,8 +65,8 @@ var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
64
65
  var execa__default = /*#__PURE__*/_interopDefault(execa);
65
66
  var path__default = /*#__PURE__*/_interopDefault(path);
66
67
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
67
- var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
68
68
  var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
69
+ var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
69
70
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
70
71
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
71
72
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
@@ -84,7 +85,7 @@ function isCI() {
84
85
  }
85
86
 
86
87
  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; }
87
- 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; }
88
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys$4(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$4(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
88
89
  function _callSuper(_this, derived, args) {
89
90
  function isNativeReflectConstruct() {
90
91
  if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false;
@@ -124,12 +125,12 @@ let StorageProvider = /*#__PURE__*/function () {
124
125
  * This allows all cloud environments sharing the same static assets while each application's index
125
126
  * is uploaded with different headers (e.g. CSP rules).
126
127
  */
127
- _createClass(StorageProvider, [{
128
+ return _createClass(StorageProvider, [{
128
129
  key: "getBucketNamespace",
129
130
  value: function getBucketNamespace(prNumber) {
130
131
  if (!prNumber) return;
131
132
  if (prNumber === 'merchant-center-preview') return prNumber;
132
- return `mc-${prNumber}`;
133
+ return "mc-".concat(prNumber);
133
134
  }
134
135
 
135
136
  /**
@@ -138,7 +139,7 @@ let StorageProvider = /*#__PURE__*/function () {
138
139
  }, {
139
140
  key: "getAssetsBucketUrl",
140
141
  value: function getAssetsBucketUrl(_ref) {
141
- var _context;
142
+ var _storageProvider$urls, _storageProvider$urls2, _context, _context2;
142
143
  let applicationName = _ref.applicationName,
143
144
  bucketProtocol = _ref.bucketProtocol,
144
145
  bucketNamespace = _ref.bucketNamespace,
@@ -147,13 +148,14 @@ let StorageProvider = /*#__PURE__*/function () {
147
148
  throw new Error("'bucketRegion' is not defined. Required to determine 'assetsBucketUrl'.");
148
149
  }
149
150
  const storageProvider = storageBucketsConfig.storageProviders[tag];
150
- const assetBuketUrl = storageProvider.urls.bucket?.[_classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1]] ?? _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1];
151
+ 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];
151
152
  const assetsBucketUrl = _filterInstanceProperty__default["default"](_context = [assetBuketUrl, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
152
- return `${bucketProtocol}${assetsBucketUrl}`;
153
+ return _concatInstanceProperty__default["default"](_context2 = "".concat(bucketProtocol)).call(_context2, assetsBucketUrl);
153
154
  }
154
155
  }, {
155
156
  key: "getApplicationIndexBucketUrl",
156
157
  value: function getApplicationIndexBucketUrl(_ref2) {
158
+ var _context3;
157
159
  let tag = _ref2.tag,
158
160
  prNumber = _ref2.prNumber,
159
161
  applicationName = _ref2.applicationName,
@@ -166,53 +168,53 @@ let StorageProvider = /*#__PURE__*/function () {
166
168
  bucketProtocol,
167
169
  bucketNamespace
168
170
  });
169
- const applicationIndexBucketUrl = `${applicationAssetsBucketUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]}`;
171
+ const applicationIndexBucketUrl = _concatInstanceProperty__default["default"](_context3 = "".concat(applicationAssetsBucketUrl, "/")).call(_context3, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]);
170
172
  return applicationIndexBucketUrl;
171
173
  }
172
174
  }, {
173
175
  key: "getCdnUrl",
174
176
  value: function getCdnUrl(_ref3) {
175
- var _context2;
177
+ var _context4;
176
178
  let applicationName = _ref3.applicationName,
177
179
  prNumber = _ref3.prNumber,
178
180
  publicBaseUrl = _ref3.publicBaseUrl,
179
181
  excludeBucketRegion = _ref3.excludeBucketRegion;
180
- return _filterInstanceProperty__default["default"](_context2 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context2, Boolean).join('/');
182
+ return _filterInstanceProperty__default["default"](_context4 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context4, Boolean).join('/');
181
183
  }
182
184
  }, {
183
185
  key: "getPublicBaseUrl",
184
186
  value: function getPublicBaseUrl(tag) {
187
+ var _storageProvider$urls3;
185
188
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
186
189
  throw new Error("'bucketEnvironment' is not defined. Required to determine 'publicBaseUrl'.");
187
190
  }
188
191
  const storageProvider = storageBucketsConfig.storageProviders[tag];
189
- const publicBaseUrl = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]] ?? storageProvider.urls.public.default;
192
+ const publicBaseUrl = (_storageProvider$urls3 = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]) !== null && _storageProvider$urls3 !== void 0 ? _storageProvider$urls3 : storageProvider.urls.public.default;
190
193
  return publicBaseUrl;
191
194
  }
192
195
  }]);
193
- return StorageProvider;
194
196
  }();
195
197
  var _bucketRegion2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
196
198
  var _bucketEnvironment2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
197
- let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
198
- _inherits(GoogleStorageProvider, _StorageProvider);
199
+ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
199
200
  function GoogleStorageProvider(config) {
200
- var _this;
201
+ var _this2;
201
202
  _classCallCheck(this, GoogleStorageProvider);
202
- _this = _callSuper(this, GoogleStorageProvider, [config]);
203
- _Object$defineProperty__default["default"](_assertThisInitialized(_this), _bucketRegion2$1, {
203
+ _this2 = _callSuper(this, GoogleStorageProvider, [config]);
204
+ _Object$defineProperty__default["default"](_this2, _bucketRegion2$1, {
204
205
  writable: true,
205
206
  value: void 0
206
207
  });
207
- _Object$defineProperty__default["default"](_assertThisInitialized(_this), _bucketEnvironment2$1, {
208
+ _Object$defineProperty__default["default"](_this2, _bucketEnvironment2$1, {
208
209
  writable: true,
209
210
  value: void 0
210
211
  });
211
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
212
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
213
- return _this;
212
+ _classPrivateFieldLooseBase(_this2, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
213
+ _classPrivateFieldLooseBase(_this2, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
214
+ return _this2;
214
215
  }
215
- _createClass(GoogleStorageProvider, [{
216
+ _inherits(GoogleStorageProvider, _StorageProvider2);
217
+ return _createClass(GoogleStorageProvider, [{
216
218
  key: "getTag",
217
219
  value: function getTag() {
218
220
  return 'gs';
@@ -263,29 +265,28 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
263
265
  }, config));
264
266
  }
265
267
  }]);
266
- return GoogleStorageProvider;
267
268
  }(StorageProvider);
268
269
  var _bucketRegion3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
269
270
  var _bucketEnvironment3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
270
- let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
271
- _inherits(AwsStorageProvider, _StorageProvider2);
271
+ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider3) {
272
272
  function AwsStorageProvider(config) {
273
- var _this2;
273
+ var _this3;
274
274
  _classCallCheck(this, AwsStorageProvider);
275
- _this2 = _callSuper(this, AwsStorageProvider, [config]);
276
- _Object$defineProperty__default["default"](_assertThisInitialized(_this2), _bucketRegion3, {
275
+ _this3 = _callSuper(this, AwsStorageProvider, [config]);
276
+ _Object$defineProperty__default["default"](_this3, _bucketRegion3, {
277
277
  writable: true,
278
278
  value: void 0
279
279
  });
280
- _Object$defineProperty__default["default"](_assertThisInitialized(_this2), _bucketEnvironment3, {
280
+ _Object$defineProperty__default["default"](_this3, _bucketEnvironment3, {
281
281
  writable: true,
282
282
  value: void 0
283
283
  });
284
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
285
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
286
- return _this2;
284
+ _classPrivateFieldLooseBase(_this3, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
285
+ _classPrivateFieldLooseBase(_this3, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
286
+ return _this3;
287
287
  }
288
- _createClass(AwsStorageProvider, [{
288
+ _inherits(AwsStorageProvider, _StorageProvider3);
289
+ return _createClass(AwsStorageProvider, [{
289
290
  key: "getTag",
290
291
  value: function getTag() {
291
292
  return 's3';
@@ -337,7 +338,6 @@ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
337
338
  }, config));
338
339
  }
339
340
  }]);
340
- return AwsStorageProvider;
341
341
  }(StorageProvider);
342
342
  function getStorageProvider(storageProvider, config) {
343
343
  switch (storageProvider) {
@@ -346,7 +346,7 @@ function getStorageProvider(storageProvider, config) {
346
346
  case 's3':
347
347
  return new AwsStorageProvider(config);
348
348
  default:
349
- throw new Error(`Storage provider ${storageProvider} not supported`);
349
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
350
350
  }
351
351
  }
352
352
 
@@ -366,9 +366,10 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
366
366
  _classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion] = config.bucketRegion;
367
367
  _classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment] = config.bucketEnvironment;
368
368
  }
369
- _createClass(GoogleStorageUploadScriptsGenerator, [{
369
+ return _createClass(GoogleStorageUploadScriptsGenerator, [{
370
370
  key: "getApplicationIndexUploadScript",
371
371
  value: function getApplicationIndexUploadScript(_ref) {
372
+ var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10;
372
373
  let packageManagerName = _ref.packageManagerName,
373
374
  bucketUrl = _ref.bucketUrl,
374
375
  cdnUrl = _ref.cdnUrl,
@@ -378,109 +379,18 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
378
379
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
379
380
  throw new Error("Missing 'bucketEnvironment' when generating application index.");
380
381
  }
381
- return `
382
- #!/usr/bin/env bash
383
-
384
- set -e
385
-
386
- echo "Uploading compiled ${applicationIndexOutFile} to Google Storage bucket ${bucketUrl}"
387
-
388
- gcloud storage cp \\
389
- "$(dirname "$0")/${applicationIndexOutFile}" \\
390
- "${bucketUrl}/" \\
391
- -z html \\
392
- --content-type="text/html" \\
393
- --cache-control="public,max-age=0,no-transform"
394
-
395
- echo "Creating version.json and uploading it to bucket ${bucketUrl}"
396
-
397
- NODE_ENV=production ${packageManagerName} application-cli create-version \\
398
- --version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
399
- --build-revision=${buildRevision} \\
400
- --build-number=${buildNumber} \\
401
- --out-file=$(dirname "$0")/version.json
402
-
403
- gcloud storage cp \\
404
- "$(dirname "$0")/version.json" \\
405
- "${bucketUrl}/" \\
406
- -z json \\
407
- --content-type="application/json" \\
408
- --cache-control="public,max-age=0,no-transform"
409
- `;
382
+ 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"](_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");
410
383
  }
411
384
  }, {
412
385
  key: "getProductionBundlesUploadScript",
413
386
  value: function getProductionBundlesUploadScript(_ref2) {
387
+ var _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18;
414
388
  let bucketUrl = _ref2.bucketUrl,
415
389
  assetsPath = _ref2.assetsPath,
416
390
  skipMenu = _ref2.skipMenu;
417
- return `
418
- #!/usr/bin/env bash
419
-
420
- set -e
421
-
422
- # NOTES:
423
- # https://cloud.google.com/sdk/gcloud/reference/storage/cp
424
- # 1. The '-z' option triggers compressing the assets before
425
- # uploading them and sets the 'Content-Encoding' to 'gzip'.
426
- # 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.
427
- # 3. The 'max-age' is set to 1 year which is considered the maximum
428
- # "valid" lifetime of an asset to be cached.
429
- # 4. The '-n' will skip uploading existing files and prevents them to
430
- # be overwritten
431
- echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
432
-
433
- gcloud storage cp \\
434
- ${assetsPath}/public/{*.css,*.js,*.js.map,*.html} \\
435
- "${bucketUrl}" \\
436
- -n \\
437
- -z js,css \\
438
- --cache-control="public,max-age=31536000,no-transform"
439
-
440
- # We need to upload the PNG and HTML files separately because we want them
441
- # to be able to overwrite the existing files (if any). For instance, the
442
- # file or the favicons.
443
- # This is controlled with the '-n' option (which is used for the JS and CSS
444
- # as we don't want to overwrite them)
445
- gcloud storage cp \\
446
- ${assetsPath}/public/{*.png,robots.txt} \\
447
- "${bucketUrl}" \\
448
- -z txt \\
449
- --cache-control="public,max-age=31536000,no-transform"
450
-
451
- if ${skipMenu}; then
452
- echo "Skipping menu.json upload"
453
- else
454
- echo "Uploading menu.json to bucket ${bucketUrl}"
455
- # NOTE: somehow the 'cache-control:private' doesn't work.
456
- # I mean, the file is uploaded with the correct metadata but when I fetch
457
- # the file the response contains the header
458
- # 'cache-control: public,max-age=31536000,no-transform', even though the
459
- # documentation clearly states that by marking the header as 'private' will
460
- # disable the cache (for publicly readable objects).
461
- # https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
462
- # However, I found out that, by requesting the file with any RANDOM
463
- # query parameter, will instruct the storage to return a 'fresh' object
464
- # (without any cache control).
465
- # Unofficial source: https://stackoverflow.com/a/49052895
466
- # This seems to be the 'easiest' option to 'disable' the cache for public
467
- # objects. Other alternative approaces are:
468
- # * make the object private with some simple ACL (private objects are not cached)
469
- # * suffix the file name with e.g. the git SHA, so we have different files
470
- # for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
471
- # the git SHA on runtime and can get the correct file when it starts.
472
- # * find out why the 'private' cache control does not work
473
- gcloud storage cp \\
474
- ${assetsPath}/menu.json \\
475
- ${bucketUrl} \\
476
- -z json \\
477
- --content-type="application/json" \\
478
- --cache-control="public,max-age=0,no-transform"
479
- fi
480
- `;
391
+ return _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 = "\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");
481
392
  }
482
393
  }]);
483
- return GoogleStorageUploadScriptsGenerator;
484
394
  }();
485
395
  var _bucketEnvironment2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
486
396
  var _bucketRegion2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
@@ -498,106 +408,28 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
498
408
  _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2] = config.bucketRegion;
499
409
  _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2] = config.bucketEnvironment;
500
410
  }
501
- _createClass(AwsStorageUploadScriptsGenerator, [{
411
+ return _createClass(AwsStorageUploadScriptsGenerator, [{
502
412
  key: "getApplicationIndexUploadScript",
503
413
  value: function getApplicationIndexUploadScript(_ref3) {
414
+ var _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
504
415
  let packageManagerName = _ref3.packageManagerName,
505
416
  bucketUrl = _ref3.bucketUrl,
506
417
  cdnUrl = _ref3.cdnUrl,
507
418
  buildRevision = _ref3.buildRevision,
508
419
  buildNumber = _ref3.buildNumber,
509
420
  applicationIndexOutFile = _ref3.applicationIndexOutFile;
510
- return `
511
- #!/usr/bin/env bash
512
-
513
- echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
514
-
515
- set -e
516
-
517
- aws s3 cp \\
518
- "$(dirname "$0")/${applicationIndexOutFile}" \\
519
- "${bucketUrl}/" \\
520
- --content-type="text/html" \\
521
- --cache-control="public,max-age=0,no-transform" \\
522
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
523
-
524
- echo "Creating version.json and uploading it to bucket ${bucketUrl}"
525
-
526
- NODE_ENV=production ${packageManagerName} application-cli create-version \\
527
- --version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}/version.json \\
528
- --build-revision=${buildRevision} \\
529
- --build-number=${buildNumber} \\
530
- --out-file=$(dirname "$0")/version.json
531
-
532
- aws s3 cp \\
533
- "$(dirname "$0")/version.json" \\
534
- "${bucketUrl}/" \\
535
- --content-type="application/json" \\
536
- --cache-control="public,max-age=0,no-transform" \\
537
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
538
- `;
421
+ return _concatInstanceProperty__default["default"](_context19 = _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 = "\n #!/usr/bin/env bash\n\n echo \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\n set -e\n\n aws s3 cp \"$(dirname \"$0\")/")).call(_context29, applicationIndexOutFile, "\" \\\n \"")).call(_context28, bucketUrl, "/\" \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context27, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n echo \"Creating version.json and uploading it to bucket ")).call(_context26, bucketUrl, "\"\n\n NODE_ENV=production ")).call(_context25, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context24, cdnUrl, "/")).call(_context23, _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2], "/version.json \\\n --build-revision=")).call(_context22, buildRevision, " \\\n --build-number=")).call(_context21, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\n aws s3 cp \"$(dirname \"$0\")\" \\\n \"")).call(_context20, bucketUrl, "/\" \\\n --exclude \"*\" \\\n --include \"version.json\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context19, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n");
539
422
  }
540
423
  }, {
541
424
  key: "getProductionBundlesUploadScript",
542
425
  value: function getProductionBundlesUploadScript(_ref4) {
426
+ var _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40;
543
427
  let bucketUrl = _ref4.bucketUrl,
544
428
  assetsPath = _ref4.assetsPath,
545
429
  skipMenu = _ref4.skipMenu;
546
- return `
547
- #!/usr/bin/env bash
548
-
549
- echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
550
-
551
- set -e
552
-
553
- # NOTE:
554
- # The sync command on the AWS CLI is different to the -n option on the gcloud CLI.
555
- # Sync will only upload files that are not already in the bucket, but it will skip existing ones
556
- # that have been changed locally.
557
- # The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.
558
- # https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
559
- # https://cloud.google.com/sdk/gcloud/reference/storage/cp
560
- #
561
- # Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.
562
- # https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring
563
- aws s3 sync ${assetsPath}/public \\
564
- "${bucketUrl}" \\
565
- --exclude "*" \\
566
- --include "*.css" \\
567
- --include "*.js" \\
568
- --include "*.js.map" \\
569
- --include "*.html" \\
570
- --cache-control="public,max-age=31536000,no-transform" \\
571
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
572
-
573
- # We need to upload the PNG and HTML files separately because we want them
574
- # to be able to overwrite the existing files (if any). For instance, the
575
- # file or the favicons.
576
- aws s3 cp ${assetsPath}/public \\
577
- "${bucketUrl}" \\
578
- --recursive \\
579
- --exclude "*" \\
580
- --include "*.png" \\
581
- --include "robots.txt" \\
582
- --cache-control="public,max-age=31536000,no-transform" \\
583
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
584
-
585
- if ${skipMenu}; then
586
- echo "Skipping menu.json upload"
587
- else
588
- echo "Uploading menu.json to bucket ${bucketUrl}"
589
-
590
- aws s3 cp \\
591
- ${assetsPath}/menu.json \\
592
- ${bucketUrl} \\
593
- --content-type="application/json" \\
594
- --cache-control="public,max-age=0,no-transform" \\
595
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
596
- fi
597
- `;
430
+ return _concatInstanceProperty__default["default"](_context30 = _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 = "\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");
598
431
  }
599
432
  }]);
600
- return AwsStorageUploadScriptsGenerator;
601
433
  }();
602
434
  function getUploadScriptsGenerator(storageProvider, config) {
603
435
  switch (storageProvider) {
@@ -606,12 +438,21 @@ function getUploadScriptsGenerator(storageProvider, config) {
606
438
  case 's3':
607
439
  return new AwsStorageUploadScriptsGenerator(config);
608
440
  default:
609
- throw new Error(`Storage provider ${storageProvider} not supported`);
441
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
442
+ }
443
+ }
444
+
445
+ function doesFileExist(filePath) {
446
+ try {
447
+ fs__default$1["default"].accessSync(filePath);
448
+ return true;
449
+ } catch (e) {
450
+ return false;
610
451
  }
611
452
  }
612
453
 
613
454
  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; }
614
- 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; }
455
+ 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; }
615
456
  function loadDotenvFiles(_ref) {
616
457
  let dotenvPath = _ref.dotenvPath,
617
458
  cloudEnvironment = _ref.cloudEnvironment;
@@ -621,13 +462,13 @@ function loadDotenvFiles(_ref) {
621
462
  }
622
463
 
623
464
  // Check if the given path exists.
624
- if (!fs__default$1["default"].existsSync(dotenvPath)) {
625
- throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
465
+ if (!doesFileExist(dotenvPath)) {
466
+ throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
626
467
  }
627
468
 
628
469
  // Load the environment values
629
470
  const sharedDotenvFile = '.env.production';
630
- const cloudDotenvFile = `.env.${cloudEnvironment}`;
471
+ const cloudDotenvFile = ".env.".concat(cloudEnvironment);
631
472
 
632
473
  // The shared dotenv file across environments is optional
633
474
  const sharedProductionEnvironment = dotenv__default["default"].config({
@@ -639,16 +480,18 @@ function loadDotenvFiles(_ref) {
639
480
  path: path__default["default"].join(dotenvPath, cloudDotenvFile)
640
481
  });
641
482
  if (cloudSpecificProductionEnvironment.error) {
642
- throw new Error(`Failed loading '${cloudDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
483
+ var _context;
484
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
643
485
  }
644
486
  if (sharedProductionEnvironment.error) {
645
- throw new Error(`Failed loading '${sharedDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
487
+ var _context2;
488
+ throw new Error(_concatInstanceProperty__default["default"](_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
646
489
  }
647
490
  return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
648
491
  }
649
492
 
650
493
  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; }
651
- 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; }
494
+ 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; }
652
495
  function writeUploadScriptFile(_ref) {
653
496
  let fileName = _ref.fileName,
654
497
  fileContent = _ref.fileContent,
@@ -660,6 +503,7 @@ function writeUploadScriptFile(_ref) {
660
503
  });
661
504
  }
662
505
  async function compileApplicationAssets(_ref2) {
506
+ var _context, _context2;
663
507
  let cliFlags = _ref2.cliFlags,
664
508
  storageProvider = _ref2.storageProvider,
665
509
  uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
@@ -674,7 +518,7 @@ async function compileApplicationAssets(_ref2) {
674
518
  skipMenu: cliFlags.skipMenu
675
519
  });
676
520
  const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
677
- const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${storageProvider.getBucketRegion()}${parsedApplicationAssetsUploadScriptFile.ext}`;
521
+ const applicationAssetsUploadScriptFileName = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
678
522
  writeUploadScriptFile({
679
523
  fileName: applicationAssetsUploadScriptFileName,
680
524
  fileContent: applicationAssetsUploadScriptContent,
@@ -707,7 +551,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
707
551
  })), {}, {
708
552
  // The trailing slash is important to indicate to the CSP directive that all the resources
709
553
  // under that path should be allowed.
710
- MC_CDN_URL: `${cdnUrl}/`
554
+ MC_CDN_URL: "".concat(cdnUrl, "/")
711
555
  }, cliFlags.mcUrl ? {
712
556
  MC_URL: cliFlags.mcUrl
713
557
  } : {}), cliFlags.mcApiUrl ? {
@@ -764,7 +608,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
764
608
  }
765
609
  }
766
610
  async function command$3(cliFlags, cwd) {
767
- var _context;
611
+ var _context3;
768
612
  const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
769
613
  const applicationDirectory = getApplicationDirectory(cwd);
770
614
  let assetsPath;
@@ -781,12 +625,12 @@ async function command$3(cliFlags, cwd) {
781
625
  assetsPath
782
626
  };
783
627
  const defaultStorageProviders = [storageBucketsConfig.storageProviders.gs.tag];
784
- const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](storageBucketConfig)).call(_context, _ref4 => {
628
+ const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](storageBucketConfig)).call(_context3, _ref4 => {
785
629
  let _ref5 = _slicedToArray(_ref4, 2),
786
630
  bucketRegion = _ref5[0],
787
631
  bucketEnvironmentConfigs = _ref5[1];
788
632
  return {
789
- title: `Compiling for bucket region ${bucketRegion}`,
633
+ title: "Compiling for bucket region ".concat(bucketRegion),
790
634
  task: (_bucketRegionCtx, bucketRegionTask) => {
791
635
  // NOTE: Application assets need to be compiled
792
636
  // for all storage providers once per region.
@@ -801,7 +645,7 @@ async function command$3(cliFlags, cwd) {
801
645
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
802
646
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
803
647
  return {
804
- title: `Compiling application assets for '${storageProviderTag}'`,
648
+ title: "Compiling application assets for '".concat(storageProviderTag, "'"),
805
649
  task: () => compileApplicationAssets({
806
650
  cliFlags,
807
651
  storageProvider,
@@ -819,14 +663,14 @@ async function command$3(cliFlags, cwd) {
819
663
  bucketEnvironment
820
664
  };
821
665
  return {
822
- title: `Compiling for cloud environment '${cloudEnvironment}'`,
666
+ title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
823
667
  task: (_storageProviderCtx, storageProviderTask) => {
824
- var _context2;
825
- const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context2 = storageProviders || defaultStorageProviders).call(_context2, storageProviderTag => {
668
+ var _context4;
669
+ const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
826
670
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
827
671
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
828
672
  return {
829
- title: `Compiling application index for storage provider '${storageProviderTag}'`,
673
+ title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
830
674
  task: () => {
831
675
  return compileEnvironmentApplicationIndexes({
832
676
  cliFlags,
@@ -882,52 +726,58 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
882
726
  */
883
727
 
884
728
  const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
885
- var _context2;
729
+ var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
886
730
  const entryPointUriPath = config.env.entryPointUriPath;
887
731
 
888
732
  // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
889
- const accountLinks = config.env.__DEVELOPMENT__?.accountLinks ?? [];
733
+ 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 : [];
890
734
  if (accountLinks.length > 0) {
891
- return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => ({
892
- key: menuLink.uriPath,
893
- uriPath: menuLink.uriPath,
894
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
895
- permissions: menuLink.permissions ?? [],
896
- // @ts-ignore: not defined in schema, as it's only used internally.
897
- featureToggle: menuLink.featureToggle ?? null
898
- }));
735
+ return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => {
736
+ var _menuLink$permissions, _menuLink$featureTogg;
737
+ return {
738
+ key: menuLink.uriPath,
739
+ uriPath: menuLink.uriPath,
740
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
741
+ permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
742
+ // @ts-ignore: not defined in schema, as it's only used internally.
743
+ featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
744
+ };
745
+ });
899
746
  }
900
- const menuLinks = config.env.__DEVELOPMENT__?.menuLinks;
747
+ const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
901
748
  return {
902
749
  key: entryPointUriPath,
903
750
  uriPath: entryPointUriPath,
904
751
  icon: menuLinks.icon,
905
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks?.labelAllLocales, menuLinks?.defaultLabel),
752
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
906
753
  permissions: menuLinks.permissions,
907
754
  // @ts-ignore: not defined in schema, as it's only used internally.
908
- featureToggle: menuLinks.featureToggle ?? null,
755
+ featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
909
756
  // @ts-ignore: not defined in schema, as it's only used internally.
910
- menuVisibility: menuLinks.menuVisibility ?? null,
757
+ menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
911
758
  // @ts-ignore: not defined in schema, as it's only used internally.
912
- actionRights: menuLinks.actionRights ?? null,
759
+ actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
913
760
  // @ts-ignore: not defined in schema, as it's only used internally.
914
- dataFences: menuLinks.dataFences ?? null,
915
- submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => ({
916
- key: submenuLink.uriPath.replace('/', '-'),
917
- uriPath: submenuLink.uriPath,
918
- labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
919
- permissions: submenuLink.permissions,
920
- // @ts-ignore: not defined in schema, as it's only used internally.
921
- featureToggle: submenuLink.featureToggle ?? null,
922
- // @ts-ignore: not defined in schema, as it's only used internally.
923
- menuVisibility: submenuLink.menuVisibility ?? null,
924
- // @ts-ignore: not defined in schema, as it's only used internally.
925
- actionRights: submenuLink.actionRights ?? null,
926
- // @ts-ignore: not defined in schema, as it's only used internally.
927
- dataFences: submenuLink.dataFences ?? null
928
- })),
761
+ dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
762
+ submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
763
+ var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
764
+ return {
765
+ key: submenuLink.uriPath.replace('/', '-'),
766
+ uriPath: submenuLink.uriPath,
767
+ labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
768
+ permissions: submenuLink.permissions,
769
+ // @ts-ignore: not defined in schema, as it's only used internally.
770
+ featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
771
+ // @ts-ignore: not defined in schema, as it's only used internally.
772
+ menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
773
+ // @ts-ignore: not defined in schema, as it's only used internally.
774
+ actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
775
+ // @ts-ignore: not defined in schema, as it's only used internally.
776
+ dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
777
+ };
778
+ }),
929
779
  // @ts-ignore: not defined in schema, as it's only used internally.
930
- shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
780
+ shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
931
781
  };
932
782
  };
933
783
  async function command$2(cliFlags, cwd) {
@@ -1109,15 +959,15 @@ function validateMenu(menuJson) {
1109
959
  async function command(cliFlags) {
1110
960
  const menuJsonPath = cliFlags.inputFile;
1111
961
  const isAppbarMenu = cliFlags.navigation === 'top';
1112
- if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
1113
- if (!fs__default$1["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
962
+ if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
963
+ if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
1114
964
  const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
1115
965
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
1116
966
  }
1117
967
 
1118
968
  var pkgJson = {
1119
969
  name: "@commercetools-frontend/application-cli",
1120
- version: "2.3.0",
970
+ version: "2.3.2",
1121
971
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
1122
972
  keywords: [
1123
973
  "commercetools",
@@ -1142,22 +992,22 @@ var pkgJson = {
1142
992
  "@babel/core": "^7.22.11",
1143
993
  "@babel/runtime": "^7.21.0",
1144
994
  "@babel/runtime-corejs3": "^7.21.0",
1145
- "@commercetools-frontend/application-config": "22.22.0",
1146
- "@commercetools-frontend/constants": "22.22.0",
1147
- "@commercetools-frontend/l10n": "22.22.0",
995
+ "@commercetools-frontend/application-config": "22.23.3",
996
+ "@commercetools-frontend/constants": "22.23.3",
997
+ "@commercetools-frontend/l10n": "22.23.3",
1148
998
  "@manypkg/find-root": "2.2.1",
1149
999
  cac: "^6.7.14",
1150
1000
  cosmiconfig: "9.0.0",
1151
- dotenv: "16.4.2",
1001
+ dotenv: "16.4.5",
1152
1002
  execa: "5.1.1",
1153
1003
  jsonschema: "^1.4.1",
1154
- listr2: "8.0.2",
1004
+ listr2: "8.2.0",
1155
1005
  "node-fetch": "2.7.0",
1156
1006
  "ts-deepmerge": "7.0.0"
1157
1007
  },
1158
1008
  devDependencies: {
1159
- "@tsconfig/node20": "20.1.2",
1160
- "@types/node": "20.11.30",
1009
+ "@tsconfig/node20": "20.1.4",
1010
+ "@types/node": "20.12.7",
1161
1011
  typescript: "5.2.2"
1162
1012
  },
1163
1013
  engines: {
@@ -1189,7 +1039,7 @@ const run = async () => {
1189
1039
  // Default command
1190
1040
  cli.command('').usage('\n\n Compile deployments and menus and create versions for MC applications').action(cli.outputHelp);
1191
1041
  const usageCompileDeployment = 'Compile the deployments for an application for all environments.';
1192
- 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.', {
1042
+ 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.', {
1193
1043
  default: 'application.html'
1194
1044
  }).option('--application-index-upload-script-out-file [path]', '(optional) The name of the the application index upload script file.', {
1195
1045
  default: 'upload-index.sh'
@@ -1201,15 +1051,15 @@ const run = async () => {
1201
1051
  await command$3(options, cwd);
1202
1052
  });
1203
1053
  const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
1204
- 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 => {
1054
+ 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 => {
1205
1055
  await command$2(options, cwd);
1206
1056
  });
1207
1057
  const usageValidateMenu = 'Validate compiled `menu.json` file';
1208
- 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 => {
1058
+ 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 => {
1209
1059
  await command(options);
1210
1060
  });
1211
1061
  const usageCreateVersion = 'Output a JSON string about the information in the `version.json` for a deployment, including the updated list of rollbacks.';
1212
- 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', {
1062
+ 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', {
1213
1063
  default: 15
1214
1064
  }).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 => {
1215
1065
  await command$1(options);