From 1e68ceb211bb7d46739377edd79fdbb1a42544fe Mon Sep 17 00:00:00 2001 From: z3n Date: Fri, 29 May 2026 14:16:52 +0000 Subject: [PATCH] fix(docs-generation): utiliser @asyncapi/generator en API programmatique MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-Authored-By: Happy --- back/package.json | 1 + .../docs-generation/docs-generation.service.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/back/package.json b/back/package.json index 2540578..b3b7689 100644 --- a/back/package.json +++ b/back/package.json @@ -29,6 +29,7 @@ "class-validator": "^0.14.0", "class-transformer": "^0.5.0", "@asyncapi/cli": "6.0.0", + "@asyncapi/generator": "3.0.1", "@asyncapi/html-template": "3.5.6", "@redocly/cli": "latest" }, diff --git a/back/src/modules/docs-generation/docs-generation.service.ts b/back/src/modules/docs-generation/docs-generation.service.ts index a4f8df2..5dc806a 100644 --- a/back/src/modules/docs-generation/docs-generation.service.ts +++ b/back/src/modules/docs-generation/docs-generation.service.ts @@ -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 { - /* 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 {