@azure-net/cli 1.0.1 → 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
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ export default async function generateCrudRepository() {
|
|
|
19
19
|
const result = ejs.render(template, answers);
|
|
20
20
|
|
|
21
21
|
const outputDir = config.output.repository;
|
|
22
|
-
const outFile = path.join(process.cwd(), outputDir, `${answers.className}.ts`);
|
|
22
|
+
const outFile = path.join(process.cwd(), outputDir, `${answers.className}Repo.ts`);
|
|
23
23
|
await fs.mkdir(path.dirname(outFile), { recursive: true });
|
|
24
24
|
await fs.writeFile(outFile, result, 'utf-8');
|
|
25
25
|
|
|
@@ -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
|
+
}
|