@commercetools-frontend/application-cli 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,28 +30,28 @@ The environments to compile the deployments for must be specified in a `storage-
30
30
  * @type {import('@commercetools-frontend/application-cli').TStorageBucketsConfig}
31
31
  */
32
32
  module.exports = {
33
- 'merchant-center-north-america': ['gcp-production-us'],
34
- 'merchant-center-asia': ['gcp-production-au'],
33
+ 'merchant-center-north-america': {
34
+ cloudEnvironment: 'ctp_production_gcp_us-central1_v1',
35
+ bucketEnvironment: 'ctp-gcp-production-us',
36
+ },
35
37
  };
36
38
  ```
37
39
 
38
- The above configuration would compile for two environments in `gcp-production-us` and `gcp-production-au` each for their respective region. Yielding a `/deployments` folder for the application with the following structure:
40
+ The above configuration would compile for one environment in `gcp-production-us` with its respective region. Yielding a `/deployments` folder for the application with the following structure:
39
41
 
40
42
  ```txt
41
- - public
42
- - gcp-production-us
43
- - application.html
44
- - upload-index.sh
45
- - gcp-production-au
46
- - application.html
47
- - upload-index.sh
48
- - upload-assets-merchant-center-north-america.sh
49
- - upload-assets-merchant-center-asia.sh
43
+ - gs
44
+ - gcp-production-us
45
+ - application.html
46
+ - upload-index.sh
47
+ - upload-assets-merchant-center-north-america.sh
48
+ - upload-assets-merchant-center-asia.sh
50
49
  ```
51
50
 
52
- 1. The `upload-index.sh` and `upload-assets-<bucket>.sh` scripts are generated pre-configured bash scripts for uploading the `application.html` and static assets to the respective storage bucket using `gcloud storage`.
53
- 2. The `public` folder contains shared static assets for all environments.
54
- 3. The `application.html` references the static assets from its respective environment's bucket
51
+ 1. The `gs` folder signals that these files will be uploaded to Google Storage which is the default storage provider
52
+ 2. The `upload-index.sh` and `upload-assets-<bucket>.sh` scripts are generated pre-configured bash scripts for uploading the `application.html` and static assets to the respective storage bucket using `gcloud storage`.
53
+ 3. The `public` folder contains shared static assets for all environments.
54
+ 4. The `application.html` references the static assets from its respective environment's bucket
55
55
 
56
56
  Depending on the environment you are deploying to, you need to:
57
57
 
@@ -60,25 +60,30 @@ Depending on the environment you are deploying to, you need to:
60
60
 
61
61
  Additionally, when specifying the `--dotenv-folder` option, you can specify a dotenv file for each environment (for example `.env.gcp-production-eu`) and a single `.env.production` dotenv file. These files are then loaded when compiling the application for the respective environment.
62
62
 
63
- The configuration also supports an expanded version in which each cloud environment can be linked to another bucket environment:
63
+ The configuration also using a `defineBucketConfig` helper function to opt into defaults for bucket region and their environments:
64
64
 
65
65
  ```js
66
- /**
67
- * @type {import('@commercetools-frontend/application-cli').TStorageBucketsConfig}
68
- */
69
- module.exports = {
70
- 'merchant-center-europe': [
71
- {
72
- cloudEnvironment: 'ctp_production_aws_eu-central-1_v1',
73
- bucketEnvironment: 'ctp-aws-production-fra',
74
- },
75
- ],
76
- };
66
+ const {
67
+ defineStorageBucketsConfig,
68
+ } = require('@commercetools-frontend/application-cli');
69
+
70
+ module.exports = defineStorageBucketsConfig();
77
71
  ```
78
72
 
79
- Given the configuration above the cloud environment `ctp_production_aws_eu-central-1_v1` will be uploaded to the `merchant-center-europe` bucket region within the `ctp-aws-production-fra` folder as the bucket environment.
73
+ Given the configuration above upload scripts and `application.html` files would be generated for all default bucket regions and cloud environments. These can then be picked up by the CircleCI Orb for upload.
74
+
75
+ If you need to disable certain bucket regions or cloud environments, you can use the `options` parameter of `defineBucketConfig`:
76
+
77
+ You can disable existing bucket regions or environments:
80
78
 
81
- This is useful as cloud and bucket environments do not fall in the same lifecycle. A Kubernetes cluster is versioned and may have to change (e.g. be updated) without that needing to be reflected in the respective bucket environment. Also two cloud environments (e.g. in different versions) can be served from one bucket environment if needed.
79
+ ```js
80
+ module.exports = defineStorageBucketsConfig({
81
+ options: {
82
+ disabledBucketRegions: ['merchant-center-north-america']
83
+ disabledEnvironments: ['vw_production_aws_eu-central-1_v1']
84
+ },
85
+ });
86
+ ```
82
87
 
83
88
  ### Command: `compile-menu`
84
89
 
@@ -17,12 +17,13 @@ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instan
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
19
  var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
20
- var fs = require('fs');
21
- var path = require('path');
20
+ var fs = require('node:fs');
21
+ var path$1 = require('node:path');
22
22
  var listr2 = require('listr2');
23
23
  var execa = require('execa');
24
24
  var cosmiconfig = require('cosmiconfig');
25
25
  var findRoot = require('@manypkg/find-root');
26
+ var path = require('path');
26
27
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
27
28
  var _get = require('@babel/runtime-corejs3/helpers/get');
28
29
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
@@ -30,13 +31,16 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
30
31
  var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
31
32
  var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
32
33
  var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
34
+ var fs$1 = require('fs');
33
35
  var dotenv = require('dotenv');
34
36
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
35
37
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
36
38
  var applicationConfig = require('@commercetools-frontend/application-config');
37
39
  var l10n = require('@commercetools-frontend/l10n');
40
+ var storageBucketsConfig = require('../../dist/storage-buckets-config-478b8585.cjs.dev.js');
38
41
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
39
42
  var jsonschema = require('jsonschema');
43
+ require('ts-deepmerge');
40
44
 
41
45
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
42
46
 
@@ -53,9 +57,11 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
53
57
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
54
58
  var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
55
59
  var fs__default = /*#__PURE__*/_interopDefault(fs);
56
- var path__default = /*#__PURE__*/_interopDefault(path);
60
+ var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
57
61
  var execa__default = /*#__PURE__*/_interopDefault(execa);
62
+ var path__default = /*#__PURE__*/_interopDefault(path);
58
63
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
64
+ var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
59
65
  var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
60
66
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
61
67
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
@@ -341,7 +347,7 @@ function loadDotenvFiles(_ref) {
341
347
  }
342
348
 
343
349
  // Check if the given path exists.
344
- if (!fs__default["default"].existsSync(dotenvPath)) {
350
+ if (!fs__default$1["default"].existsSync(dotenvPath)) {
345
351
  throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
346
352
  }
347
353
 
@@ -369,14 +375,14 @@ function loadDotenvFiles(_ref) {
369
375
 
370
376
  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; }
371
377
  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__default["default"](_context4 = ownKeys$2(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$2(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
372
- const buckedConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
378
+ const storageBucketConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
373
379
  searchStrategy: 'project'
374
380
  });
375
381
  function writeUploadScriptFile(_ref) {
376
382
  let fileName = _ref.fileName,
377
383
  fileContent = _ref.fileContent,
378
384
  filePath = _ref.filePath;
379
- fs__default["default"].writeFileSync(path__default["default"].join(filePath, fileName), fileContent, {
385
+ fs__default["default"].writeFileSync(path__default$1["default"].join(filePath, fileName), fileContent, {
380
386
  // Make the script executable
381
387
  mode: 0o755,
382
388
  encoding: 'utf8'
@@ -398,12 +404,12 @@ async function compileApplicationAssets(_ref2) {
398
404
  assetsPath: paths.assetsPath,
399
405
  skipMenu: cliFlags.skipMenu
400
406
  });
401
- const parsedApplicationAssetsUploadScriptFile = path__default["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
407
+ const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
402
408
  const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${bucketRegion}${parsedApplicationAssetsUploadScriptFile.ext}`;
403
409
  writeUploadScriptFile({
404
410
  fileName: applicationAssetsUploadScriptFileName,
405
411
  fileContent: applicationAssetsUploadScriptContent,
406
- filePath: path__default["default"].join(paths.deploymentsPath, storageProvider.getTag())
412
+ filePath: path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag())
407
413
  });
408
414
  }
409
415
  async function compileEnvironmentApplicationIndexes(_ref3) {
@@ -414,7 +420,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
414
420
  bucketRegion = _ref3.bucketRegion,
415
421
  cloudEnvironment = _ref3.cloudEnvironment,
416
422
  bucketEnvironment = _ref3.bucketEnvironment;
417
- const cloudEnvironmentDeploymentPath = path__default["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
423
+ const cloudEnvironmentDeploymentPath = path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
418
424
  // Ensure the folder exists
419
425
  const createDeploymentsFolderResult = await execa__default["default"]('mkdir', ['-p', cloudEnvironmentDeploymentPath], {
420
426
  encoding: 'utf8'
@@ -489,7 +495,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
489
495
  });
490
496
 
491
497
  // Move the compiled `index.html` to the deployments folder of the related cloud environment.
492
- const moveResult = await execa__default["default"]('mv', [path__default["default"].join(paths.publicAssetsPath, 'index.html'), path__default["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
498
+ const moveResult = await execa__default["default"]('mv', [path__default$1["default"].join(paths.publicAssetsPath, 'index.html'), path__default$1["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
493
499
  if (moveResult.failed) {
494
500
  throw new Error(moveResult.stderr);
495
501
  }
@@ -499,9 +505,9 @@ async function command$3(cliFlags, cwd) {
499
505
  let cloudEnvironmentsGroupedByBucketRegions;
500
506
  try {
501
507
  // This is the list of the supported cloud environments and their related bucket location.
502
- cloudEnvironmentsGroupedByBucketRegions = await buckedConfigExplorer.search();
508
+ cloudEnvironmentsGroupedByBucketRegions = await storageBucketConfigExplorer.search();
503
509
  } catch (e) {
504
- throw new Error('Failed loading a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
510
+ throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
505
511
  }
506
512
  if (!cloudEnvironmentsGroupedByBucketRegions) {
507
513
  throw new Error('Failed loading a storage bucket configuration');
@@ -517,7 +523,7 @@ async function command$3(cliFlags, cwd) {
517
523
  const paths = {
518
524
  publicAssetsPath: resolveInApplication('public', cwd),
519
525
  deploymentsPath: resolveInApplication('deployments', cwd),
520
- dotenvPath: cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
526
+ dotenvPath: cliFlags.dotenvFolder && path__default$1["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
521
527
  assetsPath
522
528
  };
523
529
  const defaultStorageProviders = ['gs'];
@@ -541,7 +547,7 @@ async function command$3(cliFlags, cwd) {
541
547
  cliFlags,
542
548
  storageProvider,
543
549
  uploadScriptsGenerator,
544
- bucketRegion,
550
+ bucketRegion: bucketRegion,
545
551
  paths
546
552
  })
547
553
  };
@@ -565,7 +571,7 @@ async function command$3(cliFlags, cwd) {
565
571
  storageProvider,
566
572
  uploadScriptsGenerator,
567
573
  paths,
568
- bucketRegion,
574
+ bucketRegion: bucketRegion,
569
575
  cloudEnvironment,
570
576
  bucketEnvironment
571
577
  });
@@ -671,21 +677,23 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
671
677
  const doesCloudEnvironmentExist = _ref => {
672
678
  let dotenvPath = _ref.dotenvPath,
673
679
  cloudEnvironment = _ref.cloudEnvironment;
674
- return fs__default["default"].existsSync(path__default["default"].join(dotenvPath ?? '', cloudEnvironment));
680
+ return fs__default$1["default"].existsSync(path__default["default"].join(dotenvPath ?? '', `.env.${cloudEnvironment}`));
675
681
  };
676
682
  async function command$2(cliFlags, cwd) {
677
683
  const applicationDirectory = getApplicationDirectory(cwd);
678
684
  const monorepoRoot = findRoot.findRootSync(cwd);
679
685
  const dotenvPath = cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
686
+
687
+ // The env itself is not important for the menu. However, the application config
688
+ // uses environment placeholders and therefore we need to provide the variables for it.
689
+ // TODO: Remove after all repositories migrated to NCR.
690
+ const cloudEnvironment = doesCloudEnvironmentExist({
691
+ dotenvPath,
692
+ cloudEnvironment: storageBucketsConfig.clusterContexts['ctp_staging_gcp_europe-west1_v1']
693
+ }) ? storageBucketsConfig.clusterContexts['ctp_staging_gcp_europe-west1_v1'] : 'ctp-gcp-staging';
680
694
  const processEnv = _objectSpread$1(_objectSpread$1({}, loadDotenvFiles({
681
695
  dotenvPath,
682
- // The env itself is not important for the menu. However, the application config
683
- // uses environment placeholders and therefore we need to provide the variables for it.
684
- // TODO: Remove after all repositories migrated to NCR.
685
- cloudEnvironment: doesCloudEnvironmentExist({
686
- dotenvPath,
687
- cloudEnvironment: '.env.ctp_staging_gcp_europe-west1_v1'
688
- }) ? 'ctp_staging_gcp_europe-west1_v1' : 'ctp-gcp-staging'
696
+ cloudEnvironment
689
697
  })), {}, {
690
698
  // Again, make sure that the environment is "development", otherwise
691
699
  // the menu config won't be available.
@@ -701,7 +709,7 @@ async function command$2(cliFlags, cwd) {
701
709
  });
702
710
  const applicationMenu = mapApplicationMenuConfigToGraqhQLMenuJson(applicationRuntimeConfig);
703
711
  const formattedJson = _JSON$stringify__default["default"](applicationMenu, null, 2);
704
- fs__default["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
712
+ fs__default$1["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
705
713
  encoding: 'utf8'
706
714
  });
707
715
  }
@@ -734,7 +742,7 @@ async function command$1(cliFlags) {
734
742
  // Logging to stdout which is from where it will be picked
735
743
  // up by the caller (a bash script).
736
744
  if (cliFlags.outFile) {
737
- fs__default["default"].writeFileSync(cliFlags.outFile, formattedJson, {
745
+ fs__default$1["default"].writeFileSync(cliFlags.outFile, formattedJson, {
738
746
  encoding: 'utf8'
739
747
  });
740
748
  } else {
@@ -855,14 +863,14 @@ async function command(cliFlags) {
855
863
  const menuJsonPath = cliFlags.inputFile;
856
864
  const isAppbarMenu = cliFlags.navigation === 'top';
857
865
  if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
858
- if (!fs__default["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
859
- const menuJson = fs__default["default"].readFileSync(menuJsonPath, 'utf-8');
866
+ if (!fs__default$1["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
867
+ const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
860
868
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
861
869
  }
862
870
 
863
871
  var pkgJson = {
864
872
  name: "@commercetools-frontend/application-cli",
865
- version: "2.0.0",
873
+ version: "2.1.0",
866
874
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
867
875
  keywords: [
868
876
  "commercetools",
@@ -885,8 +893,8 @@ var pkgJson = {
885
893
  },
886
894
  dependencies: {
887
895
  "@babel/core": "^7.22.11",
888
- "@babel/runtime": "^7.21.0",
889
896
  "@babel/runtime-corejs3": "^7.21.0",
897
+ "@babel/runtime": "^7.21.0",
890
898
  "@commercetools-frontend/application-config": "22.16.0",
891
899
  "@commercetools-frontend/constants": "22.16.0",
892
900
  "@commercetools-frontend/l10n": "22.16.0",
@@ -897,7 +905,8 @@ var pkgJson = {
897
905
  execa: "5.1.1",
898
906
  jsonschema: "^1.4.1",
899
907
  listr2: "8.0.1",
900
- "node-fetch": "2.7.0"
908
+ "node-fetch": "2.7.0",
909
+ "ts-deepmerge": "7.0.0"
901
910
  },
902
911
  devDependencies: {
903
912
  "@tsconfig/node20": "20.1.2",
@@ -17,12 +17,13 @@ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instan
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
19
  var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
20
- var fs = require('fs');
21
- var path = require('path');
20
+ var fs = require('node:fs');
21
+ var path$1 = require('node:path');
22
22
  var listr2 = require('listr2');
23
23
  var execa = require('execa');
24
24
  var cosmiconfig = require('cosmiconfig');
25
25
  var findRoot = require('@manypkg/find-root');
26
+ var path = require('path');
26
27
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
27
28
  var _get = require('@babel/runtime-corejs3/helpers/get');
28
29
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
@@ -30,13 +31,16 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
30
31
  var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
31
32
  var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
32
33
  var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
34
+ var fs$1 = require('fs');
33
35
  var dotenv = require('dotenv');
34
36
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
35
37
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
36
38
  var applicationConfig = require('@commercetools-frontend/application-config');
37
39
  var l10n = require('@commercetools-frontend/l10n');
40
+ var storageBucketsConfig = require('../../dist/storage-buckets-config-0b3808a3.cjs.prod.js');
38
41
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
39
42
  var jsonschema = require('jsonschema');
43
+ require('ts-deepmerge');
40
44
 
41
45
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
42
46
 
@@ -53,9 +57,11 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
53
57
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
54
58
  var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
55
59
  var fs__default = /*#__PURE__*/_interopDefault(fs);
56
- var path__default = /*#__PURE__*/_interopDefault(path);
60
+ var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
57
61
  var execa__default = /*#__PURE__*/_interopDefault(execa);
62
+ var path__default = /*#__PURE__*/_interopDefault(path);
58
63
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
64
+ var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
59
65
  var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
60
66
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
61
67
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
@@ -341,7 +347,7 @@ function loadDotenvFiles(_ref) {
341
347
  }
342
348
 
343
349
  // Check if the given path exists.
344
- if (!fs__default["default"].existsSync(dotenvPath)) {
350
+ if (!fs__default$1["default"].existsSync(dotenvPath)) {
345
351
  throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
346
352
  }
347
353
 
@@ -369,14 +375,14 @@ function loadDotenvFiles(_ref) {
369
375
 
370
376
  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; }
371
377
  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__default["default"](_context4 = ownKeys$2(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$2(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
372
- const buckedConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
378
+ const storageBucketConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
373
379
  searchStrategy: 'project'
374
380
  });
375
381
  function writeUploadScriptFile(_ref) {
376
382
  let fileName = _ref.fileName,
377
383
  fileContent = _ref.fileContent,
378
384
  filePath = _ref.filePath;
379
- fs__default["default"].writeFileSync(path__default["default"].join(filePath, fileName), fileContent, {
385
+ fs__default["default"].writeFileSync(path__default$1["default"].join(filePath, fileName), fileContent, {
380
386
  // Make the script executable
381
387
  mode: 0o755,
382
388
  encoding: 'utf8'
@@ -398,12 +404,12 @@ async function compileApplicationAssets(_ref2) {
398
404
  assetsPath: paths.assetsPath,
399
405
  skipMenu: cliFlags.skipMenu
400
406
  });
401
- const parsedApplicationAssetsUploadScriptFile = path__default["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
407
+ const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
402
408
  const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${bucketRegion}${parsedApplicationAssetsUploadScriptFile.ext}`;
403
409
  writeUploadScriptFile({
404
410
  fileName: applicationAssetsUploadScriptFileName,
405
411
  fileContent: applicationAssetsUploadScriptContent,
406
- filePath: path__default["default"].join(paths.deploymentsPath, storageProvider.getTag())
412
+ filePath: path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag())
407
413
  });
408
414
  }
409
415
  async function compileEnvironmentApplicationIndexes(_ref3) {
@@ -414,7 +420,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
414
420
  bucketRegion = _ref3.bucketRegion,
415
421
  cloudEnvironment = _ref3.cloudEnvironment,
416
422
  bucketEnvironment = _ref3.bucketEnvironment;
417
- const cloudEnvironmentDeploymentPath = path__default["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
423
+ const cloudEnvironmentDeploymentPath = path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
418
424
  // Ensure the folder exists
419
425
  const createDeploymentsFolderResult = await execa__default["default"]('mkdir', ['-p', cloudEnvironmentDeploymentPath], {
420
426
  encoding: 'utf8'
@@ -489,7 +495,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
489
495
  });
490
496
 
491
497
  // Move the compiled `index.html` to the deployments folder of the related cloud environment.
492
- const moveResult = await execa__default["default"]('mv', [path__default["default"].join(paths.publicAssetsPath, 'index.html'), path__default["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
498
+ const moveResult = await execa__default["default"]('mv', [path__default$1["default"].join(paths.publicAssetsPath, 'index.html'), path__default$1["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
493
499
  if (moveResult.failed) {
494
500
  throw new Error(moveResult.stderr);
495
501
  }
@@ -499,9 +505,9 @@ async function command$3(cliFlags, cwd) {
499
505
  let cloudEnvironmentsGroupedByBucketRegions;
500
506
  try {
501
507
  // This is the list of the supported cloud environments and their related bucket location.
502
- cloudEnvironmentsGroupedByBucketRegions = await buckedConfigExplorer.search();
508
+ cloudEnvironmentsGroupedByBucketRegions = await storageBucketConfigExplorer.search();
503
509
  } catch (e) {
504
- throw new Error('Failed loading a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
510
+ throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
505
511
  }
506
512
  if (!cloudEnvironmentsGroupedByBucketRegions) {
507
513
  throw new Error('Failed loading a storage bucket configuration');
@@ -517,7 +523,7 @@ async function command$3(cliFlags, cwd) {
517
523
  const paths = {
518
524
  publicAssetsPath: resolveInApplication('public', cwd),
519
525
  deploymentsPath: resolveInApplication('deployments', cwd),
520
- dotenvPath: cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
526
+ dotenvPath: cliFlags.dotenvFolder && path__default$1["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
521
527
  assetsPath
522
528
  };
523
529
  const defaultStorageProviders = ['gs'];
@@ -541,7 +547,7 @@ async function command$3(cliFlags, cwd) {
541
547
  cliFlags,
542
548
  storageProvider,
543
549
  uploadScriptsGenerator,
544
- bucketRegion,
550
+ bucketRegion: bucketRegion,
545
551
  paths
546
552
  })
547
553
  };
@@ -565,7 +571,7 @@ async function command$3(cliFlags, cwd) {
565
571
  storageProvider,
566
572
  uploadScriptsGenerator,
567
573
  paths,
568
- bucketRegion,
574
+ bucketRegion: bucketRegion,
569
575
  cloudEnvironment,
570
576
  bucketEnvironment
571
577
  });
@@ -671,21 +677,23 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
671
677
  const doesCloudEnvironmentExist = _ref => {
672
678
  let dotenvPath = _ref.dotenvPath,
673
679
  cloudEnvironment = _ref.cloudEnvironment;
674
- return fs__default["default"].existsSync(path__default["default"].join(dotenvPath ?? '', cloudEnvironment));
680
+ return fs__default$1["default"].existsSync(path__default["default"].join(dotenvPath ?? '', `.env.${cloudEnvironment}`));
675
681
  };
676
682
  async function command$2(cliFlags, cwd) {
677
683
  const applicationDirectory = getApplicationDirectory(cwd);
678
684
  const monorepoRoot = findRoot.findRootSync(cwd);
679
685
  const dotenvPath = cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
686
+
687
+ // The env itself is not important for the menu. However, the application config
688
+ // uses environment placeholders and therefore we need to provide the variables for it.
689
+ // TODO: Remove after all repositories migrated to NCR.
690
+ const cloudEnvironment = doesCloudEnvironmentExist({
691
+ dotenvPath,
692
+ cloudEnvironment: storageBucketsConfig.clusterContexts['ctp_staging_gcp_europe-west1_v1']
693
+ }) ? storageBucketsConfig.clusterContexts['ctp_staging_gcp_europe-west1_v1'] : 'ctp-gcp-staging';
680
694
  const processEnv = _objectSpread$1(_objectSpread$1({}, loadDotenvFiles({
681
695
  dotenvPath,
682
- // The env itself is not important for the menu. However, the application config
683
- // uses environment placeholders and therefore we need to provide the variables for it.
684
- // TODO: Remove after all repositories migrated to NCR.
685
- cloudEnvironment: doesCloudEnvironmentExist({
686
- dotenvPath,
687
- cloudEnvironment: '.env.ctp_staging_gcp_europe-west1_v1'
688
- }) ? 'ctp_staging_gcp_europe-west1_v1' : 'ctp-gcp-staging'
696
+ cloudEnvironment
689
697
  })), {}, {
690
698
  // Again, make sure that the environment is "development", otherwise
691
699
  // the menu config won't be available.
@@ -701,7 +709,7 @@ async function command$2(cliFlags, cwd) {
701
709
  });
702
710
  const applicationMenu = mapApplicationMenuConfigToGraqhQLMenuJson(applicationRuntimeConfig);
703
711
  const formattedJson = _JSON$stringify__default["default"](applicationMenu, null, 2);
704
- fs__default["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
712
+ fs__default$1["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
705
713
  encoding: 'utf8'
706
714
  });
707
715
  }
@@ -734,7 +742,7 @@ async function command$1(cliFlags) {
734
742
  // Logging to stdout which is from where it will be picked
735
743
  // up by the caller (a bash script).
736
744
  if (cliFlags.outFile) {
737
- fs__default["default"].writeFileSync(cliFlags.outFile, formattedJson, {
745
+ fs__default$1["default"].writeFileSync(cliFlags.outFile, formattedJson, {
738
746
  encoding: 'utf8'
739
747
  });
740
748
  } else {
@@ -855,14 +863,14 @@ async function command(cliFlags) {
855
863
  const menuJsonPath = cliFlags.inputFile;
856
864
  const isAppbarMenu = cliFlags.navigation === 'top';
857
865
  if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
858
- if (!fs__default["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
859
- const menuJson = fs__default["default"].readFileSync(menuJsonPath, 'utf-8');
866
+ if (!fs__default$1["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
867
+ const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
860
868
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
861
869
  }
862
870
 
863
871
  var pkgJson = {
864
872
  name: "@commercetools-frontend/application-cli",
865
- version: "2.0.0",
873
+ version: "2.1.0",
866
874
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
867
875
  keywords: [
868
876
  "commercetools",
@@ -885,8 +893,8 @@ var pkgJson = {
885
893
  },
886
894
  dependencies: {
887
895
  "@babel/core": "^7.22.11",
888
- "@babel/runtime": "^7.21.0",
889
896
  "@babel/runtime-corejs3": "^7.21.0",
897
+ "@babel/runtime": "^7.21.0",
890
898
  "@commercetools-frontend/application-config": "22.16.0",
891
899
  "@commercetools-frontend/constants": "22.16.0",
892
900
  "@commercetools-frontend/l10n": "22.16.0",
@@ -897,7 +905,8 @@ var pkgJson = {
897
905
  execa: "5.1.1",
898
906
  jsonschema: "^1.4.1",
899
907
  listr2: "8.0.1",
900
- "node-fetch": "2.7.0"
908
+ "node-fetch": "2.7.0",
909
+ "ts-deepmerge": "7.0.0"
901
910
  },
902
911
  devDependencies: {
903
912
  "@tsconfig/node20": "20.1.2",
@@ -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 buckedConfigExplorer = cosmiconfig('storage-buckets', {
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 buckedConfigExplorer.search();
479
+ cloudEnvironmentsGroupedByBucketRegions = await storageBucketConfigExplorer.search();
476
480
  } catch (e) {
477
- throw new Error('Failed loading a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
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
  });
@@ -644,21 +648,23 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
644
648
  const doesCloudEnvironmentExist = _ref => {
645
649
  let dotenvPath = _ref.dotenvPath,
646
650
  cloudEnvironment = _ref.cloudEnvironment;
647
- return fs.existsSync(path.join(dotenvPath ?? '', cloudEnvironment));
651
+ return fs$1.existsSync(path.join(dotenvPath ?? '', `.env.${cloudEnvironment}`));
648
652
  };
649
653
  async function command$2(cliFlags, cwd) {
650
654
  const applicationDirectory = getApplicationDirectory(cwd);
651
655
  const monorepoRoot = findRootSync(cwd);
652
656
  const dotenvPath = cliFlags.dotenvFolder && path.join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
657
+
658
+ // The env itself is not important for the menu. However, the application config
659
+ // uses environment placeholders and therefore we need to provide the variables for it.
660
+ // TODO: Remove after all repositories migrated to NCR.
661
+ const cloudEnvironment = doesCloudEnvironmentExist({
662
+ dotenvPath,
663
+ cloudEnvironment: clusterContexts['ctp_staging_gcp_europe-west1_v1']
664
+ }) ? clusterContexts['ctp_staging_gcp_europe-west1_v1'] : 'ctp-gcp-staging';
653
665
  const processEnv = _objectSpread$1(_objectSpread$1({}, loadDotenvFiles({
654
666
  dotenvPath,
655
- // The env itself is not important for the menu. However, the application config
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'
667
+ cloudEnvironment
662
668
  })), {}, {
663
669
  // Again, make sure that the environment is "development", otherwise
664
670
  // the menu config won't be available.
@@ -674,7 +680,7 @@ async function command$2(cliFlags, cwd) {
674
680
  });
675
681
  const applicationMenu = mapApplicationMenuConfigToGraqhQLMenuJson(applicationRuntimeConfig);
676
682
  const formattedJson = _JSON$stringify(applicationMenu, null, 2);
677
- fs.writeFileSync(path.join(applicationDirectory, 'menu.json'), formattedJson, {
683
+ fs$1.writeFileSync(path.join(applicationDirectory, 'menu.json'), formattedJson, {
678
684
  encoding: 'utf8'
679
685
  });
680
686
  }
@@ -707,7 +713,7 @@ async function command$1(cliFlags) {
707
713
  // Logging to stdout which is from where it will be picked
708
714
  // up by the caller (a bash script).
709
715
  if (cliFlags.outFile) {
710
- fs.writeFileSync(cliFlags.outFile, formattedJson, {
716
+ fs$1.writeFileSync(cliFlags.outFile, formattedJson, {
711
717
  encoding: 'utf8'
712
718
  });
713
719
  } else {
@@ -828,14 +834,14 @@ async function command(cliFlags) {
828
834
  const menuJsonPath = cliFlags.inputFile;
829
835
  const isAppbarMenu = cliFlags.navigation === 'top';
830
836
  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');
837
+ if (!fs$1.existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
838
+ const menuJson = fs$1.readFileSync(menuJsonPath, 'utf-8');
833
839
  return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
834
840
  }
835
841
 
836
842
  var pkgJson = {
837
843
  name: "@commercetools-frontend/application-cli",
838
- version: "2.0.0",
844
+ version: "2.1.0",
839
845
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
840
846
  keywords: [
841
847
  "commercetools",
@@ -858,8 +864,8 @@ var pkgJson = {
858
864
  },
859
865
  dependencies: {
860
866
  "@babel/core": "^7.22.11",
861
- "@babel/runtime": "^7.21.0",
862
867
  "@babel/runtime-corejs3": "^7.21.0",
868
+ "@babel/runtime": "^7.21.0",
863
869
  "@commercetools-frontend/application-config": "22.16.0",
864
870
  "@commercetools-frontend/constants": "22.16.0",
865
871
  "@commercetools-frontend/l10n": "22.16.0",
@@ -870,7 +876,8 @@ var pkgJson = {
870
876
  execa: "5.1.1",
871
877
  jsonschema: "^1.4.1",
872
878
  listr2: "8.0.1",
873
- "node-fetch": "2.7.0"
879
+ "node-fetch": "2.7.0",
880
+ "ts-deepmerge": "7.0.0"
874
881
  },
875
882
  devDependencies: {
876
883
  "@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
+ };
@@ -1 +1,3 @@
1
1
  export type { TStorageBucketsConfig } from "./types.js";
2
+ export { defineStorageBucketsConfig } from "./storage-buckets-config.js";
3
+ export * from "./constants.js";
@@ -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: string;
6
+ bucketRegion: TBucketRegion;
3
7
  prNumber?: string;
4
8
  applicationName: string;
5
9
  };
6
10
  export type TApplicationIndexBucketConfig = {
7
- bucketRegion: string;
11
+ bucketRegion: TBucketRegion;
8
12
  prNumber?: string;
9
13
  applicationName: string;
10
- bucketEnvironment: string;
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: string;
42
- cloudEnvironment: string;
43
- bucketEnvironment: string;
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: string;
54
+ bucketRegion: TBucketRegion;
51
55
  };
52
- type TBucketRegion = string;
53
56
  export type TBucketEnvironmentConfig = {
54
- cloudEnvironment: string;
55
- bucketEnvironment: string;
56
- storageProviders: TStorageProviderTag[];
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: string;
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: string;
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;
@@ -0,0 +1,101 @@
1
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
2
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
3
+ import { merge } from 'ts-deepmerge';
4
+
5
+ const clusterContexts = {
6
+ 'ctp_staging_gcp_europe-west1_v1': 'ctp_staging_gcp_europe-west1_v1',
7
+ 'vw_staging_aws_eu-central-1_v1': 'vw_staging_aws_eu-central-1_v1',
8
+ 'ctp_staging_aws_cn-northwest-1_v1': 'ctp_staging_aws_cn-northwest-1_v1',
9
+ 'ctp_testing_performance_gcp_europe-west1_v1': 'ctp_testing_performance_gcp_europe-west1_v1',
10
+ 'ctp_production_aws_eu-central-1_v1': 'ctp_production_aws_eu-central-1_v1',
11
+ 'ctp_production_gcp_europe-west1_v1': 'ctp_production_gcp_europe-west1_v1',
12
+ 'vw_production_aws_eu-central-1_v1': 'vw_production_aws_eu-central-1_v1',
13
+ 'att_production_aws_us-east-1_v1': 'att_production_aws_us-east-1_v1',
14
+ 'ctp_production_aws_us-east-2_v1': 'ctp_production_aws_us-east-2_v1',
15
+ 'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
16
+ 'ctp_production_gcp_australia-southeast1_v1': 'ctp_production_gcp_australia-southeast1_v1',
17
+ 'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1'
18
+ };
19
+ const bucketEnvironments = {
20
+ 'ctp-gcp-staging': 'ctp-gcp-staging',
21
+ 'ctp-vw-staging-eu': 'ctp-vw-staging-eu',
22
+ 'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
23
+ 'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
24
+ 'ctp-aws-production-fra': 'ctp-aws-production-fra',
25
+ 'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
26
+ 'ctp-vw-production-eu': 'ctp-vw-production-eu',
27
+ 'ctp-att-production-va': 'ctp-att-production-va',
28
+ 'ctp-aws-production-ohio': 'ctp-aws-production-ohio',
29
+ 'ctp-gcp-production-us': 'ctp-gcp-production-us',
30
+ 'ctp-gcp-production-au': 'ctp-gcp-production-au',
31
+ 'ctp-aws-production-cn': 'ctp-aws-production-cn'
32
+ };
33
+ const bucketRegions = {
34
+ previews: 'merchant-center-previews',
35
+ europe: 'merchant-center-europe',
36
+ northAmerica: 'merchant-center-north-america',
37
+ asia: 'merchant-center-asia'
38
+ };
39
+
40
+ const defaultConfig = {
41
+ [bucketRegions.previews]: [{
42
+ cloudEnvironment: clusterContexts['ctp_staging_gcp_europe-west1_v1'],
43
+ bucketEnvironment: bucketEnvironments['ctp-gcp-staging']
44
+ }, {
45
+ cloudEnvironment: clusterContexts['vw_staging_aws_eu-central-1_v1'],
46
+ bucketEnvironment: bucketEnvironments['ctp-vw-staging-eu']
47
+ }, {
48
+ cloudEnvironment: clusterContexts['ctp_staging_aws_cn-northwest-1_v1'],
49
+ bucketEnvironment: bucketEnvironments['ctp-aws-staging-cn']
50
+ }, {
51
+ cloudEnvironment: clusterContexts['ctp_testing_performance_gcp_europe-west1_v1'],
52
+ bucketEnvironment: bucketEnvironments['ctp-gcp-testing-performance-eu']
53
+ }],
54
+ [bucketRegions.europe]: [{
55
+ cloudEnvironment: clusterContexts['ctp_production_aws_eu-central-1_v1'],
56
+ bucketEnvironment: bucketEnvironments['ctp-aws-production-fra']
57
+ }, {
58
+ cloudEnvironment: clusterContexts['ctp_production_gcp_europe-west1_v1'],
59
+ bucketEnvironment: bucketEnvironments['ctp-gcp-production-eu']
60
+ }, {
61
+ cloudEnvironment: clusterContexts['vw_production_aws_eu-central-1_v1'],
62
+ bucketEnvironment: bucketEnvironments['ctp-vw-production-eu']
63
+ }],
64
+ [bucketRegions.northAmerica]: [{
65
+ cloudEnvironment: clusterContexts['att_production_aws_us-east-1_v1'],
66
+ bucketEnvironment: bucketEnvironments['ctp-att-production-va']
67
+ }, {
68
+ cloudEnvironment: clusterContexts['ctp_production_aws_us-east-2_v1'],
69
+ bucketEnvironment: bucketEnvironments['ctp-aws-production-ohio']
70
+ }, {
71
+ cloudEnvironment: clusterContexts['ctp_production_gcp_us-central1_v1'],
72
+ bucketEnvironment: bucketEnvironments['ctp-gcp-production-us']
73
+ }],
74
+ [bucketRegions.asia]: [{
75
+ cloudEnvironment: clusterContexts['ctp_production_gcp_australia-southeast1_v1'],
76
+ bucketEnvironment: bucketEnvironments['ctp-gcp-production-au']
77
+ }, {
78
+ cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
79
+ bucketEnvironment: bucketEnvironments['ctp-aws-production-cn']
80
+ }]
81
+ };
82
+ function defineStorageBucketsConfig() {
83
+ let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
84
+ regions = _ref.regions,
85
+ options = _ref.options;
86
+ const actualConfig = regions ? merge(defaultConfig, regions) : defaultConfig;
87
+ const disabledBucketRegions = options?.disabledBucketRegions ?? [];
88
+ const disabledEnvironments = options?.disabledEnvironments ?? [];
89
+ _forEachInstanceProperty(disabledBucketRegions).call(disabledBucketRegions, disabledBucketRegion => {
90
+ delete actualConfig[disabledBucketRegion];
91
+ });
92
+ const allBucketRegions = _Object$keys(actualConfig);
93
+ _forEachInstanceProperty(disabledEnvironments).call(disabledEnvironments, disabledEnvrionment => {
94
+ _forEachInstanceProperty(allBucketRegions).call(allBucketRegions, bucketRegionToBeRemoved => {
95
+ actualConfig[bucketRegionToBeRemoved] = actualConfig[bucketRegionToBeRemoved]?.filter(bucketEnvironmentConfig => bucketEnvironmentConfig.cloudEnvironment !== disabledEnvrionment);
96
+ });
97
+ });
98
+ return actualConfig;
99
+ }
100
+
101
+ export { bucketRegions as a, bucketEnvironments as b, clusterContexts as c, defineStorageBucketsConfig as d };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-cli",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Internal CLI to manage Merchant Center application deployments across various environments.",
5
5
  "keywords": [
6
6
  "commercetools",
@@ -20,8 +20,8 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "@babel/core": "^7.22.11",
23
- "@babel/runtime": "^7.21.0",
24
23
  "@babel/runtime-corejs3": "^7.21.0",
24
+ "@babel/runtime": "^7.21.0",
25
25
  "@commercetools-frontend/application-config": "22.16.0",
26
26
  "@commercetools-frontend/constants": "22.16.0",
27
27
  "@commercetools-frontend/l10n": "22.16.0",
@@ -32,7 +32,8 @@
32
32
  "execa": "5.1.1",
33
33
  "jsonschema": "^1.4.1",
34
34
  "listr2": "8.0.1",
35
- "node-fetch": "2.7.0"
35
+ "node-fetch": "2.7.0",
36
+ "ts-deepmerge": "7.0.0"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@tsconfig/node20": "20.1.2",