vibelet 1.0.12 → 1.0.13
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/dist/index.cjs +43 -43
- package/dist/runtime-version.cjs +2 -0
- package/dist/vibelet.mjs +8090 -0
- package/package.json +4 -11
- package/bin/cloudflared-quick-tunnel.mjs +0 -11
- package/bin/cloudflared-resolver.mjs +0 -171
- package/bin/vibelet-runtime-policy.mjs +0 -36
- package/bin/vibelet.cjs +0 -12
- package/bin/vibelet.mjs +0 -1414
package/package.json
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibelet",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "macOS CLI for installing and running the Vibelet daemon",
|
|
5
5
|
"homepage": "https://vibelet.icu",
|
|
6
6
|
"files": [
|
|
7
|
-
"
|
|
8
|
-
"bin/cloudflared-resolver.mjs",
|
|
9
|
-
"bin/cloudflared-quick-tunnel.mjs",
|
|
10
|
-
"bin/vibelet.mjs",
|
|
11
|
-
"bin/vibelet-runtime-policy.mjs",
|
|
7
|
+
"dist/vibelet.mjs",
|
|
12
8
|
"dist/index.cjs",
|
|
9
|
+
"dist/runtime-version.cjs",
|
|
13
10
|
"README.md",
|
|
14
11
|
"package.json"
|
|
15
12
|
],
|
|
16
13
|
"bin": {
|
|
17
|
-
"vibelet": "
|
|
14
|
+
"vibelet": "dist/vibelet.mjs"
|
|
18
15
|
},
|
|
19
16
|
"os": [
|
|
20
17
|
"darwin",
|
|
@@ -26,9 +23,5 @@
|
|
|
26
23
|
},
|
|
27
24
|
"publishConfig": {
|
|
28
25
|
"access": "public"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"cloudflared": "0.7.1",
|
|
32
|
-
"qrcode": "^1.5.4"
|
|
33
26
|
}
|
|
34
27
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const QUICK_TUNNEL_URL_PATTERN = /https:\/\/[a-z0-9-]+\.trycloudflare\.com(?=$|[\s"',)\]])/g;
|
|
2
|
-
|
|
3
|
-
export function extractQuickTunnelUrl(logContent) {
|
|
4
|
-
if (typeof logContent !== 'string' || logContent.length === 0) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const match = QUICK_TUNNEL_URL_PATTERN.exec(logContent);
|
|
9
|
-
QUICK_TUNNEL_URL_PATTERN.lastIndex = 0;
|
|
10
|
-
return match?.[0] ?? null;
|
|
11
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
-
import { delimiter, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
|
-
|
|
5
|
-
const npmFallbackCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
6
|
-
const npmFallbackArgs = ['--yes', '--package=cloudflared', 'cloudflared'];
|
|
7
|
-
const npmFallbackDescription = `npx ${npmFallbackArgs.join(' ')}`;
|
|
8
|
-
const require = createRequire(import.meta.url);
|
|
9
|
-
|
|
10
|
-
function defaultResolveCloudflaredPackageJsonPath() {
|
|
11
|
-
if (process.env.VIBELET_CLOUDFLARED_PACKAGE_JSON) {
|
|
12
|
-
return process.env.VIBELET_CLOUDFLARED_PACKAGE_JSON;
|
|
13
|
-
}
|
|
14
|
-
return require.resolve('cloudflared/package.json');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getExecutableCandidates(name, pathExtValue = process.env.PATHEXT ?? '') {
|
|
18
|
-
if (process.platform !== 'win32') {
|
|
19
|
-
return [name];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const extensions = pathExtValue
|
|
23
|
-
.split(';')
|
|
24
|
-
.map((entry) => entry.trim())
|
|
25
|
-
.filter(Boolean)
|
|
26
|
-
.map((entry) => (entry.startsWith('.') ? entry : `.${entry}`))
|
|
27
|
-
.map((entry) => entry.toLowerCase());
|
|
28
|
-
|
|
29
|
-
return [name, ...extensions.map((entry) => `${name}${entry}`)];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function findExecutableInPath(name, {
|
|
33
|
-
pathValue = process.env.PATH ?? '',
|
|
34
|
-
pathExtValue = process.env.PATHEXT ?? '',
|
|
35
|
-
} = {}) {
|
|
36
|
-
if (!pathValue) return null;
|
|
37
|
-
|
|
38
|
-
for (const dir of pathValue.split(delimiter)) {
|
|
39
|
-
if (!dir) continue;
|
|
40
|
-
for (const candidate of getExecutableCandidates(name, pathExtValue)) {
|
|
41
|
-
const candidatePath = join(dir, candidate);
|
|
42
|
-
if (existsSync(candidatePath)) {
|
|
43
|
-
return candidatePath;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function resolveInstalledCloudflaredCliPath({
|
|
52
|
-
resolvePackageJsonPath = defaultResolveCloudflaredPackageJsonPath,
|
|
53
|
-
} = {}) {
|
|
54
|
-
let packageJsonPath;
|
|
55
|
-
try {
|
|
56
|
-
packageJsonPath = resolvePackageJsonPath();
|
|
57
|
-
} catch {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let packageJson;
|
|
62
|
-
try {
|
|
63
|
-
packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
64
|
-
} catch {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const relativeBinPath = typeof packageJson.bin === 'string'
|
|
69
|
-
? packageJson.bin
|
|
70
|
-
: packageJson.bin?.cloudflared;
|
|
71
|
-
|
|
72
|
-
if (typeof relativeBinPath !== 'string' || !relativeBinPath) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const cliPath = isAbsolute(relativeBinPath)
|
|
77
|
-
? relativeBinPath
|
|
78
|
-
: resolve(dirname(packageJsonPath), relativeBinPath);
|
|
79
|
-
|
|
80
|
-
return existsSync(cliPath) ? cliPath : null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function resolveCloudflaredLaunchSpec({
|
|
84
|
-
pathValue = process.env.PATH ?? '',
|
|
85
|
-
pathExtValue = process.env.PATHEXT ?? '',
|
|
86
|
-
resolvePackageJsonPath,
|
|
87
|
-
} = {}) {
|
|
88
|
-
const directPath = findExecutableInPath('cloudflared', { pathValue, pathExtValue });
|
|
89
|
-
if (directPath) {
|
|
90
|
-
return {
|
|
91
|
-
command: directPath,
|
|
92
|
-
args: [],
|
|
93
|
-
source: 'path',
|
|
94
|
-
description: directPath,
|
|
95
|
-
urlTimeoutMs: 30_000,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const dependencyCliPath = resolveInstalledCloudflaredCliPath({ resolvePackageJsonPath });
|
|
100
|
-
if (dependencyCliPath) {
|
|
101
|
-
return {
|
|
102
|
-
command: process.execPath,
|
|
103
|
-
args: [dependencyCliPath],
|
|
104
|
-
source: 'dependency',
|
|
105
|
-
description: dependencyCliPath,
|
|
106
|
-
urlTimeoutMs: 90_000,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
command: npmFallbackCommand,
|
|
112
|
-
args: [...npmFallbackArgs],
|
|
113
|
-
source: 'npm',
|
|
114
|
-
description: npmFallbackDescription,
|
|
115
|
-
urlTimeoutMs: 90_000,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function summarizeCloudflaredLog(logContent, {
|
|
120
|
-
maxLines = 8,
|
|
121
|
-
maxChars = 1200,
|
|
122
|
-
} = {}) {
|
|
123
|
-
const lines = logContent
|
|
124
|
-
.split(/\r?\n/u)
|
|
125
|
-
.map((line) => line.trimEnd())
|
|
126
|
-
.filter(Boolean);
|
|
127
|
-
|
|
128
|
-
if (lines.length === 0) {
|
|
129
|
-
return '';
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const tail = lines.slice(-maxLines).join('\n');
|
|
133
|
-
if (tail.length <= maxChars) {
|
|
134
|
-
return tail;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return tail.slice(tail.length - maxChars);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function formatCloudflaredFailureMessage({
|
|
141
|
-
launchSpec,
|
|
142
|
-
logContent = '',
|
|
143
|
-
logPath,
|
|
144
|
-
err = null,
|
|
145
|
-
phase = 'exit',
|
|
146
|
-
}) {
|
|
147
|
-
const launchSuffix = launchSpec?.source === 'npm'
|
|
148
|
-
? ' via npm fallback (npx --yes --package=cloudflared cloudflared)'
|
|
149
|
-
: launchSpec?.source === 'dependency'
|
|
150
|
-
? ' via bundled cloudflared dependency'
|
|
151
|
-
: '';
|
|
152
|
-
|
|
153
|
-
if (phase === 'spawn') {
|
|
154
|
-
return `Failed to start cloudflared${launchSuffix}: ${err?.message ?? 'unknown error'}`;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (phase === 'timeout') {
|
|
158
|
-
const summary = summarizeCloudflaredLog(logContent);
|
|
159
|
-
if (summary) {
|
|
160
|
-
return `Timed out waiting for tunnel URL (${Math.round((launchSpec?.urlTimeoutMs ?? 30_000) / 1000)}s)${launchSuffix}.\nRecent stderr:\n${summary}`;
|
|
161
|
-
}
|
|
162
|
-
return `Timed out waiting for tunnel URL (${Math.round((launchSpec?.urlTimeoutMs ?? 30_000) / 1000)}s)${launchSuffix}. Check network/proxy settings and ${logPath}.`;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const summary = summarizeCloudflaredLog(logContent);
|
|
166
|
-
if (summary) {
|
|
167
|
-
return `cloudflared exited before producing a tunnel URL${launchSuffix}.\nRecent stderr:\n${summary}`;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return `cloudflared exited before producing a tunnel URL${launchSuffix}. Check ${logPath}.`;
|
|
171
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export function shouldReuseHealthyDaemon({
|
|
2
|
-
command,
|
|
3
|
-
daemonHealthy,
|
|
4
|
-
hasExplicitConfigOverrides,
|
|
5
|
-
}) {
|
|
6
|
-
if (!daemonHealthy) return false;
|
|
7
|
-
if (command !== 'default' && command !== 'start') return false;
|
|
8
|
-
return !hasExplicitConfigOverrides;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function doesHealthMatchRequestedConnectionConfig({
|
|
12
|
-
health,
|
|
13
|
-
relayUrl = '',
|
|
14
|
-
canonicalHost = '',
|
|
15
|
-
fallbackHosts = '',
|
|
16
|
-
localMode = false,
|
|
17
|
-
}) {
|
|
18
|
-
if (!health) return false;
|
|
19
|
-
|
|
20
|
-
const currentRelayUrl = typeof health.relayUrl === 'string' ? health.relayUrl : '';
|
|
21
|
-
if (relayUrl) {
|
|
22
|
-
return currentRelayUrl === relayUrl;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (localMode) {
|
|
26
|
-
return currentRelayUrl === '';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (canonicalHost) {
|
|
30
|
-
if (fallbackHosts) return false;
|
|
31
|
-
return currentRelayUrl === '' && health.canonicalHost === canonicalHost;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (fallbackHosts) return false;
|
|
35
|
-
return currentRelayUrl === '';
|
|
36
|
-
}
|
package/bin/vibelet.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { realpathSync } = require('node:fs');
|
|
4
|
-
const { dirname, join } = require('node:path');
|
|
5
|
-
const { pathToFileURL } = require('node:url');
|
|
6
|
-
|
|
7
|
-
const entryPath = join(dirname(realpathSync(__filename)), 'vibelet.mjs');
|
|
8
|
-
|
|
9
|
-
import(pathToFileURL(entryPath).href).catch((error) => {
|
|
10
|
-
console.error(error);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
});
|