Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function getDependenciesFromPodfileLock(
podfileLockPath: string,
) {
logger.debug(`Reading ${podfileLockPath}`);
let fileContent;
try {
fileContent = fs.readFileSync(podfileLockPath, 'utf8');
} catch (err) {
logger.error(
`Could not find "Podfile.lock" at ${chalk.dim(
podfileLockPath,
)}. Did you run "${chalk.bold('pod install')}" in iOS directory?`,
);
return [];
}
// Previous portions of the lock file could be invalid yaml.
// Only parse parts that are valid
const tail = fileContent.split(CHECKSUM_KEY).slice(1);
const checksumTail = CHECKSUM_KEY + tail;
return Object.keys(safeLoad(checksumTail)[CHECKSUM_KEY] || {});
}
encoding: 'utf8',
}),
);
if (devices.length === 0) {
return logger.error('No iOS devices connected.');
}
const selectedDevice = matchingDevice(devices, device, udid);
if (selectedDevice) {
return runOnDevice(selectedDevice, scheme, xcodeProject, args);
}
if (device) {
return logger.error(
`Could not find a device named: "${chalk.bold(
String(device),
)}". ${printFoundDevices(devices)}`,
);
}
if (udid) {
return logger.error(
`Could not find a device with udid: "${chalk.bold(
udid,
)}". ${printFoundDevices(devices)}`,
);
}
}
currentVersion: string,
newVersion: string,
config: Config,
) => {
let patch;
logger.info(`Fetching diff between v${currentVersion} and v${newVersion}...`);
try {
const {data} = await fetch(
`${rawDiffUrl}/${currentVersion}..${newVersion}.diff`,
);
patch = data;
} catch (error) {
logger.error(error.message);
logger.error(
`Failed to fetch diff for react-native@${newVersion}. Maybe it's not released yet?`,
);
logger.info(
`For available releases to diff see: ${chalk.underline.dim(
'https://github.com/react-native-community/rn-diff-purge#diff-table-full-table-here',
)}`,
);
return null;
}
let patchWithRenamedProjects = patch;
Object.keys(config.project).forEach(platform => {
if (!config.project[platform]) {
return;
async function installCocoaPods(loader: ora.Ora) {
loader.stop();
const {installMethod} = await promptCocoaPodsInstallationQuestion();
if (installMethod === 'gem') {
loader.start('Installing CocoaPods');
try {
await installCocoaPodsWithGem();
return loader.succeed();
} catch (error) {
loader.fail();
logger.error(error.stderr);
throw new Error(
`An error occured while trying to install CocoaPods, which is required by this template.\nPlease try again manually: sudo gem install cocoapods.\nCocoaPods documentation: ${chalk.dim.underline(
'https://cocoapods.org/',
)}`,
);
}
}
if (installMethod === 'homebrew') {
return await brewInstall({
pkg: 'cocoapods',
label: 'Installing CocoaPods',
loader,
});
}
adbPath: string,
) {
const devices = adb.getDevices(adbPath);
const {deviceId} = args;
if (devices.length > 0 && deviceId) {
if (devices.indexOf(deviceId) !== -1) {
buildApk(gradlew);
installAndLaunchOnDevice(
args,
deviceId,
packageNameWithSuffix,
packageName,
adbPath,
);
} else {
logger.error(
`Could not find device with the id: "${deviceId}". Please choose one of the following:`,
...devices,
);
}
} else {
logger.error('No Android devices connected.');
}
}
exec(command, function(error) {
if (error !== null) {
logger.error('Error while starting custom debugger:', error.stack || '');
}
});
}
const info = async function getInfo(_argv: Array, ctx: Config) {
try {
logger.info('Fetching system and libraries information...');
const output = await envinfo.run({
System: ['OS', 'CPU', 'Memory', 'Shell'],
Binaries: ['Node', 'Yarn', 'npm', 'Watchman'],
IDEs: ['Xcode', 'Android Studio'],
SDKs: ['iOS SDK', 'Android SDK'],
npmPackages: ['react', 'react-native', '@react-native-community/cli'],
npmGlobalPackages: '*react-native*',
});
logger.log(output.trim());
} catch (err) {
logger.error(`Unable to print environment info.\n${err}`);
} finally {
await releaseChecker(ctx.root);
}
};
)
.trim();
logger.info(`Launching "${chalk.bold(bundleID)}"`);
const result = child_process.spawnSync('xcrun', [
'simctl',
'launch',
selectedSimulator.udid,
bundleID,
]);
if (result.status === 0) {
logger.success('Successfully launched the app on the simulator');
} else {
logger.error('Failed to launch the app on simulator', result.stderr);
}
}
);
const {device, udid} = args;
if (!device && !udid) {
return runOnSimulator(xcodeProject, scheme, args);
}
const devices = parseIOSDevicesList(
child_process.execFileSync('xcrun', ['instruments', '-s'], {
encoding: 'utf8',
}),
);
if (devices.length === 0) {
return logger.error('No iOS devices connected.');
}
const selectedDevice = matchingDevice(devices, device, udid);
if (selectedDevice) {
return runOnDevice(selectedDevice, scheme, xcodeProject, args);
}
if (device) {
return logger.error(
`Could not find a device named: "${chalk.bold(
String(device),
)}". ${printFoundDevices(devices)}`,
);
}
};
if (clients.size === 0) {
notifier.notify({
title: 'React Native: No apps connected',
message:
`Sending '${message.method}' to all React Native apps ` +
'failed. Make sure your app is running in the simulator ' +
'or on a phone connected via USB.',
});
}
for (const [otherId, otherWs] of clients) {
if (otherId !== broadcasterId) {
try {
otherWs.send(JSON.stringify(forwarded));
} catch (e) {
logger.error(
`Failed to send broadcast to client: '${otherId}' ` +
`due to:\n ${e.toString()}`,
);
}
}
}
}