fluxy-bot 0.5.52 → 0.5.53
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/bin/cli.js +16 -8
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -325,7 +325,7 @@ async function installCloudflared() {
|
|
|
325
325
|
|
|
326
326
|
// ── Boot server ──
|
|
327
327
|
|
|
328
|
-
function bootServer() {
|
|
328
|
+
function bootServer({ onTunnelUp, onReady } = {}) {
|
|
329
329
|
return new Promise((resolve, reject) => {
|
|
330
330
|
const child = spawn(
|
|
331
331
|
process.execPath,
|
|
@@ -337,6 +337,7 @@ function bootServer() {
|
|
|
337
337
|
let relayUrl = null;
|
|
338
338
|
let resolved = false;
|
|
339
339
|
let stderrBuf = '';
|
|
340
|
+
let tunnelFired = false;
|
|
340
341
|
|
|
341
342
|
// Vite warmup tracking
|
|
342
343
|
let viteWarmResolve;
|
|
@@ -345,6 +346,8 @@ function bootServer() {
|
|
|
345
346
|
const doResolve = () => {
|
|
346
347
|
if (resolved) return;
|
|
347
348
|
resolved = true;
|
|
349
|
+
if (!tunnelFired && onTunnelUp) onTunnelUp();
|
|
350
|
+
if (onReady) onReady();
|
|
348
351
|
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
349
352
|
resolve({
|
|
350
353
|
child,
|
|
@@ -358,7 +361,10 @@ function bootServer() {
|
|
|
358
361
|
const text = data.toString();
|
|
359
362
|
|
|
360
363
|
const tunnelMatch = text.match(/__TUNNEL_URL__=(\S+)/);
|
|
361
|
-
if (tunnelMatch)
|
|
364
|
+
if (tunnelMatch) {
|
|
365
|
+
tunnelUrl = tunnelMatch[1];
|
|
366
|
+
if (!tunnelFired && onTunnelUp) { tunnelFired = true; onTunnelUp(); }
|
|
367
|
+
}
|
|
362
368
|
|
|
363
369
|
const relayMatch = text.match(/__RELAY_URL__=(\S+)/);
|
|
364
370
|
if (relayMatch) relayUrl = relayMatch[1];
|
|
@@ -434,7 +440,10 @@ async function init() {
|
|
|
434
440
|
stepper.advance();
|
|
435
441
|
let result;
|
|
436
442
|
try {
|
|
437
|
-
result = await bootServer(
|
|
443
|
+
result = await bootServer({
|
|
444
|
+
onTunnelUp: () => stepper.advance(), // Connecting tunnel done
|
|
445
|
+
onReady: () => stepper.advance(), // Verifying connection done
|
|
446
|
+
});
|
|
438
447
|
} catch (err) {
|
|
439
448
|
stepper.finish();
|
|
440
449
|
console.error(`\n ${c.red}Server failed to start:${c.reset}`);
|
|
@@ -442,8 +451,6 @@ async function init() {
|
|
|
442
451
|
process.exit(1);
|
|
443
452
|
}
|
|
444
453
|
const { child, tunnelUrl, relayUrl, viteWarm } = result;
|
|
445
|
-
stepper.advance(); // Connecting tunnel done
|
|
446
|
-
stepper.advance(); // Verifying connection done
|
|
447
454
|
|
|
448
455
|
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
449
456
|
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|
|
@@ -525,7 +532,10 @@ async function start() {
|
|
|
525
532
|
|
|
526
533
|
let result;
|
|
527
534
|
try {
|
|
528
|
-
result = await bootServer(
|
|
535
|
+
result = await bootServer({
|
|
536
|
+
onTunnelUp: () => stepper.advance(), // Connecting tunnel done
|
|
537
|
+
onReady: () => stepper.advance(), // Verifying connection done
|
|
538
|
+
});
|
|
529
539
|
} catch (err) {
|
|
530
540
|
stepper.finish();
|
|
531
541
|
console.error(`\n ${c.red}Server failed to start:${c.reset}`);
|
|
@@ -533,8 +543,6 @@ async function start() {
|
|
|
533
543
|
process.exit(1);
|
|
534
544
|
}
|
|
535
545
|
const { child, tunnelUrl, relayUrl, viteWarm } = result;
|
|
536
|
-
stepper.advance(); // Connecting tunnel done
|
|
537
|
-
stepper.advance(); // Verifying connection done
|
|
538
546
|
|
|
539
547
|
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
540
548
|
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|