localgate 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -372,7 +372,7 @@ switch back from `internet` when you are done. There is no TLS - it is plain htt
372
372
  ## Development
373
373
 
374
374
  ```bash
375
- pnpm run verify # type-check + lint + tests
375
+ pnpm run check # lint + typecheck + tests
376
376
  pnpm test # vitest
377
377
  ```
378
378
 
@@ -100,15 +100,21 @@ export class LocalgateProxyClient
100
100
  return ((await response.json()) as { route: LocalgateRoute | null }).route;
101
101
  }
102
102
 
103
- // Two levels of spawn on Windows, deliberately: `cmd` exits immediately, so the proxy's recorded
104
- // parent is already gone and the tree kill VSCode performs when a terminal closes cannot reach it.
105
- // Otherwise closing one project's terminal would take the routing of every other project with it.
103
+ // Two levels of spawn on Windows, deliberately: the intermediate exits immediately, so the proxy's
104
+ // recorded parent is already gone and the tree kill VSCode performs when a terminal closes cannot
105
+ // reach it. Otherwise closing one project's terminal would take the routing of every other project
106
+ // with it. The intermediate is node, not `cmd /c start /b`: a detached child gets DETACHED_PROCESS,
107
+ // so cmd had no console and Windows allocated a new one for the proxy - a visible window when
108
+ // Windows Terminal is the default terminal. A detached child of a detached node has no console.
109
+ private static readonly windowsLauncherConst = "require('node:child_process').spawn(process.execPath, "
110
+ + "process.argv.slice(1), { detached: true, stdio: 'ignore', windowsHide: true }).unref()";
111
+
106
112
  private static spawnDetached(): void
107
113
  {
108
114
  const entry = join(fileURLToPath(new URL("../../", import.meta.url)), "bin", "localgate.mjs");
109
115
 
110
116
  const child = process.platform == "win32"
111
- ? spawn("cmd", ["/c", "start", "\"\"", "/b", process.execPath, entry, "__proxy"],
117
+ ? spawn(process.execPath, ["-e", LocalgateProxyClient.windowsLauncherConst, entry, "__proxy"],
112
118
  { detached: true, stdio: "ignore", windowsHide: true })
113
119
  : spawn(process.execPath, [entry, "__proxy"], { detached: true, stdio: "ignore" });
114
120
 
@@ -37,6 +37,6 @@ export class LocalgatePortProbe
37
37
  static async listeningRoutes(routes: Pick<LocalgateRoute, "id" | "port">[]): Promise<Map<string, boolean>>
38
38
  {
39
39
  const answers = await Promise.all(routes.map(route => LocalgatePortProbe.listening(route.port)));
40
- return new Map(routes.map((route, index) => [route.id, answers[index]!]));
40
+ return new Map(routes.map((route, index) => [route.id, answers[index]]));
41
41
  }
42
42
  }
@@ -101,7 +101,7 @@ export class LocalgateProxy
101
101
  {
102
102
  const reachedFrom: LocalgateReach = loopback ? "loopback" : "lan";
103
103
  const server = createServer((request, response) => void this.handleRequest(request, response, loopback, reachedFrom));
104
- server.on("upgrade", (request, socket, head) => this.handleUpgrade(request, socket as Duplex, head, reachedFrom));
104
+ server.on("upgrade", (request, socket, head) => this.handleUpgrade(request, socket, head, reachedFrom));
105
105
 
106
106
  return new Promise<void>((resolve, reject) =>
107
107
  {
@@ -152,7 +152,7 @@ export class LocalgateProxy
152
152
  + "service actually listens on.\n");
153
153
 
154
154
  const headers = { ...request.headers };
155
- LocalgateHeaderRewrite.apply(request.url ?? "/", headers, request.headers.host ?? "", route.names[0]!);
155
+ LocalgateHeaderRewrite.apply(request.url ?? "/", headers, request.headers.host ?? "", route.names[0]);
156
156
 
157
157
  // Only a request that may be sent twice takes a kept-alive socket: a body is streamed through once, and
158
158
  // a method that changes state must not run again because the first attempt might have reached the server.
@@ -250,7 +250,7 @@ export class LocalgateProxy
250
250
  }
251
251
 
252
252
  const headers = { ...request.headers };
253
- LocalgateHeaderRewrite.apply(request.url ?? "/", headers, request.headers.host ?? "", route.names[0]!);
253
+ LocalgateHeaderRewrite.apply(request.url ?? "/", headers, request.headers.host ?? "", route.names[0]);
254
254
 
255
255
  const upstream = httpRequest({
256
256
  host: "127.0.0.1",
@@ -321,7 +321,7 @@ export class LocalgateProxy
321
321
 
322
322
  // The port this request arrived on, not the configured one: the two differ when the proxy was asked
323
323
  // for an ephemeral port, and a hint pointing at a port nothing listens on is worse than no hint.
324
- lines.push("", `Every route, with its addresses: ${LocalgateStartPage.localUrl(this.boundPorts()[0]!)}`, "");
324
+ lines.push("", `Every route, with its addresses: ${LocalgateStartPage.localUrl(this.boundPorts()[0])}`, "");
325
325
  return lines.join("\n");
326
326
  }
327
327
 
@@ -75,7 +75,7 @@ export class LocalgateProxyHost
75
75
  {
76
76
  if (route.controlUrl) return LocalgateProxyHost.request(route, "stop");
77
77
 
78
- const name = LocalgateNames.shortName(route.names[0]!);
78
+ const name = LocalgateNames.shortName(route.names[0]);
79
79
  const command = LocalgateAliasStore.stopCommands().get(name);
80
80
  if (!command) throw new Error(`${name} is an alias with no stop command in ${LocalgateAliasStore.filePath()}`);
81
81
 
@@ -327,8 +327,8 @@ export class LocalgateStartPage
327
327
  "<span class=\"title\">",
328
328
  asking
329
329
  ? `<span class="name">${LocalgateStartPage.escape(name)}</span>`
330
- : `<a class="name" href="${LocalgateStartPage.escape(primary!.url)}">${LocalgateStartPage.escape(name)}</a>`,
331
- `<span class="primary">${LocalgateStartPage.escape(primary!.hostname)}</span>`,
330
+ : `<a class="name" href="${LocalgateStartPage.escape(primary.url)}">${LocalgateStartPage.escape(name)}</a>`,
331
+ `<span class="primary">${LocalgateStartPage.escape(primary.hostname)}</span>`,
332
332
  "</span>",
333
333
  `<span class="state ${status.shade}"><span class="dot"></span>`
334
334
  + `${LocalgateStartPage.escape(status.word)}</span>`,
@@ -385,8 +385,8 @@ export class LocalgateStartPage
385
385
  {
386
386
  const words = name.split("-").filter(word => word.length > 0);
387
387
  if (words.length == 0) return "?";
388
- if (words.length == 1) return words[0]!.slice(0, 2).toUpperCase();
389
- return `${words[0]![0]!}${words[words.length - 1]!.slice(0, 2)}`.toUpperCase();
388
+ if (words.length == 1) return words[0].slice(0, 2).toUpperCase();
389
+ return `${words[0][0]}${words[words.length - 1].slice(0, 2)}`.toUpperCase();
390
390
  }
391
391
 
392
392
  // A colour the name always gets back, so a card keeps its look across a refresh and a person finds an
@@ -445,7 +445,7 @@ export class LocalgateStartPage
445
445
 
446
446
  private static appName(route: LocalgateRoute): string
447
447
  {
448
- return LocalgateNames.shortName(route.names[0]!);
448
+ return LocalgateNames.shortName(route.names[0]);
449
449
  }
450
450
 
451
451
  private subtitle(count: number, loopback: boolean): string
@@ -224,7 +224,7 @@ export class LocalgateProcessTree
224
224
  catch (error)
225
225
  {
226
226
  throw new Error(`${file} ${JSON.stringify(args)} [shell=false timeout=${timeout}ms]: `
227
- + LocalgateProcessTree.describeFailure(error));
227
+ + LocalgateProcessTree.describeFailure(error), { cause: error });
228
228
  }
229
229
  }
230
230
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "localgate",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Stable names for local dev servers: one port 80 multiplexed by Host, plus an API that can restart a dev server owned by your editor.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -36,18 +36,18 @@
36
36
  "scripts": {
37
37
  "test": "vitest run --passWithNoTests",
38
38
  "test:watch": "vitest",
39
- "lint": "eslint .",
40
- "type-check": "tsc --noEmit",
41
- "verify": "pnpm run type-check && pnpm run lint && pnpm run test"
39
+ "lint": "oxlint --type-aware",
40
+ "typecheck": "tsc --noEmit",
41
+ "check": "pnpm run lint && pnpm run typecheck && pnpm test"
42
42
  },
43
43
  "dependencies": {
44
44
  "tsx": "4.21.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "25.5.0",
48
- "eslint": "9.22.0",
48
+ "oxlint": "1.95.0",
49
+ "oxlint-tsgolint": "7.0.2008",
49
50
  "typescript": "5.8.3",
50
- "typescript-eslint": "8.27.0",
51
- "vitest": "4.1.9"
51
+ "vitest": "5.1.1"
52
52
  }
53
53
  }