-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: resolve parent workspace in monorepos workspaces #118
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8cf0716
Initial plan
Copilot 4ae8ca5
Add workspace parent detection using resolve-workspace-root
Copilot d7ea7f0
Add documentation for nested workspace support
Copilot 636eaca
Improve workspace parent detection to support nested workspaces
Copilot 21dd54f
Address code review feedback: improve workspace detection logic and f…
Copilot 572af97
Refactor: move findUltimateWorkspaceRoot to lib/utils.js
Copilot 2a740a4
Simplify: use resolveWorkspaceRootAsync directly instead of findUltim…
Copilot 24cf5cc
Add --no-parent-workspace flag and improve parent workspace detection…
Copilot 6f4a3dc
Add debug logging for parent workspace detection
Copilot d8a63a6
Refactor import for resolveWorkspaceRootAsync
voxpelli b32653b
Change debug messages to use console.error instead of console.log
Copilot 3ceffca
Add type annotation for reasons array to achieve 100% type coverage
Copilot f4f891c
Set includeWorkspaceRoot to false when using parent workspace detection
Copilot c9c2483
Support parent workspace detection with custom paths and add debug he…
Copilot 8b88590
Add examples and integration tests for monorepo workspace support
Copilot 8ad8f14
Improve examples and tests with unified/remark parsing
Copilot fa70920
Refactor integration tests for better reusability and add monorepo ex…
Copilot 679e98a
Fix critical bug: always set cwd in lookupOptions + split monorepo RE…
Copilot 062725e
Fix critical bug: always set cwd in lookupOptions + split monorepo RE…
Copilot e478577
Refactor integration tests and enhance examples
Copilot 52202d5
Fix glob pattern in package.json scripts
Copilot 4c7f990
Fix test-ci script to avoid recursive call
Copilot 33ce039
Address code review feedback: improve assertion style
Copilot 05366d7
Add distinct errors to all three examples
Copilot 53758c4
Add test/helpers.js to tsconfig and revert test script to explicit form
Copilot 9028ce9
Fix CI failures: normalize line endings and fix helper function signa…
Copilot 463880e
Fix CI failures: normalize line endings and fix helper function signa…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "extends": "@voxpelli/eslint-config/esm", | ||
| "root": true | ||
| "root": true, | ||
| "ignorePatterns": ["examples/**"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules/ | ||
| package-lock.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Basic Example | ||
|
|
||
| This is a simple example showing how `installed-check` works with a basic Node.js project. | ||
|
|
||
| ## What's in This Example | ||
|
|
||
| This example demonstrates a common issue - a dependency (`meow`) has a stricter `engines.node` requirement than the package itself: | ||
| - `chalk@^4.0.0` - A popular terminal coloring library | ||
| - `meow@^14.0.0` - A CLI helper library (requires Node >=20, but package specifies >=18.6.0) | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| # From the repository root | ||
| cd examples/basic | ||
| npm install | ||
| cd ../.. | ||
|
|
||
| # Run installed-check | ||
| node cli-wrapper.cjs examples/basic | ||
| ``` | ||
|
|
||
| ## Example Output | ||
|
|
||
| <!-- BEGIN EXPECTED OUTPUT --> | ||
| ``` | ||
| Errors: | ||
|
|
||
| meow: Narrower "engines.node" is needed: >=20.0.0 | ||
|
|
||
voxpelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Suggestions: | ||
|
|
||
| Combined "engines.node" needs to be narrower: >=20.0.0 | ||
| ``` | ||
| <!-- END EXPECTED OUTPUT --> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "example-basic", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "Basic example for installed-check - intentionally has issues for demonstration", | ||
| "dependencies": { | ||
| "chalk": "^4.0.0", | ||
| "meow": "^14.0.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18.6.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Monorepo Example | ||
|
|
||
| This example demonstrates how `installed-check` works with monorepo workspaces. | ||
|
|
||
| ## Structure | ||
|
|
||
| ``` | ||
| monorepo/ | ||
| ├── package.json (workspace root with chalk@^4.0.0 and meow@^14.0.0 - has engine issue) | ||
| ├── node_modules/ (shared dependencies installed here) | ||
| └── packages/ | ||
| ├── workspace-a/ | ||
| │ └── package.json (depends on chalk@^4.0.0) | ||
| └── workspace-b/ | ||
| └── package.json (depends on chalk@^4.0.0, has typescript in devDeps) | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Running from Monorepo Root | ||
|
|
||
| This checks all workspaces at once including the root: | ||
|
|
||
| ```bash | ||
| # From the repository root | ||
| cd examples/monorepo | ||
| npm install | ||
| cd ../.. | ||
|
|
||
| # Check the entire monorepo | ||
| node cli-wrapper.cjs examples/monorepo | ||
| ``` | ||
|
|
||
| ## Example Output | ||
|
|
||
| <!-- BEGIN EXPECTED OUTPUT --> | ||
| ``` | ||
| Errors: | ||
|
|
||
| root: meow: Narrower "engines.node" is needed: >=20.0.0 | ||
|
|
||
| Suggestions: | ||
|
|
||
| root: Combined "engines.node" needs to be narrower: >=20.0.0 | ||
| ``` | ||
voxpelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <!-- END EXPECTED OUTPUT --> | ||
|
|
||
| ### Running from Individual Workspace | ||
|
|
||
| See [workspace-a/README.md](./packages/workspace-a/README.md) for examples of running `installed-check` on an individual workspace with automatic parent workspace detection. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "name": "example-monorepo", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "Monorepo example for installed-check parent workspace detection", | ||
| "workspaces": [ | ||
| "packages/*" | ||
| ], | ||
| "dependencies": { | ||
| "chalk": "^4.0.0", | ||
| "meow": "^14.0.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18.6.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Workspace A | ||
|
|
||
| This workspace is part of the monorepo example and demonstrates automatic parent workspace detection. | ||
|
|
||
| ## What's in This Workspace | ||
|
|
||
| This workspace: | ||
| - Depends on `chalk@^4.0.0` (installed in parent's node_modules) | ||
| - Has a clean configuration with no errors | ||
|
|
||
| The parent monorepo root has a `meow` dependency with an engine issue, but that issue does NOT appear when checking this workspace because `includeWorkspaceRoot` is set to `false` when using parent workspace detection. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| # From the repository root | ||
| cd examples/monorepo | ||
| npm install | ||
| cd ../.. | ||
|
|
||
| # Run installed-check on this workspace | ||
| node cli-wrapper.cjs examples/monorepo/packages/workspace-a | ||
|
|
||
| # With debug output | ||
| node cli-wrapper.cjs --debug examples/monorepo/packages/workspace-a | ||
| ``` | ||
|
|
||
| ## What Happens | ||
|
|
||
| When you run `installed-check` in this workspace: | ||
| 1. **Parent detection**: Automatically detects the parent monorepo at `examples/monorepo` | ||
| 2. **Module resolution**: Uses the parent's `node_modules` for finding dependencies | ||
| 3. **Filtered checking**: Only checks this workspace package, not the parent (includeWorkspaceRoot: false) | ||
| 4. **Validation**: Passes cleanly - the root's meow issue is excluded | ||
|
|
||
| ## Example Output | ||
|
|
||
| <!-- BEGIN EXPECTED OUTPUT --> | ||
| ``` | ||
|
|
||
voxpelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| <!-- END EXPECTED OUTPUT --> | ||
|
|
||
| The empty output indicates success - this workspace has no issues, and the parent's issue is excluded. | ||
|
|
||
| ### Debug Output | ||
|
|
||
| When run with `--debug`, you'll see parent workspace detection: | ||
|
|
||
| <!-- BEGIN DEBUG OUTPUT --> | ||
| ``` | ||
| Parent workspace detection: Attempting to resolve parent workspace root | ||
| Parent workspace detection: Found parent workspace root: /absolute/path/to/examples/monorepo | ||
| Parent workspace detection: Using parent workspace root, filtering to current workspace | ||
| ``` | ||
| <!-- END DEBUG OUTPUT --> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "workspace-a", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "Workspace A in monorepo example", | ||
| "dependencies": { | ||
| "chalk": "^4.0.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18.6.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "workspace-b", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "Workspace B in monorepo example", | ||
| "dependencies": { | ||
| "chalk": "^4.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "typescript": "^5.0.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18.6.0" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.