dsh-version-manager 0.1.7 → 0.1.8
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/CHANGELOG.md +7 -0
- package/README.md +6 -4
- package/README.zh-CN.md +6 -4
- package/docs/release-notes-0.1.8.md +33 -0
- package/lib/client.js +177 -12
- package/lib/host/registry-migration.js +93 -0
- package/lib/host/routes.js +42 -8
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
|
|
5
|
+
- Fix bounded vertical scrolling and automatically expand version checks.
|
|
6
|
+
- Add confirmed sequential batch updates and opt-in migration from local archives to the same named stable npm bundle.
|
|
7
|
+
- Validate source, identity, compatibility and archive digest; snapshot before writes, serialize mutations, verify installed state and attempt rollback on failure.
|
|
8
|
+
- Retain all admission hardening from 0.1.7.
|
|
9
|
+
|
|
3
10
|
## 0.1.7
|
|
4
11
|
|
|
5
12
|
- Apply DSH Host/Origin and authentication admission to every HTTP route before owner authorization, body parsing or profile service access. Refuse missing, throwing and invalid synchronous checks.
|
package/README.md
CHANGED
|
@@ -18,19 +18,21 @@
|
|
|
18
18
|
|
|
19
19
|
## Get started
|
|
20
20
|
|
|
21
|
-
Desktop:
|
|
21
|
+
Desktop: enter `dsh-version-manager` in Extensions → Plugin Management → Add Plugin. Prefer the npm source to enable future online updates. Release `.tgz` files are for offline installation; the host cannot update local archives online. For a Web profile you explicitly control:
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
|
-
dsh plugin --profile web add dsh-version-manager@0.1.
|
|
24
|
+
dsh plugin --profile web add dsh-version-manager@0.1.8
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Install into an existing Desktop/Web profile and open Version manager. Review inventory and the exact from → to update first; a new empty profile also needs the Web app bundle.
|
|
28
28
|
|
|
29
|
+
The panel scrolls vertically and supports horizontal scrolling on narrow screens. “Check all updates” defaults to writable npm plugins; “Update all” previews exact changes and asks for confirmation. Updates run sequentially, snapshot each target first, and stop on failure. Opt into “Include local archives (change source to npm)” to migrate local `.tgz` installs to the same named stable npm bundle, showing the source change before confirmation. Failed installs attempt rollback to the retained original archive and preserve disabled state. Missing archives, identity mismatch, downgrades and unconfirmed compatibility refuse migration. Prerelease, deprecated, non-bundle, Git, directory, alias and official sources are not automatically updated. Single checks expand their results automatically.
|
|
30
|
+
|
|
29
31
|
## Status and compatibility
|
|
30
32
|
|
|
31
33
|
| Item | Current source of truth |
|
|
32
34
|
| --- | --- |
|
|
33
|
-
| Source version | `0.1.
|
|
35
|
+
| Source version | `0.1.8` · see [package.json](package.json) |
|
|
34
36
|
| Distribution | `npm` · [Releases](https://github.com/tangyixiao/dsh-version-manager/releases) |
|
|
35
37
|
| DSH | `>=0.2.2-rc.1` |
|
|
36
38
|
| Node.js | `>=22` |
|
|
@@ -40,7 +42,7 @@ Restore is not a full backup: restoring a plugin version does not roll back conf
|
|
|
40
42
|
|
|
41
43
|
[Detailed usage, configuration and troubleshooting](docs/guide.en.md)
|
|
42
44
|
|
|
43
|
-
HTTP routes require the host's synchronous `connection.requestRejection(request)` check before owner authorization, request bodies or profile services. Missing, throwing or asynchronous checks refuse access. See the [0.1.
|
|
45
|
+
HTTP routes require the host's synchronous `connection.requestRejection(request)` check before owner authorization, request bodies or profile services. Missing, throwing or asynchronous checks refuse access. See the [0.1.8 release notes](docs/release-notes-0.1.8.md) and [changelog](CHANGELOG.md).
|
|
44
46
|
|
|
45
47
|
## Development and participation
|
|
46
48
|
|
package/README.zh-CN.md
CHANGED
|
@@ -18,19 +18,21 @@
|
|
|
18
18
|
|
|
19
19
|
## 开始使用
|
|
20
20
|
|
|
21
|
-
Desktop
|
|
21
|
+
Desktop:在“扩展 → 插件管理 → 添加插件”中输入 `dsh-version-manager`,优先使用 npm 来源,以便后续在线更新。发行页 `.tgz` 用于离线安装;宿主把本地安装包视为不可在线更新来源。命令行示例用于你明确控制的 Web profile:
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
|
-
dsh plugin --profile web add dsh-version-manager@0.1.
|
|
24
|
+
dsh plugin --profile web add dsh-version-manager@0.1.8
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
在原有 Desktop/Web profile 中安装并打开“版本管理”。先查看清单与更新预览,再确认具体 from → to;新建空 profile 还需要 Web 应用 bundle。
|
|
28
28
|
|
|
29
|
+
面板支持上下滚动与窄屏横向滚动。“检查全部更新”默认检查当前 profile 中可写入的 npm 插件,展示版本变化后可“一键更新”;更新逐项执行,每项先拍快照,失败即停。勾选“包含本地安装包(切换到 npm 来源)”后,可将本地 `.tgz` 安装迁移到同名 npm 正式版;确认前展示来源变化,失败时尝试恢复原安装包,保留停用状态。原包不存在、身份不符、版本过旧或兼容性未确认时拒绝迁移。预发布、已废弃、非 bundle、Git、目录、别名及官方内置来源不自动更新。单项检查会自动展开结果。
|
|
30
|
+
|
|
29
31
|
## 当前状态与兼容性
|
|
30
32
|
|
|
31
33
|
| 项目 | 当前依据 |
|
|
32
34
|
| --- | --- |
|
|
33
|
-
| 源码版本 | `0.1.
|
|
35
|
+
| 源码版本 | `0.1.8` · 以 [package.json](package.json) 为准 |
|
|
34
36
|
| 分发方式 | `npm` · [Releases](https://github.com/tangyixiao/dsh-version-manager/releases) |
|
|
35
37
|
| DSH | `>=0.2.2-rc.1` |
|
|
36
38
|
| Node.js | `>=22` |
|
|
@@ -40,7 +42,7 @@ dsh plugin --profile web add dsh-version-manager@0.1.7
|
|
|
40
42
|
|
|
41
43
|
[Detailed guide](docs/guide.en.md)
|
|
42
44
|
|
|
43
|
-
HTTP 路由先调用宿主同步的 `connection.requestRejection(request)` 检查,再验证 owner 权限、读取请求体和访问 profile 服务。宿主检查缺失、抛错或返回异步结果时拒绝访问。参见 [0.1.
|
|
45
|
+
HTTP 路由先调用宿主同步的 `connection.requestRejection(request)` 检查,再验证 owner 权限、读取请求体和访问 profile 服务。宿主检查缺失、抛错或返回异步结果时拒绝访问。参见 [0.1.8 发行说明](docs/release-notes-0.1.8.md)与[更新记录](CHANGELOG.md)。
|
|
44
46
|
|
|
45
47
|
## 开发与参与
|
|
46
48
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# dsh-version-manager 0.1.8
|
|
2
|
+
|
|
3
|
+
## 简体中文
|
|
4
|
+
|
|
5
|
+
- 修复主面板纵向滚动,根据窗口与宿主裁切区域计算可见高度;保留窄屏横向滚动。
|
|
6
|
+
- 单项检查自动展开结果;新增批量检查、版本变化预览与统一确认更新,逐项执行且失败即停。
|
|
7
|
+
- 支持明确确认后将本地 `.tgz` 安装迁移到同名 npm 正式版;检查包身份、兼容性、旧来源及安装包指纹,失败时尝试恢复原来源,保留停用状态。
|
|
8
|
+
- 批量迁移默认关闭;不替换 Git、目录、别名和官方内置来源,不自动降级或选择预发布。
|
|
9
|
+
- 更新前保存快照,共享写入锁;完成后回读实际版本及来源。保留 DSH Host/Origin 与 owner 认证检查。
|
|
10
|
+
- 推荐使用 npm 安装,后续可以直接在线更新。
|
|
11
|
+
- 将主分支已有的 HTTP 路由准入修复纳入发行包:全部 16 条路由先调用宿主 `connection.requestRejection(request)`,执行 Host/Origin 与身份检查,再验证 owner 权限、读取请求体和访问 profile 服务。
|
|
12
|
+
- 宿主检查缺失、抛错或返回非法值时拒绝访问。该接口必须同步返回 `undefined`、`401` 或 `403`;异步结果也拒绝,并消费其 Promise 拒绝,避免出现未处理拒绝。
|
|
13
|
+
- owner 准入同样要求同步结果;异步结果及不可读取的服务、拒绝状态或身份字段会安全拒绝,Promise/thenable 的拒绝被消费。
|
|
14
|
+
- 保留只允许 owner、HTTP 方法限制、写操作显式确认和路由卸载清理;新增异步拒绝及 connection 服务不可读的全路由回归测试。
|
|
15
|
+
- 已核对的官方 rc.3 宿主中,`requestRejection` 委托 `admit`,而 `admit` 本身已检查 Host/Origin;本次明确调用宿主公开检查接口并加强失败时拒绝访问的处理,不据此宣称该宿主已有准入绕过。
|
|
16
|
+
- 保留现有 Node.js `>=22`、DSH `>=0.2.2-rc.1` 声明。宿主必须提供上述同步准入接口;无法验证该接口时 HTTP 功能不可用。
|
|
17
|
+
- 更新既有 profile 中的插件后,确认宿主已重新加载新版,再打开版本管理。版本恢复仍不回滚配置、依赖树或 agent presets。
|
|
18
|
+
|
|
19
|
+
## English
|
|
20
|
+
|
|
21
|
+
- Bound vertical scrolling to the actual visible host area while retaining narrow-screen horizontal scrolling.
|
|
22
|
+
- Expand individual version results automatically; add batch checks, exact previews and confirmed sequential updates that stop on failure.
|
|
23
|
+
- Opt into migrating local `.tgz` installs to the same named stable npm bundle. Validate identity, compatibility, source and archive fingerprint, preserve disabled state, and attempt rollback to the retained original archive on failure.
|
|
24
|
+
- Local migration is off by default. Git, directories, aliases, official bundles, downgrades and prereleases are excluded.
|
|
25
|
+
- Snapshot before changes, serialize writes and verify the installed version/source after completion. Preserve host admission and owner authentication.
|
|
26
|
+
- Prefer npm installation for subsequent online updates.
|
|
27
|
+
- Include the HTTP route admission fix already on main in the distribution: all 16 routes call the host's `connection.requestRejection(request)` for Host/Origin and authentication checks before owner authorization, body parsing or profile service access.
|
|
28
|
+
- Refuse access if the host check is missing, throws or returns an invalid value. The contract is synchronous and accepts only `undefined`, `401` or `403`. Asynchronous results are refused and their promise rejections are consumed to avoid unhandled rejections.
|
|
29
|
+
- Owner admission also requires a synchronous result. Asynchronous results and unreadable service, rejection or principal fields fail closed, and rejected promises/thenables are consumed.
|
|
30
|
+
- Preserve owner-only access, HTTP method checks, explicit write confirmation and route disposal. Add regressions across every route for rejected asynchronous verdicts and unavailable connection services.
|
|
31
|
+
- In the verified official rc.3 host, `requestRejection` delegates to `admit`, which already checks Host/Origin. This release explicitly uses the host's public check and strengthens fail-closed handling; it does not establish an admission bypass in that host.
|
|
32
|
+
- Retain the declared Node.js `>=22` / DSH `>=0.2.2-rc.1` ranges. The host must provide the synchronous admission API above; HTTP features remain unavailable when that check cannot be verified.
|
|
33
|
+
- After updating the plugin in the existing profile, confirm that the host has reloaded the new version before opening Version manager. Version restore still does not roll back configuration, dependency trees or agent presets.
|
package/lib/client.js
CHANGED
|
@@ -79,6 +79,21 @@ window.__ModuleLoader__.load({
|
|
|
79
79
|
colCompat: '兼容性',
|
|
80
80
|
colActions: '操作',
|
|
81
81
|
tableScroll: '插件列表,可横向滚动',
|
|
82
|
+
panelScroll: '版本管理,可上下滚动',
|
|
83
|
+
checkAll: '检查全部更新',
|
|
84
|
+
updateAll: '一键更新',
|
|
85
|
+
batchChecking: (done, total) => `正在检查 ${done}/${total}`,
|
|
86
|
+
batchReady: (count) => `发现 ${count} 个可更新插件`,
|
|
87
|
+
batchConfirm: '更新下列插件?',
|
|
88
|
+
batchNotes: '依次更新,每项更新前自动拍快照;失败即停。跳过预发布、不兼容和已废弃版本。本地安装包仅在明确勾选后切换到 npm 来源。',
|
|
89
|
+
batchDone: (done, total) => `已更新 ${done}/${total} 个插件`,
|
|
90
|
+
batchEmpty: '未发现可直接更新的正式版。',
|
|
91
|
+
localInstall: '本地安装包',
|
|
92
|
+
localUpdateHelp: '可检查同名 npm 正式版,确认后切换来源并更新。原本地安装包保留,安装失败时尝试恢复原来源。',
|
|
93
|
+
includeLocal: '包含本地安装包(切换到 npm 来源)',
|
|
94
|
+
migrateAction: '检查在线版本',
|
|
95
|
+
migrateConfirm: '切换到 npm 来源并更新',
|
|
96
|
+
migrateBody: (name, source, version) => `将 ${name} 的安装来源从 ${source} 切换为 npm 正式版 ${version}。之后可以直接在线更新。`,
|
|
82
97
|
skillTableScroll: 'Skill 列表,可横向滚动',
|
|
83
98
|
checkVersions: '检查更新',
|
|
84
99
|
checking: '检查中…',
|
|
@@ -349,6 +364,21 @@ window.__ModuleLoader__.load({
|
|
|
349
364
|
colCompat: 'Compatibility',
|
|
350
365
|
colActions: 'Actions',
|
|
351
366
|
tableScroll: 'Plugin list, scroll horizontally',
|
|
367
|
+
panelScroll: 'Version manager, scroll vertically',
|
|
368
|
+
checkAll: 'Check all updates',
|
|
369
|
+
updateAll: 'Update all',
|
|
370
|
+
batchChecking: (done, total) => `Checking ${done}/${total}`,
|
|
371
|
+
batchReady: (count) => `${count} plugins can be updated`,
|
|
372
|
+
batchConfirm: 'Update these plugins?',
|
|
373
|
+
batchNotes: 'Update sequentially with a snapshot before each change; stop on failure. Skip prerelease, incompatible and deprecated versions. Local archives change to npm only after explicit opt-in.',
|
|
374
|
+
batchDone: (done, total) => `Updated ${done}/${total} plugins`,
|
|
375
|
+
batchEmpty: 'No stable versions available for direct update.',
|
|
376
|
+
localInstall: 'Local archive',
|
|
377
|
+
localUpdateHelp: 'Check the same named stable npm bundle, then confirm a source change and update. The original archive is retained and used for rollback if installation fails.',
|
|
378
|
+
includeLocal: 'Include local archives (change source to npm)',
|
|
379
|
+
migrateAction: 'Check online version',
|
|
380
|
+
migrateConfirm: 'Change source to npm and update',
|
|
381
|
+
migrateBody: (name, source, version) => `Change ${name} from ${source} to stable npm version ${version}. Future updates can then use the registry directly.`,
|
|
352
382
|
skillTableScroll: 'Skill list, scroll horizontally',
|
|
353
383
|
checkVersions: 'Check versions',
|
|
354
384
|
checking: 'Checking…',
|
|
@@ -782,6 +812,132 @@ window.__ModuleLoader__.load({
|
|
|
782
812
|
// local tarball paths must not take space away from versions and actions.
|
|
783
813
|
const ELLIPSIS = { display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', minWidth: 0 }
|
|
784
814
|
|
|
815
|
+
function usePanelViewport() {
|
|
816
|
+
const element = useRef(null)
|
|
817
|
+
const [height, setHeight] = useState(null)
|
|
818
|
+
useEffect(() => {
|
|
819
|
+
const node = element.current
|
|
820
|
+
if (node === null) return undefined
|
|
821
|
+
const measure = () => {
|
|
822
|
+
const top = node.getBoundingClientRect().top
|
|
823
|
+
let bottom = window.visualViewport
|
|
824
|
+
? window.visualViewport.offsetTop + window.visualViewport.height
|
|
825
|
+
: window.innerHeight
|
|
826
|
+
for (let parent = node.parentElement; parent; parent = parent.parentElement) {
|
|
827
|
+
const rect = parent.getBoundingClientRect()
|
|
828
|
+
if (rect.height > 0 && /hidden|clip|auto|scroll/.test(window.getComputedStyle(parent).overflowY)) {
|
|
829
|
+
bottom = Math.min(bottom, rect.bottom)
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
setHeight(Math.max(0, Math.floor(bottom - top)))
|
|
833
|
+
}
|
|
834
|
+
measure()
|
|
835
|
+
const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(measure) : null
|
|
836
|
+
if (node.parentElement) observer?.observe(node.parentElement)
|
|
837
|
+
window.addEventListener('resize', measure)
|
|
838
|
+
window.visualViewport?.addEventListener('resize', measure)
|
|
839
|
+
return () => {
|
|
840
|
+
observer?.disconnect()
|
|
841
|
+
window.removeEventListener('resize', measure)
|
|
842
|
+
window.visualViewport?.removeEventListener('resize', measure)
|
|
843
|
+
}
|
|
844
|
+
}, [])
|
|
845
|
+
return { ref: element, height }
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function localArchive(row) {
|
|
849
|
+
return row.updateRefusal === 'not-registry:tarball' && row.source?.kind === 'tarball' &&
|
|
850
|
+
(/^file:/i.test(row.declaredSpec ?? '') || (row.declaredSpec ?? '').startsWith(`${row.targetId}@file:`))
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function safeUpdate(item, installed, migration = false) {
|
|
854
|
+
return item.isBundle === true && !item.deprecated && !item.prerelease &&
|
|
855
|
+
(migration || item.version !== installed) && item.incompatible == null &&
|
|
856
|
+
(item.compatibility == null || !item.compatibility.requirements || item.compatibility.exempted === true)
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
function BatchUpdates({ rows, t, onRefresh }) {
|
|
860
|
+
const [state, setState] = useState({ phase: 'idle', items: [], messages: [], done: 0, total: 0 })
|
|
861
|
+
const busy = state.phase === 'checking' || state.phase === 'updating'
|
|
862
|
+
const active = useRef(false)
|
|
863
|
+
const [includeLocal, setIncludeLocal] = useState(false)
|
|
864
|
+
const check = async () => {
|
|
865
|
+
if (active.current) return
|
|
866
|
+
active.current = true
|
|
867
|
+
const targets = rows.filter(row => row.updateRefusal === null || (includeLocal && localArchive(row)))
|
|
868
|
+
const items = []
|
|
869
|
+
const messages = []
|
|
870
|
+
setState({ phase: 'checking', items: [], messages: [], done: 0, total: targets.length })
|
|
871
|
+
try {
|
|
872
|
+
for (let index = 0; index < targets.length; index++) {
|
|
873
|
+
const row = targets[index]
|
|
874
|
+
try {
|
|
875
|
+
const listing = await request(`/versions?target=${encodeURIComponent(row.targetId)}${localArchive(row) ? '&migrateToRegistry=true' : ''}`)
|
|
876
|
+
if (listing.status !== 'ok') throw new Error(listing.message ?? listing.reason ?? listing.status)
|
|
877
|
+
const candidate = listing.stable.find(item => safeUpdate(item, row.installedVersion, !!listing.sourceMigration))
|
|
878
|
+
if (candidate) items.push({ targetId: row.targetId, from: row.installedVersion, version: candidate.version, sourceMigration: listing.sourceMigration })
|
|
879
|
+
} catch (error) {
|
|
880
|
+
messages.push(`${row.targetId}: ${describeError(error, t)}`)
|
|
881
|
+
}
|
|
882
|
+
setState({ phase: 'checking', items: [...items], messages: [...messages], done: index + 1, total: targets.length })
|
|
883
|
+
}
|
|
884
|
+
// Updating the running manager can unmount this panel. Finish it last.
|
|
885
|
+
items.sort((a, b) => Number(a.targetId === PANEL_ID) - Number(b.targetId === PANEL_ID))
|
|
886
|
+
setState({ phase: 'ready', items, messages, done: 0, total: items.length })
|
|
887
|
+
} finally {
|
|
888
|
+
active.current = false
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
const update = async () => {
|
|
892
|
+
if (active.current || state.phase !== 'confirm') return
|
|
893
|
+
active.current = true
|
|
894
|
+
let done = 0
|
|
895
|
+
const messages = [...state.messages]
|
|
896
|
+
setState(previous => ({ ...previous, phase: 'updating', done }))
|
|
897
|
+
try {
|
|
898
|
+
for (const item of state.items) {
|
|
899
|
+
const result = await request('/update', {
|
|
900
|
+
method: 'POST',
|
|
901
|
+
body: { targetId: item.targetId, toVersion: item.version, fromVersion: item.from, confirm: true,
|
|
902
|
+
...(item.sourceMigration ? { migrateToRegistry: true, expectedSource: item.sourceMigration.from, archiveDigest: item.sourceMigration.archiveDigest } : {}) },
|
|
903
|
+
})
|
|
904
|
+
if (result.ok !== true) throw new Error(`${item.targetId}: ${result.message ?? t.updateFailed}`)
|
|
905
|
+
done++
|
|
906
|
+
setState(previous => ({ ...previous, done }))
|
|
907
|
+
}
|
|
908
|
+
} catch (error) {
|
|
909
|
+
messages.push(describeError(error, t))
|
|
910
|
+
} finally {
|
|
911
|
+
setState(previous => ({ ...previous, phase: 'done', done, messages }))
|
|
912
|
+
active.current = false
|
|
913
|
+
await onRefresh()
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return h('div', { style: { margin: '10px 0', fontSize: 12 } },
|
|
917
|
+
h('label', { style: { display: 'block', marginBottom: 6 } },
|
|
918
|
+
h('input', { type: 'checkbox', checked: includeLocal, disabled: busy, onChange: event => {
|
|
919
|
+
setIncludeLocal(event.target.checked)
|
|
920
|
+
setState({ phase: 'idle', items: [], messages: [], done: 0, total: 0 })
|
|
921
|
+
} }), ' ', t.includeLocal),
|
|
922
|
+
h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } },
|
|
923
|
+
h(Button, { onClick: check, disabled: busy }, state.phase === 'checking' ? t.batchChecking(state.done, state.total) : t.checkAll),
|
|
924
|
+
state.phase === 'ready' && state.items.length > 0
|
|
925
|
+
? h(Button, { primary: true, onClick: () => setState(previous => ({ ...previous, phase: 'confirm' })) }, `${t.updateAll} (${state.items.length})`)
|
|
926
|
+
: null,
|
|
927
|
+
h('span', { role: 'status' },
|
|
928
|
+
state.phase === 'ready' ? (state.items.length ? t.batchReady(state.items.length) : t.batchEmpty) :
|
|
929
|
+
state.phase === 'updating' || state.phase === 'done' ? t.batchDone(state.done, state.total) : ''),
|
|
930
|
+
),
|
|
931
|
+
state.items.length > 0 ? h('ul', { style: { margin: '6px 0', paddingLeft: 20 } },
|
|
932
|
+
state.items.map(item => h('li', { key: item.targetId }, `${item.targetId}: ${item.from} → ${item.version}${item.sourceMigration ? ` · ${item.sourceMigration.from} → ${item.sourceMigration.to}` : ''}`))) : null,
|
|
933
|
+
state.phase === 'confirm' ? h(ConfirmBar, {
|
|
934
|
+
title: t.batchConfirm, body: t.batchNotes, notes: state.items.some(item => item.sourceMigration) ? [t.includeLocal] : [], t, busy: false,
|
|
935
|
+
onConfirm: update, onCancel: () => setState(previous => ({ ...previous, phase: 'ready' })),
|
|
936
|
+
}) : null,
|
|
937
|
+
state.messages.map((message, index) => h(Notice, { key: index, tone: 'warn', title: t.errorLabel }, message)),
|
|
938
|
+
)
|
|
939
|
+
}
|
|
940
|
+
|
|
785
941
|
function TableViewport({ label, children }) {
|
|
786
942
|
return h('div', {
|
|
787
943
|
role: 'region',
|
|
@@ -945,6 +1101,7 @@ window.__ModuleLoader__.load({
|
|
|
945
1101
|
item.version === installed ? h(Badge, null, t.colVersion) : null,
|
|
946
1102
|
item.deprecated !== null && item.deprecated !== undefined ? h(Badge, null, t.deprecated) : null,
|
|
947
1103
|
item.isBundle === false ? h(Badge, null, 'not a bundle') : null,
|
|
1104
|
+
item.incompatible != null ? h(Badge, { tone: 'warn' }, t.compatFail) : null,
|
|
948
1105
|
item.compatibility !== null && item.compatibility !== undefined && item.compatibility.exempted !== true
|
|
949
1106
|
? h(Badge, null, item.compatibility.requirements ? t.compatFail : t.compatOk)
|
|
950
1107
|
: null,
|
|
@@ -954,7 +1111,7 @@ window.__ModuleLoader__.load({
|
|
|
954
1111
|
Button,
|
|
955
1112
|
{
|
|
956
1113
|
onClick: () => onPick(item),
|
|
957
|
-
disabled: busyVersion !== null,
|
|
1114
|
+
disabled: busyVersion !== null || (item.version === installed && !data.sourceMigration) || !item.isBundle || item.incompatible != null,
|
|
958
1115
|
primary: false,
|
|
959
1116
|
ariaLabel: `${t.updateTo} ${item.version}`,
|
|
960
1117
|
},
|
|
@@ -1089,7 +1246,7 @@ window.__ModuleLoader__.load({
|
|
|
1089
1246
|
}
|
|
1090
1247
|
|
|
1091
1248
|
function Row(props) {
|
|
1092
|
-
const { row, t, language, expanded, onToggle, onRefresh } = props
|
|
1249
|
+
const { row, t, language, expanded, onToggle, onExpand, onRefresh } = props
|
|
1093
1250
|
const [versions, setVersions] = useState(null)
|
|
1094
1251
|
const [versionsBusy, setVersionsBusy] = useState(false)
|
|
1095
1252
|
const [versionsError, setVersionsError] = useState(null)
|
|
@@ -1102,16 +1259,17 @@ window.__ModuleLoader__.load({
|
|
|
1102
1259
|
const [pruneBusy, setPruneBusy] = useState(false)
|
|
1103
1260
|
const [pendingPrune, setPendingPrune] = useState(false)
|
|
1104
1261
|
const loadVersions = useCallback(async () => {
|
|
1262
|
+
onExpand()
|
|
1105
1263
|
setVersionsBusy(true)
|
|
1106
1264
|
setVersionsError(null)
|
|
1107
1265
|
try {
|
|
1108
|
-
setVersions(await request(`/versions?target=${encodeURIComponent(row.targetId)}`))
|
|
1266
|
+
setVersions(await request(`/versions?target=${encodeURIComponent(row.targetId)}${localArchive(row) ? '&migrateToRegistry=true' : ''}`))
|
|
1109
1267
|
} catch (error) {
|
|
1110
1268
|
setVersionsError(error)
|
|
1111
1269
|
} finally {
|
|
1112
1270
|
setVersionsBusy(false)
|
|
1113
1271
|
}
|
|
1114
|
-
}, [row.targetId])
|
|
1272
|
+
}, [row.targetId, onExpand])
|
|
1115
1273
|
|
|
1116
1274
|
const takeSnapshot = useCallback(async () => {
|
|
1117
1275
|
setSnapshotBusy(true)
|
|
@@ -1167,6 +1325,8 @@ window.__ModuleLoader__.load({
|
|
|
1167
1325
|
targetId: row.targetId,
|
|
1168
1326
|
toVersion: pendingUpdate.version,
|
|
1169
1327
|
allowPrerelease: pendingUpdate.prerelease === true,
|
|
1328
|
+
fromVersion: row.installedVersion,
|
|
1329
|
+
...(pendingUpdate.sourceMigration ? { migrateToRegistry: true, expectedSource: pendingUpdate.sourceMigration.from, archiveDigest: pendingUpdate.sourceMigration.archiveDigest } : {}),
|
|
1170
1330
|
confirm: true,
|
|
1171
1331
|
},
|
|
1172
1332
|
})
|
|
@@ -1262,7 +1422,7 @@ window.__ModuleLoader__.load({
|
|
|
1262
1422
|
'div',
|
|
1263
1423
|
{ style: { display: 'flex', gap: 4, marginTop: 3, flexWrap: 'wrap' } },
|
|
1264
1424
|
row.official === true ? h(Badge, null, t.official) : null,
|
|
1265
|
-
writable ? null : h(Badge,
|
|
1425
|
+
writable ? null : h(Badge, { tone: 'warn' }, row.source.kind === 'tarball' || row.source.kind === 'file' ? t.localInstall : t.readOnly),
|
|
1266
1426
|
row.prerelease === true ? h(Badge, null, t.prerelease) : null,
|
|
1267
1427
|
),
|
|
1268
1428
|
),
|
|
@@ -1294,14 +1454,14 @@ window.__ModuleLoader__.load({
|
|
|
1294
1454
|
h(
|
|
1295
1455
|
Button,
|
|
1296
1456
|
{
|
|
1297
|
-
onClick: loadVersions,
|
|
1298
|
-
disabled:
|
|
1457
|
+
onClick: writable || localArchive(row) ? loadVersions : onExpand,
|
|
1458
|
+
disabled: versionsBusy,
|
|
1299
1459
|
title: writable ? undefined : refusalLabel(row.updateRefusal, t) ?? '',
|
|
1300
1460
|
// Every row renders the same words, so the label alone leaves
|
|
1301
1461
|
// eight identical "检查更新" buttons in the accessibility tree.
|
|
1302
1462
|
ariaLabel: `${t.checkVersions}: ${row.targetId}`,
|
|
1303
1463
|
},
|
|
1304
|
-
versionsBusy ? t.checking : t.checkVersions,
|
|
1464
|
+
versionsBusy ? t.checking : writable ? t.checkVersions : localArchive(row) ? t.migrateAction : t.details,
|
|
1305
1465
|
),
|
|
1306
1466
|
h(
|
|
1307
1467
|
Button,
|
|
@@ -1354,7 +1514,7 @@ window.__ModuleLoader__.load({
|
|
|
1354
1514
|
}),
|
|
1355
1515
|
row.updateRefusal === null
|
|
1356
1516
|
? null
|
|
1357
|
-
: h(Field, { label: t.readOnly, value: refusalLabel(row.updateRefusal, t) }),
|
|
1517
|
+
: h(Field, { label: t.readOnly, value: row.source.kind === 'tarball' || row.source.kind === 'file' ? t.localUpdateHelp : refusalLabel(row.updateRefusal, t) }),
|
|
1358
1518
|
|
|
1359
1519
|
h('div', { style: { marginTop: 10 } }, h('div', { style: { fontSize: 12, fontWeight: 600 } }, t.snapshots),
|
|
1360
1520
|
h(SnapshotList, {
|
|
@@ -1393,7 +1553,7 @@ window.__ModuleLoader__.load({
|
|
|
1393
1553
|
data: versions,
|
|
1394
1554
|
installed: row.installedVersion,
|
|
1395
1555
|
busyVersion: updateBusy ? pendingUpdate?.version ?? null : null,
|
|
1396
|
-
onPick: (item) => setPendingUpdate({ version: item.version, prerelease: item.prerelease }),
|
|
1556
|
+
onPick: (item) => setPendingUpdate({ version: item.version, prerelease: item.prerelease, sourceMigration: versions?.sourceMigration }),
|
|
1397
1557
|
}),
|
|
1398
1558
|
|
|
1399
1559
|
pendingUpdate === null
|
|
@@ -1401,7 +1561,7 @@ window.__ModuleLoader__.load({
|
|
|
1401
1561
|
: h(ConfirmBar, {
|
|
1402
1562
|
t,
|
|
1403
1563
|
title: t.confirmTitle,
|
|
1404
|
-
body: t.confirmBody(row.targetId, row.installedVersion ?? t.unknown, pendingUpdate.version),
|
|
1564
|
+
body: pendingUpdate.sourceMigration ? t.migrateBody(row.targetId, pendingUpdate.sourceMigration.from, pendingUpdate.version) : t.confirmBody(row.targetId, row.installedVersion ?? t.unknown, pendingUpdate.version),
|
|
1405
1565
|
notes: t.confirmNotes,
|
|
1406
1566
|
busy: updateBusy,
|
|
1407
1567
|
onCancel: () => setPendingUpdate(null),
|
|
@@ -2193,6 +2353,7 @@ window.__ModuleLoader__.load({
|
|
|
2193
2353
|
const [skills, setSkills] = useState({ status: 'idle', data: null, error: null })
|
|
2194
2354
|
const abortRef = useRef(null)
|
|
2195
2355
|
const skillsAbortRef = useRef(null)
|
|
2356
|
+
const viewport = usePanelViewport()
|
|
2196
2357
|
|
|
2197
2358
|
const refresh = useCallback(async () => {
|
|
2198
2359
|
abortRef.current?.abort()
|
|
@@ -2391,6 +2552,7 @@ window.__ModuleLoader__.load({
|
|
|
2391
2552
|
language,
|
|
2392
2553
|
expanded: expanded === row.targetId,
|
|
2393
2554
|
onToggle: () => setExpanded((current) => (current === row.targetId ? null : row.targetId)),
|
|
2555
|
+
onExpand: () => setExpanded(row.targetId),
|
|
2394
2556
|
onRefresh: refresh,
|
|
2395
2557
|
}),
|
|
2396
2558
|
),
|
|
@@ -2399,6 +2561,8 @@ window.__ModuleLoader__.load({
|
|
|
2399
2561
|
|
|
2400
2562
|
return h(
|
|
2401
2563
|
'div',
|
|
2564
|
+
{ ref: viewport.ref, role: 'region', 'aria-label': t.panelScroll, tabIndex: 0, style: { height: viewport.height ?? '100%', maxHeight: '100dvh', flex: '0 0 auto', minHeight: 0, width: '100%', overflowY: 'scroll', overflowX: 'hidden', scrollbarWidth: 'auto', scrollbarGutter: 'stable', scrollbarColor: '#85858b transparent', boxSizing: 'border-box' } },
|
|
2565
|
+
h('div',
|
|
2402
2566
|
{ style: { padding: '18px 20px 32px', width: '100%', minWidth: 0, boxSizing: 'border-box', maxWidth: 1240, margin: '0 auto', overflowWrap: 'anywhere', lineHeight: 1.5 } },
|
|
2403
2567
|
header,
|
|
2404
2568
|
state.error === null
|
|
@@ -2472,7 +2636,7 @@ window.__ModuleLoader__.load({
|
|
|
2472
2636
|
loading: skills.status === 'loading',
|
|
2473
2637
|
onReload: loadSkills,
|
|
2474
2638
|
})
|
|
2475
|
-
: toolbar,
|
|
2639
|
+
: h(React.Fragment, null, h(BatchUpdates, { rows, t, onRefresh: refresh }), toolbar),
|
|
2476
2640
|
tab !== 'plugins'
|
|
2477
2641
|
? skills.error === null
|
|
2478
2642
|
? null
|
|
@@ -2491,6 +2655,7 @@ window.__ModuleLoader__.load({
|
|
|
2491
2655
|
h(OperationsList, { t, language, operations: state.data.operations ?? [] }),
|
|
2492
2656
|
),
|
|
2493
2657
|
),
|
|
2658
|
+
),
|
|
2494
2659
|
)
|
|
2495
2660
|
}
|
|
2496
2661
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import { readFile, stat } from 'node:fs/promises'
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
import { classifySpec } from './spec.js'
|
|
5
|
+
import { evaluateCompatibility, parseVersion } from './compat.js'
|
|
6
|
+
|
|
7
|
+
export const REGISTRY = 'https://registry.npmjs.org/'
|
|
8
|
+
|
|
9
|
+
export function canMigrate(row) {
|
|
10
|
+
if (!row || row.official || row.availability !== 'profile' || row.source?.kind !== 'tarball') return false
|
|
11
|
+
if (row.updateRefusal !== 'not-registry:tarball') return false
|
|
12
|
+
const spec = row.declaredSpec ?? ''
|
|
13
|
+
return /^file:/i.test(spec) || spec.startsWith(`${row.targetId}@file:`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function archiveDigest(row, profileDir) {
|
|
17
|
+
if (!canMigrate(row)) throw new Error('Only installed local archives can change to a registry source.')
|
|
18
|
+
const source = classifySpec(row.declaredSpec)
|
|
19
|
+
const file = resolve(profileDir, source.detail)
|
|
20
|
+
const info = await stat(file)
|
|
21
|
+
if (!info.isFile() || info.size > 32 * 1024 * 1024) throw new Error('The original archive is missing or exceeds 32 MiB.')
|
|
22
|
+
return createHash('sha256').update(await readFile(file)).digest('hex')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function previewMigration(row, profile, options = {}) {
|
|
26
|
+
if (!canMigrate(row)) throw new Error('This source cannot migrate to npm.')
|
|
27
|
+
if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9][a-z0-9._-]*$/.test(row.targetId)) throw new Error('Invalid npm package name.')
|
|
28
|
+
const installed = JSON.parse(await readFile(resolve(profile.dir, 'node_modules', row.targetId, 'package.json'), 'utf8'))
|
|
29
|
+
if (installed.name !== row.targetId || installed.version !== row.installedVersion) throw new Error('The installed package identity changed.')
|
|
30
|
+
const digest = await archiveDigest(row, profile.dir)
|
|
31
|
+
const response = await (options.fetch ?? fetch)(`${REGISTRY}${encodeURIComponent(row.targetId)}/latest`, {
|
|
32
|
+
redirect: 'error', signal: AbortSignal.timeout(15000), headers: { accept: 'application/json' },
|
|
33
|
+
})
|
|
34
|
+
if (!response.ok) throw new Error(`npm metadata request failed: HTTP ${response.status}`)
|
|
35
|
+
const reader = response.body.getReader()
|
|
36
|
+
const chunks = []
|
|
37
|
+
let bytes = 0
|
|
38
|
+
try {
|
|
39
|
+
while (true) {
|
|
40
|
+
const { done, value } = await reader.read()
|
|
41
|
+
if (done) break
|
|
42
|
+
bytes += value.byteLength
|
|
43
|
+
if (bytes > 1024 * 1024) throw new Error('npm metadata exceeds 1 MiB.')
|
|
44
|
+
chunks.push(Buffer.from(value))
|
|
45
|
+
}
|
|
46
|
+
} finally { await reader.cancel().catch(() => {}); reader.releaseLock() }
|
|
47
|
+
const manifest = JSON.parse(Buffer.concat(chunks).toString('utf8'))
|
|
48
|
+
const version = parseVersion(manifest.version)
|
|
49
|
+
const current = parseVersion(row.installedVersion)
|
|
50
|
+
if (manifest.name !== row.targetId || !version || !current || version.prerelease.length || manifest.deprecated ||
|
|
51
|
+
typeof manifest.dsh?.bundle?.patch !== 'string' || !manifest.dsh.bundle.patch || !manifest.dist?.integrity) throw new Error('npm latest is not a verified stable bundle with the same package name.')
|
|
52
|
+
const numeric = v => [v.major, v.minor, v.patch]
|
|
53
|
+
const latestParts = numeric(version), currentParts = numeric(current)
|
|
54
|
+
const differing = latestParts.findIndex((part, index) => part !== currentParts[index])
|
|
55
|
+
if (differing >= 0 && latestParts[differing] < currentParts[differing]) throw new Error('npm latest is older than the installed version.')
|
|
56
|
+
const compatibility = evaluateCompatibility({ manifest, runtimeVersion: row.compatibility?.runtimeVersion })
|
|
57
|
+
if (compatibility.verdict !== 'satisfied') throw new Error('npm latest compatibility could not be confirmed.')
|
|
58
|
+
return {
|
|
59
|
+
status: 'ok', installed: row.installedVersion, registry: REGISTRY,
|
|
60
|
+
sourceMigration: { from: row.declaredSpec, to: `${row.targetId}@${manifest.version}`, archiveDigest: digest },
|
|
61
|
+
stable: [{ version: manifest.version, isBundle: true, prerelease: false, deprecated: null, incompatible: null }],
|
|
62
|
+
prerelease: [], versions: [{ version: manifest.version, isBundle: true, prerelease: false, deprecated: null, incompatible: null }],
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function applied(result) {
|
|
67
|
+
const inner = result?.result ?? result
|
|
68
|
+
return inner?.changed === true && inner?.application === 'applied'
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function applyMigration(manager, row, version, profile, digest) {
|
|
72
|
+
const replace = async (spec, expectedVersion, registry) => {
|
|
73
|
+
const settings = { saveExact: true, enabled: row.enabledState !== 'disabled', expected: { name: row.targetId, version: expectedVersion }, ...(registry ? { registry } : {}) }
|
|
74
|
+
let result = await manager.installBundle(spec, settings)
|
|
75
|
+
if ((result?.result ?? result)?.error?.code === 'already-installed') {
|
|
76
|
+
const removed = await manager.removeBundle(row.targetId)
|
|
77
|
+
if (!applied(removed)) throw new Error('The host did not remove the previous bundle.')
|
|
78
|
+
result = await manager.installBundle(spec, settings)
|
|
79
|
+
}
|
|
80
|
+
if (!applied(result)) throw new Error('The host did not apply the requested installation.')
|
|
81
|
+
return result
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
return await replace(`${row.targetId}@${version}`, version, REGISTRY)
|
|
85
|
+
} catch (error) {
|
|
86
|
+
let rollback
|
|
87
|
+
try {
|
|
88
|
+
if (await archiveDigest(row, profile.dir) !== digest) throw new Error('The original archive changed; automatic rollback refused.')
|
|
89
|
+
rollback = { ok: true, result: await replace(`file:${classifySpec(row.declaredSpec).detail}`, row.installedVersion) }
|
|
90
|
+
} catch (restoreError) { rollback = { ok: false, message: restoreError.message } }
|
|
91
|
+
return { changed: false, application: 'failed', error: { message: error.message }, rollback }
|
|
92
|
+
}
|
|
93
|
+
}
|
package/lib/host/routes.js
CHANGED
|
@@ -48,6 +48,8 @@ import {
|
|
|
48
48
|
writeSnapshot,
|
|
49
49
|
} from './snapshot-store.js'
|
|
50
50
|
import { classifySpec, declaredSpecMatches, isPrerelease, updateRefusal } from './spec.js'
|
|
51
|
+
import { applyMigration, canMigrate, previewMigration } from './registry-migration.js'
|
|
52
|
+
import { withMutationLock } from './mutation-lock.js'
|
|
51
53
|
|
|
52
54
|
/** Every route this plugin publishes, so the panel and the tests share one list. */
|
|
53
55
|
export const ROUTE_BASE = '/dsh-version-manager'
|
|
@@ -448,6 +450,11 @@ export async function readVersions(ctx, name, options = {}) {
|
|
|
448
450
|
}
|
|
449
451
|
const parsed = classifySpec(row.source, { official: row.official })
|
|
450
452
|
const refusal = updateRefusal(row, parsed)
|
|
453
|
+
if (refusal !== null && options.migrateToRegistry === true) {
|
|
454
|
+
const overview = await buildOverview(ctx)
|
|
455
|
+
const target = overview.plugins.find(entry => entry.targetId === name)
|
|
456
|
+
return previewMigration(target, profile, options)
|
|
457
|
+
}
|
|
451
458
|
if (refusal !== null) {
|
|
452
459
|
return {
|
|
453
460
|
status: 'read_only',
|
|
@@ -485,6 +492,7 @@ export async function readVersions(ctx, name, options = {}) {
|
|
|
485
492
|
deprecated: entry.deprecated ?? null,
|
|
486
493
|
isBundle: entry.bundle === true,
|
|
487
494
|
compatibility: entry.compatibility ?? null,
|
|
495
|
+
incompatible: entry.incompatible ?? null,
|
|
488
496
|
prerelease: isPrerelease(entry.version),
|
|
489
497
|
}
|
|
490
498
|
if (item.version === null) continue
|
|
@@ -761,7 +769,14 @@ export async function takeSnapshot(ctx, body) {
|
|
|
761
769
|
* @param {{ targetId: string, toVersion: string, allowPrerelease?: boolean }} body
|
|
762
770
|
* @returns {Promise<{ status: number, body: object }>}
|
|
763
771
|
*/
|
|
764
|
-
export async function runUpdate(ctx, body) {
|
|
772
|
+
export async function runUpdate(ctx, body, options = {}) {
|
|
773
|
+
const profile = readProfileContext(ctx)
|
|
774
|
+
if (profile.dir === null || profile.id === 'unknown') return { status: 409, body: { error: 'profile-identity-unknown' } }
|
|
775
|
+
const result = await withMutationLock({ dshHome: profile.home }, () => updateTarget(ctx, body, options))
|
|
776
|
+
return result?.reason === 'operation-in-progress' ? { status: 409, body: { error: result.reason } } : result
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
async function updateTarget(ctx, body, options) {
|
|
765
780
|
const profile = readProfileContext(ctx)
|
|
766
781
|
if (profile.dir === null || profile.id === 'unknown') {
|
|
767
782
|
return { status: 409, body: { error: 'profile-identity-unknown' } }
|
|
@@ -778,9 +793,23 @@ export async function runUpdate(ctx, body) {
|
|
|
778
793
|
const overview = await buildOverview(ctx)
|
|
779
794
|
const row = overview.plugins.find((entry) => entry.targetId === body.targetId)
|
|
780
795
|
if (row === undefined) return { status: 404, body: { error: 'unknown-target' } }
|
|
781
|
-
|
|
796
|
+
const migration = body.migrateToRegistry === true && canMigrate(row)
|
|
797
|
+
if (row.updateRefusal !== null && !migration) {
|
|
782
798
|
return { status: 409, body: { error: 'not-updatable', message: row.updateRefusal } }
|
|
783
799
|
}
|
|
800
|
+
if (body.fromVersion !== undefined && body.fromVersion !== row.installedVersion) {
|
|
801
|
+
return { status: 409, body: { error: 'stale-update-plan', message: 'Installed version changed; check updates again.' } }
|
|
802
|
+
}
|
|
803
|
+
let migrationPreview
|
|
804
|
+
if (migration) {
|
|
805
|
+
if (body.expectedSource !== row.declaredSpec || body.fromVersion !== row.installedVersion) {
|
|
806
|
+
return { status: 409, body: { error: 'source-confirmation-required' } }
|
|
807
|
+
}
|
|
808
|
+
migrationPreview = await previewMigration(row, profile, options)
|
|
809
|
+
if (migrationPreview.stable[0].version !== toVersion || body.archiveDigest !== migrationPreview.sourceMigration.archiveDigest) {
|
|
810
|
+
return { status: 409, body: { error: 'stale-update-plan' } }
|
|
811
|
+
}
|
|
812
|
+
}
|
|
784
813
|
if (isPrerelease(toVersion) && body.allowPrerelease !== true) {
|
|
785
814
|
return {
|
|
786
815
|
status: 409,
|
|
@@ -790,7 +819,7 @@ export async function runUpdate(ctx, body) {
|
|
|
790
819
|
},
|
|
791
820
|
}
|
|
792
821
|
}
|
|
793
|
-
if (toVersion === row.installedVersion) {
|
|
822
|
+
if (toVersion === row.installedVersion && !migration) {
|
|
794
823
|
return { status: 409, body: { error: 'already-at-version' } }
|
|
795
824
|
}
|
|
796
825
|
|
|
@@ -827,7 +856,9 @@ export async function runUpdate(ctx, body) {
|
|
|
827
856
|
// installation; a failure between them is the host's `restore` path, not ours.
|
|
828
857
|
let result
|
|
829
858
|
try {
|
|
830
|
-
result =
|
|
859
|
+
result = migration
|
|
860
|
+
? await applyMigration(pluginManager, row, toVersion, profile, migrationPreview.sourceMigration.archiveDigest)
|
|
861
|
+
: await pluginManager.updateBundle(row.targetId, toVersion, {})
|
|
831
862
|
} catch (error) {
|
|
832
863
|
await transition(profile.home, profile.id, record, 'failed', { error: messageOf(error) })
|
|
833
864
|
return {
|
|
@@ -838,14 +869,17 @@ export async function runUpdate(ctx, body) {
|
|
|
838
869
|
|
|
839
870
|
await transition(profile.home, profile.id, record, 'verifying')
|
|
840
871
|
const outcome = classifyUpdateResult(result)
|
|
872
|
+
const after = await buildOverview(ctx.root ?? ctx)
|
|
873
|
+
const afterRow = after.plugins.find((entry) => entry.targetId === body.targetId)
|
|
874
|
+
if (outcome.ok && (afterRow?.installedVersion !== toVersion || (migration && afterRow.source.kind !== 'registry'))) {
|
|
875
|
+
outcome.ok = false
|
|
876
|
+
outcome.message = 'The installed version or source does not match the requested result.'
|
|
877
|
+
}
|
|
841
878
|
const finalState = outcome.ok ? 'succeeded' : 'recovery_required'
|
|
842
879
|
await transition(profile.home, profile.id, record, finalState, {
|
|
843
880
|
error: outcome.message,
|
|
844
881
|
})
|
|
845
882
|
|
|
846
|
-
const after = await buildOverview(ctx)
|
|
847
|
-
const afterRow = after.plugins.find((entry) => entry.targetId === body.targetId)
|
|
848
|
-
|
|
849
883
|
return {
|
|
850
884
|
status: outcome.ok ? 200 : 502,
|
|
851
885
|
body: {
|
|
@@ -1315,7 +1349,7 @@ export function registerRoutes(ctx, scope) {
|
|
|
1315
1349
|
return
|
|
1316
1350
|
}
|
|
1317
1351
|
try {
|
|
1318
|
-
sendJson(response, 200, await readVersions(ctx, name))
|
|
1352
|
+
sendJson(response, 200, await readVersions(ctx, name, { migrateToRegistry: url.searchParams.get('migrateToRegistry') === 'true' }))
|
|
1319
1353
|
} catch (error) {
|
|
1320
1354
|
sendJson(response, 500, { error: 'versions-failed', message: messageOf(error) })
|
|
1321
1355
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-version-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Version management for DSH plugins and skills: an honest inventory of what is installed, a preview of what an update would change, a verifiable snapshot taken before the change, and a recovery path that is only offered when it can actually work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"docs/guide.en.md",
|
|
27
27
|
"docs/release-notes-0.1.6.md",
|
|
28
28
|
"docs/release-notes-0.1.7.md",
|
|
29
|
-
"CHANGELOG.md"
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"docs/release-notes-0.1.8.md"
|
|
30
31
|
],
|
|
31
32
|
"keywords": [
|
|
32
33
|
"deepseek",
|