* feat(cli): manage projects Expose the existing project lifecycle through one CLI command group so projects can be managed without opening the app. * fix(cli): preserve remote project paths Project paths belong to the daemon when a target is explicit. Require that path instead of resolving the CLI machine's cwd, and keep local convenience resolution for the default connection. * docs(cli): document project management * docs(cli): remove repeated project reference
76 lines
2.0 KiB
TypeScript
76 lines
2.0 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 { createCliParseArgv } from "./run";
|
|
|
|
describe("runCli", () => {
|
|
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 });
|
|
}
|
|
});
|
|
});
|