rush-fs 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -28
- package/README.zh-CN.md +62 -28
- package/index.d.ts +2 -2
- package/index.js +138 -134
- package/package.json +25 -22
package/README.md
CHANGED
|
@@ -1,21 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Rush-FS
|
|
2
4
|
|
|
3
5
|
<p align="center">
|
|
4
6
|
<img src="https://img.shields.io/badge/Written%20in-Rust-orange?style=flat-square" alt="Written in Rust">
|
|
5
|
-
<img src="https://img.shields.io/npm/v/
|
|
6
|
-
<img src="https://img.shields.io/npm/l/
|
|
7
|
+
<img src="https://img.shields.io/npm/v/rush-fs?style=flat-square" alt="NPM Version">
|
|
8
|
+
<img src="https://img.shields.io/npm/l/rush-fs?style=flat-square" alt="License">
|
|
7
9
|
</p>
|
|
8
10
|
|
|
9
11
|
<p align="center">
|
|
10
12
|
A high-performance, drop-in replacement for Node.js <code>fs</code> module, powered by Rust.
|
|
11
13
|
</p>
|
|
12
14
|
|
|
15
|
+
</div>
|
|
16
|
+
|
|
13
17
|
## Installation
|
|
14
18
|
|
|
15
19
|
```bash
|
|
16
|
-
npm install
|
|
20
|
+
npm install rush-fs
|
|
17
21
|
# or
|
|
18
|
-
pnpm add
|
|
22
|
+
pnpm add rush-fs
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## How does it works
|
|
26
|
+
|
|
27
|
+
For the original Node.js, it works serially and cost lots of memory to parse os object and string into JS style:
|
|
28
|
+
|
|
29
|
+
```mermaid
|
|
30
|
+
graph TD
|
|
31
|
+
A["JS: readdir"] -->|Call| B("Node.js C++ Binding")
|
|
32
|
+
B -->|Submit Task| C{"Libuv Thread Pool"}
|
|
33
|
+
|
|
34
|
+
subgraph "Native Layer (Serial)"
|
|
35
|
+
C -->|"Syscall: getdents"| D[OS Kernel]
|
|
36
|
+
D -->|"Return File List"| C
|
|
37
|
+
C -->|"Process Paths"| C
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
C -->|"Results Ready"| E("V8 Main Thread")
|
|
41
|
+
|
|
42
|
+
subgraph "V8 Interaction (Heavy)"
|
|
43
|
+
E -->|"Create JS String 1"| F[V8 Heap]
|
|
44
|
+
E -->|"String 2"| F
|
|
45
|
+
E -->|"String N..."| F
|
|
46
|
+
F -->|"GC Pressure Rising"| F
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
E -->|"Return Array"| G["JS Callback/Promise"]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
But, it's saved with Rust now:
|
|
53
|
+
|
|
54
|
+
```mermaid
|
|
55
|
+
graph TD
|
|
56
|
+
A["JS: readdir"] -->|"N-API Call"| B("Rust Wrapper")
|
|
57
|
+
B -->|"Spawn Thread/Task"| C{"Rust Thread Pool"}
|
|
58
|
+
|
|
59
|
+
subgraph "Rust 'Black Box'"
|
|
60
|
+
C -->|"Rayon: Parallel work"| D[OS Kernel]
|
|
61
|
+
D -->|"Syscall: getdents"| C
|
|
62
|
+
C -->|"Store as Rust Vec<String>"| H[Rust Heap]
|
|
63
|
+
H -->|"No V8 Interaction yet"| H
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
C -->|"All Done"| I("Convert to JS")
|
|
67
|
+
|
|
68
|
+
subgraph "N-API Bridge"
|
|
69
|
+
I -->|"Batch Create JS Array"| J[V8 Heap]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
J -->|Return| K["JS Result"]
|
|
19
73
|
```
|
|
20
74
|
|
|
21
75
|
## Status & Roadmap
|
|
@@ -26,7 +80,7 @@ We are rewriting `fs` APIs one by one.
|
|
|
26
80
|
>
|
|
27
81
|
> - ✅: Fully Supported
|
|
28
82
|
> - 🚧: Partially Supported / WIP
|
|
29
|
-
> - ✨:New feature from
|
|
83
|
+
> - ✨:New feature from rush-fs
|
|
30
84
|
> - ❌: Not Supported Yet
|
|
31
85
|
|
|
32
86
|
### `readdir`
|
|
@@ -312,7 +366,7 @@ We are rewriting `fs` APIs one by one.
|
|
|
312
366
|
## Usage
|
|
313
367
|
|
|
314
368
|
```ts
|
|
315
|
-
import { readdir, stat, readFile, writeFile, mkdir, rm } from '
|
|
369
|
+
import { readdir, stat, readFile, writeFile, mkdir, rm } from 'rush-fs'
|
|
316
370
|
|
|
317
371
|
// Read directory
|
|
318
372
|
const files = await readdir('./src')
|
|
@@ -343,11 +397,11 @@ await rm('./temp', { recursive: true, force: true })
|
|
|
343
397
|
> Tested on Apple Silicon (arm64), Node.js 24.0.2, release build with LTO.
|
|
344
398
|
> Run `pnpm build && pnpm bench` to reproduce.
|
|
345
399
|
|
|
346
|
-
### Where
|
|
400
|
+
### Where Rush-FS Shines
|
|
347
401
|
|
|
348
402
|
These are the scenarios where Rust's parallelism and zero-copy I/O make a real difference:
|
|
349
403
|
|
|
350
|
-
| Scenario | Node.js |
|
|
404
|
+
| Scenario | Node.js | Rush-FS | Speedup |
|
|
351
405
|
| ------------------------------------------------ | --------- | -------- | --------- |
|
|
352
406
|
| `readdir` recursive (node_modules, ~30k entries) | 281 ms | 23 ms | **12x** |
|
|
353
407
|
| `glob` recursive (`**/*.rs`) | 25 ms | 1.46 ms | **17x** |
|
|
@@ -364,27 +418,27 @@ These are the scenarios where Rust's parallelism and zero-copy I/O make a real d
|
|
|
364
418
|
|
|
365
419
|
Single-file operations have a ~0.3 µs napi bridge overhead, making them roughly equivalent:
|
|
366
420
|
|
|
367
|
-
| Scenario | Node.js |
|
|
368
|
-
| -------------------------- | ------- |
|
|
369
|
-
| `stat` (single file) | 1.45 µs | 1.77 µs
|
|
370
|
-
| `readFile` small (Buffer) | 8.86 µs | 9.46 µs
|
|
371
|
-
| `writeFile` small (string) | 74 µs | 66 µs
|
|
372
|
-
| `writeFile` small (Buffer) | 115 µs | 103 µs
|
|
373
|
-
| `appendFile` | 30 µs | 27 µs
|
|
421
|
+
| Scenario | Node.js | Rush-FS | Ratio |
|
|
422
|
+
| -------------------------- | ------- | ------- | ----- |
|
|
423
|
+
| `stat` (single file) | 1.45 µs | 1.77 µs | 1.2x |
|
|
424
|
+
| `readFile` small (Buffer) | 8.86 µs | 9.46 µs | 1.1x |
|
|
425
|
+
| `writeFile` small (string) | 74 µs | 66 µs | 0.9x |
|
|
426
|
+
| `writeFile` small (Buffer) | 115 µs | 103 µs | 0.9x |
|
|
427
|
+
| `appendFile` | 30 µs | 27 µs | 0.9x |
|
|
374
428
|
|
|
375
429
|
### Where Node.js Wins
|
|
376
430
|
|
|
377
431
|
Lightweight built-in calls where napi overhead is proportionally large:
|
|
378
432
|
|
|
379
|
-
| Scenario | Node.js |
|
|
380
|
-
| ---------------------------- | ------- |
|
|
381
|
-
| `existsSync` (existing file) | 444 ns | 1.34 µs
|
|
382
|
-
| `accessSync` F_OK | 456 ns | 1.46 µs
|
|
383
|
-
| `writeFile` 4 MB string | 2.93 ms | 5.69 ms
|
|
433
|
+
| Scenario | Node.js | Rush-FS | Note |
|
|
434
|
+
| ---------------------------- | ------- | ------- | --------------------------------- |
|
|
435
|
+
| `existsSync` (existing file) | 444 ns | 1.34 µs | Node.js internal fast path |
|
|
436
|
+
| `accessSync` F_OK | 456 ns | 1.46 µs | Same — napi overhead dominates |
|
|
437
|
+
| `writeFile` 4 MB string | 2.93 ms | 5.69 ms | Large string crossing napi bridge |
|
|
384
438
|
|
|
385
439
|
### Parallelism
|
|
386
440
|
|
|
387
|
-
|
|
441
|
+
Rush-FS uses multi-threaded parallelism for operations that traverse the filesystem:
|
|
388
442
|
|
|
389
443
|
| API | Library | `concurrency` option | Default |
|
|
390
444
|
| --------------------- | ------------------------------------------------------------------------- | -------------------- | ------- |
|
|
@@ -397,15 +451,15 @@ Single-file operations (`stat`, `readFile`, `writeFile`, `chmod`, etc.) are atom
|
|
|
397
451
|
|
|
398
452
|
### Key Takeaway
|
|
399
453
|
|
|
400
|
-
**
|
|
454
|
+
**Rush-FS excels at recursive / batch filesystem operations** (readdir, glob, rm, cp) where Rust's parallel walkers deliver 2–70x speedups. For single-file operations it performs on par with Node.js. The napi bridge adds a fixed ~0.3 µs overhead per call, which only matters for sub-microsecond operations like `existsSync`.
|
|
401
455
|
|
|
402
456
|
**`cp` benchmark detail** (Apple Silicon, release build):
|
|
403
457
|
|
|
404
|
-
| Scenario | Node.js |
|
|
405
|
-
| ----------------------------------------- | --------- |
|
|
406
|
-
| Flat dir (500 files) | 86.45 ms | 61.56 ms
|
|
407
|
-
| Tree dir (breadth=4, depth=3, ~84 nodes) | 23.80 ms | 16.94 ms
|
|
408
|
-
| Tree dir (breadth=3, depth=5, ~363 nodes) | 108.73 ms | 75.39 ms
|
|
458
|
+
| Scenario | Node.js | Rush-FS 1T | Rush-FS 4T | Rush-FS 8T |
|
|
459
|
+
| ----------------------------------------- | --------- | ---------- | ---------- | ---------- |
|
|
460
|
+
| Flat dir (500 files) | 86.45 ms | 61.56 ms | 32.88 ms | 36.67 ms |
|
|
461
|
+
| Tree dir (breadth=4, depth=3, ~84 nodes) | 23.80 ms | 16.94 ms | 10.62 ms | 9.76 ms |
|
|
462
|
+
| Tree dir (breadth=3, depth=5, ~363 nodes) | 108.73 ms | 75.39 ms | 46.88 ms | 46.18 ms |
|
|
409
463
|
|
|
410
464
|
Optimal concurrency for `cp` is **4 threads** on Apple Silicon — beyond that, I/O bandwidth becomes the bottleneck and diminishing returns set in.
|
|
411
465
|
|
|
@@ -413,6 +467,46 @@ Optimal concurrency for `cp` is **4 threads** on Apple Silicon — beyond that,
|
|
|
413
467
|
|
|
414
468
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for the complete development guide — from environment setup, referencing Node.js source, writing Rust implementations, to testing and benchmarking.
|
|
415
469
|
|
|
470
|
+
## Publishing (Maintainers Only)
|
|
471
|
+
|
|
472
|
+
`rush-fs` ships prebuilt native binaries per platform. In this repo, `optionalDependencies` are omitted so CI can use `pnpm install --frozen-lockfile` (the platform packages are not published until release). **Before publishing**, add them back to `package.json` with the same version as the main package, for example:
|
|
473
|
+
|
|
474
|
+
```json
|
|
475
|
+
"optionalDependencies": {
|
|
476
|
+
"rush-fs-win32-x64-msvc": "<version>",
|
|
477
|
+
"rush-fs-darwin-x64": "<version>",
|
|
478
|
+
"rush-fs-linux-x64-gnu": "<version>",
|
|
479
|
+
"rush-fs-darwin-arm64": "<version>"
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Then publish both the platform-specific packages and the main package **in order**:
|
|
484
|
+
|
|
485
|
+
1. Ensure you are logged in to npm (`npm login`).
|
|
486
|
+
2. Bump the version via `pnpm version <patch|minor|major>`. This runs `pnpm preversion`, which builds the `.node` for the **current platform only** (output is in the crate root, not under `npm/`). **To verify the Mac build:** after `pnpm build` or `preversion`, check that the crate root contains `rush-fs.darwin-arm64.node` (Apple Silicon) or `rush-fs.darwin-x64.node` (Intel Mac). For `prepublishOnly` to see it, you must have the file under `npm/<platform>/` (see "Local single-platform publish" below).
|
|
487
|
+
3. Run `pnpm prepublishOnly` (which runs `napi prepublish -t npm`) to publish each built package from `npm/` (e.g. `rush-fs-darwin-arm64`, `rush-fs-win32-x64-msvc`). **If you see "doesn't exist" here,** the `.node` is not in `npm/` yet—either use CI to build all platforms, or for local Mac-only: run `napi create-npm-dirs`, then copy `rush-fs.darwin-arm64.node` (or `darwin-x64`) into `npm/darwin-arm64/` (or `npm/darwin-x64/`), then run `pnpm prepublishOnly` again.
|
|
488
|
+
4. Publish the main package with `pnpm publish --access public`. The `prepublishOnly` hook runs automatically, but running step 3 manually lets you verify each platform succeeded before tagging the main release.
|
|
489
|
+
|
|
490
|
+
If any platform publish fails, fix it and re-run `pnpm prepublishOnly` before retrying `pnpm publish` so consumers never receive a release referring to missing optional dependencies.
|
|
491
|
+
|
|
492
|
+
### How to verify the Mac build (方式 B 第 2 步后)
|
|
493
|
+
|
|
494
|
+
- **Apple Silicon (M1/M2/M3):** in the repo root, a file named `rush-fs.darwin-arm64.node` must exist.
|
|
495
|
+
- **Intel Mac:** in the repo root, a file named `rush-fs.darwin-x64.node` must exist.
|
|
496
|
+
|
|
497
|
+
Command to check: `ls -la rush-fs.darwin-*.node` in the package directory. If you see the file, the Mac native build succeeded.
|
|
498
|
+
|
|
499
|
+
### Local single-platform publish (Mac only)
|
|
500
|
+
|
|
501
|
+
If you are not using CI and only have a Mac build:
|
|
502
|
+
|
|
503
|
+
1. `pnpm build` (or `pnpm version patch` to also bump version).
|
|
504
|
+
2. `napi create-npm-dirs` to create `npm/darwin-arm64/` (and other platform dirs).
|
|
505
|
+
3. Copy the built `.node` into the matching npm dir, e.g.
|
|
506
|
+
`cp rush-fs.darwin-arm64.node npm/darwin-arm64/`
|
|
507
|
+
4. `pnpm prepublishOnly` — only the Mac platform package will be published; others will show "doesn't exist" (expected).
|
|
508
|
+
5. `pnpm publish --access public`. Users on other platforms will need to build from source or you publish those platform packages later via CI.
|
|
509
|
+
|
|
416
510
|
## License
|
|
417
511
|
|
|
418
512
|
MIT
|
package/README.zh-CN.md
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Rush-FS
|
|
2
4
|
|
|
3
5
|
[English](./README.md) | 中文
|
|
4
6
|
|
|
5
7
|
<p align="center">
|
|
6
8
|
<img src="https://img.shields.io/badge/Written%20in-Rust-orange?style=flat-square" alt="Written in Rust">
|
|
7
|
-
<img src="https://img.shields.io/npm/v/
|
|
8
|
-
<img src="https://img.shields.io/npm/l/
|
|
9
|
+
<img src="https://img.shields.io/npm/v/rush-fs?style=flat-square" alt="NPM Version">
|
|
10
|
+
<img src="https://img.shields.io/npm/l/rush-fs?style=flat-square" alt="License">
|
|
9
11
|
</p>
|
|
10
12
|
|
|
11
13
|
<p align="center">
|
|
12
14
|
由 Rust 驱动的高性能 Node.js <code>fs</code> 模块「即插即用」替代品。
|
|
13
15
|
</p>
|
|
16
|
+
</div>
|
|
14
17
|
|
|
15
18
|
## 安装
|
|
16
19
|
|
|
17
20
|
```bash
|
|
18
|
-
npm install
|
|
21
|
+
npm install rush-fs
|
|
19
22
|
# or
|
|
20
|
-
pnpm add
|
|
23
|
+
pnpm add rush-fs
|
|
21
24
|
```
|
|
22
25
|
|
|
23
26
|
## 状态与路线图
|
|
@@ -28,7 +31,7 @@ pnpm add hyper-fs
|
|
|
28
31
|
>
|
|
29
32
|
> - ✅:完全支持
|
|
30
33
|
> - 🚧:部分支持 / 开发中
|
|
31
|
-
> - ✨:
|
|
34
|
+
> - ✨:rush-fs 的新增能力
|
|
32
35
|
> - ❌:暂未支持
|
|
33
36
|
|
|
34
37
|
### `readdir`
|
|
@@ -314,7 +317,7 @@ pnpm add hyper-fs
|
|
|
314
317
|
## 用法
|
|
315
318
|
|
|
316
319
|
```ts
|
|
317
|
-
import { readdir, stat, readFile, writeFile, mkdir, rm } from '
|
|
320
|
+
import { readdir, stat, readFile, writeFile, mkdir, rm } from 'rush-fs'
|
|
318
321
|
|
|
319
322
|
// 读取目录
|
|
320
323
|
const files = await readdir('./src')
|
|
@@ -345,11 +348,11 @@ await rm('./temp', { recursive: true, force: true })
|
|
|
345
348
|
> 测试环境:Apple Silicon (arm64),Node.js 24.0.2,release 构建(开启 LTO)。
|
|
346
349
|
> 运行 `pnpm build && pnpm bench` 可复现。
|
|
347
350
|
|
|
348
|
-
###
|
|
351
|
+
### Rush-FS 显著更快的场景
|
|
349
352
|
|
|
350
353
|
这些场景中 Rust 的并行遍历和零拷贝 I/O 发挥了真正优势:
|
|
351
354
|
|
|
352
|
-
| 场景 | Node.js |
|
|
355
|
+
| 场景 | Node.js | Rush-FS | 加速比 |
|
|
353
356
|
| ------------------------------------------- | --------- | -------- | --------- |
|
|
354
357
|
| `readdir` 递归(node_modules,约 3 万条目) | 281 ms | 23 ms | **12x** |
|
|
355
358
|
| `glob` 递归(`**/*.rs`) | 25 ms | 1.46 ms | **17x** |
|
|
@@ -366,27 +369,27 @@ await rm('./temp', { recursive: true, force: true })
|
|
|
366
369
|
|
|
367
370
|
单文件操作有约 0.3 µs 的 napi 桥接开销,整体表现基本一致:
|
|
368
371
|
|
|
369
|
-
| 场景 | Node.js |
|
|
370
|
-
| ---------------------------- | ------- |
|
|
371
|
-
| `stat`(单文件) | 1.45 µs | 1.77 µs
|
|
372
|
-
| `readFile` 小文件(Buffer) | 8.86 µs | 9.46 µs
|
|
373
|
-
| `writeFile` 小文件(string) | 74 µs | 66 µs
|
|
374
|
-
| `writeFile` 小文件(Buffer) | 115 µs | 103 µs
|
|
375
|
-
| `appendFile` | 30 µs | 27 µs
|
|
372
|
+
| 场景 | Node.js | Rush-FS | 比率 |
|
|
373
|
+
| ---------------------------- | ------- | ------- | ---- |
|
|
374
|
+
| `stat`(单文件) | 1.45 µs | 1.77 µs | 1.2x |
|
|
375
|
+
| `readFile` 小文件(Buffer) | 8.86 µs | 9.46 µs | 1.1x |
|
|
376
|
+
| `writeFile` 小文件(string) | 74 µs | 66 µs | 0.9x |
|
|
377
|
+
| `writeFile` 小文件(Buffer) | 115 µs | 103 µs | 0.9x |
|
|
378
|
+
| `appendFile` | 30 µs | 27 µs | 0.9x |
|
|
376
379
|
|
|
377
380
|
### Node.js 更快的场景
|
|
378
381
|
|
|
379
382
|
极轻量级的内置调用,napi 开销占比较大:
|
|
380
383
|
|
|
381
|
-
| 场景 | Node.js |
|
|
382
|
-
| -------------------------- | ------- |
|
|
383
|
-
| `existsSync`(已存在文件) | 444 ns | 1.34 µs
|
|
384
|
-
| `accessSync` F_OK | 456 ns | 1.46 µs
|
|
385
|
-
| `writeFile` 4 MB string | 2.93 ms | 5.69 ms
|
|
384
|
+
| 场景 | Node.js | Rush-FS | 说明 |
|
|
385
|
+
| -------------------------- | ------- | ------- | ------------------------ |
|
|
386
|
+
| `existsSync`(已存在文件) | 444 ns | 1.34 µs | Node.js 内部有 fast path |
|
|
387
|
+
| `accessSync` F_OK | 456 ns | 1.46 µs | 同上——napi 开销占主导 |
|
|
388
|
+
| `writeFile` 4 MB string | 2.93 ms | 5.69 ms | 大字符串跨 napi 桥传输 |
|
|
386
389
|
|
|
387
390
|
### 并行支持
|
|
388
391
|
|
|
389
|
-
|
|
392
|
+
Rush-FS 在文件系统遍历类操作中使用多线程并行:
|
|
390
393
|
|
|
391
394
|
| API | 并行库 | `concurrency` 选项 | 默认值 |
|
|
392
395
|
| ----------------- | ------------------------------------------------------------------------- | ------------------ | ------ |
|
|
@@ -399,15 +402,15 @@ Hyper-FS 在文件系统遍历类操作中使用多线程并行:
|
|
|
399
402
|
|
|
400
403
|
### 核心结论
|
|
401
404
|
|
|
402
|
-
**
|
|
405
|
+
**Rush-FS 在递归/批量文件系统操作上表现卓越**(readdir、glob、rm、cp),Rust 的并行遍历器带来 2–70 倍加速。单文件操作与 Node.js 基本持平。napi 桥接带来固定约 0.3 µs 的每次调用开销,仅在亚微秒级操作(如 `existsSync`)中有感知。
|
|
403
406
|
|
|
404
407
|
**`cp` 基准详情**(Apple Silicon,release 构建):
|
|
405
408
|
|
|
406
|
-
| 场景 | Node.js |
|
|
407
|
-
| ------------------------------------- | --------- |
|
|
408
|
-
| 平铺目录(500 文件) | 86.45 ms | 61.56 ms
|
|
409
|
-
| 树形目录(宽度=4,深度=3,~84 节点) | 23.80 ms | 16.94 ms
|
|
410
|
-
| 树形目录(宽度=3,深度=5,~363 节点) | 108.73 ms | 75.39 ms
|
|
409
|
+
| 场景 | Node.js | Rush-FS 1 线程 | Rush-FS 4 线程 | Rush-FS 8 线程 |
|
|
410
|
+
| ------------------------------------- | --------- | -------------- | -------------- | -------------- |
|
|
411
|
+
| 平铺目录(500 文件) | 86.45 ms | 61.56 ms | 32.88 ms | 36.67 ms |
|
|
412
|
+
| 树形目录(宽度=4,深度=3,~84 节点) | 23.80 ms | 16.94 ms | 10.62 ms | 9.76 ms |
|
|
413
|
+
| 树形目录(宽度=3,深度=5,~363 节点) | 108.73 ms | 75.39 ms | 46.88 ms | 46.18 ms |
|
|
411
414
|
|
|
412
415
|
`cp` 的最优并发数在 Apple Silicon 上为 **4 线程**——超过后受 I/O 带宽限制,收益趋于平稳。
|
|
413
416
|
|
|
@@ -415,6 +418,37 @@ Hyper-FS 在文件系统遍历类操作中使用多线程并行:
|
|
|
415
418
|
|
|
416
419
|
参阅 [CONTRIBUTING.md](./CONTRIBUTING.md) — 完整的开发指南,涵盖环境搭建、参考 Node.js 源码、编写 Rust 实现、测试与性能基准。
|
|
417
420
|
|
|
421
|
+
## 发布(维护者专用)
|
|
422
|
+
|
|
423
|
+
`rush-fs` 会为每个平台发布一个预编译二进制(参见 `package.json` 中的 `optionalDependencies`)。**若只有 Mac,无法本地构建 Windows/Linux 的 .node,请用下面的「通过 CI 发布」。**
|
|
424
|
+
|
|
425
|
+
### 通过 GitHub Actions 发布(推荐)
|
|
426
|
+
|
|
427
|
+
CI 已在多平台(macOS x64/arm64、Windows、Linux)构建并测试,通过后可由同一 workflow 发布到 npm。
|
|
428
|
+
|
|
429
|
+
1. 在仓库 **Settings → Secrets and variables → Actions** 里添加 **NPM_TOKEN**(npm 账号生成的 Classic Token,需允许发布)。
|
|
430
|
+
2. 确保 `package.json` 和 `Cargo.toml` 中版本号一致(如 `0.0.3`),且 `package.json` 里已包含四个 `optionalDependencies`(版本与主包一致)。
|
|
431
|
+
3. 提交并推送到 `main`,**且该次提交的 commit message 仅为版本号**(如 `0.0.3`)。CI 跑通后会自动:先发布四个平台包,再发布主包 `rush-fs`。
|
|
432
|
+
|
|
433
|
+
示例:
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
# 版本和 optionalDependencies 已改好后
|
|
437
|
+
git add package.json Cargo.toml
|
|
438
|
+
git commit -m "0.0.3"
|
|
439
|
+
git push origin main
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
4. 发版完成后,若希望 CI 继续用 `pnpm install --frozen-lockfile`,可在仓库里删掉 `optionalDependencies` 再提交,下次发版前再加回。
|
|
443
|
+
|
|
444
|
+
### 本地发布(需能构建各平台)
|
|
445
|
+
|
|
446
|
+
若本机可构建所有平台(或只发当前平台),可按顺序执行:
|
|
447
|
+
|
|
448
|
+
1. 确保已执行 `npm login`。
|
|
449
|
+
2. 使用 `pnpm version <patch|minor|major>` 提升版本号(会执行 `pnpm preversion` 在 `npm/` 下构建)。
|
|
450
|
+
3. 运行 `pnpm prepublishOnly` 发布各平台包,再执行 `pnpm publish --access public` 发布主包。
|
|
451
|
+
|
|
418
452
|
## 许可证
|
|
419
453
|
|
|
420
454
|
MIT
|
package/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export interface CpOptions {
|
|
|
83
83
|
dereference?: boolean
|
|
84
84
|
verbatimSymlinks?: boolean
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* Rush-FS extension: number of parallel threads for recursive copy.
|
|
87
87
|
* 0 or 1 means sequential; > 1 enables rayon parallel traversal.
|
|
88
88
|
*/
|
|
89
89
|
concurrency?: number
|
|
@@ -200,7 +200,7 @@ export declare function rmdirSync(path: string): void
|
|
|
200
200
|
* encountered, Node.js retries the operation with a linear backoff of `retryDelay` ms longer on
|
|
201
201
|
* each try. This option represents the number of retries.
|
|
202
202
|
* - `retryDelay`: The amount of time in milliseconds to wait between retries (default 100ms).
|
|
203
|
-
* - `concurrency` (
|
|
203
|
+
* - `concurrency` (rush-fs extension): Number of parallel threads for recursive removal.
|
|
204
204
|
*/
|
|
205
205
|
export interface RmOptions {
|
|
206
206
|
force?: boolean
|
package/index.js
CHANGED
|
@@ -70,15 +70,15 @@ function requireNative() {
|
|
|
70
70
|
} else if (process.platform === 'android') {
|
|
71
71
|
if (process.arch === 'arm64') {
|
|
72
72
|
try {
|
|
73
|
-
return require('./
|
|
73
|
+
return require('./rush-fs.android-arm64.node')
|
|
74
74
|
} catch (e) {
|
|
75
75
|
loadErrors.push(e)
|
|
76
76
|
}
|
|
77
77
|
try {
|
|
78
|
-
const binding = require('
|
|
79
|
-
const bindingPackageVersion = require('
|
|
80
|
-
if (bindingPackageVersion !== '0.0.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
78
|
+
const binding = require('rush-fs-android-arm64')
|
|
79
|
+
const bindingPackageVersion = require('rush-fs-android-arm64/package.json').version
|
|
80
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -86,15 +86,15 @@ function requireNative() {
|
|
|
86
86
|
}
|
|
87
87
|
} else if (process.arch === 'arm') {
|
|
88
88
|
try {
|
|
89
|
-
return require('./
|
|
89
|
+
return require('./rush-fs.android-arm-eabi.node')
|
|
90
90
|
} catch (e) {
|
|
91
91
|
loadErrors.push(e)
|
|
92
92
|
}
|
|
93
93
|
try {
|
|
94
|
-
const binding = require('
|
|
95
|
-
const bindingPackageVersion = require('
|
|
96
|
-
if (bindingPackageVersion !== '0.0.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
94
|
+
const binding = require('rush-fs-android-arm-eabi')
|
|
95
|
+
const bindingPackageVersion = require('rush-fs-android-arm-eabi/package.json').version
|
|
96
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -107,15 +107,15 @@ function requireNative() {
|
|
|
107
107
|
if (process.arch === 'x64') {
|
|
108
108
|
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
|
109
109
|
try {
|
|
110
|
-
return require('./
|
|
110
|
+
return require('./rush-fs.win32-x64-gnu.node')
|
|
111
111
|
} catch (e) {
|
|
112
112
|
loadErrors.push(e)
|
|
113
113
|
}
|
|
114
114
|
try {
|
|
115
|
-
const binding = require('
|
|
116
|
-
const bindingPackageVersion = require('
|
|
117
|
-
if (bindingPackageVersion !== '0.0.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
115
|
+
const binding = require('rush-fs-win32-x64-gnu')
|
|
116
|
+
const bindingPackageVersion = require('rush-fs-win32-x64-gnu/package.json').version
|
|
117
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -123,15 +123,15 @@ function requireNative() {
|
|
|
123
123
|
}
|
|
124
124
|
} else {
|
|
125
125
|
try {
|
|
126
|
-
return require('./
|
|
126
|
+
return require('./rush-fs.win32-x64-msvc.node')
|
|
127
127
|
} catch (e) {
|
|
128
128
|
loadErrors.push(e)
|
|
129
129
|
}
|
|
130
130
|
try {
|
|
131
|
-
const binding = require('
|
|
132
|
-
const bindingPackageVersion = require('
|
|
133
|
-
if (bindingPackageVersion !== '0.0.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
131
|
+
const binding = require('rush-fs-win32-x64-msvc')
|
|
132
|
+
const bindingPackageVersion = require('rush-fs-win32-x64-msvc/package.json').version
|
|
133
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -140,15 +140,15 @@ function requireNative() {
|
|
|
140
140
|
}
|
|
141
141
|
} else if (process.arch === 'ia32') {
|
|
142
142
|
try {
|
|
143
|
-
return require('./
|
|
143
|
+
return require('./rush-fs.win32-ia32-msvc.node')
|
|
144
144
|
} catch (e) {
|
|
145
145
|
loadErrors.push(e)
|
|
146
146
|
}
|
|
147
147
|
try {
|
|
148
|
-
const binding = require('
|
|
149
|
-
const bindingPackageVersion = require('
|
|
150
|
-
if (bindingPackageVersion !== '0.0.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
148
|
+
const binding = require('rush-fs-win32-ia32-msvc')
|
|
149
|
+
const bindingPackageVersion = require('rush-fs-win32-ia32-msvc/package.json').version
|
|
150
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -156,15 +156,15 @@ function requireNative() {
|
|
|
156
156
|
}
|
|
157
157
|
} else if (process.arch === 'arm64') {
|
|
158
158
|
try {
|
|
159
|
-
return require('./
|
|
159
|
+
return require('./rush-fs.win32-arm64-msvc.node')
|
|
160
160
|
} catch (e) {
|
|
161
161
|
loadErrors.push(e)
|
|
162
162
|
}
|
|
163
163
|
try {
|
|
164
|
-
const binding = require('
|
|
165
|
-
const bindingPackageVersion = require('
|
|
166
|
-
if (bindingPackageVersion !== '0.0.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
164
|
+
const binding = require('rush-fs-win32-arm64-msvc')
|
|
165
|
+
const bindingPackageVersion = require('rush-fs-win32-arm64-msvc/package.json').version
|
|
166
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -175,15 +175,15 @@ function requireNative() {
|
|
|
175
175
|
}
|
|
176
176
|
} else if (process.platform === 'darwin') {
|
|
177
177
|
try {
|
|
178
|
-
return require('./
|
|
178
|
+
return require('./rush-fs.darwin-universal.node')
|
|
179
179
|
} catch (e) {
|
|
180
180
|
loadErrors.push(e)
|
|
181
181
|
}
|
|
182
182
|
try {
|
|
183
|
-
const binding = require('
|
|
184
|
-
const bindingPackageVersion = require('
|
|
185
|
-
if (bindingPackageVersion !== '0.0.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
183
|
+
const binding = require('rush-fs-darwin-universal')
|
|
184
|
+
const bindingPackageVersion = require('rush-fs-darwin-universal/package.json').version
|
|
185
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -191,15 +191,15 @@ function requireNative() {
|
|
|
191
191
|
}
|
|
192
192
|
if (process.arch === 'x64') {
|
|
193
193
|
try {
|
|
194
|
-
return require('./
|
|
194
|
+
return require('./rush-fs.darwin-x64.node')
|
|
195
195
|
} catch (e) {
|
|
196
196
|
loadErrors.push(e)
|
|
197
197
|
}
|
|
198
198
|
try {
|
|
199
|
-
const binding = require('
|
|
200
|
-
const bindingPackageVersion = require('
|
|
201
|
-
if (bindingPackageVersion !== '0.0.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
199
|
+
const binding = require('rush-fs-darwin-x64')
|
|
200
|
+
const bindingPackageVersion = require('rush-fs-darwin-x64/package.json').version
|
|
201
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -207,15 +207,15 @@ function requireNative() {
|
|
|
207
207
|
}
|
|
208
208
|
} else if (process.arch === 'arm64') {
|
|
209
209
|
try {
|
|
210
|
-
return require('./
|
|
210
|
+
return require('./rush-fs.darwin-arm64.node')
|
|
211
211
|
} catch (e) {
|
|
212
212
|
loadErrors.push(e)
|
|
213
213
|
}
|
|
214
214
|
try {
|
|
215
|
-
const binding = require('
|
|
216
|
-
const bindingPackageVersion = require('
|
|
217
|
-
if (bindingPackageVersion !== '0.0.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
215
|
+
const binding = require('rush-fs-darwin-arm64')
|
|
216
|
+
const bindingPackageVersion = require('rush-fs-darwin-arm64/package.json').version
|
|
217
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -227,15 +227,15 @@ function requireNative() {
|
|
|
227
227
|
} else if (process.platform === 'freebsd') {
|
|
228
228
|
if (process.arch === 'x64') {
|
|
229
229
|
try {
|
|
230
|
-
return require('./
|
|
230
|
+
return require('./rush-fs.freebsd-x64.node')
|
|
231
231
|
} catch (e) {
|
|
232
232
|
loadErrors.push(e)
|
|
233
233
|
}
|
|
234
234
|
try {
|
|
235
|
-
const binding = require('
|
|
236
|
-
const bindingPackageVersion = require('
|
|
237
|
-
if (bindingPackageVersion !== '0.0.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
235
|
+
const binding = require('rush-fs-freebsd-x64')
|
|
236
|
+
const bindingPackageVersion = require('rush-fs-freebsd-x64/package.json').version
|
|
237
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -243,15 +243,15 @@ function requireNative() {
|
|
|
243
243
|
}
|
|
244
244
|
} else if (process.arch === 'arm64') {
|
|
245
245
|
try {
|
|
246
|
-
return require('./
|
|
246
|
+
return require('./rush-fs.freebsd-arm64.node')
|
|
247
247
|
} catch (e) {
|
|
248
248
|
loadErrors.push(e)
|
|
249
249
|
}
|
|
250
250
|
try {
|
|
251
|
-
const binding = require('
|
|
252
|
-
const bindingPackageVersion = require('
|
|
253
|
-
if (bindingPackageVersion !== '0.0.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
251
|
+
const binding = require('rush-fs-freebsd-arm64')
|
|
252
|
+
const bindingPackageVersion = require('rush-fs-freebsd-arm64/package.json').version
|
|
253
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -264,15 +264,15 @@ function requireNative() {
|
|
|
264
264
|
if (process.arch === 'x64') {
|
|
265
265
|
if (isMusl()) {
|
|
266
266
|
try {
|
|
267
|
-
return require('./
|
|
267
|
+
return require('./rush-fs.linux-x64-musl.node')
|
|
268
268
|
} catch (e) {
|
|
269
269
|
loadErrors.push(e)
|
|
270
270
|
}
|
|
271
271
|
try {
|
|
272
|
-
const binding = require('
|
|
273
|
-
const bindingPackageVersion = require('
|
|
274
|
-
if (bindingPackageVersion !== '0.0.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
272
|
+
const binding = require('rush-fs-linux-x64-musl')
|
|
273
|
+
const bindingPackageVersion = require('rush-fs-linux-x64-musl/package.json').version
|
|
274
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -280,15 +280,15 @@ function requireNative() {
|
|
|
280
280
|
}
|
|
281
281
|
} else {
|
|
282
282
|
try {
|
|
283
|
-
return require('./
|
|
283
|
+
return require('./rush-fs.linux-x64-gnu.node')
|
|
284
284
|
} catch (e) {
|
|
285
285
|
loadErrors.push(e)
|
|
286
286
|
}
|
|
287
287
|
try {
|
|
288
|
-
const binding = require('
|
|
289
|
-
const bindingPackageVersion = require('
|
|
290
|
-
if (bindingPackageVersion !== '0.0.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
288
|
+
const binding = require('rush-fs-linux-x64-gnu')
|
|
289
|
+
const bindingPackageVersion = require('rush-fs-linux-x64-gnu/package.json').version
|
|
290
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -298,15 +298,15 @@ function requireNative() {
|
|
|
298
298
|
} else if (process.arch === 'arm64') {
|
|
299
299
|
if (isMusl()) {
|
|
300
300
|
try {
|
|
301
|
-
return require('./
|
|
301
|
+
return require('./rush-fs.linux-arm64-musl.node')
|
|
302
302
|
} catch (e) {
|
|
303
303
|
loadErrors.push(e)
|
|
304
304
|
}
|
|
305
305
|
try {
|
|
306
|
-
const binding = require('
|
|
307
|
-
const bindingPackageVersion = require('
|
|
308
|
-
if (bindingPackageVersion !== '0.0.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
306
|
+
const binding = require('rush-fs-linux-arm64-musl')
|
|
307
|
+
const bindingPackageVersion = require('rush-fs-linux-arm64-musl/package.json').version
|
|
308
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -314,15 +314,15 @@ function requireNative() {
|
|
|
314
314
|
}
|
|
315
315
|
} else {
|
|
316
316
|
try {
|
|
317
|
-
return require('./
|
|
317
|
+
return require('./rush-fs.linux-arm64-gnu.node')
|
|
318
318
|
} catch (e) {
|
|
319
319
|
loadErrors.push(e)
|
|
320
320
|
}
|
|
321
321
|
try {
|
|
322
|
-
const binding = require('
|
|
323
|
-
const bindingPackageVersion = require('
|
|
324
|
-
if (bindingPackageVersion !== '0.0.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
322
|
+
const binding = require('rush-fs-linux-arm64-gnu')
|
|
323
|
+
const bindingPackageVersion = require('rush-fs-linux-arm64-gnu/package.json').version
|
|
324
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -332,15 +332,15 @@ function requireNative() {
|
|
|
332
332
|
} else if (process.arch === 'arm') {
|
|
333
333
|
if (isMusl()) {
|
|
334
334
|
try {
|
|
335
|
-
return require('./
|
|
335
|
+
return require('./rush-fs.linux-arm-musleabihf.node')
|
|
336
336
|
} catch (e) {
|
|
337
337
|
loadErrors.push(e)
|
|
338
338
|
}
|
|
339
339
|
try {
|
|
340
|
-
const binding = require('
|
|
341
|
-
const bindingPackageVersion = require('
|
|
342
|
-
if (bindingPackageVersion !== '0.0.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
340
|
+
const binding = require('rush-fs-linux-arm-musleabihf')
|
|
341
|
+
const bindingPackageVersion = require('rush-fs-linux-arm-musleabihf/package.json').version
|
|
342
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -348,15 +348,15 @@ function requireNative() {
|
|
|
348
348
|
}
|
|
349
349
|
} else {
|
|
350
350
|
try {
|
|
351
|
-
return require('./
|
|
351
|
+
return require('./rush-fs.linux-arm-gnueabihf.node')
|
|
352
352
|
} catch (e) {
|
|
353
353
|
loadErrors.push(e)
|
|
354
354
|
}
|
|
355
355
|
try {
|
|
356
|
-
const binding = require('
|
|
357
|
-
const bindingPackageVersion = require('
|
|
358
|
-
if (bindingPackageVersion !== '0.0.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
356
|
+
const binding = require('rush-fs-linux-arm-gnueabihf')
|
|
357
|
+
const bindingPackageVersion = require('rush-fs-linux-arm-gnueabihf/package.json').version
|
|
358
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -366,15 +366,15 @@ function requireNative() {
|
|
|
366
366
|
} else if (process.arch === 'loong64') {
|
|
367
367
|
if (isMusl()) {
|
|
368
368
|
try {
|
|
369
|
-
return require('./
|
|
369
|
+
return require('./rush-fs.linux-loong64-musl.node')
|
|
370
370
|
} catch (e) {
|
|
371
371
|
loadErrors.push(e)
|
|
372
372
|
}
|
|
373
373
|
try {
|
|
374
|
-
const binding = require('
|
|
375
|
-
const bindingPackageVersion = require('
|
|
376
|
-
if (bindingPackageVersion !== '0.0.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
374
|
+
const binding = require('rush-fs-linux-loong64-musl')
|
|
375
|
+
const bindingPackageVersion = require('rush-fs-linux-loong64-musl/package.json').version
|
|
376
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -382,15 +382,15 @@ function requireNative() {
|
|
|
382
382
|
}
|
|
383
383
|
} else {
|
|
384
384
|
try {
|
|
385
|
-
return require('./
|
|
385
|
+
return require('./rush-fs.linux-loong64-gnu.node')
|
|
386
386
|
} catch (e) {
|
|
387
387
|
loadErrors.push(e)
|
|
388
388
|
}
|
|
389
389
|
try {
|
|
390
|
-
const binding = require('
|
|
391
|
-
const bindingPackageVersion = require('
|
|
392
|
-
if (bindingPackageVersion !== '0.0.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
390
|
+
const binding = require('rush-fs-linux-loong64-gnu')
|
|
391
|
+
const bindingPackageVersion = require('rush-fs-linux-loong64-gnu/package.json').version
|
|
392
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -400,15 +400,15 @@ function requireNative() {
|
|
|
400
400
|
} else if (process.arch === 'riscv64') {
|
|
401
401
|
if (isMusl()) {
|
|
402
402
|
try {
|
|
403
|
-
return require('./
|
|
403
|
+
return require('./rush-fs.linux-riscv64-musl.node')
|
|
404
404
|
} catch (e) {
|
|
405
405
|
loadErrors.push(e)
|
|
406
406
|
}
|
|
407
407
|
try {
|
|
408
|
-
const binding = require('
|
|
409
|
-
const bindingPackageVersion = require('
|
|
410
|
-
if (bindingPackageVersion !== '0.0.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
408
|
+
const binding = require('rush-fs-linux-riscv64-musl')
|
|
409
|
+
const bindingPackageVersion = require('rush-fs-linux-riscv64-musl/package.json').version
|
|
410
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -416,15 +416,15 @@ function requireNative() {
|
|
|
416
416
|
}
|
|
417
417
|
} else {
|
|
418
418
|
try {
|
|
419
|
-
return require('./
|
|
419
|
+
return require('./rush-fs.linux-riscv64-gnu.node')
|
|
420
420
|
} catch (e) {
|
|
421
421
|
loadErrors.push(e)
|
|
422
422
|
}
|
|
423
423
|
try {
|
|
424
|
-
const binding = require('
|
|
425
|
-
const bindingPackageVersion = require('
|
|
426
|
-
if (bindingPackageVersion !== '0.0.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
424
|
+
const binding = require('rush-fs-linux-riscv64-gnu')
|
|
425
|
+
const bindingPackageVersion = require('rush-fs-linux-riscv64-gnu/package.json').version
|
|
426
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -433,15 +433,15 @@ function requireNative() {
|
|
|
433
433
|
}
|
|
434
434
|
} else if (process.arch === 'ppc64') {
|
|
435
435
|
try {
|
|
436
|
-
return require('./
|
|
436
|
+
return require('./rush-fs.linux-ppc64-gnu.node')
|
|
437
437
|
} catch (e) {
|
|
438
438
|
loadErrors.push(e)
|
|
439
439
|
}
|
|
440
440
|
try {
|
|
441
|
-
const binding = require('
|
|
442
|
-
const bindingPackageVersion = require('
|
|
443
|
-
if (bindingPackageVersion !== '0.0.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
441
|
+
const binding = require('rush-fs-linux-ppc64-gnu')
|
|
442
|
+
const bindingPackageVersion = require('rush-fs-linux-ppc64-gnu/package.json').version
|
|
443
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -449,15 +449,15 @@ function requireNative() {
|
|
|
449
449
|
}
|
|
450
450
|
} else if (process.arch === 's390x') {
|
|
451
451
|
try {
|
|
452
|
-
return require('./
|
|
452
|
+
return require('./rush-fs.linux-s390x-gnu.node')
|
|
453
453
|
} catch (e) {
|
|
454
454
|
loadErrors.push(e)
|
|
455
455
|
}
|
|
456
456
|
try {
|
|
457
|
-
const binding = require('
|
|
458
|
-
const bindingPackageVersion = require('
|
|
459
|
-
if (bindingPackageVersion !== '0.0.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
457
|
+
const binding = require('rush-fs-linux-s390x-gnu')
|
|
458
|
+
const bindingPackageVersion = require('rush-fs-linux-s390x-gnu/package.json').version
|
|
459
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -469,15 +469,15 @@ function requireNative() {
|
|
|
469
469
|
} else if (process.platform === 'openharmony') {
|
|
470
470
|
if (process.arch === 'arm64') {
|
|
471
471
|
try {
|
|
472
|
-
return require('./
|
|
472
|
+
return require('./rush-fs.openharmony-arm64.node')
|
|
473
473
|
} catch (e) {
|
|
474
474
|
loadErrors.push(e)
|
|
475
475
|
}
|
|
476
476
|
try {
|
|
477
|
-
const binding = require('
|
|
478
|
-
const bindingPackageVersion = require('
|
|
479
|
-
if (bindingPackageVersion !== '0.0.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
477
|
+
const binding = require('rush-fs-openharmony-arm64')
|
|
478
|
+
const bindingPackageVersion = require('rush-fs-openharmony-arm64/package.json').version
|
|
479
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -485,15 +485,15 @@ function requireNative() {
|
|
|
485
485
|
}
|
|
486
486
|
} else if (process.arch === 'x64') {
|
|
487
487
|
try {
|
|
488
|
-
return require('./
|
|
488
|
+
return require('./rush-fs.openharmony-x64.node')
|
|
489
489
|
} catch (e) {
|
|
490
490
|
loadErrors.push(e)
|
|
491
491
|
}
|
|
492
492
|
try {
|
|
493
|
-
const binding = require('
|
|
494
|
-
const bindingPackageVersion = require('
|
|
495
|
-
if (bindingPackageVersion !== '0.0.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
493
|
+
const binding = require('rush-fs-openharmony-x64')
|
|
494
|
+
const bindingPackageVersion = require('rush-fs-openharmony-x64/package.json').version
|
|
495
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -501,15 +501,15 @@ function requireNative() {
|
|
|
501
501
|
}
|
|
502
502
|
} else if (process.arch === 'arm') {
|
|
503
503
|
try {
|
|
504
|
-
return require('./
|
|
504
|
+
return require('./rush-fs.openharmony-arm.node')
|
|
505
505
|
} catch (e) {
|
|
506
506
|
loadErrors.push(e)
|
|
507
507
|
}
|
|
508
508
|
try {
|
|
509
|
-
const binding = require('
|
|
510
|
-
const bindingPackageVersion = require('
|
|
511
|
-
if (bindingPackageVersion !== '0.0.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.
|
|
509
|
+
const binding = require('rush-fs-openharmony-arm')
|
|
510
|
+
const bindingPackageVersion = require('rush-fs-openharmony-arm/package.json').version
|
|
511
|
+
if (bindingPackageVersion !== '0.0.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -529,20 +529,24 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
529
529
|
let wasiBinding = null
|
|
530
530
|
let wasiBindingError = null
|
|
531
531
|
try {
|
|
532
|
-
wasiBinding = require('./
|
|
532
|
+
wasiBinding = require('./rush-fs.wasi.cjs')
|
|
533
533
|
nativeBinding = wasiBinding
|
|
534
534
|
} catch (err) {
|
|
535
535
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
536
536
|
wasiBindingError = err
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
|
-
if (!nativeBinding) {
|
|
539
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
540
540
|
try {
|
|
541
|
-
wasiBinding = require('
|
|
541
|
+
wasiBinding = require('rush-fs-wasm32-wasi')
|
|
542
542
|
nativeBinding = wasiBinding
|
|
543
543
|
} catch (err) {
|
|
544
544
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
545
|
-
wasiBindingError
|
|
545
|
+
if (!wasiBindingError) {
|
|
546
|
+
wasiBindingError = err
|
|
547
|
+
} else {
|
|
548
|
+
wasiBindingError.cause = err
|
|
549
|
+
}
|
|
546
550
|
loadErrors.push(err)
|
|
547
551
|
}
|
|
548
552
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rush-fs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "High-performance drop-in replacement for Node.js fs module, powered by Rust",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/CoderSerio/rush-fs.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"browser": "browser.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"browser.js"
|
|
30
30
|
],
|
|
31
31
|
"napi": {
|
|
32
|
-
"binaryName": "
|
|
32
|
+
"binaryName": "rush-fs",
|
|
33
33
|
"targets": [
|
|
34
34
|
"x86_64-pc-windows-msvc",
|
|
35
35
|
"x86_64-apple-darwin",
|
|
@@ -44,6 +44,23 @@
|
|
|
44
44
|
"registry": "https://registry.npmjs.org/",
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"artifacts": "napi artifacts",
|
|
49
|
+
"bench": "node --import @oxc-node/core/register benchmark/bench.ts",
|
|
50
|
+
"build": "napi build --platform --release",
|
|
51
|
+
"build:debug": "napi build --platform",
|
|
52
|
+
"format": "run-p format:prettier format:rs format:toml",
|
|
53
|
+
"format:prettier": "prettier . -w",
|
|
54
|
+
"format:toml": "taplo format",
|
|
55
|
+
"format:rs": "cargo fmt",
|
|
56
|
+
"fmt:check": "cargo fmt -- --check",
|
|
57
|
+
"lint": "oxlint .",
|
|
58
|
+
"prepublishOnly": "napi prepublish -t npm",
|
|
59
|
+
"test": "ava",
|
|
60
|
+
"preversion": "napi build --platform && git add .",
|
|
61
|
+
"version": "napi version",
|
|
62
|
+
"prepare": "husky"
|
|
63
|
+
},
|
|
47
64
|
"devDependencies": {
|
|
48
65
|
"@emnapi/core": "^1.5.0",
|
|
49
66
|
"@emnapi/runtime": "^1.5.0",
|
|
@@ -96,25 +113,11 @@
|
|
|
96
113
|
"singleQuote": true,
|
|
97
114
|
"arrowParens": "always"
|
|
98
115
|
},
|
|
116
|
+
"packageManager": "pnpm@9.15.4",
|
|
99
117
|
"optionalDependencies": {
|
|
100
|
-
"rush-fs-win32-x64-msvc": "0.0.
|
|
101
|
-
"rush-fs-darwin-x64": "0.0.
|
|
102
|
-
"rush-fs-linux-x64-gnu": "0.0.
|
|
103
|
-
"rush-fs-darwin-arm64": "0.0.
|
|
104
|
-
},
|
|
105
|
-
"scripts": {
|
|
106
|
-
"artifacts": "napi artifacts",
|
|
107
|
-
"bench": "node --import @oxc-node/core/register benchmark/bench.ts",
|
|
108
|
-
"build": "napi build --platform --release",
|
|
109
|
-
"build:debug": "napi build --platform",
|
|
110
|
-
"format": "run-p format:prettier format:rs format:toml",
|
|
111
|
-
"format:prettier": "prettier . -w",
|
|
112
|
-
"format:toml": "taplo format",
|
|
113
|
-
"format:rs": "cargo fmt",
|
|
114
|
-
"fmt:check": "cargo fmt -- --check",
|
|
115
|
-
"lint": "oxlint .",
|
|
116
|
-
"test": "ava",
|
|
117
|
-
"preversion": "napi build --platform && git add .",
|
|
118
|
-
"version": "napi version"
|
|
118
|
+
"rush-fs-win32-x64-msvc": "0.0.4",
|
|
119
|
+
"rush-fs-darwin-x64": "0.0.4",
|
|
120
|
+
"rush-fs-linux-x64-gnu": "0.0.4",
|
|
121
|
+
"rush-fs-darwin-arm64": "0.0.4"
|
|
119
122
|
}
|
|
120
123
|
}
|