dsh-aupdate 0.6.7 → 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 +14 -2
- package/client.js +115 -14
- package/index.js +80 -4
- 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
|
不提供写入口——面板能看,但改不了日志。
|
|
@@ -190,6 +192,10 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
190
192
|
发现可更新版本时,界面右下角浮一条提醒,列出插件名和「当前 → 新」版本;超过 8 条
|
|
191
193
|
时余下给一句「还有 N 个」,15 秒后自动消失。
|
|
192
194
|
|
|
195
|
+
提醒逐条列出**包名**和「当前版本 → 新版本」,包名过长时省略包名那一侧、不动版本;
|
|
196
|
+
超过 6 条在框内滚动。设置页的「上一次」卡片也会列出同一份清单,不用只靠一句
|
|
197
|
+
「4 个可更新」猜是哪几个。
|
|
198
|
+
|
|
193
199
|
同一批更新只提醒一次:这批更新的签名记在 `localStorage` 里,刷新页面不会重复弹。
|
|
194
200
|
关掉「发现更新时提醒我」就完全不弹,日志和设置页照常记录——提醒只是别让它装完你
|
|
195
201
|
还不知道,不是唯一的告知渠道。
|
|
@@ -410,7 +416,9 @@ in the same language. Wording only — it changes no update behaviour.
|
|
|
410
416
|
|
|
411
417
|
When a check finds updates, a notice appears in the bottom-right corner listing each
|
|
412
418
|
plugin and its current → new version; past eight it adds "and N more", and it closes
|
|
413
|
-
itself after 15 seconds.
|
|
419
|
+
itself after 15 seconds. Long package names are truncated on the name side so the
|
|
420
|
+
versions stay visible, and past six entries the list scrolls. The Last run card on the
|
|
421
|
+
settings page lists the same plugins and version pairs. Each batch is announced once — the signature is kept in
|
|
414
422
|
`localStorage` — and turning "Tell me when updates are found" off silences it entirely
|
|
415
423
|
while the log and settings page keep recording.
|
|
416
424
|
|
|
@@ -434,7 +442,11 @@ while the log and settings page keep recording.
|
|
|
434
442
|
live in `~/.dsh/aupdate-settings.json`.
|
|
435
443
|
|
|
436
444
|
The page renders the log newest first, so whatever just happened is at the top of the
|
|
437
|
-
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.
|
|
438
450
|
|
|
439
451
|
Log lines are stored as an event code plus its arguments, not as finished sentences, so
|
|
440
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
|
-
|
|
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 },
|
|
@@ -936,6 +974,23 @@ window.__ModuleLoader__.load({
|
|
|
936
974
|
: T.upToDate),
|
|
937
975
|
h('span', null, last.reason || last.status || ''),
|
|
938
976
|
),
|
|
977
|
+
// 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
|
|
978
|
+
// 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
|
|
979
|
+
(() => {
|
|
980
|
+
const rows = (Array.isArray(last?.updates) ? last.updates : [])
|
|
981
|
+
.map((item) => describeUpdate(item))
|
|
982
|
+
.filter((row) => row !== null)
|
|
983
|
+
if (rows.length === 0) return null
|
|
984
|
+
return h('div', { style: S.scrollList },
|
|
985
|
+
rows.map((row, index) => h('div', {
|
|
986
|
+
key: row.name + ':' + index,
|
|
987
|
+
style: { display: 'flex', alignItems: 'baseline', gap: '8px' },
|
|
988
|
+
},
|
|
989
|
+
h('span', { style: S.pkgName, title: row.name }, row.name),
|
|
990
|
+
row.versions === '' ? null : h('span', { style: S.pkgVer }, row.versions),
|
|
991
|
+
)),
|
|
992
|
+
)
|
|
993
|
+
})(),
|
|
939
994
|
runHint ? h('span', { style: S.status }, runHint) : null,
|
|
940
995
|
),
|
|
941
996
|
// 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
|
|
@@ -1100,40 +1155,85 @@ window.__ModuleLoader__.load({
|
|
|
1100
1155
|
|
|
1101
1156
|
let toastOpen = false
|
|
1102
1157
|
|
|
1158
|
+
/**
|
|
1159
|
+
* 把一条「可更新」记录归一成 { name, versions }。
|
|
1160
|
+
*
|
|
1161
|
+
* 后端 0.6.8 起存 { name, from, to };更早的版本存的是成品句子
|
|
1162
|
+
* 「名字 1.0 -> 1.1」。两种都要能显示——旧数据不该因为升级就变成
|
|
1163
|
+
* undefined。之前正是只按对象读,句子条目全是 undefined ? → ?。
|
|
1164
|
+
*/
|
|
1165
|
+
function describeUpdate(item) {
|
|
1166
|
+
if (typeof item === 'string') {
|
|
1167
|
+
const text = item.trim()
|
|
1168
|
+
if (text === '') return null
|
|
1169
|
+
const match = /^(.*) (\S+) -> (\S+)$/u.exec(text)
|
|
1170
|
+
if (match === null) return { name: text, versions: '' }
|
|
1171
|
+
return { name: match[1], versions: match[2] + ' → ' + match[3] }
|
|
1172
|
+
}
|
|
1173
|
+
if (item === null || typeof item !== 'object') return null
|
|
1174
|
+
const name = typeof item.name === 'string' ? item.name : ''
|
|
1175
|
+
if (name === '') return null
|
|
1176
|
+
const from = typeof item.from === 'string' && item.from !== '' ? item.from : '?'
|
|
1177
|
+
const to = typeof item.to === 'string' && item.to !== '' ? item.to : '?'
|
|
1178
|
+
return { name, versions: from + ' → ' + to }
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
function updateSignature(updates) {
|
|
1182
|
+
return (Array.isArray(updates) ? updates : [])
|
|
1183
|
+
.map((item) => describeUpdate(item))
|
|
1184
|
+
.filter((row) => row !== null)
|
|
1185
|
+
.map((row) => row.name + '@' + row.versions)
|
|
1186
|
+
.sort()
|
|
1187
|
+
.join('|')
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1103
1190
|
function showUpdateToast(updates) {
|
|
1104
1191
|
if (toastOpen) return
|
|
1105
1192
|
const doc = typeof document === 'undefined' ? null : document
|
|
1106
1193
|
if (doc === null || doc.body === null) return
|
|
1194
|
+
const rows = (Array.isArray(updates) ? updates : []).map((item) => describeUpdate(item)).filter((row) => row !== null)
|
|
1195
|
+
if (rows.length === 0) return
|
|
1107
1196
|
toastOpen = true
|
|
1108
1197
|
const box = doc.createElement('div')
|
|
1109
1198
|
box.setAttribute('data-dsh-aupdate', 'toast')
|
|
1110
1199
|
box.style.cssText = [
|
|
1111
1200
|
'position:fixed', 'right:16px', 'bottom:16px', 'z-index:2147483000',
|
|
1112
|
-
'max-width:
|
|
1201
|
+
'width:320px', 'max-width:calc(100vw - 32px)', 'padding:12px 14px', 'border-radius:10px',
|
|
1113
1202
|
'background:rgba(28,28,30,0.97)', 'color:#f4f4f5',
|
|
1114
1203
|
'box-shadow:0 8px 28px rgba(0,0,0,0.38)', 'border:1px solid rgba(255,255,255,0.14)',
|
|
1115
1204
|
'font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif',
|
|
1116
|
-
'display:flex', 'flex-direction:column', 'gap:
|
|
1205
|
+
'display:flex', 'flex-direction:column', 'gap:9px',
|
|
1117
1206
|
].join(';')
|
|
1118
1207
|
|
|
1119
1208
|
const title = doc.createElement('div')
|
|
1120
|
-
title.textContent = T.toastTitle.replace('{n}', String(
|
|
1121
|
-
title.style.cssText = 'font-weight:600'
|
|
1209
|
+
title.textContent = T.toastTitle.replace('{n}', String(rows.length))
|
|
1210
|
+
title.style.cssText = 'font-weight:600;display:flex;align-items:center;gap:6px'
|
|
1122
1211
|
box.appendChild(title)
|
|
1123
1212
|
|
|
1124
1213
|
const list = doc.createElement('div')
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1214
|
+
// 超过 6 条就在框内滚动:提醒不该占掉半屏。
|
|
1215
|
+
list.style.cssText = 'display:flex;flex-direction:column;gap:2px;max-height:190px;overflow:auto;margin:0 -4px'
|
|
1216
|
+
for (const row of rows.slice(0, 12)) {
|
|
1217
|
+
const line = doc.createElement('div')
|
|
1218
|
+
line.style.cssText = 'display:flex;align-items:baseline;gap:8px;padding:2px 4px;border-radius:4px;background:rgba(255,255,255,0.05)'
|
|
1219
|
+
const nameEl = doc.createElement('span')
|
|
1220
|
+
nameEl.textContent = row.name
|
|
1221
|
+
// 包名可能很长(@scope/name),压缩它而不是压缩版本。
|
|
1222
|
+
nameEl.style.cssText = 'flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap'
|
|
1223
|
+
line.appendChild(nameEl)
|
|
1224
|
+
if (row.versions !== '') {
|
|
1225
|
+
const verEl = doc.createElement('span')
|
|
1226
|
+
verEl.textContent = row.versions
|
|
1227
|
+
verEl.style.cssText = 'flex:0 0 auto;font-size:11.5px;opacity:0.72;font-variant-numeric:tabular-nums'
|
|
1228
|
+
line.appendChild(verEl)
|
|
1229
|
+
}
|
|
1230
|
+
list.appendChild(line)
|
|
1131
1231
|
}
|
|
1132
1232
|
box.appendChild(list)
|
|
1133
1233
|
|
|
1134
|
-
if (
|
|
1234
|
+
if (rows.length > 12) {
|
|
1135
1235
|
const more = doc.createElement('div')
|
|
1136
|
-
more.textContent = T.toastMore.replace('{n}', String(
|
|
1236
|
+
more.textContent = T.toastMore.replace('{n}', String(rows.length - 12))
|
|
1137
1237
|
more.style.cssText = 'font-size:11.5px;opacity:0.6'
|
|
1138
1238
|
box.appendChild(more)
|
|
1139
1239
|
}
|
|
@@ -1163,7 +1263,8 @@ window.__ModuleLoader__.load({
|
|
|
1163
1263
|
if (state?.settings?.notify !== false) {
|
|
1164
1264
|
const updates = Array.isArray(state?.lastRun?.updates) ? state.lastRun.updates : []
|
|
1165
1265
|
if (updates.length > 0) {
|
|
1166
|
-
|
|
1266
|
+
// 签名算的是「包名+版本变化」,旧格式也能算出来,不会重复弹。
|
|
1267
|
+
const sig = updateSignature(updates)
|
|
1167
1268
|
if (sig !== notifiedMark()) {
|
|
1168
1269
|
markNotified(sig)
|
|
1169
1270
|
showUpdateToast(updates)
|
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)`),
|
|
@@ -784,11 +810,38 @@ function readLastRun() {
|
|
|
784
810
|
if (raw === null || typeof raw !== 'object') return null
|
|
785
811
|
if (typeof raw.at !== 'string' || raw.at === '') return null
|
|
786
812
|
const textList = (value) => (Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [])
|
|
813
|
+
/**
|
|
814
|
+
* 待更新清单。
|
|
815
|
+
*
|
|
816
|
+
* 0.6.7 及更早把这一项存成「名字 1.0 -> 1.1」的句子,界面只能整行照搬;
|
|
817
|
+
* 现在存 { name, from, to },提醒和设置页才能把包名和版本分开排版。
|
|
818
|
+
* 旧数据在这里解析回来,不需要用户清文件。
|
|
819
|
+
*/
|
|
820
|
+
const updateList = (value) => {
|
|
821
|
+
if (!Array.isArray(value)) return []
|
|
822
|
+
const out = []
|
|
823
|
+
for (const item of value) {
|
|
824
|
+
if (item !== null && typeof item === 'object') {
|
|
825
|
+
if (typeof item.name !== 'string' || item.name === '') continue
|
|
826
|
+
out.push({
|
|
827
|
+
name: item.name,
|
|
828
|
+
from: typeof item.from === 'string' ? item.from : '',
|
|
829
|
+
to: typeof item.to === 'string' ? item.to : '',
|
|
830
|
+
})
|
|
831
|
+
continue
|
|
832
|
+
}
|
|
833
|
+
if (typeof item !== 'string' || item === '') continue
|
|
834
|
+
const match = /^(.*) (\S+) -> (\S+)$/u.exec(item)
|
|
835
|
+
if (match === null) out.push({ name: item, from: '', to: '' })
|
|
836
|
+
else out.push({ name: match[1], from: match[2], to: match[3] })
|
|
837
|
+
}
|
|
838
|
+
return out
|
|
839
|
+
}
|
|
787
840
|
return {
|
|
788
841
|
status: typeof raw.status === 'string' ? raw.status : 'unknown',
|
|
789
842
|
at: raw.at,
|
|
790
843
|
checked: Number.isFinite(raw.checked) ? raw.checked : 0,
|
|
791
|
-
updates:
|
|
844
|
+
updates: updateList(raw.updates),
|
|
792
845
|
installed: textList(raw.installed),
|
|
793
846
|
reload: typeof raw.reload === 'string' ? raw.reload : 'none',
|
|
794
847
|
// 0.6.2 及更早存的是句子;0.6.3 起是 { code, args },两种都要能读。
|
|
@@ -1646,8 +1699,10 @@ async function hotApply(ctx, requiredBefore) {
|
|
|
1646
1699
|
}
|
|
1647
1700
|
function beginningRun(mode, ctxRef) {
|
|
1648
1701
|
if (running !== null) return null
|
|
1702
|
+
if (mode === 'update') setProgress({ phase: 'checking', index: 0, total: 0, name: '' })
|
|
1649
1703
|
const promise = runCycle(mode, ctxRef).finally(() => {
|
|
1650
1704
|
running = null
|
|
1705
|
+
clearProgress()
|
|
1651
1706
|
})
|
|
1652
1707
|
running = promise
|
|
1653
1708
|
return promise
|
|
@@ -1783,7 +1838,8 @@ async function runCycle(mode, ctxRef) {
|
|
|
1783
1838
|
status: report.status,
|
|
1784
1839
|
at: report.finishedAt,
|
|
1785
1840
|
checked: report.checked,
|
|
1786
|
-
|
|
1841
|
+
// 结构化存:界面要分开排「包名」和「版本」,句子做不到。
|
|
1842
|
+
updates: report.updates.map((item) => ({ name: item.name, from: item.current ?? '', to: item.target })),
|
|
1787
1843
|
installed: report.installed.map((item) => item.name + '@' + item.version + (item.ok ? '' : ' !failed')),
|
|
1788
1844
|
reload: report.reload?.status ?? 'none',
|
|
1789
1845
|
reason: report.reason,
|
|
@@ -1801,8 +1857,25 @@ async function applyUpdates(ctxRef, report, settings, runner, profileDir, profil
|
|
|
1801
1857
|
const requiredBefore = activeEntryIds(ctxRef.ctx)
|
|
1802
1858
|
// 自身放到最后:换掉自身之后,这一轮剩下的代码就来自旧模块了。
|
|
1803
1859
|
const ordered = report.updates.slice().sort((a, b) => (a.name === name ? 1 : b.name === name ? -1 : 0))
|
|
1804
|
-
|
|
1805
|
-
|
|
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
|
+
}
|
|
1806
1879
|
report.installed.push(outcome)
|
|
1807
1880
|
writeLog('install', [update.name, update.target, outcome.ok === true, outcome.detail ?? ''])
|
|
1808
1881
|
if (outcome.ok) {
|
|
@@ -1821,6 +1894,7 @@ async function applyUpdates(ctxRef, report, settings, runner, profileDir, profil
|
|
|
1821
1894
|
noteFailure(update.name, update.target)
|
|
1822
1895
|
}
|
|
1823
1896
|
}
|
|
1897
|
+
setProgress({ phase: 'applying', index: total, total, name: '' })
|
|
1824
1898
|
const okCount = report.installed.filter((item) => item.ok).length
|
|
1825
1899
|
if (okCount === 0) {
|
|
1826
1900
|
report.status = 'failed'
|
|
@@ -2115,6 +2189,8 @@ function settingsSnapshot(config, ctxRef, lang) {
|
|
|
2115
2189
|
return {
|
|
2116
2190
|
settings,
|
|
2117
2191
|
overrides: readOverrides(),
|
|
2192
|
+
// 运行中的进度:没在跑时为 null,设置页据此决定要不要显示进度条。
|
|
2193
|
+
progress: progress === null ? null : { ...progress },
|
|
2118
2194
|
lastRun: lastRun === null ? null : {
|
|
2119
2195
|
status: lastRun.status,
|
|
2120
2196
|
reason: renderReason(lastRun.reason, lang),
|
package/package.json
CHANGED