@vibelet/cli 1.0.25 → 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.
@@ -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.25"}var i=p();process.stdout.write(`${i}
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 (process.platform !== 'win32') {
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: npmFallbackCommand,
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 logFd = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.openSync)(logPath, 'a');
7831
- const child = (0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.spawn)(launchSpec.command, [
7832
- ...launchSpec.args,
7833
- 'tunnel',
7834
- '--protocol',
7835
- 'http2',
7836
- '--url',
7837
- `http://localhost:${port}`,
7838
- ], {
7839
- detached: true,
7840
- stdio: ['ignore', logFd, logFd],
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)(logFd); } catch { /* */ }
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
- fail(err.message);
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
- process.stdout.write('Vibelet daemon is already running.\n');
8121
- process.stdout.write('Reusing the current runtime so active sessions stay alive.\n');
8122
- process.stdout.write('Run `npx vibelet restart` to force a full restart.\n\n');
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@vibelet/cli",
3
- "version": "1.0.25",
4
- "description": "macOS CLI for installing and running the Vibelet daemon",
3
+ "version": "1.0.26",
4
+ "description": "Cross-platform CLI for installing and running the Vibelet daemon",
5
5
  "homepage": "https://vibelet.icu",
6
6
  "private": false,
7
7
  "files": [