mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 07:31:44 +00:00
refactor: centralize plugin install config policy
This commit is contained in:
@@ -129,6 +129,12 @@ describe("registerPreActionHooks", () => {
|
||||
program.command("onboard").action(() => {});
|
||||
const channels = program.command("channels");
|
||||
channels.command("add").action(() => {});
|
||||
program
|
||||
.command("plugins")
|
||||
.command("install")
|
||||
.argument("<spec>")
|
||||
.option("--marketplace <marketplace>")
|
||||
.action(() => {});
|
||||
program
|
||||
.command("update")
|
||||
.command("status")
|
||||
@@ -229,6 +235,61 @@ describe("registerPreActionHooks", () => {
|
||||
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("only allows invalid config for explicit Matrix reinstall requests", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["plugins", "install", "@openclaw/matrix"],
|
||||
processArgv: ["node", "openclaw", "plugins", "install", "@openclaw/matrix"],
|
||||
});
|
||||
|
||||
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
|
||||
runtime: runtimeMock,
|
||||
commandPath: ["plugins", "install"],
|
||||
allowInvalid: true,
|
||||
});
|
||||
|
||||
vi.clearAllMocks();
|
||||
await runPreAction({
|
||||
parseArgv: ["plugins", "install", "alpha"],
|
||||
processArgv: ["node", "openclaw", "plugins", "install", "alpha"],
|
||||
});
|
||||
|
||||
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
|
||||
runtime: runtimeMock,
|
||||
commandPath: ["plugins", "install"],
|
||||
});
|
||||
|
||||
vi.clearAllMocks();
|
||||
await runPreAction({
|
||||
parseArgv: ["plugins", "install", "./extensions/matrix"],
|
||||
processArgv: ["node", "openclaw", "plugins", "install", "./extensions/matrix"],
|
||||
});
|
||||
|
||||
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
|
||||
runtime: runtimeMock,
|
||||
commandPath: ["plugins", "install"],
|
||||
allowInvalid: true,
|
||||
});
|
||||
|
||||
vi.clearAllMocks();
|
||||
await runPreAction({
|
||||
parseArgv: ["plugins", "install", "@openclaw/matrix", "--marketplace", "local/repo"],
|
||||
processArgv: [
|
||||
"node",
|
||||
"openclaw",
|
||||
"plugins",
|
||||
"install",
|
||||
"@openclaw/matrix",
|
||||
"--marketplace",
|
||||
"local/repo",
|
||||
],
|
||||
});
|
||||
|
||||
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
|
||||
runtime: runtimeMock,
|
||||
commandPath: ["plugins", "install"],
|
||||
});
|
||||
});
|
||||
|
||||
it("skips help/version preaction and respects banner opt-out", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["status"],
|
||||
|
||||
Reference in New Issue
Block a user