@teammy/server 0.1.5 → 0.1.6

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.
Files changed (155) hide show
  1. package/dist/main.js +9835 -6799
  2. package/dist/native-pi-entry.js +14 -1
  3. package/dist/project-pi-entry.js +46 -8
  4. package/dist/runtime/workflows/task-bootstrap/prompt.md +2 -0
  5. package/dist/web/assets/{Assistant-B3h2yQF3.css → Assistant-4yZWjYm-.css} +1 -1
  6. package/dist/web/assets/Assistant-BNVXOHQZ.js +1 -0
  7. package/dist/web/assets/Dashboard-zKTK6EZD.js +1 -0
  8. package/dist/web/assets/Files-DI98WkdW.js +1 -0
  9. package/dist/web/assets/{Markdown-oZagG-wy.js → Markdown-D3cU0ani.js} +4 -4
  10. package/dist/web/assets/Materials-CK-mbNmo.css +1 -0
  11. package/dist/web/assets/Materials-CWptgAHz.js +6 -0
  12. package/dist/web/assets/Sessions-DiDwqXLI.js +1 -0
  13. package/dist/web/assets/WorkspaceTree-DeAA1QtV.js +1 -0
  14. package/dist/web/assets/{file-links-CD346_jf.js → file-links-GfCXWkEh.js} +1 -1
  15. package/dist/web/assets/index-BwEl1PIa.js +66 -0
  16. package/dist/web/assets/{index-Be5hGscJ.css → index-CTIAGUGG.css} +1 -1
  17. package/dist/web/downloads/teammy-skill.zip +0 -0
  18. package/dist/web/index.html +2 -2
  19. package/node_modules/@isaacs/nonrecursive-glob-match/LICENSE.md +55 -0
  20. package/node_modules/@isaacs/nonrecursive-glob-match/README.md +333 -0
  21. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts +114 -0
  22. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.d.ts.map +1 -0
  23. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js +762 -0
  24. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.js.map +1 -0
  25. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js +3 -0
  26. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/index.min.js.map +7 -0
  27. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/package.json +3 -0
  28. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts +4 -0
  29. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.d.ts.map +1 -0
  30. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js +142 -0
  31. package/node_modules/@isaacs/nonrecursive-glob-match/dist/commonjs/parse-class.js.map +1 -0
  32. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts +114 -0
  33. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.d.ts.map +1 -0
  34. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js +758 -0
  35. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js.map +1 -0
  36. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js +3 -0
  37. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.min.js.map +7 -0
  38. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/package.json +3 -0
  39. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts +4 -0
  40. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.d.ts.map +1 -0
  41. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js +138 -0
  42. package/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js.map +1 -0
  43. package/node_modules/@isaacs/nonrecursive-glob-match/package.json +56 -0
  44. package/node_modules/@isaacs/nonrecursive-glob-match/src/index.ts +900 -0
  45. package/node_modules/@isaacs/nonrecursive-glob-match/src/parse-class.ts +158 -0
  46. package/node_modules/glob/README.md +388 -214
  47. package/node_modules/glob/dist/commonjs/glob.d.ts +20 -11
  48. package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -1
  49. package/node_modules/glob/dist/commonjs/glob.js +22 -29
  50. package/node_modules/glob/dist/commonjs/glob.js.map +1 -1
  51. package/node_modules/glob/dist/commonjs/has-magic.d.ts +1 -1
  52. package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -1
  53. package/node_modules/glob/dist/commonjs/has-magic.js +1 -4
  54. package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -1
  55. package/node_modules/glob/dist/commonjs/ignore.d.ts +16 -4
  56. package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -1
  57. package/node_modules/glob/dist/commonjs/ignore.js +24 -4
  58. package/node_modules/glob/dist/commonjs/ignore.js.map +1 -1
  59. package/node_modules/glob/dist/commonjs/index.d.ts +3 -2
  60. package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -1
  61. package/node_modules/glob/dist/commonjs/index.js.map +1 -1
  62. package/node_modules/glob/dist/commonjs/index.min.js +2 -3
  63. package/node_modules/glob/dist/commonjs/index.min.js.map +4 -4
  64. package/node_modules/glob/dist/commonjs/pattern.d.ts +10 -3
  65. package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -1
  66. package/node_modules/glob/dist/commonjs/pattern.js +27 -15
  67. package/node_modules/glob/dist/commonjs/pattern.js.map +1 -1
  68. package/node_modules/glob/dist/commonjs/processor.d.ts +23 -10
  69. package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -1
  70. package/node_modules/glob/dist/commonjs/processor.js +36 -23
  71. package/node_modules/glob/dist/commonjs/processor.js.map +1 -1
  72. package/node_modules/glob/dist/commonjs/walker.d.ts +19 -17
  73. package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -1
  74. package/node_modules/glob/dist/commonjs/walker.js +50 -35
  75. package/node_modules/glob/dist/commonjs/walker.js.map +1 -1
  76. package/node_modules/glob/dist/esm/glob.d.ts +20 -11
  77. package/node_modules/glob/dist/esm/glob.d.ts.map +1 -1
  78. package/node_modules/glob/dist/esm/glob.js +22 -29
  79. package/node_modules/glob/dist/esm/glob.js.map +1 -1
  80. package/node_modules/glob/dist/esm/has-magic.d.ts +1 -1
  81. package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -1
  82. package/node_modules/glob/dist/esm/has-magic.js +1 -4
  83. package/node_modules/glob/dist/esm/has-magic.js.map +1 -1
  84. package/node_modules/glob/dist/esm/ignore.d.ts +16 -4
  85. package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -1
  86. package/node_modules/glob/dist/esm/ignore.js +25 -5
  87. package/node_modules/glob/dist/esm/ignore.js.map +1 -1
  88. package/node_modules/glob/dist/esm/index.d.ts +3 -2
  89. package/node_modules/glob/dist/esm/index.d.ts.map +1 -1
  90. package/node_modules/glob/dist/esm/index.js.map +1 -1
  91. package/node_modules/glob/dist/esm/index.min.js +2 -3
  92. package/node_modules/glob/dist/esm/index.min.js.map +4 -4
  93. package/node_modules/glob/dist/esm/pattern.d.ts +10 -3
  94. package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -1
  95. package/node_modules/glob/dist/esm/pattern.js +27 -15
  96. package/node_modules/glob/dist/esm/pattern.js.map +1 -1
  97. package/node_modules/glob/dist/esm/processor.d.ts +23 -10
  98. package/node_modules/glob/dist/esm/processor.d.ts.map +1 -1
  99. package/node_modules/glob/dist/esm/processor.js +36 -23
  100. package/node_modules/glob/dist/esm/processor.js.map +1 -1
  101. package/node_modules/glob/dist/esm/walker.d.ts +19 -17
  102. package/node_modules/glob/dist/esm/walker.d.ts.map +1 -1
  103. package/node_modules/glob/dist/esm/walker.js +51 -36
  104. package/node_modules/glob/dist/esm/walker.js.map +1 -1
  105. package/node_modules/glob/package.json +28 -12
  106. package/node_modules/glob/src/glob.ts +655 -0
  107. package/node_modules/glob/src/has-magic.ts +23 -0
  108. package/node_modules/glob/src/ignore.ts +162 -0
  109. package/node_modules/glob/src/index.ts +225 -0
  110. package/node_modules/glob/src/pattern.ts +286 -0
  111. package/node_modules/glob/src/processor.ts +333 -0
  112. package/node_modules/glob/src/walker.ts +523 -0
  113. package/node_modules/minimatch/README.md +125 -107
  114. package/node_modules/minimatch/dist/commonjs/index.d.ts +49 -38
  115. package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -1
  116. package/node_modules/minimatch/dist/commonjs/index.js +782 -359
  117. package/node_modules/minimatch/dist/commonjs/index.js.map +1 -1
  118. package/node_modules/minimatch/dist/esm/index.d.ts +49 -38
  119. package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -1
  120. package/node_modules/minimatch/dist/esm/index.js +781 -356
  121. package/node_modules/minimatch/dist/esm/index.js.map +1 -1
  122. package/node_modules/minimatch/package.json +5 -4
  123. package/node_modules/path-scurry/README.md +0 -1
  124. package/node_modules/path-scurry/dist/commonjs/index.d.ts +7 -0
  125. package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -1
  126. package/node_modules/path-scurry/dist/commonjs/index.js +59 -21
  127. package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -1
  128. package/node_modules/path-scurry/dist/esm/index.d.ts +7 -0
  129. package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -1
  130. package/node_modules/path-scurry/dist/esm/index.js +42 -14
  131. package/node_modules/path-scurry/dist/esm/index.js.map +1 -1
  132. package/node_modules/path-scurry/package.json +4 -4
  133. package/package.json +2 -1
  134. package/dist/web/assets/Assistant-Dm_p8EZl.js +0 -1
  135. package/dist/web/assets/Dashboard-fwW9NxcC.js +0 -1
  136. package/dist/web/assets/Files-D-KCDWmO.js +0 -1
  137. package/dist/web/assets/Sessions-BQhGiLvz.js +0 -1
  138. package/dist/web/assets/WorkspaceTree-B9733pV3.js +0 -1
  139. package/dist/web/assets/index-BiiPuwDi.js +0 -66
  140. package/node_modules/minimatch/dist/commonjs/ast.d.ts +0 -22
  141. package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +0 -1
  142. package/node_modules/minimatch/dist/commonjs/ast.js +0 -845
  143. package/node_modules/minimatch/dist/commonjs/ast.js.map +0 -1
  144. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +0 -8
  145. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +0 -1
  146. package/node_modules/minimatch/dist/commonjs/brace-expressions.js +0 -150
  147. package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +0 -1
  148. package/node_modules/minimatch/dist/esm/ast.d.ts +0 -22
  149. package/node_modules/minimatch/dist/esm/ast.d.ts.map +0 -1
  150. package/node_modules/minimatch/dist/esm/ast.js +0 -841
  151. package/node_modules/minimatch/dist/esm/ast.js.map +0 -1
  152. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +0 -8
  153. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +0 -1
  154. package/node_modules/minimatch/dist/esm/brace-expressions.js +0 -146
  155. package/node_modules/minimatch/dist/esm/brace-expressions.js.map +0 -1
@@ -0,0 +1,655 @@
1
+ import type { Form, MinimatchOptions } from 'minimatch'
2
+ import { Minimatch } from 'minimatch'
3
+ import type { Minipass } from 'minipass'
4
+ import { fileURLToPath } from 'node:url'
5
+ import type { FSOption, Path } from 'path-scurry'
6
+ import {
7
+ PathScurry,
8
+ PathScurryDarwin,
9
+ PathScurryPosix,
10
+ PathScurryWin32,
11
+ } from 'path-scurry'
12
+ import type { IgnoreLike } from './ignore.js'
13
+ import { Pattern } from './pattern.js'
14
+ import { GlobStream, GlobWalker } from './walker.js'
15
+
16
+ export type MatchSet = Minimatch['set']
17
+ export type GlobParts = Exclude<Minimatch['globParts'], undefined>
18
+
19
+ // if no process global, just call it linux.
20
+ // so we default to case-sensitive, / separators
21
+ const defaultPlatform: NodeJS.Platform =
22
+ (
23
+ typeof process === 'object' &&
24
+ process &&
25
+ typeof process.platform === 'string'
26
+ ) ?
27
+ process.platform
28
+ : 'linux'
29
+
30
+ /**
31
+ * A `GlobOptions` object may be provided to any of the exported methods, and
32
+ * must be provided to the `Glob` constructor.
33
+ *
34
+ * All options are optional, boolean, and false by default, unless otherwise
35
+ * noted.
36
+ *
37
+ * All resolved options are added to the Glob object as properties.
38
+ *
39
+ * If you are running many `glob` operations, you can pass a Glob object as the
40
+ * `options` argument to a subsequent operation to share the previously loaded
41
+ * cache.
42
+ */
43
+ export interface GlobOptions {
44
+ /**
45
+ * Set to `true` to always receive absolute paths for
46
+ * matched files. Set to `false` to always return relative paths.
47
+ *
48
+ * When this option is not set, absolute paths are returned for patterns
49
+ * that are absolute, and otherwise paths are returned that are relative
50
+ * to the `cwd` setting.
51
+ *
52
+ * This does _not_ make an extra system call to get
53
+ * the realpath, it only does string path resolution.
54
+ *
55
+ * Conflicts with {@link withFileTypes}
56
+ */
57
+ absolute?: boolean
58
+
59
+ /**
60
+ * Set to false to enable {@link windowsPathsNoEscape}
61
+ *
62
+ * @deprecated
63
+ */
64
+ allowWindowsEscape?: boolean
65
+
66
+ /**
67
+ * The current working directory in which to search. Defaults to
68
+ * `process.cwd()`.
69
+ *
70
+ * May be eiher a string path or a `file://` URL object or string.
71
+ */
72
+ cwd?: string | URL
73
+
74
+ /**
75
+ * Include `.dot` files in normal matches and `globstar`
76
+ * matches. Note that an explicit dot in a portion of the pattern
77
+ * will always match dot files.
78
+ */
79
+ dot?: boolean
80
+
81
+ /**
82
+ * Prepend all relative path strings with `./` (or `.\` on Windows).
83
+ *
84
+ * Without this option, returned relative paths are "bare", so instead of
85
+ * returning `'./foo/bar'`, they are returned as `'foo/bar'`.
86
+ *
87
+ * Relative patterns starting with `'../'` are not prepended with `./`, even
88
+ * if this option is set.
89
+ */
90
+ dotRelative?: boolean
91
+
92
+ /**
93
+ * Follow symlinked directories when expanding `**`
94
+ * patterns. This can result in a lot of duplicate references in
95
+ * the presence of cyclic links, and make performance quite bad.
96
+ *
97
+ * By default, a `**` in a pattern will follow 1 symbolic link if
98
+ * it is not the first item in the pattern, or none if it is the
99
+ * first item in the pattern, following the same behavior as Bash.
100
+ */
101
+ follow?: boolean
102
+
103
+ /**
104
+ * string or string[], or an object with `ignored` and `childrenIgnored`
105
+ * methods.
106
+ *
107
+ * If a string or string[] is provided, then this is treated as a glob
108
+ * pattern or array of glob patterns to exclude from matches. To ignore all
109
+ * children within a directory, as well as the entry itself, append `'/**'`
110
+ * to the ignore pattern.
111
+ *
112
+ * **Note** `ignore` patterns are _always_ in `dot:true` mode, regardless of
113
+ * any other settings.
114
+ *
115
+ * If an object is provided that has `ignored(path)` and/or
116
+ * `childrenIgnored(path)` methods, then these methods will be called to
117
+ * determine whether any Path is a match or if its children should be
118
+ * traversed, respectively.
119
+ */
120
+ readonly ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>
121
+
122
+ /**
123
+ * Treat brace expansion like `{a,b}` as a "magic" pattern. Has no
124
+ * effect if {@link nobrace} is set.
125
+ *
126
+ * Only has effect on the {@link hasMagic} function.
127
+ */
128
+ magicalBraces?: boolean
129
+
130
+ /**
131
+ * Add a `/` character to directory matches. Note that this requires
132
+ * additional stat calls in some cases.
133
+ */
134
+ mark?: boolean
135
+
136
+ /**
137
+ * Perform a basename-only match if the pattern does not contain any slash
138
+ * characters. That is, `*.js` would be treated as equivalent to
139
+ * `**\/*.js`, matching all js files in all directories.
140
+ */
141
+ matchBase?: boolean
142
+
143
+ /**
144
+ * Limit the directory traversal to a given depth below the cwd.
145
+ * Note that this does NOT prevent traversal to sibling folders,
146
+ * root patterns, and so on. It only limits the maximum folder depth
147
+ * that the walk will descend, relative to the cwd.
148
+ */
149
+ maxDepth?: number
150
+
151
+ /**
152
+ * Do not expand `{a,b}` and `{1..3}` brace sets.
153
+ */
154
+ nobrace?: boolean
155
+
156
+ /**
157
+ * Perform a case-insensitive match. This defaults to `true` on macOS and
158
+ * Windows systems, and `false` on all others.
159
+ *
160
+ * **Note** `nocase` should only be explicitly set when it is
161
+ * known that the filesystem's case sensitivity differs from the
162
+ * platform default. If set `true` on case-sensitive file
163
+ * systems, or `false` on case-insensitive file systems, then the
164
+ * walk may return more or less results than expected.
165
+ */
166
+ nocase?: boolean
167
+
168
+ /**
169
+ * Do not match directories, only files. (Note: to match
170
+ * _only_ directories, put a `/` at the end of the pattern.)
171
+ */
172
+ nodir?: boolean
173
+
174
+ /**
175
+ * Do not match "extglob" patterns such as `+(a|b)`.
176
+ */
177
+ noext?: boolean
178
+
179
+ /**
180
+ * Normalize unicode in the pattern, and in the file names that it is
181
+ * matched against, with this form: `'NFC'`, `'NFD'`, `'NFKC'`, or
182
+ * `'NFKD'`. `true` means `'NFC'`. This is passed to minimatch, so it
183
+ * applies to the portions of the pattern with magic, and to the
184
+ * `ignore` patterns.
185
+ *
186
+ * The portions of the pattern without magic are looked up with
187
+ * path-scurry, which already compares the names of the entries
188
+ * that it knows in their `'NFKD'` form.
189
+ */
190
+ normalize?: boolean | Form
191
+
192
+ /**
193
+ * Do not match `**` against multiple filenames. (Ie, treat it as a normal
194
+ * `*` instead.)
195
+ *
196
+ * Conflicts with {@link matchBase}
197
+ */
198
+ noglobstar?: boolean
199
+
200
+ /**
201
+ * Defaults to value of `process.platform` if available, or `'linux'` if
202
+ * not. Setting `platform:'win32'` on non-Windows systems may cause strange
203
+ * behavior.
204
+ */
205
+ platform?: NodeJS.Platform
206
+
207
+ /**
208
+ * Set to true to call `fs.realpath` on all of the
209
+ * results. In the case of an entry that cannot be resolved, the
210
+ * entry is omitted. This incurs a slight performance penalty, of
211
+ * course, because of the added system calls.
212
+ */
213
+ realpath?: boolean
214
+
215
+ /**
216
+ *
217
+ * A string path resolved against the `cwd` option, which
218
+ * is used as the starting point for absolute patterns that start
219
+ * with `/`, (but not drive letters or UNC paths on Windows).
220
+ *
221
+ * Note that this _doesn't_ necessarily limit the walk to the
222
+ * `root` directory, and doesn't affect the cwd starting point for
223
+ * non-absolute patterns. A pattern containing `..` will still be
224
+ * able to traverse out of the root directory, if it is not an
225
+ * actual root directory on the filesystem, and any non-absolute
226
+ * patterns will be matched in the `cwd`. For example, the
227
+ * pattern `/../*` with `{root:'/some/path'}` will return all
228
+ * files in `/some`, not all files in `/some/path`. The pattern
229
+ * `*` with `{root:'/some/path'}` will return all the entries in
230
+ * the cwd, not the entries in `/some/path`.
231
+ *
232
+ * To start absolute and non-absolute patterns in the same
233
+ * path, you can use `{root:''}`. However, be aware that on
234
+ * Windows systems, a pattern like `x:/*` or `//host/share/*` will
235
+ * _always_ start in the `x:/` or `//host/share` directory,
236
+ * regardless of the `root` setting.
237
+ */
238
+ root?: string
239
+
240
+ /**
241
+ * A [PathScurry](http://npm.im/path-scurry) object used
242
+ * to traverse the file system. If the `nocase` option is set
243
+ * explicitly, then any provided `scurry` object must match this
244
+ * setting.
245
+ */
246
+ scurry?: PathScurry
247
+
248
+ /**
249
+ * Call `lstat()` on all entries, whether required or not to determine
250
+ * if it's a valid match. When used with {@link withFileTypes}, this means
251
+ * that matches will include data such as modified time, permissions, and
252
+ * so on. Note that this will incur a performance cost due to the added
253
+ * system calls.
254
+ */
255
+ stat?: boolean
256
+
257
+ /**
258
+ * An AbortSignal which will cancel the Glob walk when
259
+ * triggered.
260
+ */
261
+ signal?: AbortSignal
262
+
263
+ /**
264
+ * Use `\\` as a path separator _only_, and
265
+ * _never_ as an escape character. If set, all `\\` characters are
266
+ * replaced with `/` in the pattern.
267
+ *
268
+ * Note that this makes it **impossible** to match against paths
269
+ * containing literal glob pattern characters, but allows matching
270
+ * with patterns constructed using `path.join()` and
271
+ * `path.resolve()` on Windows platforms, mimicking the (buggy!)
272
+ * behavior of Glob v7 and before on Windows. Please use with
273
+ * caution, and be mindful of [the caveat below about Windows
274
+ * paths](#windows). (For legacy reasons, this is also set if
275
+ * `allowWindowsEscape` is set to the exact value `false`.)
276
+ */
277
+ windowsPathsNoEscape?: boolean
278
+
279
+ /**
280
+ * Return [PathScurry](http://npm.im/path-scurry)
281
+ * `Path` objects instead of strings. These are similar to a
282
+ * NodeJS `Dirent` object, but with additional methods and
283
+ * properties.
284
+ *
285
+ * Conflicts with {@link absolute}
286
+ */
287
+ withFileTypes?: boolean
288
+
289
+ /**
290
+ * An fs implementation to override some or all of the defaults. See
291
+ * http://npm.im/path-scurry for details about what can be overridden.
292
+ */
293
+ fs?: FSOption
294
+
295
+ /**
296
+ * Return `/` delimited paths, even on Windows.
297
+ *
298
+ * On posix systems, this has no effect. But, on Windows, it means that
299
+ * paths will be `/` delimited, and absolute paths will be their full
300
+ * resolved UNC forms, eg instead of `'C:\\foo\\bar'`, it would return
301
+ * `'//?/C:/foo/bar'`
302
+ */
303
+ posix?: boolean
304
+
305
+ /**
306
+ * Do not match any children of any matches. For example, the pattern
307
+ * `**\/foo` would match `a/foo`, but not `a/foo/b/foo` in this mode.
308
+ *
309
+ * This is especially useful for cases like "find all `node_modules`
310
+ * folders, but not the ones in `node_modules`".
311
+ *
312
+ * In order to support this, the `Ignore` implementation must support an
313
+ * `add(pattern: string)` method. If using the default `Ignore` class, then
314
+ * this is fine, but if this is set to `false`, and a custom `Ignore` is
315
+ * provided that does not have an `add()` method, then it will throw an
316
+ * error.
317
+ *
318
+ * **Caveat** It *only* ignores matches that would be a descendant of a
319
+ * previous match, and only if that descendant is matched *after* the
320
+ * ancestor is encountered. Since the file system walk happens in
321
+ * indeterminate order, it's possible that a match will already be added
322
+ * before its ancestor, if multiple or braced patterns are used.
323
+ *
324
+ * For example:
325
+ *
326
+ * ```ts
327
+ * const results = await glob([
328
+ * // likely to match first, since it's just a stat
329
+ * 'a/b/c/d/e/f',
330
+ *
331
+ * // this pattern is more complicated! It must to various readdir()
332
+ * // calls and test the results against a regular expression, and that
333
+ * // is certainly going to take a little bit longer.
334
+ * //
335
+ * // So, later on, it encounters a match at 'a/b/c/d/e', but it's too
336
+ * // late to ignore a/b/c/d/e/f, because it's already been emitted.
337
+ * 'a/[bdf]/?/[a-z]/*',
338
+ * ], { includeChildMatches: false })
339
+ * ```
340
+ *
341
+ * It's best to only set this to `false` if you can be reasonably sure that
342
+ * no components of the pattern will potentially match one another's file
343
+ * system descendants, or if the occasional included child entry will not
344
+ * cause problems.
345
+ *
346
+ * @default true
347
+ */
348
+ includeChildMatches?: boolean
349
+
350
+ /**
351
+ * max number of `{...}` patterns to expand. Default `1_000`.
352
+ *
353
+ * Note: this is much less than minimatch's default of `100_000`,
354
+ * because Glob has higher memory requirements due to walking
355
+ * the file system tree.
356
+ */
357
+ braceExpandMax?: number
358
+ }
359
+
360
+ export type GlobOptionsWithFileTypesTrue = GlobOptions & {
361
+ withFileTypes: true
362
+ // string options not relevant if returning Path objects.
363
+ absolute?: undefined
364
+ mark?: undefined
365
+ posix?: undefined
366
+ }
367
+
368
+ export type GlobOptionsWithFileTypesFalse = GlobOptions & {
369
+ withFileTypes?: false
370
+ }
371
+
372
+ export type GlobOptionsWithFileTypesUnset = GlobOptions & {
373
+ withFileTypes?: undefined
374
+ }
375
+
376
+ export type Result<Opts> =
377
+ Opts extends GlobOptionsWithFileTypesTrue ? Path
378
+ : Opts extends GlobOptionsWithFileTypesFalse ? string
379
+ : Opts extends GlobOptionsWithFileTypesUnset ? string
380
+ : string | Path
381
+ export type Results<Opts> = Result<Opts>[]
382
+
383
+ export type FileTypes<Opts> =
384
+ Opts extends GlobOptionsWithFileTypesTrue ? true
385
+ : Opts extends GlobOptionsWithFileTypesFalse ? false
386
+ : Opts extends GlobOptionsWithFileTypesUnset ? false
387
+ : boolean
388
+
389
+ /**
390
+ * An object that can perform glob pattern traversals.
391
+ */
392
+ export class Glob<Opts extends GlobOptions> implements GlobOptions {
393
+ absolute?: boolean
394
+ cwd: string
395
+ root?: string
396
+ dot: boolean
397
+ dotRelative: boolean
398
+ follow: boolean
399
+ ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>
400
+ magicalBraces: boolean
401
+ mark?: boolean
402
+ matchBase: boolean
403
+ maxDepth: number
404
+ nobrace: boolean
405
+ nocase: boolean
406
+ nodir: boolean
407
+ noext: boolean
408
+ noglobstar: boolean
409
+ pattern: string[] | ReadonlyArray<string>
410
+ platform: NodeJS.Platform
411
+ realpath: boolean
412
+ scurry: PathScurry
413
+ stat: boolean
414
+ signal?: AbortSignal
415
+ windowsPathsNoEscape: boolean
416
+ withFileTypes: FileTypes<Opts>
417
+ includeChildMatches: boolean
418
+
419
+ /**
420
+ * The options provided to the constructor.
421
+ */
422
+ opts: Opts
423
+
424
+ /**
425
+ * An array of parsed immutable {@link Pattern} objects.
426
+ */
427
+ patterns: Pattern[]
428
+
429
+ /**
430
+ * All options are stored as properties on the `Glob` object.
431
+ *
432
+ * See {@link GlobOptions} for full options descriptions.
433
+ *
434
+ * Note that a previous `Glob` object can be passed as the
435
+ * `GlobOptions` to another `Glob` instantiation to re-use settings
436
+ * and caches with a new pattern.
437
+ *
438
+ * Traversal functions can be called multiple times to run the walk
439
+ * again.
440
+ */
441
+ constructor(pattern: string | string[], opts: Opts) {
442
+ /* c8 ignore start */
443
+ if (!opts) throw new TypeError('glob options required')
444
+ /* c8 ignore stop */
445
+ this.withFileTypes = !!opts.withFileTypes as FileTypes<Opts>
446
+ this.signal = opts.signal
447
+ this.follow = !!opts.follow
448
+ this.dot = !!opts.dot
449
+ this.dotRelative = !!opts.dotRelative
450
+ this.nodir = !!opts.nodir
451
+ this.mark = !!opts.mark
452
+ if (!opts.cwd) {
453
+ this.cwd = ''
454
+ } else if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) {
455
+ opts.cwd = fileURLToPath(opts.cwd)
456
+ }
457
+ this.cwd = opts.cwd || ''
458
+ this.root = opts.root
459
+ this.magicalBraces = !!opts.magicalBraces
460
+ this.nobrace = !!opts.nobrace
461
+ this.noext = !!opts.noext
462
+ this.realpath = !!opts.realpath
463
+ this.absolute = opts.absolute
464
+ this.includeChildMatches = opts.includeChildMatches !== false
465
+
466
+ this.noglobstar = !!opts.noglobstar
467
+ this.matchBase = !!opts.matchBase
468
+ this.maxDepth =
469
+ typeof opts.maxDepth === 'number' ? opts.maxDepth : Infinity
470
+ this.stat = !!opts.stat
471
+ this.ignore = opts.ignore
472
+
473
+ if (this.withFileTypes && this.absolute !== undefined) {
474
+ throw new Error('cannot set absolute and withFileTypes:true')
475
+ }
476
+
477
+ let p: string[] = typeof pattern === 'string' ? [pattern] : pattern
478
+
479
+ this.windowsPathsNoEscape =
480
+ !!opts.windowsPathsNoEscape ||
481
+ (opts as { allowWindowsEscape?: boolean }).allowWindowsEscape ===
482
+ false
483
+
484
+ if (this.windowsPathsNoEscape) {
485
+ p = p.map(p => p.replace(/\\/g, '/'))
486
+ }
487
+
488
+ if (this.matchBase) {
489
+ if (opts.noglobstar) {
490
+ throw new TypeError('base matching requires globstar')
491
+ }
492
+ p = p.map(p => (p.includes('/') ? p : `./**/${p}`))
493
+ }
494
+
495
+ this.pattern = p
496
+
497
+ this.platform = opts.platform || defaultPlatform
498
+ this.opts = { ...opts, platform: this.platform }
499
+ if (opts.scurry) {
500
+ this.scurry = opts.scurry
501
+ if (
502
+ opts.nocase !== undefined &&
503
+ opts.nocase !== opts.scurry.nocase
504
+ ) {
505
+ throw new Error('nocase option contradicts provided scurry option')
506
+ }
507
+ } else {
508
+ const Scurry =
509
+ opts.platform === 'win32' ? PathScurryWin32
510
+ : opts.platform === 'darwin' ? PathScurryDarwin
511
+ : opts.platform ? PathScurryPosix
512
+ : PathScurry
513
+ this.scurry = new Scurry(this.cwd, {
514
+ nocase: opts.nocase,
515
+ fs: opts.fs,
516
+ })
517
+ }
518
+ this.nocase = this.scurry.nocase
519
+
520
+ // If you do nocase:true on a case-sensitive file system, then
521
+ // we need to use regexps instead of strings for non-magic
522
+ // path portions, because statting `aBc` won't return results
523
+ // for the file `AbC` for example.
524
+ const nocaseMagicOnly =
525
+ this.platform === 'darwin' || this.platform === 'win32'
526
+
527
+ const mmo: MinimatchOptions = {
528
+ braceExpandMax: 10_000,
529
+ ...opts,
530
+ dot: this.dot,
531
+ matchBase: this.matchBase,
532
+ nobrace: this.nobrace,
533
+ // default nocase based on platform
534
+ nocase: this.nocase,
535
+ nocaseMagicOnly,
536
+ nocomment: true,
537
+ noext: this.noext,
538
+ nonegate: true,
539
+ optimizationLevel: 2,
540
+ platform: this.platform,
541
+ windowsPathsNoEscape: this.windowsPathsNoEscape,
542
+ }
543
+
544
+ const mms = this.pattern.map(p => new Minimatch(p, mmo))
545
+ const [matchSet, globParts] = mms.reduce(
546
+ (set: [MatchSet, GlobParts], m) => {
547
+ set[0].push(...m.set)
548
+ set[1].push(...m.globParts)
549
+ return set
550
+ },
551
+ [[], []],
552
+ )
553
+ this.patterns = matchSet.map((set, i) => {
554
+ const g = globParts[i]
555
+ /* c8 ignore start */
556
+ if (!g) throw new Error('invalid pattern object')
557
+ /* c8 ignore stop */
558
+ return new Pattern(set, g, 0, this.platform)
559
+ })
560
+ }
561
+
562
+ /**
563
+ * Returns a Promise that resolves to the results array.
564
+ */
565
+ async walk(): Promise<Results<Opts>>
566
+ async walk(): Promise<(string | Path)[]> {
567
+ // Walkers always return array of Path objects, so we just have to
568
+ // coerce them into the right shape. It will have already called
569
+ // realpath() if the option was set to do so, so we know that's cached.
570
+ // start out knowing the cwd, at least
571
+ return await new GlobWalker(this.patterns, this.scurry.cwd, {
572
+ ...this.opts,
573
+ maxDepth:
574
+ this.maxDepth !== Infinity ?
575
+ this.maxDepth + this.scurry.cwd.depth()
576
+ : Infinity,
577
+ platform: this.platform,
578
+ nocase: this.nocase,
579
+ includeChildMatches: this.includeChildMatches,
580
+ }).walk()
581
+ }
582
+
583
+ /**
584
+ * synchronous {@link Glob.walk}
585
+ */
586
+ walkSync(): Results<Opts>
587
+ walkSync(): (string | Path)[] {
588
+ return new GlobWalker(this.patterns, this.scurry.cwd, {
589
+ ...this.opts,
590
+ maxDepth:
591
+ this.maxDepth !== Infinity ?
592
+ this.maxDepth + this.scurry.cwd.depth()
593
+ : Infinity,
594
+ platform: this.platform,
595
+ nocase: this.nocase,
596
+ includeChildMatches: this.includeChildMatches,
597
+ }).walkSync()
598
+ }
599
+
600
+ /**
601
+ * Stream results asynchronously.
602
+ */
603
+ stream(): Minipass<Result<Opts>, Result<Opts>>
604
+ stream(): Minipass<string | Path, string | Path> {
605
+ return new GlobStream(this.patterns, this.scurry.cwd, {
606
+ ...this.opts,
607
+ maxDepth:
608
+ this.maxDepth !== Infinity ?
609
+ this.maxDepth + this.scurry.cwd.depth()
610
+ : Infinity,
611
+ platform: this.platform,
612
+ nocase: this.nocase,
613
+ includeChildMatches: this.includeChildMatches,
614
+ }).stream()
615
+ }
616
+
617
+ /**
618
+ * Stream results synchronously.
619
+ */
620
+ streamSync(): Minipass<Result<Opts>, Result<Opts>>
621
+ streamSync(): Minipass<string | Path, string | Path> {
622
+ return new GlobStream(this.patterns, this.scurry.cwd, {
623
+ ...this.opts,
624
+ maxDepth:
625
+ this.maxDepth !== Infinity ?
626
+ this.maxDepth + this.scurry.cwd.depth()
627
+ : Infinity,
628
+ platform: this.platform,
629
+ nocase: this.nocase,
630
+ includeChildMatches: this.includeChildMatches,
631
+ }).streamSync()
632
+ }
633
+
634
+ /**
635
+ * Default sync iteration function. Returns a Generator that
636
+ * iterates over the results.
637
+ */
638
+ iterateSync(): Generator<Result<Opts>, void, void> {
639
+ return this.streamSync()[Symbol.iterator]()
640
+ }
641
+ [Symbol.iterator]() {
642
+ return this.iterateSync()
643
+ }
644
+
645
+ /**
646
+ * Default async iteration function. Returns an AsyncGenerator that
647
+ * iterates over the results.
648
+ */
649
+ iterate(): AsyncGenerator<Result<Opts>, void, void> {
650
+ return this.stream()[Symbol.asyncIterator]()
651
+ }
652
+ [Symbol.asyncIterator]() {
653
+ return this.iterate()
654
+ }
655
+ }
@@ -0,0 +1,23 @@
1
+ import { Minimatch } from 'minimatch'
2
+ import type { GlobOptions } from './glob.js'
3
+
4
+ /**
5
+ * Return true if the patterns provided contain any magic glob characters,
6
+ * given the options provided.
7
+ *
8
+ * Brace expansion is not considered "magic" unless the `magicalBraces` option
9
+ * is set, as brace expansion just turns one string into an array of strings.
10
+ * So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and
11
+ * `'xby'` both do not contain any magic glob characters, and it's treated the
12
+ * same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`
13
+ * is in the options, brace expansion _is_ treated as a pattern having magic.
14
+ */
15
+ export const hasMagic = (
16
+ pattern: string | string[],
17
+ options: GlobOptions = {},
18
+ ): boolean => {
19
+ for (const p of Array.isArray(pattern) ? pattern : [pattern]) {
20
+ if (new Minimatch(p, options).hasMagic()) return true
21
+ }
22
+ return false
23
+ }