chore: stop tracking generated diffs viewer runtime (#87405)

* chore: stop tracking generated diffs viewer runtime

* test(diffs): generate viewer runtime fixture when missing
This commit is contained in:
Dallin Romney
2026-05-27 19:59:35 -07:00
committed by GitHub
parent bf22893cb6
commit 5887119e8d
5 changed files with 44 additions and 262 deletions

1
.gitignore vendored
View File

@@ -249,6 +249,7 @@ extensions/qa-lab/web/dist/
# Generated bundled plugin runtime dependency manifests
extensions/**/.openclaw-runtime-deps.json
extensions/**/.openclaw-runtime-deps-stamp.json
extensions/diffs/assets/viewer-runtime.js
extensions/diffs-language-pack/assets/viewer-runtime.js
# Output dir for scripts/run-opengrep.sh (local opengrep scans)

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@ import {
validateJsonSchemaValue,
type JsonSchemaObject,
} from "openclaw/plugin-sdk/json-schema-runtime";
import { describe, expect, it, vi } from "vitest";
import { beforeAll, describe, expect, it, vi } from "vitest";
import {
DEFAULT_DIFFS_PLUGIN_SECURITY,
DEFAULT_DIFFS_TOOL_DEFAULTS,
@@ -17,6 +17,7 @@ import {
resolveDiffsPluginViewerBaseUrl,
} from "./config.js";
import { resolveDiffsLanguagePackAvailability } from "./plugin.js";
import { ensureCuratedViewerRuntimeForTests } from "./test-helpers.js";
import { buildViewerUrl, normalizeViewerBaseUrl } from "./url.js";
import {
getServedLanguagePackViewerAsset,
@@ -46,6 +47,10 @@ const FULL_DEFAULTS = {
ttlSeconds: 21_600,
} as const;
beforeAll(async () => {
await ensureCuratedViewerRuntimeForTests();
});
function compileManifestConfigSchema() {
const manifest = JSON.parse(
fs.readFileSync(new URL("../openclaw.plugin.json", import.meta.url), "utf8"),

View File

@@ -2,10 +2,14 @@ import fs from "node:fs/promises";
import type { IncomingMessage } from "node:http";
import path from "node:path";
import { createMockServerResponse } from "openclaw/plugin-sdk/test-env";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { createDiffsHttpHandler } from "./http.js";
import { DiffArtifactStore } from "./store.js";
import { createDiffStoreHarness } from "./test-helpers.js";
import { createDiffStoreHarness, ensureCuratedViewerRuntimeForTests } from "./test-helpers.js";
beforeAll(async () => {
await ensureCuratedViewerRuntimeForTests();
});
describe("DiffArtifactStore", () => {
let rootDir: string;

View File

@@ -1,8 +1,39 @@
import { execFile } from "node:child_process";
import fs from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { resolvePreferredOpenClawTmpDir } from "../api.js";
import { DiffArtifactStore } from "./store.js";
const execFileAsync = promisify(execFile);
async function pathExists(filePath: string): Promise<boolean> {
try {
await fs.stat(filePath);
return true;
} catch (error) {
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
return false;
}
throw error;
}
}
export async function ensureCuratedViewerRuntimeForTests(): Promise<void> {
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
const runtimePath = path.join(repoRoot, "extensions", "diffs", "assets", "viewer-runtime.js");
if (await pathExists(runtimePath)) {
return;
}
// The curated runtime is generated output. Source tests that serve viewer
// assets need a clean-checkout fixture before the normal build hook runs.
await execFileAsync(process.execPath, ["scripts/build-diffs-viewer-runtime.mjs", "curated"], {
cwd: repoRoot,
});
}
export async function createTempDiffRoot(prefix: string): Promise<{
rootDir: string;
cleanup: () => Promise<void>;