Skip to content

Commit 5bda53e

Browse files
committed
Merge pull request #12 from CoderSerio/doc/carbon-dev
docs: add CHANGELOG.md and update README with installation troublesho…
2 parents d45752f + c8c2ee0 commit 5bda53e

File tree

9 files changed

+150
-68
lines changed

9 files changed

+150
-68
lines changed

.github/workflows/Release.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,6 @@ jobs:
126126
- name: List packages
127127
run: ls -R ./npm
128128
shell: bash
129-
- name: Add optionalDependencies for publish
130-
run: |
131-
node -e "
132-
const fs = require('fs');
133-
const p = JSON.parse(fs.readFileSync('package.json', 'utf8'));
134-
const v = p.version;
135-
p.optionalDependencies = {
136-
'@rush-fs/rush-fs-win32-x64-msvc': v,
137-
'@rush-fs/rush-fs-darwin-x64': v,
138-
'@rush-fs/rush-fs-linux-x64-gnu': v,
139-
'@rush-fs/rush-fs-darwin-arm64': v
140-
};
141-
fs.writeFileSync('package.json', JSON.stringify(p, null, 2));
142-
"
143129
- name: Update platform package names to use scope (@rush-fs/xxx)
144130
run: |
145131
for dir in npm/*/; do
@@ -193,6 +179,19 @@ jobs:
193179
# 主包 index.js 里 require 的是 rush-fs-xxx,改为 @rush-fs/rush-fs-xxx 才能找到已发布的平台包
194180
sed -i "s/require('rush-fs-/require('@rush-fs\/rush-fs-/g" index.js
195181
sed -i 's/require(\"rush-fs-/require(\"@rush-fs\/rush-fs-/g' index.js
182+
# optionalDependencies 必须在 prepublish 之后注入,否则会被 prepublish 覆盖,导致用户 pnpm i rush-fs 时不会自动安装平台包
183+
node -e "
184+
const fs = require('fs');
185+
const p = JSON.parse(fs.readFileSync('package.json', 'utf8'));
186+
const v = p.version;
187+
p.optionalDependencies = {
188+
'@rush-fs/rush-fs-win32-x64-msvc': v,
189+
'@rush-fs/rush-fs-darwin-x64': v,
190+
'@rush-fs/rush-fs-linux-x64-gnu': v,
191+
'@rush-fs/rush-fs-darwin-arm64': v
192+
};
193+
fs.writeFileSync('package.json', JSON.stringify(p, null, 2));
194+
"
196195
npm publish --access public
197196
env:
198197
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog
2+
3+
All notable changes to Rush-FS are documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4+
5+
## [Unreleased]
6+
7+
- (Add new changes here before each release.)
8+
9+
## [0.0.5] - (release date TBD)
10+
11+
- Re-publish with `optionalDependencies` correctly injected after `napi prepublish`, so `pnpm i rush-fs` / `npm i rush-fs` auto-installs the platform native binding. No API or behavior changes from 0.0.4.
12+
13+
## [0.0.4] - (release date TBD)
14+
15+
### Fixed
16+
17+
- **Publish:** `optionalDependencies` are now injected **after** `napi prepublish` in the Release workflow, so the published npm package correctly lists platform packages. Installing `rush-fs` will again auto-install the native binding for your OS/arch (e.g. `@rush-fs/rush-fs-darwin-arm64`). If you are on an older version and see "Cannot find native binding", see [README#Installation](./README.md#installation) for a manual fix.
18+
19+
### Added
20+
21+
- **Docs:** Nextra-based documentation site under `docs/` with i18n (EN / 中文), guide, API reference, and benchmarks.
22+
- **README:** Installation troubleshooting: how to reinstall or manually add the platform package when the native binding is missing.
23+
24+
## [0.0.3] - (historical)
25+
26+
- Earlier releases; see [GitHub Releases](https://github.com/CoderSerio/rush-fs/releases) for tags and assets.
27+
28+
---
29+
30+
[Unreleased]: https://github.com/CoderSerio/rush-fs/compare/v0.0.5...HEAD
31+
[0.0.5]: https://github.com/CoderSerio/rush-fs/compare/v0.0.4...v0.0.5
32+
[0.0.4]: https://github.com/CoderSerio/rush-fs/compare/v0.0.3...v0.0.4
33+
[0.0.3]: https://github.com/CoderSerio/rush-fs/releases/tag/v0.0.3

CONTRIBUTING-CN.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,3 +506,14 @@ GitHub Actions 会在 push / PR 时自动执行:
506506
4. **Publish** — 版本 tag 触发自动发布到 npm
507507

508508
本地开发只需关注 `pnpm build:debug` + `pnpm test`,CI 会处理跨平台验证。
509+
510+
### 发布前/后检查(维护者)
511+
512+
打新版本时(在运行 Release 工作流**之前**):
513+
514+
1. **升级版本号**(两处需一致):
515+
- `package.json``"version": "x.y.z"`
516+
- `Cargo.toml``version = "x.y.z"`
517+
- npm 不允许覆盖已发布版本;若上次发布半途失败但版本已上 npm(例如 0.0.4 已存在),需先改为新版本号(如 0.0.5)再重新发布。
518+
2. **更新 [CHANGELOG.md](CHANGELOG.md)**:将 **\[Unreleased]** 下的条目移到新的 `## [x.y.z] - YYYY-MM-DD` 小节,并在文末补充该版本的链接(`[x.y.z]: https://github.com/CoderSerio/rush-fs/compare/vA.B.C...vx.y.z`)。
519+
3. **执行发布**:推送到 `main` 后,在 **Actions → Release → Run workflow** 中运行,或执行 `git tag vx.y.z && git push origin vx.y.z`

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,14 @@ GitHub Actions on push/PR:
508508
4. **Publish** — Triggered by version tags; see [Release workflow](.github/workflows/Release.yml)
509509

510510
For local development, `pnpm build:debug` and `pnpm test` are enough; CI handles cross-platform checks.
511+
512+
### Release checklist (maintainers)
513+
514+
When cutting a new version (before running the Release workflow):
515+
516+
1. **Bump version** in both places (must stay in sync):
517+
- `package.json``"version": "x.y.z"`
518+
- `Cargo.toml``version = "x.y.z"`
519+
- npm does not allow re-publishing the same version; if a previous run partially published (e.g. 0.0.4 already on npm), bump to the next version (e.g. 0.0.5) and release again.
520+
2. **Update [CHANGELOG.md](CHANGELOG.md):** move items from **\[Unreleased]** into a new `## [x.y.z] - YYYY-MM-DD` section, and add the version link at the bottom (`[x.y.z]: https://github.com/CoderSerio/rush-fs/compare/vA.B.C...vx.y.z`).
521+
3. **Run Release:** push to `main`, then either **Actions → Release → Run workflow** or `git tag vx.y.z && git push origin vx.y.z`.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
authors = []
44
edition = "2021"
55
name = "rush_fs"
6-
version = "0.0.3"
6+
version = "0.0.5"
77

88
[lib]
99
crate-type = ["cdylib"]

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ npm install rush-fs
2525
pnpm add rush-fs
2626
```
2727

28+
When you install `rush-fs`, the package manager should automatically install the **platform-specific native binding** for your OS/arch via `optionalDependencies` (e.g. `@rush-fs/rush-fs-darwin-arm64` on macOS ARM). If the native binding is missing and you see "Cannot find native binding", try:
29+
30+
1. Remove `node_modules` and the lockfile (`package-lock.json` or `pnpm-lock.yaml`), then run `pnpm install` (or `npm i`) again.
31+
2. Or install the platform package explicitly:
32+
**macOS ARM:** `pnpm add @rush-fs/rush-fs-darwin-arm64`
33+
**macOS x64:** `pnpm add @rush-fs/rush-fs-darwin-x64`
34+
**Windows x64:** `pnpm add @rush-fs/rush-fs-win32-x64-msvc`
35+
**Linux x64 (glibc):** `pnpm add @rush-fs/rush-fs-linux-x64-gnu`
36+
2837
## Usage
2938

3039
```ts
@@ -466,6 +475,10 @@ We are rewriting `fs` APIs one by one.
466475

467476
- **Status**: ❌
468477

478+
## Changelog
479+
480+
See [CHANGELOG.md](./CHANGELOG.md) for a summary of changes in each version. Release tags are listed in [GitHub Releases](https://github.com/CoderSerio/rush-fs/releases).
481+
469482
## Contributing
470483

471484
See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full development guide: environment setup, Node.js reference, Rust implementation, testing, and benchmarking.
@@ -476,6 +489,7 @@ Releases are handled by the [Release workflow](.github/workflows/Release.yml): i
476489

477490
1. **Secrets:** In the repo **Settings → Secrets and variables → Actions**, add **NPM_TOKEN** (npm Classic or Automation token with Publish permission).
478491
2. **Release:** Either run **Actions → Release → Run workflow** (uses the current `package.json` version on `main`), or bump version in `package.json` and `Cargo.toml`, push to `main`, then create and push a tag: `git tag v<version> && git push origin v<version>`.
492+
3. **Changelog:** Update [CHANGELOG.md](./CHANGELOG.md) before or right after the release (move entries from `[Unreleased]` to a new version heading and add the compare link).
479493

480494
The workflow injects `optionalDependencies` and publishes all packages; no need to edit `package.json` manually for release.
481495

README.zh-CN.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ npm install rush-fs
2424
pnpm add rush-fs
2525
```
2626

27+
安装 `rush-fs` 时,包管理器会通过 `optionalDependencies` 自动安装**当前平台**的本地绑定(例如 macOS ARM 上的 `@rush-fs/rush-fs-darwin-arm64`)。若未安装或出现「Cannot find native binding」:
28+
29+
1. 删除 `node_modules` 和锁文件(`package-lock.json``pnpm-lock.yaml`)后重新执行 `pnpm install`(或 `npm i`)。
30+
2. 或手动安装对应平台包:
31+
**macOS ARM:** `pnpm add @rush-fs/rush-fs-darwin-arm64`
32+
**macOS x64:** `pnpm add @rush-fs/rush-fs-darwin-x64`
33+
**Windows x64:** `pnpm add @rush-fs/rush-fs-win32-x64-msvc`
34+
**Linux x64 (glibc):** `pnpm add @rush-fs/rush-fs-linux-x64-gnu`
35+
2736
## 用法
2837

2938
```ts
@@ -465,6 +474,10 @@ graph TD
465474

466475
- **状态**:❌
467476

477+
## 更新日志
478+
479+
各版本变更见 [CHANGELOG.md](./CHANGELOG.md)。发布 tag 列表见 [GitHub Releases](https://github.com/CoderSerio/rush-fs/releases)
480+
468481
## 贡献
469482

470483
参阅 [CONTRIBUTING-CN.md](./CONTRIBUTING-CN.md) 获取完整开发指南:环境搭建、参考 Node.js 源码、编写 Rust 实现、测试与性能基准。
@@ -475,6 +488,7 @@ graph TD
475488

476489
1. **Secrets:** 在仓库 **Settings → Secrets and variables → Actions** 中添加 **NPM_TOKEN**(npm Classic 或 Automation token,需具备 Publish 权限)。
477490
2. **发布:****Actions → Release → Run workflow** 中手动运行(使用当前 `main` 上的 `package.json` 版本),或先更新 `package.json``Cargo.toml` 中的版本号并推送到 `main`,再创建并推送 tag:`git tag v<版本号> && git push origin v<版本号>`
491+
3. **更新日志:** 发布前或发布后更新 [CHANGELOG.md](./CHANGELOG.md)(将 `[Unreleased]` 下的条目移到新版本标题下并补充 compare 链接)。
478492

479493
工作流会自动注入 `optionalDependencies` 并发布所有包,无需在 `package.json` 中手动填写。
480494

0 commit comments

Comments
 (0)