Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions apps/server/src/cli/up.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
/** Runs as if in a terminal, answering each question with this text. */
readonly answer?: string;
readonly prints?: string;
readonly omits?: string;
readonly json?: object;
readonly env: string;
readonly args: ReadonlyArray<string>;
readonly installs: number;
Expand Down Expand Up @@ -271,12 +273,28 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
installed: true,
status: { current: false, otherBaseDir: "/srv/t3 home" },
reportStatus: true,
json: {
service: { otherBaseDir: "/srv/t3 home" },
lan: { enabled: false, inheritedDefault: false },
},
env: "",
args: ["--json"],
installs: 0,
restarts: 0,
envAfter: "",
},
{
label: "a host override gets no --no-lan hint it would ignore",
installed: true,
reportStatus: true,
prints: "overridden · T3CODE_HOST=0.0.0.0",
omits: "t3 up --no-lan",
env: "T3CODE_HOST=0.0.0.0\n",
args: [],
installs: 0,
restarts: 0,
envAfter: "T3CODE_HOST=0.0.0.0\n",
},
{
label: "no service manager still records the choice",
installed: false,
Expand Down Expand Up @@ -371,11 +389,11 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
if (input.prints !== undefined) {
expect(lines.join("\n")).toContain(input.prints.replace("<baseDir>", baseDir));
}
if (input.reportStatus) {
expect(JSON.parse(lines.join("\n"))).toMatchObject({
service: { otherBaseDir: "/srv/t3 home" },
lan: { enabled: false, inheritedDefault: false },
});
if (input.omits !== undefined) {
expect(lines.join("\n")).not.toContain(input.omits);
}
if (input.json !== undefined) {
expect(JSON.parse(lines.join("\n"))).toMatchObject(input.json);
}
expect(exit._tag).toBe(
input.restartFails === true || input.fails === true ? "Failure" : "Success",
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/cli/up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface Setup {
/** T3 Connect revoked the link; `t3 connect` links again. */
readonly connectRevoked: boolean;
readonly lan: boolean;
/** An installed service with no T3CODE_LAN keeps the old default: on. */
/** An installed service with no T3CODE_LAN or T3CODE_HOST keeps the old default: on. */
readonly lanFromOldDefault: boolean;
readonly host: string | undefined;
}
Expand Down Expand Up @@ -86,7 +86,7 @@ const readSetup = Effect.fn("cli.up.read_setup")(function* () {
connect,
connectRevoked,
lan: Option.getOrElse(lan, () => servesThisHome),
lanFromOldDefault: Option.isNone(lan) && servesThisHome,
lanFromOldDefault: Option.isNone(lan) && servesThisHome && entries.T3CODE_HOST === undefined,
host: entries.T3CODE_HOST,
} satisfies Setup;
});
Expand Down
Loading