dsh-aupdate 0.4.2 → 0.6.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 +71 -5
- package/client.js +253 -31
- package/index.js +156 -45
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,14 +55,14 @@ https://github.com/CalmSun/dsh-aupdate
|
|
|
55
55
|
|
|
56
56
|
| 设置 | 默认 | 说明 |
|
|
57
57
|
|---|---|---|
|
|
58
|
-
| `
|
|
59
|
-
| `exclude` | `[]` | 不更新的包,优先级高于 `allow` |
|
|
58
|
+
| `exclude` | `[]` | 不更新的包;填了就一直不参与自动更新 |
|
|
60
59
|
| `allowMajor` | `true` | 关掉后只在同一主版本内升级 |
|
|
61
60
|
| `allowPrerelease` | `false` | 关掉后不装预发布;`next` 标签不受影响 |
|
|
62
61
|
| `idleOnly` | `true` | 忙的时候不动手(见下节) |
|
|
63
62
|
| `hotReload` | `true` | 装完就地生效,否则等重启 |
|
|
64
63
|
| `maxPerCycle` | `0` | 一轮最多装几个,0 表示不限 |
|
|
65
64
|
| `sessionIdleMinutes` | `2` | 会话静默多少分钟才算闲,0 表示只看子任务 |
|
|
65
|
+
| `notify` | `true` | 发现可更新版本时在右下角提醒,列出插件与版本 |
|
|
66
66
|
|
|
67
67
|
## 什么时候动手
|
|
68
68
|
|
|
@@ -86,6 +86,9 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
86
86
|
`~/.dsh/aupdate-history.json`,设置页里能直接看到,并对最近一次更新点「回滚」
|
|
87
87
|
把旧版本装回去。回滚只针对本插件自己装上去的那一次。
|
|
88
88
|
|
|
89
|
+
记录栏固定高度、在自己的框里滚动:堆到上百条也只是这一栏变长,不会把整页顶到几屏
|
|
90
|
+
之外,按钮也不会被挤到看不见的地方。
|
|
91
|
+
|
|
89
92
|
同一个包的 `from → to` 完全相同、且都不是回滚记录时只留最新一条:
|
|
90
93
|
否则同一行失败记录会一轮一条堆满历史,真正要回的那个点反而找不到了。
|
|
91
94
|
`1.0 → 1.1` 和 `1.0 → 1.2` 是两件事,不会合并。
|
|
@@ -118,11 +121,32 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
118
121
|
## 设置页
|
|
119
122
|
|
|
120
123
|
插件页里的这一行有摘要和整页两种视图,保存后立刻按新节奏重排,不用重启。
|
|
124
|
+
同一份界面还挂在**设置 → 插件更新**里,是独立的一页,不用先去插件页翻这张卡。
|
|
121
125
|
读写走 `/api/dsh-aupdate/{state,run,rollback,logs}`。
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
### 勾选插件,而不是手写包名
|
|
128
|
+
|
|
129
|
+
`exclude` 原来要一行一个包名地敲。现在整页里是一张勾选清单,直接列出这个 profile
|
|
130
|
+
实际装着的插件和各自的已装版本:
|
|
131
|
+
|
|
132
|
+
- **不自动更新的包**:勾上的永远不参与自动更新
|
|
133
|
+
- 能按名字搜索,`/state` 里带着 `packages`(名字、版本、当前是否被排除)
|
|
134
|
+
- 「全选 / 清空」只作用于当前筛选出来的行——搜完再点全选,意思是把搜到的都勾上
|
|
135
|
+
- 这个 profile 里装着的插件都会列出来,列表本身就是「能勾什么」的全部答案
|
|
136
|
+
|
|
137
|
+
### 「上一次」不会再被重启清空
|
|
138
|
+
|
|
139
|
+
最近一轮的结果(时间、查了多少个、几个可更新、装成几个、失败原因)现在落在
|
|
140
|
+
`~/.dsh/aupdate-lastrun.json`,DSH 重启后照旧显示。以前它是纯内存的,重启一次就回到
|
|
141
|
+
「还没跑过」,看着像这一轮根本没跑过。读的时候逐字段校验,坏文件只会让这张卡缺席,
|
|
142
|
+
不会让插件加载失败。
|
|
143
|
+
|
|
144
|
+
整页最下面是**运行日志**卡片,直接看插件最近写了什么,不用再去翻文件。日志正文用中文写,
|
|
145
|
+
一行一件事(检查了多少个、装哪个、为什么跳过),状态词也翻成人话;
|
|
124
146
|
|
|
125
147
|
- 可选显示最近 100 / 200 / 500 / 1000 行,默认 200
|
|
148
|
+
- **最新的在最上面**:按时间倒序渲染,刚装了什么不用滚到底
|
|
149
|
+
- 时间只到「月-日 时:分:秒」并等宽对齐,省下的宽度留给正文
|
|
126
150
|
- 打开「自动刷新」后每 5 秒拉一次,正在排查时开着;关掉就完全不动
|
|
127
151
|
- 读之前会先把待写队列刷下去,所以刚点完检查,那几行马上就在里面
|
|
128
152
|
- 时间戳按本地时区显示,文件超过 1MB 轮转给一句提示,另附总行数
|
|
@@ -135,6 +159,18 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
135
159
|
一律 503。不用「只认回环地址」这种判据:浏览器里任何网页都能向 127.0.0.1 发请求。
|
|
136
160
|
`/state` 和 `/logs` 也照样要过,因为它们分别会吐全量设置和读磁盘上的日志文件。
|
|
137
161
|
|
|
162
|
+
## 更新提醒
|
|
163
|
+
|
|
164
|
+
发现可更新版本时,界面右下角浮一条提醒,列出插件名和「当前 → 新」版本;超过 8 条
|
|
165
|
+
时余下给一句「还有 N 个」,15 秒后自动消失。
|
|
166
|
+
|
|
167
|
+
同一批更新只提醒一次:这批更新的签名记在 `localStorage` 里,刷新页面不会重复弹。
|
|
168
|
+
关掉「发现更新时提醒我」就完全不弹,日志和设置页照常记录——提醒只是别让它装完你
|
|
169
|
+
还不知道,不是唯一的告知渠道。
|
|
170
|
+
|
|
171
|
+
提醒用的是原生 DOM 浮层,不是新的槽位:槽位只在宿主页挂载时才渲染,而提醒要能在
|
|
172
|
+
会话、插件页、设置页都出现。
|
|
173
|
+
|
|
138
174
|
## 效率
|
|
139
175
|
|
|
140
176
|
- 只取 dist-tags:24 个包从 2.88 MB 降到 655 B
|
|
@@ -234,14 +270,14 @@ A successful install clears the record.
|
|
|
234
270
|
|
|
235
271
|
| Setting | Default | Meaning |
|
|
236
272
|
|---|---|---|
|
|
237
|
-
| `
|
|
238
|
-
| `exclude` | `[]` | Never update these; takes priority over `allow` |
|
|
273
|
+
| `exclude` | `[]` | Never update these; whatever is listed stays out of auto-updates |
|
|
239
274
|
| `allowMajor` | `true` | When off, stay within the same major version |
|
|
240
275
|
| `allowPrerelease` | `false` | When off, skip prereleases; the `next` tag is unaffected |
|
|
241
276
|
| `idleOnly` | `true` | Hold off while anything is busy (see below) |
|
|
242
277
|
| `hotReload` | `true` | Apply in place after install instead of waiting for a restart |
|
|
243
278
|
| `maxPerCycle` | `0` | Installs per cycle; 0 means no limit |
|
|
244
279
|
| `sessionIdleMinutes` | `2` | Session must be quiet this long to count as idle; 0 judges by subagents only |
|
|
280
|
+
| `notify` | `true` | Announce available updates in the bottom-right corner, with plugin names and versions |
|
|
245
281
|
|
|
246
282
|
### When it acts
|
|
247
283
|
|
|
@@ -296,11 +332,38 @@ the new version, and a timestamp, in `~/.dsh/aupdate-history.json`. The settings
|
|
|
296
332
|
page lists them and can roll the most recent update back to its previous version.
|
|
297
333
|
A rollback applies once: the same downgrade cannot be replayed.
|
|
298
334
|
|
|
335
|
+
The list keeps a fixed height and scrolls inside its own box, so a hundred entries make
|
|
336
|
+
that one card longer instead of pushing the whole page down.
|
|
337
|
+
|
|
299
338
|
Repeated rows for the same package with an identical `from → to`, where neither is
|
|
300
339
|
a rollback, collapse into the newest one. Otherwise a single failing version would
|
|
301
340
|
pile up one row per cycle and bury the entry you actually want to return to.
|
|
302
341
|
`1.0 → 1.1` and `1.0 → 1.2` are different events and stay separate.
|
|
303
342
|
|
|
343
|
+
### Settings page
|
|
344
|
+
|
|
345
|
+
The row in the plugins page shows a summary and a full page; saving re-schedules
|
|
346
|
+
immediately without a restart. The same UI is also its own page under
|
|
347
|
+
**Settings → Plugin updates**, so it is not buried in the plugins page.
|
|
348
|
+
|
|
349
|
+
`exclude` is a checkbox list of the plugins actually installed in this profile, with
|
|
350
|
+
their installed versions, instead of a textarea you had to type package names into.
|
|
351
|
+
Search narrows the list; Select all / Clear only touch the rows currently shown, so
|
|
352
|
+
"search, then select all" means what you expect.
|
|
353
|
+
|
|
354
|
+
The last run's outcome (when, how many checked, how many updatable, how many installed,
|
|
355
|
+
why it failed) is persisted to `~/.dsh/aupdate-lastrun.json` and survives a restart. It
|
|
356
|
+
used to live in memory only, so every restart reset the card to "never run" and looked
|
|
357
|
+
like nothing had happened.
|
|
358
|
+
|
|
359
|
+
### Update notices
|
|
360
|
+
|
|
361
|
+
When a check finds updates, a notice appears in the bottom-right corner listing each
|
|
362
|
+
plugin and its current → new version; past eight it adds "and N more", and it closes
|
|
363
|
+
itself after 15 seconds. Each batch is announced once — the signature is kept in
|
|
364
|
+
`localStorage` — and turning "Tell me when updates are found" off silences it entirely
|
|
365
|
+
while the log and settings page keep recording.
|
|
366
|
+
|
|
304
367
|
### Tool
|
|
305
368
|
|
|
306
369
|
`plugin_updater` with an `action` argument: `check`, `update`, `state`, or `history`.
|
|
@@ -320,6 +383,9 @@ pile up one row per cycle and bury the entry you actually want to return to.
|
|
|
320
383
|
`~/.dsh/aupdate.log`, flushed on write and rotated when it grows. Setting overrides
|
|
321
384
|
live in `~/.dsh/aupdate-settings.json`.
|
|
322
385
|
|
|
386
|
+
The page renders the log newest first, so whatever just happened is at the top of the
|
|
387
|
+
box instead of at the bottom of a scroll.
|
|
388
|
+
|
|
323
389
|
You can read this file straight from the settings page (see above). Point it
|
|
324
390
|
elsewhere with `DSH_AUTO_UPDATE_LOG`.
|
|
325
391
|
|
package/client.js
CHANGED
|
@@ -60,7 +60,6 @@ window.__ModuleLoader__.load({
|
|
|
60
60
|
firstDelayHint: '分钟,0 表示立刻',
|
|
61
61
|
exclude: '不自动更新的包',
|
|
62
62
|
excludeHint: '每行一个包名',
|
|
63
|
-
allow: '只更新这些包',
|
|
64
63
|
allowHint: '每行一个包名;留空表示全部包都参与',
|
|
65
64
|
allowMajor: '允许跨大版本',
|
|
66
65
|
allowMajorHint: '关闭后只在同一主版本内升级(0.x 插件多半会因此长期不动)',
|
|
@@ -83,6 +82,22 @@ window.__ModuleLoader__.load({
|
|
|
83
82
|
logsAutoHint: '每 5 秒拉一次,正在排查时开着',
|
|
84
83
|
logsRotated: '日志已超过 1MB,旧内容在 .old 里',
|
|
85
84
|
logsTotal: '共 {n} 行',
|
|
85
|
+
logsNewest: '最新的在最上面',
|
|
86
|
+
notify: '发现更新时提醒我',
|
|
87
|
+
notifyHint: '在界面右下角弹一条提醒,列出可更新的插件和「当前 → 新」版本;同一批更新只提醒一次',
|
|
88
|
+
pkgsExclude: '不自动更新的包',
|
|
89
|
+
pkgsExcludeHint: '勾上的插件永远不自动更新;一个都不勾表示全部参与自动更新',
|
|
90
|
+
pkgsSearch: '搜索插件名',
|
|
91
|
+
pkgsAll: '全选',
|
|
92
|
+
pkgsNone: '清空',
|
|
93
|
+
pkgsEmpty: '这个 profile 里没有可自动更新的插件',
|
|
94
|
+
pkgsCount: '已勾选 {n} 个',
|
|
95
|
+
pkgsNotInstalled: '未安装',
|
|
96
|
+
pkgsNoMatch: '没有匹配的插件',
|
|
97
|
+
pageLabel: '插件更新',
|
|
98
|
+
toastTitle: '{n} 个插件可以更新',
|
|
99
|
+
toastMore: '还有 {n} 个',
|
|
100
|
+
toastDismiss: '知道了',
|
|
86
101
|
history: '更新记录',
|
|
87
102
|
historyEmpty: '还没有安装过任何更新',
|
|
88
103
|
rollback: '回滚',
|
|
@@ -145,7 +160,6 @@ window.__ModuleLoader__.load({
|
|
|
145
160
|
firstDelayHint: 'minutes, 0 means immediately',
|
|
146
161
|
exclude: 'Never auto-update',
|
|
147
162
|
excludeHint: 'one package name per line',
|
|
148
|
-
allow: 'Only update these',
|
|
149
163
|
allowHint: 'one package name per line; empty means every package',
|
|
150
164
|
allowMajor: 'Allow major upgrades',
|
|
151
165
|
allowMajorHint: 'Off keeps upgrades inside one major; 0.x plugins would rarely move',
|
|
@@ -168,6 +182,22 @@ window.__ModuleLoader__.load({
|
|
|
168
182
|
logsAutoHint: 'Polls every 5s; turn it on while debugging',
|
|
169
183
|
logsRotated: 'Log passed 1MB; older content is in .old',
|
|
170
184
|
logsTotal: '{n} lines',
|
|
185
|
+
logsNewest: 'newest first',
|
|
186
|
+
notify: 'Tell me when updates are found',
|
|
187
|
+
notifyHint: 'Pops a notice in the bottom-right corner listing the plugins that can update and their current → new versions; each batch is announced once',
|
|
188
|
+
pkgsExclude: 'Never auto-update',
|
|
189
|
+
pkgsExcludeHint: 'Checked plugins are never updated automatically; nothing checked means everything takes part',
|
|
190
|
+
pkgsSearch: 'Search plugin names',
|
|
191
|
+
pkgsAll: 'All',
|
|
192
|
+
pkgsNone: 'None',
|
|
193
|
+
pkgsEmpty: 'This profile has no plugins that can auto-update',
|
|
194
|
+
pkgsCount: '{n} selected',
|
|
195
|
+
pkgsNotInstalled: 'not installed',
|
|
196
|
+
pkgsNoMatch: 'Nothing matches',
|
|
197
|
+
pageLabel: 'Plugin updates',
|
|
198
|
+
toastTitle: '{n} plugin(s) can update',
|
|
199
|
+
toastMore: 'and {n} more',
|
|
200
|
+
toastDismiss: 'Got it',
|
|
171
201
|
history: 'Update history',
|
|
172
202
|
historyEmpty: 'No update has been installed yet',
|
|
173
203
|
rollback: 'Roll back',
|
|
@@ -220,6 +250,20 @@ window.__ModuleLoader__.load({
|
|
|
220
250
|
}
|
|
221
251
|
}
|
|
222
252
|
|
|
253
|
+
/**
|
|
254
|
+
* 日志行的时间只到 月-日 时:分:秒。
|
|
255
|
+
*
|
|
256
|
+
* 整条「2026-11-24 09:14:13」占掉一行近四分之一宽度,而日志的重点是内容,
|
|
257
|
+
* 年份在同一个文件里几乎不可能变。缩成短格式后一行能放进更多正文。
|
|
258
|
+
*/
|
|
259
|
+
function formatLogWhen(iso) {
|
|
260
|
+
const when = new Date(iso)
|
|
261
|
+
if (Number.isNaN(when.getTime())) return String(iso ?? '')
|
|
262
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
263
|
+
return pad(when.getMonth() + 1) + '-' + pad(when.getDate()) +
|
|
264
|
+
' ' + pad(when.getHours()) + ':' + pad(when.getMinutes()) + ':' + pad(when.getSeconds())
|
|
265
|
+
}
|
|
266
|
+
|
|
223
267
|
/** 「上一次」的光看绝对时间不好判断新鲜度,补一句相对时间。 */
|
|
224
268
|
function relativeWhen(iso) {
|
|
225
269
|
const when = new Date(iso)
|
|
@@ -312,8 +356,16 @@ window.__ModuleLoader__.load({
|
|
|
312
356
|
meta: { display: 'flex', gap: '14px', flexWrap: 'wrap', fontSize: '12px', opacity: 0.7 },
|
|
313
357
|
// 等宽 + 可滚动:日志要能对齐看时间戳,也不能把整页顶长。
|
|
314
358
|
logBox: { margin: 0, padding: '8px 10px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.22)', background: 'rgba(128,128,128,0.06)', fontSize: '11.5px', lineHeight: 1.55, fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace', maxHeight: '260px', overflow: 'auto', whiteSpace: 'pre-wrap', wordBreak: 'break-word' },
|
|
315
|
-
logTime: { opacity: 0.5 },
|
|
359
|
+
logTime: { opacity: 0.5, flexShrink: 0, fontVariantNumeric: 'tabular-nums' },
|
|
316
360
|
logText: {},
|
|
361
|
+
// 勾选清单:包名可能很长(@scope/name),要能截断,版本靠右对齐。
|
|
362
|
+
// 更新记录可能上百条,不封高度会把整页顶到几屏之外,滚动条交还给这一栏。
|
|
363
|
+
scrollList: { display: 'flex', flexDirection: 'column', gap: '8px', maxHeight: '260px', overflowY: 'auto', paddingRight: '4px' },
|
|
364
|
+
pkgList: { display: 'flex', flexDirection: 'column', gap: '1px', maxHeight: '240px', overflow: 'auto', border: '1px solid rgba(128,128,128,0.22)', borderRadius: '6px', padding: '4px' },
|
|
365
|
+
pkgRow: { display: 'flex', alignItems: 'center', gap: '8px', padding: '2px 4px', borderRadius: '4px', cursor: 'pointer' },
|
|
366
|
+
pkgName: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
|
367
|
+
pkgVer: { opacity: 0.5, fontSize: '11px', marginLeft: 'auto', flexShrink: 0 },
|
|
368
|
+
search: { padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '12.5px' },
|
|
317
369
|
}
|
|
318
370
|
|
|
319
371
|
function Toggle(props) {
|
|
@@ -427,6 +479,73 @@ window.__ModuleLoader__.load({
|
|
|
427
479
|
)
|
|
428
480
|
}
|
|
429
481
|
|
|
482
|
+
/**
|
|
483
|
+
* 勾选清单。
|
|
484
|
+
*
|
|
485
|
+
* 原来是两个 textarea,让用户一行一个包名敲进去。难用在两处:包名得照着
|
|
486
|
+
* node_modules 手抄,抄错一个字符这条规则就永远不生效、也不会报错;而且看不出
|
|
487
|
+
* 自己填的到底是不是想排除的那个。改成从 /state 拿到的已装清单直接勾。
|
|
488
|
+
*/
|
|
489
|
+
function PackagePicker(props) {
|
|
490
|
+
const { packages, selected, onChange } = props
|
|
491
|
+
const [query, setQuery] = useState('')
|
|
492
|
+
const chosen = useMemo(() => new Set(Array.isArray(selected) ? selected : []), [selected])
|
|
493
|
+
const all = useMemo(() => (Array.isArray(packages) ? packages : []), [packages])
|
|
494
|
+
const rows = useMemo(() => {
|
|
495
|
+
const text = query.trim().toLowerCase()
|
|
496
|
+
if (text === '') return all
|
|
497
|
+
return all.filter((item) => String(item.name).toLowerCase().includes(text))
|
|
498
|
+
}, [all, query])
|
|
499
|
+
|
|
500
|
+
const commit = (next) => onChange(Array.from(next).sort())
|
|
501
|
+
|
|
502
|
+
const toggle = (name) => {
|
|
503
|
+
const next = new Set(chosen)
|
|
504
|
+
if (next.has(name)) next.delete(name)
|
|
505
|
+
else next.add(name)
|
|
506
|
+
commit(next)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// 全选/清空只作用于当前筛选出来的行:搜索之后再点「全选」,
|
|
510
|
+
// 用户的意思是「把搜到的都勾上」,不是把看不见的也一并改掉。
|
|
511
|
+
const setVisible = (on) => {
|
|
512
|
+
const next = new Set(chosen)
|
|
513
|
+
for (const item of rows) {
|
|
514
|
+
if (on) next.add(item.name)
|
|
515
|
+
else next.delete(item.name)
|
|
516
|
+
}
|
|
517
|
+
commit(next)
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (all.length === 0) return h('span', { style: S.status }, T.pkgsEmpty)
|
|
521
|
+
|
|
522
|
+
return h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
|
|
523
|
+
h('div', { style: S.actions },
|
|
524
|
+
h('input', {
|
|
525
|
+
type: 'search',
|
|
526
|
+
value: query,
|
|
527
|
+
placeholder: T.pkgsSearch,
|
|
528
|
+
onChange: (event) => setQuery(event.target.value),
|
|
529
|
+
style: { ...S.search, flex: '1 1 160px' },
|
|
530
|
+
}),
|
|
531
|
+
h('button', { type: 'button', style: S.btn, onClick: () => setVisible(true) }, T.pkgsAll),
|
|
532
|
+
h('button', { type: 'button', style: S.btn, onClick: () => setVisible(false) }, T.pkgsNone),
|
|
533
|
+
h('span', { style: S.hint }, T.pkgsCount.replace('{n}', String(chosen.size))),
|
|
534
|
+
),
|
|
535
|
+
h('div', { style: S.pkgList },
|
|
536
|
+
rows.length === 0
|
|
537
|
+
? h('span', { style: { ...S.status, padding: '4px' } }, T.pkgsNoMatch)
|
|
538
|
+
: rows.map((item) => h('label', { key: item.name, style: S.pkgRow, title: item.name },
|
|
539
|
+
h(Toggle, { checked: chosen.has(item.name), onChange: () => toggle(item.name) }),
|
|
540
|
+
h('span', { style: S.pkgName }, item.name),
|
|
541
|
+
item.version === ''
|
|
542
|
+
? h('span', { style: S.pkgVer }, T.pkgsNotInstalled)
|
|
543
|
+
: h('span', { style: S.pkgVer }, item.version),
|
|
544
|
+
)),
|
|
545
|
+
),
|
|
546
|
+
)
|
|
547
|
+
}
|
|
548
|
+
|
|
430
549
|
function AutoUpdateCard() {
|
|
431
550
|
const [state, setState] = useState(null)
|
|
432
551
|
const [draft, setDraft] = useState(null)
|
|
@@ -460,13 +579,11 @@ window.__ModuleLoader__.load({
|
|
|
460
579
|
|
|
461
580
|
const dirty = useMemo(() => {
|
|
462
581
|
if (state === null || draft === null) return false
|
|
463
|
-
const keys = ['enabled', 'autoApply', 'hotReload', 'checkOnStart', 'idleOnly', 'intervalMinutes', 'firstDelayMinutes', 'allowMajor', 'allowPrerelease', 'scheduleMode', 'dailyAt', 'everyHours', 'everyDays', 'suppressHours', 'maxPerCycle', 'sessionIdleMinutes']
|
|
582
|
+
const keys = ['enabled', 'autoApply', 'hotReload', 'checkOnStart', 'idleOnly', 'notify', 'intervalMinutes', 'firstDelayMinutes', 'allowMajor', 'allowPrerelease', 'scheduleMode', 'dailyAt', 'everyHours', 'everyDays', 'suppressHours', 'maxPerCycle', 'sessionIdleMinutes']
|
|
464
583
|
for (const key of keys) {
|
|
465
584
|
if (draft[key] !== state.settings[key]) return true
|
|
466
585
|
}
|
|
467
|
-
|
|
468
|
-
if (String((draft[listKey] || []).join('\n')) !== String((state.settings[listKey] || []).join('\n'))) return true
|
|
469
|
-
}
|
|
586
|
+
if (String((draft.exclude || []).join('\n')) !== String((state.settings.exclude || []).join('\n'))) return true
|
|
470
587
|
return false
|
|
471
588
|
}, [state, draft])
|
|
472
589
|
|
|
@@ -481,10 +598,10 @@ window.__ModuleLoader__.load({
|
|
|
481
598
|
hotReload: draft.hotReload,
|
|
482
599
|
checkOnStart: draft.checkOnStart,
|
|
483
600
|
idleOnly: draft.idleOnly,
|
|
601
|
+
notify: draft.notify,
|
|
484
602
|
intervalMinutes: draft.intervalMinutes,
|
|
485
603
|
firstDelayMinutes: draft.firstDelayMinutes,
|
|
486
604
|
exclude: draft.exclude,
|
|
487
|
-
allow: draft.allow,
|
|
488
605
|
allowMajor: draft.allowMajor,
|
|
489
606
|
allowPrerelease: draft.allowPrerelease,
|
|
490
607
|
scheduleMode: draft.scheduleMode,
|
|
@@ -579,6 +696,7 @@ window.__ModuleLoader__.load({
|
|
|
579
696
|
h(SwitchRow, { label: T.hotReload, hint: T.hotReloadHint, value: draft.hotReload, onChange: (v) => patch('hotReload', v), disabled: !draft.enabled }),
|
|
580
697
|
h(SwitchRow, { label: T.checkOnStart, value: draft.checkOnStart, onChange: (v) => patch('checkOnStart', v), disabled: !draft.enabled }),
|
|
581
698
|
h(SwitchRow, { label: T.idleOnly, hint: T.idleOnlyHint, value: draft.idleOnly, onChange: (v) => patch('idleOnly', v), disabled: !draft.enabled }),
|
|
699
|
+
h(SwitchRow, { label: T.notify, hint: T.notifyHint, value: draft.notify, onChange: (v) => patch('notify', v) }),
|
|
582
700
|
),
|
|
583
701
|
h('div', { style: S.card },
|
|
584
702
|
h(SelectRow, {
|
|
@@ -613,32 +731,20 @@ window.__ModuleLoader__.load({
|
|
|
613
731
|
h(NumberRow, { label: T.sessionIdle, hint: T.sessionIdleHint, value: draft.sessionIdleMinutes, min: 0, max: 120, onChange: (v) => patch('sessionIdleMinutes', v), disabled: !draft.enabled || !draft.idleOnly }),
|
|
614
732
|
gateLine(state),
|
|
615
733
|
h('div', { style: S.labelBox },
|
|
616
|
-
h('span', { style: S.label }, T.
|
|
617
|
-
h('span', { style: S.hint }, T.
|
|
734
|
+
h('span', { style: S.label }, T.pkgsExclude),
|
|
735
|
+
h('span', { style: S.hint }, T.pkgsExcludeHint),
|
|
618
736
|
),
|
|
619
|
-
h(
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
onChange: (
|
|
623
|
-
style: S.area,
|
|
624
|
-
spellCheck: false,
|
|
737
|
+
h(PackagePicker, {
|
|
738
|
+
packages: state?.packages,
|
|
739
|
+
selected: draft.exclude,
|
|
740
|
+
onChange: (list) => patch('exclude', list),
|
|
625
741
|
}),
|
|
626
742
|
),
|
|
627
|
-
//
|
|
743
|
+
// 策略:预发布 / 跨大版本,决定「什么算可以装」。
|
|
628
744
|
h('div', { style: S.card },
|
|
629
745
|
h('span', { style: S.label }, T.policy),
|
|
630
746
|
h(SwitchRow, { label: T.allowMajor, hint: T.allowMajorHint, value: draft.allowMajor, onChange: (v) => patch('allowMajor', v) }),
|
|
631
747
|
h(SwitchRow, { label: T.allowPrerelease, hint: T.allowPrereleaseHint, value: draft.allowPrerelease, onChange: (v) => patch('allowPrerelease', v) }),
|
|
632
|
-
h('div', { style: S.labelBox },
|
|
633
|
-
h('span', { style: S.label }, T.allow),
|
|
634
|
-
h('span', { style: S.hint }, T.allowHint),
|
|
635
|
-
),
|
|
636
|
-
h('textarea', {
|
|
637
|
-
value: (draft.allow || []).join('\n'),
|
|
638
|
-
onChange: (event) => patch('allow', event.target.value.split('\n').map((line) => line.trim()).filter((line) => line !== '')),
|
|
639
|
-
style: S.area,
|
|
640
|
-
spellCheck: false,
|
|
641
|
-
}),
|
|
642
748
|
),
|
|
643
749
|
h('div', { style: S.actions },
|
|
644
750
|
h('button', { type: 'button', style: dirty ? S.btnPrimary : S.btn, disabled: !dirty || saving, onClick: () => void save() }, saving ? T.saving : T.save),
|
|
@@ -664,7 +770,7 @@ window.__ModuleLoader__.load({
|
|
|
664
770
|
h('span', { style: S.label }, T.history),
|
|
665
771
|
(state?.history?.length ?? 0) === 0
|
|
666
772
|
? h('span', { style: S.status }, T.historyEmpty)
|
|
667
|
-
: h('div', { style:
|
|
773
|
+
: h('div', { style: S.scrollList },
|
|
668
774
|
state.history.map((row, index) => h('div', {
|
|
669
775
|
key: row.name + '@' + row.at + ':' + index,
|
|
670
776
|
style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: '10px' },
|
|
@@ -724,14 +830,16 @@ window.__ModuleLoader__.load({
|
|
|
724
830
|
return () => clearInterval(timer)
|
|
725
831
|
}, [auto])
|
|
726
832
|
|
|
727
|
-
|
|
833
|
+
// 后端按追加顺序给(老的在前面),这里渲染时倒过来:最近发生的事在最上面,
|
|
834
|
+
// 打开这一栏先看到的应该是刚才装了什么,而不是要滚到底才看见。
|
|
835
|
+
const rows = (data?.rows ?? []).slice().reverse()
|
|
728
836
|
const total = data?.total ?? 0
|
|
729
837
|
|
|
730
838
|
return h('div', { style: S.card },
|
|
731
839
|
h('div', { style: S.row },
|
|
732
840
|
h('div', { style: S.labelBox },
|
|
733
841
|
h('span', { style: S.label }, T.logs),
|
|
734
|
-
h('span', { style: S.hint }, T.logsHint),
|
|
842
|
+
h('span', { style: S.hint }, T.logsHint + ' · ' + T.logsNewest),
|
|
735
843
|
),
|
|
736
844
|
h('div', { style: S.actions },
|
|
737
845
|
h('select', {
|
|
@@ -751,7 +859,7 @@ window.__ModuleLoader__.load({
|
|
|
751
859
|
? h('span', { style: S.status }, T.logsEmpty)
|
|
752
860
|
: h('pre', { style: S.logBox, title: data?.path || '' },
|
|
753
861
|
rows.map((row, index) => h('div', { key: index },
|
|
754
|
-
row.at ? h('span', { style: S.logTime },
|
|
862
|
+
row.at ? h('span', { style: S.logTime }, formatLogWhen(row.at) + ' ') : null,
|
|
755
863
|
h('span', { style: S.logText }, row.text),
|
|
756
864
|
)),
|
|
757
865
|
),
|
|
@@ -793,9 +901,114 @@ window.__ModuleLoader__.load({
|
|
|
793
901
|
return h('span', { style: { fontSize: '12px', opacity: 0.68 } }, text)
|
|
794
902
|
}
|
|
795
903
|
|
|
904
|
+
/* ── 更新提醒 ────────────────────────────────────────────────────────
|
|
905
|
+
*
|
|
906
|
+
* 定时更新最容易出的事,是它在后台悄悄装完,用户根本不知道装了什么。
|
|
907
|
+
* 这里轮询 /state,发现 lastRun 里有可更新项就在右下角浮一条提醒。
|
|
908
|
+
*
|
|
909
|
+
* 用原生 DOM 而不是再注册一个槽位:提醒要能在任何页面出现(会话、插件页、
|
|
910
|
+
* 设置页),而槽位只在宿主页挂载时才渲染。浮层还得幂等——同一批更新重复弹
|
|
911
|
+
* 三次比不弹更烦,所以把「已提醒过的批次」签名记进 localStorage。
|
|
912
|
+
*/
|
|
913
|
+
const NOTIFIED_KEY = 'dsh-aupdate:notified'
|
|
914
|
+
|
|
915
|
+
function notifiedMark() {
|
|
916
|
+
try { return window.localStorage.getItem(NOTIFIED_KEY) || '' } catch { return '' }
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function markNotified(sig) {
|
|
920
|
+
try { window.localStorage.setItem(NOTIFIED_KEY, sig) } catch {}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
let toastOpen = false
|
|
924
|
+
|
|
925
|
+
function showUpdateToast(updates) {
|
|
926
|
+
if (toastOpen) return
|
|
927
|
+
const doc = typeof document === 'undefined' ? null : document
|
|
928
|
+
if (doc === null || doc.body === null) return
|
|
929
|
+
toastOpen = true
|
|
930
|
+
const box = doc.createElement('div')
|
|
931
|
+
box.setAttribute('data-dsh-aupdate', 'toast')
|
|
932
|
+
box.style.cssText = [
|
|
933
|
+
'position:fixed', 'right:16px', 'bottom:16px', 'z-index:2147483000',
|
|
934
|
+
'max-width:340px', 'padding:12px 14px', 'border-radius:10px',
|
|
935
|
+
'background:rgba(28,28,30,0.97)', 'color:#f4f4f5',
|
|
936
|
+
'box-shadow:0 8px 28px rgba(0,0,0,0.38)', 'border:1px solid rgba(255,255,255,0.14)',
|
|
937
|
+
'font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif',
|
|
938
|
+
'display:flex', 'flex-direction:column', 'gap:8px',
|
|
939
|
+
].join(';')
|
|
940
|
+
|
|
941
|
+
const title = doc.createElement('div')
|
|
942
|
+
title.textContent = T.toastTitle.replace('{n}', String(updates.length))
|
|
943
|
+
title.style.cssText = 'font-weight:600'
|
|
944
|
+
box.appendChild(title)
|
|
945
|
+
|
|
946
|
+
const list = doc.createElement('div')
|
|
947
|
+
list.style.cssText = 'display:flex;flex-direction:column;gap:3px;max-height:180px;overflow:auto'
|
|
948
|
+
for (const item of updates.slice(0, 8)) {
|
|
949
|
+
const row = doc.createElement('div')
|
|
950
|
+
row.textContent = item.name + ' ' + (item.current || '?') + ' → ' + (item.target || '?')
|
|
951
|
+
row.style.cssText = 'font-size:12px;opacity:0.9;white-space:nowrap;overflow:hidden;text-overflow:ellipsis'
|
|
952
|
+
list.appendChild(row)
|
|
953
|
+
}
|
|
954
|
+
box.appendChild(list)
|
|
955
|
+
|
|
956
|
+
if (updates.length > 8) {
|
|
957
|
+
const more = doc.createElement('div')
|
|
958
|
+
more.textContent = T.toastMore.replace('{n}', String(updates.length - 8))
|
|
959
|
+
more.style.cssText = 'font-size:11.5px;opacity:0.6'
|
|
960
|
+
box.appendChild(more)
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
const close = doc.createElement('button')
|
|
964
|
+
close.type = 'button'
|
|
965
|
+
close.textContent = T.toastDismiss
|
|
966
|
+
close.style.cssText = 'align-self:flex-end;padding:3px 10px;border-radius:6px;border:1px solid rgba(255,255,255,0.25);background:transparent;color:inherit;cursor:pointer;font-size:12px'
|
|
967
|
+
const dismiss = () => {
|
|
968
|
+
toastOpen = false
|
|
969
|
+
try { box.remove() } catch {}
|
|
970
|
+
}
|
|
971
|
+
close.addEventListener('click', dismiss)
|
|
972
|
+
box.appendChild(close)
|
|
973
|
+
doc.body.appendChild(box)
|
|
974
|
+
// 不点也不会一直挂着:15 秒后自己消失,省得挡住下面的界面。
|
|
975
|
+
setTimeout(dismiss, 15000)
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function startUpdateNotifier() {
|
|
979
|
+
let stopped = false
|
|
980
|
+
let timer = null
|
|
981
|
+
const tick = async () => {
|
|
982
|
+
if (stopped) return
|
|
983
|
+
try {
|
|
984
|
+
const state = await getState()
|
|
985
|
+
if (state?.settings?.notify !== false) {
|
|
986
|
+
const updates = Array.isArray(state?.lastRun?.updates) ? state.lastRun.updates : []
|
|
987
|
+
if (updates.length > 0) {
|
|
988
|
+
const sig = updates.map((item) => item.name + '@' + (item.target || '')).sort().join('|')
|
|
989
|
+
if (sig !== notifiedMark()) {
|
|
990
|
+
markNotified(sig)
|
|
991
|
+
showUpdateToast(updates)
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
} catch {
|
|
996
|
+
// 读不到就等下一轮,提醒失败不该写日志也不该报错。
|
|
997
|
+
}
|
|
998
|
+
if (!stopped) timer = setTimeout(() => void tick(), 60000)
|
|
999
|
+
}
|
|
1000
|
+
void tick()
|
|
1001
|
+
return () => {
|
|
1002
|
+
stopped = true
|
|
1003
|
+
if (timer !== null) clearTimeout(timer)
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
796
1007
|
return {
|
|
797
1008
|
inject: ['slots'],
|
|
798
1009
|
apply(ctx) {
|
|
1010
|
+
// 提醒跟着插件一起上、一起卸:ctx.effect 收的是清理函数。
|
|
1011
|
+
if (typeof ctx.effect === 'function') ctx.effect(startUpdateNotifier, 'dsh-aupdate: update notices')
|
|
799
1012
|
// key 的格式是「包名#条目id」:本插件在 cordis.patch.yml 里的条目 id 就是包名本身,
|
|
800
1013
|
// 和 dsh-ops 的 dsh-ops#dsh-ops 一样。写成 #auto-update 之类是挂不上的。
|
|
801
1014
|
ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
|
|
@@ -808,6 +1021,15 @@ window.__ModuleLoader__.load({
|
|
|
808
1021
|
name: 'plugins.bundle.config',
|
|
809
1022
|
key: NS,
|
|
810
1023
|
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
1024
|
+
|
|
1025
|
+
// 设置 → 插件更新:挂成独立的一页,写法照抄 dsh-our-free-model-balance-zxp
|
|
1026
|
+
// 的「渠道余额」。原来只有插件页里那张卡,想改策略得先去插件页翻它。
|
|
1027
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
1028
|
+
name: 'settings.section',
|
|
1029
|
+
id: NS,
|
|
1030
|
+
order: 36,
|
|
1031
|
+
label: () => T.pageLabel,
|
|
1032
|
+
}, () => h(AutoUpdateCard)))
|
|
811
1033
|
},
|
|
812
1034
|
}
|
|
813
1035
|
},
|
package/index.js
CHANGED
|
@@ -32,7 +32,10 @@ const SESSION_IDLE_MINUTES = 2
|
|
|
32
32
|
/** 跨进程的安装锁:同一 profile 同时跑两个 pnpm 会抢锁失败。 */
|
|
33
33
|
const LOCK_STALE_MS = 30 * 60 * 1000
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
// 上一次运行结果从磁盘恢复。原来是纯内存的,DSH 一重启就没了:设置页明明刚装过
|
|
36
|
+
// 东西,却显示「还没跑过」——那是真的没记住,不是没跑。注意这是在模块加载期调用,
|
|
37
|
+
// 所以只能依赖函数声明(readLastRun/readJson 都提升),不能依赖下面的 const。
|
|
38
|
+
let lastRun = readLastRun()
|
|
36
39
|
let running = null
|
|
37
40
|
|
|
38
41
|
function oneLine(value, limit = 2000) {
|
|
@@ -88,6 +91,31 @@ function flushLog() {
|
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
/** 日志里的状态词翻译成人话——面板是给人看的,不留英文状态码。 */
|
|
95
|
+
const STATUS_TEXT = { done: '完成', blocked: '已让开', failed: '失败', skipped: '已跳过', none: '无', ok: '成功' }
|
|
96
|
+
|
|
97
|
+
function statusText(value) {
|
|
98
|
+
return STATUS_TEXT[String(value ?? '')] ?? String(value ?? '')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** 设置页提交的键名,日志里不该出现 enabled,autoApply 这种字面量。 */
|
|
102
|
+
const FIELD_LABELS = {
|
|
103
|
+
enabled: '定时检查', autoApply: '自动安装', hotReload: '就地生效', checkOnStart: '启动先查',
|
|
104
|
+
idleOnly: '忙时不动手', notify: '更新提醒', intervalMinutes: '检查间隔',
|
|
105
|
+
firstDelayMinutes: '首次延迟', exclude: '不更新的包', allowMajor: '跨大版本',
|
|
106
|
+
allowPrerelease: '预发布', scheduleMode: '调度方式', dailyAt: '每天时刻',
|
|
107
|
+
everyHours: '每几小时', everyDays: '每几天', suppressHours: '失败抑制',
|
|
108
|
+
maxPerCycle: '单轮上限', sessionIdleMinutes: '会话静默',
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function fieldLabel(key) {
|
|
112
|
+
return FIELD_LABELS[key] ?? String(key)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function yesNo(value) {
|
|
116
|
+
return value === true ? '开' : '关'
|
|
117
|
+
}
|
|
118
|
+
|
|
91
119
|
function writeLog(message) {
|
|
92
120
|
try {
|
|
93
121
|
console.log('[dsh-aupdate] ' + oneLine(message, 400))
|
|
@@ -219,9 +247,9 @@ function settingsPath() {
|
|
|
219
247
|
}
|
|
220
248
|
|
|
221
249
|
const OVERRIDEABLE = [
|
|
222
|
-
'enabled', 'autoApply', 'hotReload', 'checkOnStart', 'idleOnly',
|
|
250
|
+
'enabled', 'autoApply', 'hotReload', 'checkOnStart', 'idleOnly', 'notify',
|
|
223
251
|
'intervalMinutes', 'firstDelayMinutes', 'exclude',
|
|
224
|
-
'
|
|
252
|
+
'allowMajor', 'allowPrerelease',
|
|
225
253
|
// 调度:四种节奏 + 失败抑制时长。这些键不写进 Config schema,
|
|
226
254
|
// 只活在覆盖层里——Config 的字段类型是宿主校验的,加错一个类型
|
|
227
255
|
// 会在加载期直接抛错,而覆盖层是我们自己的文件,改坏了只影响这一项。
|
|
@@ -278,7 +306,7 @@ function writeOverrides(patch) {
|
|
|
278
306
|
for (const key of OVERRIDEABLE) {
|
|
279
307
|
if (patch === null || typeof patch !== 'object' || patch[key] === undefined) continue
|
|
280
308
|
const raw = patch[key]
|
|
281
|
-
if (key === 'exclude'
|
|
309
|
+
if (key === 'exclude') {
|
|
282
310
|
next[key] = stringList(raw)
|
|
283
311
|
continue
|
|
284
312
|
}
|
|
@@ -373,10 +401,12 @@ function settingsOf(config) {
|
|
|
373
401
|
hotReload: booleanSetting(config, 'hotReload', true),
|
|
374
402
|
checkOnStart: booleanSetting(config, 'checkOnStart', true),
|
|
375
403
|
idleOnly: booleanSetting(config, 'idleOnly', true),
|
|
404
|
+
// 发现可更新版本时是否弹出提醒。默认开着:定时更新最容易出的事,是它一直在
|
|
405
|
+
// 后台装,用户根本不知道装了什么、装到哪一版。
|
|
406
|
+
notify: booleanSetting(config, 'notify', true),
|
|
376
407
|
intervalMinutes: numberSetting(config, 'intervalMinutes', 1440, 10, 10080),
|
|
377
408
|
firstDelayMinutes: numberSetting(config, 'firstDelayMinutes', 5, 0, 1440),
|
|
378
409
|
exclude: stringList(config?.exclude),
|
|
379
|
-
allow: stringList(config?.allow),
|
|
380
410
|
// 默认允许跨大版本:这些都是 0.x 插件,按 semver 卡大版本等于几乎不更新。
|
|
381
411
|
allowMajor: booleanSetting(config, 'allowMajor', true),
|
|
382
412
|
// 默认不装预发布。注意:走 next 标签的包(@deepseek-ai/dsh-*)是显式选择,
|
|
@@ -410,7 +440,6 @@ const FIELDS = {
|
|
|
410
440
|
intervalMinutes: { type: 'number', meta: { default: 1440, description: '检查间隔(分钟)' } },
|
|
411
441
|
firstDelayMinutes: { type: 'number', meta: { default: 5, description: '启动后多久开始第一次' } },
|
|
412
442
|
exclude: { type: 'array', meta: { default: [], description: '不要自动更新的包' } },
|
|
413
|
-
allow: { type: 'array', meta: { default: [], description: '只更新这些包(留空表示全部)' } },
|
|
414
443
|
allowMajor: { type: 'boolean', meta: { default: true, description: '允许跨大版本更新' } },
|
|
415
444
|
allowPrerelease: { type: 'boolean', meta: { default: false, description: '允许安装预发布版本' } },
|
|
416
445
|
}
|
|
@@ -418,7 +447,7 @@ const FIELDS = {
|
|
|
418
447
|
const DICT = {
|
|
419
448
|
enabled: 1, autoApply: 2, hotReload: 3, checkOnStart: 4, idleOnly: 5,
|
|
420
449
|
intervalMinutes: 6, firstDelayMinutes: 7, exclude: 8,
|
|
421
|
-
|
|
450
|
+
allowMajor: 12, allowPrerelease: 13,
|
|
422
451
|
}
|
|
423
452
|
|
|
424
453
|
export const Config = {
|
|
@@ -432,7 +461,6 @@ export const Config = {
|
|
|
432
461
|
6: FIELDS.intervalMinutes,
|
|
433
462
|
7: FIELDS.firstDelayMinutes,
|
|
434
463
|
8: FIELDS.exclude,
|
|
435
|
-
11: FIELDS.allow,
|
|
436
464
|
12: FIELDS.allowMajor,
|
|
437
465
|
13: FIELDS.allowPrerelease,
|
|
438
466
|
10: { type: 'object', meta: { default: {} }, dict: DICT },
|
|
@@ -466,6 +494,52 @@ function historyPath() {
|
|
|
466
494
|
return join(dirname(settingsPath()), 'aupdate-history.json')
|
|
467
495
|
}
|
|
468
496
|
|
|
497
|
+
/**
|
|
498
|
+
* 上一次运行结果落盘。
|
|
499
|
+
*
|
|
500
|
+
* 「上一次」这张卡是设置页最有用的东西——它告诉你最近一轮什么时候跑、查了多少个、
|
|
501
|
+
* 装成了几个。但它是纯内存状态,DSH 一重启就归零,页面显示「还没跑过」,而磁盘上
|
|
502
|
+
* 明明有刚装好的包。所以照历史表的做法落一份在 ~/.dsh 下。
|
|
503
|
+
*
|
|
504
|
+
* 读的时候按字段逐个校验:这个文件可能是别的版本写的,缺字段就当默认值,
|
|
505
|
+
* 绝不因为一个坏文件让插件加载失败。
|
|
506
|
+
*/
|
|
507
|
+
function lastRunPath() {
|
|
508
|
+
return join(dirname(settingsPath()), 'aupdate-lastrun.json')
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function readLastRun() {
|
|
512
|
+
let raw = null
|
|
513
|
+
try {
|
|
514
|
+
raw = readJson(lastRunPath())
|
|
515
|
+
} catch {
|
|
516
|
+
return null
|
|
517
|
+
}
|
|
518
|
+
if (raw === null || typeof raw !== 'object') return null
|
|
519
|
+
if (typeof raw.at !== 'string' || raw.at === '') return null
|
|
520
|
+
const textList = (value) => (Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [])
|
|
521
|
+
return {
|
|
522
|
+
status: typeof raw.status === 'string' ? raw.status : 'unknown',
|
|
523
|
+
at: raw.at,
|
|
524
|
+
checked: Number.isFinite(raw.checked) ? raw.checked : 0,
|
|
525
|
+
updates: textList(raw.updates),
|
|
526
|
+
installed: textList(raw.installed),
|
|
527
|
+
reload: typeof raw.reload === 'string' ? raw.reload : 'none',
|
|
528
|
+
reason: typeof raw.reason === 'string' ? raw.reason : '',
|
|
529
|
+
snapshot: typeof raw.snapshot === 'string' ? raw.snapshot : '',
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function saveLastRun(value) {
|
|
534
|
+
try {
|
|
535
|
+
const file = lastRunPath()
|
|
536
|
+
mkdirSync(dirname(file), { recursive: true })
|
|
537
|
+
writeFileSync(file, JSON.stringify(value, null, 2) + '\n', 'utf8')
|
|
538
|
+
} catch {
|
|
539
|
+
// 记不住也不要紧,最坏的结果就是下次重启又显示「还没跑过」,不该影响更新本身。
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
469
543
|
// 和失败表一样按 mtime+size 判新旧:这个文件也在 ~/.dsh 下跨 profile 共用,
|
|
470
544
|
// 读到一次就永久缓存会让另一个进程刚写的记录在这边看不见。
|
|
471
545
|
let historyCache = { stamp: null, value: [] }
|
|
@@ -696,24 +770,51 @@ function readJson(file) {
|
|
|
696
770
|
}
|
|
697
771
|
|
|
698
772
|
/** 要被检查的依赖:dependencies 里非 link/file 的那些。 */
|
|
699
|
-
function dependencyList(profileDir, exclude
|
|
773
|
+
function dependencyList(profileDir, exclude) {
|
|
700
774
|
const manifest = readJson(join(profileDir, 'package.json'))
|
|
701
775
|
const deps = manifest?.dependencies
|
|
702
776
|
if (deps === null || typeof deps !== 'object') return []
|
|
703
777
|
const skip = new Set(exclude)
|
|
704
|
-
// 白名单非空时就是「只更新这些」;空数组表示不启用白名单。
|
|
705
|
-
const only = new Set(allow)
|
|
706
778
|
const rows = []
|
|
707
779
|
for (const [pkgName, spec] of Object.entries(deps)) {
|
|
708
780
|
if (typeof spec !== 'string') continue
|
|
709
781
|
if (/^(link|file|workspace|portal):/iu.test(spec)) continue
|
|
710
782
|
if (!NPM_NAME_RE.test(pkgName) || skip.has(pkgName)) continue
|
|
711
|
-
if (only.size > 0 && !only.has(pkgName)) continue
|
|
712
783
|
rows.push({ name: pkgName, spec })
|
|
713
784
|
}
|
|
714
785
|
return rows
|
|
715
786
|
}
|
|
716
787
|
|
|
788
|
+
/**
|
|
789
|
+
* 设置页的勾选清单。
|
|
790
|
+
*
|
|
791
|
+
* dependencyList 会按 exclude 过滤,而那正是勾选框要展示的东西——被排除的包
|
|
792
|
+
* 也必须出现在列表里,否则一旦勾上就再也取消不掉。所以这里不过滤,只给每一项
|
|
793
|
+
* 标注「当前是否被排除」,让页面自己决定勾没勾。
|
|
794
|
+
*/
|
|
795
|
+
function packageChoices(profileDir, settings) {
|
|
796
|
+
const manifest = readJson(join(profileDir, 'package.json'))
|
|
797
|
+
const deps = manifest?.dependencies
|
|
798
|
+
if (deps === null || typeof deps !== 'object') return []
|
|
799
|
+
const skip = new Set(settings.exclude)
|
|
800
|
+
const rows = []
|
|
801
|
+
for (const [name, spec] of Object.entries(deps)) {
|
|
802
|
+
if (typeof spec !== 'string') continue
|
|
803
|
+
if (/^(link|file|workspace|portal):/iu.test(spec)) continue
|
|
804
|
+
if (!NPM_NAME_RE.test(name)) continue
|
|
805
|
+
const version = installedVersion(profileDir, name, spec)
|
|
806
|
+
rows.push({
|
|
807
|
+
name,
|
|
808
|
+
version: typeof version === 'string' ? version : '',
|
|
809
|
+
excluded: skip.has(name),
|
|
810
|
+
})
|
|
811
|
+
}
|
|
812
|
+
// 不能直接用 localeCompare:它的结果跟着系统区域变,同一个 profile 在不同机器上
|
|
813
|
+
// 排出来的顺序会不一样,页面顺序跳来跳去会让人以为列表变了。
|
|
814
|
+
rows.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
|
|
815
|
+
return rows
|
|
816
|
+
}
|
|
817
|
+
|
|
717
818
|
/**
|
|
718
819
|
* 已装版本带缓存。
|
|
719
820
|
*
|
|
@@ -1015,7 +1116,7 @@ function snapshotProfile(profileDir, now) {
|
|
|
1015
1116
|
return { dir, files: saved }
|
|
1016
1117
|
} catch (error) {
|
|
1017
1118
|
// 留底失败不该拦住更新本身:它只是事后证据,不是前置条件。
|
|
1018
|
-
writeLog('
|
|
1119
|
+
writeLog('留快照失败:' + oneLine(error?.message ?? error, 200))
|
|
1019
1120
|
return null
|
|
1020
1121
|
}
|
|
1021
1122
|
}
|
|
@@ -1074,7 +1175,7 @@ function takeProfileLock(profileDir, now) {
|
|
|
1074
1175
|
} catch {}
|
|
1075
1176
|
try {
|
|
1076
1177
|
writeFileSync(file, stamp + '\n', { encoding: 'utf8', flag: 'wx' })
|
|
1077
|
-
writeLog('
|
|
1178
|
+
writeLog('接管了一个已挂 ' + ageMinutes + ' 分钟的安装锁')
|
|
1078
1179
|
return { ok: true, file }
|
|
1079
1180
|
} catch (error) {
|
|
1080
1181
|
return { ok: false, reason: '抢锁失败:' + oneLine(error?.message ?? error, 160) }
|
|
@@ -1196,7 +1297,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1196
1297
|
try {
|
|
1197
1298
|
const profileDir = profileDirOf(ctxRef.ctx)
|
|
1198
1299
|
const profileName = basename(profileDir)
|
|
1199
|
-
const deps = dependencyList(profileDir, settings.exclude
|
|
1300
|
+
const deps = dependencyList(profileDir, settings.exclude)
|
|
1200
1301
|
report.checked = deps.length
|
|
1201
1302
|
if (deps.length === 0) {
|
|
1202
1303
|
report.reason = '这个 profile 里没有可检查的依赖'
|
|
@@ -1244,7 +1345,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1244
1345
|
else report.skipped.push(answer)
|
|
1245
1346
|
}
|
|
1246
1347
|
}
|
|
1247
|
-
writeLog('
|
|
1348
|
+
writeLog('检查 ' + report.checked + ' 个插件,' + report.updates.length + ' 个可更新')
|
|
1248
1349
|
if (report.updates.length === 0) {
|
|
1249
1350
|
report.reason = '没有可更新的插件'
|
|
1250
1351
|
return report
|
|
@@ -1254,7 +1355,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1254
1355
|
const deferred = settings.maxPerCycle > 0 ? report.updates.length - settings.maxPerCycle : 0
|
|
1255
1356
|
if (deferred > 0) {
|
|
1256
1357
|
report.updates = report.updates.slice(0, settings.maxPerCycle)
|
|
1257
|
-
writeLog('
|
|
1358
|
+
writeLog('本轮限量装 ' + settings.maxPerCycle + ' 个,剩下 ' + deferred + ' 个下一轮再装')
|
|
1258
1359
|
}
|
|
1259
1360
|
if (mode === 'check' || !settings.autoApply) {
|
|
1260
1361
|
report.reason = '只查不装'
|
|
@@ -1269,7 +1370,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1269
1370
|
if (why.length > 0) {
|
|
1270
1371
|
report.status = 'blocked'
|
|
1271
1372
|
report.reason = why.join(';') + ',这一轮不安装'
|
|
1272
|
-
writeLog('
|
|
1373
|
+
writeLog('跳过安装:' + why.join(';'))
|
|
1273
1374
|
return report
|
|
1274
1375
|
}
|
|
1275
1376
|
}
|
|
@@ -1284,7 +1385,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1284
1385
|
if (!lock.ok) {
|
|
1285
1386
|
report.status = 'blocked'
|
|
1286
1387
|
report.reason = lock.reason
|
|
1287
|
-
writeLog('
|
|
1388
|
+
writeLog('跳过安装:' + lock.reason)
|
|
1288
1389
|
return report
|
|
1289
1390
|
}
|
|
1290
1391
|
try {
|
|
@@ -1292,7 +1393,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1292
1393
|
const snapshot = snapshotProfile(profileDir, new Date())
|
|
1293
1394
|
if (snapshot !== null) {
|
|
1294
1395
|
report.snapshot = snapshot.dir
|
|
1295
|
-
writeLog('
|
|
1396
|
+
writeLog('已留快照 ' + snapshot.dir + '(' + snapshot.files.join('、') + ')')
|
|
1296
1397
|
}
|
|
1297
1398
|
return await applyUpdates(ctxRef, report, settings, runner, profileDir, profileName)
|
|
1298
1399
|
} finally {
|
|
@@ -1301,7 +1402,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1301
1402
|
} catch (error) {
|
|
1302
1403
|
report.status = 'failed'
|
|
1303
1404
|
report.reason = oneLine(error?.message ?? error, 400)
|
|
1304
|
-
writeLog('
|
|
1405
|
+
writeLog('本轮失败:' + report.reason)
|
|
1305
1406
|
return report
|
|
1306
1407
|
} finally {
|
|
1307
1408
|
report.finishedAt = new Date().toISOString()
|
|
@@ -1315,6 +1416,7 @@ async function runCycle(mode, ctxRef) {
|
|
|
1315
1416
|
reason: report.reason,
|
|
1316
1417
|
snapshot: report.snapshot,
|
|
1317
1418
|
}
|
|
1419
|
+
saveLastRun(lastRun)
|
|
1318
1420
|
}
|
|
1319
1421
|
}
|
|
1320
1422
|
|
|
@@ -1329,7 +1431,7 @@ async function applyUpdates(ctxRef, report, settings, runner, profileDir, profil
|
|
|
1329
1431
|
for (const update of ordered) {
|
|
1330
1432
|
const outcome = await installOne(runner, profileName, profileDir, update.name, update.target)
|
|
1331
1433
|
report.installed.push(outcome)
|
|
1332
|
-
writeLog('
|
|
1434
|
+
writeLog('安装 ' + update.name + '@' + update.target + ' → ' + (outcome.ok ? '成功' : '失败:' + outcome.detail))
|
|
1333
1435
|
if (outcome.ok) {
|
|
1334
1436
|
clearFailure(update.name, update.target)
|
|
1335
1437
|
appendHistory({
|
|
@@ -1366,7 +1468,7 @@ async function applyUpdates(ctxRef, report, settings, runner, profileDir, profil
|
|
|
1366
1468
|
return report
|
|
1367
1469
|
}
|
|
1368
1470
|
report.reload = await hotApply(ctxRef.ctx, requiredBefore)
|
|
1369
|
-
writeLog('
|
|
1471
|
+
writeLog('就地生效 → ' + statusText(report.reload.status) + (report.reload.reason ? ':' + report.reload.reason : ''))
|
|
1370
1472
|
report.reason = '已安装 ' + okCount + ' 个;' + (report.reload.reason ?? '')
|
|
1371
1473
|
if (report.reload.status === 'failed') report.status = 'failed'
|
|
1372
1474
|
else if (report.reload.status === 'blocked' || report.reload.status === 'restart') report.status = 'partial'
|
|
@@ -1429,7 +1531,7 @@ async function rollbackOne(ctxRef, entryName) {
|
|
|
1429
1531
|
} finally {
|
|
1430
1532
|
releaseProfileLock(lock)
|
|
1431
1533
|
}
|
|
1432
|
-
writeLog('
|
|
1534
|
+
writeLog('回滚 ' + row.name + ' ' + row.to + ' → ' + row.from + ' → ' + (outcome.ok ? '成功' : '失败:' + outcome.detail))
|
|
1433
1535
|
if (!outcome.ok) return { ok: false, reason: outcome.detail }
|
|
1434
1536
|
const next = rows.slice()
|
|
1435
1537
|
next.unshift({
|
|
@@ -1513,14 +1615,14 @@ function registerTool(ctx, config) {
|
|
|
1513
1615
|
skipped: report.skipped.map((item) => item.name + ':' + item.why),
|
|
1514
1616
|
}
|
|
1515
1617
|
} catch (error) {
|
|
1516
|
-
writeLog('
|
|
1618
|
+
writeLog('工具调用失败:' + oneLine(error?.message ?? error, 300))
|
|
1517
1619
|
return { status: 'failed', reason: '没能完成,插件状态需要核对', checked: 0, updates: [], installed: [], reload: 'none' }
|
|
1518
1620
|
}
|
|
1519
1621
|
},
|
|
1520
1622
|
}), 'dsh-aupdate: plugin_updater')
|
|
1521
1623
|
return true
|
|
1522
1624
|
} catch (error) {
|
|
1523
|
-
writeLog('
|
|
1625
|
+
writeLog('无法提供工具:' + oneLine(error?.message ?? error, 300))
|
|
1524
1626
|
return false
|
|
1525
1627
|
}
|
|
1526
1628
|
}
|
|
@@ -1641,6 +1743,15 @@ function settingsSnapshot(config, ctxRef) {
|
|
|
1641
1743
|
reload: lastRun.reload,
|
|
1642
1744
|
snapshot: lastRun.snapshot ?? '',
|
|
1643
1745
|
},
|
|
1746
|
+
// 设置页把已装插件列成勾选框,用户勾就行,不用照着手抄包名。
|
|
1747
|
+
// 每项带上已装版本,勾的时候能看见自己勾的是哪个版本。
|
|
1748
|
+
packages: (() => {
|
|
1749
|
+
try {
|
|
1750
|
+
return packageChoices(profileDirOf(ctxRef?.ctx ?? null), settings)
|
|
1751
|
+
} catch {
|
|
1752
|
+
return []
|
|
1753
|
+
}
|
|
1754
|
+
})(),
|
|
1644
1755
|
path: settingsPath(),
|
|
1645
1756
|
history: readHistory().slice(0, 40),
|
|
1646
1757
|
historyPath: historyPath(),
|
|
@@ -1721,12 +1832,12 @@ function registerRoutes(scope, ctxRef) {
|
|
|
1721
1832
|
sendJson(res, 500, { error: result.error })
|
|
1722
1833
|
return
|
|
1723
1834
|
}
|
|
1724
|
-
writeLog('
|
|
1835
|
+
writeLog('设置页改了:' + Object.keys(body).map(fieldLabel).join('、'))
|
|
1725
1836
|
// 改完立刻按新设置重排,否则要等下一次触发才换节奏。
|
|
1726
1837
|
try {
|
|
1727
1838
|
if (typeof ctxRef.reschedule === 'function') ctxRef.reschedule()
|
|
1728
1839
|
} catch (error) {
|
|
1729
|
-
writeLog('
|
|
1840
|
+
writeLog('重排定时失败:' + oneLine(error?.message ?? error, 200))
|
|
1730
1841
|
}
|
|
1731
1842
|
sendJson(res, 200, settingsSnapshot(ctxRef.config, ctxRef))
|
|
1732
1843
|
return
|
|
@@ -1739,7 +1850,7 @@ function registerRoutes(scope, ctxRef) {
|
|
|
1739
1850
|
return
|
|
1740
1851
|
}
|
|
1741
1852
|
const outcome = await rollbackOne(ctxRef, target)
|
|
1742
|
-
writeLog('
|
|
1853
|
+
writeLog('收到回滚请求 ' + target + ' → ' + (outcome.ok ? '成功' : '失败:' + outcome.reason))
|
|
1743
1854
|
sendJson(res, outcome.ok ? 200 : 409, outcome)
|
|
1744
1855
|
return
|
|
1745
1856
|
}
|
|
@@ -1759,7 +1870,7 @@ function registerRoutes(scope, ctxRef) {
|
|
|
1759
1870
|
}
|
|
1760
1871
|
sendJson(res, 405, { error: 'method not allowed' })
|
|
1761
1872
|
} catch (error) {
|
|
1762
|
-
writeLog('
|
|
1873
|
+
writeLog('接口处理出错:' + oneLine(error?.message ?? error, 300))
|
|
1763
1874
|
try { sendJson(res, 500, { error: 'internal' }) } catch {}
|
|
1764
1875
|
}
|
|
1765
1876
|
}
|
|
@@ -1768,14 +1879,14 @@ function registerRoutes(scope, ctxRef) {
|
|
|
1768
1879
|
const register = () => webServer.register({ kind: 'prefix', path: ROUTE_PREFIX, handler })
|
|
1769
1880
|
if (typeof effect === 'function') {
|
|
1770
1881
|
effect.call(scope, register, 'dsh-aupdate: settings routes')
|
|
1771
|
-
writeLog('
|
|
1882
|
+
writeLog('设置接口已就绪:' + ROUTE_PREFIX)
|
|
1772
1883
|
return true
|
|
1773
1884
|
}
|
|
1774
1885
|
register()
|
|
1775
|
-
writeLog('
|
|
1886
|
+
writeLog('设置接口已就绪(没有 effect 作用域):' + ROUTE_PREFIX)
|
|
1776
1887
|
return true
|
|
1777
1888
|
} catch (error) {
|
|
1778
|
-
writeLog('
|
|
1889
|
+
writeLog('无法注册设置接口:' + oneLine(error?.message ?? error, 300))
|
|
1779
1890
|
return false
|
|
1780
1891
|
}
|
|
1781
1892
|
}
|
|
@@ -1794,15 +1905,15 @@ export function apply(ctx, config) {
|
|
|
1794
1905
|
try {
|
|
1795
1906
|
const tools = serviceOf(scope, 'tools')
|
|
1796
1907
|
if (tools === null || typeof tools.register !== 'function') {
|
|
1797
|
-
writeLog('
|
|
1908
|
+
writeLog('工具注册失败')
|
|
1798
1909
|
return
|
|
1799
1910
|
}
|
|
1800
1911
|
if (toolService === tools) return
|
|
1801
1912
|
toolService = tools
|
|
1802
1913
|
const ok = registerTool(scope, config)
|
|
1803
|
-
writeLog('
|
|
1914
|
+
writeLog('工具注册:' + (ok ? '成功' : '失败'))
|
|
1804
1915
|
} catch (error) {
|
|
1805
|
-
writeLog('
|
|
1916
|
+
writeLog('注册工具时抛错:' + oneLine(error?.message ?? error, 300))
|
|
1806
1917
|
}
|
|
1807
1918
|
}
|
|
1808
1919
|
// 路由和工具是同一类问题:apply 执行时 webServer 可能还没就绪,
|
|
@@ -1812,14 +1923,14 @@ export function apply(ctx, config) {
|
|
|
1812
1923
|
try {
|
|
1813
1924
|
const webServer = serviceOf(scope, 'webServer')
|
|
1814
1925
|
if (webServer === null || typeof webServer.register !== 'function') {
|
|
1815
|
-
writeLog('webServer
|
|
1926
|
+
writeLog('没有 webServer 服务,设置页会显示不可用')
|
|
1816
1927
|
return
|
|
1817
1928
|
}
|
|
1818
1929
|
if (routeService === webServer) return
|
|
1819
1930
|
const ok = registerRoutes(scope, ctxRef)
|
|
1820
1931
|
if (ok) routeService = webServer
|
|
1821
1932
|
} catch (error) {
|
|
1822
|
-
writeLog('
|
|
1933
|
+
writeLog('注册设置接口时抛错:' + oneLine(error?.message ?? error, 300))
|
|
1823
1934
|
}
|
|
1824
1935
|
}
|
|
1825
1936
|
const inject = propOf(ctx, 'inject')
|
|
@@ -1833,10 +1944,10 @@ export function apply(ctx, config) {
|
|
|
1833
1944
|
offerRoutes(scope)
|
|
1834
1945
|
})
|
|
1835
1946
|
Promise.resolve(fiber).catch((error) => {
|
|
1836
|
-
writeLog('
|
|
1947
|
+
writeLog('工具作用域已结束:' + oneLine(error?.message ?? error, 300))
|
|
1837
1948
|
})
|
|
1838
1949
|
} catch (error) {
|
|
1839
|
-
writeLog('
|
|
1950
|
+
writeLog('无法提供工具:' + oneLine(error?.message ?? error, 300))
|
|
1840
1951
|
offerTool(ctx)
|
|
1841
1952
|
offerRoutes(ctx)
|
|
1842
1953
|
}
|
|
@@ -1849,9 +1960,9 @@ export function apply(ctx, config) {
|
|
|
1849
1960
|
const go = async () => {
|
|
1850
1961
|
try {
|
|
1851
1962
|
const report = await beginningRun(mode, ctxRef)
|
|
1852
|
-
if (report !== null) writeLog('
|
|
1963
|
+
if (report !== null) writeLog('本轮' + (mode === 'check' ? '检查' : '更新') + ' → ' + statusText(report.status) + ':' + report.reason)
|
|
1853
1964
|
} catch (error) {
|
|
1854
|
-
writeLog('
|
|
1965
|
+
writeLog('本轮抛错:' + oneLine(error?.message ?? error, 300))
|
|
1855
1966
|
}
|
|
1856
1967
|
}
|
|
1857
1968
|
void go()
|
|
@@ -1886,7 +1997,7 @@ export function apply(ctx, config) {
|
|
|
1886
1997
|
clearScheduled()
|
|
1887
1998
|
const live = settingsOf(ctxRef.config)
|
|
1888
1999
|
if (!live.enabled) {
|
|
1889
|
-
writeLog('
|
|
2000
|
+
writeLog('设置里已关闭自动更新,定时器待命')
|
|
1890
2001
|
return
|
|
1891
2002
|
}
|
|
1892
2003
|
// 启动后第一次仍然只看 firstDelayMinutes,之后按当前调度模式算。
|
|
@@ -1920,7 +2031,7 @@ export function apply(ctx, config) {
|
|
|
1920
2031
|
|
|
1921
2032
|
// 设置页要能读到运行状态并改设置,所以路由最后注册、且与 enabled 无关:
|
|
1922
2033
|
// 关掉定时检查之后,用户仍然要能看到这一页并把它重新打开。
|
|
1923
|
-
if (!settings.enabled) writeLog('
|
|
2034
|
+
if (!settings.enabled) writeLog('配置里已关闭自动更新,定时器待命,设置页仍然可用')
|
|
1924
2035
|
|
|
1925
2036
|
const stop = () => {
|
|
1926
2037
|
for (const off of timers.splice(0)) {
|
|
@@ -1936,7 +2047,7 @@ export function apply(ctx, config) {
|
|
|
1936
2047
|
} catch {}
|
|
1937
2048
|
}
|
|
1938
2049
|
|
|
1939
|
-
writeLog('
|
|
2050
|
+
writeLog('已就绪:每 ' + settings.intervalMinutes + ' 分钟检查一次,自动安装=' + yesNo(settings.autoApply) + ',就地生效=' + yesNo(settings.hotReload))
|
|
1940
2051
|
}
|
|
1941
2052
|
|
|
1942
2053
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-aupdate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "定时检查 DSH
|
|
5
|
+
"description": "定时检查 DSH 插件更新,串行安装后就地生效,不重启;支持多种调度节奏、失败抑制、按包回滚,并在动手前留快照、忙时自动让开;不更新/只更新哪些插件改成勾选,发现更新在右下角提醒,日志最新在最上面,并在「设置 → 插件更新」里有独立一页。",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|