feat(GOV-010): 强制校验开发质量证据
This commit is contained in:
@@ -3,7 +3,11 @@ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import { assertCurrentReleasedBaselinePublished } from '../database/schema-baseline.mjs';
|
||||
import { getFeatureDirectory, validateFeatureId } from './feature-record.mjs';
|
||||
import {
|
||||
buildImpactPlanTemplate,
|
||||
getFeatureDirectory,
|
||||
validateFeatureId,
|
||||
} from './feature-record.mjs';
|
||||
|
||||
const [featureId, slug] = process.argv.slice(2);
|
||||
const repositoryRoot = process.cwd();
|
||||
@@ -15,13 +19,15 @@ if (!featureId || !slug || !validateFeatureId(featureId)) {
|
||||
const featureDirectory = getFeatureDirectory(repositoryRoot, featureId, slug);
|
||||
const gitnexusDirectory = path.join(featureDirectory, 'gitnexus');
|
||||
const beforeReport = path.join(gitnexusDirectory, 'before.md');
|
||||
const impactPlan = path.join(gitnexusDirectory, 'impact-plan.md');
|
||||
|
||||
// Schema 基线必须在新版本的功能档案和 GitNexus 分析之前已经独立提交;
|
||||
// 这里仅做只读验证,绝不在一般功能开发命令中连接数据库或静默生成历史产物。
|
||||
assertCurrentReleasedBaselinePublished(repositoryRoot);
|
||||
|
||||
if (existsSync(beforeReport)) {
|
||||
throw new Error(`开发前报告已存在,为保护历史不会覆盖:${beforeReport}`);
|
||||
const existingReports = [beforeReport, impactPlan].filter((file) => existsSync(file));
|
||||
if (existingReports.length > 0) {
|
||||
throw new Error(`开发前报告已存在,为保护历史不会覆盖:${existingReports.join(', ')}`);
|
||||
}
|
||||
|
||||
mkdirSync(gitnexusDirectory, { recursive: true });
|
||||
@@ -64,5 +70,6 @@ writeFileSync(
|
||||
`\`gitnexus/impact-plan.md\`。高风险结果必须先获得用户确认。\n`,
|
||||
'utf8',
|
||||
);
|
||||
writeFileSync(impactPlan, buildImpactPlanTemplate(featureId), 'utf8');
|
||||
|
||||
process.stdout.write(`已创建开发前基线:${beforeReport}\n`);
|
||||
process.stdout.write(`已创建开发前基线:${beforeReport}\n已创建影响计划:${impactPlan}\n`);
|
||||
|
||||
Reference in New Issue
Block a user