stim 1.17.2 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -1
- package/dist/{activity-IRvJY_ru.mjs → activity-BSw0x84R.mjs} +4 -4
- package/dist/{agent-device-usage-output-BK41vnzN.mjs → agent-device-usage-output-Bjxu_VmX.mjs} +8 -8
- package/dist/{android-B9yaNKwa.mjs → android-BXc6BmEi.mjs} +658 -404
- package/dist/{android-B_YNZy61.mjs → android-BdQC6zs1.mjs} +9 -9
- package/dist/android-BvV1gGdN.mjs +4 -0
- package/dist/{android-DE4v59Mb.mjs → android-DE5g_5gv.mjs} +2 -2
- package/dist/{android-cas-ZFpjJBL_.mjs → android-cas-C87geAg-.mjs} +5 -5
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/api-DIf_s86s.mjs +150 -0
- package/dist/api-run.d.mts +1 -0
- package/dist/api-run.mjs +145 -0
- package/dist/api.d.mts +218 -0
- package/dist/api.mjs +2 -0
- package/dist/{app-install-VPkI5WEg.mjs → app-install-CFI4ptUL.mjs} +33 -13
- package/dist/{attempt-Bk2ouQVL.mjs → attempt-DW-mQqM7.mjs} +14 -4
- package/dist/{web-Dl0KSRHf.mjs → browser-web-CDhqQxhv.mjs} +138 -176
- package/dist/{budget-DfcgFdQB.mjs → budget-Dz-kyXLv.mjs} +1391 -58
- package/dist/build-facts-B87vo-Im.d.mts +142 -0
- package/dist/{cache-manifest-DnUHBJaU.mjs → cache-manifest-DiwKSyv9.mjs} +3 -3
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{chrome-BrcVWQyD.mjs → chrome-BTUOo8p2.mjs} +1 -1
- package/dist/cli-C9Zvgbdc.mjs +68 -0
- package/dist/cli.mjs +1 -1
- package/dist/{client-SvBdgObD.mjs → client-CuUo8Nvg.mjs} +381 -49
- package/dist/collector-run.d.mts +6 -0
- package/dist/collector-run.mjs +9 -9
- package/dist/{command-output-CDAIFD-8.mjs → command-output-Bt8ygHE7.mjs} +2 -2
- package/dist/{config-D0DbpZtM.mjs → config-DC5jEtd1.mjs} +9 -5
- package/dist/{created-devices-CpvzBL25.mjs → created-devices-D0s26Hx5.mjs} +2 -2
- package/dist/{dependency-state-CLcBHH2M.mjs → dependency-state-DKaS1OM9.mjs} +2 -2
- package/dist/{detached-entry-CiTEgMR1.mjs → detached-entry-pB_IPfV4.mjs} +1 -1
- package/dist/{dev-client-B-XC4uRH.mjs → dev-client-CDY_zAmD.mjs} +2 -2
- package/dist/{device-C8IOoJPv.mjs → device-BHw0WlHl.mjs} +8 -8
- package/dist/{device-capacity-ZC4XSZ4R.mjs → device-capacity-BoN1jQkO.mjs} +25 -14
- package/dist/device-host-worker.mjs +19 -19
- package/dist/{gradle-dJpre3Yn.mjs → device-ios-B2ruohE-.mjs} +661 -107
- package/dist/{device-lease-DpoS36_u.mjs → device-lease-Cu7PtQpZ.mjs} +9 -9
- package/dist/{device-lease-run-B8YltIH_.mjs → device-lease-run-D38SnZtt.mjs} +4 -4
- package/dist/{device-pool-3o7s5lo4.mjs → device-pool-CP4rAsHx.mjs} +3 -3
- package/dist/{device-remote-hFSkpfQu.mjs → device-remote-B5GiUifk.mjs} +15 -16
- package/dist/{doctor-CFv1fCrF.mjs → doctor-PRJH94v6.mjs} +61 -34
- package/dist/doctor-watchman-wZhyTdp4.mjs +259 -0
- package/dist/{error-diagnostics-C-NMnhrk.mjs → error-diagnostics--v5HGOU0.mjs} +11 -11
- package/dist/{exec-CaErVv7t.mjs → exec-i8GDPwq9.mjs} +93 -6
- package/dist/{gc-DEmkg3Xh.mjs → gc-CyHMcKcn.mjs} +25 -471
- package/dist/{guide-CSmhMTf8.mjs → guide-dRaQJJk9.mjs} +681 -507
- package/dist/{hosted-android-E1Heoqnv.mjs → hosted-android-Bs7fytj7.mjs} +3 -3
- package/dist/{hosted-client-Bp4knSwu.mjs → hosted-client-C5G4h_OJ.mjs} +2 -2
- package/dist/{hosted-ios-BnbeYOUD.mjs → hosted-ios-Bik035eL.mjs} +1 -1
- package/dist/{hosted-logs-OcgIBvCT.mjs → hosted-logs-CI9Az9a4.mjs} +9 -9
- package/dist/{hosted-macos-DcxKjtfH.mjs → hosted-macos-DABm3ScO.mjs} +5 -5
- package/dist/{hosted-native-1Ebbig4w.mjs → hosted-native-DbV2aUVw.mjs} +13 -9
- package/dist/{idle-shutdown-IGyNV8Cr.mjs → idle-shutdown-DYiMBn34.mjs} +7 -8
- package/dist/{ios-DSfnPfse.mjs → ios-BWbHFZVz.mjs} +19 -7
- package/dist/{ios-Cr1h5gnO.mjs → ios-DCrkgXEM.mjs} +1 -1
- package/dist/ios-DYUr9LGc.mjs +8 -0
- package/dist/ios-ITYno9rO.mjs +2241 -0
- package/dist/{ios-device-pAN4t54-.mjs → ios-device-CJ_ZOGky.mjs} +3 -3
- package/dist/{ios-device-Ee7sDXfp.mjs → ios-device-CrW8aMb5.mjs} +1 -1
- package/dist/{ios-state-8L3lgum6.mjs → ios-state-By0XuLTQ.mjs} +1 -1
- package/dist/{launch-verify-lTnWZikR.mjs → launch-verify-DCveSE6d.mjs} +5 -5
- package/dist/{logs-BAaS7gS2.mjs → logs-Bao1HOMy.mjs} +13 -13
- package/dist/{macos-BIRQS90f.mjs → macos-ciyBdTY5.mjs} +194 -132
- package/dist/macos-nIOATJmR.mjs +2 -0
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +349 -47
- package/dist/manifest-CX0d1IkZ.mjs +148 -0
- package/dist/{metro-g8NqiJp-.mjs → metro-DI2AjPF_.mjs} +196 -43
- package/dist/{metro-gateway-C-ijGI2F.mjs → metro-gateway-BxpJLIwh.mjs} +4 -4
- package/dist/{metro-store-CDDZHtPl.mjs → metro-store-BAHFcJm6.mjs} +16 -2
- package/dist/{build-plan-BDsSi09V.mjs → miss-reason-CjQCOKqq.mjs} +207 -249
- package/dist/{named-ports-C8m8EQs2.mjs → named-ports-B4iWH4E-.mjs} +70 -8
- package/dist/{native-runtime-BEK171xQ.mjs → native-runtime-BGxsbfny.mjs} +6 -6
- package/dist/{ndjson-PclOIwVY.mjs → ndjson-LGZAMsqa.mjs} +8 -4
- package/dist/offload-worker.d.mts +3 -45
- package/dist/offload-worker.mjs +11 -11
- package/dist/{ownership-DyRQru0q.mjs → ownership-EB0ySdGK.mjs} +3 -3
- package/dist/{page-QF_Ke10s.mjs → page-Bv9s2KwY.mjs} +1 -1
- package/dist/placement-log-Dxe34rJm.mjs +88 -0
- package/dist/plan-placement-BVY59qa8.mjs +290 -0
- package/dist/{ports-4nYqxPWC.mjs → ports-ByPc0_97.mjs} +3 -3
- package/dist/{prebuild-D7RUMkwN.mjs → prebuild-BKJ3wJI1.mjs} +5 -5
- package/dist/preview-BbSottmO.mjs +986 -0
- package/dist/{rolldown-runtime-BsOwBuO_.mjs → process-identity-Biv3arCO.mjs} +11 -1
- package/dist/project-B5eQ1USs.mjs +612 -0
- package/dist/{pull-request-pxnDCQzn.mjs → pull-request-IHNdMnG8.mjs} +1 -1
- package/dist/pull-requests.mjs +1 -1
- package/dist/react-native-ios-BMh2i25I.mjs +2 -0
- package/dist/react-native-ios-CSpIxexZ.mjs +2083 -0
- package/dist/{recordings-BNgsD1Tr.mjs → recordings-Bv8McZN4.mjs} +1 -1
- package/dist/{reload-DcRxj3qG.mjs → reload-rAPdqeRR.mjs} +14 -15
- package/dist/{remote-cache-Ci4DQYYj.mjs → remote-cache-N3hAEaAL.mjs} +5 -5
- package/dist/{run-CkE9y0nc.mjs → run-lAkle1-c.mjs} +5 -5
- package/dist/{server-bare-BkrSxSsZ.mjs → server-bare-CkIjnegq.mjs} +5 -6
- package/dist/server-expo-DGsdUGX2.mjs +2 -0
- package/dist/{server-expo-CHTyXD0G.mjs → server-expo-n3tUi3Em.mjs} +5 -6
- package/dist/{settings-SR9OmW9h.mjs → settings-2am7TSxp.mjs} +5 -5
- package/dist/{settings-Cfd-0r2d.mjs → settings-CxgngUZk.mjs} +116 -103
- package/dist/{settings-BBpMcDbD.mjs → settings-Djl-mpjX.mjs} +1 -1
- package/dist/settings.schema.json +198 -9
- package/dist/{simslim-BWNrc3M3.mjs → simslim-D9LkJxIO.mjs} +7 -7
- package/dist/{slot-launch-DmjBmpQV.mjs → slot-launch-HV_KtPIw.mjs} +6 -6
- package/dist/{spawn-claims-D0XfSe8u.mjs → spawn-claims-Kqiifsk2.mjs} +1 -1
- package/dist/{spawn-entry-jw19m8Nl.mjs → spawn-entry-Dcb7sDUz.mjs} +1 -0
- package/dist/{stage-CzaiwFsI.mjs → stage-BgaZJVZY.mjs} +14 -3
- package/dist/{start-AlfCPRVU.mjs → start-D8NbxNBb.mjs} +1 -1
- package/dist/{start-DUz3mYdb.mjs → start-DtxthMfI.mjs} +34 -27
- package/dist/{state-PeQiJuIu.mjs → state-D2KtnALG.mjs} +4 -4
- package/dist/{state-DyaNTgfR.mjs → state-Tp4uImDS.mjs} +5 -3
- package/dist/{state-B4PQFXMW.d.mts → state-lKh8shBp.d.mts} +2 -3
- package/dist/{stats-Bq4fJOdB.mjs → stats-8EJ5ivFT.mjs} +6 -6
- package/dist/{status-DlKvVJBE.mjs → status-BEeL6IKz.mjs} +6 -4
- package/dist/{status-BA2pehwf.mjs → status-BOyp0CUl.mjs} +31 -34
- package/dist/{stim-desktop-Cnz8CPnl.mjs → stim-desktop-C65jk_q2.mjs} +1 -1
- package/dist/{stim-installations-QMEI32v1.mjs → stim-installations-DbmUjsLv.mjs} +1 -1
- package/dist/stop-D0UIpZuh.mjs +72 -0
- package/dist/{stop-zF1y04f2.mjs → stop-DRipAg-e.mjs} +2 -2
- package/dist/{stop-DQIasgKp.mjs → stop-zDlknFoz.mjs} +79 -33
- package/dist/supervisor-run.d.mts +24 -22
- package/dist/supervisor-run.mjs +21 -22
- package/dist/{support-CsJNVfOc.mjs → support-CNqYkV0y.mjs} +7 -7
- package/dist/{support-WvD__tSV.mjs → support-DsNaFg6D.mjs} +5 -5
- package/dist/swiftpm-macos-aJzPAj1t.mjs +119 -0
- package/dist/{toolchain-DNyR3NPq.mjs → toolchain-C3xSoyUl.mjs} +475 -269
- package/dist/{trigger-Bemu8ytw.mjs → trigger-CAhmG-4s.mjs} +6 -6
- package/dist/trigger-CoalsMTV.mjs +2 -0
- package/dist/{warm-progress-DF4JRvYI.mjs → warm-progress-pFLB2e6P.mjs} +135 -38
- package/dist/{status-CzS4bPO9.mjs → watchman-BL1IdOtq.mjs} +75 -7
- package/dist/web-DFpFeZu5.mjs +2 -0
- package/dist/web-DbbrPUn0.mjs +127 -0
- package/dist/web-run.mjs +10 -10
- package/dist/{workspace-state-DqcCbpE7.mjs → workspace-state-CR9X86xJ.mjs} +3 -3
- package/dist/{ownership-BMLqyBgJ.mjs → workspaces-Djb2gfi9.mjs} +661 -23
- package/dist/{worktree-Be_7NLKy.mjs → worktree-BL4M1rhB.mjs} +252 -50
- package/dist/{worktree-j3IcFAI5.mjs → worktree-DV-A0LNL.mjs} +1 -1
- package/package.json +10 -5
- package/shim/bundle-response.cjs +2 -1
- package/shim/bundle-response.d.cts +1 -1
- package/shim/expo-metro-config.cjs +1 -1
- package/dist/build-progress-D0WkjCPd.mjs +0 -1036
- package/dist/build-slots-41v_d2x9.mjs +0 -142
- package/dist/cli-CYXb29oE.mjs +0 -51
- package/dist/deps-iKw0eD4P.mjs +0 -438
- package/dist/device-ios-C2Um-XUR.mjs +0 -412
- package/dist/errors-B6W7FkxQ.mjs +0 -15
- package/dist/guide-status-Du-ZQ3FD.mjs +0 -125
- package/dist/idle-BXG__1BA.mjs +0 -176
- package/dist/in-use-CvGOUn-x.mjs +0 -130
- package/dist/ios-BJ4XUSe1.mjs +0 -3867
- package/dist/native-run-D1Q56rAD.mjs +0 -158
- package/dist/preview-B-g9d7kV.mjs +0 -318
- package/dist/process-identity-BmRm1qV0.mjs +0 -12
- package/dist/project-D47Rh0ly.mjs +0 -276
- package/dist/server-expo-CeakhI8P.mjs +0 -2
- package/dist/state-BKa8wNN5.mjs +0 -148
- package/dist/stop-BIiM49EY.mjs +0 -48
- package/dist/stop-cause-rhmGfwvt.mjs +0 -97
- package/dist/trigger-CXts6qt1.mjs +0 -2
- package/dist/watchman-APYjXSQa.mjs +0 -48
- package/dist/workspace-process-lock-2mNzOlaB.mjs +0 -58
- package/dist/workspaces-Bcib97-6.mjs +0 -306
package/dist/ios-BJ4XUSe1.mjs
DELETED
|
@@ -1,3867 +0,0 @@
|
|
|
1
|
-
import { t as getExecutor } from "./exec-CaErVv7t.mjs";
|
|
2
|
-
import { E as upsertProject, L as deviceSlotFileKey, R as deviceSlotKey, V as parseDeviceSlotOption, W as validateDeviceSlot, p as getProject, u as getConcurrencyLimits, v as recordIosSchemeApprovals, z as deviceSlotPlatforms } from "./config-D0DbpZtM.mjs";
|
|
3
|
-
import { n as ownership_claim_exports } from "./process-identity-BmRm1qV0.mjs";
|
|
4
|
-
import { _ as stepTimer, c as launchErrorReport, g as stepClock, h as shortUdid, i as formatDuration, l as phaseLine, m as shortHash, n as appReadinessMessage, v as launchErrorPreview } from "./command-output-CDAIFD-8.mjs";
|
|
5
|
-
import { B as settingsLayers, C as metroWarmupUrlSetting, G as detectProviders, H as unknownSettingKeys, J as artifactCachePolicy, L as settingOriginScope, M as remoteIosSetting, N as resolveCacheProviderConfig, P as resolveSettings, R as settingShapeErrors, T as parseIosRemote, Tt as removeTemporaryEntry, V as tunnelModeSetting, X as optimizationBuildProfile, Z as resolveOptimizations, _ as iosSigningIdentitySha1SettingError, f as iosLanHostSetting, g as iosSigningIdentitySha1Setting, gt as repoRoot, h as iosSigningIdentitySettingError, i as SETTING_SHAPE_REMEDY, it as gitCommonDir, k as publicUrlSetting, m as iosSigningIdentitySetting, p as iosLanHostSettingError, u as cacheProviderSettingError, wt as makeTemporaryDirectory, x as metroPortSetting } from "./settings-Cfd-0r2d.mjs";
|
|
6
|
-
import { n as appProjectProblem, r as detectIsExpo, s as findProjectRoot$1, t as NO_PROJECT_REFUSAL } from "./project-D47Rh0ly.mjs";
|
|
7
|
-
import { l as resolveProjectMetro, o as pidExists, u as signalProcessTree } from "./metro-g8NqiJp-.mjs";
|
|
8
|
-
import { c as writeWorkspaceState, g as workspaceAgentDeviceDir, i as recordWorkspaceUse, r as readWorkspaceState$1, v as workspaceDir, x as workspaceLogsDir$1 } from "./workspace-state-DqcCbpE7.mjs";
|
|
9
|
-
import { t as budgetGate } from "./budget-DfcgFdQB.mjs";
|
|
10
|
-
import { A as providerDownloadPath, D as fingerprintProject, E as fingerprintDiffRecord, L as untrackedMissLine, M as refingerprintAfterMutation, N as resolveBuild, O as inputsChangedDuringBuild, P as storeBuild, R as untrackedNativeFiles, S as configInputsChanged, T as filesystemBuildCapability, _ as waitForBuild, b as buildCacheKey, g as releaseBuildLock, j as providerUploadOutcome, k as prepareProviderDownloadDir, m as acquireBuildLock, v as waitForSharedBuild, x as changedDuringBuildLine } from "./device-lease-DpoS36_u.mjs";
|
|
11
|
-
import { r as releaseBuildSlot, t as acquireBuildSlot } from "./build-slots-41v_d2x9.mjs";
|
|
12
|
-
import { m as writeWorkspaceLaunch, n as MODE_EXPO, t as MODE_BARE } from "./state-BKa8wNN5.mjs";
|
|
13
|
-
import { ft as parkedMaxSetting, ot as POOL_SETTING_REMEDY } from "./android-B_YNZy61.mjs";
|
|
14
|
-
import { p as listIosRuntimes, r as clearIosAppData, u as listAllIosSims } from "./ios-DSfnPfse.mjs";
|
|
15
|
-
import { a as workspaceLinks, i as workspaceLinkLine } from "./stim-desktop-Cnz8CPnl.mjs";
|
|
16
|
-
import { _ as statsProjectKey$1, c as recordFinishedBuild, d as createRunRecorder, f as readRunEstimates, g as recordRunStats, l as startBuildProgress, m as recordCapacityRefusal, n as NO_BUILD_PROGRESS, u as tapBuildLog } from "./build-progress-D0WkjCPd.mjs";
|
|
17
|
-
import { r as createNdjsonWriter } from "./ndjson-PclOIwVY.mjs";
|
|
18
|
-
import { S as bundlerPin, _ as readBundleId, c as COMPILATION_CACHE_NOT_RUN, d as buildIos, g as readBundleExecutable, h as discoverXcodeProject, p as compilationCacheActivityLine, r as iosToolchain, v as resolveScheme } from "./toolchain-DNyR3NPq.mjs";
|
|
19
|
-
import { a as offloadBuild, c as placementLoad, d as OffloadRefusal, f as namedBuildMachine, h as resolveBuildPlacement, i as closeOffload, l as remotePhaseText, n as buildPlacementCandidates, p as parseBuildMachineOption, r as chooseBuildMachine, s as offloadPlacement, u as simulatorRuntime } from "./client-SvBdgObD.mjs";
|
|
20
|
-
import { r as hostedMetroSettings } from "./metro-gateway-C-ijGI2F.mjs";
|
|
21
|
-
import { n as verifyCollectorOwnership } from "./ownership-DyRQru0q.mjs";
|
|
22
|
-
import { r as checkDeviceCapacity } from "./device-capacity-ZC4XSZ4R.mjs";
|
|
23
|
-
import { D as schemesFromInfoPlist, S as restartedAppNote, T as pickDevClientScheme, _ as installIosApp, a as IOS_DEV_MENU_OFF_DEFAULTS_PLIST, d as devClientUrl, l as clearOtherUserApps, r as DEFAULT_METRO_PORT, v as iosAppProcess, x as launchIosApp } from "./app-install-VPkI5WEg.mjs";
|
|
24
|
-
import { n as devClientTakesDevMenuParams, t as devClientScheme } from "./dev-client-B-XC4uRH.mjs";
|
|
25
|
-
import { t as spawnEntry } from "./spawn-entry-jw19m8Nl.mjs";
|
|
26
|
-
import { a as runPodInstall, n as podsAreStale, r as readPodState } from "./deps-iKw0eD4P.mjs";
|
|
27
|
-
import { i as staleNativeDirRefusal, n as recordPrebuild, r as runPrebuild, t as planPrebuild } from "./prebuild-D7RUMkwN.mjs";
|
|
28
|
-
import { c as readMetroRecords, f as verifyLaunch, i as RELEASE_VERIFY_WAIT_MS, l as unattributedLaunchLines, n as LAUNCH_FATAL, o as isBundleProof, p as verifyReleaseLaunch, r as LAUNCH_UNVERIFIED, s as readCollectorRecords, t as LAUNCH_BUNDLING, u as unverifiedLaunchLines } from "./launch-verify-lTnWZikR.mjs";
|
|
29
|
-
import { a as acquireRunLease, c as lostRefusal, d as runLease, f as waitFlagConflict, o as leaseExpiryText, s as lostLine, t as DEBUG_VERIFY_STEP_MS, u as releaseLeaseOnSignal } from "./device-lease-run-B8YltIH_.mjs";
|
|
30
|
-
import { n as clearIosAdoptionPending } from "./device-ios-C2Um-XUR.mjs";
|
|
31
|
-
import { _ as resolveSimulatorAppFlag, a as deviceModelRefusal, c as iosProviderRunOptions, d as podAction, f as printDiagnostics, g as resolveRuntime, h as resolveIosWait, i as deviceLabel, l as isReleaseConfiguration, m as resolveDeviceType, n as buildLogFile, o as deviceShortName, p as resolveConfiguration, r as createIosDeviceWaitRun, s as iosConfigurationSetting, t as appNameFromPath, u as ownedSimFailure, v as simulatorBuildArch, y as xcodeFailureReport } from "./support-CsJNVfOc.mjs";
|
|
32
|
-
import { i as writeDevicePlacement, n as readHostedIos, o as writeHostedIos } from "./ios-state-8L3lgum6.mjs";
|
|
33
|
-
import { a as refusePlan, b as devicePlacementLine, c as skippedMissReason, f as swapJsBundle, h as ensureOwnedDevice, i as printPlan, m as ensureBooted, n as planFlagRefusal, o as explainBuildMiss, p as didSetUpDevice, r as planPayload, s as fingerprintErrorMissReason, t as planCachedBuild, v as warmMetro, y as automaticDevicePlacement } from "./build-plan-BDsSi09V.mjs";
|
|
34
|
-
import { n as nativeRunCommand, r as siblingPlatformSlots, t as launchSlotScope } from "./slot-launch-DmjBmpQV.mjs";
|
|
35
|
-
import { a as easAuthNote, c as loadProjectProvider, f as resolveEasCliBin, i as checkEasAuth, m as uploadRemote, n as UPLOAD_TIMEOUT_MS, o as exitAfterFlush, p as resolveRemote, r as cacheLevel, s as isEasAuthFailureText, t as RESOLVE_TIMEOUT_MS } from "./remote-cache-Ci4DQYYj.mjs";
|
|
36
|
-
import { O as readRemoteSimulatorArch, a as ensureMetroReachable, k as gateMetroOrigin, l as remoteIosDeps, n as binOnPath, o as ensureRemoteBootOwned, r as bundleEntryPoint, u as resolveRemoteContext, w as ownedSessionName } from "./device-remote-hFSkpfQu.mjs";
|
|
37
|
-
import { d as runCancellationSignal, f as withNativeBuildRun, r as cancelledFailure, u as runCancellation } from "./native-run-D1Q56rAD.mjs";
|
|
38
|
-
import { a as isEasBuildFailure, i as easDeviceBuildRemedy, o as planEasDevelopmentBuild, s as resolveEasDevelopmentBuild } from "./simslim-BWNrc3M3.mjs";
|
|
39
|
-
import { c as startDevServer, h as detectBundleId } from "./start-DUz3mYdb.mjs";
|
|
40
|
-
import { a as sleep, i as launchOutcomeRecord, n as ensureWorkspaceStorageSafely, r as isPhysicalDeviceRequest, t as ensureDevServer } from "./native-runtime-BEK171xQ.mjs";
|
|
41
|
-
import { t as selectFromPool } from "./device-pool-3o7s5lo4.mjs";
|
|
42
|
-
import { a as printNativeCrashReport, n as IOS_CRASH_REPORT_RETRY, o as simulatorConsolePaths, r as captureNativeCrashes, t as errorDiagnostics } from "./error-diagnostics-C-NMnhrk.mjs";
|
|
43
|
-
import { a as iosPoolCandidates, c as isWirelessIosDevice, f as resolveIosPhysicalDevice, i as iosDeviceProcess, l as listIosDevices, n as installIosDeviceApp, o as iosPoolNoCandidatesRefusal, p as verifyIosDeviceReleaseLaunch, r as iosDeviceBounds, t as awaitIosDeviceLaunch, u as localNetworkPending } from "./ios-device-pAN4t54-.mjs";
|
|
44
|
-
import { n as prepareHostedIos, t as placeHostedIos } from "./hosted-ios-BnbeYOUD.mjs";
|
|
45
|
-
import { X509Certificate } from "node:crypto";
|
|
46
|
-
import { existsSync, mkdirSync, mkdtempSync, openSync, rmSync, writeFileSync } from "node:fs";
|
|
47
|
-
import { basename, join } from "node:path";
|
|
48
|
-
import { hostSimulatorArch, workspaceId } from "@stim-cli/core";
|
|
49
|
-
import { InvalidArgumentError } from "commander";
|
|
50
|
-
import { buildDiagnostics, hostedIosStatus, machineCapacity, parseMachine } from "@stim-cli/core/state";
|
|
51
|
-
import { networkInterfaces, tmpdir } from "node:os";
|
|
52
|
-
import chalk from "chalk";
|
|
53
|
-
import { createWarnOnce, loadCacheProvider, resolveTieredBuild, storeTieredBuild } from "@stim-cli/cache";
|
|
54
|
-
//#region src/engine/ios-lan.ts
|
|
55
|
-
const IP_TXT = "ip.txt";
|
|
56
|
-
function chooseLanAddress({ pinned = null, candidates }) {
|
|
57
|
-
const list = Array.isArray(candidates) ? candidates : [];
|
|
58
|
-
if (pinned) return {
|
|
59
|
-
address: pinned,
|
|
60
|
-
interfaceName: list.find((candidate) => candidate.address === pinned)?.interfaceName ?? null,
|
|
61
|
-
pinned: true,
|
|
62
|
-
candidates: list.length
|
|
63
|
-
};
|
|
64
|
-
const first = list[0];
|
|
65
|
-
if (!first) return null;
|
|
66
|
-
return {
|
|
67
|
-
address: first.address,
|
|
68
|
-
interfaceName: first.interfaceName,
|
|
69
|
-
pinned: false,
|
|
70
|
-
candidates: list.length
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function lanOriginUrlFor(address, port) {
|
|
74
|
-
return `http://${address}:${port}`;
|
|
75
|
-
}
|
|
76
|
-
function ipTxtContents(address, port) {
|
|
77
|
-
return `${String(address).trim()}:${String(port).trim()}\n`;
|
|
78
|
-
}
|
|
79
|
-
function writeIpTxt(appPath, address, port, { write = writeFileSync } = {}) {
|
|
80
|
-
const path = join(appPath, IP_TXT);
|
|
81
|
-
write(path, ipTxtContents(address, port), "utf-8");
|
|
82
|
-
return path;
|
|
83
|
-
}
|
|
84
|
-
async function ensureLanReachable({ origin, metroPort, root, isExpo, logsDir, gateOrigin = gateMetroOrigin, readRecords = null }) {
|
|
85
|
-
const result = await gateOrigin({
|
|
86
|
-
origin,
|
|
87
|
-
metroPort,
|
|
88
|
-
platform: "ios",
|
|
89
|
-
entryPoint: bundleEntryPoint(root, isExpo),
|
|
90
|
-
readRecords: readRecords ?? (() => readMetroRecords(logsDir)),
|
|
91
|
-
isProof: isBundleProof
|
|
92
|
-
});
|
|
93
|
-
if (result.failed) return {
|
|
94
|
-
failed: result.reason ?? `${origin} is not this workspace's Metro.`,
|
|
95
|
-
remedy: `The phone reaches Metro at ${origin}, so that address has to serve THIS workspace's dev server. \`stim start\` prints the port it reserved. Set ios.lanHost in .stim.json when this Mac has several network interfaces and the phone shares one that is not the first.`
|
|
96
|
-
};
|
|
97
|
-
return { ok: true };
|
|
98
|
-
}
|
|
99
|
-
function copyAppAside(appPath, { exec = null, mkdtemp = () => makeTemporaryDirectory(appPath, "stim-ios-device-") } = {}) {
|
|
100
|
-
const e = exec || getExecutor();
|
|
101
|
-
const tmpDir = mkdtemp();
|
|
102
|
-
const copy = join(tmpDir, basename(appPath));
|
|
103
|
-
try {
|
|
104
|
-
e.runFile("cp", [
|
|
105
|
-
"-c",
|
|
106
|
-
"-R",
|
|
107
|
-
appPath,
|
|
108
|
-
copy
|
|
109
|
-
]);
|
|
110
|
-
} catch {
|
|
111
|
-
try {
|
|
112
|
-
removeTemporaryEntry(copy);
|
|
113
|
-
e.runFile("cp", [
|
|
114
|
-
"-R",
|
|
115
|
-
appPath,
|
|
116
|
-
copy
|
|
117
|
-
]);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
removeTemporaryEntry(tmpDir);
|
|
120
|
-
throw error;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
tmpDir,
|
|
125
|
-
appPath: copy
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/commands/ios/result.ts
|
|
130
|
-
function lastBuildRecord({ devicePlacement, fingerprint = null, cacheKey = null, cacheHit = false, cacheSkipped = false, durationMs = 0, appPath = null, bundleId = null, startedAt, status, errorCode = null, missReason = null, diagnostics = null, configuration = null, buildMachine = "auto", builtOn, offloadedTo = null, offloadFallback = null }) {
|
|
131
|
-
const record = {
|
|
132
|
-
platform: "ios",
|
|
133
|
-
fingerprint,
|
|
134
|
-
cacheKey,
|
|
135
|
-
cacheHit: cacheLevel(cacheHit),
|
|
136
|
-
cacheSkipped: Boolean(cacheSkipped),
|
|
137
|
-
durationMs,
|
|
138
|
-
appPath,
|
|
139
|
-
bundleId,
|
|
140
|
-
startedAt,
|
|
141
|
-
status,
|
|
142
|
-
configuration
|
|
143
|
-
};
|
|
144
|
-
if (errorCode) record.errorCode = errorCode;
|
|
145
|
-
if (devicePlacement) record.devicePlacement = devicePlacement;
|
|
146
|
-
record.buildMachine = buildMachine;
|
|
147
|
-
if (builtOn) record.builtOn = builtOn;
|
|
148
|
-
if (offloadedTo) record.offloadedTo = offloadedTo;
|
|
149
|
-
if (offloadFallback) record.offloadFallback = offloadFallback;
|
|
150
|
-
if (missReason && !cacheLevel(cacheHit)) record.missReason = missReason;
|
|
151
|
-
const recorded = status === "failed" ? buildDiagnostics(diagnostics) : [];
|
|
152
|
-
if (recorded.length) record.diagnostics = recorded;
|
|
153
|
-
return record;
|
|
154
|
-
}
|
|
155
|
-
function iosFacts({ root, slot, udid, deviceName, deviceType = null, runtime = null, fingerprint, configuration = null, scheme = null, cacheKey, cacheHit, cacheSkipped = false, compilationCache = COMPILATION_CACHE_NOT_RUN, waitedForBuild = null, appPath, bundleId, installSkipped = false, metroPort, logsDir, durationMs, launched = true, webPreviewUrl = null, lease, devServer = null, buildMachine = "auto", builtOn, offloadedTo = null, offloadFallback = null }) {
|
|
156
|
-
return {
|
|
157
|
-
platform: "ios",
|
|
158
|
-
...slot && slot !== "default" ? { slot } : {},
|
|
159
|
-
udid,
|
|
160
|
-
deviceName: deviceName ?? null,
|
|
161
|
-
deviceType: deviceType ?? null,
|
|
162
|
-
runtime: runtime ?? null,
|
|
163
|
-
fingerprint,
|
|
164
|
-
configuration: configuration ?? null,
|
|
165
|
-
...scheme ? { scheme } : {},
|
|
166
|
-
cacheKey,
|
|
167
|
-
cacheHit: cacheLevel(cacheHit),
|
|
168
|
-
cacheSkipped: Boolean(cacheSkipped),
|
|
169
|
-
buildMachine,
|
|
170
|
-
...builtOn ? { builtOn } : {},
|
|
171
|
-
...offloadedTo ? { offloadedTo } : {},
|
|
172
|
-
...offloadFallback ? { offloadFallback } : {},
|
|
173
|
-
compilationCache,
|
|
174
|
-
waitedForBuild: waitedForBuild ? {
|
|
175
|
-
pid: waitedForBuild.pid ?? null,
|
|
176
|
-
ms: waitedForBuild.ms ?? 0
|
|
177
|
-
} : null,
|
|
178
|
-
appPath,
|
|
179
|
-
bundleId,
|
|
180
|
-
installSkipped: Boolean(installSkipped),
|
|
181
|
-
launched: launched === "unverified" || launched === "bundling" ? launched : Boolean(launched),
|
|
182
|
-
metroPort,
|
|
183
|
-
logs: { dir: logsDir },
|
|
184
|
-
...root ? { agentDevice: { stateDir: workspaceAgentDeviceDir(root) } } : {},
|
|
185
|
-
durationMs,
|
|
186
|
-
...webPreviewUrl ? { webPreviewUrl } : {},
|
|
187
|
-
...lease === void 0 ? {} : { lease },
|
|
188
|
-
...devServer ? { devServer } : {}
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function writeLastBuild(root, record, { record: recordBuild = recordFinishedBuild } = {}) {
|
|
192
|
-
try {
|
|
193
|
-
recordBuild(root, record);
|
|
194
|
-
} catch {}
|
|
195
|
-
return record;
|
|
196
|
-
}
|
|
197
|
-
async function finishIosUpload(uploadPending, remote, phase, note) {
|
|
198
|
-
if (!uploadPending) return false;
|
|
199
|
-
const upload = await uploadPending;
|
|
200
|
-
if (upload?.uploaded) phase("cache", `uploaded (${remote?.name})`);
|
|
201
|
-
else if (upload?.timedOut) {
|
|
202
|
-
note(chalk.yellow(phaseLine("cache", `${remote?.name} upload still running after ${formatDuration(UPLOAD_TIMEOUT_MS)}; not waiting`)));
|
|
203
|
-
return true;
|
|
204
|
-
} else if (upload?.failed) {
|
|
205
|
-
const authNote = remote?.name === "eas" && isEasAuthFailureText(upload.failed) ? easAuthNote({
|
|
206
|
-
code: "logged-out",
|
|
207
|
-
reason: upload.failed,
|
|
208
|
-
phase: "upload"
|
|
209
|
-
}) : null;
|
|
210
|
-
note(chalk.yellow(phaseLine("cache", authNote || `${remote?.name} upload failed: ${upload.failed}`)));
|
|
211
|
-
}
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
function reportIosResult({ devicePlacement, host, slot, root, json, release, configuration, buildScheme = null, metroCheck, metroPort, logsDir, device, udid, appPath, bundleId, installSkipped, elapsed, startedAt, storeHash, storeKey, cacheHit, missReason, compilationCache, useBuildCache, waitedForBuild, launchState, launchWarning, providerName, buildMachine = "auto", builtOn, offloadedTo = null, offloadFallback = null, closeWriter, webPreviewUrl, lease, recordRun, reclaimed = [], devServer = null, links }) {
|
|
215
|
-
const durationMs = elapsed();
|
|
216
|
-
recordRun({
|
|
217
|
-
failed: false,
|
|
218
|
-
cacheHit,
|
|
219
|
-
waited: waitedForBuild,
|
|
220
|
-
durationMs,
|
|
221
|
-
offloadedTo
|
|
222
|
-
});
|
|
223
|
-
writeLastBuild(root, lastBuildRecord({
|
|
224
|
-
devicePlacement,
|
|
225
|
-
fingerprint: storeHash,
|
|
226
|
-
cacheKey: storeKey,
|
|
227
|
-
cacheHit,
|
|
228
|
-
cacheSkipped: !useBuildCache,
|
|
229
|
-
missReason,
|
|
230
|
-
durationMs,
|
|
231
|
-
appPath,
|
|
232
|
-
bundleId,
|
|
233
|
-
startedAt,
|
|
234
|
-
status: "ok",
|
|
235
|
-
configuration: configuration ?? "Debug",
|
|
236
|
-
buildMachine,
|
|
237
|
-
builtOn,
|
|
238
|
-
offloadedTo,
|
|
239
|
-
offloadFallback
|
|
240
|
-
}));
|
|
241
|
-
closeWriter();
|
|
242
|
-
const facts = iosFacts({
|
|
243
|
-
root,
|
|
244
|
-
slot,
|
|
245
|
-
udid,
|
|
246
|
-
deviceName: device?.deviceName ?? null,
|
|
247
|
-
deviceType: device?.deviceType,
|
|
248
|
-
runtime: device?.runtime,
|
|
249
|
-
fingerprint: storeHash,
|
|
250
|
-
configuration,
|
|
251
|
-
scheme: buildScheme,
|
|
252
|
-
cacheKey: storeKey,
|
|
253
|
-
cacheHit,
|
|
254
|
-
compilationCache,
|
|
255
|
-
cacheSkipped: !useBuildCache,
|
|
256
|
-
waitedForBuild,
|
|
257
|
-
appPath,
|
|
258
|
-
bundleId,
|
|
259
|
-
installSkipped,
|
|
260
|
-
metroPort,
|
|
261
|
-
logsDir,
|
|
262
|
-
durationMs,
|
|
263
|
-
launched: launchState,
|
|
264
|
-
webPreviewUrl,
|
|
265
|
-
lease,
|
|
266
|
-
devServer,
|
|
267
|
-
buildMachine,
|
|
268
|
-
builtOn,
|
|
269
|
-
offloadedTo,
|
|
270
|
-
offloadFallback
|
|
271
|
-
});
|
|
272
|
-
if (devicePlacement) facts.devicePlacement = devicePlacement;
|
|
273
|
-
if (host) facts.host = host;
|
|
274
|
-
if (json) console.log(JSON.stringify({
|
|
275
|
-
...facts,
|
|
276
|
-
...links ? { links } : {},
|
|
277
|
-
...reclaimed.length ? { reclaimed } : {}
|
|
278
|
-
}));
|
|
279
|
-
else {
|
|
280
|
-
const summary = `${launchWarning ? "WARNING" : "OK"}: ${bundleId} on ${host ? `${device.deviceName} (iOS ${device.runtime?.replace(/^iOS /, "")}) on ${host.machine}` : deviceLabel(device, udid)}, ` + (release ? `${configuration} (embedded JS, no Metro)` : `Metro port ${metroPort}`) + ` (${cacheDescription(cacheHit, providerName, offloadedTo)}, ${formatDuration(durationMs)})`;
|
|
281
|
-
const outcome = launchWarning ? chalk.yellow(`${summary} -- ${launchWarning}`) : launchState === "unverified" ? chalk.yellow(`${summary} -- launch UNVERIFIED`) : launchState === "bundling" ? chalk.green(`${summary} -- bundle requested, still building`) : chalk.green(summary);
|
|
282
|
-
const deviceName = device?.deviceName ?? device?.name ?? udid;
|
|
283
|
-
const cacheResult = useBuildCache ? cacheDescription(cacheHit, providerName, offloadedTo) : `bypassed; ${cacheDescription(false, null, offloadedTo)}`;
|
|
284
|
-
const metroResult = release ? `embedded (${configuration})` : !metroCheck ? `check skipped on port ${metroPort}` : launchState === "unverified" ? `state unverified on port ${metroPort}` : `running on port ${metroPort}${devServer ? ` (started: ${devServer.reason})` : ""}`;
|
|
285
|
-
console.log([
|
|
286
|
-
outcome,
|
|
287
|
-
phaseLine("device", host ? `${deviceName} (iOS ${device.runtime?.replace(/^iOS /, "")}) on ${host.machine}` : `${deviceName} (${udid})`),
|
|
288
|
-
phaseLine("app", bundleId),
|
|
289
|
-
phaseLine("metro", metroResult),
|
|
290
|
-
phaseLine("cache", cacheResult),
|
|
291
|
-
...compilationCache.status === "not-run" ? [phaseLine("compilation cache", compilationCacheActivityLine(compilationCache))] : [],
|
|
292
|
-
phaseLine("logs", logsDir),
|
|
293
|
-
phaseLine("agent-device", `AGENT_DEVICE_STATE_DIR=${workspaceAgentDeviceDir(root)}`)
|
|
294
|
-
].join("\n"));
|
|
295
|
-
if (facts.webPreviewUrl) console.error(chalk.dim(`Watch this device: ${facts.webPreviewUrl}`));
|
|
296
|
-
if (links) console.error(chalk.dim(workspaceLinkLine(links)));
|
|
297
|
-
}
|
|
298
|
-
return facts;
|
|
299
|
-
}
|
|
300
|
-
function cacheDescription(cacheHit, providerName = null, offloadedTo = null) {
|
|
301
|
-
if (cacheHit === "remote") return `from ${providerName || "the remote cache"}`;
|
|
302
|
-
if (cacheHit === "local") return "from cache";
|
|
303
|
-
return offloadedTo ? `built on ${offloadedTo}` : "built";
|
|
304
|
-
}
|
|
305
|
-
//#endregion
|
|
306
|
-
//#region src/commands/ios/artifact.ts
|
|
307
|
-
const GENERIC_SIM_DESTINATION = "generic/platform=iOS Simulator";
|
|
308
|
-
const IPHONEOS_SDK = "iphoneos";
|
|
309
|
-
const PROVIDER_SKIPPED_ON_DEVICE = "a device build is local-tier only: its cache key names the iphoneos slice, and a remote or provider entry is keyed for the simulator";
|
|
310
|
-
var ArtifactRefusal = class extends Error {
|
|
311
|
-
failure;
|
|
312
|
-
constructor(failure) {
|
|
313
|
-
super(failure.message ?? failure.code);
|
|
314
|
-
this.failure = failure;
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
async function acquireIosArtifact({ root, logFile, udid, remoteDestination, hostedDestination, simulatorArch, device, configuration, buildScheme, buildProfile, buildMachine = "auto", isExpo, optimizations, cache, easBuild, easProfile, maxBuilds, progress }, d) {
|
|
318
|
-
const { phase, note, logWriter, estimates, stats, step, miss, hit: lateHit, place, waitingOn, waitingFor } = progress;
|
|
319
|
-
const physical = device !== null;
|
|
320
|
-
const keyOptions = {
|
|
321
|
-
scheme: buildScheme,
|
|
322
|
-
...configuration ? { configuration } : {},
|
|
323
|
-
isSimulator: !physical,
|
|
324
|
-
...simulatorArch ? { arch: simulatorArch } : {},
|
|
325
|
-
...buildProfile ? { buildProfile } : {}
|
|
326
|
-
};
|
|
327
|
-
const providerRunOptions = iosProviderRunOptions(configuration, simulatorArch);
|
|
328
|
-
const lanAddress = device?.lanAddress ?? null;
|
|
329
|
-
const metroPort = device?.metroPort ?? null;
|
|
330
|
-
const release = isReleaseConfiguration(configuration);
|
|
331
|
-
const cachePolicy = cache.policy;
|
|
332
|
-
const useBuildCache = cachePolicy.read;
|
|
333
|
-
const cacheProviderConfig = cache.providerConfig;
|
|
334
|
-
let compilationCache = COMPILATION_CACHE_NOT_RUN;
|
|
335
|
-
function fail(failure) {
|
|
336
|
-
throw new ArtifactRefusal(failure);
|
|
337
|
-
}
|
|
338
|
-
const temporaryDirs = /* @__PURE__ */ new Set();
|
|
339
|
-
const releaseArtifact = () => {
|
|
340
|
-
for (const directory of temporaryDirs) {
|
|
341
|
-
try {
|
|
342
|
-
rmSync(directory, {
|
|
343
|
-
recursive: true,
|
|
344
|
-
force: true
|
|
345
|
-
});
|
|
346
|
-
} catch {}
|
|
347
|
-
temporaryDirs.delete(directory);
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
let buildLock = null;
|
|
351
|
-
const releaseLock = () => {
|
|
352
|
-
if (!buildLock) return;
|
|
353
|
-
const held = buildLock;
|
|
354
|
-
buildLock = null;
|
|
355
|
-
try {
|
|
356
|
-
d.releaseBuildLock(held);
|
|
357
|
-
} catch (e) {
|
|
358
|
-
note(chalk.dim(`Could not release the build lock at ${held.path}: ${e?.message || e}`));
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
let buildSlot = null;
|
|
362
|
-
const releaseSlot = () => {
|
|
363
|
-
if (!buildSlot) return;
|
|
364
|
-
const held = buildSlot;
|
|
365
|
-
buildSlot = null;
|
|
366
|
-
try {
|
|
367
|
-
d.releaseBuildSlot(held);
|
|
368
|
-
} catch (e) {
|
|
369
|
-
note(chalk.dim(`Could not release the build slot: ${e?.message || e}`));
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
let fingerprint = "";
|
|
373
|
-
let fingerprintSources = [];
|
|
374
|
-
let cacheKey = "";
|
|
375
|
-
let storeHash = null;
|
|
376
|
-
let storeKey = null;
|
|
377
|
-
let storeSources = [];
|
|
378
|
-
let appPath = null;
|
|
379
|
-
let bundleId = null;
|
|
380
|
-
let cacheHit = false;
|
|
381
|
-
let offloadedTo = null;
|
|
382
|
-
let handoff = null;
|
|
383
|
-
let offloadFallback = null;
|
|
384
|
-
let fallbackMachine = null;
|
|
385
|
-
let hereReason = "no remote Mac is paired";
|
|
386
|
-
let slotWaitMs;
|
|
387
|
-
let builtOn;
|
|
388
|
-
const fallBack = (reason, line = reason) => {
|
|
389
|
-
if (namedBuildMachine(buildMachine)) throw new OffloadRefusal(buildMachine, reason);
|
|
390
|
-
offloadFallback = reason;
|
|
391
|
-
buildFailure = {
|
|
392
|
-
...buildFailure,
|
|
393
|
-
offloadFallback: reason
|
|
394
|
-
};
|
|
395
|
-
phase("build", `${line} -> building here`);
|
|
396
|
-
};
|
|
397
|
-
const openOffload = { choice: null };
|
|
398
|
-
let remote = null;
|
|
399
|
-
let abandonedRemote = false;
|
|
400
|
-
let uploadPending = null;
|
|
401
|
-
let providerUpload = null;
|
|
402
|
-
let providerName = null;
|
|
403
|
-
let providerLoad = null;
|
|
404
|
-
const cacheWarn = createWarnOnce((line) => note(chalk.yellow(phaseLine("cache", line))));
|
|
405
|
-
const loadProvider = cachePolicy.remote && cacheProviderConfig && !physical ? () => providerLoad ??= d.loadCacheProvider({
|
|
406
|
-
projectRoot: root,
|
|
407
|
-
config: cacheProviderConfig
|
|
408
|
-
}) : null;
|
|
409
|
-
if (cacheProviderConfig && physical) note(chalk.dim(phaseLine("cache", PROVIDER_SKIPPED_ON_DEVICE)));
|
|
410
|
-
let waitedForBuild = null;
|
|
411
|
-
let releasedWait = null;
|
|
412
|
-
let swapFellBack = false;
|
|
413
|
-
let buildFailure = {};
|
|
414
|
-
let missReason = null;
|
|
415
|
-
async function resolveInitialFingerprint() {
|
|
416
|
-
if (easBuild?.ok) {
|
|
417
|
-
fingerprint = storeHash = easBuild.fingerprint;
|
|
418
|
-
cacheKey = storeKey = easBuild.cacheKey;
|
|
419
|
-
appPath = easBuild.path;
|
|
420
|
-
cacheHit = easBuild.cacheHit;
|
|
421
|
-
providerName = "eas";
|
|
422
|
-
stats.setCacheKey(cacheKey);
|
|
423
|
-
if (physical) {
|
|
424
|
-
const gate = d.gateProfileForDevice({
|
|
425
|
-
appPath,
|
|
426
|
-
udid,
|
|
427
|
-
configuration
|
|
428
|
-
});
|
|
429
|
-
if (!gate.ok) fail({
|
|
430
|
-
code: gate.code,
|
|
431
|
-
message: gate.reason,
|
|
432
|
-
remedy: easDeviceBuildRemedy(easProfile)
|
|
433
|
-
});
|
|
434
|
-
if (!d.devClientScheme(root, appPath)) fail({
|
|
435
|
-
code: "STIM_BAD_ARG",
|
|
436
|
-
message: "The EAS device app has no development-client URL scheme.",
|
|
437
|
-
remedy: "Install expo-dev-client with npx expo install expo-dev-client, then rebuild the EAS profile and retry."
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (useBuildCache) step("cache-lookup");
|
|
443
|
-
const fingerprintTimer = stepTimer(d.now);
|
|
444
|
-
let computedFingerprint;
|
|
445
|
-
let fingerprintError = "no hash";
|
|
446
|
-
try {
|
|
447
|
-
const computed = await d.fingerprintProject(root, { platform: "ios" });
|
|
448
|
-
computedFingerprint = computed?.hash ?? null;
|
|
449
|
-
fingerprintSources = computed?.sources ?? [];
|
|
450
|
-
} catch (e) {
|
|
451
|
-
computedFingerprint = null;
|
|
452
|
-
fingerprintError = String(e?.message || e);
|
|
453
|
-
note(chalk.dim(`Fingerprinting failed: ${fingerprintError}`));
|
|
454
|
-
}
|
|
455
|
-
if (!computedFingerprint) fail({
|
|
456
|
-
code: "STIM_NO_FINGERPRINT",
|
|
457
|
-
message: `Could not fingerprint ${root}: @expo/fingerprint produced no hash for it.`,
|
|
458
|
-
remedy: "Check the project native inputs and the @expo/fingerprint error above, then retry.",
|
|
459
|
-
build: {
|
|
460
|
-
cacheSkipped: !useBuildCache,
|
|
461
|
-
missReason: fingerprintErrorMissReason(fingerprintError)
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
fingerprint = computedFingerprint;
|
|
465
|
-
cacheKey = buildCacheKey("ios", fingerprint, keyOptions);
|
|
466
|
-
stats.setCacheKey(cacheKey);
|
|
467
|
-
storeHash = fingerprint;
|
|
468
|
-
storeKey = cacheKey;
|
|
469
|
-
storeSources = fingerprintSources;
|
|
470
|
-
const found = await resolveTieredBuild({
|
|
471
|
-
local: filesystemBuildCapability({
|
|
472
|
-
resolve: d.resolveBuild,
|
|
473
|
-
store: d.storeBuild,
|
|
474
|
-
sources: fingerprintSources
|
|
475
|
-
}),
|
|
476
|
-
loadProvider,
|
|
477
|
-
target: {
|
|
478
|
-
projectRoot: root,
|
|
479
|
-
platform: "ios",
|
|
480
|
-
key: cacheKey
|
|
481
|
-
},
|
|
482
|
-
destinationDir: providerDownloadPath(workspaceDir(root)),
|
|
483
|
-
ensureDestination: prepareProviderDownloadDir,
|
|
484
|
-
skipRead: !useBuildCache,
|
|
485
|
-
warn: cacheWarn
|
|
486
|
-
});
|
|
487
|
-
const cached = found?.tier === "local" ? found.path : null;
|
|
488
|
-
cacheHit = cached ? "local" : false;
|
|
489
|
-
phase("fingerprint", `${shortHash(fingerprint)} ${cached ? "hit" : "miss"}${useBuildCache ? "" : cache.disabledByFlag ? " (--no-build-cache)" : " (cache reuse off in config)"} ${fingerprintTimer()}`);
|
|
490
|
-
if (found?.tier === "provider") {
|
|
491
|
-
cacheHit = "remote";
|
|
492
|
-
providerName = found.providerName ?? null;
|
|
493
|
-
phase("cache", `provider hit (${providerName})${found.storedLocally ? " -> stored locally" : ""}`);
|
|
494
|
-
}
|
|
495
|
-
appPath = found?.path ?? null;
|
|
496
|
-
}
|
|
497
|
-
async function resolveRemoteArtifact() {
|
|
498
|
-
if (physical || !cachePolicy.remote || buildProfile || buildScheme) return null;
|
|
499
|
-
if (!appPath) {
|
|
500
|
-
const loaded = await d.loadProjectProvider(root, { isExpo });
|
|
501
|
-
if (loaded?.unavailable) note(chalk.yellow(phaseLine("cache", `provider not usable: ${loaded.unavailable}`)));
|
|
502
|
-
else if (loaded?.provider) remote = loaded;
|
|
503
|
-
if (remote?.name === "eas") {
|
|
504
|
-
const auth = d.checkEasAuth({
|
|
505
|
-
projectRoot: root,
|
|
506
|
-
owner: loaded?.owner || null
|
|
507
|
-
});
|
|
508
|
-
const authNote = easAuthNote(auth);
|
|
509
|
-
if (authNote) note(chalk.yellow(phaseLine("cache", authNote)));
|
|
510
|
-
if (auth?.code === "logged-out") remote = null;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
if (remote && useBuildCache) {
|
|
514
|
-
const remoteTimer = stepTimer(d.now);
|
|
515
|
-
const hit = await d.resolveRemote({
|
|
516
|
-
logWriter: logWriter(),
|
|
517
|
-
provider: remote.provider,
|
|
518
|
-
platform: "ios",
|
|
519
|
-
projectRoot: root,
|
|
520
|
-
fingerprintHash: fingerprint,
|
|
521
|
-
runOptions: providerRunOptions
|
|
522
|
-
});
|
|
523
|
-
if (hit?.appPath) {
|
|
524
|
-
let stored = null;
|
|
525
|
-
try {
|
|
526
|
-
stored = d.storeBuild("ios", cacheKey, hit.appPath, { sources: fingerprintSources });
|
|
527
|
-
} catch (e) {
|
|
528
|
-
note(chalk.yellow(phaseLine("cache", `remote hit could not be stored locally: ${e?.message || e}`)));
|
|
529
|
-
}
|
|
530
|
-
appPath = stored || hit.appPath;
|
|
531
|
-
cacheHit = "remote";
|
|
532
|
-
phase("cache", `remote hit (${remote.name})${stored ? " -> stored locally" : ""} ${remoteTimer()}`);
|
|
533
|
-
} else if (hit?.timedOut) {
|
|
534
|
-
abandonedRemote = true;
|
|
535
|
-
note(chalk.yellow(phaseLine("cache", `${remote.name} did not answer within ${formatDuration(RESOLVE_TIMEOUT_MS)}; building instead`)));
|
|
536
|
-
} else if (hit?.failed) {
|
|
537
|
-
const authNote = remote.name === "eas" && isEasAuthFailureText(hit.failed) ? easAuthNote({
|
|
538
|
-
code: "logged-out",
|
|
539
|
-
reason: hit.failed
|
|
540
|
-
}) : null;
|
|
541
|
-
note(chalk.yellow(phaseLine("cache", authNote || `${remote.name} could not be used: ${hit.failed}; building instead`)));
|
|
542
|
-
} else phase("cache", `remote miss (${remote.name}) ${remoteTimer()}`);
|
|
543
|
-
}
|
|
544
|
-
return remote;
|
|
545
|
-
}
|
|
546
|
-
async function awaitSharedBuild() {
|
|
547
|
-
if (!useBuildCache || appPath) return;
|
|
548
|
-
const shared = await waitForSharedBuild({
|
|
549
|
-
platform: "ios",
|
|
550
|
-
key: cacheKey,
|
|
551
|
-
fingerprint,
|
|
552
|
-
root,
|
|
553
|
-
logFile,
|
|
554
|
-
command: "stim ios",
|
|
555
|
-
acquire: d.acquireBuildLock,
|
|
556
|
-
wait: d.waitForBuild,
|
|
557
|
-
now: d.now,
|
|
558
|
-
phase: (text) => {
|
|
559
|
-
step("wait");
|
|
560
|
-
phase("build", text);
|
|
561
|
-
},
|
|
562
|
-
waitingOn,
|
|
563
|
-
warn: (text) => note(chalk.yellow(phaseLine("build", text))),
|
|
564
|
-
out: note
|
|
565
|
-
});
|
|
566
|
-
if (shared.refusal) fail({
|
|
567
|
-
...shared.refusal,
|
|
568
|
-
build: {
|
|
569
|
-
fingerprint,
|
|
570
|
-
cacheKey,
|
|
571
|
-
cacheHit,
|
|
572
|
-
cacheSkipped: !useBuildCache
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
buildLock = shared.lock;
|
|
576
|
-
releasedWait = shared.released;
|
|
577
|
-
if (shared.hit) {
|
|
578
|
-
appPath = shared.hit.path;
|
|
579
|
-
cacheHit = "local";
|
|
580
|
-
waitedForBuild = shared.hit.waited;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
const prepareDeviceApp = async (path, { fresh }) => {
|
|
584
|
-
const refuse = (code, reason, remedy) => {
|
|
585
|
-
if (fresh) fail({
|
|
586
|
-
code,
|
|
587
|
-
message: reason,
|
|
588
|
-
remedy,
|
|
589
|
-
build: {
|
|
590
|
-
...buildFailure,
|
|
591
|
-
appPath: path
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
note(chalk.yellow(phaseLine("cache", `${reason} -- building fresh instead`)));
|
|
595
|
-
note(chalk.dim(phaseLine("", remedy)));
|
|
596
|
-
swapFellBack = true;
|
|
597
|
-
return null;
|
|
598
|
-
};
|
|
599
|
-
const gateProfile = () => {
|
|
600
|
-
const gate = d.gateProfileForDevice({
|
|
601
|
-
appPath: path,
|
|
602
|
-
udid,
|
|
603
|
-
configuration
|
|
604
|
-
});
|
|
605
|
-
return gate.ok ? path : refuse(gate.code, gate.reason, gate.remedy);
|
|
606
|
-
};
|
|
607
|
-
if (release) {
|
|
608
|
-
if (!fresh) {
|
|
609
|
-
note(chalk.yellow(phaseLine("cache", `a cached ${configuration} device app carries its builder's JS, and the device JS swap lands with phase 6 of appandflow/stim#178 -- building fresh instead, which bakes in this workspace's JS`)));
|
|
610
|
-
swapFellBack = true;
|
|
611
|
-
return null;
|
|
612
|
-
}
|
|
613
|
-
return gateProfile();
|
|
614
|
-
}
|
|
615
|
-
if (d.devClientScheme(root, path)) return gateProfile();
|
|
616
|
-
let copy;
|
|
617
|
-
try {
|
|
618
|
-
copy = copyAppAside(path);
|
|
619
|
-
} catch (e) {
|
|
620
|
-
return refuse("STIM_INSTALL_FAILED", `Could not copy ${path} aside to write its ip.txt: ${e?.message || e}`, "Free space in the temporary directory and run the command again.");
|
|
621
|
-
}
|
|
622
|
-
temporaryDirs.add(copy.tmpDir);
|
|
623
|
-
writeIpTxt(copy.appPath, lanAddress, metroPort);
|
|
624
|
-
const sealed = d.sealAppForDevice({
|
|
625
|
-
appPath: copy.appPath,
|
|
626
|
-
udid,
|
|
627
|
-
configuration,
|
|
628
|
-
pinnedName: device?.signingName ?? null,
|
|
629
|
-
pinnedSha1: device?.signingSha1 ?? null
|
|
630
|
-
});
|
|
631
|
-
if (!sealed.ok) {
|
|
632
|
-
try {
|
|
633
|
-
rmSync(copy.tmpDir, {
|
|
634
|
-
recursive: true,
|
|
635
|
-
force: true
|
|
636
|
-
});
|
|
637
|
-
} catch {}
|
|
638
|
-
for (const line of sealed.lastLines ?? []) note(chalk.dim(phaseLine("", line)));
|
|
639
|
-
return refuse(sealed.code, sealed.reason, sealed.remedy);
|
|
640
|
-
}
|
|
641
|
-
phase("ip.txt", `${lanAddress}:${metroPort} written into the install copy and re-sealed with "${sealed.identity.name}"${sealed.mode === "preserve-metadata" ? "" : ` (${sealed.mode})`}`);
|
|
642
|
-
return copy.appPath;
|
|
643
|
-
};
|
|
644
|
-
const installableCachedApp = async (cachedPath) => {
|
|
645
|
-
if (physical) return prepareDeviceApp(cachedPath, { fresh: false });
|
|
646
|
-
if (!release) return cachedPath;
|
|
647
|
-
phase("swap", `regenerating this workspace's JS for the cached ${configuration} app`);
|
|
648
|
-
const swap = await d.swapJsBundle({
|
|
649
|
-
root,
|
|
650
|
-
isExpo,
|
|
651
|
-
cachedAppPath: cachedPath,
|
|
652
|
-
logWriter: logWriter()
|
|
653
|
-
});
|
|
654
|
-
if (swap?.ok && swap.appPath) {
|
|
655
|
-
if (swap.note) note(chalk.yellow(phaseLine("swap", swap.note)));
|
|
656
|
-
if (swap.tmpDir) temporaryDirs.add(swap.tmpDir);
|
|
657
|
-
phase("swap", `${swap.hermes ? "hermes bytecode" : "plain JS"} + assets replaced, re-signed (${formatDuration(swap.durationMs ?? 0)})`);
|
|
658
|
-
return swap.appPath;
|
|
659
|
-
}
|
|
660
|
-
note(chalk.yellow(phaseLine("swap", `failed at ${swap?.step || "unknown step"}: ${swap?.reason || "unknown reason"} -- building fresh instead (a cached ${configuration} app carries its builder's JS; it is never installed after a failed swap)`)));
|
|
661
|
-
for (const line of swap?.lastLines ?? []) note(chalk.dim(phaseLine("", line)));
|
|
662
|
-
swapFellBack = true;
|
|
663
|
-
return null;
|
|
664
|
-
};
|
|
665
|
-
async function prepareCachedArtifact() {
|
|
666
|
-
if (appPath && cacheHit) {
|
|
667
|
-
const prepared = await installableCachedApp(appPath);
|
|
668
|
-
appPath = prepared;
|
|
669
|
-
if (!prepared) {
|
|
670
|
-
cacheHit = false;
|
|
671
|
-
waitedForBuild = null;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
function reasonForMiss(rekeyedBy) {
|
|
676
|
-
if (swapFellBack) return {
|
|
677
|
-
reason: skippedMissReason("the cached app could not be reused, so this run built it fresh"),
|
|
678
|
-
diff: null
|
|
679
|
-
};
|
|
680
|
-
if (!useBuildCache) return {
|
|
681
|
-
reason: skippedMissReason(cache.disabledByFlag ? "cache reuse turned off by --no-build-cache" : "cache reuse off in config"),
|
|
682
|
-
diff: null
|
|
683
|
-
};
|
|
684
|
-
const current = {
|
|
685
|
-
hash: storeHash ?? fingerprint,
|
|
686
|
-
sources: storeSources
|
|
687
|
-
};
|
|
688
|
-
const explained = explainBuildMiss({
|
|
689
|
-
root,
|
|
690
|
-
platform: "ios",
|
|
691
|
-
current,
|
|
692
|
-
rekeyedBy,
|
|
693
|
-
baselineDeps: { readState: d.readWorkspaceState }
|
|
694
|
-
});
|
|
695
|
-
return {
|
|
696
|
-
reason: explained.reason,
|
|
697
|
-
diff: explained.previousHash && explained.changedNames.length ? fingerprintDiffRecord({
|
|
698
|
-
changed: explained.changedNames,
|
|
699
|
-
previousHash: explained.previousHash,
|
|
700
|
-
hash: current.hash
|
|
701
|
-
}) : null
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
function reportPendingRecheck(prebuild) {
|
|
705
|
-
const pods = d.readPodState(root);
|
|
706
|
-
if ((prebuild === "generate" || prebuild === "regenerate" || podAction(pods, d.podsAreStale(pods.lockText, pods.manifestText)).install) && useBuildCache) miss(reasonForMiss([]).reason, true);
|
|
707
|
-
}
|
|
708
|
-
function explainMiss(rekeyedBy) {
|
|
709
|
-
const explained = reasonForMiss(rekeyedBy);
|
|
710
|
-
missReason = explained.reason;
|
|
711
|
-
if (explained.diff) logWriter().write(explained.diff);
|
|
712
|
-
buildFailure = {
|
|
713
|
-
...buildFailure,
|
|
714
|
-
missReason
|
|
715
|
-
};
|
|
716
|
-
miss(missReason);
|
|
717
|
-
phase("cache", `miss: ${missReason.summary}`);
|
|
718
|
-
if (missReason.kind === "no-baseline") {
|
|
719
|
-
const untracked = untrackedMissLine(d.untrackedNativeFiles({ projectRoot: root }));
|
|
720
|
-
if (untracked) note(chalk.dim(phaseLine("fingerprint", untracked)));
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
async function settleStoreKeyAfterCompile(prebuildRan) {
|
|
724
|
-
if (!storeHash || !storeKey) return;
|
|
725
|
-
const afterBuild = await refingerprintAfterMutation({
|
|
726
|
-
projectRoot: root,
|
|
727
|
-
platform: "ios",
|
|
728
|
-
previousHash: storeHash,
|
|
729
|
-
fingerprint: d.fingerprintProject
|
|
730
|
-
});
|
|
731
|
-
const changedDuringBuild = afterBuild ? inputsChangedDuringBuild({
|
|
732
|
-
platform: "ios",
|
|
733
|
-
lookup: fingerprintSources,
|
|
734
|
-
prebuildRan,
|
|
735
|
-
compiled: storeSources,
|
|
736
|
-
current: afterBuild.sources
|
|
737
|
-
}) : [];
|
|
738
|
-
if (!afterBuild || changedDuringBuild.length) {
|
|
739
|
-
storeHash = null;
|
|
740
|
-
storeKey = null;
|
|
741
|
-
buildFailure = {
|
|
742
|
-
...buildFailure,
|
|
743
|
-
fingerprint: null,
|
|
744
|
-
cacheKey: null
|
|
745
|
-
};
|
|
746
|
-
note(chalk.yellow(phaseLine("fingerprint", afterBuild ? changedDuringBuildLine(changedDuringBuild) : "unavailable after xcodebuild; the build will be installed but not cached")));
|
|
747
|
-
} else if (afterBuild.moved) {
|
|
748
|
-
const beforeBuildHash = storeHash;
|
|
749
|
-
storeHash = afterBuild.hash;
|
|
750
|
-
storeSources = afterBuild.sources;
|
|
751
|
-
storeKey = buildCacheKey("ios", afterBuild.hash, keyOptions);
|
|
752
|
-
buildFailure = {
|
|
753
|
-
...buildFailure,
|
|
754
|
-
fingerprint: storeHash,
|
|
755
|
-
cacheKey: storeKey
|
|
756
|
-
};
|
|
757
|
-
note(chalk.dim(phaseLine("fingerprint", `${shortHash(beforeBuildHash)} -> ${shortHash(storeHash)} (after xcodebuild)`)));
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
async function takeBuildSlot() {
|
|
761
|
-
if (!maxBuilds) return;
|
|
762
|
-
try {
|
|
763
|
-
buildSlot = await d.acquireBuildSlot({
|
|
764
|
-
max: maxBuilds,
|
|
765
|
-
root,
|
|
766
|
-
logFile,
|
|
767
|
-
out: note,
|
|
768
|
-
waitingFor: (info) => waitingFor?.(info, "build-slot")
|
|
769
|
-
});
|
|
770
|
-
slotWaitMs = buildSlot.slotWaitMs;
|
|
771
|
-
} catch (e) {
|
|
772
|
-
const refusal = (0, ownership_claim_exports.claimFailure)(e, "stim ios");
|
|
773
|
-
if (refusal) fail({
|
|
774
|
-
code: refusal.code,
|
|
775
|
-
message: refusal.message,
|
|
776
|
-
remedy: refusal.remedy,
|
|
777
|
-
build: buildFailure
|
|
778
|
-
});
|
|
779
|
-
note(chalk.yellow(phaseLine("build", `could not take a build slot: ${e?.message || e}; building anyway`)));
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
/** Whether this build should leave this Mac, before any machine is asked; null builds here. */
|
|
783
|
-
function placeBuild() {
|
|
784
|
-
const { mode, machines } = buildPlacementCandidates(buildMachine);
|
|
785
|
-
if (machines.length === 0 && !namedBuildMachine(buildMachine) && buildMachine !== "local") return null;
|
|
786
|
-
const runtime = physical || release ? null : hostedDestination?.runtime ?? (remoteDestination ? null : simulatorRuntime(udid));
|
|
787
|
-
const unsupported = physical ? "device builds build here" : remoteDestination && !hostedDestination ? "--remote builds build here" : release ? `${configuration} builds build here` : !cachePolicy.write ? "the build cache is off" : !runtime ? `the runtime of simulator ${udid} is unknown` : null;
|
|
788
|
-
const here = machineCapacity();
|
|
789
|
-
const placement = offloadPlacement({
|
|
790
|
-
mode,
|
|
791
|
-
machines: machines.length,
|
|
792
|
-
here,
|
|
793
|
-
unsupported,
|
|
794
|
-
selected: buildMachine
|
|
795
|
-
});
|
|
796
|
-
if (!placement.offload) {
|
|
797
|
-
hereReason = placement.reason;
|
|
798
|
-
if (mode !== "off") phase("build", `placement: here (${placement.reason})`);
|
|
799
|
-
return null;
|
|
800
|
-
}
|
|
801
|
-
return {
|
|
802
|
-
mode,
|
|
803
|
-
here,
|
|
804
|
-
reason: placement.reason,
|
|
805
|
-
runtime,
|
|
806
|
-
machines
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
/** Asks the paired machines once the post-mutation key is known; null builds here. */
|
|
810
|
-
async function chooseMachine(candidate) {
|
|
811
|
-
const choice = await chooseBuildMachine({
|
|
812
|
-
projectRoot: root,
|
|
813
|
-
target: {
|
|
814
|
-
platform: "ios",
|
|
815
|
-
local: {
|
|
816
|
-
...iosToolchain(),
|
|
817
|
-
...hostedDestination ? { arch: hostedDestination.architecture === "x86_64" ? "x64" : "arm64" } : {}
|
|
818
|
-
},
|
|
819
|
-
runtime: candidate.runtime,
|
|
820
|
-
cocoapodsPinned: bundlerPin(root) !== null
|
|
821
|
-
},
|
|
822
|
-
mode: candidate.mode,
|
|
823
|
-
here: candidate.here,
|
|
824
|
-
note: (line) => note(chalk.dim(phaseLine("build", `offload: ${line}`))),
|
|
825
|
-
machines: candidate.machines,
|
|
826
|
-
selected: buildMachine
|
|
827
|
-
});
|
|
828
|
-
if (typeof choice === "string") {
|
|
829
|
-
const only = candidate.machines.length === 1 ? candidate.machines[0].machine : null;
|
|
830
|
-
if (only && choice.startsWith(`${only}: `)) fallbackMachine = only;
|
|
831
|
-
fallBack(choice);
|
|
832
|
-
return null;
|
|
833
|
-
}
|
|
834
|
-
openOffload.choice = choice;
|
|
835
|
-
phase("build", `placement: ${choice.machine} (${candidate.reason}${placementLoad(choice)})`);
|
|
836
|
-
return choice;
|
|
837
|
-
}
|
|
838
|
-
/** Builds on the chosen machine and stores the app under the post-mutation key; false builds here instead unless a machine was named. */
|
|
839
|
-
async function compileElsewhere({ choice, candidate }) {
|
|
840
|
-
const runtime = candidate.runtime;
|
|
841
|
-
if (!storeKey || !storeHash) {
|
|
842
|
-
if (namedBuildMachine(buildMachine)) fallBack("the build fingerprint or cache key is unavailable");
|
|
843
|
-
return false;
|
|
844
|
-
}
|
|
845
|
-
const stagingDir = join(workspaceDir(root), "offload", "ios");
|
|
846
|
-
const outcome = await offloadBuild({
|
|
847
|
-
choice,
|
|
848
|
-
expectedFingerprint: storeHash,
|
|
849
|
-
request: {
|
|
850
|
-
platform: "ios",
|
|
851
|
-
runtime,
|
|
852
|
-
configuration,
|
|
853
|
-
scheme: buildScheme ?? null,
|
|
854
|
-
isExpo,
|
|
855
|
-
optimizations
|
|
856
|
-
},
|
|
857
|
-
stagingDir,
|
|
858
|
-
onPhase: (name, msg) => phase(name, remotePhaseText(name, msg, choice.machine)),
|
|
859
|
-
onEnter: (name) => {
|
|
860
|
-
if (name === "compile" || name === "build" || name === "prebuild" || name === "pods") {
|
|
861
|
-
builtOn = choice.machine;
|
|
862
|
-
buildFailure = {
|
|
863
|
-
...buildFailure,
|
|
864
|
-
builtOn
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
place({
|
|
868
|
-
host: choice.machine,
|
|
869
|
-
phase: name
|
|
870
|
-
});
|
|
871
|
-
step(name === "prebuild" || name === "pods" ? name : "compile");
|
|
872
|
-
},
|
|
873
|
-
onRecord: (record) => logWriter().write({
|
|
874
|
-
...record,
|
|
875
|
-
offloadedTo: choice.machine
|
|
876
|
-
}),
|
|
877
|
-
note: (line) => phase("build", line)
|
|
878
|
-
});
|
|
879
|
-
place(null);
|
|
880
|
-
let stored = null;
|
|
881
|
-
let reason = outcome.ok ? null : outcome.reason;
|
|
882
|
-
if (outcome.ok) {
|
|
883
|
-
const settled = await refingerprintAfterMutation({
|
|
884
|
-
projectRoot: root,
|
|
885
|
-
platform: "ios",
|
|
886
|
-
previousHash: storeHash,
|
|
887
|
-
fingerprint: d.fingerprintProject
|
|
888
|
-
});
|
|
889
|
-
if (!settled || settled.moved) reason = "the checkout here changed while it built";
|
|
890
|
-
else try {
|
|
891
|
-
stored = d.storeBuild("ios", storeKey, outcome.artifactPath, {
|
|
892
|
-
sources: storeSources,
|
|
893
|
-
overwrite: !useBuildCache
|
|
894
|
-
});
|
|
895
|
-
} catch (e) {
|
|
896
|
-
reason = `could not store the app: ${e?.message || e}`;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
try {
|
|
900
|
-
rmSync(stagingDir, {
|
|
901
|
-
recursive: true,
|
|
902
|
-
force: true
|
|
903
|
-
});
|
|
904
|
-
} catch {}
|
|
905
|
-
step("compile");
|
|
906
|
-
const prepared = stored ? await installableCachedApp(stored) : null;
|
|
907
|
-
if (!outcome.ok || !prepared) {
|
|
908
|
-
const why = reason ?? "the stored app is not installable";
|
|
909
|
-
fallbackMachine = choice.machine;
|
|
910
|
-
fallBack(`${choice.machine}: ${why}`, `offload failed: ${why}`);
|
|
911
|
-
logWriter().write({
|
|
912
|
-
src: "build",
|
|
913
|
-
level: "warn",
|
|
914
|
-
event: "offload_failed",
|
|
915
|
-
msg: reason,
|
|
916
|
-
machine: choice.machine
|
|
917
|
-
});
|
|
918
|
-
return false;
|
|
919
|
-
}
|
|
920
|
-
const { timings } = outcome;
|
|
921
|
-
appPath = prepared;
|
|
922
|
-
builtOn = outcome.machine;
|
|
923
|
-
offloadedTo = outcome.machine;
|
|
924
|
-
handoff = outcome.handoff ?? null;
|
|
925
|
-
stats.setPlacement({
|
|
926
|
-
decision: "offloaded",
|
|
927
|
-
machine: outcome.machine,
|
|
928
|
-
reason: `${candidate.reason}${placementLoad(choice)}`,
|
|
929
|
-
buildMs: timings.totalMs
|
|
930
|
-
});
|
|
931
|
-
phase("build", `built on ${outcome.machine} in ${formatDuration(timings.totalMs)}: offer ${formatDuration(timings.offerMs)}, sync ${formatDuration(timings.syncMs)}, build ${formatDuration(timings.workerMs)}, fetch ${formatDuration(timings.fetchMs)}`);
|
|
932
|
-
compilationCache = outcome.compilationCache;
|
|
933
|
-
phase("cache", `compilation cache on ${outcome.machine} ${compilationCacheActivityLine(compilationCache)}`);
|
|
934
|
-
logWriter().write({
|
|
935
|
-
src: "build",
|
|
936
|
-
level: "info",
|
|
937
|
-
event: "offload_done",
|
|
938
|
-
msg: `built on ${outcome.machine}`,
|
|
939
|
-
timings
|
|
940
|
-
});
|
|
941
|
-
return true;
|
|
942
|
-
}
|
|
943
|
-
async function buildArtifact() {
|
|
944
|
-
buildFailure = {
|
|
945
|
-
fingerprint,
|
|
946
|
-
cacheKey,
|
|
947
|
-
cacheHit,
|
|
948
|
-
cacheSkipped: !useBuildCache,
|
|
949
|
-
buildMachine
|
|
950
|
-
};
|
|
951
|
-
if (!appPath) {
|
|
952
|
-
const offload = placeBuild();
|
|
953
|
-
if (!offload) await takeBuildSlot();
|
|
954
|
-
const mutatingSteps = [];
|
|
955
|
-
const rekeyedBy = [];
|
|
956
|
-
const prebuild = d.planPrebuild(root, "ios", {
|
|
957
|
-
isExpo,
|
|
958
|
-
fingerprint,
|
|
959
|
-
sources: fingerprintSources
|
|
960
|
-
});
|
|
961
|
-
if (prebuild === "refuse") fail({
|
|
962
|
-
...staleNativeDirRefusal("ios"),
|
|
963
|
-
build: buildFailure
|
|
964
|
-
});
|
|
965
|
-
reportPendingRecheck(prebuild);
|
|
966
|
-
if (prebuild === "generate" || prebuild === "regenerate") {
|
|
967
|
-
step("prebuild");
|
|
968
|
-
recordPrebuild(root, "ios", null);
|
|
969
|
-
const result = await d.runPrebuild(root, "ios", logWriter(), { clean: prebuild === "regenerate" });
|
|
970
|
-
if (result?.failed) {
|
|
971
|
-
phase("prebuild", "FAILED");
|
|
972
|
-
fail({
|
|
973
|
-
code: result.code || "STIM_PREBUILD_FAILED",
|
|
974
|
-
message: result.reason || "expo prebuild failed.",
|
|
975
|
-
remedy: result.remedy || `See ${logFile} for the transcript.`,
|
|
976
|
-
lines: (result.lastLines || []).slice(-5),
|
|
977
|
-
build: buildFailure
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
phase("prebuild", `${prebuild === "generate" ? "ios/ absent -> generated" : "ios/ not generated from this fingerprint -> regenerated with --clean"} (${formatDuration(result?.durationMs ?? 0)})`);
|
|
981
|
-
mutatingSteps.push("prebuild");
|
|
982
|
-
}
|
|
983
|
-
if (isExpo && buildScheme !== void 0) {
|
|
984
|
-
const project = d.discoverXcodeProject(root);
|
|
985
|
-
if (project.error) fail({
|
|
986
|
-
...project.error,
|
|
987
|
-
build: buildFailure
|
|
988
|
-
});
|
|
989
|
-
const schemeError = d.resolveScheme(project, { scheme: buildScheme }).error;
|
|
990
|
-
if (schemeError) fail({
|
|
991
|
-
...schemeError,
|
|
992
|
-
build: buildFailure
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
const podState = d.readPodState(root);
|
|
996
|
-
const verdict = d.podsAreStale(podState.lockText, podState.manifestText);
|
|
997
|
-
const action = podAction(podState, verdict);
|
|
998
|
-
if (action.install) {
|
|
999
|
-
step("pods");
|
|
1000
|
-
const result = await d.runPodInstall(root, logWriter(), { estimateMs: estimates().podsMs });
|
|
1001
|
-
const podCommand = result?.command || "pod install";
|
|
1002
|
-
for (const line of result?.notes || []) note(chalk.dim(phaseLine("pods", line)));
|
|
1003
|
-
if (result?.failed) {
|
|
1004
|
-
phase("pods", "FAILED");
|
|
1005
|
-
fail({
|
|
1006
|
-
code: result.code || "STIM_DEPS_FAILED",
|
|
1007
|
-
message: result.reason || "`pod install` failed.",
|
|
1008
|
-
remedy: result.remedy || `See ${logFile} for the transcript.`,
|
|
1009
|
-
lines: result.diagnosticLines?.length ? result.diagnosticLines : (result.lastLines || []).slice(-5),
|
|
1010
|
-
build: buildFailure
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
stats.setPodsMs(result?.durationMs ?? 0);
|
|
1014
|
-
phase("pods", `${action.reason} -> installed with \`${podCommand}\` (${formatDuration(result?.durationMs ?? 0)})`);
|
|
1015
|
-
mutatingSteps.push(podCommand);
|
|
1016
|
-
}
|
|
1017
|
-
if (mutatingSteps.length) {
|
|
1018
|
-
const after = await refingerprintAfterMutation({
|
|
1019
|
-
projectRoot: root,
|
|
1020
|
-
platform: "ios",
|
|
1021
|
-
previousHash: fingerprint,
|
|
1022
|
-
fingerprint: d.fingerprintProject
|
|
1023
|
-
});
|
|
1024
|
-
const prebuildRan = mutatingSteps.includes("prebuild");
|
|
1025
|
-
const editedConfig = after ? configInputsChanged(fingerprintSources, after.sources, { prebuildRan }) : [];
|
|
1026
|
-
if (after && !editedConfig.length && prebuildRan) recordPrebuild(root, "ios", after.hash);
|
|
1027
|
-
if (!after || editedConfig.length) {
|
|
1028
|
-
storeHash = null;
|
|
1029
|
-
storeKey = null;
|
|
1030
|
-
buildFailure = {
|
|
1031
|
-
...buildFailure,
|
|
1032
|
-
fingerprint: null,
|
|
1033
|
-
cacheKey: null
|
|
1034
|
-
};
|
|
1035
|
-
note(chalk.yellow(phaseLine("fingerprint", after ? changedDuringBuildLine(editedConfig) : `unavailable after ${mutatingSteps.join(", ")}; the build will be installed but not cached`)));
|
|
1036
|
-
} else if (after.moved) {
|
|
1037
|
-
rekeyedBy.push(...mutatingSteps.map((mutation) => mutation === "prebuild" ? mutation : "pod install"));
|
|
1038
|
-
storeHash = after.hash;
|
|
1039
|
-
storeSources = after.sources;
|
|
1040
|
-
storeKey = buildCacheKey("ios", after.hash, keyOptions);
|
|
1041
|
-
buildFailure = {
|
|
1042
|
-
...buildFailure,
|
|
1043
|
-
fingerprint: storeHash,
|
|
1044
|
-
cacheKey: storeKey
|
|
1045
|
-
};
|
|
1046
|
-
note(chalk.dim(phaseLine("fingerprint", `${shortHash(fingerprint)} -> ${shortHash(storeHash)} (after ${mutatingSteps.join(", ")})`)));
|
|
1047
|
-
const late = useBuildCache ? d.resolveBuild("ios", storeKey) : null;
|
|
1048
|
-
if (late) {
|
|
1049
|
-
const prepared = await installableCachedApp(late);
|
|
1050
|
-
if (prepared) {
|
|
1051
|
-
appPath = prepared;
|
|
1052
|
-
cacheHit = "local";
|
|
1053
|
-
lateHit();
|
|
1054
|
-
phase("cache", `hit ${shortHash(storeHash)} (post-${mutatingSteps.join("/")} key)`);
|
|
1055
|
-
if (releasedWait) {
|
|
1056
|
-
waitedForBuild = releasedWait.facts;
|
|
1057
|
-
phase("build", `waited ${formatDuration(waitedForBuild.ms)} for ${releasedWait.who}'s build -> installed from cache -- stim guide lifecycle concurrency`);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
if (offload && !appPath) {
|
|
1064
|
-
explainMiss(rekeyedBy);
|
|
1065
|
-
step("compile");
|
|
1066
|
-
if (!storeKey) fallBack("no cache key to store the app under", "offload failed: no cache key to store the app under");
|
|
1067
|
-
const choice = storeKey ? await chooseMachine(offload) : null;
|
|
1068
|
-
if (!choice || !await compileElsewhere({
|
|
1069
|
-
choice,
|
|
1070
|
-
candidate: offload
|
|
1071
|
-
})) await takeBuildSlot();
|
|
1072
|
-
}
|
|
1073
|
-
if (!appPath) {
|
|
1074
|
-
if (!offload) explainMiss(rekeyedBy);
|
|
1075
|
-
step("compile");
|
|
1076
|
-
if (offload) stats.setPlacement({
|
|
1077
|
-
decision: "fell-back",
|
|
1078
|
-
slotWaitMs,
|
|
1079
|
-
deviceSlotWaitMs: stats.deviceSlotWaitMs(),
|
|
1080
|
-
reason: offloadFallback ?? "offload failed",
|
|
1081
|
-
...fallbackMachine ? { machine: fallbackMachine } : {}
|
|
1082
|
-
});
|
|
1083
|
-
else stats.setPlacement({
|
|
1084
|
-
decision: "here",
|
|
1085
|
-
reason: hereReason,
|
|
1086
|
-
slotWaitMs,
|
|
1087
|
-
deviceSlotWaitMs: stats.deviceSlotWaitMs()
|
|
1088
|
-
});
|
|
1089
|
-
builtOn = "here";
|
|
1090
|
-
buildFailure = {
|
|
1091
|
-
...buildFailure,
|
|
1092
|
-
builtOn
|
|
1093
|
-
};
|
|
1094
|
-
phase("build", `compiling ${configuration || "Debug"} with xcodebuild`);
|
|
1095
|
-
const result = await d.buildIos({
|
|
1096
|
-
root,
|
|
1097
|
-
scheme: buildScheme,
|
|
1098
|
-
udid,
|
|
1099
|
-
destination: remoteDestination ? GENERIC_SIM_DESTINATION : null,
|
|
1100
|
-
arch: remoteDestination ? simulatorArch : null,
|
|
1101
|
-
...physical ? { sdk: IPHONEOS_SDK } : {},
|
|
1102
|
-
logWriter: logWriter(),
|
|
1103
|
-
...configuration ? { configuration } : {},
|
|
1104
|
-
estimateMs: estimates().coldBuildMs,
|
|
1105
|
-
optimizations
|
|
1106
|
-
});
|
|
1107
|
-
compilationCache = result.compilationCache;
|
|
1108
|
-
phase("cache", `compilation cache ${compilationCacheActivityLine(compilationCache)}`);
|
|
1109
|
-
if (!result.ok) {
|
|
1110
|
-
phase("build", `FAILED after ${formatDuration(result.durationMs)}`);
|
|
1111
|
-
printDiagnostics(note, result);
|
|
1112
|
-
const report = xcodeFailureReport(result, logFile);
|
|
1113
|
-
fail({
|
|
1114
|
-
code: result.code,
|
|
1115
|
-
message: report.message,
|
|
1116
|
-
remedy: report.remedy,
|
|
1117
|
-
logPath: logFile,
|
|
1118
|
-
build: {
|
|
1119
|
-
...buildFailure,
|
|
1120
|
-
diagnostics: result.diagnostics
|
|
1121
|
-
}
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
|
-
stats.setBuildMs(result.durationMs);
|
|
1125
|
-
phase("build", `ok (${formatDuration(result.durationMs)})`);
|
|
1126
|
-
appPath = result.appPath;
|
|
1127
|
-
bundleId = result.bundleId;
|
|
1128
|
-
await settleStoreKeyAfterCompile(mutatingSteps.includes("prebuild"));
|
|
1129
|
-
if (storeKey && cachePolicy.write) try {
|
|
1130
|
-
const stored = await storeTieredBuild({
|
|
1131
|
-
local: filesystemBuildCapability({
|
|
1132
|
-
resolve: d.resolveBuild,
|
|
1133
|
-
store: d.storeBuild,
|
|
1134
|
-
sources: storeSources
|
|
1135
|
-
}),
|
|
1136
|
-
loadProvider,
|
|
1137
|
-
target: {
|
|
1138
|
-
projectRoot: root,
|
|
1139
|
-
platform: "ios",
|
|
1140
|
-
key: storeKey
|
|
1141
|
-
},
|
|
1142
|
-
sourcePath: appPath,
|
|
1143
|
-
overwrite: !useBuildCache || swapFellBack,
|
|
1144
|
-
warn: cacheWarn
|
|
1145
|
-
});
|
|
1146
|
-
providerUpload = stored.providerUpload;
|
|
1147
|
-
providerName = stored.providerName ?? providerName;
|
|
1148
|
-
} catch (e) {
|
|
1149
|
-
note(chalk.yellow(`Could not store the build in the shared cache: ${e?.message || e}`));
|
|
1150
|
-
}
|
|
1151
|
-
if (physical) {
|
|
1152
|
-
const prepared = await prepareDeviceApp(appPath, { fresh: true });
|
|
1153
|
-
if (!prepared) return;
|
|
1154
|
-
appPath = prepared;
|
|
1155
|
-
}
|
|
1156
|
-
if (remote && !physical && storeHash) uploadPending = d.uploadRemote({
|
|
1157
|
-
logWriter: logWriter(),
|
|
1158
|
-
provider: remote.provider,
|
|
1159
|
-
platform: "ios",
|
|
1160
|
-
projectRoot: root,
|
|
1161
|
-
fingerprintHash: storeHash,
|
|
1162
|
-
buildPath: appPath,
|
|
1163
|
-
runOptions: providerRunOptions
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
let transferred = false;
|
|
1169
|
-
try {
|
|
1170
|
-
await resolveInitialFingerprint();
|
|
1171
|
-
if (!easBuild) {
|
|
1172
|
-
remote = await resolveRemoteArtifact();
|
|
1173
|
-
if (!appPath) miss(reasonForMiss([]).reason);
|
|
1174
|
-
await awaitSharedBuild();
|
|
1175
|
-
await prepareCachedArtifact();
|
|
1176
|
-
if (appPath) lateHit();
|
|
1177
|
-
else if (swapFellBack) miss(reasonForMiss([]).reason);
|
|
1178
|
-
await buildArtifact();
|
|
1179
|
-
}
|
|
1180
|
-
const artifact = {
|
|
1181
|
-
handoff,
|
|
1182
|
-
path: appPath,
|
|
1183
|
-
bundleId,
|
|
1184
|
-
cache: {
|
|
1185
|
-
identity: storeHash && storeKey ? {
|
|
1186
|
-
fingerprint: storeHash,
|
|
1187
|
-
key: storeKey
|
|
1188
|
-
} : null,
|
|
1189
|
-
hit: cacheHit,
|
|
1190
|
-
providerName: remote?.name ?? providerName,
|
|
1191
|
-
buildMachine,
|
|
1192
|
-
...builtOn ? { builtOn } : {},
|
|
1193
|
-
offloadedTo,
|
|
1194
|
-
offloadFallback: offloadedTo ? null : offloadFallback,
|
|
1195
|
-
readEnabled: useBuildCache,
|
|
1196
|
-
missReason: cacheHit ? null : missReason,
|
|
1197
|
-
waitedForBuild,
|
|
1198
|
-
compilation: compilationCache
|
|
1199
|
-
},
|
|
1200
|
-
failureFields: {
|
|
1201
|
-
...buildFailure,
|
|
1202
|
-
buildMachine,
|
|
1203
|
-
...builtOn ? { builtOn } : {},
|
|
1204
|
-
fingerprint: storeHash,
|
|
1205
|
-
cacheKey: storeKey,
|
|
1206
|
-
cacheHit,
|
|
1207
|
-
cacheSkipped: !useBuildCache
|
|
1208
|
-
},
|
|
1209
|
-
completeUploads: async () => {
|
|
1210
|
-
const uploadWasAbandoned = await finishIosUpload(uploadPending, remote, phase, note);
|
|
1211
|
-
const outcome = providerUploadOutcome(providerUpload ? await providerUpload : null, providerName);
|
|
1212
|
-
if (outcome) {
|
|
1213
|
-
if (outcome.warn) note(chalk.yellow(phaseLine("cache", outcome.line)));
|
|
1214
|
-
else phase("cache", outcome.line);
|
|
1215
|
-
}
|
|
1216
|
-
return abandonedRemote || uploadWasAbandoned;
|
|
1217
|
-
},
|
|
1218
|
-
release: releaseArtifact
|
|
1219
|
-
};
|
|
1220
|
-
transferred = true;
|
|
1221
|
-
return {
|
|
1222
|
-
ok: true,
|
|
1223
|
-
artifact
|
|
1224
|
-
};
|
|
1225
|
-
} catch (error) {
|
|
1226
|
-
if (error instanceof OffloadRefusal) {
|
|
1227
|
-
const refusal = error;
|
|
1228
|
-
return {
|
|
1229
|
-
ok: false,
|
|
1230
|
-
failure: {
|
|
1231
|
-
code: refusal.code,
|
|
1232
|
-
message: refusal.message,
|
|
1233
|
-
remedy: refusal.remedy,
|
|
1234
|
-
build: {
|
|
1235
|
-
...buildFailure,
|
|
1236
|
-
buildMachine,
|
|
1237
|
-
...builtOn ? { builtOn } : {}
|
|
1238
|
-
}
|
|
1239
|
-
},
|
|
1240
|
-
compilationCache
|
|
1241
|
-
};
|
|
1242
|
-
}
|
|
1243
|
-
if (error instanceof ArtifactRefusal) return {
|
|
1244
|
-
ok: false,
|
|
1245
|
-
failure: error.failure,
|
|
1246
|
-
compilationCache
|
|
1247
|
-
};
|
|
1248
|
-
throw error;
|
|
1249
|
-
} finally {
|
|
1250
|
-
if (openOffload.choice) closeOffload(openOffload.choice);
|
|
1251
|
-
releaseLock();
|
|
1252
|
-
releaseSlot();
|
|
1253
|
-
if (!transferred) releaseArtifact();
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
//#endregion
|
|
1257
|
-
//#region src/commands/ios/remote.ts
|
|
1258
|
-
function resolveIosRemote({ opts, settings, physical, recorded }) {
|
|
1259
|
-
const target = opts.remote !== void 0 ? parseIosRemote(opts.remote) : remoteIosSetting(settings);
|
|
1260
|
-
if (physical && target?.kind === "machine") return { failure: {
|
|
1261
|
-
code: "STIM_BAD_ARG",
|
|
1262
|
-
message: "--device builds for a phone connected to this machine, and --remote installs on a remote one.",
|
|
1263
|
-
remedy: "Pass only one of --device and --remote; unset ios.remote for a local phone."
|
|
1264
|
-
} };
|
|
1265
|
-
const machine = target?.kind === "machine" ? target.machine : null;
|
|
1266
|
-
if (recorded && recorded.machine !== machine && machine !== "auto") return { failure: {
|
|
1267
|
-
code: "STIM_BAD_ARG",
|
|
1268
|
-
message: `This workspace's iOS simulator runs on ${recorded.machine}; run stim stop first.`
|
|
1269
|
-
} };
|
|
1270
|
-
return {
|
|
1271
|
-
machine,
|
|
1272
|
-
backend: !physical && target?.kind === "backend" ? target.backend : null,
|
|
1273
|
-
recorded
|
|
1274
|
-
};
|
|
1275
|
-
}
|
|
1276
|
-
function selectIosTarget({ root, slot, opts, settings, physical, release, metroCheck, d }) {
|
|
1277
|
-
let recorded;
|
|
1278
|
-
try {
|
|
1279
|
-
recorded = d.readHostedIos(root, slot)[slot];
|
|
1280
|
-
} catch (error) {
|
|
1281
|
-
return { failure: {
|
|
1282
|
-
code: "STIM_HOSTING_REFUSED",
|
|
1283
|
-
message: error.message,
|
|
1284
|
-
...error instanceof Error && "remedy" in error && typeof error.remedy === "string" ? { remedy: error.remedy } : {}
|
|
1285
|
-
} };
|
|
1286
|
-
}
|
|
1287
|
-
const selection = resolveIosRemote({
|
|
1288
|
-
opts,
|
|
1289
|
-
settings,
|
|
1290
|
-
physical,
|
|
1291
|
-
recorded
|
|
1292
|
-
});
|
|
1293
|
-
if ("failure" in selection) return selection;
|
|
1294
|
-
const localIos = selection.machine ? deviceSlotPlatforms(d.getProject(root), slot)?.ios : void 0;
|
|
1295
|
-
if (selection.machine !== "auto" && selection.machine && localIos?.owned && localIos.deviceUdid) {
|
|
1296
|
-
let localRunning = true;
|
|
1297
|
-
try {
|
|
1298
|
-
localRunning = d.listAllIosSims({ timeoutMs: 5e3 }).some((sim) => sim.udid === localIos.deviceUdid && sim.state !== "Shutdown");
|
|
1299
|
-
} catch {}
|
|
1300
|
-
if (localRunning) return { failure: {
|
|
1301
|
-
code: "STIM_BAD_ARG",
|
|
1302
|
-
message: `This workspace's iOS simulator for slot ${slot} runs on this Mac; run stim stop first.`
|
|
1303
|
-
} };
|
|
1304
|
-
}
|
|
1305
|
-
if (selection.machine !== "auto" && selection.machine && !release && !metroCheck) return { failure: {
|
|
1306
|
-
code: "STIM_BAD_ARG",
|
|
1307
|
-
message: "Hosted Debug runs require the local Metro supervisor; --no-metro-check cannot be used.",
|
|
1308
|
-
remedy: "Run stim stop; stim start, then retry without --no-metro-check."
|
|
1309
|
-
} };
|
|
1310
|
-
return selection;
|
|
1311
|
-
}
|
|
1312
|
-
async function selectIosPlacement(args) {
|
|
1313
|
-
const selection = selectIosTarget(args);
|
|
1314
|
-
if ("failure" in selection || selection.machine !== "auto") return selection;
|
|
1315
|
-
const { root, slot, d, opts, deviceType, runtime, noWait, phase, release, metroCheck } = args;
|
|
1316
|
-
const viewer = resolveSimulatorAppFlag(opts.simulatorApp, args.physical, null);
|
|
1317
|
-
if ("refusal" in viewer) return { failure: viewer.refusal };
|
|
1318
|
-
const refusal = args.validateSelectors();
|
|
1319
|
-
if (refusal) return { failure: refusal };
|
|
1320
|
-
try {
|
|
1321
|
-
const placed = await d.automaticDevicePlacement({
|
|
1322
|
-
root,
|
|
1323
|
-
slot,
|
|
1324
|
-
platform: "ios",
|
|
1325
|
-
selectors: hostedIosSelectors(deviceType, runtime),
|
|
1326
|
-
buildMachine: opts.remoteBuild,
|
|
1327
|
-
noWait
|
|
1328
|
-
});
|
|
1329
|
-
phase("placement:", devicePlacementLine(placed.placement, placed.skipped));
|
|
1330
|
-
if (placed.target && !release && !metroCheck) return { failure: {
|
|
1331
|
-
code: "STIM_BAD_ARG",
|
|
1332
|
-
message: "Hosted Debug runs require the local Metro supervisor; --no-metro-check cannot be used.",
|
|
1333
|
-
remedy: "Run stim stop; stim start, then retry without --no-metro-check."
|
|
1334
|
-
} };
|
|
1335
|
-
return {
|
|
1336
|
-
...selection,
|
|
1337
|
-
machine: placed.target?.host.machine ?? null,
|
|
1338
|
-
recorded: void 0,
|
|
1339
|
-
auto: { target: placed.target },
|
|
1340
|
-
budget: placed.target ? {
|
|
1341
|
-
reclaimed: [],
|
|
1342
|
-
refusal: null
|
|
1343
|
-
} : void 0,
|
|
1344
|
-
devicePlacement: placed.placement
|
|
1345
|
-
};
|
|
1346
|
-
} catch (error) {
|
|
1347
|
-
return { failure: {
|
|
1348
|
-
code: error.code ?? "STIM_HOSTING_REFUSED",
|
|
1349
|
-
message: error.message,
|
|
1350
|
-
...error instanceof Error && "remedy" in error && typeof error.remedy === "string" ? { remedy: error.remedy } : {}
|
|
1351
|
-
} };
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
function hostedIosSelectors(deviceType, runtime) {
|
|
1355
|
-
return {
|
|
1356
|
-
...deviceType ? { deviceType } : {},
|
|
1357
|
-
...runtime ? { runtime } : {}
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
async function connectIosTarget(selection, selectors, d) {
|
|
1361
|
-
if (selection.auto) return { target: selection.auto.target };
|
|
1362
|
-
if (!selection.machine) return { target: null };
|
|
1363
|
-
try {
|
|
1364
|
-
return { target: await d.prepareHostedIos(selection.machine, selectors, selection.recorded) };
|
|
1365
|
-
} catch (error) {
|
|
1366
|
-
return { failure: {
|
|
1367
|
-
code: error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "STIM_HOSTING_REFUSED",
|
|
1368
|
-
message: error instanceof Error ? error.message : String(error),
|
|
1369
|
-
...error instanceof Error && "remedy" in error && typeof error.remedy === "string" ? { remedy: error.remedy } : {}
|
|
1370
|
-
} };
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
function hostedIosBuildTarget(target) {
|
|
1374
|
-
return target ? { hostedDestination: {
|
|
1375
|
-
runtime: target.choice.runtimeId,
|
|
1376
|
-
architecture: target.choice.architecture
|
|
1377
|
-
} } : {};
|
|
1378
|
-
}
|
|
1379
|
-
async function iosPlacementBudget(d, root, note, hosted, automatic) {
|
|
1380
|
-
if (automatic) return {
|
|
1381
|
-
...automatic,
|
|
1382
|
-
refusal: hosted ? null : automatic.refusal
|
|
1383
|
-
};
|
|
1384
|
-
return hosted ? {
|
|
1385
|
-
reclaimed: [],
|
|
1386
|
-
refusal: null
|
|
1387
|
-
} : d.budgetGate({
|
|
1388
|
-
root,
|
|
1389
|
-
note
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
function hostedIosMetroNote(hosted, settings, note, simulatorApp) {
|
|
1393
|
-
if (hosted && (settings.iosSimulatorApp !== void 0 || simulatorApp !== void 0)) note(chalk.dim(phaseLine("device", "iosSimulatorApp is ignored on a hosting Mac; the simulator boots headless.")));
|
|
1394
|
-
if (hosted && (publicUrlSetting(settings) || tunnelModeSetting(settings))) note(chalk.dim(phaseLine("metro", "metro.publicUrl and metro.tunnel are ignored on a hosting Mac; Metro uses the private tailnet bridge.")));
|
|
1395
|
-
}
|
|
1396
|
-
async function connectIosBackend(root, backend, deviceType, d) {
|
|
1397
|
-
if (!backend) return {
|
|
1398
|
-
remote: null,
|
|
1399
|
-
arch: null
|
|
1400
|
-
};
|
|
1401
|
-
const resolved = await d.resolveRemoteContext({
|
|
1402
|
-
root,
|
|
1403
|
-
backend,
|
|
1404
|
-
easBin: d.resolveEasCliBin(root)?.file ?? null,
|
|
1405
|
-
deviceType: deviceType?.trim() || null
|
|
1406
|
-
});
|
|
1407
|
-
if ("failed" in resolved) return { failure: {
|
|
1408
|
-
code: resolved.code ?? "STIM_NO_REMOTE_SESSION",
|
|
1409
|
-
message: resolved.failed,
|
|
1410
|
-
remedy: resolved.remedy
|
|
1411
|
-
} };
|
|
1412
|
-
return {
|
|
1413
|
-
remote: d.remoteIosDeps(resolved.ctx),
|
|
1414
|
-
arch: await d.readRemoteSimulatorArch(resolved.ctx.existingDaemon)
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
//#endregion
|
|
1418
|
-
//#region src/commands/ios/hosted.ts
|
|
1419
|
-
async function finishHostedIosRun({ target, d, artifact, root, slot, release, isExpo, metroCheck, metroPort, logsDir, fail, note, selectors, ...report }) {
|
|
1420
|
-
const bundleId = artifact.bundleId ?? (d.readBundleId(artifact.path) || d.detectBundleId(root));
|
|
1421
|
-
if (!bundleId) return fail({
|
|
1422
|
-
code: "STIM_INSTALL_FAILED",
|
|
1423
|
-
message: "The built app has no bundle identifier."
|
|
1424
|
-
});
|
|
1425
|
-
const launchedAt = d.now();
|
|
1426
|
-
let run;
|
|
1427
|
-
try {
|
|
1428
|
-
run = await d.placeHostedIos(target, {
|
|
1429
|
-
root,
|
|
1430
|
-
slot,
|
|
1431
|
-
bundle: artifact.path,
|
|
1432
|
-
handoff: artifact.handoff,
|
|
1433
|
-
bundleId,
|
|
1434
|
-
selectors,
|
|
1435
|
-
release,
|
|
1436
|
-
...!release && isExpo ? { devClientScheme: d.devClientScheme(root, artifact.path) ?? void 0 } : {},
|
|
1437
|
-
reserved: (placement) => d.writeHostedIos(root, slot, placement),
|
|
1438
|
-
note
|
|
1439
|
-
});
|
|
1440
|
-
} catch (error) {
|
|
1441
|
-
return fail({
|
|
1442
|
-
code: error.code ?? "STIM_HOSTING_REFUSED",
|
|
1443
|
-
message: error.message,
|
|
1444
|
-
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.`
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
d.writeHostedIos(root, slot, run.placement);
|
|
1448
|
-
d.writeWorkspaceLaunch(root, "ios", {
|
|
1449
|
-
appId: bundleId,
|
|
1450
|
-
deviceId: run.placement.session,
|
|
1451
|
-
metroPort,
|
|
1452
|
-
release,
|
|
1453
|
-
launchedAt: new Date(launchedAt).toISOString()
|
|
1454
|
-
}, slot);
|
|
1455
|
-
let launched = run.launched;
|
|
1456
|
-
if (!release && metroCheck) {
|
|
1457
|
-
const evidence = await d.verifyLaunch({
|
|
1458
|
-
requireBundleResponse: true,
|
|
1459
|
-
platform: "ios",
|
|
1460
|
-
logsDir,
|
|
1461
|
-
since: launchedAt,
|
|
1462
|
-
metroPort,
|
|
1463
|
-
mode: isExpo ? MODE_EXPO : MODE_BARE,
|
|
1464
|
-
slot: launchSlotScope(root, slot),
|
|
1465
|
-
platformShared: siblingPlatformSlots(root, "ios", slot).length > 0
|
|
1466
|
-
});
|
|
1467
|
-
if (evidence.fatal) return fail({
|
|
1468
|
-
code: "STIM_LAUNCH_FAILED",
|
|
1469
|
-
message: "Metro could not deliver the hosted app bundle.",
|
|
1470
|
-
remedy: "Run stim logs --errors and fix the bundle error."
|
|
1471
|
-
});
|
|
1472
|
-
launched = evidence.verified ? true : evidence.requested ? "bundling" : "unverified";
|
|
1473
|
-
}
|
|
1474
|
-
if (launched === "unverified") note(`Launch on ${target.host.machine} is unverified; check the hosted app, then retry stim ios --remote ${target.host.machine}.`);
|
|
1475
|
-
const cache = artifact.cache;
|
|
1476
|
-
const device = run.placement.device;
|
|
1477
|
-
const uploadsAbandoned = await artifact.completeUploads();
|
|
1478
|
-
return {
|
|
1479
|
-
facts: reportIosResult({
|
|
1480
|
-
...report,
|
|
1481
|
-
root,
|
|
1482
|
-
slot,
|
|
1483
|
-
release,
|
|
1484
|
-
metroCheck,
|
|
1485
|
-
metroPort,
|
|
1486
|
-
logsDir,
|
|
1487
|
-
device: {
|
|
1488
|
-
deviceName: device.deviceType,
|
|
1489
|
-
deviceType: device.deviceType,
|
|
1490
|
-
runtime: device.runtime
|
|
1491
|
-
},
|
|
1492
|
-
udid: "",
|
|
1493
|
-
host: hostedIosStatus(run.placement),
|
|
1494
|
-
appPath: artifact.path,
|
|
1495
|
-
bundleId,
|
|
1496
|
-
installSkipped: false,
|
|
1497
|
-
storeHash: cache.identity?.fingerprint ?? null,
|
|
1498
|
-
storeKey: cache.identity?.key ?? null,
|
|
1499
|
-
cacheHit: cache.hit,
|
|
1500
|
-
missReason: cache.missReason,
|
|
1501
|
-
compilationCache: cache.compilation,
|
|
1502
|
-
useBuildCache: cache.readEnabled,
|
|
1503
|
-
waitedForBuild: cache.waitedForBuild,
|
|
1504
|
-
launchState: launched,
|
|
1505
|
-
providerName: cache.providerName,
|
|
1506
|
-
buildMachine: cache.buildMachine,
|
|
1507
|
-
builtOn: cache.builtOn,
|
|
1508
|
-
offloadedTo: cache.offloadedTo,
|
|
1509
|
-
offloadFallback: cache.offloadFallback,
|
|
1510
|
-
webPreviewUrl: null
|
|
1511
|
-
}),
|
|
1512
|
-
uploadsAbandoned
|
|
1513
|
-
};
|
|
1514
|
-
}
|
|
1515
|
-
//#endregion
|
|
1516
|
-
//#region src/engine/ios-profile.ts
|
|
1517
|
-
const TAG = /<(\/?)\s*([A-Za-z0-9_]+)(?:\s[^>]*?)?(\/?)>/g;
|
|
1518
|
-
const ENTITIES = {
|
|
1519
|
-
amp: "&",
|
|
1520
|
-
lt: "<",
|
|
1521
|
-
gt: ">",
|
|
1522
|
-
quot: "\"",
|
|
1523
|
-
apos: "'"
|
|
1524
|
-
};
|
|
1525
|
-
var PlistError = class extends Error {};
|
|
1526
|
-
function codePoint(value) {
|
|
1527
|
-
if (!Number.isInteger(value) || value < 0 || value > 1114111 || value >= 55296 && value <= 57343) throw new PlistError(`character reference out of range: ${value}`);
|
|
1528
|
-
return String.fromCodePoint(value);
|
|
1529
|
-
}
|
|
1530
|
-
function decodeEntities(raw) {
|
|
1531
|
-
return raw.replace(/&(#x?[0-9A-Fa-f]+|[a-z]+);/g, (match, body) => {
|
|
1532
|
-
if (body.startsWith("#x") || body.startsWith("#X")) return codePoint(Number.parseInt(body.slice(2), 16));
|
|
1533
|
-
if (body.startsWith("#")) return codePoint(Number.parseInt(body.slice(1), 10));
|
|
1534
|
-
return ENTITIES[body] ?? match;
|
|
1535
|
-
});
|
|
1536
|
-
}
|
|
1537
|
-
function peekTag(cursor) {
|
|
1538
|
-
TAG.lastIndex = cursor.pos;
|
|
1539
|
-
const match = TAG.exec(cursor.xml);
|
|
1540
|
-
if (!match) return null;
|
|
1541
|
-
return {
|
|
1542
|
-
name: (match[2] ?? "").toLowerCase(),
|
|
1543
|
-
closing: match[1] === "/",
|
|
1544
|
-
selfClosing: match[3] === "/",
|
|
1545
|
-
end: TAG.lastIndex
|
|
1546
|
-
};
|
|
1547
|
-
}
|
|
1548
|
-
function takeTag(cursor) {
|
|
1549
|
-
const tag = peekTag(cursor);
|
|
1550
|
-
if (tag) cursor.pos = tag.end;
|
|
1551
|
-
return tag;
|
|
1552
|
-
}
|
|
1553
|
-
function takeText(cursor, name) {
|
|
1554
|
-
const close = cursor.xml.indexOf(`</${name}>`, cursor.pos);
|
|
1555
|
-
if (close < 0) {
|
|
1556
|
-
cursor.pos = cursor.xml.length;
|
|
1557
|
-
return "";
|
|
1558
|
-
}
|
|
1559
|
-
const raw = cursor.xml.slice(cursor.pos, close);
|
|
1560
|
-
cursor.pos = close + name.length + 3;
|
|
1561
|
-
return raw;
|
|
1562
|
-
}
|
|
1563
|
-
function parseValue(cursor) {
|
|
1564
|
-
const peeked = peekTag(cursor);
|
|
1565
|
-
if (!peeked || peeked.closing) return void 0;
|
|
1566
|
-
const tag = takeTag(cursor);
|
|
1567
|
-
if (tag.selfClosing) {
|
|
1568
|
-
if (tag.name === "true") return true;
|
|
1569
|
-
if (tag.name === "false") return false;
|
|
1570
|
-
if (tag.name === "array") return [];
|
|
1571
|
-
if (tag.name === "dict") return {};
|
|
1572
|
-
return "";
|
|
1573
|
-
}
|
|
1574
|
-
switch (tag.name) {
|
|
1575
|
-
case "plist": return parseValue(cursor);
|
|
1576
|
-
case "dict": {
|
|
1577
|
-
const out = {};
|
|
1578
|
-
for (;;) {
|
|
1579
|
-
const next = peekTag(cursor);
|
|
1580
|
-
if (!next) break;
|
|
1581
|
-
if (next.closing) {
|
|
1582
|
-
cursor.pos = next.end;
|
|
1583
|
-
break;
|
|
1584
|
-
}
|
|
1585
|
-
cursor.pos = next.end;
|
|
1586
|
-
if (next.name !== "key") continue;
|
|
1587
|
-
const key = decodeEntities(next.selfClosing ? "" : takeText(cursor, "key"));
|
|
1588
|
-
const value = parseValue(cursor);
|
|
1589
|
-
if (value !== void 0) out[key] = value;
|
|
1590
|
-
}
|
|
1591
|
-
return out;
|
|
1592
|
-
}
|
|
1593
|
-
case "array": {
|
|
1594
|
-
const out = [];
|
|
1595
|
-
for (;;) {
|
|
1596
|
-
const next = peekTag(cursor);
|
|
1597
|
-
if (!next) break;
|
|
1598
|
-
if (next.closing) {
|
|
1599
|
-
cursor.pos = next.end;
|
|
1600
|
-
break;
|
|
1601
|
-
}
|
|
1602
|
-
const value = parseValue(cursor);
|
|
1603
|
-
if (value === void 0) break;
|
|
1604
|
-
out.push(value);
|
|
1605
|
-
}
|
|
1606
|
-
return out;
|
|
1607
|
-
}
|
|
1608
|
-
case "string":
|
|
1609
|
-
case "key": return decodeEntities(takeText(cursor, tag.name));
|
|
1610
|
-
case "integer": return Number.parseInt(takeText(cursor, "integer").trim(), 10);
|
|
1611
|
-
case "real": return Number.parseFloat(takeText(cursor, "real").trim());
|
|
1612
|
-
case "date": return new Date(takeText(cursor, "date").trim());
|
|
1613
|
-
case "data": return Buffer.from(takeText(cursor, "data").replace(/\s+/g, ""), "base64");
|
|
1614
|
-
case "true":
|
|
1615
|
-
takeText(cursor, "true");
|
|
1616
|
-
return true;
|
|
1617
|
-
case "false":
|
|
1618
|
-
takeText(cursor, "false");
|
|
1619
|
-
return false;
|
|
1620
|
-
default:
|
|
1621
|
-
takeText(cursor, tag.name);
|
|
1622
|
-
return "";
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
function parsePlist(xml) {
|
|
1626
|
-
if (typeof xml !== "string" || xml.trim() === "") return null;
|
|
1627
|
-
const stripped = xml.replace(/<!--[\s\S]*?-->/g, "");
|
|
1628
|
-
const start = stripped.indexOf("<plist");
|
|
1629
|
-
const cursor = {
|
|
1630
|
-
xml: stripped,
|
|
1631
|
-
pos: start < 0 ? 0 : start
|
|
1632
|
-
};
|
|
1633
|
-
try {
|
|
1634
|
-
const value = parseValue(cursor);
|
|
1635
|
-
return value === void 0 ? null : value;
|
|
1636
|
-
} catch {
|
|
1637
|
-
return null;
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
function isDict(value) {
|
|
1641
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && !Buffer.isBuffer(value) && !(value instanceof Date);
|
|
1642
|
-
}
|
|
1643
|
-
function stringsOf(value) {
|
|
1644
|
-
if (!Array.isArray(value)) return null;
|
|
1645
|
-
return value.filter((v) => typeof v === "string");
|
|
1646
|
-
}
|
|
1647
|
-
function parseProvisioningProfilePlist(xml) {
|
|
1648
|
-
const root = parsePlist(xml);
|
|
1649
|
-
if (!isDict(root)) return null;
|
|
1650
|
-
const entitlements = isDict(root.Entitlements ?? null) ? root.Entitlements : {};
|
|
1651
|
-
const teamIdentifier = stringsOf(root.TeamIdentifier);
|
|
1652
|
-
const expiration = root.ExpirationDate;
|
|
1653
|
-
const certificates = Array.isArray(root.DeveloperCertificates) ? root.DeveloperCertificates.filter((v) => Buffer.isBuffer(v)) : [];
|
|
1654
|
-
return {
|
|
1655
|
-
name: typeof root.Name === "string" ? root.Name : null,
|
|
1656
|
-
uuid: typeof root.UUID === "string" ? root.UUID : null,
|
|
1657
|
-
teamIdentifier: teamIdentifier?.[0] ?? null,
|
|
1658
|
-
expirationDate: expiration instanceof Date && !Number.isNaN(expiration.getTime()) ? expiration : null,
|
|
1659
|
-
provisionedDevices: stringsOf(root.ProvisionedDevices),
|
|
1660
|
-
provisionsAllDevices: root.ProvisionsAllDevices === true,
|
|
1661
|
-
getTaskAllow: entitlements["get-task-allow"] === true,
|
|
1662
|
-
certificates
|
|
1663
|
-
};
|
|
1664
|
-
}
|
|
1665
|
-
function provisioningProfileKind(profile) {
|
|
1666
|
-
if (profile.provisionedDevices) return profile.getTaskAllow ? "development" : "ad hoc";
|
|
1667
|
-
return profile.provisionsAllDevices ? "enterprise" : "App Store";
|
|
1668
|
-
}
|
|
1669
|
-
function certificateCommonName(der) {
|
|
1670
|
-
if (!Buffer.isBuffer(der) || der.length === 0) return null;
|
|
1671
|
-
let subject;
|
|
1672
|
-
try {
|
|
1673
|
-
subject = new X509Certificate(der).subject;
|
|
1674
|
-
} catch {
|
|
1675
|
-
return null;
|
|
1676
|
-
}
|
|
1677
|
-
for (const part of String(subject).split(/\r?\n/)) {
|
|
1678
|
-
const trimmed = part.trim();
|
|
1679
|
-
if (trimmed.startsWith("CN=")) return trimmed.slice(3).trim() || null;
|
|
1680
|
-
}
|
|
1681
|
-
return /(?:^|,)\s*CN=([^,]+)/.exec(String(subject))?.[1]?.trim() || null;
|
|
1682
|
-
}
|
|
1683
|
-
const IDENTITY_LINE = /^\s*\d+\)\s+([0-9A-Fa-f]{40})\s+"(.+)"\s*$/;
|
|
1684
|
-
function parseSigningIdentities(text) {
|
|
1685
|
-
if (typeof text !== "string") return [];
|
|
1686
|
-
const out = [];
|
|
1687
|
-
for (const line of text.split(/\r?\n/)) {
|
|
1688
|
-
const match = IDENTITY_LINE.exec(line);
|
|
1689
|
-
if (!match) continue;
|
|
1690
|
-
out.push({
|
|
1691
|
-
sha1: match[1].toUpperCase(),
|
|
1692
|
-
name: match[2]
|
|
1693
|
-
});
|
|
1694
|
-
}
|
|
1695
|
-
return out;
|
|
1696
|
-
}
|
|
1697
|
-
const SIGNING_CODES = {
|
|
1698
|
-
noProfile: "STIM_NO_PROFILE",
|
|
1699
|
-
profileMismatch: "STIM_PROFILE_MISMATCH",
|
|
1700
|
-
noIdentity: "STIM_NO_SIGNING_IDENTITY",
|
|
1701
|
-
codesignFailed: "STIM_CODESIGN_FAILED"
|
|
1702
|
-
};
|
|
1703
|
-
const XCODE_STEP = "build once from Xcode to install it -- Stim will not, because registering a device or minting a profile changes your Apple Developer account.";
|
|
1704
|
-
const KEYCHAIN_REMEDY = "Open Xcode > Settings > Accounts and download your certificates, or unlock the login keychain with `security unlock-keychain`. `security find-identity -v -p codesigning` should list `Apple Development: ...`.";
|
|
1705
|
-
function signingConfiguration(input) {
|
|
1706
|
-
return input.configuration ?? "Debug";
|
|
1707
|
-
}
|
|
1708
|
-
function profileGate(input) {
|
|
1709
|
-
const now = input.now ?? Date.now();
|
|
1710
|
-
if (!input.profilePresent) return {
|
|
1711
|
-
ok: false,
|
|
1712
|
-
code: SIGNING_CODES.noProfile,
|
|
1713
|
-
reason: "The app bundle has no embedded.mobileprovision, so it was built unsigned or for the simulator.",
|
|
1714
|
-
remedy: `Set a team and profile for the target's ${signingConfiguration(input)} configuration in Xcode > Signing & Capabilities, then ${XCODE_STEP}`
|
|
1715
|
-
};
|
|
1716
|
-
if (!input.profile) return {
|
|
1717
|
-
ok: false,
|
|
1718
|
-
code: SIGNING_CODES.noProfile,
|
|
1719
|
-
reason: "`openssl smime` could not decode the app bundle's embedded.mobileprovision.",
|
|
1720
|
-
remedy: `The profile inside the app is corrupt. Delete the build cache entry with \`stim gc --delete\`, then ${XCODE_STEP}`
|
|
1721
|
-
};
|
|
1722
|
-
const profile = input.profile;
|
|
1723
|
-
const named = profile.name ? `"${profile.name}"` : "the embedded profile";
|
|
1724
|
-
if (!profile.expirationDate || profile.expirationDate.getTime() <= now) return {
|
|
1725
|
-
ok: false,
|
|
1726
|
-
code: SIGNING_CODES.profileMismatch,
|
|
1727
|
-
reason: profile.expirationDate ? `The ${provisioningProfileKind(profile)} profile ${named} expired on ${profile.expirationDate.toISOString()}.` : `The ${provisioningProfileKind(profile)} profile ${named} carries no ExpirationDate, so Stim cannot prove it is still valid.`,
|
|
1728
|
-
remedy: `Renew the profile under Signing & Capabilities, then ${XCODE_STEP}`
|
|
1729
|
-
};
|
|
1730
|
-
if (!profile.provisionedDevices) {
|
|
1731
|
-
const kind = provisioningProfileKind(profile);
|
|
1732
|
-
return {
|
|
1733
|
-
ok: false,
|
|
1734
|
-
code: SIGNING_CODES.profileMismatch,
|
|
1735
|
-
reason: `${named} is an ${kind} profile, which carries no ProvisionedDevices list, so Stim cannot prove ${input.udid ?? "the target device"} is admitted.`,
|
|
1736
|
-
remedy: `Local device runs need a development profile. Select one under Signing & Capabilities, then ${XCODE_STEP}`
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
|
-
const udid = input.udid;
|
|
1740
|
-
if (!udid || !profile.provisionedDevices.some((d) => d.toLowerCase() === udid.toLowerCase())) return {
|
|
1741
|
-
ok: false,
|
|
1742
|
-
code: SIGNING_CODES.profileMismatch,
|
|
1743
|
-
reason: `The ${provisioningProfileKind(profile)} profile ${named} lists ${profile.provisionedDevices.length} device(s) and ${udid ?? "the target device"} is not one of them.`,
|
|
1744
|
-
remedy: `Register ${udid ?? "the device"} at developer.apple.com, regenerate the profile, then ${XCODE_STEP}`
|
|
1745
|
-
};
|
|
1746
|
-
return {
|
|
1747
|
-
ok: true,
|
|
1748
|
-
profile
|
|
1749
|
-
};
|
|
1750
|
-
}
|
|
1751
|
-
function signingGate(input) {
|
|
1752
|
-
const gated = profileGate(input);
|
|
1753
|
-
if (!gated.ok) return gated;
|
|
1754
|
-
const profile = gated.profile;
|
|
1755
|
-
const named = profile.name ? `"${profile.name}"` : "the embedded profile";
|
|
1756
|
-
const identities = Array.isArray(input.identities) ? input.identities : [];
|
|
1757
|
-
if (identities.length === 0) return {
|
|
1758
|
-
ok: false,
|
|
1759
|
-
code: SIGNING_CODES.noIdentity,
|
|
1760
|
-
reason: "`security find-identity -v -p codesigning` lists no codesigning identity on this machine.",
|
|
1761
|
-
remedy: KEYCHAIN_REMEDY
|
|
1762
|
-
};
|
|
1763
|
-
if (input.pinnedSha1) {
|
|
1764
|
-
const wanted = input.pinnedSha1.trim().toUpperCase();
|
|
1765
|
-
const match = identities.find((i) => i.sha1 === wanted);
|
|
1766
|
-
if (match) return {
|
|
1767
|
-
ok: true,
|
|
1768
|
-
identity: match
|
|
1769
|
-
};
|
|
1770
|
-
return {
|
|
1771
|
-
ok: false,
|
|
1772
|
-
code: SIGNING_CODES.noIdentity,
|
|
1773
|
-
reason: `ios.signingIdentitySha1 is ${wanted}, which is not in the keychain. Available: ${identities.map((i) => `${i.sha1} "${i.name}"`).join(", ")}.`,
|
|
1774
|
-
remedy: KEYCHAIN_REMEDY
|
|
1775
|
-
};
|
|
1776
|
-
}
|
|
1777
|
-
const wantedName = input.pinnedName?.trim() || certificateCommonName(profile.certificates[0] ?? null);
|
|
1778
|
-
if (!wantedName) return {
|
|
1779
|
-
ok: false,
|
|
1780
|
-
code: SIGNING_CODES.noIdentity,
|
|
1781
|
-
reason: `Stim could not read a signing-identity name out of ${named}: its DeveloperCertificates entry has no readable subject CN.`,
|
|
1782
|
-
remedy: "Set ios.signingIdentity in .stim.json to the identity name to re-sign with, or ios.signingIdentitySha1 to its SHA-1 hash."
|
|
1783
|
-
};
|
|
1784
|
-
const matches = identities.filter((i) => i.name === wantedName);
|
|
1785
|
-
if (matches.length === 1) return {
|
|
1786
|
-
ok: true,
|
|
1787
|
-
identity: matches[0]
|
|
1788
|
-
};
|
|
1789
|
-
if (matches.length === 0) return {
|
|
1790
|
-
ok: false,
|
|
1791
|
-
code: SIGNING_CODES.noIdentity,
|
|
1792
|
-
reason: `The app was signed by "${wantedName}", which is not in this machine's keychain. Available: ${identities.map((i) => `"${i.name}"`).join(", ")}.`,
|
|
1793
|
-
remedy: `${KEYCHAIN_REMEDY} Or set ios.signingIdentity in .stim.json to one of the identities listed above.`
|
|
1794
|
-
};
|
|
1795
|
-
return {
|
|
1796
|
-
ok: false,
|
|
1797
|
-
code: SIGNING_CODES.noIdentity,
|
|
1798
|
-
reason: `${matches.length} keychain identities share the name "${wantedName}", so Stim cannot pick one: ${matches.map((i) => i.sha1).join(", ")}.`,
|
|
1799
|
-
remedy: "Set ios.signingIdentitySha1 in .stim.json to the SHA-1 hash of the certificate to sign with."
|
|
1800
|
-
};
|
|
1801
|
-
}
|
|
1802
|
-
//#endregion
|
|
1803
|
-
//#region src/engine/ios-signing.ts
|
|
1804
|
-
const EMBEDDED_PROFILE = "embedded.mobileprovision";
|
|
1805
|
-
const SIGNING_TIMEOUT_MS = 12e4;
|
|
1806
|
-
function lastLines(text, count = 5) {
|
|
1807
|
-
return String(text ?? "").split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.trim() !== "").slice(-count);
|
|
1808
|
-
}
|
|
1809
|
-
function errorText(error) {
|
|
1810
|
-
const withOutput = error;
|
|
1811
|
-
const stderr = String(withOutput?.stderr ?? "").trim();
|
|
1812
|
-
const stdout = String(withOutput?.stdout ?? "").trim();
|
|
1813
|
-
return stderr || stdout || String(withOutput?.message ?? error);
|
|
1814
|
-
}
|
|
1815
|
-
function readEmbeddedProfile(appPath, { exec = null } = {}) {
|
|
1816
|
-
const executor = exec || getExecutor();
|
|
1817
|
-
const path = join(appPath, EMBEDDED_PROFILE);
|
|
1818
|
-
if (!existsSync(path)) return {
|
|
1819
|
-
present: false,
|
|
1820
|
-
profile: null
|
|
1821
|
-
};
|
|
1822
|
-
try {
|
|
1823
|
-
return {
|
|
1824
|
-
present: true,
|
|
1825
|
-
profile: parseProvisioningProfilePlist(executor.runFile("/usr/bin/openssl", [
|
|
1826
|
-
"smime",
|
|
1827
|
-
"-verify",
|
|
1828
|
-
"-noverify",
|
|
1829
|
-
"-inform",
|
|
1830
|
-
"DER",
|
|
1831
|
-
"-in",
|
|
1832
|
-
path
|
|
1833
|
-
], { timeoutMs: SIGNING_TIMEOUT_MS }))
|
|
1834
|
-
};
|
|
1835
|
-
} catch {
|
|
1836
|
-
return {
|
|
1837
|
-
present: true,
|
|
1838
|
-
profile: null
|
|
1839
|
-
};
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
function findSigningIdentities({ exec = null } = {}) {
|
|
1843
|
-
const executor = exec || getExecutor();
|
|
1844
|
-
try {
|
|
1845
|
-
return parseSigningIdentities(executor.runFile("security", [
|
|
1846
|
-
"find-identity",
|
|
1847
|
-
"-v",
|
|
1848
|
-
"-p",
|
|
1849
|
-
"codesigning"
|
|
1850
|
-
], { timeoutMs: SIGNING_TIMEOUT_MS }));
|
|
1851
|
-
} catch {
|
|
1852
|
-
return [];
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
function gateProfileForDevice(options) {
|
|
1856
|
-
const read = readEmbeddedProfile(options.appPath, { exec: options.exec ?? null });
|
|
1857
|
-
return profileGate({
|
|
1858
|
-
profilePresent: read.present,
|
|
1859
|
-
profile: read.profile,
|
|
1860
|
-
identities: [],
|
|
1861
|
-
udid: options.udid,
|
|
1862
|
-
configuration: options.configuration ?? null,
|
|
1863
|
-
...options.now === void 0 ? {} : { now: options.now }
|
|
1864
|
-
});
|
|
1865
|
-
}
|
|
1866
|
-
function gateAppForDevice(options) {
|
|
1867
|
-
const read = readEmbeddedProfile(options.appPath, { exec: options.exec ?? null });
|
|
1868
|
-
return signingGate({
|
|
1869
|
-
profilePresent: read.present,
|
|
1870
|
-
profile: read.profile,
|
|
1871
|
-
identities: read.present ? findSigningIdentities({ exec: options.exec ?? null }) : [],
|
|
1872
|
-
udid: options.udid,
|
|
1873
|
-
configuration: options.configuration ?? null,
|
|
1874
|
-
pinnedName: options.pinnedName ?? null,
|
|
1875
|
-
pinnedSha1: options.pinnedSha1 ?? null,
|
|
1876
|
-
...options.now === void 0 ? {} : { now: options.now }
|
|
1877
|
-
});
|
|
1878
|
-
}
|
|
1879
|
-
function extractEntitlements(appPath, executor) {
|
|
1880
|
-
try {
|
|
1881
|
-
return String(executor.runFile("codesign", [
|
|
1882
|
-
"-d",
|
|
1883
|
-
"--entitlements",
|
|
1884
|
-
"-",
|
|
1885
|
-
"--xml",
|
|
1886
|
-
appPath
|
|
1887
|
-
], { timeoutMs: SIGNING_TIMEOUT_MS })).trim();
|
|
1888
|
-
} catch {
|
|
1889
|
-
return "";
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
function resealBundle({ appPath, identity, exec = null }) {
|
|
1893
|
-
const executor = exec || getExecutor();
|
|
1894
|
-
const signAs = identity.sha1 || identity.name;
|
|
1895
|
-
let mode = "preserve-metadata";
|
|
1896
|
-
let preserveError = null;
|
|
1897
|
-
try {
|
|
1898
|
-
executor.runFile("codesign", [
|
|
1899
|
-
"--force",
|
|
1900
|
-
"--sign",
|
|
1901
|
-
signAs,
|
|
1902
|
-
"--preserve-metadata=identifier,entitlements,flags,runtime",
|
|
1903
|
-
appPath
|
|
1904
|
-
], { timeoutMs: SIGNING_TIMEOUT_MS });
|
|
1905
|
-
} catch (error) {
|
|
1906
|
-
preserveError = error;
|
|
1907
|
-
}
|
|
1908
|
-
let tempDir = null;
|
|
1909
|
-
if (preserveError) {
|
|
1910
|
-
const entitlements = extractEntitlements(appPath, executor);
|
|
1911
|
-
const args = [
|
|
1912
|
-
"--force",
|
|
1913
|
-
"--sign",
|
|
1914
|
-
signAs
|
|
1915
|
-
];
|
|
1916
|
-
if (entitlements !== "") {
|
|
1917
|
-
tempDir = mkdtempSync(join(tmpdir(), "stim-entitlements-"));
|
|
1918
|
-
const plist = join(tempDir, "entitlements.plist");
|
|
1919
|
-
writeFileSync(plist, `${entitlements}\n`, "utf-8");
|
|
1920
|
-
args.push("--entitlements", plist);
|
|
1921
|
-
mode = "entitlements";
|
|
1922
|
-
} else mode = "no-entitlements";
|
|
1923
|
-
args.push(appPath);
|
|
1924
|
-
try {
|
|
1925
|
-
executor.runFile("codesign", args, { timeoutMs: SIGNING_TIMEOUT_MS });
|
|
1926
|
-
} catch (error) {
|
|
1927
|
-
return {
|
|
1928
|
-
ok: false,
|
|
1929
|
-
code: SIGNING_CODES.codesignFailed,
|
|
1930
|
-
reason: `codesign could not re-seal ${appPath} with "${identity.name}": ${errorText(error)}`,
|
|
1931
|
-
remedy: `Unlock the login keychain (\`security unlock-keychain\`) and confirm exactly one identity matches "${identity.name}".`,
|
|
1932
|
-
lastLines: [...lastLines(errorText(preserveError)), ...lastLines(errorText(error))]
|
|
1933
|
-
};
|
|
1934
|
-
} finally {
|
|
1935
|
-
if (tempDir) rmSync(tempDir, {
|
|
1936
|
-
recursive: true,
|
|
1937
|
-
force: true
|
|
1938
|
-
});
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
try {
|
|
1942
|
-
executor.runFile("codesign", [
|
|
1943
|
-
"--verify",
|
|
1944
|
-
"--strict",
|
|
1945
|
-
appPath
|
|
1946
|
-
], { timeoutMs: SIGNING_TIMEOUT_MS });
|
|
1947
|
-
} catch (error) {
|
|
1948
|
-
return {
|
|
1949
|
-
ok: false,
|
|
1950
|
-
code: SIGNING_CODES.codesignFailed,
|
|
1951
|
-
reason: `codesign --verify --strict rejected ${appPath} after re-sealing it with "${identity.name}": ${errorText(error)}`,
|
|
1952
|
-
remedy: "The bundle signed but did not seal. Delete the cached artifact with `stim gc --delete` and build fresh, then retry.",
|
|
1953
|
-
lastLines: lastLines(errorText(error))
|
|
1954
|
-
};
|
|
1955
|
-
}
|
|
1956
|
-
return {
|
|
1957
|
-
ok: true,
|
|
1958
|
-
identity,
|
|
1959
|
-
mode
|
|
1960
|
-
};
|
|
1961
|
-
}
|
|
1962
|
-
function sealAppForDevice(options) {
|
|
1963
|
-
const gate = gateAppForDevice(options);
|
|
1964
|
-
if (!gate.ok) return {
|
|
1965
|
-
...gate,
|
|
1966
|
-
lastLines: []
|
|
1967
|
-
};
|
|
1968
|
-
return resealBundle({
|
|
1969
|
-
appPath: options.appPath,
|
|
1970
|
-
identity: gate.identity,
|
|
1971
|
-
exec: options.exec ?? null
|
|
1972
|
-
});
|
|
1973
|
-
}
|
|
1974
|
-
//#endregion
|
|
1975
|
-
//#region src/engine/lan-address.ts
|
|
1976
|
-
const EN_INTERFACE = /^en(\d+)$/;
|
|
1977
|
-
const EXCLUDED_INTERFACE = /^(?:utun|bridge|awdl)/;
|
|
1978
|
-
const LINK_LOCAL = /^169\.254\./;
|
|
1979
|
-
function isIpv4(entry) {
|
|
1980
|
-
return entry.family === "IPv4" || entry.family === 4;
|
|
1981
|
-
}
|
|
1982
|
-
function lanCandidates(interfaces) {
|
|
1983
|
-
const ranked = [];
|
|
1984
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1985
|
-
for (const [interfaceName, entries] of Object.entries(interfaces ?? {})) {
|
|
1986
|
-
if (EXCLUDED_INTERFACE.test(interfaceName)) continue;
|
|
1987
|
-
const en = EN_INTERFACE.exec(interfaceName);
|
|
1988
|
-
for (const entry of entries ?? []) {
|
|
1989
|
-
if (!entry || typeof entry !== "object" || !isIpv4(entry) || entry.internal === true) continue;
|
|
1990
|
-
const address = typeof entry.address === "string" ? entry.address.trim() : "";
|
|
1991
|
-
if (address === "" || LINK_LOCAL.test(address)) continue;
|
|
1992
|
-
if (seen.has(address)) continue;
|
|
1993
|
-
seen.add(address);
|
|
1994
|
-
ranked.push({
|
|
1995
|
-
interfaceName,
|
|
1996
|
-
address,
|
|
1997
|
-
rank: en ? 0 : 1,
|
|
1998
|
-
index: en ? Number(en[1]) : 0
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
ranked.sort((a, b) => a.rank - b.rank || a.index - b.index || a.interfaceName.localeCompare(b.interfaceName) || a.address.localeCompare(b.address));
|
|
2003
|
-
return ranked.map(({ interfaceName, address }) => ({
|
|
2004
|
-
interfaceName,
|
|
2005
|
-
address
|
|
2006
|
-
}));
|
|
2007
|
-
}
|
|
2008
|
-
function hostLanCandidates(interfaces = networkInterfaces) {
|
|
2009
|
-
return lanCandidates(interfaces());
|
|
2010
|
-
}
|
|
2011
|
-
//#endregion
|
|
2012
|
-
//#region src/commands/ios/collector.ts
|
|
2013
|
-
function collectorLogFile(root, slot) {
|
|
2014
|
-
return join(workspaceLogsDir$1(root), `collector-${deviceSlotFileKey("ios", slot)}.log`);
|
|
2015
|
-
}
|
|
2016
|
-
function collectorEntry() {
|
|
2017
|
-
return spawnEntry("collector-run");
|
|
2018
|
-
}
|
|
2019
|
-
const COLLECTOR_EXIT_WAIT_MS = 2e3;
|
|
2020
|
-
const COLLECTOR_POLL_MS = 25;
|
|
2021
|
-
async function stopPreviousCollector({ root, slot = "default", kill = (pid, signal) => signalProcessTree(pid, signal), alive = pidExists, readState = readWorkspaceState$1, verify = verifyCollectorOwnership, waitMs = COLLECTOR_EXIT_WAIT_MS, note = (_line) => {} }) {
|
|
2022
|
-
const previous = (readState(root)?.collectors)?.[deviceSlotKey("ios", slot)] || null;
|
|
2023
|
-
const previousPid = Number(previous?.pid) || null;
|
|
2024
|
-
let killed = null;
|
|
2025
|
-
if (previousPid) {
|
|
2026
|
-
const ownership = verify({
|
|
2027
|
-
pid: previousPid,
|
|
2028
|
-
platform: deviceSlotKey("ios", slot),
|
|
2029
|
-
root,
|
|
2030
|
-
isAlive: alive,
|
|
2031
|
-
expected: previous
|
|
2032
|
-
});
|
|
2033
|
-
if (ownership.status === "ours") {
|
|
2034
|
-
try {
|
|
2035
|
-
kill(previousPid, "SIGTERM");
|
|
2036
|
-
killed = previousPid;
|
|
2037
|
-
} catch (err) {
|
|
2038
|
-
if (err?.code !== "ESRCH") note(chalk.yellow(`Could not stop the previous ios log collector (pid ${previousPid}): ${err?.message || err}`));
|
|
2039
|
-
}
|
|
2040
|
-
const deadline = Date.now() + waitMs;
|
|
2041
|
-
while (Date.now() < deadline && alive(previousPid)) await sleep(COLLECTOR_POLL_MS);
|
|
2042
|
-
} else if (ownership.status === "unverified") note(chalk.dim(`Previous ios log collector (pid ${previousPid}): ${ownership.reason}, so it was not signalled -- starting a replacement anyway`));
|
|
2043
|
-
}
|
|
2044
|
-
return { killed };
|
|
2045
|
-
}
|
|
2046
|
-
async function replaceCollector({ root, slot = "default", udid, bundleId, appName, appExecutable, physical = false, payloadUrl = null, spawn = (cmd, args, opts) => getExecutor().spawn(cmd, args, opts), kill = (pid, signal) => process.kill(pid, signal), alive = pidExists, readState = readWorkspaceState$1, verify = verifyCollectorOwnership, waitMs = COLLECTOR_EXIT_WAIT_MS, note = (_line) => {} }) {
|
|
2047
|
-
const { killed } = await stopPreviousCollector({
|
|
2048
|
-
root,
|
|
2049
|
-
slot,
|
|
2050
|
-
kill,
|
|
2051
|
-
alive,
|
|
2052
|
-
readState,
|
|
2053
|
-
verify,
|
|
2054
|
-
waitMs,
|
|
2055
|
-
note
|
|
2056
|
-
});
|
|
2057
|
-
const args = [
|
|
2058
|
-
collectorEntry(),
|
|
2059
|
-
"--platform",
|
|
2060
|
-
"ios",
|
|
2061
|
-
"--root",
|
|
2062
|
-
root,
|
|
2063
|
-
"--udid",
|
|
2064
|
-
udid,
|
|
2065
|
-
"--bundle",
|
|
2066
|
-
bundleId
|
|
2067
|
-
];
|
|
2068
|
-
if (slot !== "default") args.push("--slot", slot);
|
|
2069
|
-
if (appName) args.push("--app-name", appName);
|
|
2070
|
-
if (appExecutable) args.push("--app-executable", appExecutable);
|
|
2071
|
-
if (physical) args.push("--physical");
|
|
2072
|
-
if (payloadUrl) args.push("--payload-url", payloadUrl);
|
|
2073
|
-
let stdio = "ignore";
|
|
2074
|
-
try {
|
|
2075
|
-
mkdirSync(workspaceLogsDir$1(root), { recursive: true });
|
|
2076
|
-
const fd = openSync(collectorLogFile(root, slot), "a");
|
|
2077
|
-
stdio = [
|
|
2078
|
-
"ignore",
|
|
2079
|
-
fd,
|
|
2080
|
-
fd
|
|
2081
|
-
];
|
|
2082
|
-
} catch {}
|
|
2083
|
-
let child;
|
|
2084
|
-
try {
|
|
2085
|
-
child = spawn(process.execPath, args, {
|
|
2086
|
-
cwd: root,
|
|
2087
|
-
detached: true,
|
|
2088
|
-
stdio,
|
|
2089
|
-
env: process.env
|
|
2090
|
-
});
|
|
2091
|
-
child?.unref?.();
|
|
2092
|
-
} catch (err) {
|
|
2093
|
-
note(chalk.yellow(`Could not start the ios log collector: ${err?.message || err}`));
|
|
2094
|
-
return {
|
|
2095
|
-
killed,
|
|
2096
|
-
pid: null
|
|
2097
|
-
};
|
|
2098
|
-
}
|
|
2099
|
-
return {
|
|
2100
|
-
killed,
|
|
2101
|
-
pid: child?.pid ?? null
|
|
2102
|
-
};
|
|
2103
|
-
}
|
|
2104
|
-
//#endregion
|
|
2105
|
-
//#region src/commands/ios/dependencies.ts
|
|
2106
|
-
const DEFAULT_DEPS = {
|
|
2107
|
-
automaticDevicePlacement,
|
|
2108
|
-
prepareHostedIos,
|
|
2109
|
-
placeHostedIos,
|
|
2110
|
-
readHostedIos,
|
|
2111
|
-
writeHostedIos,
|
|
2112
|
-
resolveEasDevelopmentBuild,
|
|
2113
|
-
findProjectRoot: findProjectRoot$1,
|
|
2114
|
-
resolveSettings,
|
|
2115
|
-
settingsLayers,
|
|
2116
|
-
settingOriginScope,
|
|
2117
|
-
gitCommonDir,
|
|
2118
|
-
repoRoot,
|
|
2119
|
-
detectBundleId,
|
|
2120
|
-
detectIsExpo,
|
|
2121
|
-
devClientScheme,
|
|
2122
|
-
devClientTakesDevMenuParams,
|
|
2123
|
-
getProject,
|
|
2124
|
-
upsertProject,
|
|
2125
|
-
recordIosSchemeApprovals,
|
|
2126
|
-
checkDeviceCapacity,
|
|
2127
|
-
budgetGate,
|
|
2128
|
-
ensureOwnedDevice,
|
|
2129
|
-
listIosRuntimes,
|
|
2130
|
-
listAllIosSims,
|
|
2131
|
-
ensureBooted,
|
|
2132
|
-
resolveRemoteContext,
|
|
2133
|
-
remoteIosDeps,
|
|
2134
|
-
readRemoteSimulatorArch,
|
|
2135
|
-
hostSimulatorArch,
|
|
2136
|
-
ensureMetroReachable,
|
|
2137
|
-
ensureRemoteBootOwned,
|
|
2138
|
-
detectProviders,
|
|
2139
|
-
resolveProjectMetro,
|
|
2140
|
-
startDevServer,
|
|
2141
|
-
warmMetro,
|
|
2142
|
-
readWorkspaceState: readWorkspaceState$1,
|
|
2143
|
-
pidExists,
|
|
2144
|
-
getConcurrencyLimits,
|
|
2145
|
-
fingerprintProject,
|
|
2146
|
-
untrackedNativeFiles,
|
|
2147
|
-
resolveBuild,
|
|
2148
|
-
storeBuild,
|
|
2149
|
-
resolveCacheProviderConfig,
|
|
2150
|
-
loadCacheProvider,
|
|
2151
|
-
acquireBuildLock,
|
|
2152
|
-
releaseBuildLock,
|
|
2153
|
-
waitForBuild,
|
|
2154
|
-
acquireBuildSlot,
|
|
2155
|
-
releaseBuildSlot,
|
|
2156
|
-
loadProjectProvider,
|
|
2157
|
-
checkEasAuth,
|
|
2158
|
-
resolveEasCliBin,
|
|
2159
|
-
resolveRemote,
|
|
2160
|
-
uploadRemote,
|
|
2161
|
-
planPrebuild,
|
|
2162
|
-
runPrebuild,
|
|
2163
|
-
readPodState,
|
|
2164
|
-
podsAreStale,
|
|
2165
|
-
runPodInstall,
|
|
2166
|
-
buildIos,
|
|
2167
|
-
discoverXcodeProject,
|
|
2168
|
-
resolveScheme,
|
|
2169
|
-
listIosDevices,
|
|
2170
|
-
hostLanCandidates,
|
|
2171
|
-
ensureLanReachable,
|
|
2172
|
-
gateProfileForDevice,
|
|
2173
|
-
sealAppForDevice,
|
|
2174
|
-
installIosDeviceApp,
|
|
2175
|
-
awaitIosDeviceLaunch,
|
|
2176
|
-
acquireRunLease,
|
|
2177
|
-
runLease,
|
|
2178
|
-
selectFromPool,
|
|
2179
|
-
releaseLeaseOnSignal,
|
|
2180
|
-
iosDeviceProcess,
|
|
2181
|
-
verifyIosDeviceReleaseLaunch,
|
|
2182
|
-
readBundleId,
|
|
2183
|
-
readBundleExecutable,
|
|
2184
|
-
swapJsBundle,
|
|
2185
|
-
installIosApp,
|
|
2186
|
-
clearOtherUserApps,
|
|
2187
|
-
clearIosAppData,
|
|
2188
|
-
clearIosAdoptionPending,
|
|
2189
|
-
launchIosApp,
|
|
2190
|
-
verifyLaunch,
|
|
2191
|
-
verifyReleaseLaunch,
|
|
2192
|
-
ensureWorkspaceStorage: ensureWorkspaceStorageSafely,
|
|
2193
|
-
replaceCollector,
|
|
2194
|
-
stopPreviousCollector,
|
|
2195
|
-
writeWorkspaceLaunch,
|
|
2196
|
-
writeWorkspaceState,
|
|
2197
|
-
createWriter: createNdjsonWriter,
|
|
2198
|
-
recordStats: recordRunStats,
|
|
2199
|
-
recordCapacityRefusal,
|
|
2200
|
-
readEstimates: readRunEstimates,
|
|
2201
|
-
now: () => Date.now()
|
|
2202
|
-
};
|
|
2203
|
-
//#endregion
|
|
2204
|
-
//#region src/commands/ios/launch.ts
|
|
2205
|
-
function missingCrashReportHint({ physical, remote, crashed }) {
|
|
2206
|
-
return crashed && !physical && !remote ? `No attributable native crash report captured yet. ${IOS_CRASH_REPORT_RETRY}` : "No attributable native crash report captured. Read `stim logs --source device` for available output.";
|
|
2207
|
-
}
|
|
2208
|
-
async function verifyIosRun({ root, slot, appPath, d, release, launched, configuration, phase, note, metroCheck, logsDir, launchedAt, metroPort, isExpo, bundleId, udid, scheme, physical, appName, lanAddress, lanOrigin, remoteDevice, metroOrigin }) {
|
|
2209
|
-
const runCommand = nativeRunCommand("ios", slot, {
|
|
2210
|
-
physical,
|
|
2211
|
-
deviceId: udid
|
|
2212
|
-
});
|
|
2213
|
-
const readNativeCrashes = () => remoteDevice ? [] : captureNativeCrashes({
|
|
2214
|
-
root,
|
|
2215
|
-
slot,
|
|
2216
|
-
platform: "ios",
|
|
2217
|
-
deviceId: udid,
|
|
2218
|
-
appId: bundleId,
|
|
2219
|
-
since: launchedAt,
|
|
2220
|
-
appPath,
|
|
2221
|
-
physical
|
|
2222
|
-
}, logsDir);
|
|
2223
|
-
const deviceProcess = () => {
|
|
2224
|
-
const pid = d.iosDeviceProcess({
|
|
2225
|
-
udid,
|
|
2226
|
-
appName: appName ?? bundleId
|
|
2227
|
-
});
|
|
2228
|
-
return pid === void 0 ? null : pid !== null;
|
|
2229
|
-
};
|
|
2230
|
-
if (release) {
|
|
2231
|
-
const processCheck = physical ? await d.verifyIosDeviceReleaseLaunch({
|
|
2232
|
-
udid,
|
|
2233
|
-
appName: appName ?? bundleId
|
|
2234
|
-
}) : await d.verifyReleaseLaunch({ pid: launched?.pid ?? null });
|
|
2235
|
-
const crashes = readNativeCrashes();
|
|
2236
|
-
if (processCheck?.verified && !crashes.length) {
|
|
2237
|
-
phase("verify", `process alive ${formatDuration(processCheck.waitedMs ?? 0)} after launch (${configuration}: no bundle fetch to observe)`);
|
|
2238
|
-
return { state: true };
|
|
2239
|
-
}
|
|
2240
|
-
for (const line of launchErrorPreview(crashes, root)) note(chalk.red(phaseLine("launch", line)));
|
|
2241
|
-
if (!crashes.length) note(phaseLine("logs", missingCrashReportHint({
|
|
2242
|
-
physical,
|
|
2243
|
-
remote: Boolean(remoteDevice),
|
|
2244
|
-
crashed: processCheck?.reason === "exited"
|
|
2245
|
-
})));
|
|
2246
|
-
phase("verify", chalk.yellow(crashes.length ? "FATAL: the app reported a native crash" : processCheck?.reason === "exited" ? `FATAL: the app process exited within ${formatDuration(processCheck.waitedMs ?? 0)} of launch` : physical ? `UNVERIFIED: devicectl could not read ${udid}'s process list` : "UNVERIFIED: simctl launch reported no process id to check"));
|
|
2247
|
-
note(chalk.yellow(phaseLine("", "Release readiness was not established. Run `stim logs --errors` for captured crash reports, or `stim logs --source device` for the full device output.")));
|
|
2248
|
-
return { state: crashes.length || processCheck?.reason === "exited" ? LAUNCH_FATAL : LAUNCH_UNVERIFIED };
|
|
2249
|
-
}
|
|
2250
|
-
const siblings = metroCheck ? siblingPlatformSlots(root, "ios", slot) : [];
|
|
2251
|
-
const verification = metroCheck ? await d.verifyLaunch({
|
|
2252
|
-
requireBundleResponse: true,
|
|
2253
|
-
slot: launchSlotScope(root, slot),
|
|
2254
|
-
appPid: physical || remoteDevice ? null : launched?.pid,
|
|
2255
|
-
platformShared: siblings.length > 0,
|
|
2256
|
-
onReadinessPending: () => phase("readiness", "waiting for app readiness (up to 30s after bundle load)"),
|
|
2257
|
-
logsDir,
|
|
2258
|
-
since: launchedAt,
|
|
2259
|
-
metroPort,
|
|
2260
|
-
platform: "ios",
|
|
2261
|
-
mode: isExpo ? MODE_EXPO : MODE_BARE,
|
|
2262
|
-
readNativeCrashes,
|
|
2263
|
-
processAlive: remoteDevice ? null : physical ? deviceProcess : () => {
|
|
2264
|
-
if (launched?.pid) return d.pidExists(launched.pid);
|
|
2265
|
-
const pid = iosAppProcess(udid, bundleId);
|
|
2266
|
-
return pid === void 0 ? null : pid !== null;
|
|
2267
|
-
}
|
|
2268
|
-
}) : {
|
|
2269
|
-
verified: false,
|
|
2270
|
-
skipped: true
|
|
2271
|
-
};
|
|
2272
|
-
const nativeCrashes = verification.errors?.some((record) => record.event === "native_crash") ? [] : readNativeCrashes();
|
|
2273
|
-
if (nativeCrashes.length) verification.fatal = true;
|
|
2274
|
-
verification.errors = await errorDiagnostics([...verification.errors ?? [], ...nativeCrashes], {
|
|
2275
|
-
root,
|
|
2276
|
-
logsDir,
|
|
2277
|
-
port: metroPort,
|
|
2278
|
-
allowRequest: true
|
|
2279
|
-
});
|
|
2280
|
-
if (verification.readiness) phase("readiness", appReadinessMessage(verification.readiness, verification.waitedMs ?? 0));
|
|
2281
|
-
if (verification?.fatal) {
|
|
2282
|
-
const nativeFatal = verification.errors?.some((record) => record.event === "native_crash");
|
|
2283
|
-
const deliveryFailed = verification.record?.event === "bundle_response_failed";
|
|
2284
|
-
const reason = nativeFatal ? "the app reported a native crash" : verification.processAlive === false ? "the app process exited" : deliveryFailed ? "Metro bundle delivery failed" : "Metro could not build the bundle";
|
|
2285
|
-
phase("verify", chalk.red(`FATAL after ${formatDuration(verification.waitedMs ?? 0)}: ${reason}`));
|
|
2286
|
-
for (const line of launchErrorPreview(verification.errors ?? [], root)) note(chalk.red(phaseLine("", line)));
|
|
2287
|
-
if (verification.processAlive === false && !verification.errors?.some((record) => record.event === "native_crash")) note(phaseLine("logs", missingCrashReportHint({
|
|
2288
|
-
physical,
|
|
2289
|
-
remote: Boolean(remoteDevice),
|
|
2290
|
-
crashed: true
|
|
2291
|
-
})));
|
|
2292
|
-
if (nativeFatal || verification.processAlive === false) note(chalk.yellow(phaseLine("remedy", `Fix the crash, then run \`${runCommand}\` again. A Metro reload cannot restart an exited app.`)));
|
|
2293
|
-
else if (verification.processAlive === true && metroPort !== null) {
|
|
2294
|
-
const reloadRemedy = `press Reload on the app's own error screen -- run \`agent-device snapshot -i --platform ios --udid ${udid}\` in your existing automation session to reach it. Neither \`stim reload ios\` nor \`agent-device metro reload\` can: this app never connected to Metro.`;
|
|
2295
|
-
note(chalk.yellow(phaseLine("remedy", `The native app is still running. ${deliveryFailed ? "Check the Metro logs and device connection, then" : "Fix the JavaScript or TypeScript error, then"} ${reloadRemedy} Do not run \`${runCommand}\` unless native inputs changed or the app process exits.`)));
|
|
2296
|
-
}
|
|
2297
|
-
return { state: LAUNCH_FATAL };
|
|
2298
|
-
}
|
|
2299
|
-
if (verification?.verified) {
|
|
2300
|
-
phase("verify", `bundle loaded` + (verification.processAlive === true ? ", process alive" : "") + (verification.readiness ? "" : ", stable for 3s -- the first screen may still be rendering") + ` (${formatDuration(verification.waitedMs ?? 0)} total)`);
|
|
2301
|
-
const hasAppErrors = reportLaunchErrors(verification.errors ?? [], note, root);
|
|
2302
|
-
if (hasAppErrors && verification.processAlive === true && metroPort !== null) {
|
|
2303
|
-
const reloadRemedy = physical || remoteDevice ? `run \`agent-device metro reload --metro-port ${metroPort}\`.` : "run `stim reload ios`.";
|
|
2304
|
-
note(chalk.yellow(phaseLine("remedy", `The native app is still running. Fix the JavaScript or TypeScript error; Fast Refresh should apply the edit. If the error screen remains, ${reloadRemedy} Do not run \`${runCommand}\` unless native inputs changed or the app process exits.`)));
|
|
2305
|
-
}
|
|
2306
|
-
return {
|
|
2307
|
-
state: true,
|
|
2308
|
-
warning: hasAppErrors ? "app errors detected; inspect the error above" : verification.readiness === "timed-out" || verification.readiness === "error" ? "app readiness not confirmed; inspect the UI and logs" : void 0
|
|
2309
|
-
};
|
|
2310
|
-
}
|
|
2311
|
-
if (verification?.skipped) {
|
|
2312
|
-
phase("verify", "skipped (--no-metro-check): the launch is reported as unverified");
|
|
2313
|
-
return { state: LAUNCH_UNVERIFIED };
|
|
2314
|
-
}
|
|
2315
|
-
if (verification?.requested) {
|
|
2316
|
-
phase("verify", `BUNDLING: the app asked port ${metroPort} for its bundle; build or delivery was still pending after ${formatDuration(verification.waitedMs ?? 0)} (a cold bundle on a large graph outlasts this window)`);
|
|
2317
|
-
note(chalk.dim(phaseLine("", "Nothing to do: `stim logs --source metro` shows the build finishing, usually within a minute.")));
|
|
2318
|
-
return { state: LAUNCH_BUNDLING };
|
|
2319
|
-
}
|
|
2320
|
-
return reportUnverified({
|
|
2321
|
-
verification,
|
|
2322
|
-
siblings,
|
|
2323
|
-
slot,
|
|
2324
|
-
phase,
|
|
2325
|
-
note,
|
|
2326
|
-
metroPort,
|
|
2327
|
-
bundleId,
|
|
2328
|
-
udid,
|
|
2329
|
-
scheme,
|
|
2330
|
-
lanAddress,
|
|
2331
|
-
isExpo,
|
|
2332
|
-
remoteDevice,
|
|
2333
|
-
physical,
|
|
2334
|
-
lanOrigin,
|
|
2335
|
-
metroOrigin,
|
|
2336
|
-
logsDir,
|
|
2337
|
-
launchedAt,
|
|
2338
|
-
launched
|
|
2339
|
-
});
|
|
2340
|
-
}
|
|
2341
|
-
function reportUnverified({ verification, siblings, slot, phase, note, metroPort, bundleId, udid, scheme, lanAddress, isExpo, remoteDevice, physical, lanOrigin, metroOrigin, logsDir, launchedAt, launched }) {
|
|
2342
|
-
if (verification.unattributed) {
|
|
2343
|
-
const [headline, ...lines] = unattributedLaunchLines({
|
|
2344
|
-
platform: "ios",
|
|
2345
|
-
metroPort,
|
|
2346
|
-
slot,
|
|
2347
|
-
siblings
|
|
2348
|
-
});
|
|
2349
|
-
phase("verify", chalk.yellow(headline));
|
|
2350
|
-
for (const line of lines) note(chalk.yellow(phaseLine("", line)));
|
|
2351
|
-
return {
|
|
2352
|
-
state: LAUNCH_UNVERIFIED,
|
|
2353
|
-
unattributed: true
|
|
2354
|
-
};
|
|
2355
|
-
}
|
|
2356
|
-
phase("verify", chalk.yellow("UNVERIFIED: no bundle request reached this workspace's Metro"));
|
|
2357
|
-
for (const line of unverifiedLaunchLines({
|
|
2358
|
-
platform: "ios",
|
|
2359
|
-
metroPort: metroPort ?? 8081,
|
|
2360
|
-
waitedMs: verification.waitedMs,
|
|
2361
|
-
bundleId,
|
|
2362
|
-
udid,
|
|
2363
|
-
devClientUrl: scheme ? launched?.url ?? devClientUrl(scheme, metroPort ?? 8081, lanAddress ?? void 0) : null,
|
|
2364
|
-
mode: isExpo ? MODE_EXPO : MODE_BARE,
|
|
2365
|
-
remote: remoteDevice,
|
|
2366
|
-
physical,
|
|
2367
|
-
devClient: Boolean(scheme),
|
|
2368
|
-
lanOrigin,
|
|
2369
|
-
metroOrigin,
|
|
2370
|
-
localNetworkPending: physical && localNetworkPending(readCollectorRecords(logsDir), {
|
|
2371
|
-
since: launchedAt,
|
|
2372
|
-
pid: launched?.pid ?? null,
|
|
2373
|
-
lanOrigin
|
|
2374
|
-
})
|
|
2375
|
-
})) note(chalk.yellow(phaseLine("", line)));
|
|
2376
|
-
return { state: LAUNCH_UNVERIFIED };
|
|
2377
|
-
}
|
|
2378
|
-
function reportLaunchErrors(errors, note, root) {
|
|
2379
|
-
const report = launchErrorReport(errors, root);
|
|
2380
|
-
if (report.summary) note(chalk.dim(phaseLine("launch", report.summary)));
|
|
2381
|
-
for (const line of report.lines) note(chalk.yellow(phaseLine("launch", line)));
|
|
2382
|
-
return report.lines.length > 0;
|
|
2383
|
-
}
|
|
2384
|
-
function installsOverWifi(d, udid, selectedWireless, note) {
|
|
2385
|
-
const current = d.listIosDevices().find((entry) => entry.udid === udid);
|
|
2386
|
-
const wireless = current ? isWirelessIosDevice(current) : selectedWireless;
|
|
2387
|
-
if (wireless) note(phaseLine("device", `${current?.name ?? udid} is paired over Wi-Fi, so the install and launch go over the network and take longer than over a cable`));
|
|
2388
|
-
return wireless;
|
|
2389
|
-
}
|
|
2390
|
-
function cleanAdoptedIosApps({ d, udid, bundleId, devClient, phase, note }) {
|
|
2391
|
-
const swept = d.clearOtherUserApps({
|
|
2392
|
-
udid,
|
|
2393
|
-
keep: bundleId
|
|
2394
|
-
});
|
|
2395
|
-
if (swept.removed.length) phase("install", `removed ${swept.removed.join(", ")}, left by the previous workspace`);
|
|
2396
|
-
if (swept.listed && swept.failed.length === 0) {
|
|
2397
|
-
if (swept.kept && bundleId) {
|
|
2398
|
-
try {
|
|
2399
|
-
d.clearIosAppData(udid, bundleId, { defaultsPlist: devClient ? IOS_DEV_MENU_OFF_DEFAULTS_PLIST : null });
|
|
2400
|
-
} catch (error) {
|
|
2401
|
-
return `Could not clear the data ${bundleId} kept from the previous workspace: ${String(error?.message || error)}`;
|
|
2402
|
-
}
|
|
2403
|
-
phase("install", `cleared ${bundleId} data left by the previous workspace`);
|
|
2404
|
-
}
|
|
2405
|
-
return null;
|
|
2406
|
-
}
|
|
2407
|
-
if (!swept.listed) return "Could not list apps left by the previous workspace.";
|
|
2408
|
-
for (const failure of swept.failed) note(chalk.yellow(phaseLine("install", `could not remove ${failure}, left by the previous workspace`)));
|
|
2409
|
-
return `Could not remove ${swept.failed.join(", ")}, left by the previous workspace.`;
|
|
2410
|
-
}
|
|
2411
|
-
function installMayBeProven(adopting, parkedCacheKey, storeKey) {
|
|
2412
|
-
return !adopting || !parkedCacheKey || parkedCacheKey === storeKey;
|
|
2413
|
-
}
|
|
2414
|
-
function resolveRunBundleId(d, root, appPath, bundleId) {
|
|
2415
|
-
if (!appPath || bundleId) return bundleId;
|
|
2416
|
-
return d.readBundleId(appPath) || d.detectBundleId(root);
|
|
2417
|
-
}
|
|
2418
|
-
function readRunExecutable(d, appPath, note) {
|
|
2419
|
-
const executable = appPath ? d.readBundleExecutable(appPath) : null;
|
|
2420
|
-
if (appPath && !executable) note(chalk.dim(`Could not read CFBundleExecutable from ${appPath}; the device log predicate falls back to the .app basename.`));
|
|
2421
|
-
return executable;
|
|
2422
|
-
}
|
|
2423
|
-
function recordIosReloadTarget({ d, root, physical, remoteDevice, bundleId, udid, metroPort, release, launchedAt, note }) {
|
|
2424
|
-
if (physical || remoteDevice) return;
|
|
2425
|
-
try {
|
|
2426
|
-
d.writeWorkspaceLaunch(root, "ios", {
|
|
2427
|
-
appId: bundleId,
|
|
2428
|
-
deviceId: udid,
|
|
2429
|
-
metroPort,
|
|
2430
|
-
release,
|
|
2431
|
-
launchedAt: new Date(launchedAt).toISOString()
|
|
2432
|
-
});
|
|
2433
|
-
} catch (error) {
|
|
2434
|
-
note(chalk.yellow(phaseLine("state", `could not record iOS launch: ${error?.message || error}`)));
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
function installFailureRemedy(remoteDevice) {
|
|
2438
|
-
return remoteDevice?.failureRemedy() ?? "Check that the simulator is booted and that the app was built for the simulator SDK.";
|
|
2439
|
-
}
|
|
2440
|
-
function launchFailureRemedy(remoteDevice, udid, bundleId, logFile) {
|
|
2441
|
-
if (remoteDevice) return remoteDevice.failureRemedy();
|
|
2442
|
-
return `If the simulator timed out, run \`stim doctor --platform ios\` and resolve any reported host memory pressure before retrying. Otherwise run \`xcrun simctl launch --terminate-running-process --console ${udid} ${bundleId}\` to see what the app reports, and check ${logFile}.`;
|
|
2443
|
-
}
|
|
2444
|
-
async function finishIosRun({ devicePlacement, artifact, d, root, slot, json, release, configuration, buildScheme, isExpo, metroCheck, metroPort, logsDir, logFile, device, udid, physical, wireless, lanAddress, lanOriginUrl, remoteDevice, bootPromise, bootDuration, fail, phase, note, logWriter, elapsed, startedAt, closeWriter, lease, releaseLease, recordRun, reclaimed, devServer, enterPhase }) {
|
|
2445
|
-
const { path: appPath, bundleId: initialBundleId, failureFields: buildFailure, cache } = artifact;
|
|
2446
|
-
const { hit: cacheHit, providerName, buildMachine, builtOn, offloadedTo, offloadFallback, readEnabled: useBuildCache, missReason, waitedForBuild, compilation: compilationCache } = cache;
|
|
2447
|
-
const storeHash = cache.identity?.fingerprint ?? null;
|
|
2448
|
-
const storeKey = cache.identity?.key ?? null;
|
|
2449
|
-
const runCommand = nativeRunCommand("ios", slot, {
|
|
2450
|
-
physical,
|
|
2451
|
-
deviceId: udid
|
|
2452
|
-
});
|
|
2453
|
-
let bundleId = initialBundleId;
|
|
2454
|
-
let leaseWarned = false;
|
|
2455
|
-
const raiseLeaseFor = (boundMs, beforeInstall) => {
|
|
2456
|
-
const step = lease?.raise(boundMs);
|
|
2457
|
-
if (!step || step.ok) return null;
|
|
2458
|
-
if (beforeInstall) {
|
|
2459
|
-
const refusal = lostRefusal(step.holder, step.expiresAt, d.now());
|
|
2460
|
-
return {
|
|
2461
|
-
code: refusal.code,
|
|
2462
|
-
message: refusal.message,
|
|
2463
|
-
remedy: refusal.remedy,
|
|
2464
|
-
lease: refusal.lease
|
|
2465
|
-
};
|
|
2466
|
-
}
|
|
2467
|
-
if (!leaseWarned) {
|
|
2468
|
-
leaseWarned = true;
|
|
2469
|
-
note(chalk.yellow(phaseLine("lease", lostLine(step.holder, step.expiresAt, d.now()))));
|
|
2470
|
-
}
|
|
2471
|
-
return null;
|
|
2472
|
-
};
|
|
2473
|
-
bundleId = resolveRunBundleId(d, root, appPath, bundleId);
|
|
2474
|
-
if (appPath && !bundleId) return fail({
|
|
2475
|
-
code: "STIM_INSTALL_FAILED",
|
|
2476
|
-
message: `Could not read a bundle identifier from the cached app at ${appPath}.`,
|
|
2477
|
-
remedy: "Remove the cache entry (`stim gc`) and run again to rebuild it.",
|
|
2478
|
-
build: {
|
|
2479
|
-
...buildFailure,
|
|
2480
|
-
appPath
|
|
2481
|
-
}
|
|
2482
|
-
});
|
|
2483
|
-
if (bundleId) d.upsertProject(root, { bundleId });
|
|
2484
|
-
enterPhase("device");
|
|
2485
|
-
const booted = await bootPromise;
|
|
2486
|
-
if (!booted?.ok) return fail({
|
|
2487
|
-
code: booted?.code || "STIM_NO_DEVICE",
|
|
2488
|
-
message: booted?.reason || "The owned simulator could not be booted.",
|
|
2489
|
-
remedy: booted?.remedy || `Run \`${runCommand}\` again to re-establish an owned simulator for this workspace.`
|
|
2490
|
-
});
|
|
2491
|
-
const deviceOutcome = physical ? "connected" : `${device?.adopted ? "adopted" : "booted"} ${bootDuration()}`;
|
|
2492
|
-
phase("device", `${deviceLabel(device, udid)} ${deviceOutcome}`);
|
|
2493
|
-
const scheme = release ? void 0 : d.devClientScheme(root, appPath);
|
|
2494
|
-
const devMenuParams = d.devClientTakesDevMenuParams(root);
|
|
2495
|
-
const appName = appNameFromPath(appPath);
|
|
2496
|
-
const appExecutable = readRunExecutable(d, appPath, note);
|
|
2497
|
-
const dropSwapDir = artifact.release;
|
|
2498
|
-
let installSkipped = false;
|
|
2499
|
-
let launched;
|
|
2500
|
-
let launchedAt = d.now();
|
|
2501
|
-
if (physical) {
|
|
2502
|
-
const overWifi = installsOverWifi(d, udid, wireless, note);
|
|
2503
|
-
const bounds = iosDeviceBounds(overWifi);
|
|
2504
|
-
const lostBeforeInstall = raiseLeaseFor(bounds.installMs, true);
|
|
2505
|
-
if (lostBeforeInstall) return fail(lostBeforeInstall);
|
|
2506
|
-
await d.stopPreviousCollector({
|
|
2507
|
-
root,
|
|
2508
|
-
note
|
|
2509
|
-
});
|
|
2510
|
-
enterPhase("install");
|
|
2511
|
-
const installTimer = stepTimer(d.now);
|
|
2512
|
-
const installed = d.installIosDeviceApp({
|
|
2513
|
-
udid,
|
|
2514
|
-
appPath,
|
|
2515
|
-
bundleId,
|
|
2516
|
-
wireless: overWifi
|
|
2517
|
-
}, { beforeStep: () => raiseLeaseFor(bounds.installMs, false) });
|
|
2518
|
-
if (installed?.failed) {
|
|
2519
|
-
dropSwapDir();
|
|
2520
|
-
return fail({
|
|
2521
|
-
code: installed.code || "STIM_INSTALL_FAILED",
|
|
2522
|
-
message: installed.reason ?? `devicectl could not install ${appPath} on ${udid}.`,
|
|
2523
|
-
remedy: installed.remedy ?? null,
|
|
2524
|
-
build: {
|
|
2525
|
-
...buildFailure,
|
|
2526
|
-
appPath,
|
|
2527
|
-
bundleId
|
|
2528
|
-
}
|
|
2529
|
-
});
|
|
2530
|
-
}
|
|
2531
|
-
phase("install", `${basename(appPath)} -> ${deviceLabel(device, udid)} ${installTimer()}`);
|
|
2532
|
-
if (installed?.note) {
|
|
2533
|
-
note(chalk.yellow(phaseLine("install", installed.note)));
|
|
2534
|
-
logWriter().write({
|
|
2535
|
-
src: "build",
|
|
2536
|
-
level: "warn",
|
|
2537
|
-
event: "install_uninstalled_first",
|
|
2538
|
-
msg: installed.note
|
|
2539
|
-
});
|
|
2540
|
-
}
|
|
2541
|
-
dropSwapDir();
|
|
2542
|
-
raiseLeaseFor(COLLECTOR_EXIT_WAIT_MS + bounds.launchMs, false);
|
|
2543
|
-
const payloadUrl = scheme && metroPort !== null && lanAddress ? devClientUrl(scheme, metroPort, lanAddress) : null;
|
|
2544
|
-
enterPhase("launch");
|
|
2545
|
-
const launchTimer = stepTimer(d.now);
|
|
2546
|
-
launchedAt = d.now();
|
|
2547
|
-
logWriter().write({
|
|
2548
|
-
src: "build",
|
|
2549
|
-
level: "info",
|
|
2550
|
-
marker: true,
|
|
2551
|
-
event: "launch_attempt",
|
|
2552
|
-
ts: launchedAt,
|
|
2553
|
-
platform: "ios",
|
|
2554
|
-
appId: bundleId,
|
|
2555
|
-
deviceId: udid,
|
|
2556
|
-
appPath,
|
|
2557
|
-
physical: true,
|
|
2558
|
-
msg: `launching ${bundleId} on ${udid}`
|
|
2559
|
-
});
|
|
2560
|
-
const collector = await d.replaceCollector({
|
|
2561
|
-
root,
|
|
2562
|
-
slot,
|
|
2563
|
-
udid,
|
|
2564
|
-
bundleId,
|
|
2565
|
-
appName,
|
|
2566
|
-
physical: true,
|
|
2567
|
-
payloadUrl,
|
|
2568
|
-
note
|
|
2569
|
-
});
|
|
2570
|
-
if (!collector?.pid) return fail({
|
|
2571
|
-
code: "STIM_LAUNCH_FAILED",
|
|
2572
|
-
message: `The device log collector, which is what launches ${bundleId} on a phone, could not be started.`,
|
|
2573
|
-
remedy: `Check ${logFile} and the workspace collector log, then run the command again.`,
|
|
2574
|
-
build: {
|
|
2575
|
-
...buildFailure,
|
|
2576
|
-
appPath,
|
|
2577
|
-
bundleId
|
|
2578
|
-
}
|
|
2579
|
-
});
|
|
2580
|
-
const started = await d.awaitIosDeviceLaunch({
|
|
2581
|
-
udid,
|
|
2582
|
-
bundleId,
|
|
2583
|
-
appName: appName ?? bundleId,
|
|
2584
|
-
collectorPid: collector.pid,
|
|
2585
|
-
wireless: overWifi,
|
|
2586
|
-
readRecords: () => readCollectorRecords(logsDir).filter((entry) => Number(entry.ts) >= launchedAt && (entry.slot ?? "default") === (slot ?? "default"))
|
|
2587
|
-
});
|
|
2588
|
-
if (started.failed || !started.pid) return fail({
|
|
2589
|
-
code: started.code ?? "STIM_LAUNCH_FAILED",
|
|
2590
|
-
message: started.reason ?? `${bundleId} did not start on ${udid}.`,
|
|
2591
|
-
remedy: started.remedy ?? null,
|
|
2592
|
-
lines: started.lines ?? [],
|
|
2593
|
-
logPath: logsDir,
|
|
2594
|
-
build: {
|
|
2595
|
-
...buildFailure,
|
|
2596
|
-
appPath,
|
|
2597
|
-
bundleId
|
|
2598
|
-
}
|
|
2599
|
-
});
|
|
2600
|
-
launched = {
|
|
2601
|
-
ok: true,
|
|
2602
|
-
mode: payloadUrl ? "payload-url" : "launch",
|
|
2603
|
-
pid: started.pid,
|
|
2604
|
-
...payloadUrl ? { url: payloadUrl } : {},
|
|
2605
|
-
...lanOriginUrl ? { jsLocation: lanOriginUrl } : {}
|
|
2606
|
-
};
|
|
2607
|
-
phase("launch", `${bundleId} pid ${started.pid} ${launchTimer()}`);
|
|
2608
|
-
} else {
|
|
2609
|
-
const adopting = Boolean(device?.adoptionPending);
|
|
2610
|
-
if (adopting) {
|
|
2611
|
-
const cleanupFailure = cleanAdoptedIosApps({
|
|
2612
|
-
d,
|
|
2613
|
-
udid,
|
|
2614
|
-
bundleId,
|
|
2615
|
-
devClient: Boolean(scheme),
|
|
2616
|
-
phase,
|
|
2617
|
-
note
|
|
2618
|
-
});
|
|
2619
|
-
if (cleanupFailure) return fail({
|
|
2620
|
-
code: "STIM_INSTALL_FAILED",
|
|
2621
|
-
message: `${cleanupFailure} Stim kept the adoption cleanup pending and did not install or launch the app.`,
|
|
2622
|
-
remedy: `Run \`${runCommand}\` again after simulator tooling is responsive.`,
|
|
2623
|
-
build: {
|
|
2624
|
-
...buildFailure,
|
|
2625
|
-
appPath,
|
|
2626
|
-
bundleId
|
|
2627
|
-
}
|
|
2628
|
-
});
|
|
2629
|
-
}
|
|
2630
|
-
enterPhase("install");
|
|
2631
|
-
const installTimer = stepTimer(d.now);
|
|
2632
|
-
const installed = d.installIosApp({
|
|
2633
|
-
udid,
|
|
2634
|
-
appPath,
|
|
2635
|
-
bundleId,
|
|
2636
|
-
devClientScheme: scheme,
|
|
2637
|
-
schemeApprovals: device.schemeApprovals,
|
|
2638
|
-
proveInstalled: installMayBeProven(adopting, device?.parkedCacheKey, storeKey)
|
|
2639
|
-
}, { now: d.now });
|
|
2640
|
-
if (installed?.failed) return fail({
|
|
2641
|
-
code: installed.code || "STIM_INSTALL_FAILED",
|
|
2642
|
-
message: installed.reason,
|
|
2643
|
-
remedy: installFailureRemedy(remoteDevice),
|
|
2644
|
-
build: {
|
|
2645
|
-
...buildFailure,
|
|
2646
|
-
appPath,
|
|
2647
|
-
bundleId
|
|
2648
|
-
}
|
|
2649
|
-
});
|
|
2650
|
-
if (adopting) d.clearIosAdoptionPending(root, slot);
|
|
2651
|
-
installSkipped = Boolean(installed?.skipped);
|
|
2652
|
-
const artifactDuration = installed?.artifactDurationMs === void 0 ? installTimer() : `(${formatDuration(installed.artifactDurationMs)})`;
|
|
2653
|
-
phase("install", installSkipped ? `unchanged (${deviceShortName(device, udid)} already has this build) ${artifactDuration}` : `${basename(appPath)} -> ${deviceLabel(device, udid)} ${artifactDuration}`);
|
|
2654
|
-
if (!remoteDevice && installed?.devClientPreparationDurationMs !== void 0) phase("install", `dev client prepared (${formatDuration(installed.devClientPreparationDurationMs)})`);
|
|
2655
|
-
if (installed.schemeApprovals) d.recordIosSchemeApprovals(root, udid, installed.schemeApprovals, slot);
|
|
2656
|
-
dropSwapDir();
|
|
2657
|
-
if (!remoteDevice) await d.replaceCollector({
|
|
2658
|
-
root,
|
|
2659
|
-
slot,
|
|
2660
|
-
udid,
|
|
2661
|
-
bundleId,
|
|
2662
|
-
appName,
|
|
2663
|
-
appExecutable,
|
|
2664
|
-
note
|
|
2665
|
-
});
|
|
2666
|
-
enterPhase("launch");
|
|
2667
|
-
const launchTimer = stepTimer(d.now);
|
|
2668
|
-
launchedAt = d.now();
|
|
2669
|
-
logWriter().write({
|
|
2670
|
-
src: "build",
|
|
2671
|
-
level: "info",
|
|
2672
|
-
marker: true,
|
|
2673
|
-
event: "launch_attempt",
|
|
2674
|
-
ts: launchedAt,
|
|
2675
|
-
platform: "ios",
|
|
2676
|
-
appId: bundleId,
|
|
2677
|
-
deviceId: udid,
|
|
2678
|
-
appPath,
|
|
2679
|
-
remote: Boolean(remoteDevice),
|
|
2680
|
-
msg: `launching ${bundleId} on ${udid}`
|
|
2681
|
-
});
|
|
2682
|
-
launched = d.launchIosApp({
|
|
2683
|
-
udid,
|
|
2684
|
-
bundleId,
|
|
2685
|
-
metroPort,
|
|
2686
|
-
devClientScheme: scheme,
|
|
2687
|
-
devMenuParams,
|
|
2688
|
-
consolePaths: simulatorConsolePaths({
|
|
2689
|
-
deviceId: udid,
|
|
2690
|
-
appId: bundleId,
|
|
2691
|
-
since: launchedAt
|
|
2692
|
-
}, true, Boolean(remoteDevice))
|
|
2693
|
-
});
|
|
2694
|
-
if (launched.failed) {
|
|
2695
|
-
printNativeCrashReport({
|
|
2696
|
-
root,
|
|
2697
|
-
slot,
|
|
2698
|
-
platform: "ios",
|
|
2699
|
-
deviceId: udid,
|
|
2700
|
-
appId: bundleId,
|
|
2701
|
-
since: launchedAt,
|
|
2702
|
-
appPath
|
|
2703
|
-
}, logsDir, (line) => note(chalk.red(phaseLine("launch", line))), Boolean(remoteDevice));
|
|
2704
|
-
return fail({
|
|
2705
|
-
code: launched.code || "STIM_LAUNCH_FAILED",
|
|
2706
|
-
message: launched.reason,
|
|
2707
|
-
remedy: launchFailureRemedy(remoteDevice, udid, bundleId, logFile),
|
|
2708
|
-
build: {
|
|
2709
|
-
...buildFailure,
|
|
2710
|
-
appPath,
|
|
2711
|
-
bundleId
|
|
2712
|
-
}
|
|
2713
|
-
});
|
|
2714
|
-
}
|
|
2715
|
-
phase("launch", `${bundleId}${restartedAppNote(launched.restartedPid)} ${launchTimer()}`);
|
|
2716
|
-
}
|
|
2717
|
-
recordIosReloadTarget({
|
|
2718
|
-
d,
|
|
2719
|
-
root,
|
|
2720
|
-
slot,
|
|
2721
|
-
physical,
|
|
2722
|
-
remoteDevice: Boolean(remoteDevice),
|
|
2723
|
-
bundleId,
|
|
2724
|
-
udid,
|
|
2725
|
-
metroPort,
|
|
2726
|
-
release,
|
|
2727
|
-
launchedAt,
|
|
2728
|
-
note
|
|
2729
|
-
});
|
|
2730
|
-
logWriter().write({
|
|
2731
|
-
src: "build",
|
|
2732
|
-
level: "info",
|
|
2733
|
-
event: "launch",
|
|
2734
|
-
msg: release ? `launched ${bundleId} on ${udid} (${configuration}, embedded JS bundle, no Metro)` : `launched ${bundleId} on ${udid} against Metro ${lanOriginUrl ?? `port ${metroPort}`}` + (launched?.mode === "openurl" || launched?.mode === "payload-url" ? " (expo-dev-client)" : "") + restartedAppNote(launched.restartedPid, "; ")
|
|
2735
|
-
});
|
|
2736
|
-
if (remoteDevice) logWriter().write({
|
|
2737
|
-
src: "build",
|
|
2738
|
-
level: "info",
|
|
2739
|
-
event: "collector_skipped",
|
|
2740
|
-
msg: `remote session ${udid}: device logs come from agent-device/EAS, so no simctl log stream is attached`
|
|
2741
|
-
});
|
|
2742
|
-
if (physical) raiseLeaseFor(release ? RELEASE_VERIFY_WAIT_MS : DEBUG_VERIFY_STEP_MS, false);
|
|
2743
|
-
const { state: launchState, warning: launchWarning, unattributed } = await verifyIosRun({
|
|
2744
|
-
root,
|
|
2745
|
-
slot,
|
|
2746
|
-
appPath,
|
|
2747
|
-
d,
|
|
2748
|
-
release,
|
|
2749
|
-
launched,
|
|
2750
|
-
configuration,
|
|
2751
|
-
phase,
|
|
2752
|
-
note,
|
|
2753
|
-
metroCheck,
|
|
2754
|
-
logsDir,
|
|
2755
|
-
launchedAt,
|
|
2756
|
-
metroPort,
|
|
2757
|
-
isExpo,
|
|
2758
|
-
bundleId,
|
|
2759
|
-
udid,
|
|
2760
|
-
scheme,
|
|
2761
|
-
physical,
|
|
2762
|
-
appName,
|
|
2763
|
-
lanAddress,
|
|
2764
|
-
lanOrigin: lanOriginUrl,
|
|
2765
|
-
remoteDevice: Boolean(remoteDevice),
|
|
2766
|
-
metroOrigin: typeof launched?.jsLocation === "string" ? launched.jsLocation : null
|
|
2767
|
-
});
|
|
2768
|
-
if (launchState === "fatal") return fail({
|
|
2769
|
-
code: "STIM_LAUNCH_FAILED",
|
|
2770
|
-
message: "The app failed its launch readiness check.",
|
|
2771
|
-
remedy: `Read the launch error above or run \`stim logs --errors\`. The full timeline is in ${logsDir}.`,
|
|
2772
|
-
logPath: logsDir,
|
|
2773
|
-
build: {
|
|
2774
|
-
...buildFailure,
|
|
2775
|
-
appPath,
|
|
2776
|
-
bundleId
|
|
2777
|
-
}
|
|
2778
|
-
});
|
|
2779
|
-
logWriter().write(launchOutcomeRecord({
|
|
2780
|
-
launchState,
|
|
2781
|
-
release,
|
|
2782
|
-
bundleId,
|
|
2783
|
-
configuration,
|
|
2784
|
-
metroPort,
|
|
2785
|
-
unattributed
|
|
2786
|
-
}));
|
|
2787
|
-
const leaseFacts = lease?.facts() ?? null;
|
|
2788
|
-
releaseLease();
|
|
2789
|
-
const uploadsAbandoned = await artifact.completeUploads();
|
|
2790
|
-
return {
|
|
2791
|
-
facts: reportIosResult({
|
|
2792
|
-
devicePlacement,
|
|
2793
|
-
root,
|
|
2794
|
-
slot,
|
|
2795
|
-
json,
|
|
2796
|
-
release,
|
|
2797
|
-
configuration,
|
|
2798
|
-
buildScheme,
|
|
2799
|
-
metroCheck,
|
|
2800
|
-
metroPort,
|
|
2801
|
-
logsDir,
|
|
2802
|
-
device,
|
|
2803
|
-
udid,
|
|
2804
|
-
appPath,
|
|
2805
|
-
bundleId,
|
|
2806
|
-
installSkipped,
|
|
2807
|
-
elapsed,
|
|
2808
|
-
startedAt,
|
|
2809
|
-
storeHash,
|
|
2810
|
-
storeKey,
|
|
2811
|
-
cacheHit,
|
|
2812
|
-
missReason,
|
|
2813
|
-
compilationCache,
|
|
2814
|
-
useBuildCache,
|
|
2815
|
-
waitedForBuild,
|
|
2816
|
-
launchState,
|
|
2817
|
-
launchWarning,
|
|
2818
|
-
providerName,
|
|
2819
|
-
buildMachine,
|
|
2820
|
-
builtOn,
|
|
2821
|
-
offloadedTo,
|
|
2822
|
-
offloadFallback,
|
|
2823
|
-
closeWriter,
|
|
2824
|
-
webPreviewUrl: remoteDevice?.webPreviewUrl() ?? null,
|
|
2825
|
-
lease: physical ? leaseFacts : void 0,
|
|
2826
|
-
recordRun,
|
|
2827
|
-
reclaimed,
|
|
2828
|
-
devServer,
|
|
2829
|
-
links: workspaceLinks(root, {
|
|
2830
|
-
platform: "ios",
|
|
2831
|
-
slot
|
|
2832
|
-
})
|
|
2833
|
-
}),
|
|
2834
|
-
uploadsAbandoned
|
|
2835
|
-
};
|
|
2836
|
-
}
|
|
2837
|
-
//#endregion
|
|
2838
|
-
//#region src/commands/ios/next-build.ts
|
|
2839
|
-
function note(line) {
|
|
2840
|
-
console.error(line);
|
|
2841
|
-
}
|
|
2842
|
-
function runOnlyFlag(opts) {
|
|
2843
|
-
if (isPhysicalDeviceRequest(opts.device)) return "--device";
|
|
2844
|
-
if (opts.remote) return "--remote";
|
|
2845
|
-
if (opts.wait !== void 0) return opts.wait === false ? "--no-wait" : "--wait";
|
|
2846
|
-
if (opts.simulatorApp !== void 0) return "--simulator-app";
|
|
2847
|
-
if (opts.metroCheck === false) return "--no-metro-check";
|
|
2848
|
-
return null;
|
|
2849
|
-
}
|
|
2850
|
-
async function planIos(opts, d, schemeRefusal) {
|
|
2851
|
-
const json = Boolean(opts.json);
|
|
2852
|
-
const refuse = (refusal, lines = []) => refusePlan(refusal, json, lines);
|
|
2853
|
-
const flag = runOnlyFlag(opts);
|
|
2854
|
-
if (flag) return refuse(planFlagRefusal(flag));
|
|
2855
|
-
const root = d.findProjectRoot(process.cwd());
|
|
2856
|
-
if (!root) return refuse(NO_PROJECT_REFUSAL);
|
|
2857
|
-
const projectProblem = appProjectProblem(root);
|
|
2858
|
-
if (projectProblem) return refuse({
|
|
2859
|
-
code: "STIM_NO_PROJECT",
|
|
2860
|
-
...projectProblem
|
|
2861
|
-
});
|
|
2862
|
-
const settingsContext = {
|
|
2863
|
-
projectPath: root,
|
|
2864
|
-
gitCommonDir: d.gitCommonDir(root),
|
|
2865
|
-
repoRoot: d.repoRoot(root)
|
|
2866
|
-
};
|
|
2867
|
-
const settings = d.resolveSettings(settingsContext);
|
|
2868
|
-
const [shapeError, ...moreShapeErrors] = settingShapeErrors(settings);
|
|
2869
|
-
if (shapeError) return refuse({
|
|
2870
|
-
code: "STIM_BAD_ARG",
|
|
2871
|
-
message: shapeError,
|
|
2872
|
-
remedy: SETTING_SHAPE_REMEDY
|
|
2873
|
-
}, moreShapeErrors);
|
|
2874
|
-
let optimizations;
|
|
2875
|
-
try {
|
|
2876
|
-
optimizations = resolveOptimizations(settings);
|
|
2877
|
-
} catch (error) {
|
|
2878
|
-
return refuse({
|
|
2879
|
-
code: "STIM_BAD_ARG",
|
|
2880
|
-
message: error.message,
|
|
2881
|
-
remedy: SETTING_SHAPE_REMEDY
|
|
2882
|
-
});
|
|
2883
|
-
}
|
|
2884
|
-
const cacheProviderError = cacheProviderSettingError(settings);
|
|
2885
|
-
if (cacheProviderError) note(chalk.yellow(phaseLine("cache", `${cacheProviderError} Using the local cache.`)));
|
|
2886
|
-
const slot = opts.slot ?? "default";
|
|
2887
|
-
const target = {
|
|
2888
|
-
platform: "ios",
|
|
2889
|
-
slot,
|
|
2890
|
-
root,
|
|
2891
|
-
projectKey: statsProjectKey$1({
|
|
2892
|
-
root,
|
|
2893
|
-
commonDir: settingsContext.gitCommonDir,
|
|
2894
|
-
repoRoot: settingsContext.repoRoot
|
|
2895
|
-
})
|
|
2896
|
-
};
|
|
2897
|
-
const isExpo = d.detectIsExpo(root);
|
|
2898
|
-
const settingsLayersForOrigin = d.settingsLayers(settingsContext);
|
|
2899
|
-
const iosRemote = remoteIosSetting(settings);
|
|
2900
|
-
const modelRefusal = deviceModelRefusal({
|
|
2901
|
-
slot,
|
|
2902
|
-
deviceTypeFlag: opts.deviceType,
|
|
2903
|
-
runtimeFlag: opts.runtime,
|
|
2904
|
-
deviceType: resolveDeviceType(opts.deviceType, settings),
|
|
2905
|
-
runtime: resolveRuntime(opts.runtime, settings),
|
|
2906
|
-
deviceTypeOrigin: d.settingOriginScope(settingsLayersForOrigin, "ios.deviceType"),
|
|
2907
|
-
runtimeOrigin: d.settingOriginScope(settingsLayersForOrigin, "ios.runtime"),
|
|
2908
|
-
physical: false,
|
|
2909
|
-
remoteBackend: iosRemote?.kind === "backend" ? iosRemote.backend : null,
|
|
2910
|
-
hosted: iosRemote?.kind === "machine",
|
|
2911
|
-
listRuntimes: d.listIosRuntimes
|
|
2912
|
-
});
|
|
2913
|
-
if (modelRefusal) return refuse(modelRefusal);
|
|
2914
|
-
if (opts.easProfile !== void 0) {
|
|
2915
|
-
const eas = await planEasDevelopmentBuild({
|
|
2916
|
-
root,
|
|
2917
|
-
platform: "ios",
|
|
2918
|
-
profile: opts.easProfile,
|
|
2919
|
-
note,
|
|
2920
|
-
isExpo,
|
|
2921
|
-
selectors: [opts.scheme, opts.configuration],
|
|
2922
|
-
buildCache: opts.buildCache
|
|
2923
|
-
});
|
|
2924
|
-
if (!eas.ok) return refuse(eas);
|
|
2925
|
-
return printPlan(planPayload(target, {
|
|
2926
|
-
fingerprint: eas.fingerprint,
|
|
2927
|
-
cacheKey: eas.cacheKey,
|
|
2928
|
-
cacheHit: eas.buildId ? "remote" : false,
|
|
2929
|
-
provider: "eas",
|
|
2930
|
-
cacheSkipped: false,
|
|
2931
|
-
prebuild: null,
|
|
2932
|
-
refusal: eas.missing
|
|
2933
|
-
}), json);
|
|
2934
|
-
}
|
|
2935
|
-
const remoteBackend = remoteIosSetting(settings);
|
|
2936
|
-
if (remoteBackend) return refuse({
|
|
2937
|
-
code: "STIM_BAD_ARG",
|
|
2938
|
-
message: `ios.remote routes this workspace's runs to a ${remoteBackend.kind === "backend" ? remoteBackend.backend : remoteBackend.machine} device, whose architecture --plan cannot read without a session.`,
|
|
2939
|
-
remedy: "Run `stim ios` to build for the remote device, or unset ios.remote to plan the owned simulator."
|
|
2940
|
-
});
|
|
2941
|
-
const refusal = schemeRefusal(root, opts.scheme, isExpo);
|
|
2942
|
-
if (refusal) return refuse({
|
|
2943
|
-
code: refusal.code,
|
|
2944
|
-
message: refusal.message ?? "",
|
|
2945
|
-
remedy: refusal.remedy ?? ""
|
|
2946
|
-
});
|
|
2947
|
-
const configuration = resolveConfiguration(opts.configuration, settings);
|
|
2948
|
-
const buildProfile = optimizationBuildProfile("ios", optimizations);
|
|
2949
|
-
const cachePolicy = artifactCachePolicy(optimizations, opts.buildCache !== false, isReleaseConfiguration(configuration));
|
|
2950
|
-
let fingerprint;
|
|
2951
|
-
try {
|
|
2952
|
-
fingerprint = await d.fingerprintProject(root, { platform: "ios" });
|
|
2953
|
-
} catch (error) {
|
|
2954
|
-
note(chalk.dim(`Fingerprinting failed: ${error?.message || error}`));
|
|
2955
|
-
}
|
|
2956
|
-
if (!fingerprint?.hash) return refuse({
|
|
2957
|
-
code: "STIM_NO_FINGERPRINT",
|
|
2958
|
-
message: `Could not fingerprint ${root}: @expo/fingerprint produced no hash for it.`,
|
|
2959
|
-
remedy: "Check the project native inputs and the @expo/fingerprint error above, then retry."
|
|
2960
|
-
});
|
|
2961
|
-
const arch = simulatorBuildArch({
|
|
2962
|
-
physical: false,
|
|
2963
|
-
remoteArch: null,
|
|
2964
|
-
hostArch: d.hostSimulatorArch(),
|
|
2965
|
-
configuration
|
|
2966
|
-
});
|
|
2967
|
-
const cacheKey = buildCacheKey("ios", fingerprint.hash, {
|
|
2968
|
-
scheme: opts.scheme,
|
|
2969
|
-
...configuration ? { configuration } : {},
|
|
2970
|
-
isSimulator: true,
|
|
2971
|
-
...arch ? { arch } : {},
|
|
2972
|
-
...buildProfile ? { buildProfile } : {}
|
|
2973
|
-
});
|
|
2974
|
-
const plan = await planCachedBuild({
|
|
2975
|
-
...target,
|
|
2976
|
-
isExpo,
|
|
2977
|
-
fingerprint: fingerprint.hash,
|
|
2978
|
-
sources: fingerprint.sources ?? [],
|
|
2979
|
-
cacheKey,
|
|
2980
|
-
cachePolicy,
|
|
2981
|
-
providerConfig: d.resolveCacheProviderConfig(settingsContext),
|
|
2982
|
-
expoRemote: cachePolicy.remote && !buildProfile && !opts.scheme ? { runOptions: iosProviderRunOptions(configuration, arch) } : null
|
|
2983
|
-
}, {
|
|
2984
|
-
loadCacheProvider: d.loadCacheProvider,
|
|
2985
|
-
loadProjectProvider: d.loadProjectProvider,
|
|
2986
|
-
checkEasAuth: d.checkEasAuth,
|
|
2987
|
-
resolveRemote: d.resolveRemote,
|
|
2988
|
-
planPrebuild: d.planPrebuild,
|
|
2989
|
-
note
|
|
2990
|
-
});
|
|
2991
|
-
printPlan(plan, json);
|
|
2992
|
-
}
|
|
2993
|
-
//#endregion
|
|
2994
|
-
//#region src/commands/ios.ts
|
|
2995
|
-
function writeNote(line) {
|
|
2996
|
-
console.error(line);
|
|
2997
|
-
}
|
|
2998
|
-
function writePhase(name, text) {
|
|
2999
|
-
console.error(phaseLine(name, text));
|
|
3000
|
-
}
|
|
3001
|
-
function iosCommand(program) {
|
|
3002
|
-
registerIos(program);
|
|
3003
|
-
}
|
|
3004
|
-
function registerIos(program, deps = {}) {
|
|
3005
|
-
program.command("ios").description("Build (or restore from the fingerprint cache), install and launch this workspace's app on its owned simulator, wired to the reserved Metro port. A Debug run starts 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.", (value) => {
|
|
3006
|
-
if (parseMachine(value)) return value.trim();
|
|
3007
|
-
throw new InvalidArgumentError("expected eas, proxy, auto, or a remote Mac name");
|
|
3008
|
-
}).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) => {
|
|
3009
|
-
if (opts.plan) {
|
|
3010
|
-
const d = {
|
|
3011
|
-
...DEFAULT_DEPS,
|
|
3012
|
-
...deps
|
|
3013
|
-
};
|
|
3014
|
-
await planIos(opts, d, (root, scheme, isExpo) => explicitSchemeRefusal(root, scheme, isExpo, d));
|
|
3015
|
-
return;
|
|
3016
|
-
}
|
|
3017
|
-
const root = (deps.findProjectRoot ?? DEFAULT_DEPS.findProjectRoot)(process.cwd());
|
|
3018
|
-
const run = (progress) => runIos({
|
|
3019
|
-
...opts,
|
|
3020
|
-
waitConflict: waitFlagConflict(process.argv)
|
|
3021
|
-
}, deps, progress);
|
|
3022
|
-
const completion = root ? await withNativeBuildRun(root, {
|
|
3023
|
-
command: "ios",
|
|
3024
|
-
platform: "ios",
|
|
3025
|
-
slot: opts.slot ?? "default"
|
|
3026
|
-
}, async (claim) => {
|
|
3027
|
-
recordWorkspaceUse(root);
|
|
3028
|
-
const progress = startBuildProgress({
|
|
3029
|
-
root,
|
|
3030
|
-
platform: "ios",
|
|
3031
|
-
slot: opts.slot ?? "default",
|
|
3032
|
-
claim,
|
|
3033
|
-
note: (line) => writeNote(chalk.dim(line))
|
|
3034
|
-
});
|
|
3035
|
-
try {
|
|
3036
|
-
return await run(progress);
|
|
3037
|
-
} finally {
|
|
3038
|
-
progress.clear();
|
|
3039
|
-
}
|
|
3040
|
-
}, { write: (line) => writeNote(chalk.dim(phaseLine("lock", line))) }) : await run();
|
|
3041
|
-
if (!completion) process.exit(runCancellation() ? 130 : 1);
|
|
3042
|
-
else if (completion.uploadsAbandoned) exitAfterFlush(0);
|
|
3043
|
-
});
|
|
3044
|
-
}
|
|
3045
|
-
function unlessCancelled(result) {
|
|
3046
|
-
if (!result.ok || !runCancellation()) return result;
|
|
3047
|
-
return {
|
|
3048
|
-
ok: false,
|
|
3049
|
-
failure: {
|
|
3050
|
-
code: "STIM_CANCELLED",
|
|
3051
|
-
message: "before install"
|
|
3052
|
-
},
|
|
3053
|
-
compilationCache: result.artifact.cache.compilation
|
|
3054
|
-
};
|
|
3055
|
-
}
|
|
3056
|
-
function explicitSchemeRefusal(root, scheme, isExpo, d) {
|
|
3057
|
-
if (scheme === void 0) return null;
|
|
3058
|
-
if (!scheme.trim()) return {
|
|
3059
|
-
code: "STIM_BAD_ARG",
|
|
3060
|
-
message: "--scheme must name a non-empty shared Xcode app scheme.",
|
|
3061
|
-
remedy: "Pass the exact scheme name shown by xcodebuild -list."
|
|
3062
|
-
};
|
|
3063
|
-
if (isExpo) return null;
|
|
3064
|
-
const project = d.discoverXcodeProject(root);
|
|
3065
|
-
if (project.error) return project.error;
|
|
3066
|
-
return d.resolveScheme(project, { scheme }).error ?? null;
|
|
3067
|
-
}
|
|
3068
|
-
function resolveIosBuildSetup(flag, settings) {
|
|
3069
|
-
const placement = resolveBuildPlacement(flag);
|
|
3070
|
-
if (placement.failure) return {
|
|
3071
|
-
ok: false,
|
|
3072
|
-
failure: {
|
|
3073
|
-
...placement.failure,
|
|
3074
|
-
setup: true
|
|
3075
|
-
}
|
|
3076
|
-
};
|
|
3077
|
-
try {
|
|
3078
|
-
return {
|
|
3079
|
-
ok: true,
|
|
3080
|
-
buildMachine: placement.selected,
|
|
3081
|
-
optimizations: resolveOptimizations(settings)
|
|
3082
|
-
};
|
|
3083
|
-
} catch (error) {
|
|
3084
|
-
return {
|
|
3085
|
-
ok: false,
|
|
3086
|
-
failure: {
|
|
3087
|
-
code: "STIM_BAD_ARG",
|
|
3088
|
-
message: error.message,
|
|
3089
|
-
remedy: SETTING_SHAPE_REMEDY
|
|
3090
|
-
}
|
|
3091
|
-
};
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
function iosSlotLogFile(root, slot) {
|
|
3095
|
-
return slot === "default" ? buildLogFile(root) : join(workspaceLogsDir$1(root), `build-${deviceSlotFileKey("ios", slot)}.ndjson`);
|
|
3096
|
-
}
|
|
3097
|
-
function iosSlotDeps(d, slot) {
|
|
3098
|
-
if (slot !== "default") {
|
|
3099
|
-
const base = d;
|
|
3100
|
-
d = {
|
|
3101
|
-
...base,
|
|
3102
|
-
ensureOwnedDevice: (args) => base.ensureOwnedDevice({
|
|
3103
|
-
...args,
|
|
3104
|
-
slot
|
|
3105
|
-
}),
|
|
3106
|
-
checkDeviceCapacity: (args) => base.checkDeviceCapacity({
|
|
3107
|
-
...args,
|
|
3108
|
-
slot
|
|
3109
|
-
}),
|
|
3110
|
-
selectFromPool: (args) => base.selectFromPool({
|
|
3111
|
-
...args,
|
|
3112
|
-
slot
|
|
3113
|
-
}),
|
|
3114
|
-
acquireRunLease: (args) => base.acquireRunLease({
|
|
3115
|
-
...args,
|
|
3116
|
-
slot
|
|
3117
|
-
}),
|
|
3118
|
-
runLease: (args) => base.runLease({
|
|
3119
|
-
...args,
|
|
3120
|
-
slot
|
|
3121
|
-
}),
|
|
3122
|
-
replaceCollector: (args) => base.replaceCollector({
|
|
3123
|
-
...args,
|
|
3124
|
-
slot
|
|
3125
|
-
}),
|
|
3126
|
-
stopPreviousCollector: (args) => base.stopPreviousCollector({
|
|
3127
|
-
...args,
|
|
3128
|
-
slot
|
|
3129
|
-
}),
|
|
3130
|
-
clearIosAdoptionPending: (root) => base.clearIosAdoptionPending(root, slot),
|
|
3131
|
-
writeWorkspaceLaunch: (root, platform, record) => base.writeWorkspaceLaunch(root, platform, record, slot),
|
|
3132
|
-
createWriter: (file, options) => base.createWriter(file, {
|
|
3133
|
-
...options,
|
|
3134
|
-
fields: { slot }
|
|
3135
|
-
})
|
|
3136
|
-
};
|
|
3137
|
-
}
|
|
3138
|
-
return d;
|
|
3139
|
-
}
|
|
3140
|
-
async function runIos(opts = {}, overrides = {}, progress = NO_BUILD_PROGRESS) {
|
|
3141
|
-
const slot = validateDeviceSlot(opts.slot);
|
|
3142
|
-
let d = iosSlotDeps({
|
|
3143
|
-
...DEFAULT_DEPS,
|
|
3144
|
-
...overrides
|
|
3145
|
-
}, slot);
|
|
3146
|
-
const json = Boolean(opts.json);
|
|
3147
|
-
const metroCheck = opts.metroCheck !== false;
|
|
3148
|
-
let useBuildCache = opts.buildCache !== false;
|
|
3149
|
-
const phase = writePhase;
|
|
3150
|
-
const note = writeNote;
|
|
3151
|
-
const started = d.now();
|
|
3152
|
-
const startedAt = new Date(started).toISOString();
|
|
3153
|
-
const elapsed = () => d.now() - started;
|
|
3154
|
-
const refuseProject = ({ message, remedy }) => {
|
|
3155
|
-
note(chalk.red(phaseLine("error", message)));
|
|
3156
|
-
note(chalk.dim(phaseLine("remedy", remedy)));
|
|
3157
|
-
note(chalk.red(phaseLine("failed", "STIM_NO_PROJECT")));
|
|
3158
|
-
if (json) console.log(JSON.stringify({
|
|
3159
|
-
code: "STIM_NO_PROJECT",
|
|
3160
|
-
message,
|
|
3161
|
-
remedy
|
|
3162
|
-
}));
|
|
3163
|
-
process.exitCode = 1;
|
|
3164
|
-
return null;
|
|
3165
|
-
};
|
|
3166
|
-
const foundRoot = d.findProjectRoot(process.cwd());
|
|
3167
|
-
if (!foundRoot) return refuseProject(NO_PROJECT_REFUSAL);
|
|
3168
|
-
const root = foundRoot;
|
|
3169
|
-
const projectProblem = appProjectProblem(root);
|
|
3170
|
-
if (projectProblem) return refuseProject(projectProblem);
|
|
3171
|
-
try {
|
|
3172
|
-
await d.ensureWorkspaceStorage(root, { note });
|
|
3173
|
-
} catch (error) {
|
|
3174
|
-
const code = error?.code || "STIM_WORKSPACE_STATE";
|
|
3175
|
-
const message = `Could not prepare this workspace's Stim state: ${error?.message || error}`;
|
|
3176
|
-
note(chalk.red(`${code}: ${message}`));
|
|
3177
|
-
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`)."));
|
|
3178
|
-
if (json) console.log(JSON.stringify({
|
|
3179
|
-
code,
|
|
3180
|
-
message,
|
|
3181
|
-
remedy: "Check that STIM_HOME is writable and has free space."
|
|
3182
|
-
}));
|
|
3183
|
-
process.exitCode = 1;
|
|
3184
|
-
return null;
|
|
3185
|
-
}
|
|
3186
|
-
const logsDir = workspaceLogsDir$1(root);
|
|
3187
|
-
const logFile = iosSlotLogFile(root, slot);
|
|
3188
|
-
let writer = null;
|
|
3189
|
-
const logWriter = () => writer ||= tapBuildLog(d.createWriter(logFile, {
|
|
3190
|
-
truncate: true,
|
|
3191
|
-
fields: {
|
|
3192
|
-
platform: "ios",
|
|
3193
|
-
slot
|
|
3194
|
-
}
|
|
3195
|
-
}), progress);
|
|
3196
|
-
let leaseHandle = null;
|
|
3197
|
-
let stopLeaseSignals = null;
|
|
3198
|
-
const releaseLease = () => {
|
|
3199
|
-
const held = leaseHandle;
|
|
3200
|
-
const stopSignals = stopLeaseSignals;
|
|
3201
|
-
leaseHandle = null;
|
|
3202
|
-
stopLeaseSignals = null;
|
|
3203
|
-
stopSignals?.();
|
|
3204
|
-
try {
|
|
3205
|
-
held?.release();
|
|
3206
|
-
} catch (e) {
|
|
3207
|
-
note(chalk.dim(`Could not release this run's device lease: ${e?.message || e}`));
|
|
3208
|
-
}
|
|
3209
|
-
};
|
|
3210
|
-
const stats = createRunRecorder({
|
|
3211
|
-
platform: "ios",
|
|
3212
|
-
write: (statsRun, at) => d.recordStats(statsRun, at),
|
|
3213
|
-
now: () => d.now(),
|
|
3214
|
-
note: (line) => note(chalk.dim(line)),
|
|
3215
|
-
phases: () => progress.durations(),
|
|
3216
|
-
deviceSetup: () => progress.deviceSetupKnown()
|
|
3217
|
-
});
|
|
3218
|
-
const deviceWaitRun = createIosDeviceWaitRun(stats, progress, runCancellationSignal());
|
|
3219
|
-
const recordRun = deviceWaitRun.record;
|
|
3220
|
-
let compilationCache = COMPILATION_CACHE_NOT_RUN;
|
|
3221
|
-
let reclaimed = [];
|
|
3222
|
-
let buildMachine = "auto";
|
|
3223
|
-
let devicePlacement;
|
|
3224
|
-
let builtConfiguration = null;
|
|
3225
|
-
const fail = ({ code, message, remedy = null, lines = [], logPath = null, build = null, lease, setup = false }) => {
|
|
3226
|
-
({code, message, remedy, lines} = cancelledFailure("ios", {
|
|
3227
|
-
code,
|
|
3228
|
-
message
|
|
3229
|
-
}) ?? {
|
|
3230
|
-
code,
|
|
3231
|
-
message,
|
|
3232
|
-
remedy,
|
|
3233
|
-
lines
|
|
3234
|
-
});
|
|
3235
|
-
releaseLease();
|
|
3236
|
-
if (message) note(chalk.red(phaseLine("error", message)));
|
|
3237
|
-
for (const line of lines) note(chalk.dim(phaseLine("", line)));
|
|
3238
|
-
if (remedy) note(chalk.dim(phaseLine("remedy", remedy)));
|
|
3239
|
-
if (logPath) note(chalk.dim(phaseLine("log", logPath)));
|
|
3240
|
-
if (build) writeLastBuild(root, lastBuildRecord({
|
|
3241
|
-
devicePlacement,
|
|
3242
|
-
buildMachine,
|
|
3243
|
-
...build,
|
|
3244
|
-
configuration: builtConfiguration,
|
|
3245
|
-
startedAt,
|
|
3246
|
-
status: "failed",
|
|
3247
|
-
errorCode: code,
|
|
3248
|
-
durationMs: elapsed()
|
|
3249
|
-
}));
|
|
3250
|
-
note(chalk.red(phaseLine("failed", code)));
|
|
3251
|
-
if (!setup) recordRun({
|
|
3252
|
-
failed: true,
|
|
3253
|
-
durationMs: elapsed()
|
|
3254
|
-
});
|
|
3255
|
-
if (json) console.log(JSON.stringify({
|
|
3256
|
-
code,
|
|
3257
|
-
message: message ?? null,
|
|
3258
|
-
remedy: remedy ?? null,
|
|
3259
|
-
...devicePlacement ? { devicePlacement } : {},
|
|
3260
|
-
...compilationCache.status === "not-run" ? {} : { compilationCache },
|
|
3261
|
-
...lease === void 0 ? {} : { lease },
|
|
3262
|
-
...reclaimed.length ? { reclaimed } : {}
|
|
3263
|
-
}));
|
|
3264
|
-
writer?.close?.();
|
|
3265
|
-
process.exitCode = 1;
|
|
3266
|
-
return null;
|
|
3267
|
-
};
|
|
3268
|
-
const settingsRepoRoot = d.repoRoot(root);
|
|
3269
|
-
const settingsContext = {
|
|
3270
|
-
projectPath: root,
|
|
3271
|
-
gitCommonDir: d.gitCommonDir(root),
|
|
3272
|
-
repoRoot: settingsRepoRoot
|
|
3273
|
-
};
|
|
3274
|
-
const projectKey = statsProjectKey$1({
|
|
3275
|
-
root,
|
|
3276
|
-
commonDir: settingsContext.gitCommonDir,
|
|
3277
|
-
repoRoot: settingsRepoRoot
|
|
3278
|
-
});
|
|
3279
|
-
stats.setProject(projectKey);
|
|
3280
|
-
progress.estimate(projectKey);
|
|
3281
|
-
let estimatesRead = null;
|
|
3282
|
-
const estimates = () => estimatesRead ??= d.readEstimates({
|
|
3283
|
-
projectKey,
|
|
3284
|
-
platform: "ios"
|
|
3285
|
-
});
|
|
3286
|
-
const settings = d.resolveSettings(settingsContext);
|
|
3287
|
-
const [shapeError, ...moreShapeErrors] = settingShapeErrors(settings);
|
|
3288
|
-
if (shapeError) return fail({
|
|
3289
|
-
code: "STIM_BAD_ARG",
|
|
3290
|
-
message: shapeError,
|
|
3291
|
-
lines: moreShapeErrors,
|
|
3292
|
-
remedy: SETTING_SHAPE_REMEDY
|
|
3293
|
-
});
|
|
3294
|
-
const setup = resolveIosBuildSetup(opts.remoteBuild, settings);
|
|
3295
|
-
if (!setup.ok) return fail(setup.failure);
|
|
3296
|
-
buildMachine = setup.buildMachine;
|
|
3297
|
-
const { optimizations } = setup;
|
|
3298
|
-
const buildProfile = optimizationBuildProfile("ios", optimizations);
|
|
3299
|
-
const cacheProviderConfig = d.resolveCacheProviderConfig(settingsContext);
|
|
3300
|
-
for (const key of unknownSettingKeys(settings)) note(phaseLine("setting", chalk.yellow(`Warning: setting "${key}" is not read by Stim and will be ignored.`)));
|
|
3301
|
-
const cacheProviderError = cacheProviderSettingError(settings);
|
|
3302
|
-
if (cacheProviderError) note(chalk.yellow(phaseLine("cache", `${cacheProviderError} Using the local cache.`)));
|
|
3303
|
-
const poolError = parkedMaxSetting("ios").error;
|
|
3304
|
-
if (poolError) return fail({
|
|
3305
|
-
code: "STIM_BAD_ARG",
|
|
3306
|
-
message: poolError,
|
|
3307
|
-
remedy: POOL_SETTING_REMEDY
|
|
3308
|
-
});
|
|
3309
|
-
for (const settingError of [
|
|
3310
|
-
iosSigningIdentitySettingError(settings),
|
|
3311
|
-
iosSigningIdentitySha1SettingError(settings),
|
|
3312
|
-
iosLanHostSettingError(settings)
|
|
3313
|
-
]) if (settingError) return fail({
|
|
3314
|
-
code: "STIM_BAD_ARG",
|
|
3315
|
-
message: settingError,
|
|
3316
|
-
remedy: SETTING_SHAPE_REMEDY
|
|
3317
|
-
});
|
|
3318
|
-
const configuration = opts.easProfile !== void 0 ? null : resolveConfiguration(opts.configuration, settings);
|
|
3319
|
-
builtConfiguration = configuration ?? "Debug";
|
|
3320
|
-
const buildScheme = opts.scheme;
|
|
3321
|
-
const release = isReleaseConfiguration(configuration);
|
|
3322
|
-
const cachePolicy = artifactCachePolicy(optimizations, useBuildCache, release);
|
|
3323
|
-
useBuildCache = cachePolicy.read;
|
|
3324
|
-
const deviceType = resolveDeviceType(opts.deviceType, settings);
|
|
3325
|
-
const runtime = resolveRuntime(opts.runtime, settings);
|
|
3326
|
-
const deviceFlag = opts.device;
|
|
3327
|
-
const physical = isPhysicalDeviceRequest(deviceFlag);
|
|
3328
|
-
if (physical && deviceFlag === "") return fail({
|
|
3329
|
-
code: "STIM_BAD_ARG",
|
|
3330
|
-
message: "--device was given an empty UDID.",
|
|
3331
|
-
remedy: "Pass `--device` on its own to take the first connected device this workspace can lease, or `--device <udid>` to name one."
|
|
3332
|
-
});
|
|
3333
|
-
if (physical && opts.remote) return fail({
|
|
3334
|
-
code: "STIM_BAD_ARG",
|
|
3335
|
-
message: "--device builds for a phone connected to this machine, and --remote installs on a remote one.",
|
|
3336
|
-
remedy: "Pass only one of --device and --remote."
|
|
3337
|
-
});
|
|
3338
|
-
const wait = resolveIosWait(opts, physical);
|
|
3339
|
-
if ("failure" in wait) return fail(wait.failure);
|
|
3340
|
-
const { waitSeconds, noWait, deviceSlotWaitMs, checkCapacity } = wait;
|
|
3341
|
-
const deviceSlotWait = {
|
|
3342
|
-
waitMs: deviceSlotWaitMs,
|
|
3343
|
-
displayName: basename(root),
|
|
3344
|
-
...deviceWaitRun.policy,
|
|
3345
|
-
onWait: (ms) => {
|
|
3346
|
-
deviceWaitRun.policy.onWait?.(ms);
|
|
3347
|
-
if (devicePlacement?.decision === "local" && ms > 0) devicePlacement.decision = "waited-locally";
|
|
3348
|
-
}
|
|
3349
|
-
};
|
|
3350
|
-
const isExpo = d.detectIsExpo(root);
|
|
3351
|
-
const schemeRefusal = explicitSchemeRefusal(root, buildScheme, isExpo, d);
|
|
3352
|
-
if (schemeRefusal) return fail(schemeRefusal);
|
|
3353
|
-
const remoteSelection = await selectIosPlacement({
|
|
3354
|
-
root,
|
|
3355
|
-
slot,
|
|
3356
|
-
opts,
|
|
3357
|
-
settings,
|
|
3358
|
-
physical,
|
|
3359
|
-
release,
|
|
3360
|
-
metroCheck,
|
|
3361
|
-
d,
|
|
3362
|
-
deviceType,
|
|
3363
|
-
runtime,
|
|
3364
|
-
validateSelectors: () => deviceModelRefusal({
|
|
3365
|
-
slot,
|
|
3366
|
-
deviceTypeFlag: opts.deviceType,
|
|
3367
|
-
runtimeFlag: opts.runtime,
|
|
3368
|
-
deviceType,
|
|
3369
|
-
runtime,
|
|
3370
|
-
physical,
|
|
3371
|
-
remoteBackend: null,
|
|
3372
|
-
deviceTypeOrigin: d.settingOriginScope(d.settingsLayers(settingsContext), "ios.deviceType"),
|
|
3373
|
-
runtimeOrigin: d.settingOriginScope(d.settingsLayers(settingsContext), "ios.runtime"),
|
|
3374
|
-
listRuntimes: d.listIosRuntimes
|
|
3375
|
-
}),
|
|
3376
|
-
noWait: deviceSlotWaitMs === 0,
|
|
3377
|
-
note,
|
|
3378
|
-
phase
|
|
3379
|
-
});
|
|
3380
|
-
if ("failure" in remoteSelection) return fail(remoteSelection.failure);
|
|
3381
|
-
devicePlacement = remoteSelection.devicePlacement;
|
|
3382
|
-
writeDevicePlacement(root, slot, "ios", devicePlacement);
|
|
3383
|
-
const { machine: hostedMachine, backend: remoteBackend } = remoteSelection;
|
|
3384
|
-
const viewer = resolveSimulatorAppFlag(opts.simulatorApp, physical, hostedMachine ?? remoteBackend, Boolean(remoteSelection.auto));
|
|
3385
|
-
if ("refusal" in viewer) return fail(viewer.refusal);
|
|
3386
|
-
const { simulatorApp } = viewer;
|
|
3387
|
-
const settingsLayersForOrigin = d.settingsLayers(settingsContext);
|
|
3388
|
-
const modelRefusal = deviceModelRefusal({
|
|
3389
|
-
slot,
|
|
3390
|
-
deviceTypeFlag: opts.deviceType,
|
|
3391
|
-
runtimeFlag: opts.runtime,
|
|
3392
|
-
deviceType,
|
|
3393
|
-
runtime,
|
|
3394
|
-
deviceTypeOrigin: d.settingOriginScope(settingsLayersForOrigin, "ios.deviceType"),
|
|
3395
|
-
runtimeOrigin: d.settingOriginScope(settingsLayersForOrigin, "ios.runtime"),
|
|
3396
|
-
physical,
|
|
3397
|
-
remoteBackend,
|
|
3398
|
-
hosted: Boolean(hostedMachine),
|
|
3399
|
-
listRuntimes: d.listIosRuntimes
|
|
3400
|
-
});
|
|
3401
|
-
if (modelRefusal) return fail(modelRefusal);
|
|
3402
|
-
const selectors = hostedIosSelectors(deviceType, runtime);
|
|
3403
|
-
const connected = await connectIosTarget(remoteSelection, selectors, d);
|
|
3404
|
-
if ("failure" in connected) return fail(connected.failure);
|
|
3405
|
-
const hostedTarget = connected.target;
|
|
3406
|
-
try {
|
|
3407
|
-
const budget = await iosPlacementBudget(d, root, note, Boolean(hostedTarget), remoteSelection.budget);
|
|
3408
|
-
reclaimed = budget.reclaimed;
|
|
3409
|
-
if (budget.refusal) return fail(budget.refusal);
|
|
3410
|
-
const backendConnection = await connectIosBackend(root, remoteBackend, opts.deviceType, d);
|
|
3411
|
-
if ("failure" in backendConnection) return fail(backendConnection.failure);
|
|
3412
|
-
const remoteDevice = backendConnection.remote;
|
|
3413
|
-
const remoteArch = hostedTarget ? hostedTarget.choice.architecture : backendConnection.arch;
|
|
3414
|
-
if (remoteDevice) d = {
|
|
3415
|
-
...d,
|
|
3416
|
-
checkDeviceCapacity: remoteDevice.checkDeviceCapacity,
|
|
3417
|
-
ensureOwnedDevice: remoteDevice.ensureOwnedDevice,
|
|
3418
|
-
ensureBooted: remoteDevice.ensureBooted,
|
|
3419
|
-
installIosApp: remoteDevice.installIosApp,
|
|
3420
|
-
launchIosApp: remoteDevice.launchIosApp
|
|
3421
|
-
};
|
|
3422
|
-
const easBuild = await d.resolveEasDevelopmentBuild({
|
|
3423
|
-
root,
|
|
3424
|
-
platform: "ios",
|
|
3425
|
-
profile: opts.easProfile,
|
|
3426
|
-
note,
|
|
3427
|
-
isExpo,
|
|
3428
|
-
physical,
|
|
3429
|
-
selectors: [opts.scheme, opts.configuration],
|
|
3430
|
-
buildCache: opts.buildCache
|
|
3431
|
-
});
|
|
3432
|
-
if (isEasBuildFailure(easBuild)) return fail(easBuild);
|
|
3433
|
-
const registerProject = () => d.upsertProject(root, {
|
|
3434
|
-
bundleId: d.detectBundleId(root) ?? void 0,
|
|
3435
|
-
isExpo
|
|
3436
|
-
});
|
|
3437
|
-
if (remoteBackend !== "eas") registerProject();
|
|
3438
|
-
const proj = d.getProject(root);
|
|
3439
|
-
const limits = d.getConcurrencyLimits();
|
|
3440
|
-
let physicalDevice = null;
|
|
3441
|
-
let wireless = false;
|
|
3442
|
-
if (physical && typeof deviceFlag !== "string") {
|
|
3443
|
-
const pooled = await d.selectFromPool({
|
|
3444
|
-
root,
|
|
3445
|
-
platform: "ios",
|
|
3446
|
-
idLabel: "udid",
|
|
3447
|
-
list: () => iosPoolCandidates(d.listIosDevices()).map((entry) => ({
|
|
3448
|
-
id: entry.udid,
|
|
3449
|
-
name: entry.name,
|
|
3450
|
-
fallback: isWirelessIosDevice(entry)
|
|
3451
|
-
})),
|
|
3452
|
-
noCandidates: () => {
|
|
3453
|
-
const resolved = iosPoolNoCandidatesRefusal(d.listIosDevices());
|
|
3454
|
-
return {
|
|
3455
|
-
message: resolved.error,
|
|
3456
|
-
remedy: resolved.remedy
|
|
3457
|
-
};
|
|
3458
|
-
},
|
|
3459
|
-
waitSeconds,
|
|
3460
|
-
noWait,
|
|
3461
|
-
now: d.now,
|
|
3462
|
-
warn: (line) => note(chalk.yellow(phaseLine("lease", line)))
|
|
3463
|
-
});
|
|
3464
|
-
if (pooled.status === "refused") return fail({
|
|
3465
|
-
code: pooled.refusal.code,
|
|
3466
|
-
message: pooled.refusal.message,
|
|
3467
|
-
remedy: pooled.refusal.remedy,
|
|
3468
|
-
...pooled.refusal.lease === null ? {} : { lease: pooled.refusal.lease }
|
|
3469
|
-
});
|
|
3470
|
-
physicalDevice = {
|
|
3471
|
-
udid: pooled.candidate.id,
|
|
3472
|
-
name: pooled.candidate.name ?? pooled.candidate.id
|
|
3473
|
-
};
|
|
3474
|
-
wireless = pooled.candidate.fallback === true;
|
|
3475
|
-
} else if (physical) {
|
|
3476
|
-
const resolved = resolveIosPhysicalDevice(typeof deviceFlag === "string" ? deviceFlag : null, d.listIosDevices());
|
|
3477
|
-
if (!resolved.udid) return fail({
|
|
3478
|
-
code: "STIM_NO_DEVICE",
|
|
3479
|
-
message: resolved.error,
|
|
3480
|
-
remedy: resolved.remedy
|
|
3481
|
-
});
|
|
3482
|
-
physicalDevice = {
|
|
3483
|
-
udid: resolved.udid,
|
|
3484
|
-
name: resolved.name ?? resolved.udid
|
|
3485
|
-
};
|
|
3486
|
-
wireless = resolved.wireless === true;
|
|
3487
|
-
}
|
|
3488
|
-
if (checkCapacity && !hostedTarget) {
|
|
3489
|
-
const capacity = d.checkDeviceCapacity({
|
|
3490
|
-
platform: "ios",
|
|
3491
|
-
project: proj,
|
|
3492
|
-
max: limits.maxDevices
|
|
3493
|
-
});
|
|
3494
|
-
if (capacity) {
|
|
3495
|
-
if (capacity.code === "STIM_AT_CAPACITY") d.recordCapacityRefusal({
|
|
3496
|
-
platform: "ios",
|
|
3497
|
-
max: limits.maxDevices,
|
|
3498
|
-
workspace: workspaceId(root)
|
|
3499
|
-
}, d.now());
|
|
3500
|
-
return fail(capacity);
|
|
3501
|
-
}
|
|
3502
|
-
}
|
|
3503
|
-
let metroPort = proj?.metroPort ?? null;
|
|
3504
|
-
let lanAddress = null;
|
|
3505
|
-
let lanOriginUrl = null;
|
|
3506
|
-
let devServer = null;
|
|
3507
|
-
if (!await resolveMetroPort()) return null;
|
|
3508
|
-
let device;
|
|
3509
|
-
if (physicalDevice) device = {
|
|
3510
|
-
deviceUdid: physicalDevice.udid,
|
|
3511
|
-
deviceName: physicalDevice.name,
|
|
3512
|
-
owned: false
|
|
3513
|
-
};
|
|
3514
|
-
else if (hostedTarget) device = {
|
|
3515
|
-
owned: false,
|
|
3516
|
-
deviceName: hostedTarget.choice.deviceType,
|
|
3517
|
-
runtime: hostedTarget.choice.runtime
|
|
3518
|
-
};
|
|
3519
|
-
else {
|
|
3520
|
-
const prepare = stepClock(d.now);
|
|
3521
|
-
try {
|
|
3522
|
-
device = await d.ensureOwnedDevice({
|
|
3523
|
-
platform: "ios",
|
|
3524
|
-
project: proj,
|
|
3525
|
-
projectPath: root,
|
|
3526
|
-
settingsRoot: root,
|
|
3527
|
-
settings,
|
|
3528
|
-
flags: {
|
|
3529
|
-
deviceSlotWait,
|
|
3530
|
-
deviceType,
|
|
3531
|
-
runtime,
|
|
3532
|
-
runtimeFlag: resolveRuntime(opts.runtime, null),
|
|
3533
|
-
simulatorApp
|
|
3534
|
-
},
|
|
3535
|
-
note,
|
|
3536
|
-
out: note
|
|
3537
|
-
});
|
|
3538
|
-
} catch (e) {
|
|
3539
|
-
return fail(ownedSimFailure(e));
|
|
3540
|
-
}
|
|
3541
|
-
deviceWaitRun.booting(device.booting);
|
|
3542
|
-
progress.deviceSetup(didSetUpDevice(device, Boolean(remoteDevice)));
|
|
3543
|
-
const prepareMs = prepare();
|
|
3544
|
-
if (device.created || prepareMs >= 2e3) phase("device", `${deviceLabel(device, device.deviceUdid)} ${device.created ? "created" : "prepared"} (${formatDuration(prepareMs)})`);
|
|
3545
|
-
}
|
|
3546
|
-
let bootDuration = "";
|
|
3547
|
-
let bootPromise;
|
|
3548
|
-
let udid = "";
|
|
3549
|
-
async function resolveMetroPort() {
|
|
3550
|
-
if (release) {
|
|
3551
|
-
metroPort = null;
|
|
3552
|
-
phase("metro", `skipped (${configuration}: the JS bundle is embedded, no dev server is used)`);
|
|
3553
|
-
} else if (metroCheck) {
|
|
3554
|
-
const gate = await ensureDevServer({
|
|
3555
|
-
root,
|
|
3556
|
-
port: metroPort,
|
|
3557
|
-
settings: hostedMetroSettings(settings, Boolean(hostedTarget)),
|
|
3558
|
-
remote: Boolean(remoteDevice),
|
|
3559
|
-
note,
|
|
3560
|
-
resolve: d.resolveProjectMetro,
|
|
3561
|
-
start: d.startDevServer,
|
|
3562
|
-
readState: d.readWorkspaceState
|
|
3563
|
-
});
|
|
3564
|
-
reclaimed = [...reclaimed, ...gate.reclaimed];
|
|
3565
|
-
if (!gate.ok) {
|
|
3566
|
-
fail({
|
|
3567
|
-
code: gate.code,
|
|
3568
|
-
message: gate.message,
|
|
3569
|
-
remedy: gate.remedy,
|
|
3570
|
-
lines: gate.lines
|
|
3571
|
-
});
|
|
3572
|
-
return false;
|
|
3573
|
-
}
|
|
3574
|
-
metroPort = gate.port;
|
|
3575
|
-
devServer = gate.devServer;
|
|
3576
|
-
} else {
|
|
3577
|
-
const pin = metroPortSetting(root);
|
|
3578
|
-
if (pin.error) {
|
|
3579
|
-
fail({
|
|
3580
|
-
code: "STIM_BAD_ARG",
|
|
3581
|
-
message: pin.error,
|
|
3582
|
-
remedy: SETTING_SHAPE_REMEDY
|
|
3583
|
-
});
|
|
3584
|
-
return false;
|
|
3585
|
-
}
|
|
3586
|
-
if (pin.port === null && !metroPort) note(chalk.yellow(`No Metro port is reserved for this workspace; wiring the app to ${DEFAULT_METRO_PORT}.`));
|
|
3587
|
-
metroPort = pin.port ?? metroPort ?? 8081;
|
|
3588
|
-
}
|
|
3589
|
-
hostedIosMetroNote(Boolean(hostedTarget), settings, note, opts.simulatorApp);
|
|
3590
|
-
if (physical && metroPort !== null && !await resolveLanOrigin()) return false;
|
|
3591
|
-
if (remoteDevice && metroPort !== null) {
|
|
3592
|
-
const reachable = await d.ensureMetroReachable({
|
|
3593
|
-
ctx: remoteDevice.ctx,
|
|
3594
|
-
metroPort,
|
|
3595
|
-
isExpo,
|
|
3596
|
-
tunnelMode: tunnelModeSetting(settings) ?? void 0,
|
|
3597
|
-
publicUrl: publicUrlSetting(settings),
|
|
3598
|
-
available: d.detectProviders(binOnPath, tunnelModeSetting(settings) ?? "auto")
|
|
3599
|
-
});
|
|
3600
|
-
if ("failed" in reachable) {
|
|
3601
|
-
fail({
|
|
3602
|
-
code: reachable.code ?? "STIM_NO_REMOTE_SESSION",
|
|
3603
|
-
message: reachable.failed,
|
|
3604
|
-
remedy: reachable.remedy
|
|
3605
|
-
});
|
|
3606
|
-
return false;
|
|
3607
|
-
}
|
|
3608
|
-
}
|
|
3609
|
-
if (!release && metroCheck && optimizations.metroWarmup) d.warmMetro({
|
|
3610
|
-
port: metroPort,
|
|
3611
|
-
platform: "ios",
|
|
3612
|
-
isExpo,
|
|
3613
|
-
appId: proj?.bundleId,
|
|
3614
|
-
bundleUrl: metroWarmupUrlSetting(settings, "ios")
|
|
3615
|
-
});
|
|
3616
|
-
return true;
|
|
3617
|
-
}
|
|
3618
|
-
async function resolveLanOrigin() {
|
|
3619
|
-
const port = metroPort;
|
|
3620
|
-
const chosen = chooseLanAddress({
|
|
3621
|
-
pinned: iosLanHostSetting(settings),
|
|
3622
|
-
candidates: d.hostLanCandidates()
|
|
3623
|
-
});
|
|
3624
|
-
if (!chosen) {
|
|
3625
|
-
fail({
|
|
3626
|
-
code: "STIM_NO_LAN_ADDRESS",
|
|
3627
|
-
message: "A Debug run on a phone needs an address the phone can reach, and this Mac has no non-internal IPv4 interface.",
|
|
3628
|
-
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."
|
|
3629
|
-
});
|
|
3630
|
-
return false;
|
|
3631
|
-
}
|
|
3632
|
-
lanAddress = chosen.address;
|
|
3633
|
-
lanOriginUrl = lanOriginUrlFor(chosen.address, port);
|
|
3634
|
-
const source = chosen.pinned ? "ios.lanHost" : `${chosen.interfaceName ?? "interface"}${chosen.candidates > 1 ? ` of ${chosen.candidates} candidates` : ""}`;
|
|
3635
|
-
phase("lan", `${lanOriginUrl} (${source})`);
|
|
3636
|
-
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.")));
|
|
3637
|
-
if (!metroCheck) return true;
|
|
3638
|
-
const reachable = await d.ensureLanReachable({
|
|
3639
|
-
origin: lanOriginUrl,
|
|
3640
|
-
metroPort: port,
|
|
3641
|
-
root,
|
|
3642
|
-
isExpo,
|
|
3643
|
-
logsDir
|
|
3644
|
-
});
|
|
3645
|
-
if ("failed" in reachable) {
|
|
3646
|
-
fail({
|
|
3647
|
-
code: "STIM_LAN_METRO_UNREACHABLE",
|
|
3648
|
-
message: reachable.failed,
|
|
3649
|
-
remedy: reachable.remedy
|
|
3650
|
-
});
|
|
3651
|
-
return false;
|
|
3652
|
-
}
|
|
3653
|
-
phase("lan", `gated: ${lanOriginUrl} answered as this workspace's Metro`);
|
|
3654
|
-
return true;
|
|
3655
|
-
}
|
|
3656
|
-
let artifact = null;
|
|
3657
|
-
try {
|
|
3658
|
-
const boot = () => physicalDevice ? Promise.resolve({
|
|
3659
|
-
ok: true,
|
|
3660
|
-
udid: physicalDevice.udid
|
|
3661
|
-
}) : Promise.resolve(d.ensureBooted({
|
|
3662
|
-
platform: "ios",
|
|
3663
|
-
device,
|
|
3664
|
-
projectPath: root,
|
|
3665
|
-
deviceSlotWait,
|
|
3666
|
-
simulatorApp,
|
|
3667
|
-
out: note
|
|
3668
|
-
})).catch((e) => ({
|
|
3669
|
-
ok: false,
|
|
3670
|
-
reason: String(e?.message || e)
|
|
3671
|
-
}));
|
|
3672
|
-
const startBoot = () => {
|
|
3673
|
-
const bootTimer = stepTimer(d.now);
|
|
3674
|
-
bootPromise = (remoteDevice?.ctx.backend === "eas" ? d.ensureRemoteBootOwned({
|
|
3675
|
-
root,
|
|
3676
|
-
platform: "ios",
|
|
3677
|
-
sessionName: ownedSessionName(remoteDevice.ctx.label),
|
|
3678
|
-
startedAt: new Date(d.now()).toISOString(),
|
|
3679
|
-
deviceType: remoteDevice.ctx.deviceType ?? null,
|
|
3680
|
-
boot,
|
|
3681
|
-
createdSessionId: remoteDevice.createdSessionId,
|
|
3682
|
-
abandonCreatedSession: remoteDevice.abandonCreatedSession,
|
|
3683
|
-
webPreviewUrl: remoteDevice.webPreviewUrl,
|
|
3684
|
-
writeState: d.writeWorkspaceState,
|
|
3685
|
-
register: registerProject,
|
|
3686
|
-
notice: (line) => note(chalk.dim(phaseLine("lock", line)))
|
|
3687
|
-
}) : boot()).then((result) => {
|
|
3688
|
-
bootDuration = bootTimer();
|
|
3689
|
-
return result;
|
|
3690
|
-
});
|
|
3691
|
-
deviceWaitRun.booting({ done: bootPromise });
|
|
3692
|
-
return bootPromise.then((result) => result?.udid ?? "");
|
|
3693
|
-
};
|
|
3694
|
-
const localBoot = remoteDevice || hostedTarget ? null : startBoot();
|
|
3695
|
-
udid = device.deviceUdid ?? await localBoot ?? "";
|
|
3696
|
-
const acquiredArtifact = unlessCancelled(await acquireIosArtifact({
|
|
3697
|
-
root,
|
|
3698
|
-
logFile,
|
|
3699
|
-
udid,
|
|
3700
|
-
configuration,
|
|
3701
|
-
buildScheme,
|
|
3702
|
-
buildProfile,
|
|
3703
|
-
buildMachine,
|
|
3704
|
-
isExpo,
|
|
3705
|
-
remoteDestination: Boolean(remoteDevice || hostedTarget),
|
|
3706
|
-
...hostedIosBuildTarget(hostedTarget),
|
|
3707
|
-
simulatorArch: simulatorBuildArch({
|
|
3708
|
-
physical,
|
|
3709
|
-
remoteArch,
|
|
3710
|
-
hostArch: d.hostSimulatorArch(),
|
|
3711
|
-
configuration
|
|
3712
|
-
}),
|
|
3713
|
-
device: physical ? {
|
|
3714
|
-
lanAddress,
|
|
3715
|
-
metroPort,
|
|
3716
|
-
signingName: iosSigningIdentitySetting(settings),
|
|
3717
|
-
signingSha1: iosSigningIdentitySha1Setting(settings)
|
|
3718
|
-
} : null,
|
|
3719
|
-
optimizations: optimizations.ios,
|
|
3720
|
-
cache: {
|
|
3721
|
-
policy: cachePolicy,
|
|
3722
|
-
providerConfig: cacheProviderConfig,
|
|
3723
|
-
disabledByFlag: opts.buildCache === false
|
|
3724
|
-
},
|
|
3725
|
-
easBuild,
|
|
3726
|
-
easProfile: opts.easProfile,
|
|
3727
|
-
maxBuilds: limits.maxBuilds,
|
|
3728
|
-
progress: {
|
|
3729
|
-
phase,
|
|
3730
|
-
note,
|
|
3731
|
-
logWriter,
|
|
3732
|
-
estimates,
|
|
3733
|
-
stats,
|
|
3734
|
-
step: progress.step,
|
|
3735
|
-
miss: progress.miss,
|
|
3736
|
-
hit: progress.hit,
|
|
3737
|
-
place: progress.place,
|
|
3738
|
-
waitingOn: progress.waitingOn,
|
|
3739
|
-
waitingFor: progress.waitingFor
|
|
3740
|
-
}
|
|
3741
|
-
}, d));
|
|
3742
|
-
if (!acquiredArtifact.ok) {
|
|
3743
|
-
compilationCache = acquiredArtifact.compilationCache;
|
|
3744
|
-
return fail(acquiredArtifact.failure);
|
|
3745
|
-
}
|
|
3746
|
-
artifact = acquiredArtifact.artifact;
|
|
3747
|
-
compilationCache = artifact.cache.compilation;
|
|
3748
|
-
if (hostedTarget) return await finishHostedIosRun({
|
|
3749
|
-
target: hostedTarget,
|
|
3750
|
-
root,
|
|
3751
|
-
slot,
|
|
3752
|
-
d,
|
|
3753
|
-
artifact,
|
|
3754
|
-
configuration,
|
|
3755
|
-
buildScheme,
|
|
3756
|
-
release,
|
|
3757
|
-
isExpo,
|
|
3758
|
-
metroCheck,
|
|
3759
|
-
metroPort,
|
|
3760
|
-
logsDir,
|
|
3761
|
-
json,
|
|
3762
|
-
elapsed,
|
|
3763
|
-
startedAt,
|
|
3764
|
-
closeWriter: () => writer?.close(),
|
|
3765
|
-
devicePlacement,
|
|
3766
|
-
recordRun,
|
|
3767
|
-
reclaimed,
|
|
3768
|
-
devServer,
|
|
3769
|
-
fail,
|
|
3770
|
-
note,
|
|
3771
|
-
selectors
|
|
3772
|
-
});
|
|
3773
|
-
if (!localBoot) {
|
|
3774
|
-
progress.step("device");
|
|
3775
|
-
udid = await startBoot();
|
|
3776
|
-
}
|
|
3777
|
-
if (physicalDevice) {
|
|
3778
|
-
progress.step("device");
|
|
3779
|
-
const acquired = await d.acquireRunLease({
|
|
3780
|
-
root,
|
|
3781
|
-
platform: "ios",
|
|
3782
|
-
id: physicalDevice.udid,
|
|
3783
|
-
deviceName: physicalDevice.name,
|
|
3784
|
-
idLabel: "udid",
|
|
3785
|
-
waitSeconds,
|
|
3786
|
-
noWait,
|
|
3787
|
-
installBoundMs: iosDeviceBounds(wireless).installMs,
|
|
3788
|
-
appId: artifact.bundleId ?? proj?.bundleId ?? null,
|
|
3789
|
-
holderAppId: (holder) => d.getProject(holder)?.bundleId ?? null,
|
|
3790
|
-
now: d.now,
|
|
3791
|
-
warn: (line) => note(chalk.yellow(phaseLine("lease", line)))
|
|
3792
|
-
});
|
|
3793
|
-
if (acquired.status === "refused") return fail({
|
|
3794
|
-
code: acquired.refusal.code,
|
|
3795
|
-
message: acquired.refusal.message,
|
|
3796
|
-
remedy: acquired.refusal.remedy,
|
|
3797
|
-
lease: acquired.refusal.lease
|
|
3798
|
-
});
|
|
3799
|
-
leaseHandle = d.runLease({
|
|
3800
|
-
root,
|
|
3801
|
-
platform: "ios",
|
|
3802
|
-
kind: acquired.status === "leased" ? acquired.kind : null,
|
|
3803
|
-
expiresAt: acquired.status === "leased" ? acquired.expiresAt : null
|
|
3804
|
-
});
|
|
3805
|
-
if (acquired.status === "leased") {
|
|
3806
|
-
stopLeaseSignals = d.releaseLeaseOnSignal(releaseLease);
|
|
3807
|
-
phase("lease", `${acquired.kind} lease on ${physicalDevice.udid} until ${leaseExpiryText(acquired.expiresAt, d.now())}`);
|
|
3808
|
-
}
|
|
3809
|
-
}
|
|
3810
|
-
try {
|
|
3811
|
-
return await finishIosRun({
|
|
3812
|
-
slot,
|
|
3813
|
-
d,
|
|
3814
|
-
root,
|
|
3815
|
-
json,
|
|
3816
|
-
release,
|
|
3817
|
-
configuration,
|
|
3818
|
-
buildScheme,
|
|
3819
|
-
isExpo,
|
|
3820
|
-
metroCheck,
|
|
3821
|
-
metroPort,
|
|
3822
|
-
logsDir,
|
|
3823
|
-
logFile,
|
|
3824
|
-
device,
|
|
3825
|
-
udid,
|
|
3826
|
-
physical,
|
|
3827
|
-
wireless,
|
|
3828
|
-
lanAddress,
|
|
3829
|
-
lanOriginUrl,
|
|
3830
|
-
remoteDevice,
|
|
3831
|
-
bootPromise,
|
|
3832
|
-
bootDuration: () => bootDuration,
|
|
3833
|
-
artifact,
|
|
3834
|
-
fail,
|
|
3835
|
-
phase,
|
|
3836
|
-
note,
|
|
3837
|
-
logWriter,
|
|
3838
|
-
elapsed,
|
|
3839
|
-
startedAt,
|
|
3840
|
-
closeWriter: () => writer?.close?.(),
|
|
3841
|
-
lease: leaseHandle,
|
|
3842
|
-
releaseLease,
|
|
3843
|
-
devicePlacement,
|
|
3844
|
-
recordRun,
|
|
3845
|
-
reclaimed,
|
|
3846
|
-
devServer,
|
|
3847
|
-
enterPhase: progress.step
|
|
3848
|
-
});
|
|
3849
|
-
} finally {
|
|
3850
|
-
releaseLease();
|
|
3851
|
-
}
|
|
3852
|
-
} catch (error) {
|
|
3853
|
-
recordRun({
|
|
3854
|
-
failed: true,
|
|
3855
|
-
durationMs: elapsed()
|
|
3856
|
-
});
|
|
3857
|
-
throw error;
|
|
3858
|
-
} finally {
|
|
3859
|
-
artifact?.release();
|
|
3860
|
-
}
|
|
3861
|
-
} finally {
|
|
3862
|
-
await deviceWaitRun.finish();
|
|
3863
|
-
hostedTarget?.host.connection.close();
|
|
3864
|
-
}
|
|
3865
|
-
}
|
|
3866
|
-
//#endregion
|
|
3867
|
-
export { appNameFromPath, buildLogFile, cacheDescription, collectorEntry, iosCommand as default, devClientScheme, deviceLabel, ensureWorkspaceStorageSafely, formatDuration, iosConfigurationSetting, iosFacts, isReleaseConfiguration, lastBuildRecord, phaseLine, pickDevClientScheme, podAction, registerIos, replaceCollector, resolveConfiguration, resolveDeviceType, resolveRuntime, schemesFromInfoPlist, shortHash, shortUdid, writeLastBuild };
|