Skip to content

Commit e4eba21

Browse files
committed
feat(server): add t3 project list command
1 parent 65ba252 commit e4eba21

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎apps/server/src/cli/project.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import * as FileSystem from "effect/FileSystem";
2323
import * as Layer from "effect/Layer";
2424
import * as References from "effect/References";
2525
import * as Stream from "effect/Stream";
26+
import * as TestConsole from "effect/testing/TestConsole";
2627
import { Command } from "effect/cli";
2728

2829
import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
@@ -147,12 +148,18 @@ it.effect("adds, renames, and removes projects through the V2 project CLI domain
147148
assert.equal(added?.title, "Alpha");
148149
assert.equal(added?.workspaceRoot, workspaceRoot);
149150

151+
yield* runCli(["project", "list", "--base-dir", baseDir]);
152+
assert.equal((yield* TestConsole.logLines).at(-1), `${added?.id}\tAlpha\t${workspaceRoot}`);
153+
150154
yield* runCli(["project", "rename", workspaceRoot, "Beta", "--base-dir", baseDir]);
151155
assert.equal((yield* readProjects(baseDir)).projects[0]?.title, "Beta");
152156

153157
yield* runCli(["project", "remove", added?.id ?? "", "--base-dir", baseDir]);
154158
assert.deepEqual((yield* readProjects(baseDir)).projects, []);
155-
}).pipe(Effect.provide(NodeServices.layer)),
159+
160+
yield* runCli(["project", "list", "--base-dir", baseDir]);
161+
assert.equal((yield* TestConsole.logLines).at(-1), "No projects.");
162+
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, TestConsole.layer))),
156163
);
157164

158165
const makeProjectLookupFixture = Effect.fn("ProjectCliTest.makeProjectLookupFixture")(function* () {

‎apps/server/src/cli/project.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,28 @@ const projectRenameCommand = Command.make("rename", {
579579
),
580580
);
581581

582+
const projectListCommand = Command.make("list", projectLocationFlags).pipe(
583+
Command.withDescription("List projects."),
584+
Command.withHandler((flags) =>
585+
runProjectMutation(flags, ({ snapshot }) => {
586+
const active = snapshot.projects.filter((project) => project.deletedAt === null);
587+
return Effect.succeed(
588+
active.length === 0
589+
? "No projects."
590+
: active
591+
.map((project) => `${project.id}\t${project.title}\t${project.workspaceRoot}`)
592+
.join("\n"),
593+
);
594+
}),
595+
),
596+
);
597+
582598
export const projectCommand = Command.make("project").pipe(
583599
Command.withDescription("Manage projects."),
584-
Command.withSubcommands([projectAddCommand, projectRemoveCommand, projectRenameCommand]),
600+
Command.withSubcommands([
601+
projectAddCommand,
602+
projectListCommand,
603+
projectRemoveCommand,
604+
projectRenameCommand,
605+
]),
585606
);

0 commit comments

Comments
 (0)