mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
fix(plugins): track package boundary dts freshness
This commit is contained in:
@@ -206,30 +206,26 @@ describe("check-extension-package-tsc-boundary", () => {
|
||||
).toBe("skipped 97 fresh plugin compiles\n");
|
||||
});
|
||||
|
||||
it("treats a plugin compile as fresh only when its outputs are newer than plugin and sdk inputs", () => {
|
||||
it("treats a plugin compile as fresh only when its outputs are newer than plugin and package sdk inputs", () => {
|
||||
const { rootDir, extensionRoot } = createTempExtensionRoot();
|
||||
const extensionSourcePath = path.join(extensionRoot, "index.ts");
|
||||
const extensionTsconfigPath = path.join(extensionRoot, "tsconfig.json");
|
||||
const stampPath = path.join(extensionRoot, "dist", ".boundary-tsc.stamp");
|
||||
const rootSdkBuildInfoPath = path.join(rootDir, "dist", "plugin-sdk", ".tsbuildinfo");
|
||||
const packageSdkBuildInfoPath = path.join(
|
||||
const rootSdkTypePath = path.join(rootDir, "dist", "plugin-sdk", "core.d.ts");
|
||||
const packageSdkTypePath = path.join(
|
||||
rootDir,
|
||||
"packages",
|
||||
"plugin-sdk",
|
||||
"dist",
|
||||
".tsbuildinfo",
|
||||
);
|
||||
const entryShimStampPath = path.join(
|
||||
rootDir,
|
||||
"dist",
|
||||
"src",
|
||||
"plugin-sdk",
|
||||
".boundary-entry-shims.stamp",
|
||||
"core.d.ts",
|
||||
);
|
||||
|
||||
fs.mkdirSync(path.dirname(extensionSourcePath), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(stampPath), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(rootSdkBuildInfoPath), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(packageSdkBuildInfoPath), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(rootSdkTypePath), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(packageSdkTypePath), { recursive: true });
|
||||
|
||||
fs.writeFileSync(extensionSourcePath, "export const demo = 1;\n", "utf8");
|
||||
fs.writeFileSync(
|
||||
@@ -238,26 +234,27 @@ describe("check-extension-package-tsc-boundary", () => {
|
||||
"utf8",
|
||||
);
|
||||
fs.writeFileSync(stampPath, "ok\n", "utf8");
|
||||
fs.writeFileSync(rootSdkBuildInfoPath, "ok\n", "utf8");
|
||||
fs.writeFileSync(packageSdkBuildInfoPath, "ok\n", "utf8");
|
||||
fs.writeFileSync(entryShimStampPath, "ok\n", "utf8");
|
||||
fs.writeFileSync(rootSdkTypePath, "export {};\n", "utf8");
|
||||
fs.writeFileSync(packageSdkTypePath, "export {};\n", "utf8");
|
||||
|
||||
fs.utimesSync(extensionSourcePath, new Date(1_000), new Date(1_000));
|
||||
fs.utimesSync(extensionTsconfigPath, new Date(1_000), new Date(1_000));
|
||||
fs.utimesSync(rootSdkBuildInfoPath, new Date(2_000), new Date(2_000));
|
||||
fs.utimesSync(packageSdkBuildInfoPath, new Date(2_000), new Date(2_000));
|
||||
fs.utimesSync(entryShimStampPath, new Date(2_000), new Date(2_000));
|
||||
fs.utimesSync(rootSdkTypePath, new Date(500), new Date(500));
|
||||
fs.utimesSync(packageSdkTypePath, new Date(2_000), new Date(2_000));
|
||||
fs.utimesSync(stampPath, new Date(3_000), new Date(3_000));
|
||||
|
||||
expect(isBoundaryCompileFresh("demo", { rootDir })).toBe(true);
|
||||
|
||||
fs.utimesSync(rootSdkBuildInfoPath, new Date(500), new Date(500));
|
||||
fs.utimesSync(packageSdkBuildInfoPath, new Date(500), new Date(500));
|
||||
fs.utimesSync(entryShimStampPath, new Date(500), new Date(500));
|
||||
fs.utimesSync(rootSdkTypePath, new Date(500), new Date(500));
|
||||
fs.utimesSync(packageSdkTypePath, new Date(500), new Date(500));
|
||||
|
||||
expect(isBoundaryCompileFresh("demo", { rootDir })).toBe(true);
|
||||
|
||||
fs.utimesSync(rootSdkBuildInfoPath, new Date(4_000), new Date(4_000));
|
||||
fs.utimesSync(rootSdkTypePath, new Date(4_000), new Date(4_000));
|
||||
|
||||
expect(isBoundaryCompileFresh("demo", { rootDir })).toBe(true);
|
||||
|
||||
fs.utimesSync(packageSdkTypePath, new Date(4_000), new Date(4_000));
|
||||
|
||||
expect(isBoundaryCompileFresh("demo", { rootDir })).toBe(false);
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
createPrefixedOutputWriter,
|
||||
isArtifactSetFresh,
|
||||
parseMode,
|
||||
runNodeStepsInParallel,
|
||||
} from "../../scripts/prepare-extension-package-boundary-artifacts.mjs";
|
||||
|
||||
@@ -85,4 +86,10 @@ describe("prepare-extension-package-boundary-artifacts", () => {
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("parses prep mode and rejects unknown values", () => {
|
||||
expect(parseMode([])).toBe("all");
|
||||
expect(parseMode(["--mode=package-boundary"])).toBe("package-boundary");
|
||||
expect(() => parseMode(["--mode=nope"])).toThrow("Unknown mode: nope");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user