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(devkit): add method for tree-aware glob search #19128

Merged
merged 3 commits into from Sep 13, 2023

Conversation

AgentEnder
Copy link
Member

Current Behavior

There is not an easy way to perform a glob search during a generator, as new files on the Tree will not show up, and files deleted on the Tree will still be visible.

Expected Behavior

There is a method exported from @nx/devkit to perform glob searches. Allowing it to be passed a Tree or just a list of patterns allows folks to take advantage of the glob search in generators, executors, or random scripts easily. This is important, as the glob search provided will also adhere to the way we do glob searches, and can help plugins become more uniform in how patterns are evaluated.

Newly created files on the tree show up if it is provided, and deleted files are hidden.

Related Issue(s)

Fixes #

@vercel
Copy link

vercel bot commented Sep 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 13, 2023 7:53pm

packages/nx/src/generators/utils/glob.ts Outdated Show resolved Hide resolved
* @param patterns A list of glob patterns
* @returns Normalized paths in the workspace that match the provided glob patterns.
*/
export async function glob(patterns: string[]): Promise<string[]>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm uneasy about exposing this version of it. Why use this instead of fast-glob or some minimal wrapper of globset? Anyways, I'd say we shouldn't do this until someone asks for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

You'd use this over fast-glob or globset when the intention is to be consistent with how globs run for the rest of Nx, I think its pretty valuable and I'd likely use it for nx-dotnet.

packages/nx/src/generators/utils/glob.ts Outdated Show resolved Hide resolved
packages/nx/internal-testing-utils/temp-fs.ts Outdated Show resolved Hide resolved
… point s.t. they do not get included in published code

chore(core): move nx/internal-testing-utils -> nx/src/internal-testing-utils

const matches = new Set(globWithWorkspaceContext(root, patterns));

if ('root' in treeOrPatterns) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the non-tree version.

@AgentEnder AgentEnder enabled auto-merge (squash) September 13, 2023 20:33
@AgentEnder AgentEnder merged commit de2824a into nrwl:master Sep 13, 2023
14 of 15 checks passed
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants