Socket
Socket
Sign inDemoInstall

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

Package Overview
Dependencies
Maintainers
30
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 13.4.0 to 13.5.0

46

build/commands/logCommand/createLog.js

@@ -35,9 +35,6 @@ "use strict";

}
var _getSimulators = _interopRequireDefault(require("../../tools/getSimulators"));
var _listDevices = _interopRequireWildcard(require("../../tools/listDevices"));
var _listDevices = _interopRequireDefault(require("../../tools/listDevices"));
var _getPlatformInfo = require("../runCommand/getPlatformInfo");
var _supportedPlatforms = require("../../config/supportedPlatforms");
var _prompts = require("../../tools/prompts");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -58,38 +55,23 @@ /**

}
// 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.
const simulators = (0, _getSimulators.default)();
const bootedSimulators = Object.keys(simulators.devices).map(key => simulators.devices[key]).reduce((acc, val) => acc.concat(val), []).filter(({
state
}) => state === 'Booted');
const {
sdkNames
} = (0, _getPlatformInfo.getPlatformInfo)(platformName);
const devices = await (0, _listDevices.default)(sdkNames);
const availableSimulators = devices.filter(({
type,
isAvailable
}) => type === 'simulator' && isAvailable);
if (availableSimulators.length === 0) {
const allDevices = await (0, _listDevices.default)(sdkNames);
const simulators = allDevices.filter(({
type
}) => type === 'simulator');
if (simulators.length === 0) {
_cliTools().logger.error('No simulators detected. Install simulators via Xcode.');
return;
}
const bootedAndAvailableSimulators = bootedSimulators.map(booted => {
const available = availableSimulators.find(({
udid
}) => udid === booted.udid);
return {
...available,
...booted
};
}).filter(({
sdk
}) => sdk && sdkNames.includes((0, _listDevices.stripPlatform)(sdk)));
if (bootedAndAvailableSimulators.length === 0) {
const booted = simulators.filter(({
state
}) => state === 'Booted');
if (booted.length === 0) {
_cliTools().logger.error(`No booted and available ${platformReadableName} simulators found.`);
return;
}
if (args.interactive && bootedAndAvailableSimulators.length > 1) {
const udid = await (0, _prompts.promptForDeviceToTailLogs)(platformReadableName, bootedAndAvailableSimulators);
const simulator = bootedAndAvailableSimulators.find(({
if (args.interactive && booted.length > 1) {
const udid = await (0, _prompts.promptForDeviceToTailLogs)(platformReadableName, booted);
const simulator = booted.find(({
udid: deviceUDID

@@ -102,3 +84,3 @@ }) => deviceUDID === udid);

} else {
tailDeviceLogs(bootedAndAvailableSimulators[0]);
tailDeviceLogs(booted[0]);
}

@@ -105,0 +87,0 @@ };

@@ -127,9 +127,6 @@ "use strict";

const devices = await (0, _listDevices.default)(sdkNames);
const availableDevices = devices.filter(({
isAvailable
}) => isAvailable === true);
if (availableDevices.length === 0) {
if (devices.length === 0) {
return _cliTools().logger.error(`${platformReadableName} devices or simulators not detected. Install simulators via Xcode or connect a physical ${platformReadableName} device`);
}
const fallbackSimulator = platformName === 'ios' ? (0, _getFallbackSimulator.getFallbackSimulator)(args) : availableDevices[0];
const fallbackSimulator = platformName === 'ios' ? (0, _getFallbackSimulator.getFallbackSimulator)(args) : devices[0];
if (args.listDevices || args.interactive) {

@@ -141,3 +138,3 @@ if (args.device || args.udid) {

const preferredDevice = _cliTools().cacheManager.get(packageJson.name, 'lastUsedIOSDeviceId');
const selectedDevice = await (0, _prompts.promptForDeviceSelection)(availableDevices, preferredDevice);
const selectedDevice = await (0, _prompts.promptForDeviceSelection)(devices, preferredDevice);
if (!selectedDevice) {

@@ -157,9 +154,10 @@ throw new (_cliTools().CLIError)(`Failed to select device, please try to run app without ${args.listDevices ? 'list-devices' : 'interactive'} command.`);

if (!args.device && !args.udid && !args.simulator) {
const bootedDevices = availableDevices.filter(({
type
}) => type === 'device');
const bootedSimulators = devices.filter(({
state,
type
}) => type === 'simulator');
const booted = [...bootedDevices, ...bootedSimulators];
}) => state === 'Booted' && type === 'simulator');
const bootedDevices = devices.filter(({
type
}) => type === 'device'); // Physical devices here are always booted
const booted = [...bootedSimulators, ...bootedDevices];
if (booted.length === 0) {

@@ -184,5 +182,5 @@ _cliTools().logger.info('No booted devices or simulators found. Launching first available simulator...');

if (args.udid) {
const device = availableDevices.find(d => d.udid === args.udid);
const device = devices.find(d => d.udid === args.udid);
if (!device) {
return _cliTools().logger.error(`Could not find a device with udid: "${_chalk().default.bold(args.udid)}". ${(0, _matchingDevice.printFoundDevices)(availableDevices)}`);
return _cliTools().logger.error(`Could not find a device with udid: "${_chalk().default.bold(args.udid)}". ${(0, _matchingDevice.printFoundDevices)(devices)}`);
}

@@ -195,3 +193,3 @@ if (device.type === 'simulator') {

} else if (args.device) {
const physicalDevices = availableDevices.filter(({
const physicalDevices = devices.filter(({
type

@@ -198,0 +196,0 @@ }) => type !== 'simulator');

@@ -32,5 +32,39 @@ "use strict";

};
/**
* Executes `xcrun xcdevice list` and `xcrun simctl list --json devices`, and connects parsed output of these two commands. We are running these two commands as they are necessary to display both physical devices and simulators. However, it's important to note that neither command provides a combined output of both.
* @param sdkNames
* @returns List of available devices and simulators.
*/
async function listDevices(sdkNames) {
const out = _execa().default.sync('xcrun', ['xcdevice', 'list']).stdout;
return parseXcdeviceList(out, sdkNames);
const xcdeviceOutput = _execa().default.sync('xcrun', ['xcdevice', 'list']).stdout;
const parsedXcdeviceOutput = parseXcdeviceList(xcdeviceOutput, sdkNames);
const simctlOutput = JSON.parse(_execa().default.sync('xcrun', ['simctl', 'list', '--json', 'devices']).stdout);
const parsedSimctlOutput = Object.keys(simctlOutput.devices).map(key => simctlOutput.devices[key]).reduce((acc, val) => acc.concat(val), []);
const merged = [];
const matchedUdids = new Set();
parsedXcdeviceOutput.forEach(first => {
const match = parsedSimctlOutput.find(second => first.udid === second.udid);
if (match) {
matchedUdids.add(first.udid);
merged.push({
...first,
...match
});
} else {
merged.push({
...first
});
}
});
parsedSimctlOutput.forEach(item => {
if (!matchedUdids.has(item.udid)) {
merged.push({
...item
});
}
});
return merged.filter(({
isAvailable
}) => isAvailable === true);
}

@@ -37,0 +71,0 @@ function stripPlatform(platform) {

{
"name": "@react-native-community/cli-platform-apple",
"version": "13.4.0",
"version": "13.5.0",
"license": "MIT",

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

"dependencies": {
"@react-native-community/cli-tools": "13.4.0",
"@react-native-community/cli-tools": "13.5.0",
"chalk": "^4.1.2",

@@ -19,3 +19,3 @@ "execa": "^5.0.0",

"devDependencies": {
"@react-native-community/cli-types": "13.4.0",
"@react-native-community/cli-types": "13.5.0",
"@types/glob": "^7.1.1",

@@ -36,3 +36,3 @@ "@types/lodash": "^4.14.149",

},
"gitHead": "13e37351f1959b9cc96f325d938e3930895049dd"
"gitHead": "092c37cf27ebbf019e710f8aa118f673066f273c"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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