mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-24 10:12:44 +00:00
* feat(plugins): unify source installation and simplify plugin settings * feat(plugins): install npm sources and review CLI updates Treat install selectors as one-time choices. Keep source identity separate from the installed revision, and resolve ordinary updates from the current upstream default. npm only acquires directories; plugin loading remains independent of npm. * fix(plugins): preserve CLI diagnostics and exercise reviewed updates Move new source capability coverage to real browser journeys. Update the requirements regression to exercise preview and apply, and preserve the existing duplicate-selector diagnostic across positional option scopes. * test(plugins): remove unused pending helper * test(plugins): pack registry fixtures with the Windows command runner * test(plugins): assert failed client contribution setup * docs(plugins): consolidate guides and document npm publishing * docs(plugins): introduce publishing choices before npm instructions * test(plugins): own browser journey cleanup in a fixture * feat(plugins): prepare scaffolded packages for publishing
96 lines
2.8 KiB
TypeScript
96 lines
2.8 KiB
TypeScript
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { createCli } from "./cli";
|
|
import { createCliParseArgv } from "./run";
|
|
|
|
describe("runCli", () => {
|
|
it("lets plugin update own --version while preserving global output options", async () => {
|
|
const cli = createCli()
|
|
.exitOverride()
|
|
.configureOutput({ writeOut: () => {} });
|
|
const update = cli.commands
|
|
.find((command) => command.name() === "plugin")!
|
|
.commands.find((command) => command.name() === "update")!;
|
|
let received: Record<string, unknown> | undefined;
|
|
update.action((_id, options) => {
|
|
received = options;
|
|
});
|
|
await cli.parseAsync(
|
|
["plugin", "update", "example", "--version", "1.2.0", "--format", "json", "--no-color"],
|
|
{ from: "user" },
|
|
);
|
|
expect(received).toMatchObject({ version: "1.2.0" });
|
|
expect(update.optsWithGlobals()).toMatchObject({ format: "json", color: false });
|
|
});
|
|
|
|
it("defaults an empty CLI invocation to onboard", () => {
|
|
expect(
|
|
createCliParseArgv({
|
|
argv: [],
|
|
cwd: process.cwd(),
|
|
nodeArgv: ["node", "paseo"],
|
|
}),
|
|
).toEqual(["node", "paseo", "onboard"]);
|
|
});
|
|
|
|
it("routes explicit root relay flags to onboard", () => {
|
|
expect(
|
|
createCliParseArgv({
|
|
argv: ["--relay"],
|
|
cwd: process.cwd(),
|
|
nodeArgv: ["node", "paseo"],
|
|
}),
|
|
).toEqual(["node", "paseo", "onboard", "--relay"]);
|
|
expect(
|
|
createCliParseArgv({
|
|
argv: ["--no-relay"],
|
|
cwd: process.cwd(),
|
|
nodeArgv: ["node", "paseo"],
|
|
}),
|
|
).toEqual(["node", "paseo", "onboard", "--no-relay"]);
|
|
});
|
|
|
|
it("preserves known CLI command argv", () => {
|
|
expect(
|
|
createCliParseArgv({
|
|
argv: ["daemon", "set-password"],
|
|
cwd: process.cwd(),
|
|
nodeArgv: ["node", "paseo"],
|
|
}),
|
|
).toEqual(["node", "paseo", "daemon", "set-password"]);
|
|
});
|
|
|
|
it("preserves the hooks command argv", () => {
|
|
expect(
|
|
createCliParseArgv({
|
|
argv: ["hooks", "claude", "UserPromptSubmit"],
|
|
cwd: process.cwd(),
|
|
nodeArgv: ["node", "paseo"],
|
|
}),
|
|
).toEqual(["node", "paseo", "hooks", "claude", "UserPromptSubmit"]);
|
|
});
|
|
|
|
it("classifies existing unknown directories as open-project invocations", () => {
|
|
const root = mkdtempSync(path.join(tmpdir(), "paseo-cli-run-"));
|
|
const project = path.join(root, "repository");
|
|
mkdirSync(project);
|
|
|
|
try {
|
|
expect(
|
|
createCliParseArgv({
|
|
argv: ["repository"],
|
|
cwd: root,
|
|
nodeArgv: ["node", "paseo"],
|
|
}),
|
|
).toEqual({
|
|
kind: "open-project",
|
|
resolvedPath: project,
|
|
});
|
|
} finally {
|
|
rmSync(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|