@teammy/server 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/main.js +10936 -6840
- package/dist/native-pi-entry.js +14 -1
- package/dist/project-pi-entry.js +51 -11
- package/dist/runtime/workflows/task-bootstrap/prompt.md +2 -0
- package/dist/web/assets/Assistant-BeYamS0w.js +1 -0
- package/dist/web/assets/Assistant-C7QfFYLo.css +1 -0
- package/dist/web/assets/Dashboard-BzmrE4Xv.js +1 -0
- package/dist/web/assets/Files-BvCYgjVV.js +1 -0
- package/dist/web/assets/{Markdown-oZagG-wy.js → Markdown-BRPMsc7D.js} +4 -4
- package/dist/web/assets/Materials-CK-mbNmo.css +1 -0
- package/dist/web/assets/Materials-DK3CkLr0.js +6 -0
- package/dist/web/assets/Sessions-D_579m-e.js +1 -0
- package/dist/web/assets/WorkspaceTree-fMDtGIFa.js +1 -0
- package/dist/web/assets/{file-links-CD346_jf.js → file-links-I1K8CwVK.js} +1 -1
- package/dist/web/assets/{index-Be5hGscJ.css → index-CTIAGUGG.css} +1 -1
- package/dist/web/assets/index-DQsx-e5d.js +66 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@isaacs/nonrecursive-glob-match/LICENSE.md +55 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/README.md +333 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts +114 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js +762 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/package.json +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts +4 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js +142 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts +114 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js +758 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js.map +7 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/package.json +3 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts +4 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js +138 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js.map +1 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/package.json +56 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/src/index.ts +900 -0
- package/node_modules/@isaacs/nonrecursive-glob-match/src/parse-class.ts +158 -0
- package/node_modules/glob/README.md +388 -214
- package/node_modules/glob/dist/commonjs/glob.d.ts +20 -11
- package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/glob.js +22 -29
- package/node_modules/glob/dist/commonjs/glob.js.map +1 -1
- package/node_modules/glob/dist/commonjs/has-magic.d.ts +1 -1
- package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/has-magic.js +1 -4
- package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -1
- package/node_modules/glob/dist/commonjs/ignore.d.ts +16 -4
- package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/ignore.js +24 -4
- package/node_modules/glob/dist/commonjs/ignore.js.map +1 -1
- package/node_modules/glob/dist/commonjs/index.d.ts +3 -2
- package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/index.js.map +1 -1
- package/node_modules/glob/dist/commonjs/index.min.js +2 -3
- package/node_modules/glob/dist/commonjs/index.min.js.map +4 -4
- package/node_modules/glob/dist/commonjs/pattern.d.ts +10 -3
- package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/pattern.js +27 -15
- package/node_modules/glob/dist/commonjs/pattern.js.map +1 -1
- package/node_modules/glob/dist/commonjs/processor.d.ts +23 -10
- package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/processor.js +36 -23
- package/node_modules/glob/dist/commonjs/processor.js.map +1 -1
- package/node_modules/glob/dist/commonjs/walker.d.ts +19 -17
- package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/walker.js +50 -35
- package/node_modules/glob/dist/commonjs/walker.js.map +1 -1
- package/node_modules/glob/dist/esm/glob.d.ts +20 -11
- package/node_modules/glob/dist/esm/glob.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/glob.js +22 -29
- package/node_modules/glob/dist/esm/glob.js.map +1 -1
- package/node_modules/glob/dist/esm/has-magic.d.ts +1 -1
- package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/has-magic.js +1 -4
- package/node_modules/glob/dist/esm/has-magic.js.map +1 -1
- package/node_modules/glob/dist/esm/ignore.d.ts +16 -4
- package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/ignore.js +25 -5
- package/node_modules/glob/dist/esm/ignore.js.map +1 -1
- package/node_modules/glob/dist/esm/index.d.ts +3 -2
- package/node_modules/glob/dist/esm/index.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/index.js.map +1 -1
- package/node_modules/glob/dist/esm/index.min.js +2 -3
- package/node_modules/glob/dist/esm/index.min.js.map +4 -4
- package/node_modules/glob/dist/esm/pattern.d.ts +10 -3
- package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/pattern.js +27 -15
- package/node_modules/glob/dist/esm/pattern.js.map +1 -1
- package/node_modules/glob/dist/esm/processor.d.ts +23 -10
- package/node_modules/glob/dist/esm/processor.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/processor.js +36 -23
- package/node_modules/glob/dist/esm/processor.js.map +1 -1
- package/node_modules/glob/dist/esm/walker.d.ts +19 -17
- package/node_modules/glob/dist/esm/walker.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/walker.js +51 -36
- package/node_modules/glob/dist/esm/walker.js.map +1 -1
- package/node_modules/glob/package.json +28 -12
- package/node_modules/glob/src/glob.ts +655 -0
- package/node_modules/glob/src/has-magic.ts +23 -0
- package/node_modules/glob/src/ignore.ts +162 -0
- package/node_modules/glob/src/index.ts +225 -0
- package/node_modules/glob/src/pattern.ts +286 -0
- package/node_modules/glob/src/processor.ts +333 -0
- package/node_modules/glob/src/walker.ts +523 -0
- package/node_modules/minimatch/README.md +125 -107
- package/node_modules/minimatch/dist/commonjs/index.d.ts +49 -38
- package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/minimatch/dist/commonjs/index.js +782 -359
- package/node_modules/minimatch/dist/commonjs/index.js.map +1 -1
- package/node_modules/minimatch/dist/esm/index.d.ts +49 -38
- package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -1
- package/node_modules/minimatch/dist/esm/index.js +781 -356
- package/node_modules/minimatch/dist/esm/index.js.map +1 -1
- package/node_modules/minimatch/package.json +5 -4
- package/node_modules/path-scurry/README.md +0 -1
- package/node_modules/path-scurry/dist/commonjs/index.d.ts +7 -0
- package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/path-scurry/dist/commonjs/index.js +59 -21
- package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -1
- package/node_modules/path-scurry/dist/esm/index.d.ts +7 -0
- package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -1
- package/node_modules/path-scurry/dist/esm/index.js +42 -14
- package/node_modules/path-scurry/dist/esm/index.js.map +1 -1
- package/node_modules/path-scurry/package.json +4 -4
- package/package.json +2 -1
- package/dist/web/assets/Assistant-B3h2yQF3.css +0 -1
- package/dist/web/assets/Assistant-Dm_p8EZl.js +0 -1
- package/dist/web/assets/Dashboard-fwW9NxcC.js +0 -1
- package/dist/web/assets/Files-D-KCDWmO.js +0 -1
- package/dist/web/assets/Sessions-BQhGiLvz.js +0 -1
- package/dist/web/assets/WorkspaceTree-B9733pV3.js +0 -1
- package/dist/web/assets/index-BiiPuwDi.js +0 -66
- package/node_modules/minimatch/dist/commonjs/ast.d.ts +0 -22
- package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +0 -1
- package/node_modules/minimatch/dist/commonjs/ast.js +0 -845
- package/node_modules/minimatch/dist/commonjs/ast.js.map +0 -1
- package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +0 -8
- package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +0 -1
- package/node_modules/minimatch/dist/commonjs/brace-expressions.js +0 -150
- package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +0 -1
- package/node_modules/minimatch/dist/esm/ast.d.ts +0 -22
- package/node_modules/minimatch/dist/esm/ast.d.ts.map +0 -1
- package/node_modules/minimatch/dist/esm/ast.js +0 -841
- package/node_modules/minimatch/dist/esm/ast.js.map +0 -1
- package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +0 -8
- package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +0 -1
- package/node_modules/minimatch/dist/esm/brace-expressions.js +0 -146
- package/node_modules/minimatch/dist/esm/brace-expressions.js.map +0 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// synchronous utility for filtering entries and calculating subwalks
|
|
2
|
+
|
|
3
|
+
import { GLOBSTAR } from 'minimatch'
|
|
4
|
+
import type { Path } from 'path-scurry'
|
|
5
|
+
import type { MMMatcher, MMPattern, Pattern } from './pattern.js'
|
|
6
|
+
import type { GlobWalkerOpts } from './walker.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A cache of which patterns have been processed for a given Path, in
|
|
10
|
+
* this walk step and the steps that led to it.
|
|
11
|
+
*
|
|
12
|
+
* A step only adds to it before it makes the caches for the next
|
|
13
|
+
* steps, so a copy can look up the chain of caches before it, in
|
|
14
|
+
* place of copying their entries. A pattern for a path that a cache
|
|
15
|
+
* up the chain has already seen is added to that cache's set, so that
|
|
16
|
+
* the other steps that share it see it too. Paths are keyed by their
|
|
17
|
+
* full path, because path-scurry can make a new Path object for the
|
|
18
|
+
* same path once its cache of children is full.
|
|
19
|
+
*/
|
|
20
|
+
export class HasWalkedCache {
|
|
21
|
+
parent?: HasWalkedCache
|
|
22
|
+
store?: Map<string, Set<string>>
|
|
23
|
+
constructor(parent?: HasWalkedCache) {
|
|
24
|
+
this.parent = parent
|
|
25
|
+
}
|
|
26
|
+
copy() {
|
|
27
|
+
return new HasWalkedCache(this)
|
|
28
|
+
}
|
|
29
|
+
// the set for the path in this cache, or the closest one before it
|
|
30
|
+
#find(fullpath: string): Set<string> | undefined {
|
|
31
|
+
const set = this.store?.get(fullpath)
|
|
32
|
+
return set || !this.parent ? set : this.parent.#find(fullpath)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
hasWalked(target: Path, pattern: Pattern) {
|
|
36
|
+
return !!this.#find(target.fullpath())?.has(pattern.globString())
|
|
37
|
+
}
|
|
38
|
+
storeWalked(target: Path, pattern: Pattern) {
|
|
39
|
+
const fullpath = target.fullpath()
|
|
40
|
+
const cached = this.#find(fullpath)
|
|
41
|
+
if (cached) cached.add(pattern.globString())
|
|
42
|
+
else
|
|
43
|
+
(this.store ??= new Map()).set(
|
|
44
|
+
fullpath,
|
|
45
|
+
new Set([pattern.globString()]),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A record of which paths have been matched in a given walk step,
|
|
52
|
+
* and whether they only are considered a match if they are a directory,
|
|
53
|
+
* and whether their absolute or relative path should be returned.
|
|
54
|
+
* The store maps each path to {@link MatchRecord.ABSOLUTE} and
|
|
55
|
+
* {@link MatchRecord.IF_DIR} flags.
|
|
56
|
+
*/
|
|
57
|
+
export class MatchRecord {
|
|
58
|
+
static readonly ABSOLUTE = 2
|
|
59
|
+
static readonly IF_DIR = 1
|
|
60
|
+
store: Map<Path, number> = new Map()
|
|
61
|
+
add(target: Path, absolute: boolean, ifDir: boolean) {
|
|
62
|
+
const n =
|
|
63
|
+
(absolute ? MatchRecord.ABSOLUTE : 0) |
|
|
64
|
+
(ifDir ? MatchRecord.IF_DIR : 0)
|
|
65
|
+
const current = this.store.get(target)
|
|
66
|
+
this.store.set(target, current === undefined ? n : n & current)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A collection of patterns that must be processed in a subsequent step
|
|
72
|
+
* for a given path.
|
|
73
|
+
*/
|
|
74
|
+
export class SubWalks {
|
|
75
|
+
store: Map<Path, Pattern[]> = new Map()
|
|
76
|
+
add(target: Path, pattern: Pattern) {
|
|
77
|
+
if (!target.canReaddir()) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
const subs = this.store.get(target)
|
|
81
|
+
if (subs) {
|
|
82
|
+
if (!subs.find(p => p.globString() === pattern.globString())) {
|
|
83
|
+
subs.push(pattern)
|
|
84
|
+
}
|
|
85
|
+
} else this.store.set(target, [pattern])
|
|
86
|
+
}
|
|
87
|
+
get(target: Path): Pattern[] {
|
|
88
|
+
const subs = this.store.get(target)
|
|
89
|
+
/* c8 ignore start */
|
|
90
|
+
if (!subs) {
|
|
91
|
+
throw new Error('attempting to walk unknown path')
|
|
92
|
+
}
|
|
93
|
+
/* c8 ignore stop */
|
|
94
|
+
return subs
|
|
95
|
+
}
|
|
96
|
+
entries(): [Path, Pattern[]][] {
|
|
97
|
+
return this.keys().map(k => [k, this.store.get(k) as Pattern[]])
|
|
98
|
+
}
|
|
99
|
+
keys(): Path[] {
|
|
100
|
+
return [...this.store.keys()].filter(t => t.canReaddir())
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The class that processes patterns for a given path.
|
|
106
|
+
*
|
|
107
|
+
* Handles child entry filtering, and determining whether a path's
|
|
108
|
+
* directory contents must be read.
|
|
109
|
+
*/
|
|
110
|
+
export class Processor {
|
|
111
|
+
hasWalkedCache: HasWalkedCache
|
|
112
|
+
matches = new MatchRecord()
|
|
113
|
+
subwalks = new SubWalks()
|
|
114
|
+
patterns?: Pattern[]
|
|
115
|
+
follow: boolean
|
|
116
|
+
dot: boolean
|
|
117
|
+
opts: GlobWalkerOpts
|
|
118
|
+
|
|
119
|
+
constructor(opts: GlobWalkerOpts, hasWalkedCache?: HasWalkedCache) {
|
|
120
|
+
this.opts = opts
|
|
121
|
+
this.follow = !!opts.follow
|
|
122
|
+
this.dot = !!opts.dot
|
|
123
|
+
this.hasWalkedCache =
|
|
124
|
+
hasWalkedCache ? hasWalkedCache.copy() : new HasWalkedCache()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
processPatterns(target: Path, patterns: Pattern[]) {
|
|
128
|
+
this.patterns = patterns
|
|
129
|
+
const processingSet: [Path, Pattern][] = patterns.map(p => [target, p])
|
|
130
|
+
|
|
131
|
+
// map of paths to the magic-starting subwalks they need to walk
|
|
132
|
+
// first item in patterns is the filter
|
|
133
|
+
|
|
134
|
+
for (let [t, pattern] of processingSet) {
|
|
135
|
+
this.hasWalkedCache.storeWalked(t, pattern)
|
|
136
|
+
|
|
137
|
+
const root = pattern.root()
|
|
138
|
+
const absolute = pattern.isAbsolute() && this.opts.absolute !== false
|
|
139
|
+
|
|
140
|
+
// start absolute patterns at root
|
|
141
|
+
if (root) {
|
|
142
|
+
t = t.resolve(
|
|
143
|
+
root === '/' && this.opts.root !== undefined ?
|
|
144
|
+
this.opts.root
|
|
145
|
+
: root,
|
|
146
|
+
)
|
|
147
|
+
const rest = pattern.rest()
|
|
148
|
+
if (!rest) {
|
|
149
|
+
this.matches.add(t, true, false)
|
|
150
|
+
continue
|
|
151
|
+
} else {
|
|
152
|
+
pattern = rest
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (t.isENOENT()) continue
|
|
157
|
+
|
|
158
|
+
let p: MMPattern
|
|
159
|
+
let rest: Pattern | null
|
|
160
|
+
let changed = false
|
|
161
|
+
while (
|
|
162
|
+
typeof (p = pattern.pattern()) === 'string' &&
|
|
163
|
+
(rest = pattern.rest())
|
|
164
|
+
) {
|
|
165
|
+
const c = t.resolve(p)
|
|
166
|
+
t = c
|
|
167
|
+
pattern = rest
|
|
168
|
+
changed = true
|
|
169
|
+
}
|
|
170
|
+
p = pattern.pattern()
|
|
171
|
+
rest = pattern.rest()
|
|
172
|
+
if (changed) {
|
|
173
|
+
if (this.hasWalkedCache.hasWalked(t, pattern)) continue
|
|
174
|
+
this.hasWalkedCache.storeWalked(t, pattern)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// now we have either a final string for a known entry,
|
|
178
|
+
// more strings for an unknown entry,
|
|
179
|
+
// or a pattern starting with magic, mounted on t.
|
|
180
|
+
if (typeof p === 'string') {
|
|
181
|
+
// must not be final entry, otherwise we would have
|
|
182
|
+
// concatenated it earlier.
|
|
183
|
+
const ifDir = p === '..' || p === '' || p === '.'
|
|
184
|
+
this.matches.add(t.resolve(p), absolute, ifDir)
|
|
185
|
+
continue
|
|
186
|
+
} else if (p === GLOBSTAR) {
|
|
187
|
+
// if no rest, match and subwalk pattern
|
|
188
|
+
// if rest, process rest and subwalk pattern
|
|
189
|
+
// if it's a symlink, but we didn't get here by way of a
|
|
190
|
+
// globstar match (meaning it's the first time THIS globstar
|
|
191
|
+
// has traversed a symlink), then we follow it. Otherwise, stop.
|
|
192
|
+
if (
|
|
193
|
+
!t.isSymbolicLink() ||
|
|
194
|
+
this.follow ||
|
|
195
|
+
pattern.checkFollowGlobstar()
|
|
196
|
+
) {
|
|
197
|
+
this.subwalks.add(t, pattern)
|
|
198
|
+
}
|
|
199
|
+
const rp = rest?.pattern()
|
|
200
|
+
const rrest = rest?.rest()
|
|
201
|
+
if (!rest || ((rp === '' || rp === '.') && !rrest)) {
|
|
202
|
+
// only HAS to be a dir if it ends in **/ or **/.
|
|
203
|
+
// but ending in ** will match files as well.
|
|
204
|
+
this.matches.add(t, absolute, rp === '' || rp === '.')
|
|
205
|
+
} else {
|
|
206
|
+
if (rp === '..') {
|
|
207
|
+
// this would mean you're matching **/.. at the fs root,
|
|
208
|
+
// and no thanks, I'm not gonna test that specific case.
|
|
209
|
+
/* c8 ignore start */
|
|
210
|
+
const tp = t.parent || t
|
|
211
|
+
/* c8 ignore stop */
|
|
212
|
+
if (!rrest) this.matches.add(tp, absolute, true)
|
|
213
|
+
else if (!this.hasWalkedCache.hasWalked(tp, rrest)) {
|
|
214
|
+
this.subwalks.add(tp, rrest)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
} else if (typeof p === 'object') {
|
|
219
|
+
this.subwalks.add(t, pattern)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return this
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
subwalkTargets(): Path[] {
|
|
227
|
+
return this.subwalks.keys()
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
child() {
|
|
231
|
+
return new Processor(this.opts, this.hasWalkedCache)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// return a new Processor containing the subwalks for each
|
|
235
|
+
// child entry, and a set of matches, and
|
|
236
|
+
// a hasWalkedCache that's a copy of this one
|
|
237
|
+
// then we're going to call
|
|
238
|
+
filterEntries(parent: Path, entries: Path[]): Processor {
|
|
239
|
+
const patterns = this.subwalks.get(parent)
|
|
240
|
+
// put matches and entry walks into the results processor
|
|
241
|
+
const results = this.child()
|
|
242
|
+
for (const e of entries) {
|
|
243
|
+
for (const pattern of patterns) {
|
|
244
|
+
const absolute = pattern.isAbsolute()
|
|
245
|
+
const p = pattern.pattern()
|
|
246
|
+
const rest = pattern.rest()
|
|
247
|
+
if (p === GLOBSTAR) {
|
|
248
|
+
results.testGlobstar(e, pattern, rest, absolute)
|
|
249
|
+
} else if (typeof p === 'object') {
|
|
250
|
+
results.testMatcher(e, p, rest, absolute)
|
|
251
|
+
} else {
|
|
252
|
+
results.testString(e, p, rest, absolute)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return results
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
testGlobstar(
|
|
260
|
+
e: Path,
|
|
261
|
+
pattern: Pattern,
|
|
262
|
+
rest: Pattern | null,
|
|
263
|
+
absolute: boolean,
|
|
264
|
+
) {
|
|
265
|
+
if (this.dot || !e.name.startsWith('.')) {
|
|
266
|
+
if (!pattern.hasMore()) {
|
|
267
|
+
this.matches.add(e, absolute, false)
|
|
268
|
+
}
|
|
269
|
+
if (e.canReaddir()) {
|
|
270
|
+
// if we're in follow mode or it's not a symlink, just keep
|
|
271
|
+
// testing the same pattern. If there's more after the globstar,
|
|
272
|
+
// then this symlink consumes the globstar. If not, then we can
|
|
273
|
+
// follow at most ONE symlink along the way, so we mark it, which
|
|
274
|
+
// also checks to ensure that it wasn't already marked.
|
|
275
|
+
if (this.follow || !e.isSymbolicLink()) {
|
|
276
|
+
this.subwalks.add(e, pattern)
|
|
277
|
+
} else if (e.isSymbolicLink()) {
|
|
278
|
+
if (rest && pattern.checkFollowGlobstar()) {
|
|
279
|
+
this.subwalks.add(e, rest)
|
|
280
|
+
} else if (pattern.markFollowGlobstar()) {
|
|
281
|
+
this.subwalks.add(e, pattern)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// if the NEXT thing matches this entry, then also add
|
|
287
|
+
// the rest.
|
|
288
|
+
if (rest) {
|
|
289
|
+
const rp = rest.pattern()
|
|
290
|
+
if (
|
|
291
|
+
typeof rp === 'string' &&
|
|
292
|
+
// dots and empty were handled already
|
|
293
|
+
rp !== '..' &&
|
|
294
|
+
rp !== '' &&
|
|
295
|
+
rp !== '.'
|
|
296
|
+
) {
|
|
297
|
+
this.testString(e, rp, rest.rest(), absolute)
|
|
298
|
+
} else if (rp === '..') {
|
|
299
|
+
/* c8 ignore start */
|
|
300
|
+
const ep = e.parent || e
|
|
301
|
+
/* c8 ignore stop */
|
|
302
|
+
this.subwalks.add(ep, rest)
|
|
303
|
+
} else if (typeof rp === 'object') {
|
|
304
|
+
this.testMatcher(e, rp, rest.rest(), absolute)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
testMatcher(
|
|
310
|
+
e: Path,
|
|
311
|
+
p: MMMatcher,
|
|
312
|
+
rest: Pattern | null,
|
|
313
|
+
absolute: boolean,
|
|
314
|
+
) {
|
|
315
|
+
// an entry name is one path portion, with no `/`
|
|
316
|
+
if (!p.testUnchecked(e.name)) return
|
|
317
|
+
if (!rest) {
|
|
318
|
+
this.matches.add(e, absolute, false)
|
|
319
|
+
} else {
|
|
320
|
+
this.subwalks.add(e, rest)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
testString(e: Path, p: string, rest: Pattern | null, absolute: boolean) {
|
|
325
|
+
// should never happen?
|
|
326
|
+
if (!e.isNamed(p)) return
|
|
327
|
+
if (!rest) {
|
|
328
|
+
this.matches.add(e, absolute, false)
|
|
329
|
+
} else {
|
|
330
|
+
this.subwalks.add(e, rest)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|