dsh-plugin-update-all 0.0.0-stage → 1.0.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.
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: plugin-update
3
+ name: 'dsh-plugin-update-all'
package/icon.svg ADDED
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" aria-hidden="true">
2
+ <!-- Update all: a refresh ring around the rows it refreshes. -->
3
+ <g fill="none" stroke="#2e6bd6" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
4
+ <path d="M25.78 10.22A11 11 0 1 1 18 7" />
5
+ <path d="M17.4 4.4 22.6 7 17.4 9.6" />
6
+ </g>
7
+ <g fill="#8ca9e6">
8
+ <rect x="13.9" y="12.5" width="8.2" height="2.6" rx="1.3" />
9
+ <rect x="15.3" y="16.7" width="5.4" height="2.6" rx="1.3" />
10
+ <rect x="16.7" y="20.9" width="2.6" height="2.6" rx="1.3" />
11
+ </g>
12
+ </svg>
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Host half of the Update all bundle: nothing to do.
3
+ *
4
+ * The feature is entirely a browser contribution — the tab registers into the
5
+ * Plugins page's `plugins.tab` slot and reaches the Host through the existing
6
+ * `pluginManager` Remote (`listBundles`, `listVersions`, `updateBundle`). This
7
+ * row exists so the bundle has a profile entry Plugin Manager can list,
8
+ * enable, and disable, and so the Client half is composed with it.
9
+ */
10
+ export function apply() {}
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Update all",
4
+ "description": "Adds an Updates tab to the Plugins page: one run checks every installed plugin for a compatible newer release and updates the outdated ones. Only third-party plugins installed from an install registry are updated; Git and local installs are listed as skipped. Each update replaces the installed version with the new one, keeps or reinstalls the current version when the installation fails, and needs a page reload (or a DSH restart) to take effect."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "全部更新",
4
+ "description": "在「插件」页面加入「更新」视图:一键检查所有已安装插件的可用新版本,再一次更新需要更新的插件。只处理从安装源安装的第三方插件(Git 与本地安装会标示为跳过);每一项更新会以新版本替换当前版本,安装失败时会保留或重新安装当前版本,更新后需重新加载页面或重启 DSH 才生效。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "dsh-plugin-update-all",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Adds an Updates tab to the Plugins page that checks every installed plugin and updates the outdated ones in one run.",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "dsh",
8
+ "dsh-plugin",
9
+ "deepseek-harness",
10
+ "deepseek",
11
+ "plugin-manager",
12
+ "update"
13
+ ],
14
+ "engines": {
15
+ "dsh": ">=0.2.2-rc.3"
16
+ },
17
+ "type": "module",
18
+ "exports": {
19
+ ".": "./index.js",
20
+ "./client": "./client.js",
21
+ "./locale/*.json": "./locale/*.json",
22
+ "./icon": "./icon.svg"
23
+ },
24
+ "files": [
25
+ "index.js",
26
+ "client.js",
27
+ "cordis.patch.yml",
28
+ "locale/*.json",
29
+ "icon.svg",
30
+ "README.md",
31
+ "README.zh.md",
32
+ "LICENSE",
33
+ "test"
34
+ ],
35
+ "dsh": {
36
+ "bundle": { "patch": "./cordis.patch.yml" },
37
+ "client": {
38
+ "platform": "web",
39
+ "immediately": true
40
+ }
41
+ }
42
+ }
package/test/json.cjs ADDED
@@ -0,0 +1,13 @@
1
+ // Probe helper: validate UTF-8 JSON files.
2
+ const fs = require('node:fs')
3
+ let failed = false
4
+ for (const file of process.argv.slice(2)) {
5
+ try {
6
+ JSON.parse(fs.readFileSync(file, 'utf8'))
7
+ console.log('OK ' + file)
8
+ } catch (error) {
9
+ failed = true
10
+ console.log('FAIL ' + file + ' :: ' + error.message)
11
+ }
12
+ }
13
+ process.exitCode = failed ? 1 : 0
package/test/smoke.cjs ADDED
@@ -0,0 +1,354 @@
1
+ // Headless smoke test for the Update all client half.
2
+ //
3
+ // Loads the real client.js through a stub module loader, stubs React with a
4
+ // tree-walking renderer, and drives the controller against a fake
5
+ // `pluginManager` Remote. Sections:
6
+ // 1. the flow — check pass, confirmation, serial update pass, every outcome,
7
+ // the Host step wiring, and stopping after the current plugin;
8
+ // 2. render audit — the states the fake Host cannot reach, rendered from a
9
+ // snapshot, to prove every phase has its copy;
10
+ // 3. dictionaries — both languages cover the same keys, and every key shows.
11
+ //
12
+ // Run it from the package root: `node test/smoke.cjs`.
13
+ const path = require('node:path')
14
+
15
+ let spec
16
+ globalThis.window = { __ModuleLoader__: { load(registered) { spec = registered } } }
17
+ require(path.join(__dirname, '..', 'client.js'))
18
+
19
+ const failures = []
20
+ const check = (condition, label, detail) => {
21
+ if (condition) { console.log(' ok ' + label); return }
22
+ failures.push(label)
23
+ console.log(' FAIL ' + label + (detail === undefined ? '' : ' :: ' + JSON.stringify(detail)))
24
+ }
25
+
26
+ // --- React stub -----------------------------------------------------------
27
+ function createElement(type, props, ...children) {
28
+ return { type, props: props === null || props === undefined ? {} : props, children: children.flat(Infinity) }
29
+ }
30
+ const usedKeys = new Set()
31
+ const ReactStub = {
32
+ createElement,
33
+ useEffect(effect) { effect() },
34
+ useSyncExternalStore(_subscribe, getSnapshot) { return getSnapshot() },
35
+ }
36
+
37
+ function render(node) {
38
+ if (node === null || node === undefined || node === false || node === true) return null
39
+ if (Array.isArray(node)) return node.map(render)
40
+ if (typeof node === 'string' || typeof node === 'number') return String(node)
41
+ const props = Object.assign({}, node.props, { children: node.children })
42
+ if (typeof node.type === 'function') return render(node.type(props))
43
+ return { type: node.type, props: node.props, children: node.children.map(render) }
44
+ }
45
+
46
+ /** Every text leaf of the rendered tree, in order. */
47
+ function texts(node, out) {
48
+ if (node === null || node === undefined) return out
49
+ if (Array.isArray(node)) { for (const item of node) texts(item, out); return out }
50
+ if (typeof node === 'string') { if (node.trim() !== '') out.push(node); return out }
51
+ texts(node.children, out)
52
+ return out
53
+ }
54
+
55
+ /** Every rendered button, so the controls are asserted and not just the copy. */
56
+ function buttons(node, out) {
57
+ if (node === null || node === undefined) return out
58
+ if (Array.isArray(node)) { for (const item of node) buttons(item, out); return out }
59
+ if (typeof node === 'string') return out
60
+ if (node.type === 'button') out.push({ text: texts(node.children, []).join(' '), disabled: node.props.disabled === true, autoFocus: node.props.autoFocus === true })
61
+ buttons(node.children, out)
62
+ return out
63
+ }
64
+
65
+ // --- Fake Remote ----------------------------------------------------------
66
+ const bundle = (overrides) => Object.assign({
67
+ name: 'pkg', official: false, availability: 'profile', enabled: true, installed: true,
68
+ optional: false, removable: true, rows: [], overrides: [],
69
+ }, overrides)
70
+
71
+ const version = (number, overrides) => Object.assign({ version: number, tags: [], prerelease: false, bundle: true }, overrides)
72
+ const listed = (installed, versions) => ({ status: 'listed', installed, registry: 'https://registry.npmjs.org/', attempts: [], omitted: 0, versions })
73
+
74
+ /** One registry plugin with a newer release, plus the Host answer that update returns for it. */
75
+ const registry = (name, installed, versions, answer) => ({ bundle: bundle({ name, update: 'registry', version: installed, meta: { title: name } }), list: listed(installed, versions), answer })
76
+
77
+ const outdated = registry('pkg-outdated', '1.0.0', [version('1.3.0', { prerelease: true }), version('1.2.0'), version('1.1.0', { deprecated: 'old' })], { kind: 'applied' })
78
+ const restored = registry('pkg-fails', '2.0.0', [version('2.1.0')], { kind: 'restored' })
79
+ const restarting = registry('pkg-third', '3.0.0', [version('3.1.0')], { kind: 'restart' })
80
+ const checkRefused = registry('pkg-check-refused', '4.0.0', [version('4.1.0')], { kind: 'check-refused' })
81
+ const removeFailed = registry('pkg-remove-failed', '5.0.0', [version('5.1.0')], { kind: 'remove-failed' })
82
+ const installFailed = registry('pkg-install-failed', '6.0.0', [version('6.1.0')], { kind: 'install-failed' })
83
+ const broken = registry('pkg-broken', '7.0.0', [version('7.1.0')], { kind: 'broken' })
84
+ const current = registry('pkg-latest', '8.0.0', [], { kind: 'applied' })
85
+ const blockedIncompatible = registry('pkg-blocked', '9.0.0', [
86
+ version('10.0.0', { incompatible: { name: 'pkg-blocked', version: '10.0.0', runtimeVersion: '0.2.2-rc.3', requirements: { '@deepseek-ai/dsh': '^0.3.0' } } }),
87
+ ], { kind: 'applied' })
88
+ const blockedPrerelease = registry('pkg-prerelease-only', '11.0.0', [version('12.0.0', { prerelease: true })], { kind: 'applied' })
89
+
90
+ const sub = [outdated, restored, restarting, checkRefused, removeFailed, installFailed, broken, current, blockedIncompatible, blockedPrerelease]
91
+
92
+ const bundles = [
93
+ bundle({ name: 'dsh-plugin-update-all', update: 'registry', version: '1.0.0', meta: { title: '全部更新' } }),
94
+ ...sub.map(item => item.bundle),
95
+ bundle({ name: 'pkg-git', update: 'git', version: '0.4.0' }),
96
+ bundle({ name: 'pkg-link', version: '0.0.1', source: 'link:C:/x' }),
97
+ bundle({ name: 'pkg-managed', readOnlyReason: 'management-required', version: '0.0.2' }),
98
+ bundle({ name: 'pkg-missing', update: 'registry', availability: 'missing', version: '0.0.3' }),
99
+ bundle({ name: 'pkg-noversion', update: 'registry' }),
100
+ bundle({ name: 'pkg-nolist', update: 'registry', version: '0.0.6' }),
101
+ bundle({ name: 'pkg-shipped', availability: 'installation', version: '0.0.4' }),
102
+ bundle({ name: 'pkg-official', official: true, version: '0.0.5' }),
103
+ bundle({ name: '@deepseek-ai/dsh-optional', installed: false, availability: 'installation', version: '9.9.9' }),
104
+ ]
105
+
106
+ const lists = new Map(sub.map(item => [item.bundle.name, item.list]))
107
+ const answers = new Map(sub.map(item => [item.bundle.name, item.answer]))
108
+
109
+ const changes = {
110
+ applied: (name, target) => ({ changed: true, application: 'applied', stage: 'install', target }),
111
+ restart: (name, target) => ({ changed: true, application: 'restart-required', restartReason: 'host-module', stage: 'install', target }),
112
+ failed: (name, target) => ({ changed: false, application: 'failed', stage: 'install', target, error: { code: 'operation-error', diagnostic: 'pnpm said no' } }),
113
+ restored: (name, target) => ({ changed: true, application: 'applied', stage: 'install', target }),
114
+ }
115
+
116
+ let stepHook = null
117
+ const updates = []
118
+ let updateDelayMs = 0
119
+ const remote = {
120
+ pluginManager: {
121
+ async listBundles() { return { ok: true, value: bundles } },
122
+ async listVersions(name) {
123
+ const list = lists.get(name)
124
+ return list === undefined
125
+ ? { ok: true, value: { status: 'refused', problem: 'network', reason: 'offline', attempts: [] } }
126
+ : { ok: true, value: list }
127
+ },
128
+ async updateBundle(name, target, options) {
129
+ updates.push({ name, target, registry: options.registry, hasRequestId: typeof options.requestId === 'string' })
130
+ if (updateDelayMs > 0) await new Promise(resolve => setTimeout(resolve, updateDelayMs))
131
+ if (stepHook !== null) stepHook(options.requestId)
132
+ const answer = answers.get(name)
133
+ const kind = answer === undefined ? 'applied' : answer.kind
134
+ const from = (answer === undefined ? '0.0.0' : lists.get(name).installed)
135
+ if (kind === 'check-refused') {
136
+ return { ok: true, value: { from, to: target, step: 'check', result: changes.failed(name, name) } }
137
+ }
138
+ if (kind === 'remove-failed') {
139
+ return { ok: true, value: { from, to: target, step: 'remove', result: changes.failed(name, name) } }
140
+ }
141
+ if (kind === 'install-failed') {
142
+ return { ok: true, value: { from, to: target, step: 'install', result: changes.failed(name, target) } }
143
+ }
144
+ if (kind === 'broken') {
145
+ return { ok: true, value: { from, to: target, step: 'install', result: changes.failed(name, target), restore: changes.failed(name, name) } }
146
+ }
147
+ if (kind === 'restored') {
148
+ return { ok: true, value: { from, to: target, step: 'install', result: changes.failed(name, target), restore: changes.restored(name, name) } }
149
+ }
150
+ if (kind === 'restart') {
151
+ return { ok: true, value: { from, to: target, step: 'install', result: changes.restart(name, target) } }
152
+ }
153
+ return { ok: true, value: { from, to: target, step: 'install', result: changes.applied(name, target) } }
154
+ },
155
+ },
156
+ $on(event, handler) { stepListeners.push({ event, handler }); return () => {} },
157
+ }
158
+ const stepListeners = []
159
+
160
+ // --- Fake context ---------------------------------------------------------
161
+ let dictionaries
162
+ let registered
163
+ const bind = (language) => (key, params) => {
164
+ usedKeys.add(key)
165
+ const text = dictionaries[language][key]
166
+ if (text === undefined) return 'MISSING:' + key
167
+ return params === undefined ? text : text.replace(/\{(\w+)\}/g, (_match, name) => (params[name] === undefined ? '{' + name + '}' : String(params[name])))
168
+ }
169
+ const ctx = {
170
+ effect(factory) { const dispose = factory(); return typeof dispose === 'function' ? dispose : () => {} },
171
+ locale: {
172
+ register(_ns, dicts) { dictionaries = dicts; return () => {} },
173
+ bind() { return bind('zh') },
174
+ resolveText(text) {
175
+ if (typeof text === 'string') return text
176
+ if (text === null || typeof text !== 'object') return ''
177
+ return text.zh === undefined ? String(text.en === undefined ? '' : text.en) : String(text.zh)
178
+ },
179
+ },
180
+ remote,
181
+ slots: {
182
+ inject(_owner, factory) { factory() },
183
+ register(options, Component) { registered = { options, Component }; return () => {} },
184
+ },
185
+ }
186
+
187
+ const settle = (milliseconds = 40) => new Promise(resolve => setTimeout(resolve, milliseconds))
188
+ const noMissing = (label, list) => check(!list.some(text => text.includes('MISSING:')), label + ': copy present', list.filter(text => text.includes('MISSING:')))
189
+
190
+ async function main() {
191
+ console.log('factory')
192
+ check(spec !== undefined && spec.id === 'dsh-plugin-update-all', 'registers under its package id', spec && spec.id)
193
+ const plugin = spec.factory((id) => {
194
+ if (id === 'react') return ReactStub
195
+ throw new Error('unexpected module ' + id)
196
+ })
197
+ check(Array.isArray(plugin.inject) && plugin.inject.includes('remote.pluginManager'), 'injects the pluginManager Remote', plugin.inject)
198
+
199
+ plugin.apply(ctx)
200
+ check(registered.options.name === 'plugins.tab' && registered.options.id === 'update-all', 'registers into plugins.tab', registered.options)
201
+ check(registered.options.label() === '更新', 'labels the tab', registered.options.label())
202
+ check(registered.options.locale === 'updateAll', 'binds its locale namespace')
203
+ check(stepListeners.some(item => item.event === 'plugin-manager/update-state'), 'follows the Host update steps')
204
+
205
+ const controller = registered.options.inject().controller
206
+ const onScreen = () => render(registered.Component({ t: ctx.locale.bind('updateAll'), controller }))
207
+
208
+ console.log('\nfirst render (idle)')
209
+ const idleButtons = buttons(onScreen(), [])
210
+ check(idleButtons.some(button => button.text === '检查更新'), 'offers a first check', idleButtons)
211
+ check(!idleButtons.some(button => button.text.startsWith('全部更新')), 'offers no update before the check', idleButtons)
212
+
213
+ console.log('\ncheck pass')
214
+ await settle()
215
+ const checked = controller.getSnapshot()
216
+ check(checked.phase === 'ready', 'settles on ready', checked.phase)
217
+ check(checked.candidates.length === 7, 'finds the seven outdated packages', checked.candidates.map(item => item.name))
218
+ check(checked.candidates[0].to === '1.2.0', 'picks the newest installable release', checked.candidates[0])
219
+ check(checked.latest.length === 1 && checked.latest[0] === 'pkg-latest', 'counts the current package', checked.latest)
220
+ const reasons = Object.fromEntries(checked.skipped.map(item => [item.name, item.reason]))
221
+ check(reasons['pkg-git'] === 'git', 'reports git separately', reasons)
222
+ check(reasons['pkg-link'] === 'local', 'reports a local install', reasons)
223
+ check(reasons['pkg-managed'] === 'managed', 'reports a managed plugin', reasons)
224
+ check(reasons['pkg-missing'] === 'missing', 'reports missing files', reasons)
225
+ check(reasons['pkg-noversion'] === 'noVersion', 'reports an unreadable version', reasons)
226
+ check(reasons['pkg-shipped'] === 'shipped', 'reports a shipped bundle', reasons)
227
+ check(reasons['pkg-official'] === 'official', 'reports an official plugin', reasons)
228
+ check(!('dsh-plugin-update-all' in reasons), 'hides itself', Object.keys(reasons))
229
+ check(!('@deepseek-ai/dsh-optional' in reasons), 'ignores installation bundles', Object.keys(reasons))
230
+ check(checked.blocked.length === 2, 'lists releases it will not install', checked.blocked.map(item => item.name))
231
+ check(checked.blocked.some(item => item.reason === 'incompatible' && item.peers.includes('@deepseek-ai/dsh')), 'names the DSH requirement', checked.blocked)
232
+ check(checked.blocked.some(item => item.reason === 'notInstallable'), 'reports a prerelease-only package', checked.blocked)
233
+
234
+ console.log('\nready render')
235
+ const readyTexts = texts(onScreen(), [])
236
+ noMissing('ready', readyTexts)
237
+ check(buttons(onScreen(), []).some(button => button.text === '全部更新(7)'), 'offers the batch update', buttons(onScreen(), []))
238
+ check(readyTexts.some(text => text.includes('7 个可更新')), 'summarizes the check', readyTexts)
239
+ check(readyTexts.some(text => text.includes('2 个有新版本但无法更新')), 'surfaces the blocked releases', readyTexts)
240
+ check(readyTexts.some(text => text.includes('8 个已跳过')), 'surfaces the skipped packages', readyTexts)
241
+
242
+ console.log('\nconfirmation')
243
+ controller.askConfirm()
244
+ check(controller.getSnapshot().phase === 'confirm', 'asks before updating', controller.getSnapshot().phase)
245
+ const confirmTexts = texts(onScreen(), [])
246
+ const confirmButtons = buttons(onScreen(), [])
247
+ check(confirmTexts.some(text => text.includes('更新这 7 个插件?')), 'names what it will update', confirmTexts)
248
+ check(confirmButtons.some(button => button.text === '开始更新 7 个' && button.autoFocus === true), 'focuses the confirm control', confirmButtons)
249
+ const confirmOrder = confirmButtons.map(button => button.text)
250
+ check(confirmOrder.indexOf('取消') < confirmOrder.indexOf('开始更新 7 个'), 'puts cancel before the primary action', confirmOrder)
251
+
252
+ console.log('\nupdate pass (every outcome)')
253
+ const stepsSeen = []
254
+ stepHook = (requestId) => {
255
+ for (const step of ['checking', 'removing', 'installing', 'restoring']) {
256
+ for (const listener of stepListeners) {
257
+ if (listener.event === 'plugin-manager/update-state') listener.handler({ requestId, step })
258
+ }
259
+ stepsSeen.push(controller.getSnapshot().run.step)
260
+ noMissing('running', texts(onScreen(), []))
261
+ }
262
+ }
263
+ controller.runUpdate()
264
+ await settle(10)
265
+ check(updates.length > 0 && updates.every(item => item.hasRequestId), 'names its update request', updates)
266
+ await settle(80)
267
+ stepHook = null
268
+ check(stepsSeen.slice(0, 4).join(',') === 'checking,removing,installing,restoring', 'follows the Host steps in order', stepsSeen.slice(0, 4))
269
+ check(updates.length === 7, 'updates one candidate at a time', updates.map(item => item.name))
270
+ check(updates.every(item => item.registry === 'https://registry.npmjs.org/'), 'updates from the registry that listed it', updates.map(item => item.registry))
271
+ const done = controller.getSnapshot()
272
+ check(done.phase === 'done', 'settles on done', done.phase)
273
+ const outcomeKeys = done.results.map(item => item.key)
274
+ check(done.results.length === 7, 'reports every candidate', outcomeKeys)
275
+ check(outcomeKeys.filter(key => key === 'outcomeApplied').length === 1, 'reports an applied update', outcomeKeys)
276
+ check(outcomeKeys.includes('outcomeRestart'), 'reports a restart requirement', outcomeKeys)
277
+ check(outcomeKeys.includes('outcomeRestored'), 'reports a restored failure', outcomeKeys)
278
+ check(outcomeKeys.includes('outcomeBroken'), 'reports a failed restore', outcomeKeys)
279
+ check(outcomeKeys.includes('outcomeFailed'), 'reports a plain failure', outcomeKeys)
280
+ check(outcomeKeys.includes('outcomeCheckRefused'), 'reports a refused target', outcomeKeys)
281
+ check(outcomeKeys.includes('outcomeRemoveFailed'), 'reports a failed removal', outcomeKeys)
282
+ check(done.results.every(item => item.key !== 'outcomeRestored' || item.detail === 'pnpm said no'), 'keeps the failure detail', done.results)
283
+
284
+ console.log('\ndone render')
285
+ const doneTexts = texts(onScreen(), [])
286
+ noMissing('done', doneTexts)
287
+ check(doneTexts.includes('已更新'), 'shows the applied row', doneTexts)
288
+ check(doneTexts.some(text => text.includes('已恢复到 2.0.0')), 'shows the restored row', doneTexts)
289
+ check(doneTexts.some(text => text === 'pnpm said no'), 'shows the failure detail line', doneTexts)
290
+ check(doneTexts.some(text => text.includes('重新加载页面')), 'tells the reader to reload', doneTexts)
291
+
292
+ console.log('\nstop after the current plugin')
293
+ updateDelayMs = 30
294
+ controller.askConfirm()
295
+ controller.runUpdate()
296
+ await settle(10)
297
+ controller.requestStop()
298
+ check(controller.getSnapshot().stopping === true, 'records the stop request', controller.getSnapshot().stopping)
299
+ await settle(300)
300
+ updateDelayMs = 0
301
+ const stopped = controller.getSnapshot()
302
+ check(stopped.phase === 'done', 'settles after stopping', stopped.phase)
303
+ check(stopped.stopping === false, 'clears the stop flag', stopped.stopping)
304
+ check(stopped.results.length === 7, 'accounts for every candidate', stopped.results.length)
305
+ check(stopped.results.filter(item => item.key === 'outcomeSkipped').length === 6, 'marks the unreached packages', stopped.results.map(item => item.key))
306
+ const stoppedTexts = texts(onScreen(), [])
307
+ noMissing('stopped', stoppedTexts)
308
+ check(stoppedTexts.filter(text => text === '已跳过').length === 6, 'shows the unreached packages', stoppedTexts.filter(text => text.includes('跳过')))
309
+
310
+ console.log('\nrender audit (states the fake Host cannot reach)')
311
+ const frozen = (overrides) => Object.freeze(Object.assign({
312
+ phase: 'idle', refreshing: false, checked: 0, total: 0, current: null, checkedAt: null,
313
+ error: null, candidates: [], latest: [], blocked: [], skipped: [], run: null, results: [], stopping: false,
314
+ }, overrides))
315
+ const audit = (state) => {
316
+ const stub = {
317
+ getSnapshot: () => state,
318
+ subscribe: () => () => {},
319
+ ensureChecked: () => {}, check: () => {}, askConfirm: () => {}, cancelConfirm: () => {}, runUpdate: () => {}, requestStop: () => {},
320
+ }
321
+ return texts(render(registered.Component({ t: ctx.locale.bind('updateAll'), controller: stub })), [])
322
+ }
323
+ const scenes = [
324
+ ['reading the list', frozen({ phase: 'checking' })],
325
+ ['checking part way', frozen({ phase: 'checking', total: 3, checked: 1, current: '某个插件' })],
326
+ ['the list failed', frozen({ phase: 'error', error: 'offline' })],
327
+ ['everything current', frozen({ phase: 'ready', checkedAt: 1, latest: ['a', 'b'] })],
328
+ ['two candidates running, one waiting', frozen({
329
+ phase: 'running', checkedAt: 1,
330
+ run: { total: 3, index: 2, name: 'b', title: 'b', from: '1.0.0', to: '2.0.0', step: 'installing' },
331
+ candidates: [{ name: 'a', title: 'a', from: '1.0.0', to: '2.0.0' }, { name: 'b', title: 'b', from: '1.0.0', to: '2.0.0' }, { name: 'c', title: 'c', from: '1.0.0', to: '2.0.0' }],
332
+ results: [{ name: 'a', title: 'a', from: '1.0.0', to: '2.0.0', key: 'outcomeApplied', tone: 'success', params: {}, detail: '', updated: true }],
333
+ })],
334
+ ['stopping', frozen({
335
+ phase: 'running', checkedAt: 1, stopping: true,
336
+ run: { total: 2, index: 1, name: 'a', title: 'a', from: '1.0.0', to: '2.0.0', step: 'removing' },
337
+ candidates: [{ name: 'a', title: 'a', from: '1.0.0', to: '2.0.0' }],
338
+ })],
339
+ ]
340
+ for (const [label, state] of scenes) noMissing(label, audit(state))
341
+
342
+ console.log('\ndictionaries')
343
+ const zhKeys = Object.keys(dictionaries.zh)
344
+ const enKeys = Object.keys(dictionaries.en)
345
+ check(zhKeys.length === enKeys.length && enKeys.every(key => zhKeys.includes(key)), 'both dictionaries cover the same keys',
346
+ { onlyZh: zhKeys.filter(key => !enKeys.includes(key)), onlyEn: enKeys.filter(key => !zhKeys.includes(key)) })
347
+ check(zhKeys.every(key => usedKeys.has(key)), 'every copy key is reachable', zhKeys.filter(key => !usedKeys.has(key)))
348
+ check(enKeys.every(key => dictionaries.en[key] !== ''), 'no empty English copy', enKeys.filter(key => dictionaries.en[key] === ''))
349
+
350
+ console.log('\n' + (failures.length === 0 ? 'ALL PASS' : failures.length + ' FAILURES'))
351
+ process.exitCode = failures.length === 0 ? 0 : 1
352
+ }
353
+
354
+ main().catch((error) => { console.error(error); process.exitCode = 1 })
@@ -0,0 +1,18 @@
1
+ // Probe helper: report Traditional-only characters left in the Simplified dictionaries.
2
+ const fs = require('node:fs')
3
+ const TRADITIONAL = '個這檢過說為檔開關執並與訊應時間後態確誤頁讀載們處圖標選擇網連結產環設號類裝復啟動敗進兒麼樣樂瀏顯資錯嘗試項錄開啟關閉錄'
4
+ let bad = 0
5
+ for (const file of process.argv.slice(2)) {
6
+ const text = fs.readFileSync(file, 'utf8')
7
+ const found = new Map()
8
+ for (const line of text.split(/\r?\n/)) {
9
+ for (const char of line) {
10
+ if (!TRADITIONAL.includes(char)) continue
11
+ found.set(char, (found.get(char) || 0) + 1)
12
+ }
13
+ }
14
+ if (found.size === 0) { console.log('clean ' + file); continue }
15
+ bad += 1
16
+ console.log('TRADITIONAL ' + file + ' :: ' + [...found.entries()].map(([char, count]) => char + '×' + count).join(' '))
17
+ }
18
+ process.exitCode = bad === 0 ? 0 : 1