Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# Generated codes (excluded from GitHub language stats)
index.js linguist-detectable=false
index.d.ts linguist-detectable=false
hyper-fs.wasi-browser.js linguist-detectable=false
hyper-fs.wasi.cjs linguist-detectable=false
rush-fs.wasi-browser.js linguist-detectable=false
rush-fs.wasi.cjs linguist-detectable=false
wasi-worker-browser.mjs linguist-detectable=false
wasi-worker.mjs linguist-detectable=false

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ title: '[FEAT/BUG]'

- **OS:** [e.g. macOS, Windows, Linux]
- **Node.js Version:** [e.g. v18.16.0]
- **hyper-fs Version:** [e.g. 0.0.1]
- **rush-fs Version:** [e.g. 0.0.1]

## Related Issues:

Expand Down
69 changes: 16 additions & 53 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
name: CI
env:
DEBUG: napi:*
APP_NAME: hyper-fs
APP_NAME: rush-fs
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_INCREMENTAL: '1'
NODE_VERSION: '20'
# CI:PR 与 main 的检查(lint / build / test),不包含发布
'on':
push:
branches:
- main
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- LICENSE
- '**/*.gitignore'
- .editorconfig
- docs/**
pull_request: null
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'
- LICENSE
- '**/*.gitignore'
- .editorconfig
- docs/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -67,6 +74,11 @@ jobs:
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Cache Rust toolchain
uses: actions/cache@v4
with:
path: ~/.rustup
key: rustup-${{ matrix.settings.host }}-${{ matrix.settings.target }}-stable
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup node
Expand Down Expand Up @@ -232,52 +244,3 @@ jobs:
--platform "${{ steps.docker.outputs.PLATFORM }}" \
"${{ steps.docker.outputs.IMAGE }}" \
sh -lc "corepack enable && pnpm test"
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
needs:
- lint
- test-macOS-windows-binding
- test-linux-binding
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: create npm dirs
run: pnpm napi create-npm-dirs
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
run: pnpm artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Publish
run: |
npm config set provenance true
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
151 changes: 151 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Release:仅维护者触发,构建四平台并发布到 npm
# 触发方式:
# 1. 手动:Actions → Release → Run workflow(使用当前 main 的 package.json version)
# 2. 打 tag:git tag v0.0.3 && git push origin v0.0.3(需先已把 package.json 改为 0.0.3 并 push)
# 仓库需配置 Secrets → NPM_TOKEN(npm 的 Automation token,Publish 权限)
name: Release
env:
DEBUG: napi:*
APP_NAME: rush-fs
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_INCREMENTAL: '1'
NODE_VERSION: '20'
on:
workflow_dispatch: {}
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: pnpm build --target x86_64-apple-darwin
- host: windows-latest
build: pnpm build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
- host: macos-latest
target: aarch64-apple-darwin
build: pnpm build --target aarch64-apple-darwin
name: build - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Cache Rust toolchain
uses: actions/cache@v4
with:
path: ~/.rustup
key: rustup-${{ matrix.settings.host }}-${{ matrix.settings.target }}-stable
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.napi-rs
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: mlugg/setup-zig@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
with:
version: 0.14.1
- name: Install cargo-zigbuild
uses: taiki-e/install-action@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tool: cargo-zigbuild
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: pnpm install
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: bindings-${{ matrix.settings.target }}
path: |
${{ env.APP_NAME }}.*.node
${{ env.APP_NAME }}.*.wasm
if-no-files-found: error
publish:
name: Publish to npm
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Create npm dirs
run: pnpm napi create-npm-dirs
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
run: pnpm artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Add optionalDependencies for publish
run: |
node -e "
const fs = require('fs');
const p = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const v = p.version;
p.optionalDependencies = {
'rush-fs-win32-x64-msvc': v,
'rush-fs-darwin-x64': v,
'rush-fs-linux-x64-gnu': v,
'rush-fs-darwin-arm64': v
};
fs.writeFileSync('package.json', JSON.stringify(p, null, 2));
"
- name: Publish to npm
run: |
npm config set provenance true
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
pnpm prepublishOnly
npm publish --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 贡献指南

欢迎参与 hyper-fs 开发!本文档将引导你从零开始搭建环境、理解项目架构、实现新 API、编写测试,直到提交一个完整的 PR。
欢迎参与 rush-fs 开发!本文档将引导你从零开始搭建环境、理解项目架构、实现新 API、编写测试,直到提交一个完整的 PR。

## 目录

Expand Down Expand Up @@ -33,7 +33,7 @@
```bash
# 1. 克隆仓库
git clone <repo-url>
cd hyper-fs
cd rush-fs

# 2. 确保 Rust 工具链就绪
rustup default stable
Expand Down Expand Up @@ -67,7 +67,7 @@ pnpm format # 格式化所有代码(Prettier + cargo fmt + taplo)
## 项目架构

```
hyper-fs/
rush-fs/
├── src/ # Rust 源码(核心实现)
│ ├── lib.rs # 模块注册入口
│ ├── types.rs # 共享类型(Dirent, Stats)
Expand Down Expand Up @@ -225,7 +225,7 @@ pnpm build:debug

## 性能优化:并行化

hyper-fs 的核心优势是利用 Rust 的并行能力。以下是常用的并行化手段:
rush-fs 的核心优势是利用 Rust 的并行能力。以下是常用的并行化手段:

### 1. jwalk — 并行目录遍历

Expand Down Expand Up @@ -294,7 +294,7 @@ import { tmpdir } from 'node:os'

// 辅助函数:创建临时目录
function tmpDir(): string {
const dir = join(tmpdir(), `hyper-fs-test-symlink-${Date.now()}-${Math.random().toString(36).slice(2)}`)
const dir = join(tmpdir(), `rush-fs-test-symlink-${Date.now()}-${Math.random().toString(36).slice(2)}`)
mkdirSync(dir, { recursive: true })
return dir
}
Expand Down Expand Up @@ -334,7 +334,7 @@ test('symlinkSync: should match node:fs behavior', (t) => {

#### 2. 双跑对比测试

同时调用 `node:fs` 和 `hyper-fs`,对比返回值。这是确保行为一致性的关键:
同时调用 `node:fs` 和 `rush-fs`,对比返回值。这是确保行为一致性的关键:

```typescript
import * as nodeFs from 'node:fs'
Expand Down Expand Up @@ -416,11 +416,11 @@ import { someSync } from '../index.js'
// 对标 Node.js 原生实现
group('Some API', () => {
bench('Node.js', () => fs.someSync(args)).baseline()
bench('Hyper-FS', () => someSync(args))
bench('Rush-FS', () => someSync(args))
})

// 如果有并发选项,做并发对比
group('Hyper-FS Concurrency', () => {
group('Rush-FS Concurrency', () => {
bench('Default', () => someSync(args)).baseline()
bench('4 Threads', () => someSync(args, { concurrency: 4 }))
bench('8 Threads', () => someSync(args, { concurrency: 8 }))
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
[package]
authors = []
edition = "2021"
name = "hyper_fs"
version = "0.1.0"
name = "rush_fs"
version = "0.0.3"

[lib]
crate-type = ["cdylib"]
Expand Down
Loading