stim 1.10.1 → 1.12.0
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/dist/{build-progress-BXx-ZBe4.mjs → activity-CCZJs__P.mjs} +9 -182
- package/dist/{android-787HhP5w.mjs → android-75Sk2rIR.mjs} +81 -19
- package/dist/{android-Bu4mbDzc.mjs → android-B7X-8H7h.mjs} +426 -106
- package/dist/{android-DPov-fv2.mjs → android-BQiKJYK0.mjs} +1 -1
- package/dist/{android-cas-CITmIeWY.mjs → android-cas-DzLPXiEn.mjs} +7 -7
- package/dist/{app-install-Cfmqr3TQ.mjs → app-install-CsZi0SAT.mjs} +1 -1
- package/dist/{workspaces-wrH6dXfu.mjs → budget-DbzW5VTD.mjs} +651 -32
- package/dist/{dev-client-DExzPiOa.mjs → build-plan-CqntbR7b.mjs} +514 -38
- package/dist/build-progress-h60GPV27.mjs +179 -0
- package/dist/{cache-manifest-Pubfp8wV.mjs → cache-manifest-DWPF4RKJ.mjs} +1 -1
- package/dist/cache-manifest.mjs +1 -1
- package/dist/cli.mjs +16 -16
- package/dist/collector-run.mjs +4 -4
- package/dist/{command-output-D5z2_bcF.mjs → command-output-BWCj5Vh-.mjs} +1 -1
- package/dist/{config-BEq0Qw_a.mjs → config-0jCcMM0E.mjs} +10 -1
- package/dist/{dependency-state-r9UesA9a.mjs → dependency-state-DNN0yfx6.mjs} +1 -1
- package/dist/{deps-DP4eWqea.mjs → deps-CO-_7UOm.mjs} +2 -2
- package/dist/{device-Czh5kO8A.mjs → device-9r9xRYDa.mjs} +49 -11
- package/dist/{device-lease-CbEaIk7b.mjs → device-lease-B9LAXIUH.mjs} +55 -55
- package/dist/{device-pool-BBWLAr55.mjs → device-pool-BoezJd-c.mjs} +4 -4
- package/dist/{device-remote-powUHdbK.mjs → device-remote-C0_o-tJH.mjs} +254 -579
- package/dist/{doctor-CmqK1LcQ.mjs → doctor-LfDlbR-N.mjs} +20 -19
- package/dist/{error-diagnostics-xxWKNO3-.mjs → error-diagnostics-CCxjn31V.mjs} +7 -7
- package/dist/{gc-zCDpmdHU.mjs → gc-C4nQFcTX.mjs} +220 -282
- package/dist/{guide-DwmaD_Wa.mjs → guide-BPBlh9ML.mjs} +512 -73
- package/dist/{guide-status-CWvti2Lg.mjs → guide-status-i9ogHt4v.mjs} +2 -2
- package/dist/{idle--jn7pBNe.mjs → idle-S3tFZ53_.mjs} +7 -6
- package/dist/{in-use-CNIWU-r-.mjs → in-use-D9XYEgFD.mjs} +7 -7
- package/dist/{ios-CbdqTqOc.mjs → ios-CDzWL1mj.mjs} +302 -88
- package/dist/{ios-COGcGEcN.mjs → ios-CZWOHTTc.mjs} +24 -19
- package/dist/{ios-device-DNjPXBnb.mjs → ios-device-D9cLxVr5.mjs} +1 -1
- package/dist/{launch-verify-BhgkYAws.mjs → launch-verify-B2oR_kFN.mjs} +2 -2
- package/dist/logs-SzuYudOj.mjs +485 -0
- package/dist/merge-state-ytFQCeh4.mjs +262 -0
- package/dist/{metro-BWLOJ_Wr.mjs → metro-Dzo30hvJ.mjs} +1 -1
- package/dist/{named-ports-DiTfSz6p.mjs → named-ports-Dn1o61D9.mjs} +3 -3
- package/dist/{ownership-BfPNRf3-.mjs → ownership-B8d4kXBx.mjs} +49 -16
- package/dist/{ownership-D2xbLVoz.mjs → ownership-Dqnrjrio.mjs} +2 -2
- package/dist/{ports-CLSSFOuz.mjs → ports-Dp_QTwTC.mjs} +3 -3
- package/dist/{project-BXZzOABt.mjs → project-B8rbutVC.mjs} +4 -72
- package/dist/{reload-CymyF6Kk.mjs → reload-nocmx8KB.mjs} +9 -9
- package/dist/remote-cache-BRsRZru5.mjs +526 -0
- package/dist/{server-bare-DVbb7kXH.mjs → server-bare-Gn3ssSdK.mjs} +1 -1
- package/dist/{server-expo-BvOCeakp.mjs → server-expo-CeT1nIIk.mjs} +2 -2
- package/dist/server-expo-eWi9Coof.mjs +2 -0
- package/dist/{settings-DOugPlPz.mjs → settings-BlyDn2Oz.mjs} +14 -5
- package/dist/{settings-EWYNwe72.mjs → settings-bE-Gu3Ti.mjs} +23 -11
- package/dist/settings.schema.json +73 -1
- package/dist/{simslim-DZUxzsjq.mjs → simslim-COtEEP7x.mjs} +152 -96
- package/dist/{slot-launch-Dk4oTREM.mjs → slot-launch-DIACGEfH.mjs} +4 -4
- package/dist/{spawn-claims-CUleC2cM.mjs → spawn-claims-PT8aQpCa.mjs} +25 -2
- package/dist/{start-qWapeB4W.mjs → start-BFstVBlx.mjs} +1 -1
- package/dist/{start-RbmFPeZ7.mjs → start-BboE1HIS.mjs} +108 -17
- package/dist/{state-WGdIbi_d.mjs → state-DcDgzfu3.mjs} +15 -3
- package/dist/{stats-BAgJaLA4.mjs → stats-D8rUTPHd.mjs} +1 -1
- package/dist/{stats-DBYJ5bxL.mjs → stats-DiCtmluY.mjs} +4 -4
- package/dist/{status-Dr4fRkym.mjs → status-BUASYyy_.mjs} +92 -33
- package/dist/{status-Zp8kvexe.mjs → status-DI9Tjo7T.mjs} +255 -38
- package/dist/stim-desktop-D0xhpZt8.mjs +29 -0
- package/dist/stop-BI7QY76M.mjs +3 -0
- package/dist/{stop-DcEv5sk-.mjs → stop-Bn6v-GvS.mjs} +205 -37
- package/dist/supervisor-run.mjs +11 -11
- package/dist/{workspace-process-lock-BXA96myD.mjs → workspace-process-lock-BvvJTfo_.mjs} +10 -5
- package/dist/{worktree-DEG2o9F8.mjs → worktree-B5sTRskL.mjs} +1 -1
- package/dist/{worktree-Bd4dRvx7.mjs → worktree-ChDL5fO1.mjs} +17 -16
- package/dist/{worktree-BlizKDpZ.mjs → worktree-DeBQSVtR.mjs} +3 -1
- package/dist/{xcode-B2tBkf0m.mjs → xcode-BzplpQzc.mjs} +7 -7
- package/package.json +5 -5
- package/dist/budget-nDCEwtJv.mjs +0 -620
- package/dist/logs-MARIy6m9.mjs +0 -209
- package/dist/server-expo-DBVTdult.mjs +0 -2
- package/dist/stop-DI4BG4Os.mjs +0 -3
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { O as workspaceDir, _ as withWorkspaceStateLock, c as signalProcessTree, i as pidExists, m as readWorkspaceState, p as clearWorkspaceStateKeys, s as resolveProjectMetro, t as killMetroTree, y as writeWorkspaceState } from "./metro-
|
|
3
|
-
import {
|
|
4
|
-
import { a as clearRemoteSession, i as clearManagedMetroTunnel,
|
|
5
|
-
import { t as withWorkspaceProcessLock } from "./workspace-process-lock-
|
|
6
|
-
import { f as refuseNoProject, l as phaseLine, p as releasedLeaseFact, u as plural } from "./command-output-
|
|
7
|
-
import { u as releaseWorkspaceLeases } from "./device-lease-
|
|
8
|
-
import { d as teardownOwnedAvd, f as teardownOwnedIosSim, i as stopTunnel, t as resolveSupervisorTarget } from "./ownership-
|
|
9
|
-
import { n as verifyCollectorOwnership } from "./ownership-
|
|
10
|
-
import {
|
|
1
|
+
import { A as ownership_claim_exports, B as deviceSlotPlatforms, E as withConfigLock, G as validateDeviceSlot, H as parseDeviceSlotOption, O as process_identity_exports, T as upsertProject, U as projectDeviceSlots, V as parseDeviceSlotKey, o as clearSupervisor, p as getProject } from "./config-0jCcMM0E.mjs";
|
|
2
|
+
import { O as workspaceDir, _ as withWorkspaceStateLock, c as signalProcessTree, i as pidExists, m as readWorkspaceState, p as clearWorkspaceStateKeys, s as resolveProjectMetro, t as killMetroTree, y as writeWorkspaceState } from "./metro-Dzo30hvJ.mjs";
|
|
3
|
+
import { i as findProjectRoot } from "./project-B8rbutVC.mjs";
|
|
4
|
+
import { a as clearRemoteSession, c as readMetroTunnel, i as clearManagedMetroTunnel, o as clearWorkspaceLaunches, s as clearWorkspaceSupervisor, u as readRemoteSession } from "./state-DcDgzfu3.mjs";
|
|
5
|
+
import { t as withWorkspaceProcessLock } from "./workspace-process-lock-BvvJTfo_.mjs";
|
|
6
|
+
import { f as refuseNoProject, l as phaseLine, p as releasedLeaseFact, u as plural } from "./command-output-BWCj5Vh-.mjs";
|
|
7
|
+
import { u as releaseWorkspaceLeases } from "./device-lease-B9LAXIUH.mjs";
|
|
8
|
+
import { d as teardownOwnedAvd, f as teardownOwnedIosSim, i as stopTunnel, t as resolveSupervisorTarget } from "./ownership-B8d4kXBx.mjs";
|
|
9
|
+
import { n as verifyCollectorOwnership } from "./ownership-Dqnrjrio.mjs";
|
|
10
|
+
import { f as resolveEasCliBin } from "./remote-cache-BRsRZru5.mjs";
|
|
11
|
+
import { _ as describeNativeRunHolder, b as requestNativeRunCancel, f as NATIVE_RUN_LOCK, g as decideStopAction, h as clearNativeRunCancel, i as endRecordedSession, p as NATIVE_RUN_WAIT_MS, v as nativeRunHolder, y as nativeRunWaitNotice } from "./device-remote-C0_o-tJH.mjs";
|
|
11
12
|
import chalk from "chalk";
|
|
12
13
|
//#region src/commands/stop.ts
|
|
13
14
|
const DEFAULT_WAIT_MS = 1e4;
|
|
@@ -101,6 +102,23 @@ function defaultTeardownRemoteSession(root, sessionId) {
|
|
|
101
102
|
easBin: resolveEasCliBin(root)?.file ?? null
|
|
102
103
|
});
|
|
103
104
|
}
|
|
105
|
+
function endRemoteSession(root, sessionId, { teardownRemoteSession, report }) {
|
|
106
|
+
const result = teardownRemoteSession(root, sessionId);
|
|
107
|
+
if (result.status === "failed") report(chalk.red(phaseLine("device", result.reason ?? `could not stop remote session ${sessionId}`)));
|
|
108
|
+
else {
|
|
109
|
+
report(chalk.dim(phaseLine("device", `stopped remote session ${sessionId}`)));
|
|
110
|
+
if (result.reason) report(chalk.yellow(phaseLine("device", result.reason)));
|
|
111
|
+
else clearRemoteSession(root, sessionId);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
status: result.status,
|
|
115
|
+
label: sessionId,
|
|
116
|
+
reason: result.reason
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function remoteEnded(entry) {
|
|
120
|
+
return entry.status !== "failed" && !entry.reason;
|
|
121
|
+
}
|
|
104
122
|
async function runStop(options) {
|
|
105
123
|
if (options.slot === void 0) return stopWorkspace(options);
|
|
106
124
|
const slot = validateDeviceSlot(options.slot);
|
|
@@ -125,7 +143,10 @@ async function runStop(options) {
|
|
|
125
143
|
clearCollectorState(projectRoot, expected);
|
|
126
144
|
return !Object.keys(readCollectorState(projectRoot)).some((key) => parseDeviceSlotKey(key)?.slot === slot);
|
|
127
145
|
}),
|
|
128
|
-
clearState: () =>
|
|
146
|
+
clearState: (projectRoot) => {
|
|
147
|
+
clearWorkspaceLaunches(projectRoot, slot);
|
|
148
|
+
return true;
|
|
149
|
+
},
|
|
129
150
|
clearRegistration: async () => true,
|
|
130
151
|
releaseLeases: (projectRoot) => releaseWorkspaceLeases(projectRoot, { slot })
|
|
131
152
|
});
|
|
@@ -287,7 +308,7 @@ async function stopWorkspace({ root, project = void 0, state = void 0, collector
|
|
|
287
308
|
};
|
|
288
309
|
if (stillHolding) report(chalk.dim(phaseLine("device", "left alone (something is still running)")));
|
|
289
310
|
else {
|
|
290
|
-
outcomes.device = shutDownDevices(proj, {
|
|
311
|
+
outcomes.device = shutDownDevices(proj, root, {
|
|
291
312
|
teardownIos,
|
|
292
313
|
teardownAvd,
|
|
293
314
|
report
|
|
@@ -297,22 +318,11 @@ async function stopWorkspace({ root, project = void 0, state = void 0, collector
|
|
|
297
318
|
const remote = remoteDevice === void 0 ? readRemoteSession(root) : remoteDevice;
|
|
298
319
|
const sessionId = typeof remote?.sessionId === "string" ? remote.sessionId : null;
|
|
299
320
|
if (sessionId) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
};
|
|
306
|
-
if (result.status === "failed") {
|
|
307
|
-
ok = false;
|
|
308
|
-
report(chalk.red(phaseLine("device", result.reason ?? `could not stop remote session ${sessionId}`)));
|
|
309
|
-
} else {
|
|
310
|
-
report(chalk.dim(phaseLine("device", `stopped remote session ${sessionId}`)));
|
|
311
|
-
if (result.reason) {
|
|
312
|
-
ok = false;
|
|
313
|
-
report(chalk.yellow(phaseLine("device", result.reason)));
|
|
314
|
-
} else clearRemoteSession(root, sessionId);
|
|
315
|
-
}
|
|
321
|
+
outcomes.device.remote = endRemoteSession(root, sessionId, {
|
|
322
|
+
teardownRemoteSession,
|
|
323
|
+
report
|
|
324
|
+
});
|
|
325
|
+
if (!remoteEnded(outcomes.device.remote)) ok = false;
|
|
316
326
|
}
|
|
317
327
|
const tunnel = metroTunnel === void 0 ? readMetroTunnel(root) : metroTunnel;
|
|
318
328
|
let tunnelHolding = null;
|
|
@@ -572,7 +582,7 @@ function occupiedSkipReason(reason, holders) {
|
|
|
572
582
|
const named = (holders || []).filter(Boolean);
|
|
573
583
|
return named.length ? `${reason} -- held by UI-test runner ${named.join(", ")}` : `${reason} -- ${OCCUPANCY_HINT}`;
|
|
574
584
|
}
|
|
575
|
-
function shutDownDevices(project, { teardownIos, teardownAvd, report }) {
|
|
585
|
+
function shutDownDevices(project, workspace, { teardownIos, teardownAvd, report }) {
|
|
576
586
|
const device = {
|
|
577
587
|
ios: null,
|
|
578
588
|
android: null
|
|
@@ -594,7 +604,8 @@ function shutDownDevices(project, { teardownIos, teardownAvd, report }) {
|
|
|
594
604
|
report(chalk.dim(phaseLine("device", `${iosUdid} is not Stim-owned, leaving it running`)));
|
|
595
605
|
} else device[iosKey] = reportDevice(iosUdid, teardownIos(iosUdid, {
|
|
596
606
|
del: false,
|
|
597
|
-
label: iosName
|
|
607
|
+
label: iosName,
|
|
608
|
+
workspace
|
|
598
609
|
}), report, "ios");
|
|
599
610
|
}
|
|
600
611
|
const android = platforms.android;
|
|
@@ -607,7 +618,10 @@ function shutDownDevices(project, { teardownIos, teardownAvd, report }) {
|
|
|
607
618
|
reason: "Stim does not own this device"
|
|
608
619
|
};
|
|
609
620
|
report(chalk.dim(phaseLine("device", `${android.avdName} is not Stim-owned, leaving it running`)));
|
|
610
|
-
} else device[androidKey] = reportDevice(android.avdName, teardownAvd(android.avdName, {
|
|
621
|
+
} else device[androidKey] = reportDevice(android.avdName, teardownAvd(android.avdName, {
|
|
622
|
+
del: false,
|
|
623
|
+
workspace
|
|
624
|
+
}), report, "android");
|
|
611
625
|
}
|
|
612
626
|
}
|
|
613
627
|
return device;
|
|
@@ -696,20 +710,174 @@ async function defaultClearRegistration(root, expected) {
|
|
|
696
710
|
return false;
|
|
697
711
|
}
|
|
698
712
|
}
|
|
713
|
+
const INTERRUPT_WAIT_MS = 6e4;
|
|
714
|
+
var StopBlocked = class extends Error {
|
|
715
|
+
refusal;
|
|
716
|
+
constructor(refusal) {
|
|
717
|
+
super(refusal.message);
|
|
718
|
+
this.refusal = refusal;
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
var LeaveBuildRunning = class extends Error {};
|
|
722
|
+
function ownerGoneRefusal(holder, at) {
|
|
723
|
+
const child = holder.child ? ` (pid ${holder.child.pid})` : "";
|
|
724
|
+
return new StopBlocked({
|
|
725
|
+
code: "STIM_STOP_BLOCKED",
|
|
726
|
+
message: `${describeNativeRunHolder(holder, at)} holds this workspace's native-run claim at ${holder.path}, but pid ${holder.owner.pid} is no longer that run; the build tool it started${child} still holds the claim. Stim signals only a claim owner whose identity it can prove.`,
|
|
727
|
+
remedy: `Wait for the build tool${child} to exit, or end it yourself, then run \`stim stop\` again.`
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
function workspaceDeviceSlots(root) {
|
|
731
|
+
const slots = projectDeviceSlots(getProject(root)).filter(({ platforms }) => Object.values(platforms).some(Boolean)).map(({ slot }) => slot);
|
|
732
|
+
if (typeof readRemoteSession(root)?.sessionId === "string" && !slots.includes("default")) slots.push("default");
|
|
733
|
+
return slots;
|
|
734
|
+
}
|
|
735
|
+
function readRemoteSessionEntry(root, report) {
|
|
736
|
+
const sessionId = readRemoteSession(root)?.sessionId;
|
|
737
|
+
if (typeof sessionId !== "string") return null;
|
|
738
|
+
report(chalk.dim(phaseLine("device", `ending remote session ${sessionId} without waiting on the build lock`)));
|
|
739
|
+
return endRemoteSession(root, sessionId, {
|
|
740
|
+
teardownRemoteSession: defaultTeardownRemoteSession,
|
|
741
|
+
report
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* `stop` under the workspace's native-run lock. A billable remote session is ended as soon as the lock is
|
|
746
|
+
* seen held; a live `ios` or `android` run that the stop leaves nothing to deploy to is interrupted with
|
|
747
|
+
* SIGINT and given INTERRUPT_WAIT_MS to exit; a build for another slot that stays is left running while
|
|
748
|
+
* the slot stops without the lock; any other holder is waited on with a visible notice.
|
|
749
|
+
*/
|
|
750
|
+
async function stopWorkspaceNow({ root, slot, report = (line) => console.error(line), now = Date.now, sleep, waitMs = NATIVE_RUN_WAIT_MS, interruptWaitMs = INTERRUPT_WAIT_MS, inspectIdentity = process_identity_exports.inspectProcessIdentity, interrupt = (pid) => process.kill(pid, "SIGINT"), endRemote = (projectRoot) => readRemoteSessionEntry(projectRoot, report), deviceSlots = workspaceDeviceSlots, stop = (options) => runStop(options) }) {
|
|
751
|
+
let remote = null;
|
|
752
|
+
let remoteHandled = slot !== void 0;
|
|
753
|
+
const endRemoteNow = () => {
|
|
754
|
+
if (remoteHandled) return;
|
|
755
|
+
remoteHandled = true;
|
|
756
|
+
remote = endRemote(root);
|
|
757
|
+
};
|
|
758
|
+
const notice = nativeRunWaitNotice({
|
|
759
|
+
write: (line) => report(chalk.dim(phaseLine("lock", line))),
|
|
760
|
+
now
|
|
761
|
+
});
|
|
762
|
+
let seen = null;
|
|
763
|
+
const interrupted = [];
|
|
764
|
+
const onHeld = (holder) => {
|
|
765
|
+
const at = now();
|
|
766
|
+
if (seen?.claimId === holder.claimId) {
|
|
767
|
+
if (seen.action === "interrupt" && at >= seen.deadline) {
|
|
768
|
+
if (inspectIdentity(holder.owner) !== "same") throw ownerGoneRefusal(holder, at);
|
|
769
|
+
throw new StopBlocked({
|
|
770
|
+
code: "STIM_STOP_BLOCKED",
|
|
771
|
+
message: `${describeNativeRunHolder(holder, at)} did not exit within ${Math.round(interruptWaitMs / 1e3)}s of SIGINT; it still holds this workspace's native-run claim at ${holder.path}.`,
|
|
772
|
+
remedy: `Wait for it to finish, or end it with \`kill ${holder.owner.pid}\`, then run \`stim stop\` again.`
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
notice(holder);
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
endRemoteNow();
|
|
779
|
+
const target = nativeRunHolder(holder);
|
|
780
|
+
const { action } = decideStopAction({
|
|
781
|
+
stopSlot: slot,
|
|
782
|
+
holder: target,
|
|
783
|
+
ownerIdentity: inspectIdentity(holder.owner),
|
|
784
|
+
deviceSlots: deviceSlots(root)
|
|
785
|
+
});
|
|
786
|
+
seen = {
|
|
787
|
+
claimId: holder.claimId,
|
|
788
|
+
action,
|
|
789
|
+
deadline: Number.POSITIVE_INFINITY
|
|
790
|
+
};
|
|
791
|
+
const who = describeNativeRunHolder(holder, at);
|
|
792
|
+
if (action === "proceed") {
|
|
793
|
+
notice(holder, `leaving ${who} running: slot ${target.slot} stays, so slot ${slot} stops without the build lock`);
|
|
794
|
+
throw new LeaveBuildRunning();
|
|
795
|
+
}
|
|
796
|
+
if (action === "refuse") throw ownerGoneRefusal(holder, at);
|
|
797
|
+
if (action === "interrupt") {
|
|
798
|
+
requestNativeRunCancel(root, holder.claimId);
|
|
799
|
+
interrupted.push(holder.claimId);
|
|
800
|
+
seen = {
|
|
801
|
+
claimId: holder.claimId,
|
|
802
|
+
action,
|
|
803
|
+
deadline: now() + interruptWaitMs
|
|
804
|
+
};
|
|
805
|
+
if (inspectIdentity(holder.owner) !== "same") return;
|
|
806
|
+
try {
|
|
807
|
+
interrupt(holder.owner.pid);
|
|
808
|
+
} catch (error) {
|
|
809
|
+
if (error?.code !== "ESRCH") throw error;
|
|
810
|
+
}
|
|
811
|
+
notice(holder, `interrupting ${who}: sent SIGINT, waiting up to ${Math.round(interruptWaitMs / 1e3)}s for it to exit`);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
notice(holder);
|
|
815
|
+
};
|
|
816
|
+
const withRemote = (result) => {
|
|
817
|
+
if (!remote || result.outcomes.device.remote) return result;
|
|
818
|
+
result.outcomes.device.remote = remote;
|
|
819
|
+
if (!remoteEnded(remote)) result.ok = false;
|
|
820
|
+
return result;
|
|
821
|
+
};
|
|
822
|
+
try {
|
|
823
|
+
return withRemote(await withWorkspaceProcessLock(workspaceDir(root), NATIVE_RUN_LOCK, () => stop({
|
|
824
|
+
root,
|
|
825
|
+
slot
|
|
826
|
+
}), {
|
|
827
|
+
external: true,
|
|
828
|
+
waitMs,
|
|
829
|
+
now,
|
|
830
|
+
...sleep ? { sleep } : {},
|
|
831
|
+
details: {
|
|
832
|
+
command: "stop",
|
|
833
|
+
...slot === void 0 ? {} : { slot }
|
|
834
|
+
},
|
|
835
|
+
onHeld
|
|
836
|
+
}));
|
|
837
|
+
} catch (error) {
|
|
838
|
+
if (error instanceof LeaveBuildRunning) return withRemote(await stop({
|
|
839
|
+
root,
|
|
840
|
+
slot
|
|
841
|
+
}));
|
|
842
|
+
if (error instanceof StopBlocked) return {
|
|
843
|
+
refusal: error.refusal,
|
|
844
|
+
remote
|
|
845
|
+
};
|
|
846
|
+
if ((0, ownership_claim_exports.isClaimRefusal)(error)) endRemoteNow();
|
|
847
|
+
throw error;
|
|
848
|
+
} finally {
|
|
849
|
+
for (const claimId of interrupted) clearNativeRunCancel(root, claimId);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
699
852
|
function stopCommand(program) {
|
|
700
|
-
program.command("stop").description("The inverse of `start`: halt this workspace's supervisor, shut the owned device down (never deleted), and free the reserved port. Non-destructive -- the device stays assigned, so coming back costs a boot. Acts on the current workspace.").option("--slot <name>", "Stop only this device slot, keeping the shared server running", parseDeviceSlotOption).option("--json", "print the per-step outcomes as JSON").action(async (opts) => {
|
|
853
|
+
program.command("stop").description("The inverse of `start`: halt this workspace's supervisor, shut the owned device down (never deleted), and free the reserved port. Non-destructive -- the device stays assigned, so coming back costs a boot. Acts on the current workspace.").option("--slot <name>", "Stop only this device slot, keeping the shared server running. Use 'default' for the workspace's default device.", parseDeviceSlotOption).option("--json", "print the per-step outcomes as JSON").action(async (opts) => {
|
|
701
854
|
const root = findProjectRoot(process.cwd());
|
|
702
855
|
if (!root) {
|
|
703
856
|
refuseNoProject({ json: Boolean(opts.json) });
|
|
704
857
|
return;
|
|
705
858
|
}
|
|
706
|
-
const
|
|
859
|
+
const stopped = await stopWorkspaceNow({
|
|
707
860
|
root,
|
|
708
861
|
slot: opts.slot
|
|
709
|
-
}), {
|
|
710
|
-
external: true,
|
|
711
|
-
waitMs: 18e5
|
|
712
862
|
});
|
|
863
|
+
if ("refusal" in stopped) {
|
|
864
|
+
const { code, message, remedy } = stopped.refusal;
|
|
865
|
+
console.error(chalk.red(phaseLine("error", `${code}: ${message}`)));
|
|
866
|
+
console.error(phaseLine("remedy", remedy));
|
|
867
|
+
if (opts.json) {
|
|
868
|
+
const remote = stopped.remote ? { device: { remote: stopped.remote } } : {};
|
|
869
|
+
console.log(JSON.stringify({
|
|
870
|
+
root,
|
|
871
|
+
ok: false,
|
|
872
|
+
code,
|
|
873
|
+
message,
|
|
874
|
+
remedy,
|
|
875
|
+
...remote
|
|
876
|
+
}));
|
|
877
|
+
}
|
|
878
|
+
process.exit(1);
|
|
879
|
+
}
|
|
880
|
+
const { ok, outcomes, summary } = stopped;
|
|
713
881
|
if (opts.json) console.log(JSON.stringify({
|
|
714
882
|
root,
|
|
715
883
|
ok,
|
|
@@ -720,4 +888,4 @@ function stopCommand(program) {
|
|
|
720
888
|
});
|
|
721
889
|
}
|
|
722
890
|
//#endregion
|
|
723
|
-
export { resolveCollectorTargets as a, readSupervisorState as i, clearSupervisorState as n, runStop as o, readCollectorState as r, stopCommand as s, clearCollectorState as t };
|
|
891
|
+
export { resolveCollectorTargets as a, stopWorkspaceNow as c, readSupervisorState as i, clearSupervisorState as n, runStop as o, readCollectorState as r, stopCommand as s, clearCollectorState as t };
|
package/dist/supervisor-run.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as process_identity_exports, U as projectDeviceSlots, V as parseDeviceSlotKey, o as clearSupervisor, p as getProject, w as setSupervisor } from "./config-0jCcMM0E.mjs";
|
|
2
2
|
import { r as createNdjsonWriter } from "./ndjson-CDY9IkVC.mjs";
|
|
3
|
-
import { _ as withWorkspaceStateLock, j as workspaceLogsDir, m as readWorkspaceState$1, p as clearWorkspaceStateKeys, y as writeWorkspaceState } from "./metro-
|
|
4
|
-
import {
|
|
3
|
+
import { _ as withWorkspaceStateLock, j as workspaceLogsDir, m as readWorkspaceState$1, p as clearWorkspaceStateKeys, y as writeWorkspaceState } from "./metro-Dzo30hvJ.mjs";
|
|
4
|
+
import { r as detectIsExpo } from "./project-B8rbutVC.mjs";
|
|
5
5
|
import { t as describeError } from "./errors-B6W7FkxQ.mjs";
|
|
6
6
|
import { t as relaunchWithLogFile } from "./detached-entry-DJHoca49.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { t as withWorkspaceProcessLock } from "./workspace-process-lock-
|
|
9
|
-
import { a as parseLease, r as leaseIsExpired, s as parseWorkspaceLeases, t as deviceLeasePath } from "./device-lease-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { s as workspaceBuildInProgress } from "./idle
|
|
13
|
-
import { n as withIdleWorkspace } from "./in-use-
|
|
7
|
+
import { l as readPidFile, n as MODE_EXPO, p as writePidFile, r as clearExpoMetroTunnel, s as clearWorkspaceSupervisor, t as MODE_BARE } from "./state-DcDgzfu3.mjs";
|
|
8
|
+
import { t as withWorkspaceProcessLock } from "./workspace-process-lock-BvvJTfo_.mjs";
|
|
9
|
+
import { a as parseLease, r as leaseIsExpired, s as parseWorkspaceLeases, t as deviceLeasePath } from "./device-lease-B9LAXIUH.mjs";
|
|
10
|
+
import { n as createActivityReader } from "./activity-CCZJs__P.mjs";
|
|
11
|
+
import { L as ownedAvdSerialResolver } from "./android-75Sk2rIR.mjs";
|
|
12
|
+
import { s as workspaceBuildInProgress } from "./idle-S3tFZ53_.mjs";
|
|
13
|
+
import { n as withIdleWorkspace } from "./in-use-D9XYEgFD.mjs";
|
|
14
14
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
15
15
|
import { LOG_ROTATE_BYTES } from "@stim-cli/core";
|
|
16
16
|
import { IDLE_STOP_KEY } from "@stim-cli/core/state";
|
|
@@ -264,7 +264,7 @@ async function runSupervisor({ root, port, tunnel = false, resetCache = false, i
|
|
|
264
264
|
return writer.write(entry);
|
|
265
265
|
} });
|
|
266
266
|
try {
|
|
267
|
-
server = await (mode === "expo-child" ? startExpo || (await import("./server-expo-
|
|
267
|
+
server = await (mode === "expo-child" ? startExpo || (await import("./server-expo-eWi9Coof.mjs")).startExpoServer : startBare || (await import("./server-bare-Gn3ssSdK.mjs")).startBareServer)({
|
|
268
268
|
root,
|
|
269
269
|
port,
|
|
270
270
|
logsDir,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as ownership_claim_exports } from "./config-0jCcMM0E.mjs";
|
|
2
|
+
import { n as declareSpawnsOn, o as stopDeclaringSpawnsOn } from "./spawn-claims-PT8aQpCa.mjs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
//#region src/engine/workspace-process-lock.ts
|
|
5
5
|
const DEFAULT_WAIT_MS = 6e4;
|
|
@@ -14,7 +14,7 @@ function workspaceProcessLockError(err) {
|
|
|
14
14
|
function workspaceProcessLockPath(root, name, external) {
|
|
15
15
|
return external ? join(root, `${name}.lock`) : join(root, ".stim", `${name}.lock`);
|
|
16
16
|
}
|
|
17
|
-
async function withWorkspaceProcessLock(root, name, fn, { now = Date.now, sleep = defaultSleep, waitMs = DEFAULT_WAIT_MS, ownerPurpose, rejectOwnerPurposes = [], external = false, declareSpawns = false } = {}) {
|
|
17
|
+
async function withWorkspaceProcessLock(root, name, fn, { now = Date.now, sleep = defaultSleep, waitMs = DEFAULT_WAIT_MS, ownerPurpose, details = {}, onHeld, rejectOwnerPurposes = [], external = false, declareSpawns = false } = {}) {
|
|
18
18
|
const path = workspaceProcessLockPath(root, name, external);
|
|
19
19
|
const deadline = now() + waitMs;
|
|
20
20
|
for (;;) {
|
|
@@ -22,7 +22,10 @@ async function withWorkspaceProcessLock(root, name, fn, { now = Date.now, sleep
|
|
|
22
22
|
root: path,
|
|
23
23
|
mode: "exclusive",
|
|
24
24
|
label: `${name} lock`,
|
|
25
|
-
details: ownerPurpose ? {
|
|
25
|
+
details: ownerPurpose ? {
|
|
26
|
+
...details,
|
|
27
|
+
purpose: ownerPurpose
|
|
28
|
+
} : details
|
|
26
29
|
});
|
|
27
30
|
if (attempt.pending) (0, ownership_claim_exports.releaseClaim)(attempt.pending);
|
|
28
31
|
if (attempt.acquired) {
|
|
@@ -34,12 +37,14 @@ async function withWorkspaceProcessLock(root, name, fn, { now = Date.now, sleep
|
|
|
34
37
|
(0, ownership_claim_exports.releaseClaim)(attempt.acquired);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
|
-
const
|
|
40
|
+
const holder = attempt.held ?? attempt.waitingFor?.[0];
|
|
41
|
+
const purpose = holder?.details.purpose;
|
|
38
42
|
if (typeof purpose === "string" && rejectOwnerPurposes.includes(purpose)) {
|
|
39
43
|
const error = /* @__PURE__ */ new Error(`The ${name} lock at ${path} is held for ${purpose}.`);
|
|
40
44
|
error.code = "STIM_LOCK_REFUSED";
|
|
41
45
|
throw error;
|
|
42
46
|
}
|
|
47
|
+
if (holder && onHeld) await onHeld(holder);
|
|
43
48
|
if (now() >= deadline) {
|
|
44
49
|
const error = /* @__PURE__ */ new Error(`Timed out waiting for the ${name} lock at ${path}.`);
|
|
45
50
|
error.code = "STIM_LOCK_TIMEOUT";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as reclaimKeys, c as removalBlockers, d as removeWorktreeTarget, f as worktreeCommand, i as porcelainPath, l as removalPath, n as excludePodChurn, o as registerRemove, r as matchWorktreeEntry, s as registerWarm, t as dependencyInstallCommand, u as removalRemedy } from "./worktree-
|
|
1
|
+
import { a as reclaimKeys, c as removalBlockers, d as removeWorktreeTarget, f as worktreeCommand, i as porcelainPath, l as removalPath, n as excludePodChurn, o as registerRemove, r as matchWorktreeEntry, s as registerWarm, t as dependencyInstallCommand, u as removalRemedy } from "./worktree-ChDL5fO1.mjs";
|
|
2
2
|
export { worktreeCommand as default, dependencyInstallCommand, excludePodChurn, matchWorktreeEntry, porcelainPath, reclaimKeys, registerRemove, registerWarm, removalBlockers, removalPath, removalRemedy, removeWorktreeTarget };
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as ownership_claim_exports, O as process_identity_exports, T as upsertProject, U as projectDeviceSlots, _ as loadConfig, a as clearDevice, d as getConfigDir, g as isPathPrefix, k as acquireAvdClaim, p as getProject, x as removeProject } from "./config-0jCcMM0E.mjs";
|
|
2
2
|
import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
|
|
3
|
-
import { O as workspaceDir, c as signalProcessTree, h as recordWorkspaceUse, i as pidExists, m as readWorkspaceState, s as resolveProjectMetro, t as killMetroTree } from "./metro-
|
|
4
|
-
import { C as sourceCheckoutOf, S as restoreFile, T as warmWorktreePaths, _ as readWorktreeExclude, b as resolveFullRef, d as hasUncommittedWork, f as isPodInstallChurn, g as podsOutOfSync, h as locallyKnownUpstream, i as depsOutOfSync, l as hasPopulatedSubmodules, m as listWorktrees, n as cloneIgnoredEntries, o as dirtyPaths, r as deleteBranch, s as gitCommonDir, t as branchExists, u as hasRemote, v as removeWorktree, w as unpushedCommits } from "./worktree-
|
|
5
|
-
import {
|
|
6
|
-
import { a as clearRemoteSession,
|
|
7
|
-
import { a as formatElapsed, h as shortUdid, i as formatDuration, l as phaseLine, p as releasedLeaseFact, u as plural } from "./command-output-
|
|
8
|
-
import { u as releaseWorkspaceLeases } from "./device-lease-
|
|
9
|
-
import { L as unknownSettingKeys, P as settingShapeErrors, a as SETTING_SHAPE_REMEDY, j as resolveSettings } from "./settings-
|
|
10
|
-
import { d as teardownOwnedAvd, f as teardownOwnedIosSim, h as POOL_SETTING_REMEDY, i as stopTunnel, l as withManagedTunnelRemovalLock, s as withManagedRemoteWorktreeRemovalLock, t as resolveSupervisorTarget, y as parkedMaxSetting } from "./ownership-
|
|
11
|
-
import { n as withIdleWorkspace, t as emptyWorkspaceDir } from "./in-use-
|
|
12
|
-
import { n as verifyCollectorOwnership } from "./ownership-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { t as
|
|
17
|
-
import {
|
|
3
|
+
import { O as workspaceDir, c as signalProcessTree, h as recordWorkspaceUse, i as pidExists, m as readWorkspaceState, s as resolveProjectMetro, t as killMetroTree } from "./metro-Dzo30hvJ.mjs";
|
|
4
|
+
import { C as sourceCheckoutOf, S as restoreFile, T as warmWorktreePaths, _ as readWorktreeExclude, b as resolveFullRef, d as hasUncommittedWork, f as isPodInstallChurn, g as podsOutOfSync, h as locallyKnownUpstream, i as depsOutOfSync, l as hasPopulatedSubmodules, m as listWorktrees, n as cloneIgnoredEntries, o as dirtyPaths, r as deleteBranch, s as gitCommonDir, t as branchExists, u as hasRemote, v as removeWorktree, w as unpushedCommits } from "./worktree-DeBQSVtR.mjs";
|
|
5
|
+
import { i as findProjectRoot } from "./project-B8rbutVC.mjs";
|
|
6
|
+
import { a as clearRemoteSession, c as readMetroTunnel, d as readRemoteSessionId, i as clearManagedMetroTunnel, u as readRemoteSession } from "./state-DcDgzfu3.mjs";
|
|
7
|
+
import { a as formatElapsed, h as shortUdid, i as formatDuration, l as phaseLine, p as releasedLeaseFact, u as plural } from "./command-output-BWCj5Vh-.mjs";
|
|
8
|
+
import { u as releaseWorkspaceLeases } from "./device-lease-B9LAXIUH.mjs";
|
|
9
|
+
import { L as unknownSettingKeys, P as settingShapeErrors, a as SETTING_SHAPE_REMEDY, j as resolveSettings } from "./settings-BlyDn2Oz.mjs";
|
|
10
|
+
import { d as teardownOwnedAvd, f as teardownOwnedIosSim, h as POOL_SETTING_REMEDY, i as stopTunnel, l as withManagedTunnelRemovalLock, s as withManagedRemoteWorktreeRemovalLock, t as resolveSupervisorTarget, y as parkedMaxSetting } from "./ownership-B8d4kXBx.mjs";
|
|
11
|
+
import { n as withIdleWorkspace, t as emptyWorkspaceDir } from "./in-use-D9XYEgFD.mjs";
|
|
12
|
+
import { n as verifyCollectorOwnership } from "./ownership-Dqnrjrio.mjs";
|
|
13
|
+
import { f as resolveEasCliBin } from "./remote-cache-BRsRZru5.mjs";
|
|
14
|
+
import { i as endRecordedSession } from "./device-remote-C0_o-tJH.mjs";
|
|
15
|
+
import { h as podInstallCommand, n as HEARTBEAT_INTERVAL_MS } from "./xcode-BzplpQzc.mjs";
|
|
16
|
+
import { n as hasInstalledDependencies, r as installedNpmTreeIsValid, t as dependencyState } from "./dependency-state-DNN0yfx6.mjs";
|
|
17
|
+
import { t as clearNamedPorts } from "./named-ports-Dn1o61D9.mjs";
|
|
18
|
+
import { a as runPodInstall, i as runCaptured, n as podsAreStale, r as readPodState, t as DEPS_ERROR } from "./deps-CO-_7UOm.mjs";
|
|
18
19
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
19
20
|
import { existsSync as existsSync$1, realpathSync as realpathSync$1 } from "fs";
|
|
20
21
|
import { basename, dirname, isAbsolute, relative, resolve } from "path";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as loadConfig, d as getConfigDir } from "./config-0jCcMM0E.mjs";
|
|
2
2
|
import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
|
|
3
3
|
import { accessSync, chmodSync, constants, lstatSync, mkdirSync, mkdtempSync, readdirSync, realpathSync, rmSync, statSync } from "node:fs";
|
|
4
4
|
import { chmodSync as chmodSync$1, existsSync as existsSync$1, lstatSync as lstatSync$1, mkdirSync as mkdirSync$1, readFileSync as readFileSync$1, readdirSync as readdirSync$1, realpathSync as realpathSync$1, statSync as statSync$1, utimesSync } from "fs";
|
|
@@ -481,6 +481,7 @@ function dirtyFingerprintFiles(root) {
|
|
|
481
481
|
}
|
|
482
482
|
function hasUncommittedWork(dir) {
|
|
483
483
|
const out = getExecutor().runFileQuiet("git", [
|
|
484
|
+
"--no-optional-locks",
|
|
484
485
|
"-C",
|
|
485
486
|
dir,
|
|
486
487
|
"status",
|
|
@@ -491,6 +492,7 @@ function hasUncommittedWork(dir) {
|
|
|
491
492
|
}
|
|
492
493
|
function dirtyPaths(dir, { limit = 10 } = {}) {
|
|
493
494
|
const out = getExecutor().runFileQuiet("git", [
|
|
495
|
+
"--no-optional-locks",
|
|
494
496
|
"-C",
|
|
495
497
|
dir,
|
|
496
498
|
"status",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
|
|
2
|
-
import { r as register } from "./cache-manifest-
|
|
3
|
-
import { D as workspaceDerivedData, w as sharedCompilationCache } from "./metro-
|
|
4
|
-
import { u as resolvePackageJson } from "./project-
|
|
5
|
-
import {
|
|
2
|
+
import { r as register } from "./cache-manifest-DWPF4RKJ.mjs";
|
|
3
|
+
import { D as workspaceDerivedData, w as sharedCompilationCache } from "./metro-Dzo30hvJ.mjs";
|
|
4
|
+
import { u as resolvePackageJson } from "./project-B8rbutVC.mjs";
|
|
5
|
+
import { a as spawnDeclared } from "./spawn-claims-PT8aQpCa.mjs";
|
|
6
6
|
import { t as createLineReader } from "./process-output-Fpl8PYi8.mjs";
|
|
7
|
-
import { a as formatElapsed, l as phaseLine } from "./command-output-
|
|
8
|
-
import { W as resolveOptimizations } from "./settings-
|
|
9
|
-
import { t as cleanLine } from "./server-expo-
|
|
7
|
+
import { a as formatElapsed, l as phaseLine } from "./command-output-BWCj5Vh-.mjs";
|
|
8
|
+
import { W as resolveOptimizations } from "./settings-BlyDn2Oz.mjs";
|
|
9
|
+
import { t as cleanLine } from "./server-expo-CeT1nIIk.mjs";
|
|
10
10
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
11
11
|
import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
12
12
|
import { createHash } from "node:crypto";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stim",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Stim: fast, isolated React Native environments for coding agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@expo/fingerprint": "^0.20.10",
|
|
46
|
-
"@stim-cli/cache": "^1.
|
|
47
|
-
"@stim-cli/core": "^1.
|
|
48
|
-
"@stim-cli/metro": "^1.
|
|
46
|
+
"@stim-cli/cache": "^1.12.0",
|
|
47
|
+
"@stim-cli/core": "^1.12.0",
|
|
48
|
+
"@stim-cli/metro": "^1.12.0",
|
|
49
49
|
"chalk": "^6.0.0",
|
|
50
50
|
"commander": "^15.0.0",
|
|
51
51
|
"cross-spawn": "^7.0.6",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"ws": "^8.21.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@stim-cli/expo-build-cache": "1.
|
|
56
|
+
"@stim-cli/expo-build-cache": "1.12.0",
|
|
57
57
|
"@types/cross-spawn": "^6.0.6",
|
|
58
58
|
"@types/which": "^3.0.4",
|
|
59
59
|
"@types/ws": "^8.18.1",
|