@rockcarver/frodo-cli 0.19.1 → 0.19.3-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/esm/cli/idp/idp-export.js +2 -6
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +2 -7
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +2 -4
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/ops/IdpOps.js +169 -0
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +20 -2
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.19.3-0] - 2022-12-31
|
|
11
|
+
|
|
12
|
+
## [0.19.2] - 2022-12-30
|
|
13
|
+
|
|
10
14
|
## [0.19.1] - 2022-12-20
|
|
11
15
|
|
|
12
16
|
### Fixed
|
|
@@ -829,7 +833,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
829
833
|
- Fixed problem with adding connection profiles
|
|
830
834
|
- Miscellaneous bug fixes
|
|
831
835
|
|
|
832
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.19.
|
|
836
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.19.3-0...HEAD
|
|
837
|
+
|
|
838
|
+
[0.19.3-0]: https://github.com/rockcarver/frodo-cli/compare/v0.19.2...v0.19.3-0
|
|
839
|
+
|
|
840
|
+
[0.19.2]: https://github.com/rockcarver/frodo-cli/compare/v0.19.1...v0.19.2
|
|
833
841
|
|
|
834
842
|
[0.19.1]: https://github.com/rockcarver/frodo-cli/compare/v0.19.0...v0.19.1
|
|
835
843
|
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { FrodoCommand } from '../FrodoCommand';
|
|
2
2
|
import { Option } from 'commander';
|
|
3
|
-
import { Authenticate,
|
|
3
|
+
import { Authenticate, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
5
|
+
import { exportSocialProvidersToFile, exportSocialProvidersToFiles, exportSocialProviderToFile } from '../../ops/IdpOps';
|
|
5
6
|
const {
|
|
6
7
|
getTokens
|
|
7
8
|
} = Authenticate;
|
|
8
|
-
const {
|
|
9
|
-
exportSocialProviderToFile,
|
|
10
|
-
exportSocialProvidersToFile,
|
|
11
|
-
exportSocialProvidersToFiles
|
|
12
|
-
} = Idp;
|
|
13
9
|
const program = new FrodoCommand('frodo idp export');
|
|
14
10
|
program.description('Export (social) identity providers.').addOption(new Option('-i, --idp-id <idp-id>', 'Id/name of a provider. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file [file]', 'Name of the file to write the exported provider(s) to. Ignored with -A.')).addOption(new Option('-a, --all', 'Export all the providers in a realm to a single file. Ignored with -t and -i.')).addOption(new Option('-A, --all-separate', 'Export all the providers in a realm as separate files <provider name>.idp.json. Ignored with -t, -i, and -a.')).action(
|
|
15
11
|
// implement command logic inside action handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idp-export.js","names":["FrodoCommand","Option","Authenticate","
|
|
1
|
+
{"version":3,"file":"idp-export.js","names":["FrodoCommand","Option","Authenticate","state","printMessage","verboseMessage","exportSocialProvidersToFile","exportSocialProvidersToFiles","exportSocialProviderToFile","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","idpId","getRealm","file","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/idp/idp-export.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 exportSocialProvidersToFile,\n exportSocialProvidersToFiles,\n exportSocialProviderToFile,\n} from '../../ops/IdpOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo idp export');\n\nprogram\n .description('Export (social) identity 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 in a realm to a single file. Ignored with -t and -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all the providers in a realm as separate files <provider name>.idp.json. Ignored with -t, -i, and -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n // export by id/name\n if (options.idpId) {\n verboseMessage(\n `Exporting provider \"${\n options.idpId\n }\" from realm \"${state.getRealm()}\"...`\n );\n exportSocialProviderToFile(options.idpId, options.file);\n }\n // --all -a\n else if (options.all) {\n verboseMessage('Exporting all providers to a single file...');\n exportSocialProvidersToFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate) {\n verboseMessage('Exporting all providers to separate files...');\n exportSocialProvidersToFiles();\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,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,0BAA0B,Q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AI,EAAE;MACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF;AACF;AACA;AAAA,CACD;;AAEHlB,OAAO,CAACmB,KAAK,EAAE"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { FrodoCommand } from '../FrodoCommand';
|
|
2
2
|
import { Option } from 'commander';
|
|
3
|
-
import { Authenticate,
|
|
3
|
+
import { Authenticate, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
5
|
+
import { importFirstSocialProviderFromFile, importSocialProviderFromFile, importSocialProvidersFromFile, importSocialProvidersFromFiles } from '../../ops/IdpOps';
|
|
5
6
|
const {
|
|
6
7
|
getTokens
|
|
7
8
|
} = Authenticate;
|
|
8
|
-
const {
|
|
9
|
-
importSocialProviderFromFile,
|
|
10
|
-
importFirstSocialProviderFromFile,
|
|
11
|
-
importSocialProvidersFromFile,
|
|
12
|
-
importSocialProvidersFromFiles
|
|
13
|
-
} = Idp;
|
|
14
9
|
const program = new FrodoCommand('frodo idp import');
|
|
15
10
|
program.description('Import (social) identity providers.').addOption(new Option('-i, --idp-id <id>', 'Provider id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import the provider(s) from.')).addOption(new Option('-a, --all', 'Import all the providers from single file. Ignored with -t or -i.')).addOption(new Option('-A, --all-separate', 'Import all the providers from separate files (*.json) in the current directory. Ignored with -t or -i or -a.')).action(
|
|
16
11
|
// implement command logic inside action handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idp-import.js","names":["FrodoCommand","Option","Authenticate","
|
|
1
|
+
{"version":3,"file":"idp-import.js","names":["FrodoCommand","Option","Authenticate","state","printMessage","verboseMessage","importFirstSocialProviderFromFile","importSocialProviderFromFile","importSocialProvidersFromFile","importSocialProvidersFromFiles","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","idpId","getRealm","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/idp/idp-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 importFirstSocialProviderFromFile,\n importSocialProviderFromFile,\n importSocialProvidersFromFile,\n importSocialProvidersFromFiles,\n} from '../../ops/IdpOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo idp import');\n\nprogram\n .description('Import (social) identity 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 (*.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, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by id\n if (options.file && options.idpId && (await getTokens())) {\n verboseMessage(\n `Importing provider \"${\n options.idpId\n }\" into realm \"${state.getRealm()}\"...`\n );\n importSocialProviderFromFile(options.idpId, options.file);\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage(\n `Importing all providers from a single file (${options.file})...`\n );\n importSocialProvidersFromFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n verboseMessage(\n 'Importing all providers from separate files in current directory...'\n );\n importSocialProvidersFromFiles();\n }\n // import first provider from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first provider from file \"${\n options.file\n }\" into realm \"${state.getRealm()}\"...`\n );\n importFirstSocialProviderFromFile(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,iCAAiC,EACjCC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,8BAA8B,QACzB,kBAAkB;AAEzB,MAAM;EAAEC;AAAU,CAAC,GAAGR,YAAY;AAElC,MAAMS,OAAO,GAAG,IAAIX,YAAY,CAAC,kBAAkB,CAAC;AAEpDW,OAAO,CACJC,WAAW,CAAC,qCAAqC,CAAC,CAClDC,SAAS,CACR,IAAIZ,MAAM,CACR,mBAAmB,EACnB,mDAAmD,CACpD,CACF,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,mBAAmB,EACnB,kDAAkD,CACnD,CACF,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,WAAW,EACX,mEAAmE,CACpE,CACF,CACAY,SAAS,CACR,IAAIZ,MAAM,CACR,oBAAoB,EACpB,8GAA8G,CAC/G,CACF,CACAa,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OAAO,CACR;EACD;EACA,IAAID,OAAO,CAACG,IAAI,IAAIH,OAAO,CAACI,KAAK,KAAK,MAAMb,SAAS,EAAE,CAAC,EAAE;IACxDL,cAAc,CACX,uBACCc,OAAO,CAACI,KACT,iBAAgBpB,KAAK,CAACqB,QAAQ,EAAG,MAAK,CACxC;IACDjB,4BAA4B,CAACY,OAAO,CAACI,KAAK,EAAEJ,OAAO,CAACG,IAAI,CAAC;EAC3D;EACA;EAAA,KACK,IAAIH,OAAO,CAACM,GAAG,IAAIN,OAAO,CAACG,IAAI,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IAC3DL,cAAc,CACX,+CAA8Cc,OAAO,CAACG,IAAK,MAAK,CAClE;IACDd,6BAA6B,CAACW,OAAO,CAACG,IAAI,CAAC;EAC7C;EACA;EAAA,KACK,IAAIH,OAAO,CAACO,WAAW,IAAI,CAACP,OAAO,CAACG,IAAI,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IACpEL,cAAc,CACZ,qEAAqE,CACtE;IACDI,8BAA8B,EAAE;EAClC;EACA;EAAA,KACK,IAAIU,OAAO,CAACG,IAAI,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IAC5CL,cAAc,CACX,uCACCc,OAAO,CAACG,IACT,iBAAgBnB,KAAK,CAACqB,QAAQ,EAAG,MAAK,CACxC;IACDlB,iCAAiC,CAACa,OAAO,CAACG,IAAI,CAAC;EACjD;EACA;EAAA,KACK;IACHlB,YAAY,CAAC,sDAAsD,CAAC;IACpEO,OAAO,CAACgB,IAAI,EAAE;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHlB,OAAO,CAACmB,KAAK,EAAE"}
|
package/esm/cli/idp/idp-list.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { FrodoCommand } from '../FrodoCommand';
|
|
2
|
-
import { Authenticate,
|
|
2
|
+
import { Authenticate, state } from '@rockcarver/frodo-lib';
|
|
3
3
|
import { verboseMessage } from '../../utils/Console';
|
|
4
|
+
import { listSocialProviders } from '../../ops/IdpOps';
|
|
4
5
|
const {
|
|
5
6
|
getTokens
|
|
6
7
|
} = Authenticate;
|
|
7
|
-
const {
|
|
8
|
-
listSocialProviders
|
|
9
|
-
} = Idp;
|
|
10
8
|
const program = new FrodoCommand('frodo idp list');
|
|
11
9
|
program.description('List (social) identity providers.')
|
|
12
10
|
// .addOption(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idp-list.js","names":["FrodoCommand","Authenticate","
|
|
1
|
+
{"version":3,"file":"idp-list.js","names":["FrodoCommand","Authenticate","state","verboseMessage","listSocialProviders","getTokens","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","process","exitCode","parse"],"sources":["cli/idp/idp-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport { listSocialProviders } from '../../ops/IdpOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo idp list');\n\nprogram\n .description('List (social) identity 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, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n verboseMessage(`Listing providers in realm \"${state.getRealm()}\"...`);\n listSocialProviders();\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,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,mBAAmB,QAAQ,kBAAkB;AAEtD,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAElC,MAAMK,OAAO,GAAG,IAAIN,YAAY,CAAC,gBAAgB,CAAC;AAElDM,OAAO,CACJC,WAAW,CAAC,mCAAmC;AAChD;AACA;AACA;AAAA,CACCC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OAAO,CACR;EACD,IAAI,MAAMT,SAAS,EAAE,EAAE;IACrBF,cAAc,CAAE,+BAA8BD,KAAK,CAACc,QAAQ,EAAG,MAAK,CAAC;IACrEZ,mBAAmB,EAAE;EACvB,CAAC,MAAM;IACLa,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHZ,OAAO,CAACa,KAAK,EAAE"}
|
package/esm/ops/IdpOps.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { Idp } from '@rockcarver/frodo-lib';
|
|
3
|
+
import { createProgressBar, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
|
+
import { getRealmString, getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
5
|
+
const {
|
|
6
|
+
getSocialIdentityProviders,
|
|
7
|
+
exportSocialProvider,
|
|
8
|
+
exportSocialProviders,
|
|
9
|
+
importSocialProvider,
|
|
10
|
+
importFirstSocialProvider,
|
|
11
|
+
importSocialProviders
|
|
12
|
+
} = Idp;
|
|
13
|
+
|
|
1
14
|
/**
|
|
2
15
|
* Get a one-line description of the social idp object
|
|
3
16
|
* @param {SocialIdpSkeleton} socialIdpObj social idp object to describe
|
|
@@ -28,4 +41,160 @@ export function getTableRowMd(socialIdpObj) {
|
|
|
28
41
|
const row = `| ${socialIdpObj._id} | ${socialIdpObj.enabled === false ? ':o: `disabled`' : ':white_check_mark: `enabled`'} | ${socialIdpObj._type.name} |`;
|
|
29
42
|
return row;
|
|
30
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* List providers
|
|
47
|
+
*/
|
|
48
|
+
export async function listSocialProviders() {
|
|
49
|
+
try {
|
|
50
|
+
const providers = await getSocialIdentityProviders();
|
|
51
|
+
providers.sort((a, b) => a._id.localeCompare(b._id));
|
|
52
|
+
providers.forEach(socialIdentityProvider => {
|
|
53
|
+
printMessage(`${socialIdentityProvider._id}`, 'data');
|
|
54
|
+
});
|
|
55
|
+
} catch (err) {
|
|
56
|
+
printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');
|
|
57
|
+
printMessage(err, 'error');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Export provider by id
|
|
63
|
+
* @param {string} providerId provider id/name
|
|
64
|
+
* @param {string} file optional export file name
|
|
65
|
+
*/
|
|
66
|
+
export async function exportSocialProviderToFile(providerId, file = '') {
|
|
67
|
+
let fileName = file;
|
|
68
|
+
if (!fileName) {
|
|
69
|
+
fileName = getTypedFilename(providerId, 'idp');
|
|
70
|
+
}
|
|
71
|
+
createProgressBar(1, `Exporting ${providerId}`);
|
|
72
|
+
try {
|
|
73
|
+
updateProgressBar(`Writing file ${fileName}`);
|
|
74
|
+
const fileData = await exportSocialProvider(providerId);
|
|
75
|
+
saveJsonToFile(fileData, fileName);
|
|
76
|
+
stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
stopProgressBar(`${err}`);
|
|
79
|
+
printMessage(`${err}`, 'error');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Export all providers
|
|
85
|
+
* @param {string} file optional export file name
|
|
86
|
+
*/
|
|
87
|
+
export async function exportSocialProvidersToFile(file = '') {
|
|
88
|
+
let fileName = file;
|
|
89
|
+
if (!fileName) {
|
|
90
|
+
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
|
|
91
|
+
}
|
|
92
|
+
const fileData = await exportSocialProviders();
|
|
93
|
+
saveJsonToFile(fileData, fileName);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Export all providers to individual files
|
|
98
|
+
*/
|
|
99
|
+
export async function exportSocialProvidersToFiles() {
|
|
100
|
+
const allIdpsData = await getSocialIdentityProviders();
|
|
101
|
+
// printMessage(allIdpsData, 'data');
|
|
102
|
+
createProgressBar(allIdpsData.length, 'Exporting providers');
|
|
103
|
+
for (const idpData of allIdpsData) {
|
|
104
|
+
updateProgressBar(`Writing provider ${idpData._id}`);
|
|
105
|
+
const fileName = getTypedFilename(idpData._id, 'idp');
|
|
106
|
+
const fileData = await exportSocialProvider(idpData._id);
|
|
107
|
+
saveJsonToFile(fileData, fileName);
|
|
108
|
+
}
|
|
109
|
+
stopProgressBar(`${allIdpsData.length} providers exported.`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Import provider by id/name
|
|
114
|
+
* @param {string} providerId provider id/name
|
|
115
|
+
* @param {string} file import file name
|
|
116
|
+
* @returns {Promise<boolean>} true if provider was imported successfully, false otherwise
|
|
117
|
+
*/
|
|
118
|
+
export async function importSocialProviderFromFile(providerId, file) {
|
|
119
|
+
let outcome = false;
|
|
120
|
+
showSpinner(`Importing provider ${providerId} from ${file}...`);
|
|
121
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
122
|
+
if (err) throw err;
|
|
123
|
+
try {
|
|
124
|
+
const fileData = JSON.parse(data);
|
|
125
|
+
outcome = await importSocialProvider(providerId, fileData);
|
|
126
|
+
succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
var _error$response;
|
|
129
|
+
failSpinner(`Error importing provider ${providerId} from ${file}.`);
|
|
130
|
+
printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return outcome;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Import first provider from file
|
|
138
|
+
* @param {String} file import file name
|
|
139
|
+
* @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise
|
|
140
|
+
*/
|
|
141
|
+
export async function importFirstSocialProviderFromFile(file) {
|
|
142
|
+
let outcome = false;
|
|
143
|
+
showSpinner(`Importing first provider from ${file}...`);
|
|
144
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
145
|
+
if (err) throw err;
|
|
146
|
+
try {
|
|
147
|
+
const fileData = JSON.parse(data);
|
|
148
|
+
outcome = await importFirstSocialProvider(fileData);
|
|
149
|
+
succeedSpinner(`Successfully imported first provider from ${file}.`);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
var _error$response2;
|
|
152
|
+
failSpinner(`Error importing first provider from ${file}.`);
|
|
153
|
+
printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return outcome;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Import all providers from file
|
|
161
|
+
* @param {string} file import file name
|
|
162
|
+
* @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise
|
|
163
|
+
*/
|
|
164
|
+
export async function importSocialProvidersFromFile(file) {
|
|
165
|
+
let outcome = false;
|
|
166
|
+
showSpinner(`Importing providers from ${file}...`);
|
|
167
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
168
|
+
if (err) throw err;
|
|
169
|
+
try {
|
|
170
|
+
const fileData = JSON.parse(data);
|
|
171
|
+
outcome = await importSocialProviders(fileData);
|
|
172
|
+
succeedSpinner(`Successfully imported providers from ${file}.`);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
var _error$response3;
|
|
175
|
+
failSpinner(`Error importing providers from ${file}.`);
|
|
176
|
+
printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return outcome;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Import providers from *.idp.json files in current working directory
|
|
184
|
+
*/
|
|
185
|
+
export async function importSocialProvidersFromFiles() {
|
|
186
|
+
const names = fs.readdirSync('.');
|
|
187
|
+
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json'));
|
|
188
|
+
createProgressBar(jsonFiles.length, 'Importing providers...');
|
|
189
|
+
let total = 0;
|
|
190
|
+
for (const file of jsonFiles) {
|
|
191
|
+
const data = fs.readFileSync(file, 'utf8');
|
|
192
|
+
const fileData = JSON.parse(data);
|
|
193
|
+
const count = Object.keys(fileData.idp).length;
|
|
194
|
+
total += count;
|
|
195
|
+
await importSocialProviders(fileData);
|
|
196
|
+
updateProgressBar(`Imported ${count} provider(s) from ${file}`);
|
|
197
|
+
}
|
|
198
|
+
stopProgressBar(`Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);
|
|
199
|
+
}
|
|
31
200
|
//# sourceMappingURL=IdpOps.js.map
|
package/esm/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqB,CAACC,YAA+B,EAAU;EAC7E,MAAMC,WAAW,GAAI,IAAGD,YAAY,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,YAAY,CAACG,KAAK,CAACD,GAAI,EAAC;EACnF,OAAOD,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,gBAAgB,GAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,+BAA+B;EAC3CA,QAAQ,IAAI,6BAA6B;EACzC,OAAOA,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAa,CAACN,YAA+B,EAAU;EACrE,MAAMO,GAAG,GAAI,KAAIP,YAAY,CAACE,GAAI,MAChCF,YAAY,CAACQ,OAAO,KAAK,KAAK,GAC1B,gBAAgB,GAChB,8BACL,MAAKR,YAAY,CAACG,KAAK,CAACM,IAAK,IAAG;EACjC,OAAOF,GAAG;AACZ"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["fs","Idp","createProgressBar","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getSocialIdentityProviders","exportSocialProvider","exportSocialProviders","importSocialProvider","importFirstSocialProvider","importSocialProviders","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvidersToFile","exportSocialProvidersToFiles","allIdpsData","length","idpData","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","error","response","importFirstSocialProviderFromFile","importSocialProvidersFromFile","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { Idp } from '@rockcarver/frodo-lib';\nimport {\n createProgressBar,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\nconst {\n getSocialIdentityProviders,\n exportSocialProvider,\n exportSocialProviders,\n importSocialProvider,\n importFirstSocialProvider,\n importSocialProviders,\n} = Idp;\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await getSocialIdentityProviders();\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(`listSocialProviders 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 exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportSocialProvider(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 exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n const allIdpsData = await getSocialIdentityProviders();\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, 'idp');\n const fileData = await exportSocialProvider(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 importSocialProviderFromFile(\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 outcome = await importSocialProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\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 importFirstSocialProviderFromFile(\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 outcome = await importFirstSocialProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\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 importSocialProvidersFromFile(\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 outcome = await importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\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 importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.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 importSocialProviders(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":"AAAA,OAAOA,EAAE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AACf,MAAO,WAAU,CAC5E;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import slugify from 'slugify';
|
|
3
|
-
import { ExportImportUtils } from '@rockcarver/frodo-lib';
|
|
3
|
+
import { ExportImportUtils, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import { printMessage } from './Console';
|
|
5
5
|
const {
|
|
6
6
|
getMetadata
|
|
@@ -17,7 +17,7 @@ export function getTypedFilename(name, type, suffix = 'json') {
|
|
|
17
17
|
*/
|
|
18
18
|
export function saveJsonToFile(data, filename) {
|
|
19
19
|
const exportData = data;
|
|
20
|
-
exportData.meta = getMetadata();
|
|
20
|
+
if (!exportData.meta) exportData.meta = getMetadata();
|
|
21
21
|
fs.writeFile(filename, JSON.stringify(exportData, null, 2), err => {
|
|
22
22
|
if (err) {
|
|
23
23
|
return printMessage(`ERROR - can't save ${filename}`, 'error');
|
|
@@ -43,4 +43,22 @@ export function saveToFile(type, data, identifier, filename) {
|
|
|
43
43
|
return '';
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* Output str in title case
|
|
49
|
+
*
|
|
50
|
+
* e.g.: 'ALL UPPERCASE AND all lowercase' = 'All Uppercase And All Lowercase'
|
|
51
|
+
*/
|
|
52
|
+
export function titleCase(input) {
|
|
53
|
+
const str = input.toString();
|
|
54
|
+
const splitStr = str.toLowerCase().split(' ');
|
|
55
|
+
for (let i = 0; i < splitStr.length; i += 1) {
|
|
56
|
+
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].slice(1);
|
|
57
|
+
}
|
|
58
|
+
return splitStr.join(' ');
|
|
59
|
+
}
|
|
60
|
+
export function getRealmString() {
|
|
61
|
+
const realm = state.getRealm();
|
|
62
|
+
return realm.split('/').reduce((result, item) => `${result}${titleCase(item)}`, '');
|
|
63
|
+
}
|
|
46
64
|
//# sourceMappingURL=ExportImportUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportImportUtils.js","names":["fs","slugify","ExportImportUtils","printMessage","getMetadata","getTypedFilename","name","type","suffix","slug","replace","saveJsonToFile","data","filename","exportData","meta","writeFile","JSON","stringify","err","saveToFile","identifier","Array","isArray","forEach","element"],"sources":["utils/ExportImportUtils.ts"],"sourcesContent":["import fs from 'fs';\nimport slugify from 'slugify';\nimport { ExportImportUtils } from '@rockcarver/frodo-lib';\nimport { printMessage } from './Console';\n\nconst { getMetadata } = ExportImportUtils;\n\nexport function getTypedFilename(name: string, type: string, suffix = 'json') {\n const slug = slugify(name.replace(/^http(s?):\\/\\//, ''));\n return `${slug}.${type}.${suffix}`;\n}\n\n/**\n * Save JSON object to file\n * @param {Object} data data object\n * @param {String} filename file name\n */\nexport function saveJsonToFile(data, filename) {\n const exportData = data;\n exportData.meta = getMetadata();\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${filename}`, 'error');\n }\n return '';\n });\n}\n\nexport function saveToFile(type, data, identifier, filename) {\n const exportData = {};\n exportData['meta'] = getMetadata();\n exportData[type] = {};\n\n if (Array.isArray(data)) {\n data.forEach((element) => {\n exportData[type][element[identifier]] = element;\n });\n } else {\n exportData[type][data[identifier]] = data;\n }\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${type} to file`, 'error');\n }\n return '';\n });\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,OAAO,MAAM,SAAS;AAC7B,SAASC,iBAAiB,QAAQ,uBAAuB;
|
|
1
|
+
{"version":3,"file":"ExportImportUtils.js","names":["fs","slugify","ExportImportUtils","state","printMessage","getMetadata","getTypedFilename","name","type","suffix","slug","replace","saveJsonToFile","data","filename","exportData","meta","writeFile","JSON","stringify","err","saveToFile","identifier","Array","isArray","forEach","element","titleCase","input","str","toString","splitStr","toLowerCase","split","i","length","charAt","toUpperCase","slice","join","getRealmString","realm","getRealm","reduce","result","item"],"sources":["utils/ExportImportUtils.ts"],"sourcesContent":["import fs from 'fs';\nimport slugify from 'slugify';\nimport { ExportImportUtils, state } from '@rockcarver/frodo-lib';\nimport { printMessage } from './Console';\n\nconst { getMetadata } = ExportImportUtils;\n\nexport function getTypedFilename(name: string, type: string, suffix = 'json') {\n const slug = slugify(name.replace(/^http(s?):\\/\\//, ''));\n return `${slug}.${type}.${suffix}`;\n}\n\n/**\n * Save JSON object to file\n * @param {Object} data data object\n * @param {String} filename file name\n */\nexport function saveJsonToFile(data, filename) {\n const exportData = data;\n if (!exportData.meta) exportData.meta = getMetadata();\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${filename}`, 'error');\n }\n return '';\n });\n}\n\nexport function saveToFile(type, data, identifier, filename) {\n const exportData = {};\n exportData['meta'] = getMetadata();\n exportData[type] = {};\n\n if (Array.isArray(data)) {\n data.forEach((element) => {\n exportData[type][element[identifier]] = element;\n });\n } else {\n exportData[type][data[identifier]] = data;\n }\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${type} to file`, 'error');\n }\n return '';\n });\n}\n\n/*\n * Output str in title case\n *\n * e.g.: 'ALL UPPERCASE AND all lowercase' = 'All Uppercase And All Lowercase'\n */\nexport function titleCase(input) {\n const str = input.toString();\n const splitStr = str.toLowerCase().split(' ');\n for (let i = 0; i < splitStr.length; i += 1) {\n splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].slice(1);\n }\n return splitStr.join(' ');\n}\n\nexport function getRealmString() {\n const realm = state.getRealm();\n return realm\n .split('/')\n .reduce((result, item) => `${result}${titleCase(item)}`, '');\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,OAAO,MAAM,SAAS;AAC7B,SAASC,iBAAiB,EAAEC,KAAK,QAAQ,uBAAu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carver/frodo-cli",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3-0",
|
|
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": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
]
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@rockcarver/frodo-lib": "0.17.
|
|
91
|
+
"@rockcarver/frodo-lib": "0.17.3",
|
|
92
92
|
"cli-progress": "^3.11.2",
|
|
93
93
|
"cli-table3": "^0.6.3",
|
|
94
94
|
"colors": "^1.4.0",
|