@rockcarver/frodo-cli 2.0.0-53 → 2.0.0-55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -17
- package/esm/cli/config/config-export.js +13 -8
- package/esm/cli/config/config-export.js.map +1 -1
- package/esm/cli/config/config-import.js +16 -10
- package/esm/cli/config/config-import.js.map +1 -1
- package/esm/ops/ConfigOps.js +37 -8
- package/esm/ops/ConfigOps.js.map +1 -1
- package/esm/ops/IdmOps.js +6 -1
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +12 -10
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/utils/Config.js +2 -2
- package/esm/utils/Config.js.map +1 -1
- package/esm/utils/Console.js +8 -2
- package/esm/utils/Console.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,27 +9,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
+
- Update to frodo-lib 2.0.0-77
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Improved filtering out secrets from recordings
|
|
17
|
+
- rockcarver/frodo-lib#392: Implemented error handling pattern for methods with unusual amounts of REST calls like `frodo.config.exportFullConfiguration` and `frodo.config.importFullConfiguration` used in the `frodo config import` and `frodo config export` commands
|
|
18
|
+
|
|
19
|
+
## [2.0.0-54] - 2024-04-01
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Update to frodo-lib 2.0.0-75
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- rockcarver/frodo-lib#397: Service accounts now use the proper scopes when created using the `frodo conn save` command
|
|
28
|
+
|
|
29
|
+
## [2.0.0-53] - 2024-03-24
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
12
33
|
- Update to frodo-lib 2.0.0-74
|
|
13
34
|
|
|
14
35
|
### Fixed
|
|
15
36
|
|
|
16
37
|
- rockcarver/frodo-lib#391: Frodo now creates service accounts with all allowed scopes:
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
38
|
+
- `fr:am:*`
|
|
39
|
+
- `fr:idc:analytics:*`
|
|
40
|
+
- `fr:autoaccess:*`
|
|
41
|
+
- `fr:idc:certificate:*`
|
|
42
|
+
- `fr:idc:certificate:read`
|
|
43
|
+
- `fr:idc:content-security-policy:*`
|
|
44
|
+
- `fr:idc:custom-domain:*`
|
|
45
|
+
- `fr:idc:esv:*`
|
|
46
|
+
- `fr:idc:esv:read`
|
|
47
|
+
- `fr:idc:esv:restart`
|
|
48
|
+
- `fr:idc:esv:update`
|
|
49
|
+
- `fr:idm:*`
|
|
50
|
+
- `fr:iga:*`
|
|
51
|
+
- `fr:idc:promotion:*`
|
|
52
|
+
- `fr:idc:release:*`
|
|
53
|
+
- `fr:idc:sso-cookie:*`
|
|
33
54
|
|
|
34
55
|
## [2.0.0-52] - 2024-03-23
|
|
35
56
|
|
|
@@ -1520,7 +1541,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1520
1541
|
- Fixed problem with adding connection profiles
|
|
1521
1542
|
- Miscellaneous bug fixes
|
|
1522
1543
|
|
|
1523
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-
|
|
1544
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-54...HEAD
|
|
1545
|
+
|
|
1546
|
+
[2.0.0-54]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-53...v2.0.0-54
|
|
1547
|
+
|
|
1548
|
+
[2.0.0-53]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-52...v2.0.0-53
|
|
1524
1549
|
|
|
1525
1550
|
[2.0.0-52]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-51...v2.0.0-52
|
|
1526
1551
|
|
|
@@ -12,28 +12,33 @@ async (host, realm, user, password, options, command) => {
|
|
|
12
12
|
// --all -a
|
|
13
13
|
if (options.all && (await getTokens())) {
|
|
14
14
|
verboseMessage('Exporting everything to a single file...');
|
|
15
|
-
await exportEverythingToFile(options.file, options.metadata, {
|
|
15
|
+
const outcome = await exportEverythingToFile(options.file, options.metadata, {
|
|
16
16
|
useStringArrays: options.useStringArrays,
|
|
17
17
|
noDecode: options.decode,
|
|
18
18
|
coords: options.coords,
|
|
19
19
|
includeDefault: options.default
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
if (!outcome) process.exitCode = 1;
|
|
22
|
+
}
|
|
23
|
+
// require --directory -D for all-separate function
|
|
24
|
+
else if (options.allSeparate && !state.getDirectory()) {
|
|
23
25
|
printMessage('-D or --directory required when using -A or --all-separate', 'error');
|
|
24
26
|
program.help();
|
|
25
27
|
process.exitCode = 1;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
}
|
|
29
|
+
// --all-separate -A
|
|
30
|
+
else if (options.allSeparate && (await getTokens())) {
|
|
28
31
|
verboseMessage('Exporting everything to separate files...');
|
|
29
|
-
await exportEverythingToFiles(options.extract, options.metadata, {
|
|
32
|
+
const outcome = await exportEverythingToFiles(options.extract, options.metadata, {
|
|
30
33
|
useStringArrays: options.useStringArrays,
|
|
31
34
|
noDecode: options.decode,
|
|
32
35
|
coords: options.coords,
|
|
33
36
|
includeDefault: options.default
|
|
34
37
|
});
|
|
35
|
-
|
|
36
|
-
}
|
|
38
|
+
if (!outcome) process.exitCode = 1;
|
|
39
|
+
}
|
|
40
|
+
// unrecognized combination of options or no options
|
|
41
|
+
else {
|
|
37
42
|
verboseMessage('Unrecognized combination of options or no options...');
|
|
38
43
|
program.help();
|
|
39
44
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-export.js","names":["state","Option","getTokens","exportEverythingToFile","exportEverythingToFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","metadata","useStringArrays","noDecode","decode","coords","includeDefault","
|
|
1
|
+
{"version":3,"file":"config-export.js","names":["state","Option","getTokens","exportEverythingToFile","exportEverythingToFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","outcome","file","metadata","useStringArrays","noDecode","decode","coords","includeDefault","process","exitCode","allSeparate","getDirectory","help","extract","parse"],"sources":["../../../src/cli/config/config-export.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n exportEverythingToFile,\n exportEverythingToFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst program = new FrodoCommand('frodo config export');\n\nprogram\n .description(\n 'Export full cloud configuration for all ops that currently support export.'\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(new Option('-a, --all', 'Export everything to a single file.'))\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export everything to separate files in the -D directory. Ignored with -a.'\n )\n )\n .addOption(\n new Option(\n '--use-string-arrays',\n 'Where applicable, use string arrays to store multi-line text (e.g. scripts).'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--no-decode',\n 'Do not include decoded variable value in variable export'\n ).default(false, 'false')\n )\n .addOption(\n new Option(\n '-x, --extract',\n 'Extract scripts from the exported file, and save it to a separate file. Ignored with -a.'\n )\n )\n .addOption(\n new Option(\n '-N, --no-metadata',\n 'Does not include metadata in the export file.'\n )\n )\n .addOption(\n new Option(\n '--no-coords',\n 'Do not include the x and y coordinate positions of the journey/tree nodes.'\n )\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Export all scripts including the default scripts.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // --all -a\n if (options.all && (await getTokens())) {\n verboseMessage('Exporting everything to a single file...');\n const outcome = await exportEverythingToFile(\n options.file,\n options.metadata,\n {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\n includeDefault: options.default,\n }\n );\n if (!outcome) process.exitCode = 1;\n }\n // require --directory -D for all-separate function\n else if (options.allSeparate && !state.getDirectory()) {\n printMessage(\n '-D or --directory required when using -A or --all-separate',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting everything to separate files...');\n const outcome = await exportEverythingToFiles(\n options.extract,\n options.metadata,\n {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\n includeDefault: options.default,\n }\n );\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,sBAAsB,EACtBC,uBAAuB,QAClB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,OAAO,GAAG,IAAID,YAAY,CAAC,qBAAqB,CAAC;AAEvDC,OAAO,CACJC,WAAW,CACV,4EACF,CAAC,CACAC,SAAS,C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AAO,CAACN;IAC1B,CACF,CAAC;IACD,IAAI,CAACU,OAAO,EAAEQ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIb,OAAO,CAACc,WAAW,IAAI,CAAC/B,KAAK,CAACgC,YAAY,CAAC,CAAC,EAAE;IACrD3B,YAAY,CACV,4DAA4D,EAC5D,OACF,CAAC;IACDG,OAAO,CAACyB,IAAI,CAAC,CAAC;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;EACA;EAAA,KACK,IAAIb,OAAO,CAACc,WAAW,KAAK,MAAM7B,SAAS,CAAC,CAAC,CAAC,EAAE;IACnDI,cAAc,CAAC,2CAA2C,CAAC;IAC3D,MAAMe,OAAO,GAAG,MAAMjB,uBAAuB,CAC3Ca,OAAO,CAACiB,OAAO,EACfjB,OAAO,CAACM,QAAQ,EAChB;MACEC,eAAe,EAAEP,OAAO,CAACO,eAAe;MACxCC,QAAQ,EAAER,OAAO,CAACS,MAAM;MACxBC,MAAM,EAAEV,OAAO,CAACU,MAAM;MACtBC,cAAc,EAAEX,OAAO,CAACN;IAC1B,CACF,CAAC;IACD,IAAI,CAACU,OAAO,EAAEQ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHxB,cAAc,CAAC,sDAAsD,CAAC;IACtEE,OAAO,CAACyB,IAAI,CAAC,CAAC;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHtB,OAAO,CAAC2B,KAAK,CAAC,CAAC"}
|
|
@@ -14,10 +14,11 @@ async (host, realm, user, password, options, command) => {
|
|
|
14
14
|
printMessage('-f or --file required when using -a or --all', 'error');
|
|
15
15
|
program.help();
|
|
16
16
|
process.exitCode = 1;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
// --all -a
|
|
19
|
+
else if (options.all && (await getTokens())) {
|
|
19
20
|
verboseMessage('Exporting everything from a single file...');
|
|
20
|
-
await importEverythingFromFile(options.file, {
|
|
21
|
+
const outcome = await importEverythingFromFile(options.file, {
|
|
21
22
|
reUuidJourneys: options.reUuidJourneys,
|
|
22
23
|
reUuidScripts: options.reUuidScripts,
|
|
23
24
|
cleanServices: options.clean,
|
|
@@ -25,15 +26,18 @@ async (host, realm, user, password, options, command) => {
|
|
|
25
26
|
realm: options.realm,
|
|
26
27
|
includeDefault: options.default
|
|
27
28
|
});
|
|
28
|
-
|
|
29
|
-
}
|
|
29
|
+
if (!outcome) process.exitCode = 1;
|
|
30
|
+
}
|
|
31
|
+
// require --directory -D for all-separate function
|
|
32
|
+
else if (options.allSeparate && !state.getDirectory()) {
|
|
30
33
|
printMessage('-D or --directory required when using -A or --all-separate', 'error');
|
|
31
34
|
program.help();
|
|
32
35
|
process.exitCode = 1;
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
}
|
|
37
|
+
// --all-separate -A
|
|
38
|
+
else if (options.allSeparate && (await getTokens())) {
|
|
35
39
|
verboseMessage('Importing everything from separate files...');
|
|
36
|
-
await importEverythingFromFiles({
|
|
40
|
+
const outcome = await importEverythingFromFiles({
|
|
37
41
|
reUuidJourneys: options.reUuidJourneys,
|
|
38
42
|
reUuidScripts: options.reUuidScripts,
|
|
39
43
|
cleanServices: options.clean,
|
|
@@ -41,8 +45,10 @@ async (host, realm, user, password, options, command) => {
|
|
|
41
45
|
realm: options.realm,
|
|
42
46
|
includeDefault: options.default
|
|
43
47
|
});
|
|
44
|
-
|
|
45
|
-
}
|
|
48
|
+
if (!outcome) process.exitCode = 1;
|
|
49
|
+
}
|
|
50
|
+
// unrecognized combination of options or no options
|
|
51
|
+
else {
|
|
46
52
|
verboseMessage('Unrecognized combination of options or no options...');
|
|
47
53
|
program.help();
|
|
48
54
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-import.js","names":["state","Option","getTokens","importEverythingFromFile","importEverythingFromFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","help","process","exitCode","reUuidJourneys","reUuidScripts","cleanServices","clean","global","includeDefault","allSeparate","getDirectory","parse"],"sources":["../../../src/cli/config/config-import.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n importEverythingFromFile,\n importEverythingFromFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst program = new FrodoCommand('frodo config import');\n\nprogram\n .description('Import full cloud configuration.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all configuration from the single file -f. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all configuration from separate (.json) files in the (working) directory -D. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option('-g, --global', 'Import service(s) as global service(s).')\n )\n .addOption(\n new Option(\n '-r, --current-realm',\n 'Import service(s) into the current realm.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid-journeys',\n 'Generate new UUIDs for all journey nodes during import.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--re-uuid-scripts',\n 'Create new UUIDs for the scripts upon import. Use this to duplicate scripts or create a new versions of the same scripts.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Import all scripts including the default scripts.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // Require --file -f for all function\n if (options.all && !options.file) {\n printMessage('-f or --file required when using -a or --all', 'error');\n program.help();\n process.exitCode = 1;\n
|
|
1
|
+
{"version":3,"file":"config-import.js","names":["state","Option","getTokens","importEverythingFromFile","importEverythingFromFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","help","process","exitCode","outcome","reUuidJourneys","reUuidScripts","cleanServices","clean","global","includeDefault","allSeparate","getDirectory","parse"],"sources":["../../../src/cli/config/config-import.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n importEverythingFromFile,\n importEverythingFromFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst program = new FrodoCommand('frodo config import');\n\nprogram\n .description('Import full cloud configuration.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all configuration from the single file -f. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all configuration from separate (.json) files in the (working) directory -D. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option('-g, --global', 'Import service(s) as global service(s).')\n )\n .addOption(\n new Option(\n '-r, --current-realm',\n 'Import service(s) into the current realm.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid-journeys',\n 'Generate new UUIDs for all journey nodes during import.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--re-uuid-scripts',\n 'Create new UUIDs for the scripts upon import. Use this to duplicate scripts or create a new versions of the same scripts.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Import all scripts including the default scripts.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // Require --file -f for all function\n if (options.all && !options.file) {\n printMessage('-f or --file required when using -a or --all', 'error');\n program.help();\n process.exitCode = 1;\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting everything from a single file...');\n const outcome = await importEverythingFromFile(options.file, {\n reUuidJourneys: options.reUuidJourneys,\n reUuidScripts: options.reUuidScripts,\n cleanServices: options.clean,\n global: options.global,\n realm: options.realm,\n includeDefault: options.default,\n });\n if (!outcome) process.exitCode = 1;\n }\n // require --directory -D for all-separate function\n else if (options.allSeparate && !state.getDirectory()) {\n printMessage(\n '-D or --directory required when using -A or --all-separate',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Importing everything from separate files...');\n const outcome = await importEverythingFromFiles({\n reUuidJourneys: options.reUuidJourneys,\n reUuidScripts: options.reUuidScripts,\n cleanServices: options.clean,\n global: options.global,\n realm: options.realm,\n includeDefault: options.default,\n });\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,OAAO,GAAG,IAAID,YAAY,CAAC,qBAAqB,CAAC;AAEvDC,OAAO,CACJC,WAAW,CAAC,kCAAkC,CAAC,CAC/CC,SAAS,CAAC,IAAIT,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzES,SAAS,CACR,IAAIT,MAAM,CACR,WAAW,EACX,oEACF,CACF,CAAC,CACAS,SAAS,CACR,IAAIT,MAAM,CACR,oBAAoB,EACpB,4GACF,CACF,CAAC,CACAS,SAAS,CACR,IAAIT,MAAM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K,EAAEG,OAAO,CAACH,KAAK;MACpBiB,cAAc,EAAEd,OAAO,CAACN;IAC1B,CAAC,CAAC;IACF,IAAI,CAACc,OAAO,EAAEF,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIP,OAAO,CAACe,WAAW,IAAI,CAAChC,KAAK,CAACiC,YAAY,CAAC,CAAC,EAAE;IACrD5B,YAAY,CACV,4DAA4D,EAC5D,OACF,CAAC;IACDG,OAAO,CAACc,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;EACA;EAAA,KACK,IAAIP,OAAO,CAACe,WAAW,KAAK,MAAM9B,SAAS,CAAC,CAAC,CAAC,EAAE;IACnDI,cAAc,CAAC,6CAA6C,CAAC;IAC7D,MAAMmB,OAAO,GAAG,MAAMrB,yBAAyB,CAAC;MAC9CsB,cAAc,EAAET,OAAO,CAACS,cAAc;MACtCC,aAAa,EAAEV,OAAO,CAACU,aAAa;MACpCC,aAAa,EAAEX,OAAO,CAACY,KAAK;MAC5BC,MAAM,EAAEb,OAAO,CAACa,MAAM;MACtBhB,KAAK,EAAEG,OAAO,CAACH,KAAK;MACpBiB,cAAc,EAAEd,OAAO,CAACN;IAC1B,CAAC,CAAC;IACF,IAAI,CAACc,OAAO,EAAEF,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHlB,cAAc,CAAC,sDAAsD,CAAC;IACtEE,OAAO,CAACc,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHhB,OAAO,CAAC0B,KAAK,CAAC,CAAC"}
|
package/esm/ops/ConfigOps.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
1
|
+
import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import fse from 'fs-extra';
|
|
4
4
|
import { getFullExportConfig, getFullExportConfigFromDirectory } from '../utils/Config';
|
|
5
|
-
import { printError, printMessage } from '../utils/Console';
|
|
5
|
+
import { cleanupProgressIndicators, printError, printMessage } from '../utils/Console';
|
|
6
6
|
import { extractScriptToFile } from './ScriptOps';
|
|
7
7
|
const {
|
|
8
8
|
getRealmName,
|
|
@@ -25,6 +25,7 @@ const {
|
|
|
25
25
|
* @param {String} file file name
|
|
26
26
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
27
27
|
* @param {FullExportOptions} options export options
|
|
28
|
+
* @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
|
|
28
29
|
*/
|
|
29
30
|
export async function exportEverythingToFile(file, includeMeta = true, options = {
|
|
30
31
|
useStringArrays: true,
|
|
@@ -33,15 +34,21 @@ export async function exportEverythingToFile(file, includeMeta = true, options =
|
|
|
33
34
|
includeDefault: false
|
|
34
35
|
}) {
|
|
35
36
|
try {
|
|
36
|
-
const
|
|
37
|
+
const collectErrors = [];
|
|
38
|
+
const exportData = await exportFullConfiguration(options, collectErrors);
|
|
37
39
|
let fileName = getTypedFilename(`${titleCase(getRealmName(state.getRealm()))}`, `everything`);
|
|
38
40
|
if (file) {
|
|
39
41
|
fileName = file;
|
|
40
42
|
}
|
|
41
43
|
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
44
|
+
if (collectErrors.length > 0) {
|
|
45
|
+
throw new FrodoError(`Errors occurred during full export`, collectErrors);
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
42
48
|
} catch (error) {
|
|
43
49
|
printError(error);
|
|
44
50
|
}
|
|
51
|
+
return false;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
/**
|
|
@@ -49,6 +56,7 @@ export async function exportEverythingToFile(file, includeMeta = true, options =
|
|
|
49
56
|
* @param {boolean} extract Extracts the scripts from the exports into separate files if true
|
|
50
57
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
51
58
|
* @param {FullExportOptions} options export options
|
|
59
|
+
* @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
|
|
52
60
|
*/
|
|
53
61
|
export async function exportEverythingToFiles(extract = false, includeMeta = true, options = {
|
|
54
62
|
useStringArrays: true,
|
|
@@ -57,7 +65,8 @@ export async function exportEverythingToFiles(extract = false, includeMeta = tru
|
|
|
57
65
|
includeDefault: false
|
|
58
66
|
}) {
|
|
59
67
|
try {
|
|
60
|
-
const
|
|
68
|
+
const collectErrors = [];
|
|
69
|
+
const exportData = await exportFullConfiguration(options, collectErrors);
|
|
61
70
|
delete exportData.meta;
|
|
62
71
|
const baseDirectory = getWorkingDirectory(true);
|
|
63
72
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -123,7 +132,7 @@ export async function exportEverythingToFiles(extract = false, includeMeta = tru
|
|
|
123
132
|
});
|
|
124
133
|
}
|
|
125
134
|
} else {
|
|
126
|
-
const filename = getTypedFilename(value && value.name ? value.name : id, type);
|
|
135
|
+
const filename = getTypedFilename(value && value.name && type !== 'emailTemplate' ? value.name : id, type);
|
|
127
136
|
if (extract && type == 'script') {
|
|
128
137
|
extractScriptToFile(exportData, id, type);
|
|
129
138
|
}
|
|
@@ -137,15 +146,21 @@ export async function exportEverythingToFiles(extract = false, includeMeta = tru
|
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
148
|
});
|
|
149
|
+
if (collectErrors.length > 0) {
|
|
150
|
+
throw new FrodoError(`Errors occurred during full export`, collectErrors);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
140
153
|
} catch (error) {
|
|
141
154
|
printError(error);
|
|
142
155
|
}
|
|
156
|
+
return false;
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
/**
|
|
146
160
|
* Import everything from a single file
|
|
147
|
-
* @param {
|
|
161
|
+
* @param {string} file The file path
|
|
148
162
|
* @param {FullImportOptions} options import options
|
|
163
|
+
* @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
|
|
149
164
|
*/
|
|
150
165
|
export async function importEverythingFromFile(file, options = {
|
|
151
166
|
reUuidJourneys: false,
|
|
@@ -157,14 +172,22 @@ export async function importEverythingFromFile(file, options = {
|
|
|
157
172
|
}) {
|
|
158
173
|
try {
|
|
159
174
|
const data = await getFullExportConfig(file);
|
|
160
|
-
|
|
175
|
+
const collectErrors = [];
|
|
176
|
+
await importFullConfiguration(data, options, collectErrors);
|
|
177
|
+
if (collectErrors.length > 0) {
|
|
178
|
+
throw new FrodoError(`Errors occurred during full config import`, collectErrors);
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
161
181
|
} catch (error) {
|
|
182
|
+
cleanupProgressIndicators();
|
|
162
183
|
printError(error);
|
|
163
184
|
}
|
|
185
|
+
return false;
|
|
164
186
|
}
|
|
165
187
|
|
|
166
188
|
/**
|
|
167
189
|
* Import everything from separate files
|
|
190
|
+
* @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
|
|
168
191
|
*/
|
|
169
192
|
export async function importEverythingFromFiles(options = {
|
|
170
193
|
reUuidJourneys: false,
|
|
@@ -176,9 +199,15 @@ export async function importEverythingFromFiles(options = {
|
|
|
176
199
|
}) {
|
|
177
200
|
try {
|
|
178
201
|
const data = await getFullExportConfigFromDirectory(state.getDirectory());
|
|
179
|
-
|
|
202
|
+
const collectErrors = [];
|
|
203
|
+
await importFullConfiguration(data, options, collectErrors);
|
|
204
|
+
if (collectErrors.length > 0) {
|
|
205
|
+
throw new FrodoError(`Errors occurred during full config import`, collectErrors);
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
180
208
|
} catch (error) {
|
|
181
209
|
printError(error);
|
|
182
210
|
}
|
|
211
|
+
return false;
|
|
183
212
|
}
|
|
184
213
|
//# sourceMappingURL=ConfigOps.js.map
|
package/esm/ops/ConfigOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigOps.js","names":["frodo","state","fs","fse","getFullExportConfig","getFullExportConfigFromDirectory","printError","printMessage","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","stringify","json","exportFullConfiguration","importFullConfiguration","config","exportEverythingToFile","file","includeMeta","options","useStringArrays","noDecode","coords","includeDefault","exportData","fileName","getRealm","error","exportEverythingToFiles","extract","meta","baseDirectory","Object","entries","forEach","type","obj","existsSync","mkdirSync","samlData","saml","cot","hosted","metadata","remote","id","value","concat","filename","entityId","samlType","authentication","includes","slice","lastIndexOf","recursive","outputFile","err","name","importEverythingFromFile","reUuidJourneys","reUuidScripts","cleanServices","global","realm","data","importEverythingFromFiles","getDirectory"],"sources":["../../src/ops/ConfigOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport {\n FullExportInterface,\n FullExportOptions,\n FullImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ConfigOps';\nimport { ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\n\nimport {\n getFullExportConfig,\n getFullExportConfigFromDirectory,\n} from '../utils/Config';\nimport { printError, printMessage } from '../utils/Console';\nimport { extractScriptToFile } from './ScriptOps';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst { stringify } = frodo.utils.json;\nconst { exportFullConfiguration, importFullConfiguration } = frodo.config;\n\n/**\n * Export everything to separate files\n * @param {String} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFile(\n file: string,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<void> {\n try {\n const exportData = await exportFullConfiguration(options);\n let fileName = getTypedFilename(\n `${titleCase(getRealmName(state.getRealm()))}`,\n `everything`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n } catch (error) {\n printError(error);\n }\n}\n\n/**\n * Export everything to separate files\n * @param {boolean} extract Extracts the scripts from the exports into separate files if true\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFiles(\n extract: boolean = false,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<void> {\n try {\n const exportData: FullExportInterface =\n await exportFullConfiguration(options);\n delete exportData.meta;\n const baseDirectory = getWorkingDirectory(true);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(exportData).forEach(([type, obj]: [string, any]) => {\n if (obj) {\n if (!fs.existsSync(`${baseDirectory}/${type}`)) {\n fs.mkdirSync(`${baseDirectory}/${type}`);\n }\n if (type == 'saml') {\n const samlData = {\n saml: {\n cot: {},\n hosted: {},\n metadata: {},\n remote: {},\n },\n };\n if (obj.cot) {\n if (!fs.existsSync(`${baseDirectory}/cot`)) {\n fs.mkdirSync(`${baseDirectory}/cot`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj.cot).forEach(([id, value]: [string, any]) => {\n samlData.saml.cot = {\n [id]: value,\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/cot/${getTypedFilename(id, 'cot.saml')}`,\n includeMeta\n );\n });\n samlData.saml.cot = {};\n }\n Object.entries(obj.hosted)\n .concat(Object.entries(obj.remote))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .forEach(([id, value]: [string, any]) => {\n const filename = getTypedFilename(\n value.entityId ? value.entityId : id,\n type\n );\n const samlType = obj.hosted[id] ? 'hosted' : 'remote';\n samlData.saml[samlType][id] = value;\n samlData.saml.metadata = {\n [id]: obj.metadata[id],\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n samlData.saml[samlType] = {};\n });\n } else if (type == 'authentication') {\n const fileName = getTypedFilename(\n `${frodo.utils.getRealmName(state.getRealm())}Realm`,\n 'authentication.settings'\n );\n saveJsonToFile(\n {\n authentication: obj,\n },\n `${baseDirectory}/${type}/${fileName}`,\n includeMeta\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj).forEach(([id, value]: [string, any]) => {\n if (type == 'config') {\n if (value != null) {\n const filename = `${id}.json`;\n if (filename.includes('/')) {\n fs.mkdirSync(\n `${baseDirectory}/${type}/${filename.slice(\n 0,\n filename.lastIndexOf('/')\n )}`,\n {\n recursive: true,\n }\n );\n }\n fse.outputFile(\n `${baseDirectory}/${type}/${filename}`,\n stringify(value),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n } else {\n const filename = getTypedFilename(\n value && value.name ? value.name : id,\n type\n );\n if (extract && type == 'script') {\n extractScriptToFile(\n exportData as ScriptExportInterface,\n id,\n type\n );\n }\n saveJsonToFile(\n {\n [type]: {\n [id]: value,\n },\n },\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n }\n });\n }\n }\n });\n } catch (error) {\n printError(error);\n }\n}\n\n/**\n * Import everything from a single file\n * @param {String} file The file path\n * @param {FullImportOptions} options import options\n */\nexport async function importEverythingFromFile(\n file: string,\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n) {\n try {\n const data = await getFullExportConfig(file);\n await importFullConfiguration(data, options);\n } catch (error) {\n printError(error);\n }\n}\n\n/**\n * Import everything from separate files\n */\nexport async function importEverythingFromFiles(\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n) {\n try {\n const data = await getFullExportConfigFromDirectory(state.getDirectory());\n await importFullConfiguration(data, options);\n } catch (error) {\n printError(error);\n }\n}\n"],"mappings":"AAAA,SAASA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,aAAc,IAAGI,IAAK,IAAGa,QAAS,EAAC,EACtC9B,WACF,CAAC;YACH;UACF,CAAC,CAAC;QACJ;MACF;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,OAAOS,KAAK,EAAE;IACd1B,UAAU,CAAC0B,KAAK,CAAC;EACnB;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAegC,wBAAwBA,CAC5C1C,IAAY,EACZE,OAA0B,GAAG;EAC3ByC,cAAc,EAAE,KAAK;EACrBC,aAAa,EAAE,KAAK;EACpBC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE,KAAK;EACZzC,cAAc,EAAE;AAClB,CAAC,EACD;EACA,IAAI;IACF,MAAM0C,IAAI,GAAG,MAAMlE,mBAAmB,CAACkB,IAAI,CAAC;IAC5C,MAAMH,uBAAuB,CAACmD,IAAI,EAAE9C,OAAO,CAAC;EAC9C,CAAC,CAAC,OAAOQ,KAAK,EAAE;IACd1B,UAAU,CAAC0B,KAAK,CAAC;EACnB;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeuC,yBAAyBA,CAC7C/C,OAA0B,GAAG;EAC3ByC,cAAc,EAAE,KAAK;EACrBC,aAAa,EAAE,KAAK;EACpBC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE,KAAK;EACZzC,cAAc,EAAE;AAClB,CAAC,EACD;EACA,IAAI;IACF,MAAM0C,IAAI,GAAG,MAAMjE,gCAAgC,CAACJ,KAAK,CAACuE,YAAY,CAAC,CAAC,CAAC;IACzE,MAAMrD,uBAAuB,CAACmD,IAAI,EAAE9C,OAAO,CAAC;EAC9C,CAAC,CAAC,OAAOQ,KAAK,EAAE;IACd1B,UAAU,CAAC0B,KAAK,CAAC;EACnB;AACF"}
|
|
1
|
+
{"version":3,"file":"ConfigOps.js","names":["frodo","FrodoError","state","fs","fse","getFullExportConfig","getFullExportConfigFromDirectory","cleanupProgressIndicators","printError","printMessage","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","stringify","json","exportFullConfiguration","importFullConfiguration","config","exportEverythingToFile","file","includeMeta","options","useStringArrays","noDecode","coords","includeDefault","collectErrors","exportData","fileName","getRealm","length","error","exportEverythingToFiles","extract","meta","baseDirectory","Object","entries","forEach","type","obj","existsSync","mkdirSync","samlData","saml","cot","hosted","metadata","remote","id","value","concat","filename","entityId","samlType","authentication","includes","slice","lastIndexOf","recursive","outputFile","err","name","importEverythingFromFile","reUuidJourneys","reUuidScripts","cleanServices","global","realm","data","importEverythingFromFiles","getDirectory"],"sources":["../../src/ops/ConfigOps.ts"],"sourcesContent":["import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';\nimport {\n FullExportInterface,\n FullExportOptions,\n FullImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ConfigOps';\nimport { ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\n\nimport {\n getFullExportConfig,\n getFullExportConfigFromDirectory,\n} from '../utils/Config';\nimport { cleanupProgressIndicators, printError, printMessage } from '../utils/Console';\nimport { extractScriptToFile } from './ScriptOps';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst { stringify } = frodo.utils.json;\nconst { exportFullConfiguration, importFullConfiguration } = frodo.config;\n\n/**\n * Export everything to separate files\n * @param {String} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportEverythingToFile(\n file: string,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const collectErrors: Error[] = [];\n const exportData = await exportFullConfiguration(options, collectErrors);\n let fileName = getTypedFilename(\n `${titleCase(getRealmName(state.getRealm()))}`,\n `everything`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n if (collectErrors.length > 0) {\n throw new FrodoError(`Errors occurred during full export`, collectErrors);\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export everything to separate files\n * @param {boolean} extract Extracts the scripts from the exports into separate files if true\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportEverythingToFiles(\n extract: boolean = false,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const collectErrors: Error[] = [];\n const exportData: FullExportInterface = await exportFullConfiguration(\n options,\n collectErrors\n );\n delete exportData.meta;\n const baseDirectory = getWorkingDirectory(true);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(exportData).forEach(([type, obj]: [string, any]) => {\n if (obj) {\n if (!fs.existsSync(`${baseDirectory}/${type}`)) {\n fs.mkdirSync(`${baseDirectory}/${type}`);\n }\n if (type == 'saml') {\n const samlData = {\n saml: {\n cot: {},\n hosted: {},\n metadata: {},\n remote: {},\n },\n };\n if (obj.cot) {\n if (!fs.existsSync(`${baseDirectory}/cot`)) {\n fs.mkdirSync(`${baseDirectory}/cot`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj.cot).forEach(([id, value]: [string, any]) => {\n samlData.saml.cot = {\n [id]: value,\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/cot/${getTypedFilename(id, 'cot.saml')}`,\n includeMeta\n );\n });\n samlData.saml.cot = {};\n }\n Object.entries(obj.hosted)\n .concat(Object.entries(obj.remote))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .forEach(([id, value]: [string, any]) => {\n const filename = getTypedFilename(\n value.entityId ? value.entityId : id,\n type\n );\n const samlType = obj.hosted[id] ? 'hosted' : 'remote';\n samlData.saml[samlType][id] = value;\n samlData.saml.metadata = {\n [id]: obj.metadata[id],\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n samlData.saml[samlType] = {};\n });\n } else if (type == 'authentication') {\n const fileName = getTypedFilename(\n `${frodo.utils.getRealmName(state.getRealm())}Realm`,\n 'authentication.settings'\n );\n saveJsonToFile(\n {\n authentication: obj,\n },\n `${baseDirectory}/${type}/${fileName}`,\n includeMeta\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj).forEach(([id, value]: [string, any]) => {\n if (type == 'config') {\n if (value != null) {\n const filename = `${id}.json`;\n if (filename.includes('/')) {\n fs.mkdirSync(\n `${baseDirectory}/${type}/${filename.slice(\n 0,\n filename.lastIndexOf('/')\n )}`,\n {\n recursive: true,\n }\n );\n }\n fse.outputFile(\n `${baseDirectory}/${type}/${filename}`,\n stringify(value),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n } else {\n const filename = getTypedFilename(\n value && value.name && type !== 'emailTemplate'\n ? value.name\n : id,\n type\n );\n if (extract && type == 'script') {\n extractScriptToFile(\n exportData as ScriptExportInterface,\n id,\n type\n );\n }\n saveJsonToFile(\n {\n [type]: {\n [id]: value,\n },\n },\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n }\n });\n }\n }\n });\n if (collectErrors.length > 0) {\n throw new FrodoError(`Errors occurred during full export`, collectErrors);\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import everything from a single file\n * @param {string} file The file path\n * @param {FullImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importEverythingFromFile(\n file: string,\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const data = await getFullExportConfig(file);\n const collectErrors: Error[] = [];\n await importFullConfiguration(data, options, collectErrors);\n if (collectErrors.length > 0) {\n throw new FrodoError(\n `Errors occurred during full config import`,\n collectErrors\n );\n }\n return true;\n } catch (error) {\n cleanupProgressIndicators();\n printError(error);\n }\n return false;\n}\n\n/**\n * Import everything from separate files\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importEverythingFromFiles(\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const data = await getFullExportConfigFromDirectory(state.getDirectory());\n const collectErrors: Error[] = [];\n await importFullConfiguration(data, options, collectErrors);\n if (collectErrors.length > 0) {\n throw new FrodoError(\n `Errors occurred during full config import`,\n collectErrors\n );\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,EAAEC,KAAK,QAAQ,uBAAuB;AAOhE,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAE1B,SACEC,mBAAmB,EACnBC,gCAAgC,QAC3B,iBAAiB;AACxB,SAASC,yBAAyB,EAAEC,UAAU,EAAEC,YAAY,QAAQ,kBAAkB;AACtF,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,MAAM;EACJC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGhB,KAAK,CAACiB,KAAK;AACf,MAAM;EAAEC;AAAU,CAAC,GAAGlB,KAAK,CAACiB,KAAK,CAACE,IAAI;AACtC,MAAM;EAAEC,uBAAuB;EAAEC;AAAwB,CAAC,GAAGrB,KAAK,CAACsB,MAAM;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAA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IA,aAAa,CAACI,MAAM,GAAG,CAAC,EAAE;MAC5B,MAAM,IAAIlC,UAAU,CACjB,2CAA0C,EAC3C8B,aACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOK,KAAK,EAAE;IACd5B,UAAU,CAAC4B,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd"}
|
package/esm/ops/IdmOps.js
CHANGED
|
@@ -197,8 +197,11 @@ export async function importConfigEntityByIdFromFile(entityId, file, validate) {
|
|
|
197
197
|
* @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
|
|
198
198
|
*/
|
|
199
199
|
export async function importConfigEntityFromFile(file, validate) {
|
|
200
|
+
const filePath = getFilePath(file);
|
|
201
|
+
let indicatorId;
|
|
200
202
|
try {
|
|
201
|
-
|
|
203
|
+
indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${filePath}...`);
|
|
204
|
+
const fileData = fs.readFileSync(path.resolve(process.cwd(), filePath), 'utf8');
|
|
202
205
|
const entityData = JSON.parse(fileData);
|
|
203
206
|
const entityId = entityData._id;
|
|
204
207
|
const isValid = areScriptHooksValid(entityData);
|
|
@@ -207,8 +210,10 @@ export async function importConfigEntityFromFile(file, validate) {
|
|
|
207
210
|
return;
|
|
208
211
|
}
|
|
209
212
|
await updateConfigEntity(entityId, entityData);
|
|
213
|
+
stopProgressIndicator(indicatorId, `Imported ${entityId} from ${filePath}.`, 'success');
|
|
210
214
|
return true;
|
|
211
215
|
} catch (error) {
|
|
216
|
+
stopProgressIndicator(indicatorId, `Error importing ${filePath}.`, 'fail');
|
|
212
217
|
printError(error);
|
|
213
218
|
}
|
|
214
219
|
return false;
|
package/esm/ops/IdmOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdmOps.js","names":["frodo","FrodoError","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printError","printMessage","stopProgressIndicator","stringify","utils","json","unSubstituteEnvParams","areScriptHooksValid","getFilePath","getTypedFilename","readFiles","getWorkingDirectory","readConfigEntities","readConfigEntity","exportConfigEntities","updateConfigEntity","importConfigEntities","idm","config","queryManagedObjects","managed","testConnectorServers","system","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","listAllConfigEntities","configurations","configEntity","_id","exportConfigEntity","id","file","fileName","writeFile","err","exportAllRawConfigEntities","exportedConfigurations","value","Object","entries","outputFile","exportAllConfigEntities","entitiesFile","envFile","errors","entriesToExport","data","readFileSync","entriesData","JSON","parse","envParams","undefined","entityPromises","includes","push","results","Promise","item","configEntityString","each","key","outputFileSync","importConfigEntityByIdFromFile","entityId","validate","fileData","resolve","process","cwd","entityData","isValid","importConfigEntityFromFile","importAllRawConfigEntities","options","indicatorId","baseDirectory","files","jsonObjects","toLowerCase","endsWith","content","entity","importData","fromEntries","importAllConfigEntities","entriesToImport","envReader","countManagedObjects","type","result"],"sources":["../../src/ops/IdmOps.ts"],"sourcesContent":["import { frodo, FrodoError } from '@rockcarver/frodo-lib';\nimport { type ConfigEntityImportOptions } from '@rockcarver/frodo-lib/types/ops/IdmConfigOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport {\n createProgressIndicator,\n printError,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\n\nconst { stringify } = frodo.utils.json;\n\nconst {\n unSubstituteEnvParams,\n areScriptHooksValid,\n getFilePath,\n getTypedFilename,\n readFiles,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readConfigEntities,\n readConfigEntity,\n exportConfigEntities,\n updateConfigEntity,\n importConfigEntities,\n} = frodo.idm.config;\nconst { queryManagedObjects } = frodo.idm.managed;\nconst { testConnectorServers } = frodo.idm.system;\n\n/**\n * Warn about and list offline remote connector servers\n * @return {Promise<boolean>} a promise that resolves to true if a warning was printed, false otherwise\n */\nexport async function warnAboutOfflineConnectorServers(): Promise<boolean> {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length > 0) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n return true;\n }\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * List all IDM configuration objects\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function listAllConfigEntities(): Promise<boolean> {\n try {\n const configurations = await readConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export an IDM configuration object.\n * @param {string} id the desired configuration object\n * @param {string} file optional export file\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportConfigEntity(\n id: string,\n file: string\n): Promise<boolean> {\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await readConfigEntity(id);\n fs.writeFile(\n getFilePath(fileName, true),\n stringify(configEntity),\n (err) => {\n if (err) {\n printError(err, `Error exporting config entity ${id}`);\n }\n }\n );\n return true;\n } catch (error) {\n printError(error, `Error exporting config entity ${id}`);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllRawConfigEntities() {\n try {\n const exportedConfigurations = await exportConfigEntities();\n for (const [id, value] of Object.entries(exportedConfigurations.config)) {\n if (value != null) {\n fse.outputFile(\n getFilePath(`${id}.json`, true),\n stringify(value),\n (err) => {\n if (err) {\n printError(err, `Error exporting raw config entity ${id}`);\n }\n }\n );\n }\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllConfigEntities(\n entitiesFile: string,\n envFile: string\n): Promise<boolean> {\n const errors: Error[] = [];\n try {\n let entriesToExport = [];\n // read list of entities to export\n const data = fs.readFileSync(entitiesFile, 'utf8');\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n const configurations = await readConfigEntities();\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(readConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n try {\n let configEntityString = stringify(item);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFileSync(\n getFilePath(`${item._id}.json`, true),\n configEntityString\n );\n } catch (error) {\n errors.push(\n new FrodoError(`Error saving config entity ${item._id}`, error)\n );\n }\n }\n }\n if (errors.length > 0) {\n throw new FrodoError(`Error saving config entities`, errors);\n }\n stopProgressIndicator(null, 'success');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param {string} entityId the configuration object to import\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n): Promise<boolean> {\n try {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n\n const entityData = JSON.parse(fileData);\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import IDM configuration object from file.\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n): Promise<boolean> {\n try {\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllRawConfigEntities(\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n) {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) => JSON.parse(content))\n .map((entity) => [entity._id, entity]);\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllConfigEntities(\n entitiesFile: string,\n envFile: string,\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n): Promise<boolean> {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const entriesToImport = JSON.parse(\n fs.readFileSync(entitiesFile, 'utf8')\n ).idm;\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) =>\n JSON.parse(unSubstituteEnvParams(content, envReader))\n )\n .filter((entity) => entriesToImport.includes(entity._id))\n .map((entity) => [entity._id, entity]);\n\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function countManagedObjects(type: string): Promise<boolean> {\n try {\n const result = await queryManagedObjects(type);\n printMessage(`${type}: ${result.length}`, 'data');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,QAAQ,uBAAuB;AAEzD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,uBAAuB,EACvBC,UAAU,EACVC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AAEzB,MAAM;EAAEC;AAAU,CAAC,GAAGX,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E,IAAI,CAAC;IAC9CjG,YAAY,CAAE,GAAEiG,IAAK,KAAIC,MAAM,CAACpE,MAAO,EAAC,EAAE,MAAM,CAAC;IACjD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdjC,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"IdmOps.js","names":["frodo","FrodoError","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printError","printMessage","stopProgressIndicator","stringify","utils","json","unSubstituteEnvParams","areScriptHooksValid","getFilePath","getTypedFilename","readFiles","getWorkingDirectory","readConfigEntities","readConfigEntity","exportConfigEntities","updateConfigEntity","importConfigEntities","idm","config","queryManagedObjects","managed","testConnectorServers","system","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","listAllConfigEntities","configurations","configEntity","_id","exportConfigEntity","id","file","fileName","writeFile","err","exportAllRawConfigEntities","exportedConfigurations","value","Object","entries","outputFile","exportAllConfigEntities","entitiesFile","envFile","errors","entriesToExport","data","readFileSync","entriesData","JSON","parse","envParams","undefined","entityPromises","includes","push","results","Promise","item","configEntityString","each","key","outputFileSync","importConfigEntityByIdFromFile","entityId","validate","fileData","resolve","process","cwd","entityData","isValid","importConfigEntityFromFile","filePath","indicatorId","importAllRawConfigEntities","options","baseDirectory","files","jsonObjects","toLowerCase","endsWith","content","entity","importData","fromEntries","importAllConfigEntities","entriesToImport","envReader","countManagedObjects","type","result"],"sources":["../../src/ops/IdmOps.ts"],"sourcesContent":["import { frodo, FrodoError } from '@rockcarver/frodo-lib';\nimport { type ConfigEntityImportOptions } from '@rockcarver/frodo-lib/types/ops/IdmConfigOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport {\n createProgressIndicator,\n printError,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\n\nconst { stringify } = frodo.utils.json;\n\nconst {\n unSubstituteEnvParams,\n areScriptHooksValid,\n getFilePath,\n getTypedFilename,\n readFiles,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readConfigEntities,\n readConfigEntity,\n exportConfigEntities,\n updateConfigEntity,\n importConfigEntities,\n} = frodo.idm.config;\nconst { queryManagedObjects } = frodo.idm.managed;\nconst { testConnectorServers } = frodo.idm.system;\n\n/**\n * Warn about and list offline remote connector servers\n * @return {Promise<boolean>} a promise that resolves to true if a warning was printed, false otherwise\n */\nexport async function warnAboutOfflineConnectorServers(): Promise<boolean> {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length > 0) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n return true;\n }\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * List all IDM configuration objects\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function listAllConfigEntities(): Promise<boolean> {\n try {\n const configurations = await readConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export an IDM configuration object.\n * @param {string} id the desired configuration object\n * @param {string} file optional export file\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportConfigEntity(\n id: string,\n file: string\n): Promise<boolean> {\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await readConfigEntity(id);\n fs.writeFile(\n getFilePath(fileName, true),\n stringify(configEntity),\n (err) => {\n if (err) {\n printError(err, `Error exporting config entity ${id}`);\n }\n }\n );\n return true;\n } catch (error) {\n printError(error, `Error exporting config entity ${id}`);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllRawConfigEntities() {\n try {\n const exportedConfigurations = await exportConfigEntities();\n for (const [id, value] of Object.entries(exportedConfigurations.config)) {\n if (value != null) {\n fse.outputFile(\n getFilePath(`${id}.json`, true),\n stringify(value),\n (err) => {\n if (err) {\n printError(err, `Error exporting raw config entity ${id}`);\n }\n }\n );\n }\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllConfigEntities(\n entitiesFile: string,\n envFile: string\n): Promise<boolean> {\n const errors: Error[] = [];\n try {\n let entriesToExport = [];\n // read list of entities to export\n const data = fs.readFileSync(entitiesFile, 'utf8');\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n const configurations = await readConfigEntities();\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(readConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n try {\n let configEntityString = stringify(item);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFileSync(\n getFilePath(`${item._id}.json`, true),\n configEntityString\n );\n } catch (error) {\n errors.push(\n new FrodoError(`Error saving config entity ${item._id}`, error)\n );\n }\n }\n }\n if (errors.length > 0) {\n throw new FrodoError(`Error saving config entities`, errors);\n }\n stopProgressIndicator(null, 'success');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param {string} entityId the configuration object to import\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n): Promise<boolean> {\n try {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n\n const entityData = JSON.parse(fileData);\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import IDM configuration object from file.\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n): Promise<boolean> {\n const filePath = getFilePath(file);\n let indicatorId: string;\n try {\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${filePath}...`\n );\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), filePath),\n 'utf8'\n );\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n stopProgressIndicator(\n indicatorId,\n `Imported ${entityId} from ${filePath}.`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error importing ${filePath}.`, 'fail');\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllRawConfigEntities(\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n) {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) => JSON.parse(content))\n .map((entity) => [entity._id, entity]);\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllConfigEntities(\n entitiesFile: string,\n envFile: string,\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n): Promise<boolean> {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const entriesToImport = JSON.parse(\n fs.readFileSync(entitiesFile, 'utf8')\n ).idm;\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) =>\n JSON.parse(unSubstituteEnvParams(content, envReader))\n )\n .filter((entity) => entriesToImport.includes(entity._id))\n .map((entity) => [entity._id, entity]);\n\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function countManagedObjects(type: string): Promise<boolean> {\n try {\n const result = await queryManagedObjects(type);\n printMessage(`${type}: ${result.length}`, 'data');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,QAAQ,uBAAuB;AAEzD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,uBAAuB,EACvBC,UAAU,EACVC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AAEzB,MAAM;EAAEC;AAAU,CAAC,GAAGX,KAAK,CAACY,KAAK,CAACC,IAAI;AAEtC,MAAM;EACJC,qBAAqB;EACrBC,mBAAmB;EACnBC,WAAW;EACXC,gBAAgB;EAChBC,SAAS;EACTC;AACF,CAAC,GAAGnB,KAAK,CAACY,KAAK;AACf,MAAM;EACJQ,kBAAkB;EAClBC,gBAAgB;EAChBC,oBAAoB;EACpBC,kBAAkB;EAClBC;AACF,CAAC,GAAGxB,KAAK,CAACyB,GAAG,CAACC,MAAM;AACpB,MAAM;EAAEC;AAAoB,CAAC,GAAG3B,KAAK,CAACyB,GAAG,CAACG,OAAO;AACjD,MAAM;EAAEC;AAAqB,CAAC,GAAG7B,KAAK,CAACyB,GAAG,CAACK,MAAM;;AAEjD;AACA;AACA;AACA;AACA,OAAO,eAAeC,gCAAgCA,CAAA,EAAqB;EACzE,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMH,oBAAoB,CAAC,CAAC;IACxC,MAAMI,OAAO,GAAGD,GAAG,CAChBE,MAAM,CAAEC,MAAM,IAAK,CAACA,MAAM,CAACC,EAAE,CAAC,CAC9BC,GA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qF,OAAO,EAAEM,SAAS,CAAC,CACtD,CAAC,CACAvE,MAAM,CAAEkE,MAAM,IAAKI,eAAe,CAACjC,QAAQ,CAAC6B,MAAM,CAACvD,GAAG,CAAC,CAAC,CACxDR,GAAG,CAAE+D,MAAM,IAAK,CAACA,MAAM,CAACvD,GAAG,EAAEuD,MAAM,CAAC,CAAC;IAExC,MAAMC,UAAU,GAAG;MACjB3E,MAAM,EAAE6B,MAAM,CAAC+C,WAAW,CAACN,WAAW;IACxC,CAAC;IAEDL,WAAW,GAAGpF,uBAAuB,CACnC,eAAe,EACf,CAAC,EACA,kCAAiCuF,aAAc,KAClD,CAAC;IAED,MAAMtE,oBAAoB,CAAC6E,UAAU,EAAER,OAAO,CAAC;IAC/CnF,qBAAqB,CACnBiF,WAAW,EACV,YAAWK,WAAW,CAACzD,MAAO,kBAAiB,EAChD,SACF,CAAC;IACD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd/B,qBAAqB,CACnBiF,WAAW,EACV,wCAAuCG,aAAc,GAAE,EACxD,MACF,CAAC;IACDtF,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeiE,mBAAmBA,CAACC,IAAY,EAAoB;EACxE,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMjF,mBAAmB,CAACgF,IAAI,CAAC;IAC9ClG,YAAY,CAAE,GAAEkG,IAAK,KAAIC,MAAM,CAACrE,MAAO,EAAC,EAAE,MAAM,CAAC;IACjD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdjC,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd"}
|
package/esm/ops/ServiceOps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { createTable, debugMessage,
|
|
3
|
+
import { createProgressIndicator, createTable, debugMessage, printError, printMessage, stopProgressIndicator } from '../utils/Console';
|
|
4
4
|
const {
|
|
5
5
|
getRealmName,
|
|
6
6
|
getTypedFilename,
|
|
@@ -129,22 +129,23 @@ export async function importServiceFromFile(serviceId, file, options = {
|
|
|
129
129
|
global: false,
|
|
130
130
|
realm: false
|
|
131
131
|
}) {
|
|
132
|
+
let indicatorId;
|
|
132
133
|
try {
|
|
133
134
|
debugMessage(`cli.ServiceOps.importServiceFromFile: start`);
|
|
134
|
-
showSpinner(`Importing service ${serviceId}...`);
|
|
135
135
|
const filePath = getFilePath(file);
|
|
136
|
+
indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${serviceId} from ${filePath}...`);
|
|
136
137
|
const data = fs.readFileSync(filePath, 'utf8');
|
|
137
138
|
const importData = JSON.parse(data);
|
|
138
139
|
if (importData !== null && importData !== void 0 && importData.service[serviceId]) {
|
|
139
140
|
await importService(serviceId, importData, options);
|
|
140
|
-
|
|
141
|
+
stopProgressIndicator(indicatorId, `Imported ${serviceId} from ${filePath}.`, 'success');
|
|
141
142
|
} else {
|
|
142
|
-
|
|
143
|
+
stopProgressIndicator(indicatorId, `${serviceId} not found`, 'fail');
|
|
143
144
|
}
|
|
144
145
|
debugMessage(`cli.ServiceOps.importServiceFromFile: end`);
|
|
145
146
|
return true;
|
|
146
147
|
} catch (error) {
|
|
147
|
-
|
|
148
|
+
stopProgressIndicator(indicatorId, `Error importing ${serviceId}.`, 'fail');
|
|
148
149
|
printError(error);
|
|
149
150
|
}
|
|
150
151
|
return false;
|
|
@@ -161,23 +162,24 @@ export async function importFirstServiceFromFile(file, options = {
|
|
|
161
162
|
global: false,
|
|
162
163
|
realm: false
|
|
163
164
|
}) {
|
|
165
|
+
let indicatorId;
|
|
164
166
|
try {
|
|
165
|
-
|
|
167
|
+
debugMessage(`cli.ServiceOps.importFirstServiceFromFile: start`);
|
|
166
168
|
const filePath = getFilePath(file);
|
|
167
|
-
|
|
169
|
+
indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${filePath}...`);
|
|
168
170
|
const data = fs.readFileSync(filePath, 'utf8');
|
|
169
171
|
const importData = JSON.parse(data);
|
|
170
172
|
if (importData && Object.keys(importData.service).length) {
|
|
171
173
|
const serviceId = Object.keys(importData.service)[0];
|
|
172
174
|
await importService(serviceId, importData, options);
|
|
173
|
-
|
|
175
|
+
stopProgressIndicator(indicatorId, `Imported ${serviceId} from ${filePath}.`, 'success');
|
|
174
176
|
} else {
|
|
175
|
-
|
|
177
|
+
stopProgressIndicator(indicatorId, `No service found in import data`, 'fail');
|
|
176
178
|
}
|
|
177
179
|
debugMessage(`cli.ServiceOps.importFirstServiceFromFile: end`);
|
|
178
180
|
return true;
|
|
179
181
|
} catch (error) {
|
|
180
|
-
|
|
182
|
+
stopProgressIndicator(indicatorId, `Error importing first service`, 'fail');
|
|
181
183
|
printError(error);
|
|
182
184
|
}
|
|
183
185
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOps.js","names":["frodo","FrodoError","state","fs","createTable","debugMessage","failSpinner","printError","printMessage","showSpinner","succeedSpinner","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","getListOfServices","exportServices","exportService","getFullServices","createServiceExportTemplate","importService","importServices","deleteFullService","deleteFullServices","service","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","push","name","toString","error","exportServicesToFile","file","includeMeta","exportData","fileName","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","filePath","importServiceFromFile","options","clean","global","realm","data","readFileSync","importData","JSON","parse","importFirstServiceFromFile","Object","keys","length","importServicesFromFile","importServicesFromFiles","errors","names","readdirSync","serviceFiles","filter","toLowerCase","endsWith","deleteService","deleteServices"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';\nimport {\n type ServiceExportInterface,\n type ServiceImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ServiceOps';\nimport fs from 'fs';\n\nimport {\n createTable,\n debugMessage,\n failSpinner,\n printError,\n printMessage,\n showSpinner,\n succeedSpinner,\n} from '../utils/Console';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n getListOfServices,\n exportServices,\n exportService,\n getFullServices,\n createServiceExportTemplate,\n importService,\n importServices,\n deleteFullService,\n deleteFullServices,\n} = frodo.service;\n\n/**\n * List services\n * @param {boolean} [long=false] detailed list\n * @param {boolean} [globalConfig=false] global services\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listServices(\n long: boolean = false,\n globalConfig: boolean = false\n): Promise<boolean> {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([\n service._id,\n globalConfig ? service['_type'].name : service.name,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportServicesToFile(\n file: string,\n globalConfig: boolean = false,\n includeMeta: boolean = true\n): Promise<boolean> {\n try {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${\n globalConfig ? 'Global' : titleCase(getRealmName(state.getRealm()))\n }Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig: boolean = false,\n includeMeta: boolean = true\n): Promise<boolean> {\n try {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all services to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportServicesToFiles(\n globalConfig: boolean = false,\n includeMeta: boolean = true\n): Promise<boolean> {\n try {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const filePath = getFilePath(fileName, true);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${filePath}`\n );\n saveJsonToFile(exportData, filePath, includeMeta);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n try {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start`);\n showSpinner(`Importing service ${serviceId}...`);\n const filePath = getFilePath(file);\n const data = fs.readFileSync(filePath, 'utf8');\n const importData = JSON.parse(data);\n if (importData?.service[serviceId]) {\n await importService(serviceId, importData, options);\n succeedSpinner(`Imported ${serviceId}.`);\n } else {\n failSpinner(`${serviceId} not found!`);\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end`);\n return true;\n } catch (error) {\n failSpinner(`Error importing service ${serviceId}`);\n printError(error);\n }\n return false;\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstServiceFromFile(\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n try {\n showSpinner(`Importing first service...`);\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${filePath}]`\n );\n const data = fs.readFileSync(filePath, 'utf8');\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n await importService(serviceId, importData, options);\n succeedSpinner(`Imported first service ${serviceId}.`);\n } else {\n failSpinner(`No services found in ${filePath}!`);\n }\n debugMessage(`cli.ServiceOps.importFirstServiceFromFile: end`);\n return true;\n } catch (error) {\n failSpinner(`Error importing first service`);\n printError(error);\n }\n return false;\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importServicesFromFile(\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n try {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [file=${filePath}]`\n );\n const data = fs.readFileSync(filePath, 'utf8');\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${filePath}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n await importServices(importData, options);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [file=${filePath}]`\n );\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all services from separate files\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importServicesFromFiles(\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n try {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const errors: Error[] = [];\n const names = fs.readdirSync(getWorkingDirectory());\n const serviceFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of serviceFiles) {\n try {\n await importServicesFromFile(file, options);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new FrodoError(`Error importing services from files`, errors);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteService(\n serviceId: string,\n globalConfig = false\n): Promise<boolean> {\n try {\n await deleteFullService(serviceId, globalConfig);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Delete all services\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteServices(globalConfig = false): Promise<boolean> {\n try {\n await deleteFullServices(globalConfig);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,EAAEC,KAAK,QAAQ,uBAAuB;AAKhE,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,WAAW,EACXC,cAAc,QACT,kBAAkB;AAEzB,MAAM;EACJC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGhB,KAAK,CAACiB,KAAK;AACf,MAAM;EACJC,iBAAiB;EACjBC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,2BAA2B;EAC3BC,aAAa;EACbC,cAAc;EACdC,iBAAiB;EACjBC;AACF,CAAC,GAAG1B,KAAK,CAAC2B,OAAO;;AAEjB;AACA;AACA;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AAC,eAAe,CAC7C,CAAC;IACD,KAAK,MAAMhC,IAAI,IAAI6B,YAAY,EAAE;MAC/B,IAAI;QACF,MAAML,sBAAsB,CAACxB,IAAI,EAAEW,OAAO,CAAC;MAC7C,CAAC,CAAC,OAAOb,KAAK,EAAE;QACd4B,MAAM,CAAC/B,IAAI,CAACG,KAAK,CAAC;MACpB;IACF;IACA,IAAI4B,MAAM,CAACH,MAAM,GAAG,CAAC,EAAE;MACrB,MAAM,IAAIjE,UAAU,CAAE,qCAAoC,EAAEoE,MAAM,CAAC;IACrE;IACAhE,YAAY,CAAE,6CAA4C,CAAC;IAC3D,OAAO,IAAI;EACb,CAAC,CAAC,OAAOoC,KAAK,EAAE;IACdlC,UAAU,CAACkC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAemC,aAAaA,CACjC3B,SAAiB,EACjBnB,YAAY,GAAG,KAAK,EACF;EAClB,IAAI;IACF,MAAML,iBAAiB,CAACwB,SAAS,EAAEnB,YAAY,CAAC;IAChD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOW,KAAK,EAAE;IACdlC,UAAU,CAACkC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAeoC,cAAcA,CAAC/C,YAAY,GAAG,KAAK,EAAoB;EAC3E,IAAI;IACF,MAAMJ,kBAAkB,CAACI,YAAY,CAAC;IACtC,OAAO,IAAI;EACb,CAAC,CAAC,OAAOW,KAAK,EAAE;IACdlC,UAAU,CAACkC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"ServiceOps.js","names":["frodo","FrodoError","state","fs","createProgressIndicator","createTable","debugMessage","printError","printMessage","stopProgressIndicator","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","getListOfServices","exportServices","exportService","getFullServices","createServiceExportTemplate","importService","importServices","deleteFullService","deleteFullServices","service","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","push","name","toString","error","exportServicesToFile","file","includeMeta","exportData","fileName","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","filePath","importServiceFromFile","options","clean","global","realm","indicatorId","data","readFileSync","importData","JSON","parse","importFirstServiceFromFile","Object","keys","length","importServicesFromFile","importServicesFromFiles","errors","names","readdirSync","serviceFiles","filter","toLowerCase","endsWith","deleteService","deleteServices"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';\nimport {\n type ServiceExportInterface,\n type ServiceImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ServiceOps';\nimport fs from 'fs';\n\nimport {\n createProgressIndicator,\n createTable,\n debugMessage,\n printError,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n getListOfServices,\n exportServices,\n exportService,\n getFullServices,\n createServiceExportTemplate,\n importService,\n importServices,\n deleteFullService,\n deleteFullServices,\n} = frodo.service;\n\n/**\n * List services\n * @param {boolean} [long=false] detailed list\n * @param {boolean} [globalConfig=false] global services\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listServices(\n long: boolean = false,\n globalConfig: boolean = false\n): Promise<boolean> {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([\n service._id,\n globalConfig ? service['_type'].name : service.name,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportServicesToFile(\n file: string,\n globalConfig: boolean = false,\n includeMeta: boolean = true\n): Promise<boolean> {\n try {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${\n globalConfig ? 'Global' : titleCase(getRealmName(state.getRealm()))\n }Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig: boolean = false,\n includeMeta: boolean = true\n): Promise<boolean> {\n try {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all services to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportServicesToFiles(\n globalConfig: boolean = false,\n includeMeta: boolean = true\n): Promise<boolean> {\n try {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const filePath = getFilePath(fileName, true);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${filePath}`\n );\n saveJsonToFile(exportData, filePath, includeMeta);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n let indicatorId: string;\n try {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start`);\n const filePath = getFilePath(file);\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${serviceId} from ${filePath}...`\n );\n const data = fs.readFileSync(filePath, 'utf8');\n const importData = JSON.parse(data);\n if (importData?.service[serviceId]) {\n await importService(serviceId, importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${serviceId} from ${filePath}.`,\n 'success'\n );\n } else {\n stopProgressIndicator(indicatorId, `${serviceId} not found`, 'fail');\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end`);\n return true;\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error importing ${serviceId}.`, 'fail');\n printError(error);\n }\n return false;\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstServiceFromFile(\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n let indicatorId: string;\n try {\n debugMessage(`cli.ServiceOps.importFirstServiceFromFile: start`);\n const filePath = getFilePath(file);\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${filePath}...`\n );\n const data = fs.readFileSync(filePath, 'utf8');\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n await importService(serviceId, importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${serviceId} from ${filePath}.`,\n 'success'\n );\n } else {\n stopProgressIndicator(\n indicatorId,\n `No service found in import data`,\n 'fail'\n );\n }\n debugMessage(`cli.ServiceOps.importFirstServiceFromFile: end`);\n return true;\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error importing first service`, 'fail');\n printError(error);\n }\n return false;\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importServicesFromFile(\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n try {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [file=${filePath}]`\n );\n const data = fs.readFileSync(filePath, 'utf8');\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${filePath}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n await importServices(importData, options);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [file=${filePath}]`\n );\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all services from separate files\n * @param {ServiceImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importServicesFromFiles(\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n): Promise<boolean> {\n try {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const errors: Error[] = [];\n const names = fs.readdirSync(getWorkingDirectory());\n const serviceFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of serviceFiles) {\n try {\n await importServicesFromFile(file, options);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) {\n throw new FrodoError(`Error importing services from files`, errors);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteService(\n serviceId: string,\n globalConfig = false\n): Promise<boolean> {\n try {\n await deleteFullService(serviceId, globalConfig);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Delete all services\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteServices(globalConfig = false): Promise<boolean> {\n try {\n await deleteFullServices(globalConfig);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,EAAEC,KAAK,QAAQ,uBAAuB;AAKhE,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AAEzB,MAAM;EACJC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGf,KAAK,CAACgB,KAAK;AACf,MAAM;EACJC,iBAAiB;EACjBC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,2BAA2B;EAC3BC,aAAa;EACbC,cAAc;EACdC,iBAAiB;EACjBC;AACF,CAAC,GAAGzB,KAAK,CAAC0B,OAAO;;AAEjB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,IAAa,GAAG,KAAK,EACrBC,YAAqB,GAAG,KAAK,EACX;EAClB,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMb,iBAAiB,CAACY,YAAY,CAAC;IACtDC,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,IAAIN,IAAI,EAAE;MACR,MAAMQ,KAAK,GAAG/B,WAAW,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;MACzD,KAAK,MAAMqB,OAAO,IAAII,QAAQ,EAAE;QAC9BM,KAAK,CAACC,IAAI,CAAC,CACTX,OAAO,CAACQ,GAAG,EACXL,YAAY,GAAGH,OAAO,CAAC,OAAO,CAAC,CAACY,IAAI,GAAGZ,OAAO,CAACY,IAAI,CACpD,CAAC;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E,qCAAoC,EAAEoE,MAAM,CAAC;IACrE;IACA/D,YAAY,CAAE,6CAA4C,CAAC;IAC3D,OAAO,IAAI;EACb,CAAC,CAAC,OAAOkC,KAAK,EAAE;IACdjC,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeoC,aAAaA,CACjC5B,SAAiB,EACjBnB,YAAY,GAAG,KAAK,EACF;EAClB,IAAI;IACF,MAAML,iBAAiB,CAACwB,SAAS,EAAEnB,YAAY,CAAC;IAChD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOW,KAAK,EAAE;IACdjC,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAeqC,cAAcA,CAAChD,YAAY,GAAG,KAAK,EAAoB;EAC3E,IAAI;IACF,MAAMJ,kBAAkB,CAACI,YAAY,CAAC;IACtC,OAAO,IAAI;EACb,CAAC,CAAC,OAAOW,KAAK,EAAE;IACdjC,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd"}
|
package/esm/utils/Config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
1
|
+
import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import slugify from 'slugify';
|
|
@@ -145,7 +145,7 @@ export async function getFullExportConfigFromDirectory(directory) {
|
|
|
145
145
|
remove: /[^\w\s$*_+~.()'"!\-@]+/g
|
|
146
146
|
}) === name);
|
|
147
147
|
if (!script) {
|
|
148
|
-
throw
|
|
148
|
+
throw new FrodoError(`Can't find the script corresponding to the file '${f.path}' in the export files`);
|
|
149
149
|
}
|
|
150
150
|
script.script = scriptLines;
|
|
151
151
|
}
|
package/esm/utils/Config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.js","names":["frodo","state","fs","os","slugify","printMessage","getFilePath","readFiles","utils","exportFullConfiguration","config","getDefaultNoiseFilter","cloud","log","FRODO_CONFIG_PATH_KEY","FRODO_LOG_NOISEFILTER_FILENAME","getConfigPath","process","env","homedir","getCustomNoiseFilters","filename","noiseFilter","data","readFileSync","JSON","parse","e","message","getNoiseFilters","defaults","length","writeFileSync","stringify","getFullExportConfig","file","workingDirectory","getDirectory","useStringArrays","noDecode","coords","includeDefault","getFullExportConfigFromDirectory","directory","fullExportConfig","meta","agents","application","authentication","emailTemplate","idp","managedApplication","policy","policyset","resourcetype","saml","hosted","remote","metadata","cot","script","secrets","service","theme","trees","variables","files","jsonFiles","filter","f","path","endsWith","idmConfigFiles","startsWith","samlFiles","otherFiles","scriptFiles","id","value","Object","entries","content","assign","_id","scriptExports","values","name","substring","lastIndexOf","indexOf","scriptLines","split","find","s","replace","remove","Error","isIdUsed","configuration","isEsv","isIdUsedRecurse","RegExp","replaceAll","regex","type","used","location","test"],"sources":["../../src/utils/Config.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { FullExportInterface } from '@rockcarver/frodo-lib/types/ops/ConfigOps';\nimport fs from 'fs';\nimport os from 'os';\nimport slugify from 'slugify';\n\nimport { printMessage } from './Console';\n\nconst { getFilePath, readFiles } = frodo.utils;\n\nconst { exportFullConfiguration } = frodo.config;\n\nconst { getDefaultNoiseFilter } = frodo.cloud.log;\n\nexport const FRODO_CONFIG_PATH_KEY = 'FRODO_CONFIG_PATH';\nexport const FRODO_LOG_NOISEFILTER_FILENAME = 'LoggingNoiseFilter.json';\n\nexport function getConfigPath(): string {\n return process.env[FRODO_CONFIG_PATH_KEY] || `${os.homedir()}/.frodo`;\n}\n\nfunction getCustomNoiseFilters(): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n let noiseFilter = [];\n try {\n const data = fs.readFileSync(filename, 'utf8');\n noiseFilter = JSON.parse(data);\n } catch (e) {\n printMessage(`Error reading ${filename} (${e.message})`, 'error');\n }\n return noiseFilter;\n}\n\nexport function getNoiseFilters(defaults: boolean): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n if (defaults) {\n printMessage(`Using default logging noise filters.`, 'info');\n return getDefaultNoiseFilter();\n }\n let noiseFilter = getCustomNoiseFilters();\n if (noiseFilter.length == 0) {\n printMessage(`No custom noise filters defined. Using defaults.`, 'info');\n noiseFilter = getDefaultNoiseFilter();\n try {\n fs.writeFileSync(filename, JSON.stringify(noiseFilter, null, 2));\n printMessage(\n `The default filters were saved in ${filename}. You can change the filters as needed.`,\n 'info'\n );\n } catch (e) {\n printMessage(\n `Error creating noise filter configuration with default values.`,\n 'error'\n );\n }\n }\n return noiseFilter;\n}\n\n/**\n * Gets the full export config from one of three locations:\n * 1. The file passed into the function if one is provided.\n * 2. The working directory if it exists (provided by the user)\n * 3. The cloud tenant if the exports are not locally provided\n * @param file The optional file path\n * @returns The full export config\n */\nexport async function getFullExportConfig(\n file: string | null = null\n): Promise<FullExportInterface> {\n // Get export from file if it exists\n if (file) {\n return JSON.parse(fs.readFileSync(getFilePath(file), 'utf8'));\n }\n // If working directory doesn't exist, export from the cloud\n const workingDirectory = state.getDirectory();\n if (!workingDirectory) {\n return await exportFullConfiguration({\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: true,\n });\n }\n // Go through files in the working directory and reconstruct the full export\n return getFullExportConfigFromDirectory(workingDirectory);\n}\n\n/**\n * Reconstructs the full export config from files in the given directory\n * @param directory The directory\n * @return The full export config\n */\nexport async function getFullExportConfigFromDirectory(\n directory: string\n): Promise<FullExportInterface> {\n const fullExportConfig = {\n meta: {},\n agents: {},\n application: {},\n authentication: {},\n config: {},\n emailTemplate: {},\n idp: {},\n managedApplication: {},\n policy: {},\n policyset: {},\n resourcetype: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n cot: {},\n },\n script: {},\n secrets: {},\n service: {},\n theme: {},\n trees: {},\n variables: {},\n } as FullExportInterface;\n const files = await readFiles(directory);\n const jsonFiles = files.filter((f) => f.path.endsWith('.json'));\n const idmConfigFiles = jsonFiles.filter((f) => f.path.startsWith('config/'));\n const samlFiles = jsonFiles.filter(\n (f) => f.path.startsWith('saml/') || f.path.startsWith('cot/')\n );\n const otherFiles = jsonFiles.filter(\n (f) =>\n !f.path.startsWith('config/') &&\n !f.path.startsWith('saml/') &&\n !f.path.startsWith('cot/')\n );\n const scriptFiles = files.filter(\n (f) => f.path.endsWith('.js') || f.path.endsWith('.groovy')\n );\n // Handle json files\n for (const f of otherFiles) {\n for (const [id, value] of Object.entries(JSON.parse(f.content))) {\n if (value == null || fullExportConfig[id] == null) {\n continue;\n }\n Object.assign(fullExportConfig[id], value);\n }\n }\n // Handle saml files\n for (const f of samlFiles) {\n let content = JSON.parse(f.content);\n content = content.saml;\n for (const [id, value] of Object.entries(content)) {\n Object.assign(fullExportConfig.saml[id], value);\n }\n }\n // Handle idm config files\n for (const f of idmConfigFiles) {\n const content = JSON.parse(f.content);\n fullExportConfig.config[content._id] = content;\n }\n // Handle extracted scripts, adding them to their corresponding script objects in the export\n if (scriptFiles.length > 0 && fullExportConfig.script != null) {\n const scriptExports = Object.values(fullExportConfig.script);\n for (const f of scriptFiles) {\n const name = f.path.substring(\n f.path.lastIndexOf('/') + 1,\n f.path.indexOf('.', f.path.lastIndexOf('/'))\n );\n const scriptLines = f.content.split('\\n');\n const script = scriptExports.find(\n (s) =>\n slugify(s.name.replace(/^http(s?):\\/\\//, ''), {\n remove: /[^\\w\\s$*_+~.()'\"!\\-@]+/g,\n }) === name\n );\n if (!script) {\n throw Error(\n `Can't find the script corresponding to the file '${f.path}' in the export files`\n );\n }\n script.script = scriptLines;\n }\n }\n return fullExportConfig;\n}\n\n/**\n * Determines if a string id is being used anywhere within the given configuration object\n * @param configuration The configuration object\n * @param id The id being search for\n * @param isEsv Whether the id corresponds to an ESV or not\n */\nexport function isIdUsed(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n configuration: any,\n id: string,\n isEsv: boolean\n): {\n used: boolean;\n location: string;\n} {\n return isIdUsedRecurse(\n configuration,\n isEsv\n ? // For ESV ids, they contain either letters, numbers, dashes, or underscores. The dashes get replaced with periods (escaped with a \\ for the regex)\n // since anywhere they are being used they will be used with periods, not dashes. Note that the (?:[^a-z0-9._]|$) expressions at the beginning and\n // end are meant to ensure that the id found is not a substring of some other id (i.e. the id found must either be at the beginning or end of the\n // string, or if in the middle of a string, is not preceded or followed by a character that would be part of another id).\n new RegExp(\n `(?:[^a-z0-9._]|^)${id.replaceAll('-', '\\\\.')}(?:[^a-z0-9._]|$)`\n )\n : // For normal ids, they contain only letters, numbers, or dashes.\n new RegExp(`(?:[^a-z0-9-]|^)${id}(?:[^a-z0-9-]|$)`)\n );\n}\n\n/**\n * Recursive helper for isIdUsed that finds any strings contained in the configuration that pass the regex\n * @param configuration The configuration (could be anything)\n * @param regex The regex test\n */\nfunction isIdUsedRecurse(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n configuration: any,\n regex: RegExp\n): {\n used: boolean;\n location: string;\n} {\n const type = typeof configuration;\n if (type === 'object' && configuration !== null) {\n for (const [id, value] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n configuration as Record<string, any>\n )) {\n const isIdUsed = isIdUsedRecurse(value, regex);\n if (isIdUsed.used) {\n isIdUsed.location =\n id +\n (value.name ? `(name: '${value.name}')` : '') +\n (isIdUsed.location === '' ? '' : '.') +\n isIdUsed.location;\n return isIdUsed;\n }\n }\n }\n return {\n used: type === 'string' && regex.test(configuration),\n location: '',\n };\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,YAAY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Aa,EAIb;EACA,MAAMC,IAAI,GAAG,OAAON,aAAa;EACjC,IAAIM,IAAI,KAAK,QAAQ,IAAIN,aAAa,KAAK,IAAI,EAAE;IAC/C,KAAK,MAAM,CAACrB,EAAE,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO;IACtC;IACAkB,aACF,CAAC,EAAE;MACD,MAAMD,QAAQ,GAAGG,eAAe,CAACtB,KAAK,EAAEyB,KAAK,CAAC;MAC9C,IAAIN,QAAQ,CAACQ,IAAI,EAAE;QACjBR,QAAQ,CAACS,QAAQ,GACf7B,EAAE,IACDC,KAAK,CAACQ,IAAI,GAAI,WAAUR,KAAK,CAACQ,IAAK,IAAG,GAAG,EAAE,CAAC,IAC5CW,QAAQ,CAACS,QAAQ,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,GACrCT,QAAQ,CAACS,QAAQ;QACnB,OAAOT,QAAQ;MACjB;IACF;EACF;EACA,OAAO;IACLQ,IAAI,EAAED,IAAI,KAAK,QAAQ,IAAID,KAAK,CAACI,IAAI,CAACT,aAAa,CAAC;IACpDQ,QAAQ,EAAE;EACZ,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"Config.js","names":["frodo","FrodoError","state","fs","os","slugify","printMessage","getFilePath","readFiles","utils","exportFullConfiguration","config","getDefaultNoiseFilter","cloud","log","FRODO_CONFIG_PATH_KEY","FRODO_LOG_NOISEFILTER_FILENAME","getConfigPath","process","env","homedir","getCustomNoiseFilters","filename","noiseFilter","data","readFileSync","JSON","parse","e","message","getNoiseFilters","defaults","length","writeFileSync","stringify","getFullExportConfig","file","workingDirectory","getDirectory","useStringArrays","noDecode","coords","includeDefault","getFullExportConfigFromDirectory","directory","fullExportConfig","meta","agents","application","authentication","emailTemplate","idp","managedApplication","policy","policyset","resourcetype","saml","hosted","remote","metadata","cot","script","secrets","service","theme","trees","variables","files","jsonFiles","filter","f","path","endsWith","idmConfigFiles","startsWith","samlFiles","otherFiles","scriptFiles","id","value","Object","entries","content","assign","_id","scriptExports","values","name","substring","lastIndexOf","indexOf","scriptLines","split","find","s","replace","remove","isIdUsed","configuration","isEsv","isIdUsedRecurse","RegExp","replaceAll","regex","type","used","location","test"],"sources":["../../src/utils/Config.ts"],"sourcesContent":["import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';\nimport { FullExportInterface } from '@rockcarver/frodo-lib/types/ops/ConfigOps';\nimport fs from 'fs';\nimport os from 'os';\nimport slugify from 'slugify';\n\nimport { printMessage } from './Console';\n\nconst { getFilePath, readFiles } = frodo.utils;\n\nconst { exportFullConfiguration } = frodo.config;\n\nconst { getDefaultNoiseFilter } = frodo.cloud.log;\n\nexport const FRODO_CONFIG_PATH_KEY = 'FRODO_CONFIG_PATH';\nexport const FRODO_LOG_NOISEFILTER_FILENAME = 'LoggingNoiseFilter.json';\n\nexport function getConfigPath(): string {\n return process.env[FRODO_CONFIG_PATH_KEY] || `${os.homedir()}/.frodo`;\n}\n\nfunction getCustomNoiseFilters(): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n let noiseFilter = [];\n try {\n const data = fs.readFileSync(filename, 'utf8');\n noiseFilter = JSON.parse(data);\n } catch (e) {\n printMessage(`Error reading ${filename} (${e.message})`, 'error');\n }\n return noiseFilter;\n}\n\nexport function getNoiseFilters(defaults: boolean): Array<string> {\n const filename = `${getConfigPath()}/${FRODO_LOG_NOISEFILTER_FILENAME}`;\n if (defaults) {\n printMessage(`Using default logging noise filters.`, 'info');\n return getDefaultNoiseFilter();\n }\n let noiseFilter = getCustomNoiseFilters();\n if (noiseFilter.length == 0) {\n printMessage(`No custom noise filters defined. Using defaults.`, 'info');\n noiseFilter = getDefaultNoiseFilter();\n try {\n fs.writeFileSync(filename, JSON.stringify(noiseFilter, null, 2));\n printMessage(\n `The default filters were saved in ${filename}. You can change the filters as needed.`,\n 'info'\n );\n } catch (e) {\n printMessage(\n `Error creating noise filter configuration with default values.`,\n 'error'\n );\n }\n }\n return noiseFilter;\n}\n\n/**\n * Gets the full export config from one of three locations:\n * 1. The file passed into the function if one is provided.\n * 2. The working directory if it exists (provided by the user)\n * 3. The cloud tenant if the exports are not locally provided\n * @param file The optional file path\n * @returns The full export config\n */\nexport async function getFullExportConfig(\n file: string | null = null\n): Promise<FullExportInterface> {\n // Get export from file if it exists\n if (file) {\n return JSON.parse(fs.readFileSync(getFilePath(file), 'utf8'));\n }\n // If working directory doesn't exist, export from the cloud\n const workingDirectory = state.getDirectory();\n if (!workingDirectory) {\n return await exportFullConfiguration({\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: true,\n });\n }\n // Go through files in the working directory and reconstruct the full export\n return getFullExportConfigFromDirectory(workingDirectory);\n}\n\n/**\n * Reconstructs the full export config from files in the given directory\n * @param directory The directory\n * @return The full export config\n */\nexport async function getFullExportConfigFromDirectory(\n directory: string\n): Promise<FullExportInterface> {\n const fullExportConfig = {\n meta: {},\n agents: {},\n application: {},\n authentication: {},\n config: {},\n emailTemplate: {},\n idp: {},\n managedApplication: {},\n policy: {},\n policyset: {},\n resourcetype: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n cot: {},\n },\n script: {},\n secrets: {},\n service: {},\n theme: {},\n trees: {},\n variables: {},\n } as FullExportInterface;\n const files = await readFiles(directory);\n const jsonFiles = files.filter((f) => f.path.endsWith('.json'));\n const idmConfigFiles = jsonFiles.filter((f) => f.path.startsWith('config/'));\n const samlFiles = jsonFiles.filter(\n (f) => f.path.startsWith('saml/') || f.path.startsWith('cot/')\n );\n const otherFiles = jsonFiles.filter(\n (f) =>\n !f.path.startsWith('config/') &&\n !f.path.startsWith('saml/') &&\n !f.path.startsWith('cot/')\n );\n const scriptFiles = files.filter(\n (f) => f.path.endsWith('.js') || f.path.endsWith('.groovy')\n );\n // Handle json files\n for (const f of otherFiles) {\n for (const [id, value] of Object.entries(JSON.parse(f.content))) {\n if (value == null || fullExportConfig[id] == null) {\n continue;\n }\n Object.assign(fullExportConfig[id], value);\n }\n }\n // Handle saml files\n for (const f of samlFiles) {\n let content = JSON.parse(f.content);\n content = content.saml;\n for (const [id, value] of Object.entries(content)) {\n Object.assign(fullExportConfig.saml[id], value);\n }\n }\n // Handle idm config files\n for (const f of idmConfigFiles) {\n const content = JSON.parse(f.content);\n fullExportConfig.config[content._id] = content;\n }\n // Handle extracted scripts, adding them to their corresponding script objects in the export\n if (scriptFiles.length > 0 && fullExportConfig.script != null) {\n const scriptExports = Object.values(fullExportConfig.script);\n for (const f of scriptFiles) {\n const name = f.path.substring(\n f.path.lastIndexOf('/') + 1,\n f.path.indexOf('.', f.path.lastIndexOf('/'))\n );\n const scriptLines = f.content.split('\\n');\n const script = scriptExports.find(\n (s) =>\n slugify(s.name.replace(/^http(s?):\\/\\//, ''), {\n remove: /[^\\w\\s$*_+~.()'\"!\\-@]+/g,\n }) === name\n );\n if (!script) {\n throw new FrodoError(\n `Can't find the script corresponding to the file '${f.path}' in the export files`\n );\n }\n script.script = scriptLines;\n }\n }\n return fullExportConfig;\n}\n\n/**\n * Determines if a string id is being used anywhere within the given configuration object\n * @param configuration The configuration object\n * @param id The id being search for\n * @param isEsv Whether the id corresponds to an ESV or not\n */\nexport function isIdUsed(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n configuration: any,\n id: string,\n isEsv: boolean\n): {\n used: boolean;\n location: string;\n} {\n return isIdUsedRecurse(\n configuration,\n isEsv\n ? // For ESV ids, they contain either letters, numbers, dashes, or underscores. The dashes get replaced with periods (escaped with a \\ for the regex)\n // since anywhere they are being used they will be used with periods, not dashes. Note that the (?:[^a-z0-9._]|$) expressions at the beginning and\n // end are meant to ensure that the id found is not a substring of some other id (i.e. the id found must either be at the beginning or end of the\n // string, or if in the middle of a string, is not preceded or followed by a character that would be part of another id).\n new RegExp(\n `(?:[^a-z0-9._]|^)${id.replaceAll('-', '\\\\.')}(?:[^a-z0-9._]|$)`\n )\n : // For normal ids, they contain only letters, numbers, or dashes.\n new RegExp(`(?:[^a-z0-9-]|^)${id}(?:[^a-z0-9-]|$)`)\n );\n}\n\n/**\n * Recursive helper for isIdUsed that finds any strings contained in the configuration that pass the regex\n * @param configuration The configuration (could be anything)\n * @param regex The regex test\n */\nfunction isIdUsedRecurse(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n configuration: any,\n regex: RegExp\n): {\n used: boolean;\n location: string;\n} {\n const type = typeof configuration;\n if (type === 'object' && configuration !== null) {\n for (const [id, value] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n configuration as Record<string, any>\n )) {\n const isIdUsed = isIdUsedRecurse(value, regex);\n if (isIdUsed.used) {\n isIdUsed.location =\n id +\n (value.name ? `(name: '${value.name}')` : '') +\n (isIdUsed.location === '' ? '' : '.') +\n isIdUsed.location;\n return isIdUsed;\n }\n }\n }\n return {\n used: type === 'string' && regex.test(configuration),\n location: '',\n };\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,EAAEC,KAAK,QAAQ,uBAAuB;AAEhE,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,YAAY,QAAQ,WAAW;AAExC,MAAM;EAAEC,WAAW;EAAEC;AAAU,CAAC,GAAGR,KAAK,CAACS,KAAK;AAE9C,MAAM;EAAEC;AAAwB,CAAC,GAAGV,KAAK,CAACW,MAAM;AAEhD,MAAM;EAAEC;AAAsB,CAAC,GAAGZ,KAAK,CAACa,KAAK,CAACC,GAAG;AAEjD,OAAO,MAAMC,qBAAqB,GAAG,mBAAmB;AACxD,OAAO,MAAMC,8BAA8B,GAAG,yBAAyB;AAEvE,OAAO,SAASC,aAAaA,CAAA,EAAW;EACtC,OAAOC,OAAO,CAACC,GAAG,CAACJ,qBAAqB,CAAC,IAAK,GAAEX,EAAE,CAACgB,OAAO,CAAC,CAAE,SAAQ;AACvE;AAEA,SAASC,qBAAqBA,CAAA,EAAkB;EAC9C,MAAMC,Q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EAAE,GAAG,GAAG,CAAC,GACrCT,QAAQ,CAACS,QAAQ;QACnB,OAAOT,QAAQ;MACjB;IACF;EACF;EACA,OAAO;IACLQ,IAAI,EAAED,IAAI,KAAK,QAAQ,IAAID,KAAK,CAACI,IAAI,CAACT,aAAa,CAAC;IACpDQ,QAAQ,EAAE;EACZ,CAAC;AACH"}
|
package/esm/utils/Console.js
CHANGED
|
@@ -245,7 +245,10 @@ function createProgressBar(total, message = null, options = {
|
|
|
245
245
|
clearOnComplete: false,
|
|
246
246
|
hideCursor: true,
|
|
247
247
|
format: '[{bar}] {percentage}% | {value}/{total} | {data}',
|
|
248
|
-
noTTYOutput: true
|
|
248
|
+
noTTYOutput: true,
|
|
249
|
+
forceRedraw: true,
|
|
250
|
+
gracefulExit: true,
|
|
251
|
+
stopOnComplete: true
|
|
249
252
|
}) {
|
|
250
253
|
debugMessage(`cli.Console.createProgressBar: start`);
|
|
251
254
|
let opt = options;
|
|
@@ -254,7 +257,10 @@ function createProgressBar(total, message = null, options = {
|
|
|
254
257
|
clearOnComplete: false,
|
|
255
258
|
hideCursor: true,
|
|
256
259
|
format: '[{bar}] {percentage}% | {value}/{total}',
|
|
257
|
-
noTTYOutput: true
|
|
260
|
+
noTTYOutput: true,
|
|
261
|
+
forceRedraw: true,
|
|
262
|
+
gracefulExit: true,
|
|
263
|
+
stopOnComplete: true
|
|
258
264
|
};
|
|
259
265
|
}
|
|
260
266
|
if (!multiBarContainer) {
|
package/esm/utils/Console.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Console.js","names":["frodo","state","MultiBar","Presets","Table","Color","createSpinner","v4","uuidv4","enable","appendTextToFile","utils","progressBars","multiBarContainer","spinner","data","message","newline","getOutputFile","JSON","stringify","console","dir","depth","maxArrayLength","log","process","stdout","write","text","error","stderr","info","warn","debug","curlirize","verboseMessage","getVerbose","debugMessage","getDebug","curlirizeMessage","getCurlirize","printMessage","type","printError","name","getCombinedMessage","code","status","detail","errorMessage","createProgressBar","total","options","clearOnComplete","hideCursor","format","noTTYOutput","opt","legacy","id","create","Object","keys","length","updateProgressBar","increment","stopProgressBar","update","stop","cleanupProgressBars","showSpinner","start","stopSpinner","succeedSpinner","success","warnSpinner","failSpinner","spinSpinner","spin","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","cleanupProgressIndicators","createTable","head","table","chars","top","bottom","left","mid","right","style","createKeyValueTable","wordWrap","getObjectDepth","object","Math","max","values","map","hasValues","has","key","addRows","level","keyMap","space","push","brightCyan","hAlign","content","gray","indention","Array","fill","join","concat","createObjectTable"],"sources":["../../src/utils/Console.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { frodo, FrodoError, state } from '@rockcarver/frodo-lib';\nimport {\n ProgressIndicatorStatusType,\n ProgressIndicatorType,\n} from '@rockcarver/frodo-lib/types/utils/Console';\nimport { MultiBar, Presets } from 'cli-progress';\nimport Table from 'cli-table3';\nimport Color from 'colors';\nimport { createSpinner } from 'nanospinner';\nimport { v4 as uuidv4 } from 'uuid';\n\nColor.enable();\n\nconst { appendTextToFile } = frodo.utils;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst progressBars: { [k: string]: any } = {};\nlet multiBarContainer = null;\nlet spinner = null;\n\n/**\n * Output a message in default color to stdout or append to `state.getOutputFile()`\n * @param {string | object} message the message\n */\nfunction data(message: string | object, newline = true) {\n if (!message) return;\n if (state.getOutputFile()) {\n if (typeof message === 'object') {\n message = JSON.stringify(message, null, 2);\n }\n if (newline) {\n message += '\\n';\n }\n appendTextToFile(message, state.getOutputFile());\n } else if (typeof message === 'object') {\n console.dir(message, { depth: 10, maxArrayLength: null });\n } else if (newline) {\n console.log(message);\n } else {\n process.stdout.write(message);\n }\n}\n\n/**\n * Output a default color message to stderr\n * @param {Object} message the message\n */\nfunction text(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message);\n } else {\n process.stderr.write(message);\n }\n}\n\n/**\n * Output a message in bright cyan to stderr\n * @param {Object} message the message\n */\nfunction info(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message['brightCyan']);\n } else {\n process.stderr.write(message['brightCyan']);\n }\n}\n\n/**\n * Output a message in yellow to stderr\n * @param {Object} message the message\n */\nfunction warn(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message['yellow']);\n } else {\n process.stderr.write(message['yellow']);\n }\n}\n\n/**\n * Output a message in bright red to stderr\n * @param {Object} message the message\n */\nfunction error(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message['brightRed']);\n } else {\n process.stderr.write(message['brightRed']);\n }\n}\n\n/**\n * Output a debug message\n * @param {string | object} message the message\n */\nfunction debug(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 6 });\n } else if (newline) {\n console.error(message['brightMagenta']);\n } else {\n process.stderr.write(message['brightMagenta']);\n }\n}\n\n/**\n * Output a curlirize message\n * @param {string} message the message\n */\nfunction curlirize(message: string) {\n if (!message) return;\n console.error(message['brightBlue']);\n}\n\n/**\n * Output a message in default color to stderr\n * @param {Object} message the message\n */\nexport function verboseMessage(message) {\n if (!message) return;\n if (state.getVerbose()) {\n text(message);\n }\n}\n\n/**\n * Output a debug message\n * @param {Object} message the message\n */\nexport function debugMessage(message) {\n if (!message) return;\n if (state.getDebug()) {\n debug(message);\n }\n}\n\n/**\n * Output a curlirize message\n * @param {Object} message the message\n */\nexport function curlirizeMessage(message) {\n if (!message) return;\n if (state.getCurlirize()) {\n curlirize(message);\n }\n}\n\n/**\n * Prints a string message to console\n *\n * @param {string} message The string message to print\n * @param {string} [type=text] \"text\", \"info\", \"warn\", \"error\" or \"data\". All but\n * type=\"data\" will be written to stderr.\n * @param {boolean} [newline=true] Whether to add a newline at the end of message\n *\n */\nexport function printMessage(message, type = 'text', newline = true) {\n switch (type) {\n case 'data':\n data(message, newline);\n break;\n case 'text':\n text(message, newline);\n break;\n case 'info':\n info(message, newline);\n break;\n case 'warn':\n warn(message, newline);\n break;\n case 'error':\n error(message, newline);\n break;\n default:\n text(message, newline);\n }\n}\n\n/**\n * Prints an error message from an error object and an optional custom message\n *\n * @param error error object\n */\nexport function printError(error: Error, message?: string) {\n if (message) printMessage('' + message, 'error');\n switch (error.name) {\n case 'FrodoError':\n printMessage('' + (error as FrodoError).getCombinedMessage(), 'error');\n break;\n\n case 'AxiosError': {\n const code = error['code'];\n const status = error['response'] ? error['response'].status : null;\n const message = error['response']\n ? error['response'].data\n ? error['response'].data.message\n : null\n : null;\n const detail = error['response']\n ? error['response'].data\n ? error['response'].data.detail\n : null\n : null;\n let errorMessage = 'HTTP client error';\n errorMessage += code ? `\\n Code: ${code}` : '';\n errorMessage += status ? `\\n Status: ${status}` : '';\n errorMessage += message ? `\\n Message: ${message}` : '';\n errorMessage += detail ? `\\n Detail: ${detail}` : '';\n printMessage(errorMessage, 'error');\n break;\n }\n\n default:\n printMessage(error.message, 'error');\n break;\n }\n}\n\n/**\n * Creates a progress bar on stderr\n *\n * Example:\n * [========================================] 100% | 49/49 | Analyzing journey - transactional_auth\n *\n * @param {number} total The total number of entries to track progress for\n * @param {string} message optional progress bar message\n * @param {object} options progress bar configuration options\n * @returns {string} progress bar reference id. Save this id to manage (update, stop) the progress bar.\n */\nfunction createProgressBar(\n total: number,\n message: string = null,\n options: object = {\n clearOnComplete: false,\n hideCursor: true,\n format: '[{bar}] {percentage}% | {value}/{total} | {data}',\n noTTYOutput: true,\n }\n): string {\n debugMessage(`cli.Console.createProgressBar: start`);\n let opt = options;\n if (message == null) {\n opt = {\n clearOnComplete: false,\n hideCursor: true,\n format: '[{bar}] {percentage}% | {value}/{total}',\n noTTYOutput: true,\n };\n }\n if (!multiBarContainer) {\n multiBarContainer = new MultiBar(opt, Presets.legacy);\n debugMessage(\n `cli.Console.createProgressBar: initialized multiBarContainer`\n );\n }\n const id = uuidv4();\n progressBars[id] = multiBarContainer.create(total, 0, {\n data: message,\n });\n debugMessage(\n `cli.Console.createProgressBar: end [${id}, ${\n Object.keys(progressBars).length\n } bars]`\n );\n return id;\n}\n\n/**\n * Updates the progress bar by 1\n * @param {string} message optional message to update the progress bar\n *\n */\nfunction updateProgressBar(id: string, message: string = null) {\n if (!progressBars[id]) {\n warn(\n `progressBar is undefined. Make sure to call 'createProgressBar' before calling 'updateProgressBar'.`\n );\n } else if (message) {\n progressBars[id].increment({\n data: message,\n });\n } else {\n progressBars[id].increment();\n }\n}\n\n/**\n * Stop and hide the progress bar\n * @param {*} message optional message to update the progress bar\n */\nfunction stopProgressBar(id: string, message: string = null) {\n debugMessage(`cli.Console.stopProgressBar: start [${id}]`);\n if (!progressBars[id]) {\n warn(\n `progressBar is undefined. Make sure to call 'createProgressBar' before calling 'stopProgressBar'.`\n );\n } else if (message) {\n progressBars[id].update({\n data: message,\n });\n }\n progressBars[id].stop();\n // progressBars[id].render();\n debugMessage(\n `cli.Console.stopProgressBar: end [${\n Object.keys(progressBars).length\n } bars]`\n );\n}\n\n/**\n * Clean-up progress bars\n */\nfunction cleanupProgressBars() {\n debugMessage(`cli.Console.cleanupProgressBars: start`);\n try {\n debugMessage(\n `cli.Console.cleanupProgressBars: stopping ${\n Object.keys(progressBars).length\n } bars`\n );\n multiBarContainer.stop();\n multiBarContainer = null;\n } catch (error) {\n // ignore\n }\n debugMessage(`cli.Console.cleanupProgressBars: end`);\n}\n\n/**\n * Create the spinner\n * @param {String} message optional spinner message\n */\nexport function showSpinner(message) {\n spinner = createSpinner(message).start();\n}\n\n/**\n * Stop the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function stopSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.stop(options);\n }\n}\n\n/**\n * Succeed the spinner. Stop and render success checkmark with optional message.\n * @param {String} message optional message to update the spinner\n */\nexport function succeedSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.success(options);\n }\n}\n\n/**\n * Warn the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function warnSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.warn(options);\n }\n}\n\n/**\n * Fail the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function failSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.error(options);\n }\n}\n\n/**\n * Spin the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function spinSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.update(options);\n spinner.spin();\n }\n}\n\nexport function createProgressIndicator(\n type: ProgressIndicatorType = 'determinate',\n total = 0,\n message = null\n): string {\n if (type === 'determinate') {\n return createProgressBar(total, message);\n } else {\n showSpinner(message);\n }\n}\n\nexport function updateProgressIndicator(id: string, message: string) {\n if (!progressBars[id]) {\n spinSpinner(message);\n } else {\n updateProgressBar(id, message);\n }\n}\n\nexport function stopProgressIndicator(\n id: string,\n message: string = null,\n status: ProgressIndicatorStatusType = 'none'\n) {\n if (!progressBars[id]) {\n switch (status) {\n case 'none':\n stopSpinner(message);\n break;\n case 'success':\n succeedSpinner(message);\n break;\n case 'warn':\n warnSpinner(message);\n break;\n case 'fail':\n failSpinner(message);\n break;\n default:\n stopSpinner(message);\n break;\n }\n } else {\n stopProgressBar(id, message);\n }\n}\n\nexport function cleanupProgressIndicators() {\n cleanupProgressBars();\n}\n\n/**\n * Create an empty table\n * @param {string[]} head header row as an array of strings\n * @returns {any} an empty table\n */\nexport function createTable(head) {\n const table = new Table({\n head,\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n return table;\n}\n\n/**\n * Create a new key/value table\n * @returns {any} an empty key/value table\n */\nexport function createKeyValueTable() {\n const table = new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0 },\n wordWrap: true,\n });\n return table;\n}\n\n/**\n * Helper function to determine the total depth of an object\n * @param {Object} object input object\n * @returns {Number} total depth of the input object\n */\nfunction getObjectDepth(object) {\n return Object(object) === object\n ? 1 + Math.max(-1, ...Object.values(object).map(getObjectDepth))\n : 0;\n}\n\n/**\n * Helper function to determine if an object has values\n * @param {Object} object input object\n * @returns {boolean} true of the object or any of its sub-objects contain values, false otherwise\n */\nfunction hasValues(object) {\n let has = false;\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n return true;\n }\n has = has || hasValues(object[key]);\n }\n return has;\n}\n\n/**\n * Helper function (recursive) to add rows to an object table\n * @param {object} object object to render\n * @param {number} depth total depth of initial object\n * @param {number} level current level\n * @param {any} table the object table to add the rows to\n * @param {Object} keyMap optional JSON map to map raw config names to human readable names {'raw': 'readable'}\n * @returns the updated object table\n */\nfunction addRows(object, depth, level, table, keyMap) {\n const space = ' ';\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n if (level === 1) {\n table.push([\n keyMap[key] ? keyMap[key].brightCyan : key['brightCyan'],\n object[key],\n ]);\n } else {\n table.push([\n {\n hAlign: 'right',\n content: keyMap[key] ? keyMap[key].gray : key.gray,\n },\n object[key],\n ]);\n }\n }\n }\n for (const key of keys) {\n if (Object(object[key]) === object[key]) {\n // only print header if there are any values below\n if (hasValues(object[key])) {\n let indention = new Array(level).fill(space).join('');\n if (level < 3) indention = `\\n${indention}`;\n table.push([\n indention.concat(\n keyMap[key] ? keyMap[key].brightCyan : key['brightCyan']\n ),\n '',\n ]);\n }\n // eslint-disable-next-line no-param-reassign\n table = addRows(object[key], depth, level + 1, table, keyMap);\n }\n }\n return table;\n}\n\n/**\n * Create and populate an object table from any JSON object. Use for describe commands.\n * @param {Object} object JSON object to create\n * @param {Object} keyMap optional JSON map to map raw config names to human readable names {'raw': 'readable'}\n * @returns {any} a table that can be printed to the console\n */\nexport function createObjectTable(object, keyMap = {}) {\n // eslint-disable-next-line no-param-reassign\n const depth = getObjectDepth(object);\n // eslint-disable-next-line no-param-reassign\n const level = 0;\n // eslint-disable-next-line no-param-reassign\n const table = new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n addRows(object, depth, level + 1, table, keyMap);\n return table;\n}\n"],"mappings":"AAAA;AACA,SAASA,KAAK,EAAcC,KAAK,QAAQ,uBAAuB;AAKhE,SAASC,QAAQ,EAAEC,OAAO,QAAQ,cAAc;AAChD,OAAOC,KAAK,MAAM,YAAY;AAC9B,OAAOC,KAAK,MAAM,QAAQ;AAC1B,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AAEnCH,KAAK,CAACI,MAAM,CAAC,CAAC;AAEd,MAAM;EAAEC;AAAiB,CAAC,GAAGV,KAAK,CAACW,KAAK;;AAExC;AACA,MAAMC,YAAkC,GAAG,CAAC,CAAC;AAC7C,IAAIC,iBAAiB,GAAG,IAAI;AAC5B,IAAIC,OAAO,GAAG,IAAI;;AAElB;AACA;AACA;AACA;AACA,SAASC,IAAIA,CAACC,OAA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,CAAC,CAACM,UAAU,GAAGN,GAAG,CAAC,YAAY,CACzD,CAAC,EACD,EAAE,CACH,CAAC;MACJ;MACA;MACAlB,KAAK,GAAGmB,OAAO,CAACR,MAAM,CAACO,GAAG,CAAC,EAAEjF,KAAK,EAAEmF,KAAK,GAAG,CAAC,EAAEpB,KAAK,EAAEqB,MAAM,CAAC;IAC/D;EACF;EACA,OAAOrB,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiC,iBAAiBA,CAACtB,MAAM,EAAEU,MAAM,GAAG,CAAC,CAAC,EAAE;EACrD;EACA,MAAMpF,KAAK,GAAGyE,cAAc,CAACC,MAAM,CAAC;EACpC;EACA,MAAMS,KAAK,GAAG,CAAC;EACf;EACA,MAAMpB,KAAK,GAAG,IAAIlF,KAAK,CAAC;IACtBmF,KAAK,EAAE;MACLC,GAAG,EAAE,EAAE;MACP,SAAS,EAAE,EAAE;MACb,UAAU,EAAE,EAAE;MACd,WAAW,EAAE,EAAE;MACfC,MAAM,EAAE,EAAE;MACV,YAAY,EAAE,EAAE;MAChB,aAAa,EAAE,EAAE;MACjB,cAAc,EAAE,EAAE;MAClBC,IAAI,EAAE,EAAE;MACR,UAAU,EAAE,EAAE;MACdC,GAAG,EAAE,EAAE;MACP,SAAS,EAAE,EAAE;MACbC,KAAK,EAAE,EAAE;MACT,WAAW,EAAE;IACf,CAAC;IACDC,KAAK,EAAE;MAAE,cAAc,EAAE,CAAC;MAAE,eAAe,EAAE,CAAC;MAAER,IAAI,EAAE,CAAC,YAAY;IAAE;EACvE,CAAC,CAAC;EACFoB,OAAO,CAACR,MAAM,EAAE1E,KAAK,EAAEmF,KAAK,GAAG,CAAC,EAAEpB,KAAK,EAAEqB,MAAM,CAAC;EAChD,OAAOrB,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"Console.js","names":["frodo","state","MultiBar","Presets","Table","Color","createSpinner","v4","uuidv4","enable","appendTextToFile","utils","progressBars","multiBarContainer","spinner","data","message","newline","getOutputFile","JSON","stringify","console","dir","depth","maxArrayLength","log","process","stdout","write","text","error","stderr","info","warn","debug","curlirize","verboseMessage","getVerbose","debugMessage","getDebug","curlirizeMessage","getCurlirize","printMessage","type","printError","name","getCombinedMessage","code","status","detail","errorMessage","createProgressBar","total","options","clearOnComplete","hideCursor","format","noTTYOutput","forceRedraw","gracefulExit","stopOnComplete","opt","legacy","id","create","Object","keys","length","updateProgressBar","increment","stopProgressBar","update","stop","cleanupProgressBars","showSpinner","start","stopSpinner","succeedSpinner","success","warnSpinner","failSpinner","spinSpinner","spin","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","cleanupProgressIndicators","createTable","head","table","chars","top","bottom","left","mid","right","style","createKeyValueTable","wordWrap","getObjectDepth","object","Math","max","values","map","hasValues","has","key","addRows","level","keyMap","space","push","brightCyan","hAlign","content","gray","indention","Array","fill","join","concat","createObjectTable"],"sources":["../../src/utils/Console.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { frodo, FrodoError, state } from '@rockcarver/frodo-lib';\nimport {\n ProgressIndicatorStatusType,\n ProgressIndicatorType,\n} from '@rockcarver/frodo-lib/types/utils/Console';\nimport { MultiBar, Presets } from 'cli-progress';\nimport Table from 'cli-table3';\nimport Color from 'colors';\nimport { createSpinner } from 'nanospinner';\nimport { v4 as uuidv4 } from 'uuid';\n\nColor.enable();\n\nconst { appendTextToFile } = frodo.utils;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst progressBars: { [k: string]: any } = {};\nlet multiBarContainer = null;\nlet spinner = null;\n\n/**\n * Output a message in default color to stdout or append to `state.getOutputFile()`\n * @param {string | object} message the message\n */\nfunction data(message: string | object, newline = true) {\n if (!message) return;\n if (state.getOutputFile()) {\n if (typeof message === 'object') {\n message = JSON.stringify(message, null, 2);\n }\n if (newline) {\n message += '\\n';\n }\n appendTextToFile(message, state.getOutputFile());\n } else if (typeof message === 'object') {\n console.dir(message, { depth: 10, maxArrayLength: null });\n } else if (newline) {\n console.log(message);\n } else {\n process.stdout.write(message);\n }\n}\n\n/**\n * Output a default color message to stderr\n * @param {Object} message the message\n */\nfunction text(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message);\n } else {\n process.stderr.write(message);\n }\n}\n\n/**\n * Output a message in bright cyan to stderr\n * @param {Object} message the message\n */\nfunction info(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message['brightCyan']);\n } else {\n process.stderr.write(message['brightCyan']);\n }\n}\n\n/**\n * Output a message in yellow to stderr\n * @param {Object} message the message\n */\nfunction warn(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message['yellow']);\n } else {\n process.stderr.write(message['yellow']);\n }\n}\n\n/**\n * Output a message in bright red to stderr\n * @param {Object} message the message\n */\nfunction error(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 3 });\n } else if (newline) {\n console.error(message['brightRed']);\n } else {\n process.stderr.write(message['brightRed']);\n }\n}\n\n/**\n * Output a debug message\n * @param {string | object} message the message\n */\nfunction debug(message: string | object, newline = true) {\n if (!message) return;\n if (typeof message === 'object') {\n console.dir(message, { depth: 6 });\n } else if (newline) {\n console.error(message['brightMagenta']);\n } else {\n process.stderr.write(message['brightMagenta']);\n }\n}\n\n/**\n * Output a curlirize message\n * @param {string} message the message\n */\nfunction curlirize(message: string) {\n if (!message) return;\n console.error(message['brightBlue']);\n}\n\n/**\n * Output a message in default color to stderr\n * @param {Object} message the message\n */\nexport function verboseMessage(message) {\n if (!message) return;\n if (state.getVerbose()) {\n text(message);\n }\n}\n\n/**\n * Output a debug message\n * @param {Object} message the message\n */\nexport function debugMessage(message) {\n if (!message) return;\n if (state.getDebug()) {\n debug(message);\n }\n}\n\n/**\n * Output a curlirize message\n * @param {Object} message the message\n */\nexport function curlirizeMessage(message) {\n if (!message) return;\n if (state.getCurlirize()) {\n curlirize(message);\n }\n}\n\n/**\n * Prints a string message to console\n *\n * @param {string} message The string message to print\n * @param {string} [type=text] \"text\", \"info\", \"warn\", \"error\" or \"data\". All but\n * type=\"data\" will be written to stderr.\n * @param {boolean} [newline=true] Whether to add a newline at the end of message\n *\n */\nexport function printMessage(message, type = 'text', newline = true) {\n switch (type) {\n case 'data':\n data(message, newline);\n break;\n case 'text':\n text(message, newline);\n break;\n case 'info':\n info(message, newline);\n break;\n case 'warn':\n warn(message, newline);\n break;\n case 'error':\n error(message, newline);\n break;\n default:\n text(message, newline);\n }\n}\n\n/**\n * Prints an error message from an error object and an optional custom message\n *\n * @param error error object\n */\nexport function printError(error: Error, message?: string) {\n if (message) printMessage('' + message, 'error');\n switch (error.name) {\n case 'FrodoError':\n printMessage('' + (error as FrodoError).getCombinedMessage(), 'error');\n break;\n\n case 'AxiosError': {\n const code = error['code'];\n const status = error['response'] ? error['response'].status : null;\n const message = error['response']\n ? error['response'].data\n ? error['response'].data.message\n : null\n : null;\n const detail = error['response']\n ? error['response'].data\n ? error['response'].data.detail\n : null\n : null;\n let errorMessage = 'HTTP client error';\n errorMessage += code ? `\\n Code: ${code}` : '';\n errorMessage += status ? `\\n Status: ${status}` : '';\n errorMessage += message ? `\\n Message: ${message}` : '';\n errorMessage += detail ? `\\n Detail: ${detail}` : '';\n printMessage(errorMessage, 'error');\n break;\n }\n\n default:\n printMessage(error.message, 'error');\n break;\n }\n}\n\n/**\n * Creates a progress bar on stderr\n *\n * Example:\n * [========================================] 100% | 49/49 | Analyzing journey - transactional_auth\n *\n * @param {number} total The total number of entries to track progress for\n * @param {string} message optional progress bar message\n * @param {object} options progress bar configuration options\n * @returns {string} progress bar reference id. Save this id to manage (update, stop) the progress bar.\n */\nfunction createProgressBar(\n total: number,\n message: string = null,\n options: object = {\n clearOnComplete: false,\n hideCursor: true,\n format: '[{bar}] {percentage}% | {value}/{total} | {data}',\n noTTYOutput: true,\n forceRedraw: true,\n gracefulExit: true,\n stopOnComplete: true,\n }\n): string {\n debugMessage(`cli.Console.createProgressBar: start`);\n let opt = options;\n if (message == null) {\n opt = {\n clearOnComplete: false,\n hideCursor: true,\n format: '[{bar}] {percentage}% | {value}/{total}',\n noTTYOutput: true,\n forceRedraw: true,\n gracefulExit: true,\n stopOnComplete: true,\n };\n }\n if (!multiBarContainer) {\n multiBarContainer = new MultiBar(opt, Presets.legacy);\n debugMessage(\n `cli.Console.createProgressBar: initialized multiBarContainer`\n );\n }\n const id = uuidv4();\n progressBars[id] = multiBarContainer.create(total, 0, {\n data: message,\n });\n debugMessage(\n `cli.Console.createProgressBar: end [${id}, ${\n Object.keys(progressBars).length\n } bars]`\n );\n return id;\n}\n\n/**\n * Updates the progress bar by 1\n * @param {string} message optional message to update the progress bar\n *\n */\nfunction updateProgressBar(id: string, message: string = null) {\n if (!progressBars[id]) {\n warn(\n `progressBar is undefined. Make sure to call 'createProgressBar' before calling 'updateProgressBar'.`\n );\n } else if (message) {\n progressBars[id].increment({\n data: message,\n });\n } else {\n progressBars[id].increment();\n }\n}\n\n/**\n * Stop and hide the progress bar\n * @param {*} message optional message to update the progress bar\n */\nfunction stopProgressBar(id: string, message: string = null) {\n debugMessage(`cli.Console.stopProgressBar: start [${id}]`);\n if (!progressBars[id]) {\n warn(\n `progressBar is undefined. Make sure to call 'createProgressBar' before calling 'stopProgressBar'.`\n );\n } else if (message) {\n progressBars[id].update({\n data: message,\n });\n }\n progressBars[id].stop();\n // progressBars[id].render();\n debugMessage(\n `cli.Console.stopProgressBar: end [${\n Object.keys(progressBars).length\n } bars]`\n );\n}\n\n/**\n * Clean-up progress bars\n */\nfunction cleanupProgressBars() {\n debugMessage(`cli.Console.cleanupProgressBars: start`);\n try {\n debugMessage(\n `cli.Console.cleanupProgressBars: stopping ${\n Object.keys(progressBars).length\n } bars`\n );\n multiBarContainer.stop();\n multiBarContainer = null;\n } catch (error) {\n // ignore\n }\n debugMessage(`cli.Console.cleanupProgressBars: end`);\n}\n\n/**\n * Create the spinner\n * @param {String} message optional spinner message\n */\nexport function showSpinner(message) {\n spinner = createSpinner(message).start();\n}\n\n/**\n * Stop the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function stopSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.stop(options);\n }\n}\n\n/**\n * Succeed the spinner. Stop and render success checkmark with optional message.\n * @param {String} message optional message to update the spinner\n */\nexport function succeedSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.success(options);\n }\n}\n\n/**\n * Warn the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function warnSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.warn(options);\n }\n}\n\n/**\n * Fail the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function failSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.error(options);\n }\n}\n\n/**\n * Spin the spinner\n * @param {String} message optional message to update the spinner\n */\nexport function spinSpinner(message = null) {\n if (spinner) {\n let options = {};\n if (message) options = { text: message };\n spinner.update(options);\n spinner.spin();\n }\n}\n\nexport function createProgressIndicator(\n type: ProgressIndicatorType = 'determinate',\n total = 0,\n message = null\n): string {\n if (type === 'determinate') {\n return createProgressBar(total, message);\n } else {\n showSpinner(message);\n }\n}\n\nexport function updateProgressIndicator(id: string, message: string) {\n if (!progressBars[id]) {\n spinSpinner(message);\n } else {\n updateProgressBar(id, message);\n }\n}\n\nexport function stopProgressIndicator(\n id: string,\n message: string = null,\n status: ProgressIndicatorStatusType = 'none'\n) {\n if (!progressBars[id]) {\n switch (status) {\n case 'none':\n stopSpinner(message);\n break;\n case 'success':\n succeedSpinner(message);\n break;\n case 'warn':\n warnSpinner(message);\n break;\n case 'fail':\n failSpinner(message);\n break;\n default:\n stopSpinner(message);\n break;\n }\n } else {\n stopProgressBar(id, message);\n }\n}\n\nexport function cleanupProgressIndicators() {\n cleanupProgressBars();\n}\n\n/**\n * Create an empty table\n * @param {string[]} head header row as an array of strings\n * @returns {any} an empty table\n */\nexport function createTable(head) {\n const table = new Table({\n head,\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n return table;\n}\n\n/**\n * Create a new key/value table\n * @returns {any} an empty key/value table\n */\nexport function createKeyValueTable() {\n const table = new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0 },\n wordWrap: true,\n });\n return table;\n}\n\n/**\n * Helper function to determine the total depth of an object\n * @param {Object} object input object\n * @returns {Number} total depth of the input object\n */\nfunction getObjectDepth(object) {\n return Object(object) === object\n ? 1 + Math.max(-1, ...Object.values(object).map(getObjectDepth))\n : 0;\n}\n\n/**\n * Helper function to determine if an object has values\n * @param {Object} object input object\n * @returns {boolean} true of the object or any of its sub-objects contain values, false otherwise\n */\nfunction hasValues(object) {\n let has = false;\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n return true;\n }\n has = has || hasValues(object[key]);\n }\n return has;\n}\n\n/**\n * Helper function (recursive) to add rows to an object table\n * @param {object} object object to render\n * @param {number} depth total depth of initial object\n * @param {number} level current level\n * @param {any} table the object table to add the rows to\n * @param {Object} keyMap optional JSON map to map raw config names to human readable names {'raw': 'readable'}\n * @returns the updated object table\n */\nfunction addRows(object, depth, level, table, keyMap) {\n const space = ' ';\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n if (level === 1) {\n table.push([\n keyMap[key] ? keyMap[key].brightCyan : key['brightCyan'],\n object[key],\n ]);\n } else {\n table.push([\n {\n hAlign: 'right',\n content: keyMap[key] ? keyMap[key].gray : key.gray,\n },\n object[key],\n ]);\n }\n }\n }\n for (const key of keys) {\n if (Object(object[key]) === object[key]) {\n // only print header if there are any values below\n if (hasValues(object[key])) {\n let indention = new Array(level).fill(space).join('');\n if (level < 3) indention = `\\n${indention}`;\n table.push([\n indention.concat(\n keyMap[key] ? keyMap[key].brightCyan : key['brightCyan']\n ),\n '',\n ]);\n }\n // eslint-disable-next-line no-param-reassign\n table = addRows(object[key], depth, level + 1, table, keyMap);\n }\n }\n return table;\n}\n\n/**\n * Create and populate an object table from any JSON object. Use for describe commands.\n * @param {Object} object JSON object to create\n * @param {Object} keyMap optional JSON map to map raw config names to human readable names {'raw': 'readable'}\n * @returns {any} a table that can be printed to the console\n */\nexport function createObjectTable(object, keyMap = {}) {\n // eslint-disable-next-line no-param-reassign\n const depth = getObjectDepth(object);\n // eslint-disable-next-line no-param-reassign\n const level = 0;\n // eslint-disable-next-line no-param-reassign\n const table = new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n addRows(object, depth, level + 1, table, keyMap);\n return table;\n}\n"],"mappings":"AAAA;AACA,SAASA,KAAK,EAAcC,KAAK,QAAQ,uBAAuB;AAKhE,SAASC,QAAQ,EAAEC,OAAO,QAAQ,cAAc;AAChD,OAAOC,KAAK,MAAM,YAAY;AAC9B,OAAOC,KAAK,MAAM,QAAQ;AAC1B,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,EAAE,IAAIC,M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MACP,SAAS,EAAE,EAAE;MACbC,KAAK,EAAE,EAAE;MACT,WAAW,EAAE;IACf,CAAC;IACDC,KAAK,EAAE;MAAE,cAAc,EAAE,CAAC;MAAE,eAAe,EAAE,CAAC;MAAER,IAAI,EAAE,CAAC,YAAY;IAAE;EACvE,CAAC,CAAC;EACFoB,OAAO,CAACR,MAAM,EAAE7E,KAAK,EAAEsF,KAAK,GAAG,CAAC,EAAEpB,KAAK,EAAEqB,MAAM,CAAC;EAChD,OAAOrB,KAAK;AACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rockcarver/frodo-cli",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-55",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
|
|
6
6
|
"keywords": [
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
]
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
|
-
"@rockcarver/frodo-lib": "2.0.0-
|
|
122
|
+
"@rockcarver/frodo-lib": "2.0.0-77",
|
|
123
123
|
"chokidar": "^3.5.3",
|
|
124
124
|
"cli-progress": "^3.11.2",
|
|
125
125
|
"cli-table3": "^0.6.3",
|