Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 51 Release #1290

Merged
merged 84 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
1721c99
added preview token as required in env file
cs-raj Dec 15, 2023
03fc211
added preview host
cs-raj Dec 18, 2023
747682d
Merge branch 'development' into feat/CS-42980
cs-raj Dec 19, 2023
48d44f6
lock file update
shafeeqd959 Dec 19, 2023
810e415
lock file update
shafeeqd959 Dec 19, 2023
d79733c
lock file update
shafeeqd959 Dec 19, 2023
5c45c35
version bumps and added for rest of the starter apps
cs-raj Dec 18, 2023
049e71f
version bump
cs-raj Dec 18, 2023
cd1fb27
added the test case for preview_token
cs-raj Dec 19, 2023
49bfd8e
feedback change added optional chaining while getting the preview host
cs-raj Dec 20, 2023
4159fdb
fixed test cases failing
cs-raj Dec 20, 2023
d73324a
added option to continue lp or not
cs-raj Dec 21, 2023
c406159
added app host as empty string
cs-raj Jan 3, 2024
f0dfaec
Merge branch 'development' into feat/CS-42980
cs-raj Jan 3, 2024
36b9a47
minor version bump
cs-raj Jan 4, 2024
4c85166
fromatted the code and in substring used number instead of string
cs-raj Jan 4, 2024
69789e8
Merge pull request #1217 from contentstack/feat/CS-42980
cs-raj Jan 4, 2024
9410f44
Merge branch 'development' into feat/CS-42473-live-preview
cs-raj Jan 11, 2024
dbbb4e2
Merge branch 'development' into feat/CS-42473-live-preview
cs-raj Jan 16, 2024
fb1253e
Ui text fixes
cs-raj Jan 16, 2024
a6c40a5
Merge branch 'feat/CS-42473-live-preview' into fix/CS-43464
cs-raj Jan 16, 2024
3b37a61
Merge pull request #1248 from contentstack/fix/CS-43464
cs-raj Jan 16, 2024
7185a49
added the customHost back as it will be used for regions other than prod
cs-raj Jan 18, 2024
ffe29b5
Merge pull request #1252 from contentstack/fix/CS-43531
cs-raj Jan 18, 2024
8070434
latest changes
shafeeqd959 Jan 23, 2024
e8e5113
Merge remote-tracking branch 'origin/development' into feat/CS-42473-…
cs-raj Jan 24, 2024
dc60ea4
modified the env for angular and next
cs-raj Jan 24, 2024
55dd367
added external config
shafeeqd959 Jan 24, 2024
e8e8bc6
bumped version in the core
shafeeqd959 Jan 24, 2024
441339f
removed management token from nextjs
cs-raj Jan 24, 2024
a8115a6
Merge branch 'development' into feat/CS-43355
netrajpatel Jan 24, 2024
655c4a2
merged changes
shafeeqd959 Jan 24, 2024
69a9ddf
Merge branch 'feat/CS-43355' of github.com:contentstack/cli into feat…
shafeeqd959 Jan 24, 2024
3fd9bd6
merged latest
shafeeqd959 Jan 24, 2024
3742fe5
added separate config for export and import
shafeeqd959 Jan 24, 2024
0214eba
Merge remote-tracking branch 'origin/development' into feat/CS-42473-…
cs-raj Jan 25, 2024
6fe4c8e
Merge remote-tracking branch 'origin/development' into fix/CS-43652
cs-raj Jan 25, 2024
b197543
modifed the test cases
cs-raj Jan 25, 2024
78051a4
Merge branch 'feat/CS-42473-live-preview' into fix/CS-43652
cs-raj Jan 25, 2024
7eba02c
Merge pull request #1266 from contentstack/fix/CS-43652
cs-raj Jan 25, 2024
8207577
Merge pull request #1259 from contentstack/feat/CS-43355
cs-raj Jan 25, 2024
f6ceeea
Merge pull request #1268 from contentstack/main
aman19K Jan 29, 2024
b99ef9d
refactor: Launch base class refactor
antonyagustine Jan 29, 2024
fcbd0e5
Merge branch 'staging' into stag-to-dev
aman19K Jan 29, 2024
d68e80e
Merge pull request #1271 from contentstack/stag-to-dev
aman19K Jan 29, 2024
3141ff4
fix: Project query and mutation update
antonyagustine Jan 29, 2024
327a06e
Merge pull request #1270 from contentstack/refactor/CS-43461
antonyagustine Jan 29, 2024
6e2e0b3
Merge branch 'development' into fix/CS-43461
antonyagustine Jan 30, 2024
1760911
Merge pull request #1272 from contentstack/fix/CS-43461
antonyagustine Jan 30, 2024
3f59ab6
Merge remote-tracking branch 'origin/main' into feat/CS-42473-live-pr…
cs-raj Jan 31, 2024
63b2d05
added unit tests for early access header config
shafeeqd959 Jan 31, 2024
db2b120
refactor: Handle file/folder missing case
antonyagustine Jan 31, 2024
ee89db5
Fix: missing local file/folder condition handled
antonyagustine Jan 31, 2024
ac1d401
Log printing issue fix
antonyagustine Jan 31, 2024
0d9ba83
Local existence check condition added
antonyagustine Jan 31, 2024
af24bb5
Fix: @oclif/test version updated
antonyagustine Jan 31, 2024
d6ad91e
Merge pull request #1276 from contentstack/refactor/CS-43730
antonyagustine Jan 31, 2024
1015f6d
Merge branch 'development' into refactor/dependency-update
antonyagustine Jan 31, 2024
3d4320f
Merge pull request #1275 from contentstack/refactor/dependency-update
antonyagustine Jan 31, 2024
4ad0e93
fixed early access test case
shafeeqd959 Feb 1, 2024
492111f
Merge branch 'development' of github.com:contentstack/cli into tests/…
shafeeqd959 Feb 1, 2024
fce3f47
corrected the type
shafeeqd959 Feb 1, 2024
3477b42
Merge pull request #1274 from contentstack/tests/CS-43313
netrajpatel Feb 1, 2024
6d37cb1
Merge branch 'main' of github.com:contentstack/cli
shafeeqd959 Feb 2, 2024
ef692eb
fixed content type flag
shafeeqd959 Feb 2, 2024
c5dcf52
removed logs
shafeeqd959 Feb 2, 2024
cd24449
Merge branch 'main' into main-to-stage
cs-raj Feb 5, 2024
5a304ff
Merge pull request #1280 from contentstack/main-to-stage
cs-raj Feb 5, 2024
fe739b4
Merge branch 'staging' into stage-to-development
cs-raj Feb 5, 2024
968778d
Merge pull request #1281 from contentstack/stage-to-development
cs-raj Feb 5, 2024
af566af
updated version
shafeeqd959 Feb 5, 2024
1fdcb6d
version update
shafeeqd959 Feb 5, 2024
8ef0dde
merge changes
shafeeqd959 Feb 5, 2024
4985ab7
Merge pull request #1284 from contentstack/hotfix-dev/CS-43629
aman19K Feb 5, 2024
cb47fad
version bump
aman19K Feb 5, 2024
59d4c56
Merge pull request #1285 from contentstack/release/sprint51-version-bump
aman19K Feb 5, 2024
84aaacf
Merge branch 'development' into feat/CS-42473-live-preview
cs-raj Feb 6, 2024
b1edf8d
added gcp-na arg example
cs-raj Feb 6, 2024
e4d7f8f
cli version bump
cs-raj Feb 6, 2024
d4496b8
Merge branch 'development' into feat/CS-42473-live-preview
cs-raj Feb 6, 2024
1aaf97e
Merge pull request #1286 from contentstack/feat/CS-42473-live-preview
cs-raj Feb 6, 2024
7524900
Merge pull request #1288 from contentstack/development
aman19K Feb 6, 2024
cdc182c
replaced cdn by appHost for generating the rest-preview urls
cs-raj Feb 9, 2024
ee2ae13
Merge pull request #1293 from contentstack/fix/lp
cs-raj Feb 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
582 changes: 79 additions & 503 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.3.4 darwin-arm64 node-v18.12.1
@contentstack/cli-audit/1.3.5 darwin-arm64 node-v20.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.3.4",
"version": "1.3.5",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@contentstack/cli-dev-dependencies": "^1.2.4",
"@oclif/test": "^2.0.3",
"@oclif/test": "^2.5.6",
"@types/chai": "^4.3.5",
"@types/fs-extra": "^11.0.2",
"@types/mocha": "^10.0.6",
Expand Down
13 changes: 0 additions & 13 deletions packages/contentstack-audit/src/audit-base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
* `gfSchema`. The values of these properties are the parsed JSON data from two different files.
*/
getCtAndGfSchema() {
const modules = this.sharedConfig.flags.modules || this.sharedConfig.modules;
const ctPath = join(
this.sharedConfig.basePath,
this.sharedConfig.moduleConfig['content-types'].dirName,
Expand All @@ -176,18 +175,6 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
this.sharedConfig.moduleConfig['global-fields'].fileName,
);

if (modules.includes('content-types')) {
if (!existsSync(ctPath)) {
this.log(this.$t(auditMsg.NOT_VALID_PATH, { path: ctPath }), 'error');
}
}

if (modules.includes('global-fields')) {
if (!existsSync(gfPath)) {
this.log(this.$t(auditMsg.NOT_VALID_PATH, { path: ctPath }), 'error');
}
}

const gfSchema = existsSync(gfPath) ? (JSON.parse(readFileSync(gfPath, 'utf8')) as ContentTypeStruct[]) : [];
const ctSchema = existsSync(ctPath) ? (JSON.parse(readFileSync(ctPath, 'utf8')) as ContentTypeStruct[]) : [];

Expand Down
4 changes: 3 additions & 1 deletion packages/contentstack-audit/src/modules/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export default class ContentType {
this.inMemoryFix = returnFixSchema;

if (!existsSync(this.folderPath)) {
throw new Error($t(auditMsg.NOT_VALID_PATH, { path: this.folderPath }));
this.log(`Skipping ${this.moduleName} audit`, 'warn');
this.log($t(auditMsg.NOT_VALID_PATH, { path: this.folderPath }), { color: 'yellow' });
return returnFixSchema ? [] : {};
}

this.schema = this.moduleName === 'content-types' ? this.ctSchema : this.gfSchema;
Expand Down
11 changes: 8 additions & 3 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export default class Entries {
*/
async run() {
if (!existsSync(this.folderPath)) {
throw new Error($t(auditMsg.NOT_VALID_PATH, { path: this.folderPath }));
this.log(`Skipping ${this.moduleName} audit`, 'warn');
this.log($t(auditMsg.NOT_VALID_PATH, { path: this.folderPath }), { color: 'yellow' });
return {};
}

await this.prepareEntryMetaData();
Expand Down Expand Up @@ -799,8 +801,11 @@ export default class Entries {
const localesFolderPath = resolve(this.config.basePath, this.config.moduleConfig.locales.dirName);
const localesPath = join(localesFolderPath, this.config.moduleConfig.locales.fileName);
const masterLocalesPath = join(localesFolderPath, 'master-locale.json');
this.locales = values(JSON.parse(readFileSync(masterLocalesPath, 'utf8')));
this.locales.push(...values(JSON.parse(readFileSync(localesPath, 'utf8'))));
this.locales = existsSync(masterLocalesPath) ? values(JSON.parse(readFileSync(masterLocalesPath, 'utf8'))) : [];

if (existsSync(localesPath)) {
this.locales.push(...values(JSON.parse(readFileSync(localesPath, 'utf8'))));
}

for (const { code } of this.locales) {
for (const { uid } of this.ctSchema) {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"devDependencies": {
"@fancy-test/nock": "^0.1.1",
"@oclif/plugin-help": "^5.1.19",
"@oclif/test": "^2.2.10",
"@oclif/test": "^2.5.6",
"@types/chai": "^4.2.18",
"@types/inquirer": "^9.0.3",
"@types/mkdirp": "^1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Tokens Add Command', () => {
let environmentTokenValidationStub;
let printStub;
const validAPIKey = 'adasdfagsf';
const validDeliveryToken = 'cdae3493fkdflklssw';
const validDeliveryToken = '***REMOVED***';
const validmanagementToken = 'cmajhsd98939482';
const validEnvironment = 'textenv';

Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "1.7.1",
"version": "1.8.0",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -25,7 +25,7 @@
"tar": "^6.1.13"
},
"devDependencies": {
"@oclif/test": "^2.2.10",
"@oclif/test": "^2.5.6",
"@types/inquirer": "^9.0.3",
"@types/mkdirp": "^1.0.1",
"@types/node": "^14.14.32",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stream } from 'stream';
import * as zlib from 'zlib';
import * as tar from 'tar';
import * as mkdirp from 'mkdirp';
const mkdirp = require('mkdirp')
import { HttpRequestConfig, HttpClient } from '@contentstack/cli-utilities';

import GithubError from './github-error';
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class Bootstrap {

if (this.options.livePreviewEnabled) {
cliux.print(
'Important: set management token and app host in the environment file before running the application',
'Note: Before running the app, please configure a preview token, preview host, and app host in the environment file',
{
color: 'yellow',
},
Expand Down
11 changes: 11 additions & 0 deletions packages/contentstack-bootstrap/src/bootstrap/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,14 @@ export async function inquireLivePreviewSupport() {
});
return livePreviewEnabled;
}

export async function continueBootstrapCommand() {
const { shouldContinue } = await inquirer.prompt({
type: 'list',
name: 'shouldContinue',
message: `To continue with the Bootstrap command without Live Preview, please select Yes.`,
choices: ['yes', 'no'],
loop: false,
});
return shouldContinue;
}
137 changes: 99 additions & 38 deletions packages/contentstack-bootstrap/src/bootstrap/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { cliux } from '@contentstack/cli-utilities';

import { continueBootstrapCommand } from '../bootstrap/interactive';
import { AppConfig } from '../config';
import messageHandler from '../messages';

Expand All @@ -10,6 +10,7 @@ interface EnviornmentVariables {
deliveryToken: string;
environment: string;
livePreviewEnabled?: boolean;
preview_token: string;
}

/**
Expand Down Expand Up @@ -54,30 +55,45 @@ export const setupEnvironments = async (
],
},
};
if (!managementToken) {
try {
const tokenResult = await managementAPIClient.stack({ api_key }).deliveryToken().create(body);
if (tokenResult.token) {
const environmentVariables: EnviornmentVariables = {
api_key,
deliveryToken: tokenResult.token,
environment: environment.name,
livePreviewEnabled,
};
await envFileHandler(
appConfig.appConfigKey || '',
environmentVariables,
clonedDirectory,
region,
livePreviewEnabled,
);
} else {
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_TOKEN_FOR_ENV', environment.name));
try {
const tokenResult = !managementToken
? await managementAPIClient
.stack({ api_key })
.deliveryToken()
.create(body, livePreviewEnabled ? { create_with_preview_token: true } : {})
: {};
if (livePreviewEnabled && !tokenResult.preview_token && !managementToken) {
cliux.print(
`Info: Failed to generate a preview token for the ${environment.name} environment.\nNote: Live Preview using a preview token is not available in your plan. Please contact the admin for support.`,
{
color: 'yellow',
},
);
if ((await continueBootstrapCommand()) === 'no') {
return;
}
} catch (error) {
console.log('error', error);
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV', environment.name));
}
if (tokenResult.token) {
const environmentVariables: EnviornmentVariables = {
api_key,
deliveryToken: tokenResult.token ?? '',
environment: environment.name,
livePreviewEnabled,
preview_token: tokenResult.preview_token ?? '',
};
await envFileHandler(
appConfig.appConfigKey || '',
environmentVariables,
clonedDirectory,
region,
livePreviewEnabled,
);
} else {
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_TOKEN_FOR_ENV', environment.name));
}
} catch (error) {
console.log('error', error);
cliux.print(messageHandler.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV', environment.name));
}
} else {
cliux.print('No environments name found for the environment');
Expand Down Expand Up @@ -123,11 +139,15 @@ const envFileHandler = async (
let filePath;
let fileName;
let customHost;
let previewHost: string;
let appHost: string;
const managementAPIHost = region?.cma?.substring('8');
const regionName = region && region.name && region.name.toLowerCase();
const managementAPIHost = region.cma && region.cma.substring('8');
previewHost = region?.uiHost?.substring(8)?.replace('app', 'rest-preview');
appHost = region?.uiHost?.substring(8);
const isUSRegion = regionName === 'us' || regionName === 'na';
if (regionName !== 'eu' && !isUSRegion) {
customHost = region.cma && region.cma.substring('8');
customHost = region?.cma?.substring(8);
}
const production = environmentVariables.environment === 'production' ? true : false;
switch (appConfigKey) {
Expand All @@ -137,9 +157,13 @@ const envFileHandler = async (
filePath = path.join(clonedDirectory, fileName);
content = `REACT_APP_CONTENTSTACK_API_KEY=${
environmentVariables.api_key
}\nREACT_APP_CONTENTSTACK_DELIVERY_TOKEN=${
environmentVariables.deliveryToken
}\nREACT_APP_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${
}\nREACT_APP_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}${
livePreviewEnabled
? `\nREACT_APP_CONTENTSTACK_PREVIEW_TOKEN=${
environmentVariables.preview_token || `''`
}\nREACT_APP_CONTENTSTACK_PREVIEW_HOST=${previewHost}\nREACT_APP_CONTENTSTACK_APP_HOST=${appHost}\n`
: '\n'
}\nREACT_APP_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\n${
customHost ? '\nREACT_APP_CONTENTSTACK_API_HOST=' + customHost : ''
}${
!isUSRegion && !customHost ? '\nREACT_APP_CONTENTSTACK_REGION=' + region.name : ''
Expand All @@ -152,26 +176,45 @@ const envFileHandler = async (
filePath = path.join(clonedDirectory, fileName);
content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${
environmentVariables.deliveryToken
}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${
}\n${
livePreviewEnabled
? `\nCONTENTSTACK_PREVIEW_TOKEN=${
environmentVariables.preview_token || `''`
}\nCONTENTSTACK_PREVIEW_HOST=${previewHost}\nCONTENTSTACK_APP_HOST=${appHost}\n`
: '\n'
}CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${
customHost ? customHost : managementAPIHost
}${
!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_MANAGEMENT_TOKEN=''\nCONTENTSTACK_APP_HOST=''\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
result = await writeEnvFile(content, filePath);
break;
case 'gatsby':
case 'gatsby-starter':
fileName = `.env.${environmentVariables.environment}`;
filePath = path.join(clonedDirectory, fileName);
content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${managementAPIHost}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${
environmentVariables.deliveryToken
}\n${
livePreviewEnabled
? `\nCONTENTSTACK_PREVIEW_TOKEN=${environmentVariables.preview_token || `''`}\nCONTENTSTACK_PREVIEW_HOST=${previewHost}\nCONTENTSTACK_APP_HOST=${appHost}\n`: '\n'
}\nCONTENTSTACK_ENVIRONMENT=${
environmentVariables.environment
}\nCONTENTSTACK_API_HOST=${managementAPIHost}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
result = await writeEnvFile(content, filePath);
break;
case 'angular':
content = `export const environment = { \n\tproduction:${
environmentVariables.environment === 'production' ? true : false
}, \n\tconfig : { \n\t\tapi_key: '${environmentVariables.api_key}', \n\t\tdelivery_token: '${
environmentVariables.deliveryToken
}', \n\t\tenvironment: '${environmentVariables.environment}'${
}',\n${
livePreviewEnabled
? `\n\tpreivew_token:'${
environmentVariables.preview_token || `''`
}'\n\tpreview_host:'${previewHost}'\n\tapp_host:'${appHost}'\n`
: '\n'
},\n\t\tenvironment: '${environmentVariables.environment}'${
!isUSRegion && !customHost ? `,\n\t\tregion: '${region.name}'` : ''
} \n\t } \n };`;
fileName = `environment${environmentVariables.environment === 'production' ? '.prod.' : '.'}ts`;
Expand All @@ -181,11 +224,16 @@ const envFileHandler = async (
case 'angular-starter':
content = `export const environment = { \n\tproduction: true \n}; \nexport const Config = { \n\tapi_key: '${
environmentVariables.api_key
}', \n\tdelivery_token: '${environmentVariables.deliveryToken}', \n\tenvironment: '${
environmentVariables.environment
}'${!isUSRegion && !customHost ? `,\n\tregion: '${region.name}'` : ''},\n\tapi_host: '${
}', \n\tdelivery_token: '${environmentVariables.deliveryToken}',\n\t${
livePreviewEnabled
? `\npreview_token:'${environmentVariables.preview_token || ''}',\npreview_host:'${previewHost
}',\napp_host:'${appHost}'`
: '\n'
},\n\tenvironment: '${environmentVariables.environment}'${
!isUSRegion && !customHost ? `,\n\tregion: '${region.name}'` : ''
},\n\tapi_host: '${
customHost ? customHost : managementAPIHost
}',\n\tapp_host: '',\n\tmanagement_token: '',\n\tlive_preview: ${livePreviewEnabled}\n};`;
}',\n\tlive_preview: ${livePreviewEnabled}\n};`;
fileName = `environment${environmentVariables.environment === 'production' ? '.prod.' : '.'}ts`;
filePath = path.join(clonedDirectory, 'src', 'environments', fileName);
result = await writeEnvFile(content, filePath);
Expand All @@ -198,18 +246,31 @@ const envFileHandler = async (
// Note: Stencil app needs all the env variables, even if they are not having values otherwise the rollup does not work properly and throws process in undefined error.
content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${
environmentVariables.deliveryToken
}\n${
livePreviewEnabled
? `\nCONTENTSTACK_PREVIEW_TOKEN=${environmentVariables.preview_token || `''`}\nCONTENTSTACK_PREVIEW_HOST=${
customHost ?? previewHost
}\nCONTENTSTACK_APP_HOST=${appHost}`
: '\n'
}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${
!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_MANAGEMENT_TOKEN=''\nCONTENTSTACK_API_HOST='${
}\nCONTENTSTACK_API_HOST=${
customHost ? customHost : managementAPIHost
}'\nCONTENTSTACK_APP_HOST=''\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\n\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
result = await writeEnvFile(content, filePath);
break;
case 'vue-starter':
fileName = '.env';
filePath = path.join(clonedDirectory, fileName);
content = `VUE_APP_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nVUE_APP_CONTENTSTACK_DELIVERY_TOKEN=${
environmentVariables.deliveryToken
}\n${
livePreviewEnabled
? `\nVUE_APP_CONTENTSTACK_PREVIEW_TOKEN=${
environmentVariables.preview_token || `''`
}\nVUE_APP_CONTENTSTACK_PREVIEW_HOST=${previewHost
}\nVUE_APP_CONTENTSTACK_APP_HOST=${appHost}\n`
: '\n'
}\nVUE_APP_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${
customHost ? '\nVUE_APP_CONTENTSTACK_API_HOST=' + customHost : ''
}${
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/test/github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Github Client', function () {
it('Git Tarball url creation', () => {
const repo = GitHubClient.parsePath('contentstack/contentstack-nextjs-react-universal-demo');
const gClient = new GitHubClient(repo);
expect(gClient.gitTarBallUrl).to.be.equal('https://api.github.com/repos/contentstack/contentstack-nextjs-react-universal-demo/tarball/master')
expect(gClient.gitTarBallUrl).to.be.equal('https://api.github.com/repos/contentstack/contentstack-nextjs-react-universal-demo/tarball/cli-use')
})

it('Clone the source repo', async function () {
Expand Down
Loading
Loading