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.
- package/README.md +1146 -78
- package/cli.js +3 -0
- 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/dev.js +75 -0
- package/dist/commands/dev.js.map +7 -0
- 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 +169 -32
- package/dist/commands/get.js.map +3 -3
- package/dist/commands/globalOptions.js +37 -12
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +47 -12
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +22 -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 +2 -2
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/push.js +17 -13
- 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 +259 -49
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +56 -0
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +7 -0
- package/dist/mappers/DevInit-to-CIWorkflow.js +127 -0
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +7 -0
- package/dist/mappers/DevInit-to-RolePermissions.js +54 -0
- package/dist/mappers/DevInit-to-RolePermissions.js.map +7 -0
- package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js +56 -0
- package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js.map +7 -0
- package/dist/models/CliService.d.js +17 -0
- package/dist/models/CliService.d.js.map +7 -0
- package/dist/models/DevService.d.js +17 -0
- package/dist/models/DevService.d.js.map +7 -0
- package/dist/providers/CredentialProvider.js +46 -14
- 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 +12 -6
- package/dist/providers/file-provider.js.map +3 -3
- package/dist/services/ContensisCliService.js +1148 -421
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/services/ContensisDevService.js +309 -0
- package/dist/services/ContensisDevService.js.map +7 -0
- package/dist/services/ContensisRoleService.js +87 -0
- package/dist/services/ContensisRoleService.js.map +7 -0
- package/dist/shell.js +58 -18
- 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 +102 -0
- package/dist/util/diff.js.map +7 -0
- package/dist/util/dotenv.js +57 -0
- package/dist/util/dotenv.js.map +7 -0
- package/dist/util/find.js +31 -0
- package/dist/util/find.js.map +7 -0
- package/dist/util/git.js +126 -0
- package/dist/util/git.js.map +7 -0
- package/dist/util/index.js +8 -2
- package/dist/util/index.js.map +3 -3
- package/dist/util/logger.js +90 -29
- package/dist/util/logger.js.map +3 -3
- package/dist/util/os.js +39 -0
- package/dist/util/os.js.map +7 -0
- package/dist/util/timers.js +49 -0
- package/dist/util/timers.js.map +7 -0
- package/dist/util/yaml.js +45 -0
- package/dist/util/yaml.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 +12 -3
- package/src/commands/connect.ts +3 -2
- package/src/commands/create.ts +61 -8
- package/src/commands/dev.ts +69 -0
- package/src/commands/diff.ts +41 -0
- package/src/commands/execute.ts +117 -0
- package/src/commands/get.ts +242 -28
- package/src/commands/globalOptions.ts +42 -12
- package/src/commands/import.ts +58 -8
- package/src/commands/index.ts +22 -1
- package/src/commands/list.ts +85 -11
- package/src/commands/login.ts +2 -1
- package/src/commands/push.ts +18 -11
- 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 +374 -66
- package/src/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.ts +44 -0
- package/src/mappers/DevInit-to-CIWorkflow.ts +150 -0
- package/src/mappers/DevInit-to-RolePermissions.ts +33 -0
- package/src/mappers/DevRequests-to-RequestHanderSiteConfigYaml.ts +44 -0
- package/src/models/CliService.d.ts +36 -0
- package/src/models/DevService.d.ts +5 -0
- package/src/models/JsModules.d.ts +1 -0
- package/src/providers/CredentialProvider.ts +51 -18
- package/src/providers/SessionCacheProvider.ts +29 -2
- package/src/providers/file-provider.ts +17 -6
- package/src/services/ContensisCliService.ts +1458 -518
- package/src/services/ContensisDevService.ts +365 -0
- package/src/services/ContensisRoleService.ts +76 -0
- package/src/shell.ts +68 -18
- package/src/util/console.printer.ts +240 -78
- package/src/util/diff.ts +113 -0
- package/src/util/dotenv.ts +37 -0
- package/src/util/find.ts +8 -0
- package/src/util/git.ts +130 -0
- package/src/util/index.ts +16 -7
- package/src/util/logger.ts +145 -31
- package/src/util/os.ts +7 -0
- package/src/util/timers.ts +24 -0
- package/src/util/yaml.ts +13 -0
- package/src/version.ts +1 -1
package/dist/commands/get.js
CHANGED
|
@@ -23,47 +23,147 @@ __export(get_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(get_exports);
|
|
25
25
|
var import_commander = require("commander");
|
|
26
|
+
var import_lodash = require("lodash");
|
|
26
27
|
var import_ContensisCliService = require("../services/ContensisCliService");
|
|
27
28
|
var import_globalOptions = require("./globalOptions");
|
|
28
29
|
const makeGetCommand = () => {
|
|
29
|
-
const program = new import_commander.Command().command("get").
|
|
30
|
-
|
|
30
|
+
const program = new import_commander.Command().command("get").description("get command").addHelpText("after", `
|
|
31
|
+
`).showHelpAfterError(true).exitOverride();
|
|
32
|
+
program.command("version").description("get current Contensis version").addHelpText(
|
|
33
|
+
"after",
|
|
34
|
+
`
|
|
35
|
+
Example call:
|
|
36
|
+
> version
|
|
37
|
+
`
|
|
38
|
+
).action(async (opts) => {
|
|
39
|
+
await (0, import_ContensisCliService.cliCommand)(["get", "version"], opts).PrintContensisVersion();
|
|
40
|
+
});
|
|
41
|
+
program.command("token").description("show a bearer token for the currently logged in user").addHelpText(
|
|
42
|
+
"after",
|
|
43
|
+
`
|
|
44
|
+
Example call:
|
|
45
|
+
> get token
|
|
46
|
+
`
|
|
47
|
+
).action(async (opts) => {
|
|
48
|
+
await (0, import_ContensisCliService.cliCommand)(["get", "token"], opts).PrintBearerToken();
|
|
49
|
+
});
|
|
50
|
+
program.command("project").description("get a project").argument("[projectId]", "id of the project to get (default: current)").addHelpText(
|
|
51
|
+
"after",
|
|
52
|
+
`
|
|
53
|
+
Example call:
|
|
54
|
+
> get project website
|
|
55
|
+
`
|
|
56
|
+
).action(async (projectId, opts) => {
|
|
57
|
+
await (0, import_ContensisCliService.cliCommand)(["get", "project", projectId], opts).PrintProject(
|
|
58
|
+
projectId
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
program.command("role").description("get a role").argument("<roleNameOrId>", "id or name of the role to get").addHelpText(
|
|
62
|
+
"after",
|
|
63
|
+
`
|
|
64
|
+
Example call:
|
|
65
|
+
> get role "entry admin"
|
|
66
|
+
`
|
|
67
|
+
).action(async (roleNameOrId, opts) => {
|
|
68
|
+
await (0, import_ContensisCliService.cliCommand)(["get", "role", roleNameOrId], opts).PrintRole(
|
|
69
|
+
roleNameOrId
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
program.command("webhook").description("get a webhook").argument("<webhookNameOrId...>", "id or name of the webhook(s) to get").addHelpText(
|
|
73
|
+
"after",
|
|
74
|
+
`
|
|
75
|
+
Example call:
|
|
76
|
+
> get webhook "Slack notification"
|
|
77
|
+
`
|
|
78
|
+
).action(async (webhookNameOrId, opts) => {
|
|
79
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
80
|
+
["get", "webhook", webhookNameOrId.join(" ")],
|
|
81
|
+
opts
|
|
82
|
+
).PrintWebhookSubscriptions(webhookNameOrId);
|
|
83
|
+
});
|
|
84
|
+
program.command("model").description("get a content model").argument("<contentTypeId...>", "ids of the content models to get").addHelpText(
|
|
85
|
+
"after",
|
|
86
|
+
`
|
|
87
|
+
Example call:
|
|
88
|
+
> get model podcast podcastLinks
|
|
89
|
+
`
|
|
90
|
+
).action(async (modelIds, opts) => {
|
|
91
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
92
|
+
["get", "model", modelIds.join(" ")],
|
|
93
|
+
opts
|
|
94
|
+
).PrintContentModels(modelIds);
|
|
95
|
+
});
|
|
96
|
+
program.command("contenttype").description("get a content type").argument("<contentTypeId>", "the API id of the content type to get").addHelpText(
|
|
31
97
|
"after",
|
|
32
98
|
`
|
|
33
99
|
Example call:
|
|
34
100
|
> get contenttype {contentTypeId} -o content-type-backup.json
|
|
35
101
|
`
|
|
36
102
|
).action(async (contentTypeId, opts) => {
|
|
37
|
-
await (0, import_ContensisCliService.cliCommand)(
|
|
38
|
-
contentTypeId
|
|
39
|
-
|
|
103
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
104
|
+
["get", "contenttype", contentTypeId],
|
|
105
|
+
opts
|
|
106
|
+
).PrintContentType(contentTypeId);
|
|
40
107
|
});
|
|
41
|
-
program.command("component").argument("<componentId>", "the API id of the component to get").addHelpText(
|
|
108
|
+
program.command("component").description("get a component").argument("<componentId>", "the API id of the component to get").addHelpText(
|
|
42
109
|
"after",
|
|
43
110
|
`
|
|
44
111
|
Example call:
|
|
45
112
|
> get component {componentId} -o component-backup.json
|
|
46
113
|
`
|
|
47
114
|
).action(async (componentId, opts) => {
|
|
48
|
-
await (0, import_ContensisCliService.cliCommand)(["get", "component"], opts).PrintComponent(
|
|
115
|
+
await (0, import_ContensisCliService.cliCommand)(["get", "component", componentId], opts).PrintComponent(
|
|
116
|
+
componentId
|
|
117
|
+
);
|
|
49
118
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
119
|
+
const sharedGetEntryOptions = (command) => command.addOption(import_globalOptions.entryId).addOption(import_globalOptions.zenql).addOption(
|
|
120
|
+
new import_commander.Option(
|
|
121
|
+
"-fi --fields <fields...>",
|
|
122
|
+
"limit the output fields on returned entries"
|
|
123
|
+
)
|
|
124
|
+
).addOption(
|
|
125
|
+
new import_commander.Option(
|
|
126
|
+
"-ob --order-by <orderBy...>",
|
|
127
|
+
'field name(s) to order the results by (prefix "-" for descending)'
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
sharedGetEntryOptions(
|
|
131
|
+
program.command("assets").description("get asset entries").argument(
|
|
132
|
+
"[search phrase]",
|
|
133
|
+
"get assets with the search phrase, use quotes for multiple words"
|
|
134
|
+
).addOption(import_globalOptions.assetTypes)
|
|
135
|
+
).option("-l --paths <paths...>", "get assets under the given path(s)").addHelpText(
|
|
136
|
+
"after",
|
|
137
|
+
`
|
|
138
|
+
Example call:
|
|
139
|
+
> get assets --zenql "sys.contentTypeId = blog" --fields sys.id sys.properties.filePath sys.properties.filename
|
|
140
|
+
`
|
|
141
|
+
).action(async (phrase, opts) => {
|
|
142
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
143
|
+
["get", "assets"],
|
|
144
|
+
opts,
|
|
145
|
+
(0, import_globalOptions.mapContensisOpts)({ dataFormat: "asset", phrase, ...opts })
|
|
146
|
+
).GetEntries({});
|
|
147
|
+
});
|
|
148
|
+
sharedGetEntryOptions(
|
|
149
|
+
program.command("entries").description("get entries").argument(
|
|
150
|
+
"[search phrase]",
|
|
151
|
+
"get entries with the search phrase, use quotes for multiple words"
|
|
152
|
+
).addOption(import_globalOptions.contentTypes).option(
|
|
153
|
+
"-d --dependents",
|
|
154
|
+
"find and return any dependencies of all found entries"
|
|
155
|
+
)
|
|
156
|
+
).addOption(
|
|
157
|
+
new import_commander.Option(
|
|
158
|
+
"--data-format <dataFormat>",
|
|
159
|
+
"find and return entries of a specific data format"
|
|
160
|
+
).choices(["entry", "asset", "webpage"]).default("entry")
|
|
62
161
|
).addHelpText(
|
|
63
162
|
"after",
|
|
64
163
|
`
|
|
65
164
|
Example call:
|
|
66
165
|
> get entries --zenql "sys.contentTypeId = blog" --fields entryTitle entryDescription sys.id --output ./blog-posts.csv --format csv
|
|
166
|
+
> get entries --content-type blog --fields entryTitle sys.version.modified --order-by -sys.version.modified
|
|
67
167
|
`
|
|
68
168
|
).action(async (phrase, opts, cmd) => {
|
|
69
169
|
await (0, import_ContensisCliService.cliCommand)(
|
|
@@ -74,42 +174,79 @@ Example call:
|
|
|
74
174
|
withDependents: opts.dependents
|
|
75
175
|
});
|
|
76
176
|
});
|
|
77
|
-
|
|
177
|
+
program.command("nodes").description("get nodes").argument("[root]", "get node(s) from the specified path e.g. /blog", "/").option(
|
|
178
|
+
"-d --depth <depth>",
|
|
179
|
+
"get nodes with children to a specified depth",
|
|
180
|
+
"0"
|
|
181
|
+
).addHelpText(
|
|
182
|
+
"after",
|
|
183
|
+
`
|
|
184
|
+
Example call:
|
|
185
|
+
> get nodes /blog --depth 1
|
|
186
|
+
`
|
|
187
|
+
).action(async (root, opts) => {
|
|
188
|
+
await (0, import_ContensisCliService.cliCommand)(["get", "nodes"], opts, (0, import_globalOptions.mapContensisOpts)(opts)).GetNodes(
|
|
189
|
+
root,
|
|
190
|
+
opts.depth
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
const block = program.command("block").description("get a block or block version").argument("[blockId]", "the block to get version details for").argument(
|
|
78
194
|
"[branch]",
|
|
79
195
|
"the branch of the block to get version details for",
|
|
80
|
-
"
|
|
196
|
+
"default"
|
|
81
197
|
).argument(
|
|
82
198
|
"[version]",
|
|
83
199
|
"get a specific version of the block pushed to the specified branch"
|
|
200
|
+
).addHelpText(
|
|
201
|
+
"after",
|
|
202
|
+
`
|
|
203
|
+
Example call:
|
|
204
|
+
> get block contensis-website
|
|
205
|
+
> get block contensis-website develop latest
|
|
206
|
+
`
|
|
84
207
|
).action(async (blockId, branch, version, opts) => {
|
|
85
|
-
await (0, import_ContensisCliService.cliCommand)(["get", "block"], opts).PrintBlockVersions(
|
|
208
|
+
await (0, import_ContensisCliService.cliCommand)(["get", "block", blockId], opts).PrintBlockVersions(
|
|
86
209
|
blockId,
|
|
87
210
|
branch,
|
|
88
211
|
version
|
|
89
212
|
);
|
|
90
213
|
});
|
|
91
|
-
|
|
92
|
-
"[dataCenter]",
|
|
93
|
-
"the datacentre of the block to get logs for"
|
|
94
|
-
).choices(["hq", "london", "manchester"]).default("hq");
|
|
95
|
-
block.command("logs").argument("[blockId]", "the block to get version logs for").argument(
|
|
214
|
+
block.command("logs").description("get logs for a block").argument("[blockId]", "the block to get version logs for").argument(
|
|
96
215
|
"[branch]",
|
|
97
216
|
"the branch of the block to get version details for",
|
|
98
|
-
"
|
|
217
|
+
"default"
|
|
99
218
|
).argument(
|
|
100
219
|
"[version]",
|
|
101
220
|
"the version of the block pushed to the branch to get logs for",
|
|
102
221
|
"latest"
|
|
103
|
-
).addArgument(
|
|
104
|
-
|
|
105
|
-
|
|
222
|
+
).addArgument(
|
|
223
|
+
new import_commander.Argument(
|
|
224
|
+
"[dataCenter]",
|
|
225
|
+
"the datacentre of the block to get logs for"
|
|
226
|
+
).choices(["hq", "london", "manchester", "all"]).default("all")
|
|
227
|
+
).option("-t --follow", "follow block logs in near realtime", false).usage("get block logs [blockId] [branch] [version] [dataCenter]").addHelpText(
|
|
228
|
+
"after",
|
|
229
|
+
`
|
|
230
|
+
Example call:
|
|
231
|
+
> get block logs contensis-website default
|
|
232
|
+
> get block logs contensis-website master latest london --follow
|
|
233
|
+
`
|
|
234
|
+
).action(
|
|
235
|
+
async (blockId, branch, version, dataCenter, opts) => {
|
|
236
|
+
const parentOpts = block.opts() || {};
|
|
237
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
238
|
+
["get", "block", "logs"],
|
|
239
|
+
(0, import_lodash.merge)(opts, parentOpts)
|
|
240
|
+
).PrintBlockLogs(
|
|
106
241
|
blockId,
|
|
107
242
|
branch,
|
|
108
243
|
version,
|
|
109
|
-
|
|
244
|
+
dataCenter === "all" ? void 0 : dataCenter,
|
|
245
|
+
opts.follow
|
|
110
246
|
);
|
|
111
247
|
}
|
|
112
248
|
);
|
|
249
|
+
(0, import_globalOptions.addGlobalOptions)(block);
|
|
113
250
|
return program;
|
|
114
251
|
};
|
|
115
252
|
const get = makeGetCommand();
|
package/dist/commands/get.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/get.ts"],
|
|
4
|
-
"sourcesContent": ["import { Argument, Command } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { Argument, Command, Option } from 'commander';\nimport { merge } from 'lodash';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport {\n addGlobalOptions,\n assetTypes,\n contentTypes,\n entryId,\n mapContensisOpts,\n zenql,\n} from './globalOptions';\n\nexport const makeGetCommand = () => {\n const program = new Command()\n .command('get')\n .description('get command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n program\n .command('version')\n .description('get current Contensis version')\n .addHelpText(\n 'after',\n `\nExample call:\n > version\n`\n )\n .action(async opts => {\n await cliCommand(['get', 'version'], opts).PrintContensisVersion();\n });\n\n program\n .command('token')\n .description('show a bearer token for the currently logged in user')\n .addHelpText(\n 'after',\n `\nExample call:\n > get token\n`\n )\n .action(async opts => {\n await cliCommand(['get', 'token'], opts).PrintBearerToken();\n });\n\n program\n .command('project')\n .description('get a project')\n .argument('[projectId]', 'id of the project to get (default: current)')\n .addHelpText(\n 'after',\n `\nExample call:\n > get project website\n`\n )\n .action(async (projectId: string, opts) => {\n await cliCommand(['get', 'project', projectId], opts).PrintProject(\n projectId\n );\n });\n\n program\n .command('role')\n .description('get a role')\n .argument('<roleNameOrId>', 'id or name of the role to get')\n .addHelpText(\n 'after',\n `\nExample call:\n > get role \"entry admin\"\n`\n )\n .action(async (roleNameOrId: string, opts) => {\n await cliCommand(['get', 'role', roleNameOrId], opts).PrintRole(\n roleNameOrId\n );\n });\n\n program\n .command('webhook')\n .description('get a webhook')\n .argument('<webhookNameOrId...>', 'id or name of the webhook(s) to get')\n .addHelpText(\n 'after',\n `\nExample call:\n > get webhook \"Slack notification\"\n`\n )\n .action(async (webhookNameOrId: string[], opts) => {\n await cliCommand(\n ['get', 'webhook', webhookNameOrId.join(' ')],\n opts\n ).PrintWebhookSubscriptions(webhookNameOrId);\n });\n\n program\n .command('model')\n .description('get a content model')\n .argument('<contentTypeId...>', 'ids of the content models to get')\n .addHelpText(\n 'after',\n `\nExample call:\n > get model podcast podcastLinks\n`\n )\n .action(async (modelIds: string[], opts) => {\n await cliCommand(\n ['get', 'model', modelIds.join(' ')],\n opts\n ).PrintContentModels(modelIds);\n });\n\n program\n .command('contenttype')\n .description('get a content type')\n .argument('<contentTypeId>', 'the API id of the content type to get')\n .addHelpText(\n 'after',\n `\nExample call:\n > get contenttype {contentTypeId} -o content-type-backup.json\n`\n )\n .action(async (contentTypeId: string, opts) => {\n await cliCommand(\n ['get', 'contenttype', contentTypeId],\n opts\n ).PrintContentType(contentTypeId);\n });\n\n program\n .command('component')\n .description('get a component')\n .argument('<componentId>', 'the API id of the component to get')\n .addHelpText(\n 'after',\n `\nExample call:\n > get component {componentId} -o component-backup.json\n`\n )\n .action(async (componentId: string, opts) => {\n await cliCommand(['get', 'component', componentId], opts).PrintComponent(\n componentId\n );\n });\n\n const sharedGetEntryOptions = (command: Command) =>\n command\n .addOption(entryId)\n .addOption(zenql)\n .addOption(\n new Option(\n '-fi --fields <fields...>',\n 'limit the output fields on returned entries'\n )\n )\n .addOption(\n new Option(\n '-ob --order-by <orderBy...>',\n 'field name(s) to order the results by (prefix \"-\" for descending)'\n )\n );\n\n sharedGetEntryOptions(\n program\n .command('assets')\n .description('get asset entries')\n .argument(\n '[search phrase]',\n 'get assets with the search phrase, use quotes for multiple words'\n )\n .addOption(assetTypes)\n )\n .option('-l --paths <paths...>', 'get assets under the given path(s)')\n .addHelpText(\n 'after',\n `\nExample call:\n > get assets --zenql \"sys.contentTypeId = blog\" --fields sys.id sys.properties.filePath sys.properties.filename\n`\n )\n .action(async (phrase: string, opts) => {\n // Maintaining a separate command for assets vs entries\n // allows us to offer up more options when dealing with just assets\n await cliCommand(\n ['get', 'assets'],\n opts,\n mapContensisOpts({ dataFormat: 'asset', phrase, ...opts })\n ).GetEntries({});\n });\n\n sharedGetEntryOptions(\n program\n .command('entries')\n .description('get entries')\n .argument(\n '[search phrase]',\n 'get entries with the search phrase, use quotes for multiple words'\n )\n .addOption(contentTypes)\n .option(\n '-d --dependents',\n 'find and return any dependencies of all found entries'\n )\n )\n .addOption(\n new Option(\n '--data-format <dataFormat>',\n 'find and return entries of a specific data format'\n )\n .choices(['entry', 'asset', 'webpage'])\n .default('entry')\n )\n .addHelpText(\n 'after',\n `\nExample call:\n > get entries --zenql \"sys.contentTypeId = blog\" --fields entryTitle entryDescription sys.id --output ./blog-posts.csv --format csv\n > get entries --content-type blog --fields entryTitle sys.version.modified --order-by -sys.version.modified\n`\n )\n .action(async (phrase: string, opts, cmd) => {\n // console.log('phrase: ', phrase, '\\nopts:', JSON.stringify(opts, null, 2));\n // console.log('opts:', JSON.stringify(opts, null, 2));\n await cliCommand(\n ['get', 'entries'],\n opts,\n mapContensisOpts({ phrase, ...opts })\n ).GetEntries({\n withDependents: opts.dependents,\n });\n });\n\n program\n .command('nodes')\n .description('get nodes')\n .argument('[root]', 'get node(s) from the specified path e.g. /blog', '/')\n .option(\n '-d --depth <depth>',\n 'get nodes with children to a specified depth',\n '0'\n )\n .addHelpText(\n 'after',\n `\nExample call:\n > get nodes /blog --depth 1\n`\n )\n .action(async (root: string, opts) => {\n await cliCommand(['get', 'nodes'], opts, mapContensisOpts(opts)).GetNodes(\n root,\n opts.depth\n );\n });\n\n const block = program\n .command('block')\n .description('get a block or block version')\n .argument('[blockId]', 'the block to get version details for')\n .argument(\n '[branch]',\n 'the branch of the block to get version details for',\n 'default'\n )\n .argument(\n '[version]',\n 'get a specific version of the block pushed to the specified branch'\n )\n .addHelpText(\n 'after',\n `\nExample call:\n > get block contensis-website\n > get block contensis-website develop latest\n`\n )\n .action(async (blockId: string, branch: string, version: string, opts) => {\n await cliCommand(['get', 'block', blockId], opts).PrintBlockVersions(\n blockId,\n branch,\n version\n );\n });\n\n block\n .command('logs')\n .description('get logs for a block')\n .argument('[blockId]', 'the block to get version logs for')\n .argument(\n '[branch]',\n 'the branch of the block to get version details for',\n 'default'\n )\n .argument(\n '[version]',\n 'the version of the block pushed to the branch to get logs for',\n 'latest'\n )\n .addArgument(\n new Argument(\n '[dataCenter]',\n 'the datacentre of the block to get logs for'\n )\n .choices(['hq', 'london', 'manchester', 'all'])\n .default('all')\n )\n .option('-t --follow', 'follow block logs in near realtime', false)\n .usage('get block logs [blockId] [branch] [version] [dataCenter]')\n .addHelpText(\n 'after',\n `\nExample call:\n > get block logs contensis-website default\n > get block logs contensis-website master latest london --follow\n`\n )\n .action(\n async (\n blockId: string,\n branch: string,\n version: string,\n dataCenter: 'hq' | 'manchester' | 'london' | 'all',\n opts\n ) => {\n const parentOpts = block.opts() || {};\n await cliCommand(\n ['get', 'block', 'logs'],\n merge(opts, parentOpts)\n ).PrintBlockLogs(\n blockId,\n branch,\n version,\n dataCenter === 'all' ? undefined : dataCenter,\n opts.follow as boolean\n );\n }\n );\n\n // Add global opts for inner sub-commands\n addGlobalOptions(block);\n\n return program;\n};\n\nexport const get = makeGetCommand();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,oBAAsB;AACtB,iCAA2B;AAC3B,2BAOO;AAEA,MAAM,iBAAiB,MAAM;AAClC,QAAM,UAAU,IAAI,yBAAQ,EACzB,QAAQ,KAAK,EACb,YAAY,aAAa,EACzB,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,aAAa;AAEhB,UACG,QAAQ,SAAS,EACjB,YAAY,+BAA+B,EAC3C;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC,OAAO,OAAM,SAAQ;AACpB,cAAM,uCAAW,CAAC,OAAO,SAAS,GAAG,IAAI,EAAE,sBAAsB;AAAA,EACnE,CAAC;AAEH,UACG,QAAQ,OAAO,EACf,YAAY,sDAAsD,EAClE;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC,OAAO,OAAM,SAAQ;AACpB,cAAM,uCAAW,CAAC,OAAO,OAAO,GAAG,IAAI,EAAE,iBAAiB;AAAA,EAC5D,CAAC;AAEH,UACG,QAAQ,SAAS,EACjB,YAAY,eAAe,EAC3B,SAAS,eAAe,6CAA6C,EACrE;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC,OAAO,OAAO,WAAmB,SAAS;AACzC,cAAM,uCAAW,CAAC,OAAO,WAAW,SAAS,GAAG,IAAI,EAAE;AAAA,MACpD;AAAA,IACF;AAAA,EACF,CAAC;AAEH,UACG,QAAQ,MAAM,EACd,YAAY,YAAY,EACxB,SAAS,kBAAkB,+BAA+B,EAC1D;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC,OAAO,OAAO,cAAsB,SAAS;AAC5C,cAA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AAS,MAAM;AAAA,YACvB,qBAAM,MAAM,UAAU;AAAA,MACxB,EAAE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,QAAQ,SAAY;AAAA,QACnC,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAGF,6CAAiB,KAAK;AAEtB,SAAO;AACT;AAEO,MAAM,MAAM,eAAe;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -23,35 +23,46 @@ __export(globalOptions_exports, {
|
|
|
23
23
|
addGetEntryOptions: () => addGetEntryOptions,
|
|
24
24
|
addGlobalOptions: () => addGlobalOptions,
|
|
25
25
|
addImportOptions: () => addImportOptions,
|
|
26
|
+
assetTypes: () => assetTypes,
|
|
26
27
|
commit: () => commit,
|
|
28
|
+
contentTypes: () => contentTypes,
|
|
29
|
+
entryId: () => entryId,
|
|
27
30
|
fromCms: () => fromCms,
|
|
28
31
|
fromFile: () => fromFile,
|
|
29
32
|
fromProject: () => fromProject,
|
|
33
|
+
getEntryOptions: () => getEntryOptions,
|
|
30
34
|
mapContensisOpts: () => mapContensisOpts,
|
|
31
|
-
project: () => project
|
|
35
|
+
project: () => project,
|
|
36
|
+
zenql: () => zenql
|
|
32
37
|
});
|
|
33
38
|
module.exports = __toCommonJS(globalOptions_exports);
|
|
34
39
|
var import_commander = require("commander");
|
|
35
40
|
var import_util = require("../util");
|
|
36
41
|
const mapContensisOpts = (opts = {}) => ({
|
|
37
|
-
source: opts.
|
|
38
|
-
url: opts.
|
|
42
|
+
source: opts.sourceAlias || opts.sourceProjectId ? {
|
|
43
|
+
url: opts.sourceAlias ? (0, import_util.url)(opts.sourceAlias, "website").cms : void 0,
|
|
39
44
|
project: opts.sourceProjectId || void 0
|
|
40
45
|
} : void 0,
|
|
41
|
-
|
|
46
|
+
models: opts.modelIds,
|
|
47
|
+
query: opts.id || opts.entryIds || opts.phrase || opts.fields || opts.orderBy || opts.paths || opts.assetType || opts.contentType || opts.dataFormat ? {
|
|
48
|
+
assetTypes: opts.assetType,
|
|
49
|
+
contentTypeIds: opts.contentType,
|
|
50
|
+
dataFormats: opts.dataFormat ? [opts.dataFormat] : void 0,
|
|
42
51
|
fields: opts.fields,
|
|
43
|
-
includeIds: opts.id,
|
|
52
|
+
includeIds: opts.id || opts.entryIds,
|
|
53
|
+
includePaths: opts.paths,
|
|
54
|
+
orderBy: opts.orderBy,
|
|
44
55
|
searchTerm: opts.phrase
|
|
45
56
|
} : void 0,
|
|
46
57
|
zenQL: opts.zenql,
|
|
47
58
|
transformGuids: !opts.preserveGuids
|
|
48
59
|
});
|
|
49
60
|
const output = new import_commander.Option(
|
|
50
|
-
"-o
|
|
61
|
+
"-o --output <output>",
|
|
51
62
|
"save output to a file e.g. --output ./output.txt"
|
|
52
63
|
);
|
|
53
64
|
const format = new import_commander.Option(
|
|
54
|
-
"-f
|
|
65
|
+
"-f --format <format>",
|
|
55
66
|
"format output as csv, json, xml or table (default)"
|
|
56
67
|
).choices(["csv", "json", "xml", "table"]);
|
|
57
68
|
const alias = new import_commander.Option(
|
|
@@ -79,10 +90,18 @@ const sharedSecret = new import_commander.Option(
|
|
|
79
90
|
"the shared secret to use when logging in with a client id"
|
|
80
91
|
);
|
|
81
92
|
const zenql = new import_commander.Option(
|
|
82
|
-
"-q
|
|
93
|
+
"-q --zenql <zenql>",
|
|
83
94
|
"get entries with a supplied ZenQL statement"
|
|
84
95
|
);
|
|
85
|
-
const entryId = new import_commander.Option("-i --id <id...>", "the entry id to get");
|
|
96
|
+
const entryId = new import_commander.Option("-i --id <id...>", "the entry id(s) to get");
|
|
97
|
+
const contentTypes = new import_commander.Option(
|
|
98
|
+
"-c --content-type <contentType...>",
|
|
99
|
+
"get entries of these content type(s)"
|
|
100
|
+
);
|
|
101
|
+
const assetTypes = new import_commander.Option(
|
|
102
|
+
"-at --asset-type <assetType...>",
|
|
103
|
+
"get assets of given content type(s) e.g. image word pdf"
|
|
104
|
+
);
|
|
86
105
|
const fromFile = new import_commander.Option(
|
|
87
106
|
"-file --from-file <fromFile>",
|
|
88
107
|
"file path to import asset(s) from"
|
|
@@ -97,7 +116,7 @@ const fromProject = new import_commander.Option(
|
|
|
97
116
|
);
|
|
98
117
|
const commit = new import_commander.Option(
|
|
99
118
|
"--commit",
|
|
100
|
-
"
|
|
119
|
+
"add this flag only after you have run a preview of the import and agree with the analysis"
|
|
101
120
|
).default(false);
|
|
102
121
|
const addConnectOptions = (program) => program.addOption(alias.hideHelp()).addOption(project.hideHelp());
|
|
103
122
|
const addAuthenticationOptions = (program) => program.addOption(user.hideHelp()).addOption(password.hideHelp()).addOption(clientId.hideHelp()).addOption(sharedSecret.hideHelp());
|
|
@@ -108,9 +127,10 @@ const addImportOptions = (program) => {
|
|
|
108
127
|
}
|
|
109
128
|
return program;
|
|
110
129
|
};
|
|
130
|
+
const getEntryOptions = (command) => command.addOption(entryId).addOption(zenql).addOption(contentTypes).addOption(assetTypes);
|
|
111
131
|
const addGetEntryOptions = (program) => {
|
|
112
132
|
for (const command of program.commands) {
|
|
113
|
-
command
|
|
133
|
+
getEntryOptions(command);
|
|
114
134
|
}
|
|
115
135
|
return program;
|
|
116
136
|
};
|
|
@@ -129,11 +149,16 @@ const addGlobalOptions = (program) => {
|
|
|
129
149
|
addGetEntryOptions,
|
|
130
150
|
addGlobalOptions,
|
|
131
151
|
addImportOptions,
|
|
152
|
+
assetTypes,
|
|
132
153
|
commit,
|
|
154
|
+
contentTypes,
|
|
155
|
+
entryId,
|
|
133
156
|
fromCms,
|
|
134
157
|
fromFile,
|
|
135
158
|
fromProject,
|
|
159
|
+
getEntryOptions,
|
|
136
160
|
mapContensisOpts,
|
|
137
|
-
project
|
|
161
|
+
project,
|
|
162
|
+
zenql
|
|
138
163
|
});
|
|
139
164
|
//# sourceMappingURL=globalOptions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/globalOptions.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command, Option } from 'commander';\nimport { url } from '~/util';\n\nexport const mapContensisOpts = (opts: any = {}) => ({\n source:\n opts.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgC;AAChC,kBAAoB;AAEb,MAAM,mBAAmB,CAAC,OAAY,CAAC,OAAO;AAAA,EACnD,QACE,KAAK,
|
|
4
|
+
"sourcesContent": ["import { Command, Option } from 'commander';\nimport { url } from '~/util';\n\nexport const mapContensisOpts = (opts: any = {}) => ({\n source:\n opts.sourceAlias || opts.sourceProjectId\n ? {\n url: opts.sourceAlias\n ? url(opts.sourceAlias, 'website').cms\n : (undefined as any),\n project: opts.sourceProjectId || (undefined as any),\n }\n : undefined,\n models: opts.modelIds,\n query:\n opts.id ||\n opts.entryIds ||\n opts.phrase ||\n opts.fields ||\n opts.orderBy ||\n opts.paths ||\n opts.assetType ||\n opts.contentType ||\n opts.dataFormat\n ? {\n assetTypes: opts.assetType,\n contentTypeIds: opts.contentType,\n dataFormats: opts.dataFormat ? [opts.dataFormat] : undefined,\n fields: opts.fields,\n includeIds: opts.id || opts.entryIds,\n includePaths: opts.paths,\n orderBy: opts.orderBy,\n searchTerm: opts.phrase,\n }\n : undefined,\n zenQL: opts.zenql,\n transformGuids: !opts.preserveGuids,\n});\n\n/* Output options */\nconst output = new Option(\n '-o --output <output>',\n 'save output to a file e.g. --output ./output.txt'\n);\n\nconst format = new Option(\n '-f --format <format>',\n 'format output as csv, json, xml or table (default)'\n).choices(['csv', 'json', 'xml', 'table']);\n\n/* Connect options */\nconst alias = new Option(\n '-a --alias <alias>',\n 'the cloud CMS alias to connect your request with'\n);\n\nexport const project = new Option(\n '-p --project-id <projectId>',\n 'the projectId to make your request with'\n);\n\n/* Authentication options */\nconst user = new Option(\n '-u --user <user>',\n 'the username to authenticate your request with'\n);\nconst password = new Option(\n '-pw --password <password>',\n 'the password to use to login with (optional/insecure)'\n);\nconst clientId = new Option(\n '-id --client-id <clientId>',\n 'the clientId to authenticate your request with'\n);\nconst sharedSecret = new Option(\n '-s --shared-secret <sharedSecret>',\n 'the shared secret to use when logging in with a client id'\n);\n\n/* Entry get options */\nexport const zenql = new Option(\n '-q --zenql <zenql>',\n 'get entries with a supplied ZenQL statement'\n);\n\nexport const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');\nexport const contentTypes = new Option(\n '-c --content-type <contentType...>',\n 'get entries of these content type(s)'\n);\nexport const assetTypes = new Option(\n '-at --asset-type <assetType...>',\n 'get assets of given content type(s) e.g. image word pdf'\n);\n\n/* Import options */\nexport const fromFile = new Option(\n '-file --from-file <fromFile>',\n 'file path to import asset(s) from'\n);\n\nexport const fromCms = new Option(\n '-source --source-alias <fromCms>',\n 'the cloud CMS alias to import asset(s) from'\n);\nexport const fromProject = new Option(\n '-sp --source-project-id <fromProject>',\n 'the id of the Contensis project to import asset(s) from (Default: [last connected project])'\n);\n\nexport const commit = new Option(\n '--commit',\n 'add this flag only after you have run a preview of the import and agree with the analysis'\n).default(false);\n\nexport const addConnectOptions = (program: Command) =>\n program.addOption(alias.hideHelp()).addOption(project.hideHelp());\n\nexport const addAuthenticationOptions = (program: Command) =>\n program\n .addOption(user.hideHelp())\n .addOption(password.hideHelp())\n .addOption(clientId.hideHelp())\n .addOption(sharedSecret.hideHelp());\n\nconst addOutputAndFormatOptions = (program: Command) =>\n program.addOption(output).addOption(format);\n\nexport const addImportOptions = (program: Command) => {\n for (const command of program.commands) {\n command.addOption(fromFile).addOption(fromCms).addOption(fromProject);\n }\n return program;\n};\n\nexport const getEntryOptions = (command: Command) =>\n command\n .addOption(entryId)\n .addOption(zenql)\n .addOption(contentTypes)\n .addOption(assetTypes);\n\nexport const addGetEntryOptions = (program: Command) => {\n for (const command of program.commands) {\n getEntryOptions(command);\n }\n return program;\n};\nexport const addGlobalOptions = (program: Command) => {\n for (const command of program.commands) {\n addOutputAndFormatOptions(command);\n addConnectOptions(command);\n addAuthenticationOptions(command);\n }\n return program;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgC;AAChC,kBAAoB;AAEb,MAAM,mBAAmB,CAAC,OAAY,CAAC,OAAO;AAAA,EACnD,QACE,KAAK,eAAe,KAAK,kBACrB;AAAA,IACE,KAAK,KAAK,kBACN,iBAAI,KAAK,aAAa,SAAS,EAAE,MAChC;AAAA,IACL,SAAS,KAAK,mBAAoB;AAAA,EACpC,IACA;AAAA,EACN,QAAQ,KAAK;AAAA,EACb,OACE,KAAK,MACL,KAAK,YACL,KAAK,UACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,aACL,KAAK,eACL,KAAK,aACD;AAAA,IACE,YAAY,KAAK;AAAA,IACjB,gBAAgB,KAAK;AAAA,IACrB,aAAa,KAAK,aAAa,CAAC,KAAK,UAAU,IAAI;AAAA,IACnD,QAAQ,KAAK;AAAA,IACb,YAAY,KAAK,MAAM,KAAK;AAAA,IAC5B,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,YAAY,KAAK;AAAA,EACnB,IACA;AAAA,EACN,OAAO,KAAK;AAAA,EACZ,gBAAgB,CAAC,KAAK;AACxB;AAGA,MAAM,SAAS,IAAI;AAAA,EACjB;AAAA,EACA;AACF;AAEA,MAAM,SAAS,IAAI;AAAA,EACjB;AAAA,EACA;AACF,EAAE,QAAQ,CAAC,OAAO,QAAQ,OAAO,OAAO,CAAC;AAGzC,MAAM,QAAQ,IAAI;AAAA,EAChB;AAAA,EACA;AACF;AAEO,MAAM,UAAU,IAAI;AAAA,EACzB;AAAA,EACA;AACF;AAGA,MAAM,OAAO,IAAI;AAAA,EACf;AAAA,EACA;AACF;AACA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BAAgB,OAAO;AAAA,EACzB;AACA,SAAO;AACT;AACO,MAAM,mBAAmB,CAAC,YAAqB;AACpD,aAAW,WAAW,QAAQ,UAAU;AACtC,8BAA0B,OAAO;AACjC,sBAAkB,OAAO;AACzB,6BAAyB,OAAO;AAAA,EAClC;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/commands/import.js
CHANGED
|
@@ -26,11 +26,29 @@ var import_commander = require("commander");
|
|
|
26
26
|
var import_ContensisCliService = require("../services/ContensisCliService");
|
|
27
27
|
var import_globalOptions = require("./globalOptions");
|
|
28
28
|
const makeImportCommand = () => {
|
|
29
|
-
const program = new import_commander.Command().command("import").
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const program = new import_commander.Command().command("import").description("import command").addHelpText("after", `
|
|
30
|
+
`).showHelpAfterError(true).exitOverride();
|
|
31
|
+
program.command("models").description("import complete content models").argument("[modelIds...]", "ids of the content models to import (optional)").addOption(import_globalOptions.commit).addHelpText(
|
|
32
|
+
"after",
|
|
33
|
+
`
|
|
34
|
+
Example call:
|
|
35
|
+
> import models blogPost --from-file contentmodels-backup.json
|
|
36
|
+
> import models --source-alias example-dev
|
|
37
|
+
`
|
|
38
|
+
).action(async (modelIds, opts) => {
|
|
39
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
40
|
+
["import", "models", modelIds.join(" ")],
|
|
41
|
+
opts,
|
|
42
|
+
(0, import_globalOptions.mapContensisOpts)({ modelIds, ...opts })
|
|
43
|
+
).ImportContentModels({
|
|
44
|
+
fromFile: opts.fromFile,
|
|
45
|
+
commit: opts.commit
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
program.command("contenttypes").description("import content types").argument(
|
|
49
|
+
"[contentTypeIds...]",
|
|
32
50
|
"Optional list of API id(s) of the content type(s) to import"
|
|
33
|
-
).addHelpText(
|
|
51
|
+
).addOption(import_globalOptions.commit).addHelpText(
|
|
34
52
|
"after",
|
|
35
53
|
`
|
|
36
54
|
Example call:
|
|
@@ -38,7 +56,11 @@ Example call:
|
|
|
38
56
|
> import contenttypes {contentTypeIds} --source-alias example-dev
|
|
39
57
|
`
|
|
40
58
|
).action(async (contentTypeIds, opts) => {
|
|
41
|
-
await (0, import_ContensisCliService.cliCommand)(
|
|
59
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
60
|
+
["import", "contenttypes"],
|
|
61
|
+
opts,
|
|
62
|
+
(0, import_globalOptions.mapContensisOpts)({ contentTypeIds, ...opts })
|
|
63
|
+
).ImportContentTypes(
|
|
42
64
|
{
|
|
43
65
|
fromFile: opts.fromFile,
|
|
44
66
|
commit: opts.commit
|
|
@@ -46,10 +68,10 @@ Example call:
|
|
|
46
68
|
contentTypeIds
|
|
47
69
|
);
|
|
48
70
|
});
|
|
49
|
-
program.command("components").argument(
|
|
50
|
-
"[componentIds]",
|
|
71
|
+
program.command("components").description("import components").argument(
|
|
72
|
+
"[componentIds...]",
|
|
51
73
|
"Optional list of API id(s) of the component(s) to import"
|
|
52
|
-
).addHelpText(
|
|
74
|
+
).addOption(import_globalOptions.commit).addHelpText(
|
|
53
75
|
"after",
|
|
54
76
|
`
|
|
55
77
|
Example call:
|
|
@@ -57,7 +79,11 @@ Example call:
|
|
|
57
79
|
> import components {componentIds} --source-alias example-dev
|
|
58
80
|
`
|
|
59
81
|
).action(async (componentIds, opts) => {
|
|
60
|
-
await (0, import_ContensisCliService.cliCommand)(
|
|
82
|
+
await (0, import_ContensisCliService.cliCommand)(
|
|
83
|
+
["import", "component"],
|
|
84
|
+
opts,
|
|
85
|
+
(0, import_globalOptions.mapContensisOpts)({ componentIds, ...opts })
|
|
86
|
+
).ImportComponents(
|
|
61
87
|
{
|
|
62
88
|
fromFile: opts.fromFile,
|
|
63
89
|
commit: opts.commit
|
|
@@ -65,12 +91,17 @@ Example call:
|
|
|
65
91
|
componentIds
|
|
66
92
|
);
|
|
67
93
|
});
|
|
68
|
-
program.command("entries").argument(
|
|
94
|
+
program.command("entries").description("import entries").argument(
|
|
69
95
|
"[search phrase]",
|
|
70
96
|
"get entries with the search phrase, use quotes for multiple words"
|
|
71
97
|
).addOption(import_globalOptions.commit).option(
|
|
72
|
-
"-preserve
|
|
98
|
+
"-preserve --preserve-guids",
|
|
73
99
|
"include this flag when you are importing entries that you have previously exported and wish to update"
|
|
100
|
+
).addOption(
|
|
101
|
+
new import_commander.Option(
|
|
102
|
+
"-oe --output-entries <outputEntries>",
|
|
103
|
+
"which details of the entries included in the import to output"
|
|
104
|
+
).choices(["errors", "changes", "all"]).default("errors")
|
|
74
105
|
).addHelpText(
|
|
75
106
|
"after",
|
|
76
107
|
`
|
|
@@ -82,7 +113,11 @@ Example call:
|
|
|
82
113
|
["import", "entries"],
|
|
83
114
|
opts,
|
|
84
115
|
(0, import_globalOptions.mapContensisOpts)({ phrase, ...opts })
|
|
85
|
-
).ImportEntries({
|
|
116
|
+
).ImportEntries({
|
|
117
|
+
commit: opts.commit,
|
|
118
|
+
fromFile: opts.fromFile,
|
|
119
|
+
logOutput: opts.outputEntries
|
|
120
|
+
});
|
|
86
121
|
});
|
|
87
122
|
return program;
|
|
88
123
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/import.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Command, Option } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport { commit, mapContensisOpts } from './globalOptions';\n\nexport const makeImportCommand = () => {\n const program = new Command()\n .command('import')\n .description('import command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n program\n .command('models')\n .description('import complete content models')\n .argument('[modelIds...]', 'ids of the content models to import (optional)')\n .addOption(commit)\n .addHelpText(\n 'after',\n `\nExample call:\n > import models blogPost --from-file contentmodels-backup.json\n > import models --source-alias example-dev\n`\n )\n .action(async (modelIds: string[], opts) => {\n await cliCommand(\n ['import', 'models', modelIds.join(' ')],\n opts,\n mapContensisOpts({ modelIds, ...opts })\n ).ImportContentModels({\n fromFile: opts.fromFile,\n commit: opts.commit,\n });\n });\n\n program\n .command('contenttypes')\n .description('import content types')\n .argument(\n '[contentTypeIds...]',\n 'Optional list of API id(s) of the content type(s) to import'\n )\n .addOption(commit)\n .addHelpText(\n 'after',\n `\nExample call:\n > import contenttypes {contentTypeIds} --from-file contenttypes-backup.json\n > import contenttypes {contentTypeIds} --source-alias example-dev\n`\n )\n .action(async (contentTypeIds: string[], opts) => {\n await cliCommand(\n ['import', 'contenttypes'],\n opts,\n mapContensisOpts({ contentTypeIds, ...opts })\n ).ImportContentTypes(\n {\n fromFile: opts.fromFile,\n commit: opts.commit,\n },\n contentTypeIds\n );\n });\n\n program\n .command('components')\n .description('import components')\n .argument(\n '[componentIds...]',\n 'Optional list of API id(s) of the component(s) to import'\n )\n .addOption(commit)\n .addHelpText(\n 'after',\n `\nExample call:\n > import components {componentIds} --from-file component-backup.json\n > import components {componentIds} --source-alias example-dev\n`\n )\n .action(async (componentIds: string[], opts) => {\n await cliCommand(\n ['import', 'component'],\n opts,\n mapContensisOpts({ componentIds, ...opts })\n ).ImportComponents(\n {\n fromFile: opts.fromFile,\n commit: opts.commit,\n },\n componentIds\n );\n });\n\n program\n .command('entries')\n .description('import entries')\n .argument(\n '[search phrase]',\n 'get entries with the search phrase, use quotes for multiple words'\n )\n .addOption(commit)\n .option(\n '-preserve --preserve-guids',\n 'include this flag when you are importing entries that you have previously exported and wish to update'\n )\n .addOption(\n new Option(\n '-oe --output-entries <outputEntries>',\n 'which details of the entries included in the import to output'\n )\n .choices(['errors', 'changes', 'all'])\n .default('errors')\n )\n .addHelpText(\n 'after',\n `\nExample call:\n > import entries --source-cms example-dev --source-project-id microsite --zenql \"sys.contentTypeId = blog\"\n`\n )\n .action(async (phrase: string, opts, cmd) => {\n await cliCommand(\n ['import', 'entries'],\n opts,\n mapContensisOpts({ phrase, ...opts })\n ).ImportEntries({\n commit: opts.commit,\n fromFile: opts.fromFile,\n logOutput: opts.outputEntries,\n });\n });\n\n return program;\n};\n\nexport const get = makeImportCommand();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgC;AAChC,iCAA2B;AAC3B,2BAAyC;AAElC,MAAM,oBAAoB,MAAM;AACrC,QAAM,UAAU,IAAI,yBAAQ,EACzB,QAAQ,QAAQ,EAChB,YAAY,gBAAgB,EAC5B,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,aAAa;AAEhB,UACG,QAAQ,QAAQ,EAChB,YAAY,gCAAgC,EAC5C,SAAS,iBAAiB,gDAAgD,EAC1E,UAAU,2BAAM,EAChB;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKF,EACC,OAAO,OAAO,UAAoB,SAAS;AAC1C,cAAM;AAAA,MACJ,CAAC,UAAU,UAAU,SAAS,KAAK,GAAG,CAAC;AAAA,MACvC;AAAA,UACA,uCAAiB,EAAE,UAAU,GAAG,KAAK,CAAC;AAAA,IACxC,EAAE,oBAAoB;AAAA,MACpB,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,IACf,CAAC;AAAA,EACH,CAAC;AAEH,UACG,QAAQ,cAAc,EACtB,YAAY,sBAAsB,EAClC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,UAAU,2BAAM,EAChB;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKF,EACC,OAAO,OAAO,gBAA0B,SAAS;AAChD,cAAM;AAAA,MACJ,CAAC,UAAU,cAAc;AAAA,MACzB;AAAA,UACA,uCAAiB,EAAE,gBAAgB,GAAG,KAAK,CAAC;AAAA,IAC9C,EAAE;AAAA,MACA;AAAA,QACE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