@contentstack/cli-cm-seed 1.0.12 → 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
@@ -10,31 +10,37 @@ To import content to your stack, you can choose from the following two sources:
10
10
  <!-- usagestop -->
11
11
  ## Commands
12
12
  <!-- commands -->
13
- * [`csdx cm:seed`](#csdx-cmseed)
13
+ * [`csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>]`](#csdx-cmstacksseed---repo-value---org-value--k-value--n-value--y-value--s-value)
14
14
 
15
- ## `csdx cm:seed`
15
+ ## `csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>]`
16
16
 
17
- Create a Stack from existing content types, entries, assets, etc
17
+ Create a stack from existing content types, entries, assets, etc
18
18
 
19
19
  ```
20
20
  USAGE
21
- $ csdx cm:seed
21
+ $ csdx cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>]
22
22
 
23
23
  OPTIONS
24
- -n, --stack-name=stack-name Name of a new stack that needs to be created.
25
- -o, --org=org Provide Organization UID to create a new stack
26
- -r, --repo=repo GitHub account or GitHub account/repository
27
- -s, --stack=stack Provide stack UID to seed content to
24
+ -k, --stack-api-key=stack-api-key Provide stack api key to seed content to
25
+ -n, --stack-name=stack-name Name of a new stack that needs to be created.
26
+ -o, --org=org Provide Organization UID to create a new stack
27
+ -r, --repo=repo GitHub account or GitHub account/repository
28
+ -s, --stack=stack Provide stack UID to seed content to
29
+ -y, --yes=yes
30
+
31
+ ALIASES
32
+ $ csdx cm:seed
28
33
 
29
34
  EXAMPLES
30
- $ csdx cm:seed
31
- $ csdx cm:seed -r "account"
32
- $ csdx cm:seed -r "account/repository"
33
- $ csdx cm:seed -r "account/repository" -s "stack-uid" //seed content into specific stack
34
- $ csdx cm:seed -r "account/repository" -o "your-org-uid" -n "stack-name" //create a new stack in given org uid
35
+ $ csdx cm:stacks:seed
36
+ $ csdx cm:stacks:seed --repo "account"
37
+ $ csdx cm:stacks:seed --repo "account/repository"
38
+ $ csdx cm:stacks:seed --repo "account/repository" --stack-api-key "stack-api-key" //seed content into specific stack
39
+ $ csdx cm:stacks:seed --repo "account/repository" --org "your-org-uid" --stack-name "stack-name" //create a new stack
40
+ in given org uid
35
41
  ```
36
42
 
37
- _See code: [src/commands/cm/seed.ts](https://github.com/contentstack/cli/blob/v1.0.12/src/commands/cm/seed.ts)_
43
+ _See code: [src/commands/cm/stacks/seed.ts](https://github.com/contentstack/cli/blob/v1.1.0/src/commands/cm/stacks/seed.ts)_
38
44
  <!-- commandsstop -->
39
45
 
40
46
  ## Advanced Flags
@@ -45,7 +51,7 @@ The account name can be a personal user account, organization account, or enterp
45
51
  $ csdx cm:seed -r "account/repository"
46
52
  ```
47
53
 
48
- **Step 1.** Export a Stack
54
+ **Step 1.** Export a Stack
49
55
 
50
56
  Identify a Stack that you would like to export.
51
57
  This stack might be used in conjunction with a sample web site or mobile app you have created.
@@ -2,13 +2,17 @@ import { Command, flags } from '@contentstack/cli-command';
2
2
  export default class SeedCommand extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
+ static usage: string;
5
6
  static flags: {
6
7
  repo: flags.IOptionFlag<string | undefined>;
7
8
  org: flags.IOptionFlag<string | undefined>;
8
- stack: flags.IOptionFlag<string | undefined>;
9
+ 'stack-api-key': flags.IOptionFlag<string | undefined>;
9
10
  'stack-name': flags.IOptionFlag<string | undefined>;
10
11
  'fetch-limit': flags.IOptionFlag<string | undefined>;
12
+ yes: flags.IOptionFlag<string | undefined>;
13
+ stack: flags.IOptionFlag<string | undefined>;
11
14
  };
15
+ static aliases: string[];
12
16
  run(): Promise<{
13
17
  api_key: string;
14
18
  } | undefined>;
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_command_1 = require("@contentstack/cli-command");
4
- const seed_1 = require("../../seed");
4
+ const seed_1 = require("../../../seed");
5
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
5
6
  class SeedCommand extends cli_command_1.Command {
6
7
  async run() {
7
8
  try {
8
9
  const { flags: seedFlags } = this.parse(SeedCommand);
9
10
  if (!this.authToken) {
10
- this.error("You need to login, first. See: auth:login --help", {
11
+ this.error('You need to login, first. See: auth:login --help', {
11
12
  exit: 2,
12
- suggestions: [
13
- "https://www.contentstack.com/docs/developers/cli/authentication/",
14
- ],
13
+ suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'],
15
14
  });
16
15
  }
17
16
  const options = {
@@ -20,34 +19,37 @@ class SeedCommand extends cli_command_1.Command {
20
19
  authToken: this.authToken,
21
20
  gitHubPath: seedFlags.repo,
22
21
  orgUid: seedFlags.org,
23
- stackUid: seedFlags.stack,
24
- stackName: seedFlags["stack-name"],
25
- fetchLimit: seedFlags["fetch-limit"],
22
+ stackUid: seedFlags['stack-api-key'] || seedFlags.stack,
23
+ stackName: seedFlags['stack-name'],
24
+ fetchLimit: seedFlags['fetch-limit'],
25
+ skipStackConfirmation: seedFlags['yes'],
26
26
  };
27
27
  const seeder = new seed_1.default(options);
28
- const result = await seeder.run();
29
- return result;
28
+ return await seeder.run();
30
29
  }
31
30
  catch (error) {
32
- this.error(error, { exit: 1, suggestions: error.suggestions });
31
+ let errorObj = error;
32
+ this.error(errorObj, { exit: 1, suggestions: errorObj.suggestions });
33
33
  }
34
34
  }
35
35
  }
36
36
  exports.default = SeedCommand;
37
- SeedCommand.description = 'Create a Stack from existing content types, entries, assets, etc';
37
+ SeedCommand.description = 'Create a stack from existing content types, entries, assets, etc';
38
38
  SeedCommand.examples = [
39
- '$ csdx cm:seed',
40
- '$ csdx cm:seed -r "account"',
41
- '$ csdx cm:seed -r "account/repository"',
42
- '$ csdx cm:seed -r "account/repository" -s "stack-uid" //seed content into specific stack',
43
- '$ csdx cm:seed -r "account/repository" -o "your-org-uid" -n "stack-name" //create a new stack in given org uid',
39
+ '$ csdx cm:stacks:seed',
40
+ '$ csdx cm:stacks:seed --repo "account"',
41
+ '$ csdx cm:stacks:seed --repo "account/repository"',
42
+ '$ csdx cm:stacks:seed --repo "account/repository" --stack-api-key "stack-api-key" //seed content into specific stack',
43
+ '$ csdx cm:stacks:seed --repo "account/repository" --org "your-org-uid" --stack-name "stack-name" //create a new stack in given org uid',
44
44
  ];
45
+ SeedCommand.usage = 'cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>]';
45
46
  SeedCommand.flags = {
46
47
  repo: cli_command_1.flags.string({
47
48
  char: 'r',
48
49
  description: 'GitHub account or GitHub account/repository',
49
50
  multiple: false,
50
51
  required: false,
52
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-r'], ['--repo']),
51
53
  }),
52
54
  org: cli_command_1.flags.string({
53
55
  char: 'o',
@@ -55,13 +57,14 @@ SeedCommand.flags = {
55
57
  multiple: false,
56
58
  required: false,
57
59
  exclusive: ['stack'],
60
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-o'], ['--org']),
58
61
  }),
59
- stack: cli_command_1.flags.string({
60
- char: 's',
61
- description: 'Provide stack UID to seed content to',
62
+ 'stack-api-key': cli_command_1.flags.string({
63
+ char: 'k',
64
+ description: 'Provide stack api key to seed content to',
62
65
  multiple: false,
63
66
  required: false,
64
- exclusive: ['org', 'name'],
67
+ exclusive: ['org'],
65
68
  }),
66
69
  'stack-name': cli_command_1.flags.string({
67
70
  char: 'n',
@@ -77,4 +80,18 @@ SeedCommand.flags = {
77
80
  required: false,
78
81
  hidden: true,
79
82
  }),
83
+ yes: cli_command_1.flags.string({
84
+ char: 'y',
85
+ required: false,
86
+ }),
87
+ //To be deprecated
88
+ stack: cli_command_1.flags.string({
89
+ char: 's',
90
+ description: 'Provide stack UID to seed content to',
91
+ multiple: false,
92
+ required: false,
93
+ exclusive: ['org', 'name'],
94
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['s', 'stack'], ['-k', 'stack-api-key']),
95
+ }),
80
96
  };
97
+ SeedCommand.aliases = ['cm:seed'];
@@ -4,6 +4,7 @@ export default class GitHubClient {
4
4
  username: string;
5
5
  readonly gitHubRepoUrl: string;
6
6
  readonly gitHubUserUrl: string;
7
+ private readonly httpClient;
7
8
  static parsePath(path?: string): {
8
9
  username: string;
9
10
  repo: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const axios_1 = require("axios");
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
4
  const zlib = require("zlib");
5
5
  const tar = require("tar");
6
6
  const mkdirp = require("mkdirp");
@@ -10,6 +10,7 @@ class GitHubClient {
10
10
  this.username = username;
11
11
  this.gitHubRepoUrl = `https://api.github.com/repos/${username}`;
12
12
  this.gitHubUserUrl = `https://api.github.com/search/repositories?q=org%3A${username}+in:name+${defaultStackPattern}`;
13
+ this.httpClient = cli_utilities_1.HttpClient.create();
13
14
  }
14
15
  static parsePath(path) {
15
16
  const result = {
@@ -27,7 +28,7 @@ class GitHubClient {
27
28
  }
28
29
  async getAllRepos(count = 100) {
29
30
  try {
30
- const response = await axios_1.default.get(`${this.gitHubUserUrl}&per_page=${count}`);
31
+ const response = await this.httpClient.get(`${this.gitHubUserUrl}&per_page=${count}`);
31
32
  return response.data.items;
32
33
  }
33
34
  catch (error) {
@@ -42,7 +43,7 @@ class GitHubClient {
42
43
  }
43
44
  async checkIfRepoExists(repo) {
44
45
  try {
45
- const response = await axios_1.default.head(`${this.gitHubRepoUrl}/${repo}/contents`);
46
+ const response = await this.httpClient.send('HEAD', `${this.gitHubRepoUrl}/${repo}/contents`);
46
47
  return response.status === 200;
47
48
  }
48
49
  catch (error) {
@@ -52,7 +53,7 @@ class GitHubClient {
52
53
  }
53
54
  async getLatestTarballUrl(repo) {
54
55
  try {
55
- const response = await axios_1.default.get(`${this.gitHubRepoUrl}/${repo}/releases/latest`);
56
+ const response = await this.httpClient.get(`${this.gitHubRepoUrl}/${repo}/releases/latest`);
56
57
  return response.data.tarball_url;
57
58
  }
58
59
  catch (error) {
@@ -60,9 +61,12 @@ class GitHubClient {
60
61
  }
61
62
  }
62
63
  async streamRelease(url) {
63
- const response = await axios_1.default.get(url, {
64
+ const response = await this.httpClient
65
+ .options({
64
66
  responseType: 'stream',
65
- });
67
+ })
68
+ .get(url);
69
+ this.httpClient.resetConfig();
66
70
  return response.data;
67
71
  }
68
72
  async extract(destination, stream) {
@@ -9,6 +9,6 @@ async function run(options) {
9
9
  process.chdir(options.tmpPath);
10
10
  // moving here to fix jest testing bug
11
11
  const { parametersWithAuthToken } = require('@contentstack/cli-cm-import/src/lib/util/import-flags');
12
- await parametersWithAuthToken(options.authToken, options.api_key, importPath, '', options.cmaHost);
12
+ await parametersWithAuthToken(options.authToken, options.api_key, importPath, '', options.cmaHost, '', {});
13
13
  }
14
14
  exports.run = run;
@@ -10,11 +10,13 @@ export interface ContentModelSeederOptions {
10
10
  stackUid: string | undefined;
11
11
  stackName: string | undefined;
12
12
  fetchLimit: string | undefined;
13
+ skipStackConfirmation: string | undefined;
13
14
  }
14
15
  export default class ContentModelSeeder {
15
16
  options: ContentModelSeederOptions;
16
17
  private readonly csClient;
17
18
  private readonly ghClient;
19
+ private readonly _options;
18
20
  private ghUsername;
19
21
  private ghRepo;
20
22
  get ghPath(): string;
@@ -25,7 +27,7 @@ export default class ContentModelSeeder {
25
27
  getInput(): Promise<{
26
28
  organizationResponse: Organization;
27
29
  stackResponse: InquireStackResponse;
28
- }>;
30
+ } | any>;
29
31
  createStack(organization: Organization, stackName: string): Promise<string>;
30
32
  shouldProceed(api_key: string): Promise<boolean>;
31
33
  downloadRelease(): Promise<string>;
package/lib/seed/index.js CHANGED
@@ -1,8 +1,8 @@
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 tmp = require("tmp");
5
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
6
6
  const importer = require("../seed/importer");
7
7
  const client_1 = require("../seed/contentstack/client");
8
8
  const interactive_1 = require("../seed/interactive");
@@ -15,6 +15,7 @@ class ContentModelSeeder {
15
15
  constructor(options) {
16
16
  this.options = options;
17
17
  this.ghUsername = DEFAULT_OWNER;
18
+ this._options = options;
18
19
  const gh = client_2.default.parsePath(options.gitHubPath);
19
20
  this.ghUsername = gh.username || DEFAULT_OWNER;
20
21
  this.ghRepo = gh.repo;
@@ -35,12 +36,12 @@ class ContentModelSeeder {
35
36
  api_key = stackResponse.api_key;
36
37
  const proceed = await this.shouldProceed(api_key);
37
38
  if (!proceed) {
38
- cli_ux_1.default.log('Exiting. Please re-run the command, if you wish to seed content.');
39
+ cli_utilities_1.cliux.print('Exiting. Please re-run the command, if you wish to seed content.');
39
40
  return;
40
41
  }
41
42
  }
42
43
  const tmpPath = await this.downloadRelease();
43
- cli_ux_1.default.log(`Importing into '${stackResponse.name}'.`);
44
+ cli_utilities_1.cliux.print(`Importing into '${stackResponse.name}'.`);
44
45
  await importer.run({
45
46
  api_key: api_key,
46
47
  authToken: this.options.authToken,
@@ -57,21 +58,11 @@ class ContentModelSeeder {
57
58
  }
58
59
  const repoExists = await this.ghClient.checkIfRepoExists(this.ghRepo);
59
60
  if (repoExists === false) {
60
- cli_ux_1.default.error(`Could not find GitHub repository '${this.ghPath}'.`);
61
+ cli_utilities_1.cliux.error(`Could not find GitHub repository '${this.ghPath}'.`);
61
62
  }
62
63
  else {
63
64
  let organizationResponse;
64
65
  let stackResponse;
65
- if (this.options.orgUid) {
66
- organizationResponse = await this.csClient.getOrganization(this.options.orgUid);
67
- }
68
- else {
69
- const organizations = await this.csClient.getOrganizations();
70
- if (!organizations || organizations.length === 0) {
71
- throw new Error('You do not have access to any organizations. Please try again or ask an Administrator for assistance.');
72
- }
73
- organizationResponse = await (0, interactive_1.inquireOrganization)(organizations);
74
- }
75
66
  if (this.options.stackUid) {
76
67
  const stack = await this.csClient.getStack(this.options.stackUid);
77
68
  stackResponse = {
@@ -82,6 +73,16 @@ class ContentModelSeeder {
82
73
  };
83
74
  }
84
75
  else {
76
+ if (this.options.orgUid) {
77
+ organizationResponse = await this.csClient.getOrganization(this.options.orgUid);
78
+ }
79
+ else {
80
+ const organizations = await this.csClient.getOrganizations();
81
+ if (!organizations || organizations.length === 0) {
82
+ throw new Error('You do not have access to any organizations. Please try again or ask an Administrator for assistance.');
83
+ }
84
+ organizationResponse = await (0, interactive_1.inquireOrganization)(organizations);
85
+ }
85
86
  const stacks = await this.csClient.getStacks(organizationResponse.uid);
86
87
  stackResponse = await (0, interactive_1.inquireStack)(stacks, this.options.stackName);
87
88
  }
@@ -89,20 +90,19 @@ class ContentModelSeeder {
89
90
  }
90
91
  }
91
92
  async createStack(organization, stackName) {
92
- cli_ux_1.default.action.start(`Creating Stack '${stackName}' within Organization '${organization.name}'`);
93
- this.options.fetchLimit;
93
+ cli_utilities_1.cliux.loader(`Creating Stack '${stackName}' within Organization '${organization.name}'`);
94
94
  const newStack = await this.csClient.createStack({
95
95
  name: stackName,
96
96
  description: '',
97
97
  master_locale: exports.ENGLISH_LOCALE,
98
98
  org_uid: organization.uid,
99
99
  });
100
- cli_ux_1.default.action.stop();
100
+ cli_utilities_1.cliux.loader();
101
101
  return newStack.api_key;
102
102
  }
103
103
  async shouldProceed(api_key) {
104
104
  const count = await this.csClient.getContentTypeCount(api_key);
105
- if (count > 0) {
105
+ if (count > 0 && this._options.skipStackConfirmation !== 'yes') {
106
106
  const proceed = await (0, interactive_1.inquireProceed)();
107
107
  if (!proceed) {
108
108
  return false;
@@ -114,20 +114,20 @@ class ContentModelSeeder {
114
114
  const tmpDir = tmp.dirSync({
115
115
  unsafeCleanup: true,
116
116
  });
117
- cli_ux_1.default.debug(`Creating temporary directory '${tmpDir.name}'.`);
118
- cli_ux_1.default.action.start('Downloading and extracting Stack');
117
+ cli_utilities_1.cliux.print(`Creating temporary directory '${tmpDir.name}'.`);
118
+ cli_utilities_1.cliux.loader('Downloading and extracting Stack');
119
119
  try {
120
120
  await this.ghClient.getLatest(this.ghRepo, tmpDir.name);
121
121
  }
122
122
  catch (error) {
123
123
  if (error instanceof error_1.default) {
124
124
  if (error.status === 404) {
125
- cli_ux_1.default.error(`Unable to find a release for '${this.ghPath}'.`);
125
+ cli_utilities_1.cliux.error(`Unable to find a release for '${this.ghPath}'.`);
126
126
  }
127
127
  }
128
128
  }
129
129
  finally {
130
- cli_ux_1.default.action.stop();
130
+ cli_utilities_1.cliux.loader();
131
131
  }
132
132
  return tmpDir.name;
133
133
  }
@@ -139,7 +139,7 @@ class ContentModelSeeder {
139
139
  this.ghRepo = repoResponse.choice;
140
140
  }
141
141
  catch (error) {
142
- cli_ux_1.default.error(`Unable to find any Stack repositories within the '${this.ghUsername}' GitHub account. Please re-run this command with a GitHub repository in the 'account/repo' format. You can also re-run the command without arguments to pull from the official Stack list.`);
142
+ cli_utilities_1.cliux.error(`Unable to find any Stack repositories within the '${this.ghUsername}' GitHub account. Please re-run this command with a GitHub repository in the 'account/repo' format. You can also re-run the command without arguments to pull from the official Stack list.`);
143
143
  }
144
144
  }
145
145
  }
@@ -8,18 +8,17 @@ async function inquireRepo(repos) {
8
8
  if (repos.length === 1) {
9
9
  return { choice: extractRepoName(repos[0].html_url) };
10
10
  }
11
- const choices = repos.map(r => {
11
+ const choices = repos.map((r) => {
12
12
  return { name: formatStackName(r.name), value: extractRepoName(r.html_url) };
13
13
  });
14
- const response = await inquirer.prompt([
14
+ return inquirer.prompt([
15
15
  {
16
16
  type: 'list',
17
17
  name: 'choice',
18
18
  message: 'Select a Stack to Import',
19
- choices,
20
- },
19
+ choices
20
+ }
21
21
  ]);
22
- return response;
23
22
  }
24
23
  exports.inquireRepo = inquireRepo;
25
24
  async function inquireOrganization(organizations) {
@@ -28,7 +27,7 @@ async function inquireOrganization(organizations) {
28
27
  if (organizations.length === 1) {
29
28
  return organizations[0];
30
29
  }
31
- const choices = organizations.map(r => {
30
+ const choices = organizations.map((r) => {
32
31
  return { name: r.name, value: r.uid };
33
32
  });
34
33
  const response = await inquirer.prompt([
@@ -39,7 +38,7 @@ async function inquireOrganization(organizations) {
39
38
  choices,
40
39
  },
41
40
  ]);
42
- return organizations.find(r => r.uid === response.uid);
41
+ return organizations.find((r) => r.uid === response.uid);
43
42
  }
44
43
  exports.inquireOrganization = inquireOrganization;
45
44
  async function inquireProceed() {
@@ -101,10 +100,10 @@ async function inquireStack(stacks, stackName) {
101
100
  }
102
101
  else {
103
102
  // project stacks into the format the prompt function requires
104
- const choices = stacks.map(s => {
103
+ const choices = stacks.map((s) => {
105
104
  return { name: `${s.name}`, value: s.uid };
106
105
  });
107
- choices.sort((a, b) => (a.name > b.name) ? 1 : -1);
106
+ choices.sort((a, b) => (a.name > b.name ? 1 : -1));
108
107
  const selectResponse = await inquirer.prompt([
109
108
  {
110
109
  type: 'list',
@@ -113,7 +112,7 @@ async function inquireStack(stacks, stackName) {
113
112
  choices: choices,
114
113
  },
115
114
  ]);
116
- const stack = stacks.find(r => r.uid === selectResponse.uid);
115
+ const stack = stacks.find((r) => r.uid === selectResponse.uid);
117
116
  result.name = stack.name;
118
117
  result.uid = stack.uid;
119
118
  result.api_key = stack.api_key;
@@ -125,7 +124,7 @@ function formatStackName(name) {
125
124
  return name
126
125
  .replace('stack-', '')
127
126
  .replace(/-/g, ' ')
128
- .replace(/(?:^|\s)\S/g, match => {
127
+ .replace(/(?:^|\s)\S/g, (match) => {
129
128
  return match.toUpperCase();
130
129
  });
131
130
  }
@@ -1 +1 @@
1
- {"version":"1.0.12","commands":{"cm:seed":{"id":"cm:seed","description":"Create a Stack from existing content types, entries, assets, etc","pluginName":"@contentstack/cli-cm-seed","pluginType":"core","aliases":[],"examples":["$ csdx cm:seed","$ csdx cm:seed -r \"account\"","$ csdx cm:seed -r \"account/repository\"","$ csdx cm:seed -r \"account/repository\" -s \"stack-uid\" //seed content into specific stack","$ csdx cm:seed -r \"account/repository\" -o \"your-org-uid\" -n \"stack-name\" //create a new stack in given org uid"],"flags":{"repo":{"name":"repo","type":"option","char":"r","description":"GitHub account or GitHub account/repository","required":false},"org":{"name":"org","type":"option","char":"o","description":"Provide Organization UID to create a new stack","required":false},"stack":{"name":"stack","type":"option","char":"s","description":"Provide stack UID to seed content to","required":false},"stack-name":{"name":"stack-name","type":"option","char":"n","description":"Name of a new stack that needs to be created.","required":false},"fetch-limit":{"name":"fetch-limit","type":"option","char":"l","description":"Limit for number of Organizations or stacks to be fetched","hidden":true,"required":false}},"args":[]}}}
1
+ {"version":"1.1.0","commands":{"cm:stacks:seed":{"id":"cm:stacks:seed","description":"Create a stack from existing content types, entries, assets, etc","usage":"cm:stacks:seed [--repo <value>] [--org <value>] [-k <value>] [-n <value>] [-y <value>] [-s <value>]","pluginName":"@contentstack/cli-cm-seed","pluginType":"core","aliases":["cm:seed"],"examples":["$ csdx cm:stacks:seed","$ csdx cm:stacks:seed --repo \"account\"","$ csdx cm:stacks:seed --repo \"account/repository\"","$ csdx cm:stacks:seed --repo \"account/repository\" --stack-api-key \"stack-api-key\" //seed content into specific stack","$ csdx cm:stacks:seed --repo \"account/repository\" --org \"your-org-uid\" --stack-name \"stack-name\" //create a new stack in given org uid"],"flags":{"repo":{"name":"repo","type":"option","char":"r","description":"GitHub account or GitHub account/repository","required":false},"org":{"name":"org","type":"option","char":"o","description":"Provide Organization UID to create a new stack","required":false},"stack-api-key":{"name":"stack-api-key","type":"option","char":"k","description":"Provide stack api key to seed content to","required":false},"stack-name":{"name":"stack-name","type":"option","char":"n","description":"Name of a new stack that needs to be created.","required":false},"fetch-limit":{"name":"fetch-limit","type":"option","char":"l","description":"Limit for number of Organizations or stacks to be fetched","hidden":true,"required":false},"yes":{"name":"yes","type":"option","char":"y","required":false},"stack":{"name":"stack","type":"option","char":"s","description":"Provide stack UID to seed content to","required":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-seed",
3
3
  "description": "create a Stack from existing content types, entries, assets, etc.",
4
- "version": "1.0.12",
4
+ "version": "1.1.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-cm-import": "^0.1.1-beta.16",
9
- "@contentstack/cli-command": "^0.1.1-beta.6",
10
- "@oclif/command": "^1.8.0",
11
- "@oclif/config": "^1.17.0",
8
+ "@contentstack/cli-cm-import": "^1.0.0",
9
+ "@contentstack/cli-command": "^1.0.0",
10
+ "@contentstack/cli-utilities": "^1.0.0",
11
+ "@oclif/command": "^1.8.16",
12
+ "@oclif/config": "^1.18.3",
12
13
  "axios": "^0.21.1",
13
- "cli-ux": "^5.5.0",
14
14
  "inquirer": "^8.0.0",
15
15
  "mkdirp": "^1.0.4",
16
16
  "tar": "^6.0.5",
@@ -19,14 +19,14 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@oclif/dev-cli": "^1.22.2",
22
- "@oclif/plugin-help": "^3.2.0",
22
+ "@oclif/plugin-help": "^5.1.12",
23
23
  "@types/inquirer": "^7.3.1",
24
24
  "@types/jest": "^26.0.15",
25
25
  "@types/mkdirp": "^1.0.1",
26
26
  "@types/node": "^14.14.32",
27
27
  "@types/tar": "^4.0.3",
28
28
  "@types/tmp": "^0.2.0",
29
- "eslint": "^5.16.0",
29
+ "eslint": "^8.18.0",
30
30
  "eslint-config-oclif": "^3.1.0",
31
31
  "eslint-config-oclif-typescript": "^0.1.0",
32
32
  "globby": "^10.0.2",
@@ -57,6 +57,11 @@
57
57
  "@oclif/plugin-help"
58
58
  ]
59
59
  },
60
+ "csdxConfig": {
61
+ "expiredCommands": {
62
+ "cm:seed": "csdx cm:stacks:seed"
63
+ }
64
+ },
60
65
  "repository": "contentstack/cli",
61
66
  "scripts": {
62
67
  "test": "jest",