Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli] Make expo install work in any React Native app #2729

Merged
merged 1 commit into from
Sep 29, 2020
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This is the log of notable changes to Expo CLI and related packages.

### 🐛 Bug fixes

- Make `expo install` pass through to npm or yarn directly when running it in a bare React Native app without the expo package installed

## [Mon, 28 Sep 2020 12:02:49 -0700](https://github.com/expo/expo-cli/commit/19e206bdc3973aa5263a11999c9624ef3590b00d)

### 🛠 Breaking changes
Expand Down
32 changes: 22 additions & 10 deletions packages/expo-cli/src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,33 @@ async function installAsync(packages: string[], options: PackageManager.CreateFo
log,
});

// This ends up being confusing for people. If they're using expo install,
// let's just install the deps such that they work in the client even if
// it's a bare project.
const { exp, pkg } = ConfigUtils.getConfig(projectRoot, { skipSDKVersionRequirement: true });

// If using `expo install` in a project without the expo package even listed
// in package.json, just fall through to npm/yarn.
//
// if (workflow === 'bare') {
// return await packageManager.addAsync(...packages);
// }
if (!pkg.dependencies['expo']) {
return await packageManager.addAsync(...packages);
}

if (!exp.sdkVersion) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this has the side effect of improving the messaging in the weird edge case where maybe somebody 1) has expo pkg in pkg.json 2) has node_modules directory but 3) somehow we can't resolve the sdk version

log.addNewLineIfNone();
log.error(
`The ${log.chalk.bold(`expo`)} package was found in your ${log.chalk.bold(
`package.json`
)} but we couldn't resolve the Expo SDK version. Run ${log.chalk.bold(
`${packageManager.name.toLowerCase()} install`
)} and then try this command again.`
);
log.newLine();
process.exit(1);
return;
}

const { exp } = ConfigUtils.getConfig(projectRoot);
if (!Versions.gteSdkVersion(exp, '33.0.0')) {
log.addNewLineIfNone();
log.error(
`${log.chalk.bold(
`expo install`
)} is only available for managed apps using Expo SDK version 33 or higher.`
`${log.chalk.bold(`expo install`)} is only available for Expo SDK version 33 or higher.`
);
log.newLine();
log(log.chalk.cyan(`Current version: ${log.chalk.bold(exp.sdkVersion)}`));
Expand Down