question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bgotinkcommented, Feb 1, 2020

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 a yarnw file and falls back to the global yarn command if not found.

0reactions
merceyzcommented, Jan 2, 2021

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>

Read more comments on GitHub >

github_iconTop Results From Across the Web

wrapped | Yarn - Package Manager
Low-level wrapper to provide a consistent interface for sync, async, promises, and generator functions. Works with node.js and in the browser.
Read more >
Yarn Wrapper - Etsy
Check out our yarn wrapper selection for the very best in unique or custom, handmade pieces from our shops.
Read more >
Feature Pattern of the Week - Pure Happiness
The wrap is knit in Cascade Cantata, a light & soft yarn with a unique structure. Ideal for textured stitches, the yarn is...
Read more >
Cascade Yarns C290 Catrina Cabled Wrap (Free) at WEBS
Crocheted in Ecological Wool, the wrap works up quickly and features ribbing on the edges and cables down the center. Wear it loose...
Read more >
WRAP YARN TECHNOLOGY - UPCommons
different types of wrap yarns. For this reason, it has been tried to develop a prototype able to deal with some particular features...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found