@commercetools-frontend/application-cli 2.1.2 → 2.3.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.
@@ -2,14 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var storageBucketsConfig = require('./storage-buckets-config-478b8585.cjs.dev.js');
5
+ var storageBucketsConfig = require('./storage-buckets-config-28a1d76e.cjs.dev.js');
6
6
  require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
7
7
  require('@babel/runtime-corejs3/core-js-stable/object/keys');
8
+ require('cosmiconfig');
8
9
  require('ts-deepmerge');
9
10
 
10
11
 
11
12
 
12
13
  exports.bucketEnvironments = storageBucketsConfig.bucketEnvironments;
13
14
  exports.bucketRegions = storageBucketsConfig.bucketRegions;
15
+ exports.bucketUrls = storageBucketsConfig.bucketUrls;
14
16
  exports.clusterContexts = storageBucketsConfig.clusterContexts;
15
17
  exports.defineStorageBucketsConfig = storageBucketsConfig.defineStorageBucketsConfig;
18
+ exports.publicStorageUrls = storageBucketsConfig.publicStorageUrls;
19
+ exports.storageProviders = storageBucketsConfig.storageProviders;
@@ -2,14 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var storageBucketsConfig = require('./storage-buckets-config-0b3808a3.cjs.prod.js');
5
+ var storageBucketsConfig = require('./storage-buckets-config-e3ea6d6f.cjs.prod.js');
6
6
  require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
7
7
  require('@babel/runtime-corejs3/core-js-stable/object/keys');
8
+ require('cosmiconfig');
8
9
  require('ts-deepmerge');
9
10
 
10
11
 
11
12
 
12
13
  exports.bucketEnvironments = storageBucketsConfig.bucketEnvironments;
13
14
  exports.bucketRegions = storageBucketsConfig.bucketRegions;
15
+ exports.bucketUrls = storageBucketsConfig.bucketUrls;
14
16
  exports.clusterContexts = storageBucketsConfig.clusterContexts;
15
17
  exports.defineStorageBucketsConfig = storageBucketsConfig.defineStorageBucketsConfig;
18
+ exports.publicStorageUrls = storageBucketsConfig.publicStorageUrls;
19
+ exports.storageProviders = storageBucketsConfig.storageProviders;
@@ -1,4 +1,5 @@
1
- export { b as bucketEnvironments, a as bucketRegions, c as clusterContexts, d as defineStorageBucketsConfig } from './storage-buckets-config-7845a091.esm.js';
1
+ export { b as bucketEnvironments, a as bucketRegions, e as bucketUrls, c as clusterContexts, d as defineStorageBucketsConfig, p as publicStorageUrls, s as storageProviders } from './storage-buckets-config-705b6341.esm.js';
2
2
  import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
3
3
  import '@babel/runtime-corejs3/core-js-stable/object/keys';
4
+ import 'cosmiconfig';
4
5
  import 'ts-deepmerge';
@@ -1,3 +1,4 @@
1
+ import type { TStorageProviderTag, TStorageProvider } from "./types.js";
1
2
  export declare const clusterContexts: {
2
3
  readonly 'ctp_staging_gcp_europe-west1_v1': "ctp_staging_gcp_europe-west1_v1";
3
4
  readonly 'vw_staging_aws_eu-central-1_v1': "vw_staging_aws_eu-central-1_v1";
@@ -11,12 +12,14 @@ export declare const clusterContexts: {
11
12
  readonly 'ctp_production_gcp_us-central1_v1': "ctp_production_gcp_us-central1_v1";
12
13
  readonly 'ctp_production_gcp_australia-southeast1_v1': "ctp_production_gcp_australia-southeast1_v1";
13
14
  readonly 'ctp_production_aws_cn-northwest-1_v1': "ctp_production_aws_cn-northwest-1_v1";
15
+ readonly ctp_staging_azure_northeurope_v1: "ctp_staging_azure_northeurope_v1";
14
16
  };
15
17
  export declare const bucketEnvironments: {
16
18
  readonly 'ctp-gcp-staging': "ctp-gcp-staging";
17
19
  readonly 'ctp-vw-staging-eu': "ctp-vw-staging-eu";
18
20
  readonly 'ctp-aws-staging-cn': "ctp-aws-staging-cn";
19
21
  readonly 'ctp-gcp-testing-performance-eu': "ctp-gcp-testing-performance-eu";
22
+ readonly 'ctp-azure-staging': "ctp-azure-staging";
20
23
  readonly 'ctp-aws-production-fra': "ctp-aws-production-fra";
21
24
  readonly 'ctp-gcp-production-eu': "ctp-gcp-production-eu";
22
25
  readonly 'ctp-vw-production-eu': "ctp-vw-production-eu";
@@ -31,4 +34,14 @@ export declare const bucketRegions: {
31
34
  readonly europe: "merchant-center-europe";
32
35
  readonly northAmerica: "merchant-center-north-america";
33
36
  readonly asia: "merchant-center-asia";
37
+ readonly china: "merchant-center-china";
34
38
  };
39
+ export declare const publicStorageUrls: {
40
+ readonly google: "https://storage.googleapis.com";
41
+ readonly aws: "https://s3.amazonaws.com";
42
+ readonly china: "https://mc-storage.cn-northwest-1.aws.commercetools.cn";
43
+ };
44
+ export declare const bucketUrls: {
45
+ readonly china: "commercetools-mc-storage-aws-cn-prod-merchant-center";
46
+ };
47
+ export declare const storageProviders: Record<TStorageProviderTag, TStorageProvider>;
@@ -1,4 +1,4 @@
1
- import { TBucketRegion, TCloudEnvironment, type TStorageBucketsConfig } from "./types.js";
1
+ import type { TBucketRegion, TCloudEnvironment, TStorageBucketsConfig } from "./types.js";
2
2
  type TConfigOptions = {
3
3
  disabledBucketRegions?: TBucketRegion[];
4
4
  disabledEnvironments?: TCloudEnvironment[];
@@ -8,4 +8,5 @@ type TDefineConfigArgs = {
8
8
  options?: TConfigOptions;
9
9
  };
10
10
  declare function defineStorageBucketsConfig({ regions, options, }?: TDefineConfigArgs): TStorageBucketsConfig;
11
- export { defineStorageBucketsConfig };
11
+ declare function loadStorageBucketsConfig(): Promise<TStorageBucketsConfig>;
12
+ export { defineStorageBucketsConfig, loadStorageBucketsConfig };
@@ -3,16 +3,10 @@ export type TCloudEnvironment = (typeof clusterContexts)[keyof typeof clusterCon
3
3
  export type TBucketEnvironment = (typeof bucketEnvironments)[keyof typeof bucketEnvironments];
4
4
  export type TBucketRegion = (typeof bucketRegions)[keyof typeof bucketRegions];
5
5
  export type TApplicationAssetsBucketConfig = {
6
- bucketRegion: TBucketRegion;
7
6
  prNumber?: string;
8
7
  applicationName: string;
9
8
  };
10
- export type TApplicationIndexBucketConfig = {
11
- bucketRegion: TBucketRegion;
12
- prNumber?: string;
13
- applicationName: string;
14
- bucketEnvironment: TBucketEnvironment;
15
- };
9
+ export type TApplicationIndexBucketConfig = TApplicationAssetsBucketConfig;
16
10
  export type TUploadScriptFile = {
17
11
  fileName: string;
18
12
  fileContent: string;
@@ -25,14 +19,33 @@ type TPaths = {
25
19
  assetsPath: string;
26
20
  };
27
21
  export type TStorageProviderTag = 'gs' | 's3';
22
+ export type TStorageProvider = {
23
+ tag: TStorageProviderTag;
24
+ urls: {
25
+ public: {
26
+ default: string;
27
+ } & Partial<Record<TBucketEnvironment, string>>;
28
+ bucket?: Partial<Record<TBucketRegion, string>>;
29
+ };
30
+ };
31
+ export type TStorageProviderConfig = {
32
+ bucketRegion?: TBucketRegion;
33
+ bucketEnvironment?: TBucketEnvironment;
34
+ };
28
35
  export interface IStorageProvider {
29
36
  getTag(): TStorageProviderTag;
37
+ getBucketRegion(): TBucketRegion | undefined;
38
+ getBucketEnvironment(): TBucketEnvironment | undefined;
30
39
  getProtocol(): string;
31
40
  getPublicBaseUrl(): string;
32
41
  getCdnUrl(config: TApplicationAssetsBucketConfig): string;
33
42
  getAssetsBucketUrl(config: TApplicationAssetsBucketConfig): string;
34
43
  getApplicationIndexBucketUrl(config: TApplicationIndexBucketConfig): string;
35
44
  }
45
+ export type TUploadScriptsGeneratorConfig = {
46
+ bucketRegion: TBucketRegion;
47
+ bucketEnvironment?: TBucketEnvironment;
48
+ };
36
49
  export interface IUploadScriptsGenerator {
37
50
  getProductionBundlesUploadScript(config: TCreateApplicationAssetsUploadScript): string;
38
51
  getApplicationIndexUploadScript(config: TCreateApplicationIndexUploadScript): string;
@@ -42,16 +55,13 @@ export type TCompileEnvApplicationIndexes = {
42
55
  storageProvider: IStorageProvider;
43
56
  uploadScriptsGenerator: IUploadScriptsGenerator;
44
57
  paths: TPaths;
45
- bucketRegion: TBucketRegion;
46
58
  cloudEnvironment: TCloudEnvironment;
47
- bucketEnvironment: TBucketEnvironment;
48
59
  };
49
60
  export type TCompileApplicationAssets = {
50
61
  cliFlags: TCompileDeploymentsFlags;
51
62
  storageProvider: IStorageProvider;
52
63
  uploadScriptsGenerator: IUploadScriptsGenerator;
53
64
  paths: TPaths;
54
- bucketRegion: TBucketRegion;
55
65
  };
56
66
  export type TBucketEnvironmentConfig = {
57
67
  cloudEnvironment: TCloudEnvironment;
@@ -67,7 +77,6 @@ export type TCreateApplicationIndexUploadScript = {
67
77
  storageProvider: IStorageProvider;
68
78
  bucketUrl: string;
69
79
  cdnUrl: string;
70
- bucketEnvironment: TBucketEnvironment;
71
80
  buildRevision: string;
72
81
  buildNumber: number;
73
82
  applicationIndexOutFile: string;
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
4
4
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
5
+ var cosmiconfig = require('cosmiconfig');
5
6
  var tsDeepmerge = require('ts-deepmerge');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -21,13 +22,15 @@ const clusterContexts = {
21
22
  'ctp_production_aws_us-east-2_v1': 'ctp_production_aws_us-east-2_v1',
22
23
  'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
23
24
  '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
+ 'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1',
26
+ ctp_staging_azure_northeurope_v1: 'ctp_staging_azure_northeurope_v1'
25
27
  };
26
28
  const bucketEnvironments = {
27
29
  'ctp-gcp-staging': 'ctp-gcp-staging',
28
30
  'ctp-vw-staging-eu': 'ctp-vw-staging-eu',
29
31
  'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
30
32
  'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
33
+ 'ctp-azure-staging': 'ctp-azure-staging',
31
34
  'ctp-aws-production-fra': 'ctp-aws-production-fra',
32
35
  'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
33
36
  'ctp-vw-production-eu': 'ctp-vw-production-eu',
@@ -41,7 +44,39 @@ const bucketRegions = {
41
44
  previews: 'merchant-center-previews',
42
45
  europe: 'merchant-center-europe',
43
46
  northAmerica: 'merchant-center-north-america',
44
- asia: 'merchant-center-asia'
47
+ asia: 'merchant-center-asia',
48
+ china: 'merchant-center-china'
49
+ };
50
+ const publicStorageUrls = {
51
+ google: 'https://storage.googleapis.com',
52
+ aws: 'https://s3.amazonaws.com',
53
+ china: 'https://mc-storage.cn-northwest-1.aws.commercetools.cn'
54
+ };
55
+ const bucketUrls = {
56
+ china: 'commercetools-mc-storage-aws-cn-prod-merchant-center'
57
+ };
58
+ const storageProviders = {
59
+ gs: {
60
+ tag: 'gs',
61
+ urls: {
62
+ public: {
63
+ default: publicStorageUrls.google
64
+ }
65
+ }
66
+ },
67
+ s3: {
68
+ tag: 's3',
69
+ urls: {
70
+ public: {
71
+ default: publicStorageUrls.aws,
72
+ 'ctp-aws-staging-cn': publicStorageUrls.china,
73
+ 'ctp-aws-production-cn': publicStorageUrls.china
74
+ },
75
+ bucket: {
76
+ 'merchant-center-china': bucketUrls.china
77
+ }
78
+ }
79
+ }
45
80
  };
46
81
 
47
82
  const defaultConfig = {
@@ -57,6 +92,9 @@ const defaultConfig = {
57
92
  }, {
58
93
  cloudEnvironment: clusterContexts['ctp_testing_performance_gcp_europe-west1_v1'],
59
94
  bucketEnvironment: bucketEnvironments['ctp-gcp-testing-performance-eu']
95
+ }, {
96
+ cloudEnvironment: clusterContexts['ctp_staging_azure_northeurope_v1'],
97
+ bucketEnvironment: bucketEnvironments['ctp-azure-staging']
60
98
  }],
61
99
  [bucketRegions.europe]: [{
62
100
  cloudEnvironment: clusterContexts['ctp_production_aws_eu-central-1_v1'],
@@ -84,6 +122,15 @@ const defaultConfig = {
84
122
  }, {
85
123
  cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
86
124
  bucketEnvironment: bucketEnvironments['ctp-aws-production-cn']
125
+ }],
126
+ [bucketRegions.china]: [{
127
+ cloudEnvironment: clusterContexts['ctp_staging_aws_cn-northwest-1_v1'],
128
+ bucketEnvironment: bucketEnvironments['ctp-aws-staging-cn'],
129
+ storageProviders: ['s3']
130
+ }, {
131
+ cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
132
+ bucketEnvironment: bucketEnvironments['ctp-aws-production-cn'],
133
+ storageProviders: ['s3']
87
134
  }]
88
135
  };
89
136
  function defineStorageBucketsConfig() {
@@ -104,8 +151,28 @@ function defineStorageBucketsConfig() {
104
151
  });
105
152
  return actualConfig;
106
153
  }
154
+ async function loadStorageBucketsConfig() {
155
+ let explorerResult;
156
+ const storageBucketConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
157
+ searchStrategy: 'project'
158
+ });
159
+ try {
160
+ // This is the list of the supported cloud environments and their related bucket location.
161
+ explorerResult = await storageBucketConfigExplorer.search();
162
+ } catch (e) {
163
+ throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
164
+ }
165
+ if (!explorerResult) {
166
+ throw new Error('Failed loading a storage bucket configuration');
167
+ }
168
+ return explorerResult?.config;
169
+ }
107
170
 
108
171
  exports.bucketEnvironments = bucketEnvironments;
109
172
  exports.bucketRegions = bucketRegions;
173
+ exports.bucketUrls = bucketUrls;
110
174
  exports.clusterContexts = clusterContexts;
111
175
  exports.defineStorageBucketsConfig = defineStorageBucketsConfig;
176
+ exports.loadStorageBucketsConfig = loadStorageBucketsConfig;
177
+ exports.publicStorageUrls = publicStorageUrls;
178
+ exports.storageProviders = storageProviders;
@@ -1,5 +1,6 @@
1
1
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
2
2
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
3
+ import { cosmiconfig } from 'cosmiconfig';
3
4
  import { merge } from 'ts-deepmerge';
4
5
 
5
6
  const clusterContexts = {
@@ -14,13 +15,15 @@ const clusterContexts = {
14
15
  'ctp_production_aws_us-east-2_v1': 'ctp_production_aws_us-east-2_v1',
15
16
  'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
16
17
  '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
+ 'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1',
19
+ ctp_staging_azure_northeurope_v1: 'ctp_staging_azure_northeurope_v1'
18
20
  };
19
21
  const bucketEnvironments = {
20
22
  'ctp-gcp-staging': 'ctp-gcp-staging',
21
23
  'ctp-vw-staging-eu': 'ctp-vw-staging-eu',
22
24
  'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
23
25
  'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
26
+ 'ctp-azure-staging': 'ctp-azure-staging',
24
27
  'ctp-aws-production-fra': 'ctp-aws-production-fra',
25
28
  'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
26
29
  'ctp-vw-production-eu': 'ctp-vw-production-eu',
@@ -34,7 +37,39 @@ const bucketRegions = {
34
37
  previews: 'merchant-center-previews',
35
38
  europe: 'merchant-center-europe',
36
39
  northAmerica: 'merchant-center-north-america',
37
- asia: 'merchant-center-asia'
40
+ asia: 'merchant-center-asia',
41
+ china: 'merchant-center-china'
42
+ };
43
+ const publicStorageUrls = {
44
+ google: 'https://storage.googleapis.com',
45
+ aws: 'https://s3.amazonaws.com',
46
+ china: 'https://mc-storage.cn-northwest-1.aws.commercetools.cn'
47
+ };
48
+ const bucketUrls = {
49
+ china: 'commercetools-mc-storage-aws-cn-prod-merchant-center'
50
+ };
51
+ const storageProviders = {
52
+ gs: {
53
+ tag: 'gs',
54
+ urls: {
55
+ public: {
56
+ default: publicStorageUrls.google
57
+ }
58
+ }
59
+ },
60
+ s3: {
61
+ tag: 's3',
62
+ urls: {
63
+ public: {
64
+ default: publicStorageUrls.aws,
65
+ 'ctp-aws-staging-cn': publicStorageUrls.china,
66
+ 'ctp-aws-production-cn': publicStorageUrls.china
67
+ },
68
+ bucket: {
69
+ 'merchant-center-china': bucketUrls.china
70
+ }
71
+ }
72
+ }
38
73
  };
39
74
 
40
75
  const defaultConfig = {
@@ -50,6 +85,9 @@ const defaultConfig = {
50
85
  }, {
51
86
  cloudEnvironment: clusterContexts['ctp_testing_performance_gcp_europe-west1_v1'],
52
87
  bucketEnvironment: bucketEnvironments['ctp-gcp-testing-performance-eu']
88
+ }, {
89
+ cloudEnvironment: clusterContexts['ctp_staging_azure_northeurope_v1'],
90
+ bucketEnvironment: bucketEnvironments['ctp-azure-staging']
53
91
  }],
54
92
  [bucketRegions.europe]: [{
55
93
  cloudEnvironment: clusterContexts['ctp_production_aws_eu-central-1_v1'],
@@ -77,6 +115,15 @@ const defaultConfig = {
77
115
  }, {
78
116
  cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
79
117
  bucketEnvironment: bucketEnvironments['ctp-aws-production-cn']
118
+ }],
119
+ [bucketRegions.china]: [{
120
+ cloudEnvironment: clusterContexts['ctp_staging_aws_cn-northwest-1_v1'],
121
+ bucketEnvironment: bucketEnvironments['ctp-aws-staging-cn'],
122
+ storageProviders: ['s3']
123
+ }, {
124
+ cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
125
+ bucketEnvironment: bucketEnvironments['ctp-aws-production-cn'],
126
+ storageProviders: ['s3']
80
127
  }]
81
128
  };
82
129
  function defineStorageBucketsConfig() {
@@ -97,5 +144,21 @@ function defineStorageBucketsConfig() {
97
144
  });
98
145
  return actualConfig;
99
146
  }
147
+ async function loadStorageBucketsConfig() {
148
+ let explorerResult;
149
+ const storageBucketConfigExplorer = cosmiconfig('storage-buckets', {
150
+ searchStrategy: 'project'
151
+ });
152
+ try {
153
+ // This is the list of the supported cloud environments and their related bucket location.
154
+ explorerResult = await storageBucketConfigExplorer.search();
155
+ } catch (e) {
156
+ throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
157
+ }
158
+ if (!explorerResult) {
159
+ throw new Error('Failed loading a storage bucket configuration');
160
+ }
161
+ return explorerResult?.config;
162
+ }
100
163
 
101
- export { bucketRegions as a, bucketEnvironments as b, clusterContexts as c, defineStorageBucketsConfig as d };
164
+ export { bucketRegions as a, bucketEnvironments as b, clusterContexts as c, defineStorageBucketsConfig as d, bucketUrls as e, loadStorageBucketsConfig as l, publicStorageUrls as p, storageProviders as s };
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
4
4
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
5
+ var cosmiconfig = require('cosmiconfig');
5
6
  var tsDeepmerge = require('ts-deepmerge');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -21,13 +22,15 @@ const clusterContexts = {
21
22
  'ctp_production_aws_us-east-2_v1': 'ctp_production_aws_us-east-2_v1',
22
23
  'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
23
24
  '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
+ 'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1',
26
+ ctp_staging_azure_northeurope_v1: 'ctp_staging_azure_northeurope_v1'
25
27
  };
26
28
  const bucketEnvironments = {
27
29
  'ctp-gcp-staging': 'ctp-gcp-staging',
28
30
  'ctp-vw-staging-eu': 'ctp-vw-staging-eu',
29
31
  'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
30
32
  'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
33
+ 'ctp-azure-staging': 'ctp-azure-staging',
31
34
  'ctp-aws-production-fra': 'ctp-aws-production-fra',
32
35
  'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
33
36
  'ctp-vw-production-eu': 'ctp-vw-production-eu',
@@ -41,7 +44,39 @@ const bucketRegions = {
41
44
  previews: 'merchant-center-previews',
42
45
  europe: 'merchant-center-europe',
43
46
  northAmerica: 'merchant-center-north-america',
44
- asia: 'merchant-center-asia'
47
+ asia: 'merchant-center-asia',
48
+ china: 'merchant-center-china'
49
+ };
50
+ const publicStorageUrls = {
51
+ google: 'https://storage.googleapis.com',
52
+ aws: 'https://s3.amazonaws.com',
53
+ china: 'https://mc-storage.cn-northwest-1.aws.commercetools.cn'
54
+ };
55
+ const bucketUrls = {
56
+ china: 'commercetools-mc-storage-aws-cn-prod-merchant-center'
57
+ };
58
+ const storageProviders = {
59
+ gs: {
60
+ tag: 'gs',
61
+ urls: {
62
+ public: {
63
+ default: publicStorageUrls.google
64
+ }
65
+ }
66
+ },
67
+ s3: {
68
+ tag: 's3',
69
+ urls: {
70
+ public: {
71
+ default: publicStorageUrls.aws,
72
+ 'ctp-aws-staging-cn': publicStorageUrls.china,
73
+ 'ctp-aws-production-cn': publicStorageUrls.china
74
+ },
75
+ bucket: {
76
+ 'merchant-center-china': bucketUrls.china
77
+ }
78
+ }
79
+ }
45
80
  };
46
81
 
47
82
  const defaultConfig = {
@@ -57,6 +92,9 @@ const defaultConfig = {
57
92
  }, {
58
93
  cloudEnvironment: clusterContexts['ctp_testing_performance_gcp_europe-west1_v1'],
59
94
  bucketEnvironment: bucketEnvironments['ctp-gcp-testing-performance-eu']
95
+ }, {
96
+ cloudEnvironment: clusterContexts['ctp_staging_azure_northeurope_v1'],
97
+ bucketEnvironment: bucketEnvironments['ctp-azure-staging']
60
98
  }],
61
99
  [bucketRegions.europe]: [{
62
100
  cloudEnvironment: clusterContexts['ctp_production_aws_eu-central-1_v1'],
@@ -84,6 +122,15 @@ const defaultConfig = {
84
122
  }, {
85
123
  cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
86
124
  bucketEnvironment: bucketEnvironments['ctp-aws-production-cn']
125
+ }],
126
+ [bucketRegions.china]: [{
127
+ cloudEnvironment: clusterContexts['ctp_staging_aws_cn-northwest-1_v1'],
128
+ bucketEnvironment: bucketEnvironments['ctp-aws-staging-cn'],
129
+ storageProviders: ['s3']
130
+ }, {
131
+ cloudEnvironment: clusterContexts['ctp_production_aws_cn-northwest-1_v1'],
132
+ bucketEnvironment: bucketEnvironments['ctp-aws-production-cn'],
133
+ storageProviders: ['s3']
87
134
  }]
88
135
  };
89
136
  function defineStorageBucketsConfig() {
@@ -104,8 +151,28 @@ function defineStorageBucketsConfig() {
104
151
  });
105
152
  return actualConfig;
106
153
  }
154
+ async function loadStorageBucketsConfig() {
155
+ let explorerResult;
156
+ const storageBucketConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
157
+ searchStrategy: 'project'
158
+ });
159
+ try {
160
+ // This is the list of the supported cloud environments and their related bucket location.
161
+ explorerResult = await storageBucketConfigExplorer.search();
162
+ } catch (e) {
163
+ throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
164
+ }
165
+ if (!explorerResult) {
166
+ throw new Error('Failed loading a storage bucket configuration');
167
+ }
168
+ return explorerResult?.config;
169
+ }
107
170
 
108
171
  exports.bucketEnvironments = bucketEnvironments;
109
172
  exports.bucketRegions = bucketRegions;
173
+ exports.bucketUrls = bucketUrls;
110
174
  exports.clusterContexts = clusterContexts;
111
175
  exports.defineStorageBucketsConfig = defineStorageBucketsConfig;
176
+ exports.loadStorageBucketsConfig = loadStorageBucketsConfig;
177
+ exports.publicStorageUrls = publicStorageUrls;
178
+ exports.storageProviders = storageProviders;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-cli",
3
- "version": "2.1.2",
3
+ "version": "2.3.0",
4
4
  "description": "Internal CLI to manage Merchant Center application deployments across various environments.",
5
5
  "keywords": [
6
6
  "commercetools",
@@ -20,15 +20,15 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "@babel/core": "^7.22.11",
23
- "@babel/runtime-corejs3": "^7.21.0",
24
23
  "@babel/runtime": "^7.21.0",
25
- "@commercetools-frontend/application-config": "22.17.1",
26
- "@commercetools-frontend/constants": "22.17.1",
27
- "@commercetools-frontend/l10n": "22.17.1",
24
+ "@babel/runtime-corejs3": "^7.21.0",
25
+ "@commercetools-frontend/application-config": "22.22.0",
26
+ "@commercetools-frontend/constants": "22.22.0",
27
+ "@commercetools-frontend/l10n": "22.22.0",
28
28
  "@manypkg/find-root": "2.2.1",
29
29
  "cac": "^6.7.14",
30
30
  "cosmiconfig": "9.0.0",
31
- "dotenv": "16.4.1",
31
+ "dotenv": "16.4.2",
32
32
  "execa": "5.1.1",
33
33
  "jsonschema": "^1.4.1",
34
34
  "listr2": "8.0.2",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@tsconfig/node20": "20.1.2",
40
- "@types/node": "20.11.5",
40
+ "@types/node": "20.11.30",
41
41
  "typescript": "5.2.2"
42
42
  },
43
43
  "engines": {