Repository navigation
ref(cli): Read the route tree from a registry instead of app.ts - #1766
Merged
Merged
Conversation
help.ts and completions.ts imported the route map from app.ts, and list-command.ts loaded it lazily with require(). Every command imports help.ts through buildCommand, so bundling any one command pulled in the whole CLI: every other command, sentry init, and Mastra. app.ts now registers its route map with setRoutes() in lib/route-registry.ts, and help, completions, list-command, and schema read it from there. getRoutes() throws when nothing is registered yet. list-command uses findRoutes() so a command's func called on its own (as unit tests do) still runs without subcommand hints, as before. Another entry point can register a smaller map. Bundling commands/auth/whoami.ts goes from 1822 modules (5.6 MB) to 1156 (2.9 MB), and no longer includes app.ts or Mastra. A test bundles every module in src/lib/ and fails if one reaches app.ts, following lazy _require() loads too. The interceptSubcommand tests that were skipped because that require() failed under vitest now run. Co-Authored-By: BYK <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
BYK
approved these changes
Oct 31, 2026
# Conflicts: # packages/cli/script/build.ts # packages/cli/script/bundle.ts
BYK
approved these changes
Oct 31, 2026
BYK
enabled auto-merge (squash)
October 31, 2026 14:34
sentry-junior Bot
added a commit
that referenced
this pull request
Oct 31, 2026
Brings in the #1766 squash (route registry). This branch already merged #1766's branch, and its final head only added main's #1763-#1765, which are here too, so every conflict (`app.ts`, `lib/help.ts`, `script/bundle.ts`) resolves to this branch's version: the application setup and `setRoutes()` live in `lib/application.ts`, help names come from `lib/app-identity.ts`, and the require-alias filter is the shared `script/lib/require-alias-plugin.ts`. The tree is unchanged.
This branch was previously deployed
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.
This is groundwork for #1731. That PR builds
@sentry/mcp-serverfrom the real CLI runner with a smaller route map ({ mcp, auth, help },mcpas the default command). Today that can't work:lib/help.tsandlib/completions.tsimportroutesfromapp.ts, andlib/list-command.tsloads it lazily withrequire(). Every command importshelp.tsthroughbuildCommand, so bundling any one command pulls in the whole CLI: every other command,sentry init, and Mastra.app.tsnow registers its route map withsetRoutes()in the newlib/route-registry.ts.help,completions,list-command, and theschemacommand read it from there.getRoutes()throws a clear error when nothing has been registered.list-commandusesfindRoutes()instead, so a command'sfunccalled on its own, as unit tests do, still runs without subcommand hints, as it did before. Another entry point can register a smaller map.Output doesn't change:
sentry --help,sentry help --json,sentry cli completion bash,sentry schema issues --json, andsentry projects list --helpare byte-identical before and after, from source and from the npm bundle. The plural-alias hint (sentry projects list→Tip: "list" is a subcommand) still works in the bundle.Bundle size with an esbuild metafile (minified ESM, the same plugins as
script/bundle.ts):commands/auth/whoami.tslib/command.tscommands/auth/index.tscommands/mcp.tsAfter the change, none of these include
app.tsor@mastra/*.Guard:
test/lib/route-registry.test.tsbundles every module insrc/lib/and fails, naming the importer, if any of them reachesapp.ts. It follows lazy_require()loads too.sdk-invoke.tsis the one exception: it's the library-mode runner, reached only fromsrc/index.ts, and it executes the whole app. The threeinterceptSubcommandtests that were skipped because thatrequire()failed under vitest now run.list-commandno longer needs therequire-aliasrewrite, so it's removed from the filters inscript/build.tsandscript/bundle.ts.Not included, left for #1731 or later PRs:
cli.tsstill imports./app.jsforrun()and unknown-command reporting. Making the application injectable is the next step. I leftcli.tsalone here to stay clear of #1762. This branch merges cleanly with #1762.whoamialso still reacheslib/init/ui/ink-ui.tsthroughresolve-target.ts(the Ink prompt UI, not the init wizard).via BYK.
--
View Session in Sentry