@yorha2b-lab/autodev 5.4.0 → 5.5.0

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
@@ -4,9 +4,11 @@ const path = require('path')
4
4
  const chalk = require('chalk')
5
5
  const pkg = require('../package.json')
6
6
  const { program } = require('commander')
7
+
8
+ const { discover } = require('../src/utils/foundation')
7
9
  const { local, matrixEffect, bootSequence } = require('../src/utils/ux')
8
10
 
9
- const dialogs = require('../src/bootstrap/registry')({ dir: path.join(__dirname, '../src/dialogs') })
11
+ const dialogs = discover(path.join(__dirname, '../src/dialogs'))
10
12
  const dialog = dialogs[local] ?? dialogs['EN-US']
11
13
 
12
14
  program
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "description": "基于视觉大模型的前端(react+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -27,9 +27,9 @@ module.exports = {
27
27
  openAI: require('./openai')(),
28
28
  core: require('../utils/core'),
29
29
  menus: foundation.getExistingMenus(),
30
+ handlers: foundation.discover(path.join(__dirname, '../handlers')),
30
31
  handlebars: require('./handlebar')({ config, template, ...foundation }),
31
- handlers: require('./registry')({ dir: path.join(__dirname, '../handlers') }),
32
- prompts: require('./registry')({ dir: path.join(__dirname, `../framework/${template}/prompts`) }),
32
+ prompts: foundation.discover(path.join(__dirname, `../framework/${template}/prompts`)),
33
33
  }
34
34
 
35
35
  require('./foundation')(accessPoint)
@@ -11,7 +11,6 @@ const fs = require('fs')
11
11
  const path = require('path')
12
12
  const stringify = require('json-stringify-pretty-compact')
13
13
 
14
-
15
14
  /**
16
15
  * 获取项目配置信息
17
16
  * 优先读取项目根目录的 config.js,如果不存在则使用默认配置
@@ -63,4 +62,6 @@ const copyTemplateDir = (template, templateSubDir, targetSubDir) => {
63
62
 
64
63
  const contextStringify = ({ context, indent = 4, maxLength = 200 }) => stringify.default(context, { indent, maxLength })
65
64
 
66
- module.exports = { getConfig, getExistingMenus, copyTemplateDir, contextStringify }
65
+ const discover = dir => Object.fromEntries(fs.readdirSync(dir).filter(file => file.endsWith('.js')).map(file => [path.basename(file, '.js'), require(path.join(dir, file))]))
66
+
67
+ module.exports = { discover, getConfig, getExistingMenus, copyTemplateDir, contextStringify }
@@ -1,14 +0,0 @@
1
- module.exports = ({ dir }) => {
2
-
3
- const fs = require('fs')
4
- const path = require('path')
5
-
6
- return Object.fromEntries(
7
- fs.readdirSync(dir)
8
- .filter(file => file.endsWith('.js'))
9
- .map(file => [
10
- path.basename(file, '.js'),
11
- require(path.join(dir, file))
12
- ])
13
- )
14
- }