stim 1.17.2 → 1.18.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/README.md +50 -1
- package/dist/{activity-IRvJY_ru.mjs → activity-BxnkDZDi.mjs} +4 -4
- package/dist/{agent-device-usage-output-BK41vnzN.mjs → agent-device-usage-output-CZ66YA4T.mjs} +8 -8
- package/dist/android-BKA16DTf.mjs +4 -0
- package/dist/{android-B9yaNKwa.mjs → android-BvwuMUJ9.mjs} +192 -98
- package/dist/{android-DE4v59Mb.mjs → android-CBwCNicO.mjs} +2 -2
- package/dist/{android-B_YNZy61.mjs → android-DC3ZLuw0.mjs} +9 -9
- package/dist/{android-cas-ZFpjJBL_.mjs → android-cas-BBFyr9CA.mjs} +5 -5
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/api-D0VtFhqk.mjs +152 -0
- package/dist/api-run.d.mts +1 -0
- package/dist/api-run.mjs +145 -0
- package/dist/api.d.mts +212 -0
- package/dist/api.mjs +2 -0
- package/dist/{app-install-VPkI5WEg.mjs → app-install-D-PUENug.mjs} +3 -3
- package/dist/{attempt-Bk2ouQVL.mjs → attempt-DW-mQqM7.mjs} +14 -4
- package/dist/{budget-DfcgFdQB.mjs → budget-DIhL2BKx.mjs} +1578 -58
- package/dist/build-facts-DcLv2HSd.d.mts +111 -0
- package/dist/{cache-manifest-DnUHBJaU.mjs → cache-manifest-BI7ozfmH.mjs} +3 -3
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{chrome-BrcVWQyD.mjs → chrome-DJnmnS5q.mjs} +1 -1
- package/dist/cli-DNJMwADx.mjs +68 -0
- package/dist/cli.mjs +1 -1
- package/dist/{client-SvBdgObD.mjs → client-DzhapoMB.mjs} +139 -32
- package/dist/collector-run.mjs +9 -9
- package/dist/{command-output-CDAIFD-8.mjs → command-output-CBtzyIgF.mjs} +2 -2
- package/dist/{config-D0DbpZtM.mjs → config-CgYMahz7.mjs} +5 -5
- package/dist/{created-devices-CpvzBL25.mjs → created-devices-DKbeWsiK.mjs} +2 -2
- package/dist/{dependency-state-CLcBHH2M.mjs → dependency-state-xKoOypBm.mjs} +2 -2
- package/dist/{detached-entry-CiTEgMR1.mjs → detached-entry-BLfcgc4O.mjs} +1 -1
- package/dist/{dev-client-B-XC4uRH.mjs → dev-client-CLnIH02x.mjs} +2 -2
- package/dist/{device-C8IOoJPv.mjs → device-D7oCHGWi.mjs} +8 -8
- package/dist/{device-capacity-ZC4XSZ4R.mjs → device-capacity-EUOOYr8T.mjs} +13 -13
- package/dist/device-host-worker.mjs +19 -19
- package/dist/{device-ios-C2Um-XUR.mjs → device-ios-6MewKKnc.mjs} +13 -13
- package/dist/{device-lease-DpoS36_u.mjs → device-lease-Co-EwifR.mjs} +9 -9
- package/dist/{device-lease-run-B8YltIH_.mjs → device-lease-run-w1xhCqIW.mjs} +4 -4
- package/dist/{device-pool-3o7s5lo4.mjs → device-pool-F5WvRPtD.mjs} +3 -3
- package/dist/{device-remote-hFSkpfQu.mjs → device-remote-tHbd1fKy.mjs} +15 -15
- package/dist/{doctor-CFv1fCrF.mjs → doctor-B9ckYUoU.mjs} +33 -30
- package/dist/{error-diagnostics-C-NMnhrk.mjs → error-diagnostics-BRXOqDzG.mjs} +11 -11
- package/dist/{exec-CaErVv7t.mjs → exec-DWhCZDGm.mjs} +65 -2
- package/dist/{gc-DEmkg3Xh.mjs → gc-Dh6mXOKC.mjs} +23 -469
- package/dist/{gradle-dJpre3Yn.mjs → gradle-C6GKnunQ.mjs} +6 -6
- package/dist/{guide-status-Du-ZQ3FD.mjs → guide-status-Bhf9SJXc.mjs} +3 -3
- package/dist/{guide-CSmhMTf8.mjs → guide-tm6igAaa.mjs} +290 -53
- package/dist/{hosted-android-E1Heoqnv.mjs → hosted-android-Bv285t_t.mjs} +3 -3
- package/dist/{hosted-client-Bp4knSwu.mjs → hosted-client-C-rMtppF.mjs} +2 -2
- package/dist/{hosted-ios-BnbeYOUD.mjs → hosted-ios-D5mNmtj4.mjs} +1 -1
- package/dist/{hosted-logs-OcgIBvCT.mjs → hosted-logs-DN8Iz4mJ.mjs} +9 -9
- package/dist/{hosted-macos-DcxKjtfH.mjs → hosted-macos-B-wEjlwG.mjs} +5 -5
- package/dist/{hosted-native-1Ebbig4w.mjs → hosted-native-DeeOG8xZ.mjs} +6 -6
- package/dist/{idle-shutdown-IGyNV8Cr.mjs → idle-shutdown-jjtxAn5C.mjs} +7 -8
- package/dist/{ios-DSfnPfse.mjs → ios-B3SbOWdw.mjs} +19 -7
- package/dist/{ios-Cr1h5gnO.mjs → ios-Bvbf0SGY.mjs} +1 -1
- package/dist/{ios-BJ4XUSe1.mjs → ios-CPdkoKaa.mjs} +181 -95
- package/dist/ios-DNpdygiv.mjs +7 -0
- package/dist/{ios-device-Ee7sDXfp.mjs → ios-device-Bn7jWDB1.mjs} +1 -1
- package/dist/{ios-device-pAN4t54-.mjs → ios-device-vOaByMhw.mjs} +3 -3
- package/dist/{ios-state-8L3lgum6.mjs → ios-state-B2pES6Vs.mjs} +1 -1
- package/dist/{launch-verify-lTnWZikR.mjs → launch-verify-hskNcWkZ.mjs} +5 -5
- package/dist/{logs-BAaS7gS2.mjs → logs-1Ylc1Ri6.mjs} +13 -13
- package/dist/macos-Ck7OBMNY.mjs +2 -0
- package/dist/{macos-BIRQS90f.mjs → macos-DF6C7wUU.mjs} +118 -34
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +349 -47
- package/dist/{metro-g8NqiJp-.mjs → metro-Dh8T4Ytd.mjs} +5 -5
- package/dist/{metro-gateway-C-ijGI2F.mjs → metro-gateway-CEUw9RMH.mjs} +4 -4
- package/dist/{metro-store-CDDZHtPl.mjs → metro-store-BAHFcJm6.mjs} +16 -2
- package/dist/{named-ports-C8m8EQs2.mjs → named-ports-BFIz1Shz.mjs} +61 -6
- package/dist/{native-run-D1Q56rAD.mjs → native-run-B06FkmZx.mjs} +4 -4
- package/dist/{native-runtime-BEK171xQ.mjs → native-runtime-D_603JiC.mjs} +6 -6
- package/dist/{ndjson-PclOIwVY.mjs → ndjson-LGZAMsqa.mjs} +8 -4
- package/dist/offload-worker.d.mts +3 -17
- package/dist/offload-worker.mjs +10 -11
- package/dist/{ownership-DyRQru0q.mjs → ownership-D6Se7gg_.mjs} +3 -3
- package/dist/{page-QF_Ke10s.mjs → page-Bv9s2KwY.mjs} +1 -1
- package/dist/placement-log-BcPhRwR4.mjs +84 -0
- package/dist/{build-plan-BDsSi09V.mjs → plan-placement-CtxkCO54.mjs} +122 -48
- package/dist/{ports-4nYqxPWC.mjs → ports-BLTtfBq-.mjs} +3 -3
- package/dist/{prebuild-D7RUMkwN.mjs → prebuild-juCyreaR.mjs} +5 -5
- package/dist/preview-D5V07Nrl.mjs +987 -0
- package/dist/{rolldown-runtime-BsOwBuO_.mjs → process-identity-Biv3arCO.mjs} +11 -1
- package/dist/{project-D47Rh0ly.mjs → project-C3ChRLZy.mjs} +4 -68
- package/dist/projects-DD7dBTCj.mjs +92 -0
- package/dist/{pull-request-pxnDCQzn.mjs → pull-request-u4vp7zmK.mjs} +1 -1
- package/dist/pull-requests.mjs +1 -1
- package/dist/{recordings-BNgsD1Tr.mjs → recordings-BAWltsVt.mjs} +1 -1
- package/dist/{reload-DcRxj3qG.mjs → reload-DvyWzVjJ.mjs} +15 -15
- package/dist/{remote-cache-Ci4DQYYj.mjs → remote-cache-BGg7aGIZ.mjs} +5 -5
- package/dist/{run-CkE9y0nc.mjs → run-vhtDgpHO.mjs} +5 -5
- package/dist/{server-bare-BkrSxSsZ.mjs → server-bare-B9E7S1aR.mjs} +4 -5
- package/dist/server-expo-Db9HBUoa.mjs +2 -0
- package/dist/{server-expo-CHTyXD0G.mjs → server-expo-DoBHhuzK.mjs} +5 -6
- package/dist/{settings-SR9OmW9h.mjs → settings-Byp2AQ_E.mjs} +6 -5
- package/dist/{settings-Cfd-0r2d.mjs → settings-CQyMElEP.mjs} +24 -763
- package/dist/{settings-BBpMcDbD.mjs → settings-Djl-mpjX.mjs} +1 -1
- package/dist/settings.schema.json +126 -3
- package/dist/{simslim-BWNrc3M3.mjs → simslim-EHBQ2R4G.mjs} +7 -7
- package/dist/{slot-launch-DmjBmpQV.mjs → slot-launch-C1nqh4mu.mjs} +6 -6
- package/dist/{spawn-claims-D0XfSe8u.mjs → spawn-claims-Kqiifsk2.mjs} +1 -1
- package/dist/{spawn-entry-jw19m8Nl.mjs → spawn-entry-Dcb7sDUz.mjs} +1 -0
- package/dist/{stage-CzaiwFsI.mjs → stage-g_WqWeaE.mjs} +14 -3
- package/dist/{start-DUz3mYdb.mjs → start-D-IeOyoK.mjs} +19 -19
- package/dist/{start-AlfCPRVU.mjs → start-NTc1Ifqs.mjs} +1 -1
- package/dist/{state-PeQiJuIu.mjs → state-BG-aAk4k.mjs} +4 -4
- package/dist/{state-B4PQFXMW.d.mts → state-lKh8shBp.d.mts} +2 -3
- package/dist/{state-DyaNTgfR.mjs → state-xnqpx3AD.mjs} +2 -2
- package/dist/{stats-Bq4fJOdB.mjs → stats-DY6ekz8F.mjs} +5 -5
- package/dist/{status-DlKvVJBE.mjs → status-BEeL6IKz.mjs} +6 -4
- package/dist/{status-BA2pehwf.mjs → status-DCjZeE-K.mjs} +33 -34
- package/dist/{status-CzS4bPO9.mjs → status-Dcr0Qexd.mjs} +5 -5
- package/dist/{stim-desktop-Cnz8CPnl.mjs → stim-desktop-Behws_fi.mjs} +1 -1
- package/dist/{stim-installations-QMEI32v1.mjs → stim-installations-aR_WsNOA.mjs} +1 -1
- package/dist/{stop-BIiM49EY.mjs → stop-BGhKMOuH.mjs} +5 -5
- package/dist/{stop-DQIasgKp.mjs → stop-BTjs3xbc.mjs} +17 -18
- package/dist/{stop-zF1y04f2.mjs → stop-DIJtD2GL.mjs} +2 -2
- package/dist/supervisor-run.d.mts +24 -22
- package/dist/supervisor-run.mjs +21 -22
- package/dist/{support-CsJNVfOc.mjs → support-BaayeYCf.mjs} +7 -7
- package/dist/{support-WvD__tSV.mjs → support-Bwvbrq5-.mjs} +5 -5
- package/dist/{toolchain-DNyR3NPq.mjs → toolchain-Bnyd_K3A.mjs} +471 -22
- package/dist/{trigger-Bemu8ytw.mjs → trigger-CJMhwXe8.mjs} +5 -5
- package/dist/trigger-DWAq9hkw.mjs +2 -0
- package/dist/{warm-progress-DF4JRvYI.mjs → warm-progress-CjB-MP6H.mjs} +7 -7
- package/dist/web-B6_bFDn7.mjs +2 -0
- package/dist/{web-Dl0KSRHf.mjs → web-DTU0uiWj.mjs} +22 -22
- package/dist/web-run.mjs +10 -10
- package/dist/{workspace-state-DqcCbpE7.mjs → workspace-state-C59dqG-Z.mjs} +3 -3
- package/dist/{ownership-BMLqyBgJ.mjs → workspaces-xXItD8Dj.mjs} +577 -23
- package/dist/{worktree-j3IcFAI5.mjs → worktree-BJfnU6r5.mjs} +1 -1
- package/dist/{worktree-Be_7NLKy.mjs → worktree-BSYlofkq.mjs} +234 -35
- package/dist/worktree-CsKYexJM.mjs +753 -0
- package/package.json +10 -5
- package/dist/build-progress-D0WkjCPd.mjs +0 -1036
- package/dist/build-slots-41v_d2x9.mjs +0 -142
- package/dist/cli-CYXb29oE.mjs +0 -51
- package/dist/deps-iKw0eD4P.mjs +0 -438
- package/dist/errors-B6W7FkxQ.mjs +0 -15
- package/dist/idle-BXG__1BA.mjs +0 -176
- package/dist/in-use-CvGOUn-x.mjs +0 -130
- package/dist/preview-B-g9d7kV.mjs +0 -318
- package/dist/process-identity-BmRm1qV0.mjs +0 -12
- package/dist/server-expo-CeakhI8P.mjs +0 -2
- package/dist/state-BKa8wNN5.mjs +0 -148
- package/dist/stop-cause-rhmGfwvt.mjs +0 -97
- package/dist/trigger-CXts6qt1.mjs +0 -2
- package/dist/watchman-APYjXSQa.mjs +0 -48
- package/dist/workspace-process-lock-2mNzOlaB.mjs +0 -58
- package/dist/workspaces-Bcib97-6.mjs +0 -306
package/dist/idle-BXG__1BA.mjs
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { H as projectDeviceSlots } from "./config-D0DbpZtM.mjs";
|
|
2
|
-
import { o as formatLongDuration } from "./command-output-CDAIFD-8.mjs";
|
|
3
|
-
import { r as readWorkspaceState } from "./workspace-state-DqcCbpE7.mjs";
|
|
4
|
-
import { i as recordGcResult } from "./in-use-CvGOUn-x.mjs";
|
|
5
|
-
import { o as idleForMs, r as createActivityReader } from "./activity-IRvJY_ru.mjs";
|
|
6
|
-
import { z as ownedAvdSerialResolver } from "./android-B_YNZy61.mjs";
|
|
7
|
-
import { g as teardownOwnedIosSim, m as teardownOwnedAvd } from "./ownership-BMLqyBgJ.mjs";
|
|
8
|
-
import { r as activeBuildState, s as parseActiveBuild, t as ACTIVE_BUILD_KEY } from "./build-progress-D0WkjCPd.mjs";
|
|
9
|
-
import chalk from "chalk";
|
|
10
|
-
//#region src/commands/gc/idle.ts
|
|
11
|
-
function findOwnedDeviceActivity({ config, sims, androidSerial, readActivity, deadProjects = [] }) {
|
|
12
|
-
const booted = new Map(sims.filter((sim) => sim.state === "Booted").map((sim) => [sim.udid, sim.name]));
|
|
13
|
-
const dead = new Set(deadProjects);
|
|
14
|
-
const found = [];
|
|
15
|
-
for (const [project, record] of Object.entries(config?.projects ?? {})) {
|
|
16
|
-
if (dead.has(project)) continue;
|
|
17
|
-
for (const { slot, platforms } of projectDeviceSlots(record)) {
|
|
18
|
-
const ios = platforms.ios;
|
|
19
|
-
if (ios?.owned && ios.deviceUdid && booted.has(ios.deviceUdid)) found.push({
|
|
20
|
-
kind: "ios",
|
|
21
|
-
id: ios.deviceUdid,
|
|
22
|
-
name: booted.get(ios.deviceUdid) ?? ios.deviceUdid,
|
|
23
|
-
project,
|
|
24
|
-
slot,
|
|
25
|
-
activity: readActivity({
|
|
26
|
-
platform: "ios",
|
|
27
|
-
id: ios.deviceUdid,
|
|
28
|
-
slot,
|
|
29
|
-
workspace: project
|
|
30
|
-
})
|
|
31
|
-
});
|
|
32
|
-
const android = platforms.android;
|
|
33
|
-
const serial = android?.owned && android.avdName ? androidSerial(android.avdName) : null;
|
|
34
|
-
if (android?.avdName && serial) found.push({
|
|
35
|
-
kind: "android",
|
|
36
|
-
id: android.avdName,
|
|
37
|
-
name: android.avdName,
|
|
38
|
-
project,
|
|
39
|
-
slot,
|
|
40
|
-
activity: readActivity({
|
|
41
|
-
platform: "android",
|
|
42
|
-
id: serial,
|
|
43
|
-
slot,
|
|
44
|
-
workspace: project
|
|
45
|
-
})
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return found;
|
|
50
|
-
}
|
|
51
|
-
function findIdleDevices({ buildInProgress, now, ...inputs }) {
|
|
52
|
-
return findOwnedDeviceActivity(inputs).filter((device) => device.activity.state === "idle").map(({ kind, id, name, project, slot, activity }) => ({
|
|
53
|
-
kind,
|
|
54
|
-
id,
|
|
55
|
-
name,
|
|
56
|
-
project,
|
|
57
|
-
slot,
|
|
58
|
-
lastActivityAt: activity.lastActivityAt ?? null,
|
|
59
|
-
idleForMs: idleForMs(activity, now),
|
|
60
|
-
buildInProgress: buildInProgress(project)
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
function idleShutdownCandidates(devices, idleMs) {
|
|
64
|
-
return devices.filter((d) => !d.buildInProgress && d.idleForMs !== null && d.idleForMs >= idleMs);
|
|
65
|
-
}
|
|
66
|
-
function parseIdleDuration(value) {
|
|
67
|
-
const match = /^([1-9][0-9]*)(m|h|d)$/.exec(value.trim());
|
|
68
|
-
if (!match) return null;
|
|
69
|
-
const unit = {
|
|
70
|
-
m: 6e4,
|
|
71
|
-
h: 36e5,
|
|
72
|
-
d: 864e5
|
|
73
|
-
}[match[2]];
|
|
74
|
-
return Number(match[1]) * unit;
|
|
75
|
-
}
|
|
76
|
-
function workspaceBuildInProgress(project) {
|
|
77
|
-
const record = parseActiveBuild(readWorkspaceState(project)?.[ACTIVE_BUILD_KEY]);
|
|
78
|
-
if (!record) return false;
|
|
79
|
-
try {
|
|
80
|
-
return activeBuildState(record.claim) !== "stale";
|
|
81
|
-
} catch {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function deviceActivityInputs(config, sims, now) {
|
|
86
|
-
const resolve = ownedAvdSerialResolver({ timeoutMs: 5e3 });
|
|
87
|
-
return {
|
|
88
|
-
config,
|
|
89
|
-
sims,
|
|
90
|
-
readActivity: createActivityReader({ now }),
|
|
91
|
-
androidSerial: (avdName) => {
|
|
92
|
-
try {
|
|
93
|
-
return resolve(avdName).serial ?? null;
|
|
94
|
-
} catch {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function collectOwnedDeviceActivity(config, sims, now = Date.now()) {
|
|
101
|
-
return findOwnedDeviceActivity(deviceActivityInputs(config, sims, now));
|
|
102
|
-
}
|
|
103
|
-
function collectIdleDevices(config, sims, deadProjects, now = Date.now()) {
|
|
104
|
-
return findIdleDevices({
|
|
105
|
-
...deviceActivityInputs(config, sims, now),
|
|
106
|
-
deadProjects,
|
|
107
|
-
now,
|
|
108
|
-
buildInProgress: workspaceBuildInProgress
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function idleDeviceLines(devices) {
|
|
112
|
-
if (devices.length === 0) return [];
|
|
113
|
-
return [`Idle owned devices (${devices.length}) - booted with no driver, claim, or recent activity:`, ...devices.map((d) => {
|
|
114
|
-
const slot = d.slot === "default" ? "" : ` [${d.slot}]`;
|
|
115
|
-
const idle = d.idleForMs === null ? "idle for an unknown time" : `idle ${formatLongDuration(d.idleForMs)}`;
|
|
116
|
-
const build = d.buildInProgress ? ", build in progress" : "";
|
|
117
|
-
return ` ${d.kind}${slot} ${d.name} (${d.project}) -- ${idle}${build}`;
|
|
118
|
-
})];
|
|
119
|
-
}
|
|
120
|
-
function shutDownIdleDevices(devices, idleMs, recollect) {
|
|
121
|
-
const candidates = idleShutdownCandidates(devices, idleMs);
|
|
122
|
-
const shutDown = [];
|
|
123
|
-
if (candidates.length === 0) {
|
|
124
|
-
console.log(chalk.dim(`No owned device has been idle for ${formatLongDuration(idleMs)} or more.`));
|
|
125
|
-
return {
|
|
126
|
-
failures: 0,
|
|
127
|
-
shutDown
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const fresh = idleShutdownCandidates(recollect(), idleMs);
|
|
131
|
-
let failures = 0;
|
|
132
|
-
for (const device of candidates) {
|
|
133
|
-
const what = `${device.kind} ${device.name}`;
|
|
134
|
-
const current = fresh.find((d) => d.kind === device.kind && d.id === device.id && d.project === device.project && d.slot === device.slot);
|
|
135
|
-
if (!current) {
|
|
136
|
-
console.log(chalk.dim(`Kept ${what}: it is no longer idle for ${formatLongDuration(idleMs)}.`));
|
|
137
|
-
recordGcResult("idleDevice", "kept", device.name, {
|
|
138
|
-
id: device.id,
|
|
139
|
-
detail: `it is no longer idle for ${formatLongDuration(idleMs)}`
|
|
140
|
-
});
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const outcome = device.kind === "ios" ? teardownOwnedIosSim(device.id, { label: device.name }) : teardownOwnedAvd(device.id, { owner: {
|
|
144
|
-
projectPath: device.project,
|
|
145
|
-
slot: device.slot
|
|
146
|
-
} });
|
|
147
|
-
if (outcome.status === "torn-down") {
|
|
148
|
-
shutDown.push(device);
|
|
149
|
-
console.log(chalk.green(`Shut down ${what}, idle ${formatLongDuration(current.idleForMs)}`));
|
|
150
|
-
recordGcResult("idleDevice", "done", device.name, {
|
|
151
|
-
id: device.id,
|
|
152
|
-
detail: `idle ${formatLongDuration(current.idleForMs)}`
|
|
153
|
-
});
|
|
154
|
-
} else if (outcome.status === "missing") console.log(chalk.dim(`${what} is already gone; nothing to shut down.`));
|
|
155
|
-
else if (outcome.status === "skipped") {
|
|
156
|
-
console.log(chalk.yellow(`Skipped ${what}: ${outcome.reason}`));
|
|
157
|
-
recordGcResult("idleDevice", "kept", device.name, {
|
|
158
|
-
id: device.id,
|
|
159
|
-
detail: outcome.reason
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
failures++;
|
|
163
|
-
console.log(chalk.red(`Failed to shut down ${what}: ${outcome.reason}`));
|
|
164
|
-
recordGcResult("idleDevice", "failed", device.name, {
|
|
165
|
-
id: device.id,
|
|
166
|
-
detail: outcome.reason
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
failures,
|
|
172
|
-
shutDown
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
export { parseIdleDuration as a, idleShutdownCandidates as i, collectOwnedDeviceActivity as n, shutDownIdleDevices as o, idleDeviceLines as r, workspaceBuildInProgress as s, collectIdleDevices as t };
|
package/dist/in-use-CvGOUn-x.mjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { p as getProject } from "./config-D0DbpZtM.mjs";
|
|
2
|
-
import { n as ownership_claim_exports } from "./process-identity-BmRm1qV0.mjs";
|
|
3
|
-
import { r as readWorkspaceState$1, v as workspaceDir } from "./workspace-state-DqcCbpE7.mjs";
|
|
4
|
-
import { o as readWebRecord, u as webFacts } from "./state-PeQiJuIu.mjs";
|
|
5
|
-
import { h as listBuildLocks } from "./device-lease-DpoS36_u.mjs";
|
|
6
|
-
import { n as listBuildSlots } from "./build-slots-41v_d2x9.mjs";
|
|
7
|
-
import { n as managedLockHolders, t as resolveSupervisorTarget } from "./ownership-BMLqyBgJ.mjs";
|
|
8
|
-
import { n as workspaceProcessLockError, r as workspaceProcessLockPath, t as withWorkspaceProcessLock } from "./workspace-process-lock-2mNzOlaB.mjs";
|
|
9
|
-
import { i as macosRuntimeClaim } from "./state-DyaNTgfR.mjs";
|
|
10
|
-
import { lstatSync, readdirSync, rmSync, rmdirSync, unlinkSync } from "node:fs";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { realpathSync as realpathSync$1 } from "fs";
|
|
13
|
-
import { resolve as resolve$1 } from "path";
|
|
14
|
-
import { hostedNativeRecords, macosAppState, parseHostedNativePlacement, readMacosRecord, unreadableHostedNative } from "@stim-cli/core/state";
|
|
15
|
-
//#region src/commands/gc/paths.ts
|
|
16
|
-
function canonicalPath(p) {
|
|
17
|
-
try {
|
|
18
|
-
return realpathSync$1(p);
|
|
19
|
-
} catch {
|
|
20
|
-
return resolve$1(p);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/commands/gc/results.ts
|
|
25
|
-
const results = [];
|
|
26
|
-
function recordGcResult(kind, status, label, { id = null, bytes = null, detail = null } = {}) {
|
|
27
|
-
results.push({
|
|
28
|
-
kind,
|
|
29
|
-
status,
|
|
30
|
-
label,
|
|
31
|
-
id,
|
|
32
|
-
bytes,
|
|
33
|
-
detail
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function takeGcResults() {
|
|
37
|
-
return results.splice(0);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/workspace/in-use.ts
|
|
41
|
-
const NATIVE_RUN = "native-run";
|
|
42
|
-
const NATIVE_RUN_HELD = "a stim ios, android or stop run holds its native-run.lock";
|
|
43
|
-
function workspaceInUse(root, { supervisor = true, managedLocks = true, hosted = true, nativeRun = true } = {}) {
|
|
44
|
-
const reasons = [];
|
|
45
|
-
if (supervisor) {
|
|
46
|
-
const project = getProject(root);
|
|
47
|
-
const target = resolveSupervisorTarget({
|
|
48
|
-
state: readWorkspaceState$1(root)?.supervisor,
|
|
49
|
-
record: project?.supervisor,
|
|
50
|
-
reservedPort: project?.metroPort
|
|
51
|
-
});
|
|
52
|
-
if (target.status === "ours") reasons.push(`its dev server supervisor (pid ${target.pid}) is running`);
|
|
53
|
-
else if (target.status === "unverified") reasons.push(`its dev server supervisor cannot be verified: ${target.reason ?? "unknown identity"}`);
|
|
54
|
-
const macos = macosAppState(readMacosRecord(root));
|
|
55
|
-
if (macos?.host) reasons.push(`its macOS app runs on ${macos.host.machine}`);
|
|
56
|
-
else if (macos?.state === "running" || macos?.state === "orphaned" || macos?.build.state === "running") reasons.push("its macOS app or build is running");
|
|
57
|
-
else if (macos?.state === "unverified" || !macos && readWorkspaceState$1(root)?.macos !== void 0) reasons.push("its macOS process owner cannot be verified");
|
|
58
|
-
const runtime = (0, ownership_claim_exports.readClaimSet)(macosRuntimeClaim(root));
|
|
59
|
-
if (runtime.live.length) reasons.push("its macOS runtime claim is held");
|
|
60
|
-
else if (runtime.unresolved[0]) reasons.push(`its macOS runtime cannot be verified: ${runtime.unresolved[0].reason}`);
|
|
61
|
-
const browser = webFacts(readWebRecord(root));
|
|
62
|
-
if (browser?.status === "running" || browser?.status === "orphaned") reasons.push(`its owned Chrome (pid ${browser.record.chromeProcess?.pid}) is running`);
|
|
63
|
-
else if (browser?.status === "unverified") reasons.push("its owned Chrome cannot be verified");
|
|
64
|
-
}
|
|
65
|
-
if (nativeRun) {
|
|
66
|
-
const claims = (0, ownership_claim_exports.readClaimSet)(workspaceProcessLockPath(workspaceDir(root), NATIVE_RUN, true));
|
|
67
|
-
if (claims.live.length) reasons.push(NATIVE_RUN_HELD);
|
|
68
|
-
else if (claims.unresolved[0]) reasons.push(`its native-run.lock cannot be resolved: ${claims.unresolved[0].reason}`);
|
|
69
|
-
}
|
|
70
|
-
for (const platform of ["ios", "android"]) for (const [slot, record] of Object.entries(hosted ? hostedNativeRecords(readWorkspaceState$1(root), platform) : {})) {
|
|
71
|
-
const placement = parseHostedNativePlacement(record, platform);
|
|
72
|
-
reasons.push(placement ? `its ${platform === "ios" ? "iOS simulator" : "Android emulator"} runs on ${placement.machine}` : unreadableHostedNative(slot, platform));
|
|
73
|
-
}
|
|
74
|
-
const self = canonicalPath(root);
|
|
75
|
-
for (const [kind, entries] of [["build lock", listBuildLocks()], ["build slot", listBuildSlots()]]) for (const entry of entries) {
|
|
76
|
-
if (!entry.alive && !entry.unresolved) continue;
|
|
77
|
-
if (entry.projectRoot !== null && canonicalPath(entry.projectRoot) === self) reasons.push(`a ${entry.alive ? "live" : "unresolvable"} ${kind} at ${entry.path} names it`);
|
|
78
|
-
}
|
|
79
|
-
if (managedLocks) reasons.push(...managedLockHolders(root));
|
|
80
|
-
return reasons;
|
|
81
|
-
}
|
|
82
|
-
function emptyWorkspaceDir(dir) {
|
|
83
|
-
if (lstatSync(dir).isSymbolicLink()) {
|
|
84
|
-
unlinkSync(dir);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
for (const name of readdirSync(dir)) if (name !== `${NATIVE_RUN}.lock`) rmSync(join(dir, name), {
|
|
88
|
-
recursive: true,
|
|
89
|
-
force: true
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
async function withIdleWorkspace(root, fn, { purpose, ...checks }) {
|
|
93
|
-
try {
|
|
94
|
-
return await withWorkspaceProcessLock(workspaceDir(root), NATIVE_RUN, async () => {
|
|
95
|
-
const reasons = workspaceInUse(root, {
|
|
96
|
-
...checks,
|
|
97
|
-
nativeRun: false
|
|
98
|
-
});
|
|
99
|
-
if (reasons.length) return {
|
|
100
|
-
ran: false,
|
|
101
|
-
reasons
|
|
102
|
-
};
|
|
103
|
-
return {
|
|
104
|
-
ran: true,
|
|
105
|
-
value: await fn()
|
|
106
|
-
};
|
|
107
|
-
}, {
|
|
108
|
-
external: true,
|
|
109
|
-
waitMs: 0,
|
|
110
|
-
ownerPurpose: purpose
|
|
111
|
-
});
|
|
112
|
-
} catch (error) {
|
|
113
|
-
if (workspaceProcessLockError(error)) return {
|
|
114
|
-
ran: false,
|
|
115
|
-
reasons: [NATIVE_RUN_HELD]
|
|
116
|
-
};
|
|
117
|
-
if ((0, ownership_claim_exports.isClaimRefusal)(error) || (0, ownership_claim_exports.isClaimUnavailable)(error)) return {
|
|
118
|
-
ran: false,
|
|
119
|
-
reasons: [`its native-run.lock cannot be taken: ${error.reason}`]
|
|
120
|
-
};
|
|
121
|
-
throw error;
|
|
122
|
-
} finally {
|
|
123
|
-
try {
|
|
124
|
-
const dir = workspaceDir(root);
|
|
125
|
-
if (!lstatSync(dir).isSymbolicLink()) rmdirSync(dir);
|
|
126
|
-
} catch {}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
export { takeGcResults as a, recordGcResult as i, withIdleWorkspace as n, canonicalPath as o, workspaceInUse as r, emptyWorkspaceDir as t };
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { P as measuredDirectorySize } from "./config-D0DbpZtM.mjs";
|
|
2
|
-
import { s as findProjectRoot$1 } from "./project-D47Rh0ly.mjs";
|
|
3
|
-
import { M as planCacheEmptying, Q as discoverCaches, c as resolveBudget, r as enforceBudget, s as readVolumeSpace } from "./budget-DfcgFdQB.mjs";
|
|
4
|
-
import { o as canonicalPath } from "./in-use-CvGOUn-x.mjs";
|
|
5
|
-
import { h as listBuildLocks } from "./device-lease-DpoS36_u.mjs";
|
|
6
|
-
import { n as listBuildSlots } from "./build-slots-41v_d2x9.mjs";
|
|
7
|
-
import { j as readHostMemoryPressure } from "./ios-DSfnPfse.mjs";
|
|
8
|
-
import { a as collectWorkspaceOutputs } from "./workspaces-Bcib97-6.mjs";
|
|
9
|
-
import { t as resolveMaintenanceSettings } from "./settings-BBpMcDbD.mjs";
|
|
10
|
-
import { existsSync } from "node:fs";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { buildCacheRoot, configDir, metroCacheRoot } from "@stim-cli/core";
|
|
13
|
-
import { buildWorkerRoot, loadConfig, readMaintenanceState, sharedCcache, sharedCompilationCache } from "@stim-cli/core/state";
|
|
14
|
-
import { cpus, freemem, loadavg, totalmem } from "node:os";
|
|
15
|
-
//#region src/maintenance/measure.ts
|
|
16
|
-
function measurePressure(settings, previous, now) {
|
|
17
|
-
const config = loadConfig();
|
|
18
|
-
const level = readHostMemoryPressure();
|
|
19
|
-
const availableBytes = process.platform === "darwin" ? null : freemem();
|
|
20
|
-
const warningSince = level === "warning" ? previous?.warningSince ?? now : null;
|
|
21
|
-
const pressured = settings.memoryPressureLevel !== "off" && (level === "critical" || settings.memoryPressureLevel === "warning" && warningSince !== null && now - warningSince >= settings.memoryWarningMinutes * 6e4 || availableBytes !== null && availableBytes < (settings.minAvailableMemoryGb === void 0 ? totalmem() * .1 : settings.minAvailableMemoryGb * 1024 ** 3));
|
|
22
|
-
return {
|
|
23
|
-
disk: readVolumeSpace([
|
|
24
|
-
configDir(),
|
|
25
|
-
...Object.keys(config?.projects ?? {}),
|
|
26
|
-
buildWorkerRoot(config)
|
|
27
|
-
]),
|
|
28
|
-
memory: {
|
|
29
|
-
level,
|
|
30
|
-
availableBytes,
|
|
31
|
-
pressured
|
|
32
|
-
},
|
|
33
|
-
warningSince
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function sizeScanDeferred(settings) {
|
|
37
|
-
return loadavg()[0] / Math.max(1, cpus().length) > settings.maxLoadPerCore;
|
|
38
|
-
}
|
|
39
|
-
function cacheBlocked(entry, discovered = discoverCaches()) {
|
|
40
|
-
return planCacheEmptying([{
|
|
41
|
-
...entry,
|
|
42
|
-
note: "",
|
|
43
|
-
prune: "entries",
|
|
44
|
-
...discovered.some((cache) => canonicalPath(cache.dir) === canonicalPath(entry.dir) && cache.source === "registered") ? { source: "registered" } : {}
|
|
45
|
-
}], false)[0]?.machineGlobal ?? (entry.category === "compilation-cache" && [...listBuildLocks(), ...listBuildSlots()].some((item) => item.alive || item.unresolved) ? "a build lock or slot is live or unresolved" : void 0);
|
|
46
|
-
}
|
|
47
|
-
function measureSizes(now, failure) {
|
|
48
|
-
const sizes = [];
|
|
49
|
-
const outputs = collectWorkspaceOutputs({
|
|
50
|
-
olderThan: null,
|
|
51
|
-
now,
|
|
52
|
-
sizeTimeoutMs: 12e4
|
|
53
|
-
});
|
|
54
|
-
for (const entry of outputs.workspaces) {
|
|
55
|
-
if (entry.bytes === null) {
|
|
56
|
-
failure(entry.dir, entry.projectRoot ?? void 0);
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
sizes.push({
|
|
60
|
-
name: "workspace build outputs",
|
|
61
|
-
category: "workspace-outputs",
|
|
62
|
-
dir: entry.dir,
|
|
63
|
-
bytes: entry.bytes,
|
|
64
|
-
measuredAt: now,
|
|
65
|
-
...entry.projectRoot ? { workspace: canonicalPath(entry.projectRoot) } : {},
|
|
66
|
-
idleDays: entry.idleDays,
|
|
67
|
-
...!entry.willClear ? { blocked: entry.keptReason ?? "workspace ownership is unresolved" } : {}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const known = [
|
|
71
|
-
{
|
|
72
|
-
name: "shared build cache",
|
|
73
|
-
dir: buildCacheRoot(),
|
|
74
|
-
category: "build-cache"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "Metro transform caches",
|
|
78
|
-
dir: metroCacheRoot(),
|
|
79
|
-
category: "metro-cache"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "ccache",
|
|
83
|
-
dir: sharedCcache(),
|
|
84
|
-
category: "ccache"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "Swift compilation cache",
|
|
88
|
-
dir: sharedCompilationCache(),
|
|
89
|
-
category: "compilation-cache"
|
|
90
|
-
}
|
|
91
|
-
];
|
|
92
|
-
const discovered = discoverCaches();
|
|
93
|
-
for (const cache of discovered) {
|
|
94
|
-
if (cache.source !== "registered" && !canonicalPath(cache.dir).startsWith(`${canonicalPath(configDir())}/`)) continue;
|
|
95
|
-
if (cache.prune === "report-only") continue;
|
|
96
|
-
const dir = canonicalPath(cache.dir);
|
|
97
|
-
if (known.some((item) => dir === canonicalPath(item.dir) || dir.startsWith(`${canonicalPath(item.dir)}/`))) continue;
|
|
98
|
-
const category = cache.name.startsWith("Metro transform cache") ? "metro-cache" : /^(Expo build cache|native build cache|Build cache)$/.test(cache.name) ? "build-cache" : "other";
|
|
99
|
-
known.push({
|
|
100
|
-
name: cache.name,
|
|
101
|
-
dir: cache.dir,
|
|
102
|
-
category
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
for (const entry of known) {
|
|
106
|
-
if (!existsSync(entry.dir)) continue;
|
|
107
|
-
const bytes = measuredDirectorySize(entry.dir, { timeoutMs: 12e4 });
|
|
108
|
-
if (bytes === null) {
|
|
109
|
-
failure(entry.dir);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
const blocked = cacheBlocked(entry, discovered);
|
|
113
|
-
sizes.push({
|
|
114
|
-
...entry,
|
|
115
|
-
bytes,
|
|
116
|
-
measuredAt: now,
|
|
117
|
-
...blocked ? { blocked } : {}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
return sizes;
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/maintenance/plan.ts
|
|
124
|
-
function plan({ pressure, sizes, settings, budget, diskSteps = [], protectedRoot, scoped = false, projects = [] }) {
|
|
125
|
-
const actions = [];
|
|
126
|
-
const blocked = [];
|
|
127
|
-
const skips = [];
|
|
128
|
-
const add = (action) => {
|
|
129
|
-
if (!actions.some((entry) => entry.kind === action.kind && entry.target === action.target)) actions.push(action);
|
|
130
|
-
};
|
|
131
|
-
const floor = Math.max(budget.minFreeDiskMb, budget.hardFloorDiskMb);
|
|
132
|
-
const low = pressure?.disk.filter((disk) => disk.freeMb < floor) ?? [];
|
|
133
|
-
const reason = low.map((disk) => `free disk ${(disk.freeMb / 1024).toFixed(1)}G on ${disk.volume} under the ${(floor / 1024).toFixed(1)}G floor`).join("; ");
|
|
134
|
-
const kinds = {
|
|
135
|
-
"idle-devices": "would-shutdown-device",
|
|
136
|
-
"idle-dev-servers": "would-stop-workspace",
|
|
137
|
-
"workspace-outputs": "would-clear-outputs",
|
|
138
|
-
"stale-cache-entries": "would-trim-cache"
|
|
139
|
-
};
|
|
140
|
-
if (low.length) {
|
|
141
|
-
for (const step of diskSteps) {
|
|
142
|
-
if (scoped && step.step === "idle-devices") continue;
|
|
143
|
-
for (const target of step.targets) {
|
|
144
|
-
const workspace = projects.find((root) => root === target || target.endsWith(` in ${root}`)) ?? (step.step === "idle-dev-servers" || step.step === "workspace-outputs" ? target : void 0);
|
|
145
|
-
if (workspace === protectedRoot || target === protectedRoot) continue;
|
|
146
|
-
const size = workspace && step.step !== "idle-devices" ? sizes.find((entry) => entry.workspace === workspace && entry.category === "workspace-outputs") : void 0;
|
|
147
|
-
add({
|
|
148
|
-
kind: kinds[step.step],
|
|
149
|
-
target,
|
|
150
|
-
bytes: step.step === "workspace-outputs" ? size?.bytes ?? 0 : 0,
|
|
151
|
-
reason: `${size?.idleDays == null ? "" : `idle ${size.idleDays} days, `}${reason}`,
|
|
152
|
-
...workspace ? { workspace } : {}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if (step.failures) blocked.push(`Could not plan ${step.step}: ${step.failures} failures`);
|
|
156
|
-
}
|
|
157
|
-
if (actions.length === 0) blocked.push(`${reason}; no reclaimable disk targets`);
|
|
158
|
-
}
|
|
159
|
-
const caps = [
|
|
160
|
-
[
|
|
161
|
-
"workspace-outputs",
|
|
162
|
-
settings.workspaceOutputsMaxGb,
|
|
163
|
-
"would-clear-outputs"
|
|
164
|
-
],
|
|
165
|
-
[
|
|
166
|
-
"build-cache",
|
|
167
|
-
settings.buildCacheMaxGb,
|
|
168
|
-
"would-trim-cache"
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
"metro-cache",
|
|
172
|
-
settings.metroCacheMaxGb,
|
|
173
|
-
"would-trim-cache"
|
|
174
|
-
],
|
|
175
|
-
[
|
|
176
|
-
"compilation-cache",
|
|
177
|
-
settings.swiftCompilationCacheMaxGb,
|
|
178
|
-
"would-empty-cache"
|
|
179
|
-
]
|
|
180
|
-
];
|
|
181
|
-
for (const [category, capGb, kind] of caps) {
|
|
182
|
-
const entries = sizes.filter((size) => size.category === category);
|
|
183
|
-
const total = entries.reduce((sum, size) => sum + size.bytes, 0);
|
|
184
|
-
const cap = capGb * 1024 ** 3;
|
|
185
|
-
if (cap === 0 || total <= cap) continue;
|
|
186
|
-
let remaining = total;
|
|
187
|
-
const targetBytes = cap * settings.capTargetPercent / 100;
|
|
188
|
-
const why = `${category} ${(total / 1024 ** 3).toFixed(1)}G over the ${capGb}G cap; target ${(targetBytes / 1024 ** 3).toFixed(1)}G`;
|
|
189
|
-
for (const size of entries.toSorted((a, b) => (b.idleDays ?? 0) - (a.idleDays ?? 0))) {
|
|
190
|
-
if (remaining <= targetBytes) break;
|
|
191
|
-
const kept = size.workspace === protectedRoot ? "the triggering workspace is protected" : size.blocked;
|
|
192
|
-
if (kept) {
|
|
193
|
-
skips.push({
|
|
194
|
-
target: size.dir,
|
|
195
|
-
reason: kept,
|
|
196
|
-
...size.workspace ? { workspace: size.workspace } : {}
|
|
197
|
-
});
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
const bytes = kind === "would-trim-cache" ? Math.min(size.bytes, remaining - targetBytes) : size.bytes;
|
|
201
|
-
add({
|
|
202
|
-
kind,
|
|
203
|
-
target: size.workspace ?? size.dir,
|
|
204
|
-
bytes,
|
|
205
|
-
reason: `${!size.workspace || size.idleDays == null ? "" : `idle ${size.idleDays} days, `}${why}`,
|
|
206
|
-
...size.workspace ? { workspace: size.workspace } : {}
|
|
207
|
-
});
|
|
208
|
-
remaining -= bytes;
|
|
209
|
-
}
|
|
210
|
-
if (remaining > targetBytes) blocked.push(`${why}; eligible targets cannot reach the target`);
|
|
211
|
-
}
|
|
212
|
-
if (pressure?.memory.pressured) skips.push({
|
|
213
|
-
target: "memory",
|
|
214
|
-
reason: "memory pressure observed; stopping helpers and idle workspaces is not active in report-only mode"
|
|
215
|
-
});
|
|
216
|
-
return {
|
|
217
|
-
actions,
|
|
218
|
-
blocked,
|
|
219
|
-
skips
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/maintenance/preview.ts
|
|
224
|
-
function triggeringRoot() {
|
|
225
|
-
return canonicalPath(findProjectRoot$1(process.cwd()) ?? join(configDir(), "maintenance", "no-project"));
|
|
226
|
-
}
|
|
227
|
-
async function plannedMaintenance(pressure, sizes, settings, { devices = true } = {}) {
|
|
228
|
-
const resolved = resolveBudget();
|
|
229
|
-
if (resolved.error) throw new Error(resolved.error);
|
|
230
|
-
const budget = {
|
|
231
|
-
...resolved.budget,
|
|
232
|
-
maxCommittedMemoryMb: 0,
|
|
233
|
-
maxLiveWorkspaces: 0
|
|
234
|
-
};
|
|
235
|
-
const root = triggeringRoot();
|
|
236
|
-
const floor = Math.max(budget.minFreeDiskMb, budget.hardFloorDiskMb);
|
|
237
|
-
const low = pressure?.disk.some((disk) => disk.freeMb < floor);
|
|
238
|
-
const outcome = low ? await enforceBudget({
|
|
239
|
-
root,
|
|
240
|
-
note: () => {},
|
|
241
|
-
dryRun: true,
|
|
242
|
-
budget
|
|
243
|
-
}, { volumes: () => pressure.disk }) : null;
|
|
244
|
-
if (outcome && outcome.status !== "ok") throw new Error(outcome.refusal.message);
|
|
245
|
-
const outputs = collectWorkspaceOutputs({
|
|
246
|
-
olderThan: null,
|
|
247
|
-
now: Date.now(),
|
|
248
|
-
measure: false
|
|
249
|
-
});
|
|
250
|
-
const result = plan({
|
|
251
|
-
pressure,
|
|
252
|
-
sizes: sizes.map((size) => {
|
|
253
|
-
if (size.category === "compilation-cache") return {
|
|
254
|
-
...size,
|
|
255
|
-
blocked: cacheBlocked(size)
|
|
256
|
-
};
|
|
257
|
-
if (!size.workspace) return size;
|
|
258
|
-
const current = outputs.workspaces.find((entry) => entry.projectRoot && canonicalPath(entry.projectRoot) === size.workspace);
|
|
259
|
-
return Object.assign({}, size, { blocked: current?.willClear ? void 0 : current?.keptReason ?? "workspace outputs cannot be resolved" });
|
|
260
|
-
}),
|
|
261
|
-
settings,
|
|
262
|
-
budget,
|
|
263
|
-
diskSteps: outcome?.status === "ok" ? outcome.reclaimed.filter((step) => devices || step.step !== "idle-devices") : [],
|
|
264
|
-
protectedRoot: root,
|
|
265
|
-
scoped: Boolean(process.env.STIM_HOME),
|
|
266
|
-
projects: Object.keys(loadConfig()?.projects ?? {}).map(canonicalPath)
|
|
267
|
-
});
|
|
268
|
-
if (low) result.skips.push(...outputs.workspaces.filter((entry) => !entry.willClear && entry.keptReason).map((entry) => ({
|
|
269
|
-
target: entry.dir,
|
|
270
|
-
reason: entry.keptReason,
|
|
271
|
-
workspace: entry.projectRoot ?? void 0
|
|
272
|
-
})));
|
|
273
|
-
return result;
|
|
274
|
-
}
|
|
275
|
-
async function previewMaintenance({ devices = true } = {}) {
|
|
276
|
-
let settings;
|
|
277
|
-
try {
|
|
278
|
-
settings = resolveMaintenanceSettings();
|
|
279
|
-
const state = readMaintenanceState();
|
|
280
|
-
if (settings.invalid && settings.mode === "off") return {
|
|
281
|
-
mode: "off",
|
|
282
|
-
pressure: null,
|
|
283
|
-
actions: [],
|
|
284
|
-
blocked: [],
|
|
285
|
-
skips: [],
|
|
286
|
-
invalid: settings.invalid,
|
|
287
|
-
note: settings.invalid
|
|
288
|
-
};
|
|
289
|
-
if (settings.mode === "off") return {
|
|
290
|
-
mode: "off",
|
|
291
|
-
pressure: null,
|
|
292
|
-
actions: [],
|
|
293
|
-
blocked: [],
|
|
294
|
-
skips: [],
|
|
295
|
-
note: "maintenance.mode is off"
|
|
296
|
-
};
|
|
297
|
-
const pressure = measurePressure(settings, state?.pressure ?? null, Date.now());
|
|
298
|
-
return {
|
|
299
|
-
...await plannedMaintenance(pressure, state?.sizes ?? [], settings, { devices }),
|
|
300
|
-
mode: settings.mode,
|
|
301
|
-
...settings.invalid ? { invalid: settings.invalid } : {},
|
|
302
|
-
pressure,
|
|
303
|
-
note: settings.invalid ?? (state === null ? "no pass has run yet; sizes have not been measured" : null)
|
|
304
|
-
};
|
|
305
|
-
} catch (error) {
|
|
306
|
-
return {
|
|
307
|
-
mode: settings?.mode ?? "off",
|
|
308
|
-
...settings?.invalid ? { invalid: settings.invalid } : {},
|
|
309
|
-
pressure: null,
|
|
310
|
-
actions: [],
|
|
311
|
-
blocked: [String(error)],
|
|
312
|
-
skips: [],
|
|
313
|
-
note: "maintenance preview failed"
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
//#endregion
|
|
318
|
-
export { sizeScanDeferred as a, measureSizes as i, previewMaintenance as n, measurePressure as r, plannedMaintenance as t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { n as __exportAll, r as __reExport } from "./rolldown-runtime-BsOwBuO_.mjs";
|
|
2
|
-
//#region src/ownership-claim.ts
|
|
3
|
-
var ownership_claim_exports = /* @__PURE__ */ __exportAll({});
|
|
4
|
-
import * as import__stim_cli_core_ownership_claim from "@stim-cli/core/ownership-claim";
|
|
5
|
-
__reExport(ownership_claim_exports, import__stim_cli_core_ownership_claim);
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/process-identity.ts
|
|
8
|
-
var process_identity_exports = /* @__PURE__ */ __exportAll({});
|
|
9
|
-
import * as import__stim_cli_core_process_identity from "@stim-cli/core/process-identity";
|
|
10
|
-
__reExport(process_identity_exports, import__stim_cli_core_process_identity);
|
|
11
|
-
//#endregion
|
|
12
|
-
export { ownership_claim_exports as n, process_identity_exports as t };
|