dsh-windows-tray 1.0.5 → 1.0.6
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/launcher/dsh-lib.ps1 +1 -1
- package/launcher/dsh-update.ps1 +9 -4
- package/package.json +1 -1
package/launcher/dsh-lib.ps1
CHANGED
|
@@ -12,7 +12,7 @@ $URL = "http://127.0.0.1:$PORT"
|
|
|
12
12
|
$LOG_DIR = "$env:USERPROFILE\.dsh\logs"
|
|
13
13
|
$WT = "$env:LOCALAPPDATA\Microsoft\WindowsApps\wt.exe"
|
|
14
14
|
$PWSH = 'D:\Program Files (x86)\PowerShell-7.6.4\pwsh.exe'
|
|
15
|
-
$TRAY_VERSION = '1.0.
|
|
15
|
+
$TRAY_VERSION = '1.0.6' # 托盘版本 (与 npm 包版本同步, 用于日志/排查)
|
|
16
16
|
$TRAY_PKG = 'dsh-windows-tray' # npm 包名 (托盘自更新)
|
|
17
17
|
$TRAY_SCRIPT = Join-Path $PSScriptRoot 'dsh-tray.ps1'
|
|
18
18
|
|
package/launcher/dsh-update.ps1
CHANGED
|
@@ -28,6 +28,8 @@ function Find-NpmCmd {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
# 隐藏执行 cmd /c (CreateNoWindow: 不弹黑窗), 可选超时
|
|
31
|
+
# ⚠️ 调用必须空格分隔传参 (Run-HiddenCmd $cmd $timeout)——写成 ('cmd', timeout) 会把
|
|
32
|
+
# 两者绑成数组并入命令行, 超时值被当成包名/脚本参数 (1.0.5 及以前自更新因此从未成功过)
|
|
31
33
|
function Run-HiddenCmd([string]$cmdLine, [int]$timeoutMs = 0) {
|
|
32
34
|
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
|
33
35
|
$psi.FileName = $env:ComSpec
|
|
@@ -71,7 +73,8 @@ if (-not $npm) {
|
|
|
71
73
|
# 1) 安装最新包 (全局; 输出落盘, 失败可查因 — 旧版 2>nul 黑洞)
|
|
72
74
|
$npmLog = Join-Path $LOG_DIR 'dsh-update-npm.log'
|
|
73
75
|
Remove-Item $npmLog -Force -ErrorAction SilentlyContinue
|
|
74
|
-
$
|
|
76
|
+
$installCmd = '/c ""' + $npm + '" install -g ' + $TRAY_PKG + ' >> "' + $npmLog + '" 2>&1 "'
|
|
77
|
+
$code = Run-HiddenCmd $installCmd 180000
|
|
75
78
|
if ($code -ne 0) {
|
|
76
79
|
Log "自更新失败: npm install 退出码 $code (输出: $npmLog)"
|
|
77
80
|
Get-Content $npmLog -Tail 5 -ErrorAction SilentlyContinue | ForEach-Object { Log " npm> $_" }
|
|
@@ -83,7 +86,8 @@ Log 'npm install -g 完成'
|
|
|
83
86
|
# 2) 定位新包根目录
|
|
84
87
|
$rootTmp = Join-Path $LOG_DIR 'tray-npm-root.txt'
|
|
85
88
|
Remove-Item $rootTmp -Force -ErrorAction SilentlyContinue
|
|
86
|
-
|
|
89
|
+
$rootCmd = '/c ""' + $npm + '" root -g > "' + $rootTmp + '" 2>nul "'
|
|
90
|
+
Run-HiddenCmd $rootCmd | Out-Null
|
|
87
91
|
$globalRoot = ''
|
|
88
92
|
if (Test-Path $rootTmp) {
|
|
89
93
|
$globalRoot = (Get-Content $rootTmp -Raw).Trim()
|
|
@@ -101,12 +105,13 @@ if (-not (Test-Path $newInstall)) {
|
|
|
101
105
|
$dshRoot = Split-Path $DSH_CMD -Parent
|
|
102
106
|
$deployLog = Join-Path $LOG_DIR 'dsh-update-deploy.log'
|
|
103
107
|
Remove-Item $deployLog -Force -ErrorAction SilentlyContinue
|
|
104
|
-
$
|
|
108
|
+
$deployCmd = '/c ""' + $PWSH + '" -NoProfile -ExecutionPolicy Bypass -File "' + $newInstall + '" -Auto -NoTrayStart' +
|
|
105
109
|
' -DshRoot "' + $dshRoot + '"' +
|
|
106
110
|
' -Port ' + $PORT +
|
|
107
111
|
' -NodePath "' + $NODE + '"' +
|
|
108
112
|
' -PwshPath "' + $PWSH + '"' +
|
|
109
|
-
' >> "' + $deployLog + '" 2>&1 "'
|
|
113
|
+
' >> "' + $deployLog + '" 2>&1 "'
|
|
114
|
+
$code = Run-HiddenCmd $deployCmd 120000
|
|
110
115
|
if ($code -ne 0) {
|
|
111
116
|
Log "自更新失败: install.ps1 退出码 $code (输出: $deployLog)"
|
|
112
117
|
Get-Content $deployLog -Tail 5 -ErrorAction SilentlyContinue | ForEach-Object { Log " deploy> $_" }
|