@rockcarver/frodo-cli 0.18.2-13 → 0.18.2-15
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/app.js +1 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/conn/conn-save.js +78 -0
- package/esm/cli/conn/conn-save.js.map +1 -0
- package/esm/cli/conn/conn.js +1 -1
- package/esm/cli/conn/conn.js.map +1 -1
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/info/info.js +20 -17
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/logging/logs-fetch.js +4 -4
- package/esm/cli/logging/logs-fetch.js.map +1 -1
- package/esm/cli/logging/logs-list.js +4 -4
- package/esm/cli/logging/logs-list.js.map +1 -1
- package/esm/cli/logging/logs-tail.js +4 -4
- package/esm/cli/logging/logs-tail.js.map +1 -1
- package/esm/cli/service/service-delete.js +4 -3
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +6 -4
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +6 -5
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +2 -2
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +30 -0
- package/esm/ops/ConnectionProfileOps.js.map +1 -0
- package/esm/ops/ServiceOps.js +20 -20
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/utils/Console.js +9 -19
- package/esm/utils/Console.js.map +1 -1
- package/package.json +2 -2
- package/esm/cli/conn/conn-add.js +0 -40
- package/esm/cli/conn/conn-add.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-delete.js","names":["Authenticate","state","Command","Option","deleteService","deleteServices","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","id","all","help","parse"],"sources":["cli/service/service-delete.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { deleteService, deleteServices } from '../../ops/ServiceOps.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service delete');\n\ninterface ServiceDeleteOptions {\n id?: string;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n all?: boolean;\n}\n\nprogram\n .description('Delete AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(new Option('-i, --id <id>', 'Id of Service to be deleted.'))\n .addOption(new Option('-a, --all', 'Delete all services. Ignored with -i.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceDeleteOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (options.id && (await getTokens())) {\n await deleteService(options.id);\n } else if (options.all && (await getTokens())) {\n await deleteServices();\n } else {\n program.help();\n }\n }\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AACvE,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIN,OAAO,CAAC,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-delete.js","names":["Authenticate","state","Command","Option","deleteService","deleteServices","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","globalConfig","global","id","all","help","parse"],"sources":["cli/service/service-delete.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { deleteService, deleteServices } from '../../ops/ServiceOps.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service delete');\n\ninterface ServiceDeleteOptions {\n id?: string;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n all?: boolean;\n global?: boolean;\n}\n\nprogram\n .description('Delete AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(new Option('-i, --id <id>', 'Id of Service to be deleted.'))\n .addOption(new Option('-a, --all', 'Delete all services. Ignored with -i.'))\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceDeleteOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n\n const globalConfig = options.global ?? false;\n\n if (options.id && (await getTokens())) {\n await deleteService(options.id, globalConfig);\n } else if (options.all && (await getTokens())) {\n await deleteServices(globalConfig);\n } else {\n program.help();\n }\n }\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AACvE,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIN,OAAO,CAAC,sBAAsB,CAAC;AAanDM,OAAO,CACJC,WAAW,CAAC,qBAAqB,CAAC,CAClCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,kBAAkB,EAAE,CACpBC,WAAW,CAACN,MAAM,CAACO,aAAa,CAAC,CACjCD,WAAW,CAACN,MAAM,CAACQ,aAAa,CAAC,CACjCF,WAAW,CAACN,MAAM,CAACS,YAAY,CAAC,CAChCH,WAAW,CAACN,MAAM,CAACU,gBAAgB,CAAC,CACpCC,SAAS,CAACX,MAAM,CAACY,gBAAgB,CAAC,CAClCD,SAAS,CAACX,MAAM,CAACa,cAAc,CAAC,CAChCF,SAAS,CAACX,MAAM,CAACc,aAAa,CAAC,CAC/BH,SAAS,CAACX,MAAM,CAACe,WAAW,CAAC,CAC7BJ,SAAS,CAACX,MAAM,CAACgB,eAAe,CAAC,CACjCL,SAAS,CAAC,IAAId,MAAM,CAAC,eAAe,EAAE,8BAA8B,CAAC,CAAC,CACtEc,SAAS,CAAC,IA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,YAAY,CAAC;EACpC,CAAC,MAAM;IACLrC,OAAO,CAACyC,IAAI,EAAE;EAChB;AACF,CAAC,CACF;AAEHzC,OAAO,CAAC0C,KAAK,EAAE"}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = Authenticate;
|
|
9
9
|
const program = new Command('frodo service export');
|
|
10
|
-
program.description('Export AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all services to a single file.')).addOption(new Option('-A, --all-separate', 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.')).action(async (host, realm, user, password, options) => {
|
|
10
|
+
program.description('Export AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all services to a single file.')).addOption(new Option('-A, --all-separate', 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.')).addOption(new Option('-g, --global', 'List global services.')).action(async (host, realm, user, password, options) => {
|
|
11
11
|
state.default.session.setTenant(host);
|
|
12
12
|
state.default.session.setRealm(realm);
|
|
13
13
|
state.default.session.setUsername(user);
|
|
@@ -17,20 +17,22 @@ program.description('Export AM services.').helpOption('-h, --help', 'Help').show
|
|
|
17
17
|
state.default.session.setVerbose(options.verbose);
|
|
18
18
|
state.default.session.setDebug(options.debug);
|
|
19
19
|
state.default.session.setCurlirize(options.curlirize);
|
|
20
|
+
const globalConfig = options.global ?? false;
|
|
21
|
+
|
|
20
22
|
// export by name
|
|
21
23
|
if (options.serviceId && (await getTokens())) {
|
|
22
24
|
verboseMessage('Exporting service...');
|
|
23
|
-
await exportServiceToFile(options.serviceId, options.file);
|
|
25
|
+
await exportServiceToFile(options.serviceId, options.file, globalConfig);
|
|
24
26
|
}
|
|
25
27
|
// -a / --all
|
|
26
28
|
else if (options.all && (await getTokens())) {
|
|
27
29
|
verboseMessage('Exporting all services to a single file...');
|
|
28
|
-
await exportServicesToFile(options.file);
|
|
30
|
+
await exportServicesToFile(options.file, globalConfig);
|
|
29
31
|
}
|
|
30
32
|
// -A / --all-separate
|
|
31
33
|
else if (options.allSeparate && (await getTokens())) {
|
|
32
34
|
verboseMessage('Exporting all services to separate files...');
|
|
33
|
-
await exportServicesToFiles();
|
|
35
|
+
await exportServicesToFiles(globalConfig);
|
|
34
36
|
}
|
|
35
37
|
// unrecognized combination of options or no options
|
|
36
38
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-export.js","names":["Authenticate","state","Command","Option","exportServicesToFile","exportServicesToFiles","exportServiceToFile","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-export.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n exportServicesToFile,\n exportServicesToFiles,\n exportServiceToFile,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service export');\n\ninterface ServiceExportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n}\n\nprogram\n .description('Export AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(new Option('-a, --all', 'Export all services to a single file.'))\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.'\n )\n )\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceExportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n // export by name\n if (options.serviceId && (await getTokens())) {\n verboseMessage('Exporting service...');\n await exportServiceToFile(options.serviceId
|
|
1
|
+
{"version":3,"file":"service-export.js","names":["Authenticate","state","Command","Option","exportServicesToFile","exportServicesToFiles","exportServiceToFile","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","globalConfig","global","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-export.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n exportServicesToFile,\n exportServicesToFiles,\n exportServiceToFile,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service export');\n\ninterface ServiceExportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n global?: boolean;\n}\n\nprogram\n .description('Export AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(new Option('-a, --all', 'Export all services to a single file.'))\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.'\n )\n )\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceExportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n\n const globalConfig = options.global ?? false;\n\n // export by name\n if (options.serviceId && (await getTokens())) {\n verboseMessage('Exporting service...');\n await exportServiceToFile(\n options.serviceId,\n options.file,\n globalConfig\n );\n }\n // -a / --all\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all services to a single file...');\n await exportServicesToFile(options.file, globalConfig);\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all services to separate files...');\n await exportServicesToFiles(globalConfig);\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 }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,mBAAmB,QACd,yBAAyB;AAChC,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGV,YAAY;AAElC,MAAMW,OAAO,GAAG,IAAIT,OAAO,CAAC,sBAAsB,CAAC;AAenDS,OAAO,CACJC,WAAW,CAAC,qBAAqB,CAAC,CAClCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,kBAAkB,EAAE,CACpBC,WAAW,CAACN,MAAM,CAACO,aAAa,CAAC,CACjCD,WAAW,CAACN,MAAM,CAACQ,aAAa,CAAC,CACjCF,WAAW,CAACN,MAAM,CAACS,YAAY,CAAC,CAChCH,WAAW,CAACN,MAAM,CAACU,gBAAgB,CAAC,CACpCC,SAAS,CAACX,MAAM,CAACY,gBAAgB,CAAC,CAClCD,SAAS,CAACX,MAAM,CAACa,cAAc,CAAC,CAChCF,SAAS,CAACX,MAAM,CAACc,aAAa,CAAC,CAC/BH,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CAACgB,SAAS,CAAC;EAErD,MAAMC,YAAY,GAAGjB,OAAO,CAACkB,MAAM,IAAI,KAAK;;EAE5C;EACA,IAAIlB,OAAO,CAACmB,SAAS,KAAK,MAAMxC,SAAS,EAAE,CAAC,EAAE;IAC5CF,cAAc,CAAC,sBAAsB,CAAC;IACtC,MAAMF,mBAAmB,CACvByB,OAAO,CAACmB,SAAS,EACjBnB,OAAO,CAACoB,IAAI,EACZH,YAAY,CACb;EACH;EACA;EAAA,KACK,IAAIjB,OAAO,CAACqB,GAAG,KAAK,MAAM1C,SAAS,EAAE,CAAC,EAAE;IAC3CF,cAAc,CAAC,4CAA4C,CAAC;IAC5D,MAAMJ,oBAAoB,CAAC2B,OAAO,CAACoB,IAAI,EAAEH,YAAY,CAAC;EACxD;EACA;EAAA,KACK,IAAIjB,OAAO,CAACsB,WAAW,KAAK,MAAM3C,SAAS,EAAE,CAAC,EAAE;IACnDF,cAAc,CAAC,6CAA6C,CAAC;IAC7D,MAAMH,qBAAqB,CAAC2C,YAAY,CAAC;EAC3C;EACA;EAAA,KACK;IACHzC,YAAY,CACV,sDAAsD,EACtD,OAAO,CACR;IACDI,OAAO,CAAC2C,IAAI,EAAE;EAChB;AACF;AACA;AAAA,CACD;;AAEH3C,OAAO,CAAC4C,KAAK,EAAE"}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = Authenticate;
|
|
9
9
|
const program = new Command('frodo service import');
|
|
10
|
-
program.description('Import AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import SAML Entity(s) from. Ignored with -A.')).addOption(new Option('-a, --all', 'Import all services from a single file.')).addOption(new Option('-C, --clean', 'Remove existing service(s) before importing.')).addOption(new Option('-A, --all-separate', 'Import all services from separate files <id>.service.json.')).addOption(new Option('-D, --directory <directory>', 'Working directory.')).action(async (host, realm, user, password, options) => {
|
|
10
|
+
program.description('Import AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import SAML Entity(s) from. Ignored with -A.')).addOption(new Option('-a, --all', 'Import all services from a single file.')).addOption(new Option('-C, --clean', 'Remove existing service(s) before importing.')).addOption(new Option('-A, --all-separate', 'Import all services from separate files <id>.service.json.')).addOption(new Option('-D, --directory <directory>', 'Working directory.')).addOption(new Option('-g, --global', 'List global services.')).action(async (host, realm, user, password, options) => {
|
|
11
11
|
state.default.session.setTenant(host);
|
|
12
12
|
state.default.session.setRealm(realm);
|
|
13
13
|
state.default.session.setUsername(user);
|
|
@@ -19,26 +19,27 @@ program.description('Import AM services.').helpOption('-h, --help', 'Help').show
|
|
|
19
19
|
state.default.session.setCurlirize(options.curlirize);
|
|
20
20
|
state.default.session.setDirectory(options.directory || '.');
|
|
21
21
|
const clean = options.clean ?? false;
|
|
22
|
+
const globalConfig = options.global ?? false;
|
|
22
23
|
|
|
23
24
|
// import by id
|
|
24
25
|
if (options.serviceId && options.file && (await getTokens())) {
|
|
25
26
|
verboseMessage('Importing service...');
|
|
26
|
-
await importServiceFromFile(options.serviceId, options.file, clean);
|
|
27
|
+
await importServiceFromFile(options.serviceId, options.file, clean, globalConfig);
|
|
27
28
|
}
|
|
28
29
|
// -a / --all
|
|
29
30
|
else if (options.all && options.file && (await getTokens())) {
|
|
30
31
|
verboseMessage('Importing all services from a single file...');
|
|
31
|
-
await importServicesFromFile(options.file, clean);
|
|
32
|
+
await importServicesFromFile(options.file, clean, globalConfig);
|
|
32
33
|
}
|
|
33
34
|
// -A / --all-separate
|
|
34
35
|
else if (options.allSeparate && (await getTokens())) {
|
|
35
36
|
verboseMessage('Importing all services from separate files...');
|
|
36
|
-
await importServicesFromFiles(clean);
|
|
37
|
+
await importServicesFromFiles(clean, globalConfig);
|
|
37
38
|
}
|
|
38
39
|
// import file
|
|
39
40
|
else if (options.file && (await getTokens())) {
|
|
40
41
|
verboseMessage('Importing service...');
|
|
41
|
-
await importFirstServiceFromFile(options.file, clean);
|
|
42
|
+
await importFirstServiceFromFile(options.file, clean, globalConfig);
|
|
42
43
|
}
|
|
43
44
|
// unrecognized combination of options or no options
|
|
44
45
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-import.js","names":["Authenticate","state","Command","Option","importFirstServiceFromFile","importServiceFromFile","importServicesFromFile","importServicesFromFiles","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","setDirectory","directory","clean","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-import.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n importFirstServiceFromFile,\n importServiceFromFile,\n importServicesFromFile,\n importServicesFromFiles,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service import');\n\ninterface ServiceImportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n clean?: boolean;\n directory?: string;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n}\n\nprogram\n .description('Import AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service 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 SAML Entity(s) from. Ignored with -A.'\n )\n )\n .addOption(new Option('-a, --all', 'Import all services from a single file.'))\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all services from separate files <id>.service.json.'\n )\n )\n .addOption(new Option('-D, --directory <directory>', 'Working directory.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceImportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n state.default.session.setDirectory(options.directory || '.');\n\n const clean = options.clean ?? false;\n\n // import by id\n if (options.serviceId && options.file && (await getTokens())) {\n verboseMessage('Importing service...');\n await importServiceFromFile(options.serviceId
|
|
1
|
+
{"version":3,"file":"service-import.js","names":["Authenticate","state","Command","Option","importFirstServiceFromFile","importServiceFromFile","importServicesFromFile","importServicesFromFiles","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","setDirectory","directory","clean","globalConfig","global","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-import.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n importFirstServiceFromFile,\n importServiceFromFile,\n importServicesFromFile,\n importServicesFromFiles,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service import');\n\ninterface ServiceImportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n clean?: boolean;\n directory?: string;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n global?: boolean;\n}\n\nprogram\n .description('Import AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service 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 SAML Entity(s) from. Ignored with -A.'\n )\n )\n .addOption(new Option('-a, --all', 'Import all services from a single file.'))\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all services from separate files <id>.service.json.'\n )\n )\n .addOption(new Option('-D, --directory <directory>', 'Working directory.'))\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceImportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n state.default.session.setDirectory(options.directory || '.');\n\n const clean = options.clean ?? false;\n const globalConfig = options.global ?? false;\n\n // import by id\n if (options.serviceId && options.file && (await getTokens())) {\n verboseMessage('Importing service...');\n await importServiceFromFile(\n options.serviceId,\n options.file,\n clean,\n globalConfig\n );\n }\n // -a / --all\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage('Importing all services from a single file...');\n await importServicesFromFile(options.file, clean, globalConfig);\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Importing all services from separate files...');\n await importServicesFromFiles(clean, globalConfig);\n }\n // import file\n else if (options.file && (await getTokens())) {\n verboseMessage('Importing service...');\n await importFirstServiceFromFile(options.file, clean, globalConfig);\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 }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SACEC,0BAA0B,EAC1BC,qBAAqB,EACrBC,sBAAsB,EACtBC,uBAAuB,QAClB,yBAAyB;AAChC,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGX,YAAY;AAElC,MAAMY,OAAO,GAAG,IAAIV,OAAO,CAAC,sBAAsB,CAAC;AAiBnDU,OAAO,CACJC,WAAW,CAAC,qBAAqB,CAAC,CAClC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ACjE;EACA;EAAA,KACK,IAAIpB,OAAO,CAACyB,WAAW,KAAK,MAAM9C,SAAS,EAAE,CAAC,EAAE;IACnDF,cAAc,CAAC,+CAA+C,CAAC;IAC/D,MAAMF,uBAAuB,CAAC4C,KAAK,EAAEC,YAAY,CAAC;EACpD;EACA;EAAA,KACK,IAAIpB,OAAO,CAACuB,IAAI,KAAK,MAAM5C,SAAS,EAAE,CAAC,EAAE;IAC5CF,cAAc,CAAC,sBAAsB,CAAC;IACtC,MAAML,0BAA0B,CAAC4B,OAAO,CAACuB,IAAI,EAAEJ,KAAK,EAAEC,YAAY,CAAC;EACrE;EACA;EAAA,KACK;IACH5C,YAAY,CACV,sDAAsD,EACtD,OAAO,CACR;IACDI,OAAO,CAAC8C,IAAI,EAAE;EAChB;AACF;AACA;AAAA,CACD;;AAEH9C,OAAO,CAAC+C,KAAK,EAAE"}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = Authenticate;
|
|
9
9
|
const program = new Command('frodo service list');
|
|
10
|
-
program.description('List AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-l, --long', 'Long with all fields.').default(false, 'false')).action(async (host, realm, user, password, options) => {
|
|
10
|
+
program.description('List AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-l, --long', 'Long with all fields.').default(false, 'false')).addOption(new Option('-g, --global', 'List global services.')).action(async (host, realm, user, password, options) => {
|
|
11
11
|
state.default.session.setTenant(host);
|
|
12
12
|
state.default.session.setRealm(realm);
|
|
13
13
|
state.default.session.setUsername(user);
|
|
@@ -19,7 +19,7 @@ program.description('List AM services.').helpOption('-h, --help', 'Help').showHe
|
|
|
19
19
|
state.default.session.setCurlirize(options.curlirize);
|
|
20
20
|
if (await getTokens()) {
|
|
21
21
|
verboseMessage(`Listing all AM services for realm: ${realm}`);
|
|
22
|
-
await listServices(options.long);
|
|
22
|
+
await listServices(options.long, options.global);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
program.parse();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-list.js","names":["Authenticate","state","Command","Option","listServices","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","default","action","host","realm","user","password","options","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","long","parse"],"sources":["cli/service/service-list.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { listServices } from '../../ops/ServiceOps.js';\nimport { verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service list');\n\nprogram\n .description('List AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n )\n .action(async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (await getTokens()) {\n verboseMessage(`Listing all AM services for realm: ${realm}`);\n await listServices(options.long);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,cAAc,QAAQ,wBAAwB;AACvD,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIN,OAAO,CAAC,oBAAoB,CAAC;AAEjDM,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,kBAAkB,EAAE,CACpBC,WAAW,CAACN,MAAM,CAACO,aAAa,CAAC,CACjCD,WAAW,CAACN,MAAM,CAACQ,aAAa,CAAC,CACjCF,WAAW,CAACN,MAAM,CAACS,YAAY,CAAC,CAChCH,WAAW,CAACN,MAAM,CAACU,gBAAgB,CAAC,CACpCC,SAAS,CAACX,MAAM,CAACY,gBAAgB,CAAC,CAClCD,SAAS,CAACX,MAAM,CAACa,cAAc,CAAC,CAChCF,SAAS,CAACX,MAAM,CAACc,aAAa,CAAC,CAC/BH,SAAS,CAACX,MAAM,CAACe,WAAW,CAAC,CAC7BJ,SAAS,CAACX,MAAM,CAACgB,eAAe,CAAC,CACjCL,SAAS,CACR,IAAId,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAACoB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAC1E,
|
|
1
|
+
{"version":3,"file":"service-list.js","names":["Authenticate","state","Command","Option","listServices","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","default","action","host","realm","user","password","options","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","long","global","parse"],"sources":["cli/service/service-list.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { listServices } from '../../ops/ServiceOps.js';\nimport { verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service list');\n\nprogram\n .description('List AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n )\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (await getTokens()) {\n verboseMessage(`Listing all AM services for realm: ${realm}`);\n await listServices(options.long, options.global);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,cAAc,QAAQ,wBAAwB;AACvD,OAAO,KAAKC,MAAM,MAAM,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iBAAiB,CAACN,OAAO,CAACO,IAAI,CAAC;EACrDnC,KAAK,CAACsB,OAAO,CAACO,OAAO,CAACO,0BAA0B,CAACR,OAAO,CAACS,QAAQ,CAAC;EAClErC,KAAK,CAACsB,OAAO,CAACO,OAAO,CAACS,UAAU,CAACV,OAAO,CAACW,OAAO,CAAC;EACjDvC,KAAK,CAACsB,OAAO,CAACO,OAAO,CAACW,QAAQ,CAACZ,OAAO,CAACa,KAAK,CAAC;EAC7CzC,KAAK,CAACsB,OAAO,CAACO,OAAO,CAACa,YAAY,CAACd,OAAO,CAACe,SAAS,CAAC;EACrD,IAAI,MAAMrC,SAAS,EAAE,EAAE;IACrBF,cAAc,CAAE,sCAAqCqB,KAAM,EAAC,CAAC;IAC7D,MAAMtB,YAAY,CAACyB,OAAO,CAACgB,IAAI,EAAEhB,OAAO,CAACiB,MAAM,CAAC;EAClD;AACF,CAAC,CAAC;AAEJtC,OAAO,CAACuC,KAAK,EAAE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { Authenticate, state } from '@rockcarver/frodo-lib';
|
|
3
|
+
import { failSpinner, showSpinner, succeedSpinner } from '../utils/Console';
|
|
4
|
+
const {
|
|
5
|
+
getAccessTokenForServiceAccount
|
|
6
|
+
} = Authenticate;
|
|
7
|
+
export async function addExistingServiceAccount(serviceAccountId, privateKeyFile, validate) {
|
|
8
|
+
try {
|
|
9
|
+
const data = fs.readFileSync(privateKeyFile);
|
|
10
|
+
const jwk = JSON.parse(data.toString());
|
|
11
|
+
if (validate) {
|
|
12
|
+
showSpinner(`Validating service account ${serviceAccountId}...`);
|
|
13
|
+
const token = await getAccessTokenForServiceAccount(serviceAccountId, jwk);
|
|
14
|
+
if (token === null) {
|
|
15
|
+
failSpinner(`Failed to validate service account ${serviceAccountId}.`);
|
|
16
|
+
return false;
|
|
17
|
+
} else {
|
|
18
|
+
succeedSpinner(`Successfully validated service account ${serviceAccountId}.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
state.default.session.setServiceAccountId(serviceAccountId);
|
|
22
|
+
state.default.session.setServiceAccountJwk(jwk);
|
|
23
|
+
return true;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
failSpinner(`Failed to validate service account ${serviceAccountId}: ${err}.`);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ConnectionProfileOps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionProfileOps.js","names":["fs","Authenticate","state","failSpinner","showSpinner","succeedSpinner","getAccessTokenForServiceAccount","addExistingServiceAccount","serviceAccountId","privateKeyFile","validate","data","readFileSync","jwk","JSON","parse","toString","token","default","session","setServiceAccountId","setServiceAccountJwk","err"],"sources":["ops/ConnectionProfileOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { failSpinner, showSpinner, succeedSpinner } from '../utils/Console';\n\nconst { getAccessTokenForServiceAccount } = Authenticate;\n\nexport async function addExistingServiceAccount(\n serviceAccountId: string,\n privateKeyFile: string,\n validate: boolean\n): Promise<boolean> {\n try {\n const data = fs.readFileSync(privateKeyFile);\n const jwk = JSON.parse(data.toString());\n if (validate) {\n showSpinner(`Validating service account ${serviceAccountId}...`);\n const token = await getAccessTokenForServiceAccount(\n serviceAccountId,\n jwk\n );\n if (token === null) {\n failSpinner(`Failed to validate service account ${serviceAccountId}.`);\n return false;\n } else {\n succeedSpinner(\n `Successfully validated service account ${serviceAccountId}.`\n );\n }\n }\n state.default.session.setServiceAccountId(serviceAccountId);\n state.default.session.setServiceAccountJwk(jwk);\n return true;\n } catch (err) {\n failSpinner(\n `Failed to validate service account ${serviceAccountId}: ${err}.`\n );\n return false;\n }\n return false;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,WAAW,EAAEC,WAAW,EAAEC,cAAc,QAAQ,kBAAkB;AAE3E,MAAM;EAAEC;AAAgC,CAAC,GAAGL,YAAY;AAExD,OAAO,eAAeM,yBAAyB,CAC7CC,gBAAwB,EACxBC,cAAsB,EACtBC,QAAiB,EACC;EAClB,IAAI;IACF,MAAMC,IAAI,GAAGX,EAAE,CAACY,YAAY,CAACH,cAAc,CAAC;IAC5C,MAAMI,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAACK,QAAQ,EAAE,CAAC;IACvC,IAAIN,QAAQ,EAAE;MACZN,WAAW,CAAE,8BAA6BI,gBAAiB,KAAI,CAAC;MAChE,MAAMS,KAAK,GAAG,MAAMX,+BAA+B,CACjDE,gBAAgB,EAChBK,GAAG,CACJ;MACD,IAAII,KAAK,KAAK,IAAI,EAAE;QAClBd,WAAW,CAAE,sCAAqCK,gBAAiB,GAAE,CAAC;QACtE,OAAO,KAAK;MACd,CAAC,MAAM;QACLH,cAAc,CACX,0CAAyCG,gBAAiB,GAAE,CAC9D;MACH;IACF;IACAN,KAAK,CAACgB,OAAO,CAACC,OAAO,CAACC,mBAAmB,CAACZ,gBAAgB,CAAC;IAC3DN,KAAK,CAACgB,OAAO,CAACC,OAAO,CAACE,oBAAoB,CAACR,GAAG,CAAC;IAC/C,OAAO,IAAI;EACb,CAAC,CAAC,OAAOS,GAAG,EAAE;IACZnB,WAAW,CACR,sCAAqCK,gBAAiB,KAAIc,GAAI,GAAE,CAClE;IACD,OAAO,KAAK;EACd;EACA,OAAO,KAAK;AACd"}
|
package/esm/ops/ServiceOps.js
CHANGED
|
@@ -25,9 +25,9 @@ const {
|
|
|
25
25
|
/**
|
|
26
26
|
* List services
|
|
27
27
|
*/
|
|
28
|
-
export async function listServices(long = false) {
|
|
28
|
+
export async function listServices(long = false, globalConfig = false) {
|
|
29
29
|
try {
|
|
30
|
-
const services = await getListOfServices();
|
|
30
|
+
const services = await getListOfServices(globalConfig);
|
|
31
31
|
services.sort((a, b) => a._id.localeCompare(b._id));
|
|
32
32
|
if (long) {
|
|
33
33
|
const table = createTable(['Service Id', 'Service Name']);
|
|
@@ -50,8 +50,8 @@ export async function listServices(long = false) {
|
|
|
50
50
|
* Export all services to file
|
|
51
51
|
* @param {string} file file name
|
|
52
52
|
*/
|
|
53
|
-
export async function exportServicesToFile(file) {
|
|
54
|
-
const exportData = await exportServices();
|
|
53
|
+
export async function exportServicesToFile(file, globalConfig = false) {
|
|
54
|
+
const exportData = await exportServices(globalConfig);
|
|
55
55
|
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.default.session.getRealm()))}Services`, `service`);
|
|
56
56
|
if (file) {
|
|
57
57
|
fileName = file;
|
|
@@ -64,8 +64,8 @@ export async function exportServicesToFile(file) {
|
|
|
64
64
|
* @param {string} serviceId service id
|
|
65
65
|
* @param {string} file file name
|
|
66
66
|
*/
|
|
67
|
-
export async function exportServiceToFile(serviceId, file) {
|
|
68
|
-
const exportData = await exportService(serviceId);
|
|
67
|
+
export async function exportServiceToFile(serviceId, file, globalConfig = false) {
|
|
68
|
+
const exportData = await exportService(serviceId, globalConfig);
|
|
69
69
|
let fileName = getTypedFilename(serviceId, `service`);
|
|
70
70
|
if (file) {
|
|
71
71
|
fileName = file;
|
|
@@ -76,9 +76,9 @@ export async function exportServiceToFile(serviceId, file) {
|
|
|
76
76
|
/**
|
|
77
77
|
* Export all services to separate files
|
|
78
78
|
*/
|
|
79
|
-
export async function exportServicesToFiles() {
|
|
79
|
+
export async function exportServicesToFiles(globalConfig = false) {
|
|
80
80
|
debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);
|
|
81
|
-
const services = await getFullServices();
|
|
81
|
+
const services = await getFullServices(globalConfig);
|
|
82
82
|
for (const service of services) {
|
|
83
83
|
const fileName = getTypedFilename(service._type._id, `service`);
|
|
84
84
|
const exportData = createServiceExportTemplate();
|
|
@@ -95,7 +95,7 @@ export async function exportServicesToFiles() {
|
|
|
95
95
|
* @param {string} file import file name
|
|
96
96
|
* @param {boolean} clean remove existing service
|
|
97
97
|
*/
|
|
98
|
-
export async function importServiceFromFile(serviceId, file, clean) {
|
|
98
|
+
export async function importServiceFromFile(serviceId, file, clean, globalConfig = false) {
|
|
99
99
|
debugMessage(`cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`);
|
|
100
100
|
const verbose = state.default.session.getVerbose();
|
|
101
101
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
@@ -105,7 +105,7 @@ export async function importServiceFromFile(serviceId, file, clean) {
|
|
|
105
105
|
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
106
106
|
try {
|
|
107
107
|
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
108
|
-
await importService(serviceId, importData, clean);
|
|
108
|
+
await importService(serviceId, importData, clean, globalConfig);
|
|
109
109
|
succeedSpinner(`Imported ${serviceId}.`);
|
|
110
110
|
} catch (importError) {
|
|
111
111
|
var _importError$response, _importError$response2, _importError$response3, _importError$response4;
|
|
@@ -127,7 +127,7 @@ export async function importServiceFromFile(serviceId, file, clean) {
|
|
|
127
127
|
* @param {string} file import file name
|
|
128
128
|
* @param {boolean} clean remove existing service
|
|
129
129
|
*/
|
|
130
|
-
export async function importFirstServiceFromFile(file, clean) {
|
|
130
|
+
export async function importFirstServiceFromFile(file, clean, globalConfig = false) {
|
|
131
131
|
debugMessage(`cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`);
|
|
132
132
|
const verbose = state.default.session.getVerbose();
|
|
133
133
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
@@ -138,7 +138,7 @@ export async function importFirstServiceFromFile(file, clean) {
|
|
|
138
138
|
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
139
139
|
try {
|
|
140
140
|
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
141
|
-
await importService(serviceId, importData, clean);
|
|
141
|
+
await importService(serviceId, importData, clean, globalConfig);
|
|
142
142
|
succeedSpinner(`Imported ${serviceId}.`);
|
|
143
143
|
} catch (importError) {
|
|
144
144
|
var _importError$response5, _importError$response6, _importError$response7, _importError$response8;
|
|
@@ -160,14 +160,14 @@ export async function importFirstServiceFromFile(file, clean) {
|
|
|
160
160
|
* @param {String} file file name
|
|
161
161
|
* @param {boolean} clean remove existing service
|
|
162
162
|
*/
|
|
163
|
-
export async function importServicesFromFile(file, clean) {
|
|
163
|
+
export async function importServicesFromFile(file, clean, globalConfig = false) {
|
|
164
164
|
debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);
|
|
165
165
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
166
166
|
if (err) throw err;
|
|
167
167
|
debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);
|
|
168
168
|
const importData = JSON.parse(data);
|
|
169
169
|
try {
|
|
170
|
-
await importServices(importData, clean);
|
|
170
|
+
await importServices(importData, clean, globalConfig);
|
|
171
171
|
} catch (error) {
|
|
172
172
|
printMessage(`${error.message}`, 'error');
|
|
173
173
|
printMessage(error.response.status, 'error');
|
|
@@ -180,12 +180,12 @@ export async function importServicesFromFile(file, clean) {
|
|
|
180
180
|
* Import all services from separate files
|
|
181
181
|
* @param {boolean} clean remove existing service
|
|
182
182
|
*/
|
|
183
|
-
export async function importServicesFromFiles(clean) {
|
|
183
|
+
export async function importServicesFromFiles(clean, globalConfig = false) {
|
|
184
184
|
debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);
|
|
185
185
|
const names = fs.readdirSync(getWorkingDirectory());
|
|
186
186
|
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.service.json'));
|
|
187
187
|
for (const file of agentFiles) {
|
|
188
|
-
await importServicesFromFile(file, clean);
|
|
188
|
+
await importServicesFromFile(file, clean, globalConfig);
|
|
189
189
|
}
|
|
190
190
|
debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);
|
|
191
191
|
}
|
|
@@ -194,9 +194,9 @@ export async function importServicesFromFiles(clean) {
|
|
|
194
194
|
* Delete a service by id/name
|
|
195
195
|
* @param {string} serviceId Reference to the service to delete
|
|
196
196
|
*/
|
|
197
|
-
export async function deleteService(serviceId) {
|
|
197
|
+
export async function deleteService(serviceId, globalConfig = false) {
|
|
198
198
|
try {
|
|
199
|
-
await deleteFullService(serviceId);
|
|
199
|
+
await deleteFullService(serviceId, globalConfig);
|
|
200
200
|
} catch (error) {
|
|
201
201
|
var _error$response, _error$response$data;
|
|
202
202
|
const message = (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message;
|
|
@@ -207,7 +207,7 @@ export async function deleteService(serviceId) {
|
|
|
207
207
|
/**
|
|
208
208
|
* Delete all services
|
|
209
209
|
*/
|
|
210
|
-
export async function deleteServices() {
|
|
211
|
-
await deleteFullServices();
|
|
210
|
+
export async function deleteServices(globalConfig = false) {
|
|
211
|
+
await deleteFullServices(globalConfig);
|
|
212
212
|
}
|
|
213
213
|
//# sourceMappingURL=ServiceOps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOps.js","names":["fs","printMessage","createTable","debugMessage","showSpinner","succeedSpinner","failSpinner","ExportImportUtils","Service","Utils","state","createServiceExportTemplate","deleteFullServices","deleteFullService","getListOfServices","getFullServices","exportServices","exportService","importServices","importService","getTypedFilename","getWorkingDirectory","saveJsonToFile","titleCase","getRealmName","listServices","long","services","sort","a","b","_id","localeCompare","table","service","push","name","toString","error","stack","exportServicesToFile","file","exportData","fileName","default","session","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","importServiceFromFile","clean","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","message","response","detail","importFirstServiceFromFile","Object","keys","length","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","agentFiles","filter","toLowerCase","endsWith","deleteService","deleteServices"],"sources":["ops/ServiceOps.ts"],"sourcesContent":["import fs from 'fs';\nimport {\n printMessage,\n createTable,\n debugMessage,\n showSpinner,\n succeedSpinner,\n failSpinner,\n} from '../utils/Console';\nimport {\n ExportImportUtils,\n Service,\n Utils,\n state,\n} from '@rockcarver/frodo-lib';\nimport { ServiceExportInterface } from '@rockcarver/frodo-lib/types/ops/OpsTypes';\n\nconst {\n createServiceExportTemplate,\n deleteFullServices,\n deleteFullService,\n getListOfServices,\n getFullServices,\n exportServices,\n exportService,\n importServices,\n importService,\n} = Service;\nconst { getTypedFilename, getWorkingDirectory, saveJsonToFile, titleCase } =\n ExportImportUtils;\nconst { getRealmName } = Utils;\n\n/**\n * List services\n */\nexport async function listServices(long = false) {\n try {\n const services = await getListOfServices();\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([service._id, service.name]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n */\nexport async function exportServicesToFile(file) {\n const exportData = await exportServices();\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.default.session.getRealm()))}Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n */\nexport async function exportServiceToFile(serviceId: string, file: string) {\n const exportData = await exportService(serviceId);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export all services to separate files\n */\nexport async function exportServicesToFiles() {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices();\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${fileName}`\n );\n saveJsonToFile(exportData, fileName);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n clean: boolean\n) {\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${file}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importFirstServiceFromFile(file: string, clean: boolean) {\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${file}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${file}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFile(file: string, clean: boolean) {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, clean);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end [file=${file}]`);\n });\n}\n\n/**\n * Import all services from separate files\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFiles(clean: boolean) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const agentFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of agentFiles) {\n await importServicesFromFile(file, clean);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string) {\n try {\n await deleteFullService(serviceId);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices() {\n await deleteFullServices();\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,EACdC,WAAW,QACN,kBAAkB;AACzB,SACEC,iBAAiB,EACjBC,OAAO,EACPC,KAAK,EACLC,KAA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,CAACpD,mBAAmB,EAAE,CAAC;EACnD,MAAMqD,UAAU,GAAGF,KAAK,CAACG,MAAM,CAAEvC,IAAI,IACnCA,IAAI,CAACwC,WAAW,EAAE,CAACC,QAAQ,CAAC,eAAe,CAAC,CAC7C;EACD,KAAK,MAAMpC,IAAI,IAAIiC,UAAU,EAAE;IAC7B,MAAML,sBAAsB,CAAC5B,IAAI,EAAEW,KAAK,CAAC;EAC3C;EACAjD,YAAY,CAAE,6CAA4C,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe2E,aAAa,CAAC9B,SAAiB,EAAE;EACrD,IAAI;IACF,MAAMnC,iBAAiB,CAACmC,SAAS,CAAC;EACpC,CAAC,CAAC,OAAOV,KAAK,EAAE;IAAA;IACd,MAAMwB,OAAO,sBAAGxB,KAAK,CAACyB,QAAQ,4EAAd,gBAAgBN,IAAI,yDAApB,qBAAsBK,OAAO;IAC7C7D,YAAY,CAAE,mBAAkB+C,SAAU,MAAKc,OAAQ,EAAC,EAAE,OAAO,CAAC;EACpE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeiB,cAAc,GAAG;EACrC,MAAMnE,kBAAkB,EAAE;AAC5B"}
|
|
1
|
+
{"version":3,"file":"ServiceOps.js","names":["fs","printMessage","createTable","debugMessage","showSpinner","succeedSpinner","failSpinner","ExportImportUtils","Service","Utils","state","createServiceExportTemplate","deleteFullServices","deleteFullService","getListOfServices","getFullServices","exportServices","exportService","importServices","importService","getTypedFilename","getWorkingDirectory","saveJsonToFile","titleCase","getRealmName","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","service","push","name","toString","error","stack","exportServicesToFile","file","exportData","fileName","default","session","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","importServiceFromFile","clean","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","message","response","detail","importFirstServiceFromFile","Object","keys","length","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","agentFiles","filter","toLowerCase","endsWith","deleteService","deleteServices"],"sources":["ops/ServiceOps.ts"],"sourcesContent":["import fs from 'fs';\nimport {\n printMessage,\n createTable,\n debugMessage,\n showSpinner,\n succeedSpinner,\n failSpinner,\n} from '../utils/Console';\nimport {\n ExportImportUtils,\n Service,\n Utils,\n state,\n} from '@rockcarver/frodo-lib';\nimport { ServiceExportInterface } from '@rockcarver/frodo-lib/types/ops/OpsTypes';\n\nconst {\n createServiceExportTemplate,\n deleteFullServices,\n deleteFullService,\n getListOfServices,\n getFullServices,\n exportServices,\n exportService,\n importServices,\n importService,\n} = Service;\nconst { getTypedFilename, getWorkingDirectory, saveJsonToFile, titleCase } =\n ExportImportUtils;\nconst { getRealmName } = Utils;\n\n/**\n * List services\n */\nexport async function listServices(long = false, globalConfig = false) {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([service._id, service.name]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n */\nexport async function exportServicesToFile(file, globalConfig = false) {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.default.session.getRealm()))}Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig = false\n) {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export all services to separate files\n */\nexport async function exportServicesToFiles(globalConfig = false) {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${fileName}`\n );\n saveJsonToFile(exportData, fileName);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${file}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importFirstServiceFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${file}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${file}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, clean, globalConfig);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end [file=${file}]`);\n });\n}\n\n/**\n * Import all services from separate files\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFiles(\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const agentFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of agentFiles) {\n await importServicesFromFile(file, clean, globalConfig);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string, globalConfig = false) {\n try {\n await deleteFullService(serviceId, globalConfig);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices(globalConfig = false) {\n await deleteFullServices(globalConfig);\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,EACdC,WAAW,QACN,kBAAkB;AACzB,SACEC,iBAAiB,EACjBC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAG9B,MAAM;EACJC,2BAA2B;EAC3BC,kBAAkB;EAClBC,iBAAiB;EACjBC,iBAAiB;EACjBC,eAAe;EACfC,cAAc;EACdC,aAAa;EACbC,cAAc;EACdC;AACF,CAAC,GAAGX,OAAO;AACX,MAAM;EAAEY,gBAAgB;EAAEC,mBAAmB;EAAEC,cAAc;EAAEC;AAAU,CAAC,GACxEhB,iBAAiB;AACnB,MAAM;EAAEiB;AAAa,CAAC,GAAGf,KAAK;;AAE9B;AACA;AACA;AACA,OAAO,eAAegB,YAAY,CAACC,IAAI,GAAG,KAAK,EAAEC,YAAY,GAAG,KAAK,EAAE;EACrE,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMd,iBAAiB,CAACa,YAAY,CAAC;IACtDC,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,IAAIN,IAAI,EAAE;MACR,MAAMQ,KAAK,GAAGhC,WAAW,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;MACzD,KAAK,MAAMiC,OAAO,IAAIP,QAAQ,EAAE;QAC9BM,KAAK,CAACE,IAAI,CAAC,CAACD,OAAO,CAACH,GAAG,EAAEG,OAAO,CAACE,IAAI,CAAC,CAAC;MACzC;MACApC,YAAY,CAACiC,KAAK,CAACI,QAAQ,EAAE,EAAE,MAAM,CAAC;IACxC,CAAC,MA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kBgD,SAAU,MAAKc,OAAQ,EAAC,EAAE,OAAO,CAAC;EACpE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeiB,cAAc,CAACrD,YAAY,GAAG,KAAK,EAAE;EACzD,MAAMf,kBAAkB,CAACe,YAAY,CAAC;AACxC"}
|
package/esm/utils/Console.js
CHANGED
|
@@ -8,6 +8,8 @@ Color.enable();
|
|
|
8
8
|
const {
|
|
9
9
|
appendTextToFile
|
|
10
10
|
} = ExportImportUtils;
|
|
11
|
+
let progressBar = null;
|
|
12
|
+
let spinner = null;
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Output a message in default color to stdout or append to `state.default.session.getOutputFile()`
|
|
@@ -214,12 +216,10 @@ export function createProgressBar(total, message = null, options = {
|
|
|
214
216
|
noTTYOutput: true
|
|
215
217
|
};
|
|
216
218
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
pBar.start(total, 0, {
|
|
219
|
+
progressBar = new SingleBar(opt, Presets.legacy); // create only when needed
|
|
220
|
+
progressBar.start(total, 0, {
|
|
220
221
|
data: message
|
|
221
222
|
});
|
|
222
|
-
state.default.session.setItem('progressBar', pBar);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
@@ -228,10 +228,9 @@ export function createProgressBar(total, message = null, options = {
|
|
|
228
228
|
*
|
|
229
229
|
*/
|
|
230
230
|
export function updateProgressBar(message = null) {
|
|
231
|
-
|
|
232
|
-
if (message) pBar.increment({
|
|
231
|
+
if (message) progressBar.increment({
|
|
233
232
|
data: message
|
|
234
|
-
});else
|
|
233
|
+
});else progressBar.increment();
|
|
235
234
|
}
|
|
236
235
|
|
|
237
236
|
/**
|
|
@@ -239,11 +238,10 @@ export function updateProgressBar(message = null) {
|
|
|
239
238
|
* @param {*} message optional message to update the progress bar
|
|
240
239
|
*/
|
|
241
240
|
export function stopProgressBar(message = null) {
|
|
242
|
-
|
|
243
|
-
if (message) pBar.update({
|
|
241
|
+
if (message) progressBar.update({
|
|
244
242
|
data: message
|
|
245
243
|
});
|
|
246
|
-
|
|
244
|
+
progressBar.stop();
|
|
247
245
|
}
|
|
248
246
|
|
|
249
247
|
/**
|
|
@@ -251,8 +249,7 @@ export function stopProgressBar(message = null) {
|
|
|
251
249
|
* @param {String} message optional spinner message
|
|
252
250
|
*/
|
|
253
251
|
export function showSpinner(message) {
|
|
254
|
-
|
|
255
|
-
state.default.session.setItem('Spinner', spinner);
|
|
252
|
+
spinner = createSpinner(message).start();
|
|
256
253
|
}
|
|
257
254
|
|
|
258
255
|
/**
|
|
@@ -260,7 +257,6 @@ export function showSpinner(message) {
|
|
|
260
257
|
* @param {String} message optional message to update the spinner
|
|
261
258
|
*/
|
|
262
259
|
export function stopSpinner(message = null) {
|
|
263
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
264
260
|
if (spinner) {
|
|
265
261
|
let options = {};
|
|
266
262
|
if (message) options = {
|
|
@@ -275,7 +271,6 @@ export function stopSpinner(message = null) {
|
|
|
275
271
|
* @param {String} message optional message to update the spinner
|
|
276
272
|
*/
|
|
277
273
|
export function succeedSpinner(message = null) {
|
|
278
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
279
274
|
if (spinner) {
|
|
280
275
|
let options = {};
|
|
281
276
|
if (message) options = {
|
|
@@ -290,7 +285,6 @@ export function succeedSpinner(message = null) {
|
|
|
290
285
|
* @param {String} message optional message to update the spinner
|
|
291
286
|
*/
|
|
292
287
|
export function warnSpinner(message = null) {
|
|
293
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
294
288
|
if (spinner) {
|
|
295
289
|
let options = {};
|
|
296
290
|
if (message) options = {
|
|
@@ -305,7 +299,6 @@ export function warnSpinner(message = null) {
|
|
|
305
299
|
* @param {String} message optional message to update the spinner
|
|
306
300
|
*/
|
|
307
301
|
export function failSpinner(message = null) {
|
|
308
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
309
302
|
if (spinner) {
|
|
310
303
|
let options = {};
|
|
311
304
|
if (message) options = {
|
|
@@ -320,7 +313,6 @@ export function failSpinner(message = null) {
|
|
|
320
313
|
* @param {String} message optional message to update the spinner
|
|
321
314
|
*/
|
|
322
315
|
export function spinSpinner(message = null) {
|
|
323
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
324
316
|
if (spinner) {
|
|
325
317
|
let options = {};
|
|
326
318
|
if (message) options = {
|
|
@@ -338,7 +330,6 @@ export function createProgressIndicator(type = 'determinate', total = 0, message
|
|
|
338
330
|
}
|
|
339
331
|
}
|
|
340
332
|
export function updateProgressIndicator(message) {
|
|
341
|
-
const progressBar = state.default.session.getItem('progressBar');
|
|
342
333
|
if (!progressBar) {
|
|
343
334
|
spinSpinner(message);
|
|
344
335
|
} else {
|
|
@@ -346,7 +337,6 @@ export function updateProgressIndicator(message) {
|
|
|
346
337
|
}
|
|
347
338
|
}
|
|
348
339
|
export function stopProgressIndicator(message, status = 'none') {
|
|
349
|
-
const progressBar = state.default.session.getItem('progressBar');
|
|
350
340
|
if (!progressBar) {
|
|
351
341
|
switch (status) {
|
|
352
342
|
case 'none':
|