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(...@@ -28,6 +28,7 @@ const testLayer = Layer.mergeAll(
28 } satisfies CliConfigShape),28 } satisfies CliConfigShape),
29 Layer.succeed(Server, {29 Layer.succeed(Server, {
30 createServer,30 createServer,
31 stopSignal: Effect.never,
31 } satisfies ServerShape),32 } satisfies ServerShape),
32 Layer.succeed(Open, {33 Layer.succeed(Open, {
33 openBrowser: (_target: string) => Effect.void,34 openBrowser: (_target: string) => Effect.void,
...@@ -113,19 +114,4 @@ it.layer(testLayer)("server cli", (it) => {...@@ -113,19 +114,4 @@ it.layer(testLayer)("server cli", (it) => {
113 assert.equal(options?.host, "127.0.0.1");114 assert.equal(options?.host, "127.0.0.1");
114 }),115 }),
115 );116 );
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 );
131});117});
apps/server/src/main.ts+3-3
...@@ -157,7 +157,7 @@ const resolveCliConfig = Effect.fn(function* (input: CliInput) {...@@ -157,7 +157,7 @@ const resolveCliConfig = Effect.fn(function* (input: CliInput) {
157157
158const makeServerProgram = Effect.fn(function* (input: CliInput) {158const makeServerProgram = Effect.fn(function* (input: CliInput) {
159 const cliConfig = yield* CliConfig;159 const cliConfig = yield* CliConfig;
160 const serverDeps = yield* Server;160 const { createServer, stopSignal } = yield* Server;
161 const openDeps = yield* Open;161 const openDeps = yield* Open;
162 yield* cliConfig.fixPath;162 yield* cliConfig.fixPath;
163 const config = yield* resolveCliConfig(input);163 const config = yield* resolveCliConfig(input);
...@@ -171,7 +171,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {...@@ -171,7 +171,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {
171 yield* Effect.acquireRelease(171 yield* Effect.acquireRelease(
172 Effect.tryPromise({172 Effect.tryPromise({
173 try: async () => {173 try: async () => {
174 const server = serverDeps.createServer({174 const server = createServer({
175 port: config.port,175 port: config.port,
176 host: config.mode === "desktop" ? "127.0.0.1" : undefined,176 host: config.mode === "desktop" ? "127.0.0.1" : undefined,
177 cwd: config.cwd,177 cwd: config.cwd,
...@@ -213,7 +213,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {...@@ -213,7 +213,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {
213 );213 );
214 }214 }
215215
216 return yield* Effect.never;216 return yield* stopSignal;
217}, Effect.scoped);217}, Effect.scoped);
218218
219export function makeCliCommand() {219export function makeCliCommand() {
apps/server/src/wsServer.ts+2
...@@ -113,12 +113,14 @@ export interface ServerRuntime {...@@ -113,12 +113,14 @@ export interface ServerRuntime {
113113
114export interface ServerShape {114export interface ServerShape {
115 readonly createServer: (options: ServerOptions) => ServerRuntime;115 readonly createServer: (options: ServerOptions) => ServerRuntime;
116 readonly stopSignal: Effect.Effect<unknown, never>;
116}117}
117118
118export class Server extends ServiceMap.Service<Server, ServerShape>()("server/Server") {}119export class Server extends ServiceMap.Service<Server, ServerShape>()("server/Server") {}
119120
120export const ServerLive = Layer.succeed(Server, {121export const ServerLive = Layer.succeed(Server, {
121 createServer,122 createServer,
123 stopSignal: Effect.never,
122} satisfies ServerShape);124} satisfies ServerShape);
123125
124const isServerNotRunningError = (error: unknown): boolean => {126const isServerNotRunningError = (error: unknown): boolean => {