refactor(#1558): plan runtime artifact uninstall removal (#1564)

This commit is contained in:
Tom Boucher
2026-06-21 21:55:29 -04:00
committed by GitHub
parent 3416dda9d4
commit 94e7e3f88f
4 changed files with 81 additions and 8 deletions

View File

@@ -24,6 +24,7 @@ interface ResolvedProfile {
interface ArtifactKind {
kind: ArtifactKindName;
destSubpath: string;
prefix?: string;
stage: (resolvedProfile: ResolvedProfile) => string;
}
@@ -64,6 +65,15 @@ interface InstallPlan {
cleanupDirs: string[];
}
interface UninstallPlanItem {
kind: ArtifactKindName;
destDir: string;
}
interface UninstallPlan {
items: UninstallPlanItem[];
}
type InstallPlanResult =
| { ok: true; plan: InstallPlan }
| { ok: false; kind: 'stage_failed' | 'rewrite_failed'; message: string; cleanupDirs: string[]; failedKind?: ArtifactKindName };
@@ -143,4 +153,13 @@ function createRuntimeArtifactInstallPlan(args: CreateRuntimeArtifactInstallPlan
return { ok: true, plan: { items, cleanupDirs } };
}
export = { createRuntimeArtifactInstallPlan };
function createRuntimeArtifactUninstallPlan(layout: Layout): UninstallPlan {
return {
items: layout.kinds.map((kind) => ({
kind: kind.kind,
destDir: path.join(layout.configDir, kind.destSubpath),
})),
};
}
export = { createRuntimeArtifactInstallPlan, createRuntimeArtifactUninstallPlan };