@rockcarver/frodo-cli 0.24.6-1 → 0.24.6-2

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,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.24.6-2] - 2023-06-22
11
+
10
12
  ## [0.24.6-1] - 2023-06-22
11
13
 
12
14
  ### Added
@@ -1234,7 +1236,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1234
1236
  - Fixed problem with adding connection profiles
1235
1237
  - Miscellaneous bug fixes
1236
1238
 
1237
- [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-1...HEAD
1239
+ [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-2...HEAD
1240
+
1241
+ [0.24.6-2]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-1...v0.24.6-2
1238
1242
 
1239
1243
  [0.24.6-1]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-0...v0.24.6-1
1240
1244
 
@@ -15,17 +15,20 @@ async (host, user, password, options, command) => {
15
15
  // export by id/name
16
16
  if (options.idpId) {
17
17
  verboseMessage(`Exporting provider "${options.idpId}...`);
18
- exportAdminFederationProviderToFile(options.idpId, options.file);
18
+ const outcome = await exportAdminFederationProviderToFile(options.idpId, options.file);
19
+ if (!outcome) process.exitCode = 1;
19
20
  }
20
21
  // --all -a
21
22
  else if (options.all) {
22
23
  verboseMessage('Exporting all providers to a single file...');
23
- exportAdminFederationProvidersToFile(options.file);
24
+ const outcome = await exportAdminFederationProvidersToFile(options.file);
25
+ if (!outcome) process.exitCode = 1;
24
26
  }
25
27
  // --all-separate -A
26
28
  else if (options.allSeparate) {
27
29
  verboseMessage('Exporting all providers to separate files...');
28
- exportAdminFederationProvidersToFiles();
30
+ const outcome = await exportAdminFederationProvidersToFiles();
31
+ if (!outcome) process.exitCode = 1;
29
32
  }
30
33
  // unrecognized combination of options or no options
31
34
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"admin-federation-export.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","exportAdminFederationProviderToFile","exportAdminFederationProvidersToFile","exportAdminFederationProvidersToFiles","getTokens","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","idpId","file","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/admin/admin-federation-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n exportAdminFederationProviderToFile,\n exportAdminFederationProvidersToFile,\n exportAdminFederationProvidersToFiles,\n} from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation export', ['realm']);\n\nprogram\n .description('Export admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <idp-id>',\n 'Id/name of a provider. 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.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the providers 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 as separate files <provider name>.admin.federation.json. Ignored with -t, -i, and -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await getTokens(true)) {\n // export by id/name\n if (options.idpId) {\n verboseMessage(`Exporting provider \"${options.idpId}...`);\n exportAdminFederationProviderToFile(options.idpId, options.file);\n }\n // --all -a\n else if (options.all) {\n verboseMessage('Exporting all providers to a single file...');\n exportAdminFederationProvidersToFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate) {\n verboseMessage('Exporting all providers to separate files...');\n exportAdminFederationProvidersToFiles();\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 }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,mCAAmC,EACnCC,oCAAoC,EACpCC,qCAAqC,QAChC,8BAA8B;AAErC,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5ES,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIV,MAAM,CACR,uBAAuB,EACvB,6DACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,mBAAmB,EACnB,yEACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,oEACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,gHACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAI,MAAMT,SAAS,CAAC,IAAI,CAAC,EAAE;IACzB;IACA,IAAIQ,OAAO,CAACG,KAAK,EAAE;MACjBf,cAAc,CAAE,uBAAsBY,OAAO,CAACG,KAAM,KAAI,CAAC;MACzDd,mCAAmC,CAACW,OAAO,CAACG,KAAK,EAAEH,OAAO,CAACI,IAAI,CAAC;IAClE;IACA;IAAA,KACK,IAAIJ,OAAO,CAACK,GAAG,EAAE;MACpBjB,cAAc,CAAC,6CAA6C,CAAC;MAC7DE,oCAAoC,CAACU,OAAO,CAACI,IAAI,CAAC;IACpD;IACA;IAAA,KACK,IAAIJ,OAAO,CAACM,WAAW,EAAE;MAC5BlB,cAAc,CAAC,8CAA8C,CAAC;MAC9DG,qCAAqC,CAAC,CAAC;IACzC;IACA;IAAA,KACK;MACHJ,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;MACDM,OAAO,CAACc,IAAI,CAAC,CAAC;MACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF;AACF;AACA;AACF,CAAC;;AAEHhB,OAAO,CAACiB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"admin-federation-export.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","exportAdminFederationProviderToFile","exportAdminFederationProvidersToFile","exportAdminFederationProvidersToFiles","getTokens","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","idpId","outcome","file","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/admin/admin-federation-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n exportAdminFederationProviderToFile,\n exportAdminFederationProvidersToFile,\n exportAdminFederationProvidersToFiles,\n} from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation export', ['realm']);\n\nprogram\n .description('Export admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <idp-id>',\n 'Id/name of a provider. 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.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the providers 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 as separate files <provider name>.admin.federation.json. Ignored with -t, -i, and -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await getTokens(true)) {\n // export by id/name\n if (options.idpId) {\n verboseMessage(`Exporting provider \"${options.idpId}...`);\n const outcome = await exportAdminFederationProviderToFile(\n options.idpId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all) {\n verboseMessage('Exporting all providers to a single file...');\n const outcome = await exportAdminFederationProvidersToFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate) {\n verboseMessage('Exporting all providers to separate files...');\n const outcome = await exportAdminFederationProvidersToFiles();\n if (!outcome) process.exitCode = 1;\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 }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,mCAAmC,EACnCC,oCAAoC,EACpCC,qCAAqC,QAChC,8BAA8B;AAErC,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5ES,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIV,MAAM,CACR,uBAAuB,EACvB,6DACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,mBAAmB,EACnB,yEACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR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AC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
- import { Authenticate, state } from '@rockcarver/frodo-lib';
3
+ import { Authenticate } from '@rockcarver/frodo-lib';
4
4
  import { printMessage, verboseMessage } from '../../utils/Console';
5
5
  import { importAdminFederationProviderFromFile, importAdminFederationProvidersFromFile, importAdminFederationProvidersFromFiles, importFirstAdminFederationProviderFromFile } from '../../ops/AdminFederationOps';
6
6
  const {
@@ -13,23 +13,27 @@ async (host, user, password, options, command) => {
13
13
  command.handleDefaultArgsAndOpts(host, user, password, options, command);
14
14
  // import by id
15
15
  if (options.file && options.idpId && (await getTokens(true))) {
16
- verboseMessage(`Importing provider "${options.idpId}" into realm "${state.getRealm()}"...`);
17
- importAdminFederationProviderFromFile(options.idpId, options.file);
16
+ verboseMessage(`Importing provider "${options.idpId}"...`);
17
+ const outcome = await importAdminFederationProviderFromFile(options.idpId, options.file);
18
+ if (!outcome) process.exitCode = 1;
18
19
  }
19
20
  // --all -a
20
21
  else if (options.all && options.file && (await getTokens(true))) {
21
22
  verboseMessage(`Importing all providers from a single file (${options.file})...`);
22
- importAdminFederationProvidersFromFile(options.file);
23
+ const outcome = await importAdminFederationProvidersFromFile(options.file);
24
+ if (!outcome) process.exitCode = 1;
23
25
  }
24
26
  // --all-separate -A
25
27
  else if (options.allSeparate && !options.file && (await getTokens(true))) {
26
28
  verboseMessage('Importing all providers from separate files in current directory...');
27
- importAdminFederationProvidersFromFiles();
29
+ const outcome = await importAdminFederationProvidersFromFiles();
30
+ if (!outcome) process.exitCode = 1;
28
31
  }
29
32
  // import first provider from file
30
33
  else if (options.file && (await getTokens(true))) {
31
- verboseMessage(`Importing first provider from file "${options.file}" into realm "${state.getRealm()}"...`);
32
- importFirstAdminFederationProviderFromFile(options.file);
34
+ verboseMessage(`Importing first provider from file "${options.file}"...`);
35
+ const outcome = await importFirstAdminFederationProviderFromFile(options.file);
36
+ if (!outcome) process.exitCode = 1;
33
37
  }
34
38
  // unrecognized combination of options or no options
35
39
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"admin-federation-import.js","names":["FrodoCommand","Option","Authenticate","state","printMessage","verboseMessage","importAdminFederationProviderFromFile","importAdminFederationProvidersFromFile","importAdminFederationProvidersFromFiles","importFirstAdminFederationProviderFromFile","getTokens","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","file","idpId","getRealm","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/admin/admin-federation-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n importAdminFederationProviderFromFile,\n importAdminFederationProvidersFromFile,\n importAdminFederationProvidersFromFiles,\n importFirstAdminFederationProviderFromFile,\n} from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation import', ['realm']);\n\nprogram\n .description('Import admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <id>',\n 'Provider 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 import the provider(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the providers from single file. Ignored with -t or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the providers from separate files (*.admin.federation.json) in the current directory. Ignored with -t or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n // import by id\n if (options.file && options.idpId && (await getTokens(true))) {\n verboseMessage(\n `Importing provider \"${\n options.idpId\n }\" into realm \"${state.getRealm()}\"...`\n );\n importAdminFederationProviderFromFile(options.idpId, options.file);\n }\n // --all -a\n else if (options.all && options.file && (await getTokens(true))) {\n verboseMessage(\n `Importing all providers from a single file (${options.file})...`\n );\n importAdminFederationProvidersFromFile(options.file);\n }\n // --all-separate -A\n else if (\n options.allSeparate &&\n !options.file &&\n (await getTokens(true))\n ) {\n verboseMessage(\n 'Importing all providers from separate files in current directory...'\n );\n importAdminFederationProvidersFromFiles();\n }\n // import first provider from file\n else if (options.file && (await getTokens(true))) {\n verboseMessage(\n `Importing first provider from file \"${\n options.file\n }\" into realm \"${state.getRealm()}\"...`\n );\n importFirstAdminFederationProviderFromFile(options.file);\n }\n // unrecognized combination of options or no options\n else {\n printMessage('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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,qCAAqC,EACrCC,sCAAsC,EACtCC,uCAAuC,EACvCC,0CAA0C,QACrC,8BAA8B;AAErC,MAAM;EAAEC;AAAU,CAAC,GAAGR,YAAY;AAElC,MAAMS,OAAO,GAAG,IAAIX,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5EW,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIZ,MAAM,CACR,mBAAmB,EACnB,mDACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,mBAAmB,EACnB,kDACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,WAAW,EACX,mEACF,CACF,CAAC,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,oBAAoB,EACpB,+HACF,CACF,CAAC,CACAa,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE;EACA,IAAID,OAAO,CAACG,IAAI,IAAIH,OAAO,CAACI,KAAK,KAAK,MAAMZ,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE;IAC5DL,cAAc,CACX,uBACCa,OAAO,CAACI,KACT,iBAAgBnB,KAAK,CAACoB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACDjB,qCAAqC,CAACY,OAAO,CAACI,KAAK,EAAEJ,OAAO,CAACG,IAAI,CAAC;EACpE;EACA;EAAA,KACK,IAAIH,OAAO,CAACM,GAAG,IAAIN,OAAO,CAACG,IAAI,KAAK,MAAMX,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE;IAC/DL,cAAc,CACX,+CAA8Ca,OAAO,CAACG,IAAK,MAC9D,CAAC;IACDd,sCAAsC,CAACW,OAAO,CAACG,IAAI,CAAC;EACtD;EACA;EAAA,KACK,IACHH,OAAO,CAACO,WAAW,IACnB,CAACP,OAAO,CAACG,IAAI,KACZ,MAAMX,SAAS,CAAC,IAAI,CAAC,CAAC,EACvB;IACAL,cAAc,CACZ,qEACF,CAAC;IACDG,uCAAuC,CAAC,CAAC;EAC3C;EACA;EAAA,KACK,IAAIU,OAAO,CAACG,IAAI,KAAK,MAAMX,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE;IAChDL,cAAc,CACX,uCACCa,OAAO,CAACG,IACT,iBAAgBlB,KAAK,CAACoB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACDd,0CAA0C,CAACS,OAAO,CAACG,IAAI,CAAC;EAC1D;EACA;EAAA,KACK;IACHjB,YAAY,CAAC,sDAAsD,CAAC;IACpEO,OAAO,CAACe,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHjB,OAAO,CAACkB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"admin-federation-import.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","importAdminFederationProviderFromFile","importAdminFederationProvidersFromFile","importAdminFederationProvidersFromFiles","importFirstAdminFederationProviderFromFile","getTokens","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","file","idpId","outcome","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/admin/admin-federation-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n importAdminFederationProviderFromFile,\n importAdminFederationProvidersFromFile,\n importAdminFederationProvidersFromFiles,\n importFirstAdminFederationProviderFromFile,\n} from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation import', ['realm']);\n\nprogram\n .description('Import admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <id>',\n 'Provider 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 import the provider(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the providers from single file. Ignored with -t or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the providers from separate files (*.admin.federation.json) in the current directory. Ignored with -t or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n // import by id\n if (options.file && options.idpId && (await getTokens(true))) {\n verboseMessage(`Importing provider \"${options.idpId}\"...`);\n const outcome = await importAdminFederationProviderFromFile(\n options.idpId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && options.file && (await getTokens(true))) {\n verboseMessage(\n `Importing all providers from a single file (${options.file})...`\n );\n const outcome = await importAdminFederationProvidersFromFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (\n options.allSeparate &&\n !options.file &&\n (await getTokens(true))\n ) {\n verboseMessage(\n 'Importing all providers from separate files in current directory...'\n );\n const outcome = await importAdminFederationProvidersFromFiles();\n if (!outcome) process.exitCode = 1;\n }\n // import first provider from file\n else if (options.file && (await getTokens(true))) {\n verboseMessage(\n `Importing first provider from file \"${options.file}\"...`\n );\n const outcome = await importFirstAdminFederationProviderFromFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage('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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,qCAAqC,EACrCC,sCAAsC,EACtCC,uCAAuC,EACvCC,0CAA0C,QACrC,8BAA8B;AAErC,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIV,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5EU,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIX,MAAM,CACR,mBAAmB,EACnB,mDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,mBAAmB,EACnB,kDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,mEACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,+HACF,CACF,CAAC,CACAY,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,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IACHrB,YAAY,CAAC,sDAAsD,CAAC;IACpEO,OAAO,CAACiB,IAAI,CAAC,CAAC;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHd,OAAO,CAACkB,KAAK,CAAC,CAAC"}
@@ -16,7 +16,8 @@ async (host, user, password, options, command) => {
16
16
  command.handleDefaultArgsAndOpts(host, user, password, options, command);
17
17
  if (await getTokens(true)) {
18
18
  verboseMessage(`Listing admin federation providers...`);
19
- listAdminFederationProviders();
19
+ const outcome = await listAdminFederationProviders();
20
+ if (!outcome) process.exitCode = 1;
20
21
  } else {
21
22
  process.exitCode = 1;
22
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"admin-federation-list.js","names":["FrodoCommand","Authenticate","verboseMessage","listAdminFederationProviders","getTokens","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","process","exitCode","parse"],"sources":["cli/admin/admin-federation-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport { listAdminFederationProviders } from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation list', ['realm']);\n\nprogram\n .description('List admin federation providers.')\n // .addOption(\n // new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n // )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await getTokens(true)) {\n verboseMessage(`Listing admin federation providers...`);\n listAdminFederationProviders();\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,4BAA4B,QAAQ,8BAA8B;AAE3E,MAAM;EAAEC;AAAU,CAAC,GAAGH,YAAY;AAElC,MAAMI,OAAO,GAAG,IAAIL,YAAY,CAAC,6BAA6B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE1EK,OAAO,CACJC,WAAW,CAAC,kCAAkC;AAC/C;AACA;AACA;AAAA,CACCC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAI,MAAMR,SAAS,CAAC,IAAI,CAAC,EAAE;IACzBF,cAAc,CAAE,uCAAsC,CAAC;IACvDC,4BAA4B,CAAC,CAAC;EAChC,CAAC,MAAM;IACLW,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHV,OAAO,CAACW,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"admin-federation-list.js","names":["FrodoCommand","Authenticate","verboseMessage","listAdminFederationProviders","getTokens","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","outcome","process","exitCode","parse"],"sources":["cli/admin/admin-federation-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport { listAdminFederationProviders } from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation list', ['realm']);\n\nprogram\n .description('List admin federation providers.')\n // .addOption(\n // new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n // )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await getTokens(true)) {\n verboseMessage(`Listing admin federation providers...`);\n const outcome = await listAdminFederationProviders();\n if (!outcome) process.exitCode = 1;\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,4BAA4B,QAAQ,8BAA8B;AAE3E,MAAM;EAAEC;AAAU,CAAC,GAAGH,YAAY;AAElC,MAAMI,OAAO,GAAG,IAAIL,YAAY,CAAC,6BAA6B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE1EK,OAAO,CACJC,WAAW,CAAC,kCAAkC;AAC/C;AACA;AACA;AAAA,CACCC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAI,MAAMR,SAAS,CAAC,IAAI,CAAC,EAAE;IACzBF,cAAc,CAAE,uCAAsC,CAAC;IACvD,MAAMY,OAAO,GAAG,MAAMX,4BAA4B,CAAC,CAAC;IACpD,IAAI,CAACW,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHX,OAAO,CAACY,KAAK,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import { AdminFederation } from '@rockcarver/frodo-lib';
3
- import { createProgressBar, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
3
+ import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
4
  import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
5
5
  const {
6
6
  getAdminFederationProviders,
@@ -13,26 +13,32 @@ const {
13
13
 
14
14
  /**
15
15
  * List providers
16
+ * @returns {Promise<boolean>} true if successful, false otherwise
16
17
  */
17
18
  export async function listAdminFederationProviders() {
19
+ let outcome = false;
18
20
  try {
19
21
  const providers = await getAdminFederationProviders();
20
22
  providers.sort((a, b) => a._id.localeCompare(b._id));
21
23
  providers.forEach(socialIdentityProvider => {
22
24
  printMessage(`${socialIdentityProvider._id}`, 'data');
23
25
  });
26
+ outcome = true;
24
27
  } catch (err) {
25
28
  printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');
26
29
  printMessage(err, 'error');
27
30
  }
31
+ return outcome;
28
32
  }
29
33
 
30
34
  /**
31
35
  * Export provider by id
32
36
  * @param {string} providerId provider id/name
33
37
  * @param {string} file optional export file name
38
+ * @returns {Promise<boolean>} true if successful, false otherwise
34
39
  */
35
40
  export async function exportAdminFederationProviderToFile(providerId, file = '') {
41
+ let outcome = false;
36
42
  let fileName = file;
37
43
  if (!fileName) {
38
44
  fileName = getTypedFilename(providerId, 'admin.federation');
@@ -43,130 +49,168 @@ export async function exportAdminFederationProviderToFile(providerId, file = '')
43
49
  const fileData = await exportAdminFederationProvider(providerId);
44
50
  saveJsonToFile(fileData, fileName);
45
51
  stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
52
+ outcome = true;
46
53
  } catch (err) {
47
54
  stopProgressBar(`${err}`);
48
55
  printMessage(`${err}`, 'error');
49
56
  }
57
+ return outcome;
50
58
  }
51
59
 
52
60
  /**
53
61
  * Export all providers
54
62
  * @param {string} file optional export file name
63
+ * @returns {Promise<boolean>} true if successful, false otherwise
55
64
  */
56
65
  export async function exportAdminFederationProvidersToFile(file = '') {
57
- let fileName = file;
58
- if (!fileName) {
59
- fileName = getTypedFilename(`allProviders`, 'admin.federation');
66
+ let outcome = false;
67
+ showSpinner(`Exporting all providers...`);
68
+ try {
69
+ let fileName = file;
70
+ if (!fileName) {
71
+ fileName = getTypedFilename(`allProviders`, 'admin.federation');
72
+ }
73
+ const fileData = await exportAdminFederationProviders();
74
+ saveJsonToFile(fileData, fileName);
75
+ succeedSpinner(`Exported all providers to ${fileName}`);
76
+ outcome = true;
77
+ } catch (error) {
78
+ var _error$response;
79
+ failSpinner(`Error exporting all providers.`);
80
+ printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
60
81
  }
61
- const fileData = await exportAdminFederationProviders();
62
- saveJsonToFile(fileData, fileName);
82
+ return outcome;
63
83
  }
64
84
 
65
85
  /**
66
86
  * Export all providers to individual files
87
+ * @returns {Promise<boolean>} true if successful, false otherwise
67
88
  */
68
89
  export async function exportAdminFederationProvidersToFiles() {
69
- const allIdpsData = await getAdminFederationProviders();
70
- // printMessage(allIdpsData, 'data');
71
- createProgressBar(allIdpsData.length, 'Exporting providers');
72
- for (const idpData of allIdpsData) {
73
- updateProgressBar(`Writing provider ${idpData._id}`);
74
- const fileName = getTypedFilename(idpData._id, 'admin.federation');
75
- const fileData = await exportAdminFederationProvider(idpData._id);
76
- saveJsonToFile(fileData, fileName);
90
+ let outcome = false;
91
+ try {
92
+ const allIdpsData = await getAdminFederationProviders();
93
+ createProgressBar(allIdpsData.length, 'Exporting providers');
94
+ for (const idpData of allIdpsData) {
95
+ updateProgressBar(`Writing provider ${idpData._id}`);
96
+ const fileName = getTypedFilename(idpData._id, 'admin.federation');
97
+ const fileData = await exportAdminFederationProvider(idpData._id);
98
+ saveJsonToFile(fileData, fileName);
99
+ }
100
+ stopProgressBar(`${allIdpsData.length} providers exported.`);
101
+ outcome = true;
102
+ } catch (error) {
103
+ var _error$response2;
104
+ failSpinner(`Error exporting all providers.`);
105
+ printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
77
106
  }
78
- stopProgressBar(`${allIdpsData.length} providers exported.`);
107
+ return outcome;
79
108
  }
80
109
 
81
110
  /**
82
111
  * Import provider by id/name
83
112
  * @param {string} providerId provider id/name
84
113
  * @param {string} file import file name
85
- * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise
114
+ * @returns {Promise<boolean>} true if successful, false otherwise
86
115
  */
87
116
  export async function importAdminFederationProviderFromFile(providerId, file) {
88
117
  let outcome = false;
89
118
  showSpinner(`Importing provider ${providerId} from ${file}...`);
90
- fs.readFile(file, 'utf8', async (err, data) => {
91
- if (err) throw err;
92
- try {
93
- const fileData = JSON.parse(data);
94
- await importAdminFederationProvider(providerId, fileData);
95
- succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
96
- outcome = true;
97
- } catch (error) {
98
- var _error$response;
99
- failSpinner(`Error importing provider ${providerId} from ${file}.`);
100
- printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
101
- }
102
- });
119
+ try {
120
+ const data = fs.readFileSync(file, 'utf8');
121
+ const fileData = JSON.parse(data);
122
+ await importAdminFederationProvider(providerId, fileData);
123
+ succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
124
+ outcome = true;
125
+ } catch (error) {
126
+ var _error$response3;
127
+ failSpinner(`Error importing provider ${providerId} from ${file}.`);
128
+ printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
129
+ }
103
130
  return outcome;
104
131
  }
105
132
 
106
133
  /**
107
134
  * Import first provider from file
108
135
  * @param {String} file import file name
109
- * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise
136
+ * @returns {Promise<boolean>} true if successful, false otherwise
110
137
  */
111
138
  export async function importFirstAdminFederationProviderFromFile(file) {
112
139
  let outcome = false;
140
+ debugMessage(`cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`);
113
141
  showSpinner(`Importing first provider from ${file}...`);
114
- fs.readFile(file, 'utf8', async (err, data) => {
115
- if (err) throw err;
116
- try {
117
- const fileData = JSON.parse(data);
118
- await importFirstAdminFederationProvider(fileData);
119
- succeedSpinner(`Successfully imported first provider from ${file}.`);
120
- outcome = true;
121
- } catch (error) {
122
- var _error$response2;
123
- failSpinner(`Error importing first provider from ${file}.`);
124
- printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
125
- }
126
- });
142
+ try {
143
+ const data = fs.readFileSync(file, 'utf8');
144
+ const fileData = JSON.parse(data);
145
+ await importFirstAdminFederationProvider(fileData);
146
+ succeedSpinner(`Successfully imported first provider from ${file}.`);
147
+ outcome = true;
148
+ } catch (error) {
149
+ var _error$response4;
150
+ failSpinner(`Error importing first provider from ${file}.`);
151
+ printMessage(((_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.data) || error, 'error');
152
+ }
153
+ debugMessage(`cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`);
127
154
  return outcome;
128
155
  }
129
156
 
130
157
  /**
131
158
  * Import all providers from file
132
159
  * @param {string} file import file name
133
- * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise
160
+ * @returns {Promise<boolean>} true if successful, false otherwise
134
161
  */
135
162
  export async function importAdminFederationProvidersFromFile(file) {
136
163
  let outcome = false;
164
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`);
137
165
  showSpinner(`Importing providers from ${file}...`);
138
- fs.readFile(file, 'utf8', async (err, data) => {
139
- if (err) throw err;
140
- try {
141
- const fileData = JSON.parse(data);
142
- await importAdminFederationProviders(fileData);
143
- succeedSpinner(`Successfully imported providers from ${file}.`);
144
- outcome = true;
145
- } catch (error) {
146
- var _error$response3;
147
- failSpinner(`Error importing providers from ${file}.`);
148
- printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
149
- }
150
- });
166
+ try {
167
+ const data = fs.readFileSync(file, 'utf8');
168
+ const fileData = JSON.parse(data);
169
+ await importAdminFederationProviders(fileData);
170
+ succeedSpinner(`Imported providers from ${file}.`);
171
+ outcome = true;
172
+ } catch (error) {
173
+ var _error$response5;
174
+ failSpinner(`Error importing ${file}.`);
175
+ printMessage(((_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : _error$response5.data) || error, 'error');
176
+ }
177
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`);
151
178
  return outcome;
152
179
  }
153
180
 
154
181
  /**
155
182
  * Import providers from *.idp.json files in current working directory
183
+ * @returns {Promise<boolean>} true if successful, false otherwise
156
184
  */
157
185
  export async function importAdminFederationProvidersFromFiles() {
158
- const names = fs.readdirSync('.');
159
- const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.admin.federation.json'));
160
- createProgressBar(jsonFiles.length, 'Importing providers...');
161
- let total = 0;
162
- for (const file of jsonFiles) {
163
- const data = fs.readFileSync(file, 'utf8');
164
- const fileData = JSON.parse(data);
165
- const count = Object.keys(fileData.idp).length;
166
- total += count;
167
- await importAdminFederationProviders(fileData);
168
- updateProgressBar(`Imported ${count} provider(s) from ${file}`);
186
+ const errors = [];
187
+ try {
188
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`);
189
+ const names = fs.readdirSync('.');
190
+ const files = names.filter(name => name.toLowerCase().endsWith('.admin.federation.json'));
191
+ createProgressBar(files.length, 'Importing providers...');
192
+ let total = 0;
193
+ for (const file of files) {
194
+ try {
195
+ const data = fs.readFileSync(file, 'utf8');
196
+ const fileData = JSON.parse(data);
197
+ const count = Object.keys(fileData.idp).length;
198
+ total += count;
199
+ await importAdminFederationProviders(fileData);
200
+ updateProgressBar(`Imported ${count} provider(s) from ${file}`);
201
+ } catch (error) {
202
+ errors.push(error);
203
+ updateProgressBar(`Error importing provider(s) from ${file}`);
204
+ printMessage(error, 'error');
205
+ }
206
+ }
207
+ stopProgressBar(`Finished importing ${total} provider(s) from ${files.length} file(s).`);
208
+ } catch (error) {
209
+ errors.push(error);
210
+ stopProgressBar(`Error importing provider(s) from file(s).`);
211
+ printMessage(error, 'error');
169
212
  }
170
- stopProgressBar(`Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);
213
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`);
214
+ return 0 === errors.length;
171
215
  }
172
216
  //# sourceMappingURL=AdminFederationOps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdminFederationOps.js","names":["fs","AdminFederation","createProgressBar","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","getAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importFirstAdminFederationProvider","importAdminFederationProviders","listAdminFederationProviders","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","fileData","exportAdminFederationProvidersToFile","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","importAdminFederationProviderFromFile","outcome","readFile","data","JSON","parse","error","_error$response","response","importFirstAdminFederationProviderFromFile","_error$response2","importAdminFederationProvidersFromFile","_error$response3","importAdminFederationProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/AdminFederationOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { AdminFederation } from '@rockcarver/frodo-lib';\nimport {\n createProgressBar,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst {\n getAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importFirstAdminFederationProvider,\n importAdminFederationProviders,\n} = AdminFederation;\n\n/**\n * List providers\n */\nexport async function listAdminFederationProviders() {\n try {\n const providers = await getAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportAdminFederationProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportAdminFederationProvidersToFiles() {\n const allIdpsData = await getAdminFederationProviders();\n // printMessage(allIdpsData, 'data');\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importAdminFederationProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importFirstAdminFederationProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importAdminFederationProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.admin.federation.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importAdminFederationProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings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AO,eAAeY,uCAAuCA,CAAA,EAAG;EAC9D,MAAMC,KAAK,GAAGpD,EAAE,CAACqD,WAAW,CAAC,GAAG,CAAC;EACjC,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAEC,IAAI,IAClCA,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,wBAAwB,CACtD,CAAC;EAEDxD,iBAAiB,CAACoD,SAAS,CAAClB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,MAAM7B,IAAI,IAAIwB,SAAS,EAAE;IAC5B,MAAMb,IAAI,GAAGzC,EAAE,CAAC4D,YAAY,CAAC9B,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGU,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMoB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAC/B,QAAQ,CAACgC,GAAG,CAAC,CAAC5B,MAAM;IAC9CuB,KAAK,IAAIE,KAAK;IACd,MAAM7C,8BAA8B,CAACgB,QAAQ,CAAC;IAC9CxB,iBAAiB,CAAE,YAAWqD,KAAM,qBAAoB/B,IAAK,EAAC,CAAC;EACjE;EACAxB,eAAe,CACZ,sBAAqBqD,KAAM,qBAAoBL,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
1
+ {"version":3,"file":"AdminFederationOps.js","names":["fs","AdminFederation","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","getAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importFirstAdminFederationProvider","importAdminFederationProviders","listAdminFederationProviders","outcome","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","fileData","exportAdminFederationProvidersToFile","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","_error$response3","importFirstAdminFederationProviderFromFile","_error$response4","importAdminFederationProvidersFromFile","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","idp","push"],"sources":["ops/AdminFederationOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { AdminFederation } from '@rockcarver/frodo-lib';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst {\n getAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importFirstAdminFederationProvider,\n importAdminFederationProviders,\n} = AdminFederation;\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await getAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = ''\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Exporting all providers...`);\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, fileName);\n succeedSpinner(`Exported all providers to ${fileName}`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(): Promise<boolean> {\n let outcome = false;\n try {\n const allIdpsData = await getAdminFederationProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n showSpinner(`Importing first provider from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstAdminFederationProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n showSpinner(`Importing providers from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n succeedSpinner(`Imported providers from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.admin.federation.json')\n );\n createProgressBar(files.length, 'Importing providers...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importAdminFederationProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing provider(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing provider(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7E,MAAM;EACJC,2BAA2B;EAC3BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,kCAAkC;EAClCC;AACF,CAAC,GAAGhB,eAAe;;AAEnB;AACA;AACA;AACA;AACA,OAAO,eAAeiB,4BAA4BA,CAAA,EAAqB;EACrE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMR,2BAA2B,CAAC,CAAC;IACrDQ,SAAS,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACpDJ,SAAS,CAACM,OAAO,CAAEC,sBAAsB,IAAK;MAC5CtB,YAAY,CAAE,GAAEsB,sBAAsB,CAACH,GAAI,EAAC,EAAE,MAAM,CAAC;IACvD,C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CAAC;IAClB7B,eAAe,CAAE,2CAA0C,CAAC;IAC5DF,YAAY,CAAC+B,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAjC,YAAY,CACT,qEACH,CAAC;EACD,OAAO,CAAC,KAAKoD,MAAM,CAACb,MAAM;AAC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockcarver/frodo-cli",
3
- "version": "0.24.6-1",
3
+ "version": "0.24.6-2",
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": [