RFC: use the currently used package manager from init#1909
RFC: use the currently used package manager from init#1909tadhglewis wants to merge 4 commits intomainfrom
Conversation
|
|
seems reasonable but i wonder if we should fall back to the old logic? |
|
@AaronMoat let me do some more digging. I'm not a huge fan of |
|
|
||
| const name = pkgSpecArr?.[0]; | ||
|
|
||
| const validpkgManger = packageManagerSchema.safeParse(name); |
| const [manifest, packageManagerConfig] = await Promise.all([ | ||
| getConsumerManifest(destinationDir), | ||
| detectPackageManager(destinationDir), | ||
| packageManagerFromUserAgent(process.env.npm_config_user_agent), |
There was a problem hiding this comment.
What happens if you install skuba locally then invoke its bin script directly?
There was a problem hiding this comment.
Sorry, to clarify I mean for global installs, which may be resolved via PATH and not via shim / the package manager binary. (Maybe it's fine to always pick the default package manager in these scenarios, but we should probably check that the logging looks reasonable at a minimum.)
It seems strange to use
detectPackageManagerwhich uses find-up to find the closest lock file as it means you could end up with the "wrong" manager during fresh installs.We can detect the package manager from the user agent. For example, if they use
pnpm dlx skuba init, it'll extract the pnpm user agent.One edge case is monorepos, this would use the current package manager which might differ from the monorepo package manager... But that should be okay?