[Feature] Yarn wrapper
See original GitHub issue- I’d be willing to implement this feature
- This feature can already be implemented through a plugin
Describe the user story
Recommended way to install yarn is yarn set version berry
. This command installs the required version of yarn in the .yarn/releases directory and set a path to it through .yarnrc.yml
. As I understand it, yarn classic will consider this setting and delegate each command to the downloaded yarn. In this case it would be nice to use project’s yarn directly without having to install yarn classic. This will make it easier for developers to start working with the project, and will also make it easier to set up CI, since only runtime in the form of NodeJs will be needed.
Describe the solution you’d like
After executing yarn set version berry
, a yarn wrapper is created in the root directory of the project. As a result, instead of running commands via the global yarn classic, you can use the wrapper which, by analogy with yarn classic, will delegate execution to yarn from .yarn/releases.
project directory:
project ├── .yarn │ └── releases │ └── yarn-rc.js ├── src │ └── ... ├── package.json ├── yarn.lock ├── yarnw ├── yarnw.bat
run wrapper:
./yarnw --version
./yarnw add [package] --dev
Describe the drawbacks of your solution
Additional files in the project directory. For Windows it is necessary to create a similar wrapper yarnw.bat
Additional context
This concept is quite widespread in the JVM ecosystem for package managers.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top GitHub Comments
I really like the idea of repositories that work standalone, without requiring any software that’s not available by default on a modern OS (i.e. a shell, curl, tar and other basic commands). The idea that you just need to clone and you’re ready to go—regardless of whether your system has yarn or even node installed—is powerful for contributors old and new.
That being said, I’m not sure if this belongs in yarn itself per se. This could be built as a plugin.
As to typing
yarn
vs./yarnw
… It’s not just a matter of typing those extra characters, it’s also the fact that this yarn wrapper is only present in one location, so you could end up having to run../../../yarnw add -D typescript
to install typescript in a workspace. On the other hand, you could write a function into your shells’s RC file that looks for ayarnw
file and falls back to the global yarn command if not found.Closing as the solution from @bgotink solves this request, but if you want to invoke v2 directly without the global yarn you can always use
node ./<path-to-yarn>