@egen-civitas/egen 2.1.0 → 2.1.1
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 +7 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -2
- package/dist/utils/devserver.js +3 -2
- package/dist/utils/log-hub.d.ts +6 -3
- package/dist/utils/log-hub.d.ts.map +1 -1
- package/dist/utils/log-hub.js +25 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @egen-civitas/egen
|
|
2
2
|
|
|
3
|
+
## 2.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e8ccb0f: Hub de logs : niveaux plus justes (pluriels « errors/warnings », succès resserré, stderr sans indice = info), lignes de suite d'un bloc d'erreur/avertissement héritant du niveau, retours chariot (barres de progression) réduits à leur dernier état, couleurs ANSI conservées chez les processus fils, ids croissants entre redémarrages (reprise SSE fiable).
|
|
8
|
+
- @egen-civitas/esm-app-shell@2.6.2
|
|
9
|
+
|
|
3
10
|
## 2.1.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAc,EAAE,KAAK,IAAI,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAc,EAAE,KAAK,IAAI,EAAE,MAAM,OAAO,CAAC;AAsDzC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,YA6W/B"}
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { fork } from "child_process";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
|
-
import { getAvailablePort, getImportmapAndRoutes, isPortAvailable, startLogHub, getLogHub, logFail, mergeImportmapAndRoutes, proxyImportmapAndRoutes, resolvePackages, runProject, trimEnd } from "./utils/index.js";
|
|
5
|
+
import { getAvailablePort, getImportmapAndRoutes, isPortAvailable, startLogHub, childColorEnv, getLogHub, logFail, mergeImportmapAndRoutes, proxyImportmapAndRoutes, resolvePackages, runProject, trimEnd } from "./utils/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Port explicite de l'URL du backend (ex. 8082 pour http://localhost:8082), à réserver : les serveurs de
|
|
8
8
|
* dev des apps sont alloués à partir de `port + 1` et ne doivent JAMAIS prendre le port du backend, même
|
|
@@ -24,7 +24,8 @@ function runCommand(type, args) {
|
|
|
24
24
|
const hub = type === 'runDevelop' ? getLogHub() : undefined;
|
|
25
25
|
const ps = fork(runner, [], {
|
|
26
26
|
cwd: type === 'runBuild' ? root : process.cwd(),
|
|
27
|
-
silent: !!hub
|
|
27
|
+
silent: !!hub,
|
|
28
|
+
env: hub ? childColorEnv() : process.env
|
|
28
29
|
});
|
|
29
30
|
hub?.attachChild(ps, 'egen-develop');
|
|
30
31
|
ps.send({
|
package/dist/utils/devserver.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { resolve } from "path";
|
|
2
2
|
import { basename } from "path";
|
|
3
3
|
import { fork } from "child_process";
|
|
4
|
-
import { getLogHub } from "./log-hub.js";
|
|
4
|
+
import { childColorEnv, getLogHub } from "./log-hub.js";
|
|
5
5
|
export function startDevServer(source, port, cwd = process.cwd(), useRspack = false) {
|
|
6
6
|
const runner = resolve(import.meta.dirname, 'debugger.js');
|
|
7
7
|
const hub = getLogHub();
|
|
8
8
|
// Avec le hub, la sortie du serveur de dev transite par lui (puis est réémise dans le terminal).
|
|
9
9
|
const ps = fork(runner, [], {
|
|
10
10
|
cwd,
|
|
11
|
-
silent: !!hub
|
|
11
|
+
silent: !!hub,
|
|
12
|
+
env: hub ? childColorEnv() : process.env
|
|
12
13
|
});
|
|
13
14
|
hub?.attachChild(ps, basename(cwd));
|
|
14
15
|
ps.send({
|
package/dist/utils/log-hub.d.ts
CHANGED
|
@@ -17,16 +17,17 @@ export interface LogEntry {
|
|
|
17
17
|
message: string;
|
|
18
18
|
}
|
|
19
19
|
export declare function stripAnsi(text: string): string;
|
|
20
|
-
/**
|
|
21
|
-
export declare function detectLevel(line: string
|
|
20
|
+
/** Niveau explicite d'une ligne, ou `undefined` si rien ne l'indique (le niveau vient alors du contexte). */
|
|
21
|
+
export declare function detectLevel(line: string): LogLevel | undefined;
|
|
22
22
|
export declare class LogHub {
|
|
23
23
|
private entries;
|
|
24
24
|
private nextId;
|
|
25
|
+
private lastLevel;
|
|
25
26
|
private clients;
|
|
26
27
|
private partial;
|
|
27
28
|
private server?;
|
|
28
29
|
private readonly write;
|
|
29
|
-
push(source: string, line: string,
|
|
30
|
+
push(source: string, line: string, _stream?: 'out' | 'err'): void;
|
|
30
31
|
/** Découpe un flux en lignes complètes (le reste attend le prochain bloc). */
|
|
31
32
|
ingest(source: string, chunk: string | Buffer, stream?: 'out' | 'err'): void;
|
|
32
33
|
/** Duplique stdout/stderr du processus courant dans le hub (le terminal reste inchangé). */
|
|
@@ -35,6 +36,8 @@ export declare class LogHub {
|
|
|
35
36
|
attachChild(child: ChildProcess, source: string): void;
|
|
36
37
|
start(): Promise<number>;
|
|
37
38
|
}
|
|
39
|
+
/** Env des processus fils capturés : sortie piped = non-TTY, donc on force les couleurs si le terminal en a. */
|
|
40
|
+
export declare function childColorEnv(): NodeJS.ProcessEnv;
|
|
38
41
|
export declare function getLogHub(): LogHub | undefined;
|
|
39
42
|
/** Démarre (une seule fois) le hub : capte le processus courant et retourne son port local. */
|
|
40
43
|
export declare function startLogHub(): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-hub.d.ts","sourceRoot":"","sources":["../../src/utils/log-hub.ts"],"names":[],"mappings":"AAEA,OAA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AAC,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGpB;IAEF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,KAAK,GAAG,KAAa;IAgBjE,8EAA8E;IAC9E,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,GAAE,KAAK,GAAG,KAAa;IAQ5E,4FAA4F;IAC5F,UAAU,CAAC,MAAM,EAAE,MAAM;IAczB,oGAAoG;IACpG,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAW/C,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;CAyCzB;AAED,gHAAgH;AAChH,wBAAgB,aAAa,IAAI,MAAM,CAAC,UAAU,CAGjD;AAID,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAE9C;AAED,+FAA+F;AAC/F,wBAAsB,WAAW,IAAI,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAK1E"}
|
package/dist/utils/log-hub.js
CHANGED
|
@@ -18,19 +18,26 @@ const ANSI = /\u001b\[[0-9;]*[A-Za-z]/g;
|
|
|
18
18
|
export function stripAnsi(text) {
|
|
19
19
|
return text.replace(ANSI, '');
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
21
|
+
/** Niveau explicite d'une ligne, ou `undefined` si rien ne l'indique (le niveau vient alors du contexte). */ export function detectLevel(line) {
|
|
22
22
|
const text = stripAnsi(line);
|
|
23
|
-
if (/\b(
|
|
24
|
-
if (/\b(warn
|
|
25
|
-
if (/\b(success
|
|
23
|
+
if (/\b(errors?|erreurs?|fatal|failed|failure|exception|ELIFECYCLE|ERR_[A-Z_]+|TS\d{4})\b|✖|✘|^\s*at\s.+\(.+\)/i.test(text)) return 'error';
|
|
24
|
+
if (/\b(warn(ing)?s?|avertissements?|deprecated|deprecation)\b|⚠/i.test(text)) return 'warn';
|
|
25
|
+
if (/\b(success(ful(ly)?)?|succeeded|ready|done|listening at)\b|✔|✓/i.test(text)) return 'success';
|
|
26
26
|
if (/\b(debug|trace|verbose)\b/i.test(text)) return 'debug';
|
|
27
|
-
|
|
27
|
+
if (/^\s*<i>|\binfo\b/i.test(text)) return 'info';
|
|
28
|
+
return undefined;
|
|
28
29
|
}
|
|
30
|
+
/** Ligne de suite d'un bloc (indentée ou encadrée) : hérite du niveau de la ligne qui l'ouvre. */ const CONTINUATION = /^\s+\S|^\s*[│╭╰├└┌┐┘╵╷×›>|]/;
|
|
29
31
|
export class LogHub {
|
|
30
|
-
push(source, line,
|
|
31
|
-
|
|
32
|
+
push(source, line, _stream = 'out') {
|
|
33
|
+
// Comme le terminal : un retour chariot réécrit la ligne (barres de progression) — seul le dernier état compte.
|
|
34
|
+
const message = line.replace(/\r+$/, '').split('\r').pop() ?? '';
|
|
32
35
|
if (stripAnsi(message).trim().length === 0) return;
|
|
33
|
-
const
|
|
36
|
+
const explicit = detectLevel(message);
|
|
37
|
+
const previous = this.lastLevel.get(source);
|
|
38
|
+
const inherited = !explicit && CONTINUATION.test(stripAnsi(message)) && (previous === 'error' || previous === 'warn') ? previous : undefined;
|
|
39
|
+
const level = explicit ?? inherited ?? 'info';
|
|
40
|
+
this.lastLevel.set(source, level);
|
|
34
41
|
const entry = {
|
|
35
42
|
id: this.nextId++,
|
|
36
43
|
ts: Date.now(),
|
|
@@ -134,7 +141,9 @@ export class LogHub {
|
|
|
134
141
|
}
|
|
135
142
|
constructor(){
|
|
136
143
|
_define_property(this, "entries", []);
|
|
137
|
-
|
|
144
|
+
// Base horaire : les ids restent croissants d'un redémarrage à l'autre (reprise SSE par Last-Event-ID sans trou ni doublon).
|
|
145
|
+
_define_property(this, "nextId", Date.now() * 1000);
|
|
146
|
+
_define_property(this, "lastLevel", new Map());
|
|
138
147
|
_define_property(this, "clients", new Set());
|
|
139
148
|
_define_property(this, "partial", new Map());
|
|
140
149
|
_define_property(this, "server", void 0);
|
|
@@ -144,6 +153,13 @@ export class LogHub {
|
|
|
144
153
|
});
|
|
145
154
|
}
|
|
146
155
|
}
|
|
156
|
+
/** Env des processus fils capturés : sortie piped = non-TTY, donc on force les couleurs si le terminal en a. */ export function childColorEnv() {
|
|
157
|
+
const color = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
158
|
+
return color ? {
|
|
159
|
+
...process.env,
|
|
160
|
+
FORCE_COLOR: process.env.FORCE_COLOR ?? '1'
|
|
161
|
+
} : process.env;
|
|
162
|
+
}
|
|
147
163
|
let hub;
|
|
148
164
|
export function getLogHub() {
|
|
149
165
|
return hub;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egen-civitas/egen",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
],
|
|
61
61
|
"homepage": "https://github.com/amourgit/Frontend-esm-framework/tree/main/packages/tooling/egen#readme",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@egen-civitas/esm-app-shell": "^2.6.
|
|
63
|
+
"@egen-civitas/esm-app-shell": "^2.6.2",
|
|
64
64
|
"@egen-civitas/rspack-config": "^1.1.0",
|
|
65
65
|
"@egen-civitas/webpack-config": "^1.0.0",
|
|
66
66
|
"@inquirer/prompts": "8.3.2",
|