Skip to content

chore: migrate to Rstack CLI - #37

Merged
chenjiahan merged 3 commits into
mainfrom
chore/migrate-to-rstack-cli
Sep 1, 2026
Merged

chenjiahan merged 3 commits into
mainfrom
chore/migrate-to-rstack-cli

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Migrates the repository from standalone Rslib, Rslint and Prettier to the unified Rstack CLI (rstack package, rs commands, single rstack.config.ts).

Configuration

rslib.config.ts, rslint.config.ts and .prettierrc are replaced by a single rstack.config.ts:

  • define.lib — carries over the previous Rslib config (syntax: 'es2023', dts: true)
  • define.lint — carries over the previous Rslint presets, including the existing no-this-alias override for test/**/*
  • define.fmt — carries over singleQuote, and enables sortPackageJson
  • define.test / define.staged — new

Tests: Mocha → Rstest

Mocha was not part of the Rstack toolchain, so the suite is migrated to Rstest.

Every flag of the previous mocha --file test/support/env.js --reporter spec --bail --check-leaks test/ command was audited:

Mocha flag Migrated to Notes
--file test/support/env.js define.test({ env: { NODE_ENV: 'test' } }) Load-bearing: src/index.ts reads NODE_ENV at module scope to silence error logging, so test/support/env.js is removed rather than kept
--reporter spec Rstest default reporter Equivalent output
--bail define.test({ bail: 1 }) Verified: 3 failing specs report 1 failure with the option, 3 without
--check-leaks not carried over See below
test/ Rstest default include Confirmed all 5 files and 53 tests are collected

--check-leaks is intentionally not carried over. It detects global variable leaks, and Rstest has no equivalent option. Its nearest neighbour, detectAsyncLeaks, detects lingering async resources — a different check that the docs describe as a debugging aid that slows tests down. Rather than silently substitute a different behaviour, this is left out and flagged here for a maintainer decision.

Rewrites

Rstest has no Mocha-style done callback, so all five spec files and test/support/rawagent.js are rewritten as promise-based tests:

  • rawagent.expect() now returns a promise and rejects on assertion failure rather than taking a callback.
  • Tests that used done(new Error(...)) to assert a middleware was not invoked now record a flag and assert it after the request completes.
  • should invoke error stack even when headers sent wraps the error-middleware callback in a promise that the test awaits.

All 66 it/describe names are byte-for-byte identical to the originals, and per-file test counts match exactly (1/6/22/9/15). The assertions are semantically equivalent; the three cases above are the only ones whose mechanism changed, since the done-based patterns have no direct Rstest equivalent.

Dependencies

@rslib/core, @rslint/core, mocha, prettier and jiti are replaced by a single rstack dependency. They remain available transitively, as expected for this migration.

This branch is based on top of #36. That renovate update bumped @rslib/core, @rslint/core, mocha and prettier, which are exactly the packages removed here — rstack@0.7.1 already bundles Rslint 0.9.0, Rslib and Prettier 3.9.6. The unrelated bumps from #36 (@types/node, pnpm@11.24.0, workflow action pins) are preserved.

Other

  • Adds .rstack/hooks/pre-commit running rs staged, plus the prepare: rs hooks script.
  • CI now runs pnpm run check (lint + format) in place of the previous lint-only step.
  • Adds the rstack-cli-docs Agent Skill.
  • src/index.ts and .github/renovate.json5 have formatting-only changes from rs fmt.

Verification

  • pnpm test — 53 tests pass, matching the pre-migration count
  • pnpm check and rs check --type-check — pass
  • pnpm install --frozen-lockfile — succeeds
  • The built dist/index.js is byte-identical to the pre-migration output at the migration commit
  • Each rewritten pattern was checked against a deliberately broken variant to confirm it genuinely fails rather than silently passing: mutated assertions fail, the flag-based assertions fail when the middleware is invoked, and the promise-wrapped test times out when the error never fires

The dist/index.js size on this branch is 52.6 kB vs 48.0 kB before. That increase comes from #36, not from this migration: the updated lockfile makes debug's optional supports-color dependency resolvable, which also clears a pre-existing build warning.

Notes for reviewers

  1. --check-leaks has no replacement (see the table above) — please confirm dropping it is acceptable.
  2. rs hooks will skip installation on machines that already set a global core.hooksPath (for example a corporate commit hook). Those users need rs hooks --force to enable the Rstack pre-commit hook, which deactivates the previously configured hooks.

Migrate the repository from standalone Rslib, Rslint and Prettier to the
unified Rstack CLI (`rstack` package, `rs` commands, `rstack.config.ts`).

- Replace rslib.config.ts, rslint.config.ts and .prettierrc with a single
  rstack.config.ts using define.lib / define.lint / define.fmt, and add
  define.test and define.staged.
- Migrate the test suite from Mocha to Rstest. Rstest has no Mocha-style
  `done` callback, so the specs and test/support/rawagent.js are rewritten
  as promise-based tests. The former `--file test/support/env.js` behaviour
  is preserved via define.test({ env: { NODE_ENV: 'test' } }), which
  src/index.ts relies on to silence error logging.
- Replace @rslib/core, @rslint/core, mocha, prettier and jiti with rstack;
  they remain available transitively.
- Add a .rstack/hooks/pre-commit hook running `rs staged`.
- Run `rs check` in CI in place of the previous lint-only step.

All 53 tests pass, matching the pre-migration count. The built dist/index.js
is byte-identical to the pre-migration output.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chenjiahan
chenjiahan merged commit 0450abc into main Sep 1, 2026
4 checks passed
@chenjiahan
chenjiahan deleted the chore/migrate-to-rstack-cli branch September 1, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant