@expo/simulator-launcher 27.5.0 → 27.7.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.
Files changed (3) hide show
  1. package/README.md +102 -18
  2. package/dist/index.js +3152 -69
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @expo/simulator-launcher
2
2
 
3
- Warm iOS Simulators before an EAS job arrives. Requires macOS.
4
- The image installs vm-tools and writes its startup script at
5
- `/usr/local/share/vm-tools/startup.sh`:
3
+ Prepare iOS Simulators and native tools, cache Expo Go and Appium files, and claim prepared sessions. Requires macOS.
4
+
5
+ Start the launcher with the devices you want to prepare:
6
6
 
7
7
  ```sh
8
8
  export EXPO_SIMULATOR_STARTUP=1
@@ -21,26 +21,47 @@ exec bunx @expo/simulator-launcher@latest start
21
21
  - `prepare-tools`: continue the consumed claim after adoption. Keep global Argent, reuse the default
22
22
  agent-device runner or prepare a runner for the selected device. Appium waits for old XCTest cleanup.
23
23
  - `stop`: permanently end warmup for this boot and wait for all owned resources to be cleaned up.
24
+ - `warmup`: populate Simulator and native tool caches. With `EXPO_SIMULATOR_STARTUP=1`,
25
+ calls `prefetch`, boots the selected Simulators, installs Expo Go unless disabled, and waits
26
+ for Argent and agent-device on the default device. It then drains owned processes and shuts
27
+ down the selected Simulators. Prepared files and native build caches remain available.
28
+ Incomplete preparation or cleanup fails. The preparation deadline is ten minutes; cleanup
29
+ can take longer. Requires a fresh macOS boot before `start` has run. A repeat, or `start`
30
+ after `warmup`, requires another boot. It does not start an Appium session or prepare an
31
+ agent-device runner on secondary devices.
32
+ - `prefetch`: cache the selected Expo Go archive for reuse. With `APPIUM_VERSION` and `XCUITEST_VERSION`, prepare Appium, XCUITest and WebDriverAgent files. It does not fetch serve-sim, agent-device or Argent. Progress goes to stderr; the command stops at the first failure.
33
+
34
+ Consumers use the launcher version recorded by `start` for session commands (`LAUNCHER_VERSION`
35
+ below). Run these in another process:
24
36
 
25
37
  ```sh
26
- # Build-tools reads LAUNCHER_VERSION from the version recorded by start.
27
- bun x --no-install "@expo/simulator-launcher@$LAUNCHER_VERSION" claim serve-sim
28
- # After private serve-sim adoption confirms the selected device and native ACK:
29
- bun x --no-install "@expo/simulator-launcher@$LAUNCHER_VERSION" prepare-tools
30
- bun x --no-install "@expo/simulator-launcher@$LAUNCHER_VERSION" stop
38
+ bun x "@expo/simulator-launcher@$LAUNCHER_VERSION" claim serve-sim
39
+ # After adoption confirms the selected device and native ACK:
40
+ bun x "@expo/simulator-launcher@$LAUNCHER_VERSION" prepare-tools
41
+ bun x "@expo/simulator-launcher@$LAUNCHER_VERSION" stop
31
42
  ```
32
43
 
33
- There is no copied launcher bundle. Build-tools uses the recorded package version for claim/stop;
34
- Warmup primes Bun’s exact-version cache before ready, with two attempts of up to 30 seconds. Its claim/stop calls use `--no-install`, retrying
35
- once with the registry only when Bun cannot find that cached binary. Priming failures warn.
36
- Before start has run,
37
- stop uses the normal package-manager path and still disables later warmup for this boot.
44
+ To cache files without booting devices:
45
+
46
+ ```sh
47
+ simulator-launcher prefetch
48
+ ```
38
49
 
39
- This flow requires the serve-sim release supporting port-based device adoption.
50
+ To also prepare Simulators and native tools (`warmup` already calls `prefetch`):
51
+
52
+ ```sh
53
+ EXPO_SIMULATOR_STARTUP=1 simulator-launcher warmup
54
+ ```
55
+
56
+ Session adoption requires the serve-sim release supporting port-based device adoption.
40
57
 
41
58
  One durable state file, `/tmp/expo-simulator-startup.json`, holds the lifecycle, launcher version,
42
59
  selected device, server credentials, claim and native identity. It is independent of HOME/TMPDIR. A short boot-scoped lock
43
- serializes updates; an abandoned lock fails closed. This private format requires a fresh VM.
60
+ serializes updates; an abandoned lock fails closed. State is scoped to the current boot.
61
+ `start` uses the supplied runtime package versions and records exact version inputs as
62
+ `serveSimVersion`, `agentDeviceVersion` and `argentVersion` in this state and the claim. Consumers
63
+ compare explicit package requests with these versions before reuse. Tags, ranges and unset inputs
64
+ do not report an exact version. Build-tools also uses `serveSimVersion` for warm adoption and recordings.
44
65
 
45
66
  ## Environment
46
67
 
@@ -50,13 +71,74 @@ serializes updates; an abandoned lock fails closed. This private format requires
50
71
  trimmed and must each identify one available device. The first is the default. Unset keeps
51
72
  the shortest available iPhone name, as does an empty or blank value. Empty list entries, missing,
52
73
  ambiguous or duplicate devices fail clearly.
53
- - `SERVE_SIM_VERSION`, `AGENT_DEVICE_VERSION`, `ARGENT_VERSION`: each defaults to `latest`.
74
+ - `SERVE_SIM_VERSION`, `AGENT_DEVICE_VERSION`, `ARGENT_VERSION` (`start`/`warmup` only): runtime
75
+ package selections, each defaulting to `latest`. The launcher passes them to Bun without a separate
76
+ version lookup. Callers that select exact versions can identify them in state and claims.
77
+ `prefetch` ignores these settings and never records them in `prepared.json`.
78
+ - `EXPO_GO_SDK_VERSION`: select an SDK for `prefetch` and `start` with an https iOS Simulator archive
79
+ in the Expo versions API. Unset selects the latest stable SDK; a pin must be `x.y.z` and may select
80
+ a beta. `start` reuses recorded SDK/archive metadata when it matches the supplied SDK, or when
81
+ no SDK is supplied. Without matching metadata, startup selects from the API using this variable
82
+ or the latest stable SDK. Ignored when `EXPO_SIMULATOR_PREINSTALL_EXPO_GO=0`.
83
+ - `APPIUM_VERSION`, `XCUITEST_VERSION` (`prefetch` only): exact versions (`x.y.z`), both or
84
+ neither. Any other value makes `prefetch` fail.
54
85
  - `AGENT_DEVICE_STATE_DIR`, `ARGENT_EVENT_LOG`: tool state/output locations.
55
86
  - Agent-device idle timers default to off. Override with `AGENT_DEVICE_DAEMON_IDLE_TIMEOUT_MS`
56
87
  and `AGENT_DEVICE_IOS_RUNNER_IDLE_STOP_MS` (milliseconds).
57
88
 
89
+ ## Prepared files
90
+
91
+ `prefetch` writes `expo-go/` and `appium/` under `~/Library/Caches/expo-simulator-startup/`, and
92
+ removes each one when its step is skipped. Each reader checks the files before it uses them and
93
+ otherwise runs its normal download or install. Keep these directories when reusing prepared files.
94
+
95
+ - `expo-go/<sha256 of the archive URL>.tar.gz`: `start` uses the recorded URL when its SDK matches
96
+ the supplied selection, or when no SDK is supplied. It checks the file with `gzip -t` before
97
+ extraction. A missing or damaged archive is downloaded again from that URL.
98
+ - `appium/`: an Appium home with the pinned xcuitest driver and WebDriverAgent runner.
99
+ Prefetch checks the runner's bundle metadata and executable before recording it.
100
+ Build-tools reuses it when the files match the manifest and Appium matches the current
101
+ resolution of an explicit version request, including ranges and `latest`. Without an override,
102
+ the prepared version must satisfy the default Appium 3 range. Build-tools does not write or
103
+ remove this home. These checks do not load the driver or launch WDA; validate reuse with a
104
+ real Appium session.
105
+
106
+ ### Prepared tool manifest
107
+
108
+ `prefetch` writes `~/Library/Caches/expo-simulator-startup/prepared.json` after all requested
109
+ steps and temporary-file cleanup succeed. Before refreshing caches, it removes the previous
110
+ manifest. Skipped tools are absent from the new manifest; a failed preparation publishes no new one.
111
+
112
+ The JSON has a `tools` map:
113
+
114
+ - `appium.version`, `appium.xcuitest`, `appium.home`: the prepared Appium and XCUITest versions
115
+ and the absolute Appium home path. This entry is written only after WDA preparation succeeds.
116
+
117
+ When Expo Go is enabled, `expo-go.sdk` and `expo-go.url` in `tools` record its selected SDK and archive URL.
118
+ The SDK identifies the selected Expo release, not the app's binary version. With every step
119
+ disabled or unset, the manifest is `{"tools":{}}`.
120
+
121
+ `start` reads only the optional Expo Go selection from this manifest. Missing or invalid Expo Go
122
+ metadata, or metadata for a different supplied SDK, uses normal SDK/archive selection. Legacy
123
+ serve-sim, agent-device and Argent entries are ignored, including malformed entries. Exact CLI
124
+ version inputs are recorded only in the current boot's state and claim.
125
+
126
+ Build-tools' shared `readPreparedSimulatorToolAsync(tool, schema)` reader selects an entry from
127
+ `tools` using the consumer's schema. Each consumer checks compatibility before reuse. Missing,
128
+ invalid or older metadata is a cache miss and uses normal setup.
129
+
130
+ Keep the Expo Go archive and the whole Appium home, not only the manifest. Appium's home
131
+ must stay at the recorded path under the same user. Rerun `prefetch` to regenerate the manifest
132
+ when changing versions. Metadata does not prove that a driver loads or WDA launches; validate
133
+ Appium reuse with a real session.
134
+
58
135
  ## Boundaries
59
136
 
137
+ Native warmup still runs serve-sim, agent-device and Argent. Bun may cache their packages as a side
138
+ effect; these incidental caches are retained. The caller supplies the requested package selections
139
+ for each boot, and Bun reuses matching files or fetches the requested versions. Native build-cache
140
+ reuse depends on the selected version and device.
141
+
60
142
  - Ready means the default device booted and serve-sim answers. The apsd step and the Expo Go
61
143
  preinstall run in the background on every listed device. A claim does not wait for them; stop
62
144
  joins them.
@@ -67,13 +149,15 @@ serializes updates; an abandoned lock fails closed. This private format requires
67
149
  - Agent-device prestarts on the default device only. A secondary claim prepares its runner after
68
150
  adoption and old-runner cleanup finish. One device-independent Argent server is reused for the claimed device.
69
151
  Appium waits for unused tools to stop before starting its own WDA.
70
- - Warmup downloads/extracts the latest stable Expo Go once and reuses it for the second device.
152
+ - Warmup uses the prepared Expo Go selection, or the standalone SDK selection when none exists, once, from the
153
+ prefetched archive (see
154
+ [Prepared files](#prepared-files)) or by download, and reuses it for the second device.
71
155
  Each initial device gets a preinstall attempt; ordinary failures warn. Claim prevents new
72
156
  preinstalls. `prepare-tools` waits for an install still running on the claimed device and
73
157
  reports its version, because the job installs its app next. Installs on other devices continue;
74
158
  adoption may shut such a device down, and its install then fails with a warning. Terminal stop
75
159
  drains them and the download cleanup. Job app installs remain
76
- authoritative. Replacements do not preinstall again. The VM image provides ffmpeg.
160
+ authoritative. Replacements do not preinstall again. `ffmpeg` must be available on PATH.
77
161
  - One start attempt and one accepted claim per boot. Failed cleanup never permits another session.
78
162
  Stop's caller timeout is not a global cleanup deadline or proof that teardown completed.
79
163
  A build-tools claim timeout uses normal startup only after confirmed terminal cleanup.