Skip to content

Commit 09c39e0

Browse files
fix(scripts): keep bundled channel smoke standalone (#122212)
1 parent a1846db commit 09c39e0

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

‎scripts/test-built-bundled-channel-entry-smoke.mts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import fs from "node:fs";
66
import os from "node:os";
77
import path from "node:path";
88
import { fileURLToPath, pathToFileURL } from "node:url";
9-
import { isRecord } from "@openclaw/normalization-core/record-coerce";
109
import { collectRootPackageExcludedExtensionDirs } from "./lib/bundled-plugin-build-entries.mjs";
1110
import { parsePackageRootArg } from "./lib/package-root-args.mts";
11+
// Keep this prepack smoke independent of workspace package links.
12+
import { isRecord } from "./lib/record-shared.mjs";
1213
import { installProcessWarningFilter } from "./process-warning-filter.mts";
1314

1415
installProcessWarningFilter();

‎test/openclaw-prepack.test.ts‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,79 @@ import { useAutoCleanupTempDirTracker } from "./helpers/temp-dir.js";
2424

2525
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
2626

27+
const standaloneBundledChannelSmokeFiles = [
28+
"scripts/test-built-bundled-channel-entry-smoke.mts",
29+
"scripts/lib/bundled-plugin-build-entries.mjs",
30+
"scripts/lib/bundled-plugin-paths.mjs",
31+
"scripts/lib/optional-bundled-clusters.mjs",
32+
"scripts/lib/package-root-args.mts",
33+
"scripts/lib/record-shared.mjs",
34+
"scripts/process-warning-filter.mts",
35+
];
36+
37+
function runStandaloneBundledChannelSmoke(entrySource: string) {
38+
const rootDir = tempDirs.make("openclaw-prepack-standalone-smoke-");
39+
for (const relativePath of standaloneBundledChannelSmokeFiles) {
40+
const destination = path.join(rootDir, relativePath);
41+
mkdirSync(path.dirname(destination), { recursive: true });
42+
copyFileSync(path.join(process.cwd(), relativePath), destination);
43+
}
44+
45+
const packageRoot = path.join(rootDir, "package");
46+
const extensionRoot = path.join(packageRoot, "dist", "extensions", "fixture-channel");
47+
mkdirSync(extensionRoot, { recursive: true });
48+
writeFileSync(path.join(packageRoot, "package.json"), '{"files":[]}\n');
49+
writeFileSync(
50+
path.join(extensionRoot, "package.json"),
51+
`${JSON.stringify({
52+
name: "@openclaw/fixture-channel",
53+
openclaw: { channel: true, extensions: ["./index.ts"] },
54+
})}\n`,
55+
);
56+
writeFileSync(path.join(extensionRoot, "index.js"), entrySource);
57+
58+
return spawnSync(
59+
process.execPath,
60+
[
61+
path.join(rootDir, "scripts", "test-built-bundled-channel-entry-smoke.mts"),
62+
"--package-root",
63+
packageRoot,
64+
],
65+
{
66+
cwd: rootDir,
67+
encoding: "utf8",
68+
env: {
69+
...process.env,
70+
OPENCLAW_BUNDLED_CHANNEL_SMOKE_INSTALLED_LAYOUT: "1",
71+
},
72+
stdio: ["ignore", "pipe", "pipe"],
73+
},
74+
);
75+
}
76+
77+
describe("standalone bundled channel smoke", () => {
78+
it("runs without workspace packages linked at the root", () => {
79+
const result = runStandaloneBundledChannelSmoke(`
80+
export default {
81+
kind: "bundled-channel-entry",
82+
loadChannelPlugin() {
83+
return { id: "fixture-channel" };
84+
},
85+
};
86+
`);
87+
88+
expect(result.status, result.stderr).toBe(0);
89+
expect(result.stdout).toContain("channel=1");
90+
});
91+
92+
it("rejects a non-record channel entry default export", () => {
93+
const result = runStandaloneBundledChannelSmoke("export default [];\n");
94+
95+
expect(result.status).not.toBe(0);
96+
expect(result.stderr).toContain("AssertionError");
97+
});
98+
});
99+
27100
describe("collectSourcePackWorkspaceDependencyErrors", () => {
28101
it("rejects the plain source pack that pnpm rewrites without bundling @openclaw/ai", () => {
29102
const rootDir = tempDirs.make("openclaw-source-pack-workspace-");

0 commit comments

Comments
 (0)