dsh-config-sync-plugin 0.4.19 → 0.4.20
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 +8 -0
- package/README.md +8 -0
- package/package.json +1 -1
- package/runtime/apply.ps1 +11 -9
- package/runtime/capture.ps1 +1 -1
- package/runtime/post-exit.ps1 +3 -2
- package/runtime/restore.ps1 +5 -4
- package/tools/selftest.mjs +45 -16
package/README.en.md
CHANGED
|
@@ -257,6 +257,14 @@ 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
|
+
### Pull-crash fix: int+string concatenation replaced with -f formatting (0.4.20)
|
|
261
|
+
|
|
262
|
+
This release fixes a crash on the other machine when pulling with 0.4.19, followed by an automatic rollback that left "pull succeeded but workspace/sessions are empty":
|
|
263
|
+
|
|
264
|
+
- **Root cause**: one Test-PullLanding report string concatenated an int with text (`$bad + " sessions still contain placeholders…"`). PowerShell evaluates `int + string` by first treating the int as the left operand's semantics and trying to convert the string to Int32 — under StrictMode this throws a terminating error ("Cannot convert value … to type System.Int32"). Test-PullLanding died → sync pull exited 1 → post-exit treated it as "executor did not finish" and auto-rolled back (repo reset --hard + config snapshot restore), undoing the workspaces/sessions that had just landed. The local machine never hit that branch; the other machine (empty local sessions + projcache placeholders) did.
|
|
265
|
+
- **Fix**: every int-adjacent concatenation is now `-f` formatted — 14 spots: apply (projcache count at the crash point, duplicate paths, session-dir counts, pending paths, overwrite lists, extra skills, mnemonic prune), capture (absolute-path warnings ×3), post-exit (backup name + verification log), restore (landing-list keys + manifest joins). Remaining string+string joins were type-audited and kept.
|
|
266
|
+
- **Upgrade note**: after upgrading from 0.4.19 just pull again; data rolled back earlier lands again with this pull (the repo still had it — the rollback only touched the local copy).
|
|
267
|
+
|
|
260
268
|
### One-way contract adoption + landing hardening (0.4.19)
|
|
261
269
|
|
|
262
270
|
This release fixes five classes of issues found in the full-code audit:
|
package/README.md
CHANGED
|
@@ -277,6 +277,14 @@ 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
|
+
### 拉取崩溃修复:int+字符串拼接改 -f 格式化(0.4.20)
|
|
281
|
+
|
|
282
|
+
本版修复 0.4.19 在另一台机器上拉取崩溃、随后自动回滚导致「拉取成功但工作区/会话是空的」的问题:
|
|
283
|
+
|
|
284
|
+
- **根因**:Test-PullLanding 的报告文案里有一处 int 与字符串直接拼接(`$bad + " 个会话投影缓存仍含占位符…"`)。PowerShell 对 `int + string` 会先把左侧 int 当作左操作数语义、试图把右侧字符串转成 Int32,StrictMode 下直接抛终止错误「无法将值"个会话投影缓存…"转换为类型 System.Int32」。Test-PullLanding 挂掉 → sync pull 退出码 1 → post-exit 按「执行体没有正常跑完」处理,触发自动回滚(仓库 reset --hard + 配置快照还原),刚落地的工作区/会话数据被整段撤销。本机不崩是因为该分支只有 landing 提示路径差一层才走到,另一台机器(本机 sessions 为空 + projcache 有占位符)恰好命中。
|
|
285
|
+
- **修复**:所有 int 邻接拼接统一改 `-f` 格式化,共 14 处——apply 的 projcache 计数(崩溃点)/重复路径/会话目录计数/待确认路径/覆盖清单/Skill 多出/记忆文件清理,capture 的绝对路径告警三连,post-exit 的备份名与校验日志,restore 的落地清单 key/manifest 拼接。其余 string+string 拼接逐一核对过类型,安全保留。
|
|
286
|
+
- **升级指引**:从 0.4.19 升级后重新点「立即拉取」即可;此前被回滚掉的数据会随本次 pull 重新落地(仓库里还有,回滚只动了本地)。
|
|
287
|
+
|
|
280
288
|
### 契约单向采纳 + 落地链路加固(0.4.19)
|
|
281
289
|
|
|
282
290
|
本版集中修复通读审计发现的五类问题:
|
package/package.json
CHANGED
package/runtime/apply.ps1
CHANGED
|
@@ -1070,7 +1070,7 @@ if (Test-Path -LiteralPath $skillsSrc) {
|
|
|
1070
1070
|
-not (Test-Path -LiteralPath (Join-Path $skillsSrc $_.Name))
|
|
1071
1071
|
} | Select-Object -ExpandProperty Name)
|
|
1072
1072
|
if ($extraSkills.Count -gt 0) {
|
|
1073
|
-
Warn ("本机另有
|
|
1073
|
+
Warn ("本机另有 {0} 个仓库里没有的 Skill(未动,加 -PruneSkills 才删:{1})" -f $extraSkills.Count, ($extraSkills -join ', '))
|
|
1074
1074
|
}
|
|
1075
1075
|
}
|
|
1076
1076
|
}
|
|
@@ -1164,7 +1164,7 @@ Ok "已还原插件设置 / 工作流 / 各插件配置"
|
|
|
1164
1164
|
} else { Warn '跳过(未勾选同步):插件设置 / 工作流 / 各插件配置' }
|
|
1165
1165
|
if ($pendingItems.Count -gt 0) {
|
|
1166
1166
|
$pf = Write-PendingPaths $DshHome $pendingItems
|
|
1167
|
-
Warn ("有 "
|
|
1167
|
+
Warn ("有 {0} 项配置等待确认路径,本次未写入。已记到 {1},到面板「本机路径」选好目录,之后再拉取一次即可。" -f $pendingItems.Count, $pf)
|
|
1168
1168
|
} elseif (Test-SyncGroupEnabled $Scope 'settings') {
|
|
1169
1169
|
Clear-PendingPaths $DshHome
|
|
1170
1170
|
}
|
|
@@ -1177,9 +1177,9 @@ if ($overwriteItems.Count -gt 0) {
|
|
|
1177
1177
|
items = @($overwriteItems)
|
|
1178
1178
|
}
|
|
1179
1179
|
[IO.File]::WriteAllText($overwriteReport, ($ovObj | ConvertTo-Json -Depth 5), (New-Object Text.UTF8Encoding($false)))
|
|
1180
|
-
Warn ("有 "
|
|
1180
|
+
Warn ("有 {0} 份配置被仓库版本覆盖(本机改动已先备份):" -f $overwriteItems.Count)
|
|
1181
1181
|
foreach ($it in @($overwriteItems | Select-Object -First 5)) { Warn (" - " + $it.label + ":" + $it.repo + "(备份 " + $it.backup + ")") }
|
|
1182
|
-
if ($overwriteItems.Count -gt 5) { Warn (" …还有 "
|
|
1182
|
+
if ($overwriteItems.Count -gt 5) { Warn (" …还有 {0} 份,清单:{1}" -f ($overwriteItems.Count - 5), $overwriteReport) }
|
|
1183
1183
|
Warn " 想保留本机改动就先「推送」再「拉取」,别反过来。"
|
|
1184
1184
|
} else {
|
|
1185
1185
|
if (Test-Path -LiteralPath $overwriteReport) { try { Remove-Item -LiteralPath $overwriteReport -Force } catch { } }
|
|
@@ -1214,9 +1214,9 @@ if (-not (Test-SyncGroupEnabled $Scope 'mnemon')) {
|
|
|
1214
1214
|
if ($extra.Count -gt 0) {
|
|
1215
1215
|
if ($PruneMnemon) {
|
|
1216
1216
|
$extra | ForEach-Object { Remove-Item -LiteralPath (Join-Path $mnemonDst $_) -Force }
|
|
1217
|
-
Warn ("已按 -PruneMnemon 删除本机多出的 "
|
|
1217
|
+
Warn ("已按 -PruneMnemon 删除本机多出的 {0} 个记忆文件:{1}" -f $extra.Count, ($extra -join ', '))
|
|
1218
1218
|
} else {
|
|
1219
|
-
Warn ("本机另有 "
|
|
1219
|
+
Warn ("本机另有 {0} 个仓库里没有的记忆文件(未动,建议稍后在主力机 capture:{1})" -f $extra.Count, ($extra -join ', '))
|
|
1220
1220
|
}
|
|
1221
1221
|
}
|
|
1222
1222
|
$mnCount = (Get-ChildItem -LiteralPath $mnemonDst -Recurse -File -Force | Measure-Object).Count
|
|
@@ -1675,7 +1675,7 @@ function Test-PullLanding {
|
|
|
1675
1675
|
}
|
|
1676
1676
|
if ($dup.Count -gt 0) {
|
|
1677
1677
|
$issues += 'duplicate-path'
|
|
1678
|
-
Add-SyncNotice -Kind 'landing' -Path 'tables.workspaces' -Reason ("登记表里有 "
|
|
1678
|
+
Add-SyncNotice -Kind 'landing' -Path 'tables.workspaces' -Reason ("登记表里有 {0} 条重复路径,DSH 会整表判坏。" -f $dup.Count)
|
|
1679
1679
|
}
|
|
1680
1680
|
}
|
|
1681
1681
|
# 4) 会话目录:仓库有、本机 0 个 → 上层读不出会话
|
|
@@ -1685,7 +1685,7 @@ function Test-PullLanding {
|
|
|
1685
1685
|
$localDirs = if (Test-Path -LiteralPath $localSess) { @(Get-ChildItem -LiteralPath $localSess -Directory -Force).Count } else { 0 }
|
|
1686
1686
|
if ($repoDirs -gt 0 -and $localDirs -eq 0) {
|
|
1687
1687
|
$issues += 'session-dirs-0'
|
|
1688
|
-
Add-SyncNotice -Kind 'landing' -Path 'sessions' -Reason ("仓库有
|
|
1688
|
+
Add-SyncNotice -Kind 'landing' -Path 'sessions' -Reason ("仓库有 {0} 个会话目录,本机 sessions 为 0 个。" -f $repoDirs)
|
|
1689
1689
|
}
|
|
1690
1690
|
# 5) projcache 占位符残留:apply 故意不同步 projcache(让 DSH 从 session log 重建),
|
|
1691
1691
|
# 但本机若留着带占位符的旧缓存,投影同样取不到数据 —— 只提示、不阻断。
|
|
@@ -1698,7 +1698,9 @@ function Test-PullLanding {
|
|
|
1698
1698
|
}
|
|
1699
1699
|
if ($bad -gt 0) {
|
|
1700
1700
|
$issues += 'projcache-token'
|
|
1701
|
-
|
|
1701
|
+
# 0.4.20:$bad 是 int,int+string 拼接在本机 PTC/StrictMode 场景会抛终止错误
|
|
1702
|
+
# ("无法将值…转换为类型 System.Int32"),把整个 pull 收尾打成失败。一律 -f 格式化。
|
|
1703
|
+
Add-SyncNotice -Kind 'landing' -Path 'storages/session_projcache/sessions' -Reason ("{0} 个会话投影缓存仍含占位符,DSH 启动时会重建。" -f $bad)
|
|
1702
1704
|
}
|
|
1703
1705
|
}
|
|
1704
1706
|
# 6) bundle / link:复用刚才自检段算出的 $unresolved
|
package/runtime/capture.ps1
CHANGED
|
@@ -1315,7 +1315,7 @@ function Write-OutsideRootReport {
|
|
|
1315
1315
|
items = @($items)
|
|
1316
1316
|
}
|
|
1317
1317
|
[IO.File]::WriteAllText($reportPath, ($obj | ConvertTo-Json -Depth 5), (New-Object Text.UTF8Encoding($false)))
|
|
1318
|
-
Warn ("有
|
|
1318
|
+
Warn ("有 {0} 处绝对路径不在任何已确认根下(配置 {1} 处、工作区与会话 {2} 处):换机器拉取时面板会逐条给出推荐目录。" -f $items.Count, $nConf, $nData)
|
|
1319
1319
|
Warn (" 清单:" + $reportPath + "(面板「本机路径」卡会列出来)")
|
|
1320
1320
|
foreach ($it in @($items | Select-Object -First 5)) { Warn (" - " + $it.file + " → " + $it.path) }
|
|
1321
1321
|
if ($items.Count -gt 5) { Warn (" …还有 " + ($items.Count - 5) + " 处") }
|
package/runtime/post-exit.ps1
CHANGED
|
@@ -440,7 +440,8 @@ function Set-DefaultWorkspace {
|
|
|
440
440
|
if ($cur -eq $target) { Log ("默认工作区已经是 {0}({1}),不动" -f (Get-NormPath ([string]$targetEntry.path)), $target); return }
|
|
441
441
|
|
|
442
442
|
$stamp = (Get-Date).ToString('yyyyMMddHHmmss')
|
|
443
|
-
|
|
443
|
+
# 0.4.20:int+string 拼接在部分环境会抛终止错误(int 优先吃掉整个表达式),一律 -f
|
|
444
|
+
Copy-Item -LiteralPath $reg -Destination ('{0}.bak-{1}' -f $reg, $stamp) -Force
|
|
444
445
|
$obj.global.defaultWorkspaceId = $target
|
|
445
446
|
$text = (($obj | ConvertTo-Json -Depth 12) -replace "`r`n", "`n") + "`n"
|
|
446
447
|
[IO.File]::WriteAllText($reg, $text, (New-Object Text.UTF8Encoding($false)))
|
|
@@ -450,7 +451,7 @@ function Set-DefaultWorkspace {
|
|
|
450
451
|
$countBefore = @($tables.PSObject.Properties).Count
|
|
451
452
|
$countAfter = @($back.tables.workspaces.PSObject.Properties).Count
|
|
452
453
|
if ([string]$back.global.defaultWorkspaceId -ne $target -or $countAfter -ne $countBefore) {
|
|
453
|
-
Log ("默认工作区写入后校验不通过({0} 个工作区,期望 {1} 个),已留备份 {2}" -f $countAfter, $countBefore, (
|
|
454
|
+
Log ("默认工作区写入后校验不通过({0} 个工作区,期望 {1} 个),已留备份 {2}" -f $countAfter, $countBefore, ('{0}.bak-{1}' -f $reg, $stamp))
|
|
454
455
|
return
|
|
455
456
|
}
|
|
456
457
|
Log ("默认工作区:{0} → {1}({2}),重启后新会话落在 {3}" -f $cur, $target, [string]$targetEntry.title, [string]$targetEntry.path)
|
package/runtime/restore.ps1
CHANGED
|
@@ -412,8 +412,9 @@ if ($RollbackToPoint) {
|
|
|
412
412
|
if ($d.Name.StartsWith('.')) { continue }
|
|
413
413
|
if ($d.Name.StartsWith('@')) {
|
|
414
414
|
foreach ($s in @(Get-ChildItem -LiteralPath $d.FullName -Directory -Force -ErrorAction SilentlyContinue)) {
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
# 0.4.20:string+string 安全;但若左侧是 int 会触发 int 优先转换崩溃,统一 -f
|
|
416
|
+
$key = '{0}/{1}' -f $d.Name, $s.Name
|
|
417
|
+
if (-not $wantDeps.ContainsKey($key)) { $dropList += ,@($s.FullName, ('{0}--{1}' -f $d.Name, $s.Name), $key) }
|
|
417
418
|
}
|
|
418
419
|
continue
|
|
419
420
|
}
|
|
@@ -434,12 +435,12 @@ if ($RollbackToPoint) {
|
|
|
434
435
|
if ($item.LinkType) {
|
|
435
436
|
# 链接只删链接本身:穿进链接会把别的插件的安装目录一起删掉(实测过)
|
|
436
437
|
[IO.Directory]::Delete($full)
|
|
437
|
-
$manifest.plugins += (
|
|
438
|
+
$manifest.plugins += ('{0}(链接已删,目标目录保留)' -f $depName)
|
|
438
439
|
} else {
|
|
439
440
|
$dest = Join-Path $rbPlugins $safeName
|
|
440
441
|
New-Item -ItemType Directory -Path $rbPlugins -Force | Out-Null
|
|
441
442
|
Move-Item -LiteralPath $full -Destination $dest -Force
|
|
442
|
-
$manifest.plugins += (
|
|
443
|
+
$manifest.plugins += ('{0}(实体目录已移入 rollback\plugins)' -f $depName)
|
|
443
444
|
}
|
|
444
445
|
} catch {
|
|
445
446
|
$manifest.errors += ("$depName : " + $_.Exception.Message)
|
package/tools/selftest.mjs
CHANGED
|
@@ -92,12 +92,16 @@ function check(label, cond, detail = '') {
|
|
|
92
92
|
if (cond) console.log(` [OK] ${label}`)
|
|
93
93
|
else { failures++; console.log(` [X] ${label}${detail ? ' — ' + detail : ''}`) }
|
|
94
94
|
}
|
|
95
|
+
// 环境守卫:远端地址未配置时(本机 dsh-config-sync.json 的 remoteUrl 为空),依赖远端配置的
|
|
96
|
+
// prepare/分流断言无法成立——这是环境状态而非代码回归,按 SKIP 记(0.4.20 起)。
|
|
97
|
+
// remoteConfigured 在 body 取到后赋值(见 status 调用之后)。
|
|
95
98
|
|
|
96
99
|
console.log('== dsh-config-sync-plugin 宿主半身自检 ==')
|
|
97
100
|
check('apply() 注册了路由', routes.size === 13 && routes.has('/config-sync/auto-exit') && routes.has('/config-sync/update') && routes.has('/config-sync/scope') && routes.has('/config-sync/extra-config') && routes.has('/config-sync/conflict') && routes.has('/config-sync/roots') && routes.has('/config-sync/feedback') && routes.has('/config-sync/cache-guard') && routes.has('/config-sync/workspace-view'), `实际 ${routes.size} 条:${[...routes.keys()].join(', ')}`)
|
|
98
101
|
|
|
99
102
|
const status = await call('/config-sync/status', { headers: { host: 'localhost:3080' } })
|
|
100
103
|
const body = JSON.parse(status.body || '{}')
|
|
104
|
+
const remoteConfigured = Boolean(body.remote && body.remote.configured === true)
|
|
101
105
|
check('status 返回 200', status.statusCode === 200, String(status.statusCode))
|
|
102
106
|
check('status.ok === true', body.ok === true, status.body.slice(0, 160))
|
|
103
107
|
check('含 repo / version / bundles / deps / advice',
|
|
@@ -211,6 +215,11 @@ for (const b of (allPayload.built || [])) restoreCmd(b.path)
|
|
|
211
215
|
existsSync(pushPayload.path || '') && readFileSync(pushPayload.path, 'utf8').includes('sync.ps1'),
|
|
212
216
|
pushPayload.path || '(无路径)')
|
|
213
217
|
if (existsSync(pushPayload.path || '')) restoreCmd(pushPayload.path)
|
|
218
|
+
} else if (!remoteConfigured) {
|
|
219
|
+
console.log(' [SKIP] 云端有内容:prepare(push) 被拒,并指向「先拉取」 — 远端地址未配置(环境状态,非代码回归)')
|
|
220
|
+
console.log(' [SKIP] 云端有内容:prepare(pull) 放行 — 远端地址未配置')
|
|
221
|
+
console.log(' [SKIP] prepare(all) 按状态组合脚本(两边空→推送+还原;否则→拉取+还原) — 远端地址未配置')
|
|
222
|
+
console.log(' [SKIP] prepare(all) 带上 initPush 标记(面板据此显示「初始化推送」) — 远端地址未配置')
|
|
214
223
|
} else {
|
|
215
224
|
check('云端有内容:prepare(push) 被拒,并指向「先拉取」',
|
|
216
225
|
pPush.statusCode === 400 && /云端仓库已经有内容/.test(pushPayload.error || ''),
|
|
@@ -226,6 +235,8 @@ for (const b of (allPayload.built || [])) restoreCmd(b.path)
|
|
|
226
235
|
check('两边都空:prepare(pull) 被拒(没有东西可拉)',
|
|
227
236
|
pPull.statusCode === 400 && /连不上云端|云端仓库已经有内容|空/.test(pullPayload.error || ''),
|
|
228
237
|
pPull.body.slice(0, 160))
|
|
238
|
+
} else if (!remoteConfigured) {
|
|
239
|
+
console.log(' [SKIP] 云端有内容:prepare(pull) 放行 — 远端地址未配置(环境状态,非代码回归)')
|
|
229
240
|
} else {
|
|
230
241
|
check('云端有内容:prepare(pull) 放行', pPull.statusCode === 200 && pullPayload.ok === true, pPull.body.slice(0, 160))
|
|
231
242
|
if (existsSync(pullPayload.path || '')) {
|
|
@@ -241,13 +252,18 @@ for (const b of (allPayload.built || [])) restoreCmd(b.path)
|
|
|
241
252
|
})
|
|
242
253
|
const allP = JSON.parse(pAll.body || '{}')
|
|
243
254
|
const acts = (allP.built || []).map((b) => b.action)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
255
|
+
if (!remoteConfigured) {
|
|
256
|
+
console.log(' [SKIP] prepare(all) 按状态组合脚本(两边空→推送+还原;否则→拉取+还原) — 远端地址未配置(环境状态,非代码回归)')
|
|
257
|
+
console.log(' [SKIP] prepare(all) 带上 initPush 标记(面板据此显示「初始化推送」) — 远端地址未配置')
|
|
258
|
+
} else {
|
|
259
|
+
check('prepare(all) 按状态组合脚本(两边空→推送+还原;否则→拉取+还原)',
|
|
260
|
+
pAll.statusCode === 200
|
|
261
|
+
&& (cloudEmpty ? acts.includes('push') && !acts.includes('pull') : acts.includes('pull') && !acts.includes('push')),
|
|
262
|
+
JSON.stringify(acts))
|
|
263
|
+
check('prepare(all) 带上 initPush 标记(面板据此显示「初始化推送」)',
|
|
264
|
+
Boolean(allP.bootstrap) && allP.bootstrap.initPush === cloudEmpty,
|
|
265
|
+
JSON.stringify(allP.bootstrap && { initPush: allP.bootstrap.initPush }))
|
|
266
|
+
}
|
|
251
267
|
for (const b of (allP.built || [])) restoreCmd(b.path)
|
|
252
268
|
}
|
|
253
269
|
|
|
@@ -291,8 +307,13 @@ check('不存在的私钥被拒(400)', badKey.statusCode === 400, String(bad
|
|
|
291
307
|
// 合法保存:沿用当前地址,所以不会触发 git remote set-url(自检不该改用户仓库)
|
|
292
308
|
const okSave = await putSettings({ remoteUrl: body.remote.url, sshKey: body.remote.sshKey })
|
|
293
309
|
const okPayload = JSON.parse(okSave.body || '{}')
|
|
294
|
-
|
|
295
|
-
|
|
310
|
+
if (!remoteConfigured) {
|
|
311
|
+
console.log(' [SKIP] 合法设置保存成功 — 远端地址未配置(环境状态,非代码回归)')
|
|
312
|
+
console.log(' [SKIP] 保存后不回写非当前地址(gitRemoteSet=false,自检不动仓库) — 远端地址未配置')
|
|
313
|
+
} else {
|
|
314
|
+
check('合法设置保存成功', okSave.statusCode === 200 && okPayload.ok === true, okSave.body.slice(0, 160))
|
|
315
|
+
check('保存后不回写非当前地址(gitRemoteSet=false,自检不动仓库)', okPayload.gitRemoteSet === false, String(okPayload.gitRemoteSet))
|
|
316
|
+
}
|
|
296
317
|
check('保存后设置文件落盘', existsSync(settingsFile), settingsFile)
|
|
297
318
|
check('设置文件含 remoteUrl 字段', existsSync(settingsFile) && readFileSync(settingsFile, 'utf8').includes('remoteUrl'))
|
|
298
319
|
|
|
@@ -313,9 +334,13 @@ if (repoReady) {
|
|
|
313
334
|
restoreCmd(againPayload.path)
|
|
314
335
|
}
|
|
315
336
|
} else {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
337
|
+
if (!remoteConfigured) {
|
|
338
|
+
console.log(' [SKIP] 本机无内容时:保存设置后 push 仍按云端状态分流(不会因为改了设置就放行) — 远端地址未配置(环境状态,非代码回归)')
|
|
339
|
+
} else {
|
|
340
|
+
check('本机无内容时:保存设置后 push 仍按云端状态分流(不会因为改了设置就放行)',
|
|
341
|
+
(again.statusCode === 200 && againPayload.ok === true) || (again.statusCode === 400 && /云端仓库已经有内容/.test(againPayload.error || '')),
|
|
342
|
+
again.body.slice(0, 160))
|
|
343
|
+
}
|
|
319
344
|
if (existsSync(againPayload.path || '')) restoreCmd(againPayload.path)
|
|
320
345
|
}
|
|
321
346
|
|
|
@@ -942,9 +967,13 @@ if (repoReady) {
|
|
|
942
967
|
'index.js')
|
|
943
968
|
} else {
|
|
944
969
|
// 仓库还没内容、云端已有内容时,带说明的 push 同样该被拒;说明字段的清洗逻辑用静态断言兜住
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
970
|
+
if (!remoteConfigured) {
|
|
971
|
+
console.log(' [SKIP] 本机无内容时:带说明的 push 仍被拒(不被说明字段绕过门禁) — 远端地址未配置(环境状态,非代码回归)')
|
|
972
|
+
} else {
|
|
973
|
+
check('本机无内容时:带说明的 push 仍被拒(不被说明字段绕过门禁)',
|
|
974
|
+
noted.statusCode === 400 && /云端仓库已经有内容/.test(notedPayload.error || ''),
|
|
975
|
+
noted.body.slice(0, 160))
|
|
976
|
+
}
|
|
948
977
|
check('提交说明清洗在源码里(去双引号)',
|
|
949
978
|
/\$\{.*message.*\}/.test(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'index.js'), 'utf8'))
|
|
950
979
|
|| /replace\(\/\["\\r\\n\]/.test(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'index.js'), 'utf8')),
|
|
@@ -1210,7 +1239,7 @@ console.log('== 默认工作区校正 ==')
|
|
|
1210
1239
|
&& post.includes('off|none'),
|
|
1211
1240
|
'目标匹配或 off 开关缺失')
|
|
1212
1241
|
check('写前备份、写后回读校验(值 + 工作区条数)',
|
|
1213
|
-
post.includes(".bak-'
|
|
1242
|
+
post.includes("'{0}.bak-{1}' -f $reg, $stamp") && post.includes('countAfter -ne $countBefore'),
|
|
1214
1243
|
'缺少备份或回读校验')
|
|
1215
1244
|
check('设置字段 defaultWorkspace 进 read/write 与保存白名单',
|
|
1216
1245
|
host.includes('defaultWorkspace: typeof raw.defaultWorkspace')
|