lerna / lerna

:dragon: Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
https://lerna.js.org
MIT License
35.5k stars 2.24k forks source link

Add support for the yarn portal protocol #3564

Open jgornick opened 1 year ago

jgornick commented 1 year ago

Description

Yarn implemented support for the portal: protocol when specifying dependencies. This implementation is similar to the link: protocol, but follows the dependencies in the package and installs them.

However, when using the portal: protocol, lerna is unable to parse and handle it.

Motivation

This support would bring parity to protocols supported by yarn.

Suggested Implementation

My understanding from lerna's perspective, this protocol wouldn't be handled any different than the link protocol.

Alternate Implementations

I don't think there are any 🤷

JamesHenry commented 1 year ago

Thanks @jgornick, I was not aware of this protocol until seeing your issue.

Would you like to submit a PR to add support for it?

jgornick commented 1 year ago

Hey @JamesHenry!

If I understand, because the link and portal protocol would behave the same from a dependency graph perspective, we would just need to add support for converting portal to file? This would be similar to how link is handled.

If so, I should be able to add support.

JamesHenry commented 1 year ago

Lol at that passive aggressive comment from previous maintainers 😄

Yes I would think so by looking at that. The main thing is to just add some proper e2e coverage for it and then we know for sure that we are good to go.

I think the most lightweight thing you could do is add a new spec file to lerna list's e2e, and prove the nodes and relationships are correct by asserting the output of lerna list --graph --all

To see an example of setting up an e2e fixture for modern yarn (berry), you can take a look at https://github.com/lerna/lerna/blob/ab1dff525cc700d4760946c0f68e4f390e356d5e/e2e/version/src/yarn-lockfiles.spec.ts#L18

bytemain commented 9 months ago

meet the same problem, I am using yarn@3, and using: portal:

❯ lerna exec "xx"
info cli using local version of lerna
lerna notice cli v7.3.0
lerna ERR! Error: Unsupported URL Type "portal:": portal:../dev-tool
lerna ERR!     at unsupportedURLType (/Users/user/0Workspace/github.com/opensumi/core/node_modules/lerna/node_modules/npm-package-arg/npa.js:203:15)
lerna ERR!     at fromURL (/Users/user/0Workspace/github.com/opensumi/core/node_modules/lerna/node_modules/npm-package-arg/npa.js:261:13)
lerna ERR!     at resolve (/Users/user/0Workspace/github.com/opensumi/core/node_modules/lerna/node_modules/npm-package-arg/npa.js:80:12)
lerna ERR!     at resolvePackage (/Users/user/0Workspace/github.com/opensumi/core/node_modules/lerna/dist/index.js:1439:60)
lerna ERR!     at /Users/user/0Workspace/github.com/opensumi/core/node_modules/lerna/dist/index.js:1384:30
lerna ERR!     at Array.forEach (<anonymous>)q
lerna ERR!     at createProjectGraphWithPackages (/Users/user/0Workspace/github.com/opensumi/core/node_modules/lerna/dist/index.js:1367:60)
lerna ERR!     at async detectProjects (/Users/user/0Workspace/github.com/opensumi/core/node_modules/lerna/dist/index.js:1451:24)
lerna ERR! lerna Unsupported URL Type "portal:": portal:../dev-tool
JamesHenry commented 9 months ago

@bytemain as noted on here, we would very happily accept a PR on this from users who leverage portal, would you like to submit one?