@hamedb89/localghost 0.1.0

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/docs/github.md ADDED
@@ -0,0 +1,129 @@
1
+ # GitHub Discoverability
2
+
3
+ Use this copy for the GitHub repo About box, topics, and social cards. Keep it specific enough for search, but still human.
4
+
5
+ ## Repository Description
6
+
7
+ Friendly local HTTPS hostnames for app repos. A tiny CLI for `.localghost` configs, `/etc/hosts` blocks, Caddy reverse proxies, and Vite `allowedHosts`.
8
+
9
+ Shorter alternative:
10
+
11
+ Friendly local HTTPS hostnames for app repos, powered by `.localghost`, Caddy, `/etc/hosts`, and Vite.
12
+
13
+ ## Topics
14
+
15
+ Recommended GitHub topics:
16
+
17
+ ```txt
18
+ localghost
19
+ localhost
20
+ local-development
21
+ local-dev
22
+ local-https
23
+ https
24
+ caddy
25
+ vite
26
+ vite-plugin
27
+ nodejs
28
+ cli
29
+ developer-tools
30
+ reverse-proxy
31
+ hosts-file
32
+ npm-package
33
+ ```
34
+
35
+ If GitHub topic limits force trimming, keep these first:
36
+
37
+ ```txt
38
+ localhost
39
+ local-development
40
+ local-https
41
+ caddy
42
+ vite
43
+ vite-plugin
44
+ nodejs
45
+ cli
46
+ developer-tools
47
+ reverse-proxy
48
+ ```
49
+
50
+ ## Search Phrases To Own
51
+
52
+ - local HTTPS hostnames for Vite
53
+ - Caddy localhost reverse proxy
54
+ - friendly localhost domains
55
+ - manage /etc/hosts for local development
56
+ - Vite allowedHosts local domains
57
+ - project-local hostname config
58
+
59
+ ## GitHub CLI Setup
60
+
61
+ After creating `hamedb89/localghost`, this sets the public repo metadata:
62
+
63
+ ```sh
64
+ gh repo edit hamedb89/localghost \
65
+ --description "Friendly local HTTPS hostnames for app repos. A tiny CLI for .localghost configs, /etc/hosts blocks, Caddy reverse proxies, and Vite allowedHosts." \
66
+ --homepage "https://hamedb89.github.io/localghost/" \
67
+ --add-topic localhost \
68
+ --add-topic local-development \
69
+ --add-topic local-https \
70
+ --add-topic caddy \
71
+ --add-topic vite \
72
+ --add-topic vite-plugin \
73
+ --add-topic nodejs \
74
+ --add-topic cli \
75
+ --add-topic developer-tools \
76
+ --add-topic reverse-proxy
77
+ ```
78
+
79
+ ## README Opening Shape
80
+
81
+ The first visible paragraph should say what it is, who it is for, and what tools it touches:
82
+
83
+ ```txt
84
+ Localghost is a tiny Node.js CLI for local HTTPS domains in app repos. It gives each project one small contract for `.localhost` hostnames, Caddy reverse proxies, Vite `allowedHosts`, and the system hosts file.
85
+ ```
86
+
87
+ That phrasing helps GitHub search and npm search without making the README feel like SEO sludge.
88
+
89
+ ## GitHub Pages
90
+
91
+ The repo ships a static marketing page in `site/` and deploys it with `.github/workflows/pages.yml`.
92
+
93
+ Local build:
94
+
95
+ ```sh
96
+ npm run site:build
97
+ ```
98
+
99
+ The build script writes `_site/`, copies `site/` into it, then copies the existing `assets/` folder into `_site/assets`. This keeps GitHub Pages support out of the npm package payload and avoids committing duplicate images.
100
+
101
+ After the repo is created, enable GitHub Pages with GitHub Actions as the source. The site URL should be:
102
+
103
+ ```txt
104
+ https://hamedb89.github.io/localghost/
105
+ ```
106
+
107
+ Recommended repo homepage:
108
+
109
+ ```txt
110
+ https://hamedb89.github.io/localghost/
111
+ ```
112
+
113
+ ## CI And Publishing
114
+
115
+ `.github/workflows/ci.yml` runs on pull requests and pushes to `main`. It uses `npm ci`, then runs:
116
+
117
+ ```sh
118
+ npm run release:check
119
+ ```
120
+
121
+ That command typechecks, builds the package, builds the static site, and runs `npm pack --dry-run`.
122
+
123
+ `.github/workflows/publish-npm.yml` publishes to npm from a published GitHub release or manual workflow dispatch. The workflow reruns `npm run release:check` before publishing and uses:
124
+
125
+ ```sh
126
+ npm publish --access public --provenance
127
+ ```
128
+
129
+ Configure npm trusted publishing for `hamedb89/localghost` before relying on the release workflow. Local manual publishes are guarded by the `prepublishOnly` package hook, which runs the same release check.
@@ -0,0 +1,124 @@
1
+ # localghost(1)
2
+
3
+ ## Name
4
+
5
+ localghost - friendly local hostnames for app repos
6
+
7
+ ## Synopsis
8
+
9
+ ```sh
10
+ localghost init [--write-scripts] [--config file] [--host host] [--port port]
11
+ localghost doctor
12
+ localghost setup [--project name] [--config file] [--config-pattern regex]
13
+ localghost teardown [--project name] [--remove-caddyfile]
14
+ localghost status [--json]
15
+ localghost update [--json]
16
+ localghost dev [--config file] [--config-pattern regex]
17
+ localghost print [--config file] [--config-pattern regex]
18
+ ```
19
+
20
+ ## Description
21
+
22
+ Localghost reads `.localghost`, writes a managed `/etc/hosts` block, records `ops/local/localghost-state.json`, generates `ops/local/Caddyfile`, and runs a Caddy local HTTPS proxy. It is intentionally small and explicit: no hidden installs, no full hosts-file rewrites, and no broad Vite `allowedHosts: true` shortcut.
23
+
24
+ Localghost checks npm for newer releases after successful commands. The check is best-effort, cached for 24 hours, and can be disabled with `LOCALGHOST_NO_UPDATE_CHECK=1` or `--no-update-check`.
25
+
26
+ ## Commands
27
+
28
+ ### init
29
+
30
+ Creates `.localghost` in the current project by default. Pass `--config <file>` to create a differently named config file.
31
+
32
+ ```sh
33
+ localghost init --write-scripts
34
+ ```
35
+
36
+ Options:
37
+
38
+ - `--cwd <path>`: project directory.
39
+ - `--host <host>`: primary hostname.
40
+ - `--port <number>`: primary app port.
41
+ - `--api-host <host>`: API hostname.
42
+ - `--api-port <number>`: API port.
43
+ - `--package-manager <npm|yarn|pnpm>`: package manager for suggested commands.
44
+ - `--write-scripts`: add Localghost scripts to `package.json`.
45
+ - `--force`: overwrite an existing config file.
46
+
47
+ ### doctor
48
+
49
+ Checks machine prerequisites.
50
+
51
+ ```sh
52
+ localghost doctor
53
+ ```
54
+
55
+ Currently checks Caddy and prints `brew install caddy` when missing.
56
+
57
+ ### setup
58
+
59
+ Updates the managed Localghost block in `/etc/hosts`, writes `ops/local/Caddyfile`, and validates it with Caddy. Pass `--config <file>` to look for a specific config file. Repeat `--config` to use the first existing file from an ordered list. Pass `--config-pattern <regex>` to search matching filenames in the project root.
60
+
61
+ ```sh
62
+ localghost setup --project app
63
+ ```
64
+
65
+ ### teardown
66
+
67
+ Removes the managed Localghost block from `/etc/hosts` for the selected project and records the action in `ops/local/localghost-state.json`. It leaves `ops/local/Caddyfile` in place unless `--remove-caddyfile` is passed.
68
+
69
+ ```sh
70
+ localghost teardown --remove-caddyfile
71
+ ```
72
+
73
+ ### status
74
+
75
+ Prints Localghost's project-local state file. Pass `--json` for scripts and agents.
76
+
77
+ ```sh
78
+ localghost status --json
79
+ ```
80
+
81
+ ### update
82
+
83
+ Checks npm for a newer Localghost release. Pass `--json` for scripts and agents.
84
+
85
+ ```sh
86
+ localghost update
87
+ ```
88
+
89
+ ### routes
90
+
91
+ Prints the local domain layer as `domain -> upstream` routes. Pass `--http` if the browser-facing domain should be shown as plain HTTP.
92
+
93
+ ```sh
94
+ localghost routes
95
+ ```
96
+
97
+ ### dev
98
+
99
+ Writes `ops/local/Caddyfile`, validates it, and runs Caddy. Supports `--config` and `--config-pattern`.
100
+
101
+ ```sh
102
+ localghost dev
103
+ ```
104
+
105
+ ### print
106
+
107
+ Prints parsed Localghost config entries as JSON. Supports `--config` and `--config-pattern`.
108
+
109
+ ```sh
110
+ localghost print
111
+ ```
112
+
113
+ ## Files
114
+
115
+ - `.localghost`: default project hostname config.
116
+ - custom config files: pass `--config <file>` or `--config-pattern <regex>`.
117
+ - `ops/local/Caddyfile`: generated local Caddy config.
118
+ - `ops/local/localghost-state.json`: last setup or teardown action.
119
+ - `/etc/hosts`: managed block only, bounded by `# localghost:start` and `# localghost:end`.
120
+
121
+ ## Exit Status
122
+
123
+ - `0`: command completed successfully.
124
+ - `1`: missing prerequisite, invalid config, or failed system command.
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@hamedb89/localghost",
3
+ "version": "0.1.0",
4
+ "description": "Friendly local HTTPS hostnames for app repos with .localghost, Caddy, /etc/hosts, and Vite.",
5
+ "type": "module",
6
+ "bin": {
7
+ "localghost": "./dist/cli.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./vite": {
15
+ "types": "./dist/vite.d.ts",
16
+ "import": "./dist/vite.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "assets",
22
+ "docs",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "keywords": [
27
+ "localghost",
28
+ "localhost",
29
+ "local-dev",
30
+ "local-development",
31
+ "local-https",
32
+ "https",
33
+ "caddy",
34
+ "vite",
35
+ "vite-plugin",
36
+ "hosts-file",
37
+ "reverse-proxy",
38
+ "developer-tools",
39
+ "cli"
40
+ ],
41
+ "scripts": {
42
+ "clean": "rm -rf dist",
43
+ "build": "tsup src/index.ts src/vite.ts src/cli.ts --format esm --dts",
44
+ "dev": "tsx src/cli.ts",
45
+ "typecheck": "tsc --noEmit",
46
+ "prepack": "npm run build",
47
+ "prepublishOnly": "npm run release:check",
48
+ "pack:dry": "npm pack --dry-run",
49
+ "release:check": "npm run typecheck && npm run build && npm run site:build && npm pack --dry-run",
50
+ "site:build": "node scripts/build-site.mjs",
51
+ "publish:public": "npm publish --access public --provenance"
52
+ },
53
+ "dependencies": {
54
+ "commander": "^14.0.0",
55
+ "execa": "^9.0.0"
56
+ },
57
+ "peerDependencies": {
58
+ "vite": ">=5"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "vite": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "devDependencies": {
66
+ "@types/node": "^22.0.0",
67
+ "tsup": "^8.0.0",
68
+ "tsx": "^4.0.0",
69
+ "typescript": "^5.0.0",
70
+ "vite": ">=5"
71
+ },
72
+ "engines": {
73
+ "node": ">=20"
74
+ },
75
+ "license": "MIT",
76
+ "private": false,
77
+ "repository": {
78
+ "type": "git",
79
+ "url": "git+https://github.com/hamedb89/localghost.git"
80
+ },
81
+ "homepage": "https://hamedb89.github.io/localghost/",
82
+ "bugs": {
83
+ "url": "https://github.com/hamedb89/localghost/issues"
84
+ },
85
+ "publishConfig": {
86
+ "access": "public"
87
+ },
88
+ "packageManager": "npm@10.9.8",
89
+ "overrides": {
90
+ "esbuild": "0.28.1"
91
+ }
92
+ }