@yorha2b-lab/autodev 5.3.1 → 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 =
|
|
11
|
+
const dialogs = discover(path.join(__dirname, '../src/dialogs'))
|
|
10
12
|
const dialog = dialogs[local] ?? dialogs['EN-US']
|
|
11
13
|
|
|
12
14
|
program
|
|
@@ -20,7 +22,7 @@ program
|
|
|
20
22
|
.description(dialog.bunker.initDesc)
|
|
21
23
|
.action(() => {
|
|
22
24
|
const battlefield = {
|
|
23
|
-
dirs: [
|
|
25
|
+
dirs: [],
|
|
24
26
|
files: [
|
|
25
27
|
{ from: '.env.example', to: '.env', exist: 'envCheck', success: 'envCopy' },
|
|
26
28
|
{ from: 'config.js', to: 'config.js', exist: 'configCheck', success: 'configCopy' }
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
module.exports = ({ yorha, config, dialog, handlers, template, foundation }) => {
|
|
2
5
|
|
|
3
6
|
const { copyTemplateDir } = foundation
|
|
4
7
|
const { hbsDir, hooksDir, utilsDir, componentsDir } = config
|
|
5
8
|
|
|
6
9
|
try {
|
|
10
|
+
Object.values(handlers).forEach(handler => fs.mkdirSync(path.join(process.cwd(), handler.watch), { recursive: true }))
|
|
7
11
|
if (hbsDir === '') {
|
|
8
12
|
copyTemplateDir(template, 'hooks', hooksDir)
|
|
9
13
|
copyTemplateDir(template, 'utils', utilsDir)
|
package/src/bootstrap/index.js
CHANGED
|
@@ -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
|
-
|
|
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)
|
package/src/commands/watch.js
CHANGED
|
@@ -8,6 +8,7 @@ module.exports = () => {
|
|
|
8
8
|
const ctx = bootstrap.get()
|
|
9
9
|
|
|
10
10
|
const queue = ctx.core.createTaskQueue(2)
|
|
11
|
+
const routes = Object.values(ctx.handlers)
|
|
11
12
|
|
|
12
13
|
queue.onIdle(() => {
|
|
13
14
|
ctx.yorha.pod042.report(ctx.dialog.pod042.queueEmpty)
|
|
@@ -25,12 +26,10 @@ module.exports = () => {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const fileWatcher = chokidar.watch(['./config.js'], options)
|
|
28
|
-
const dirWatcher = chokidar.watch(
|
|
29
|
+
const dirWatcher = chokidar.watch(routes.map(route => `${route.watch}`), options)
|
|
29
30
|
|
|
30
31
|
ctx.yorha.operator6O.report(ctx.dialog.operator6O.call2B)
|
|
31
32
|
|
|
32
|
-
const routes = Object.values(ctx.handlers)
|
|
33
|
-
|
|
34
33
|
dirWatcher.on('add', filePath => {
|
|
35
34
|
const absolutePath = path.resolve(filePath)
|
|
36
35
|
const route = routes.find(route => absolutePath.includes(route.watch))
|
package/src/utils/foundation.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
}
|