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

Renames yarnrc -> yarnrc.yml #244

Merged
merged 8 commits into from Jun 21, 2019
Merged

Renames yarnrc -> yarnrc.yml #244

merged 8 commits into from Jun 21, 2019

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Jun 21, 2019

Motivation

We previously were trying to make one file work for both tools. It was causing a lot of confusion, and it made the code and migrations significantly more complex (in particular we were relying on weak heuristics to figure out which parser to user).

Effects

  • Berry only look for .yarnrc.yml files; files named .yarnrc are completely ignored.
  • The yarnrc keys now must be defined in camelCase or they won't be picked up.
  • I've updated the documentation accordingly.

Migration plan

  • People with Yarn 1.17.2+ in their global path (still a RC) won't have anything to do; I've published Adds basic support for .yamlrc.yml (yarnPath only, v2) yarn#7350 which adds a basic support for reading .yarnrc.yml files if possible (it will only use the yarnPath settings, and ignore everything else).

  • People with Yarn 2.0.0+ in their global path won't have anything to do as well; they'll just have to set yarnPath from their .yarnrc.yml file instead of .yarnrc (just like people using 1.17.2+) and things will work as expected.

  • People that don't have Yarn 1.17.2+ in their global path (which I assume will be a lot of people) will need to keep the yarn-path settings inside a .yarnrc file.

  • Teams that use a combination of pre-1.17.2 and 2.x+ global binaries will have to either set both the yarn-path and yarnPath settings in their respective files, or use the branched binary hack (cf below) to recommend pre-1.17.2 users to upgrade to 1.17.2+.

Branched binary hack

Some problems may arise when working on a v2 project: someone with a pre-1.17.2 global binary might fail to pick up the yarnPath configuration from the .yarnrc.yml. Yarn would then disregard the configuration and use the global one instead of whatever has been configured in the repository. Fortunately, this can be avoided: we can use both the .yarnrc and the .yarnrc.yml!

Maybe even more interesting, by setting the yarn-path settings in the .yarnrc file to a file that prints an error message, you can ensure that engineers in such situations will quickly find out what's wrong, and learn how to fix it. For an example of what I mean, look for scripts/warn-about-yarn1.js in this PR - this script will be the one called by anyone running pre-1.17.2 global yarns.

Extra notes

  • I decided to go with .yml instead of .yaml as that's what the industry uses. Although the official recommendation is .yaml, in practice it's not applied this way.

@deini
Copy link
Member

deini commented Jun 21, 2019

Looks like the README.md and Configuration.ts are still referencing .yarnrc in comments.

@arcanis arcanis merged commit f1b67c4 into master Jun 21, 2019
@arcanis arcanis deleted the rc-refactoring branch June 21, 2019 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants