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:
z3n
2026-05-29 14:16:52 +00:00
parent 67609231d9
commit 1e68ceb211
2 changed files with 7 additions and 10 deletions

View File

@@ -3,11 +3,13 @@ import { execFile } from 'child_process';
import { promisify } from 'util';
import * as fs from 'fs/promises';
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';
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 execEnv = {
...process.env,
@@ -50,16 +52,10 @@ export class DocsGenerationService {
}
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');
await execFileAsync('asyncapi', [
'generate', 'fromTemplate',
yamlPath,
templatePath,
'--output', outputDir,
'--no-interactive',
'--force-write',
], { shell: true, env: execEnv });
const generator = new AsyncApiGenerator(templatePath, outputDir, { forceWrite: true });
await generator.generateFromFile(yamlPath);
}
private async generateOpenApi(yamlPath: string, outputDir: string): Promise<void> {