@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 +5 -0
- package/README_EN.md +5 -0
- package/config.js +5 -0
- package/package.json +1 -1
- package/src/commands/watch-page.js +10 -7
- package/src/prompts/mock.js +4 -3
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
package/package.json
CHANGED
|
@@ -42,9 +42,12 @@ const watchPage = options => {
|
|
|
42
42
|
const { index, resource } = require(compilerPath)
|
|
43
43
|
|
|
44
44
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 })}
|
|
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
|
-
|
|
125
|
-
|
|
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
|
|
package/src/prompts/mock.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module.exports = (columns, fileName) => `
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
根据这些字段生成一个简单的接口mock数据: ${JSON.stringify(columns)},
|
|
3
|
+
格式为{key:value}:
|
|
4
|
+
key: POST /api/${fileName}
|
|
5
|
+
value: {data:模块对象列表},
|
|
5
6
|
`
|