fluxy-bot 0.5.53 → 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 +61 -8
- 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
|
}
|
|
@@ -363,7 +391,7 @@ function bootServer({ onTunnelUp, onReady } = {}) {
|
|
|
363
391
|
const tunnelMatch = text.match(/__TUNNEL_URL__=(\S+)/);
|
|
364
392
|
if (tunnelMatch) {
|
|
365
393
|
tunnelUrl = tunnelMatch[1];
|
|
366
|
-
if (!tunnelFired && onTunnelUp) { tunnelFired = true; onTunnelUp(); }
|
|
394
|
+
if (!tunnelFired && onTunnelUp) { tunnelFired = true; onTunnelUp(tunnelUrl); }
|
|
367
395
|
}
|
|
368
396
|
|
|
369
397
|
const relayMatch = text.match(/__RELAY_URL__=(\S+)/);
|
|
@@ -438,11 +466,24 @@ async function init() {
|
|
|
438
466
|
|
|
439
467
|
// Server + Tunnel
|
|
440
468
|
stepper.advance();
|
|
469
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
441
470
|
let result;
|
|
442
471
|
try {
|
|
443
472
|
result = await bootServer({
|
|
444
|
-
onTunnelUp: () =>
|
|
445
|
-
|
|
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
|
+
},
|
|
446
487
|
});
|
|
447
488
|
} catch (err) {
|
|
448
489
|
stepper.finish();
|
|
@@ -530,11 +571,23 @@ async function start() {
|
|
|
530
571
|
stepper.advance(); // config exists
|
|
531
572
|
stepper.advance(); // starting
|
|
532
573
|
|
|
574
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
533
575
|
let result;
|
|
534
576
|
try {
|
|
535
577
|
result = await bootServer({
|
|
536
|
-
onTunnelUp: () =>
|
|
537
|
-
|
|
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
|
+
},
|
|
538
591
|
});
|
|
539
592
|
} catch (err) {
|
|
540
593
|
stepper.finish();
|