Convert iOSDevice dispatcher to TS
Summary: Convert iOSDevice dispatcher to TS Reviewed By: passy Differential Revision: D16690183 fbshipit-source-id: 629ac178e91b4774449503529df7e07cee6741c5
This commit is contained in:
committed by
Facebook Github Bot
parent
6da09fa381
commit
4afc417ea5
@@ -5,28 +5,28 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {ChildProcess} from 'child_process';
|
import {ChildProcess} from 'child_process';
|
||||||
import type {Store} from '../reducers/index.tsx';
|
import {Store} from '../reducers/index';
|
||||||
import type {Logger} from '../fb-interfaces/Logger.js';
|
import {Logger} from '../fb-interfaces/Logger.js';
|
||||||
import type {DeviceType} from '../devices/BaseDevice.tsx';
|
import {DeviceType} from '../devices/BaseDevice';
|
||||||
import {promisify} from 'util';
|
import {promisify} from 'util';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import child_process from 'child_process';
|
import child_process from 'child_process';
|
||||||
const execFile = child_process.execFile;
|
const execFile = child_process.execFile;
|
||||||
import iosUtil from '../fb-stubs/iOSContainerUtility.tsx';
|
import iosUtil from '../fb-stubs/iOSContainerUtility';
|
||||||
import IOSDevice from '../devices/IOSDevice.tsx';
|
import IOSDevice from '../devices/IOSDevice';
|
||||||
import isProduction from '../utils/isProduction.js';
|
import isProduction from '../utils/isProduction.js';
|
||||||
import GK from '../fb-stubs/GK.tsx';
|
import GK from '../fb-stubs/GK';
|
||||||
import {registerDeviceCallbackOnPlugins} from '../utils/onRegisterDevice.js';
|
import {registerDeviceCallbackOnPlugins} from '../utils/onRegisterDevice.js';
|
||||||
type iOSSimulatorDevice = {|
|
type iOSSimulatorDevice = {
|
||||||
state: 'Booted' | 'Shutdown' | 'Shutting Down',
|
state: 'Booted' | 'Shutdown' | 'Shutting Down';
|
||||||
availability?: string,
|
availability?: string;
|
||||||
isAvailable?: 'YES' | 'NO' | true | false,
|
isAvailable?: 'YES' | 'NO' | true | false;
|
||||||
name: string,
|
name: string;
|
||||||
udid: string,
|
udid: string;
|
||||||
|};
|
};
|
||||||
|
|
||||||
type IOSDeviceParams = {udid: string, type: DeviceType, name: string};
|
type IOSDeviceParams = {udid: string; type: DeviceType; name: string};
|
||||||
|
|
||||||
function isAvailable(simulator: iOSSimulatorDevice): boolean {
|
function isAvailable(simulator: iOSSimulatorDevice): boolean {
|
||||||
// For some users "availability" is set, for others it's "isAvailable"
|
// For some users "availability" is set, for others it's "isAvailable"
|
||||||
@@ -123,9 +123,10 @@ function getActiveSimulators(): Promise<Array<IOSDeviceParams>> {
|
|||||||
)
|
)
|
||||||
.then(({stdout}) => JSON.parse(stdout).devices)
|
.then(({stdout}) => JSON.parse(stdout).devices)
|
||||||
.then(simulatorDevices => {
|
.then(simulatorDevices => {
|
||||||
|
// @ts-ignore
|
||||||
const simulators: Array<iOSSimulatorDevice> = Object.values(
|
const simulators: Array<iOSSimulatorDevice> = Object.values(
|
||||||
simulatorDevices,
|
simulatorDevices,
|
||||||
// $FlowFixMe
|
// @ts-ignore
|
||||||
).reduce((acc, cv) => acc.concat(cv), []);
|
).reduce((acc, cv) => acc.concat(cv), []);
|
||||||
|
|
||||||
return simulators
|
return simulators
|
||||||
@@ -137,7 +138,7 @@ function getActiveSimulators(): Promise<Array<IOSDeviceParams>> {
|
|||||||
udid: simulator.udid,
|
udid: simulator.udid,
|
||||||
type: 'emulator',
|
type: 'emulator',
|
||||||
name: simulator.name,
|
name: simulator.name,
|
||||||
};
|
} as IOSDeviceParams;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(_ => []);
|
.catch(_ => []);
|
||||||
@@ -179,7 +180,7 @@ async function checkXcodeVersionMismatch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getActiveDevicesAndSimulators(): Promise<
|
export async function getActiveDevicesAndSimulators(): Promise<
|
||||||
Array<IOSDevice>,
|
Array<IOSDevice>
|
||||||
> {
|
> {
|
||||||
const activeDevices: Array<Array<IOSDeviceParams>> = await Promise.all([
|
const activeDevices: Array<Array<IOSDeviceParams>> = await Promise.all([
|
||||||
getActiveSimulators(),
|
getActiveSimulators(),
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
import {getActiveAndroidDevices} from '../dispatcher/androidDevice.tsx';
|
import {getActiveAndroidDevices} from '../dispatcher/androidDevice.tsx';
|
||||||
import {getActiveDevicesAndSimulators} from '../dispatcher/iOSDevice';
|
import {getActiveDevicesAndSimulators} from '../dispatcher/iOSDevice.tsx';
|
||||||
import type BaseDevice from '../devices/BaseDevice.tsx';
|
import type BaseDevice from '../devices/BaseDevice.tsx';
|
||||||
|
|
||||||
export async function listDevices(): Promise<Array<BaseDevice>> {
|
export async function listDevices(): Promise<Array<BaseDevice>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user