fix(docs-generation): utiliser @asyncapi/generator en API programmatique
Remplace execFile('asyncapi') par l'API Node.js directe — aucun appel
réseau vers registry.npmjs.org, template résolu depuis node_modules local.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
"class-validator": "^0.14.0",
|
"class-validator": "^0.14.0",
|
||||||
"class-transformer": "^0.5.0",
|
"class-transformer": "^0.5.0",
|
||||||
"@asyncapi/cli": "6.0.0",
|
"@asyncapi/cli": "6.0.0",
|
||||||
|
"@asyncapi/generator": "3.0.1",
|
||||||
"@asyncapi/html-template": "3.5.6",
|
"@asyncapi/html-template": "3.5.6",
|
||||||
"@redocly/cli": "latest"
|
"@redocly/cli": "latest"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import { execFile } from 'child_process';
|
|||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
import * as fs from 'fs/promises';
|
import * as fs from 'fs/promises';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
const AsyncApiGenerator = require('@asyncapi/generator');
|
||||||
import { ApisService } from '../apis/apis.service';
|
import { ApisService } from '../apis/apis.service';
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
|
|
||||||
/* Ajoute node_modules/.bin au PATH pour trouver asyncapi/redocly en local */
|
/* Ajoute node_modules/.bin au PATH pour trouver redocly en local */
|
||||||
const localBin = path.join(process.cwd(), 'node_modules', '.bin');
|
const localBin = path.join(process.cwd(), 'node_modules', '.bin');
|
||||||
const execEnv = {
|
const execEnv = {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -50,16 +52,10 @@ export class DocsGenerationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async generateAsyncApi(yamlPath: string, outputDir: string): Promise<void> {
|
private async generateAsyncApi(yamlPath: string, outputDir: string): Promise<void> {
|
||||||
/* Chemin local du template — évite l'appel réseau vers registry.npmjs.org */
|
/* API programmatique — aucun appel réseau, template résolu localement */
|
||||||
const templatePath = path.join(process.cwd(), 'node_modules', '@asyncapi', 'html-template');
|
const templatePath = path.join(process.cwd(), 'node_modules', '@asyncapi', 'html-template');
|
||||||
await execFileAsync('asyncapi', [
|
const generator = new AsyncApiGenerator(templatePath, outputDir, { forceWrite: true });
|
||||||
'generate', 'fromTemplate',
|
await generator.generateFromFile(yamlPath);
|
||||||
yamlPath,
|
|
||||||
templatePath,
|
|
||||||
'--output', outputDir,
|
|
||||||
'--no-interactive',
|
|
||||||
'--force-write',
|
|
||||||
], { shell: true, env: execEnv });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async generateOpenApi(yamlPath: string, outputDir: string): Promise<void> {
|
private async generateOpenApi(yamlPath: string, outputDir: string): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user