devtunnel-cli 3.0.18 → 3.0.20
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 +4 -4
- package/package.json +1 -1
- package/src/core/start.js +25 -3
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
**1. Install DevTunnel (one-time setup):**
|
|
19
19
|
```bash
|
|
20
|
-
npm install -g devtunnel
|
|
20
|
+
npm install -g devtunnel-cli
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
**2. Navigate to your project directory:**
|
|
@@ -73,7 +73,7 @@ npm run dev
|
|
|
73
73
|
|
|
74
74
|
# Terminal 2 - DevTunnel (same directory!)
|
|
75
75
|
cd my-react-app
|
|
76
|
-
devtunnel
|
|
76
|
+
devtunnel-cli
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
**Works with any framework, API, or backend:** Vite, React, Next.js, Express, NestJS, FastAPI, Flask, Django, Spring Boot, Laravel, and any HTTP/HTTPS server!
|
|
@@ -106,7 +106,7 @@ MIT License - see [LICENSE](docs/LICENSE)
|
|
|
106
106
|
|
|
107
107
|
---
|
|
108
108
|
|
|
109
|
-
**
|
|
109
|
+
**Latest on [npm](https://www.npmjs.com/package/devtunnel-cli)** | Made with ❤️ for developers worldwide
|
|
110
110
|
|
|
111
111
|
---
|
|
112
112
|
|
|
@@ -118,7 +118,7 @@ MIT License - see [LICENSE](docs/LICENSE)
|
|
|
118
118
|
|
|
119
119
|
## 📦 Installation & Links
|
|
120
120
|
|
|
121
|
-
- **npm Package**: [devtunnel](https://www.npmjs.com/package/devtunnel)
|
|
121
|
+
- **npm Package**: [devtunnel-cli](https://www.npmjs.com/package/devtunnel-cli)
|
|
122
122
|
- **GitHub Repository**: [maiz-an/DevTunnel](https://github.com/maiz-an/DevTunnel)
|
|
123
123
|
- **GitHub Pages**: [maiz-an.github.io/DevTunnel](https://maiz-an.github.io/DevTunnel/)
|
|
124
124
|
- **Official Website**: [devtunnel.vercel.app](https://devtunnel.vercel.app)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devtunnel-cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DevTunnel - Share local dev servers worldwide. Zero configuration tunnel for any framework. Install via npm: npm install -g devtunnel-cli. Works with Vite, React, Next.js, Express, NestJS, Laravel (PHP), HTML, and more.",
|
|
6
6
|
"main": "src/core/start.js",
|
package/src/core/start.js
CHANGED
|
@@ -69,6 +69,22 @@ function checkPortInUse(port) {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// Poll until server at port responds (for HTML built-in static server)
|
|
73
|
+
async function waitForServerReady(port, timeoutMs = 10000) {
|
|
74
|
+
const start = Date.now();
|
|
75
|
+
while (Date.now() - start < timeoutMs) {
|
|
76
|
+
try {
|
|
77
|
+
const code = await new Promise((resolve) => {
|
|
78
|
+
const req = http.get(`http://127.0.0.1:${port}`, { timeout: 2000 }, (res) => resolve(res.statusCode));
|
|
79
|
+
req.on("error", () => resolve(null));
|
|
80
|
+
});
|
|
81
|
+
if (code !== null && code >= 200 && code < 500) return true;
|
|
82
|
+
} catch (err) {}
|
|
83
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
72
88
|
// Detect port from package.json
|
|
73
89
|
function detectPortFromPackage(packagePath) {
|
|
74
90
|
try {
|
|
@@ -536,7 +552,7 @@ async function main() {
|
|
|
536
552
|
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
537
553
|
console.log("");
|
|
538
554
|
|
|
539
|
-
// For HTML projects with no server running: start built-in static server
|
|
555
|
+
// For HTML projects with no server running: start built-in static server and confirm it works
|
|
540
556
|
let staticServerProcess = null;
|
|
541
557
|
const isHtmlProject = !!detectHtmlProject(projectPath);
|
|
542
558
|
const portInUseNow = await checkPortInUse(devPort);
|
|
@@ -548,8 +564,14 @@ async function main() {
|
|
|
548
564
|
shell: false
|
|
549
565
|
});
|
|
550
566
|
staticServerProcess.on("error", () => {});
|
|
551
|
-
|
|
552
|
-
|
|
567
|
+
const ready = await waitForServerReady(devPort, 10000);
|
|
568
|
+
if (!ready) {
|
|
569
|
+
if (staticServerProcess) staticServerProcess.kill();
|
|
570
|
+
console.log("");
|
|
571
|
+
console.log("ERROR: Built-in static server did not start in time. Check that port " + devPort + " is free.");
|
|
572
|
+
process.exit(1);
|
|
573
|
+
}
|
|
574
|
+
console.log("Static server ready at http://localhost:" + devPort);
|
|
553
575
|
console.log("");
|
|
554
576
|
}
|
|
555
577
|
|