@yorha2b-lab/autodev 2.0.2 → 2.0.4

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
@@ -2,20 +2,11 @@
2
2
  const fs = require('fs')
3
3
  const path = require('path')
4
4
  const chalk = require('chalk')
5
- const figlet = require('figlet')
6
5
  const { program } = require('commander')
7
6
  const pkg = require(path.join(__dirname, '../package.json'))
8
- const { language } = require(path.join(__dirname, '../src/utils/utils.js'))
7
+ const { language, matrixEffect, bootSequence } = require(path.join(__dirname, '../src/utils/utils.js'))
9
8
 
10
- console.log(chalk.cyan(figlet.textSync('AutoDev', { horizontalLayout: 'full' })))
11
- console.log(chalk.gray('Booting System...'))
12
- console.log(chalk.white(' [System] ') + chalk.green('Locale Detection: ') + chalk.cyan(language('ZH-CN', 'EN-US')))
13
- console.log(chalk.white(' [System] ') + chalk.green('YoRHa No.2 Type B Unit: ') + chalk.cyan('Online'))
14
- console.log(chalk.white(' [System] ') + chalk.green('Scanner Type 9S Unit: ') + chalk.cyan('Standby'))
15
- console.log(chalk.white(' [System] ') + chalk.green('Full-Channel Link: ') + chalk.cyan('Established')) // 2.0 新增
16
- console.log(chalk.white(' [Mission] ') + chalk.yellow('Bunker Construction Protocol: ') + chalk.cyan('v' + pkg.version))
17
- console.log(chalk.white(' [Bunker] ') + chalk.magenta('Glory to mankind. (人类荣光永存)'))
18
- console.log(chalk.gray('--------------------------------------------------\n'))
9
+ bootSequence(pkg.version)
19
10
 
20
11
  program
21
12
  .version(pkg.version)
@@ -67,16 +58,8 @@ program
67
58
  process.on('SIGINT', () => {
68
59
  console.log('\n')
69
60
  console.log(chalk.gray('--------------------------------------------------'))
70
- console.log(chalk.white(' [System] ') + chalk.yellow(language('正在断开神经云链接...', 'Disconnecting Neural Link...')))
71
- console.log(chalk.white(' [System] ') + chalk.green(language('所有构筑数据已同步至 Bunker 存储节点。', 'All data synced to Bunker storage nodes.')))
72
- setTimeout(() => {
73
- console.log(chalk.cyan(language(
74
- '📡 Operator 6O: 辛苦了,2B!地堡系统已进入待机状态,愿人类荣光永存。',
75
- '📡 Operator 6O: Well done, 2B! Bunker system is in standby. Glory to mankind.'
76
- )))
77
- console.log(chalk.gray(' [Bunker] ') + chalk.white('Signal Lost... Bye.\n'))
78
- process.exit(0)
79
- }, 500)
61
+ console.log(chalk.white(' [System] ') + chalk.yellow(language('正在断开神经云链接,执行数据物理封存...', 'Disconnecting Neural Link, Executing Physical Assembly...')))
62
+ matrixEffect(1500)
80
63
  })
81
64
  })
82
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "基于视觉大模型的前端(react+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -1,9 +1,13 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
+ const chalk = require('chalk')
4
+ const figlet = require('figlet')
3
5
 
4
6
  const isCN = Intl.DateTimeFormat().resolvedOptions().locale.includes('zh')
5
7
  const language = (zh, en) => (isCN ? zh : en)
6
8
 
9
+ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
10
+
7
11
  /**
8
12
  * 获取项目配置信息
9
13
  * 优先读取项目根目录的 config.js,如果不存在则使用默认配置
@@ -40,6 +44,75 @@ const cleanCode = str => {
40
44
  .trim() + '\n'
41
45
  }
42
46
 
47
+ /**
48
+ * 引导序列
49
+ * 模拟系统引导过程中的动画效果
50
+ * @returns {void}
51
+ */
52
+ const bootSequence = async version => {
53
+ const lines = [
54
+ chalk.cyan(figlet.textSync('AutoDev', { horizontalLayout: 'full' })),
55
+ chalk.gray('Booting System...'),
56
+ chalk.white(' [System] ') + chalk.green('Locale Detection: ') + chalk.cyan(language('ZH-CN', 'EN-US')),
57
+ chalk.white(' [System] ') + chalk.green('YoRHa No.2 Type B Unit: ') + chalk.cyan('Online'),
58
+ chalk.white(' [System] ') + chalk.green('Scanner Type 9S Unit: ') + chalk.cyan('Standby'),
59
+ chalk.white(' [System] ') + chalk.green('Full-Channel Link: ') + chalk.cyan('Established'),
60
+ chalk.white(' [Mission] ') + chalk.yellow('Bunker Construction Protocol: ') + chalk.cyan('v' + version),
61
+ chalk.white(' [Bunker] ') + chalk.magenta('Glory to mankind. (人类荣光永存)'),
62
+ chalk.gray('--------------------------------------------------\n')
63
+ ]
64
+ for (const line of lines) {
65
+ console.log(line)
66
+ await sleep(line.includes('AutoDev') ? 300 : 80)
67
+ }
68
+ }
69
+
70
+ /**
71
+ * 矩阵效果
72
+ * 模拟数据物理封存过程中的矩阵效果
73
+ * @param {number} duration - 持续时间(毫秒)
74
+ * @returns {void}
75
+ */
76
+ const matrixEffect = (duration = 1500) => {
77
+
78
+ const coreFragments = [
79
+ '47 4c 4f 52 59', // GLORY
80
+ '54 4f 20 4d 41', // TO MA
81
+ '4e 4b 49 4e 44', // NKIND
82
+ '59 6f 52 48 61', // YoRHa
83
+ '32 42 2d 55 6e', // 2B-Un
84
+ '69 74 20 4f 4b', // it OK
85
+ '39 53 2d 48 61', // 9S-Ha
86
+ '63 6b 69 6e 67', // cking
87
+ '5f 43 4f 44 45 5f' // _CODE_
88
+ ]
89
+
90
+ const width = process.stdout.columns || 80
91
+ const endTime = Date.now() + duration
92
+
93
+ const interval = setInterval(() => {
94
+ if (Date.now() > endTime) {
95
+ clearInterval(interval)
96
+ console.log(chalk.white(' [System] ') + chalk.green(language('所有构筑数据已同步至 Bunker 存储节点。', 'All data synced to Bunker storage nodes.')))
97
+ console.log(chalk.cyan('\n[System] Signal Lost. Glory to Mankind.\n'))
98
+ process.exit(0)
99
+ return
100
+ }
101
+ let line = ''
102
+ while (line.length < width) {
103
+ if (Math.random() > 0.8) {
104
+ const frag = coreFragments[Math.floor(Math.random() * coreFragments.length)]
105
+ line += chalk.white.bold(frag) + ' '
106
+ } else {
107
+ const hex = Math.floor(Math.random() * 256).toString(16).padStart(2, '0').toUpperCase()
108
+ const color = Math.random() > 0.5 ? chalk.cyan : chalk.cyan.dim
109
+ line += color(hex) + ' '
110
+ }
111
+ }
112
+ process.stdout.write(line.substring(0, width * 10) + '\n')
113
+ }, 40)
114
+ }
115
+
43
116
  /**
44
117
  * 获取已有的页面菜单配置
45
118
  * @param {string} dir - 页面目录路径(默认 'src/pages')
@@ -104,4 +177,4 @@ const copyTemplateDir = (options, templateSubDir, targetSubDir) => {
104
177
  })
105
178
  }
106
179
 
107
- module.exports = { language, getConfig, cleanCode, getExistingMenus, copyTemplateDir, generateSmartImports }
180
+ module.exports = { language, getConfig, cleanCode, matrixEffect, bootSequence, getExistingMenus, copyTemplateDir, generateSmartImports }