@rockcarver/frodo-cli 0.18.2-4 → 0.18.2-6
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 +2 -0
- package/esm/app.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +4 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +4 -1
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +4 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +4 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +4 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +4 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +4 -1
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +4 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +4 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/agent/agent-export.js +1 -1
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/service/service-delete.js +29 -0
- package/esm/cli/service/service-delete.js.map +1 -0
- package/esm/cli/service/service-export.js +40 -0
- package/esm/cli/service/service-export.js.map +1 -0
- package/esm/cli/service/service-import.js +46 -0
- package/esm/cli/service/service-import.js.map +1 -0
- package/esm/cli/service/service-list.js +27 -0
- package/esm/cli/service/service-list.js.map +1 -0
- package/esm/cli/service/service.js +16 -0
- package/esm/cli/service/service.js.map +1 -0
- package/esm/cli/theme/theme-delete.js +19 -19
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +23 -23
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +26 -28
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +4 -1
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/ops/ServiceOps.js +234 -0
- package/esm/ops/ServiceOps.js.map +1 -0
- package/esm/utils/Console.js +19 -0
- package/esm/utils/Console.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
|
-
import { Authenticate, Theme, state } from '@rockcarver/frodo-lib';
|
|
3
2
|
import * as common from '../cmd_common';
|
|
3
|
+
import { Authenticate, Theme, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import { printMessage } from '../../utils/Console';
|
|
5
5
|
const {
|
|
6
6
|
getTokens
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
importThemesFromFiles
|
|
14
14
|
} = Theme;
|
|
15
15
|
const program = new Command('frodo theme import');
|
|
16
|
-
program.description('Import themes.').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(new Option('-n, --theme-name <name>', 'Name of the theme. If specified, -a and -A are ignored.')).addOption(new Option('-i, --theme-id <uuid>', 'Uuid of the theme. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import the theme(s) from.')).addOption(new Option('-a, --all', 'Import all the themes from single file. Ignored with -n or -i.')).addOption(new Option('-A, --all-separate', 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.')).action( // implement command logic inside action handler
|
|
16
|
+
program.description('Import themes.').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('-n, --theme-name <name>', 'Name of the theme. If specified, -a and -A are ignored.')).addOption(new Option('-i, --theme-id <uuid>', 'Uuid of the theme. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import the theme(s) from.')).addOption(new Option('-a, --all', 'Import all the themes from single file. Ignored with -n or -i.')).addOption(new Option('-A, --all-separate', 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.')).action( // implement command logic inside action handler
|
|
17
17
|
async (host, realm, user, password, options) => {
|
|
18
18
|
state.default.session.setTenant(host);
|
|
19
19
|
state.default.session.setRealm(realm);
|
|
@@ -23,33 +23,31 @@ async (host, realm, user, password, options) => {
|
|
|
23
23
|
state.default.session.setAllowInsecureConnection(options.insecure);
|
|
24
24
|
state.default.session.setVerbose(options.verbose);
|
|
25
25
|
state.default.session.setDebug(options.debug);
|
|
26
|
+
state.default.session.setCurlirize(options.curlirize); // import by name
|
|
26
27
|
|
|
27
|
-
if (await getTokens()) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
printMessage('Unrecognized combination of options or no options...');
|
|
51
|
-
program.help();
|
|
52
|
-
}
|
|
28
|
+
if (options.file && options.themeName && (await getTokens())) {
|
|
29
|
+
printMessage(`Importing theme with name "${options.themeName}" into realm "${state.default.session.getRealm()}"...`);
|
|
30
|
+
importThemeByName(options.themeName, options.file);
|
|
31
|
+
} // import by id
|
|
32
|
+
else if (options.file && options.themeId && (await getTokens())) {
|
|
33
|
+
printMessage(`Importing theme with id "${options.themeId}" into realm "${state.default.session.getRealm()}"...`);
|
|
34
|
+
importThemeById(options.themeId, options.file);
|
|
35
|
+
} // --all -a
|
|
36
|
+
else if (options.all && options.file && (await getTokens())) {
|
|
37
|
+
printMessage(`Importing all themes from a single file (${options.file})...`);
|
|
38
|
+
importThemesFromFile(options.file);
|
|
39
|
+
} // --all-separate -A
|
|
40
|
+
else if (options.allSeparate && !options.file && (await getTokens())) {
|
|
41
|
+
printMessage('Importing all themes from separate files in current directory...');
|
|
42
|
+
importThemesFromFiles();
|
|
43
|
+
} // import single theme from file
|
|
44
|
+
else if (options.file && (await getTokens())) {
|
|
45
|
+
printMessage(`Importing first theme from file "${options.file}" into realm "${state.default.session.getRealm()}"...`);
|
|
46
|
+
importFirstThemeFromFile(options.file);
|
|
47
|
+
} // unrecognized combination of options or no options
|
|
48
|
+
else {
|
|
49
|
+
printMessage('Unrecognized combination of options or no options...');
|
|
50
|
+
program.help();
|
|
53
51
|
}
|
|
54
52
|
} // end command logic inside action handler
|
|
55
53
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-import.js","names":["Command","Option","Authenticate","Theme","state","
|
|
1
|
+
{"version":3,"file":"theme-import.js","names":["Command","Option","common","Authenticate","Theme","state","printMessage","getTokens","importFirstThemeFromFile","importThemeById","importThemeByName","importThemesFromFile","importThemesFromFiles","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","file","themeName","getRealm","themeId","all","allSeparate","help","parse"],"sources":["cli/theme/theme-import.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport * as common from '../cmd_common';\nimport { Authenticate, Theme, state } from '@rockcarver/frodo-lib';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\n\nconst {\n importFirstThemeFromFile,\n importThemeById,\n importThemeByName,\n importThemesFromFile,\n importThemesFromFiles,\n} = Theme;\n\nconst program = new Command('frodo theme import');\n\nprogram\n .description('Import themes.')\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 '-n, --theme-name <name>',\n 'Name of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-i, --theme-id <uuid>',\n 'Uuid of the theme. 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 theme(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the themes from single file. Ignored with -n or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n 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 // import by name\n if (options.file && options.themeName && (await getTokens())) {\n printMessage(\n `Importing theme with name \"${\n options.themeName\n }\" into realm \"${state.default.session.getRealm()}\"...`\n );\n importThemeByName(options.themeName, options.file);\n }\n // import by id\n else if (options.file && options.themeId && (await getTokens())) {\n printMessage(\n `Importing theme with id \"${\n options.themeId\n }\" into realm \"${state.default.session.getRealm()}\"...`\n );\n importThemeById(options.themeId, options.file);\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n printMessage(\n `Importing all themes from a single file (${options.file})...`\n );\n importThemesFromFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n printMessage(\n 'Importing all themes from separate files in current directory...'\n );\n importThemesFromFiles();\n }\n // import single theme from file\n else if (options.file && (await getTokens())) {\n printMessage(\n `Importing first theme from file \"${\n options.file\n }\" into realm \"${state.default.session.getRealm()}\"...`\n );\n importFirstThemeFromFile(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 }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,SAASC,YAAT,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA2C,uBAA3C;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBJ,YAAtB;AAEA,MAAM;EACJK,wBADI;EAEJC,eAFI;EAGJC,iBAHI;EAIJC,oBAJI;EAKJC;AALI,IAMFR,KANJ;AAQA,MAAMS,OAAO,GAAG,IAAIb,OAAJ,CAAY,oBAAZ,CAAhB;AAEAa,OAAO,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C,oBAAoB,CAACsB,OAAO,CAACiB,IAAT,CAApB;EACD,CALI,CAML;EANK,KAOA,IAAIjB,OAAO,CAACsB,WAAR,IAAuB,CAACtB,OAAO,CAACiB,IAAhC,KAAyC,MAAM3C,SAAS,EAAxD,CAAJ,EAAiE;IACpED,YAAY,CACV,kEADU,CAAZ;IAGAM,qBAAqB;EACtB,CALI,CAML;EANK,KAOA,IAAIqB,OAAO,CAACiB,IAAR,KAAiB,MAAM3C,SAAS,EAAhC,CAAJ,EAAyC;IAC5CD,YAAY,CACT,oCACC2B,OAAO,CAACiB,IACT,iBAAgB7C,KAAK,CAAC6B,OAAN,CAAcC,OAAd,CAAsBiB,QAAtB,EAAiC,MAHxC,CAAZ;IAKA5C,wBAAwB,CAACyB,OAAO,CAACiB,IAAT,CAAxB;EACD,CAPI,CAQL;EARK,KASA;IACH5C,YAAY,CAAC,sDAAD,CAAZ;IACAO,OAAO,CAAC2C,IAAR;EACD;AACF,CArGL,CAsGI;AAtGJ;AAyGA3C,OAAO,CAAC4C,KAAR"}
|
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
listThemes
|
|
10
10
|
} = Theme;
|
|
11
11
|
const program = new Command('frodo theme list');
|
|
12
|
-
program.description('List themes.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(new Option('-l, --long', 'Long with more fields.').default(false, 'false')).action( // implement command logic inside action handler
|
|
12
|
+
program.description('List themes.').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 more fields.').default(false, 'false')).action( // implement command logic inside action handler
|
|
13
13
|
async (host, realm, user, password, options) => {
|
|
14
14
|
state.default.session.setTenant(host);
|
|
15
15
|
state.default.session.setRealm(realm);
|
|
@@ -17,6 +17,9 @@ async (host, realm, user, password, options) => {
|
|
|
17
17
|
state.default.session.setPassword(password);
|
|
18
18
|
state.default.session.setDeploymentType(options.type);
|
|
19
19
|
state.default.session.setAllowInsecureConnection(options.insecure);
|
|
20
|
+
state.default.session.setVerbose(options.verbose);
|
|
21
|
+
state.default.session.setDebug(options.debug);
|
|
22
|
+
state.default.session.setCurlirize(options.curlirize);
|
|
20
23
|
|
|
21
24
|
if (await getTokens()) {
|
|
22
25
|
printMessage(`Listing themes in realm "${state.default.session.getRealm()}"...`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-list.js","names":["Command","Option","Authenticate","Theme","state","common","printMessage","getTokens","listThemes","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","default","action","host","realm","user","password","options","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","getRealm","long","parse"],"sources":["cli/theme/theme-list.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { Authenticate, Theme, state } from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { listThemes } = Theme;\n\nconst program = new Command('frodo theme list');\n\nprogram\n .description('List themes.')\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(\n new Option('-l, --long', 'Long with more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n 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 if (await getTokens()) {\n printMessage(\n `Listing themes in realm \"${state.default.session.getRealm()}\"...`\n );\n listThemes(options.long);\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,SAASC,YAAT,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA2C,uBAA3C;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBL,YAAtB;AACA,MAAM;EAAEM;AAAF,IAAiBL,KAAvB;AAEA,MAAMM,OAAO,GAAG,IAAIT,OAAJ,CAAY,kBAAZ,CAAhB;AAEAS,OAAO,CACJC,WADH,CACe,cADf,EAEGC,UAFH,CAEc,YAFd,EAE4B,MAF5B,EAGGC,kBAHH,GAIGC,WAJH,CAIeR,MAAM,CAACS,aAJtB,EAKGD,WALH,CAKeR,MAAM,CAACU,aALtB,EAMGF,WANH,CAMeR,MAAM,CAACW,YANtB,EAOGH,WAPH,CAOeR,MAAM,CAACY,gBAPtB,EAQGC,SARH,CAQab,MAAM,CAACc,gBARpB,EASGD,SATH,CASab,MAAM,CAACe,cATpB,EAUGF,SAVH,
|
|
1
|
+
{"version":3,"file":"theme-list.js","names":["Command","Option","Authenticate","Theme","state","common","printMessage","getTokens","listThemes","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","getRealm","long","parse"],"sources":["cli/theme/theme-list.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { Authenticate, Theme, state } from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport { printMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { listThemes } = Theme;\n\nconst program = new Command('frodo theme list');\n\nprogram\n .description('List themes.')\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 more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n 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 printMessage(\n `Listing themes in realm \"${state.default.session.getRealm()}\"...`\n );\n listThemes(options.long);\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,WAAhC;AACA,SAASC,YAAT,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA2C,uBAA3C;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,MAAM;EAAEC;AAAF,IAAgBL,YAAtB;AACA,MAAM;EAAEM;AAAF,IAAiBL,KAAvB;AAEA,MAAMM,OAAO,GAAG,IAAIT,OAAJ,CAAY,kBAAZ,CAAhB;AAEAS,OAAO,CACJC,WADH,CACe,cADf,EAEGC,UAFH,CAEc,YAFd,EAE4B,MAF5B,EAGGC,kBAHH,GAIGC,WAJH,CAIeR,MAAM,CAACS,aAJtB,EAKGD,WALH,CAKeR,MAAM,CAACU,aALtB,EAMGF,WAN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,YAAY,CACT,4BAA2BF,KAAK,CAACoB,OAAN,CAAcO,OAAd,CAAsBe,QAAtB,EAAiC,MADnD,CAAZ;IAGAtC,UAAU,CAACsB,OAAO,CAACiB,IAAT,CAAV;EACD;AACF,CAlCL,CAmCI;AAnCJ;AAsCAtC,OAAO,CAACuC,KAAR"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { printMessage, createTable, debugMessage, showSpinner, succeedSpinner, failSpinner } from '../utils/Console';
|
|
3
|
+
import { ExportImportUtils, Service, Utils, state } from '@rockcarver/frodo-lib';
|
|
4
|
+
const {
|
|
5
|
+
createServiceExportTemplate,
|
|
6
|
+
deleteFullServices,
|
|
7
|
+
deleteFullService,
|
|
8
|
+
getListOfServices,
|
|
9
|
+
getFullServices,
|
|
10
|
+
exportServices,
|
|
11
|
+
exportService,
|
|
12
|
+
importServices,
|
|
13
|
+
importService
|
|
14
|
+
} = Service;
|
|
15
|
+
const {
|
|
16
|
+
getTypedFilename,
|
|
17
|
+
getWorkingDirectory,
|
|
18
|
+
saveJsonToFile,
|
|
19
|
+
titleCase
|
|
20
|
+
} = ExportImportUtils;
|
|
21
|
+
const {
|
|
22
|
+
getRealmName
|
|
23
|
+
} = Utils;
|
|
24
|
+
/**
|
|
25
|
+
* List services
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export async function listServices(long = false) {
|
|
29
|
+
try {
|
|
30
|
+
const services = await getListOfServices();
|
|
31
|
+
services.sort((a, b) => a._id.localeCompare(b._id));
|
|
32
|
+
|
|
33
|
+
if (long) {
|
|
34
|
+
const table = createTable(['Service Id', 'Service Name']);
|
|
35
|
+
|
|
36
|
+
for (const service of services) {
|
|
37
|
+
table.push([service._id, service.name]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
printMessage(table.toString(), 'data');
|
|
41
|
+
} else {
|
|
42
|
+
for (const service of services) {
|
|
43
|
+
printMessage(`${service._id}`, 'data');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
printMessage(`Error listing agents - ${error}`, 'error');
|
|
48
|
+
printMessage(error.stack, 'error');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Export all services to file
|
|
53
|
+
* @param {string} file file name
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
export async function exportServicesToFile(file) {
|
|
57
|
+
const exportData = await exportServices();
|
|
58
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.default.session.getRealm()))}Services`, `service`);
|
|
59
|
+
|
|
60
|
+
if (file) {
|
|
61
|
+
fileName = file;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
saveJsonToFile(exportData, fileName);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Export service to file
|
|
68
|
+
* @param {string} serviceId service id
|
|
69
|
+
* @param {string} file file name
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
export async function exportServiceToFile(serviceId, file) {
|
|
73
|
+
const exportData = await exportService(serviceId);
|
|
74
|
+
let fileName = getTypedFilename(serviceId, `service`);
|
|
75
|
+
|
|
76
|
+
if (file) {
|
|
77
|
+
fileName = file;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
saveJsonToFile(exportData, fileName);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Export all services to separate files
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
export async function exportServicesToFiles() {
|
|
87
|
+
debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);
|
|
88
|
+
const services = await getFullServices();
|
|
89
|
+
|
|
90
|
+
for (const service of services) {
|
|
91
|
+
const fileName = getTypedFilename(service._type._id, `service`);
|
|
92
|
+
const exportData = createServiceExportTemplate();
|
|
93
|
+
exportData.service[service._type._id] = service;
|
|
94
|
+
debugMessage(`cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${fileName}`);
|
|
95
|
+
saveJsonToFile(exportData, fileName);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Import a service from file
|
|
102
|
+
* @param {string} serviceId service id/name
|
|
103
|
+
* @param {string} file import file name
|
|
104
|
+
* @param {boolean} clean remove existing service
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
export async function importServiceFromFile(serviceId, file, clean) {
|
|
108
|
+
debugMessage(`cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`);
|
|
109
|
+
const verbose = state.default.session.getVerbose();
|
|
110
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
111
|
+
if (err) throw err;
|
|
112
|
+
const importData = JSON.parse(data);
|
|
113
|
+
|
|
114
|
+
if (importData && importData.service[serviceId]) {
|
|
115
|
+
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
119
|
+
await importService(serviceId, importData, clean);
|
|
120
|
+
succeedSpinner(`Imported ${serviceId}.`);
|
|
121
|
+
} catch (importError) {
|
|
122
|
+
var _importError$response, _importError$response2, _importError$response3, _importError$response4;
|
|
123
|
+
|
|
124
|
+
const message = (_importError$response = importError.response) === null || _importError$response === void 0 ? void 0 : (_importError$response2 = _importError$response.data) === null || _importError$response2 === void 0 ? void 0 : _importError$response2.message;
|
|
125
|
+
const detail = (_importError$response3 = importError.response) === null || _importError$response3 === void 0 ? void 0 : (_importError$response4 = _importError$response3.data) === null || _importError$response4 === void 0 ? void 0 : _importError$response4.detail;
|
|
126
|
+
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
127
|
+
failSpinner(`${detail ? message + ' - ' + detail : message}`);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
showSpinner(`Importing ${serviceId}...`);
|
|
131
|
+
failSpinner(`${serviceId} not found!`);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
debugMessage(`cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${file}]`);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Import first service from file
|
|
138
|
+
* @param {string} file import file name
|
|
139
|
+
* @param {boolean} clean remove existing service
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
export async function importFirstServiceFromFile(file, clean) {
|
|
143
|
+
debugMessage(`cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`);
|
|
144
|
+
const verbose = state.default.session.getVerbose();
|
|
145
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
146
|
+
if (err) throw err;
|
|
147
|
+
const importData = JSON.parse(data);
|
|
148
|
+
|
|
149
|
+
if (importData && Object.keys(importData.service).length) {
|
|
150
|
+
const serviceId = Object.keys(importData.service)[0];
|
|
151
|
+
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
155
|
+
await importService(serviceId, importData, clean);
|
|
156
|
+
succeedSpinner(`Imported ${serviceId}.`);
|
|
157
|
+
} catch (importError) {
|
|
158
|
+
var _importError$response5, _importError$response6, _importError$response7, _importError$response8;
|
|
159
|
+
|
|
160
|
+
const message = (_importError$response5 = importError.response) === null || _importError$response5 === void 0 ? void 0 : (_importError$response6 = _importError$response5.data) === null || _importError$response6 === void 0 ? void 0 : _importError$response6.message;
|
|
161
|
+
const detail = (_importError$response7 = importError.response) === null || _importError$response7 === void 0 ? void 0 : (_importError$response8 = _importError$response7.data) === null || _importError$response8 === void 0 ? void 0 : _importError$response8.detail;
|
|
162
|
+
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
163
|
+
failSpinner(`${detail ? message + ' - ' + detail : message}`);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
showSpinner(`Importing service...`);
|
|
167
|
+
failSpinner(`No service found in ${file}!`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
debugMessage(`cli.ServiceOps.importFirstServiceFromFile: end [file=${file}]`);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Import services from file
|
|
175
|
+
* @param {String} file file name
|
|
176
|
+
* @param {boolean} clean remove existing service
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
export async function importServicesFromFile(file, clean) {
|
|
180
|
+
debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);
|
|
181
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
182
|
+
if (err) throw err;
|
|
183
|
+
debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);
|
|
184
|
+
const importData = JSON.parse(data);
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
await importServices(importData, clean);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
printMessage(`${error.message}`, 'error');
|
|
190
|
+
printMessage(error.response.status, 'error');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
debugMessage(`cli.ServiceOps.importServiceFromFile: end [file=${file}]`);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Import all services from separate files
|
|
198
|
+
* @param {boolean} clean remove existing service
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
export async function importServicesFromFiles(clean) {
|
|
202
|
+
debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);
|
|
203
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
204
|
+
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.service.json'));
|
|
205
|
+
|
|
206
|
+
for (const file of agentFiles) {
|
|
207
|
+
await importServicesFromFile(file, clean);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Delete a service by id/name
|
|
214
|
+
* @param {string} serviceId Reference to the service to delete
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
export async function deleteService(serviceId) {
|
|
218
|
+
try {
|
|
219
|
+
await deleteFullService(serviceId);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
var _error$response, _error$response$data;
|
|
222
|
+
|
|
223
|
+
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;
|
|
224
|
+
printMessage(`Delete service '${serviceId}': ${message}`, 'error');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Delete all services
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
export async function deleteServices() {
|
|
232
|
+
await deleteFullServices();
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=ServiceOps.js.map
|
|
@@ -0,0 +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,EAAP,MAAe,IAAf;AACA,SACEC,YADF,EAEEC,WAFF,EAGEC,YAHF,EAIEC,WAJF,EAKEC,cALF,EAMEC,WANF,QAOO,kBAPP;AAQA,SACEC,iBADF,EAEEC,OAFF,EAGEC,KAHF,EAIEC,KAJF,QAKO,uBALP;AAQA,MAAM;EACJC,2BADI;EAEJC,kBAFI;EAGJC,iBAHI;EAIJC,iBAJI;EAKJC,e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AMqD,UAAU,GAAGF,KAAK,CAACG,MAAN,CAAcvC,IAAD,IAC9BA,IAAI,CAACwC,WAAL,GAAmBC,QAAnB,CAA4B,eAA5B,CADiB,CAAnB;;EAGA,KAAK,MAAMpC,IAAX,IAAmBiC,UAAnB,EAA+B;IAC7B,MAAML,sBAAsB,CAAC5B,IAAD,EAAOW,KAAP,CAA5B;EACD;;EACDjD,YAAY,CAAE,6CAAF,CAAZ;AACD;AAED;AACA;AACA;AACA;;AACA,OAAO,eAAe2E,aAAf,CAA6B9B,SAA7B,EAAgD;EACrD,IAAI;IACF,MAAMnC,iBAAiB,CAACmC,SAAD,CAAvB;EACD,CAFD,CAEE,OAAOV,KAAP,EAAc;IAAA;;IACd,MAAMwB,OAAO,sBAAGxB,KAAK,CAACyB,QAAT,4EAAG,gBAAgBN,IAAnB,yDAAG,qBAAsBK,OAAtC;IACA7D,YAAY,CAAE,mBAAkB+C,SAAU,MAAKc,OAAQ,EAA3C,EAA8C,OAA9C,CAAZ;EACD;AACF;AAED;AACA;AACA;;AACA,OAAO,eAAeiB,cAAf,GAAgC;EACrC,MAAMnE,kBAAkB,EAAxB;AACD"}
|
package/esm/utils/Console.js
CHANGED
|
@@ -14,6 +14,8 @@ const {
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
function data(message, newline = true) {
|
|
17
|
+
if (!message) return;
|
|
18
|
+
|
|
17
19
|
if (state.default.session.getOutputFile()) {
|
|
18
20
|
if (typeof message === 'object') {
|
|
19
21
|
message = JSON.stringify(message, null, 2);
|
|
@@ -41,6 +43,8 @@ function data(message, newline = true) {
|
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
function text(message, newline = true) {
|
|
46
|
+
if (!message) return;
|
|
47
|
+
|
|
44
48
|
if (typeof message === 'object') {
|
|
45
49
|
console.dir(message, {
|
|
46
50
|
depth: 3
|
|
@@ -58,6 +62,8 @@ function text(message, newline = true) {
|
|
|
58
62
|
|
|
59
63
|
|
|
60
64
|
function info(message, newline = true) {
|
|
65
|
+
if (!message) return;
|
|
66
|
+
|
|
61
67
|
if (typeof message === 'object') {
|
|
62
68
|
console.dir(message, {
|
|
63
69
|
depth: 3
|
|
@@ -75,6 +81,8 @@ function info(message, newline = true) {
|
|
|
75
81
|
|
|
76
82
|
|
|
77
83
|
function warn(message, newline = true) {
|
|
84
|
+
if (!message) return;
|
|
85
|
+
|
|
78
86
|
if (typeof message === 'object') {
|
|
79
87
|
console.dir(message, {
|
|
80
88
|
depth: 3
|
|
@@ -92,6 +100,8 @@ function warn(message, newline = true) {
|
|
|
92
100
|
|
|
93
101
|
|
|
94
102
|
function error(message, newline = true) {
|
|
103
|
+
if (!message) return;
|
|
104
|
+
|
|
95
105
|
if (typeof message === 'object') {
|
|
96
106
|
console.dir(message, {
|
|
97
107
|
depth: 3
|
|
@@ -109,6 +119,8 @@ function error(message, newline = true) {
|
|
|
109
119
|
|
|
110
120
|
|
|
111
121
|
function debug(message, newline = true) {
|
|
122
|
+
if (!message) return;
|
|
123
|
+
|
|
112
124
|
if (typeof message === 'object') {
|
|
113
125
|
console.dir(message, {
|
|
114
126
|
depth: 6
|
|
@@ -126,6 +138,7 @@ function debug(message, newline = true) {
|
|
|
126
138
|
|
|
127
139
|
|
|
128
140
|
function curlirize(message) {
|
|
141
|
+
if (!message) return;
|
|
129
142
|
console.error(message['brightBlue']);
|
|
130
143
|
}
|
|
131
144
|
/**
|
|
@@ -135,6 +148,8 @@ function curlirize(message) {
|
|
|
135
148
|
|
|
136
149
|
|
|
137
150
|
export function verboseMessage(message) {
|
|
151
|
+
if (!message) return;
|
|
152
|
+
|
|
138
153
|
if (state.default.session.getVerbose()) {
|
|
139
154
|
text(message);
|
|
140
155
|
}
|
|
@@ -145,6 +160,8 @@ export function verboseMessage(message) {
|
|
|
145
160
|
*/
|
|
146
161
|
|
|
147
162
|
export function debugMessage(message) {
|
|
163
|
+
if (!message) return;
|
|
164
|
+
|
|
148
165
|
if (state.default.session.getDebug()) {
|
|
149
166
|
debug(message);
|
|
150
167
|
}
|
|
@@ -155,6 +172,8 @@ export function debugMessage(message) {
|
|
|
155
172
|
*/
|
|
156
173
|
|
|
157
174
|
export function curlirizeMessage(message) {
|
|
175
|
+
if (!message) return;
|
|
176
|
+
|
|
158
177
|
if (state.default.session.getCurlirize()) {
|
|
159
178
|
curlirize(message);
|
|
160
179
|
}
|