feat: add mock generation for DTOs, models, and repositories with corresponding templates
This commit is contained in:
@@ -3,6 +3,15 @@ import path from 'path';
|
||||
import { logStep, logSuccess } from '../utils/logger';
|
||||
import type { SwaggerAnalysis, GenerationReport } from '../types';
|
||||
|
||||
/** Counts files ending with `.mock.ts` in a directory (returns 0 if directory does not exist). */
|
||||
function countMockFiles(dir: string): number {
|
||||
try {
|
||||
return fs.readdirSync(dir).filter((f) => f.endsWith('.mock.ts')).length;
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Generates and persists the `generation-report.json` file with process statistics. */
|
||||
export function generateReport(outputDir: string, analysis: SwaggerAnalysis): GenerationReport {
|
||||
logStep('Generating report...');
|
||||
@@ -19,7 +28,14 @@ export function generateReport(outputDir: string, analysis: SwaggerAnalysis): Ge
|
||||
useCases: fs.readdirSync(path.join(outputDir, 'domain/use-cases')).length,
|
||||
providers:
|
||||
fs.readdirSync(path.join(outputDir, 'di/repositories')).length +
|
||||
fs.readdirSync(path.join(outputDir, 'di/use-cases')).length
|
||||
fs.readdirSync(path.join(outputDir, 'di/use-cases')).length,
|
||||
mocks:
|
||||
countMockFiles(path.join(outputDir, 'data/dtos')) +
|
||||
countMockFiles(path.join(outputDir, 'data/repositories')) +
|
||||
countMockFiles(path.join(outputDir, 'di/repositories')) +
|
||||
countMockFiles(path.join(outputDir, 'di/use-cases')) +
|
||||
countMockFiles(path.join(outputDir, 'domain/use-cases')) +
|
||||
countMockFiles(path.join(outputDir, 'entities/models'))
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user