@commercetools-frontend/application-cli 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -29
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.dev.js +37 -41
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +37 -41
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +34 -40
- package/dist/commercetools-frontend-application-cli.cjs.dev.js +13 -0
- package/dist/commercetools-frontend-application-cli.cjs.prod.js +13 -0
- package/dist/commercetools-frontend-application-cli.esm.js +4 -1
- package/dist/declarations/src/constants.d.ts +34 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/storage-buckets-config.d.ts +11 -0
- package/dist/declarations/src/types.d.ts +17 -16
- package/dist/storage-buckets-config-0b3808a3.cjs.prod.js +111 -0
- package/dist/storage-buckets-config-478b8585.cjs.dev.js +111 -0
- package/dist/storage-buckets-config-7845a091.esm.js +101 -0
- package/package.json +7 -6
|
@@ -13,12 +13,13 @@ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance
|
|
|
13
13
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
14
14
|
import _Set from '@babel/runtime-corejs3/core-js-stable/set';
|
|
15
15
|
import _flatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat';
|
|
16
|
-
import fs from 'fs';
|
|
17
|
-
import path from 'path';
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import path$1 from 'node:path';
|
|
18
18
|
import { Listr } from 'listr2';
|
|
19
19
|
import execa from 'execa';
|
|
20
20
|
import { cosmiconfig } from 'cosmiconfig';
|
|
21
21
|
import { findRootSync } from '@manypkg/find-root';
|
|
22
|
+
import path from 'path';
|
|
22
23
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
23
24
|
import _get from '@babel/runtime-corejs3/helpers/esm/get';
|
|
24
25
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
@@ -26,13 +27,16 @@ import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
|
26
27
|
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
27
28
|
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
28
29
|
import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
30
|
+
import fs$1 from 'fs';
|
|
29
31
|
import dotenv from 'dotenv';
|
|
30
32
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
31
33
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
32
34
|
import { processConfig } from '@commercetools-frontend/application-config';
|
|
33
35
|
import { getSupportedLocales } from '@commercetools-frontend/l10n';
|
|
36
|
+
import { c as clusterContexts } from '../../dist/storage-buckets-config-7845a091.esm.js';
|
|
34
37
|
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
35
38
|
import { Validator } from 'jsonschema';
|
|
39
|
+
import 'ts-deepmerge';
|
|
36
40
|
|
|
37
41
|
function getApplicationDirectory(cwd) {
|
|
38
42
|
return fs.realpathSync(cwd);
|
|
@@ -314,7 +318,7 @@ function loadDotenvFiles(_ref) {
|
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
// Check if the given path exists.
|
|
317
|
-
if (!fs.existsSync(dotenvPath)) {
|
|
321
|
+
if (!fs$1.existsSync(dotenvPath)) {
|
|
318
322
|
throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
|
|
319
323
|
}
|
|
320
324
|
|
|
@@ -342,14 +346,14 @@ function loadDotenvFiles(_ref) {
|
|
|
342
346
|
|
|
343
347
|
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; }
|
|
344
348
|
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys$2(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys$2(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
345
|
-
const
|
|
349
|
+
const storageBucketConfigExplorer = cosmiconfig('storage-buckets', {
|
|
346
350
|
searchStrategy: 'project'
|
|
347
351
|
});
|
|
348
352
|
function writeUploadScriptFile(_ref) {
|
|
349
353
|
let fileName = _ref.fileName,
|
|
350
354
|
fileContent = _ref.fileContent,
|
|
351
355
|
filePath = _ref.filePath;
|
|
352
|
-
fs.writeFileSync(path.join(filePath, fileName), fileContent, {
|
|
356
|
+
fs.writeFileSync(path$1.join(filePath, fileName), fileContent, {
|
|
353
357
|
// Make the script executable
|
|
354
358
|
mode: 0o755,
|
|
355
359
|
encoding: 'utf8'
|
|
@@ -371,12 +375,12 @@ async function compileApplicationAssets(_ref2) {
|
|
|
371
375
|
assetsPath: paths.assetsPath,
|
|
372
376
|
skipMenu: cliFlags.skipMenu
|
|
373
377
|
});
|
|
374
|
-
const parsedApplicationAssetsUploadScriptFile = path.parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
378
|
+
const parsedApplicationAssetsUploadScriptFile = path$1.parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
375
379
|
const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${bucketRegion}${parsedApplicationAssetsUploadScriptFile.ext}`;
|
|
376
380
|
writeUploadScriptFile({
|
|
377
381
|
fileName: applicationAssetsUploadScriptFileName,
|
|
378
382
|
fileContent: applicationAssetsUploadScriptContent,
|
|
379
|
-
filePath: path.join(paths.deploymentsPath, storageProvider.getTag())
|
|
383
|
+
filePath: path$1.join(paths.deploymentsPath, storageProvider.getTag())
|
|
380
384
|
});
|
|
381
385
|
}
|
|
382
386
|
async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
@@ -387,7 +391,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
387
391
|
bucketRegion = _ref3.bucketRegion,
|
|
388
392
|
cloudEnvironment = _ref3.cloudEnvironment,
|
|
389
393
|
bucketEnvironment = _ref3.bucketEnvironment;
|
|
390
|
-
const cloudEnvironmentDeploymentPath = path.join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
|
|
394
|
+
const cloudEnvironmentDeploymentPath = path$1.join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
|
|
391
395
|
// Ensure the folder exists
|
|
392
396
|
const createDeploymentsFolderResult = await execa('mkdir', ['-p', cloudEnvironmentDeploymentPath], {
|
|
393
397
|
encoding: 'utf8'
|
|
@@ -462,7 +466,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
462
466
|
});
|
|
463
467
|
|
|
464
468
|
// Move the compiled `index.html` to the deployments folder of the related cloud environment.
|
|
465
|
-
const moveResult = await execa('mv', [path.join(paths.publicAssetsPath, 'index.html'), path.join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
|
|
469
|
+
const moveResult = await execa('mv', [path$1.join(paths.publicAssetsPath, 'index.html'), path$1.join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
|
|
466
470
|
if (moveResult.failed) {
|
|
467
471
|
throw new Error(moveResult.stderr);
|
|
468
472
|
}
|
|
@@ -472,9 +476,9 @@ async function command$3(cliFlags, cwd) {
|
|
|
472
476
|
let cloudEnvironmentsGroupedByBucketRegions;
|
|
473
477
|
try {
|
|
474
478
|
// This is the list of the supported cloud environments and their related bucket location.
|
|
475
|
-
cloudEnvironmentsGroupedByBucketRegions = await
|
|
479
|
+
cloudEnvironmentsGroupedByBucketRegions = await storageBucketConfigExplorer.search();
|
|
476
480
|
} catch (e) {
|
|
477
|
-
throw new Error('Failed
|
|
481
|
+
throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
|
|
478
482
|
}
|
|
479
483
|
if (!cloudEnvironmentsGroupedByBucketRegions) {
|
|
480
484
|
throw new Error('Failed loading a storage bucket configuration');
|
|
@@ -490,7 +494,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
490
494
|
const paths = {
|
|
491
495
|
publicAssetsPath: resolveInApplication('public', cwd),
|
|
492
496
|
deploymentsPath: resolveInApplication('deployments', cwd),
|
|
493
|
-
dotenvPath: cliFlags.dotenvFolder && path.join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
|
|
497
|
+
dotenvPath: cliFlags.dotenvFolder && path$1.join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
|
|
494
498
|
assetsPath
|
|
495
499
|
};
|
|
496
500
|
const defaultStorageProviders = ['gs'];
|
|
@@ -514,7 +518,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
514
518
|
cliFlags,
|
|
515
519
|
storageProvider,
|
|
516
520
|
uploadScriptsGenerator,
|
|
517
|
-
bucketRegion,
|
|
521
|
+
bucketRegion: bucketRegion,
|
|
518
522
|
paths
|
|
519
523
|
})
|
|
520
524
|
};
|
|
@@ -538,7 +542,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
538
542
|
storageProvider,
|
|
539
543
|
uploadScriptsGenerator,
|
|
540
544
|
paths,
|
|
541
|
-
bucketRegion,
|
|
545
|
+
bucketRegion: bucketRegion,
|
|
542
546
|
cloudEnvironment,
|
|
543
547
|
bucketEnvironment
|
|
544
548
|
});
|
|
@@ -637,28 +641,17 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
|
637
641
|
shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
|
|
638
642
|
};
|
|
639
643
|
};
|
|
640
|
-
|
|
641
|
-
// During the migration to the Naming Convention Record for Cloud Environments
|
|
642
|
-
// we need to gracefully use the non-compliant and compliant environment names
|
|
643
|
-
// for staging to avoid a breaking release of the CLI.
|
|
644
|
-
const doesCloudEnvironmentExist = _ref => {
|
|
645
|
-
let dotenvPath = _ref.dotenvPath,
|
|
646
|
-
cloudEnvironment = _ref.cloudEnvironment;
|
|
647
|
-
return fs.existsSync(path.join(dotenvPath ?? '', cloudEnvironment));
|
|
648
|
-
};
|
|
649
644
|
async function command$2(cliFlags, cwd) {
|
|
650
645
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
651
646
|
const monorepoRoot = findRootSync(cwd);
|
|
652
647
|
const dotenvPath = cliFlags.dotenvFolder && path.join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
|
|
648
|
+
|
|
649
|
+
// The env itself is not important for the menu. However, the application config
|
|
650
|
+
// uses environment placeholders and therefore we need to provide the variables for it.
|
|
651
|
+
const cloudEnvironment = clusterContexts['ctp_staging_gcp_europe-west1_v1'];
|
|
653
652
|
const processEnv = _objectSpread$1(_objectSpread$1({}, loadDotenvFiles({
|
|
654
653
|
dotenvPath,
|
|
655
|
-
|
|
656
|
-
// uses environment placeholders and therefore we need to provide the variables for it.
|
|
657
|
-
// TODO: Remove after all repositories migrated to NCR.
|
|
658
|
-
cloudEnvironment: doesCloudEnvironmentExist({
|
|
659
|
-
dotenvPath,
|
|
660
|
-
cloudEnvironment: '.env.ctp_staging_gcp_europe-west1_v1'
|
|
661
|
-
}) ? 'ctp_staging_gcp_europe-west1_v1' : 'ctp-gcp-staging'
|
|
654
|
+
cloudEnvironment
|
|
662
655
|
})), {}, {
|
|
663
656
|
// Again, make sure that the environment is "development", otherwise
|
|
664
657
|
// the menu config won't be available.
|
|
@@ -674,7 +667,7 @@ async function command$2(cliFlags, cwd) {
|
|
|
674
667
|
});
|
|
675
668
|
const applicationMenu = mapApplicationMenuConfigToGraqhQLMenuJson(applicationRuntimeConfig);
|
|
676
669
|
const formattedJson = _JSON$stringify(applicationMenu, null, 2);
|
|
677
|
-
fs.writeFileSync(path.join(applicationDirectory, 'menu.json'), formattedJson, {
|
|
670
|
+
fs$1.writeFileSync(path.join(applicationDirectory, 'menu.json'), formattedJson, {
|
|
678
671
|
encoding: 'utf8'
|
|
679
672
|
});
|
|
680
673
|
}
|
|
@@ -707,7 +700,7 @@ async function command$1(cliFlags) {
|
|
|
707
700
|
// Logging to stdout which is from where it will be picked
|
|
708
701
|
// up by the caller (a bash script).
|
|
709
702
|
if (cliFlags.outFile) {
|
|
710
|
-
fs.writeFileSync(cliFlags.outFile, formattedJson, {
|
|
703
|
+
fs$1.writeFileSync(cliFlags.outFile, formattedJson, {
|
|
711
704
|
encoding: 'utf8'
|
|
712
705
|
});
|
|
713
706
|
} else {
|
|
@@ -828,14 +821,14 @@ async function command(cliFlags) {
|
|
|
828
821
|
const menuJsonPath = cliFlags.inputFile;
|
|
829
822
|
const isAppbarMenu = cliFlags.navigation === 'top';
|
|
830
823
|
if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
|
|
831
|
-
if (!fs.existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
|
|
832
|
-
const menuJson = fs.readFileSync(menuJsonPath, 'utf-8');
|
|
824
|
+
if (!fs$1.existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
|
|
825
|
+
const menuJson = fs$1.readFileSync(menuJsonPath, 'utf-8');
|
|
833
826
|
return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
|
|
834
827
|
}
|
|
835
828
|
|
|
836
829
|
var pkgJson = {
|
|
837
830
|
name: "@commercetools-frontend/application-cli",
|
|
838
|
-
version: "2.
|
|
831
|
+
version: "2.1.1",
|
|
839
832
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
840
833
|
keywords: [
|
|
841
834
|
"commercetools",
|
|
@@ -858,11 +851,11 @@ var pkgJson = {
|
|
|
858
851
|
},
|
|
859
852
|
dependencies: {
|
|
860
853
|
"@babel/core": "^7.22.11",
|
|
861
|
-
"@babel/runtime": "^7.21.0",
|
|
862
854
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
863
|
-
"@
|
|
864
|
-
"@commercetools-frontend/
|
|
865
|
-
"@commercetools-frontend/
|
|
855
|
+
"@babel/runtime": "^7.21.0",
|
|
856
|
+
"@commercetools-frontend/application-config": "22.17.0",
|
|
857
|
+
"@commercetools-frontend/constants": "22.17.0",
|
|
858
|
+
"@commercetools-frontend/l10n": "22.17.0",
|
|
866
859
|
"@manypkg/find-root": "2.2.1",
|
|
867
860
|
cac: "^6.7.14",
|
|
868
861
|
cosmiconfig: "9.0.0",
|
|
@@ -870,7 +863,8 @@ var pkgJson = {
|
|
|
870
863
|
execa: "5.1.1",
|
|
871
864
|
jsonschema: "^1.4.1",
|
|
872
865
|
listr2: "8.0.1",
|
|
873
|
-
"node-fetch": "2.7.0"
|
|
866
|
+
"node-fetch": "2.7.0",
|
|
867
|
+
"ts-deepmerge": "7.0.0"
|
|
874
868
|
},
|
|
875
869
|
devDependencies: {
|
|
876
870
|
"@tsconfig/node20": "20.1.2",
|
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var storageBucketsConfig = require('./storage-buckets-config-478b8585.cjs.dev.js');
|
|
6
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
7
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
8
|
+
require('ts-deepmerge');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.bucketEnvironments = storageBucketsConfig.bucketEnvironments;
|
|
13
|
+
exports.bucketRegions = storageBucketsConfig.bucketRegions;
|
|
14
|
+
exports.clusterContexts = storageBucketsConfig.clusterContexts;
|
|
15
|
+
exports.defineStorageBucketsConfig = storageBucketsConfig.defineStorageBucketsConfig;
|
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var storageBucketsConfig = require('./storage-buckets-config-0b3808a3.cjs.prod.js');
|
|
6
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
7
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
8
|
+
require('ts-deepmerge');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.bucketEnvironments = storageBucketsConfig.bucketEnvironments;
|
|
13
|
+
exports.bucketRegions = storageBucketsConfig.bucketRegions;
|
|
14
|
+
exports.clusterContexts = storageBucketsConfig.clusterContexts;
|
|
15
|
+
exports.defineStorageBucketsConfig = storageBucketsConfig.defineStorageBucketsConfig;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { b as bucketEnvironments, a as bucketRegions, c as clusterContexts, d as defineStorageBucketsConfig } from './storage-buckets-config-7845a091.esm.js';
|
|
2
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
3
|
+
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
4
|
+
import 'ts-deepmerge';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const clusterContexts: {
|
|
2
|
+
readonly 'ctp_staging_gcp_europe-west1_v1': "ctp_staging_gcp_europe-west1_v1";
|
|
3
|
+
readonly 'vw_staging_aws_eu-central-1_v1': "vw_staging_aws_eu-central-1_v1";
|
|
4
|
+
readonly 'ctp_staging_aws_cn-northwest-1_v1': "ctp_staging_aws_cn-northwest-1_v1";
|
|
5
|
+
readonly 'ctp_testing_performance_gcp_europe-west1_v1': "ctp_testing_performance_gcp_europe-west1_v1";
|
|
6
|
+
readonly 'ctp_production_aws_eu-central-1_v1': "ctp_production_aws_eu-central-1_v1";
|
|
7
|
+
readonly 'ctp_production_gcp_europe-west1_v1': "ctp_production_gcp_europe-west1_v1";
|
|
8
|
+
readonly 'vw_production_aws_eu-central-1_v1': "vw_production_aws_eu-central-1_v1";
|
|
9
|
+
readonly 'att_production_aws_us-east-1_v1': "att_production_aws_us-east-1_v1";
|
|
10
|
+
readonly 'ctp_production_aws_us-east-2_v1': "ctp_production_aws_us-east-2_v1";
|
|
11
|
+
readonly 'ctp_production_gcp_us-central1_v1': "ctp_production_gcp_us-central1_v1";
|
|
12
|
+
readonly 'ctp_production_gcp_australia-southeast1_v1': "ctp_production_gcp_australia-southeast1_v1";
|
|
13
|
+
readonly 'ctp_production_aws_cn-northwest-1_v1': "ctp_production_aws_cn-northwest-1_v1";
|
|
14
|
+
};
|
|
15
|
+
export declare const bucketEnvironments: {
|
|
16
|
+
readonly 'ctp-gcp-staging': "ctp-gcp-staging";
|
|
17
|
+
readonly 'ctp-vw-staging-eu': "ctp-vw-staging-eu";
|
|
18
|
+
readonly 'ctp-aws-staging-cn': "ctp-aws-staging-cn";
|
|
19
|
+
readonly 'ctp-gcp-testing-performance-eu': "ctp-gcp-testing-performance-eu";
|
|
20
|
+
readonly 'ctp-aws-production-fra': "ctp-aws-production-fra";
|
|
21
|
+
readonly 'ctp-gcp-production-eu': "ctp-gcp-production-eu";
|
|
22
|
+
readonly 'ctp-vw-production-eu': "ctp-vw-production-eu";
|
|
23
|
+
readonly 'ctp-att-production-va': "ctp-att-production-va";
|
|
24
|
+
readonly 'ctp-aws-production-ohio': "ctp-aws-production-ohio";
|
|
25
|
+
readonly 'ctp-gcp-production-us': "ctp-gcp-production-us";
|
|
26
|
+
readonly 'ctp-gcp-production-au': "ctp-gcp-production-au";
|
|
27
|
+
readonly 'ctp-aws-production-cn': "ctp-aws-production-cn";
|
|
28
|
+
};
|
|
29
|
+
export declare const bucketRegions: {
|
|
30
|
+
readonly previews: "merchant-center-previews";
|
|
31
|
+
readonly europe: "merchant-center-europe";
|
|
32
|
+
readonly northAmerica: "merchant-center-north-america";
|
|
33
|
+
readonly asia: "merchant-center-asia";
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TBucketRegion, TCloudEnvironment, type TStorageBucketsConfig } from "./types.js";
|
|
2
|
+
type TConfigOptions = {
|
|
3
|
+
disabledBucketRegions?: TBucketRegion[];
|
|
4
|
+
disabledEnvironments?: TCloudEnvironment[];
|
|
5
|
+
};
|
|
6
|
+
type TDefineConfigArgs = {
|
|
7
|
+
regions?: TStorageBucketsConfig;
|
|
8
|
+
options?: TConfigOptions;
|
|
9
|
+
};
|
|
10
|
+
declare function defineStorageBucketsConfig({ regions, options, }?: TDefineConfigArgs): TStorageBucketsConfig;
|
|
11
|
+
export { defineStorageBucketsConfig };
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { clusterContexts, bucketRegions, bucketEnvironments } from "./constants.js";
|
|
2
|
+
export type TCloudEnvironment = (typeof clusterContexts)[keyof typeof clusterContexts];
|
|
3
|
+
export type TBucketEnvironment = (typeof bucketEnvironments)[keyof typeof bucketEnvironments];
|
|
4
|
+
export type TBucketRegion = (typeof bucketRegions)[keyof typeof bucketRegions];
|
|
1
5
|
export type TApplicationAssetsBucketConfig = {
|
|
2
|
-
bucketRegion:
|
|
6
|
+
bucketRegion: TBucketRegion;
|
|
3
7
|
prNumber?: string;
|
|
4
8
|
applicationName: string;
|
|
5
9
|
};
|
|
6
10
|
export type TApplicationIndexBucketConfig = {
|
|
7
|
-
bucketRegion:
|
|
11
|
+
bucketRegion: TBucketRegion;
|
|
8
12
|
prNumber?: string;
|
|
9
13
|
applicationName: string;
|
|
10
|
-
bucketEnvironment:
|
|
14
|
+
bucketEnvironment: TBucketEnvironment;
|
|
11
15
|
};
|
|
12
16
|
export type TUploadScriptFile = {
|
|
13
17
|
fileName: string;
|
|
@@ -38,26 +42,23 @@ export type TCompileEnvApplicationIndexes = {
|
|
|
38
42
|
storageProvider: IStorageProvider;
|
|
39
43
|
uploadScriptsGenerator: IUploadScriptsGenerator;
|
|
40
44
|
paths: TPaths;
|
|
41
|
-
bucketRegion:
|
|
42
|
-
cloudEnvironment:
|
|
43
|
-
bucketEnvironment:
|
|
45
|
+
bucketRegion: TBucketRegion;
|
|
46
|
+
cloudEnvironment: TCloudEnvironment;
|
|
47
|
+
bucketEnvironment: TBucketEnvironment;
|
|
44
48
|
};
|
|
45
49
|
export type TCompileApplicationAssets = {
|
|
46
50
|
cliFlags: TCompileDeploymentsFlags;
|
|
47
51
|
storageProvider: IStorageProvider;
|
|
48
52
|
uploadScriptsGenerator: IUploadScriptsGenerator;
|
|
49
53
|
paths: TPaths;
|
|
50
|
-
bucketRegion:
|
|
54
|
+
bucketRegion: TBucketRegion;
|
|
51
55
|
};
|
|
52
|
-
type TBucketRegion = string;
|
|
53
56
|
export type TBucketEnvironmentConfig = {
|
|
54
|
-
cloudEnvironment:
|
|
55
|
-
bucketEnvironment:
|
|
56
|
-
storageProviders
|
|
57
|
-
};
|
|
58
|
-
export type TStorageBucketsConfig = {
|
|
59
|
-
[key: TBucketRegion]: TBucketEnvironmentConfig[];
|
|
57
|
+
cloudEnvironment: TCloudEnvironment;
|
|
58
|
+
bucketEnvironment: TBucketEnvironment;
|
|
59
|
+
storageProviders?: TStorageProviderTag[];
|
|
60
60
|
};
|
|
61
|
+
export type TStorageBucketsConfig = Record<TBucketRegion, TBucketEnvironmentConfig[]>;
|
|
61
62
|
export type TCosmiconfigResult = {
|
|
62
63
|
config: TStorageBucketsConfig;
|
|
63
64
|
};
|
|
@@ -66,7 +67,7 @@ export type TCreateApplicationIndexUploadScript = {
|
|
|
66
67
|
storageProvider: IStorageProvider;
|
|
67
68
|
bucketUrl: string;
|
|
68
69
|
cdnUrl: string;
|
|
69
|
-
bucketEnvironment:
|
|
70
|
+
bucketEnvironment: TBucketEnvironment;
|
|
70
71
|
buildRevision: string;
|
|
71
72
|
buildNumber: number;
|
|
72
73
|
applicationIndexOutFile: string;
|
|
@@ -79,7 +80,7 @@ export type TCreateApplicationAssetsUploadScript = {
|
|
|
79
80
|
};
|
|
80
81
|
export type TLoadDotDev = {
|
|
81
82
|
dotenvPath?: string;
|
|
82
|
-
cloudEnvironment:
|
|
83
|
+
cloudEnvironment: TCloudEnvironment;
|
|
83
84
|
};
|
|
84
85
|
export type TLocalizedField = {
|
|
85
86
|
locale: string;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
4
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
5
|
+
var tsDeepmerge = require('ts-deepmerge');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
10
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
11
|
+
|
|
12
|
+
const clusterContexts = {
|
|
13
|
+
'ctp_staging_gcp_europe-west1_v1': 'ctp_staging_gcp_europe-west1_v1',
|
|
14
|
+
'vw_staging_aws_eu-central-1_v1': 'vw_staging_aws_eu-central-1_v1',
|
|
15
|
+
'ctp_staging_aws_cn-northwest-1_v1': 'ctp_staging_aws_cn-northwest-1_v1',
|
|
16
|
+
'ctp_testing_performance_gcp_europe-west1_v1': 'ctp_testing_performance_gcp_europe-west1_v1',
|
|
17
|
+
'ctp_production_aws_eu-central-1_v1': 'ctp_production_aws_eu-central-1_v1',
|
|
18
|
+
'ctp_production_gcp_europe-west1_v1': 'ctp_production_gcp_europe-west1_v1',
|
|
19
|
+
'vw_production_aws_eu-central-1_v1': 'vw_production_aws_eu-central-1_v1',
|
|
20
|
+
'att_production_aws_us-east-1_v1': 'att_production_aws_us-east-1_v1',
|
|
21
|
+
'ctp_production_aws_us-east-2_v1': 'ctp_production_aws_us-east-2_v1',
|
|
22
|
+
'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
|
|
23
|
+
'ctp_production_gcp_australia-southeast1_v1': 'ctp_production_gcp_australia-southeast1_v1',
|
|
24
|
+
'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1'
|
|
25
|
+
};
|
|
26
|
+
const bucketEnvironments = {
|
|
27
|
+
'ctp-gcp-staging': 'ctp-gcp-staging',
|
|
28
|
+
'ctp-vw-staging-eu': 'ctp-vw-staging-eu',
|
|
29
|
+
'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
|
|
30
|
+
'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
|
|
31
|
+
'ctp-aws-production-fra': 'ctp-aws-production-fra',
|
|
32
|
+
'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
|
|
33
|
+
'ctp-vw-production-eu': 'ctp-vw-production-eu',
|
|
34
|
+
'ctp-att-production-va': 'ctp-att-production-va',
|
|
35
|
+
'ctp-aws-production-ohio': 'ctp-aws-production-ohio',
|
|
36
|
+
'ctp-gcp-production-us': 'ctp-gcp-production-us',
|
|
37
|
+
'ctp-gcp-production-au': 'ctp-gcp-production-au',
|
|
38
|
+
'ctp-aws-production-cn': 'ctp-aws-production-cn'
|
|
39
|
+
};
|
|
40
|
+
const bucketRegions = {
|
|
41
|
+
previews: 'merchant-center-previews',
|
|
42
|
+
europe: 'merchant-center-europe',
|
|
43
|
+
northAmerica: 'merchant-center-north-america',
|
|
44
|
+
asia: 'merchant-center-asia'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const defaultConfig = {
|
|
48
|
+
[bucketRegions.previews]: [{
|
|
49
|
+
cloudEnvironment: clusterContexts['ctp_staging_gcp_europe-west1_v1'],
|
|
50
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-staging']
|
|
51
|
+
}, {
|
|
52
|
+
cloudEnvironment: clusterContexts['vw_staging_aws_eu-central-1_v1'],
|
|
53
|
+
bucketEnvironment: bucketEnvironments['ctp-vw-staging-eu']
|
|
54
|
+
}, {
|
|
55
|
+
cloudEnvironment: clusterContexts['ctp_staging_aws_cn-northwest-1_v1'],
|
|
56
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-staging-cn']
|
|
57
|
+
}, {
|
|
58
|
+
cloudEnvironment: clusterContexts['ctp_testing_performance_gcp_europe-west1_v1'],
|
|
59
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-testing-performance-eu']
|
|
60
|
+
}],
|
|
61
|
+
[bucketRegions.europe]: [{
|
|
62
|
+
cloudEnvironment: clusterContexts['ctp_production_aws_eu-central-1_v1'],
|
|
63
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-production-fra']
|
|
64
|
+
}, {
|
|
65
|
+
cloudEnvironment: clusterContexts['ctp_production_gcp_europe-west1_v1'],
|
|
66
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-production-eu']
|
|
67
|
+
}, {
|
|
68
|
+
cloudEnvironment: clusterContexts['vw_production_aws_eu-central-1_v1'],
|
|
69
|
+
bucketEnvironment: bucketEnvironments['ctp-vw-production-eu']
|
|
70
|
+
}],
|
|
71
|
+
[bucketRegions.northAmerica]: [{
|
|
72
|
+
cloudEnvironment: clusterContexts['att_production_aws_us-east-1_v1'],
|
|
73
|
+
bucketEnvironment: bucketEnvironments['ctp-att-production-va']
|
|
74
|
+
}, {
|
|
75
|
+
cloudEnvironment: clusterContexts['ctp_production_aws_us-east-2_v1'],
|
|
76
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-production-ohio']
|
|
77
|
+
}, {
|
|
78
|
+
cloudEnvironment: clusterContexts['ctp_production_gcp_us-central1_v1'],
|
|
79
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-production-us']
|
|
80
|
+
}],
|
|
81
|
+
[bucketRegions.asia]: [{
|
|
82
|
+
cloudEnvironment: clusterContexts['ctp_production_gcp_australia-southeast1_v1'],
|
|
83
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-production-au']
|
|
84
|
+
}, {
|
|
85
|
+
cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
|
|
86
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-production-cn']
|
|
87
|
+
}]
|
|
88
|
+
};
|
|
89
|
+
function defineStorageBucketsConfig() {
|
|
90
|
+
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
91
|
+
regions = _ref.regions,
|
|
92
|
+
options = _ref.options;
|
|
93
|
+
const actualConfig = regions ? tsDeepmerge.merge(defaultConfig, regions) : defaultConfig;
|
|
94
|
+
const disabledBucketRegions = options?.disabledBucketRegions ?? [];
|
|
95
|
+
const disabledEnvironments = options?.disabledEnvironments ?? [];
|
|
96
|
+
_forEachInstanceProperty__default["default"](disabledBucketRegions).call(disabledBucketRegions, disabledBucketRegion => {
|
|
97
|
+
delete actualConfig[disabledBucketRegion];
|
|
98
|
+
});
|
|
99
|
+
const allBucketRegions = _Object$keys__default["default"](actualConfig);
|
|
100
|
+
_forEachInstanceProperty__default["default"](disabledEnvironments).call(disabledEnvironments, disabledEnvrionment => {
|
|
101
|
+
_forEachInstanceProperty__default["default"](allBucketRegions).call(allBucketRegions, bucketRegionToBeRemoved => {
|
|
102
|
+
actualConfig[bucketRegionToBeRemoved] = actualConfig[bucketRegionToBeRemoved]?.filter(bucketEnvironmentConfig => bucketEnvironmentConfig.cloudEnvironment !== disabledEnvrionment);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
return actualConfig;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
exports.bucketEnvironments = bucketEnvironments;
|
|
109
|
+
exports.bucketRegions = bucketRegions;
|
|
110
|
+
exports.clusterContexts = clusterContexts;
|
|
111
|
+
exports.defineStorageBucketsConfig = defineStorageBucketsConfig;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
4
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
5
|
+
var tsDeepmerge = require('ts-deepmerge');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
10
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
11
|
+
|
|
12
|
+
const clusterContexts = {
|
|
13
|
+
'ctp_staging_gcp_europe-west1_v1': 'ctp_staging_gcp_europe-west1_v1',
|
|
14
|
+
'vw_staging_aws_eu-central-1_v1': 'vw_staging_aws_eu-central-1_v1',
|
|
15
|
+
'ctp_staging_aws_cn-northwest-1_v1': 'ctp_staging_aws_cn-northwest-1_v1',
|
|
16
|
+
'ctp_testing_performance_gcp_europe-west1_v1': 'ctp_testing_performance_gcp_europe-west1_v1',
|
|
17
|
+
'ctp_production_aws_eu-central-1_v1': 'ctp_production_aws_eu-central-1_v1',
|
|
18
|
+
'ctp_production_gcp_europe-west1_v1': 'ctp_production_gcp_europe-west1_v1',
|
|
19
|
+
'vw_production_aws_eu-central-1_v1': 'vw_production_aws_eu-central-1_v1',
|
|
20
|
+
'att_production_aws_us-east-1_v1': 'att_production_aws_us-east-1_v1',
|
|
21
|
+
'ctp_production_aws_us-east-2_v1': 'ctp_production_aws_us-east-2_v1',
|
|
22
|
+
'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
|
|
23
|
+
'ctp_production_gcp_australia-southeast1_v1': 'ctp_production_gcp_australia-southeast1_v1',
|
|
24
|
+
'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1'
|
|
25
|
+
};
|
|
26
|
+
const bucketEnvironments = {
|
|
27
|
+
'ctp-gcp-staging': 'ctp-gcp-staging',
|
|
28
|
+
'ctp-vw-staging-eu': 'ctp-vw-staging-eu',
|
|
29
|
+
'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
|
|
30
|
+
'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
|
|
31
|
+
'ctp-aws-production-fra': 'ctp-aws-production-fra',
|
|
32
|
+
'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
|
|
33
|
+
'ctp-vw-production-eu': 'ctp-vw-production-eu',
|
|
34
|
+
'ctp-att-production-va': 'ctp-att-production-va',
|
|
35
|
+
'ctp-aws-production-ohio': 'ctp-aws-production-ohio',
|
|
36
|
+
'ctp-gcp-production-us': 'ctp-gcp-production-us',
|
|
37
|
+
'ctp-gcp-production-au': 'ctp-gcp-production-au',
|
|
38
|
+
'ctp-aws-production-cn': 'ctp-aws-production-cn'
|
|
39
|
+
};
|
|
40
|
+
const bucketRegions = {
|
|
41
|
+
previews: 'merchant-center-previews',
|
|
42
|
+
europe: 'merchant-center-europe',
|
|
43
|
+
northAmerica: 'merchant-center-north-america',
|
|
44
|
+
asia: 'merchant-center-asia'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const defaultConfig = {
|
|
48
|
+
[bucketRegions.previews]: [{
|
|
49
|
+
cloudEnvironment: clusterContexts['ctp_staging_gcp_europe-west1_v1'],
|
|
50
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-staging']
|
|
51
|
+
}, {
|
|
52
|
+
cloudEnvironment: clusterContexts['vw_staging_aws_eu-central-1_v1'],
|
|
53
|
+
bucketEnvironment: bucketEnvironments['ctp-vw-staging-eu']
|
|
54
|
+
}, {
|
|
55
|
+
cloudEnvironment: clusterContexts['ctp_staging_aws_cn-northwest-1_v1'],
|
|
56
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-staging-cn']
|
|
57
|
+
}, {
|
|
58
|
+
cloudEnvironment: clusterContexts['ctp_testing_performance_gcp_europe-west1_v1'],
|
|
59
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-testing-performance-eu']
|
|
60
|
+
}],
|
|
61
|
+
[bucketRegions.europe]: [{
|
|
62
|
+
cloudEnvironment: clusterContexts['ctp_production_aws_eu-central-1_v1'],
|
|
63
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-production-fra']
|
|
64
|
+
}, {
|
|
65
|
+
cloudEnvironment: clusterContexts['ctp_production_gcp_europe-west1_v1'],
|
|
66
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-production-eu']
|
|
67
|
+
}, {
|
|
68
|
+
cloudEnvironment: clusterContexts['vw_production_aws_eu-central-1_v1'],
|
|
69
|
+
bucketEnvironment: bucketEnvironments['ctp-vw-production-eu']
|
|
70
|
+
}],
|
|
71
|
+
[bucketRegions.northAmerica]: [{
|
|
72
|
+
cloudEnvironment: clusterContexts['att_production_aws_us-east-1_v1'],
|
|
73
|
+
bucketEnvironment: bucketEnvironments['ctp-att-production-va']
|
|
74
|
+
}, {
|
|
75
|
+
cloudEnvironment: clusterContexts['ctp_production_aws_us-east-2_v1'],
|
|
76
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-production-ohio']
|
|
77
|
+
}, {
|
|
78
|
+
cloudEnvironment: clusterContexts['ctp_production_gcp_us-central1_v1'],
|
|
79
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-production-us']
|
|
80
|
+
}],
|
|
81
|
+
[bucketRegions.asia]: [{
|
|
82
|
+
cloudEnvironment: clusterContexts['ctp_production_gcp_australia-southeast1_v1'],
|
|
83
|
+
bucketEnvironment: bucketEnvironments['ctp-gcp-production-au']
|
|
84
|
+
}, {
|
|
85
|
+
cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
|
|
86
|
+
bucketEnvironment: bucketEnvironments['ctp-aws-production-cn']
|
|
87
|
+
}]
|
|
88
|
+
};
|
|
89
|
+
function defineStorageBucketsConfig() {
|
|
90
|
+
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
91
|
+
regions = _ref.regions,
|
|
92
|
+
options = _ref.options;
|
|
93
|
+
const actualConfig = regions ? tsDeepmerge.merge(defaultConfig, regions) : defaultConfig;
|
|
94
|
+
const disabledBucketRegions = options?.disabledBucketRegions ?? [];
|
|
95
|
+
const disabledEnvironments = options?.disabledEnvironments ?? [];
|
|
96
|
+
_forEachInstanceProperty__default["default"](disabledBucketRegions).call(disabledBucketRegions, disabledBucketRegion => {
|
|
97
|
+
delete actualConfig[disabledBucketRegion];
|
|
98
|
+
});
|
|
99
|
+
const allBucketRegions = _Object$keys__default["default"](actualConfig);
|
|
100
|
+
_forEachInstanceProperty__default["default"](disabledEnvironments).call(disabledEnvironments, disabledEnvrionment => {
|
|
101
|
+
_forEachInstanceProperty__default["default"](allBucketRegions).call(allBucketRegions, bucketRegionToBeRemoved => {
|
|
102
|
+
actualConfig[bucketRegionToBeRemoved] = actualConfig[bucketRegionToBeRemoved]?.filter(bucketEnvironmentConfig => bucketEnvironmentConfig.cloudEnvironment !== disabledEnvrionment);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
return actualConfig;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
exports.bucketEnvironments = bucketEnvironments;
|
|
109
|
+
exports.bucketRegions = bucketRegions;
|
|
110
|
+
exports.clusterContexts = clusterContexts;
|
|
111
|
+
exports.defineStorageBucketsConfig = defineStorageBucketsConfig;
|