@contentstack/cli-cm-bootstrap 1.0.8 → 1.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Contentstack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Contentstack CLI’s “Bootstrap” plugin enables you to automate the process of setting up projects for sample and starter apps in Contentstack.
1
+ Contentstack CLI’s “Bootstrap” plugin enables you to automate the process of setting up projects for sample and starter apps in Contentstack.
2
2
 
3
3
  This means that all the required steps such as stack, environment, and content type creation, entry and asset publishing are performed just by using a single command.
4
4
 
@@ -6,20 +6,23 @@ This means that all the required steps such as stack, environment, and content t
6
6
  * [Usage](#usage)
7
7
  * [Commands](#commands)
8
8
  <!-- tocstop -->
9
+
9
10
  # Usage
11
+
10
12
  <!-- usage -->
11
13
  ```sh-session
12
14
  $ npm install -g @contentstack/cli-cm-bootstrap
13
15
  $ csdx COMMAND
14
16
  running command...
15
17
  $ csdx (-v|--version|version)
16
- @contentstack/cli-cm-bootstrap/1.0.8 linux-x64 node-v16.14.2
18
+ @contentstack/cli-cm-bootstrap/1.1.0 linux-x64 node-v16.14.2
17
19
  $ csdx --help [COMMAND]
18
20
  USAGE
19
21
  $ csdx COMMAND
20
22
  ...
21
23
  ```
22
24
  <!-- usagestop -->
25
+
23
26
  ```sh-session
24
27
  $ npm install -g @contentstack/cli-cm-clone
25
28
  $ csdx COMMAND
@@ -29,7 +32,9 @@ USAGE
29
32
  $ csdx COMMAND
30
33
  ...
31
34
  ```
35
+
32
36
  # Commands
37
+
33
38
  <!-- commands -->
34
39
  * [`csdx cm:bootstrap`](#csdx-cmbootstrap)
35
40
 
@@ -42,20 +47,27 @@ USAGE
42
47
  $ csdx cm:bootstrap
43
48
 
44
49
  OPTIONS
45
- -a, --appName=appName App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter,
46
- nuxt-starter
50
+ -k, --stack-api-key=stack-api-key Provide stack API key to seed content
51
+ -n, --stack-name=stack-name Name of a new stack that will be created.
52
+ -y, --yes=yes
53
+
54
+ --app-name=app-name App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter,
55
+ nuxt-starter
47
56
 
48
- -d, --directory=directory Directory to setup the project. If directory name has a space then provide the path as
49
- a string or escap the space using back slash eg: "../../test space" or ../../test\
50
- space
57
+ --org=org Provide organization UID to create a new stack
51
58
 
52
- -t, --accessToken=accessToken Access token for private github repo
59
+ --project-dir=project-dir Directory to setup the project. If directory name has a space then provide the path
60
+ as a string or escap the space using back slash eg: "../../test space" or
61
+ ../../test\ space
53
62
 
54
63
  EXAMPLES
55
64
  $ csdx cm:bootstrap
56
- $ csdx cm:bootstrap -d <path/to/setup/the/app>
57
- $ csdx cm:bootstrap -t <github access token>
65
+ $ csdx cm:bootstrap --project-dir <path/to/setup/the/app>
66
+ $ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app>
67
+ $ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app> --stack-api-key "stack-api-key"
68
+ $ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app> --org "your-org-uid"
69
+ --stack-name "stack-name"
58
70
  ```
59
71
 
60
- _See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/v1.0.8/src/commands/cm/bootstrap.ts)_
72
+ _See code: [src/commands/cm/bootstrap.ts](https://github.com/contentstack/cli/blob/v1.1.0/src/commands/cm/bootstrap.ts)_
61
73
  <!-- commandsstop -->
@@ -5,7 +5,7 @@ class BootstrapError extends Error {
5
5
  super(message);
6
6
  this.suggestions = suggestions;
7
7
  this.name = this.constructor.name;
8
- if (typeof Error.captureStackTrace === 'function') {
8
+ if (typeof Error.captureStackTrace === "function") {
9
9
  Error.captureStackTrace(this, this.constructor);
10
10
  }
11
11
  else {
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const axios_1 = require("axios");
4
3
  const zlib = require("zlib");
5
4
  const tar = require("tar");
6
5
  const mkdirp = require("mkdirp");
6
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
7
  const github_error_1 = require("./github-error");
8
8
  const messages_1 = require("../../messages");
9
- const DEFAULT_BRANCH = 'master';
9
+ const DEFAULT_BRANCH = 'cli-use';
10
10
  class GitHubClient {
11
11
  constructor(repo, privateRepo = false, token) {
12
12
  this.repo = repo;
@@ -42,14 +42,14 @@ class GitHubClient {
42
42
  if (this.private) {
43
43
  if (this.accessToken) {
44
44
  options.headers = {
45
- Authorization: `token ${this.accessToken}`
45
+ Authorization: `token ${this.accessToken}`,
46
46
  };
47
47
  }
48
48
  else {
49
49
  throw new github_error_1.default(messages_1.default.parse('CLI_BOOTSTRAP_GITHUB_ACCESS_NOT_FOUND'), 1);
50
50
  }
51
51
  }
52
- const response = await axios_1.default.get(url, options);
52
+ const response = await cli_utilities_1.HttpClient.create().options(options).get(url);
53
53
  return response.data;
54
54
  }
55
55
  async extract(destination, stream) {
@@ -5,7 +5,7 @@ class GithubError extends Error {
5
5
  super(message);
6
6
  this.status = status;
7
7
  this.name = this.constructor.name;
8
- if (typeof Error.captureStackTrace === 'function') {
8
+ if (typeof Error.captureStackTrace === "function") {
9
9
  Error.captureStackTrace(this, this.constructor);
10
10
  }
11
11
  else {
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENGLISH_LOCALE = void 0;
4
- const cli_ux_1 = require("cli-ux");
5
4
  const path = require("path");
6
- const seed_1 = require("@contentstack/cli-cm-seed/lib/commands/cm/seed");
7
- const client_1 = require("./github/client");
8
- const github_error_1 = require("./github/github-error");
9
- const utils_1 = require("./utils");
5
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
6
+ const seed_1 = require("@contentstack/cli-cm-seed/lib/commands/cm/stacks/seed");
10
7
  const messages_1 = require("../messages");
11
- exports.ENGLISH_LOCALE = "en-us";
8
+ const utils_1 = require("./utils");
9
+ const github_error_1 = require("./github/github-error");
10
+ const client_1 = require("./github/client");
11
+ exports.ENGLISH_LOCALE = 'en-us';
12
12
  /**
13
13
  * @description Bootstraps the sample app
14
14
  * Clone the repo
@@ -31,34 +31,47 @@ class Bootstrap {
31
31
  this.options = options;
32
32
  }
33
33
  async run() {
34
- cli_ux_1.default.action.start(messages_1.default.parse("CLI_BOOTSTRAP_START_CLONE_APP"));
34
+ cli_utilities_1.cliux.loader(messages_1.default.parse('CLI_BOOTSTRAP_START_CLONE_APP'));
35
35
  try {
36
36
  await this.ghClient.getLatest(this.cloneDirectory);
37
37
  }
38
38
  catch (error) {
39
39
  if (error instanceof github_error_1.default) {
40
40
  if (error.status === 404) {
41
- cli_ux_1.default.error(messages_1.default.parse("CLI_BOOTSTRAP_REPO_NOT_FOUND", this.appConfig.source));
41
+ cli_utilities_1.cliux.error(messages_1.default.parse('CLI_BOOTSTRAP_REPO_NOT_FOUND', this.appConfig.source));
42
42
  }
43
43
  }
44
44
  throw error;
45
45
  }
46
46
  finally {
47
- cli_ux_1.default.action.stop();
47
+ cli_utilities_1.cliux.loader();
48
48
  }
49
49
  // seed plugin start
50
50
  try {
51
- const result = await seed_1.default.run(["-r", this.appConfig.stack]);
51
+ const cmd = ['--repo', this.appConfig.stack];
52
+ if (this.options.seedParams.stackAPIKey) {
53
+ cmd.push('--stack-api-key', this.options.seedParams.stackAPIKey);
54
+ }
55
+ if (this.options.seedParams.org) {
56
+ cmd.push('--org', this.options.seedParams.org);
57
+ }
58
+ if (this.options.seedParams.stackName) {
59
+ cmd.push('-n', this.options.seedParams.stackName);
60
+ }
61
+ if (this.options.seedParams.yes) {
62
+ cmd.push('-y', this.options.seedParams.yes);
63
+ }
64
+ const result = await seed_1.default.run(cmd);
52
65
  if (result.api_key) {
53
66
  await (0, utils_1.setupEnvironments)(this.managementAPIClient, result.api_key, this.appConfig, this.cloneDirectory, this.region);
54
67
  }
55
68
  else {
56
- throw new Error(messages_1.default.parse("CLI_BOOTSTRAP_NO_API_KEY_FOUND"));
69
+ throw new Error(messages_1.default.parse('CLI_BOOTSTRAP_NO_API_KEY_FOUND'));
57
70
  }
58
- cli_ux_1.default.log(messages_1.default.parse("CLI_BOOTSTRAP_SUCCESS"));
71
+ cli_utilities_1.cliux.print(messages_1.default.parse('CLI_BOOTSTRAP_SUCCESS'));
59
72
  }
60
73
  catch (error) {
61
- cli_ux_1.default.error(messages_1.default.parse("CLI_BOOTSTRAP_STACK_CREATION_FAILED", this.appConfig.stack));
74
+ cli_utilities_1.cliux.error(messages_1.default.parse('CLI_BOOTSTRAP_STACK_CREATION_FAILED', this.appConfig.stack));
62
75
  }
63
76
  }
64
77
  }
@@ -1,29 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.inquireAppType = exports.inquireGithubAccessToken = exports.inquireCloneDirectory = exports.inquireApp = void 0;
4
- const inquirer = require("inquirer");
5
- const cli_ux_1 = require("cli-ux");
6
4
  const path = require("path");
5
+ const inquirer = require("inquirer");
6
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
7
  const messages_1 = require("../messages");
8
8
  /**
9
9
  * @description Inquire starter app
10
10
  */
11
11
  async function inquireApp(apps) {
12
- const appsPreview = apps.map(app => {
12
+ const appsPreview = apps.map((app) => {
13
13
  return {
14
14
  name: app.displayName,
15
15
  value: app,
16
16
  };
17
17
  });
18
- const actions = [{
18
+ const actions = [
19
+ {
19
20
  type: 'list',
20
21
  name: 'app',
21
22
  message: messages_1.default.parse('CLI_BOOTSTRAP_APP_SELECTION_ENQUIRY'),
22
23
  choices: [...appsPreview, 'Exit'],
23
- }];
24
+ },
25
+ ];
24
26
  const selectedApp = await inquirer.prompt(actions);
25
27
  if (selectedApp.app === 'Exit') {
26
- cli_ux_1.default.log('Exiting...');
28
+ cli_utilities_1.cliux.print('Exiting...');
27
29
  throw new Error('Exit');
28
30
  }
29
31
  return selectedApp.app;
@@ -33,35 +35,54 @@ exports.inquireApp = inquireApp;
33
35
  * @description Inquire clone destination directory
34
36
  */
35
37
  async function inquireCloneDirectory() {
36
- const actions = [{
38
+ const actions = [
39
+ {
37
40
  type: 'list',
38
41
  name: 'path',
39
42
  message: messages_1.default.parse('CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_TYPE_ENQUIRY'),
40
43
  choices: ['Current Folder', 'Other'],
41
- }];
44
+ },
45
+ ];
42
46
  const selectedPath = await inquirer.prompt(actions);
43
47
  if (selectedPath.path === 'Current Folder') {
44
48
  return process.cwd();
45
49
  }
46
50
  // Ask for the custom path
47
- let selectedCustomPath = await inquirer.prompt([{ type: 'string', name: 'path', message: messages_1.default.parse('CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_ENQUIRY') }]);
51
+ let selectedCustomPath = await inquirer.prompt([
52
+ {
53
+ type: 'string',
54
+ name: 'path',
55
+ message: messages_1.default.parse('CLI_BOOTSTRAP_APP_COPY_SOURCE_CODE_DESTINATION_ENQUIRY'),
56
+ },
57
+ ]);
48
58
  selectedCustomPath = path.resolve(selectedCustomPath.path);
49
59
  return selectedCustomPath;
50
60
  }
51
61
  exports.inquireCloneDirectory = inquireCloneDirectory;
52
62
  async function inquireGithubAccessToken() {
53
63
  // Ask for the access token
54
- const accessToken = await inquirer.prompt([{ type: 'string', name: 'token', message: messages_1.default.parse('CLI_BOOTSTRAP_NO_ACCESS_TOKEN_CREATED') }]);
64
+ const accessToken = await inquirer.prompt([
65
+ {
66
+ type: 'string',
67
+ name: 'token',
68
+ message: messages_1.default.parse('CLI_BOOTSTRAP_NO_ACCESS_TOKEN_CREATED'),
69
+ },
70
+ ]);
55
71
  return accessToken.token;
56
72
  }
57
73
  exports.inquireGithubAccessToken = inquireGithubAccessToken;
58
74
  async function inquireAppType() {
59
- const actions = [{
75
+ const actions = [
76
+ {
60
77
  type: 'list',
61
78
  name: 'type',
62
79
  message: messages_1.default.parse('CLI_BOOTSTRAP_TYPE_OF_APP_ENQUIRY'),
63
- choices: [{ name: 'Sample App', value: 'sampleapp' }, { name: 'Starter App', value: 'starterapp' }],
64
- }];
80
+ choices: [
81
+ { name: 'Sample App', value: 'sampleapp' },
82
+ { name: 'Starter App', value: 'starterapp' },
83
+ ],
84
+ },
85
+ ];
65
86
  const appType = await inquirer.prompt(actions);
66
87
  return appType.type;
67
88
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupEnvironments = void 0;
4
- const cli_ux_1 = require("cli-ux");
5
4
  const fs = require("fs");
6
5
  const path = require("path");
6
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
7
  const messages_1 = require("../messages");
8
8
  /**
9
9
  * @description Setup the environment for a given app for each environment
@@ -17,21 +17,21 @@ const setupEnvironments = async (managementAPIClient, api_key, appConfig, cloned
17
17
  for (const environment of environmentResult.items) {
18
18
  if (environment.name) {
19
19
  const body = {
20
- 'token': {
21
- 'name': `Sample app ${environment.name}`,
22
- 'description': 'Sample app',
23
- 'scope': [
20
+ token: {
21
+ name: `Sample app ${environment.name}`,
22
+ description: 'Sample app',
23
+ scope: [
24
24
  {
25
- 'module': 'environment',
26
- 'environments': [environment.name],
27
- 'acl': { 'read': true }
25
+ module: 'environment',
26
+ environments: [environment.name],
27
+ acl: { read: true },
28
28
  },
29
29
  {
30
- module: "branch",
30
+ module: 'branch',
31
31
  acl: { read: true },
32
- branches: ["main"]
33
- }
34
- ]
32
+ branches: ['main'],
33
+ },
34
+ ],
35
35
  },
36
36
  };
37
37
  try {
@@ -40,26 +40,26 @@ const setupEnvironments = async (managementAPIClient, api_key, appConfig, cloned
40
40
  const environmentVariables = {
41
41
  api_key,
42
42
  deliveryToken: tokenResult.token,
43
- environment: environment.name
43
+ environment: environment.name,
44
44
  };
45
- await envFileHandler(appConfig.appConfigKey || "", environmentVariables, clonedDirectory, region);
45
+ await envFileHandler(appConfig.appConfigKey || '', environmentVariables, clonedDirectory, region);
46
46
  }
47
47
  else {
48
- cli_ux_1.default.log(messages_1.default.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_TOKEN_FOR_ENV', environment.name));
48
+ cli_utilities_1.cliux.print(messages_1.default.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_TOKEN_FOR_ENV', environment.name));
49
49
  }
50
50
  }
51
51
  catch (error) {
52
- console.log("error", error);
53
- cli_ux_1.default.log(messages_1.default.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV', environment.name));
52
+ console.log('error', error);
53
+ cli_utilities_1.cliux.print(messages_1.default.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV', environment.name));
54
54
  }
55
55
  }
56
56
  else {
57
- cli_ux_1.default.log('No environments name found for the environment');
57
+ cli_utilities_1.cliux.print('No environments name found for the environment');
58
58
  }
59
59
  }
60
60
  }
61
61
  else {
62
- cli_ux_1.default.error(messages_1.default.parse('CLI_BOOTSTRAP_APP_ENV_NOT_FOUND_FOR_THE_STACK'));
62
+ cli_utilities_1.cliux.error(messages_1.default.parse('CLI_BOOTSTRAP_APP_ENV_NOT_FOUND_FOR_THE_STACK'));
63
63
  }
64
64
  };
65
65
  exports.setupEnvironments = setupEnvironments;
@@ -68,7 +68,7 @@ const writeEnvFile = (content, fileName) => {
68
68
  return;
69
69
  }
70
70
  return new Promise((resolve, reject) => {
71
- fs.writeFile(fileName, content, 'utf8', error => {
71
+ fs.writeFile(fileName, content, 'utf8', (error) => {
72
72
  if (error) {
73
73
  reject(error);
74
74
  }
@@ -140,7 +140,7 @@ const envFileHandler = async (appConfigKey, environmentVariables, clonedDirector
140
140
  result = await writeEnvFile(content, filePath);
141
141
  break;
142
142
  default:
143
- cli_ux_1.default.error(messages_1.default.parse('CLI_BOOTSTRAP_INVALID_APP_NAME'));
143
+ cli_utilities_1.cliux.error(messages_1.default.parse('CLI_BOOTSTRAP_INVALID_APP_NAME'));
144
144
  }
145
145
  return result;
146
146
  };
@@ -4,64 +4,74 @@ const cli_command_1 = require("@contentstack/cli-command");
4
4
  const ContentstackManagementSDK = require('@contentstack/management');
5
5
  const bootstrap_1 = require("../../bootstrap");
6
6
  const interactive_1 = require("../../bootstrap/interactive");
7
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
8
  const config_1 = require("../../config");
8
9
  const messages_1 = require("../../messages");
9
10
  class BootstrapCommand extends cli_command_1.Command {
10
11
  get managementAPIClient() {
11
- this._managementAPIClient = ContentstackManagementSDK.client({ host: this.cmaHost, authtoken: this.authToken });
12
- return this._managementAPIClient;
12
+ this.bootstrapManagementAPIClient = ContentstackManagementSDK.client({
13
+ host: this.cmaHost,
14
+ authtoken: this.authToken,
15
+ });
16
+ return this.bootstrapManagementAPIClient;
13
17
  }
14
18
  async run() {
15
19
  const bootstrapCommandFlags = this.parse(BootstrapCommand).flags;
16
20
  try {
17
21
  if (!this.authToken) {
18
- this.error(messages_1.default.parse("CLI_BOOTSTRAP_LOGIN_FAILED"), {
22
+ this.error(messages_1.default.parse('CLI_BOOTSTRAP_LOGIN_FAILED'), {
19
23
  exit: 2,
20
- suggestions: [
21
- "https://www.contentstack.com/docs/developers/cli/authentication/",
22
- ],
24
+ suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'],
23
25
  });
24
26
  }
25
27
  // inquire user inputs
26
- let appType = bootstrapCommandFlags.appType || "starterapp";
28
+ let appType = bootstrapCommandFlags.appType || bootstrapCommandFlags['app-type'] || 'starterapp';
27
29
  if (!appType) {
28
30
  appType = await (0, interactive_1.inquireAppType)();
29
31
  }
30
- const selectedAppName = bootstrapCommandFlags.appName;
32
+ const selectedAppName = bootstrapCommandFlags.appName || bootstrapCommandFlags['app-name'];
31
33
  let selectedApp;
32
34
  if (!selectedAppName) {
33
- if (appType === "sampleapp") {
35
+ if (appType === 'sampleapp') {
34
36
  selectedApp = await (0, interactive_1.inquireApp)(config_1.default.sampleApps);
35
37
  }
36
- else if (appType === "starterapp") {
38
+ else if (appType === 'starterapp') {
37
39
  selectedApp = await (0, interactive_1.inquireApp)(config_1.default.starterApps);
38
40
  }
39
41
  else {
40
- this.error("Invalid app type provided " + appType, { exit: 1 });
42
+ this.error('Invalid app type provided ' + appType, { exit: 1 });
41
43
  }
42
44
  }
43
45
  if (!selectedAppName && !selectedApp) {
44
- this.error(messages_1.default.parse("CLI_BOOTSTRAP_INVALID_APP_NAME"), {
46
+ this.error(messages_1.default.parse('CLI_BOOTSTRAP_INVALID_APP_NAME'), {
45
47
  exit: 1,
46
48
  });
47
49
  }
50
+ const yes = bootstrapCommandFlags.yes;
48
51
  const appConfig = (0, config_1.getAppLevelConfigByName)(selectedAppName || selectedApp.configKey);
49
- let cloneDirectory = bootstrapCommandFlags.directory;
52
+ let cloneDirectory = bootstrapCommandFlags.directory || bootstrapCommandFlags['project-dir'];
50
53
  if (!cloneDirectory) {
51
54
  cloneDirectory = await (0, interactive_1.inquireCloneDirectory)();
52
55
  }
53
- // Check the access token
54
- let accessToken = bootstrapCommandFlags.accessToken;
55
- if (appConfig.private && !accessToken) {
56
- accessToken = await (0, interactive_1.inquireGithubAccessToken)();
57
- }
56
+ const seedParams = {};
57
+ const stackAPIKey = bootstrapCommandFlags['stack-api-key'];
58
+ const org = bootstrapCommandFlags['org'];
59
+ const stackName = bootstrapCommandFlags['stack-name'];
60
+ if (stackAPIKey)
61
+ seedParams.stackAPIKey = stackAPIKey;
62
+ if (org)
63
+ seedParams.org = org;
64
+ if (stackName)
65
+ seedParams.stackName = stackName;
66
+ if (yes)
67
+ seedParams.yes = yes;
58
68
  // initiate bootstrsourceap
59
69
  const options = {
60
70
  appConfig,
71
+ seedParams,
61
72
  cloneDirectory,
62
73
  managementAPIClient: this.managementAPIClient,
63
74
  region: this.region,
64
- accessToken,
65
75
  appType,
66
76
  };
67
77
  const bootstrap = new bootstrap_1.default(options);
@@ -76,27 +86,68 @@ exports.default = BootstrapCommand;
76
86
  BootstrapCommand.description = 'Bootstrap contentstack apps';
77
87
  BootstrapCommand.examples = [
78
88
  '$ csdx cm:bootstrap',
79
- '$ csdx cm:bootstrap -d <path/to/setup/the/app>',
80
- '$ csdx cm:bootstrap -t <github access token>',
89
+ '$ csdx cm:bootstrap --project-dir <path/to/setup/the/app>',
90
+ '$ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app>',
91
+ '$ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app> --stack-api-key "stack-api-key"',
92
+ '$ csdx cm:bootstrap --app-name "reactjs-starter" --project-dir <path/to/setup/the/app> --org "your-org-uid" --stack-name "stack-name"',
81
93
  ];
82
94
  BootstrapCommand.flags = {
83
- appName: cli_command_1.flags.string({
84
- char: 'a',
95
+ 'app-name': cli_command_1.flags.string({
85
96
  description: 'App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter',
86
97
  multiple: false,
87
98
  required: false,
88
99
  }),
89
- directory: cli_command_1.flags.string({
90
- char: 'd',
100
+ 'project-dir': cli_command_1.flags.string({
91
101
  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',
92
102
  multiple: false,
93
103
  required: false,
94
104
  }),
95
- accessToken: cli_command_1.flags.string({
96
- char: 't',
97
- description: 'Access token for private github repo',
105
+ 'app-type': cli_command_1.flags.string({
106
+ description: 'Sample or Starter app',
107
+ multiple: false,
108
+ required: false,
109
+ hidden: true,
110
+ }),
111
+ 'stack-api-key': cli_command_1.flags.string({
112
+ char: 'k',
113
+ description: 'Provide stack API key to seed content',
114
+ multiple: false,
115
+ required: false,
116
+ exclusive: ['org', 'stack-name'],
117
+ }),
118
+ org: cli_command_1.flags.string({
119
+ description: 'Provide organization UID to create a new stack',
120
+ multiple: false,
121
+ required: false,
122
+ exclusive: ['stack-api-key'],
123
+ }),
124
+ 'stack-name': cli_command_1.flags.string({
125
+ char: 'n',
126
+ description: 'Name of a new stack that will be created.',
98
127
  multiple: false,
99
128
  required: false,
129
+ exclusive: ['stack-api-key'],
130
+ }),
131
+ yes: cli_command_1.flags.string({
132
+ char: 'y',
133
+ required: false,
134
+ }),
135
+ // To be deprecated
136
+ appName: cli_command_1.flags.string({
137
+ char: 'a',
138
+ description: 'App name, reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter',
139
+ multiple: false,
140
+ required: false,
141
+ hidden: true,
142
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-a', '--appName'], ['--app-name']),
143
+ }),
144
+ directory: cli_command_1.flags.string({
145
+ char: 'd',
146
+ 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',
147
+ multiple: false,
148
+ required: false,
149
+ hidden: true,
150
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-d', '--directory'], ['--project-dir']),
100
151
  }),
101
152
  appType: cli_command_1.flags.string({
102
153
  char: 's',
@@ -104,5 +155,6 @@ BootstrapCommand.flags = {
104
155
  multiple: false,
105
156
  required: false,
106
157
  hidden: true,
158
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-s', '--appType'], ['--app-type']),
107
159
  }),
108
160
  };
package/lib/config.js CHANGED
@@ -51,7 +51,7 @@ const config = {
51
51
  },
52
52
  'gatsby-starter': {
53
53
  source: 'contentstack/contentstack-gatsby-starter-app',
54
- stack: 'contentstack/stack-starter-app'
54
+ stack: 'contentstack/stack-starter-app',
55
55
  },
56
56
  'angular-starter': {
57
57
  source: 'contentstack/contentstack-angular-starter',
@@ -1 +1 @@
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":[]}}}
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":[]}}}
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.8",
4
+ "version": "1.1.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {
@@ -17,27 +17,26 @@
17
17
  "test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
18
18
  },
19
19
  "dependencies": {
20
- "@contentstack/cli-cm-seed": "^1.0.12",
21
- "@contentstack/cli-command": "^0.1.1-beta.6",
20
+ "@contentstack/cli-cm-seed": "^1.1.0",
21
+ "@contentstack/cli-command": "^1.0.0",
22
+ "@contentstack/cli-utilities": "^1.0.0",
22
23
  "@contentstack/management": "^1.3.0",
23
- "@oclif/command": "^1.8.0",
24
- "@oclif/config": "^1.17.0",
25
- "axios": "^0.21.1",
26
- "cli-ux": "^5.5.0",
24
+ "@oclif/command": "^1.8.16",
25
+ "@oclif/config": "^1.18.3",
27
26
  "inquirer": "^8.0.0",
28
27
  "mkdirp": "^1.0.4",
29
28
  "tar": "^6.0.5"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@oclif/dev-cli": "^1.22.2",
33
- "@oclif/plugin-help": "^3.2.0",
32
+ "@oclif/plugin-help": "^5.1.12",
34
33
  "@oclif/test": "^1.2.8",
35
34
  "@types/inquirer": "^7.3.1",
36
35
  "@types/mkdirp": "^1.0.1",
37
36
  "@types/node": "^14.14.32",
38
37
  "@types/tar": "^4.0.3",
39
38
  "chai": "^4.3.4",
40
- "eslint": "^5.16.0",
39
+ "eslint": "^8.18.0",
41
40
  "eslint-config-oclif": "^3.1.0",
42
41
  "eslint-config-oclif-typescript": "^0.1.0",
43
42
  "globby": "^10.0.2",