fluxy-bot 0.1.30 → 0.1.32
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 +11 -28
- package/package.json +1 -1
- package/supervisor/tunnel.ts +10 -12
package/bin/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { spawn,
|
|
3
|
+
import { spawn, execSync } from 'child_process';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import os from 'os';
|
|
@@ -8,21 +8,6 @@ import { fileURLToPath } from 'url';
|
|
|
8
8
|
|
|
9
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
|
|
11
|
-
// Delegate to ~/.fluxy/app/ if we're not already running from there
|
|
12
|
-
const FLUXY_APP_DIR = path.join(os.homedir(), '.fluxy', 'app');
|
|
13
|
-
const FLUXY_APP_CLI = path.join(FLUXY_APP_DIR, 'bin', 'cli.js');
|
|
14
|
-
if (
|
|
15
|
-
fs.existsSync(FLUXY_APP_CLI) &&
|
|
16
|
-
path.resolve(__dirname) !== path.resolve(path.join(FLUXY_APP_DIR, 'bin'))
|
|
17
|
-
) {
|
|
18
|
-
const { status } = spawnSync(
|
|
19
|
-
process.execPath,
|
|
20
|
-
[FLUXY_APP_CLI, ...process.argv.slice(2)],
|
|
21
|
-
{ stdio: 'inherit' },
|
|
22
|
-
);
|
|
23
|
-
process.exit(status ?? 0);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
11
|
const ROOT = path.resolve(__dirname, '..');
|
|
27
12
|
const DATA_DIR = path.join(os.homedir(), '.fluxy');
|
|
28
13
|
const CONFIG_PATH = path.join(DATA_DIR, 'config.json');
|
|
@@ -159,21 +144,19 @@ function createConfig() {
|
|
|
159
144
|
const MIN_CF_SIZE = 10 * 1024 * 1024; // 10 MB — valid cloudflared is ~30-50 MB
|
|
160
145
|
|
|
161
146
|
function hasCloudflared() {
|
|
162
|
-
// Check
|
|
147
|
+
// Check system-wide install
|
|
148
|
+
const which = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
|
|
149
|
+
try { execSync(which, { stdio: 'ignore' }); return true; } catch {}
|
|
150
|
+
|
|
151
|
+
// Check local install (validate by file size, never execute — avoids Windows popup)
|
|
163
152
|
const cfExe = process.platform === 'win32' ? CF_PATH + '.exe' : CF_PATH;
|
|
164
|
-
if (fs.existsSync(cfExe))
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
if (!fs.existsSync(cfExe)) return false;
|
|
154
|
+
const size = fs.statSync(cfExe).size;
|
|
155
|
+
if (size < MIN_CF_SIZE) {
|
|
167
156
|
fs.unlinkSync(cfExe);
|
|
157
|
+
return false;
|
|
168
158
|
}
|
|
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;
|
|
159
|
+
return true;
|
|
177
160
|
}
|
|
178
161
|
|
|
179
162
|
async function installCloudflared() {
|
package/package.json
CHANGED
package/supervisor/tunnel.ts
CHANGED
|
@@ -10,20 +10,18 @@ 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
|
-
|
|
13
|
+
// Check system-wide install
|
|
14
|
+
const which = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
|
|
15
|
+
try { execSync(which, { stdio: 'ignore' }); return 'cloudflared'; } catch {}
|
|
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) {
|
|
17
21
|
fs.unlinkSync(paths.cloudflared);
|
|
22
|
+
return null;
|
|
18
23
|
}
|
|
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;
|
|
24
|
+
return paths.cloudflared;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export async function installCloudflared(): Promise<string> {
|