dsh-aupdate 0.6.8 → 0.7.0
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 +7 -1
- package/client.js +47 -0
- package/index.js +50 -2
- package/package.json +1 -1
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 settings page polls /state every three seconds while it is open, so progress
|
|
449
|
+
from an automatically scheduled cycle shows up too — not only one started by the button.
|
|
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('')
|
|
@@ -672,6 +680,25 @@ window.__ModuleLoader__.load({
|
|
|
672
680
|
|
|
673
681
|
useEffect(() => { void load() }, [load])
|
|
674
682
|
|
|
683
|
+
// 进度轮询要常驻:更新多数是定时器自动触发的,若只在点「立刻检查」时轮询,
|
|
684
|
+
// 自动跑的那一轮界面上什么也看不到——上次就是这个原因以为进度功能没生效。
|
|
685
|
+
useEffect(() => {
|
|
686
|
+
let alive = true
|
|
687
|
+
const tick = async () => {
|
|
688
|
+
try {
|
|
689
|
+
const next = await getState(LANG)
|
|
690
|
+
if (alive) {
|
|
691
|
+
setProgress(next?.progress ?? null)
|
|
692
|
+
// 别人(定时器 / 另一个窗口)触发的轮次,也把 running 点亮。
|
|
693
|
+
if (next?.progress) setRunning(true)
|
|
694
|
+
}
|
|
695
|
+
} catch {}
|
|
696
|
+
}
|
|
697
|
+
void tick()
|
|
698
|
+
const timer = setInterval(() => { void tick() }, 3000)
|
|
699
|
+
return () => { alive = false; clearInterval(timer) }
|
|
700
|
+
}, [LANG])
|
|
701
|
+
|
|
675
702
|
/**
|
|
676
703
|
* 立即保存。
|
|
677
704
|
*
|
|
@@ -726,11 +753,26 @@ window.__ModuleLoader__.load({
|
|
|
726
753
|
}, [])
|
|
727
754
|
|
|
728
755
|
|
|
756
|
+
/** 把后端进度翻成一行中文/英文;没进度就退回普通「正在检查」。 */
|
|
757
|
+
const runningText = (() => {
|
|
758
|
+
if (!progress) return ''
|
|
759
|
+
if (progress.phase === 'installing' && progress.total > 0) {
|
|
760
|
+
return T.progressInstall
|
|
761
|
+
.replace('{n}', String(progress.index))
|
|
762
|
+
.replace('{m}', String(progress.total))
|
|
763
|
+
.replace('{name}', String(progress.name || ''))
|
|
764
|
+
}
|
|
765
|
+
if (progress.phase === 'applying') return T.progressApply
|
|
766
|
+
if (progress.phase === 'checking') return T.progressCheck
|
|
767
|
+
return T.running
|
|
768
|
+
})()
|
|
769
|
+
|
|
729
770
|
const fire = useCallback(async () => {
|
|
730
771
|
if (running) return
|
|
731
772
|
setRunning(true)
|
|
732
773
|
setRunHint(T.running)
|
|
733
774
|
try {
|
|
775
|
+
// 进度由上面的常驻轮询统一负责,这里只发请求。
|
|
734
776
|
const result = await runNow('update')
|
|
735
777
|
if (result?.started === false) {
|
|
736
778
|
setRunHint(result.reason || T.runFailed)
|
|
@@ -747,6 +789,7 @@ window.__ModuleLoader__.load({
|
|
|
747
789
|
setRunHint(T.runFailed)
|
|
748
790
|
} finally {
|
|
749
791
|
setRunning(false)
|
|
792
|
+
// 不在这里清 progress:常驻轮询会在后端清掉后同步,手动作废会和它打架。
|
|
750
793
|
}
|
|
751
794
|
}, [running])
|
|
752
795
|
|
|
@@ -926,6 +969,10 @@ window.__ModuleLoader__.load({
|
|
|
926
969
|
h('span', { style: S.label }, T.lastRun),
|
|
927
970
|
h('button', { type: 'button', style: S.btn, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
|
|
928
971
|
),
|
|
972
|
+
// 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
|
|
973
|
+
progress
|
|
974
|
+
? h('span', { style: { ...S.status, color: '#4c9aff', fontWeight: 500 } }, runningText)
|
|
975
|
+
: null,
|
|
929
976
|
last === null || last === undefined
|
|
930
977
|
? h('span', { style: S.status }, T.never)
|
|
931
978
|
: 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
|
-
|
|
1833
|
-
|
|
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