-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cli] Add dependency exclusion to
npx expo install
(expo#22736)
# Why Fulfills https://linear.app/expo/issue/ENG-8564/add-dependency-exclusion-to-npx-expo-install. Developers will be able to suppress warnings from `npx expo install --check` via a package.json config, and thus suppress doctor warnings when they intentionally choose to install a different version, especially when using dev builds and not needing to stick to the Expo Go- bundled version. # How `npx expo install --check|fix` reads from `expo.install.exclude` if it's available, and, if one of the packages it thinks it should fix is in that list, it will skip asking/ fixing it. If you run `EXPO_DEBUG=1 npx expo install --check`, the packages whose checks were actually skipped will be listed in debug output; otherwise there are no warnings or messages about the excluded packages. The package.json configuration verbiage is intended to be similar to the [autolinking config](https://docs.expo.dev/modules/autolinking/#exclude). ~~It also seemed appropriate that `npx expo install` should behave differently if you try to install an excluded package, so someone doesn't come along and write over a version that another developer determined was good and thus applied the override for. Currently, it aborts if any of the packages are in the exclusion list. I could see doing a warning and skipping the affected packages instead, but the command outright failing is pretty hard to miss.~~ `npx expo install` now installs excluded packages with the latest version, just like a package without a specified native version. It will add a note describing what it's doing and why. # Test Plan - [x] test without `expo.install.exclude` (works the same) - [x] test with empty exclusion list (works the same) - [x] test with exclusions that aren't actual dependencies (works the same) - [x] test `expo install --fix|check` when excluding an actual dependency (skips it) - [x] test with `EXPO_DEBUG=1` (lists excluded packages) - [x] test `expo install [package]` with exclusions (installs latest with notes) - [x] test `expo install [package]` without exclusions (proceeds as it normally does) ## Output `npx expo install --check`, showing note that it is skipping checking packages in the exclude list: <img width="884" alt="image" src="https://github.com/expo/expo/assets/8053974/30cef729-af18-44cb-98ef-11fc9729ae3d"> Additional debug output for `EXPO_DEBUG=1 npx expo install --check`: <img width="904" alt="image" src="https://github.com/expo/expo/assets/8053974/9096a939-066c-431b-a467-6d3d70ef448d"> `expo install <package>` with exclusions: <img width="932" alt="image" src="https://github.com/expo/expo/assets/8053974/d51e9e5a-cc59-4aa4-9cb6-4a2294b01ccc"> # Checklist <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [x] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [x] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [x] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). --------- Co-authored-by: Brent Vatne <[email protected]>
- Loading branch information
1 parent
b9e44d7
commit 6fb32dd
Showing
11 changed files
with
312 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ describe(getVersionedPackagesAsync, () => { | |
const { packages, messages } = await getVersionedPackagesAsync('/', { | ||
sdkVersion: '1.0.0', | ||
packages: ['@expo/vector-icons', 'react@next', 'expo-camera', 'uuid@^3.4.0'], | ||
pkg: {}, | ||
}); | ||
|
||
expect(packages).toEqual([ | ||
|
@@ -49,6 +50,93 @@ describe(getVersionedPackagesAsync, () => { | |
|
||
expect(messages).toEqual(['2 SDK 1.0.0 compatible native modules', '2 other packages']); | ||
}); | ||
|
||
it('should not specify versions for excluded packages', async () => { | ||
asMock(getVersionedNativeModulesAsync).mockResolvedValueOnce({}); | ||
asMock(getVersionsAsync).mockResolvedValueOnce({ | ||
sdkVersions: { | ||
'1.0.0': { | ||
relatedPackages: { | ||
'@expo/vector-icons': '3.0.0', | ||
'react-native': 'default', | ||
react: 'default', | ||
'react-dom': 'default', | ||
'expo-sms': 'default', | ||
}, | ||
facebookReactVersion: 'facebook-react', | ||
facebookReactNativeVersion: 'facebook-rn', | ||
}, | ||
}, | ||
} as any); | ||
const { packages, messages, excludedNativeModules } = await getVersionedPackagesAsync('/', { | ||
sdkVersion: '1.0.0', | ||
packages: ['@expo/vector-icons', 'react@next', 'expo-camera', 'uuid@^3.4.0'], | ||
pkg: { | ||
expo: { | ||
install: { | ||
exclude: ['@expo/vector-icons'], | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(packages).toEqual([ | ||
// Excluded | ||
'@expo/vector-icons', | ||
// Custom | ||
'react@facebook-react', | ||
// Passthrough | ||
'expo-camera', | ||
'uuid@^3.4.0', | ||
]); | ||
|
||
expect(messages).toEqual(['1 SDK 1.0.0 compatible native module', '3 other packages']); | ||
expect(excludedNativeModules).toEqual([ | ||
{ name: '@expo/vector-icons', bundledNativeVersion: '3.0.0' }, | ||
]); | ||
}); | ||
|
||
it('should not list packages in expo.install.exclude that do not have a bundledNativeVersion', async () => { | ||
asMock(getVersionedNativeModulesAsync).mockResolvedValueOnce({}); | ||
asMock(getVersionsAsync).mockResolvedValueOnce({ | ||
sdkVersions: { | ||
'1.0.0': { | ||
relatedPackages: { | ||
'@expo/vector-icons': '3.0.0', | ||
'react-native': 'default', | ||
react: 'default', | ||
'react-dom': 'default', | ||
'expo-sms': 'default', | ||
}, | ||
facebookReactVersion: 'facebook-react', | ||
facebookReactNativeVersion: 'facebook-rn', | ||
}, | ||
}, | ||
} as any); | ||
const { packages, messages, excludedNativeModules } = await getVersionedPackagesAsync('/', { | ||
sdkVersion: '1.0.0', | ||
packages: ['@expo/vector-icons', 'react@next', 'expo-camera', 'uuid@^3.4.0'], | ||
pkg: { | ||
expo: { | ||
install: { | ||
exclude: ['expo-camera'], | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(packages).toEqual([ | ||
// Custom | ||
'@expo/[email protected]', | ||
'react@facebook-react', | ||
// Passthrough | ||
'expo-camera', // but also excluded | ||
'uuid@^3.4.0', | ||
]); | ||
|
||
expect(messages).toEqual(['2 SDK 1.0.0 compatible native modules', '2 other packages']); | ||
expect(excludedNativeModules).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe(getOperationLog, () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.