Closed mmkal closed 9 months ago
Ah, I should have checked pull requests as well as issues: https://github.com/sindresorhus/np/pull/667
That one is the smaller, backwards compatible, but messier change, adding --pnpm
/--no-pnpm
args etc.
I guess that PR going quiet isn't a good sign in terms of maintenance, but if this change would be accepted, I'd be happy to maintain it going forward.
This looks like a good start to me. I agree with the general direction. 👍
// @transitive-bullshit @mifi
I like these simplifications, and can help to test the yarn berry functionality once ready
Tests now passing for me locally (with the 1 known failure).
Edit: oops, forgot to run xo. Will do soon, but this is ready for review if you're willing to ignore missing semicolon etc.
np could be stricter about package managers. We could say you can only resolve a package manager based on the packageManager field, no looking at lock files. I think that would simplify things, and still make it easy for anyone who wanted to override with a specific behaviour to get what they want. But that would be a more significant breaking change, so I didn't do it for now.
Open an issue about this. I think we could do this in a couple of years when the packageManager
field is more commonly used.
Tried this out for a bit now. This seems to work well for me.
@mifi I believe this is ready for review.
np
could be stricter about package managers. We could say you can only resolve a package manager based on thepackageManager
field, no looking at lock files.
I think automatically determining the package manager via the lockfile makes np
that much nicer to use - it "just works."
I think we could do this in a couple of years when the
packageManager
field is more commonly used.
That's also fair.
Sorry for taking so long to review, this all looks really good to me as well. Thanks for putting this together. I use Yarn so I can give it a try for publishing with it.
This worked great with Yarn v1.
Thanks for the feedback - will try to incorporate it this week.
@tommy-mitchell pushed your suggestions minus the () => enabled
-> enabled
one.
@mifi I squashed in https://github.com/mmkal/np/pull/1 - thank you v much. I like the installCommandNoLockfile
better than what I had before. I made some changes in https://github.com/sindresorhus/np/pull/730/commits/3163835537d8b20290c0a77e80f422c42d153da6 though:
publishCli
and some "prefix args", I made publishCommand
a function which returns a command, similar to versionCommand
.
publish
cli arg, it will be possible to handle that by doing publishCommand: args => ['yarn', remapAllTheArgsWithArbitraryComplexRules(args)]
.PackageManagerConfig
and let downstream users define their own configs or something).@mifi would you be able to test on yarn berry one more time 😬? I just successfully did with pnpm again.
@mmkal Looks good. Thanks for working on this 👍
Fixes #729
~This is starting out as a draft, because it ended up being a fairly big change. If it's unwanted, I can scrap this and do a smaller change that adds pnpm support similarly to yarn, but it was already very messy, so I thought I'd clean up.~
In the end by adding pnpm support there are net ~50 lines of code fewer, and one dependency dropped.
User-facing changes:
--package-manager
- this acts like the packageManager field in package.json.np
will default to reading package.json, and look for lockfiles to determine the best package manager as a last resort.--yarn
(and--no-yarn
). This is a breaking change. The functionality is replaced by--package-manager
(if you want yarn, instead of--yarn
set"packageManager": "yarn@1.7.0"
in package.json or--package-manager yarn@1.7.0
via CLI. If you don't want yarn, set"packageManager": "npm@9.0.0"
or whatever in package.json)np
now doesnpm run test
/yarn run test
/pnpm run test
instead ofnpm test
etc.Outside of the above, I tried as hard as I could do make the logic identical as far as the user is concerned.
Implementation:
package-manager
subfolder insource/
Potential simplifications:
np
could be stricter about package managers. We could say you can only resolve a package manager based on thepackageManager
field, no looking at lock files. I think that would simplify things, and still make it easy for anyone who wanted to override with a specific behaviour to get what they want. But that would be a more significant breaking change, so I didn't do it for now.Other stuff:
cli-implementation.js
and exported functions. It doesn't affect the API surface of this package but is potentially a bit... weird.main
, though.~I use
np
regularly and would happy to join as a maintainer if that'd be helpful.Testing:
npm
with this to make sure it wasn't regressing existing functionalitypnpm
, although I saw an issue with the bumped package.json not being committed. This happened with np v9.2.0 too, though, so I think it's a separate issueFYI @sindresorhus @zkochan