@intellegens/cornerstone-cli 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,16 +28,24 @@ exports.zodSchemaGeneratorCommand = {
28
28
  async handler(args) {
29
29
  try {
30
30
  const { input: inputPath, output: outputPath } = args;
31
- if (!fs_extra_1.default.existsSync(outputPath)) {
32
- fs_extra_1.default.mkdirSync(outputPath, { recursive: true });
31
+ if (!fs_extra_1.default.existsSync(inputPath)) {
32
+ console.warn('🟡 Input directory not found.');
33
+ process.exit(0);
33
34
  }
34
35
  const files = fs_extra_1.default
35
36
  .readdirSync(inputPath)
36
37
  .filter((file) => file.endsWith('.json'));
37
38
  if (files.length === 0) {
38
- console.error('No JSON schema files found in the input directory.');
39
- process.exit(1);
39
+ console.warn('🟡 No JSON schema files found in the input directory.');
40
+ process.exit(0);
41
+ }
42
+ if (!fs_extra_1.default.existsSync(outputPath)) {
43
+ fs_extra_1.default.emptyDirSync(outputPath);
40
44
  }
45
+ else {
46
+ fs_extra_1.default.mkdirSync(outputPath, { recursive: true });
47
+ }
48
+ var exports = {};
41
49
  for (const file of files) {
42
50
  const filePath = path_1.default.join(inputPath, file);
43
51
  const schemaContent = fs_extra_1.default.readFileSync(filePath, 'utf-8');
@@ -60,15 +68,26 @@ exports.zodSchemaGeneratorCommand = {
60
68
  depth: 5,
61
69
  });
62
70
  // Generate TypeScript file
63
- const fileName = typeName;
71
+ const fileName = `${typeName}.ts`;
64
72
  const outputFilePath = path_1.default.join(namespaceDir, fileName);
73
+ const outputTypePath = path_1.default.join(namespaceDir, typeName);
65
74
  fs_extra_1.default.writeFileSync(outputFilePath, zodSchema, 'utf-8');
66
- console.log(`Generated Zod schema: ${outputFilePath}`);
75
+ console.log(`- Generated Zod schema: ${outputFilePath}`);
76
+ // Register for (re)export
77
+ exports[typeName] = path_1.default.relative(outputPath, outputTypePath);
78
+ }
79
+ // Write (re)export file
80
+ let exportFileContent = '';
81
+ for (const typeName in exports) {
82
+ const typePath = exports[typeName];
83
+ exportFileContent += `export * from './${typePath}'; // .NET ${typeName} class\n`;
67
84
  }
68
- console.log(' Zod schemas generated successfully!');
85
+ fs_extra_1.default.writeFileSync(path_1.default.join(outputPath, './index.ts'), exportFileContent, 'utf-8');
86
+ // Prompt done
87
+ console.log('🟢 Zod schemas generated successfully!');
69
88
  }
70
89
  catch (error) {
71
- console.error(' Error generating Zod schemas:', error);
90
+ console.error('🔴 Error generating Zod schemas:', error);
72
91
  process.exit(1);
73
92
  }
74
93
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intellegens/cornerstone-cli",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "main": "./index.js",
5
5
  "bin": {
6
6
  "cornerstone-ts": "./index.js"