contensis-cli 1.0.0-beta.9 → 1.0.0-beta.90

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 (125) hide show
  1. package/README.md +1146 -78
  2. package/cli.js +3 -0
  3. package/dist/commands/connect.js +3 -3
  4. package/dist/commands/connect.js.map +2 -2
  5. package/dist/commands/create.js +45 -10
  6. package/dist/commands/create.js.map +2 -2
  7. package/dist/commands/dev.js +75 -0
  8. package/dist/commands/dev.js.map +7 -0
  9. package/dist/commands/diff.js +57 -0
  10. package/dist/commands/diff.js.map +7 -0
  11. package/dist/commands/execute.js +103 -0
  12. package/dist/commands/execute.js.map +7 -0
  13. package/dist/commands/get.js +169 -32
  14. package/dist/commands/get.js.map +3 -3
  15. package/dist/commands/globalOptions.js +37 -12
  16. package/dist/commands/globalOptions.js.map +2 -2
  17. package/dist/commands/import.js +47 -12
  18. package/dist/commands/import.js.map +2 -2
  19. package/dist/commands/index.js +22 -2
  20. package/dist/commands/index.js.map +2 -2
  21. package/dist/commands/list.js +53 -10
  22. package/dist/commands/list.js.map +2 -2
  23. package/dist/commands/login.js +2 -2
  24. package/dist/commands/login.js.map +2 -2
  25. package/dist/commands/push.js +17 -13
  26. package/dist/commands/push.js.map +2 -2
  27. package/dist/commands/remove.js +51 -8
  28. package/dist/commands/remove.js.map +2 -2
  29. package/dist/commands/set.js +139 -12
  30. package/dist/commands/set.js.map +2 -2
  31. package/dist/index.js +1 -1
  32. package/dist/index.js.map +2 -2
  33. package/dist/localisation/en-GB.js +259 -49
  34. package/dist/localisation/en-GB.js.map +2 -2
  35. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +56 -0
  36. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +7 -0
  37. package/dist/mappers/DevInit-to-CIWorkflow.js +127 -0
  38. package/dist/mappers/DevInit-to-CIWorkflow.js.map +7 -0
  39. package/dist/mappers/DevInit-to-RolePermissions.js +54 -0
  40. package/dist/mappers/DevInit-to-RolePermissions.js.map +7 -0
  41. package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js +56 -0
  42. package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js.map +7 -0
  43. package/dist/models/CliService.d.js +17 -0
  44. package/dist/models/CliService.d.js.map +7 -0
  45. package/dist/models/DevService.d.js +17 -0
  46. package/dist/models/DevService.d.js.map +7 -0
  47. package/dist/providers/CredentialProvider.js +46 -14
  48. package/dist/providers/CredentialProvider.js.map +3 -3
  49. package/dist/providers/SessionCacheProvider.js +21 -1
  50. package/dist/providers/SessionCacheProvider.js.map +2 -2
  51. package/dist/providers/file-provider.js +12 -6
  52. package/dist/providers/file-provider.js.map +3 -3
  53. package/dist/services/ContensisCliService.js +1148 -421
  54. package/dist/services/ContensisCliService.js.map +3 -3
  55. package/dist/services/ContensisDevService.js +309 -0
  56. package/dist/services/ContensisDevService.js.map +7 -0
  57. package/dist/services/ContensisRoleService.js +87 -0
  58. package/dist/services/ContensisRoleService.js.map +7 -0
  59. package/dist/shell.js +58 -18
  60. package/dist/shell.js.map +3 -3
  61. package/dist/util/console.printer.js +171 -55
  62. package/dist/util/console.printer.js.map +2 -2
  63. package/dist/util/diff.js +102 -0
  64. package/dist/util/diff.js.map +7 -0
  65. package/dist/util/dotenv.js +57 -0
  66. package/dist/util/dotenv.js.map +7 -0
  67. package/dist/util/find.js +31 -0
  68. package/dist/util/find.js.map +7 -0
  69. package/dist/util/git.js +126 -0
  70. package/dist/util/git.js.map +7 -0
  71. package/dist/util/index.js +8 -2
  72. package/dist/util/index.js.map +3 -3
  73. package/dist/util/logger.js +90 -29
  74. package/dist/util/logger.js.map +3 -3
  75. package/dist/util/os.js +39 -0
  76. package/dist/util/os.js.map +7 -0
  77. package/dist/util/timers.js +49 -0
  78. package/dist/util/timers.js.map +7 -0
  79. package/dist/util/yaml.js +45 -0
  80. package/dist/util/yaml.js.map +7 -0
  81. package/dist/version.js +1 -1
  82. package/dist/version.js.map +1 -1
  83. package/esbuild.config.js +3 -1
  84. package/package.json +12 -3
  85. package/src/commands/connect.ts +3 -2
  86. package/src/commands/create.ts +61 -8
  87. package/src/commands/dev.ts +69 -0
  88. package/src/commands/diff.ts +41 -0
  89. package/src/commands/execute.ts +117 -0
  90. package/src/commands/get.ts +242 -28
  91. package/src/commands/globalOptions.ts +42 -12
  92. package/src/commands/import.ts +58 -8
  93. package/src/commands/index.ts +22 -1
  94. package/src/commands/list.ts +85 -11
  95. package/src/commands/login.ts +2 -1
  96. package/src/commands/push.ts +18 -11
  97. package/src/commands/remove.ts +66 -4
  98. package/src/commands/set.ts +189 -9
  99. package/src/index.ts +1 -4
  100. package/src/localisation/en-GB.ts +374 -66
  101. package/src/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.ts +44 -0
  102. package/src/mappers/DevInit-to-CIWorkflow.ts +150 -0
  103. package/src/mappers/DevInit-to-RolePermissions.ts +33 -0
  104. package/src/mappers/DevRequests-to-RequestHanderSiteConfigYaml.ts +44 -0
  105. package/src/models/CliService.d.ts +36 -0
  106. package/src/models/DevService.d.ts +5 -0
  107. package/src/models/JsModules.d.ts +1 -0
  108. package/src/providers/CredentialProvider.ts +51 -18
  109. package/src/providers/SessionCacheProvider.ts +29 -2
  110. package/src/providers/file-provider.ts +17 -6
  111. package/src/services/ContensisCliService.ts +1458 -518
  112. package/src/services/ContensisDevService.ts +365 -0
  113. package/src/services/ContensisRoleService.ts +76 -0
  114. package/src/shell.ts +68 -18
  115. package/src/util/console.printer.ts +240 -78
  116. package/src/util/diff.ts +113 -0
  117. package/src/util/dotenv.ts +37 -0
  118. package/src/util/find.ts +8 -0
  119. package/src/util/git.ts +130 -0
  120. package/src/util/index.ts +16 -7
  121. package/src/util/logger.ts +145 -31
  122. package/src/util/os.ts +7 -0
  123. package/src/util/timers.ts +24 -0
  124. package/src/util/yaml.ts +13 -0
  125. package/src/version.ts +1 -1
@@ -1,15 +1,124 @@
1
- import { Argument, Command } from 'commander';
1
+ import { Argument, Command, Option } from 'commander';
2
+ import { merge } from 'lodash';
2
3
  import { cliCommand } from '~/services/ContensisCliService';
3
- import { mapContensisOpts } from './globalOptions';
4
+ import {
5
+ addGlobalOptions,
6
+ assetTypes,
7
+ contentTypes,
8
+ entryId,
9
+ mapContensisOpts,
10
+ zenql,
11
+ } from './globalOptions';
4
12
 
5
13
  export const makeGetCommand = () => {
6
14
  const program = new Command()
7
15
  .command('get')
16
+ .description('get command')
17
+ .addHelpText('after', `\n`)
8
18
  .showHelpAfterError(true)
9
19
  .exitOverride();
10
20
 
21
+ program
22
+ .command('version')
23
+ .description('get current Contensis version')
24
+ .addHelpText(
25
+ 'after',
26
+ `
27
+ Example call:
28
+ > version
29
+ `
30
+ )
31
+ .action(async opts => {
32
+ await cliCommand(['get', 'version'], opts).PrintContensisVersion();
33
+ });
34
+
35
+ program
36
+ .command('token')
37
+ .description('show a bearer token for the currently logged in user')
38
+ .addHelpText(
39
+ 'after',
40
+ `
41
+ Example call:
42
+ > get token
43
+ `
44
+ )
45
+ .action(async opts => {
46
+ await cliCommand(['get', 'token'], opts).PrintBearerToken();
47
+ });
48
+
49
+ program
50
+ .command('project')
51
+ .description('get a project')
52
+ .argument('[projectId]', 'id of the project to get (default: current)')
53
+ .addHelpText(
54
+ 'after',
55
+ `
56
+ Example call:
57
+ > get project website
58
+ `
59
+ )
60
+ .action(async (projectId: string, opts) => {
61
+ await cliCommand(['get', 'project', projectId], opts).PrintProject(
62
+ projectId
63
+ );
64
+ });
65
+
66
+ program
67
+ .command('role')
68
+ .description('get a role')
69
+ .argument('<roleNameOrId>', 'id or name of the role to get')
70
+ .addHelpText(
71
+ 'after',
72
+ `
73
+ Example call:
74
+ > get role "entry admin"
75
+ `
76
+ )
77
+ .action(async (roleNameOrId: string, opts) => {
78
+ await cliCommand(['get', 'role', roleNameOrId], opts).PrintRole(
79
+ roleNameOrId
80
+ );
81
+ });
82
+
83
+ program
84
+ .command('webhook')
85
+ .description('get a webhook')
86
+ .argument('<webhookNameOrId...>', 'id or name of the webhook(s) to get')
87
+ .addHelpText(
88
+ 'after',
89
+ `
90
+ Example call:
91
+ > get webhook "Slack notification"
92
+ `
93
+ )
94
+ .action(async (webhookNameOrId: string[], opts) => {
95
+ await cliCommand(
96
+ ['get', 'webhook', webhookNameOrId.join(' ')],
97
+ opts
98
+ ).PrintWebhookSubscriptions(webhookNameOrId);
99
+ });
100
+
101
+ program
102
+ .command('model')
103
+ .description('get a content model')
104
+ .argument('<contentTypeId...>', 'ids of the content models to get')
105
+ .addHelpText(
106
+ 'after',
107
+ `
108
+ Example call:
109
+ > get model podcast podcastLinks
110
+ `
111
+ )
112
+ .action(async (modelIds: string[], opts) => {
113
+ await cliCommand(
114
+ ['get', 'model', modelIds.join(' ')],
115
+ opts
116
+ ).PrintContentModels(modelIds);
117
+ });
118
+
11
119
  program
12
120
  .command('contenttype')
121
+ .description('get a content type')
13
122
  .argument('<contentTypeId>', 'the API id of the content type to get')
14
123
  .addHelpText(
15
124
  'after',
@@ -19,12 +128,15 @@ Example call:
19
128
  `
20
129
  )
21
130
  .action(async (contentTypeId: string, opts) => {
22
- await cliCommand(['get', 'contenttype'], opts).PrintContentType(
23
- contentTypeId
24
- );
131
+ await cliCommand(
132
+ ['get', 'contenttype', contentTypeId],
133
+ opts
134
+ ).PrintContentType(contentTypeId);
25
135
  });
136
+
26
137
  program
27
138
  .command('component')
139
+ .description('get a component')
28
140
  .argument('<componentId>', 'the API id of the component to get')
29
141
  .addHelpText(
30
142
  'after',
@@ -34,32 +146,84 @@ Example call:
34
146
  `
35
147
  )
36
148
  .action(async (componentId: string, opts) => {
37
- await cliCommand(['get', 'component'], opts).PrintComponent(componentId);
149
+ await cliCommand(['get', 'component', componentId], opts).PrintComponent(
150
+ componentId
151
+ );
152
+ });
153
+
154
+ const sharedGetEntryOptions = (command: Command) =>
155
+ command
156
+ .addOption(entryId)
157
+ .addOption(zenql)
158
+ .addOption(
159
+ new Option(
160
+ '-fi --fields <fields...>',
161
+ 'limit the output fields on returned entries'
162
+ )
163
+ )
164
+ .addOption(
165
+ new Option(
166
+ '-ob --order-by <orderBy...>',
167
+ 'field name(s) to order the results by (prefix "-" for descending)'
168
+ )
169
+ );
170
+
171
+ sharedGetEntryOptions(
172
+ program
173
+ .command('assets')
174
+ .description('get asset entries')
175
+ .argument(
176
+ '[search phrase]',
177
+ 'get assets with the search phrase, use quotes for multiple words'
178
+ )
179
+ .addOption(assetTypes)
180
+ )
181
+ .option('-l --paths <paths...>', 'get assets under the given path(s)')
182
+ .addHelpText(
183
+ 'after',
184
+ `
185
+ Example call:
186
+ > get assets --zenql "sys.contentTypeId = blog" --fields sys.id sys.properties.filePath sys.properties.filename
187
+ `
188
+ )
189
+ .action(async (phrase: string, opts) => {
190
+ // Maintaining a separate command for assets vs entries
191
+ // allows us to offer up more options when dealing with just assets
192
+ await cliCommand(
193
+ ['get', 'assets'],
194
+ opts,
195
+ mapContensisOpts({ dataFormat: 'asset', phrase, ...opts })
196
+ ).GetEntries({});
38
197
  });
198
+
199
+ sharedGetEntryOptions(
39
200
  program
40
201
  .command('entries')
202
+ .description('get entries')
41
203
  .argument(
42
204
  '[search phrase]',
43
205
  'get entries with the search phrase, use quotes for multiple words'
44
206
  )
45
- .option('-i --id <id...>', 'the entry id to get')
207
+ .addOption(contentTypes)
46
208
  .option(
47
- '-d, --dependents',
209
+ '-d --dependents',
48
210
  'find and return any dependencies of all found entries'
49
211
  )
50
- .option(
51
- '-fi, --fields <fields...>',
52
- 'limit the output fields on returned entries'
212
+ )
213
+ .addOption(
214
+ new Option(
215
+ '--data-format <dataFormat>',
216
+ 'find and return entries of a specific data format'
53
217
  )
54
- .option(
55
- '-q, --zenql <zenql>',
56
- 'get entries with a supplied ZenQL statement'
218
+ .choices(['entry', 'asset', 'webpage'])
219
+ .default('entry')
57
220
  )
58
221
  .addHelpText(
59
222
  'after',
60
223
  `
61
224
  Example call:
62
225
  > get entries --zenql "sys.contentTypeId = blog" --fields entryTitle entryDescription sys.id --output ./blog-posts.csv --format csv
226
+ > get entries --content-type blog --fields entryTitle sys.version.modified --order-by -sys.version.modified
63
227
  `
64
228
  )
65
229
  .action(async (phrase: string, opts, cmd) => {
@@ -74,65 +238,115 @@ Example call:
74
238
  });
75
239
  });
76
240
 
241
+ program
242
+ .command('nodes')
243
+ .description('get nodes')
244
+ .argument('[root]', 'get node(s) from the specified path e.g. /blog', '/')
245
+ .option(
246
+ '-d --depth <depth>',
247
+ 'get nodes with children to a specified depth',
248
+ '0'
249
+ )
250
+ .addHelpText(
251
+ 'after',
252
+ `
253
+ Example call:
254
+ > get nodes /blog --depth 1
255
+ `
256
+ )
257
+ .action(async (root: string, opts) => {
258
+ await cliCommand(['get', 'nodes'], opts, mapContensisOpts(opts)).GetNodes(
259
+ root,
260
+ opts.depth
261
+ );
262
+ });
263
+
77
264
  const block = program
78
265
  .command('block')
266
+ .description('get a block or block version')
79
267
  .argument('[blockId]', 'the block to get version details for')
80
268
  .argument(
81
269
  '[branch]',
82
270
  'the branch of the block to get version details for',
83
- 'main'
271
+ 'default'
84
272
  )
85
273
  .argument(
86
274
  '[version]',
87
275
  'get a specific version of the block pushed to the specified branch'
88
276
  )
277
+ .addHelpText(
278
+ 'after',
279
+ `
280
+ Example call:
281
+ > get block contensis-website
282
+ > get block contensis-website develop latest
283
+ `
284
+ )
89
285
  .action(async (blockId: string, branch: string, version: string, opts) => {
90
- await cliCommand(['get', 'block'], opts).PrintBlockVersions(
286
+ await cliCommand(['get', 'block', blockId], opts).PrintBlockVersions(
91
287
  blockId,
92
288
  branch,
93
289
  version
94
290
  );
95
291
  });
96
292
 
97
- const dataCenter = new Argument(
98
- '[dataCenter]',
99
- 'the datacentre of the block to get logs for'
100
- )
101
- .choices(['hq', 'london', 'manchester'])
102
- .default('hq');
103
-
104
293
  block
105
294
  .command('logs')
295
+ .description('get logs for a block')
106
296
  .argument('[blockId]', 'the block to get version logs for')
107
297
  .argument(
108
298
  '[branch]',
109
299
  'the branch of the block to get version details for',
110
- 'main'
300
+ 'default'
111
301
  )
112
302
  .argument(
113
303
  '[version]',
114
304
  'the version of the block pushed to the branch to get logs for',
115
305
  'latest'
116
306
  )
117
- .addArgument(dataCenter)
307
+ .addArgument(
308
+ new Argument(
309
+ '[dataCenter]',
310
+ 'the datacentre of the block to get logs for'
311
+ )
312
+ .choices(['hq', 'london', 'manchester', 'all'])
313
+ .default('all')
314
+ )
315
+ .option('-t --follow', 'follow block logs in near realtime', false)
118
316
  .usage('get block logs [blockId] [branch] [version] [dataCenter]')
317
+ .addHelpText(
318
+ 'after',
319
+ `
320
+ Example call:
321
+ > get block logs contensis-website default
322
+ > get block logs contensis-website master latest london --follow
323
+ `
324
+ )
119
325
  .action(
120
326
  async (
121
327
  blockId: string,
122
328
  branch: string,
123
329
  version: string,
124
- dataCenter: 'hq' | 'manchester' | 'london',
330
+ dataCenter: 'hq' | 'manchester' | 'london' | 'all',
125
331
  opts
126
332
  ) => {
127
- await cliCommand(['get', 'block', 'logs'], opts).PrintBlockLogs(
333
+ const parentOpts = block.opts() || {};
334
+ await cliCommand(
335
+ ['get', 'block', 'logs'],
336
+ merge(opts, parentOpts)
337
+ ).PrintBlockLogs(
128
338
  blockId,
129
339
  branch,
130
340
  version,
131
- dataCenter
341
+ dataCenter === 'all' ? undefined : dataCenter,
342
+ opts.follow as boolean
132
343
  );
133
344
  }
134
345
  );
135
346
 
347
+ // Add global opts for inner sub-commands
348
+ addGlobalOptions(block);
349
+
136
350
  return program;
137
351
  };
138
352
 
@@ -3,19 +3,33 @@ import { url } from '~/util';
3
3
 
4
4
  export const mapContensisOpts = (opts: any = {}) => ({
5
5
  source:
6
- opts.sourceCms || opts.sourceProjectId
6
+ opts.sourceAlias || opts.sourceProjectId
7
7
  ? {
8
- url: opts.sourceCms
9
- ? url(opts.sourceCms, 'website').cms
8
+ url: opts.sourceAlias
9
+ ? url(opts.sourceAlias, 'website').cms
10
10
  : (undefined as any),
11
11
  project: opts.sourceProjectId || (undefined as any),
12
12
  }
13
13
  : undefined,
14
+ models: opts.modelIds,
14
15
  query:
15
- opts.id || opts.phrase || opts.fields
16
+ opts.id ||
17
+ opts.entryIds ||
18
+ opts.phrase ||
19
+ opts.fields ||
20
+ opts.orderBy ||
21
+ opts.paths ||
22
+ opts.assetType ||
23
+ opts.contentType ||
24
+ opts.dataFormat
16
25
  ? {
26
+ assetTypes: opts.assetType,
27
+ contentTypeIds: opts.contentType,
28
+ dataFormats: opts.dataFormat ? [opts.dataFormat] : undefined,
17
29
  fields: opts.fields,
18
- includeIds: opts.id,
30
+ includeIds: opts.id || opts.entryIds,
31
+ includePaths: opts.paths,
32
+ orderBy: opts.orderBy,
19
33
  searchTerm: opts.phrase,
20
34
  }
21
35
  : undefined,
@@ -25,12 +39,12 @@ export const mapContensisOpts = (opts: any = {}) => ({
25
39
 
26
40
  /* Output options */
27
41
  const output = new Option(
28
- '-o, --output <output>',
42
+ '-o --output <output>',
29
43
  'save output to a file e.g. --output ./output.txt'
30
44
  );
31
45
 
32
46
  const format = new Option(
33
- '-f, --format <format>',
47
+ '-f --format <format>',
34
48
  'format output as csv, json, xml or table (default)'
35
49
  ).choices(['csv', 'json', 'xml', 'table']);
36
50
 
@@ -64,12 +78,20 @@ const sharedSecret = new Option(
64
78
  );
65
79
 
66
80
  /* Entry get options */
67
- const zenql = new Option(
68
- '-q, --zenql <zenql>',
81
+ export const zenql = new Option(
82
+ '-q --zenql <zenql>',
69
83
  'get entries with a supplied ZenQL statement'
70
84
  );
71
85
 
72
- const entryId = new Option('-i --id <id...>', 'the entry id to get');
86
+ export const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');
87
+ export const contentTypes = new Option(
88
+ '-c --content-type <contentType...>',
89
+ 'get entries of these content type(s)'
90
+ );
91
+ export const assetTypes = new Option(
92
+ '-at --asset-type <assetType...>',
93
+ 'get assets of given content type(s) e.g. image word pdf'
94
+ );
73
95
 
74
96
  /* Import options */
75
97
  export const fromFile = new Option(
@@ -88,7 +110,7 @@ export const fromProject = new Option(
88
110
 
89
111
  export const commit = new Option(
90
112
  '--commit',
91
- 'omit and only add this flag when you are happy with the preview of the import'
113
+ 'add this flag only after you have run a preview of the import and agree with the analysis'
92
114
  ).default(false);
93
115
 
94
116
  export const addConnectOptions = (program: Command) =>
@@ -110,9 +132,17 @@ export const addImportOptions = (program: Command) => {
110
132
  }
111
133
  return program;
112
134
  };
135
+
136
+ export const getEntryOptions = (command: Command) =>
137
+ command
138
+ .addOption(entryId)
139
+ .addOption(zenql)
140
+ .addOption(contentTypes)
141
+ .addOption(assetTypes);
142
+
113
143
  export const addGetEntryOptions = (program: Command) => {
114
144
  for (const command of program.commands) {
115
- command.addOption(entryId).addOption(zenql);
145
+ getEntryOptions(command);
116
146
  }
117
147
  return program;
118
148
  };
@@ -1,20 +1,47 @@
1
- import { Argument, Command } from 'commander';
1
+ import { Command, Option } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
- import { url } from '~/util';
4
3
  import { commit, mapContensisOpts } from './globalOptions';
5
4
 
6
5
  export const makeImportCommand = () => {
7
6
  const program = new Command()
8
7
  .command('import')
8
+ .description('import command')
9
+ .addHelpText('after', `\n`)
9
10
  .showHelpAfterError(true)
10
11
  .exitOverride();
11
12
 
13
+ program
14
+ .command('models')
15
+ .description('import complete content models')
16
+ .argument('[modelIds...]', 'ids of the content models to import (optional)')
17
+ .addOption(commit)
18
+ .addHelpText(
19
+ 'after',
20
+ `
21
+ Example call:
22
+ > import models blogPost --from-file contentmodels-backup.json
23
+ > import models --source-alias example-dev
24
+ `
25
+ )
26
+ .action(async (modelIds: string[], opts) => {
27
+ await cliCommand(
28
+ ['import', 'models', modelIds.join(' ')],
29
+ opts,
30
+ mapContensisOpts({ modelIds, ...opts })
31
+ ).ImportContentModels({
32
+ fromFile: opts.fromFile,
33
+ commit: opts.commit,
34
+ });
35
+ });
36
+
12
37
  program
13
38
  .command('contenttypes')
39
+ .description('import content types')
14
40
  .argument(
15
- '[contentTypeIds]',
41
+ '[contentTypeIds...]',
16
42
  'Optional list of API id(s) of the content type(s) to import'
17
43
  )
44
+ .addOption(commit)
18
45
  .addHelpText(
19
46
  'after',
20
47
  `
@@ -24,7 +51,11 @@ Example call:
24
51
  `
25
52
  )
26
53
  .action(async (contentTypeIds: string[], opts) => {
27
- await cliCommand(['import', 'contenttypes'], opts).ImportContentTypes(
54
+ await cliCommand(
55
+ ['import', 'contenttypes'],
56
+ opts,
57
+ mapContensisOpts({ contentTypeIds, ...opts })
58
+ ).ImportContentTypes(
28
59
  {
29
60
  fromFile: opts.fromFile,
30
61
  commit: opts.commit,
@@ -35,10 +66,12 @@ Example call:
35
66
 
36
67
  program
37
68
  .command('components')
69
+ .description('import components')
38
70
  .argument(
39
- '[componentIds]',
71
+ '[componentIds...]',
40
72
  'Optional list of API id(s) of the component(s) to import'
41
73
  )
74
+ .addOption(commit)
42
75
  .addHelpText(
43
76
  'after',
44
77
  `
@@ -48,7 +81,11 @@ Example call:
48
81
  `
49
82
  )
50
83
  .action(async (componentIds: string[], opts) => {
51
- await cliCommand(['import', 'component'], opts).ImportComponents(
84
+ await cliCommand(
85
+ ['import', 'component'],
86
+ opts,
87
+ mapContensisOpts({ componentIds, ...opts })
88
+ ).ImportComponents(
52
89
  {
53
90
  fromFile: opts.fromFile,
54
91
  commit: opts.commit,
@@ -59,15 +96,24 @@ Example call:
59
96
 
60
97
  program
61
98
  .command('entries')
99
+ .description('import entries')
62
100
  .argument(
63
101
  '[search phrase]',
64
102
  'get entries with the search phrase, use quotes for multiple words'
65
103
  )
66
104
  .addOption(commit)
67
105
  .option(
68
- '-preserve, --preserve-guids',
106
+ '-preserve --preserve-guids',
69
107
  'include this flag when you are importing entries that you have previously exported and wish to update'
70
108
  )
109
+ .addOption(
110
+ new Option(
111
+ '-oe --output-entries <outputEntries>',
112
+ 'which details of the entries included in the import to output'
113
+ )
114
+ .choices(['errors', 'changes', 'all'])
115
+ .default('errors')
116
+ )
71
117
  .addHelpText(
72
118
  'after',
73
119
  `
@@ -80,7 +126,11 @@ Example call:
80
126
  ['import', 'entries'],
81
127
  opts,
82
128
  mapContensisOpts({ phrase, ...opts })
83
- ).ImportEntries({ commit: opts.commit, fromFile: opts.fromFile });
129
+ ).ImportEntries({
130
+ commit: opts.commit,
131
+ fromFile: opts.fromFile,
132
+ logOutput: opts.outputEntries,
133
+ });
84
134
  });
85
135
 
86
136
  return program;
@@ -3,6 +3,9 @@ import { Logger } from '~/util/logger';
3
3
  import { LIB_VERSION } from '~/version';
4
4
  import { makeConnectCommand } from './connect';
5
5
  import { makeCreateCommand } from './create';
6
+ import { makeDevCommand } from './dev';
7
+ import { makeDiffCommand } from './diff';
8
+ import { makeExecuteCommand } from './execute';
6
9
  import { makeGetCommand } from './get';
7
10
  import {
8
11
  addAuthenticationOptions,
@@ -29,6 +32,13 @@ const commands = () => {
29
32
  : str.trim() && Logger.help(str);
30
33
  },
31
34
  })
35
+ .addHelpText(
36
+ 'after',
37
+ Logger.helpText`
38
+ >> Each command has its own help - for example:
39
+ > login --help\n > get --help
40
+ `
41
+ )
32
42
  .exitOverride()
33
43
  .showHelpAfterError(true);
34
44
 
@@ -37,9 +47,20 @@ const commands = () => {
37
47
  program
38
48
  )
39
49
  );
50
+ program.addCommand(
51
+ addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)
52
+ );
53
+ program.addCommand(
54
+ addConnectOptions(
55
+ addAuthenticationOptions(makeDevCommand())
56
+ ).copyInheritedSettings(program)
57
+ );
58
+ program.addCommand(
59
+ addGlobalOptions(makeExecuteCommand()).copyInheritedSettings(program)
60
+ );
40
61
  program.addCommand(
41
62
  addGlobalOptions(
42
- addImportOptions(makeCreateCommand())
63
+ addGetEntryOptions(addImportOptions(makeDiffCommand()))
43
64
  ).copyInheritedSettings(program)
44
65
  );
45
66
  program.addCommand(