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

feat(compat): add cordova support #1288

Closed
wants to merge 7 commits into from
Closed

feat(compat): add cordova support #1288

wants to merge 7 commits into from

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented May 3, 2020

What's the problem this PR addresses?

Cordova is currently hardcoded to run npm commands which makes using cordova with yarn a bit problematic. Getting them to detect which package manager to use has proven to not be happening any time soon. See apache/cordova-fetch#46 and apache/cordova-cli#292 (comment)

How did you fix it?

Implement a proxy that translates the required npm commands to yarn commands

@merceyz merceyz force-pushed the cordova-compat branch 2 times, most recently from c415954 to 8e22e7d Compare May 3, 2020 21:03
@merceyz merceyz marked this pull request as ready for review May 3, 2020 21:09
@andypalmer
Copy link

This PR looks like it would solve a problem that I'm having 🎉 , but it also looks like it could be distributed as an external plugin rather than being incorporated directly into berry.

AFAICT, this would be a useful plugin wherever any bin files reference npm directly (not just for cordova)

Comment on lines 10 to 16
//#region Ignored
@Command.Boolean('--save')
save!: boolean;

@Command.Boolean('-P,--save-prod,--production')
production!: boolean;
//#endregion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not this (or to type them as ?: boolean, at worst)?

Suggested change
//#region Ignored
@Command.Boolean('--save')
save!: boolean;
@Command.Boolean('-P,--save-prod,--production')
production!: boolean;
//#endregion
@Command.Boolean('--save')
save: boolean = false;
@Command.Boolean('-P,--save-prod,--production')
production: boolean = false;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yarn has no version of these flags so their value doesn't really matter, however if it was to be set, the default would be true. But they're just ignored, so I marked them as such

const descriptor = workspace.dependencies.get(ident.identHash)!;
const resolution = project.storedResolutions.get(descriptor.descriptorHash)!;
const pkg = project.storedPackages.get(resolution)!;
console.log(`+ ${pkg.name}@${pkg.version}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn that ain't pretty :( Not sure it should be in the default compat plugin after all ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not pretty. On the bright side, it's only printed when someone runs yarn npm install foo (npm can be replaced with something else to hide it even more, open for suggestions here). Should probably make the command hidden as well.

@bgotink
Copy link
Member

bgotink commented May 8, 2020

I'm pro putting this in a separate plugin to make this opt-in.
These commands are very brittle, if a new version of cordova parses the npm output slightly differently we will get issues. Same if they change the npm commands they're executing.
Having a separate plugin that can be released separately from berry itself will help a lot in those cases.

I would definitely propose using a separate name for the plugin commands, especially given the existence of yarn npm info and yarn npm publish. Something like yarn npm-compat install perhaps? Or yarn npm-shim-because-this-is-the-darkest-timeline install if we're feeling quirky.

@arcanis
Copy link
Member

arcanis commented Jun 15, 2020

I'll be with @bgotink here and say that the complexity would be a better fit as a standalone contrib plugin (perhaps not even inside our own repository).

@arcanis arcanis closed this Jun 15, 2020
@merceyz merceyz deleted the cordova-compat branch June 15, 2020 14:42
@yinzara
Copy link

yinzara commented Apr 17, 2021

Was there ever a separate contrib plugin made for this? I can't find one

@merceyz
Copy link
Member Author

merceyz commented Apr 17, 2021

No, I ended up making one for internal use at the company I work for since I required more changes than I initially made here.

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

Successfully merging this pull request may close these issues.

5 participants