@commercetools-frontend/application-cli 6.1.9 → 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 +121 -300
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +121 -300
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +120 -300
- 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 +5 -5
|
@@ -9,11 +9,12 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
|
|
|
9
9
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
10
10
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
11
11
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
12
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
12
13
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
13
14
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
14
15
|
import _Set from '@babel/runtime-corejs3/core-js-stable/set';
|
|
15
16
|
import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
|
|
16
|
-
import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts, a as loadConfig } from '../../dist/storage-buckets-config-
|
|
17
|
+
import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts, a as loadConfig } from '../../dist/storage-buckets-config-3894c4d6.esm.js';
|
|
17
18
|
import fs from 'node:fs';
|
|
18
19
|
import path$1 from 'node:path';
|
|
19
20
|
import { Listr } from 'listr2';
|
|
@@ -44,7 +45,6 @@ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/ins
|
|
|
44
45
|
import micromatch from 'micromatch';
|
|
45
46
|
import snakeCase from 'lodash/snakeCase';
|
|
46
47
|
import { Validator } from 'jsonschema';
|
|
47
|
-
import '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
48
48
|
import 'cosmiconfig';
|
|
49
49
|
import 'ts-deepmerge';
|
|
50
50
|
import 'lodash';
|
|
@@ -63,7 +63,7 @@ function isCI() {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function ownKeys$4(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
66
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
66
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$4(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$4(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
67
67
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
68
68
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
69
69
|
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; }
|
|
@@ -97,7 +97,7 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
97
97
|
value: function getBucketNamespace(prNumber) {
|
|
98
98
|
if (!prNumber) return;
|
|
99
99
|
if (prNumber === 'merchant-center-preview') return prNumber;
|
|
100
|
-
return
|
|
100
|
+
return "mc-".concat(prNumber);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
@@ -106,7 +106,7 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
106
106
|
}, {
|
|
107
107
|
key: "getAssetsBucketUrl",
|
|
108
108
|
value: function getAssetsBucketUrl(_ref) {
|
|
109
|
-
var _context;
|
|
109
|
+
var _storageProvider$urls, _storageProvider$urls2, _context, _context2;
|
|
110
110
|
let applicationName = _ref.applicationName,
|
|
111
111
|
bucketProtocol = _ref.bucketProtocol,
|
|
112
112
|
bucketNamespace = _ref.bucketNamespace,
|
|
@@ -115,13 +115,14 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
115
115
|
throw new Error("'bucketRegion' is not defined. Required to determine 'assetsBucketUrl'.");
|
|
116
116
|
}
|
|
117
117
|
const storageProvider = storageProviders[tag];
|
|
118
|
-
const assetBuketUrl = storageProvider.urls.bucket
|
|
118
|
+
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];
|
|
119
119
|
const assetsBucketUrl = _filterInstanceProperty(_context = [assetBuketUrl, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
|
|
120
|
-
return
|
|
120
|
+
return _concatInstanceProperty(_context2 = "".concat(bucketProtocol)).call(_context2, assetsBucketUrl);
|
|
121
121
|
}
|
|
122
122
|
}, {
|
|
123
123
|
key: "getApplicationIndexBucketUrl",
|
|
124
124
|
value: function getApplicationIndexBucketUrl(_ref2) {
|
|
125
|
+
var _context3;
|
|
125
126
|
let tag = _ref2.tag,
|
|
126
127
|
prNumber = _ref2.prNumber,
|
|
127
128
|
applicationName = _ref2.applicationName,
|
|
@@ -134,29 +135,31 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
134
135
|
bucketProtocol,
|
|
135
136
|
bucketNamespace
|
|
136
137
|
});
|
|
137
|
-
const applicationIndexBucketUrl =
|
|
138
|
+
const applicationIndexBucketUrl = _concatInstanceProperty(_context3 = "".concat(applicationAssetsBucketUrl, "/")).call(_context3, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]);
|
|
138
139
|
return applicationIndexBucketUrl;
|
|
139
140
|
}
|
|
140
141
|
}, {
|
|
141
142
|
key: "getCdnUrl",
|
|
142
143
|
value: function getCdnUrl(_ref3) {
|
|
143
|
-
var
|
|
144
|
+
var _context4;
|
|
144
145
|
let applicationName = _ref3.applicationName,
|
|
145
146
|
prNumber = _ref3.prNumber,
|
|
146
147
|
publicBaseUrl = _ref3.publicBaseUrl,
|
|
147
148
|
excludeBucketRegion = _ref3.excludeBucketRegion;
|
|
148
|
-
return _filterInstanceProperty(
|
|
149
|
+
return _filterInstanceProperty(_context4 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context4, Boolean).join('/');
|
|
149
150
|
}
|
|
150
151
|
}, {
|
|
151
152
|
key: "getPublicBaseUrl",
|
|
152
153
|
value: function getPublicBaseUrl(tag) {
|
|
154
|
+
var _storageProvider$urls3;
|
|
153
155
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
|
|
154
156
|
throw new Error("'bucketEnvironment' is not defined. Required to determine 'publicBaseUrl'.");
|
|
155
157
|
}
|
|
156
158
|
const storageProvider = storageProviders[tag];
|
|
157
|
-
const publicBaseUrl = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]
|
|
159
|
+
const publicBaseUrl = (_storageProvider$urls3 = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]) !== null && _storageProvider$urls3 !== void 0 ? _storageProvider$urls3 : storageProvider.urls.public.default;
|
|
158
160
|
if (!publicBaseUrl) {
|
|
159
|
-
|
|
161
|
+
var _context5;
|
|
162
|
+
throw new Error(_concatInstanceProperty(_context5 = "'publicBaseUrl' is not defined for '".concat(tag, "' storage provider for ")).call(_context5, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1], " or as default."));
|
|
160
163
|
}
|
|
161
164
|
return publicBaseUrl;
|
|
162
165
|
}
|
|
@@ -314,7 +317,7 @@ function getStorageProvider(storageProvider, config) {
|
|
|
314
317
|
case 's3':
|
|
315
318
|
return new AwsStorageProvider(config);
|
|
316
319
|
default:
|
|
317
|
-
throw new Error(
|
|
320
|
+
throw new Error("Storage provider ".concat(storageProvider, " not supported"));
|
|
318
321
|
}
|
|
319
322
|
}
|
|
320
323
|
|
|
@@ -337,6 +340,7 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
337
340
|
return _createClass(GoogleStorageUploadScriptsGenerator, [{
|
|
338
341
|
key: "getApplicationIndexUploadScript",
|
|
339
342
|
value: function getApplicationIndexUploadScript(_ref) {
|
|
343
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context0;
|
|
340
344
|
let packageManagerName = _ref.packageManagerName,
|
|
341
345
|
bucketUrl = _ref.bucketUrl,
|
|
342
346
|
cdnUrl = _ref.cdnUrl,
|
|
@@ -346,138 +350,16 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
346
350
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
|
|
347
351
|
throw new Error("Missing 'bucketEnvironment' when generating application index.");
|
|
348
352
|
}
|
|
349
|
-
return
|
|
350
|
-
#!/usr/bin/env bash
|
|
351
|
-
|
|
352
|
-
set -e
|
|
353
|
-
|
|
354
|
-
echo "Uploading compiled ${applicationIndexOutFile} to Google Storage bucket ${bucketUrl}"
|
|
355
|
-
|
|
356
|
-
gcloud storage cp \\
|
|
357
|
-
"$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
358
|
-
"${bucketUrl}/" \\
|
|
359
|
-
-z html \\
|
|
360
|
-
--content-type="text/html" \\
|
|
361
|
-
--cache-control="public,max-age=0,no-transform"
|
|
362
|
-
|
|
363
|
-
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
364
|
-
|
|
365
|
-
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
366
|
-
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
|
|
367
|
-
--build-revision=${buildRevision} \\
|
|
368
|
-
--build-number=${buildNumber} \\
|
|
369
|
-
--out-file=$(dirname "$0")/version.json
|
|
370
|
-
|
|
371
|
-
gcloud storage cp \\
|
|
372
|
-
"$(dirname "$0")/version.json" \\
|
|
373
|
-
"${bucketUrl}/" \\
|
|
374
|
-
-z json \\
|
|
375
|
-
--content-type="application/json" \\
|
|
376
|
-
--cache-control="public,max-age=0,no-transform"
|
|
377
|
-
`;
|
|
353
|
+
return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = _concatInstanceProperty(_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");
|
|
378
354
|
}
|
|
379
355
|
}, {
|
|
380
356
|
key: "getProductionBundlesUploadScript",
|
|
381
357
|
value: function getProductionBundlesUploadScript(_ref2) {
|
|
358
|
+
var _context1, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19;
|
|
382
359
|
let bucketUrl = _ref2.bucketUrl,
|
|
383
360
|
assetsPath = _ref2.assetsPath,
|
|
384
361
|
skipMenu = _ref2.skipMenu;
|
|
385
|
-
return
|
|
386
|
-
#!/usr/bin/env bash
|
|
387
|
-
|
|
388
|
-
set -e
|
|
389
|
-
|
|
390
|
-
# NOTES:
|
|
391
|
-
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
392
|
-
# 1. The '-z' option triggers compressing the assets before
|
|
393
|
-
# uploading them and sets the 'Content-Encoding' to 'gzip'.
|
|
394
|
-
# 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.
|
|
395
|
-
# 3. The 'max-age' is set to 1 year which is considered the maximum
|
|
396
|
-
# "valid" lifetime of an asset to be cached.
|
|
397
|
-
# 4. The '-n' will skip uploading existing files and prevents them to
|
|
398
|
-
# be overwritten
|
|
399
|
-
echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
|
|
400
|
-
|
|
401
|
-
# List of required file types
|
|
402
|
-
required_files=("*.css" "*.js" "*.js.map" "*.html")
|
|
403
|
-
|
|
404
|
-
# List of optional file types
|
|
405
|
-
optional_files=("*.svg")
|
|
406
|
-
|
|
407
|
-
# Check for the existence of required files
|
|
408
|
-
for file_pattern in "\${required_files[@]}"; do
|
|
409
|
-
if ! find "${assetsPath}/public" -type f -name "$file_pattern" -print -quit | grep -q .; then
|
|
410
|
-
echo "Error: No required files matching $file_pattern found in ${assetsPath}/public."
|
|
411
|
-
exit 1
|
|
412
|
-
fi
|
|
413
|
-
done
|
|
414
|
-
|
|
415
|
-
# Initialize source_pattern with required files
|
|
416
|
-
source_pattern="${assetsPath}/public/{$(IFS=,; echo "\${required_files[*]}")"
|
|
417
|
-
|
|
418
|
-
# Check for optional files and add them to the source_pattern if they exist
|
|
419
|
-
for file_pattern in "\${optional_files[@]}"; do
|
|
420
|
-
if find "${assetsPath}/public" -type f -name "$file_pattern" -print -quit | grep -q .; then
|
|
421
|
-
source_pattern+=",\${file_pattern}"
|
|
422
|
-
fi
|
|
423
|
-
done
|
|
424
|
-
|
|
425
|
-
# Close the brace in source_pattern
|
|
426
|
-
source_pattern+="}"
|
|
427
|
-
|
|
428
|
-
echo "Uploading files using the following pattern: \${source_pattern}"
|
|
429
|
-
|
|
430
|
-
# Expand the source_pattern variable as the below command will not work if the variable is a string
|
|
431
|
-
expanded_source_pattern=$(eval echo $source_pattern)
|
|
432
|
-
|
|
433
|
-
gcloud storage cp \\
|
|
434
|
-
$expanded_source_pattern \\
|
|
435
|
-
"${bucketUrl}" \\
|
|
436
|
-
-n \\
|
|
437
|
-
-z js,css \\
|
|
438
|
-
--cache-control="public,max-age=31536000,no-transform"
|
|
439
|
-
|
|
440
|
-
# We need to upload the PNG and HTML files separately because we want them
|
|
441
|
-
# to be able to overwrite the existing files (if any). For instance, the
|
|
442
|
-
# file or the favicons.
|
|
443
|
-
# This is controlled with the '-n' option (which is used for the JS and CSS
|
|
444
|
-
# as we don't want to overwrite them)
|
|
445
|
-
gcloud storage cp \\
|
|
446
|
-
${assetsPath}/public/{*.png,robots.txt} \\
|
|
447
|
-
"${bucketUrl}" \\
|
|
448
|
-
-z txt \\
|
|
449
|
-
--cache-control="public,max-age=31536000,no-transform"
|
|
450
|
-
|
|
451
|
-
if ${skipMenu}; then
|
|
452
|
-
echo "Skipping menu.json upload"
|
|
453
|
-
else
|
|
454
|
-
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
455
|
-
# NOTE: somehow the 'cache-control:private' doesn't work.
|
|
456
|
-
# I mean, the file is uploaded with the correct metadata but when I fetch
|
|
457
|
-
# the file the response contains the header
|
|
458
|
-
# 'cache-control: public,max-age=31536000,no-transform', even though the
|
|
459
|
-
# documentation clearly states that by marking the header as 'private' will
|
|
460
|
-
# disable the cache (for publicly readable objects).
|
|
461
|
-
# https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
|
|
462
|
-
# However, I found out that, by requesting the file with any RANDOM
|
|
463
|
-
# query parameter, will instruct the storage to return a 'fresh' object
|
|
464
|
-
# (without any cache control).
|
|
465
|
-
# Unofficial source: https://stackoverflow.com/a/49052895
|
|
466
|
-
# This seems to be the 'easiest' option to 'disable' the cache for public
|
|
467
|
-
# objects. Other alternative approaces are:
|
|
468
|
-
# * make the object private with some simple ACL (private objects are not cached)
|
|
469
|
-
# * suffix the file name with e.g. the git SHA, so we have different files
|
|
470
|
-
# for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
|
|
471
|
-
# the git SHA on runtime and can get the correct file when it starts.
|
|
472
|
-
# * find out why the 'private' cache control does not work
|
|
473
|
-
gcloud storage cp \\
|
|
474
|
-
${assetsPath}/menu.json \\
|
|
475
|
-
${bucketUrl} \\
|
|
476
|
-
-z json \\
|
|
477
|
-
--content-type="application/json" \\
|
|
478
|
-
--cache-control="public,max-age=0,no-transform"
|
|
479
|
-
fi
|
|
480
|
-
`;
|
|
362
|
+
return _concatInstanceProperty(_context1 = _concatInstanceProperty(_context10 = _concatInstanceProperty(_context11 = _concatInstanceProperty(_context12 = _concatInstanceProperty(_context13 = _concatInstanceProperty(_context14 = _concatInstanceProperty(_context15 = _concatInstanceProperty(_context16 = _concatInstanceProperty(_context17 = _concatInstanceProperty(_context18 = _concatInstanceProperty(_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");
|
|
481
363
|
}
|
|
482
364
|
}]);
|
|
483
365
|
}();
|
|
@@ -500,104 +382,23 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
500
382
|
return _createClass(AwsStorageUploadScriptsGenerator, [{
|
|
501
383
|
key: "getApplicationIndexUploadScript",
|
|
502
384
|
value: function getApplicationIndexUploadScript(_ref3) {
|
|
385
|
+
var _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30;
|
|
503
386
|
let packageManagerName = _ref3.packageManagerName,
|
|
504
387
|
bucketUrl = _ref3.bucketUrl,
|
|
505
388
|
cdnUrl = _ref3.cdnUrl,
|
|
506
389
|
buildRevision = _ref3.buildRevision,
|
|
507
390
|
buildNumber = _ref3.buildNumber,
|
|
508
391
|
applicationIndexOutFile = _ref3.applicationIndexOutFile;
|
|
509
|
-
return
|
|
510
|
-
#!/usr/bin/env bash
|
|
511
|
-
|
|
512
|
-
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
513
|
-
|
|
514
|
-
set -e
|
|
515
|
-
|
|
516
|
-
aws s3 cp "$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
517
|
-
"${bucketUrl}/" \\
|
|
518
|
-
--content-type="text/html" \\
|
|
519
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
520
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
521
|
-
|
|
522
|
-
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
523
|
-
|
|
524
|
-
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
525
|
-
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2]}/version.json \\
|
|
526
|
-
--build-revision=${buildRevision} \\
|
|
527
|
-
--build-number=${buildNumber} \\
|
|
528
|
-
--out-file=$(dirname "$0")/version.json
|
|
529
|
-
|
|
530
|
-
aws s3 cp "$(dirname "$0")/version.json" \\
|
|
531
|
-
"${bucketUrl}/" \\
|
|
532
|
-
--content-type="application/json" \\
|
|
533
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
534
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
535
|
-
`;
|
|
392
|
+
return _concatInstanceProperty(_context20 = _concatInstanceProperty(_context21 = _concatInstanceProperty(_context22 = _concatInstanceProperty(_context23 = _concatInstanceProperty(_context24 = _concatInstanceProperty(_context25 = _concatInstanceProperty(_context26 = _concatInstanceProperty(_context27 = _concatInstanceProperty(_context28 = _concatInstanceProperty(_context29 = _concatInstanceProperty(_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");
|
|
536
393
|
}
|
|
537
394
|
}, {
|
|
538
395
|
key: "getProductionBundlesUploadScript",
|
|
539
396
|
value: function getProductionBundlesUploadScript(_ref4) {
|
|
397
|
+
var _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40, _context41, _context42, _context43;
|
|
540
398
|
let bucketUrl = _ref4.bucketUrl,
|
|
541
399
|
assetsPath = _ref4.assetsPath,
|
|
542
400
|
skipMenu = _ref4.skipMenu;
|
|
543
|
-
return
|
|
544
|
-
#!/usr/bin/env bash
|
|
545
|
-
|
|
546
|
-
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
547
|
-
|
|
548
|
-
set -e
|
|
549
|
-
|
|
550
|
-
# Check for the existence of the application required files types
|
|
551
|
-
if ! find "${assetsPath}" -type f -regex ".*\\.\\(css\\|js\\|html\\)" | grep -q .; then
|
|
552
|
-
echo "Error: No CSS, JS, or HTML files found in ${assetsPath}."
|
|
553
|
-
exit 1
|
|
554
|
-
fi
|
|
555
|
-
|
|
556
|
-
# NOTE:
|
|
557
|
-
# The sync command on the AWS CLI is different to the -n option on the gcloud CLI.
|
|
558
|
-
# Sync will only upload files that are not already in the bucket, but it will skip existing ones
|
|
559
|
-
# that have been changed locally.
|
|
560
|
-
# The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.
|
|
561
|
-
# https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
|
|
562
|
-
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
563
|
-
#
|
|
564
|
-
# Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.
|
|
565
|
-
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring
|
|
566
|
-
aws s3 sync ${assetsPath}/public \\
|
|
567
|
-
"${bucketUrl}" \\
|
|
568
|
-
--exclude "*" \\
|
|
569
|
-
--include "*.css" \\
|
|
570
|
-
--include "*.js" \\
|
|
571
|
-
--include "*.js.map" \\
|
|
572
|
-
--include "*.html" \\
|
|
573
|
-
--include "*.svg" \\
|
|
574
|
-
--cache-control="public,max-age=31536000,no-transform" \\
|
|
575
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
576
|
-
|
|
577
|
-
# We need to upload the PNG and HTML files separately because we want them
|
|
578
|
-
# to be able to overwrite the existing files (if any). For instance, the
|
|
579
|
-
# file or the favicons.
|
|
580
|
-
aws s3 cp ${assetsPath}/public \\
|
|
581
|
-
"${bucketUrl}" \\
|
|
582
|
-
--recursive \\
|
|
583
|
-
--exclude "*" \\
|
|
584
|
-
--include "*.png" \\
|
|
585
|
-
--include "robots.txt" \\
|
|
586
|
-
--cache-control="public,max-age=31536000,no-transform" \\
|
|
587
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
588
|
-
|
|
589
|
-
if ${skipMenu}; then
|
|
590
|
-
echo "Skipping menu.json upload"
|
|
591
|
-
else
|
|
592
|
-
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
593
|
-
|
|
594
|
-
aws s3 cp ${assetsPath}/menu.json \\
|
|
595
|
-
"${bucketUrl}/" \\
|
|
596
|
-
--content-type="application/json" \\
|
|
597
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
598
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
599
|
-
fi
|
|
600
|
-
`;
|
|
401
|
+
return _concatInstanceProperty(_context31 = _concatInstanceProperty(_context32 = _concatInstanceProperty(_context33 = _concatInstanceProperty(_context34 = _concatInstanceProperty(_context35 = _concatInstanceProperty(_context36 = _concatInstanceProperty(_context37 = _concatInstanceProperty(_context38 = _concatInstanceProperty(_context39 = _concatInstanceProperty(_context40 = _concatInstanceProperty(_context41 = _concatInstanceProperty(_context42 = _concatInstanceProperty(_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");
|
|
601
402
|
}
|
|
602
403
|
}]);
|
|
603
404
|
}();
|
|
@@ -608,7 +409,7 @@ function getUploadScriptsGenerator(storageProvider, config) {
|
|
|
608
409
|
case 's3':
|
|
609
410
|
return new AwsStorageUploadScriptsGenerator(config);
|
|
610
411
|
default:
|
|
611
|
-
throw new Error(
|
|
412
|
+
throw new Error("Storage provider ".concat(storageProvider, " not supported"));
|
|
612
413
|
}
|
|
613
414
|
}
|
|
614
415
|
|
|
@@ -622,7 +423,7 @@ function doesFileExist(filePath) {
|
|
|
622
423
|
}
|
|
623
424
|
|
|
624
425
|
function ownKeys$3(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
625
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
426
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$3(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$3(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
626
427
|
function loadDotenvFiles(_ref) {
|
|
627
428
|
let dotenvPath = _ref.dotenvPath,
|
|
628
429
|
cloudEnvironment = _ref.cloudEnvironment;
|
|
@@ -633,12 +434,12 @@ function loadDotenvFiles(_ref) {
|
|
|
633
434
|
|
|
634
435
|
// Check if the given path exists.
|
|
635
436
|
if (!doesFileExist(dotenvPath)) {
|
|
636
|
-
throw new Error(
|
|
437
|
+
throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
|
|
637
438
|
}
|
|
638
439
|
|
|
639
440
|
// Load the environment values
|
|
640
441
|
const sharedDotenvFile = '.env.production';
|
|
641
|
-
const cloudDotenvFile =
|
|
442
|
+
const cloudDotenvFile = ".env.".concat(cloudEnvironment);
|
|
642
443
|
|
|
643
444
|
// The shared dotenv file across environments is optional
|
|
644
445
|
const sharedProductionEnvironment = dotenv.config({
|
|
@@ -650,16 +451,18 @@ function loadDotenvFiles(_ref) {
|
|
|
650
451
|
path: path.join(dotenvPath, cloudDotenvFile)
|
|
651
452
|
});
|
|
652
453
|
if (cloudSpecificProductionEnvironment.error) {
|
|
653
|
-
|
|
454
|
+
var _context;
|
|
455
|
+
throw new Error(_concatInstanceProperty(_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
|
|
654
456
|
}
|
|
655
457
|
if (sharedProductionEnvironment.error) {
|
|
656
|
-
|
|
458
|
+
var _context2;
|
|
459
|
+
throw new Error(_concatInstanceProperty(_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
|
|
657
460
|
}
|
|
658
461
|
return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
|
|
659
462
|
}
|
|
660
463
|
|
|
661
464
|
function ownKeys$2(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
662
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
465
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys$2(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys$2(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
663
466
|
function writeUploadScriptFile(_ref) {
|
|
664
467
|
let fileName = _ref.fileName,
|
|
665
468
|
fileContent = _ref.fileContent,
|
|
@@ -671,6 +474,7 @@ function writeUploadScriptFile(_ref) {
|
|
|
671
474
|
});
|
|
672
475
|
}
|
|
673
476
|
async function compileApplicationAssets(_ref2) {
|
|
477
|
+
var _context, _context2;
|
|
674
478
|
let cliFlags = _ref2.cliFlags,
|
|
675
479
|
storageProvider = _ref2.storageProvider,
|
|
676
480
|
uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
|
|
@@ -685,7 +489,7 @@ async function compileApplicationAssets(_ref2) {
|
|
|
685
489
|
skipMenu: cliFlags.skipMenu
|
|
686
490
|
});
|
|
687
491
|
const parsedApplicationAssetsUploadScriptFile = path$1.parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
688
|
-
const applicationAssetsUploadScriptFileName =
|
|
492
|
+
const applicationAssetsUploadScriptFileName = _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
|
|
689
493
|
writeUploadScriptFile({
|
|
690
494
|
fileName: applicationAssetsUploadScriptFileName,
|
|
691
495
|
fileContent: applicationAssetsUploadScriptContent,
|
|
@@ -718,7 +522,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
718
522
|
})), {}, {
|
|
719
523
|
// The trailing slash is important to indicate to the CSP directive that all the resources
|
|
720
524
|
// under that path should be allowed.
|
|
721
|
-
MC_CDN_URL:
|
|
525
|
+
MC_CDN_URL: "".concat(cdnUrl, "/")
|
|
722
526
|
}, cliFlags.mcUrl ? {
|
|
723
527
|
MC_URL: cliFlags.mcUrl
|
|
724
528
|
} : {}), cliFlags.mcApiUrl ? {
|
|
@@ -775,7 +579,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
775
579
|
}
|
|
776
580
|
}
|
|
777
581
|
async function command$4(cliFlags, cwd) {
|
|
778
|
-
var
|
|
582
|
+
var _context3;
|
|
779
583
|
const storageBucketConfig = await loadStorageBucketsConfig();
|
|
780
584
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
781
585
|
let assetsPath;
|
|
@@ -792,12 +596,12 @@ async function command$4(cliFlags, cwd) {
|
|
|
792
596
|
assetsPath
|
|
793
597
|
};
|
|
794
598
|
const defaultStorageProviders = [storageProviders.gs.tag];
|
|
795
|
-
const taskList = new Listr(_mapInstanceProperty(
|
|
599
|
+
const taskList = new Listr(_mapInstanceProperty(_context3 = _Object$entries(storageBucketConfig)).call(_context3, _ref4 => {
|
|
796
600
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
797
601
|
bucketRegion = _ref5[0],
|
|
798
602
|
bucketEnvironmentConfigs = _ref5[1];
|
|
799
603
|
return {
|
|
800
|
-
title:
|
|
604
|
+
title: "Compiling for bucket region ".concat(bucketRegion),
|
|
801
605
|
task: (_bucketRegionCtx, bucketRegionTask) => {
|
|
802
606
|
// NOTE: Application assets need to be compiled
|
|
803
607
|
// for all storage providers once per region.
|
|
@@ -812,7 +616,7 @@ async function command$4(cliFlags, cwd) {
|
|
|
812
616
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
813
617
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
|
|
814
618
|
return {
|
|
815
|
-
title:
|
|
619
|
+
title: "Compiling application assets for '".concat(storageProviderTag, "'"),
|
|
816
620
|
task: () => compileApplicationAssets({
|
|
817
621
|
cliFlags,
|
|
818
622
|
storageProvider,
|
|
@@ -830,14 +634,14 @@ async function command$4(cliFlags, cwd) {
|
|
|
830
634
|
bucketEnvironment
|
|
831
635
|
};
|
|
832
636
|
return {
|
|
833
|
-
title:
|
|
637
|
+
title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
|
|
834
638
|
task: (_storageProviderCtx, storageProviderTask) => {
|
|
835
|
-
var
|
|
836
|
-
const applicationIndexTasksForStorageProviders = _mapInstanceProperty(
|
|
639
|
+
var _context4;
|
|
640
|
+
const applicationIndexTasksForStorageProviders = _mapInstanceProperty(_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
|
|
837
641
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
838
642
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
|
|
839
643
|
return {
|
|
840
|
-
title:
|
|
644
|
+
title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
|
|
841
645
|
task: () => {
|
|
842
646
|
return compileEnvironmentApplicationIndexes({
|
|
843
647
|
cliFlags,
|
|
@@ -893,52 +697,58 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
|
893
697
|
*/
|
|
894
698
|
|
|
895
699
|
const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
896
|
-
var _context2;
|
|
700
|
+
var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
|
|
897
701
|
const entryPointUriPath = config.env.entryPointUriPath;
|
|
898
702
|
|
|
899
703
|
// @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
|
|
900
|
-
const accountLinks = config.env.__DEVELOPMENT__
|
|
704
|
+
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 : [];
|
|
901
705
|
if (accountLinks.length > 0) {
|
|
902
|
-
return _mapInstanceProperty(accountLinks).call(accountLinks, menuLink =>
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
706
|
+
return _mapInstanceProperty(accountLinks).call(accountLinks, menuLink => {
|
|
707
|
+
var _menuLink$permissions, _menuLink$featureTogg;
|
|
708
|
+
return {
|
|
709
|
+
key: menuLink.uriPath,
|
|
710
|
+
uriPath: menuLink.uriPath,
|
|
711
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
|
|
712
|
+
permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
|
|
713
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
714
|
+
featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
|
|
715
|
+
};
|
|
716
|
+
});
|
|
910
717
|
}
|
|
911
|
-
const menuLinks = config.env.__DEVELOPMENT__
|
|
718
|
+
const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
|
|
912
719
|
return {
|
|
913
720
|
key: entryPointUriPath,
|
|
914
721
|
uriPath: entryPointUriPath,
|
|
915
722
|
icon: menuLinks.icon,
|
|
916
|
-
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks
|
|
723
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
|
|
917
724
|
permissions: menuLinks.permissions,
|
|
918
725
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
919
|
-
featureToggle: menuLinks.featureToggle
|
|
726
|
+
featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
|
|
920
727
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
921
|
-
menuVisibility: menuLinks.menuVisibility
|
|
728
|
+
menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
|
|
922
729
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
923
|
-
actionRights: menuLinks.actionRights
|
|
730
|
+
actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
|
|
924
731
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
925
|
-
dataFences: menuLinks.dataFences
|
|
926
|
-
submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink =>
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
732
|
+
dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
|
|
733
|
+
submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
|
|
734
|
+
var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
|
|
735
|
+
return {
|
|
736
|
+
key: submenuLink.uriPath.replace('/', '-'),
|
|
737
|
+
uriPath: submenuLink.uriPath,
|
|
738
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
|
|
739
|
+
permissions: submenuLink.permissions,
|
|
740
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
741
|
+
featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
|
|
742
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
743
|
+
menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
|
|
744
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
745
|
+
actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
|
|
746
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
747
|
+
dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
|
|
748
|
+
};
|
|
749
|
+
}),
|
|
940
750
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
941
|
-
shouldRenderDivider: menuLinks.shouldRenderDivider
|
|
751
|
+
shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
|
|
942
752
|
};
|
|
943
753
|
};
|
|
944
754
|
async function command$3(cliFlags, cwd) {
|
|
@@ -1018,43 +828,51 @@ async function command$2(cliFlags) {
|
|
|
1018
828
|
*/
|
|
1019
829
|
const git = {
|
|
1020
830
|
// https://git-scm.com/docs/git-merge-base
|
|
1021
|
-
base: (baseBranch, headRevision) =>
|
|
831
|
+
base: (baseBranch, headRevision) => {
|
|
832
|
+
var _context;
|
|
833
|
+
return _concatInstanceProperty(_context = "git merge-base ".concat(baseBranch, " ")).call(_context, headRevision);
|
|
834
|
+
},
|
|
1022
835
|
// https://git-scm.com/docs/git-diff
|
|
1023
|
-
changedFiles: (mergeRevision, headRevision) =>
|
|
1024
|
-
|
|
836
|
+
changedFiles: (mergeRevision, headRevision) => {
|
|
837
|
+
var _context2;
|
|
838
|
+
return _concatInstanceProperty(_context2 = "git diff --name-only ".concat(mergeRevision, " ")).call(_context2, headRevision);
|
|
839
|
+
},
|
|
840
|
+
commitMessage: headRevision => "git log --format=oneline -n 1 ".concat(headRevision)
|
|
1025
841
|
};
|
|
1026
842
|
const helpers = {
|
|
1027
843
|
async writeOutDotEnvFile(cliFlags, cwd, matchingTriggers) {
|
|
1028
|
-
var
|
|
844
|
+
var _context3;
|
|
1029
845
|
// If desired read the env file and write out the matching triggers.
|
|
1030
846
|
if (!cliFlags.outEnvFile) {
|
|
1031
847
|
return;
|
|
1032
848
|
}
|
|
1033
849
|
const filePath = path$1.join(fs.realpathSync(cwd), cliFlags.outEnvFile);
|
|
1034
|
-
const fileContents = _mapInstanceProperty(
|
|
850
|
+
const fileContents = _mapInstanceProperty(_context3 = _Object$entries(matchingTriggers)).call(_context3, _ref => {
|
|
851
|
+
var _context5;
|
|
1035
852
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
1036
853
|
triggerName = _ref2[0],
|
|
1037
854
|
triggerValue = _ref2[1];
|
|
1038
|
-
const triggerNameForEnvFile =
|
|
855
|
+
const triggerNameForEnvFile = "".concat(snakeCase(triggerName).toUpperCase());
|
|
1039
856
|
|
|
1040
857
|
// General pipeline optimization hints are not transformed
|
|
1041
858
|
if (_startsWithInstanceProperty(triggerName).call(triggerName, 'allowPipelineOptimizations')) {
|
|
1042
|
-
|
|
859
|
+
var _context4;
|
|
860
|
+
return _concatInstanceProperty(_context4 = "".concat(triggerNameForEnvFile, "=")).call(_context4, triggerValue);
|
|
1043
861
|
}
|
|
1044
|
-
return
|
|
862
|
+
return _concatInstanceProperty(_context5 = "DID_".concat(triggerNameForEnvFile, "_CHANGE=")).call(_context5, triggerValue);
|
|
1045
863
|
}).join('\n');
|
|
1046
864
|
await fs.promises.writeFile(filePath, fileContents);
|
|
1047
865
|
if (!cliFlags.silent) {
|
|
1048
|
-
console.log(
|
|
866
|
+
console.log("\uD83D\uDCDD Wrote out file to '".concat(filePath, "' with contents:"));
|
|
1049
867
|
console.log(fileContents);
|
|
1050
868
|
}
|
|
1051
869
|
},
|
|
1052
870
|
async getChangedFiles(cliFlags) {
|
|
1053
|
-
var
|
|
871
|
+
var _context6, _context7;
|
|
1054
872
|
const baseCmdResult = await command$5(git.base(cliFlags.baseBranch, cliFlags.headRevision));
|
|
1055
873
|
const mergeRevision = baseCmdResult.stdout;
|
|
1056
874
|
const changedFilesCmdResult = await command$5(git.changedFiles(mergeRevision, cliFlags.headRevision));
|
|
1057
|
-
const changedFiles = _filterInstanceProperty(
|
|
875
|
+
const changedFiles = _filterInstanceProperty(_context6 = _mapInstanceProperty(_context7 = changedFilesCmdResult.stdout.split('\n')).call(_context7, filePath => _trimInstanceProperty(filePath).call(filePath))).call(_context6, filePath => filePath.length > 0);
|
|
1058
876
|
return changedFiles;
|
|
1059
877
|
},
|
|
1060
878
|
async matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles) {
|
|
@@ -1062,6 +880,7 @@ const helpers = {
|
|
|
1062
880
|
|
|
1063
881
|
// Evaluate each trigger against each file.
|
|
1064
882
|
_forEachInstanceProperty(config).call(config, async trigger => {
|
|
883
|
+
var _trigger$exclude;
|
|
1065
884
|
const hasTriggerBeenInitialized = typeof matchedTriggers[trigger.name] === 'number';
|
|
1066
885
|
|
|
1067
886
|
// Given the trigger with this name was never evaluated it has to be defaulted to 0.
|
|
@@ -1079,10 +898,10 @@ const helpers = {
|
|
|
1079
898
|
ignore: trigger.ignore
|
|
1080
899
|
});
|
|
1081
900
|
if (!cliFlags.silent && anyFileChangedForTrigger) {
|
|
1082
|
-
console.log(
|
|
901
|
+
console.log("\u2139\uFE0F Files for trigger ".concat(trigger.name, " changed."));
|
|
1083
902
|
}
|
|
1084
903
|
let onlyExcludedFilesChangedForTrigger = false;
|
|
1085
|
-
if (trigger.exclude
|
|
904
|
+
if (((_trigger$exclude = trigger.exclude) === null || _trigger$exclude === void 0 ? void 0 : _trigger$exclude.length) > 0) {
|
|
1086
905
|
// NOTE: `micromatch.every` evaluates if every file matches
|
|
1087
906
|
// every pattern.
|
|
1088
907
|
// We need to evaluate if every file matches some pattern.
|
|
@@ -1093,7 +912,7 @@ const helpers = {
|
|
|
1093
912
|
});
|
|
1094
913
|
}
|
|
1095
914
|
if (!cliFlags.silent && onlyExcludedFilesChangedForTrigger) {
|
|
1096
|
-
console.log(
|
|
915
|
+
console.log("\u2139\uFE0F Only excluded files for trigger ".concat(trigger.name, " changed."));
|
|
1097
916
|
}
|
|
1098
917
|
if (onlyExcludedFilesChangedForTrigger) {
|
|
1099
918
|
matchedTriggers[trigger.name] = 0;
|
|
@@ -1110,18 +929,19 @@ async function command$1(cliFlags, config, cwd) {
|
|
|
1110
929
|
const isDevelopmentBranch = cliFlags.branch !== cliFlags.baseBranch;
|
|
1111
930
|
const triggersContainingSharedFiles = _filterInstanceProperty(config).call(config, trigger => trigger.containsSharedFiles);
|
|
1112
931
|
if (!cliFlags.silent) {
|
|
1113
|
-
|
|
1114
|
-
console.log(
|
|
1115
|
-
console.log(
|
|
932
|
+
var _context8;
|
|
933
|
+
console.log("\u2139\uFE0F Pipeline optimizations are ".concat(enablePipelineOptimizations ? 'enabled' : 'disabled', "."));
|
|
934
|
+
console.log("\u2139\uFE0F Changes have been commited to the ".concat(isDevelopmentBranch ? 'a development' : 'the main', " branch."));
|
|
935
|
+
console.log(_concatInstanceProperty(_context8 = "\uD83D\uDEA7 Comparing '".concat(cliFlags.baseBranch, "' against '")).call(_context8, cliFlags.headRevision, "' to determine changed files."));
|
|
1116
936
|
}
|
|
1117
937
|
|
|
1118
938
|
// Collect and parse changed files from git comparing base and head revision.
|
|
1119
939
|
const changedFiles = await helpers.getChangedFiles(cliFlags);
|
|
1120
940
|
if (!cliFlags.silent) {
|
|
1121
941
|
if (changedFiles.length === 0) {
|
|
1122
|
-
console.log(
|
|
942
|
+
console.log("\u2139\uFE0F No changes found.");
|
|
1123
943
|
} else {
|
|
1124
|
-
console.log(
|
|
944
|
+
console.log("\u2139\uFE0F ".concat(changedFiles.length, " changes found."));
|
|
1125
945
|
}
|
|
1126
946
|
}
|
|
1127
947
|
|
|
@@ -1132,17 +952,17 @@ async function command$1(cliFlags, config, cwd) {
|
|
|
1132
952
|
const hasCommitMessageTrigger = commitMessage && _includesInstanceProperty(commitMessage).call(commitMessage, '[ci all]');
|
|
1133
953
|
const doesSharedTriggerMatch = _someInstanceProperty(triggersContainingSharedFiles).call(triggersContainingSharedFiles, triggerContainingSharedFiles => matchedTriggers[triggerContainingSharedFiles.name] === 1);
|
|
1134
954
|
if (!cliFlags.silent) {
|
|
1135
|
-
console.log(
|
|
955
|
+
console.log("\u2139\uFE0F The git commit message ".concat(hasCommitMessageTrigger ? 'does' : 'does not', " contain a [ci all] trigger."));
|
|
1136
956
|
}
|
|
1137
957
|
const doesPackageFolderTriggerMatch = matchedTriggers[cliFlags.triggerName] === 1;
|
|
1138
958
|
if (enablePipelineOptimizations && isDevelopmentBranch && !hasCommitMessageTrigger && !doesSharedTriggerMatch && !doesPackageFolderTriggerMatch) {
|
|
1139
959
|
if (!cliFlags.silent) {
|
|
1140
|
-
console.log(
|
|
960
|
+
console.log("\u2139\uFE0F No relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
1141
961
|
}
|
|
1142
962
|
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 1;
|
|
1143
963
|
} else {
|
|
1144
964
|
if (!cliFlags.silent) {
|
|
1145
|
-
console.log(
|
|
965
|
+
console.log("\u2139\uFE0F Relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
1146
966
|
}
|
|
1147
967
|
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 0;
|
|
1148
968
|
}
|
|
@@ -1262,15 +1082,15 @@ function validateMenu(menuJson) {
|
|
|
1262
1082
|
async function command(cliFlags) {
|
|
1263
1083
|
const menuJsonPath = cliFlags.inputFile;
|
|
1264
1084
|
const isAppbarMenu = cliFlags.navigation === 'top';
|
|
1265
|
-
if (!menuJsonPath) throw new Error(
|
|
1266
|
-
if (!doesFileExist(menuJsonPath)) throw new Error(
|
|
1085
|
+
if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
|
|
1086
|
+
if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
|
|
1267
1087
|
const menuJson = fs$1.readFileSync(menuJsonPath, 'utf-8');
|
|
1268
1088
|
return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
|
|
1269
1089
|
}
|
|
1270
1090
|
|
|
1271
1091
|
var pkgJson = {
|
|
1272
1092
|
name: "@commercetools-frontend/application-cli",
|
|
1273
|
-
version: "
|
|
1093
|
+
version: "7.0.0",
|
|
1274
1094
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
1275
1095
|
keywords: [
|
|
1276
1096
|
"commercetools",
|
|
@@ -1295,9 +1115,9 @@ var pkgJson = {
|
|
|
1295
1115
|
dependencies: {
|
|
1296
1116
|
"@babel/core": "^7.22.11",
|
|
1297
1117
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
1298
|
-
"@commercetools-frontend/application-config": "24.
|
|
1299
|
-
"@commercetools-frontend/constants": "24.
|
|
1300
|
-
"@commercetools-frontend/l10n": "24.
|
|
1118
|
+
"@commercetools-frontend/application-config": "24.11.0",
|
|
1119
|
+
"@commercetools-frontend/constants": "24.11.0",
|
|
1120
|
+
"@commercetools-frontend/l10n": "24.11.0",
|
|
1301
1121
|
"@manypkg/find-root": "2.2.3",
|
|
1302
1122
|
commander: "^13.1.0",
|
|
1303
1123
|
cosmiconfig: "9.0.0",
|
|
@@ -1314,7 +1134,7 @@ var pkgJson = {
|
|
|
1314
1134
|
"@tsconfig/node20": "20.1.6",
|
|
1315
1135
|
"@types/lodash": "^4.14.198",
|
|
1316
1136
|
"@types/micromatch": "4.0.9",
|
|
1317
|
-
"@types/node": "22.
|
|
1137
|
+
"@types/node": "22.19.1",
|
|
1318
1138
|
typescript: "5.2.2"
|
|
1319
1139
|
},
|
|
1320
1140
|
engines: {
|