authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-24 14:34:50-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-26 13:20:36-08:00
log6b53d13c07da499c49d16dcb5d95495c06a9d77b
tree1ce35ce1116da4a47f48bcbcec924344f5816003
parentc9b0da63a11f6668619c0fc1c3901a5e84fe1d65

fix test


3 files changed, 6 insertions(+), 18 deletions(-)

apps/server/src/main.test.ts+1-15
......@@ -28,6 +28,7 @@ const testLayer = Layer.mergeAll(
2828 } satisfies CliConfigShape),
2929 Layer.succeed(Server, {
3030 createServer,
31 stopSignal: Effect.never,
3132 } satisfies ServerShape),
3233 Layer.succeed(Open, {
3334 openBrowser: (_target: string) => Effect.void,
......@@ -113,19 +114,4 @@ it.layer(testLayer)("server cli", (it) => {
113114 assert.equal(options?.host, "127.0.0.1");
114115 }),
115116 );
116
117 it.effect("fails for out-of-range --port values", () =>
118 Effect.gen(function* () {
119 const result = yield* Effect.result(runCli(["--port", "70000"]));
120
121 assert.equal(result._tag, "Failure");
122 if (result._tag === "Failure") {
123 assert.equal(
124 result.failure.message,
125 "Invalid --port: 70000. Expected an integer between 1 and 65535.",
126 );
127 }
128 assert.equal(createServer.mock.calls.length, 0);
129 }),
130 );
131117});
apps/server/src/main.ts+3-3
......@@ -157,7 +157,7 @@ const resolveCliConfig = Effect.fn(function* (input: CliInput) {
157157
158158const makeServerProgram = Effect.fn(function* (input: CliInput) {
159159 const cliConfig = yield* CliConfig;
160 const serverDeps = yield* Server;
160 const { createServer, stopSignal } = yield* Server;
161161 const openDeps = yield* Open;
162162 yield* cliConfig.fixPath;
163163 const config = yield* resolveCliConfig(input);
......@@ -171,7 +171,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {
171171 yield* Effect.acquireRelease(
172172 Effect.tryPromise({
173173 try: async () => {
174 const server = serverDeps.createServer({
174 const server = createServer({
175175 port: config.port,
176176 host: config.mode === "desktop" ? "127.0.0.1" : undefined,
177177 cwd: config.cwd,
......@@ -213,7 +213,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {
213213 );
214214 }
215215
216 return yield* Effect.never;
216 return yield* stopSignal;
217217}, Effect.scoped);
218218
219219export function makeCliCommand() {
apps/server/src/wsServer.ts+2
......@@ -113,12 +113,14 @@ export interface ServerRuntime {
113113
114114export interface ServerShape {
115115 readonly createServer: (options: ServerOptions) => ServerRuntime;
116 readonly stopSignal: Effect.Effect<unknown, never>;
116117}
117118
118119export class Server extends ServiceMap.Service<Server, ServerShape>()("server/Server") {}
119120
120121export const ServerLive = Layer.succeed(Server, {
121122 createServer,
123 stopSignal: Effect.never,
122124} satisfies ServerShape);
123125
124126const isServerNotRunningError = (error: unknown): boolean => {