@teambit/logger 0.0.469 → 0.0.473
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.d.ts +33 -0
- package/dist/long-process-logger.d.ts +9 -0
- package/package.json +14 -6
- package/tsconfig.json +1 -2
- package/index.ts +0 -4
- package/logger.aspect.ts +0 -7
- package/logger.docs.mdx +0 -8
- package/logger.main.runtime.ts +0 -19
- package/logger.ts +0 -119
- package/long-process-logger.ts +0 -48
- package/package-tar/teambit-logger-0.0.469.tgz +0 -0
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
package/dist/logger.d.ts
CHANGED
|
@@ -10,16 +10,49 @@ export declare class Logger implements IBitLogger {
|
|
|
10
10
|
error(message: string, ...meta: any[]): void;
|
|
11
11
|
fatal(message: string, ...meta: any[]): void;
|
|
12
12
|
get isLoaderStarted(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
15
|
+
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
16
|
+
* components, then pass the `totalItems` as the total of the total components in the list.
|
|
17
|
+
* later, during the iteration, call `LongProcessLogger.logProgress(componentName)`.
|
|
18
|
+
* once done, call `LongProcessLogger.end()`
|
|
19
|
+
* the status-line will show all messages in the terminal.
|
|
20
|
+
*/
|
|
13
21
|
createLongProcessLogger(processDescription: string, totalItems?: number): LongProcessLogger;
|
|
22
|
+
/**
|
|
23
|
+
* single status-line on the bottom of the screen.
|
|
24
|
+
* the text is replaced every time this method is called.
|
|
25
|
+
*/
|
|
14
26
|
setStatusLine(text: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* remove the text from the last line on the screen.
|
|
29
|
+
*/
|
|
15
30
|
clearStatusLine(): void;
|
|
31
|
+
/**
|
|
32
|
+
* print to the screen. if message is empty, print the last logged message.
|
|
33
|
+
*/
|
|
16
34
|
console(message?: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* print to the screen as a title, with bold text.
|
|
37
|
+
*/
|
|
17
38
|
consoleTitle(message: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* print to the screen with a green `✔` prefix. if message is empty, print the last logged message.
|
|
41
|
+
*/
|
|
18
42
|
consoleSuccess(message?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* turn off the logger.
|
|
45
|
+
*/
|
|
19
46
|
off(): import("@teambit/legacy/dist/cli/loader/loader").Loader;
|
|
20
47
|
on(): import("@teambit/legacy/dist/cli/loader/loader").Loader;
|
|
21
48
|
profile(id: string, console?: boolean): void;
|
|
49
|
+
/**
|
|
50
|
+
* print to the screen with a red `✖` prefix. if message is empty, print the last logged message.
|
|
51
|
+
*/
|
|
22
52
|
consoleFailure(message?: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* print to the screen with a red `⚠` prefix. if message is empty, print the last logged message.
|
|
55
|
+
*/
|
|
23
56
|
consoleWarning(message?: string): void;
|
|
24
57
|
private colorMessage;
|
|
25
58
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { Logger } from './logger';
|
|
2
|
+
/**
|
|
3
|
+
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
4
|
+
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
5
|
+
* components, then pass the `totalItems` as the total components in the list.
|
|
6
|
+
* later, during the iteration, call `logProgress(componentName)`.
|
|
7
|
+
* once done, call `end()`.
|
|
8
|
+
* the status-line will show all messages in the terminal.
|
|
9
|
+
* see README for more data.
|
|
10
|
+
*/
|
|
2
11
|
export declare class LongProcessLogger {
|
|
3
12
|
private logPublisher;
|
|
4
13
|
private extensionName;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/logger",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.473",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/harmony/logger",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "logger",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.473"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.2.11",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"pretty-time": "1.1.0",
|
|
16
16
|
"@babel/runtime": "7.12.18",
|
|
17
17
|
"core-js": "^3.0.0",
|
|
18
|
-
"@teambit/cli": "0.0.
|
|
18
|
+
"@teambit/cli": "0.0.388"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/mocha": "5.2.7",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"@types/react-dom": "^17.0.5",
|
|
25
25
|
"@types/react": "^17.0.8",
|
|
26
26
|
"@types/node": "12.20.4",
|
|
27
|
-
"@teambit/harmony.aspect-docs.logger": "0.0.
|
|
27
|
+
"@teambit/harmony.aspect-docs.logger": "0.0.107"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@teambit/legacy": "1.0.
|
|
30
|
+
"@teambit/legacy": "1.0.174",
|
|
31
31
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0"
|
|
33
33
|
},
|
|
@@ -55,12 +55,20 @@
|
|
|
55
55
|
"react": "-"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@teambit/legacy": "1.0.
|
|
58
|
+
"@teambit/legacy": "1.0.174",
|
|
59
59
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist",
|
|
66
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
67
|
+
"README.md",
|
|
68
|
+
"README.mdx",
|
|
69
|
+
"*.js",
|
|
70
|
+
"*.json"
|
|
71
|
+
],
|
|
64
72
|
"private": false,
|
|
65
73
|
"engines": {
|
|
66
74
|
"node": ">=12.22.0"
|
package/tsconfig.json
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"skipLibCheck": true,
|
|
16
16
|
"moduleResolution": "node",
|
|
17
17
|
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
18
|
"composite": true,
|
|
20
19
|
"emitDeclarationOnly": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
21
|
"experimentalDecorators": true,
|
|
22
22
|
"emitDecoratorMetadata": true,
|
|
23
23
|
"allowSyntheticDefaultImports": true,
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"strict": true,
|
|
26
26
|
"noImplicitAny": false,
|
|
27
27
|
"rootDir": ".",
|
|
28
|
-
"removeComments": true,
|
|
29
28
|
"preserveConstEnums": true,
|
|
30
29
|
"resolveJsonModule": true
|
|
31
30
|
},
|
package/index.ts
DELETED
package/logger.aspect.ts
DELETED
package/logger.docs.mdx
DELETED
package/logger.main.runtime.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MainRuntime } from '@teambit/cli';
|
|
2
|
-
|
|
3
|
-
import { Logger } from './logger';
|
|
4
|
-
import { LoggerAspect } from './logger.aspect';
|
|
5
|
-
|
|
6
|
-
export class LoggerMain {
|
|
7
|
-
static runtime = MainRuntime;
|
|
8
|
-
static dependencies = [];
|
|
9
|
-
|
|
10
|
-
createLogger(extensionName: string): Logger {
|
|
11
|
-
return new Logger(extensionName);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static async provider() {
|
|
15
|
-
return new LoggerMain();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
LoggerAspect.addRuntime(LoggerMain);
|
package/logger.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import loader from '@teambit/legacy/dist/cli/loader';
|
|
2
|
-
import logger, { IBitLogger } from '@teambit/legacy/dist/logger/logger';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import stc from 'string-to-color';
|
|
5
|
-
|
|
6
|
-
import { LongProcessLogger } from './long-process-logger';
|
|
7
|
-
|
|
8
|
-
export class Logger implements IBitLogger {
|
|
9
|
-
constructor(private extensionName: string) {}
|
|
10
|
-
|
|
11
|
-
trace(message: string, ...meta: any[]) {
|
|
12
|
-
logger.trace(this.colorMessage(message), ...meta);
|
|
13
|
-
}
|
|
14
|
-
debug(message: string, ...meta: any[]) {
|
|
15
|
-
logger.debug(this.colorMessage(message), ...meta);
|
|
16
|
-
}
|
|
17
|
-
info(message: string, ...meta: any[]) {
|
|
18
|
-
logger.info(this.colorMessage(message), ...meta);
|
|
19
|
-
}
|
|
20
|
-
warn(message: string, ...meta: any[]) {
|
|
21
|
-
logger.warn(this.colorMessage(message), ...meta);
|
|
22
|
-
}
|
|
23
|
-
error(message: string, ...meta: any[]) {
|
|
24
|
-
logger.error(this.colorMessage(message), ...meta);
|
|
25
|
-
}
|
|
26
|
-
fatal(message: string, ...meta: any[]) {
|
|
27
|
-
logger.fatal(this.colorMessage(message), ...meta);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get isLoaderStarted() {
|
|
31
|
-
return loader.isStarted;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
35
|
-
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
36
|
-
* components, then pass the `totalItems` as the total of the total components in the list.
|
|
37
|
-
* later, during the iteration, call `LongProcessLogger.logProgress(componentName)`.
|
|
38
|
-
* once done, call `LongProcessLogger.end()`
|
|
39
|
-
* the status-line will show all messages in the terminal.
|
|
40
|
-
*/
|
|
41
|
-
createLongProcessLogger(processDescription: string, totalItems?: number): LongProcessLogger {
|
|
42
|
-
return new LongProcessLogger(this, this.extensionName, processDescription, totalItems);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* single status-line on the bottom of the screen.
|
|
46
|
-
* the text is replaced every time this method is called.
|
|
47
|
-
*/
|
|
48
|
-
setStatusLine(text: string) {
|
|
49
|
-
loader.setTextAndRestart(text);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* remove the text from the last line on the screen.
|
|
53
|
-
*/
|
|
54
|
-
clearStatusLine() {
|
|
55
|
-
loader.stop();
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* print to the screen. if message is empty, print the last logged message.
|
|
59
|
-
*/
|
|
60
|
-
console(message?: string) {
|
|
61
|
-
if (message) this.info(message);
|
|
62
|
-
if (!loader.isStarted && logger.shouldWriteToConsole) {
|
|
63
|
-
// eslint-disable-next-line no-console
|
|
64
|
-
console.log(message);
|
|
65
|
-
} else {
|
|
66
|
-
loader.stopAndPersist({ text: message });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* print to the screen as a title, with bold text.
|
|
71
|
-
*/
|
|
72
|
-
consoleTitle(message: string) {
|
|
73
|
-
this.info(message);
|
|
74
|
-
loader.stopAndPersist({ text: chalk.bold(message) });
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* print to the screen with a green `✔` prefix. if message is empty, print the last logged message.
|
|
78
|
-
*/
|
|
79
|
-
consoleSuccess(message?: string) {
|
|
80
|
-
if (message) this.info(message);
|
|
81
|
-
loader.succeed(message);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* turn off the logger.
|
|
86
|
-
*/
|
|
87
|
-
off() {
|
|
88
|
-
return loader.off();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
on() {
|
|
92
|
-
return loader.on();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
profile(id: string, console?: boolean) {
|
|
96
|
-
logger.profile(id, console);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* print to the screen with a red `✖` prefix. if message is empty, print the last logged message.
|
|
101
|
-
*/
|
|
102
|
-
consoleFailure(message?: string) {
|
|
103
|
-
if (message) this.error(message);
|
|
104
|
-
loader.fail(message);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* print to the screen with a red `⚠` prefix. if message is empty, print the last logged message.
|
|
108
|
-
*/
|
|
109
|
-
consoleWarning(message?: string) {
|
|
110
|
-
if (message) this.warn(message);
|
|
111
|
-
loader.warn(message);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private colorMessage(message: string) {
|
|
115
|
-
const text = `${this.extensionName}, ${message}`;
|
|
116
|
-
if (logger.isJsonFormat) return text;
|
|
117
|
-
return chalk.hex(stc(this.extensionName))(text);
|
|
118
|
-
}
|
|
119
|
-
}
|
package/long-process-logger.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import prettyTime from 'pretty-time';
|
|
2
|
-
import type { Logger } from './logger';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
6
|
-
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
7
|
-
* components, then pass the `totalItems` as the total components in the list.
|
|
8
|
-
* later, during the iteration, call `logProgress(componentName)`.
|
|
9
|
-
* once done, call `end()`.
|
|
10
|
-
* the status-line will show all messages in the terminal.
|
|
11
|
-
* see README for more data.
|
|
12
|
-
*/
|
|
13
|
-
export class LongProcessLogger {
|
|
14
|
-
constructor(
|
|
15
|
-
private logPublisher: Logger,
|
|
16
|
-
private extensionName: string,
|
|
17
|
-
private processDescription: string,
|
|
18
|
-
private totalItems?: number,
|
|
19
|
-
private currentItem = 0,
|
|
20
|
-
private startTime = process.hrtime()
|
|
21
|
-
) {
|
|
22
|
-
this.start();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
logProgress(itemName = '') {
|
|
26
|
-
this.currentItem += 1;
|
|
27
|
-
const message = `${this.processDescription} (${this.currentItem}/${this.totalItems}). ${itemName}`;
|
|
28
|
-
this.logPublisher.debug(message);
|
|
29
|
-
this.logPublisher.setStatusLine(`${this.extensionName}, ${message}`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
end() {
|
|
33
|
-
const duration = process.hrtime(this.startTime);
|
|
34
|
-
const message = `${this.processDescription} (completed in ${prettyTime(duration)})`;
|
|
35
|
-
this.logAndConsole(message);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private start() {
|
|
39
|
-
const totalItemsStr = this.totalItems ? `(total: ${this.totalItems})` : '';
|
|
40
|
-
const message = `${this.processDescription} ${totalItemsStr}`;
|
|
41
|
-
this.logAndConsole(message);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private logAndConsole(message: string) {
|
|
45
|
-
this.logPublisher.info(message);
|
|
46
|
-
this.logPublisher.setStatusLine(`${this.extensionName}, ${message}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
Binary file
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare module '*.png' {
|
|
2
|
-
const value: any;
|
|
3
|
-
export = value;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.svg' {
|
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
-
|
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
|
-
declare module '*.jpg' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export = value;
|
|
17
|
-
}
|
|
18
|
-
declare module '*.jpeg' {
|
|
19
|
-
const value: any;
|
|
20
|
-
export = value;
|
|
21
|
-
}
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const value: any;
|
|
24
|
-
export = value;
|
|
25
|
-
}
|
|
26
|
-
declare module '*.bmp' {
|
|
27
|
-
const value: any;
|
|
28
|
-
export = value;
|
|
29
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { readonly [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.module.scss' {
|
|
6
|
-
const classes: { readonly [key: string]: string };
|
|
7
|
-
export default classes;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.module.sass' {
|
|
10
|
-
const classes: { readonly [key: string]: string };
|
|
11
|
-
export default classes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '*.module.less' {
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export default classes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module '*.less' {
|
|
20
|
-
const classes: { readonly [key: string]: string };
|
|
21
|
-
export default classes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '*.css' {
|
|
25
|
-
const classes: { readonly [key: string]: string };
|
|
26
|
-
export default classes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare module '*.sass' {
|
|
30
|
-
const classes: { readonly [key: string]: string };
|
|
31
|
-
export default classes;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.scss' {
|
|
35
|
-
const classes: { readonly [key: string]: string };
|
|
36
|
-
export default classes;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module '*.mdx' {
|
|
40
|
-
const component: any;
|
|
41
|
-
export default component;
|
|
42
|
-
}
|