@hamedb89/localghost 0.1.3 → 0.1.8

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/dist/index.d.ts CHANGED
@@ -1,11 +1,98 @@
1
- import { D as DevHostEntry } from './config-Cde1Bich.js';
2
- export { C as ConfigPattern, L as LOCALGHOST_CONFIG_FILE, R as ReadDevHostsOptions, a as ResolvedDevHostsPath, f as findLocalMdnsHosts, g as getConfigFileCandidates, b as getDevHostsPath, c as getProjectName, p as parseDevHosts, r as readDevHosts, d as resolveDevHostsPath, s as sanitizeProjectName } from './config-Cde1Bich.js';
1
+ import { D as DevHostEntry, R as ReadDevHostsOptions, C as ConfigPattern } from './config-Cde1Bich.js';
2
+ export { L as LOCALGHOST_CONFIG_FILE, a as ResolvedDevHostsPath, f as findLocalMdnsHosts, g as getConfigFileCandidates, b as getDevHostsPath, c as getProjectName, p as parseDevHosts, r as readDevHosts, d as resolveDevHostsPath, s as sanitizeProjectName } from './config-Cde1Bich.js';
3
+ import * as execa from 'execa';
3
4
 
5
+ declare const LOCALGHOST_ACTIVITY_VERSION = 1;
6
+ type LocalghostRunMode = "dev" | "run";
7
+ type LocalghostRunRecord = {
8
+ id: string;
9
+ mode: LocalghostRunMode;
10
+ pid: number;
11
+ cwd: string;
12
+ projectName: string;
13
+ startedAt: string;
14
+ updatedAt: string;
15
+ configPath?: string;
16
+ caddyfilePath?: string;
17
+ caddyPid?: number;
18
+ childPid?: number;
19
+ childCommand?: string[];
20
+ https?: boolean;
21
+ requestedPort?: number;
22
+ port?: number;
23
+ dynamicPort?: boolean;
24
+ entries: DevHostEntry[];
25
+ };
26
+ type LocalghostActivity = {
27
+ version: typeof LOCALGHOST_ACTIVITY_VERSION;
28
+ runs: LocalghostRunRecord[];
29
+ };
30
+ type RegisterLocalghostRunInput = Omit<LocalghostRunRecord, "id" | "pid" | "startedAt" | "updatedAt"> & {
31
+ id?: string;
32
+ pid?: number;
33
+ startedAt?: string;
34
+ };
35
+ declare function getLocalghostActivityPath(env?: NodeJS.ProcessEnv): string;
36
+ declare function isProcessRunning(pid: number): boolean;
37
+ declare function readLocalghostActivity(path?: string): LocalghostActivity;
38
+ declare function writeLocalghostActivity(activity: LocalghostActivity, path?: string): string;
39
+ declare function pruneLocalghostActivity(path?: string): {
40
+ path: string;
41
+ pruned: boolean;
42
+ runs: LocalghostRunRecord[];
43
+ };
44
+ declare function listLocalghostRuns(path?: string): LocalghostRunRecord[];
45
+ declare function registerLocalghostRun(input: RegisterLocalghostRunInput, path?: string): LocalghostRunRecord;
46
+ declare function unregisterLocalghostRun(id: string, path?: string): void;
47
+
48
+ type CaddyModeOptions = {
49
+ https?: boolean;
50
+ };
4
51
  declare function getCaddyfilePath(cwd?: string): string;
5
- declare function renderCaddyfile(entries: DevHostEntry[]): string;
6
- declare function writeCaddyfile(entries: DevHostEntry[], cwd?: string): Promise<string>;
52
+ declare function renderCaddyfile(entries: DevHostEntry[], options?: CaddyModeOptions): string;
53
+ declare function writeCaddyfile(entries: DevHostEntry[], cwd?: string, options?: CaddyModeOptions): Promise<string>;
7
54
  declare function validateCaddyfile(path: string): Promise<void>;
8
55
  declare function runCaddy(path: string): Promise<void>;
56
+ declare function startCaddy(path: string): execa.ResultPromise<{
57
+ cwd: string;
58
+ stdio: "inherit";
59
+ }>;
60
+ declare function trustCaddy(path: string): Promise<void>;
61
+
62
+ type LocalghostContextOptions = {
63
+ cwd?: string;
64
+ project?: string;
65
+ localghostConfig?: string | false;
66
+ fileName?: string;
67
+ configFiles?: string[];
68
+ configPattern?: ConfigPattern;
69
+ port?: number;
70
+ https?: boolean;
71
+ bindHost?: string | boolean;
72
+ primaryHost?: string;
73
+ dynamicPort?: boolean;
74
+ wwwAlias?: boolean;
75
+ };
76
+ type LocalghostContext = {
77
+ cwd: string;
78
+ projectName: string;
79
+ readOptions: ReadDevHostsOptions;
80
+ configPath: string;
81
+ configFileName: string;
82
+ configEntries: DevHostEntry[];
83
+ entries: DevHostEntry[];
84
+ hosts: string[];
85
+ requestedPort: number;
86
+ port: number;
87
+ dynamicPort: boolean;
88
+ bindHost: string | boolean;
89
+ primaryHost: string;
90
+ https: boolean;
91
+ wwwAlias: boolean;
92
+ projectConfigPath?: string;
93
+ };
94
+ declare function defineLocalghostConfig<T extends LocalghostContextOptions>(config: T): T;
95
+ declare function resolveLocalghostContext(options?: LocalghostContextOptions): Promise<LocalghostContext>;
9
96
 
10
97
  type DoctorResult = {
11
98
  ok: boolean;
@@ -18,6 +105,12 @@ type DoctorResult = {
18
105
  declare function checkCaddy(): Promise<DoctorResult["caddy"]>;
19
106
  declare function runDoctor(): Promise<DoctorResult>;
20
107
 
108
+ type LocalghostEnvironment = NodeJS.ProcessEnv;
109
+ declare function getProductionReason(env?: LocalghostEnvironment): "LOCALGHOST_ENV=production" | "NODE_ENV=production" | "VERCEL_ENV=production" | "NETLIFY=true and CONTEXT=production" | "CF_PAGES_BRANCH matches CF_PAGES_PRODUCTION_BRANCH" | null;
110
+ declare function isProductionLike(env?: LocalghostEnvironment): boolean;
111
+ declare function assertLocalDevelopment(command: string, env?: LocalghostEnvironment): void;
112
+ declare function getProductionEnvKeys(): readonly ["NODE_ENV", "VERCEL_ENV", "NETLIFY", "CF_PAGES_BRANCH", "LOCALGHOST_ENV"];
113
+
21
114
  type UpdateSystemHostsResult = {
22
115
  changed: boolean;
23
116
  hostsPath: string;
@@ -58,6 +151,13 @@ declare function packageRunCommand(packageManager: PackageManager, script: strin
58
151
  declare function packageAddCommand(packageManager: PackageManager, packageName?: string): string;
59
152
  declare function initLocalghost(options?: InitOptions): InitResult;
60
153
 
154
+ type FindAvailablePortOptions = {
155
+ host?: string;
156
+ maxAttempts?: number;
157
+ };
158
+ declare function isPortAvailable(port: number, host?: string): Promise<boolean>;
159
+ declare function findAvailablePort(startPort: number, options?: FindAvailablePortOptions): Promise<number>;
160
+
61
161
  type DomainRoute = {
62
162
  host: string;
63
163
  port: number;
@@ -84,15 +184,19 @@ type LocalghostState = {
84
184
  hostsTempPath?: string;
85
185
  caddyfilePath?: string;
86
186
  caddyfileRemoved?: boolean;
187
+ caddyHttps?: boolean;
188
+ caddyTrustedAt?: string;
189
+ caddyTrustPromptedAt?: string;
87
190
  entries?: DevHostEntry[];
88
191
  };
89
192
  type WriteLocalghostStateInput = Omit<LocalghostState, "version" | "updatedAt">;
90
193
  declare function getLocalghostStatePath(cwd?: string): string;
91
194
  declare function readLocalghostState(cwd?: string): LocalghostState | null;
92
195
  declare function writeLocalghostState(cwd: string, state: WriteLocalghostStateInput): string;
196
+ declare function patchLocalghostState(cwd: string, patch: Partial<WriteLocalghostStateInput>): string | null;
93
197
 
94
198
  declare const LOCALGHOST_PACKAGE_NAME = "@hamedb89/localghost";
95
- declare const LOCALGHOST_VERSION = "0.1.0";
199
+ declare const LOCALGHOST_VERSION = "0.1.8";
96
200
  declare const UPDATE_CHECK_CACHE_TTL_MS: number;
97
201
  declare const UPDATE_CHECK_NOTIFY_TTL_MS: number;
98
202
  declare const UPDATE_CHECK_TIMEOUT_MS = 900;
@@ -129,4 +233,4 @@ declare function maybeNotifyAboutUpdate(options?: {
129
233
  disabled?: boolean;
130
234
  }): Promise<void>;
131
235
 
132
- export { DevHostEntry, type DoctorResult, type DomainRoute, type DomainRouteOptions, type InitOptions, type InitResult, LOCALGHOST_PACKAGE_NAME, LOCALGHOST_STATE_FILE, LOCALGHOST_VERSION, type LocalghostState, type LocalghostStateAction, type PackageManager, type RemoveSystemHostsResult, UPDATE_CHECK_CACHE_TTL_MS, UPDATE_CHECK_NOTIFY_TTL_MS, UPDATE_CHECK_TIMEOUT_MS, type UpdateCheckCache, type UpdateCheckResult, type UpdateSystemHostsResult, type WriteLocalghostStateInput, checkCaddy, checkForUpdate, compareVersions, detectPackageManager, formatDomainRoutes, formatUpdateMessage, getCaddyfilePath, getDomainRoutes, getLocalghostStatePath, getSystemHostsPath, getUpdateCheckCachePath, initLocalghost, isNewerVersion, isUpdateCheckDisabled, markUpdateNotified, maybeNotifyAboutUpdate, packageAddCommand, packageRunCommand, readLocalghostState, removeManagedBlock, removeSystemHosts, renderCaddyfile, renderHostsBlock, runCaddy, runDoctor, shouldNotifyAboutUpdate, updateSystemHosts, upsertManagedBlock, validateCaddyfile, writeCaddyfile, writeLocalghostState };
236
+ export { type CaddyModeOptions, ConfigPattern, DevHostEntry, type DoctorResult, type DomainRoute, type DomainRouteOptions, type FindAvailablePortOptions, type InitOptions, type InitResult, LOCALGHOST_ACTIVITY_VERSION, LOCALGHOST_PACKAGE_NAME, LOCALGHOST_STATE_FILE, LOCALGHOST_VERSION, type LocalghostActivity, type LocalghostContext, type LocalghostContextOptions, type LocalghostEnvironment, type LocalghostRunMode, type LocalghostRunRecord, type LocalghostState, type LocalghostStateAction, type PackageManager, ReadDevHostsOptions, type RegisterLocalghostRunInput, type RemoveSystemHostsResult, UPDATE_CHECK_CACHE_TTL_MS, UPDATE_CHECK_NOTIFY_TTL_MS, UPDATE_CHECK_TIMEOUT_MS, type UpdateCheckCache, type UpdateCheckResult, type UpdateSystemHostsResult, type WriteLocalghostStateInput, assertLocalDevelopment, checkCaddy, checkForUpdate, compareVersions, defineLocalghostConfig, detectPackageManager, findAvailablePort, formatDomainRoutes, formatUpdateMessage, getCaddyfilePath, getDomainRoutes, getLocalghostActivityPath, getLocalghostStatePath, getProductionEnvKeys, getProductionReason, getSystemHostsPath, getUpdateCheckCachePath, initLocalghost, isNewerVersion, isPortAvailable, isProcessRunning, isProductionLike, isUpdateCheckDisabled, listLocalghostRuns, markUpdateNotified, maybeNotifyAboutUpdate, packageAddCommand, packageRunCommand, patchLocalghostState, pruneLocalghostActivity, readLocalghostActivity, readLocalghostState, registerLocalghostRun, removeManagedBlock, removeSystemHosts, renderCaddyfile, renderHostsBlock, resolveLocalghostContext, runCaddy, runDoctor, shouldNotifyAboutUpdate, startCaddy, trustCaddy, unregisterLocalghostRun, updateSystemHosts, upsertManagedBlock, validateCaddyfile, writeCaddyfile, writeLocalghostActivity, writeLocalghostState };