@rockcarver/frodo-cli 2.0.0-42 → 2.0.0-44
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 +9 -1
- package/esm/cli/config/config-export.js +5 -3
- package/esm/cli/config/config-export.js.map +1 -1
- package/esm/cli/config/config-import.js +5 -3
- package/esm/cli/config/config-import.js.map +1 -1
- package/esm/cli/saml/saml-export.js +10 -4
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/script/script-export.js +3 -3
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +9 -3
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/ops/ConfigOps.js +8 -4
- package/esm/ops/ConfigOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +12 -6
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +26 -17
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/utils/Config.js +2 -1
- package/esm/utils/Config.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0-43] - 2024-01-05
|
|
11
|
+
|
|
12
|
+
## [2.0.0-42] - 2024-01-04
|
|
13
|
+
|
|
10
14
|
## [2.0.0-41] - 2023-12-23
|
|
11
15
|
|
|
12
16
|
## [2.0.0-40] - 2023-12-22
|
|
@@ -1449,7 +1453,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1449
1453
|
- Fixed problem with adding connection profiles
|
|
1450
1454
|
- Miscellaneous bug fixes
|
|
1451
1455
|
|
|
1452
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-
|
|
1456
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-43...HEAD
|
|
1457
|
+
|
|
1458
|
+
[2.0.0-43]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-42...v2.0.0-43
|
|
1459
|
+
|
|
1460
|
+
[2.0.0-42]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-41...v2.0.0-42
|
|
1453
1461
|
|
|
1454
1462
|
[2.0.0-41]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-40...v2.0.0-41
|
|
1455
1463
|
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = frodo.login;
|
|
9
9
|
const program = new FrodoCommand('frodo config export');
|
|
10
|
-
program.description('Export full cloud configuration for all ops that currently support export.').addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export everything to a single file.')).addOption(new Option('-A, --all-separate', 'Export everything to separate files in the -D directory. Ignored with -a.')).addOption(new Option('--use-string-arrays', 'Where applicable, use string arrays to store multi-line text (e.g. scripts).').default(false, 'off')).addOption(new Option('--no-decode', 'Do not include decoded variable value in variable export').default(false, 'false')).addOption(new Option('-x, --extract', 'Extract scripts from the exported file, and save it to a separate file. Ignored with -a.')).addOption(new Option('-N, --no-metadata', 'Does not include metadata in the export file.')).addOption(new Option('--no-coords', 'Do not include the x and y coordinate positions of the journey/tree nodes.')).action(
|
|
10
|
+
program.description('Export full cloud configuration for all ops that currently support export.').addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export everything to a single file.')).addOption(new Option('-A, --all-separate', 'Export everything to separate files in the -D directory. Ignored with -a.')).addOption(new Option('--use-string-arrays', 'Where applicable, use string arrays to store multi-line text (e.g. scripts).').default(false, 'off')).addOption(new Option('--no-decode', 'Do not include decoded variable value in variable export').default(false, 'false')).addOption(new Option('-x, --extract', 'Extract scripts from the exported file, and save it to a separate file. Ignored with -a.')).addOption(new Option('-N, --no-metadata', 'Does not include metadata in the export file.')).addOption(new Option('--no-coords', 'Do not include the x and y coordinate positions of the journey/tree nodes.')).addOption(new Option('-d, --default', 'Export all scripts including the default scripts.')).action(
|
|
11
11
|
// implement command logic inside action handler
|
|
12
12
|
async (host, realm, user, password, options, command) => {
|
|
13
13
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
@@ -17,7 +17,8 @@ async (host, realm, user, password, options, command) => {
|
|
|
17
17
|
await exportEverythingToFile(options.file, options.metadata, {
|
|
18
18
|
useStringArrays: options.useStringArrays,
|
|
19
19
|
noDecode: options.decode,
|
|
20
|
-
coords: options.coords
|
|
20
|
+
coords: options.coords,
|
|
21
|
+
includeDefault: options.default
|
|
21
22
|
});
|
|
22
23
|
// require --directory -D for all-separate function
|
|
23
24
|
} else if (options.allSeparate && !state.getDirectory()) {
|
|
@@ -30,7 +31,8 @@ async (host, realm, user, password, options, command) => {
|
|
|
30
31
|
await exportEverythingToFiles(options.extract, options.metadata, {
|
|
31
32
|
useStringArrays: options.useStringArrays,
|
|
32
33
|
noDecode: options.decode,
|
|
33
|
-
coords: options.coords
|
|
34
|
+
coords: options.coords,
|
|
35
|
+
includeDefault: options.default
|
|
34
36
|
});
|
|
35
37
|
// unrecognized combination of options or no options
|
|
36
38
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-export.js","names":["frodo","state","Option","exportEverythingToFile","exportEverythingToFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","metadata","useStringArrays","noDecode","decode","coords","allSeparate","getDirectory","help","process","exitCode","extract","parse"],"sources":["../../../src/cli/config/config-export.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportEverythingToFile,\n exportEverythingToFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\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 .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 await exportEverythingToFile(options.file, options.metadata, {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\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 // --all-separate -A\n } else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting everything to separate files...');\n await exportEverythingToFiles(options.extract, options.metadata, {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\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,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,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ACtCF,cAAc,CAAC,0CAA0C,CAAC;IAC1D,MAAMH,sBAAsB,CAACgB,OAAO,CAACI,IAAI,EAAEJ,OAAO,CAACK,QAAQ,EAAE;MAC3DC,eAAe,EAAEN,OAAO,CAACM,eAAe;MACxCC,QAAQ,EAAEP,OAAO,CAACQ,MAAM;MACxBC,MAAM,EAAET,OAAO,CAACS;
|
|
1
|
+
{"version":3,"file":"config-export.js","names":["frodo","state","Option","exportEverythingToFile","exportEverythingToFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","metadata","useStringArrays","noDecode","decode","coords","includeDefault","allSeparate","getDirectory","help","process","exitCode","extract","parse"],"sources":["../../../src/cli/config/config-export.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportEverythingToFile,\n exportEverythingToFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\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 await exportEverythingToFile(options.file, options.metadata, {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\n includeDefault: options.default,\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 // --all-separate -A\n } else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting everything to separate files...');\n await exportEverythingToFiles(options.extract, options.metadata, {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\n includeDefault: options.default,\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,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,sBAAsB,EACtBC,uBAAuB,QAClB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGR,KAAK,CAACS,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,qBAAqB,CAAC;AAEvDG,OAAO,CACJC,WAAW,CACV,4EACF,CAAC,CACAC,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEU,SAAS,CAAC,IAAIV,MAAM,CAAC,WAAW,EAAE,qCAAqC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vD1B,YAAY,CACV,4DAA4D,EAC5D,OACF,CAAC;IACDK,OAAO,CAACsB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpB;EACF,CAAC,MAAM,IAAIf,OAAO,CAACW,WAAW,KAAK,MAAMtB,SAAS,CAAC,CAAC,CAAC,EAAE;IACrDF,cAAc,CAAC,2CAA2C,CAAC;IAC3D,MAAMF,uBAAuB,CAACe,OAAO,CAACgB,OAAO,EAAEhB,OAAO,CAACK,QAAQ,EAAE;MAC/DC,eAAe,EAAEN,OAAO,CAACM,eAAe;MACxCC,QAAQ,EAAEP,OAAO,CAACQ,MAAM;MACxBC,MAAM,EAAET,OAAO,CAACS,MAAM;MACtBC,cAAc,EAAEV,OAAO,CAACN;IAC1B,CAAC,CAAC;IACF;EACF,CAAC,MAAM;IACLP,cAAc,CAAC,sDAAsD,CAAC;IACtEI,OAAO,CAACsB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHxB,OAAO,CAAC0B,KAAK,CAAC,CAAC"}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = frodo.login;
|
|
9
9
|
const program = new FrodoCommand('frodo config import');
|
|
10
|
-
program.description('Import full cloud configuration.').addOption(new Option('-f, --file <file>', 'Name of the file to import.')).addOption(new Option('-a, --all', 'Import all configuration from the single file -f. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Import all configuration from separate (.json) files in the (working) directory -D. Ignored with -i or -a.')).addOption(new Option('-C, --clean', 'Remove existing service(s) before importing.')).addOption(new Option('-g, --global', 'Import service(s) as global service(s).')).addOption(new Option('-r, --current-realm', 'Import service(s) into the current realm.')).addOption(new Option('--re-uuid-journeys', 'Generate new UUIDs for all journey nodes during import.').default(false, 'off')).addOption(new Option('--re-uuid-scripts', 'Create new UUIDs for the scripts upon import. Use this to duplicate scripts or create a new versions of the same scripts.').default(false, 'off')).action(
|
|
10
|
+
program.description('Import full cloud configuration.').addOption(new Option('-f, --file <file>', 'Name of the file to import.')).addOption(new Option('-a, --all', 'Import all configuration from the single file -f. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Import all configuration from separate (.json) files in the (working) directory -D. Ignored with -i or -a.')).addOption(new Option('-C, --clean', 'Remove existing service(s) before importing.')).addOption(new Option('-g, --global', 'Import service(s) as global service(s).')).addOption(new Option('-r, --current-realm', 'Import service(s) into the current realm.')).addOption(new Option('--re-uuid-journeys', 'Generate new UUIDs for all journey nodes during import.').default(false, 'off')).addOption(new Option('--re-uuid-scripts', 'Create new UUIDs for the scripts upon import. Use this to duplicate scripts or create a new versions of the same scripts.').default(false, 'off')).addOption(new Option('-d, --default', 'Import all scripts including the default scripts.')).action(
|
|
11
11
|
// implement command logic inside action handler
|
|
12
12
|
async (host, realm, user, password, options, command) => {
|
|
13
13
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
@@ -24,7 +24,8 @@ async (host, realm, user, password, options, command) => {
|
|
|
24
24
|
reUuidScripts: options.reUuidScripts,
|
|
25
25
|
cleanServices: options.clean,
|
|
26
26
|
global: options.global,
|
|
27
|
-
realm: options.realm
|
|
27
|
+
realm: options.realm,
|
|
28
|
+
includeDefault: options.default
|
|
28
29
|
});
|
|
29
30
|
// require --directory -D for all-separate function
|
|
30
31
|
} else if (options.allSeparate && !state.getDirectory()) {
|
|
@@ -39,7 +40,8 @@ async (host, realm, user, password, options, command) => {
|
|
|
39
40
|
reUuidScripts: options.reUuidScripts,
|
|
40
41
|
cleanServices: options.clean,
|
|
41
42
|
global: options.global,
|
|
42
|
-
realm: options.realm
|
|
43
|
+
realm: options.realm,
|
|
44
|
+
includeDefault: options.default
|
|
43
45
|
});
|
|
44
46
|
// unrecognized combination of options or no options
|
|
45
47
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-import.js","names":["frodo","state","Option","importEverythingFromFile","importEverythingFromFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","help","process","exitCode","reUuidJourneys","reUuidScripts","cleanServices","clean","global","allSeparate","getDirectory","parse"],"sources":["../../../src/cli/config/config-import.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importEverythingFromFile,\n importEverythingFromFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\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 .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 // --all -a\n } else if (options.all && (await getTokens())) {\n verboseMessage('Exporting everything from a single file...');\n 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 });\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 // --all-separate -A\n } else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Importing everything from separate files...');\n await importEverythingFromFiles({\n reUuidJourneys: options.reUuidJourneys,\n reUuidScripts: options.reUuidScripts,\n cleanServices: options.clean,\n global: options.global,\n realm: options.realm,\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,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGR,KAAK,CAACS,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,qBAAqB,CAAC;AAEvDG,OAAO,CACJC,WAAW,CAAC,kCAAkC,CAAC,CAC/CC,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,oEACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,4GACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CAAC,aAAa,EAAE,8CAA8C,CAC1E,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CAAC,cAAc,EAAE,yCAAyC,CACtE,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,qBAAqB,EACrB,2CACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,yDACF,CAAC,CAACW,OAAO,CAAC,KAAK,EAAE,KAAK,CACxB,CAAC,CACAD,SAAS,CACR,IAAIV,MAAM,CACR,mBAAmB,EACnB,2HACF,CAAC,CAACW,OAAO,CAAC,KAAK,EAAE,KAAK,CACxB,CAAC,
|
|
1
|
+
{"version":3,"file":"config-import.js","names":["frodo","state","Option","importEverythingFromFile","importEverythingFromFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","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 { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importEverythingFromFile,\n importEverythingFromFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\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 // --all -a\n } else if (options.all && (await getTokens())) {\n verboseMessage('Exporting everything from a single file...');\n 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 // 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 // --all-separate -A\n } else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Importing everything from separate files...');\n 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 // 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,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGR,KAAK,CAACS,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,qB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= frodo.login;
|
|
9
9
|
const program = new FrodoCommand('frodo saml export');
|
|
10
|
-
program.description('Export SAML entity providers.').addOption(new Option('-i, --entity-id <entity-id>', 'Entity id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file [file]', 'Name of the file to write the exported provider(s) to. Ignored with -A. If not specified, the export file is named <id>.saml.json.')).addOption(new Option('-a, --all', 'Export all the providers in a realm to a single file. Ignored with -t and -i.')).addOption(new Option('-A, --all-separate', 'Export all the providers in a realm as separate files <provider name>.saml.json. Ignored with -t, -i, and -a.')).addOption(new Option('-N, --no-metadata', 'Does not include metadata in the export file.')).action(
|
|
10
|
+
program.description('Export SAML entity providers.').addOption(new Option('-i, --entity-id <entity-id>', 'Entity id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file [file]', 'Name of the file to write the exported provider(s) to. Ignored with -A. If not specified, the export file is named <id>.saml.json.')).addOption(new Option('-a, --all', 'Export all the providers in a realm to a single file. Ignored with -t and -i.')).addOption(new Option('-A, --all-separate', 'Export all the providers in a realm as separate files <provider name>.saml.json. Ignored with -t, -i, and -a.')).addOption(new Option('-N, --no-metadata', 'Does not include metadata in the export file.')).addOption(new Option('--no-deps', 'Do not include any dependencies (scripts).')).action(
|
|
11
11
|
// implement command logic inside action handler
|
|
12
12
|
async (host, realm, user, password, options, command) => {
|
|
13
13
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
14
14
|
// export by id/name
|
|
15
15
|
if (options.entityId && (await getTokens())) {
|
|
16
16
|
verboseMessage(`Exporting provider "${options.entityId}" from realm "${state.getRealm()}"...`);
|
|
17
|
-
await exportSaml2ProviderToFile(options.entityId, options.file, options.metadata
|
|
17
|
+
await exportSaml2ProviderToFile(options.entityId, options.file, options.metadata, {
|
|
18
|
+
deps: options.deps
|
|
19
|
+
});
|
|
18
20
|
}
|
|
19
21
|
// --all -a
|
|
20
22
|
else if (options.all && (await getTokens())) {
|
|
21
23
|
verboseMessage('Exporting all providers to a single file...');
|
|
22
|
-
await exportSaml2ProvidersToFile(options.file, options.metadata
|
|
24
|
+
await exportSaml2ProvidersToFile(options.file, options.metadata, {
|
|
25
|
+
deps: options.deps
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
// --all-separate -A
|
|
25
29
|
else if (options.allSeparate && (await getTokens())) {
|
|
26
30
|
verboseMessage('Exporting all providers to separate files...');
|
|
27
|
-
await exportSaml2ProvidersToFiles(options.metadata
|
|
31
|
+
await exportSaml2ProvidersToFiles(options.metadata, {
|
|
32
|
+
deps: options.deps
|
|
33
|
+
});
|
|
28
34
|
}
|
|
29
35
|
// unrecognized combination of options or no options
|
|
30
36
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saml-export.js","names":["frodo","state","Option","exportSaml2ProvidersToFile","exportSaml2ProvidersToFiles","exportSaml2ProviderToFile","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","entityId","getRealm","file","metadata","all","allSeparate","help","process","exitCode","parse"],"sources":["../../../src/cli/saml/saml-export.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportSaml2ProvidersToFile,\n exportSaml2ProvidersToFiles,\n exportSaml2ProviderToFile,\n} from '../../ops/Saml2Ops';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo saml export');\n\nprogram\n .description('Export SAML entity providers.')\n .addOption(\n new Option(\n '-i, --entity-id <entity-id>',\n 'Entity id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file [file]',\n 'Name of the file to write the exported provider(s) to. Ignored with -A. If not specified, the export file is named <id>.saml.json.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the providers in a realm to a single file. Ignored with -t and -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all the providers in a realm as separate files <provider name>.saml.json. Ignored with -t, -i, and -a.'\n )\n )\n .addOption(\n new Option(\n '-N, --no-metadata',\n 'Does not include metadata in the export file.'\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 // export by id/name\n if (options.entityId && (await getTokens())) {\n verboseMessage(\n `Exporting provider \"${\n options.entityId\n }\" from realm \"${state.getRealm()}\"...`\n );\n await exportSaml2ProviderToFile(\n options.entityId,\n options.file,\n options.metadata\n );\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all providers to a single file...');\n await exportSaml2ProvidersToFile(options.file, options.metadata);\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all providers to separate files...');\n await exportSaml2ProvidersToFiles(options.metadata);\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\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,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,yBAAyB,QACpB,oBAAoB;AAC3B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGT,KAAK,CAACU,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,mBAAmB,CAAC;AAErDG,OAAO,CACJC,WAAW,CAAC,+BAA+B,CAAC,CAC5CC,SAAS,CACR,IAAIX,MAAM,CACR,6BAA6B,EAC7B,iDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,mBAAmB,EACnB,oIACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,+EACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,+GACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,mBAAmB,EACnB,+CACF,CACF,CAAC,CACAY,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,QAAQ,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CACX,uBACCY,OAAO,CAACG,QACT,iBAAgBrB,KAAK,CAACsB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACD,MAAMlB,yBAAyB,CAC7Bc,OAAO,CAACG,QAAQ,EAChBH,OAAO,CAACK,IAAI,EACZL,OAAO,CAACM,
|
|
1
|
+
{"version":3,"file":"saml-export.js","names":["frodo","state","Option","exportSaml2ProvidersToFile","exportSaml2ProvidersToFiles","exportSaml2ProviderToFile","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","entityId","getRealm","file","metadata","deps","all","allSeparate","help","process","exitCode","parse"],"sources":["../../../src/cli/saml/saml-export.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportSaml2ProvidersToFile,\n exportSaml2ProvidersToFiles,\n exportSaml2ProviderToFile,\n} from '../../ops/Saml2Ops';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo saml export');\n\nprogram\n .description('Export SAML entity providers.')\n .addOption(\n new Option(\n '-i, --entity-id <entity-id>',\n 'Entity id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file [file]',\n 'Name of the file to write the exported provider(s) to. Ignored with -A. If not specified, the export file is named <id>.saml.json.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the providers in a realm to a single file. Ignored with -t and -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all the providers in a realm as separate files <provider name>.saml.json. Ignored with -t, -i, and -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('--no-deps', 'Do not include any dependencies (scripts).')\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 // export by id/name\n if (options.entityId && (await getTokens())) {\n verboseMessage(\n `Exporting provider \"${\n options.entityId\n }\" from realm \"${state.getRealm()}\"...`\n );\n await exportSaml2ProviderToFile(\n options.entityId,\n options.file,\n options.metadata,\n {\n deps: options.deps,\n }\n );\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all providers to a single file...');\n await exportSaml2ProvidersToFile(options.file, options.metadata, {\n deps: options.deps,\n });\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all providers to separate files...');\n await exportSaml2ProvidersToFiles(options.metadata, {\n deps: options.deps,\n });\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\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,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,yBAAyB,QACpB,oBAAoB;AAC3B,SAASC,YAAY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MlB,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,6CAA6C,CAAC;IAC7D,MAAMJ,0BAA0B,CAACgB,OAAO,CAACK,IAAI,EAAEL,OAAO,CAACM,QAAQ,EAAE;MAC/DC,IAAI,EAAEP,OAAO,CAACO;IAChB,CAAC,CAAC;EACJ;EACA;EAAA,KACK,IAAIP,OAAO,CAACS,WAAW,KAAK,MAAMnB,SAAS,CAAC,CAAC,CAAC,EAAE;IACnDF,cAAc,CAAC,8CAA8C,CAAC;IAC9D,MAAMH,2BAA2B,CAACe,OAAO,CAACM,QAAQ,EAAE;MAClDC,IAAI,EAAEP,OAAO,CAACO;IAChB,CAAC,CAAC;EACJ;EACA;EAAA,KACK;IACHpB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDK,OAAO,CAACkB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHpB,OAAO,CAACqB,KAAK,CAAC,CAAC"}
|
|
@@ -16,7 +16,7 @@ program.description('Export scripts.').addOption(new Option('-n, --script-name <
|
|
|
16
16
|
// )
|
|
17
17
|
.addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all scripts to a single file. Ignored with -n.')).addOption(new Option('-A, --all-separate', 'Export all scripts to separate files (*.script.json) in the current directory. Ignored with -n or -a.')).addOption(new Option('-N, --no-metadata', 'Does not include metadata in the export file.'))
|
|
18
18
|
// deprecated option
|
|
19
|
-
.addOption(new Option('-s, --script <script>', 'DEPRECATED! Use -n/--script-name instead. Name of the script.')).addOption(new Option('-x, --extract', 'Extract the script from the exported file, and save it to a separate file. Ignored with -n or -a.')).action(
|
|
19
|
+
.addOption(new Option('-s, --script <script>', 'DEPRECATED! Use -n/--script-name instead. Name of the script.')).addOption(new Option('-x, --extract', 'Extract the script from the exported file, and save it to a separate file. Ignored with -n or -a.')).addOption(new Option('-d, --default', 'Export all scripts including the default scripts. Ignored with -n.')).action(
|
|
20
20
|
// implement command logic inside action handler
|
|
21
21
|
async (host, realm, user, password, options, command) => {
|
|
22
22
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
@@ -35,13 +35,13 @@ async (host, realm, user, password, options, command) => {
|
|
|
35
35
|
// -a / --all
|
|
36
36
|
else if (options.all) {
|
|
37
37
|
verboseMessage('Exporting all scripts to a single file...');
|
|
38
|
-
await exportScriptsToFile(options.file, options.metadata);
|
|
38
|
+
await exportScriptsToFile(options.file, options.metadata, options.default);
|
|
39
39
|
}
|
|
40
40
|
// -A / --all-separate
|
|
41
41
|
else if (options.allSeparate) {
|
|
42
42
|
verboseMessage('Exporting all scripts to separate files...');
|
|
43
43
|
// -x / --extract
|
|
44
|
-
await exportScriptsToFiles(options.extract, options.metadata);
|
|
44
|
+
await exportScriptsToFiles(options.extract, options.metadata, options.default);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// unrecognized combination of options or no options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-export.js","names":["frodo","Option","exportScriptByNameToFile","exportScriptsToFile","exportScriptsToFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","tokens","help","process","exitCode","scriptName","script","file","metadata","all","allSeparate","extract","parse"],"sources":["../../../src/cli/script/script-export.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportScriptByNameToFile,\n exportScriptsToFile,\n exportScriptsToFiles,\n} from '../../ops/ScriptOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo script export');\n\nprogram\n .description('Export scripts.')\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n // .addOption(\n // new Option(\n // '-i, --script-id <uuid>',\n // 'Uuid of the script. If specified, -a and -A are ignored.'\n // )\n // )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Export all scripts to a single file. Ignored with -n.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all scripts to separate files (*.script.json) in the current directory. Ignored with -n or -a.'\n )\n )\n .addOption(\n new Option(\n '-N, --no-metadata',\n 'Does not include metadata in the export file.'\n )\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\n )\n )\n .addOption(\n new Option(\n '-x, --extract',\n 'Extract the script from the exported file, and save it to a separate file. Ignored with -n or -a.'\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 const tokens = await getTokens();\n if (!tokens) {\n printMessage('Unable to get tokens. Exiting...', 'error');\n program.help();\n process.exitCode = 1;\n return;\n }\n // export by name\n if (options.scriptName || options.script) {\n verboseMessage('Exporting script...');\n await exportScriptByNameToFile(\n options.scriptName || options.script,\n options.file,\n options.metadata\n );\n }\n // -a / --all\n else if (options.all) {\n verboseMessage('Exporting all scripts to a single file...');\n await exportScriptsToFile(options.file
|
|
1
|
+
{"version":3,"file":"script-export.js","names":["frodo","Option","exportScriptByNameToFile","exportScriptsToFile","exportScriptsToFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","tokens","help","process","exitCode","scriptName","script","file","metadata","all","default","allSeparate","extract","parse"],"sources":["../../../src/cli/script/script-export.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportScriptByNameToFile,\n exportScriptsToFile,\n exportScriptsToFiles,\n} from '../../ops/ScriptOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo script export');\n\nprogram\n .description('Export scripts.')\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n // .addOption(\n // new Option(\n // '-i, --script-id <uuid>',\n // 'Uuid of the script. If specified, -a and -A are ignored.'\n // )\n // )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Export all scripts to a single file. Ignored with -n.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all scripts to separate files (*.script.json) in the current directory. Ignored with -n or -a.'\n )\n )\n .addOption(\n new Option(\n '-N, --no-metadata',\n 'Does not include metadata in the export file.'\n )\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\n )\n )\n .addOption(\n new Option(\n '-x, --extract',\n 'Extract the script from the exported file, and save it to a separate file. Ignored with -n or -a.'\n )\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Export all scripts including the default scripts. Ignored with -n.'\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 const tokens = await getTokens();\n if (!tokens) {\n printMessage('Unable to get tokens. Exiting...', 'error');\n program.help();\n process.exitCode = 1;\n return;\n }\n // export by name\n if (options.scriptName || options.script) {\n verboseMessage('Exporting script...');\n await exportScriptByNameToFile(\n options.scriptName || options.script,\n options.file,\n options.metadata\n );\n }\n // -a / --all\n else if (options.all) {\n verboseMessage('Exporting all scripts to a single file...');\n await exportScriptsToFile(\n options.file,\n options.metadata,\n options.default\n );\n }\n // -A / --all-separate\n else if (options.allSeparate) {\n verboseMessage('Exporting all scripts to separate files...');\n // -x / --extract\n await exportScriptsToFiles(\n options.extract,\n options.metadata,\n options.default\n );\n }\n\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\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,SACEC,wBAAwB,EACxBC,mBAAmB,EACnBC,oBAAoB,QACf,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGR,KAAK,CAACS,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,qBAAqB,CAAC;AAEvDG,OAAO,CACJC,WAAW,CAAC,iBAAiB,CAAC,CAC9BC,SAAS,CACR,IAAIX,MAAM,CACR,0BAA0B,EAC1B,0DACF,CACF;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,CACCW,SAAS,CAAC,IAAIX,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,uDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,uGACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,mBAAmB,EACnB,+CACF,CACF;AACA;AAAA,CACCW,SAAS,CACR,IAAIX,MAAM,CACR,uBAAuB,EACvB,+DACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,eAAe,EACf,mGACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,eAAe,EACf,oEACF,CACF,CAAC,CACAY,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,MAAME,MAAM,GAAG,MAAMb,SAAS,CAAC,CAAC;EAChC,IAAI,CAACa,MAAM,EAAE;IACXhB,YAAY,CAAC,kCAAkC,EAAE,OAAO,CAAC;IACzDK,OAAO,CAACY,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpB;EACF;EACA;EACA,IAAIN,OAAO,CAACO,UAAU,IAAIP,OAAO,CAACQ,MAAM,EAAE;IACxCpB,cAAc,CAAC,qBAAqB,CAAC;IACrC,MAAMJ,wBAAwB,CAC5BgB,OAAO,CAACO,UAAU,IAAIP,OAAO,CAACQ,MAAM,EACpCR,OAAO,CAACS,IAAI,EACZT,OAAO,CAACU,QACV,CAAC;EACH;EACA;EAAA,KACK,IAAIV,OAAO,CAACW,GAAG,EAAE;IACpBvB,cAAc,CAAC,2CAA2C,CAAC;IAC3D,MAAMH,mBAAmB,CACvBe,OAAO,CAACS,IAAI,EACZT,OAAO,CAACU,QAAQ,EAChBV,OAAO,CAACY,OACV,CAAC;EACH;EACA;EAAA,KACK,IAAIZ,OAAO,CAACa,WAAW,EAAE;IAC5BzB,cAAc,CAAC,4CAA4C,CAAC;IAC5D;IACA,MAAMF,oBAAoB,CACxBc,OAAO,CAACc,OAAO,EACfd,OAAO,CAACU,QAAQ,EAChBV,OAAO,CAACY,OACV,CAAC;EACH;;EAEA;EAAA,KACK;IACHzB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDK,OAAO,CAACY,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHd,OAAO,CAACuB,KAAK,CAAC,CAAC"}
|
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
const program = new FrodoCommand('frodo script import');
|
|
10
10
|
program.description('Import scripts.').addOption(new Option('-f, --file <file>', 'Name of the file to import.')).addOption(new Option('-n, --script-name <name>', 'Name of the script. If specified, -a and -A are ignored.')).addOption(new Option('--re-uuid', 'Re-UUID. Create a new UUID for the script upon import. Use this to duplicate a script or create a new version of the same script. Note that you must also choose a new name using -n/--script-name to avoid import errors.').default(false, 'false'))
|
|
11
11
|
// deprecated option
|
|
12
|
-
.addOption(new Option('-s, --script <script>', 'DEPRECATED! Use -n/--script-name instead. Name of the script.')).addOption(new Option('-A, --all-separate', 'Import all scripts from separate files (*.script.json) in the current directory. Ignored with -n.')).addOption(new Option('-w, --watch', 'Watch for changes to the script files and import the scripts automatically when the file changes. Can only be used with -A.').default(false, 'false')).action(
|
|
12
|
+
.addOption(new Option('-s, --script <script>', 'DEPRECATED! Use -n/--script-name instead. Name of the script.')).addOption(new Option('-A, --all-separate', 'Import all scripts from separate files (*.script.json) in the current directory. Ignored with -n.')).addOption(new Option('-w, --watch', 'Watch for changes to the script files and import the scripts automatically when the file changes. Can only be used with -A.').default(false, 'false')).addOption(new Option('-d, --default', 'Import all scripts including the default scripts. Ignored with -n.')).action(
|
|
13
13
|
// implement command logic inside action handler
|
|
14
14
|
async (host, realm, user, password, options, command) => {
|
|
15
15
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
@@ -22,10 +22,16 @@ async (host, realm, user, password, options, command) => {
|
|
|
22
22
|
}
|
|
23
23
|
verboseMessage(`Importing script(s) into realm "${state.getRealm()}"...`);
|
|
24
24
|
if (options.file) {
|
|
25
|
-
const outcome = await importScriptsFromFile(options.scriptName || options.script, options.file,
|
|
25
|
+
const outcome = await importScriptsFromFile(options.scriptName || options.script, options.file, {
|
|
26
|
+
reUuid: options.reUuid,
|
|
27
|
+
includeDefault: options.default
|
|
28
|
+
});
|
|
26
29
|
if (!outcome) process.exitCode = 1;
|
|
27
30
|
} else if (options.allSeparate) {
|
|
28
|
-
await importScriptsFromFiles(options.watch,
|
|
31
|
+
await importScriptsFromFiles(options.watch, {
|
|
32
|
+
reUuid: options.reUuid,
|
|
33
|
+
includeDefault: options.default
|
|
34
|
+
}, true);
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
// end command logic inside action handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-import.js","names":["frodo","state","Option","importScriptsFromFile","importScriptsFromFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","tokens","help","process","exitCode","getRealm","file","outcome","scriptName","script","reUuid","allSeparate","watch","parse"],"sources":["../../../src/cli/script/script-import.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importScriptsFromFile,\n importScriptsFromFiles,\n} from '../../ops/ScriptOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo script import');\n\nprogram\n .description('Import scripts.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid',\n 'Re-UUID. Create a new UUID for the script upon import. Use this to duplicate a script or create a new version of the same script. Note that you must also choose a new name using -n/--script-name to avoid import errors.'\n ).default(false, 'false')\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all scripts from separate files (*.script.json) in the current directory. Ignored with -n.'\n )\n )\n .addOption(\n new Option(\n '-w, --watch',\n 'Watch for changes to the script files and import the scripts automatically when the file changes. Can only be used with -A.'\n ).default(false, 'false')\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 const tokens = await getTokens();\n if (!tokens) {\n printMessage('Unable to get tokens. Exiting...', 'error');\n program.help();\n process.exitCode = 1;\n return;\n }\n\n verboseMessage(`Importing script(s) into realm \"${state.getRealm()}\"...`);\n\n if (options.file) {\n const outcome = await importScriptsFromFile(\n options.scriptName || options.script,\n options.file,\n options.reUuid\n );\n if (!outcome) process.exitCode = 1;\n } else if (options.allSeparate) {\n await importScriptsFromFiles(options.watch
|
|
1
|
+
{"version":3,"file":"script-import.js","names":["frodo","state","Option","importScriptsFromFile","importScriptsFromFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","tokens","help","process","exitCode","getRealm","file","outcome","scriptName","script","reUuid","includeDefault","allSeparate","watch","parse"],"sources":["../../../src/cli/script/script-import.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importScriptsFromFile,\n importScriptsFromFiles,\n} from '../../ops/ScriptOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo script import');\n\nprogram\n .description('Import scripts.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid',\n 'Re-UUID. Create a new UUID for the script upon import. Use this to duplicate a script or create a new version of the same script. Note that you must also choose a new name using -n/--script-name to avoid import errors.'\n ).default(false, 'false')\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all scripts from separate files (*.script.json) in the current directory. Ignored with -n.'\n )\n )\n .addOption(\n new Option(\n '-w, --watch',\n 'Watch for changes to the script files and import the scripts automatically when the file changes. Can only be used with -A.'\n ).default(false, 'false')\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Import all scripts including the default scripts. Ignored with -n.'\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 const tokens = await getTokens();\n if (!tokens) {\n printMessage('Unable to get tokens. Exiting...', 'error');\n program.help();\n process.exitCode = 1;\n return;\n }\n\n verboseMessage(`Importing script(s) into realm \"${state.getRealm()}\"...`);\n\n if (options.file) {\n const outcome = await importScriptsFromFile(\n options.scriptName || options.script,\n options.file,\n {\n reUuid: options.reUuid,\n includeDefault: options.default,\n }\n );\n if (!outcome) process.exitCode = 1;\n } else if (options.allSeparate) {\n await importScriptsFromFiles(\n options.watch,\n {\n reUuid: options.reUuid,\n includeDefault: options.default,\n },\n true\n );\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,qBAAqB,EACrBC,sBAAsB,QACjB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGR,KAAK,CAACS,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,qBAAqB,CAAC;AAEvDG,OAAO,CACJC,WAAW,CAAC,iBAAiB,CAAC,CAC9BC,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEU,SAAS,CACR,IAAIV,MAAM,CACR,0BAA0B,EAC1B,0DACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,4NACF,CAAC,CAACW,OAAO,CAAC,KAAK,EAAE,OAAO,CAC1B;AACA;AAAA,CACCD,SAAS,CACR,IAAIV,MAAM,CACR,uBAAuB,EACvB,+DACF,CACF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AACN;IAC1B,CAAC,EACD,IACF,CAAC;EACH;AACF;AACA;AACF,CAAC;AAEHH,OAAO,CAACyB,KAAK,CAAC,CAAC"}
|
package/esm/ops/ConfigOps.js
CHANGED
|
@@ -29,7 +29,8 @@ const {
|
|
|
29
29
|
export async function exportEverythingToFile(file, includeMeta = true, options = {
|
|
30
30
|
useStringArrays: true,
|
|
31
31
|
noDecode: false,
|
|
32
|
-
coords: true
|
|
32
|
+
coords: true,
|
|
33
|
+
includeDefault: false
|
|
33
34
|
}) {
|
|
34
35
|
const exportData = await exportFullConfiguration(options);
|
|
35
36
|
let fileName = getTypedFilename(`${titleCase(getRealmName(state.getRealm()))}`, `everything`);
|
|
@@ -48,7 +49,8 @@ export async function exportEverythingToFile(file, includeMeta = true, options =
|
|
|
48
49
|
export async function exportEverythingToFiles(extract = false, includeMeta = true, options = {
|
|
49
50
|
useStringArrays: true,
|
|
50
51
|
noDecode: false,
|
|
51
|
-
coords: true
|
|
52
|
+
coords: true,
|
|
53
|
+
includeDefault: false
|
|
52
54
|
}) {
|
|
53
55
|
const exportData = await exportFullConfiguration(options);
|
|
54
56
|
delete exportData.meta;
|
|
@@ -142,7 +144,8 @@ export async function importEverythingFromFile(file, options = {
|
|
|
142
144
|
reUuidScripts: false,
|
|
143
145
|
cleanServices: false,
|
|
144
146
|
global: false,
|
|
145
|
-
realm: false
|
|
147
|
+
realm: false,
|
|
148
|
+
includeDefault: false
|
|
146
149
|
}) {
|
|
147
150
|
const data = await getFullExportConfig(file);
|
|
148
151
|
await importFullConfiguration(data, options);
|
|
@@ -156,7 +159,8 @@ export async function importEverythingFromFiles(options = {
|
|
|
156
159
|
reUuidScripts: false,
|
|
157
160
|
cleanServices: false,
|
|
158
161
|
global: false,
|
|
159
|
-
realm: false
|
|
162
|
+
realm: false,
|
|
163
|
+
includeDefault: false
|
|
160
164
|
}) {
|
|
161
165
|
const data = await getFullExportConfigFromDirectory(state.getDirectory());
|
|
162
166
|
await importFullConfiguration(data, options);
|
package/esm/ops/ConfigOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigOps.js","names":["frodo","state","fs","fse","getFullExportConfig","getFullExportConfigFromDirectory","printMessage","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","exportFullConfiguration","importFullConfiguration","config","stringify","json","exportEverythingToFile","file","includeMeta","options","useStringArrays","noDecode","coords","exportData","fileName","getRealm","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 type FullExportInterface,\n type FullExportOptions,\n type 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 { 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 { exportFullConfiguration, importFullConfiguration } = frodo.config;\nconst { stringify } = frodo.utils.json;\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 }\n): Promise<void> {\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}\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 }\n): Promise<void> {\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}\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 }\n) {\n const data = await getFullExportConfig(file);\n await importFullConfiguration(data, options);\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 }\n) {\n const data = await getFullExportConfigFromDirectory(state.getDirectory());\n await importFullConfiguration(data, options);\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAOpD,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,cAAc,EAAE,KAAK;EACrBC,aAAa,EAAE,KAAK;EACpBC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE;AACT,CAAC,EACD;EACA,MAAMC,IAAI,GAAG,MAAM/D,mBAAmB,CAACiB,IAAI,CAAC;EAC5C,MAAML,uBAAuB,CAACmD,IAAI,EAAE5C,OAAO,CAAC;AAC9C;;AAEA;AACA;AACA;AACA,OAAO,eAAe6C,yBAAyBA,CAC7C7C,OAA0B,GAAG;EAC3BuC,cAAc,EAAE,KAAK;EACrBC,aAAa,EAAE,KAAK;EACpBC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE;AACT,CAAC,EACD;EACA,MAAMC,IAAI,GAAG,MAAM9D,gCAAgC,CAACJ,KAAK,CAACoE,YAAY,CAAC,CAAC,CAAC;EACzE,MAAMrD,uBAAuB,CAACmD,IAAI,EAAE5C,OAAO,CAAC;AAC9C"}
|
|
1
|
+
{"version":3,"file":"ConfigOps.js","names":["frodo","state","fs","fse","getFullExportConfig","getFullExportConfigFromDirectory","printMessage","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","exportFullConfiguration","importFullConfiguration","config","stringify","json","exportEverythingToFile","file","includeMeta","options","useStringArrays","noDecode","coords","includeDefault","exportData","fileName","getRealm","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 type FullExportInterface,\n type FullExportOptions,\n type 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 { 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 { exportFullConfiguration, importFullConfiguration } = frodo.config;\nconst { stringify } = frodo.utils.json;\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 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}\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 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}\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 const data = await getFullExportConfig(file);\n await importFullConfiguration(data, options);\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 const data = await getFullExportConfigFromDirectory(state.getDirectory());\n await importFullConfiguration(data, options);\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAOpD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAE1B,SACEC,mBAAmB,EACnBC,gCAAgC,QAC3B,iBAAiB;AACxB,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,MAAM;EACJC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGb,KAAK,CAACc,KAAK;AACf,MAAM;EAAEC,uBAAuB;EAAEC;AAAwB,CAAC,GAAGhB,KAAK,CAACiB,MAAM;AACzE,MAAM;EAAEC;AAAU,CAAC,GAAGlB,KAAK,CAACc,KAAK,CAACK,IAAI;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,sBAAsBA,CAC1CC,IAAY,EACZC,WAAoB,GAAG,IAAI,EAC3BC,OAA0B,GAAG;EAC3BC,eAAe,EAAE,IAAI;EACrBC,QAAQ,EAAE,KAAK;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,CAACqE,YAAY,CAAC,CAAC,CAAC;EACzE,MAAMtD,uBAAuB,CAACoD,IAAI,EAAE7C,OAAO,CAAC;AAC9C"}
|
package/esm/ops/Saml2Ops.js
CHANGED
|
@@ -149,7 +149,9 @@ export async function exportSaml2MetadataToFile(entityId, file = null) {
|
|
|
149
149
|
* @param {String} file Optional filename
|
|
150
150
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
151
151
|
*/
|
|
152
|
-
export async function exportSaml2ProviderToFile(entityId, file = null, includeMeta = true
|
|
152
|
+
export async function exportSaml2ProviderToFile(entityId, file = null, includeMeta = true, options = {
|
|
153
|
+
deps: true
|
|
154
|
+
}) {
|
|
153
155
|
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`);
|
|
154
156
|
if (!file) {
|
|
155
157
|
file = getTypedFilename(entityId, 'saml');
|
|
@@ -158,7 +160,7 @@ export async function exportSaml2ProviderToFile(entityId, file = null, includeMe
|
|
|
158
160
|
let indicatorId;
|
|
159
161
|
try {
|
|
160
162
|
indicatorId = createProgressIndicator('determinate', 1, `Exporting provider ${entityId}`);
|
|
161
|
-
const fileData = await exportSaml2Provider(entityId);
|
|
163
|
+
const fileData = await exportSaml2Provider(entityId, options);
|
|
162
164
|
saveJsonToFile(fileData, filePath, includeMeta);
|
|
163
165
|
updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);
|
|
164
166
|
stopProgressIndicator(indicatorId,
|
|
@@ -176,13 +178,15 @@ export async function exportSaml2ProviderToFile(entityId, file = null, includeMe
|
|
|
176
178
|
* @param {String} file Optional filename
|
|
177
179
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
178
180
|
*/
|
|
179
|
-
export async function exportSaml2ProvidersToFile(file = null, includeMeta = true
|
|
181
|
+
export async function exportSaml2ProvidersToFile(file = null, includeMeta = true, options = {
|
|
182
|
+
deps: true
|
|
183
|
+
}) {
|
|
180
184
|
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);
|
|
181
185
|
if (!file) {
|
|
182
186
|
file = getTypedFilename(`all${getRealmString()}Providers`, 'saml');
|
|
183
187
|
}
|
|
184
188
|
try {
|
|
185
|
-
const exportData = await exportSaml2Providers();
|
|
189
|
+
const exportData = await exportSaml2Providers(options);
|
|
186
190
|
saveJsonToFile(exportData, getFilePath(file, true), includeMeta);
|
|
187
191
|
} catch (error) {
|
|
188
192
|
var _error$response;
|
|
@@ -196,13 +200,15 @@ export async function exportSaml2ProvidersToFile(file = null, includeMeta = true
|
|
|
196
200
|
* Export all entity providers to individual files
|
|
197
201
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
198
202
|
*/
|
|
199
|
-
export async function exportSaml2ProvidersToFiles(includeMeta = true
|
|
203
|
+
export async function exportSaml2ProvidersToFiles(includeMeta = true, options = {
|
|
204
|
+
deps: true
|
|
205
|
+
}) {
|
|
200
206
|
const stubs = await readSaml2ProviderStubs();
|
|
201
207
|
if (stubs.length > 0) {
|
|
202
208
|
const indicatorId = createProgressIndicator('determinate', stubs.length, 'Exporting providers');
|
|
203
209
|
for (const stub of stubs) {
|
|
204
210
|
const file = getFilePath(getTypedFilename(stub.entityId, 'saml'), true);
|
|
205
|
-
const fileData = await exportSaml2Provider(stub.entityId);
|
|
211
|
+
const fileData = await exportSaml2Provider(stub.entityId, options);
|
|
206
212
|
saveJsonToFile(fileData, file, includeMeta);
|
|
207
213
|
updateProgressIndicator(indicatorId, `Exported provider ${stub.entityId}`);
|
|
208
214
|
}
|
package/esm/ops/Saml2Ops.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saml2Ops.js","names":["frodo","fs","createObjectTable","createProgressIndicator","createTable","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","decodeBase64","saveTextToFile","getFilePath","getWorkingDirectory","utils","getTypedFilename","saveJsonToFile","getRealmString","validateImport","readSaml2ProviderStubs","readSaml2Provider","readSaml2ProviderStub","getSaml2ProviderMetadataUrl","getSaml2ProviderMetadata","exportSaml2Provider","exportSaml2Providers","importSaml2Provider","importSaml2Providers","saml2","entityProvider","roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","rawProviderData","_rev","metadataUrl","error","message","exportSaml2MetadataToFile","file","filePath","indicatorId","metaData","brightCyan","exportSaml2ProviderToFile","includeMeta","fileData","err","exportSaml2ProvidersToFile","exportData","_error$response","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","options","deps","data","readFileSync","JSON","parse","importFirstSaml2ProviderFromFile","entityId64","keys","saml","remote","hosted","importSaml2ProvidersFromFile","meta","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","total","result"],"sources":["../../src/ops/Saml2Ops.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { type Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/Saml2Api';\nimport {\n type Saml2ExportInterface,\n type Saml2ProviderImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/Saml2Ops';\nimport fs from 'fs';\n\nimport {\n createObjectTable,\n createProgressIndicator,\n createTable,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst { decodeBase64, saveTextToFile, getFilePath, getWorkingDirectory } =\n frodo.utils;\nconst { getTypedFilename, saveJsonToFile, getRealmString, validateImport } =\n frodo.utils;\nconst {\n readSaml2ProviderStubs,\n readSaml2Provider,\n readSaml2ProviderStub,\n getSaml2ProviderMetadataUrl,\n getSaml2ProviderMetadata,\n exportSaml2Provider,\n exportSaml2Providers,\n importSaml2Provider,\n importSaml2Providers,\n} = frodo.saml2.entityProvider;\n\nconst roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await readSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await readSaml2ProviderStub(entityId);\n const { location } = stub;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData = await readSaml2Provider(entityId);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getSaml2ProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString(), 'data');\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n if (!file) {\n file = getTypedFilename(entityId, 'metadata', 'xml');\n }\n const filePath = getFilePath(file, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting metadata for: ${entityId}`\n );\n try {\n updateProgressIndicator(indicatorId, `Writing file ${filePath}`);\n const metaData = await getSaml2ProviderMetadata(entityId);\n saveTextToFile(metaData, filePath);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} metadata to ${filePath.brightCyan}.`\n );\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProviderToFile(\n entityId,\n file = null,\n includeMeta = true\n) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n if (!file) {\n file = getTypedFilename(entityId, 'saml');\n }\n const filePath = getFilePath(file, true);\n let indicatorId: string;\n try {\n indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting provider ${entityId}`\n );\n const fileData = await exportSaml2Provider(entityId);\n saveJsonToFile(fileData, filePath, includeMeta);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} to ${filePath.brightCyan}.`\n );\n } catch (err) {\n stopProgressIndicator(indicatorId, `${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${filePath}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFile(\n file = null,\n includeMeta = true\n) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const exportData = await exportSaml2Providers();\n saveJsonToFile(exportData, getFilePath(file, true), includeMeta);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFiles(includeMeta = true) {\n const stubs = await readSaml2ProviderStubs();\n if (stubs.length > 0) {\n const indicatorId = createProgressIndicator(\n 'determinate',\n stubs.length,\n 'Exporting providers'\n );\n for (const stub of stubs) {\n const file = getFilePath(getTypedFilename(stub.entityId, 'saml'), true);\n const fileData = await exportSaml2Provider(stub.entityId);\n saveJsonToFile(fileData, file, includeMeta);\n updateProgressIndicator(\n indicatorId,\n `Exported provider ${stub.entityId}`\n );\n }\n stopProgressIndicator(indicatorId, `${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string,\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData, options);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(\n `Error importing saml2 provider ${entityId}: ${error}`,\n 'error'\n );\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importFirstSaml2ProviderFromFile(\n file: string,\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId64 =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n const entityId = decodeBase64(entityId64);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData, options);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(`Error importing first saml2 provider: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProvidersFromFile(\n file: string,\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n await importSaml2Providers(fileData, options);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n } catch (error) {\n printMessage(`Error importing saml2 providers: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProvidersFromFiles(\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.saml.json'))\n .map((name) => getFilePath(name));\n const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing providers...'\n );\n let total = 0;\n for (const file of jsonFiles) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const result = await importSaml2Providers(fileData, options);\n total += result.length;\n updateProgressIndicator(\n indicatorId,\n `Imported ${result.length} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n } catch (error) {\n printMessage(\n `Error importing providers from ${file}: ${error.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Imported ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAM7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AAEzB,MAAM;EAAEC,YAAY;EAAEC,cAAc;EAAEC,WAAW;EAAEC;AAAoB,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,aAAa,EACbwG,SAAS,CAAC9D,MAAM,EAChB,wBACF,CAAC;EACD,IAAImE,KAAK,GAAG,CAAC;EACb,KAAK,MAAMvC,IAAI,IAAIkC,SAAS,EAAE;IAC5B,IAAI;MACF,MAAMf,IAAI,GAAG3F,EAAE,CAAC4F,YAAY,CAACpB,IAAI,EAAE,MAAM,CAAC;MAC1C,MAAMO,QAAQ,GAAGc,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;MACjC,IAAI3E,cAAc,CAAC+D,QAAQ,CAACuB,IAAI,CAAC,EAAE;QACjC,MAAMU,MAAM,GAAG,MAAMvF,oBAAoB,CAACsD,QAAQ,EAAEU,OAAO,CAAC;QAC5DsB,KAAK,IAAIC,MAAM,CAACpE,MAAM;QACtBrC,uBAAuB,CACrBmE,WAAW,EACV,YAAWsC,MAAM,CAACpE,MAAO,qBAAoB4B,IAAK,GACrD,CAAC;MACH,CAAC,MAAM;QACLnE,YAAY,CAAE,iBAAgBmE,IAAK,UAAS,EAAE,OAAO,CAAC;MACxD;IACF,CAAC,CAAC,OAAOH,KAAK,EAAE;MACdhE,YAAY,CACT,kCAAiCmE,IAAK,KAAIH,KAAK,CAACC,OAAQ,EAAC,EAC1D,OACF,CAAC;IACH;EACF;EACAhE,qBAAqB,CACnBoE,WAAW,EACV,YAAWqC,KAAM,qBAAoBL,SAAS,CAAC9D,MAAO,WACzD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"Saml2Ops.js","names":["frodo","fs","createObjectTable","createProgressIndicator","createTable","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","decodeBase64","saveTextToFile","getFilePath","getWorkingDirectory","utils","getTypedFilename","saveJsonToFile","getRealmString","validateImport","readSaml2ProviderStubs","readSaml2Provider","readSaml2ProviderStub","getSaml2ProviderMetadataUrl","getSaml2ProviderMetadata","exportSaml2Provider","exportSaml2Providers","importSaml2Provider","importSaml2Providers","saml2","entityProvider","roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","rawProviderData","_rev","metadataUrl","error","message","exportSaml2MetadataToFile","file","filePath","indicatorId","metaData","brightCyan","exportSaml2ProviderToFile","includeMeta","options","deps","fileData","err","exportSaml2ProvidersToFile","exportData","_error$response","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","data","readFileSync","JSON","parse","importFirstSaml2ProviderFromFile","entityId64","keys","saml","remote","hosted","importSaml2ProvidersFromFile","meta","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","total","result"],"sources":["../../src/ops/Saml2Ops.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { type Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/Saml2Api';\nimport type {\n Saml2EntitiesExportOptions,\n Saml2EntitiesImportOptions,\n Saml2ExportInterface,\n} from '@rockcarver/frodo-lib/types/ops/Saml2Ops';\nimport fs from 'fs';\n\nimport {\n createObjectTable,\n createProgressIndicator,\n createTable,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst { decodeBase64, saveTextToFile, getFilePath, getWorkingDirectory } =\n frodo.utils;\nconst { getTypedFilename, saveJsonToFile, getRealmString, validateImport } =\n frodo.utils;\nconst {\n readSaml2ProviderStubs,\n readSaml2Provider,\n readSaml2ProviderStub,\n getSaml2ProviderMetadataUrl,\n getSaml2ProviderMetadata,\n exportSaml2Provider,\n exportSaml2Providers,\n importSaml2Provider,\n importSaml2Providers,\n} = frodo.saml2.entityProvider;\n\nconst roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await readSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await readSaml2ProviderStub(entityId);\n const { location } = stub;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData = await readSaml2Provider(entityId);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getSaml2ProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString(), 'data');\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n if (!file) {\n file = getTypedFilename(entityId, 'metadata', 'xml');\n }\n const filePath = getFilePath(file, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting metadata for: ${entityId}`\n );\n try {\n updateProgressIndicator(indicatorId, `Writing file ${filePath}`);\n const metaData = await getSaml2ProviderMetadata(entityId);\n saveTextToFile(metaData, filePath);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} metadata to ${filePath.brightCyan}.`\n );\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProviderToFile(\n entityId: string,\n file: string = null,\n includeMeta = true,\n options: Saml2EntitiesExportOptions = { deps: true }\n) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n if (!file) {\n file = getTypedFilename(entityId, 'saml');\n }\n const filePath = getFilePath(file, true);\n let indicatorId: string;\n try {\n indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting provider ${entityId}`\n );\n const fileData = await exportSaml2Provider(entityId, options);\n saveJsonToFile(fileData, filePath, includeMeta);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} to ${filePath.brightCyan}.`\n );\n } catch (err) {\n stopProgressIndicator(indicatorId, `${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${filePath}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFile(\n file: string = null,\n includeMeta = true,\n options: Saml2EntitiesExportOptions = { deps: true }\n) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const exportData = await exportSaml2Providers(options);\n saveJsonToFile(exportData, getFilePath(file, true), includeMeta);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFiles(\n includeMeta = true,\n options: Saml2EntitiesExportOptions = { deps: true }\n) {\n const stubs = await readSaml2ProviderStubs();\n if (stubs.length > 0) {\n const indicatorId = createProgressIndicator(\n 'determinate',\n stubs.length,\n 'Exporting providers'\n );\n for (const stub of stubs) {\n const file = getFilePath(getTypedFilename(stub.entityId, 'saml'), true);\n const fileData = await exportSaml2Provider(stub.entityId, options);\n saveJsonToFile(fileData, file, includeMeta);\n updateProgressIndicator(\n indicatorId,\n `Exported provider ${stub.entityId}`\n );\n }\n stopProgressIndicator(indicatorId, `${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string,\n options: Saml2EntitiesImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData, options);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(\n `Error importing saml2 provider ${entityId}: ${error}`,\n 'error'\n );\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importFirstSaml2ProviderFromFile(\n file: string, \n options: Saml2EntitiesImportOptions = { deps: true }) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId64 =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n const entityId = decodeBase64(entityId64);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData, options);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(`Error importing first saml2 provider: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProvidersFromFile(\n file: string,\n options: Saml2EntitiesImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n await importSaml2Providers(fileData, options);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n } catch (error) {\n printMessage(`Error importing saml2 providers: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProvidersFromFiles(\n options: Saml2EntitiesImportOptions = { deps: true }\n) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.saml.json'))\n .map((name) => getFilePath(name));\n const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing providers...'\n );\n let total = 0;\n for (const file of jsonFiles) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const result = await importSaml2Providers(fileData, options);\n total += result.length;\n updateProgressIndicator(\n indicatorId,\n `Imported ${result.length} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n } catch (error) {\n printMessage(\n `Error importing providers from ${file}: ${error.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Imported ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAO7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AAEzB,MAAM;EAAEC,YAAY;EAAEC,cAAc;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GACtE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AAI,IAAKA,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAC3DjD,GAAG,CAAE+C,IAAI,IAAKlG,WAAW,CAACkG,IAAI,CAAC,CAAC;EACnC,MAAMlC,WAAW,GAAGxE,uBAAuB,CACzC,aAAa,EACbwG,SAAS,CAAC9D,MAAM,EAChB,wBACF,CAAC;EACD,IAAImE,KAAK,GAAG,CAAC;EACb,KAAK,MAAMvC,IAAI,IAAIkC,SAAS,EAAE;IAC5B,IAAI;MACF,MAAMf,IAAI,GAAG3F,EAAE,CAAC4F,YAAY,CAACpB,IAAI,EAAE,MAAM,CAAC;MAC1C,MAAMS,QAAQ,GAAGY,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;MACjC,IAAI3E,cAAc,CAACiE,QAAQ,CAACqB,IAAI,CAAC,EAAE;QACjC,MAAMU,MAAM,GAAG,MAAMvF,oBAAoB,CAACwD,QAAQ,EAAEF,OAAO,CAAC;QAC5DgC,KAAK,IAAIC,MAAM,CAACpE,MAAM;QACtBrC,uBAAuB,CACrBmE,WAAW,EACV,YAAWsC,MAAM,CAACpE,MAAO,qBAAoB4B,IAAK,GACrD,CAAC;MACH,CAAC,MAAM;QACLnE,YAAY,CAAE,iBAAgBmE,IAAK,UAAS,EAAE,OAAO,CAAC;MACxD;IACF,CAAC,CAAC,OAAOH,KAAK,EAAE;MACdhE,YAAY,CACT,kCAAiCmE,IAAK,KAAIH,KAAK,CAACC,OAAQ,EAAC,EAC1D,OACF,CAAC;IACH;EACF;EACAhE,qBAAqB,CACnBoE,WAAW,EACV,YAAWqC,KAAM,qBAAoBL,SAAS,CAAC9D,MAAO,WACzD,CAAC;AACH"}
|
package/esm/ops/ScriptOps.js
CHANGED
|
@@ -187,16 +187,17 @@ export async function exportScriptByNameToFile(name, file, includeMeta = true) {
|
|
|
187
187
|
* Export all scripts to single file
|
|
188
188
|
* @param {string} file file name
|
|
189
189
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
190
|
+
* @param {boolean} includeDefault true to include default scripts in export, false otherwise. Default: false
|
|
190
191
|
* @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
|
|
191
192
|
*/
|
|
192
|
-
export async function exportScriptsToFile(file, includeMeta = true) {
|
|
193
|
+
export async function exportScriptsToFile(file, includeMeta = true, includeDefault = false) {
|
|
193
194
|
debugMessage(`Cli.ScriptOps.exportScriptsToFile: start`);
|
|
194
195
|
try {
|
|
195
196
|
let fileName = getTypedFilename(`all${titleCase(state.getRealm())}Scripts`, 'script');
|
|
196
197
|
if (file) {
|
|
197
198
|
fileName = file;
|
|
198
199
|
}
|
|
199
|
-
const scriptExport = await exportScripts();
|
|
200
|
+
const scriptExport = await exportScripts(includeDefault);
|
|
200
201
|
saveJsonToFile(scriptExport, getFilePath(fileName, true), includeMeta);
|
|
201
202
|
debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [true]`);
|
|
202
203
|
return true;
|
|
@@ -210,14 +211,16 @@ export async function exportScriptsToFile(file, includeMeta = true) {
|
|
|
210
211
|
|
|
211
212
|
/**
|
|
212
213
|
* Export all scripts to individual files
|
|
213
|
-
* @param extract Extracts the scripts from the exports into separate files if true
|
|
214
|
+
* @param {boolean} extract Extracts the scripts from the exports into separate files if true
|
|
214
215
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
216
|
+
* @param {boolean} includeDefault true to include default scripts in export, false otherwise. Default: false
|
|
215
217
|
* @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
|
|
216
218
|
*/
|
|
217
|
-
export async function exportScriptsToFiles(extract = false, includeMeta = true) {
|
|
219
|
+
export async function exportScriptsToFiles(extract = false, includeMeta = true, includeDefault = false) {
|
|
218
220
|
let outcome = true;
|
|
219
221
|
debugMessage(`Cli.ScriptOps.exportScriptsToFiles: start`);
|
|
220
|
-
|
|
222
|
+
let scriptList = await readScripts();
|
|
223
|
+
if (!includeDefault) scriptList = scriptList.filter(script => !script.default);
|
|
221
224
|
const barId = createProgressIndicator('determinate', scriptList.length, 'Exporting scripts to individual files...');
|
|
222
225
|
for (const script of scriptList) {
|
|
223
226
|
const fileBarId = createProgressIndicator('determinate', 1, `Exporting script ${script.name}...`);
|
|
@@ -287,10 +290,13 @@ function isScriptExtracted(importData) {
|
|
|
287
290
|
* Import script(s) from file
|
|
288
291
|
* @param {string} name Optional name of script. If supplied, only the script of that name is imported
|
|
289
292
|
* @param {string} file file name
|
|
290
|
-
* @param {
|
|
293
|
+
* @param {ScriptImportOptions} options Script import options
|
|
291
294
|
* @returns {Promise<boolean>} true if no errors occurred during import, false otherwise
|
|
292
295
|
*/
|
|
293
|
-
export async function importScriptsFromFile(name, file,
|
|
296
|
+
export async function importScriptsFromFile(name, file, options = {
|
|
297
|
+
reUuid: false,
|
|
298
|
+
includeDefault: false
|
|
299
|
+
}) {
|
|
294
300
|
let outcome = false;
|
|
295
301
|
const filePath = getFilePath(file);
|
|
296
302
|
debugMessage(`Cli.ScriptOps.importScriptsFromFile: start`);
|
|
@@ -299,9 +305,9 @@ export async function importScriptsFromFile(name, file, reUuid = false) {
|
|
|
299
305
|
if (err) throw err;
|
|
300
306
|
const importData = JSON.parse(data);
|
|
301
307
|
if (isScriptExtracted(importData)) {
|
|
302
|
-
await handleScriptFileImport(filePath,
|
|
308
|
+
await handleScriptFileImport(filePath, options, false);
|
|
303
309
|
} else {
|
|
304
|
-
await importScripts(name, importData,
|
|
310
|
+
await importScripts(name, importData, options);
|
|
305
311
|
}
|
|
306
312
|
outcome = true;
|
|
307
313
|
} catch (error) {
|
|
@@ -316,11 +322,13 @@ export async function importScriptsFromFile(name, file, reUuid = false) {
|
|
|
316
322
|
/**
|
|
317
323
|
* Import extracted scripts.
|
|
318
324
|
*
|
|
319
|
-
* @param watch whether or not to watch for file changes
|
|
325
|
+
* @param {boolean} watch whether or not to watch for file changes
|
|
326
|
+
* @param {ScriptImportOptions} options Script import options
|
|
327
|
+
* @param {boolean} validateScripts If true, validates Javascript scripts to ensure no errors exist in them. Default: false
|
|
320
328
|
*/
|
|
321
|
-
export async function importScriptsFromFiles(watch,
|
|
329
|
+
export async function importScriptsFromFiles(watch, options, validateScripts) {
|
|
322
330
|
// If watch is true, it doesn't make sense to reUuid.
|
|
323
|
-
reUuid = watch ? false : reUuid;
|
|
331
|
+
options.reUuid = watch ? false : options.reUuid;
|
|
324
332
|
|
|
325
333
|
/**
|
|
326
334
|
* Run on file change detection, as well as on initial run.
|
|
@@ -328,7 +336,7 @@ export async function importScriptsFromFiles(watch, reUuid, validateScripts) {
|
|
|
328
336
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
329
337
|
async function onChange(path, _stats) {
|
|
330
338
|
try {
|
|
331
|
-
await handleScriptFileImport(path,
|
|
339
|
+
await handleScriptFileImport(path, options, validateScripts);
|
|
332
340
|
} catch (error) {
|
|
333
341
|
printMessage(`${path}: ${error.message}`, 'error');
|
|
334
342
|
}
|
|
@@ -354,14 +362,15 @@ export async function importScriptsFromFiles(watch, reUuid, validateScripts) {
|
|
|
354
362
|
/**
|
|
355
363
|
* Handle a script file import.
|
|
356
364
|
*
|
|
357
|
-
* @param file Either a script file or an extract file
|
|
358
|
-
* @param
|
|
365
|
+
* @param {string} file Either a script file or an extract file
|
|
366
|
+
* @param {ScriptImportOptions} options Script import options
|
|
367
|
+
* @param {boolean} validateScripts If true, validates Javascript scripts to ensure no errors exist in them. Default: false
|
|
359
368
|
*/
|
|
360
|
-
async function handleScriptFileImport(file,
|
|
369
|
+
async function handleScriptFileImport(file, options, validateScripts) {
|
|
361
370
|
debugMessage(`Cli.ScriptOps.handleScriptFileImport: start`);
|
|
362
371
|
const scriptFile = getScriptFile(file);
|
|
363
372
|
const script = getScriptExportByScriptFile(scriptFile);
|
|
364
|
-
const imported = await importScripts('', script,
|
|
373
|
+
const imported = await importScripts('', script, options, validateScripts);
|
|
365
374
|
if (imported) {
|
|
366
375
|
printMessage(`Imported '${scriptFile}'`);
|
|
367
376
|
}
|
package/esm/ops/ScriptOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptOps.js","names":["frodo","state","chokidar","fs","getFullExportConfig","isIdUsed","createProgressIndicator","createTable","debugMessage","failSpinner","printMessage","showSpinner","spinSpinner","stopProgressIndicator","succeedSpinner","updateProgressIndicator","wordwrap","getTypedFilename","isValidUrl","saveJsonToFile","saveTextToFile","titleCase","isBase64Encoded","getFilePath","getWorkingDirectory","utils","readScripts","exportScript","exportScriptByName","exportScripts","importScripts","deleteScript","deleteScriptByName","deleteScripts","script","getOneLineDescription","scriptObj","description","_id","context","name","getTableHeaderMd","markdown","getTableRowMd","langMap","JAVASCRIPT","GROOVY","language","split","join","listScripts","long","usage","file","spinnerId","scripts","sort","a","b","localeCompare","length","error","_error$response","response","data","message","forEach","fullExport","headers","_error$response2","push","table","values","isScriptUsed","used","location","toString","exportScriptToFile","scriptId","includeMeta","fileName","filePath","scriptExport","exportScriptByNameToFile","exportScriptsToFile","getRealm","exportScriptsToFiles","extract","outcome","scriptList","barId","fileBarId","extractScriptToFile","directory","scriptSkeleton","getScriptSkeleton","fileExtension","scriptFileName","scriptFilePath","scriptText","Array","isArray","isScriptExtracted","importData","extracted","Object","keys","importScriptsFromFile","reUuid","readFile","err","JSON","parse","handleScriptFileImport","importScriptsFromFiles","watch","validateScripts","onChange","path","_stats","watcher","persistent","on","close","scriptFile","getScriptFile","getScriptExportByScriptFile","imported","endsWith","replace","getScriptExport","extractFile","getExtractFile","scriptRaw","readFileSync","startsWith","scriptExportRaw","getScriptId","scriptIds","Error","deleteScriptId","id","undefined","deleteScriptName","deleteAllScripts"],"sources":["../../src/ops/ScriptOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type ScriptSkeleton } from '@rockcarver/frodo-lib/types/api/ScriptApi';\nimport { type ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport chokidar from 'chokidar';\nimport fs from 'fs';\n\nimport { getFullExportConfig, isIdUsed } from '../utils/Config';\nimport {\n createProgressIndicator,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n spinSpinner,\n stopProgressIndicator,\n succeedSpinner,\n updateProgressIndicator,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\n\nconst {\n getTypedFilename,\n isValidUrl,\n saveJsonToFile,\n saveTextToFile,\n titleCase,\n isBase64Encoded,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readScripts,\n exportScript,\n exportScriptByName,\n exportScripts,\n importScripts,\n deleteScript,\n deleteScriptByName,\n deleteScripts,\n} = frodo.script;\n\n/**\n * Get a one-line description of the script object\n * @param {ScriptSkeleton} scriptObj script object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(scriptObj: ScriptSkeleton): string {\n const description = `[${scriptObj._id['brightCyan']}] ${scriptObj.context} - ${scriptObj.name}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Language | Type | Id |\\n';\n markdown += '| ---- | -------- | ---- | ---|';\n return markdown;\n}\n\n/**\n * Get a one-line description of the script object in markdown\n * @param {TypesRaw.ScriptSkeleton} scriptObj script object to describe\n * @returns {string} markdown table row\n */\nexport function getTableRowMd(scriptObj: ScriptSkeleton): string {\n const langMap = { JAVASCRIPT: 'JavaSscript', GROOVY: 'Groovy' };\n const description = `| ${scriptObj.name} | ${\n langMap[scriptObj.language]\n } | ${titleCase(scriptObj.context.split('_').join(' '))} | \\`${\n scriptObj._id\n }\\` |`;\n return description;\n}\n\n/**\n * List scripts\n * @param {boolean} long detail list\n * @param {boolean} usage display usage field\n * @param {String | null} file Optional filename to determine usage\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function listScripts(\n long: boolean = false,\n usage: boolean = false,\n file: string | null = null\n): Promise<boolean> {\n let spinnerId: string;\n let scripts: ScriptSkeleton[] = [];\n debugMessage(`Cli.ScriptOps.listScripts: start`);\n try {\n spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Reading scripts...`\n );\n scripts = await readScripts();\n scripts.sort((a, b) => a.name.localeCompare(b.name));\n stopProgressIndicator(\n spinnerId,\n `Successfully read ${scripts.length} scripts.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n `Error reading scripts: ${error.response?.data || error.message}`,\n 'fail'\n );\n debugMessage(error);\n debugMessage(`Cli.ScriptOps.listScripts: end [false]`);\n return false;\n }\n if (!long && !usage) {\n scripts.forEach((script) => {\n printMessage(`${script.name}`, 'data');\n });\n debugMessage(`Cli.ScriptOps.listScripts: end [true]`);\n return true;\n }\n let fullExport = null;\n const headers = long\n ? ['Name', 'UUID', 'Language', 'Context', 'Description']\n : ['Name'];\n if (usage) {\n try {\n fullExport = await getFullExportConfig(file);\n } catch (error) {\n printMessage(\n `Error getting full export: ${error.response?.data || error.message}`,\n 'error'\n );\n debugMessage(`Cli.ScriptOps.listScripts: end [false]`);\n return false;\n }\n //Delete scripts from full export so they aren't mistakenly used for determining usage\n delete fullExport.script;\n headers.push('Used');\n }\n const table = createTable(headers);\n const langMap = { JAVASCRIPT: 'JS', GROOVY: 'Groovy' };\n scripts.forEach((script) => {\n const values = long\n ? [\n wordwrap(script.name, 25, ' '),\n script._id,\n langMap[script.language],\n wordwrap(titleCase(script.context.split('_').join(' ')), 25),\n wordwrap(script.description, 30),\n ]\n : [wordwrap(script.name, 25, ' ')];\n if (usage) {\n const isScriptUsed = isIdUsed(fullExport, script._id, false);\n values.push(\n isScriptUsed.used\n ? `${'yes'['brightGreen']} (at ${isScriptUsed.location})`\n : 'no'['brightRed']\n );\n }\n table.push(values);\n });\n printMessage(table.toString(), 'data');\n debugMessage(`Cli.ScriptOps.listScripts: end [true]`);\n return true;\n}\n\n/**\n * Export script by id to file\n * @param {string} scriptId script uuid\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptToFile(\n scriptId: string,\n file: string,\n includeMeta = true\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptToFile: start`);\n try {\n showSpinner(`Exporting script '${scriptId}'...`);\n let fileName = getTypedFilename(scriptId, 'script');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n spinSpinner(`Exporting script '${scriptId}' to '${filePath}'...`);\n const scriptExport = await exportScript(scriptId);\n saveJsonToFile(scriptExport, filePath, includeMeta);\n succeedSpinner(`Exported script '${scriptId}' to '${filePath}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${scriptId}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [false]`);\n return false;\n}\n\n/**\n * Export script by name to file\n * @param {string} name script name\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptByNameToFile(\n name: string,\n file: string,\n includeMeta = true\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: start`);\n try {\n showSpinner(`Exporting script '${name}'...`);\n let fileName = getTypedFilename(name, 'script');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n spinSpinner(`Exporting script '${name}' to '${filePath}'...`);\n const scriptExport = await exportScriptByName(name);\n saveJsonToFile(scriptExport, filePath, includeMeta);\n succeedSpinner(`Exported script '${name}' to '${filePath}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${name}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to single 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 no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFile(\n file: string,\n includeMeta = true\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: start`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(state.getRealm())}Scripts`,\n 'script'\n );\n if (file) {\n fileName = file;\n }\n const scriptExport = await exportScripts();\n saveJsonToFile(scriptExport, getFilePath(fileName, true), includeMeta);\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [true]`);\n return true;\n } catch (error) {\n printMessage(`Error exporting scripts: ${error.message}`, 'error');\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to individual files\n * @param 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 * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFiles(\n extract = false,\n includeMeta = true\n): Promise<boolean> {\n let outcome = true;\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: start`);\n const scriptList = await readScripts();\n const barId = createProgressIndicator(\n 'determinate',\n scriptList.length,\n 'Exporting scripts to individual files...'\n );\n for (const script of scriptList) {\n const fileBarId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting script ${script.name}...`\n );\n updateProgressIndicator(barId, `Reading script ${script.name}`);\n const file = getFilePath(getTypedFilename(script.name, 'script'), true);\n try {\n const scriptExport = await exportScriptByName(script.name);\n if (extract) extractScriptToFile(scriptExport);\n saveJsonToFile(scriptExport, file, includeMeta);\n updateProgressIndicator(fileBarId, `Saving ${script.name} to ${file}.`);\n stopProgressIndicator(fileBarId, `${script.name} saved to ${file}.`);\n } catch (error) {\n outcome = false;\n updateProgressIndicator(barId, `Error exporting ${script.name}.`);\n stopProgressIndicator(\n fileBarId,\n `Error saving ${script.name} to ${file}.`\n );\n printMessage(\n `Error exporting script '${script.name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n }\n stopProgressIndicator(\n barId,\n `Exported ${scriptList.length} scripts to individual files.`\n );\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Extracts a script from a script export into a separate file.\n * @param scriptExport The script export\n * @param scriptId The script id (optional if there is only one script in the export)\n * @param directory The directory within the base directory to save the script file\n */\nexport function extractScriptToFile(\n scriptExport: ScriptExportInterface,\n scriptId?: string,\n directory?: string\n) {\n const scriptSkeleton = scriptId\n ? scriptExport.script[scriptId]\n : getScriptSkeleton(scriptExport);\n const fileExtension =\n scriptSkeleton.language === 'JAVASCRIPT' ? 'js' : 'groovy';\n const scriptFileName = getTypedFilename(\n scriptSkeleton.name,\n 'script',\n fileExtension\n );\n const scriptFilePath = getFilePath(\n (directory ? `${directory}/` : '') + scriptFileName,\n true\n );\n const scriptText = Array.isArray(scriptSkeleton.script)\n ? scriptSkeleton.script.join('\\n')\n : scriptSkeleton.script;\n scriptSkeleton.script = `file://${scriptFilePath}`;\n saveTextToFile(scriptText, scriptFilePath);\n}\n\nfunction isScriptExtracted(importData: ScriptExportInterface): boolean {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: start`);\n let extracted = true;\n for (const scriptId of Object.keys(importData.script)) {\n const script = importData.script[scriptId].script;\n if (Array.isArray(script)) {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: script is string array`);\n extracted = false;\n break;\n }\n if (isValidUrl(script as string)) {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: script is extracted`);\n extracted = true;\n break;\n }\n if (isBase64Encoded) {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: script is base64-encoded`);\n extracted = false;\n break;\n }\n break;\n }\n debugMessage(`Cli.ScriptOps.isScriptExtracted: end [extracted=${extracted}]`);\n return extracted;\n}\n\n/**\n * Import script(s) from file\n * @param {string} name Optional name of script. If supplied, only the script of that name is imported\n * @param {string} file file name\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\nexport async function importScriptsFromFile(\n name: string,\n file: string,\n reUuid = false\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: start`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n try {\n if (err) throw err;\n const importData: ScriptExportInterface = JSON.parse(data);\n if (isScriptExtracted(importData)) {\n await handleScriptFileImport(filePath, reUuid, false);\n } else {\n await importScripts(name, importData, reUuid);\n }\n outcome = true;\n } catch (error) {\n printMessage(\n `Error importing script '${name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n });\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Import extracted scripts.\n *\n * @param watch whether or not to watch for file changes\n */\nexport async function importScriptsFromFiles(\n watch: boolean,\n reUuid: boolean,\n validateScripts: boolean\n) {\n // If watch is true, it doesn't make sense to reUuid.\n reUuid = watch ? false : reUuid;\n\n /**\n * Run on file change detection, as well as on initial run.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async function onChange(path: string, _stats?: fs.Stats): Promise<void> {\n try {\n await handleScriptFileImport(path, reUuid, validateScripts);\n } catch (error) {\n printMessage(`${path}: ${error.message}`, 'error');\n }\n }\n\n // We watch json files and script files.\n const watcher = chokidar.watch(\n [\n `${getWorkingDirectory()}/**/*.script.json`,\n `${getWorkingDirectory()}/**/*.script.js`,\n `${getWorkingDirectory()}/**/*.script.groovy`,\n ],\n {\n persistent: watch,\n }\n );\n\n watcher\n .on('add', onChange)\n .on('change', onChange)\n .on('error', (error) => {\n printMessage(`Watcher error: ${error}`, 'error');\n watcher.close();\n })\n .on('ready', () => {\n if (watch) {\n printMessage('Watching for changes...');\n } else {\n watcher.close();\n printMessage('Done.');\n }\n });\n}\n\n/**\n * Handle a script file import.\n *\n * @param file Either a script file or an extract file\n * @param reUuid whether or not to generate a new uuid for each script on import\n */\nasync function handleScriptFileImport(\n file: string,\n reUuid: boolean,\n validateScripts: boolean\n) {\n debugMessage(`Cli.ScriptOps.handleScriptFileImport: start`);\n const scriptFile = getScriptFile(file);\n const script = getScriptExportByScriptFile(scriptFile);\n\n const imported = await importScripts('', script, reUuid, validateScripts);\n if (imported) {\n printMessage(`Imported '${scriptFile}'`);\n }\n debugMessage(`Cli.ScriptOps.handleScriptFileImport: end`);\n}\n\n/**\n * Get a script file from a file.\n *\n * @param file Either a script file or an extract file\n * @returns The script file\n */\nfunction getScriptFile(file: string) {\n if (file.endsWith('.script.json')) {\n return file;\n }\n return file.replace(/\\.script\\.(js|groovy)/, '.script.json');\n}\n\n/**\n * Get a script export from a script file.\n *\n * @param scriptFile The path to the script file\n * @returns The script export\n */\nfunction getScriptExportByScriptFile(\n scriptFile: string\n): ScriptExportInterface {\n const scriptExport = getScriptExport(scriptFile);\n const scriptSkeleton = getScriptSkeleton(scriptExport);\n\n const extractFile = getExtractFile(scriptSkeleton);\n if (!extractFile) {\n return scriptExport;\n }\n\n const scriptRaw = fs.readFileSync(extractFile, 'utf8');\n scriptSkeleton.script = scriptRaw.split('\\n');\n\n return scriptExport;\n}\n\n/**\n * Get an extract file from a script skeleton.\n *\n * @param scriptSkeleton The script skeleton\n * @returns The extract file or null if there is no extract file\n */\nfunction getExtractFile(scriptSkeleton: ScriptSkeleton): string | null {\n const extractFile = scriptSkeleton.script;\n if (Array.isArray(extractFile)) {\n return null;\n }\n if (\n extractFile.startsWith('file://') &&\n (extractFile.endsWith('.js') || extractFile.endsWith('.groovy'))\n ) {\n return extractFile.replace('file://', '');\n }\n return null;\n}\n\n/**\n * Get a script export from a file.\n *\n * @param file The path to a script export file\n * @returns The script export\n */\nfunction getScriptExport(file: string): ScriptExportInterface {\n const scriptExportRaw = fs.readFileSync(file, 'utf8');\n const scriptExport = JSON.parse(scriptExportRaw) as ScriptExportInterface;\n\n return scriptExport;\n}\n\n/**\n * Get the main script skeleton from a script export. If there is more than one\n * script, an error is thrown.\n *\n * @param script Get the main script skeleton from a script export\n * @returns The main script skeleton\n */\nfunction getScriptSkeleton(script: ScriptExportInterface): ScriptSkeleton {\n const scriptId = getScriptId(script);\n return script.script[scriptId];\n}\n\n/**\n * Get the main script ID from a script export. If there is more than one\n * script, an error is thrown.\n *\n * @param script The script export\n * @returns The main script ID\n */\nfunction getScriptId(script: ScriptExportInterface): string {\n const scriptIds = Object.keys(script.script);\n if (scriptIds.length !== 1) {\n throw new Error(`Expected 1 script, found ${scriptIds.length}`);\n }\n return scriptIds[0];\n}\n\n/**\n * Delete script by id\n * @param {String} id script id\n */\nexport async function deleteScriptId(id) {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${id}...`\n );\n try {\n await deleteScript(id);\n stopProgressIndicator(spinnerId, `Deleted ${id}.`, 'success');\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete script by name\n * @param {String} name script name\n */\nexport async function deleteScriptName(name) {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${name}...`\n );\n try {\n await deleteScriptByName(name);\n stopProgressIndicator(spinnerId, `Deleted ${name}.`, 'success');\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all non-default scripts\n */\nexport async function deleteAllScripts() {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting all non-default scripts...`\n );\n try {\n await deleteScripts();\n stopProgressIndicator(\n spinnerId,\n `Deleted all non-default scripts.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error: ${error.message}`, 'fail');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAGpD,OAAOC,QAAQ,MAAM,UAAU;AAC/B,OAAOC,EAAE,MAAM,IAAI;AAEnB,SAASC,mBA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M,CAAC;EACrE;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe8E,gBAAgBA,CAACvG,IAAI,EAAE;EAC3C,MAAMc,SAAS,GAAGhD,uBAAuB,CACvC,eAAe,EACfwI,SAAS,EACR,YAAWtG,IAAK,KACnB,CAAC;EACD,IAAI;IACF,MAAMR,kBAAkB,CAACQ,IAAI,CAAC;IAC9B3B,qBAAqB,CAACyC,SAAS,EAAG,WAAUd,IAAK,GAAE,EAAE,SAAS,CAAC;EACjE,CAAC,CAAC,OAAOqB,KAAK,EAAE;IACdhD,qBAAqB,CAACyC,SAAS,EAAG,UAASO,KAAK,CAACI,OAAQ,EAAC,EAAE,MAAM,CAAC;EACrE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAe+E,gBAAgBA,CAAA,EAAG;EACvC,MAAM1F,SAAS,GAAGhD,uBAAuB,CACvC,eAAe,EACfwI,SAAS,EACR,qCACH,CAAC;EACD,IAAI;IACF,MAAM7G,aAAa,CAAC,CAAC;IACrBpB,qBAAqB,CACnByC,SAAS,EACR,kCAAiC,EAClC,SACF,CAAC;EACH,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdhD,qBAAqB,CAACyC,SAAS,EAAG,UAASO,KAAK,CAACI,OAAQ,EAAC,EAAE,MAAM,CAAC;EACrE;AACF"}
|
|
1
|
+
{"version":3,"file":"ScriptOps.js","names":["frodo","state","chokidar","fs","getFullExportConfig","isIdUsed","createProgressIndicator","createTable","debugMessage","failSpinner","printMessage","showSpinner","spinSpinner","stopProgressIndicator","succeedSpinner","updateProgressIndicator","wordwrap","getTypedFilename","isValidUrl","saveJsonToFile","saveTextToFile","titleCase","isBase64Encoded","getFilePath","getWorkingDirectory","utils","readScripts","exportScript","exportScriptByName","exportScripts","importScripts","deleteScript","deleteScriptByName","deleteScripts","script","getOneLineDescription","scriptObj","description","_id","context","name","getTableHeaderMd","markdown","getTableRowMd","langMap","JAVASCRIPT","GROOVY","language","split","join","listScripts","long","usage","file","spinnerId","scripts","sort","a","b","localeCompare","length","error","_error$response","response","data","message","forEach","fullExport","headers","_error$response2","push","table","values","isScriptUsed","used","location","toString","exportScriptToFile","scriptId","includeMeta","fileName","filePath","scriptExport","exportScriptByNameToFile","exportScriptsToFile","includeDefault","getRealm","exportScriptsToFiles","extract","outcome","scriptList","filter","default","barId","fileBarId","extractScriptToFile","directory","scriptSkeleton","getScriptSkeleton","fileExtension","scriptFileName","scriptFilePath","scriptText","Array","isArray","isScriptExtracted","importData","extracted","Object","keys","importScriptsFromFile","options","reUuid","readFile","err","JSON","parse","handleScriptFileImport","importScriptsFromFiles","watch","validateScripts","onChange","path","_stats","watcher","persistent","on","close","scriptFile","getScriptFile","getScriptExportByScriptFile","imported","endsWith","replace","getScriptExport","extractFile","getExtractFile","scriptRaw","readFileSync","startsWith","scriptExportRaw","getScriptId","scriptIds","Error","deleteScriptId","id","undefined","deleteScriptName","deleteAllScripts"],"sources":["../../src/ops/ScriptOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type ScriptSkeleton } from '@rockcarver/frodo-lib/types/api/ScriptApi';\nimport {\n type ScriptExportInterface,\n type ScriptImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport chokidar from 'chokidar';\nimport fs from 'fs';\n\nimport { getFullExportConfig, isIdUsed } from '../utils/Config';\nimport {\n createProgressIndicator,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n spinSpinner,\n stopProgressIndicator,\n succeedSpinner,\n updateProgressIndicator,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\n\nconst {\n getTypedFilename,\n isValidUrl,\n saveJsonToFile,\n saveTextToFile,\n titleCase,\n isBase64Encoded,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readScripts,\n exportScript,\n exportScriptByName,\n exportScripts,\n importScripts,\n deleteScript,\n deleteScriptByName,\n deleteScripts,\n} = frodo.script;\n\n/**\n * Get a one-line description of the script object\n * @param {ScriptSkeleton} scriptObj script object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(scriptObj: ScriptSkeleton): string {\n const description = `[${scriptObj._id['brightCyan']}] ${scriptObj.context} - ${scriptObj.name}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Language | Type | Id |\\n';\n markdown += '| ---- | -------- | ---- | ---|';\n return markdown;\n}\n\n/**\n * Get a one-line description of the script object in markdown\n * @param {TypesRaw.ScriptSkeleton} scriptObj script object to describe\n * @returns {string} markdown table row\n */\nexport function getTableRowMd(scriptObj: ScriptSkeleton): string {\n const langMap = { JAVASCRIPT: 'JavaSscript', GROOVY: 'Groovy' };\n const description = `| ${scriptObj.name} | ${\n langMap[scriptObj.language]\n } | ${titleCase(scriptObj.context.split('_').join(' '))} | \\`${\n scriptObj._id\n }\\` |`;\n return description;\n}\n\n/**\n * List scripts\n * @param {boolean} long detail list\n * @param {boolean} usage display usage field\n * @param {String | null} file Optional filename to determine usage\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function listScripts(\n long: boolean = false,\n usage: boolean = false,\n file: string | null = null\n): Promise<boolean> {\n let spinnerId: string;\n let scripts: ScriptSkeleton[] = [];\n debugMessage(`Cli.ScriptOps.listScripts: start`);\n try {\n spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Reading scripts...`\n );\n scripts = await readScripts();\n scripts.sort((a, b) => a.name.localeCompare(b.name));\n stopProgressIndicator(\n spinnerId,\n `Successfully read ${scripts.length} scripts.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n `Error reading scripts: ${error.response?.data || error.message}`,\n 'fail'\n );\n debugMessage(error);\n debugMessage(`Cli.ScriptOps.listScripts: end [false]`);\n return false;\n }\n if (!long && !usage) {\n scripts.forEach((script) => {\n printMessage(`${script.name}`, 'data');\n });\n debugMessage(`Cli.ScriptOps.listScripts: end [true]`);\n return true;\n }\n let fullExport = null;\n const headers = long\n ? ['Name', 'UUID', 'Language', 'Context', 'Description']\n : ['Name'];\n if (usage) {\n try {\n fullExport = await getFullExportConfig(file);\n } catch (error) {\n printMessage(\n `Error getting full export: ${error.response?.data || error.message}`,\n 'error'\n );\n debugMessage(`Cli.ScriptOps.listScripts: end [false]`);\n return false;\n }\n //Delete scripts from full export so they aren't mistakenly used for determining usage\n delete fullExport.script;\n headers.push('Used');\n }\n const table = createTable(headers);\n const langMap = { JAVASCRIPT: 'JS', GROOVY: 'Groovy' };\n scripts.forEach((script) => {\n const values = long\n ? [\n wordwrap(script.name, 25, ' '),\n script._id,\n langMap[script.language],\n wordwrap(titleCase(script.context.split('_').join(' ')), 25),\n wordwrap(script.description, 30),\n ]\n : [wordwrap(script.name, 25, ' ')];\n if (usage) {\n const isScriptUsed = isIdUsed(fullExport, script._id, false);\n values.push(\n isScriptUsed.used\n ? `${'yes'['brightGreen']} (at ${isScriptUsed.location})`\n : 'no'['brightRed']\n );\n }\n table.push(values);\n });\n printMessage(table.toString(), 'data');\n debugMessage(`Cli.ScriptOps.listScripts: end [true]`);\n return true;\n}\n\n/**\n * Export script by id to file\n * @param {string} scriptId script uuid\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptToFile(\n scriptId: string,\n file: string,\n includeMeta = true\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptToFile: start`);\n try {\n showSpinner(`Exporting script '${scriptId}'...`);\n let fileName = getTypedFilename(scriptId, 'script');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n spinSpinner(`Exporting script '${scriptId}' to '${filePath}'...`);\n const scriptExport = await exportScript(scriptId);\n saveJsonToFile(scriptExport, filePath, includeMeta);\n succeedSpinner(`Exported script '${scriptId}' to '${filePath}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${scriptId}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [false]`);\n return false;\n}\n\n/**\n * Export script by name to file\n * @param {string} name script name\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptByNameToFile(\n name: string,\n file: string,\n includeMeta = true\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: start`);\n try {\n showSpinner(`Exporting script '${name}'...`);\n let fileName = getTypedFilename(name, 'script');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n spinSpinner(`Exporting script '${name}' to '${filePath}'...`);\n const scriptExport = await exportScriptByName(name);\n saveJsonToFile(scriptExport, filePath, includeMeta);\n succeedSpinner(`Exported script '${name}' to '${filePath}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${name}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to single file\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {boolean} includeDefault true to include default scripts in export, false otherwise. Default: false\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFile(\n file: string,\n includeMeta = true,\n includeDefault = false\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: start`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(state.getRealm())}Scripts`,\n 'script'\n );\n if (file) {\n fileName = file;\n }\n const scriptExport = await exportScripts(includeDefault);\n saveJsonToFile(scriptExport, getFilePath(fileName, true), includeMeta);\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [true]`);\n return true;\n } catch (error) {\n printMessage(`Error exporting scripts: ${error.message}`, 'error');\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to individual 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 {boolean} includeDefault true to include default scripts in export, false otherwise. Default: false\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFiles(\n extract = false,\n includeMeta = true,\n includeDefault = false\n): Promise<boolean> {\n let outcome = true;\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: start`);\n let scriptList = await readScripts();\n if (!includeDefault)\n scriptList = scriptList.filter((script) => !script.default);\n const barId = createProgressIndicator(\n 'determinate',\n scriptList.length,\n 'Exporting scripts to individual files...'\n );\n for (const script of scriptList) {\n const fileBarId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting script ${script.name}...`\n );\n updateProgressIndicator(barId, `Reading script ${script.name}`);\n const file = getFilePath(getTypedFilename(script.name, 'script'), true);\n try {\n const scriptExport = await exportScriptByName(script.name);\n if (extract) extractScriptToFile(scriptExport);\n saveJsonToFile(scriptExport, file, includeMeta);\n updateProgressIndicator(fileBarId, `Saving ${script.name} to ${file}.`);\n stopProgressIndicator(fileBarId, `${script.name} saved to ${file}.`);\n } catch (error) {\n outcome = false;\n updateProgressIndicator(barId, `Error exporting ${script.name}.`);\n stopProgressIndicator(\n fileBarId,\n `Error saving ${script.name} to ${file}.`\n );\n printMessage(\n `Error exporting script '${script.name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n }\n stopProgressIndicator(\n barId,\n `Exported ${scriptList.length} scripts to individual files.`\n );\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Extracts a script from a script export into a separate file.\n * @param scriptExport The script export\n * @param scriptId The script id (optional if there is only one script in the export)\n * @param directory The directory within the base directory to save the script file\n */\nexport function extractScriptToFile(\n scriptExport: ScriptExportInterface,\n scriptId?: string,\n directory?: string\n) {\n const scriptSkeleton = scriptId\n ? scriptExport.script[scriptId]\n : getScriptSkeleton(scriptExport);\n const fileExtension =\n scriptSkeleton.language === 'JAVASCRIPT' ? 'js' : 'groovy';\n const scriptFileName = getTypedFilename(\n scriptSkeleton.name,\n 'script',\n fileExtension\n );\n const scriptFilePath = getFilePath(\n (directory ? `${directory}/` : '') + scriptFileName,\n true\n );\n const scriptText = Array.isArray(scriptSkeleton.script)\n ? scriptSkeleton.script.join('\\n')\n : scriptSkeleton.script;\n scriptSkeleton.script = `file://${scriptFilePath}`;\n saveTextToFile(scriptText, scriptFilePath);\n}\n\nfunction isScriptExtracted(importData: ScriptExportInterface): boolean {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: start`);\n let extracted = true;\n for (const scriptId of Object.keys(importData.script)) {\n const script = importData.script[scriptId].script;\n if (Array.isArray(script)) {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: script is string array`);\n extracted = false;\n break;\n }\n if (isValidUrl(script as string)) {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: script is extracted`);\n extracted = true;\n break;\n }\n if (isBase64Encoded) {\n debugMessage(`Cli.ScriptOps.isScriptExtracted: script is base64-encoded`);\n extracted = false;\n break;\n }\n break;\n }\n debugMessage(`Cli.ScriptOps.isScriptExtracted: end [extracted=${extracted}]`);\n return extracted;\n}\n\n/**\n * Import script(s) from file\n * @param {string} name Optional name of script. If supplied, only the script of that name is imported\n * @param {string} file file name\n * @param {ScriptImportOptions} options Script import options\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\nexport async function importScriptsFromFile(\n name: string,\n file: string,\n options: ScriptImportOptions = {\n reUuid: false,\n includeDefault: false,\n }\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: start`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n try {\n if (err) throw err;\n const importData: ScriptExportInterface = JSON.parse(data);\n if (isScriptExtracted(importData)) {\n await handleScriptFileImport(filePath, options, false);\n } else {\n await importScripts(name, importData, options);\n }\n outcome = true;\n } catch (error) {\n printMessage(\n `Error importing script '${name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n });\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Import extracted scripts.\n *\n * @param {boolean} watch whether or not to watch for file changes\n * @param {ScriptImportOptions} options Script import options\n * @param {boolean} validateScripts If true, validates Javascript scripts to ensure no errors exist in them. Default: false\n */\nexport async function importScriptsFromFiles(\n watch: boolean,\n options: ScriptImportOptions,\n validateScripts: boolean\n) {\n // If watch is true, it doesn't make sense to reUuid.\n options.reUuid = watch ? false : options.reUuid;\n\n /**\n * Run on file change detection, as well as on initial run.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async function onChange(path: string, _stats?: fs.Stats): Promise<void> {\n try {\n await handleScriptFileImport(path, options, validateScripts);\n } catch (error) {\n printMessage(`${path}: ${error.message}`, 'error');\n }\n }\n\n // We watch json files and script files.\n const watcher = chokidar.watch(\n [\n `${getWorkingDirectory()}/**/*.script.json`,\n `${getWorkingDirectory()}/**/*.script.js`,\n `${getWorkingDirectory()}/**/*.script.groovy`,\n ],\n {\n persistent: watch,\n }\n );\n\n watcher\n .on('add', onChange)\n .on('change', onChange)\n .on('error', (error) => {\n printMessage(`Watcher error: ${error}`, 'error');\n watcher.close();\n })\n .on('ready', () => {\n if (watch) {\n printMessage('Watching for changes...');\n } else {\n watcher.close();\n printMessage('Done.');\n }\n });\n}\n\n/**\n * Handle a script file import.\n *\n * @param {string} file Either a script file or an extract file\n * @param {ScriptImportOptions} options Script import options\n * @param {boolean} validateScripts If true, validates Javascript scripts to ensure no errors exist in them. Default: false\n */\nasync function handleScriptFileImport(\n file: string,\n options: ScriptImportOptions,\n validateScripts: boolean\n) {\n debugMessage(`Cli.ScriptOps.handleScriptFileImport: start`);\n const scriptFile = getScriptFile(file);\n const script = getScriptExportByScriptFile(scriptFile);\n\n const imported = await importScripts('', script, options, validateScripts);\n if (imported) {\n printMessage(`Imported '${scriptFile}'`);\n }\n debugMessage(`Cli.ScriptOps.handleScriptFileImport: end`);\n}\n\n/**\n * Get a script file from a file.\n *\n * @param file Either a script file or an extract file\n * @returns The script file\n */\nfunction getScriptFile(file: string) {\n if (file.endsWith('.script.json')) {\n return file;\n }\n return file.replace(/\\.script\\.(js|groovy)/, '.script.json');\n}\n\n/**\n * Get a script export from a script file.\n *\n * @param scriptFile The path to the script file\n * @returns The script export\n */\nfunction getScriptExportByScriptFile(\n scriptFile: string\n): ScriptExportInterface {\n const scriptExport = getScriptExport(scriptFile);\n const scriptSkeleton = getScriptSkeleton(scriptExport);\n\n const extractFile = getExtractFile(scriptSkeleton);\n if (!extractFile) {\n return scriptExport;\n }\n\n const scriptRaw = fs.readFileSync(extractFile, 'utf8');\n scriptSkeleton.script = scriptRaw.split('\\n');\n\n return scriptExport;\n}\n\n/**\n * Get an extract file from a script skeleton.\n *\n * @param scriptSkeleton The script skeleton\n * @returns The extract file or null if there is no extract file\n */\nfunction getExtractFile(scriptSkeleton: ScriptSkeleton): string | null {\n const extractFile = scriptSkeleton.script;\n if (Array.isArray(extractFile)) {\n return null;\n }\n if (\n extractFile.startsWith('file://') &&\n (extractFile.endsWith('.js') || extractFile.endsWith('.groovy'))\n ) {\n return extractFile.replace('file://', '');\n }\n return null;\n}\n\n/**\n * Get a script export from a file.\n *\n * @param file The path to a script export file\n * @returns The script export\n */\nfunction getScriptExport(file: string): ScriptExportInterface {\n const scriptExportRaw = fs.readFileSync(file, 'utf8');\n const scriptExport = JSON.parse(scriptExportRaw) as ScriptExportInterface;\n\n return scriptExport;\n}\n\n/**\n * Get the main script skeleton from a script export. If there is more than one\n * script, an error is thrown.\n *\n * @param script Get the main script skeleton from a script export\n * @returns The main script skeleton\n */\nfunction getScriptSkeleton(script: ScriptExportInterface): ScriptSkeleton {\n const scriptId = getScriptId(script);\n return script.script[scriptId];\n}\n\n/**\n * Get the main script ID from a script export. If there is more than one\n * script, an error is thrown.\n *\n * @param script The script export\n * @returns The main script ID\n */\nfunction getScriptId(script: ScriptExportInterface): string {\n const scriptIds = Object.keys(script.script);\n if (scriptIds.length !== 1) {\n throw new Error(`Expected 1 script, found ${scriptIds.length}`);\n }\n return scriptIds[0];\n}\n\n/**\n * Delete script by id\n * @param {String} id script id\n */\nexport async function deleteScriptId(id) {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${id}...`\n );\n try {\n await deleteScript(id);\n stopProgressIndicator(spinnerId, `Deleted ${id}.`, 'success');\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete script by name\n * @param {String} name script name\n */\nexport async function deleteScriptName(name) {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${name}...`\n );\n try {\n await deleteScriptByName(name);\n stopProgressIndicator(spinnerId, `Deleted ${name}.`, 'success');\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all non-default scripts\n */\nexport async function deleteAllScripts() {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting all non-default scripts...`\n );\n try {\n await deleteScripts();\n stopProgressIndicator(\n spinnerId,\n `Deleted all non-default scripts.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error: ${error.message}`, 'fail');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAMpD,OAAOC,QAAQ,MAAM,UAAU;AAC/B,OAAOC,EAAE,MAAM,IAAI;AAEnB,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ,iBAAiB;AAC/D,SACEC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAA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S,EAAG,WAAU2F,EAAG,GAAE,EAAE,SAAS,CAAC;EAC/D,CAAC,CAAC,OAAOpF,KAAK,EAAE;IACdhD,qBAAqB,CAACyC,SAAS,EAAG,UAASO,KAAK,CAACI,OAAQ,EAAC,EAAE,MAAM,CAAC;EACrE;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAekF,gBAAgBA,CAAC3G,IAAI,EAAE;EAC3C,MAAMc,SAAS,GAAGhD,uBAAuB,CACvC,eAAe,EACf4I,SAAS,EACR,YAAW1G,IAAK,KACnB,CAAC;EACD,IAAI;IACF,MAAMR,kBAAkB,CAACQ,IAAI,CAAC;IAC9B3B,qBAAqB,CAACyC,SAAS,EAAG,WAAUd,IAAK,GAAE,EAAE,SAAS,CAAC;EACjE,CAAC,CAAC,OAAOqB,KAAK,EAAE;IACdhD,qBAAqB,CAACyC,SAAS,EAAG,UAASO,KAAK,CAACI,OAAQ,EAAC,EAAE,MAAM,CAAC;EACrE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAemF,gBAAgBA,CAAA,EAAG;EACvC,MAAM9F,SAAS,GAAGhD,uBAAuB,CACvC,eAAe,EACf4I,SAAS,EACR,qCACH,CAAC;EACD,IAAI;IACF,MAAMjH,aAAa,CAAC,CAAC;IACrBpB,qBAAqB,CACnByC,SAAS,EACR,kCAAiC,EAClC,SACF,CAAC;EACH,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdhD,qBAAqB,CAACyC,SAAS,EAAG,UAASO,KAAK,CAACI,OAAQ,EAAC,EAAE,MAAM,CAAC;EACrE;AACF"}
|
package/esm/utils/Config.js
CHANGED
|
@@ -68,7 +68,8 @@ export async function getFullExportConfig(file = null) {
|
|
|
68
68
|
return await exportFullConfiguration({
|
|
69
69
|
useStringArrays: true,
|
|
70
70
|
noDecode: false,
|
|
71
|
-
coords: true
|
|
71
|
+
coords: true,
|
|
72
|
+
includeDefault: true
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
// Go through files in the working directory and reconstruct the full export
|
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","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 });\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,M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,KAAa,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","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,QAAQ,WAAW;AAExC,MAAM;EAAEC,WAAW;EAAEC;AAAU,CAAC,GAAGP,KAAK,CAACQ,KAAK;AAE9C,MAAM;EAAEC;AAAwB,CAAC,GAAGT,KAAK,CAACU,MAAM;AAEhD,MAAM;EAAEC;AAAsB,CAAC,GAAGX,KAAK,CAACY,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,QAAQ,GAAI,GAAEL,aAAa,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AAQ,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/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-44",
|
|
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": [
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
]
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"@rockcarver/frodo-lib": "2.0.0-
|
|
119
|
+
"@rockcarver/frodo-lib": "2.0.0-60",
|
|
120
120
|
"chokidar": "^3.5.3",
|
|
121
121
|
"cli-progress": "^3.11.2",
|
|
122
122
|
"cli-table3": "^0.6.3",
|