@yorha2b-lab/autodev 5.0.0 → 5.2.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 +31 -45
- package/package.json +1 -1
- package/src/bootstrap/foundation.js +15 -0
- package/src/bootstrap/index.js +35 -30
- package/src/bootstrap/labs.js +21 -0
- package/src/bootstrap/registry.js +14 -0
- package/src/bootstrap/yorha.js +36 -0
- package/src/commands/watch.js +23 -27
- package/src/dialogs/EN-US.js +62 -0
- package/src/dialogs/ZH-CN.js +62 -0
- package/src/framework/react/generator/index.js +4 -1
- package/src/framework/react/prompts/page.js +29 -38
- package/src/handlers/api.js +89 -0
- package/src/handlers/page.js +68 -0
- package/src/handlers/part.js +57 -0
- package/src/labs/linker.js +11 -31
- package/src/labs/tower.js +9 -21
- package/src/services/llm.js +21 -23
- package/src/utils/core.js +43 -3
- package/src/utils/{infrastructure.js → foundation.js} +5 -44
- package/src/utils/ux.js +17 -20
- package/src/bootstrap/handlers.js +0 -10
- package/src/bootstrap/infrastructure.js +0 -15
- package/src/bootstrap/prompt.js +0 -10
- package/src/handlers/apiHandler.js +0 -111
- package/src/handlers/pageHandler.js +0 -95
- package/src/handlers/partHandler.js +0 -77
- /package/src/bootstrap/{handlebars.js → handlebar.js} +0 -0
package/src/utils/ux.js
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
const chalk = require('chalk')
|
|
7
7
|
const figlet = require('figlet')
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const language = (zh, en) => (isCN ? zh : en)
|
|
9
|
+
const local = Intl.DateTimeFormat().resolvedOptions().locale.toUpperCase()
|
|
11
10
|
|
|
12
11
|
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
13
12
|
|
|
@@ -16,17 +15,17 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
|
16
15
|
* 模拟系统引导过程中的动画效果
|
|
17
16
|
* @returns {void}
|
|
18
17
|
*/
|
|
19
|
-
const bootSequence = async version => {
|
|
18
|
+
const bootSequence = async (version) => {
|
|
20
19
|
const lines = [
|
|
21
20
|
chalk.cyan(figlet.textSync('AutoDev', { horizontalLayout: 'full' })),
|
|
22
|
-
chalk.gray('Booting System...'),
|
|
23
|
-
chalk.white('
|
|
24
|
-
chalk.white('
|
|
25
|
-
chalk.white('
|
|
26
|
-
chalk.white('
|
|
27
|
-
chalk.white('
|
|
28
|
-
chalk.white('
|
|
29
|
-
chalk.gray('
|
|
21
|
+
chalk.gray('[BUNKER] Booting System...'),
|
|
22
|
+
chalk.white('[BUNKER] ') + chalk.green('Locale Detection: ') + chalk.cyan(local),
|
|
23
|
+
chalk.white('[BUNKER] ') + chalk.green('YoRHa No.2 Type B Unit: ') + chalk.cyan('Online'),
|
|
24
|
+
chalk.white('[BUNKER] ') + chalk.green('Scanner Type 9S Unit: ') + chalk.cyan('Standby'),
|
|
25
|
+
chalk.white('[BUNKER] ') + chalk.green('Full-Channel Link: ') + chalk.cyan('Established'),
|
|
26
|
+
chalk.white('[BUNKER] ') + chalk.yellow('Construction Protocol: ') + chalk.cyan('v' + version),
|
|
27
|
+
chalk.white('[BUNKER] ') + chalk.magenta('Glory to mankind. (人类荣光永存)'),
|
|
28
|
+
chalk.gray('--------------------------------------------------')
|
|
30
29
|
]
|
|
31
30
|
for (const line of lines) {
|
|
32
31
|
console.log(line)
|
|
@@ -40,7 +39,7 @@ const bootSequence = async version => {
|
|
|
40
39
|
* @param {number} duration - 持续时间(毫秒)
|
|
41
40
|
* @returns {void}
|
|
42
41
|
*/
|
|
43
|
-
const matrixEffect = async (duration = 1500) => {
|
|
42
|
+
const matrixEffect = async (duration = 1500, dialog) => {
|
|
44
43
|
|
|
45
44
|
let currentTotal = 0
|
|
46
45
|
const MIRROR_URL = 'https://cdn.jsdelivr.net/gh/yorha2b-lab/auto-crud-copilot@github-repo-stats/bunker-stats.json'
|
|
@@ -83,17 +82,15 @@ const matrixEffect = async (duration = 1500) => {
|
|
|
83
82
|
const interval = setInterval(() => {
|
|
84
83
|
if (Date.now() > endTime) {
|
|
85
84
|
clearInterval(interval)
|
|
86
|
-
console.log(
|
|
85
|
+
console.log(dialog.bunker.dataSynced)
|
|
87
86
|
if (currentTotal !== 0) {
|
|
88
87
|
if (isLegendary) {
|
|
89
|
-
console.log(chalk.yellow.bold(
|
|
90
|
-
console.log(chalk.yellow(language(' [Bunker] 恭喜指挥官,您的构筑协议已成为人类荣光的一部分。', ' [Bunker] Congratulations, your construction protocol is now part of humanity.')))
|
|
91
|
-
} else {
|
|
92
|
-
console.log(chalk.cyan(language(` [System] 当前构筑总数:${currentTotal}。距离 ${threshold} 勋章还剩 ${threshold - currentTotal} 次。`, ` [System] Current clones: ${currentTotal}. ${threshold - currentTotal} to Achievement.`)))
|
|
88
|
+
console.log(chalk.yellow.bold(dialog.bunker.strategicThreshold(threshold, currentTotal)))
|
|
93
89
|
}
|
|
90
|
+
console.log(chalk.yellow(dialog.bunker.isLegendary(isLegendary, currentTotal, threshold)))
|
|
94
91
|
}
|
|
95
|
-
console.log(chalk.cyan(
|
|
96
|
-
console.log(chalk.cyan(
|
|
92
|
+
console.log(chalk.cyan(dialog.bunker.star))
|
|
93
|
+
console.log(chalk.cyan(dialog.bunker.exit))
|
|
97
94
|
process.exit(0)
|
|
98
95
|
return
|
|
99
96
|
}
|
|
@@ -112,4 +109,4 @@ const matrixEffect = async (duration = 1500) => {
|
|
|
112
109
|
}, 40)
|
|
113
110
|
}
|
|
114
111
|
|
|
115
|
-
module.exports = {
|
|
112
|
+
module.exports = { local, matrixEffect, bootSequence }
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module.exports = () => {
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
const handlersPath = path.join(__dirname, `../handlers`)
|
|
7
|
-
const handlers = fs.readdirSync(handlersPath).map(handler => [path.basename(handler, '.js'), require(path.join(handlersPath, handler))])
|
|
8
|
-
|
|
9
|
-
return Object.fromEntries(handlers)
|
|
10
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module.exports = ({ ux, config, options, copyTemplateDir }) => {
|
|
2
|
-
|
|
3
|
-
const { language } = ux
|
|
4
|
-
const { hbsDir, hooksDir, utilsDir, componentsDir } = config
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
if (hbsDir === '') {
|
|
8
|
-
copyTemplateDir(options, 'hooks', hooksDir)
|
|
9
|
-
copyTemplateDir(options, 'utils', utilsDir)
|
|
10
|
-
copyTemplateDir(options, 'components', componentsDir)
|
|
11
|
-
}
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.error(language('❌ 模板构筑失败:', '❌ Template construction failed:'), error)
|
|
14
|
-
}
|
|
15
|
-
}
|
package/src/bootstrap/prompt.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module.exports = ({ template }) => {
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
const promptsPath = path.join(__dirname, `../framework/${template}/prompts`)
|
|
7
|
-
const prompts = fs.readdirSync(promptsPath).map(prompt => [`${path.basename(prompt, '.js')}Prompt`, require(path.join(promptsPath, prompt))])
|
|
8
|
-
|
|
9
|
-
return Object.fromEntries(prompts)
|
|
10
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
module.exports = async (filePath, liveResponse = null) => {
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const ora = require('ora')
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const chalk = require('chalk')
|
|
7
|
-
|
|
8
|
-
const { ux, llm, core, infrastructure } = require('../bootstrap').get()
|
|
9
|
-
|
|
10
|
-
const { language } = ux
|
|
11
|
-
const { unwrapSignal } = core
|
|
12
|
-
const { config } = infrastructure
|
|
13
|
-
const { alignResponseFields } = llm
|
|
14
|
-
|
|
15
|
-
const { pagesDir } = config
|
|
16
|
-
const startTime = Date.now()
|
|
17
|
-
const fileName = liveResponse?.fileName ?? path.basename(filePath, path.extname(filePath))
|
|
18
|
-
const resourcePath = path.join(process.cwd(), pagesDir, fileName, 'resource.js')
|
|
19
|
-
|
|
20
|
-
const spinner = ora({
|
|
21
|
-
text: chalk.yellow(language(
|
|
22
|
-
`🤖 Pod 153: [侦察] 发现加密数据源 [${fileName}]。正在尝试执行语义对齐协议...\n`,
|
|
23
|
-
`🤖 Pod 153: [Recon] Encrypted data source [${fileName}] detected. Initiating semantic alignment...\n`
|
|
24
|
-
)),
|
|
25
|
-
color: 'yellow'
|
|
26
|
-
}).start()
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
if (!fs.existsSync(resourcePath)) {
|
|
30
|
-
throw new Error(language(
|
|
31
|
-
`🤖 Pod 153: [警告] 地堡数据库中未检索到模块 [${fileName}] 的资源文件。请先执行视觉构筑。`,
|
|
32
|
-
`🤖 Pod 153: [Warning] Module [${fileName}] resource not found in Bunker database. Please execute visual construction first.`
|
|
33
|
-
))
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let rawJson = liveResponse ? liveResponse.data : JSON.parse(fs.readFileSync(filePath, 'utf8'))
|
|
37
|
-
let resourceStr = fs.readFileSync(resourcePath, 'utf8')
|
|
38
|
-
|
|
39
|
-
const coreArray = unwrapSignal(rawJson)
|
|
40
|
-
|
|
41
|
-
if (!coreArray || coreArray.length === 0) {
|
|
42
|
-
console.log(chalk.gray(language(
|
|
43
|
-
` [System] 数据格式非标准 JSON,将尝试原始字符对齐。`,
|
|
44
|
-
` [System] Data format is not standard JSON, will try to align by character.`)
|
|
45
|
-
))
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const sampleData = coreArray && coreArray.length > 0 ? [coreArray[0]] : rawJson
|
|
49
|
-
|
|
50
|
-
spinner.text = chalk.yellow(language(
|
|
51
|
-
`🧑💻 9S: 正在扫描前后端字段差异... 执行语义桥接任务。`,
|
|
52
|
-
`🧑💻 9S: Scanning field differences... Bridging semantic gaps.`
|
|
53
|
-
))
|
|
54
|
-
|
|
55
|
-
const extractKeys = str => {
|
|
56
|
-
const keys = []
|
|
57
|
-
const regex = /(dataIndex|name)\s*:\s*['"]([^'"]+)['"]/g
|
|
58
|
-
let match
|
|
59
|
-
while ((match = regex.exec(str)) !== null) {
|
|
60
|
-
keys.push(match[2])
|
|
61
|
-
}
|
|
62
|
-
return Array.from(new Set(keys))
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const result = await alignResponseFields({ responseStr: JSON.stringify(sampleData), resourceStr: extractKeys(resourceStr).join(',') })
|
|
66
|
-
let changeCount = 0
|
|
67
|
-
const resultMapping = {}
|
|
68
|
-
Object.entries(result).forEach(([oldField, newField]) => {
|
|
69
|
-
if (oldField === newField) return
|
|
70
|
-
const regex = new RegExp(`(dataIndex|name)\\s*:\\s*['"]${oldField}['"]`, 'g')
|
|
71
|
-
resourceStr = resourceStr.replace(regex, `$1: '${newField}'`)
|
|
72
|
-
changeCount++
|
|
73
|
-
resultMapping[oldField] = newField
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
fs.writeFileSync(resourcePath, resourceStr)
|
|
77
|
-
const endTime = Date.now()
|
|
78
|
-
|
|
79
|
-
spinner.succeed(chalk.green(language(
|
|
80
|
-
`🤖 Pod 153: [肯定] 语义桥接协议执行完毕。已物理修正 ${changeCount} 处字段偏差。耗时: ${(endTime - startTime) / 1000}s`,
|
|
81
|
-
`🤖 Pod 153: [Affirmative] Semantic bridge protocol complete. Corrected ${changeCount} field deviations. Elapsed: ${(endTime - startTime) / 1000}s`
|
|
82
|
-
)))
|
|
83
|
-
|
|
84
|
-
if (changeCount > 0) {
|
|
85
|
-
console.log(chalk.magenta(`\n┌────── [ YoRHa Autonomous Backend Alignment ] ──────┐`))
|
|
86
|
-
Object.entries(resultMapping).forEach(([oldField, newField]) => {
|
|
87
|
-
// 💡 物理校准:计算空格数量,让箭头对齐在第 15 个字符位
|
|
88
|
-
// 中文字符长度 * 2 是为了抵消它在终端占的双倍宽度
|
|
89
|
-
const padding = ' '.repeat(Math.max(1, 15 - oldField.length * 2))
|
|
90
|
-
console.log(
|
|
91
|
-
chalk.gray(` │ `) +
|
|
92
|
-
chalk.yellow(oldField) +
|
|
93
|
-
padding +
|
|
94
|
-
chalk.cyan(` -> `) +
|
|
95
|
-
chalk.white(newField)
|
|
96
|
-
)
|
|
97
|
-
})
|
|
98
|
-
console.log(chalk.magenta(`└───────────────────────────────────────────────────────┘\n`))
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (fs.existsSync(filePath)) {
|
|
102
|
-
fs.unlinkSync(filePath)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
} catch (error) {
|
|
106
|
-
spinner.fail(chalk.red(language(
|
|
107
|
-
`🤖 Pod 153: [严重警告] 信号对齐失败。接口数据遭遇强力防火墙:${error}`,
|
|
108
|
-
`🤖 Pod 153: [CRITICAL] Alignment failed. Encountered powerful API firewall: ${error}`
|
|
109
|
-
)))
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
module.exports = async filePath => {
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const ora = require('ora')
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const chalk = require('chalk')
|
|
7
|
-
|
|
8
|
-
const { ux, llm, prompts, generator, infrastructure } = require('../bootstrap').get()
|
|
9
|
-
|
|
10
|
-
const { language } = ux
|
|
11
|
-
const { pagePrompt } = prompts
|
|
12
|
-
const { index, resource } = generator
|
|
13
|
-
const { generateMock, recognizePage } = llm
|
|
14
|
-
const { menus, config, contextStringify } = infrastructure
|
|
15
|
-
|
|
16
|
-
const { useDemo, pagesDir, needMock } = config
|
|
17
|
-
|
|
18
|
-
const startTime = Date.now()
|
|
19
|
-
const fileName = path.basename(filePath, path.extname(filePath))
|
|
20
|
-
const mockDir = path.join(process.cwd(), 'mock')
|
|
21
|
-
const targetDir = path.join(process.cwd(), pagesDir, fileName)
|
|
22
|
-
|
|
23
|
-
const spinner = ora({
|
|
24
|
-
text: chalk.cyan(language(
|
|
25
|
-
`[System] 视觉传感器捕捉完成: [${fileName}]。正在调配地堡资源进行物理构筑...\n`,
|
|
26
|
-
`[System] Visual sensor captured: [${fileName}]. Allocating Bunker resources for physical construction...\n`
|
|
27
|
-
)),
|
|
28
|
-
color: 'cyan'
|
|
29
|
-
}).start()
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
|
|
33
|
-
if (fs.existsSync(targetDir)) {
|
|
34
|
-
spinner.warn(chalk.yellow(language(
|
|
35
|
-
`🤖 Pod 042: [拦截] 模块 [${fileName}] 已存在于地堡数据库中。为了防止数据覆盖,构筑协议已跳过。`,
|
|
36
|
-
`🤖 Pod 042: [Intercept] Module [${fileName}] already exists. Construction skipped to prevent overwrite.`
|
|
37
|
-
)))
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!fs.existsSync(mockDir)) fs.mkdirSync(mockDir, { recursive: true })
|
|
42
|
-
if (!fs.existsSync(targetDir)) fs.mkdirSync(targetDir, { recursive: true })
|
|
43
|
-
|
|
44
|
-
let pageConfig
|
|
45
|
-
if (useDemo) {
|
|
46
|
-
console.log(chalk.yellow(language(
|
|
47
|
-
`\n🤖 Pod 042: [报告] 拦截到实弹请求。正在空投标准模拟包: example.json\n`,
|
|
48
|
-
`\n🤖 Pod 042: [Report] Real-fire request intercepted. Dropping simulation package: example.json\n`
|
|
49
|
-
)))
|
|
50
|
-
pageConfig = require('../../example/example.json')
|
|
51
|
-
} else {
|
|
52
|
-
spinner.text = chalk.cyan(language(
|
|
53
|
-
`🤖 Pod 042: 正在上传视觉元数据至司令部进行语义分析...\n`,
|
|
54
|
-
`🤖 Pod 042: Uploading visual metadata to Command for semantic analysis...\n`
|
|
55
|
-
))
|
|
56
|
-
pageConfig = await recognizePage({ prompt: pagePrompt, filePath })
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
fs.writeFileSync(path.join(targetDir, 'resource.js'), resource({ pageConfig }))
|
|
60
|
-
fs.writeFileSync(path.join(targetDir, 'index.js'), index({ fileName, pageConfig }))
|
|
61
|
-
|
|
62
|
-
if (!menus.find(m => m.key === fileName)) {
|
|
63
|
-
menus.push({ label: fileName, key: fileName })
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (needMock) {
|
|
67
|
-
spinner.text = chalk.yellow(language(
|
|
68
|
-
`🧑💻 9S: 正在突破目标防火墙... 执行数据伪装程序 [${fileName}]`,
|
|
69
|
-
`🧑💻 9S: Piercing target firewall... Executing data camouflage [${fileName}]`
|
|
70
|
-
))
|
|
71
|
-
const rawContent = await generateMock({ columns: pageConfig.table.columns, fileName })
|
|
72
|
-
fs.writeFileSync(path.join(mockDir, `${fileName}.js`), `export default ${contextStringify({ context: rawContent })}`)
|
|
73
|
-
console.log(chalk.green(language(
|
|
74
|
-
`\n[Success] 9S 报告: Mock 数据生成成功`,
|
|
75
|
-
`\n[Success] 9S Report: Mock data generation successful.`
|
|
76
|
-
)))
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const endTime = Date.now()
|
|
80
|
-
spinner.succeed(chalk.green(language(
|
|
81
|
-
`🤖 Pod 042: [报告] 构筑协议执行完毕。模块 [${fileName}] 物理装配达成。耗时: ${(endTime - startTime) / 1000}s`,
|
|
82
|
-
`🤖 Pod 042: [Report] Protocol complete. Physical assembly of [${fileName}] achieved. Elapsed: ${(endTime - startTime) / 1000}s`
|
|
83
|
-
)))
|
|
84
|
-
|
|
85
|
-
if (fs.existsSync(filePath)) {
|
|
86
|
-
fs.unlinkSync(filePath)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
} catch (error) {
|
|
90
|
-
spinner.fail(chalk.red(language(
|
|
91
|
-
`🤖 Pod 042: [警告] 构筑中断。检测到逻辑病毒或连接超时:${error}`,
|
|
92
|
-
`🤖 Pod 042: [Warning] Construction aborted. Logic virus or timeout detected: ${error}`
|
|
93
|
-
)))
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
module.exports = async filePath => {
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const ora = require('ora')
|
|
5
|
-
const chalk = require('chalk')
|
|
6
|
-
|
|
7
|
-
const { ux, llm, core, prompts, infrastructure } = require('../bootstrap').get()
|
|
8
|
-
|
|
9
|
-
const { language } = ux
|
|
10
|
-
const { partPrompt } = prompts
|
|
11
|
-
const { recognizePage } = llm
|
|
12
|
-
const { contextStringify } = infrastructure
|
|
13
|
-
const { cleanCode, formatFormItemAndColumns } = core
|
|
14
|
-
|
|
15
|
-
const startTime = Date.now()
|
|
16
|
-
|
|
17
|
-
const spinner = ora({
|
|
18
|
-
text: chalk.cyan(language(
|
|
19
|
-
`[System] 侦测到局部视觉样本。正在执行“碎片构筑协议”...`,
|
|
20
|
-
`[System] Partial visual sample detected. Executing 'Fragment Construction Protocol'...`
|
|
21
|
-
)),
|
|
22
|
-
color: 'cyan'
|
|
23
|
-
}).start()
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
spinner.text = chalk.cyan(language(
|
|
27
|
-
`🤖 Pod 042: 正在从神经云网络提取 UI 元数据...\n`,
|
|
28
|
-
`🤖 Pod 042: Extracting UI metadata from neural cloud network...\n`
|
|
29
|
-
))
|
|
30
|
-
|
|
31
|
-
const pageConfig = await recognizePage({ prompt: partPrompt, filePath, taskType: 'part' })
|
|
32
|
-
|
|
33
|
-
const { formItems, dictBlocks, processedColumns } = formatFormItemAndColumns({ pageConfig })
|
|
34
|
-
|
|
35
|
-
const result = Object.fromEntries(Object.entries({ formItems, processedColumns }).filter(([key, value]) => value?.length > 0))
|
|
36
|
-
|
|
37
|
-
let mainConfigStr = cleanCode(contextStringify({ context: result }))
|
|
38
|
-
|
|
39
|
-
let optionsCodeStr = ''
|
|
40
|
-
dictBlocks.forEach(key => {
|
|
41
|
-
const optionsArray = pageConfig.optionDict?.[key] ?? []
|
|
42
|
-
const arrayItemsStr = optionsArray.map(opt => ` { label: '${opt.label}', value: '${opt.value}' }`).join(',\n')
|
|
43
|
-
optionsCodeStr += `\nexport const ${key} = [\n${arrayItemsStr}\n]\n`
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const finalResult = `${mainConfigStr}\n${optionsCodeStr}`
|
|
47
|
-
const endTime = Date.now()
|
|
48
|
-
|
|
49
|
-
spinner.stop()
|
|
50
|
-
|
|
51
|
-
console.log(chalk.magenta(`\n┌────────────────── [ YoRHa Construction Output ] ──────────────────┐`))
|
|
52
|
-
console.log(chalk.gray(`│ Source: ${filePath}`))
|
|
53
|
-
console.log(chalk.gray(`│ Protocol: Partial UI Fragment | Status: SUCCESS`))
|
|
54
|
-
console.log(chalk.magenta(`├────────────────────────────────────────────────────────────────────┘`))
|
|
55
|
-
console.log(chalk.white(finalResult))
|
|
56
|
-
console.log(chalk.magenta(`┌────────────────────────────────────────────────────────────────────┐`))
|
|
57
|
-
console.log(chalk.green(language(
|
|
58
|
-
`│ 🤖 Pod 042 报告:局部构筑达成。耗时: ${(endTime - startTime) / 1000}s`,
|
|
59
|
-
`│ 🤖 Pod 042 Report: Partial construction achieved. Elapsed: ${(endTime - startTime) / 1000}s`
|
|
60
|
-
)))
|
|
61
|
-
console.log(chalk.green(language(
|
|
62
|
-
`│ 命令:请手动将上述代码块物理装配至您的目标文件中。`,
|
|
63
|
-
`│ Command: Please manually assemble the above code block into your target file.`
|
|
64
|
-
)))
|
|
65
|
-
console.log(chalk.magenta(`└───────────────────────────────────────────────────────────────────┘\n`))
|
|
66
|
-
|
|
67
|
-
if (fs.existsSync(filePath)) {
|
|
68
|
-
fs.unlinkSync(filePath)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
} catch (error) {
|
|
72
|
-
spinner.fail(chalk.red(language(
|
|
73
|
-
`🤖 Pod 042: [警告] 碎片构筑失败。系统检测到逻辑干扰:${error}`,
|
|
74
|
-
`🤖 Pod 042: [Warning] Fragment construction failed. Logic interference detected: ${error}`
|
|
75
|
-
)))
|
|
76
|
-
}
|
|
77
|
-
}
|
|
File without changes
|