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

Adding Yarn v1.x workspaces metadata extractor #666

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a-ovchinnikov
Copy link
Collaborator

@a-ovchinnikov a-ovchinnikov commented Sep 26, 2024

In Yarn v1.x workspaces metadata is stored outside of yarn.lock in package.json. This commit inroduces functions for workspaces metadata extraction and a dataclass to represent workspaces.

This addresses #630

Maintainers will complete the following section

  • Commit messages are descriptive enough
  • Code coverage from testing does not decrease and new code is covered
  • Docs updated (if applicable)
  • Docs links in the code are still valid (if docs were updated)

Note: if the contribution is external (not from an organization member), the CI
pipeline will not run automatically. After verifying that the CI is safe to run:

) -> list[Workspace]:
"""Extract workspace metadata from a package.

Currently does not deal with nested workspaces, however the way the code
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember reading that nested workspaces are not supported: https://classic.yarnpkg.com/lang/en/docs/workspaces/#toc-limitations-caveats

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. I think it is worth mentioning this here anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Is it? Yarn v1 is maintenance only so nested workspaces aren't happening and so we'd better not confuse the reader with the unlikely possibility of an unplanned feature in the ecosystem.

)


def get_workspace_paths(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably ensure that a package.json exists for each workspace we report

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, added a check.

In Yarn v1.x workspaces metadata is stored outside of yarn.lock in
package.json. This commit inroduces functions for workspaces metadata
extraction and a dataclass to represent workspaces.

Signed-off-by: Alexey Ovchinnikov <[email protected]>
@a-ovchinnikov a-ovchinnikov marked this pull request as ready for review October 9, 2024 20:00
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.

3 participants