Skip to content

Commit 3c63dff

Browse files
Merge pull request #2369 from contentstack/fix/kickstart-apps
Fixed kickstart apps breaking issue in bootstrap command
2 parents 40680b5 + 0f91563 commit 3c63dff

File tree

18 files changed

+448
-469
lines changed

18 files changed

+448
-469
lines changed

.talismanrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
fileignoreconfig:
22
- filename: package-lock.json
3-
checksum: 20001b2b16e2ab8cc8a3ccc30cebb5093c5c63f58e5b5fe64889d260a8d4cc56
3+
checksum: 09bde87514151440d68bc6154984a984c536728e37d18173bab4fdb53827dadd
44
- filename: pnpm-lock.yaml
5-
checksum: c2982bbd478bd9aabcc12bc162d2a76e2635d70023674a677dea996a8671e9ab
5+
checksum: e81b8b629ff23df0cd27af8c055c9bb3718b68e388fd9ff5e3485ef37bfe794b
6+
- filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts
7+
checksum: 6e6fb00bb11b03141e5ad27eeaa4af9718dc30520c3e73970bc208cc0ba2a7d2
68
version: '1.0'

package-lock.json

Lines changed: 371 additions & 427 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-audit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"chalk": "^4.1.2",
2727
"fast-csv": "^4.3.6",
2828
"fs-extra": "^11.3.0",
29-
"lodash": "^4.17.21",
29+
"lodash": "^4.17.23",
3030
"uuid": "^9.0.1",
3131
"winston": "^3.17.0"
3232
},

packages/contentstack-bootstrap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-bootstrap",
33
"description": "Bootstrap contentstack apps",
4-
"version": "1.18.2",
4+
"version": "1.18.3",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {

packages/contentstack-bootstrap/src/bootstrap/utils.ts

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { cliux, pathValidator, sanitizePath } from '@contentstack/cli-utilities'
44
import { continueBootstrapCommand } from '../bootstrap/interactive';
55
import { AppConfig } from '../config';
66
import messageHandler from '../messages';
7+
import { regions } from '@contentstack/cli-config/lib/utils/region-handler';
78

89
interface EnvironmentVariables {
910
api_key: string;
@@ -187,27 +188,59 @@ const envFileHandler = async (
187188
const cdnHost = region?.cda?.substring('8');
188189
const appHost = region?.uiHost?.substring(8);
189190
const isUSRegion = regionName === 'us' || regionName === 'na';
191+
192+
const isPredefinedRegion = region?.name && Object.keys(regions).some(
193+
key => key.toLowerCase() === region.name.toLowerCase()
194+
);
195+
190196
if (regionName !== 'eu' && !isUSRegion) {
191197
customHost = region?.cma?.substring(8);
192198
}
193-
let graphqlHost = "graphql.contentstack.com";
194-
if(regionName != 'na'){
195-
graphqlHost = `${regionName}-.graphql.contentstack.com`;
196-
}
197-
198199

199-
// Construct image hostname based on the actual host being used
200-
let imageHostname = '*-images.contentstack.com'; // default fallback
201-
if (region?.cda) {
200+
const getGraphqlHost = (): string => {
201+
if (!isPredefinedRegion) {
202+
return cdnHost.replace('-cdn.', '-graphql.');
203+
}
204+
const normalizedRegion = regionName?.toLowerCase();
205+
if (!normalizedRegion || normalizedRegion === 'na' || normalizedRegion === 'aws-na' || normalizedRegion === 'us') {
206+
return cdnHost.replace('cdn.', 'graphql.').replace('.io', '.com');
207+
}
208+
return cdnHost.replace('-cdn.', '-graphql.');
209+
};
210+
const graphqlHost = getGraphqlHost();
211+
212+
let imageHostname: string;
213+
if (isPredefinedRegion && region?.cda) {
202214
const baseHost = region.cda.replace(/^https?:\/\//, '').replace(/^[^.]+\./, '');
203215
imageHostname = `images.${baseHost}`;
216+
} else if (region?.cda) {
217+
const baseHost = region.cda.replace(/^https?:\/\//, '').replace(/^[^.]+\./, '');
218+
imageHostname = `*-images.${baseHost}`;
219+
} else {
220+
//default
221+
imageHostname = '*-images.contentstack.com';
204222
}
205223
const production = environmentVariables.environment === 'production' ? true : false;
206224
switch (appConfigKey) {
207225
case 'kickstart-next':
208226
case 'kickstart-next-ssr':
209227
case 'kickstart-next-ssg':
210228
case 'kickstart-next-middleware':
229+
fileName = `.env`;
230+
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
231+
content = `NEXT_PUBLIC_CONTENTSTACK_API_KEY=${environmentVariables.api_key
232+
}\nNEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken
233+
}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_TOKEN=${environmentVariables.preview_token || ''
234+
}\nNEXT_PUBLIC_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment
235+
}\nNEXT_PUBLIC_CONTENTSTACK_REGION=${regionName
236+
}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW=${livePreviewEnabled ? 'true' : 'false'
237+
}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_DELIVERY = ${cdnHost
238+
}\nNEXT_PUBLIC_CONTENTSTACK_CONTENT_APPLICATION = ${appHost
239+
}\nNEXT_PUBLIC_CONTENTSTACK_PREVIEW_HOST = ${previewHost
240+
}\nNEXT_PUBLIC_CONTENTSTACK_IMAGE_HOSTNAME=${imageHostname}`;
241+
242+
result = await writeEnvFile(content, filePath);
243+
break;
211244
case 'kickstart-next-graphql':
212245
fileName = `.env`;
213246
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));

packages/contentstack-branches/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@contentstack/cli-utilities": "~1.17.1",
1212
"chalk": "^4.1.2",
1313
"just-diff": "^6.0.2",
14-
"lodash": "^4.17.21"
14+
"lodash": "^4.17.23"
1515
},
1616
"devDependencies": {
1717
"@contentstack/cli-dev-dependencies": "~1.3.0",

packages/contentstack-bulk-publish/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"chalk": "^4.1.2",
1414
"dotenv": "^16.5.0",
1515
"inquirer": "8.2.7",
16-
"lodash": "^4.17.21",
16+
"lodash": "^4.17.23",
1717
"winston": "^3.17.0"
1818
},
1919
"devDependencies": {

packages/contentstack-clone/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@oclif/plugin-help": "^6.2.28",
1515
"chalk": "^4.1.2",
1616
"inquirer": "8.2.7",
17-
"lodash": "^4.17.21",
17+
"lodash": "^4.17.23",
1818
"merge": "^2.1.1",
1919
"ora": "^5.4.1",
2020
"prompt": "^1.3.0",

packages/contentstack-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@contentstack/cli-utilities": "~1.17.1",
2626
"@oclif/core": "^4.3.0",
2727
"@oclif/plugin-help": "^6.2.28",
28-
"lodash": "^4.17.21"
28+
"lodash": "^4.17.23"
2929
},
3030
"devDependencies": {
3131
"@oclif/test": "^4.1.13",

packages/contentstack-dev-dependencies/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"license": "MIT",
2323
"dependencies": {
2424
"@oclif/core": "^4.3.0",
25-
"lodash": "^4.17.21",
25+
"lodash": "^4.17.23",
2626
"fancy-test": "^2.0.42",
2727
"@oclif/test": "^4.1.13"
2828
},

0 commit comments

Comments
 (0)