@vibelet/cli 1.0.13 → 1.0.14

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.13"}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.14"}var i=p();process.stdout.write(`${i}
2
2
  `);
package/dist/vibelet.mjs CHANGED
@@ -6255,7 +6255,7 @@ __nccwpck_require__.d(__webpack_exports__, {
6255
6255
  Wo: () => (/* binding */ resolveCloudflaredLaunchSpec)
6256
6256
  });
6257
6257
 
6258
- // UNUSED EXPORTS: findExecutableInPath, resolveInstalledCloudflaredCliPath, summarizeCloudflaredLog
6258
+ // UNUSED EXPORTS: findExecutableInPath, findExecutablesInPath, resolveInstalledCloudflaredCliPath, summarizeCloudflaredLog
6259
6259
 
6260
6260
  ;// CONCATENATED MODULE: external "node:module"
6261
6261
  const external_node_module_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:module");
@@ -6271,6 +6271,7 @@ var external_node_path_ = __nccwpck_require__(6760);
6271
6271
  const npmFallbackCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
6272
6272
  const npmFallbackArgs = ['--yes', '--package=cloudflared', 'cloudflared'];
6273
6273
  const npmFallbackDescription = `npx ${npmFallbackArgs.join(' ')}`;
6274
+ const defaultUrlTimeoutMs = 90_000;
6274
6275
  const cloudflared_resolver_require = (0,external_node_module_namespaceObject.createRequire)(import.meta.url);
6275
6276
 
6276
6277
  function defaultResolveCloudflaredPackageJsonPath() {
@@ -6295,23 +6296,35 @@ function getExecutableCandidates(name, pathExtValue = process.env.PATHEXT ?? '')
6295
6296
  return [name, ...extensions.map((entry) => `${name}${entry}`)];
6296
6297
  }
6297
6298
 
6298
- function findExecutableInPath(name, {
6299
+ function findExecutablesInPath(name, {
6299
6300
  pathValue = process.env.PATH ?? '',
6300
6301
  pathExtValue = process.env.PATHEXT ?? '',
6301
6302
  } = {}) {
6302
- if (!pathValue) return null;
6303
+ if (!pathValue) return [];
6304
+
6305
+ const results = [];
6303
6306
 
6304
6307
  for (const dir of pathValue.split(external_node_path_.delimiter)) {
6305
6308
  if (!dir) continue;
6306
6309
  for (const candidate of getExecutableCandidates(name, pathExtValue)) {
6307
6310
  const candidatePath = (0,external_node_path_.join)(dir, candidate);
6308
6311
  if ((0,external_node_fs_.existsSync)(candidatePath)) {
6309
- return candidatePath;
6312
+ results.push(candidatePath);
6313
+ break;
6310
6314
  }
6311
6315
  }
6312
6316
  }
6313
6317
 
6314
- return null;
6318
+ return results;
6319
+ }
6320
+
6321
+ function findExecutableInPath(name, options = {}) {
6322
+ return findExecutablesInPath(name, options)[0] ?? null;
6323
+ }
6324
+
6325
+ function isNodeModulesBinPath(candidatePath) {
6326
+ return typeof candidatePath === 'string'
6327
+ && /(?:^|[\\/])node_modules[\\/]\.bin(?:[\\/]|$)/u.test(candidatePath);
6315
6328
  }
6316
6329
 
6317
6330
  function resolveInstalledCloudflaredCliPath({
@@ -6351,14 +6364,17 @@ function resolveCloudflaredLaunchSpec({
6351
6364
  pathExtValue = process.env.PATHEXT ?? '',
6352
6365
  resolvePackageJsonPath,
6353
6366
  } = {}) {
6354
- const directPath = findExecutableInPath('cloudflared', { pathValue, pathExtValue });
6367
+ const directPathCandidates = findExecutablesInPath('cloudflared', { pathValue, pathExtValue });
6368
+ const directPath = directPathCandidates.find((candidatePath) => !isNodeModulesBinPath(candidatePath))
6369
+ ?? directPathCandidates[0]
6370
+ ?? null;
6355
6371
  if (directPath) {
6356
6372
  return {
6357
6373
  command: directPath,
6358
6374
  args: [],
6359
6375
  source: 'path',
6360
6376
  description: directPath,
6361
- urlTimeoutMs: 30_000,
6377
+ urlTimeoutMs: defaultUrlTimeoutMs,
6362
6378
  };
6363
6379
  }
6364
6380
 
@@ -6369,7 +6385,7 @@ function resolveCloudflaredLaunchSpec({
6369
6385
  args: [dependencyCliPath],
6370
6386
  source: 'dependency',
6371
6387
  description: dependencyCliPath,
6372
- urlTimeoutMs: 90_000,
6388
+ urlTimeoutMs: defaultUrlTimeoutMs,
6373
6389
  };
6374
6390
  }
6375
6391
 
@@ -6378,7 +6394,7 @@ function resolveCloudflaredLaunchSpec({
6378
6394
  args: [...npmFallbackArgs],
6379
6395
  source: 'npm',
6380
6396
  description: npmFallbackDescription,
6381
- urlTimeoutMs: 90_000,
6397
+ urlTimeoutMs: defaultUrlTimeoutMs,
6382
6398
  };
6383
6399
  }
6384
6400
 
@@ -7674,14 +7690,27 @@ function startTunnel() {
7674
7690
  stdio: ['ignore', logFd, logFd],
7675
7691
  });
7676
7692
  child.unref();
7693
+ try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(logFd); } catch { /* */ }
7677
7694
 
7678
7695
  const pid = child.pid;
7679
7696
  let url = null;
7697
+ let settled = false;
7698
+ let childExited = false;
7699
+
7700
+ function settle(callback, value) {
7701
+ if (settled) {
7702
+ return;
7703
+ }
7704
+ settled = true;
7705
+ clearInterval(poll);
7706
+ clearTimeout(timeout);
7707
+ callback(value);
7708
+ }
7680
7709
 
7681
7710
  const timeout = setTimeout(() => {
7682
7711
  if (!url) {
7683
7712
  try { process.kill(pid, 'SIGTERM'); } catch { /* */ }
7684
- reject(new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
7713
+ settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
7685
7714
  launchSpec,
7686
7715
  logContent: readCloudflaredLog(logPath),
7687
7716
  logPath,
@@ -7697,17 +7726,12 @@ function startTunnel() {
7697
7726
  const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_8__/* .extractQuickTunnelUrl */ .k)(content);
7698
7727
  if (tunnelUrl) {
7699
7728
  url = tunnelUrl;
7700
- clearInterval(poll);
7701
- clearTimeout(timeout);
7702
7729
  saveTunnelState(pid, url);
7703
- resolve({ pid, url });
7730
+ settle(resolve, { pid, url });
7704
7731
  return;
7705
7732
  }
7706
- // Check if process died before producing URL
7707
- if (!isProcessAlive(pid)) {
7708
- clearInterval(poll);
7709
- clearTimeout(timeout);
7710
- reject(new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
7733
+ if (childExited) {
7734
+ settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
7711
7735
  launchSpec,
7712
7736
  logContent: content,
7713
7737
  logPath,
@@ -7717,10 +7741,28 @@ function startTunnel() {
7717
7741
  } catch { /* file not ready yet */ }
7718
7742
  }, 300);
7719
7743
 
7744
+ child.once('exit', () => {
7745
+ childExited = true;
7746
+ if (!url) {
7747
+ const content = readCloudflaredLog(logPath);
7748
+ const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_8__/* .extractQuickTunnelUrl */ .k)(content);
7749
+ if (tunnelUrl) {
7750
+ url = tunnelUrl;
7751
+ saveTunnelState(pid, url);
7752
+ settle(resolve, { pid, url });
7753
+ return;
7754
+ }
7755
+ settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
7756
+ launchSpec,
7757
+ logContent: content,
7758
+ logPath,
7759
+ phase: 'exit',
7760
+ })));
7761
+ }
7762
+ });
7763
+
7720
7764
  child.on('error', (err) => {
7721
- clearInterval(poll);
7722
- clearTimeout(timeout);
7723
- reject(new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
7765
+ settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
7724
7766
  launchSpec,
7725
7767
  logContent: readCloudflaredLog(logPath),
7726
7768
  logPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibelet/cli",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "macOS CLI for installing and running the Vibelet daemon",
5
5
  "homepage": "https://vibelet.icu",
6
6
  "files": [