rslog 1.2.10 → 1.2.11
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/color.d.ts +8 -0
- package/dist/constants.d.ts +48 -0
- package/dist/createLogger.d.ts +2 -0
- package/dist/gradient.d.ts +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +4 -75
- package/dist/index.js +10 -9
- package/dist/types.d.ts +19 -0
- package/dist/utils.d.ts +2 -0
- package/package.json +3 -4
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ColorFn = (input: string | number | null | undefined) => string;
|
|
2
|
+
export declare const bold: ColorFn;
|
|
3
|
+
export declare const red: ColorFn;
|
|
4
|
+
export declare const green: ColorFn;
|
|
5
|
+
export declare const yellow: ColorFn;
|
|
6
|
+
export declare const magenta: ColorFn;
|
|
7
|
+
export declare const cyan: ColorFn;
|
|
8
|
+
export declare const gray: ColorFn;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare let LOG_LEVEL: {
|
|
2
|
+
readonly silent: -1;
|
|
3
|
+
readonly error: 0;
|
|
4
|
+
readonly warn: 1;
|
|
5
|
+
readonly info: 2;
|
|
6
|
+
readonly log: 2;
|
|
7
|
+
readonly verbose: 3;
|
|
8
|
+
};
|
|
9
|
+
export declare let LOG_TYPES: {
|
|
10
|
+
error: {
|
|
11
|
+
label: string;
|
|
12
|
+
level: "error";
|
|
13
|
+
color: import("./color.js").ColorFn;
|
|
14
|
+
};
|
|
15
|
+
warn: {
|
|
16
|
+
label: string;
|
|
17
|
+
level: "warn";
|
|
18
|
+
color: import("./color.js").ColorFn;
|
|
19
|
+
};
|
|
20
|
+
info: {
|
|
21
|
+
label: string;
|
|
22
|
+
level: "info";
|
|
23
|
+
color: import("./color.js").ColorFn;
|
|
24
|
+
};
|
|
25
|
+
start: {
|
|
26
|
+
label: string;
|
|
27
|
+
level: "info";
|
|
28
|
+
color: import("./color.js").ColorFn;
|
|
29
|
+
};
|
|
30
|
+
ready: {
|
|
31
|
+
label: string;
|
|
32
|
+
level: "info";
|
|
33
|
+
color: import("./color.js").ColorFn;
|
|
34
|
+
};
|
|
35
|
+
success: {
|
|
36
|
+
label: string;
|
|
37
|
+
level: "info";
|
|
38
|
+
color: import("./color.js").ColorFn;
|
|
39
|
+
};
|
|
40
|
+
log: {
|
|
41
|
+
level: "info";
|
|
42
|
+
};
|
|
43
|
+
debug: {
|
|
44
|
+
label: string;
|
|
45
|
+
level: "verbose";
|
|
46
|
+
color: import("./color.js").ColorFn;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare let gradient: (message: string) => string;
|
package/dist/index.cjs
CHANGED
|
@@ -99,6 +99,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
99
99
|
if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
100
100
|
if ('truecolor' === env.COLORTERM) return 3;
|
|
101
101
|
if ('xterm-kitty' === env.TERM) return 3;
|
|
102
|
+
if ('xterm-ghostty' === env.TERM) return 3;
|
|
102
103
|
if ('TERM_PROGRAM' in env) {
|
|
103
104
|
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
104
105
|
switch(env.TERM_PROGRAM){
|
package/dist/index.d.ts
CHANGED
|
@@ -1,75 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare let createLogger: (options?: Options) => Logger;
|
|
7
|
-
|
|
8
|
-
declare let LOG_TYPES: {
|
|
9
|
-
error: {
|
|
10
|
-
label: string;
|
|
11
|
-
level: "error";
|
|
12
|
-
color: ColorFn;
|
|
13
|
-
};
|
|
14
|
-
warn: {
|
|
15
|
-
label: string;
|
|
16
|
-
level: "warn";
|
|
17
|
-
color: ColorFn;
|
|
18
|
-
};
|
|
19
|
-
info: {
|
|
20
|
-
label: string;
|
|
21
|
-
level: "info";
|
|
22
|
-
color: ColorFn;
|
|
23
|
-
};
|
|
24
|
-
start: {
|
|
25
|
-
label: string;
|
|
26
|
-
level: "info";
|
|
27
|
-
color: ColorFn;
|
|
28
|
-
};
|
|
29
|
-
ready: {
|
|
30
|
-
label: string;
|
|
31
|
-
level: "info";
|
|
32
|
-
color: ColorFn;
|
|
33
|
-
};
|
|
34
|
-
success: {
|
|
35
|
-
label: string;
|
|
36
|
-
level: "info";
|
|
37
|
-
color: ColorFn;
|
|
38
|
-
};
|
|
39
|
-
log: {
|
|
40
|
-
level: "info";
|
|
41
|
-
};
|
|
42
|
-
debug: {
|
|
43
|
-
label: string;
|
|
44
|
-
level: "verbose";
|
|
45
|
-
color: ColorFn;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export declare type LogFunction = (message?: LogMessage, ...args: any[]) => void;
|
|
50
|
-
|
|
51
|
-
export declare type Logger = Record<LogMethods, LogFunction> & {
|
|
52
|
-
greet: (message: string) => void;
|
|
53
|
-
level: LogLevel;
|
|
54
|
-
override: (customLogger: Partial<Record<LogMethods, LogFunction>>) => void;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export declare let logger: Logger_2;
|
|
58
|
-
|
|
59
|
-
export declare type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
|
|
60
|
-
|
|
61
|
-
export declare type LogMessage = unknown;
|
|
62
|
-
|
|
63
|
-
declare type LogMethods = keyof typeof LOG_TYPES;
|
|
64
|
-
|
|
65
|
-
export declare interface LogType {
|
|
66
|
-
label?: string;
|
|
67
|
-
level: LogLevel;
|
|
68
|
-
color?: ColorFn_2;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export declare interface Options {
|
|
72
|
-
level?: LogLevel;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { }
|
|
1
|
+
import { createLogger } from './createLogger.js';
|
|
2
|
+
export { createLogger };
|
|
3
|
+
export declare let logger: import("./types.js").Logger;
|
|
4
|
+
export type { Options, Logger, LogType, LogLevel, LogMessage, LogFunction, } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args :
|
|
1
|
+
import node_process from "node:process";
|
|
2
|
+
import node_os from "node:os";
|
|
3
|
+
import node_tty from "node:tty";
|
|
4
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
5
5
|
const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
|
|
6
6
|
const position = argv.indexOf(prefix + flag);
|
|
7
7
|
const terminatorPosition = argv.indexOf('--');
|
|
8
8
|
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
9
9
|
}
|
|
10
|
-
const { env } =
|
|
10
|
+
const { env } = node_process;
|
|
11
11
|
let flagForceColor;
|
|
12
12
|
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
13
13
|
else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
|
|
@@ -47,8 +47,8 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
47
47
|
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
48
48
|
const min = forceColor || 0;
|
|
49
49
|
if ('dumb' === env.TERM) return min;
|
|
50
|
-
if ('win32' ===
|
|
51
|
-
const osRelease =
|
|
50
|
+
if ('win32' === node_process.platform) {
|
|
51
|
+
const osRelease = node_os.release().split('.');
|
|
52
52
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
53
53
|
return 1;
|
|
54
54
|
}
|
|
@@ -70,6 +70,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
70
70
|
if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
71
71
|
if ('truecolor' === env.COLORTERM) return 3;
|
|
72
72
|
if ('xterm-kitty' === env.TERM) return 3;
|
|
73
|
+
if ('xterm-ghostty' === env.TERM) return 3;
|
|
73
74
|
if ('TERM_PROGRAM' in env) {
|
|
74
75
|
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
75
76
|
switch(env.TERM_PROGRAM){
|
|
@@ -93,10 +94,10 @@ function createSupportsColor(stream, options = {}) {
|
|
|
93
94
|
}
|
|
94
95
|
const supportsColor = {
|
|
95
96
|
stdout: createSupportsColor({
|
|
96
|
-
isTTY:
|
|
97
|
+
isTTY: node_tty.isatty(1)
|
|
97
98
|
}),
|
|
98
99
|
stderr: createSupportsColor({
|
|
99
|
-
isTTY:
|
|
100
|
+
isTTY: node_tty.isatty(2)
|
|
100
101
|
})
|
|
101
102
|
};
|
|
102
103
|
const supports_color = supportsColor;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ColorFn } from './color.js';
|
|
2
|
+
import type { LOG_TYPES } from './constants.js';
|
|
3
|
+
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
|
|
4
|
+
export type LogMessage = unknown;
|
|
5
|
+
export interface LogType {
|
|
6
|
+
label?: string;
|
|
7
|
+
level: LogLevel;
|
|
8
|
+
color?: ColorFn;
|
|
9
|
+
}
|
|
10
|
+
export type LogFunction = (message?: LogMessage, ...args: any[]) => void;
|
|
11
|
+
export interface Options {
|
|
12
|
+
level?: LogLevel;
|
|
13
|
+
}
|
|
14
|
+
export type LogMethods = keyof typeof LOG_TYPES;
|
|
15
|
+
export type Logger = Record<LogMethods, LogFunction> & {
|
|
16
|
+
greet: (message: string) => void;
|
|
17
|
+
level: LogLevel;
|
|
18
|
+
override: (customLogger: Partial<Record<LogMethods, LogFunction>>) => void;
|
|
19
|
+
};
|
package/dist/utils.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rslog",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rspack-contrib/rslog.git"
|
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
"test": "rstest"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@rstest/core": "^0.0.6",
|
|
31
|
+
"@rslib/core": "^0.11.1",
|
|
32
|
+
"@rstest/core": "^0.1.0",
|
|
34
33
|
"@types/node": "^22.15.31",
|
|
35
34
|
"prettier": "~3.5.3",
|
|
36
35
|
"strip-ansi": "^7.1.0",
|