contensis-cli 1.0.0-beta.38 → 1.0.0-beta.40

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.
Files changed (58) hide show
  1. package/dist/commands/create.js +4 -2
  2. package/dist/commands/create.js.map +2 -2
  3. package/dist/commands/diff.js +57 -0
  4. package/dist/commands/diff.js.map +7 -0
  5. package/dist/commands/get.js +40 -11
  6. package/dist/commands/get.js.map +2 -2
  7. package/dist/commands/globalOptions.js +4 -3
  8. package/dist/commands/globalOptions.js.map +2 -2
  9. package/dist/commands/import.js +31 -5
  10. package/dist/commands/import.js.map +2 -2
  11. package/dist/commands/index.js +6 -0
  12. package/dist/commands/index.js.map +2 -2
  13. package/dist/commands/list.js +19 -8
  14. package/dist/commands/list.js.map +2 -2
  15. package/dist/commands/push.js +2 -1
  16. package/dist/commands/push.js.map +2 -2
  17. package/dist/commands/release.js +2 -1
  18. package/dist/commands/release.js.map +2 -2
  19. package/dist/commands/remove.js +6 -4
  20. package/dist/commands/remove.js.map +2 -2
  21. package/dist/commands/set.js +6 -3
  22. package/dist/commands/set.js.map +2 -2
  23. package/dist/localisation/en-GB.js +43 -24
  24. package/dist/localisation/en-GB.js.map +2 -2
  25. package/dist/providers/SessionCacheProvider.js +2 -2
  26. package/dist/providers/SessionCacheProvider.js.map +2 -2
  27. package/dist/providers/file-provider.js +1 -1
  28. package/dist/providers/file-provider.js.map +2 -2
  29. package/dist/services/ContensisCliService.js +240 -72
  30. package/dist/services/ContensisCliService.js.map +3 -3
  31. package/dist/shell.js +4 -1
  32. package/dist/shell.js.map +2 -2
  33. package/dist/util/console.printer.js +87 -4
  34. package/dist/util/console.printer.js.map +2 -2
  35. package/dist/util/logger.js +45 -13
  36. package/dist/util/logger.js.map +2 -2
  37. package/dist/version.js +1 -1
  38. package/dist/version.js.map +1 -1
  39. package/package.json +2 -2
  40. package/src/commands/create.ts +2 -0
  41. package/src/commands/diff.ts +39 -0
  42. package/src/commands/get.ts +48 -4
  43. package/src/commands/globalOptions.ts +5 -4
  44. package/src/commands/import.ts +36 -2
  45. package/src/commands/index.ts +6 -0
  46. package/src/commands/list.ts +34 -9
  47. package/src/commands/push.ts +1 -0
  48. package/src/commands/release.ts +1 -0
  49. package/src/commands/remove.ts +4 -2
  50. package/src/commands/set.ts +3 -0
  51. package/src/localisation/en-GB.ts +58 -33
  52. package/src/providers/SessionCacheProvider.ts +3 -2
  53. package/src/providers/file-provider.ts +2 -1
  54. package/src/services/ContensisCliService.ts +301 -84
  55. package/src/shell.ts +4 -2
  56. package/src/util/console.printer.ts +100 -3
  57. package/src/util/logger.ts +84 -15
  58. package/src/version.ts +1 -1
@@ -1,20 +1,16 @@
1
1
  import { Command } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
3
 
4
- // projects
5
- // content types
6
- // components
7
- // api keys
8
- // roles
9
- // webhooks
10
4
  export const makeListCommand = () => {
11
5
  const list = new Command()
12
6
  .command('list')
7
+ .addHelpText('after', `\n`)
13
8
  .showHelpAfterError(true)
14
9
  .exitOverride();
15
10
 
16
11
  list
17
12
  .command('envs')
13
+ .description('List all previously connected environments')
18
14
  .addHelpText(
19
15
  'after',
20
16
  `
@@ -25,11 +21,31 @@ Example call:
25
21
  .action(opts => {
26
22
  cliCommand(['list', 'envs'], opts).PrintEnvironments();
27
23
  });
28
- list.command('projects').action(async opts => {
29
- await cliCommand(['list', 'projects'], opts).PrintProjects();
30
- });
24
+
25
+ list
26
+ .command('projects')
27
+ .description('Print list of projects')
28
+ .action(async opts => {
29
+ await cliCommand(['list', 'projects'], opts).PrintProjects();
30
+ });
31
+
32
+ list
33
+ .command('models')
34
+ .description('Print list of content models')
35
+ .addHelpText(
36
+ 'after',
37
+ `
38
+ Example call:
39
+ > list models
40
+ `
41
+ )
42
+ .action(async opts => {
43
+ await cliCommand(['list', 'models'], opts).PrintContentModels();
44
+ });
45
+
31
46
  list
32
47
  .command('contenttypes')
48
+ .description('Print list of content types')
33
49
  .addHelpText(
34
50
  'after',
35
51
  `
@@ -40,8 +56,10 @@ Example call:
40
56
  .action(async opts => {
41
57
  await cliCommand(['list', 'contenttypes'], opts).PrintContentTypes();
42
58
  });
59
+
43
60
  list
44
61
  .command('components')
62
+ .description('Print list of components')
45
63
  .addHelpText(
46
64
  'after',
47
65
  `
@@ -52,8 +70,10 @@ Example call:
52
70
  .action(async opts => {
53
71
  await cliCommand(['list', 'components'], opts).PrintComponents();
54
72
  });
73
+
55
74
  list
56
75
  .command('blocks')
76
+ .description('Print list of content blocks')
57
77
  .addHelpText(
58
78
  'after',
59
79
  `
@@ -64,8 +84,10 @@ Example call:
64
84
  .action(async opts => {
65
85
  await cliCommand(['list', 'blocks'], opts).PrintBlocks();
66
86
  });
87
+
67
88
  list
68
89
  .command('keys')
90
+ .description('Print list of API keys')
69
91
  .addHelpText(
70
92
  'after',
71
93
  `
@@ -76,10 +98,13 @@ Example call:
76
98
  .action(async opts => {
77
99
  await cliCommand(['list', 'keys'], opts).PrintApiKeys();
78
100
  });
101
+
79
102
  list
80
103
  .command('webhooks')
104
+ .description('Print list of webhooks')
81
105
  .argument('[name]', 'find webhooks matching the supplied name')
82
106
  .option('-i --id <id...>', 'the subscription id(s) to get')
107
+ .addHelpText('after', `\n`)
83
108
  .action(async (name?: string, { id, ...opts }: any = {}) => {
84
109
  await cliCommand(['list', 'webhooks'], opts).PrintWebhookSubscriptions(
85
110
  id,
@@ -6,6 +6,7 @@ import { cliCommand } from '~/services/ContensisCliService';
6
6
  export const makePushCommand = () => {
7
7
  const push = new Command()
8
8
  .command('push')
9
+ .addHelpText('after', `\n`)
9
10
  .showHelpAfterError(true)
10
11
  .exitOverride();
11
12
 
@@ -4,6 +4,7 @@ import { cliCommand } from '~/services/ContensisCliService';
4
4
  export const makeReleaseCommand = () => {
5
5
  const release = new Command()
6
6
  .command('release')
7
+ .addHelpText('after', `\n`)
7
8
  .showHelpAfterError(true)
8
9
  .exitOverride();
9
10
 
@@ -6,6 +6,7 @@ import { commit, mapContensisOpts } from './globalOptions';
6
6
  export const makeRemoveCommand = () => {
7
7
  const remove = new Command()
8
8
  .command('remove')
9
+ .addHelpText('after', `\n`)
9
10
  .showHelpAfterError(true)
10
11
  .exitOverride();
11
12
 
@@ -13,6 +14,7 @@ export const makeRemoveCommand = () => {
13
14
  .command('project')
14
15
  .argument('<projectId>', 'the project id to delete')
15
16
  .usage('<projectId>')
17
+ .addHelpText('after', `\n`)
16
18
  .action(async (projectId, opts) => {
17
19
  const project = await cliCommand(
18
20
  ['remove', 'project', projectId],
@@ -49,7 +51,7 @@ Example call:
49
51
  )
50
52
  .action(async (id: string[], opts) => {
51
53
  await cliCommand(
52
- ['remove', 'components', id.join(', ')],
54
+ ['remove', 'components', id.join(' ')],
53
55
  opts
54
56
  ).RemoveComponents(id, opts.commit);
55
57
  });
@@ -68,7 +70,7 @@ Example call:
68
70
  )
69
71
  .action(async (id: string[], opts) => {
70
72
  await cliCommand(
71
- ['remove', 'contenttypes', id.join(', ')],
73
+ ['remove', 'contenttypes', id.join(' ')],
72
74
  opts
73
75
  ).RemoveContentTypes(id, opts.commit);
74
76
  });
@@ -5,12 +5,14 @@ import { shell } from '~/shell';
5
5
  export const makeSetCommand = () => {
6
6
  const set = new Command()
7
7
  .command('set')
8
+ .addHelpText('after', `\n`)
8
9
  .showHelpAfterError(true)
9
10
  .exitOverride();
10
11
  set
11
12
  .command('project')
12
13
  .argument('<projectId>', 'the project id to work with')
13
14
  .usage('<projectId>')
15
+ .addHelpText('after', `\n`)
14
16
  .action(async projectId => {
15
17
  const project = cliCommand(['set', 'project', projectId]).SetProject(
16
18
  projectId
@@ -25,6 +27,7 @@ export const makeSetCommand = () => {
25
27
  .default('latest')
26
28
  )
27
29
  .usage('<latest/published>')
30
+ .addHelpText('after', `\n`)
28
31
  .action(async versionStatus => {
29
32
  const success = cliCommand(['set', 'version', versionStatus]).SetVersion(
30
33
  versionStatus
@@ -1,4 +1,8 @@
1
- import { BlockRunningStatus, MigrateStatus } from 'migratortron';
1
+ import {
2
+ BlockRunningStatus,
3
+ MigrateModelsResult,
4
+ MigrateStatus,
5
+ } from 'migratortron';
2
6
  import { Logger } from '~/util/logger';
3
7
 
4
8
  export const LogMessages = {
@@ -94,16 +98,56 @@ export const LogMessages = {
94
98
  tip: () =>
95
99
  `You need to set your current working project with "set project {projectId}"`,
96
100
  },
101
+ migrate: {
102
+ models: {
103
+ result: (
104
+ status: keyof MigrateModelsResult['project']['contentTypes']
105
+ ) => {
106
+ switch (status) {
107
+ case 'created':
108
+ case 'updated':
109
+ return Logger.successText;
110
+ case 'errors':
111
+ return Logger.errorText;
112
+ default:
113
+ return Logger.infoText;
114
+ }
115
+ },
116
+ },
117
+ status: (status: MigrateStatus) => {
118
+ switch (status) {
119
+ case 'no change':
120
+ return Logger.successText;
121
+ case 'create':
122
+ case 'two-pass':
123
+ case 'update':
124
+ case 'delete':
125
+ return Logger.warningText;
126
+ case 'error':
127
+ case 'not found':
128
+ return Logger.errorText;
129
+ default:
130
+ return Logger.infoText;
131
+ }
132
+ },
133
+ },
134
+ models: {
135
+ list: (projectId: string) => `Content models in "${projectId}":`,
136
+ noList: (projectId: string) =>
137
+ `[${projectId}] Cannot retrieve content models`,
138
+ get: (projectId: string, id: string) =>
139
+ `[${projectId}] Content models ${Logger.infoText(`[ ${id} ]`)}`,
140
+ failedGet: (projectId: string, id: string) =>
141
+ `[${projectId}] Unable to get content models "${id}"`,
142
+ },
97
143
  contenttypes: {
98
144
  list: (projectId: string) => `Content types in "${projectId}":`,
99
- noList: (projectId: string) =>
100
- `[${projectId}] Cannot retrieve content types list`,
101
- get: (projectId: string, contentTypeId: string) =>
102
- `[${projectId}] Content type "${contentTypeId}"`,
103
- failedGet: (projectId: string, contentTypeId: string) =>
104
- `[${projectId}] Unable to get content type "${contentTypeId}"`,
105
- created: (projectId: string, componentId: string, status?: string) =>
106
- `[${projectId}] Content type ${status}d "${componentId}"`,
145
+ get: (projectId: string, id: string) =>
146
+ `[${projectId}] Content type "${id}"`,
147
+ failedGet: (projectId: string, id: string) =>
148
+ `[${projectId}] Unable to get content type "${id}"`,
149
+ created: (projectId: string, id: string, status?: string) =>
150
+ `[${projectId}] Content type ${status}d "${id}"`,
107
151
  removed: (env: string, id: string, commit: boolean) =>
108
152
  `[${env}] ${commit ? `Deleted` : `Will delete`} content type "${id}"`,
109
153
  failedRemove: (env: string, id: string) =>
@@ -111,14 +155,11 @@ export const LogMessages = {
111
155
  },
112
156
  components: {
113
157
  list: (projectId: string) => `Components in "${projectId}":`,
114
- noList: (projectId: string) =>
115
- `[${projectId}] Cannot retrieve components list`,
116
- get: (projectId: string, componentId: string) =>
117
- `[${projectId}] Component "${componentId}"`,
118
- failedGet: (projectId: string, componentId: string) =>
119
- `[${projectId}] Unable to get component "${componentId}"`,
120
- created: (projectId: string, componentId: string, status?: string) =>
121
- `[${projectId}] Component ${status}d "${componentId}"`,
158
+ get: (projectId: string, id: string) => `[${projectId}] Component "${id}"`,
159
+ failedGet: (projectId: string, id: string) =>
160
+ `[${projectId}] Unable to get component "${id}"`,
161
+ created: (projectId: string, id: string, status?: string) =>
162
+ `[${projectId}] Component ${status}d "${id}"`,
122
163
  removed: (env: string, id: string, commit: boolean) =>
123
164
  `[${env}] ${commit ? `Deleted` : `Will delete`} component "${id}"`,
124
165
  failedRemove: (env: string, id: string) =>
@@ -133,22 +174,6 @@ export const LogMessages = {
133
174
  `No Contensis environment set, connect to your Contensis cloud instance using "contensis connect {cms alias}"`,
134
175
  },
135
176
  entries: {
136
- migrateStatus: (status: MigrateStatus) => {
137
- switch (status) {
138
- case 'no change':
139
- return Logger.successText;
140
- case 'create':
141
- case 'two-pass':
142
- case 'update':
143
- case 'delete':
144
- return Logger.warningText;
145
- case 'error':
146
- case 'not found':
147
- return Logger.errorText;
148
- default:
149
- return Logger.infoText;
150
- }
151
- },
152
177
  removed: (env: string, id: string, commit: boolean) =>
153
178
  `[${env}] ${commit ? `Deleted` : `Will delete`} entry "${id}"`,
154
179
  failedRemove: (env: string, id: string) =>
@@ -72,7 +72,8 @@ class SessionCacheProvider {
72
72
 
73
73
  UpdateEnv = (
74
74
  updateContent: Partial<EnvironmentCache>,
75
- env = this.cache.currentEnvironment
75
+ env = this.cache.currentEnvironment,
76
+ setCurrentEnv = true
76
77
  ) => {
77
78
  try {
78
79
  const environment = this.cache.environments[env || ''];
@@ -82,7 +83,7 @@ class SessionCacheProvider {
82
83
  ...updateContent,
83
84
  };
84
85
  this.Update({
85
- currentEnvironment: env,
86
+ currentEnvironment: setCurrentEnv ? env : this.cache.currentEnvironment,
86
87
  environments: this.cache.environments,
87
88
  });
88
89
  } catch (ex: any) {
@@ -69,4 +69,5 @@ export const checkDir = (filePath: string) => {
69
69
  fs.mkdirSync(directoryPath, { recursive: true });
70
70
  };
71
71
 
72
- export const localPath = (filePath: string) => path.join(appRoot, filePath);
72
+ export const localPath = (filePath: string) =>
73
+ path.isAbsolute(filePath) ? filePath : path.join(appRoot, filePath);