@rockcarver/frodo-cli 0.20.1-1 → 0.20.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.
- package/CHANGELOG.md +18 -2
- package/esm/cli/FrodoCommand.js +5 -1
- package/esm/cli/FrodoCommand.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.20.1] - 2023-01-20
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Updated to frodo-lib 0.18.1
|
|
15
|
+
- Include service account name in `frodo conn list -l` and `frodo conn describe <host>` output.
|
|
16
|
+
- Add missing service account name when running `frodo conn save <host>`.
|
|
17
|
+
- Add tenant name to beginning of output of all `frodo logs` sub-commands: `fetch`, `list`, `tail`.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- \#176: frodo logs fetch end timestamp ignored
|
|
22
|
+
|
|
10
23
|
## [0.20.1-1] - 2023-01-16
|
|
11
24
|
|
|
12
25
|
## [0.20.1-0] - 2023-01-15
|
|
@@ -109,7 +122,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
109
122
|
|
|
110
123
|
- Updated list of contributors in package.json
|
|
111
124
|
|
|
112
|
-
- Add linux arm64 binary builds
|
|
125
|
+
- \#166: Add linux arm64 binary builds
|
|
113
126
|
|
|
114
127
|
### Changed
|
|
115
128
|
|
|
@@ -118,6 +131,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
118
131
|
|
|
119
132
|
### Fixed
|
|
120
133
|
|
|
134
|
+
- \#164: Frodo now properly exports scripts with special chars in name
|
|
121
135
|
- \#161: Frodo now properly adds connection profiles with log credentials
|
|
122
136
|
|
|
123
137
|
## [0.19.5-2] - 2023-01-13
|
|
@@ -962,7 +976,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
962
976
|
- Fixed problem with adding connection profiles
|
|
963
977
|
- Miscellaneous bug fixes
|
|
964
978
|
|
|
965
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1
|
|
979
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1...HEAD
|
|
980
|
+
|
|
981
|
+
[0.20.1]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1-1...v0.20.1
|
|
966
982
|
|
|
967
983
|
[0.20.1-1]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1-0...v0.20.1-1
|
|
968
984
|
|
package/esm/cli/FrodoCommand.js
CHANGED
|
@@ -10,7 +10,7 @@ process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY, '"alpha" for Identity
|
|
|
10
10
|
const usernameArgument = new Argument('[username]', 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.');
|
|
11
11
|
const passwordArgument = new Argument('[password]', 'Password.');
|
|
12
12
|
const serviceAccountIdOption = new Option('--sa-id <sa-id>', 'Service account id.');
|
|
13
|
-
const serviceAccountJwkFileOption = new Option('--sa-jwk-file <file>', 'File containing the
|
|
13
|
+
const serviceAccountJwkFileOption = new Option('--sa-jwk-file <file>', 'File containing the JSON Web Key (JWK) associated with the the service account.');
|
|
14
14
|
const deploymentOption = new Option('-m, --type <type>', 'Override auto-detected deployment type. Valid values for type: \n\
|
|
15
15
|
classic: A classic Access Management-only deployment with custom layout and configuration. \n\
|
|
16
16
|
cloud: A ForgeRock Identity Cloud environment. \n\
|
|
@@ -111,6 +111,10 @@ export class FrodoCommand extends FrodoStubCommand {
|
|
|
111
111
|
|
|
112
112
|
// handle arguments first
|
|
113
113
|
for (const [i, v] of command.args.entries()) {
|
|
114
|
+
if (!command._args[i]) {
|
|
115
|
+
printMessage(`${command.args.length} arguments supplied but command only supports ${command._args.length}.`, 'warn');
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
114
118
|
const arg = command._args[i].name();
|
|
115
119
|
// handle only default arguments
|
|
116
120
|
if (Object.keys(stateMap).includes(arg)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrodoCommand.js","names":["Argument","Command","Option","globalConfig","state","fs","printMessage","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","verboseMessage","debugMessage","curlirizeMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","insecureOption","verboseOption","debugOption","curlirizeOption","defaultArgs","defaultOpts","stateMap","name","setHost","setRealm","setUsername","setPassword","attributeName","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","setDeploymentType","setAllowInsecureConnection","setVerbose","setDebug","setCurlirize","FrodoStubCommand","constructor","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","Object","keys","handler","k"],"sources":["cli/FrodoCommand.ts"],"sourcesContent":["import { Argument, Command, Option } from 'commander';\nimport * as globalConfig from '../storage/StaticStorage';\nimport { state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n verboseMessage,\n debugMessage,\n curlirizeMessage,\n} from '../utils/Console.js';\n\nconst hostArgument = new Argument(\n '[host]',\n 'Access Management base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.'\n);\n\nconst realmArgument = new Argument(\n '[realm]',\n \"Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise.\"\n).default(\n // must check for FRODO_REALM env variable here because otherwise cli will overwrite realm with default value\n process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY,\n '\"alpha\" for Identity Cloud tenants, \"/\" otherwise.'\n);\n\nconst usernameArgument = new Argument(\n '[username]',\n 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.'\n);\n\nconst passwordArgument = new Argument('[password]', 'Password.');\n\nconst serviceAccountIdOption = new Option(\n '--sa-id <sa-id>',\n 'Service account id.'\n);\n\nconst serviceAccountJwkFileOption = new Option(\n '--sa-jwk-file <file>',\n 'File containing the java web key (jwk) associated with the the service account.'\n);\n\nconst deploymentOption = new Option(\n '-m, --type <type>',\n 'Override auto-detected deployment type. Valid values for type: \\n\\\nclassic: A classic Access Management-only deployment with custom layout and configuration. \\n\\\ncloud: A ForgeRock Identity Cloud environment. \\n\\\nforgeops: A ForgeOps CDK or CDM deployment. \\n\\\nThe detected or provided deployment type controls certain behavior like obtaining an Identity \\\nManagement admin token or not and whether to export/import referenced email templates or how \\\nto walk through the tenant admin login flow of Identity Cloud and handle MFA'\n).choices(globalConfig.DEPLOYMENT_TYPES);\n\nconst insecureOption = new Option(\n '-k, --insecure',\n '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.'\n).default(false, \"Don't allow insecure connections\");\n\nconst verboseOption = new Option(\n '--verbose',\n 'Verbose output during command execution. If specified, may or may not produce additional output.'\n);\n\nconst debugOption = new Option(\n '--debug',\n 'Debug output during command execution. If specified, may or may not produce additional output helpful for troubleshooting.'\n);\n\nconst curlirizeOption = new Option(\n '--curlirize',\n 'Output all network calls in curl format.'\n);\n\nconst defaultArgs = [\n hostArgument,\n realmArgument,\n usernameArgument,\n passwordArgument,\n];\n\nconst defaultOpts = [\n serviceAccountIdOption,\n serviceAccountJwkFileOption,\n deploymentOption,\n insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: state.setHost,\n [realmArgument.name()]: state.setRealm,\n [usernameArgument.name()]: state.setUsername,\n [passwordArgument.name()]: state.setPassword,\n [serviceAccountIdOption.attributeName()]: state.setServiceAccountId,\n [serviceAccountJwkFileOption.attributeName()]: (file) => {\n try {\n const data = fs.readFileSync(file);\n const jwk = JSON.parse(data.toString());\n state.setServiceAccountJwk(jwk);\n } catch (error) {\n printMessage(\n `Error parsing JWK from file ${file}: ${error.message}`,\n 'error'\n );\n }\n },\n [deploymentOption.attributeName()]: state.setDeploymentType,\n [insecureOption.attributeName()]: state.setAllowInsecureConnection,\n [verboseOption.attributeName()]: state.setVerbose,\n [debugOption.attributeName()]: state.setDebug,\n [curlirizeOption.attributeName()]: state.setCurlirize,\n};\n\n/**\n * Command with default options\n */\nexport class FrodoStubCommand extends Command {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string) {\n super(name);\n\n // other default settings\n this.helpOption('-h, --help', 'Help');\n this.showHelpAfterError();\n this.configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n });\n\n // register default handlers\n state.setPrintHandler(printMessage);\n state.setVerboseHandler(verboseMessage);\n state.setDebugHandler(debugMessage);\n state.setCurlirizeHandler(curlirizeMessage);\n state.setCreateProgressHandler(createProgressIndicator);\n state.setUpdateProgressHandler(updateProgressIndicator);\n state.setStopProgressHandler(stopProgressIndicator);\n }\n}\n\n/**\n * Command with default options\n */\nexport class FrodoCommand extends FrodoStubCommand {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string, omits: string[] = []) {\n super(name);\n\n // register default arguments\n for (const arg of defaultArgs) {\n if (!omits.includes(arg.name())) this.addArgument(arg);\n }\n\n // register default options\n for (const opt of defaultOpts) {\n if (!omits.includes(opt.name())) this.addOption(opt);\n }\n }\n\n /**\n *\n * @param args\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleDefaultArgsAndOpts(...args: any) {\n const command = args.pop();\n const options = args.pop();\n\n // handle arguments first\n for (const [i, v] of command.args.entries()) {\n const arg = command._args[i].name();\n // handle only default arguments\n if (Object.keys(stateMap).includes(arg)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default argument '${arg}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[arg];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default argument '${arg}'.`\n );\n }\n }\n\n // handle options\n for (const [k, v] of Object.entries(options)) {\n // handle only default options\n if (Object.keys(stateMap).includes(k)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default option '${k}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[k];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default option '${k}'.`\n );\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,cAAc,EACdC,YAAY,EACZC,gBAAgB,QACX,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIb,QAAQ,CAC/B,QAAQ,EACR,iIAAiI,CAClI;AAED,MAAMc,aAAa,GAAG,IAAId,QAAQ,CAChC,SAAS,EACT,yFAAyF,CAC1F,CAACe,OAAO;AACP;AACAC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIf,YAAY,CAACgB,iBAAiB,EACzD,oDAAoD,CACrD;AAED,MAAMC,gBAAgB,GAAG,IAAIpB,QAA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I,EAAE;MACnC;MACA,IAAIoD,MAAM,CAACC,IAAI,CAACtD,QAAQ,CAAC,CAACwC,QAAQ,CAACD,GAAG,CAAC,EAAE;QACvC7D,YAAY,CACT,qEAAoE6D,GAAI,IAAG,CAC7E;QACD;QACA,MAAMgB,OAAY,GAAGvD,QAAQ,CAACuC,GAAG,CAAC;QAClCgB,OAAO,CAACL,CAAC,CAAC;MACZ,CAAC,MAAM;QACLxE,YAAY,CACT,yEAAwE6D,GAAI,IAAG,CACjF;MACH;IACF;;IAEA;IACA,KAAK,MAAM,CAACiB,CAAC,EAAEN,CAAC,CAAC,IAAIG,MAAM,CAACF,OAAO,CAACH,OAAO,CAAC,EAAE;MAC5C;MACA,IAAIK,MAAM,CAACC,IAAI,CAACtD,QAAQ,CAAC,CAACwC,QAAQ,CAACgB,CAAC,CAAC,EAAE;QACrC9E,YAAY,CACT,mEAAkE8E,CAAE,IAAG,CACzE;QACD;QACA,MAAMD,OAAY,GAAGvD,QAAQ,CAACwD,CAAC,CAAC;QAChCD,OAAO,CAACL,CAAC,CAAC;MACZ,CAAC,MAAM;QACLxE,YAAY,CACT,uEAAsE8E,CAAE,IAAG,CAC7E;MACH;IACF;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"FrodoCommand.js","names":["Argument","Command","Option","globalConfig","state","fs","printMessage","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","verboseMessage","debugMessage","curlirizeMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","insecureOption","verboseOption","debugOption","curlirizeOption","defaultArgs","defaultOpts","stateMap","name","setHost","setRealm","setUsername","setPassword","attributeName","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","setDeploymentType","setAllowInsecureConnection","setVerbose","setDebug","setCurlirize","FrodoStubCommand","constructor","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","length","Object","keys","handler","k"],"sources":["cli/FrodoCommand.ts"],"sourcesContent":["import { Argument, Command, Option } from 'commander';\nimport * as globalConfig from '../storage/StaticStorage';\nimport { state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n verboseMessage,\n debugMessage,\n curlirizeMessage,\n} from '../utils/Console.js';\n\nconst hostArgument = new Argument(\n '[host]',\n 'Access Management base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.'\n);\n\nconst realmArgument = new Argument(\n '[realm]',\n \"Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise.\"\n).default(\n // must check for FRODO_REALM env variable here because otherwise cli will overwrite realm with default value\n process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY,\n '\"alpha\" for Identity Cloud tenants, \"/\" otherwise.'\n);\n\nconst usernameArgument = new Argument(\n '[username]',\n 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.'\n);\n\nconst passwordArgument = new Argument('[password]', 'Password.');\n\nconst serviceAccountIdOption = new Option(\n '--sa-id <sa-id>',\n 'Service account id.'\n);\n\nconst serviceAccountJwkFileOption = new Option(\n '--sa-jwk-file <file>',\n 'File containing the JSON Web Key (JWK) associated with the the service account.'\n);\n\nconst deploymentOption = new Option(\n '-m, --type <type>',\n 'Override auto-detected deployment type. Valid values for type: \\n\\\nclassic: A classic Access Management-only deployment with custom layout and configuration. \\n\\\ncloud: A ForgeRock Identity Cloud environment. \\n\\\nforgeops: A ForgeOps CDK or CDM deployment. \\n\\\nThe detected or provided deployment type controls certain behavior like obtaining an Identity \\\nManagement admin token or not and whether to export/import referenced email templates or how \\\nto walk through the tenant admin login flow of Identity Cloud and handle MFA'\n).choices(globalConfig.DEPLOYMENT_TYPES);\n\nconst insecureOption = new Option(\n '-k, --insecure',\n '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.'\n).default(false, \"Don't allow insecure connections\");\n\nconst verboseOption = new Option(\n '--verbose',\n 'Verbose output during command execution. If specified, may or may not produce additional output.'\n);\n\nconst debugOption = new Option(\n '--debug',\n 'Debug output during command execution. If specified, may or may not produce additional output helpful for troubleshooting.'\n);\n\nconst curlirizeOption = new Option(\n '--curlirize',\n 'Output all network calls in curl format.'\n);\n\nconst defaultArgs = [\n hostArgument,\n realmArgument,\n usernameArgument,\n passwordArgument,\n];\n\nconst defaultOpts = [\n serviceAccountIdOption,\n serviceAccountJwkFileOption,\n deploymentOption,\n insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: state.setHost,\n [realmArgument.name()]: state.setRealm,\n [usernameArgument.name()]: state.setUsername,\n [passwordArgument.name()]: state.setPassword,\n [serviceAccountIdOption.attributeName()]: state.setServiceAccountId,\n [serviceAccountJwkFileOption.attributeName()]: (file) => {\n try {\n const data = fs.readFileSync(file);\n const jwk = JSON.parse(data.toString());\n state.setServiceAccountJwk(jwk);\n } catch (error) {\n printMessage(\n `Error parsing JWK from file ${file}: ${error.message}`,\n 'error'\n );\n }\n },\n [deploymentOption.attributeName()]: state.setDeploymentType,\n [insecureOption.attributeName()]: state.setAllowInsecureConnection,\n [verboseOption.attributeName()]: state.setVerbose,\n [debugOption.attributeName()]: state.setDebug,\n [curlirizeOption.attributeName()]: state.setCurlirize,\n};\n\n/**\n * Command with default options\n */\nexport class FrodoStubCommand extends Command {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string) {\n super(name);\n\n // other default settings\n this.helpOption('-h, --help', 'Help');\n this.showHelpAfterError();\n this.configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n });\n\n // register default handlers\n state.setPrintHandler(printMessage);\n state.setVerboseHandler(verboseMessage);\n state.setDebugHandler(debugMessage);\n state.setCurlirizeHandler(curlirizeMessage);\n state.setCreateProgressHandler(createProgressIndicator);\n state.setUpdateProgressHandler(updateProgressIndicator);\n state.setStopProgressHandler(stopProgressIndicator);\n }\n}\n\n/**\n * Command with default options\n */\nexport class FrodoCommand extends FrodoStubCommand {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string, omits: string[] = []) {\n super(name);\n\n // register default arguments\n for (const arg of defaultArgs) {\n if (!omits.includes(arg.name())) this.addArgument(arg);\n }\n\n // register default options\n for (const opt of defaultOpts) {\n if (!omits.includes(opt.name())) this.addOption(opt);\n }\n }\n\n /**\n *\n * @param args\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleDefaultArgsAndOpts(...args: any) {\n const command = args.pop();\n const options = args.pop();\n\n // handle arguments first\n for (const [i, v] of command.args.entries()) {\n if (!command._args[i]) {\n printMessage(\n `${command.args.length} arguments supplied but command only supports ${command._args.length}.`,\n 'warn'\n );\n break;\n }\n const arg = command._args[i].name();\n // handle only default arguments\n if (Object.keys(stateMap).includes(arg)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default argument '${arg}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[arg];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default argument '${arg}'.`\n );\n }\n }\n\n // handle options\n for (const [k, v] of Object.entries(options)) {\n // handle only default options\n if (Object.keys(stateMap).includes(k)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default option '${k}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[k];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default option '${k}'.`\n );\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,cAAc,EACdC,YAAY,EACZC,gBAAgB,QACX,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIb,QAAQ,CAC/B,QAAQ,EACR,iIAAiI,CAClI;AAED,MAAMc,aAAa,GAAG,IAAId,QAAQ,CAChC,SAAS,EACT,yFAAyF,CAC1F,CAACe,OAAO;AACP;AACAC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIf,YAAY,CAACgB,iBAAiB,EACzD,oDAAoD,CACrD;AAED,MAAMC,gBAAgB,GAAG,IAAIpB,QAAQ,CACnC,YAAY,EACZ,gHAAgH,CACjH;AAED,MAAMqB,gBAAgB,GAAG,IAAIrB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;AAEhE,MAAMsB,sBAAsB,GAAG,IAAIpB,MAAM,CACvC,iBAAiB,EACjB,qBAAqB,CACtB;AAED,MAAMqB,2BAA2B,GAAG,IAAIrB,MAAM,CAC5C,sBAAsB,EACtB,iFAAiF,CAClF;AAED,MAAMsB,gBAAgB,GAAG,IAAItB,MAAM,CACjC,mBAAmB,EACnB;AACF;AACA;AACA;AACA;AACA;AACA,6EAA6E,CAC5E,CAACuB,OAAO,CAACtB,YAAY,CAACuB,gBAAgB,CAAC;AAExC,MAAMC,cAAc,GAAG,IAAIzB,MAAM,CAC/B,gBAAgB,EAChB,4LAA4L,CAC7L,CAACa,OAAO,CAAC,KAAK,EAAE,kCAAkC,CAAC;AAEpD,MA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P,CAAC,CAAC,IAAII,MAAM,CAACH,OAAO,CAACH,OAAO,CAAC,EAAE;MAC5C;MACA,IAAIM,MAAM,CAACC,IAAI,CAACvD,QAAQ,CAAC,CAACwC,QAAQ,CAACiB,CAAC,CAAC,EAAE;QACrC/E,YAAY,CACT,mEAAkE+E,CAAE,IAAG,CACzE;QACD;QACA,MAAMD,OAAY,GAAGxD,QAAQ,CAACyD,CAAC,CAAC;QAChCD,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLxE,YAAY,CACT,uEAAsE+E,CAAE,IAAG,CAC7E;MACH;IACF;EACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rockcarver/frodo-cli",
|
|
3
|
-
"version": "0.20.1
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
|
|
6
6
|
"keywords": [
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
]
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@rockcarver/frodo-lib": "0.18.1
|
|
107
|
+
"@rockcarver/frodo-lib": "0.18.1",
|
|
108
108
|
"cli-progress": "^3.11.2",
|
|
109
109
|
"cli-table3": "^0.6.3",
|
|
110
110
|
"colors": "^1.4.0",
|