@hamedb89/localghost 0.5.0 → 0.6.2
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 +5 -1
- package/dist/cli.js +427 -321
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +147 -107
- package/dist/index.js +1511 -1407
- package/dist/index.js.map +1 -1
- package/dist/{tunnel-BA52DD9e.d.ts → tunnel-DHYPpsX2.d.ts} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +35 -1
- package/dist/vite.js.map +1 -1
- package/docs/ghost-tunnel.md +9 -3
- package/docs/localghost.1.md +10 -0
- package/package.json +5 -2
|
@@ -175,4 +175,4 @@ declare function assertSecureGhostTunnelRequest(input: {
|
|
|
175
175
|
authenticated?: boolean;
|
|
176
176
|
}): GhostTunnelRoute;
|
|
177
177
|
|
|
178
|
-
export { findLocalMdnsHosts as A, getConfigFileCandidates as B, type ConfigPattern as C, type DevHostEntry as D, getDevHostsPath as E, getGhostTunnelDefaultDisplayUrl as F, type GhostTunnelOptions as G, getGhostTunnelDisplayUrl as H, getGhostTunnelDisplayUrls as I, getGhostTunnelEntryHost as J, getGhostTunnelPreviewUrl as K, LOCALGHOST_CONFIG_FILE as L, getGhostTunnelWildcardHost as M, getProjectName as N, parseDevHosts as O, parseGhostTunnelHost as P, readDevHosts as Q, type ReadDevHostsOptions as R, resolveDevHostsPath as S, resolveGhostTunnelConfig as T, sanitizeProjectName as U, type
|
|
178
|
+
export { findLocalMdnsHosts as A, getConfigFileCandidates as B, type ConfigPattern as C, type DevHostEntry as D, getDevHostsPath as E, getGhostTunnelDefaultDisplayUrl as F, type GhostTunnelOptions as G, getGhostTunnelDisplayUrl as H, getGhostTunnelDisplayUrls as I, getGhostTunnelEntryHost as J, getGhostTunnelPreviewUrl as K, LOCALGHOST_CONFIG_FILE as L, getGhostTunnelWildcardHost as M, getProjectName as N, parseDevHosts as O, parseGhostTunnelHost as P, readDevHosts as Q, type ReadDevHostsOptions as R, resolveDevHostsPath as S, resolveGhostTunnelConfig as T, sanitizeProjectName as U, type ConstructGhostTunnelUrlInput as a, type GhostTunnelTransportOptions as b, type GhostTunnelTransportConfig as c, type GhostTunnelConfig as d, type GhostTunnelRoute as e, type GhostTunnelAdapterOptions as f, type GhostTunnelAdapterProvider as g, type GhostTunnelAdapterStrategy as h, type GhostTunnelAdapterTransport as i, type GhostTunnelDisplayDefaults as j, type GhostTunnelDomainOptions as k, type GhostTunnelMode as l, type GhostTunnelNamespaceConfig as m, type GhostTunnelNamespaceOptions as n, type GhostTunnelNamespaceTag as o, type GhostTunnelNamespaceValues as p, type GhostTunnelPreviewOptions as q, type GhostTunnelTransportKind as r, type GhostTunnelTunnelStoreEnv as s, type GhostTunnelTunnelStoreOptions as t, type GhostTunnelTunnelStoreProvider as u, type ResolvedDevHostsPath as v, assertSecureGhostTunnelRequest as w, constructGhostTunnelHost as x, constructGhostTunnelURL as y, constructGhostTunnelUrl as z };
|
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -306,6 +306,9 @@ function validRegistry(value) {
|
|
|
306
306
|
function pruneRegistry(registry, now, isRunning) {
|
|
307
307
|
registry.leases = registry.leases.filter((lease) => lease.expiresAt > now && isRunning(lease.pid));
|
|
308
308
|
}
|
|
309
|
+
function isTestSessionKey(instanceKey) {
|
|
310
|
+
return instanceKey.startsWith("test:");
|
|
311
|
+
}
|
|
309
312
|
async function readJson(path) {
|
|
310
313
|
try {
|
|
311
314
|
return JSON.parse(await readFile(path, "utf8"));
|
|
@@ -402,6 +405,37 @@ function createLocalghostRegistry(options = {}) {
|
|
|
402
405
|
await releaseLock();
|
|
403
406
|
}
|
|
404
407
|
},
|
|
408
|
+
async pruneTestSessions() {
|
|
409
|
+
const releaseLock = await lock();
|
|
410
|
+
try {
|
|
411
|
+
const registry = await readRegistry();
|
|
412
|
+
const staleTestKeys = new Set(
|
|
413
|
+
registry.leases.filter((lease) => isTestSessionKey(lease.instanceKey) && (lease.expiresAt <= now() || !isRunning(lease.pid))).map((lease) => leaseKey(lease.projectCwd, lease.instanceKey))
|
|
414
|
+
);
|
|
415
|
+
const beforeLeases = registry.leases.length;
|
|
416
|
+
registry.leases = registry.leases.filter((lease) => !staleTestKeys.has(leaseKey(lease.projectCwd, lease.instanceKey)));
|
|
417
|
+
const activeKeys = new Set(registry.leases.map((lease) => leaseKey(lease.projectCwd, lease.instanceKey)));
|
|
418
|
+
const beforeAllocations = registry.allocations.length;
|
|
419
|
+
registry.allocations = registry.allocations.filter(
|
|
420
|
+
(allocation) => !isTestSessionKey(allocation.instanceKey) || activeKeys.has(leaseKey(allocation.projectCwd, allocation.instanceKey))
|
|
421
|
+
);
|
|
422
|
+
await writeRegistry(registry);
|
|
423
|
+
return {
|
|
424
|
+
removedLeases: beforeLeases - registry.leases.length,
|
|
425
|
+
removedAllocations: beforeAllocations - registry.allocations.length
|
|
426
|
+
};
|
|
427
|
+
} finally {
|
|
428
|
+
await releaseLock();
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
async reset() {
|
|
432
|
+
const releaseLock = await lock();
|
|
433
|
+
try {
|
|
434
|
+
await writeRegistry({ version: 1, allocations: [], leases: [] });
|
|
435
|
+
} finally {
|
|
436
|
+
await releaseLock();
|
|
437
|
+
}
|
|
438
|
+
},
|
|
405
439
|
async acquirePort(acquireOptions) {
|
|
406
440
|
const projectCwd = canonicalizeLocalghostProjectCwd(acquireOptions.projectCwd ?? cwd);
|
|
407
441
|
if (!acquireOptions.instanceKey) throw new Error("instanceKey is required");
|
|
@@ -464,7 +498,7 @@ function createLocalghostRegistry(options = {}) {
|
|
|
464
498
|
};
|
|
465
499
|
}
|
|
466
500
|
|
|
467
|
-
// src/tunnel.ts
|
|
501
|
+
// packages/ghost-tunnel/src/tunnel.ts
|
|
468
502
|
import { domainToASCII } from "url";
|
|
469
503
|
var DEFAULT_GHOST_TUNNEL_SUBDOMAIN = "ghost";
|
|
470
504
|
var DEFAULT_GHOST_TUNNEL_NAMESPACE_TAGS = ["route", "project", "owner"];
|