Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect which package manager to invoke #46

Open
jayvdb opened this issue Sep 19, 2018 · 5 comments
Open

Detect which package manager to invoke #46

jayvdb opened this issue Sep 19, 2018 · 5 comments

Comments

@jayvdb
Copy link

jayvdb commented Sep 19, 2018

https://github.com/pnpm/pnpm is almost a drop-in replacement for npm, and I am successfully using it with cordova-fetch by creating a symlink from npm to pnpm.

The flags used by cordova-fetch are also compatible with yarn, afaics, but I havent tested that. npm is also planning a new package manager on the horizon, https://github.com/npm/tink , which looks likely to support the same args.

@zkochan, creator of pnpm, has created https://github.com/zkochan/which-pm to do the detection, so it should be fairly easy to invoke the correct package manager, using the same flags.

@raphinesse
Copy link
Contributor

Please take a look at apache/cordova-cli#292. Especially @dpogue's and my comment towards the end of the discussion. In short: I do not think that this is feasible, the way cordova currently works.

If you are interested in more technical details, I can provide them. Thanks for taking the time to create this issue and providing some helpful links too.

@jayvdb
Copy link
Author

jayvdb commented Sep 21, 2018

Well, I just tried yarn for giggles, and found it did work with cordova@8 .
Im not discounting that you've fixed a lot of bugs by more tightly integrating with npm, but it shouldnt be hard to have similar integration with the other package managers. This train is coming.

I would question that tighter integration with npm solves anything, because there are a raft of differences between npm versions, and also massive changes in how npm works based on npm config variables, which are beyond your control unless cordova reads and understands the npm config, and possibly even override them, and also understands all reasonable npm versions, and how those config variables operate in each version -- usually a few are broken in any npm release.

Perhaps as an interim measure, cordova fetch at least checks which package manager is used, and fails early when it isnt npm, indicating that patches are welcome to support for other package managers, but those patches would need to pass the test suite, ensuring it is as supportable as npm.

@cmitz
Copy link

cmitz commented Nov 2, 2018

I think only supporting NPM because of tight coupling with that package manager is an indication that some plugins are not using package managers in a way the're supposed to. However, since I just started to try things with Cordova and because I don't know how things work you should take my comment with a grain of sailt.

Preferences aside, in the JavaScript community nobody expects not being able to swap NPM with Yarn, so I think that should be documented in the basic introductions like the "Get started": https://cordova.apache.org/

@marckassay
Copy link

Although 'spypkg' doesn't detect which package manager to use, its capable of parsing npm expressions to be mapped into yarn expressions. When installed and configured, in essence it intercepts execution, maps the expression and executes the modified expression.

@stalinkay
Copy link

stalinkay commented Apr 11, 2022

Ionic provides an elegant implementation of this in the form of ionic config set -g npmClient pnpm. See this issue for detail. The user should still have the liberty to choose their client of choice globally or per-project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants