Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
francescobianco committed Nov 29, 2024
1 parent a7de3b8 commit 1434f5f
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/commands/generate/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@

import { Command, Flags } from '@oclif/core';
import * as fs from 'node:fs';

import { parseModules } from '../../services/parser.js';
import * as fs from 'fs';

export default class Generate extends Command {
static description = 'Genera un diagramma UML dei moduli NestJS';

static flags = {
path: Flags.string({
char: 'p',
description: 'Percorso alla codebase NestJS',
default: 'src/',
}),
output: Flags.string({
char: 'o',
description: 'File di output per il diagramma UML',
default: 'modules.puml',
description: 'File di output per il diagramma UML',
}),
path: Flags.string({
char: 'p',
default: 'src/',
description: 'Percorso alla codebase NestJS',
}),
};

generatePlantUML(modules: { imports: string[]; name: string }[]): string {
const lines = ['@startuml', 'skinparam componentStyle rectangle'];
for (const { imports, name } of modules) {
lines.push(`component ${name}`);
for (const imp of imports) {
lines.push(`${name} --> ${imp}`);
}
}

lines.push('@enduml');
return lines.join('\n');
}

async run() {
const { flags } = await this.parse(Generate);
this.log((`Analizzo il percorso: ${flags.path}`));
Expand All @@ -27,7 +41,7 @@ export default class Generate extends Command {

console.log(modules);

if (!modules.length) {
if (modules.length === 0) {
this.error(('Nessun modulo trovato nella codebase.'));
}

Expand All @@ -41,16 +55,4 @@ export default class Generate extends Command {
this.log(uml);
}
}

generatePlantUML(modules: { name: string; imports: string[] }[]): string {
const lines = ['@startuml', 'skinparam componentStyle rectangle'];
modules.forEach(({ name, imports }) => {
lines.push(`component ${name}`);
imports.forEach((imp) => {
lines.push(`${name} --> ${imp}`);
});
});
lines.push('@enduml');
return lines.join('\n');
}
}

0 comments on commit 1434f5f

Please sign in to comment.