Skip to content
98 changes: 0 additions & 98 deletions packages/contentstack-bootstrap/src/bootstrap/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ const envFileHandler = async (
//default
imageHostname = '*-images.contentstack.com';
}
const production = environmentVariables.environment === 'production' ? true : false;
switch (appConfigKey) {
case 'kickstart-next':
case 'kickstart-next-ssr':
Expand Down Expand Up @@ -275,34 +274,6 @@ const envFileHandler = async (
result = await writeEnvFile(content, filePath);
break;

case 'reactjs':
case 'reactjs-starter':
fileName = `.env.${environmentVariables.environment}.local`;
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
content = `REACT_APP_CONTENTSTACK_API_KEY=${environmentVariables.api_key
}\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 : ''
}\nSKIP_PREFLIGHT_CHECK=true\nREACT_APP_CONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
result = await writeEnvFile(content, filePath);
break;
case 'nextjs':
case 'nextjs-starter':
fileName = `.env.${environmentVariables.environment}.local`;
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
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'
}CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${customHost ? customHost : managementAPIHost
}${!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
result = await writeEnvFile(content, filePath);
break;
case 'compass-app':
fileName = '.env';
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
Expand All @@ -318,75 +289,6 @@ const envFileHandler = async (
}\nCONTENTSTACK_HOST=${cdnHost}`;
result = await writeEnvFile(content, filePath);
break;
case 'gatsby':
case 'gatsby-starter':
fileName = `.env.${environmentVariables.environment}`;
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
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${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 = `.env${environmentVariables.environment === 'production' ? '.prod' : ''}`;
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), 'src', 'environments', sanitizePath(fileName)));
result = await writeEnvFile(content, filePath);
break;
case 'angular-starter':
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'
}CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${customHost ? customHost : managementAPIHost
}${!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
fileName = `.env${environmentVariables.environment === 'production' ? '.prod' : ''}`;
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
result = await writeEnvFile(content, filePath);
break;
case 'nuxtjs':
case 'nuxt-starter':
case 'nuxt3-starter':
case 'stencil-starter':
fileName = production ? '.env.production' : '.env';
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
// 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_API_HOST=${customHost ? customHost : managementAPIHost
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\n\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
result = await writeEnvFile(content, filePath);
break;
case 'vue-starter':
fileName = '.env';
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(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 : ''
}${!isUSRegion && !customHost ? '\nVUE_APP_CONTENTSTACK_REGION=' + region.name : ''
}\nVUE_APP_CONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
result = await writeEnvFile(content, filePath);
break;
default:
cliux.error(messageHandler.parse('CLI_BOOTSTRAP_INVALID_APP_NAME'));
}
Expand Down
68 changes: 1 addition & 67 deletions packages/contentstack-bootstrap/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ export interface AppConfig {
}

const config: Configuration = {
sampleApps: [
{ displayName: 'React JS (Deprecated)', configKey: 'reactjs' },
{ displayName: 'Next JS (Deprecated)', configKey: 'nextjs' },
{ displayName: 'Gatsby (Deprecated)', configKey: 'gatsby' },
{ displayName: 'Angular (Deprecated)', configKey: 'angular' },
],
sampleApps: [],
starterApps: [
{ displayName: 'Compass App', configKey: 'compass-app' },
{ displayName: 'Kickstart Next.js', configKey: 'kickstart-next' },
Expand All @@ -30,15 +25,6 @@ const config: Configuration = {
{ displayName: 'Kickstart Next.js Middleware', configKey: 'kickstart-next-middleware' },
{ displayName: 'Kickstart NuxtJS', configKey: 'kickstart-nuxt' },
{ displayName: 'Kickstart NuxtJS SSR', configKey: 'kickstart-nuxt-ssr' },

{ displayName: 'React JS (Deprecated)', configKey: 'reactjs-starter' },
{ displayName: 'Next JS (Deprecated)', configKey: 'nextjs-starter' },
{ displayName: 'Gatsby (Deprecated)', configKey: 'gatsby-starter' },
{ displayName: 'Angular (Deprecated)', configKey: 'angular-starter' },
{ displayName: 'Nuxt JS (Deprecated)', configKey: 'nuxt-starter' },
{ displayName: 'Vue JS (Deprecated)', configKey: 'vue-starter' },
{ displayName: 'Stencil (Deprecated)', configKey: 'stencil-starter' },
{ displayName: 'Nuxt3 (Deprecated)', configKey: 'nuxt3-starter' },
],
appLevelConfig: {
'kickstart-next': {
Expand Down Expand Up @@ -74,63 +60,11 @@ const config: Configuration = {
source: 'contentstack/kickstart-nuxt-ssr',
stack: 'contentstack/kickstart-stack-seed',
},
nextjs: {
source: 'contentstack/contentstack-nextjs-react-universal-demo',
stack: 'contentstack/stack-contentstack-nextjs-react-universal-demo',
},
reactjs: {
source: 'contentstack/contentstack-reactjs-universal-sample-app',
stack: 'contentstack/stack-contentstack-reactjs-universal-sample-app',
},
gatsby: {
source: 'contentstack/gatsby-starter-contentstack',
stack: 'contentstack/stack-gatsby-starter-contentstack',
},
angular: {
source: 'contentstack/contentstack-angular-modularblock-example',
stack: 'contentstack/stack-contentstack-angular-modularblock-example',
},
'compass-app': {
source: 'contentstack/compass-starter-app',
stack: 'contentstack/compass-starter-stack',
master_locale: 'en',
},
'nuxtjs-disabled': {
source: 'contentstack/contentstack-nuxtjs-vue-universal-demo',
stack: 'shafeeqd959/stack-contentstack-nuxtjs-vue-universal-demo',
},
'nuxt-starter': {
source: 'contentstack/contentstack-nuxtjs-starter-app',
stack: 'contentstack/stack-starter-app',
},
'reactjs-starter': {
source: 'contentstack/contentstack-react-starter-app',
stack: 'contentstack/stack-starter-app',
},
'nextjs-starter': {
source: 'contentstack/contentstack-nextjs-starter-app',
stack: 'contentstack/stack-starter-app',
},
'gatsby-starter': {
source: 'contentstack/contentstack-gatsby-starter-app',
stack: 'contentstack/stack-starter-app',
},
'angular-starter': {
source: 'contentstack/contentstack-angular-starter',
stack: 'contentstack/stack-starter-app',
},
'vue-starter': {
source: 'contentstack/contentstack-vuejs-starter-app',
stack: 'contentstack/stack-starter-app',
},
'stencil-starter': {
source: 'contentstack/contentstack-stencil-starter-app',
stack: 'contentstack/stack-starter-app',
},
'nuxt3-starter': {
source: 'contentstack/contentstack-nuxt3-starter-app',
stack: 'contentstack/stack-starter-app',
},
},
};
export default config;
Expand Down
12 changes: 6 additions & 6 deletions packages/contentstack-bootstrap/test/bootstrap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const mock = {
preview_token: 'test-preview-token',
},
appConfig: {
configKey: 'reactjs-starter',
displayName: 'React.js Starter',
configKey: 'kickstart-next',
displayName: 'Kickstart Next.js',
source: 'contentstack/stack-starter-app',
stack: 'contentstack/stack-starter-app',
master_locale: 'en-us',
Expand Down Expand Up @@ -159,10 +159,10 @@ describe('Bootstrapping an app', () => {
});
sandbox.stub(cliux, 'prompt').callsFake((question) => {
const responses = {
'app-name': 'reactjs-starter',
'app-name': 'kickstart-next',
org: 'org-uid',
'stack-name': 'test-bootstrap-cmd',
'app-type': 'reactjs-starter',
'app-type': 'kickstart-next',
yes: true,
};
return Promise.resolve(responses[question.name] || {});
Expand Down Expand Up @@ -654,7 +654,7 @@ describe('Bootstrapping an app', () => {
// Track Bootstrap instantiation
sandbox.stub(require('../lib/bootstrap/index'), 'default').callsFake(function (_options) {
// Verify that appConfig was retrieved using app-name
expect(config.getAppLevelConfigByName.calledWith('reactjs-starter')).to.be.true;
expect(config.getAppLevelConfigByName.calledWith('kickstart-next')).to.be.true;
return {
run: sandbox.stub().resolves(),
};
Expand All @@ -664,7 +664,7 @@ describe('Bootstrapping an app', () => {
command.parse = sandbox.stub().resolves({
flags: {
alias: undefined,
'app-name': 'reactjs-starter',
'app-name': 'kickstart-next',
'app-type': undefined,
'project-dir': undefined,
'stack-api-key': undefined,
Expand Down
Loading
Loading