@azure-net/cli 1.0.2 → 1.0.3

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.
package/bin/azure-net.js CHANGED
@@ -11,7 +11,7 @@ program
11
11
  .description('Universal code generator')
12
12
  .version('1.0.0');
13
13
 
14
- program.command('generate:crud-repository')
14
+ program.command('generate:crud-repo')
15
15
  .description('Generate a CRUD repository')
16
16
  .action(generateRepository);
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -1,3 +1,27 @@
1
+ import prompts from 'prompts';
2
+ import ejs from 'ejs';
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import { loadUserConfig } from "../utils/loadConfig.js";
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
+
1
10
  export default async function generateCrudService() {
11
+ const config = await loadUserConfig();
12
+ const answers = await prompts([
13
+ { type: 'text', name: 'className', message: 'Class name:' },
14
+ { type: 'text', name: 'endpoint', message: 'API endpoint:' },
15
+ ]);
16
+
17
+ const templatePath = path.join(__dirname, '../templates/generateCrudRepo.ejs');
18
+ const template = await fs.readFile(templatePath, 'utf-8');
19
+ const result = ejs.render(template, answers);
20
+
21
+ const outputDir = config.output.repository;
22
+ const outFile = path.join(process.cwd(), outputDir, `${answers.className}Repo.ts`);
23
+ await fs.mkdir(path.dirname(outFile), { recursive: true });
24
+ await fs.writeFile(outFile, result, 'utf-8');
2
25
 
3
- };
26
+ console.log(`✅ Created: ${outFile}`);
27
+ }