修复生产运维门禁格式误报
Project CI / Frontend tests (pull_request) Successful in 2m30s
Project CI / Repository checks (pull_request) Successful in 2m34s
Project CI / Backend tests (pull_request) Successful in 5m16s
Project CI / Native shell tests (pull_request) Successful in 15m55s

生产运维门禁对备份安全片段启用空白与尾逗号容错匹配
补充开发运维文档中的门禁匹配规则说明
This commit is contained in:
2026-08-28 04:11:15 +00:00
parent f4819e9a42
commit fa3b60777c
2 changed files with 18 additions and 2 deletions
+17 -1
View File
@@ -973,12 +973,14 @@ const checks = [
{
file: 'scripts/database-backup-to-oss.mjs',
includes: 'assertSufficientWorkDirSpace({dataDir, workDir, args, env})',
normalizeWhitespace: true,
reason: '生产冷备份必须先做工作目录剩余空间预检,避免停库后写满磁盘。',
},
{
file: 'scripts/database-backup-to-oss.mjs',
includes:
'restoreServicesAfterBackup({stopService, serviceStopped, restartServicesAfter, stopMarkerPath})',
normalizeWhitespace: true,
reason: '生产冷备份打包失败时也必须恢复 SpacetimeDB 及依赖服务。',
},
{
@@ -7504,9 +7506,23 @@ const databaseTargetSourceStashes = [
let failed = false;
function includesGuardrail(content, check) {
if (!check.includes) {
return true;
}
if (!check.normalizeWhitespace) {
return content.includes(check.includes);
}
const normalizeSourceFragment = (value) =>
value.replace(/\s+/gu, '').replace(/,([})])/gu, '$1');
const normalizedContent = normalizeSourceFragment(content);
const normalizedExpected = normalizeSourceFragment(check.includes);
return normalizedContent.includes(normalizedExpected);
}
for (const check of checks) {
const content = readFileSync(check.file, 'utf8');
if (check.includes && !content.includes(check.includes)) {
if (!includesGuardrail(content, check)) {
failed = true;
console.error(
`[check:production-ops] ${check.file} 缺少 ${check.includes}${check.reason}`,