@commercetools-frontend/application-cli 2.3.1 → 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 -278
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +129 -278
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +127 -277
- 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
|
@@ -13,11 +13,12 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
|
|
|
13
13
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
14
14
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
15
15
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
16
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
16
17
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
17
18
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
18
19
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
19
20
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
20
|
-
var storageBucketsConfig = require('../../dist/storage-buckets-config-
|
|
21
|
+
var storageBucketsConfig = require('../../dist/storage-buckets-config-8e7abeff.cjs.dev.js');
|
|
21
22
|
var fs = require('node:fs');
|
|
22
23
|
var path$1 = require('node:path');
|
|
23
24
|
var listr2 = require('listr2');
|
|
@@ -25,7 +26,6 @@ var execa = require('execa');
|
|
|
25
26
|
var findRoot = require('@manypkg/find-root');
|
|
26
27
|
var path = require('path');
|
|
27
28
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
28
|
-
var _assertThisInitialized = require('@babel/runtime-corejs3/helpers/assertThisInitialized');
|
|
29
29
|
var _get = require('@babel/runtime-corejs3/helpers/get');
|
|
30
30
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
31
31
|
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
@@ -34,8 +34,8 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
|
34
34
|
var _classPrivateFieldLooseBase = require('@babel/runtime-corejs3/helpers/classPrivateFieldLooseBase');
|
|
35
35
|
var _classPrivateFieldLooseKey = require('@babel/runtime-corejs3/helpers/classPrivateFieldLooseKey');
|
|
36
36
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
37
|
-
var fs$1 = require('fs');
|
|
38
37
|
var dotenv = require('dotenv');
|
|
38
|
+
var fs$1 = require('fs');
|
|
39
39
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
40
40
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
41
41
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
@@ -55,6 +55,7 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
55
55
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
56
56
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
57
57
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
58
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
58
59
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
59
60
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
60
61
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
@@ -64,8 +65,8 @@ var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
|
|
|
64
65
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
65
66
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
66
67
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
67
|
-
var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
68
68
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
69
|
+
var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
69
70
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
70
71
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
71
72
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
@@ -84,7 +85,7 @@ function isCI() {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
87
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
88
|
+
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__default["default"](_context5 = ownKeys$4(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$4(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
88
89
|
function _callSuper(_this, derived, args) {
|
|
89
90
|
function isNativeReflectConstruct() {
|
|
90
91
|
if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false;
|
|
@@ -124,12 +125,12 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
124
125
|
* This allows all cloud environments sharing the same static assets while each application's index
|
|
125
126
|
* is uploaded with different headers (e.g. CSP rules).
|
|
126
127
|
*/
|
|
127
|
-
_createClass(StorageProvider, [{
|
|
128
|
+
return _createClass(StorageProvider, [{
|
|
128
129
|
key: "getBucketNamespace",
|
|
129
130
|
value: function getBucketNamespace(prNumber) {
|
|
130
131
|
if (!prNumber) return;
|
|
131
132
|
if (prNumber === 'merchant-center-preview') return prNumber;
|
|
132
|
-
return
|
|
133
|
+
return "mc-".concat(prNumber);
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/**
|
|
@@ -138,7 +139,7 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
138
139
|
}, {
|
|
139
140
|
key: "getAssetsBucketUrl",
|
|
140
141
|
value: function getAssetsBucketUrl(_ref) {
|
|
141
|
-
var _context;
|
|
142
|
+
var _storageProvider$urls, _storageProvider$urls2, _context, _context2;
|
|
142
143
|
let applicationName = _ref.applicationName,
|
|
143
144
|
bucketProtocol = _ref.bucketProtocol,
|
|
144
145
|
bucketNamespace = _ref.bucketNamespace,
|
|
@@ -147,13 +148,14 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
147
148
|
throw new Error("'bucketRegion' is not defined. Required to determine 'assetsBucketUrl'.");
|
|
148
149
|
}
|
|
149
150
|
const storageProvider = storageBucketsConfig.storageProviders[tag];
|
|
150
|
-
const assetBuketUrl = storageProvider.urls.bucket
|
|
151
|
+
const assetBuketUrl = (_storageProvider$urls = (_storageProvider$urls2 = storageProvider.urls.bucket) === null || _storageProvider$urls2 === void 0 ? void 0 : _storageProvider$urls2[_classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1]]) !== null && _storageProvider$urls !== void 0 ? _storageProvider$urls : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1];
|
|
151
152
|
const assetsBucketUrl = _filterInstanceProperty__default["default"](_context = [assetBuketUrl, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
|
|
152
|
-
return
|
|
153
|
+
return _concatInstanceProperty__default["default"](_context2 = "".concat(bucketProtocol)).call(_context2, assetsBucketUrl);
|
|
153
154
|
}
|
|
154
155
|
}, {
|
|
155
156
|
key: "getApplicationIndexBucketUrl",
|
|
156
157
|
value: function getApplicationIndexBucketUrl(_ref2) {
|
|
158
|
+
var _context3;
|
|
157
159
|
let tag = _ref2.tag,
|
|
158
160
|
prNumber = _ref2.prNumber,
|
|
159
161
|
applicationName = _ref2.applicationName,
|
|
@@ -166,53 +168,53 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
166
168
|
bucketProtocol,
|
|
167
169
|
bucketNamespace
|
|
168
170
|
});
|
|
169
|
-
const applicationIndexBucketUrl =
|
|
171
|
+
const applicationIndexBucketUrl = _concatInstanceProperty__default["default"](_context3 = "".concat(applicationAssetsBucketUrl, "/")).call(_context3, _classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]);
|
|
170
172
|
return applicationIndexBucketUrl;
|
|
171
173
|
}
|
|
172
174
|
}, {
|
|
173
175
|
key: "getCdnUrl",
|
|
174
176
|
value: function getCdnUrl(_ref3) {
|
|
175
|
-
var
|
|
177
|
+
var _context4;
|
|
176
178
|
let applicationName = _ref3.applicationName,
|
|
177
179
|
prNumber = _ref3.prNumber,
|
|
178
180
|
publicBaseUrl = _ref3.publicBaseUrl,
|
|
179
181
|
excludeBucketRegion = _ref3.excludeBucketRegion;
|
|
180
|
-
return _filterInstanceProperty__default["default"](
|
|
182
|
+
return _filterInstanceProperty__default["default"](_context4 = [publicBaseUrl, excludeBucketRegion ? null : _classPrivateFieldLooseBase(this, _bucketRegion$1)[_bucketRegion$1], this.getBucketNamespace(prNumber), applicationName]).call(_context4, Boolean).join('/');
|
|
181
183
|
}
|
|
182
184
|
}, {
|
|
183
185
|
key: "getPublicBaseUrl",
|
|
184
186
|
value: function getPublicBaseUrl(tag) {
|
|
187
|
+
var _storageProvider$urls3;
|
|
185
188
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
|
|
186
189
|
throw new Error("'bucketEnvironment' is not defined. Required to determine 'publicBaseUrl'.");
|
|
187
190
|
}
|
|
188
191
|
const storageProvider = storageBucketsConfig.storageProviders[tag];
|
|
189
|
-
const publicBaseUrl = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]
|
|
192
|
+
const publicBaseUrl = (_storageProvider$urls3 = storageProvider.urls.public[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]]) !== null && _storageProvider$urls3 !== void 0 ? _storageProvider$urls3 : storageProvider.urls.public.default;
|
|
190
193
|
return publicBaseUrl;
|
|
191
194
|
}
|
|
192
195
|
}]);
|
|
193
|
-
return StorageProvider;
|
|
194
196
|
}();
|
|
195
197
|
var _bucketRegion2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
196
198
|
var _bucketEnvironment2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
197
|
-
let GoogleStorageProvider = /*#__PURE__*/function (
|
|
198
|
-
_inherits(GoogleStorageProvider, _StorageProvider);
|
|
199
|
+
let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
|
|
199
200
|
function GoogleStorageProvider(config) {
|
|
200
|
-
var
|
|
201
|
+
var _this2;
|
|
201
202
|
_classCallCheck(this, GoogleStorageProvider);
|
|
202
|
-
|
|
203
|
-
_Object$defineProperty__default["default"](
|
|
203
|
+
_this2 = _callSuper(this, GoogleStorageProvider, [config]);
|
|
204
|
+
_Object$defineProperty__default["default"](_this2, _bucketRegion2$1, {
|
|
204
205
|
writable: true,
|
|
205
206
|
value: void 0
|
|
206
207
|
});
|
|
207
|
-
_Object$defineProperty__default["default"](
|
|
208
|
+
_Object$defineProperty__default["default"](_this2, _bucketEnvironment2$1, {
|
|
208
209
|
writable: true,
|
|
209
210
|
value: void 0
|
|
210
211
|
});
|
|
211
|
-
_classPrivateFieldLooseBase(
|
|
212
|
-
_classPrivateFieldLooseBase(
|
|
213
|
-
return
|
|
212
|
+
_classPrivateFieldLooseBase(_this2, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
|
|
213
|
+
_classPrivateFieldLooseBase(_this2, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
|
|
214
|
+
return _this2;
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
+
_inherits(GoogleStorageProvider, _StorageProvider2);
|
|
217
|
+
return _createClass(GoogleStorageProvider, [{
|
|
216
218
|
key: "getTag",
|
|
217
219
|
value: function getTag() {
|
|
218
220
|
return 'gs';
|
|
@@ -263,29 +265,28 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
|
|
|
263
265
|
}, config));
|
|
264
266
|
}
|
|
265
267
|
}]);
|
|
266
|
-
return GoogleStorageProvider;
|
|
267
268
|
}(StorageProvider);
|
|
268
269
|
var _bucketRegion3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
269
270
|
var _bucketEnvironment3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
270
|
-
let AwsStorageProvider = /*#__PURE__*/function (
|
|
271
|
-
_inherits(AwsStorageProvider, _StorageProvider2);
|
|
271
|
+
let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider3) {
|
|
272
272
|
function AwsStorageProvider(config) {
|
|
273
|
-
var
|
|
273
|
+
var _this3;
|
|
274
274
|
_classCallCheck(this, AwsStorageProvider);
|
|
275
|
-
|
|
276
|
-
_Object$defineProperty__default["default"](
|
|
275
|
+
_this3 = _callSuper(this, AwsStorageProvider, [config]);
|
|
276
|
+
_Object$defineProperty__default["default"](_this3, _bucketRegion3, {
|
|
277
277
|
writable: true,
|
|
278
278
|
value: void 0
|
|
279
279
|
});
|
|
280
|
-
_Object$defineProperty__default["default"](
|
|
280
|
+
_Object$defineProperty__default["default"](_this3, _bucketEnvironment3, {
|
|
281
281
|
writable: true,
|
|
282
282
|
value: void 0
|
|
283
283
|
});
|
|
284
|
-
_classPrivateFieldLooseBase(
|
|
285
|
-
_classPrivateFieldLooseBase(
|
|
286
|
-
return
|
|
284
|
+
_classPrivateFieldLooseBase(_this3, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
|
|
285
|
+
_classPrivateFieldLooseBase(_this3, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
|
|
286
|
+
return _this3;
|
|
287
287
|
}
|
|
288
|
-
|
|
288
|
+
_inherits(AwsStorageProvider, _StorageProvider3);
|
|
289
|
+
return _createClass(AwsStorageProvider, [{
|
|
289
290
|
key: "getTag",
|
|
290
291
|
value: function getTag() {
|
|
291
292
|
return 's3';
|
|
@@ -337,7 +338,6 @@ let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
|
|
|
337
338
|
}, config));
|
|
338
339
|
}
|
|
339
340
|
}]);
|
|
340
|
-
return AwsStorageProvider;
|
|
341
341
|
}(StorageProvider);
|
|
342
342
|
function getStorageProvider(storageProvider, config) {
|
|
343
343
|
switch (storageProvider) {
|
|
@@ -346,7 +346,7 @@ function getStorageProvider(storageProvider, config) {
|
|
|
346
346
|
case 's3':
|
|
347
347
|
return new AwsStorageProvider(config);
|
|
348
348
|
default:
|
|
349
|
-
throw new Error(
|
|
349
|
+
throw new Error("Storage provider ".concat(storageProvider, " not supported"));
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
@@ -366,9 +366,10 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
366
366
|
_classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion] = config.bucketRegion;
|
|
367
367
|
_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment] = config.bucketEnvironment;
|
|
368
368
|
}
|
|
369
|
-
_createClass(GoogleStorageUploadScriptsGenerator, [{
|
|
369
|
+
return _createClass(GoogleStorageUploadScriptsGenerator, [{
|
|
370
370
|
key: "getApplicationIndexUploadScript",
|
|
371
371
|
value: function getApplicationIndexUploadScript(_ref) {
|
|
372
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10;
|
|
372
373
|
let packageManagerName = _ref.packageManagerName,
|
|
373
374
|
bucketUrl = _ref.bucketUrl,
|
|
374
375
|
cdnUrl = _ref.cdnUrl,
|
|
@@ -378,109 +379,18 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
378
379
|
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
|
|
379
380
|
throw new Error("Missing 'bucketEnvironment' when generating application index.");
|
|
380
381
|
}
|
|
381
|
-
return
|
|
382
|
-
#!/usr/bin/env bash
|
|
383
|
-
|
|
384
|
-
set -e
|
|
385
|
-
|
|
386
|
-
echo "Uploading compiled ${applicationIndexOutFile} to Google Storage bucket ${bucketUrl}"
|
|
387
|
-
|
|
388
|
-
gcloud storage cp \\
|
|
389
|
-
"$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
390
|
-
"${bucketUrl}/" \\
|
|
391
|
-
-z html \\
|
|
392
|
-
--content-type="text/html" \\
|
|
393
|
-
--cache-control="public,max-age=0,no-transform"
|
|
394
|
-
|
|
395
|
-
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
396
|
-
|
|
397
|
-
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
398
|
-
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
|
|
399
|
-
--build-revision=${buildRevision} \\
|
|
400
|
-
--build-number=${buildNumber} \\
|
|
401
|
-
--out-file=$(dirname "$0")/version.json
|
|
402
|
-
|
|
403
|
-
gcloud storage cp \\
|
|
404
|
-
"$(dirname "$0")/version.json" \\
|
|
405
|
-
"${bucketUrl}/" \\
|
|
406
|
-
-z json \\
|
|
407
|
-
--content-type="application/json" \\
|
|
408
|
-
--cache-control="public,max-age=0,no-transform"
|
|
409
|
-
`;
|
|
382
|
+
return _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = _concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = _concatInstanceProperty__default["default"](_context10 = "\n#!/usr/bin/env bash\n\nset -e\n\necho \"Uploading compiled ".concat(applicationIndexOutFile, " to Google Storage bucket ")).call(_context10, bucketUrl, "\"\n\ngcloud storage cp \\\n \"$(dirname \"$0\")/")).call(_context9, applicationIndexOutFile, "\" \\\n \"")).call(_context8, bucketUrl, "/\" \\\n -z html \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\"\n\necho \"Creating version.json and uploading it to bucket ")).call(_context7, bucketUrl, "\"\n\nNODE_ENV=production ")).call(_context6, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context5, cdnUrl, "/")).call(_context4, _classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment], "/version.json \\\n --build-revision=")).call(_context3, buildRevision, " \\\n --build-number=")).call(_context2, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\ngcloud storage cp \\\n \"$(dirname \"$0\")/version.json\" \\\n \"")).call(_context, bucketUrl, "/\" \\\n -z json \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\"\n");
|
|
410
383
|
}
|
|
411
384
|
}, {
|
|
412
385
|
key: "getProductionBundlesUploadScript",
|
|
413
386
|
value: function getProductionBundlesUploadScript(_ref2) {
|
|
387
|
+
var _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18;
|
|
414
388
|
let bucketUrl = _ref2.bucketUrl,
|
|
415
389
|
assetsPath = _ref2.assetsPath,
|
|
416
390
|
skipMenu = _ref2.skipMenu;
|
|
417
|
-
return
|
|
418
|
-
#!/usr/bin/env bash
|
|
419
|
-
|
|
420
|
-
set -e
|
|
421
|
-
|
|
422
|
-
# NOTES:
|
|
423
|
-
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
424
|
-
# 1. The '-z' option triggers compressing the assets before
|
|
425
|
-
# uploading them and sets the 'Content-Encoding' to 'gzip'.
|
|
426
|
-
# 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.
|
|
427
|
-
# 3. The 'max-age' is set to 1 year which is considered the maximum
|
|
428
|
-
# "valid" lifetime of an asset to be cached.
|
|
429
|
-
# 4. The '-n' will skip uploading existing files and prevents them to
|
|
430
|
-
# be overwritten
|
|
431
|
-
echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
|
|
432
|
-
|
|
433
|
-
gcloud storage cp \\
|
|
434
|
-
${assetsPath}/public/{*.css,*.js,*.js.map,*.html} \\
|
|
435
|
-
"${bucketUrl}" \\
|
|
436
|
-
-n \\
|
|
437
|
-
-z js,css \\
|
|
438
|
-
--cache-control="public,max-age=31536000,no-transform"
|
|
439
|
-
|
|
440
|
-
# We need to upload the PNG and HTML files separately because we want them
|
|
441
|
-
# to be able to overwrite the existing files (if any). For instance, the
|
|
442
|
-
# file or the favicons.
|
|
443
|
-
# This is controlled with the '-n' option (which is used for the JS and CSS
|
|
444
|
-
# as we don't want to overwrite them)
|
|
445
|
-
gcloud storage cp \\
|
|
446
|
-
${assetsPath}/public/{*.png,robots.txt} \\
|
|
447
|
-
"${bucketUrl}" \\
|
|
448
|
-
-z txt \\
|
|
449
|
-
--cache-control="public,max-age=31536000,no-transform"
|
|
450
|
-
|
|
451
|
-
if ${skipMenu}; then
|
|
452
|
-
echo "Skipping menu.json upload"
|
|
453
|
-
else
|
|
454
|
-
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
455
|
-
# NOTE: somehow the 'cache-control:private' doesn't work.
|
|
456
|
-
# I mean, the file is uploaded with the correct metadata but when I fetch
|
|
457
|
-
# the file the response contains the header
|
|
458
|
-
# 'cache-control: public,max-age=31536000,no-transform', even though the
|
|
459
|
-
# documentation clearly states that by marking the header as 'private' will
|
|
460
|
-
# disable the cache (for publicly readable objects).
|
|
461
|
-
# https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
|
|
462
|
-
# However, I found out that, by requesting the file with any RANDOM
|
|
463
|
-
# query parameter, will instruct the storage to return a 'fresh' object
|
|
464
|
-
# (without any cache control).
|
|
465
|
-
# Unofficial source: https://stackoverflow.com/a/49052895
|
|
466
|
-
# This seems to be the 'easiest' option to 'disable' the cache for public
|
|
467
|
-
# objects. Other alternative approaces are:
|
|
468
|
-
# * make the object private with some simple ACL (private objects are not cached)
|
|
469
|
-
# * suffix the file name with e.g. the git SHA, so we have different files
|
|
470
|
-
# for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
|
|
471
|
-
# the git SHA on runtime and can get the correct file when it starts.
|
|
472
|
-
# * find out why the 'private' cache control does not work
|
|
473
|
-
gcloud storage cp \\
|
|
474
|
-
${assetsPath}/menu.json \\
|
|
475
|
-
${bucketUrl} \\
|
|
476
|
-
-z json \\
|
|
477
|
-
--content-type="application/json" \\
|
|
478
|
-
--cache-control="public,max-age=0,no-transform"
|
|
479
|
-
fi
|
|
480
|
-
`;
|
|
391
|
+
return _concatInstanceProperty__default["default"](_context11 = _concatInstanceProperty__default["default"](_context12 = _concatInstanceProperty__default["default"](_context13 = _concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = _concatInstanceProperty__default["default"](_context16 = _concatInstanceProperty__default["default"](_context17 = _concatInstanceProperty__default["default"](_context18 = "\n#!/usr/bin/env bash\n\nset -e\n\n# NOTES:\n# https://cloud.google.com/sdk/gcloud/reference/storage/cp\n# 1. The '-z' option triggers compressing the assets before\n# uploading them and sets the 'Content-Encoding' to 'gzip'.\n# 2. The 'Accept-encoding: gzip' is set automatically by the 'gcloud storage'.\n# 3. The 'max-age' is set to 1 year which is considered the maximum\n# \"valid\" lifetime of an asset to be cached.\n# 4. The '-n' will skip uploading existing files and prevents them to\n# be overwritten\necho \"Uploading static assets to Google Storage bucket ".concat(bucketUrl, "\"\n\ngcloud storage cp \\\n ")).call(_context18, assetsPath, "/public/{*.css,*.js,*.js.map,*.html} \\\n \"")).call(_context17, bucketUrl, "\" \\\n -n \\\n -z js,css \\\n --cache-control=\"public,max-age=31536000,no-transform\"\n\n# We need to upload the PNG and HTML files separately because we want them\n# to be able to overwrite the existing files (if any). For instance, the\n# file or the favicons.\n# This is controlled with the '-n' option (which is used for the JS and CSS\n# as we don't want to overwrite them)\ngcloud storage cp \\\n ")).call(_context16, assetsPath, "/public/{*.png,robots.txt} \\\n \"")).call(_context15, bucketUrl, "\" \\\n -z txt \\\n --cache-control=\"public,max-age=31536000,no-transform\"\n\nif ")).call(_context14, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context13, bucketUrl, "\"\n # NOTE: somehow the 'cache-control:private' doesn't work.\n # I mean, the file is uploaded with the correct metadata but when I fetch\n # the file the response contains the header\n # 'cache-control: public,max-age=31536000,no-transform', even though the\n # documentation clearly states that by marking the header as 'private' will\n # disable the cache (for publicly readable objects).\n # https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control\n # However, I found out that, by requesting the file with any RANDOM\n # query parameter, will instruct the storage to return a 'fresh' object\n # (without any cache control).\n # Unofficial source: https://stackoverflow.com/a/49052895\n # This seems to be the 'easiest' option to 'disable' the cache for public\n # objects. Other alternative approaces are:\n # * make the object private with some simple ACL (private objects are not cached)\n # * suffix the file name with e.g. the git SHA, so we have different files\n # for each upload ('index.html.template-${CIRCLE_SHA1}'). The server knows\n # the git SHA on runtime and can get the correct file when it starts.\n # * find out why the 'private' cache control does not work\n gcloud storage cp \\\n ")).call(_context12, assetsPath, "/menu.json \\\n ")).call(_context11, bucketUrl, " \\\n -z json \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\"\nfi\n");
|
|
481
392
|
}
|
|
482
393
|
}]);
|
|
483
|
-
return GoogleStorageUploadScriptsGenerator;
|
|
484
394
|
}();
|
|
485
395
|
var _bucketEnvironment2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
486
396
|
var _bucketRegion2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
@@ -498,105 +408,28 @@ let AwsStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
498
408
|
_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2] = config.bucketRegion;
|
|
499
409
|
_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2] = config.bucketEnvironment;
|
|
500
410
|
}
|
|
501
|
-
_createClass(AwsStorageUploadScriptsGenerator, [{
|
|
411
|
+
return _createClass(AwsStorageUploadScriptsGenerator, [{
|
|
502
412
|
key: "getApplicationIndexUploadScript",
|
|
503
413
|
value: function getApplicationIndexUploadScript(_ref3) {
|
|
414
|
+
var _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
|
|
504
415
|
let packageManagerName = _ref3.packageManagerName,
|
|
505
416
|
bucketUrl = _ref3.bucketUrl,
|
|
506
417
|
cdnUrl = _ref3.cdnUrl,
|
|
507
418
|
buildRevision = _ref3.buildRevision,
|
|
508
419
|
buildNumber = _ref3.buildNumber,
|
|
509
420
|
applicationIndexOutFile = _ref3.applicationIndexOutFile;
|
|
510
|
-
return
|
|
511
|
-
#!/usr/bin/env bash
|
|
512
|
-
|
|
513
|
-
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
514
|
-
|
|
515
|
-
set -e
|
|
516
|
-
|
|
517
|
-
aws s3 cp "$(dirname "$0")/${applicationIndexOutFile}" \\
|
|
518
|
-
"${bucketUrl}/" \\
|
|
519
|
-
--content-type="text/html" \\
|
|
520
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
521
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
522
|
-
|
|
523
|
-
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
524
|
-
|
|
525
|
-
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
526
|
-
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2]}/version.json \\
|
|
527
|
-
--build-revision=${buildRevision} \\
|
|
528
|
-
--build-number=${buildNumber} \\
|
|
529
|
-
--out-file=$(dirname "$0")/version.json
|
|
530
|
-
|
|
531
|
-
aws s3 cp "$(dirname "$0")" \\
|
|
532
|
-
"${bucketUrl}/" \\
|
|
533
|
-
--exclude "*" \\
|
|
534
|
-
--include "version.json" \\
|
|
535
|
-
--content-type="application/json" \\
|
|
536
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
537
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
538
|
-
`;
|
|
421
|
+
return _concatInstanceProperty__default["default"](_context19 = _concatInstanceProperty__default["default"](_context20 = _concatInstanceProperty__default["default"](_context21 = _concatInstanceProperty__default["default"](_context22 = _concatInstanceProperty__default["default"](_context23 = _concatInstanceProperty__default["default"](_context24 = _concatInstanceProperty__default["default"](_context25 = _concatInstanceProperty__default["default"](_context26 = _concatInstanceProperty__default["default"](_context27 = _concatInstanceProperty__default["default"](_context28 = _concatInstanceProperty__default["default"](_context29 = "\n #!/usr/bin/env bash\n\n echo \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\n set -e\n\n aws s3 cp \"$(dirname \"$0\")/")).call(_context29, applicationIndexOutFile, "\" \\\n \"")).call(_context28, bucketUrl, "/\" \\\n --content-type=\"text/html\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context27, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n echo \"Creating version.json and uploading it to bucket ")).call(_context26, bucketUrl, "\"\n\n NODE_ENV=production ")).call(_context25, packageManagerName, " application-cli create-version \\\n --version-url=")).call(_context24, cdnUrl, "/")).call(_context23, _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2], "/version.json \\\n --build-revision=")).call(_context22, buildRevision, " \\\n --build-number=")).call(_context21, buildNumber, " \\\n --out-file=$(dirname \"$0\")/version.json\n\n aws s3 cp \"$(dirname \"$0\")\" \\\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");
|
|
539
422
|
}
|
|
540
423
|
}, {
|
|
541
424
|
key: "getProductionBundlesUploadScript",
|
|
542
425
|
value: function getProductionBundlesUploadScript(_ref4) {
|
|
426
|
+
var _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40;
|
|
543
427
|
let bucketUrl = _ref4.bucketUrl,
|
|
544
428
|
assetsPath = _ref4.assetsPath,
|
|
545
429
|
skipMenu = _ref4.skipMenu;
|
|
546
|
-
return
|
|
547
|
-
#!/usr/bin/env bash
|
|
548
|
-
|
|
549
|
-
echo "Uploading static assets to Amazon S3 bucket ${bucketUrl}"
|
|
550
|
-
|
|
551
|
-
set -e
|
|
552
|
-
|
|
553
|
-
# NOTE:
|
|
554
|
-
# The sync command on the AWS CLI is different to the -n option on the gcloud CLI.
|
|
555
|
-
# Sync will only upload files that are not already in the bucket, but it will skip existing ones
|
|
556
|
-
# that have been changed locally.
|
|
557
|
-
# The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.
|
|
558
|
-
# https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
|
|
559
|
-
# https://cloud.google.com/sdk/gcloud/reference/storage/cp
|
|
560
|
-
#
|
|
561
|
-
# Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.
|
|
562
|
-
# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring
|
|
563
|
-
aws s3 sync ${assetsPath}/public \\
|
|
564
|
-
"${bucketUrl}" \\
|
|
565
|
-
--exclude "*" \\
|
|
566
|
-
--include "*.css" \\
|
|
567
|
-
--include "*.js" \\
|
|
568
|
-
--include "*.js.map" \\
|
|
569
|
-
--include "*.html" \\
|
|
570
|
-
--cache-control="public,max-age=31536000,no-transform" \\
|
|
571
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
572
|
-
|
|
573
|
-
# We need to upload the PNG and HTML files separately because we want them
|
|
574
|
-
# to be able to overwrite the existing files (if any). For instance, the
|
|
575
|
-
# file or the favicons.
|
|
576
|
-
aws s3 cp ${assetsPath}/public \\
|
|
577
|
-
"${bucketUrl}" \\
|
|
578
|
-
--recursive \\
|
|
579
|
-
--exclude "*" \\
|
|
580
|
-
--include "*.png" \\
|
|
581
|
-
--include "robots.txt" \\
|
|
582
|
-
--cache-control="public,max-age=31536000,no-transform" \\
|
|
583
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
584
|
-
|
|
585
|
-
if ${skipMenu}; then
|
|
586
|
-
echo "Skipping menu.json upload"
|
|
587
|
-
else
|
|
588
|
-
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
589
|
-
|
|
590
|
-
aws s3 cp ${assetsPath}/menu.json \\
|
|
591
|
-
"${bucketUrl}/" \\
|
|
592
|
-
--content-type="application/json" \\
|
|
593
|
-
--cache-control="public,max-age=0,no-transform" \\
|
|
594
|
-
--profile ${_classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2]}
|
|
595
|
-
fi
|
|
596
|
-
`;
|
|
430
|
+
return _concatInstanceProperty__default["default"](_context30 = _concatInstanceProperty__default["default"](_context31 = _concatInstanceProperty__default["default"](_context32 = _concatInstanceProperty__default["default"](_context33 = _concatInstanceProperty__default["default"](_context34 = _concatInstanceProperty__default["default"](_context35 = _concatInstanceProperty__default["default"](_context36 = _concatInstanceProperty__default["default"](_context37 = _concatInstanceProperty__default["default"](_context38 = _concatInstanceProperty__default["default"](_context39 = _concatInstanceProperty__default["default"](_context40 = "\n#!/usr/bin/env bash\n\necho \"Uploading static assets to Amazon S3 bucket ".concat(bucketUrl, "\"\n\nset -e\n\n# NOTE:\n# The sync command on the AWS CLI is different to the -n option on the gcloud CLI.\n# Sync will only upload files that are not already in the bucket, but it will skip existing ones\n# that have been changed locally.\n# The -n option on the gcloud CLI will skip uploading existing files and prevents them to be overwritten.\n# https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html\n# https://cloud.google.com/sdk/gcloud/reference/storage/cp\n#\n# Compression (gzip) is enabled on CloudFront by default. Hence compression does happing while uploading.\n# https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-configuring\naws s3 sync ")).call(_context40, assetsPath, "/public \\\n \"")).call(_context39, bucketUrl, "\" \\\n --exclude \"*\" \\\n --include \"*.css\" \\\n --include \"*.js\" \\\n --include \"*.js.map\" \\\n --include \"*.html\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context38, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\n# We need to upload the PNG and HTML files separately because we want them\n# to be able to overwrite the existing files (if any). For instance, the\n# file or the favicons.\naws s3 cp ")).call(_context37, assetsPath, "/public \\\n \"")).call(_context36, bucketUrl, "\" \\\n --recursive \\\n --exclude \"*\" \\\n --include \"*.png\" \\\n --include \"robots.txt\" \\\n --cache-control=\"public,max-age=31536000,no-transform\" \\\n --profile ")).call(_context35, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\n\nif ")).call(_context34, skipMenu, "; then\n echo \"Skipping menu.json upload\"\nelse\n echo \"Uploading menu.json to bucket ")).call(_context33, bucketUrl, "\"\n\n aws s3 cp ")).call(_context32, assetsPath, "/menu.json \\\n \"")).call(_context31, bucketUrl, "/\" \\\n --content-type=\"application/json\" \\\n --cache-control=\"public,max-age=0,no-transform\" \\\n --profile ")).call(_context30, _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2], "\nfi\n");
|
|
597
431
|
}
|
|
598
432
|
}]);
|
|
599
|
-
return AwsStorageUploadScriptsGenerator;
|
|
600
433
|
}();
|
|
601
434
|
function getUploadScriptsGenerator(storageProvider, config) {
|
|
602
435
|
switch (storageProvider) {
|
|
@@ -605,12 +438,21 @@ function getUploadScriptsGenerator(storageProvider, config) {
|
|
|
605
438
|
case 's3':
|
|
606
439
|
return new AwsStorageUploadScriptsGenerator(config);
|
|
607
440
|
default:
|
|
608
|
-
throw new Error(
|
|
441
|
+
throw new Error("Storage provider ".concat(storageProvider, " not supported"));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function doesFileExist(filePath) {
|
|
446
|
+
try {
|
|
447
|
+
fs__default$1["default"].accessSync(filePath);
|
|
448
|
+
return true;
|
|
449
|
+
} catch (e) {
|
|
450
|
+
return false;
|
|
609
451
|
}
|
|
610
452
|
}
|
|
611
453
|
|
|
612
454
|
function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
613
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
455
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$3(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$3(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
614
456
|
function loadDotenvFiles(_ref) {
|
|
615
457
|
let dotenvPath = _ref.dotenvPath,
|
|
616
458
|
cloudEnvironment = _ref.cloudEnvironment;
|
|
@@ -620,13 +462,13 @@ function loadDotenvFiles(_ref) {
|
|
|
620
462
|
}
|
|
621
463
|
|
|
622
464
|
// Check if the given path exists.
|
|
623
|
-
if (!
|
|
624
|
-
throw new Error(
|
|
465
|
+
if (!doesFileExist(dotenvPath)) {
|
|
466
|
+
throw new Error("The dotenv folder path does not exist: \"".concat(dotenvPath, "\"."));
|
|
625
467
|
}
|
|
626
468
|
|
|
627
469
|
// Load the environment values
|
|
628
470
|
const sharedDotenvFile = '.env.production';
|
|
629
|
-
const cloudDotenvFile =
|
|
471
|
+
const cloudDotenvFile = ".env.".concat(cloudEnvironment);
|
|
630
472
|
|
|
631
473
|
// The shared dotenv file across environments is optional
|
|
632
474
|
const sharedProductionEnvironment = dotenv__default["default"].config({
|
|
@@ -638,16 +480,18 @@ function loadDotenvFiles(_ref) {
|
|
|
638
480
|
path: path__default["default"].join(dotenvPath, cloudDotenvFile)
|
|
639
481
|
});
|
|
640
482
|
if (cloudSpecificProductionEnvironment.error) {
|
|
641
|
-
|
|
483
|
+
var _context;
|
|
484
|
+
throw new Error(_concatInstanceProperty__default["default"](_context = "Failed loading '".concat(cloudDotenvFile, "' in '")).call(_context, dotenvPath, "'. Make sure it exists."));
|
|
642
485
|
}
|
|
643
486
|
if (sharedProductionEnvironment.error) {
|
|
644
|
-
|
|
487
|
+
var _context2;
|
|
488
|
+
throw new Error(_concatInstanceProperty__default["default"](_context2 = "Failed loading '".concat(sharedDotenvFile, "' in '")).call(_context2, dotenvPath, "'. Make sure it exists."));
|
|
645
489
|
}
|
|
646
490
|
return _objectSpread$3(_objectSpread$3({}, sharedProductionEnvironment.parsed), cloudSpecificProductionEnvironment.parsed);
|
|
647
491
|
}
|
|
648
492
|
|
|
649
493
|
function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
650
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
494
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys$2(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$2(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
651
495
|
function writeUploadScriptFile(_ref) {
|
|
652
496
|
let fileName = _ref.fileName,
|
|
653
497
|
fileContent = _ref.fileContent,
|
|
@@ -659,6 +503,7 @@ function writeUploadScriptFile(_ref) {
|
|
|
659
503
|
});
|
|
660
504
|
}
|
|
661
505
|
async function compileApplicationAssets(_ref2) {
|
|
506
|
+
var _context, _context2;
|
|
662
507
|
let cliFlags = _ref2.cliFlags,
|
|
663
508
|
storageProvider = _ref2.storageProvider,
|
|
664
509
|
uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
|
|
@@ -673,7 +518,7 @@ async function compileApplicationAssets(_ref2) {
|
|
|
673
518
|
skipMenu: cliFlags.skipMenu
|
|
674
519
|
});
|
|
675
520
|
const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
676
|
-
const applicationAssetsUploadScriptFileName =
|
|
521
|
+
const applicationAssetsUploadScriptFileName = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(parsedApplicationAssetsUploadScriptFile.name, "-")).call(_context2, storageProvider.getBucketRegion())).call(_context, parsedApplicationAssetsUploadScriptFile.ext);
|
|
677
522
|
writeUploadScriptFile({
|
|
678
523
|
fileName: applicationAssetsUploadScriptFileName,
|
|
679
524
|
fileContent: applicationAssetsUploadScriptContent,
|
|
@@ -706,7 +551,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
706
551
|
})), {}, {
|
|
707
552
|
// The trailing slash is important to indicate to the CSP directive that all the resources
|
|
708
553
|
// under that path should be allowed.
|
|
709
|
-
MC_CDN_URL:
|
|
554
|
+
MC_CDN_URL: "".concat(cdnUrl, "/")
|
|
710
555
|
}, cliFlags.mcUrl ? {
|
|
711
556
|
MC_URL: cliFlags.mcUrl
|
|
712
557
|
} : {}), cliFlags.mcApiUrl ? {
|
|
@@ -763,7 +608,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
763
608
|
}
|
|
764
609
|
}
|
|
765
610
|
async function command$3(cliFlags, cwd) {
|
|
766
|
-
var
|
|
611
|
+
var _context3;
|
|
767
612
|
const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
|
|
768
613
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
769
614
|
let assetsPath;
|
|
@@ -780,12 +625,12 @@ async function command$3(cliFlags, cwd) {
|
|
|
780
625
|
assetsPath
|
|
781
626
|
};
|
|
782
627
|
const defaultStorageProviders = [storageBucketsConfig.storageProviders.gs.tag];
|
|
783
|
-
const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](
|
|
628
|
+
const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](storageBucketConfig)).call(_context3, _ref4 => {
|
|
784
629
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
785
630
|
bucketRegion = _ref5[0],
|
|
786
631
|
bucketEnvironmentConfigs = _ref5[1];
|
|
787
632
|
return {
|
|
788
|
-
title:
|
|
633
|
+
title: "Compiling for bucket region ".concat(bucketRegion),
|
|
789
634
|
task: (_bucketRegionCtx, bucketRegionTask) => {
|
|
790
635
|
// NOTE: Application assets need to be compiled
|
|
791
636
|
// for all storage providers once per region.
|
|
@@ -800,7 +645,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
800
645
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
801
646
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
|
|
802
647
|
return {
|
|
803
|
-
title:
|
|
648
|
+
title: "Compiling application assets for '".concat(storageProviderTag, "'"),
|
|
804
649
|
task: () => compileApplicationAssets({
|
|
805
650
|
cliFlags,
|
|
806
651
|
storageProvider,
|
|
@@ -818,14 +663,14 @@ async function command$3(cliFlags, cwd) {
|
|
|
818
663
|
bucketEnvironment
|
|
819
664
|
};
|
|
820
665
|
return {
|
|
821
|
-
title:
|
|
666
|
+
title: "Compiling for cloud environment '".concat(cloudEnvironment, "'"),
|
|
822
667
|
task: (_storageProviderCtx, storageProviderTask) => {
|
|
823
|
-
var
|
|
824
|
-
const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](
|
|
668
|
+
var _context4;
|
|
669
|
+
const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context4 = storageProviders || defaultStorageProviders).call(_context4, storageProviderTag => {
|
|
825
670
|
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
826
671
|
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
|
|
827
672
|
return {
|
|
828
|
-
title:
|
|
673
|
+
title: "Compiling application index for storage provider '".concat(storageProviderTag, "'"),
|
|
829
674
|
task: () => {
|
|
830
675
|
return compileEnvironmentApplicationIndexes({
|
|
831
676
|
cliFlags,
|
|
@@ -881,52 +726,58 @@ const mapLabelAllLocalesWithDefaults = (labelAllLocales, defaultLabel) => {
|
|
|
881
726
|
*/
|
|
882
727
|
|
|
883
728
|
const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
884
|
-
var _context2;
|
|
729
|
+
var _ref, _config$env$__DEVELOP, _config$env$__DEVELOP2, _menuLinks$featureTog, _menuLinks$menuVisibi, _menuLinks$actionRigh, _menuLinks$dataFences, _context2, _menuLinks$shouldRend;
|
|
885
730
|
const entryPointUriPath = config.env.entryPointUriPath;
|
|
886
731
|
|
|
887
732
|
// @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
|
|
888
|
-
const accountLinks = config.env.__DEVELOPMENT__
|
|
733
|
+
const accountLinks = (_ref = (_config$env$__DEVELOP = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP === void 0 ? void 0 : _config$env$__DEVELOP.accountLinks) !== null && _ref !== void 0 ? _ref : [];
|
|
889
734
|
if (accountLinks.length > 0) {
|
|
890
|
-
return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink =>
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
735
|
+
return _mapInstanceProperty__default["default"](accountLinks).call(accountLinks, menuLink => {
|
|
736
|
+
var _menuLink$permissions, _menuLink$featureTogg;
|
|
737
|
+
return {
|
|
738
|
+
key: menuLink.uriPath,
|
|
739
|
+
uriPath: menuLink.uriPath,
|
|
740
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLink.labelAllLocales, menuLink.defaultLabel),
|
|
741
|
+
permissions: (_menuLink$permissions = menuLink.permissions) !== null && _menuLink$permissions !== void 0 ? _menuLink$permissions : [],
|
|
742
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
743
|
+
featureToggle: (_menuLink$featureTogg = menuLink.featureToggle) !== null && _menuLink$featureTogg !== void 0 ? _menuLink$featureTogg : null
|
|
744
|
+
};
|
|
745
|
+
});
|
|
898
746
|
}
|
|
899
|
-
const menuLinks = config.env.__DEVELOPMENT__
|
|
747
|
+
const menuLinks = (_config$env$__DEVELOP2 = config.env.__DEVELOPMENT__) === null || _config$env$__DEVELOP2 === void 0 ? void 0 : _config$env$__DEVELOP2.menuLinks;
|
|
900
748
|
return {
|
|
901
749
|
key: entryPointUriPath,
|
|
902
750
|
uriPath: entryPointUriPath,
|
|
903
751
|
icon: menuLinks.icon,
|
|
904
|
-
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks
|
|
752
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.labelAllLocales, menuLinks === null || menuLinks === void 0 ? void 0 : menuLinks.defaultLabel),
|
|
905
753
|
permissions: menuLinks.permissions,
|
|
906
754
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
907
|
-
featureToggle: menuLinks.featureToggle
|
|
755
|
+
featureToggle: (_menuLinks$featureTog = menuLinks.featureToggle) !== null && _menuLinks$featureTog !== void 0 ? _menuLinks$featureTog : null,
|
|
908
756
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
909
|
-
menuVisibility: menuLinks.menuVisibility
|
|
757
|
+
menuVisibility: (_menuLinks$menuVisibi = menuLinks.menuVisibility) !== null && _menuLinks$menuVisibi !== void 0 ? _menuLinks$menuVisibi : null,
|
|
910
758
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
911
|
-
actionRights: menuLinks.actionRights
|
|
759
|
+
actionRights: (_menuLinks$actionRigh = menuLinks.actionRights) !== null && _menuLinks$actionRigh !== void 0 ? _menuLinks$actionRigh : null,
|
|
912
760
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
913
|
-
dataFences: menuLinks.dataFences
|
|
914
|
-
submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink =>
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
761
|
+
dataFences: (_menuLinks$dataFences = menuLinks.dataFences) !== null && _menuLinks$dataFences !== void 0 ? _menuLinks$dataFences : null,
|
|
762
|
+
submenu: _mapInstanceProperty__default["default"](_context2 = menuLinks.submenuLinks).call(_context2, submenuLink => {
|
|
763
|
+
var _submenuLink$featureT, _submenuLink$menuVisi, _submenuLink$actionRi, _submenuLink$dataFenc;
|
|
764
|
+
return {
|
|
765
|
+
key: submenuLink.uriPath.replace('/', '-'),
|
|
766
|
+
uriPath: submenuLink.uriPath,
|
|
767
|
+
labelAllLocales: mapLabelAllLocalesWithDefaults(submenuLink.labelAllLocales, submenuLink.defaultLabel),
|
|
768
|
+
permissions: submenuLink.permissions,
|
|
769
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
770
|
+
featureToggle: (_submenuLink$featureT = submenuLink.featureToggle) !== null && _submenuLink$featureT !== void 0 ? _submenuLink$featureT : null,
|
|
771
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
772
|
+
menuVisibility: (_submenuLink$menuVisi = submenuLink.menuVisibility) !== null && _submenuLink$menuVisi !== void 0 ? _submenuLink$menuVisi : null,
|
|
773
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
774
|
+
actionRights: (_submenuLink$actionRi = submenuLink.actionRights) !== null && _submenuLink$actionRi !== void 0 ? _submenuLink$actionRi : null,
|
|
775
|
+
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
776
|
+
dataFences: (_submenuLink$dataFenc = submenuLink.dataFences) !== null && _submenuLink$dataFenc !== void 0 ? _submenuLink$dataFenc : null
|
|
777
|
+
};
|
|
778
|
+
}),
|
|
928
779
|
// @ts-ignore: not defined in schema, as it's only used internally.
|
|
929
|
-
shouldRenderDivider: menuLinks.shouldRenderDivider
|
|
780
|
+
shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
|
|
930
781
|
};
|
|
931
782
|
};
|
|
932
783
|
async function command$2(cliFlags, cwd) {
|
|
@@ -1108,15 +959,15 @@ function validateMenu(menuJson) {
|
|
|
1108
959
|
async function command(cliFlags) {
|
|
1109
960
|
const menuJsonPath = cliFlags.inputFile;
|
|
1110
961
|
const isAppbarMenu = cliFlags.navigation === 'top';
|
|
1111
|
-
if (!menuJsonPath) throw new Error(
|
|
1112
|
-
if (!
|
|
962
|
+
if (!menuJsonPath) throw new Error("--input-file cannot be empty. please provide the path of compiled menu.json");
|
|
963
|
+
if (!doesFileExist(menuJsonPath)) throw new Error("The menu.json file doesn't exist: ".concat(menuJsonPath));
|
|
1113
964
|
const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
|
|
1114
965
|
return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
|
|
1115
966
|
}
|
|
1116
967
|
|
|
1117
968
|
var pkgJson = {
|
|
1118
969
|
name: "@commercetools-frontend/application-cli",
|
|
1119
|
-
version: "2.3.
|
|
970
|
+
version: "2.3.2",
|
|
1120
971
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
1121
972
|
keywords: [
|
|
1122
973
|
"commercetools",
|
|
@@ -1141,22 +992,22 @@ var pkgJson = {
|
|
|
1141
992
|
"@babel/core": "^7.22.11",
|
|
1142
993
|
"@babel/runtime": "^7.21.0",
|
|
1143
994
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
1144
|
-
"@commercetools-frontend/application-config": "22.
|
|
1145
|
-
"@commercetools-frontend/constants": "22.
|
|
1146
|
-
"@commercetools-frontend/l10n": "22.
|
|
995
|
+
"@commercetools-frontend/application-config": "22.23.3",
|
|
996
|
+
"@commercetools-frontend/constants": "22.23.3",
|
|
997
|
+
"@commercetools-frontend/l10n": "22.23.3",
|
|
1147
998
|
"@manypkg/find-root": "2.2.1",
|
|
1148
999
|
cac: "^6.7.14",
|
|
1149
1000
|
cosmiconfig: "9.0.0",
|
|
1150
|
-
dotenv: "16.4.
|
|
1001
|
+
dotenv: "16.4.5",
|
|
1151
1002
|
execa: "5.1.1",
|
|
1152
1003
|
jsonschema: "^1.4.1",
|
|
1153
|
-
listr2: "8.0
|
|
1004
|
+
listr2: "8.2.0",
|
|
1154
1005
|
"node-fetch": "2.7.0",
|
|
1155
1006
|
"ts-deepmerge": "7.0.0"
|
|
1156
1007
|
},
|
|
1157
1008
|
devDependencies: {
|
|
1158
|
-
"@tsconfig/node20": "20.1.
|
|
1159
|
-
"@types/node": "20.12.
|
|
1009
|
+
"@tsconfig/node20": "20.1.4",
|
|
1010
|
+
"@types/node": "20.12.7",
|
|
1160
1011
|
typescript: "5.2.2"
|
|
1161
1012
|
},
|
|
1162
1013
|
engines: {
|
|
@@ -1188,7 +1039,7 @@ const run = async () => {
|
|
|
1188
1039
|
// Default command
|
|
1189
1040
|
cli.command('').usage('\n\n Compile deployments and menus and create versions for MC applications').action(cli.outputHelp);
|
|
1190
1041
|
const usageCompileDeployment = 'Compile the deployments for an application for all environments.';
|
|
1191
|
-
cli.command('compile-deployments', usageCompileDeployment).usage(
|
|
1042
|
+
cli.command('compile-deployments', usageCompileDeployment).usage("compile-deployments \n\n ".concat(usageCompileDeployment)).option('--application-name <string>', '(required) The name of the application being compiled for example application-products.').option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file ".env.production" and a cloud-environment specific dotenv file (for example ".env.gcp-production-eu"). Those values are parsed and merged together to be used by the `mc-scripts compile-html` command.').option('--pr-number [string]', '(optional) A pull request number determining a scoped storage bucket for the deployment. Please use it carefully.').option('--mc-url [string]', '(optional) The MC URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--mc-api-url [string]', '(optional) The MC API URL of the deployment. This is usually inferred from the env file and overwrites the value. Please use it carefully.').option('--application-index-out-file [path]', '(optional) The name of the application index file.', {
|
|
1192
1043
|
default: 'application.html'
|
|
1193
1044
|
}).option('--application-index-upload-script-out-file [path]', '(optional) The name of the the application index upload script file.', {
|
|
1194
1045
|
default: 'upload-index.sh'
|
|
@@ -1200,15 +1051,15 @@ const run = async () => {
|
|
|
1200
1051
|
await command$3(options, cwd);
|
|
1201
1052
|
});
|
|
1202
1053
|
const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
|
|
1203
|
-
cli.command('compile-menu', usageCompileMenu).usage(
|
|
1054
|
+
cli.command('compile-menu', usageCompileMenu).usage("compile-menu \n\n ".concat(usageCompileMenu)).option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file `.env.production` and a cloud-environment specific dotenv file (for example `.env.gcp-production-eu`). Those values are parsed and merged together to be used by the application config.').action(async options => {
|
|
1204
1055
|
await command$2(options, cwd);
|
|
1205
1056
|
});
|
|
1206
1057
|
const usageValidateMenu = 'Validate compiled `menu.json` file';
|
|
1207
|
-
cli.command('validate-menu', usageValidateMenu).usage(
|
|
1058
|
+
cli.command('validate-menu', usageValidateMenu).usage("validate-menu \n\n ".concat(usageValidateMenu)).option('--input-file <path>', '(required) The path to the `menu.json` file to be validated.').option('--navigation [string]', '(optional) Location of the menu navigation. Possible values are `top`.').action(async options => {
|
|
1208
1059
|
await command(options);
|
|
1209
1060
|
});
|
|
1210
1061
|
const usageCreateVersion = 'Output a JSON string about the information in the `version.json` for a deployment, including the updated list of rollbacks.';
|
|
1211
|
-
cli.command('create-version', usageCreateVersion).usage(
|
|
1062
|
+
cli.command('create-version', usageCreateVersion).usage("create-version \n\n ".concat(usageCreateVersion)).option('--version-url <url>', "(required) The path of an application's current `version.json` within the storage bucket.").option('--rollbacks [int]', '(optional) The number of max rollbacks to keep', {
|
|
1212
1063
|
default: 15
|
|
1213
1064
|
}).option('--out-file [path]', '(optional) The path to the file where to write the JSON. If not specified, the JSON is printed to stdout.').action(async options => {
|
|
1214
1065
|
await command$1(options);
|