Skip to content

Commit 831b63c

Browse files
committed
fix: add default excluded paths for problematic dirs
1 parent ad4ab27 commit 831b63c

File tree

8 files changed

+75
-64
lines changed

8 files changed

+75
-64
lines changed

desktop/src-tauri/src/types/generated/workspace.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for CommonTags
7676
#[doc = " \"type\": \"object\","]
7777
#[doc = " \"properties\": {"]
7878
#[doc = " \"excluded\": {"]
79-
#[doc = " \"description\": \"A list of directories to exclude from the executable search.\","]
79+
#[doc = " \"description\": \"A list of directories or file patterns to exclude from the executable search.\\nSupports directory paths (e.g., \\\"node_modules/\\\", \\\"vendor/\\\") and glob patterns for filenames (e.g., \\\"*.js.flow\\\", \\\"*temp*\\\").\\nCommon exclusions like node_modules/, vendor/, third_party/, external/, and *.js.flow are excluded by default.\\n\","]
8080
#[doc = " \"default\": [],"]
8181
#[doc = " \"type\": \"array\","]
8282
#[doc = " \"items\": {"]
8383
#[doc = " \"type\": \"string\""]
8484
#[doc = " }"]
8585
#[doc = " },"]
8686
#[doc = " \"included\": {"]
87-
#[doc = " \"description\": \"A list of directories to include in the executable search.\","]
87+
#[doc = " \"description\": \"A list of directories or file patterns to include in the executable search.\\nSupports directory paths (e.g., \\\"src/\\\", \\\"scripts/\\\") and glob patterns for filenames (e.g., \\\"*.test.flow\\\", \\\"example*\\\").\\n\","]
8888
#[doc = " \"default\": [],"]
8989
#[doc = " \"type\": \"array\","]
9090
#[doc = " \"items\": {"]
@@ -97,10 +97,10 @@ impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for CommonTags
9797
#[doc = r" </details>"]
9898
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
9999
pub struct ExecutableFilter {
100-
#[doc = "A list of directories to exclude from the executable search."]
100+
#[doc = "A list of directories or file patterns to exclude from the executable search.\nSupports directory paths (e.g., \"node_modules/\", \"vendor/\") and glob patterns for filenames (e.g., \"*.js.flow\", \"*temp*\").\nCommon exclusions like node_modules/, vendor/, third_party/, external/, and *.js.flow are excluded by default.\n"]
101101
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
102102
pub excluded: ::std::vec::Vec<::std::string::String>,
103-
#[doc = "A list of directories to include in the executable search."]
103+
#[doc = "A list of directories or file patterns to include in the executable search.\nSupports directory paths (e.g., \"src/\", \"scripts/\") and glob patterns for filenames (e.g., \"*.test.flow\", \"example*\").\n"]
104104
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
105105
pub included: ::std::vec::Vec<::std::string::String>,
106106
}

desktop/src/types/generated/workspace.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ export interface Workspace {
3636
}
3737
export interface ExecutableFilter {
3838
/**
39-
* A list of directories to exclude from the executable search.
39+
* A list of directories or file patterns to exclude from the executable search.
40+
* Supports directory paths (e.g., "node_modules/", "vendor/") and glob patterns for filenames (e.g., "*.js.flow", "*temp*").
41+
* Common exclusions like node_modules/, vendor/, third_party/, external/, and *.js.flow are excluded by default.
42+
*
4043
*/
4144
excluded?: string[];
4245
/**
43-
* A list of directories to include in the executable search.
46+
* A list of directories or file patterns to include in the executable search.
47+
* Supports directory paths (e.g., "src/", "scripts/") and glob patterns for filenames (e.g., "*.test.flow", "example*").
48+
*
4449
*/
4550
included?: string[];
4651
[k: string]: unknown;

docs/schemas/workspace_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
"type": "object",
1717
"properties": {
1818
"excluded": {
19-
"description": "A list of directories to exclude from the executable search.",
19+
"description": "A list of directories or file patterns to exclude from the executable search.\nSupports directory paths (e.g., \"node_modules/\", \"vendor/\") and glob patterns for filenames (e.g., \"*.js.flow\", \"*temp*\").\nCommon exclusions like node_modules/, vendor/, third_party/, external/, and *.js.flow are excluded by default.\n",
2020
"type": "array",
2121
"default": [],
2222
"items": {
2323
"type": "string"
2424
}
2525
},
2626
"included": {
27-
"description": "A list of directories to include in the executable search.",
27+
"description": "A list of directories or file patterns to include in the executable search.\nSupports directory paths (e.g., \"src/\", \"scripts/\") and glob patterns for filenames (e.g., \"*.test.flow\", \"example*\").\n",
2828
"type": "array",
2929
"default": [],
3030
"items": {

docs/types/workspace.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Tags can be used with list commands to filter returned data.
4747

4848
| Field | Description | Type | Default | Required |
4949
| ----- | ----------- | ---- | ------- | :--------: |
50-
| `excluded` | A list of directories to exclude from the executable search. | `array` (`string`) | [] | |
51-
| `included` | A list of directories to include in the executable search. | `array` (`string`) | [] | |
50+
| `excluded` | A list of directories or file patterns to exclude from the executable search. Supports directory paths (e.g., "node_modules/", "vendor/") and glob patterns for filenames (e.g., "*.js.flow", "*temp*"). Common exclusions like node_modules/, vendor/, third_party/, external/, and *.js.flow are excluded by default. | `array` (`string`) | [] | |
51+
| `included` | A list of directories or file patterns to include in the executable search. Supports directory paths (e.g., "src/", "scripts/") and glob patterns for filenames (e.g., "*.test.flow", "example*"). | `array` (`string`) | [] | |
5252

5353
### VerbAliases
5454

flow.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
GitHub Repo: github.com/flowexec/flow
66
descriptionFile: docs/development.md
77
verbAliases: {}
8-
executables:
9-
excluded:
10-
- node_modules

internal/filesystem/executables.go

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"io/fs"
66
"os"
77
"path/filepath"
8-
"regexp"
98
"strings"
109

1110
"github.com/pkg/errors"
@@ -88,6 +87,14 @@ func LoadWorkspaceFlowFiles(
8887
return cfgs, nil
8988
}
9089

90+
var defaultExcutablePaths = []string{
91+
"vendor/",
92+
"third_party/",
93+
"external/",
94+
"node_modules/",
95+
"*.js.flow",
96+
}
97+
9198
func findFlowFiles(workspaceCfg *workspace.Workspace) ([]string, error) {
9299
var includePaths, excludedPaths []string
93100
if workspaceCfg.Executables != nil {
@@ -100,6 +107,7 @@ func findFlowFiles(workspaceCfg *workspace.Workspace) ([]string, error) {
100107
} else {
101108
includePaths = []string{workspaceCfg.Location()}
102109
}
110+
excludedPaths = append(excludedPaths, defaultExcutablePaths...)
103111

104112
var cfgPaths []string
105113
walkDirFunc := func(path string, entry fs.DirEntry, err error) error {
@@ -128,64 +136,52 @@ func findFlowFiles(workspaceCfg *workspace.Workspace) ([]string, error) {
128136
return cfgPaths, nil
129137
}
130138

131-
// IsPathIn returns true if the path is in any of the include paths.
132-
func isPathIncluded(path, basePath string, includePaths []string) bool {
133-
if includePaths == nil {
134-
return true
139+
func pathMatches(path, basePath string, patterns []string) bool {
140+
if patterns == nil {
141+
return false
142+
}
143+
144+
relPath, err := filepath.Rel(basePath, path)
145+
if err != nil {
146+
// fallback to absolute if relative path cannot be determined
147+
relPath = path
135148
}
136149

137-
for _, p := range includePaths {
138-
includePath := p
139-
if strings.HasPrefix(includePath, "//") {
140-
includePath = strings.Replace(includePath, "//", basePath+"/", 1)
150+
for _, p := range patterns {
151+
pattern := p
152+
if strings.HasPrefix(pattern, "//") {
153+
pattern = strings.Replace(pattern, "//", basePath+"/", 1)
141154
}
142155

143-
if path == includePath || strings.HasPrefix(path, includePath) {
156+
if path == pattern || strings.HasPrefix(path, pattern) {
157+
return true
158+
}
159+
if relPath == pattern || strings.HasPrefix(relPath, pattern) {
144160
return true
145161
}
146162

147-
isMatch, err := regexp.MatchString(includePath, path)
148-
if err != nil {
149-
logger.Log().Errorx(
150-
"unable to regex match path against include path",
151-
"path", path,
152-
"includePath", includePath,
153-
"err", err,
154-
)
155-
continue
163+
for _, checkPath := range []string{path, relPath} {
164+
if strings.Contains(pattern, "*") ||
165+
strings.Contains(pattern, "?") ||
166+
strings.Contains(pattern, "[") {
167+
fileName := filepath.Base(checkPath)
168+
isMatch, err := filepath.Match(pattern, fileName)
169+
if err == nil && isMatch {
170+
return true
171+
}
172+
}
156173
}
157-
return isMatch
158174
}
159175
return false
160176
}
161177

162-
// IsPathExcluded returns true if the path is in any of the excluded paths.
163-
func isPathExcluded(path, basePath string, excludedPaths []string) bool {
164-
if excludedPaths == nil {
165-
return false
178+
func isPathIncluded(path, basePath string, includePaths []string) bool {
179+
if includePaths == nil {
180+
return true
166181
}
182+
return pathMatches(path, basePath, includePaths)
183+
}
167184

168-
for _, p := range excludedPaths {
169-
excludedPath := p
170-
if strings.HasPrefix(excludedPath, "//") {
171-
excludedPath = strings.Replace(excludedPath, "//", basePath+"/", 1)
172-
}
173-
174-
if path == excludedPath || strings.HasPrefix(path, excludedPath) {
175-
return true
176-
}
177-
178-
isMatch, err := regexp.MatchString(excludedPath, path)
179-
if err != nil {
180-
logger.Log().Errorx(
181-
"unable to regex match path against excluded path",
182-
"path", path,
183-
"excludedPath", excludedPath,
184-
"err", err,
185-
)
186-
continue
187-
}
188-
return isMatch
189-
}
190-
return false
185+
func isPathExcluded(path, basePath string, excludedPaths []string) bool {
186+
return pathMatches(path, basePath, excludedPaths)
191187
}

types/workspace/schema.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ definitions:
1515
type: array
1616
items:
1717
type: string
18-
description: A list of directories to include in the executable search.
18+
description: |
19+
A list of directories or file patterns to include in the executable search.
20+
Supports directory paths (e.g., "src/", "scripts/") and glob patterns for filenames (e.g., "*.test.flow", "example*").
1921
default: []
2022
excluded:
2123
type: array
2224
items:
2325
type: string
24-
description: A list of directories to exclude from the executable search.
26+
description: |
27+
A list of directories or file patterns to exclude from the executable search.
28+
Supports directory paths (e.g., "node_modules/", "vendor/") and glob patterns for filenames (e.g., "*.js.flow", "*temp*").
29+
Common exclusions like node_modules/, vendor/, third_party/, external/, and *.js.flow are excluded by default.
2530
default: []
2631
VerbAliases:
2732
type: object

types/workspace/workspace.gen.go

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)