@contentstack/cli-cm-bootstrap 1.1.0 → 1.1.3

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 (-v|--version|version)
18
- @contentstack/cli-cm-bootstrap/1.1.0 linux-x64 node-v16.14.2
18
+ @contentstack/cli-cm-bootstrap/1.1.3 darwin-arm64 node-v18.11.0
19
19
  $ csdx --help [COMMAND]
20
20
  USAGE
21
21
  $ csdx COMMAND
@@ -52,7 +52,7 @@ OPTIONS
52
52
  -y, --yes=yes
53
53
 
54
54
  --app-name=app-name App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter,
55
- nuxt-starter
55
+ nuxt-starter, vue-starter, stencil-starter
56
56
 
57
57
  --org=org Provide organization UID to create a new stack
58
58
 
@@ -69,5 +69,5 @@ EXAMPLES
69
69
  --stack-name "stack-name"
70
70
  ```
71
71
 
72
- _See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/v1.1.0/src/commands/cm/bootstrap.ts)_
72
+ _See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts)_
73
73
  <!-- commandsstop -->
@@ -63,7 +63,7 @@ class Bootstrap {
63
63
  }
64
64
  const result = await seed_1.default.run(cmd);
65
65
  if (result.api_key) {
66
- await (0, utils_1.setupEnvironments)(this.managementAPIClient, result.api_key, this.appConfig, this.cloneDirectory, this.region);
66
+ await (0, utils_1.setupEnvironments)(this.managementAPIClient, result.api_key, this.appConfig, this.cloneDirectory, this.region, this.options.livePreviewEnabled);
67
67
  }
68
68
  else {
69
69
  throw new Error(messages_1.default.parse('CLI_BOOTSTRAP_NO_API_KEY_FOUND'));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inquireAppType = exports.inquireGithubAccessToken = exports.inquireCloneDirectory = exports.inquireApp = void 0;
3
+ exports.inquireLivePreviewSupport = exports.inquireAppType = exports.inquireGithubAccessToken = exports.inquireCloneDirectory = exports.inquireApp = void 0;
4
4
  const path = require("path");
5
5
  const inquirer = require("inquirer");
6
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
@@ -87,3 +87,12 @@ async function inquireAppType() {
87
87
  return appType.type;
88
88
  }
89
89
  exports.inquireAppType = inquireAppType;
90
+ async function inquireLivePreviewSupport() {
91
+ const { livePreviewEnabled } = await inquirer.prompt({
92
+ type: 'confirm',
93
+ name: 'livePreviewEnabled',
94
+ message: 'Enable live preview?'
95
+ });
96
+ return livePreviewEnabled;
97
+ }
98
+ exports.inquireLivePreviewSupport = inquireLivePreviewSupport;
@@ -11,7 +11,7 @@ const messages_1 = require("../messages");
11
11
  * Create delivery token
12
12
  * Create enviroment
13
13
  */
14
- const setupEnvironments = async (managementAPIClient, api_key, appConfig, clonedDirectory, region) => {
14
+ const setupEnvironments = async (managementAPIClient, api_key, appConfig, clonedDirectory, region, livePreviewEnabled) => {
15
15
  const environmentResult = await managementAPIClient.stack({ api_key }).environment().query().find();
16
16
  if (Array.isArray(environmentResult.items) && environmentResult.items.length > 0) {
17
17
  for (const environment of environmentResult.items) {
@@ -41,8 +41,9 @@ const setupEnvironments = async (managementAPIClient, api_key, appConfig, cloned
41
41
  api_key,
42
42
  deliveryToken: tokenResult.token,
43
43
  environment: environment.name,
44
+ livePreviewEnabled,
44
45
  };
45
- await envFileHandler(appConfig.appConfigKey || '', environmentVariables, clonedDirectory, region);
46
+ await envFileHandler(appConfig.appConfigKey || '', environmentVariables, clonedDirectory, region, livePreviewEnabled);
46
47
  }
47
48
  else {
48
49
  cli_utilities_1.cliux.print(messages_1.default.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_TOKEN_FOR_ENV', environment.name));
@@ -82,7 +83,7 @@ const writeEnvFile = (content, fileName) => {
82
83
  * @description Create environment files for each app
83
84
  * TBD: moving the content to config file
84
85
  */
85
- const envFileHandler = async (appConfigKey, environmentVariables, clonedDirectory, region) => {
86
+ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirectory, region, livePreviewEnabled) => {
86
87
  if (!appConfigKey || !environmentVariables) {
87
88
  return;
88
89
  }
@@ -103,21 +104,21 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
103
104
  case 'reactjs-starter':
104
105
  fileName = `.env.${environmentVariables.environment}.local`;
105
106
  filePath = path.join(clonedDirectory, fileName);
106
- content = `REACT_APP_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nREACT_APP_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nREACT_APP_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(customHost ? '\nREACT_APP_CONTENTSTACK_API_HOST=' + customHost : '')}${(!isUSRegion && !customHost) ? '\nREACT_APP_CONTENTSTACK_REGION=' + region.name : ''}\nSKIP_PREFLIGHT_CHECK=true`;
107
+ content = `REACT_APP_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nREACT_APP_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nREACT_APP_CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(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}`;
107
108
  result = await writeEnvFile(content, filePath);
108
109
  break;
109
110
  case 'nextjs':
110
111
  case 'nextjs-starter':
111
112
  fileName = `.env.${environmentVariables.environment}.local`;
112
113
  filePath = path.join(clonedDirectory, fileName);
113
- content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(customHost ? '\nCONTENTSTACK_API_HOST=' + customHost : '')}${(!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '')}`;
114
+ content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(customHost ? '\nCONTENTSTACK_API_HOST=' + customHost : '')}${(!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '')}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
114
115
  result = await writeEnvFile(content, filePath);
115
116
  break;
116
117
  case 'gatsby':
117
118
  case 'gatsby-starter':
118
119
  fileName = `.env.${environmentVariables.environment}`;
119
120
  filePath = path.join(clonedDirectory, fileName);
120
- content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${managementAPIHost}`;
121
+ content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${managementAPIHost}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
121
122
  result = await writeEnvFile(content, filePath);
122
123
  break;
123
124
  case 'angular':
@@ -127,16 +128,23 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
127
128
  result = await writeEnvFile(content, filePath);
128
129
  break;
129
130
  case 'angular-starter':
130
- 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: '${customHost ? customHost : ''}',\n\tapp_host: '',\n\tmanagement_token: '',\n\tlive_preview: ''\n};`;
131
+ 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: '${customHost ? customHost : managementAPIHost}',\n\tapp_host: '',\n\tmanagement_token: '',\n\tlive_preview: ${livePreviewEnabled}\n};`;
131
132
  fileName = `environment${(environmentVariables.environment === 'production' ? '.prod.' : ".")}ts`;
132
133
  filePath = path.join(clonedDirectory, 'src', 'environments', fileName);
133
134
  result = await writeEnvFile(content, filePath);
134
135
  break;
135
136
  case 'nuxtjs':
136
137
  case 'nuxt-starter':
138
+ case 'stencil-starter':
137
139
  fileName = (production ? '.env.production' : '.env');
138
140
  filePath = path.join(clonedDirectory, fileName);
139
- content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(customHost ? '\nCONTENTSTACK_API_HOST=' + customHost : '')}${(!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '')}`;
141
+ content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(customHost ? '\nCONTENTSTACK_API_HOST=' + customHost : '')}${(!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '')}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
142
+ result = await writeEnvFile(content, filePath);
143
+ break;
144
+ case 'vue-starter':
145
+ fileName = '.env';
146
+ filePath = path.join(clonedDirectory, fileName);
147
+ content = `VUE_APP_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nVUE_APP_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\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}`;
140
148
  result = await writeEnvFile(content, filePath);
141
149
  break;
142
150
  default:
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_command_1 = require("@contentstack/cli-command");
4
+ const path_1 = require("path");
4
5
  const ContentstackManagementSDK = require('@contentstack/management');
5
6
  const bootstrap_1 = require("../../bootstrap");
6
7
  const interactive_1 = require("../../bootstrap/interactive");
@@ -53,6 +54,8 @@ class BootstrapCommand extends cli_command_1.Command {
53
54
  if (!cloneDirectory) {
54
55
  cloneDirectory = await (0, interactive_1.inquireCloneDirectory)();
55
56
  }
57
+ cloneDirectory = (0, path_1.resolve)(cloneDirectory);
58
+ const livePreviewEnabled = await (0, interactive_1.inquireLivePreviewSupport)();
56
59
  const seedParams = {};
57
60
  const stackAPIKey = bootstrapCommandFlags['stack-api-key'];
58
61
  const org = bootstrapCommandFlags['org'];
@@ -73,6 +76,7 @@ class BootstrapCommand extends cli_command_1.Command {
73
76
  managementAPIClient: this.managementAPIClient,
74
77
  region: this.region,
75
78
  appType,
79
+ livePreviewEnabled,
76
80
  };
77
81
  const bootstrap = new bootstrap_1.default(options);
78
82
  await bootstrap.run();
@@ -93,7 +97,7 @@ BootstrapCommand.examples = [
93
97
  ];
94
98
  BootstrapCommand.flags = {
95
99
  'app-name': cli_command_1.flags.string({
96
- description: 'App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter',
100
+ description: 'App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter, vue-starter, stencil-starter',
97
101
  multiple: false,
98
102
  required: false,
99
103
  }),
package/lib/config.js CHANGED
@@ -15,6 +15,8 @@ const config = {
15
15
  { displayName: 'Gatsby', configKey: 'gatsby-starter' },
16
16
  { displayName: 'Angular', configKey: 'angular-starter' },
17
17
  { displayName: 'Nuxt JS', configKey: 'nuxt-starter' },
18
+ { displayName: 'Vue JS', configKey: 'vue-starter' },
19
+ { displayName: 'Stencil', configKey: 'stencil-starter' },
18
20
  ],
19
21
  appLevelConfig: {
20
22
  nextjs: {
@@ -57,6 +59,14 @@ const config = {
57
59
  source: 'contentstack/contentstack-angular-starter',
58
60
  stack: 'contentstack/stack-starter-app',
59
61
  },
62
+ 'vue-starter': {
63
+ source: 'contentstack/contentstack-vuejs-starter-app',
64
+ stack: 'contentstack/stack-starter-app',
65
+ },
66
+ 'stencil-starter': {
67
+ source: 'contentstack/contentstack-stencil-starter-app',
68
+ stack: 'contentstack/stack-starter-app',
69
+ },
60
70
  },
61
71
  };
62
72
  exports.default = config;
@@ -1 +1 @@
1
- {"version":"1.1.0","commands":{"cm:bootstrap":{"id":"cm:bootstrap","description":"Bootstrap contentstack apps","pluginName":"@contentstack/cli-cm-bootstrap","pluginType":"core","aliases":[],"examples":["$ csdx cm:bootstrap","$ csdx cm:bootstrap --project-dir <path/to/setup/the/app>","$ csdx cm:bootstrap --app-name \"reactjs-starter\" --project-dir <path/to/setup/the/app>","$ csdx cm:bootstrap --app-name \"reactjs-starter\" --project-dir <path/to/setup/the/app> --stack-api-key \"stack-api-key\"","$ csdx cm:bootstrap --app-name \"reactjs-starter\" --project-dir <path/to/setup/the/app> --org \"your-org-uid\" --stack-name \"stack-name\""],"flags":{"app-name":{"name":"app-name","type":"option","description":"App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter","required":false},"project-dir":{"name":"project-dir","type":"option","description":"Directory to setup the project. If directory name has a space then provide the path as a string or escap the space using back slash eg: \"../../test space\" or ../../test\\ space","required":false},"app-type":{"name":"app-type","type":"option","description":"Sample or Starter app","hidden":true,"required":false},"stack-api-key":{"name":"stack-api-key","type":"option","char":"k","description":"Provide stack API key to seed content","required":false},"org":{"name":"org","type":"option","description":"Provide organization UID to create a new stack","required":false},"stack-name":{"name":"stack-name","type":"option","char":"n","description":"Name of a new stack that will be created.","required":false},"yes":{"name":"yes","type":"option","char":"y","required":false},"appName":{"name":"appName","type":"option","char":"a","description":"App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter","hidden":true,"required":false},"directory":{"name":"directory","type":"option","char":"d","description":"Directory to set up the project. If directory name has a space then provide the path as a string or escape the space using backslash eg: \"../../test space\" or ../../test\\ space","hidden":true,"required":false},"appType":{"name":"appType","type":"option","char":"s","description":"Sample or Starter app","hidden":true,"required":false}},"args":[]}}}
1
+ {"version":"1.1.3","commands":{"cm:bootstrap":{"id":"cm:bootstrap","description":"Bootstrap contentstack apps","pluginName":"@contentstack/cli-cm-bootstrap","pluginType":"core","aliases":[],"examples":["$ csdx cm:bootstrap","$ csdx cm:bootstrap --project-dir <path/to/setup/the/app>","$ csdx cm:bootstrap --app-name \"reactjs-starter\" --project-dir <path/to/setup/the/app>","$ csdx cm:bootstrap --app-name \"reactjs-starter\" --project-dir <path/to/setup/the/app> --stack-api-key \"stack-api-key\"","$ csdx cm:bootstrap --app-name \"reactjs-starter\" --project-dir <path/to/setup/the/app> --org \"your-org-uid\" --stack-name \"stack-name\""],"flags":{"app-name":{"name":"app-name","type":"option","description":"App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter, vue-starter, stencil-starter","required":false},"project-dir":{"name":"project-dir","type":"option","description":"Directory to setup the project. If directory name has a space then provide the path as a string or escap the space using back slash eg: \"../../test space\" or ../../test\\ space","required":false},"app-type":{"name":"app-type","type":"option","description":"Sample or Starter app","hidden":true,"required":false},"stack-api-key":{"name":"stack-api-key","type":"option","char":"k","description":"Provide stack API key to seed content","required":false},"org":{"name":"org","type":"option","description":"Provide organization UID to create a new stack","required":false},"stack-name":{"name":"stack-name","type":"option","char":"n","description":"Name of a new stack that will be created.","required":false},"yes":{"name":"yes","type":"option","char":"y","required":false},"appName":{"name":"appName","type":"option","char":"a","description":"App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter","hidden":true,"required":false},"directory":{"name":"directory","type":"option","char":"d","description":"Directory to set up the project. If directory name has a space then provide the path as a string or escape the space using backslash eg: \"../../test space\" or ../../test\\ space","hidden":true,"required":false},"appType":{"name":"appType","type":"option","char":"s","description":"Sample or Starter app","hidden":true,"required":false}},"args":[]}}}
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": "1.1.0",
4
+ "version": "1.1.3",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {
@@ -17,13 +17,13 @@
17
17
  "test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
18
18
  },
19
19
  "dependencies": {
20
- "@contentstack/cli-cm-seed": "^1.1.0",
21
- "@contentstack/cli-command": "^1.0.0",
22
- "@contentstack/cli-utilities": "^1.0.0",
20
+ "@contentstack/cli-cm-seed": "^1.1.3",
21
+ "@contentstack/cli-command": "^1.0.2",
22
+ "@contentstack/cli-utilities": "^1.0.3",
23
23
  "@contentstack/management": "^1.3.0",
24
24
  "@oclif/command": "^1.8.16",
25
25
  "@oclif/config": "^1.18.3",
26
- "inquirer": "^8.0.0",
26
+ "inquirer": "^8.2.4",
27
27
  "mkdirp": "^1.0.4",
28
28
  "tar": "^6.0.5"
29
29
  },
@@ -71,7 +71,8 @@
71
71
  ],
72
72
  "plugin": [
73
73
  "@contentstack/cli-cm-seed"
74
- ]
74
+ ],
75
+ "repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-bootstrap/<%- commandPath %>"
75
76
  },
76
77
  "repository": "contentstack/cli"
77
78
  }