@rockcarver/frodo-cli 0.14.0 → 0.15.0

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 (138) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/package.json +2 -2
  3. package/babel.config.esm.json +0 -6
  4. package/src/app.ts +0 -63
  5. package/src/cli/_template/cmd-delete.ts +0 -56
  6. package/src/cli/_template/cmd-describe.ts +0 -36
  7. package/src/cli/_template/cmd-export.ts +0 -54
  8. package/src/cli/_template/cmd-import.ts +0 -54
  9. package/src/cli/_template/cmd-list.ts +0 -38
  10. package/src/cli/_template/cmd-sub1-delete.ts +0 -56
  11. package/src/cli/_template/cmd-sub1-describe.ts +0 -36
  12. package/src/cli/_template/cmd-sub1-export.ts +0 -54
  13. package/src/cli/_template/cmd-sub1-import.ts +0 -54
  14. package/src/cli/_template/cmd-sub1-list.ts +0 -38
  15. package/src/cli/_template/cmd-sub1.ts +0 -20
  16. package/src/cli/_template/cmd-sub2-delete.ts +0 -56
  17. package/src/cli/_template/cmd-sub2-describe.ts +0 -36
  18. package/src/cli/_template/cmd-sub2-export.ts +0 -54
  19. package/src/cli/_template/cmd-sub2-import.ts +0 -54
  20. package/src/cli/_template/cmd-sub2-list.ts +0 -38
  21. package/src/cli/_template/cmd-sub2.ts +0 -20
  22. package/src/cli/_template/cmd.ts +0 -29
  23. package/src/cli/admin/admin-add-autoid-static-user-mapping.ts +0 -40
  24. package/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.ts +0 -121
  25. package/src/cli/admin/admin-get-access-token.ts +0 -59
  26. package/src/cli/admin/admin-grant-oauth2-client-admin-privileges.ts +0 -45
  27. package/src/cli/admin/admin-hide-generic-extension-attributes.ts +0 -47
  28. package/src/cli/admin/admin-list-oauth2-clients-with-admin-privileges.ts +0 -45
  29. package/src/cli/admin/admin-list-oauth2-clients-with-custom-privileges.ts +0 -46
  30. package/src/cli/admin/admin-list-static-user-mappings.ts +0 -53
  31. package/src/cli/admin/admin-remove-static-user-mapping.ts +0 -38
  32. package/src/cli/admin/admin-repair-org-model.ts +0 -53
  33. package/src/cli/admin/admin-revoke-oauth2-client-admin-privileges.ts +0 -47
  34. package/src/cli/admin/admin-show-generic-extension-attributes.ts +0 -55
  35. package/src/cli/admin/admin.ts +0 -94
  36. package/src/cli/app/app-delete.ts +0 -56
  37. package/src/cli/app/app-describe.ts +0 -36
  38. package/src/cli/app/app-export.ts +0 -78
  39. package/src/cli/app/app-import.ts +0 -56
  40. package/src/cli/app/app-list.ts +0 -40
  41. package/src/cli/app/app.ts +0 -29
  42. package/src/cli/cmd_common.ts +0 -181
  43. package/src/cli/conn/conn-add.ts +0 -65
  44. package/src/cli/conn/conn-delete.ts +0 -22
  45. package/src/cli/conn/conn-describe.ts +0 -23
  46. package/src/cli/conn/conn-list.ts +0 -27
  47. package/src/cli/conn/conn.ts +0 -28
  48. package/src/cli/email/email-template-export.ts +0 -90
  49. package/src/cli/email/email-template-import.ts +0 -90
  50. package/src/cli/email/email-template-list.ts +0 -40
  51. package/src/cli/email/email-template.ts +0 -16
  52. package/src/cli/email/email.ts +0 -17
  53. package/src/cli/esv/esv-apply.ts +0 -120
  54. package/src/cli/esv/esv-secret-create.ts +0 -64
  55. package/src/cli/esv/esv-secret-delete.ts +0 -65
  56. package/src/cli/esv/esv-secret-describe.ts +0 -43
  57. package/src/cli/esv/esv-secret-export.ts +0 -54
  58. package/src/cli/esv/esv-secret-import.ts +0 -54
  59. package/src/cli/esv/esv-secret-list.ts +0 -40
  60. package/src/cli/esv/esv-secret-set.ts +0 -45
  61. package/src/cli/esv/esv-secret-version-activate.ts +0 -53
  62. package/src/cli/esv/esv-secret-version-create.ts +0 -45
  63. package/src/cli/esv/esv-secret-version-deactivate.ts +0 -53
  64. package/src/cli/esv/esv-secret-version-delete.ts +0 -66
  65. package/src/cli/esv/esv-secret-version-list.ts +0 -41
  66. package/src/cli/esv/esv-secret-version.ts +0 -20
  67. package/src/cli/esv/esv-secret.ts +0 -26
  68. package/src/cli/esv/esv-variable-create.ts +0 -46
  69. package/src/cli/esv/esv-variable-delete.ts +0 -71
  70. package/src/cli/esv/esv-variable-describe.ts +0 -43
  71. package/src/cli/esv/esv-variable-export.ts +0 -54
  72. package/src/cli/esv/esv-variable-import.ts +0 -54
  73. package/src/cli/esv/esv-variable-list.ts +0 -40
  74. package/src/cli/esv/esv-variable-set.ts +0 -62
  75. package/src/cli/esv/esv-variable.ts +0 -24
  76. package/src/cli/esv/esv.ts +0 -21
  77. package/src/cli/idm/idm-count.ts +0 -42
  78. package/src/cli/idm/idm-export.ts +0 -116
  79. package/src/cli/idm/idm-list.ts +0 -40
  80. package/src/cli/idm/idm.ts +0 -28
  81. package/src/cli/idp/idp-export.ts +0 -90
  82. package/src/cli/idp/idp-import.ts +0 -101
  83. package/src/cli/idp/idp-list.ts +0 -42
  84. package/src/cli/idp/idp.ts +0 -21
  85. package/src/cli/info/info.ts +0 -55
  86. package/src/cli/journey/journey-delete.e2e.test_.ts +0 -380
  87. package/src/cli/journey/journey-delete.ts +0 -78
  88. package/src/cli/journey/journey-describe.ts +0 -148
  89. package/src/cli/journey/journey-export.ts +0 -110
  90. package/src/cli/journey/journey-import.ts +0 -127
  91. package/src/cli/journey/journey-list.e2e.test_.ts +0 -142
  92. package/src/cli/journey/journey-list.ts +0 -43
  93. package/src/cli/journey/journey-prune.ts +0 -52
  94. package/src/cli/journey/journey.ts +0 -37
  95. package/src/cli/logging/logs-list.ts +0 -77
  96. package/src/cli/logging/logs-tail.ts +0 -85
  97. package/src/cli/logging/logs.ts +0 -21
  98. package/src/cli/realm/realm-add-custom-domain.ts +0 -47
  99. package/src/cli/realm/realm-describe.ts +0 -40
  100. package/src/cli/realm/realm-list.ts +0 -40
  101. package/src/cli/realm/realm-remove-custom-domain.ts +0 -50
  102. package/src/cli/realm/realm.ts +0 -33
  103. package/src/cli/saml/saml-cot-export.ts +0 -90
  104. package/src/cli/saml/saml-cot-import.ts +0 -101
  105. package/src/cli/saml/saml-cot-list.ts +0 -42
  106. package/src/cli/saml/saml-cot.ts +0 -16
  107. package/src/cli/saml/saml-describe.ts +0 -42
  108. package/src/cli/saml/saml-export.ts +0 -91
  109. package/src/cli/saml/saml-import.ts +0 -102
  110. package/src/cli/saml/saml-list.ts +0 -42
  111. package/src/cli/saml/saml-metadata-export.ts +0 -76
  112. package/src/cli/saml/saml-metadata.ts +0 -12
  113. package/src/cli/saml/saml.ts +0 -29
  114. package/src/cli/script/script-delete.ts +0 -56
  115. package/src/cli/script/script-describe.ts +0 -36
  116. package/src/cli/script/script-export.ts +0 -95
  117. package/src/cli/script/script-import.ts +0 -64
  118. package/src/cli/script/script-list.ts +0 -42
  119. package/src/cli/script/script.ts +0 -25
  120. package/src/cli/theme/theme-delete.e2e.test_.ts +0 -178
  121. package/src/cli/theme/theme-delete.ts +0 -83
  122. package/src/cli/theme/theme-export.ts +0 -107
  123. package/src/cli/theme/theme-import.ts +0 -118
  124. package/src/cli/theme/theme-list.e2e.test_.ts +0 -119
  125. package/src/cli/theme/theme-list.ts +0 -42
  126. package/src/cli/theme/theme.ts +0 -23
  127. package/src/ops/CirclesOfTrustOps.ts +0 -12
  128. package/src/ops/EmailTemplateOps.ts +0 -19
  129. package/src/ops/IdpOps.ts +0 -11
  130. package/src/ops/JourneyOps.ts +0 -278
  131. package/src/ops/NodeOps.ts +0 -47
  132. package/src/ops/Saml2Ops.ts +0 -24
  133. package/src/ops/ScriptOps.ts +0 -11
  134. package/src/ops/ThemeOps.ts +0 -17
  135. package/src/ops/utils/Wordwrap.ts +0 -11
  136. package/src/storage/StaticStorage.ts +0 -15
  137. package/src/utils/Console.ts +0 -483
  138. package/tsconfig.json +0 -106
@@ -1,181 +0,0 @@
1
- import { Argument, Option } from 'commander';
2
- import { state } from '@rockcarver/frodo-lib';
3
- import * as global from '../storage/StaticStorage.js';
4
- import {
5
- printMessage,
6
- createProgressIndicator,
7
- updateProgressIndicator,
8
- stopProgressIndicator,
9
- } from '../utils/Console.js';
10
-
11
- state.default.session.setPrintHandler(printMessage);
12
- state.default.session.setCreateProgressHandler(createProgressIndicator);
13
- state.default.session.setUpdateProgressHandler(updateProgressIndicator);
14
- state.default.session.setStopProgressHandler(stopProgressIndicator);
15
-
16
- // pseudo functions for commands that do not otherwise need to import
17
- // this file but need to trigger print and progress handler registration
18
- export function init() {}
19
-
20
- const hostArgumentDescription =
21
- 'Access Management base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.';
22
- export const hostArgument = new Argument('[host]', hostArgumentDescription);
23
- export const hostArgumentM = new Argument('<host>', hostArgumentDescription);
24
-
25
- const realmArgumentDescription =
26
- "Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise.";
27
- export const realmArgument = new Argument(
28
- '[realm]',
29
- realmArgumentDescription
30
- ).default(
31
- global.DEFAULT_REALM_KEY,
32
- '"alpha" for Identity Cloud tenants, "/" otherwise.'
33
- );
34
- export const realmArgumentM = new Argument('<realm>', realmArgumentDescription);
35
-
36
- const userArgumentDescription =
37
- 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.';
38
- export const userArgument = new Argument('[user]', userArgumentDescription);
39
- export const userArgumentM = new Argument('<user>', userArgumentDescription);
40
-
41
- const passwordArgumentDescription = 'Password.';
42
- export const passwordArgument = new Argument(
43
- '[password]',
44
- passwordArgumentDescription
45
- );
46
- export const passwordArgumentM = new Argument(
47
- '<password>',
48
- passwordArgumentDescription
49
- );
50
-
51
- const apiKeyArgumentDescription = 'API key for logging API.';
52
- export const apiKeyArgument = new Argument('[key]', apiKeyArgumentDescription);
53
-
54
- const apiSecretArgumentDescription = 'API secret for logging API.';
55
- export const apiSecretArgument = new Argument(
56
- '[secret]',
57
- apiSecretArgumentDescription
58
- );
59
-
60
- const treeOptionDescription =
61
- 'Specify the name of an authentication journey/tree.';
62
- export const treeOption = new Option(
63
- '-t, --tree <tree>',
64
- treeOptionDescription
65
- );
66
- export const treeOptionM = new Option(
67
- '-t, --tree <tree>',
68
- treeOptionDescription
69
- );
70
-
71
- const fileOptionDescription = 'File name.';
72
- export const fileOption = new Option(
73
- '-f, --file <file>',
74
- fileOptionDescription
75
- );
76
- export const fileOptionM = new Option(
77
- '-f, --file <file>',
78
- fileOptionDescription
79
- );
80
-
81
- const deploymentOptionDescription =
82
- 'Override auto-detected deployment type. Valid values for type: \n\
83
- classic: A classic Access Management-only deployment with custom layout and configuration. \n\
84
- cloud: A ForgeRock Identity Cloud environment. \n\
85
- forgeops: A ForgeOps CDK or CDM deployment. \n\
86
- The detected or provided deployment type controls certain behavior like obtaining an Identity \
87
- Management admin token or not and whether to export/import referenced email templates or how \
88
- to walk through the tenant admin login flow of Identity Cloud and handle MFA';
89
- export const deploymentOption = new Option(
90
- '-m, --type <type>',
91
- deploymentOptionDescription
92
- ).choices(global.DEPLOYMENT_TYPES);
93
- export const deploymentOptionM = new Option(
94
- '-m, --type <type>',
95
- deploymentOptionDescription
96
- ).choices(global.DEPLOYMENT_TYPES);
97
-
98
- export const insecureOption = new Option(
99
- '-k, --insecure',
100
- 'Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability.'
101
- ).default(false, "Don't allow insecure connections");
102
-
103
- export const nameOption = new Option(
104
- '-N, --name <name>',
105
- 'Config entity name to be exported or imported/updated. Examples are \
106
- managed, sync, provisioner-xxxx, etc.'
107
- );
108
- export const nameOptionM = new Option(
109
- '-N, --name <name>',
110
- 'Config entity name to be exported or imported/updated. Examples are \
111
- managed, sync, provisioner-xxxx, etc.'
112
- );
113
-
114
- export const managedNameOption = new Option(
115
- '-N, --name <name>',
116
- 'Managed object name to be operated on. Examples are \
117
- user, role, alpha_user, alpha_role etc.'
118
- );
119
- export const managedNameOptionM = new Option(
120
- '-N, --name <name>',
121
- 'Managed object name to be operated on. Examples are \
122
- user, role, alpha_user, alpha_role etc.'
123
- );
124
-
125
- const dirOptionDescription =
126
- 'Directory for exporting all configuration entities to.';
127
- export const dirOption = new Option(
128
- '-D, --directory <directory>',
129
- dirOptionDescription
130
- );
131
- export const dirOptionM = new Option(
132
- '-D, --directory <directory>',
133
- dirOptionDescription
134
- );
135
-
136
- const entitiesFileOptionDescription =
137
- 'JSON file that specifies the config entities to export/import.';
138
- export const entitiesFileOption = new Option(
139
- '-E, --entitiesFile <file>',
140
- entitiesFileOptionDescription
141
- );
142
- export const entitiesFileOptionM = new Option(
143
- '-E, --entitiesFile <file>',
144
- entitiesFileOptionDescription
145
- );
146
-
147
- const envFileOptionDescription =
148
- 'File that defines environment specific variables for replacement during configuration export/import.';
149
- export const envFileOption = new Option(
150
- '-e, --envFile <file>',
151
- envFileOptionDescription
152
- );
153
- export const envFileOptionM = new Option(
154
- '-e, --envFile <file>',
155
- envFileOptionDescription
156
- );
157
-
158
- const sourcesOptionDescription = 'Comma separated list of log sources';
159
- const sourcesOptionDefaultValueDescription = 'Log everything';
160
- export const sourcesOptionM = new Option(
161
- '-c, --sources <sources>',
162
- sourcesOptionDescription
163
- ).default('am-everything,idm-everything', sourcesOptionDefaultValueDescription);
164
-
165
- export const scriptFriendlyOption = new Option(
166
- '-s, --scriptFriendly',
167
- 'Send output of operation to STDOUT in a script-friendly format (JSON) which can be piped to other \
168
- commands. User messages/warnings are output to STDERR, and are not piped. For example, to only get \
169
- bearer token: \n\
170
- <<< frodo info my-tenant -s 2>/dev/null | jq -r .bearerToken >>>'
171
- ).default(false, 'Output as plain text');
172
-
173
- treeOptionM.makeOptionMandatory();
174
- fileOptionM.makeOptionMandatory();
175
- deploymentOptionM.makeOptionMandatory();
176
- nameOptionM.makeOptionMandatory();
177
- dirOptionM.makeOptionMandatory();
178
- entitiesFileOptionM.makeOptionMandatory();
179
- envFileOptionM.makeOptionMandatory();
180
- managedNameOptionM.makeOptionMandatory();
181
- sourcesOptionM.makeOptionMandatory();
@@ -1,65 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { Authenticate, ConnectionProfile, state } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { getTokens } = Authenticate;
6
- const { saveConnectionProfile } = ConnectionProfile;
7
-
8
- const program = new Command('frodo conn add');
9
-
10
- program
11
- .description(
12
- 'Add a new connection profiles. You have to specify a URL, username and password at a minimum.\nOptionally, for Identity Cloud, you can also add a log API key and secret.'
13
- )
14
- .helpOption('-h, --help', 'Help')
15
- .showHelpAfterError()
16
- .addArgument(common.hostArgumentM)
17
- .addArgument(common.userArgument)
18
- .addArgument(common.passwordArgument)
19
- .addArgument(common.apiKeyArgument)
20
- .addArgument(common.apiSecretArgument)
21
- .addOption(common.deploymentOption)
22
- .addOption(common.insecureOption)
23
- .addOption(new Option('--no-validate', 'Do not validate connection.'))
24
- .addOption(
25
- new Option(
26
- '--authentication-service [service]',
27
- 'Name of the authentication service/tree to use.'
28
- )
29
- )
30
- .addOption(
31
- new Option(
32
- '--authentication-header-overrides [headers]',
33
- 'Map of headers: {"host":"am.example.com:8081"}.'
34
- )
35
- )
36
- .action(
37
- // implement command logic inside action handler
38
- async (host, user, password, key, secret, options) => {
39
- state.default.session.setTenant(host);
40
- state.default.session.setUsername(user);
41
- state.default.session.setPassword(password);
42
- state.default.session.setLogApiKey(key);
43
- state.default.session.setLogApiSecret(secret);
44
- state.default.session.setDeploymentType(options.type);
45
- state.default.session.setAllowInsecureConnection(options.insecure);
46
- if (options.authenticationService) {
47
- state.default.session.setAuthenticationService(
48
- options.authenticationService
49
- );
50
- }
51
- if (options.authenticationHeaderOverrides) {
52
- state.default.session.setAuthenticationHeaderOverrides(
53
- JSON.parse(options.authenticationHeaderOverrides)
54
- );
55
- }
56
- if ((options.validate && (await getTokens())) || !options.validate) {
57
- saveConnectionProfile();
58
- } else {
59
- process.exitCode = 1;
60
- }
61
- }
62
- // end command logic inside action handler
63
- );
64
-
65
- program.parse();
@@ -1,22 +0,0 @@
1
- import { Command } from 'commander';
2
- import { ConnectionProfile } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { deleteConnectionProfile } = ConnectionProfile;
6
-
7
- const program = new Command('frodo conn delete');
8
-
9
- program
10
- .description('Delete connection profiles.')
11
- .helpOption('-h, --help', 'Help')
12
- .showHelpAfterError()
13
- .addArgument(common.hostArgumentM)
14
- .action(
15
- // implement command logic inside action handler
16
- async (host) => {
17
- deleteConnectionProfile(host);
18
- }
19
- // end command logic inside action handler
20
- );
21
-
22
- program.parse();
@@ -1,23 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { ConnectionProfile } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { describeConnectionProfile } = ConnectionProfile;
6
-
7
- const program = new Command('frodo conn describe');
8
-
9
- program
10
- .description('Describe connection profile.')
11
- .helpOption('-h, --help', 'Help')
12
- .showHelpAfterError()
13
- .addArgument(common.hostArgumentM)
14
- .addOption(new Option('--show-secrets', 'Show passwords and secrets.'))
15
- .action(
16
- // implement command logic inside action handler
17
- async (host, options) => {
18
- describeConnectionProfile(host, options.showSecrets);
19
- }
20
- // end command logic inside action handler
21
- );
22
-
23
- program.parse();
@@ -1,27 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { ConnectionProfile } from '@rockcarver/frodo-lib';
3
- import { init } from '../cmd_common.js';
4
-
5
- const { listConnectionProfiles } = ConnectionProfile;
6
-
7
- // pseudo init to trigger print and progress handler registration
8
- init();
9
-
10
- const program = new Command('frodo conn list');
11
-
12
- program
13
- .description('List connection profiles.')
14
- .helpOption('-h, --help', 'Help')
15
- .showHelpAfterError()
16
- .addOption(
17
- new Option('-l, --long', 'Long with all fields.').default(false, 'false')
18
- )
19
- .action(
20
- // implement command logic inside action handler
21
- async (options) => {
22
- listConnectionProfiles(options.long);
23
- }
24
- // end command logic inside action handler
25
- );
26
-
27
- program.parse();
@@ -1,28 +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('conn')
9
- .alias('connection')
10
- // for backwards compatibility
11
- .alias('connections')
12
- .helpOption('-h, --help', 'Help')
13
- .description('Manage connection profiles.')
14
- .executableDir(__dirname);
15
-
16
- program.command('add', 'Add connection profiles.').showHelpAfterError();
17
-
18
- program.command('delete', 'Delete connection profiles.').showHelpAfterError();
19
-
20
- program
21
- .command('describe', 'Describe connection profiles.')
22
- .showHelpAfterError();
23
-
24
- program.command('list', 'List connection profiles.').showHelpAfterError();
25
-
26
- program.showHelpAfterError();
27
- return program;
28
- }
@@ -1,90 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { Authenticate, EmailTemplate, state } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { getTokens } = Authenticate;
6
- const {
7
- exportEmailTemplatesToFile,
8
- exportEmailTemplatesToFiles,
9
- exportEmailTemplateToFile,
10
- } = EmailTemplate;
11
-
12
- const program = new Command('frodo email template export');
13
-
14
- program
15
- .description('Export email templates.')
16
- .helpOption('-h, --help', 'Help')
17
- .showHelpAfterError()
18
- .addArgument(common.hostArgumentM)
19
- .addArgument(common.realmArgument)
20
- .addArgument(common.userArgument)
21
- .addArgument(common.passwordArgument)
22
- .addOption(common.deploymentOption)
23
- .addOption(common.insecureOption)
24
- .addOption(
25
- new Option(
26
- '-i, --template-id <template-id>',
27
- 'Email template id/name. If specified, -a and -A are ignored.'
28
- )
29
- )
30
- .addOption(
31
- new Option(
32
- '-f, --file [file]',
33
- 'Name of the export file. Ignored with -A. Defaults to <template-id>.template.email.json.'
34
- )
35
- )
36
- .addOption(
37
- new Option(
38
- '-a, --all',
39
- 'Export all email templates to a single file. Ignored with -i.'
40
- )
41
- )
42
- .addOption(
43
- new Option(
44
- '-A, --all-separate',
45
- 'Export all email templates as separate files <template-id>.template.email.json. Ignored with -i, and -a.'
46
- )
47
- )
48
- .action(
49
- // implement command logic inside action handler
50
- async (host, realm, user, password, options) => {
51
- state.default.session.setTenant(host);
52
- state.default.session.setRealm(realm);
53
- state.default.session.setUsername(user);
54
- state.default.session.setPassword(password);
55
- state.default.session.setDeploymentType(options.type);
56
- state.default.session.setAllowInsecureConnection(options.insecure);
57
- if (await getTokens()) {
58
- // export by id/name
59
- if (options.templateId) {
60
- console.log(
61
- `Exporting email template "${
62
- options.templateId
63
- }" from realm "${state.default.session.getRealm()}"...`
64
- );
65
- exportEmailTemplateToFile(options.templateId, options.file);
66
- }
67
- // --all -a
68
- else if (options.all) {
69
- console.log('Exporting all email templates to a single file...');
70
- exportEmailTemplatesToFile(options.file);
71
- }
72
- // --all-separate -A
73
- else if (options.allSeparate) {
74
- console.log('Exporting all email templates to separate files...');
75
- exportEmailTemplatesToFiles();
76
- }
77
- // unrecognized combination of options or no options
78
- else {
79
- console.log(
80
- 'Unrecognized combination of options or no options...',
81
- 'error'
82
- );
83
- program.help();
84
- }
85
- }
86
- }
87
- // end command logic inside action handler
88
- );
89
-
90
- program.parse();
@@ -1,90 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { Authenticate, EmailTemplate, state } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { getTokens } = Authenticate;
6
- const {
7
- importEmailTemplateFromFile,
8
- importEmailTemplatesFromFile,
9
- importEmailTemplatesFromFiles,
10
- importFirstEmailTemplateFromFile,
11
- } = EmailTemplate;
12
-
13
- const program = new Command('frodo email template import');
14
-
15
- program
16
- .description('Import email templates.')
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, --template-id <template-id>',
28
- 'Email template id/name. If specified, -a and -A are ignored.'
29
- )
30
- )
31
- .addOption(new Option('-f, --file <file>', 'Name of the import file.'))
32
- .addOption(
33
- new Option(
34
- '-a, --all',
35
- 'Import all email templates from single file. Ignored with -i.'
36
- )
37
- )
38
- .addOption(
39
- new Option(
40
- '-A, --all-separate',
41
- 'Import all email templates from separate files (*.template.email.json) in the current directory. Ignored with -i or -a.'
42
- )
43
- )
44
- .action(
45
- // implement program logic inside action handler
46
- async (host, realm, user, password, options) => {
47
- state.default.session.setTenant(host);
48
- state.default.session.setRealm(realm);
49
- state.default.session.setUsername(user);
50
- state.default.session.setPassword(password);
51
- state.default.session.setDeploymentType(options.type);
52
- state.default.session.setAllowInsecureConnection(options.insecure);
53
- if (await getTokens()) {
54
- // import by id
55
- if (options.file && options.templateId) {
56
- console.log(`Importing email template "${options.templateId}"...`);
57
- importEmailTemplateFromFile(options.templateId, options.file);
58
- }
59
- // --all -a
60
- else if (options.all && options.file) {
61
- console.log(
62
- `Importing all email templates from a single file (${options.file})...`
63
- );
64
- importEmailTemplatesFromFile(options.file);
65
- }
66
- // --all-separate -A
67
- else if (options.allSeparate && !options.file) {
68
- console.log(
69
- 'Importing all email templates from separate files (*.template.email.json) in current directory...'
70
- );
71
- importEmailTemplatesFromFiles();
72
- }
73
- // import first template from file
74
- else if (options.file) {
75
- console.log(
76
- `Importing first email template from file "${options.file}"...`
77
- );
78
- importFirstEmailTemplateFromFile(options.file);
79
- }
80
- // unrecognized combination of options or no options
81
- else {
82
- console.log('Unrecognized combination of options or no options...');
83
- program.help();
84
- }
85
- }
86
- }
87
- // end program logic inside action handler
88
- );
89
-
90
- program.parse();
@@ -1,40 +0,0 @@
1
- import { Command, Option } from 'commander';
2
- import { Authenticate, EmailTemplate, state } from '@rockcarver/frodo-lib';
3
- import * as common from '../cmd_common.js';
4
-
5
- const { getTokens } = Authenticate;
6
- const { listEmailTemplates } = EmailTemplate;
7
-
8
- const program = new Command('frodo email template list');
9
-
10
- program
11
- .description('List email templates.')
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
- .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(`Listing email templates ...`);
34
- listEmailTemplates(options.long);
35
- }
36
- }
37
- // end command logic inside action handler
38
- );
39
-
40
- program.parse();
@@ -1,16 +0,0 @@
1
- import { Command } from 'commander';
2
-
3
- const program = new Command('frodo email template');
4
-
5
- program
6
- .description('Manage email templates.')
7
- .helpOption('-h, --help', 'Help')
8
- .showHelpAfterError();
9
-
10
- program.command('list', 'List email templates.').showHelpAfterError();
11
-
12
- program.command('export', 'Export email templates.').showHelpAfterError();
13
-
14
- program.command('import', 'Import email templates.').showHelpAfterError();
15
-
16
- program.parse();
@@ -1,17 +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('email')
9
- .helpOption('-h, --help', 'Help')
10
- .description('Manage email templates and configuration.')
11
- .executableDir(__dirname);
12
-
13
- program.command('template', 'Manage email templates.').showHelpAfterError();
14
-
15
- program.showHelpAfterError();
16
- return program;
17
- }