fluxy-bot 0.1.28 → 0.1.30
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 +12 -10
- package/package.json +1 -1
- package/supervisor/tunnel.ts +16 -13
package/bin/cli.js
CHANGED
|
@@ -159,19 +159,21 @@ function createConfig() {
|
|
|
159
159
|
const MIN_CF_SIZE = 10 * 1024 * 1024; // 10 MB — valid cloudflared is ~30-50 MB
|
|
160
160
|
|
|
161
161
|
function hasCloudflared() {
|
|
162
|
-
// Check
|
|
163
|
-
const which = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
|
|
164
|
-
try { execSync(which, { stdio: 'ignore' }); return true; } catch {}
|
|
165
|
-
|
|
166
|
-
// Check local install (validate by file size, never execute — avoids Windows popup)
|
|
162
|
+
// Check local install first (validate by file size, never execute — avoids Windows popup)
|
|
167
163
|
const cfExe = process.platform === 'win32' ? CF_PATH + '.exe' : CF_PATH;
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
164
|
+
if (fs.existsSync(cfExe)) {
|
|
165
|
+
const size = fs.statSync(cfExe).size;
|
|
166
|
+
if (size >= MIN_CF_SIZE) return true;
|
|
171
167
|
fs.unlinkSync(cfExe);
|
|
172
|
-
return false;
|
|
173
168
|
}
|
|
174
|
-
|
|
169
|
+
|
|
170
|
+
// Fall back to system-wide install (skip on Windows — system cloudflared
|
|
171
|
+
// spams AssignProcessToJobObject when spawned as a child process)
|
|
172
|
+
if (process.platform !== 'win32') {
|
|
173
|
+
try { execSync('which cloudflared', { stdio: 'ignore' }); return true; } catch {}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return false;
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
async function installCloudflared() {
|
package/package.json
CHANGED
package/supervisor/tunnel.ts
CHANGED
|
@@ -10,18 +10,20 @@ let proc: ChildProcess | null = null;
|
|
|
10
10
|
const MIN_CF_SIZE = 10 * 1024 * 1024; // 10 MB — valid cloudflared is ~30-50 MB
|
|
11
11
|
|
|
12
12
|
function findBinary(): string | null {
|
|
13
|
-
// Check
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Check local install (validate by file size, never execute — avoids Windows popup)
|
|
18
|
-
if (!fs.existsSync(paths.cloudflared)) return null;
|
|
19
|
-
const size = fs.statSync(paths.cloudflared).size;
|
|
20
|
-
if (size < MIN_CF_SIZE) {
|
|
13
|
+
// Check local install first (validate by file size, never execute — avoids Windows popup)
|
|
14
|
+
if (fs.existsSync(paths.cloudflared)) {
|
|
15
|
+
const size = fs.statSync(paths.cloudflared).size;
|
|
16
|
+
if (size >= MIN_CF_SIZE) return paths.cloudflared;
|
|
21
17
|
fs.unlinkSync(paths.cloudflared);
|
|
22
|
-
return null;
|
|
23
18
|
}
|
|
24
|
-
|
|
19
|
+
|
|
20
|
+
// Fall back to system-wide install (skip on Windows — system cloudflared
|
|
21
|
+
// spams AssignProcessToJobObject when spawned as a child process)
|
|
22
|
+
if (process.platform !== 'win32') {
|
|
23
|
+
try { execSync('which cloudflared', { stdio: 'ignore' }); return 'cloudflared'; } catch {}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return null;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export async function installCloudflared(): Promise<string> {
|
|
@@ -64,12 +66,13 @@ export function startTunnel(port: number): Promise<string> {
|
|
|
64
66
|
|
|
65
67
|
proc = spawn(bin, ['tunnel', '--url', `http://localhost:${port}`, '--no-autoupdate'], {
|
|
66
68
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
69
|
+
windowsHide: true,
|
|
67
70
|
});
|
|
68
71
|
|
|
72
|
+
let buf = '';
|
|
69
73
|
const onData = (d: Buffer) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const m = text.match(/https:\/\/[^\s]+\.trycloudflare\.com/);
|
|
74
|
+
buf += d.toString();
|
|
75
|
+
const m = buf.match(/https:\/\/[^\s]+\.trycloudflare\.com/);
|
|
73
76
|
if (m) { clearTimeout(timeout); resolve(m[0]); }
|
|
74
77
|
};
|
|
75
78
|
|