generator icon indicating copy to clipboard operation
generator copied to clipboard

Yarn support

Open tobymurray opened this issue 7 years ago • 8 comments

It looks like there is very little actually going on in this generator that's strictly NPM dependent - pretty much just npm install and the documentation. Thoughts about adding a flag (e.g. --yarn) to allow using Yarn instead?

tobymurray avatar Feb 25 '17 05:02 tobymurray

I mean, all this does is create a package.json file. I haven't used yarn before, but from my understanding, you just run yarn install, right? What would we change besides the docs, if anything? Maybe you'd be willing to put together a PR for what would need to be done for yarn support?

dougwilson avatar Feb 25 '17 05:02 dougwilson

It would be a tiny change functionally speaking - npm install would become yarn install and a yarn.lock file would be generated (which locks down the transitive dependencies).

I can do up a PR to flesh it out, the big thing for me is Yarn tends to be way faster (looking at you, CI tests that install the packages...).

tobymurray avatar Feb 25 '17 05:02 tobymurray

Well, we're not going to change the CI -- the CI needs to be the most common one. We can add an additional yarn to the CI, but all the current npm CI will need to stay. But the generator itself AFAIK never runs npm, so I'm still not sure what actually needs to change to support yarn, so a PR would help me understand, I suppose :)

dougwilson avatar Feb 25 '17 05:02 dougwilson

My mistake, I was simply confused. It's just the documentation, and it doesn't make sense to add a switch to change the documentation (especially for a less frequently used alternative). I was thinking npm install was invoked by the generator.

tobymurray avatar Feb 25 '17 06:02 tobymurray

So, I was just thinking, and perhaps there is something you can do, if you want (can re-open): perhaps the generator can see if there is a yarn command in the environment, and if so show the yarn install command in the output, otherwise npm. It seems to me that since yarn is not default, the presence of it would indicate the person probably wants to use it.

dougwilson avatar Feb 25 '17 06:02 dougwilson

True - I believe that's what they're doing over at the angular-cli (I think the relevant code is here). Definitely not an earth shattering change but it seems like a nice touch. To be clear, the change would be to use Yarn if its present in the environment, and use NPM otherwise?

tobymurray avatar Feb 25 '17 06:02 tobymurray

Yea, like in the block https://github.com/expressjs/generator/blob/master/bin/express#L117-L129 just like it detects cmd.exe that it could detect yarn and show the yarn commands.

dougwilson avatar Feb 25 '17 06:02 dougwilson

Sounds extremely doable. I'll give it a shot!

tobymurray avatar Feb 25 '17 06:02 tobymurray