fix(npm): support workspace globs#159
Merged
Merged
Conversation
Coverage Report for CI Build 28439957933Coverage increased (+0.1%) to 64.313%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes npm workspace glob handling by expanding workspace patterns (e.g. packages/*) into actual package.json manifest paths, preventing attempts to open literal glob paths.
Changes:
- Use
fast-globin the npm workspaces project implementation to resolve workspace glob patterns to concretepackage.jsonpaths. - Add a unit test covering glob-based workspace configuration in
package.json. - Update npm package dependencies and the lockfile accordingly.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds fast-glob to the npm package importer and updates lockfile entries. |
| packages/npm/src/workspacesProject.ts | Resolves npm workspace glob patterns via fast-glob instead of treating them as literal paths. |
| packages/npm/src/workspacesProject.spec.ts | Adds a unit test for glob-based npm workspace configuration. |
| packages/npm/package.json | Adds fast-glob as a runtime dependency for glob expansion. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
80
| it('should parse workspace globs from package.json', async () => { | ||
| const { cwd } = await forkProject('npm-workspace-globs', packageJsonIndependentMonorepoProject()) | ||
| const pkgJsonContent = await fs.readFile(join(cwd, 'package.json'), 'utf-8') | ||
| const pkgJson = JSON.parse(pkgJsonContent) | ||
|
|
||
| pkgJson.workspaces = [ | ||
| 'packages/*' | ||
| ] | ||
|
|
||
| await fs.writeFile(join(cwd, 'package.json'), JSON.stringify(pkgJson)) | ||
|
|
||
| const project = new NpmWorkspacesProject({ | ||
| mode: 'independent', | ||
| root: cwd | ||
| }) | ||
| const workspaces = await toArray(project.getProjects()) | ||
| const manifestPaths = workspaces.map(workspace => workspace.manifest.manifestPath) | ||
|
|
||
| expect(manifestPaths).toEqual(expect.arrayContaining([ | ||
| expect.stringContaining('packages/subproject-1/package.json'), | ||
| expect.stringContaining('packages/subproject-2/package.json'), | ||
| expect.stringContaining('packages/subproject-3/package.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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes TrigenSoftware/simple-release-action#18.