amis-rpc-design/node_modules/@react-native-community/cli-platform-ios/build/commands/logIOS/index.js.map

1 line
5.5 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["logIOS","_argv","_ctx","args","simulators","getSimulators","bootedSimulators","Object","keys","devices","map","key","reduce","acc","val","concat","filter","state","listIOSDevices","availableSimulators","type","isAvailable","bootedAndAvailableSimulators","booted","available","find","udid","length","logger","error","interactive","prompts","name","message","choices","simulator","title","value","tailDeviceLogs","logDir","path","join","os","homedir","log","spawnSync","stdio","description","func","options"],"sources":["../../../src/commands/logIOS/index.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport {spawnSync} from 'child_process';\nimport os from 'os';\nimport path from 'path';\nimport {logger} from '@react-native-community/cli-tools';\nimport listIOSDevices from '../../tools/listIOSDevices';\nimport getSimulators from '../../tools/getSimulators';\nimport {Config} from '@react-native-community/cli-types';\nimport prompts from 'prompts';\n\n/**\n * Starts iOS device syslog tail\n */\n\ntype Args = {\n interactive: boolean;\n};\n\nasync function logIOS(_argv: Array<string>, _ctx: Config, args: Args) {\n // Here we're using two command because first command `xcrun simctl list --json devices` outputs `state` but doesn't return `available`. But second command `xcrun xcdevice list` outputs `available` but doesn't output `state`. So we need to connect outputs of both commands.\n const simulators = getSimulators();\n const bootedSimulators = Object.keys(simulators.devices)\n .map((key) => simulators.devices[key])\n .reduce((acc, val) => acc.concat(val), [])\n .filter(({state}) => state === 'Booted');\n\n const devices = await listIOSDevices();\n const availableSimulators = devices.filter(\n ({type, isAvailable}) => type === 'simulator' && isAvailable,\n );\n\n const bootedAndAvailableSimulators = bootedSimulators.map((booted) => {\n const available = availableSimulators.find(\n ({udid}) => udid === booted.udid,\n );\n return {...available, ...booted};\n });\n\n if (bootedAndAvailableSimulators.length === 0) {\n logger.error('No active iOS device found');\n return;\n }\n\n if (args.interactive && bootedAndAvailableSimulators.length > 1) {\n const {udid} = await prompts({\n type: 'select',\n name: 'udid',\n message: 'Select iOS simulators to tail logs from',\n choices: bootedAndAvailableSimulators.map((simulator) => ({\n title: simulator.name,\n value: simulator.udid,\n })),\n });\n\n tailDeviceLogs(udid);\n } else {\n tailDeviceLogs(bootedAndAvailableSimulators[0].udid);\n }\n}\n\nfunction tailDeviceLogs(udid: string) {\n const logDir = path.join(\n os.homedir(),\n 'Library',\n 'Logs',\n 'CoreSimulator',\n udid,\n 'asl',\n );\n\n const log = spawnSync('syslog', ['-w', '-F', 'std', '-d', logDir], {\n stdio: 'inherit',\n });\n\n if (log.error !== null) {\n throw log.error;\n }\n}\n\nexport default {\n name: 'log-ios',\n description: 'starts iOS device syslog tail',\n func: logIOS,\n options: [\n {\n name: '--interactive',\n description:\n 'Explicitly select simulator to tail logs from. By default it will tail logs from the first booted and available simulator.',\n },\n ],\n};\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA8B;AAf9B;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA,eAAeA,MAAM,CAACC,KAAoB,EAAEC,IAAY,EAAEC,IAAU,EAAE;EACpE;EACA,MAAMC,UAAU,GAAG,IAAAC,sBAAa,GAAE;EAClC,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CAACJ,UAAU,CAACK,OAAO,CAAC,CACrDC,GAAG,CAAEC,GAAG,IAAKP,UAAU,CAACK,OAAO,CAACE,GAAG,CAAC,CAAC,CACrCC,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAKD,GAAG,CAACE,MAAM,CAACD,GAAG,CAAC,EAAE,EAAE,CAAC,CACzCE,MAAM,CAAC,CAAC;IAACC;EAAK,CAAC,