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: install cmd supports monorepo #4140

Merged
merged 11 commits into from Nov 15, 2021
Merged

feat: install cmd supports monorepo #4140

merged 11 commits into from Nov 15, 2021

Conversation

moroine
Copy link
Contributor

@moroine moroine commented Sep 22, 2021

install command supports mono-repo

@Brianzchen
Copy link
Member

Any tests we can add to verify this?

Copy link
Member

@Brianzchen Brianzchen left a comment

Choose a reason for hiding this comment

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

Functionally LGTM!

): Promise<string[]> {
if (
pkgJson.content.private !== true ||
!Array.isArray(pkgJson.content.workspaces)
Copy link
Member

Choose a reason for hiding this comment

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

It seems that yarn has updated their api over time, but my projects seem to use workspaces.packages can you make it support that also so that flow-typed has the best compatibility with the end user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't really understand your question.

workspaces field seems to be string[] according to:

Do you mean you have, workspaces.packages field?

https://docs.npmjs.com/cli/v7/configuring-npm/package-json#workspaces

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think docs have since updated but they still support the old way. I implemented workspaces way back when it was first released and never really touched it since, my package.json looks like this

  "workspaces": {
    "packages": [
      "packages/*"
    ]
  },

Do you think we should continue to support this so that if I want to make use of this I also don't need to change the way my project is configured?

@@ -265,7 +266,17 @@ async function installNpmLibDefs({
const termMatches = term.match(/(@[^@\/]+\/)?([^@]+)@(.+)/);
if (termMatches == null) {
const pkgJsonData = await getPackageJsonData(cwd);
const pkgJsonDeps = getPackageJsonDependencies(pkgJsonData, []);
const workspacesPckJsonData = await findWorkspacesPackages(
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick but suggest we rename this var to be consistent with how it's used in rest of the project

Suggested change
const workspacesPckJsonData = await findWorkspacesPackages(
const workspacesPkgJsonData = await findWorkspacesPackages(

@moroine
Copy link
Contributor Author

moroine commented Sep 23, 2021

@Brianzchen I've added some tests

Copy link
Member

@Brianzchen Brianzchen left a comment

Choose a reason for hiding this comment

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

This is a great start. I hope this will get merged and we can improve incrementally later if need be

@moroine
Copy link
Contributor Author

moroine commented Sep 28, 2021

@Brianzchen just added support for your workspaces

@gantoine gantoine self-assigned this Sep 30, 2021
@Brianzchen
Copy link
Member

@moroine can you fix the conflicts

@moroine
Copy link
Contributor Author

moroine commented Sep 30, 2021

@Brianzchen updated

@moroine
Copy link
Contributor Author

moroine commented Oct 4, 2021

@gantoine any update on this?

@Brianzchen
Copy link
Member

@moroine until the changes merge I've published them here https://www.npmjs.com/package/ftyped

@Brianzchen
Copy link
Member

@moroine do you mind pulling from master, your test will have a single flow error that you can suppress that's caused by new method-unbinding

@moroine
Copy link
Contributor Author

moroine commented Nov 11, 2021

@Brianzchen updated

Copy link
Member

@gantoine gantoine left a comment

Choose a reason for hiding this comment

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

So after discussing it with @Brianzchen, I'm happy with this change. Couple things to cleanup:

  • Could you fix the tests so they pass on both node versions?
  • Can we print warning messages for duplicate versions?

Once those are addressed, I'd want to release this as an RC, so people can try it in their existing yarn monorepos.

@moroine
Copy link
Contributor Author

moroine commented Nov 12, 2021

@gantoine I've updated the PR

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.

None yet

3 participants