@yorha2b-lab/autodev 1.0.6 → 1.0.7

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/autodev.js CHANGED
@@ -3,6 +3,7 @@ const fs = require('fs')
3
3
  const path = require('path')
4
4
  const chalk = require('chalk')
5
5
  const figlet = require('figlet')
6
+ const { program } = require('commander')
6
7
 
7
8
  console.log(chalk.cyan(figlet.textSync('AutoDev', { horizontalLayout: 'full' })))
8
9
  console.log(chalk.gray('--------------------------------------------------'))
@@ -10,20 +11,7 @@ console.log(chalk.white(' [System] ') + chalk.green('YoRHa No.2 Type B Unit: ')
10
11
  console.log(chalk.white(' [Mission] ') + chalk.yellow('Generate Frontend CRUD: ') + chalk.cyan('Awaiting Command'))
11
12
  console.log(chalk.gray('--------------------------------------------------\n'))
12
13
 
13
- const localEnv = path.resolve(process.cwd(), '.env')
14
- const pkgEnv = path.resolve(__dirname, '../.env')
15
-
16
- require("dotenv").config({
17
- path: fs.existsSync(localEnv) ? localEnv : pkgEnv
18
- })
19
-
20
- const { program } = require('commander')
21
- const watchApi = require('../src/commands/watch-api')
22
- const watchPage = require('../src/commands/watch-page')
23
- const watchPart = require('../src/commands/watch-part')
24
-
25
14
  program.version('1.0.0').description('AI驱动的前端CRUD代码生成器')
26
-
27
15
  program.option('-t, --template <type>', '指定前端框架模板', 'react')
28
16
 
29
17
  program
@@ -41,16 +29,25 @@ program
41
29
  program
42
30
  .command('watch:page')
43
31
  .description('监听截图,自动生成完整的增删改查页面')
44
- .action(() => watchPage(program.opts()))
32
+ .action(() => {
33
+ const watchPage = require('../src/commands/watch-page')
34
+ watchPage(program.opts())
35
+ })
45
36
 
46
37
  program
47
38
  .command('watch:part')
48
39
  .description('监听截图,自动生成局部 UI 组件')
49
- .action(() => watchPart(program.opts()))
40
+ .action(() => {
41
+ const watchPart = require('../src/commands/watch-part')
42
+ watchPart(program.opts())
43
+ })
50
44
 
51
45
  program
52
46
  .command('watch:api')
53
47
  .description('监听 Swagger,自动对齐真实接口字段')
54
- .action(() => watchApi())
48
+ .action(() => {
49
+ const watchApi = require('../src/commands/watch-api')
50
+ watchApi()
51
+ })
55
52
 
56
53
  program.parse(process.argv)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "基于视觉大模型的前端(Umi+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -1,3 +1,5 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
1
3
  const JSON5 = require('json5')
2
4
  const sharp = require('sharp')
3
5
  const OpenAI = require('openai')
@@ -12,6 +14,12 @@ let client = null
12
14
 
13
15
  const getOpenAI = () => {
14
16
  if (!client) {
17
+
18
+ const localEnv = path.resolve(process.cwd(), '.env')
19
+ const pkgEnv = path.resolve(__dirname, '../.env')
20
+ require("dotenv").config({
21
+ path: fs.existsSync(localEnv) ? localEnv : pkgEnv
22
+ })
15
23
  client = new OpenAI({ apiKey: process.env.API_KEY, baseURL: process.env.BASE_URL })
16
24
  }
17
25
  return client