@expo/cli 0.1.1 → 0.1.4
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/build/bin/cli +8 -2
- package/build/bin/cli.map +1 -1
- package/build/src/export/index.js +1 -0
- package/build/src/export/index.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +3 -3
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -0
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/hints.js +1 -1
- package/build/src/run/hints.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +275 -0
- package/build/src/run/ios/XcodeBuild.js.map +1 -0
- package/build/src/run/ios/XcodeBuild.types.js +6 -0
- package/build/src/run/ios/XcodeBuild.types.js.map +1 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js +161 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -0
- package/build/src/run/ios/appleDevice/ClientManager.js +161 -0
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js +195 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js +107 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +97 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js +140 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +91 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js +21 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +117 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +90 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +332 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js +115 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +126 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +74 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js +65 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js.map +1 -0
- package/build/src/run/ios/codeSigning/Security.js +85 -0
- package/build/src/run/ios/codeSigning/Security.js.map +1 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js +77 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +102 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -0
- package/build/src/run/ios/codeSigning/settings.js +21 -0
- package/build/src/run/ios/codeSigning/settings.js.map +1 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +76 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -0
- package/build/src/run/ios/index.js +98 -0
- package/build/src/run/ios/index.js.map +1 -0
- package/build/src/run/ios/launchApp.js +75 -0
- package/build/src/run/ios/launchApp.js.map +1 -0
- package/build/src/run/ios/options/promptDevice.js +50 -0
- package/build/src/run/ios/options/promptDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveDevice.js +92 -0
- package/build/src/run/ios/options/resolveDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveNativeScheme.js +92 -0
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -0
- package/build/src/run/ios/options/resolveOptions.js +44 -0
- package/build/src/run/ios/options/resolveOptions.js.map +1 -0
- package/build/src/run/ios/options/resolveXcodeProject.js +39 -0
- package/build/src/run/ios/options/resolveXcodeProject.js.map +1 -0
- package/build/src/run/ios/runIosAsync.js +85 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -0
- package/build/src/run/resolveBundlerProps.js +9 -6
- package/build/src/run/resolveBundlerProps.js.map +1 -1
- package/build/src/run/startBundler.js +4 -2
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/Prerequisite.js +4 -4
- package/build/src/start/doctor/Prerequisite.js.map +1 -1
- package/build/src/start/doctor/SecurityBinPrerequisite.js +27 -0
- package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js +69 -0
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js.map +1 -0
- package/build/src/start/platforms/android/emulator.js +8 -0
- package/build/src/start/platforms/android/emulator.js.map +1 -1
- package/build/src/start/platforms/android/promptAndroidDevice.js +1 -5
- package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +5 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/promptAppleDevice.js +1 -5
- package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +14 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/platforms/ios/simctlLogging.js +220 -0
- package/build/src/start/platforms/ios/simctlLogging.js.map +1 -0
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +30 -3
- package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
- package/build/src/utils/cocoapods.js +47 -0
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/dir.js +6 -1
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/plist.js +59 -0
- package/build/src/utils/plist.js.map +1 -0
- package/build/src/utils/prompts.js +16 -0
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/resolveArgs.js +4 -1
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/build/src/utils/terminal.js +10 -0
- package/build/src/utils/terminal.js.map +1 -0
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/platforms/ios/AppleDeviceManager.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { delayAsync, waitForActionAsync } from '../../../utils/delay';\nimport { CommandError } from '../../../utils/errors';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\nimport { assertSystemRequirementsAsync } from './assertSystemRequirements';\nimport { ensureSimulatorAppRunningAsync } from './ensureSimulatorAppRunning';\nimport {\n getBestBootedSimulatorAsync,\n getBestUnbootedSimulatorAsync,\n getSelectableSimulatorsAsync,\n} from './getBestSimulator';\nimport { promptAppleDeviceAsync } from './promptAppleDevice';\nimport * as SimControl from './simctl';\n\nconst EXPO_GO_BUNDLE_IDENTIFIER = 'host.exp.Exponent';\n\n/**\n * Ensure a simulator is booted and the Simulator app is opened.\n * This is where any timeout related error handling should live.\n */\nexport async function ensureSimulatorOpenAsync(\n { udid, osType }: Partial<Pick<SimControl.Device, 'udid' | 'osType'>> = {},\n tryAgain: boolean = true\n): Promise<SimControl.Device> {\n // Use a default simulator if none was specified\n if (!udid) {\n // If a simulator is open, side step the entire booting sequence.\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp;\n }\n\n // Otherwise, find the best possible simulator from user defaults and continue\n const bestUdid = await getBestUnbootedSimulatorAsync({ osType });\n if (!bestUdid) {\n throw new CommandError('No simulators found.');\n }\n udid = bestUdid;\n }\n\n const bootedDevice = await waitForActionAsync({\n action: () => {\n // Just for the type check.\n assert(udid);\n return SimControl.bootAsync({ udid });\n },\n });\n\n if (!bootedDevice) {\n // Give it a second chance, this might not be needed but it could potentially lead to a better UX on slower devices.\n if (tryAgain) {\n return await ensureSimulatorOpenAsync({ udid, osType }, false);\n }\n // TODO: We should eliminate all needs for a timeout error, it's bad UX to get an error about the simulator not starting while the user can clearly see it starting on their slow computer.\n throw new CommandError(\n 'SIMULATOR_TIMEOUT',\n `Simulator didn't boot fast enough. Try opening Simulator first, then running your app.`\n );\n }\n return bootedDevice;\n}\nexport class AppleDeviceManager extends DeviceManager<SimControl.Device> {\n static assertSystemRequirementsAsync = assertSystemRequirementsAsync;\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<\n Pick<SimControl.Device, 'udid' | 'osType'>\n > = {}): Promise<AppleDeviceManager> {\n if (shouldPrompt) {\n const devices = await getSelectableSimulatorsAsync(device);\n device = await promptAppleDeviceAsync(devices, device?.osType);\n }\n\n const booted = await ensureSimulatorOpenAsync(device);\n return new AppleDeviceManager(booted);\n }\n\n get name() {\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.udid;\n }\n\n async getAppVersionAsync(appId: string): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n });\n }\n\n async startAsync(): Promise<SimControl.Device> {\n return ensureSimulatorOpenAsync({ osType: this.device.osType, udid: this.device.udid });\n }\n\n async launchApplicationIdAsync(appId: string) {\n try {\n const result = await SimControl.openAppIdAsync(this.device, {\n appId,\n });\n if (result.status === 0) {\n await this.activateWindowAsync();\n } else {\n throw new CommandError(result.stderr);\n }\n } catch (error: any) {\n let errorMessage = `Couldn't open iOS app with ID \"${appId}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `expo run:ios -d ${this.device.udid}`\n )}`;\n }\n if (error.stderr) {\n errorMessage += chalk.gray(`\\n${error.stderr}`);\n } else if (error.message) {\n errorMessage += chalk.gray(`\\n${error.message}`);\n }\n throw new CommandError(errorMessage);\n }\n }\n\n async installAppAsync(filePath: string) {\n await SimControl.installAsync(this.device, {\n filePath,\n });\n\n await this.waitForAppInstalledAsync(await this.getApplicationIdFromBundle(filePath));\n }\n\n private async getApplicationIdFromBundle(filePath: string): Promise<string> {\n // TODO: Implement...\n return EXPO_GO_BUNDLE_IDENTIFIER;\n }\n\n private async waitForAppInstalledAsync(applicationId: string): Promise<boolean> {\n while (true) {\n if (await this.isAppInstalledAsync(applicationId)) {\n return true;\n }\n await delayAsync(100);\n }\n }\n\n async uninstallAppAsync(appId: string) {\n await SimControl.uninstallAsync(this.device, {\n appId,\n });\n }\n\n async isAppInstalledAsync(appId: string) {\n return !!(await SimControl.getContainerPathAsync(this.device, {\n appId,\n }));\n }\n\n async openUrlAsync(url: string) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n return await this.launchApplicationIdAsync(url);\n }\n\n try {\n await SimControl.openUrlAsync(this.device, { url });\n } catch (error: any) {\n // 194 means the device does not conform to a given URL, in this case we'll assume that the desired app is not installed.\n if (error.status === 194) {\n // An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):\n // The operation couldn’t be completed. (OSStatus error -10814.)\n //\n // This can be thrown when no app conforms to the URI scheme that we attempted to open.\n throw new CommandError(\n 'APP_NOT_INSTALLED',\n `Device ${this.device.name} (${this.device.udid}) has no app to handle the URI: ${url}`\n );\n }\n throw error;\n }\n }\n\n async activateWindowAsync() {\n await ensureSimulatorAppRunningAsync(this.device);\n // TODO: Focus the individual window\n await osascript.execAsync(`tell application \"Simulator\" to activate`);\n }\n\n async ensureExpoGoAsync(sdkVersion?: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('ios', EXPO_GO_BUNDLE_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["ensureSimulatorOpenAsync","osascript","SimControl","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","bootAsync","AppleDeviceManager","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","getInfoPlistValueAsync","key","startAsync","launchApplicationIdAsync","result","openAppIdAsync","status","activateWindowAsync","stderr","error","errorMessage","code","chalk","bold","gray","message","installAppAsync","filePath","installAsync","waitForAppInstalledAsync","getApplicationIdFromBundle","applicationId","isAppInstalledAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","execAsync","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;QA0BsBA,wBAAwB,GAAxBA,wBAAwB;AA1BlCC,IAAAA,SAAS,mCAAM,iBAAiB,EAAvB;AACF,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEsB,IAAA,MAAsB,WAAtB,sBAAsB,CAAA;AACxC,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACxB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAClB,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;AAChB,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;AAEN,IAAA,yBAA4B,WAA5B,4BAA4B,CAAA;AAC3B,I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AAC,OAAOnB,KAAK,EAAO;YACnB,yHAAyH;YACzH,IAAIA,KAAK,CAACH,MAAM,KAAK,GAAG,EAAE;gBACxB,+FAA+F;gBAC/F,kEAAgE;gBAChE,EAAE;gBACF,uFAAuF;gBACvF,MAAM,IAAI1B,OAAY,aAAA,CACpB,mBAAmB,EACnB,CAAC,OAAO,EAAE,IAAI,CAACU,MAAM,CAACM,IAAI,CAAC,EAAE,EAAE,IAAI,CAACN,MAAM,CAACjB,IAAI,CAAC,gCAAgC,EAAEuD,GAAG,CAAC,CAAC,CACxF,CAAC;aACH;YACD,MAAMnB,KAAK,CAAC;SACb;KACF;IAED,MAAMF,mBAAmB,GAAG;QAC1B,MAAMwB,CAAAA,GAAAA,0BAA8B,AAAa,CAAA,+BAAb,CAAC,IAAI,CAACzC,MAAM,CAAC,CAAC;QAClD,oCAAoC;QACpC,MAAMpB,SAAS,CAAC8D,SAAS,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC;KACvE;IAED,MAAMC,iBAAiB,CAACC,UAAmB,EAAoB;QAC7D,MAAMC,SAAS,GAAG,IAAIC,gBAAe,gBAAA,CAAC,KAAK,EAAEhE,yBAAyB,EAAE8D,UAAU,CAAC,AAAC;QACpF,OAAOC,SAAS,CAACE,WAAW,CAAC,IAAI,CAAC,CAAC;KACpC;CACF;QAnIYnD,kBAAkB,GAAlBA,kBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/platforms/ios/AppleDeviceManager.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { delayAsync, waitForActionAsync } from '../../../utils/delay';\nimport { CommandError } from '../../../utils/errors';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\nimport { assertSystemRequirementsAsync } from './assertSystemRequirements';\nimport { ensureSimulatorAppRunningAsync } from './ensureSimulatorAppRunning';\nimport {\n getBestBootedSimulatorAsync,\n getBestUnbootedSimulatorAsync,\n getSelectableSimulatorsAsync,\n} from './getBestSimulator';\nimport { promptAppleDeviceAsync } from './promptAppleDevice';\nimport * as SimControl from './simctl';\n\nconst EXPO_GO_BUNDLE_IDENTIFIER = 'host.exp.Exponent';\n\n/**\n * Ensure a simulator is booted and the Simulator app is opened.\n * This is where any timeout related error handling should live.\n */\nexport async function ensureSimulatorOpenAsync(\n { udid, osType }: Partial<Pick<SimControl.Device, 'udid' | 'osType'>> = {},\n tryAgain: boolean = true\n): Promise<SimControl.Device> {\n // Use a default simulator if none was specified\n if (!udid) {\n // If a simulator is open, side step the entire booting sequence.\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp;\n }\n\n // Otherwise, find the best possible simulator from user defaults and continue\n const bestUdid = await getBestUnbootedSimulatorAsync({ osType });\n if (!bestUdid) {\n throw new CommandError('No simulators found.');\n }\n udid = bestUdid;\n }\n\n const bootedDevice = await waitForActionAsync({\n action: () => {\n // Just for the type check.\n assert(udid);\n return SimControl.bootAsync({ udid });\n },\n });\n\n if (!bootedDevice) {\n // Give it a second chance, this might not be needed but it could potentially lead to a better UX on slower devices.\n if (tryAgain) {\n return await ensureSimulatorOpenAsync({ udid, osType }, false);\n }\n // TODO: We should eliminate all needs for a timeout error, it's bad UX to get an error about the simulator not starting while the user can clearly see it starting on their slow computer.\n throw new CommandError(\n 'SIMULATOR_TIMEOUT',\n `Simulator didn't boot fast enough. Try opening Simulator first, then running your app.`\n );\n }\n return bootedDevice;\n}\nexport class AppleDeviceManager extends DeviceManager<SimControl.Device> {\n static assertSystemRequirementsAsync = assertSystemRequirementsAsync;\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<\n Partial<Pick<SimControl.Device, 'udid' | 'osType'>>\n > = {}): Promise<AppleDeviceManager> {\n if (shouldPrompt) {\n const devices = await getSelectableSimulatorsAsync(device);\n device = await promptAppleDeviceAsync(devices, device?.osType);\n }\n\n const booted = await ensureSimulatorOpenAsync(device);\n return new AppleDeviceManager(booted);\n }\n\n get name() {\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.udid;\n }\n\n async getAppVersionAsync(appId: string): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n });\n }\n\n async startAsync(): Promise<SimControl.Device> {\n return ensureSimulatorOpenAsync({ osType: this.device.osType, udid: this.device.udid });\n }\n\n async launchApplicationIdAsync(appId: string) {\n try {\n const result = await SimControl.openAppIdAsync(this.device, {\n appId,\n });\n if (result.status === 0) {\n await this.activateWindowAsync();\n } else {\n throw new CommandError(result.stderr);\n }\n } catch (error: any) {\n let errorMessage = `Couldn't open iOS app with ID \"${appId}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n if (appId === EXPO_GO_BUNDLE_IDENTIFIER) {\n errorMessage = `Couldn't open Expo Go app on device \"${this.name}\". Please install.`;\n } else {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `expo run:ios -d ${this.device.udid}`\n )}`;\n }\n }\n if (error.stderr) {\n errorMessage += chalk.gray(`\\n${error.stderr}`);\n } else if (error.message) {\n errorMessage += chalk.gray(`\\n${error.message}`);\n }\n throw new CommandError(errorMessage);\n }\n }\n\n async installAppAsync(filePath: string) {\n await SimControl.installAsync(this.device, {\n filePath,\n });\n\n await this.waitForAppInstalledAsync(await this.getApplicationIdFromBundle(filePath));\n }\n\n private async getApplicationIdFromBundle(filePath: string): Promise<string> {\n // TODO: Implement...\n return EXPO_GO_BUNDLE_IDENTIFIER;\n }\n\n private async waitForAppInstalledAsync(applicationId: string): Promise<boolean> {\n while (true) {\n if (await this.isAppInstalledAsync(applicationId)) {\n return true;\n }\n await delayAsync(100);\n }\n }\n\n async uninstallAppAsync(appId: string) {\n await SimControl.uninstallAsync(this.device, {\n appId,\n });\n }\n\n async isAppInstalledAsync(appId: string) {\n return !!(await SimControl.getContainerPathAsync(this.device, {\n appId,\n }));\n }\n\n async openUrlAsync(url: string) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n return await this.launchApplicationIdAsync(url);\n }\n\n try {\n await SimControl.openUrlAsync(this.device, { url });\n } catch (error: any) {\n // 194 means the device does not conform to a given URL, in this case we'll assume that the desired app is not installed.\n if (error.status === 194) {\n // An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):\n // The operation couldn’t be completed. (OSStatus error -10814.)\n //\n // This can be thrown when no app conforms to the URI scheme that we attempted to open.\n throw new CommandError(\n 'APP_NOT_INSTALLED',\n `Device ${this.device.name} (${this.device.udid}) has no app to handle the URI: ${url}`\n );\n }\n throw error;\n }\n }\n\n async activateWindowAsync() {\n await ensureSimulatorAppRunningAsync(this.device);\n // TODO: Focus the individual window\n await osascript.execAsync(`tell application \"Simulator\" to activate`);\n }\n\n async ensureExpoGoAsync(sdkVersion?: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('ios', EXPO_GO_BUNDLE_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["ensureSimulatorOpenAsync","osascript","SimControl","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","bootAsync","AppleDeviceManager","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","getInfoPlistValueAsync","key","startAsync","launchApplicationIdAsync","result","openAppIdAsync","status","activateWindowAsync","stderr","error","errorMessage","code","chalk","bold","gray","message","installAppAsync","filePath","installAsync","waitForAppInstalledAsync","getApplicationIdFromBundle","applicationId","isAppInstalledAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","execAsync","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;QA0BsBA,wBAAwB,GAAxBA,wBAAwB;AA1BlCC,IAAAA,SAAS,mCAAM,iBAAiB,EAAvB;AACF,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEsB,IAAA,MAAsB,WAAtB,sBAAsB,CAAA;AACxC,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACxB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAClB,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;AAChB,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;AAEN,IAAA,yBAA4B,WAA5B,4BAA4B,CAAA;AAC3B,IAAA,0BAA6B,WAA7B,6BAA6B,CAAA;AAKrE,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AACY,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AAChDC,IAAAA,UAAU,mCAAM,UAAU,EAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtB,MAAMC,yBAAyB,GAAG,mBAAmB,AAAC;AAM/C,eAAeH,wBAAwB,CAC5C,EAAEI,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAuD,GAAG,EAAE,EAC1EC,QAAiB,GAAG,IAAI,EACI;IAC5B,gDAAgD;IAChD,IAAI,CAACF,IAAI,EAAE;QACT,iEAAiE;QACjE,MAAMG,oBAAoB,GAAG,MAAMC,CAAAA,GAAAA,iBAA2B,AAAY,CAAA,4BAAZ,CAAC;YAAEH,MAAM;SAAE,CAAC,AAAC;QAC3E,IAAIE,oBAAoB,EAAE;YACxB,OAAOA,oBAAoB,CAAC;SAC7B;QAED,8EAA8E;QAC9E,MAAME,QAAQ,GAAG,MAAMC,CAAAA,GAAAA,iBAA6B,AAAY,CA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D,oCAAoC;QACpC,MAAMpB,SAAS,CAAC8D,SAAS,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC;KACvE;IAED,MAAMC,iBAAiB,CAACC,UAAmB,EAAoB;QAC7D,MAAMC,SAAS,GAAG,IAAIC,gBAAe,gBAAA,CAAC,KAAK,EAAEhE,yBAAyB,EAAE8D,UAAU,CAAC,AAAC;QACpF,OAAOC,SAAS,CAACE,WAAW,CAAC,IAAI,CAAC,CAAC;KACpC;CACF;QAvIYnD,kBAAkB,GAAlBA,kBAAkB"}
|
|
@@ -48,11 +48,7 @@ async function promptAppleDeviceInternalAsync(devices) {
|
|
|
48
48
|
value: item.udid
|
|
49
49
|
};
|
|
50
50
|
}),
|
|
51
|
-
suggest: (
|
|
52
|
-
const regex = new RegExp(input, "i");
|
|
53
|
-
return choices.filter((choice)=>regex.test(choice.title)
|
|
54
|
-
);
|
|
55
|
-
}
|
|
51
|
+
suggest: (0, _prompts).createSelectionFilter()
|
|
56
52
|
});
|
|
57
53
|
return value;
|
|
58
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/platforms/ios/promptAppleDevice.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { promptAsync } from '../../../utils/prompts';\nimport { getBestSimulatorAsync } from './getBestSimulator';\nimport { Device } from './simctl';\n\n/**\n * Sort the devices so the last simulator that was opened (user's default) is the first suggested.\n *\n * @param devices list of devices to sort.\n * @param osType optional sort by operating system.\n */\nexport async function sortDefaultDeviceToBeginningAsync(\n devices: Device[],\n osType?: Device['osType']\n): Promise<Device[]> {\n const defaultId = await getBestSimulatorAsync({ osType });\n if (defaultId) {\n let iterations = 0;\n while (devices[0].udid !== defaultId && iterations < devices.length) {\n devices.push(devices.shift()!);\n iterations++;\n }\n }\n return devices;\n}\n\n/** Prompt the user to select an Apple device, sorting the most likely option to the beginning. */\nexport async function promptAppleDeviceAsync(\n devices: Device[],\n osType?: Device['osType']\n): Promise<Device> {\n devices = await sortDefaultDeviceToBeginningAsync(devices, osType);\n const results = await promptAppleDeviceInternalAsync(devices);\n return devices.find(({ udid }) => results === udid)!;\n}\n\nasync function promptAppleDeviceInternalAsync(devices: Device[]): Promise<string> {\n // TODO: provide an option to add or download more simulators\n // TODO: Add support for physical devices too.\n\n const { value } = await promptAsync({\n type: 'autocomplete',\n name: 'value',\n limit: 11,\n message: 'Select a simulator',\n choices: devices.map((item) => {\n const isActive = item.state === 'Booted';\n const format = isActive ? chalk.bold : (text: string) => text;\n return {\n title: `${format(item.name)} ${chalk.dim(`(${item.osVersion})`)}`,\n value: item.udid,\n };\n }),\n suggest: (
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/platforms/ios/promptAppleDevice.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { createSelectionFilter, promptAsync } from '../../../utils/prompts';\nimport { getBestSimulatorAsync } from './getBestSimulator';\nimport { Device } from './simctl';\n\n/**\n * Sort the devices so the last simulator that was opened (user's default) is the first suggested.\n *\n * @param devices list of devices to sort.\n * @param osType optional sort by operating system.\n */\nexport async function sortDefaultDeviceToBeginningAsync(\n devices: Device[],\n osType?: Device['osType']\n): Promise<Device[]> {\n const defaultId = await getBestSimulatorAsync({ osType });\n if (defaultId) {\n let iterations = 0;\n while (devices[0].udid !== defaultId && iterations < devices.length) {\n devices.push(devices.shift()!);\n iterations++;\n }\n }\n return devices;\n}\n\n/** Prompt the user to select an Apple device, sorting the most likely option to the beginning. */\nexport async function promptAppleDeviceAsync(\n devices: Device[],\n osType?: Device['osType']\n): Promise<Device> {\n devices = await sortDefaultDeviceToBeginningAsync(devices, osType);\n const results = await promptAppleDeviceInternalAsync(devices);\n return devices.find(({ udid }) => results === udid)!;\n}\n\nasync function promptAppleDeviceInternalAsync(devices: Device[]): Promise<string> {\n // TODO: provide an option to add or download more simulators\n // TODO: Add support for physical devices too.\n\n const { value } = await promptAsync({\n type: 'autocomplete',\n name: 'value',\n limit: 11,\n message: 'Select a simulator',\n choices: devices.map((item) => {\n const isActive = item.state === 'Booted';\n const format = isActive ? chalk.bold : (text: string) => text;\n return {\n title: `${format(item.name)} ${chalk.dim(`(${item.osVersion})`)}`,\n value: item.udid,\n };\n }),\n suggest: createSelectionFilter(),\n });\n\n return value;\n}\n"],"names":["sortDefaultDeviceToBeginningAsync","promptAppleDeviceAsync","devices","osType","defaultId","getBestSimulatorAsync","iterations","udid","length","push","shift","results","promptAppleDeviceInternalAsync","find","value","promptAsync","type","name","limit","message","choices","map","item","isActive","state","format","chalk","bold","text","title","dim","osVersion","suggest","createSelectionFilter"],"mappings":"AAAA;;;;QAYsBA,iCAAiC,GAAjCA,iCAAiC;QAgBjCC,sBAAsB,GAAtBA,sBAAsB;AA5B1B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAE0B,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;AACrC,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;;;;;;AASnD,eAAeD,iCAAiC,CACrDE,OAAiB,EACjBC,MAAyB,EACN;IACnB,MAAMC,SAAS,GAAG,MAAMC,CAAAA,GAAAA,iBAAqB,AAAY,CAAA,sBAAZ,CAAC;QAAEF,MAAM;KAAE,CAAC,AAAC;IAC1D,IAAIC,SAAS,EAAE;QACb,IAAIE,UAAU,GAAG,CAAC,AAAC;QACnB,MAAOJ,OAAO,CAAC,CAAC,CAAC,CAACK,IAAI,KAAKH,SAAS,IAAIE,UAAU,GAAGJ,OAAO,CAACM,MAAM,CAAE;YACnEN,OAAO,CAACO,IAAI,CAACP,OAAO,CAACQ,KAAK,EAAE,CAAE,CAAC;YAC/BJ,UAAU,EAAE,CAAC;SACd;KACF;IACD,OAAOJ,OAAO,CAAC;CAChB;AAGM,eAAeD,sBAAsB,CAC1CC,OAAiB,EACjBC,MAAyB,EACR;IACjBD,OAAO,GAAG,MAAMF,iCAAiC,CAACE,OAAO,EAAEC,MAAM,CAAC,CAAC;IACnE,MAAMQ,OAAO,GAAG,MAAMC,8BAA8B,CAACV,OAAO,CAAC,AAAC;IAC9D,OAAOA,OAAO,CAACW,IAAI,CAAC,CAAC,EAAEN,IAAI,CAAA,EAAE,GAAKI,OAAO,KAAKJ,IAAI;IAAA,CAAC,CAAE;CACtD;AAED,eAAeK,8BAA8B,CAACV,OAAiB,EAAmB;IAChF,6DAA6D;IAC7D,8CAA8C;IAE9C,MAAM,EAAEY,KAAK,CAAA,EAAE,GAAG,MAAMC,CAAAA,GAAAA,QAAW,AAcjC,CAAA,YAdiC,CAAC;QAClCC,IAAI,EAAE,cAAc;QACpBC,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE,EAAE;QACTC,OAAO,EAAE,oBAAoB;QAC7BC,OAAO,EAAElB,OAAO,CAACmB,GAAG,CAAC,CAACC,IAAI,GAAK;YAC7B,MAAMC,QAAQ,GAAGD,IAAI,CAACE,KAAK,KAAK,QAAQ,AAAC;YACzC,MAAMC,MAAM,GAAGF,QAAQ,GAAGG,MAAK,QAAA,CAACC,IAAI,GAAG,CAACC,IAAY,GAAKA,IAAI;YAAC;YAC9D,OAAO;gBACLC,KAAK,EAAE,CAAC,EAAEJ,MAAM,CAACH,IAAI,CAACL,IAAI,CAAC,CAAC,CAAC,EAAES,MAAK,QAAA,CAACI,GAAG,CAAC,CAAC,CAAC,EAAER,IAAI,CAACS,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjEjB,KAAK,EAAEQ,IAAI,CAACf,IAAI;aACjB,CAAC;SACH,CAAC;QACFyB,OAAO,EAAEC,CAAAA,GAAAA,QAAqB,AAAE,CAAA,sBAAF,EAAE;KACjC,CAAC,AAAC;IAEH,OAAOnB,KAAK,CAAC;CACd"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
exports.isOSType = isOSType;
|
|
5
6
|
exports.getContainerPathAsync = getContainerPathAsync;
|
|
6
7
|
exports.getInfoPlistValueAsync = getInfoPlistValueAsync;
|
|
7
8
|
exports.openUrlAsync = openUrlAsync;
|
|
@@ -44,6 +45,19 @@ function _interopRequireWildcard(obj) {
|
|
|
44
45
|
return newObj;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
function isOSType(value) {
|
|
49
|
+
if (!value || typeof value !== "string") return false;
|
|
50
|
+
const knownTypes = [
|
|
51
|
+
"iOS",
|
|
52
|
+
"tvOS",
|
|
53
|
+
"watchOS",
|
|
54
|
+
"macOS"
|
|
55
|
+
];
|
|
56
|
+
if (!knownTypes.includes(value)) {
|
|
57
|
+
Log.warn(`Unknown OS type: ${value}. Expected one of: ${knownTypes.join(", ")}`);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
47
61
|
async function getContainerPathAsync(device, { appId }) {
|
|
48
62
|
try {
|
|
49
63
|
const { stdout } = await simctlAsync([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/platforms/ios/simctl.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { xcrunAsync } from './xcrun';\n\ntype DeviceState = 'Shutdown' | 'Booted';\n\ntype OSType = 'iOS' | 'tvOS' | 'watchOS' | 'macOS';\n\nexport type Device = {\n availabilityError?: 'runtime profile not found';\n /** '/Users/name/Library/Developer/CoreSimulator/Devices/00E55DC0-0364-49DF-9EC6-77BE587137D4/data' */\n dataPath: string;\n /** '/Users/name/Library/Logs/CoreSimulator/00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n logPath: string;\n /** '00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n udid: string;\n /** 'com.apple.CoreSimulator.SimRuntime.iOS-15-1' */\n runtime: string;\n /** If the device is \"available\" which generally means that the OS files haven't been deleted (this can happen when Xcode updates). */\n isAvailable: boolean;\n /** 'com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro' */\n deviceTypeIdentifier: string;\n state: DeviceState;\n /** 'iPhone 13 Pro' */\n name: string;\n /** Type of OS the device uses. */\n osType: OSType;\n /** '15.1' */\n osVersion: string;\n /** 'iPhone 13 Pro (15.1)' */\n windowName: string;\n};\n\ntype SimulatorDeviceList = {\n devices: {\n [runtime: string]: Device[];\n };\n};\n\ntype DeviceContext = Pick<Device, 'udid'>;\n\n/**\n * Returns the local path for the installed tar.app. Returns null when the app isn't installed.\n *\n * @param device context for selecting a device.\n * @param props.appId 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 device: Partial<DeviceContext>,\n {\n appId,\n }: {\n appId: string;\n }\n): Promise<string | null> {\n try {\n const { stdout } = await simctlAsync(['get_app_container', resolveId(device), appId]);\n return stdout.trim();\n } catch (error: any) {\n if (error.stderr?.match(/No such file or directory/)) {\n return null;\n }\n throw error;\n }\n}\n\n/** Return a value from an installed app's Info.plist. */\nexport async function getInfoPlistValueAsync(\n device: Partial<DeviceContext>,\n {\n appId,\n key,\n }: {\n appId: string;\n key: string;\n }\n): Promise<string | null> {\n const containerPath = await getContainerPathAsync(device, { appId });\n if (containerPath) {\n try {\n const { output } = await spawnAsync('defaults', ['read', `${containerPath}/Info`, key], {\n stdio: 'pipe',\n });\n return output.join('\\n').trim();\n } catch {\n return null;\n }\n }\n return null;\n}\n\n/** Open a URL on a device. The url can have any protocol. */\nexport async function openUrlAsync(\n device: Partial<DeviceContext>,\n options: { url: string }\n): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['openurl', resolveId(device), options.url]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to lookup in current state: Shut/)) {\n throw error;\n }\n\n // If the device was in a weird in-between state (\"Shutting Down\" or \"Shutdown\"), then attempt to reboot it and try again.\n // This can happen when quitting the Simulator app, and immediately pressing `i` to reopen the project.\n\n // First boot the simulator\n await bootDeviceAsync({ udid: resolveId(device) });\n\n // Finally, try again...\n return await openUrlAsync(device, options);\n }\n}\n\n/** Open a simulator using a bundle identifier. If no app with a matching bundle identifier is installed then an error will be thrown. */\nexport async function openAppIdAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n const results = await openAppIdInternalAsync(device, options);\n // Similar to 194, this is a conformance issue which indicates that the given device has no app that can handle our launch request.\n if (results.status === 4) {\n throw new CommandError('APP_NOT_INSTALLED', results.stderr);\n }\n return results;\n}\nasync function openAppIdInternalAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n try {\n return await simctlAsync(['launch', resolveId(device), options.appId]);\n } catch (error: any) {\n if ('status' in error) {\n return error;\n }\n throw error;\n }\n}\n\n// This will only boot in headless mode if the Simulator app is not running.\nexport async function bootAsync(device: DeviceContext): Promise<Device | null> {\n await bootDeviceAsync(device);\n return isDeviceBootedAsync(device);\n}\n\n/** Returns a list of devices whose current state is 'Booted' as an array. */\nexport async function getBootedSimulatorsAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flatMap((runtime) =>\n runtime.filter((device) => device.state === 'Booted')\n );\n}\n\n/** Returns the current device if its state is 'Booted'. */\nexport async function isDeviceBootedAsync(device: Partial<DeviceContext>): Promise<Device | null> {\n // Simulators can be booted even if the app isn't running :(\n const devices = await getBootedSimulatorsAsync();\n if (device.udid) {\n return devices.find((bootedDevice) => bootedDevice.udid === device.udid) ?? null;\n }\n\n return devices[0] ?? null;\n}\n\n/** Boot a device. */\nexport async function bootDeviceAsync(device: DeviceContext): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['boot', device.udid]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to boot device in current state: Booted/)) {\n throw error;\n }\n }\n}\n\n/** Install a binary file on the device. */\nexport async function installAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Local absolute file path to an app binary that is built and provisioned for iOS simulators. */\n filePath: string;\n }\n): Promise<any> {\n return simctlAsync(['install', resolveId(device), options.filePath]);\n}\n\n/** Uninstall an app from the provided device. */\nexport async function uninstallAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Bundle identifier */\n appId: string;\n }\n): Promise<any> {\n return simctlAsync(['uninstall', resolveId(device), options.appId]);\n}\n\nfunction parseSimControlJSONResults(input: string): any {\n try {\n return JSON.parse(input);\n } catch (error: any) {\n // Nov 15, 2020: Observed this can happen when opening the simulator and the simulator prompts the user to update the xcode command line tools.\n // Unexpected token I in JSON at position 0\n if (error.message.includes('Unexpected token')) {\n Log.error(`Apple's simctl returned malformed JSON:\\n${input}`);\n }\n throw error;\n }\n}\n\n/** Get all runtime devices given a certain type. */\nasync function getRuntimesAsync(\n type: 'devices' | 'devicetypes' | 'runtimes' | 'pairs',\n query?: string | 'available'\n): Promise<SimulatorDeviceList> {\n const result = await simctlAsync(['list', type, '--json', query]);\n const info = parseSimControlJSONResults(result.stdout) as SimulatorDeviceList;\n\n for (const runtime of Object.keys(info.devices)) {\n // Given a string like 'com.apple.CoreSimulator.SimRuntime.tvOS-13-4'\n const runtimeSuffix = 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 const sims = info.devices[runtime];\n for (const device of sims) {\n device.runtime = runtime;\n device.osVersion = osVersion;\n device.windowName = `${device.name} (${osVersion})`;\n device.osType = osType as OSType;\n }\n }\n return info;\n}\n\n/** Return a list of iOS simulators. */\nexport async function getDevicesAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flat();\n}\n\n/** Run a `simctl` command. */\nexport async function simctlAsync(\n args: (string | undefined)[],\n options?: SpawnOptions\n): Promise<SpawnResult> {\n return xcrunAsync(['simctl', ...args], options);\n}\n\nfunction resolveId(device: Partial<DeviceContext>): string {\n return device.udid ?? 'booted';\n}\n"],"names":["getContainerPathAsync","getInfoPlistValueAsync","openUrlAsync","openAppIdAsync","bootAsync","getBootedSimulatorsAsync","isDeviceBootedAsync","bootDeviceAsync","installAsync","uninstallAsync","getDevicesAsync","simctlAsync","Log","device","appId","stdout","resolveId","trim","error","stderr","match","key","containerPath","output","spawnAsync","stdio","join","options","url","udid","results","openAppIdInternalAsync","status","CommandError","simulatorDeviceInfo","getRuntimesAsync","Object","values","devices","flatMap","runtime","filter","state","find","bootedDevice","filePath","parseSimControlJSONResults","input","JSON","parse","message","includes","type","query","result","info","keys","runtimeSuffix","split","pop","osType","osVersionComponents","osVersion","sims","windowName","name","flat","args","xcrunAsync"],"mappings":"AAAA;;;;QAkDsBA,qBAAqB,GAArBA,qBAAqB;QAoBrBC,sBAAsB,GAAtBA,sBAAsB;QAyBtBC,YAAY,GAAZA,YAAY;QAwBZC,cAAc,GAAdA,cAAc;QA8BdC,SAAS,GAATA,SAAS;QAMTC,wBAAwB,GAAxBA,wBAAwB;QAQxBC,mBAAmB,GAAnBA,mBAAmB;QAWnBC,eAAe,GAAfA,eAAe;QAYfC,YAAY,GAAZA,YAAY;QAWZC,cAAc,GAAdA,cAAc;QAkDdC,eAAe,GAAfA,eAAe;QAMfC,WAAW,GAAXA,WAAW;AA7PqB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AAE7DC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACzB,IAAA,MAAS,WAAT,SAAS,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8C7B,eAAeZ,qBAAqB,CACzCa,MAA8B,EAC9B,EACEC,KAAK,CAAA,EAGN,EACuB;IACxB,IAAI;Q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IAAI,CAAC,GAAG,CAAC,AAAC;QAChD,MAAMqC,IAAI,GAAGR,IAAI,CAACjB,OAAO,CAACE,OAAO,CAAC,AAAC;QACnC,KAAK,MAAM3B,MAAM,IAAIkD,IAAI,CAAE;YACzBlD,MAAM,CAAC2B,OAAO,GAAGA,OAAO,CAAC;YACzB3B,MAAM,CAACiD,SAAS,GAAGA,SAAS,CAAC;YAC7BjD,MAAM,CAACmD,UAAU,GAAG,CAAC,EAAEnD,MAAM,CAACoD,IAAI,CAAC,EAAE,EAAEH,SAAS,CAAC,CAAC,CAAC,CAAC;YACpDjD,MAAM,CAAC+C,MAAM,GAAGA,MAAM,AAAU,CAAC;SAClC;KACF;IACD,OAAOL,IAAI,CAAC;CACb;AAGM,eAAe7C,eAAe,GAAsB;IACzD,MAAMwB,mBAAmB,GAAG,MAAMC,gBAAgB,CAAC,SAAS,CAAC,AAAC;IAC9D,OAAOC,MAAM,CAACC,MAAM,CAACH,mBAAmB,CAACI,OAAO,CAAC,CAAC4B,IAAI,EAAE,CAAC;CAC1D;AAGM,eAAevD,WAAW,CAC/BwD,IAA4B,EAC5BxC,OAAsB,EACA;IACtB,OAAOyC,CAAAA,GAAAA,MAAU,AAA8B,CAAA,WAA9B,CAAC;QAAC,QAAQ;WAAKD,IAAI;KAAC,EAAExC,OAAO,CAAC,CAAC;CACjD;AAED,SAASX,SAAS,CAACH,MAA8B,EAAU;QAClDA,KAAW;IAAlB,OAAOA,CAAAA,KAAW,GAAXA,MAAM,CAACgB,IAAI,YAAXhB,KAAW,GAAI,QAAQ,CAAC;CAChC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/platforms/ios/simctl.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { xcrunAsync } from './xcrun';\n\ntype DeviceState = 'Shutdown' | 'Booted';\n\nexport type OSType = 'iOS' | 'tvOS' | 'watchOS' | 'macOS';\n\nexport type Device = {\n availabilityError?: 'runtime profile not found';\n /** '/Users/name/Library/Developer/CoreSimulator/Devices/00E55DC0-0364-49DF-9EC6-77BE587137D4/data' */\n dataPath: string;\n /** @example `2811236352` */\n dataPathSize?: number;\n /** '/Users/name/Library/Logs/CoreSimulator/00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n logPath: string;\n /** @example `479232` */\n logPathSize?: number;\n /** '00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n udid: string;\n /** 'com.apple.CoreSimulator.SimRuntime.iOS-15-1' */\n runtime: string;\n /** If the device is \"available\" which generally means that the OS files haven't been deleted (this can happen when Xcode updates). */\n isAvailable: boolean;\n /** 'com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro' */\n deviceTypeIdentifier: string;\n state: DeviceState;\n /** 'iPhone 13 Pro' */\n name: string;\n /** Type of OS the device uses. */\n osType: OSType;\n /** '15.1' */\n osVersion: string;\n /** 'iPhone 13 Pro (15.1)' */\n windowName: string;\n};\n\ntype SimulatorDeviceList = {\n devices: {\n [runtime: string]: Device[];\n };\n};\n\ntype DeviceContext = Pick<Device, 'udid'>;\n\n/** Returns true if the given value is an `OSType`, if we don't recognize the value we continue anyways but warn. */\nexport function isOSType(value: any): value is OSType {\n if (!value || typeof value !== 'string') return false;\n\n const knownTypes = ['iOS', 'tvOS', 'watchOS', 'macOS'];\n if (!knownTypes.includes(value)) {\n Log.warn(`Unknown OS type: ${value}. Expected one of: ${knownTypes.join(', ')}`);\n }\n return true;\n}\n\n/**\n * Returns the local path for the installed tar.app. Returns null when the app isn't installed.\n *\n * @param device context for selecting a device.\n * @param props.appId 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 device: Partial<DeviceContext>,\n {\n appId,\n }: {\n appId: string;\n }\n): Promise<string | null> {\n try {\n const { stdout } = await simctlAsync(['get_app_container', resolveId(device), appId]);\n return stdout.trim();\n } catch (error: any) {\n if (error.stderr?.match(/No such file or directory/)) {\n return null;\n }\n throw error;\n }\n}\n\n/** Return a value from an installed app's Info.plist. */\nexport async function getInfoPlistValueAsync(\n device: Partial<DeviceContext>,\n {\n appId,\n key,\n }: {\n appId: string;\n key: string;\n }\n): Promise<string | null> {\n const containerPath = await getContainerPathAsync(device, { appId });\n if (containerPath) {\n try {\n const { output } = await spawnAsync('defaults', ['read', `${containerPath}/Info`, key], {\n stdio: 'pipe',\n });\n return output.join('\\n').trim();\n } catch {\n return null;\n }\n }\n return null;\n}\n\n/** Open a URL on a device. The url can have any protocol. */\nexport async function openUrlAsync(\n device: Partial<DeviceContext>,\n options: { url: string }\n): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['openurl', resolveId(device), options.url]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to lookup in current state: Shut/)) {\n throw error;\n }\n\n // If the device was in a weird in-between state (\"Shutting Down\" or \"Shutdown\"), then attempt to reboot it and try again.\n // This can happen when quitting the Simulator app, and immediately pressing `i` to reopen the project.\n\n // First boot the simulator\n await bootDeviceAsync({ udid: resolveId(device) });\n\n // Finally, try again...\n return await openUrlAsync(device, options);\n }\n}\n\n/** Open a simulator using a bundle identifier. If no app with a matching bundle identifier is installed then an error will be thrown. */\nexport async function openAppIdAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n const results = await openAppIdInternalAsync(device, options);\n // Similar to 194, this is a conformance issue which indicates that the given device has no app that can handle our launch request.\n if (results.status === 4) {\n throw new CommandError('APP_NOT_INSTALLED', results.stderr);\n }\n return results;\n}\nasync function openAppIdInternalAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n try {\n return await simctlAsync(['launch', resolveId(device), options.appId]);\n } catch (error: any) {\n if ('status' in error) {\n return error;\n }\n throw error;\n }\n}\n\n// This will only boot in headless mode if the Simulator app is not running.\nexport async function bootAsync(device: DeviceContext): Promise<Device | null> {\n await bootDeviceAsync(device);\n return isDeviceBootedAsync(device);\n}\n\n/** Returns a list of devices whose current state is 'Booted' as an array. */\nexport async function getBootedSimulatorsAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flatMap((runtime) =>\n runtime.filter((device) => device.state === 'Booted')\n );\n}\n\n/** Returns the current device if its state is 'Booted'. */\nexport async function isDeviceBootedAsync(device: Partial<DeviceContext>): Promise<Device | null> {\n // Simulators can be booted even if the app isn't running :(\n const devices = await getBootedSimulatorsAsync();\n if (device.udid) {\n return devices.find((bootedDevice) => bootedDevice.udid === device.udid) ?? null;\n }\n\n return devices[0] ?? null;\n}\n\n/** Boot a device. */\nexport async function bootDeviceAsync(device: DeviceContext): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['boot', device.udid]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to boot device in current state: Booted/)) {\n throw error;\n }\n }\n}\n\n/** Install a binary file on the device. */\nexport async function installAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Local absolute file path to an app binary that is built and provisioned for iOS simulators. */\n filePath: string;\n }\n): Promise<any> {\n return simctlAsync(['install', resolveId(device), options.filePath]);\n}\n\n/** Uninstall an app from the provided device. */\nexport async function uninstallAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Bundle identifier */\n appId: string;\n }\n): Promise<any> {\n return simctlAsync(['uninstall', resolveId(device), options.appId]);\n}\n\nfunction parseSimControlJSONResults(input: string): any {\n try {\n return JSON.parse(input);\n } catch (error: any) {\n // Nov 15, 2020: Observed this can happen when opening the simulator and the simulator prompts the user to update the xcode command line tools.\n // Unexpected token I in JSON at position 0\n if (error.message.includes('Unexpected token')) {\n Log.error(`Apple's simctl returned malformed JSON:\\n${input}`);\n }\n throw error;\n }\n}\n\n/** Get all runtime devices given a certain type. */\nasync function getRuntimesAsync(\n type: 'devices' | 'devicetypes' | 'runtimes' | 'pairs',\n query?: string | 'available'\n): Promise<SimulatorDeviceList> {\n const result = await simctlAsync(['list', type, '--json', query]);\n const info = parseSimControlJSONResults(result.stdout) as SimulatorDeviceList;\n\n for (const runtime of Object.keys(info.devices)) {\n // Given a string like 'com.apple.CoreSimulator.SimRuntime.tvOS-13-4'\n const runtimeSuffix = 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 const sims = info.devices[runtime];\n for (const device of sims) {\n device.runtime = runtime;\n device.osVersion = osVersion;\n device.windowName = `${device.name} (${osVersion})`;\n device.osType = osType as OSType;\n }\n }\n return info;\n}\n\n/** Return a list of iOS simulators. */\nexport async function getDevicesAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flat();\n}\n\n/** Run a `simctl` command. */\nexport async function simctlAsync(\n args: (string | undefined)[],\n options?: SpawnOptions\n): Promise<SpawnResult> {\n return xcrunAsync(['simctl', ...args], options);\n}\n\nfunction resolveId(device: Partial<DeviceContext>): string {\n return device.udid ?? 'booted';\n}\n"],"names":["isOSType","getContainerPathAsync","getInfoPlistValueAsync","openUrlAsync","openAppIdAsync","bootAsync","getBootedSimulatorsAsync","isDeviceBootedAsync","bootDeviceAsync","installAsync","uninstallAsync","getDevicesAsync","simctlAsync","Log","value","knownTypes","includes","warn","join","device","appId","stdout","resolveId","trim","error","stderr","match","key","containerPath","output","spawnAsync","stdio","options","url","udid","results","openAppIdInternalAsync","status","CommandError","simulatorDeviceInfo","getRuntimesAsync","Object","values","devices","flatMap","runtime","filter","state","find","bootedDevice","filePath","parseSimControlJSONResults","input","JSON","parse","message","type","query","result","info","keys","runtimeSuffix","split","pop","osType","osVersionComponents","osVersion","sims","windowName","name","flat","args","xcrunAsync"],"mappings":"AAAA;;;;QAgDgBA,QAAQ,GAARA,QAAQ;QAiBFC,qBAAqB,GAArBA,qBAAqB;QAoBrBC,sBAAsB,GAAtBA,sBAAsB;QAyBtBC,YAAY,GAAZA,YAAY;QAwBZC,cAAc,GAAdA,cAAc;QA8BdC,SAAS,GAATA,SAAS;QAMTC,wBAAwB,GAAxBA,wBAAwB;QAQxBC,mBAAmB,GAAnBA,mBAAmB;QAWnBC,eAAe,GAAfA,eAAe;QAYfC,YAAY,GAAZA,YAAY;QAWZC,cAAc,GAAdA,cAAc;QAkDdC,eAAe,GAAfA,eAAe;QAMfC,WAAW,GAAXA,WAAW;AA5QqB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AAE7DC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACzB,IAAA,MAAS,WAAT,SAAS,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4C7B,SAASb,QAAQ,CAACc,KAAU,EAAmB;IACpD,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,OAAO,KAAK,CAAC;IAEtD,MAAMC,UAAU,GAAG;QAAC,KAAK;QAAE,MAAM;QAAE,SAAS;QAAE,OAAO;KAAC,AAAC;IACvD,IAAI,CAACA,UAAU,CAACC,QAAQ,CAACF,KAAK,CAAC,EAAE;QAC/BD,GAAG,CAACI,IAAI,CAAC,CAAC,iBAAiB,EAAEH,KAAK,CAAC,mBAAmB,EAAEC,UAAU,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KAClF;IACD,OAAO,IAAI,CAAC;CACb;AASM,eAAejB,qBAAqB,CACzCkB,MAA8B,EAC9B,EACEC,KAAK,CAAA,EAGN,EACuB;IACxB,IAAI;QACF,MAAM,EAAEC,MAAM,CAAA,E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C,AAAC;QAChD,MAAMiD,IAAI,GAAGR,IAAI,CAAChB,OAAO,CAACE,OAAO,CAAC,AAAC;QACnC,KAAK,MAAM1B,MAAM,IAAIgD,IAAI,CAAE;YACzBhD,MAAM,CAAC0B,OAAO,GAAGA,OAAO,CAAC;YACzB1B,MAAM,CAAC+C,SAAS,GAAGA,SAAS,CAAC;YAC7B/C,MAAM,CAACiD,UAAU,GAAG,CAAC,EAAEjD,MAAM,CAACkD,IAAI,CAAC,EAAE,EAAEH,SAAS,CAAC,CAAC,CAAC,CAAC;YACpD/C,MAAM,CAAC6C,MAAM,GAAGA,MAAM,AAAU,CAAC;SAClC;KACF;IACD,OAAOL,IAAI,CAAC;CACb;AAGM,eAAehD,eAAe,GAAsB;IACzD,MAAM4B,mBAAmB,GAAG,MAAMC,gBAAgB,CAAC,SAAS,CAAC,AAAC;IAC9D,OAAOC,MAAM,CAACC,MAAM,CAACH,mBAAmB,CAACI,OAAO,CAAC,CAAC2B,IAAI,EAAE,CAAC;CAC1D;AAGM,eAAe1D,WAAW,CAC/B2D,IAA4B,EAC5BvC,OAAsB,EACA;IACtB,OAAOwC,CAAAA,GAAAA,MAAU,AAA8B,CAAA,WAA9B,CAAC;QAAC,QAAQ;WAAKD,IAAI;KAAC,EAAEvC,OAAO,CAAC,CAAC;CACjD;AAED,SAASV,SAAS,CAACH,MAA8B,EAAU;QAClDA,KAAW;IAAlB,OAAOA,CAAAA,KAAW,GAAXA,MAAM,CAACe,IAAI,YAAXf,KAAW,GAAI,QAAQ,CAAC;CAChC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.onMessage = onMessage;
|
|
6
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
7
|
+
var _childProcess = require("child_process");
|
|
8
|
+
var _os = require("os");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _wrapAnsi = _interopRequireDefault(require("wrap-ansi"));
|
|
11
|
+
var Log = _interopRequireWildcard(require("../../../log"));
|
|
12
|
+
var _errors = require("../../../utils/errors");
|
|
13
|
+
var _exit = require("../../../utils/exit");
|
|
14
|
+
var _simctl = require("./simctl");
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function _interopRequireWildcard(obj) {
|
|
21
|
+
if (obj && obj.__esModule) {
|
|
22
|
+
return obj;
|
|
23
|
+
} else {
|
|
24
|
+
var newObj = {};
|
|
25
|
+
if (obj != null) {
|
|
26
|
+
for(var key in obj){
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
28
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
29
|
+
if (desc.get || desc.set) {
|
|
30
|
+
Object.defineProperty(newObj, key, desc);
|
|
31
|
+
} else {
|
|
32
|
+
newObj[key] = obj[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
newObj.default = obj;
|
|
38
|
+
return newObj;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class SimulatorLogStreamer {
|
|
42
|
+
static cache = [];
|
|
43
|
+
static getStreamer = (device, resolver)=>{
|
|
44
|
+
var ref;
|
|
45
|
+
return (ref = SimulatorLogStreamer.cache.find((streamer)=>streamer.device.udid === device.udid
|
|
46
|
+
)) != null ? ref : new SimulatorLogStreamer(device, resolver);
|
|
47
|
+
};
|
|
48
|
+
constructor(device, resolver){
|
|
49
|
+
this.device = device;
|
|
50
|
+
this.resolver = resolver;
|
|
51
|
+
this.childProcess = null;
|
|
52
|
+
this.off = null;
|
|
53
|
+
}
|
|
54
|
+
isAttached() {
|
|
55
|
+
return !!this.childProcess;
|
|
56
|
+
}
|
|
57
|
+
async resolvePidAsync() {
|
|
58
|
+
if ("pid" in this.resolver) {
|
|
59
|
+
return this.resolver.pid;
|
|
60
|
+
}
|
|
61
|
+
return getImageNameFromBundleIdentifierAsync(this.device.udid, this.resolver.appId);
|
|
62
|
+
}
|
|
63
|
+
async attachAsync() {
|
|
64
|
+
await this.detachAsync();
|
|
65
|
+
const pid = await this.resolvePidAsync();
|
|
66
|
+
if (!pid) {
|
|
67
|
+
throw new _errors.CommandError(`Could not find pid for ${this.device.udid}`);
|
|
68
|
+
}
|
|
69
|
+
// xcrun simctl spawn booted log stream --process --style json
|
|
70
|
+
this.childProcess = (0, _childProcess).spawn("xcrun", [
|
|
71
|
+
"simctl",
|
|
72
|
+
"spawn",
|
|
73
|
+
this.device.udid,
|
|
74
|
+
"log",
|
|
75
|
+
"stream",
|
|
76
|
+
"--process",
|
|
77
|
+
pid,
|
|
78
|
+
// ndjson provides a better format than json.
|
|
79
|
+
"--style",
|
|
80
|
+
"ndjson",
|
|
81
|
+
// Provide the source so we can filter logs better
|
|
82
|
+
"--source",
|
|
83
|
+
// log, activity, trace -- activity was related to layouts, trace didn't work, so that leaves log.
|
|
84
|
+
// Passing nothing combines all three, but we don't use activity.
|
|
85
|
+
"--type",
|
|
86
|
+
"log",
|
|
87
|
+
// backtrace doesn't seem very useful in basic cases.
|
|
88
|
+
// TODO: Maybe we can format as a stack trace for native errors.
|
|
89
|
+
"--no-backtrace",
|
|
90
|
+
]);
|
|
91
|
+
this.childProcess.stdout.on("data", (data)=>{
|
|
92
|
+
// Sometimes more than one chunk comes at a time, here we split by system newline,
|
|
93
|
+
// then trim and filter.
|
|
94
|
+
const strings = data.toString().split(_os.EOL).map((value)=>value.trim()
|
|
95
|
+
)// This filters out the first log which says something like:
|
|
96
|
+
// Filtering the log data using "process BEGINSWITH[cd] "my-app" AND type == 1024"
|
|
97
|
+
.filter((value)=>value.startsWith("{")
|
|
98
|
+
);
|
|
99
|
+
strings.forEach((str)=>{
|
|
100
|
+
const simLog = parseMessageJson(str);
|
|
101
|
+
if (!simLog) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
onMessage(simLog);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
this.childProcess.on("error", ({ message })=>{
|
|
108
|
+
Log.debug("[simctl error]:", message);
|
|
109
|
+
});
|
|
110
|
+
this.off = (0, _exit).installExitHooks(()=>{
|
|
111
|
+
this.detachAsync.bind(this);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
detachAsync() {
|
|
115
|
+
var _obj, ref2;
|
|
116
|
+
(ref2 = (_obj = this).off) == null ? void 0 : ref2.call(_obj);
|
|
117
|
+
this.off = null;
|
|
118
|
+
if (this.childProcess) {
|
|
119
|
+
return new Promise((resolve)=>{
|
|
120
|
+
var ref, ref1;
|
|
121
|
+
(ref = this.childProcess) == null ? void 0 : ref.on("close", resolve);
|
|
122
|
+
(ref1 = this.childProcess) == null ? void 0 : ref1.kill();
|
|
123
|
+
this.childProcess = null;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return Promise.resolve();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.SimulatorLogStreamer = SimulatorLogStreamer;
|
|
130
|
+
function parseMessageJson(data) {
|
|
131
|
+
const stringData = data.toString();
|
|
132
|
+
try {
|
|
133
|
+
return JSON.parse(stringData);
|
|
134
|
+
} catch {
|
|
135
|
+
Log.debug("Failed to parse simctl JSON message:\n" + stringData);
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
// There are a lot of networking logs in RN that aren't relevant to the user.
|
|
140
|
+
function isNetworkLog(simLog) {
|
|
141
|
+
var ref;
|
|
142
|
+
return simLog.subsystem === "com.apple.network" || simLog.category === "connection" || ((ref = simLog.source) == null ? void 0 : ref.image) === "CFNetwork";
|
|
143
|
+
}
|
|
144
|
+
function isReactLog(simLog) {
|
|
145
|
+
var ref;
|
|
146
|
+
return simLog.subsystem === "com.facebook.react.log" && ((ref = simLog.source) == null ? void 0 : ref.file) === "RCTLog.mm";
|
|
147
|
+
}
|
|
148
|
+
// It's not clear what these are but they aren't very useful.
|
|
149
|
+
// (The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated)
|
|
150
|
+
// We can add them later if need.
|
|
151
|
+
function isCoreTelephonyLog(simLog) {
|
|
152
|
+
// [CoreTelephony] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099
|
|
153
|
+
// "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
|
|
154
|
+
return simLog.subsystem === "com.apple.CoreTelephony";
|
|
155
|
+
}
|
|
156
|
+
// https://stackoverflow.com/a/65313219/4047926
|
|
157
|
+
function isWebKitLog(simLog) {
|
|
158
|
+
// [WebKit] 0x1143ca500 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 27084, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target
|
|
159
|
+
// entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
|
|
160
|
+
return simLog.subsystem === "com.apple.WebKit";
|
|
161
|
+
}
|
|
162
|
+
// Similar to WebKit logs
|
|
163
|
+
function isRunningBoardServicesLog(simLog) {
|
|
164
|
+
// [RunningBoardServices] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit"
|
|
165
|
+
// name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
|
|
166
|
+
return simLog.subsystem === "com.apple.runningboard";
|
|
167
|
+
}
|
|
168
|
+
function formatMessage(simLog) {
|
|
169
|
+
var ref;
|
|
170
|
+
var ref3;
|
|
171
|
+
// TODO: Maybe change "TCC" to "Consent" or "System".
|
|
172
|
+
const category = _chalk.default.gray(`[${(ref3 = (ref = simLog.source) == null ? void 0 : ref.image) != null ? ref3 : simLog.subsystem}]`);
|
|
173
|
+
const message = simLog.eventMessage;
|
|
174
|
+
return (0, _wrapAnsi).default(category + " " + message, process.stdout.columns || 80);
|
|
175
|
+
}
|
|
176
|
+
function onMessage(simLog) {
|
|
177
|
+
let hasLogged = false;
|
|
178
|
+
if (simLog.messageType === "Error") {
|
|
179
|
+
if (// Hide all networking errors which are mostly useless.
|
|
180
|
+
!isNetworkLog(simLog) && // Showing React errors will result in duplicate messages.
|
|
181
|
+
!isReactLog(simLog) && !isCoreTelephonyLog(simLog) && !isWebKitLog(simLog) && !isRunningBoardServicesLog(simLog)) {
|
|
182
|
+
hasLogged = true;
|
|
183
|
+
// Sim: This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
|
|
184
|
+
Log.error(formatMessage(simLog));
|
|
185
|
+
}
|
|
186
|
+
} else if (simLog.eventMessage) {
|
|
187
|
+
var ref;
|
|
188
|
+
// If the source has a file (i.e. not a system log).
|
|
189
|
+
if (((ref = simLog.source) == null ? void 0 : ref.file) || simLog.eventMessage.includes("Terminating app due to uncaught exception")) {
|
|
190
|
+
hasLogged = true;
|
|
191
|
+
Log.log(formatMessage(simLog));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!hasLogged) {
|
|
195
|
+
Log.debug(formatMessage(simLog));
|
|
196
|
+
} else {
|
|
197
|
+
// console.log('DATA:', JSON.stringify(simLog));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
* @param udid
|
|
203
|
+
* @param bundleIdentifier
|
|
204
|
+
* @returns Image name like `Exponent` and `null` when the app is not installed on the provided simulator.
|
|
205
|
+
*/ async function getImageNameFromBundleIdentifierAsync(udid, bundleIdentifier) {
|
|
206
|
+
const containerPath = await (0, _simctl).getContainerPathAsync({
|
|
207
|
+
udid
|
|
208
|
+
}, {
|
|
209
|
+
appId: bundleIdentifier
|
|
210
|
+
});
|
|
211
|
+
if (containerPath) {
|
|
212
|
+
return getImageNameFromContainerPath(containerPath);
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
function getImageNameFromContainerPath(binaryPath) {
|
|
217
|
+
return _path.default.basename(binaryPath).split(".")[0];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=simctlLogging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/platforms/ios/simctlLogging.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { ChildProcessWithoutNullStreams, spawn } from 'child_process';\nimport { EOL } from 'os';\nimport path from 'path';\nimport wrapAnsi from 'wrap-ansi';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { installExitHooks } from '../../../utils/exit';\nimport { Device, getContainerPathAsync } from './simctl';\n\nexport type SimControlLog = {\n /**\n * 258753568922927108\n */\n traceID: number;\n /**\n *\n * \"Connection 1: done\",\n */\n eventMessage: string;\n /**\n * \"logEvent\" | \"activityCreateEvent\",\n */\n eventType: 'logEvent' | 'activityCreateEvent';\n source: null | {\n /**\n * 'RCTDefaultLogFunction_block_invoke' | '__TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION__'\n */\n symbol: string;\n line: number;\n /**\n * 'TCC' | 'Security' | 'CFNetwork' | 'libnetwork.dylib' | 'myapp'\n *\n * TCC is apple sys, it means \"Transparency, Consent, and Control\"\n */\n image: string;\n /**\n * 'RCTLog.mm' | ''\n */\n file: string;\n };\n /**\n * \"Connection %llu: done\"\n */\n formatString: string;\n /**\n * 0\n */\n activityIdentifier: number;\n subsystem:\n | ''\n | 'com.apple.network'\n | 'com.facebook.react.log'\n | 'com.apple.TCC'\n | 'com.apple.CoreTelephony'\n | 'com.apple.WebKit'\n | 'com.apple.runningboard'\n | string;\n category: '' | 'access' | 'connection' | 'plugin';\n /**\n * \"2021-03-15 15:36:28.004331-0700\"\n */\n timestamp: string;\n /**\n * 706567072091713\n */\n machTimestamp: number;\n /**\n * \"Default\"\n */\n messageType: 'Default' | 'Error';\n /**\n * 15192\n */\n processID: number;\n};\n\ntype ProcessResolver =\n | {\n pid: string;\n }\n | {\n appId: string;\n };\n\nexport class SimulatorLogStreamer {\n private childProcess: ChildProcessWithoutNullStreams | null = null;\n\n static cache: SimulatorLogStreamer[] = [];\n\n static getStreamer = (device: Pick<Device, 'udid'>, resolver: ProcessResolver) => {\n return (\n SimulatorLogStreamer.cache.find((streamer) => streamer.device.udid === device.udid) ??\n new SimulatorLogStreamer(device, resolver)\n );\n };\n\n constructor(public device: Pick<Device, 'udid'>, public resolver: ProcessResolver) {}\n\n isAttached() {\n return !!this.childProcess;\n }\n\n async resolvePidAsync() {\n if ('pid' in this.resolver) {\n return this.resolver.pid;\n }\n return getImageNameFromBundleIdentifierAsync(this.device.udid, this.resolver.appId);\n }\n\n async attachAsync() {\n await this.detachAsync();\n\n const pid = await this.resolvePidAsync();\n\n if (!pid) {\n throw new CommandError(`Could not find pid for ${this.device.udid}`);\n }\n\n // xcrun simctl spawn booted log stream --process --style json\n this.childProcess = spawn('xcrun', [\n 'simctl',\n 'spawn',\n this.device.udid,\n 'log',\n 'stream',\n '--process',\n pid,\n // ndjson provides a better format than json.\n '--style',\n 'ndjson',\n // Provide the source so we can filter logs better\n '--source',\n // log, activity, trace -- activity was related to layouts, trace didn't work, so that leaves log.\n // Passing nothing combines all three, but we don't use activity.\n '--type',\n 'log',\n // backtrace doesn't seem very useful in basic cases.\n // TODO: Maybe we can format as a stack trace for native errors.\n '--no-backtrace',\n ]);\n\n this.childProcess.stdout.on('data', (data: Buffer) => {\n // Sometimes more than one chunk comes at a time, here we split by system newline,\n // then trim and filter.\n const strings = data\n .toString()\n .split(EOL)\n .map((value) => value.trim())\n // This filters out the first log which says something like:\n // Filtering the log data using \"process BEGINSWITH[cd] \"my-app\" AND type == 1024\"\n .filter((value) => value.startsWith('{'));\n\n strings.forEach((str) => {\n const simLog = parseMessageJson(str);\n if (!simLog) {\n return;\n }\n onMessage(simLog);\n });\n });\n\n this.childProcess.on('error', ({ message }) => {\n Log.debug('[simctl error]:', message);\n });\n\n this.off = installExitHooks(() => {\n this.detachAsync.bind(this);\n });\n }\n\n private off: (() => void) | null = null;\n\n detachAsync() {\n this.off?.();\n this.off = null;\n if (this.childProcess) {\n return new Promise<void>((resolve) => {\n this.childProcess?.on('close', resolve);\n this.childProcess?.kill();\n this.childProcess = null;\n });\n }\n return Promise.resolve();\n }\n}\n\nfunction parseMessageJson(data: string) {\n const stringData = data.toString();\n try {\n return JSON.parse(stringData) as SimControlLog;\n } catch {\n Log.debug('Failed to parse simctl JSON message:\\n' + stringData);\n }\n return null;\n}\n\n// There are a lot of networking logs in RN that aren't relevant to the user.\nfunction isNetworkLog(simLog: SimControlLog): boolean {\n return (\n simLog.subsystem === 'com.apple.network' ||\n simLog.category === 'connection' ||\n simLog.source?.image === 'CFNetwork'\n );\n}\n\nfunction isReactLog(simLog: SimControlLog): boolean {\n return simLog.subsystem === 'com.facebook.react.log' && simLog.source?.file === 'RCTLog.mm';\n}\n\n// It's not clear what these are but they aren't very useful.\n// (The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated)\n// We can add them later if need.\nfunction isCoreTelephonyLog(simLog: SimControlLog): boolean {\n // [CoreTelephony] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099\n // \"The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.\" UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}\n return simLog.subsystem === 'com.apple.CoreTelephony';\n}\n\n// https://stackoverflow.com/a/65313219/4047926\nfunction isWebKitLog(simLog: SimControlLog): boolean {\n // [WebKit] 0x1143ca500 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 27084, error: Error Domain=RBSAssertionErrorDomain Code=3 \"Target is not running or required target\n // entitlement is missing\" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:\"com.apple.webkit\" name:\"Background\" sourceEnvironment:\"(null)\">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}\n return simLog.subsystem === 'com.apple.WebKit';\n}\n\n// Similar to WebKit logs\nfunction isRunningBoardServicesLog(simLog: SimControlLog): boolean {\n // [RunningBoardServices] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 \"Target is not running or required target entitlement is missing\" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:\"com.apple.webkit\"\n // name:\"Background\" sourceEnvironment:\"(null)\">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>\n return simLog.subsystem === 'com.apple.runningboard';\n}\n\nfunction formatMessage(simLog: SimControlLog): string {\n // TODO: Maybe change \"TCC\" to \"Consent\" or \"System\".\n const category = chalk.gray(`[${simLog.source?.image ?? simLog.subsystem}]`);\n const message = simLog.eventMessage;\n return wrapAnsi(category + ' ' + message, process.stdout.columns || 80);\n}\n\nexport function onMessage(simLog: SimControlLog) {\n let hasLogged = false;\n\n if (simLog.messageType === 'Error') {\n if (\n // Hide all networking errors which are mostly useless.\n !isNetworkLog(simLog) &&\n // Showing React errors will result in duplicate messages.\n !isReactLog(simLog) &&\n !isCoreTelephonyLog(simLog) &&\n !isWebKitLog(simLog) &&\n !isRunningBoardServicesLog(simLog)\n ) {\n hasLogged = true;\n // Sim: This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.\n Log.error(formatMessage(simLog));\n }\n } else if (simLog.eventMessage) {\n // If the source has a file (i.e. not a system log).\n if (\n simLog.source?.file ||\n simLog.eventMessage.includes('Terminating app due to uncaught exception')\n ) {\n hasLogged = true;\n Log.log(formatMessage(simLog));\n }\n }\n\n if (!hasLogged) {\n Log.debug(formatMessage(simLog));\n } else {\n // console.log('DATA:', JSON.stringify(simLog));\n }\n}\n\n/**\n *\n * @param udid\n * @param bundleIdentifier\n * @returns Image name like `Exponent` and `null` when the app is not installed on the provided simulator.\n */\nasync function getImageNameFromBundleIdentifierAsync(\n udid: string,\n bundleIdentifier: string\n): Promise<string | null> {\n const containerPath = await getContainerPathAsync({ udid }, { appId: bundleIdentifier });\n\n if (containerPath) {\n return getImageNameFromContainerPath(containerPath);\n }\n return null;\n}\n\nfunction getImageNameFromContainerPath(binaryPath: string): string {\n return path.basename(binaryPath).split('.')[0];\n}\n"],"names":["onMessage","Log","SimulatorLogStreamer","cache","getStreamer","device","resolver","find","streamer","udid","constructor","childProcess","off","isAttached","resolvePidAsync","pid","getImageNameFromBundleIdentifierAsync","appId","attachAsync","detachAsync","CommandError","spawn","stdout","on","data","strings","toString","split","EOL","map","value","trim","filter","startsWith","forEach","str","simLog","parseMessageJson","message","debug","installExitHooks","bind","Promise","resolve","kill","stringData","JSON","parse","isNetworkLog","subsystem","category","source","image","isReactLog","file","isCoreTelephonyLog","isWebKitLog","isRunningBoardServicesLog","formatMessage","chalk","gray","eventMessage","wrapAnsi","process","columns","hasLogged","messageType","error","includes","log","bundleIdentifier","containerPath","getContainerPathAsync","getImageNameFromContainerPath","binaryPath","path","basename"],"mappings":"AAAA;;;;QAiPgBA,SAAS,GAATA,SAAS;AAjPP,IAAA,MAAO,kCAAP,OAAO,EAAA;AAC6B,IAAA,aAAe,WAAf,eAAe,CAAA;AACjD,IAAA,GAAI,WAAJ,IAAI,CAAA;AACP,IAAA,KAAM,kCAAN,MAAM,EAAA;AACF,IAAA,SAAW,kCAAX,WAAW,EAAA;AAEpBC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACnB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACR,IAA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tB,MAAM,CAAC,CAAC,CAAC;KAClC,MAAM;IACL,gDAAgD;KACjD;CACF;AAED;;;;;GAKG,CACH,eAAepB,qCAAqC,CAClDP,IAAY,EACZ6D,gBAAwB,EACA;IACxB,MAAMC,aAAa,GAAG,MAAMC,CAAAA,GAAAA,OAAqB,AAAuC,CAAA,sBAAvC,CAAC;QAAE/D,IAAI;KAAE,EAAE;QAAEQ,KAAK,EAAEqD,gBAAgB;KAAE,CAAC,AAAC;IAEzF,IAAIC,aAAa,EAAE;QACjB,OAAOE,6BAA6B,CAACF,aAAa,CAAC,CAAC;KACrD;IACD,OAAO,IAAI,CAAC;CACb;AAED,SAASE,6BAA6B,CAACC,UAAkB,EAAU;IACjE,OAAOC,KAAI,QAAA,CAACC,QAAQ,CAACF,UAAU,CAAC,CAAC/C,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;CAChD"}
|
|
@@ -128,7 +128,7 @@ async function createHostInfoAsync() {
|
|
|
128
128
|
host: await _userSettings.default.getAnonymousIdentifierAsync(),
|
|
129
129
|
server: "expo",
|
|
130
130
|
// Defined in the build step
|
|
131
|
-
serverVersion: "0.1.
|
|
131
|
+
serverVersion: "0.1.4",
|
|
132
132
|
serverDriver: _manifestMiddleware.DEVELOPER_TOOL,
|
|
133
133
|
serverOS: _os.default.platform(),
|
|
134
134
|
serverOSVersion: _os.default.release()
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.setUserDataAsync = setUserDataAsync;
|
|
6
6
|
exports.logEvent = logEvent;
|
|
7
|
+
exports.getContext = getContext;
|
|
7
8
|
var _rudderSdkNode = _interopRequireDefault(require("@expo/rudder-sdk-node"));
|
|
9
|
+
var ciInfo = _interopRequireWildcard(require("ci-info"));
|
|
8
10
|
var _os = _interopRequireDefault(require("os"));
|
|
9
11
|
var _uuid = require("uuid");
|
|
10
12
|
var _userSettings = _interopRequireDefault(require("../../api/user/UserSettings"));
|
|
@@ -14,6 +16,27 @@ function _interopRequireDefault(obj) {
|
|
|
14
16
|
default: obj
|
|
15
17
|
};
|
|
16
18
|
}
|
|
19
|
+
function _interopRequireWildcard(obj) {
|
|
20
|
+
if (obj && obj.__esModule) {
|
|
21
|
+
return obj;
|
|
22
|
+
} else {
|
|
23
|
+
var newObj = {};
|
|
24
|
+
if (obj != null) {
|
|
25
|
+
for(var key in obj){
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
27
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
28
|
+
if (desc.get || desc.set) {
|
|
29
|
+
Object.defineProperty(newObj, key, desc);
|
|
30
|
+
} else {
|
|
31
|
+
newObj[key] = obj[key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
newObj.default = obj;
|
|
37
|
+
return newObj;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
17
40
|
const PLATFORM_TO_ANALYTICS_PLATFORM = {
|
|
18
41
|
darwin: "Mac",
|
|
19
42
|
win32: "Windows",
|
|
@@ -57,7 +80,7 @@ function logEvent(event, properties = {}) {
|
|
|
57
80
|
ensureIdentified();
|
|
58
81
|
const { userId , deviceId } = identifyData != null ? identifyData : {};
|
|
59
82
|
const commonEventProperties = {
|
|
60
|
-
source_version: "0.1.
|
|
83
|
+
source_version: "0.1.4",
|
|
61
84
|
source: "expo"
|
|
62
85
|
};
|
|
63
86
|
const identity = {
|
|
@@ -98,8 +121,12 @@ function getContext() {
|
|
|
98
121
|
},
|
|
99
122
|
app: {
|
|
100
123
|
name: "expo",
|
|
101
|
-
version: "0.1.
|
|
102
|
-
}
|
|
124
|
+
version: "0.1.4"
|
|
125
|
+
},
|
|
126
|
+
ci: ciInfo.isCI ? {
|
|
127
|
+
name: ciInfo.name,
|
|
128
|
+
isPr: ciInfo.isPR
|
|
129
|
+
} : undefined
|
|
103
130
|
};
|
|
104
131
|
}
|
|
105
132
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/analytics/rudderstackClient.ts"],"sourcesContent":["import RudderAnalytics from '@expo/rudder-sdk-node';\nimport os from 'os';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { env } from '../env';\n\nconst PLATFORM_TO_ANALYTICS_PLATFORM: { [platform: string]: string } = {\n darwin: 'Mac',\n win32: 'Windows',\n linux: 'Linux',\n};\n\nlet client: RudderAnalytics | null = null;\nlet identified = false;\nlet identifyData: {\n userId: string;\n deviceId: string;\n traits: Record<string, any>;\n} | null = null;\n\nfunction getClient(): RudderAnalytics {\n if (client) {\n return client;\n }\n\n client = new RudderAnalytics(\n env.EXPO_STAGING || env.EXPO_LOCAL\n ? '24TKICqYKilXM480mA7ktgVDdea'\n : '24TKR7CQAaGgIrLTgu3Fp4OdOkI', // expo unified\n 'https://cdp.expo.dev/v1/batch',\n {\n flushInterval: 300,\n }\n );\n\n // Install flush on exit...\n process.on('SIGINT', () => client?.flush?.());\n process.on('SIGTERM', () => client?.flush?.());\n\n return client;\n}\n\nexport async function setUserDataAsync(userId: string, traits: Record<string, any>): Promise<void> {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n\n const deviceId = await UserSettings.getAnonymousIdentifierAsync();\n\n identifyData = {\n userId,\n deviceId,\n traits,\n };\n\n ensureIdentified();\n}\n\nexport function logEvent(\n event: // TODO: revise\n | 'action'\n | 'Open Url on Device'\n | 'Start Project'\n | 'Serve Manifest'\n | 'dev client start command'\n | 'Serve Expo Updates Manifest',\n properties: Record<string, any> = {}\n): void {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n ensureIdentified();\n\n const { userId, deviceId } = identifyData ?? {};\n const commonEventProperties = { source_version: process.env.__EXPO_VERSION, source: 'expo' };\n\n const identity = { userId: userId ?? undefined, anonymousId: deviceId ?? uuidv4() };\n getClient().track({\n event,\n properties: { ...properties, ...commonEventProperties },\n ...identity,\n context: getContext(),\n });\n}\n\nfunction ensureIdentified(): void {\n if (env.EXPO_NO_TELEMETRY || identified || !identifyData) {\n return;\n }\n\n getClient().identify({\n userId: identifyData.userId,\n anonymousId: identifyData.deviceId,\n traits: identifyData.traits,\n });\n identified = true;\n}\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/analytics/rudderstackClient.ts"],"sourcesContent":["import RudderAnalytics from '@expo/rudder-sdk-node';\nimport * as ciInfo from 'ci-info';\nimport os from 'os';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { env } from '../env';\n\nconst PLATFORM_TO_ANALYTICS_PLATFORM: { [platform: string]: string } = {\n darwin: 'Mac',\n win32: 'Windows',\n linux: 'Linux',\n};\n\nlet client: RudderAnalytics | null = null;\nlet identified = false;\nlet identifyData: {\n userId: string;\n deviceId: string;\n traits: Record<string, any>;\n} | null = null;\n\nfunction getClient(): RudderAnalytics {\n if (client) {\n return client;\n }\n\n client = new RudderAnalytics(\n env.EXPO_STAGING || env.EXPO_LOCAL\n ? '24TKICqYKilXM480mA7ktgVDdea'\n : '24TKR7CQAaGgIrLTgu3Fp4OdOkI', // expo unified\n 'https://cdp.expo.dev/v1/batch',\n {\n flushInterval: 300,\n }\n );\n\n // Install flush on exit...\n process.on('SIGINT', () => client?.flush?.());\n process.on('SIGTERM', () => client?.flush?.());\n\n return client;\n}\n\nexport async function setUserDataAsync(userId: string, traits: Record<string, any>): Promise<void> {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n\n const deviceId = await UserSettings.getAnonymousIdentifierAsync();\n\n identifyData = {\n userId,\n deviceId,\n traits,\n };\n\n ensureIdentified();\n}\n\nexport function logEvent(\n event: // TODO: revise\n | 'action'\n | 'Open Url on Device'\n | 'Start Project'\n | 'Serve Manifest'\n | 'dev client start command'\n | 'Serve Expo Updates Manifest',\n properties: Record<string, any> = {}\n): void {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n ensureIdentified();\n\n const { userId, deviceId } = identifyData ?? {};\n const commonEventProperties = { source_version: process.env.__EXPO_VERSION, source: 'expo' };\n\n const identity = { userId: userId ?? undefined, anonymousId: deviceId ?? uuidv4() };\n getClient().track({\n event,\n properties: { ...properties, ...commonEventProperties },\n ...identity,\n context: getContext(),\n });\n}\n\nfunction ensureIdentified(): void {\n if (env.EXPO_NO_TELEMETRY || identified || !identifyData) {\n return;\n }\n\n getClient().identify({\n userId: identifyData.userId,\n anonymousId: identifyData.deviceId,\n traits: identifyData.traits,\n });\n identified = true;\n}\n\n/** Exposed for testing only */\nexport function getContext(): Record<string, any> {\n const platform = PLATFORM_TO_ANALYTICS_PLATFORM[os.platform()] || os.platform();\n return {\n os: { name: platform, version: os.release() },\n device: { type: platform, model: platform },\n app: { name: 'expo', version: process.env.__EXPO_VERSION },\n ci: ciInfo.isCI ? { name: ciInfo.name, isPr: ciInfo.isPR } : undefined,\n };\n}\n"],"names":["setUserDataAsync","logEvent","getContext","ciInfo","PLATFORM_TO_ANALYTICS_PLATFORM","darwin","win32","linux","client","identified","identifyData","getClient","RudderAnalytics","env","EXPO_STAGING","EXPO_LOCAL","flushInterval","process","on","flush","userId","traits","EXPO_NO_TELEMETRY","deviceId","UserSettings","getAnonymousIdentifierAsync","ensureIdentified","event","properties","commonEventProperties","source_version","__EXPO_VERSION","source","identity","undefined","anonymousId","uuidv4","track","context","identify","platform","os","name","version","release","device","type","model","app","ci","isCI","isPr","isPR"],"mappings":"AAAA;;;;QA4CsBA,gBAAgB,GAAhBA,gBAAgB;QAgBtBC,QAAQ,GAARA,QAAQ;QAyCRC,UAAU,GAAVA,UAAU;AArGE,IAAA,cAAuB,kCAAvB,uBAAuB,EAAA;AACvCC,IAAAA,MAAM,mCAAM,SAAS,EAAf;AACH,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACU,IAAA,KAAM,WAAN,MAAM,CAAA;AAEV,IAAA,aAA6B,kCAA7B,6BA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