@yorha2b-lab/autodev 1.0.24 → 1.0.25

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/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  拒绝重复劳动!为什么你需要 Auto CRUD Copilot?
14
14
  告别手写 Table/Form:截图即代码,提升你的开发效率,告别烦人的复制粘贴。
15
- 拒绝接口联调痛苦:自动读取 Swagger,AI 帮你抹平前后端字段命名差异。
15
+ 拒绝接口联调痛苦:自动读取 Response,AI 帮你抹平前后端字段命名差异。
16
16
  架构解耦:核心逻辑与 UI 框架分离,React/Vue/Angular 均可适配。
17
17
 
18
18
  ## ✨ 特性
@@ -21,7 +21,7 @@
21
21
  - 🔧 **智能生成**: 支持React、Vue、Angular等多种前端框架模板
22
22
  - 📊 **表格组件**: 自动生成可编辑、可排序、可筛选的数据表格
23
23
  - 📝 **表单组件**: 智能生成搜索表单和模态框表单
24
- - 🔌 **API对齐**: 自动对齐Swagger接口与前端字段映射
24
+ - 🔌 **API对齐**: 自动对齐Response接口与前端字段映射
25
25
  - 🎨 **UI组件**: 支持多种UI组件类型(输入框、选择器、日期等)
26
26
  - 📱 **响应式**: 生成的代码支持响应式布局
27
27
 
@@ -70,7 +70,6 @@ autodev watch:part
70
70
  3. **对齐API字段**
71
71
 
72
72
  ```bash
73
- # 将Swagger文档放入swagger目录
74
73
  autodev watch:api
75
74
  ```
76
75
 
@@ -97,7 +96,7 @@ autodev watch:part -t vue
97
96
 
98
97
  ### watch:api 命令
99
98
 
100
- 监听 `swagger` 目录下的API文档,自动对齐真实接口字段。
99
+ 监听 `response` 目录下的与模块同名的json文件,自动对齐真实接口字段。
101
100
 
102
101
  ```bash
103
102
  autodev watch:api
@@ -109,7 +108,7 @@ autodev watch:api
109
108
  your-project/
110
109
  ├── screenShot/ # 页面截图目录
111
110
  ├── screenPart/ # 组件截图目录
112
- ├── swagger/ # API文档目录
111
+ ├── response/ # Response目录
113
112
  ├── mock/ # 生成的Mock数据
114
113
  ├── src/
115
114
  │ ├── pages/ # 生成的页面代码
package/bin/autodev.js CHANGED
@@ -25,7 +25,7 @@ program
25
25
  const tplEnv = path.resolve(__dirname, '../.env.example')
26
26
  const targetEnv = path.join(process.cwd(), '.env')
27
27
  const targetConfig = path.join(process.cwd(), 'config.js')
28
- fs.mkdirSync(path.join(process.cwd(), 'swagger'), { recursive: true })
28
+ fs.mkdirSync(path.join(process.cwd(), 'response'), { recursive: true })
29
29
  fs.mkdirSync(path.join(process.cwd(), 'screenShot'), { recursive: true })
30
30
  fs.mkdirSync(path.join(process.cwd(), 'screenPart'), { recursive: true })
31
31
  if (fs.existsSync(targetEnv)) {
@@ -61,7 +61,7 @@ program
61
61
 
62
62
  program
63
63
  .command('watch:api')
64
- .description('监听 Swagger,自动对齐真实接口字段')
64
+ .description('监听 Response,自动对齐真实接口字段')
65
65
  .action(() => {
66
66
  const watchApi = require('../src/commands/watch-api')
67
67
  watchApi()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "基于视觉大模型的前端(Umi+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -7,11 +7,11 @@ const chokidar = require('chokidar')
7
7
  const watchApi = () => {
8
8
 
9
9
  const { getConfig } = require('../utils/utils.js')
10
- const { alignSwaggerFields } = require('../services/llm.js')
10
+ const { alignResponseFields } = require('../services/llm.js')
11
11
 
12
12
  const config = getConfig()
13
13
 
14
- const watcher = chokidar.watch('./swagger', {
14
+ const watcher = chokidar.watch('./response', {
15
15
  persistent: true,
16
16
  ignored: /(^|[\/\\])\../,
17
17
  awaitWriteFinish: {
@@ -23,13 +23,13 @@ const watchApi = () => {
23
23
  watcher.on('add', async filePath => {
24
24
  const startTime = Date.now()
25
25
  const fileName = path.basename(filePath, path.extname(filePath))
26
- const spinner = ora(chalk.cyan(`🤖 Pod 153: [报告] 侦测到未知的 Swagger 数据源 [${fileName}],开始进行语义对齐...`))
26
+ const spinner = ora(chalk.cyan(`🤖 Pod 153: [报告] 侦测到未知的 Response 数据源 [${fileName}],开始进行语义对齐...`))
27
27
  spinner.start()
28
28
 
29
29
  try {
30
- const swaggerStr = fs.readFileSync(filePath, 'utf8')
30
+ const responseStr = fs.readFileSync(filePath, 'utf8')
31
31
  let resourceStr = fs.readFileSync(`./${config.pagesDir}/${fileName}/resource.js`, 'utf8')
32
- const result = await alignSwaggerFields(swaggerStr, resourceStr)
32
+ const result = await alignResponseFields(responseStr, resourceStr)
33
33
  Object.entries(result).forEach(([oldField, newField]) => {
34
34
  if (oldField === newField) return
35
35
  const regex = new RegExp(`(dataIndex|name)\\s*:\\s*['"]${oldField}['"]`, 'g')
@@ -1,11 +1,11 @@
1
- module.exports = (swaggerStr, resourceStr) => `
2
- swaggerStr: ${swaggerStr}
1
+ module.exports = (responseStr, resourceStr) => `
2
+ responseStr: ${responseStr}
3
3
  resourceStr: ${resourceStr}
4
4
  resourceStr是前端目前猜测的字段名列表(请从resourceStr中提取dataIndex和name),
5
- swaggerStr是后端的真实响应。
5
+ responseStr是后端的真实响应。
6
6
  请比对两者,找出现有前端字段名应该被替换为哪个真实的后端字段名。
7
7
  匹配规则: 1.完全相同 2.下划线/驼峰转换 3.语义相似。
8
- 请只输出一个JSON对象, Key为前端猜测的旧名字, Value为Swagger里的真实新名字。
8
+ 请只输出一个JSON对象, Key为前端猜测的旧名字, Value为Response里的真实新名字。
9
9
  例如:{"key_1": "key1"}
10
10
  如果没有找到对应的,请不要包含在结果中。
11
11
  `.trim()
@@ -117,12 +117,12 @@ module.exports = {
117
117
  },
118
118
 
119
119
  /**
120
- * 对齐 Swagger 接口字段与前端字段
121
- * @param {string} swaggerStr - 真实接口响应数据
120
+ * 对齐 Response 接口字段与前端字段
121
+ * @param {string} responseStr - 真实接口响应数据
122
122
  * @param {string} resourceStr - 前端 resource.js 内容
123
123
  * @returns {Object} 字段映射对象 { oldName: newName }
124
124
  */
125
- alignSwaggerFields: async (swaggerStr, resourceStr) => {
125
+ alignResponseFields: async (responseStr, resourceStr) => {
126
126
  const config = getConfig()
127
127
  const apiPrompt = require('../prompts/watch-api.js')
128
128
  const { API_DESIGNER } = require('../prompts/system.js')
@@ -130,7 +130,7 @@ module.exports = {
130
130
  config.textModel,
131
131
  [
132
132
  { role: 'system', content: API_DESIGNER },
133
- { role: 'user', content: apiPrompt(swaggerStr, resourceStr) }
133
+ { role: 'user', content: apiPrompt(responseStr, resourceStr) }
134
134
  ]
135
135
  )
136
136
  }
@@ -9,7 +9,7 @@ const AliyunOSSUpload = ({ style, value, disabled, onChange }) => {
9
9
 
10
10
  const init = async () => {
11
11
  try {
12
- const result = await initOss()
12
+ const result = await initOSS()
13
13
  setOSSData(result)
14
14
  } catch (err) {
15
15
  console.log(err)