-
Notifications
You must be signed in to change notification settings - Fork 12
feat: support running commands from subdirectories in monorepo #15
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| } | ||
|
|
||
| private getRepoRootPath(): string { | ||
| const root = findUp("yarn.lock", this.cwd); |
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.
Minor: What do you think about using the find-up library here? It's more robust and battle-tested than maintaining our own implementation.
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.
I've applied review.
a4871cf
| } | ||
|
|
||
| return findUp(name, path.dirname(absoluteCwd)); | ||
| } No newline at end of file |
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.
Missing EOL here. Might be worth checking our formatter settings.
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 repository doesn't have a formatter (prettier or biome) configured.
I'll create a separate PR to apply formatting across the codebase.
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.
raon0211
left a comment
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.
LGTM except for two minor comments. Feel free to merge if you don't think they're relevant.
319c833 to
2d9df7e
Compare
8443491 to
a4871cf
Compare
Summary
Add support for running CLI commands from subdirectories in a monorepo by resolving
process.cwd()behavior differences across package managers.Problem
When running
docflowcommands from a subdirectory (e.g.,packages/web), path calculations failed becauseprocess.cwd()behaves differently across package managers:process.cwd()INIT_CWDThis inconsistency caused incorrect relative path calculations for workspace packages.
Solution
getWorkingDirectory()Returns
INIT_CWD ?? process.cwd()to get consistent invocation directory across all package managers.Package manager
path.relative(cwd, pkgPath)from absolutepathfieldyarn.locklocation, then calculate relative pathsCommand updates
Replace
process.cwd()withgetWorkingDirectory()in commands.Result
Users can now run
docflow build,docflow check, anddocflow generatefrom any subdirectory in a monorepo, regardless of which package manager they use.