contensis-cli 1.0.0-beta.8 → 1.0.0-beta.81
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/README.md +1146 -78
- package/dist/commands/connect.js +3 -3
- package/dist/commands/connect.js.map +2 -2
- package/dist/commands/create.js +45 -10
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/diff.js +57 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/execute.js +103 -0
- package/dist/commands/execute.js.map +7 -0
- package/dist/commands/get.js +107 -18
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +22 -17
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +46 -11
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +16 -2
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +53 -10
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/push.js +9 -5
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/remove.js +51 -8
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +139 -12
- package/dist/commands/set.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/localisation/en-GB.js +193 -49
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/CredentialProvider.js +36 -7
- package/dist/providers/CredentialProvider.js.map +3 -3
- package/dist/providers/SessionCacheProvider.js +21 -1
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/providers/file-provider.js +8 -4
- package/dist/providers/file-provider.js.map +3 -3
- package/dist/services/ContensisCliService.js +1092 -410
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +48 -14
- package/dist/shell.js.map +3 -3
- package/dist/util/console.printer.js +171 -55
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/diff.js +39 -0
- package/dist/util/diff.js.map +7 -0
- package/dist/util/index.js +8 -2
- package/dist/util/index.js.map +3 -3
- package/dist/util/logger.js +61 -29
- package/dist/util/logger.js.map +3 -3
- package/dist/util/timers.js +49 -0
- package/dist/util/timers.js.map +7 -0
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/esbuild.config.js +3 -1
- package/package.json +2 -2
- package/src/commands/connect.ts +3 -2
- package/src/commands/create.ts +61 -8
- package/src/commands/diff.ts +41 -0
- package/src/commands/execute.ts +117 -0
- package/src/commands/get.ts +150 -14
- package/src/commands/globalOptions.ts +18 -17
- package/src/commands/import.ts +57 -7
- package/src/commands/index.ts +16 -1
- package/src/commands/list.ts +85 -11
- package/src/commands/login.ts +3 -2
- package/src/commands/push.ts +10 -3
- package/src/commands/remove.ts +66 -4
- package/src/commands/set.ts +189 -9
- package/src/index.ts +1 -4
- package/src/localisation/en-GB.ts +269 -66
- package/src/providers/CredentialProvider.ts +39 -6
- package/src/providers/SessionCacheProvider.ts +29 -2
- package/src/providers/file-provider.ts +12 -4
- package/src/services/ContensisCliService.ts +1384 -484
- package/src/shell.ts +52 -15
- package/src/util/console.printer.ts +240 -78
- package/src/util/diff.ts +17 -0
- package/src/util/index.ts +16 -7
- package/src/util/logger.ts +111 -31
- package/src/util/timers.ts +24 -0
- package/src/version.ts +1 -1
package/src/commands/get.ts
CHANGED
|
@@ -1,15 +1,117 @@
|
|
|
1
1
|
import { Argument, Command } from 'commander';
|
|
2
|
+
import { merge } from 'lodash';
|
|
2
3
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
-
import { mapContensisOpts } from './globalOptions';
|
|
4
|
+
import { addGlobalOptions, mapContensisOpts } from './globalOptions';
|
|
4
5
|
|
|
5
6
|
export const makeGetCommand = () => {
|
|
6
7
|
const program = new Command()
|
|
7
8
|
.command('get')
|
|
9
|
+
.description('get command')
|
|
10
|
+
.addHelpText('after', `\n`)
|
|
8
11
|
.showHelpAfterError(true)
|
|
9
12
|
.exitOverride();
|
|
10
13
|
|
|
14
|
+
program
|
|
15
|
+
.command('version')
|
|
16
|
+
.description('get current Contensis version')
|
|
17
|
+
.addHelpText(
|
|
18
|
+
'after',
|
|
19
|
+
`
|
|
20
|
+
Example call:
|
|
21
|
+
> version
|
|
22
|
+
`
|
|
23
|
+
)
|
|
24
|
+
.action(async opts => {
|
|
25
|
+
await cliCommand(['get', 'version'], opts).PrintContensisVersion();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
program
|
|
29
|
+
.command('token')
|
|
30
|
+
.description('show a bearer token for the currently logged in user')
|
|
31
|
+
.addHelpText(
|
|
32
|
+
'after',
|
|
33
|
+
`
|
|
34
|
+
Example call:
|
|
35
|
+
> get token
|
|
36
|
+
`
|
|
37
|
+
)
|
|
38
|
+
.action(async opts => {
|
|
39
|
+
await cliCommand(['get', 'token'], opts).PrintBearerToken();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
program
|
|
43
|
+
.command('project')
|
|
44
|
+
.description('get a project')
|
|
45
|
+
.argument('[projectId]', 'id of the project to get (default: current)')
|
|
46
|
+
.addHelpText(
|
|
47
|
+
'after',
|
|
48
|
+
`
|
|
49
|
+
Example call:
|
|
50
|
+
> get project website
|
|
51
|
+
`
|
|
52
|
+
)
|
|
53
|
+
.action(async (projectId: string, opts) => {
|
|
54
|
+
await cliCommand(['get', 'project', projectId], opts).PrintProject(
|
|
55
|
+
projectId
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
program
|
|
60
|
+
.command('role')
|
|
61
|
+
.description('get a role')
|
|
62
|
+
.argument('<roleNameOrId>', 'id or name of the role to get')
|
|
63
|
+
.addHelpText(
|
|
64
|
+
'after',
|
|
65
|
+
`
|
|
66
|
+
Example call:
|
|
67
|
+
> get role "entry admin"
|
|
68
|
+
`
|
|
69
|
+
)
|
|
70
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
71
|
+
await cliCommand(['get', 'role', roleNameOrId], opts).PrintRole(
|
|
72
|
+
roleNameOrId
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
program
|
|
77
|
+
.command('webhook')
|
|
78
|
+
.description('get a webhook')
|
|
79
|
+
.argument('<webhookNameOrId...>', 'id or name of the webhook(s) to get')
|
|
80
|
+
.addHelpText(
|
|
81
|
+
'after',
|
|
82
|
+
`
|
|
83
|
+
Example call:
|
|
84
|
+
> get webhook "Slack notification"
|
|
85
|
+
`
|
|
86
|
+
)
|
|
87
|
+
.action(async (webhookNameOrId: string[], opts) => {
|
|
88
|
+
await cliCommand(
|
|
89
|
+
['get', 'webhook', webhookNameOrId.join(' ')],
|
|
90
|
+
opts
|
|
91
|
+
).PrintWebhookSubscriptions(webhookNameOrId);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
program
|
|
95
|
+
.command('model')
|
|
96
|
+
.description('get a content model')
|
|
97
|
+
.argument('<contentTypeId...>', 'ids of the content models to get')
|
|
98
|
+
.addHelpText(
|
|
99
|
+
'after',
|
|
100
|
+
`
|
|
101
|
+
Example call:
|
|
102
|
+
> get model podcast podcastLinks
|
|
103
|
+
`
|
|
104
|
+
)
|
|
105
|
+
.action(async (modelIds: string[], opts) => {
|
|
106
|
+
await cliCommand(
|
|
107
|
+
['get', 'model', modelIds.join(' ')],
|
|
108
|
+
opts
|
|
109
|
+
).PrintContentModels(modelIds);
|
|
110
|
+
});
|
|
111
|
+
|
|
11
112
|
program
|
|
12
113
|
.command('contenttype')
|
|
114
|
+
.description('get a content type')
|
|
13
115
|
.argument('<contentTypeId>', 'the API id of the content type to get')
|
|
14
116
|
.addHelpText(
|
|
15
117
|
'after',
|
|
@@ -19,12 +121,15 @@ Example call:
|
|
|
19
121
|
`
|
|
20
122
|
)
|
|
21
123
|
.action(async (contentTypeId: string, opts) => {
|
|
22
|
-
await cliCommand(
|
|
23
|
-
contentTypeId
|
|
24
|
-
|
|
124
|
+
await cliCommand(
|
|
125
|
+
['get', 'contenttype', contentTypeId],
|
|
126
|
+
opts
|
|
127
|
+
).PrintContentType(contentTypeId);
|
|
25
128
|
});
|
|
129
|
+
|
|
26
130
|
program
|
|
27
131
|
.command('component')
|
|
132
|
+
.description('get a component')
|
|
28
133
|
.argument('<componentId>', 'the API id of the component to get')
|
|
29
134
|
.addHelpText(
|
|
30
135
|
'after',
|
|
@@ -34,15 +139,19 @@ Example call:
|
|
|
34
139
|
`
|
|
35
140
|
)
|
|
36
141
|
.action(async (componentId: string, opts) => {
|
|
37
|
-
await cliCommand(['get', 'component'], opts).PrintComponent(
|
|
142
|
+
await cliCommand(['get', 'component', componentId], opts).PrintComponent(
|
|
143
|
+
componentId
|
|
144
|
+
);
|
|
38
145
|
});
|
|
146
|
+
|
|
39
147
|
program
|
|
40
148
|
.command('entries')
|
|
149
|
+
.description('get entries')
|
|
41
150
|
.argument(
|
|
42
151
|
'[search phrase]',
|
|
43
152
|
'get entries with the search phrase, use quotes for multiple words'
|
|
44
153
|
)
|
|
45
|
-
.option('-i --id <id...>', 'the entry id to get')
|
|
154
|
+
.option('-i --id <id...>', 'the entry id(s) to get')
|
|
46
155
|
.option(
|
|
47
156
|
'-d, --dependents',
|
|
48
157
|
'find and return any dependencies of all found entries'
|
|
@@ -76,18 +185,27 @@ Example call:
|
|
|
76
185
|
|
|
77
186
|
const block = program
|
|
78
187
|
.command('block')
|
|
188
|
+
.description('get a block or block version')
|
|
79
189
|
.argument('[blockId]', 'the block to get version details for')
|
|
80
190
|
.argument(
|
|
81
191
|
'[branch]',
|
|
82
192
|
'the branch of the block to get version details for',
|
|
83
|
-
'
|
|
193
|
+
'default'
|
|
84
194
|
)
|
|
85
195
|
.argument(
|
|
86
196
|
'[version]',
|
|
87
197
|
'get a specific version of the block pushed to the specified branch'
|
|
88
198
|
)
|
|
199
|
+
.addHelpText(
|
|
200
|
+
'after',
|
|
201
|
+
`
|
|
202
|
+
Example call:
|
|
203
|
+
> get block contensis-website
|
|
204
|
+
> get block contensis-website develop latest
|
|
205
|
+
`
|
|
206
|
+
)
|
|
89
207
|
.action(async (blockId: string, branch: string, version: string, opts) => {
|
|
90
|
-
await cliCommand(['get', 'block'], opts).PrintBlockVersions(
|
|
208
|
+
await cliCommand(['get', 'block', blockId], opts).PrintBlockVersions(
|
|
91
209
|
blockId,
|
|
92
210
|
branch,
|
|
93
211
|
version
|
|
@@ -98,16 +216,17 @@ Example call:
|
|
|
98
216
|
'[dataCenter]',
|
|
99
217
|
'the datacentre of the block to get logs for'
|
|
100
218
|
)
|
|
101
|
-
.choices(['hq', 'london', 'manchester'])
|
|
102
|
-
.default('
|
|
219
|
+
.choices(['hq', 'london', 'manchester', 'all'])
|
|
220
|
+
.default('all');
|
|
103
221
|
|
|
104
222
|
block
|
|
105
223
|
.command('logs')
|
|
224
|
+
.description('get logs for a block')
|
|
106
225
|
.argument('[blockId]', 'the block to get version logs for')
|
|
107
226
|
.argument(
|
|
108
227
|
'[branch]',
|
|
109
228
|
'the branch of the block to get version details for',
|
|
110
|
-
'
|
|
229
|
+
'default'
|
|
111
230
|
)
|
|
112
231
|
.argument(
|
|
113
232
|
'[version]',
|
|
@@ -115,24 +234,41 @@ Example call:
|
|
|
115
234
|
'latest'
|
|
116
235
|
)
|
|
117
236
|
.addArgument(dataCenter)
|
|
237
|
+
.option('-t, --follow', 'follow block logs in near realtime', false)
|
|
118
238
|
.usage('get block logs [blockId] [branch] [version] [dataCenter]')
|
|
239
|
+
.addHelpText(
|
|
240
|
+
'after',
|
|
241
|
+
`
|
|
242
|
+
Example call:
|
|
243
|
+
> get block logs contensis-website default
|
|
244
|
+
> get block logs contensis-website master latest london --follow
|
|
245
|
+
`
|
|
246
|
+
)
|
|
119
247
|
.action(
|
|
120
248
|
async (
|
|
121
249
|
blockId: string,
|
|
122
250
|
branch: string,
|
|
123
251
|
version: string,
|
|
124
|
-
dataCenter: 'hq' | 'manchester' | 'london',
|
|
252
|
+
dataCenter: 'hq' | 'manchester' | 'london' | 'all',
|
|
125
253
|
opts
|
|
126
254
|
) => {
|
|
127
|
-
|
|
255
|
+
const parentOpts = block.opts() || {};
|
|
256
|
+
await cliCommand(
|
|
257
|
+
['get', 'block', 'logs'],
|
|
258
|
+
merge(opts, parentOpts)
|
|
259
|
+
).PrintBlockLogs(
|
|
128
260
|
blockId,
|
|
129
261
|
branch,
|
|
130
262
|
version,
|
|
131
|
-
dataCenter
|
|
263
|
+
dataCenter === 'all' ? undefined : dataCenter,
|
|
264
|
+
opts.follow as boolean
|
|
132
265
|
);
|
|
133
266
|
}
|
|
134
267
|
);
|
|
135
268
|
|
|
269
|
+
// Add global opts for inner sub-commands
|
|
270
|
+
addGlobalOptions(block);
|
|
271
|
+
|
|
136
272
|
return program;
|
|
137
273
|
};
|
|
138
274
|
|
|
@@ -3,19 +3,20 @@ import { url } from '~/util';
|
|
|
3
3
|
|
|
4
4
|
export const mapContensisOpts = (opts: any = {}) => ({
|
|
5
5
|
source:
|
|
6
|
-
opts.
|
|
6
|
+
opts.sourceAlias || opts.sourceProjectId
|
|
7
7
|
? {
|
|
8
|
-
url: opts.
|
|
9
|
-
? url(opts.
|
|
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 || opts.entryIds || opts.phrase || opts.fields
|
|
16
17
|
? {
|
|
17
18
|
fields: opts.fields,
|
|
18
|
-
includeIds: opts.id,
|
|
19
|
+
includeIds: opts.id || opts.entryIds,
|
|
19
20
|
searchTerm: opts.phrase,
|
|
20
21
|
}
|
|
21
22
|
: undefined,
|
|
@@ -36,59 +37,59 @@ const format = new Option(
|
|
|
36
37
|
|
|
37
38
|
/* Connect options */
|
|
38
39
|
const alias = new Option(
|
|
39
|
-
'-a --alias <alias>',
|
|
40
|
+
'-a, --alias <alias>',
|
|
40
41
|
'the cloud CMS alias to connect your request with'
|
|
41
42
|
);
|
|
42
43
|
|
|
43
44
|
export const project = new Option(
|
|
44
|
-
'-p --project-id <projectId>',
|
|
45
|
+
'-p, --project-id <projectId>',
|
|
45
46
|
'the projectId to make your request with'
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
/* Authentication options */
|
|
49
50
|
const user = new Option(
|
|
50
|
-
'-u --user <user>',
|
|
51
|
+
'-u, --user <user>',
|
|
51
52
|
'the username to authenticate your request with'
|
|
52
53
|
);
|
|
53
54
|
const password = new Option(
|
|
54
|
-
'-pw --password <password>',
|
|
55
|
+
'-pw, --password <password>',
|
|
55
56
|
'the password to use to login with (optional/insecure)'
|
|
56
57
|
);
|
|
57
58
|
const clientId = new Option(
|
|
58
|
-
'-id --client-id <clientId>',
|
|
59
|
+
'-id, --client-id <clientId>',
|
|
59
60
|
'the clientId to authenticate your request with'
|
|
60
61
|
);
|
|
61
62
|
const sharedSecret = new Option(
|
|
62
|
-
'-s --shared-secret <sharedSecret>',
|
|
63
|
+
'-s, --shared-secret <sharedSecret>',
|
|
63
64
|
'the shared secret to use when logging in with a client id'
|
|
64
65
|
);
|
|
65
66
|
|
|
66
67
|
/* Entry get options */
|
|
67
|
-
const zenql = new Option(
|
|
68
|
+
export const zenql = new Option(
|
|
68
69
|
'-q, --zenql <zenql>',
|
|
69
70
|
'get entries with a supplied ZenQL statement'
|
|
70
71
|
);
|
|
71
72
|
|
|
72
|
-
const entryId = new Option('-i --id <id...>', 'the entry id to get');
|
|
73
|
+
export const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');
|
|
73
74
|
|
|
74
75
|
/* Import options */
|
|
75
76
|
export const fromFile = new Option(
|
|
76
|
-
'-file --from-file <fromFile>',
|
|
77
|
+
'-file, --from-file <fromFile>',
|
|
77
78
|
'file path to import asset(s) from'
|
|
78
79
|
);
|
|
79
80
|
|
|
80
81
|
export const fromCms = new Option(
|
|
81
|
-
'-source --source-alias <fromCms>',
|
|
82
|
+
'-source, --source-alias <fromCms>',
|
|
82
83
|
'the cloud CMS alias to import asset(s) from'
|
|
83
84
|
);
|
|
84
85
|
export const fromProject = new Option(
|
|
85
|
-
'-sp --source-project-id <fromProject>',
|
|
86
|
+
'-sp, --source-project-id <fromProject>',
|
|
86
87
|
'the id of the Contensis project to import asset(s) from (Default: [last connected project])'
|
|
87
88
|
);
|
|
88
89
|
|
|
89
90
|
export const commit = new Option(
|
|
90
91
|
'--commit',
|
|
91
|
-
'
|
|
92
|
+
'add this flag only after you have run a preview of the import and agree with the analysis'
|
|
92
93
|
).default(false);
|
|
93
94
|
|
|
94
95
|
export const addConnectOptions = (program: Command) =>
|
package/src/commands/import.ts
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
import {
|
|
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(
|
|
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(
|
|
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,6 +96,7 @@ 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'
|
|
@@ -68,6 +106,14 @@ Example call:
|
|
|
68
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({
|
|
129
|
+
).ImportEntries({
|
|
130
|
+
commit: opts.commit,
|
|
131
|
+
fromFile: opts.fromFile,
|
|
132
|
+
logOutput: opts.outputEntries,
|
|
133
|
+
});
|
|
84
134
|
});
|
|
85
135
|
|
|
86
136
|
return program;
|
package/src/commands/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ 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 { makeDiffCommand } from './diff';
|
|
7
|
+
import { makeExecuteCommand } from './execute';
|
|
6
8
|
import { makeGetCommand } from './get';
|
|
7
9
|
import {
|
|
8
10
|
addAuthenticationOptions,
|
|
@@ -29,6 +31,13 @@ const commands = () => {
|
|
|
29
31
|
: str.trim() && Logger.help(str);
|
|
30
32
|
},
|
|
31
33
|
})
|
|
34
|
+
.addHelpText(
|
|
35
|
+
'after',
|
|
36
|
+
Logger.helpText`
|
|
37
|
+
>> Each command has its own help - for example:
|
|
38
|
+
> login --help\n > get --help
|
|
39
|
+
`
|
|
40
|
+
)
|
|
32
41
|
.exitOverride()
|
|
33
42
|
.showHelpAfterError(true);
|
|
34
43
|
|
|
@@ -37,9 +46,15 @@ const commands = () => {
|
|
|
37
46
|
program
|
|
38
47
|
)
|
|
39
48
|
);
|
|
49
|
+
program.addCommand(
|
|
50
|
+
addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)
|
|
51
|
+
);
|
|
52
|
+
program.addCommand(
|
|
53
|
+
addGlobalOptions(makeExecuteCommand()).copyInheritedSettings(program)
|
|
54
|
+
);
|
|
40
55
|
program.addCommand(
|
|
41
56
|
addGlobalOptions(
|
|
42
|
-
addImportOptions(
|
|
57
|
+
addGetEntryOptions(addImportOptions(makeDiffCommand()))
|
|
43
58
|
).copyInheritedSettings(program)
|
|
44
59
|
);
|
|
45
60
|
program.addCommand(
|
package/src/commands/list.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
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
|
+
.description('list command')
|
|
8
|
+
.addHelpText('after', `\n`)
|
|
13
9
|
.showHelpAfterError(true)
|
|
14
10
|
.exitOverride();
|
|
15
11
|
|
|
16
12
|
list
|
|
17
13
|
.command('envs')
|
|
14
|
+
.description('List all previously connected environments')
|
|
18
15
|
.addHelpText(
|
|
19
16
|
'after',
|
|
20
17
|
`
|
|
@@ -25,11 +22,38 @@ Example call:
|
|
|
25
22
|
.action(opts => {
|
|
26
23
|
cliCommand(['list', 'envs'], opts).PrintEnvironments();
|
|
27
24
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
|
|
26
|
+
list
|
|
27
|
+
.command('projects')
|
|
28
|
+
.description('print list of projects')
|
|
29
|
+
.addHelpText(
|
|
30
|
+
'after',
|
|
31
|
+
`
|
|
32
|
+
Example call:
|
|
33
|
+
> list projects
|
|
34
|
+
`
|
|
35
|
+
)
|
|
36
|
+
.action(async opts => {
|
|
37
|
+
await cliCommand(['list', 'projects'], opts).PrintProjects();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
list
|
|
41
|
+
.command('models')
|
|
42
|
+
.description('print list of content models')
|
|
43
|
+
.addHelpText(
|
|
44
|
+
'after',
|
|
45
|
+
`
|
|
46
|
+
Example call:
|
|
47
|
+
> list models
|
|
48
|
+
`
|
|
49
|
+
)
|
|
50
|
+
.action(async opts => {
|
|
51
|
+
await cliCommand(['list', 'models'], opts).PrintContentModels();
|
|
52
|
+
});
|
|
53
|
+
|
|
31
54
|
list
|
|
32
55
|
.command('contenttypes')
|
|
56
|
+
.description('print list of content types')
|
|
33
57
|
.addHelpText(
|
|
34
58
|
'after',
|
|
35
59
|
`
|
|
@@ -40,8 +64,10 @@ Example call:
|
|
|
40
64
|
.action(async opts => {
|
|
41
65
|
await cliCommand(['list', 'contenttypes'], opts).PrintContentTypes();
|
|
42
66
|
});
|
|
67
|
+
|
|
43
68
|
list
|
|
44
69
|
.command('components')
|
|
70
|
+
.description('print list of components')
|
|
45
71
|
.addHelpText(
|
|
46
72
|
'after',
|
|
47
73
|
`
|
|
@@ -52,8 +78,10 @@ Example call:
|
|
|
52
78
|
.action(async opts => {
|
|
53
79
|
await cliCommand(['list', 'components'], opts).PrintComponents();
|
|
54
80
|
});
|
|
81
|
+
|
|
55
82
|
list
|
|
56
83
|
.command('blocks')
|
|
84
|
+
.description('print list of content blocks')
|
|
57
85
|
.addHelpText(
|
|
58
86
|
'after',
|
|
59
87
|
`
|
|
@@ -64,8 +92,10 @@ Example call:
|
|
|
64
92
|
.action(async opts => {
|
|
65
93
|
await cliCommand(['list', 'blocks'], opts).PrintBlocks();
|
|
66
94
|
});
|
|
95
|
+
|
|
67
96
|
list
|
|
68
97
|
.command('keys')
|
|
98
|
+
.description('print list of API keys')
|
|
69
99
|
.addHelpText(
|
|
70
100
|
'after',
|
|
71
101
|
`
|
|
@@ -76,14 +106,58 @@ Example call:
|
|
|
76
106
|
.action(async opts => {
|
|
77
107
|
await cliCommand(['list', 'keys'], opts).PrintApiKeys();
|
|
78
108
|
});
|
|
109
|
+
|
|
110
|
+
list
|
|
111
|
+
.command('proxies')
|
|
112
|
+
.description('print list of proxies')
|
|
113
|
+
.addHelpText(
|
|
114
|
+
'after',
|
|
115
|
+
`
|
|
116
|
+
Example call:
|
|
117
|
+
> list proxies
|
|
118
|
+
`
|
|
119
|
+
)
|
|
120
|
+
.action(async opts => {
|
|
121
|
+
await cliCommand(['list', 'proxies'], opts).PrintProxies();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
list
|
|
125
|
+
.command('renderers')
|
|
126
|
+
.description('print list of renderers')
|
|
127
|
+
.addHelpText(
|
|
128
|
+
'after',
|
|
129
|
+
`
|
|
130
|
+
Example call:
|
|
131
|
+
> list renderers
|
|
132
|
+
`
|
|
133
|
+
)
|
|
134
|
+
.action(async opts => {
|
|
135
|
+
await cliCommand(['list', 'renderers'], opts).PrintRenderers();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
list
|
|
139
|
+
.command('roles')
|
|
140
|
+
.description('print list of roles')
|
|
141
|
+
.addHelpText(
|
|
142
|
+
'after',
|
|
143
|
+
`
|
|
144
|
+
Example call:
|
|
145
|
+
> list roles
|
|
146
|
+
`
|
|
147
|
+
)
|
|
148
|
+
.action(async opts => {
|
|
149
|
+
await cliCommand(['list', 'roles'], opts).PrintRoles();
|
|
150
|
+
});
|
|
151
|
+
|
|
79
152
|
list
|
|
80
153
|
.command('webhooks')
|
|
154
|
+
.description('print list of webhooks')
|
|
81
155
|
.argument('[name]', 'find webhooks matching the supplied name')
|
|
82
156
|
.option('-i --id <id...>', 'the subscription id(s) to get')
|
|
157
|
+
.addHelpText('after', `\n`)
|
|
83
158
|
.action(async (name?: string, { id, ...opts }: any = {}) => {
|
|
84
159
|
await cliCommand(['list', 'webhooks'], opts).PrintWebhookSubscriptions(
|
|
85
|
-
id
|
|
86
|
-
name
|
|
160
|
+
name ? [name] : id
|
|
87
161
|
);
|
|
88
162
|
});
|
|
89
163
|
return list;
|
package/src/commands/login.ts
CHANGED
|
@@ -5,13 +5,14 @@ import { shell } from '~/shell';
|
|
|
5
5
|
export const makeLoginCommand = () => {
|
|
6
6
|
const login = new Command()
|
|
7
7
|
.command('login')
|
|
8
|
+
.description('login to a connected Contensis instance')
|
|
8
9
|
.argument('<user/clientId>', 'the username to login with')
|
|
9
10
|
.argument(
|
|
10
11
|
'[password]',
|
|
11
12
|
'the password to use to login with (optional/insecure)'
|
|
12
13
|
)
|
|
13
14
|
.option(
|
|
14
|
-
'-s --shared-secret <sharedSecret>',
|
|
15
|
+
'-s, --shared-secret <sharedSecret>',
|
|
15
16
|
'the shared secret to use when logging in with a client id'
|
|
16
17
|
)
|
|
17
18
|
.usage('<user/clientId> [password] [-s <sharedSecret>]')
|
|
@@ -27,7 +28,7 @@ Example call:
|
|
|
27
28
|
password,
|
|
28
29
|
sharedSecret: opts.sharedSecret,
|
|
29
30
|
});
|
|
30
|
-
if (token) await shell().
|
|
31
|
+
if (token) await shell().restart();
|
|
31
32
|
});
|
|
32
33
|
return login;
|
|
33
34
|
};
|