dsh-aupdate 0.6.8 → 0.6.9

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/README.md CHANGED
@@ -176,6 +176,8 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
176
176
  - 打开「自动刷新」后每 5 秒拉一次,正在排查时开着;关掉就完全不动
177
177
  - 读之前会先把待写队列刷下去,所以刚点完检查,那几行马上就在里面
178
178
  - 时间戳按本地时区显示,文件超过 1MB 轮转给一句提示,另附总行数
179
+ - 安装阶段逐条写「正在安装第 N/M 个:<包名>」,某个包超过 2 分钟还没结束会再写一条
180
+ 明确的超时提示——网络重试时 pnpm 把 WARN 攒到结束才吐,中途得有个「还在跑」的锚点
179
181
 
180
182
  日志只经由 `GET /api/dsh-aupdate/logs?lines=N` 读,参数夹在 1 到 1000 之间,
181
183
  不提供写入口——面板能看,但改不了日志。
@@ -440,7 +442,11 @@ while the log and settings page keep recording.
440
442
  live in `~/.dsh/aupdate-settings.json`.
441
443
 
442
444
  The page renders the log newest first, so whatever just happened is at the top of the
443
- box instead of at the bottom of a scroll.
445
+ box instead of at the bottom of a scroll. During installation it writes "Installing N/M:
446
+ <name>" for each package and, past two minutes on any one package, an explicit slow-install
447
+ notice — pnpm buffers network warnings until the command ends, so there needs to be an
448
+ anchor in the meantime. The Last run card polls /state every two seconds while a cycle is
449
+ active and shows the same progress live.
444
450
 
445
451
  Log lines are stored as an event code plus its arguments, not as finished sentences, so
446
452
  switching **Display language** re-renders history too. Lines written before 0.6.2 are
package/client.js CHANGED
@@ -21,6 +21,9 @@ window.__ModuleLoader__.load({
21
21
  failed: '保存失败',
22
22
  runNow: '立刻检查',
23
23
  running: '正在检查…',
24
+ progressCheck: '正在检查更新…',
25
+ progressInstall: '正在安装第 {n}/{m} 个:{name}',
26
+ progressApply: '正在就地生效…',
24
27
  runDone: '检查完成',
25
28
  runFailed: '检查没能完成',
26
29
  lastRun: '上一次',
@@ -137,6 +140,9 @@ window.__ModuleLoader__.load({
137
140
  failed: 'Save failed',
138
141
  runNow: 'Check now',
139
142
  running: 'Checking…',
143
+ progressCheck: 'Checking for updates…',
144
+ progressInstall: 'Installing {n}/{m}: {name}',
145
+ progressApply: 'Applying in place…',
140
146
  runDone: 'Check finished',
141
147
  runFailed: 'Check could not finish',
142
148
  lastRun: 'Last run',
@@ -646,6 +652,8 @@ window.__ModuleLoader__.load({
646
652
  const [phase, setPhase] = useState('loading') // loading | ready | error
647
653
  const [saveHint, setSaveHint] = useState('')
648
654
  const [running, setRunning] = useState(false)
655
+ // 安装可能耗好几分钟(网络重试时更久),运行按钮旁边显示实时进度。
656
+ const [progress, setProgress] = useState(null)
649
657
  const [runHint, setRunHint] = useState('')
650
658
  const [rolling, setRolling] = useState('')
651
659
  const [rollHint, setRollHint] = useState('')
@@ -726,12 +734,37 @@ window.__ModuleLoader__.load({
726
734
  }, [])
727
735
 
728
736
 
737
+ /** 把后端进度翻成一行中文/英文;没进度就退回普通「正在检查」。 */
738
+ const runningText = (() => {
739
+ if (!running) return ''
740
+ if (progress?.phase === 'installing' && progress.total > 0) {
741
+ return T.progressInstall
742
+ .replace('{n}', String(progress.index))
743
+ .replace('{m}', String(progress.total))
744
+ .replace('{name}', String(progress.name || ''))
745
+ }
746
+ if (progress?.phase === 'applying') return T.progressApply
747
+ if (progress?.phase === 'checking') return T.progressCheck
748
+ return T.running
749
+ })()
750
+
729
751
  const fire = useCallback(async () => {
730
752
  if (running) return
731
753
  setRunning(true)
732
754
  setRunHint(T.running)
755
+ setProgress(null)
733
756
  try {
734
- const result = await runNow('update')
757
+ // 点完立刻先读一次进度(后端可能已经在跑),之后每 2 秒跟一次。
758
+ const poll = async () => {
759
+ try {
760
+ setProgress((await getState(LANG))?.progress ?? null)
761
+ } catch {}
762
+ }
763
+ void poll()
764
+ const timer = setInterval(() => { void poll() }, 2000)
765
+ const result = await (async () => {
766
+ try { return await runNow('update') } finally { clearInterval(timer) }
767
+ })()
735
768
  if (result?.started === false) {
736
769
  setRunHint(result.reason || T.runFailed)
737
770
  } else {
@@ -747,6 +780,7 @@ window.__ModuleLoader__.load({
747
780
  setRunHint(T.runFailed)
748
781
  } finally {
749
782
  setRunning(false)
783
+ setProgress(null)
750
784
  }
751
785
  }, [running])
752
786
 
@@ -926,6 +960,10 @@ window.__ModuleLoader__.load({
926
960
  h('span', { style: S.label }, T.lastRun),
927
961
  h('button', { type: 'button', style: S.btn, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
928
962
  ),
963
+ // 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
964
+ running && progress
965
+ ? h('span', { style: { ...S.status, color: '#4c9aff', fontWeight: 500 } }, runningText)
966
+ : null,
929
967
  last === null || last === undefined
930
968
  ? h('span', { style: S.status }, T.never)
931
969
  : h('div', { style: S.meta },
package/index.js CHANGED
@@ -23,6 +23,8 @@ const LOG_MAX_BYTES = 1_000_000
23
23
  const FETCH_CONCURRENCY = 6
24
24
  /** 单个包安装的上限;实测最慢 1m51s。 */
25
25
  const INSTALL_TIMEOUT_MS = 420_000
26
+ /** 超过这个时长就写一条明确提示:别让人把网络重试误当成卡死。 */
27
+ const INSTALL_SLOW_MS = 120_000
26
28
  const RELOAD_TIMEOUT_MS = 180_000
27
29
  /** 这些包的 dist-tags.latest 落后于 next。 */
28
30
  const NEXT_TAG_SCOPES = ['@deepseek-ai/dsh-']
@@ -38,6 +40,23 @@ const LOCK_STALE_MS = 30 * 60 * 1000
38
40
  let lastRun = readLastRun()
39
41
  let running = null
40
42
 
43
+ /**
44
+ * 正在进行的这一轮的进度。
45
+ *
46
+ * 原来安装阶段只有开始/结束两条日志,中途 registry 超时重试好几分钟时界面上
47
+ * 一片空白——用户以为卡死。这里把「装到第几个、哪个包」记成可查询状态,
48
+ * /state 每次读都带上,设置页就能实时显示。
49
+ */
50
+ let progress = null
51
+
52
+ function setProgress(value) {
53
+ progress = value
54
+ }
55
+
56
+ function clearProgress() {
57
+ progress = null
58
+ }
59
+
41
60
  function oneLine(value, limit = 2000) {
42
61
  const text = String(value ?? '')
43
62
  .replace(/[\r\n\u2028\u2029]+/gu, ' ')
@@ -190,6 +209,13 @@ function makeLogTemplates(lang) {
190
209
  disabledBySettings: () => (zh ? '设置里已关闭自动更新,定时器待命' : 'Auto-update is off in settings; scheduler parked'),
191
210
  disabledByConfig: () => (zh ? '配置里已关闭自动更新,定时器待命,设置页仍然可用' : 'Auto-update is off in config; scheduler parked, settings page stays live'),
192
211
  // 清理日志按对象报数,几个数字一处说完,免得刷三行。
212
+ // 安装进度:N/M 个 + 包名,超时时也给出上一包的明确提示。
213
+ installing: (n, total, name) => (zh
214
+ ? `正在安装第 ${n}/${total} 个:${name}`
215
+ : `Installing ${n}/${total}: ${name}`),
216
+ installTimeout: (name, minutes) => (zh
217
+ ? `${name} 安装超过 ${minutes} 分钟仍没结束,等本包收尾后继续`
218
+ : `${name} has been installing for over ${minutes} min; will continue when it finishes`),
193
219
  cleaned: (kind, rows, days) => (zh
194
220
  ? `清理${kind}:删掉 ${rows} 条超过 ${days} 天的`
195
221
  : `Cleaned ${kind}: removed ${rows} entr${rows === 1 ? 'y' : 'ies'} older than ${days} day(s)`),
@@ -1673,8 +1699,10 @@ async function hotApply(ctx, requiredBefore) {
1673
1699
  }
1674
1700
  function beginningRun(mode, ctxRef) {
1675
1701
  if (running !== null) return null
1702
+ if (mode === 'update') setProgress({ phase: 'checking', index: 0, total: 0, name: '' })
1676
1703
  const promise = runCycle(mode, ctxRef).finally(() => {
1677
1704
  running = null
1705
+ clearProgress()
1678
1706
  })
1679
1707
  running = promise
1680
1708
  return promise
@@ -1829,8 +1857,25 @@ async function applyUpdates(ctxRef, report, settings, runner, profileDir, profil
1829
1857
  const requiredBefore = activeEntryIds(ctxRef.ctx)
1830
1858
  // 自身放到最后:换掉自身之后,这一轮剩下的代码就来自旧模块了。
1831
1859
  const ordered = report.updates.slice().sort((a, b) => (a.name === name ? 1 : b.name === name ? -1 : 0))
1832
- for (const update of ordered) {
1833
- const outcome = await installOne(runner, profileName, profileDir, update.name, update.target)
1860
+ const total = ordered.length
1861
+ for (let i = 0; i < ordered.length; i += 1) {
1862
+ const update = ordered[i]
1863
+ // 每装一个之前更新一次进度;日志也写一行,日志卡片里能看到同样的话。
1864
+ setProgress({ phase: 'installing', index: i + 1, total, name: update.name })
1865
+ writeLog('installing', [i + 1, total, update.name])
1866
+ // 慢装提示:到点就报,不等整个命令结束。pnpm 的网络重试会把 WARN
1867
+ // 攒到结束才吐出来,中途必须有个「还在跑、已经跑了多久」的锚点。
1868
+ const startedAt = Date.now()
1869
+ const slowTimer = setTimeout(() => {
1870
+ writeLog('installTimeout', [update.name, Math.round(INSTALL_SLOW_MS / 60000)])
1871
+ }, INSTALL_SLOW_MS)
1872
+ slowTimer.unref?.()
1873
+ let outcome
1874
+ try {
1875
+ outcome = await installOne(runner, profileName, profileDir, update.name, update.target)
1876
+ } finally {
1877
+ clearTimeout(slowTimer)
1878
+ }
1834
1879
  report.installed.push(outcome)
1835
1880
  writeLog('install', [update.name, update.target, outcome.ok === true, outcome.detail ?? ''])
1836
1881
  if (outcome.ok) {
@@ -1849,6 +1894,7 @@ async function applyUpdates(ctxRef, report, settings, runner, profileDir, profil
1849
1894
  noteFailure(update.name, update.target)
1850
1895
  }
1851
1896
  }
1897
+ setProgress({ phase: 'applying', index: total, total, name: '' })
1852
1898
  const okCount = report.installed.filter((item) => item.ok).length
1853
1899
  if (okCount === 0) {
1854
1900
  report.status = 'failed'
@@ -2143,6 +2189,8 @@ function settingsSnapshot(config, ctxRef, lang) {
2143
2189
  return {
2144
2190
  settings,
2145
2191
  overrides: readOverrides(),
2192
+ // 运行中的进度:没在跑时为 null,设置页据此决定要不要显示进度条。
2193
+ progress: progress === null ? null : { ...progress },
2146
2194
  lastRun: lastRun === null ? null : {
2147
2195
  status: lastRun.status,
2148
2196
  reason: renderReason(lastRun.reason, lang),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aupdate",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "type": "module",
5
5
  "description": "定时检查 DSH 插件更新,串行安装后就地生效,不重启;支持多种调度节奏、失败抑制、按包回滚,并在动手前留快照、忙时自动让开;不更新/只更新哪些插件改成勾选,发现更新在右下角提醒,日志最新在最上面,并在「设置 → 插件更新」里有独立一页。",
6
6
  "license": "MIT",