@dylanpiercey/work 0.0.159 → 0.0.160

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.
Files changed (74) hide show
  1. package/bin/work.mjs +57 -16
  2. package/dist/{_B8Ruz8T9.js → _BRBF-t9p.js} +9 -7
  3. package/dist/_Cr-5sjB_.js +2 -0
  4. package/dist/index.mjs +362 -362
  5. package/dist/public/assets/_BU6w6X4q.js +1 -0
  6. package/dist/public/assets/_BbqN_0Hf.js +1 -0
  7. package/dist/public/assets/_BfEhpnxc.js +1 -0
  8. package/dist/public/assets/_Bjs6hRWD.js +1 -0
  9. package/dist/public/assets/_BjtlvkCt.js +1 -0
  10. package/dist/public/assets/_BnZSGKpL.js +1 -0
  11. package/dist/public/assets/_BnepJiz-.js +1 -0
  12. package/dist/public/assets/{_DrrcCvtP.js → _BpIalLUl.js} +1 -1
  13. package/dist/public/assets/_BpIalLUl.js.br +0 -0
  14. package/dist/public/assets/_BvcYfwFl.js +1 -0
  15. package/dist/public/assets/_C0zwP2qH.js +1 -0
  16. package/dist/public/assets/_C9oWRx13.js +1 -0
  17. package/dist/public/assets/_CC3Ffsld.js +1 -0
  18. package/dist/public/assets/_ClG30-Cs.js +1 -0
  19. package/dist/public/assets/_CxFNOCPZ.js +1 -0
  20. package/dist/public/assets/{_DzlXAMSp.js → _D6gBuUWs.js} +4 -4
  21. package/dist/public/assets/_D6gBuUWs.js.br +0 -0
  22. package/dist/public/assets/_D9-BvOKl.js +1 -0
  23. package/dist/public/assets/_D_opOE0v.js +1 -0
  24. package/dist/public/assets/_DdJpsshP.js +1 -0
  25. package/dist/public/assets/_L9P-Lxf4.js +1 -0
  26. package/dist/public/assets/{_DgrVjbbj.js → __CI6owKB.js} +4 -4
  27. package/dist/public/assets/__CI6owKB.js.br +0 -0
  28. package/dist/public/assets/_dvB7DobJ.js +1 -0
  29. package/dist/public/assets/_o7CRZZeJ.js +1 -0
  30. package/dist/public/assets/{app-page-DkJHV2Hb.css → app-page-DyrVoVeZ.css} +1 -1
  31. package/dist/public/assets/app-page-DyrVoVeZ.css.br +0 -0
  32. package/dist/public/assets/diff-view-DH-5ACi2.js +2 -0
  33. package/dist/public/assets/{diff-view-D_kTcxOl.css → diff-view-DKJzuUb0.css} +1 -1
  34. package/dist/public/assets/diff-view-DKJzuUb0.css.br +0 -0
  35. package/dist/public/assets/{icon-arrow-down-ptjlirxL.css → icon-arrow-down-Bh8nsodJ.css} +1 -1
  36. package/dist/public/assets/icon-arrow-down-Bh8nsodJ.css.br +0 -0
  37. package/dist/public/assets/new-qqqf-1EI.js +1 -0
  38. package/dist/public/assets/settings-qqqf-1EI.js +1 -0
  39. package/dist/public/assets/w-qqqf-1EI.js +1 -0
  40. package/dist/public/assets/w._-Bmrox8Ci.js +1 -0
  41. package/dist/public/assets/w._-qqqf-1EI.js +1 -0
  42. package/package.json +1 -1
  43. package/dist/_wmfv4tOT.js +0 -2
  44. package/dist/public/assets/_BEMlWJ3i.js +0 -1
  45. package/dist/public/assets/_BF3jdOKL.js +0 -1
  46. package/dist/public/assets/_BN2MNMec.js +0 -1
  47. package/dist/public/assets/_BX85X6vL.js +0 -1
  48. package/dist/public/assets/_BgTyVBoz.js +0 -1
  49. package/dist/public/assets/_BtPnCFTI.js +0 -1
  50. package/dist/public/assets/_C62EU_76.js +0 -1
  51. package/dist/public/assets/_C9t1K6t0.js +0 -1
  52. package/dist/public/assets/_CV1AUMfT.js +0 -1
  53. package/dist/public/assets/_DONc62ot.js +0 -1
  54. package/dist/public/assets/_DQxAgIZ5.js +0 -1
  55. package/dist/public/assets/_DRrf0ps3.js +0 -1
  56. package/dist/public/assets/_DUwNzfo2.js +0 -1
  57. package/dist/public/assets/_DgrVjbbj.js.br +0 -0
  58. package/dist/public/assets/_DliuBq2F.js +0 -1
  59. package/dist/public/assets/_DrrcCvtP.js.br +0 -0
  60. package/dist/public/assets/_Dt9shJET.js +0 -1
  61. package/dist/public/assets/_DzlXAMSp.js.br +0 -0
  62. package/dist/public/assets/_KbIm5gXb.js +0 -1
  63. package/dist/public/assets/_kP4m5eyY.js +0 -1
  64. package/dist/public/assets/_kRAx7xJD.js +0 -1
  65. package/dist/public/assets/_wGg-Flxh.js +0 -1
  66. package/dist/public/assets/app-page-DkJHV2Hb.css.br +0 -0
  67. package/dist/public/assets/diff-view-B7Akkn43.js +0 -2
  68. package/dist/public/assets/diff-view-D_kTcxOl.css.br +0 -0
  69. package/dist/public/assets/icon-arrow-down-ptjlirxL.css.br +0 -0
  70. package/dist/public/assets/new-CjRAL7y8.js +0 -1
  71. package/dist/public/assets/settings-CjRAL7y8.js +0 -1
  72. package/dist/public/assets/w-CjRAL7y8.js +0 -1
  73. package/dist/public/assets/w._-CjRAL7y8.js +0 -1
  74. package/dist/public/assets/w._-DvPeuuNc.js +0 -1
package/bin/work.mjs CHANGED
@@ -80,9 +80,14 @@ switch (command) {
80
80
  // Service installation only — no doctor/fix, no migrate. Used by
81
81
  // scripts/setup-prod.sh so npm and source installs share one
82
82
  // definition; WORK_SERVICE_EXEC points it at a checkout's run-prod.sh.
83
- if (installService()) {
83
+ if (!installService()) {
84
+ process.exitCode = 1;
85
+ } else if (await waitForServer(serviceEnv().PORT)) {
84
86
  log(`done — http://localhost:${serviceEnv().PORT}`);
85
87
  } else {
88
+ warn(
89
+ `service started but nothing answered on port ${serviceEnv().PORT} within 30s — check the logs`,
90
+ );
86
91
  process.exitCode = 1;
87
92
  }
88
93
  break;
@@ -567,8 +572,13 @@ async function setup() {
567
572
  const running = installService();
568
573
  const port = serviceEnv().PORT;
569
574
  maybeTunnel(port);
570
- if (running) log(`done — http://localhost:${port}`);
571
- else {
575
+ if (running) {
576
+ if (await waitForServer(port)) log(`done — http://localhost:${port}`);
577
+ else
578
+ warn(
579
+ `service started but nothing answered on port ${port} within 30s — check the logs`,
580
+ );
581
+ } else {
572
582
  // A fresh install's shell may not have mise on PATH yet — name the shim.
573
583
  const shim = path.join(
574
584
  os.homedir(),
@@ -952,6 +962,26 @@ function stopOldCopies(port) {
952
962
  killPids(pidsListening(port), "SIGKILL");
953
963
  }
954
964
 
965
+ /** Wait for the service to answer before we tell anyone it is up. Both
966
+ * service managers return as soon as the job is spawned, so `done — http://…`
967
+ * used to print at a port that answers a second or two later — which reads as
968
+ * an update that broke the app. Any HTTP reply proves the server is serving;
969
+ * the status the route returns is not this function's business. */
970
+ async function waitForServer(port, timeoutMs = 30_000) {
971
+ const deadline = Date.now() + timeoutMs;
972
+ for (;;) {
973
+ try {
974
+ await fetch(`http://127.0.0.1:${port}/`, {
975
+ redirect: "manual",
976
+ signal: AbortSignal.timeout(2000),
977
+ });
978
+ return true;
979
+ } catch {}
980
+ if (Date.now() >= deadline) return false;
981
+ await new Promise((r) => setTimeout(r, 150));
982
+ }
983
+ }
984
+
955
985
  function installService() {
956
986
  const port = serviceEnv().PORT;
957
987
  stopOldCopies(port);
@@ -1001,26 +1031,37 @@ ${envXml}
1001
1031
  );
1002
1032
  log("installing launchd agent");
1003
1033
  const uid = process.getuid();
1004
- spawnSync("launchctl", ["bootout", `gui/${uid}/dev.work.app`], {
1034
+ const label = `gui/${uid}/dev.work.app`;
1035
+ spawnSync("launchctl", ["bootout", label], { stdio: "ignore" });
1036
+ // Exactly one spawn, whichever verb gets us there. launchd allows a job
1037
+ // one start per 10s: `kickstart -k` on top of the start `bootstrap`'s
1038
+ // RunAtLoad just did kills that process and serves nothing for the rest
1039
+ // of the throttle window — ten seconds of a dead port after `done`.
1040
+ let started = spawnSync("launchctl", ["bootstrap", `gui/${uid}`, plist], {
1005
1041
  stdio: "ignore",
1006
- });
1007
- const boot = spawnSync("launchctl", ["bootstrap", `gui/${uid}`, plist], {
1008
- stdio: "ignore",
1009
- });
1010
- if (
1011
- boot.status !== 0 &&
1012
- spawnSync("launchctl", ["load", "-w", plist], { stdio: "ignore" })
1013
- .status !== 0
1014
- ) {
1042
+ }).status === 0;
1043
+ if (!started) {
1044
+ // A launchd that only speaks the legacy verbs: `load -w` honours
1045
+ // RunAtLoad the same way.
1046
+ started =
1047
+ spawnSync("launchctl", ["load", "-w", plist], { stdio: "ignore" })
1048
+ .status === 0;
1049
+ }
1050
+ if (!started) {
1051
+ // Both refused because the job is loaded already (a bootout that did
1052
+ // not take). Nothing spawned it with the new definition, and it is old
1053
+ // enough not to be throttled, so restart it.
1054
+ started =
1055
+ spawnSync("launchctl", ["kickstart", "-k", label], { stdio: "ignore" })
1056
+ .status === 0;
1057
+ }
1058
+ if (!started) {
1015
1059
  warn(
1016
1060
  `could not load the agent (no GUI launchd session?). Run from a local terminal: launchctl bootstrap gui/$UID ${plist}`,
1017
1061
  );
1018
1062
  warn("or start manually: work start");
1019
1063
  return false;
1020
1064
  }
1021
- spawnSync("launchctl", ["kickstart", "-k", `gui/${uid}/dev.work.app`], {
1022
- stdio: "ignore",
1023
- });
1024
1065
  log(
1025
1066
  "manage with: launchctl {kickstart -k,print} gui/$UID/dev.work.app (logs: ~/Library/Logs/work.log)",
1026
1067
  );
@@ -46,7 +46,7 @@ fs.mkdirSync(config.dataDir, { recursive: true });
46
46
  var TMUX_SOCKET = "work";
47
47
  var execFileAsync = promisify(execFile);
48
48
  async function run$1(cmd, args, cwd, env, opts = {}) {
49
- const { stdout } = await execFileAsync(cmd, args, {
49
+ const child = execFileAsync(cmd, args, {
50
50
  cwd,
51
51
  env,
52
52
  maxBuffer: 67108864,
@@ -55,6 +55,8 @@ async function run$1(cmd, args, cwd, env, opts = {}) {
55
55
  killSignal: "SIGKILL"
56
56
  }
57
57
  });
58
+ if (opts.stdin !== void 0) child.child.stdin?.end(opts.stdin);
59
+ const { stdout } = await child;
58
60
  return stdout.trim();
59
61
  }
60
62
  /** Ceilings for git's network verbs. A connection that stalls (GitHub
@@ -90,11 +92,11 @@ var gh = (args, host) => run$1("gh", args, void 0, host ? {
90
92
  ...process.env,
91
93
  GH_HOST: host
92
94
  } : void 0);
93
- var tmux = (args, env) => run$1("tmux", [
95
+ var tmux = (args, env, opts) => run$1("tmux", [
94
96
  "-L",
95
97
  TMUX_SOCKET,
96
98
  ...args
97
- ], os.homedir(), utf8Locale(env ?? process.env));
99
+ ], os.homedir(), utf8Locale(env ?? process.env), opts);
98
100
  /** launchd starts the service with no locale at all, and under a non-UTF-8
99
101
  * locale tmux replaces characters it deems unprintable in format output —
100
102
  * including the \t separators sessionStates and the scraper split on, which
@@ -6746,7 +6748,7 @@ function publishChange(sessionId) {
6746
6748
  const row = get("SELECT workspace_id FROM sessions WHERE id = ?", sessionId);
6747
6749
  if (row?.workspace_id) {
6748
6750
  const workspaceId = row.workspace_id;
6749
- import("./_wmfv4tOT.js").then((m) => m.notifySessionsChanged(workspaceId));
6751
+ import("./_Cr-5sjB_.js").then((m) => m.notifySessionsChanged(workspaceId));
6750
6752
  return;
6751
6753
  }
6752
6754
  publish("sessions.changed");
@@ -8347,11 +8349,11 @@ async function sendToSession(id, text, size) {
8347
8349
  }
8348
8350
  const buffer = `work-send-${Math.random().toString(36).slice(2, 8)}`;
8349
8351
  await tmux([
8350
- "set-buffer",
8352
+ "load-buffer",
8351
8353
  "-b",
8352
8354
  buffer,
8353
- text
8354
- ], env);
8355
+ "-"
8356
+ ], env, { stdin: text });
8355
8357
  await tmux([
8356
8358
  "paste-buffer",
8357
8359
  "-p",
@@ -0,0 +1,2 @@
1
+ import { m as notifySessionsChanged } from "./_BRBF-t9p.js";
2
+ export { notifySessionsChanged };