@icyfenix-dmla/cli 2026.6.11-1919 → 2026.6.11-2001
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/package.json +1 -1
- package/src/commands/update.js +38 -6
- package/src/server/native_env_check.js +5 -1
- package/version.json +2 -2
package/package.json
CHANGED
package/src/commands/update.js
CHANGED
|
@@ -8,6 +8,16 @@ import path from 'path'
|
|
|
8
8
|
import { fileURLToPath } from 'url'
|
|
9
9
|
import fs from 'fs'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* 获取当前包的版本号
|
|
13
|
+
*/
|
|
14
|
+
function getCurrentVersion() {
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
16
|
+
const __dirname = path.dirname(__filename)
|
|
17
|
+
const pkgPath = path.resolve(__dirname, '../package.json')
|
|
18
|
+
return JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
/**
|
|
12
22
|
* 运行 update 命令
|
|
13
23
|
*/
|
|
@@ -15,6 +25,15 @@ export async function runUpdate() {
|
|
|
15
25
|
console.log(chalk.blue('更新 DMLA...'))
|
|
16
26
|
console.log()
|
|
17
27
|
|
|
28
|
+
// 在 npm update 之前读取当前版本(更新后旧文件可能被删除导致读取失败)
|
|
29
|
+
let oldVersion
|
|
30
|
+
try {
|
|
31
|
+
oldVersion = getCurrentVersion()
|
|
32
|
+
console.log(chalk.gray(`当前版本: ${oldVersion}`))
|
|
33
|
+
} catch {
|
|
34
|
+
// 读取失败时继续执行更新
|
|
35
|
+
}
|
|
36
|
+
|
|
18
37
|
try {
|
|
19
38
|
// 直接执行 npm 更新
|
|
20
39
|
console.log(chalk.cyan('正在从 npm 更新...'))
|
|
@@ -26,12 +45,25 @@ export async function runUpdate() {
|
|
|
26
45
|
console.log()
|
|
27
46
|
console.log(chalk.green('✓ 更新完成'))
|
|
28
47
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
// 尝试读取更新后的版本号
|
|
49
|
+
// npm update 可能删除了当前进程的旧文件,需要用 npm list 获取新版本
|
|
50
|
+
try {
|
|
51
|
+
const newVersion = execSync('npm list -g @icyfenix-dmla/cli --depth=0 --json', {
|
|
52
|
+
encoding: 'utf-8'
|
|
53
|
+
})
|
|
54
|
+
const parsed = JSON.parse(newVersion)
|
|
55
|
+
const version = parsed?.dependencies?.['@icyfenix-dmla/cli']?.version
|
|
56
|
+
if (version) {
|
|
57
|
+
console.log(chalk.cyan(`更新后版本: ${version}`))
|
|
58
|
+
if (oldVersion && version !== oldVersion) {
|
|
59
|
+
console.log(chalk.green(`${oldVersion} → ${version}`))
|
|
60
|
+
} else if (oldVersion && version === oldVersion) {
|
|
61
|
+
console.log(chalk.gray('已是最新版本'))
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
// npm list 读取失败时静默跳过,不影响更新结果
|
|
66
|
+
}
|
|
35
67
|
|
|
36
68
|
// 提示用户更新 Docker 镜像(可选)
|
|
37
69
|
console.log()
|
package/version.json
CHANGED