stim 1.20.1 → 1.21.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 +94 -11
- package/dist/acquire-artifact-CD4lbiWE.mjs +153 -0
- package/dist/act-DHAw2A2S.mjs +2667 -0
- package/dist/activity-BzVfHSrY.mjs +1376 -0
- package/dist/{agent-device-usage-output-VPaOgGaF.mjs → agent-device-usage-output-zh1vhbLp.mjs} +21 -66
- package/dist/{android-CZh6ElG5.mjs → android-BEJ8Jpl7.mjs} +3 -3
- package/dist/{android-CLbBJ2ve.mjs → android-BLgbNqox.mjs} +128 -79
- package/dist/{android-eXfIjKJr.mjs → android-CV_GCELZ.mjs} +5 -5
- package/dist/{android-DE8-JfGW.mjs → android-DUYkNF4u.mjs} +188 -106
- package/dist/{android-cas-BFpS84v2.mjs → android-cas-Ct5b1xCK.mjs} +7 -6
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/android-project-BCAAmMwz.mjs +12 -0
- package/dist/api.d.mts +740 -8
- package/dist/api.mjs +585 -1
- package/dist/{artifact-Ctb2jpw6.mjs → artifact-B8T3S5gi.mjs} +223 -201
- package/dist/{artifact-DXk_Fle_.mjs → artifact-DAuZ-FNU.mjs} +158 -148
- package/dist/{browser-web-xQWC2RWl.mjs → browser-web-QQzVjz3O.mjs} +28 -26
- package/dist/budget-Bs6SxxzO.mjs +9154 -0
- package/dist/{build-COBA1tBc.mjs → build-CoPzQRNw.mjs} +144 -101
- package/dist/build-cache-DmyR9Zzc.mjs +602 -0
- package/dist/build-plan-CaFskB7_.mjs +188 -0
- package/dist/{cache-manifest-qA3dT2x2.mjs → cache-manifest-DkkqguoK.mjs} +10 -5
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{ccache-CtbqWxIC.mjs → ccache-BJRZ9pG3.mjs} +10 -9
- package/dist/{cdp-Dq_ypAlJ.mjs → cdp-CWmIUMbw.mjs} +18 -5
- package/dist/{chrome-Dp2lMLBe.mjs → chrome-B6tfCta1.mjs} +7 -4
- package/dist/{cli-sGqlPu1n.mjs → cli-0DYf8QhQ.mjs} +20 -20
- package/dist/cli.mjs +1 -1
- package/dist/client-B7QVOlCr.d.mts +253 -0
- package/dist/client-UXD70ZbM.mjs +1406 -0
- package/dist/collector-run.d.mts +4 -39
- package/dist/collector-run.mjs +9 -9
- package/dist/{command-output-CPDq_90S.mjs → command-output-B1UrjZHL.mjs} +1 -1
- package/dist/config-CYcBF478.mjs +949 -0
- package/dist/{created-devices-CXBMtoj5.mjs → created-devices-CqeBlrEn.mjs} +3 -3
- package/dist/{dependency-state-B2m8eqsS.mjs → dependency-state-BbKQW83h.mjs} +20 -5
- package/dist/{detached-entry-BXq4fIl-.mjs → detached-entry-DFRyG1_o.mjs} +1 -1
- package/dist/{dev-client-BqYjMIaC.mjs → dev-client-UOeESKm6.mjs} +2 -2
- package/dist/device-DCxH7_By.mjs +1068 -0
- package/dist/{device-D4DqjSZZ.mjs → device-ExJq8Ei7.mjs} +35 -36
- package/dist/{device-capacity-DrwHwR97.mjs → device-capacity-CMlqEcvw.mjs} +43 -14
- package/dist/device-host-worker.mjs +65 -62
- package/dist/{device-ios-DE8KJd3b.mjs → device-ios-DRUeKaFV.mjs} +49 -49
- package/dist/{device-lease-run-Baelt3nc.mjs → device-lease-run-C8raGFoP.mjs} +14 -26
- package/dist/{device-pool-DtK9S6AD.mjs → device-pool-DMRpVX9a.mjs} +5 -5
- package/dist/doctor-BLHCYxzi.mjs +2 -0
- package/dist/{doctor-Dunu3Nv1.mjs → doctor-DTvaDOda.mjs} +317 -344
- package/dist/{doctor-DiP9HsIP.mjs → doctor-Dhqebm0q.mjs} +183 -91
- package/dist/doctor-fingerprint.mjs +19 -0
- package/dist/{doctor-watchman-XJzT8tK-.mjs → doctor-watchman-Cv1F10Kj.mjs} +40 -23
- package/dist/{eas-build-0gadvrca.mjs → eas-build-BomfRnFT.mjs} +53 -20
- package/dist/{build-plan-CRjAA6Qi.mjs → eas-fallback-DJwZpy0c.mjs} +26 -208
- package/dist/{watchman-CqmaGcIb.mjs → eas-session-ledger-op6A54yi.mjs} +229 -11
- package/dist/{error-diagnostics-BhQtoLrZ.mjs → error-diagnostics-Bf0rZvG9.mjs} +172 -82
- package/dist/exec-H20xSg2T.d.mts +65 -0
- package/dist/exec-_UbtCQcG.mjs +750 -0
- package/dist/gc-C-WwL0yi.mjs +3 -0
- package/dist/{gc-D5cz5G0k.mjs → gc-_-dCXdyL.mjs} +625 -786
- package/dist/git-C3iTsJaZ.mjs +73 -0
- package/dist/{guide-DakjcoUt.mjs → guide-Yqwt2bd6.mjs} +990 -280
- package/dist/{hosted-android-C-D8Dj0_.mjs → hosted-android-Bw-honsd.mjs} +8 -6
- package/dist/{hosted-client--hNFgixu.mjs → hosted-client-DB_gBPfY.mjs} +47 -24
- package/dist/{hosted-ios-Chx9XQyI.mjs → hosted-ios-CUvOf4Vr.mjs} +1 -1
- package/dist/{hosted-logs-Bkz0Hxzh.mjs → hosted-logs-DL_P5AdN.mjs} +77 -43
- package/dist/{hosted-macos-ckTjN-0V.mjs → hosted-macos-QI141yKk.mjs} +21 -15
- package/dist/{hosted-native-3KXZ5-qn.mjs → hosted-native-Ksyjgzq-.mjs} +31 -20
- package/dist/idle-BVeRGroT.d.mts +24 -0
- package/dist/{idle-shutdown-DhAUyf5s.mjs → idle-shutdown-DaKmZi0z.mjs} +11 -10
- package/dist/{ios-BDBN-xpf.mjs → ios-CQ68hG9s.mjs} +8 -8
- package/dist/{ios-o896T9PE.mjs → ios-CpByZy12.mjs} +141 -81
- package/dist/{ios-device-B1B14xND.mjs → ios-device-CXGP1bsD.mjs} +1 -1
- package/dist/{ios-device-BWHKGaJq.mjs → ios-device-CwFMehUS.mjs} +60 -35
- package/dist/{ios-project-BeOXKPt2.mjs → ios-project-WuwwBdvW.mjs} +13 -13
- package/dist/{ios-VGvNdsv2.mjs → ios-qNJt4dFm.mjs} +1 -1
- package/dist/ios-signing-DTTIChGs.mjs +489 -0
- package/dist/{ios-state-BsXMwo5y.mjs → ios-state-DvFX-K_l.mjs} +1 -1
- package/dist/{ios-CQ8bHQXB.mjs → ios-ubFsBzwq.mjs} +129 -86
- package/dist/{js-swap-Z_mSuRrx.mjs → js-swap-Cc1dttps.mjs} +60 -33
- package/dist/{launch-V1zqiOYn.mjs → launch-CD1yVc7U.mjs} +92 -91
- package/dist/{launch-BootbMk4.mjs → launch-Zq2mOSDy.mjs} +87 -545
- package/dist/logs-BS00Anxf.mjs +352 -0
- package/dist/logs-CMm05HxN.mjs +255 -0
- package/dist/macos-B65--pPd.mjs +2 -0
- package/dist/{macos-D7irBW3A.mjs → macos-C-0qJ6zq.mjs} +244 -215
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +122 -247
- package/dist/{metro-_ZIE3Axg.mjs → metro-DEXpIhHC.mjs} +71 -17
- package/dist/{metro-gateway-BzlQZQmU.mjs → metro-gateway-BMJNlj3E.mjs} +20 -12
- package/dist/{named-ports-O1TIl7tx.mjs → named-ports-BWTzt6mu.mjs} +8 -64
- package/dist/native-android-JACyjTZs.mjs +844 -0
- package/dist/{native-gradle-inputs-BQnIdAlL.mjs → native-gradle-inputs-Bep9JcSF.mjs} +128 -147
- package/dist/native-inputs-TRTTTRxt.mjs +91 -0
- package/dist/native-run-DY_RLx3C.mjs +277 -0
- package/dist/{native-runtime-D024BAvm.mjs → native-runtime-Dg1Q7tfF.mjs} +10 -10
- package/dist/{native-xcode-inputs-UElfGs59.mjs → native-xcode-inputs-CB2iQeWq.mjs} +28 -20
- package/dist/{native-xcode-ios-CjS-nDVY.mjs → native-xcode-ios-CXX39F7o.mjs} +96 -47
- package/dist/{ndjson-GOnbyvso.mjs → ndjson-CgE_o3Dl.mjs} +3 -3
- package/dist/offload-worker.d.mts +1 -46
- package/dist/offload-worker.mjs +213 -86
- package/dist/{ownership-BrjepDiv.mjs → ownership-DEmM5vhh.mjs} +3 -3
- package/dist/{page-Bv9s2KwY.mjs → page-CPaHeYqj.mjs} +7 -4
- package/dist/paths-BsJMoPP2.mjs +12 -0
- package/dist/paths-DQtTgsBf.mjs +42 -0
- package/dist/{placement-log-BItXET1x.mjs → placement-log-BqGbTa61.mjs} +5 -5
- package/dist/{plan-placement-B466UYMU.mjs → plan-placement-Bwj-IjY1.mjs} +6 -6
- package/dist/{ports-BFRL6JTj.mjs → ports-D-MmCTdv.mjs} +3 -3
- package/dist/prebuild-uD_ipCxF.mjs +449 -0
- package/dist/{project-DX8fXyw_.mjs → project-BZNjmW_8.mjs} +65 -38
- package/dist/{pull-request-vOhLNmIb.mjs → pull-request-Lfetn8Kr.mjs} +5 -18
- package/dist/pull-request-zjCSAryH.d.mts +120 -0
- package/dist/pull-requests.d.mts +1 -119
- package/dist/pull-requests.mjs +1 -1
- package/dist/{react-native-android-CuXM3QS8.mjs → react-native-android-DuzH0cn3.mjs} +83 -53
- package/dist/{gradle-CZZo1TSA.mjs → react-native-build-rhk4smwQ.mjs} +292 -15
- package/dist/react-native-doctor-CQpuIMso.mjs +234 -0
- package/dist/{react-native-ios-DtVO4qf2.mjs → react-native-ios-Bhq1rJeV.mjs} +46 -28
- package/dist/{recordings-Bk-VivUV.mjs → recordings-DYteQSu4.mjs} +12 -9
- package/dist/{reload-D9V7D8gP.mjs → reload-CmTRFJaX.mjs} +95 -49
- package/dist/reload-DzjSl5P_.mjs +2 -0
- package/dist/{remote-CZiTijxG.mjs → remote-ByYkXdGD.mjs} +15 -10
- package/dist/result-DNiS-tTP.mjs +434 -0
- package/dist/{run-ClC8UVB5.mjs → run-D23HmJMs.mjs} +4 -5
- package/dist/selection-CSl9i5qU.mjs +619 -0
- package/dist/{server-bare-dWjAarki.mjs → server-bare-CxTrvDg8.mjs} +3 -4
- package/dist/{server-command-DnJYLnr4.mjs → server-command-CtzloH3v.mjs} +14 -7
- package/dist/server-expo-C-90EhcG.mjs +2 -0
- package/dist/{server-expo-CUuzP9Mp.mjs → server-expo-DT_F_uVI.mjs} +51 -15
- package/dist/{settings-Bbztm4oV.mjs → settings-CsJDEXgK.mjs} +301 -132
- package/dist/{settings-vk3mJGSm.d.mts → settings-DkdmlelE.d.mts} +6 -4
- package/dist/settings-T1gtc3bf.mjs +114 -0
- package/dist/settings-write-HyVZ8eQ8.mjs +359 -0
- package/dist/settings.schema.json +163 -16
- package/dist/{simslim-ChMfe8rg.mjs → simslim-Cgk17SXV.mjs} +14 -13
- package/dist/{slot-launch-CeCRr6MK.mjs → slot-launch-DF8VfT64.mjs} +15 -20
- package/dist/{spawn-entry-Dcb7sDUz.mjs → spawn-entry-jw19m8Nl.mjs} +0 -1
- package/dist/stage-BIS0ydsV.mjs +183 -0
- package/dist/{start-CRkG-mZ7.mjs → start-7lpH7hmN.mjs} +66 -48
- package/dist/{start-mh6bS27z.mjs → start-RChynRDp.mjs} +1 -1
- package/dist/{state-lqxdOH_g.mjs → state-C4ZtUisW.mjs} +41 -14
- package/dist/{state-BUpAmt2r.mjs → state-XMziexv2.mjs} +3 -2
- package/dist/{stats-CaB1MxMi.mjs → stats-53T7OTb9.mjs} +7 -13
- package/dist/stats-report-BFfMpWWF.mjs +16 -0
- package/dist/{status-C7vzkInu.mjs → status-BL7jVyAB.mjs} +538 -467
- package/dist/status-CSi6tlRq.mjs +2 -0
- package/dist/{status-BDGHwkCs.mjs → status-DqEUSSxs.mjs} +6 -4
- package/dist/{status-watch-ZaVqRdtW.mjs → status-watch-GDCfqpTE.mjs} +187 -22
- package/dist/status-worker.d.mts +1 -0
- package/dist/status-worker.mjs +19 -0
- package/dist/stim-desktop-C12we7lz.mjs +112 -0
- package/dist/{stop-BU7JaFCg.mjs → stop-Bk_1qiV6.mjs} +2 -2
- package/dist/{stop-BO80KJoT.mjs → stop-CPzlM1L-.mjs} +138 -99
- package/dist/{stop-Cftw_sXJ.mjs → stop-D7h6jAXQ.mjs} +11 -10
- package/dist/supervisor-run.d.mts +8 -17
- package/dist/supervisor-run.mjs +63 -28
- package/dist/{support-Ca6PZbpr.mjs → support-67vraa1Q.mjs} +18 -11
- package/dist/{support-Co0wk8Cv.mjs → support-Dlu37g6H.mjs} +12 -12
- package/dist/{swiftpm-macos-siFSkmCO.mjs → swiftpm-macos-p8WZbxKU.mjs} +35 -24
- package/dist/toolchain-DhKwp9iI.mjs +2 -0
- package/dist/toolchain-Hp9sCpK4.mjs +873 -0
- package/dist/{trigger-C0MWBi8O.mjs → trigger-BAahxUPq.mjs} +20 -5
- package/dist/trigger-Bf3uDcpv.mjs +2 -0
- package/dist/{warm-progress-5FAXkXIg.mjs → warm-progress-BHX5r0Ei.mjs} +252 -176
- package/dist/{web-BTjzE8mc.mjs → web-CJmIj6AI.mjs} +18 -13
- package/dist/web-DknQETPs.mjs +2 -0
- package/dist/web-run.mjs +16 -17
- package/dist/windows-report.d.mts +1 -0
- package/dist/windows-report.mjs +18 -0
- package/dist/windows-report.ps1 +43 -0
- package/dist/workspace-process-lock-1_1OoVW5.mjs +57 -0
- package/dist/{workspace-state-CvgTFe-h.mjs → workspace-state-Cjuigeeu.mjs} +70 -56
- package/dist/{workspaces-C4kqIOlx.mjs → workspaces-BccMFmGQ.mjs} +1188 -1080
- package/dist/worktree-CK2MpJW5.mjs +2 -0
- package/dist/{worktree-DtRsh6go.mjs → worktree-DQ6Zi2Mv.mjs} +368 -110
- package/dist/xcode-Zlx3qjEs.mjs +896 -0
- package/package.json +7 -5
- package/shim/android-optimizations.gradle +7 -5
- package/dist/activity-BaMpUQ4-.mjs +0 -629
- package/dist/api-run.mjs +0 -296
- package/dist/api-zuX3ynYN.mjs +0 -154
- package/dist/app-install-Cg9YJy3x.mjs +0 -873
- package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
- package/dist/budget-RFbwFpG5.mjs +0 -4109
- package/dist/build-facts-DcLv2HSd.d.mts +0 -111
- package/dist/client-zqjFd79D.mjs +0 -1779
- package/dist/config-D0LhTY3S.mjs +0 -524
- package/dist/device-BgNj-qVj.mjs +0 -290
- package/dist/device-lease-C309csaB.mjs +0 -1228
- package/dist/device-remote-DjsNw8DD.mjs +0 -1272
- package/dist/eas-session-ledger-DJDeL4Uq.mjs +0 -205
- package/dist/exec-B81Qodjn.mjs +0 -254
- package/dist/launch-verify-Dl78EVgR.mjs +0 -428
- package/dist/logs-Bh4eqCCc.mjs +0 -384
- package/dist/macos-kivF8qKz.mjs +0 -2
- package/dist/miss-reason-SuTptY-I.mjs +0 -238
- package/dist/native-android-D94RlJ-X.mjs +0 -226
- package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
- package/dist/plan-Jwu_vr-F.mjs +0 -260
- package/dist/prebuild-DB_zLOLc.mjs +0 -213
- package/dist/preview-BRLFRhTz.mjs +0 -1004
- package/dist/process-identity-Biv3arCO.mjs +0 -40
- package/dist/react-native-build-JUF31S8U.mjs +0 -239
- package/dist/react-native-doctor-BQHqiXaQ.mjs +0 -78
- package/dist/remote-cache-fxcl5C-L.mjs +0 -526
- package/dist/result-BrfgXtdO.mjs +0 -186
- package/dist/server-expo-Dvkd7JcF.mjs +0 -2
- package/dist/settings-BuKMOANA.mjs +0 -402
- package/dist/spawn-claims-Kqiifsk2.mjs +0 -72
- package/dist/stage-BNKKdDNc.mjs +0 -157
- package/dist/stim-desktop-8GQX2OV8.mjs +0 -63
- package/dist/tailnet-D7-tE_ug.mjs +0 -265
- package/dist/toolchain-B12psPA2.mjs +0 -2
- package/dist/toolchain-SqehyPLw.mjs +0 -1657
- package/dist/trigger-SHLOWJ4O.mjs +0 -2
- package/dist/web-CHN5gh34.mjs +0 -2
- package/dist/worktree-Cgnm6vZt.mjs +0 -2
- package/dist/{api-run.d.mts → doctor-fingerprint.d.mts} +0 -0
- package/dist/{errors-DzkMYh8Q.mjs → errors-ccaPc4ox.mjs} +2 -2
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { t as getExecutor } from "./exec-B81Qodjn.mjs";
|
|
2
|
-
import { D as withDirLock } from "./workspace-state-CvgTFe-h.mjs";
|
|
3
|
-
import { accessSync, constants, existsSync, mkdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { delimiter, dirname, join, resolve } from "node:path";
|
|
5
|
-
import { easMachineStateRoot, easMachineStateRoot as easMachineStateRoot$1, easSessionLedgerFile, easSessionLedgerLock, readEasSessionLedger, readEasSessionLedger as readEasSessionLedger$1, validEasSessionClaim } from "@stim-cli/core/state";
|
|
6
|
-
//#region src/diagnostics/stim-installations.ts
|
|
7
|
-
const VERSION_OUTPUT_LIMIT = 4096;
|
|
8
|
-
function parsedVersion(version) {
|
|
9
|
-
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
10
|
-
if (!match) return null;
|
|
11
|
-
const core = [
|
|
12
|
-
match[1],
|
|
13
|
-
match[2],
|
|
14
|
-
match[3]
|
|
15
|
-
];
|
|
16
|
-
if (core.some((part) => part.length > 1 && part.startsWith("0"))) return null;
|
|
17
|
-
const prereleaseParts = match[4]?.split(".");
|
|
18
|
-
if (prereleaseParts?.some((part) => !part || /^\d+$/.test(part) && part.length > 1 && part.startsWith("0"))) return null;
|
|
19
|
-
const prerelease = prereleaseParts?.map((part) => /^\d+$/.test(part) ? Number(part) : part);
|
|
20
|
-
return {
|
|
21
|
-
core: core.map(Number),
|
|
22
|
-
prerelease: prerelease ?? null
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function compareStimVersions(left, right) {
|
|
26
|
-
const a = parsedVersion(left);
|
|
27
|
-
const b = parsedVersion(right);
|
|
28
|
-
if (!a || !b) return null;
|
|
29
|
-
for (let index = 0; index < a.core.length; index += 1) {
|
|
30
|
-
const difference = (a.core[index] ?? 0) - (b.core[index] ?? 0);
|
|
31
|
-
if (difference !== 0) return difference;
|
|
32
|
-
}
|
|
33
|
-
if (!a.prerelease && !b.prerelease) return 0;
|
|
34
|
-
if (!a.prerelease) return 1;
|
|
35
|
-
if (!b.prerelease) return -1;
|
|
36
|
-
for (let index = 0; index < Math.max(a.prerelease.length, b.prerelease.length); index += 1) {
|
|
37
|
-
const x = a.prerelease[index];
|
|
38
|
-
const y = b.prerelease[index];
|
|
39
|
-
if (x === void 0) return -1;
|
|
40
|
-
if (y === void 0) return 1;
|
|
41
|
-
if (x === y) continue;
|
|
42
|
-
if (typeof x === "number" && typeof y === "number") return x - y;
|
|
43
|
-
if (typeof x === "number") return -1;
|
|
44
|
-
if (typeof y === "number") return 1;
|
|
45
|
-
return x < y ? -1 : 1;
|
|
46
|
-
}
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
function parseStimVersionOutput(output) {
|
|
50
|
-
const version = output?.split("\n")[0]?.trim() ?? "";
|
|
51
|
-
return parsedVersion(version) ? version.replace(/^v/, "") : null;
|
|
52
|
-
}
|
|
53
|
-
function executableNames(platform) {
|
|
54
|
-
return platform === "win32" ? [
|
|
55
|
-
"stim.cmd",
|
|
56
|
-
"stim.exe",
|
|
57
|
-
"stim"
|
|
58
|
-
] : ["stim"];
|
|
59
|
-
}
|
|
60
|
-
function stimExecutablePaths(pathValue, { platform = process.platform, cwd = process.cwd() } = {}) {
|
|
61
|
-
const found = [];
|
|
62
|
-
const seen = /* @__PURE__ */ new Set();
|
|
63
|
-
for (const entry of pathValue.split(delimiter)) {
|
|
64
|
-
const directory = resolve(cwd, entry || ".");
|
|
65
|
-
for (const name of executableNames(platform)) {
|
|
66
|
-
const path = join(directory, name);
|
|
67
|
-
try {
|
|
68
|
-
accessSync(path, platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
69
|
-
if (!statSync(path).isFile()) continue;
|
|
70
|
-
const realPath = realpathSync(path);
|
|
71
|
-
if (seen.has(realPath)) continue;
|
|
72
|
-
seen.add(realPath);
|
|
73
|
-
found.push({
|
|
74
|
-
path,
|
|
75
|
-
realPath
|
|
76
|
-
});
|
|
77
|
-
} catch {}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return found;
|
|
81
|
-
}
|
|
82
|
-
function canonicalPath(path) {
|
|
83
|
-
if (!path) return null;
|
|
84
|
-
try {
|
|
85
|
-
return realpathSync(resolve(path));
|
|
86
|
-
} catch {
|
|
87
|
-
return resolve(path);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function analyzeStimVersions(runningVersion, runningPath, installations) {
|
|
91
|
-
const candidates = [runningVersion, ...installations.map((entry) => entry.version)];
|
|
92
|
-
const versions = [...new Set(candidates)].filter((version) => version !== null && compareStimVersions(version, version) !== null).toSorted((left, right) => -(compareStimVersions(left, right) ?? 0));
|
|
93
|
-
const highestVersion = versions[0] ?? null;
|
|
94
|
-
const resolved = installations[0] ?? null;
|
|
95
|
-
return {
|
|
96
|
-
runningVersion,
|
|
97
|
-
runningPath,
|
|
98
|
-
resolved,
|
|
99
|
-
installations,
|
|
100
|
-
versions,
|
|
101
|
-
highestVersion,
|
|
102
|
-
resolvedIsOlder: Boolean(resolved?.version && highestVersion && (compareStimVersions(resolved.version, highestVersion) ?? 0) < 0)
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function probeStimVersion(path, timeoutMs) {
|
|
106
|
-
return new Promise((resolveProbe) => {
|
|
107
|
-
let settled = false;
|
|
108
|
-
let output = "";
|
|
109
|
-
const finish = (version) => {
|
|
110
|
-
if (settled) return;
|
|
111
|
-
settled = true;
|
|
112
|
-
clearTimeout(timer);
|
|
113
|
-
resolveProbe(version);
|
|
114
|
-
};
|
|
115
|
-
let child;
|
|
116
|
-
try {
|
|
117
|
-
child = getExecutor().spawn(path, ["--version"], {
|
|
118
|
-
stdio: [
|
|
119
|
-
"ignore",
|
|
120
|
-
"pipe",
|
|
121
|
-
"ignore"
|
|
122
|
-
],
|
|
123
|
-
detached: process.platform !== "win32"
|
|
124
|
-
});
|
|
125
|
-
} catch {
|
|
126
|
-
resolveProbe(null);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const timer = setTimeout(() => {
|
|
130
|
-
try {
|
|
131
|
-
if (process.platform !== "win32" && child.pid) process.kill(-child.pid, "SIGKILL");
|
|
132
|
-
else child.kill("SIGKILL");
|
|
133
|
-
} catch {}
|
|
134
|
-
finish(null);
|
|
135
|
-
}, timeoutMs);
|
|
136
|
-
child.stdout?.on("data", (chunk) => {
|
|
137
|
-
if (output.length < VERSION_OUTPUT_LIMIT) output += String(chunk).slice(0, VERSION_OUTPUT_LIMIT - output.length);
|
|
138
|
-
});
|
|
139
|
-
child.on("error", () => finish(null));
|
|
140
|
-
child.on("close", (code) => finish(code === 0 ? parseStimVersionOutput(output) : null));
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
async function inspectStimVersions(runningVersion, { pathValue = process.env.PATH ?? "", runningPath = process.argv[1], probeTimeoutMs = 5e3 } = {}) {
|
|
144
|
-
const paths = stimExecutablePaths(pathValue);
|
|
145
|
-
const versions = await Promise.all(paths.map((entry) => probeStimVersion(entry.path, probeTimeoutMs)));
|
|
146
|
-
const installations = paths.map((entry, index) => ({
|
|
147
|
-
path: entry.path,
|
|
148
|
-
realPath: entry.realPath,
|
|
149
|
-
version: versions[index] ?? null
|
|
150
|
-
}));
|
|
151
|
-
return analyzeStimVersions(runningVersion, canonicalPath(runningPath), installations);
|
|
152
|
-
}
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/engine/eas-machine-root-guard-env.ts
|
|
155
|
-
const EAS_TEST_GUARD_ROOT_ENV = "STIM_TEST_GUARD_REAL_EAS_ROOT";
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/engine/eas-session-ledger.ts
|
|
158
|
-
function assertEasMachineRootWritable(root) {
|
|
159
|
-
const guardedRoot = process.env[EAS_TEST_GUARD_ROOT_ENV];
|
|
160
|
-
if (!guardedRoot || resolve(root) !== resolve(guardedRoot)) return;
|
|
161
|
-
throw new Error(`Refusing to write the real EAS machine root ${root} from a test process. Pass a temporary ledgerRoot, machineRoot, or easLedgerRoot, or point HOME (and USERPROFILE on Windows) at a temporary directory.`);
|
|
162
|
-
}
|
|
163
|
-
function writeLedger(root, ledger) {
|
|
164
|
-
mkdirSync(root, { recursive: true });
|
|
165
|
-
const file = easSessionLedgerFile(root);
|
|
166
|
-
const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
167
|
-
writeFileSync(tmp, `${JSON.stringify(ledger, null, 2)}\n`);
|
|
168
|
-
try {
|
|
169
|
-
renameSync(tmp, file);
|
|
170
|
-
} catch (error) {
|
|
171
|
-
rmSync(tmp, { force: true });
|
|
172
|
-
throw error;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function recordEasSessionClaim(claim, root = easMachineStateRoot()) {
|
|
176
|
-
assertEasMachineRootWritable(root);
|
|
177
|
-
const normalized = validEasSessionClaim(claim.sessionId, claim);
|
|
178
|
-
if (!normalized) throw new Error(`Invalid EAS session claim for ${claim.sessionId}.`);
|
|
179
|
-
withDirLock(easSessionLedgerLock(root), () => {
|
|
180
|
-
const current = readEasSessionLedger(root);
|
|
181
|
-
if (!current.safe) throw new Error(current.notice ?? "EAS ownership ledger is unreadable.");
|
|
182
|
-
current.claims.set(normalized.sessionId, normalized);
|
|
183
|
-
writeLedger(root, {
|
|
184
|
-
version: 1,
|
|
185
|
-
claims: Object.fromEntries(current.claims)
|
|
186
|
-
});
|
|
187
|
-
}, { ensureParent: () => mkdirSync(dirname(easSessionLedgerLock(root)), { recursive: true }) });
|
|
188
|
-
}
|
|
189
|
-
function removeEasSessionClaim(sessionId, root = easMachineStateRoot()) {
|
|
190
|
-
const file = easSessionLedgerFile(root);
|
|
191
|
-
if (!existsSync(file)) return false;
|
|
192
|
-
assertEasMachineRootWritable(root);
|
|
193
|
-
return withDirLock(easSessionLedgerLock(root), () => {
|
|
194
|
-
const current = readEasSessionLedger(root);
|
|
195
|
-
if (!current.safe) return false;
|
|
196
|
-
if (!current.claims.delete(sessionId)) return false;
|
|
197
|
-
writeLedger(root, {
|
|
198
|
-
version: 1,
|
|
199
|
-
claims: Object.fromEntries(current.claims)
|
|
200
|
-
});
|
|
201
|
-
return true;
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
//#endregion
|
|
205
|
-
export { removeEasSessionClaim as a, recordEasSessionClaim as i, easMachineStateRoot$1 as n, compareStimVersions as o, readEasSessionLedger$1 as r, inspectStimVersions as s, assertEasMachineRootWritable as t };
|
package/dist/exec-B81Qodjn.mjs
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
|
-
import spawn from "cross-spawn";
|
|
3
|
-
import which from "which";
|
|
4
|
-
import { basename } from "path";
|
|
5
|
-
import { createDebugLog, runId } from "@stim-cli/core/state";
|
|
6
|
-
//#region src/debug-log.ts
|
|
7
|
-
const debugLog = createDebugLog("cli", { base: () => ({ runId: runId() }) });
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/exec.ts
|
|
10
|
-
const MAX_BUFFER = 67108864;
|
|
11
|
-
function nameTimeout(error, command, timeoutMs) {
|
|
12
|
-
if (error?.code === "ETIMEDOUT" && error instanceof Error) error.message = `Command timed out after ${timeoutMs}ms: ${command}`;
|
|
13
|
-
return error;
|
|
14
|
-
}
|
|
15
|
-
const WINDOWS_BATCH_FILE = /\.(?:bat|cmd)$/i;
|
|
16
|
-
const BATCH_UNSAFE_ARGUMENT = /["\r\n]/;
|
|
17
|
-
function isUnsafeBatchSpawn(target, args, platform = process.platform) {
|
|
18
|
-
return platform === "win32" && WINDOWS_BATCH_FILE.test(target) && args.some((arg) => BATCH_UNSAFE_ARGUMENT.test(arg));
|
|
19
|
-
}
|
|
20
|
-
function refuseUnsafeBatchArguments(file, args) {
|
|
21
|
-
if (process.platform !== "win32") return;
|
|
22
|
-
const target = which.sync(file, { nothrow: true }) ?? file;
|
|
23
|
-
if (isUnsafeBatchSpawn(target, args)) throw new Error(`Refusing to run ${basename(target)}: an argument contains a character cmd.exe could misinterpret (a double quote or a line break).`);
|
|
24
|
-
}
|
|
25
|
-
function redactError(error, values) {
|
|
26
|
-
const secrets = values?.filter(Boolean) ?? [];
|
|
27
|
-
if (secrets.length === 0 || !error || typeof error !== "object") return error;
|
|
28
|
-
const scrub = (text) => secrets.reduce((acc, secret) => acc.split(secret).join("***"), text);
|
|
29
|
-
const fields = error;
|
|
30
|
-
for (const key of Object.getOwnPropertyNames(error)) {
|
|
31
|
-
const value = fields[key];
|
|
32
|
-
if (typeof value === "string") fields[key] = scrub(value);
|
|
33
|
-
else if (Array.isArray(value)) fields[key] = value.map((item) => typeof item === "string" ? scrub(item) : item);
|
|
34
|
-
}
|
|
35
|
-
return error;
|
|
36
|
-
}
|
|
37
|
-
const defaultExecutor = {
|
|
38
|
-
run(cmd, { timeoutMs, killSignal, cwd, env } = {}) {
|
|
39
|
-
const opts = {
|
|
40
|
-
encoding: "utf-8",
|
|
41
|
-
stdio: [
|
|
42
|
-
"pipe",
|
|
43
|
-
"pipe",
|
|
44
|
-
"pipe"
|
|
45
|
-
],
|
|
46
|
-
maxBuffer: MAX_BUFFER
|
|
47
|
-
};
|
|
48
|
-
if (timeoutMs) opts.timeout = timeoutMs;
|
|
49
|
-
if (killSignal) opts.killSignal = killSignal;
|
|
50
|
-
if (cwd) opts.cwd = cwd;
|
|
51
|
-
if (env) opts.env = {
|
|
52
|
-
...process.env,
|
|
53
|
-
...env
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
return String(execSync(cmd, opts)).trim();
|
|
57
|
-
} catch (error) {
|
|
58
|
-
throw nameTimeout(error, cmd, timeoutMs);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
runFile(file, args = [], { timeoutMs, killSignal, cwd, env, omitEnv, input, untrimmed, rejectStderr, detachedSilent, redact } = {}) {
|
|
62
|
-
const opts = {
|
|
63
|
-
encoding: "utf-8",
|
|
64
|
-
stdio: detachedSilent ? "ignore" : [
|
|
65
|
-
"pipe",
|
|
66
|
-
"pipe",
|
|
67
|
-
"pipe"
|
|
68
|
-
],
|
|
69
|
-
maxBuffer: MAX_BUFFER
|
|
70
|
-
};
|
|
71
|
-
if (detachedSilent) opts.detached = true;
|
|
72
|
-
if (timeoutMs) opts.timeout = timeoutMs;
|
|
73
|
-
if (killSignal) opts.killSignal = killSignal;
|
|
74
|
-
if (cwd) opts.cwd = cwd;
|
|
75
|
-
if (input !== void 0) opts.input = input;
|
|
76
|
-
if (env || omitEnv?.length) {
|
|
77
|
-
const childEnv = {
|
|
78
|
-
...process.env,
|
|
79
|
-
...env
|
|
80
|
-
};
|
|
81
|
-
for (const key of omitEnv ?? []) delete childEnv[key];
|
|
82
|
-
opts.env = childEnv;
|
|
83
|
-
}
|
|
84
|
-
refuseUnsafeBatchArguments(file, args);
|
|
85
|
-
const result = spawn.sync(file, args, opts);
|
|
86
|
-
if (result.error) throw redactError(nameTimeout(Object.assign(result.error, result), [file, ...args].join(" "), timeoutMs), redact);
|
|
87
|
-
if (result.status !== 0 || rejectStderr && String(result.stderr ?? "").trim()) {
|
|
88
|
-
const stderr = String(result.stderr ?? "");
|
|
89
|
-
const message = `Command failed: ${[file, ...args].join(" ")}${stderr ? `\n${stderr}` : ""}`;
|
|
90
|
-
throw redactError(Object.assign(new Error(message), result), redact);
|
|
91
|
-
}
|
|
92
|
-
if (detachedSilent) return "";
|
|
93
|
-
return untrimmed ? String(result.stdout) : String(result.stdout).trim();
|
|
94
|
-
},
|
|
95
|
-
runFileAsync(file, args = [], { timeoutMs, killSignal, cwd, env, omitEnv, rejectStderr, onSpawn, detachedSilent, redact } = {}) {
|
|
96
|
-
const command = [file, ...args].join(" ");
|
|
97
|
-
return new Promise((resolve, reject) => {
|
|
98
|
-
refuseUnsafeBatchArguments(file, args);
|
|
99
|
-
const opts = detachedSilent ? {
|
|
100
|
-
stdio: "ignore",
|
|
101
|
-
detached: true
|
|
102
|
-
} : { stdio: [
|
|
103
|
-
"ignore",
|
|
104
|
-
"pipe",
|
|
105
|
-
"pipe"
|
|
106
|
-
] };
|
|
107
|
-
if (cwd) opts.cwd = cwd;
|
|
108
|
-
if (env || omitEnv?.length) {
|
|
109
|
-
const childEnv = {
|
|
110
|
-
...process.env,
|
|
111
|
-
...env
|
|
112
|
-
};
|
|
113
|
-
for (const key of omitEnv ?? []) delete childEnv[key];
|
|
114
|
-
opts.env = childEnv;
|
|
115
|
-
}
|
|
116
|
-
const child = spawn(file, args, opts);
|
|
117
|
-
try {
|
|
118
|
-
onSpawn?.(child);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
child.kill("SIGKILL");
|
|
121
|
-
reject(error);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const stdout = [];
|
|
125
|
-
const stderr = [];
|
|
126
|
-
let timedOut = false;
|
|
127
|
-
const timer = timeoutMs ? setTimeout(() => {
|
|
128
|
-
timedOut = true;
|
|
129
|
-
child.kill(killSignal ?? "SIGTERM");
|
|
130
|
-
}, timeoutMs) : void 0;
|
|
131
|
-
child.stdout?.on("data", (chunk) => stdout.push(chunk));
|
|
132
|
-
child.stderr?.on("data", (chunk) => stderr.push(chunk));
|
|
133
|
-
child.on("error", (error) => {
|
|
134
|
-
clearTimeout(timer);
|
|
135
|
-
reject(redactError(error, redact));
|
|
136
|
-
});
|
|
137
|
-
child.on("close", (status, signal) => {
|
|
138
|
-
clearTimeout(timer);
|
|
139
|
-
const out = Buffer.concat(stdout).toString("utf-8");
|
|
140
|
-
const err = Buffer.concat(stderr).toString("utf-8");
|
|
141
|
-
const result = {
|
|
142
|
-
status,
|
|
143
|
-
signal,
|
|
144
|
-
stdout: out,
|
|
145
|
-
stderr: err
|
|
146
|
-
};
|
|
147
|
-
if (timedOut) reject(redactError(nameTimeout(Object.assign(new Error(command), result, { code: "ETIMEDOUT" }), command, timeoutMs), redact));
|
|
148
|
-
else if (status !== 0 || rejectStderr && err.trim()) reject(redactError(Object.assign(/* @__PURE__ */ new Error(`Command failed: ${command}${err ? `\n${err}` : ""}`), result), redact));
|
|
149
|
-
else resolve(detachedSilent ? "" : out.trim());
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
runQuiet(cmd, opts) {
|
|
154
|
-
try {
|
|
155
|
-
return this.run(cmd, opts);
|
|
156
|
-
} catch {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
runFileQuiet(file, args, opts) {
|
|
161
|
-
try {
|
|
162
|
-
return this.runFile(file, args, opts);
|
|
163
|
-
} catch {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
spawn(cmd, args = [], opts = {}) {
|
|
168
|
-
refuseUnsafeBatchArguments(cmd, args);
|
|
169
|
-
return spawn(cmd, args, opts);
|
|
170
|
-
},
|
|
171
|
-
findExecutable(name) {
|
|
172
|
-
return which.sync(name, { nothrow: true });
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
/** The program a call runs, without its arguments: those can carry tokens. */
|
|
176
|
-
const programOf = (command) => basename(command.trim().split(/\s+/)[0] ?? "");
|
|
177
|
-
function outcomeOf(error) {
|
|
178
|
-
const { status, signal, code } = error ?? {};
|
|
179
|
-
return {
|
|
180
|
-
ok: false,
|
|
181
|
-
...typeof status === "number" ? { exit: status } : {},
|
|
182
|
-
...signal ? { signal } : {},
|
|
183
|
-
...code ? { code } : {}
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
let executionId = 0;
|
|
187
|
-
function timedSync(fn, program) {
|
|
188
|
-
return (...args) => {
|
|
189
|
-
if (!debugLog.enabled()) return fn(...args);
|
|
190
|
-
const id = ++executionId;
|
|
191
|
-
const name = program(...args);
|
|
192
|
-
const started = performance.now();
|
|
193
|
-
debugLog.log("exec.start", {
|
|
194
|
-
program: name,
|
|
195
|
-
executionId: id
|
|
196
|
-
});
|
|
197
|
-
try {
|
|
198
|
-
const out = fn(...args);
|
|
199
|
-
debugLog.log("exec", {
|
|
200
|
-
program: name,
|
|
201
|
-
executionId: id,
|
|
202
|
-
ms: Math.round(performance.now() - started),
|
|
203
|
-
ok: true
|
|
204
|
-
});
|
|
205
|
-
return out;
|
|
206
|
-
} catch (error) {
|
|
207
|
-
debugLog.log("exec", {
|
|
208
|
-
program: name,
|
|
209
|
-
executionId: id,
|
|
210
|
-
ms: Math.round(performance.now() - started),
|
|
211
|
-
...outcomeOf(error)
|
|
212
|
-
});
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
let active = {
|
|
218
|
-
...defaultExecutor,
|
|
219
|
-
run: timedSync((cmd, opts) => defaultExecutor.run(cmd, opts), programOf),
|
|
220
|
-
runFile: timedSync((file, args, opts) => defaultExecutor.runFile(file, args, opts), (file) => basename(file)),
|
|
221
|
-
async runFileAsync(file, args, opts) {
|
|
222
|
-
if (!debugLog.enabled()) return defaultExecutor.runFileAsync(file, args, opts);
|
|
223
|
-
const id = ++executionId;
|
|
224
|
-
const name = basename(file);
|
|
225
|
-
const started = performance.now();
|
|
226
|
-
debugLog.log("exec.start", {
|
|
227
|
-
program: name,
|
|
228
|
-
executionId: id
|
|
229
|
-
});
|
|
230
|
-
try {
|
|
231
|
-
const out = await defaultExecutor.runFileAsync(file, args, opts);
|
|
232
|
-
debugLog.log("exec", {
|
|
233
|
-
program: name,
|
|
234
|
-
executionId: id,
|
|
235
|
-
ms: Math.round(performance.now() - started),
|
|
236
|
-
ok: true
|
|
237
|
-
});
|
|
238
|
-
return out;
|
|
239
|
-
} catch (error) {
|
|
240
|
-
debugLog.log("exec", {
|
|
241
|
-
program: name,
|
|
242
|
-
executionId: id,
|
|
243
|
-
ms: Math.round(performance.now() - started),
|
|
244
|
-
...outcomeOf(error)
|
|
245
|
-
});
|
|
246
|
-
throw error;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
function getExecutor() {
|
|
251
|
-
return active;
|
|
252
|
-
}
|
|
253
|
-
//#endregion
|
|
254
|
-
export { debugLog as n, getExecutor as t };
|