mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-06 09:24:20 +02:00
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
renderBundledRootHelpText,
|
|
writeCliStartupMetadata,
|
|
} from "../../scripts/write-cli-startup-metadata.ts";
|
|
import { createScriptTestHarness } from "./test-helpers.js";
|
|
|
|
describe("write-cli-startup-metadata", () => {
|
|
const { createTempDir } = createScriptTestHarness();
|
|
|
|
it("captures bundled root help text from the CLI program", async () => {
|
|
const rootHelpText = await renderBundledRootHelpText();
|
|
|
|
expect(rootHelpText).toContain("Usage:");
|
|
expect(rootHelpText).toContain("openclaw");
|
|
});
|
|
|
|
it("writes startup metadata with populated root help text", async () => {
|
|
const tempRoot = createTempDir("openclaw-startup-metadata-");
|
|
const distDir = path.join(tempRoot, "dist");
|
|
const extensionsDir = path.join(tempRoot, "extensions");
|
|
const outputPath = path.join(distDir, "cli-startup-metadata.json");
|
|
|
|
mkdirSync(distDir, { recursive: true });
|
|
mkdirSync(path.join(extensionsDir, "matrix"), { recursive: true });
|
|
writeFileSync(
|
|
path.join(extensionsDir, "matrix", "package.json"),
|
|
JSON.stringify({
|
|
openclaw: {
|
|
channel: {
|
|
id: "matrix",
|
|
order: 120,
|
|
label: "Matrix",
|
|
},
|
|
},
|
|
}),
|
|
"utf8",
|
|
);
|
|
|
|
await writeCliStartupMetadata({ distDir, outputPath, extensionsDir });
|
|
|
|
const written = JSON.parse(readFileSync(outputPath, "utf8")) as {
|
|
channelOptions: string[];
|
|
rootHelpText: string;
|
|
};
|
|
expect(written.channelOptions).toContain("matrix");
|
|
expect(written.rootHelpText).toContain("Usage:");
|
|
expect(written.rootHelpText).toContain("openclaw");
|
|
});
|
|
});
|