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

fix: init uses yarn assuming version > 1.x #2329

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

blakef
Copy link
Contributor

@blakef blakef commented Mar 15, 2024

Summary:

Checks that we're using yarn > 1.x when calling yarn set which isn't supported [1] but is for later versions [2]. This also updated the E2E test to vary depending on whether yarn 1 or 3 is running.

[1] https://classic.yarnpkg.com/en/docs/cli/set
[2] https://yarnpkg.com/cli/set/version

Test Plan:

Ran against earlier version of yarn where I hit this.

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@blakef blakef requested review from adamTrz and thymikee as code owners March 15, 2024 15:43
@blakef blakef force-pushed the fix-init-yarn-legacy branch 2 times, most recently from 4f84ea8 to 6dd1ff8 Compare March 18, 2024 10:45

const yarnConfigFiles: string[] = [];
if (yarnVersion.major >= 3) {
yarnConfigFiles.push('.yarnrc.yml', '.yarn');
Copy link
Contributor Author

@blakef blakef Mar 18, 2024

Choose a reason for hiding this comment

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

@szymonrybczak these were added in #2134, which seem to cause issues with the test for me locally and on CI. If I toggle on the version this now seems fine, but I've no way to validate that locally it works for Yarn 3.

@blakef blakef requested a review from cortinico as a code owner March 18, 2024 13:40
@blakef blakef force-pushed the fix-init-yarn-legacy branch 5 times, most recently from 6c8ceaf to 2e72bec Compare March 19, 2024 09:36
args: string[] | undefined,
) {
if (!options.expectedFailure && result.code !== 0) {
if (!options.expectedFailure && result.exitCode !== 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was spamming the logs with false positives on the CI E2E tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know that some time ago we hit the issue where commands were failing and execa where reporting status codes as undefined, hopefully this change will catch all situations when there's a failure.

More details: #2152

@@ -11,7 +11,7 @@ import path from 'path';
import {unixifyPaths} from '@react-native-community/cli-tools';

export default function findManifest(folder: string) {
let manifestPaths = glob.sync(path.join('**', 'AndroidManifest.xml'), {
let manifestPaths = glob.sync('**/AndroidManifest.xml', {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fast-glob only wants paths expressed as forward slashes, so we want the opposite behaviour. This was causing failures on the Windows E2E tests.

@cortinico cortinico requested a review from szymonrybczak March 19, 2024 13:33
@blakef blakef force-pushed the fix-init-yarn-legacy branch 4 times, most recently from 7e09287 to e00e5b0 Compare March 20, 2024 12:27
- Checks that we're using yarn > 1.x when calling `yarn set` which isn't
supported [1] but is for later versions [2].
- Update tests to support
environment change differences between yarn 1.x & 3.x.
- Fix glob.sync to only use forward slashes.

[1] https://classic.yarnpkg.com/en/docs/cli/set
[2] https://yarnpkg.com/cli/set/version
[3] https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows
@blakef blakef force-pushed the fix-init-yarn-legacy branch from e00e5b0 to 6f95dc4 Compare March 20, 2024 13:23
Copy link
Collaborator

@szymonrybczak szymonrybczak left a comment

Choose a reason for hiding this comment

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

Thank you!

@blakef blakef merged commit 97a19b9 into react-native-community:main Mar 20, 2024
10 checks passed
@blakef blakef deleted the fix-init-yarn-legacy branch March 20, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants