stim 1.18.0 → 1.20.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 +21 -4
- package/dist/{activity-BxnkDZDi.mjs → activity-BrGh9EAI.mjs} +3 -3
- package/dist/{agent-device-usage-output-CZ66YA4T.mjs → agent-device-usage-output-DVyv_hWj.mjs} +7 -7
- package/dist/android-0vv-OruW.mjs +6 -0
- package/dist/android-Brx6EKvJ.mjs +1258 -0
- package/dist/{android-DC3ZLuw0.mjs → android-BsYNR81W.mjs} +103 -45
- package/dist/{android-CBwCNicO.mjs → android-CK3fpEyZ.mjs} +2 -2
- package/dist/{android-cas-BBFyr9CA.mjs → android-cas-DCAuXryb.mjs} +9 -5
- package/dist/android-cas-compiler.mjs +1 -1
- package/dist/api-run.mjs +159 -8
- package/dist/{api-D0VtFhqk.mjs → api-zuX3ynYN.mjs} +9 -7
- package/dist/api.d.mts +104 -4
- package/dist/api.mjs +1 -1
- package/dist/{app-install-D-PUENug.mjs → app-install-0LgaQRT7.mjs} +39 -18
- package/dist/artifact-CnC0mfov.mjs +807 -0
- package/dist/artifact-DClXJNWx.mjs +772 -0
- package/dist/artifact-lifecycle-DzPpBYvK.mjs +30 -0
- package/dist/{web-DTU0uiWj.mjs → browser-web-CzBmhmgs.mjs} +136 -174
- package/dist/{budget-DIhL2BKx.mjs → budget-BONq9vXY.mjs} +3096 -3244
- package/dist/build-BixRI6sB.mjs +462 -0
- package/dist/build-plan-CP0tckNU.mjs +553 -0
- package/dist/{cache-manifest-BI7ozfmH.mjs → cache-manifest-qA3dT2x2.mjs} +1 -1
- package/dist/cache-manifest.mjs +1 -1
- package/dist/ccache-CjHQ5F8g.mjs +142 -0
- package/dist/{chrome-DJnmnS5q.mjs → chrome-Dp2lMLBe.mjs} +1 -1
- package/dist/{cli-DNJMwADx.mjs → cli-B2R8wH1F.mjs} +20 -20
- package/dist/cli.mjs +1 -1
- package/dist/{client-DzhapoMB.mjs → client-BLy1Pw2V.mjs} +172 -165
- package/dist/collector-run.d.mts +10 -0
- package/dist/collector-run.mjs +7 -7
- package/dist/{command-output-CBtzyIgF.mjs → command-output-BjPN99ZB.mjs} +2 -2
- package/dist/{config-CgYMahz7.mjs → config-D0LhTY3S.mjs} +13 -13
- package/dist/{created-devices-DKbeWsiK.mjs → created-devices-HU_DAb_Q.mjs} +7 -6
- package/dist/{dependency-state-xKoOypBm.mjs → dependency-state-B2m8eqsS.mjs} +2 -2
- package/dist/{detached-entry-BLfcgc4O.mjs → detached-entry-BXq4fIl-.mjs} +1 -1
- package/dist/{dev-client-CLnIH02x.mjs → dev-client-ClATaJoH.mjs} +2 -2
- package/dist/{device-D7oCHGWi.mjs → device-B7lsC0K1.mjs} +8 -8
- package/dist/device-DVCwAFlX.mjs +727 -0
- package/dist/{device-capacity-EUOOYr8T.mjs → device-capacity-Ca_ke1LE.mjs} +25 -15
- package/dist/device-host-worker.mjs +38 -18
- package/dist/{device-ios-6MewKKnc.mjs → device-ios-CRUqPxKw.mjs} +12 -11
- package/dist/{device-lease-Co-EwifR.mjs → device-lease-DHOBXGgS.mjs} +135 -22
- package/dist/{device-lease-run-w1xhCqIW.mjs → device-lease-run-CvDeHTkG.mjs} +4 -4
- package/dist/{device-pool-F5WvRPtD.mjs → device-pool-L2-5GxMy.mjs} +3 -3
- package/dist/{device-remote-tHbd1fKy.mjs → device-remote-Bmg42063.mjs} +17 -69
- package/dist/doctor-C2MSuMMg.mjs +515 -0
- package/dist/{doctor-B9ckYUoU.mjs → doctor-DPAqhVCK.mjs} +334 -721
- package/dist/doctor-watchman-CB4NnVZm.mjs +260 -0
- package/dist/{simslim-EHBQ2R4G.mjs → eas-build-Dw_ec2Km.mjs} +6 -152
- package/dist/{stim-installations-aR_WsNOA.mjs → eas-session-ledger-DZlC-Fq3.mjs} +57 -4
- package/dist/{error-diagnostics-BRXOqDzG.mjs → error-diagnostics-Du7I_GuY.mjs} +17 -12
- package/dist/errors-DzkMYh8Q.mjs +205 -0
- package/dist/{exec-DWhCZDGm.mjs → exec-B81Qodjn.mjs} +69 -15
- package/dist/{gc-Dh6mXOKC.mjs → gc-PWp34zGb.mjs} +23 -22
- package/dist/{gradle-C6GKnunQ.mjs → gradle-C2OEKCCI.mjs} +50 -125
- package/dist/{guide-tm6igAaa.mjs → guide-Dai9lphv.mjs} +862 -538
- package/dist/{hosted-android-Bv285t_t.mjs → hosted-android-DQ-Agsd8.mjs} +5 -5
- package/dist/{hosted-client-C-rMtppF.mjs → hosted-client-Io01s5By.mjs} +9 -3
- package/dist/{hosted-ios-D5mNmtj4.mjs → hosted-ios-DIxFnYp-.mjs} +3 -3
- package/dist/{hosted-logs-DN8Iz4mJ.mjs → hosted-logs-DP-ABU_M.mjs} +8 -8
- package/dist/{hosted-macos-B-wEjlwG.mjs → hosted-macos-Aziw9T_9.mjs} +7 -6
- package/dist/{hosted-native-DeeOG8xZ.mjs → hosted-native-BdAQi21M.mjs} +23 -16
- package/dist/{idle-shutdown-jjtxAn5C.mjs → idle-shutdown-DdMqoSUB.mjs} +7 -7
- package/dist/ios-BZ9dg2Fr.mjs +9 -0
- package/dist/{ios-B3SbOWdw.mjs → ios-CXLIUxXJ.mjs} +180 -24
- package/dist/ios-CZuv6gRv.mjs +1112 -0
- package/dist/{ios-Bvbf0SGY.mjs → ios-VGvNdsv2.mjs} +1 -1
- package/dist/{ios-device-Bn7jWDB1.mjs → ios-device-B1B14xND.mjs} +1 -1
- package/dist/{ios-device-vOaByMhw.mjs → ios-device-BreZOpM0.mjs} +3 -3
- package/dist/ios-project-B9drt_aY.mjs +197 -0
- package/dist/{ios-state-B2pES6Vs.mjs → ios-state-CjrL2qv-.mjs} +1 -1
- package/dist/js-swap-C8icNYIY.mjs +432 -0
- package/dist/launch-DxH0THLP.mjs +745 -0
- package/dist/launch-YrbqaIFj.mjs +1530 -0
- package/dist/{launch-verify-hskNcWkZ.mjs → launch-verify-BzRdbuO1.mjs} +26 -7
- package/dist/{logs-1Ylc1Ri6.mjs → logs-DHaRNfg7.mjs} +11 -11
- package/dist/macos-C0iljhsN.mjs +2 -0
- package/dist/{macos-DF6C7wUU.mjs → macos-V_3Ui7g4.mjs} +125 -155
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +13 -10
- package/dist/{metro-Dh8T4Ytd.mjs → metro-D_j9sN-B.mjs} +209 -43
- package/dist/{metro-gateway-CEUw9RMH.mjs → metro-gateway-BBJldOdi.mjs} +2 -2
- package/dist/miss-reason-BPAzZS0r.mjs +238 -0
- package/dist/{named-ports-BFIz1Shz.mjs → named-ports-C2lvoPsb.mjs} +12 -5
- package/dist/native-android-lHzaew7r.mjs +226 -0
- package/dist/native-gradle-inputs-BQnIdAlL.mjs +356 -0
- package/dist/{native-runtime-D_603JiC.mjs → native-runtime-BRmWL7ru.mjs} +9 -8
- package/dist/native-xcode-inputs-eutS19jU.mjs +307 -0
- package/dist/native-xcode-ios-DP3cHLwu.mjs +434 -0
- package/dist/{ndjson-LGZAMsqa.mjs → ndjson-GOnbyvso.mjs} +6 -6
- package/dist/offload-worker.d.mts +12 -6
- package/dist/offload-worker.mjs +409 -73
- package/dist/{ownership-D6Se7gg_.mjs → ownership-DXzMMSx6.mjs} +2 -2
- package/dist/{placement-log-BcPhRwR4.mjs → placement-log-reFbjqEr.mjs} +7 -3
- package/dist/plan-BDk2AeY_.mjs +260 -0
- package/dist/plan-placement-D_YYlE6N.mjs +73 -0
- package/dist/{ports-BLTtfBq-.mjs → ports-jzvAJXXL.mjs} +3 -3
- package/dist/{prebuild-juCyreaR.mjs → prebuild-Bw44QxVh.mjs} +4 -4
- package/dist/{preview-D5V07Nrl.mjs → preview-BaBJ72Al.mjs} +51 -34
- package/dist/project-B8_duAzW.mjs +1067 -0
- package/dist/project-plan-BPwbLwQu.mjs +10 -0
- package/dist/{pull-request-u4vp7zmK.mjs → pull-request-vOhLNmIb.mjs} +1 -1
- package/dist/pull-requests.mjs +1 -1
- package/dist/react-native-android-chm1DMlA.mjs +921 -0
- package/dist/react-native-build-oAw6gQeW.mjs +239 -0
- package/dist/react-native-doctor-DYXoh-6I.mjs +78 -0
- package/dist/react-native-ios-SCTK_CT5.mjs +595 -0
- package/dist/{recordings-BAWltsVt.mjs → recordings-Bk-VivUV.mjs} +1 -1
- package/dist/{reload-DvyWzVjJ.mjs → reload-D34GkY78.mjs} +17 -14
- package/dist/remote-BU9UyhCJ.mjs +192 -0
- package/dist/{remote-cache-BGg7aGIZ.mjs → remote-cache-Bsts6f6Y.mjs} +5 -5
- package/dist/result-BDoRk1k3.mjs +186 -0
- package/dist/{run-vhtDgpHO.mjs → run-qvff78hv.mjs} +3 -3
- package/dist/{server-bare-B9E7S1aR.mjs → server-bare-dWjAarki.mjs} +6 -6
- package/dist/server-command-7XIKlWtO.mjs +69 -0
- package/dist/{server-expo-DoBHhuzK.mjs → server-expo-CsYu2aKL.mjs} +107 -82
- package/dist/server-expo-DV43vep4.mjs +2 -0
- package/dist/settings-Bbztm4oV.mjs +1503 -0
- package/dist/{settings-Byp2AQ_E.mjs → settings-CT3E71-i.mjs} +6 -7
- package/dist/{state-lKh8shBp.d.mts → settings-vk3mJGSm.d.mts} +4 -2
- package/dist/settings.schema.json +156 -6
- package/dist/simslim-ChMfe8rg.mjs +149 -0
- package/dist/{slot-launch-C1nqh4mu.mjs → slot-launch-B9hn96wd.mjs} +6 -6
- package/dist/{stage-g_WqWeaE.mjs → stage-BNKKdDNc.mjs} +6 -3
- package/dist/start-CbQCSnXQ.mjs +2 -0
- package/dist/{start-D-IeOyoK.mjs → start-CdvcTaXr.mjs} +113 -77
- package/dist/{state-xnqpx3AD.mjs → state-Boo0IMJq.mjs} +4 -2
- package/dist/{state-BG-aAk4k.mjs → state-DI84A-uu.mjs} +29 -10
- package/dist/{stats-DY6ekz8F.mjs → stats-BIIDrjA8.mjs} +6 -6
- package/dist/{status-BEeL6IKz.mjs → status-BDGHwkCs.mjs} +3 -1
- package/dist/{status-DCjZeE-K.mjs → status-DARMkc9q.mjs} +80 -294
- package/dist/status-watch-DvmI3SmN.mjs +296 -0
- package/dist/{stim-desktop-Behws_fi.mjs → stim-desktop-8GQX2OV8.mjs} +1 -1
- package/dist/{stop-DIJtD2GL.mjs → stop-CCZS-C9m.mjs} +2 -2
- package/dist/stop-WQPQHLuy.mjs +72 -0
- package/dist/{stop-BTjs3xbc.mjs → stop-iNemHsJC.mjs} +81 -33
- package/dist/supervisor-run.d.mts +7 -2
- package/dist/supervisor-run.mjs +32 -20
- package/dist/{support-Bwvbrq5-.mjs → support-CnE_SIjt.mjs} +17 -7
- package/dist/{support-BaayeYCf.mjs → support-DCco5fut.mjs} +61 -8
- package/dist/swiftpm-macos-afeNUExW.mjs +119 -0
- package/dist/{native-run-B06FkmZx.mjs → tailnet-CoJUb2tB.mjs} +113 -6
- package/dist/toolchain-BIupIro1.mjs +2 -0
- package/dist/{toolchain-Bnyd_K3A.mjs → toolchain-DqyDXs30.mjs} +225 -315
- package/dist/{trigger-CJMhwXe8.mjs → trigger-C0MWBi8O.mjs} +3 -3
- package/dist/trigger-SHLOWJ4O.mjs +2 -0
- package/dist/{warm-progress-CjB-MP6H.mjs → warm-progress-C3ASD6z5.mjs} +134 -37
- package/dist/{status-Dcr0Qexd.mjs → watchman-CQl51YZu.mjs} +75 -7
- package/dist/web-B3eldHFH.mjs +123 -0
- package/dist/web-BLXpOe6b.mjs +2 -0
- package/dist/web-run.mjs +10 -10
- package/dist/{workspace-state-C59dqG-Z.mjs → workspace-state-CSIFuuDa.mjs} +33 -33
- package/dist/{workspaces-xXItD8Dj.mjs → workspaces-D2xSHBDY.mjs} +1297 -1211
- package/dist/{worktree-BSYlofkq.mjs → worktree-BxDqaTev.mjs} +102 -63
- package/dist/worktree-q7_OZNY0.mjs +2 -0
- package/package.json +8 -6
- package/shim/bundle-response.cjs +2 -1
- package/shim/bundle-response.d.cts +1 -1
- package/shim/expo-metro-config.cjs +1 -1
- package/shim/native-android.gradle +101 -0
- package/dist/android-BKA16DTf.mjs +0 -4
- package/dist/android-BvwuMUJ9.mjs +0 -3572
- package/dist/guide-status-Bhf9SJXc.mjs +0 -125
- package/dist/ios-CPdkoKaa.mjs +0 -3953
- package/dist/ios-DNpdygiv.mjs +0 -7
- package/dist/macos-Ck7OBMNY.mjs +0 -2
- package/dist/metro-store-BAHFcJm6.mjs +0 -106
- package/dist/plan-placement-CtxkCO54.mjs +0 -1859
- package/dist/project-C3ChRLZy.mjs +0 -212
- package/dist/projects-DD7dBTCj.mjs +0 -92
- package/dist/server-expo-Db9HBUoa.mjs +0 -2
- package/dist/settings-CQyMElEP.mjs +0 -701
- package/dist/start-NTc1Ifqs.mjs +0 -2
- package/dist/stop-BGhKMOuH.mjs +0 -48
- package/dist/trigger-DWAq9hkw.mjs +0 -2
- package/dist/web-B6_bFDn7.mjs +0 -2
- package/dist/worktree-BJfnU6r5.mjs +0 -2
- package/dist/worktree-CsKYexJM.mjs +0 -753
|
@@ -0,0 +1,1112 @@
|
|
|
1
|
+
import { L as deviceSlotFileKey, V as parseDeviceSlotOption, W as validateDeviceSlot } from "./config-D0LhTY3S.mjs";
|
|
2
|
+
import { C as iosSigningIdentitySha1Setting, I as projectSettingsContext, L as publicUrlSetting, N as metroWarmupUrlSetting, S as iosSigningIdentitySettingError, _ as iosLanHostSetting, a as SETTING_SHAPE_REMEDY, g as deviceReclaimIdleMinutesSetting, j as metroPortSetting, tt as tunnelModeSetting, v as iosLanHostSettingError, w as iosSigningIdentitySha1SettingError, x as iosSigningIdentitySetting } from "./settings-Bbztm4oV.mjs";
|
|
3
|
+
import { i as recordWorkspaceUse, w as workspaceLogsDir$1 } from "./workspace-state-CSIFuuDa.mjs";
|
|
4
|
+
import { _ as stepTimer, g as stepClock, i as formatDuration, l as phaseLine } from "./command-output-BjPN99ZB.mjs";
|
|
5
|
+
import { I as workspaceDevServerMode, t as NO_PROJECT_REFUSAL } from "./project-B8_duAzW.mjs";
|
|
6
|
+
import { at as POOL_SETTING_REMEDY, dt as parkedMaxSetting } from "./android-BsYNR81W.mjs";
|
|
7
|
+
import { At as createRunRecorder, It as statsProjectKey$1, Ot as startBuildProgress, kt as tapBuildLog, yt as NO_BUILD_PROGRESS } from "./budget-BONq9vXY.mjs";
|
|
8
|
+
import { S as withNativeBuildRun, b as runCancellation, p as cancelledFailure, x as runCancellationSignal } from "./tailnet-CoJUb2tB.mjs";
|
|
9
|
+
import { d as optimizationBuildProfile, l as artifactCachePolicy } from "./errors-DzkMYh8Q.mjs";
|
|
10
|
+
import { o as exitAfterFlush } from "./remote-cache-Bsts6f6Y.mjs";
|
|
11
|
+
import { d as simulatorRuntime, f as setRemoteLogSink, g as parseBuildMachineOption } from "./client-BLy1Pw2V.mjs";
|
|
12
|
+
import { i as createIosSimSnapshot } from "./ios-CXLIUxXJ.mjs";
|
|
13
|
+
import { r as DEFAULT_METRO_PORT } from "./app-install-0LgaQRT7.mjs";
|
|
14
|
+
import { r as isPhysicalDeviceRequest, t as ensureDevServer } from "./native-runtime-BRmWL7ru.mjs";
|
|
15
|
+
import { _ as COMPILATION_CACHE_NOT_RUN } from "./toolchain-DqyDXs30.mjs";
|
|
16
|
+
import "./dev-client-ClATaJoH.mjs";
|
|
17
|
+
import { f as waitFlagConflict, o as leaseExpiryText } from "./device-lease-run-CvDeHTkG.mjs";
|
|
18
|
+
import { r as hostedMetroSettings } from "./metro-gateway-BBJldOdi.mjs";
|
|
19
|
+
import { i as writeDevicePlacement } from "./ios-state-CjrL2qv-.mjs";
|
|
20
|
+
import { a as refusePlan, i as printPlan, n as planFlagRefusal } from "./build-plan-CP0tckNU.mjs";
|
|
21
|
+
import { r as siblingPlatformSlots, t as launchSlotScope } from "./slot-launch-B9hn96wd.mjs";
|
|
22
|
+
import { S as ownedSessionName, n as binOnPath } from "./device-remote-Bmg42063.mjs";
|
|
23
|
+
import { r as isEasBuildFailure } from "./eas-build-Dw_ec2Km.mjs";
|
|
24
|
+
import { t as didSetUpDevice } from "./device-DVCwAFlX.mjs";
|
|
25
|
+
import { t as unsupportedPlan } from "./project-plan-BPwbLwQu.mjs";
|
|
26
|
+
import { _ as resolveIosWait, a as deviceModelRefusal, b as resolveSimulatorAppFlag, c as iosProjectPathError, d as ownedSimFailure, g as resolveIosBuildSetup, h as resolveDeviceType, i as deviceLabel, m as resolveConfiguration, n as buildLogFile, r as createIosDeviceWaitRun, u as isReleaseConfiguration, v as resolveRuntime, x as simulatorBuildArch, y as resolveSchemeSelection } from "./support-DCco5fut.mjs";
|
|
27
|
+
import { a as lastBuildRecord, o as reportIosResult, s as writeLastBuild } from "./ios-project-B9drt_aY.mjs";
|
|
28
|
+
import { t as acquireIosArtifact } from "./artifact-CnC0mfov.mjs";
|
|
29
|
+
import { a as iosPlacementBudget, i as hostedIosSelectors, n as connectIosTarget, o as selectIosPlacement, r as hostedIosMetroNote, t as connectIosBackend } from "./remote-BU9UyhCJ.mjs";
|
|
30
|
+
import { a as iosPoolCandidates, c as isWirelessIosDevice, f as resolveIosPhysicalDevice, o as iosPoolNoCandidatesRefusal, r as iosDeviceBounds } from "./ios-device-BreZOpM0.mjs";
|
|
31
|
+
import { i as DEFAULT_DEPS, l as lanOriginUrlFor, s as chooseLanAddress, t as finishIosRun } from "./launch-YrbqaIFj.mjs";
|
|
32
|
+
import { basename, join } from "node:path";
|
|
33
|
+
import { hostedIosStatus, parseMachine } from "@stim-cli/core/state";
|
|
34
|
+
import { workspaceId } from "@stim-cli/core";
|
|
35
|
+
import { InvalidArgumentError } from "commander";
|
|
36
|
+
import chalk from "chalk";
|
|
37
|
+
//#region src/commands/ios/hosted.ts
|
|
38
|
+
async function finishHostedIosRun({ target, d, artifact, root, slot, release, appMode, isExpo, metroCheck, metroPort, logsDir, fail, note, enterPhase, selectors, projectBundleId, ...report }) {
|
|
39
|
+
const bundleId = artifact.bundleId ?? (d.readBundleId(artifact.path) || projectBundleId());
|
|
40
|
+
if (!bundleId) return fail({
|
|
41
|
+
code: "STIM_INSTALL_FAILED",
|
|
42
|
+
message: "The built app has no bundle identifier."
|
|
43
|
+
});
|
|
44
|
+
const launchedAt = d.now();
|
|
45
|
+
let run;
|
|
46
|
+
try {
|
|
47
|
+
run = await d.placeHostedIos(target, {
|
|
48
|
+
root,
|
|
49
|
+
slot,
|
|
50
|
+
bundle: artifact.path,
|
|
51
|
+
handoff: artifact.handoff,
|
|
52
|
+
bundleId,
|
|
53
|
+
selectors,
|
|
54
|
+
release,
|
|
55
|
+
mode: appMode,
|
|
56
|
+
...appMode === "development" && isExpo ? { devClientScheme: d.devClientScheme(root, artifact.path) ?? void 0 } : {},
|
|
57
|
+
reserved: (placement) => d.writeHostedIos(root, slot, placement),
|
|
58
|
+
note,
|
|
59
|
+
enterPhase
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return fail({
|
|
63
|
+
code: error.code ?? "STIM_HOSTING_REFUSED",
|
|
64
|
+
message: error.message,
|
|
65
|
+
remedy: error instanceof Error && "remedy" in error && typeof error.remedy === "string" ? error.remedy : `Retry stim ios --remote ${target.host.machine}, or run stim stop to reconcile any recorded placement.`
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
d.writeHostedIos(root, slot, run.placement);
|
|
69
|
+
d.writeWorkspaceLaunch(root, "ios", {
|
|
70
|
+
appId: bundleId,
|
|
71
|
+
deviceId: run.placement.session,
|
|
72
|
+
metroPort,
|
|
73
|
+
release,
|
|
74
|
+
...appMode === "process" ? { runtime: "process" } : {},
|
|
75
|
+
launchedAt: new Date(launchedAt).toISOString()
|
|
76
|
+
}, slot);
|
|
77
|
+
let launched = run.launched;
|
|
78
|
+
if (appMode === "development" && metroCheck) {
|
|
79
|
+
const evidence = await d.verifyLaunch({
|
|
80
|
+
requireBundleResponse: true,
|
|
81
|
+
platform: "ios",
|
|
82
|
+
logsDir,
|
|
83
|
+
since: launchedAt,
|
|
84
|
+
metroPort,
|
|
85
|
+
mode: workspaceDevServerMode(root, isExpo),
|
|
86
|
+
slot: launchSlotScope(root, slot),
|
|
87
|
+
platformShared: siblingPlatformSlots(root, "ios", slot).length > 0
|
|
88
|
+
});
|
|
89
|
+
if (evidence.fatal) return fail({
|
|
90
|
+
code: "STIM_LAUNCH_FAILED",
|
|
91
|
+
message: "Metro could not deliver the hosted app bundle.",
|
|
92
|
+
remedy: "Run stim logs --errors and fix the bundle error."
|
|
93
|
+
});
|
|
94
|
+
launched = evidence.verified ? true : evidence.requested ? "bundling" : "unverified";
|
|
95
|
+
}
|
|
96
|
+
if (launched === "unverified") note(`Launch on ${target.host.machine} is unverified; check the hosted app, then retry stim ios --remote ${target.host.machine}.`);
|
|
97
|
+
const cache = artifact.cache;
|
|
98
|
+
const device = run.placement.device;
|
|
99
|
+
const uploadsAbandoned = await artifact.completeUploads();
|
|
100
|
+
return {
|
|
101
|
+
facts: reportIosResult({
|
|
102
|
+
...report,
|
|
103
|
+
...appMode === "process" ? { runtimeKind: "process" } : {},
|
|
104
|
+
root,
|
|
105
|
+
slot,
|
|
106
|
+
release,
|
|
107
|
+
metroCheck,
|
|
108
|
+
metroPort,
|
|
109
|
+
logsDir,
|
|
110
|
+
device: {
|
|
111
|
+
deviceName: device.deviceType,
|
|
112
|
+
deviceType: device.deviceType,
|
|
113
|
+
runtime: device.runtime
|
|
114
|
+
},
|
|
115
|
+
udid: "",
|
|
116
|
+
host: hostedIosStatus(run.placement),
|
|
117
|
+
appPath: artifact.path,
|
|
118
|
+
bundleId,
|
|
119
|
+
installSkipped: false,
|
|
120
|
+
storeHash: cache.identity?.fingerprint ?? null,
|
|
121
|
+
storeKey: cache.identity?.key ?? null,
|
|
122
|
+
cacheHit: cache.hit,
|
|
123
|
+
missReason: cache.missReason,
|
|
124
|
+
compilationCache: cache.compilation,
|
|
125
|
+
useBuildCache: cache.readEnabled,
|
|
126
|
+
waitedForBuild: cache.waitedForBuild,
|
|
127
|
+
launchState: launched,
|
|
128
|
+
providerName: cache.providerName,
|
|
129
|
+
buildMachine: cache.buildMachine,
|
|
130
|
+
builtOn: cache.builtOn,
|
|
131
|
+
offloadedTo: cache.offloadedTo,
|
|
132
|
+
offloadFallback: cache.offloadFallback,
|
|
133
|
+
webPreviewUrl: null
|
|
134
|
+
}),
|
|
135
|
+
uploadsAbandoned
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/commands/ios/next-build.ts
|
|
140
|
+
function runOnlyFlag(opts) {
|
|
141
|
+
if (isPhysicalDeviceRequest(opts.device)) return "--device";
|
|
142
|
+
if (opts.remote) return "--remote";
|
|
143
|
+
if (opts.wait !== void 0) return opts.wait === false ? "--no-wait" : "--wait";
|
|
144
|
+
if (opts.simulatorApp !== void 0) return "--simulator-app";
|
|
145
|
+
if (opts.metroCheck === false) return "--no-metro-check";
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
async function planIos(opts, d) {
|
|
149
|
+
const json = Boolean(opts.json);
|
|
150
|
+
const flag = runOnlyFlag(opts);
|
|
151
|
+
if (flag) return refusePlan(planFlagRefusal(flag), json);
|
|
152
|
+
const root = d.findProjectRoot(process.cwd());
|
|
153
|
+
if (!root) return refusePlan(NO_PROJECT_REFUSAL, json);
|
|
154
|
+
const selected = d.projectRegistry.selectIos(root);
|
|
155
|
+
if ("problem" in selected) return refusePlan({
|
|
156
|
+
code: "STIM_NO_PROJECT",
|
|
157
|
+
...selected.problem
|
|
158
|
+
}, json);
|
|
159
|
+
const context = projectSettingsContext(root, d);
|
|
160
|
+
const settings = d.resolveSettings(context);
|
|
161
|
+
const project = await selected.load(settings);
|
|
162
|
+
if (!project.plan) return refusePlan(unsupportedPlan("ios"), json);
|
|
163
|
+
const result = await project.plan(opts, {
|
|
164
|
+
context,
|
|
165
|
+
settings
|
|
166
|
+
});
|
|
167
|
+
if ("platform" in result) printPlan(result, json);
|
|
168
|
+
else refusePlan(result.refusal, json, result.lines);
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/commands/ios.ts
|
|
172
|
+
function writeNote(line) {
|
|
173
|
+
console.error(line);
|
|
174
|
+
}
|
|
175
|
+
function writePhase(name, text) {
|
|
176
|
+
console.error(phaseLine(name, text));
|
|
177
|
+
}
|
|
178
|
+
function iosCommand(program) {
|
|
179
|
+
registerIos(program);
|
|
180
|
+
}
|
|
181
|
+
function registerIos(program, deps = {}) {
|
|
182
|
+
program.command("ios").description("Build (or restore from the fingerprint cache), install and launch this workspace's app on its owned simulator. React Native and Expo Debug runs start the dev server when it is not running.").option("--eas-profile <name>", "Download a matching EAS development build; on a miss, print the build command without running it").option("--slot <name>", "Reusable device slot within this workspace (default: default)", parseDeviceSlotOption).option("--remote-build <value>", "Build on auto, local, or one named machine; a name refuses without fallback", parseBuildMachineOption).option("--json", "Emit the facts as a single JSON line on stdout; every other line goes to stderr").option("--plan", "Predict the next build without building, booting or installing: resolve the fingerprint, check the local then remote cache, and print the expected cache result and duration. Writes no Stim state.").option("--scheme <name>", "Shared Xcode app scheme to build; overrides automatic scheme selection, not the app URL scheme").option("--no-metro-check", "Skip the \"is this workspace's dev server running?\" check: do not start it, and build anyway").option("--no-build-cache", "Build fresh, ignoring cached artifacts (local and the project's build-cache provider); the fresh build still replaces the cache entry").option("--configuration <name>", "Xcode configuration to build (e.g. Release). A non-Debug configuration embeds the JS bundle and skips Metro entirely. Overrides the ios.configuration setting. Default: Debug").option("--device-type <name>", "Simulator model to create this workspace's owned sim as, exactly as `xcrun simctl list devicetypes` names it (e.g. \"iPad Pro 13-inch (M5)\"). Overrides the ios.deviceType setting for this invocation. A model no installed runtime can create refuses with STIM_BAD_ARG and prints the models they do offer.").option("--runtime <version>", "Simulator runtime to create this workspace's owned sim on, as a version (\"18.5\") or a runtime's full name (\"iOS 18.5\"); nothing else matches. Overrides the ios.runtime setting for this invocation. An unknown version refuses with STIM_BAD_ARG and prints the installed runtimes.").option("--simulator-app <app>", "Open the owned simulator in xcode, siniulator, or stim-desktop for this run, overriding the machine iosSimulatorApp setting. Also opens an already running simulator; local simulators only.").option("--device [udid]", "Build the iphoneos slice for a connected iPhone, install it, and launch it, instead of using this workspace's owned simulator. The phone can be cabled or paired over Wi-Fi. With no UDID, the first cabled device this workspace can lease is used, waiting for one that is busy; a Wi-Fi device is used only when no cabled one is connected and ready. In Debug the app is wired to this workspace's Metro over the LAN. Stim never creates, boots, or deletes a physical device.").option("--remote <target>", "Run on eas, proxy, or an approved Mac in remote.machines; named Macs never fall back locally. auto places on an approved Mac when this Mac is full or busy. local runs here, whatever ios.remote says.", (value) => {
|
|
183
|
+
if (parseMachine(value)) return value.trim();
|
|
184
|
+
throw new InvalidArgumentError("expected eas, proxy, auto, local, or a remote Mac name");
|
|
185
|
+
}).option("--wait <seconds>", "How long to wait for another workspace to release the phone it leases, before refusing with STIM_DEVICE_BUSY (default 60, 0 refuses at once). Without --device, wait for an owned-device slot (default 600 seconds; --no-wait refuses immediately).").option("--no-wait", "Install on a phone another workspace leases instead of waiting: this run takes no lease and, when both workspaces build the same app id, the install terminates the holder's running app. Without --device, refuse a full device cap or existing slot queue immediately.").action(async (opts) => {
|
|
186
|
+
if (opts.plan) {
|
|
187
|
+
await planIos(opts, {
|
|
188
|
+
...DEFAULT_DEPS,
|
|
189
|
+
...deps
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const completion = await runIosOperation((deps.findProjectRoot ?? DEFAULT_DEPS.findProjectRoot)(process.cwd()), {
|
|
194
|
+
...opts,
|
|
195
|
+
waitConflict: waitFlagConflict(process.argv)
|
|
196
|
+
}, deps);
|
|
197
|
+
if (!completion) process.exit(runCancellation() ? 130 : 1);
|
|
198
|
+
else if (completion.uploadsAbandoned) exitAfterFlush(0);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function runIosOperation(root, opts = {}, deps = {}, onFailure = () => {}) {
|
|
202
|
+
const run = (progress) => runIos(root, opts, deps, progress, onFailure);
|
|
203
|
+
return root ? withNativeBuildRun(root, {
|
|
204
|
+
command: "ios",
|
|
205
|
+
platform: "ios",
|
|
206
|
+
slot: opts.slot ?? "default"
|
|
207
|
+
}, async (claim) => {
|
|
208
|
+
recordWorkspaceUse(root);
|
|
209
|
+
const progress = startBuildProgress({
|
|
210
|
+
root,
|
|
211
|
+
platform: "ios",
|
|
212
|
+
slot: opts.slot ?? "default",
|
|
213
|
+
claim,
|
|
214
|
+
note: (line) => writeNote(chalk.dim(line))
|
|
215
|
+
});
|
|
216
|
+
try {
|
|
217
|
+
return await run(progress);
|
|
218
|
+
} finally {
|
|
219
|
+
progress.clear();
|
|
220
|
+
}
|
|
221
|
+
}, { write: (line) => writeNote(chalk.dim(phaseLine("lock", line))) }) : run();
|
|
222
|
+
}
|
|
223
|
+
function unlessCancelled(result) {
|
|
224
|
+
if (!result.ok || !runCancellation()) return result;
|
|
225
|
+
return {
|
|
226
|
+
ok: false,
|
|
227
|
+
failure: {
|
|
228
|
+
code: "STIM_CANCELLED",
|
|
229
|
+
message: "before install"
|
|
230
|
+
},
|
|
231
|
+
compilationCache: result.artifact.cache.compilation
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function iosProjectTargetRefusal(project, { physical, easProfile, placement }) {
|
|
235
|
+
const target = physical ? "physical" : placement ? placement.machine ? "hosted" : placement.backend ? "remote" : "simulator" : null;
|
|
236
|
+
if (target && !project.targets.includes(target)) return {
|
|
237
|
+
code: "STIM_BAD_ARG",
|
|
238
|
+
message: `This project integration does not support the ${target} iOS target.`,
|
|
239
|
+
remedy: "Use a local iOS simulator for this integration."
|
|
240
|
+
};
|
|
241
|
+
if (easProfile !== void 0 && !project.eas) return {
|
|
242
|
+
code: "STIM_BAD_ARG",
|
|
243
|
+
message: "This project integration does not support EAS builds.",
|
|
244
|
+
remedy: "Use its local iOS build recipe."
|
|
245
|
+
};
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
function iosArtifactTargetInputs({ udid, physical, remote, hosted, simulatorArch, lanAddress, metroPort, settings }) {
|
|
249
|
+
return {
|
|
250
|
+
target: {
|
|
251
|
+
udid,
|
|
252
|
+
destination: remote || hosted ? "generic/platform=iOS Simulator" : null,
|
|
253
|
+
sdk: physical ? "iphoneos" : "iphonesimulator",
|
|
254
|
+
arch: remote || hosted ? simulatorArch : null,
|
|
255
|
+
keyArch: simulatorArch,
|
|
256
|
+
offloadRuntime: () => hosted?.choice.runtimeId ?? (remote ? null : simulatorRuntime(udid)),
|
|
257
|
+
hostedArchitecture: hosted?.choice.architecture,
|
|
258
|
+
offloadRefusal: physical ? "device builds build here" : remote ? "--remote builds build here" : null
|
|
259
|
+
},
|
|
260
|
+
device: physical ? {
|
|
261
|
+
udid,
|
|
262
|
+
lanAddress,
|
|
263
|
+
metroPort,
|
|
264
|
+
signingName: iosSigningIdentitySetting(settings),
|
|
265
|
+
signingSha1: iosSigningIdentitySha1Setting(settings)
|
|
266
|
+
} : null
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function iosSlotLogFile(root, slot) {
|
|
270
|
+
return slot === "default" ? buildLogFile(root) : join(workspaceLogsDir$1(root), `build-${deviceSlotFileKey("ios", slot)}.ndjson`);
|
|
271
|
+
}
|
|
272
|
+
function iosSlotDeps(d, slot) {
|
|
273
|
+
if (slot !== "default") {
|
|
274
|
+
const base = d;
|
|
275
|
+
d = {
|
|
276
|
+
...base,
|
|
277
|
+
ensureOwnedDevice: (args) => base.ensureOwnedDevice({
|
|
278
|
+
...args,
|
|
279
|
+
slot
|
|
280
|
+
}),
|
|
281
|
+
checkDeviceCapacity: (args) => base.checkDeviceCapacity({
|
|
282
|
+
...args,
|
|
283
|
+
slot
|
|
284
|
+
}),
|
|
285
|
+
selectFromPool: (args) => base.selectFromPool({
|
|
286
|
+
...args,
|
|
287
|
+
slot
|
|
288
|
+
}),
|
|
289
|
+
acquireRunLease: (args) => base.acquireRunLease({
|
|
290
|
+
...args,
|
|
291
|
+
slot
|
|
292
|
+
}),
|
|
293
|
+
runLease: (args) => base.runLease({
|
|
294
|
+
...args,
|
|
295
|
+
slot
|
|
296
|
+
}),
|
|
297
|
+
replaceCollector: (args) => base.replaceCollector({
|
|
298
|
+
...args,
|
|
299
|
+
slot
|
|
300
|
+
}),
|
|
301
|
+
stopPreviousCollector: (args) => base.stopPreviousCollector({
|
|
302
|
+
...args,
|
|
303
|
+
slot
|
|
304
|
+
}),
|
|
305
|
+
clearIosAdoptionPending: (root) => base.clearIosAdoptionPending(root, slot),
|
|
306
|
+
writeWorkspaceLaunch: (root, platform, record) => base.writeWorkspaceLaunch(root, platform, record, slot),
|
|
307
|
+
createWriter: (file, options) => base.createWriter(file, {
|
|
308
|
+
...options,
|
|
309
|
+
fields: { slot }
|
|
310
|
+
})
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
return d;
|
|
314
|
+
}
|
|
315
|
+
async function runIos(projectRoot, opts = {}, overrides = {}, progress = NO_BUILD_PROGRESS, onFailure) {
|
|
316
|
+
const slot = validateDeviceSlot(opts.slot);
|
|
317
|
+
let d = iosSlotDeps({
|
|
318
|
+
...DEFAULT_DEPS,
|
|
319
|
+
...overrides
|
|
320
|
+
}, slot);
|
|
321
|
+
const json = Boolean(opts.json);
|
|
322
|
+
const metroCheck = opts.metroCheck !== false;
|
|
323
|
+
const phase = writePhase;
|
|
324
|
+
const note = writeNote;
|
|
325
|
+
const started = d.now();
|
|
326
|
+
const startedAt = new Date(started).toISOString();
|
|
327
|
+
const elapsed = () => d.now() - started;
|
|
328
|
+
const refuseProject = ({ message, remedy }) => {
|
|
329
|
+
note(chalk.red(phaseLine("error", message)));
|
|
330
|
+
note(chalk.dim(phaseLine("remedy", remedy)));
|
|
331
|
+
note(chalk.red(phaseLine("failed", "STIM_NO_PROJECT")));
|
|
332
|
+
if (json) console.log(JSON.stringify({
|
|
333
|
+
code: "STIM_NO_PROJECT",
|
|
334
|
+
message,
|
|
335
|
+
remedy
|
|
336
|
+
}));
|
|
337
|
+
onFailure({
|
|
338
|
+
code: "STIM_NO_PROJECT",
|
|
339
|
+
message,
|
|
340
|
+
remedy
|
|
341
|
+
});
|
|
342
|
+
return null;
|
|
343
|
+
};
|
|
344
|
+
if (!projectRoot) return refuseProject(NO_PROJECT_REFUSAL);
|
|
345
|
+
const root = projectRoot;
|
|
346
|
+
const selectedProject = d.projectRegistry.selectIos(root);
|
|
347
|
+
if ("problem" in selectedProject) return refuseProject(selectedProject.problem);
|
|
348
|
+
try {
|
|
349
|
+
await d.ensureWorkspaceStorage(root, { note });
|
|
350
|
+
} catch (error) {
|
|
351
|
+
const code = error?.code || "STIM_WORKSPACE_STATE";
|
|
352
|
+
const message = `Could not prepare this workspace's Stim state: ${error?.message || error}`;
|
|
353
|
+
note(chalk.red(`${code}: ${message}`));
|
|
354
|
+
note(chalk.dim("Check that STIM_HOME is writable and has free space. An EPERM on a directory you can write is a sandbox: allow writes to STIM_HOME, or run Stim with the sandbox disabled (`stim guide errors sandbox`)."));
|
|
355
|
+
if (json) console.log(JSON.stringify({
|
|
356
|
+
code,
|
|
357
|
+
message,
|
|
358
|
+
remedy: "Check that STIM_HOME is writable and has free space."
|
|
359
|
+
}));
|
|
360
|
+
onFailure({
|
|
361
|
+
code,
|
|
362
|
+
message,
|
|
363
|
+
remedy: "Check that STIM_HOME is writable and has free space."
|
|
364
|
+
});
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
const logsDir = workspaceLogsDir$1(root);
|
|
368
|
+
const logFile = iosSlotLogFile(root, slot);
|
|
369
|
+
let writer = null;
|
|
370
|
+
const logWriter = () => writer ||= tapBuildLog(d.createWriter(logFile, {
|
|
371
|
+
truncate: true,
|
|
372
|
+
fields: {
|
|
373
|
+
platform: "ios",
|
|
374
|
+
slot
|
|
375
|
+
}
|
|
376
|
+
}), progress);
|
|
377
|
+
setRemoteLogSink((record) => logWriter().write(record));
|
|
378
|
+
let leaseHandle = null;
|
|
379
|
+
let stopLeaseSignals = null;
|
|
380
|
+
const releaseLease = () => {
|
|
381
|
+
const held = leaseHandle;
|
|
382
|
+
const stopSignals = stopLeaseSignals;
|
|
383
|
+
leaseHandle = null;
|
|
384
|
+
stopLeaseSignals = null;
|
|
385
|
+
stopSignals?.();
|
|
386
|
+
try {
|
|
387
|
+
held?.release();
|
|
388
|
+
} catch (e) {
|
|
389
|
+
note(chalk.dim(`Could not release this run's device lease: ${e?.message || e}`));
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const stats = createRunRecorder({
|
|
393
|
+
platform: "ios",
|
|
394
|
+
write: (statsRun, at) => d.recordStats(statsRun, at),
|
|
395
|
+
now: () => d.now(),
|
|
396
|
+
note: (line) => note(chalk.dim(line)),
|
|
397
|
+
phases: () => progress.durations(),
|
|
398
|
+
deviceSetup: () => progress.deviceSetupKnown()
|
|
399
|
+
});
|
|
400
|
+
const deviceWaitRun = createIosDeviceWaitRun(stats, progress, runCancellationSignal());
|
|
401
|
+
const recordRun = deviceWaitRun.record;
|
|
402
|
+
let compilationCache = COMPILATION_CACHE_NOT_RUN;
|
|
403
|
+
let reclaimed = [];
|
|
404
|
+
let buildMachine = "auto";
|
|
405
|
+
let devicePlacement;
|
|
406
|
+
let builtConfiguration = null;
|
|
407
|
+
const fail = ({ code, message, remedy = null, lines = [], logPath = null, build = null, lease, setup = false }) => {
|
|
408
|
+
({code, message, remedy, lines} = cancelledFailure("ios", {
|
|
409
|
+
code,
|
|
410
|
+
message
|
|
411
|
+
}) ?? {
|
|
412
|
+
code,
|
|
413
|
+
message,
|
|
414
|
+
remedy,
|
|
415
|
+
lines
|
|
416
|
+
});
|
|
417
|
+
releaseLease();
|
|
418
|
+
if (message) note(chalk.red(phaseLine("error", message)));
|
|
419
|
+
for (const line of lines) note(chalk.dim(phaseLine("", line)));
|
|
420
|
+
if (remedy) note(chalk.dim(phaseLine("remedy", remedy)));
|
|
421
|
+
if (logPath) note(chalk.dim(phaseLine("log", logPath)));
|
|
422
|
+
if (build) writeLastBuild(root, lastBuildRecord({
|
|
423
|
+
devicePlacement,
|
|
424
|
+
buildMachine,
|
|
425
|
+
...build,
|
|
426
|
+
configuration: builtConfiguration,
|
|
427
|
+
startedAt,
|
|
428
|
+
status: "failed",
|
|
429
|
+
errorCode: code,
|
|
430
|
+
durationMs: elapsed()
|
|
431
|
+
}));
|
|
432
|
+
note(chalk.red(phaseLine("failed", code)));
|
|
433
|
+
if (!setup) recordRun({
|
|
434
|
+
failed: true,
|
|
435
|
+
durationMs: elapsed()
|
|
436
|
+
});
|
|
437
|
+
if (json) console.log(JSON.stringify({
|
|
438
|
+
code,
|
|
439
|
+
message: message ?? null,
|
|
440
|
+
remedy: remedy ?? null,
|
|
441
|
+
...devicePlacement ? { devicePlacement } : {},
|
|
442
|
+
...compilationCache.status === "not-run" ? {} : { compilationCache },
|
|
443
|
+
...lease === void 0 ? {} : { lease },
|
|
444
|
+
...reclaimed.length ? { reclaimed } : {}
|
|
445
|
+
}));
|
|
446
|
+
writer?.close?.();
|
|
447
|
+
onFailure({
|
|
448
|
+
code,
|
|
449
|
+
message,
|
|
450
|
+
remedy,
|
|
451
|
+
lines,
|
|
452
|
+
logPath,
|
|
453
|
+
build,
|
|
454
|
+
lease,
|
|
455
|
+
setup
|
|
456
|
+
});
|
|
457
|
+
return null;
|
|
458
|
+
};
|
|
459
|
+
const settingsContext = projectSettingsContext(root, d);
|
|
460
|
+
const projectKey = statsProjectKey$1({
|
|
461
|
+
root,
|
|
462
|
+
commonDir: settingsContext.gitCommonDir,
|
|
463
|
+
repoRoot: settingsContext.repoRoot
|
|
464
|
+
});
|
|
465
|
+
stats.setProject(projectKey);
|
|
466
|
+
progress.estimate(projectKey);
|
|
467
|
+
let estimatesRead = null;
|
|
468
|
+
const estimates = () => estimatesRead ??= d.readEstimates({
|
|
469
|
+
projectKey,
|
|
470
|
+
platform: "ios"
|
|
471
|
+
});
|
|
472
|
+
const settings = d.resolveSettings(settingsContext);
|
|
473
|
+
const setup = resolveIosBuildSetup(opts.remoteBuild, settings, (label, message) => note(phaseLine(label, chalk.yellow(message))));
|
|
474
|
+
if (!setup.ok) return fail(setup.failure);
|
|
475
|
+
buildMachine = setup.buildMachine;
|
|
476
|
+
const { optimizations } = setup;
|
|
477
|
+
const buildProfile = optimizationBuildProfile("ios", optimizations);
|
|
478
|
+
const cacheProviderConfig = d.resolveCacheProviderConfig(settingsContext);
|
|
479
|
+
const poolError = parkedMaxSetting("ios").error;
|
|
480
|
+
if (poolError) return fail({
|
|
481
|
+
code: "STIM_BAD_ARG",
|
|
482
|
+
message: poolError,
|
|
483
|
+
remedy: POOL_SETTING_REMEDY
|
|
484
|
+
});
|
|
485
|
+
for (const settingError of [
|
|
486
|
+
iosSigningIdentitySettingError(settings),
|
|
487
|
+
iosSigningIdentitySha1SettingError(settings),
|
|
488
|
+
iosLanHostSettingError(settings),
|
|
489
|
+
iosProjectPathError(settings, root, () => d.detectIsExpo(root))
|
|
490
|
+
]) if (settingError) return fail({
|
|
491
|
+
code: "STIM_BAD_ARG",
|
|
492
|
+
message: settingError,
|
|
493
|
+
remedy: SETTING_SHAPE_REMEDY
|
|
494
|
+
});
|
|
495
|
+
const integration = await selectedProject.load(settings);
|
|
496
|
+
const configuration = opts.easProfile !== void 0 ? null : resolveConfiguration(opts.configuration, settings);
|
|
497
|
+
builtConfiguration = configuration ?? "Debug";
|
|
498
|
+
const buildScheme = resolveSchemeSelection(opts, settings);
|
|
499
|
+
const release = isReleaseConfiguration(configuration);
|
|
500
|
+
const appMode = {
|
|
501
|
+
metro: "development",
|
|
502
|
+
process: "process",
|
|
503
|
+
"embedded-js": "release"
|
|
504
|
+
}[integration.runtimeKind(configuration)];
|
|
505
|
+
const cachePolicy = artifactCachePolicy(optimizations, opts.buildCache !== false, integration.runtimeKind(configuration) === "embedded-js");
|
|
506
|
+
const deviceType = resolveDeviceType(opts.deviceType, settings);
|
|
507
|
+
const runtime = resolveRuntime(opts.runtime, settings);
|
|
508
|
+
const deviceFlag = opts.device;
|
|
509
|
+
const physical = isPhysicalDeviceRequest(deviceFlag);
|
|
510
|
+
if (physical && deviceFlag === "") return fail({
|
|
511
|
+
code: "STIM_BAD_ARG",
|
|
512
|
+
message: "--device was given an empty UDID.",
|
|
513
|
+
remedy: "Pass `--device` on its own to take the first connected device this workspace can lease, or `--device <udid>` to name one."
|
|
514
|
+
});
|
|
515
|
+
if (physical && opts.remote) return fail({
|
|
516
|
+
code: "STIM_BAD_ARG",
|
|
517
|
+
message: "--device builds for a phone connected to this machine, and --remote installs on a remote one.",
|
|
518
|
+
remedy: "Pass only one of --device and --remote."
|
|
519
|
+
});
|
|
520
|
+
const wait = resolveIosWait(opts, physical);
|
|
521
|
+
if ("failure" in wait) return fail(wait.failure);
|
|
522
|
+
const { waitSeconds, noWait, deviceSlotWaitMs, checkCapacity } = wait;
|
|
523
|
+
const deviceSlotWait = {
|
|
524
|
+
automatic: false,
|
|
525
|
+
waitMs: deviceSlotWaitMs,
|
|
526
|
+
displayName: basename(root),
|
|
527
|
+
reclaimIdleMinutes: deviceReclaimIdleMinutesSetting(settings),
|
|
528
|
+
...deviceWaitRun.policy,
|
|
529
|
+
onWait: (ms) => {
|
|
530
|
+
deviceWaitRun.policy.onWait?.(ms);
|
|
531
|
+
if (devicePlacement?.decision === "local" && ms > 0) devicePlacement.decision = "waited-locally";
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const isExpo = integration.isExpo;
|
|
535
|
+
const schemeRefusal = integration.schemeProblem(buildScheme, configuration);
|
|
536
|
+
if (schemeRefusal) return fail(schemeRefusal);
|
|
537
|
+
const capabilityRefusal = iosProjectTargetRefusal(integration, {
|
|
538
|
+
physical,
|
|
539
|
+
easProfile: opts.easProfile
|
|
540
|
+
});
|
|
541
|
+
if (capabilityRefusal) return fail(capabilityRefusal);
|
|
542
|
+
const remoteSelection = await selectIosPlacement({
|
|
543
|
+
root,
|
|
544
|
+
slot,
|
|
545
|
+
opts,
|
|
546
|
+
settings,
|
|
547
|
+
physical,
|
|
548
|
+
release,
|
|
549
|
+
appMode,
|
|
550
|
+
supportsRemote: integration.targets.includes("remote"),
|
|
551
|
+
metroCheck,
|
|
552
|
+
d,
|
|
553
|
+
deviceType,
|
|
554
|
+
runtime,
|
|
555
|
+
validateSelectors: () => deviceModelRefusal({
|
|
556
|
+
slot,
|
|
557
|
+
deviceTypeFlag: opts.deviceType,
|
|
558
|
+
runtimeFlag: opts.runtime,
|
|
559
|
+
deviceType,
|
|
560
|
+
runtime,
|
|
561
|
+
physical,
|
|
562
|
+
remoteBackend: null,
|
|
563
|
+
deviceTypeOrigin: d.settingOriginScope(d.settingsLayers(settingsContext), "ios.deviceType"),
|
|
564
|
+
runtimeOrigin: d.settingOriginScope(d.settingsLayers(settingsContext), "ios.runtime"),
|
|
565
|
+
listRuntimes: d.listIosRuntimes
|
|
566
|
+
}),
|
|
567
|
+
noWait: deviceSlotWaitMs === 0,
|
|
568
|
+
note,
|
|
569
|
+
phase,
|
|
570
|
+
log: (entry) => logWriter().write(entry)
|
|
571
|
+
});
|
|
572
|
+
if ("failure" in remoteSelection) return fail(remoteSelection.failure);
|
|
573
|
+
deviceSlotWait.automatic = Boolean(remoteSelection.auto);
|
|
574
|
+
const targetRefusal = iosProjectTargetRefusal(integration, {
|
|
575
|
+
physical,
|
|
576
|
+
placement: remoteSelection
|
|
577
|
+
});
|
|
578
|
+
if (targetRefusal) return fail(targetRefusal);
|
|
579
|
+
devicePlacement = remoteSelection.devicePlacement;
|
|
580
|
+
writeDevicePlacement(root, slot, "ios", devicePlacement);
|
|
581
|
+
const { machine: hostedMachine, backend: remoteBackend } = remoteSelection;
|
|
582
|
+
const viewer = resolveSimulatorAppFlag(opts.simulatorApp, physical, hostedMachine ?? remoteBackend, Boolean(remoteSelection.auto));
|
|
583
|
+
if ("refusal" in viewer) return fail(viewer.refusal);
|
|
584
|
+
const { simulatorApp } = viewer;
|
|
585
|
+
const settingsLayersForOrigin = d.settingsLayers(settingsContext);
|
|
586
|
+
const modelRefusal = deviceModelRefusal({
|
|
587
|
+
slot,
|
|
588
|
+
deviceTypeFlag: opts.deviceType,
|
|
589
|
+
runtimeFlag: opts.runtime,
|
|
590
|
+
deviceType,
|
|
591
|
+
runtime,
|
|
592
|
+
deviceTypeOrigin: d.settingOriginScope(settingsLayersForOrigin, "ios.deviceType"),
|
|
593
|
+
runtimeOrigin: d.settingOriginScope(settingsLayersForOrigin, "ios.runtime"),
|
|
594
|
+
physical,
|
|
595
|
+
remoteBackend,
|
|
596
|
+
hosted: Boolean(hostedMachine),
|
|
597
|
+
listRuntimes: d.listIosRuntimes
|
|
598
|
+
});
|
|
599
|
+
if (modelRefusal) return fail(modelRefusal);
|
|
600
|
+
const selectors = hostedIosSelectors(deviceType, runtime);
|
|
601
|
+
const connected = await connectIosTarget(remoteSelection, selectors, d, appMode);
|
|
602
|
+
if ("failure" in connected) return fail(connected.failure);
|
|
603
|
+
const hostedTarget = connected.target;
|
|
604
|
+
try {
|
|
605
|
+
const simSnapshot = createIosSimSnapshot();
|
|
606
|
+
const budget = await iosPlacementBudget(d, root, note, Boolean(hostedTarget), remoteSelection.budget, simSnapshot);
|
|
607
|
+
reclaimed = budget.reclaimed;
|
|
608
|
+
if (budget.refusal) return fail(budget.refusal);
|
|
609
|
+
const backendConnection = await connectIosBackend(root, remoteBackend, opts.deviceType, d);
|
|
610
|
+
if ("failure" in backendConnection) return fail(backendConnection.failure);
|
|
611
|
+
const remoteDevice = backendConnection.remote;
|
|
612
|
+
const remoteArch = hostedTarget ? hostedTarget.choice.architecture : backendConnection.arch;
|
|
613
|
+
if (remoteDevice) d = {
|
|
614
|
+
...d,
|
|
615
|
+
checkDeviceCapacity: remoteDevice.checkDeviceCapacity,
|
|
616
|
+
ensureOwnedDevice: remoteDevice.ensureOwnedDevice,
|
|
617
|
+
ensureBooted: remoteDevice.ensureBooted,
|
|
618
|
+
installIosApp: remoteDevice.installIosApp,
|
|
619
|
+
launchIosApp: remoteDevice.launchIosApp
|
|
620
|
+
};
|
|
621
|
+
const easBuild = await d.resolveEasDevelopmentBuild({
|
|
622
|
+
root,
|
|
623
|
+
platform: "ios",
|
|
624
|
+
profile: opts.easProfile,
|
|
625
|
+
note,
|
|
626
|
+
isExpo,
|
|
627
|
+
physical,
|
|
628
|
+
selectors: [opts.scheme, opts.configuration],
|
|
629
|
+
buildCache: opts.buildCache
|
|
630
|
+
});
|
|
631
|
+
if (isEasBuildFailure(easBuild)) return fail(easBuild);
|
|
632
|
+
const registerProject = () => d.upsertProject(root, {
|
|
633
|
+
bundleId: integration.bundleId() ?? void 0,
|
|
634
|
+
isExpo
|
|
635
|
+
});
|
|
636
|
+
if (remoteBackend !== "eas") registerProject();
|
|
637
|
+
const proj = d.getProject(root);
|
|
638
|
+
const limits = d.getConcurrencyLimits();
|
|
639
|
+
let physicalDevice = null;
|
|
640
|
+
let wireless = false;
|
|
641
|
+
if (physical && typeof deviceFlag !== "string") {
|
|
642
|
+
const pooled = await d.selectFromPool({
|
|
643
|
+
root,
|
|
644
|
+
platform: "ios",
|
|
645
|
+
idLabel: "udid",
|
|
646
|
+
list: () => iosPoolCandidates(d.listIosDevices()).map((entry) => ({
|
|
647
|
+
id: entry.udid,
|
|
648
|
+
name: entry.name,
|
|
649
|
+
fallback: isWirelessIosDevice(entry)
|
|
650
|
+
})),
|
|
651
|
+
noCandidates: () => {
|
|
652
|
+
const resolved = iosPoolNoCandidatesRefusal(d.listIosDevices());
|
|
653
|
+
return {
|
|
654
|
+
message: resolved.error,
|
|
655
|
+
remedy: resolved.remedy
|
|
656
|
+
};
|
|
657
|
+
},
|
|
658
|
+
waitSeconds,
|
|
659
|
+
noWait,
|
|
660
|
+
now: d.now,
|
|
661
|
+
warn: (line) => note(chalk.yellow(phaseLine("lease", line)))
|
|
662
|
+
});
|
|
663
|
+
if (pooled.status === "refused") return fail({
|
|
664
|
+
code: pooled.refusal.code,
|
|
665
|
+
message: pooled.refusal.message,
|
|
666
|
+
remedy: pooled.refusal.remedy,
|
|
667
|
+
...pooled.refusal.lease === null ? {} : { lease: pooled.refusal.lease }
|
|
668
|
+
});
|
|
669
|
+
physicalDevice = {
|
|
670
|
+
udid: pooled.candidate.id,
|
|
671
|
+
name: pooled.candidate.name ?? pooled.candidate.id
|
|
672
|
+
};
|
|
673
|
+
wireless = pooled.candidate.fallback === true;
|
|
674
|
+
} else if (physical) {
|
|
675
|
+
const resolved = resolveIosPhysicalDevice(typeof deviceFlag === "string" ? deviceFlag : null, d.listIosDevices());
|
|
676
|
+
if (!resolved.udid) return fail({
|
|
677
|
+
code: "STIM_NO_DEVICE",
|
|
678
|
+
message: resolved.error,
|
|
679
|
+
remedy: resolved.remedy
|
|
680
|
+
});
|
|
681
|
+
physicalDevice = {
|
|
682
|
+
udid: resolved.udid,
|
|
683
|
+
name: resolved.name ?? resolved.udid
|
|
684
|
+
};
|
|
685
|
+
wireless = resolved.wireless === true;
|
|
686
|
+
}
|
|
687
|
+
if (checkCapacity && !hostedTarget) {
|
|
688
|
+
const capacity = d.checkDeviceCapacity({
|
|
689
|
+
platform: "ios",
|
|
690
|
+
project: proj,
|
|
691
|
+
max: limits.maxDevices,
|
|
692
|
+
sims: () => simSnapshot.read().filter((sim) => sim.available)
|
|
693
|
+
});
|
|
694
|
+
if (capacity) {
|
|
695
|
+
if (capacity.code === "STIM_AT_CAPACITY") d.recordCapacityRefusal({
|
|
696
|
+
platform: "ios",
|
|
697
|
+
max: limits.maxDevices,
|
|
698
|
+
workspace: workspaceId(root)
|
|
699
|
+
}, d.now());
|
|
700
|
+
return fail(capacity);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
let metroPort = proj?.metroPort ?? null;
|
|
704
|
+
let lanAddress = null;
|
|
705
|
+
let lanOriginUrl = null;
|
|
706
|
+
let devServer = null;
|
|
707
|
+
const appRuntime = composeRuntime();
|
|
708
|
+
const preparation = await appRuntime.prepare();
|
|
709
|
+
if (!preparation.ok) return fail(preparation.error);
|
|
710
|
+
const runtimePreparation = preparation.prepared;
|
|
711
|
+
metroPort = runtimePreparation.metroPort;
|
|
712
|
+
let device;
|
|
713
|
+
if (physicalDevice) device = {
|
|
714
|
+
deviceUdid: physicalDevice.udid,
|
|
715
|
+
deviceName: physicalDevice.name,
|
|
716
|
+
owned: false
|
|
717
|
+
};
|
|
718
|
+
else if (hostedTarget) device = {
|
|
719
|
+
owned: false,
|
|
720
|
+
deviceName: hostedTarget.choice.deviceType,
|
|
721
|
+
runtime: hostedTarget.choice.runtime
|
|
722
|
+
};
|
|
723
|
+
else {
|
|
724
|
+
const prepare = stepClock(d.now);
|
|
725
|
+
try {
|
|
726
|
+
device = await d.ensureOwnedDevice({
|
|
727
|
+
platform: "ios",
|
|
728
|
+
project: proj,
|
|
729
|
+
projectPath: root,
|
|
730
|
+
settingsRoot: root,
|
|
731
|
+
settings,
|
|
732
|
+
flags: {
|
|
733
|
+
deviceSlotWait,
|
|
734
|
+
deviceType,
|
|
735
|
+
runtime,
|
|
736
|
+
runtimeFlag: resolveRuntime(opts.runtime, null),
|
|
737
|
+
simulatorApp
|
|
738
|
+
},
|
|
739
|
+
note,
|
|
740
|
+
out: note,
|
|
741
|
+
simSnapshot
|
|
742
|
+
});
|
|
743
|
+
} catch (e) {
|
|
744
|
+
return fail(ownedSimFailure(e));
|
|
745
|
+
}
|
|
746
|
+
deviceWaitRun.booting(device.booting);
|
|
747
|
+
progress.deviceSetup(didSetUpDevice(device, Boolean(remoteDevice)));
|
|
748
|
+
const prepareMs = prepare();
|
|
749
|
+
if (device.created || prepareMs >= 2e3) phase("device", `${deviceLabel(device, device.deviceUdid)} ${device.created ? "created" : "prepared"} (${formatDuration(prepareMs)})`);
|
|
750
|
+
}
|
|
751
|
+
let bootDuration = "";
|
|
752
|
+
let bootPending = false;
|
|
753
|
+
let bootPromise;
|
|
754
|
+
let udid = "";
|
|
755
|
+
function composeRuntime() {
|
|
756
|
+
return d.runtimePlan ?? integration.runtime({
|
|
757
|
+
configuration,
|
|
758
|
+
prepareMetro,
|
|
759
|
+
prepareEmbedded: async () => {
|
|
760
|
+
phase("metro", `skipped (${configuration}: the JS bundle is embedded, no dev server is used)`);
|
|
761
|
+
hostedIosMetroNote(Boolean(hostedTarget), settings, note, opts.simulatorApp);
|
|
762
|
+
return {
|
|
763
|
+
ok: true,
|
|
764
|
+
prepared: { metroPort: null }
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
async function prepareMetro() {
|
|
770
|
+
if (metroCheck) {
|
|
771
|
+
const gate = await ensureDevServer({
|
|
772
|
+
root,
|
|
773
|
+
port: metroPort,
|
|
774
|
+
settings: hostedMetroSettings(settings, Boolean(hostedTarget)),
|
|
775
|
+
settingsContext,
|
|
776
|
+
remote: Boolean(remoteDevice),
|
|
777
|
+
note,
|
|
778
|
+
resolve: d.resolveProjectMetro,
|
|
779
|
+
start: d.startDevServer,
|
|
780
|
+
readState: d.readWorkspaceState
|
|
781
|
+
});
|
|
782
|
+
reclaimed = [...reclaimed, ...gate.reclaimed];
|
|
783
|
+
if (!gate.ok) return {
|
|
784
|
+
ok: false,
|
|
785
|
+
error: {
|
|
786
|
+
code: gate.code,
|
|
787
|
+
message: gate.message,
|
|
788
|
+
remedy: gate.remedy,
|
|
789
|
+
lines: gate.lines
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
metroPort = gate.port;
|
|
793
|
+
devServer = gate.devServer;
|
|
794
|
+
} else {
|
|
795
|
+
const pin = metroPortSetting(settings);
|
|
796
|
+
if (pin.error) return {
|
|
797
|
+
ok: false,
|
|
798
|
+
error: {
|
|
799
|
+
code: "STIM_BAD_ARG",
|
|
800
|
+
message: pin.error,
|
|
801
|
+
remedy: SETTING_SHAPE_REMEDY
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
if (pin.port === null && !metroPort) note(chalk.yellow(`No Metro port is reserved for this workspace; wiring the app to ${DEFAULT_METRO_PORT}.`));
|
|
805
|
+
metroPort = pin.port ?? metroPort ?? 8081;
|
|
806
|
+
}
|
|
807
|
+
hostedIosMetroNote(Boolean(hostedTarget), settings, note, opts.simulatorApp);
|
|
808
|
+
if (physical && metroPort !== null) {
|
|
809
|
+
const error = await resolveLanOrigin();
|
|
810
|
+
if (error) return {
|
|
811
|
+
ok: false,
|
|
812
|
+
error
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
if (remoteDevice && metroPort !== null) {
|
|
816
|
+
const reachable = await d.ensureMetroReachable({
|
|
817
|
+
ctx: remoteDevice.ctx,
|
|
818
|
+
metroPort,
|
|
819
|
+
isExpo,
|
|
820
|
+
tunnelMode: tunnelModeSetting(settings) ?? void 0,
|
|
821
|
+
publicUrl: publicUrlSetting(settings),
|
|
822
|
+
available: d.detectProviders(binOnPath, tunnelModeSetting(settings) ?? "auto")
|
|
823
|
+
});
|
|
824
|
+
if ("failed" in reachable) return {
|
|
825
|
+
ok: false,
|
|
826
|
+
error: {
|
|
827
|
+
code: reachable.code ?? "STIM_NO_REMOTE_SESSION",
|
|
828
|
+
message: reachable.failed,
|
|
829
|
+
remedy: reachable.remedy
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
if (metroCheck && optimizations.metroWarmup) d.warmMetro({
|
|
834
|
+
port: metroPort,
|
|
835
|
+
platform: "ios",
|
|
836
|
+
isExpo,
|
|
837
|
+
appId: proj?.bundleId,
|
|
838
|
+
bundleUrl: metroWarmupUrlSetting(settings, "ios")
|
|
839
|
+
});
|
|
840
|
+
return {
|
|
841
|
+
ok: true,
|
|
842
|
+
prepared: { metroPort }
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
async function resolveLanOrigin() {
|
|
846
|
+
const port = metroPort;
|
|
847
|
+
const pinned = iosLanHostSetting(settings);
|
|
848
|
+
const candidates = d.hostLanCandidates();
|
|
849
|
+
const chosen = chooseLanAddress({
|
|
850
|
+
pinned,
|
|
851
|
+
candidates
|
|
852
|
+
});
|
|
853
|
+
if (!chosen) return {
|
|
854
|
+
code: "STIM_NO_LAN_ADDRESS",
|
|
855
|
+
message: "A Debug run on a phone needs an address the phone can reach, and this Mac has no non-internal IPv4 interface.",
|
|
856
|
+
remedy: "The phone reaches Metro over the network you share, because USB carries no reverse forward. Join a Wi-Fi or Ethernet network, or connect this Mac by cable, then run the command again."
|
|
857
|
+
};
|
|
858
|
+
lanAddress = chosen.address;
|
|
859
|
+
lanOriginUrl = lanOriginUrlFor(chosen.address, port);
|
|
860
|
+
const source = chosen.pinned ? "ios.lanHost" : `${chosen.interfaceName ?? "interface"}${chosen.candidates > 1 ? ` of ${chosen.candidates} candidates` : ""}`;
|
|
861
|
+
phase("lan", `${lanOriginUrl} (${source})`);
|
|
862
|
+
if (publicUrlSetting(settings) || tunnelModeSetting(settings)) note(chalk.dim(phaseLine("lan", "metro.publicUrl and metro.tunnel are ignored on --device: neither channel to a phone carries a URL, only a host and a port. They still apply to --remote.")));
|
|
863
|
+
if (!metroCheck) return null;
|
|
864
|
+
const reachable = await d.ensureLanReachable({
|
|
865
|
+
origin: lanOriginUrl,
|
|
866
|
+
metroPort: port,
|
|
867
|
+
root,
|
|
868
|
+
isExpo,
|
|
869
|
+
logsDir
|
|
870
|
+
});
|
|
871
|
+
if ("failed" in reachable) return {
|
|
872
|
+
code: "STIM_LAN_METRO_UNREACHABLE",
|
|
873
|
+
message: reachable.failed,
|
|
874
|
+
remedy: reachable.remedy
|
|
875
|
+
};
|
|
876
|
+
phase("lan", `gated: ${lanOriginUrl} answered as this workspace's Metro`);
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
let artifact = null;
|
|
880
|
+
try {
|
|
881
|
+
const boot = () => physicalDevice ? Promise.resolve({
|
|
882
|
+
ok: true,
|
|
883
|
+
udid: physicalDevice.udid
|
|
884
|
+
}) : Promise.resolve(d.ensureBooted({
|
|
885
|
+
platform: "ios",
|
|
886
|
+
device,
|
|
887
|
+
projectPath: root,
|
|
888
|
+
deviceSlotWait,
|
|
889
|
+
simulatorApp,
|
|
890
|
+
out: note
|
|
891
|
+
})).catch((e) => ({
|
|
892
|
+
ok: false,
|
|
893
|
+
reason: String(e?.message || e)
|
|
894
|
+
}));
|
|
895
|
+
const startBoot = () => {
|
|
896
|
+
const bootTimer = stepTimer(d.now);
|
|
897
|
+
bootPending = remoteDevice?.ctx.backend !== "eas";
|
|
898
|
+
bootPromise = (remoteDevice?.ctx.backend === "eas" ? d.ensureRemoteBootOwned({
|
|
899
|
+
root,
|
|
900
|
+
platform: "ios",
|
|
901
|
+
sessionName: ownedSessionName(remoteDevice.ctx.label),
|
|
902
|
+
startedAt: new Date(d.now()).toISOString(),
|
|
903
|
+
deviceType: remoteDevice.ctx.deviceType ?? null,
|
|
904
|
+
boot,
|
|
905
|
+
createdSessionId: remoteDevice.createdSessionId,
|
|
906
|
+
abandonCreatedSession: remoteDevice.abandonCreatedSession,
|
|
907
|
+
webPreviewUrl: remoteDevice.webPreviewUrl,
|
|
908
|
+
writeState: d.writeWorkspaceState,
|
|
909
|
+
register: registerProject,
|
|
910
|
+
notice: (line) => note(chalk.dim(phaseLine("lock", line)))
|
|
911
|
+
}) : boot()).then((result) => {
|
|
912
|
+
bootDuration = bootTimer();
|
|
913
|
+
bootPending = false;
|
|
914
|
+
return result;
|
|
915
|
+
});
|
|
916
|
+
deviceWaitRun.booting({ done: bootPromise });
|
|
917
|
+
return bootPromise.then((result) => result?.udid ?? "");
|
|
918
|
+
};
|
|
919
|
+
const localBoot = remoteDevice || hostedTarget ? null : startBoot();
|
|
920
|
+
udid = device.deviceUdid ?? await localBoot ?? "";
|
|
921
|
+
const simulatorArch = simulatorBuildArch({
|
|
922
|
+
physical,
|
|
923
|
+
remoteArch,
|
|
924
|
+
hostArch: d.hostSimulatorArch(),
|
|
925
|
+
configuration
|
|
926
|
+
});
|
|
927
|
+
const acquiredArtifact = unlessCancelled(await acquireIosArtifact({
|
|
928
|
+
root,
|
|
929
|
+
logFile,
|
|
930
|
+
configuration,
|
|
931
|
+
buildMachine,
|
|
932
|
+
physical,
|
|
933
|
+
recipe: integration.artifact({
|
|
934
|
+
root,
|
|
935
|
+
logFile,
|
|
936
|
+
configuration,
|
|
937
|
+
buildScheme,
|
|
938
|
+
buildProfile,
|
|
939
|
+
...iosArtifactTargetInputs({
|
|
940
|
+
udid,
|
|
941
|
+
physical,
|
|
942
|
+
remote: Boolean(remoteDevice),
|
|
943
|
+
hosted: hostedTarget,
|
|
944
|
+
simulatorArch,
|
|
945
|
+
lanAddress,
|
|
946
|
+
metroPort,
|
|
947
|
+
settings
|
|
948
|
+
}),
|
|
949
|
+
optimizations: optimizations.ios,
|
|
950
|
+
easProfile: opts.easProfile,
|
|
951
|
+
cache: cachePolicy,
|
|
952
|
+
phase,
|
|
953
|
+
note,
|
|
954
|
+
logWriter,
|
|
955
|
+
estimates,
|
|
956
|
+
step: progress.step,
|
|
957
|
+
setPodsMs: (ms) => stats.setPodsMs(ms)
|
|
958
|
+
}),
|
|
959
|
+
cache: {
|
|
960
|
+
policy: cachePolicy,
|
|
961
|
+
providerConfig: cacheProviderConfig,
|
|
962
|
+
disabledByFlag: opts.buildCache === false
|
|
963
|
+
},
|
|
964
|
+
easBuild,
|
|
965
|
+
maxBuilds: limits.maxBuilds,
|
|
966
|
+
progress: {
|
|
967
|
+
phase,
|
|
968
|
+
note,
|
|
969
|
+
logWriter,
|
|
970
|
+
stats,
|
|
971
|
+
step: progress.step,
|
|
972
|
+
miss: progress.miss,
|
|
973
|
+
hit: progress.hit,
|
|
974
|
+
place: progress.place,
|
|
975
|
+
waitingOn: progress.waitingOn,
|
|
976
|
+
waitingFor: progress.waitingFor
|
|
977
|
+
}
|
|
978
|
+
}, d));
|
|
979
|
+
if (!acquiredArtifact.ok) {
|
|
980
|
+
compilationCache = acquiredArtifact.compilationCache;
|
|
981
|
+
return fail(acquiredArtifact.failure);
|
|
982
|
+
}
|
|
983
|
+
artifact = acquiredArtifact.artifact;
|
|
984
|
+
compilationCache = artifact.cache.compilation;
|
|
985
|
+
if (hostedTarget) return await finishHostedIosRun({
|
|
986
|
+
target: hostedTarget,
|
|
987
|
+
projectBundleId: integration.bundleId,
|
|
988
|
+
root,
|
|
989
|
+
slot,
|
|
990
|
+
d,
|
|
991
|
+
artifact,
|
|
992
|
+
configuration,
|
|
993
|
+
buildScheme,
|
|
994
|
+
release,
|
|
995
|
+
appMode,
|
|
996
|
+
isExpo,
|
|
997
|
+
metroCheck,
|
|
998
|
+
metroPort,
|
|
999
|
+
logsDir,
|
|
1000
|
+
json,
|
|
1001
|
+
elapsed,
|
|
1002
|
+
startedAt,
|
|
1003
|
+
closeWriter: () => writer?.close(),
|
|
1004
|
+
devicePlacement,
|
|
1005
|
+
recordRun,
|
|
1006
|
+
reclaimed,
|
|
1007
|
+
devServer,
|
|
1008
|
+
fail,
|
|
1009
|
+
note,
|
|
1010
|
+
enterPhase: progress.step,
|
|
1011
|
+
selectors
|
|
1012
|
+
});
|
|
1013
|
+
if (!localBoot) {
|
|
1014
|
+
progress.step("device");
|
|
1015
|
+
udid = await startBoot();
|
|
1016
|
+
}
|
|
1017
|
+
if (physicalDevice) {
|
|
1018
|
+
progress.step("device");
|
|
1019
|
+
const acquired = await d.acquireRunLease({
|
|
1020
|
+
root,
|
|
1021
|
+
platform: "ios",
|
|
1022
|
+
id: physicalDevice.udid,
|
|
1023
|
+
deviceName: physicalDevice.name,
|
|
1024
|
+
idLabel: "udid",
|
|
1025
|
+
waitSeconds,
|
|
1026
|
+
noWait,
|
|
1027
|
+
installBoundMs: iosDeviceBounds(wireless).installMs,
|
|
1028
|
+
appId: artifact.bundleId ?? proj?.bundleId ?? null,
|
|
1029
|
+
holderAppId: (holder) => d.getProject(holder)?.bundleId ?? null,
|
|
1030
|
+
now: d.now,
|
|
1031
|
+
warn: (line) => note(chalk.yellow(phaseLine("lease", line)))
|
|
1032
|
+
});
|
|
1033
|
+
if (acquired.status === "refused") return fail({
|
|
1034
|
+
code: acquired.refusal.code,
|
|
1035
|
+
message: acquired.refusal.message,
|
|
1036
|
+
remedy: acquired.refusal.remedy,
|
|
1037
|
+
lease: acquired.refusal.lease
|
|
1038
|
+
});
|
|
1039
|
+
leaseHandle = d.runLease({
|
|
1040
|
+
root,
|
|
1041
|
+
platform: "ios",
|
|
1042
|
+
kind: acquired.status === "leased" ? acquired.kind : null,
|
|
1043
|
+
expiresAt: acquired.status === "leased" ? acquired.expiresAt : null
|
|
1044
|
+
});
|
|
1045
|
+
if (acquired.status === "leased") {
|
|
1046
|
+
stopLeaseSignals = d.releaseLeaseOnSignal(releaseLease);
|
|
1047
|
+
phase("lease", `${acquired.kind} lease on ${physicalDevice.udid} until ${leaseExpiryText(acquired.expiresAt, d.now())}`);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
try {
|
|
1051
|
+
return await finishIosRun({
|
|
1052
|
+
projectBundleId: integration.bundleId,
|
|
1053
|
+
runtime: appRuntime,
|
|
1054
|
+
runtimePreparation,
|
|
1055
|
+
slot,
|
|
1056
|
+
d,
|
|
1057
|
+
root,
|
|
1058
|
+
json,
|
|
1059
|
+
release,
|
|
1060
|
+
configuration,
|
|
1061
|
+
buildScheme,
|
|
1062
|
+
isExpo,
|
|
1063
|
+
metroCheck,
|
|
1064
|
+
metroPort,
|
|
1065
|
+
logsDir,
|
|
1066
|
+
logFile,
|
|
1067
|
+
device,
|
|
1068
|
+
udid,
|
|
1069
|
+
physical,
|
|
1070
|
+
wireless,
|
|
1071
|
+
lanAddress,
|
|
1072
|
+
lanOriginUrl,
|
|
1073
|
+
remoteDevice,
|
|
1074
|
+
bootPromise,
|
|
1075
|
+
bootDuration: () => bootDuration,
|
|
1076
|
+
bootPending: () => bootPending,
|
|
1077
|
+
artifact,
|
|
1078
|
+
fail,
|
|
1079
|
+
phase,
|
|
1080
|
+
note,
|
|
1081
|
+
logWriter,
|
|
1082
|
+
elapsed,
|
|
1083
|
+
startedAt,
|
|
1084
|
+
closeWriter: () => writer?.close?.(),
|
|
1085
|
+
lease: leaseHandle,
|
|
1086
|
+
releaseLease,
|
|
1087
|
+
devicePlacement,
|
|
1088
|
+
recordRun,
|
|
1089
|
+
reclaimed,
|
|
1090
|
+
devServer,
|
|
1091
|
+
enterPhase: progress.step,
|
|
1092
|
+
enterActivity: progress.activity
|
|
1093
|
+
});
|
|
1094
|
+
} finally {
|
|
1095
|
+
releaseLease();
|
|
1096
|
+
}
|
|
1097
|
+
} catch (error) {
|
|
1098
|
+
recordRun({
|
|
1099
|
+
failed: true,
|
|
1100
|
+
durationMs: elapsed()
|
|
1101
|
+
});
|
|
1102
|
+
throw error;
|
|
1103
|
+
} finally {
|
|
1104
|
+
artifact?.release();
|
|
1105
|
+
}
|
|
1106
|
+
} finally {
|
|
1107
|
+
await deviceWaitRun.finish();
|
|
1108
|
+
hostedTarget?.host.connection.close();
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
//#endregion
|
|
1112
|
+
export { registerIos as n, runIosOperation as r, iosCommand as t };
|