microsoft / react-native-macos

A framework for building native macOS apps with React.
https://microsoft.github.io/react-native-windows/
MIT License
3.45k stars 132 forks source link

fix(cli): initialising in projects using Yarn v3 #2025

Closed szymonrybczak closed 7 months ago

szymonrybczak commented 8 months ago

Please select one of the following

Summary:

Recently in React Native Community CLI we added bumping Yarn version in every new project created to Yarn v3 (PR for more context). And In Yarn v3 flag -s doesn't exists anymore, so the react-native-macos-init tool won't work.
CleanShot 2024-01-09 at 17 29 31 I've replaced usage of -s with --silent flag. Also this change is backward compatible, since Yarn v1 support --silent flag.

CleanShot 2024-01-09 at 17 29 47

Changelog:

[GENERAL] [FIXED] - Initialising react-native-macos in project using Yarn v3 with react-native-macos-init

Test Plan:

  1. Create new project with npx react-native@latest init and bump Yarn version to 3 (we didn't released changes with bumping version by default yet.
  2. Try running react-native-macos-init
szymonrybczak commented 8 months ago

cc @Saadnajmi @tido64

Saadnajmi commented 8 months ago

cc @Saadnajmi @tido64

I was actually thinking of moving the repo to yarn v4 (I guess 3 for the template project works though). Do either of you see any issue with that?

szymonrybczak commented 8 months ago

Do either of you see any issue with that?

Just make sure to properly set nodeLinker value in the Yarn config file, I think that's the most important thing.

Saadnajmi commented 7 months ago

So this PR is ready to go, but to release a new version of react-native-macos-init, we use beachball, which works by generating a change file (aka, running yarn change). For some reason, that is not working, so if I merge this as is, we won't get a new package. Bear with me while I sort that out!

Saadnajmi commented 7 months ago

@szymonrybczak Could you run yarn change --type patch --message 'fix(cli): initialising in projects using Yarn v3' in packages/react-native-macos-init to hopefully force a change file to show up and get added as a commit?

szymonrybczak commented 7 months ago

hey @Saadnajmi, so the command that you sent is not working with current setup. I checked why, and it's because the root package.json has: https://github.com/microsoft/react-native-macos/blob/740732e06c6597e20e9a6824d3cca1f9e99d8bed/package.json#L111-L113 and packages/react-native-macos-init has the same value, so: beachball.shouldPublish=false. After tweaking this value in packages/react-native-macos-init/package.json to true the change file is correctly added and generated.

diff --git a/change/react-native-macos-init-cf2af331-a6c9-40dd-a2f2-f599609799bd.json b/change/react-native-macos-init-cf2af331-a6c9-40dd-a2f2-f599609799bd.json
new file mode 100644
index 0000000000..1ee6fb29f3
--- /dev/null
+++ b/change/react-native-macos-init-cf2af331-a6c9-40dd-a2f2-f599609799bd.json
@@ -0,0 +1,7 @@
+{
+  "type": "patch",
+  "comment": "fix(cli): initialising in projects using Yarn v3",
+  "packageName": "react-native-macos-init",
+  "email": "szymon.rybczak@gmail.com",
+  "dependentChangeType": "patch"
+}

Do you think we can change this value for this package? and should we do it in under this PR or in the separate?

Saadnajmi commented 7 months ago

hey @Saadnajmi, so the command that you sent is not working with current setup. I checked why, and it's because the root package.json has:

https://github.com/microsoft/react-native-macos/blob/740732e06c6597e20e9a6824d3cca1f9e99d8bed/package.json#L111-L113

and packages/react-native-macos-init has the same value, so: beachball.shouldPublish=false. After tweaking this value in packages/react-native-macos-init/package.json to true the change file is correctly added and generated.

diff --git a/change/react-native-macos-init-cf2af331-a6c9-40dd-a2f2-f599609799bd.json b/change/react-native-macos-init-cf2af331-a6c9-40dd-a2f2-f599609799bd.json
new file mode 100644
index 0000000000..1ee6fb29f3
--- /dev/null
+++ b/change/react-native-macos-init-cf2af331-a6c9-40dd-a2f2-f599609799bd.json
@@ -0,0 +1,7 @@
+{
+  "type": "patch",
+  "comment": "fix(cli): initialising in projects using Yarn v3",
+  "packageName": "react-native-macos-init",
+  "email": "szymon.rybczak@gmail.com",
+  "dependentChangeType": "patch"
+}

Do you think we can change this value for this package? and should we do it in under this PR or in the separate?

derp, I missed that in the react-native-macos-init package.json. Yes, please set it to true in this PR and then I'll merge :)

szymonrybczak commented 7 months ago

derp, I missed that in the react-native-macos-init package.json.

The thing is that it wasn't specified! I assume that is getting value from the root's package.json πŸ˜…

szymonrybczak commented 7 months ago

@microsoft-github-policy-service agree company="Callstack"

szymonrybczak commented 7 months ago

@microsoft-github-policy-service agree

Saadnajmi commented 7 months ago

@szymonrybczak Looks like there are other issues I'll still have to investigate. We haven't had to release a new version of react-native-macos-init since it was created really, so I'm realizing now the CI to publish stuff as issues πŸ˜…. I'll try to make that fix and then update back here. Meanwhile, I think you can undo your last commit and I'll merge the PR as is.

szymonrybczak commented 7 months ago

@Saadnajmi ah, okay. I've removed the last commit. Should be good to merge.

Saadnajmi commented 7 months ago

@Saadnajmi ah, okay. I've removed the last commit. Should be good to merge.

Sorry, last two commits. Looks like adding the change file is what causes the break

seanstrom commented 3 months ago

Has the the NPM package been updated for this script? If not could someone publish an update please πŸ™

cc @szymonrybczak @Saadnajmi

Saadnajmi commented 3 months ago

@seanstrom I think not, I can look into it