@rockcarver/frodo-cli 0.13.3 → 0.14.1

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 (124) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/package.json +14 -7
  3. package/src/app.js +0 -63
  4. package/src/cli/_template/cmd-delete.js +0 -56
  5. package/src/cli/_template/cmd-describe.js +0 -36
  6. package/src/cli/_template/cmd-export.js +0 -54
  7. package/src/cli/_template/cmd-import.js +0 -54
  8. package/src/cli/_template/cmd-list.js +0 -38
  9. package/src/cli/_template/cmd-sub1-delete.js +0 -56
  10. package/src/cli/_template/cmd-sub1-describe.js +0 -36
  11. package/src/cli/_template/cmd-sub1-export.js +0 -54
  12. package/src/cli/_template/cmd-sub1-import.js +0 -54
  13. package/src/cli/_template/cmd-sub1-list.js +0 -38
  14. package/src/cli/_template/cmd-sub1.js +0 -20
  15. package/src/cli/_template/cmd-sub2-delete.js +0 -56
  16. package/src/cli/_template/cmd-sub2-describe.js +0 -36
  17. package/src/cli/_template/cmd-sub2-export.js +0 -54
  18. package/src/cli/_template/cmd-sub2-import.js +0 -54
  19. package/src/cli/_template/cmd-sub2-list.js +0 -38
  20. package/src/cli/_template/cmd-sub2.js +0 -20
  21. package/src/cli/_template/cmd.js +0 -29
  22. package/src/cli/admin/admin-add-autoid-static-user-mapping.js +0 -40
  23. package/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +0 -121
  24. package/src/cli/admin/admin-get-access-token.js +0 -59
  25. package/src/cli/admin/admin-grant-oauth2-client-admin-privileges.js +0 -45
  26. package/src/cli/admin/admin-hide-generic-extension-attributes.js +0 -47
  27. package/src/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +0 -45
  28. package/src/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +0 -46
  29. package/src/cli/admin/admin-list-static-user-mappings.js +0 -53
  30. package/src/cli/admin/admin-remove-static-user-mapping.js +0 -38
  31. package/src/cli/admin/admin-repair-org-model.js +0 -47
  32. package/src/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +0 -47
  33. package/src/cli/admin/admin-show-generic-extension-attributes.js +0 -55
  34. package/src/cli/admin/admin.js +0 -94
  35. package/src/cli/app/app-delete.js +0 -56
  36. package/src/cli/app/app-describe.js +0 -36
  37. package/src/cli/app/app-export.js +0 -78
  38. package/src/cli/app/app-import.js +0 -56
  39. package/src/cli/app/app-list.js +0 -40
  40. package/src/cli/app/app.js +0 -29
  41. package/src/cli/cmd_common.js +0 -181
  42. package/src/cli/conn/conn-add.js +0 -65
  43. package/src/cli/conn/conn-delete.js +0 -22
  44. package/src/cli/conn/conn-describe.js +0 -23
  45. package/src/cli/conn/conn-list.js +0 -27
  46. package/src/cli/conn/conn.js +0 -28
  47. package/src/cli/email/email-template-export.js +0 -90
  48. package/src/cli/email/email-template-import.js +0 -90
  49. package/src/cli/email/email-template-list.js +0 -40
  50. package/src/cli/email/email-template.js +0 -16
  51. package/src/cli/email/email.js +0 -17
  52. package/src/cli/esv/esv-apply.js +0 -120
  53. package/src/cli/esv/esv-secret-create.js +0 -64
  54. package/src/cli/esv/esv-secret-delete.js +0 -65
  55. package/src/cli/esv/esv-secret-describe.js +0 -43
  56. package/src/cli/esv/esv-secret-export.js +0 -54
  57. package/src/cli/esv/esv-secret-import.js +0 -54
  58. package/src/cli/esv/esv-secret-list.js +0 -40
  59. package/src/cli/esv/esv-secret-set.js +0 -45
  60. package/src/cli/esv/esv-secret-version-activate.js +0 -53
  61. package/src/cli/esv/esv-secret-version-create.js +0 -45
  62. package/src/cli/esv/esv-secret-version-deactivate.js +0 -53
  63. package/src/cli/esv/esv-secret-version-delete.js +0 -66
  64. package/src/cli/esv/esv-secret-version-list.js +0 -41
  65. package/src/cli/esv/esv-secret-version.js +0 -20
  66. package/src/cli/esv/esv-secret.js +0 -26
  67. package/src/cli/esv/esv-variable-create.js +0 -46
  68. package/src/cli/esv/esv-variable-delete.js +0 -71
  69. package/src/cli/esv/esv-variable-describe.js +0 -43
  70. package/src/cli/esv/esv-variable-export.js +0 -54
  71. package/src/cli/esv/esv-variable-import.js +0 -54
  72. package/src/cli/esv/esv-variable-list.js +0 -40
  73. package/src/cli/esv/esv-variable-set.js +0 -62
  74. package/src/cli/esv/esv-variable.js +0 -24
  75. package/src/cli/esv/esv.js +0 -21
  76. package/src/cli/idm/idm-count.js +0 -42
  77. package/src/cli/idm/idm-export.js +0 -116
  78. package/src/cli/idm/idm-list.js +0 -40
  79. package/src/cli/idm/idm.js +0 -28
  80. package/src/cli/idp/idp-export.js +0 -90
  81. package/src/cli/idp/idp-import.js +0 -101
  82. package/src/cli/idp/idp-list.js +0 -42
  83. package/src/cli/idp/idp.js +0 -21
  84. package/src/cli/info/info.js +0 -55
  85. package/src/cli/journey/journey-delete.js +0 -78
  86. package/src/cli/journey/journey-describe.js +0 -143
  87. package/src/cli/journey/journey-export.js +0 -110
  88. package/src/cli/journey/journey-import.js +0 -127
  89. package/src/cli/journey/journey-list.js +0 -43
  90. package/src/cli/journey/journey-prune.js +0 -52
  91. package/src/cli/journey/journey.js +0 -37
  92. package/src/cli/logging/logs-list.js +0 -77
  93. package/src/cli/logging/logs-tail.js +0 -85
  94. package/src/cli/logging/logs.js +0 -21
  95. package/src/cli/realm/realm-add-custom-domain.js +0 -47
  96. package/src/cli/realm/realm-describe.js +0 -40
  97. package/src/cli/realm/realm-list.js +0 -40
  98. package/src/cli/realm/realm-remove-custom-domain.js +0 -50
  99. package/src/cli/realm/realm.js +0 -33
  100. package/src/cli/saml/saml-cot-export.js +0 -90
  101. package/src/cli/saml/saml-cot-import.js +0 -101
  102. package/src/cli/saml/saml-cot-list.js +0 -42
  103. package/src/cli/saml/saml-cot.js +0 -16
  104. package/src/cli/saml/saml-describe.js +0 -42
  105. package/src/cli/saml/saml-export.js +0 -91
  106. package/src/cli/saml/saml-import.js +0 -102
  107. package/src/cli/saml/saml-list.js +0 -42
  108. package/src/cli/saml/saml-metadata-export.js +0 -76
  109. package/src/cli/saml/saml-metadata.js +0 -12
  110. package/src/cli/saml/saml.js +0 -29
  111. package/src/cli/script/script-delete.js +0 -56
  112. package/src/cli/script/script-describe.js +0 -36
  113. package/src/cli/script/script-export.js +0 -95
  114. package/src/cli/script/script-import.js +0 -64
  115. package/src/cli/script/script-list.js +0 -42
  116. package/src/cli/script/script.js +0 -25
  117. package/src/cli/theme/theme-delete.js +0 -83
  118. package/src/cli/theme/theme-export.js +0 -107
  119. package/src/cli/theme/theme-import.js +0 -118
  120. package/src/cli/theme/theme-list.js +0 -42
  121. package/src/cli/theme/theme.js +0 -23
  122. package/src/storage/StaticStorage.js +0 -15
  123. package/src/utils/Console.js +0 -482
  124. package/tsconfig.json +0 -106
@@ -1,143 +0,0 @@
1
- import fs from 'fs';
2
- import { Command, Option } from 'commander';
3
- import { Authenticate, Journey, state } from '@rockcarver/frodo-lib';
4
- import * as common from '../cmd_common.js';
5
-
6
- const { getTokens } = Authenticate;
7
- const {
8
- getJourneys,
9
- exportJourney,
10
- createFileParamTreeExportResolver,
11
- describeJourney,
12
- } = Journey;
13
-
14
- const program = new Command('frodo journey describe');
15
-
16
- program
17
- .description(
18
- 'If -h is supplied, describe the journey/tree indicated by -i, or all journeys/trees in the realm if no -i is supplied, otherwise describe the journey/tree export file indicated by -f.'
19
- )
20
- .helpOption('-h, --help', 'Help')
21
- .showHelpAfterError()
22
- .addArgument(common.hostArgument)
23
- .addArgument(common.realmArgument)
24
- .addArgument(common.userArgument)
25
- .addArgument(common.passwordArgument)
26
- .addOption(common.deploymentOption)
27
- .addOption(common.insecureOption)
28
- .addOption(
29
- new Option(
30
- '-i, --journey-id <journey>',
31
- 'Name of a journey/tree. If specified, -a and -A are ignored.'
32
- )
33
- )
34
- .addOption(
35
- new Option(
36
- '-f, --file <file>',
37
- 'Name of the file to write the exported journey(s) to. Ignored with -A.'
38
- )
39
- )
40
- // .addOption(
41
- // new Option(
42
- // '-o, --override-version <version>',
43
- // "Override version. Notation: 'X.Y.Z' e.g. '7.1.0'. Override detected version with any version. This is helpful in order to check if journeys in one environment would be compatible running in another environment (e.g. in preparation of migrating from on-prem to ForgeRock Identity Cloud. Only impacts these actions: -d, -l."
44
- // )
45
- // )
46
- .action(
47
- // implement command logic inside action handler
48
- async (host, realm, user, password, options) => {
49
- state.default.session.setTenant(host);
50
- state.default.session.setRealm(realm);
51
- state.default.session.setUsername(user);
52
- state.default.session.setPassword(password);
53
- state.default.session.setDeploymentType(options.type);
54
- state.default.session.setAllowInsecureConnection(options.insecure);
55
- // TODO: review checks for arguments
56
- if (typeof host === 'undefined' || typeof options.file !== 'undefined') {
57
- if (
58
- typeof host === 'undefined' &&
59
- typeof options.file === 'undefined'
60
- ) {
61
- console.log('Need either [host] or -f.');
62
- process.exitCode = 1;
63
- return;
64
- }
65
- console.log(`Describing local journey file ${options.file}...`);
66
- try {
67
- const fileData = JSON.parse(fs.readFileSync(options.file, 'utf8'));
68
- let journeyData = null;
69
- // single or multi tree export?
70
- // multi - by id
71
- if (
72
- typeof options.journeyId !== 'undefined' &&
73
- fileData.trees &&
74
- fileData.trees[options.journeyId]
75
- ) {
76
- journeyData = fileData.trees[options.journeyId];
77
- }
78
- // multi - first
79
- else if (typeof options.journeyId === 'undefined' && fileData.trees) {
80
- [journeyData] = Object.values(fileData.trees);
81
- }
82
- // single - by id
83
- else if (
84
- typeof options.journeyId !== 'undefined' &&
85
- options.journeyId === fileData.tree?._id
86
- ) {
87
- journeyData = fileData;
88
- }
89
- // single
90
- else if (
91
- typeof options.journeyId === 'undefined' &&
92
- fileData.tree?._id
93
- ) {
94
- journeyData = fileData;
95
- }
96
- // no journey/tree found
97
- else {
98
- throw new Error(
99
- typeof options.journeyId === 'undefined'
100
- ? `No journey found in ${options.file}`
101
- : `Journey '${options.journeyId}' not found in ${options.file}`
102
- );
103
- }
104
- describeJourney(
105
- journeyData,
106
- createFileParamTreeExportResolver(options.file)
107
- );
108
- } catch (error) {
109
- console.log(error.message);
110
- process.exitCode = 1;
111
- }
112
- } else if (await getTokens()) {
113
- console.log(
114
- `Describing journey(s) in realm "${state.default.session.getRealm()}"...`
115
- );
116
- if (typeof options.journeyId === 'undefined') {
117
- let journeys = [];
118
- journeys = await getJourneys();
119
- for (const journey of journeys) {
120
- try {
121
- // eslint-disable-next-line no-await-in-loop, dot-notation
122
- const treeData = await exportJourney(journey['_id']);
123
- describeJourney(treeData);
124
- } catch (error) {
125
- console.log(error.message);
126
- process.exitCode = 1;
127
- }
128
- }
129
- } else {
130
- try {
131
- const treeData = await exportJourney(options.journeyId);
132
- describeJourney(treeData);
133
- } catch (error) {
134
- console.log(error.message);
135
- process.exitCode = 1;
136
- }
137
- }
138
- }
139
- }
140
- // end command logic inside action handler
141
- );
142
-
143
- program.parse();
@@ -1,110 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { Authenticate, Journey, state } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { getTokens } = Authenticate;
6
- const { exportJourneyToFile, exportJourneysToFile, exportJourneysToFiles } =
7
- Journey;
8
-
9
- const program = new Command('frodo journey export');
10
-
11
- program
12
- .description('Export journeys/trees.')
13
- .helpOption('-h, --help', 'Help')
14
- .showHelpAfterError()
15
- .addArgument(common.hostArgumentM)
16
- .addArgument(common.realmArgument)
17
- .addArgument(common.userArgument)
18
- .addArgument(common.passwordArgument)
19
- .addOption(common.deploymentOption)
20
- .addOption(common.insecureOption)
21
- .addOption(
22
- new Option(
23
- '-i, --journey-id <journey>',
24
- 'Name of a journey/tree. If specified, -a and -A are ignored.'
25
- )
26
- )
27
- .addOption(
28
- new Option(
29
- '-f, --file <file>',
30
- 'Name of the file to write the exported journey(s) to. Ignored with -A.'
31
- )
32
- )
33
- .addOption(
34
- new Option(
35
- '-a, --all',
36
- 'Export all the journeys/trees in a realm. Ignored with -i.'
37
- )
38
- )
39
- .addOption(
40
- new Option(
41
- '-A, --all-separate',
42
- 'Export all the journeys/trees in a realm as separate files <journey/tree name>.json. Ignored with -i or -a.'
43
- )
44
- )
45
- .addOption(
46
- new Option(
47
- '--use-string-arrays',
48
- 'Where applicable, use string arrays to store multi-line text (e.g. scripts).'
49
- ).default(false, 'off')
50
- )
51
- .addOption(
52
- new Option(
53
- '--no-deps',
54
- 'Do not include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).'
55
- )
56
- )
57
- .addOption(
58
- new Option(
59
- '--verbose',
60
- 'Verbose output during command execution. If specified, may or may not produce additional output.'
61
- ).default(false, 'off')
62
- )
63
- .action(
64
- // implement command logic inside action handler
65
- async (host, realm, user, password, options) => {
66
- state.default.session.setTenant(host);
67
- state.default.session.setRealm(realm);
68
- state.default.session.setUsername(user);
69
- state.default.session.setPassword(password);
70
- state.default.session.setDeploymentType(options.type);
71
- state.default.session.setAllowInsecureConnection(options.insecure);
72
- if (await getTokens()) {
73
- // export
74
- if (options.journeyId) {
75
- console.log('Exporting journey...');
76
- await exportJourneyToFile(options.journeyId, options.file, {
77
- useStringArrays: options.useStringArrays,
78
- deps: options.deps,
79
- verbose: options.verbose,
80
- });
81
- }
82
- // --all -a
83
- else if (options.all) {
84
- console.log('Exporting all journeys to a single file...');
85
- await exportJourneysToFile(options.file, {
86
- useStringArrays: options.useStringArrays,
87
- deps: options.deps,
88
- verbose: options.verbose,
89
- });
90
- }
91
- // --all-separate -A
92
- else if (options.allSeparate) {
93
- console.log('Exporting all journeys to separate files...');
94
- await exportJourneysToFiles({
95
- useStringArrays: options.useStringArrays,
96
- deps: options.deps,
97
- verbose: options.verbose,
98
- });
99
- }
100
- // unrecognized combination of options or no options
101
- else {
102
- console.log('Unrecognized combination of options or no options...');
103
- program.help();
104
- }
105
- }
106
- }
107
- // end command logic inside action handler
108
- );
109
-
110
- program.parse();
@@ -1,127 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { Authenticate, Journey, state } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { getTokens } = Authenticate;
6
- const {
7
- importJourneyFromFile,
8
- importJourneysFromFile,
9
- importJourneysFromFiles,
10
- importFirstJourneyFromFile,
11
- } = Journey;
12
-
13
- const program = new Command('frodo journey import');
14
-
15
- program
16
- .description('Import journey/tree.')
17
- .helpOption('-h, --help', 'Help')
18
- .showHelpAfterError()
19
- .addArgument(common.hostArgumentM)
20
- .addArgument(common.realmArgument)
21
- .addArgument(common.userArgument)
22
- .addArgument(common.passwordArgument)
23
- .addOption(common.deploymentOption)
24
- .addOption(common.insecureOption)
25
- .addOption(
26
- new Option(
27
- '-i, --journey-id <journey>',
28
- 'Name of a journey/tree. If specified, -a and -A are ignored.'
29
- )
30
- )
31
- .addOption(
32
- new Option(
33
- '-f, --file <file>',
34
- 'Name of the file to import the journey(s) from. Ignored with -A.'
35
- )
36
- )
37
- .addOption(
38
- new Option(
39
- '-a, --all',
40
- 'Import all the journeys/trees from single file. Ignored with -i.'
41
- )
42
- )
43
- .addOption(
44
- new Option(
45
- '-A, --all-separate',
46
- 'Import all the journeys/trees from separate files (*.json) in the current directory. Ignored with -i or -a.'
47
- )
48
- )
49
- .addOption(
50
- new Option(
51
- '--re-uuid',
52
- 'Generate new UUIDs for all nodes during import.'
53
- ).default(false, 'off')
54
- )
55
- .addOption(
56
- new Option(
57
- '--no-deps',
58
- 'Do not include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).'
59
- )
60
- )
61
- .addOption(
62
- new Option(
63
- '--verbose',
64
- 'Verbose output during command execution. If specified, may or may not produce additional output.'
65
- ).default(false, 'off')
66
- )
67
- .action(
68
- // implement command logic inside action handler
69
- async (host, realm, user, password, options) => {
70
- state.default.session.setTenant(host);
71
- state.default.session.setRealm(realm);
72
- state.default.session.setUsername(user);
73
- state.default.session.setPassword(password);
74
- state.default.session.setDeploymentType(options.type);
75
- state.default.session.setAllowInsecureConnection(options.insecure);
76
- if (await getTokens()) {
77
- // import
78
- if (options.journeyId) {
79
- console.log(`Importing journey ${options.journeyId}...`);
80
- importJourneyFromFile(options.journeyId, options.file, {
81
- reUuid: options.reUuid,
82
- deps: options.deps,
83
- verbose: options.verbose,
84
- });
85
- }
86
- // --all -a
87
- else if (options.all && options.file) {
88
- console.log(
89
- `Importing all journeys from a single file (${options.file})...`
90
- );
91
- importJourneysFromFile(options.file, {
92
- reUuid: options.reUuid,
93
- deps: options.deps,
94
- verbose: options.verbose,
95
- });
96
- }
97
- // --all-separate -A
98
- else if (options.allSeparate && !options.file) {
99
- console.log(
100
- 'Importing all journeys from separate files in current directory...'
101
- );
102
- importJourneysFromFiles({
103
- reUuid: options.reUuid,
104
- deps: options.deps,
105
- verbose: options.verbose,
106
- });
107
- }
108
- // import first journey in file
109
- else if (options.file) {
110
- console.log('Importing first journey in file...');
111
- importFirstJourneyFromFile(options.file, {
112
- reUuid: options.reUuid,
113
- deps: options.deps,
114
- verbose: options.verbose,
115
- });
116
- }
117
- // unrecognized combination of options or no options
118
- else {
119
- console.log('Unrecognized combination of options or no options...');
120
- program.help();
121
- }
122
- }
123
- }
124
- // end command logic inside action handler
125
- );
126
-
127
- program.parse();
@@ -1,43 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { Authenticate, Journey, state } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { getTokens } = Authenticate;
6
- const { listJourneys } = Journey;
7
-
8
- const program = new Command('frodo journey list');
9
-
10
- program
11
- .description('List journeys/trees.')
12
- .helpOption('-h, --help', 'Help')
13
- .showHelpAfterError()
14
- .addArgument(common.hostArgumentM)
15
- .addArgument(common.realmArgument)
16
- .addArgument(common.userArgument)
17
- .addArgument(common.passwordArgument)
18
- .addOption(common.deploymentOption)
19
- .addOption(common.insecureOption)
20
- .addOption(
21
- new Option('-l, --long', 'Long with all fields.').default(false, 'false')
22
- )
23
- .addOption(new Option('-a, --analyze', 'Analyze journeys for custom nodes.'))
24
- .action(
25
- // implement command logic inside action handler
26
- async (host, realm, user, password, options) => {
27
- state.default.session.setTenant(host);
28
- state.default.session.setRealm(realm);
29
- state.default.session.setUsername(user);
30
- state.default.session.setPassword(password);
31
- state.default.session.setDeploymentType(options.type);
32
- state.default.session.setAllowInsecureConnection(options.insecure);
33
- if (await getTokens()) {
34
- console.log(
35
- `Listing journeys in realm "${state.default.session.getRealm()}"...`
36
- );
37
- listJourneys(options.long, options.analyze);
38
- }
39
- }
40
- // end command logic inside action handler
41
- );
42
-
43
- program.parse();
@@ -1,52 +0,0 @@
1
- import { Command } from 'commander';
2
- import { Authenticate, Journey, state } from '@rockcarver/frodo-lib';
3
- import yesno from 'yesno';
4
- import * as common from '../cmd_common.js';
5
-
6
- const { getTokens } = Authenticate;
7
- const { findOrphanedNodes, removeOrphanedNodes } = Journey;
8
-
9
- const program = new Command('frodo journey prune');
10
-
11
- program
12
- .description(
13
- 'Prune orphaned configuration artifacts left behind after deleting authentication trees. You will be prompted before any destructive operations are performed.'
14
- )
15
- .helpOption('-h, --help', 'Help')
16
- .showHelpAfterError()
17
- .addArgument(common.hostArgumentM)
18
- .addArgument(common.realmArgument)
19
- .addArgument(common.userArgument)
20
- .addArgument(common.passwordArgument)
21
- .addOption(common.deploymentOption)
22
- .addOption(common.insecureOption)
23
- .action(
24
- // implement command logic inside action handler
25
- async (host, realm, user, password, options) => {
26
- state.default.session.setTenant(host);
27
- state.default.session.setRealm(realm);
28
- state.default.session.setUsername(user);
29
- state.default.session.setPassword(password);
30
- state.default.session.setDeploymentType(options.type);
31
- state.default.session.setAllowInsecureConnection(options.insecure);
32
- if (await getTokens()) {
33
- console.log(
34
- `Pruning orphaned configuration artifacts in realm "${state.default.session.getRealm()}"...`
35
- );
36
- const orphanedNodes = await findOrphanedNodes();
37
- if (orphanedNodes.length > 0) {
38
- const ok = await yesno({
39
- question: 'Prune (permanently delete) orphaned nodes? (y|n):',
40
- });
41
- if (ok) {
42
- await removeOrphanedNodes(orphanedNodes);
43
- }
44
- } else {
45
- console.log('No orphaned nodes found.');
46
- }
47
- }
48
- }
49
- // end command logic inside action handler
50
- );
51
-
52
- program.parse();
@@ -1,37 +0,0 @@
1
- import { Command } from 'commander';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
-
7
- export default function setup() {
8
- const program = new Command('journey')
9
- .helpOption('-h, --help', 'Help')
10
- .description('Manage journeys/trees.')
11
- .executableDir(__dirname);
12
-
13
- program.command('list', 'List journeys/trees.').showHelpAfterError();
14
-
15
- program
16
- .command(
17
- 'describe',
18
- 'If host argument is supplied, describe the journey/tree indicated by -t, or all journeys/trees in the realm if no -t is supplied, otherwise describe the journey/tree export file indicated by -f.'
19
- )
20
- .showHelpAfterError();
21
-
22
- program.command('export', 'Export journeys/trees.').showHelpAfterError();
23
-
24
- program.command('import', 'Import journeys/trees.').showHelpAfterError();
25
-
26
- program.command('delete', 'Delete journeys/trees.').showHelpAfterError();
27
-
28
- program
29
- .command(
30
- 'prune',
31
- 'Prune orphaned configuration artifacts left behind after deleting authentication trees. You will be prompted before any destructive operations are performed.'
32
- )
33
- .showHelpAfterError();
34
-
35
- program.showHelpAfterError();
36
- return program;
37
- }
@@ -1,77 +0,0 @@
1
- import {
2
- Authenticate,
3
- ConnectionProfile,
4
- Log,
5
- state,
6
- } from '@rockcarver/frodo-lib';
7
- import { Command } from 'commander';
8
- import * as common from '../cmd_common.js';
9
-
10
- const { provisionCreds, getLogSources } = Log;
11
- const { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;
12
- const { getTokens } = Authenticate;
13
-
14
- const program = new Command('frodo journey list');
15
- program
16
- .description('List available ID Cloud log sources.')
17
- .helpOption('-h, --help', 'Help')
18
- .addArgument(common.hostArgumentM)
19
- .addArgument(common.userArgument)
20
- .addArgument(common.passwordArgument)
21
- .addOption(common.insecureOption)
22
- .action(async (host, user, password, options) => {
23
- let credsFromParameters = true;
24
- state.default.session.setTenant(host);
25
- state.default.session.setUsername(user);
26
- state.default.session.setPassword(password);
27
- state.default.session.setAllowInsecureConnection(options.insecure);
28
- console.log('Listing available ID Cloud log sources...');
29
- const conn = await getConnectionProfile();
30
- state.default.session.setTenant(conn.tenant);
31
- if (conn.key != null && conn.secret != null) {
32
- credsFromParameters = false;
33
- state.default.session.setLogApiKey(conn.key);
34
- state.default.session.setLogApiSecret(conn.secret);
35
- } else {
36
- if (conn.username == null && conn.password == null) {
37
- if (
38
- !state.default.session.getUsername() &&
39
- !state.default.session.getPassword()
40
- ) {
41
- credsFromParameters = false;
42
- console.log(
43
- 'User credentials not specified as parameters and no saved API key and secret found!',
44
- 'warn'
45
- );
46
- return;
47
- }
48
- } else {
49
- state.default.session.setUsername(conn.username);
50
- state.default.session.setPassword(conn.password);
51
- }
52
- if (await getTokens()) {
53
- const creds = await provisionCreds();
54
- state.default.session.setLogApiKey(creds.api_key_id);
55
- state.default.session.setLogApiSecret(creds.api_key_secret);
56
- }
57
- }
58
-
59
- const sources = await getLogSources();
60
- if (sources.length === 0) {
61
- console.log(
62
- "Can't get sources, possible cause - wrong API key or secret",
63
- 'error'
64
- );
65
- } else {
66
- if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI
67
- console.log('Available log sources:');
68
- sources.forEach((source) => {
69
- console.log(`${source}`, 'info');
70
- });
71
- console.log('You can use any combination of comma separated sources.');
72
- console.log('For example:');
73
- console.log(`$ frodo logs tail -c am-core,idm-core ${host}`, 'info');
74
- }
75
- });
76
-
77
- program.parse();
@@ -1,85 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import {
3
- Authenticate,
4
- ConnectionProfile,
5
- Log,
6
- state,
7
- } from '@rockcarver/frodo-lib';
8
- import * as common from '../cmd_common.js';
9
-
10
- const { provisionCreds, tailLogs, resolveLevel } = Log;
11
- const { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;
12
- const { getTokens } = Authenticate;
13
-
14
- const program = new Command('frodo journey tail');
15
- program
16
- .description('Tail Identity Cloud logs.')
17
- .helpOption('-h, --help', 'Help')
18
- .addArgument(common.hostArgumentM)
19
- .addArgument(common.userArgument)
20
- .addArgument(common.passwordArgument)
21
- .addOption(common.insecureOption)
22
- .addOption(common.sourcesOptionM)
23
- .addOption(
24
- new Option(
25
- '-l, --level <level>',
26
- 'Set log level filter. You can specify the level as a number or a string. \
27
- Following values are possible (values on the same line are equivalent): \
28
- \n0, SEVERE, FATAL, or ERROR\n1, WARNING, WARN or CONFIG\
29
- \n2, INFO or INFORMATION\n3, DEBUG, FINE, FINER or FINEST\
30
- \n4 or ALL'
31
- ).default('ERROR', `${resolveLevel('ERROR')}`)
32
- )
33
- .addOption(
34
- new Option('-t, --transaction-id <txid>', 'Filter by transactionId')
35
- )
36
- .action(async (host, user, password, options, command) => {
37
- let credsFromParameters = true;
38
- state.default.session.setTenant(host);
39
- state.default.session.setUsername(user);
40
- state.default.session.setPassword(password);
41
- state.default.session.setAllowInsecureConnection(options.insecure);
42
- const conn = await getConnectionProfile();
43
- state.default.session.setTenant(conn.tenant);
44
- if (conn.key != null && conn.secret != null) {
45
- credsFromParameters = false;
46
- state.default.session.setLogApiKey(conn.key);
47
- state.default.session.setLogApiSecret(conn.secret);
48
- } else {
49
- if (conn.username == null && conn.password == null) {
50
- if (
51
- !state.default.session.getUsername() &&
52
- !state.default.session.getPassword()
53
- ) {
54
- credsFromParameters = false;
55
- console.log(
56
- 'User credentials not specified as parameters and no saved API key and secret found!',
57
- 'warn'
58
- );
59
- return;
60
- }
61
- } else {
62
- state.default.session.setUsername(conn.username);
63
- state.default.session.setPassword(conn.password);
64
- }
65
- if (await getTokens()) {
66
- const creds = await provisionCreds();
67
- state.default.session.setLogApiKey(creds.api_key_id);
68
- state.default.session.setLogApiSecret(creds.api_key_secret);
69
- }
70
- }
71
- console.log(
72
- `Tailing ID Cloud logs from the following sources: ${
73
- command.opts().sources
74
- } and levels [${resolveLevel(command.opts().level)}]...`
75
- );
76
- if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI
77
- await tailLogs(
78
- command.opts().sources,
79
- resolveLevel(command.opts().level),
80
- command.opts().transactionId,
81
- null
82
- );
83
- });
84
-
85
- program.parse();