6b76463941
- Fixed npm CLI bundling by invoking `generate-client-bundle.ts --generate` before build and `--reset` after. - Added `PI_BUNDLED` handling in `packages/stats/src/server.ts` and switched bundled distributions to embedded assets. - Decoded embedded archives via `decodeEmbeddedClientArchive` and treated legacy placeholder content as missing. - Handled missing dashboard source/build directories as ENOENT during mtime scans to avoid startup crashes. - Extended `--smoke-test` to start the stats server and validate dashboard HTML contains expected asset markers.
31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import * as path from "node:path";
|
|
|
|
describe("stats dashboard assets in distributed CLI builds", () => {
|
|
const repoRoot = path.resolve(import.meta.dir, "../../..");
|
|
const bundleScriptPath = path.join(repoRoot, "packages/coding-agent/scripts/bundle-dist.ts");
|
|
const cliPath = path.join(repoRoot, "packages/coding-agent/src/cli.ts");
|
|
const statsServerPath = path.join(repoRoot, "packages/stats/src/server.ts");
|
|
|
|
it("embeds the stats client archive while building the npm CLI bundle", async () => {
|
|
const bundleScript = await Bun.file(bundleScriptPath).text();
|
|
expect(bundleScript).toContain(`"scripts/generate-client-bundle.ts", "--generate"`);
|
|
expect(bundleScript).toContain(`"scripts/generate-client-bundle.ts", "--reset"`);
|
|
expect(bundleScript).toContain(`process.env.PI_BUNDLED="true"`);
|
|
});
|
|
|
|
it("uses embedded stats assets for prebuilt CLI distributions", async () => {
|
|
const statsServer = await Bun.file(statsServerPath).text();
|
|
expect(statsServer).toContain("process.env.PI_BUNDLED");
|
|
expect(statsServer).toContain("USE_EMBEDDED_CLIENT");
|
|
expect(statsServer).toContain("Embedded stats client bundle missing");
|
|
});
|
|
|
|
it("probes dashboard static assets in the install smoke test path", async () => {
|
|
const cliSource = await Bun.file(cliPath).text();
|
|
expect(cliSource).toContain("startServer(0)");
|
|
expect(cliSource).toContain("127.0.0.1");
|
|
expect(cliSource).toContain("dashboard HTML was not served");
|
|
});
|
|
});
|