@commercetools-frontend/application-cli 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.dev.js +129 -279
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +129 -279
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +127 -278
- package/dist/commercetools-frontend-application-cli.cjs.dev.js +2 -1
- package/dist/commercetools-frontend-application-cli.cjs.prod.js +2 -1
- package/dist/commercetools-frontend-application-cli.esm.js +2 -1
- package/dist/{storage-buckets-config-28a1d76e.cjs.dev.js → storage-buckets-config-8e7abeff.cjs.dev.js} +9 -4
- package/dist/{storage-buckets-config-e3ea6d6f.cjs.prod.js → storage-buckets-config-e092f613.cjs.prod.js} +9 -4
- package/dist/{storage-buckets-config-705b6341.esm.js → storage-buckets-config-f41d07bc.esm.js} +8 -4
- package/package.json +8 -8
|
@@ -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 } from '../../dist/storage-buckets-config-
|
|
17
|
+
import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts } from '../../dist/storage-buckets-config-f41d07bc.esm.js';
|
|
17
18
|
import fs from 'node:fs';
|
|
18
19
|
import path$1 from 'node:path';
|
|
19
20
|
import { Listr } from 'listr2';
|
|
@@ -21,7 +22,6 @@ import execa from 'execa';
|
|
|
21
22
|
import { findRootSync } from '@manypkg/find-root';
|
|
22
23
|
import path from 'path';
|
|
23
24
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
24
|
-
import _assertThisInitialized from '@babel/runtime-corejs3/helpers/esm/assertThisInitialized';
|
|
25
25
|
import _get from '@babel/runtime-corejs3/helpers/esm/get';
|
|
26
26
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
27
27
|
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
@@ -30,8 +30,8 @@ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
|
30
30
|
import _classPrivateFieldLooseBase from '@babel/runtime-corejs3/helpers/esm/classPrivateFieldLooseBase';
|
|
31
31
|
import _classPrivateFieldLooseKey from '@babel/runtime-corejs3/helpers/esm/classPrivateFieldLooseKey';
|
|
32
32
|
import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
33
|
-
import fs$1 from 'fs';
|
|
34
33
|
import dotenv from 'dotenv';
|
|
34
|
+
import fs$1 from 'fs';
|
|
35
35
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
36
36
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
37
37
|
import { processConfig } from '@commercetools-frontend/application-config';
|
|
@@ -55,7 +55,7 @@ function isCI() {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
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; }
|
|
58
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
58
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys$4(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys$4(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
59
59
|
function _callSuper(_this, derived, args) {
|
|
60
60
|
function isNativeReflectConstruct() {
|
|
61
61
|
if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
|
|
@@ -95,12 +95,12 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
95
95
|
* This allows all cloud environments sharing the same static assets while each application's index
|
|
96
96
|
* is uploaded with different headers (e.g. CSP rules).
|
|
97
97
|
*/
|
|
98
|
-
_createClass(StorageProvider, [{
|
|
98
|
+
return _createClass(StorageProvider, [{
|
|
99
99
|
key: "getBucketNamespace",
|
|
100
100
|
value: function getBucketNamespace(prNumber) {
|
|
101
101
|
if (!prNumber) return;
|
|
102
102
|
if (prNumber === 'merchant-center-preview') return prNumber;
|
|
103
|
-
return
|
|
103
|
+
return "mc-".concat(prNumber);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/**
|
|
@@ -109,7 +109,7 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
109
109
|
}, {
|
|
110
110
|
key: "getAssetsBucketUrl",
|
|
111
111
|
value: function getAssetsBucketUrl(_ref) {
|
|
112
|
-
var _context;
|
|
112
|
+
var _storageProvider$urls, _storageProvider$urls2, _context, _context2;
|
|
113
113
|
let applicationName = _ref.applicationName,
|
|
114
114
|
bucketProtocol = _ref.bucketProtocol,
|
|
115
115
|
bucketNamespace = _ref.bucketNamespace,
|
|
@@ -118,13 +118,14 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
118
118
|
throw new Error("'bucketRegion' is not defined. Required to determine 'assetsBucketUrl'.");
|
|
119
119
|
}
|
|
120
120
|
const storageProvider = storageProviders[tag];
|
|
121
|
-
const assetBuketUrl = storageProvider.urls.bucket
|
|
121
|
+
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];
|
|
122
122
|
const assetsBucketUrl = _filterInstanceProperty(_context = [assetBuketUrl, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
|
|
123
|
-
return
|
|
123
|
+
return _concatInstanceProperty(_context2 = "".concat(bucketProtocol)).call(_context2, assetsBucketUrl);
|
|
124
124
|
}
|
|
125
125
|
}, {
|
|
126
126
|
key: "getApplicationIndexBucketUrl",
|
|
127
127
|
value: function getApplicationIndexBucketUrl(_ref2) {
|
|
128
|
+
var _context3;
|
|
128
129
|
let tag = _ref2.tag,
|
|
129
130
|
prNumber = _ref2.prNumber,
|
|
130
131
|
applicationName = _ref2.applicationName,
|
|
@@ -137,53 +138,53 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
137
138
|
bucketProtocol,
|
|
138
139
|
bucketNamespace
|
|
139
140
|
});
|
|
140
|
-
const applicationIndexBucketUrl =
|
|
141
|
+
const applicationIndexBucketUrl = _concatInstanceProperty(_context3 = "".concat(applicationAssetsBucketUrl, "/")).call(_context3, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]);
|
|
141
142
|
return applicationIndexBucketUrl;
|
|
142
143
|
}
|
|
143
144
|
}, {
|
|
144
145
|
key: "getCdnUrl",
|
|
145
146
|
value: function getCdnUrl(_ref3) {
|
|
146
|
-
var
|
|
147
|
+
var _context4;
|
|
147
148
|
let applicationName = _ref3.applicationName,
|
|
148
149
|
prNumber = _ref3.prNumber,
|
|
149
150
|
publicBaseUrl = _ref3.publicBaseUrl,
|
|
150
151
|
excludeBucketRegion = _ref3.excludeBucketRegion;
|
|
151
|
-
return _filterInstanceProperty(
|
|
152
|
+
return _filterInstanceProperty(_context4 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context4, Boolean).join('/');
|
|
152
153
|
}
|
|
153
154
|
}, {
|
|
154
155
|
key: "getPublicBaseUrl",
|
|
155
156
|
value: function getPublicBaseUrl(tag) {
|
|
157
|
+
var _storageProvider$urls3;
|
|
156
158
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
|
|
157
159
|
throw new Error("'bucketEnvironment' is not defined. Required to determine 'publicBaseUrl'.");
|
|
158
160
|
}
|
|
159
161
|
const storageProvider = storageProviders[tag];
|
|
160
|
-
const publicBaseUrl = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]
|
|
162
|
+
const publicBaseUrl = (_storageProvider$urls3 = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]) !== null && _storageProvider$urls3 !== void 0 ? _storageProvider$urls3 : storageProvider.urls.public.default;
|
|
161
163
|
return publicBaseUrl;
|
|
162
164
|
}
|
|
163
165
|
}]);
|
|
164
|
-
return StorageProvider;
|
|
165
166
|
}();
|
|
166
167
|
var _bucketRegion2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
167
168
|
var _bucketEnvironment2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
168
|
-
let GoogleStorageProvider = /*#__PURE__*/function (
|
|
169
|
-
_inherits(GoogleStorageProvider, _StorageProvider);
|
|
169
|
+
let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
|
|
170
170
|
function GoogleStorageProvider(config) {
|
|
171
|
-
var
|
|
171
|
+
var _this2;
|
|
172
172
|
_classCallCheck(this, GoogleStorageProvider);
|
|
173
|
-
|
|
174
|
-
_Object$defineProperty(
|
|
173
|
+
_this2 = _callSuper(this, GoogleStorageProvider, [config]);
|
|
174
|
+
_Object$defineProperty(_this2, _bucketRegion2$1, {
|
|
175
175
|
writable: true,
|
|
176
176
|
value: void 0
|
|
177
177
|
});
|
|
178
|
-
_Object$defineProperty(
|
|
178
|
+
_Object$defineProperty(_this2, _bucketEnvironment2$1, {
|
|
179
179
|
writable: true,
|
|
180
180
|
value: void 0
|
|
181
181
|
});
|
|
182
|
-
_classPrivateFieldLooseBase(
|
|
183
|
-
_classPrivateFieldLooseBase(
|
|
184
|
-
return
|
|
182
|
+
_classPrivateFieldLooseBase(_this2, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
|
|
183
|
+
_classPrivateFieldLooseBase(_this2, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
|
|
184
|
+
return _this2;
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
_inherits(GoogleStorageProvider, _StorageProvider2);
|
|
187
|
+
return _createClass(GoogleStorageProvider, [{
|
|
187
188
|
key: "getTag",
|
|
188
189
|
value: function getTag() {
|
|
189
190
|
return 'gs';
|
|
@@ -234,29 +235,28 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
|
|
|
234
235
|
}, config));
|
|
235
236
|
}
|
|
236
237
|
}]);
|
|
237
|
-
return GoogleStorageProvider;
|
|
238
238
|
}(StorageProvider);
|
|
239
239
|
var _bucketRegion3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
240
240
|
var _bucketEnvironment3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
241
|
-
let AwsStorageProvider = /*#__PURE__*/function (
|
|
242
|
-
_inherits(AwsStorageProvider, _StorageProvider2);
|
|
241
|
+
let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider3) {
|
|
243
242
|
function AwsStorageProvider(config) {
|
|
244
|
-
var
|
|
243
|
+
var _this3;
|
|
245
244
|
_classCallCheck(this, AwsStorageProvider);
|
|
246
|
-
|
|
247
|
-
_Object$defineProperty(
|
|
245
|
+
_this3 = _callSuper(this, AwsStorageProvider, [config]);
|
|
246
|
+
_Object$defineProperty(_this3, _bucketRegion3, {
|
|
248
247
|
writable: true,
|
|
249
248
|
value: void 0
|
|
250
249
|
});
|
|
251
|
-
_Object$defineProperty(
|
|
250
|
+
_Object$defineProperty(_this3, _bucketEnvironment3, {
|
|
252
251
|
writable: true,
|
|
253
252
|
value: void 0
|
|
254
253
|
});
|
|
255
|
-
_classPrivateFieldLooseBase(
|
|
256
|
-
_classPrivateFieldLooseBase(
|
|
257
|
-
return
|
|
254
|
+
_classPrivateFieldLooseBase(_this3, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
|
|
255
|
+
_classPrivateFieldLooseBase(_this3, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
|
|
256
|
+
return _this3;
|
|
258
257
|
}
|
|
259
|
-
|
|
258
|
+
_inherits(AwsStorageProvider, _StorageProvider3);
|
|
259
|
+
return _createClass(AwsStorageProvider, [{
|
|
260
260
|
key: "getTag",
|
|
261
261
|
value: function getTag() {
|
|
262
262
|
return 's3';
|
|
@@ -308,7 +308,6 @@ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
|
|
|
308
308
|
}, config));
|
|
309
309
|
}
|
|
310
310
|
}]);
|
|
311
|
-
return AwsStorageProvider;
|
|
312
311
|
}(StorageProvider);
|
|
313
312
|
function getStorageProvider(storageProvider, config) {
|
|
314
313
|
switch (storageProvider) {
|
|
@@ -317,7 +316,7 @@ function getStorageProvider(storageProvider, config) {
|
|
|
317
316
|
case 's3':
|
|
318
317
|
return new AwsStorageProvider(config);
|
|
319
318
|
default:
|
|
320
|
-
throw new Error(
|
|
319
|
+
throw new Error("Storage provider ".concat(storageProvider, " not supported"));
|
|
321
320
|
}
|
|
322
321
|
}
|
|
323
322
|
|
|
@@ -337,9 +336,10 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
337
336
|
_classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion] = config.bucketRegion;
|
|
338
337
|
_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment] = config.bucketEnvironment;
|
|
339
338
|
}
|
|
340
|
-
_createClass(GoogleStorageUploadScriptsGenerator, [{
|
|
339
|
+
return _createClass(GoogleStorageUploadScriptsGenerator, [{
|
|
341
340
|
key: "getApplicationIndexUploadScript",
|
|
342
341
|
value: function getApplicationIndexUploadScript(_ref) {
|
|
342
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10;
|
|
343
343
|
let packageManagerName = _ref.packageManagerName,
|
|
344
344
|
bucketUrl = _ref.bucketUrl,
|
|
345
345
|
cdnUrl = _ref.cdnUrl,
|
|
@@ -349,109 +349,18 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
349
349
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
|
|
350
350
|
throw new Error("Missing 'bucketEnvironment' when generating application index.");
|
|
351
351
|
}
|
|
352
|
-
return
|
|
353
|
-
#!/usr/bin/env bash
|
|
354
|
-
|
|
355
|
-
set -e
|
|
356
|
-
|
|
357
|
-
echo "Uploading compiled ${applicationIndexOutFile} to Google Storage bucket ${bucketUrl}"
|
|
358
|
-
|
|
359
|
-
gcloud storage cp \\
|
|
360
|
-
"$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
361
|
-
"${bucketUrl}/" \\
|
|
362
|
-
-z html \\
|
|
363
|
-
--content-type="text/html" \\
|
|
364
|
-
--cache-control="public,max-age=0,no-transform"
|
|
365
|
-
|
|
366
|
-
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
367
|
-
|
|
368
|
-
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
369
|
-
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
|
|
370
|
-
--build-revision=${buildRevision} \\
|
|
371
|
-
--build-number=${buildNumber} \\
|
|
372
|
-
--out-file=$(dirname "$0")/version.json
|
|
373
|
-
|
|
374
|
-
gcloud storage cp \\
|
|
375
|
-
"$(dirname "$0")/version.json" \\
|
|
376
|
-
"${bucketUrl}/" \\
|
|
377
|
-
-z json \\
|
|
378
|
-
--content-type="application/json" \\
|
|
379
|
-
--cache-control="public,max-age=0,no-transform"
|
|
380
|
-
`;
|
|
352
|
+
return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "\n#!/usr/bin/env bash\n\nset -e\n\necho \"Uploading compiled ".concat(applicationIndexOutFile, " to Google Storage bucket ")).call(_context10, bucketUrl, "\"\n\ngcloud storage cp \\\n \"$(dirname \"$0\")/")).call(_context9, applicationIndexOutFile, "\" \\\n \"")).call(_context8, bucketUrl, "/\" \\\n -z html \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\"\n\necho \"Creating version.json and uploading it to bucket ")).call(_context7, bucketUrl, "\"\n\nNODE_ENV=production ")).call(_context6, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context5, cdnUrl, "/")).call(_context4, _classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment], "/version.json \\\n --build-revision=")).call(_context3, buildRevision, " \\\n --build-number=")).call(_context2, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\ngcloud storage cp \\\n \"$(dirname \"$0\")/version.json\" \\\n \"")).call(_context, bucketUrl, "/\" \\\n -z json \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\"\n");
|
|
381
353
|
}
|
|
382
354
|
}, {
|
|
383
355
|
key: "getProductionBundlesUploadScript",
|
|
384
356
|
value: function getProductionBundlesUploadScript(_ref2) {
|
|
357
|
+
var _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18;
|
|
385
358
|
let bucketUrl = _ref2.bucketUrl,
|
|
386
359
|
assetsPath = _ref2.assetsPath,
|
|
387
360
|
skipMenu = _ref2.skipMenu;
|
|
388
|
-
return
|
|
389
|
-
#!/usr/bin/env bash
|
|
390
|
-
|
|
391
|
-
set -e
|
|
392
|
-
|
|
393
|
-
# NOTES:
|
|
394
|
-
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
395
|
-
# 1. The '-z' option triggers compressing the assets before
|
|
396
|
-
# uploading them and sets the 'Content-Encoding' to 'gzip'.
|
|
397
|
-
# 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.
|
|
398
|
-
# 3. The 'max-age' is set to 1 year which is considered the maximum
|
|
399
|
-
# "valid" lifetime of an asset to be cached.
|
|
400
|
-
# 4. The '-n' will skip uploading existing files and prevents them to
|
|
401
|
-
# be overwritten
|
|
402
|
-
echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
|
|
403
|
-
|
|
404
|
-
gcloud storage cp \\
|
|
405
|
-
${assetsPath}/public/{*.css,*.js,*.js.map,*.html} \\
|
|
406
|
-
"${bucketUrl}" \\
|
|
407
|
-
-n \\
|
|
408
|
-
-z js,css \\
|
|
409
|
-
--cache-control="public,max-age=31536000,no-transform"
|
|
410
|
-
|
|
411
|
-
# We need to upload the PNG and HTML files separately because we want them
|
|
412
|
-
# to be able to overwrite the existing files (if any). For instance, the
|
|
413
|
-
# file or the favicons.
|
|
414
|
-
# This is controlled with the '-n' option (which is used for the JS and CSS
|
|
415
|
-
# as we don't want to overwrite them)
|
|
416
|
-
gcloud storage cp \\
|
|
417
|
-
${assetsPath}/public/{*.png,robots.txt} \\
|
|
418
|
-
"${bucketUrl}" \\
|
|
419
|
-
-z txt \\
|
|
420
|
-
--cache-control="public,max-age=31536000,no-transform"
|
|
421
|
-
|
|
422
|
-
if ${skipMenu}; then
|
|
423
|
-
echo "Skipping menu.json upload"
|
|
424
|
-
else
|
|
425
|
-
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
426
|
-
# NOTE: somehow the 'cache-control:private' doesn't work.
|
|
427
|
-
# I mean, the file is uploaded with the correct metadata but when I fetch
|
|
428
|
-
# the file the response contains the header
|
|
429
|
-
# 'cache-control: public,max-age=31536000,no-transform', even though the
|
|
430
|
-
# documentation clearly states that by marking the header as 'private' will
|
|
431
|
-
# disable the cache (for publicly readable objects).
|
|
432
|
-
# https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
|
|
433
|
-
# However, I found out that, by requesting the file with any RANDOM
|
|
434
|
-
# query parameter, will instruct the storage to return a 'fresh' object
|
|
435
|
-
# (without any cache control).
|
|
436
|
-
# Unofficial source: https://stackoverflow.com/a/49052895
|
|
437
|
-
# This seems to be the 'easiest' option to 'disable' the cache for public
|
|
438
|
-
# objects. Other alternative approaces are:
|
|
439
|
-
# * make the object private with some simple ACL (private objects are not cached)
|
|
440
|
-
# * suffix the file name with e.g. the git SHA, so we have different files
|
|
441
|
-
# for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
|
|
442
|
-
# the git SHA on runtime and can get the correct file when it starts.
|
|
443
|
-
# * find out why the 'private' cache control does not work
|
|
444
|
-
gcloud storage cp \\
|
|
445
|
-
${assetsPath}/menu.json \\
|
|
446
|
-
${bucketUrl} \\
|
|
447
|
-
-z json \\
|
|
448
|
-
--content-type="application/json" \\
|
|
449
|
-
--cache-control="public,max-age=0,no-transform"
|
|
450
|
-
fi
|
|
451
|
-
`;
|
|
361
|
+
return _concatInstanceProperty(_context11 = _concatInstanceProperty(_context12 = _concatInstanceProperty(_context13 = _concatInstanceProperty(_context14 = _concatInstanceProperty(_context15 = _concatInstanceProperty(_context16 = _concatInstanceProperty(_context17 = _concatInstanceProperty(_context18 = "\n#!/usr/bin/env bash\n\nset -e\n\n# NOTES:\n# https://cloud.google.com/sdk/gcloud/reference/storage/cp\n# 1. The '-z' option triggers compressing the assets before\n# uploading them and sets the 'Content-Encoding' to 'gzip'.\n# 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.\n# 3. The 'max-age' is set to 1 year which is considered the maximum\n# \"valid\" lifetime of an asset to be cached.\n# 4. The '-n' will skip uploading existing files and prevents them to\n# be overwritten\necho \"Uploading static assets to Google Storage bucket ".concat(bucketUrl, "\"\n\ngcloud storage cp \\\n ")).call(_context18, assetsPath, "/public/{*.css,*.js,*.js.map,*.html} \\\n \"")).call(_context17, bucketUrl, "\" \\\n -n \\\n -z js,css \\\n --cache-control=\"public,max-age=31536000,no-transform\"\n\n# We need to upload the PNG and HTML files separately because we want them\n# to be able to overwrite the existing files (if any). For instance, the\n# file or the favicons.\n# This is controlled with the '-n' option (which is used for the JS and CSS\n# as we don't want to overwrite them)\ngcloud storage cp \\\n ")).call(_context16, assetsPath, "/public/{*.png,robots.txt} \\\n \"")).call(_context15, bucketUrl, "\" \\\n -z txt \\\n --cache-control=\"public,max-age=31536000,no-transform\"\n\nif ")).call(_context14, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context13, bucketUrl, "\"\n # NOTE: somehow the 'cache-control:private' doesn't work.\n # I mean, the file is uploaded with the correct metadata but when I fetch\n # the file the response contains the header\n # 'cache-control: public,max-age=31536000,no-transform', even though the\n # documentation clearly states that by marking the header as 'private' will\n # disable the cache (for publicly readable objects).\n # https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control\n # However, I found out that, by requesting the file with any RANDOM\n # query parameter, will instruct the storage to return a 'fresh' object\n # (without any cache control).\n # Unofficial source: https://stackoverflow.com/a/49052895\n # This seems to be the 'easiest' option to 'disable' the cache for public\n # objects. Other alternative approaces are:\n # * make the object private with some simple ACL (private objects are not cached)\n # * suffix the file name with e.g. the git SHA, so we have different files\n # for each upload ('index.html.template-${CIRCLE_SHA1}'). The server knows\n # the git SHA on runtime and can get the correct file when it starts.\n # * find out why the 'private' cache control does not work\n gcloud storage cp \\\n ")).call(_context12, assetsPath, "/menu.json \\\n ")).call(_context11, bucketUrl, " \\\n -z json \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\"\nfi\n");
|
|
452
362
|
}
|
|
453
363
|
}]);
|
|
454
|
-
return GoogleStorageUploadScriptsGenerator;
|
|
455
364
|
}();
|
|
456
365
|
var _bucketEnvironment2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
457
366
|
var _bucketRegion2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
@@ -469,106 +378,28 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
469
378
|
_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2] = config.bucketRegion;
|
|
470
379
|
_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2] = config.bucketEnvironment;
|
|
471
380
|
}
|
|
472
|
-
_createClass(AwsStorageUploadScriptsGenerator, [{
|
|
381
|
+
return _createClass(AwsStorageUploadScriptsGenerator, [{
|
|
473
382
|
key: "getApplicationIndexUploadScript",
|
|
474
383
|
value: function getApplicationIndexUploadScript(_ref3) {
|
|
384
|
+
var _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
|
|
475
385
|
let packageManagerName = _ref3.packageManagerName,
|
|
476
386
|
bucketUrl = _ref3.bucketUrl,
|
|
477
387
|
cdnUrl = _ref3.cdnUrl,
|
|
478
388
|
buildRevision = _ref3.buildRevision,
|
|
479
389
|
buildNumber = _ref3.buildNumber,
|
|
480
390
|
applicationIndexOutFile = _ref3.applicationIndexOutFile;
|
|
481
|
-
return
|
|
482
|
-
#!/usr/bin/env bash
|
|
483
|
-
|
|
484
|
-
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
485
|
-
|
|
486
|
-
set -e
|
|
487
|
-
|
|
488
|
-
aws s3 cp \\
|
|
489
|
-
"$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
490
|
-
"${bucketUrl}/" \\
|
|
491
|
-
--content-type="text/html" \\
|
|
492
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
493
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
494
|
-
|
|
495
|
-
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
496
|
-
|
|
497
|
-
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
498
|
-
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}/version.json \\
|
|
499
|
-
--build-revision=${buildRevision} \\
|
|
500
|
-
--build-number=${buildNumber} \\
|
|
501
|
-
--out-file=$(dirname "$0")/version.json
|
|
502
|
-
|
|
503
|
-
aws s3 cp \\
|
|
504
|
-
"$(dirname "$0")/version.json" \\
|
|
505
|
-
"${bucketUrl}/" \\
|
|
506
|
-
--content-type="application/json" \\
|
|
507
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
508
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
509
|
-
`;
|
|
391
|
+
return _concatInstanceProperty(_context19 = _concatInstanceProperty(_context20 = _concatInstanceProperty(_context21 = _concatInstanceProperty(_context22 = _concatInstanceProperty(_context23 = _concatInstanceProperty(_context24 = _concatInstanceProperty(_context25 = _concatInstanceProperty(_context26 = _concatInstanceProperty(_context27 = _concatInstanceProperty(_context28 = _concatInstanceProperty(_context29 = "\n #!/usr/bin/env bash\n\n echo \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\n set -e\n\n aws s3 cp \"$(dirname \"$0\")/")).call(_context29, applicationIndexOutFile, "\" \\\n \"")).call(_context28, bucketUrl, "/\" \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context27, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n echo \"Creating version.json and uploading it to bucket ")).call(_context26, bucketUrl, "\"\n\n NODE_ENV=production ")).call(_context25, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context24, cdnUrl, "/")).call(_context23, _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2], "/version.json \\\n --build-revision=")).call(_context22, buildRevision, " \\\n --build-number=")).call(_context21, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\n aws s3 cp \"$(dirname \"$0\")\" \\\n \"")).call(_context20, bucketUrl, "/\" \\\n --exclude \"*\" \\\n --include \"version.json\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context19, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n");
|
|
510
392
|
}
|
|
511
393
|
}, {
|
|
512
394
|
key: "getProductionBundlesUploadScript",
|
|
513
395
|
value: function getProductionBundlesUploadScript(_ref4) {
|
|
396
|
+
var _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40;
|
|
514
397
|
let bucketUrl = _ref4.bucketUrl,
|
|
515
398
|
assetsPath = _ref4.assetsPath,
|
|
516
399
|
skipMenu = _ref4.skipMenu;
|
|
517
|
-
return
|
|
518
|
-
#!/usr/bin/env bash
|
|
519
|
-
|
|
520
|
-
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
521
|
-
|
|
522
|
-
set -e
|
|
523
|
-
|
|
524
|
-
# NOTE:
|
|
525
|
-
# The sync command on the AWS CLI is different to the -n option on the gcloud CLI.
|
|
526
|
-
# Sync will only upload files that are not already in the bucket, but it will skip existing ones
|
|
527
|
-
# that have been changed locally.
|
|
528
|
-
# The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.
|
|
529
|
-
# https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
|
|
530
|
-
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
531
|
-
#
|
|
532
|
-
# Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.
|
|
533
|
-
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring
|
|
534
|
-
aws s3 sync ${assetsPath}/public \\
|
|
535
|
-
"${bucketUrl}" \\
|
|
536
|
-
--exclude "*" \\
|
|
537
|
-
--include "*.css" \\
|
|
538
|
-
--include "*.js" \\
|
|
539
|
-
--include "*.js.map" \\
|
|
540
|
-
--include "*.html" \\
|
|
541
|
-
--cache-control="public,max-age=31536000,no-transform" \\
|
|
542
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
543
|
-
|
|
544
|
-
# We need to upload the PNG and HTML files separately because we want them
|
|
545
|
-
# to be able to overwrite the existing files (if any). For instance, the
|
|
546
|
-
# file or the favicons.
|
|
547
|
-
aws s3 cp ${assetsPath}/public \\
|
|
548
|
-
"${bucketUrl}" \\
|
|
549
|
-
--recursive \\
|
|
550
|
-
--exclude "*" \\
|
|
551
|
-
--include "*.png" \\
|
|
552
|
-
--include "robots.txt" \\
|
|
553
|
-
--cache-control="public,max-age=31536000,no-transform" \\
|
|
554
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
555
|
-
|
|
556
|
-
if ${skipMenu}; then
|
|
557
|
-
echo "Skipping menu.json upload"
|
|
558
|
-
else
|
|
559
|
-
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
560
|
-
|
|
561
|
-
aws s3 cp \\
|
|
562
|
-
${assetsPath}/menu.json \\
|
|
563
|
-
${bucketUrl} \\
|
|
564
|
-
--content-type="application/json" \\
|
|
565
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
566
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
567
|
-
fi
|
|
568
|
-
`;
|
|
400
|
+
return _concatInstanceProperty(_context30 = _concatInstanceProperty(_context31 = _concatInstanceProperty(_context32 = _concatInstanceProperty(_context33 = _concatInstanceProperty(_context34 = _concatInstanceProperty(_context35 = _concatInstanceProperty(_context36 = _concatInstanceProperty(_context37 = _concatInstanceProperty(_context38 = _concatInstanceProperty(_context39 = _concatInstanceProperty(_context40 = "\n#!/usr/bin/env bash\n\necho \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\nset -e\n\n# NOTE:\n# The sync command on the AWS CLI is different to the -n option on the gcloud CLI.\n# Sync will only upload files that are not already in the bucket, but it will skip existing ones\n# that have been changed locally.\n# The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.\n# https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html\n# https://cloud.google.com/sdk/gcloud/reference/storage/cp\n#\n# Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.\n# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring\naws s3 sync ")).call(_context40, assetsPath, "/public \\\n \"")).call(_context39, bucketUrl, "\" \\\n --exclude \"*\" \\\n --include \"*.css\" \\\n --include \"*.js\" \\\n --include \"*.js.map\" \\\n --include \"*.html\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context38, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n# We need to upload the PNG and HTML files separately because we want them\n# to be able to overwrite the existing files (if any). For instance, the\n# file or the favicons.\naws s3 cp ")).call(_context37, assetsPath, "/public \\\n \"")).call(_context36, bucketUrl, "\" \\\n --recursive \\\n --exclude \"*\" \\\n --include \"*.png\" \\\n --include \"robots.txt\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context35, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\nif ")).call(_context34, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context33, bucketUrl, "\"\n\n aws s3 cp ")).call(_context32, assetsPath, "/menu.json \\\n \"")).call(_context31, bucketUrl, "/\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context30, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\nfi\n");
|
|
569
401
|
}
|
|
570
402
|
}]);
|
|
571
|
-
return AwsStorageUploadScriptsGenerator;
|
|
572
403
|
}();
|
|
573
404
|
function getUploadScriptsGenerator(storageProvider, config) {
|
|
574
405
|
switch (storageProvider) {
|
|
@@ -577,12 +408,21 @@ function getUploadScriptsGenerator(storageProvider, config) {
|
|
|
577
408
|
case 's3':
|
|
578
409
|
return new AwsStorageUploadScriptsGenerator(config);
|
|
579
410
|
default:
|
|
580
|
-
throw new Error(
|
|
411
|
+
throw new Error("Storage provider ".concat(storageProvider, " not supported"));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function doesFileExist(filePath) {
|
|
416
|
+
try {
|
|
417
|
+
fs$1.accessSync(filePath);
|
|
418
|
+
return true;
|
|
419
|
+
} catch (e) {
|
|
420
|
+
return false;
|
|
581
421
|
}
|
|
582
422
|
}
|
|
583
423
|
|
|
584
424
|
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; }
|
|
585
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
425
|
+
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; }
|
|
586
426
|
function loadDotenvFiles(_ref) {
|
|
587
427
|
let dotenvPath = _ref.dotenvPath,
|
|
588
428
|
cloudEnvironment = _ref.cloudEnvironment;
|
|
@@ -592,13 +432,13 @@ function loadDotenvFiles(_ref) {
|
|
|
592
432
|
}
|
|
593
433
|
|
|
594
434
|
// Check if the given path exists.
|
|
595
|
-
if (!
|
|
596
|
-
throw new Error(
|
|
435
|
+
if (!doesFileExist(dotenvPath)) {
|
|
436
|
+
throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
|
|
597
437
|
}
|
|
598
438
|
|
|
599
439
|
// Load the environment values
|
|
600
440
|
const sharedDotenvFile = '.env.production';
|
|
601
|
-
const cloudDotenvFile =
|
|
441
|
+
const cloudDotenvFile = ".env.".concat(cloudEnvironment);
|
|
602
442
|
|
|
603
443
|
// The shared dotenv file across environments is optional
|
|
604
444
|
const sharedProductionEnvironment = dotenv.config({
|
|
@@ -610,16 +450,18 @@ function loadDotenvFiles(_ref) {
|
|
|
610
450
|
path: path.join(dotenvPath, cloudDotenvFile)
|
|
611
451
|
});
|
|
612
452
|
if (cloudSpecificProductionEnvironment.error) {
|
|
613
|
-
|
|
453
|
+
var _context;
|
|
454
|
+
throw new Error(_concatInstanceProperty(_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
|
|
614
455
|
}
|
|
615
456
|
if (sharedProductionEnvironment.error) {
|
|
616
|
-
|
|
457
|
+
var _context2;
|
|
458
|
+
throw new Error(_concatInstanceProperty(_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
|
|
617
459
|
}
|
|
618
460
|
return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
|
|
619
461
|
}
|
|
620
462
|
|
|
621
463
|
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; }
|
|
622
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
464
|
+
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; }
|
|
623
465
|
function writeUploadScriptFile(_ref) {
|
|
624
466
|
let fileName = _ref.fileName,
|
|
625
467
|
fileContent = _ref.fileContent,
|
|
@@ -631,6 +473,7 @@ function writeUploadScriptFile(_ref) {
|
|
|
631
473
|
});
|
|
632
474
|
}
|
|
633
475
|
async function compileApplicationAssets(_ref2) {
|
|
476
|
+
var _context, _context2;
|
|
634
477
|
let cliFlags = _ref2.cliFlags,
|
|
635
478
|
storageProvider = _ref2.storageProvider,
|
|
636
479
|
uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
|
|
@@ -645,7 +488,7 @@ async function compileApplicationAssets(_ref2) {
|
|
|
645
488
|
skipMenu: cliFlags.skipMenu
|
|
646
489
|
});
|
|
647
490
|
const parsedApplicationAssetsUploadScriptFile = path$1.parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
648
|
-
const applicationAssetsUploadScriptFileName =
|
|
491
|
+
const applicationAssetsUploadScriptFileName = _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
|
|
649
492
|
writeUploadScriptFile({
|
|
650
493
|
fileName: applicationAssetsUploadScriptFileName,
|
|
651
494
|
fileContent: applicationAssetsUploadScriptContent,
|
|
@@ -678,7 +521,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
678
521
|
})), {}, {
|
|
679
522
|
// The trailing slash is important to indicate to the CSP directive that all the resources
|
|
680
523
|
// under that path should be allowed.
|
|
681
|
-
MC_CDN_URL:
|
|
524
|
+
MC_CDN_URL: "".concat(cdnUrl, "/")
|
|
682
525
|
}, cliFlags.mcUrl ? {
|
|
683
526
|
MC_URL: cliFlags.mcUrl
|
|
684
527
|
} : {}), cliFlags.mcApiUrl ? {
|
|
@@ -735,7 +578,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
735
578
|
}
|
|
736
579
|
}
|
|
737
580
|
async function command$3(cliFlags, cwd) {
|
|
738
|
-
var
|
|
581
|
+
var _context3;
|
|
739
582
|
const storageBucketConfig = await loadStorageBucketsConfig();
|
|
740
583
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
741
584
|
let assetsPath;
|
|
@@ -752,12 +595,12 @@ async function command$3(cliFlags, cwd) {
|
|
|
752
595
|
assetsPath
|
|
753
596
|
};
|
|
754
597
|
const defaultStorageProviders = [storageProviders.gs.tag];
|
|
755
|
-
const taskList = new Listr(_mapInstanceProperty(
|
|
598
|
+
const taskList = new Listr(_mapInstanceProperty(_context3 = _Object$entries(storageBucketConfig)).call(_context3, _ref4 => {
|
|
756
599
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
757
600
|
bucketRegion = _ref5[0],
|
|
758
601
|
bucketEnvironmentConfigs = _ref5[1];
|
|
759
602
|
return {
|
|
760
|
-
title:
|
|
603
|
+
title: "Compiling for bucket region ".concat(bucketRegion),
|
|
761
604
|
task: (_bucketRegionCtx, bucketRegionTask) => {
|
|
762
605
|
// NOTE: Application assets need to be compiled
|
|
763
606
|
// for all storage providers once per region.
|
|
@@ -772,7 +615,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
772
615
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
773
616
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
|
|
774
617
|
return {
|
|
775
|
-
title:
|
|
618
|
+
title: "Compiling application assets for '".concat(storageProviderTag, "'"),
|
|
776
619
|
task: () => compileApplicationAssets({
|
|
777
620
|
cliFlags,
|
|
778
621
|
storageProvider,
|
|
@@ -790,14 +633,14 @@ async function command$3(cliFlags, cwd) {
|
|
|
790
633
|
bucketEnvironment
|
|
791
634
|
};
|
|
792
635
|
return {
|
|
793
|
-
title:
|
|
636
|
+
title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
|
|
794
637
|
task: (_storageProviderCtx, storageProviderTask) => {
|
|
795
|
-
var
|
|
796
|
-
const applicationIndexTasksForStorageProviders = _mapInstanceProperty(
|
|
638
|
+
var _context4;
|
|
639
|
+
const applicationIndexTasksForStorageProviders = _mapInstanceProperty(_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
|
|
797
640
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
798
641
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
|
|
799
642
|
return {
|
|
800
|
-
title:
|
|
643
|
+
title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
|
|
801
644
|
task: () => {
|
|
802
645
|
return compileEnvironmentApplicationIndexes({
|
|
803
646
|
cliFlags,
|
|
@@ -853,52 +696,58 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
|
853
696
|
*/
|
|
854
697
|
|
|
855
698
|
const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
856
|
-
var _context2;
|
|
699
|
+
var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
|
|
857
700
|
const entryPointUriPath = config.env.entryPointUriPath;
|
|
858
701
|
|
|
859
702
|
// @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
|
|
860
|
-
const accountLinks = config.env.__DEVELOPMENT__
|
|
703
|
+
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 : [];
|
|
861
704
|
if (accountLinks.length > 0) {
|
|
862
|
-
return _mapInstanceProperty(accountLinks).call(accountLinks, menuLink =>
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
705
|
+
return _mapInstanceProperty(accountLinks).call(accountLinks, menuLink => {
|
|
706
|
+
var _menuLink$permissions, _menuLink$featureTogg;
|
|
707
|
+
return {
|
|
708
|
+
key: menuLink.uriPath,
|
|
709
|
+
uriPath: menuLink.uriPath,
|
|
710
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
|
|
711
|
+
permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
|
|
712
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
713
|
+
featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
|
|
714
|
+
};
|
|
715
|
+
});
|
|
870
716
|
}
|
|
871
|
-
const menuLinks = config.env.__DEVELOPMENT__
|
|
717
|
+
const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
|
|
872
718
|
return {
|
|
873
719
|
key: entryPointUriPath,
|
|
874
720
|
uriPath: entryPointUriPath,
|
|
875
721
|
icon: menuLinks.icon,
|
|
876
|
-
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks
|
|
722
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
|
|
877
723
|
permissions: menuLinks.permissions,
|
|
878
724
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
879
|
-
featureToggle: menuLinks.featureToggle
|
|
725
|
+
featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
|
|
880
726
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
881
|
-
menuVisibility: menuLinks.menuVisibility
|
|
727
|
+
menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
|
|
882
728
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
883
|
-
actionRights: menuLinks.actionRights
|
|
729
|
+
actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
|
|
884
730
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
885
|
-
dataFences: menuLinks.dataFences
|
|
886
|
-
submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink =>
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
731
|
+
dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
|
|
732
|
+
submenu: _mapInstanceProperty(_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
|
|
733
|
+
var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
|
|
734
|
+
return {
|
|
735
|
+
key: submenuLink.uriPath.replace('/', '-'),
|
|
736
|
+
uriPath: submenuLink.uriPath,
|
|
737
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
|
|
738
|
+
permissions: submenuLink.permissions,
|
|
739
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
740
|
+
featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
|
|
741
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
742
|
+
menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
|
|
743
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
744
|
+
actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
|
|
745
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
746
|
+
dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
|
|
747
|
+
};
|
|
748
|
+
}),
|
|
900
749
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
901
|
-
shouldRenderDivider: menuLinks.shouldRenderDivider
|
|
750
|
+
shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
|
|
902
751
|
};
|
|
903
752
|
};
|
|
904
753
|
async function command$2(cliFlags, cwd) {
|
|
@@ -1080,15 +929,15 @@ function validateMenu(menuJson) {
|
|
|
1080
929
|
async function command(cliFlags) {
|
|
1081
930
|
const menuJsonPath = cliFlags.inputFile;
|
|
1082
931
|
const isAppbarMenu = cliFlags.navigation === 'top';
|
|
1083
|
-
if (!menuJsonPath) throw new Error(
|
|
1084
|
-
if (!
|
|
932
|
+
if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
|
|
933
|
+
if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
|
|
1085
934
|
const menuJson = fs$1.readFileSync(menuJsonPath, 'utf-8');
|
|
1086
935
|
return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
|
|
1087
936
|
}
|
|
1088
937
|
|
|
1089
938
|
var pkgJson = {
|
|
1090
939
|
name: "@commercetools-frontend/application-cli",
|
|
1091
|
-
version: "2.3.
|
|
940
|
+
version: "2.3.2",
|
|
1092
941
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
1093
942
|
keywords: [
|
|
1094
943
|
"commercetools",
|
|
@@ -1113,22 +962,22 @@ var pkgJson = {
|
|
|
1113
962
|
"@babel/core": "^7.22.11",
|
|
1114
963
|
"@babel/runtime": "^7.21.0",
|
|
1115
964
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
1116
|
-
"@commercetools-frontend/application-config": "22.
|
|
1117
|
-
"@commercetools-frontend/constants": "22.
|
|
1118
|
-
"@commercetools-frontend/l10n": "22.
|
|
965
|
+
"@commercetools-frontend/application-config": "22.23.3",
|
|
966
|
+
"@commercetools-frontend/constants": "22.23.3",
|
|
967
|
+
"@commercetools-frontend/l10n": "22.23.3",
|
|
1119
968
|
"@manypkg/find-root": "2.2.1",
|
|
1120
969
|
cac: "^6.7.14",
|
|
1121
970
|
cosmiconfig: "9.0.0",
|
|
1122
|
-
dotenv: "16.4.
|
|
971
|
+
dotenv: "16.4.5",
|
|
1123
972
|
execa: "5.1.1",
|
|
1124
973
|
jsonschema: "^1.4.1",
|
|
1125
|
-
listr2: "8.0
|
|
974
|
+
listr2: "8.2.0",
|
|
1126
975
|
"node-fetch": "2.7.0",
|
|
1127
976
|
"ts-deepmerge": "7.0.0"
|
|
1128
977
|
},
|
|
1129
978
|
devDependencies: {
|
|
1130
|
-
"@tsconfig/node20": "20.1.
|
|
1131
|
-
"@types/node": "20.
|
|
979
|
+
"@tsconfig/node20": "20.1.4",
|
|
980
|
+
"@types/node": "20.12.7",
|
|
1132
981
|
typescript: "5.2.2"
|
|
1133
982
|
},
|
|
1134
983
|
engines: {
|
|
@@ -1160,7 +1009,7 @@ const run = async () => {
|
|
|
1160
1009
|
// Default command
|
|
1161
1010
|
cli.command('').usage('\n\n Compile deployments and menus and create versions for MC applications').action(cli.outputHelp);
|
|
1162
1011
|
const usageCompileDeployment = 'Compile the deployments for an application for all environments.';
|
|
1163
|
-
cli.command('compile-deployments', usageCompileDeployment).usage(
|
|
1012
|
+
cli.command('compile-deployments', usageCompileDeployment).usage("compile-deployments \n\n ".concat(usageCompileDeployment)).option('--application-name <string>', '(required) The name of the application being compiled for example application-products.').option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file ".env.production" and a cloud-environment specific dotenv file (for example ".env.gcp-production-eu"). Those values are parsed and merged together to be used by the `mc-scripts compile-html` command.').option('--pr-number [string]', '(optional) A pull request number determining a scoped storage bucket for the deployment. Please use it carefully.').option('--mc-url [string]', '(optional) The MC URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--mc-api-url [string]', '(optional) The MC API URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--application-index-out-file [path]', '(optional) The name of the application index file.', {
|
|
1164
1013
|
default: 'application.html'
|
|
1165
1014
|
}).option('--application-index-upload-script-out-file [path]', '(optional) The name of the the application index upload script file.', {
|
|
1166
1015
|
default: 'upload-index.sh'
|
|
@@ -1172,15 +1021,15 @@ const run = async () => {
|
|
|
1172
1021
|
await command$3(options, cwd);
|
|
1173
1022
|
});
|
|
1174
1023
|
const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
|
|
1175
|
-
cli.command('compile-menu', usageCompileMenu).usage(
|
|
1024
|
+
cli.command('compile-menu', usageCompileMenu).usage("compile-menu \n\n ".concat(usageCompileMenu)).option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file `.env.production` and a cloud-environment specific dotenv file (for example `.env.gcp-production-eu`). Those values are parsed and merged together to be used by the application config.').action(async options => {
|
|
1176
1025
|
await command$2(options, cwd);
|
|
1177
1026
|
});
|
|
1178
1027
|
const usageValidateMenu = 'Validate compiled `menu.json` file';
|
|
1179
|
-
cli.command('validate-menu', usageValidateMenu).usage(
|
|
1028
|
+
cli.command('validate-menu', usageValidateMenu).usage("validate-menu \n\n ".concat(usageValidateMenu)).option('--input-file <path>', '(required) The path to the `menu.json` file to be validated.').option('--navigation [string]', '(optional) Location of the menu navigation. Possible values are `top`.').action(async options => {
|
|
1180
1029
|
await command(options);
|
|
1181
1030
|
});
|
|
1182
1031
|
const usageCreateVersion = 'Output a JSON string about the information in the `version.json` for a deployment, including the updated list of rollbacks.';
|
|
1183
|
-
cli.command('create-version', usageCreateVersion).usage(
|
|
1032
|
+
cli.command('create-version', usageCreateVersion).usage("create-version \n\n ".concat(usageCreateVersion)).option('--version-url <url>', "(required) The path of an application's current `version.json` within the storage bucket.").option('--rollbacks [int]', '(optional) The number of max rollbacks to keep', {
|
|
1184
1033
|
default: 15
|
|
1185
1034
|
}).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 => {
|
|
1186
1035
|
await command$1(options);
|