contensis-cli 1.0.0-beta.53 → 1.0.0-beta.55

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 (68) hide show
  1. package/.vscode/launch.json +15 -15
  2. package/README.md +1226 -1226
  3. package/dist/commands/connect.js.map +1 -1
  4. package/dist/commands/create.js.map +1 -1
  5. package/dist/commands/diff.js.map +1 -1
  6. package/dist/commands/get.js.map +1 -1
  7. package/dist/commands/globalOptions.js.map +1 -1
  8. package/dist/commands/import.js.map +1 -1
  9. package/dist/commands/index.js.map +1 -1
  10. package/dist/commands/list.js.map +1 -1
  11. package/dist/commands/login.js.map +1 -1
  12. package/dist/commands/push.js.map +1 -1
  13. package/dist/commands/release.js.map +1 -1
  14. package/dist/commands/remove.js.map +1 -1
  15. package/dist/commands/set.js.map +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/localisation/en-GB.js.map +1 -1
  18. package/dist/providers/CredentialProvider.js.map +1 -1
  19. package/dist/providers/SessionCacheProvider.js.map +1 -1
  20. package/dist/providers/file-provider.js.map +1 -1
  21. package/dist/services/ContensisAuthService.js.map +1 -1
  22. package/dist/services/ContensisCliService.js +4 -0
  23. package/dist/services/ContensisCliService.js.map +2 -2
  24. package/dist/shell.js.map +1 -1
  25. package/dist/util/console.printer.js +5 -5
  26. package/dist/util/console.printer.js.map +2 -2
  27. package/dist/util/csv.formatter.js.map +1 -1
  28. package/dist/util/index.js.map +1 -1
  29. package/dist/util/json.formatter.js.map +1 -1
  30. package/dist/util/logger.js.map +1 -1
  31. package/dist/util/xml.formatter.js.map +1 -1
  32. package/dist/version.js +1 -1
  33. package/dist/version.js.map +1 -1
  34. package/esbuild.config.js +49 -49
  35. package/headless-setup.sh +6 -6
  36. package/package.json +59 -59
  37. package/src/commands/connect.ts +24 -24
  38. package/src/commands/create.ts +70 -70
  39. package/src/commands/diff.ts +41 -41
  40. package/src/commands/get.ts +214 -214
  41. package/src/commands/globalOptions.ts +127 -127
  42. package/src/commands/import.ts +128 -128
  43. package/src/commands/index.ts +80 -80
  44. package/src/commands/list.ts +116 -116
  45. package/src/commands/login.ts +34 -34
  46. package/src/commands/push.ts +127 -127
  47. package/src/commands/release.ts +32 -32
  48. package/src/commands/remove.ts +85 -85
  49. package/src/commands/set.ts +96 -96
  50. package/src/index.ts +19 -19
  51. package/src/localisation/en-GB.ts +289 -289
  52. package/src/models/AppError.d.ts +40 -40
  53. package/src/models/Cache.d.ts +25 -25
  54. package/src/models/JsModules.d.ts +1 -1
  55. package/src/providers/CredentialProvider.ts +121 -121
  56. package/src/providers/SessionCacheProvider.ts +101 -101
  57. package/src/providers/file-provider.ts +76 -76
  58. package/src/services/ContensisAuthService.ts +70 -70
  59. package/src/services/ContensisCliService.ts +1749 -1745
  60. package/src/shell.ts +270 -270
  61. package/src/util/console.printer.ts +371 -371
  62. package/src/util/csv.formatter.ts +21 -21
  63. package/src/util/index.ts +73 -73
  64. package/src/util/json.formatter.ts +1 -1
  65. package/src/util/logger.ts +234 -234
  66. package/src/util/xml.formatter.ts +20 -20
  67. package/src/version.ts +1 -1
  68. package/tsconfig.json +22 -22
@@ -1,116 +1,116 @@
1
- import { Command } from 'commander';
2
- import { cliCommand } from '~/services/ContensisCliService';
3
-
4
- export const makeListCommand = () => {
5
- const list = new Command()
6
- .command('list')
7
- .description('list command')
8
- .addHelpText('after', `\n`)
9
- .showHelpAfterError(true)
10
- .exitOverride();
11
-
12
- list
13
- .command('envs')
14
- .description('List all previously connected environments')
15
- .addHelpText(
16
- 'after',
17
- `
18
- Example call:
19
- > list envs
20
- `
21
- )
22
- .action(opts => {
23
- cliCommand(['list', 'envs'], opts).PrintEnvironments();
24
- });
25
-
26
- list
27
- .command('projects')
28
- .description('print list of projects')
29
- .action(async opts => {
30
- await cliCommand(['list', 'projects'], opts).PrintProjects();
31
- });
32
-
33
- list
34
- .command('models')
35
- .description('print list of content models')
36
- .addHelpText(
37
- 'after',
38
- `
39
- Example call:
40
- > list models
41
- `
42
- )
43
- .action(async opts => {
44
- await cliCommand(['list', 'models'], opts).PrintContentModels();
45
- });
46
-
47
- list
48
- .command('contenttypes')
49
- .description('print list of content types')
50
- .addHelpText(
51
- 'after',
52
- `
53
- Example call:
54
- > list contenttypes -o ./output.json -f json
55
- `
56
- )
57
- .action(async opts => {
58
- await cliCommand(['list', 'contenttypes'], opts).PrintContentTypes();
59
- });
60
-
61
- list
62
- .command('components')
63
- .description('print list of components')
64
- .addHelpText(
65
- 'after',
66
- `
67
- Example call:
68
- > list components -o ./output.json -f json
69
- `
70
- )
71
- .action(async opts => {
72
- await cliCommand(['list', 'components'], opts).PrintComponents();
73
- });
74
-
75
- list
76
- .command('blocks')
77
- .description('print list of content blocks')
78
- .addHelpText(
79
- 'after',
80
- `
81
- Example call:
82
- > list blocks
83
- `
84
- )
85
- .action(async opts => {
86
- await cliCommand(['list', 'blocks'], opts).PrintBlocks();
87
- });
88
-
89
- list
90
- .command('keys')
91
- .description('print list of API keys')
92
- .addHelpText(
93
- 'after',
94
- `
95
- Example call:
96
- > list keys
97
- `
98
- )
99
- .action(async opts => {
100
- await cliCommand(['list', 'keys'], opts).PrintApiKeys();
101
- });
102
-
103
- list
104
- .command('webhooks')
105
- .description('print list of webhooks')
106
- .argument('[name]', 'find webhooks matching the supplied name')
107
- .option('-i --id <id...>', 'the subscription id(s) to get')
108
- .addHelpText('after', `\n`)
109
- .action(async (name?: string, { id, ...opts }: any = {}) => {
110
- await cliCommand(['list', 'webhooks'], opts).PrintWebhookSubscriptions(
111
- id,
112
- name
113
- );
114
- });
115
- return list;
116
- };
1
+ import { Command } from 'commander';
2
+ import { cliCommand } from '~/services/ContensisCliService';
3
+
4
+ export const makeListCommand = () => {
5
+ const list = new Command()
6
+ .command('list')
7
+ .description('list command')
8
+ .addHelpText('after', `\n`)
9
+ .showHelpAfterError(true)
10
+ .exitOverride();
11
+
12
+ list
13
+ .command('envs')
14
+ .description('List all previously connected environments')
15
+ .addHelpText(
16
+ 'after',
17
+ `
18
+ Example call:
19
+ > list envs
20
+ `
21
+ )
22
+ .action(opts => {
23
+ cliCommand(['list', 'envs'], opts).PrintEnvironments();
24
+ });
25
+
26
+ list
27
+ .command('projects')
28
+ .description('print list of projects')
29
+ .action(async opts => {
30
+ await cliCommand(['list', 'projects'], opts).PrintProjects();
31
+ });
32
+
33
+ list
34
+ .command('models')
35
+ .description('print list of content models')
36
+ .addHelpText(
37
+ 'after',
38
+ `
39
+ Example call:
40
+ > list models
41
+ `
42
+ )
43
+ .action(async opts => {
44
+ await cliCommand(['list', 'models'], opts).PrintContentModels();
45
+ });
46
+
47
+ list
48
+ .command('contenttypes')
49
+ .description('print list of content types')
50
+ .addHelpText(
51
+ 'after',
52
+ `
53
+ Example call:
54
+ > list contenttypes -o ./output.json -f json
55
+ `
56
+ )
57
+ .action(async opts => {
58
+ await cliCommand(['list', 'contenttypes'], opts).PrintContentTypes();
59
+ });
60
+
61
+ list
62
+ .command('components')
63
+ .description('print list of components')
64
+ .addHelpText(
65
+ 'after',
66
+ `
67
+ Example call:
68
+ > list components -o ./output.json -f json
69
+ `
70
+ )
71
+ .action(async opts => {
72
+ await cliCommand(['list', 'components'], opts).PrintComponents();
73
+ });
74
+
75
+ list
76
+ .command('blocks')
77
+ .description('print list of content blocks')
78
+ .addHelpText(
79
+ 'after',
80
+ `
81
+ Example call:
82
+ > list blocks
83
+ `
84
+ )
85
+ .action(async opts => {
86
+ await cliCommand(['list', 'blocks'], opts).PrintBlocks();
87
+ });
88
+
89
+ list
90
+ .command('keys')
91
+ .description('print list of API keys')
92
+ .addHelpText(
93
+ 'after',
94
+ `
95
+ Example call:
96
+ > list keys
97
+ `
98
+ )
99
+ .action(async opts => {
100
+ await cliCommand(['list', 'keys'], opts).PrintApiKeys();
101
+ });
102
+
103
+ list
104
+ .command('webhooks')
105
+ .description('print list of webhooks')
106
+ .argument('[name]', 'find webhooks matching the supplied name')
107
+ .option('-i --id <id...>', 'the subscription id(s) to get')
108
+ .addHelpText('after', `\n`)
109
+ .action(async (name?: string, { id, ...opts }: any = {}) => {
110
+ await cliCommand(['list', 'webhooks'], opts).PrintWebhookSubscriptions(
111
+ id,
112
+ name
113
+ );
114
+ });
115
+ return list;
116
+ };
@@ -1,34 +1,34 @@
1
- import { Command } from 'commander';
2
- import { cliCommand } from '~/services/ContensisCliService';
3
- import { shell } from '~/shell';
4
-
5
- export const makeLoginCommand = () => {
6
- const login = new Command()
7
- .command('login')
8
- .description('login to a connected Contensis instance')
9
- .argument('<user/clientId>', 'the username to login with')
10
- .argument(
11
- '[password]',
12
- 'the password to use to login with (optional/insecure)'
13
- )
14
- .option(
15
- '-s, --shared-secret <sharedSecret>',
16
- 'the shared secret to use when logging in with a client id'
17
- )
18
- .usage('<user/clientId> [password] [-s <sharedSecret>]')
19
- .addHelpText(
20
- 'after',
21
- `
22
- Example call:
23
- > login myuserid\n -- or --\n > login {clientId} -s {sharedSecret}
24
- `
25
- )
26
- .action(async (user, password, opts) => {
27
- const token = await cliCommand(['login', user]).Login(user, {
28
- password,
29
- sharedSecret: opts.sharedSecret,
30
- });
31
- if (token) await shell().restart();
32
- });
33
- return login;
34
- };
1
+ import { Command } from 'commander';
2
+ import { cliCommand } from '~/services/ContensisCliService';
3
+ import { shell } from '~/shell';
4
+
5
+ export const makeLoginCommand = () => {
6
+ const login = new Command()
7
+ .command('login')
8
+ .description('login to a connected Contensis instance')
9
+ .argument('<user/clientId>', 'the username to login with')
10
+ .argument(
11
+ '[password]',
12
+ 'the password to use to login with (optional/insecure)'
13
+ )
14
+ .option(
15
+ '-s, --shared-secret <sharedSecret>',
16
+ 'the shared secret to use when logging in with a client id'
17
+ )
18
+ .usage('<user/clientId> [password] [-s <sharedSecret>]')
19
+ .addHelpText(
20
+ 'after',
21
+ `
22
+ Example call:
23
+ > login myuserid\n -- or --\n > login {clientId} -s {sharedSecret}
24
+ `
25
+ )
26
+ .action(async (user, password, opts) => {
27
+ const token = await cliCommand(['login', user]).Login(user, {
28
+ password,
29
+ sharedSecret: opts.sharedSecret,
30
+ });
31
+ if (token) await shell().restart();
32
+ });
33
+ return login;
34
+ };
@@ -1,127 +1,127 @@
1
- import { Command } from 'commander';
2
- import mapJson from 'jsonpath-mapper';
3
- import { PushBlockParams } from 'migratortron';
4
- import { cliCommand } from '~/services/ContensisCliService';
5
-
6
- export const makePushCommand = () => {
7
- const push = new Command()
8
- .command('push')
9
- .description('push command')
10
- .addHelpText('after', `\n`)
11
- .showHelpAfterError(true)
12
- .exitOverride();
13
-
14
- push
15
- .command('block')
16
- .description('push a block')
17
- .argument('<block-id>', 'the name of the block to push to')
18
- .argument(
19
- '<image uri:tag>',
20
- 'the uri and tag of the container image to push as a block (tag default: latest)'
21
- )
22
- .argument('[branch]', 'the branch we are pushing to')
23
- .option(
24
- '-r, --release',
25
- 'whether to release the pushed block version',
26
- false
27
- )
28
- .option(
29
- '-cid, --commit-id <commitId>',
30
- 'the id of the source git commit for the supplied image uri'
31
- )
32
- .option(
33
- '-cmsg, --commit-message <commitMessage>',
34
- 'the git commit message for the supplied commit id'
35
- )
36
- .option(
37
- '-cdt, --commit-datetime <commitDateTime>',
38
- 'the timestamp of the source git commit for the supplied image uri'
39
- )
40
- .option(
41
- '-author, --author-email <authorEmail>',
42
- 'the git email address of the author of the source git commit'
43
- )
44
- .option(
45
- '-committer, --committer-email <committerEmail>',
46
- 'the git email address of the commiter of the source git commit'
47
- )
48
- .option(
49
- '-repo, --repository-url <repositoryUrl>',
50
- 'the url of the source repository for the supplied image uri'
51
- )
52
- .option(
53
- '-pr, --provider <sourceProvider>',
54
- 'the url of the source repository for the supplied image uri'
55
- )
56
- .usage('<block-id> <image uri> [branch] [options]')
57
- .addHelpText(
58
- 'after',
59
- `
60
- Example call:
61
- > push block contensis-app ghcr.io/contensis/contensis-app/app:build-4359 master --release\n`
62
- )
63
- .action(async (blockId: string, imageUri: string, branch: string, opts) => {
64
- const cli = cliCommand(['push', 'block', blockId], opts);
65
- const mapSourceVars = {
66
- blockId,
67
- imageUri,
68
- branch,
69
- ...opts,
70
- ...process.env,
71
- };
72
-
73
- const blockRequest = mapJson(mapSourceVars, {
74
- autoRelease: { $path: 'release', $default: () => false },
75
- id: ['blockId'],
76
- image: () => {
77
- const lastIndexOfColon = imageUri.lastIndexOf(':');
78
- return {
79
- uri: imageUri.slice(0, lastIndexOfColon),
80
- tag: imageUri.slice(lastIndexOfColon + 1) || 'latest',
81
- };
82
- },
83
- projectId: () => cli.env.currentProject || '',
84
- source: {
85
- provider: {
86
- $path: ['provider'],
87
- $return: (provider: string, { GITHUB_ACTIONS, GITLAB_CI }) => {
88
- if (provider) return provider;
89
- if (GITHUB_ACTIONS) return 'Github';
90
- else if (GITLAB_CI) return 'GitlabSelfHosted';
91
- },
92
- },
93
- repositoryUrl: {
94
- $path: ['repositoryUrl', 'CI_PROJECT_URL', 'GITHUB_REPOSITORY'],
95
- $formatting: (url: string, { GITHUB_ACTIONS }) => {
96
- if (GITHUB_ACTIONS) url = `https://github.com/${url}`;
97
-
98
- if (url && !url.endsWith('.git')) return `${url}.git`;
99
- return url;
100
- },
101
- },
102
- branch: ['branch', 'CI_COMMIT_REF_NAME', 'GITHUB_REF_NAME'],
103
- commit: {
104
- id: ['commitId', 'CI_COMMIT_SHORT_SHA', 'GITHUB_SHA'],
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
- },
110
- dateTime: ['commitDatetime', 'CI_COMMIT_TIMESTAMP'], // ${{ github.event.head_commit.timestamp }}
111
- authorEmail: ['authorEmail', 'GITLAB_USER_EMAIL', 'GITHUB_ACTOR'], // ${{ github.event.head_commit.author.email }}
112
- committerEmail: [
113
- 'committerEmail',
114
- 'GITLAB_USER_EMAIL',
115
- 'GITHUB_TRIGGERING_ACTOR',
116
- ], // ${{ github.event.head_commit.committer.email }}
117
- },
118
- },
119
- }) as PushBlockParams;
120
-
121
- await cli.PushBlock(blockRequest);
122
-
123
- // console.log(process.env);
124
- });
125
-
126
- return push;
127
- };
1
+ import { Command } from 'commander';
2
+ import mapJson from 'jsonpath-mapper';
3
+ import { PushBlockParams } from 'migratortron';
4
+ import { cliCommand } from '~/services/ContensisCliService';
5
+
6
+ export const makePushCommand = () => {
7
+ const push = new Command()
8
+ .command('push')
9
+ .description('push command')
10
+ .addHelpText('after', `\n`)
11
+ .showHelpAfterError(true)
12
+ .exitOverride();
13
+
14
+ push
15
+ .command('block')
16
+ .description('push a block')
17
+ .argument('<block-id>', 'the name of the block to push to')
18
+ .argument(
19
+ '<image uri:tag>',
20
+ 'the uri and tag of the container image to push as a block (tag default: latest)'
21
+ )
22
+ .argument('[branch]', 'the branch we are pushing to')
23
+ .option(
24
+ '-r, --release',
25
+ 'whether to release the pushed block version',
26
+ false
27
+ )
28
+ .option(
29
+ '-cid, --commit-id <commitId>',
30
+ 'the id of the source git commit for the supplied image uri'
31
+ )
32
+ .option(
33
+ '-cmsg, --commit-message <commitMessage>',
34
+ 'the git commit message for the supplied commit id'
35
+ )
36
+ .option(
37
+ '-cdt, --commit-datetime <commitDateTime>',
38
+ 'the timestamp of the source git commit for the supplied image uri'
39
+ )
40
+ .option(
41
+ '-author, --author-email <authorEmail>',
42
+ 'the git email address of the author of the source git commit'
43
+ )
44
+ .option(
45
+ '-committer, --committer-email <committerEmail>',
46
+ 'the git email address of the commiter of the source git commit'
47
+ )
48
+ .option(
49
+ '-repo, --repository-url <repositoryUrl>',
50
+ 'the url of the source repository for the supplied image uri'
51
+ )
52
+ .option(
53
+ '-pr, --provider <sourceProvider>',
54
+ 'the url of the source repository for the supplied image uri'
55
+ )
56
+ .usage('<block-id> <image uri> [branch] [options]')
57
+ .addHelpText(
58
+ 'after',
59
+ `
60
+ Example call:
61
+ > push block contensis-app ghcr.io/contensis/contensis-app/app:build-4359 master --release\n`
62
+ )
63
+ .action(async (blockId: string, imageUri: string, branch: string, opts) => {
64
+ const cli = cliCommand(['push', 'block', blockId], opts);
65
+ const mapSourceVars = {
66
+ blockId,
67
+ imageUri,
68
+ branch,
69
+ ...opts,
70
+ ...process.env,
71
+ };
72
+
73
+ const blockRequest = mapJson(mapSourceVars, {
74
+ autoRelease: { $path: 'release', $default: () => false },
75
+ id: ['blockId'],
76
+ image: () => {
77
+ const lastIndexOfColon = imageUri.lastIndexOf(':');
78
+ return {
79
+ uri: imageUri.slice(0, lastIndexOfColon),
80
+ tag: imageUri.slice(lastIndexOfColon + 1) || 'latest',
81
+ };
82
+ },
83
+ projectId: () => cli.env.currentProject || '',
84
+ source: {
85
+ provider: {
86
+ $path: ['provider'],
87
+ $return: (provider: string, { GITHUB_ACTIONS, GITLAB_CI }) => {
88
+ if (provider) return provider;
89
+ if (GITHUB_ACTIONS) return 'Github';
90
+ else if (GITLAB_CI) return 'GitlabSelfHosted';
91
+ },
92
+ },
93
+ repositoryUrl: {
94
+ $path: ['repositoryUrl', 'CI_PROJECT_URL', 'GITHUB_REPOSITORY'],
95
+ $formatting: (url: string, { GITHUB_ACTIONS }) => {
96
+ if (GITHUB_ACTIONS) url = `https://github.com/${url}`;
97
+
98
+ if (url && !url.endsWith('.git')) return `${url}.git`;
99
+ return url;
100
+ },
101
+ },
102
+ branch: ['branch', 'CI_COMMIT_REF_NAME', 'GITHUB_REF_NAME'],
103
+ commit: {
104
+ id: ['commitId', 'CI_COMMIT_SHORT_SHA', 'GITHUB_SHA'],
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
+ },
110
+ dateTime: ['commitDatetime', 'CI_COMMIT_TIMESTAMP'], // ${{ github.event.head_commit.timestamp }}
111
+ authorEmail: ['authorEmail', 'GITLAB_USER_EMAIL', 'GITHUB_ACTOR'], // ${{ github.event.head_commit.author.email }}
112
+ committerEmail: [
113
+ 'committerEmail',
114
+ 'GITLAB_USER_EMAIL',
115
+ 'GITHUB_TRIGGERING_ACTOR',
116
+ ], // ${{ github.event.head_commit.committer.email }}
117
+ },
118
+ },
119
+ }) as PushBlockParams;
120
+
121
+ await cli.PushBlock(blockRequest);
122
+
123
+ // console.log(process.env);
124
+ });
125
+
126
+ return push;
127
+ };
@@ -1,32 +1,32 @@
1
- import { Command } from 'commander';
2
- import { cliCommand } from '~/services/ContensisCliService';
3
-
4
- export const makeReleaseCommand = () => {
5
- const release = new Command()
6
- .command('release')
7
- .description('release command')
8
- .addHelpText('after', `\n`)
9
- .showHelpAfterError(true)
10
- .exitOverride();
11
-
12
- release
13
- .command('block')
14
- .description('release a block version')
15
- .argument('<block-id>', 'the name of the block to release')
16
- .argument('<version>', 'the block version to release')
17
- .usage('<block-id> <version>')
18
- .addHelpText(
19
- 'after',
20
- `
21
- Example call:
22
- > release block contensis-app 3\n`
23
- )
24
- .action(async (blockId: string, version: string, opts) => {
25
- await cliCommand(['release', 'block', blockId], opts).ReleaseBlock(
26
- blockId,
27
- version
28
- );
29
- });
30
-
31
- return release;
32
- };
1
+ import { Command } from 'commander';
2
+ import { cliCommand } from '~/services/ContensisCliService';
3
+
4
+ export const makeReleaseCommand = () => {
5
+ const release = new Command()
6
+ .command('release')
7
+ .description('release command')
8
+ .addHelpText('after', `\n`)
9
+ .showHelpAfterError(true)
10
+ .exitOverride();
11
+
12
+ release
13
+ .command('block')
14
+ .description('release a block version')
15
+ .argument('<block-id>', 'the name of the block to release')
16
+ .argument('<version>', 'the block version to release')
17
+ .usage('<block-id> <version>')
18
+ .addHelpText(
19
+ 'after',
20
+ `
21
+ Example call:
22
+ > release block contensis-app 3\n`
23
+ )
24
+ .action(async (blockId: string, version: string, opts) => {
25
+ await cliCommand(['release', 'block', blockId], opts).ReleaseBlock(
26
+ blockId,
27
+ version
28
+ );
29
+ });
30
+
31
+ return release;
32
+ };