@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,523 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-use utility classes to provide functionality to the {@link Glob}
|
|
3
|
+
* methods.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { Minipass } from 'minipass'
|
|
8
|
+
import type { Form } from 'minimatch'
|
|
9
|
+
import type { Path } from 'path-scurry'
|
|
10
|
+
import type { IgnoreLike } from './ignore.js'
|
|
11
|
+
import { Ignore } from './ignore.js'
|
|
12
|
+
|
|
13
|
+
// XXX can we somehow make it so that it NEVER processes a given path more than
|
|
14
|
+
// once, enough that the match set tracking is no longer needed? that'd speed
|
|
15
|
+
// things up a lot. Or maybe bring back nounique, and skip it in that case?
|
|
16
|
+
|
|
17
|
+
// a single minimatch set entry with 1 or more parts
|
|
18
|
+
import type { Pattern } from './pattern.js'
|
|
19
|
+
import { MatchRecord, Processor } from './processor.js'
|
|
20
|
+
|
|
21
|
+
const { ABSOLUTE, IF_DIR } = MatchRecord
|
|
22
|
+
|
|
23
|
+
export interface GlobWalkerOpts {
|
|
24
|
+
absolute?: boolean
|
|
25
|
+
allowWindowsEscape?: boolean
|
|
26
|
+
cwd?: string | URL
|
|
27
|
+
dot?: boolean
|
|
28
|
+
dotRelative?: boolean
|
|
29
|
+
follow?: boolean
|
|
30
|
+
ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>
|
|
31
|
+
mark?: boolean
|
|
32
|
+
matchBase?: boolean
|
|
33
|
+
// Note: maxDepth here means "maximum actual Path.depth()",
|
|
34
|
+
// not "maximum depth beyond cwd"
|
|
35
|
+
maxDepth?: number
|
|
36
|
+
nobrace?: boolean
|
|
37
|
+
nocase?: boolean
|
|
38
|
+
nodir?: boolean
|
|
39
|
+
noext?: boolean
|
|
40
|
+
noglobstar?: boolean
|
|
41
|
+
normalize?: boolean | Form
|
|
42
|
+
platform?: NodeJS.Platform
|
|
43
|
+
posix?: boolean
|
|
44
|
+
realpath?: boolean
|
|
45
|
+
root?: string
|
|
46
|
+
stat?: boolean
|
|
47
|
+
signal?: AbortSignal
|
|
48
|
+
windowsPathsNoEscape?: boolean
|
|
49
|
+
withFileTypes?: boolean
|
|
50
|
+
includeChildMatches?: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type GWOFileTypesTrue = GlobWalkerOpts & {
|
|
54
|
+
withFileTypes: true
|
|
55
|
+
}
|
|
56
|
+
export type GWOFileTypesFalse = GlobWalkerOpts & {
|
|
57
|
+
withFileTypes: false
|
|
58
|
+
}
|
|
59
|
+
export type GWOFileTypesUnset = GlobWalkerOpts & {
|
|
60
|
+
withFileTypes?: undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type Result<O extends GlobWalkerOpts> =
|
|
64
|
+
O extends GWOFileTypesTrue ? Path
|
|
65
|
+
: O extends GWOFileTypesFalse ? string
|
|
66
|
+
: O extends GWOFileTypesUnset ? string
|
|
67
|
+
: Path | string
|
|
68
|
+
|
|
69
|
+
export type Matches<O extends GlobWalkerOpts> =
|
|
70
|
+
O extends GWOFileTypesTrue ? Path[]
|
|
71
|
+
: O extends GWOFileTypesFalse ? string[]
|
|
72
|
+
: O extends GWOFileTypesUnset ? string[]
|
|
73
|
+
: (Path | string)[]
|
|
74
|
+
|
|
75
|
+
export type MatchStream<O extends GlobWalkerOpts> = Minipass<
|
|
76
|
+
Result<O>,
|
|
77
|
+
Result<O>
|
|
78
|
+
>
|
|
79
|
+
|
|
80
|
+
const makeIgnore = (
|
|
81
|
+
ignore: string | string[] | IgnoreLike | ReadonlyArray<string>,
|
|
82
|
+
opts: GlobWalkerOpts,
|
|
83
|
+
cwd: Path,
|
|
84
|
+
): IgnoreLike =>
|
|
85
|
+
typeof ignore === 'string' ? new Ignore([ignore], opts, cwd)
|
|
86
|
+
: Array.isArray(ignore) ? new Ignore(ignore, opts, cwd)
|
|
87
|
+
: (ignore as IgnoreLike)
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* basic walking utilities that all the glob walker types use
|
|
91
|
+
*/
|
|
92
|
+
export abstract class GlobUtil<O extends GlobWalkerOpts = GlobWalkerOpts> {
|
|
93
|
+
path: Path
|
|
94
|
+
patterns: Pattern[]
|
|
95
|
+
opts: O
|
|
96
|
+
seen: Set<Path> = new Set<Path>()
|
|
97
|
+
paused: boolean = false
|
|
98
|
+
aborted: boolean = false
|
|
99
|
+
#onResume: (() => unknown)[] = []
|
|
100
|
+
#ignore?: IgnoreLike
|
|
101
|
+
#sep: '\\' | '/'
|
|
102
|
+
signal?: AbortSignal
|
|
103
|
+
maxDepth: number
|
|
104
|
+
includeChildMatches: boolean
|
|
105
|
+
|
|
106
|
+
constructor(patterns: Pattern[], path: Path, opts: O)
|
|
107
|
+
constructor(patterns: Pattern[], path: Path, opts: O) {
|
|
108
|
+
this.patterns = patterns
|
|
109
|
+
this.path = path
|
|
110
|
+
this.opts = opts
|
|
111
|
+
this.#sep = !opts.posix && opts.platform === 'win32' ? '\\' : '/'
|
|
112
|
+
this.includeChildMatches = opts.includeChildMatches !== false
|
|
113
|
+
if (opts.ignore || !this.includeChildMatches) {
|
|
114
|
+
this.#ignore = makeIgnore(opts.ignore ?? [], opts, path)
|
|
115
|
+
if (
|
|
116
|
+
!this.includeChildMatches &&
|
|
117
|
+
typeof this.#ignore.add !== 'function'
|
|
118
|
+
) {
|
|
119
|
+
const m = 'cannot ignore child matches, ignore lacks add() method.'
|
|
120
|
+
throw new Error(m)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ignore, always set with maxDepth, but it's optional on the
|
|
124
|
+
// GlobOptions type
|
|
125
|
+
/* c8 ignore start */
|
|
126
|
+
this.maxDepth = opts.maxDepth || Infinity
|
|
127
|
+
/* c8 ignore stop */
|
|
128
|
+
if (opts.signal) {
|
|
129
|
+
this.signal = opts.signal
|
|
130
|
+
this.signal.addEventListener('abort', () => {
|
|
131
|
+
this.#onResume.length = 0
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
#ignored(path: Path): boolean {
|
|
137
|
+
return this.seen.has(path) || !!this.#ignore?.ignored?.(path)
|
|
138
|
+
}
|
|
139
|
+
#childrenIgnored(path: Path): boolean {
|
|
140
|
+
return !!this.#ignore?.childrenIgnored?.(path)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// backpressure mechanism
|
|
144
|
+
pause() {
|
|
145
|
+
this.paused = true
|
|
146
|
+
}
|
|
147
|
+
resume() {
|
|
148
|
+
/* c8 ignore start */
|
|
149
|
+
if (this.signal?.aborted) return
|
|
150
|
+
/* c8 ignore stop */
|
|
151
|
+
this.paused = false
|
|
152
|
+
let fn: (() => unknown) | undefined = undefined
|
|
153
|
+
while (!this.paused && (fn = this.#onResume.shift())) {
|
|
154
|
+
fn()
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
onResume(fn: () => unknown) {
|
|
158
|
+
/* c8 ignore start */
|
|
159
|
+
if (!this.paused) {
|
|
160
|
+
fn()
|
|
161
|
+
} else {
|
|
162
|
+
/* c8 ignore stop */
|
|
163
|
+
this.#onResume.push(fn)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// do the requisite realpath/stat checking, and return the path
|
|
168
|
+
// to add or undefined to filter it out.
|
|
169
|
+
async matchCheck(
|
|
170
|
+
inPath: Path,
|
|
171
|
+
ifDir: boolean,
|
|
172
|
+
): Promise<Path | undefined> {
|
|
173
|
+
if (ifDir && this.opts.nodir) return undefined
|
|
174
|
+
let rpc: Path | undefined
|
|
175
|
+
let e: Path
|
|
176
|
+
if (this.opts.realpath) {
|
|
177
|
+
rpc = inPath.realpathCached() || (await inPath.realpath())
|
|
178
|
+
if (!rpc) return undefined
|
|
179
|
+
e = rpc
|
|
180
|
+
} else {
|
|
181
|
+
e = inPath
|
|
182
|
+
}
|
|
183
|
+
const needStat = e.isUnknown() || this.opts.stat
|
|
184
|
+
const s = needStat ? await e.lstat() : e
|
|
185
|
+
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
|
|
186
|
+
const target = await s.realpath()
|
|
187
|
+
/* c8 ignore start */
|
|
188
|
+
if (target && (target.isUnknown() || this.opts.stat)) {
|
|
189
|
+
await target.lstat()
|
|
190
|
+
}
|
|
191
|
+
/* c8 ignore stop */
|
|
192
|
+
}
|
|
193
|
+
return this.matchCheckTest(s, ifDir)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
matchCheckTest(e: Path | undefined, ifDir: boolean): Path | undefined {
|
|
197
|
+
return (
|
|
198
|
+
e &&
|
|
199
|
+
(this.maxDepth === Infinity || e.depth() <= this.maxDepth) &&
|
|
200
|
+
(!ifDir || e.canReaddir()) &&
|
|
201
|
+
(!this.opts.nodir || !e.isDirectory()) &&
|
|
202
|
+
(!this.opts.nodir ||
|
|
203
|
+
!this.opts.follow ||
|
|
204
|
+
!e.isSymbolicLink() ||
|
|
205
|
+
!e.realpathCached()?.isDirectory()) &&
|
|
206
|
+
!this.#ignored(e)
|
|
207
|
+
) ?
|
|
208
|
+
e
|
|
209
|
+
: undefined
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
matchCheckSync(inPath: Path, ifDir: boolean): Path | undefined {
|
|
213
|
+
if (ifDir && this.opts.nodir) return undefined
|
|
214
|
+
let rpc: Path | undefined
|
|
215
|
+
let e: Path
|
|
216
|
+
if (this.opts.realpath) {
|
|
217
|
+
rpc = inPath.realpathCached() || inPath.realpathSync()
|
|
218
|
+
if (!rpc) return undefined
|
|
219
|
+
e = rpc
|
|
220
|
+
} else {
|
|
221
|
+
e = inPath
|
|
222
|
+
}
|
|
223
|
+
const needStat = e.isUnknown() || this.opts.stat
|
|
224
|
+
const s = needStat ? e.lstatSync() : e
|
|
225
|
+
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
|
|
226
|
+
const target = s.realpathSync()
|
|
227
|
+
if (target && (target?.isUnknown() || this.opts.stat)) {
|
|
228
|
+
target.lstatSync()
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return this.matchCheckTest(s, ifDir)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
abstract matchEmit(p: Result<O>): void
|
|
235
|
+
abstract matchEmit(p: string | Path): void
|
|
236
|
+
|
|
237
|
+
matchFinish(e: Path, absolute: boolean) {
|
|
238
|
+
if (this.#ignored(e)) return
|
|
239
|
+
this.#matchEmitChecked(e, absolute)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// emit a match that is known to not be seen or ignored yet
|
|
243
|
+
#matchEmitChecked(e: Path, absolute: boolean) {
|
|
244
|
+
// we know we have an ignore if this is false, but TS doesn't
|
|
245
|
+
if (!this.includeChildMatches && this.#ignore?.add) {
|
|
246
|
+
const ign = `${e.relativePosix()}/**`
|
|
247
|
+
this.#ignore.add(ign)
|
|
248
|
+
}
|
|
249
|
+
const abs =
|
|
250
|
+
this.opts.absolute === undefined ? absolute : this.opts.absolute
|
|
251
|
+
this.seen.add(e)
|
|
252
|
+
const mark = this.opts.mark && e.isDirectory() ? this.#sep : ''
|
|
253
|
+
// ok, we have what we need!
|
|
254
|
+
if (this.opts.withFileTypes) {
|
|
255
|
+
this.matchEmit(e)
|
|
256
|
+
} else if (abs) {
|
|
257
|
+
const abs = this.opts.posix ? e.fullpathPosix() : e.fullpath()
|
|
258
|
+
this.matchEmit(abs + mark)
|
|
259
|
+
} else {
|
|
260
|
+
const rel = this.opts.posix ? e.relativePosix() : e.relative()
|
|
261
|
+
const pre =
|
|
262
|
+
this.opts.dotRelative && !rel.startsWith(`..${this.#sep}`) ?
|
|
263
|
+
`.${this.#sep}`
|
|
264
|
+
: ''
|
|
265
|
+
this.matchEmit(!rel ? `.${mark}` : pre + rel + mark)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async match(e: Path, absolute: boolean, ifDir: boolean): Promise<void> {
|
|
270
|
+
const p = await this.matchCheck(e, ifDir)
|
|
271
|
+
if (p) this.matchFinish(p, absolute)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
matchSync(e: Path, absolute: boolean, ifDir: boolean): void {
|
|
275
|
+
// matchCheckSync just checked that it is not seen or ignored, and
|
|
276
|
+
// nothing can have changed since
|
|
277
|
+
const p = this.matchCheckSync(e, ifDir)
|
|
278
|
+
if (p) this.#matchEmitChecked(p, absolute)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
walkCB(target: Path, patterns: Pattern[], cb: () => unknown) {
|
|
282
|
+
/* c8 ignore start */
|
|
283
|
+
if (this.signal?.aborted) return cb()
|
|
284
|
+
/* c8 ignore stop */
|
|
285
|
+
this.walkCB2(target, patterns, new Processor(this.opts), cb)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
walkCB2(
|
|
289
|
+
target: Path,
|
|
290
|
+
patterns: Pattern[],
|
|
291
|
+
processor: Processor,
|
|
292
|
+
cb: () => unknown,
|
|
293
|
+
) {
|
|
294
|
+
if (this.#childrenIgnored(target)) return cb()
|
|
295
|
+
if (this.signal?.aborted) return cb()
|
|
296
|
+
if (this.paused) {
|
|
297
|
+
this.onResume(() => this.walkCB2(target, patterns, processor, cb))
|
|
298
|
+
return
|
|
299
|
+
}
|
|
300
|
+
processor.processPatterns(target, patterns)
|
|
301
|
+
|
|
302
|
+
// done processing. all of the above is sync, can be abstracted out.
|
|
303
|
+
// subwalks is a map of paths to the entry filters they need
|
|
304
|
+
// matches is a map of paths to [absolute, ifDir] tuples.
|
|
305
|
+
let tasks = 1
|
|
306
|
+
const next = () => {
|
|
307
|
+
if (--tasks === 0) cb()
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
for (const [m, n] of processor.matches.store) {
|
|
311
|
+
if (this.#ignored(m)) continue
|
|
312
|
+
tasks++
|
|
313
|
+
void this.match(m, !!(n & ABSOLUTE), !!(n & IF_DIR)).then(() =>
|
|
314
|
+
next(),
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
for (const t of processor.subwalkTargets()) {
|
|
319
|
+
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
|
|
320
|
+
continue
|
|
321
|
+
}
|
|
322
|
+
tasks++
|
|
323
|
+
const childrenCached = t.readdirCached()
|
|
324
|
+
if (t.calledReaddir())
|
|
325
|
+
this.walkCB3(t, childrenCached, processor, next)
|
|
326
|
+
else {
|
|
327
|
+
t.readdirCB(
|
|
328
|
+
(_, entries) => this.walkCB3(t, entries, processor, next),
|
|
329
|
+
true,
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
next()
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
walkCB3(
|
|
338
|
+
target: Path,
|
|
339
|
+
entries: Path[],
|
|
340
|
+
processorx: Processor,
|
|
341
|
+
cb: () => unknown,
|
|
342
|
+
) {
|
|
343
|
+
const proc = processorx.filterEntries(target, entries)
|
|
344
|
+
|
|
345
|
+
let tasks = 1
|
|
346
|
+
const next = () => {
|
|
347
|
+
if (--tasks === 0) cb()
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
for (const [m, n] of proc.matches.store) {
|
|
351
|
+
if (this.#ignored(m)) continue
|
|
352
|
+
tasks++
|
|
353
|
+
void this.match(m, !!(n & ABSOLUTE), !!(n & IF_DIR)).then(() =>
|
|
354
|
+
next(),
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
for (const [target, patterns] of proc.subwalks.entries()) {
|
|
358
|
+
tasks++
|
|
359
|
+
this.walkCB2(target, patterns, proc.child(), next)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
next()
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
walkCBSync(target: Path, patterns: Pattern[], cb: () => unknown) {
|
|
366
|
+
/* c8 ignore start */
|
|
367
|
+
if (this.signal?.aborted) return cb()
|
|
368
|
+
/* c8 ignore stop */
|
|
369
|
+
this.walkCB2Sync(target, patterns, new Processor(this.opts), cb)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
walkCB2Sync(
|
|
373
|
+
target: Path,
|
|
374
|
+
patterns: Pattern[],
|
|
375
|
+
processor: Processor,
|
|
376
|
+
cb: () => unknown,
|
|
377
|
+
) {
|
|
378
|
+
if (this.#childrenIgnored(target)) return cb()
|
|
379
|
+
if (this.signal?.aborted) return cb()
|
|
380
|
+
if (this.paused) {
|
|
381
|
+
this.onResume(() =>
|
|
382
|
+
this.walkCB2Sync(target, patterns, processor, cb),
|
|
383
|
+
)
|
|
384
|
+
return
|
|
385
|
+
}
|
|
386
|
+
processor.processPatterns(target, patterns)
|
|
387
|
+
|
|
388
|
+
// done processing. all of the above is sync, can be abstracted out.
|
|
389
|
+
// subwalks is a map of paths to the entry filters they need
|
|
390
|
+
// matches is a map of paths to [absolute, ifDir] tuples.
|
|
391
|
+
let tasks = 1
|
|
392
|
+
const next = () => {
|
|
393
|
+
if (--tasks === 0) cb()
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
for (const [m, n] of processor.matches.store) {
|
|
397
|
+
if (this.#ignored(m)) continue
|
|
398
|
+
this.matchSync(m, !!(n & ABSOLUTE), !!(n & IF_DIR))
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
for (const t of processor.subwalkTargets()) {
|
|
402
|
+
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
|
|
403
|
+
continue
|
|
404
|
+
}
|
|
405
|
+
tasks++
|
|
406
|
+
const children = t.readdirSync()
|
|
407
|
+
this.walkCB3Sync(t, children, processor, next)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
next()
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
walkCB3Sync(
|
|
414
|
+
target: Path,
|
|
415
|
+
entries: Path[],
|
|
416
|
+
processor: Processor,
|
|
417
|
+
cb: () => unknown,
|
|
418
|
+
) {
|
|
419
|
+
const proc = processor.filterEntries(target, entries)
|
|
420
|
+
|
|
421
|
+
let tasks = 1
|
|
422
|
+
const next = () => {
|
|
423
|
+
if (--tasks === 0) cb()
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
for (const [m, n] of proc.matches.store) {
|
|
427
|
+
if (this.#ignored(m)) continue
|
|
428
|
+
this.matchSync(m, !!(n & ABSOLUTE), !!(n & IF_DIR))
|
|
429
|
+
}
|
|
430
|
+
for (const [target, patterns] of proc.subwalks.entries()) {
|
|
431
|
+
tasks++
|
|
432
|
+
this.walkCB2Sync(target, patterns, proc.child(), next)
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
next()
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export class GlobWalker<
|
|
440
|
+
O extends GlobWalkerOpts = GlobWalkerOpts,
|
|
441
|
+
> extends GlobUtil<O> {
|
|
442
|
+
// each Path is only emitted once (see GlobUtil.seen), so the results
|
|
443
|
+
// do not need to be deduped
|
|
444
|
+
matches: Result<O>[] = []
|
|
445
|
+
|
|
446
|
+
constructor(patterns: Pattern[], path: Path, opts: O) {
|
|
447
|
+
super(patterns, path, opts)
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
matchEmit(e: Result<O>): void {
|
|
451
|
+
this.matches.push(e)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async walk(): Promise<Result<O>[]> {
|
|
455
|
+
if (this.signal?.aborted) throw this.signal.reason
|
|
456
|
+
if (this.path.isUnknown()) {
|
|
457
|
+
await this.path.lstat()
|
|
458
|
+
}
|
|
459
|
+
await new Promise((res, rej) => {
|
|
460
|
+
this.walkCB(this.path, this.patterns, () => {
|
|
461
|
+
if (this.signal?.aborted) {
|
|
462
|
+
rej(this.signal.reason)
|
|
463
|
+
} else {
|
|
464
|
+
res(this.matches)
|
|
465
|
+
}
|
|
466
|
+
})
|
|
467
|
+
})
|
|
468
|
+
return this.matches
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
walkSync(): Result<O>[] {
|
|
472
|
+
if (this.signal?.aborted) throw this.signal.reason
|
|
473
|
+
if (this.path.isUnknown()) {
|
|
474
|
+
this.path.lstatSync()
|
|
475
|
+
}
|
|
476
|
+
// nothing for the callback to do, because this never pauses
|
|
477
|
+
this.walkCBSync(this.path, this.patterns, () => {
|
|
478
|
+
if (this.signal?.aborted) throw this.signal.reason
|
|
479
|
+
})
|
|
480
|
+
return this.matches
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export class GlobStream<
|
|
485
|
+
O extends GlobWalkerOpts = GlobWalkerOpts,
|
|
486
|
+
> extends GlobUtil<O> {
|
|
487
|
+
results: Minipass<Result<O>, Result<O>>
|
|
488
|
+
|
|
489
|
+
constructor(patterns: Pattern[], path: Path, opts: O) {
|
|
490
|
+
super(patterns, path, opts)
|
|
491
|
+
this.results = new Minipass<Result<O>, Result<O>>({
|
|
492
|
+
signal: this.signal,
|
|
493
|
+
objectMode: true,
|
|
494
|
+
})
|
|
495
|
+
this.results.on('drain', () => this.resume())
|
|
496
|
+
this.results.on('resume', () => this.resume())
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
matchEmit(e: Result<O>): void {
|
|
500
|
+
this.results.write(e)
|
|
501
|
+
if (!this.results.flowing) this.pause()
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
stream(): MatchStream<O> {
|
|
505
|
+
const target = this.path
|
|
506
|
+
if (target.isUnknown()) {
|
|
507
|
+
void target.lstat().then(() => {
|
|
508
|
+
this.walkCB(target, this.patterns, () => this.results.end())
|
|
509
|
+
})
|
|
510
|
+
} else {
|
|
511
|
+
this.walkCB(target, this.patterns, () => this.results.end())
|
|
512
|
+
}
|
|
513
|
+
return this.results
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
streamSync(): MatchStream<O> {
|
|
517
|
+
if (this.path.isUnknown()) {
|
|
518
|
+
this.path.lstatSync()
|
|
519
|
+
}
|
|
520
|
+
this.walkCBSync(this.path, this.patterns, () => this.results.end())
|
|
521
|
+
return this.results
|
|
522
|
+
}
|
|
523
|
+
}
|