Skip to content

Commit c7107f0

Browse files
committed
Merge branch 'v2-beta-dev' into fix/DX-4421
2 parents fbea555 + c9e1b17 commit c7107f0

22 files changed

Lines changed: 534 additions & 696 deletions

File tree

package-lock.json

Lines changed: 221 additions & 426 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
@@ -25,7 +25,7 @@
2525
"chalk": "^4.1.2",
2626
"fast-csv": "^4.3.6",
2727
"fs-extra": "^11.3.0",
28-
"lodash": "^4.17.21",
28+
"lodash": "^4.17.23",
2929
"uuid": "^9.0.1",
3030
"winston": "^3.17.0"
3131
},

packages/contentstack-bootstrap/package.json

Lines changed: 5 additions & 5 deletions
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": "2.0.0-beta.6",
4+
"version": "2.0.0-beta.7",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {
@@ -16,14 +16,14 @@
1616
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
1717
},
1818
"dependencies": {
19-
"@contentstack/cli-cm-seed": "~2.0.0-beta.6",
19+
"@contentstack/cli-cm-seed": "~2.0.0-beta.7",
2020
"@contentstack/cli-command": "~1.7.2",
2121
"@contentstack/cli-utilities": "~1.17.2",
2222
"@oclif/core": "^4.3.0",
23-
"@oclif/plugin-help": "^6.2.28",
23+
"@oclif/plugin-help": "^6.2.37",
2424
"inquirer": "8.2.7",
2525
"mkdirp": "^1.0.4",
26-
"tar": "^7.5.6 "
26+
"tar": "^7.5.7"
2727
},
2828
"devDependencies": {
2929
"@oclif/test": "^4.1.13",
@@ -38,7 +38,7 @@
3838
"mocha": "10.8.2",
3939
"nyc": "^15.1.0",
4040
"oclif": "^4.17.46",
41-
"tmp": "^0.2.3",
41+
"tmp": "^0.2.5",
4242
"ts-node": "^8.10.2",
4343
"typescript": "^4.9.5"
4444
},

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.2",
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-clone/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
"dependencies": {
88
"@colors/colors": "^1.6.0",
99
"@contentstack/cli-cm-export": "~2.0.0-beta.7",
10-
"@contentstack/cli-cm-import": "~2.0.0-beta.6",
10+
"@contentstack/cli-cm-import": "~2.0.0-beta.7",
1111
"@contentstack/cli-command": "~1.7.2",
1212
"@contentstack/cli-utilities": "~1.17.2",
1313
"@oclif/core": "^4.3.0",
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
@@ -26,7 +26,7 @@
2626
"@contentstack/utils": "~1.7.0",
2727
"@oclif/core": "^4.3.0",
2828
"@oclif/plugin-help": "^6.2.28",
29-
"lodash": "^4.17.21"
29+
"lodash": "^4.17.23"
3030
},
3131
"devDependencies": {
3232
"@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
},

packages/contentstack-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"big-json": "^3.2.0",
1414
"bluebird": "^3.7.2",
1515
"chalk": "^4.1.2",
16-
"lodash": "^4.17.21",
16+
"lodash": "^4.17.23",
1717
"merge": "^2.1.1",
1818
"mkdirp": "^1.0.4",
1919
"progress-stream": "^2.0.0",

packages/contentstack-import-setup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"big-json": "^3.2.0",
1212
"chalk": "^4.1.2",
1313
"fs-extra": "^11.3.0",
14-
"lodash": "^4.17.21",
14+
"lodash": "^4.17.23",
1515
"merge": "^2.1.1",
1616
"mkdirp": "^1.0.4",
1717
"winston": "^3.17.0"

0 commit comments

Comments
 (0)