mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(ci): repair plugin prerelease validation (#117562)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
export const STATE_SCHEMA_INLINE_PLUGIN_NAME: string;
|
||||
|
||||
export function createStateSchemaInlinePlugin(rootDir?: string): {
|
||||
name: string;
|
||||
load(
|
||||
this: { addWatchFile(id: string): void },
|
||||
id: string,
|
||||
): { code: string; moduleType: "js" } | null;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
export const STATE_SCHEMA_INLINE_PLUGIN_NAME = "openclaw:inline-state-schemas";
|
||||
|
||||
const STATE_SCHEMA_MODULES = [
|
||||
{
|
||||
modulePath: "src/state/openclaw-state-schema.ts",
|
||||
schemaPath: "src/state/openclaw-state-schema.sql",
|
||||
exportName: "OPENCLAW_STATE_SCHEMA_SQL",
|
||||
},
|
||||
{
|
||||
modulePath: "src/state/openclaw-agent-schema.ts",
|
||||
schemaPath: "src/state/openclaw-agent-schema.sql",
|
||||
exportName: "OPENCLAW_AGENT_SCHEMA_SQL",
|
||||
},
|
||||
];
|
||||
|
||||
/** Inline canonical schema bytes so bundled consumers need no SQL asset. */
|
||||
export function createStateSchemaInlinePlugin(rootDir = process.cwd()) {
|
||||
const schemasByModulePath = new Map(
|
||||
STATE_SCHEMA_MODULES.map((schema) => [path.resolve(rootDir, schema.modulePath), schema]),
|
||||
);
|
||||
|
||||
return {
|
||||
name: STATE_SCHEMA_INLINE_PLUGIN_NAME,
|
||||
load(id) {
|
||||
const schema = schemasByModulePath.get(path.resolve(id));
|
||||
if (!schema) {
|
||||
return null;
|
||||
}
|
||||
const schemaPath = path.resolve(rootDir, schema.schemaPath);
|
||||
this.addWatchFile(schemaPath);
|
||||
return {
|
||||
code: `export const ${schema.exportName} = ${JSON.stringify(fs.readFileSync(schemaPath, "utf8"))};\n`,
|
||||
moduleType: "js",
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -80,8 +80,8 @@ vi.mock("./manifest-registry.js", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./plugin-registry.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./plugin-registry.js")>();
|
||||
vi.mock("./plugin-registry-snapshot.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./plugin-registry-snapshot.js")>();
|
||||
return {
|
||||
...actual,
|
||||
loadPluginRegistrySnapshot: mocks.loadPluginRegistrySnapshot,
|
||||
|
||||
@@ -61,7 +61,7 @@ vi.mock("./active-runtime-registry.js", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("./plugin-registry.js", () => ({
|
||||
vi.mock("./plugin-registry-snapshot.js", () => ({
|
||||
loadPluginRegistrySnapshot: mocks.loadPluginRegistrySnapshot,
|
||||
loadPluginRegistrySnapshotWithMetadata: mocks.loadPluginRegistrySnapshotWithMetadata,
|
||||
}));
|
||||
|
||||
@@ -16,8 +16,8 @@ import { resetPluginRuntimeStateForTest } from "./runtime.js";
|
||||
const loadPluginRegistrySnapshotWithMetadata = vi.hoisted(() => vi.fn());
|
||||
const loadPluginManifestRegistryForInstalledIndex = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("./plugin-registry.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./plugin-registry.js")>();
|
||||
vi.mock("./plugin-registry-snapshot.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./plugin-registry-snapshot.js")>();
|
||||
return {
|
||||
...actual,
|
||||
loadPluginRegistrySnapshotWithMetadata: (params: unknown) =>
|
||||
|
||||
@@ -104,9 +104,10 @@ function createRuntimeWebFetchProvider() {
|
||||
|
||||
describe("resolvePluginWebFetchProviders", () => {
|
||||
beforeAll(async () => {
|
||||
vi.doMock("./plugin-registry.js", async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import("./plugin-registry.js")>("./plugin-registry.js");
|
||||
vi.doMock("./plugin-registry-snapshot.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("./plugin-registry-snapshot.js")>(
|
||||
"./plugin-registry-snapshot.js",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
loadPluginRegistrySnapshotWithMetadata: () => ({
|
||||
|
||||
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
|
||||
import acpCorePackageJson from "../../packages/acp-core/package.json" with { type: "json" };
|
||||
import { pluginSdkSubpaths } from "../../scripts/lib/plugin-sdk-entries.mjs";
|
||||
import privateLocalOnlyPluginSdkSubpaths from "../../scripts/lib/plugin-sdk-private-local-only-subpaths.json" with { type: "json" };
|
||||
import { createStateSchemaInlinePlugin } from "../../scripts/lib/state-schema-inline-plugin.mjs";
|
||||
import {
|
||||
detectVitestHostInfo as detectVitestHostInfoImpl,
|
||||
isCiLikeEnv,
|
||||
@@ -158,6 +159,7 @@ if (!isCI && localScheduling.throttledBySystem && shouldPrintVitestThrottle(proc
|
||||
export const sharedVitestConfig = {
|
||||
root: repoRoot,
|
||||
envDir: false as const,
|
||||
plugins: [createStateSchemaInlinePlugin(repoRoot)],
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
|
||||
+5
-37
@@ -11,6 +11,10 @@ import {
|
||||
pluginSdkEntrypoints,
|
||||
productionPluginSdkEntrypoints,
|
||||
} from "./scripts/lib/plugin-sdk-entries.mjs";
|
||||
import {
|
||||
createStateSchemaInlinePlugin,
|
||||
STATE_SCHEMA_INLINE_PLUGIN_NAME,
|
||||
} from "./scripts/lib/state-schema-inline-plugin.mjs";
|
||||
import {
|
||||
TSDOWN_PACKAGE_CONFIG_GROUP,
|
||||
TSDOWN_UNIFIED_CONFIG_GROUP,
|
||||
@@ -46,43 +50,7 @@ const env = {
|
||||
const OUTPUT_SOURCE_MAPS = process.env.OUTPUT_SOURCE_MAPS === "1";
|
||||
const RUN_NODE_SKIP_DTS_BUILD = process.env.OPENCLAW_RUN_NODE_SKIP_DTS_BUILD === "1";
|
||||
const TSDOWN_DECLARATIONS = !RUN_NODE_SKIP_DTS_BUILD;
|
||||
export const STATE_SCHEMA_INLINE_PLUGIN_NAME = "openclaw:inline-state-schemas";
|
||||
|
||||
const STATE_SCHEMA_MODULES = [
|
||||
{
|
||||
modulePath: "src/state/openclaw-state-schema.ts",
|
||||
schemaPath: "src/state/openclaw-state-schema.sql",
|
||||
exportName: "OPENCLAW_STATE_SCHEMA_SQL",
|
||||
},
|
||||
{
|
||||
modulePath: "src/state/openclaw-agent-schema.ts",
|
||||
schemaPath: "src/state/openclaw-agent-schema.sql",
|
||||
exportName: "OPENCLAW_AGENT_SCHEMA_SQL",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/** Inline canonical schema bytes so packaged database opens need no SQL asset. */
|
||||
export function createStateSchemaInlinePlugin(rootDir: string = process.cwd()) {
|
||||
const schemasByModulePath = new Map(
|
||||
STATE_SCHEMA_MODULES.map((schema) => [path.resolve(rootDir, schema.modulePath), schema]),
|
||||
);
|
||||
|
||||
return {
|
||||
name: STATE_SCHEMA_INLINE_PLUGIN_NAME,
|
||||
load(this: { addWatchFile(id: string): void }, id: string) {
|
||||
const schema = schemasByModulePath.get(path.resolve(id));
|
||||
if (!schema) {
|
||||
return null;
|
||||
}
|
||||
const schemaPath = path.resolve(rootDir, schema.schemaPath);
|
||||
this.addWatchFile(schemaPath);
|
||||
return {
|
||||
code: `export const ${schema.exportName} = ${JSON.stringify(fs.readFileSync(schemaPath, "utf8"))};\n`,
|
||||
moduleType: "js" as const,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
export { createStateSchemaInlinePlugin, STATE_SCHEMA_INLINE_PLUGIN_NAME };
|
||||
|
||||
const SUPPRESSED_EVAL_WARNING_PATHS = [
|
||||
"@protobufjs/inquire/index.js",
|
||||
|
||||
Reference in New Issue
Block a user