@ui5/logger 5.0.0-alpha.6 → 5.0.0-alpha.8
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/CHANGELOG.md +19 -0
- package/lib/loggers/Serve.js +17 -6
- package/lib/writers/Console.js +5 -6
- package/lib/writers/InteractiveConsole.js +147 -37
- package/lib/writers/interactiveConsole/remoteConnectionsWarning.js +1 -1
- package/lib/writers/interactiveConsole/render.js +28 -8
- package/lib/writers/interactiveConsole/state/build.js +31 -5
- package/lib/writers/interactiveConsole/state/project.js +29 -2
- package/lib/writers/internal/format.js +41 -0
- package/package.json +4 -4
- package/lib/writers/internal/levelPrefix.js +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
|
4
4
|
|
|
5
5
|
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-logger/compare/v4.0.2...HEAD).
|
|
6
6
|
|
|
7
|
+
## [5.0.0-alpha.8](https://github.com/UI5/cli/compare/logger-v5.0.0-alpha.7...logger-v5.0.0-alpha.8) (2026-08-14)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* Require Node.js ^22.22.2 || ^24.15.0 || >=26.0.0 ([#1522](https://github.com/UI5/cli/issues/1522))
|
|
13
|
+
|
|
14
|
+
### Dependencies
|
|
15
|
+
|
|
16
|
+
* Require Node.js ^22.22.2 || ^24.15.0 || >=26.0.0 ([#1522](https://github.com/UI5/cli/issues/1522)) ([f02105e](https://github.com/UI5/cli/commit/f02105e9a75a6c82526343dc47c4aaf9bccdc6ae))
|
|
17
|
+
|
|
18
|
+
## [5.0.0-alpha.7](https://github.com/UI5/cli/compare/logger-v5.0.0-alpha.6...logger-v5.0.0-alpha.7) (2026-08-05)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* Refine interactive serve logging and warning messaging ([#1483](https://github.com/UI5/cli/issues/1483)) ([acd707b](https://github.com/UI5/cli/commit/acd707b18ec7c8453b9210307574e837a19cca4d))
|
|
24
|
+
* Show resolved framework version in serve console output ([3210e8b](https://github.com/UI5/cli/commit/3210e8b4f1e212621b03afb6f0b888a32aa19f3e))
|
|
25
|
+
|
|
7
26
|
## [5.0.0-alpha.6](https://github.com/UI5/cli/compare/logger-v5.0.0-alpha.5...logger-v5.0.0-alpha.6) (2026-07-10)
|
|
8
27
|
|
|
9
28
|
|
package/lib/loggers/Serve.js
CHANGED
|
@@ -3,7 +3,7 @@ import Logger from "./Logger.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Logger for emitting status events on the lifecycle of a UI5 development server
|
|
6
|
-
* (idle / stale / building / build-done / error).
|
|
6
|
+
* (idle / stale / settling / building / build-done / error).
|
|
7
7
|
* <br><br>
|
|
8
8
|
* Emits <code>ui5.log</code> and <code>ui5.serve-status</code> events on the
|
|
9
9
|
* [<code>process</code>]{@link https://nodejs.org/api/process.html} object, which can be handled
|
|
@@ -38,12 +38,23 @@ class Serve extends Logger {
|
|
|
38
38
|
this.#emitStatus("serve-ready", {}, `Server ready`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
stale
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
// Emits the current stale-project set. An empty list means every project is up-to-date.
|
|
42
|
+
stale(staleProjects) {
|
|
43
|
+
if (!staleProjects || !Array.isArray(staleProjects)) {
|
|
44
|
+
throw new Error("loggers/Serve#stale: Missing or incorrect staleProjects parameter");
|
|
44
45
|
}
|
|
45
|
-
this.#emitStatus("serve-stale", {
|
|
46
|
-
|
|
46
|
+
this.#emitStatus("serve-stale", {staleProjects},
|
|
47
|
+
staleProjects.length ?
|
|
48
|
+
`Stale projects: ${staleProjects.join(", ")}` :
|
|
49
|
+
`All projects up-to-date`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
settling(pendingProjects) {
|
|
53
|
+
if (!pendingProjects || !Array.isArray(pendingProjects)) {
|
|
54
|
+
throw new Error("loggers/Serve#settling: Missing or incorrect pendingProjects parameter");
|
|
55
|
+
}
|
|
56
|
+
this.#emitStatus("serve-settling", {pendingProjects},
|
|
57
|
+
`Waiting for changes to settle in: ${pendingProjects.join(", ")}`);
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
validating(validatingProjects) {
|
package/lib/writers/Console.js
CHANGED
|
@@ -3,7 +3,7 @@ import {chalkStderr as chalk} from "chalk";
|
|
|
3
3
|
import figures from "figures";
|
|
4
4
|
import {MultiBar} from "cli-progress";
|
|
5
5
|
import Logger from "../loggers/Logger.js";
|
|
6
|
-
import {
|
|
6
|
+
import {formatLogLine, prefixModuleName} from "./internal/format.js";
|
|
7
7
|
import {REMOTE_CONNECTIONS_WARNING_LINES} from "./interactiveConsole/remoteConnectionsWarning.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -113,7 +113,7 @@ class Console {
|
|
|
113
113
|
process.on("ui5.project-build-metadata", this._handleProjectBuildMetadataEvent);
|
|
114
114
|
process.on("ui5.build-status", this._handleBuildStatusEvent);
|
|
115
115
|
process.on("ui5.project-build-status", this._handleProjectBuildStatusEvent);
|
|
116
|
-
process.on("ui5.project-
|
|
116
|
+
process.on("ui5.project-resolve-succeeded", this._handleProjectResolvedEvent);
|
|
117
117
|
process.on("ui5.server-listening", this._handleServerListeningEvent);
|
|
118
118
|
process.on("ui5.log.stop-console", this._handleStop);
|
|
119
119
|
}
|
|
@@ -129,7 +129,7 @@ class Console {
|
|
|
129
129
|
process.off("ui5.project-build-metadata", this._handleProjectBuildMetadataEvent);
|
|
130
130
|
process.off("ui5.build-status", this._handleBuildStatusEvent);
|
|
131
131
|
process.off("ui5.project-build-status", this._handleProjectBuildStatusEvent);
|
|
132
|
-
process.off("ui5.project-
|
|
132
|
+
process.off("ui5.project-resolve-succeeded", this._handleProjectResolvedEvent);
|
|
133
133
|
process.off("ui5.server-listening", this._handleServerListeningEvent);
|
|
134
134
|
process.off("ui5.log.stop-console", this._handleStop);
|
|
135
135
|
if (this.#progressBarContainer) {
|
|
@@ -199,8 +199,7 @@ class Console {
|
|
|
199
199
|
if (!Logger.isLevelEnabled(level)) {
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
|
-
const
|
|
203
|
-
const msg = `${levelPrefix} ${message}\n`;
|
|
202
|
+
const msg = formatLogLine(level, message) + "\n";
|
|
204
203
|
|
|
205
204
|
if (this.#progressBarContainer) {
|
|
206
205
|
// If a progress bar is in use, we have to log through it's API
|
|
@@ -213,7 +212,7 @@ class Console {
|
|
|
213
212
|
|
|
214
213
|
#handleLogEvent({level, message, moduleName}) {
|
|
215
214
|
if (this.#filterModule(moduleName)) {
|
|
216
|
-
this.#writeMessage(level,
|
|
215
|
+
this.#writeMessage(level, prefixModuleName(message, moduleName));
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
218
|
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
2
|
import {createLogUpdate} from "log-update";
|
|
3
3
|
import sliceAnsi from "slice-ansi";
|
|
4
|
-
import chalk from "chalk";
|
|
5
4
|
import Logger from "../loggers/Logger.js";
|
|
6
|
-
import {
|
|
5
|
+
import {formatLogLine, prefixModuleName} from "./internal/format.js";
|
|
7
6
|
import {createHeaderState, setTool} from "./interactiveConsole/state/header.js";
|
|
8
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createProjectState,
|
|
9
|
+
setProject,
|
|
10
|
+
setFramework,
|
|
11
|
+
enableProjectPlaceholders,
|
|
12
|
+
setVersionResolving,
|
|
13
|
+
clearVersionResolving,
|
|
14
|
+
} from "./interactiveConsole/state/project.js";
|
|
9
15
|
import {createServerState, setListening, enableServerPlaceholders} from "./interactiveConsole/state/server.js";
|
|
10
16
|
import {
|
|
11
|
-
createBuildState, beginBuild, advanceToProject, setTask, transitionTo, setError, STATES,
|
|
12
|
-
SPINNING_STATES, enableBuildPlaceholders,
|
|
17
|
+
createBuildState, beginBuild, advanceToProject, setTask, transitionTo, setError, setStale, STATES,
|
|
18
|
+
SPINNING_STATES, enableBuildPlaceholders, setDegraded, clearDegraded,
|
|
13
19
|
} from "./interactiveConsole/state/build.js";
|
|
14
20
|
import {
|
|
15
21
|
renderHeaderRegion, renderProjectRegion, renderServerRegion, renderBuildRegion,
|
|
@@ -18,6 +24,20 @@ import {
|
|
|
18
24
|
// Spinner tick interval while in `building` or `validating` state.
|
|
19
25
|
const BUILDING_TICK_MS = 120;
|
|
20
26
|
|
|
27
|
+
// Module names whose info-level logs duplicate state the banner already renders
|
|
28
|
+
// via named build events (ui5.build-metadata / ui5.build-status). Their info
|
|
29
|
+
// lines are suppressed so they don't scroll above the live region. Warnings and
|
|
30
|
+
// errors from these modules, and all other levels, still pass through.
|
|
31
|
+
const BANNER_REDUNDANT_INFO_MODULES = new Set(["ProjectBuilder"]);
|
|
32
|
+
|
|
33
|
+
// DECTCEM "show cursor". log-update hides the cursor on each render; disable()
|
|
34
|
+
// emits this to restore it.
|
|
35
|
+
const CURSOR_SHOW = "[?25h";
|
|
36
|
+
|
|
37
|
+
// Signals that terminate the process while the live region is on-screen.
|
|
38
|
+
// SIGBREAK exists only on Windows; on other platforms the listener is inert.
|
|
39
|
+
const TERMINATION_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM", "SIGBREAK"];
|
|
40
|
+
|
|
21
41
|
// Decode the tail of `stream.write(chunk[, encoding][, callback])`. `encoding`
|
|
22
42
|
// falls back to "utf8" (Node's default) when not supplied.
|
|
23
43
|
function parseWriteArgs(encodingOrCallback, maybeCallback) {
|
|
@@ -40,9 +60,11 @@ function parseWriteArgs(encodingOrCallback, maybeCallback) {
|
|
|
40
60
|
* No command knowledge. Regions render top-to-bottom in a fixed order —
|
|
41
61
|
* header, root project, server, build status — and hidden regions collapse.
|
|
42
62
|
* <br><br>
|
|
43
|
-
* All state is event-driven.
|
|
44
|
-
* <code
|
|
45
|
-
*
|
|
63
|
+
* All state is event-driven. It reacts to process events emitted across
|
|
64
|
+
* <code>@ui5/logger</code> and related packages, including CLI, project,
|
|
65
|
+
* server, build, serve, and log events. These event shapes are internal
|
|
66
|
+
* cross-package contracts within the UI5 CLI codebase and should be kept
|
|
67
|
+
* stable for their in-repo consumers.
|
|
46
68
|
*
|
|
47
69
|
* @public
|
|
48
70
|
* @class
|
|
@@ -77,8 +99,6 @@ class InteractiveConsole {
|
|
|
77
99
|
stderr: {orig: null, partial: ""},
|
|
78
100
|
};
|
|
79
101
|
|
|
80
|
-
#seenProjectResolved = false;
|
|
81
|
-
|
|
82
102
|
// Bound listeners so we can `process.off` them on stop().
|
|
83
103
|
#onLog;
|
|
84
104
|
#onBuildMetadata;
|
|
@@ -88,10 +108,17 @@ class InteractiveConsole {
|
|
|
88
108
|
#onToolInfo;
|
|
89
109
|
#onToolMode;
|
|
90
110
|
#onProjectResolved;
|
|
111
|
+
#onProjectFrameworkResolved;
|
|
112
|
+
#onProjectResolving;
|
|
113
|
+
#onProjectResolveFailed;
|
|
91
114
|
#onServerListening;
|
|
92
115
|
#onStopConsole;
|
|
93
116
|
#onResize;
|
|
94
117
|
|
|
118
|
+
// Termination-signal handlers (plus an `exit` catch-all), keyed by event
|
|
119
|
+
// name, so disable() detaches exactly what enable() registered.
|
|
120
|
+
#signalHandlers = new Map();
|
|
121
|
+
|
|
95
122
|
constructor({stderr = process.stderr} = {}) {
|
|
96
123
|
this.#stderr = stderr;
|
|
97
124
|
this.#headerState = createHeaderState();
|
|
@@ -112,6 +139,7 @@ class InteractiveConsole {
|
|
|
112
139
|
process.emit("ui5.log.stop-console");
|
|
113
140
|
this.#stopped = false;
|
|
114
141
|
this.#attachListeners();
|
|
142
|
+
this.#registerSignalHandlers();
|
|
115
143
|
if (!this.#logUpdate) {
|
|
116
144
|
this.#logUpdate = createLogUpdate(this.#stderr);
|
|
117
145
|
}
|
|
@@ -133,6 +161,9 @@ class InteractiveConsole {
|
|
|
133
161
|
this.#stopped = true;
|
|
134
162
|
this.#clearTick();
|
|
135
163
|
this.#detachListeners();
|
|
164
|
+
// Detach before the terminal teardown so a re-raised signal (see
|
|
165
|
+
// #handleTerminationSignal) doesn't re-enter our handler.
|
|
166
|
+
this.#deregisterSignalHandlers();
|
|
136
167
|
// Flush any partial (non-newline-terminated) buffered writes before
|
|
137
168
|
// we tear down the live region, then restore the process.* originals.
|
|
138
169
|
// Flushing first while the live region is still on-screen keeps the
|
|
@@ -143,9 +174,53 @@ class InteractiveConsole {
|
|
|
143
174
|
// and resets state. End on a clean newline so the prompt lands
|
|
144
175
|
// below the final frame.
|
|
145
176
|
this.#withRenderingGuard(() => this.#logUpdate?.done());
|
|
177
|
+
// done() is a no-op on a non-TTY stderr, so restore the cursor
|
|
178
|
+
// explicitly. This runs after #uninstallWriteInterceptors so the escape
|
|
179
|
+
// reaches the stream instead of being buffered as a partial write.
|
|
180
|
+
this.#stderr.write(CURSOR_SHOW);
|
|
146
181
|
this.#stderr.write("\n");
|
|
147
182
|
}
|
|
148
183
|
|
|
184
|
+
// ---- Termination-signal teardown -----------------------------------------
|
|
185
|
+
// On CTRL+C the process dies without disable() ever running, leaving the
|
|
186
|
+
// cursor hidden. Tear the live region down on the terminating signals, then
|
|
187
|
+
// re-raise so cooperating handlers (profile.js, ProjectBuilder) still run.
|
|
188
|
+
|
|
189
|
+
#registerSignalHandlers() {
|
|
190
|
+
// Re-registering would strand the previous handlers on `process`:
|
|
191
|
+
// #deregisterSignalHandlers() can only detach what the map tracks.
|
|
192
|
+
if (this.#signalHandlers.size > 0) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
for (const signal of TERMINATION_SIGNALS) {
|
|
196
|
+
const handler = () => this.#handleTerminationSignal(signal);
|
|
197
|
+
this.#signalHandlers.set(signal, handler);
|
|
198
|
+
process.on(signal, handler);
|
|
199
|
+
}
|
|
200
|
+
// `exit` covers cooperating handlers that call process.exit(); it never
|
|
201
|
+
// fires on a bare signal kill, hence the signal handlers above.
|
|
202
|
+
const onExit = () => this.disable();
|
|
203
|
+
this.#signalHandlers.set("exit", onExit);
|
|
204
|
+
process.on("exit", onExit);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
#deregisterSignalHandlers() {
|
|
208
|
+
for (const [event, handler] of this.#signalHandlers) {
|
|
209
|
+
process.off(event, handler);
|
|
210
|
+
}
|
|
211
|
+
this.#signalHandlers.clear();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#handleTerminationSignal(signal) {
|
|
215
|
+
// Re-raise only if this call did the teardown, so a stale handler
|
|
216
|
+
// invoked after disable() can't kill an already-stopped process.
|
|
217
|
+
const wasStopped = this.#stopped;
|
|
218
|
+
this.disable();
|
|
219
|
+
if (!wasStopped) {
|
|
220
|
+
process.kill(process.pid, signal);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
149
224
|
// Compose the full live region as a single string. One block per region,
|
|
150
225
|
// separated by their own leading blank line. `log-update` handles wrapping
|
|
151
226
|
// and erase of the previous frame, so we just hand it the full text.
|
|
@@ -225,6 +300,9 @@ class InteractiveConsole {
|
|
|
225
300
|
this.#onToolInfo = (evt) => this.#handleToolInfo(evt);
|
|
226
301
|
this.#onToolMode = (evt) => this.#handleToolMode(evt);
|
|
227
302
|
this.#onProjectResolved = (evt) => this.#handleProjectResolved(evt);
|
|
303
|
+
this.#onProjectFrameworkResolved = (evt) => this.#handleProjectFrameworkResolved(evt);
|
|
304
|
+
this.#onProjectResolving = () => this.#handleProjectResolving();
|
|
305
|
+
this.#onProjectResolveFailed = (evt) => this.#handleProjectResolveFailed(evt);
|
|
228
306
|
this.#onServerListening = (evt) => this.#handleServerListening(evt);
|
|
229
307
|
this.#onStopConsole = () => this.disable();
|
|
230
308
|
this.#onResize = () => this.#handleResize();
|
|
@@ -236,7 +314,10 @@ class InteractiveConsole {
|
|
|
236
314
|
process.on("ui5.serve-status", this.#onServeStatus);
|
|
237
315
|
process.on("ui5.tool-info", this.#onToolInfo);
|
|
238
316
|
process.on("ui5.tool-mode", this.#onToolMode);
|
|
239
|
-
process.on("ui5.project-
|
|
317
|
+
process.on("ui5.project-resolve-succeeded", this.#onProjectResolved);
|
|
318
|
+
process.on("ui5.project-framework-resolved", this.#onProjectFrameworkResolved);
|
|
319
|
+
process.on("ui5.project-resolve-started", this.#onProjectResolving);
|
|
320
|
+
process.on("ui5.project-resolve-failed", this.#onProjectResolveFailed);
|
|
240
321
|
process.on("ui5.server-listening", this.#onServerListening);
|
|
241
322
|
process.on("ui5.log.stop-console", this.#onStopConsole);
|
|
242
323
|
if (typeof this.#stderr.on === "function") {
|
|
@@ -252,7 +333,10 @@ class InteractiveConsole {
|
|
|
252
333
|
process.off("ui5.serve-status", this.#onServeStatus);
|
|
253
334
|
process.off("ui5.tool-info", this.#onToolInfo);
|
|
254
335
|
process.off("ui5.tool-mode", this.#onToolMode);
|
|
255
|
-
process.off("ui5.project-
|
|
336
|
+
process.off("ui5.project-resolve-succeeded", this.#onProjectResolved);
|
|
337
|
+
process.off("ui5.project-framework-resolved", this.#onProjectFrameworkResolved);
|
|
338
|
+
process.off("ui5.project-resolve-started", this.#onProjectResolving);
|
|
339
|
+
process.off("ui5.project-resolve-failed", this.#onProjectResolveFailed);
|
|
256
340
|
process.off("ui5.server-listening", this.#onServerListening);
|
|
257
341
|
process.off("ui5.log.stop-console", this.#onStopConsole);
|
|
258
342
|
if (typeof this.#stderr.off === "function") {
|
|
@@ -261,23 +345,13 @@ class InteractiveConsole {
|
|
|
261
345
|
}
|
|
262
346
|
|
|
263
347
|
#handleLog({level, message, moduleName}) {
|
|
264
|
-
|
|
265
|
-
// the build's state). Verbose / perf / silly users hit the fallback
|
|
266
|
-
// path before the writer ever activates. Warnings and errors persist —
|
|
267
|
-
// but only if the configured log level lets them through. The standard
|
|
268
|
-
// ConsoleWriter does this filtering implicitly via its `#writeMessage`;
|
|
269
|
-
// this writer acts as its own sink here, so it has to check too.
|
|
270
|
-
if (level !== "warn" && level !== "error") {
|
|
348
|
+
if (!Logger.isLevelEnabled(level)) {
|
|
271
349
|
return;
|
|
272
350
|
}
|
|
273
|
-
if (
|
|
351
|
+
if (level === "info" && BANNER_REDUNDANT_INFO_MODULES.has(moduleName)) {
|
|
274
352
|
return;
|
|
275
353
|
}
|
|
276
|
-
|
|
277
|
-
const formatted = moduleName ?
|
|
278
|
-
`${levelPrefix} ${chalk.blue(moduleName)} ${message}` :
|
|
279
|
-
`${levelPrefix} ${message}`;
|
|
280
|
-
this.logAbove(formatted);
|
|
354
|
+
this.logAbove(formatLogLine(level, prefixModuleName(message, moduleName)));
|
|
281
355
|
}
|
|
282
356
|
|
|
283
357
|
#handleToolInfo(evt) {
|
|
@@ -303,16 +377,39 @@ class InteractiveConsole {
|
|
|
303
377
|
}
|
|
304
378
|
|
|
305
379
|
#handleProjectResolved(evt) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
throw new Error(
|
|
312
|
-
`writers/InteractiveConsole: Received duplicate ui5.project-resolved event`);
|
|
313
|
-
}
|
|
314
|
-
this.#seenProjectResolved = true;
|
|
380
|
+
// The writer's model is single-root-project, but the root can be resolved more
|
|
381
|
+
// than once in a process: `Supervisor.reinitialize()` re-resolves the graph
|
|
382
|
+
// on a project-definition change (a `git checkout`, a hand-edit of ui5.yaml), and
|
|
383
|
+
// re-emits this event for the same root. A repeat updates the project region in
|
|
384
|
+
// place; framework data is updated through `ui5.project-framework-resolved`.
|
|
315
385
|
setProject(this.#projectState, evt);
|
|
386
|
+
// A completed re-resolve lifts any degraded state a prior failed re-resolve left sticky, so
|
|
387
|
+
// the next `serve-ready` from the fresh stack renders "ready" normally again.
|
|
388
|
+
clearDegraded(this.#buildState);
|
|
389
|
+
this.#render();
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
#handleProjectFrameworkResolved({framework}) {
|
|
393
|
+
setFramework(this.#projectState, framework);
|
|
394
|
+
this.#render();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// A definition change is coming: blank the version slot(s) to a "resolving" placeholder. A
|
|
398
|
+
// completed resolve arrives as `ui5.project-resolve-succeeded` and repopulates them via
|
|
399
|
+
// #handleProjectResolved; an abandoned or failed resolve arrives as `ui5.project-resolve-failed`.
|
|
400
|
+
#handleProjectResolving() {
|
|
401
|
+
setVersionResolving(this.#projectState);
|
|
402
|
+
this.#render();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// A re-resolve was abandoned or failed with no `ui5.project-resolve-succeeded`: release the
|
|
406
|
+
// placeholder back to the last-known version rather than leave it on "resolving". A failed
|
|
407
|
+
// re-resolve also means the server is now serving a last-good graph that no longer matches disk;
|
|
408
|
+
// mark it degraded and surface the reason on the (sticky) ERROR status line.
|
|
409
|
+
#handleProjectResolveFailed(evt) {
|
|
410
|
+
clearVersionResolving(this.#projectState);
|
|
411
|
+
setDegraded(this.#buildState);
|
|
412
|
+
setError(this.#buildState, evt?.message);
|
|
316
413
|
this.#render();
|
|
317
414
|
}
|
|
318
415
|
|
|
@@ -346,13 +443,27 @@ class InteractiveConsole {
|
|
|
346
443
|
if (evt.status !== "serve-validating") {
|
|
347
444
|
this.#buildState.validatingProjects = [];
|
|
348
445
|
}
|
|
446
|
+
// While degraded (a re-resolve failed and the last-good stack keeps serving), the surviving
|
|
447
|
+
// BuildServer still resettles to IDLE/stale on the branch switch's source churn and would
|
|
448
|
+
// otherwise repaint "ready" over the degraded ERROR line. Suppress those transitions until a
|
|
449
|
+
// successful re-resolve clears the flag (via `ui5.project-resolve-succeeded`). A genuine
|
|
450
|
+
// `serve-error` still passes through: it keeps the line on ERROR either way.
|
|
451
|
+
if (this.#buildState.degraded && evt.status !== "serve-error") {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
349
454
|
switch (evt.status) {
|
|
350
455
|
case "serve-ready":
|
|
351
456
|
this.#transitionTo(STATES.READY);
|
|
352
457
|
break;
|
|
353
458
|
case "serve-stale":
|
|
354
|
-
|
|
355
|
-
|
|
459
|
+
// Record the stale set and re-render without a state transition, so the count updates
|
|
460
|
+
// in place beneath the current status (typically `ready`).
|
|
461
|
+
setStale(this.#buildState, evt.staleProjects);
|
|
462
|
+
this.#render();
|
|
463
|
+
break;
|
|
464
|
+
case "serve-settling":
|
|
465
|
+
this.#buildState.pendingProjects = evt.pendingProjects || [];
|
|
466
|
+
this.#transitionTo(STATES.SETTLING);
|
|
356
467
|
break;
|
|
357
468
|
case "serve-building":
|
|
358
469
|
beginBuild(this.#buildState, this.#buildState.projectOrder);
|
|
@@ -360,7 +471,6 @@ class InteractiveConsole {
|
|
|
360
471
|
break;
|
|
361
472
|
case "serve-validating":
|
|
362
473
|
this.#buildState.validatingProjects = evt.validatingProjects || [];
|
|
363
|
-
this.#buildState.spinFrame = 0;
|
|
364
474
|
this.#transitionTo(STATES.VALIDATING);
|
|
365
475
|
break;
|
|
366
476
|
case "serve-build-done":
|
|
@@ -8,7 +8,7 @@ import figures from "figures";
|
|
|
8
8
|
export const REMOTE_CONNECTIONS_WARNING_LINES = Object.freeze([
|
|
9
9
|
chalk.bold.yellow(
|
|
10
10
|
`${figures.warning} This server is accepting connections from all hosts on your network`),
|
|
11
|
-
chalk.dim.underline("
|
|
11
|
+
chalk.dim.underline("Warning:"),
|
|
12
12
|
chalk.dim(`${figures.pointerSmall} `) +
|
|
13
13
|
chalk.dim.bold("This server is intended for development purposes only. Do not use it in production."),
|
|
14
14
|
chalk.dim(`${figures.pointerSmall} ` +
|
|
@@ -8,6 +8,8 @@ import {REMOTE_CONNECTIONS_WARNING_LINES} from "./remoteConnectionsWarning.js";
|
|
|
8
8
|
const SPINNER_FRAMES = ["◐", "◓", "◑", "◒"];
|
|
9
9
|
const STATE_LABEL_WIDTH = "building".length;
|
|
10
10
|
const pad = (s) => s.padEnd(STATE_LABEL_WIDTH);
|
|
11
|
+
// "1 project" / "2 projects" - shared by the stale (ready) and validating counts.
|
|
12
|
+
const projectCount = (n) => `${n} project${n === 1 ? "" : "s"}`;
|
|
11
13
|
|
|
12
14
|
// Align continuation lines (additional network URLs / extra placeholders)
|
|
13
15
|
// under the first URL slot. The arrow, single space, and "Network: " label
|
|
@@ -43,8 +45,14 @@ export function renderProjectRegion(projectState) {
|
|
|
43
45
|
if (projectState.project) {
|
|
44
46
|
const project = projectState.project;
|
|
45
47
|
const framework = projectState.framework;
|
|
48
|
+
const resolving = projectState.versionResolving;
|
|
46
49
|
const projectType = project.type ? chalk.dim(`(${project.type})`) : "";
|
|
47
|
-
|
|
50
|
+
// While a re-resolve is pending, the version is about to change: show a placeholder in
|
|
51
|
+
// its slot rather than the stale value. The name and type keep showing so the region
|
|
52
|
+
// does not collapse.
|
|
53
|
+
const projectVersion = resolving ?
|
|
54
|
+
placeholder("resolving…") :
|
|
55
|
+
(project.version ? chalk.dim("v" + project.version) : "");
|
|
48
56
|
lines.push(`${chalk.dim("Project")} ${chalk.bold(project.name)}` +
|
|
49
57
|
(projectType ? ` ${projectType}` : "") +
|
|
50
58
|
(projectVersion ? ` ${projectVersion}` : ""));
|
|
@@ -54,12 +62,16 @@ export function renderProjectRegion(projectState) {
|
|
|
54
62
|
// making "(none)" misleading; omitting the row also avoids a stale
|
|
55
63
|
// "Framework resolving…" placeholder flashing before it disappears.
|
|
56
64
|
if (framework?.name) {
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
// The framework version goes stale alongside the project version on a branch
|
|
66
|
+
// switch: placeholder it too, keeping the name.
|
|
67
|
+
const frameworkVersion = resolving ?
|
|
68
|
+
` ${placeholder("resolving…")}` :
|
|
69
|
+
(framework.version ? chalk.bold(` ${framework.version}`) : "");
|
|
70
|
+
lines.push(`${chalk.dim("Framework")} ${chalk.bold(framework.name)}${frameworkVersion}`);
|
|
59
71
|
}
|
|
60
72
|
} else {
|
|
61
73
|
// Placeholder mode: reserve only the Project row. The Framework row is
|
|
62
|
-
// deferred until
|
|
74
|
+
// deferred until framework resolution reveals a real framework name.
|
|
63
75
|
lines.push(`${chalk.dim("Project")} ${placeholder("resolving…")}`);
|
|
64
76
|
}
|
|
65
77
|
return lines;
|
|
@@ -145,11 +157,19 @@ function renderStatusLine(state) {
|
|
|
145
157
|
if (state.lastBuildHrtime) {
|
|
146
158
|
suffix = ` ${chalk.dim("·")} ${chalk.dim("Time elapsed: " + prettyHrtime(state.lastBuildHrtime))}`;
|
|
147
159
|
}
|
|
160
|
+
// Append the stale count to the ready line.
|
|
161
|
+
const staleCount = state.staleProjects.length;
|
|
162
|
+
if (staleCount > 0) {
|
|
163
|
+
suffix += ` ${chalk.dim("·")} ` +
|
|
164
|
+
chalk.yellow(`${projectCount(staleCount)} stale`);
|
|
165
|
+
}
|
|
148
166
|
return `${label}${chalk.green(figures.bullet)} ${chalk.green(pad("ready"))}${suffix}`;
|
|
149
167
|
}
|
|
150
|
-
case STATES.
|
|
151
|
-
|
|
152
|
-
|
|
168
|
+
case STATES.SETTLING: {
|
|
169
|
+
const frame = SPINNER_FRAMES[state.spinFrame % SPINNER_FRAMES.length];
|
|
170
|
+
return `${label}${chalk.yellow(frame)} ${chalk.yellow(pad("settling"))} ` +
|
|
171
|
+
`${chalk.dim("· waiting for changes to settle")}`;
|
|
172
|
+
}
|
|
153
173
|
case STATES.VALIDATING: {
|
|
154
174
|
const frame = SPINNER_FRAMES[state.spinFrame % SPINNER_FRAMES.length];
|
|
155
175
|
const parts = [
|
|
@@ -159,7 +179,7 @@ function renderStatusLine(state) {
|
|
|
159
179
|
];
|
|
160
180
|
const count = state.validatingProjects.length;
|
|
161
181
|
if (count > 0) {
|
|
162
|
-
parts.push(chalk.dim("·"), chalk.dim(
|
|
182
|
+
parts.push(chalk.dim("·"), chalk.dim(projectCount(count)));
|
|
163
183
|
}
|
|
164
184
|
return `${label}${parts.join(" ")}`;
|
|
165
185
|
}
|
|
@@ -5,7 +5,7 @@ export const STATES = Object.freeze({
|
|
|
5
5
|
INITIAL: "initial",
|
|
6
6
|
STARTING: "starting", // pre-populated placeholder before the first real state arrives
|
|
7
7
|
READY: "ready",
|
|
8
|
-
|
|
8
|
+
SETTLING: "settling", // changes seen, rebuild deferred until they quiesce
|
|
9
9
|
BUILDING: "building",
|
|
10
10
|
VALIDATING: "validating",
|
|
11
11
|
ERROR: "error",
|
|
@@ -14,7 +14,7 @@ export const STATES = Object.freeze({
|
|
|
14
14
|
// States that animate a spinner. Consulted by both the tick scheduler in the
|
|
15
15
|
// interactive console writer and the status-line renderer, so a state either
|
|
16
16
|
// spins in both places or in neither.
|
|
17
|
-
export const SPINNING_STATES = new Set([STATES.BUILDING, STATES.VALIDATING]);
|
|
17
|
+
export const SPINNING_STATES = new Set([STATES.SETTLING, STATES.BUILDING, STATES.VALIDATING]);
|
|
18
18
|
|
|
19
19
|
export function createBuildState() {
|
|
20
20
|
return {
|
|
@@ -25,12 +25,15 @@ export function createBuildState() {
|
|
|
25
25
|
totalProjects: 0,
|
|
26
26
|
currentProjectName: "",
|
|
27
27
|
currentTaskName: "",
|
|
28
|
-
// Names of projects
|
|
29
|
-
// the
|
|
30
|
-
|
|
28
|
+
// Names of projects currently stale, reported via `serve-stale`. The renderer surfaces
|
|
29
|
+
// the count alongside the ready line.
|
|
30
|
+
staleProjects: [],
|
|
31
31
|
// Names of projects collected via `serve-validating` payloads — used to
|
|
32
32
|
// label the validating state if/when the renderer wants to.
|
|
33
33
|
validatingProjects: [],
|
|
34
|
+
// Names of projects collected via `serve-settling` payloads — used to
|
|
35
|
+
// label the settling state if/when the renderer wants to.
|
|
36
|
+
pendingProjects: [],
|
|
34
37
|
// Frame counter for the spinner (incremented by the tick loop).
|
|
35
38
|
spinFrame: 0,
|
|
36
39
|
// Most recent error captured by `serve-error`.
|
|
@@ -47,6 +50,12 @@ export function createBuildState() {
|
|
|
47
50
|
// Ordered list of projects announced by build-metadata. Used to compute
|
|
48
51
|
// a stable 1-based `currentProjectIndex` when build-status events arrive.
|
|
49
52
|
projectOrder: [],
|
|
53
|
+
// True while the server is serving a last-good graph after a failed re-resolve (e.g. a
|
|
54
|
+
// branch switch to a config the tooling can't resolve). The status line reuses the ERROR
|
|
55
|
+
// rendering; this flag makes it sticky so the surviving BuildServer's `serve-ready` from
|
|
56
|
+
// source churn can't repaint "ready" over it. Set by `ui5.project-resolve-failed`, cleared
|
|
57
|
+
// by `ui5.project-resolve-succeeded`.
|
|
58
|
+
degraded: false,
|
|
50
59
|
};
|
|
51
60
|
}
|
|
52
61
|
|
|
@@ -88,11 +97,28 @@ export function transitionTo(state, newState) {
|
|
|
88
97
|
state.spinFrame = 0;
|
|
89
98
|
}
|
|
90
99
|
|
|
100
|
+
// Record the current stale-project set, reported via `serve-stale`. Does not touch the
|
|
101
|
+
// activity `state` or reset the spinner: the count updates in place beneath the current status.
|
|
102
|
+
export function setStale(state, staleProjects) {
|
|
103
|
+
state.staleProjects = Array.isArray(staleProjects) ? staleProjects : [];
|
|
104
|
+
}
|
|
105
|
+
|
|
91
106
|
export function setError(state, message) {
|
|
92
107
|
state.errorMessage = message || "";
|
|
93
108
|
transitionTo(state, STATES.ERROR);
|
|
94
109
|
}
|
|
95
110
|
|
|
111
|
+
// Marks the server degraded after a failed re-resolve. The caller pairs this with `setError` to
|
|
112
|
+
// render the reason on the ERROR line; this flag keeps that line sticky against later `serve-ready`
|
|
113
|
+
// events from the surviving BuildServer until a successful re-resolve calls `clearDegraded`.
|
|
114
|
+
export function setDegraded(state) {
|
|
115
|
+
state.degraded = true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function clearDegraded(state) {
|
|
119
|
+
state.degraded = false;
|
|
120
|
+
}
|
|
121
|
+
|
|
96
122
|
// Advance the region into a "starting" placeholder state so the Status row is
|
|
97
123
|
// visible from the first frame. Called from `ui5.tool-mode`. Real state
|
|
98
124
|
// transitions (READY/BUILDING/…) replace it.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// Region 2
|
|
1
|
+
// Region 2 - root project. Populated by `ui5.project-resolve-succeeded` and, when
|
|
2
|
+
// framework usage is actually resolved for the current run, by
|
|
3
|
+
// `ui5.project-framework-resolved`.
|
|
2
4
|
export function createProjectState() {
|
|
3
5
|
return {
|
|
4
6
|
project: null, // {name, type, version}
|
|
@@ -7,14 +9,39 @@ export function createProjectState() {
|
|
|
7
9
|
// of real data. Enabled by `ui5.tool-mode` before the graph is built so
|
|
8
10
|
// the layout is stable from the very first frame.
|
|
9
11
|
showPlaceholders: false,
|
|
12
|
+
// When true, the version slot(s) render a dim "resolving" placeholder while the project
|
|
13
|
+
// name and type keep showing. Enabled by `ui5.project-resolve-started` once a definition
|
|
14
|
+
// change is known to be coming (a `git checkout`, a ui5.yaml edit) and the resolved version
|
|
15
|
+
// is about to change. `setProject` clears it; a failed re-resolve releases it via
|
|
16
|
+
// `clearVersionResolving`.
|
|
17
|
+
versionResolving: false,
|
|
10
18
|
};
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export function setProject(state, evt) {
|
|
14
22
|
state.project = {name: evt.name, type: evt.type, version: evt.version};
|
|
15
|
-
|
|
23
|
+
// A resolve completed: drop the placeholder in favour of the new version.
|
|
24
|
+
state.versionResolving = false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function setFramework(state, framework) {
|
|
28
|
+
state.framework = framework ? {
|
|
29
|
+
name: framework.name,
|
|
30
|
+
version: framework.version,
|
|
31
|
+
} : null;
|
|
16
32
|
}
|
|
17
33
|
|
|
18
34
|
export function enableProjectPlaceholders(state) {
|
|
19
35
|
state.showPlaceholders = true;
|
|
20
36
|
}
|
|
37
|
+
|
|
38
|
+
// Blanks the version slot(s) to a "resolving" placeholder: a re-resolve is coming.
|
|
39
|
+
export function setVersionResolving(state) {
|
|
40
|
+
state.versionResolving = true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Releases the placeholder back to the last-known version: a re-resolve was abandoned or failed
|
|
44
|
+
// with no `ui5.project-resolve-succeeded`.
|
|
45
|
+
export function clearVersionResolving(state) {
|
|
46
|
+
state.versionResolving = false;
|
|
47
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {chalkStderr as chalk} from "chalk";
|
|
2
|
+
|
|
3
|
+
// Shared message-formatting helpers used by every console-writing writer so
|
|
4
|
+
// scrolled log lines look identical regardless of which writer produced them.
|
|
5
|
+
// Kept as an internal helper module rather than a public export — the exact
|
|
6
|
+
// styling is an implementation detail of `writers/Console` and its siblings.
|
|
7
|
+
|
|
8
|
+
function getLevelPrefix(level) {
|
|
9
|
+
switch (level) {
|
|
10
|
+
case "silly":
|
|
11
|
+
return chalk.inverse(level);
|
|
12
|
+
case "verbose":
|
|
13
|
+
return chalk.cyan("verb");
|
|
14
|
+
case "perf":
|
|
15
|
+
return chalk.bgYellow.red(level);
|
|
16
|
+
case "info":
|
|
17
|
+
return chalk.green(level);
|
|
18
|
+
case "warn":
|
|
19
|
+
return chalk.yellow(level);
|
|
20
|
+
case "error":
|
|
21
|
+
return chalk.bgRed.white(level);
|
|
22
|
+
default:
|
|
23
|
+
// Log level silent does not produce messages
|
|
24
|
+
throw new Error(`writers/internal/format: Invalid message log level "${level}"`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Prepend the blue module name to a message when one is present. Both console
|
|
29
|
+
// writers render log messages as "<moduleName> <message>", omitting the module
|
|
30
|
+
// name when it is absent.
|
|
31
|
+
export function prefixModuleName(message, moduleName) {
|
|
32
|
+
return moduleName ? `${chalk.blue(moduleName)} ${message}` : message;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Render a full log line as "<levelPrefix> <message>". The trailing newline is
|
|
36
|
+
// left to the caller: `writers/Console` writes straight to the stream and needs
|
|
37
|
+
// it, while `writers/InteractiveConsole` hands the line to log-update, which
|
|
38
|
+
// adds its own.
|
|
39
|
+
export function formatLogLine(level, message) {
|
|
40
|
+
return `${getLevelPrefix(level)} ${message}`;
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/logger",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.8",
|
|
4
4
|
"description": "UI5 CLI - Internal Logger",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SAP SE",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"./internal/loggers/*": "./lib/loggers/*.js"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": "^22.
|
|
28
|
+
"node": "^22.22.2 || ^24.15.0 || >=26.0.0",
|
|
29
29
|
"npm": ">= 8"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@istanbuljs/esm-loader-hook": "^0.3.0",
|
|
60
|
-
"ava": "^
|
|
60
|
+
"ava": "^8.0.1",
|
|
61
61
|
"cross-env": "^10.1.0",
|
|
62
|
-
"eslint": "^10.
|
|
62
|
+
"eslint": "^10.7.0",
|
|
63
63
|
"nyc": "^18.0.0",
|
|
64
64
|
"rimraf": "^6.1.3",
|
|
65
65
|
"sinon": "^21.1.2",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {chalkStderr as chalk} from "chalk";
|
|
2
|
-
|
|
3
|
-
// Shared level-prefix renderer used by every console-writing writer so scrolled
|
|
4
|
-
// log lines look identical regardless of which writer produced them. Kept as
|
|
5
|
-
// an internal helper module rather than a public export — the exact styling is
|
|
6
|
-
// an implementation detail of `writers/Console` and its siblings.
|
|
7
|
-
export function getLevelPrefix(level) {
|
|
8
|
-
switch (level) {
|
|
9
|
-
case "silly":
|
|
10
|
-
return chalk.inverse(level);
|
|
11
|
-
case "verbose":
|
|
12
|
-
return chalk.cyan("verb");
|
|
13
|
-
case "perf":
|
|
14
|
-
return chalk.bgYellow.red(level);
|
|
15
|
-
case "info":
|
|
16
|
-
return chalk.green(level);
|
|
17
|
-
case "warn":
|
|
18
|
-
return chalk.yellow(level);
|
|
19
|
-
case "error":
|
|
20
|
-
return chalk.bgRed.white(level);
|
|
21
|
-
default:
|
|
22
|
-
// Log level silent does not produce messages
|
|
23
|
-
throw new Error(`writers/internal/levelPrefix: Invalid message log level "${level}"`);
|
|
24
|
-
}
|
|
25
|
-
}
|