@visulima/fs 1.0.0
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/CHANGELOG.md +13 -0
- package/LICENSE.md +21 -0
- package/README.md +249 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +137 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## @visulima/fs 1.0.0 (2024-03-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **fs:** added collect-sync ([ed76052](https://github.com/visulima/visulima/commit/ed760529d190a177c64c4028c572160da62c9a0f))
|
|
7
|
+
* migrating readdir to fs package ([664d567](https://github.com/visulima/visulima/commit/664d5670ac84811963a830b594968f19bf81809a))
|
|
8
|
+
* renamed readdir for fs ([29b0564](https://github.com/visulima/visulima/commit/29b0564913cd136cd126a1e3a6d9461a85158930))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **fs:** fixed test and lint errors ([01e5f92](https://github.com/visulima/visulima/commit/01e5f921fd2a8700f40464bdc77b0a9ea00ab613))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 visulima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>Visulima fs</h3>
|
|
3
|
+
<p>
|
|
4
|
+
Human friendly file system utilities for Node.js
|
|
5
|
+
</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<br />
|
|
9
|
+
|
|
10
|
+
<div align="center">
|
|
11
|
+
|
|
12
|
+
[![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<p>
|
|
20
|
+
<sup>
|
|
21
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
22
|
+
</sup>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @visulima/fs
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
yarn add @visulima/fs
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
pnpm add @visulima/fs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
## walk
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { walk } from "@visulima/fs";
|
|
48
|
+
|
|
49
|
+
const filesAndFolders: string[] = [];
|
|
50
|
+
|
|
51
|
+
for await (const index of walk(`${__dirname}/fixtures`, {})) {
|
|
52
|
+
filesAndFolders.push(index.path);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log(filesAndFolders);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## walkSync
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { walkSync } from "@visulima/fs";
|
|
62
|
+
|
|
63
|
+
const filesAndFolders: string[] = [];
|
|
64
|
+
|
|
65
|
+
for (const index of walkSync(`${__dirname}/fixtures`, {})) {
|
|
66
|
+
filesAndFolders.push(index.path);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log(filesAndFolders);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### API for `walk` and `walkSync`
|
|
73
|
+
|
|
74
|
+
#### path
|
|
75
|
+
|
|
76
|
+
Type: `string`
|
|
77
|
+
|
|
78
|
+
The directory to start from.
|
|
79
|
+
|
|
80
|
+
#### options
|
|
81
|
+
|
|
82
|
+
Type: `object`
|
|
83
|
+
|
|
84
|
+
#### maxDepth
|
|
85
|
+
|
|
86
|
+
Type: `number`
|
|
87
|
+
|
|
88
|
+
Default: `Infinity`
|
|
89
|
+
|
|
90
|
+
Optional: `true`
|
|
91
|
+
|
|
92
|
+
Description: The maximum depth of the file tree to be walked recursively.
|
|
93
|
+
|
|
94
|
+
#### includeFiles
|
|
95
|
+
|
|
96
|
+
Type: `boolean`
|
|
97
|
+
|
|
98
|
+
Default: `true`
|
|
99
|
+
|
|
100
|
+
Optional: `true`
|
|
101
|
+
|
|
102
|
+
Description: Indicates whether file entries should be included or not.
|
|
103
|
+
|
|
104
|
+
#### includeDirs
|
|
105
|
+
|
|
106
|
+
Type: `boolean`
|
|
107
|
+
|
|
108
|
+
Default: `true`
|
|
109
|
+
|
|
110
|
+
Optional: `true`
|
|
111
|
+
|
|
112
|
+
Description: Indicates whether directory entries should be included or not.
|
|
113
|
+
|
|
114
|
+
#### includeSymlinks
|
|
115
|
+
|
|
116
|
+
Type: `boolean`
|
|
117
|
+
|
|
118
|
+
Default: `true`
|
|
119
|
+
|
|
120
|
+
Optional: `true`
|
|
121
|
+
|
|
122
|
+
Description: Indicates whether symlink entries should be included or not. This option is meaningful only if followSymlinks is set to false.
|
|
123
|
+
|
|
124
|
+
#### followSymlinks
|
|
125
|
+
|
|
126
|
+
Type: `boolean`
|
|
127
|
+
|
|
128
|
+
Default: `false`
|
|
129
|
+
|
|
130
|
+
Optional: `true`
|
|
131
|
+
|
|
132
|
+
Description: Indicates whether symlinks should be resolved or not.
|
|
133
|
+
|
|
134
|
+
#### extensions
|
|
135
|
+
|
|
136
|
+
Type: `string[]`
|
|
137
|
+
|
|
138
|
+
Default: `undefined`
|
|
139
|
+
|
|
140
|
+
Optional: `true`
|
|
141
|
+
|
|
142
|
+
Description: List of file extensions used to filter entries. If specified, entries without the file extension specified by this option are excluded.
|
|
143
|
+
|
|
144
|
+
#### match
|
|
145
|
+
|
|
146
|
+
Type: `(RegExp | string)[]`
|
|
147
|
+
|
|
148
|
+
Default: `undefined`
|
|
149
|
+
|
|
150
|
+
Optional: `true`
|
|
151
|
+
|
|
152
|
+
Description: List of regular expression or [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns used to filter entries. If specified, entries that do not match the patterns specified by this option are excluded.
|
|
153
|
+
|
|
154
|
+
#### skip
|
|
155
|
+
|
|
156
|
+
Type: `(RegExp | string)[]`
|
|
157
|
+
|
|
158
|
+
Default: `undefined`
|
|
159
|
+
|
|
160
|
+
Optional: `true`
|
|
161
|
+
|
|
162
|
+
Description: List of regular expression or [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns used to filter entries. If specified, entries matching the patterns specified by this option are excluded.
|
|
163
|
+
|
|
164
|
+
## findUp
|
|
165
|
+
|
|
166
|
+
Find a file or directory by walking up parent directories.
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { findUp } from "@visulima/fs";
|
|
170
|
+
|
|
171
|
+
// Returns a Promise for the found path or undefined if it could not be found.
|
|
172
|
+
const file = await findUp("package.json");
|
|
173
|
+
|
|
174
|
+
console.log(file);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## findUpSync
|
|
178
|
+
|
|
179
|
+
Find a file or directory by walking up parent directories.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { findUpSync } from "@visulima/fs";
|
|
183
|
+
|
|
184
|
+
// Returns the found path or undefined if it could not be found.
|
|
185
|
+
const file = findUpSync("package.json");
|
|
186
|
+
|
|
187
|
+
console.log(file);
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### API for `findUp` and `findUpSync`
|
|
191
|
+
|
|
192
|
+
#### name
|
|
193
|
+
|
|
194
|
+
Type: `string`
|
|
195
|
+
|
|
196
|
+
The name of the file or directory to find.
|
|
197
|
+
|
|
198
|
+
#### options
|
|
199
|
+
|
|
200
|
+
Type: `object`
|
|
201
|
+
|
|
202
|
+
##### cwd
|
|
203
|
+
|
|
204
|
+
Type: `URL | string`\
|
|
205
|
+
Default: `process.cwd()`
|
|
206
|
+
|
|
207
|
+
The directory to start from.
|
|
208
|
+
|
|
209
|
+
##### type
|
|
210
|
+
|
|
211
|
+
Type: `string`\
|
|
212
|
+
Default: `'file'`\
|
|
213
|
+
Values: `'file' | 'directory'`
|
|
214
|
+
|
|
215
|
+
The type of path to match.
|
|
216
|
+
|
|
217
|
+
##### stopAt
|
|
218
|
+
|
|
219
|
+
Type: `URL | string`\
|
|
220
|
+
Default: Root directory
|
|
221
|
+
|
|
222
|
+
A directory path where the search halts if no matches are found before reaching this point.
|
|
223
|
+
|
|
224
|
+
## Supported Node.js Versions
|
|
225
|
+
|
|
226
|
+
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
227
|
+
Here’s [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
228
|
+
|
|
229
|
+
## Contributing
|
|
230
|
+
|
|
231
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guild.
|
|
232
|
+
|
|
233
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
234
|
+
|
|
235
|
+
## Credits
|
|
236
|
+
|
|
237
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
238
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
The visulima fs is open-sourced software licensed under the [MIT][license-url]
|
|
243
|
+
|
|
244
|
+
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
245
|
+
[typescript-url]: "typescript"
|
|
246
|
+
[license-image]: https://img.shields.io/npm/l/@visulima/fs?color=blueviolet&style=for-the-badge
|
|
247
|
+
[license-url]: LICENSE.md "license"
|
|
248
|
+
[npm-image]: https://img.shields.io/npm/v/@visulima/fs/latest.svg?style=for-the-badge&logo=npm
|
|
249
|
+
[npm-url]: https://www.npmjs.com/package/@visulima/fs/v/latest "npm"
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Dirent } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
interface WalkOptions {
|
|
4
|
+
extensions?: string[];
|
|
5
|
+
followSymlinks?: boolean;
|
|
6
|
+
includeDirs?: boolean;
|
|
7
|
+
includeFiles?: boolean;
|
|
8
|
+
includeSymlinks?: boolean;
|
|
9
|
+
match?: (RegExp | string)[];
|
|
10
|
+
maxDepth?: number;
|
|
11
|
+
skip?: (RegExp | string)[];
|
|
12
|
+
}
|
|
13
|
+
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
|
|
18
|
+
|
|
19
|
+
declare const collectSync: (directory: string, options?: WalkOptions) => string[];
|
|
20
|
+
|
|
21
|
+
declare const findUp: (name: string, options?: {
|
|
22
|
+
cwd?: URL | string;
|
|
23
|
+
stopAt?: URL | string;
|
|
24
|
+
type?: "directory" | "file";
|
|
25
|
+
}) => Promise<string | undefined>;
|
|
26
|
+
|
|
27
|
+
declare const findUpSync: (name: string, options?: {
|
|
28
|
+
cwd?: URL | string;
|
|
29
|
+
stopAt?: URL | string;
|
|
30
|
+
type?: "directory" | "file";
|
|
31
|
+
}) => string | undefined;
|
|
32
|
+
|
|
33
|
+
declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
|
|
34
|
+
|
|
35
|
+
declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
|
|
36
|
+
|
|
37
|
+
export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, walk, walkSync };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Dirent } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
interface WalkOptions {
|
|
4
|
+
extensions?: string[];
|
|
5
|
+
followSymlinks?: boolean;
|
|
6
|
+
includeDirs?: boolean;
|
|
7
|
+
includeFiles?: boolean;
|
|
8
|
+
includeSymlinks?: boolean;
|
|
9
|
+
match?: (RegExp | string)[];
|
|
10
|
+
maxDepth?: number;
|
|
11
|
+
skip?: (RegExp | string)[];
|
|
12
|
+
}
|
|
13
|
+
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
|
|
18
|
+
|
|
19
|
+
declare const collectSync: (directory: string, options?: WalkOptions) => string[];
|
|
20
|
+
|
|
21
|
+
declare const findUp: (name: string, options?: {
|
|
22
|
+
cwd?: URL | string;
|
|
23
|
+
stopAt?: URL | string;
|
|
24
|
+
type?: "directory" | "file";
|
|
25
|
+
}) => Promise<string | undefined>;
|
|
26
|
+
|
|
27
|
+
declare const findUpSync: (name: string, options?: {
|
|
28
|
+
cwd?: URL | string;
|
|
29
|
+
stopAt?: URL | string;
|
|
30
|
+
type?: "directory" | "file";
|
|
31
|
+
}) => string | undefined;
|
|
32
|
+
|
|
33
|
+
declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
|
|
34
|
+
|
|
35
|
+
declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
|
|
36
|
+
|
|
37
|
+
export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, walk, walkSync };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var promises = require('fs/promises');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var url = require('url');
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
|
|
8
|
+
var h=class extends Error{root;constructor(i,r){super(`${i instanceof Error?i.message:i} for path "${r}"`),this.cause=i,this.name="WalkError",this.root=r;}},u=h;var L=e=>{let i=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${i}$`)},g=L;var x=e=>e instanceof URL?url.fileURLToPath(e):e,m=x;var R=(e,i,r,o)=>i&&!i.some(s=>e.endsWith(s))||r&&!r.some(s=>s.test(e))?!1:!(o&&o.some(s=>s.test(e))),y=R;var T=async e=>{let i=path.normalize(e),r=path.basename(i),o=await promises.stat(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};async function*w(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:k}={}){if(a<0)return;let d=c?c.map(t=>typeof t=="string"?g(t):t):void 0,f=k?k.map(t=>typeof t=="string"?g(t):t):void 0;if(e=path.resolve(m(e)),o&&y(e,i,d,f)&&(yield await T(e)),!(a<1||!y(e,void 0,void 0,f)))try{for await(let t of await promises.readdir(e,{withFileTypes:!0})){let n=path.join(e,t.name);if(t.isSymbolicLink())if(r)n=await promises.realpath(n);else if(l&&y(n,i,d,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*w(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:d,maxDepth:a-1,skip:f}):t.isFile()&&s&&y(n,i,d,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof u?t:new u(t,e)}}var A=async(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for await(let s of w(e,r))o.push(s.path);return o},N=A;var q=e=>{let i=path.normalize(e),r=path.basename(i),o=fs.statSync(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};function*b(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:k}={}){if(a<0)return;let d=c?c.map(t=>typeof t=="string"?g(t):t):void 0,f=k?k.map(t=>typeof t=="string"?g(t):t):void 0;if(e=path.resolve(m(e)),o&&y(e,i,d,f)&&(yield q(e)),!(a<1||!y(e,void 0,void 0,f)))try{for(let t of fs.readdirSync(e,{withFileTypes:!0})){let n=path.join(e,t.name);if(t.isSymbolicLink())if(r)n=fs.realpathSync(n);else if(l&&y(n,i,d,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*b(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:d,maxDepth:a-1,skip:f}):t.isFile()&&s&&y(n,i,d,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof u?t:new u(t,e)}}var B=(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for(let s of b(e,r))o.push(s.path);return o},C=B;var X=async(e,i={})=>{let r=path.resolve(i.cwd?m(i.cwd):process.cwd()),{root:o}=path.parse(r),s=path.resolve(r,m(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=path.isAbsolute(e)?e:path.join(r,e);try{let a=await promises.stat(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=path.dirname(r);}},Z=X;var st=(e,i={})=>{let r=path.resolve(i.cwd?m(i.cwd):process.cwd()),{root:o}=path.parse(r),s=path.resolve(r,m(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=path.isAbsolute(e)?e:path.join(r,e);try{let a=fs.statSync(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=path.dirname(r);}},nt=st;
|
|
9
|
+
|
|
10
|
+
exports.collect = N;
|
|
11
|
+
exports.collectSync = C;
|
|
12
|
+
exports.findUp = Z;
|
|
13
|
+
exports.findUpSync = nt;
|
|
14
|
+
exports.walk = w;
|
|
15
|
+
exports.walkSync = b;
|
|
16
|
+
//# sourceMappingURL=out.js.map
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/walk.ts","../src/error/walk-error.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","WalkError","cause","root","walk_error_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsolute","parse","findUp","stopAt","type","filePath","stats","find_up_default","findUpSync","find_up_sync_default"],"mappings":"AAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,cACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,OCDnD,IAAMC,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,c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GAAK4B,EAAWH,CAAI,EAE/D,GAAI,CAEA,IAAM+B,EAAQX,GAASU,CAAQ,EAE/B,GAAKD,IAAS,QAAUE,EAAM,OAAO,GAAOF,IAAS,aAAeE,EAAM,YAAY,EAClF,OAAOD,CAEf,MAAQ,CAER,CAEA3B,EAAYqB,GAAQrB,CAAS,CACjC,CAGJ,EAEO+B,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { readdir, realpath, stat } from 'node:fs/promises';
|
|
2
|
+
import { resolve, join, normalize, basename, parse, isAbsolute, dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { readdirSync, realpathSync, statSync } from 'node:fs';
|
|
5
|
+
|
|
6
|
+
var S=class extends Error{root;constructor(i,r){super(`${i instanceof Error?i.message:i} for path "${r}"`),this.cause=i,this.name="WalkError",this.root=r;}},g=S;var W=e=>{let i=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${i}$`)},k=W;var R=e=>e instanceof URL?fileURLToPath(e):e,y=R;var F=(e,i,r,o)=>i&&!i.some(s=>e.endsWith(s))||r&&!r.some(s=>s.test(e))?!1:!(o&&o.some(s=>s.test(e))),d=F;var A=async e=>{let i=normalize(e),r=basename(i),o=await stat(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};async function*b(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:w}={}){if(a<0)return;let u=c?c.map(t=>typeof t=="string"?k(t):t):void 0,f=w?w.map(t=>typeof t=="string"?k(t):t):void 0;if(e=resolve(y(e)),o&&d(e,i,u,f)&&(yield await A(e)),!(a<1||!d(e,void 0,void 0,f)))try{for await(let t of await readdir(e,{withFileTypes:!0})){let n=join(e,t.name);if(t.isSymbolicLink())if(r)n=await realpath(n);else if(l&&d(n,i,u,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*b(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:u,maxDepth:a-1,skip:f}):t.isFile()&&s&&d(n,i,u,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof g?t:new g(t,e)}}var N=async(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for await(let s of b(e,r))o.push(s.path);return o},$=N;var B=e=>{let i=normalize(e),r=basename(i),o=statSync(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};function*h(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:w}={}){if(a<0)return;let u=c?c.map(t=>typeof t=="string"?k(t):t):void 0,f=w?w.map(t=>typeof t=="string"?k(t):t):void 0;if(e=resolve(y(e)),o&&d(e,i,u,f)&&(yield B(e)),!(a<1||!d(e,void 0,void 0,f)))try{for(let t of readdirSync(e,{withFileTypes:!0})){let n=join(e,t.name);if(t.isSymbolicLink())if(r)n=realpathSync(n);else if(l&&d(n,i,u,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*h(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:u,maxDepth:a-1,skip:f}):t.isFile()&&s&&d(n,i,u,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof g?t:new g(t,e)}}var C=(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for(let s of h(e,r))o.push(s.path);return o},G=C;var Z=async(e,i={})=>{let r=resolve(i.cwd?y(i.cwd):process.cwd()),{root:o}=parse(r),s=resolve(r,y(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=isAbsolute(e)?e:join(r,e);try{let a=await stat(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=dirname(r);}},tt=Z;var nt=(e,i={})=>{let r=resolve(i.cwd?y(i.cwd):process.cwd()),{root:o}=parse(r),s=resolve(r,y(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=isAbsolute(e)?e:join(r,e);try{let a=statSync(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=dirname(r);}},at=nt;
|
|
7
|
+
|
|
8
|
+
export { $ as collect, G as collectSync, tt as findUp, at as findUpSync, b as walk, h as walkSync };
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/walk.ts","../src/error/walk-error.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","WalkError","cause","root","walk_error_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsolute","parse","findUp","stopAt","type","filePath","stats","find_up_default","findUpSync","find_up_sync_default"],"mappings":"AAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,mBACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,YCDnD,IAAMC,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ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ASU,CAAQ,EAE/B,GAAKD,IAAS,QAAUE,EAAM,OAAO,GAAOF,IAAS,aAAeE,EAAM,YAAY,EAClF,OAAOD,CAEf,MAAQ,CAER,CAEA3B,EAAYqB,GAAQrB,CAAS,CACjC,CAGJ,EAEO+B,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@visulima/fs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Human friendly file system utilities for Node.js",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"anolilab",
|
|
7
|
+
"directory",
|
|
8
|
+
"file",
|
|
9
|
+
"find",
|
|
10
|
+
"find-up",
|
|
11
|
+
"findup",
|
|
12
|
+
"folder",
|
|
13
|
+
"look",
|
|
14
|
+
"look-up",
|
|
15
|
+
"match",
|
|
16
|
+
"package",
|
|
17
|
+
"parent",
|
|
18
|
+
"parents",
|
|
19
|
+
"path",
|
|
20
|
+
"fs",
|
|
21
|
+
"resolve",
|
|
22
|
+
"search",
|
|
23
|
+
"up",
|
|
24
|
+
"visulima",
|
|
25
|
+
"walk",
|
|
26
|
+
"walking",
|
|
27
|
+
"filesystem",
|
|
28
|
+
"files"
|
|
29
|
+
],
|
|
30
|
+
"homepage": "https://www.visulima.com/docs/package/fs",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/visulima/visulima.git",
|
|
34
|
+
"directory": "packages/fs"
|
|
35
|
+
},
|
|
36
|
+
"funding": [
|
|
37
|
+
{
|
|
38
|
+
"type": "github",
|
|
39
|
+
"url": "https://github.com/sponsors/prisis"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"type": "consulting",
|
|
43
|
+
"url": "https://anolilab.com/support"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"author": {
|
|
48
|
+
"name": "Daniel Bannert",
|
|
49
|
+
"email": "d.bannert@anolilab.de"
|
|
50
|
+
},
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"exports": {
|
|
53
|
+
".": {
|
|
54
|
+
"require": {
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"default": "./dist/index.js"
|
|
57
|
+
},
|
|
58
|
+
"import": {
|
|
59
|
+
"types": "./dist/index.d.mts",
|
|
60
|
+
"default": "./dist/index.mjs"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"./package.json": "./package.json"
|
|
64
|
+
},
|
|
65
|
+
"main": "dist/index.js",
|
|
66
|
+
"module": "dist/index.mjs",
|
|
67
|
+
"source": "src/index.ts",
|
|
68
|
+
"types": "dist/index.d.ts",
|
|
69
|
+
"files": [
|
|
70
|
+
"dist/**",
|
|
71
|
+
"README.md",
|
|
72
|
+
"CHANGELOG.md",
|
|
73
|
+
"LICENSE.md"
|
|
74
|
+
],
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "cross-env NODE_ENV=development tsup",
|
|
77
|
+
"build:prod": "cross-env NODE_ENV=production tsup",
|
|
78
|
+
"clean": "rimraf node_modules dist .eslintcache",
|
|
79
|
+
"dev": "pnpm run build --watch",
|
|
80
|
+
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js",
|
|
81
|
+
"lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js --fix",
|
|
82
|
+
"lint:packagejson": "publint --strict",
|
|
83
|
+
"lint:prettier": "prettier --config=.prettierrc.js --check .",
|
|
84
|
+
"lint:prettier:fix": "prettier --config=.prettierrc.js --write .",
|
|
85
|
+
"lint:types": "tsc --noEmit",
|
|
86
|
+
"test": "vitest run",
|
|
87
|
+
"test:coverage": "vitest run --coverage",
|
|
88
|
+
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
89
|
+
"test:watch": "vitest"
|
|
90
|
+
},
|
|
91
|
+
"devDependencies": {
|
|
92
|
+
"@anolilab/eslint-config": "^15.0.3",
|
|
93
|
+
"@anolilab/prettier-config": "^5.0.14",
|
|
94
|
+
"@anolilab/semantic-release-preset": "^8.0.3",
|
|
95
|
+
"@babel/core": "^7.24.0",
|
|
96
|
+
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
97
|
+
"@types/micromatch": "^4.0.6",
|
|
98
|
+
"@types/node": "18.18.14",
|
|
99
|
+
"@vitest/coverage-v8": "^1.3.1",
|
|
100
|
+
"@vitest/ui": "^1.3.1",
|
|
101
|
+
"cross-env": "^7.0.3",
|
|
102
|
+
"eslint": "^8.57.0",
|
|
103
|
+
"eslint-plugin-deprecation": "^2.0.0",
|
|
104
|
+
"eslint-plugin-etc": "^2.0.3",
|
|
105
|
+
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
106
|
+
"eslint-plugin-mdx": "^3.1.5",
|
|
107
|
+
"eslint-plugin-vitest": "^0.3.22",
|
|
108
|
+
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
109
|
+
"prettier": "^3.2.5",
|
|
110
|
+
"rimraf": "^5.0.5",
|
|
111
|
+
"semantic-release": "^23.0.2",
|
|
112
|
+
"sort-package-json": "^2.8.0",
|
|
113
|
+
"tempy": "^3.1.0",
|
|
114
|
+
"tsup": "^8.0.2",
|
|
115
|
+
"typescript": "^5.4.2",
|
|
116
|
+
"vitest": "^1.3.1"
|
|
117
|
+
},
|
|
118
|
+
"engines": {
|
|
119
|
+
"node": ">=18.* <=21.*"
|
|
120
|
+
},
|
|
121
|
+
"publishConfig": {
|
|
122
|
+
"access": "public",
|
|
123
|
+
"provenance": true
|
|
124
|
+
},
|
|
125
|
+
"anolilab": {
|
|
126
|
+
"eslint-config": {
|
|
127
|
+
"plugin": {
|
|
128
|
+
"tsdoc": false
|
|
129
|
+
},
|
|
130
|
+
"warn_on_unsupported_typescript_version": false,
|
|
131
|
+
"info_on_disabling_jsx_react_rule": false,
|
|
132
|
+
"info_on_disabling_prettier_conflict_rule": false,
|
|
133
|
+
"info_on_disabling_jsonc_sort_keys_rule": false,
|
|
134
|
+
"info_on_disabling_etc_no_deprecated": false
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|