@teambit/logger 0.0.931 → 0.0.933
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.composition.d.ts +2 -2
- package/dist/logger.main.runtime.d.ts +1 -1
- package/dist/logger.main.runtime.js +2 -2
- package/dist/logger.main.runtime.js.map +1 -1
- package/dist/long-process-logger.d.ts +2 -2
- package/dist/long-process-logger.js +2 -2
- package/dist/long-process-logger.js.map +1 -1
- package/dist/{preview-1703387662836.js → preview-1703647408454.js} +2 -2
- package/index.ts +4 -0
- package/logger.aspect.ts +7 -0
- package/logger.main.runtime.ts +19 -0
- package/logger.ts +154 -0
- package/long-process-logger.ts +63 -0
- package/package.json +12 -19
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const Logo: () =>
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Logo: () => JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from './logger';
|
|
2
2
|
export declare class LoggerMain {
|
|
3
3
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
4
|
-
static dependencies:
|
|
4
|
+
static dependencies: any[];
|
|
5
5
|
createLogger(extensionName: string): Logger;
|
|
6
6
|
static provider(): Promise<LoggerMain>;
|
|
7
7
|
}
|
|
@@ -26,8 +26,8 @@ function _logger2() {
|
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
28
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
-
function _toPropertyKey(
|
|
30
|
-
function _toPrimitive(
|
|
29
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
30
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
31
31
|
class LoggerMain {
|
|
32
32
|
createLogger(extensionName) {
|
|
33
33
|
return new (_logger().Logger)(extensionName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_logger","_logger2","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_logger","_logger2","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","LoggerMain","createLogger","extensionName","Logger","provider","exports","MainRuntime","LoggerAspect","addRuntime"],"sources":["logger.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\n\nimport { Logger } from './logger';\nimport { LoggerAspect } from './logger.aspect';\n\nexport class LoggerMain {\n static runtime = MainRuntime;\n static dependencies = [];\n\n createLogger(extensionName: string): Logger {\n return new Logger(extensionName);\n }\n\n static async provider() {\n return new LoggerMain();\n }\n}\n\nLoggerAspect.addRuntime(LoggerMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAI,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,GAAAI,CAAA,CAAAG,IAAA,CAAAR,CAAA,EAAAI,CAAA,uCAAAH,CAAA,SAAAA,CAAA,YAAAQ,SAAA,yEAAAL,CAAA,GAAAD,MAAA,GAAAO,MAAA,EAAAV,CAAA;AAExC,MAAMW,UAAU,CAAC;EAItBC,YAAYA,CAACC,aAAqB,EAAU;IAC1C,OAAO,KAAIC,gBAAM,EAACD,aAAa,CAAC;EAClC;EAEA,aAAaE,QAAQA,CAAA,EAAG;IACtB,OAAO,IAAIJ,UAAU,CAAC,CAAC;EACzB;AACF;AAACK,OAAA,CAAAL,UAAA,GAAAA,UAAA;AAAArB,eAAA,CAXYqB,UAAU,aACJM,kBAAW;AAAA3B,eAAA,CADjBqB,UAAU,kBAEC,EAAE;AAW1BO,uBAAY,CAACC,UAAU,CAACR,UAAU,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger } from './logger';
|
|
2
|
-
export
|
|
2
|
+
export type ConsoleOnStart = 'normal' | 'title';
|
|
3
3
|
/**
|
|
4
4
|
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
5
5
|
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
@@ -16,7 +16,7 @@ export declare class LongProcessLogger {
|
|
|
16
16
|
private totalItems?;
|
|
17
17
|
private currentItem;
|
|
18
18
|
private startTime;
|
|
19
|
-
constructor(logPublisher: Logger, extensionName: string, processDescription: string, totalItems?: number
|
|
19
|
+
constructor(logPublisher: Logger, extensionName: string, processDescription: string, totalItems?: number, shouldConsole?: ConsoleOnStart);
|
|
20
20
|
logProgress(itemName?: string, showProcessDescription?: boolean): void;
|
|
21
21
|
end(shouldConsole?: 'success' | 'error'): void;
|
|
22
22
|
getProgress(): string;
|
|
@@ -13,8 +13,8 @@ function _prettyTime() {
|
|
|
13
13
|
}
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
-
function _toPropertyKey(
|
|
17
|
-
function _toPrimitive(
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
18
|
/**
|
|
19
19
|
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
20
20
|
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","
|
|
1
|
+
{"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","LongProcessLogger","constructor","logPublisher","extensionName","processDescription","totalItems","shouldConsole","process","hrtime","start","logProgress","itemName","showProcessDescription","currentItem","processDesc","message","getProgress","debug","setStatusLine","end","env","CI","description","duration","startTime","completedOrFailedStr","prettyTime","info","consoleSuccess","consoleFailure","totalItemsStr","consoleTitle","console","exports"],"sources":["long-process-logger.ts"],"sourcesContent":["import prettyTime from 'pretty-time';\nimport type { Logger } from './logger';\n\nexport type ConsoleOnStart = 'normal' | 'title';\n\n/**\n * use it for a long running process. upon creation it logs the `processDescription`.\n * if the process involves iteration over a list of items, such as running tag on a list of\n * components, then pass the `totalItems` as the total components in the list.\n * later, during the iteration, call `logProgress(componentName)`.\n * once done, call `end()`.\n * the status-line will show all messages in the terminal.\n * see README for more data.\n */\nexport class LongProcessLogger {\n private currentItem = 0;\n private startTime = process.hrtime();\n constructor(\n private logPublisher: Logger,\n private extensionName: string,\n private processDescription: string,\n private totalItems?: number,\n shouldConsole?: ConsoleOnStart\n ) {\n this.start(shouldConsole);\n }\n\n logProgress(itemName = '', showProcessDescription = true) {\n this.currentItem += 1;\n const processDesc = showProcessDescription ? `${this.processDescription} ` : '';\n const message = `${processDesc}${this.getProgress()} ${itemName}`;\n this.logPublisher.debug(message);\n this.logPublisher.setStatusLine(message, true);\n }\n\n end(shouldConsole?: 'success' | 'error') {\n if (process.env.CI && !shouldConsole) shouldConsole = 'success';\n const description = this.processDescription;\n const duration = process.hrtime(this.startTime);\n const completedOrFailedStr = !shouldConsole || shouldConsole === 'success' ? 'Succeeded' : 'Failed';\n const message = `${description}. ${completedOrFailedStr} in ${prettyTime(duration)}`;\n this.logPublisher.info(message);\n if (shouldConsole) {\n if (shouldConsole === 'success') this.logPublisher.consoleSuccess(message);\n else this.logPublisher.consoleFailure(message);\n } else this.logPublisher.setStatusLine(message);\n }\n\n getProgress() {\n return `(${this.currentItem}/${this.totalItems})`;\n }\n\n private start(shouldConsole?: ConsoleOnStart) {\n if (process.env.CI && !shouldConsole) shouldConsole = 'normal';\n const totalItemsStr = this.totalItems ? `(total: ${this.totalItems})` : '';\n const message = `${this.processDescription} ${totalItemsStr}`;\n this.logPublisher.info(message);\n if (shouldConsole) {\n if (shouldConsole === 'title') this.logPublisher.consoleTitle(message);\n else this.logPublisher.console(message);\n } else this.logPublisher.setStatusLine(message);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAqC,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,GAAAI,CAAA,CAAAG,IAAA,CAAAR,CAAA,EAAAI,CAAA,uCAAAH,CAAA,SAAAA,CAAA,YAAAQ,SAAA,yEAAAL,CAAA,GAAAD,MAAA,GA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/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.933/dist/logger.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.933/dist/logger.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/index.ts
ADDED
package/logger.aspect.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
|
|
5
|
+
import { ConsoleOnStart, LongProcessLogger } from './long-process-logger';
|
|
6
|
+
|
|
7
|
+
export class Logger implements IBitLogger {
|
|
8
|
+
constructor(private extensionName: string) {}
|
|
9
|
+
|
|
10
|
+
trace(message: string, ...meta: any[]) {
|
|
11
|
+
logger.trace(this.colorMessage(message), ...meta);
|
|
12
|
+
}
|
|
13
|
+
debug(message: string, ...meta: any[]) {
|
|
14
|
+
logger.debug(this.colorMessage(message), ...meta);
|
|
15
|
+
}
|
|
16
|
+
info(message: string, ...meta: any[]) {
|
|
17
|
+
logger.info(this.colorMessage(message), ...meta);
|
|
18
|
+
}
|
|
19
|
+
warn(message: string, ...meta: any[]) {
|
|
20
|
+
logger.warn(this.colorMessage(message), ...meta);
|
|
21
|
+
}
|
|
22
|
+
error(message: string, ...meta: any[]) {
|
|
23
|
+
logger.error(this.colorMessage(message), ...meta);
|
|
24
|
+
}
|
|
25
|
+
fatal(message: string, ...meta: any[]) {
|
|
26
|
+
logger.fatal(this.colorMessage(message), ...meta);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get isLoaderStarted() {
|
|
30
|
+
return loader.isStarted;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
34
|
+
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
35
|
+
* components, then pass the `totalItems` as the total of the total components in the list.
|
|
36
|
+
* later, during the iteration, call `LongProcessLogger.logProgress(componentName)`.
|
|
37
|
+
* once done, call `LongProcessLogger.end()`
|
|
38
|
+
* the status-line will show all messages in the terminal.
|
|
39
|
+
*/
|
|
40
|
+
createLongProcessLogger(
|
|
41
|
+
processDescription: string,
|
|
42
|
+
totalItems?: number,
|
|
43
|
+
shouldConsole?: ConsoleOnStart
|
|
44
|
+
): LongProcessLogger {
|
|
45
|
+
return new LongProcessLogger(this, this.extensionName, processDescription, totalItems, shouldConsole);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* single status-line on the bottom of the screen.
|
|
49
|
+
* the text is replaced every time this method is called.
|
|
50
|
+
*/
|
|
51
|
+
setStatusLine(text: string, shouldPrintOnCI = false) {
|
|
52
|
+
if (process.env.CI && !shouldPrintOnCI) return;
|
|
53
|
+
loader.setTextAndRestart(text);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* remove the text from the last line on the screen.
|
|
57
|
+
*/
|
|
58
|
+
clearStatusLine() {
|
|
59
|
+
loader.stop();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* print to the screen. if message is empty, print the last logged message.
|
|
63
|
+
*/
|
|
64
|
+
console(message?: string, ...meta: any[]) {
|
|
65
|
+
if (message) this.info(message, meta);
|
|
66
|
+
if (!loader.isStarted && logger.shouldWriteToConsole) {
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.log(message, ...meta);
|
|
69
|
+
} else {
|
|
70
|
+
loader.stopAndPersist({ text: message });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated
|
|
76
|
+
* try using consoleWarning. if not possible, rename this method to a clearer one
|
|
77
|
+
*/
|
|
78
|
+
consoleWarn(message?: string, ...meta: any[]) {
|
|
79
|
+
if (message) this.warn(message, ...meta);
|
|
80
|
+
if (!loader.isStarted && logger.shouldWriteToConsole) {
|
|
81
|
+
// eslint-disable-next-line no-console
|
|
82
|
+
console.warn(message, ...meta);
|
|
83
|
+
} else {
|
|
84
|
+
loader.stopAndPersist({ text: message });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated
|
|
90
|
+
* try using consoleFailure. if not possible, rename this method to a clearer one
|
|
91
|
+
*/
|
|
92
|
+
consoleError(message?: string, ...meta: any[]) {
|
|
93
|
+
if (message) this.error(message, ...meta);
|
|
94
|
+
if (!loader.isStarted && logger.shouldWriteToConsole) {
|
|
95
|
+
// eslint-disable-next-line no-console
|
|
96
|
+
console.error(message, ...meta);
|
|
97
|
+
} else {
|
|
98
|
+
loader.stopAndPersist({ text: message });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* print to the screen as a title, with bold text.
|
|
104
|
+
*/
|
|
105
|
+
consoleTitle(message: string) {
|
|
106
|
+
this.info(message);
|
|
107
|
+
loader.stopAndPersist({ text: chalk.bold(message) });
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* print to the screen with a green `✔` prefix. if message is empty, print the last logged message.
|
|
111
|
+
*/
|
|
112
|
+
consoleSuccess(message?: string, startTime?: [number, number]) {
|
|
113
|
+
if (message) this.info(message);
|
|
114
|
+
loader.succeed(message, startTime);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* turn off the logger.
|
|
119
|
+
*/
|
|
120
|
+
off() {
|
|
121
|
+
return loader.off();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
on() {
|
|
125
|
+
return loader.on();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
profile(id: string, console?: boolean) {
|
|
129
|
+
logger.profile(id, console);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* print to the screen with a red `✖` prefix. if message is empty, print the last logged message.
|
|
134
|
+
*/
|
|
135
|
+
consoleFailure(message?: string) {
|
|
136
|
+
if (message) this.error(message);
|
|
137
|
+
loader.fail(message);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* print to the screen with a red `⚠` prefix. if message is empty, print the last logged message.
|
|
141
|
+
*/
|
|
142
|
+
consoleWarning(message?: string) {
|
|
143
|
+
if (message) {
|
|
144
|
+
this.warn(message);
|
|
145
|
+
message = chalk.yellow(message);
|
|
146
|
+
}
|
|
147
|
+
loader.warn(message);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private colorMessage(message: string) {
|
|
151
|
+
if (logger.isJsonFormat) return `${this.extensionName}, ${message}`;
|
|
152
|
+
return `${chalk.bold(this.extensionName)}, ${message}`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import prettyTime from 'pretty-time';
|
|
2
|
+
import type { Logger } from './logger';
|
|
3
|
+
|
|
4
|
+
export type ConsoleOnStart = 'normal' | 'title';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* use it for a long running process. upon creation it logs the `processDescription`.
|
|
8
|
+
* if the process involves iteration over a list of items, such as running tag on a list of
|
|
9
|
+
* components, then pass the `totalItems` as the total components in the list.
|
|
10
|
+
* later, during the iteration, call `logProgress(componentName)`.
|
|
11
|
+
* once done, call `end()`.
|
|
12
|
+
* the status-line will show all messages in the terminal.
|
|
13
|
+
* see README for more data.
|
|
14
|
+
*/
|
|
15
|
+
export class LongProcessLogger {
|
|
16
|
+
private currentItem = 0;
|
|
17
|
+
private startTime = process.hrtime();
|
|
18
|
+
constructor(
|
|
19
|
+
private logPublisher: Logger,
|
|
20
|
+
private extensionName: string,
|
|
21
|
+
private processDescription: string,
|
|
22
|
+
private totalItems?: number,
|
|
23
|
+
shouldConsole?: ConsoleOnStart
|
|
24
|
+
) {
|
|
25
|
+
this.start(shouldConsole);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
logProgress(itemName = '', showProcessDescription = true) {
|
|
29
|
+
this.currentItem += 1;
|
|
30
|
+
const processDesc = showProcessDescription ? `${this.processDescription} ` : '';
|
|
31
|
+
const message = `${processDesc}${this.getProgress()} ${itemName}`;
|
|
32
|
+
this.logPublisher.debug(message);
|
|
33
|
+
this.logPublisher.setStatusLine(message, true);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
end(shouldConsole?: 'success' | 'error') {
|
|
37
|
+
if (process.env.CI && !shouldConsole) shouldConsole = 'success';
|
|
38
|
+
const description = this.processDescription;
|
|
39
|
+
const duration = process.hrtime(this.startTime);
|
|
40
|
+
const completedOrFailedStr = !shouldConsole || shouldConsole === 'success' ? 'Succeeded' : 'Failed';
|
|
41
|
+
const message = `${description}. ${completedOrFailedStr} in ${prettyTime(duration)}`;
|
|
42
|
+
this.logPublisher.info(message);
|
|
43
|
+
if (shouldConsole) {
|
|
44
|
+
if (shouldConsole === 'success') this.logPublisher.consoleSuccess(message);
|
|
45
|
+
else this.logPublisher.consoleFailure(message);
|
|
46
|
+
} else this.logPublisher.setStatusLine(message);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getProgress() {
|
|
50
|
+
return `(${this.currentItem}/${this.totalItems})`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private start(shouldConsole?: ConsoleOnStart) {
|
|
54
|
+
if (process.env.CI && !shouldConsole) shouldConsole = 'normal';
|
|
55
|
+
const totalItemsStr = this.totalItems ? `(total: ${this.totalItems})` : '';
|
|
56
|
+
const message = `${this.processDescription} ${totalItemsStr}`;
|
|
57
|
+
this.logPublisher.info(message);
|
|
58
|
+
if (shouldConsole) {
|
|
59
|
+
if (shouldConsole === 'title') this.logPublisher.consoleTitle(message);
|
|
60
|
+
else this.logPublisher.console(message);
|
|
61
|
+
} else this.logPublisher.setStatusLine(message);
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/logger",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.933",
|
|
4
4
|
"homepage": "https://bit.cloud/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.933"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
13
13
|
"pretty-time": "1.1.0",
|
|
14
|
-
"core-js": "^3.0.0",
|
|
15
|
-
"@babel/runtime": "7.20.0",
|
|
16
14
|
"@teambit/harmony": "0.4.6",
|
|
17
|
-
"@teambit/cli": "0.0.
|
|
15
|
+
"@teambit/cli": "0.0.840"
|
|
18
16
|
},
|
|
19
17
|
"devDependencies": {
|
|
20
|
-
"@types/react": "^17.0.8",
|
|
21
18
|
"@types/mocha": "9.1.0",
|
|
22
|
-
"@types/
|
|
23
|
-
"@types/
|
|
24
|
-
"@
|
|
25
|
-
"@types/testing-library__jest-dom": "5.9.5",
|
|
19
|
+
"@types/jest": "^29.2.2",
|
|
20
|
+
"@types/testing-library__jest-dom": "^5.9.5",
|
|
21
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.13",
|
|
26
22
|
"@teambit/harmony.aspect-docs.logger": "0.0.165"
|
|
27
23
|
},
|
|
28
24
|
"peerDependencies": {
|
|
29
|
-
"
|
|
30
|
-
"react": "^
|
|
31
|
-
"
|
|
25
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
26
|
+
"@types/react": "^18.2.12",
|
|
27
|
+
"@teambit/legacy": "1.0.624"
|
|
32
28
|
},
|
|
33
29
|
"license": "Apache-2.0",
|
|
34
30
|
"optionalDependencies": {},
|
|
@@ -42,7 +38,7 @@
|
|
|
42
38
|
},
|
|
43
39
|
"private": false,
|
|
44
40
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
41
|
+
"node": ">=16.0.0"
|
|
46
42
|
},
|
|
47
43
|
"repository": {
|
|
48
44
|
"type": "git",
|
|
@@ -51,12 +47,9 @@
|
|
|
51
47
|
"keywords": [
|
|
52
48
|
"bit",
|
|
53
49
|
"bit-aspect",
|
|
50
|
+
"bit-core-aspect",
|
|
54
51
|
"components",
|
|
55
52
|
"collaboration",
|
|
56
|
-
"web"
|
|
57
|
-
"react",
|
|
58
|
-
"react-components",
|
|
59
|
-
"angular",
|
|
60
|
-
"angular-components"
|
|
53
|
+
"web"
|
|
61
54
|
]
|
|
62
55
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,38 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"lib": [
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"DOM.Iterable",
|
|
8
|
-
"ScriptHost"
|
|
4
|
+
"esnext",
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.Iterable"
|
|
9
7
|
],
|
|
10
|
-
"target": "
|
|
11
|
-
"module": "
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"allowJs": true,
|
|
14
|
-
"composite": true,
|
|
8
|
+
"target": "es2020",
|
|
9
|
+
"module": "es2020",
|
|
10
|
+
"jsx": "react-jsx",
|
|
15
11
|
"declaration": true,
|
|
16
12
|
"sourceMap": true,
|
|
17
|
-
"skipLibCheck": true,
|
|
18
13
|
"experimentalDecorators": true,
|
|
19
|
-
"
|
|
14
|
+
"skipLibCheck": true,
|
|
20
15
|
"moduleResolution": "node",
|
|
21
16
|
"esModuleInterop": true,
|
|
22
|
-
"rootDir": ".",
|
|
23
17
|
"resolveJsonModule": true,
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"strictPropertyInitialization": false,
|
|
28
|
-
"strict": true,
|
|
29
|
-
"noImplicitAny": false,
|
|
30
|
-
"preserveConstEnums": true
|
|
18
|
+
"allowJs": true,
|
|
19
|
+
"outDir": "dist",
|
|
20
|
+
"emitDeclarationOnly": true
|
|
31
21
|
},
|
|
32
22
|
"exclude": [
|
|
23
|
+
"artifacts",
|
|
24
|
+
"public",
|
|
33
25
|
"dist",
|
|
26
|
+
"node_modules",
|
|
27
|
+
"package.json",
|
|
34
28
|
"esm.mjs",
|
|
35
|
-
"
|
|
29
|
+
"**/*.cjs",
|
|
30
|
+
"./dist"
|
|
36
31
|
],
|
|
37
32
|
"include": [
|
|
38
33
|
"**/*",
|
package/types/asset.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ declare module '*.png' {
|
|
|
5
5
|
declare module '*.svg' {
|
|
6
6
|
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
7
|
|
|
8
|
-
export const ReactComponent: FunctionComponent<
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
9
11
|
const src: string;
|
|
10
12
|
export default src;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
14
|
declare module '*.jpg' {
|
|
15
15
|
const value: any;
|
|
16
16
|
export = value;
|
|
@@ -27,3 +27,15 @@ declare module '*.bmp' {
|
|
|
27
27
|
const value: any;
|
|
28
28
|
export = value;
|
|
29
29
|
}
|
|
30
|
+
declare module '*.otf' {
|
|
31
|
+
const value: any;
|
|
32
|
+
export = value;
|
|
33
|
+
}
|
|
34
|
+
declare module '*.woff' {
|
|
35
|
+
const value: any;
|
|
36
|
+
export = value;
|
|
37
|
+
}
|
|
38
|
+
declare module '*.woff2' {
|
|
39
|
+
const value: any;
|
|
40
|
+
export = value;
|
|
41
|
+
}
|