





















@@ -26,6 +26,10 @@ import {
2626} from "./install.js";
2727import { packToArchive } from "./test-helpers/archive-fixtures.js";
2828import { createSuiteTempRootTracker } from "./test-helpers/fs-fixtures.js";
29+import {
30+createBundleInstallFixtureFactory,
31+createDualFormatInstallFixtureFactory,
32+} from "./test-helpers/install-fixtures.js";
29333034vi.mock("../process/exec.js", () => ({
3135runCommandWithTimeout: vi.fn(),
@@ -63,6 +67,12 @@ const dynamicArchiveTemplatePathCache = new Map<string, string>();
6367let installPluginFromDirTemplateDir = "";
6468let manifestInstallTemplateDir = "";
6569const suiteTempRootTracker = createSuiteTempRootTracker("openclaw-plugin-install");
70+const setupBundleInstallFixture = createBundleInstallFixtureFactory(
71+suiteTempRootTracker.makeTempDir,
72+);
73+const setupDualFormatInstallFixture = createDualFormatInstallFixtureFactory(
74+suiteTempRootTracker.makeTempDir,
75+);
6676let previousNpmGlobalConfig: string | undefined;
6777let npmGlobalConfigPath = "";
6878let archiveDepsInstallCase: {
@@ -613,49 +623,6 @@ function expectInstalledFiles(targetDir: string, expectedFiles: readonly string[
613623});
614624}
615625616-function setupBundleInstallFixture(params: {
617-bundleFormat: "codex" | "claude" | "cursor";
618-name: string;
619-}) {
620-const caseDir = suiteTempRootTracker.makeTempDir();
621-const stateDir = path.join(caseDir, "state");
622-const pluginDir = path.join(caseDir, "plugin-src");
623-fs.mkdirSync(stateDir, { recursive: true });
624-fs.mkdirSync(path.join(pluginDir, "skills"), { recursive: true });
625-const manifestDir = path.join(
626-pluginDir,
627-params.bundleFormat === "codex"
628- ? ".codex-plugin"
629- : params.bundleFormat === "cursor"
630- ? ".cursor-plugin"
631- : ".claude-plugin",
632-);
633-fs.mkdirSync(manifestDir, { recursive: true });
634-fs.writeFileSync(
635-path.join(manifestDir, "plugin.json"),
636-JSON.stringify({
637-name: params.name,
638-description: `${params.bundleFormat} bundle fixture`,
639- ...(params.bundleFormat === "codex" ? { skills: "skills" } : {}),
640-}),
641-"utf-8",
642-);
643-if (params.bundleFormat === "cursor") {
644-fs.mkdirSync(path.join(pluginDir, ".cursor", "commands"), { recursive: true });
645-fs.writeFileSync(
646-path.join(pluginDir, ".cursor", "commands", "review.md"),
647-"---\ndescription: fixture\n---\n",
648-"utf-8",
649-);
650-}
651-fs.writeFileSync(
652-path.join(pluginDir, "skills", "SKILL.md"),
653-"---\ndescription: fixture\n---\n",
654-"utf-8",
655-);
656-return { pluginDir, extensionsDir: path.join(stateDir, "extensions") };
657-}
658-659626function setupManifestlessClaudeInstallFixture() {
660627const caseDir = suiteTempRootTracker.makeTempDir();
661628const stateDir = path.join(caseDir, "state");
@@ -671,49 +638,6 @@ function setupManifestlessClaudeInstallFixture() {
671638return { pluginDir, extensionsDir: path.join(stateDir, "extensions") };
672639}
673640674-function setupDualFormatInstallFixture(params: { bundleFormat: "codex" | "claude" }) {
675-const caseDir = suiteTempRootTracker.makeTempDir();
676-const stateDir = path.join(caseDir, "state");
677-const pluginDir = path.join(caseDir, "plugin-src");
678-fs.mkdirSync(path.join(pluginDir, "dist"), { recursive: true });
679-fs.mkdirSync(path.join(pluginDir, "skills"), { recursive: true });
680-const manifestDir = path.join(
681-pluginDir,
682-params.bundleFormat === "codex" ? ".codex-plugin" : ".claude-plugin",
683-);
684-fs.mkdirSync(manifestDir, { recursive: true });
685-fs.writeFileSync(
686-path.join(pluginDir, "package.json"),
687-JSON.stringify({
688-name: "@openclaw/native-dual",
689-version: "0.0.1",
690-openclaw: { extensions: ["./dist/index.js"] },
691-dependencies: { "left-pad": "1.3.0" },
692-}),
693-"utf-8",
694-);
695-fs.writeFileSync(
696-path.join(pluginDir, "openclaw.plugin.json"),
697-JSON.stringify({
698-id: "native-dual",
699-configSchema: { type: "object", properties: {} },
700-skills: ["skills"],
701-}),
702-"utf-8",
703-);
704-fs.writeFileSync(path.join(pluginDir, "dist", "index.js"), "export {};", "utf-8");
705-fs.writeFileSync(path.join(pluginDir, "skills", "SKILL.md"), "---\ndescription: fixture\n---\n");
706-fs.writeFileSync(
707-path.join(manifestDir, "plugin.json"),
708-JSON.stringify({
709-name: "Bundle Fallback",
710- ...(params.bundleFormat === "codex" ? { skills: "skills" } : {}),
711-}),
712-"utf-8",
713-);
714-return { pluginDir, extensionsDir: path.join(stateDir, "extensions") };
715-}
716-717641async function expectArchiveInstallReservedSegmentRejection(params: {
718642packageName: string;
719643outName: string;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。