实现示例type MavenDep = { groupId: string; artifactId: string; version: string; scope?: 'compile' | 'runtime' | 'test' } function semverLike(v: string): boolean { return /^(\d+\.\d+\.\d+)(?:[-A-Za-z0-9_.]+)?$/.test(v) } function aligned(root: MavenDep, child: MavenDep): boolean { return root.groupId === child.groupId && root.artifactId === child.artifactId && root.version === child.version } function evaluate(root: MavenDep[], children: MavenDep[]): { ok: boolean; errors: string[] } { const errors: string[] = []; for (const c of children) { const r = root.find(x => x.groupId === c.groupId && x.artifactId === c.artifactId); if (!r || !semverLike(c.version) || !aligned(r, c)) errors.push(`${c.groupId}:${c.artifactId}`) } return { ok: errors.length === 0, errors } } 审计与CI门禁审计版本对齐与范围;不一致阻断并输出修复建议。冻结策略对关键依赖设审批与窗口。

发表评论 取消回复