MCPcopy Index your code
hub / github.com/callstack/agent-device / resolveTargetDevice

Function resolveTargetDevice

src/core/dispatch-resolve.ts:122–180  ·  view source on GitHub ↗
(
  flags: ResolveDeviceFlags,
  options: ResolveTargetDeviceOptions = {},
)

Source from the content-addressed store, hash-verified

120}
121
122export async function resolveTargetDevice(
123 flags: ResolveDeviceFlags,
124 options: ResolveTargetDeviceOptions = {},
125): Promise<DeviceInfo> {
126 const inventoryRequest = buildDeviceInventoryRequestFromFlags(flags);
127 const { iosSimulatorSetPath, ...selector } = inventoryRequest;
128 const cacheKey = buildResolveTargetDeviceCacheKey(inventoryRequest, options);
129 const selectionContext = {
130 simulatorSetPath: iosSimulatorSetPath,
131 allowStoppedAndroidAvdPlaceholders: options.allowStoppedAndroidAvdPlaceholders,
132 };
133 const diagnosticData = {
134 platform: inventoryRequest.platform,
135 target: flags.target,
136 cacheHit: false,
137 };
138 return await withDiagnosticTimer(
139 'resolve_target_device',
140 async () => {
141 const cached = readResolveTargetDeviceCache(cacheKey);
142 if (cached) {
143 diagnosticData.cacheHit = true;
144 return cached;
145 }
146 const injectedDevices = await readInjectedDeviceInventory(inventoryRequest);
147 if (injectedDevices) {
148 if (isAppleResolutionSelector(selector)) {
149 return cacheResolvedTargetDevice(
150 cacheKey,
151 await resolveAppleDevice(injectedDevices, selector as AppleDeviceSelector, {
152 simulatorSetPath: iosSimulatorSetPath,
153 }),
154 );
155 }
156 return cacheResolvedTargetDevice(
157 cacheKey,
158 await resolveDevice(injectedDevices, selector, selectionContext),
159 );
160 }
161
162 const devices = await listLocalDeviceInventory(inventoryRequest);
163
164 if (isAppleResolutionSelector(selector)) {
165 return cacheResolvedTargetDevice(
166 cacheKey,
167 await resolveAppleDevice(devices, selector as AppleDeviceSelector, {
168 simulatorSetPath: iosSimulatorSetPath,
169 }),
170 );
171 }
172
173 return cacheResolvedTargetDevice(
174 cacheKey,
175 await resolveDevice(devices, selector, selectionContext),
176 );
177 },
178 diagnosticData,
179 );

Callers 12

createSelectorRuntimeFunction · 0.90
handleOpenCommandFunction · 0.90
resolveSessionDeviceFunction · 0.90
handleRecordCommandFunction · 0.90
resolveCommandDeviceFunction · 0.90
resolveInstallDeviceFunction · 0.90
handleFindCommandsFunction · 0.90

Calls 10

withDiagnosticTimerFunction · 0.90
resolveDeviceFunction · 0.90
listLocalDeviceInventoryFunction · 0.90
resolveAppleDeviceFunction · 0.85

Tested by

no test coverage detected