UNPKG

xdl

Version:
1 lines 17.9 kB
{"version":3,"file":"CoreSimulator.js","names":["_fs","data","_interopRequireDefault","require","_getenv","_glob","_os","_path","_internal","_parseBinaryPlistAsync","obj","__esModule","default","EXPO_USE_CORE_SIM","boolish","isEnabled","DeviceState","CoreSimulatorError","Error","constructor","message","code","exports","getDevicesDirectory","path","join","os","homedir","getDirectoryForDeviceAsync","udid","deviceFolder","fs","existsSync","possibleUdids","getDirectoriesAsync","errorMessage","length","resolveUdidAsync","bootedDevice","getBootedDeviceAsync","UDID","Logger","global","debug","listDevicesAsync","devicesDirectory","devices","Promise","all","map","device","plistPath","parseBinaryPlistAsync","devicePlistToSimulatorDevice","filter","Boolean","getDeviceInfoAsync","deviceDirectory","runtimeSuffix","runtime","split","pop","osType","osVersionComponents","osVersion","dataPath","logPath","isAvailable","isDeleted","deviceTypeIdentifier","deviceType","state","BOOTED","name","windowName","isBooted","resolve","reject","complete","error","getContainerPathAsync","bundleIdentifier","appsFolder","apps","app","appFolder","MCMMetadataIdentifier","binaryPath","findBinaryFileInDirectory","folder","globSync","absolute","cwd","directory","promises","readdir","withFileTypes","catch","isDirectory"],"sources":["../../src/apple/CoreSimulator.ts"],"sourcesContent":["import fs from 'fs';\nimport { boolish } from 'getenv';\nimport { sync as globSync } from 'glob';\nimport os from 'os';\nimport path from 'path';\n\nimport { SimulatorDevice } from '../SimControl';\nimport { Logger } from '../internal';\nimport { parseBinaryPlistAsync } from '../utils/parseBinaryPlistAsync';\n\n// Enable this to test the JS version of simctl\nconst EXPO_USE_CORE_SIM = boolish('EXPO_USE_CORE_SIM', false);\n\nexport function isEnabled() {\n return EXPO_USE_CORE_SIM;\n}\n\nenum DeviceState {\n BOOTED = 3,\n SHUTDOWN = 1,\n}\n\nexport class CoreSimulatorError extends Error {\n constructor(public message: string, public code?: 'MALFORMED_BINARY' | 'INVALID_UDID') {\n super(message);\n }\n}\n\n/**\n * CoreSimulator devices folder.\n *\n * @returns /Users/evanbacon/Library/Developer/CoreSimulator/Devices\n */\nfunction getDevicesDirectory(): string {\n return path.join(os.homedir(), '/Library/Developer/CoreSimulator/Devices/');\n}\n\n/**\n * CoreSimulator device folder, asserts when the device is invalid.\n *\n * @param props.udid device udid. Cannot be `booted`.\n * @returns /Users/evanbacon/Library/Developer/CoreSimulator/Devices/EFEEA6EF-E3F5-4EDE-9B72-29EAFA7514AE/\n */\nasync function getDirectoryForDeviceAsync(udid: string): Promise<string> {\n const deviceFolder = path.join(getDevicesDirectory(), udid);\n\n // Invalid udid (no matching device)\n if (!fs.existsSync(deviceFolder)) {\n const possibleUdids = await getDirectoriesAsync(getDevicesDirectory());\n let errorMessage = `Invalid iOS Simulator device UDID: ${udid}.`;\n if (possibleUdids.length) {\n errorMessage += ` Expected one of: ${possibleUdids.join(', ')}`;\n }\n throw new CoreSimulatorError(errorMessage, 'INVALID_UDID');\n }\n return deviceFolder;\n}\n\nasync function resolveUdidAsync(udid: string): Promise<string> {\n if (udid === 'booted') {\n const bootedDevice = await getBootedDeviceAsync();\n if (!bootedDevice) {\n throw new CoreSimulatorError('No devices are booted.', 'INVALID_UDID');\n }\n udid = bootedDevice.UDID;\n Logger.global.debug('Resolved booted device: ' + udid);\n }\n return udid;\n}\n\nexport async function listDevicesAsync(): Promise<SimulatorDevice[]> {\n const devicesDirectory = getDevicesDirectory();\n const devices = await getDirectoriesAsync(devicesDirectory);\n\n return (\n await Promise.all(\n devices.map(\n async (device): Promise<SimulatorDevice | null> => {\n const plistPath = path.join(devicesDirectory, device, 'device.plist');\n if (!fs.existsSync(plistPath)) return null;\n // The plist is stored in binary format\n const data = await parseBinaryPlistAsync(plistPath);\n return devicePlistToSimulatorDevice(devicesDirectory, data);\n }\n )\n )\n ).filter(Boolean) as SimulatorDevice[];\n}\n\nexport async function getDeviceInfoAsync({\n udid,\n}: { udid?: string } = {}): Promise<SimulatorDevice> {\n if (!udid || udid === 'booted') {\n const bootedDevice = await getBootedDeviceAsync();\n if (!bootedDevice) {\n throw new CoreSimulatorError('No devices are booted.', 'INVALID_UDID');\n }\n const deviceDirectory = await getDirectoryForDeviceAsync(bootedDevice.UDID);\n return devicePlistToSimulatorDevice(deviceDirectory, bootedDevice);\n }\n\n const deviceDirectory = await getDirectoryForDeviceAsync(udid);\n const plistPath = path.join(deviceDirectory, 'device.plist');\n // The plist is stored in binary format\n const data = await parseBinaryPlistAsync(plistPath);\n return devicePlistToSimulatorDevice(deviceDirectory, data);\n}\n\nexport function devicePlistToSimulatorDevice(deviceDirectory: string, data: any): SimulatorDevice {\n const runtimeSuffix = data.runtime.split('com.apple.CoreSimulator.SimRuntime.').pop()!;\n // Create an array [tvOS, 13, 4]\n const [osType, ...osVersionComponents] = runtimeSuffix.split('-');\n // Join the end components [13, 4] -> '13.4'\n const osVersion = osVersionComponents.join('.');\n return {\n ...data,\n /**\n * '/Users/name/Library/Developer/CoreSimulator/Devices/00E55DC0-0364-49DF-9EC6-77BE587137D4/data'\n */\n dataPath: path.join(deviceDirectory, 'data'),\n /**\n * '/Users/name/Library/Logs/CoreSimulator/00E55DC0-0364-49DF-9EC6-77BE587137D4'\n */\n logPath: path.join(os.homedir(), 'Library/Logs/CoreSimulator', data.UDID),\n /**\n * '00E55DC0-0364-49DF-9EC6-77BE587137D4'\n */\n udid: data.UDID,\n /**\n * com.apple.CoreSimulator.SimRuntime.tvOS-13-4\n */\n runtime: data.runtime,\n isAvailable: !data.isDeleted,\n /**\n * 'com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p'\n */\n deviceTypeIdentifier: data.deviceType,\n state: data.state === DeviceState.BOOTED ? 'Booted' : 'Shutdown',\n /**\n * 'Apple TV'\n */\n name: data.name,\n\n /**\n * 'iOS'\n */\n osType: osType as SimulatorDevice['osType'],\n /**\n * '13.4'\n */\n osVersion,\n /**\n * 'iPhone 11 (13.6)'\n */\n windowName: `${data.name} (${osVersion})`,\n\n // Compare state stored under `state` to 3 (booted)\n isBooted: data.state === DeviceState.BOOTED,\n };\n}\n\n/**\n * Get UDID for the first booted simulator. It's unclear if this is the exact method used by `xcrun simctl` to determine which device is \"booted\".\n *\n * @returns EFEEA6EF-E3F5-4EDE-9B72-29EAFA7514AE\n */\nexport async function getBootedDeviceAsync(): Promise<{ UDID: string } | null> {\n const devicesDirectory = getDevicesDirectory();\n const devices = await getDirectoriesAsync(devicesDirectory);\n\n // parallelize searching for the matching app\n return new Promise<{ UDID: string } | null>(async (resolve, reject) => {\n let complete: boolean = false;\n try {\n await Promise.all(\n devices.map(async device => {\n if (complete) return;\n const plistPath = path.join(devicesDirectory, device, 'device.plist');\n // The plist is stored in binary format\n const data = await parseBinaryPlistAsync(plistPath);\n // Compare state stored under `state` to 3 (booted)\n if (data.state === DeviceState.BOOTED) {\n complete = true;\n resolve(data);\n }\n })\n );\n if (!complete) {\n resolve(null);\n }\n } catch (error: any) {\n if (!complete) {\n reject(error);\n }\n }\n });\n}\n\n/**\n * Returns the local path for the installed binary.app on a given Apple simulator. Returns null when the app isn't installed.\n *\n * This can be used as a replacement for `xcrun simctl get_app_container <udid> <bundleIdentifier>` but it's over 200x faster.\n *\n * @param props.udid device udid.\n * @param props.bundleIdentifier bundle identifier for app\n * @returns local file path to installed app binary, e.g. '/Users/evanbacon/Library/Developer/CoreSimulator/Devices/EFEEA6EF-E3F5-4EDE-9B72-29EAFA7514AE/data/Containers/Bundle/Application/FA43A0C6-C2AD-442D-B8B1-EAF3E88CF3BF/Exponent-2.21.3.tar.app'\n */\nexport async function getContainerPathAsync({\n udid,\n bundleIdentifier,\n}: {\n udid: string;\n bundleIdentifier: string;\n}): Promise<string | null> {\n udid = await resolveUdidAsync(udid);\n // Like: `/Users/evanbacon/Library/Developer/CoreSimulator/Devices/EFEEA6EF-E3F5-4EDE-9B72-29EAFA7514AE/data/Containers/Bundle/Application/`\n // TODO: Maybe shallow glob for `.com.apple.mobile_container_manager.metadata.plist` to find apps faster\n const appsFolder = path.join(\n await getDirectoryForDeviceAsync(udid),\n 'data/Containers/Bundle/Application'\n );\n\n // Get all apps for a device\n // Like: `['FA43A0C6-C2AD-442D-B8B1-EAF3E88CF3BF']`\n const apps = await getDirectoriesAsync(appsFolder);\n\n // parallelize searching for the matching app\n return new Promise<string | null>(async (resolve, reject) => {\n let complete: boolean = false;\n try {\n await Promise.all(\n apps.map(async app => {\n if (complete) return;\n const appFolder = path.join(appsFolder, app);\n const plistPath = path.join(\n appFolder,\n '.com.apple.mobile_container_manager.metadata.plist'\n );\n // The plist is stored in binary format\n const data = await parseBinaryPlistAsync(plistPath);\n // Compare bundle identifier stored under `MCMMetadataIdentifier`\n if (data.MCMMetadataIdentifier === bundleIdentifier) {\n // Find .app file in the app folder\n const binaryPath = findBinaryFileInDirectory(appFolder);\n if (!binaryPath) {\n throw new CoreSimulatorError(\n `Found matching app container at \"${appFolder}\" but binary (*.app file) is missing.`,\n 'MALFORMED_BINARY'\n );\n }\n complete = true;\n resolve(binaryPath);\n }\n })\n );\n if (!complete) {\n resolve(null);\n }\n } catch (error: any) {\n if (!complete) {\n reject(error);\n }\n }\n });\n}\n\nfunction findBinaryFileInDirectory(folder: string) {\n // Find .app file in the app folder\n const binaryPath = globSync('*.app', {\n absolute: true,\n cwd: folder,\n })[0];\n\n return binaryPath || null;\n}\n\nasync function getDirectoriesAsync(directory: string) {\n return (await fs.promises.readdir(directory, { withFileTypes: true }).catch(() => []))\n .filter(device => device.isDirectory())\n .map(device => device.name);\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,KAAA,YAAAA,CAAA;IA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