@contentstack/cli-cm-bootstrap 2.0.0-beta.5 → 2.0.0-beta.7

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
@@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
15
15
  $ csdx COMMAND
16
16
  running command...
17
17
  $ csdx (--version)
18
- @contentstack/cli-cm-bootstrap/2.0.0-beta.5 linux-x64 node-v22.22.0
18
+ @contentstack/cli-cm-bootstrap/2.0.0-beta.7 linux-x64 node-v22.22.0
19
19
  $ csdx --help [COMMAND]
20
20
  USAGE
21
21
  $ csdx COMMAND
@@ -6,6 +6,7 @@ const path = require("path");
6
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
7
7
  const interactive_1 = require("../bootstrap/interactive");
8
8
  const messages_1 = require("../messages");
9
+ const region_handler_1 = require("@contentstack/cli-config/lib/utils/region-handler");
9
10
  /**
10
11
  * @description Setup the environment for a given app for each environment
11
12
  * Loads the environments for a given stack
@@ -158,25 +159,45 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
158
159
  const cdnHost = (_d = region === null || region === void 0 ? void 0 : region.cda) === null || _d === void 0 ? void 0 : _d.substring('8');
159
160
  const appHost = (_e = region === null || region === void 0 ? void 0 : region.uiHost) === null || _e === void 0 ? void 0 : _e.substring(8);
160
161
  const isUSRegion = regionName === 'us' || regionName === 'na';
162
+ const isPredefinedRegion = (region === null || region === void 0 ? void 0 : region.name) && Object.keys(region_handler_1.regions).some(key => key.toLowerCase() === region.name.toLowerCase());
161
163
  if (regionName !== 'eu' && !isUSRegion) {
162
164
  customHost = (_f = region === null || region === void 0 ? void 0 : region.cma) === null || _f === void 0 ? void 0 : _f.substring(8);
163
165
  }
164
- let graphqlHost = "graphql.contentstack.com";
165
- if (regionName != 'na') {
166
- graphqlHost = `${regionName}-.graphql.contentstack.com`;
167
- }
168
- // Construct image hostname based on the actual host being used
169
- let imageHostname = '*-images.contentstack.com'; // default fallback
170
- if (region === null || region === void 0 ? void 0 : region.cda) {
166
+ const getGraphqlHost = () => {
167
+ if (!isPredefinedRegion) {
168
+ return cdnHost.replace('-cdn.', '-graphql.');
169
+ }
170
+ const normalizedRegion = regionName === null || regionName === void 0 ? void 0 : regionName.toLowerCase();
171
+ if (!normalizedRegion || normalizedRegion === 'na' || normalizedRegion === 'aws-na' || normalizedRegion === 'us') {
172
+ return cdnHost.replace('cdn.', 'graphql.').replace('.io', '.com');
173
+ }
174
+ return cdnHost.replace('-cdn.', '-graphql.');
175
+ };
176
+ const graphqlHost = getGraphqlHost();
177
+ let imageHostname;
178
+ if (isPredefinedRegion && (region === null || region === void 0 ? void 0 : region.cda)) {
171
179
  const baseHost = region.cda.replace(/^https?:\/\//, '').replace(/^[^.]+\./, '');
172
180
  imageHostname = `images.${baseHost}`;
173
181
  }
182
+ else if (region === null || region === void 0 ? void 0 : region.cda) {
183
+ const baseHost = region.cda.replace(/^https?:\/\//, '').replace(/^[^.]+\./, '');
184
+ imageHostname = `*-images.${baseHost}`;
185
+ }
186
+ else {
187
+ //default
188
+ imageHostname = '*-images.contentstack.com';
189
+ }
174
190
  const production = environmentVariables.environment === 'production' ? true : false;
175
191
  switch (appConfigKey) {
176
192
  case 'kickstart-next':
177
193
  case 'kickstart-next-ssr':
178
194
  case 'kickstart-next-ssg':
179
195
  case 'kickstart-next-middleware':
196
+ fileName = `.env`;
197
+ filePath = (0, cli_utilities_1.pathValidator)(path.join((0, cli_utilities_1.sanitizePath)(clonedDirectory), (0, cli_utilities_1.sanitizePath)(fileName)));
198
+ content = `NEXT_PUBLIC_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nNEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_TOKEN=${environmentVariables.preview_token || ''}\nNEXT_PUBLIC_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nNEXT_PUBLIC_CONTENTSTACK_REGION=${regionName}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW=${livePreviewEnabled ? 'true' : 'false'}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_DELIVERY = ${cdnHost}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_APPLICATION = ${appHost}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_HOST = ${previewHost}\nNEXT_PUBLIC_CONTENTSTACK_IMAGE_HOSTNAME=${imageHostname}`;
199
+ result = await writeEnvFile(content, filePath);
200
+ break;
180
201
  case 'kickstart-next-graphql':
181
202
  fileName = `.env`;
182
203
  filePath = (0, cli_utilities_1.pathValidator)(path.join((0, cli_utilities_1.sanitizePath)(clonedDirectory), (0, cli_utilities_1.sanitizePath)(fileName)));
@@ -115,5 +115,5 @@
115
115
  ]
116
116
  }
117
117
  },
118
- "version": "2.0.0-beta.5"
118
+ "version": "2.0.0-beta.7"
119
119
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-bootstrap",
3
3
  "description": "Bootstrap contentstack apps",
4
- "version": "2.0.0-beta.5",
4
+ "version": "2.0.0-beta.7",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {
@@ -16,14 +16,14 @@
16
16
  "test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
17
17
  },
18
18
  "dependencies": {
19
- "@contentstack/cli-cm-seed": "~2.0.0-beta.5",
19
+ "@contentstack/cli-cm-seed": "~2.0.0-beta.7",
20
20
  "@contentstack/cli-command": "~1.7.2",
21
- "@contentstack/cli-utilities": "~1.17.0",
21
+ "@contentstack/cli-utilities": "~1.17.2",
22
22
  "@oclif/core": "^4.3.0",
23
- "@oclif/plugin-help": "^6.2.28",
23
+ "@oclif/plugin-help": "^6.2.37",
24
24
  "inquirer": "8.2.7",
25
25
  "mkdirp": "^1.0.4",
26
- "tar": "^7.5.6 "
26
+ "tar": "^7.5.7"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@oclif/test": "^4.1.13",
@@ -38,7 +38,7 @@
38
38
  "mocha": "10.8.2",
39
39
  "nyc": "^15.1.0",
40
40
  "oclif": "^4.17.46",
41
- "tmp": "^0.2.3",
41
+ "tmp": "^0.2.5",
42
42
  "ts-node": "^8.10.2",
43
43
  "typescript": "^4.9.5"
44
44
  },