@vibelet/cli 1.0.17 → 1.0.18

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.17"}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.18"}var i=p();process.stdout.write(`${i}
2
2
  `);
package/dist/vibelet.mjs CHANGED
@@ -6542,6 +6542,64 @@ function parseNamedArg(argv, name, errorHint, fail, env = process.env) {
6542
6542
  }
6543
6543
 
6544
6544
 
6545
+ /***/ }),
6546
+
6547
+ /***/ 2927:
6548
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
6549
+
6550
+ /* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
6551
+ /* harmony export */ B: () => (/* binding */ bootoutLaunchdService),
6552
+ /* harmony export */ N: () => (/* binding */ describeLaunchctlResult)
6553
+ /* harmony export */ });
6554
+ function launchctlResultText(result) {
6555
+ return [result?.stderr, result?.stdout]
6556
+ .filter((value) => typeof value === 'string' && value.trim().length > 0)
6557
+ .join('\n')
6558
+ .trim();
6559
+ }
6560
+
6561
+ function isMissingLaunchdServiceResult(result) {
6562
+ if (!result || result.status === 0) return false;
6563
+ const text = launchctlResultText(result).toLowerCase();
6564
+ return text.includes('could not find service')
6565
+ || text.includes('service could not be found')
6566
+ || text.includes('service not loaded')
6567
+ || text.includes('no such process')
6568
+ || text.includes('no such file or directory');
6569
+ }
6570
+
6571
+ function bootoutLaunchdService({
6572
+ launchctl,
6573
+ launchDomain,
6574
+ label,
6575
+ plistPath,
6576
+ }) {
6577
+ const attempts = [
6578
+ ['bootout', launchDomain, plistPath],
6579
+ ['bootout', `${launchDomain}/${label}`],
6580
+ ];
6581
+ let lastMissingResult = null;
6582
+
6583
+ for (const args of attempts) {
6584
+ const result = launchctl(args);
6585
+ if (result.status === 0) {
6586
+ return { ok: true, result };
6587
+ }
6588
+ if (isMissingLaunchdServiceResult(result)) {
6589
+ lastMissingResult = result;
6590
+ continue;
6591
+ }
6592
+ return { ok: false, result };
6593
+ }
6594
+
6595
+ return { ok: true, result: lastMissingResult };
6596
+ }
6597
+
6598
+ function describeLaunchctlResult(result) {
6599
+ return launchctlResultText(result);
6600
+ }
6601
+
6602
+
6545
6603
  /***/ }),
6546
6604
 
6547
6605
  /***/ 6067:
@@ -6596,6 +6654,36 @@ function doesHealthMatchRequestedConnectionConfig({
6596
6654
  }
6597
6655
 
6598
6656
 
6657
+ /***/ }),
6658
+
6659
+ /***/ 9917:
6660
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
6661
+
6662
+ /* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
6663
+ /* harmony export */ v: () => (/* binding */ stopDaemonWithHooks)
6664
+ /* harmony export */ });
6665
+ async function stopDaemonWithHooks({
6666
+ requestShutdown,
6667
+ backendStop,
6668
+ waitForDaemonExit,
6669
+ timeoutMs = 5_000,
6670
+ }) {
6671
+ const gracefullyStopped = await requestShutdown();
6672
+ backendStop();
6673
+
6674
+ const diedAfterBackendStop = await waitForDaemonExit(timeoutMs);
6675
+ if (diedAfterBackendStop) {
6676
+ return;
6677
+ }
6678
+
6679
+ if (gracefullyStopped) {
6680
+ throw new Error('Daemon exited briefly but started responding again before the service manager fully unloaded it.');
6681
+ }
6682
+
6683
+ throw new Error('Daemon did not stop in time.');
6684
+ }
6685
+
6686
+
6599
6687
  /***/ }),
6600
6688
 
6601
6689
  /***/ 6327:
@@ -6608,11 +6696,15 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
6608
6696
  /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(6760);
6609
6697
  /* harmony import */ var node_url__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(3136);
6610
6698
  /* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(1302);
6611
- /* harmony import */ var _vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(3428);
6612
- /* harmony import */ var _cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(1932);
6699
+ /* harmony import */ var _vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(3428);
6700
+ /* harmony import */ var _cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_11__ = __nccwpck_require__(1932);
6613
6701
  /* harmony import */ var _cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(3006);
6702
+ /* harmony import */ var _vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(2927);
6614
6703
  /* harmony import */ var _linux_systemd_mjs__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(5400);
6615
- /* harmony import */ var _vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(6067);
6704
+ /* harmony import */ var _vibelet_stop_logic_mjs__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(9917);
6705
+ /* harmony import */ var _vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_12__ = __nccwpck_require__(6067);
6706
+
6707
+
6616
6708
 
6617
6709
 
6618
6710
 
@@ -6932,6 +7024,15 @@ function createDarwinBackend() {
6932
7024
  return (0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)('launchctl', args, { encoding: 'utf8' });
6933
7025
  }
6934
7026
 
7027
+ function bootoutService() {
7028
+ return (0,_vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_8__/* .bootoutLaunchdService */ .B)({
7029
+ launchctl,
7030
+ launchDomain,
7031
+ label,
7032
+ plistPath,
7033
+ });
7034
+ }
7035
+
6935
7036
  function plistContents() {
6936
7037
  // Prefer a stable node path — fnm_multishells shims disappear when the
6937
7038
  // installing shell exits, leaving launchd unable to respawn the daemon.
@@ -7004,14 +7105,16 @@ ${envSection}
7004
7105
  (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync)(plistPath, nextContents, 'utf8');
7005
7106
  }
7006
7107
 
7007
- if (changed && serviceLoaded) {
7008
- launchctl(['bootout', `${launchDomain}/${label}`]);
7009
- }
7010
-
7011
7108
  if (changed || !serviceLoaded) {
7109
+ const bootoutResult = bootoutService();
7012
7110
  const result = launchctl(['bootstrap', launchDomain, plistPath]);
7013
7111
  if (result.status !== 0) {
7014
- fail('Failed to bootstrap vibelet launch agent.', result.stderr || result.stdout);
7112
+ fail(
7113
+ 'Failed to bootstrap vibelet launch agent.',
7114
+ [(0,_vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_8__/* .describeLaunchctlResult */ .N)(bootoutResult.result), (0,_vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_8__/* .describeLaunchctlResult */ .N)(result)]
7115
+ .filter(Boolean)
7116
+ .join('\n'),
7117
+ );
7015
7118
  }
7016
7119
  }
7017
7120
  },
@@ -7024,8 +7127,10 @@ ${envSection}
7024
7127
  },
7025
7128
 
7026
7129
  stop() {
7027
- if (!this.isServiceInstalled()) return;
7028
- launchctl(['bootout', `${launchDomain}/${label}`]);
7130
+ const bootoutResult = bootoutService();
7131
+ if (!bootoutResult.ok) {
7132
+ fail('Failed to unload vibelet launch agent.', (0,_vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_8__/* .describeLaunchctlResult */ .N)(bootoutResult.result));
7133
+ }
7029
7134
  // bootout returns before launchd actually finishes unloading. Poll
7030
7135
  // until the service is gone so a follow-up install() doesn't see a
7031
7136
  // stale registration, skip bootstrap, and leave the daemon down.
@@ -7350,12 +7455,14 @@ function isDaemonStartCommand(command) {
7350
7455
  }
7351
7456
 
7352
7457
  async function stopRunningDaemon(backend) {
7353
- const gracefullyStopped = await requestShutdown();
7354
- backend.stop();
7355
- if (gracefullyStopped) return;
7356
- const died = await waitForDaemonExit(5_000);
7357
- if (!died) {
7358
- fail('Daemon did not stop in time.');
7458
+ try {
7459
+ await (0,_vibelet_stop_logic_mjs__WEBPACK_IMPORTED_MODULE_9__/* .stopDaemonWithHooks */ .v)({
7460
+ requestShutdown,
7461
+ backendStop: () => backend.stop(),
7462
+ waitForDaemonExit,
7463
+ });
7464
+ } catch (error) {
7465
+ fail(error instanceof Error ? error.message : String(error));
7359
7466
  }
7360
7467
  }
7361
7468
 
@@ -7631,7 +7738,7 @@ function printHelp() {
7631
7738
  }
7632
7739
 
7633
7740
  function parseNamedArg(name, errorHint) {
7634
- return (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .parseNamedArg */ .nE)(process.argv, name, errorHint, fail);
7741
+ return (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .parseNamedArg */ .nE)(process.argv, name, errorHint, fail);
7635
7742
  }
7636
7743
 
7637
7744
  function parseRelayArg() {
@@ -7766,7 +7873,7 @@ function startTunnel() {
7766
7873
  const poll = setInterval(() => {
7767
7874
  try {
7768
7875
  const content = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync)(logPath, 'utf8');
7769
- const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_9__/* .extractQuickTunnelUrl */ .k)(content);
7876
+ const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_11__/* .extractQuickTunnelUrl */ .k)(content);
7770
7877
  if (tunnelUrl) {
7771
7878
  url = tunnelUrl;
7772
7879
  saveTunnelState(pid, url);
@@ -7788,7 +7895,7 @@ function startTunnel() {
7788
7895
  childExited = true;
7789
7896
  if (!url) {
7790
7897
  const content = readCloudflaredLog(logPath);
7791
- const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_9__/* .extractQuickTunnelUrl */ .k)(content);
7898
+ const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_11__/* .extractQuickTunnelUrl */ .k)(content);
7792
7899
  if (tunnelUrl) {
7793
7900
  url = tunnelUrl;
7794
7901
  saveTunnelState(pid, url);
@@ -7827,9 +7934,9 @@ async function main() {
7827
7934
  process.env.VIBE_PORT = String(portArg);
7828
7935
  }
7829
7936
 
7830
- (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .consumeFlag */ .PC)(process.argv, 'remote') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .consumeFlag */ .PC)(process.argv, 'tunnel') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .readNpmConfigFlag */ .AW)('remote') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .readNpmConfigFlag */ .AW)('tunnel');
7831
- const localFlag = (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .consumeFlag */ .PC)(process.argv, 'local') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .readNpmConfigFlag */ .AW)('local');
7832
- const forceFlag = (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .consumeFlag */ .PC)(process.argv, 'force') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_8__/* .readNpmConfigFlag */ .AW)('force');
7937
+ (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .consumeFlag */ .PC)(process.argv, 'remote') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .consumeFlag */ .PC)(process.argv, 'tunnel') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .readNpmConfigFlag */ .AW)('remote') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .readNpmConfigFlag */ .AW)('tunnel');
7938
+ const localFlag = (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .consumeFlag */ .PC)(process.argv, 'local') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .readNpmConfigFlag */ .AW)('local');
7939
+ const forceFlag = (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .consumeFlag */ .PC)(process.argv, 'force') || (0,_vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_10__/* .readNpmConfigFlag */ .AW)('force');
7833
7940
  const relayArg = parseRelayArg();
7834
7941
  const hostArg = parseNamedArg('host', '100.x.x.x');
7835
7942
  const fallbackHostsArg = parseNamedArg('fallback-hosts', '100.x.x.x,192.168.1.x');
@@ -7970,7 +8077,7 @@ async function main() {
7970
8077
 
7971
8078
  if (command === 'reset') {
7972
8079
  const healthyDaemon = await probeHealth(1_500);
7973
- const hasExplicitConfigOverrides = !(0,_vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_10__/* .doesHealthMatchRequestedConnectionConfig */ .n)({
8080
+ const hasExplicitConfigOverrides = !(0,_vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_12__/* .doesHealthMatchRequestedConnectionConfig */ .n)({
7974
8081
  health: healthyDaemon,
7975
8082
  relayUrl,
7976
8083
  canonicalHost: hostArg || '',
@@ -7996,14 +8103,14 @@ async function main() {
7996
8103
  }
7997
8104
 
7998
8105
  const healthyDaemon = await probeHealth(1_500);
7999
- const hasExplicitConfigOverrides = !(0,_vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_10__/* .doesHealthMatchRequestedConnectionConfig */ .n)({
8106
+ const hasExplicitConfigOverrides = !(0,_vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_12__/* .doesHealthMatchRequestedConnectionConfig */ .n)({
8000
8107
  health: healthyDaemon,
8001
8108
  relayUrl,
8002
8109
  canonicalHost: hostArg || '',
8003
8110
  fallbackHosts: fallbackHostsArg || '',
8004
8111
  localMode: localFlag,
8005
8112
  }) && (localFlag || Boolean(relayUrl) || Boolean(hostArg) || Boolean(fallbackHostsArg));
8006
- const existingHealth = (0,_vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_10__/* .shouldReuseHealthyDaemon */ .Z)({
8113
+ const existingHealth = (0,_vibelet_runtime_policy_mjs__WEBPACK_IMPORTED_MODULE_12__/* .shouldReuseHealthyDaemon */ .Z)({
8007
8114
  command,
8008
8115
  daemonHealthy: Boolean(healthyDaemon),
8009
8116
  hasExplicitConfigOverrides,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibelet/cli",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "macOS CLI for installing and running the Vibelet daemon",
5
5
  "homepage": "https://vibelet.icu",
6
6
  "files": [