@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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/ui/dashboard.tsx
|
|
4
|
+
import "react";
|
|
5
|
+
import { Box, render, Text } from "ink";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
var MAX_LOGS = 12;
|
|
8
|
+
function statusDot(status) {
|
|
9
|
+
switch (status) {
|
|
10
|
+
case "live":
|
|
11
|
+
return /* @__PURE__ */ jsx(Text, { color: "green", children: "\u25CF LIVE" });
|
|
12
|
+
case "reconnecting":
|
|
13
|
+
return /* @__PURE__ */ jsx(Text, { color: "yellow", children: "\u25CC RECONNECTING" });
|
|
14
|
+
default:
|
|
15
|
+
return /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u25CC CONNECTING" });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function Dashboard(state) {
|
|
19
|
+
const latency = state.avgLatencyMs !== void 0 ? ` \u26A1 ${state.avgLatencyMs}ms avg` : "";
|
|
20
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
21
|
+
/* @__PURE__ */ jsxs(
|
|
22
|
+
Box,
|
|
23
|
+
{
|
|
24
|
+
flexDirection: "column",
|
|
25
|
+
borderStyle: "round",
|
|
26
|
+
borderColor: "cyan",
|
|
27
|
+
paddingX: 1,
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
30
|
+
statusDot(state.status),
|
|
31
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
32
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: state.url })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
35
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
36
|
+
"\u2192 ",
|
|
37
|
+
state.target
|
|
38
|
+
] }),
|
|
39
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
40
|
+
" ",
|
|
41
|
+
state.connections,
|
|
42
|
+
" edge conns"
|
|
43
|
+
] })
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
46
|
+
"\u2191 ",
|
|
47
|
+
state.requests,
|
|
48
|
+
" reqs",
|
|
49
|
+
latency
|
|
50
|
+
] }) })
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsx(Box, { flexDirection: "column", paddingX: 1, children: state.logs.length === 0 ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: state.ephemeral ? "waiting for traffic\u2026 (Ctrl-C stops; this URL is temporary)" : "waiting for traffic\u2026 (Ctrl-C stops; your URL is preserved)" }) : state.logs.map((line, i) => /* @__PURE__ */ jsx(Text, { dimColor: true, wrap: "truncate-end", children: line }, i)) })
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
function startDashboard(initial) {
|
|
58
|
+
const state = { ...initial, logs: [...initial.logs] };
|
|
59
|
+
const instance = render(/* @__PURE__ */ jsx(Dashboard, { ...state }), {
|
|
60
|
+
stdout: process.stdout,
|
|
61
|
+
// We drive graceful shutdown ourselves; ink's Ctrl-C simply resolves
|
|
62
|
+
// waitUntilExit, and the caller then stops the runner (preserving state).
|
|
63
|
+
exitOnCtrlC: true
|
|
64
|
+
});
|
|
65
|
+
const rerender = () => instance.rerender(/* @__PURE__ */ jsx(Dashboard, { ...state }));
|
|
66
|
+
return {
|
|
67
|
+
update(partial) {
|
|
68
|
+
Object.assign(state, partial);
|
|
69
|
+
rerender();
|
|
70
|
+
},
|
|
71
|
+
log(line) {
|
|
72
|
+
state.logs = [...state.logs, line].slice(-MAX_LOGS);
|
|
73
|
+
rerender();
|
|
74
|
+
},
|
|
75
|
+
waitUntilExit() {
|
|
76
|
+
return instance.waitUntilExit();
|
|
77
|
+
},
|
|
78
|
+
stop() {
|
|
79
|
+
instance.unmount();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
startDashboard
|
|
85
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cliftonc/cfld",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-token, persistent Cloudflare tunnel CLI for local dev — same public HTTPS URL every run.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"cfld": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsup",
|
|
17
|
+
"dev": "tsup --watch",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:watch": "vitest",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cloudflare",
|
|
25
|
+
"cloudflared",
|
|
26
|
+
"tunnel",
|
|
27
|
+
"ngrok",
|
|
28
|
+
"localtunnel",
|
|
29
|
+
"dev",
|
|
30
|
+
"https",
|
|
31
|
+
"webhook"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@clack/prompts": "^0.7.0",
|
|
36
|
+
"boxen": "^7.1.1",
|
|
37
|
+
"ink": "^5.2.1",
|
|
38
|
+
"picocolors": "^1.0.1",
|
|
39
|
+
"react": "^18.3.1"
|
|
40
|
+
},
|
|
41
|
+
"optionalDependencies": {
|
|
42
|
+
"cloudflared": "^0.7.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^20.14.0",
|
|
46
|
+
"@types/react": "^18.3.31",
|
|
47
|
+
"tsup": "^8.1.0",
|
|
48
|
+
"typescript": "^5.5.0",
|
|
49
|
+
"vitest": "^2.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|