@vibelet/cli 1.0.24 → 1.0.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/README.md +1 -1
- package/dist/index.cjs +60 -58
- package/dist/runtime-version.cjs +1 -1
- package/dist/vibelet.mjs +81 -24
- package/package.json +25 -2
package/dist/runtime-version.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s=require("node:fs"),n=require("node:path"),c="@vibelet/cli";function a(e){try{let r=JSON.parse((0,s.readFileSync)(e,"utf8"));if(r.name===c&&typeof r.version=="string"&&r.version.length>0)return r.version}catch{}return null}function p(){return"1.0.
|
|
1
|
+
var s=require("node:fs"),n=require("node:path"),c="@vibelet/cli";function a(e){try{let r=JSON.parse((0,s.readFileSync)(e,"utf8"));if(r.name===c&&typeof r.version=="string"&&r.version.length>0)return r.version}catch{}return null}function p(){return"1.0.26"}var i=p();process.stdout.write(`${i}
|
|
2
2
|
`);
|
package/dist/vibelet.mjs
CHANGED
|
@@ -6268,12 +6268,15 @@ var external_node_path_ = __nccwpck_require__(6760);
|
|
|
6268
6268
|
|
|
6269
6269
|
|
|
6270
6270
|
|
|
6271
|
-
const npmFallbackCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
6272
6271
|
const npmFallbackArgs = ['--yes', '--package=cloudflared', 'cloudflared'];
|
|
6273
6272
|
const npmFallbackDescription = `npx ${npmFallbackArgs.join(' ')}`;
|
|
6274
6273
|
const defaultUrlTimeoutMs = 90_000;
|
|
6275
6274
|
const cloudflared_resolver_require = (0,external_node_module_namespaceObject.createRequire)(import.meta.url);
|
|
6276
6275
|
|
|
6276
|
+
function getNpmFallbackCommand(platform = process.platform) {
|
|
6277
|
+
return platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
6278
|
+
}
|
|
6279
|
+
|
|
6277
6280
|
function defaultResolveCloudflaredPackageJsonPath() {
|
|
6278
6281
|
if (process.env.VIBELET_CLOUDFLARED_PACKAGE_JSON) {
|
|
6279
6282
|
return process.env.VIBELET_CLOUDFLARED_PACKAGE_JSON;
|
|
@@ -6281,8 +6284,8 @@ function defaultResolveCloudflaredPackageJsonPath() {
|
|
|
6281
6284
|
return cloudflared_resolver_require.resolve('cloudflared/package.json');
|
|
6282
6285
|
}
|
|
6283
6286
|
|
|
6284
|
-
function getExecutableCandidates(name, pathExtValue = process.env.PATHEXT ?? '') {
|
|
6285
|
-
if (
|
|
6287
|
+
function getExecutableCandidates(name, pathExtValue = process.env.PATHEXT ?? '', platform = process.platform) {
|
|
6288
|
+
if (platform !== 'win32') {
|
|
6286
6289
|
return [name];
|
|
6287
6290
|
}
|
|
6288
6291
|
|
|
@@ -6299,6 +6302,7 @@ function getExecutableCandidates(name, pathExtValue = process.env.PATHEXT ?? '')
|
|
|
6299
6302
|
function findExecutablesInPath(name, {
|
|
6300
6303
|
pathValue = process.env.PATH ?? '',
|
|
6301
6304
|
pathExtValue = process.env.PATHEXT ?? '',
|
|
6305
|
+
platform = process.platform,
|
|
6302
6306
|
} = {}) {
|
|
6303
6307
|
if (!pathValue) return [];
|
|
6304
6308
|
|
|
@@ -6306,7 +6310,7 @@ function findExecutablesInPath(name, {
|
|
|
6306
6310
|
|
|
6307
6311
|
for (const dir of pathValue.split(external_node_path_.delimiter)) {
|
|
6308
6312
|
if (!dir) continue;
|
|
6309
|
-
for (const candidate of getExecutableCandidates(name, pathExtValue)) {
|
|
6313
|
+
for (const candidate of getExecutableCandidates(name, pathExtValue, platform)) {
|
|
6310
6314
|
const candidatePath = (0,external_node_path_.join)(dir, candidate);
|
|
6311
6315
|
if ((0,external_node_fs_.existsSync)(candidatePath)) {
|
|
6312
6316
|
results.push(candidatePath);
|
|
@@ -6327,6 +6331,10 @@ function isNodeModulesBinPath(candidatePath) {
|
|
|
6327
6331
|
&& /(?:^|[\\/])node_modules[\\/]\.bin(?:[\\/]|$)/u.test(candidatePath);
|
|
6328
6332
|
}
|
|
6329
6333
|
|
|
6334
|
+
function isWindowsCommandScript(candidatePath, platform = process.platform) {
|
|
6335
|
+
return platform === 'win32' && /\.(?:cmd|bat)$/iu.test(candidatePath);
|
|
6336
|
+
}
|
|
6337
|
+
|
|
6330
6338
|
function resolveInstalledCloudflaredCliPath({
|
|
6331
6339
|
resolvePackageJsonPath = defaultResolveCloudflaredPackageJsonPath,
|
|
6332
6340
|
} = {}) {
|
|
@@ -6362,9 +6370,10 @@ function resolveInstalledCloudflaredCliPath({
|
|
|
6362
6370
|
function resolveCloudflaredLaunchSpec({
|
|
6363
6371
|
pathValue = process.env.PATH ?? '',
|
|
6364
6372
|
pathExtValue = process.env.PATHEXT ?? '',
|
|
6373
|
+
platform = process.platform,
|
|
6365
6374
|
resolvePackageJsonPath,
|
|
6366
6375
|
} = {}) {
|
|
6367
|
-
const directPathCandidates = findExecutablesInPath('cloudflared', { pathValue, pathExtValue });
|
|
6376
|
+
const directPathCandidates = findExecutablesInPath('cloudflared', { pathValue, pathExtValue, platform });
|
|
6368
6377
|
const directPath = directPathCandidates.find((candidatePath) => !isNodeModulesBinPath(candidatePath))
|
|
6369
6378
|
?? directPathCandidates[0]
|
|
6370
6379
|
?? null;
|
|
@@ -6374,6 +6383,7 @@ function resolveCloudflaredLaunchSpec({
|
|
|
6374
6383
|
args: [],
|
|
6375
6384
|
source: 'path',
|
|
6376
6385
|
description: directPath,
|
|
6386
|
+
...(isWindowsCommandScript(directPath, platform) ? { shell: true } : {}),
|
|
6377
6387
|
urlTimeoutMs: defaultUrlTimeoutMs,
|
|
6378
6388
|
};
|
|
6379
6389
|
}
|
|
@@ -6390,10 +6400,11 @@ function resolveCloudflaredLaunchSpec({
|
|
|
6390
6400
|
}
|
|
6391
6401
|
|
|
6392
6402
|
return {
|
|
6393
|
-
command:
|
|
6403
|
+
command: getNpmFallbackCommand(platform),
|
|
6394
6404
|
args: [...npmFallbackArgs],
|
|
6395
6405
|
source: 'npm',
|
|
6396
6406
|
description: npmFallbackDescription,
|
|
6407
|
+
...(platform === 'win32' ? { shell: true } : {}),
|
|
6397
6408
|
urlTimeoutMs: defaultUrlTimeoutMs,
|
|
6398
6409
|
};
|
|
6399
6410
|
}
|
|
@@ -7827,20 +7838,38 @@ function startTunnel() {
|
|
|
7827
7838
|
// then tail the log to capture the URL.
|
|
7828
7839
|
// Truncate log so we don't match a stale URL from a previous run.
|
|
7829
7840
|
(0,node_fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync)(logPath, '', 'utf8');
|
|
7830
|
-
const
|
|
7831
|
-
const
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7841
|
+
const stdoutLogFd = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.openSync)(logPath, 'a');
|
|
7842
|
+
const stderrLogFd = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.openSync)(logPath, 'a');
|
|
7843
|
+
let child;
|
|
7844
|
+
try {
|
|
7845
|
+
child = (0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.spawn)(launchSpec.command, [
|
|
7846
|
+
...launchSpec.args,
|
|
7847
|
+
'tunnel',
|
|
7848
|
+
'--protocol',
|
|
7849
|
+
'http2',
|
|
7850
|
+
'--url',
|
|
7851
|
+
`http://localhost:${port}`,
|
|
7852
|
+
], {
|
|
7853
|
+
detached: true,
|
|
7854
|
+
stdio: ['ignore', stdoutLogFd, stderrLogFd],
|
|
7855
|
+
windowsHide: true,
|
|
7856
|
+
...(launchSpec.shell ? { shell: true } : {}),
|
|
7857
|
+
});
|
|
7858
|
+
} catch (err) {
|
|
7859
|
+
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stdoutLogFd); } catch { /* */ }
|
|
7860
|
+
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stderrLogFd); } catch { /* */ }
|
|
7861
|
+
reject(new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
|
|
7862
|
+
launchSpec,
|
|
7863
|
+
logContent: readCloudflaredLog(logPath),
|
|
7864
|
+
logPath,
|
|
7865
|
+
err,
|
|
7866
|
+
phase: 'spawn',
|
|
7867
|
+
})));
|
|
7868
|
+
return;
|
|
7869
|
+
}
|
|
7842
7870
|
child.unref();
|
|
7843
|
-
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(
|
|
7871
|
+
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stdoutLogFd); } catch { /* */ }
|
|
7872
|
+
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stderrLogFd); } catch { /* */ }
|
|
7844
7873
|
|
|
7845
7874
|
const pid = child.pid;
|
|
7846
7875
|
let url = null;
|
|
@@ -7940,6 +7969,7 @@ async function main() {
|
|
|
7940
7969
|
const relayArg = parseRelayArg();
|
|
7941
7970
|
const hostArg = parseNamedArg('host', '100.x.x.x');
|
|
7942
7971
|
const fallbackHostsArg = parseNamedArg('fallback-hosts', '100.x.x.x,192.168.1.x');
|
|
7972
|
+
let managedTunnelFailed = false;
|
|
7943
7973
|
const command = process.argv[2] ?? 'default';
|
|
7944
7974
|
const startCommand = isDaemonStartCommand(command);
|
|
7945
7975
|
// --remote/--tunnel remain accepted for compatibility, but startup commands
|
|
@@ -7973,7 +8003,12 @@ async function main() {
|
|
|
7973
8003
|
process.stdout.write(`Tunnel ready: ${tunnel.url}\n`);
|
|
7974
8004
|
saveRelayConfig(tunnel.url);
|
|
7975
8005
|
} catch (err) {
|
|
7976
|
-
|
|
8006
|
+
managedTunnelFailed = true;
|
|
8007
|
+
clearTunnelState();
|
|
8008
|
+
clearRelayConfig();
|
|
8009
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
8010
|
+
process.stderr.write(`${message}\n`);
|
|
8011
|
+
process.stderr.write('Continuing with LAN/local pairing. Use `npx vibelet --force` after fixing Cloudflare Tunnel, or pass `--relay=<url>` for a custom tunnel.\n');
|
|
7977
8012
|
}
|
|
7978
8013
|
}
|
|
7979
8014
|
}
|
|
@@ -7986,7 +8021,7 @@ async function main() {
|
|
|
7986
8021
|
clearRelayConfig();
|
|
7987
8022
|
}
|
|
7988
8023
|
}
|
|
7989
|
-
const shouldIgnoreSavedRelay = relayArg === null && (localFlag || Boolean(hostArg) || Boolean(fallbackHostsArg));
|
|
8024
|
+
const shouldIgnoreSavedRelay = relayArg === null && (localFlag || Boolean(hostArg) || Boolean(fallbackHostsArg) || managedTunnelFailed);
|
|
7990
8025
|
const relayUrl = relayArg !== null
|
|
7991
8026
|
? relayArg
|
|
7992
8027
|
: (shouldIgnoreSavedRelay ? '' : loadRelayConfig());
|
|
@@ -8117,9 +8152,31 @@ async function main() {
|
|
|
8117
8152
|
}) ? healthyDaemon : null;
|
|
8118
8153
|
|
|
8119
8154
|
if (existingHealth) {
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8155
|
+
const runningVersion = typeof existingHealth.version === 'string' ? existingHealth.version : '';
|
|
8156
|
+
const activeSessions = typeof existingHealth.activeSessions === 'number' ? existingHealth.activeSessions : 0;
|
|
8157
|
+
const isOutdated = runningVersion && compareVersions(runningVersion, packageJson.version) < 0;
|
|
8158
|
+
if (isOutdated && activeSessions === 0) {
|
|
8159
|
+
process.stdout.write(
|
|
8160
|
+
`Daemon is running v${runningVersion}, CLI is v${packageJson.version}. Restarting daemon to upgrade...\n`,
|
|
8161
|
+
);
|
|
8162
|
+
await stopRunningDaemon(backend);
|
|
8163
|
+
process.stdout.write('Daemon stopped. Starting...\n');
|
|
8164
|
+
ensureRuntimeInstalled();
|
|
8165
|
+
backend.install();
|
|
8166
|
+
backend.start();
|
|
8167
|
+
await printPairingSummary();
|
|
8168
|
+
return;
|
|
8169
|
+
}
|
|
8170
|
+
if (isOutdated) {
|
|
8171
|
+
process.stdout.write(
|
|
8172
|
+
`Daemon is running v${runningVersion}, CLI is v${packageJson.version}, but ${activeSessions} active session(s) would be interrupted.\n`,
|
|
8173
|
+
);
|
|
8174
|
+
process.stdout.write('Run `npx vibelet restart` once those sessions are idle to upgrade the daemon.\n');
|
|
8175
|
+
} else {
|
|
8176
|
+
process.stdout.write('Vibelet daemon is already running.\n');
|
|
8177
|
+
process.stdout.write('Reusing the current runtime so active sessions stay alive.\n');
|
|
8178
|
+
process.stdout.write('Run `npx vibelet restart` to force a full restart.\n\n');
|
|
8179
|
+
}
|
|
8123
8180
|
await printPairingSummary(existingHealth);
|
|
8124
8181
|
return;
|
|
8125
8182
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibelet/cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.26",
|
|
4
|
+
"description": "Cross-platform CLI for installing and running the Vibelet daemon",
|
|
5
5
|
"homepage": "https://vibelet.icu",
|
|
6
|
+
"private": false,
|
|
6
7
|
"files": [
|
|
7
8
|
"dist/vibelet.mjs",
|
|
8
9
|
"dist/index.cjs",
|
|
@@ -23,5 +24,27 @@
|
|
|
23
24
|
},
|
|
24
25
|
"publishConfig": {
|
|
25
26
|
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "NX_TUI=false nx run-many -t build",
|
|
30
|
+
"build:release": "pnpm build:release:daemon && pnpm build:release:cli",
|
|
31
|
+
"build:release:daemon": "pnpm -C apps/daemon build:release",
|
|
32
|
+
"build:release:cli": "node ./scripts/build-cli-release.mjs",
|
|
33
|
+
"build:publish": "pnpm build:release",
|
|
34
|
+
"dev": "nx run-many -t dev --parallel=10 --verbose",
|
|
35
|
+
"dev:app": "pnpm -C apps/app dev",
|
|
36
|
+
"dev:daemon": "pnpm -C apps/daemon dev",
|
|
37
|
+
"dev:site": "pnpm -C apps/site dev",
|
|
38
|
+
"build:site": "nx run site:build",
|
|
39
|
+
"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 scripts/ship-release.test.mjs",
|
|
40
|
+
"prepack": "pnpm build:publish",
|
|
41
|
+
"publish:dual": "node ./scripts/publish-dual-npm.mjs",
|
|
42
|
+
"publish:dual:dry-run": "node ./scripts/publish-dual-npm.mjs --dry-run"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@vercel/ncc": "^0.38.4",
|
|
46
|
+
"cloudflared": "0.7.1",
|
|
47
|
+
"nx": "^22.1.3",
|
|
48
|
+
"qrcode": "^1.5.4"
|
|
26
49
|
}
|
|
27
50
|
}
|