@ui5/logger 3.0.0-next.0 → 3.0.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/.reuse/dep5 +1 -1
- package/CHANGELOG.md +50 -9
- package/CONTRIBUTING.md +1 -1
- package/LICENSE.txt +1 -1
- package/README.md +10 -9
- package/jsdoc.json +59 -58
- package/lib/index.js +51 -0
- package/lib/loggers/Build.js +91 -0
- package/lib/loggers/Logger.js +240 -0
- package/lib/loggers/ProjectBuild.js +88 -0
- package/lib/writers/Console.js +378 -0
- package/package.json +39 -28
- package/index.js +0 -5
- package/lib/logger.js +0 -160
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import Logger from "./Logger.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Logger for emitting status events on the progress a single project's build process.
|
|
5
|
+
* <br><br>
|
|
6
|
+
* Emits <code>ui5.log</code>, <code>ui5.project-build-metadata</code> and <code>ui5.project-build-status</code>
|
|
7
|
+
* events on the [<code>process</code>]{@link https://nodejs.org/api/process.html} object,
|
|
8
|
+
* which can be handled by dedicated writers,
|
|
9
|
+
* like [@ui5/logger/writers/Console]{@link @ui5/logger/writers/Console}.
|
|
10
|
+
* <br><br>
|
|
11
|
+
* If no listener is attached to the the event, messages are written directly to the <code>process.stderr</code> stream.
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
* @class
|
|
15
|
+
* @alias @ui5/logger/loggers/ProjectBuild
|
|
16
|
+
*/
|
|
17
|
+
class ProjectBuild extends Logger {
|
|
18
|
+
#projectName;
|
|
19
|
+
#projectType;
|
|
20
|
+
#tasksToRun;
|
|
21
|
+
|
|
22
|
+
static PROJECT_BUILD_METADATA_EVENT_NAME = "ui5.project-build-metadata";
|
|
23
|
+
static PROJECT_BUILD_STATUS_EVENT_NAME = "ui5.project-build-status";
|
|
24
|
+
|
|
25
|
+
constructor({moduleName, projectName, projectType}) {
|
|
26
|
+
super(moduleName);
|
|
27
|
+
|
|
28
|
+
if (!projectName) {
|
|
29
|
+
throw new Error("loggers/ProjectBuild: Missing projectName parameter");
|
|
30
|
+
}
|
|
31
|
+
if (!projectType) {
|
|
32
|
+
throw new Error("loggers/ProjectBuild: Missing projectType parameter");
|
|
33
|
+
}
|
|
34
|
+
this.#projectName = projectName;
|
|
35
|
+
this.#projectType = projectType;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setTasks(tasks) {
|
|
39
|
+
if (!tasks || !Array.isArray(tasks)) {
|
|
40
|
+
throw new Error("loggers/ProjectBuild#setTasks: Missing or incorrect tasks parameter");
|
|
41
|
+
}
|
|
42
|
+
this.#tasksToRun = tasks;
|
|
43
|
+
|
|
44
|
+
this._emit(ProjectBuild.PROJECT_BUILD_METADATA_EVENT_NAME, {
|
|
45
|
+
projectName: this.#projectName,
|
|
46
|
+
projectType: this.#projectType,
|
|
47
|
+
tasksToRun: tasks
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
startTask(taskName) {
|
|
52
|
+
if (!this.#tasksToRun || !this.#tasksToRun.includes(taskName)) {
|
|
53
|
+
throw new Error(`loggers/ProjectBuild#startTask: Unknown task ${taskName}`);
|
|
54
|
+
}
|
|
55
|
+
const level = "info";
|
|
56
|
+
const hasListeners = this._emit(ProjectBuild.PROJECT_BUILD_STATUS_EVENT_NAME, {
|
|
57
|
+
level,
|
|
58
|
+
projectName: this.#projectName,
|
|
59
|
+
projectType: this.#projectType,
|
|
60
|
+
taskName,
|
|
61
|
+
status: "task-start",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!hasListeners) {
|
|
65
|
+
this._log(level, `${this.#projectName}: Running task ${taskName}...`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
endTask(taskName) {
|
|
70
|
+
if (!this.#tasksToRun || !this.#tasksToRun.includes(taskName)) {
|
|
71
|
+
throw new Error(`loggers/ProjectBuild#endTask: Unknown task ${taskName}`);
|
|
72
|
+
}
|
|
73
|
+
const level = "verbose";
|
|
74
|
+
const hasListeners = this._emit(ProjectBuild.PROJECT_BUILD_STATUS_EVENT_NAME, {
|
|
75
|
+
level,
|
|
76
|
+
projectName: this.#projectName,
|
|
77
|
+
projectType: this.#projectType,
|
|
78
|
+
taskName,
|
|
79
|
+
status: "task-end",
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (!hasListeners) {
|
|
83
|
+
this._log(level, `${this.#projectName}: Finished task ${taskName}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default ProjectBuild;
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import {chalkStderr as chalk} from "chalk";
|
|
3
|
+
import figures from "figures";
|
|
4
|
+
import {MultiBar} from "cli-progress";
|
|
5
|
+
import Logger from "../loggers/Logger.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Standard handler for events emitted by @ui5/logger modules. Writes messages to
|
|
9
|
+
* [<code>process.stderr</code>]{@link https://nodejs.org/api/process.html#processstderr} stream
|
|
10
|
+
* and renders a progress bar for UI5 Tooling build processes.
|
|
11
|
+
* <br><br>
|
|
12
|
+
* The progress bar is only used in interactive terminals. If verbose logging is enabled, the progress
|
|
13
|
+
* bar is disabled.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @class
|
|
17
|
+
* @alias @ui5/logger/writers/Console
|
|
18
|
+
*/
|
|
19
|
+
class Console {
|
|
20
|
+
#projectMetadata = new Map();
|
|
21
|
+
#progressBarContainer;
|
|
22
|
+
#progressBar;
|
|
23
|
+
#progressProjectWeight;
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
this._handleLogEvent = this.#handleLogEvent.bind(this);
|
|
27
|
+
this._handleBuildStatusEvent = this.#handleBuildStatusEvent.bind(this);
|
|
28
|
+
this._handleProjectBuildStatusEvent = this.#handleProjectBuildStatusEvent.bind(this);
|
|
29
|
+
this._handleBuildMetadataEvent = this.#handleBuildMetadataEvent.bind(this);
|
|
30
|
+
this._handleProjectBuildMetadataEvent = this.#handleProjectBuildMetadataEvent.bind(this);
|
|
31
|
+
this._handleStop = this.disable.bind(this);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Attaches all event listeners and starts writing to output stream
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
enable() {
|
|
40
|
+
process.on("ui5.log", this._handleLogEvent);
|
|
41
|
+
process.on("ui5.build-metadata", this._handleBuildMetadataEvent);
|
|
42
|
+
process.on("ui5.project-build-metadata", this._handleProjectBuildMetadataEvent);
|
|
43
|
+
process.on("ui5.build-status", this._handleBuildStatusEvent);
|
|
44
|
+
process.on("ui5.project-build-status", this._handleProjectBuildStatusEvent);
|
|
45
|
+
process.on("ui5.log.stop-console", this._handleStop);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Detaches all event listeners and stops writing to output stream
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
disable() {
|
|
54
|
+
process.off("ui5.log", this._handleLogEvent);
|
|
55
|
+
process.off("ui5.build-metadata", this._handleBuildMetadataEvent);
|
|
56
|
+
process.off("ui5.project-build-metadata", this._handleProjectBuildMetadataEvent);
|
|
57
|
+
process.off("ui5.build-status", this._handleBuildStatusEvent);
|
|
58
|
+
process.off("ui5.project-build-status", this._handleProjectBuildStatusEvent);
|
|
59
|
+
process.off("ui5.log.stop-console", this._handleStop);
|
|
60
|
+
if (this.#progressBarContainer) {
|
|
61
|
+
this.#progressBar.stop();
|
|
62
|
+
this.#progressBarContainer.stop(); // Will fire internal stop event
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* Progress bar is only required when building projects. So we create it lazily
|
|
68
|
+
*/
|
|
69
|
+
_getProgressBar() {
|
|
70
|
+
// Do not use a progress bar if there is no text terminal attached or verbose logging is enabled
|
|
71
|
+
// * If log output is piped to a static output (= no TTY), no progress bar should be rendered
|
|
72
|
+
// * Since logging through the progress bar is asynchronous (controlled by the FPS setting),
|
|
73
|
+
// exceptions might lead to log messages being dropped. Therefore do not use a progress bar
|
|
74
|
+
// for verbose logging
|
|
75
|
+
// * If log-level is set to "silent", we should never render a progress bar
|
|
76
|
+
if (process.stderr.isTTY !== true || Logger.isLevelEnabled("verbose") || Logger.getLevel() === "silent") {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (!this.#progressBarContainer) {
|
|
80
|
+
// We use a "MultiBar" instance even though we intend to only render a single progress bar
|
|
81
|
+
// This is because only MultiBar provides a "log" method as of today
|
|
82
|
+
this.#progressBarContainer = new MultiBar({
|
|
83
|
+
format: `{bar} {message}`,
|
|
84
|
+
barsize: 20,
|
|
85
|
+
linewrap: true,
|
|
86
|
+
emptyOnZero: 0,
|
|
87
|
+
hideCursor: true,
|
|
88
|
+
|
|
89
|
+
// FPS also controls how fast a log message will be rendered above the progress bar
|
|
90
|
+
fps: 120,
|
|
91
|
+
|
|
92
|
+
// Disable progress bar explicitly for non-TTY, even though this is already checked above
|
|
93
|
+
noTTYOutput: false,
|
|
94
|
+
|
|
95
|
+
// Graceful exit is required to ensure all terminal settings (e.g. hideCursor)
|
|
96
|
+
// are restored on SIGINT
|
|
97
|
+
gracefulExit: true,
|
|
98
|
+
|
|
99
|
+
// Required to prevent flickering when logging
|
|
100
|
+
forceRedraw: true,
|
|
101
|
+
|
|
102
|
+
clearOnComplete: true,
|
|
103
|
+
stopOnComplete: true,
|
|
104
|
+
|
|
105
|
+
barCompleteChar: figures.square,
|
|
106
|
+
barIncompleteChar: figures.squareLightShade,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Initialize empty progress bar to enable logging through the multibar instance
|
|
110
|
+
this.#progressBar = this.#progressBarContainer.create(0, 0, {message: ""});
|
|
111
|
+
|
|
112
|
+
this.#progressBarContainer.on("stop", () => {
|
|
113
|
+
// Progress bar has finished and will remove itself from the output.
|
|
114
|
+
// Therefore, further logging needs to be done directly to process.stderr. Otherwise it would disappear.
|
|
115
|
+
// Therefore, we de-reference all instances now
|
|
116
|
+
this.#progressBarContainer = null;
|
|
117
|
+
this.#progressBar = null;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return this.#progressBar;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#writeMessage(level, message) {
|
|
124
|
+
if (!Logger.isLevelEnabled(level)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const levelPrefix = this.#getLevelPrefix(level);
|
|
128
|
+
const msg = `${levelPrefix} ${message}\n`;
|
|
129
|
+
|
|
130
|
+
if (this.#progressBarContainer) {
|
|
131
|
+
// If a progress bar is in use, we have to log through it's API
|
|
132
|
+
// cli-progress requires full control of the stderr output to ensure correct rendering
|
|
133
|
+
this.#progressBarContainer.log(msg);
|
|
134
|
+
} else {
|
|
135
|
+
process.stderr.write(msg);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#handleLogEvent({level, message, moduleName}) {
|
|
140
|
+
this.#writeMessage(level, `${chalk.blue(moduleName)} ${message}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#handleBuildMetadataEvent({projectsToBuild}) {
|
|
144
|
+
projectsToBuild.forEach((projectName) => {
|
|
145
|
+
this.#projectMetadata.set(projectName, {
|
|
146
|
+
buildStarted: false,
|
|
147
|
+
buildSkipped: false,
|
|
148
|
+
buildEnded: false,
|
|
149
|
+
buildStartIndex: null,
|
|
150
|
+
projectTasks: new Map(),
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
this.#updateProgressBarTotal();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
#handleProjectBuildMetadataEvent({tasksToRun, projectName, projectType}) {
|
|
157
|
+
const projectMetadata = this.#getProjectMetadata(projectName);
|
|
158
|
+
tasksToRun.forEach((taskName) => {
|
|
159
|
+
projectMetadata.projectTasks.set(taskName, {
|
|
160
|
+
executionStarted: false,
|
|
161
|
+
executionEnded: false,
|
|
162
|
+
executionStartIndex: null,
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
this.#updateProgressBarTotal();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#getProjectMetadata(projectName) {
|
|
169
|
+
const projectMetadata = this.#projectMetadata.get(projectName);
|
|
170
|
+
if (!projectMetadata) {
|
|
171
|
+
throw new Error(`writers/Console: Unknown project ${projectName}`);
|
|
172
|
+
}
|
|
173
|
+
return projectMetadata;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#updateProgressBarTotal() {
|
|
177
|
+
let numberOfTasks = 0;
|
|
178
|
+
this.#projectMetadata.forEach(({projectTasks}) => {
|
|
179
|
+
numberOfTasks += projectTasks.size;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Project progress should weigh more than single task progress
|
|
183
|
+
// This is proportional to the number of projects (since that also multiplies the number of tasks)
|
|
184
|
+
this.#progressProjectWeight = this.#projectMetadata.size;
|
|
185
|
+
this._getProgressBar()?.setTotal(
|
|
186
|
+
(this.#progressProjectWeight * this.#projectMetadata.size) + numberOfTasks);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
#handleBuildStatusEvent({level, projectName, projectType, status}) {
|
|
190
|
+
const projectMetadata = this.#getProjectMetadata(projectName);
|
|
191
|
+
if (projectMetadata.buildStartIndex === null) {
|
|
192
|
+
let nextIdx = 1;
|
|
193
|
+
this.#projectMetadata.forEach((metadata) => {
|
|
194
|
+
if (metadata.buildStartIndex !== null && metadata.buildStartIndex >= nextIdx) {
|
|
195
|
+
nextIdx = metadata.buildStartIndex + 1;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
projectMetadata.buildStartIndex = nextIdx;
|
|
199
|
+
}
|
|
200
|
+
const buildIndex = `Project ${projectMetadata.buildStartIndex} of ${this.#projectMetadata.size}`;
|
|
201
|
+
|
|
202
|
+
let message;
|
|
203
|
+
switch (status) {
|
|
204
|
+
case "project-build-start":
|
|
205
|
+
if (projectMetadata.buildEnded) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
`writers/Console: Unexpected project-build-start event for project ${projectName}. ` +
|
|
208
|
+
`Project build already ended`);
|
|
209
|
+
}
|
|
210
|
+
if (projectMetadata.buildStarted) {
|
|
211
|
+
throw new Error(
|
|
212
|
+
`writers/Console: Unexpected duplicate project-build-start event for project ${projectName}`);
|
|
213
|
+
}
|
|
214
|
+
if (projectMetadata.buildSkipped) {
|
|
215
|
+
throw new Error(
|
|
216
|
+
`writers/Console: Unexpected project-build-start event for project ${projectName}. ` +
|
|
217
|
+
`Project build already skipped`);
|
|
218
|
+
}
|
|
219
|
+
projectMetadata.buildStarted = true;
|
|
220
|
+
message = `${chalk.blue(figures.pointer)} ` +
|
|
221
|
+
`Building ${projectType} project ${chalk.bold(projectName)}...`;
|
|
222
|
+
|
|
223
|
+
// Update progress bar message with current project
|
|
224
|
+
this._getProgressBar()?.update({
|
|
225
|
+
message: `${figures.pointer} Building ${projectType} project ${projectName}...`
|
|
226
|
+
});
|
|
227
|
+
break;
|
|
228
|
+
case "project-build-end":
|
|
229
|
+
if (projectMetadata.buildEnded) {
|
|
230
|
+
throw new Error(
|
|
231
|
+
`writers/Console: Unexpected duplicate project-build-end event for project ${projectName}`);
|
|
232
|
+
}
|
|
233
|
+
if (projectMetadata.buildSkipped) {
|
|
234
|
+
throw new Error(
|
|
235
|
+
`writers/Console: Unexpected project-build-end event for project ${projectName}. ` +
|
|
236
|
+
`Project build already skipped`);
|
|
237
|
+
}
|
|
238
|
+
if (!projectMetadata.buildStarted) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`writers/Console: Unexpected project-build-end event for project ${projectName}. ` +
|
|
241
|
+
`No corresponding project-build-start event handled`);
|
|
242
|
+
}
|
|
243
|
+
projectMetadata.buildEnded = true;
|
|
244
|
+
message = `${chalk.green(figures.tick)} ` +
|
|
245
|
+
`Finished building ${projectType} project ${chalk.bold(projectName)}`;
|
|
246
|
+
|
|
247
|
+
// Update progress bar (if used)
|
|
248
|
+
this._getProgressBar()?.increment(this.#progressProjectWeight);
|
|
249
|
+
break;
|
|
250
|
+
case "project-build-skip":
|
|
251
|
+
if (projectMetadata.buildSkipped) {
|
|
252
|
+
throw new Error(
|
|
253
|
+
`writers/Console: Unexpected duplicate project-build-skip event for project ${projectName}`);
|
|
254
|
+
}
|
|
255
|
+
if (projectMetadata.buildEnded) {
|
|
256
|
+
throw new Error(
|
|
257
|
+
`writers/Console: Unexpected project-build-skip event for project ${projectName}. ` +
|
|
258
|
+
`Project build already ended`);
|
|
259
|
+
}
|
|
260
|
+
if (projectMetadata.buildStarted) {
|
|
261
|
+
throw new Error(
|
|
262
|
+
`writers/Console: Unexpected project-build-skip event for project ${projectName}. ` +
|
|
263
|
+
`Project build already started`);
|
|
264
|
+
}
|
|
265
|
+
projectMetadata.buildSkipped = true;
|
|
266
|
+
message = `${chalk.yellow(figures.tick)} ` +
|
|
267
|
+
`Skipping build of ${projectType} project ${chalk.bold(projectName)}`;
|
|
268
|
+
|
|
269
|
+
// Update progress bar (if used)
|
|
270
|
+
// All tasks of this projects are completed
|
|
271
|
+
this._getProgressBar()?.increment(this.#progressProjectWeight + projectMetadata.projectTasks.size);
|
|
272
|
+
break;
|
|
273
|
+
default:
|
|
274
|
+
this.#writeMessage("verbose",
|
|
275
|
+
`writers/Console: Received unknown build-status ${status} for project ${projectName}`);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
this.#writeMessage(level, `${chalk.grey(buildIndex)}: ${message}`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
#handleProjectBuildStatusEvent({level, projectName, projectType, taskName, status}) {
|
|
283
|
+
const {projectTasks} = this.#getProjectMetadata(projectName);
|
|
284
|
+
const taskMetadata = projectTasks.get(taskName);
|
|
285
|
+
if (!taskMetadata) {
|
|
286
|
+
throw new Error(`writers/Console: Unknown task ${taskName} for project ${projectName}`);
|
|
287
|
+
}
|
|
288
|
+
if (taskMetadata.executionStartIndex === null) {
|
|
289
|
+
let nextIdx = 1;
|
|
290
|
+
projectTasks.forEach((metadata) => {
|
|
291
|
+
if (metadata.executionStartIndex !== null && metadata.executionStartIndex >= nextIdx) {
|
|
292
|
+
nextIdx = metadata.executionStartIndex + 1;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
taskMetadata.executionStartIndex = nextIdx;
|
|
296
|
+
}
|
|
297
|
+
let taskIndex = "";
|
|
298
|
+
if (Logger.isLevelEnabled("verbose")) {
|
|
299
|
+
taskIndex = chalk.grey(`Task ${taskMetadata.executionStartIndex} of ${projectTasks.size} `);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
let message;
|
|
303
|
+
switch (status) {
|
|
304
|
+
case "task-start":
|
|
305
|
+
if (taskMetadata.executionEnded) {
|
|
306
|
+
throw new Error(
|
|
307
|
+
`writers/Console: Unexpected task-start event for project ${projectName}, task ${taskName}. ` +
|
|
308
|
+
`Task execution already ended`);
|
|
309
|
+
}
|
|
310
|
+
if (taskMetadata.executionStarted) {
|
|
311
|
+
throw new Error(`writers/Console: Unexpected duplicate task-start event ` +
|
|
312
|
+
`for project ${projectName}, task ${taskName}`);
|
|
313
|
+
}
|
|
314
|
+
taskMetadata.executionStarted = true;
|
|
315
|
+
message = `${chalk.blue(figures.pointerSmall)} Running task ${chalk.bold(taskName)}...`;
|
|
316
|
+
break;
|
|
317
|
+
case "task-end":
|
|
318
|
+
if (taskMetadata.executionEnded) {
|
|
319
|
+
throw new Error(`writers/Console: ` +
|
|
320
|
+
`Unexpected duplicate task-end event for project ${projectName}, task ${taskName}`);
|
|
321
|
+
}
|
|
322
|
+
if (!taskMetadata.executionStarted) {
|
|
323
|
+
throw new Error(
|
|
324
|
+
`writers/Console: Unexpected task-end event for project ${projectName}, task ${taskName}. ` +
|
|
325
|
+
`No corresponding task-start event handled`);
|
|
326
|
+
}
|
|
327
|
+
taskMetadata.executionEnded = true;
|
|
328
|
+
message = `${chalk.green(figures.tick)} Finished task ${chalk.bold(taskName)}`;
|
|
329
|
+
|
|
330
|
+
// Update progress bar (if used)
|
|
331
|
+
this._getProgressBar()?.increment(1);
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
this.#writeMessage("verbose",
|
|
335
|
+
`writers/Console: Received unknown project-build-status ${status} for project ${projectName}`);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
this.#writeMessage(level, `${chalk.blue(`${(projectName)}`)} ${taskIndex}${message}`);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
#getLevelPrefix(level) {
|
|
343
|
+
switch (level) {
|
|
344
|
+
case "silly":
|
|
345
|
+
return chalk.inverse(level);
|
|
346
|
+
case "verbose":
|
|
347
|
+
return chalk.cyan("verb");
|
|
348
|
+
case "perf":
|
|
349
|
+
return chalk.bgYellow.red(level);
|
|
350
|
+
case "info":
|
|
351
|
+
return chalk.green(level);
|
|
352
|
+
case "warn":
|
|
353
|
+
return chalk.yellow(level);
|
|
354
|
+
case "error":
|
|
355
|
+
return chalk.bgRed.white(level);
|
|
356
|
+
// Log level silent does not produce messages
|
|
357
|
+
default:
|
|
358
|
+
return level;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Creates a new instance and subscribes it to all events
|
|
364
|
+
*
|
|
365
|
+
* @public
|
|
366
|
+
*/
|
|
367
|
+
static init() {
|
|
368
|
+
const cH = new Console();
|
|
369
|
+
cH.enable();
|
|
370
|
+
return cH;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
static stop() {
|
|
374
|
+
process.emit("ui5.log.stop-console");
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export default Console;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/logger",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "UI5 Tooling - Internal Logger",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SAP SE",
|
|
@@ -16,10 +16,17 @@
|
|
|
16
16
|
"development",
|
|
17
17
|
"tool"
|
|
18
18
|
],
|
|
19
|
-
"
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./lib/index.js",
|
|
22
|
+
"./Logger": "./lib/loggers/Logger.js",
|
|
23
|
+
"./writers/*": "./lib/writers/*.js",
|
|
24
|
+
"./package.json": "./package.json",
|
|
25
|
+
"./internal/loggers/*": "./lib/loggers/*.js"
|
|
26
|
+
},
|
|
20
27
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
22
|
-
"npm": ">=
|
|
28
|
+
"node": "^16.18.0 || >=18.12.0",
|
|
29
|
+
"npm": ">= 8"
|
|
23
30
|
},
|
|
24
31
|
"scripts": {
|
|
25
32
|
"test": "npm run lint && npm run jsdoc-generate && npm run coverage && npm run depcheck",
|
|
@@ -27,23 +34,22 @@
|
|
|
27
34
|
"lint": "eslint ./",
|
|
28
35
|
"unit": "rimraf test/tmp && ava",
|
|
29
36
|
"unit-verbose": "rimraf test/tmp && cross-env UI5_LOG_LVL=verbose ava --verbose --serial",
|
|
30
|
-
"unit-watch": "
|
|
31
|
-
"unit-
|
|
32
|
-
"unit-xunit": "rimraf test/tmp && ava --tap | tap-xunit --dontUseCommentsAsTestNames=true > test-results.xml",
|
|
37
|
+
"unit-watch": "npm run unit -- --watch",
|
|
38
|
+
"unit-xunit": "rimraf test/tmp && ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\" --tap | tap-xunit --dontUseCommentsAsTestNames=true > test-results.xml",
|
|
33
39
|
"unit-inspect": "cross-env UI5_LOG_LVL=verbose ava debug --break",
|
|
34
|
-
"coverage": "nyc
|
|
40
|
+
"coverage": "rimraf test/tmp && nyc ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\"",
|
|
35
41
|
"coverage-xunit": "nyc --reporter=text --reporter=text-summary --reporter=cobertura npm run unit-xunit",
|
|
36
42
|
"jsdoc": "npm run jsdoc-generate && open-cli jsdocs/index.html",
|
|
37
|
-
"jsdoc-generate": "
|
|
43
|
+
"jsdoc-generate": "jsdoc -c ./jsdoc.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./lib/ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
|
|
38
44
|
"jsdoc-watch": "npm run jsdoc && chokidar \"./lib/**/*.js\" -c \"npm run jsdoc-generate\"",
|
|
39
45
|
"preversion": "npm test",
|
|
40
|
-
"version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
|
|
46
|
+
"version": "git-chglog --sort semver --next-tag v$npm_package_version -o CHANGELOG.md v3.0.0.. && git add CHANGELOG.md",
|
|
41
47
|
"postversion": "git push --follow-tags",
|
|
42
|
-
"release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
|
|
43
|
-
"depcheck": "depcheck --ignores docdash"
|
|
48
|
+
"release-note": "git-chglog --sort semver -c .chglog/release-config.yml v$npm_package_version",
|
|
49
|
+
"depcheck": "depcheck --ignores @ui5/logger,rimraf,docdash,@istanbuljs/esm-loader-hook"
|
|
44
50
|
},
|
|
45
51
|
"files": [
|
|
46
|
-
"
|
|
52
|
+
"CHANGELOG.md",
|
|
47
53
|
"CONTRIBUTING.md",
|
|
48
54
|
"jsdoc.json",
|
|
49
55
|
"lib/**",
|
|
@@ -53,6 +59,9 @@
|
|
|
53
59
|
"ava": {
|
|
54
60
|
"files": [
|
|
55
61
|
"test/lib/**/*.js"
|
|
62
|
+
],
|
|
63
|
+
"nodeArguments": [
|
|
64
|
+
"--no-warnings"
|
|
56
65
|
]
|
|
57
66
|
},
|
|
58
67
|
"nyc": {
|
|
@@ -66,8 +75,8 @@
|
|
|
66
75
|
"jsdocs/**",
|
|
67
76
|
"coverage/**",
|
|
68
77
|
"test/**",
|
|
69
|
-
".eslintrc.
|
|
70
|
-
"jsdoc-plugin.
|
|
78
|
+
".eslintrc.cjs",
|
|
79
|
+
"jsdoc-plugin.cjs"
|
|
71
80
|
],
|
|
72
81
|
"check-coverage": true,
|
|
73
82
|
"statements": 90,
|
|
@@ -100,25 +109,27 @@
|
|
|
100
109
|
"url": "git@github.com:SAP/ui5-logger.git"
|
|
101
110
|
},
|
|
102
111
|
"dependencies": {
|
|
103
|
-
"
|
|
112
|
+
"chalk": "^5.2.0",
|
|
113
|
+
"cli-progress": "^3.11.2",
|
|
114
|
+
"figures": "^5.0.0"
|
|
104
115
|
},
|
|
105
116
|
"devDependencies": {
|
|
106
|
-
"
|
|
117
|
+
"@istanbuljs/esm-loader-hook": "^0.2.0",
|
|
118
|
+
"ava": "^5.2.0",
|
|
107
119
|
"chokidar-cli": "^3.0.0",
|
|
108
120
|
"cross-env": "^7.0.3",
|
|
109
|
-
"depcheck": "^1.4.
|
|
110
|
-
"docdash": "^
|
|
111
|
-
"eslint": "^
|
|
121
|
+
"depcheck": "^1.4.3",
|
|
122
|
+
"docdash": "^2.0.1",
|
|
123
|
+
"eslint": "^8.33.0",
|
|
112
124
|
"eslint-config-google": "^0.14.0",
|
|
113
|
-
"eslint-plugin-ava": "^
|
|
114
|
-
"eslint-plugin-jsdoc": "^
|
|
115
|
-
"jsdoc": "^
|
|
116
|
-
"mock-require": "^3.0.3",
|
|
125
|
+
"eslint-plugin-ava": "^14.0.0",
|
|
126
|
+
"eslint-plugin-jsdoc": "^39.8.0",
|
|
127
|
+
"jsdoc": "^4.0.0",
|
|
117
128
|
"nyc": "^15.1.0",
|
|
118
|
-
"open-cli": "^
|
|
119
|
-
"rimraf": "^
|
|
120
|
-
"sinon": "^
|
|
121
|
-
"
|
|
129
|
+
"open-cli": "^7.1.0",
|
|
130
|
+
"rimraf": "^4.1.2",
|
|
131
|
+
"sinon": "^15.0.1",
|
|
132
|
+
"strip-ansi": "^7.0.1",
|
|
122
133
|
"tap-xunit": "^2.4.1"
|
|
123
134
|
}
|
|
124
135
|
}
|