@egen-civitas/egen 2.1.1 → 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 CHANGED
@@ -1,5 +1,16 @@
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
+
3
14
  ## 2.1.1
4
15
 
5
16
  ### Patch 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;AAsDzC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,YA6W/B"}
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, childColorEnv, 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,10 +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
38
  silent: !!hub,
28
- env: hub ? childColorEnv() : process.env
39
+ env
29
40
  });
30
41
  hub?.attachChild(ps, 'egen-develop');
31
42
  ps.send({
@@ -1 +1 @@
1
- {"version":3,"file":"develop.d.ts","sourceRoot":"","sources":["../../src/commands/develop.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,iBAAiB,EAAyC,MAAM,UAAU,CAAC;AAyCpH,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,iBA+NvE"}
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"}
@@ -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
+ }
@@ -1,3 +1,4 @@
1
+ export * from './brand';
1
2
  export * from './config';
2
3
  export * from './helpers';
3
4
  export * from './importmap';
@@ -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"}
@@ -1,3 +1,4 @@
1
+ export * from "./brand.js";
1
2
  export * from "./config.js";
2
3
  export * from "./helpers.js";
3
4
  export * from "./importmap.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egen-civitas/egen",
3
- "version": "2.1.1",
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.6.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",