@contentstack/cli-cm-bootstrap 1.0.5 → 1.0.8

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
@@ -13,7 +13,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
13
13
  $ csdx COMMAND
14
14
  running command...
15
15
  $ csdx (-v|--version|version)
16
- @contentstack/cli-cm-bootstrap/1.0.5 linux-x64 node-v12.22.7
16
+ @contentstack/cli-cm-bootstrap/1.0.8 linux-x64 node-v16.14.2
17
17
  $ csdx --help [COMMAND]
18
18
  USAGE
19
19
  $ csdx COMMAND
@@ -57,5 +57,5 @@ EXAMPLES
57
57
  $ csdx cm:bootstrap -t <github access token>
58
58
  ```
59
59
 
60
- _See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/v1.0.5/src/commands/cm/bootstrap.ts)_
60
+ _See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/v1.0.8/src/commands/cm/bootstrap.ts)_
61
61
  <!-- commandsstop -->
@@ -50,7 +50,7 @@ class Bootstrap {
50
50
  try {
51
51
  const result = await seed_1.default.run(["-r", this.appConfig.stack]);
52
52
  if (result.api_key) {
53
- await utils_1.setupEnvironments(this.managementAPIClient, result.api_key, this.appConfig, this.cloneDirectory, this.region);
53
+ await (0, utils_1.setupEnvironments)(this.managementAPIClient, result.api_key, this.appConfig, this.cloneDirectory, this.region);
54
54
  }
55
55
  else {
56
56
  throw new Error(messages_1.default.parse("CLI_BOOTSTRAP_NO_API_KEY_FOUND"));
@@ -11,7 +11,7 @@ const messages_1 = require("../messages");
11
11
  * Create delivery token
12
12
  * Create enviroment
13
13
  */
14
- exports.setupEnvironments = async (managementAPIClient, api_key, appConfig, clonedDirectory, region) => {
14
+ const setupEnvironments = async (managementAPIClient, api_key, appConfig, clonedDirectory, region) => {
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) {
@@ -62,6 +62,7 @@ exports.setupEnvironments = async (managementAPIClient, api_key, appConfig, clon
62
62
  cli_ux_1.default.error(messages_1.default.parse('CLI_BOOTSTRAP_APP_ENV_NOT_FOUND_FOR_THE_STACK'));
63
63
  }
64
64
  };
65
+ exports.setupEnvironments = setupEnvironments;
65
66
  const writeEnvFile = (content, fileName) => {
66
67
  if (!content || !fileName) {
67
68
  return;
@@ -91,9 +92,10 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
91
92
  let fileName;
92
93
  let customHost;
93
94
  const regionName = region && region.name && region.name.toLowerCase();
95
+ const managementAPIHost = region.cma && region.cma.substring('8');
94
96
  const isUSRegion = (regionName === 'us' || regionName === 'na');
95
97
  if (regionName !== 'eu' && !isUSRegion) {
96
- customHost = region.cda && region.cda.substring('8');
98
+ customHost = region.cma && region.cma.substring('8');
97
99
  }
98
100
  const production = (environmentVariables.environment === 'production' ? true : false);
99
101
  switch (appConfigKey) {
@@ -101,21 +103,21 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
101
103
  case 'reactjs-starter':
102
104
  fileName = `.env.${environmentVariables.environment}.local`;
103
105
  filePath = path.join(clonedDirectory, fileName);
104
- 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_CUSTOM_HOST=' + customHost : '')}${(!isUSRegion && !customHost) ? '\nREACT_APP_CONTENTSTACK_REGION=' + region.name : ''}`;
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`;
105
107
  result = await writeEnvFile(content, filePath);
106
108
  break;
107
109
  case 'nextjs':
108
110
  case 'nextjs-starter':
109
111
  fileName = `.env.${environmentVariables.environment}.local`;
110
112
  filePath = path.join(clonedDirectory, fileName);
111
- content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(customHost ? '\nCONTENTSTACK_CUSTOM_HOST=' + customHost : '')}${(!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '')}`;
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 : '')}`;
112
114
  result = await writeEnvFile(content, filePath);
113
115
  break;
114
116
  case 'gatsby':
115
117
  case 'gatsby-starter':
116
118
  fileName = `.env.${environmentVariables.environment}`;
117
119
  filePath = path.join(clonedDirectory, fileName);
118
- content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_CDN=${region.cda}/v3`;
120
+ content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${managementAPIHost}`;
119
121
  result = await writeEnvFile(content, filePath);
120
122
  break;
121
123
  case 'angular':
@@ -125,7 +127,7 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
125
127
  result = await writeEnvFile(content, filePath);
126
128
  break;
127
129
  case 'angular-starter':
128
- 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};`;
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};`;
129
131
  fileName = `environment${(environmentVariables.environment === 'production' ? '.prod.' : ".")}ts`;
130
132
  filePath = path.join(clonedDirectory, 'src', 'environments', fileName);
131
133
  result = await writeEnvFile(content, filePath);
@@ -134,7 +136,7 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
134
136
  case 'nuxt-starter':
135
137
  fileName = (production ? '.env.production' : '.env');
136
138
  filePath = path.join(clonedDirectory, fileName);
137
- content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${(!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '')}`;
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 : '')}`;
138
140
  result = await writeEnvFile(content, filePath);
139
141
  break;
140
142
  default:
@@ -15,38 +15,45 @@ class BootstrapCommand extends cli_command_1.Command {
15
15
  const bootstrapCommandFlags = this.parse(BootstrapCommand).flags;
16
16
  try {
17
17
  if (!this.authToken) {
18
- this.error(messages_1.default.parse('CLI_BOOTSTRAP_LOGIN_FAILED'), { exit: 2, suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'] });
18
+ this.error(messages_1.default.parse("CLI_BOOTSTRAP_LOGIN_FAILED"), {
19
+ exit: 2,
20
+ suggestions: [
21
+ "https://www.contentstack.com/docs/developers/cli/authentication/",
22
+ ],
23
+ });
19
24
  }
20
25
  // inquire user inputs
21
- let appType = bootstrapCommandFlags.appType || 'starterapp';
26
+ let appType = bootstrapCommandFlags.appType || "starterapp";
22
27
  if (!appType) {
23
- appType = await interactive_1.inquireAppType();
28
+ appType = await (0, interactive_1.inquireAppType)();
24
29
  }
25
30
  const selectedAppName = bootstrapCommandFlags.appName;
26
31
  let selectedApp;
27
32
  if (!selectedAppName) {
28
- if (appType === 'sampleapp') {
29
- selectedApp = await interactive_1.inquireApp(config_1.default.sampleApps);
33
+ if (appType === "sampleapp") {
34
+ selectedApp = await (0, interactive_1.inquireApp)(config_1.default.sampleApps);
30
35
  }
31
- else if (appType === 'starterapp') {
32
- selectedApp = await interactive_1.inquireApp(config_1.default.starterApps);
36
+ else if (appType === "starterapp") {
37
+ selectedApp = await (0, interactive_1.inquireApp)(config_1.default.starterApps);
33
38
  }
34
39
  else {
35
- this.error('Invalid app type provided ' + appType, { exit: 1 });
40
+ this.error("Invalid app type provided " + appType, { exit: 1 });
36
41
  }
37
42
  }
38
43
  if (!selectedAppName && !selectedApp) {
39
- this.error(messages_1.default.parse('CLI_BOOTSTRAP_INVALID_APP_NAME'), { exit: 1 });
44
+ this.error(messages_1.default.parse("CLI_BOOTSTRAP_INVALID_APP_NAME"), {
45
+ exit: 1,
46
+ });
40
47
  }
41
- const appConfig = config_1.getAppLevelConfigByName(selectedAppName || selectedApp.configKey);
48
+ const appConfig = (0, config_1.getAppLevelConfigByName)(selectedAppName || selectedApp.configKey);
42
49
  let cloneDirectory = bootstrapCommandFlags.directory;
43
50
  if (!cloneDirectory) {
44
- cloneDirectory = await interactive_1.inquireCloneDirectory();
51
+ cloneDirectory = await (0, interactive_1.inquireCloneDirectory)();
45
52
  }
46
53
  // Check the access token
47
54
  let accessToken = bootstrapCommandFlags.accessToken;
48
55
  if (appConfig.private && !accessToken) {
49
- accessToken = await interactive_1.inquireGithubAccessToken();
56
+ accessToken = await (0, interactive_1.inquireGithubAccessToken)();
50
57
  }
51
58
  // initiate bootstrsourceap
52
59
  const options = {
@@ -1 +1 @@
1
- {"version":"1.0.5","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 -d <path/to/setup/the/app>","$ csdx cm:bootstrap -t <github access token>"],"flags":{"appName":{"name":"appName","type":"option","char":"a","description":"App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter","required":false},"directory":{"name":"directory","type":"option","char":"d","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},"accessToken":{"name":"accessToken","type":"option","char":"t","description":"Access token for private github repo","required":false},"appType":{"name":"appType","type":"option","char":"s","description":"Sample or Starter app","hidden":true,"required":false}},"args":[]}}}
1
+ {"version":"1.0.8","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 -d <path/to/setup/the/app>","$ csdx cm:bootstrap -t <github access token>"],"flags":{"appName":{"name":"appName","type":"option","char":"a","description":"App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter","required":false},"directory":{"name":"directory","type":"option","char":"d","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},"accessToken":{"name":"accessToken","type":"option","char":"t","description":"Access token for private github repo","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.0.5",
4
+ "version": "1.0.8",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {
@@ -17,8 +17,8 @@
17
17
  "test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
18
18
  },
19
19
  "dependencies": {
20
+ "@contentstack/cli-cm-seed": "^1.0.12",
20
21
  "@contentstack/cli-command": "^0.1.1-beta.6",
21
- "@contentstack/cli-cm-seed": "^1.0.10",
22
22
  "@contentstack/management": "^1.3.0",
23
23
  "@oclif/command": "^1.8.0",
24
24
  "@oclif/config": "^1.17.0",
@@ -41,12 +41,12 @@
41
41
  "eslint-config-oclif": "^3.1.0",
42
42
  "eslint-config-oclif-typescript": "^0.1.0",
43
43
  "globby": "^10.0.2",
44
- "mocha": "^8.3.2",
44
+ "mocha": "^10.0.0",
45
45
  "nyc": "^15.1.0",
46
46
  "rimraf": "^2.7.1",
47
47
  "tmp": "^0.2.1",
48
48
  "ts-node": "^8.10.2",
49
- "typescript": "^3.9.7"
49
+ "typescript": "^4.7.4"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=8.0.0"