Skip to content

Commit af8a08c

Browse files
committed
chore: update dependencies and enhance types generator functionality
- Added support for ESLint and Prettier in the types generator to enforce code quality and formatting. - Introduced a new CLI option to enable linting and formatting of generated type definitions. - Enhanced the ContentrainTypesGenerator class to recursively find configuration files and merge settings. - Improved error handling and logging throughout the types generation process. - Updated package.json to include new dependencies for ESLint and Prettier. - Modified the contentrain-config.json to enable linting by default.
1 parent 8e5a589 commit af8a08c

File tree

6 files changed

+402
-149
lines changed

6 files changed

+402
-149
lines changed

packages/types-generator/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
},
5050
"devDependencies": {
5151
"@types/node": "^20.10.6",
52+
"@typescript-eslint/eslint-plugin": "^8.21.0",
53+
"@typescript-eslint/parser": "^8.21.0",
54+
"eslint": "^9.17.0",
55+
"prettier": "^3.4.2",
5256
"tsup": "^8.0.1",
5357
"typescript": "^5.3.3",
5458
"vitest": "^1.1.3"

packages/types-generator/src/cli.ts

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,63 @@ program
1414
.option('-m, --models <path>', 'Model dizininin yolu')
1515
.option('-o, --output <path>', 'Çıktı dizininin yolu')
1616
.option('-c, --content <path>', 'İçerik dizininin yolu')
17+
.option('-l, --lint', 'Tip tanımlarını lint et ve formatla')
1718
.option('-d, --debug', 'Debug modunda çalıştır')
1819
.parse(process.argv);
1920

20-
const options = program.opts();
21+
async function main() {
22+
const options = program.opts();
2123

22-
try {
23-
// Komut satırı argümanlarını mutlak yola çevir
24-
const resolvedOptions = {
25-
modelsDir: options.models ? path.resolve(process.cwd(), options.models) : undefined,
26-
outputDir: options.output ? path.resolve(process.cwd(), options.output) : undefined,
27-
contentDir: options.content ? path.resolve(process.cwd(), options.content) : undefined,
28-
};
24+
try {
25+
// Komut satırı argümanlarını mutlak yola çevir
26+
const resolvedOptions = {
27+
modelsDir: options.models ? path.resolve(process.cwd(), options.models) : undefined,
28+
outputDir: options.output ? path.resolve(process.cwd(), options.output) : undefined,
29+
contentDir: options.content ? path.resolve(process.cwd(), options.content) : undefined,
30+
lint: options.lint,
31+
};
2932

30-
if (options.debug) {
31-
console.log('CLI Options:', options);
32-
console.log('Resolved Options:', resolvedOptions);
33-
}
34-
35-
// Eğer komut satırı argümanları verilmemişse, config dosyasını kullan
36-
const generator = new ContentrainTypesGenerator(resolvedOptions);
33+
if (options.debug) {
34+
console.log('CLI Options:', options);
35+
console.log('Resolved Options:', resolvedOptions);
36+
}
3737

38-
if (options.debug) {
39-
console.log('Generator Configuration:', {
40-
modelsDir: generator.getConfig().modelsDir,
41-
contentDir: generator.getConfig().contentDir,
42-
outputDir: generator.getConfig().outputDir,
43-
});
44-
}
38+
// Eğer komut satırı argümanları verilmemişse, config dosyasını kullan
39+
const generator = new ContentrainTypesGenerator(resolvedOptions);
4540

46-
generator.generate();
47-
}
48-
catch (error: unknown) {
49-
if (options.debug) {
50-
if (error instanceof Error) {
51-
console.error('❌ Hata detayları:', {
52-
message: error.message,
53-
cause: error.cause,
54-
stack: error.stack,
41+
if (options.debug) {
42+
console.log('Generator Configuration:', {
43+
modelsDir: generator.getConfig().modelsDir,
44+
contentDir: generator.getConfig().contentDir,
45+
outputDir: generator.getConfig().outputDir,
5546
});
5647
}
48+
49+
await generator.generate();
50+
}
51+
catch (error: unknown) {
52+
if (options.debug) {
53+
if (error instanceof Error) {
54+
console.error('❌ Hata detayları:', {
55+
message: error.message,
56+
cause: error.cause,
57+
stack: error.stack,
58+
});
59+
}
60+
else {
61+
console.error('❌ Hata detayları:', error);
62+
}
63+
}
5764
else {
58-
console.error('❌ Hata detayları:', error);
65+
console.error('❌ Tip tanımları oluşturulurken hata:', error instanceof Error ? error.message : String(error));
66+
console.error('Daha fazla detay için -d veya --debug seçeneğini kullanın');
5967
}
68+
process.exit(1);
6069
}
61-
else {
62-
console.error('❌ Tip tanımları oluşturulurken hata:', error instanceof Error ? error.message : String(error));
63-
console.error('Daha fazla detay için -d veya --debug seçeneğini kullanın');
64-
}
65-
process.exit(1);
6670
}
71+
72+
// Ana fonksiyonu çalıştır
73+
main().catch((error) => {
74+
console.error('❌ Beklenmeyen hata:', error);
75+
process.exit(1);
76+
});

0 commit comments

Comments
 (0)