@rockcarver/frodo-cli 2.0.0-54 → 2.0.0-56

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 CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.0-55] - 2024-04-09
11
+
12
+ ### Changed
13
+
14
+ - Update to frodo-lib 2.0.0-77
15
+
16
+ ### Fixed
17
+
18
+ - Improved filtering out secrets from recordings
19
+ - rockcarver/frodo-lib#392: Implemented error handling pattern for methods with unusual amounts of REST calls like `frodo.config.exportFullConfiguration` and `frodo.config.importFullConfiguration` used in the `frodo config import` and `frodo config export` commands
20
+
21
+ ## [2.0.0-54] - 2024-04-01
22
+
10
23
  ### Changed
11
24
 
12
25
  - Update to frodo-lib 2.0.0-75
@@ -1530,7 +1543,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1530
1543
  - Fixed problem with adding connection profiles
1531
1544
  - Miscellaneous bug fixes
1532
1545
 
1533
- [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-53...HEAD
1546
+ [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-55...HEAD
1547
+
1548
+ [2.0.0-55]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-54...v2.0.0-55
1549
+
1550
+ [2.0.0-54]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-53...v2.0.0-54
1534
1551
 
1535
1552
  [2.0.0-53]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-52...v2.0.0-53
1536
1553
 
@@ -12,28 +12,33 @@ async (host, realm, user, password, options, command) => {
12
12
  // --all -a
13
13
  if (options.all && (await getTokens())) {
14
14
  verboseMessage('Exporting everything to a single file...');
15
- await exportEverythingToFile(options.file, options.metadata, {
15
+ const outcome = await exportEverythingToFile(options.file, options.metadata, {
16
16
  useStringArrays: options.useStringArrays,
17
17
  noDecode: options.decode,
18
18
  coords: options.coords,
19
19
  includeDefault: options.default
20
20
  });
21
- // require --directory -D for all-separate function
22
- } else if (options.allSeparate && !state.getDirectory()) {
21
+ if (!outcome) process.exitCode = 1;
22
+ }
23
+ // require --directory -D for all-separate function
24
+ else if (options.allSeparate && !state.getDirectory()) {
23
25
  printMessage('-D or --directory required when using -A or --all-separate', 'error');
24
26
  program.help();
25
27
  process.exitCode = 1;
26
- // --all-separate -A
27
- } else if (options.allSeparate && (await getTokens())) {
28
+ }
29
+ // --all-separate -A
30
+ else if (options.allSeparate && (await getTokens())) {
28
31
  verboseMessage('Exporting everything to separate files...');
29
- await exportEverythingToFiles(options.extract, options.metadata, {
32
+ const outcome = await exportEverythingToFiles(options.extract, options.metadata, {
30
33
  useStringArrays: options.useStringArrays,
31
34
  noDecode: options.decode,
32
35
  coords: options.coords,
33
36
  includeDefault: options.default
34
37
  });
35
- // unrecognized combination of options or no options
36
- } else {
38
+ if (!outcome) process.exitCode = 1;
39
+ }
40
+ // unrecognized combination of options or no options
41
+ else {
37
42
  verboseMessage('Unrecognized combination of options or no options...');
38
43
  program.help();
39
44
  process.exitCode = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"config-export.js","names":["state","Option","getTokens","exportEverythingToFile","exportEverythingToFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","metadata","useStringArrays","noDecode","decode","coords","includeDefault","allSeparate","getDirectory","help","process","exitCode","extract","parse"],"sources":["../../../src/cli/config/config-export.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n exportEverythingToFile,\n exportEverythingToFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst program = new FrodoCommand('frodo config export');\n\nprogram\n .description(\n 'Export full cloud configuration for all ops that currently support export.'\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(new Option('-a, --all', 'Export everything to a single file.'))\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export everything to separate files in the -D directory. Ignored with -a.'\n )\n )\n .addOption(\n new Option(\n '--use-string-arrays',\n 'Where applicable, use string arrays to store multi-line text (e.g. scripts).'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--no-decode',\n 'Do not include decoded variable value in variable export'\n ).default(false, 'false')\n )\n .addOption(\n new Option(\n '-x, --extract',\n 'Extract scripts from the exported file, and save it to a separate file. Ignored with -a.'\n )\n )\n .addOption(\n new Option(\n '-N, --no-metadata',\n 'Does not include metadata in the export file.'\n )\n )\n .addOption(\n new Option(\n '--no-coords',\n 'Do not include the x and y coordinate positions of the journey/tree nodes.'\n )\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Export all scripts including the default scripts.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // --all -a\n if (options.all && (await getTokens())) {\n verboseMessage('Exporting everything to a single file...');\n 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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OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,GAAG,KAAK,MAAMlB,SAAS,CAAC,CAAC,CAAC,EAAE;IACtCI,cAAc,CAAC,0CAA0C,CAAC;IAC1D,MAAMH,sBAAsB,CAACc,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,MAAM;MACtBC,cAAc,EAAEV,OAAO,CAACN;IAC1B,CAAC,CAAC;IACF;EACF,CAAC,MAAM,IAAIM,OAAO,CAACW,WAAW,IAAI,CAAC5B,KAAK,CAAC6B,YAAY,CAAC,CAAC,EAAE;IACvDxB,YAAY,CACV,4DAA4D,EAC5D,OACF,CAAC;IACDG,OAAO,CAACsB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpB;EACF,CAAC,MAAM,IAAIf,OAAO,CAACW,WAAW,KAAK,MAAM1B,SAAS,CAAC,CAAC,CAAC,EAAE;IACrDI,cAAc,CAAC,2CAA2C,CAAC;IAC3D,MAAMF,uBAAuB,CAACa,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;IACLL,cAAc,CAAC,sDAAsD,CAAC;IACtEE,OAAO,CAACsB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHxB,OAAO,CAAC0B,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"config-export.js","names":["state","Option","getTokens","exportEverythingToFile","exportEverythingToFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","outcome","file","metadata","useStringArrays","noDecode","decode","coords","includeDefault","process","exitCode","allSeparate","getDirectory","help","extract","parse"],"sources":["../../../src/cli/config/config-export.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n exportEverythingToFile,\n exportEverythingToFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst program = new FrodoCommand('frodo config export');\n\nprogram\n .description(\n 'Export full cloud configuration for all ops that currently support export.'\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(new Option('-a, --all', 'Export everything to a single file.'))\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export everything to separate files in the -D directory. Ignored with -a.'\n )\n )\n .addOption(\n new Option(\n '--use-string-arrays',\n 'Where applicable, use string arrays to store multi-line text (e.g. scripts).'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--no-decode',\n 'Do not include decoded variable value in variable export'\n ).default(false, 'false')\n )\n .addOption(\n new Option(\n '-x, --extract',\n 'Extract scripts from the exported file, and save it to a separate file. Ignored with -a.'\n )\n )\n .addOption(\n new Option(\n '-N, --no-metadata',\n 'Does not include metadata in the export file.'\n )\n )\n .addOption(\n new Option(\n '--no-coords',\n 'Do not include the x and y coordinate positions of the journey/tree nodes.'\n )\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Export all scripts including the default scripts.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // --all -a\n if (options.all && (await getTokens())) {\n verboseMessage('Exporting everything to a single file...');\n const outcome = await exportEverythingToFile(\n options.file,\n options.metadata,\n {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\n includeDefault: options.default,\n }\n );\n if (!outcome) process.exitCode = 1;\n }\n // require --directory -D for all-separate function\n else if (options.allSeparate && !state.getDirectory()) {\n printMessage(\n '-D or --directory required when using -A or --all-separate',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting everything to separate files...');\n const outcome = await exportEverythingToFiles(\n options.extract,\n options.metadata,\n {\n useStringArrays: options.useStringArrays,\n noDecode: options.decode,\n coords: options.coords,\n includeDefault: options.default,\n }\n );\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,sBAAsB,EACtBC,uBAAuB,QAClB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,OAAO,GAAG,IAAID,YAAY,CAAC,qBAAqB,CAAC;AAEvDC,OAAO,CACJC,WAAW,CACV,4EACF,CAAC,CACAC,SAAS,CAAC,IAAIT,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtES,SAAS,CAAC,IAAIT,MAAM,CAAC,WAAW,EAAE,qCAAqC,CAAC,CAAC,CACzES,SAAS,CACR,IAAIT,MAAM,CACR,oBAAoB,EACpB,2EACF,CACF,CAAC,CACAS,SAAS,CACR,IAAIT,MAAM,CACR,qBAAqB,EACrB,8EACF,CAAC,CAACU,OAAO,CAAC,KAAK,EAAE,KAAK,CACxB,CAAC,CACAD,SAAS,CACR,IAAIT,MAAM,CACR,aAAa,EACb,0DACF,CAAC,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K,MAAM7B,SAAS,CAAC,CAAC,CAAC,EAAE;IACnDI,cAAc,CAAC,2CAA2C,CAAC;IAC3D,MAAMe,OAAO,GAAG,MAAMjB,uBAAuB,CAC3Ca,OAAO,CAACiB,OAAO,EACfjB,OAAO,CAACM,QAAQ,EAChB;MACEC,eAAe,EAAEP,OAAO,CAACO,eAAe;MACxCC,QAAQ,EAAER,OAAO,CAACS,MAAM;MACxBC,MAAM,EAAEV,OAAO,CAACU,MAAM;MACtBC,cAAc,EAAEX,OAAO,CAACN;IAC1B,CACF,CAAC;IACD,IAAI,CAACU,OAAO,EAAEQ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHxB,cAAc,CAAC,sDAAsD,CAAC;IACtEE,OAAO,CAACyB,IAAI,CAAC,CAAC;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHtB,OAAO,CAAC2B,KAAK,CAAC,CAAC"}
@@ -14,10 +14,11 @@ async (host, realm, user, password, options, command) => {
14
14
  printMessage('-f or --file required when using -a or --all', 'error');
15
15
  program.help();
16
16
  process.exitCode = 1;
17
- // --all -a
18
- } else if (options.all && (await getTokens())) {
17
+ }
18
+ // --all -a
19
+ else if (options.all && (await getTokens())) {
19
20
  verboseMessage('Exporting everything from a single file...');
20
- await importEverythingFromFile(options.file, {
21
+ const outcome = await importEverythingFromFile(options.file, {
21
22
  reUuidJourneys: options.reUuidJourneys,
22
23
  reUuidScripts: options.reUuidScripts,
23
24
  cleanServices: options.clean,
@@ -25,15 +26,18 @@ async (host, realm, user, password, options, command) => {
25
26
  realm: options.realm,
26
27
  includeDefault: options.default
27
28
  });
28
- // require --directory -D for all-separate function
29
- } else if (options.allSeparate && !state.getDirectory()) {
29
+ if (!outcome) process.exitCode = 1;
30
+ }
31
+ // require --directory -D for all-separate function
32
+ else if (options.allSeparate && !state.getDirectory()) {
30
33
  printMessage('-D or --directory required when using -A or --all-separate', 'error');
31
34
  program.help();
32
35
  process.exitCode = 1;
33
- // --all-separate -A
34
- } else if (options.allSeparate && (await getTokens())) {
36
+ }
37
+ // --all-separate -A
38
+ else if (options.allSeparate && (await getTokens())) {
35
39
  verboseMessage('Importing everything from separate files...');
36
- await importEverythingFromFiles({
40
+ const outcome = await importEverythingFromFiles({
37
41
  reUuidJourneys: options.reUuidJourneys,
38
42
  reUuidScripts: options.reUuidScripts,
39
43
  cleanServices: options.clean,
@@ -41,8 +45,10 @@ async (host, realm, user, password, options, command) => {
41
45
  realm: options.realm,
42
46
  includeDefault: options.default
43
47
  });
44
- // unrecognized combination of options or no options
45
- } else {
48
+ if (!outcome) process.exitCode = 1;
49
+ }
50
+ // unrecognized combination of options or no options
51
+ else {
46
52
  verboseMessage('Unrecognized combination of options or no options...');
47
53
  program.help();
48
54
  process.exitCode = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"config-import.js","names":["state","Option","getTokens","importEverythingFromFile","importEverythingFromFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","help","process","exitCode","reUuidJourneys","reUuidScripts","cleanServices","clean","global","includeDefault","allSeparate","getDirectory","parse"],"sources":["../../../src/cli/config/config-import.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n importEverythingFromFile,\n importEverythingFromFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst program = new FrodoCommand('frodo config import');\n\nprogram\n .description('Import full cloud configuration.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all configuration from the single file -f. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all configuration from separate (.json) files in the (working) directory -D. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option('-g, --global', 'Import service(s) as global service(s).')\n )\n .addOption(\n new Option(\n '-r, --current-realm',\n 'Import service(s) into the current realm.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid-journeys',\n 'Generate new UUIDs for all journey nodes during import.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--re-uuid-scripts',\n 'Create new UUIDs for the scripts upon import. Use this to duplicate scripts or create a new versions of the same scripts.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Import all scripts including the default scripts.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // Require --file -f for all function\n if (options.all && !options.file) {\n printMessage('-f or --file required when using -a or --all', 'error');\n program.help();\n process.exitCode = 1;\n // --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,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ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,sDAAsD,CAAC;IACtEE,OAAO,CAACc,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHhB,OAAO,CAACyB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"config-import.js","names":["state","Option","getTokens","importEverythingFromFile","importEverythingFromFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","all","file","help","process","exitCode","outcome","reUuidJourneys","reUuidScripts","cleanServices","clean","global","includeDefault","allSeparate","getDirectory","parse"],"sources":["../../../src/cli/config/config-import.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n importEverythingFromFile,\n importEverythingFromFiles,\n} from '../../ops/ConfigOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst program = new FrodoCommand('frodo config import');\n\nprogram\n .description('Import full cloud configuration.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all configuration from the single file -f. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all configuration from separate (.json) files in the (working) directory -D. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option('-g, --global', 'Import service(s) as global service(s).')\n )\n .addOption(\n new Option(\n '-r, --current-realm',\n 'Import service(s) into the current realm.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid-journeys',\n 'Generate new UUIDs for all journey nodes during import.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--re-uuid-scripts',\n 'Create new UUIDs for the scripts upon import. Use this to duplicate scripts or create a new versions of the same scripts.'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '-d, --default',\n 'Import all scripts including the default scripts.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // Require --file -f for all function\n if (options.all && !options.file) {\n printMessage('-f or --file required when using -a or --all', 'error');\n program.help();\n process.exitCode = 1;\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting everything from a single file...');\n const outcome = await importEverythingFromFile(options.file, {\n reUuidJourneys: options.reUuidJourneys,\n reUuidScripts: options.reUuidScripts,\n cleanServices: options.clean,\n global: options.global,\n realm: options.realm,\n includeDefault: options.default,\n });\n if (!outcome) process.exitCode = 1;\n }\n // require --directory -D for all-separate function\n else if (options.allSeparate && !state.getDirectory()) {\n printMessage(\n '-D or --directory required when using -A or --all-separate',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Importing everything from separate files...');\n const outcome = await importEverythingFromFiles({\n reUuidJourneys: options.reUuidJourneys,\n reUuidScripts: options.reUuidScripts,\n cleanServices: options.clean,\n global: options.global,\n realm: options.realm,\n includeDefault: options.default,\n });\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,OAAO,GAAG,IAAID,YAAY,CAAC,qBAAqB,CAAC;AAEvDC,OAAO,CACJC,WAAW,CAAC,kCAAkC,CAAC,CAC/CC,SAAS,CAAC,IAA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KAAK,CAAC,CAAC"}
@@ -13,14 +13,14 @@ program.description('Export scripts.').addOption(new Option('-n, --script-name <
13
13
  // )
14
14
  .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.'))
15
15
  // deprecated option
16
- .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(
16
+ .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 -a.')).addOption(new Option('-d, --default', 'Export all scripts including the default scripts. Ignored with -n.')).action(
17
17
  // implement command logic inside action handler
18
18
  async (host, realm, user, password, options, command) => {
19
19
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
20
20
  // export by name
21
21
  if ((options.scriptName || options.script) && (await getTokens())) {
22
22
  verboseMessage('Exporting script...');
23
- const outcome = await exportScriptByNameToFile(options.scriptName || options.script, options.file, options.metadata);
23
+ const outcome = await exportScriptByNameToFile(options.scriptName || options.script, options.file, options.metadata, options.extract);
24
24
  if (!outcome) process.exitCode = 1;
25
25
  }
26
26
  // -a / --all
@@ -1 +1 @@
1
- {"version":3,"file":"script-export.js","names":["Option","getTokens","exportScriptByNameToFile","exportScriptsToFile","exportScriptsToFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","scriptName","script","outcome","file","metadata","process","exitCode","all","default","allSeparate","extract","help","parse"],"sources":["../../../src/cli/script/script-export.ts"],"sourcesContent":["import { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n exportScriptByNameToFile,\n exportScriptsToFile,\n exportScriptsToFiles,\n} from '../../ops/ScriptOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\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 // export by name\n if ((options.scriptName || options.script) && (await getTokens())) {\n verboseMessage('Exporting script...');\n const outcome = await exportScriptByNameToFile(\n options.scriptName || options.script,\n options.file,\n options.metadata\n );\n if (!outcome) process.exitCode = 1;\n }\n // -a / --all\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all scripts to a single file...');\n const outcome = await exportScriptsToFile(\n options.file,\n options.metadata,\n options.default\n );\n if (!outcome) process.exitCode = 1;\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all scripts to separate files...');\n // -x / --extract\n const outcome = await exportScriptsToFiles(\n options.extract,\n options.metadata,\n options.default\n );\n if (!outcome) process.exitCode = 1;\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,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,wBAAwB,EACxBC,mBAAmB,EACnBC,oBAAoB,QACf,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,OAAO,GAAG,IAAID,YAAY,CAAC,qBAAqB,CAAC;AAEvDC,OAAO,CACJC,WAAW,CAAC,iBAAiB,CAAC,CAC9BC,SAAS,CACR,IAAIV,MAAM,CACR,0BAA0B,EAC1B,0DACF,CACF;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,CACCU,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,uDACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,uGACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,mBAAmB,EACnB,+CACF,CACF;AACA;AAAA,CACCU,SAAS,CACR,IAAIV,MAAM,CACR,uBAAuB,EACvB,+DACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,eAAe,EACf,mGACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,eAAe,EACf,oEACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC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,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHjB,OAAO,CAACuB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"script-export.js","names":["Option","getTokens","exportScriptByNameToFile","exportScriptsToFile","exportScriptsToFiles","printMessage","verboseMessage","FrodoCommand","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","scriptName","script","outcome","file","metadata","extract","process","exitCode","all","default","allSeparate","help","parse"],"sources":["../../../src/cli/script/script-export.ts"],"sourcesContent":["import { Option } from 'commander';\n\nimport { getTokens } from '../../ops/AuthenticateOps';\nimport {\n exportScriptByNameToFile,\n exportScriptsToFile,\n exportScriptsToFiles,\n} from '../../ops/ScriptOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\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 -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 // export by name\n if ((options.scriptName || options.script) && (await getTokens())) {\n verboseMessage('Exporting script...');\n const outcome = await exportScriptByNameToFile(\n options.scriptName || options.script,\n options.file,\n options.metadata,\n options.extract\n );\n if (!outcome) process.exitCode = 1;\n }\n // -a / --all\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all scripts to a single file...');\n const outcome = await exportScriptsToFile(\n options.file,\n options.metadata,\n options.default\n );\n if (!outcome) process.exitCode = 1;\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all scripts to separate files...');\n // -x / --extract\n const outcome = await exportScriptsToFiles(\n options.extract,\n options.metadata,\n options.default\n );\n if (!outcome) process.exitCode = 1;\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,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,wBAAwB,EACxBC,mBAAmB,EACnBC,oBAAoB,QACf,qBAAqB;AAC5B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,OAAO,GAAG,IAAID,YAAY,CAAC,qBAAqB,CAAC;AAEvDC,OAAO,CACJC,WAAW,CAAC,iBAAiB,CAAC,CAC9BC,SAAS,CACR,IAAIV,MAAM,CACR,0BAA0B,EAC1B,0DACF,CACF;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,CACCU,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,uDACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,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AAW,KAAK,MAAM5B,SAAS,CAAC,CAAC,CAAC,EAAE;IACnDK,cAAc,CAAC,4CAA4C,CAAC;IAC5D;IACA,MAAMe,OAAO,GAAG,MAAMjB,oBAAoB,CACxCY,OAAO,CAACQ,OAAO,EACfR,OAAO,CAACO,QAAQ,EAChBP,OAAO,CAACY,OACV,CAAC;IACD,IAAI,CAACP,OAAO,EAAEI,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;;EAEA;EAAA,KACK;IACHrB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDG,OAAO,CAACsB,IAAI,CAAC,CAAC;IACdL,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;AAEHlB,OAAO,CAACuB,KAAK,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
- import { frodo, state } from '@rockcarver/frodo-lib';
1
+ import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';
2
2
  import fs from 'fs';
3
3
  import fse from 'fs-extra';
4
4
  import { getFullExportConfig, getFullExportConfigFromDirectory } from '../utils/Config';
5
- import { printError, printMessage } from '../utils/Console';
5
+ import { cleanupProgressIndicators, printError, printMessage } from '../utils/Console';
6
6
  import { extractScriptToFile } from './ScriptOps';
7
7
  const {
8
8
  getRealmName,
@@ -25,6 +25,7 @@ const {
25
25
  * @param {String} file file name
26
26
  * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
27
27
  * @param {FullExportOptions} options export options
28
+ * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
28
29
  */
29
30
  export async function exportEverythingToFile(file, includeMeta = true, options = {
30
31
  useStringArrays: true,
@@ -33,15 +34,21 @@ export async function exportEverythingToFile(file, includeMeta = true, options =
33
34
  includeDefault: false
34
35
  }) {
35
36
  try {
36
- const exportData = await exportFullConfiguration(options);
37
+ const collectErrors = [];
38
+ const exportData = await exportFullConfiguration(options, collectErrors);
37
39
  let fileName = getTypedFilename(`${titleCase(getRealmName(state.getRealm()))}`, `everything`);
38
40
  if (file) {
39
41
  fileName = file;
40
42
  }
41
43
  saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
44
+ if (collectErrors.length > 0) {
45
+ throw new FrodoError(`Errors occurred during full export`, collectErrors);
46
+ }
47
+ return true;
42
48
  } catch (error) {
43
49
  printError(error);
44
50
  }
51
+ return false;
45
52
  }
46
53
 
47
54
  /**
@@ -49,6 +56,7 @@ export async function exportEverythingToFile(file, includeMeta = true, options =
49
56
  * @param {boolean} extract Extracts the scripts from the exports into separate files if true
50
57
  * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
51
58
  * @param {FullExportOptions} options export options
59
+ * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
52
60
  */
53
61
  export async function exportEverythingToFiles(extract = false, includeMeta = true, options = {
54
62
  useStringArrays: true,
@@ -57,7 +65,8 @@ export async function exportEverythingToFiles(extract = false, includeMeta = tru
57
65
  includeDefault: false
58
66
  }) {
59
67
  try {
60
- const exportData = await exportFullConfiguration(options);
68
+ const collectErrors = [];
69
+ const exportData = await exportFullConfiguration(options, collectErrors);
61
70
  delete exportData.meta;
62
71
  const baseDirectory = getWorkingDirectory(true);
63
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -123,7 +132,7 @@ export async function exportEverythingToFiles(extract = false, includeMeta = tru
123
132
  });
124
133
  }
125
134
  } else {
126
- const filename = getTypedFilename(value && value.name ? value.name : id, type);
135
+ const filename = getTypedFilename(value && value.name && type !== 'emailTemplate' ? value.name : id, type);
127
136
  if (extract && type == 'script') {
128
137
  extractScriptToFile(exportData, id, type);
129
138
  }
@@ -137,15 +146,21 @@ export async function exportEverythingToFiles(extract = false, includeMeta = tru
137
146
  }
138
147
  }
139
148
  });
149
+ if (collectErrors.length > 0) {
150
+ throw new FrodoError(`Errors occurred during full export`, collectErrors);
151
+ }
152
+ return true;
140
153
  } catch (error) {
141
154
  printError(error);
142
155
  }
156
+ return false;
143
157
  }
144
158
 
145
159
  /**
146
160
  * Import everything from a single file
147
- * @param {String} file The file path
161
+ * @param {string} file The file path
148
162
  * @param {FullImportOptions} options import options
163
+ * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
149
164
  */
150
165
  export async function importEverythingFromFile(file, options = {
151
166
  reUuidJourneys: false,
@@ -157,14 +172,22 @@ export async function importEverythingFromFile(file, options = {
157
172
  }) {
158
173
  try {
159
174
  const data = await getFullExportConfig(file);
160
- await importFullConfiguration(data, options);
175
+ const collectErrors = [];
176
+ await importFullConfiguration(data, options, collectErrors);
177
+ if (collectErrors.length > 0) {
178
+ throw new FrodoError(`Errors occurred during full config import`, collectErrors);
179
+ }
180
+ return true;
161
181
  } catch (error) {
182
+ cleanupProgressIndicators();
162
183
  printError(error);
163
184
  }
185
+ return false;
164
186
  }
165
187
 
166
188
  /**
167
189
  * Import everything from separate files
190
+ * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
168
191
  */
169
192
  export async function importEverythingFromFiles(options = {
170
193
  reUuidJourneys: false,
@@ -176,9 +199,15 @@ export async function importEverythingFromFiles(options = {
176
199
  }) {
177
200
  try {
178
201
  const data = await getFullExportConfigFromDirectory(state.getDirectory());
179
- await importFullConfiguration(data, options);
202
+ const collectErrors = [];
203
+ await importFullConfiguration(data, options, collectErrors);
204
+ if (collectErrors.length > 0) {
205
+ throw new FrodoError(`Errors occurred during full config import`, collectErrors);
206
+ }
207
+ return true;
180
208
  } catch (error) {
181
209
  printError(error);
182
210
  }
211
+ return false;
183
212
  }
184
213
  //# sourceMappingURL=ConfigOps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigOps.js","names":["frodo","state","fs","fse","getFullExportConfig","getFullExportConfigFromDirectory","printError","printMessage","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","stringify","json","exportFullConfiguration","importFullConfiguration","config","exportEverythingToFile","file","includeMeta","options","useStringArrays","noDecode","coords","includeDefault","exportData","fileName","getRealm","error","exportEverythingToFiles","extract","meta","baseDirectory","Object","entries","forEach","type","obj","existsSync","mkdirSync","samlData","saml","cot","hosted","metadata","remote","id","value","concat","filename","entityId","samlType","authentication","includes","slice","lastIndexOf","recursive","outputFile","err","name","importEverythingFromFile","reUuidJourneys","reUuidScripts","cleanServices","global","realm","data","importEverythingFromFiles","getDirectory"],"sources":["../../src/ops/ConfigOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport {\n FullExportInterface,\n FullExportOptions,\n FullImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ConfigOps';\nimport { ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\n\nimport {\n getFullExportConfig,\n getFullExportConfigFromDirectory,\n} from '../utils/Config';\nimport { printError, printMessage } from '../utils/Console';\nimport { extractScriptToFile } from './ScriptOps';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst { stringify } = frodo.utils.json;\nconst { exportFullConfiguration, importFullConfiguration } = frodo.config;\n\n/**\n * Export everything to separate files\n * @param {String} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFile(\n file: string,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<void> {\n try {\n const exportData = await exportFullConfiguration(options);\n let fileName = getTypedFilename(\n `${titleCase(getRealmName(state.getRealm()))}`,\n `everything`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n } catch (error) {\n printError(error);\n }\n}\n\n/**\n * Export everything to separate files\n * @param {boolean} extract Extracts the scripts from the exports into separate files if true\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFiles(\n extract: boolean = false,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<void> {\n try {\n const exportData: FullExportInterface =\n await exportFullConfiguration(options);\n delete exportData.meta;\n const baseDirectory = getWorkingDirectory(true);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(exportData).forEach(([type, obj]: [string, any]) => {\n if (obj) {\n if (!fs.existsSync(`${baseDirectory}/${type}`)) {\n fs.mkdirSync(`${baseDirectory}/${type}`);\n }\n if (type == 'saml') {\n const samlData = {\n saml: {\n cot: {},\n hosted: {},\n metadata: {},\n remote: {},\n },\n };\n if (obj.cot) {\n if (!fs.existsSync(`${baseDirectory}/cot`)) {\n fs.mkdirSync(`${baseDirectory}/cot`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj.cot).forEach(([id, value]: [string, any]) => {\n samlData.saml.cot = {\n [id]: value,\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/cot/${getTypedFilename(id, 'cot.saml')}`,\n includeMeta\n );\n });\n samlData.saml.cot = {};\n }\n Object.entries(obj.hosted)\n .concat(Object.entries(obj.remote))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .forEach(([id, value]: [string, any]) => {\n const filename = getTypedFilename(\n value.entityId ? value.entityId : id,\n type\n );\n const samlType = obj.hosted[id] ? 'hosted' : 'remote';\n samlData.saml[samlType][id] = value;\n samlData.saml.metadata = {\n [id]: obj.metadata[id],\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n samlData.saml[samlType] = {};\n });\n } else if (type == 'authentication') {\n const fileName = getTypedFilename(\n `${frodo.utils.getRealmName(state.getRealm())}Realm`,\n 'authentication.settings'\n );\n saveJsonToFile(\n {\n authentication: obj,\n },\n `${baseDirectory}/${type}/${fileName}`,\n includeMeta\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj).forEach(([id, value]: [string, any]) => {\n if (type == 'config') {\n if (value != null) {\n const filename = `${id}.json`;\n if (filename.includes('/')) {\n fs.mkdirSync(\n `${baseDirectory}/${type}/${filename.slice(\n 0,\n filename.lastIndexOf('/')\n )}`,\n {\n recursive: true,\n }\n );\n }\n fse.outputFile(\n `${baseDirectory}/${type}/${filename}`,\n stringify(value),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n } else {\n const filename = getTypedFilename(\n value && value.name ? value.name : id,\n type\n );\n if (extract && type == 'script') {\n extractScriptToFile(\n exportData as ScriptExportInterface,\n id,\n type\n );\n }\n saveJsonToFile(\n {\n [type]: {\n [id]: value,\n },\n },\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n }\n });\n }\n }\n });\n } catch (error) {\n printError(error);\n }\n}\n\n/**\n * Import everything from a single file\n * @param {String} file The file path\n * @param {FullImportOptions} options import options\n */\nexport async function importEverythingFromFile(\n file: string,\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n) {\n try {\n const data = await getFullExportConfig(file);\n await importFullConfiguration(data, options);\n } catch (error) {\n printError(error);\n }\n}\n\n/**\n * Import everything from separate files\n */\nexport async function importEverythingFromFiles(\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n) {\n try {\n const data = await getFullExportConfigFromDirectory(state.getDirectory());\n await importFullConfiguration(data, options);\n } catch (error) {\n printError(error);\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAOpD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAE1B,SACEC,mBAAmB,EACnBC,gCAAgC,QAC3B,iBAAiB;AACxB,SAASC,UAAU,EAAEC,YAAY,QAAQ,k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AEA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAegC,wBAAwBA,CAC5C1C,IAAY,EACZE,OAA0B,GAAG;EAC3ByC,cAAc,EAAE,KAAK;EACrBC,aAAa,EAAE,KAAK;EACpBC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE,KAAK;EACZzC,cAAc,EAAE;AAClB,CAAC,EACD;EACA,IAAI;IACF,MAAM0C,IAAI,GAAG,MAAMlE,mBAAmB,CAACkB,IAAI,CAAC;IAC5C,MAAMH,uBAAuB,CAACmD,IAAI,EAAE9C,OAAO,CAAC;EAC9C,CAAC,CAAC,OAAOQ,KAAK,EAAE;IACd1B,UAAU,CAAC0B,KAAK,CAAC;EACnB;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeuC,yBAAyBA,CAC7C/C,OAA0B,GAAG;EAC3ByC,cAAc,EAAE,KAAK;EACrBC,aAAa,EAAE,KAAK;EACpBC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE,KAAK;EACZzC,cAAc,EAAE;AAClB,CAAC,EACD;EACA,IAAI;IACF,MAAM0C,IAAI,GAAG,MAAMjE,gCAAgC,CAACJ,KAAK,CAACuE,YAAY,CAAC,CAAC,CAAC;IACzE,MAAMrD,uBAAuB,CAACmD,IAAI,EAAE9C,OAAO,CAAC;EAC9C,CAAC,CAAC,OAAOQ,KAAK,EAAE;IACd1B,UAAU,CAAC0B,KAAK,CAAC;EACnB;AACF"}
1
+ {"version":3,"file":"ConfigOps.js","names":["frodo","FrodoError","state","fs","fse","getFullExportConfig","getFullExportConfigFromDirectory","cleanupProgressIndicators","printError","printMessage","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","stringify","json","exportFullConfiguration","importFullConfiguration","config","exportEverythingToFile","file","includeMeta","options","useStringArrays","noDecode","coords","includeDefault","collectErrors","exportData","fileName","getRealm","length","error","exportEverythingToFiles","extract","meta","baseDirectory","Object","entries","forEach","type","obj","existsSync","mkdirSync","samlData","saml","cot","hosted","metadata","remote","id","value","concat","filename","entityId","samlType","authentication","includes","slice","lastIndexOf","recursive","outputFile","err","name","importEverythingFromFile","reUuidJourneys","reUuidScripts","cleanServices","global","realm","data","importEverythingFromFiles","getDirectory"],"sources":["../../src/ops/ConfigOps.ts"],"sourcesContent":["import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';\nimport {\n FullExportInterface,\n FullExportOptions,\n FullImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ConfigOps';\nimport { ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\n\nimport {\n getFullExportConfig,\n getFullExportConfigFromDirectory,\n} from '../utils/Config';\nimport {\n cleanupProgressIndicators,\n printError,\n printMessage,\n} from '../utils/Console';\nimport { extractScriptToFile } from './ScriptOps';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst { stringify } = frodo.utils.json;\nconst { exportFullConfiguration, importFullConfiguration } = frodo.config;\n\n/**\n * Export everything to separate files\n * @param {String} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportEverythingToFile(\n file: string,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const collectErrors: Error[] = [];\n const exportData = await exportFullConfiguration(options, collectErrors);\n let fileName = getTypedFilename(\n `${titleCase(getRealmName(state.getRealm()))}`,\n `everything`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n if (collectErrors.length > 0) {\n throw new FrodoError(`Errors occurred during full export`, collectErrors);\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export everything to separate files\n * @param {boolean} extract Extracts the scripts from the exports into separate files if true\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportEverythingToFiles(\n extract: boolean = false,\n includeMeta: boolean = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n coords: true,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const collectErrors: Error[] = [];\n const exportData: FullExportInterface = await exportFullConfiguration(\n options,\n collectErrors\n );\n delete exportData.meta;\n const baseDirectory = getWorkingDirectory(true);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(exportData).forEach(([type, obj]: [string, any]) => {\n if (obj) {\n if (!fs.existsSync(`${baseDirectory}/${type}`)) {\n fs.mkdirSync(`${baseDirectory}/${type}`);\n }\n if (type == 'saml') {\n const samlData = {\n saml: {\n cot: {},\n hosted: {},\n metadata: {},\n remote: {},\n },\n };\n if (obj.cot) {\n if (!fs.existsSync(`${baseDirectory}/cot`)) {\n fs.mkdirSync(`${baseDirectory}/cot`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj.cot).forEach(([id, value]: [string, any]) => {\n samlData.saml.cot = {\n [id]: value,\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/cot/${getTypedFilename(id, 'cot.saml')}`,\n includeMeta\n );\n });\n samlData.saml.cot = {};\n }\n Object.entries(obj.hosted)\n .concat(Object.entries(obj.remote))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .forEach(([id, value]: [string, any]) => {\n const filename = getTypedFilename(\n value.entityId ? value.entityId : id,\n type\n );\n const samlType = obj.hosted[id] ? 'hosted' : 'remote';\n samlData.saml[samlType][id] = value;\n samlData.saml.metadata = {\n [id]: obj.metadata[id],\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n samlData.saml[samlType] = {};\n });\n } else if (type == 'authentication') {\n const fileName = getTypedFilename(\n `${frodo.utils.getRealmName(state.getRealm())}Realm`,\n 'authentication.settings'\n );\n saveJsonToFile(\n {\n authentication: obj,\n },\n `${baseDirectory}/${type}/${fileName}`,\n includeMeta\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj).forEach(([id, value]: [string, any]) => {\n if (type == 'config') {\n if (value != null) {\n const filename = `${id}.json`;\n if (filename.includes('/')) {\n fs.mkdirSync(\n `${baseDirectory}/${type}/${filename.slice(\n 0,\n filename.lastIndexOf('/')\n )}`,\n {\n recursive: true,\n }\n );\n }\n fse.outputFile(\n `${baseDirectory}/${type}/${filename}`,\n stringify(value),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n } else {\n const filename = getTypedFilename(\n value && value.name && type !== 'emailTemplate'\n ? value.name\n : id,\n type\n );\n if (extract && type == 'script') {\n extractScriptToFile(\n exportData as ScriptExportInterface,\n id,\n type\n );\n }\n saveJsonToFile(\n {\n [type]: {\n [id]: value,\n },\n },\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n }\n });\n }\n }\n });\n if (collectErrors.length > 0) {\n throw new FrodoError(`Errors occurred during full export`, collectErrors);\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import everything from a single file\n * @param {string} file The file path\n * @param {FullImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importEverythingFromFile(\n file: string,\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const data = await getFullExportConfig(file);\n const collectErrors: Error[] = [];\n await importFullConfiguration(data, options, collectErrors);\n if (collectErrors.length > 0) {\n throw new FrodoError(\n `Errors occurred during full config import`,\n collectErrors\n );\n }\n return true;\n } catch (error) {\n cleanupProgressIndicators();\n printError(error);\n }\n return false;\n}\n\n/**\n * Import everything from separate files\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importEverythingFromFiles(\n options: FullImportOptions = {\n reUuidJourneys: false,\n reUuidScripts: false,\n cleanServices: false,\n global: false,\n realm: false,\n includeDefault: false,\n }\n): Promise<boolean> {\n try {\n const data = await getFullExportConfigFromDirectory(state.getDirectory());\n const collectErrors: Error[] = [];\n await importFullConfiguration(data, options, collectErrors);\n if (collectErrors.length > 0) {\n throw new FrodoError(\n `Errors occurred during full config import`,\n collectErrors\n );\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,EAAEC,KAAK,QAAQ,uBAAuB;AAOhE,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAE1B,SACEC,mBAAmB,EACnBC,gCAAgC,QAC3B,iBAAiB;AACxB,SACEC,yBAAyB,EACzBC,UAAU,EACVC,YAAY,QACP,kBAAkB;AACzB,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,MAAM;EACJC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGhB,KAAK,CAACiB,KAAK;AACf,MAAM;EAAEC;AAAU,CAAC,GAAGlB,KAAK,CAACiB,KAAK,CAACE,IAAI;AACtC,MAAM;EAAEC,uBAAuB;EAAEC;AAAwB,CAAC,GAAGrB,KAAK,CAACsB,MAAM;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,sBAAsBA,CAC1CC,IAAY,EACZC,WAAoB,GAAG,IAAI,EAC3BC,OAA0B,GAAG;EAC3BC,eAAe,EAAE,IAAI;EACrBC,QAAQ,EAAE,KAAK;EACfC,MAAM,EAAE,IAAI;EACZC,cAAc,EAAE;AAClB,CAAC,EACiB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;EACnB;EACA,OAAO,KAAK;AACd"}
package/esm/ops/IdmOps.js CHANGED
@@ -197,8 +197,11 @@ export async function importConfigEntityByIdFromFile(entityId, file, validate) {
197
197
  * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise
198
198
  */
199
199
  export async function importConfigEntityFromFile(file, validate) {
200
+ const filePath = getFilePath(file);
201
+ let indicatorId;
200
202
  try {
201
- const fileData = fs.readFileSync(path.resolve(process.cwd(), getFilePath(file)), 'utf8');
203
+ indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${filePath}...`);
204
+ const fileData = fs.readFileSync(path.resolve(process.cwd(), filePath), 'utf8');
202
205
  const entityData = JSON.parse(fileData);
203
206
  const entityId = entityData._id;
204
207
  const isValid = areScriptHooksValid(entityData);
@@ -207,8 +210,10 @@ export async function importConfigEntityFromFile(file, validate) {
207
210
  return;
208
211
  }
209
212
  await updateConfigEntity(entityId, entityData);
213
+ stopProgressIndicator(indicatorId, `Imported ${entityId} from ${filePath}.`, 'success');
210
214
  return true;
211
215
  } catch (error) {
216
+ stopProgressIndicator(indicatorId, `Error importing ${filePath}.`, 'fail');
212
217
  printError(error);
213
218
  }
214
219
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"IdmOps.js","names":["frodo","FrodoError","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printError","printMessage","stopProgressIndicator","stringify","utils","json","unSubstituteEnvParams","areScriptHooksValid","getFilePath","getTypedFilename","readFiles","getWorkingDirectory","readConfigEntities","readConfigEntity","exportConfigEntities","updateConfigEntity","importConfigEntities","idm","config","queryManagedObjects","managed","testConnectorServers","system","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","listAllConfigEntities","configurations","configEntity","_id","exportConfigEntity","id","file","fileName","writeFile","err","exportAllRawConfigEntities","exportedConfigurations","value","Object","entries","outputFile","exportAllConfigEntities","entitiesFile","envFile","errors","entriesToExport","data","readFileSync","entriesData","JSON","parse","envParams","undefined","entityPromises","includes","push","results","Promise","item","configEntityString","each","key","outputFileSync","importConfigEntityByIdFromFile","entityId","validate","fileData","resolve","process","cwd","entityData","isValid","importConfigEntityFromFile","importAllRawConfigEntities","options","indicatorId","baseDirectory","files","jsonObjects","toLowerCase","endsWith","content","entity","importData","fromEntries","importAllConfigEntities","entriesToImport","envReader","countManagedObjects","type","result"],"sources":["../../src/ops/IdmOps.ts"],"sourcesContent":["import { frodo, FrodoError } from '@rockcarver/frodo-lib';\nimport { type ConfigEntityImportOptions } from '@rockcarver/frodo-lib/types/ops/IdmConfigOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport {\n createProgressIndicator,\n printError,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\n\nconst { stringify } = frodo.utils.json;\n\nconst {\n unSubstituteEnvParams,\n areScriptHooksValid,\n getFilePath,\n getTypedFilename,\n readFiles,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readConfigEntities,\n readConfigEntity,\n exportConfigEntities,\n updateConfigEntity,\n importConfigEntities,\n} = frodo.idm.config;\nconst { queryManagedObjects } = frodo.idm.managed;\nconst { testConnectorServers } = frodo.idm.system;\n\n/**\n * Warn about and list offline remote connector servers\n * @return {Promise<boolean>} a promise that resolves to true if a warning was printed, false otherwise\n */\nexport async function warnAboutOfflineConnectorServers(): Promise<boolean> {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length > 0) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n return true;\n }\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * List all IDM configuration objects\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function listAllConfigEntities(): Promise<boolean> {\n try {\n const configurations = await readConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export an IDM configuration object.\n * @param {string} id the desired configuration object\n * @param {string} file optional export file\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportConfigEntity(\n id: string,\n file: string\n): Promise<boolean> {\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await readConfigEntity(id);\n fs.writeFile(\n getFilePath(fileName, true),\n stringify(configEntity),\n (err) => {\n if (err) {\n printError(err, `Error exporting config entity ${id}`);\n }\n }\n );\n return true;\n } catch (error) {\n printError(error, `Error exporting config entity ${id}`);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllRawConfigEntities() {\n try {\n const exportedConfigurations = await exportConfigEntities();\n for (const [id, value] of Object.entries(exportedConfigurations.config)) {\n if (value != null) {\n fse.outputFile(\n getFilePath(`${id}.json`, true),\n stringify(value),\n (err) => {\n if (err) {\n printError(err, `Error exporting raw config entity ${id}`);\n }\n }\n );\n }\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllConfigEntities(\n entitiesFile: string,\n envFile: string\n): Promise<boolean> {\n const errors: Error[] = [];\n try {\n let entriesToExport = [];\n // read list of entities to export\n const data = fs.readFileSync(entitiesFile, 'utf8');\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n const configurations = await readConfigEntities();\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(readConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n try {\n let configEntityString = stringify(item);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFileSync(\n getFilePath(`${item._id}.json`, true),\n configEntityString\n );\n } catch (error) {\n errors.push(\n new FrodoError(`Error saving config entity ${item._id}`, error)\n );\n }\n }\n }\n if (errors.length > 0) {\n throw new FrodoError(`Error saving config entities`, errors);\n }\n stopProgressIndicator(null, 'success');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param {string} entityId the configuration object to import\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n): Promise<boolean> {\n try {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n\n const entityData = JSON.parse(fileData);\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import IDM configuration object from file.\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n): Promise<boolean> {\n try {\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllRawConfigEntities(\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n) {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) => JSON.parse(content))\n .map((entity) => [entity._id, entity]);\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllConfigEntities(\n entitiesFile: string,\n envFile: string,\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n): Promise<boolean> {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const entriesToImport = JSON.parse(\n fs.readFileSync(entitiesFile, 'utf8')\n ).idm;\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) =>\n JSON.parse(unSubstituteEnvParams(content, envReader))\n )\n .filter((entity) => entriesToImport.includes(entity._id))\n .map((entity) => [entity._id, entity]);\n\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function countManagedObjects(type: string): Promise<boolean> {\n try {\n const result = await queryManagedObjects(type);\n printMessage(`${type}: ${result.length}`, 'data');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,QAAQ,uBAAuB;AAEzD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,uBAAuB,EACvBC,UAAU,EACVC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AAEzB,MAAM;EAAEC;AAAU,CAAC,GAAGX,KAAK,CAACY,KAAK,CAACC,IAAI;AAEtC,MAAM;EACJC,qBAAqB;EACrBC,mBAAmB;EACnBC,WAAW;EACXC,gBAAgB;EAChBC,SAAS;EACTC;AACF,CAAC,GAAGnB,KAAK,CAACY,KAAK;AACf,MAAM;EACJQ,kBAAkB;EAClBC,gBAAgB;EAChBC,oBAAoB;EACpBC,kBAAkB;EAClBC;AACF,CAAC,GAAGxB,KAAK,CAACyB,GAAG,CAACC,MAAM;AACpB,MAAM;EAAEC;AAAoB,CAAC,GAAG3B,KAAK,CAACyB,G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KAAK,CAACrD,qBAAqB,CAACoF,OAAO,EAAEM,SAAS,CAAC,CACtD,CAAC,CACAtE,MAAM,CAAEiE,MAAM,IAAKI,eAAe,CAAChC,QAAQ,CAAC4B,MAAM,CAACtD,GAAG,CAAC,CAAC,CACxDR,GAAG,CAAE8D,MAAM,IAAK,CAACA,MAAM,CAACtD,GAAG,EAAEsD,MAAM,CAAC,CAAC;IAExC,MAAMC,UAAU,GAAG;MACjB1E,MAAM,EAAE6B,MAAM,CAAC8C,WAAW,CAACN,WAAW;IACxC,CAAC;IAEDH,WAAW,GAAGrF,uBAAuB,CACnC,eAAe,EACf,CAAC,EACA,kCAAiCsF,aAAc,KAClD,CAAC;IAED,MAAMrE,oBAAoB,CAAC4E,UAAU,EAAET,OAAO,CAAC;IAC/CjF,qBAAqB,CACnBkF,WAAW,EACV,YAAWG,WAAW,CAACxD,MAAO,kBAAiB,EAChD,SACF,CAAC;IACD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd/B,qBAAqB,CACnBkF,WAAW,EACV,wCAAuCC,aAAc,GAAE,EACxD,MACF,CAAC;IACDrF,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAegE,mBAAmBA,CAACC,IAAY,EAAoB;EACxE,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMhF,mBAAmB,CAAC+E,IAAI,CAAC;IAC9CjG,YAAY,CAAE,GAAEiG,IAAK,KAAIC,MAAM,CAACpE,MAAO,EAAC,EAAE,MAAM,CAAC;IACjD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdjC,UAAU,CAACiC,KAAK,CAAC;EACnB;EACA,OAAO,KAAK;AACd"}
1
+ {"version":3,"file":"IdmOps.js","names":["frodo","FrodoError","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printError","printMessage","stopProgressIndicator","stringify","utils","json","unSubstituteEnvParams","areScriptHooksValid","getFilePath","getTypedFilename","readFiles","getWorkingDirectory","readConfigEntities","readConfigEntity","exportConfigEntities","updateConfigEntity","importConfigEntities","idm","config","queryManagedObjects","managed","testConnectorServers","system","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","listAllConfigEntities","configurations","configEntity","_id","exportConfigEntity","id","file","fileName","writeFile","err","exportAllRawConfigEntities","exportedConfigurations","value","Object","entries","outputFile","exportAllConfigEntities","entitiesFile","envFile","errors","entriesToExport","data","readFileSync","entriesData","JSON","parse","envParams","undefined","entityPromises","includes","push","results","Promise","item","configEntityString","each","key","outputFileSync","importConfigEntityByIdFromFile","entityId","validate","fileData","resolve","process","cwd","entityData","isValid","importConfigEntityFromFile","filePath","indicatorId","importAllRawConfigEntities","options","baseDirectory","files","jsonObjects","toLowerCase","endsWith","content","entity","importData","fromEntries","importAllConfigEntities","entriesToImport","envReader","countManagedObjects","type","result"],"sources":["../../src/ops/IdmOps.ts"],"sourcesContent":["import { frodo, FrodoError } from '@rockcarver/frodo-lib';\nimport { type ConfigEntityImportOptions } from '@rockcarver/frodo-lib/types/ops/IdmConfigOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport {\n createProgressIndicator,\n printError,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\n\nconst { stringify } = frodo.utils.json;\n\nconst {\n unSubstituteEnvParams,\n areScriptHooksValid,\n getFilePath,\n getTypedFilename,\n readFiles,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readConfigEntities,\n readConfigEntity,\n exportConfigEntities,\n updateConfigEntity,\n importConfigEntities,\n} = frodo.idm.config;\nconst { queryManagedObjects } = frodo.idm.managed;\nconst { testConnectorServers } = frodo.idm.system;\n\n/**\n * Warn about and list offline remote connector servers\n * @return {Promise<boolean>} a promise that resolves to true if a warning was printed, false otherwise\n */\nexport async function warnAboutOfflineConnectorServers(): Promise<boolean> {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length > 0) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n return true;\n }\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * List all IDM configuration objects\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function listAllConfigEntities(): Promise<boolean> {\n try {\n const configurations = await readConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export an IDM configuration object.\n * @param {string} id the desired configuration object\n * @param {string} file optional export file\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportConfigEntity(\n id: string,\n file: string\n): Promise<boolean> {\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await readConfigEntity(id);\n fs.writeFile(\n getFilePath(fileName, true),\n stringify(configEntity),\n (err) => {\n if (err) {\n printError(err, `Error exporting config entity ${id}`);\n }\n }\n );\n return true;\n } catch (error) {\n printError(error, `Error exporting config entity ${id}`);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllRawConfigEntities() {\n try {\n const exportedConfigurations = await exportConfigEntities();\n for (const [id, value] of Object.entries(exportedConfigurations.config)) {\n if (value != null) {\n fse.outputFile(\n getFilePath(`${id}.json`, true),\n stringify(value),\n (err) => {\n if (err) {\n printError(err, `Error exporting raw config entity ${id}`);\n }\n }\n );\n }\n }\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Export all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function exportAllConfigEntities(\n entitiesFile: string,\n envFile: string\n): Promise<boolean> {\n const errors: Error[] = [];\n try {\n let entriesToExport = [];\n // read list of entities to export\n const data = fs.readFileSync(entitiesFile, 'utf8');\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n const configurations = await readConfigEntities();\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(readConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n try {\n let configEntityString = stringify(item);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFileSync(\n getFilePath(`${item._id}.json`, true),\n configEntityString\n );\n } catch (error) {\n errors.push(\n new FrodoError(`Error saving config entity ${item._id}`, error)\n );\n }\n }\n }\n if (errors.length > 0) {\n throw new FrodoError(`Error saving config entities`, errors);\n }\n stopProgressIndicator(null, 'success');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param {string} entityId the configuration object to import\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n): Promise<boolean> {\n try {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n\n const entityData = JSON.parse(fileData);\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n\n/**\n * Import IDM configuration object from file.\n * @param {string} file optional file to import\n * @param {boolean} validate validate script hooks\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n): Promise<boolean> {\n const filePath = getFilePath(file);\n let indicatorId: string;\n try {\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${filePath}...`\n );\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), filePath),\n 'utf8'\n );\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n await updateConfigEntity(entityId, entityData);\n stopProgressIndicator(\n indicatorId,\n `Imported ${entityId} from ${filePath}.`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error importing ${filePath}.`, 'fail');\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllRawConfigEntities(\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n) {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) => JSON.parse(content))\n .map((entity) => [entity._id, entity]);\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Import all IDM configuration objects\n * @param {string} entitiesFile JSON file that specifies the config entities to export/import\n * @param {string} envFile File that defines environment specific variables for replacement during configuration export/import\n * @param {ConfigEntityImportOptions} options import options\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function importAllConfigEntities(\n entitiesFile: string,\n envFile: string,\n options: ConfigEntityImportOptions = {\n validate: false,\n }\n): Promise<boolean> {\n let indicatorId: string;\n const baseDirectory = getWorkingDirectory();\n try {\n const entriesToImport = JSON.parse(\n fs.readFileSync(entitiesFile, 'utf8')\n ).idm;\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonObjects = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content }) =>\n JSON.parse(unSubstituteEnvParams(content, envReader))\n )\n .filter((entity) => entriesToImport.includes(entity._id))\n .map((entity) => [entity._id, entity]);\n\n const importData = {\n config: Object.fromEntries(jsonObjects),\n };\n\n indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing config entities from ${baseDirectory}...`\n );\n\n await importConfigEntities(importData, options);\n stopProgressIndicator(\n indicatorId,\n `Imported ${jsonObjects.length} config entities`,\n 'success'\n );\n return true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing config entities from ${baseDirectory}.`,\n 'fail'\n );\n printError(error);\n }\n return false;\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n * @return {Promise<boolean>} a promise that resolves to true if successful, false otherwise\n */\nexport async function countManagedObjects(type: string): Promise<boolean> {\n try {\n const result = await queryManagedObjects(type);\n printMessage(`${type}: ${result.length}`, 'data');\n return true;\n } catch (error) {\n printError(error);\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,UAAU,QAAQ,uBAAuB;AAEzD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;A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