@obsidiane/meridiane 2.0.10 → 2.0.12
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/README.md +19 -2
- package/cli.js +21 -37
- package/package.json +13 -6
- package/src/README.md +9 -0
- package/{tools/app → src/application}/bridge-workflow.js +29 -23
- package/src/application/generate-bridge.js +50 -0
- package/{tools/app → src/application}/run-build.js +1 -1
- package/{tools/app → src/application}/run-dev.js +30 -36
- package/{tools/app → src/application}/run-generate.js +3 -3
- package/{tools → src}/domain/bridge-options.js +8 -21
- package/src/domain/list-values.js +6 -0
- package/src/generators/bridge/write-bridge-files.js +100 -0
- package/src/generators/models/interface-schema.js +116 -0
- package/src/generators/models/model-selection.js +148 -0
- package/src/generators/models/oas-contract.js +170 -0
- package/{tools/generator → src/generators}/models/oas-schema-name.js +6 -15
- package/src/generators/models/openapi-to-models.js +136 -0
- package/{tools/generator → src/generators}/models/schema-utils.js +27 -3
- package/src/generators/models/templates/type-alias.hbs +2 -0
- package/src/generators/models/type-expression.js +65 -0
- package/src/generators/models/type-resolver.js +240 -0
- package/src/generators/models/utils.js +89 -0
- package/src/generators/models/write-model-files.js +55 -0
- package/src/infrastructure/dev-project.js +48 -0
- package/{tools/infra → src/infrastructure}/exec.js +3 -2
- package/src/infrastructure/local-package-install.js +104 -0
- package/src/infrastructure/spec-loader.js +65 -0
- package/templates/{_lib_template → angular-bridge}/README.md +9 -0
- package/templates/angular-bridge/src/lib/bridge/rest/api-platform.adapter.ts +82 -0
- package/templates/angular-bridge/src/lib/bridge/rest/http-request.options.ts +30 -0
- package/templates/{_lib_template → angular-bridge}/src/lib/bridge/rest/query-builder.ts +10 -10
- package/templates/angular-bridge/src/lib/bridge/sse/mercure-connections.ts +255 -0
- package/templates/angular-bridge/src/lib/bridge/sse/mercure-payload.ts +82 -0
- package/templates/angular-bridge/src/lib/bridge/sse/mercure-url.builder.ts +39 -0
- package/templates/angular-bridge/src/lib/bridge/sse/mercure.adapter.ts +358 -0
- package/templates/{_lib_template → angular-bridge}/src/lib/bridge/sse/ref-count-topic.registry.ts +3 -12
- package/templates/angular-bridge/src/lib/bridge/sse/subscription-claims.ts +76 -0
- package/templates/angular-bridge/src/lib/bridge-options.ts +59 -0
- package/templates/{_lib_template → angular-bridge}/src/lib/facades/bridge.facade.ts +50 -51
- package/templates/{_lib_template → angular-bridge}/src/lib/facades/facade.factory.ts +0 -1
- package/templates/angular-bridge/src/lib/facades/facade.interface.ts +13 -0
- package/templates/{_lib_template → angular-bridge}/src/lib/facades/resource.facade.ts +24 -31
- package/templates/angular-bridge/src/lib/interceptors/bearer-auth.interceptor.ts +33 -0
- package/templates/angular-bridge/src/lib/interceptors/bridge-defaults.interceptor.ts +65 -0
- package/templates/angular-bridge/src/lib/interceptors/content-type.interceptor.ts +37 -0
- package/templates/angular-bridge/src/lib/interceptors/scoped.interceptor.ts +9 -0
- package/templates/angular-bridge/src/lib/interceptors/singleflight.interceptor.ts +46 -0
- package/templates/{_lib_template → angular-bridge}/src/lib/ports/realtime.port.ts +6 -2
- package/templates/{_lib_template → angular-bridge}/src/lib/ports/resource-repository.port.ts +7 -7
- package/templates/angular-bridge/src/lib/provide-bridge.ts +98 -0
- package/templates/angular-bridge/src/lib/utils/iri.ts +6 -0
- package/templates/angular-bridge/src/lib/utils/request-url.ts +31 -0
- package/templates/{_lib_template → angular-bridge}/src/public-api.ts +2 -0
- package/templates/{_lib_template → angular-bridge}/tsconfig.lib.json +13 -2
- package/templates/_lib_template/src/lib/bridge/rest/api-platform.adapter.ts +0 -84
- package/templates/_lib_template/src/lib/bridge/rest/http-request.options.ts +0 -21
- package/templates/_lib_template/src/lib/bridge/sse/mercure-url.builder.ts +0 -17
- package/templates/_lib_template/src/lib/bridge/sse/mercure.adapter.ts +0 -806
- package/templates/_lib_template/src/lib/facades/facade.interface.ts +0 -31
- package/templates/_lib_template/src/lib/interceptors/bridge-defaults.interceptor.ts +0 -53
- package/templates/_lib_template/src/lib/interceptors/content-type.interceptor.ts +0 -49
- package/templates/_lib_template/src/lib/interceptors/singleflight.interceptor.ts +0 -55
- package/templates/_lib_template/src/lib/provide-bridge.ts +0 -186
- package/tools/build.js +0 -1
- package/tools/dev.js +0 -1
- package/tools/domain/paths.js +0 -10
- package/tools/generate.js +0 -1
- package/tools/generator/models/oas-contract.js +0 -159
- package/tools/generator/models/openapi-to-models.js +0 -240
- package/tools/generator/models/type-resolver.js +0 -107
- package/tools/generator/models/utils.js +0 -62
- package/tools/infra/dev-support.js +0 -189
- package/tools/infra/generate/bridge.js +0 -212
- package/tools/infra/spec-loader.js +0 -59
- package/tools/infra/standalone-workspace.js +0 -162
- /package/{tools → src}/domain/lib-name.js +0 -0
- /package/{tools/generator → src/generators}/models/handlebars.js +0 -0
- /package/{tools/generator → src/generators}/models/templates/index.hbs +0 -0
- /package/{tools/generator → src/generators}/models/templates/model.hbs +0 -0
- /package/{tools/infra → src/infrastructure}/json.js +0 -0
- /package/{tools/infra → src/infrastructure}/logger.js +0 -0
- /package/templates/{_lib_template → angular-bridge}/ng-package.json +0 -0
- /package/templates/{_lib_template → angular-bridge}/package.json +0 -0
- /package/templates/{_lib_template → angular-bridge}/src/lib/bridge/sse/eventsource-wrapper.ts +0 -0
- /package/templates/{_lib_template → angular-bridge}/src/lib/bridge/sse/mercure-topic.mapper.ts +0 -0
- /package/templates/{_lib_template → angular-bridge}/src/lib/bridge.types.ts +0 -0
- /package/templates/{_lib_template → angular-bridge}/src/lib/interceptors/bridge-debug.interceptor.ts +0 -0
- /package/templates/{_lib_template → angular-bridge}/src/lib/tokens.ts +0 -0
- /package/templates/{_lib_template → angular-bridge}/src/lib/utils/url.ts +0 -0
- /package/templates/{_lib_template → angular-bridge}/src/models/index.ts +0 -0
- /package/templates/{_lib_template → angular-bridge}/tsconfig.lib.prod.json +0 -0
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import {existsSync} from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import {fileURLToPath} from 'node:url';
|
|
5
|
-
|
|
6
|
-
import {readJson, writeJsonIfChanged} from '../json.js';
|
|
7
|
-
import {renderTemplateToFile} from '../../generator/models/handlebars.js';
|
|
8
|
-
import {ensureCleanDir} from '../../generator/models/utils.js';
|
|
9
|
-
import {buildModelsFromOpenAPI} from '../../generator/models/openapi-to-models.js';
|
|
10
|
-
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
-
const __dirname = path.dirname(__filename);
|
|
13
|
-
|
|
14
|
-
const pkgRoot = path.resolve(__dirname, '../../..'); // packages/meridiane
|
|
15
|
-
|
|
16
|
-
async function readTextIfExists(filePath) {
|
|
17
|
-
try {
|
|
18
|
-
return await fs.readFile(filePath, 'utf8');
|
|
19
|
-
} catch {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function appendProjectReadme({targetReadmePath, projectReadmePath, debug, log}) {
|
|
25
|
-
if (!projectReadmePath) return;
|
|
26
|
-
|
|
27
|
-
const projectReadme = await readTextIfExists(projectReadmePath);
|
|
28
|
-
if (!projectReadme || projectReadme.trim().length === 0) return;
|
|
29
|
-
|
|
30
|
-
const targetReadme = await readTextIfExists(targetReadmePath);
|
|
31
|
-
if (!targetReadme || targetReadme.trim().length === 0) {
|
|
32
|
-
await fs.writeFile(targetReadmePath, projectReadme);
|
|
33
|
-
if (debug) log?.debug?.('[meridiane] project README copied', {source: projectReadmePath});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const combined =
|
|
38
|
-
`${targetReadme.trimEnd()}\n\n---\n\n` +
|
|
39
|
-
`## Documentation du projet\n\n` +
|
|
40
|
-
`${projectReadme.trimStart()}`;
|
|
41
|
-
await fs.writeFile(targetReadmePath, combined);
|
|
42
|
-
if (debug) log?.debug?.('[meridiane] project README appended', {source: projectReadmePath});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function replacePlaceholdersInDir(dir, placeholders) {
|
|
46
|
-
const entries = await fs.readdir(dir, {withFileTypes: true});
|
|
47
|
-
for (const entry of entries) {
|
|
48
|
-
const fullPath = path.join(dir, entry.name);
|
|
49
|
-
if (entry.isDirectory()) {
|
|
50
|
-
await replacePlaceholdersInDir(fullPath, placeholders);
|
|
51
|
-
} else if (entry.isFile()) {
|
|
52
|
-
let content = await fs.readFile(fullPath, 'utf8');
|
|
53
|
-
for (const [key, value] of Object.entries(placeholders)) {
|
|
54
|
-
content = content.replaceAll(key, value);
|
|
55
|
-
}
|
|
56
|
-
await fs.writeFile(fullPath, content);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function generateLibrary({projectDir, libName, packageName, version, debug, log, projectReadmePath}) {
|
|
62
|
-
const tplDir = path.resolve(pkgRoot, 'templates/_lib_template');
|
|
63
|
-
const targetDir = projectDir;
|
|
64
|
-
|
|
65
|
-
if (debug) {
|
|
66
|
-
log?.debug?.('[meridiane] generate lib', {
|
|
67
|
-
libName,
|
|
68
|
-
packageName,
|
|
69
|
-
version,
|
|
70
|
-
targetDir
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
await fs.rm(targetDir, {recursive: true, force: true});
|
|
75
|
-
await fs.mkdir(targetDir, {recursive: true});
|
|
76
|
-
await fs.cp(tplDir, targetDir, {recursive: true});
|
|
77
|
-
|
|
78
|
-
await replacePlaceholdersInDir(targetDir, {
|
|
79
|
-
'__LIB_NAME__': libName,
|
|
80
|
-
'__PACKAGE_NAME__': packageName,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const libPackageJsonPath = path.join(targetDir, 'package.json');
|
|
84
|
-
if (existsSync(libPackageJsonPath)) {
|
|
85
|
-
const libPkg = await readJson(libPackageJsonPath);
|
|
86
|
-
libPkg.name = packageName;
|
|
87
|
-
libPkg.version = version;
|
|
88
|
-
await writeJsonIfChanged(libPackageJsonPath, libPkg);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
await appendProjectReadme({
|
|
92
|
-
targetReadmePath: path.join(targetDir, 'README.md'),
|
|
93
|
-
projectReadmePath,
|
|
94
|
-
debug,
|
|
95
|
-
log,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// angular.json / workspace patching is intentionally not done here.
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async function generateModels({projectDir, spec, requiredMode, formats, include, exclude, debug, log}) {
|
|
102
|
-
const outDir = path.resolve(projectDir, 'src', 'models');
|
|
103
|
-
const templatesDir = path.resolve(pkgRoot, 'tools', 'generator', 'models', 'templates');
|
|
104
|
-
|
|
105
|
-
if (debug) {
|
|
106
|
-
log?.debug?.('[meridiane] generate models', {
|
|
107
|
-
outDir,
|
|
108
|
-
requiredMode,
|
|
109
|
-
formats: Array.isArray(formats) ? formats : [],
|
|
110
|
-
includeCount: include.length,
|
|
111
|
-
excludeCount: exclude.length,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
await ensureCleanDir(outDir);
|
|
116
|
-
|
|
117
|
-
// Write models + index.ts.
|
|
118
|
-
const {models} = buildModelsFromOpenAPI(spec, {
|
|
119
|
-
requiredMode,
|
|
120
|
-
formats: Array.isArray(formats) ? formats : [],
|
|
121
|
-
includeSchemaNames: include,
|
|
122
|
-
excludeSchemaNames: exclude,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
for (const m of models) {
|
|
126
|
-
await renderTemplateToFile({
|
|
127
|
-
templatePath: path.join(templatesDir, 'model.hbs'),
|
|
128
|
-
outPath: path.join(outDir, `${m.name}.ts`),
|
|
129
|
-
ctx: {
|
|
130
|
-
name: m.name,
|
|
131
|
-
props: m.props,
|
|
132
|
-
imports: m.imports,
|
|
133
|
-
extendsTypes: m.extendsTypes || [],
|
|
134
|
-
extendsItem: m.extendsItem === true,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
await renderTemplateToFile({
|
|
140
|
-
templatePath: path.join(templatesDir, 'index.hbs'),
|
|
141
|
-
outPath: path.join(outDir, 'index.ts'),
|
|
142
|
-
ctx: {models: models.map((m) => ({name: m.name}))},
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
if (debug) log?.debug?.(`[meridiane] ${models.length} model(s) generated`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @param {{
|
|
150
|
-
* cwd: string,
|
|
151
|
-
* libName: string,
|
|
152
|
-
* packageName: string,
|
|
153
|
-
* version: string,
|
|
154
|
-
* noModels: boolean,
|
|
155
|
-
* spec?: any,
|
|
156
|
-
* requiredMode: 'all'|'spec',
|
|
157
|
-
* formats?: string[],
|
|
158
|
-
* include: string[],
|
|
159
|
-
* exclude: string[],
|
|
160
|
-
* debug: boolean,
|
|
161
|
-
* log?: { step?: (msg: string) => void, info?: (msg: string) => void, success?: (msg: string) => void, debug?: (msg: string, data?: any) => void },
|
|
162
|
-
* workspaceMode?: 'angular'|'standalone',
|
|
163
|
-
* distRoot?: string,
|
|
164
|
-
* projectDir?: string,
|
|
165
|
-
* projectReadmePath?: string,
|
|
166
|
-
* }} params
|
|
167
|
-
*/
|
|
168
|
-
export async function generateBridgeWorkspace(params) {
|
|
169
|
-
const {
|
|
170
|
-
cwd,
|
|
171
|
-
libName,
|
|
172
|
-
packageName,
|
|
173
|
-
version,
|
|
174
|
-
noModels,
|
|
175
|
-
spec,
|
|
176
|
-
requiredMode,
|
|
177
|
-
formats,
|
|
178
|
-
include,
|
|
179
|
-
exclude,
|
|
180
|
-
debug,
|
|
181
|
-
log,
|
|
182
|
-
distRoot,
|
|
183
|
-
projectDir: projectDirInput,
|
|
184
|
-
projectReadmePath,
|
|
185
|
-
} = params;
|
|
186
|
-
|
|
187
|
-
const projectDir = projectDirInput ?? path.resolve(cwd, 'projects', libName);
|
|
188
|
-
log?.step?.(`génération de la librairie (${path.relative(cwd, projectDir)})`);
|
|
189
|
-
await generateLibrary({projectDir, libName, packageName, version, debug, log, projectReadmePath});
|
|
190
|
-
|
|
191
|
-
// If a dist root is provided, force ng-packagr output to that directory.
|
|
192
|
-
if (distRoot) {
|
|
193
|
-
const ngPackagePath = path.resolve(projectDir, 'ng-package.json');
|
|
194
|
-
const ngPkg = await readJson(ngPackagePath);
|
|
195
|
-
const desiredDestAbs = path.resolve(distRoot, libName);
|
|
196
|
-
const projectRoot = path.dirname(ngPackagePath);
|
|
197
|
-
ngPkg.dest = path.relative(projectRoot, desiredDestAbs).split(path.sep).join('/');
|
|
198
|
-
await writeJsonIfChanged(ngPackagePath, ngPkg);
|
|
199
|
-
log?.debug?.('ng-package.json dest overridden', {dest: ngPkg.dest});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (noModels) {
|
|
203
|
-
log?.info?.('models ignorés (--no-models)');
|
|
204
|
-
if (debug) log?.debug?.('[meridiane] --no-models enabled, skipping models generation');
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (!spec) throw new Error('Internal error: spec is required when noModels=false');
|
|
209
|
-
log?.step?.('génération des models (OpenAPI)');
|
|
210
|
-
await generateModels({projectDir, spec, requiredMode, formats, include, exclude, debug, log});
|
|
211
|
-
log?.success?.('génération terminée');
|
|
212
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
|
|
3
|
-
function isHttpUrl(v) {
|
|
4
|
-
return /^https?:\/\//i.test(String(v || ''));
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
async function fetchJson(url) {
|
|
8
|
-
let res;
|
|
9
|
-
try {
|
|
10
|
-
res = await fetch(url);
|
|
11
|
-
} catch (err) {
|
|
12
|
-
const msg = err?.message ?? String(err);
|
|
13
|
-
throw new Error(
|
|
14
|
-
`Spec fetch failed: ${url}\n` +
|
|
15
|
-
`Reason: ${msg}\n` +
|
|
16
|
-
`Tip: if your environment cannot access the network, use a local JSON file via --spec ./openapi.json`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
if (!res.ok) {
|
|
20
|
-
const body = await res.text().catch(() => '');
|
|
21
|
-
throw new Error(`Spec fetch failed: ${res.status} ${res.statusText}${body ? `\n${body}` : ''}`);
|
|
22
|
-
}
|
|
23
|
-
return await res.json();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function readOpenApiSpec(specArg) {
|
|
27
|
-
if (!specArg) throw new Error('Missing --spec (url or JSON file path)');
|
|
28
|
-
const spec = String(specArg);
|
|
29
|
-
|
|
30
|
-
if (isHttpUrl(spec)) {
|
|
31
|
-
try {
|
|
32
|
-
return await fetchJson(spec);
|
|
33
|
-
} catch (err) {
|
|
34
|
-
const isDocsJson = /\/api\/docs\.json$/i.test(spec);
|
|
35
|
-
if (!isDocsJson) throw err;
|
|
36
|
-
const fallback = spec.replace(/\/api\/docs\.json$/i, '/api/docs.jsonopenapi');
|
|
37
|
-
try {
|
|
38
|
-
return await fetchJson(fallback);
|
|
39
|
-
} catch (err2) {
|
|
40
|
-
const m1 = err?.message ?? String(err);
|
|
41
|
-
const m2 = err2?.message ?? String(err2);
|
|
42
|
-
throw new Error(`Spec fetch failed (both endpoints tried)\n- ${spec}\n ${m1}\n- ${fallback}\n ${m2}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
const raw = await fs.readFile(spec, 'utf8');
|
|
49
|
-
return JSON.parse(raw);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
if (err?.code === 'ENOENT') {
|
|
52
|
-
throw new Error(`Spec file not found: ${spec}`);
|
|
53
|
-
}
|
|
54
|
-
if (err?.name === 'SyntaxError') {
|
|
55
|
-
throw new Error(`Invalid JSON in spec file ${spec}: ${err.message}`);
|
|
56
|
-
}
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { createRequire } from 'node:module';
|
|
4
|
-
|
|
5
|
-
import { runCommand } from './exec.js';
|
|
6
|
-
import { writeJsonIfChanged } from './json.js';
|
|
7
|
-
|
|
8
|
-
async function ensureDir(p) {
|
|
9
|
-
await fs.mkdir(p, { recursive: true });
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async function exists(p) {
|
|
13
|
-
try {
|
|
14
|
-
await fs.stat(p);
|
|
15
|
-
return true;
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function toolchainPackageJson({ angularVersion, ngPackagrVersion, typescriptVersion, rxjsVersion, tslibVersion }) {
|
|
22
|
-
const v = angularVersion;
|
|
23
|
-
return {
|
|
24
|
-
name: 'meridiane-standalone-workspace',
|
|
25
|
-
private: true,
|
|
26
|
-
description: 'Temporary workspace created by @obsidiane/meridiane (standalone build).',
|
|
27
|
-
devDependencies: {
|
|
28
|
-
'@angular/common': v,
|
|
29
|
-
'@angular/compiler': v,
|
|
30
|
-
'@angular/compiler-cli': v,
|
|
31
|
-
'@angular/core': v,
|
|
32
|
-
'ng-packagr': ngPackagrVersion,
|
|
33
|
-
rxjs: rxjsVersion,
|
|
34
|
-
tslib: tslibVersion,
|
|
35
|
-
typescript: typescriptVersion,
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function rootTsconfigJson() {
|
|
41
|
-
return {
|
|
42
|
-
compilerOptions: {
|
|
43
|
-
target: 'ES2022',
|
|
44
|
-
module: 'ES2022',
|
|
45
|
-
// Angular >=21 relies on modern package exports resolution for some subpaths
|
|
46
|
-
// (e.g. @angular/common/http, @angular/core/rxjs-interop).
|
|
47
|
-
moduleResolution: 'bundler',
|
|
48
|
-
lib: ['ES2022', 'DOM'],
|
|
49
|
-
strict: true,
|
|
50
|
-
skipLibCheck: true,
|
|
51
|
-
experimentalDecorators: true,
|
|
52
|
-
importHelpers: true,
|
|
53
|
-
},
|
|
54
|
-
angularCompilerOptions: {
|
|
55
|
-
compilationMode: 'partial',
|
|
56
|
-
strictTemplates: true,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function ensureStandaloneWorkspace({ repoRoot, log }) {
|
|
62
|
-
const distRoot = path.join(repoRoot, 'dist');
|
|
63
|
-
const workspaceRoot = path.join(distRoot, '.meridiane-workspace');
|
|
64
|
-
|
|
65
|
-
await ensureDir(distRoot);
|
|
66
|
-
await ensureDir(workspaceRoot);
|
|
67
|
-
|
|
68
|
-
const detected = await detectToolchainVersions(repoRoot);
|
|
69
|
-
const angularVersion = detected.angularVersion ?? '21.1.4';
|
|
70
|
-
const derived = deriveToolchainDefaultsFromAngular(angularVersion);
|
|
71
|
-
const ngPackagrVersion = detected.ngPackagrVersion ?? derived.ngPackagrVersion;
|
|
72
|
-
const typescriptVersion = detected.typescriptVersion ?? derived.typescriptVersion;
|
|
73
|
-
const rxjsVersion = detected.rxjsVersion ?? '7.8.2';
|
|
74
|
-
const tslibVersion = detected.tslibVersion ?? '2.8.1';
|
|
75
|
-
log?.debug?.('[meridiane] angular version', { angularVersion });
|
|
76
|
-
await writeJsonIfChanged(
|
|
77
|
-
path.join(workspaceRoot, 'package.json'),
|
|
78
|
-
toolchainPackageJson({ angularVersion, ngPackagrVersion, typescriptVersion, rxjsVersion, tslibVersion })
|
|
79
|
-
);
|
|
80
|
-
await writeJsonIfChanged(path.join(workspaceRoot, 'tsconfig.json'), rootTsconfigJson());
|
|
81
|
-
|
|
82
|
-
const npmCacheDir = path.join(workspaceRoot, '.npm-cache');
|
|
83
|
-
await ensureDir(npmCacheDir);
|
|
84
|
-
|
|
85
|
-
const requireFromWs = createRequire(path.join(workspaceRoot, 'package.json'));
|
|
86
|
-
|
|
87
|
-
return { workspaceRoot, distRoot, npmCacheDir, requireFromWs };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function detectToolchainVersions(repoRoot) {
|
|
91
|
-
const pkgPath = path.join(repoRoot, 'package.json');
|
|
92
|
-
try {
|
|
93
|
-
const raw = await fs.readFile(pkgPath, 'utf8');
|
|
94
|
-
const parsed = JSON.parse(raw);
|
|
95
|
-
const angularVersion = readDependencyVersion(parsed, '@angular/core');
|
|
96
|
-
const ngPackagrVersion = readDependencyVersion(parsed, 'ng-packagr');
|
|
97
|
-
const typescriptVersion = readDependencyVersion(parsed, 'typescript');
|
|
98
|
-
const rxjsVersion = readDependencyVersion(parsed, 'rxjs');
|
|
99
|
-
const tslibVersion = readDependencyVersion(parsed, 'tslib');
|
|
100
|
-
return { angularVersion, ngPackagrVersion, typescriptVersion, rxjsVersion, tslibVersion };
|
|
101
|
-
} catch {
|
|
102
|
-
return {};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function readDependencyVersion(pkg, depName) {
|
|
107
|
-
const deps = pkg?.dependencies || {};
|
|
108
|
-
const devDeps = pkg?.devDependencies || {};
|
|
109
|
-
const peerDeps = pkg?.peerDependencies || {};
|
|
110
|
-
const value = deps[depName] ?? devDeps[depName] ?? peerDeps[depName];
|
|
111
|
-
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function deriveToolchainDefaultsFromAngular(angularVersion) {
|
|
115
|
-
const major = parseInt(String(angularVersion).match(/\d+/)?.[0] ?? '0', 10);
|
|
116
|
-
if (major >= 21) {
|
|
117
|
-
return {
|
|
118
|
-
ngPackagrVersion: '21.1.0',
|
|
119
|
-
typescriptVersion: '5.9.3',
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
ngPackagrVersion: '20.1.0',
|
|
124
|
-
typescriptVersion: '5.8.3',
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export async function ensureToolchainInstalled({ workspaceRoot, requireFromWs, npmCacheDir, log }) {
|
|
129
|
-
// Prefer using existing (hoisted) deps during local dev; in CI this will trigger installation.
|
|
130
|
-
const canResolve = (id) => {
|
|
131
|
-
try {
|
|
132
|
-
requireFromWs.resolve(id);
|
|
133
|
-
return true;
|
|
134
|
-
} catch {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
if (canResolve('ng-packagr/package.json')) return false;
|
|
140
|
-
|
|
141
|
-
log?.step?.('installation du toolchain (Angular + ng-packagr)');
|
|
142
|
-
|
|
143
|
-
// Use npm with a local cache to avoid writing to ~/.npm.
|
|
144
|
-
const env = {
|
|
145
|
-
...process.env,
|
|
146
|
-
npm_config_cache: npmCacheDir,
|
|
147
|
-
npm_config_update_notifier: 'false',
|
|
148
|
-
npm_config_fund: 'false',
|
|
149
|
-
npm_config_audit: 'false',
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
// We avoid generating a lockfile in the backend repo by keeping everything under dist/.
|
|
153
|
-
const npmCmd = 'npm';
|
|
154
|
-
const args = ['install', '--silent', '--no-progress'];
|
|
155
|
-
const code = await runCommand(npmCmd, args, { cwd: workspaceRoot, env });
|
|
156
|
-
|
|
157
|
-
if (code !== 0) throw new Error(`Toolchain install failed (npm exit ${code})`);
|
|
158
|
-
if (!(await exists(path.join(workspaceRoot, 'node_modules')))) {
|
|
159
|
-
throw new Error('Toolchain install failed: node_modules missing');
|
|
160
|
-
}
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{_lib_template → angular-bridge}/src/lib/bridge/sse/eventsource-wrapper.ts
RENAMED
|
File without changes
|
/package/templates/{_lib_template → angular-bridge}/src/lib/bridge/sse/mercure-topic.mapper.ts
RENAMED
|
File without changes
|
|
File without changes
|
/package/templates/{_lib_template → angular-bridge}/src/lib/interceptors/bridge-debug.interceptor.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|