@yorha2b-lab/autodev 1.0.39 → 1.0.41

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
@@ -143,6 +143,11 @@ module.exports = {
143
143
  visionModel: 'qwen3.5-plus',
144
144
  textModel: 'qwen-turbo',
145
145
 
146
+ // 自定义模板目录
147
+ // 如果为空,将使用内置模板
148
+ // 自定义模板需要在hbsdir目录创建自己的index.hbs和resource.hbs文件
149
+ hbsDir: '',
150
+
146
151
  // 目标项目的目录路径
147
152
  hooksDir: 'src/hooks',
148
153
  pagesDir: 'src/pages',
package/README_EN.md CHANGED
@@ -143,6 +143,11 @@ module.exports = {
143
143
  visionModel: 'qwen3.5-plus',
144
144
  textModel: 'qwen-turbo',
145
145
 
146
+ // Custom template directory path
147
+ // If empty, will use built-in templates
148
+ // Custom templates need to create their own index.hbs and resource.hbs files in the hbsdir directory
149
+ hbsDir: '',
150
+
146
151
  // Target project directory paths
147
152
  hooksDir: 'src/hooks',
148
153
  pagesDir: 'src/pages',
package/config.js CHANGED
@@ -16,6 +16,11 @@ module.exports = {
16
16
 
17
17
  textModel: 'qwen-turbo',
18
18
 
19
+ // 自定义模板目录
20
+ // 如果为空,将使用内置模板
21
+ // 自定义模板需要在hbsdir目录创建自己的index.hbs和resource.hbs文件
22
+ hbsDir: '',
23
+
19
24
  // 目标项目的 hooks 目录路径
20
25
  hooksDir: 'src/hooks',
21
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "基于视觉大模型的前端(Umi+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -42,9 +42,12 @@ const watchPage = options => {
42
42
  const { index, resource } = require(compilerPath)
43
43
 
44
44
  try {
45
- copyTemplateDir(options, 'hooks', config.hooksDir)
46
- copyTemplateDir(options, 'utils', config.utilsDir)
47
- copyTemplateDir(options, 'components', config.componentsDir)
45
+ //默认使用内置模板
46
+ if (config.hbsDir === '') {
47
+ copyTemplateDir(options, 'hooks', config.hooksDir)
48
+ copyTemplateDir(options, 'utils', config.utilsDir)
49
+ copyTemplateDir(options, 'components', config.componentsDir)
50
+ }
48
51
  } catch (error) {
49
52
  console.error(language('❌ 程序运行出错:', '❌ Runtime error:'), error)
50
53
  }
@@ -52,7 +55,7 @@ const watchPage = options => {
52
55
  const queue = createTaskQueue(2)
53
56
  const menus = getExistingMenus()
54
57
 
55
- const tplDir = path.join(__dirname, `../../templates/${options.template}`)
58
+ const tplDir = config.hbsDir !== '' ? path.join(process.cwd(), config.hbsDir) : path.join(__dirname, `../../templates/${options.template}`)
56
59
  const indexTpl = Handlebars.compile(fs.readFileSync(path.join(tplDir, 'index.hbs'), 'utf-8'))
57
60
  const resourceTpl = Handlebars.compile(fs.readFileSync(path.join(tplDir, 'resource.hbs'), 'utf-8'))
58
61
 
@@ -119,10 +122,10 @@ const watchPage = options => {
119
122
  `🧑‍💻 9S: Leave it to me, 2B! Hacking and forging Mock data for [${fileName}]...`
120
123
  )))
121
124
  const rawContent = await generateMock(pageConfig.table.columns, fileName)
122
- fs.writeFileSync(path.join(mockDir, `${fileName}.js`), `export default ${stringify.default(rawContent, { indent: 4, maxLength: 200 })}`.replaceAll(`"'`, `"`).replaceAll(`'"`, `"`))
125
+ fs.writeFileSync(path.join(mockDir, `${fileName}.js`), `export default ${stringify.default(rawContent, { indent: 4, maxLength: 200 })}`)
123
126
  console.log(chalk.green(language(
124
- `🤖 Pod 042: [报告] Mock 数据注入完成,耗时: ${(Date.now() - startTime) / 1000} 秒`,
125
- `🤖 Pod 042: [Report] Mock data injection complete. Elapsed time: ${(Date.now() - startTime) / 1000}s`
127
+ `\n🤖 Pod 042: [报告] Mock 数据注入完成,耗时: ${(Date.now() - startTime) / 1000} 秒`,
128
+ `\n🤖 Pod 042: [Report] Mock data injection complete. Elapsed time: ${(Date.now() - startTime) / 1000}s`
126
129
  )))
127
130
  }
128
131
 
@@ -1,5 +1,6 @@
1
1
  module.exports = (columns, fileName) => `
2
- 根据这些字段生成一个简单的get接口mock数据: ${JSON.stringify(columns)},
3
- 格式如下:
4
- 'POST /api/${fileName}': {data:模块对象列表},
2
+ 根据这些字段生成一个简单的接口mock数据: ${JSON.stringify(columns)},
3
+ 格式为{key:value}:
4
+ key: POST /api/${fileName}
5
+ value: {data:模块对象列表},
5
6
  `