feat(messenger): add generate-action-types CLI tool as subpath export#8264
Merged
cryptodev-2s merged 44 commits intomainfrom Apr 1, 2026
Merged
feat(messenger): add generate-action-types CLI tool as subpath export#8264cryptodev-2s merged 44 commits intomainfrom
generate-action-types CLI tool as subpath export#8264cryptodev-2s merged 44 commits intomainfrom
Conversation
@metamask/messenger-generate-action-types packagegenerate-action-types CLI tool as subpath export
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Extract `scripts/generate-method-action-types.ts` into a publishable CLI package so it can be reused across repositories. - Scaffold `@metamask/messenger-generate-action-types` with bin entry - Split script into modular source files (parse, generate, check, fix) - Use named TypeScript imports, optional ESLint peer dependency - Update 44 consuming packages to use the new binary - Update package template, CODEOWNERS, teams.json, eslint config - Add ESLint config exception for Node.js module imports - Regenerate all action type files with updated header - Delete old `scripts/generate-method-action-types.ts`
The binary requires a build step before it can be used. Using tsx to run the source TypeScript directly avoids this dependency.
Move the CLI tool into @metamask/messenger as a subpath export instead of a separate package. This keeps the library lightweight while making the codegen available via optional peer dependencies. - Move source files to packages/messenger/src/generate-action-types/ - Add ./generate-action-types subpath export and bin entry - typescript, yargs, eslint are optional peerDependencies - @metamask/utils added as dependency (needed by codegen) - Remove standalone @metamask/messenger-generate-action-types package - Update 44 consuming packages to point to new location - Revert CODEOWNERS, teams.json, tsconfig, README changes
- Remove unused `MethodInfo.signature` field - Remove redundant `ControllerInfo.exposedMethods` (derivable from methods) - Extract shared ESLint types to `types.ts`, deduplicate across check/fix - Combine eslint/eslintStatic params into single `ESLint | null` object - Inline single-use `capitalize()` helper - Remove unused `Identifier` type import and `extractMethodSignature`
89da66f to
0202e79
Compare
Move `@metamask/utils` from peerDependencies to dependencies in the messenger package since it is a required runtime dependency. Also replace `globalThis.process.exitCode` with `process.exitCode` to fix an ESLint violation.
Apply the same ESLint fix as in fix.ts — use `process.exitCode` directly instead of `globalThis.process.exitCode`.
Already listed under dependencies, so the devDependencies entry is redundant.
…perps action types Update base-data-service and phishing-controller to point their generate-method-action-types script at the new messenger CLI. Regenerate PerpsController action types to reflect current API.
…ion-types tests Replace manual mkdtemp/rm temp directory management with the createSandbox utility from @metamask/utils/node across all 4 test files. Add @metamask/utils/node subpath mapping to the shared jest.config.packages.js so all packages can resolve it.
Return boolean from checkActionTypesFiles and generateAllActionTypesFiles instead of setting process.exitCode directly. Only cli.ts now sets the exit code, keeping the global side effect in a single location.
Replace the wrapped outputFixes/getErrorResults functions with an eslintClass reference so callers use the static methods directly, making it clear these are class-level operations.
… load failure Add directory exclusions (node_modules, dist, .git, coverage) to the recursive file walker to avoid traversing irrelevant trees. Also log a warning when ESLint fails to load instead of silently skipping formatting.
…te-action-types-package
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| console.error('\n💥 Some action type files are out of date or missing.'); | ||
| console.error( | ||
| 'Run `yarn generate-method-action-types --fix` to update them.', | ||
| ); |
There was a problem hiding this comment.
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Mrtenz
reviewed
Apr 1, 2026
Allow consumers on TypeScript 5.x beyond 5.3 while keeping devDependency pinned.
Mrtenz
approved these changes
Apr 1, 2026
abretonc7s
approved these changes
Apr 1, 2026
wantedsystem
approved these changes
Apr 1, 2026
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.


Explanation
The script
scripts/generate-method-action-types.tsgenerates TypeScript action type files for controllers/services that defineMESSENGER_EXPOSED_METHODS. It was a monorepo-local script invoked viatsx ../../scripts/generate-method-action-types.tsfrom 44 packages.This PR moves it into
@metamask/messengeras a CLI tool, keeping the library lightweight while making the codegen reusable in other repositories.What changed:
generate-action-types/subdirectory underpackages/messenger/src/with modular source files (parse-source.ts,generate-content.ts,check.ts,fix.ts,cli.ts)messenger-generate-action-typesbin entry to@metamask/messengeryargsis the only runtime dependency;@metamask/utils,typescript, andeslintare non-optional peer dependencies (required for the CLI, but provided by the consuming project). The coreMessengerlibrary remains lightweight.tsx ../../packages/messenger/src/generate-action-types/cli.tsscripts/generate-method-action-types.tsexeca+tsxverify exact generated output for controllers and servicesWorking examples in external repos:
References
Checklist
Note
Medium Risk
Mostly build/tooling changes, but it touches many packages and changes the action-type generation pipeline; failures would surface as broken scripts or mismatched generated files across the monorepo.
Overview
Adds a new
@metamask/messengercodegen CLI (messenger-generate-action-types) that discovers controllers/services withMESSENGER_EXPOSED_METHODSand supports--fixand--checkworkflows, including optional ESLint formatting and extensive unit/functional tests.Migrates dozens of packages’
generate-method-action-typesscripts to call the new CLI entrypoint, deletes the legacyscripts/generate-method-action-types.ts, and updates generated*-method-action-types.tsoutputs (header/JSDoc normalization and some regenerated action unions). Also updates repo config to support the new tooling (ESLint rule exception for the generator folder and Jest module mapping for@metamask/utils/node).Written by Cursor Bugbot for commit ca19d18. This will update automatically on new commits. Configure here.