contensis-cli 1.0.0-beta.84 → 1.0.0-beta.86
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/dist/commands/create.js +2 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/get.js +43 -12
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +34 -14
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +2 -2
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/push.js +8 -8
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/set.js +1 -1
- package/dist/commands/set.js.map +1 -1
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +56 -0
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +7 -0
- package/dist/services/ContensisCliService.js.map +1 -1
- package/dist/services/ContensisDevService.js +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/create.ts +2 -2
- package/src/commands/get.ts +65 -10
- package/src/commands/globalOptions.ts +43 -14
- package/src/commands/import.ts +2 -2
- package/src/commands/login.ts +1 -1
- package/src/commands/push.ts +8 -8
- package/src/commands/set.ts +1 -1
- package/src/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.ts +44 -0
- package/src/services/ContensisCliService.ts +1 -1
- package/src/version.ts +1 -1
package/src/commands/get.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { Argument, Command } from 'commander';
|
|
1
|
+
import { Argument, Command, Option } from 'commander';
|
|
2
2
|
import { merge } from 'lodash';
|
|
3
3
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
addGlobalOptions,
|
|
6
|
+
assetTypes,
|
|
7
|
+
contentTypes,
|
|
8
|
+
entryId,
|
|
9
|
+
mapContensisOpts,
|
|
10
|
+
zenql,
|
|
11
|
+
} from './globalOptions';
|
|
5
12
|
|
|
6
13
|
export const makeGetCommand = () => {
|
|
7
14
|
const program = new Command()
|
|
@@ -144,6 +151,52 @@ Example call:
|
|
|
144
151
|
);
|
|
145
152
|
});
|
|
146
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({});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
sharedGetEntryOptions(
|
|
147
200
|
program
|
|
148
201
|
.command('entries')
|
|
149
202
|
.description('get entries')
|
|
@@ -151,24 +204,26 @@ Example call:
|
|
|
151
204
|
'[search phrase]',
|
|
152
205
|
'get entries with the search phrase, use quotes for multiple words'
|
|
153
206
|
)
|
|
154
|
-
|
|
207
|
+
.addOption(contentTypes)
|
|
155
208
|
.option(
|
|
156
|
-
|
|
209
|
+
'-d --dependents',
|
|
157
210
|
'find and return any dependencies of all found entries'
|
|
158
211
|
)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
212
|
+
)
|
|
213
|
+
.addOption(
|
|
214
|
+
new Option(
|
|
215
|
+
'--data-format <dataFormat>',
|
|
216
|
+
'find and return entries of a specific data format'
|
|
162
217
|
)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
'get entries with a supplied ZenQL statement'
|
|
218
|
+
.choices(['entry', 'asset', 'webpage'])
|
|
219
|
+
.default('entry')
|
|
166
220
|
)
|
|
167
221
|
.addHelpText(
|
|
168
222
|
'after',
|
|
169
223
|
`
|
|
170
224
|
Example call:
|
|
171
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
|
|
172
227
|
`
|
|
173
228
|
)
|
|
174
229
|
.action(async (phrase: string, opts, cmd) => {
|
|
@@ -13,10 +13,23 @@ export const mapContensisOpts = (opts: any = {}) => ({
|
|
|
13
13
|
: undefined,
|
|
14
14
|
models: opts.modelIds,
|
|
15
15
|
query:
|
|
16
|
-
opts.id ||
|
|
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
|
|
17
25
|
? {
|
|
26
|
+
assetTypes: opts.assetType,
|
|
27
|
+
contentTypeIds: opts.contentType,
|
|
28
|
+
dataFormats: opts.dataFormat ? [opts.dataFormat] : undefined,
|
|
18
29
|
fields: opts.fields,
|
|
19
30
|
includeIds: opts.id || opts.entryIds,
|
|
31
|
+
includePaths: opts.paths,
|
|
32
|
+
orderBy: opts.orderBy,
|
|
20
33
|
searchTerm: opts.phrase,
|
|
21
34
|
}
|
|
22
35
|
: undefined,
|
|
@@ -26,64 +39,72 @@ export const mapContensisOpts = (opts: any = {}) => ({
|
|
|
26
39
|
|
|
27
40
|
/* Output options */
|
|
28
41
|
const output = new Option(
|
|
29
|
-
'-o
|
|
42
|
+
'-o --output <output>',
|
|
30
43
|
'save output to a file e.g. --output ./output.txt'
|
|
31
44
|
);
|
|
32
45
|
|
|
33
46
|
const format = new Option(
|
|
34
|
-
'-f
|
|
47
|
+
'-f --format <format>',
|
|
35
48
|
'format output as csv, json, xml or table (default)'
|
|
36
49
|
).choices(['csv', 'json', 'xml', 'table']);
|
|
37
50
|
|
|
38
51
|
/* Connect options */
|
|
39
52
|
const alias = new Option(
|
|
40
|
-
'-a
|
|
53
|
+
'-a --alias <alias>',
|
|
41
54
|
'the cloud CMS alias to connect your request with'
|
|
42
55
|
);
|
|
43
56
|
|
|
44
57
|
export const project = new Option(
|
|
45
|
-
'-p
|
|
58
|
+
'-p --project-id <projectId>',
|
|
46
59
|
'the projectId to make your request with'
|
|
47
60
|
);
|
|
48
61
|
|
|
49
62
|
/* Authentication options */
|
|
50
63
|
const user = new Option(
|
|
51
|
-
'-u
|
|
64
|
+
'-u --user <user>',
|
|
52
65
|
'the username to authenticate your request with'
|
|
53
66
|
);
|
|
54
67
|
const password = new Option(
|
|
55
|
-
'-pw
|
|
68
|
+
'-pw --password <password>',
|
|
56
69
|
'the password to use to login with (optional/insecure)'
|
|
57
70
|
);
|
|
58
71
|
const clientId = new Option(
|
|
59
|
-
'-id
|
|
72
|
+
'-id --client-id <clientId>',
|
|
60
73
|
'the clientId to authenticate your request with'
|
|
61
74
|
);
|
|
62
75
|
const sharedSecret = new Option(
|
|
63
|
-
'-s
|
|
76
|
+
'-s --shared-secret <sharedSecret>',
|
|
64
77
|
'the shared secret to use when logging in with a client id'
|
|
65
78
|
);
|
|
66
79
|
|
|
67
80
|
/* Entry get options */
|
|
68
81
|
export const zenql = new Option(
|
|
69
|
-
'-q
|
|
82
|
+
'-q --zenql <zenql>',
|
|
70
83
|
'get entries with a supplied ZenQL statement'
|
|
71
84
|
);
|
|
72
85
|
|
|
73
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
|
+
);
|
|
74
95
|
|
|
75
96
|
/* Import options */
|
|
76
97
|
export const fromFile = new Option(
|
|
77
|
-
'-file
|
|
98
|
+
'-file --from-file <fromFile>',
|
|
78
99
|
'file path to import asset(s) from'
|
|
79
100
|
);
|
|
80
101
|
|
|
81
102
|
export const fromCms = new Option(
|
|
82
|
-
'-source
|
|
103
|
+
'-source --source-alias <fromCms>',
|
|
83
104
|
'the cloud CMS alias to import asset(s) from'
|
|
84
105
|
);
|
|
85
106
|
export const fromProject = new Option(
|
|
86
|
-
'-sp
|
|
107
|
+
'-sp --source-project-id <fromProject>',
|
|
87
108
|
'the id of the Contensis project to import asset(s) from (Default: [last connected project])'
|
|
88
109
|
);
|
|
89
110
|
|
|
@@ -111,9 +132,17 @@ export const addImportOptions = (program: Command) => {
|
|
|
111
132
|
}
|
|
112
133
|
return program;
|
|
113
134
|
};
|
|
135
|
+
|
|
136
|
+
export const getEntryOptions = (command: Command) =>
|
|
137
|
+
command
|
|
138
|
+
.addOption(entryId)
|
|
139
|
+
.addOption(zenql)
|
|
140
|
+
.addOption(contentTypes)
|
|
141
|
+
.addOption(assetTypes);
|
|
142
|
+
|
|
114
143
|
export const addGetEntryOptions = (program: Command) => {
|
|
115
144
|
for (const command of program.commands) {
|
|
116
|
-
command
|
|
145
|
+
getEntryOptions(command);
|
|
117
146
|
}
|
|
118
147
|
return program;
|
|
119
148
|
};
|
package/src/commands/import.ts
CHANGED
|
@@ -103,12 +103,12 @@ Example call:
|
|
|
103
103
|
)
|
|
104
104
|
.addOption(commit)
|
|
105
105
|
.option(
|
|
106
|
-
'-preserve
|
|
106
|
+
'-preserve --preserve-guids',
|
|
107
107
|
'include this flag when you are importing entries that you have previously exported and wish to update'
|
|
108
108
|
)
|
|
109
109
|
.addOption(
|
|
110
110
|
new Option(
|
|
111
|
-
'-oe
|
|
111
|
+
'-oe --output-entries <outputEntries>',
|
|
112
112
|
'which details of the entries included in the import to output'
|
|
113
113
|
)
|
|
114
114
|
.choices(['errors', 'changes', 'all'])
|
package/src/commands/login.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const makeLoginCommand = () => {
|
|
|
12
12
|
'the password to use to login with (optional/insecure)'
|
|
13
13
|
)
|
|
14
14
|
.option(
|
|
15
|
-
'-s
|
|
15
|
+
'-s --shared-secret <sharedSecret>',
|
|
16
16
|
'the shared secret to use when logging in with a client id'
|
|
17
17
|
)
|
|
18
18
|
.usage('<user/clientId> [password] [-s <sharedSecret>]')
|
package/src/commands/push.ts
CHANGED
|
@@ -21,36 +21,36 @@ export const makePushCommand = () => {
|
|
|
21
21
|
)
|
|
22
22
|
.argument('[branch]', 'the branch we are pushing to')
|
|
23
23
|
.option(
|
|
24
|
-
'-r
|
|
24
|
+
'-r --release',
|
|
25
25
|
'whether to release the pushed block version',
|
|
26
26
|
false
|
|
27
27
|
)
|
|
28
28
|
.option(
|
|
29
|
-
'-cid
|
|
29
|
+
'-cid --commit-id <commitId>',
|
|
30
30
|
'the id of the source git commit for the supplied image uri'
|
|
31
31
|
)
|
|
32
32
|
.option(
|
|
33
|
-
'-cmsg
|
|
33
|
+
'-cmsg --commit-message <commitMessage>',
|
|
34
34
|
'the git commit message for the supplied commit id'
|
|
35
35
|
)
|
|
36
36
|
.option(
|
|
37
|
-
'-cdt
|
|
37
|
+
'-cdt --commit-datetime <commitDateTime>',
|
|
38
38
|
'the timestamp of the source git commit for the supplied image uri'
|
|
39
39
|
)
|
|
40
40
|
.option(
|
|
41
|
-
'-author
|
|
41
|
+
'-author --author-email <authorEmail>',
|
|
42
42
|
'the git email address of the author of the source git commit'
|
|
43
43
|
)
|
|
44
44
|
.option(
|
|
45
|
-
'-committer
|
|
45
|
+
'-committer --committer-email <committerEmail>',
|
|
46
46
|
'the git email address of the commiter of the source git commit'
|
|
47
47
|
)
|
|
48
48
|
.option(
|
|
49
|
-
'-repo
|
|
49
|
+
'-repo --repository-url <repositoryUrl>',
|
|
50
50
|
'the url of the source repository for the supplied image uri'
|
|
51
51
|
)
|
|
52
52
|
.option(
|
|
53
|
-
'-pr
|
|
53
|
+
'-pr --provider <sourceProvider>',
|
|
54
54
|
'the url of the source repository for the supplied image uri'
|
|
55
55
|
)
|
|
56
56
|
.usage('<block-id> <image uri> [branch] [options]')
|
package/src/commands/set.ts
CHANGED
|
@@ -167,7 +167,7 @@ Example call:
|
|
|
167
167
|
.description('add entry permissions to a role')
|
|
168
168
|
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
169
169
|
.option(
|
|
170
|
-
'-contenttypes
|
|
170
|
+
'-contenttypes --content-type-ids [content-type-id...]',
|
|
171
171
|
'any content type ids to add permissions for'
|
|
172
172
|
)
|
|
173
173
|
.option(
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ContensisCli from '~/services/ContensisCliService';
|
|
2
|
+
|
|
3
|
+
interface ISiteConfigYaml {
|
|
4
|
+
alias: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
accessToken: string;
|
|
7
|
+
clientId: string;
|
|
8
|
+
sharedSecret: string;
|
|
9
|
+
blocks: {
|
|
10
|
+
id: string;
|
|
11
|
+
baseUri: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const mapSiteConfigYaml = async (cli: ContensisCli) => {
|
|
16
|
+
const credentials = await cli.GetCredentials(cli.env.lastUserId);
|
|
17
|
+
|
|
18
|
+
const blocks = [];
|
|
19
|
+
const blocksRaw = await cli.PrintBlocks();
|
|
20
|
+
|
|
21
|
+
for (const block of blocksRaw || []) {
|
|
22
|
+
const versions = await cli.PrintBlockVersions(
|
|
23
|
+
block.id,
|
|
24
|
+
'default',
|
|
25
|
+
'latest'
|
|
26
|
+
);
|
|
27
|
+
if (versions?.[0]) {
|
|
28
|
+
blocks.push({
|
|
29
|
+
id: versions[0].id,
|
|
30
|
+
baseUri: versions[0].previewUrl,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const siteConfig: ISiteConfigYaml = {
|
|
36
|
+
alias: cli.currentEnv,
|
|
37
|
+
projectId: cli.currentProject,
|
|
38
|
+
accessToken: '',
|
|
39
|
+
clientId: credentials?.current?.account || '',
|
|
40
|
+
sharedSecret: credentials?.current?.password || '',
|
|
41
|
+
blocks,
|
|
42
|
+
};
|
|
43
|
+
return siteConfig;
|
|
44
|
+
};
|
|
@@ -2307,7 +2307,7 @@ class ContensisCli {
|
|
|
2307
2307
|
|
|
2308
2308
|
export const cliCommand = (
|
|
2309
2309
|
commandArgs: string[],
|
|
2310
|
-
outputOpts
|
|
2310
|
+
outputOpts?: OutputOptionsConstructorArg,
|
|
2311
2311
|
contensisOpts: Partial<MigrateRequest> = {}
|
|
2312
2312
|
) => {
|
|
2313
2313
|
return new ContensisCli(['', '', ...commandArgs], outputOpts, contensisOpts);
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.0.0-beta.
|
|
1
|
+
export const LIB_VERSION = "1.0.0-beta.86";
|