Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function install(args: Array, ctx: Config): Promise {
const name = args[0];
logger.info(`Installing "${name}"...`);
await PackageManager.install([name], {root: ctx.root});
// Reload configuration to see newly installed dependency
const newConfig = loadConfig();
logger.info(`Linking "${name}"...`);
await link.func([name], newConfig, {platforms: undefined});
logger.success(`Successfully installed and linked "${name}"`);
}
if (!newVersion) {
return;
}
const patch = await getPatch(currentVersion, newVersion, ctx);
if (patch === null) {
return;
}
if (patch === '') {
logger.info('Diff has no changes to apply, proceeding further');
await installDeps(newVersion);
await installCocoaPodsDeps(projectDir, thirdPartyIOSDeps);
logger.success(
`Upgraded React Native to v${newVersion} 🎉. Now you can review and commit the changes`,
);
return;
}
let patchSuccess;
try {
fs.writeFileSync(tmpPatchFile, patch);
patchSuccess = await applyPatch(currentVersion, newVersion, tmpPatchFile);
} catch (error) {
throw new Error(error.stderr || error);
} finally {
try {
fs.unlinkSync(tmpPatchFile);
} catch (e) {
// ignore
const iosDeployOutput = child_process.spawnSync(
'ios-deploy',
iosDeployInstallArgs,
{encoding: 'utf8'},
);
if (iosDeployOutput.error) {
throw new CLIError(
`Failed to install the app on the device. We've encountered an error in "ios-deploy" command: ${
iosDeployOutput.error.message
}`,
);
}
return logger.success('Installed the app on the device.');
}
['-c', 'Print:CFBundleIdentifier', path.join(appPath, 'Info.plist')],
{encoding: 'utf8'},
)
.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);
}
}
)}`,
);
throw new CLIError(
`Unknown package name "${chalk.bgRed.dim(
name,
)}". The package you are trying to uninstall is not present in your "package.json" dependencies.`,
);
}
logger.info(`Unlinking "${name}"...`);
await unlink.func([name], ctx, {});
logger.info(`Uninstalling "${name}"...`);
await PackageManager.uninstall([name], {root: ctx.root});
logger.success(`Successfully uninstalled and unlinked "${name}"`);
}
Object.keys(platforms || {}).forEach(platform => {
const linkConfig =
platforms[platform] &&
platforms[platform].linkConfig &&
platforms[platform].linkConfig();
if (!linkConfig || !linkConfig.copyAssets || !project[platform]) {
return;
}
logger.info(`Linking assets to ${platform} project`);
linkConfig.copyAssets(assets, project[platform]);
});
logger.success('Assets have been successfully linked to your project');
}