dsh-config-sync-plugin 0.4.12 → 0.4.13
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.en.md +7 -0
- package/README.md +7 -0
- package/index.js +15 -3
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -257,6 +257,13 @@ Two display fixes on top of 0.3.77:
|
|
|
257
257
|
|
|
258
258
|
The "Plugin update" card now shows an **npm download URL** line with the actual fallback addresses (domestic mirror `registry.npmmirror.com` + official `registry.npmjs.org`). When the GitHub release download is unreachable (common in mainland China), the update package automatically falls back to npm. It is still verified against the authoritative sha256 in `version.json` — switching source never relaxes verification. The two sources back each other up: the mirror can briefly 404 during its first-sync window, and the official source takes over. The npm tarball is byte-identical to the GitHub release tgz (same sha256).
|
|
259
259
|
|
|
260
|
+
### Fix npm fallback download sha256 mismatch (0.4.13)
|
|
261
|
+
|
|
262
|
+
This release fixes the npm fallback download failures introduced in v0.4.12:
|
|
263
|
+
|
|
264
|
+
- **Root cause**: `version.json` only recorded the GitHub release asset's sha256, but npm tarballs (npmmirror + official registry) are different build artifacts with different hashes. When GitHub release was unreachable and the download fell back to npm, it still used the GitHub sha256 for verification, causing all fallback downloads to fail.
|
|
265
|
+
- **Fix**: `version.json` adds an `npmSha256` field recording the npm tarball hash; download logic adds `isNpmRegistryUrl()` and `pickSha256ForUrl()` to automatically pick the correct hash by URL source (GitHub release uses `sha256`, npm registry uses `npmSha256`). GitHub release unreachable cases now correctly fall back to npm and pass verification.
|
|
266
|
+
|
|
260
267
|
### Content-level pending detection: only prompt to push when content actually changed (0.4.12)
|
|
261
268
|
|
|
262
269
|
This release changes the "pending push" rule from a timestamp check to a content-level check, fixing false positives without altering the normal push/pull flow:
|
package/README.md
CHANGED
|
@@ -277,6 +277,13 @@ pwsh -File runtime\sync.ps1 pull `
|
|
|
277
277
|
|
|
278
278
|
「插件更新」卡新增一行 **npm 下载路径**,直接显示实际兜底地址(国内镜像 `registry.npmmirror.com` + 官方 `registry.npmjs.org` 两个源)。GitHub release 整段不通时(国内常见),更新包会自动兜底从 npm 下载;仍按 `version.json` 里的权威 sha256 校验,换源不放宽校验。两个源互为备份:镜像首发同步窗口期会短暂 404,官方源随即兜上。实测 npm tarball 与 GitHub release tgz 是同一份产物、sha256 完全一致。
|
|
279
279
|
|
|
280
|
+
### 修复 npm 兜底下载 sha256 校验不一致(0.4.13)
|
|
281
|
+
|
|
282
|
+
本版解决 v0.4.12 引入的 npm 兜底下载全部失败问题:
|
|
283
|
+
|
|
284
|
+
- **根因**:`version.json` 只记录 GitHub release asset 的 sha256,但 npm tarball(npmmirror + 官方 registry)打包产物不同,哈希不一致。GitHub release 不通时回退到 npm,仍用 GitHub 的 sha256 校验,导致全部失败。
|
|
285
|
+
- **修复**:`version.json` 新增 `npmSha256` 字段记录 npm tarball 哈希;下载逻辑新增 `isNpmRegistryUrl()` 与 `pickSha256ForUrl()`,按 URL 来源自动选对应哈希(GitHub release 用 `sha256`、npm registry 用 `npmSha256`)。GitHub release 不通时可正常走 npm 兜底下载并通过校验。
|
|
286
|
+
|
|
280
287
|
### 待推送判据改为内容级:实际内容变了才提示推送(0.4.12)
|
|
281
288
|
|
|
282
289
|
本版把「待推送」从时间戳判据改为内容级判据,只修误报、不改变正常推送/拉取流程:
|
package/index.js
CHANGED
|
@@ -2578,6 +2578,17 @@ function npmTgzUrls(version) {
|
|
|
2578
2578
|
`https://registry.npmjs.org/dsh-config-sync-plugin/-/${f}`,
|
|
2579
2579
|
]
|
|
2580
2580
|
}
|
|
2581
|
+
|
|
2582
|
+
/** 判断 URL 是否为 npm registry 源(需用 npmSha256 校验) */
|
|
2583
|
+
function isNpmRegistryUrl(url) {
|
|
2584
|
+
const u = String(url || '')
|
|
2585
|
+
return u.includes('registry.npmmirror.com') || u.includes('registry.npmjs.org')
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
/** 根据 URL 选择对应的 sha256:npm 源用 npmSha256,GitHub release 用 sha256 */
|
|
2589
|
+
function pickSha256ForUrl(url, githubSha256, npmSha256) {
|
|
2590
|
+
return isNpmRegistryUrl(url) ? (npmSha256 || githubSha256) : githubSha256
|
|
2591
|
+
}
|
|
2581
2592
|
// 兼容旧调用:返回首选 npm 兜底地址
|
|
2582
2593
|
function npmTgzUrl(version) {
|
|
2583
2594
|
const list = npmTgzUrls(version)
|
|
@@ -2775,16 +2786,17 @@ function updatePayload(state, settings = {}) {
|
|
|
2775
2786
|
* 候选地址逐个试(raw 常常不通,反代在前面兜着),全失败时把每个源的原因汇总抛出。
|
|
2776
2787
|
* 返回 { ok, file, size, sha256, url } 或 { ok:false, error }
|
|
2777
2788
|
*/
|
|
2778
|
-
async function downloadPackage({ urls, sha256, version, dshHome }) {
|
|
2789
|
+
async function downloadPackage({ urls, sha256, npmSha256, version, dshHome }) {
|
|
2779
2790
|
if (typeof fetch !== 'function') return { ok: false, error: t('当前运行环境没有 fetch,无法下载更新包', 'fetch is unavailable in this runtime — cannot download the update package') }
|
|
2780
2791
|
const dir = join(dshHome, 'update-staging')
|
|
2781
2792
|
try { mkdirSync(dir, { recursive: true }) } catch { }
|
|
2782
2793
|
const file = join(dir, `dsh-config-sync-plugin-${version}.tgz`)
|
|
2783
|
-
const want = String(sha256 || '').toLowerCase()
|
|
2784
2794
|
const errors = []
|
|
2785
2795
|
for (const rawUrl of urls) {
|
|
2786
2796
|
const url = String(rawUrl || '').trim()
|
|
2787
2797
|
if (!url) continue
|
|
2798
|
+
// 根据 URL 来源选择对应的 sha256:npm 源用 npmSha256,GitHub release 用 sha256
|
|
2799
|
+
const want = String(pickSha256ForUrl(url, sha256, npmSha256) || '').toLowerCase()
|
|
2788
2800
|
try {
|
|
2789
2801
|
const ctrl = typeof AbortController === 'function' ? new AbortController() : null
|
|
2790
2802
|
const timer = ctrl ? setTimeout(() => { try { ctrl.abort() } catch { } }, 120 * 1000) : null
|
|
@@ -2899,7 +2911,7 @@ async function handleUpdate(req, res, config) {
|
|
|
2899
2911
|
}
|
|
2900
2912
|
const urls = resolveTgzCandidates(remote, state.url)
|
|
2901
2913
|
if (!urls.length) throw new Error(t('version.json 里没有给 tgz 下载地址', 'version.json gives no tgz download URL'))
|
|
2902
|
-
const got = await downloadPackage({ urls, sha256: String(remote.sha256 || ''), version: String(remote.version), dshHome })
|
|
2914
|
+
const got = await downloadPackage({ urls, sha256: String(remote.sha256 || ''), npmSha256: String(remote.npmSha256 || ''), version: String(remote.version), dshHome })
|
|
2903
2915
|
if (!got.ok) throw new Error(String(got.error || t('下载失败', 'download failed')))
|
|
2904
2916
|
updateState.prepared = {
|
|
2905
2917
|
version: String(remote.version),
|
package/package.json
CHANGED