@rockcarver/frodo-cli 0.17.0 → 0.18.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.
- package/CHANGELOG.md +20 -1
- package/esm/app.js +0 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +3 -1
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/logging/logs-fetch.js +86 -0
- package/esm/cli/logging/logs-fetch.js.map +1 -0
- package/esm/cli/logging/logs.js +1 -0
- package/esm/cli/logging/logs.js.map +1 -1
- package/esm/utils/Config.js +1 -3
- package/esm/utils/Config.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.18.0] - 2022-10-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- \#85: Ability to fetch historical logs from ID Cloud
|
|
15
|
+
|
|
16
|
+
## [0.17.1] - 2022-10-17
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Updated frodo-lib to 0.15.2
|
|
21
|
+
- Added options to `frodo journey describe` command:
|
|
22
|
+
- Added `--verbose` option
|
|
23
|
+
- Added `--debug` option
|
|
24
|
+
|
|
10
25
|
## [0.17.0] - 2022-10-16
|
|
11
26
|
|
|
12
27
|
### Changed
|
|
@@ -683,7 +698,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
683
698
|
- Fixed problem with adding connection profiles
|
|
684
699
|
- Miscellaneous bug fixes
|
|
685
700
|
|
|
686
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.
|
|
701
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.18.0...HEAD
|
|
702
|
+
|
|
703
|
+
[0.18.0]: https://github.com/rockcarver/frodo-cli/compare/v0.17.1...v0.18.0
|
|
704
|
+
|
|
705
|
+
[0.17.1]: https://github.com/rockcarver/frodo-cli/compare/v0.17.0...v0.17.1
|
|
687
706
|
|
|
688
707
|
[0.17.0]: https://github.com/rockcarver/frodo-cli/compare/v0.16.2-1...v0.17.0
|
|
689
708
|
|
package/esm/app.js
CHANGED
package/esm/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","names":["ConnectionProfile","Command","admin","app","conn","email","esv","idm","idp","info","journey","logging","realm","saml","script","theme","printMessage","getVersions","initConnectionProfiles","program","version","addCommand","showHelpAfterError","enablePositionalOptions","parse","e"
|
|
1
|
+
{"version":3,"file":"app.js","names":["ConnectionProfile","Command","admin","app","conn","email","esv","idm","idp","info","journey","logging","realm","saml","script","theme","printMessage","getVersions","initConnectionProfiles","program","version","addCommand","showHelpAfterError","enablePositionalOptions","parse","e"],"sources":["app.ts"],"sourcesContent":["#!/usr/bin/env -S node --no-warnings --enable-source-maps --experimental-specifier-resolution=node\n\nimport { ConnectionProfile } from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\n\n// commands\nimport admin from './cli/admin/admin';\nimport app from './cli/app/app';\nimport conn from './cli/conn/conn';\nimport email from './cli/email/email';\nimport esv from './cli/esv/esv';\nimport idm from './cli/idm/idm';\nimport idp from './cli/idp/idp';\nimport info from './cli/info/info';\nimport journey from './cli/journey/journey';\nimport logging from './cli/logging/logs';\nimport realm from './cli/realm/realm';\nimport saml from './cli/saml/saml';\nimport script from './cli/script/script';\nimport theme from './cli/theme/theme';\nimport { printMessage } from './utils/Console';\nimport { getVersions } from './utils/Version';\n\nconst { initConnectionProfiles } = ConnectionProfile;\n\n(async () => {\n try {\n const program = new Command('frodo').version(\n await getVersions(false),\n '-v, --version'\n );\n\n printMessage(await getVersions(true), 'text', false);\n\n initConnectionProfiles();\n\n program.addCommand(admin());\n program.addCommand(app());\n program.addCommand(conn());\n program.addCommand(email());\n program.addCommand(esv());\n program.addCommand(idm());\n program.addCommand(idp());\n program.addCommand(info());\n program.addCommand(journey());\n program.addCommand(logging());\n program.addCommand(realm());\n program.addCommand(saml());\n program.addCommand(script());\n program.addCommand(theme());\n\n program.showHelpAfterError();\n program.enablePositionalOptions();\n program.parse();\n } catch (e) {\n printMessage(`ERROR: exception running frodo - ${e}`, 'error');\n }\n})();\n"],"mappings":"AAAA;AAEA,SAASA,iBAAT,QAAkC,uBAAlC;AACA,SAASC,OAAT,QAAwB,WAAxB,C,CAEA;;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,IAAP,MAAiB,iBAAjB;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,IAAP,MAAiB,iBAAjB;AACA,OAAOC,OAAP,MAAoB,uBAApB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AACA,OAAOC,IAAP,MAAiB,iBAAjB;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA,MAAM;EAAEC;AAAF,IAA6BlB,iBAAnC;;AAEA,CAAC,YAAY;EACX,IAAI;IACF,MAAMmB,OAAO,GAAG,IAAIlB,OAAJ,CAAY,OAAZ,EAAqBmB,OAArB,CACd,MAAMH,WAAW,CAAC,KAAD,CADH,EAEd,eAFc,CAAhB;IAKAD,YAAY,CAAC,MAAMC,WAAW,CAAC,IAAD,CAAlB,EAA0B,MAA1B,EAAkC,KAAlC,CAAZ;IAEAC,sBAAsB;IAEtBC,OAAO,CAACE,UAAR,CAAmBnB,KAAK,EAAxB;IACAiB,OAAO,CAACE,UAAR,CAAmBlB,GAAG,EAAtB;IACAgB,OAAO,CAACE,UAAR,CAAmBjB,IAAI,EAAvB;IACAe,OAAO,CAACE,UAAR,CAAmBhB,KAAK,EAAxB;IACAc,OAAO,CAACE,UAAR,CAAmBf,GAAG,EAAtB;IACAa,OAAO,CAACE,UAAR,CAAmBd,GAAG,EAAtB;IACAY,OAAO,CAACE,UAAR,CAAmBb,GAAG,EAAtB;IACAW,OAAO,CAACE,UAAR,CAAmBZ,IAAI,EAAvB;IACAU,OAAO,CAACE,UAAR,CAAmBX,OAAO,EAA1B;IACAS,OAAO,CAACE,UAAR,CAAmBV,OAAO,EAA1B;IACAQ,OAAO,CAACE,UAAR,CAAmBT,KAAK,EAAxB;IACAO,OAAO,CAACE,UAAR,CAAmBR,IAAI,EAAvB;IACAM,OAAO,CAACE,UAAR,CAAmBP,MAAM,EAAzB;IACAK,OAAO,CAACE,UAAR,CAAmBN,KAAK,EAAxB;IAEAI,OAAO,CAACG,kBAAR;IACAH,OAAO,CAACI,uBAAR;IACAJ,OAAO,CAACK,KAAR;EACD,CA5BD,CA4BE,OAAOC,CAAP,EAAU;IACVT,YAAY,CAAE,oCAAmCS,CAAE,EAAvC,EAA0C,OAA1C,CAAZ;EACD;AACF,CAhCD"}
|
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
saveTextToFile
|
|
17
17
|
} = ExportImportUtils;
|
|
18
18
|
const program = new Command('frodo journey describe');
|
|
19
|
-
program.description('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.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgument).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(new Option('-i, --journey-id <journey>', 'Name of a journey/tree. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the journey export file to describe. Ignored with -A.')).addOption(new Option('-F, --output-file <file>', 'Name of the file to write the output to.')).addOption(new Option('--markdown', 'Output in markdown.')).addOption(new Option('-o, --override-version <version>', "Override version. Notation: '<major>.<minor>.<patch>' e.g. '7.2.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.")).action( // implement command logic inside action handler
|
|
19
|
+
program.description('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.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgument).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(new Option('-i, --journey-id <journey>', 'Name of a journey/tree. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the journey export file to describe. Ignored with -A.')).addOption(new Option('-F, --output-file <file>', 'Name of the file to write the output to.')).addOption(new Option('--markdown', 'Output in markdown.')).addOption(new Option('-o, --override-version <version>', "Override version. Notation: '<major>.<minor>.<patch>' e.g. '7.2.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.")).action( // implement command logic inside action handler
|
|
20
20
|
async (host, realm, user, password, options) => {
|
|
21
21
|
state.default.session.setTenant(host);
|
|
22
22
|
state.default.session.setRealm(realm);
|
|
@@ -24,6 +24,8 @@ async (host, realm, user, password, options) => {
|
|
|
24
24
|
state.default.session.setPassword(password);
|
|
25
25
|
state.default.session.setDeploymentType(options.type);
|
|
26
26
|
state.default.session.setAllowInsecureConnection(options.insecure);
|
|
27
|
+
state.default.session.setVerbose(options.verbose);
|
|
28
|
+
state.default.session.setDebug(options.debug);
|
|
27
29
|
if (options.outputFile) state.default.session.setOutputFile(options.outputFile); // TODO: review checks for arguments
|
|
28
30
|
|
|
29
31
|
if (typeof host === 'undefined' || typeof options.file !== 'undefined') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journey-describe.js","names":["fs","Command","Option","Authenticate","ExportImportUtils","Journey","state","describeJourney","describeJourneyMd","common","printMessage","getTokens","getJourneys","exportJourney","createFileParamTreeExportResolver","saveTextToFile","program","description","helpOption","showHelpAfterError","addArgument","hostArgument","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","outputFile","setOutputFile","file","process","exitCode","overrideVersion","setAmVersion","fileData","JSON","parse","readFileSync","journeyData","journeyId","trees","Object","values","tree","_id","Error","markdown","error","message","getRealm","journeys","journey","treeData"],"sources":["cli/journey/journey-describe.ts"],"sourcesContent":["import fs from 'fs';\nimport { Command, Option } from 'commander';\nimport {\n Authenticate,\n ExportImportUtils,\n Journey,\n state,\n} from '@rockcarver/frodo-lib';\nimport { describeJourney, describeJourneyMd } from '../../ops/JourneyOps';\nimport * as common from '../cmd_common.js';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { getJourneys, exportJourney, createFileParamTreeExportResolver } =\n Journey;\nconst { saveTextToFile } = ExportImportUtils;\n\nconst program = new Command('frodo journey describe');\n\nprogram\n .description(\n '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.'\n )\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgument)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(\n new Option(\n '-i, --journey-id <journey>',\n 'Name of a journey/tree. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the journey export file to describe. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-F, --output-file <file>',\n 'Name of the file to write the output to.'\n )\n )\n .addOption(new Option('--markdown', 'Output in markdown.'))\n .addOption(\n new Option(\n '-o, --override-version <version>',\n \"Override version. Notation: '<major>.<minor>.<patch>' e.g. '7.2.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.\"\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n if (options.outputFile)\n state.default.session.setOutputFile(options.outputFile);\n // TODO: review checks for arguments\n if (typeof host === 'undefined' || typeof options.file !== 'undefined') {\n if (\n typeof host === 'undefined' &&\n typeof options.file === 'undefined'\n ) {\n printMessage('Need either [host] or -f.', 'error');\n process.exitCode = 1;\n return;\n }\n printMessage(`Describing local journey file ${options.file}...`);\n try {\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.default.session.setAmVersion(options.overrideVersion);\n }\n const fileData = JSON.parse(fs.readFileSync(options.file, 'utf8'));\n let journeyData;\n // single or multi tree export?\n // multi - by id\n if (\n typeof options.journeyId !== 'undefined' &&\n fileData.trees &&\n fileData.trees[options.journeyId]\n ) {\n journeyData = fileData.trees[options.journeyId];\n }\n // multi - first\n else if (typeof options.journeyId === 'undefined' && fileData.trees) {\n [journeyData] = Object.values(fileData.trees);\n }\n // single - by id\n else if (\n typeof options.journeyId !== 'undefined' &&\n options.journeyId === fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // single\n else if (\n typeof options.journeyId === 'undefined' &&\n fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // no journey/tree found\n else {\n throw new Error(\n typeof options.journeyId === 'undefined'\n ? `No journey found in ${options.file}`\n : `Journey '${options.journeyId}' not found in ${options.file}`\n );\n }\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n } else if (await getTokens()) {\n printMessage(\n `Describing journey(s) in realm \"${state.default.session.getRealm()}\"...`\n );\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.default.session.setAmVersion(options.overrideVersion);\n }\n if (typeof options.journeyId === 'undefined') {\n let journeys: any[] = [];\n journeys = await getJourneys();\n for (const journey of journeys) {\n try {\n // eslint-disable-next-line no-await-in-loop, dot-notation\n const treeData = await exportJourney(journey['_id']);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n } else {\n try {\n const treeData = await exportJourney(options.journeyId);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,OAAOA,EAAP,MAAe,IAAf;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,SACEC,YADF,EAEEC,iBAFF,EAGEC,OAHF,EAIEC,KAJF,QAKO,uBALP;AAMA,SAASC,eAAT,EAA0BC,iBAA1B,QAAmD,sBAAnD;AACA,OAAO,KAAKC,MAAZ,MAAwB,kBAAxB;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBR,YAAtB;AACA,MAAM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QAAD,CAArB;QACD,CAFD,CAGA;QAHA,KAIK;UACH;UACA,IAAIpC,OAAO,CAACW,UAAZ,EAAwB7B,cAAc,CAAC,EAAD,EAAKkB,OAAO,CAACW,UAAb,CAAd;UACxB,MAAMpC,iBAAiB,CAAC6D,QAAD,CAAvB;QACD;MACF,CAZD,CAYE,OAAOL,KAAP,EAAc;QACdtD,YAAY,CAACsD,KAAK,CAACC,OAAP,EAAgB,OAAhB,CAAZ;QACAlB,OAAO,CAACC,QAAR,GAAmB,CAAnB;MACD;IACF;EACF;AACF,CA1KL,CA2KI;AA3KJ;AA8KAhC,OAAO,CAACqC,KAAR"}
|
|
1
|
+
{"version":3,"file":"journey-describe.js","names":["fs","Command","Option","Authenticate","ExportImportUtils","Journey","state","describeJourney","describeJourneyMd","common","printMessage","getTokens","getJourneys","exportJourney","createFileParamTreeExportResolver","saveTextToFile","program","description","helpOption","showHelpAfterError","addArgument","hostArgument","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","outputFile","setOutputFile","file","process","exitCode","overrideVersion","setAmVersion","fileData","JSON","parse","readFileSync","journeyData","journeyId","trees","Object","values","tree","_id","Error","markdown","error","message","getRealm","journeys","journey","treeData"],"sources":["cli/journey/journey-describe.ts"],"sourcesContent":["import fs from 'fs';\nimport { Command, Option } from 'commander';\nimport {\n Authenticate,\n ExportImportUtils,\n Journey,\n state,\n} from '@rockcarver/frodo-lib';\nimport { describeJourney, describeJourneyMd } from '../../ops/JourneyOps';\nimport * as common from '../cmd_common.js';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { getJourneys, exportJourney, createFileParamTreeExportResolver } =\n Journey;\nconst { saveTextToFile } = ExportImportUtils;\n\nconst program = new Command('frodo journey describe');\n\nprogram\n .description(\n '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.'\n )\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgument)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(\n new Option(\n '-i, --journey-id <journey>',\n 'Name of a journey/tree. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the journey export file to describe. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-F, --output-file <file>',\n 'Name of the file to write the output to.'\n )\n )\n .addOption(new Option('--markdown', 'Output in markdown.'))\n .addOption(\n new Option(\n '-o, --override-version <version>',\n \"Override version. Notation: '<major>.<minor>.<patch>' e.g. '7.2.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.\"\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n if (options.outputFile)\n state.default.session.setOutputFile(options.outputFile);\n // TODO: review checks for arguments\n if (typeof host === 'undefined' || typeof options.file !== 'undefined') {\n if (\n typeof host === 'undefined' &&\n typeof options.file === 'undefined'\n ) {\n printMessage('Need either [host] or -f.', 'error');\n process.exitCode = 1;\n return;\n }\n printMessage(`Describing local journey file ${options.file}...`);\n try {\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.default.session.setAmVersion(options.overrideVersion);\n }\n const fileData = JSON.parse(fs.readFileSync(options.file, 'utf8'));\n let journeyData;\n // single or multi tree export?\n // multi - by id\n if (\n typeof options.journeyId !== 'undefined' &&\n fileData.trees &&\n fileData.trees[options.journeyId]\n ) {\n journeyData = fileData.trees[options.journeyId];\n }\n // multi - first\n else if (typeof options.journeyId === 'undefined' && fileData.trees) {\n [journeyData] = Object.values(fileData.trees);\n }\n // single - by id\n else if (\n typeof options.journeyId !== 'undefined' &&\n options.journeyId === fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // single\n else if (\n typeof options.journeyId === 'undefined' &&\n fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // no journey/tree found\n else {\n throw new Error(\n typeof options.journeyId === 'undefined'\n ? `No journey found in ${options.file}`\n : `Journey '${options.journeyId}' not found in ${options.file}`\n );\n }\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n } else if (await getTokens()) {\n printMessage(\n `Describing journey(s) in realm \"${state.default.session.getRealm()}\"...`\n );\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.default.session.setAmVersion(options.overrideVersion);\n }\n if (typeof options.journeyId === 'undefined') {\n let journeys: any[] = [];\n journeys = await getJourneys();\n for (const journey of journeys) {\n try {\n // eslint-disable-next-line no-await-in-loop, dot-notation\n const treeData = await exportJourney(journey['_id']);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n } else {\n try {\n const treeData = await exportJourney(options.journeyId);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,OAAOA,EAAP,MAAe,IAAf;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,SACEC,YADF,EAEEC,iBAFF,EAGEC,OAHF,EAIEC,KAJF,QAKO,uBALP;AAMA,SAASC,eAAT,EAA0BC,iBAA1B,QAAmD,sBAAnD;AACA,OAAO,KAAKC,MAAZ,MAAwB,kBAAxB;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBR,YAAtB;AACA,MAAM;EAAES,WAAF;EAAeC,aAAf;EAA8BC;AAA9B,IACJT,OADF;AAEA,MAAM;EAAEU;AAAF,IAAqBX,iBAA3B;AAEA,MAAMY,OAAO,GAAG,IAAIf,OAAJ,CAAY,wBAAZ,CAAhB;AAEAe,OAAO,CACJC,WADH,CAEI,yLAFJ,EAIGC,UAJH,CAIc,YAJd,EAI4B,MAJ5B,EAKGC,kBALH,GAMGC,WANH,CAMeX,MAAM,CAACY,YANtB,EAOGD,WAPH,CAOeX,MAAM,CAACa,aAPtB,EAQGF,WARH,CAQeX,MAAM,CAACc,YARtB,EASGH,WATH,CASeX,MAAM,CAACe,gBATtB,EAUGC,SAVH,CAUahB,MAAM,CAACiB,gBAVpB,EAWGD,SAXH,CAWahB,MAAM,CAACkB,cAXpB,EAYGF,SAZH,CAYahB,MAAM,CAACmB,aAZpB,EAaGH,SAbH,CAaahB,MAAM,CAACoB,WAbpB,EAcGJ,SAdH,CAeI,IAAIvB,MAAJ,CACE,4BADF,EAEE,8DAFF,CAfJ,EAoBGuB,SApBH,CAqBI,IAAIvB,MAAJ,CACE,mBADF,EAEE,+DAFF,CArBJ,EA0BGuB,SA1BH,CA2BI,IAAIvB,MAAJ,CACE,0BADF,EAEE,0CAFF,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, Log, state } from '@rockcarver/frodo-lib';
|
|
3
|
+
import * as common from '../cmd_common.js';
|
|
4
|
+
import * as config from '../../utils/Config.js';
|
|
5
|
+
import { printMessage } from '../../utils/Console.js';
|
|
6
|
+
const {
|
|
7
|
+
provisionCreds,
|
|
8
|
+
fetchLogs,
|
|
9
|
+
resolveLevel
|
|
10
|
+
} = Log;
|
|
11
|
+
const {
|
|
12
|
+
getConnectionProfile,
|
|
13
|
+
saveConnectionProfile
|
|
14
|
+
} = ConnectionProfile;
|
|
15
|
+
const {
|
|
16
|
+
getTokens
|
|
17
|
+
} = Authenticate;
|
|
18
|
+
const SECONDS_IN_30_DAYS = 2592000;
|
|
19
|
+
const SECONDS_IN_1_HOUR = 3600;
|
|
20
|
+
const LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;
|
|
21
|
+
const LOG_TIME_WINDOW_INCREMENT = SECONDS_IN_1_HOUR;
|
|
22
|
+
const program = new Command('frodo logs fetch');
|
|
23
|
+
program.description('Fetch Identity Cloud logs between a specified begin and end time period.\
|
|
24
|
+
WARNING: depending on filters and time period specified, this could take substantial time to complete.').helpOption('-h, --help', 'Help').addArgument(common.hostArgumentM).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.insecureOption).addOption(common.sourcesOptionM).addOption(new Option('-l, --level <level>', 'Set log level filter. You can specify the level as a number or a string. \
|
|
25
|
+
Following values are possible (values on the same line are equivalent): \
|
|
26
|
+
\n0, SEVERE, FATAL, or ERROR\n1, WARNING, WARN or CONFIG\
|
|
27
|
+
\n2, INFO or INFORMATION\n3, DEBUG, FINE, FINER or FINEST\
|
|
28
|
+
\n4 or ALL').default('ERROR', `${resolveLevel('ERROR')}`)).addOption(new Option('-t, --transaction-id <txid>', 'Filter by transactionId')).addOption(new Option('-b, --begin-timestamp <beginTs>', 'Begin timestamp for period (in ISO8601, example: "2022-10-13T19:06:28Z", or "2022-09.30". \
|
|
29
|
+
Cannot be more than 30 days in the past.')).addOption(new Option('-e, --end-timestamp <endTs>', 'End timestamp for period')).addOption(new Option('-s, --search-string <ss>', 'Filter by a specific string (ANDed with transactionID filter)')).addOption(new Option('-d, --defaults', 'Use default logging noise filters').default(false, `Use custom logging noise filters defined in ${config.getConfigPath()}/${config.FRODO_LOG_NOISEFILTER_FILENAME}`)).action(async (host, user, password, options, command) => {
|
|
30
|
+
let credsFromParameters = true;
|
|
31
|
+
state.default.session.setTenant(host);
|
|
32
|
+
state.default.session.setUsername(user);
|
|
33
|
+
state.default.session.setPassword(password);
|
|
34
|
+
state.default.session.setAllowInsecureConnection(options.insecure);
|
|
35
|
+
const conn = await getConnectionProfile();
|
|
36
|
+
state.default.session.setTenant(conn.tenant);
|
|
37
|
+
|
|
38
|
+
if (conn.key != null && conn.secret != null) {
|
|
39
|
+
credsFromParameters = false;
|
|
40
|
+
state.default.session.setLogApiKey(conn.key);
|
|
41
|
+
state.default.session.setLogApiSecret(conn.secret);
|
|
42
|
+
} else {
|
|
43
|
+
if (conn.username == null && conn.password == null) {
|
|
44
|
+
if (!state.default.session.getUsername() && !state.default.session.getPassword()) {
|
|
45
|
+
credsFromParameters = false;
|
|
46
|
+
console.log('User credentials not specified as parameters and no saved API key and secret found!', 'warn');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
state.default.session.setUsername(conn.username);
|
|
51
|
+
state.default.session.setPassword(conn.password);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (await getTokens()) {
|
|
55
|
+
const creds = await provisionCreds();
|
|
56
|
+
state.default.session.setLogApiKey(creds.api_key_id);
|
|
57
|
+
state.default.session.setLogApiSecret(creds.api_key_secret);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let beginTs = Date.parse(options.beginTimestamp) / 1000;
|
|
62
|
+
|
|
63
|
+
if (Date.parse(options.endTimestamp) / 1000 < beginTs) {
|
|
64
|
+
printMessage('End timestamp can not be before begin timestamp', 'error');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const now = Date.now() / 1000;
|
|
69
|
+
|
|
70
|
+
if (now - beginTs > LOG_TIME_WINDOW_MAX) {
|
|
71
|
+
printMessage('Begin timestamp can not be more than 30 days in the past', 'error');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let intermediateEndTs = 0;
|
|
76
|
+
console.log(`Fetching ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}]...`);
|
|
77
|
+
if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI
|
|
78
|
+
|
|
79
|
+
do {
|
|
80
|
+
intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;
|
|
81
|
+
await fetchLogs(command.opts().sources, new Date(beginTs * 1000).toISOString(), new Date(intermediateEndTs * 1000).toISOString(), resolveLevel(command.opts().level), command.opts().transactionId, command.opts().searchString, null, config.getNoiseFilters(options.defaults));
|
|
82
|
+
beginTs = intermediateEndTs;
|
|
83
|
+
} while (intermediateEndTs < Date.parse(options.endTimestamp) / 1000);
|
|
84
|
+
});
|
|
85
|
+
program.parse();
|
|
86
|
+
//# sourceMappingURL=logs-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs-fetch.js","names":["Command","Option","Authenticate","ConnectionProfile","Log","state","common","config","printMessage","provisionCreds","fetchLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","helpOption","addArgument","hostArgumentM","userArgument","passwordArgument","addOption","insecureOption","sourcesOptionM","default","getConfigPath","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","credsFromParameters","session","setTenant","setUsername","setPassword","setAllowInsecureConnection","insecure","conn","tenant","key","secret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","console","log","creds","api_key_id","api_key_secret","beginTs","Date","parse","beginTimestamp","endTimestamp","now","intermediateEndTs","opts","sources","level","toISOString","transactionId","searchString","getNoiseFilters","defaults"],"sources":["cli/logging/logs-fetch.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common.js';\nimport * as config from '../../utils/Config.js';\nimport { printMessage } from '../../utils/Console.js';\n\nconst { provisionCreds, fetchLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst SECONDS_IN_30_DAYS = 2592000;\nconst SECONDS_IN_1_HOUR = 3600;\nconst LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;\nconst LOG_TIME_WINDOW_INCREMENT = SECONDS_IN_1_HOUR;\n\nconst program = new Command('frodo logs fetch');\nprogram\n .description(\n 'Fetch Identity Cloud logs between a specified begin and end time period.\\\n WARNING: depending on filters and time period specified, this could take substantial time to complete.'\n )\n .helpOption('-h, --help', 'Help')\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.insecureOption)\n .addOption(common.sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option(\n '-b, --begin-timestamp <beginTs>',\n 'Begin timestamp for period (in ISO8601, example: \"2022-10-13T19:06:28Z\", or \"2022-09.30\". \\\nCannot be more than 30 days in the past.'\n )\n )\n .addOption(\n new Option('-e, --end-timestamp <endTs>', 'End timestamp for period')\n )\n .addOption(\n new Option(\n '-s, --search-string <ss>',\n 'Filter by a specific string (ANDed with transactionID filter)'\n )\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in ${config.getConfigPath()}/${\n config.FRODO_LOG_NOISEFILTER_FILENAME\n }`\n )\n )\n .action(async (host, user, password, options, command) => {\n let credsFromParameters = true;\n state.default.session.setTenant(host);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setAllowInsecureConnection(options.insecure);\n const conn = await getConnectionProfile();\n state.default.session.setTenant(conn.tenant);\n if (conn.key != null && conn.secret != null) {\n credsFromParameters = false;\n state.default.session.setLogApiKey(conn.key);\n state.default.session.setLogApiSecret(conn.secret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (\n !state.default.session.getUsername() &&\n !state.default.session.getPassword()\n ) {\n credsFromParameters = false;\n console.log(\n 'User credentials not specified as parameters and no saved API key and secret found!',\n 'warn'\n );\n return;\n }\n } else {\n state.default.session.setUsername(conn.username);\n state.default.session.setPassword(conn.password);\n }\n if (await getTokens()) {\n const creds = await provisionCreds();\n state.default.session.setLogApiKey(creds.api_key_id);\n state.default.session.setLogApiSecret(creds.api_key_secret);\n }\n }\n let beginTs = Date.parse(options.beginTimestamp) / 1000;\n if((Date.parse(options.endTimestamp) / 1000) < beginTs) {\n printMessage(\n 'End timestamp can not be before begin timestamp',\n 'error'\n );\n return; \n }\n const now = Date.now() / 1000;\n if (now - beginTs > LOG_TIME_WINDOW_MAX) {\n printMessage(\n 'Begin timestamp can not be more than 30 days in the past',\n 'error'\n );\n return;\n }\n let intermediateEndTs = 0;\n console.log(\n `Fetching ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}]...`\n );\n if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI\n\n do {\n intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n command.opts().searchString,\n null,\n config.getNoiseFilters(options.defaults)\n );\n beginTs = intermediateEndTs;\n } while (intermediateEndTs < Date.parse(options.endTimestamp) / 1000);\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,SACEC,YADF,EAEEC,iBAFF,EAGEC,GAHF,EAIEC,KAJF,QAKO,uBALP;AAMA,OAAO,KAAKC,MAAZ,MAAwB,kBAAxB;AACA,OAAO,KAAKC,MAAZ,MAAwB,uBAAxB;AACA,SAASC,YAAT,QAA6B,wBAA7B;AAEA,MAAM;EAAEC,cAAF;EAAkBC,SAAlB;EAA6BC;AAA7B,IAA8CP,GAApD;AACA,MAAM;EAAEQ,oBAAF;EAAwBC;AAAxB,IAAkDV,iBAAxD;AACA,MAAM;EAAEW;AAAF,IAAgBZ,YAAtB;AAEA,MAAMa,kBAAkB,GAAG,OAA3B;AACA,MAAMC,iBAAiB,GAAG,IAA1B;AACA,MAAMC,mBAAmB,GAAGF,kBAA5B;AACA,MAAMG,yBAAyB,GAAGF,iBAAlC;AAEA,MAAMG,OAAO,GAAG,IAAInB,OAAJ,CAAY,kBAAZ,CAAhB;AACAmB,OAAO,CACJC,WADH,CAEI;AACJ,wGAHA,EAKGC,UALH,CAKc,YALd,EAK4B,MAL5B,EAMGC,WANH,CAMehB,MAAM,CAACiB,aANtB,EAOGD,WAPH,CAOehB,MAAM,CAACkB,YAPtB,EAQGF,WARH,CAQehB,MAAM,CAACmB,gBARtB,EASGC,SATH,CASapB,MAAM,CAACqB,cATpB,EAUGD,SAVH,CAUapB,MAAM,CAACsB,cAVpB,EAWGF,SAXH,CAYI,IAAIzB,MAAJ,CACE,qBADF,EAEE;AACN;AACA;AACA;AACA,WANI,EAOE4B,OAPF,CAOU,OAPV,EAOoB,GAAElB,YAAY,CAAC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A,IAAIA,GAAG,GAAGL,OAAN,GAAgB1C,mBAApB,EAAyC;IACvCT,YAAY,CACV,0DADU,EAEV,OAFU,CAAZ;IAIA;EACD;;EACD,IAAIyD,iBAAiB,GAAG,CAAxB;EACAX,OAAO,CAACC,GAAR,CACG,sDACClB,OAAO,CAAC6B,IAAR,GAAeC,OAChB,gBAAexD,YAAY,CAAC0B,OAAO,CAAC6B,IAAR,GAAeE,KAAhB,CAAuB,MAHrD;EAKA,IAAI9B,mBAAJ,EAAyB,MAAMzB,qBAAqB,EAA3B,CAzD+B,CAyDA;;EAExD,GAAG;IACDoD,iBAAiB,GAAGN,OAAO,GAAGzC,yBAA9B;IACA,MAAMR,SAAS,CACb2B,OAAO,CAAC6B,IAAR,GAAeC,OADF,EAEb,IAAIP,IAAJ,CAASD,OAAO,GAAG,IAAnB,EAAyBU,WAAzB,EAFa,EAGb,IAAIT,IAAJ,CAASK,iBAAiB,GAAG,IAA7B,EAAmCI,WAAnC,EAHa,EAIb1D,YAAY,CAAC0B,OAAO,CAAC6B,IAAR,GAAeE,KAAhB,CAJC,EAKb/B,OAAO,CAAC6B,IAAR,GAAeI,aALF,EAMbjC,OAAO,CAAC6B,IAAR,GAAeK,YANF,EAOb,IAPa,EAQbhE,MAAM,CAACiE,eAAP,CAAuBpC,OAAO,CAACqC,QAA/B,CARa,CAAf;IAUAd,OAAO,GAAGM,iBAAV;EACD,CAbD,QAaSA,iBAAiB,GAAGL,IAAI,CAACC,KAAL,CAAWzB,OAAO,CAAC2B,YAAnB,IAAmC,IAbhE;AAcD,CAzHH;AA2HA5C,OAAO,CAAC0C,KAAR"}
|
package/esm/cli/logging/logs.js
CHANGED
|
@@ -8,6 +8,7 @@ export default function setup() {
|
|
|
8
8
|
const program = new Command('logs').summary('List/View Identity Cloud logs').description(`View Identity Cloud logs. If valid tenant admin credentials are specified, a log API key and secret are automatically created for that admin user.`).helpOption('-h, --help', 'Help').executableDir(__dirname);
|
|
9
9
|
program.command('list', 'List available ID Cloud log sources.').showHelpAfterError();
|
|
10
10
|
program.command('tail', 'Tail Identity Cloud logs.').showHelpAfterError();
|
|
11
|
+
program.command('fetch', 'Fetch Identity Cloud logs for a given time period.').showHelpAfterError();
|
|
11
12
|
return program;
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=logs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","names":["Command","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","summary","description","helpOption","executableDir","command","showHelpAfterError"],"sources":["cli/logging/logs.ts"],"sourcesContent":["import { Command } from 'commander';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new Command('logs')\n .summary('List/View Identity Cloud logs')\n .description(\n `View Identity Cloud logs. If valid tenant admin credentials are specified, a log API key and secret are automatically created for that admin user.`\n )\n .helpOption('-h, --help', 'Help')\n .executableDir(__dirname);\n\n program\n .command('list', 'List available ID Cloud log sources.')\n .showHelpAfterError();\n program.command('tail', 'Tail Identity Cloud logs.').showHelpAfterError();\n return program;\n}\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,WAAxB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,aAAT,QAA8B,KAA9B;;AAEA,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAL,CAAaF,aAAa,CAACG,MAAM,CAACC,IAAP,CAAYC,GAAb,CAA1B,CAAlB;;AAEA,eAAe,SAASC,KAAT,GAAiB;EAC9B,MAAMC,OAAO,GAAG,IAAIT,OAAJ,CAAY,MAAZ,EACbU,OADa,CACL,+BADK,EAEbC,WAFa,CAGX,oJAHW,EAKbC,UALa,CAKF,YALE,EAKY,MALZ,EAMbC,aANa,CAMCV,SAND,CAAhB;EAQAM,OAAO,CACJK,OADH,CACW,MADX,EACmB,sCADnB,EAEGC,kBAFH;EAGAN,OAAO,CAACK,OAAR,CAAgB,MAAhB,EAAwB,2BAAxB,EAAqDC,kBAArD;EACA,OAAON,OAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"logs.js","names":["Command","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","summary","description","helpOption","executableDir","command","showHelpAfterError"],"sources":["cli/logging/logs.ts"],"sourcesContent":["import { Command } from 'commander';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new Command('logs')\n .summary('List/View Identity Cloud logs')\n .description(\n `View Identity Cloud logs. If valid tenant admin credentials are specified, a log API key and secret are automatically created for that admin user.`\n )\n .helpOption('-h, --help', 'Help')\n .executableDir(__dirname);\n\n program\n .command('list', 'List available ID Cloud log sources.')\n .showHelpAfterError();\n program.command('tail', 'Tail Identity Cloud logs.').showHelpAfterError();\n program.command('fetch', 'Fetch Identity Cloud logs for a given time period.').showHelpAfterError();\n return program;\n}\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,WAAxB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,aAAT,QAA8B,KAA9B;;AAEA,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAL,CAAaF,aAAa,CAACG,MAAM,CAACC,IAAP,CAAYC,GAAb,CAA1B,CAAlB;;AAEA,eAAe,SAASC,KAAT,GAAiB;EAC9B,MAAMC,OAAO,GAAG,IAAIT,OAAJ,CAAY,MAAZ,EACbU,OADa,CACL,+BADK,EAEbC,WAFa,CAGX,oJAHW,EAKbC,UALa,CAKF,YALE,EAKY,MALZ,EAMbC,aANa,CAMCV,SAND,CAAhB;EAQAM,OAAO,CACJK,OADH,CACW,MADX,EACmB,sCADnB,EAEGC,kBAFH;EAGAN,OAAO,CAACK,OAAR,CAAgB,MAAhB,EAAwB,2BAAxB,EAAqDC,kBAArD;EACAN,OAAO,CAACK,OAAR,CAAgB,OAAhB,EAAyB,oDAAzB,EAA+EC,kBAA/E;EACA,OAAON,OAAP;AACD"}
|
package/esm/utils/Config.js
CHANGED
|
@@ -35,9 +35,7 @@ export function getNoiseFilters(defaults) {
|
|
|
35
35
|
|
|
36
36
|
let noiseFilter = getCustomNoiseFilters();
|
|
37
37
|
|
|
38
|
-
if (noiseFilter.length
|
|
39
|
-
printMessage(`Using custom noise filters from ${filename}`, 'info');
|
|
40
|
-
} else {
|
|
38
|
+
if (noiseFilter.length == 0) {
|
|
41
39
|
printMessage(`No custom noise filters defined. Using defaults.`, 'info');
|
|
42
40
|
noiseFilter = defaultNoiseFilter();
|
|
43
41
|
|
package/esm/utils/Config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.js","names":["fs","os","Log","printMessage","defaultNoiseFilter","FRODO_CONFIG_PATH_KEY","FRODO_LOG_NOISEFILTER_FILENAME","getConfigPath","process","env","homedir","getCustomNoiseFilters","filename","noiseFilter","data","readFileSync","JSON","parse","e","message","getNoiseFilters","defaults","length","writeFileSync","stringify"],"sources":["utils/Config.ts"],"sourcesContent":["import fs from 'fs';\nimport os from 'os';\nimport { Log } from '@rockcarver/frodo-lib';\n\nimport { printMessage } from './Console';\n\nconst { defaultNoiseFilter } = Log;\n\nexport const FRODO_CONFIG_PATH_KEY = 'FRODO_CONFIG_PATH';\nexport const FRODO_LOG_NOISEFILTER_FILENAME = 'LoggingNoiseFilter.json';\n\nexport function getConfigPath(): string {\n return process.env[FRODO_CONFIG_PATH_KEY] || `${os.homedir()}/.frodo`;\n}\n\nfunction getCustomNoiseFilters(): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n let noiseFilter = [];\n try {\n const data = fs.readFileSync(filename, 'utf8');\n noiseFilter = JSON.parse(data);\n } catch (e) {\n printMessage(`Error reading ${filename} (${e.message})`, 'error');\n }\n return noiseFilter;\n}\n\nexport function getNoiseFilters(defaults: boolean): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n if(defaults) {\n printMessage(`Using default logging noise filters.`, 'info');\n return defaultNoiseFilter();\n }\n let noiseFilter = getCustomNoiseFilters();\n if (noiseFilter.length
|
|
1
|
+
{"version":3,"file":"Config.js","names":["fs","os","Log","printMessage","defaultNoiseFilter","FRODO_CONFIG_PATH_KEY","FRODO_LOG_NOISEFILTER_FILENAME","getConfigPath","process","env","homedir","getCustomNoiseFilters","filename","noiseFilter","data","readFileSync","JSON","parse","e","message","getNoiseFilters","defaults","length","writeFileSync","stringify"],"sources":["utils/Config.ts"],"sourcesContent":["import fs from 'fs';\nimport os from 'os';\nimport { Log } from '@rockcarver/frodo-lib';\n\nimport { printMessage } from './Console';\n\nconst { defaultNoiseFilter } = Log;\n\nexport const FRODO_CONFIG_PATH_KEY = 'FRODO_CONFIG_PATH';\nexport const FRODO_LOG_NOISEFILTER_FILENAME = 'LoggingNoiseFilter.json';\n\nexport function getConfigPath(): string {\n return process.env[FRODO_CONFIG_PATH_KEY] || `${os.homedir()}/.frodo`;\n}\n\nfunction getCustomNoiseFilters(): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n let noiseFilter = [];\n try {\n const data = fs.readFileSync(filename, 'utf8');\n noiseFilter = JSON.parse(data);\n } catch (e) {\n printMessage(`Error reading ${filename} (${e.message})`, 'error');\n }\n return noiseFilter;\n}\n\nexport function getNoiseFilters(defaults: boolean): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n if(defaults) {\n printMessage(`Using default logging noise filters.`, 'info');\n return defaultNoiseFilter();\n }\n let noiseFilter = getCustomNoiseFilters();\n if (noiseFilter.length == 0) {\n printMessage(`No custom noise filters defined. Using defaults.`, 'info');\n noiseFilter = defaultNoiseFilter();\n try {\n fs.writeFileSync(filename, JSON.stringify(noiseFilter, null, 2));\n printMessage(\n `The default filters were saved in ${filename}. You can change the filters as needed.`,\n 'info'\n ); \n } catch (e) {\n printMessage(`Error creating noise filter configuration with default values.`, 'error');\n }\n }\n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AAhC;;IACA,IAAI;MACAJ,EAAE,CAACuB,aAAH,CAAiBX,QAAjB,EAA2BI,IAAI,CAACQ,SAAL,CAAeX,WAAf,EAA4B,IAA5B,EAAkC,CAAlC,CAA3B;MACAV,YAAY,CACT,qCAAoCS,QAAS,yCADpC,EAEV,MAFU,CAAZ;IAIH,CAND,CAME,OAAOM,CAAP,EAAU;MACRf,YAAY,CAAE,gEAAF,EAAmE,OAAnE,CAAZ;IACH;EACF;;EACD,OAAOU,WAAP;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rockcarver/frodo-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
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": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
]
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@rockcarver/frodo-lib": "0.
|
|
91
|
+
"@rockcarver/frodo-lib": "0.16.0",
|
|
92
92
|
"cli-progress": "^3.11.2",
|
|
93
93
|
"cli-table3": "^0.6.2",
|
|
94
94
|
"colors": "^1.4.0",
|