fix: 修复 PaC 环境复用计划语义

This commit is contained in:
root
2026-07-10 22:31:16 +02:00
parent a39f8b9ede
commit beacbdd37f
8 changed files with 362 additions and 29 deletions
+28
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env node
import { execFileSync } from "node:child_process";
import { readArtifactCatalogSummary } from "./src/artifact-catalog-authority.mjs";
const args = parseArgs(process.argv.slice(2));
const noDepsGitOpsOnlyPaths = Object.freeze([
@@ -25,6 +27,10 @@ if (args.help) {
const noDepsPlan = tryCreateNoDepsPlan(args);
if (noDepsPlan) {
const artifactCatalog = await noDepsArtifactCatalogSummary(args);
noDepsPlan.artifactCatalog = artifactCatalog;
noDepsPlan.compatibility.artifactCatalog = artifactCatalog.status === "missing" ? null : artifactCatalog.catalogPath;
noDepsPlan.compatibility.artifactCatalogAuthority = artifactCatalog.authority;
process.stdout.write(args.pretty ? `${JSON.stringify(noDepsPlan, null, 2)}\n` : `${JSON.stringify(noDepsPlan)}\n`);
process.exit(0);
}
@@ -73,7 +79,10 @@ function tryCreateNoDepsPlan(options) {
affectedServices: [],
rolloutServices: [],
buildServices: [],
rolloutWithoutImageBuildServices: [],
reusedServices: services,
serviceReusedCount: services.length,
imageBuildSkippedServices: services,
buildSkippedCount: services.length,
services: services.map((serviceId) => ({
serviceId,
@@ -89,6 +98,7 @@ function tryCreateNoDepsPlan(options) {
ciCdPlan: {
willBuild: [],
willRollout: [],
willRolloutWithoutImageBuild: [],
willReuse: services,
willRunGitopsPromote: summary.gitopsOnly,
noImageBuildReason: summary.summary
@@ -96,6 +106,24 @@ function tryCreateNoDepsPlan(options) {
};
}
async function noDepsArtifactCatalogSummary(options) {
const catalogPath = options.artifactCatalogPath;
if (!catalogPath) {
return {
status: "missing",
authority: "none",
catalogPath: null,
authorityPath: null,
gitopsBranch: null,
gitopsCommitId: null,
catalogSourceCommitId: null,
serviceCount: 0,
catalogSha256: null
};
}
return readArtifactCatalogSummary({ repoRoot: process.cwd(), catalogPath });
}
function classifyNoDepsGlobalChange(changedPaths) {
const relevant = changedPaths.filter(Boolean);
const testOnly = relevant.length > 0 && relevant.every(isNoDepsTestOnlyPath);