This commit is contained in:
40
src/generators/jsonGenerator.ts
Normal file
40
src/generators/jsonGenerator.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { TemplateData } from '../types';
|
||||
|
||||
export class JsonGenerator {
|
||||
static generate(data: TemplateData): string {
|
||||
return JSON.stringify(data, null, 2);
|
||||
}
|
||||
|
||||
static generateSummary(data: TemplateData): object {
|
||||
const { projectInfo, files, config, generatedAt } = data;
|
||||
|
||||
return {
|
||||
generatedAt,
|
||||
project: {
|
||||
type: projectInfo.projectType.primaryLanguage,
|
||||
languages: projectInfo.projectType.languages,
|
||||
frameworks: projectInfo.projectType.frameworks,
|
||||
buildTools: projectInfo.projectType.buildTools,
|
||||
fileCount: projectInfo.fileCount,
|
||||
},
|
||||
dependencies: {
|
||||
total: projectInfo.dependencies.total,
|
||||
production: projectInfo.dependencies.direct.length,
|
||||
development: projectInfo.dependencies.dev.length,
|
||||
topDependencies: projectInfo.dependencies.direct
|
||||
.slice(0, 10)
|
||||
.map(d => d.name),
|
||||
},
|
||||
conventions: projectInfo.conventions
|
||||
? {
|
||||
naming: projectInfo.conventions.namingConvention,
|
||||
importStyle: projectInfo.conventions.importStyle.style,
|
||||
testingFramework: projectInfo.conventions.testingFramework,
|
||||
codeStyle: projectInfo.conventions.codeStyle,
|
||||
}
|
||||
: null,
|
||||
config,
|
||||
sampleFiles: files.slice(0, 20),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user