Skip to content

fix: Extract emulator to @workos/emulate#171

Open
gjtorikian wants to merge 6 commits into
mainfrom
so-long-emulate
Open

fix: Extract emulator to @workos/emulate#171
gjtorikian wants to merge 6 commits into
mainfrom
so-long-emulate

Conversation

@gjtorikian
Copy link
Copy Markdown
Contributor

@gjtorikian gjtorikian commented Jun 2, 2026

Summary

  • Replace the in-tree emulator (src/emulate/, ~12k lines) with the standalone @workos/emulate package, so the emulator can ship and version independently of the CLI
  • Promote workos emulate from hidden beta to a visible command with -p/-s/-i flags and help-json registration
  • Remove hono/@hono/node-server direct dependencies (now transitive through the package)
  • Delete route codegen scripts (gen-routes, check-coverage) that only served the in-tree emulator
  • Rewrite emulate.spec.ts to mock @workos/emulate instead of standing up a real server

The emulator code lived in src/emulate/ alongside the CLI,
making it impossible to use outside the CLI (e.g. from CI
or as a standalone binary). Extracting it into its own
package lets the emulator ship independently.
# Conflicts:
#	pnpm-lock.yaml
#	src/bin.ts
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 2, 2026

Greptile Summary

This PR extracts the ~12k-line in-tree WorkOS emulator (src/emulate/) into the standalone @workos/emulate package and promotes workos emulate from a hidden beta to a public command with -p/-s/-i flags.

  • src/commands/emulate.ts is slimmed to a thin wrapper around @workos/emulate; the previously reported unhandled-rejection on shutdown is now fixed with a two-argument .then().
  • src/bin.ts swaps the emulate and dev command implementations: dev (hidden) now runs runDev, while the new visible emulate runs runEmulate with the full flag set registered in help-json.ts.
  • src/commands/emulate.spec.ts is rewritten to mock @workos/emulate rather than standing up a real server, covering port forwarding, JSON output, seed file loading, and auto-detection.

Confidence Score: 5/5

Safe to merge — the change is a well-scoped extraction of the in-tree emulator into an external package with no functional regressions visible in the changed paths.

Previously flagged issues (shutdown rejection, seed-not-found JSON mode) are both addressed in this version. The test rewrite correctly mocks the external package and handles signal-listener cleanup. The command-name swap in bin.ts is consistent with the new help-json registration.

No files require special attention.

Important Files Changed

Filename Overview
src/commands/emulate.ts Thin wrapper around @workos/emulate; shutdown fix applied (.then with two handlers), seed loading and exitWithError usage are correct
src/commands/emulate.spec.ts Tests rewritten to mock @workos/emulate; covers port, JSON output, seed file loading, and auto-detection; signal-listener cleanup looks correct
src/bin.ts emulate/dev command names swapped; emulate promoted to visible with -p/-s/-i flags and correct defaults; dev remains hidden
src/commands/dev.ts Import updated from in-tree emulator to @workos/emulate; JSDoc comment ordering reorganised with no logic changes
src/utils/help-json.ts New emulate entry added with correct port/seed/interactive options and aliases matching bin.ts definitions
package.json @workos/emulate ^0.1.0 added; hono and @hono/node-server removed as direct deps; gen:routes and check:coverage scripts removed

Reviews (3): Last reviewed commit: "style: Format emulate.ts" | Re-trigger Greptile

Comment thread src/commands/emulate.spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant