devtunnel-cli 3.0.23 → 3.0.25
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/package.json +1 -1
- package/src/core/start.js +22 -8
- package/src/core/static-server.js +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devtunnel-cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.25",
|
|
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
|
@@ -17,10 +17,10 @@ function getPackageVersion() {
|
|
|
17
17
|
const pkgPath = join(PROJECT_ROOT, "package.json");
|
|
18
18
|
if (existsSync(pkgPath)) {
|
|
19
19
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
20
|
-
return pkg.version || "3.0.
|
|
20
|
+
return pkg.version || "3.0.25";
|
|
21
21
|
}
|
|
22
22
|
} catch (err) {}
|
|
23
|
-
return "3.0.
|
|
23
|
+
return "3.0.25";
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Helper to run command
|
|
@@ -133,12 +133,12 @@ function detectLaravelProject(currentDir) {
|
|
|
133
133
|
function detectHtmlProject(currentDir) {
|
|
134
134
|
const indexPath = join(currentDir, "index.html");
|
|
135
135
|
if (!existsSync(indexPath)) return null;
|
|
136
|
-
return { name: basename(currentDir), defaultPort:
|
|
136
|
+
return { name: basename(currentDir), defaultPort: 5500 }; // Live Server default; matches VS Code
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
// Check common ports for running dev servers (includes Laravel 8000, XAMPP/Live Server 8080/5500)
|
|
140
140
|
async function detectRunningDevServer() {
|
|
141
|
-
const commonPorts = [3000, 5173, 8080, 8000, 5000, 4000,
|
|
141
|
+
const commonPorts = [3000, 5173, 5500, 8080, 8000, 5000, 4000, 3001, 5174]; // 5500 before 8080 for Live Server
|
|
142
142
|
const detected = [];
|
|
143
143
|
|
|
144
144
|
for (const port of commonPorts) {
|
|
@@ -206,7 +206,7 @@ async function autoDetectProject() {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// 3) Plain HTML (index.html) — default port
|
|
209
|
+
// 3) Plain HTML (index.html) — default port 5500 (Live Server), else built-in static server
|
|
210
210
|
const html = detectHtmlProject(currentDir);
|
|
211
211
|
if (html) {
|
|
212
212
|
const detectedPort = runningPorts.length > 0 ? runningPorts[0] : html.defaultPort;
|
|
@@ -418,12 +418,15 @@ async function main() {
|
|
|
418
418
|
projectPath = selectedPath;
|
|
419
419
|
projectName = basename(selectedPath);
|
|
420
420
|
|
|
421
|
-
// Try to detect port for selected project (Laravel → 8000, Node from package.json
|
|
421
|
+
// Try to detect port for selected project (Laravel → 8000, HTML → 5500, Node from package.json)
|
|
422
422
|
const selectedPackagePath = join(selectedPath, "package.json");
|
|
423
423
|
const laravelSelected = detectLaravelProject(selectedPath);
|
|
424
|
+
const htmlSelected = detectHtmlProject(selectedPath);
|
|
424
425
|
const detectedPort = laravelSelected
|
|
425
426
|
? laravelSelected.defaultPort
|
|
426
|
-
:
|
|
427
|
+
: htmlSelected
|
|
428
|
+
? htmlSelected.defaultPort
|
|
429
|
+
: detectPortFromPackage(selectedPackagePath);
|
|
427
430
|
|
|
428
431
|
const portResponse = await prompts({
|
|
429
432
|
type: "number",
|
|
@@ -438,6 +441,17 @@ async function main() {
|
|
|
438
441
|
}
|
|
439
442
|
|
|
440
443
|
devPort = portResponse.port;
|
|
444
|
+
} else {
|
|
445
|
+
// User confirmed – let them keep default port or type another (e.g. HTML default 5500, can change)
|
|
446
|
+
const portPrompt = await prompts({
|
|
447
|
+
type: "number",
|
|
448
|
+
name: "port",
|
|
449
|
+
message: "Dev server port (press Enter for default):",
|
|
450
|
+
initial: devPort
|
|
451
|
+
});
|
|
452
|
+
if (portPrompt.port != null && portPrompt.port > 0) {
|
|
453
|
+
devPort = portPrompt.port;
|
|
454
|
+
}
|
|
441
455
|
}
|
|
442
456
|
} else if (autoDetected && !autoDetected.port) {
|
|
443
457
|
// Project detected but no port
|
|
@@ -514,7 +528,7 @@ async function main() {
|
|
|
514
528
|
let detectedPort = laravelSelected
|
|
515
529
|
? laravelSelected.defaultPort
|
|
516
530
|
: htmlSelected
|
|
517
|
-
? htmlSelected.defaultPort
|
|
531
|
+
? htmlSelected.defaultPort // 5500
|
|
518
532
|
: detectPortFromPackage(selectedPackagePath);
|
|
519
533
|
|
|
520
534
|
// Check for running servers
|
|
@@ -7,7 +7,7 @@ import http from "http";
|
|
|
7
7
|
import fs from "fs";
|
|
8
8
|
import path from "path";
|
|
9
9
|
const ROOT = path.resolve(process.argv[2] || ".");
|
|
10
|
-
const PORT = parseInt(process.argv[3] || "
|
|
10
|
+
const PORT = parseInt(process.argv[3] || "5500", 10);
|
|
11
11
|
|
|
12
12
|
const MIME = {
|
|
13
13
|
".html": "text/html",
|
|
@@ -36,7 +36,8 @@ const server = http.createServer((req, res) => {
|
|
|
36
36
|
}
|
|
37
37
|
// Use only pathname (strip query string and hash) so /style.css?v=1 resolves to style.css
|
|
38
38
|
const pathname = (req.url || "/").split("?")[0].split("#")[0];
|
|
39
|
-
|
|
39
|
+
// Forward slashes only so /css/style.css works on Windows (path.normalize can break with \)
|
|
40
|
+
const relative = (pathname || "/").replace(/^\/+/, "").replace(/\\/g, "/") || ".";
|
|
40
41
|
let p = path.join(ROOT, relative);
|
|
41
42
|
if (!path.isAbsolute(p)) p = path.join(ROOT, p);
|
|
42
43
|
if (!p.startsWith(ROOT)) {
|