devtunnel-cli 3.0.9 → 3.0.10
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 +50 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devtunnel-cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10",
|
|
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 and more.",
|
|
6
6
|
"main": "src/core/start.js",
|
package/src/core/start.js
CHANGED
|
@@ -136,15 +136,16 @@ async function autoDetectProject() {
|
|
|
136
136
|
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
|
|
137
137
|
const projectName = packageJson.name || basename(currentDir);
|
|
138
138
|
|
|
139
|
-
//
|
|
140
|
-
|
|
139
|
+
// FIRST: Check for running dev servers (priority)
|
|
140
|
+
const runningPorts = await detectRunningDevServer();
|
|
141
|
+
let detectedPort = null;
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
if (runningPorts.length > 0) {
|
|
144
|
+
// Use running server port (most accurate)
|
|
145
|
+
detectedPort = runningPorts[0];
|
|
146
|
+
} else {
|
|
147
|
+
// Fallback: Try to detect port from package.json
|
|
148
|
+
detectedPort = detectPortFromPackage(packagePath);
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
return {
|
|
@@ -183,7 +184,7 @@ async function main() {
|
|
|
183
184
|
// Show ASCII logo
|
|
184
185
|
showLogo();
|
|
185
186
|
|
|
186
|
-
console.log("DevTunnel v3.0.
|
|
187
|
+
console.log("DevTunnel v3.0.10");
|
|
187
188
|
console.log("Share your local dev servers worldwide");
|
|
188
189
|
console.log("");
|
|
189
190
|
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
@@ -281,10 +282,48 @@ async function main() {
|
|
|
281
282
|
// Auto-detected project with port
|
|
282
283
|
projectPath = autoDetected.path;
|
|
283
284
|
projectName = autoDetected.name;
|
|
284
|
-
|
|
285
|
+
|
|
286
|
+
// Double-check: verify the port is actually in use
|
|
287
|
+
const portInUse = await checkPortInUse(autoDetected.port);
|
|
288
|
+
|
|
289
|
+
if (!portInUse) {
|
|
290
|
+
// Detected port is not actually running, check for other running servers
|
|
291
|
+
console.log(`Detected port ${autoDetected.port} from package.json, but no server running on that port`);
|
|
292
|
+
console.log("Checking for running dev servers...");
|
|
293
|
+
|
|
294
|
+
const runningPorts = await detectRunningDevServer();
|
|
295
|
+
if (runningPorts.length > 0) {
|
|
296
|
+
if (runningPorts.length === 1) {
|
|
297
|
+
devPort = runningPorts[0];
|
|
298
|
+
console.log(`Found running dev server on port: ${devPort}`);
|
|
299
|
+
} else {
|
|
300
|
+
console.log(`Found ${runningPorts.length} running dev server(s) on port(s): ${runningPorts.join(', ')}`);
|
|
301
|
+
const portResponse = await prompts({
|
|
302
|
+
type: "select",
|
|
303
|
+
name: "port",
|
|
304
|
+
message: "Select port:",
|
|
305
|
+
choices: runningPorts.map(p => ({ title: `Port ${p}`, value: p }))
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
if (!portResponse.port) {
|
|
309
|
+
console.log("ERROR: No port selected");
|
|
310
|
+
process.exit(1);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
devPort = portResponse.port;
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
// No running servers, use detected port (user might start it later)
|
|
317
|
+
devPort = autoDetected.port;
|
|
318
|
+
console.log(`Using detected port: ${devPort} (make sure dev server is running)`);
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
// Port is in use, use it
|
|
322
|
+
devPort = autoDetected.port;
|
|
323
|
+
}
|
|
285
324
|
|
|
286
325
|
console.log(`Detected project: ${projectName}`);
|
|
287
|
-
console.log(`
|
|
326
|
+
console.log(`Using port: ${devPort}`);
|
|
288
327
|
console.log(`Using current directory: ${projectPath}`);
|
|
289
328
|
console.log("");
|
|
290
329
|
|