@cliftonc/cfld 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/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/cli.js +1890 -0
- package/dist/dashboard-QUPY25QT.js +85 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Clifton Cunningham
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# cfld
|
|
2
|
+
|
|
3
|
+
**One command to give your localhost a permanent public HTTPS URL — no API tokens, no teardown.**
|
|
4
|
+
|
|
5
|
+
`cfld` wraps [`cloudflared`](https://github.com/cloudflare/cloudflared) into a frictionless dev experience: the **same** custom URL every run (not a random `trycloudflare.com` one), authorized with a **browser login** (zero API tokens), reusing the same named tunnel and DNS record across restarts instead of churning them. It runs a **live dashboard** (URL, connection count, request/latency counters, tailing logs), **auto-reconnects** on edge blips, and **guards** against stealing a DNS record that belongs to another tunnel.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# one-off, no install
|
|
9
|
+
npx @cliftonc/cfld # detect your dev port, reuse-or-create a tunnel, go live
|
|
10
|
+
npx @cliftonc/cfld 3000 # explicit port
|
|
11
|
+
npx @cliftonc/cfld --quick # ephemeral trycloudflare.com URL — no domain needed
|
|
12
|
+
|
|
13
|
+
# or install once and use the short `cfld` command everywhere
|
|
14
|
+
npm i -g @cliftonc/cfld
|
|
15
|
+
cfld
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Why not just `cloudflared`?
|
|
19
|
+
|
|
20
|
+
The persistent-tunnel flow normally means: create an API token in the dashboard, find your zone/account IDs, `tunnel create`, hand-write a `config.yml`, `route dns`, and remember not to delete anything. `cfld` collapses all of that into one idempotent command and adds the dev niceties (auto port detection, deterministic hostname, `.env` write-back, a live status view).
|
|
21
|
+
|
|
22
|
+
Compared to the alternatives:
|
|
23
|
+
|
|
24
|
+
- **[untun](https://github.com/unjs/untun)** — random URLs only (quick tunnels). `cfld` gives you a stable one.
|
|
25
|
+
- **[cf-tunnel](https://github.com/jasenmichael/cf-tunnel)** — needs an API token and **tears the tunnel + DNS down on exit**. `cfld` uses browser login and **preserves** resources so the URL is truly persistent.
|
|
26
|
+
- **[@agencyhandy/tunneler](https://github.com/AgencyHandy/tunneler)** — global install + API token + zone id. `cfld` is `npx`-first and zero-token.
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- **Node.js ≥ 18**
|
|
31
|
+
- **A domain on Cloudflare** (nameservers pointed at Cloudflare) for a persistent custom URL. Don't have one yet? `cfld` guides you, and `cfld --quick` works immediately with an ephemeral URL.
|
|
32
|
+
- `cloudflared` — used from your `PATH` if present, otherwise auto-downloaded via the optional [`cloudflared`](https://www.npmjs.com/package/cloudflared) npm package.
|
|
33
|
+
|
|
34
|
+
## How it works
|
|
35
|
+
|
|
36
|
+
Every run reconciles four things, treating **Cloudflare as the source of truth** and local files as a cache:
|
|
37
|
+
|
|
38
|
+
1. **Cert** — per-domain cert stored at `~/.cfld/certs/<zone>.pem`, obtained once via `cloudflared tunnel login` (browser, no token) and selected with `--origincert` so **multiple domains coexist** on one machine.
|
|
39
|
+
2. **Tunnel** — reused by name (`cfld-<slug>`) if it exists, created only if absent. Never deleted on exit.
|
|
40
|
+
3. **DNS** — `route dns --overwrite-dns` points `<slug>.<zone>` at the tunnel (idempotent).
|
|
41
|
+
4. **Config** — a generated ingress file + your public URL written into `./.env` (`PUBLIC_URL` by default).
|
|
42
|
+
|
|
43
|
+
A machine-wide registry at `~/.cfld/registry.json` indexes every tunnel, so you can manage them from anywhere.
|
|
44
|
+
|
|
45
|
+
## Commands
|
|
46
|
+
|
|
47
|
+
| Command | What it does |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `cfld [port]` | Ensure + run a persistent tunnel (reuses the same URL). |
|
|
50
|
+
| `cfld --quick [port]` | Ephemeral `trycloudflare.com` URL — no cert/domain. |
|
|
51
|
+
| `cfld login [--reauth]` | Authorize with Cloudflare in your browser. `--reauth` adds another domain. |
|
|
52
|
+
| `cfld init` | Interactive setup wizard — configure a project without running it. |
|
|
53
|
+
| `cfld list` | List all tunnels across projects/domains. |
|
|
54
|
+
| `cfld status [name]` | Show details for a tunnel. |
|
|
55
|
+
| `cfld up <name>` | Run a registered tunnel by name from anywhere. |
|
|
56
|
+
| `cfld destroy [name]` | Delete a tunnel (explicit, opt-in). |
|
|
57
|
+
| `cfld service <action> [name]` | Always-on background service: `install`/`uninstall`/`start`/`stop`/`status`. |
|
|
58
|
+
| `cfld doctor` | Diagnose your setup. |
|
|
59
|
+
|
|
60
|
+
### Options
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
--name <slug> Override the project name (default: package.json name / dir)
|
|
64
|
+
--host <fqdn> Explicit public hostname (e.g. api.example.com)
|
|
65
|
+
--zone <domain> Cloudflare domain to use (e.g. example.com)
|
|
66
|
+
--env <KEY> .env key to write the URL to (default: PUBLIC_URL)
|
|
67
|
+
--no-env Don't write the URL to .env
|
|
68
|
+
--force Skip confirmation (destroy)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Configuration (optional)
|
|
72
|
+
|
|
73
|
+
Everything is inferred by default, but you can commit intent to `package.json` under a `"cfld"` key. Authored values win over the machine-local `.cfld.json` cache (so edits take effect immediately); only the resolved tunnel UUID comes from the cache.
|
|
74
|
+
|
|
75
|
+
```jsonc
|
|
76
|
+
{
|
|
77
|
+
"cfld": {
|
|
78
|
+
"zone": "example.com",
|
|
79
|
+
"name": "myapp", // → myapp.example.com
|
|
80
|
+
"envKey": "PUBLIC_URL"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Multiple services from one tunnel (multi-ingress)
|
|
86
|
+
|
|
87
|
+
Expose an API and a web app at once with a `routes` array:
|
|
88
|
+
|
|
89
|
+
```jsonc
|
|
90
|
+
{
|
|
91
|
+
"cfld": {
|
|
92
|
+
"zone": "example.com",
|
|
93
|
+
"routes": [
|
|
94
|
+
{ "name": "app", "port": 3000 }, // app.example.com → :3000
|
|
95
|
+
{ "name": "api", "port": 8080, "path": "/v1" }, // api.example.com/v1 → :8080
|
|
96
|
+
{ "host": "hooks.example.com", "port": 4000 } // explicit hostname
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The first route is the primary (used for the dashboard and `.env`). Every hostname is routed and DNS-guarded.
|
|
103
|
+
|
|
104
|
+
## Always-on service
|
|
105
|
+
|
|
106
|
+
The foreground `cfld` is the dev default. To keep a tunnel up across logout/reboot, install it as a background service (macOS **LaunchAgent** / Linux **systemd user** unit):
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cfld service install # register + start
|
|
110
|
+
cfld service status
|
|
111
|
+
cfld service uninstall # stop + remove (tunnel + DNS preserved)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Windows service management is not supported — run `cfld` in the foreground there.
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install
|
|
120
|
+
npm run build # tsup → dist/
|
|
121
|
+
npm test # vitest unit + integration tests
|
|
122
|
+
npm run typecheck # tsc --noEmit
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The primary end-to-end check needs no domain or paid plan: `cfld --quick` against a local server, then fetch the resulting URL and assert the response round-trips through Cloudflare's edge.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT
|