@commercetools-frontend/application-cli 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.dev.js +138 -92
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +138 -92
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +137 -91
- package/dist/commercetools-frontend-application-cli.cjs.dev.js +3 -1
- package/dist/commercetools-frontend-application-cli.cjs.prod.js +3 -1
- package/dist/commercetools-frontend-application-cli.esm.js +2 -1
- package/dist/declarations/src/constants.d.ts +2 -0
- package/dist/declarations/src/storage-buckets-config.d.ts +3 -2
- package/dist/declarations/src/types.d.ts +16 -11
- package/dist/{storage-buckets-config-0b3808a3.cjs.prod.js → storage-buckets-config-06a6b7d2.cjs.prod.js} +33 -0
- package/dist/{storage-buckets-config-478b8585.cjs.dev.js → storage-buckets-config-30d0f671.cjs.dev.js} +33 -0
- package/dist/{storage-buckets-config-7845a091.esm.js → storage-buckets-config-7277eecb.esm.js} +32 -1
- package/package.json +7 -7
|
@@ -16,20 +16,23 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
16
16
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
17
17
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
18
18
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
19
|
-
var
|
|
19
|
+
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
20
|
+
var storageBucketsConfig = require('../../dist/storage-buckets-config-30d0f671.cjs.dev.js');
|
|
20
21
|
var fs = require('node:fs');
|
|
21
22
|
var path$1 = require('node:path');
|
|
22
23
|
var listr2 = require('listr2');
|
|
23
24
|
var execa = require('execa');
|
|
24
|
-
var cosmiconfig = require('cosmiconfig');
|
|
25
25
|
var findRoot = require('@manypkg/find-root');
|
|
26
26
|
var path = require('path');
|
|
27
27
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
28
|
+
var _assertThisInitialized = require('@babel/runtime-corejs3/helpers/assertThisInitialized');
|
|
28
29
|
var _get = require('@babel/runtime-corejs3/helpers/get');
|
|
29
30
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
30
31
|
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
31
32
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
32
33
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
34
|
+
var _classPrivateFieldLooseBase = require('@babel/runtime-corejs3/helpers/classPrivateFieldLooseBase');
|
|
35
|
+
var _classPrivateFieldLooseKey = require('@babel/runtime-corejs3/helpers/classPrivateFieldLooseKey');
|
|
33
36
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
34
37
|
var fs$1 = require('fs');
|
|
35
38
|
var dotenv = require('dotenv');
|
|
@@ -37,9 +40,9 @@ var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/insta
|
|
|
37
40
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
38
41
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
39
42
|
var l10n = require('@commercetools-frontend/l10n');
|
|
40
|
-
var storageBucketsConfig = require('../../dist/storage-buckets-config-478b8585.cjs.dev.js');
|
|
41
43
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
42
44
|
var jsonschema = require('jsonschema');
|
|
45
|
+
require('cosmiconfig');
|
|
43
46
|
require('ts-deepmerge');
|
|
44
47
|
|
|
45
48
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -55,7 +58,7 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
55
58
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
56
59
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
57
60
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
58
|
-
var
|
|
61
|
+
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
59
62
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
60
63
|
var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
|
|
61
64
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
@@ -96,23 +99,34 @@ function _callSuper(_this, derived, args) {
|
|
|
96
99
|
derived = _getPrototypeOf(derived);
|
|
97
100
|
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? _Reflect$construct__default["default"](derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
98
101
|
}
|
|
102
|
+
var _bucketRegion = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
103
|
+
var _bucketEnvironment$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
99
104
|
let StorageProvider = /*#__PURE__*/function () {
|
|
100
|
-
function StorageProvider() {
|
|
105
|
+
function StorageProvider(config) {
|
|
101
106
|
_classCallCheck(this, StorageProvider);
|
|
107
|
+
_Object$defineProperty__default["default"](this, _bucketRegion, {
|
|
108
|
+
writable: true,
|
|
109
|
+
value: void 0
|
|
110
|
+
});
|
|
111
|
+
_Object$defineProperty__default["default"](this, _bucketEnvironment$1, {
|
|
112
|
+
writable: true,
|
|
113
|
+
value: void 0
|
|
114
|
+
});
|
|
115
|
+
_classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion] = config.bucketRegion;
|
|
116
|
+
_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1] = config.bucketEnvironment;
|
|
102
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Construct the storage bucket URL for the specific application and cloud environment.
|
|
120
|
+
*
|
|
121
|
+
* 1. Static assets are uploaded to `:bucketRegion/:prNumber?/:applicationName`
|
|
122
|
+
* 2. The application index is uploaded to `:bucketRegion/:prNumber?/:applicationName/:cloudEnvironment`
|
|
123
|
+
*
|
|
124
|
+
* This allows all cloud environments sharing the same static assets while each application's index
|
|
125
|
+
* is uploaded with different headers (e.g. CSP rules).
|
|
126
|
+
*/
|
|
103
127
|
_createClass(StorageProvider, [{
|
|
104
128
|
key: "getBucketNamespace",
|
|
105
|
-
value:
|
|
106
|
-
/**
|
|
107
|
-
* Construct the storage bucket URL for the specific application and cloud environment.
|
|
108
|
-
*
|
|
109
|
-
* 1. Static assets are uploaded to `:bucketRegion/:prNumber?/:applicationName`
|
|
110
|
-
* 2. The application index is uploaded to `:bucketRegion/:prNumber?/:applicationName/:cloudEnvironment`
|
|
111
|
-
*
|
|
112
|
-
* This allows all cloud environments sharing the same static assets while each application's index
|
|
113
|
-
* is uploaded with different headers (e.g. CSP rules).
|
|
114
|
-
*/
|
|
115
|
-
function getBucketNamespace(prNumber) {
|
|
129
|
+
value: function getBucketNamespace(prNumber) {
|
|
116
130
|
if (!prNumber) return;
|
|
117
131
|
if (prNumber === 'merchant-center-preview') return prNumber;
|
|
118
132
|
return `mc-${prNumber}`;
|
|
@@ -125,56 +139,85 @@ let StorageProvider = /*#__PURE__*/function () {
|
|
|
125
139
|
key: "getAssetsBucketUrl",
|
|
126
140
|
value: function getAssetsBucketUrl(_ref) {
|
|
127
141
|
var _context;
|
|
128
|
-
let
|
|
129
|
-
|
|
130
|
-
bucketNamespace = _ref.bucketNamespace
|
|
131
|
-
|
|
132
|
-
const assetsBucketUrl = _filterInstanceProperty__default["default"](_context = [bucketRegion, bucketNamespace, applicationName]).call(_context, Boolean).join('/');
|
|
142
|
+
let applicationName = _ref.applicationName,
|
|
143
|
+
bucketProtocol = _ref.bucketProtocol,
|
|
144
|
+
bucketNamespace = _ref.bucketNamespace;
|
|
145
|
+
const assetsBucketUrl = _filterInstanceProperty__default["default"](_context = [_classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion], bucketNamespace, applicationName]).call(_context, Boolean).join('/');
|
|
133
146
|
return `${bucketProtocol}${assetsBucketUrl}`;
|
|
134
147
|
}
|
|
135
148
|
}, {
|
|
136
149
|
key: "getApplicationIndexBucketUrl",
|
|
137
150
|
value: function getApplicationIndexBucketUrl(_ref2) {
|
|
138
|
-
let
|
|
139
|
-
bucketRegion = _ref2.bucketRegion,
|
|
140
|
-
bucketNamespace = _ref2.bucketNamespace,
|
|
141
|
-
prNumber = _ref2.prNumber,
|
|
151
|
+
let prNumber = _ref2.prNumber,
|
|
142
152
|
applicationName = _ref2.applicationName,
|
|
143
|
-
|
|
153
|
+
bucketProtocol = _ref2.bucketProtocol,
|
|
154
|
+
bucketNamespace = _ref2.bucketNamespace;
|
|
144
155
|
const applicationAssetsBucketUrl = this.getAssetsBucketUrl({
|
|
145
|
-
|
|
146
|
-
bucketRegion,
|
|
147
|
-
bucketNamespace,
|
|
156
|
+
applicationName,
|
|
148
157
|
prNumber,
|
|
149
|
-
|
|
158
|
+
bucketProtocol,
|
|
159
|
+
bucketNamespace
|
|
150
160
|
});
|
|
151
|
-
const applicationIndexBucketUrl = `${applicationAssetsBucketUrl}/${
|
|
161
|
+
const applicationIndexBucketUrl = `${applicationAssetsBucketUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]}`;
|
|
152
162
|
return applicationIndexBucketUrl;
|
|
153
163
|
}
|
|
154
164
|
}, {
|
|
155
165
|
key: "getCdnUrl",
|
|
156
166
|
value: function getCdnUrl(_ref3) {
|
|
157
167
|
var _context2;
|
|
158
|
-
let
|
|
159
|
-
bucketRegion = _ref3.bucketRegion,
|
|
168
|
+
let applicationName = _ref3.applicationName,
|
|
160
169
|
prNumber = _ref3.prNumber,
|
|
161
|
-
|
|
162
|
-
return _filterInstanceProperty__default["default"](_context2 = [publicBaseUrl,
|
|
170
|
+
publicBaseUrl = _ref3.publicBaseUrl;
|
|
171
|
+
return _filterInstanceProperty__default["default"](_context2 = [publicBaseUrl, _classPrivateFieldLooseBase(this, _bucketRegion)[_bucketRegion], this.getBucketNamespace(prNumber), applicationName]).call(_context2, Boolean).join('/');
|
|
172
|
+
}
|
|
173
|
+
}, {
|
|
174
|
+
key: "getPublicBaseUrl",
|
|
175
|
+
value: function getPublicBaseUrl(tag) {
|
|
176
|
+
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]) {
|
|
177
|
+
throw new Error("'bucketEnvironment is not defined. Required to determine 'publicBaseUrl'.");
|
|
178
|
+
}
|
|
179
|
+
const storageProvider = storageBucketsConfig.storageProviders[tag];
|
|
180
|
+
const publicBaseUrl = storageProvider.urls[_classPrivateFieldLooseBase(this, _bucketEnvironment$1)[_bucketEnvironment$1]] ?? storageProvider.urls.default;
|
|
181
|
+
return publicBaseUrl;
|
|
163
182
|
}
|
|
164
183
|
}]);
|
|
165
184
|
return StorageProvider;
|
|
166
185
|
}();
|
|
186
|
+
var _bucketRegion2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
|
|
187
|
+
var _bucketEnvironment2 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
167
188
|
let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
|
|
168
189
|
_inherits(GoogleStorageProvider, _StorageProvider);
|
|
169
|
-
function GoogleStorageProvider() {
|
|
190
|
+
function GoogleStorageProvider(config) {
|
|
191
|
+
var _this;
|
|
170
192
|
_classCallCheck(this, GoogleStorageProvider);
|
|
171
|
-
|
|
193
|
+
_this = _callSuper(this, GoogleStorageProvider, [config]);
|
|
194
|
+
_Object$defineProperty__default["default"](_assertThisInitialized(_this), _bucketRegion2, {
|
|
195
|
+
writable: true,
|
|
196
|
+
value: void 0
|
|
197
|
+
});
|
|
198
|
+
_Object$defineProperty__default["default"](_assertThisInitialized(_this), _bucketEnvironment2, {
|
|
199
|
+
writable: true,
|
|
200
|
+
value: void 0
|
|
201
|
+
});
|
|
202
|
+
_classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketRegion2)[_bucketRegion2] = config.bucketRegion;
|
|
203
|
+
_classPrivateFieldLooseBase(_assertThisInitialized(_this), _bucketEnvironment2)[_bucketEnvironment2] = config.bucketEnvironment;
|
|
204
|
+
return _this;
|
|
172
205
|
}
|
|
173
206
|
_createClass(GoogleStorageProvider, [{
|
|
174
207
|
key: "getTag",
|
|
175
208
|
value: function getTag() {
|
|
176
209
|
return 'gs';
|
|
177
210
|
}
|
|
211
|
+
}, {
|
|
212
|
+
key: "getBucketRegion",
|
|
213
|
+
value: function getBucketRegion() {
|
|
214
|
+
return _classPrivateFieldLooseBase(this, _bucketRegion2)[_bucketRegion2];
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "getBucketEnvironment",
|
|
218
|
+
value: function getBucketEnvironment() {
|
|
219
|
+
return _classPrivateFieldLooseBase(this, _bucketEnvironment2)[_bucketEnvironment2];
|
|
220
|
+
}
|
|
178
221
|
}, {
|
|
179
222
|
key: "getProtocol",
|
|
180
223
|
value: function getProtocol() {
|
|
@@ -183,7 +226,7 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
|
|
|
183
226
|
}, {
|
|
184
227
|
key: "getPublicBaseUrl",
|
|
185
228
|
value: function getPublicBaseUrl() {
|
|
186
|
-
return
|
|
229
|
+
return _get(_getPrototypeOf(GoogleStorageProvider.prototype), "getPublicBaseUrl", this).call(this, this.getTag());
|
|
187
230
|
}
|
|
188
231
|
}, {
|
|
189
232
|
key: "getCdnUrl",
|
|
@@ -211,18 +254,24 @@ let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider) {
|
|
|
211
254
|
}]);
|
|
212
255
|
return GoogleStorageProvider;
|
|
213
256
|
}(StorageProvider); // TODO: to be implemented.
|
|
214
|
-
function getStorageProvider(storageProvider) {
|
|
257
|
+
function getStorageProvider(storageProvider, config) {
|
|
215
258
|
switch (storageProvider) {
|
|
216
259
|
case 'gs':
|
|
217
|
-
return new GoogleStorageProvider();
|
|
260
|
+
return new GoogleStorageProvider(config);
|
|
218
261
|
default:
|
|
219
262
|
throw new Error(`Storage provider ${storageProvider} not supported`);
|
|
220
263
|
}
|
|
221
264
|
}
|
|
222
265
|
|
|
266
|
+
var _bucketEnvironment = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
|
|
223
267
|
let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
224
|
-
function GoogleStorageUploadScriptsGenerator() {
|
|
268
|
+
function GoogleStorageUploadScriptsGenerator(config) {
|
|
225
269
|
_classCallCheck(this, GoogleStorageUploadScriptsGenerator);
|
|
270
|
+
_Object$defineProperty__default["default"](this, _bucketEnvironment, {
|
|
271
|
+
writable: true,
|
|
272
|
+
value: void 0
|
|
273
|
+
});
|
|
274
|
+
_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment] = config.bucketEnvironment;
|
|
226
275
|
}
|
|
227
276
|
_createClass(GoogleStorageUploadScriptsGenerator, [{
|
|
228
277
|
key: "getApplicationIndexUploadScript",
|
|
@@ -230,10 +279,12 @@ let GoogleStorageUploadScriptsGenerator = /*#__PURE__*/function () {
|
|
|
230
279
|
let packageManagerName = _ref.packageManagerName,
|
|
231
280
|
bucketUrl = _ref.bucketUrl,
|
|
232
281
|
cdnUrl = _ref.cdnUrl,
|
|
233
|
-
bucketEnvironment = _ref.bucketEnvironment,
|
|
234
282
|
buildRevision = _ref.buildRevision,
|
|
235
283
|
buildNumber = _ref.buildNumber,
|
|
236
284
|
applicationIndexOutFile = _ref.applicationIndexOutFile;
|
|
285
|
+
if (!_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]) {
|
|
286
|
+
throw new Error("Missing 'bucketEnvironment' when generating application index.");
|
|
287
|
+
}
|
|
237
288
|
return `
|
|
238
289
|
#!/usr/bin/env bash
|
|
239
290
|
|
|
@@ -251,7 +302,7 @@ gcloud storage cp \\
|
|
|
251
302
|
echo "Creating version.json and uploading it to bucket ${bucketUrl}"
|
|
252
303
|
|
|
253
304
|
NODE_ENV=production ${packageManagerName} application-cli create-version \\
|
|
254
|
-
--version-url=${cdnUrl}/${
|
|
305
|
+
--version-url=${cdnUrl}/${_classPrivateFieldLooseBase(this, _bucketEnvironment)[_bucketEnvironment]}/version.json \\
|
|
255
306
|
--build-revision=${buildRevision} \\
|
|
256
307
|
--build-number=${buildNumber} \\
|
|
257
308
|
--out-file=$(dirname "$0")/version.json
|
|
@@ -287,12 +338,23 @@ set -e
|
|
|
287
338
|
echo "Uploading static assets to Google Storage bucket ${bucketUrl}"
|
|
288
339
|
|
|
289
340
|
gcloud storage cp \\
|
|
290
|
-
${assetsPath}/public/{*.css,*.js,*.js.map,*.
|
|
341
|
+
${assetsPath}/public/{*.css,*.js,*.js.map,*.html} \\
|
|
291
342
|
"${bucketUrl}" \\
|
|
292
343
|
-n \\
|
|
293
344
|
-z js,css \\
|
|
294
345
|
--cache-control="public,max-age=31536000,no-transform"
|
|
295
346
|
|
|
347
|
+
# We need to upload the PNG and HTML files separately because we want them
|
|
348
|
+
# to be able to overwrite the existing files (if any). For instance, the
|
|
349
|
+
# file or the favicons.
|
|
350
|
+
# This is controlled with the '-n' option (which is used for the JS and CSS
|
|
351
|
+
# as we don't want to overwrite them)
|
|
352
|
+
gcloud storage cp \\
|
|
353
|
+
${assetsPath}/public/{*.png,robots.txt} \\
|
|
354
|
+
"${bucketUrl}" \\
|
|
355
|
+
-z txt \\
|
|
356
|
+
--cache-control="public,max-age=31536000,no-transform"
|
|
357
|
+
|
|
296
358
|
if ${skipMenu}; then
|
|
297
359
|
echo "Skipping menu.json upload"
|
|
298
360
|
else
|
|
@@ -327,10 +389,10 @@ fi
|
|
|
327
389
|
}]);
|
|
328
390
|
return GoogleStorageUploadScriptsGenerator;
|
|
329
391
|
}(); // TODO: To be implemented.
|
|
330
|
-
function getUploadScriptsGenerator(storageProvider) {
|
|
392
|
+
function getUploadScriptsGenerator(storageProvider, config) {
|
|
331
393
|
switch (storageProvider) {
|
|
332
394
|
case 'gs':
|
|
333
|
-
return new GoogleStorageUploadScriptsGenerator();
|
|
395
|
+
return new GoogleStorageUploadScriptsGenerator(config);
|
|
334
396
|
default:
|
|
335
397
|
throw new Error(`Storage provider ${storageProvider} not supported`);
|
|
336
398
|
}
|
|
@@ -374,10 +436,7 @@ function loadDotenvFiles(_ref) {
|
|
|
374
436
|
}
|
|
375
437
|
|
|
376
438
|
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; }
|
|
377
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
378
|
-
const storageBucketConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
|
|
379
|
-
searchStrategy: 'project'
|
|
380
|
-
});
|
|
439
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$2(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$2(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
381
440
|
function writeUploadScriptFile(_ref) {
|
|
382
441
|
let fileName = _ref.fileName,
|
|
383
442
|
fileContent = _ref.fileContent,
|
|
@@ -392,12 +451,10 @@ async function compileApplicationAssets(_ref2) {
|
|
|
392
451
|
let cliFlags = _ref2.cliFlags,
|
|
393
452
|
storageProvider = _ref2.storageProvider,
|
|
394
453
|
uploadScriptsGenerator = _ref2.uploadScriptsGenerator,
|
|
395
|
-
bucketRegion = _ref2.bucketRegion,
|
|
396
454
|
paths = _ref2.paths;
|
|
397
455
|
const applicationAssetsUploadScriptContent = uploadScriptsGenerator.getProductionBundlesUploadScript({
|
|
398
456
|
storageProvider,
|
|
399
457
|
bucketUrl: storageProvider.getAssetsBucketUrl({
|
|
400
|
-
bucketRegion,
|
|
401
458
|
prNumber: cliFlags.prNumber,
|
|
402
459
|
applicationName: cliFlags.applicationName
|
|
403
460
|
}),
|
|
@@ -405,7 +462,7 @@ async function compileApplicationAssets(_ref2) {
|
|
|
405
462
|
skipMenu: cliFlags.skipMenu
|
|
406
463
|
});
|
|
407
464
|
const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
408
|
-
const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${
|
|
465
|
+
const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${storageProvider.getBucketRegion()}${parsedApplicationAssetsUploadScriptFile.ext}`;
|
|
409
466
|
writeUploadScriptFile({
|
|
410
467
|
fileName: applicationAssetsUploadScriptFileName,
|
|
411
468
|
fileContent: applicationAssetsUploadScriptContent,
|
|
@@ -417,9 +474,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
417
474
|
storageProvider = _ref3.storageProvider,
|
|
418
475
|
uploadScriptsGenerator = _ref3.uploadScriptsGenerator,
|
|
419
476
|
paths = _ref3.paths,
|
|
420
|
-
|
|
421
|
-
cloudEnvironment = _ref3.cloudEnvironment,
|
|
422
|
-
bucketEnvironment = _ref3.bucketEnvironment;
|
|
477
|
+
cloudEnvironment = _ref3.cloudEnvironment;
|
|
423
478
|
const cloudEnvironmentDeploymentPath = path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
|
|
424
479
|
// Ensure the folder exists
|
|
425
480
|
const createDeploymentsFolderResult = await execa__default["default"]('mkdir', ['-p', cloudEnvironmentDeploymentPath], {
|
|
@@ -431,7 +486,6 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
431
486
|
|
|
432
487
|
// Construct the proper CDN URL for the specific application
|
|
433
488
|
const cdnUrl = storageProvider.getCdnUrl({
|
|
434
|
-
bucketRegion,
|
|
435
489
|
prNumber: cliFlags.prNumber,
|
|
436
490
|
applicationName: cliFlags.applicationName
|
|
437
491
|
});
|
|
@@ -477,13 +531,10 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
477
531
|
storageProvider,
|
|
478
532
|
packageManagerName: cliFlags.packageManagerName,
|
|
479
533
|
bucketUrl: storageProvider.getApplicationIndexBucketUrl({
|
|
480
|
-
bucketRegion,
|
|
481
534
|
prNumber: cliFlags.prNumber,
|
|
482
|
-
applicationName: cliFlags.applicationName
|
|
483
|
-
bucketEnvironment
|
|
535
|
+
applicationName: cliFlags.applicationName
|
|
484
536
|
}),
|
|
485
537
|
cdnUrl,
|
|
486
|
-
bucketEnvironment,
|
|
487
538
|
buildRevision: cliFlags.buildRevision,
|
|
488
539
|
buildNumber: cliFlags.buildNumber,
|
|
489
540
|
applicationIndexOutFile: cliFlags.applicationIndexOutFile
|
|
@@ -502,16 +553,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
502
553
|
}
|
|
503
554
|
async function command$3(cliFlags, cwd) {
|
|
504
555
|
var _context;
|
|
505
|
-
|
|
506
|
-
try {
|
|
507
|
-
// This is the list of the supported cloud environments and their related bucket location.
|
|
508
|
-
cloudEnvironmentsGroupedByBucketRegions = await storageBucketConfigExplorer.search();
|
|
509
|
-
} catch (e) {
|
|
510
|
-
throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
|
|
511
|
-
}
|
|
512
|
-
if (!cloudEnvironmentsGroupedByBucketRegions) {
|
|
513
|
-
throw new Error('Failed loading a storage bucket configuration');
|
|
514
|
-
}
|
|
556
|
+
const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
|
|
515
557
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
516
558
|
let assetsPath;
|
|
517
559
|
if (cliFlags.ciAssetsRootPath && isCI()) {
|
|
@@ -526,28 +568,30 @@ async function command$3(cliFlags, cwd) {
|
|
|
526
568
|
dotenvPath: cliFlags.dotenvFolder && path__default$1["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
|
|
527
569
|
assetsPath
|
|
528
570
|
};
|
|
529
|
-
const defaultStorageProviders = [
|
|
530
|
-
const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](
|
|
571
|
+
const defaultStorageProviders = [storageBucketsConfig.storageProviders.gs.tag];
|
|
572
|
+
const taskList = new listr2.Listr(_mapInstanceProperty__default["default"](_context = _Object$entries__default["default"](storageBucketConfig)).call(_context, _ref4 => {
|
|
531
573
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
532
574
|
bucketRegion = _ref5[0],
|
|
533
575
|
bucketEnvironmentConfigs = _ref5[1];
|
|
534
576
|
return {
|
|
535
577
|
title: `Compiling for bucket region ${bucketRegion}`,
|
|
536
578
|
task: (_bucketRegionCtx, bucketRegionTask) => {
|
|
537
|
-
var _context2;
|
|
538
579
|
// NOTE: Application assets need to be compiled
|
|
539
580
|
// for all storage providers once per region.
|
|
540
|
-
const allStorageProvidersForBucketRegion = [...new _Set__default["default"](
|
|
581
|
+
const allStorageProvidersForBucketRegion = [...new _Set__default["default"](_flatMapInstanceProperty__default["default"](bucketEnvironmentConfigs).call(bucketEnvironmentConfigs, bucketEnvironmentConfig => bucketEnvironmentConfig.storageProviders || defaultStorageProviders))];
|
|
541
582
|
const allApplicationAssetTasks = _mapInstanceProperty__default["default"](allStorageProvidersForBucketRegion).call(allStorageProvidersForBucketRegion, storageProviderTag => {
|
|
542
|
-
const
|
|
543
|
-
const
|
|
583
|
+
const uploadScriptsGeneratorConfig = {};
|
|
584
|
+
const storageProviderConfig = {
|
|
585
|
+
bucketRegion: bucketRegion
|
|
586
|
+
};
|
|
587
|
+
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
588
|
+
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, uploadScriptsGeneratorConfig);
|
|
544
589
|
return {
|
|
545
590
|
title: `Compiling application assets for '${storageProviderTag}'`,
|
|
546
591
|
task: () => compileApplicationAssets({
|
|
547
592
|
cliFlags,
|
|
548
593
|
storageProvider,
|
|
549
594
|
uploadScriptsGenerator,
|
|
550
|
-
bucketRegion: bucketRegion,
|
|
551
595
|
paths
|
|
552
596
|
})
|
|
553
597
|
};
|
|
@@ -556,13 +600,17 @@ async function command$3(cliFlags, cwd) {
|
|
|
556
600
|
const cloudEnvironment = bucketEnvironmentConfig.cloudEnvironment,
|
|
557
601
|
bucketEnvironment = bucketEnvironmentConfig.bucketEnvironment,
|
|
558
602
|
storageProviders = bucketEnvironmentConfig.storageProviders;
|
|
603
|
+
const storageProviderConfig = {
|
|
604
|
+
bucketRegion: bucketRegion,
|
|
605
|
+
bucketEnvironment
|
|
606
|
+
};
|
|
559
607
|
return {
|
|
560
608
|
title: `Compiling for cloud environment '${cloudEnvironment}'`,
|
|
561
609
|
task: (_storageProviderCtx, storageProviderTask) => {
|
|
562
|
-
var
|
|
563
|
-
const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](
|
|
564
|
-
const storageProvider = getStorageProvider(storageProviderTag);
|
|
565
|
-
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag);
|
|
610
|
+
var _context2;
|
|
611
|
+
const applicationIndexTasksForStorageProviders = _mapInstanceProperty__default["default"](_context2 = storageProviders || defaultStorageProviders).call(_context2, storageProviderTag => {
|
|
612
|
+
const storageProvider = getStorageProvider(storageProviderTag, storageProviderConfig);
|
|
613
|
+
const uploadScriptsGenerator = getUploadScriptsGenerator(storageProviderTag, storageProviderConfig);
|
|
566
614
|
return {
|
|
567
615
|
title: `Compiling application index for storage provider '${storageProviderTag}'`,
|
|
568
616
|
task: () => {
|
|
@@ -571,9 +619,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
571
619
|
storageProvider,
|
|
572
620
|
uploadScriptsGenerator,
|
|
573
621
|
paths,
|
|
574
|
-
|
|
575
|
-
cloudEnvironment,
|
|
576
|
-
bucketEnvironment
|
|
622
|
+
cloudEnvironment
|
|
577
623
|
});
|
|
578
624
|
}
|
|
579
625
|
};
|
|
@@ -857,7 +903,7 @@ async function command(cliFlags) {
|
|
|
857
903
|
|
|
858
904
|
var pkgJson = {
|
|
859
905
|
name: "@commercetools-frontend/application-cli",
|
|
860
|
-
version: "2.
|
|
906
|
+
version: "2.2.0",
|
|
861
907
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
862
908
|
keywords: [
|
|
863
909
|
"commercetools",
|
|
@@ -882,22 +928,22 @@ var pkgJson = {
|
|
|
882
928
|
"@babel/core": "^7.22.11",
|
|
883
929
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
884
930
|
"@babel/runtime": "^7.21.0",
|
|
885
|
-
"@commercetools-frontend/application-config": "22.
|
|
886
|
-
"@commercetools-frontend/constants": "22.
|
|
887
|
-
"@commercetools-frontend/l10n": "22.
|
|
931
|
+
"@commercetools-frontend/application-config": "22.19.0",
|
|
932
|
+
"@commercetools-frontend/constants": "22.19.0",
|
|
933
|
+
"@commercetools-frontend/l10n": "22.19.0",
|
|
888
934
|
"@manypkg/find-root": "2.2.1",
|
|
889
935
|
cac: "^6.7.14",
|
|
890
936
|
cosmiconfig: "9.0.0",
|
|
891
|
-
dotenv: "16.
|
|
937
|
+
dotenv: "16.4.2",
|
|
892
938
|
execa: "5.1.1",
|
|
893
939
|
jsonschema: "^1.4.1",
|
|
894
|
-
listr2: "8.0.
|
|
940
|
+
listr2: "8.0.2",
|
|
895
941
|
"node-fetch": "2.7.0",
|
|
896
942
|
"ts-deepmerge": "7.0.0"
|
|
897
943
|
},
|
|
898
944
|
devDependencies: {
|
|
899
945
|
"@tsconfig/node20": "20.1.2",
|
|
900
|
-
"@types/node": "20.11.
|
|
946
|
+
"@types/node": "20.11.25",
|
|
901
947
|
typescript: "5.2.2"
|
|
902
948
|
},
|
|
903
949
|
engines: {
|