This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-02-26 13:20:36 -08:00
1 parent c9b0da63a1
commit 6b53d13c07
3 files changed
+6 -18

No files matched your search

+1 -15
View File
@@ -28,6 +28,7 @@ const testLayer = Layer.mergeAll(
} satisfies CliConfigShape),
Layer.succeed(Server, {
createServer,
stopSignal: Effect.never,
} satisfies ServerShape),
Layer.succeed(Open, {
openBrowser: (_target: string) => Effect.void,
@@ -113,19 +114,4 @@ it.layer(testLayer)("server cli", (it) => {
assert.equal(options?.host, "127.0.0.1");
}),
);
it.effect("fails for out-of-range --port values", () =>
Effect.gen(function* () {
const result = yield* Effect.result(runCli(["--port", "70000"]));
assert.equal(result._tag, "Failure");
if (result._tag === "Failure") {
assert.equal(
result.failure.message,
"Invalid --port: 70000. Expected an integer between 1 and 65535.",
);
}
assert.equal(createServer.mock.calls.length, 0);
}),
);
});
+3 -3
View File
@@ -157,7 +157,7 @@ const resolveCliConfig = Effect.fn(function* (input: CliInput) {
const makeServerProgram = Effect.fn(function* (input: CliInput) {
const cliConfig = yield* CliConfig;
const serverDeps = yield* Server;
const { createServer, stopSignal } = yield* Server;
const openDeps = yield* Open;
yield* cliConfig.fixPath;
const config = yield* resolveCliConfig(input);
@@ -171,7 +171,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {
yield* Effect.acquireRelease(
Effect.tryPromise({
try: async () => {
const server = serverDeps.createServer({
const server = createServer({
port: config.port,
host: config.mode === "desktop" ? "127.0.0.1" : undefined,
cwd: config.cwd,
@@ -213,7 +213,7 @@ const makeServerProgram = Effect.fn(function* (input: CliInput) {
);
}
return yield* Effect.never;
return yield* stopSignal;
}, Effect.scoped);
export function makeCliCommand() {
+2
View File
@@ -113,12 +113,14 @@ export interface ServerRuntime {
export interface ServerShape {
readonly createServer: (options: ServerOptions) => ServerRuntime;
readonly stopSignal: Effect.Effect<unknown, never>;
}
export class Server extends ServiceMap.Service<Server, ServerShape>()("server/Server") {}
export const ServerLive = Layer.succeed(Server, {
createServer,
stopSignal: Effect.never,
} satisfies ServerShape);
const isServerNotRunningError = (error: unknown): boolean => {