chore: migrate to Rstack CLI - #37
Merged
Merged
Conversation
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.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the repository from standalone Rslib, Rslint and Prettier to the unified Rstack CLI (
rstackpackage,rscommands, singlerstack.config.ts).Configuration
rslib.config.ts,rslint.config.tsand.prettierrcare replaced by a singlerstack.config.ts:define.lib— carries over the previous Rslib config (syntax: 'es2023',dts: true)define.lint— carries over the previous Rslint presets, including the existingno-this-aliasoverride fortest/**/*define.fmt— carries oversingleQuote, and enablessortPackageJsondefine.test/define.staged— newTests: 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:--file test/support/env.jsdefine.test({ env: { NODE_ENV: 'test' } })src/index.tsreadsNODE_ENVat module scope to silence error logging, sotest/support/env.jsis removed rather than kept--reporter spec--baildefine.test({ bail: 1 })--check-leakstest/include--check-leaksis 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
donecallback, so all five spec files andtest/support/rawagent.jsare rewritten as promise-based tests:rawagent.expect()now returns a promise and rejects on assertion failure rather than taking a callback.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 sentwraps the error-middleware callback in a promise that the test awaits.All 66
it/describenames 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 thedone-based patterns have no direct Rstest equivalent.Dependencies
@rslib/core,@rslint/core,mocha,prettierandjitiare replaced by a singlerstackdependency. 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,mochaandprettier, which are exactly the packages removed here —rstack@0.7.1already 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
.rstack/hooks/pre-commitrunningrs staged, plus theprepare: rs hooksscript.pnpm run check(lint + format) in place of the previous lint-only step.rstack-cli-docsAgent Skill.src/index.tsand.github/renovate.json5have formatting-only changes fromrs fmt.Verification
pnpm test— 53 tests pass, matching the pre-migration countpnpm checkandrs check --type-check— passpnpm install --frozen-lockfile— succeedsdist/index.jsis byte-identical to the pre-migration output at the migration commitThe
dist/index.jssize on this branch is 52.6 kB vs 48.0 kB before. That increase comes from #36, not from this migration: the updated lockfile makesdebug's optionalsupports-colordependency resolvable, which also clears a pre-existing build warning.Notes for reviewers
--check-leakshas no replacement (see the table above) — please confirm dropping it is acceptable.rs hookswill skip installation on machines that already set a globalcore.hooksPath(for example a corporate commit hook). Those users needrs hooks --forceto enable the Rstack pre-commit hook, which deactivates the previously configured hooks.