@hubspot/local-dev-lib 5.3.1 → 5.3.2-beta.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/isUnicodeSupported.d.ts +1 -0
- package/lib/isUnicodeSupported.js +14 -0
- package/lib/logger.d.ts +9 -0
- package/lib/logger.js +28 -5
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isUnicodeSupported(): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Adapted from https://github.com/sindresorhus/is-unicode-supported (MIT)
|
|
2
|
+
export function isUnicodeSupported() {
|
|
3
|
+
if (process.platform !== 'win32') {
|
|
4
|
+
return process.env.TERM !== 'linux';
|
|
5
|
+
}
|
|
6
|
+
return (Boolean(process.env.WT_SESSION) ||
|
|
7
|
+
Boolean(process.env.TERMINUS_SUBLIME) ||
|
|
8
|
+
process.env.ConEmuTask === '{cmd::Cmder}' ||
|
|
9
|
+
process.env.TERM_PROGRAM === 'Terminus-Sublime' ||
|
|
10
|
+
process.env.TERM_PROGRAM === 'vscode' ||
|
|
11
|
+
process.env.TERM === 'xterm-256color' ||
|
|
12
|
+
process.env.TERM === 'alacritty' ||
|
|
13
|
+
process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm');
|
|
14
|
+
}
|
package/lib/logger.d.ts
CHANGED
|
@@ -6,6 +6,14 @@ export declare const LOG_LEVEL: {
|
|
|
6
6
|
WARN: number;
|
|
7
7
|
ERROR: number;
|
|
8
8
|
};
|
|
9
|
+
interface LogLabels {
|
|
10
|
+
success: string;
|
|
11
|
+
warning: string;
|
|
12
|
+
error: string;
|
|
13
|
+
info: string;
|
|
14
|
+
debug: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function getLabels(): LogLabels;
|
|
9
17
|
/**
|
|
10
18
|
* Chalk styles for logger strings.
|
|
11
19
|
*/
|
|
@@ -42,3 +50,4 @@ export declare const logger: {
|
|
|
42
50
|
group(...args: any[]): void;
|
|
43
51
|
groupEnd(): void;
|
|
44
52
|
};
|
|
53
|
+
export {};
|
package/lib/logger.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
+
import { isUnicodeSupported } from './isUnicodeSupported.js';
|
|
3
4
|
export const LOG_LEVEL = {
|
|
4
5
|
NONE: 0,
|
|
5
6
|
DEBUG: 1,
|
|
@@ -7,6 +8,23 @@ export const LOG_LEVEL = {
|
|
|
7
8
|
WARN: 4,
|
|
8
9
|
ERROR: 8,
|
|
9
10
|
};
|
|
11
|
+
const UNICODE_LABELS = {
|
|
12
|
+
success: '✔ SUCCESS',
|
|
13
|
+
warning: '⚠ WARNING',
|
|
14
|
+
error: '✖ ERROR',
|
|
15
|
+
info: 'ℹ INFO',
|
|
16
|
+
debug: 'DEBUG',
|
|
17
|
+
};
|
|
18
|
+
const ASCII_LABELS = {
|
|
19
|
+
success: '[SUCCESS]',
|
|
20
|
+
warning: '[WARNING]',
|
|
21
|
+
error: '[ERROR]',
|
|
22
|
+
info: '[INFO]',
|
|
23
|
+
debug: '[DEBUG]',
|
|
24
|
+
};
|
|
25
|
+
export function getLabels() {
|
|
26
|
+
return isUnicodeSupported() ? UNICODE_LABELS : ASCII_LABELS;
|
|
27
|
+
}
|
|
10
28
|
/**
|
|
11
29
|
* Chalk styles for logger strings.
|
|
12
30
|
*/
|
|
@@ -28,22 +46,27 @@ export function stylize(label, style, args) {
|
|
|
28
46
|
}
|
|
29
47
|
export class Logger {
|
|
30
48
|
error(...args) {
|
|
31
|
-
|
|
49
|
+
const labels = getLabels();
|
|
50
|
+
console.error(...stylize(labels.error, Styles.error, args));
|
|
32
51
|
}
|
|
33
52
|
warn(...args) {
|
|
34
|
-
|
|
53
|
+
const labels = getLabels();
|
|
54
|
+
console.warn(...stylize(labels.warning, Styles.warn, args));
|
|
35
55
|
}
|
|
36
56
|
log(...args) {
|
|
37
57
|
console.log(...args);
|
|
38
58
|
}
|
|
39
59
|
success(...args) {
|
|
40
|
-
|
|
60
|
+
const labels = getLabels();
|
|
61
|
+
console.log(...stylize(labels.success, Styles.success, args));
|
|
41
62
|
}
|
|
42
63
|
info(...args) {
|
|
43
|
-
|
|
64
|
+
const labels = getLabels();
|
|
65
|
+
console.info(...stylize(labels.info, Styles.info, args));
|
|
44
66
|
}
|
|
45
67
|
debug(...args) {
|
|
46
|
-
|
|
68
|
+
const labels = getLabels();
|
|
69
|
+
console.debug(...stylize(labels.debug, Styles.log, args));
|
|
47
70
|
}
|
|
48
71
|
group(...args) {
|
|
49
72
|
console.group(...args);
|