1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 | function _child_process() {
|
8 | const data = require("child_process");
|
9 | _child_process = function () {
|
10 | return data;
|
11 | };
|
12 | return data;
|
13 | }
|
14 | function _os() {
|
15 | const data = _interopRequireDefault(require("os"));
|
16 | _os = function () {
|
17 | return data;
|
18 | };
|
19 | return data;
|
20 | }
|
21 | function _path() {
|
22 | const data = _interopRequireDefault(require("path"));
|
23 | _path = function () {
|
24 | return data;
|
25 | };
|
26 | return data;
|
27 | }
|
28 | function _cliTools() {
|
29 | const data = require("@react-native-community/cli-tools");
|
30 | _cliTools = function () {
|
31 | return data;
|
32 | };
|
33 | return data;
|
34 | }
|
35 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | function findAvailableDevice(devices) {
|
45 | for (const key of Object.keys(devices)) {
|
46 | for (const device of devices[key]) {
|
47 | if (device.availability === '(available)' && device.state === 'Booted') {
|
48 | return device;
|
49 | }
|
50 | }
|
51 | }
|
52 | return null;
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | async function logIOS() {
|
59 | const rawDevices = (0, _child_process().execFileSync)('xcrun', ['simctl', 'list', 'devices', '--json'], {
|
60 | encoding: 'utf8'
|
61 | });
|
62 | const {
|
63 | devices
|
64 | } = JSON.parse(rawDevices);
|
65 | const device = findAvailableDevice(devices);
|
66 | if (device === null) {
|
67 | _cliTools().logger.error('No active iOS device found');
|
68 | return;
|
69 | }
|
70 | tailDeviceLogs(device.udid);
|
71 | }
|
72 | function tailDeviceLogs(udid) {
|
73 | const logDir = _path().default.join(_os().default.homedir(), 'Library', 'Logs', 'CoreSimulator', udid, 'asl');
|
74 | const log = (0, _child_process().spawnSync)('syslog', ['-w', '-F', 'std', '-d', logDir], {
|
75 | stdio: 'inherit'
|
76 | });
|
77 | if (log.error !== null) {
|
78 | throw log.error;
|
79 | }
|
80 | }
|
81 | var _default = {
|
82 | name: 'log-ios',
|
83 | description: 'starts iOS device syslog tail',
|
84 | func: logIOS
|
85 | };
|
86 | exports.default = _default;
|
87 |
|
88 |
|
\ | No newline at end of file |