@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.
@@ -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-91932b24.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 _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$4(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$4(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
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,57 @@ 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;
193
+ if (!publicBaseUrl) {
194
+ var _context5;
195
+ throw new Error(_concatInstanceProperty__default["default"](_context5 = "'publicBaseUrl' is not defined for '".concat(tag, "' storage provider for ")).call(_context5, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1], " or as default."));
196
+ }
190
197
  return publicBaseUrl;
191
198
  }
192
199
  }]);
193
- return StorageProvider;
194
200
  }();
195
201
  var _bucketRegion2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
196
202
  var _bucketEnvironment2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
197
- let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
198
- _inherits(GoogleStorageProvider, _StorageProvider);
203
+ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
199
204
  function GoogleStorageProvider(config) {
200
- var _this;
205
+ var _this2;
201
206
  _classCallCheck(this, GoogleStorageProvider);
202
- _this = _callSuper(this, GoogleStorageProvider, [config]);
203
- _Object$defineProperty__default["default"](_assertThisInitialized(_this), _bucketRegion2$1, {
207
+ _this2 = _callSuper(this, GoogleStorageProvider, [config]);
208
+ _Object$defineProperty__default["default"](_this2, _bucketRegion2$1, {
204
209
  writable: true,
205
210
  value: void 0
206
211
  });
207
- _Object$defineProperty__default["default"](_assertThisInitialized(_this), _bucketEnvironment2$1, {
212
+ _Object$defineProperty__default["default"](_this2, _bucketEnvironment2$1, {
208
213
  writable: true,
209
214
  value: void 0
210
215
  });
211
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
212
- _classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
213
- return _this;
216
+ _classPrivateFieldLooseBase(_this2, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
217
+ _classPrivateFieldLooseBase(_this2, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
218
+ return _this2;
214
219
  }
215
- _createClass(GoogleStorageProvider, [{
220
+ _inherits(GoogleStorageProvider, _StorageProvider2);
221
+ return _createClass(GoogleStorageProvider, [{
216
222
  key: "getTag",
217
223
  value: function getTag() {
218
224
  return 'gs';
@@ -263,29 +269,28 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
263
269
  }, config));
264
270
  }
265
271
  }]);
266
- return GoogleStorageProvider;
267
272
  }(StorageProvider);
268
273
  var _bucketRegion3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
269
274
  var _bucketEnvironment3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
270
- let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
271
- _inherits(AwsStorageProvider, _StorageProvider2);
275
+ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider3) {
272
276
  function AwsStorageProvider(config) {
273
- var _this2;
277
+ var _this3;
274
278
  _classCallCheck(this, AwsStorageProvider);
275
- _this2 = _callSuper(this, AwsStorageProvider, [config]);
276
- _Object$defineProperty__default["default"](_assertThisInitialized(_this2), _bucketRegion3, {
279
+ _this3 = _callSuper(this, AwsStorageProvider, [config]);
280
+ _Object$defineProperty__default["default"](_this3, _bucketRegion3, {
277
281
  writable: true,
278
282
  value: void 0
279
283
  });
280
- _Object$defineProperty__default["default"](_assertThisInitialized(_this2), _bucketEnvironment3, {
284
+ _Object$defineProperty__default["default"](_this3, _bucketEnvironment3, {
281
285
  writable: true,
282
286
  value: void 0
283
287
  });
284
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
285
- _classPrivateFieldLooseBase(_assertThisInitialized(_this2), _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
286
- return _this2;
288
+ _classPrivateFieldLooseBase(_this3, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
289
+ _classPrivateFieldLooseBase(_this3, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
290
+ return _this3;
287
291
  }
288
- _createClass(AwsStorageProvider, [{
292
+ _inherits(AwsStorageProvider, _StorageProvider3);
293
+ return _createClass(AwsStorageProvider, [{
289
294
  key: "getTag",
290
295
  value: function getTag() {
291
296
  return 's3';
@@ -337,7 +342,6 @@ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
337
342
  }, config));
338
343
  }
339
344
  }]);
340
- return AwsStorageProvider;
341
345
  }(StorageProvider);
342
346
  function getStorageProvider(storageProvider, config) {
343
347
  switch (storageProvider) {
@@ -346,7 +350,7 @@ function getStorageProvider(storageProvider, config) {
346
350
  case 's3':
347
351
  return new AwsStorageProvider(config);
348
352
  default:
349
- throw new Error(`Storage provider ${storageProvider} not supported`);
353
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
350
354
  }
351
355
  }
352
356
 
@@ -366,9 +370,10 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
366
370
  _classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion] = config.bucketRegion;
367
371
  _classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment] = config.bucketEnvironment;
368
372
  }
369
- _createClass(GoogleStorageUploadScriptsGenerator, [{
373
+ return _createClass(GoogleStorageUploadScriptsGenerator, [{
370
374
  key: "getApplicationIndexUploadScript",
371
375
  value: function getApplicationIndexUploadScript(_ref) {
376
+ var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10;
372
377
  let packageManagerName = _ref.packageManagerName,
373
378
  bucketUrl = _ref.bucketUrl,
374
379
  cdnUrl = _ref.cdnUrl,
@@ -378,109 +383,18 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
378
383
  if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
379
384
  throw new Error("Missing 'bucketEnvironment' when generating application index.");
380
385
  }
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
- `;
386
+ 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
387
  }
411
388
  }, {
412
389
  key: "getProductionBundlesUploadScript",
413
390
  value: function getProductionBundlesUploadScript(_ref2) {
391
+ var _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18;
414
392
  let bucketUrl = _ref2.bucketUrl,
415
393
  assetsPath = _ref2.assetsPath,
416
394
  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
- `;
395
+ 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
396
  }
482
397
  }]);
483
- return GoogleStorageUploadScriptsGenerator;
484
398
  }();
485
399
  var _bucketEnvironment2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
486
400
  var _bucketRegion2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
@@ -498,105 +412,28 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
498
412
  _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2] = config.bucketRegion;
499
413
  _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2] = config.bucketEnvironment;
500
414
  }
501
- _createClass(AwsStorageUploadScriptsGenerator, [{
415
+ return _createClass(AwsStorageUploadScriptsGenerator, [{
502
416
  key: "getApplicationIndexUploadScript",
503
417
  value: function getApplicationIndexUploadScript(_ref3) {
418
+ var _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
504
419
  let packageManagerName = _ref3.packageManagerName,
505
420
  bucketUrl = _ref3.bucketUrl,
506
421
  cdnUrl = _ref3.cdnUrl,
507
422
  buildRevision = _ref3.buildRevision,
508
423
  buildNumber = _ref3.buildNumber,
509
424
  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 "$(dirname "$0")/${applicationIndexOutFile}" \\
518
- "${bucketUrl}/" \\
519
- --content-type="text/html" \\
520
- --cache-control="public,max-age=0,no-transform" \\
521
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
522
-
523
- echo "Creating version.json and uploading it to bucket ${bucketUrl}"
524
-
525
- NODE_ENV=production ${packageManagerName} application-cli create-version \\
526
- --version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2]}/version.json \\
527
- --build-revision=${buildRevision} \\
528
- --build-number=${buildNumber} \\
529
- --out-file=$(dirname "$0")/version.json
530
-
531
- aws s3 cp "$(dirname "$0")" \\
532
- "${bucketUrl}/" \\
533
- --exclude "*" \\
534
- --include "version.json" \\
535
- --content-type="application/json" \\
536
- --cache-control="public,max-age=0,no-transform" \\
537
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
538
- `;
425
+ 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\")/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");
539
426
  }
540
427
  }, {
541
428
  key: "getProductionBundlesUploadScript",
542
429
  value: function getProductionBundlesUploadScript(_ref4) {
430
+ var _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40;
543
431
  let bucketUrl = _ref4.bucketUrl,
544
432
  assetsPath = _ref4.assetsPath,
545
433
  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 ${assetsPath}/menu.json \\
591
- "${bucketUrl}/" \\
592
- --content-type="application/json" \\
593
- --cache-control="public,max-age=0,no-transform" \\
594
- --profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
595
- fi
596
- `;
434
+ 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");
597
435
  }
598
436
  }]);
599
- return AwsStorageUploadScriptsGenerator;
600
437
  }();
601
438
  function getUploadScriptsGenerator(storageProvider, config) {
602
439
  switch (storageProvider) {
@@ -605,12 +442,21 @@ function getUploadScriptsGenerator(storageProvider, config) {
605
442
  case 's3':
606
443
  return new AwsStorageUploadScriptsGenerator(config);
607
444
  default:
608
- throw new Error(`Storage provider ${storageProvider} not supported`);
445
+ throw new Error("Storage provider ".concat(storageProvider, " not supported"));
446
+ }
447
+ }
448
+
449
+ function doesFileExist(filePath) {
450
+ try {
451
+ fs__default$1["default"].accessSync(filePath);
452
+ return true;
453
+ } catch (e) {
454
+ return false;
609
455
  }
610
456
  }
611
457
 
612
458
  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; }
613
- 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; }
459
+ 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; }
614
460
  function loadDotenvFiles(_ref) {
615
461
  let dotenvPath = _ref.dotenvPath,
616
462
  cloudEnvironment = _ref.cloudEnvironment;
@@ -620,13 +466,13 @@ function loadDotenvFiles(_ref) {
620
466
  }
621
467
 
622
468
  // Check if the given path exists.
623
- if (!fs__default$1["default"].existsSync(dotenvPath)) {
624
- throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
469
+ if (!doesFileExist(dotenvPath)) {
470
+ throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
625
471
  }
626
472
 
627
473
  // Load the environment values
628
474
  const sharedDotenvFile = '.env.production';
629
- const cloudDotenvFile = `.env.${cloudEnvironment}`;
475
+ const cloudDotenvFile = ".env.".concat(cloudEnvironment);
630
476
 
631
477
  // The shared dotenv file across environments is optional
632
478
  const sharedProductionEnvironment = dotenv__default["default"].config({
@@ -638,16 +484,18 @@ function loadDotenvFiles(_ref) {
638
484
  path: path__default["default"].join(dotenvPath, cloudDotenvFile)
639
485
  });
640
486
  if (cloudSpecificProductionEnvironment.error) {
641
- throw new Error(`Failed loading '${cloudDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
487
+ var _context;
488
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
642
489
  }
643
490
  if (sharedProductionEnvironment.error) {
644
- throw new Error(`Failed loading '${sharedDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
491
+ var _context2;
492
+ throw new Error(_concatInstanceProperty__default["default"](_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
645
493
  }
646
494
  return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
647
495
  }
648
496
 
649
497
  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; }
650
- 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; }
498
+ 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; }
651
499
  function writeUploadScriptFile(_ref) {
652
500
  let fileName = _ref.fileName,
653
501
  fileContent = _ref.fileContent,
@@ -659,6 +507,7 @@ function writeUploadScriptFile(_ref) {
659
507
  });
660
508
  }
661
509
  async function compileApplicationAssets(_ref2) {
510
+ var _context, _context2;
662
511
  let cliFlags = _ref2.cliFlags,
663
512
  storageProvider = _ref2.storageProvider,
664
513
  uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
@@ -673,7 +522,7 @@ async function compileApplicationAssets(_ref2) {
673
522
  skipMenu: cliFlags.skipMenu
674
523
  });
675
524
  const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
676
- const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${storageProvider.getBucketRegion()}${parsedApplicationAssetsUploadScriptFile.ext}`;
525
+ const applicationAssetsUploadScriptFileName = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
677
526
  writeUploadScriptFile({
678
527
  fileName: applicationAssetsUploadScriptFileName,
679
528
  fileContent: applicationAssetsUploadScriptContent,
@@ -706,7 +555,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
706
555
  })), {}, {
707
556
  // The trailing slash is important to indicate to the CSP directive that all the resources
708
557
  // under that path should be allowed.
709
- MC_CDN_URL: `${cdnUrl}/`
558
+ MC_CDN_URL: "".concat(cdnUrl, "/")
710
559
  }, cliFlags.mcUrl ? {
711
560
  MC_URL: cliFlags.mcUrl
712
561
  } : {}), cliFlags.mcApiUrl ? {
@@ -763,7 +612,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
763
612
  }
764
613
  }
765
614
  async function command$3(cliFlags, cwd) {
766
- var _context;
615
+ var _context3;
767
616
  const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
768
617
  const applicationDirectory = getApplicationDirectory(cwd);
769
618
  let assetsPath;
@@ -780,12 +629,12 @@ async function command$3(cliFlags, cwd) {
780
629
  assetsPath
781
630
  };
782
631
  const defaultStorageProviders = [storageBucketsConfig.storageProviders.gs.tag];
783
- const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](storageBucketConfig)).call(_context, _ref4 => {
632
+ const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](storageBucketConfig)).call(_context3, _ref4 => {
784
633
  let _ref5 = _slicedToArray(_ref4, 2),
785
634
  bucketRegion = _ref5[0],
786
635
  bucketEnvironmentConfigs = _ref5[1];
787
636
  return {
788
- title: `Compiling for bucket region ${bucketRegion}`,
637
+ title: "Compiling for bucket region ".concat(bucketRegion),
789
638
  task: (_bucketRegionCtx, bucketRegionTask) => {
790
639
  // NOTE: Application assets need to be compiled
791
640
  // for all storage providers once per region.
@@ -800,7 +649,7 @@ async function command$3(cliFlags, cwd) {
800
649
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
801
650
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
802
651
  return {
803
- title: `Compiling application assets for '${storageProviderTag}'`,
652
+ title: "Compiling application assets for '".concat(storageProviderTag, "'"),
804
653
  task: () => compileApplicationAssets({
805
654
  cliFlags,
806
655
  storageProvider,
@@ -818,14 +667,14 @@ async function command$3(cliFlags, cwd) {
818
667
  bucketEnvironment
819
668
  };
820
669
  return {
821
- title: `Compiling for cloud environment '${cloudEnvironment}'`,
670
+ title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
822
671
  task: (_storageProviderCtx, storageProviderTask) => {
823
- var _context2;
824
- const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context2 = storageProviders || defaultStorageProviders).call(_context2, storageProviderTag => {
672
+ var _context4;
673
+ const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
825
674
  const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
826
675
  const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
827
676
  return {
828
- title: `Compiling application index for storage provider '${storageProviderTag}'`,
677
+ title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
829
678
  task: () => {
830
679
  return compileEnvironmentApplicationIndexes({
831
680
  cliFlags,
@@ -881,52 +730,58 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
881
730
  */
882
731
 
883
732
  const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
884
- var _context2;
733
+ var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
885
734
  const entryPointUriPath = config.env.entryPointUriPath;
886
735
 
887
736
  // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
888
- const accountLinks = config.env.__DEVELOPMENT__?.accountLinks ?? [];
737
+ 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 : [];
889
738
  if (accountLinks.length > 0) {
890
- return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => ({
891
- key: menuLink.uriPath,
892
- uriPath: menuLink.uriPath,
893
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
894
- permissions: menuLink.permissions ?? [],
895
- // @ts-ignore: not defined in schema, as it's only used internally.
896
- featureToggle: menuLink.featureToggle ?? null
897
- }));
739
+ return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => {
740
+ var _menuLink$permissions, _menuLink$featureTogg;
741
+ return {
742
+ key: menuLink.uriPath,
743
+ uriPath: menuLink.uriPath,
744
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
745
+ permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
746
+ // @ts-ignore: not defined in schema, as it's only used internally.
747
+ featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
748
+ };
749
+ });
898
750
  }
899
- const menuLinks = config.env.__DEVELOPMENT__?.menuLinks;
751
+ const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
900
752
  return {
901
753
  key: entryPointUriPath,
902
754
  uriPath: entryPointUriPath,
903
755
  icon: menuLinks.icon,
904
- labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks?.labelAllLocales, menuLinks?.defaultLabel),
756
+ labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
905
757
  permissions: menuLinks.permissions,
906
758
  // @ts-ignore: not defined in schema, as it's only used internally.
907
- featureToggle: menuLinks.featureToggle ?? null,
759
+ featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
908
760
  // @ts-ignore: not defined in schema, as it's only used internally.
909
- menuVisibility: menuLinks.menuVisibility ?? null,
761
+ menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
910
762
  // @ts-ignore: not defined in schema, as it's only used internally.
911
- actionRights: menuLinks.actionRights ?? null,
763
+ actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
912
764
  // @ts-ignore: not defined in schema, as it's only used internally.
913
- dataFences: menuLinks.dataFences ?? null,
914
- submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => ({
915
- key: submenuLink.uriPath.replace('/', '-'),
916
- uriPath: submenuLink.uriPath,
917
- labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
918
- permissions: submenuLink.permissions,
919
- // @ts-ignore: not defined in schema, as it's only used internally.
920
- featureToggle: submenuLink.featureToggle ?? null,
921
- // @ts-ignore: not defined in schema, as it's only used internally.
922
- menuVisibility: submenuLink.menuVisibility ?? null,
923
- // @ts-ignore: not defined in schema, as it's only used internally.
924
- actionRights: submenuLink.actionRights ?? null,
925
- // @ts-ignore: not defined in schema, as it's only used internally.
926
- dataFences: submenuLink.dataFences ?? null
927
- })),
765
+ dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
766
+ submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
767
+ var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
768
+ return {
769
+ key: submenuLink.uriPath.replace('/', '-'),
770
+ uriPath: submenuLink.uriPath,
771
+ labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
772
+ permissions: submenuLink.permissions,
773
+ // @ts-ignore: not defined in schema, as it's only used internally.
774
+ featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
775
+ // @ts-ignore: not defined in schema, as it's only used internally.
776
+ menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
777
+ // @ts-ignore: not defined in schema, as it's only used internally.
778
+ actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
779
+ // @ts-ignore: not defined in schema, as it's only used internally.
780
+ dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
781
+ };
782
+ }),
928
783
  // @ts-ignore: not defined in schema, as it's only used internally.
929
- shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
784
+ shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
930
785
  };
931
786
  };
932
787
  async function command$2(cliFlags, cwd) {
@@ -1108,15 +963,15 @@ function validateMenu(menuJson) {
1108
963
  async function command(cliFlags) {
1109
964
  const menuJsonPath = cliFlags.inputFile;
1110
965
  const isAppbarMenu = cliFlags.navigation === 'top';
1111
- if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
1112
- if (!fs__default$1["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
966
+ if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
967
+ if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
1113
968
  const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
1114
969
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
1115
970
  }
1116
971
 
1117
972
  var pkgJson = {
1118
973
  name: "@commercetools-frontend/application-cli",
1119
- version: "2.3.1",
974
+ version: "2.4.0",
1120
975
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
1121
976
  keywords: [
1122
977
  "commercetools",
@@ -1141,22 +996,22 @@ var pkgJson = {
1141
996
  "@babel/core": "^7.22.11",
1142
997
  "@babel/runtime": "^7.21.0",
1143
998
  "@babel/runtime-corejs3": "^7.21.0",
1144
- "@commercetools-frontend/application-config": "22.22.0",
1145
- "@commercetools-frontend/constants": "22.22.0",
1146
- "@commercetools-frontend/l10n": "22.22.0",
999
+ "@commercetools-frontend/application-config": "22.23.3",
1000
+ "@commercetools-frontend/constants": "22.23.3",
1001
+ "@commercetools-frontend/l10n": "22.23.3",
1147
1002
  "@manypkg/find-root": "2.2.1",
1148
1003
  cac: "^6.7.14",
1149
1004
  cosmiconfig: "9.0.0",
1150
- dotenv: "16.4.2",
1005
+ dotenv: "16.4.5",
1151
1006
  execa: "5.1.1",
1152
1007
  jsonschema: "^1.4.1",
1153
- listr2: "8.0.2",
1008
+ listr2: "8.2.0",
1154
1009
  "node-fetch": "2.7.0",
1155
1010
  "ts-deepmerge": "7.0.0"
1156
1011
  },
1157
1012
  devDependencies: {
1158
- "@tsconfig/node20": "20.1.2",
1159
- "@types/node": "20.12.2",
1013
+ "@tsconfig/node20": "20.1.4",
1014
+ "@types/node": "20.12.7",
1160
1015
  typescript: "5.2.2"
1161
1016
  },
1162
1017
  engines: {
@@ -1188,7 +1043,7 @@ const run = async () => {
1188
1043
  // Default command
1189
1044
  cli.command('').usage('\n\n Compile deployments and menus and create versions for MC applications').action(cli.outputHelp);
1190
1045
  const usageCompileDeployment = 'Compile the deployments for an application for all environments.';
1191
- 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.', {
1046
+ 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.', {
1192
1047
  default: 'application.html'
1193
1048
  }).option('--application-index-upload-script-out-file [path]', '(optional) The name of the the application index upload script file.', {
1194
1049
  default: 'upload-index.sh'
@@ -1200,15 +1055,15 @@ const run = async () => {
1200
1055
  await command$3(options, cwd);
1201
1056
  });
1202
1057
  const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
1203
- 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 => {
1058
+ 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 => {
1204
1059
  await command$2(options, cwd);
1205
1060
  });
1206
1061
  const usageValidateMenu = 'Validate compiled `menu.json` file';
1207
- 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 => {
1062
+ 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 => {
1208
1063
  await command(options);
1209
1064
  });
1210
1065
  const usageCreateVersion = 'Output a JSON string about the information in the `version.json` for a deployment, including the updated list of rollbacks.';
1211
- 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', {
1066
+ 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', {
1212
1067
  default: 15
1213
1068
  }).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 => {
1214
1069
  await command$1(options);