contensis-cli 1.0.0-beta.53 → 1.0.0-beta.54
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/.vscode/launch.json +15 -15
- package/README.md +1226 -1226
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/globalOptions.js.map +1 -1
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/set.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/localisation/en-GB.js.map +1 -1
- package/dist/providers/CredentialProvider.js.map +1 -1
- package/dist/providers/SessionCacheProvider.js.map +1 -1
- package/dist/providers/file-provider.js.map +1 -1
- package/dist/services/ContensisAuthService.js.map +1 -1
- package/dist/services/ContensisCliService.js.map +1 -1
- package/dist/shell.js.map +1 -1
- package/dist/util/console.printer.js +5 -5
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/csv.formatter.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/json.formatter.js.map +1 -1
- package/dist/util/logger.js.map +1 -1
- package/dist/util/xml.formatter.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/esbuild.config.js +49 -49
- package/headless-setup.sh +6 -6
- package/package.json +59 -59
- package/src/commands/connect.ts +24 -24
- package/src/commands/create.ts +70 -70
- package/src/commands/diff.ts +41 -41
- package/src/commands/get.ts +214 -214
- package/src/commands/globalOptions.ts +127 -127
- package/src/commands/import.ts +128 -128
- package/src/commands/index.ts +80 -80
- package/src/commands/list.ts +116 -116
- package/src/commands/login.ts +34 -34
- package/src/commands/push.ts +127 -127
- package/src/commands/release.ts +32 -32
- package/src/commands/remove.ts +85 -85
- package/src/commands/set.ts +96 -96
- package/src/index.ts +19 -19
- package/src/localisation/en-GB.ts +289 -289
- package/src/models/AppError.d.ts +40 -40
- package/src/models/Cache.d.ts +25 -25
- package/src/models/JsModules.d.ts +1 -1
- package/src/providers/CredentialProvider.ts +121 -121
- package/src/providers/SessionCacheProvider.ts +101 -101
- package/src/providers/file-provider.ts +76 -76
- package/src/services/ContensisAuthService.ts +70 -70
- package/src/services/ContensisCliService.ts +1745 -1745
- package/src/shell.ts +270 -270
- package/src/util/console.printer.ts +371 -371
- package/src/util/csv.formatter.ts +21 -21
- package/src/util/index.ts +73 -73
- package/src/util/json.formatter.ts +1 -1
- package/src/util/logger.ts +234 -234
- package/src/util/xml.formatter.ts +20 -20
- package/src/version.ts +1 -1
- package/tsconfig.json +22 -22
package/src/commands/get.ts
CHANGED
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
import { Argument, Command } from 'commander';
|
|
2
|
-
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
-
import { mapContensisOpts } from './globalOptions';
|
|
4
|
-
|
|
5
|
-
export const makeGetCommand = () => {
|
|
6
|
-
const program = new Command()
|
|
7
|
-
.command('get')
|
|
8
|
-
.addHelpText('after', `\n`)
|
|
9
|
-
.showHelpAfterError(true)
|
|
10
|
-
.exitOverride();
|
|
11
|
-
|
|
12
|
-
program
|
|
13
|
-
.command('version')
|
|
14
|
-
.description('get current Contensis version')
|
|
15
|
-
.addHelpText(
|
|
16
|
-
'after',
|
|
17
|
-
`
|
|
18
|
-
Example call:
|
|
19
|
-
> version
|
|
20
|
-
`
|
|
21
|
-
)
|
|
22
|
-
.action(async opts => {
|
|
23
|
-
await cliCommand(['get', 'version'], opts).PrintContensisVersion();
|
|
24
|
-
});
|
|
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
|
-
|
|
43
|
-
program
|
|
44
|
-
.command('model')
|
|
45
|
-
.description('get a content model')
|
|
46
|
-
.argument('<contentTypeId...>', 'ids of the content models to get')
|
|
47
|
-
.addHelpText(
|
|
48
|
-
'after',
|
|
49
|
-
`
|
|
50
|
-
Example call:
|
|
51
|
-
> get model podcast podcastLinks
|
|
52
|
-
`
|
|
53
|
-
)
|
|
54
|
-
.action(async (modelIds: string[], opts) => {
|
|
55
|
-
await cliCommand(
|
|
56
|
-
['get', 'model', modelIds.join(' ')],
|
|
57
|
-
opts
|
|
58
|
-
).PrintContentModels(modelIds);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
program
|
|
62
|
-
.command('contenttype')
|
|
63
|
-
.description('get a content type')
|
|
64
|
-
.argument('<contentTypeId>', 'the API id of the content type to get')
|
|
65
|
-
.addHelpText(
|
|
66
|
-
'after',
|
|
67
|
-
`
|
|
68
|
-
Example call:
|
|
69
|
-
> get contenttype {contentTypeId} -o content-type-backup.json
|
|
70
|
-
`
|
|
71
|
-
)
|
|
72
|
-
.action(async (contentTypeId: string, opts) => {
|
|
73
|
-
await cliCommand(
|
|
74
|
-
['get', 'contenttype', contentTypeId],
|
|
75
|
-
opts
|
|
76
|
-
).PrintContentType(contentTypeId);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
program
|
|
80
|
-
.command('component')
|
|
81
|
-
.description('get a component')
|
|
82
|
-
.argument('<componentId>', 'the API id of the component to get')
|
|
83
|
-
.addHelpText(
|
|
84
|
-
'after',
|
|
85
|
-
`
|
|
86
|
-
Example call:
|
|
87
|
-
> get component {componentId} -o component-backup.json
|
|
88
|
-
`
|
|
89
|
-
)
|
|
90
|
-
.action(async (componentId: string, opts) => {
|
|
91
|
-
await cliCommand(['get', 'component', componentId], opts).PrintComponent(
|
|
92
|
-
componentId
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
program
|
|
97
|
-
.command('entries')
|
|
98
|
-
.description('get entries')
|
|
99
|
-
.argument(
|
|
100
|
-
'[search phrase]',
|
|
101
|
-
'get entries with the search phrase, use quotes for multiple words'
|
|
102
|
-
)
|
|
103
|
-
.option('-i --id <id...>', 'the entry id(s) to get')
|
|
104
|
-
.option(
|
|
105
|
-
'-d, --dependents',
|
|
106
|
-
'find and return any dependencies of all found entries'
|
|
107
|
-
)
|
|
108
|
-
.option(
|
|
109
|
-
'-fi, --fields <fields...>',
|
|
110
|
-
'limit the output fields on returned entries'
|
|
111
|
-
)
|
|
112
|
-
.option(
|
|
113
|
-
'-q, --zenql <zenql>',
|
|
114
|
-
'get entries with a supplied ZenQL statement'
|
|
115
|
-
)
|
|
116
|
-
.addHelpText(
|
|
117
|
-
'after',
|
|
118
|
-
`
|
|
119
|
-
Example call:
|
|
120
|
-
> get entries --zenql "sys.contentTypeId = blog" --fields entryTitle entryDescription sys.id --output ./blog-posts.csv --format csv
|
|
121
|
-
`
|
|
122
|
-
)
|
|
123
|
-
.action(async (phrase: string, opts, cmd) => {
|
|
124
|
-
// console.log('phrase: ', phrase, '\nopts:', JSON.stringify(opts, null, 2));
|
|
125
|
-
// console.log('opts:', JSON.stringify(opts, null, 2));
|
|
126
|
-
await cliCommand(
|
|
127
|
-
['get', 'entries'],
|
|
128
|
-
opts,
|
|
129
|
-
mapContensisOpts({ phrase, ...opts })
|
|
130
|
-
).GetEntries({
|
|
131
|
-
withDependents: opts.dependents,
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const block = program
|
|
136
|
-
.command('block')
|
|
137
|
-
.description('get a block or block version')
|
|
138
|
-
.argument('[blockId]', 'the block to get version details for')
|
|
139
|
-
.argument(
|
|
140
|
-
'[branch]',
|
|
141
|
-
'the branch of the block to get version details for',
|
|
142
|
-
'main'
|
|
143
|
-
)
|
|
144
|
-
.argument(
|
|
145
|
-
'[version]',
|
|
146
|
-
'get a specific version of the block pushed to the specified branch'
|
|
147
|
-
)
|
|
148
|
-
.addHelpText(
|
|
149
|
-
'after',
|
|
150
|
-
`
|
|
151
|
-
Example call:
|
|
152
|
-
> get block contensis-website master latest
|
|
153
|
-
`
|
|
154
|
-
)
|
|
155
|
-
.action(async (blockId: string, branch: string, version: string, opts) => {
|
|
156
|
-
await cliCommand(['get', 'block'], opts).PrintBlockVersions(
|
|
157
|
-
blockId,
|
|
158
|
-
branch,
|
|
159
|
-
version
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const dataCenter = new Argument(
|
|
164
|
-
'[dataCenter]',
|
|
165
|
-
'the datacentre of the block to get logs for'
|
|
166
|
-
)
|
|
167
|
-
.choices(['hq', 'london', 'manchester'])
|
|
168
|
-
.default('hq');
|
|
169
|
-
|
|
170
|
-
block
|
|
171
|
-
.command('logs')
|
|
172
|
-
.description('get logs for a block')
|
|
173
|
-
.argument('[blockId]', 'the block to get version logs for')
|
|
174
|
-
.argument(
|
|
175
|
-
'[branch]',
|
|
176
|
-
'the branch of the block to get version details for',
|
|
177
|
-
'main'
|
|
178
|
-
)
|
|
179
|
-
.argument(
|
|
180
|
-
'[version]',
|
|
181
|
-
'the version of the block pushed to the branch to get logs for',
|
|
182
|
-
'latest'
|
|
183
|
-
)
|
|
184
|
-
.addArgument(dataCenter)
|
|
185
|
-
.usage('get block logs [blockId] [branch] [version] [dataCenter]')
|
|
186
|
-
.addHelpText(
|
|
187
|
-
'after',
|
|
188
|
-
`
|
|
189
|
-
Example call:
|
|
190
|
-
> get block logs contensis-website master
|
|
191
|
-
> get block logs contensis-website master latest london
|
|
192
|
-
`
|
|
193
|
-
)
|
|
194
|
-
.action(
|
|
195
|
-
async (
|
|
196
|
-
blockId: string,
|
|
197
|
-
branch: string,
|
|
198
|
-
version: string,
|
|
199
|
-
dataCenter: 'hq' | 'manchester' | 'london',
|
|
200
|
-
opts
|
|
201
|
-
) => {
|
|
202
|
-
await cliCommand(['get', 'block', 'logs'], opts).PrintBlockLogs(
|
|
203
|
-
blockId,
|
|
204
|
-
branch,
|
|
205
|
-
version,
|
|
206
|
-
dataCenter
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
return program;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const get = makeGetCommand();
|
|
1
|
+
import { Argument, Command } from 'commander';
|
|
2
|
+
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
+
import { mapContensisOpts } from './globalOptions';
|
|
4
|
+
|
|
5
|
+
export const makeGetCommand = () => {
|
|
6
|
+
const program = new Command()
|
|
7
|
+
.command('get')
|
|
8
|
+
.addHelpText('after', `\n`)
|
|
9
|
+
.showHelpAfterError(true)
|
|
10
|
+
.exitOverride();
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.command('version')
|
|
14
|
+
.description('get current Contensis version')
|
|
15
|
+
.addHelpText(
|
|
16
|
+
'after',
|
|
17
|
+
`
|
|
18
|
+
Example call:
|
|
19
|
+
> version
|
|
20
|
+
`
|
|
21
|
+
)
|
|
22
|
+
.action(async opts => {
|
|
23
|
+
await cliCommand(['get', 'version'], opts).PrintContensisVersion();
|
|
24
|
+
});
|
|
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
|
+
|
|
43
|
+
program
|
|
44
|
+
.command('model')
|
|
45
|
+
.description('get a content model')
|
|
46
|
+
.argument('<contentTypeId...>', 'ids of the content models to get')
|
|
47
|
+
.addHelpText(
|
|
48
|
+
'after',
|
|
49
|
+
`
|
|
50
|
+
Example call:
|
|
51
|
+
> get model podcast podcastLinks
|
|
52
|
+
`
|
|
53
|
+
)
|
|
54
|
+
.action(async (modelIds: string[], opts) => {
|
|
55
|
+
await cliCommand(
|
|
56
|
+
['get', 'model', modelIds.join(' ')],
|
|
57
|
+
opts
|
|
58
|
+
).PrintContentModels(modelIds);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
program
|
|
62
|
+
.command('contenttype')
|
|
63
|
+
.description('get a content type')
|
|
64
|
+
.argument('<contentTypeId>', 'the API id of the content type to get')
|
|
65
|
+
.addHelpText(
|
|
66
|
+
'after',
|
|
67
|
+
`
|
|
68
|
+
Example call:
|
|
69
|
+
> get contenttype {contentTypeId} -o content-type-backup.json
|
|
70
|
+
`
|
|
71
|
+
)
|
|
72
|
+
.action(async (contentTypeId: string, opts) => {
|
|
73
|
+
await cliCommand(
|
|
74
|
+
['get', 'contenttype', contentTypeId],
|
|
75
|
+
opts
|
|
76
|
+
).PrintContentType(contentTypeId);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
program
|
|
80
|
+
.command('component')
|
|
81
|
+
.description('get a component')
|
|
82
|
+
.argument('<componentId>', 'the API id of the component to get')
|
|
83
|
+
.addHelpText(
|
|
84
|
+
'after',
|
|
85
|
+
`
|
|
86
|
+
Example call:
|
|
87
|
+
> get component {componentId} -o component-backup.json
|
|
88
|
+
`
|
|
89
|
+
)
|
|
90
|
+
.action(async (componentId: string, opts) => {
|
|
91
|
+
await cliCommand(['get', 'component', componentId], opts).PrintComponent(
|
|
92
|
+
componentId
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
program
|
|
97
|
+
.command('entries')
|
|
98
|
+
.description('get entries')
|
|
99
|
+
.argument(
|
|
100
|
+
'[search phrase]',
|
|
101
|
+
'get entries with the search phrase, use quotes for multiple words'
|
|
102
|
+
)
|
|
103
|
+
.option('-i --id <id...>', 'the entry id(s) to get')
|
|
104
|
+
.option(
|
|
105
|
+
'-d, --dependents',
|
|
106
|
+
'find and return any dependencies of all found entries'
|
|
107
|
+
)
|
|
108
|
+
.option(
|
|
109
|
+
'-fi, --fields <fields...>',
|
|
110
|
+
'limit the output fields on returned entries'
|
|
111
|
+
)
|
|
112
|
+
.option(
|
|
113
|
+
'-q, --zenql <zenql>',
|
|
114
|
+
'get entries with a supplied ZenQL statement'
|
|
115
|
+
)
|
|
116
|
+
.addHelpText(
|
|
117
|
+
'after',
|
|
118
|
+
`
|
|
119
|
+
Example call:
|
|
120
|
+
> get entries --zenql "sys.contentTypeId = blog" --fields entryTitle entryDescription sys.id --output ./blog-posts.csv --format csv
|
|
121
|
+
`
|
|
122
|
+
)
|
|
123
|
+
.action(async (phrase: string, opts, cmd) => {
|
|
124
|
+
// console.log('phrase: ', phrase, '\nopts:', JSON.stringify(opts, null, 2));
|
|
125
|
+
// console.log('opts:', JSON.stringify(opts, null, 2));
|
|
126
|
+
await cliCommand(
|
|
127
|
+
['get', 'entries'],
|
|
128
|
+
opts,
|
|
129
|
+
mapContensisOpts({ phrase, ...opts })
|
|
130
|
+
).GetEntries({
|
|
131
|
+
withDependents: opts.dependents,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const block = program
|
|
136
|
+
.command('block')
|
|
137
|
+
.description('get a block or block version')
|
|
138
|
+
.argument('[blockId]', 'the block to get version details for')
|
|
139
|
+
.argument(
|
|
140
|
+
'[branch]',
|
|
141
|
+
'the branch of the block to get version details for',
|
|
142
|
+
'main'
|
|
143
|
+
)
|
|
144
|
+
.argument(
|
|
145
|
+
'[version]',
|
|
146
|
+
'get a specific version of the block pushed to the specified branch'
|
|
147
|
+
)
|
|
148
|
+
.addHelpText(
|
|
149
|
+
'after',
|
|
150
|
+
`
|
|
151
|
+
Example call:
|
|
152
|
+
> get block contensis-website master latest
|
|
153
|
+
`
|
|
154
|
+
)
|
|
155
|
+
.action(async (blockId: string, branch: string, version: string, opts) => {
|
|
156
|
+
await cliCommand(['get', 'block'], opts).PrintBlockVersions(
|
|
157
|
+
blockId,
|
|
158
|
+
branch,
|
|
159
|
+
version
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const dataCenter = new Argument(
|
|
164
|
+
'[dataCenter]',
|
|
165
|
+
'the datacentre of the block to get logs for'
|
|
166
|
+
)
|
|
167
|
+
.choices(['hq', 'london', 'manchester'])
|
|
168
|
+
.default('hq');
|
|
169
|
+
|
|
170
|
+
block
|
|
171
|
+
.command('logs')
|
|
172
|
+
.description('get logs for a block')
|
|
173
|
+
.argument('[blockId]', 'the block to get version logs for')
|
|
174
|
+
.argument(
|
|
175
|
+
'[branch]',
|
|
176
|
+
'the branch of the block to get version details for',
|
|
177
|
+
'main'
|
|
178
|
+
)
|
|
179
|
+
.argument(
|
|
180
|
+
'[version]',
|
|
181
|
+
'the version of the block pushed to the branch to get logs for',
|
|
182
|
+
'latest'
|
|
183
|
+
)
|
|
184
|
+
.addArgument(dataCenter)
|
|
185
|
+
.usage('get block logs [blockId] [branch] [version] [dataCenter]')
|
|
186
|
+
.addHelpText(
|
|
187
|
+
'after',
|
|
188
|
+
`
|
|
189
|
+
Example call:
|
|
190
|
+
> get block logs contensis-website master
|
|
191
|
+
> get block logs contensis-website master latest london
|
|
192
|
+
`
|
|
193
|
+
)
|
|
194
|
+
.action(
|
|
195
|
+
async (
|
|
196
|
+
blockId: string,
|
|
197
|
+
branch: string,
|
|
198
|
+
version: string,
|
|
199
|
+
dataCenter: 'hq' | 'manchester' | 'london',
|
|
200
|
+
opts
|
|
201
|
+
) => {
|
|
202
|
+
await cliCommand(['get', 'block', 'logs'], opts).PrintBlockLogs(
|
|
203
|
+
blockId,
|
|
204
|
+
branch,
|
|
205
|
+
version,
|
|
206
|
+
dataCenter
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
return program;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export const get = makeGetCommand();
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import { Command, Option } from 'commander';
|
|
2
|
-
import { url } from '~/util';
|
|
3
|
-
|
|
4
|
-
export const mapContensisOpts = (opts: any = {}) => ({
|
|
5
|
-
source:
|
|
6
|
-
opts.sourceAlias || opts.sourceProjectId
|
|
7
|
-
? {
|
|
8
|
-
url: opts.sourceAlias
|
|
9
|
-
? url(opts.sourceAlias, 'website').cms
|
|
10
|
-
: (undefined as any),
|
|
11
|
-
project: opts.sourceProjectId || (undefined as any),
|
|
12
|
-
}
|
|
13
|
-
: undefined,
|
|
14
|
-
models: opts.modelIds,
|
|
15
|
-
query:
|
|
16
|
-
opts.id || opts.entryIds || opts.phrase || opts.fields
|
|
17
|
-
? {
|
|
18
|
-
fields: opts.fields,
|
|
19
|
-
includeIds: opts.id || opts.entryIds,
|
|
20
|
-
searchTerm: opts.phrase,
|
|
21
|
-
}
|
|
22
|
-
: undefined,
|
|
23
|
-
zenQL: opts.zenql,
|
|
24
|
-
transformGuids: !opts.preserveGuids,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
/* Output options */
|
|
28
|
-
const output = new Option(
|
|
29
|
-
'-o, --output <output>',
|
|
30
|
-
'save output to a file e.g. --output ./output.txt'
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const format = new Option(
|
|
34
|
-
'-f, --format <format>',
|
|
35
|
-
'format output as csv, json, xml or table (default)'
|
|
36
|
-
).choices(['csv', 'json', 'xml', 'table']);
|
|
37
|
-
|
|
38
|
-
/* Connect options */
|
|
39
|
-
const alias = new Option(
|
|
40
|
-
'-a, --alias <alias>',
|
|
41
|
-
'the cloud CMS alias to connect your request with'
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
export const project = new Option(
|
|
45
|
-
'-p, --project-id <projectId>',
|
|
46
|
-
'the projectId to make your request with'
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
/* Authentication options */
|
|
50
|
-
const user = new Option(
|
|
51
|
-
'-u, --user <user>',
|
|
52
|
-
'the username to authenticate your request with'
|
|
53
|
-
);
|
|
54
|
-
const password = new Option(
|
|
55
|
-
'-pw, --password <password>',
|
|
56
|
-
'the password to use to login with (optional/insecure)'
|
|
57
|
-
);
|
|
58
|
-
const clientId = new Option(
|
|
59
|
-
'-id, --client-id <clientId>',
|
|
60
|
-
'the clientId to authenticate your request with'
|
|
61
|
-
);
|
|
62
|
-
const sharedSecret = new Option(
|
|
63
|
-
'-s, --shared-secret <sharedSecret>',
|
|
64
|
-
'the shared secret to use when logging in with a client id'
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
/* Entry get options */
|
|
68
|
-
export const zenql = new Option(
|
|
69
|
-
'-q, --zenql <zenql>',
|
|
70
|
-
'get entries with a supplied ZenQL statement'
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
export const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');
|
|
74
|
-
|
|
75
|
-
/* Import options */
|
|
76
|
-
export const fromFile = new Option(
|
|
77
|
-
'-file, --from-file <fromFile>',
|
|
78
|
-
'file path to import asset(s) from'
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
export const fromCms = new Option(
|
|
82
|
-
'-source, --source-alias <fromCms>',
|
|
83
|
-
'the cloud CMS alias to import asset(s) from'
|
|
84
|
-
);
|
|
85
|
-
export const fromProject = new Option(
|
|
86
|
-
'-sp, --source-project-id <fromProject>',
|
|
87
|
-
'the id of the Contensis project to import asset(s) from (Default: [last connected project])'
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
export const commit = new Option(
|
|
91
|
-
'--commit',
|
|
92
|
-
'add this flag only after you have run a preview of the import and agree with the analysis'
|
|
93
|
-
).default(false);
|
|
94
|
-
|
|
95
|
-
export const addConnectOptions = (program: Command) =>
|
|
96
|
-
program.addOption(alias.hideHelp()).addOption(project.hideHelp());
|
|
97
|
-
|
|
98
|
-
export const addAuthenticationOptions = (program: Command) =>
|
|
99
|
-
program
|
|
100
|
-
.addOption(user.hideHelp())
|
|
101
|
-
.addOption(password.hideHelp())
|
|
102
|
-
.addOption(clientId.hideHelp())
|
|
103
|
-
.addOption(sharedSecret.hideHelp());
|
|
104
|
-
|
|
105
|
-
const addOutputAndFormatOptions = (program: Command) =>
|
|
106
|
-
program.addOption(output).addOption(format);
|
|
107
|
-
|
|
108
|
-
export const addImportOptions = (program: Command) => {
|
|
109
|
-
for (const command of program.commands) {
|
|
110
|
-
command.addOption(fromFile).addOption(fromCms).addOption(fromProject);
|
|
111
|
-
}
|
|
112
|
-
return program;
|
|
113
|
-
};
|
|
114
|
-
export const addGetEntryOptions = (program: Command) => {
|
|
115
|
-
for (const command of program.commands) {
|
|
116
|
-
command.addOption(entryId).addOption(zenql);
|
|
117
|
-
}
|
|
118
|
-
return program;
|
|
119
|
-
};
|
|
120
|
-
export const addGlobalOptions = (program: Command) => {
|
|
121
|
-
for (const command of program.commands) {
|
|
122
|
-
addOutputAndFormatOptions(command);
|
|
123
|
-
addConnectOptions(command);
|
|
124
|
-
addAuthenticationOptions(command);
|
|
125
|
-
}
|
|
126
|
-
return program;
|
|
127
|
-
};
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
|
+
import { url } from '~/util';
|
|
3
|
+
|
|
4
|
+
export const mapContensisOpts = (opts: any = {}) => ({
|
|
5
|
+
source:
|
|
6
|
+
opts.sourceAlias || opts.sourceProjectId
|
|
7
|
+
? {
|
|
8
|
+
url: opts.sourceAlias
|
|
9
|
+
? url(opts.sourceAlias, 'website').cms
|
|
10
|
+
: (undefined as any),
|
|
11
|
+
project: opts.sourceProjectId || (undefined as any),
|
|
12
|
+
}
|
|
13
|
+
: undefined,
|
|
14
|
+
models: opts.modelIds,
|
|
15
|
+
query:
|
|
16
|
+
opts.id || opts.entryIds || opts.phrase || opts.fields
|
|
17
|
+
? {
|
|
18
|
+
fields: opts.fields,
|
|
19
|
+
includeIds: opts.id || opts.entryIds,
|
|
20
|
+
searchTerm: opts.phrase,
|
|
21
|
+
}
|
|
22
|
+
: undefined,
|
|
23
|
+
zenQL: opts.zenql,
|
|
24
|
+
transformGuids: !opts.preserveGuids,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/* Output options */
|
|
28
|
+
const output = new Option(
|
|
29
|
+
'-o, --output <output>',
|
|
30
|
+
'save output to a file e.g. --output ./output.txt'
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const format = new Option(
|
|
34
|
+
'-f, --format <format>',
|
|
35
|
+
'format output as csv, json, xml or table (default)'
|
|
36
|
+
).choices(['csv', 'json', 'xml', 'table']);
|
|
37
|
+
|
|
38
|
+
/* Connect options */
|
|
39
|
+
const alias = new Option(
|
|
40
|
+
'-a, --alias <alias>',
|
|
41
|
+
'the cloud CMS alias to connect your request with'
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export const project = new Option(
|
|
45
|
+
'-p, --project-id <projectId>',
|
|
46
|
+
'the projectId to make your request with'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
/* Authentication options */
|
|
50
|
+
const user = new Option(
|
|
51
|
+
'-u, --user <user>',
|
|
52
|
+
'the username to authenticate your request with'
|
|
53
|
+
);
|
|
54
|
+
const password = new Option(
|
|
55
|
+
'-pw, --password <password>',
|
|
56
|
+
'the password to use to login with (optional/insecure)'
|
|
57
|
+
);
|
|
58
|
+
const clientId = new Option(
|
|
59
|
+
'-id, --client-id <clientId>',
|
|
60
|
+
'the clientId to authenticate your request with'
|
|
61
|
+
);
|
|
62
|
+
const sharedSecret = new Option(
|
|
63
|
+
'-s, --shared-secret <sharedSecret>',
|
|
64
|
+
'the shared secret to use when logging in with a client id'
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
/* Entry get options */
|
|
68
|
+
export const zenql = new Option(
|
|
69
|
+
'-q, --zenql <zenql>',
|
|
70
|
+
'get entries with a supplied ZenQL statement'
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');
|
|
74
|
+
|
|
75
|
+
/* Import options */
|
|
76
|
+
export const fromFile = new Option(
|
|
77
|
+
'-file, --from-file <fromFile>',
|
|
78
|
+
'file path to import asset(s) from'
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export const fromCms = new Option(
|
|
82
|
+
'-source, --source-alias <fromCms>',
|
|
83
|
+
'the cloud CMS alias to import asset(s) from'
|
|
84
|
+
);
|
|
85
|
+
export const fromProject = new Option(
|
|
86
|
+
'-sp, --source-project-id <fromProject>',
|
|
87
|
+
'the id of the Contensis project to import asset(s) from (Default: [last connected project])'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
export const commit = new Option(
|
|
91
|
+
'--commit',
|
|
92
|
+
'add this flag only after you have run a preview of the import and agree with the analysis'
|
|
93
|
+
).default(false);
|
|
94
|
+
|
|
95
|
+
export const addConnectOptions = (program: Command) =>
|
|
96
|
+
program.addOption(alias.hideHelp()).addOption(project.hideHelp());
|
|
97
|
+
|
|
98
|
+
export const addAuthenticationOptions = (program: Command) =>
|
|
99
|
+
program
|
|
100
|
+
.addOption(user.hideHelp())
|
|
101
|
+
.addOption(password.hideHelp())
|
|
102
|
+
.addOption(clientId.hideHelp())
|
|
103
|
+
.addOption(sharedSecret.hideHelp());
|
|
104
|
+
|
|
105
|
+
const addOutputAndFormatOptions = (program: Command) =>
|
|
106
|
+
program.addOption(output).addOption(format);
|
|
107
|
+
|
|
108
|
+
export const addImportOptions = (program: Command) => {
|
|
109
|
+
for (const command of program.commands) {
|
|
110
|
+
command.addOption(fromFile).addOption(fromCms).addOption(fromProject);
|
|
111
|
+
}
|
|
112
|
+
return program;
|
|
113
|
+
};
|
|
114
|
+
export const addGetEntryOptions = (program: Command) => {
|
|
115
|
+
for (const command of program.commands) {
|
|
116
|
+
command.addOption(entryId).addOption(zenql);
|
|
117
|
+
}
|
|
118
|
+
return program;
|
|
119
|
+
};
|
|
120
|
+
export const addGlobalOptions = (program: Command) => {
|
|
121
|
+
for (const command of program.commands) {
|
|
122
|
+
addOutputAndFormatOptions(command);
|
|
123
|
+
addConnectOptions(command);
|
|
124
|
+
addAuthenticationOptions(command);
|
|
125
|
+
}
|
|
126
|
+
return program;
|
|
127
|
+
};
|