stim 1.17.2 → 1.19.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-BSw0x84R.mjs} +4 -4
- package/dist/{agent-device-usage-output-BK41vnzN.mjs → agent-device-usage-output-Bjxu_VmX.mjs} +8 -8
- package/dist/{android-B9yaNKwa.mjs → android-BXc6BmEi.mjs} +658 -404
- package/dist/{android-B_YNZy61.mjs → android-BdQC6zs1.mjs} +9 -9
- package/dist/android-BvV1gGdN.mjs +4 -0
- package/dist/{android-DE4v59Mb.mjs → android-DE5g_5gv.mjs} +2 -2
- package/dist/{android-cas-ZFpjJBL_.mjs → android-cas-C87geAg-.mjs} +5 -5
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/api-DIf_s86s.mjs +150 -0
- package/dist/api-run.d.mts +1 -0
- package/dist/api-run.mjs +145 -0
- package/dist/api.d.mts +218 -0
- package/dist/api.mjs +2 -0
- package/dist/{app-install-VPkI5WEg.mjs → app-install-CFI4ptUL.mjs} +33 -13
- package/dist/{attempt-Bk2ouQVL.mjs → attempt-DW-mQqM7.mjs} +14 -4
- package/dist/{web-Dl0KSRHf.mjs → browser-web-CDhqQxhv.mjs} +138 -176
- package/dist/{budget-DfcgFdQB.mjs → budget-Dz-kyXLv.mjs} +1391 -58
- package/dist/build-facts-B87vo-Im.d.mts +142 -0
- package/dist/{cache-manifest-DnUHBJaU.mjs → cache-manifest-DiwKSyv9.mjs} +3 -3
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{chrome-BrcVWQyD.mjs → chrome-BTUOo8p2.mjs} +1 -1
- package/dist/cli-C9Zvgbdc.mjs +68 -0
- package/dist/cli.mjs +1 -1
- package/dist/{client-SvBdgObD.mjs → client-CuUo8Nvg.mjs} +381 -49
- package/dist/collector-run.d.mts +6 -0
- package/dist/collector-run.mjs +9 -9
- package/dist/{command-output-CDAIFD-8.mjs → command-output-Bt8ygHE7.mjs} +2 -2
- package/dist/{config-D0DbpZtM.mjs → config-DC5jEtd1.mjs} +9 -5
- package/dist/{created-devices-CpvzBL25.mjs → created-devices-D0s26Hx5.mjs} +2 -2
- package/dist/{dependency-state-CLcBHH2M.mjs → dependency-state-DKaS1OM9.mjs} +2 -2
- package/dist/{detached-entry-CiTEgMR1.mjs → detached-entry-pB_IPfV4.mjs} +1 -1
- package/dist/{dev-client-B-XC4uRH.mjs → dev-client-CDY_zAmD.mjs} +2 -2
- package/dist/{device-C8IOoJPv.mjs → device-BHw0WlHl.mjs} +8 -8
- package/dist/{device-capacity-ZC4XSZ4R.mjs → device-capacity-BoN1jQkO.mjs} +25 -14
- package/dist/device-host-worker.mjs +19 -19
- package/dist/{gradle-dJpre3Yn.mjs → device-ios-B2ruohE-.mjs} +661 -107
- package/dist/{device-lease-DpoS36_u.mjs → device-lease-Cu7PtQpZ.mjs} +9 -9
- package/dist/{device-lease-run-B8YltIH_.mjs → device-lease-run-D38SnZtt.mjs} +4 -4
- package/dist/{device-pool-3o7s5lo4.mjs → device-pool-CP4rAsHx.mjs} +3 -3
- package/dist/{device-remote-hFSkpfQu.mjs → device-remote-B5GiUifk.mjs} +15 -16
- package/dist/{doctor-CFv1fCrF.mjs → doctor-PRJH94v6.mjs} +61 -34
- package/dist/doctor-watchman-wZhyTdp4.mjs +259 -0
- package/dist/{error-diagnostics-C-NMnhrk.mjs → error-diagnostics--v5HGOU0.mjs} +11 -11
- package/dist/{exec-CaErVv7t.mjs → exec-i8GDPwq9.mjs} +93 -6
- package/dist/{gc-DEmkg3Xh.mjs → gc-CyHMcKcn.mjs} +25 -471
- package/dist/{guide-CSmhMTf8.mjs → guide-dRaQJJk9.mjs} +681 -507
- package/dist/{hosted-android-E1Heoqnv.mjs → hosted-android-Bs7fytj7.mjs} +3 -3
- package/dist/{hosted-client-Bp4knSwu.mjs → hosted-client-C5G4h_OJ.mjs} +2 -2
- package/dist/{hosted-ios-BnbeYOUD.mjs → hosted-ios-Bik035eL.mjs} +1 -1
- package/dist/{hosted-logs-OcgIBvCT.mjs → hosted-logs-CI9Az9a4.mjs} +9 -9
- package/dist/{hosted-macos-DcxKjtfH.mjs → hosted-macos-DABm3ScO.mjs} +5 -5
- package/dist/{hosted-native-1Ebbig4w.mjs → hosted-native-DbV2aUVw.mjs} +13 -9
- package/dist/{idle-shutdown-IGyNV8Cr.mjs → idle-shutdown-DYiMBn34.mjs} +7 -8
- package/dist/{ios-DSfnPfse.mjs → ios-BWbHFZVz.mjs} +19 -7
- package/dist/{ios-Cr1h5gnO.mjs → ios-DCrkgXEM.mjs} +1 -1
- package/dist/ios-DYUr9LGc.mjs +8 -0
- package/dist/ios-ITYno9rO.mjs +2241 -0
- package/dist/{ios-device-pAN4t54-.mjs → ios-device-CJ_ZOGky.mjs} +3 -3
- package/dist/{ios-device-Ee7sDXfp.mjs → ios-device-CrW8aMb5.mjs} +1 -1
- package/dist/{ios-state-8L3lgum6.mjs → ios-state-By0XuLTQ.mjs} +1 -1
- package/dist/{launch-verify-lTnWZikR.mjs → launch-verify-DCveSE6d.mjs} +5 -5
- package/dist/{logs-BAaS7gS2.mjs → logs-Bao1HOMy.mjs} +13 -13
- package/dist/{macos-BIRQS90f.mjs → macos-ciyBdTY5.mjs} +194 -132
- package/dist/macos-nIOATJmR.mjs +2 -0
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +349 -47
- package/dist/manifest-CX0d1IkZ.mjs +148 -0
- package/dist/{metro-g8NqiJp-.mjs → metro-DI2AjPF_.mjs} +196 -43
- package/dist/{metro-gateway-C-ijGI2F.mjs → metro-gateway-BxpJLIwh.mjs} +4 -4
- package/dist/{metro-store-CDDZHtPl.mjs → metro-store-BAHFcJm6.mjs} +16 -2
- package/dist/{build-plan-BDsSi09V.mjs → miss-reason-CjQCOKqq.mjs} +207 -249
- package/dist/{named-ports-C8m8EQs2.mjs → named-ports-B4iWH4E-.mjs} +70 -8
- package/dist/{native-runtime-BEK171xQ.mjs → native-runtime-BGxsbfny.mjs} +6 -6
- package/dist/{ndjson-PclOIwVY.mjs → ndjson-LGZAMsqa.mjs} +8 -4
- package/dist/offload-worker.d.mts +3 -45
- package/dist/offload-worker.mjs +11 -11
- package/dist/{ownership-DyRQru0q.mjs → ownership-EB0ySdGK.mjs} +3 -3
- package/dist/{page-QF_Ke10s.mjs → page-Bv9s2KwY.mjs} +1 -1
- package/dist/placement-log-Dxe34rJm.mjs +88 -0
- package/dist/plan-placement-BVY59qa8.mjs +290 -0
- package/dist/{ports-4nYqxPWC.mjs → ports-ByPc0_97.mjs} +3 -3
- package/dist/{prebuild-D7RUMkwN.mjs → prebuild-BKJ3wJI1.mjs} +5 -5
- package/dist/preview-BbSottmO.mjs +986 -0
- package/dist/{rolldown-runtime-BsOwBuO_.mjs → process-identity-Biv3arCO.mjs} +11 -1
- package/dist/project-B5eQ1USs.mjs +612 -0
- package/dist/{pull-request-pxnDCQzn.mjs → pull-request-IHNdMnG8.mjs} +1 -1
- package/dist/pull-requests.mjs +1 -1
- package/dist/react-native-ios-BMh2i25I.mjs +2 -0
- package/dist/react-native-ios-CSpIxexZ.mjs +2083 -0
- package/dist/{recordings-BNgsD1Tr.mjs → recordings-Bv8McZN4.mjs} +1 -1
- package/dist/{reload-DcRxj3qG.mjs → reload-rAPdqeRR.mjs} +14 -15
- package/dist/{remote-cache-Ci4DQYYj.mjs → remote-cache-N3hAEaAL.mjs} +5 -5
- package/dist/{run-CkE9y0nc.mjs → run-lAkle1-c.mjs} +5 -5
- package/dist/{server-bare-BkrSxSsZ.mjs → server-bare-CkIjnegq.mjs} +5 -6
- package/dist/server-expo-DGsdUGX2.mjs +2 -0
- package/dist/{server-expo-CHTyXD0G.mjs → server-expo-n3tUi3Em.mjs} +5 -6
- package/dist/{settings-SR9OmW9h.mjs → settings-2am7TSxp.mjs} +5 -5
- package/dist/{settings-Cfd-0r2d.mjs → settings-CxgngUZk.mjs} +116 -103
- package/dist/{settings-BBpMcDbD.mjs → settings-Djl-mpjX.mjs} +1 -1
- package/dist/settings.schema.json +198 -9
- package/dist/{simslim-BWNrc3M3.mjs → simslim-D9LkJxIO.mjs} +7 -7
- package/dist/{slot-launch-DmjBmpQV.mjs → slot-launch-HV_KtPIw.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-BgaZJVZY.mjs} +14 -3
- package/dist/{start-AlfCPRVU.mjs → start-D8NbxNBb.mjs} +1 -1
- package/dist/{start-DUz3mYdb.mjs → start-DtxthMfI.mjs} +34 -27
- package/dist/{state-PeQiJuIu.mjs → state-D2KtnALG.mjs} +4 -4
- package/dist/{state-DyaNTgfR.mjs → state-Tp4uImDS.mjs} +5 -3
- package/dist/{state-B4PQFXMW.d.mts → state-lKh8shBp.d.mts} +2 -3
- package/dist/{stats-Bq4fJOdB.mjs → stats-8EJ5ivFT.mjs} +6 -6
- package/dist/{status-DlKvVJBE.mjs → status-BEeL6IKz.mjs} +6 -4
- package/dist/{status-BA2pehwf.mjs → status-BOyp0CUl.mjs} +31 -34
- package/dist/{stim-desktop-Cnz8CPnl.mjs → stim-desktop-C65jk_q2.mjs} +1 -1
- package/dist/{stim-installations-QMEI32v1.mjs → stim-installations-DbmUjsLv.mjs} +1 -1
- package/dist/stop-D0UIpZuh.mjs +72 -0
- package/dist/{stop-zF1y04f2.mjs → stop-DRipAg-e.mjs} +2 -2
- package/dist/{stop-DQIasgKp.mjs → stop-zDlknFoz.mjs} +79 -33
- package/dist/supervisor-run.d.mts +24 -22
- package/dist/supervisor-run.mjs +21 -22
- package/dist/{support-CsJNVfOc.mjs → support-CNqYkV0y.mjs} +7 -7
- package/dist/{support-WvD__tSV.mjs → support-DsNaFg6D.mjs} +5 -5
- package/dist/swiftpm-macos-aJzPAj1t.mjs +119 -0
- package/dist/{toolchain-DNyR3NPq.mjs → toolchain-C3xSoyUl.mjs} +475 -269
- package/dist/{trigger-Bemu8ytw.mjs → trigger-CAhmG-4s.mjs} +6 -6
- package/dist/trigger-CoalsMTV.mjs +2 -0
- package/dist/{warm-progress-DF4JRvYI.mjs → warm-progress-pFLB2e6P.mjs} +135 -38
- package/dist/{status-CzS4bPO9.mjs → watchman-BL1IdOtq.mjs} +75 -7
- package/dist/web-DFpFeZu5.mjs +2 -0
- package/dist/web-DbbrPUn0.mjs +127 -0
- package/dist/web-run.mjs +10 -10
- package/dist/{workspace-state-DqcCbpE7.mjs → workspace-state-CR9X86xJ.mjs} +3 -3
- package/dist/{ownership-BMLqyBgJ.mjs → workspaces-Djb2gfi9.mjs} +661 -23
- package/dist/{worktree-Be_7NLKy.mjs → worktree-BL4M1rhB.mjs} +252 -50
- package/dist/{worktree-j3IcFAI5.mjs → worktree-DV-A0LNL.mjs} +1 -1
- package/package.json +10 -5
- package/shim/bundle-response.cjs +2 -1
- package/shim/bundle-response.d.cts +1 -1
- package/shim/expo-metro-config.cjs +1 -1
- 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/device-ios-C2Um-XUR.mjs +0 -412
- package/dist/errors-B6W7FkxQ.mjs +0 -15
- package/dist/guide-status-Du-ZQ3FD.mjs +0 -125
- package/dist/idle-BXG__1BA.mjs +0 -176
- package/dist/in-use-CvGOUn-x.mjs +0 -130
- package/dist/ios-BJ4XUSe1.mjs +0 -3867
- package/dist/native-run-D1Q56rAD.mjs +0 -158
- package/dist/preview-B-g9d7kV.mjs +0 -318
- package/dist/process-identity-BmRm1qV0.mjs +0 -12
- package/dist/project-D47Rh0ly.mjs +0 -276
- package/dist/server-expo-CeakhI8P.mjs +0 -2
- package/dist/state-BKa8wNN5.mjs +0 -148
- package/dist/stop-BIiM49EY.mjs +0 -48
- 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
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { M as isOnMountedVolume, N as listMountedVolumes, P as measuredDirectorySize, _ as loadConfig$1, d as getConfigDir, g as isPathPrefix, j as formatBytes } from "./config-D0DbpZtM.mjs";
|
|
2
|
-
import { S as workspaceName, s as workspaceLastUsed } from "./workspace-state-DqcCbpE7.mjs";
|
|
3
|
-
import { i as recordGcResult, n as withIdleWorkspace, o as canonicalPath, r as workspaceInUse, t as emptyWorkspaceDir } from "./in-use-CvGOUn-x.mjs";
|
|
4
|
-
import { h as teardownOwnedBrowser } from "./ownership-BMLqyBgJ.mjs";
|
|
5
|
-
import { existsSync, lstatSync, readdirSync, rmSync, statSync } from "fs";
|
|
6
|
-
import { basename, isAbsolute, join, relative } from "path";
|
|
7
|
-
import { isJsonObject, readJsonFile } from "@stim-cli/core/state";
|
|
8
|
-
import chalk from "chalk";
|
|
9
|
-
//#region src/commands/gc/workspaces.ts
|
|
10
|
-
function workspacesRoot() {
|
|
11
|
-
return join(getConfigDir(), "workspaces");
|
|
12
|
-
}
|
|
13
|
-
function isInsideWorkspaces(dir) {
|
|
14
|
-
const rel = relative(canonicalPath(workspacesRoot()), canonicalPath(dir));
|
|
15
|
-
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
|
|
16
|
-
}
|
|
17
|
-
function readRecordedRoot(dir, name) {
|
|
18
|
-
let parsed;
|
|
19
|
-
try {
|
|
20
|
-
parsed = readJsonFile(join(dir, "workspace.json"));
|
|
21
|
-
} catch (error) {
|
|
22
|
-
return {
|
|
23
|
-
projectRoot: null,
|
|
24
|
-
problem: error?.code === "ENOENT" ? "it has no workspace.json" : "its workspace.json does not parse"
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const projectRoot = isJsonObject(parsed) ? parsed.projectRoot : void 0;
|
|
28
|
-
if (typeof projectRoot !== "string" || !isAbsolute(projectRoot)) return {
|
|
29
|
-
projectRoot: null,
|
|
30
|
-
problem: "its workspace.json records no absolute project root"
|
|
31
|
-
};
|
|
32
|
-
if (workspaceName(projectRoot) !== name) return {
|
|
33
|
-
projectRoot: null,
|
|
34
|
-
problem: `its workspace.json records ${projectRoot}, whose workspace directory has another name`
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
projectRoot,
|
|
38
|
-
problem: null
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function listWorkspaceDirs() {
|
|
42
|
-
const root = workspacesRoot();
|
|
43
|
-
let names;
|
|
44
|
-
try {
|
|
45
|
-
names = readdirSync(root).toSorted();
|
|
46
|
-
} catch {
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
const entries = [];
|
|
50
|
-
for (const name of names) {
|
|
51
|
-
const dir = join(root, name);
|
|
52
|
-
try {
|
|
53
|
-
if (!statSync(dir).isDirectory()) continue;
|
|
54
|
-
} catch {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
entries.push({
|
|
58
|
-
dir,
|
|
59
|
-
...readRecordedRoot(dir, name)
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return entries;
|
|
63
|
-
}
|
|
64
|
-
function classifyWorkspaceDirs(entries, { registryKeys, exists, isMounted, inUse }) {
|
|
65
|
-
const orphaned = [];
|
|
66
|
-
const skipped = [];
|
|
67
|
-
for (const { dir, projectRoot, problem } of entries) {
|
|
68
|
-
if (projectRoot === null) {
|
|
69
|
-
skipped.push({
|
|
70
|
-
dir,
|
|
71
|
-
reason: `workspace directory not resolved: ${problem ?? "unknown project root"}`
|
|
72
|
-
});
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const present = exists(projectRoot);
|
|
76
|
-
if (present === null) {
|
|
77
|
-
skipped.push({
|
|
78
|
-
dir,
|
|
79
|
-
reason: `cannot tell whether its project root ${projectRoot} still exists`
|
|
80
|
-
});
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (present) continue;
|
|
84
|
-
if (registryKeys.some((key) => isPathPrefix(projectRoot, key))) continue;
|
|
85
|
-
if (!isMounted(projectRoot)) {
|
|
86
|
-
skipped.push({
|
|
87
|
-
dir,
|
|
88
|
-
reason: `the volume of its project root ${projectRoot} is not mounted`
|
|
89
|
-
});
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
const reasons = inUse(projectRoot);
|
|
93
|
-
if (reasons.length) {
|
|
94
|
-
skipped.push({
|
|
95
|
-
dir,
|
|
96
|
-
reason: `its project root ${projectRoot} is gone, but ${reasons.join("; ")}`
|
|
97
|
-
});
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
orphaned.push({
|
|
101
|
-
dir,
|
|
102
|
-
projectRoot
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
orphaned,
|
|
107
|
-
skipped
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function rootPresence(path) {
|
|
111
|
-
try {
|
|
112
|
-
lstatSync(path);
|
|
113
|
-
return true;
|
|
114
|
-
} catch (error) {
|
|
115
|
-
const code = error?.code;
|
|
116
|
-
return code === "ENOENT" || code === "ENOTDIR" ? false : null;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function collectOrphanedWorkspaces(registryKeys, mountedVolumes, { measure = true } = {}) {
|
|
120
|
-
const classified = classifyWorkspaceDirs(listWorkspaceDirs(), {
|
|
121
|
-
registryKeys,
|
|
122
|
-
exists: rootPresence,
|
|
123
|
-
isMounted: (path) => isOnMountedVolume(path, mountedVolumes),
|
|
124
|
-
inUse: (root) => workspaceInUse(root)
|
|
125
|
-
});
|
|
126
|
-
return {
|
|
127
|
-
orphaned: measure ? classified.orphaned.map((entry) => Object.assign({}, entry, { bytes: sizeOf(entry.dir) })) : classified.orphaned,
|
|
128
|
-
skipped: classified.skipped
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const REBUILD_COST = "The next build of an unchanged app installs from the shared build cache; after a native change the compilation cache speeds the rebuild, but on React Native 0.86 Swift does not use it (explicit modules are off), so that build recompiles Swift. The next stim macos in a cleared workspace is a full Swift build.";
|
|
132
|
-
const WORKSPACE_OUTPUT_DIRS = [
|
|
133
|
-
"derived-data",
|
|
134
|
-
"gradle-build",
|
|
135
|
-
"android-cas",
|
|
136
|
-
"cache-provider"
|
|
137
|
-
];
|
|
138
|
-
const DAY_MS = 864e5;
|
|
139
|
-
function planWorkspaceOutputs(entries, { olderThan, now }) {
|
|
140
|
-
return entries.map(({ dir, projectRoot, problem, bytes, lastUsed, inUse }) => {
|
|
141
|
-
const idleDays = Number.isFinite(lastUsed) ? Math.max(0, Math.floor((now - lastUsed) / DAY_MS)) : null;
|
|
142
|
-
const [keptCode, keptReason] = projectRoot === null ? ["unresolved", `workspace directory not resolved: ${problem ?? "unknown project root"}`] : inUse.length ? ["in-use", `in use: ${inUse.join("; ")}`] : olderThan === null ? [null, null] : idleDays === null ? ["last-use-unknown", "its last use is unknown"] : idleDays < olderThan ? ["recently-used", `used ${idleDays}d ago, within --older-than ${olderThan}`] : [null, null];
|
|
143
|
-
return {
|
|
144
|
-
dir,
|
|
145
|
-
projectRoot,
|
|
146
|
-
bytes,
|
|
147
|
-
idleDays,
|
|
148
|
-
willClear: keptCode === null,
|
|
149
|
-
keptCode,
|
|
150
|
-
keptReason
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
const SIZE_TIMEOUT_MS = 6e4;
|
|
155
|
-
function sizeOf(dir, timeoutMs = SIZE_TIMEOUT_MS) {
|
|
156
|
-
return measuredDirectorySize(dir, { timeoutMs });
|
|
157
|
-
}
|
|
158
|
-
function outputPaths(dir) {
|
|
159
|
-
const paths = WORKSPACE_OUTPUT_DIRS.map((name) => join(dir, name)).filter((path) => existsSync(path));
|
|
160
|
-
const macos = join(dir, "macos");
|
|
161
|
-
try {
|
|
162
|
-
if (!lstatSync(macos).isDirectory()) return paths;
|
|
163
|
-
for (const entry of readdirSync(macos, { withFileTypes: true })) if (entry.name === "build" || entry.name.endsWith(".app") || entry.name.startsWith("staging-") && entry.isDirectory()) paths.push(join(macos, entry.name));
|
|
164
|
-
} catch {}
|
|
165
|
-
return paths;
|
|
166
|
-
}
|
|
167
|
-
function outputBytes(paths, timeoutMs) {
|
|
168
|
-
let total = 0;
|
|
169
|
-
for (const path of paths) {
|
|
170
|
-
const size = sizeOf(path, timeoutMs);
|
|
171
|
-
if (size === null) return null;
|
|
172
|
-
total += size;
|
|
173
|
-
}
|
|
174
|
-
return total;
|
|
175
|
-
}
|
|
176
|
-
function collectWorkspaceOutputs({ olderThan, now, exclude = [], measure = true, sizeTimeoutMs = SIZE_TIMEOUT_MS }) {
|
|
177
|
-
const mountedVolumes = listMountedVolumes();
|
|
178
|
-
const entries = listWorkspaceDirs().filter((entry) => !exclude.includes(entry.dir)).filter((entry) => entry.projectRoot === null || isOnMountedVolume(entry.projectRoot, mountedVolumes)).map((entry) => Object.assign({}, entry, { paths: outputPaths(entry.dir) })).filter((entry) => entry.paths.length > 0).map(({ paths, ...entry }) => Object.assign({}, entry, { bytes: measure ? outputBytes(paths, sizeTimeoutMs) : null })).map((entry) => Object.assign({}, entry, {
|
|
179
|
-
lastUsed: entry.projectRoot === null ? NaN : workspaceLastUsed(entry.projectRoot),
|
|
180
|
-
inUse: entry.projectRoot === null ? [] : workspaceInUse(entry.projectRoot)
|
|
181
|
-
}));
|
|
182
|
-
return {
|
|
183
|
-
root: workspacesRoot(),
|
|
184
|
-
workspaces: planWorkspaceOutputs(entries, {
|
|
185
|
-
olderThan,
|
|
186
|
-
now
|
|
187
|
-
})
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
async function clearWorkspaceOutputs(report, { olderThan, now = Date.now() }) {
|
|
191
|
-
let failures = 0;
|
|
192
|
-
let cleared = 0;
|
|
193
|
-
const clearedRoots = [];
|
|
194
|
-
for (const entry of report.workspaces) {
|
|
195
|
-
const root = entry.projectRoot;
|
|
196
|
-
if (!entry.willClear || root === null) {
|
|
197
|
-
if (entry.keptReason) {
|
|
198
|
-
console.log(chalk.dim(`Kept the build outputs of ${root ?? entry.dir}: ${entry.keptReason}`));
|
|
199
|
-
recordGcResult("workspaceOutputs", "kept", root ?? entry.dir, {
|
|
200
|
-
bytes: entry.bytes,
|
|
201
|
-
detail: entry.keptReason
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
let run;
|
|
207
|
-
try {
|
|
208
|
-
run = await withIdleWorkspace(root, () => {
|
|
209
|
-
const [again] = planWorkspaceOutputs([{
|
|
210
|
-
...entry,
|
|
211
|
-
problem: null,
|
|
212
|
-
lastUsed: workspaceLastUsed(root),
|
|
213
|
-
inUse: []
|
|
214
|
-
}], {
|
|
215
|
-
olderThan,
|
|
216
|
-
now
|
|
217
|
-
});
|
|
218
|
-
if (again?.keptReason) return again.keptReason;
|
|
219
|
-
for (const path of outputPaths(entry.dir)) rmSync(path, {
|
|
220
|
-
recursive: true,
|
|
221
|
-
force: true
|
|
222
|
-
});
|
|
223
|
-
return null;
|
|
224
|
-
}, { purpose: "gc" });
|
|
225
|
-
} catch (error) {
|
|
226
|
-
failures++;
|
|
227
|
-
console.log(chalk.red(`Could not clear the build outputs of ${root}: ${error?.message || String(error)}`));
|
|
228
|
-
recordGcResult("workspaceOutputs", "failed", root, {
|
|
229
|
-
bytes: entry.bytes,
|
|
230
|
-
detail: error?.message || String(error)
|
|
231
|
-
});
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
const kept = run.ran ? run.value : `in use: ${run.reasons.join("; ")}`;
|
|
235
|
-
if (kept) {
|
|
236
|
-
console.log(chalk.yellow(`Kept the build outputs of ${root}: ${kept}`));
|
|
237
|
-
recordGcResult("workspaceOutputs", "kept", root, {
|
|
238
|
-
bytes: entry.bytes,
|
|
239
|
-
detail: kept
|
|
240
|
-
});
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
cleared += entry.bytes ?? 0;
|
|
244
|
-
clearedRoots.push(root);
|
|
245
|
-
console.log(chalk.green(`Cleared the build outputs of ${root} (${sizeText(entry.bytes)})`));
|
|
246
|
-
recordGcResult("workspaceOutputs", "done", root, { bytes: entry.bytes });
|
|
247
|
-
}
|
|
248
|
-
if (cleared) console.log(chalk.dim(`Cleared ${formatBytes(cleared)} of workspace build outputs. ${REBUILD_COST}`));
|
|
249
|
-
return {
|
|
250
|
-
failures,
|
|
251
|
-
cleared: clearedRoots
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
function stillOrphaned({ dir, projectRoot }) {
|
|
255
|
-
if (readRecordedRoot(dir, basename(dir)).projectRoot !== projectRoot || rootPresence(projectRoot) !== false || !isOnMountedVolume(projectRoot)) return false;
|
|
256
|
-
return !Object.keys(loadConfig$1()?.projects ?? {}).some((key) => isPathPrefix(projectRoot, key));
|
|
257
|
-
}
|
|
258
|
-
async function deleteOrphanedWorkspaces(orphaned) {
|
|
259
|
-
let failures = 0;
|
|
260
|
-
for (const entry of orphaned) {
|
|
261
|
-
if (!existsSync(entry.dir)) continue;
|
|
262
|
-
let run;
|
|
263
|
-
try {
|
|
264
|
-
run = await withIdleWorkspace(entry.projectRoot, async () => {
|
|
265
|
-
if (!stillOrphaned(entry)) return false;
|
|
266
|
-
const browser = await teardownOwnedBrowser(entry.projectRoot, { deleteProfile: true });
|
|
267
|
-
if (browser.status === "failed" || browser.status === "skipped") throw new Error(`its owned Chrome profile was kept: ${browser.reason}`);
|
|
268
|
-
emptyWorkspaceDir(entry.dir);
|
|
269
|
-
return true;
|
|
270
|
-
}, { purpose: "gc" });
|
|
271
|
-
} catch (error) {
|
|
272
|
-
failures++;
|
|
273
|
-
console.log(chalk.red(`Could not remove ${entry.dir}: ${error?.message || error}`));
|
|
274
|
-
recordGcResult("workspaceDirectory", "failed", entry.dir, {
|
|
275
|
-
bytes: entry.bytes ?? null,
|
|
276
|
-
detail: error?.message || String(error)
|
|
277
|
-
});
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
if (!run.ran) {
|
|
281
|
-
console.log(chalk.yellow(`Kept ${entry.dir}: ${run.reasons.join("; ")}`));
|
|
282
|
-
recordGcResult("workspaceDirectory", "kept", entry.dir, {
|
|
283
|
-
bytes: entry.bytes ?? null,
|
|
284
|
-
detail: run.reasons.join("; ")
|
|
285
|
-
});
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
if (!run.value) {
|
|
289
|
-
console.log(chalk.yellow(`Kept ${entry.dir}: it can no longer be confirmed orphaned.`));
|
|
290
|
-
recordGcResult("workspaceDirectory", "kept", entry.dir, {
|
|
291
|
-
bytes: entry.bytes ?? null,
|
|
292
|
-
detail: "it can no longer be confirmed orphaned"
|
|
293
|
-
});
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
const size = entry.bytes === void 0 ? "" : ` (${sizeText(entry.bytes)})`;
|
|
297
|
-
console.log(chalk.green(`Removed the orphaned workspace directory ${entry.dir}${size}`));
|
|
298
|
-
recordGcResult("workspaceDirectory", "done", entry.dir, { bytes: entry.bytes ?? null });
|
|
299
|
-
}
|
|
300
|
-
return failures;
|
|
301
|
-
}
|
|
302
|
-
function sizeText(bytes) {
|
|
303
|
-
return bytes === null ? "size unknown" : formatBytes(bytes);
|
|
304
|
-
}
|
|
305
|
-
//#endregion
|
|
306
|
-
export { collectWorkspaceOutputs as a, listWorkspaceDirs as c, collectOrphanedWorkspaces as i, rootPresence as l, WORKSPACE_OUTPUT_DIRS as n, deleteOrphanedWorkspaces as o, clearWorkspaceOutputs as r, isInsideWorkspaces as s, REBUILD_COST as t, sizeText as u };
|