openmagic 0.31.7 → 0.31.8
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/dist/cli.js +25 -10
- package/dist/cli.js.map +1 -1
- package/dist/toolbar/index.global.js +1 -1
- package/dist/toolbar/index.global.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2453,6 +2453,7 @@ async function offerToStartDevServer(expectedPort) {
|
|
|
2453
2453
|
}
|
|
2454
2454
|
}
|
|
2455
2455
|
let port = expectedPort || chosen.defaultPort;
|
|
2456
|
+
let portChanged = false;
|
|
2456
2457
|
if (await isPortOpen(port)) {
|
|
2457
2458
|
const owned = verifyPortOwnership(port, process.cwd());
|
|
2458
2459
|
if (owned === true) {
|
|
@@ -2469,14 +2470,22 @@ async function offerToStartDevServer(expectedPort) {
|
|
|
2469
2470
|
chalk.dim(` Starting on port ${altPort} instead.`)
|
|
2470
2471
|
);
|
|
2471
2472
|
port = altPort;
|
|
2473
|
+
portChanged = true;
|
|
2472
2474
|
}
|
|
2473
2475
|
console.log("");
|
|
2474
2476
|
console.log(
|
|
2475
|
-
chalk.dim(` Starting `) + chalk.cyan(`npm run ${chosen.name}`) + chalk.dim("...")
|
|
2477
|
+
chalk.dim(` Starting `) + chalk.cyan(`npm run ${chosen.name}`) + (portChanged ? chalk.dim(` (port ${port})`) : "") + chalk.dim("...")
|
|
2476
2478
|
);
|
|
2477
2479
|
const depsInfo = checkDependenciesInstalled();
|
|
2478
2480
|
const runCmd = depsInfo.packageManager === "yarn" ? "yarn" : depsInfo.packageManager === "pnpm" ? "pnpm" : depsInfo.packageManager === "bun" ? "bun" : "npm";
|
|
2479
2481
|
const runArgs = runCmd === "npm" ? ["run", chosen.name] : [chosen.name];
|
|
2482
|
+
if (portChanged) {
|
|
2483
|
+
if (runCmd === "npm") {
|
|
2484
|
+
runArgs.push("--", "--port", String(port));
|
|
2485
|
+
} else {
|
|
2486
|
+
runArgs.push("--port", String(port));
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2480
2489
|
let child;
|
|
2481
2490
|
try {
|
|
2482
2491
|
child = spawn(runCmd, runArgs, {
|
|
@@ -2500,10 +2509,14 @@ async function offerToStartDevServer(expectedPort) {
|
|
|
2500
2509
|
let detectedPort = null;
|
|
2501
2510
|
function parsePortFromOutput(line) {
|
|
2502
2511
|
const clean = line.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, "").replace(/\x1b[^a-zA-Z]*[a-zA-Z]/g, "").replace(/[\x00-\x1f\x7f]/g, "");
|
|
2503
|
-
const portMatch = clean.match(/https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)/);
|
|
2512
|
+
const portMatch = clean.match(/https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1?\]):(\d+)/);
|
|
2504
2513
|
if (portMatch && !detectedPort) {
|
|
2505
2514
|
const p = parseInt(portMatch[1], 10);
|
|
2506
|
-
if (p > 0 && p < 65536
|
|
2515
|
+
if (p > 0 && p < 65536) {
|
|
2516
|
+
if (p === port) {
|
|
2517
|
+
detectedPort = p;
|
|
2518
|
+
return;
|
|
2519
|
+
}
|
|
2507
2520
|
detectedPort = p;
|
|
2508
2521
|
return;
|
|
2509
2522
|
}
|
|
@@ -2564,17 +2577,19 @@ async function offerToStartDevServer(expectedPort) {
|
|
|
2564
2577
|
console.log(
|
|
2565
2578
|
chalk.dim(` Waiting for dev server...`)
|
|
2566
2579
|
);
|
|
2567
|
-
const isUp = await waitForPort(port,
|
|
2580
|
+
const isUp = await waitForPort(port, 6e4, () => {
|
|
2568
2581
|
if (childExited) return true;
|
|
2569
2582
|
if (detectedPort) return true;
|
|
2570
2583
|
return false;
|
|
2571
2584
|
});
|
|
2572
|
-
if (
|
|
2573
|
-
const altUp = await isPortOpen(detectedPort);
|
|
2585
|
+
if (detectedPort) {
|
|
2586
|
+
const altUp = detectedPort === port ? isUp : await isPortOpen(detectedPort);
|
|
2574
2587
|
if (altUp) {
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2588
|
+
if (detectedPort !== port) {
|
|
2589
|
+
console.log(
|
|
2590
|
+
chalk.green(` \u2713 Dev server is on port ${detectedPort} (configured in project, not default ${port})`)
|
|
2591
|
+
);
|
|
2592
|
+
}
|
|
2578
2593
|
lastDetectedPort = detectedPort;
|
|
2579
2594
|
return true;
|
|
2580
2595
|
}
|
|
@@ -2617,7 +2632,7 @@ async function offerToStartDevServer(expectedPort) {
|
|
|
2617
2632
|
}
|
|
2618
2633
|
}
|
|
2619
2634
|
console.log(
|
|
2620
|
-
chalk.yellow(` \u26A0 Port ${port} didn't open after
|
|
2635
|
+
chalk.yellow(` \u26A0 Port ${port} didn't open after 60s.`)
|
|
2621
2636
|
);
|
|
2622
2637
|
console.log(
|
|
2623
2638
|
chalk.dim(` The server might use a different port. Check the output above.`)
|