mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-31 05:32:58 +00:00
* 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
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import type { Command } from "commander";
|
|
import type { CommandError, CommandOptions, SingleResult } from "../../output/index.js";
|
|
import { buildDaemonConnectionCommandError, connectToDaemon } from "../../utils/client.js";
|
|
|
|
interface ProjectDeleteResult {
|
|
projectId: string;
|
|
removedWorkspaceIds: string[];
|
|
}
|
|
|
|
const projectDeleteSchema = {
|
|
idField: "projectId" as const,
|
|
columns: [
|
|
{ header: "PROJECT ID", field: "projectId" as const, width: 20 },
|
|
{
|
|
header: "REMOVED WORKSPACES",
|
|
field: (result: ProjectDeleteResult) => result.removedWorkspaceIds.length,
|
|
width: 18,
|
|
},
|
|
],
|
|
};
|
|
|
|
export async function runDeleteCommand(
|
|
projectId: string,
|
|
options: CommandOptions,
|
|
_command: Command,
|
|
): Promise<SingleResult<ProjectDeleteResult>> {
|
|
const client = await connectToDaemon({ host: options.host }).catch((error: unknown) => {
|
|
throw buildDaemonConnectionCommandError({ host: options.host, error });
|
|
});
|
|
|
|
try {
|
|
const result = await client.removeProject(projectId);
|
|
return {
|
|
type: "single",
|
|
data: { projectId, removedWorkspaceIds: result.removedWorkspaceIds },
|
|
schema: projectDeleteSchema,
|
|
};
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
throw { code: "PROJECT_DELETE_FAILED", message } satisfies CommandError;
|
|
} finally {
|
|
await client.close().catch(() => undefined);
|
|
}
|
|
}
|