@zokugun/cli-utils 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/logger.cjs +11 -1
- package/lib/cjs/logger.d.cts +2 -0
- package/lib/esm/logger.d.mts +2 -0
- package/lib/esm/logger.mjs +10 -1
- package/package.json +2 -1
package/lib/cjs/logger.cjs
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.begin = begin;
|
|
7
7
|
exports.check = check;
|
|
8
8
|
exports.error = error;
|
|
9
|
+
exports.fatal = fatal;
|
|
9
10
|
exports.finish = finish;
|
|
10
11
|
exports.info = info;
|
|
11
12
|
exports.newLine = newLine;
|
|
@@ -16,6 +17,7 @@ exports.step = step;
|
|
|
16
17
|
exports.stop = stop;
|
|
17
18
|
exports.success = success;
|
|
18
19
|
exports.warn = warn;
|
|
20
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
19
21
|
const log_update_plus_1 = require("@zokugun/log-update-plus");
|
|
20
22
|
const ansi_colors_1 = __importDefault(require("ansi-colors"));
|
|
21
23
|
const cli_spinners_1 = __importDefault(require("cli-spinners"));
|
|
@@ -30,9 +32,16 @@ function check(message) {
|
|
|
30
32
|
log_update_plus_1.stdout.persist(`${ansi_colors_1.default.green(ansi_colors_1.default.symbols.check)} ${message}`);
|
|
31
33
|
} // }}}
|
|
32
34
|
function error(message) {
|
|
33
|
-
|
|
35
|
+
log_update_plus_1.stdout.persist(`${ansi_colors_1.default.red(ansi_colors_1.default.symbols.cross)} ${ansi_colors_1.default.bold('Error!')}`);
|
|
34
36
|
log_update_plus_1.stdout.persist(message);
|
|
35
37
|
} // }}}
|
|
38
|
+
function fatal(message, code = 1) {
|
|
39
|
+
stop();
|
|
40
|
+
log_update_plus_1.stdout.persist(`${ansi_colors_1.default.red(ansi_colors_1.default.symbols.cross)} ${ansi_colors_1.default.bold('Fatal!')}`);
|
|
41
|
+
log_update_plus_1.stdout.persist(message);
|
|
42
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
43
|
+
node_process_1.default.exit(code);
|
|
44
|
+
} // }}}
|
|
36
45
|
function finish(duration) {
|
|
37
46
|
if (typeof duration !== 'number') {
|
|
38
47
|
if ($start === 0) {
|
|
@@ -92,6 +101,7 @@ exports.default = {
|
|
|
92
101
|
begin,
|
|
93
102
|
check,
|
|
94
103
|
error,
|
|
104
|
+
fatal,
|
|
95
105
|
finish,
|
|
96
106
|
info,
|
|
97
107
|
newLine,
|
package/lib/cjs/logger.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ export type IndicatorLoading = ReturnType<typeof setInterval>;
|
|
|
2
2
|
export declare function begin(): void;
|
|
3
3
|
export declare function check(message: string): void;
|
|
4
4
|
export declare function error(message: string): void;
|
|
5
|
+
export declare function fatal(message: string, code?: number): never;
|
|
5
6
|
export declare function finish(duration?: number): void;
|
|
6
7
|
export declare function info(message: string): void;
|
|
7
8
|
export declare function newLine(): void;
|
|
@@ -16,6 +17,7 @@ declare const _default: {
|
|
|
16
17
|
begin: typeof begin;
|
|
17
18
|
check: typeof check;
|
|
18
19
|
error: typeof error;
|
|
20
|
+
fatal: typeof fatal;
|
|
19
21
|
finish: typeof finish;
|
|
20
22
|
info: typeof info;
|
|
21
23
|
newLine: typeof newLine;
|
package/lib/esm/logger.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ export type IndicatorLoading = ReturnType<typeof setInterval>;
|
|
|
2
2
|
export declare function begin(): void;
|
|
3
3
|
export declare function check(message: string): void;
|
|
4
4
|
export declare function error(message: string): void;
|
|
5
|
+
export declare function fatal(message: string, code?: number): never;
|
|
5
6
|
export declare function finish(duration?: number): void;
|
|
6
7
|
export declare function info(message: string): void;
|
|
7
8
|
export declare function newLine(): void;
|
|
@@ -16,6 +17,7 @@ declare const _default: {
|
|
|
16
17
|
begin: typeof begin;
|
|
17
18
|
check: typeof check;
|
|
18
19
|
error: typeof error;
|
|
20
|
+
fatal: typeof fatal;
|
|
19
21
|
finish: typeof finish;
|
|
20
22
|
info: typeof info;
|
|
21
23
|
newLine: typeof newLine;
|
package/lib/esm/logger.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import { stdout } from '@zokugun/log-update-plus';
|
|
2
3
|
import c from 'ansi-colors';
|
|
3
4
|
import cliSpinners from 'cli-spinners';
|
|
@@ -12,9 +13,16 @@ export function check(message) {
|
|
|
12
13
|
stdout.persist(`${c.green(c.symbols.check)} ${message}`);
|
|
13
14
|
} // }}}
|
|
14
15
|
export function error(message) {
|
|
15
|
-
|
|
16
|
+
stdout.persist(`${c.red(c.symbols.cross)} ${c.bold('Error!')}`);
|
|
16
17
|
stdout.persist(message);
|
|
17
18
|
} // }}}
|
|
19
|
+
export function fatal(message, code = 1) {
|
|
20
|
+
stop();
|
|
21
|
+
stdout.persist(`${c.red(c.symbols.cross)} ${c.bold('Fatal!')}`);
|
|
22
|
+
stdout.persist(message);
|
|
23
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
24
|
+
process.exit(code);
|
|
25
|
+
} // }}}
|
|
18
26
|
export function finish(duration) {
|
|
19
27
|
if (typeof duration !== 'number') {
|
|
20
28
|
if ($start === 0) {
|
|
@@ -74,6 +82,7 @@ export default {
|
|
|
74
82
|
begin,
|
|
75
83
|
check,
|
|
76
84
|
error,
|
|
85
|
+
fatal,
|
|
77
86
|
finish,
|
|
78
87
|
info,
|
|
79
88
|
newLine,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zokugun/cli-utils",
|
|
3
3
|
"description": "Utils for CLI app",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baptiste Augrain",
|
|
7
7
|
"email": "daiyam@zokugun.org"
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"prepack": "npm run build",
|
|
79
79
|
"prepare": "husky; fixpack || true",
|
|
80
80
|
"release": "release-it",
|
|
81
|
+
"watch:build": "tsc-watch -p src --onSuccess 'npm run build'",
|
|
81
82
|
"watch:src": "tsc-watch -p src"
|
|
82
83
|
},
|
|
83
84
|
"dependencies": {
|