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