@hamedb89/localghost 0.1.12 → 0.1.13
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 +13 -11
- package/dist/cli.js +6 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/docs/flows.md +26 -23
- package/docs/github.md +4 -4
- package/docs/localghost.1.md +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Buh. Friendly local hostnames for app repos.
|
|
|
9
9
|
[](https://github.com/hamedb89/localghost/actions/workflows/ci.yml)
|
|
10
10
|
[](https://github.com/hamedb89/localghost/actions/workflows/pages.yml)
|
|
11
11
|
[](https://github.com/hamedb89/localghost/actions/workflows/publish-npm.yml)
|
|
12
|
-
[](https://www.npmjs.com/package/@hamedb89/localghost)
|
|
13
13
|
|
|
14
14
|
Localghost is a tiny Node.js CLI for clean local app domains. Add it as a dev dependency, keep running the command your team already knows, and use `http://app.localhost/` instead of remembering which port belongs to which process.
|
|
15
15
|
|
|
@@ -20,9 +20,14 @@ Localghost is a tiny Node.js CLI for clean local app domains. Add it as a dev de
|
|
|
20
20
|
Install it as a dev dependency:
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
|
+
npm install -D @hamedb89/localghost
|
|
24
|
+
pnpm add -D @hamedb89/localghost
|
|
23
25
|
yarn add -D @hamedb89/localghost
|
|
26
|
+
bun add -d @hamedb89/localghost
|
|
24
27
|
```
|
|
25
28
|
|
|
29
|
+
Use the command for your package manager; you only need one of the four lines above.
|
|
30
|
+
|
|
26
31
|
For Vite apps, add the plugin once:
|
|
27
32
|
|
|
28
33
|
```ts
|
|
@@ -37,7 +42,7 @@ export default defineConfig({
|
|
|
37
42
|
Then keep using the command your repo already expects:
|
|
38
43
|
|
|
39
44
|
```sh
|
|
40
|
-
|
|
45
|
+
npm exec localghost
|
|
41
46
|
```
|
|
42
47
|
|
|
43
48
|
On the first interactive run, Localghost can create `.localghost`, explain the `/etc/hosts` change, write `ops/local/Caddyfile`, and print the browser-facing URL:
|
|
@@ -54,7 +59,7 @@ For non-Vite apps, wrap your raw dev command:
|
|
|
54
59
|
```json
|
|
55
60
|
{
|
|
56
61
|
"scripts": {
|
|
57
|
-
"dev": "localghost run --
|
|
62
|
+
"dev": "localghost run -- next dev",
|
|
58
63
|
"dev:raw": "next dev"
|
|
59
64
|
}
|
|
60
65
|
}
|
|
@@ -218,14 +223,14 @@ admin.app.localhost 5174
|
|
|
218
223
|
}
|
|
219
224
|
```
|
|
220
225
|
|
|
221
|
-
### Keep
|
|
226
|
+
### Keep Your Existing Dev Command
|
|
222
227
|
|
|
223
228
|
Wrap the raw app server so teammates keep typing the normal command:
|
|
224
229
|
|
|
225
230
|
```json
|
|
226
231
|
{
|
|
227
232
|
"scripts": {
|
|
228
|
-
"dev": "localghost run --
|
|
233
|
+
"dev": "localghost run -- vite",
|
|
229
234
|
"dev:raw": "vite"
|
|
230
235
|
}
|
|
231
236
|
}
|
|
@@ -236,7 +241,7 @@ For Turborepo, wrap the dev runner and keep dev uncached:
|
|
|
236
241
|
```json
|
|
237
242
|
{
|
|
238
243
|
"scripts": {
|
|
239
|
-
"dev": "localghost run --
|
|
244
|
+
"dev": "localghost run -- turbo dev",
|
|
240
245
|
"dev:raw": "turbo dev"
|
|
241
246
|
}
|
|
242
247
|
}
|
|
@@ -307,7 +312,6 @@ export default defineLocalghostConfig({
|
|
|
307
312
|
port: 5173,
|
|
308
313
|
dynamicPort: true,
|
|
309
314
|
autoRepair: true,
|
|
310
|
-
command: ["pnpm", "dev"],
|
|
311
315
|
wwwAlias: true
|
|
312
316
|
});
|
|
313
317
|
```
|
|
@@ -329,15 +333,13 @@ export default defineLocalghostConfig({
|
|
|
329
333
|
name: "web",
|
|
330
334
|
cwd: "apps/web",
|
|
331
335
|
host: "xyz.localhost",
|
|
332
|
-
port: 5173
|
|
333
|
-
command: ["pnpm", "dev"]
|
|
336
|
+
port: 5173
|
|
334
337
|
},
|
|
335
338
|
{
|
|
336
339
|
name: "api",
|
|
337
340
|
cwd: "apps/api",
|
|
338
341
|
host: "api.xyz.localhost",
|
|
339
|
-
port: 8787
|
|
340
|
-
command: ["pnpm", "dev"]
|
|
342
|
+
port: 8787
|
|
341
343
|
}
|
|
342
344
|
]
|
|
343
345
|
});
|
package/dist/cli.js
CHANGED
|
@@ -1515,11 +1515,13 @@ import { join as join7 } from "path";
|
|
|
1515
1515
|
function detectPackageManager(cwd = process.cwd()) {
|
|
1516
1516
|
if (existsSync5(join7(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
1517
1517
|
if (existsSync5(join7(cwd, "yarn.lock"))) return "yarn";
|
|
1518
|
+
if (existsSync5(join7(cwd, "bun.lock")) || existsSync5(join7(cwd, "bun.lockb"))) return "bun";
|
|
1518
1519
|
return "npm";
|
|
1519
1520
|
}
|
|
1520
1521
|
function packageRunCommand(packageManager, script) {
|
|
1521
1522
|
if (packageManager === "yarn") return `yarn ${script}`;
|
|
1522
1523
|
if (packageManager === "pnpm") return `pnpm ${script}`;
|
|
1524
|
+
if (packageManager === "bun") return `bun run ${script}`;
|
|
1523
1525
|
return `npm run ${script}`;
|
|
1524
1526
|
}
|
|
1525
1527
|
function renderConfig(options) {
|
|
@@ -1736,7 +1738,7 @@ import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as rea
|
|
|
1736
1738
|
import { homedir as homedir2 } from "os";
|
|
1737
1739
|
import { dirname as dirname4, join as join9 } from "path";
|
|
1738
1740
|
var LOCALGHOST_PACKAGE_NAME = "@hamedb89/localghost";
|
|
1739
|
-
var LOCALGHOST_VERSION = "0.1.
|
|
1741
|
+
var LOCALGHOST_VERSION = "0.1.13";
|
|
1740
1742
|
var UPDATE_CHECK_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
1741
1743
|
var UPDATE_CHECK_NOTIFY_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
1742
1744
|
var UPDATE_CHECK_TIMEOUT_MS = 900;
|
|
@@ -1933,8 +1935,8 @@ function parsePort2(value) {
|
|
|
1933
1935
|
return port;
|
|
1934
1936
|
}
|
|
1935
1937
|
function parsePackageManager(value) {
|
|
1936
|
-
if (value === "npm" || value === "yarn" || value === "pnpm") return value;
|
|
1937
|
-
throw new InvalidArgumentError("Package manager must be npm, yarn, or
|
|
1938
|
+
if (value === "npm" || value === "yarn" || value === "pnpm" || value === "bun") return value;
|
|
1939
|
+
throw new InvalidArgumentError("Package manager must be npm, pnpm, yarn, or bun.");
|
|
1938
1940
|
}
|
|
1939
1941
|
function collect(value, previous = []) {
|
|
1940
1942
|
return [...previous, value];
|
|
@@ -2346,7 +2348,7 @@ program.hook("postAction", async (_thisCommand, actionCommand) => {
|
|
|
2346
2348
|
const options = program.opts();
|
|
2347
2349
|
await maybeNotifyAboutUpdate({ disabled: options.updateCheck === false });
|
|
2348
2350
|
});
|
|
2349
|
-
program.command("init").description("Create a .localghost config for this project").option("--cwd <path>", "Project directory", process.cwd()).option("--config <file>", "Config file to create", ".localghost").option("--host <host>", "Primary local hostname").option("--port <number>", "Primary app port", parsePort2).option("--api-host <host>", "API local hostname").option("--api-port <number>", "API port", parsePort2).option("--package-manager <npm|yarn|
|
|
2351
|
+
program.command("init").description("Create a .localghost config for this project").option("--cwd <path>", "Project directory", process.cwd()).option("--config <file>", "Config file to create", ".localghost").option("--host <host>", "Primary local hostname").option("--port <number>", "Primary app port", parsePort2).option("--api-host <host>", "API local hostname").option("--api-port <number>", "API port", parsePort2).option("--package-manager <npm|pnpm|yarn|bun>", "Package manager for suggested commands", parsePackageManager).option("--write-scripts", "Add localghost scripts to package.json").option("--force", "Overwrite an existing config file").action((options) => {
|
|
2350
2352
|
const result = initLocalghost({ ...options, configFile: options.config });
|
|
2351
2353
|
if (result.configCreated) {
|
|
2352
2354
|
console.log(`Buh. Created ${result.configPath}`);
|