vibelet 0.1.25 → 0.1.26
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/cloudflared-resolver.mjs +68 -0
- package/bin/vibelet.mjs +1 -19
- package/package.json +20 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { delimiter, join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
function getExecutableCandidates(name, pathExtValue = process.env.PATHEXT ?? '') {
|
|
6
|
+
if (process.platform !== 'win32') {
|
|
7
|
+
return [name];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const extensions = pathExtValue
|
|
11
|
+
.split(';')
|
|
12
|
+
.map((entry) => entry.trim())
|
|
13
|
+
.filter(Boolean)
|
|
14
|
+
.map((entry) => (entry.startsWith('.') ? entry : `.${entry}`))
|
|
15
|
+
.map((entry) => entry.toLowerCase());
|
|
16
|
+
|
|
17
|
+
return [name, ...extensions.map((entry) => `${name}${entry}`)];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function findExecutableInPath(name, {
|
|
21
|
+
pathValue = process.env.PATH ?? '',
|
|
22
|
+
pathExtValue = process.env.PATHEXT ?? '',
|
|
23
|
+
} = {}) {
|
|
24
|
+
if (!pathValue) return null;
|
|
25
|
+
|
|
26
|
+
for (const dir of pathValue.split(delimiter)) {
|
|
27
|
+
if (!dir) continue;
|
|
28
|
+
for (const candidate of getExecutableCandidates(name, pathExtValue)) {
|
|
29
|
+
const candidatePath = join(dir, candidate);
|
|
30
|
+
if (existsSync(candidatePath)) {
|
|
31
|
+
return candidatePath;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function resolveCloudflaredBin({
|
|
40
|
+
pathValue = process.env.PATH ?? '',
|
|
41
|
+
pathExtValue = process.env.PATHEXT ?? '',
|
|
42
|
+
spawnSyncImpl = spawnSync,
|
|
43
|
+
} = {}) {
|
|
44
|
+
const directPath = findExecutableInPath('cloudflared', { pathValue, pathExtValue });
|
|
45
|
+
if (directPath) {
|
|
46
|
+
return directPath;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const result = spawnSyncImpl('npx', [
|
|
50
|
+
'--yes',
|
|
51
|
+
'--package=cloudflared',
|
|
52
|
+
'node',
|
|
53
|
+
'-e',
|
|
54
|
+
"console.log(process.env.PATH ?? '')",
|
|
55
|
+
], {
|
|
56
|
+
encoding: 'utf8',
|
|
57
|
+
timeout: 30_000,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (result.status !== 0 || !result.stdout.trim()) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return findExecutableInPath('cloudflared', {
|
|
65
|
+
pathValue: result.stdout.trim(),
|
|
66
|
+
pathExtValue,
|
|
67
|
+
});
|
|
68
|
+
}
|
package/bin/vibelet.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { homedir } from 'node:os';
|
|
|
6
6
|
import { dirname, join, resolve } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import QRCode from 'qrcode';
|
|
9
|
+
import { resolveCloudflaredBin } from './cloudflared-resolver.mjs';
|
|
9
10
|
import { shouldReuseHealthyDaemon } from './vibelet-runtime-policy.mjs';
|
|
10
11
|
|
|
11
12
|
// ─── Paths & constants ─────────────────────────────────────────────────────────
|
|
@@ -711,25 +712,6 @@ function getAliveTunnel() {
|
|
|
711
712
|
return null;
|
|
712
713
|
}
|
|
713
714
|
|
|
714
|
-
function resolveCloudflaredBin() {
|
|
715
|
-
// 1. Check if cloudflared is in PATH
|
|
716
|
-
const which = spawnSync('which', ['cloudflared'], { encoding: 'utf8' });
|
|
717
|
-
if (which.status === 0 && which.stdout.trim()) {
|
|
718
|
-
return which.stdout.trim();
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
// 2. Ensure npx has it installed (this downloads if needed, but is fast if cached)
|
|
722
|
-
const result = spawnSync('npx', ['--yes', '--package=cloudflared', 'node', '-e',
|
|
723
|
-
"console.log(require('path').join(require('path').dirname(require.resolve('cloudflared')), 'bin', 'cloudflared'))"],
|
|
724
|
-
{ encoding: 'utf8', timeout: 30_000 });
|
|
725
|
-
if (result.status === 0 && result.stdout.trim()) {
|
|
726
|
-
const binPath = result.stdout.trim();
|
|
727
|
-
if (existsSync(binPath)) return binPath;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
return null;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
715
|
function startTunnel() {
|
|
734
716
|
return new Promise((resolve, reject) => {
|
|
735
717
|
const logPath = join(logDir, 'tunnel.stderr.log');
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibelet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "macOS CLI for installing and running the Vibelet daemon",
|
|
5
5
|
"homepage": "https://vibelet.icu",
|
|
6
|
+
"private": false,
|
|
6
7
|
"files": [
|
|
8
|
+
"bin/cloudflared-resolver.mjs",
|
|
7
9
|
"bin/vibelet.mjs",
|
|
8
10
|
"bin/vibelet-runtime-policy.mjs",
|
|
9
11
|
"dist/index.cjs",
|
|
@@ -24,7 +26,24 @@
|
|
|
24
26
|
"publishConfig": {
|
|
25
27
|
"access": "public"
|
|
26
28
|
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "NX_TUI=false nx run-many -t build",
|
|
31
|
+
"build:release": "pnpm -C apps/daemon build:release",
|
|
32
|
+
"build:publish": "pnpm build:release",
|
|
33
|
+
"dev": "nx run-many -t dev --parallel=10 --verbose",
|
|
34
|
+
"dev:app": "pnpm -C apps/app dev",
|
|
35
|
+
"dev:daemon": "pnpm -C apps/daemon dev",
|
|
36
|
+
"dev:site": "pnpm -C apps/site dev",
|
|
37
|
+
"build:site": "nx run site:build",
|
|
38
|
+
"test": "pnpm -C apps/app test && pnpm -C apps/daemon test && pnpm -C apps/site test && node --test bin/vibelet-cli.test.mjs scripts/publish-dual-npm.test.mjs",
|
|
39
|
+
"prepack": "pnpm build:publish",
|
|
40
|
+
"publish:dual": "node ./scripts/publish-dual-npm.mjs",
|
|
41
|
+
"publish:dual:dry-run": "node ./scripts/publish-dual-npm.mjs --dry-run"
|
|
42
|
+
},
|
|
27
43
|
"dependencies": {
|
|
28
44
|
"qrcode": "^1.5.4"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"nx": "^22.1.3"
|
|
29
48
|
}
|
|
30
49
|
}
|