dsh-windows-tray 1.0.4 → 1.0.5
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/install.ps1 +16 -0
- package/launcher/dsh-lib.ps1 +1 -1
- package/launcher/dsh-update.ps1 +22 -6
- package/package.json +1 -1
package/install.ps1
CHANGED
|
@@ -56,6 +56,22 @@ if (-not $DshRoot) {
|
|
|
56
56
|
(Join-Path $env:USERPROFILE 'dsh'),
|
|
57
57
|
(Join-Path $env:LOCALAPPDATA 'dsh')
|
|
58
58
|
)
|
|
59
|
+
# v1.0.5: 从运行中 node 进程命令行提取 bin.js 参数路径, 截断到 \node_modules\ 之前
|
|
60
|
+
# (自定义安装位置的机器: "<根>\node_modules\...\bin.js"; 候选一律经 Test-Path dsh.cmd 验证)
|
|
61
|
+
Get-CimInstance Win32_Process -Filter "Name='node.exe'" -ErrorAction SilentlyContinue |
|
|
62
|
+
ForEach-Object {
|
|
63
|
+
$binJs = $null
|
|
64
|
+
if ($_.CommandLine -match '"([^"]+bin\.js)"') { $binJs = $Matches[1] }
|
|
65
|
+
elseif ($_.CommandLine -match '(\S+bin\.js)') { $binJs = $Matches[1] }
|
|
66
|
+
if ($binJs) {
|
|
67
|
+
$idx = $binJs.IndexOf('\node_modules\')
|
|
68
|
+
if ($idx -lt 0) { $idx = $binJs.IndexOf('/node_modules/') }
|
|
69
|
+
if ($idx -gt 0) { $candidates += $binJs.Substring(0, $idx) }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
# v1.0.5: dsh.cmd 在 PATH 上 (Get-Command 返回的是文件全路径, 取其目录)
|
|
73
|
+
$onPath = Get-Command dsh.cmd -ErrorAction SilentlyContinue
|
|
74
|
+
if ($onPath) { $candidates += Split-Path $onPath.Source -Parent }
|
|
59
75
|
foreach ($c in $candidates) {
|
|
60
76
|
$c = [System.IO.Path]::GetFullPath($c)
|
|
61
77
|
if (Test-Path (Join-Path $c 'dsh.cmd')) { $DshRoot = $c; break }
|
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.5' # 托盘版本 (与 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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# dsh-update.ps1 —— 托盘自更新执行器 (由托盘菜单「更新到最新版」触发, 独立隐藏进程)
|
|
2
2
|
# 流程: npm install -g 最新包 -> 运行新包 install.ps1 (重新部署+改写路径+快捷方式) -> 杀旧托盘 -> 起新托盘
|
|
3
3
|
# 失败时旧托盘不受影响 (旧托盘在最后一步才被终止)
|
|
4
|
+
# v1.0.5: 步骤输出落盘 (dsh-update-npm.log / dsh-update-deploy.log, 失败时尾部进 actions log —
|
|
5
|
+
# 旧版 2>nul 吞报错, 日志只剩退出码无从排查); install.ps1 显式传本机适配值
|
|
6
|
+
# (-DshRoot/-Port/-NodePath/-PwshPath 取自点源的 dsh-lib, 自定义安装位置不再依赖探测)
|
|
4
7
|
param(
|
|
5
8
|
[int]$OldPid = 0
|
|
6
9
|
)
|
|
@@ -65,10 +68,13 @@ if (-not $npm) {
|
|
|
65
68
|
exit 1
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
# 1) 安装最新包 (
|
|
69
|
-
$
|
|
71
|
+
# 1) 安装最新包 (全局; 输出落盘, 失败可查因 — 旧版 2>nul 黑洞)
|
|
72
|
+
$npmLog = Join-Path $LOG_DIR 'dsh-update-npm.log'
|
|
73
|
+
Remove-Item $npmLog -Force -ErrorAction SilentlyContinue
|
|
74
|
+
$code = Run-HiddenCmd ('/c ""' + $npm + '" install -g ' + $TRAY_PKG + ' >> "' + $npmLog + '" 2>&1 "', 180000)
|
|
70
75
|
if ($code -ne 0) {
|
|
71
|
-
Log "自更新失败: npm install 退出码 $code"
|
|
76
|
+
Log "自更新失败: npm install 退出码 $code (输出: $npmLog)"
|
|
77
|
+
Get-Content $npmLog -Tail 5 -ErrorAction SilentlyContinue | ForEach-Object { Log " npm> $_" }
|
|
72
78
|
Show-Balloon '自更新失败:npm install 出错,详见日志' 'Error'
|
|
73
79
|
exit 1
|
|
74
80
|
}
|
|
@@ -90,10 +96,20 @@ if (-not (Test-Path $newInstall)) {
|
|
|
90
96
|
exit 1
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
# 3) 运行新包 install.ps1 (重新部署 +
|
|
94
|
-
|
|
99
|
+
# 3) 运行新包 install.ps1 (重新部署 + 快捷方式, 不启动托盘; -Auto=隐藏窗口非交互)
|
|
100
|
+
# v1.0.5: 显式传本机适配值 (取自点源的 dsh-lib, install 不必重新探测; 自定义安装位置必需)
|
|
101
|
+
$dshRoot = Split-Path $DSH_CMD -Parent
|
|
102
|
+
$deployLog = Join-Path $LOG_DIR 'dsh-update-deploy.log'
|
|
103
|
+
Remove-Item $deployLog -Force -ErrorAction SilentlyContinue
|
|
104
|
+
$code = Run-HiddenCmd ('/c ""' + $PWSH + '" -NoProfile -ExecutionPolicy Bypass -File "' + $newInstall + '" -Auto -NoTrayStart' +
|
|
105
|
+
' -DshRoot "' + $dshRoot + '"' +
|
|
106
|
+
' -Port ' + $PORT +
|
|
107
|
+
' -NodePath "' + $NODE + '"' +
|
|
108
|
+
' -PwshPath "' + $PWSH + '"' +
|
|
109
|
+
' >> "' + $deployLog + '" 2>&1 "', 120000)
|
|
95
110
|
if ($code -ne 0) {
|
|
96
|
-
Log "自更新失败: install.ps1 退出码 $code"
|
|
111
|
+
Log "自更新失败: install.ps1 退出码 $code (输出: $deployLog)"
|
|
112
|
+
Get-Content $deployLog -Tail 5 -ErrorAction SilentlyContinue | ForEach-Object { Log " deploy> $_" }
|
|
97
113
|
Show-Balloon '自更新失败:部署出错,详见日志' 'Error'
|
|
98
114
|
exit 1
|
|
99
115
|
}
|