@gehennawu/dsh-service 0.13.0 → 0.13.1

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.
Files changed (3) hide show
  1. package/client.js +11 -3
  2. package/index.js +11 -2
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -118,6 +118,7 @@ window.__ModuleLoader__.load({
118
118
  'update.upgrade': '升级插件',
119
119
  'update.upgrading': '升级中…',
120
120
  'update.upgradeError': '插件升级失败',
121
+ 'update.upgradeErrorDetail': '插件升级失败({detail})',
121
122
  'update.upgradeSuccess': '升级成功,服务重启中…',
122
123
  'restart.title': '服务重启',
123
124
  'restart.description': '重启 dsh web 进程。运行中的工作会中断,持久化会话可恢复。也可在对话中输入 /restart。',
@@ -303,6 +304,7 @@ window.__ModuleLoader__.load({
303
304
  'update.upgrade': 'Upgrade plugin',
304
305
  'update.upgrading': 'Upgrading…',
305
306
  'update.upgradeError': 'Plugin upgrade failed',
307
+ 'update.upgradeErrorDetail': 'Plugin upgrade failed ({detail})',
306
308
  'update.upgradeSuccess': 'Upgrade successful, restarting…',
307
309
  'restart.title': 'Service restart',
308
310
  'restart.description': 'Restart the dsh web process. Active work will be interrupted; persisted sessions can be resumed. You can also type /restart in a conversation.',
@@ -918,12 +920,18 @@ window.__ModuleLoader__.load({
918
920
  const versionRes = await ctx.connection.rpc.call('/dsh-service', 'version', {})
919
921
  const previousInstanceId = versionRes && versionRes.ok ? versionRes.value.instanceId : undefined
920
922
  const res = await ctx.connection.rpc.call('/dsh-service', 'upgrade', {})
921
- if (!res || res.ok === false) throw new Error('upgrade failed')
923
+ // 宿主错误详情(如 npm-failed: …、npm was not found on PATH)随通用文案透出,便于排查。
924
+ if (!res || res.ok === false) {
925
+ const detail = res && typeof res.error === 'string' ? res.error.trim() : ''
926
+ throw new Error(detail || 'upgrade failed')
927
+ }
922
928
  if (typeof previousInstanceId === 'string' && previousInstanceId.length > 0) {
923
929
  startRecovery(previousInstanceId).catch(() => {})
924
930
  }
925
- } catch (_) {
926
- setUpgradeError(translate('update.upgradeError'))
931
+ } catch (err) {
932
+ const detail = err instanceof Error && typeof err.message === 'string' && err.message !== 'upgrade failed' ? err.message.trim() : ''
933
+ console.error('dsh-service: upgrade failed', detail || err)
934
+ setUpgradeError(detail ? translate('update.upgradeErrorDetail', { detail }) : translate('update.upgradeError'))
927
935
  } finally {
928
936
  setUpgradeBusy(false)
929
937
  }
package/index.js CHANGED
@@ -666,9 +666,18 @@ async function runFixedCommand(ctx, argv) {
666
666
  const subprocess = ctx.get('subprocess')
667
667
  if (subprocess === undefined) throw new Error('subprocess-unavailable')
668
668
  const executable = await subprocess.resolveExecutable(argv[0])
669
+ let spawnArgv = [executable, ...argv.slice(1)]
670
+ // Windows 上白名单命令(如 npm)经 PATHEXT 解析为 .cmd/.bat 脚本;subprocess 服务的
671
+ // spawn 不带 shell,Node 对 .cmd/.bat 一律抛 EINVAL,无法直接执行。固定包一层
672
+ // cmd.exe /d /s /c + 已解析的绝对路径,全部参数仍是宿主白名单常量,无输入拼接。
673
+ if (process.platform === 'win32' && /\.(cmd|bat)$/i.test(executable)) {
674
+ const shell = await subprocess.resolveExecutable('cmd.exe')
675
+ spawnArgv = [shell, '/d', '/s', '/c', executable, ...argv.slice(1)]
676
+ }
669
677
  const handle = subprocess.spawn({
670
- argv: [executable, ...argv.slice(1)],
671
- cwd: '/',
678
+ argv: spawnArgv,
679
+ // '/' 不是合法的 Windows 目录路径;固定改用系统目录,POSIX 保持根目录。
680
+ cwd: process.platform === 'win32' ? (process.env.SystemRoot || 'C:\\Windows') : '/',
672
681
  stdio: {
673
682
  stdin: 'ignore',
674
683
  stdout: { maxBytes: 16 * 1024 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gehennawu/dsh-service",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "DSH Web 自托管运维面板:安全重启、健康监控、备份和 Linux 权限维护。",
5
5
  "type": "module",
6
6
  "scripts": {