diff --git a/cli/src/__tests__/plugin-init.test.ts b/cli/src/__tests__/plugin-init.test.ts index de6e8fabdd6..66a9beddebb 100644 --- a/cli/src/__tests__/plugin-init.test.ts +++ b/cli/src/__tests__/plugin-init.test.ts @@ -8,9 +8,15 @@ const mocks = vi.hoisted(() => ({ scaffoldPluginProject: vi.fn((options: { outputDir: string }) => options.outputDir), })); -vi.mock("@paperclipai/create-paperclip-plugin", () => ({ - scaffoldPluginProject: mocks.scaffoldPluginProject, -})); +vi.mock("@paperclipai/create-paperclip-plugin", async () => { + const actual = await vi.importActual( + "@paperclipai/create-paperclip-plugin", + ); + return { + ...actual, + scaffoldPluginProject: mocks.scaffoldPluginProject, + }; +}); import { buildPluginInstallRequest, diff --git a/cli/src/commands/client/plugin.ts b/cli/src/commands/client/plugin.ts index 60a8e3ba145..db9f9c5dd83 100644 --- a/cli/src/commands/client/plugin.ts +++ b/cli/src/commands/client/plugin.ts @@ -3,6 +3,7 @@ import { existsSync } from "node:fs"; import { Command, Option } from "commander"; import { scaffoldPluginProject, + shellQuote, type ScaffoldPluginOptions, } from "@paperclipai/create-paperclip-plugin"; import pc from "picocolors"; @@ -169,11 +170,6 @@ function packageToDirName(pluginName: string): string { return pluginName.replace(/^@[^/]+\//, ""); } -function shellQuote(value: string): string { - if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) return value; - return `'${value.replace(/'/g, "'\"'\"'")}'`; -} - export function buildPluginInitScaffoldOptions( packageName: string, opts: PluginInitOptions, diff --git a/packages/plugins/create-paperclip-plugin/src/index.ts b/packages/plugins/create-paperclip-plugin/src/index.ts index a3b59e7333e..099cb57eb71 100644 --- a/packages/plugins/create-paperclip-plugin/src/index.ts +++ b/packages/plugins/create-paperclip-plugin/src/index.ts @@ -62,7 +62,7 @@ function toPosixPath(value: string): string { return value.split(path.sep).join("/"); } -function shellQuote(value: string): string { +export function shellQuote(value: string): string { if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) return value; return `'${value.replace(/'/g, "'\"'\"'")}'`; }