diff --git a/package-lock.json b/package-lock.json index 94c097b56..cc1d6d3a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,6 @@ "chokidar": "^4.0.3", "cli-progress": "^3.11.2", "cli-table3": "^0.6.3", - "colors": "^1.4.0", "commander": "^11.0.0", "compare-versions": "^6.1.0", "copyfiles": "^2.4.1", @@ -52,6 +51,7 @@ "resolve": "^1.22.1", "rimraf": "^6.0.1", "slugify": "^1.6.5", + "tinyrainbow": "^3.0.3", "ts-jest": "^29.1.4", "tsup": "^8.1.0", "typescript": "^5.2.2", @@ -1341,9 +1341,9 @@ } }, "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, "license": "MIT", "dependencies": { @@ -6963,9 +6963,9 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "dev": true, "license": "MIT", "dependencies": { @@ -8559,15 +8559,15 @@ } }, "node_modules/rimraf/node_modules/glob": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", - "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.1.0.tgz", + "integrity": "sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { "foreground-child": "^3.3.1", "jackspeak": "^4.1.1", - "minimatch": "^10.0.3", + "minimatch": "^10.1.1", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" @@ -8583,11 +8583,11 @@ } }, "node_modules/rimraf/node_modules/minimatch": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", - "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz", + "integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/brace-expansion": "^5.0.0" }, @@ -9296,9 +9296,9 @@ } }, "node_modules/sucrase/node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", "dev": true, "license": "ISC", "dependencies": { @@ -9399,9 +9399,9 @@ } }, "node_modules/tar-fs": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.3.tgz", - "integrity": "sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -9547,6 +9547,16 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tinyrainbow": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/tmp": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", diff --git a/package.json b/package.json index 69ea2a8cc..ae7dd4482 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,6 @@ "chokidar": "^4.0.3", "cli-progress": "^3.11.2", "cli-table3": "^0.6.3", - "colors": "^1.4.0", "commander": "^11.0.0", "compare-versions": "^6.1.0", "copyfiles": "^2.4.1", @@ -151,6 +150,7 @@ "resolve": "^1.22.1", "rimraf": "^6.0.1", "slugify": "^1.6.5", + "tinyrainbow": "^3.0.3", "ts-jest": "^29.1.4", "tsup": "^8.1.0", "typescript": "^5.2.2", diff --git a/src/cli/_template/something-delete.ts b/src/cli/_template/something-delete.ts index 4e72f51e0..92a4df535 100644 --- a/src/cli/_template/something-delete.ts +++ b/src/cli/_template/something-delete.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -37,17 +38,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-describe.ts b/src/cli/_template/something-describe.ts index 33928b065..dc47d31cf 100644 --- a/src/cli/_template/something-describe.ts +++ b/src/cli/_template/something-describe.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -25,17 +26,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-else-delete.ts b/src/cli/_template/something-else-delete.ts index 818b705a5..efc6d65e0 100644 --- a/src/cli/_template/something-else-delete.ts +++ b/src/cli/_template/something-else-delete.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -35,17 +36,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-else-describe.ts b/src/cli/_template/something-else-describe.ts index b64a9e1e9..e0a4ea648 100644 --- a/src/cli/_template/something-else-describe.ts +++ b/src/cli/_template/something-else-describe.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -23,17 +24,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-else-export.ts b/src/cli/_template/something-else-export.ts index da1efba41..81555651a 100644 --- a/src/cli/_template/something-else-export.ts +++ b/src/cli/_template/something-else-export.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -47,17 +48,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-else-import.ts b/src/cli/_template/something-else-import.ts index af35a4894..73e9cf38a 100644 --- a/src/cli/_template/something-else-import.ts +++ b/src/cli/_template/something-else-import.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -41,17 +42,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-else-list.ts b/src/cli/_template/something-else-list.ts index b20ffdcb3..c8b681cc3 100644 --- a/src/cli/_template/something-else-list.ts +++ b/src/cli/_template/something-else-list.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -25,17 +26,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-export.ts b/src/cli/_template/something-export.ts index ff4dafc16..b52fecbd8 100644 --- a/src/cli/_template/something-export.ts +++ b/src/cli/_template/something-export.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -47,17 +48,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-import.ts b/src/cli/_template/something-import.ts index 2feaa8f0f..c81d0aa3a 100644 --- a/src/cli/_template/something-import.ts +++ b/src/cli/_template/something-import.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -41,17 +42,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-list.ts b/src/cli/_template/something-list.ts index 7d79e8c2b..ccc4dc650 100644 --- a/src/cli/_template/something-list.ts +++ b/src/cli/_template/something-list.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -21,17 +22,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-other-delete.ts b/src/cli/_template/something-other-delete.ts index 5a62ceb2d..368acb524 100644 --- a/src/cli/_template/something-other-delete.ts +++ b/src/cli/_template/something-other-delete.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -35,17 +36,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-other-describe.ts b/src/cli/_template/something-other-describe.ts index 127d96d5d..b9265fe43 100644 --- a/src/cli/_template/something-other-describe.ts +++ b/src/cli/_template/something-other-describe.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -23,17 +24,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-other-export.ts b/src/cli/_template/something-other-export.ts index eb965b599..02093d553 100644 --- a/src/cli/_template/something-other-export.ts +++ b/src/cli/_template/something-other-export.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -47,17 +48,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-other-import.ts b/src/cli/_template/something-other-import.ts index 2f078687a..47765ef05 100644 --- a/src/cli/_template/something-other-import.ts +++ b/src/cli/_template/something-other-import.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -41,17 +42,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/_template/something-other-list.ts b/src/cli/_template/something-other-list.ts index c56664d76..0813e2c4a 100644 --- a/src/cli/_template/something-other-list.ts +++ b/src/cli/_template/something-other-list.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -25,17 +26,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Example command one with params and explanation what it does:\n` + - ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Example command two with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Example command three with params and explanation what it does:\n` + - ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo something --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.ts b/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.ts index cbc07b5b9..a95165b38 100644 --- a/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.ts +++ b/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.ts @@ -1,6 +1,7 @@ import { state } from '@rockcarver/frodo-lib'; import Table from 'cli-table3'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import { v4 as uuidv4 } from 'uuid'; import { @@ -100,8 +101,8 @@ export default function setup() { style: { 'padding-left': 0, 'padding-right': 0 }, wordWrap: true, }); - table.push(['Client ID'['brightCyan'], clientId]); - table.push(['Client Secret'['brightCyan'], clientSecret]); + table.push([c.cyan('Client ID'), clientId]); + table.push([c.cyan('Client Secret'), clientSecret]); if (options.llt) { try { const response = await createLongLivedToken( @@ -112,9 +113,9 @@ export default function setup() { options.lltTtl ); if (options.lltEsv) - table.push(['Secret Name'['brightCyan'], response.secret]); - table.push(['Scope'['brightCyan'], response.scope]); - table.push(['Expires'['brightCyan'], response.expires_on]); + table.push([c.cyan('Secret Name'), response.secret]); + table.push([c.cyan('Scope'), response.scope]); + table.push([c.cyan('Expires'), response.expires_on]); printMessage(table.toString()); if (options.lltEsv === false) { printMessage(`\nBearer token:`, 'info'); diff --git a/src/cli/admin/admin-execute-rfc7523-authz-grant-flow.ts b/src/cli/admin/admin-execute-rfc7523-authz-grant-flow.ts index 2b0efbc03..d1f162d64 100644 --- a/src/cli/admin/admin-execute-rfc7523-authz-grant-flow.ts +++ b/src/cli/admin/admin-execute-rfc7523-authz-grant-flow.ts @@ -1,6 +1,7 @@ import { JwkRsa } from '@rockcarver/frodo-lib/types/ops/JoseOps.js'; import { Option } from 'commander'; import fs from 'fs'; +import c from 'tinyrainbow'; import { v4 as uuidv4 } from 'uuid'; import * as s from '../../help/SampleData'; @@ -40,19 +41,19 @@ export default function setup() { 'after', `Usage Examples:\n` + ` If you used frodo to create the RFC7523 configuration (see 'Related Commands' below), then you can test your configuration with minimal input and frodo will locate the missing parameters. The command below returns access token and identity token:\n` + - ` $ frodo admin execute-rfc7523-authz-grant-flow --client-id rfc7523-client1 ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo admin execute-rfc7523-authz-grant-flow --client-id rfc7523-client1 ${s.amBaseUrl}\n` + ) + ` Same as above but output raw json:\n` + - ` $ frodo admin execute-rfc7523-authz-grant-flow --client-id rfc7523-client1 --json ${s.amBaseUrl}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo admin execute-rfc7523-authz-grant-flow --client-id rfc7523-client1 --json ${s.amBaseUrl}'\n` + ) + ` Same as first command above but explicitly provide all parameters:\n` + - ` $ frodo admin execute-rfc7523-authz-grant-flow --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --jwk-file rfc7523-client1_private.jwk.json ${s.amBaseUrl}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo admin execute-rfc7523-authz-grant-flow --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --jwk-file rfc7523-client1_private.jwk.json ${s.amBaseUrl}'\n` + ) + `\nRelated Commands:\n` + - ` Run ${'frodo admin generate-rfc7523-authz-grant-artefacts --help'['brightCyan']} to see how to create the required configuration artefacts for ${'frodo admin execute-rfc7523-authz-grant-flow'['brightCyan']}:\n` + ` Run ${c.cyan('frodo admin generate-rfc7523-authz-grant-artefacts --help')} to see how to create the required configuration artefacts for ${c.cyan('frodo admin execute-rfc7523-authz-grant-flow')}:\n` ) .action( // implement command logic inside action handler diff --git a/src/cli/admin/admin-generate-rfc7523-authz-grant-artefacts.ts b/src/cli/admin/admin-generate-rfc7523-authz-grant-artefacts.ts index 349c7fc04..44fe2f10b 100644 --- a/src/cli/admin/admin-generate-rfc7523-authz-grant-artefacts.ts +++ b/src/cli/admin/admin-generate-rfc7523-authz-grant-artefacts.ts @@ -2,6 +2,7 @@ import { state } from '@rockcarver/frodo-lib'; import { JwkRsa } from '@rockcarver/frodo-lib/types/ops/JoseOps.js'; import { Option } from 'commander'; import fs from 'fs'; +import c from 'tinyrainbow'; import { v4 as uuidv4 } from 'uuid'; import * as s from '../../help/SampleData'; @@ -51,23 +52,23 @@ export default function setup() { ` - Fully configured OAuth2 trusted issuer - named '-issuer'\n` + ` - Private Key as Json Web Key (JWK) - named '_private.jwk.json'\n` + ` - Public Key as Json Web Key Set (JWKS) - named '_public.jwks.json'\n` + - ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d ${s.amBaseUrl}\n` + ) + ` Same as above but use an existing JWK file instead of creating one.\n` + - ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --jwk-file rfc7523-client1_private.jwk.json ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --jwk-file rfc7523-client1_private.jwk.json ${s.amBaseUrl}\n` + ) + ` Generate and output to console all the artefacts for an RFC7523 authorization grant flow configuration but do not create any configuration or files.\n` + - ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --no-save ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --no-save ${s.amBaseUrl}\n` + ) + ` Generate and output in json format all the artefacts for an RFC7523 authorization grant flow configuration.\n` + - ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --json ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo admin generate-rfc7523-authz-grant-artefacts --client-id rfc7523-client1 --iss https://my-issuer.com/issuer --sub 146c2230-9448-4442-b86d-eb4a81a0121d --json ${s.amBaseUrl}\n` + ) + `\nRelated Commands:\n` + - ` Run ${'frodo admin execute-rfc7523-authz-grant-flow --help'['brightCyan']} to see how to test your configuration created with ${'frodo admin generate-rfc7523-authz-grant-artefacts'['brightCyan']}:\n` + ` Run ${c.cyan('frodo admin execute-rfc7523-authz-grant-flow --help')} to see how to test your configuration created with ${c.cyan('frodo admin generate-rfc7523-authz-grant-artefacts')}:\n` ) .action( // implement command logic inside action handler diff --git a/src/cli/app/app-delete.ts b/src/cli/app/app-delete.ts index 2e359a098..fef3b8fca 100644 --- a/src/cli/app/app-delete.ts +++ b/src/cli/app/app-delete.ts @@ -1,4 +1,5 @@ import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { @@ -33,14 +34,14 @@ export default function setup() { ) .addHelpText( 'after', - `Important Note:\n`['brightYellow'] + - ` The ${'frodo app'['brightCyan']} command to manage OAuth2 clients in v1.x has been renamed to ${'frodo oauth client'['brightCyan']} in v2.x\n` + - ` The ${'frodo app'['brightCyan']} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${'frodo oauth client'['brightCyan']} command.\n\n` + + c.yellow(`Important Note:\n`) + + ` The ${c.cyan('frodo app')} command to manage OAuth2 clients in v1.x has been renamed to ${c.cyan('frodo oauth client')} in v2.x\n` + + ` The ${c.cyan('frodo app')} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${c.cyan('frodo oauth client')} command.\n\n` + `Usage Examples:\n` + ` Delete application 'myApp':\n` + - ` $ frodo app delete -i 'myApp' ${s.amBaseUrl}\n`['brightCyan'] + + c.cyan(` $ frodo app delete -i 'myApp' ${s.amBaseUrl}\n`) + ` Delete all applications:\n` + - ` $ frodo app delete -a ${s.connId}\n`['brightCyan'] + c.cyan(` $ frodo app delete -a ${s.connId}\n`) ) .action( // implement command logic inside action handler diff --git a/src/cli/app/app-describe.ts b/src/cli/app/app-describe.ts index 06e5d3cfc..5fbf2dd0c 100644 --- a/src/cli/app/app-describe.ts +++ b/src/cli/app/app-describe.ts @@ -1,4 +1,5 @@ import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -14,14 +15,14 @@ export default function setup() { .addOption(new Option('-i, --app-id ', 'Application name.')) .addHelpText( 'after', - `Important Note:\n`['brightYellow'] + - ` The ${'frodo app'['brightCyan']} command to manage OAuth2 clients in v1.x has been renamed to ${'frodo oauth client'['brightCyan']} in v2.x\n` + - ` The ${'frodo app'['brightCyan']} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${'frodo oauth client'['brightCyan']} command.\n\n` + + c.yellow(`Important Note:\n`) + + ` The ${c.cyan('frodo app')} command to manage OAuth2 clients in v1.x has been renamed to ${c.cyan('frodo oauth client')} in v2.x\n` + + ` The ${c.cyan('frodo app')} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${c.cyan('frodo oauth client')} command.\n\n` + `Usage Examples:\n` + ` Describe application 'myApp':\n` + - ` $ frodo app describe -i myApp ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo app describe -i myApp ${s.connId}\n`) + ` Describe application 'myApp' in raw JSON:\n` + - ` $ frodo app describe -i myApp --json ${s.connId}\n`['brightCyan'] + c.cyan(` $ frodo app describe -i myApp --json ${s.connId}\n`) ) .action( // implement command logic inside action handler diff --git a/src/cli/app/app-export.ts b/src/cli/app/app-export.ts index b20757f52..131421b31 100644 --- a/src/cli/app/app-export.ts +++ b/src/cli/app/app-export.ts @@ -1,4 +1,5 @@ import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { @@ -47,22 +48,22 @@ export default function setup() { ) .addHelpText( 'after', - `Important Note:\n`['brightYellow'] + - ` The ${'frodo app'['brightCyan']} command to manage OAuth2 clients in v1.x has been renamed to ${'frodo oauth client'['brightCyan']} in v2.x\n` + - ` The ${'frodo app'['brightCyan']} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${'frodo oauth client'['brightCyan']} command.\n\n` + + c.yellow(`Important Note:\n`) + + ` The ${c.cyan('frodo app')} command to manage OAuth2 clients in v1.x has been renamed to ${c.cyan('frodo oauth client')} in v2.x\n` + + ` The ${c.cyan('frodo app')} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${c.cyan('frodo oauth client')} command.\n\n` + `Usage Examples:\n` + ` Export all applications to a single export file with an auto-generated filename using a connection profile:\n` + - ` $ frodo app export -a ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo app export -a ${s.connId}\n`) + ` Export the first application to a single export file with a custom filename:\n` + - ` $ frodo app export -f ./allMyApplications.application.json ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo app export -f ./allMyApplications.application.json ${s.connId}\n` + ) + ` Export all applications to separate export files with an auto-generated filenames:\n` + - ` $ frodo app export -A ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo app export -A ${s.connId}\n`) + ` Export all applications without dependencies to a single export file:\n` + - ` $ frodo app export --no-deps -a ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo app export --no-deps -a ${s.connId}\n`) + ` Export the application 'myApp' to a file with an auto-generated filename of 'myApp.application.json':\n` + - ` $ frodo app export -i myApp ${s.connId}\n`['brightCyan'] + c.cyan(` $ frodo app export -i myApp ${s.connId}\n`) ) .action( // implement command logic inside action handler diff --git a/src/cli/app/app-import.ts b/src/cli/app/app-import.ts index ace0c5202..ba32b58d5 100644 --- a/src/cli/app/app-import.ts +++ b/src/cli/app/app-import.ts @@ -1,4 +1,5 @@ import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { @@ -42,28 +43,28 @@ export default function setup() { ) .addHelpText( 'after', - `Important Note:\n`['brightYellow'] + - ` The ${'frodo app'['brightCyan']} command to manage OAuth2 clients in v1.x has been renamed to ${'frodo oauth client'['brightCyan']} in v2.x\n` + - ` The ${'frodo app'['brightCyan']} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${'frodo oauth client'['brightCyan']} command.\n\n` + + c.yellow(`Important Note:\n`) + + ` The ${c.cyan('frodo app')} command to manage OAuth2 clients in v1.x has been renamed to ${c.cyan('frodo oauth client')} in v2.x\n` + + ` The ${c.cyan('frodo app')} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${c.cyan('frodo oauth client')} command.\n\n` + `Usage Examples:\n` + ` Import all applications from a single export file using a connection profile:\n` + - ` $ frodo app import -a -f ./allAlphaApplications.application.json ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo app import -a -f ./allAlphaApplications.application.json ${s.connId}\n` + ) + ` Import the first application from a single export file:\n` + - ` $ frodo app import -f ./allAlphaApplications.application.json ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo app import -f ./allAlphaApplications.application.json ${s.connId}\n` + ) + ` Import all applications from separate export files:\n` + - ` $ frodo app import -A ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo app import -A ${s.connId}\n`) + ` Import all applications without dependencies from a single export file:\n` + - ` $ frodo app import --no-deps -a -f ./allAlphaApplications.application.json ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo app import --no-deps -a -f ./allAlphaApplications.application.json ${s.connId}\n` + ) + ` Import only the application 'myApp' from a file with an export file containing multiple applications:\n` + - ` $ frodo app import -i myApp -f ./allAlphaApplications.application.json ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo app import -i myApp -f ./allAlphaApplications.application.json ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/app/app-list.ts b/src/cli/app/app-list.ts index 16e8f7d08..fafe3d013 100644 --- a/src/cli/app/app-list.ts +++ b/src/cli/app/app-list.ts @@ -1,4 +1,5 @@ import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { listApplications } from '../../ops/ApplicationOps'; @@ -18,18 +19,18 @@ export default function setup() { ) .addHelpText( 'after', - `Important Note:\n`['brightYellow'] + - ` The ${'frodo app'['brightCyan']} command to manage OAuth2 clients in v1.x has been renamed to ${'frodo oauth client'['brightCyan']} in v2.x\n` + - ` The ${'frodo app'['brightCyan']} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${'frodo oauth client'['brightCyan']} command.\n\n` + + c.yellow(`Important Note:\n`) + + ` The ${c.cyan('frodo app')} command to manage OAuth2 clients in v1.x has been renamed to ${c.cyan('frodo oauth client')} in v2.x\n` + + ` The ${c.cyan('frodo app')} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${c.cyan('frodo oauth client')} command.\n\n` + `Usage Examples:\n` + ` List applications using AM base URL, username, and password (note the quotes around password to allow special characters):\n` + - ` $ frodo app list ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo app list ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` List applications using a connection profile (identified by the full AM base URL):\n` + - ` $ frodo app list ${s.amBaseUrl}\n`['brightCyan'] + + c.cyan(` $ frodo app list ${s.amBaseUrl}\n`) + ` List applications using a connection profile (identified by a unique substring of the AM base URL):\n` + - ` $ frodo app list ${s.connId}\n`['brightCyan'] + c.cyan(` $ frodo app list ${s.connId}\n`) ) .action( // implement command logic inside action handler diff --git a/src/cli/app/app.ts b/src/cli/app/app.ts index 48768e4f9..03c5e7935 100644 --- a/src/cli/app/app.ts +++ b/src/cli/app/app.ts @@ -1,3 +1,5 @@ +import c from 'tinyrainbow'; + import { FrodoStubCommand } from '../FrodoCommand'; import DeleteCmd from './app-delete.js'; // import DescribeCmd from './app-describe.js'; @@ -10,9 +12,9 @@ export default function setup() { .description('Manage applications.') .addHelpText( 'after', - `\nImportant Note:\n`['brightYellow'] + - ` The ${'frodo app'['brightCyan']} command to manage OAuth2 clients in v1.x has been renamed to ${'frodo oauth client'['brightCyan']} in v2.x\n` + - ` The ${'frodo app'['brightCyan']} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${'frodo oauth client'['brightCyan']} command.\n\n` + c.yellow(`\nImportant Note:\n`) + + ` The ${c.cyan('frodo app')} command to manage OAuth2 clients in v1.x has been renamed to ${c.cyan('frodo oauth client')} in v2.x\n` + + ` The ${c.cyan('frodo app')} command in v2.x manages the new applications created using the new application templates in ForgeRock Identity Cloud. To manage oauth clients, use the ${c.cyan('frodo oauth client')} command.\n\n` ); program.addCommand(ListCmd().name('list')); diff --git a/src/cli/config/config-export.ts b/src/cli/config/config-export.ts index 4b9056ecf..e7aa9bc66 100644 --- a/src/cli/config/config-export.ts +++ b/src/cli/config/config-export.ts @@ -1,5 +1,6 @@ import { state } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -107,34 +108,34 @@ export default function setup() { ) .addHelpText( 'after', - `How Frodo handles secrets:\n`['brightGreen'] + - ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n`[ - 'brightGreen' - ] + + c.green(`How Frodo handles secrets:\n`) + + c.green( + ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n` + ) + `Usage Examples:\n` + ` Export global and realm configuration for version control (e.g. Git) into the current directory.\n` + ` Note that -x and -s separates script and mapping config to better track changes made to them, and -N removes metadata since it changes every export (you may consider using --no-coords as well if you don't care to track node positions in journeys):\n` + - ` $ frodo config export -sxAND . ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo config export -sxAND . ${s.connId}\n`) + ` Export global and realm configuration from cloud to be later imported into a classic, on-prem deployment.\n` + ` Note -dR is used for exporting all read-only config from cloud since certain cloud read-only config (like the realm config) can be imported into a classic on-prem deployment:\n` + - ` $ frodo config export -adR ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo config export -adR ${s.connId}\n`) + ` Export only the bravo realm configuration:\n` + - ` $ frodo config export -ar ${s.connId} bravo\n`['brightCyan'] + + c.cyan(` $ frodo config export -ar ${s.connId} bravo\n`) + ` Backup global and realm configuration including active secret values to a single file (Note: only values of active and loaded secrets can be exported):\n` + - ` $ frodo config export -a --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo config export -a --include-active-values ${s.connId}\n` + ) + ` Backup global and realm configuration including active secret values to individual files in a directory structure (Note: only values of active and loaded secrets can be exported):\n` + - ` $ frodo config export -A -D ${s.connId}-backup --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo config export -A -D ${s.connId}-backup --include-active-values ${s.connId}\n` + ) + ` Export global and realm configuration including active secret values for import into another environment.\n` + ` The --target parameter instructs frodo to encrypt the exported secret values using the target environment so they can be imported into that target environment without requiring the source environment they were exported from.\n` + ` Using the --target parameter, the target environment must be available at the time of export and the person performing the export must have a connection profile for the target environment.\n` + ` Without the --target parameter, the source environment must be available at the time of import and the person performing the import must have a connection profile for the source environment.\n` + - ` $ frodo config export -a --include-active-values --target ${s.connId2} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo config export -a --include-active-values --target ${s.connId2} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/config/config-import.ts b/src/cli/config/config-import.ts index a466a39ee..4bf4fa426 100644 --- a/src/cli/config/config-import.ts +++ b/src/cli/config/config-import.ts @@ -1,5 +1,6 @@ import { state } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -75,25 +76,25 @@ export default function setup() { ) .addHelpText( 'after', - `How Frodo handles secrets:\n`['brightGreen'] + - ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n`[ - 'brightGreen' - ] + + c.green(`How Frodo handles secrets:\n`) + + c.green( + ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n` + ) + `Usage Examples:\n` + ` Restore global and active realm configuration including active secret values from a single file (Note: config export must have been performed using the --include-active-values option):\n` + - ` $ frodo config import -a -f Alpha.everything.json --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo config import -a -f Alpha.everything.json --include-active-values ${s.connId}\n` + ) + ` Restore global and active realm configuration including active secret values from separate files in a directory structure (Note: config export must have been performed using the --include-active-values option):\n` + - ` $ frodo config import -A -D ${s.connId}-backup --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo config import -A -D ${s.connId}-backup --include-active-values ${s.connId}\n` + ) + ` Import global and active realm configuration including active secret values, wich were exported from another environment using the --include-active-values option but without using the --target parameter, therefore requiring the --source parameter on import:\n` + ` The --source parameter instructs frodo to decrypt the secret values during import using the source environment, which was used to encrypt them.\n` + ` Using the --source parameter, the source environment must be available at the time of import and the person performing the import must have a connection profile for the source environment.\n` + - ` $ frodo config import -a -f Alpha.everything.json --include-active-values --source ${s.connId} ${s.connId2}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo config import -a -f Alpha.everything.json --include-active-values --source ${s.connId} ${s.connId2}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/conn/conn-save.ts b/src/cli/conn/conn-save.ts index e48fa69d0..f6bf4ab5d 100644 --- a/src/cli/conn/conn-save.ts +++ b/src/cli/conn/conn-save.ts @@ -1,5 +1,6 @@ import { frodo, state } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -54,17 +55,17 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Create a connection profile with a new log API key and secret and a new service account:\n` + - ` $ frodo conn save ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo conn save ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Save an existing service account to an existing or new connection profile:\n` + - ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}\n` + ) + ` Save an existing service account to an existing connection profile (partial host URL only updates an existing profile):\n` + - ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/esv/esv-secret-export.ts b/src/cli/esv/esv-secret-export.ts index 2fe8f6143..f69058a55 100644 --- a/src/cli/esv/esv-secret-export.ts +++ b/src/cli/esv/esv-secret-export.ts @@ -1,5 +1,6 @@ import { state } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -61,26 +62,26 @@ export default function setup() { ) .addHelpText( 'after', - `How Frodo handles secrets:\n`['brightGreen'] + - ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n`[ - 'brightGreen' - ] + + c.green(`How Frodo handles secrets:\n`) + + c.green( + ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n` + ) + `Usage Examples:\n` + ` Export secrets including active secret values to a single file (Note: only values of active and loaded secrets can be exported):\n` + - ` $ frodo esv secret export -a --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv secret export -a --include-active-values ${s.connId}\n` + ) + ` Export secrets including active secret values to individual files in a directory (Note: only values of active and loaded secrets can be exported):\n` + - ` $ frodo esv secret export -A -D ${s.connId}-secrets --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv secret export -A -D ${s.connId}-secrets --include-active-values ${s.connId}\n` + ) + ` Export secrets including active secret values to a single file for import into another environment.\n` + ` The --target parameter instructs frodo to encrypt the exported secret values using the target environment so they can be imported into that target environment without requiring the source environment they were exported from.\n` + ` Using the --target parameter, the target environment must be available at the time of export and the person performing the export must have a connection profile for the target environment.\n` + ` Without the --target parameter, the source environment must be available at the time of import and the person performing the import must have a connection profile for the source environment.\n` + - ` $ frodo esv secret export -a --include-active-values --target ${s.connId2} ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo esv secret export -a --include-active-values --target ${s.connId2} ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/esv/esv-secret-import.ts b/src/cli/esv/esv-secret-import.ts index c5073bf86..c9ce79761 100644 --- a/src/cli/esv/esv-secret-import.ts +++ b/src/cli/esv/esv-secret-import.ts @@ -1,4 +1,5 @@ import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -54,25 +55,25 @@ export default function setup() { ) .addHelpText( 'after', - `How Frodo handles secrets:\n`['brightGreen'] + - ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n`[ - 'brightGreen' - ] + + c.green(`How Frodo handles secrets:\n`) + + c.green( + ` Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment (--target parameter). Frodo never exports secrets in the clear.\n\n` + ) + `Usage Examples:\n` + ` Import secrets including active secret values from a single file (Note: secrets must have been exported using the --include-active-values option):\n` + - ` $ frodo esv secret import -a -f allAlphaSecrets.secret.json --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv secret import -a -f allAlphaSecrets.secret.json --include-active-values ${s.connId}\n` + ) + ` Import secrets including active secret values from separate files in a directory (Note: secrets must have been exported using the --include-active-values option):\n` + - ` $ frodo esv secret import -A -D ${s.connId}-secrets --include-active-values ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv secret import -A -D ${s.connId}-secrets --include-active-values ${s.connId}\n` + ) + ` Import secrets including active secret values from a single file that was exported from another environment using the --include-active-values option but without using the --target parameter, therefore requiring the --source parameter on import:\n` + ` The --source parameter instructs frodo to decrypt the secret values during import using the source environment, which was used to encrypt them.\n` + ` Using the --source parameter, the source environment must be available at the time of import and the person performing the import must have a connection profile for the source environment.\n` + - ` $ frodo esv secret import -a -f allAlphaSecrets.secret.json --include-active-values --source ${s.connId} ${s.connId2}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo esv secret import -a -f allAlphaSecrets.secret.json --include-active-values --source ${s.connId} ${s.connId2}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/esv/esv-variable-create.ts b/src/cli/esv/esv-variable-create.ts index f3b1fe838..a37bc188e 100644 --- a/src/cli/esv/esv-variable-create.ts +++ b/src/cli/esv/esv-variable-create.ts @@ -1,3 +1,5 @@ +import c from 'tinyrainbow'; + import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; import { createVariable } from '../../ops/cloud/VariablesOps'; @@ -27,25 +29,25 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Create an ESV variable using implied default type "string":\n` + - ` $ frodo esv variable create --variable-id "esv-trinity-phone" --value "(312)-555-0690" --description "Trinity's phone number." ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv variable create --variable-id "esv-trinity-phone" --value "(312)-555-0690" --description "Trinity's phone number." ${s.connId}\n` + ) + ` Create an ESV variable of type "array":\n` + - ` $ frodo esv variable create --variable-id "esv-nebuchadnezzar-crew" --variable-type array --value '["Morpheus","Trinity","Link","Tank","Dozer","Apoc","Cypher","Mouse","Neo","Switch"]' --description "The crew of the Nebuchadnezzar hovercraft." ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv variable create --variable-id "esv-nebuchadnezzar-crew" --variable-type array --value '["Morpheus","Trinity","Link","Tank","Dozer","Apoc","Cypher","Mouse","Neo","Switch"]' --description "The crew of the Nebuchadnezzar hovercraft." ${s.connId}\n` + ) + ` Create an ESV variable of type "object":\n` + - ` $ frodo esv variable create --variable-id "esv-nebuchadnezzar-crew-structure" --variable-type object --value '{"Captain":"Morpheus","FirstMate":"Trinity","Operator":["Link","Tank"],"Medic":"Dozer","Crewmen":["Apoc","Cypher","Mouse","Neo","Switch"]}' --description "The structure of the crew of the Nebuchadnezzar hovercraft." ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv variable create --variable-id "esv-nebuchadnezzar-crew-structure" --variable-type object --value '{"Captain":"Morpheus","FirstMate":"Trinity","Operator":["Link","Tank"],"Medic":"Dozer","Crewmen":["Apoc","Cypher","Mouse","Neo","Switch"]}' --description "The structure of the crew of the Nebuchadnezzar hovercraft." ${s.connId}\n` + ) + ` Create an ESV variable of type "int":\n` + - ` $ frodo esv variable create --variable-id "esv-neo-age" --variable-type int --value '28' --description "Neo's age in the matrix." ${s.connId}\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo esv variable create --variable-id "esv-neo-age" --variable-type int --value '28' --description "Neo's age in the matrix." ${s.connId}\n` + ) + ` Create an ESV variable of type "bool":\n` + - ` $ frodo esv variable create --variable-id "esv-blue-piller" --variable-type bool --value 'false' --description "Zion membership criteria." ${s.connId}\n`[ - 'brightCyan' - ] + c.cyan( + ` $ frodo esv variable create --variable-id "esv-blue-piller" --variable-type bool --value 'false' --description "Zion membership criteria." ${s.connId}\n` + ) ) .action( // implement command logic inside action handler diff --git a/src/cli/info/info.ts b/src/cli/info/info.ts index 3324d3275..adf8a3d7c 100644 --- a/src/cli/info/info.ts +++ b/src/cli/info/info.ts @@ -1,5 +1,6 @@ import { frodo, state } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import * as s from '../../help/SampleData'; import { getTokens } from '../../ops/AuthenticateOps'; @@ -29,15 +30,15 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Show human-readable output and login using AM base URL, username, and password (note the quotes around password to allow special characters):\n` + - ` $ frodo info ${s.amBaseUrl} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo info ${s.amBaseUrl} ${s.username} '${s.password}'\n` + ) + ` Show human-readable output and login using a connection profile (identified by the full AM base URL):\n` + - ` $ frodo info ${s.amBaseUrl}\n`['brightCyan'] + + c.cyan(` $ frodo info ${s.amBaseUrl}\n`) + ` Show human-readable output and login using a connection profile (identified by a unique substring of the AM base URL):\n` + - ` $ frodo info ${s.connId}\n`['brightCyan'] + + c.cyan(` $ frodo info ${s.connId}\n`) + ` Show JSON output and login using the AM base URL's unique substring to identify the connection profile:\n` + - ` $ frodo info --json ${s.connId}\n`['brightCyan'] + c.cyan(` $ frodo info --json ${s.connId}\n`) ) .action(async (host, user, password, options, command) => { command.handleDefaultArgsAndOpts(host, user, password, options, command); diff --git a/src/cli/shell/shell.ts b/src/cli/shell/shell.ts index 9a19728bb..516467e52 100644 --- a/src/cli/shell/shell.ts +++ b/src/cli/shell/shell.ts @@ -2,6 +2,7 @@ import repl from 'node:repl'; import { frodo } from '@rockcarver/frodo-lib'; import { Option } from 'commander'; +import c from 'tinyrainbow'; import util from 'util'; import vm from 'vm'; @@ -52,13 +53,13 @@ export default function setup() { 'after', `Usage Examples:\n` + ` Launch a frodo shell using explicit login parameters:\n` + - ` $ frodo shell ${s.amBaseUrl} ${s.realm} ${s.username} '${s.password}'\n`[ - 'brightCyan' - ] + + c.cyan( + ` $ frodo shell ${s.amBaseUrl} ${s.realm} ${s.username} '${s.password}'\n` + ) + ` Launch a frodo shell using a connection profile (identified by the full AM base URL):\n` + - ` $ frodo shell ${s.amBaseUrl}\n`['brightCyan'] + + c.cyan(` $ frodo shell ${s.amBaseUrl}\n`) + ` Launch a frodo shell using a connection profile (identified by a unique substring of the AM base URL):\n` + - ` $ frodo shell ${s.connId}\n`['brightCyan'] + c.cyan(` $ frodo shell ${s.connId}\n`) ) .addOption( new Option( diff --git a/src/ops/AdminOps.ts b/src/ops/AdminOps.ts index 0463401a0..97ac90ee5 100644 --- a/src/ops/AdminOps.ts +++ b/src/ops/AdminOps.ts @@ -6,6 +6,7 @@ import { OAuth2TrustedJwtIssuerSkeleton } from '@rockcarver/frodo-lib/types/api/ import { JwkRsa, JwksInterface } from '@rockcarver/frodo-lib/types/ops/JoseOps'; import { AccessTokenMetaType } from '@rockcarver/frodo-lib/types/ops/OAuth2OidcOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { cleanupProgressIndicators, @@ -1177,21 +1178,21 @@ export async function generateRfc7523AuthZGrantArtefacts( : `\nIn AM, create an OAuth2 client in the ${state.getRealm()} realm with the following information:` ); const client = createKeyValueTable(); - client.push(['Client ID'['brightCyan'], clientId]); - client.push(['Client Name'['brightCyan'], clientId]); + client.push([c.cyan('Client ID'), clientId]); + client.push([c.cyan('Client Name'), clientId]); client.push([ - 'Scopes'['brightCyan'], + c.cyan('Scopes'), ( artefacts.client.coreOAuth2ClientConfig.scopes as Writable ).value.join(', '), ]); client.push([ - 'Client Type'['brightCyan'], + c.cyan('Client Type'), (artefacts.client.coreOAuth2ClientConfig.clientType as Writable) .value, ]); client.push([ - 'Grant Types'['brightCyan'], + c.cyan('Grant Types'), ( artefacts.client.advancedOAuth2ClientConfig.grantTypes as Writable< string[] @@ -1199,28 +1200,28 @@ export async function generateRfc7523AuthZGrantArtefacts( ).value.join(', '), ]); client.push([ - 'Implied Consent'['brightCyan'], + c.cyan('Implied Consent'), ( artefacts.client.advancedOAuth2ClientConfig .isConsentImplied as Writable ).value, ]); client.push([ - 'Token Endpoint Authentication '['brightCyan'], + c.cyan('Token Endpoint Authentication '), ( artefacts.client.advancedOAuth2ClientConfig .tokenEndpointAuthMethod as Writable ).value, ]); client.push([ - 'Public Key Selector'['brightCyan'], + c.cyan('Public Key Selector'), ( artefacts.client.signEncOAuth2ClientConfig .publicKeyLocation as Writable ).value, ]); client.push([ - 'JWKS (Public Key)'['brightCyan'], + c.cyan('JWKS (Public Key)'), options.save ? `${jwksFile}` : 'See below', ]); printMessage(`\n${client.toString()}`); @@ -1231,13 +1232,13 @@ export async function generateRfc7523AuthZGrantArtefacts( : `\nIn AM, create a trusted issuer in the ${state.getRealm()} realm with the following information:` ); const issuer = createKeyValueTable(); - issuer.push(['Name'['brightCyan'], artefacts.issuer._id]); + issuer.push([c.cyan('Name'), artefacts.issuer._id]); issuer.push([ - 'JWT Issuer'['brightCyan'], + c.cyan('JWT Issuer'), (artefacts.issuer.issuer as Writable).value, ]); issuer.push([ - 'Allowed Subjects '['brightCyan'], + c.cyan('Allowed Subjects '), (artefacts.issuer.allowedSubjects as Writable)?.value.length ? ( artefacts.issuer.allowedSubjects as Writable @@ -1245,14 +1246,14 @@ export async function generateRfc7523AuthZGrantArtefacts( : `Any ${state.getRealm()} realm user`, ]); issuer.push([ - 'JWKS (Public Key)'['brightCyan'], + c.cyan('JWKS (Public Key)'), options.save ? `${jwksFile}` : 'See below', ]); printMessage(`\n${issuer.toString()}`); if (!options.save) { - printMessage('\nJWK (Private Key)'['brightCyan']); + printMessage(c.cyan('\nJWK (Private Key)')); printMessage(stringify(artefacts.jwk)); - printMessage('\nJWKS (Public Key)'['brightCyan']); + printMessage(c.cyan('\nJWKS (Public Key)')); printMessage(stringify(artefacts.jwks)); } } @@ -1395,10 +1396,10 @@ export async function executeRfc7523AuthZGrantFlow( if (json) { printMessage(tokenResponse, 'data'); } else { - printMessage('\nAccess Token'['brightCyan']); + printMessage(c.cyan('\nAccess Token')); printMessage(tokenResponse.access_token); if (tokenResponse.id_token) { - printMessage('\nIdentity Token'['brightCyan']); + printMessage(c.cyan('\nIdentity Token')); printMessage(tokenResponse.id_token); } } diff --git a/src/ops/AgentOps.ts b/src/ops/AgentOps.ts index 76db63aed..bf171e69e 100644 --- a/src/ops/AgentOps.ts +++ b/src/ops/AgentOps.ts @@ -1,6 +1,7 @@ import { frodo, FrodoError, state } from '@rockcarver/frodo-lib'; import { type AgentExportInterface } from '@rockcarver/frodo-lib/types/ops/AgentOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createProgressIndicator, @@ -86,7 +87,7 @@ export async function listAgents( } table.push([ agent._id, - status === 'Active' ? 'Active'['brightGreen'] : status['brightRed'], + status === 'Active' ? c.green('Active') : c.red(status), agent._type.name, ]); } @@ -117,9 +118,7 @@ export async function listIdentityGatewayAgents( for (const agent of agents) { table.push([ agent._id, - agent.status === 'Active' - ? 'Active'['brightGreen'] - : agent.status['brightRed'], + agent.status === 'Active' ? c.green('Active') : c.red(agent.status), ]); } printMessage(table.toString(), 'data'); @@ -148,8 +147,8 @@ export async function listJavaAgents(long: boolean = false): Promise { table.push([ agent._id, agent['globalJ2EEAgentConfig']['status'] === 'Active' - ? 'Active'['brightGreen'] - : agent['globalJ2EEAgentConfig']['status']['brightRed'], + ? c.green('Active') + : c.red(agent['globalJ2EEAgentConfig']['status']), ]); } printMessage(table.toString(), 'data'); @@ -178,8 +177,8 @@ export async function listWebAgents(long: boolean = false): Promise { table.push([ agent._id, agent['globalWebAgentConfig']['status'] === 'Active' - ? 'Active'['brightGreen'] - : agent['globalWebAgentConfig']['status']['brightRed'], + ? c.green('Active') + : c.red(agent['globalWebAgentConfig']['status']), ]); } printMessage(table.toString(), 'data'); diff --git a/src/ops/CirclesOfTrustOps.ts b/src/ops/CirclesOfTrustOps.ts index 570e56515..99bbfe6b2 100644 --- a/src/ops/CirclesOfTrustOps.ts +++ b/src/ops/CirclesOfTrustOps.ts @@ -2,6 +2,7 @@ import { frodo, FrodoError, state } from '@rockcarver/frodo-lib'; import { type CircleOfTrustSkeleton } from '@rockcarver/frodo-lib/types/api/CirclesOfTrustApi'; import { type CirclesOfTrustExportInterface } from '@rockcarver/frodo-lib/types/ops/CirclesOfTrustOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createProgressIndicator, @@ -36,7 +37,7 @@ const { * @returns {string} a one-line description */ export function getOneLineDescription(cotObj: CircleOfTrustSkeleton): string { - const description = `[${cotObj._id['brightCyan']}]`; + const description = `[${c.cyan(cotObj._id)}]`; return description; } @@ -85,10 +86,10 @@ export async function listCirclesOfTrust( return true; } else { const table = createTable([ - 'Name'['brightCyan'], - 'Description'['brightCyan'], - 'Status'['brightCyan'], - 'Trusted Providers'['brightCyan'], + c.cyan('Name'), + c.cyan('Description'), + c.cyan('Status'), + c.cyan('Trusted Providers'), ]); cotList.forEach((cot) => { table.push([ diff --git a/src/ops/EmailTemplateOps.ts b/src/ops/EmailTemplateOps.ts index c5a2f4cf5..3f1a8f08f 100644 --- a/src/ops/EmailTemplateOps.ts +++ b/src/ops/EmailTemplateOps.ts @@ -2,6 +2,7 @@ import { frodo, FrodoError } from '@rockcarver/frodo-lib'; import { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/ops/EmailTemplateOps'; import fs from 'fs'; import path from 'path'; +import c from 'tinyrainbow'; import { createProgressIndicator, @@ -51,7 +52,7 @@ function getFileDataTemplate() { export function getOneLineDescription( templateObj: EmailTemplateSkeleton ): string { - const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${ + const description = `[${c.cyan(templateObj._id.split('/')[1])}] ${ templateObj.displayName ? templateObj.displayName : '' } - ${ templateObj.defaultLocale @@ -119,12 +120,12 @@ export async function listEmailTemplates( } } else { const table = createTable([ - 'Id'['brightCyan'], - 'Name'['brightCyan'], - 'Status'['brightCyan'], - 'Locale(s)'['brightCyan'], - 'From'['brightCyan'], - 'Subject'['brightCyan'], + c.cyan('Id'), + c.cyan('Name'), + c.cyan('Status'), + c.cyan('Locale(s)'), + c.cyan('From'), + c.cyan('Subject'), ]); for (const emailTemplate of emailTemplates) { table.push([ @@ -134,8 +135,8 @@ export async function listEmailTemplates( `${emailTemplate.displayName ? emailTemplate.displayName : ''}`, // Status emailTemplate.enabled === false - ? 'disabled'['brightRed'] - : 'enabled'['brightGreen'], + ? c.red('disabled') + : c.green('enabled'), // Locale(s) `${emailTemplate.defaultLocale}${ Object.keys(emailTemplate.subject).length > 1 @@ -186,7 +187,7 @@ export async function exportEmailTemplateToFile( saveJsonToFile(fileData, filePath, includeMeta); stopProgressIndicator( indicatorId, - `Exported ${templateId['brightCyan']} to ${filePath['brightCyan']}.` + `Exported ${c.cyan(templateId)} to ${c.cyan(filePath)}.` ); return true; } catch (error) { diff --git a/src/ops/IdpOps.ts b/src/ops/IdpOps.ts index aeab67c27..137ca0f57 100644 --- a/src/ops/IdpOps.ts +++ b/src/ops/IdpOps.ts @@ -2,6 +2,7 @@ import { frodo, FrodoError } from '@rockcarver/frodo-lib'; import { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/SocialIdentityProvidersApi'; import { type SocialIdentityProviderImportOptions } from '@rockcarver/frodo-lib/types/ops/IdpOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createProgressIndicator, @@ -31,7 +32,7 @@ const { getFilePath, getWorkingDirectory } = frodo.utils; * @returns {string} a one-line description */ export function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string { - const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`; + const description = `[${c.cyan(socialIdpObj._id)}] ${socialIdpObj._type._id}`; return description; } @@ -107,7 +108,7 @@ export async function exportSocialIdentityProviderToFile( saveJsonToFile(fileData, filePath, includeMeta); stopProgressIndicator( indicatorId, - `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.` + `Exported ${c.cyan(providerId)} to ${c.cyan(filePath)}.` ); debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: end`); return true; diff --git a/src/ops/JourneyOps.ts b/src/ops/JourneyOps.ts index d416a2c04..d3e881417 100644 --- a/src/ops/JourneyOps.ts +++ b/src/ops/JourneyOps.ts @@ -12,6 +12,7 @@ import { type TreeImportOptions, } from '@rockcarver/frodo-lib/types/ops/JourneyOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createProgressIndicator, @@ -81,8 +82,8 @@ export async function listJourneys( table.push([ `${journeyStub._id}`, journeyStub.enabled === false - ? 'disabled'['brightRed'] - : 'enabled'['brightGreen'], + ? c.red('disabled') + : c.green('enabled'), journeyStub.uiConfig?.categories ? wordwrap( JSON.parse(journeyStub.uiConfig.categories).join(', '), @@ -126,8 +127,8 @@ export async function listJourneys( table.push([ `${journeyExport.tree._id}`, journeyExport.tree.enabled === false - ? 'disabled'['brightRed'] - : 'enabled'['brightGreen'], + ? c.red('disabled') + : c.green('enabled'), getJourneyClassification(journeyExport).join(', '), journeyExport.tree.uiConfig?.categories ? wordwrap( @@ -199,7 +200,7 @@ export async function exportJourneyToFile( ); stopProgressIndicator( spinnerId, - `Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`, + `Exported ${c.cyan(journeyId)} to ${c.cyan(filePath)}.`, 'success' ); return true; @@ -569,16 +570,16 @@ export function getJourneyClassification( return _getJourneyClassification(journey).map((it) => { switch (it) { case 'standard': - return it['brightGreen']; + return c.green(it) as JourneyClassificationType; case 'cloud': - return it['brightMagenta']; + return c.magenta(it) as JourneyClassificationType; case 'custom': - return it['brightRed']; + return c.red(it) as JourneyClassificationType; case 'premium': - return it['brightYellow']; + return c.yellow(it) as JourneyClassificationType; } }); } @@ -614,7 +615,7 @@ export function getJourneyClassificationMd( * @returns {string} a one-line description */ export function getOneLineDescription(treeObj: TreeSkeleton): string { - const description = `[${treeObj._id['brightCyan']}]`; + const description = `[${c.cyan(treeObj._id)}]`; return description; } @@ -649,7 +650,7 @@ function describeTreeDescendents( .fill(' ') .join(''); const [tree] = Object.keys(descendents); - printMessage(`${indent}- ${tree['brightCyan']}`, 'data'); + printMessage(`${indent}- ${c.cyan(tree)}`, 'data'); for (const descendent of descendents[tree]) { describeTreeDescendents(descendent, depth + 1); } @@ -742,8 +743,8 @@ export async function describeJourney( printMessage( `\nStatus\n${ journeyData.tree.enabled === false - ? 'disabled'['brightRed'] - : 'enabled'['brightGreen'] + ? c.red('disabled') + : c.green('enabled') }` ); @@ -786,9 +787,9 @@ export async function describeJourney( ); for (const [nodeType, count] of Object.entries(nodeTypeMap)) { printMessage( - `- ${String(count)} [${ - nodeType['brightCyan'] - }] (${Node.getNodeClassification(nodeType).join(', ')})`, + `- ${String(count)} [${c.cyan( + nodeType + )}] (${Node.getNodeClassification(nodeType).join(', ')})`, 'data' ); } diff --git a/src/ops/MappingOps.ts b/src/ops/MappingOps.ts index 1d56aca38..0470f6183 100644 --- a/src/ops/MappingOps.ts +++ b/src/ops/MappingOps.ts @@ -7,6 +7,7 @@ import { SyncSkeleton, } from '@rockcarver/frodo-lib/types/ops/MappingOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { extractDataToFile, getExtractedJsonData } from '../utils/Config'; import { @@ -65,10 +66,8 @@ export async function listMappings(long: boolean = false): Promise { mapping.displayName, mapping.source, mapping.target, - mapping.consentRequired ? 'yes'['brightGreen'] : 'no'['brightRed'], - isLegacyMapping(mapping._id) - ? 'yes'['brightGreen'] - : 'no'['brightRed'], + mapping.consentRequired ? c.green('yes') : c.red('no'), + isLegacyMapping(mapping._id) ? c.green('yes') : c.red('no'), ]); } printMessage(table.toString(), 'data'); diff --git a/src/ops/NodeOps.ts b/src/ops/NodeOps.ts index b22155193..398d399e2 100644 --- a/src/ops/NodeOps.ts +++ b/src/ops/NodeOps.ts @@ -4,6 +4,7 @@ import { type NodeRefSkeletonInterface, type NodeSkeleton, } from '@rockcarver/frodo-lib/types/api/NodeApi'; +import c from 'tinyrainbow'; const { getNodeClassification: _getNodeClassification } = frodo.authn.node; @@ -16,22 +17,22 @@ export function getNodeClassification(nodeType: string): string[] { return _getNodeClassification(nodeType).map((it) => { switch (it) { case 'standard': - return it.toString()['brightGreen']; + return c.green(it.toString()); case 'cloud': - return it.toString()['brightMagenta']; + return c.magenta(it.toString()); case 'custom': - return it.toString()['brightRed']; + return c.red(it.toString()); case 'excluded': - return it.toString()['brightRed']; + return c.red(it.toString()); case 'premium': - return it.toString()['brightYellow']; + return c.yellow(it.toString()); case 'deprecated': - return it.toString()['brightYellow']; + return c.yellow(it.toString()); } }); } @@ -75,7 +76,7 @@ export function getOneLineDescription( nodeObj: NodeSkeleton, nodeRef?: NodeRefSkeletonInterface | InnerNodeRefSkeletonInterface ): string { - const description = `[${nodeObj._id['brightCyan']}] (${getNodeClassification( + const description = `[${c.cyan(nodeObj._id)}] (${getNodeClassification( nodeObj._type._id ).join(', ')}) ${nodeObj._type._id}${ nodeRef ? ' - ' + nodeRef?.displayName : '' diff --git a/src/ops/OAuth2ClientOps.ts b/src/ops/OAuth2ClientOps.ts index 7584716e4..bb7713fbb 100644 --- a/src/ops/OAuth2ClientOps.ts +++ b/src/ops/OAuth2ClientOps.ts @@ -6,6 +6,7 @@ import { type OAuth2ClientImportOptions, } from '@rockcarver/frodo-lib/types/ops/OAuth2ClientOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createProgressIndicator, @@ -73,8 +74,8 @@ export async function listOAuth2Clients(long = false) { table.push([ client._id, client.coreOAuth2ClientConfig.status === 'Active' - ? 'Active'['brightGreen'] - : (client.coreOAuth2ClientConfig.status as string)['brightRed'], + ? c.green('Active') + : (c.cyan(client.coreOAuth2ClientConfig.status) as string), client.coreOAuth2ClientConfig.clientType, (client.advancedOAuth2ClientConfig.grantTypes as Readable) .map((type) => grantTypesMap[type]) @@ -84,7 +85,7 @@ export async function listOAuth2Clients(long = false) { ), (client.coreOAuth2ClientConfig.redirectionUris as string[]).join( '\n' - ), + ) as any, // wordwrap(client.description, 30), ]); }); diff --git a/src/ops/PolicyOps.ts b/src/ops/PolicyOps.ts index 82b8bc5a2..80bd6780d 100644 --- a/src/ops/PolicyOps.ts +++ b/src/ops/PolicyOps.ts @@ -6,6 +6,7 @@ import type { PolicyImportOptions, } from '@rockcarver/frodo-lib/types/ops/PolicyOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createObjectTable, @@ -57,7 +58,7 @@ export async function listPolicies(long: boolean = false): Promise { table.push([ `${policy._id}`, `${policy.description}`, - policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'], + policy.active ? c.green('active') : c.red('inactive'), ]); } printMessage(table.toString(), 'data'); @@ -93,7 +94,7 @@ export async function listPoliciesByPolicySet( table.push([ `${policy._id}`, `${policy.description}`, - policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'], + policy.active ? c.green('active') : c.red('inactive'), ]); } printMessage(table.toString(), 'data'); diff --git a/src/ops/RealmOps.ts b/src/ops/RealmOps.ts index cc59f775c..05588e331 100644 --- a/src/ops/RealmOps.ts +++ b/src/ops/RealmOps.ts @@ -1,6 +1,7 @@ import { frodo, FrodoError } from '@rockcarver/frodo-lib'; import { RealmExportInterface } from '@rockcarver/frodo-lib/types/ops/RealmOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createKeyValueTable, @@ -39,19 +40,17 @@ export async function listRealms(long = false) { const realms = await readRealms(); if (long) { const table = createTable([ - 'Id'['brightCyan'], - 'Name'['brightCyan'], - 'Status'['brightCyan'], - 'Custom Domains'['brightCyan'], - 'Parent Path'['brightCyan'], + c.cyan('Id'), + c.cyan('Name'), + c.cyan('Status'), + c.cyan('Custom Domains'), + c.cyan('Parent Path'), ]); realms.forEach((realmConfig) => { table.push([ realmConfig._id, realmConfig.name, - realmConfig.active - ? 'active'['brightGreen'] - : 'inactive'['brightRed'], + realmConfig.active ? c.green('active') : c.red('inactive'), realmConfig.aliases.join('\n'), realmConfig.parentPath, ]); @@ -338,17 +337,14 @@ export async function describeRealm(realm: string) { try { const realmConfig = await readRealmByName(realm); const table = createKeyValueTable(); - table.push(['Name'['brightCyan'], realmConfig.name]); + table.push([c.cyan('Name'), realmConfig.name]); table.push([ - 'Status'['brightCyan'], - realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed'], + c.cyan('Status'), + realmConfig.active ? c.green('active') : c.red('inactive'), ]); - table.push([ - 'Custom Domains'['brightCyan'], - realmConfig.aliases.join('\n'), - ]); - table.push(['Parent'['brightCyan'], realmConfig.parentPath]); - table.push(['Id'['brightCyan'], realmConfig._id]); + table.push([c.cyan('Custom Domains'), realmConfig.aliases.join('\n')]); + table.push([c.cyan('Parent'), realmConfig.parentPath]); + table.push([c.cyan('Id'), realmConfig._id]); printMessage(table.toString(), 'data'); } catch (error) { printMessage(`Realm ${realm} not found!`, 'error'); @@ -374,19 +370,14 @@ export async function addCustomDomain(realm: string, domain: string) { realmConfig.aliases.push(domain.toLowerCase()); realmConfig = await updateRealm(realmConfig._id, realmConfig); const table = createKeyValueTable(); - table.push(['Name'['brightCyan'], realmConfig.name]); - table.push([ - 'Status'['brightCyan'], - realmConfig.active - ? 'active'['brightGreen'] - : 'inactive'['brightRed'], - ]); + table.push([c.cyan('Name'), realmConfig.name]); table.push([ - 'Custom Domains'['brightCyan'], - realmConfig.aliases.join('\n'), + c.cyan('Status'), + realmConfig.active ? c.green('active') : c.red('inactive'), ]); - table.push(['Parent'['brightCyan'], realmConfig.parentPath]); - table.push(['Id'['brightCyan'], realmConfig._id]); + table.push([c.cyan('Custom Domains'), realmConfig.aliases.join('\n')]); + table.push([c.cyan('Parent'), realmConfig.parentPath]); + table.push([c.cyan('Id'), realmConfig._id]); printMessage(table.toString()); } catch (error) { printMessage(`Error adding custom domain: ${error.message}`, 'error'); @@ -413,19 +404,14 @@ export async function removeCustomDomain(realm: string, domain: string) { realmConfig.aliases = aliases; realmConfig = await updateRealm(realmConfig._id, realmConfig); const table = createKeyValueTable(); - table.push(['Name'['brightCyan'], realmConfig.name]); - table.push([ - 'Status'['brightCyan'], - realmConfig.active - ? 'active'['brightGreen'] - : 'inactive'['brightRed'], - ]); + table.push([c.cyan('Name'), realmConfig.name]); table.push([ - 'Custom Domains'['brightCyan'], - realmConfig.aliases.join('\n'), + c.cyan('Status'), + realmConfig.active ? c.green('active') : c.red('inactive'), ]); - table.push(['Parent'['brightCyan'], realmConfig.parentPath]); - table.push(['Id'['brightCyan'], realmConfig._id]); + table.push([c.cyan('Custom Domains'), realmConfig.aliases.join('\n')]); + table.push([c.cyan('Parent'), realmConfig.parentPath]); + table.push([c.cyan('Id'), realmConfig._id]); printMessage(table.toString()); } catch (error) { printMessage(`Error removing custom domain: ${error.message}`, 'error'); diff --git a/src/ops/Saml2Ops.ts b/src/ops/Saml2Ops.ts index f707f8c6e..7ff1945ce 100644 --- a/src/ops/Saml2Ops.ts +++ b/src/ops/Saml2Ops.ts @@ -6,6 +6,7 @@ import type { Saml2ExportInterface, } from '@rockcarver/frodo-lib/types/ops/Saml2Ops'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createObjectTable, @@ -55,7 +56,7 @@ export function getOneLineDescription( roles.push(value); } } - const description = `[${saml2ProviderObj.entityId['brightCyan']}]${ + const description = `[${c.cyan(saml2ProviderObj.entityId)}]${ ' (' + saml2ProviderObj.entityLocation }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`; return description; @@ -108,9 +109,9 @@ export async function listSaml2Providers( return true; } else { const table = createTable([ - 'Entity Id'['brightCyan'], - 'Location'['brightCyan'], - 'Role(s)'['brightCyan'], + c.cyan('Entity Id'), + c.cyan('Location'), + c.cyan('Role(s)'), ]); for (const provider of providerList) { table.push([ @@ -182,7 +183,7 @@ export async function exportSaml2MetadataToFile( updateProgressIndicator(indicatorId, `Exported provider ${entityId}`); stopProgressIndicator( indicatorId, - `Exported ${entityId['brightCyan']} metadata to ${filePath['brightCyan']}.` + `Exported ${c.cyan(entityId)} metadata to ${c.cyan(filePath)}.` ); return true; } catch (error) { diff --git a/src/ops/ScriptOps.ts b/src/ops/ScriptOps.ts index 7ac1f1922..1c49a61aa 100644 --- a/src/ops/ScriptOps.ts +++ b/src/ops/ScriptOps.ts @@ -8,6 +8,7 @@ import { } from '@rockcarver/frodo-lib/types/ops/ScriptOps'; import chokidar from 'chokidar'; import fs from 'fs'; +import c from 'tinyrainbow'; import { extractDataToFile, @@ -68,7 +69,7 @@ type SeparatedScripts = { * @returns {string} a one-line description */ export function getOneLineDescription(scriptObj: ScriptSkeleton): string { - const description = `[${scriptObj._id['brightCyan']}] ${scriptObj.context} - ${scriptObj.name}`; + const description = `[${c.cyan(scriptObj._id)}] ${scriptObj.context} - ${scriptObj.name}`; return description; } @@ -169,8 +170,8 @@ export async function listScripts( ); values.push( locations.length > 0 - ? `${'yes'['brightGreen']} (${locations.length === 1 ? `at` : `${locations.length} uses, including:`} ${locations[0]})` - : 'no'['brightRed'] + ? `${c.green('yes')} (${locations.length === 1 ? `at` : `${locations.length} uses, including:`} ${locations[0]})` + : c.red('no') ); } table.push(values); @@ -223,29 +224,29 @@ export async function describeScript( printMessage(script, 'data'); } else { const table = createKeyValueTable(); - table.push(['Id'['brightCyan'], script._id]); - table.push(['Name'['brightCyan'], script.name]); - table.push(['Language'['brightCyan'], langMap[script.language]]); + table.push([c.cyan('Id'), script._id]); + table.push([c.cyan('Name'), script.name]); + table.push([c.cyan('Language'), langMap[script.language]]); table.push([ - 'Context'['brightCyan'], + c.cyan('Context'), titleCase(script.context.split('_').join(' ')), ]); - table.push(['Description'['brightCyan'], script.description]); + table.push([c.cyan('Description'), script.description]); table.push([ - 'Default'['brightCyan'], - script.default ? 'true'['brightGreen'] : 'false'['brightRed'], + c.cyan('Default'), + script.default ? c.green('true') : c.red('false'), ]); - table.push(['Evaluator Version'['brightCyan'], script.evaluatorVersion]); + table.push([c.cyan('Evaluator Version'), script.evaluatorVersion]); const scriptWrapLength = 80; const wrapRegex = new RegExp(`.{1,${scriptWrapLength + 1}}`, 'g'); const scriptParts = script.script.match(wrapRegex); - table.push(['Script (Base 64)'['brightCyan'], scriptParts[0]]); + table.push([c.cyan('Script (Base 64)'), scriptParts[0]]); for (let i = 1; i < scriptParts.length; i++) { table.push(['', scriptParts[i]]); } if (usage) { table.push([ - `Usage Locations (${script.locations.length} total)`['brightCyan'], + c.cyan(`Usage Locations (${script.locations.length} total)`), script.locations.length > 0 ? script.locations[0] : '', ]); for (let i = 1; i < script.locations.length; i++) { diff --git a/src/ops/ThemeOps.ts b/src/ops/ThemeOps.ts index 8bbe91df1..59efa0115 100644 --- a/src/ops/ThemeOps.ts +++ b/src/ops/ThemeOps.ts @@ -4,6 +4,7 @@ import { type ThemeSkeleton, } from '@rockcarver/frodo-lib/types/ops/ThemeOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { v4 as uuidv4 } from 'uuid'; import { @@ -42,9 +43,9 @@ const { * @returns {string} a one-line description */ export function getOneLineDescription(themeObj: ThemeSkeleton): string { - const description = `[${themeObj._id['brightCyan']}] ${themeObj.name}${ + const description = `[${c.cyan(themeObj._id)}] ${themeObj.name}${ themeObj.linkedTrees - ? ' (' + themeObj.linkedTrees.join(', ')['brightCyan'] + ')' + ? ' (' + c.cyan(themeObj.linkedTrees.join(', ')) + ')' : '' }`; return description; @@ -85,21 +86,21 @@ export async function listThemes(long: boolean = false): Promise { if (!long) { themeList.forEach((theme) => { printMessage( - `${theme.isDefault ? theme.name['brightCyan'] : theme.name}`, + `${theme.isDefault ? c.cyan(theme.name) : theme.name}`, 'data' ); }); } else { const table = createTable([ - 'Name'['brightCyan'], - 'Id'['brightCyan'], - 'Default'['brightCyan'], + c.cyan('Name'), + c.cyan('Id'), + c.cyan('Default'), ]); themeList.forEach((theme) => { table.push([ `${theme.name}`, `${theme._id}`, - `${theme.isDefault ? 'Yes'['brightGreen'] : ''}`, + `${theme.isDefault ? c.green('Yes') : ''}`, ]); }); printMessage(table.toString(), 'data'); diff --git a/src/ops/cloud/AdminFederationOps.ts b/src/ops/cloud/AdminFederationOps.ts index 550154daa..595687bc4 100644 --- a/src/ops/cloud/AdminFederationOps.ts +++ b/src/ops/cloud/AdminFederationOps.ts @@ -1,5 +1,6 @@ import { frodo } from '@rockcarver/frodo-lib'; import fs from 'fs'; +import c from 'tinyrainbow'; import { createProgressIndicator, @@ -70,7 +71,7 @@ export async function exportAdminFederationProviderToFile( saveJsonToFile(fileData, filePath, includeMeta); stopProgressIndicator( indicatorId, - `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.` + `Exported ${c.cyan(providerId)} to ${c.cyan(filePath)}.` ); outcome = true; } catch (err) { diff --git a/src/ops/cloud/SecretsOps.ts b/src/ops/cloud/SecretsOps.ts index e0b74d721..92e0b9f1d 100644 --- a/src/ops/cloud/SecretsOps.ts +++ b/src/ops/cloud/SecretsOps.ts @@ -6,6 +6,7 @@ import { } from '@rockcarver/frodo-lib/types/api/cloud/SecretsApi'; import { SecretsExportInterface } from '@rockcarver/frodo-lib/types/ops/cloud/SecretsOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { getFullExportConfig, getIdLocations } from '../../utils/Config'; import { @@ -85,15 +86,15 @@ export async function listSecrets( let fullExport = null; const headers = long ? [ - 'Id'['brightCyan'], - { hAlign: 'right', content: 'Active\nVersion'['brightCyan'] }, - { hAlign: 'right', content: 'Loaded\nVersion'['brightCyan'] }, - 'Status'['brightCyan'], - 'Description'['brightCyan'], - 'Modifier'['brightCyan'], - 'Modified (UTC)'['brightCyan'], + c.cyan('Id'), + { hAlign: 'right', content: c.cyan('Active\nVersion') }, + { hAlign: 'right', content: c.cyan('Loaded\nVersion') }, + c.cyan('Status'), + c.cyan('Description'), + c.cyan('Modifier'), + c.cyan('Modified (UTC)'), ] - : ['Id'['brightCyan']]; + : [c.cyan('Id')]; if (usage) { try { fullExport = await getFullExportConfig(file); @@ -103,7 +104,7 @@ export async function listSecrets( } //Delete secrets from full export so they aren't mistakenly used for determining usage delete fullExport.global.secret; - headers.push('Used'['brightCyan']); + headers.push(c.cyan('Used')); } const table = createTable(headers); for (const secret of secrets) { @@ -122,7 +123,9 @@ export async function listSecrets( secret._id, { hAlign: 'right', content: secret.activeVersion }, { hAlign: 'right', content: secret.loadedVersion }, - secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], + secret.loaded + ? (c.green('loaded') as any) + : (c.red('unloaded') as any), wordwrap(secret.description, 40), lastChangedBy, new Date(secret.lastChangeDate).toUTCString(), @@ -132,8 +135,8 @@ export async function listSecrets( const locations = getIdLocations(fullExport, secret._id, true); values.push( locations.length > 0 - ? `${'yes'['brightGreen']} (${locations.length === 1 ? `at` : `${locations.length} uses, including:`} ${locations[0]})` - : 'no'['brightRed'] + ? `${c.green('yes')} (${locations.length === 1 ? `at` : `${locations.length} uses, including:`} ${locations[0]})` + : c.red('no') ); } table.push(values); @@ -344,21 +347,21 @@ export async function listSecretVersions( return true; } const table = createTable([ - { hAlign: 'right', content: 'Version'['brightCyan'] }, - 'Status'['brightCyan'], - 'Loaded'['brightCyan'], - 'Created'['brightCyan'], + { hAlign: 'right', content: c.cyan('Version') }, + c.cyan('Status'), + c.cyan('Loaded'), + c.cyan('Created'), ]); const statusMap = { - ENABLED: 'active'['brightGreen'], - DISABLED: 'inactive'['brightRed'], - DESTROYED: 'deleted'['brightRed'], + ENABLED: c.green('active'), + DISABLED: c.red('inactive'), + DESTROYED: c.red('deleted'), }; for (const version of versions) { table.push([ { hAlign: 'right', content: version.version }, statusMap[version.status], - version.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], + version.loaded ? c.green('loaded') : c.red('unloaded'), new Date(version.createDate).toLocaleString(), ]); } @@ -404,19 +407,16 @@ export async function describeSecret( printMessage(secret, 'data'); } else { const table = createKeyValueTable(); - table.push(['Name'['brightCyan'], secret._id]); - table.push(['Active Version'['brightCyan'], secret.activeVersion]); - table.push(['Loaded Version'['brightCyan'], secret.loadedVersion]); + table.push([c.cyan('Name'), secret._id]); + table.push([c.cyan('Active Version'), secret.activeVersion]); + table.push([c.cyan('Loaded Version'), secret.loadedVersion]); table.push([ - 'Status'['brightCyan'], - secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], + c.cyan('Status'), + secret.loaded ? c.green('loaded') : c.red('unloaded'), ]); + table.push([c.cyan('Description'), wordwrap(secret.description, 60)]); table.push([ - 'Description'['brightCyan'], - wordwrap(secret.description, 60), - ]); - table.push([ - 'Modified'['brightCyan'], + c.cyan('Modified'), new Date(secret.lastChangeDate).toLocaleString(), ]); let lastChangedBy = secret.lastChangedBy; @@ -427,16 +427,13 @@ export async function describeSecret( } catch (error) { // ignore } - table.push(['Modifier'['brightCyan'], lastChangedBy]); - table.push(['Modifier UUID'['brightCyan'], secret.lastChangedBy]); - table.push(['Encoding'['brightCyan'], secret.encoding]); - table.push([ - 'Use In Placeholders'['brightCyan'], - secret.useInPlaceholders, - ]); + table.push([c.cyan('Modifier'), lastChangedBy]); + table.push([c.cyan('Modifier UUID'), secret.lastChangedBy]); + table.push([c.cyan('Encoding'), secret.encoding]); + table.push([c.cyan('Use In Placeholders'), secret.useInPlaceholders]); if (usage) { table.push([ - `Usage Locations (${secret.locations.length} total)`['brightCyan'], + c.cyan(`Usage Locations (${secret.locations.length} total)`), secret.locations.length > 0 ? secret.locations[0] : '', ]); for (let i = 1; i < secret.locations.length; i++) { @@ -489,7 +486,7 @@ export async function exportSecretToFile( saveJsonToFile(fileData, filePath, includeMeta); stopProgressIndicator( spinnerId, - `Exported ${secretId['brightCyan']} to ${filePath['brightCyan']}.`, + `Exported ${c.cyan(secretId)} to ${c.cyan(filePath)}.`, 'success' ); debugMessage( diff --git a/src/ops/cloud/VariablesOps.ts b/src/ops/cloud/VariablesOps.ts index fa2d4b30c..344aaee42 100644 --- a/src/ops/cloud/VariablesOps.ts +++ b/src/ops/cloud/VariablesOps.ts @@ -5,6 +5,7 @@ import { } from '@rockcarver/frodo-lib/types/api/cloud/VariablesApi'; import { VariablesExportInterface } from '@rockcarver/frodo-lib/types/ops/cloud/VariablesOps'; import fs from 'fs'; +import c from 'tinyrainbow'; import { getFullExportConfig, getIdLocations } from '../../utils/Config'; import { @@ -83,14 +84,14 @@ export async function listVariables( let fullExport = null; const headers = long ? [ - 'Id'['brightCyan'], - 'Value'['brightCyan'], - 'Status'['brightCyan'], - 'Description'['brightCyan'], - 'Modifier'['brightCyan'], - 'Modified (UTC)'['brightCyan'], + c.cyan('Id'), + c.cyan('Value'), + c.cyan('Status'), + c.cyan('Description'), + c.cyan('Modifier'), + c.cyan('Modified (UTC)'), ] - : ['Id'['brightCyan']]; + : [c.cyan('Id')]; if (usage) { try { fullExport = await getFullExportConfig(file); @@ -101,7 +102,7 @@ export async function listVariables( } //Delete variables from full export so they aren't mistakenly used for determining usage delete fullExport.global.variable; - headers.push('Used'['brightCyan']); + headers.push(c.cyan('Used')); } const table = createTable(headers); for (const variable of variables) { @@ -114,7 +115,7 @@ export async function listVariables( : variable.value, 40 ), - variable.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], + variable.loaded ? c.green('loaded') : c.red('unloaded'), wordwrap(variable.description, 40), state.getUseBearerTokenForAmApis() ? variable.lastChangedBy @@ -126,8 +127,8 @@ export async function listVariables( const locations = getIdLocations(fullExport, variable._id, true); values.push( locations.length > 0 - ? `${'yes'['brightGreen']} (${locations.length === 1 ? `at` : `${locations.length} uses, including:`} ${locations[0]})` - : 'no'['brightRed'] + ? `${c.green('yes')} (${locations.length === 1 ? `at` : `${locations.length} uses, including:`} ${locations[0]})` + : c.red('no') ); } table.push(values); @@ -343,9 +344,9 @@ export async function describeVariable( printMessage(variable, 'data'); } else { const table = createKeyValueTable(); - table.push(['Name'['brightCyan'], variable._id]); + table.push([c.cyan('Name'), variable._id]); table.push([ - 'Value'['brightCyan'], + c.cyan('Value'), wordwrap( variable.valueBase64 ? decodeBase64(variable.valueBase64) @@ -353,17 +354,14 @@ export async function describeVariable( 40 ), ]); - table.push(['Type'['brightCyan'], variable.expressionType]); + table.push([c.cyan('Type'), variable.expressionType]); table.push([ - 'Status'['brightCyan'], - variable.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], + c.cyan('Status'), + variable.loaded ? c.green('loaded') : c.red('unloaded'), ]); + table.push([c.cyan('Description'), wordwrap(variable.description, 60)]); table.push([ - 'Description'['brightCyan'], - wordwrap(variable.description, 60), - ]); - table.push([ - 'Modified'['brightCyan'], + c.cyan('Modified'), new Date(variable.lastChangeDate).toLocaleString(), ]); let modifierName: string; @@ -373,12 +371,12 @@ export async function describeVariable( // ignore } if (modifierName && modifierName !== variable.lastChangedBy) { - table.push(['Modifier'['brightCyan'], modifierName]); + table.push([c.cyan('Modifier'), modifierName]); } - table.push(['Modifier UUID'['brightCyan'], variable.lastChangedBy]); + table.push([c.cyan('Modifier UUID'), variable.lastChangedBy]); if (usage) { table.push([ - `Usage Locations (${variable.locations.length} total)`['brightCyan'], + c.cyan(`Usage Locations (${variable.locations.length} total)`), variable.locations.length > 0 ? variable.locations[0] : '', ]); for (let i = 1; i < variable.locations.length; i++) { @@ -428,13 +426,13 @@ export async function exportVariableToFile( updateProgressIndicator(indicatorId, `Exported variable ${variableId}`); stopProgressIndicator( indicatorId, - `Exported ${variableId['brightCyan']} to ${filePath['brightCyan']}.` + `Exported ${c.cyan(variableId)} to ${c.cyan(filePath)}.` ); return true; } catch (error) { stopProgressIndicator( indicatorId, - `Error exporting variable ${variableId['brightCyan']} to ${filePath['brightCyan']}`, + `Error exporting variable ${c.cyan(variableId)} to ${c.cyan(filePath)}`, 'fail' ); printError(error); @@ -480,7 +478,7 @@ export async function exportVariablesToFile( } catch (error) { stopProgressIndicator( spinnerId, - `Error exporting variables to ${getFilePath(file)['brightCyan']}`, + `Error exporting variables to ${c.cyan(getFilePath(file))}`, 'fail' ); } diff --git a/src/utils/Console.ts b/src/utils/Console.ts index e00d0aa82..b79cde4b7 100644 --- a/src/utils/Console.ts +++ b/src/utils/Console.ts @@ -6,12 +6,10 @@ import { } from '@rockcarver/frodo-lib/types/utils/Console'; import { MultiBar, Presets } from 'cli-progress'; import Table from 'cli-table3'; -import Color from 'colors'; import { createSpinner } from 'nanospinner'; +import c from 'tinyrainbow'; import { v4 as uuidv4 } from 'uuid'; -Color.enable(); - const { appendTextToFile } = frodo.utils; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -66,9 +64,9 @@ function info(message: string | object, newline = true) { if (typeof message === 'object') { console.dir(message, { depth: 3 }); } else if (newline) { - console.error(message['brightCyan']); + console.error(c.cyan(message)); } else { - process.stderr.write(message['brightCyan']); + process.stderr.write(c.cyan(message)); } } @@ -96,9 +94,9 @@ function error(message: string | object, newline = true) { if (typeof message === 'object') { console.dir(message, { depth: 3 }); } else if (newline) { - console.error(message['brightRed']); + console.error(c.red(message)); } else { - process.stderr.write(message['brightRed']); + process.stderr.write(c.red(message)); } } @@ -111,9 +109,9 @@ function debug(message: string | object, newline = true) { if (typeof message === 'object') { console.dir(message, { depth: 6 }); } else if (newline) { - console.error(message['brightMagenta']); + console.error(c.magenta(message)); } else { - process.stderr.write(message['brightMagenta']); + process.stderr.write(c.magenta(message)); } } @@ -123,7 +121,7 @@ function debug(message: string | object, newline = true) { */ function curlirize(message: string) { if (!message) return; - console.error(message['brightBlue']); + console.error(c.blue(message)); } /** @@ -571,7 +569,7 @@ function addRows(object, depth, level, table, keyMap) { if (Object(object[key]) !== object[key]) { if (level === 1) { table.push([ - keyMap[key] ? keyMap[key].brightCyan : key['brightCyan'], + keyMap[key] ? keyMap[key].brightCyan : c.cyan(key), object[key], ]); } else { @@ -592,9 +590,7 @@ function addRows(object, depth, level, table, keyMap) { let indention = new Array(level).fill(space).join(''); if (level < 3) indention = `\n${indention}`; table.push([ - indention.concat( - keyMap[key] ? keyMap[key].brightCyan : key['brightCyan'] - ), + indention.concat(keyMap[key] ? keyMap[key].brightCyan : c.cyan(key)), '', ]); }