@rush-fs/core 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +503 -0
- package/README.zh-CN.md +502 -0
- package/index.d.ts +251 -0
- package/index.js +786 -0
- package/package.json +126 -0
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Rush-FS
|
|
4
|
+
|
|
5
|
+
[English](./README.md) | 中文
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://img.shields.io/badge/Written%20in-Rust-orange?style=flat-square" alt="Written in Rust">
|
|
9
|
+
<img src="https://img.shields.io/npm/v/@rush-fs/core?style=flat-square" alt="NPM Version">
|
|
10
|
+
<img src="https://img.shields.io/npm/l/@rush-fs/core?style=flat-square" alt="License">
|
|
11
|
+
<img src="https://img.shields.io/badge/status-alpha-orange?style=flat-square" alt="Alpha">
|
|
12
|
+
<a href="https://github.com/CoderSerio/rush-fs/graphs/contributors"><img src="https://img.shields.io/github/contributors/CoderSerio/rush-fs?style=flat-square" alt="Contributors"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
与 Node.js <code>fs</code> API 对齐,可无痛替换现有项目中的 fs;在海量文件操作场景下获得数倍于内置 fs 的性能,由 Rust 驱动。
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center"><strong>⚠️ Alpha:</strong>当前为 <strong>alpha</strong> 版本,在 0.1.0 正式版前 API 与行为可能变更。</p>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @rush-fs/core
|
|
26
|
+
# or
|
|
27
|
+
pnpm add @rush-fs/core
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
安装 `@rush-fs/core` 时,包管理器会通过 `optionalDependencies` 自动安装**当前平台**的本地绑定(例如 macOS ARM 上的 `@rush-fs/rush-fs-darwin-arm64`)。若未安装或出现「Cannot find native binding」:
|
|
31
|
+
|
|
32
|
+
1. 删除 `node_modules` 和锁文件(`package-lock.json` 或 `pnpm-lock.yaml`)后重新执行 `pnpm install`(或 `npm i`)。
|
|
33
|
+
2. 或手动安装对应平台包:
|
|
34
|
+
**macOS ARM:** `pnpm add @rush-fs/rush-fs-darwin-arm64`
|
|
35
|
+
**macOS x64:** `pnpm add @rush-fs/rush-fs-darwin-x64`
|
|
36
|
+
**Windows x64:** `pnpm add @rush-fs/rush-fs-win32-x64-msvc`
|
|
37
|
+
**Linux x64 (glibc):** `pnpm add @rush-fs/rush-fs-linux-x64-gnu`
|
|
38
|
+
|
|
39
|
+
**从 `rush-fs` 迁移:** 自 0.1.0-alpha 起主包更名为 `@rush-fs/core`,详见 [CHANGELOG.md](./CHANGELOG.md#010-alpha0)。
|
|
40
|
+
|
|
41
|
+
## 用法
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { readdir, stat, readFile, writeFile, mkdir, rm } from '@rush-fs/core'
|
|
45
|
+
|
|
46
|
+
// 读取目录
|
|
47
|
+
const files = await readdir('./src')
|
|
48
|
+
|
|
49
|
+
// 递归 + 返回文件类型
|
|
50
|
+
const entries = await readdir('./src', {
|
|
51
|
+
recursive: true,
|
|
52
|
+
withFileTypes: true,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// 读写文件
|
|
56
|
+
const content = await readFile('./package.json', { encoding: 'utf8' })
|
|
57
|
+
await writeFile('./output.txt', 'hello world')
|
|
58
|
+
|
|
59
|
+
// 文件信息
|
|
60
|
+
const s = await stat('./package.json')
|
|
61
|
+
console.log(s.size, s.isFile())
|
|
62
|
+
|
|
63
|
+
// 创建目录
|
|
64
|
+
await mkdir('./new-dir', { recursive: true })
|
|
65
|
+
|
|
66
|
+
// 删除
|
|
67
|
+
await rm('./temp', { recursive: true, force: true })
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 性能基准
|
|
71
|
+
|
|
72
|
+
> 测试环境:Apple Silicon (arm64),Node.js 24.0.2,release 构建(开启 LTO)。
|
|
73
|
+
> 运行 `pnpm build && pnpm bench` 可复现。
|
|
74
|
+
|
|
75
|
+
### Rush-FS 显著更快的场景
|
|
76
|
+
|
|
77
|
+
这些场景中 Rust 的并行遍历和零拷贝 I/O 发挥了真正优势:
|
|
78
|
+
|
|
79
|
+
| 场景 | Node.js | Rush-FS | 加速比 |
|
|
80
|
+
| ------------------------------------------- | --------- | -------- | --------- |
|
|
81
|
+
| `readdir` 递归(node_modules,约 3 万条目) | 281 ms | 23 ms | **12x** |
|
|
82
|
+
| `glob` 递归(`**/*.rs`) | 25 ms | 1.46 ms | **17x** |
|
|
83
|
+
| `glob` 递归 vs fast-glob | 102 ms | 1.46 ms | **70x** |
|
|
84
|
+
| `copyFile` 4 MB | 4.67 ms | 0.09 ms | **50x** |
|
|
85
|
+
| `readFile` 4 MB utf8 | 1.86 ms | 0.92 ms | **2x** |
|
|
86
|
+
| `readFile` 64 KB utf8 | 42 µs | 18 µs | **2.4x** |
|
|
87
|
+
| `rm` 2000 个文件(4 线程) | 92 ms | 53 ms | **1.75x** |
|
|
88
|
+
| `access` R_OK(目录) | 4.18 µs | 1.55 µs | **2.7x** |
|
|
89
|
+
| `cp` 500 文件平铺目录(4 线程) | 86.45 ms | 32.88 ms | **2.6x** |
|
|
90
|
+
| `cp` 树形目录 ~363 节点(4 线程) | 108.73 ms | 46.88 ms | **2.3x** |
|
|
91
|
+
|
|
92
|
+
### 与 Node.js 持平的场景
|
|
93
|
+
|
|
94
|
+
单文件操作有约 0.3 µs 的 napi 桥接开销,整体表现基本一致:
|
|
95
|
+
|
|
96
|
+
| 场景 | Node.js | Rush-FS | 比率 |
|
|
97
|
+
| ---------------------------- | ------- | ------- | ---- |
|
|
98
|
+
| `stat`(单文件) | 1.45 µs | 1.77 µs | 1.2x |
|
|
99
|
+
| `readFile` 小文件(Buffer) | 8.86 µs | 9.46 µs | 1.1x |
|
|
100
|
+
| `writeFile` 小文件(string) | 74 µs | 66 µs | 0.9x |
|
|
101
|
+
| `writeFile` 小文件(Buffer) | 115 µs | 103 µs | 0.9x |
|
|
102
|
+
| `appendFile` | 30 µs | 27 µs | 0.9x |
|
|
103
|
+
|
|
104
|
+
### Node.js 更快的场景
|
|
105
|
+
|
|
106
|
+
极轻量级的内置调用,napi 开销占比较大:
|
|
107
|
+
|
|
108
|
+
| 场景 | Node.js | Rush-FS | 说明 |
|
|
109
|
+
| -------------------------- | ------- | ------- | ------------------------ |
|
|
110
|
+
| `existsSync`(已存在文件) | 444 ns | 1.34 µs | Node.js 内部有 fast path |
|
|
111
|
+
| `accessSync` F_OK | 456 ns | 1.46 µs | 同上——napi 开销占主导 |
|
|
112
|
+
| `writeFile` 4 MB string | 2.93 ms | 5.69 ms | 大字符串跨 napi 桥传输 |
|
|
113
|
+
|
|
114
|
+
### 并行支持
|
|
115
|
+
|
|
116
|
+
Rush-FS 在文件系统遍历类操作中使用多线程并行:
|
|
117
|
+
|
|
118
|
+
| API | 并行库 | `concurrency` 选项 | 默认值 |
|
|
119
|
+
| ----------------- | ------------------------------------------------------------------------- | ------------------ | ------ |
|
|
120
|
+
| `readdir`(递归) | [jwalk](https://github.com/Byron/jwalk) | ✅ | auto |
|
|
121
|
+
| `glob` | [ignore](https://github.com/BurntSushi/ripgrep/tree/master/crates/ignore) | ✅ | 4 |
|
|
122
|
+
| `rm`(递归) | [rayon](https://github.com/rayon-rs/rayon) | ✅ | 1 |
|
|
123
|
+
| `cp`(递归) | [rayon](https://github.com/rayon-rs/rayon) | ✅ | 1 |
|
|
124
|
+
|
|
125
|
+
单文件操作(`stat`、`readFile`、`writeFile`、`chmod` 等)是原子系统调用,不适用并行化。
|
|
126
|
+
|
|
127
|
+
### 核心结论
|
|
128
|
+
|
|
129
|
+
**Rush-FS 在递归/批量文件系统操作上表现卓越**(readdir、glob、rm、cp),Rust 的并行遍历器带来 2–70 倍加速。单文件操作与 Node.js 基本持平。napi 桥接带来固定约 0.3 µs 的每次调用开销,仅在亚微秒级操作(如 `existsSync`)中有感知。
|
|
130
|
+
|
|
131
|
+
**`cp` 基准详情**(Apple Silicon,release 构建):
|
|
132
|
+
|
|
133
|
+
| 场景 | Node.js | Rush-FS 1 线程 | Rush-FS 4 线程 | Rush-FS 8 线程 |
|
|
134
|
+
| ------------------------------------- | --------- | -------------- | -------------- | -------------- |
|
|
135
|
+
| 平铺目录(500 文件) | 86.45 ms | 61.56 ms | 32.88 ms | 36.67 ms |
|
|
136
|
+
| 树形目录(宽度=4,深度=3,~84 节点) | 23.80 ms | 16.94 ms | 10.62 ms | 9.76 ms |
|
|
137
|
+
| 树形目录(宽度=3,深度=5,~363 节点) | 108.73 ms | 75.39 ms | 46.88 ms | 46.18 ms |
|
|
138
|
+
|
|
139
|
+
`cp` 的最优并发数在 Apple Silicon 上为 **4 线程**——超过后受 I/O 带宽限制,收益趋于平稳。
|
|
140
|
+
|
|
141
|
+
## 工作原理
|
|
142
|
+
|
|
143
|
+
Node.js 原生的 fs 在底层串行执行,且需要较多内存将系统对象与字符串解析为 JS 形式:
|
|
144
|
+
|
|
145
|
+
```mermaid
|
|
146
|
+
graph TD
|
|
147
|
+
A["JS: readdir"] -->|Call| B("Node.js C++ Binding")
|
|
148
|
+
B -->|Submit Task| C{"Libuv Thread Pool"}
|
|
149
|
+
|
|
150
|
+
subgraph "Native Layer (Serial)"
|
|
151
|
+
C -->|"Syscall: getdents"| D[OS Kernel]
|
|
152
|
+
D -->|"Return File List"| C
|
|
153
|
+
C -->|"Process Paths"| C
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
C -->|"Results Ready"| E("V8 Main Thread")
|
|
157
|
+
|
|
158
|
+
subgraph "V8 Interaction (Heavy)"
|
|
159
|
+
E -->|"Create JS String 1"| F[V8 Heap]
|
|
160
|
+
E -->|"String 2"| F
|
|
161
|
+
E -->|"String N..."| F
|
|
162
|
+
F -->|"GC Pressure Rising"| F
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
E -->|"Return Array"| G["JS Callback/Promise"]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Rust 实现则把重计算放在 Rust 侧,减少与 V8 的交互与 GC 压力:
|
|
169
|
+
|
|
170
|
+
```mermaid
|
|
171
|
+
graph TD
|
|
172
|
+
A["JS: readdir"] -->|"N-API Call"| B("Rust Wrapper")
|
|
173
|
+
B -->|"Spawn Thread/Task"| C{"Rust Thread Pool"}
|
|
174
|
+
|
|
175
|
+
subgraph "Rust 'Black Box'"
|
|
176
|
+
C -->|"Rayon: Parallel work"| D[OS Kernel]
|
|
177
|
+
D -->|"Syscall: getdents"| C
|
|
178
|
+
C -->|"Store as Rust Vec<String>"| H[Rust Heap]
|
|
179
|
+
H -->|"No V8 Interaction yet"| H
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
C -->|"All Done"| I("Convert to JS")
|
|
183
|
+
|
|
184
|
+
subgraph "N-API Bridge"
|
|
185
|
+
I -->|"Batch Create JS Array"| J[V8 Heap]
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
J -->|Return| K["JS Result"]
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 状态与路线图
|
|
192
|
+
|
|
193
|
+
我们正在逐个重写 `fs` 的 API。
|
|
194
|
+
|
|
195
|
+
> **图例**
|
|
196
|
+
>
|
|
197
|
+
> - ✅:完全支持
|
|
198
|
+
> - 🚧:部分支持 / 开发中
|
|
199
|
+
> - ✨:@rush-fs/core 的新增能力
|
|
200
|
+
> - ❌:暂未支持
|
|
201
|
+
|
|
202
|
+
### `readdir`
|
|
203
|
+
|
|
204
|
+
- **Node.js 参数**:
|
|
205
|
+
```ts
|
|
206
|
+
path: string; // ✅
|
|
207
|
+
options?: {
|
|
208
|
+
encoding?: string; // 🚧(默认 'utf8';'buffer' 暂不支持)
|
|
209
|
+
withFileTypes?: boolean; // ✅
|
|
210
|
+
recursive?: boolean; // ✅
|
|
211
|
+
concurrency?: number; // ✨
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
- **返回类型**:
|
|
215
|
+
```ts
|
|
216
|
+
string[]
|
|
217
|
+
| {
|
|
218
|
+
name: string, // ✅
|
|
219
|
+
parentPath: string, // ✅
|
|
220
|
+
isDir: boolean // ✅
|
|
221
|
+
}[]
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### `readFile`
|
|
225
|
+
|
|
226
|
+
- **Node.js 参数**:
|
|
227
|
+
```ts
|
|
228
|
+
path: string; // ✅
|
|
229
|
+
options?: {
|
|
230
|
+
encoding?: string; // ✅ (utf8, ascii, latin1, base64, base64url, hex)
|
|
231
|
+
flag?: string; // ✅ (r, r+, w+, a+ 等)
|
|
232
|
+
};
|
|
233
|
+
```
|
|
234
|
+
- **返回类型**:`string | Buffer`
|
|
235
|
+
|
|
236
|
+
### `writeFile`
|
|
237
|
+
|
|
238
|
+
- **Node.js 参数**:
|
|
239
|
+
```ts
|
|
240
|
+
path: string; // ✅
|
|
241
|
+
data: string | Buffer; // ✅
|
|
242
|
+
options?: {
|
|
243
|
+
encoding?: string; // ✅ (utf8, ascii, latin1, base64, base64url, hex)
|
|
244
|
+
mode?: number; // ✅
|
|
245
|
+
flag?: string; // ✅ (w, wx, a, ax)
|
|
246
|
+
};
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### `appendFile`
|
|
250
|
+
|
|
251
|
+
- **Node.js 参数**:
|
|
252
|
+
```ts
|
|
253
|
+
path: string; // ✅
|
|
254
|
+
data: string | Buffer; // ✅
|
|
255
|
+
options?: {
|
|
256
|
+
encoding?: string; // ✅ (utf8, ascii, latin1, base64, base64url, hex)
|
|
257
|
+
mode?: number; // ✅
|
|
258
|
+
flag?: string; // ✅
|
|
259
|
+
};
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### `copyFile`
|
|
263
|
+
|
|
264
|
+
- **Node.js 参数**:
|
|
265
|
+
```ts
|
|
266
|
+
src: string; // ✅
|
|
267
|
+
dest: string; // ✅
|
|
268
|
+
mode?: number; // ✅ (COPYFILE_EXCL)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### `cp`
|
|
272
|
+
|
|
273
|
+
- **Node.js 参数**(Node 16.7+):
|
|
274
|
+
```ts
|
|
275
|
+
src: string; // ✅
|
|
276
|
+
dest: string; // ✅
|
|
277
|
+
options?: {
|
|
278
|
+
recursive?: boolean; // ✅
|
|
279
|
+
force?: boolean; // ✅(默认 true)
|
|
280
|
+
errorOnExist?: boolean; // ✅
|
|
281
|
+
preserveTimestamps?: boolean; // ✅
|
|
282
|
+
dereference?: boolean; // ✅
|
|
283
|
+
verbatimSymlinks?: boolean; // ✅
|
|
284
|
+
concurrency?: number; // ✨
|
|
285
|
+
};
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### `mkdir`
|
|
289
|
+
|
|
290
|
+
- **Node.js 参数**:
|
|
291
|
+
```ts
|
|
292
|
+
path: string; // ✅
|
|
293
|
+
options?: {
|
|
294
|
+
recursive?: boolean; // ✅
|
|
295
|
+
mode?: number; // ✅
|
|
296
|
+
};
|
|
297
|
+
```
|
|
298
|
+
- **返回类型**:`string | undefined`(recursive 模式下返回首个创建的路径)
|
|
299
|
+
|
|
300
|
+
### `rm`
|
|
301
|
+
|
|
302
|
+
- **Node.js 参数**:
|
|
303
|
+
```ts
|
|
304
|
+
path: string; // ✅
|
|
305
|
+
options?: {
|
|
306
|
+
force?: boolean; // ✅
|
|
307
|
+
maxRetries?: number; // ✅
|
|
308
|
+
retryDelay?: number; // ✅(默认 100ms)
|
|
309
|
+
recursive?: boolean; // ✅
|
|
310
|
+
concurrency?: number; // ✨
|
|
311
|
+
};
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### `rmdir`
|
|
315
|
+
|
|
316
|
+
- **Node.js 参数**:
|
|
317
|
+
```ts
|
|
318
|
+
path: string // ✅
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### `stat`
|
|
322
|
+
|
|
323
|
+
- **Node.js 参数**:
|
|
324
|
+
```ts
|
|
325
|
+
path: string // ✅
|
|
326
|
+
```
|
|
327
|
+
- **返回类型**:`Stats`
|
|
328
|
+
- 数值字段:`dev`, `mode`, `nlink`, `uid`, `gid`, `rdev`, `blksize`, `ino`, `size`, `blocks`, `atimeMs`, `mtimeMs`, `ctimeMs`, `birthtimeMs`
|
|
329
|
+
- **Date 字段**:`atime`, `mtime`, `ctime`, `birthtime` → `Date` 对象 ✅
|
|
330
|
+
- 方法:`isFile()`, `isDirectory()`, `isSymbolicLink()`, ...
|
|
331
|
+
- **错误区分**:`ENOENT` vs `EACCES` ✅
|
|
332
|
+
|
|
333
|
+
### `lstat`
|
|
334
|
+
|
|
335
|
+
- **Node.js 参数**:
|
|
336
|
+
```ts
|
|
337
|
+
path: string // ✅
|
|
338
|
+
```
|
|
339
|
+
- **返回类型**:`Stats`
|
|
340
|
+
|
|
341
|
+
### `fstat`
|
|
342
|
+
|
|
343
|
+
- **状态**:❌
|
|
344
|
+
|
|
345
|
+
### `access`
|
|
346
|
+
|
|
347
|
+
- **Node.js 参数**:
|
|
348
|
+
```ts
|
|
349
|
+
path: string; // ✅
|
|
350
|
+
mode?: number; // ✅ (F_OK, R_OK, W_OK, X_OK)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### `exists`
|
|
354
|
+
|
|
355
|
+
- **Node.js 参数**:
|
|
356
|
+
```ts
|
|
357
|
+
path: string // ✅
|
|
358
|
+
```
|
|
359
|
+
- **返回类型**:`boolean`
|
|
360
|
+
|
|
361
|
+
### `open`
|
|
362
|
+
|
|
363
|
+
- **状态**:❌
|
|
364
|
+
|
|
365
|
+
### `opendir`
|
|
366
|
+
|
|
367
|
+
- **状态**:❌
|
|
368
|
+
|
|
369
|
+
### `close`
|
|
370
|
+
|
|
371
|
+
- **状态**:❌
|
|
372
|
+
|
|
373
|
+
### `unlink`
|
|
374
|
+
|
|
375
|
+
- **Node.js 参数**:
|
|
376
|
+
```ts
|
|
377
|
+
path: string // ✅
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### `rename`
|
|
381
|
+
|
|
382
|
+
- **Node.js 参数**:
|
|
383
|
+
```ts
|
|
384
|
+
oldPath: string // ✅
|
|
385
|
+
newPath: string // ✅
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### `readlink`
|
|
389
|
+
|
|
390
|
+
- **Node.js 参数**:
|
|
391
|
+
```ts
|
|
392
|
+
path: string // ✅
|
|
393
|
+
```
|
|
394
|
+
- **返回类型**:`string`
|
|
395
|
+
|
|
396
|
+
### `realpath`
|
|
397
|
+
|
|
398
|
+
- **Node.js 参数**:
|
|
399
|
+
```ts
|
|
400
|
+
path: string // ✅
|
|
401
|
+
```
|
|
402
|
+
- **返回类型**:`string`
|
|
403
|
+
|
|
404
|
+
### `chmod`
|
|
405
|
+
|
|
406
|
+
- **Node.js 参数**:
|
|
407
|
+
```ts
|
|
408
|
+
path: string // ✅
|
|
409
|
+
mode: number // ✅
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### `chown`
|
|
413
|
+
|
|
414
|
+
- **Node.js 参数**:
|
|
415
|
+
```ts
|
|
416
|
+
path: string // ✅
|
|
417
|
+
uid: number // ✅
|
|
418
|
+
gid: number // ✅
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### `utimes`
|
|
422
|
+
|
|
423
|
+
- **Node.js 参数**:
|
|
424
|
+
```ts
|
|
425
|
+
path: string // ✅
|
|
426
|
+
atime: number // ✅
|
|
427
|
+
mtime: number // ✅
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### `truncate`
|
|
431
|
+
|
|
432
|
+
- **Node.js 参数**:
|
|
433
|
+
```ts
|
|
434
|
+
path: string; // ✅
|
|
435
|
+
len?: number; // ✅
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### `glob`
|
|
439
|
+
|
|
440
|
+
- **Node.js 参数**:
|
|
441
|
+
```ts
|
|
442
|
+
pattern: string; // ✅
|
|
443
|
+
options?: {
|
|
444
|
+
cwd?: string; // ✅
|
|
445
|
+
withFileTypes?: boolean; // ✅
|
|
446
|
+
exclude?: string[]; // ✅
|
|
447
|
+
concurrency?: number; // ✨
|
|
448
|
+
gitIgnore?: boolean; // ✨
|
|
449
|
+
};
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### `symlink`
|
|
453
|
+
|
|
454
|
+
- **Node.js 参数**:
|
|
455
|
+
```ts
|
|
456
|
+
target: string // ✅
|
|
457
|
+
path: string // ✅
|
|
458
|
+
type?: 'file' | 'dir' | 'junction' // ✅(仅 Windows 有效,Unix 忽略)
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### `link`
|
|
462
|
+
|
|
463
|
+
- **Node.js 参数**:
|
|
464
|
+
```ts
|
|
465
|
+
existingPath: string // ✅
|
|
466
|
+
newPath: string // ✅
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### `mkdtemp`
|
|
470
|
+
|
|
471
|
+
- **Node.js 参数**:
|
|
472
|
+
```ts
|
|
473
|
+
prefix: string // ✅
|
|
474
|
+
```
|
|
475
|
+
- **返回类型**:`string`
|
|
476
|
+
- 使用系统随机源(Unix: `/dev/urandom`,Windows: `BCryptGenRandom`),最多重试 10 次 ✅
|
|
477
|
+
|
|
478
|
+
### `watch`
|
|
479
|
+
|
|
480
|
+
- **状态**:❌
|
|
481
|
+
|
|
482
|
+
## 更新日志
|
|
483
|
+
|
|
484
|
+
各版本变更见 [CHANGELOG.md](./CHANGELOG.md)。发布 tag 列表见 [GitHub Releases](https://github.com/CoderSerio/rush-fs/releases)。
|
|
485
|
+
|
|
486
|
+
## 贡献
|
|
487
|
+
|
|
488
|
+
参阅 [CONTRIBUTING-CN.md](./CONTRIBUTING-CN.md) 获取完整开发指南:环境搭建、参考 Node.js 源码、编写 Rust 实现、测试与性能基准。
|
|
489
|
+
|
|
490
|
+
## 发布(维护者专用)
|
|
491
|
+
|
|
492
|
+
发布由 [Release 工作流](.github/workflows/Release.yml) 完成:在 macOS(x64/arm64)、Windows、Linux 上构建原生二进制,并发布各平台包与主包到 npm。
|
|
493
|
+
|
|
494
|
+
1. **Secrets:** 在仓库 **Settings → Secrets and variables → Actions** 中添加 **NPM_TOKEN**(npm Classic 或 Automation token,需具备 Publish 权限)。
|
|
495
|
+
2. **发布:** 在 **Actions → Release → Run workflow** 中手动运行(使用当前 `main` 上的 `package.json` 版本),或先更新 `package.json` 与 `Cargo.toml` 中的版本号并推送到 `main`,再创建并推送 tag:`git tag v<版本号> && git push origin v<版本号>`。
|
|
496
|
+
3. **更新日志:** 发布前或发布后更新 [CHANGELOG.md](./CHANGELOG.md)(将 `[Unreleased]` 下的条目移到新版本标题下并补充 compare 链接)。
|
|
497
|
+
|
|
498
|
+
工作流会自动注入 `optionalDependencies` 并发布所有包,无需在 `package.json` 中手动填写。
|
|
499
|
+
|
|
500
|
+
## 许可证
|
|
501
|
+
|
|
502
|
+
MIT
|