fluxy-bot 0.5.59 → 0.5.61
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 +23 -29
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -139,6 +139,7 @@ function chooseTunnelMode() {
|
|
|
139
139
|
const options = [
|
|
140
140
|
{
|
|
141
141
|
label: 'Quick Tunnel',
|
|
142
|
+
mode: 'quick',
|
|
142
143
|
tag: 'FREE',
|
|
143
144
|
tagColor: c.green,
|
|
144
145
|
desc: [
|
|
@@ -148,6 +149,7 @@ function chooseTunnelMode() {
|
|
|
148
149
|
},
|
|
149
150
|
{
|
|
150
151
|
label: 'Named Tunnel',
|
|
152
|
+
mode: 'named',
|
|
151
153
|
tag: 'Advanced',
|
|
152
154
|
tagColor: c.yellow,
|
|
153
155
|
desc: [
|
|
@@ -155,28 +157,25 @@ function chooseTunnelMode() {
|
|
|
155
157
|
'Requires a CloudFlare account + domain',
|
|
156
158
|
],
|
|
157
159
|
},
|
|
158
|
-
{
|
|
159
|
-
label: 'Offline',
|
|
160
|
-
tag: 'Local only',
|
|
161
|
-
tagColor: c.dim,
|
|
162
|
-
desc: [
|
|
163
|
-
'No internet access — localhost only',
|
|
164
|
-
`Accessible at ${c.reset}${c.white}http://localhost:3000${c.reset}${c.dim}`,
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
160
|
];
|
|
168
161
|
|
|
169
162
|
let selected = 0;
|
|
163
|
+
let lineCount = 0;
|
|
164
|
+
|
|
165
|
+
function writeLine(text = '') {
|
|
166
|
+
process.stdout.write(`\x1b[2K${text}\n`);
|
|
167
|
+
lineCount++;
|
|
168
|
+
}
|
|
170
169
|
|
|
171
170
|
function render() {
|
|
172
|
-
// Move cursor up to
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
process.stdout.write(`\x1b[${totalLines}A`);
|
|
171
|
+
// Move cursor up to overwrite previous render
|
|
172
|
+
if (lineCount > 0) {
|
|
173
|
+
process.stdout.write(`\x1b[${lineCount}A`);
|
|
176
174
|
}
|
|
177
|
-
|
|
175
|
+
lineCount = 0;
|
|
178
176
|
|
|
179
|
-
|
|
177
|
+
writeLine(` ${c.bold}${c.white}How do you want to connect your bot?${c.reset}`);
|
|
178
|
+
writeLine();
|
|
180
179
|
|
|
181
180
|
for (let i = 0; i < options.length; i++) {
|
|
182
181
|
const opt = options[i];
|
|
@@ -185,11 +184,11 @@ function chooseTunnelMode() {
|
|
|
185
184
|
const label = isSelected ? `${c.bold}${c.white}${opt.label}` : `${c.dim}${opt.label}`;
|
|
186
185
|
const tag = `${opt.tagColor}[${opt.tag}]${c.reset}`;
|
|
187
186
|
|
|
188
|
-
|
|
187
|
+
writeLine(` ${bullet} ${label}${c.reset} ${tag}`);
|
|
189
188
|
for (const line of opt.desc) {
|
|
190
|
-
|
|
189
|
+
writeLine(` ${c.dim}${line}${c.reset}`);
|
|
191
190
|
}
|
|
192
|
-
if (i < options.length - 1)
|
|
191
|
+
if (i < options.length - 1) writeLine();
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
194
|
|
|
@@ -211,8 +210,7 @@ function chooseTunnelMode() {
|
|
|
211
210
|
process.stdin.setRawMode(false);
|
|
212
211
|
process.stdin.pause();
|
|
213
212
|
process.stdin.removeListener('data', onKey);
|
|
214
|
-
|
|
215
|
-
resolve(modes[selected]);
|
|
213
|
+
resolve(options[selected].mode);
|
|
216
214
|
} else if (key === '\x03') { // Ctrl+C
|
|
217
215
|
process.stdout.write('\n');
|
|
218
216
|
process.exit(0);
|
|
@@ -640,13 +638,13 @@ async function init() {
|
|
|
640
638
|
|
|
641
639
|
const isLinux = os.platform() === 'linux';
|
|
642
640
|
const hasSystemd = isLinux && (() => { try { execSync('systemctl --version', { stdio: 'ignore' }); return true; } catch { return false; } })();
|
|
643
|
-
const hasTunnel = tunnelMode !== 'off';
|
|
644
641
|
|
|
645
642
|
const steps = [
|
|
646
643
|
'Creating config',
|
|
647
|
-
|
|
644
|
+
'Installing cloudflared',
|
|
648
645
|
'Starting server',
|
|
649
|
-
|
|
646
|
+
'Connecting tunnel',
|
|
647
|
+
'Verifying connection',
|
|
650
648
|
'Preparing dashboard',
|
|
651
649
|
...(hasSystemd ? ['Setting up auto-start daemon'] : []),
|
|
652
650
|
];
|
|
@@ -658,12 +656,10 @@ async function init() {
|
|
|
658
656
|
stepper.advance();
|
|
659
657
|
|
|
660
658
|
// Cloudflared (skip for named — already installed during setup)
|
|
661
|
-
if (
|
|
659
|
+
if (tunnelMode !== 'named') {
|
|
662
660
|
await installCloudflared();
|
|
663
|
-
stepper.advance();
|
|
664
|
-
} else if (hasTunnel) {
|
|
665
|
-
stepper.advance(); // named: already installed
|
|
666
661
|
}
|
|
662
|
+
stepper.advance();
|
|
667
663
|
|
|
668
664
|
// Server + Tunnel
|
|
669
665
|
stepper.advance();
|
|
@@ -671,7 +667,6 @@ async function init() {
|
|
|
671
667
|
try {
|
|
672
668
|
result = await bootServer({
|
|
673
669
|
onTunnelUp: (url) => {
|
|
674
|
-
if (!hasTunnel) return;
|
|
675
670
|
stepper.advance(); // Connecting tunnel done
|
|
676
671
|
// Show the direct URL while waiting for the custom domain to become reachable
|
|
677
672
|
if (config.relay?.url) {
|
|
@@ -682,7 +677,6 @@ async function init() {
|
|
|
682
677
|
}
|
|
683
678
|
},
|
|
684
679
|
onReady: () => {
|
|
685
|
-
if (!hasTunnel) return;
|
|
686
680
|
stepper.setInfo([]);
|
|
687
681
|
stepper.advance(); // Verifying connection done
|
|
688
682
|
},
|