fluxy-bot 0.5.52 → 0.5.54
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 +72 -11
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -140,6 +140,8 @@ class Stepper {
|
|
|
140
140
|
this.frame = 0;
|
|
141
141
|
this.interval = null;
|
|
142
142
|
this.done = false;
|
|
143
|
+
this.infoLines = []; // extra lines shown below the progress bar
|
|
144
|
+
this._totalLines = 0; // total lines rendered last frame (for cursor rewind)
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
start() {
|
|
@@ -151,11 +153,16 @@ class Stepper {
|
|
|
151
153
|
this.render();
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
setInfo(lines) {
|
|
157
|
+
this.infoLines = lines || [];
|
|
158
|
+
this.render();
|
|
159
|
+
}
|
|
160
|
+
|
|
154
161
|
render() {
|
|
155
162
|
if (this.done) return;
|
|
156
163
|
|
|
157
|
-
if (this.
|
|
158
|
-
process.stdout.write(`\x1b[${this.
|
|
164
|
+
if (this._totalLines > 0) {
|
|
165
|
+
process.stdout.write(`\x1b[${this._totalLines}A`);
|
|
159
166
|
}
|
|
160
167
|
|
|
161
168
|
const ratio = this.current / this.steps.length;
|
|
@@ -171,6 +178,19 @@ class Stepper {
|
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
console.log(`\n ${progressBar(ratio)} ${c.dim}${Math.round(ratio * 100)}%${c.reset}`);
|
|
181
|
+
|
|
182
|
+
// steps + blank + progress = steps.length + 2, plus info lines
|
|
183
|
+
let lineCount = this.steps.length + 2;
|
|
184
|
+
|
|
185
|
+
if (this.infoLines.length) {
|
|
186
|
+
console.log('');
|
|
187
|
+
for (const line of this.infoLines) {
|
|
188
|
+
console.log(line);
|
|
189
|
+
}
|
|
190
|
+
lineCount += 1 + this.infoLines.length;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
this._totalLines = lineCount;
|
|
174
194
|
}
|
|
175
195
|
|
|
176
196
|
advance() {
|
|
@@ -182,7 +202,15 @@ class Stepper {
|
|
|
182
202
|
this.done = true;
|
|
183
203
|
if (this.interval) clearInterval(this.interval);
|
|
184
204
|
|
|
185
|
-
|
|
205
|
+
if (this._totalLines > 0) {
|
|
206
|
+
process.stdout.write(`\x1b[${this._totalLines}A`);
|
|
207
|
+
}
|
|
208
|
+
// Clear all previously rendered lines
|
|
209
|
+
for (let i = 0; i < this._totalLines; i++) {
|
|
210
|
+
process.stdout.write('\x1b[2K\n');
|
|
211
|
+
}
|
|
212
|
+
process.stdout.write(`\x1b[${this._totalLines}A`);
|
|
213
|
+
|
|
186
214
|
for (const step of this.steps) {
|
|
187
215
|
console.log(` ${c.blue}✔${c.reset} ${step}`);
|
|
188
216
|
}
|
|
@@ -325,7 +353,7 @@ async function installCloudflared() {
|
|
|
325
353
|
|
|
326
354
|
// ── Boot server ──
|
|
327
355
|
|
|
328
|
-
function bootServer() {
|
|
356
|
+
function bootServer({ onTunnelUp, onReady } = {}) {
|
|
329
357
|
return new Promise((resolve, reject) => {
|
|
330
358
|
const child = spawn(
|
|
331
359
|
process.execPath,
|
|
@@ -337,6 +365,7 @@ function bootServer() {
|
|
|
337
365
|
let relayUrl = null;
|
|
338
366
|
let resolved = false;
|
|
339
367
|
let stderrBuf = '';
|
|
368
|
+
let tunnelFired = false;
|
|
340
369
|
|
|
341
370
|
// Vite warmup tracking
|
|
342
371
|
let viteWarmResolve;
|
|
@@ -345,6 +374,8 @@ function bootServer() {
|
|
|
345
374
|
const doResolve = () => {
|
|
346
375
|
if (resolved) return;
|
|
347
376
|
resolved = true;
|
|
377
|
+
if (!tunnelFired && onTunnelUp) onTunnelUp();
|
|
378
|
+
if (onReady) onReady();
|
|
348
379
|
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
349
380
|
resolve({
|
|
350
381
|
child,
|
|
@@ -358,7 +389,10 @@ function bootServer() {
|
|
|
358
389
|
const text = data.toString();
|
|
359
390
|
|
|
360
391
|
const tunnelMatch = text.match(/__TUNNEL_URL__=(\S+)/);
|
|
361
|
-
if (tunnelMatch)
|
|
392
|
+
if (tunnelMatch) {
|
|
393
|
+
tunnelUrl = tunnelMatch[1];
|
|
394
|
+
if (!tunnelFired && onTunnelUp) { tunnelFired = true; onTunnelUp(tunnelUrl); }
|
|
395
|
+
}
|
|
362
396
|
|
|
363
397
|
const relayMatch = text.match(/__RELAY_URL__=(\S+)/);
|
|
364
398
|
if (relayMatch) relayUrl = relayMatch[1];
|
|
@@ -432,9 +466,25 @@ async function init() {
|
|
|
432
466
|
|
|
433
467
|
// Server + Tunnel
|
|
434
468
|
stepper.advance();
|
|
469
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
435
470
|
let result;
|
|
436
471
|
try {
|
|
437
|
-
result = await bootServer(
|
|
472
|
+
result = await bootServer({
|
|
473
|
+
onTunnelUp: (url) => {
|
|
474
|
+
stepper.advance(); // Connecting tunnel done
|
|
475
|
+
// Show the direct URL while waiting for the custom domain to become reachable
|
|
476
|
+
if (config.relay?.url) {
|
|
477
|
+
stepper.setInfo([
|
|
478
|
+
` ${c.dim}Waiting for ${c.reset}${c.white}${config.relay.url.replace('https://', '')}${c.reset}${c.dim} to become reachable (can take up to 2 min)${c.reset}`,
|
|
479
|
+
` ${c.dim}In the meanwhile you can access:${c.reset} ${c.blue}${link(url)}${c.reset}`,
|
|
480
|
+
]);
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
onReady: () => {
|
|
484
|
+
stepper.setInfo([]);
|
|
485
|
+
stepper.advance(); // Verifying connection done
|
|
486
|
+
},
|
|
487
|
+
});
|
|
438
488
|
} catch (err) {
|
|
439
489
|
stepper.finish();
|
|
440
490
|
console.error(`\n ${c.red}Server failed to start:${c.reset}`);
|
|
@@ -442,8 +492,6 @@ async function init() {
|
|
|
442
492
|
process.exit(1);
|
|
443
493
|
}
|
|
444
494
|
const { child, tunnelUrl, relayUrl, viteWarm } = result;
|
|
445
|
-
stepper.advance(); // Connecting tunnel done
|
|
446
|
-
stepper.advance(); // Verifying connection done
|
|
447
495
|
|
|
448
496
|
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
449
497
|
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|
|
@@ -523,9 +571,24 @@ async function start() {
|
|
|
523
571
|
stepper.advance(); // config exists
|
|
524
572
|
stepper.advance(); // starting
|
|
525
573
|
|
|
574
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
526
575
|
let result;
|
|
527
576
|
try {
|
|
528
|
-
result = await bootServer(
|
|
577
|
+
result = await bootServer({
|
|
578
|
+
onTunnelUp: (url) => {
|
|
579
|
+
stepper.advance(); // Connecting tunnel done
|
|
580
|
+
if (config.relay?.url) {
|
|
581
|
+
stepper.setInfo([
|
|
582
|
+
` ${c.dim}Waiting for ${c.reset}${c.white}${config.relay.url.replace('https://', '')}${c.reset}${c.dim} to become reachable (can take up to 2 min)${c.reset}`,
|
|
583
|
+
` ${c.dim}In the meanwhile you can access:${c.reset} ${c.blue}${link(url)}${c.reset}`,
|
|
584
|
+
]);
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
onReady: () => {
|
|
588
|
+
stepper.setInfo([]);
|
|
589
|
+
stepper.advance(); // Verifying connection done
|
|
590
|
+
},
|
|
591
|
+
});
|
|
529
592
|
} catch (err) {
|
|
530
593
|
stepper.finish();
|
|
531
594
|
console.error(`\n ${c.red}Server failed to start:${c.reset}`);
|
|
@@ -533,8 +596,6 @@ async function start() {
|
|
|
533
596
|
process.exit(1);
|
|
534
597
|
}
|
|
535
598
|
const { child, tunnelUrl, relayUrl, viteWarm } = result;
|
|
536
|
-
stepper.advance(); // Connecting tunnel done
|
|
537
|
-
stepper.advance(); // Verifying connection done
|
|
538
599
|
|
|
539
600
|
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
540
601
|
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|