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