Skip to content

Commit 1edbe5c

Browse files
authored
Merge branch 'main' into feat/task-health-status-maintenance
2 parents 646590f + 0fe193d commit 1edbe5c

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

extensions/discord/src/monitor/message-utils.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
55
const fetchRemoteMedia = vi.fn();
66
const saveMediaBuffer = vi.fn();
77

8-
vi.mock("openclaw/plugin-sdk/media-runtime", () => ({
9-
fetchRemoteMedia: (...args: unknown[]) => fetchRemoteMedia(...args),
10-
}));
11-
128
vi.mock("openclaw/plugin-sdk/media-runtime", async (importOriginal) => {
139
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/media-runtime")>();
1410
return {
1511
...actual,
12+
fetchRemoteMedia: (...args: unknown[]) => fetchRemoteMedia(...args),
1613
saveMediaBuffer: (...args: unknown[]) => saveMediaBuffer(...args),
1714
};
1815
});

src/plugin-sdk/package-contract-guardrails.test.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { execFileSync, spawnSync } from "node:child_process";
1+
import { spawnSync } from "node:child_process";
22
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
33
import { createRequire } from "node:module";
44
import os from "node:os";
55
import { dirname, join, relative, resolve } from "node:path";
66
import { fileURLToPath, pathToFileURL } from "node:url";
7+
import * as tar from "tar";
78
import { describe, expect, it } from "vitest";
89
import { pluginSdkEntrypoints } from "./entrypoints.js";
910

@@ -198,18 +199,23 @@ function packOpenClawToTempDir(packDir: string): string {
198199
return join(packDir, filename);
199200
}
200201

201-
function readPackedRootPackageJson(archivePath: string): {
202+
async function readPackedRootPackageJson(archivePath: string): Promise<{
202203
dependencies?: Record<string, string>;
203-
} {
204-
return JSON.parse(
205-
execFileSync("tar", ["-xOf", archivePath, "package/package.json"], {
206-
encoding: "utf8",
207-
maxBuffer: NPM_PACK_MAX_BUFFER_BYTES,
208-
stdio: ["ignore", "pipe", "pipe"],
209-
}),
210-
) as {
211-
dependencies?: Record<string, string>;
212-
};
204+
}> {
205+
const extractDir = mkdtempSync(join(os.tmpdir(), "openclaw-packed-root-package-json-"));
206+
try {
207+
await tar.x({
208+
file: archivePath,
209+
cwd: extractDir,
210+
filter: (entryPath) => entryPath === "package/package.json",
211+
strict: true,
212+
});
213+
return JSON.parse(readFileSync(join(extractDir, "package", "package.json"), "utf8")) as {
214+
dependencies?: Record<string, string>;
215+
};
216+
} finally {
217+
rmSync(extractDir, { recursive: true, force: true });
218+
}
213219
}
214220

215221
function readGeneratedFacadeTypeMap(): string {
@@ -332,14 +338,14 @@ describe("plugin-sdk package contract guardrails", () => {
332338
expect(resolvedPath).toContain("@matrix-org/matrix-sdk-crypto-wasm");
333339
});
334340

335-
it("keeps matrix crypto WASM in the packed artifact manifest", () => {
341+
it("keeps matrix crypto WASM in the packed artifact manifest", async () => {
336342
const tempRoot = mkdtempSync(join(os.tmpdir(), "openclaw-matrix-wasm-pack-"));
337343
try {
338344
const packDir = join(tempRoot, "pack");
339345
mkdirSync(packDir, { recursive: true });
340346

341347
const archivePath = packOpenClawToTempDir(packDir);
342-
const packedPackageJson = readPackedRootPackageJson(archivePath);
348+
const packedPackageJson = await readPackedRootPackageJson(archivePath);
343349
const matrixPackageJson = readMatrixPackageJson();
344350

345351
expect(packedPackageJson.dependencies?.["@matrix-org/matrix-sdk-crypto-wasm"]).toBe(

0 commit comments

Comments
 (0)