@commercetools-frontend/application-cli 3.0.2 → 3.1.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/cli/dist/commercetools-frontend-application-cli-cli.cjs.dev.js +267 -128
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +267 -128
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +267 -127
- package/dist/commercetools-frontend-application-cli.cjs.dev.js +1 -3
- package/dist/commercetools-frontend-application-cli.cjs.prod.js +1 -3
- package/dist/commercetools-frontend-application-cli.esm.js +1 -3
- package/dist/declarations/src/constants.d.ts +2 -0
- package/dist/{storage-buckets-config-2f9a9168.cjs.prod.js → storage-buckets-config-a24cb35d.cjs.prod.js} +13 -16
- package/dist/{storage-buckets-config-89962880.cjs.dev.js → storage-buckets-config-e69e5c69.cjs.dev.js} +13 -16
- package/dist/{storage-buckets-config-6e04b3d3.esm.js → storage-buckets-config-f59a9bbc.esm.js} +13 -14
- package/package.json +7 -7
|
@@ -13,12 +13,11 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
|
|
|
13
13
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
14
14
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
15
15
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
16
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
17
16
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
18
17
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
19
18
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
20
19
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
21
|
-
var storageBucketsConfig = require('../../dist/storage-buckets-config-
|
|
20
|
+
var storageBucketsConfig = require('../../dist/storage-buckets-config-a24cb35d.cjs.prod.js');
|
|
22
21
|
var fs = require('node:fs');
|
|
23
22
|
var path$1 = require('node:path');
|
|
24
23
|
var listr2 = require('listr2');
|
|
@@ -63,7 +62,6 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
63
62
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
64
63
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
65
64
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
66
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
67
65
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
68
66
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
69
67
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
@@ -100,7 +98,7 @@ function isCI() {
|
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
103
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
101
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$4(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$4(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
104
102
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
105
103
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
106
104
|
var _bucketRegion$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
@@ -133,7 +131,7 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
133
131
|
value: function getBucketNamespace(prNumber) {
|
|
134
132
|
if (!prNumber) return;
|
|
135
133
|
if (prNumber === 'merchant-center-preview') return prNumber;
|
|
136
|
-
return
|
|
134
|
+
return `mc-${prNumber}`;
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
/**
|
|
@@ -142,7 +140,7 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
142
140
|
}, {
|
|
143
141
|
key: "getAssetsBucketUrl",
|
|
144
142
|
value: function getAssetsBucketUrl(_ref) {
|
|
145
|
-
var
|
|
143
|
+
var _context;
|
|
146
144
|
let applicationName = _ref.applicationName,
|
|
147
145
|
bucketProtocol = _ref.bucketProtocol,
|
|
148
146
|
bucketNamespace = _ref.bucketNamespace,
|
|
@@ -151,14 +149,13 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
151
149
|
throw new Error("'bucketRegion' is not defined. Required to determine 'assetsBucketUrl'.");
|
|
152
150
|
}
|
|
153
151
|
const storageProvider = storageBucketsConfig.storageProviders[tag];
|
|
154
|
-
const assetBuketUrl =
|
|
152
|
+
const assetBuketUrl = storageProvider.urls.bucket?.[_classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1]] ?? _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1];
|
|
155
153
|
const assetsBucketUrl = _filterInstanceProperty__default["default"](_context = [assetBuketUrl, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
|
|
156
|
-
return
|
|
154
|
+
return `${bucketProtocol}${assetsBucketUrl}`;
|
|
157
155
|
}
|
|
158
156
|
}, {
|
|
159
157
|
key: "getApplicationIndexBucketUrl",
|
|
160
158
|
value: function getApplicationIndexBucketUrl(_ref2) {
|
|
161
|
-
var _context3;
|
|
162
159
|
let tag = _ref2.tag,
|
|
163
160
|
prNumber = _ref2.prNumber,
|
|
164
161
|
applicationName = _ref2.applicationName,
|
|
@@ -171,31 +168,29 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
171
168
|
bucketProtocol,
|
|
172
169
|
bucketNamespace
|
|
173
170
|
});
|
|
174
|
-
const applicationIndexBucketUrl =
|
|
171
|
+
const applicationIndexBucketUrl = `${applicationAssetsBucketUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]}`;
|
|
175
172
|
return applicationIndexBucketUrl;
|
|
176
173
|
}
|
|
177
174
|
}, {
|
|
178
175
|
key: "getCdnUrl",
|
|
179
176
|
value: function getCdnUrl(_ref3) {
|
|
180
|
-
var
|
|
177
|
+
var _context2;
|
|
181
178
|
let applicationName = _ref3.applicationName,
|
|
182
179
|
prNumber = _ref3.prNumber,
|
|
183
180
|
publicBaseUrl = _ref3.publicBaseUrl,
|
|
184
181
|
excludeBucketRegion = _ref3.excludeBucketRegion;
|
|
185
|
-
return _filterInstanceProperty__default["default"](
|
|
182
|
+
return _filterInstanceProperty__default["default"](_context2 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context2, Boolean).join('/');
|
|
186
183
|
}
|
|
187
184
|
}, {
|
|
188
185
|
key: "getPublicBaseUrl",
|
|
189
186
|
value: function getPublicBaseUrl(tag) {
|
|
190
|
-
var _storageProvider$urls3;
|
|
191
187
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
|
|
192
188
|
throw new Error("'bucketEnvironment' is not defined. Required to determine 'publicBaseUrl'.");
|
|
193
189
|
}
|
|
194
190
|
const storageProvider = storageBucketsConfig.storageProviders[tag];
|
|
195
|
-
const publicBaseUrl =
|
|
191
|
+
const publicBaseUrl = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]] ?? storageProvider.urls.public.default;
|
|
196
192
|
if (!publicBaseUrl) {
|
|
197
|
-
|
|
198
|
-
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."));
|
|
193
|
+
throw new Error(`'publicBaseUrl' is not defined for '${tag}' storage provider for ${_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]} or as default.`);
|
|
199
194
|
}
|
|
200
195
|
return publicBaseUrl;
|
|
201
196
|
}
|
|
@@ -353,7 +348,7 @@ function getStorageProvider(storageProvider, config) {
|
|
|
353
348
|
case 's3':
|
|
354
349
|
return new AwsStorageProvider(config);
|
|
355
350
|
default:
|
|
356
|
-
throw new Error(
|
|
351
|
+
throw new Error(`Storage provider ${storageProvider} not supported`);
|
|
357
352
|
}
|
|
358
353
|
}
|
|
359
354
|
|
|
@@ -376,7 +371,6 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
376
371
|
return _createClass(GoogleStorageUploadScriptsGenerator, [{
|
|
377
372
|
key: "getApplicationIndexUploadScript",
|
|
378
373
|
value: function getApplicationIndexUploadScript(_ref) {
|
|
379
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10;
|
|
380
374
|
let packageManagerName = _ref.packageManagerName,
|
|
381
375
|
bucketUrl = _ref.bucketUrl,
|
|
382
376
|
cdnUrl = _ref.cdnUrl,
|
|
@@ -386,16 +380,106 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
386
380
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
|
|
387
381
|
throw new Error("Missing 'bucketEnvironment' when generating application index.");
|
|
388
382
|
}
|
|
389
|
-
return
|
|
383
|
+
return `
|
|
384
|
+
#!/usr/bin/env bash
|
|
385
|
+
|
|
386
|
+
set -e
|
|
387
|
+
|
|
388
|
+
echo "Uploading compiled ${applicationIndexOutFile} to Google Storage bucket ${bucketUrl}"
|
|
389
|
+
|
|
390
|
+
gcloud storage cp \\
|
|
391
|
+
"$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
392
|
+
"${bucketUrl}/" \\
|
|
393
|
+
-z html \\
|
|
394
|
+
--content-type="text/html" \\
|
|
395
|
+
--cache-control="public,max-age=0,no-transform"
|
|
396
|
+
|
|
397
|
+
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
398
|
+
|
|
399
|
+
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
400
|
+
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
|
|
401
|
+
--build-revision=${buildRevision} \\
|
|
402
|
+
--build-number=${buildNumber} \\
|
|
403
|
+
--out-file=$(dirname "$0")/version.json
|
|
404
|
+
|
|
405
|
+
gcloud storage cp \\
|
|
406
|
+
"$(dirname "$0")/version.json" \\
|
|
407
|
+
"${bucketUrl}/" \\
|
|
408
|
+
-z json \\
|
|
409
|
+
--content-type="application/json" \\
|
|
410
|
+
--cache-control="public,max-age=0,no-transform"
|
|
411
|
+
`;
|
|
390
412
|
}
|
|
391
413
|
}, {
|
|
392
414
|
key: "getProductionBundlesUploadScript",
|
|
393
415
|
value: function getProductionBundlesUploadScript(_ref2) {
|
|
394
|
-
var _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18;
|
|
395
416
|
let bucketUrl = _ref2.bucketUrl,
|
|
396
417
|
assetsPath = _ref2.assetsPath,
|
|
397
418
|
skipMenu = _ref2.skipMenu;
|
|
398
|
-
return
|
|
419
|
+
return `
|
|
420
|
+
#!/usr/bin/env bash
|
|
421
|
+
|
|
422
|
+
set -e
|
|
423
|
+
|
|
424
|
+
# NOTES:
|
|
425
|
+
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
426
|
+
# 1. The '-z' option triggers compressing the assets before
|
|
427
|
+
# uploading them and sets the 'Content-Encoding' to 'gzip'.
|
|
428
|
+
# 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.
|
|
429
|
+
# 3. The 'max-age' is set to 1 year which is considered the maximum
|
|
430
|
+
# "valid" lifetime of an asset to be cached.
|
|
431
|
+
# 4. The '-n' will skip uploading existing files and prevents them to
|
|
432
|
+
# be overwritten
|
|
433
|
+
echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
|
|
434
|
+
|
|
435
|
+
gcloud storage cp \\
|
|
436
|
+
${assetsPath}/public/{*.css,*.js,*.js.map,*.html} \\
|
|
437
|
+
"${bucketUrl}" \\
|
|
438
|
+
-n \\
|
|
439
|
+
-z js,css \\
|
|
440
|
+
--cache-control="public,max-age=31536000,no-transform"
|
|
441
|
+
|
|
442
|
+
# We need to upload the PNG and HTML files separately because we want them
|
|
443
|
+
# to be able to overwrite the existing files (if any). For instance, the
|
|
444
|
+
# file or the favicons.
|
|
445
|
+
# This is controlled with the '-n' option (which is used for the JS and CSS
|
|
446
|
+
# as we don't want to overwrite them)
|
|
447
|
+
gcloud storage cp \\
|
|
448
|
+
${assetsPath}/public/{*.png,robots.txt} \\
|
|
449
|
+
"${bucketUrl}" \\
|
|
450
|
+
-z txt \\
|
|
451
|
+
--cache-control="public,max-age=31536000,no-transform"
|
|
452
|
+
|
|
453
|
+
if ${skipMenu}; then
|
|
454
|
+
echo "Skipping menu.json upload"
|
|
455
|
+
else
|
|
456
|
+
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
457
|
+
# NOTE: somehow the 'cache-control:private' doesn't work.
|
|
458
|
+
# I mean, the file is uploaded with the correct metadata but when I fetch
|
|
459
|
+
# the file the response contains the header
|
|
460
|
+
# 'cache-control: public,max-age=31536000,no-transform', even though the
|
|
461
|
+
# documentation clearly states that by marking the header as 'private' will
|
|
462
|
+
# disable the cache (for publicly readable objects).
|
|
463
|
+
# https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
|
|
464
|
+
# However, I found out that, by requesting the file with any RANDOM
|
|
465
|
+
# query parameter, will instruct the storage to return a 'fresh' object
|
|
466
|
+
# (without any cache control).
|
|
467
|
+
# Unofficial source: https://stackoverflow.com/a/49052895
|
|
468
|
+
# This seems to be the 'easiest' option to 'disable' the cache for public
|
|
469
|
+
# objects. Other alternative approaces are:
|
|
470
|
+
# * make the object private with some simple ACL (private objects are not cached)
|
|
471
|
+
# * suffix the file name with e.g. the git SHA, so we have different files
|
|
472
|
+
# for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
|
|
473
|
+
# the git SHA on runtime and can get the correct file when it starts.
|
|
474
|
+
# * find out why the 'private' cache control does not work
|
|
475
|
+
gcloud storage cp \\
|
|
476
|
+
${assetsPath}/menu.json \\
|
|
477
|
+
${bucketUrl} \\
|
|
478
|
+
-z json \\
|
|
479
|
+
--content-type="application/json" \\
|
|
480
|
+
--cache-control="public,max-age=0,no-transform"
|
|
481
|
+
fi
|
|
482
|
+
`;
|
|
399
483
|
}
|
|
400
484
|
}]);
|
|
401
485
|
}();
|
|
@@ -418,23 +502,97 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
418
502
|
return _createClass(AwsStorageUploadScriptsGenerator, [{
|
|
419
503
|
key: "getApplicationIndexUploadScript",
|
|
420
504
|
value: function getApplicationIndexUploadScript(_ref3) {
|
|
421
|
-
var _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
|
|
422
505
|
let packageManagerName = _ref3.packageManagerName,
|
|
423
506
|
bucketUrl = _ref3.bucketUrl,
|
|
424
507
|
cdnUrl = _ref3.cdnUrl,
|
|
425
508
|
buildRevision = _ref3.buildRevision,
|
|
426
509
|
buildNumber = _ref3.buildNumber,
|
|
427
510
|
applicationIndexOutFile = _ref3.applicationIndexOutFile;
|
|
428
|
-
return
|
|
511
|
+
return `
|
|
512
|
+
#!/usr/bin/env bash
|
|
513
|
+
|
|
514
|
+
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
515
|
+
|
|
516
|
+
set -e
|
|
517
|
+
|
|
518
|
+
aws s3 cp "$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
519
|
+
"${bucketUrl}/" \\
|
|
520
|
+
--content-type="text/html" \\
|
|
521
|
+
--cache-control="public,max-age=0,no-transform" \\
|
|
522
|
+
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
523
|
+
|
|
524
|
+
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
525
|
+
|
|
526
|
+
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
527
|
+
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2]}/version.json \\
|
|
528
|
+
--build-revision=${buildRevision} \\
|
|
529
|
+
--build-number=${buildNumber} \\
|
|
530
|
+
--out-file=$(dirname "$0")/version.json
|
|
531
|
+
|
|
532
|
+
aws s3 cp "$(dirname "$0")/version.json" \\
|
|
533
|
+
"${bucketUrl}/" \\
|
|
534
|
+
--content-type="application/json" \\
|
|
535
|
+
--cache-control="public,max-age=0,no-transform" \\
|
|
536
|
+
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
537
|
+
`;
|
|
429
538
|
}
|
|
430
539
|
}, {
|
|
431
540
|
key: "getProductionBundlesUploadScript",
|
|
432
541
|
value: function getProductionBundlesUploadScript(_ref4) {
|
|
433
|
-
var _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40;
|
|
434
542
|
let bucketUrl = _ref4.bucketUrl,
|
|
435
543
|
assetsPath = _ref4.assetsPath,
|
|
436
544
|
skipMenu = _ref4.skipMenu;
|
|
437
|
-
return
|
|
545
|
+
return `
|
|
546
|
+
#!/usr/bin/env bash
|
|
547
|
+
|
|
548
|
+
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
549
|
+
|
|
550
|
+
set -e
|
|
551
|
+
|
|
552
|
+
# NOTE:
|
|
553
|
+
# The sync command on the AWS CLI is different to the -n option on the gcloud CLI.
|
|
554
|
+
# Sync will only upload files that are not already in the bucket, but it will skip existing ones
|
|
555
|
+
# that have been changed locally.
|
|
556
|
+
# The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.
|
|
557
|
+
# https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
|
|
558
|
+
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
559
|
+
#
|
|
560
|
+
# Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.
|
|
561
|
+
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring
|
|
562
|
+
aws s3 sync ${assetsPath}/public \\
|
|
563
|
+
"${bucketUrl}" \\
|
|
564
|
+
--exclude "*" \\
|
|
565
|
+
--include "*.css" \\
|
|
566
|
+
--include "*.js" \\
|
|
567
|
+
--include "*.js.map" \\
|
|
568
|
+
--include "*.html" \\
|
|
569
|
+
--cache-control="public,max-age=31536000,no-transform" \\
|
|
570
|
+
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
571
|
+
|
|
572
|
+
# We need to upload the PNG and HTML files separately because we want them
|
|
573
|
+
# to be able to overwrite the existing files (if any). For instance, the
|
|
574
|
+
# file or the favicons.
|
|
575
|
+
aws s3 cp ${assetsPath}/public \\
|
|
576
|
+
"${bucketUrl}" \\
|
|
577
|
+
--recursive \\
|
|
578
|
+
--exclude "*" \\
|
|
579
|
+
--include "*.png" \\
|
|
580
|
+
--include "robots.txt" \\
|
|
581
|
+
--cache-control="public,max-age=31536000,no-transform" \\
|
|
582
|
+
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
583
|
+
|
|
584
|
+
if ${skipMenu}; then
|
|
585
|
+
echo "Skipping menu.json upload"
|
|
586
|
+
else
|
|
587
|
+
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
588
|
+
|
|
589
|
+
aws s3 cp ${assetsPath}/menu.json \\
|
|
590
|
+
"${bucketUrl}/" \\
|
|
591
|
+
--content-type="application/json" \\
|
|
592
|
+
--cache-control="public,max-age=0,no-transform" \\
|
|
593
|
+
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
594
|
+
fi
|
|
595
|
+
`;
|
|
438
596
|
}
|
|
439
597
|
}]);
|
|
440
598
|
}();
|
|
@@ -445,7 +603,7 @@ function getUploadScriptsGenerator(storageProvider, config) {
|
|
|
445
603
|
case 's3':
|
|
446
604
|
return new AwsStorageUploadScriptsGenerator(config);
|
|
447
605
|
default:
|
|
448
|
-
throw new Error(
|
|
606
|
+
throw new Error(`Storage provider ${storageProvider} not supported`);
|
|
449
607
|
}
|
|
450
608
|
}
|
|
451
609
|
|
|
@@ -459,7 +617,7 @@ function doesFileExist(filePath) {
|
|
|
459
617
|
}
|
|
460
618
|
|
|
461
619
|
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; }
|
|
462
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
620
|
+
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; }
|
|
463
621
|
function loadDotenvFiles(_ref) {
|
|
464
622
|
let dotenvPath = _ref.dotenvPath,
|
|
465
623
|
cloudEnvironment = _ref.cloudEnvironment;
|
|
@@ -470,12 +628,12 @@ function loadDotenvFiles(_ref) {
|
|
|
470
628
|
|
|
471
629
|
// Check if the given path exists.
|
|
472
630
|
if (!doesFileExist(dotenvPath)) {
|
|
473
|
-
throw new Error(
|
|
631
|
+
throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
|
|
474
632
|
}
|
|
475
633
|
|
|
476
634
|
// Load the environment values
|
|
477
635
|
const sharedDotenvFile = '.env.production';
|
|
478
|
-
const cloudDotenvFile =
|
|
636
|
+
const cloudDotenvFile = `.env.${cloudEnvironment}`;
|
|
479
637
|
|
|
480
638
|
// The shared dotenv file across environments is optional
|
|
481
639
|
const sharedProductionEnvironment = dotenv__default["default"].config({
|
|
@@ -487,18 +645,16 @@ function loadDotenvFiles(_ref) {
|
|
|
487
645
|
path: path__default["default"].join(dotenvPath, cloudDotenvFile)
|
|
488
646
|
});
|
|
489
647
|
if (cloudSpecificProductionEnvironment.error) {
|
|
490
|
-
|
|
491
|
-
throw new Error(_concatInstanceProperty__default["default"](_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
|
|
648
|
+
throw new Error(`Failed loading '${cloudDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
|
|
492
649
|
}
|
|
493
650
|
if (sharedProductionEnvironment.error) {
|
|
494
|
-
|
|
495
|
-
throw new Error(_concatInstanceProperty__default["default"](_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
|
|
651
|
+
throw new Error(`Failed loading '${sharedDotenvFile}' in '${dotenvPath}'. Make sure it exists.`);
|
|
496
652
|
}
|
|
497
653
|
return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
|
|
498
654
|
}
|
|
499
655
|
|
|
500
656
|
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; }
|
|
501
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
657
|
+
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; }
|
|
502
658
|
function writeUploadScriptFile(_ref) {
|
|
503
659
|
let fileName = _ref.fileName,
|
|
504
660
|
fileContent = _ref.fileContent,
|
|
@@ -510,7 +666,6 @@ function writeUploadScriptFile(_ref) {
|
|
|
510
666
|
});
|
|
511
667
|
}
|
|
512
668
|
async function compileApplicationAssets(_ref2) {
|
|
513
|
-
var _context, _context2;
|
|
514
669
|
let cliFlags = _ref2.cliFlags,
|
|
515
670
|
storageProvider = _ref2.storageProvider,
|
|
516
671
|
uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
|
|
@@ -525,7 +680,7 @@ async function compileApplicationAssets(_ref2) {
|
|
|
525
680
|
skipMenu: cliFlags.skipMenu
|
|
526
681
|
});
|
|
527
682
|
const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
528
|
-
const applicationAssetsUploadScriptFileName =
|
|
683
|
+
const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${storageProvider.getBucketRegion()}${parsedApplicationAssetsUploadScriptFile.ext}`;
|
|
529
684
|
writeUploadScriptFile({
|
|
530
685
|
fileName: applicationAssetsUploadScriptFileName,
|
|
531
686
|
fileContent: applicationAssetsUploadScriptContent,
|
|
@@ -558,7 +713,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
558
713
|
})), {}, {
|
|
559
714
|
// The trailing slash is important to indicate to the CSP directive that all the resources
|
|
560
715
|
// under that path should be allowed.
|
|
561
|
-
MC_CDN_URL:
|
|
716
|
+
MC_CDN_URL: `${cdnUrl}/`
|
|
562
717
|
}, cliFlags.mcUrl ? {
|
|
563
718
|
MC_URL: cliFlags.mcUrl
|
|
564
719
|
} : {}), cliFlags.mcApiUrl ? {
|
|
@@ -615,7 +770,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
615
770
|
}
|
|
616
771
|
}
|
|
617
772
|
async function command$4(cliFlags, cwd) {
|
|
618
|
-
var
|
|
773
|
+
var _context;
|
|
619
774
|
const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
|
|
620
775
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
621
776
|
let assetsPath;
|
|
@@ -632,12 +787,12 @@ async function command$4(cliFlags, cwd) {
|
|
|
632
787
|
assetsPath
|
|
633
788
|
};
|
|
634
789
|
const defaultStorageProviders = [storageBucketsConfig.storageProviders.gs.tag];
|
|
635
|
-
const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](
|
|
790
|
+
const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](storageBucketConfig)).call(_context, _ref4 => {
|
|
636
791
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
637
792
|
bucketRegion = _ref5[0],
|
|
638
793
|
bucketEnvironmentConfigs = _ref5[1];
|
|
639
794
|
return {
|
|
640
|
-
title:
|
|
795
|
+
title: `Compiling for bucket region ${bucketRegion}`,
|
|
641
796
|
task: (_bucketRegionCtx, bucketRegionTask) => {
|
|
642
797
|
// NOTE: Application assets need to be compiled
|
|
643
798
|
// for all storage providers once per region.
|
|
@@ -652,7 +807,7 @@ async function command$4(cliFlags, cwd) {
|
|
|
652
807
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
653
808
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
|
|
654
809
|
return {
|
|
655
|
-
title:
|
|
810
|
+
title: `Compiling application assets for '${storageProviderTag}'`,
|
|
656
811
|
task: () => compileApplicationAssets({
|
|
657
812
|
cliFlags,
|
|
658
813
|
storageProvider,
|
|
@@ -670,14 +825,14 @@ async function command$4(cliFlags, cwd) {
|
|
|
670
825
|
bucketEnvironment
|
|
671
826
|
};
|
|
672
827
|
return {
|
|
673
|
-
title:
|
|
828
|
+
title: `Compiling for cloud environment '${cloudEnvironment}'`,
|
|
674
829
|
task: (_storageProviderCtx, storageProviderTask) => {
|
|
675
|
-
var
|
|
676
|
-
const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](
|
|
830
|
+
var _context2;
|
|
831
|
+
const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context2 = storageProviders || defaultStorageProviders).call(_context2, storageProviderTag => {
|
|
677
832
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
678
833
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
|
|
679
834
|
return {
|
|
680
|
-
title:
|
|
835
|
+
title: `Compiling application index for storage provider '${storageProviderTag}'`,
|
|
681
836
|
task: () => {
|
|
682
837
|
return compileEnvironmentApplicationIndexes({
|
|
683
838
|
cliFlags,
|
|
@@ -733,58 +888,52 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
|
733
888
|
*/
|
|
734
889
|
|
|
735
890
|
const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
736
|
-
var
|
|
891
|
+
var _context2;
|
|
737
892
|
const entryPointUriPath = config.env.entryPointUriPath;
|
|
738
893
|
|
|
739
894
|
// @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
|
|
740
|
-
const accountLinks =
|
|
895
|
+
const accountLinks = config.env.__DEVELOPMENT__?.accountLinks ?? [];
|
|
741
896
|
if (accountLinks.length > 0) {
|
|
742
|
-
return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
|
|
751
|
-
};
|
|
752
|
-
});
|
|
897
|
+
return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => ({
|
|
898
|
+
key: menuLink.uriPath,
|
|
899
|
+
uriPath: menuLink.uriPath,
|
|
900
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
|
|
901
|
+
permissions: menuLink.permissions ?? [],
|
|
902
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
903
|
+
featureToggle: menuLink.featureToggle ?? null
|
|
904
|
+
}));
|
|
753
905
|
}
|
|
754
|
-
const menuLinks =
|
|
906
|
+
const menuLinks = config.env.__DEVELOPMENT__?.menuLinks;
|
|
755
907
|
return {
|
|
756
908
|
key: entryPointUriPath,
|
|
757
909
|
uriPath: entryPointUriPath,
|
|
758
910
|
icon: menuLinks.icon,
|
|
759
|
-
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks
|
|
911
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks?.labelAllLocales, menuLinks?.defaultLabel),
|
|
760
912
|
permissions: menuLinks.permissions,
|
|
761
913
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
762
|
-
featureToggle:
|
|
914
|
+
featureToggle: menuLinks.featureToggle ?? null,
|
|
763
915
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
764
|
-
menuVisibility:
|
|
916
|
+
menuVisibility: menuLinks.menuVisibility ?? null,
|
|
765
917
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
766
|
-
actionRights:
|
|
918
|
+
actionRights: menuLinks.actionRights ?? null,
|
|
767
919
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
768
|
-
dataFences:
|
|
769
|
-
submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
|
|
784
|
-
};
|
|
785
|
-
}),
|
|
920
|
+
dataFences: menuLinks.dataFences ?? null,
|
|
921
|
+
submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => ({
|
|
922
|
+
key: submenuLink.uriPath.replace('/', '-'),
|
|
923
|
+
uriPath: submenuLink.uriPath,
|
|
924
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
|
|
925
|
+
permissions: submenuLink.permissions,
|
|
926
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
927
|
+
featureToggle: submenuLink.featureToggle ?? null,
|
|
928
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
929
|
+
menuVisibility: submenuLink.menuVisibility ?? null,
|
|
930
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
931
|
+
actionRights: submenuLink.actionRights ?? null,
|
|
932
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
933
|
+
dataFences: submenuLink.dataFences ?? null
|
|
934
|
+
})),
|
|
786
935
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
787
|
-
shouldRenderDivider:
|
|
936
|
+
shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
|
|
788
937
|
};
|
|
789
938
|
};
|
|
790
939
|
async function command$3(cliFlags, cwd) {
|
|
@@ -864,51 +1013,43 @@ async function command$2(cliFlags) {
|
|
|
864
1013
|
*/
|
|
865
1014
|
const git = {
|
|
866
1015
|
// https://git-scm.com/docs/git-merge-base
|
|
867
|
-
base: (baseBranch, headRevision) => {
|
|
868
|
-
var _context;
|
|
869
|
-
return _concatInstanceProperty__default["default"](_context = "git merge-base ".concat(baseBranch, " ")).call(_context, headRevision);
|
|
870
|
-
},
|
|
1016
|
+
base: (baseBranch, headRevision) => `git merge-base ${baseBranch} ${headRevision}`,
|
|
871
1017
|
// https://git-scm.com/docs/git-diff
|
|
872
|
-
changedFiles: (mergeRevision, headRevision) => {
|
|
873
|
-
|
|
874
|
-
return _concatInstanceProperty__default["default"](_context2 = "git diff --name-only ".concat(mergeRevision, " ")).call(_context2, headRevision);
|
|
875
|
-
},
|
|
876
|
-
commitMessage: headRevision => "git log --format=oneline -n 1 ".concat(headRevision)
|
|
1018
|
+
changedFiles: (mergeRevision, headRevision) => `git diff --name-only ${mergeRevision} ${headRevision}`,
|
|
1019
|
+
commitMessage: headRevision => `git log --format=oneline -n 1 ${headRevision}`
|
|
877
1020
|
};
|
|
878
1021
|
const helpers = {
|
|
879
1022
|
async writeOutDotEnvFile(cliFlags, cwd, matchingTriggers) {
|
|
880
|
-
var
|
|
1023
|
+
var _context;
|
|
881
1024
|
// If desired read the env file and write out the matching triggers.
|
|
882
1025
|
if (!cliFlags.outEnvFile) {
|
|
883
1026
|
return;
|
|
884
1027
|
}
|
|
885
1028
|
const filePath = path__default$1["default"].join(fs__default["default"].realpathSync(cwd), cliFlags.outEnvFile);
|
|
886
|
-
const fileContents = _mapInstanceProperty__default["default"](
|
|
887
|
-
var _context5;
|
|
1029
|
+
const fileContents = _mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](matchingTriggers)).call(_context, _ref => {
|
|
888
1030
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
889
1031
|
triggerName = _ref2[0],
|
|
890
1032
|
triggerValue = _ref2[1];
|
|
891
|
-
const triggerNameForEnvFile =
|
|
1033
|
+
const triggerNameForEnvFile = `${snakeCase__default["default"](triggerName).toUpperCase()}`;
|
|
892
1034
|
|
|
893
1035
|
// General pipeline optimization hints are not transformed
|
|
894
1036
|
if (_startsWithInstanceProperty__default["default"](triggerName).call(triggerName, 'allowPipelineOptimizations')) {
|
|
895
|
-
|
|
896
|
-
return _concatInstanceProperty__default["default"](_context4 = "".concat(triggerNameForEnvFile, "=")).call(_context4, triggerValue);
|
|
1037
|
+
return `${triggerNameForEnvFile}=${triggerValue}`;
|
|
897
1038
|
}
|
|
898
|
-
return
|
|
1039
|
+
return `DID_${triggerNameForEnvFile}_CHANGE=${triggerValue}`;
|
|
899
1040
|
}).join('\n');
|
|
900
1041
|
await fs__default["default"].promises.writeFile(filePath, fileContents);
|
|
901
1042
|
if (!cliFlags.silent) {
|
|
902
|
-
console.log(
|
|
1043
|
+
console.log(`📝 Wrote out file to '${filePath}' with contents:`);
|
|
903
1044
|
console.log(fileContents);
|
|
904
1045
|
}
|
|
905
1046
|
},
|
|
906
1047
|
async getChangedFiles(cliFlags) {
|
|
907
|
-
var
|
|
1048
|
+
var _context2, _context3;
|
|
908
1049
|
const baseCmdResult = await execa.command(git.base(cliFlags.baseBranch, cliFlags.headRevision));
|
|
909
1050
|
const mergeRevision = baseCmdResult.stdout;
|
|
910
1051
|
const changedFilesCmdResult = await execa.command(git.changedFiles(mergeRevision, cliFlags.headRevision));
|
|
911
|
-
const changedFiles = _filterInstanceProperty__default["default"](
|
|
1052
|
+
const changedFiles = _filterInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](_context3 = changedFilesCmdResult.stdout.split('\n')).call(_context3, filePath => _trimInstanceProperty__default["default"](filePath).call(filePath))).call(_context2, filePath => filePath.length > 0);
|
|
912
1053
|
return changedFiles;
|
|
913
1054
|
},
|
|
914
1055
|
async matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles) {
|
|
@@ -916,7 +1057,6 @@ const helpers = {
|
|
|
916
1057
|
|
|
917
1058
|
// Evaluate each trigger against each file.
|
|
918
1059
|
_forEachInstanceProperty__default["default"](config).call(config, async trigger => {
|
|
919
|
-
var _trigger$exclude;
|
|
920
1060
|
const hasTriggerBeenInitialized = typeof matchedTriggers[trigger.name] === 'number';
|
|
921
1061
|
|
|
922
1062
|
// Given the trigger with this name was never evaluated it has to be defaulted to 0.
|
|
@@ -934,10 +1074,10 @@ const helpers = {
|
|
|
934
1074
|
ignore: trigger.ignore
|
|
935
1075
|
});
|
|
936
1076
|
if (!cliFlags.silent && anyFileChangedForTrigger) {
|
|
937
|
-
console.log(
|
|
1077
|
+
console.log(`ℹ️ Files for trigger ${trigger.name} changed.`);
|
|
938
1078
|
}
|
|
939
1079
|
let onlyExcludedFilesChangedForTrigger = false;
|
|
940
|
-
if (
|
|
1080
|
+
if (trigger.exclude?.length > 0) {
|
|
941
1081
|
// NOTE: `micromatch.every` evaluates if every file matches
|
|
942
1082
|
// every pattern.
|
|
943
1083
|
// We need to evaluate if every file matches some pattern.
|
|
@@ -948,7 +1088,7 @@ const helpers = {
|
|
|
948
1088
|
});
|
|
949
1089
|
}
|
|
950
1090
|
if (!cliFlags.silent && onlyExcludedFilesChangedForTrigger) {
|
|
951
|
-
console.log(
|
|
1091
|
+
console.log(`ℹ️ Only excluded files for trigger ${trigger.name} changed.`);
|
|
952
1092
|
}
|
|
953
1093
|
if (onlyExcludedFilesChangedForTrigger) {
|
|
954
1094
|
matchedTriggers[trigger.name] = 0;
|
|
@@ -965,19 +1105,18 @@ async function command$1(cliFlags, config, cwd) {
|
|
|
965
1105
|
const isDevelopmentBranch = cliFlags.branch !== cliFlags.baseBranch;
|
|
966
1106
|
const triggersContainingSharedFiles = _filterInstanceProperty__default["default"](config).call(config, trigger => trigger.containsSharedFiles);
|
|
967
1107
|
if (!cliFlags.silent) {
|
|
968
|
-
|
|
969
|
-
console.log(
|
|
970
|
-
console.log(
|
|
971
|
-
console.log(_concatInstanceProperty__default["default"](_context8 = "\uD83D\uDEA7 Comparing '".concat(cliFlags.baseBranch, "' against '")).call(_context8, cliFlags.headRevision, "' to determine changed files."));
|
|
1108
|
+
console.log(`ℹ️ Pipeline optimizations are ${enablePipelineOptimizations ? 'enabled' : 'disabled'}.`);
|
|
1109
|
+
console.log(`ℹ️ Changes have been commited to the ${isDevelopmentBranch ? 'a development' : 'the main'} branch.`);
|
|
1110
|
+
console.log(`🚧 Comparing '${cliFlags.baseBranch}' against '${cliFlags.headRevision}' to determine changed files.`);
|
|
972
1111
|
}
|
|
973
1112
|
|
|
974
1113
|
// Collect and parse changed files from git comparing base and head revision.
|
|
975
1114
|
const changedFiles = await helpers.getChangedFiles(cliFlags);
|
|
976
1115
|
if (!cliFlags.silent) {
|
|
977
1116
|
if (changedFiles.length === 0) {
|
|
978
|
-
console.log(
|
|
1117
|
+
console.log(`ℹ️ No changes found.`);
|
|
979
1118
|
} else {
|
|
980
|
-
console.log(
|
|
1119
|
+
console.log(`ℹ️ ${changedFiles.length} changes found.`);
|
|
981
1120
|
}
|
|
982
1121
|
}
|
|
983
1122
|
|
|
@@ -988,17 +1127,17 @@ async function command$1(cliFlags, config, cwd) {
|
|
|
988
1127
|
const hasCommitMessageTrigger = commitMessage && _includesInstanceProperty__default["default"](commitMessage).call(commitMessage, '[ci all]');
|
|
989
1128
|
const doesSharedTriggerMatch = _someInstanceProperty__default["default"](triggersContainingSharedFiles).call(triggersContainingSharedFiles, triggerContainingSharedFiles => matchedTriggers[triggerContainingSharedFiles.name] === 1);
|
|
990
1129
|
if (!cliFlags.silent) {
|
|
991
|
-
console.log(
|
|
1130
|
+
console.log(`ℹ️ The git commit message ${hasCommitMessageTrigger ? 'does' : 'does not'} contain a [ci all] trigger.`);
|
|
992
1131
|
}
|
|
993
1132
|
const doesPackageFolderTriggerMatch = matchedTriggers[cliFlags.triggerName] === 1;
|
|
994
1133
|
if (enablePipelineOptimizations && isDevelopmentBranch && !hasCommitMessageTrigger && !doesSharedTriggerMatch && !doesPackageFolderTriggerMatch) {
|
|
995
1134
|
if (!cliFlags.silent) {
|
|
996
|
-
console.log(
|
|
1135
|
+
console.log(`ℹ️ No relevant changes found for ${cliFlags.triggerName}.`);
|
|
997
1136
|
}
|
|
998
1137
|
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 1;
|
|
999
1138
|
} else {
|
|
1000
1139
|
if (!cliFlags.silent) {
|
|
1001
|
-
console.log(
|
|
1140
|
+
console.log(`ℹ️ Relevant changes found for ${cliFlags.triggerName}.`);
|
|
1002
1141
|
}
|
|
1003
1142
|
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 0;
|
|
1004
1143
|
}
|
|
@@ -1118,15 +1257,15 @@ function validateMenu(menuJson) {
|
|
|
1118
1257
|
async function command(cliFlags) {
|
|
1119
1258
|
const menuJsonPath = cliFlags.inputFile;
|
|
1120
1259
|
const isAppbarMenu = cliFlags.navigation === 'top';
|
|
1121
|
-
if (!menuJsonPath) throw new Error(
|
|
1122
|
-
if (!doesFileExist(menuJsonPath)) throw new Error(
|
|
1260
|
+
if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
|
|
1261
|
+
if (!doesFileExist(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
|
|
1123
1262
|
const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
|
|
1124
1263
|
return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
|
|
1125
1264
|
}
|
|
1126
1265
|
|
|
1127
1266
|
var pkgJson = {
|
|
1128
1267
|
name: "@commercetools-frontend/application-cli",
|
|
1129
|
-
version: "3.0
|
|
1268
|
+
version: "3.1.0",
|
|
1130
1269
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
1131
1270
|
keywords: [
|
|
1132
1271
|
"commercetools",
|
|
@@ -1152,26 +1291,26 @@ var pkgJson = {
|
|
|
1152
1291
|
"@babel/core": "^7.22.11",
|
|
1153
1292
|
"@babel/runtime": "^7.21.0",
|
|
1154
1293
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
1155
|
-
"@commercetools-frontend/application-config": "22.
|
|
1156
|
-
"@commercetools-frontend/constants": "22.
|
|
1157
|
-
"@commercetools-frontend/l10n": "22.
|
|
1294
|
+
"@commercetools-frontend/application-config": "22.30.3",
|
|
1295
|
+
"@commercetools-frontend/constants": "22.30.3",
|
|
1296
|
+
"@commercetools-frontend/l10n": "22.30.3",
|
|
1158
1297
|
"@manypkg/find-root": "2.2.2",
|
|
1159
1298
|
cac: "^6.7.14",
|
|
1160
1299
|
cosmiconfig: "9.0.0",
|
|
1161
1300
|
dotenv: "16.4.5",
|
|
1162
1301
|
execa: "5.1.1",
|
|
1163
1302
|
jsonschema: "^1.4.1",
|
|
1164
|
-
listr2: "8.2.
|
|
1303
|
+
listr2: "8.2.4",
|
|
1165
1304
|
lodash: "4.17.21",
|
|
1166
1305
|
micromatch: "4.0.7",
|
|
1167
1306
|
"node-fetch": "2.7.0",
|
|
1168
|
-
"ts-deepmerge": "7.0.
|
|
1307
|
+
"ts-deepmerge": "7.0.1"
|
|
1169
1308
|
},
|
|
1170
1309
|
devDependencies: {
|
|
1171
1310
|
"@tsconfig/node20": "20.1.4",
|
|
1172
1311
|
"@types/lodash": "^4.14.198",
|
|
1173
1312
|
"@types/micromatch": "4.0.9",
|
|
1174
|
-
"@types/node": "20.14.
|
|
1313
|
+
"@types/node": "20.14.15",
|
|
1175
1314
|
typescript: "5.2.2"
|
|
1176
1315
|
},
|
|
1177
1316
|
engines: {
|
|
@@ -1203,7 +1342,7 @@ const run = async () => {
|
|
|
1203
1342
|
// Default command
|
|
1204
1343
|
cli.command('').usage('\n\n Compile deployments and menus and create versions for MC applications').action(cli.outputHelp);
|
|
1205
1344
|
const usageCompileDeployment = 'Compile the deployments for an application for all environments.';
|
|
1206
|
-
cli.command('compile-deployments', usageCompileDeployment).usage(
|
|
1345
|
+
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.', {
|
|
1207
1346
|
default: 'application.html'
|
|
1208
1347
|
}).option('--application-index-upload-script-out-file [path]', '(optional) The name of the the application index upload script file.', {
|
|
1209
1348
|
default: 'upload-index.sh'
|
|
@@ -1215,15 +1354,15 @@ const run = async () => {
|
|
|
1215
1354
|
await command$4(options, cwd);
|
|
1216
1355
|
});
|
|
1217
1356
|
const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
|
|
1218
|
-
cli.command('compile-menu', usageCompileMenu).usage(
|
|
1357
|
+
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 => {
|
|
1219
1358
|
await command$3(options, cwd);
|
|
1220
1359
|
});
|
|
1221
1360
|
const usageValidateMenu = 'Validate compiled `menu.json` file';
|
|
1222
|
-
cli.command('validate-menu', usageValidateMenu).usage(
|
|
1361
|
+
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 => {
|
|
1223
1362
|
await command(options);
|
|
1224
1363
|
});
|
|
1225
1364
|
const usageCreateVersion = 'Output a JSON string about the information in the `version.json` for a deployment, including the updated list of rollbacks.';
|
|
1226
|
-
cli.command('create-version', usageCreateVersion).usage(
|
|
1365
|
+
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', {
|
|
1227
1366
|
default: 15
|
|
1228
1367
|
}).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 => {
|
|
1229
1368
|
await command$2(options);
|
|
@@ -1231,7 +1370,7 @@ const run = async () => {
|
|
|
1231
1370
|
|
|
1232
1371
|
// Command: Evaluate change triggers
|
|
1233
1372
|
const usageEvaluateChangeTriggers = 'Evaluates changed files against a base and evaluates them against defined triggers.';
|
|
1234
|
-
cli.command('evaluate-change-triggers', usageEvaluateChangeTriggers).usage(
|
|
1373
|
+
cli.command('evaluate-change-triggers', usageEvaluateChangeTriggers).usage(`evaluate-change-triggers \n\n ${usageEvaluateChangeTriggers}`).option('--branch <string>', 'The branch of the pull request', {
|
|
1235
1374
|
default: process.env.CIRCLE_BRANCH
|
|
1236
1375
|
}).option('--base-branch <string>', 'The base revision of the git commit compare against (e.g. "main")').option('--head-revision <string>', 'The revision of the git head to compare with', {
|
|
1237
1376
|
default: process.env.CIRCLE_SHA1
|