Socket
Socket
Sign inDemoInstall

@react-native-community/cli-platform-ios

Package Overview
Dependencies
Maintainers
35
Versions
203
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/cli-platform-ios - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

LICENSE

62

build/commands/runIOS/findMatchingSimulator.js

@@ -28,3 +28,3 @@ "use strict";

*/
function findMatchingSimulator(simulators, simulatorString) {
function findMatchingSimulator(simulators, findOptions) {
if (!simulators.devices) {

@@ -36,10 +36,13 @@ return null;

let simulatorVersion;
let simulatorName;
const parsedSimulatorName = simulatorString ? simulatorString.match(/(.*)? (?:\((\d+\.\d+)?\))$/) : [];
let simulatorName = null;
if (parsedSimulatorName && parsedSimulatorName[2] !== undefined) {
simulatorVersion = parsedSimulatorName[2];
simulatorName = parsedSimulatorName[1];
} else {
simulatorName = simulatorString;
if (findOptions && findOptions.simulator) {
const parsedSimulatorName = findOptions.simulator.match(/(.*)? (?:\((\d+\.\d+)?\))$/);
if (parsedSimulatorName && parsedSimulatorName[2] !== undefined) {
simulatorVersion = parsedSimulatorName[2];
simulatorName = parsedSimulatorName[1];
} else {
simulatorName = findOptions.simulator;
}
}

@@ -76,29 +79,26 @@

const booted = simulator.state === 'Booted';
const simulatorDescriptor = {
udid: simulator.udid,
name: simulator.name,
booted,
version
};
if (booted && simulatorName === null) {
return {
udid: simulator.udid,
name: simulator.name,
booted,
version
};
}
if (findOptions && findOptions.udid) {
if (simulator.udid === findOptions.udid) {
return simulatorDescriptor;
}
} else {
if (booted && simulatorName === null) {
return simulatorDescriptor;
}
if (simulator.name === simulatorName && !match) {
match = {
udid: simulator.udid,
name: simulator.name,
booted,
version
};
} // Keeps track of the first available simulator for use if we can't find one above.
if (simulator.name === simulatorName && !match) {
match = simulatorDescriptor;
} // Keeps track of the first available simulator for use if we can't find one above.
if (simulatorName === null && !match) {
match = {
udid: simulator.udid,
name: simulator.name,
booted,
version
};
if (simulatorName === null && !match) {
match = simulatorDescriptor;
}
}

@@ -105,0 +105,0 @@ }

@@ -94,34 +94,37 @@ "use strict";

_cliTools().logger.info(`Found Xcode ${xcodeProject.isWorkspace ? 'workspace' : 'project'} "${_chalk().default.bold(xcodeProject.name)}"`);
_cliTools().logger.info(`Found Xcode ${xcodeProject.isWorkspace ? 'workspace' : 'project'} "${_chalk().default.bold(xcodeProject.name)}"`); // No need to load all available devices
const {
device,
udid
} = args;
if (!device && !udid) {
if (!args.device && !args.udid) {
return runOnSimulator(xcodeProject, scheme, args);
}
if (args.device && args.udid) {
return _cliTools().logger.error('The `device` and `udid` options are mutually exclusive.');
}
const devices = (0, _parseIOSDevicesList.default)(_child_process().default.execFileSync('xcrun', ['instruments', '-s'], {
encoding: 'utf8'
})); // first device is always the host Mac
}));
if (devices.length <= 1) {
return _cliTools().logger.error('No iOS devices connected.');
}
if (args.udid) {
const device = devices.find(d => d.udid === args.udid);
const selectedDevice = matchingDevice(devices, device, udid);
if (!device) {
return _cliTools().logger.error(`Could not find a device with udid: "${_chalk().default.bold(args.udid)}". ${printFoundDevices(devices)}`);
}
if (selectedDevice) {
return runOnDevice(selectedDevice, scheme, xcodeProject, args);
}
if (device.type === 'simulator') {
return runOnSimulator(xcodeProject, scheme, args);
} else {
return runOnDevice(device, scheme, xcodeProject, args);
}
} else {
const physicalDevices = devices.filter(d => d.type !== 'simulator');
const device = matchingDevice(physicalDevices, args.device);
if (device) {
return _cliTools().logger.error(`Could not find a device named: "${_chalk().default.bold(String(device))}". ${printFoundDevices(devices)}`);
if (device) {
return runOnDevice(device, scheme, xcodeProject, args);
}
}
if (udid) {
return _cliTools().logger.error(`Could not find a device with udid: "${_chalk().default.bold(udid)}". ${printFoundDevices(devices)}`);
}
}

@@ -148,7 +151,9 @@

const selectedSimulator = fallbackSimulators.reduce((simulator, fallback) => {
return simulator || (0, _findMatchingSimulator.default)(simulators, fallback);
}, (0, _findMatchingSimulator.default)(simulators, args.simulator));
return simulator || (0, _findMatchingSimulator.default)(simulators, {
simulator: fallback
});
}, (0, _findMatchingSimulator.default)(simulators, args));
if (!selectedSimulator) {
throw new (_cliTools().CLIError)(`Could not find "${args.simulator}" simulator`);
throw new (_cliTools().CLIError)(`No simulator available with ${args.simulator ? `name "${args.simulator}"` : `udid "${args.udid}"`}`);
}

@@ -352,22 +357,28 @@ /**

function matchingDevice(devices, deviceName, udid) {
if (udid) {
return matchingDeviceByUdid(devices, udid);
function matchingDevice(devices, deviceName) {
if (deviceName === true) {
const firstIOSDevice = devices.find(d => d.type === 'device');
if (firstIOSDevice) {
_cliTools().logger.info(`Using first available device named "${_chalk().default.bold(firstIOSDevice.name)}" due to lack of name supplied.`);
return firstIOSDevice;
} else {
_cliTools().logger.error('No iOS devices connected.');
return undefined;
}
}
if (deviceName === true && devices.length === 1) {
_cliTools().logger.info(`Using first available device named "${_chalk().default.bold(devices[0].name)}" due to lack of name supplied.`);
const deviceByName = devices.find(device => device.name === deviceName || formattedDeviceName(device) === deviceName);
return devices[0];
if (!deviceByName) {
_cliTools().logger.error(`Could not find a device named: "${_chalk().default.bold(String(deviceName))}". ${printFoundDevices(devices)}`);
}
return devices.find(device => device.name === deviceName || formattedDeviceName(device) === deviceName);
return deviceByName;
}
function matchingDeviceByUdid(devices, udid) {
return devices.find(device => device.udid === udid);
}
function formattedDeviceName(simulator) {
return `${simulator.name} (${simulator.version})`;
return simulator.version ? `${simulator.name} (${simulator.version})` : simulator.name;
}

@@ -374,0 +385,0 @@

@@ -17,36 +17,35 @@ "use strict";

/**
* Parses the output of `xcrun simctl list devices` command
* Parses the output of the `xcrun instruments -s` command and returns metadata
* about available iOS simulators and physical devices, as well as host Mac for
* Catalyst purposes.
*
* Expected text looks roughly like this:
*
* ```
* Known Devices:
* this-mac-device [ID]
* Some Apple Simulator (Version) [ID]
* this-mac-device [UDID]
* A Physical Device (OS Version) [UDID]
* A Simulator Device (OS Version) [UDID] (Simulator)
* ```
*/
function parseIOSDevicesList(text) {
const devices = [];
text.split('\n').forEach((line, index) => {
const device = line.match(/(.*?) \((.*?)\) \[(.*?)\]/);
const noSimulator = line.match(/(.*?) \((.*?)\) \[(.*?)\] \((.*?)\)/);
text.split('\n').forEach(line => {
const device = line.match(/(.*?) (\(([0-9\.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i);
if (index === 1) {
const myMac = line.match(/(.*?) \[(.*?)\]/);
if (device) {
const [, name,, version, udid, isSimulator] = device;
const metadata = {
name,
udid
};
if (myMac) {
const name = myMac[1];
const udid = myMac[2];
devices.push({
udid,
name
});
if (version) {
metadata.version = version;
metadata.type = isSimulator ? 'simulator' : 'device';
} else {
metadata.type = 'catalyst';
}
}
if (device != null && noSimulator == null) {
const name = device[1];
const version = device[2];
const udid = device[3];
devices.push({
udid,
name,
version
});
devices.push(metadata);
}

@@ -53,0 +52,0 @@ });

{
"name": "@react-native-community/cli-platform-ios",
"version": "4.4.0",
"version": "4.5.0",
"license": "MIT",

@@ -31,3 +31,3 @@ "main": "build/index.js",

],
"gitHead": "4824113076035e78883b8f0fb74aa2d40d873085"
"gitHead": "a4a0f784910c6cc7f6418ee987965778266f8d1c"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc