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
Conversation
Any tests we can add to verify this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally LGTM!
cli/src/lib/npm/npmProjectUtils.js
Outdated
): Promise<string[]> { | ||
if ( | ||
pkgJson.content.private !== true || | ||
!Array.isArray(pkgJson.content.workspaces) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces
- yarn: https://classic.yarnpkg.com/lang/en/docs/workspaces
Do you mean you have, workspaces.packages
field?
https://docs.npmjs.com/cli/v7/configuring-npm/package-json#workspaces
There was a problem hiding this comment.
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?
cli/src/commands/install.js
Outdated
@@ -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( |
There was a problem hiding this comment.
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
const workspacesPckJsonData = await findWorkspacesPackages( | |
const workspacesPkgJsonData = await findWorkspacesPackages( |
@Brianzchen I've added some tests |
There was a problem hiding this 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
@Brianzchen just added support for your workspaces |
@moroine can you fix the conflicts |
@Brianzchen updated |
@gantoine any update on this? |
@moroine until the changes merge I've published them here https://www.npmjs.com/package/ftyped |
@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 |
@Brianzchen updated |
There was a problem hiding this 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.
@gantoine I've updated the PR |
install
command supports mono-repo