@react-native-community/cli-platform-ios
Advanced tools
Comparing version 2.0.0-alpha.7 to 2.0.0-alpha.8
@@ -38,2 +38,12 @@ "use strict"; | ||
function _chalk() { | ||
const data = _interopRequireDefault(require("chalk")); | ||
_chalk = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _findXcodeProject = _interopRequireDefault(require("./findXcodeProject")); | ||
@@ -79,2 +89,11 @@ | ||
const { | ||
device, | ||
udid | ||
} = args; | ||
if (!device && !udid) { | ||
return runOnSimulator(xcodeProject, scheme, args); | ||
} | ||
const devices = (0, _parseIOSDevicesList.default)( // $FlowExpectedError https://github.com/facebook/flow/issues/5675 | ||
@@ -84,21 +103,20 @@ _child_process().default.execFileSync('xcrun', ['instruments', '-s'], { | ||
})); | ||
const device = args.device; | ||
const udid = args.udid; | ||
if (device || udid) { | ||
const selectedDevice = device ? matchingDevice(devices, device) : matchingDeviceByUdid(devices, udid); | ||
if (devices.length === 0) { | ||
return _cliTools().logger.error('No iOS devices connected.'); | ||
} | ||
if (selectedDevice) { | ||
return runOnDevice(selectedDevice, scheme, xcodeProject, args); | ||
} | ||
const selectedDevice = matchingDevice(devices, device, udid); | ||
if (devices && devices.length > 0) { | ||
const message = device ? `Could not find device with the name: "${device}". Choose one of the following:\n${printFoundDevices(devices)}` : `Could not find device with the udid: "${udid}". Choose one of the following:\n${printFoundDevices(devices)}`; | ||
return _cliTools().logger.error(message); | ||
} | ||
if (selectedDevice) { | ||
return runOnDevice(selectedDevice, scheme, xcodeProject, args); | ||
} | ||
return _cliTools().logger.error('No iOS devices connected.'); | ||
if (device) { | ||
return _cliTools().logger.error(`Could not find a device named: "${_chalk().default.bold(device)}". ${printFoundDevices(devices)}`); | ||
} | ||
return runOnSimulator(xcodeProject, scheme, args); | ||
if (udid) { | ||
return _cliTools().logger.error(`Could not find a device with udid: "${_chalk().default.bold(udid)}". ${printFoundDevices(devices)}`); | ||
} | ||
} | ||
@@ -279,5 +297,9 @@ | ||
function matchingDevice(devices, deviceName) { | ||
function matchingDevice(devices, deviceName, udid) { | ||
if (udid) { | ||
return matchingDeviceByUdid(devices, udid); | ||
} | ||
if (deviceName === true && devices.length === 1) { | ||
_cliTools().logger.info(`Using first available device ${devices[0].name} due to lack of name supplied.`); | ||
_cliTools().logger.info(`Using first available device named "${_chalk().default.bold(devices[0].name)}" due to lack of name supplied.`); | ||
@@ -287,19 +309,7 @@ return devices[0]; | ||
for (let i = devices.length - 1; i >= 0; i--) { | ||
if (devices[i].name === deviceName || formattedDeviceName(devices[i]) === deviceName) { | ||
return devices[i]; | ||
} | ||
} | ||
return null; | ||
return devices.find(device => device.name === deviceName || formattedDeviceName(device) === deviceName); | ||
} | ||
function matchingDeviceByUdid(devices, udid) { | ||
for (let i = devices.length - 1; i >= 0; i--) { | ||
if (devices[i].udid === udid) { | ||
return devices[i]; | ||
} | ||
} | ||
return null; | ||
return devices.find(device => device.udid === udid); | ||
} | ||
@@ -312,9 +322,3 @@ | ||
function printFoundDevices(devices) { | ||
let output = ''; | ||
for (let i = devices.length - 1; i >= 0; i--) { | ||
output += `${devices[i].name} Udid: ${devices[i].udid}\n`; | ||
} | ||
return output; | ||
return ['Available devices:', ...devices.map(device => ` - ${device.name} (${device.udid})`)].join('\n'); | ||
} | ||
@@ -321,0 +325,0 @@ |
{ | ||
"name": "@react-native-community/cli-platform-ios", | ||
"version": "2.0.0-alpha.7", | ||
"version": "2.0.0-alpha.8", | ||
"main": "build/index.js", | ||
"dependencies": { | ||
"@react-native-community/cli-tools": "^2.0.0-alpha.7", | ||
"@react-native-community/cli-tools": "^2.0.0-alpha.8", | ||
"chalk": "^1.1.1", | ||
@@ -11,5 +11,6 @@ "xcode": "^2.0.0" | ||
"files": [ | ||
"build" | ||
"build", | ||
"native_modules.rb" | ||
], | ||
"gitHead": "60606efd56da6065d339100e42968c25b4dad182" | ||
"gitHead": "98d88d5f4312f09b01da5ac8a14648900176a114" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94209
58
2433