Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/aibom/generator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import fs from "node:fs";
import path from "node:path";

export class AIBOMGenerator {
generateAIBOM(modelData: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
const aibom = {
Expand Down Expand Up @@ -39,15 +42,13 @@ export class AIBOMGenerator {
return aibom;
}

saveAIBOM(aibom: any, filePath: string) {
const fs = require('fs');
const path = require('path');
saveAIBOM(aibom: any, filePath: string) { // eslint-disable-line @typescript-eslint/no-explicit-any
Comment thread
helio-frota marked this conversation as resolved.
const dir = path.join(process.cwd(), 'generated_aiboms');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
// Replace slashes in filename with underscores to avoid subfolders
const safeFileName = filePath.replace(/[\/\\]/g, '_');
const safeFileName = filePath.replace(/[\\/]/g, '_');
const fullPath = path.join(dir, safeFileName);
fs.writeFileSync(fullPath, JSON.stringify(aibom, null, 2));
}
Expand Down