mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
fix(plugins): scrub canary artifacts for all opt-in packages
This commit is contained in:
@@ -272,13 +272,12 @@ export async function main(argv = process.argv.slice(2)) {
|
||||
const mode = parseMode(argv);
|
||||
const optInExtensionIds = collectOptInExtensionIds();
|
||||
const canaryExtensionIds = collectCanaryExtensionIds(optInExtensionIds);
|
||||
const cleanupExtensionIds = optInExtensionIds;
|
||||
const shouldRunCanary = mode === "all" || mode === "canary";
|
||||
const teardownCanaryCleanup = shouldRunCanary
|
||||
? installCanaryArtifactCleanup(canaryExtensionIds)
|
||||
: null;
|
||||
const teardownCanaryCleanup = installCanaryArtifactCleanup(cleanupExtensionIds);
|
||||
|
||||
try {
|
||||
cleanupCanaryArtifactsForExtensions(canaryExtensionIds);
|
||||
cleanupCanaryArtifactsForExtensions(cleanupExtensionIds);
|
||||
if (mode === "all" || mode === "compile") {
|
||||
await runCompileCheck(optInExtensionIds);
|
||||
}
|
||||
@@ -287,9 +286,7 @@ export async function main(argv = process.argv.slice(2)) {
|
||||
}
|
||||
} finally {
|
||||
teardownCanaryCleanup?.();
|
||||
if (shouldRunCanary) {
|
||||
cleanupCanaryArtifactsForExtensions(canaryExtensionIds);
|
||||
}
|
||||
cleanupCanaryArtifactsForExtensions(cleanupExtensionIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,16 @@ import {
|
||||
|
||||
const tempRoots = new Set<string>();
|
||||
|
||||
function createTempExtensionRoot() {
|
||||
function createTempExtensionRoot(extensionId = "demo") {
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-boundary-canary-"));
|
||||
tempRoots.add(rootDir);
|
||||
const extensionRoot = path.join(rootDir, "extensions", "demo");
|
||||
const extensionRoot = path.join(rootDir, "extensions", extensionId);
|
||||
fs.mkdirSync(extensionRoot, { recursive: true });
|
||||
return { rootDir, extensionRoot };
|
||||
}
|
||||
|
||||
function writeCanaryArtifacts(rootDir: string) {
|
||||
const { canaryPath, tsconfigPath } = resolveCanaryArtifactPaths("demo", rootDir);
|
||||
function writeCanaryArtifacts(rootDir: string, extensionId = "demo") {
|
||||
const { canaryPath, tsconfigPath } = resolveCanaryArtifactPaths(extensionId, rootDir);
|
||||
fs.writeFileSync(canaryPath, "export {};\n", "utf8");
|
||||
fs.writeFileSync(tsconfigPath, '{ "extends": "./tsconfig.json" }\n', "utf8");
|
||||
return { canaryPath, tsconfigPath };
|
||||
@@ -56,4 +56,26 @@ describe("check-extension-package-tsc-boundary", () => {
|
||||
expect(fs.existsSync(canaryPath)).toBe(false);
|
||||
expect(fs.existsSync(tsconfigPath)).toBe(false);
|
||||
});
|
||||
|
||||
it("cleans stale artifacts for every extension id passed to the cleanup hook", () => {
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-boundary-canary-"));
|
||||
tempRoots.add(rootDir);
|
||||
fs.mkdirSync(path.join(rootDir, "extensions", "demo-a"), { recursive: true });
|
||||
fs.mkdirSync(path.join(rootDir, "extensions", "demo-b"), { recursive: true });
|
||||
const demoA = writeCanaryArtifacts(rootDir, "demo-a");
|
||||
const demoB = writeCanaryArtifacts(rootDir, "demo-b");
|
||||
const processObject = new EventEmitter();
|
||||
const teardown = installCanaryArtifactCleanup(["demo-a", "demo-b"], {
|
||||
processObject,
|
||||
rootDir,
|
||||
});
|
||||
|
||||
processObject.emit("exit");
|
||||
teardown();
|
||||
|
||||
expect(fs.existsSync(demoA.canaryPath)).toBe(false);
|
||||
expect(fs.existsSync(demoA.tsconfigPath)).toBe(false);
|
||||
expect(fs.existsSync(demoB.canaryPath)).toBe(false);
|
||||
expect(fs.existsSync(demoB.tsconfigPath)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user