@egen-civitas/egen 1.0.1 → 2.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/default-rspack-config.d.cts +15 -0
- package/default-webpack-config.d.cts +15 -0
- package/dist/cli.js +2 -2
- package/dist/commands/develop.d.ts.map +1 -1
- package/dist/commands/develop.js +102 -0
- package/package.json +11 -7
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Types pour default-rspack-config.cjs.
|
|
2
|
+
//
|
|
3
|
+
// Ce fichier .cjs fait `Object.assign(extendConfig, rest)` a l'execution :
|
|
4
|
+
// il fusionne la fonction par defaut de @egen-civitas/rspack-config avec
|
|
5
|
+
// tous ses autres exports nommes en proprietes statiques attachees a cette
|
|
6
|
+
// fonction. Cette declaration reflete exactement cette forme pour que la
|
|
7
|
+
// resolution de types (node10, node16 CJS/ESM, bundler) reussisse.
|
|
8
|
+
|
|
9
|
+
import type RspackConfigModule from '@egen-civitas/rspack-config';
|
|
10
|
+
|
|
11
|
+
type NamedExports = Omit<typeof import('@egen-civitas/rspack-config'), 'default'>;
|
|
12
|
+
type Merged = typeof RspackConfigModule & NamedExports;
|
|
13
|
+
|
|
14
|
+
declare const merged: Merged;
|
|
15
|
+
export = merged;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Types pour default-webpack-config.cjs.
|
|
2
|
+
//
|
|
3
|
+
// Ce fichier .cjs fait `Object.assign(extendConfig, rest)` a l'execution :
|
|
4
|
+
// il fusionne la fonction par defaut de @egen-civitas/webpack-config avec
|
|
5
|
+
// tous ses autres exports nommes en proprietes statiques attachees a cette
|
|
6
|
+
// fonction. Cette declaration reflete exactement cette forme pour que la
|
|
7
|
+
// resolution de types (node10, node16 CJS/ESM, bundler) reussisse.
|
|
8
|
+
|
|
9
|
+
import type WebpackConfigModule from '@egen-civitas/webpack-config';
|
|
10
|
+
|
|
11
|
+
type NamedExports = Omit<typeof import('@egen-civitas/webpack-config'), 'default'>;
|
|
12
|
+
type Merged = typeof WebpackConfigModule & NamedExports;
|
|
13
|
+
|
|
14
|
+
declare const merged: Merged;
|
|
15
|
+
export = merged;
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ export function buildCli(y) {
|
|
|
24
24
|
describe: 'The host name or IP for the server to use.',
|
|
25
25
|
type: 'string'
|
|
26
26
|
}).option('backend', {
|
|
27
|
-
default: 'http://localhost:
|
|
27
|
+
default: 'http://localhost:8082',
|
|
28
28
|
describe: 'The backend to proxy API requests to.',
|
|
29
29
|
type: 'string',
|
|
30
30
|
coerce: (arg)=>arg.endsWith('/') ? arg.slice(0, -1) : arg
|
|
@@ -256,7 +256,7 @@ export function buildCli(y) {
|
|
|
256
256
|
y.command([
|
|
257
257
|
'start',
|
|
258
258
|
'$0'
|
|
259
|
-
], 'Starts the app shell using the provided configuration. This uses express for serving static files with some proxy middleware.', (argv)=>argv.number('port').default('port', 8081).describe('port', 'The port where the dev server should run.').string('host').default('host', 'localhost').describe('host', 'The host name or IP for the server to use.').string('backend').default('backend', 'http://localhost:
|
|
259
|
+
], 'Starts the app shell using the provided configuration. This uses express for serving static files with some proxy middleware.', (argv)=>argv.number('port').default('port', 8081).describe('port', 'The port where the dev server should run.').string('host').default('host', 'localhost').describe('host', 'The host name or IP for the server to use.').string('backend').default('backend', 'http://localhost:8082/').describe('backend', 'The backend to proxy API requests to.').string('add-cookie').default('add-cookie', '').describe('add-cookie', 'Additional cookies to provide when proxying.').boolean('open').default('open', false).describe('open', 'Immediately opens the SPA page URL in the browser.'), (args)=>runCommand('runStart', {
|
|
260
260
|
...args
|
|
261
261
|
}));
|
|
262
262
|
return y.epilog('The SPA assemble config JSON is a JSON file, typically `spa-assemble-config.json`, which defines parameters for the `build` and `assemble` ' + 'commands. The keys used by `build` are:\n' + ' `apiUrl`, `spaPath`, `configPaths`, `configUrls`, `importmap`, `pageTitle`, and `supportOffline`;\n' + 'each of which is equivalent to the corresponding command line argument (see `egen build --help`). ' + 'Multiple values provided to `configPaths` and `configUrls` should be comma-separated.\n' + 'The keys used by `assemble` are:\n' + ' frontendModules \tAn object which specifies which frontend modules to include. It should have package names ' + 'for keys and versions for values.\n' + ' publicUrl \tThe URL at which the frontend modules will be made available. Can be relative to the importmap. ' + 'Defaults to `.` (which means they will be colocated with the import map).\n\n' + 'For more information visit https://github.com/egen-civitas/egen-esm-core.').help().demandCommand().strict();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"develop.d.ts","sourceRoot":"","sources":["../../src/commands/develop.ts"],"names":[],"mappings":"
|
|
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;CACzB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,iBA8MvE"}
|
package/dist/commands/develop.js
CHANGED
|
@@ -4,7 +4,77 @@ import { createProxyMiddleware } from "http-proxy-middleware";
|
|
|
4
4
|
import { basename, resolve } from "node:path";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { resolvePublicEnv } from "@egen-civitas/rspack-config";
|
|
7
8
|
import { logInfo, logWarn, removeTrailingSlash } from "../utils/index.js";
|
|
9
|
+
/**
|
|
10
|
+
* Variables qui doivent atteindre @egen-civitas/esm-app-shell au RUNTIME
|
|
11
|
+
* plutôt qu'au build. Nécessaire uniquement parce que ce paquet est
|
|
12
|
+
* PRÉ-COMPILÉ (voir le commentaire détaillé plus bas, à l'endroit où cette
|
|
13
|
+
* liste est consommée) : `egen develop` ne le reconstruit jamais, donc rien
|
|
14
|
+
* de fixé par rspack DefinePlugin au moment du build du framework ne peut
|
|
15
|
+
* plus être changé par le .env du consommateur — seule une valeur posée sur
|
|
16
|
+
* `window` APRÈS coup, au moment où la page est servie, le peut encore.
|
|
17
|
+
*
|
|
18
|
+
* `windowKey` suit la même convention que window.egenTenantMode /
|
|
19
|
+
* window.egenAi* (voir esm-globals/src/types.ts) — la table EGEN_TENANT_*
|
|
20
|
+
* ci-dessous est recopiée à l'identique depuis EGEN_TENANT_ENV_TO_WINDOW_KEY
|
|
21
|
+
* dans esm-app-shell/rspack.config.js (même mapping, deux moments différents
|
|
22
|
+
* : build du framework là-bas, service par `egen develop` ici).
|
|
23
|
+
*
|
|
24
|
+
* `envKey` doit rester dans une convention reconnue par PUBLIC_ENV_PREFIXES
|
|
25
|
+
* (@egen-civitas/rspack-config) pour que build-time et runtime restent
|
|
26
|
+
* cohérents sur ce qui est considéré "public".
|
|
27
|
+
*
|
|
28
|
+
* `type: 'boolean'` convertit la chaîne lue en vrai booléen JS (nécessaire
|
|
29
|
+
* quand le code consommateur fait un `=== true` strict, ex.
|
|
30
|
+
* isDevAuthBypassEnabled()) ; `type: 'string'` transmet la valeur telle
|
|
31
|
+
* quelle (convention déjà utilisée par esm-tenant, où le parsing — booléen
|
|
32
|
+
* ou autre — se fait côté esm-tenant/src/config/env.ts, pas à l'injection).
|
|
33
|
+
*
|
|
34
|
+
* Pour ajouter une nouvelle variable qui a besoin de ce pont : une ligne
|
|
35
|
+
* ici suffit, jamais besoin de toucher au reste du pipeline.
|
|
36
|
+
*/ const RUNTIME_BRIDGED_VARS = [
|
|
37
|
+
{
|
|
38
|
+
envKey: 'EGEN_DEV_NO_AUTH',
|
|
39
|
+
windowKey: 'egenDevNoAuth',
|
|
40
|
+
type: 'boolean'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
envKey: 'EGEN_TENANT_MODE',
|
|
44
|
+
windowKey: 'egenTenantMode',
|
|
45
|
+
type: 'string'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
envKey: 'EGEN_TENANT_ID',
|
|
49
|
+
windowKey: 'egenTenantId',
|
|
50
|
+
type: 'string'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
envKey: 'EGEN_TENANT_PERSIST',
|
|
54
|
+
windowKey: 'egenTenantPersist',
|
|
55
|
+
type: 'string'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
envKey: 'EGEN_TENANT_RESOLUTION_ORDER',
|
|
59
|
+
windowKey: 'egenTenantResolutionOrder',
|
|
60
|
+
type: 'string'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
envKey: 'EGEN_TENANT_PATH_PREFIX',
|
|
64
|
+
windowKey: 'egenTenantPathPrefix',
|
|
65
|
+
type: 'string'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
envKey: 'EGEN_TENANT_JWT_CLAIM',
|
|
69
|
+
windowKey: 'egenTenantJwtClaim',
|
|
70
|
+
type: 'string'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
envKey: 'EGEN_TENANT_ROOT_DOMAIN',
|
|
74
|
+
windowKey: 'egenTenantRootDomain',
|
|
75
|
+
type: 'string'
|
|
76
|
+
}
|
|
77
|
+
];
|
|
8
78
|
export async function runDevelop(args, signal) {
|
|
9
79
|
const { backend, host, port, open, importmap, routes, watchedRoutesPaths, configUrls, configFiles, addCookie, supportOffline } = args;
|
|
10
80
|
const apiUrl = removeTrailingSlash(args.apiUrl);
|
|
@@ -15,7 +85,39 @@ export async function runDevelop(args, signal) {
|
|
|
15
85
|
const require = createRequire(import.meta.url);
|
|
16
86
|
const source = resolve(require.resolve('@egen-civitas/esm-app-shell/package.json'), '..', 'dist');
|
|
17
87
|
const index = resolve(source, 'index.html');
|
|
88
|
+
// @egen-civitas/esm-app-shell est un paquet npm PRÉ-COMPILÉ : son bundle a
|
|
89
|
+
// déjà été construit (et process.env.EGEN_DEV_NO_AUTH/EGEN_AI_*/etc. figés
|
|
90
|
+
// par rspack DefinePlugin) au moment du build du repo framework, bien
|
|
91
|
+
// avant que `egen develop` ne tourne ici avec le .env de l'app
|
|
92
|
+
// consommatrice. Un DefinePlugin ne peut plus aider — il faudrait rebuild
|
|
93
|
+
// le shell à chaque session de dev de l'app consommatrice, ce qui n'arrive
|
|
94
|
+
// jamais : `egen develop` se contente de le SERVIR tel quel
|
|
95
|
+
// (express.static ci-dessous), jamais de le recompiler. Seule une valeur
|
|
96
|
+
// posée sur `window` APRÈS le build, au moment où la page est réellement
|
|
97
|
+
// servie, peut donc encore traverser cette frontière — voir
|
|
98
|
+
// RUNTIME_BRIDGED_VARS en tête de fichier pour la liste des variables
|
|
99
|
+
// concernées et isDevAuthBypassEnabled() dans
|
|
100
|
+
// @egen-civitas/esm-api/src/dev-auth-bypass.ts pour un exemple de lecture
|
|
101
|
+
// côté framework. resolvePublicEnv() applique la hiérarchie complète :
|
|
102
|
+
// .env.defaults du framework < .env* du consommateur < process.env — donc
|
|
103
|
+
// le consommateur peut surcharger n'importe laquelle de ces variables, en
|
|
104
|
+
// totalité, simplement en la déclarant dans son propre .env.
|
|
105
|
+
const publicEnv = resolvePublicEnv(process.cwd(), 'development');
|
|
106
|
+
const runtimeWindowOverrides = {};
|
|
107
|
+
for (const { envKey, windowKey, type } of RUNTIME_BRIDGED_VARS){
|
|
108
|
+
const raw = publicEnv[envKey];
|
|
109
|
+
if (raw !== undefined) {
|
|
110
|
+
runtimeWindowOverrides[windowKey] = type === 'boolean' ? raw === 'true' : raw;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (runtimeWindowOverrides.egenDevNoAuth) {
|
|
114
|
+
logInfo('EGEN_DEV_NO_AUTH=true — bypass d\'authentification actif (session admin fictive, sans backend).');
|
|
115
|
+
}
|
|
116
|
+
if (runtimeWindowOverrides.egenTenantMode && runtimeWindowOverrides.egenTenantMode !== 'off') {
|
|
117
|
+
logInfo(`EGEN_TENANT_MODE=${runtimeWindowOverrides.egenTenantMode} — système multi-tenant actif.`);
|
|
118
|
+
}
|
|
18
119
|
const indexContent = readFileSync(index, 'utf8').replace(/<script>initializeSpa\([\s\S\n]*<\/script>/m, `<script>
|
|
120
|
+
Object.assign(window, ${JSON.stringify(runtimeWindowOverrides)});
|
|
19
121
|
initializeSpa({
|
|
20
122
|
apiUrl: ${JSON.stringify(apiUrl)},
|
|
21
123
|
spaPath: ${JSON.stringify(spaPath)},
|
package/package.json
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egen-civitas/egen",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"bin",
|
|
9
9
|
"default-rspack-config.cjs",
|
|
10
|
-
"default-
|
|
10
|
+
"default-rspack-config.d.cts",
|
|
11
|
+
"default-webpack-config.cjs",
|
|
12
|
+
"default-webpack-config.d.cts"
|
|
11
13
|
],
|
|
12
14
|
"bin": {
|
|
13
|
-
"egen": "
|
|
14
|
-
"rspack": "
|
|
15
|
-
"webpack": "
|
|
15
|
+
"egen": "dist/cli.js",
|
|
16
|
+
"rspack": "bin/rspack.cjs",
|
|
17
|
+
"webpack": "bin/webpack.cjs"
|
|
16
18
|
},
|
|
17
19
|
"type": "module",
|
|
18
20
|
"types": "dist/index.d.ts",
|
|
19
21
|
"exports": {
|
|
20
22
|
"./default-rspack-config": {
|
|
23
|
+
"types": "./default-rspack-config.d.cts",
|
|
21
24
|
"require": "./default-rspack-config.cjs",
|
|
22
25
|
"default": "./default-rspack-config.cjs"
|
|
23
26
|
},
|
|
24
27
|
"./default-webpack-config": {
|
|
28
|
+
"types": "./default-webpack-config.d.cts",
|
|
25
29
|
"require": "./default-webpack-config.cjs",
|
|
26
30
|
"default": "./default-webpack-config.cjs"
|
|
27
31
|
},
|
|
@@ -56,8 +60,8 @@
|
|
|
56
60
|
],
|
|
57
61
|
"homepage": "https://github.com/amourgit/Frontend-esm-framework/tree/main/packages/tooling/egen#readme",
|
|
58
62
|
"dependencies": {
|
|
59
|
-
"@egen-civitas/esm-app-shell": "^
|
|
60
|
-
"@egen-civitas/rspack-config": "^1.0.
|
|
63
|
+
"@egen-civitas/esm-app-shell": "^2.0.0",
|
|
64
|
+
"@egen-civitas/rspack-config": "^1.0.1",
|
|
61
65
|
"@egen-civitas/webpack-config": "^1.0.0",
|
|
62
66
|
"@inquirer/prompts": "8.3.2",
|
|
63
67
|
"@pnpm/npm-conf": "^3.0.2",
|