@react-native-community/cli-platform-ios
Advanced tools
Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7
@@ -82,43 +82,24 @@ "use strict"; | ||
})); | ||
const device = args.device; | ||
const udid = args.udid; | ||
if (args.device) { | ||
const selectedDevice = matchingDevice(devices, args.device); | ||
if (device || udid) { | ||
const selectedDevice = device ? matchingDevice(devices, device) : matchingDeviceByUdid(devices, udid); | ||
if (selectedDevice) { | ||
return runOnDevice(selectedDevice, scheme, xcodeProject, args.configuration, args.packager, args.verbose, args.port); | ||
return runOnDevice(selectedDevice, scheme, xcodeProject, args); | ||
} | ||
if (devices && devices.length > 0) { | ||
// $FlowIssue: args.device is defined in this context | ||
_cliTools().logger.error(`Could not find device with the name: "${args.device}". | ||
Choose one of the following:${printFoundDevices(devices)}`); | ||
} else { | ||
_cliTools().logger.error('No iOS devices connected.'); | ||
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); | ||
} | ||
} else if (args.udid) { | ||
// $FlowIssue: args.udid is defined in this context | ||
return runOnDeviceByUdid(args, scheme, xcodeProject, devices); | ||
} | ||
return runOnSimulator(xcodeProject, args, scheme); | ||
} | ||
function runOnDeviceByUdid(args, scheme, xcodeProject, devices) { | ||
const selectedDevice = matchingDeviceByUdid(devices, args.udid); | ||
if (selectedDevice) { | ||
runOnDevice(selectedDevice, scheme, xcodeProject, args.configuration, args.packager, args.verbose, args.port); | ||
return; | ||
return _cliTools().logger.error('No iOS devices connected.'); | ||
} | ||
if (devices && devices.length > 0) { | ||
// $FlowIssue: args.udid is defined in this context | ||
_cliTools().logger.error(`Could not find device with the udid: "${args.udid}". | ||
Choose one of the following:\n${printFoundDevices(devices)}`); | ||
} else { | ||
_cliTools().logger.error('No iOS devices connected.'); | ||
} | ||
return runOnSimulator(xcodeProject, scheme, args); | ||
} | ||
async function runOnSimulator(xcodeProject, args, scheme) { | ||
async function runOnSimulator(xcodeProject, scheme, args) { | ||
let simulators; | ||
@@ -164,3 +145,3 @@ | ||
const appName = await buildProject(xcodeProject, selectedSimulator.udid, scheme, args.configuration, args.packager, args.verbose, args.port); | ||
const appName = await buildProject(xcodeProject, selectedSimulator.udid, scheme, args); | ||
const appPath = getBuildPath(args.configuration, appName, false, scheme); | ||
@@ -186,7 +167,7 @@ | ||
async function runOnDevice(selectedDevice, scheme, xcodeProject, configuration, launchPackager, verbose, port) { | ||
const appName = await buildProject(xcodeProject, selectedDevice.udid, scheme, configuration, launchPackager, verbose, port); | ||
const iosDeployInstallArgs = ['--bundle', getBuildPath(configuration, appName, true, scheme), '--id', selectedDevice.udid, '--justlaunch']; | ||
async function runOnDevice(selectedDevice, scheme, xcodeProject, args) { | ||
const appName = await buildProject(xcodeProject, selectedDevice.udid, scheme, args); | ||
const iosDeployInstallArgs = ['--bundle', getBuildPath(args.configuration, appName, true, scheme), '--id', selectedDevice.udid, '--justlaunch']; | ||
_cliTools().logger.info(`installing and launching your app on ${selectedDevice.name}...`); | ||
_cliTools().logger.info(`Installing and launching your app on ${selectedDevice.name}...`); | ||
@@ -204,5 +185,5 @@ const iosDeployOutput = _child_process().default.spawnSync('ios-deploy', iosDeployInstallArgs, { | ||
function buildProject(xcodeProject, udid, scheme, configuration, launchPackager = false, verbose, port) { | ||
function buildProject(xcodeProject, udid, scheme, args) { | ||
return new Promise((resolve, reject) => { | ||
const xcodebuildArgs = [xcodeProject.isWorkspace ? '-workspace' : '-project', xcodeProject.name, '-configuration', configuration, '-scheme', scheme, '-destination', `id=${udid}`, '-derivedDataPath', `build/${scheme}`]; | ||
const xcodebuildArgs = [xcodeProject.isWorkspace ? '-workspace' : '-project', xcodeProject.name, '-configuration', args.configuration, '-scheme', scheme, '-destination', `id=${udid}`, '-derivedDataPath', `build/${scheme}`]; | ||
@@ -213,3 +194,3 @@ _cliTools().logger.info(`Building using "xcodebuild ${xcodebuildArgs.join(' ')}"`); | ||
if (!verbose) { | ||
if (!args.verbose) { | ||
xcpretty = xcprettyAvailable() && _child_process().default.spawn('xcpretty', [], { | ||
@@ -220,3 +201,3 @@ stdio: ['pipe', process.stdout, process.stderr] | ||
const buildProcess = _child_process().default.spawn('xcodebuild', xcodebuildArgs, getProcessOptions(launchPackager, port)); | ||
const buildProcess = _child_process().default.spawn('xcodebuild', xcodebuildArgs, getProcessOptions(args)); | ||
@@ -341,6 +322,11 @@ let buildOutput = ''; | ||
function getProcessOptions(launchPackager, port) { | ||
if (launchPackager) { | ||
function getProcessOptions({ | ||
packager, | ||
terminal, | ||
port | ||
}) { | ||
if (packager) { | ||
return { | ||
env: _objectSpread({}, process.env, { | ||
RCT_TERMINAL: terminal, | ||
RCT_METRO_PORT: port | ||
@@ -353,2 +339,3 @@ }) | ||
env: _objectSpread({}, process.env, { | ||
RCT_TERMINAL: terminal, | ||
RCT_NO_LAUNCH_PACKAGER: true | ||
@@ -407,4 +394,8 @@ }) | ||
parse: val => Number(val) | ||
}, { | ||
command: '--terminal [string]', | ||
description: 'Launches the Metro Bundler in a new window using the specified terminal path.', | ||
default: (0, _cliTools().getDefaultUserTerminal)() | ||
}] | ||
}; | ||
exports.default = _default; |
@@ -37,2 +37,3 @@ "use strict"; | ||
* @format | ||
* | ||
*/ | ||
@@ -39,0 +40,0 @@ function findPodfilePath(projectFolder) { |
@@ -37,2 +37,3 @@ "use strict"; | ||
* @format | ||
* | ||
*/ | ||
@@ -39,0 +40,0 @@ function findPodspecName(folder) { |
@@ -37,2 +37,3 @@ "use strict"; | ||
* @format | ||
* | ||
*/ | ||
@@ -39,0 +40,0 @@ |
@@ -34,2 +34,3 @@ "use strict"; | ||
* @format | ||
* | ||
*/ | ||
@@ -55,2 +56,6 @@ | ||
function projectConfig(folder, userConfig) { | ||
if (!userConfig) { | ||
return; | ||
} | ||
const project = userConfig.project || (0, _findProject.default)(folder); | ||
@@ -57,0 +62,0 @@ /** |
@@ -24,3 +24,3 @@ "use strict"; | ||
for (let i = firstTargetLine, len = podLines.length; i < len; i++) { | ||
for (let i = firstTargetLine; i < podLines.length - 1; i++) { | ||
const matchNextConstruct = podLines[i].match(nextTarget) || podLines[i].match(functionDefinition); | ||
@@ -27,0 +27,0 @@ const matchEnd = podLines[i].match(endOfCurrentTarget); |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.default = findMarkedLinesInPodfile; | ||
exports.MARKER_TEXT = void 0; | ||
@@ -18,2 +19,3 @@ /** | ||
const MARKER_TEXT = '# Add new pods below this line'; | ||
exports.MARKER_TEXT = MARKER_TEXT; | ||
@@ -20,0 +22,0 @@ function findMarkedLinesInPodfile(podLines) { |
@@ -8,2 +8,22 @@ "use strict"; | ||
function _chalk() { | ||
const data = _interopRequireDefault(require("chalk")); | ||
_chalk = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _cliTools() { | ||
const data = require("@react-native-community/cli-tools"); | ||
_cliTools = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _readPodfile = _interopRequireDefault(require("./readPodfile")); | ||
@@ -15,3 +35,3 @@ | ||
var _findMarkedLinesInPodfile = _interopRequireDefault(require("./findMarkedLinesInPodfile")); | ||
var _findMarkedLinesInPodfile = _interopRequireWildcard(require("./findMarkedLinesInPodfile")); | ||
@@ -22,2 +42,4 @@ var _addPodEntry = _interopRequireDefault(require("./addPodEntry")); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -50,3 +72,15 @@ | ||
const firstTargetLined = (0, _findPodTargetLine.default)(podLines, projectName); | ||
if (firstTargetLined === null) { | ||
throw new (_cliTools().CLIError)((0, _cliTools().inlineString)(` | ||
We couldn't find a target to add a CocoaPods dependency. | ||
Make sure that you have a "${_chalk().default.dim(`target '${projectName.replace('.xcodeproj', '')}' do`)}" line in your Podfile. | ||
Alternatively, include "${_chalk().default.dim(_findMarkedLinesInPodfile.MARKER_TEXT)}" in a Podfile where we should add | ||
linked dependencies. | ||
`)); | ||
} | ||
return (0, _findLineToAddPod.default)(podLines, firstTargetLined); | ||
} |
@@ -27,2 +27,3 @@ "use strict"; | ||
* @format | ||
* | ||
*/ | ||
@@ -29,0 +30,0 @@ |
{ | ||
"name": "@react-native-community/cli-platform-ios", | ||
"version": "2.0.0-alpha.6", | ||
"version": "2.0.0-alpha.7", | ||
"main": "build/index.js", | ||
"dependencies": { | ||
"@react-native-community/cli-tools": "^2.0.0-alpha.6", | ||
"@react-native-community/cli-tools": "^2.0.0-alpha.7", | ||
"chalk": "^1.1.1", | ||
"xcode": "^2.0.0" | ||
}, | ||
"gitHead": "0a049714b061979abd7f9635f5f5fe784abf5668" | ||
"files": [ | ||
"build" | ||
], | ||
"gitHead": "60606efd56da6065d339100e42968c25b4dad182" | ||
} |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
15
2
86311
57
2431