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/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,6 +5,7 @@ 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]',
|
|
@@ -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
|
};
|
package/src/commands/push.ts
CHANGED
|
@@ -6,11 +6,14 @@ import { cliCommand } from '~/services/ContensisCliService';
|
|
|
6
6
|
export const makePushCommand = () => {
|
|
7
7
|
const push = new Command()
|
|
8
8
|
.command('push')
|
|
9
|
+
.description('push command')
|
|
10
|
+
.addHelpText('after', `\n`)
|
|
9
11
|
.showHelpAfterError(true)
|
|
10
12
|
.exitOverride();
|
|
11
13
|
|
|
12
14
|
push
|
|
13
15
|
.command('block')
|
|
16
|
+
.description('push a block')
|
|
14
17
|
.argument('<block-id>', 'the name of the block to push to')
|
|
15
18
|
.argument(
|
|
16
19
|
'<image uri:tag>',
|
|
@@ -18,36 +21,36 @@ export const makePushCommand = () => {
|
|
|
18
21
|
)
|
|
19
22
|
.argument('[branch]', 'the branch we are pushing to')
|
|
20
23
|
.option(
|
|
21
|
-
'-r
|
|
24
|
+
'-r --release',
|
|
22
25
|
'whether to release the pushed block version',
|
|
23
26
|
false
|
|
24
27
|
)
|
|
25
28
|
.option(
|
|
26
|
-
'-cid
|
|
29
|
+
'-cid --commit-id <commitId>',
|
|
27
30
|
'the id of the source git commit for the supplied image uri'
|
|
28
31
|
)
|
|
29
32
|
.option(
|
|
30
|
-
'-cmsg
|
|
33
|
+
'-cmsg --commit-message <commitMessage>',
|
|
31
34
|
'the git commit message for the supplied commit id'
|
|
32
35
|
)
|
|
33
36
|
.option(
|
|
34
|
-
'-cdt
|
|
37
|
+
'-cdt --commit-datetime <commitDateTime>',
|
|
35
38
|
'the timestamp of the source git commit for the supplied image uri'
|
|
36
39
|
)
|
|
37
40
|
.option(
|
|
38
|
-
'-author
|
|
41
|
+
'-author --author-email <authorEmail>',
|
|
39
42
|
'the git email address of the author of the source git commit'
|
|
40
43
|
)
|
|
41
44
|
.option(
|
|
42
|
-
'-committer
|
|
45
|
+
'-committer --committer-email <committerEmail>',
|
|
43
46
|
'the git email address of the commiter of the source git commit'
|
|
44
47
|
)
|
|
45
48
|
.option(
|
|
46
|
-
'-repo
|
|
49
|
+
'-repo --repository-url <repositoryUrl>',
|
|
47
50
|
'the url of the source repository for the supplied image uri'
|
|
48
51
|
)
|
|
49
52
|
.option(
|
|
50
|
-
'-pr
|
|
53
|
+
'-pr --provider <sourceProvider>',
|
|
51
54
|
'the url of the source repository for the supplied image uri'
|
|
52
55
|
)
|
|
53
56
|
.usage('<block-id> <image uri> [branch] [options]')
|
|
@@ -55,7 +58,7 @@ export const makePushCommand = () => {
|
|
|
55
58
|
'after',
|
|
56
59
|
`
|
|
57
60
|
Example call:
|
|
58
|
-
> push block contensis-app ghcr.io/contensis/contensis-app/build-4359 master --release\n`
|
|
61
|
+
> push block contensis-app ghcr.io/contensis/contensis-app/app:build-4359 master --release\n`
|
|
59
62
|
)
|
|
60
63
|
.action(async (blockId: string, imageUri: string, branch: string, opts) => {
|
|
61
64
|
const cli = cliCommand(['push', 'block', blockId], opts);
|
|
@@ -68,7 +71,7 @@ Example call:
|
|
|
68
71
|
};
|
|
69
72
|
|
|
70
73
|
const blockRequest = mapJson(mapSourceVars, {
|
|
71
|
-
|
|
74
|
+
release: { $path: 'release', $default: () => false },
|
|
72
75
|
id: ['blockId'],
|
|
73
76
|
image: () => {
|
|
74
77
|
const lastIndexOfColon = imageUri.lastIndexOf(':');
|
|
@@ -99,7 +102,11 @@ Example call:
|
|
|
99
102
|
branch: ['branch', 'CI_COMMIT_REF_NAME', 'GITHUB_REF_NAME'],
|
|
100
103
|
commit: {
|
|
101
104
|
id: ['commitId', 'CI_COMMIT_SHORT_SHA', 'GITHUB_SHA'],
|
|
102
|
-
message:
|
|
105
|
+
message: {
|
|
106
|
+
$path: ['commitMessage', 'CI_COMMIT_MESSAGE'], // ${{ github.event.head_commit.message }}
|
|
107
|
+
$formatting: (msg?: string) =>
|
|
108
|
+
msg?.replace(/\\n/g, ' ').replace(/\\n/g, ' ').trim(),
|
|
109
|
+
},
|
|
103
110
|
dateTime: ['commitDatetime', 'CI_COMMIT_TIMESTAMP'], // ${{ github.event.head_commit.timestamp }}
|
|
104
111
|
authorEmail: ['authorEmail', 'GITLAB_USER_EMAIL', 'GITHUB_ACTOR'], // ${{ github.event.head_commit.author.email }}
|
|
105
112
|
committerEmail: [
|
package/src/commands/remove.ts
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
3
|
import { shell } from '~/shell';
|
|
4
|
-
import {
|
|
4
|
+
import { Logger } from '~/util/logger';
|
|
5
|
+
import { commit, mapContensisOpts, zenql } from './globalOptions';
|
|
5
6
|
|
|
6
7
|
export const makeRemoveCommand = () => {
|
|
7
8
|
const remove = new Command()
|
|
8
9
|
.command('remove')
|
|
10
|
+
.description('remove command')
|
|
11
|
+
.addHelpText('after', `\n`)
|
|
9
12
|
.showHelpAfterError(true)
|
|
10
13
|
.exitOverride();
|
|
11
14
|
|
|
12
15
|
remove
|
|
13
16
|
.command('project')
|
|
17
|
+
.description('remove an entire project')
|
|
14
18
|
.argument('<projectId>', 'the project id to delete')
|
|
15
19
|
.usage('<projectId>')
|
|
20
|
+
.addHelpText('after', `\n`)
|
|
16
21
|
.action(async (projectId, opts) => {
|
|
17
22
|
const project = await cliCommand(
|
|
18
23
|
['remove', 'project', projectId],
|
|
19
24
|
opts
|
|
20
25
|
).SetProject(projectId);
|
|
21
|
-
if (project) await shell().
|
|
26
|
+
if (project) await shell().restart();
|
|
22
27
|
});
|
|
28
|
+
|
|
23
29
|
remove
|
|
24
30
|
.command('key')
|
|
31
|
+
.description('remove api key')
|
|
25
32
|
.argument('<id>', 'the id of the API key to delete')
|
|
26
33
|
.usage('<id>')
|
|
27
34
|
.addHelpText(
|
|
@@ -35,8 +42,25 @@ Example call:
|
|
|
35
42
|
await cliCommand(['remove', 'key', id], opts).RemoveApiKey(id);
|
|
36
43
|
});
|
|
37
44
|
|
|
45
|
+
remove
|
|
46
|
+
.command('role')
|
|
47
|
+
.description('remove a role')
|
|
48
|
+
.argument('<"Role name" or id>', 'the existing role name or id to delete')
|
|
49
|
+
.addHelpText(
|
|
50
|
+
'after',
|
|
51
|
+
`
|
|
52
|
+
Example call:
|
|
53
|
+
> remove role "My role"\n`
|
|
54
|
+
)
|
|
55
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
56
|
+
await cliCommand(['remove', 'role', roleNameOrId], opts).RemoveRole(
|
|
57
|
+
roleNameOrId
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
38
61
|
remove
|
|
39
62
|
.command('components')
|
|
63
|
+
.description('delete components')
|
|
40
64
|
.argument('<id...>', 'the id(s) of the components to delete')
|
|
41
65
|
.addOption(commit)
|
|
42
66
|
.usage('<id> [--commit]')
|
|
@@ -49,13 +73,14 @@ Example call:
|
|
|
49
73
|
)
|
|
50
74
|
.action(async (id: string[], opts) => {
|
|
51
75
|
await cliCommand(
|
|
52
|
-
['remove', 'components', id.join('
|
|
76
|
+
['remove', 'components', id.join(' ')],
|
|
53
77
|
opts
|
|
54
78
|
).RemoveComponents(id, opts.commit);
|
|
55
79
|
});
|
|
56
80
|
|
|
57
81
|
remove
|
|
58
82
|
.command('contenttypes')
|
|
83
|
+
.description('delete content types')
|
|
59
84
|
.argument('<id...>', 'the id(s) of the content types to delete')
|
|
60
85
|
.addOption(commit)
|
|
61
86
|
.usage('<id> [--commit]')
|
|
@@ -68,10 +93,47 @@ Example call:
|
|
|
68
93
|
)
|
|
69
94
|
.action(async (id: string[], opts) => {
|
|
70
95
|
await cliCommand(
|
|
71
|
-
['remove', 'contenttypes', id.join('
|
|
96
|
+
['remove', 'contenttypes', id.join(' ')],
|
|
72
97
|
opts
|
|
73
98
|
).RemoveContentTypes(id, opts.commit);
|
|
74
99
|
});
|
|
75
100
|
|
|
101
|
+
const removeEntries = remove
|
|
102
|
+
.command('entries')
|
|
103
|
+
.description('delete entries')
|
|
104
|
+
.argument(
|
|
105
|
+
'[ids...]',
|
|
106
|
+
'the entry id(s) to delete ...or add *** if you wish to delete all entries in all content types'
|
|
107
|
+
)
|
|
108
|
+
.addOption(zenql)
|
|
109
|
+
.addOption(commit)
|
|
110
|
+
.addHelpText(
|
|
111
|
+
'after',
|
|
112
|
+
`
|
|
113
|
+
Example call:
|
|
114
|
+
> remove entries a1c25591-8c9b-50e2-96d8-f6c774fcf023 8df914cc-1da1-59d6-86e0-8ea4ebd99aaa
|
|
115
|
+
> remove entries --zenql "sys.contentTypeId = test"
|
|
116
|
+
`
|
|
117
|
+
)
|
|
118
|
+
.action(async (entryIds: string[], opts) => {
|
|
119
|
+
const removeAll = entryIds?.[0] === '***';
|
|
120
|
+
|
|
121
|
+
// Remove all asterisks from args
|
|
122
|
+
if (entryIds?.[0] && !entryIds[0].replace(/\*/g, '')) entryIds.pop();
|
|
123
|
+
|
|
124
|
+
const hasArgs = !!(entryIds?.length || opts.zenql || removeAll);
|
|
125
|
+
if (!hasArgs) {
|
|
126
|
+
Logger.help(
|
|
127
|
+
`Not enough arguments supplied\n\n${removeEntries.helpInformation()}`
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
await cliCommand(
|
|
131
|
+
['remove', 'entries', entryIds.join(' ')],
|
|
132
|
+
opts,
|
|
133
|
+
mapContensisOpts({ entryIds, ...opts })
|
|
134
|
+
).RemoveEntries(opts.commit);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
76
138
|
return remove;
|
|
77
139
|
};
|
package/src/commands/set.ts
CHANGED
|
@@ -5,35 +5,215 @@ import { shell } from '~/shell';
|
|
|
5
5
|
export const makeSetCommand = () => {
|
|
6
6
|
const set = new Command()
|
|
7
7
|
.command('set')
|
|
8
|
+
.description('set command')
|
|
9
|
+
.addHelpText('after', `\n`)
|
|
8
10
|
.showHelpAfterError(true)
|
|
9
11
|
.exitOverride();
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
const project = set
|
|
11
14
|
.command('project')
|
|
15
|
+
.description('set current working project')
|
|
12
16
|
.argument('<projectId>', 'the project id to work with')
|
|
13
17
|
.usage('<projectId>')
|
|
18
|
+
.addHelpText(
|
|
19
|
+
'after',
|
|
20
|
+
`
|
|
21
|
+
Example call:
|
|
22
|
+
> set project website\n`
|
|
23
|
+
)
|
|
14
24
|
.action(async projectId => {
|
|
15
|
-
const
|
|
25
|
+
const nextProjectId = cliCommand([
|
|
16
26
|
'set',
|
|
17
27
|
'project',
|
|
18
28
|
projectId,
|
|
19
29
|
]).SetProject(projectId);
|
|
20
|
-
if (
|
|
30
|
+
if (nextProjectId) await shell().restart();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
project
|
|
34
|
+
.command('name')
|
|
35
|
+
.description('update project name')
|
|
36
|
+
.argument('<"Project name">', 'update the current project name')
|
|
37
|
+
.usage('<"Project name">')
|
|
38
|
+
.addHelpText(
|
|
39
|
+
'after',
|
|
40
|
+
`
|
|
41
|
+
Example call:
|
|
42
|
+
> set project name "Project name"\n`
|
|
43
|
+
)
|
|
44
|
+
.action(async (name: string, opts) => {
|
|
45
|
+
await cliCommand(['set', 'project', 'name'], opts).UpdateProject({
|
|
46
|
+
name,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
project
|
|
51
|
+
.command('description')
|
|
52
|
+
.description('update project description')
|
|
53
|
+
.argument(
|
|
54
|
+
'<"Project description">',
|
|
55
|
+
'update the current project description'
|
|
56
|
+
)
|
|
57
|
+
.usage('<"Project description">')
|
|
58
|
+
.addHelpText(
|
|
59
|
+
'after',
|
|
60
|
+
`
|
|
61
|
+
Example call:
|
|
62
|
+
> set project description "Description of project"\n`
|
|
63
|
+
)
|
|
64
|
+
.action(async (description: string, opts) => {
|
|
65
|
+
await cliCommand(['set', 'project', 'description'], opts).UpdateProject({
|
|
66
|
+
description,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const role = set.command('role').description('update a role');
|
|
71
|
+
|
|
72
|
+
role
|
|
73
|
+
.command('name')
|
|
74
|
+
.description('update role name')
|
|
75
|
+
.argument('<"Role name">', 'update the existing role name')
|
|
76
|
+
.argument('<"New name">', 'the new name for the role')
|
|
77
|
+
.usage('<"Role name"> <"New name">')
|
|
78
|
+
.addHelpText(
|
|
79
|
+
'after',
|
|
80
|
+
`
|
|
81
|
+
Example call:
|
|
82
|
+
> set role name "Existing name" "New role name"\n`
|
|
83
|
+
)
|
|
84
|
+
.action(async (roleNameOrId: string, newName: string, opts) => {
|
|
85
|
+
await cliCommand(['set', 'role', 'name'], opts).UpdateRole(roleNameOrId, {
|
|
86
|
+
name: newName,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
role
|
|
91
|
+
.command('description')
|
|
92
|
+
.description('update role description')
|
|
93
|
+
.argument('<"Role name" or id>', 'the existing role name or id to update')
|
|
94
|
+
.argument('<"New description">', 'the new description for the role')
|
|
95
|
+
.usage('<"Role name"> <"New description">')
|
|
96
|
+
.addHelpText(
|
|
97
|
+
'after',
|
|
98
|
+
`
|
|
99
|
+
Example call:
|
|
100
|
+
> set role description "Existing role" "New role description"\n`
|
|
101
|
+
)
|
|
102
|
+
.action(async (roleNameOrId: string, description: string, opts) => {
|
|
103
|
+
await cliCommand(['set', 'role', 'description'], opts).UpdateRole(
|
|
104
|
+
roleNameOrId,
|
|
105
|
+
{
|
|
106
|
+
description,
|
|
107
|
+
}
|
|
108
|
+
);
|
|
21
109
|
});
|
|
110
|
+
|
|
111
|
+
role
|
|
112
|
+
.command('enabled')
|
|
113
|
+
.description('enable or disable a role')
|
|
114
|
+
.argument('<"Role name" or id>', 'the existing role name or id to update')
|
|
115
|
+
.usage('<"Role name"> --disabled')
|
|
116
|
+
.option('--disabled', 'disable the role', false)
|
|
117
|
+
.addHelpText(
|
|
118
|
+
'after',
|
|
119
|
+
`
|
|
120
|
+
Example call:
|
|
121
|
+
> set role enabled "Existing role"\n
|
|
122
|
+
> set role enabled "Other role" --disabled\n`
|
|
123
|
+
)
|
|
124
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
125
|
+
await cliCommand(
|
|
126
|
+
['set', 'role', opts.disabled ? 'disabled' : 'enabled'],
|
|
127
|
+
opts
|
|
128
|
+
).UpdateRole(roleNameOrId, {
|
|
129
|
+
enabled: !opts.disabled,
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
role
|
|
134
|
+
.command('assignments')
|
|
135
|
+
.description('assign users, groups or keys to a role')
|
|
136
|
+
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
137
|
+
.option(
|
|
138
|
+
'-users --assign-users [assign-users...]',
|
|
139
|
+
'the user id(s) to assign'
|
|
140
|
+
)
|
|
141
|
+
.option(
|
|
142
|
+
'-groups --assign-groups [assign-groups...]',
|
|
143
|
+
'the groups name(s) to assign'
|
|
144
|
+
)
|
|
145
|
+
.option('-keys --assign-keys [assign-keys...]', 'the key name(s) to assign')
|
|
146
|
+
.addHelpText(
|
|
147
|
+
'after',
|
|
148
|
+
`
|
|
149
|
+
Example call:
|
|
150
|
+
> set role assignments "My role" --assign-users admin \n`
|
|
151
|
+
)
|
|
152
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
153
|
+
await cliCommand(['set', 'role', 'assignments'], opts).UpdateRole(
|
|
154
|
+
roleNameOrId,
|
|
155
|
+
{
|
|
156
|
+
assignments: {
|
|
157
|
+
apiKeys: opts.assignKeys || undefined,
|
|
158
|
+
groups: opts.assignGroups || undefined,
|
|
159
|
+
users: opts.assignUsers || undefined,
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
role
|
|
166
|
+
.command('permissions')
|
|
167
|
+
.description('add entry permissions to a role')
|
|
168
|
+
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
169
|
+
.option(
|
|
170
|
+
'-contenttypes --content-type-ids [content-type-id...]',
|
|
171
|
+
'any content type ids to add permissions for'
|
|
172
|
+
)
|
|
173
|
+
.option(
|
|
174
|
+
'--entry-actions [entry-actions...]',
|
|
175
|
+
'the entry actions to add to the role permissions'
|
|
176
|
+
)
|
|
177
|
+
.option(
|
|
178
|
+
'--entry-languages [entry-languages...]',
|
|
179
|
+
'the entry languages to add to the role permissions'
|
|
180
|
+
)
|
|
181
|
+
.addHelpText(
|
|
182
|
+
'after',
|
|
183
|
+
`
|
|
184
|
+
Example call:
|
|
185
|
+
> set role permissions "My role" --content-type-id blogs -- \n`
|
|
186
|
+
)
|
|
187
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
188
|
+
await cliCommand(['set', 'role', 'permissions'], opts).UpdateRole(
|
|
189
|
+
roleNameOrId,
|
|
190
|
+
{
|
|
191
|
+
permissions: {
|
|
192
|
+
entries: opts.contentTypeIds?.map((id: string) => ({
|
|
193
|
+
id,
|
|
194
|
+
actions: opts.entryActions || [],
|
|
195
|
+
languages: opts.entryLanguages || [],
|
|
196
|
+
})),
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
|
|
22
202
|
set
|
|
23
203
|
.command('version')
|
|
204
|
+
.description('set content version')
|
|
24
205
|
.addArgument(
|
|
25
206
|
new Argument('<versionStatus>', 'content version status')
|
|
26
207
|
.choices(['latest', 'published'])
|
|
27
208
|
.default('latest')
|
|
28
209
|
)
|
|
29
210
|
.usage('<latest/published>')
|
|
211
|
+
.addHelpText('after', `\n`)
|
|
30
212
|
.action(async versionStatus => {
|
|
31
|
-
const success =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
]).SetVersion(versionStatus);
|
|
36
|
-
if (success) await shell().start();
|
|
213
|
+
const success = cliCommand(['set', 'version', versionStatus]).SetVersion(
|
|
214
|
+
versionStatus
|
|
215
|
+
);
|
|
216
|
+
if (success) await shell().restart();
|
|
37
217
|
});
|
|
38
218
|
|
|
39
219
|
return set;
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import commands from './commands';
|
|
2
2
|
import { logError } from './util/logger';
|
|
3
3
|
import ContensisCli from './services/ContensisCliService';
|
|
4
|
-
import { jsonFormatter } from './util/json.formatter';
|
|
5
|
-
// new ContensisCli(process.argv).DoCommandTasksAsync();
|
|
6
4
|
|
|
7
5
|
// This is the CLI part of the app
|
|
8
6
|
const program = commands();
|
|
@@ -12,8 +10,7 @@ program
|
|
|
12
10
|
ContensisCli.quit();
|
|
13
11
|
})
|
|
14
12
|
.catch((err: any) => {
|
|
15
|
-
if (!err.name?.includes('CommanderError'))
|
|
13
|
+
if (err && !err.name?.includes('CommanderError'))
|
|
16
14
|
logError(err, `CLI ${err.toString()}`);
|
|
17
15
|
ContensisCli.quit(err);
|
|
18
16
|
});
|
|
19
|
-
//.exitOverride(() => console.log('exit override!!!'));
|