-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(core): pattern matching for target defaults #26870
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 4a01bc9. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
7111249
to
840f448
Compare
for (const key in targetDefaults ?? {}) { | ||
if (isGlobPattern(key) && minimatch(targetName, key)) { | ||
return targetDefaults[key]; | ||
} | ||
} |
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.
Change this to find the pattern which is the longest character length wise.
840f448
to
4a01bc9
Compare
@@ -2,3 +2,14 @@ export function combineGlobPatterns(...patterns: (string | string[])[]) { | |||
const p = patterns.flat(); | |||
return p.length > 1 ? '{' + p.join(',') + '}' : p.length === 1 ? p[0] : ''; | |||
} | |||
|
|||
export const GLOB_CHARACTERS = new Set(['*', '|', '{', '}', '(', ')', '[']); |
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.
These are all the characters I found when doing the whole glob conversion stuff in the Rust side. Are they needed here as well (like the ?
, @
, etc)?
nx/packages/nx/src/native/glob.rs
Lines 110 to 124 in 0b0db78
pub(crate) fn contains_glob_pattern(value: &str) -> bool { | |
value.contains('!') | |
|| value.contains('?') | |
|| value.contains('@') | |
|| value.contains('+') | |
|| value.contains('*') | |
|| value.contains('|') | |
|| value.contains(',') | |
|| value.contains('{') | |
|| value.contains('}') | |
|| value.contains('[') | |
|| value.contains(']') | |
|| value.contains('(') | |
|| value.contains(')') | |
} |
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 don't think so... ?, @, +, ! are only valid in combination with paraenthises
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. |
Current Behavior
TargetDefaults can be specified by keys matching either executor or target name only
Expected Behavior
TargetDefaults can match based on a glob pattern that may match the target name. This is useful for things like
e2e-ci--*
. Only 1 target default will ever apply to a given target. We recognize this may be confusing, but is inline with current handling. If no default matches the target name or key, the first default that matches by pattern will be used.Related Issue(s)
Fixes #