@node-cli/logger 1.2.5 → 1.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/dist/Logger.js.map +1 -1
- package/package.json +3 -3
package/dist/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Logger.ts"],"sourcesContent":["import boxen, { Options as BoxenOptions } from \"boxen\";\nimport ora, { Ora, Options as OraOptions } from \"ora\";\n\nimport util from \"node:util\";\nimport kleur from \"kleur\";\n\nexport type PrintBoxOptions = {\n\tnewLineAfter?: boolean;\n\tnewLineBefore?: boolean;\n} & BoxenOptions;\n\nexport class Logger {\n\t#shouldLog: boolean;\n\t#globalPrefix: string;\n\t#showTimestamp: boolean;\n\t#printOptions: { colors: boolean; compact: boolean; depth: number };\n\n\tconstructor({\n\t\tboring = false,\n\t\tsilent = false,\n\t\tprefix = \"\",\n\t\ttimestamp = false,\n\t} = {}) {\n\t\tthis.#shouldLog = !silent;\n\t\tthis.#globalPrefix = prefix;\n\t\tthis.#showTimestamp = timestamp;\n\t\tthis.#printOptions = {\n\t\t\tcolors: !boring,\n\t\t\tcompact: false,\n\t\t\tdepth: 5,\n\t\t};\n\t}\n\n\tset silent(flag: boolean) {\n\t\tthis.#shouldLog = !flag;\n\t}\n\n\tset boring(flag: boolean) {\n\t\tthis.#printOptions.colors = !flag;\n\t}\n\n\tset prefix(prefix: string) {\n\t\tthis.#globalPrefix = prefix;\n\t}\n\n\tset timestamp(flag: boolean) {\n\t\tthis.#showTimestamp = flag;\n\t}\n\n\t#_log(\n\t\ttype: { method: string | number; color: (argument0: any) => any },\n\t\t...arguments_: string[]\n\t) {\n\t\tif (this.#shouldLog) {\n\t\t\tlet message: string;\n\t\t\tif (!this.#showTimestamp && !this.#globalPrefix) {\n\t\t\t\tmessage = util.formatWithOptions(this.#printOptions, ...arguments_);\n\t\t\t} else {\n\t\t\t\tconst prefix = this.#globalPrefix ? [this.#globalPrefix] : [];\n\t\t\t\tif (this.#showTimestamp) {\n\t\t\t\t\tconst now = new Date();\n\t\t\t\t\tprefix.push(\n\t\t\t\t\t\tthis.#printOptions.colors\n\t\t\t\t\t\t\t? `${kleur.grey(\n\t\t\t\t\t\t\t\t\t`[ ${now.toDateString()} ${now.toLocaleTimeString()} ]`,\n\t\t\t\t\t\t\t\t)}`\n\t\t\t\t\t\t\t: `[ ${now.toDateString()} ${now.toLocaleTimeString()} ]`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tmessage = util.formatWithOptions(\n\t\t\t\t\tthis.#printOptions,\n\t\t\t\t\tprefix.join(\" \"),\n\t\t\t\t\t...arguments_,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole[type.method](\n\t\t\t\tthis.#printOptions.colors ? `${type.color(message)}` : message,\n\t\t\t);\n\t\t}\n\t}\n\n\tinfo(...arguments_: any) {\n\t\tthis.#_log({ method: \"info\", color: kleur.blue }, ...arguments_);\n\t}\n\n\tlog(...arguments_: any) {\n\t\tthis.#_log({ method: \"log\", color: kleur.white }, ...arguments_);\n\t}\n\n\tdebug(...arguments_: any) {\n\t\tthis.#_log({ method: \"debug\", color: kleur.grey }, ...arguments_);\n\t}\n\n\twarn(...arguments_: any) {\n\t\tthis.#_log({ method: \"warn\", color: kleur.yellow }, ...arguments_);\n\t}\n\n\terror(...arguments_: any) {\n\t\tthis.#_log({ method: \"error\", color: kleur.red }, ...arguments_);\n\t}\n\n\t/**\n\t * Log multiple error messages at the prompt using `console.error` behind the scenes.\n\t * @param {string[]} errorMessages array of error message to display line by line\n\t * @param {number} [exitStatus] the process will exit with this value if provided\n\t */\n\tprintErrorsAndExit(errorMessages: string[], exitStatus?: number) {\n\t\tif (errorMessages && errorMessages.length > 0) {\n\t\t\tthis.log();\n\t\t\tfor (const message of errorMessages) {\n\t\t\t\tthis.error(message);\n\t\t\t}\n\t\t\tthis.log();\n\n\t\t\tif (typeof exitStatus === \"number\") {\n\t\t\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\t\t\tprocess.exit(exitStatus);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Print sets of logs in a box (wrapper to Boxen)\n\t * @param messages Messages to print\n\t * @param options\n\t */\n\tprintBox(messages: string | string[], options: PrintBoxOptions = {}) {\n\t\tconst { newLineAfter, newLineBefore } = {\n\t\t\tnewLineAfter: true,\n\t\t\tnewLineBefore: true,\n\t\t\t...options,\n\t\t};\n\n\t\t/**\n\t\t * Setting some sensible Boxen options if\n\t\t * not provided by the user.\n\t\t */\n\t\tconst borderColor = options.borderColor || \"yellow\";\n\t\tconst boxenOptions: BoxenOptions = {\n\t\t\t...options,\n\t\t\tborderColor: this.#printOptions.colors ? borderColor : \"white\",\n\t\t\tpadding: typeof options.padding === \"number\" ? options.padding : 1,\n\t\t\ttextAlignment: options.textAlignment || \"center\",\n\t\t};\n\n\t\tconst oldPrefix = this.#globalPrefix;\n\t\tconst oldTimestamp = this.#showTimestamp;\n\n\t\tthis.#globalPrefix = \"\";\n\t\tthis.#showTimestamp = false;\n\n\t\tnewLineBefore && this.log();\n\t\tthis.log(\n\t\t\tboxen(\n\t\t\t\ttypeof messages === \"string\" ? messages : messages.join(\"\\n\"),\n\t\t\t\tboxenOptions,\n\t\t\t),\n\t\t);\n\t\tnewLineAfter && this.log();\n\n\t\tthis.#showTimestamp = oldTimestamp;\n\t\tthis.#globalPrefix = oldPrefix;\n\t}\n}\n\n/* istanbul ignore next */\nexport class Spinner {\n\tspinner: Ora;\n\n\tconstructor(options?: OraOptions) {\n\t\tthis.spinner = ora({\n\t\t\t...options,\n\t\t\tisSilent: process.env.NODE_ENV === \"test\",\n\t\t});\n\t}\n\n\tset text(message: string) {\n\t\tthis.spinner.text = message;\n\t}\n\n\tstart(message?: string) {\n\t\tthis.spinner.start(message);\n\t}\n\n\tstop(message?: string, type?: string) {\n\t\tswitch (type) {\n\t\t\tcase Spinner.ERROR: {\n\t\t\t\tthis.spinner.fail(message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Spinner.WARNING: {\n\t\t\t\tthis.spinner.warn(message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Spinner.INFO: {\n\t\t\t\tthis.spinner.info(message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.spinner.succeed(message);\n\t\t\t\t}, 1000);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic SUCCESS = \"success\";\n\tstatic ERROR = \"fail\";\n\tstatic WARNING = \"warn\";\n\tstatic INFO = \"info\";\n}\n"],"names":["boxen","ora","util","kleur","Logger","shouldLog","globalPrefix","showTimestamp","printOptions","constructor","boring","silent","prefix","timestamp","colors","compact","depth","flag","_log","type","arguments_","message","formatWithOptions","now","Date","push","grey","toDateString","toLocaleTimeString","join","console","method","color","info","blue","log","white","debug","warn","yellow","error","red","printErrorsAndExit","errorMessages","exitStatus","length","process","exit","printBox","messages","options","newLineAfter","newLineBefore","borderColor","boxenOptions","padding","textAlignment","oldPrefix","oldTimestamp","Spinner","spinner","isSilent","env","NODE_ENV","text","start","stop","ERROR","fail","WARNING","INFO","setTimeout","succeed","SUCCESS"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,WAAwC,QAAQ;AACvD,OAAOC,SAAyC,MAAM;AAEtD,OAAOC,UAAU,YAAY;AAC7B,OAAOC,WAAW,QAAQ;AAO1B,OAAO,MAAMC;IACZ,CAACC,SAAS,CAAU;IACpB,CAACC,YAAY,CAAS;IACtB,CAACC,aAAa,CAAU;IACxB,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AQ,KAAK;QACpC;IACD;IAEA,IAAIC,KAAK3C,OAAe,EAAE;QACzB,IAAI,CAACuC,OAAO,CAACI,IAAI,GAAG3C;IACrB;IAEA4C,MAAM5C,OAAgB,EAAE;QACvB,IAAI,CAACuC,OAAO,CAACK,KAAK,CAAC5C;IACpB;IAEA6C,KAAK7C,OAAgB,EAAEF,IAAa,EAAE;QACrC,OAAQA;YACP,KAAKwC,QAAQQ,KAAK;gBAAE;oBACnB,IAAI,CAACP,OAAO,CAACQ,IAAI,CAAC/C;oBAClB;gBACD;YACA,KAAKsC,QAAQU,OAAO;gBAAE;oBACrB,IAAI,CAACT,OAAO,CAACtB,IAAI,CAACjB;oBAClB;gBACD;YACA,KAAKsC,QAAQW,IAAI;gBAAE;oBAClB,IAAI,CAACV,OAAO,CAAC3B,IAAI,CAACZ;oBAClB;gBACD;YACA;gBAAS;oBACRkD,WAAW;wBACV,IAAI,CAACX,OAAO,CAACY,OAAO,CAACnD;oBACtB,GAAG;oBACH;gBACD;QACD;IACD;IAEA,OAAOoD,UAAU,UAAU;IAC3B,OAAON,QAAQ,OAAO;IACtB,OAAOE,UAAU,OAAO;IACxB,OAAOC,OAAO,OAAO;AACtB"}
|
|
1
|
+
{"version":3,"sources":["../src/Logger.ts"],"sourcesContent":["import boxen, { Options as BoxenOptions } from \"boxen\";\nimport ora, { Ora, Options as OraOptions } from \"ora\";\n\nimport util from \"node:util\";\nimport kleur from \"kleur\";\n\nexport type PrintBoxOptions = {\n\tnewLineAfter?: boolean;\n\tnewLineBefore?: boolean;\n} & BoxenOptions;\n\nexport class Logger {\n\t#shouldLog: boolean;\n\t#globalPrefix: string;\n\t#showTimestamp: boolean;\n\t#printOptions: { colors: boolean; compact: boolean; depth: number };\n\n\tconstructor({\n\t\tboring = false,\n\t\tsilent = false,\n\t\tprefix = \"\",\n\t\ttimestamp = false,\n\t} = {}) {\n\t\tthis.#shouldLog = !silent;\n\t\tthis.#globalPrefix = prefix;\n\t\tthis.#showTimestamp = timestamp;\n\t\tthis.#printOptions = {\n\t\t\tcolors: !boring,\n\t\t\tcompact: false,\n\t\t\tdepth: 5,\n\t\t};\n\t}\n\n\tset silent(flag: boolean) {\n\t\tthis.#shouldLog = !flag;\n\t}\n\n\tset boring(flag: boolean) {\n\t\tthis.#printOptions.colors = !flag;\n\t}\n\n\tset prefix(prefix: string) {\n\t\tthis.#globalPrefix = prefix;\n\t}\n\n\tset timestamp(flag: boolean) {\n\t\tthis.#showTimestamp = flag;\n\t}\n\n\t#_log(\n\t\ttype: { method: string | number; color: (argument0: any) => any },\n\t\t...arguments_: string[]\n\t) {\n\t\tif (this.#shouldLog) {\n\t\t\tlet message: string;\n\t\t\tif (!this.#showTimestamp && !this.#globalPrefix) {\n\t\t\t\tmessage = util.formatWithOptions(this.#printOptions, ...arguments_);\n\t\t\t} else {\n\t\t\t\tconst prefix = this.#globalPrefix ? [this.#globalPrefix] : [];\n\t\t\t\tif (this.#showTimestamp) {\n\t\t\t\t\tconst now = new Date();\n\t\t\t\t\tprefix.push(\n\t\t\t\t\t\tthis.#printOptions.colors\n\t\t\t\t\t\t\t? `${kleur.grey(\n\t\t\t\t\t\t\t\t\t`[ ${now.toDateString()} ${now.toLocaleTimeString()} ]`,\n\t\t\t\t\t\t\t\t)}`\n\t\t\t\t\t\t\t: `[ ${now.toDateString()} ${now.toLocaleTimeString()} ]`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tmessage = util.formatWithOptions(\n\t\t\t\t\tthis.#printOptions,\n\t\t\t\t\tprefix.join(\" \"),\n\t\t\t\t\t...arguments_,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole[type.method](\n\t\t\t\tthis.#printOptions.colors ? `${type.color(message)}` : message,\n\t\t\t);\n\t\t}\n\t}\n\n\tinfo(...arguments_: any) {\n\t\tthis.#_log({ method: \"info\", color: kleur.blue }, ...arguments_);\n\t}\n\n\tlog(...arguments_: any) {\n\t\tthis.#_log({ method: \"log\", color: kleur.white }, ...arguments_);\n\t}\n\n\tdebug(...arguments_: any) {\n\t\tthis.#_log({ method: \"debug\", color: kleur.grey }, ...arguments_);\n\t}\n\n\twarn(...arguments_: any) {\n\t\tthis.#_log({ method: \"warn\", color: kleur.yellow }, ...arguments_);\n\t}\n\n\terror(...arguments_: any) {\n\t\tthis.#_log({ method: \"error\", color: kleur.red }, ...arguments_);\n\t}\n\n\t/**\n\t * Log multiple error messages at the prompt using `console.error` behind the scenes.\n\t * @param {string[]} errorMessages array of error message to display line by line\n\t * @param {number} [exitStatus] the process will exit with this value if provided\n\t */\n\tprintErrorsAndExit(errorMessages: string[], exitStatus?: number) {\n\t\tif (errorMessages && errorMessages.length > 0) {\n\t\t\tthis.log();\n\t\t\tfor (const message of errorMessages) {\n\t\t\t\tthis.error(message);\n\t\t\t}\n\t\t\tthis.log();\n\n\t\t\tif (typeof exitStatus === \"number\") {\n\t\t\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\t\t\tprocess.exit(exitStatus);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Print sets of logs in a box (wrapper to Boxen)\n\t * @param messages Messages to print\n\t * @param options\n\t */\n\tprintBox(messages: string | string[], options: PrintBoxOptions = {}) {\n\t\tconst { newLineAfter, newLineBefore } = {\n\t\t\tnewLineAfter: true,\n\t\t\tnewLineBefore: true,\n\t\t\t...options,\n\t\t};\n\n\t\t/**\n\t\t * Setting some sensible Boxen options if\n\t\t * not provided by the user.\n\t\t */\n\t\tconst borderColor = options.borderColor || \"yellow\";\n\t\tconst boxenOptions: BoxenOptions = {\n\t\t\t...options,\n\t\t\tborderColor: this.#printOptions.colors ? borderColor : \"white\",\n\t\t\tpadding: typeof options.padding === \"number\" ? options.padding : 1,\n\t\t\ttextAlignment: options.textAlignment || \"center\",\n\t\t};\n\n\t\tconst oldPrefix = this.#globalPrefix;\n\t\tconst oldTimestamp = this.#showTimestamp;\n\n\t\tthis.#globalPrefix = \"\";\n\t\tthis.#showTimestamp = false;\n\n\t\tnewLineBefore && this.log();\n\t\tthis.log(\n\t\t\tboxen(\n\t\t\t\ttypeof messages === \"string\" ? messages : messages.join(\"\\n\"),\n\t\t\t\tboxenOptions,\n\t\t\t),\n\t\t);\n\t\tnewLineAfter && this.log();\n\n\t\tthis.#showTimestamp = oldTimestamp;\n\t\tthis.#globalPrefix = oldPrefix;\n\t}\n}\n\n/* istanbul ignore next */\nexport class Spinner {\n\tspinner: Ora;\n\n\tconstructor(options?: OraOptions) {\n\t\tthis.spinner = ora({\n\t\t\t...options,\n\t\t\tisSilent: process.env.NODE_ENV === \"test\",\n\t\t});\n\t}\n\n\tset text(message: string) {\n\t\tthis.spinner.text = message;\n\t}\n\n\tstart(message?: string) {\n\t\tthis.spinner.start(message);\n\t}\n\n\tstop(message?: string, type?: string) {\n\t\tswitch (type) {\n\t\t\tcase Spinner.ERROR: {\n\t\t\t\tthis.spinner.fail(message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Spinner.WARNING: {\n\t\t\t\tthis.spinner.warn(message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Spinner.INFO: {\n\t\t\t\tthis.spinner.info(message);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.spinner.succeed(message);\n\t\t\t\t}, 1000);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic SUCCESS = \"success\";\n\tstatic ERROR = \"fail\";\n\tstatic WARNING = \"warn\";\n\tstatic INFO = \"info\";\n}\n"],"names":["boxen","ora","util","kleur","Logger","constructor","boring","silent","prefix","timestamp","colors","compact","depth","flag","type","arguments_","message","formatWithOptions","now","Date","push","grey","toDateString","toLocaleTimeString","join","console","method","color","info","blue","log","white","debug","warn","yellow","error","red","printErrorsAndExit","errorMessages","exitStatus","length","process","exit","printBox","messages","options","newLineAfter","newLineBefore","borderColor","boxenOptions","padding","textAlignment","oldPrefix","oldTimestamp","Spinner","spinner","isSilent","env","NODE_ENV","text","start","stop","ERROR","fail","WARNING","INFO","setTimeout","succeed","SUCCESS"],"mappings":"AAAA,OAAOA,WAAwC,QAAQ;AACvD,OAAOC,SAAyC,MAAM;AAEtD,OAAOC,UAAU,YAAY;AAC7B,OAAOC,WAAW,QAAQ;AAO1B,OAAO,MAAMC;IACZ,CAAA,SAAU,CAAU;IACpB,CAAA,YAAa,CAAS;IACtB,CAAA,aAAc,CAAU;IACxB,CAAA,YAAa,CAAuD;IAEpEC,YAAY,EACXC,SAAS,KAAK,EACdC,SAAS,KAAK,EACdC,SAAS,EAAE,EACXC,YAAY,KAAK,EACjB,GAAG,CAAC,CAAC,CAAE;QACP,IAAI,CAAC,CAAA,SAAU,GAAG,CAACF;QACnB,IAAI,CAAC,CAAA,YAAa,GAAGC;QACrB,IAAI,CAAC,CAAA,aAAc,GAAGC;QACtB,IAAI,CAAC,CAAA,YAAa,GAAG;YACpBC,QAAQ,CAACJ;YACTK,SAAS;YACTC,OAAO;QACR;IACD;IAEA,IAAIL,OAAOM,IAAa,EAAE;QACzB,IAAI,CAAC,CAAA,SAAU,GAAG,CAACA;IACpB;IAEA,IAAIP,OAAOO,IAAa,EAAE;QACzB,IAAI,CAAC,CAAA,YAAa,CAACH,MAAM,GAAG,CAACG;IAC9B;IAEA,IAAIL,OAAOA,MAAc,EAAE;QAC1B,IAAI,CAAC,CAAA,YAAa,GAAGA;IACtB;IAEA,IAAIC,UAAUI,IAAa,EAAE;QAC5B,IAAI,CAAC,CAAA,aAAc,GAAGA;IACvB;IAEA,CAAA,IAAK,CACJC,IAAiE,EACjE,GAAGC,UAAoB;QAEvB,IAAI,IAAI,CAAC,CAAA,SAAU,EAAE;YACpB,IAAIC;YACJ,IAAI,CAAC,IAAI,CAAC,CAAA,aAAc,IAAI,CAAC,IAAI,CAAC,CAAA,YAAa,EAAE;gBAChDA,UAAUd,KAAKe,iBAAiB,CAAC,IAAI,CAAC,CAAA,YAAa,KAA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;QAExB,IAAI,CAAC,CAAA,aAAc,GAAGuB;QACtB,IAAI,CAAC,CAAA,YAAa,GAAGD;IACtB;AACD;AAEA,wBAAwB,GACxB,OAAO,MAAME;IACZC,QAAa;IAEblD,YAAYwC,OAAoB,CAAE;QACjC,IAAI,CAACU,OAAO,GAAGtD,IAAI;YAClB,GAAG4C,OAAO;YACVW,UAAUf,QAAQgB,GAAG,CAACC,QAAQ,KAAK;QACpC;IACD;IAEA,IAAIC,KAAK3C,OAAe,EAAE;QACzB,IAAI,CAACuC,OAAO,CAACI,IAAI,GAAG3C;IACrB;IAEA4C,MAAM5C,OAAgB,EAAE;QACvB,IAAI,CAACuC,OAAO,CAACK,KAAK,CAAC5C;IACpB;IAEA6C,KAAK7C,OAAgB,EAAEF,IAAa,EAAE;QACrC,OAAQA;YACP,KAAKwC,QAAQQ,KAAK;gBAAE;oBACnB,IAAI,CAACP,OAAO,CAACQ,IAAI,CAAC/C;oBAClB;gBACD;YACA,KAAKsC,QAAQU,OAAO;gBAAE;oBACrB,IAAI,CAACT,OAAO,CAACtB,IAAI,CAACjB;oBAClB;gBACD;YACA,KAAKsC,QAAQW,IAAI;gBAAE;oBAClB,IAAI,CAACV,OAAO,CAAC3B,IAAI,CAACZ;oBAClB;gBACD;YACA;gBAAS;oBACRkD,WAAW;wBACV,IAAI,CAACX,OAAO,CAACY,OAAO,CAACnD;oBACtB,GAAG;oBACH;gBACD;QACD;IACD;IAEA,OAAOoD,UAAU,UAAU;IAC3B,OAAON,QAAQ,OAAO;IACtB,OAAOE,UAAU,OAAO;IACxB,OAAOC,OAAO,OAAO;AACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/logger",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "A tiny console logger for nodejs CLI apps",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"boxen": "7.1.1",
|
|
15
15
|
"kleur": "4.1.5",
|
|
16
|
-
"ora": "8.
|
|
16
|
+
"ora": "8.1.1"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "npm-run-all --serial clean build:types build:js build:barrel",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "40e92aa4e7b59c7cda398529ef00cd0fab944644"
|
|
33
33
|
}
|