contensis-cli 1.0.0-beta.10 → 1.0.0-beta.100

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.
Files changed (125) hide show
  1. package/README.md +1146 -78
  2. package/cli.js +3 -0
  3. package/dist/commands/connect.js +3 -3
  4. package/dist/commands/connect.js.map +2 -2
  5. package/dist/commands/create.js +45 -10
  6. package/dist/commands/create.js.map +2 -2
  7. package/dist/commands/dev.js +71 -0
  8. package/dist/commands/dev.js.map +7 -0
  9. package/dist/commands/diff.js +57 -0
  10. package/dist/commands/diff.js.map +7 -0
  11. package/dist/commands/execute.js +103 -0
  12. package/dist/commands/execute.js.map +7 -0
  13. package/dist/commands/get.js +169 -32
  14. package/dist/commands/get.js.map +3 -3
  15. package/dist/commands/globalOptions.js +37 -12
  16. package/dist/commands/globalOptions.js.map +2 -2
  17. package/dist/commands/import.js +65 -12
  18. package/dist/commands/import.js.map +2 -2
  19. package/dist/commands/index.js +22 -2
  20. package/dist/commands/index.js.map +2 -2
  21. package/dist/commands/list.js +53 -10
  22. package/dist/commands/list.js.map +2 -2
  23. package/dist/commands/login.js +2 -2
  24. package/dist/commands/login.js.map +2 -2
  25. package/dist/commands/push.js +17 -13
  26. package/dist/commands/push.js.map +2 -2
  27. package/dist/commands/remove.js +51 -8
  28. package/dist/commands/remove.js.map +2 -2
  29. package/dist/commands/set.js +139 -12
  30. package/dist/commands/set.js.map +2 -2
  31. package/dist/index.js +1 -1
  32. package/dist/index.js.map +2 -2
  33. package/dist/localisation/en-GB.js +297 -49
  34. package/dist/localisation/en-GB.js.map +2 -2
  35. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +56 -0
  36. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +7 -0
  37. package/dist/mappers/DevInit-to-CIWorkflow.js +374 -0
  38. package/dist/mappers/DevInit-to-CIWorkflow.js.map +7 -0
  39. package/dist/mappers/DevInit-to-RolePermissions.js +56 -0
  40. package/dist/mappers/DevInit-to-RolePermissions.js.map +7 -0
  41. package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js +56 -0
  42. package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js.map +7 -0
  43. package/dist/models/CliService.d.js +17 -0
  44. package/dist/models/CliService.d.js.map +7 -0
  45. package/dist/models/DevService.d.js +17 -0
  46. package/dist/models/DevService.d.js.map +7 -0
  47. package/dist/providers/CredentialProvider.js +46 -14
  48. package/dist/providers/CredentialProvider.js.map +3 -3
  49. package/dist/providers/SessionCacheProvider.js +21 -1
  50. package/dist/providers/SessionCacheProvider.js.map +2 -2
  51. package/dist/providers/file-provider.js +12 -6
  52. package/dist/providers/file-provider.js.map +3 -3
  53. package/dist/services/ContensisCliService.js +1211 -420
  54. package/dist/services/ContensisCliService.js.map +3 -3
  55. package/dist/services/ContensisDevService.js +368 -0
  56. package/dist/services/ContensisDevService.js.map +7 -0
  57. package/dist/services/ContensisRoleService.js +114 -0
  58. package/dist/services/ContensisRoleService.js.map +7 -0
  59. package/dist/shell.js +58 -18
  60. package/dist/shell.js.map +3 -3
  61. package/dist/util/console.printer.js +171 -55
  62. package/dist/util/console.printer.js.map +2 -2
  63. package/dist/util/diff.js +116 -0
  64. package/dist/util/diff.js.map +7 -0
  65. package/dist/util/dotenv.js +57 -0
  66. package/dist/util/dotenv.js.map +7 -0
  67. package/dist/util/find.js +31 -0
  68. package/dist/util/find.js.map +7 -0
  69. package/dist/util/git.js +128 -0
  70. package/dist/util/git.js.map +7 -0
  71. package/dist/util/index.js +8 -2
  72. package/dist/util/index.js.map +3 -3
  73. package/dist/util/logger.js +90 -29
  74. package/dist/util/logger.js.map +3 -3
  75. package/dist/util/os.js +42 -0
  76. package/dist/util/os.js.map +7 -0
  77. package/dist/util/timers.js +49 -0
  78. package/dist/util/timers.js.map +7 -0
  79. package/dist/util/yaml.js +45 -0
  80. package/dist/util/yaml.js.map +7 -0
  81. package/dist/version.js +1 -1
  82. package/dist/version.js.map +1 -1
  83. package/esbuild.config.js +3 -1
  84. package/package.json +14 -3
  85. package/src/commands/connect.ts +3 -2
  86. package/src/commands/create.ts +61 -8
  87. package/src/commands/dev.ts +69 -0
  88. package/src/commands/diff.ts +41 -0
  89. package/src/commands/execute.ts +117 -0
  90. package/src/commands/get.ts +242 -28
  91. package/src/commands/globalOptions.ts +42 -12
  92. package/src/commands/import.ts +83 -8
  93. package/src/commands/index.ts +22 -1
  94. package/src/commands/list.ts +85 -11
  95. package/src/commands/login.ts +2 -1
  96. package/src/commands/push.ts +18 -11
  97. package/src/commands/remove.ts +66 -4
  98. package/src/commands/set.ts +189 -9
  99. package/src/index.ts +1 -4
  100. package/src/localisation/en-GB.ts +428 -66
  101. package/src/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.ts +44 -0
  102. package/src/mappers/DevInit-to-CIWorkflow.ts +526 -0
  103. package/src/mappers/DevInit-to-RolePermissions.ts +32 -0
  104. package/src/mappers/DevRequests-to-RequestHanderSiteConfigYaml.ts +44 -0
  105. package/src/models/CliService.d.ts +36 -0
  106. package/src/models/DevService.d.ts +40 -0
  107. package/src/models/JsModules.d.ts +2 -0
  108. package/src/providers/CredentialProvider.ts +51 -18
  109. package/src/providers/SessionCacheProvider.ts +29 -2
  110. package/src/providers/file-provider.ts +17 -6
  111. package/src/services/ContensisCliService.ts +1532 -508
  112. package/src/services/ContensisDevService.ts +434 -0
  113. package/src/services/ContensisRoleService.ts +108 -0
  114. package/src/shell.ts +68 -18
  115. package/src/util/console.printer.ts +240 -78
  116. package/src/util/diff.ts +124 -0
  117. package/src/util/dotenv.ts +37 -0
  118. package/src/util/find.ts +8 -0
  119. package/src/util/git.ts +131 -0
  120. package/src/util/index.ts +16 -7
  121. package/src/util/logger.ts +145 -31
  122. package/src/util/os.ts +12 -0
  123. package/src/util/timers.ts +24 -0
  124. package/src/util/yaml.ts +13 -0
  125. package/src/version.ts +1 -1
@@ -1,20 +1,47 @@
1
- import { Argument, Command } from 'commander';
1
+ import { Command, Option } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
- import { url } from '~/util';
4
3
  import { commit, mapContensisOpts } from './globalOptions';
5
4
 
6
5
  export const makeImportCommand = () => {
7
6
  const program = new Command()
8
7
  .command('import')
8
+ .description('import command')
9
+ .addHelpText('after', `\n`)
9
10
  .showHelpAfterError(true)
10
11
  .exitOverride();
11
12
 
13
+ program
14
+ .command('models')
15
+ .description('import complete content models')
16
+ .argument('[modelIds...]', 'ids of the content models to import (optional)')
17
+ .addOption(commit)
18
+ .addHelpText(
19
+ 'after',
20
+ `
21
+ Example call:
22
+ > import models blogPost --from-file contentmodels-backup.json
23
+ > import models --source-alias example-dev
24
+ `
25
+ )
26
+ .action(async (modelIds: string[], opts) => {
27
+ await cliCommand(
28
+ ['import', 'models', modelIds.join(' ')],
29
+ opts,
30
+ mapContensisOpts({ modelIds, ...opts })
31
+ ).ImportContentModels({
32
+ fromFile: opts.fromFile,
33
+ commit: opts.commit,
34
+ });
35
+ });
36
+
12
37
  program
13
38
  .command('contenttypes')
39
+ .description('import content types')
14
40
  .argument(
15
- '[contentTypeIds]',
41
+ '[contentTypeIds...]',
16
42
  'Optional list of API id(s) of the content type(s) to import'
17
43
  )
44
+ .addOption(commit)
18
45
  .addHelpText(
19
46
  'after',
20
47
  `
@@ -24,7 +51,11 @@ Example call:
24
51
  `
25
52
  )
26
53
  .action(async (contentTypeIds: string[], opts) => {
27
- await cliCommand(['import', 'contenttypes'], opts).ImportContentTypes(
54
+ await cliCommand(
55
+ ['import', 'contenttypes'],
56
+ opts,
57
+ mapContensisOpts({ contentTypeIds, ...opts })
58
+ ).ImportContentTypes(
28
59
  {
29
60
  fromFile: opts.fromFile,
30
61
  commit: opts.commit,
@@ -35,10 +66,12 @@ Example call:
35
66
 
36
67
  program
37
68
  .command('components')
69
+ .description('import components')
38
70
  .argument(
39
- '[componentIds]',
71
+ '[componentIds...]',
40
72
  'Optional list of API id(s) of the component(s) to import'
41
73
  )
74
+ .addOption(commit)
42
75
  .addHelpText(
43
76
  'after',
44
77
  `
@@ -48,7 +81,11 @@ Example call:
48
81
  `
49
82
  )
50
83
  .action(async (componentIds: string[], opts) => {
51
- await cliCommand(['import', 'component'], opts).ImportComponents(
84
+ await cliCommand(
85
+ ['import', 'component'],
86
+ opts,
87
+ mapContensisOpts({ componentIds, ...opts })
88
+ ).ImportComponents(
52
89
  {
53
90
  fromFile: opts.fromFile,
54
91
  commit: opts.commit,
@@ -59,15 +96,24 @@ Example call:
59
96
 
60
97
  program
61
98
  .command('entries')
99
+ .description('import entries')
62
100
  .argument(
63
101
  '[search phrase]',
64
102
  'get entries with the search phrase, use quotes for multiple words'
65
103
  )
66
104
  .addOption(commit)
67
105
  .option(
68
- '-preserve, --preserve-guids',
106
+ '-preserve --preserve-guids',
69
107
  'include this flag when you are importing entries that you have previously exported and wish to update'
70
108
  )
109
+ .addOption(
110
+ new Option(
111
+ '-oe --output-entries <outputEntries>',
112
+ 'which details of the entries included in the import to output'
113
+ )
114
+ .choices(['errors', 'changes', 'all'])
115
+ .default('errors')
116
+ )
71
117
  .addHelpText(
72
118
  'after',
73
119
  `
@@ -80,7 +126,36 @@ Example call:
80
126
  ['import', 'entries'],
81
127
  opts,
82
128
  mapContensisOpts({ phrase, ...opts })
83
- ).ImportEntries({ commit: opts.commit, fromFile: opts.fromFile });
129
+ ).ImportEntries({
130
+ commit: opts.commit,
131
+ fromFile: opts.fromFile,
132
+ logOutput: opts.outputEntries,
133
+ });
134
+ });
135
+
136
+ // TODO: add options to import one an array of nodes? nodeIds: string[]
137
+ program
138
+ .command('nodes')
139
+ .description('import nodes')
140
+ .addOption(commit)
141
+ .addHelpText(
142
+ 'after',
143
+ `
144
+ Example call:
145
+ > import nodes --from-file component-backup.json
146
+ > import nodes --source-alias example-alias --source-project-id example-project
147
+ `
148
+ )
149
+ .action(async opts => {
150
+ await cliCommand(
151
+ ['import', 'nodes'],
152
+ opts,
153
+ mapContensisOpts({ ...opts })
154
+ ).ImportNodes({
155
+ commit: opts.commit,
156
+ fromFile: opts.fromFile,
157
+ logOutput: opts.outputNodes,
158
+ });
84
159
  });
85
160
 
86
161
  return program;
@@ -3,6 +3,9 @@ import { Logger } from '~/util/logger';
3
3
  import { LIB_VERSION } from '~/version';
4
4
  import { makeConnectCommand } from './connect';
5
5
  import { makeCreateCommand } from './create';
6
+ import { makeDevCommand } from './dev';
7
+ import { makeDiffCommand } from './diff';
8
+ import { makeExecuteCommand } from './execute';
6
9
  import { makeGetCommand } from './get';
7
10
  import {
8
11
  addAuthenticationOptions,
@@ -29,6 +32,13 @@ const commands = () => {
29
32
  : str.trim() && Logger.help(str);
30
33
  },
31
34
  })
35
+ .addHelpText(
36
+ 'after',
37
+ Logger.helpText`
38
+ >> Each command has its own help - for example:
39
+ > login --help\n > get --help
40
+ `
41
+ )
32
42
  .exitOverride()
33
43
  .showHelpAfterError(true);
34
44
 
@@ -37,9 +47,20 @@ const commands = () => {
37
47
  program
38
48
  )
39
49
  );
50
+ program.addCommand(
51
+ addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)
52
+ );
53
+ program.addCommand(
54
+ addConnectOptions(
55
+ addAuthenticationOptions(makeDevCommand())
56
+ ).copyInheritedSettings(program)
57
+ );
58
+ program.addCommand(
59
+ addGlobalOptions(makeExecuteCommand()).copyInheritedSettings(program)
60
+ );
40
61
  program.addCommand(
41
62
  addGlobalOptions(
42
- addImportOptions(makeCreateCommand())
63
+ addGetEntryOptions(addImportOptions(makeDiffCommand()))
43
64
  ).copyInheritedSettings(program)
44
65
  );
45
66
  program.addCommand(
@@ -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
- list.command('projects').action(async opts => {
29
- await cliCommand(['list', 'projects'], opts).PrintProjects();
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;
@@ -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().start();
31
+ if (token) await shell().restart();
31
32
  });
32
33
  return login;
33
34
  };
@@ -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, --release',
24
+ '-r --release',
22
25
  'whether to release the pushed block version',
23
26
  false
24
27
  )
25
28
  .option(
26
- '-cid, --commit-id <commitId>',
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, --commit-message <commitMessage>',
33
+ '-cmsg --commit-message <commitMessage>',
31
34
  'the git commit message for the supplied commit id'
32
35
  )
33
36
  .option(
34
- '-cdt, --commit-datetime <commitDateTime>',
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, --author-email <authorEmail>',
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, --committer-email <committerEmail>',
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, --repository-url <repositoryUrl>',
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, --provider <sourceProvider>',
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
- autoRelease: { $path: 'release', $default: () => false },
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: ['commitMessage', 'CI_COMMIT_MESSAGE'], // ${{ github.event.head_commit.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: [
@@ -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 { commit, mapContensisOpts } from './globalOptions';
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().start();
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
  };