@egen-civitas/egen 2.1.0 → 2.2.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/CHANGELOG.md +18 -0
- package/README.md +11 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -2
- package/dist/commands/develop.d.ts.map +1 -1
- package/dist/commands/develop.js +10 -1
- package/dist/utils/brand.d.ts +18 -0
- package/dist/utils/brand.d.ts.map +1 -0
- package/dist/utils/brand.js +31 -0
- package/dist/utils/devserver.js +3 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- 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,23 @@
|
|
|
1
1
|
# @egen-civitas/egen
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 33f2197: Support de `EGEN_BRAND_DIR` (variable d'environnement ou `.env*` du monorepo consommateur) : `egen develop` sert ce dossier avant le `dist` pré-compilé de l'app-shell, et `egen build` le transmet au shell avec un chemin absolu (le build s'exécute depuis `node_modules`, où un chemin relatif ne désignerait plus rien). Le projet client peut ainsi fournir son favicon et son icône PWA sans qu'aucune identité visuelle ne soit embarquée dans le framework. Un chemin invalide est ignoré avec un avertissement.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [33f2197]
|
|
12
|
+
- @egen-civitas/esm-app-shell@2.7.0
|
|
13
|
+
|
|
14
|
+
## 2.1.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 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).
|
|
19
|
+
- @egen-civitas/esm-app-shell@2.6.2
|
|
20
|
+
|
|
3
21
|
## 2.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -69,3 +69,14 @@ Example:
|
|
|
69
69
|
# run the command
|
|
70
70
|
npx @egen-civitas/egen assemble
|
|
71
71
|
```
|
|
72
|
+
|
|
73
|
+
## Client branding (favicon, PWA icon)
|
|
74
|
+
|
|
75
|
+
`egen` and the app shell are generic and ship no brand identity, only neutral placeholders. A client project supplies its own favicon and installable-app icon by pointing `EGEN_BRAND_DIR` to a folder containing `favicon.ico` and/or `icon-512.png`:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
# .env.development (or .env.production, or the process environment)
|
|
79
|
+
EGEN_BRAND_DIR=branding/shell
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A relative path is resolved from the root of the consuming monorepo. `develop` serves that folder ahead of the app shell's own assets, and `build` copies it over them. Missing files fall back to the neutral ones, and an invalid path is ignored with a warning.
|
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;AAiEzC,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 { BRAND_DIR_ENV, getAvailablePort, getImportmapAndRoutes, isPortAvailable, startLogHub, childColorEnv, getLogHub, logFail, mergeImportmapAndRoutes, proxyImportmapAndRoutes, resolveBrandDir, 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
|
|
@@ -22,9 +22,21 @@ const runner = resolve(import.meta.dirname, `runner.js`);
|
|
|
22
22
|
const root = resolve(import.meta.dirname, '..');
|
|
23
23
|
function runCommand(type, args) {
|
|
24
24
|
const hub = type === 'runDevelop' ? getLogHub() : undefined;
|
|
25
|
+
// Le dossier de branding est résolu ICI, dans le processus parent : `runBuild` s'exécute depuis `root`
|
|
26
|
+
// (dans node_modules), où un chemin relatif ne désignerait plus rien.
|
|
27
|
+
const env = {
|
|
28
|
+
...hub ? childColorEnv() : process.env
|
|
29
|
+
};
|
|
30
|
+
const brandDir = resolveBrandDir(process.cwd(), type === 'runBuild' ? 'production' : 'development');
|
|
31
|
+
if (brandDir) {
|
|
32
|
+
env[BRAND_DIR_ENV] = brandDir;
|
|
33
|
+
} else {
|
|
34
|
+
delete env[BRAND_DIR_ENV];
|
|
35
|
+
}
|
|
25
36
|
const ps = fork(runner, [], {
|
|
26
37
|
cwd: type === 'runBuild' ? root : process.cwd(),
|
|
27
|
-
silent: !!hub
|
|
38
|
+
silent: !!hub,
|
|
39
|
+
env
|
|
28
40
|
});
|
|
29
41
|
hub?.attachChild(ps, 'egen-develop');
|
|
30
42
|
ps.send({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"develop.d.ts","sourceRoot":"","sources":["../../src/commands/develop.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"develop.d.ts","sourceRoot":"","sources":["../../src/commands/develop.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EAKvB,MAAM,UAAU,CAAC;AAyClB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,oBAAoB,CAAC;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,iBAsOvE"}
|
package/dist/commands/develop.js
CHANGED
|
@@ -5,7 +5,7 @@ import { basename, resolve } from "node:path";
|
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
|
7
7
|
import { resolvePublicEnv } from "@egen-civitas/rspack-config";
|
|
8
|
-
import { logInfo, logWarn, removeTrailingSlash } from "../utils/index.js";
|
|
8
|
+
import { logInfo, logWarn, removeTrailingSlash, resolveBrandDir } from "../utils/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* Variables qui doivent atteindre @egen-civitas/esm-app-shell au RUNTIME
|
|
11
11
|
* plutôt qu'au build. Nécessaire uniquement parce que ce paquet est
|
|
@@ -212,6 +212,15 @@ export async function runDevelop(args, signal) {
|
|
|
212
212
|
// Route for custom `index.html` goes above static assets
|
|
213
213
|
app.get(indexHtmlPathMatcher, (_, res)=>res.contentType('text/html').send(indexContent));
|
|
214
214
|
// Return static assets for any request for which we have one, except importmap.json and index.html
|
|
215
|
+
// Branding du projet client (favicon…) : servi AVANT le dist pré-compilé du shell, dont il remplace les
|
|
216
|
+
// assets neutres du même nom. Un fichier absent du dossier retombe naturellement sur ceux du shell.
|
|
217
|
+
const brandDir = resolveBrandDir(process.cwd(), 'development');
|
|
218
|
+
if (brandDir) {
|
|
219
|
+
logInfo(`Branding : assets de ${brandDir} servis à la place de ceux, neutres, de l'app-shell.`);
|
|
220
|
+
app.use(spaPath, express.static(brandDir, {
|
|
221
|
+
index: false
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
215
224
|
app.use(spaPath, express.static(source, {
|
|
216
225
|
index: false
|
|
217
226
|
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Variable d'environnement désignant le dossier de branding (favicon, icône PWA) du projet client. */
|
|
2
|
+
export declare const BRAND_DIR_ENV = "EGEN_BRAND_DIR";
|
|
3
|
+
/**
|
|
4
|
+
* Résout le dossier de branding fourni par le projet client, qui remplace les assets neutres de l'app-shell
|
|
5
|
+
* (favicon, icône PWA). Le framework reste ainsi générique : aucune identité visuelle n'y est embarquée.
|
|
6
|
+
*
|
|
7
|
+
* - Source : `EGEN_BRAND_DIR` dans l'environnement, sinon dans les `.env*` du monorepo consommateur.
|
|
8
|
+
* - Un chemin relatif est résolu depuis la racine du monorepo consommateur (ou `cwd` hors monorepo), jamais
|
|
9
|
+
* depuis le dossier de travail d'un sous-processus : `egen build` s'exécute depuis `node_modules`.
|
|
10
|
+
* - Valeur absente → `undefined` (aucun avertissement). Valeur invalide → avertissement et `undefined`, sans
|
|
11
|
+
* jamais faire échouer la commande.
|
|
12
|
+
*
|
|
13
|
+
* @param cwd Dossier de départ pour trouver la racine du monorepo consommateur.
|
|
14
|
+
* @param mode Mode `.env` à lire (`development`, `production`…).
|
|
15
|
+
* @returns Le chemin absolu du dossier, ou `undefined`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveBrandDir(cwd: string, mode?: string): string | undefined;
|
|
18
|
+
//# sourceMappingURL=brand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/utils/brand.ts"],"names":[],"mappings":"AAKA,uGAAuG;AACvG,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,SAAgB,GAAG,MAAM,GAAG,SAAS,CAcrF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { findMonorepoRoot, loadMonorepoEnv } from "@egen-civitas/rspack-config";
|
|
4
|
+
import { logWarn } from "./logger.js";
|
|
5
|
+
/** Variable d'environnement désignant le dossier de branding (favicon, icône PWA) du projet client. */ export const BRAND_DIR_ENV = 'EGEN_BRAND_DIR';
|
|
6
|
+
/**
|
|
7
|
+
* Résout le dossier de branding fourni par le projet client, qui remplace les assets neutres de l'app-shell
|
|
8
|
+
* (favicon, icône PWA). Le framework reste ainsi générique : aucune identité visuelle n'y est embarquée.
|
|
9
|
+
*
|
|
10
|
+
* - Source : `EGEN_BRAND_DIR` dans l'environnement, sinon dans les `.env*` du monorepo consommateur.
|
|
11
|
+
* - Un chemin relatif est résolu depuis la racine du monorepo consommateur (ou `cwd` hors monorepo), jamais
|
|
12
|
+
* depuis le dossier de travail d'un sous-processus : `egen build` s'exécute depuis `node_modules`.
|
|
13
|
+
* - Valeur absente → `undefined` (aucun avertissement). Valeur invalide → avertissement et `undefined`, sans
|
|
14
|
+
* jamais faire échouer la commande.
|
|
15
|
+
*
|
|
16
|
+
* @param cwd Dossier de départ pour trouver la racine du monorepo consommateur.
|
|
17
|
+
* @param mode Mode `.env` à lire (`development`, `production`…).
|
|
18
|
+
* @returns Le chemin absolu du dossier, ou `undefined`.
|
|
19
|
+
*/ export function resolveBrandDir(cwd, mode = 'development') {
|
|
20
|
+
const monorepoRoot = findMonorepoRoot(cwd);
|
|
21
|
+
const requested = process.env[BRAND_DIR_ENV] || loadMonorepoEnv(cwd, mode)[BRAND_DIR_ENV];
|
|
22
|
+
if (!requested) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const brandDir = resolve(monorepoRoot ?? cwd, requested);
|
|
26
|
+
if (!existsSync(brandDir) || !statSync(brandDir).isDirectory()) {
|
|
27
|
+
logWarn(`${BRAND_DIR_ENV}="${requested}" ne désigne pas un dossier existant (${brandDir}) : ignoré.`);
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return brandDir;
|
|
31
|
+
}
|
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/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
package/dist/utils/index.js
CHANGED
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,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;IAChB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,
|
|
1
|
+
{"version":3,"file":"log-hub.d.ts","sourceRoot":"","sources":["../../src/utils/log-hub.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;IAChB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,6GAA6G;AAC7G,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAQ9D;AAKD,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAkB;IAEjC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAAC,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.
|
|
3
|
+
"version": "2.2.0",
|
|
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.
|
|
63
|
+
"@egen-civitas/esm-app-shell": "^2.7.0",
|
|
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",
|