contensis-cli 1.0.0-beta.46 → 1.0.0-beta.48

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.
@@ -11,7 +11,7 @@ export const makeGetCommand = () => {
11
11
 
12
12
  program
13
13
  .command('version')
14
- .description('Get current Contensis version')
14
+ .description('get current Contensis version')
15
15
  .addHelpText(
16
16
  'after',
17
17
  `
@@ -23,9 +23,26 @@ Example call:
23
23
  await cliCommand(['get', 'version'], opts).PrintContensisVersion();
24
24
  });
25
25
 
26
+ program
27
+ .command('project')
28
+ .description('get a project')
29
+ .argument('[projectId]', 'id of the project to get (default: current)')
30
+ .addHelpText(
31
+ 'after',
32
+ `
33
+ Example call:
34
+ > get project website
35
+ `
36
+ )
37
+ .action(async (projectId: string, opts) => {
38
+ await cliCommand(['get', 'project', projectId], opts).PrintProject(
39
+ projectId
40
+ );
41
+ });
42
+
26
43
  program
27
44
  .command('model')
28
- .description('Get a content model')
45
+ .description('get a content model')
29
46
  .argument('<contentTypeId...>', 'ids of the content models to get')
30
47
  .addHelpText(
31
48
  'after',
@@ -43,7 +60,7 @@ Example call:
43
60
 
44
61
  program
45
62
  .command('contenttype')
46
- .description('Get a content type')
63
+ .description('get a content type')
47
64
  .argument('<contentTypeId>', 'the API id of the content type to get')
48
65
  .addHelpText(
49
66
  'after',
@@ -61,7 +78,7 @@ Example call:
61
78
 
62
79
  program
63
80
  .command('component')
64
- .description('Get a component')
81
+ .description('get a component')
65
82
  .argument('<componentId>', 'the API id of the component to get')
66
83
  .addHelpText(
67
84
  'after',
@@ -78,7 +95,7 @@ Example call:
78
95
 
79
96
  program
80
97
  .command('entries')
81
- .description('Get entries')
98
+ .description('get entries')
82
99
  .argument(
83
100
  '[search phrase]',
84
101
  'get entries with the search phrase, use quotes for multiple words'
@@ -117,7 +134,7 @@ Example call:
117
134
 
118
135
  const block = program
119
136
  .command('block')
120
- .description('Get a block or block version')
137
+ .description('get a block or block version')
121
138
  .argument('[blockId]', 'the block to get version details for')
122
139
  .argument(
123
140
  '[branch]',
@@ -152,7 +169,7 @@ Example call:
152
169
 
153
170
  block
154
171
  .command('logs')
155
- .description('Get logs for a block')
172
+ .description('get logs for a block')
156
173
  .argument('[blockId]', 'the block to get version logs for')
157
174
  .argument(
158
175
  '[branch]',
@@ -4,6 +4,7 @@ import { cliCommand } from '~/services/ContensisCliService';
4
4
  export const makeListCommand = () => {
5
5
  const list = new Command()
6
6
  .command('list')
7
+ .description('list command')
7
8
  .addHelpText('after', `\n`)
8
9
  .showHelpAfterError(true)
9
10
  .exitOverride();
@@ -24,14 +25,14 @@ Example call:
24
25
 
25
26
  list
26
27
  .command('projects')
27
- .description('Print list of projects')
28
+ .description('print list of projects')
28
29
  .action(async opts => {
29
30
  await cliCommand(['list', 'projects'], opts).PrintProjects();
30
31
  });
31
32
 
32
33
  list
33
34
  .command('models')
34
- .description('Print list of content models')
35
+ .description('print list of content models')
35
36
  .addHelpText(
36
37
  'after',
37
38
  `
@@ -45,7 +46,7 @@ Example call:
45
46
 
46
47
  list
47
48
  .command('contenttypes')
48
- .description('Print list of content types')
49
+ .description('print list of content types')
49
50
  .addHelpText(
50
51
  'after',
51
52
  `
@@ -59,7 +60,7 @@ Example call:
59
60
 
60
61
  list
61
62
  .command('components')
62
- .description('Print list of components')
63
+ .description('print list of components')
63
64
  .addHelpText(
64
65
  'after',
65
66
  `
@@ -73,7 +74,7 @@ Example call:
73
74
 
74
75
  list
75
76
  .command('blocks')
76
- .description('Print list of content blocks')
77
+ .description('print list of content blocks')
77
78
  .addHelpText(
78
79
  'after',
79
80
  `
@@ -87,7 +88,7 @@ Example call:
87
88
 
88
89
  list
89
90
  .command('keys')
90
- .description('Print list of API keys')
91
+ .description('print list of API keys')
91
92
  .addHelpText(
92
93
  'after',
93
94
  `
@@ -101,7 +102,7 @@ Example call:
101
102
 
102
103
  list
103
104
  .command('webhooks')
104
- .description('Print list of webhooks')
105
+ .description('print list of webhooks')
105
106
  .argument('[name]', 'find webhooks matching the supplied name')
106
107
  .option('-i --id <id...>', 'the subscription id(s) to get')
107
108
  .addHelpText('after', `\n`)
@@ -6,12 +6,14 @@ import { cliCommand } from '~/services/ContensisCliService';
6
6
  export const makePushCommand = () => {
7
7
  const push = new Command()
8
8
  .command('push')
9
+ .description('push command')
9
10
  .addHelpText('after', `\n`)
10
11
  .showHelpAfterError(true)
11
12
  .exitOverride();
12
13
 
13
14
  push
14
15
  .command('block')
16
+ .description('push a block')
15
17
  .argument('<block-id>', 'the name of the block to push to')
16
18
  .argument(
17
19
  '<image uri:tag>',
@@ -4,12 +4,14 @@ import { cliCommand } from '~/services/ContensisCliService';
4
4
  export const makeReleaseCommand = () => {
5
5
  const release = new Command()
6
6
  .command('release')
7
+ .description('release command')
7
8
  .addHelpText('after', `\n`)
8
9
  .showHelpAfterError(true)
9
10
  .exitOverride();
10
11
 
11
12
  release
12
13
  .command('block')
14
+ .description('release a block version')
13
15
  .argument('<block-id>', 'the name of the block to release')
14
16
  .argument('<version>', 'the block version to release')
15
17
  .usage('<block-id> <version>')
@@ -1,17 +1,19 @@
1
1
  import { Command } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
3
  import { shell } from '~/shell';
4
- import { commit, mapContensisOpts } from './globalOptions';
4
+ import { commit, mapContensisOpts, zenql } from './globalOptions';
5
5
 
6
6
  export const makeRemoveCommand = () => {
7
7
  const remove = new Command()
8
8
  .command('remove')
9
+ .description('remove command')
9
10
  .addHelpText('after', `\n`)
10
11
  .showHelpAfterError(true)
11
12
  .exitOverride();
12
13
 
13
14
  remove
14
15
  .command('project')
16
+ .description('remove an entire project')
15
17
  .argument('<projectId>', 'the project id to delete')
16
18
  .usage('<projectId>')
17
19
  .addHelpText('after', `\n`)
@@ -22,8 +24,10 @@ export const makeRemoveCommand = () => {
22
24
  ).SetProject(projectId);
23
25
  if (project) await shell().restart();
24
26
  });
27
+
25
28
  remove
26
29
  .command('key')
30
+ .description('remove api key')
27
31
  .argument('<id>', 'the id of the API key to delete')
28
32
  .usage('<id>')
29
33
  .addHelpText(
@@ -39,6 +43,7 @@ Example call:
39
43
 
40
44
  remove
41
45
  .command('components')
46
+ .description('delete components')
42
47
  .argument('<id...>', 'the id(s) of the components to delete')
43
48
  .addOption(commit)
44
49
  .usage('<id> [--commit]')
@@ -58,6 +63,7 @@ Example call:
58
63
 
59
64
  remove
60
65
  .command('contenttypes')
66
+ .description('delete content types')
61
67
  .argument('<id...>', 'the id(s) of the content types to delete')
62
68
  .addOption(commit)
63
69
  .usage('<id> [--commit]')
@@ -5,22 +5,79 @@ import { shell } from '~/shell';
5
5
  export const makeSetCommand = () => {
6
6
  const set = new Command()
7
7
  .command('set')
8
+ .description('set command')
8
9
  .addHelpText('after', `\n`)
9
10
  .showHelpAfterError(true)
10
11
  .exitOverride();
11
- set
12
+
13
+ const project = set
12
14
  .command('project')
15
+ .description('set current working project')
13
16
  .argument('<projectId>', 'the project id to work with')
14
17
  .usage('<projectId>')
15
- .addHelpText('after', `\n`)
18
+ .addHelpText(
19
+ 'after',
20
+ `
21
+ Example call:
22
+ > set project website\n`
23
+ )
16
24
  .action(async projectId => {
17
- const project = cliCommand(['set', 'project', projectId]).SetProject(
18
- projectId
19
- );
20
- if (project) await shell().restart();
25
+ const nextProjectId = cliCommand([
26
+ 'set',
27
+ 'project',
28
+ projectId,
29
+ ]).SetProject(projectId);
30
+ if (nextProjectId) await shell().restart();
21
31
  });
32
+
33
+ project
34
+ .command('name')
35
+ .description('update project name')
36
+ .argument('<"Project name">', 'update the current project name')
37
+ .usage('<"Project name">')
38
+ .addHelpText(
39
+ 'after',
40
+ `
41
+ Example call:
42
+ > set project name "Project name"\n`
43
+ )
44
+ .action(async (name: string, opts) => {
45
+ const success = await cliCommand(
46
+ ['set', 'project', 'name'],
47
+ opts
48
+ ).UpdateProject({
49
+ name,
50
+ });
51
+ if (success) await shell().restart();
52
+ });
53
+
54
+ project
55
+ .command('description')
56
+ .description('update project description')
57
+ .argument(
58
+ '<"Project description">',
59
+ 'update the current project description'
60
+ )
61
+ .usage('<"Project description">')
62
+ .addHelpText(
63
+ 'after',
64
+ `
65
+ Example call:
66
+ > set project description "Description of project"\n`
67
+ )
68
+ .action(async (description: string, opts) => {
69
+ const success = await cliCommand(
70
+ ['set', 'project', 'description'],
71
+ opts
72
+ ).UpdateProject({
73
+ description,
74
+ });
75
+ if (success) await shell().restart();
76
+ });
77
+
22
78
  set
23
79
  .command('version')
80
+ .description('set content version')
24
81
  .addArgument(
25
82
  new Argument('<versionStatus>', 'content version status')
26
83
  .choices(['latest', 'published'])
@@ -643,6 +643,32 @@ class ContensisCli {
643
643
  }
644
644
  };
645
645
 
646
+ PrintProject = async (projectId = this.currentProject) => {
647
+ const { log, messages, session } = this;
648
+ const contensis = await this.ConnectContensis();
649
+
650
+ if (contensis) {
651
+ // Retrieve projects list for env
652
+ const [projectsErr, projects] = await to(
653
+ contensis.projects.GetSourceProjects()
654
+ );
655
+
656
+ const foundProject = projects?.find(
657
+ p => p.id.toLowerCase() === projectId.toLowerCase()
658
+ );
659
+
660
+ if (foundProject) {
661
+ log.raw('');
662
+ this.HandleFormattingAndOutput(foundProject, log.object);
663
+ }
664
+
665
+ if (projectsErr) {
666
+ log.error(messages.projects.noList());
667
+ log.error(projectsErr.message);
668
+ }
669
+ }
670
+ };
671
+
646
672
  SetProject = (projectId = 'website') => {
647
673
  const { env, log, messages, session } = this;
648
674
  let nextProjectId: string | undefined;
@@ -811,25 +837,28 @@ class ContensisCli {
811
837
  }
812
838
  };
813
839
 
814
- UpdateProject = async (project: Project) => {
815
- const { currentEnv, log, messages } = this;
840
+ UpdateProject = async (project: Partial<Project>) => {
841
+ const { currentEnv, currentProject, log, messages } = this;
816
842
  const contensis = await this.ConnectContensis();
817
843
 
818
844
  if (contensis) {
819
- const [err, updated] = await contensis.projects.UpdateProject(project);
845
+ const [err, updated] = await contensis.projects.UpdateProject({
846
+ id: currentProject,
847
+ ...project,
848
+ });
820
849
 
821
850
  if (updated) {
822
- log.success(messages.projects.updated(currentEnv, project.id));
851
+ log.success(messages.projects.updated(currentEnv, currentProject));
823
852
 
824
- this.HandleFormattingAndOutput(updated, () => {
825
- // print the projects to console
826
- this.PrintProjects();
827
- });
828
- return project.id;
853
+ this.HandleFormattingAndOutput(updated, log.object);
854
+ return updated.id;
829
855
  }
830
856
 
831
857
  if (err) {
832
- log.error(messages.projects.failedUpdate(currentEnv, project.id), err);
858
+ log.error(
859
+ messages.projects.failedUpdate(currentEnv, currentProject),
860
+ err
861
+ );
833
862
  }
834
863
  }
835
864
  };
package/src/shell.ts CHANGED
@@ -143,6 +143,7 @@ class ContensisShell {
143
143
  'get component',
144
144
  'get entries',
145
145
  'get model',
146
+ 'get project',
146
147
  'get version',
147
148
  'import contenttypes',
148
149
  'import components',
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.0.0-beta.46";
1
+ export const LIB_VERSION = "1.0.0-beta.48";