Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add installPods to legacy init #386

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/cli/src/commands/init/initCompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import printRunInstructions from './printRunInstructions';
import {createProjectFromTemplate} from '../../tools/generator/templates';
import * as PackageManager from '../../tools/packageManager';
import {logger} from '@react-native-community/cli-tools';
import installPods from '../../tools/installPods';

/**
* Creates the template for a React Native project given the provided
Expand Down Expand Up @@ -76,6 +77,13 @@ async function generateProject(destinationRoot, newProjectName, options) {
]);

addJestToPackageJson(destinationRoot);

if (process.platform === 'darwin') {
logger.info('Installing required CocoaPods dependencies');

await installPods({projectName: newProjectName});
}

printRunInstructions(destinationRoot, newProjectName);
}

Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/tools/installPods.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function installPods({
loader,
}: {
projectName: string,
loader: typeof Ora,
loader?: typeof Ora,
}) {
try {
process.chdir('ios');
Expand All @@ -26,7 +26,9 @@ async function installPods({
try {
await commandExists('pod');
} catch (e) {
loader.stop();
if (loader) {
loader.stop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit ugly, but I guess there's nothing we can do about it!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could add "onInstallFailure" and "onInstallSuccess" callbacks and delegate to them to make it cleaner, but I don't care about it here. It's not that ugly provided it's a small helper used in 2 places, not a public API surface :)

}

const {shouldInstallCocoaPods} = await inquirer.prompt([
{
Expand Down Expand Up @@ -57,7 +59,9 @@ async function installPods({

// This only shows when `CocoaPods` is automatically installed,
// if it's already installed then we just show the `Installing dependencies` step
loader.start('Installing CocoaPods dependencies');
if (loader) {
loader.start('Installing CocoaPods dependencies');
}
}
}

Expand Down