This commit is contained in:
54
app/ai-context-generator-cli/src/generators/yamlGenerator.ts
Normal file
54
app/ai-context-generator-cli/src/generators/yamlGenerator.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import yaml from 'js-yaml';
|
||||
import { TemplateData } from '../types';
|
||||
|
||||
export class YamlGenerator {
|
||||
static generate(data: TemplateData): string {
|
||||
return yaml.dump(data, {
|
||||
indent: 2,
|
||||
lineWidth: -1,
|
||||
noRefs: true,
|
||||
sortKeys: true,
|
||||
});
|
||||
}
|
||||
|
||||
static generateSummary(data: TemplateData): string {
|
||||
const summary = {
|
||||
generated_at: data.generatedAt,
|
||||
project: {
|
||||
type: data.projectInfo.projectType.primaryLanguage,
|
||||
languages: data.projectInfo.projectType.languages,
|
||||
frameworks: data.projectInfo.projectType.frameworks,
|
||||
build_tools: data.projectInfo.projectType.buildTools,
|
||||
file_count: data.projectInfo.fileCount,
|
||||
},
|
||||
dependencies: {
|
||||
total: data.projectInfo.dependencies.total,
|
||||
production: data.projectInfo.dependencies.direct.length,
|
||||
development: data.projectInfo.dependencies.dev.length,
|
||||
top_dependencies: data.projectInfo.dependencies.direct
|
||||
.slice(0, 10)
|
||||
.map(d => d.name),
|
||||
},
|
||||
conventions: data.projectInfo.conventions
|
||||
? {
|
||||
naming: {
|
||||
files: data.projectInfo.conventions.namingConvention.files,
|
||||
variables: data.projectInfo.conventions.namingConvention.variables,
|
||||
functions: data.projectInfo.conventions.namingConvention.functions,
|
||||
classes: data.projectInfo.conventions.namingConvention.classes,
|
||||
},
|
||||
import_style: data.projectInfo.conventions.importStyle.style,
|
||||
testing_framework: data.projectInfo.conventions.testingFramework,
|
||||
code_style: {
|
||||
indent_size: data.projectInfo.conventions.codeStyle.indentSize,
|
||||
indent_type: data.projectInfo.conventions.codeStyle.indentType,
|
||||
line_endings: data.projectInfo.conventions.codeStyle.lineEndings,
|
||||
quote_style: data.projectInfo.conventions.codeStyle.quoteStyle,
|
||||
},
|
||||
}
|
||||
: null,
|
||||
};
|
||||
|
||||
return yaml.dump(summary, { indent: 2, lineWidth: -1 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user