@dylanpiercey/work 0.0.158 → 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.
- package/bin/work.mjs +57 -16
- package/dist/{_B8Ruz8T9.js → _BRBF-t9p.js} +9 -7
- package/dist/_Cr-5sjB_.js +2 -0
- package/dist/index.mjs +437 -1912
- package/dist/public/assets/_BU6w6X4q.js +1 -0
- package/dist/public/assets/_BbqN_0Hf.js +1 -0
- package/dist/public/assets/_BfEhpnxc.js +1 -0
- package/dist/public/assets/_Bjs6hRWD.js +1 -0
- package/dist/public/assets/_BjtlvkCt.js +1 -0
- package/dist/public/assets/_BnZSGKpL.js +1 -0
- package/dist/public/assets/_BnepJiz-.js +1 -0
- package/dist/public/assets/_BpIalLUl.js +1 -0
- package/dist/public/assets/_BpIalLUl.js.br +0 -0
- package/dist/public/assets/_BvcYfwFl.js +1 -0
- package/dist/public/assets/_C0zwP2qH.js +1 -0
- package/dist/public/assets/_C9oWRx13.js +1 -0
- package/dist/public/assets/_CC3Ffsld.js +1 -0
- package/dist/public/assets/_ClG30-Cs.js +1 -0
- package/dist/public/assets/_CxFNOCPZ.js +1 -0
- package/dist/public/assets/{_BxabbFws.js → _D6gBuUWs.js} +45 -45
- package/dist/public/assets/_D6gBuUWs.js.br +0 -0
- package/dist/public/assets/_D9-BvOKl.js +1 -0
- package/dist/public/assets/_D_opOE0v.js +1 -0
- package/dist/public/assets/_DdJpsshP.js +1 -0
- package/dist/public/assets/_L9P-Lxf4.js +1 -0
- package/dist/public/assets/{_DUDy5h6R.js → __CI6owKB.js} +20 -20
- package/dist/public/assets/__CI6owKB.js.br +0 -0
- package/dist/public/assets/_dvB7DobJ.js +1 -0
- package/dist/public/assets/_o7CRZZeJ.js +1 -0
- package/dist/public/assets/{app-page-LdxNfDbr.css → app-page-DyrVoVeZ.css} +1 -1
- package/dist/public/assets/app-page-DyrVoVeZ.css.br +0 -0
- package/dist/public/assets/diff-view-DH-5ACi2.js +2 -0
- package/dist/public/assets/{diff-view-E8jVfABq.css → diff-view-DKJzuUb0.css} +1 -1
- package/dist/public/assets/diff-view-DKJzuUb0.css.br +0 -0
- package/dist/public/assets/new-qqqf-1EI.js +1 -0
- package/dist/public/assets/settings-qqqf-1EI.js +1 -0
- package/dist/public/assets/w-qqqf-1EI.js +1 -0
- package/dist/public/assets/w._-Bmrox8Ci.js +1 -0
- package/dist/public/assets/w._-qqqf-1EI.js +1 -0
- package/package.json +1 -1
- package/dist/_wmfv4tOT.js +0 -2
- package/dist/public/assets/_1uIdjVuP.js +0 -1
- package/dist/public/assets/_B5WqV19M.js +0 -1
- package/dist/public/assets/_BNuUCPGS.js +0 -1
- package/dist/public/assets/_BOfssVLv.js +0 -1
- package/dist/public/assets/_BxIcsysD.js +0 -1
- package/dist/public/assets/_BxabbFws.js.br +0 -0
- package/dist/public/assets/_C26sXSBM.js +0 -1
- package/dist/public/assets/_CDcWSPQn.js +0 -1
- package/dist/public/assets/_Cbu4AbsN.js +0 -1
- package/dist/public/assets/_Cbu4AbsN.js.br +0 -0
- package/dist/public/assets/_Cc9DbAYY.js +0 -1
- package/dist/public/assets/_Co6pRCsQ.js +0 -1
- package/dist/public/assets/_CoptvGxA.js +0 -1
- package/dist/public/assets/_DAh4Jg7Y.js +0 -1
- package/dist/public/assets/_DDCSqngu.js +0 -1
- package/dist/public/assets/_DEaIhIVb.js +0 -1
- package/dist/public/assets/_DFqtdaJl.js +0 -1
- package/dist/public/assets/_DUDy5h6R.js.br +0 -0
- package/dist/public/assets/_Dms-dGSD.js +0 -1
- package/dist/public/assets/_Dw0cv1OC.js +0 -1
- package/dist/public/assets/_Qvk4_rZ1.js +0 -1
- package/dist/public/assets/_bF5nF4E4.js +0 -1
- package/dist/public/assets/_iA6UTJX5.js +0 -1
- package/dist/public/assets/app-page-LdxNfDbr.css.br +0 -0
- package/dist/public/assets/diff-view-BPU5rMei.js +0 -2
- package/dist/public/assets/diff-view-E8jVfABq.css.br +0 -0
- package/dist/public/assets/new-Cz4e5lzk.js +0 -1
- package/dist/public/assets/settings-Cz4e5lzk.js +0 -1
- package/dist/public/assets/w-Cz4e5lzk.js +0 -1
- package/dist/public/assets/w._-AQhK6cKs.js +0 -1
- package/dist/public/assets/w._-Cz4e5lzk.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)
|
|
571
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
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
|
|
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("./
|
|
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
|
-
"
|
|
8352
|
+
"load-buffer",
|
|
8351
8353
|
"-b",
|
|
8352
8354
|
buffer,
|
|
8353
|
-
|
|
8354
|
-
], env);
|
|
8355
|
+
"-"
|
|
8356
|
+
], env, { stdin: text });
|
|
8355
8357
|
await tmux([
|
|
8356
8358
|
"paste-buffer",
|
|
8357
8359
|
"-p",
|