feat: use @metamask/messenger/generate-action-types CLI#575
Draft
cryptodev-2s wants to merge 5 commits intomainfrom
Draft
feat: use @metamask/messenger/generate-action-types CLI#575cryptodev-2s wants to merge 5 commits intomainfrom
cryptodev-2s wants to merge 5 commits intomainfrom
Conversation
Replace local copy-pasted script with the CLI from @metamask/messenger. Uses preview build until release.
4 tasks
ab9384b to
3166d8d
Compare
3166d8d to
9626783
Compare
Use resolutions to override @metamask/messenger and @metamask/base-controller with preview builds. This ensures consistent types across all transitive dependencies and fixes the build.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
5555741 to
7e4a4c9
Compare
github-merge-queue bot
pushed a commit
to MetaMask/core
that referenced
this pull request
Apr 1, 2026
…rt (#8264) ## Explanation The script `scripts/generate-method-action-types.ts` generates TypeScript action type files for controllers/services that define `MESSENGER_EXPOSED_METHODS`. It was a monorepo-local script invoked via `tsx ../../scripts/generate-method-action-types.ts` from 44 packages. This PR moves it into `@metamask/messenger` as a CLI tool, keeping the library lightweight while making the codegen reusable in other repositories. **What changed:** - Add `generate-action-types/` subdirectory under `packages/messenger/src/` with modular source files (`parse-source.ts`, `generate-content.ts`, `check.ts`, `fix.ts`, `cli.ts`) - Add `messenger-generate-action-types` bin entry to `@metamask/messenger` - `yargs` is the only runtime dependency; `@metamask/utils`, `typescript`, and `eslint` are non-optional peer dependencies (required for the CLI, but provided by the consuming project). The core `Messenger` library remains lightweight. - Recursive directory search discovers controllers/services in subdirectories automatically, removing the need for per-subdirectory scripts - Update all 44 consuming packages to invoke the CLI via `tsx ../../packages/messenger/src/generate-action-types/cli.ts` - Delete old `scripts/generate-method-action-types.ts` - Functional tests via `execa` + `tsx` verify exact generated output for controllers and services **Working examples in external repos:** - MetaMask/smart-transactions-controller#575 - MetaMask/snaps#3914 ## References - Consumer PRs: [smart-transactions-controller#575](MetaMask/smart-transactions-controller#575), [snaps#3914](MetaMask/snaps#3914) ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!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/messenger` codegen CLI (`messenger-generate-action-types`) that discovers controllers/services with `MESSENGER_EXPOSED_METHODS` and supports `--fix` and `--check` workflows, including optional ESLint formatting and extensive unit/functional tests. > > Migrates dozens of packages’ `generate-method-action-types` scripts to call the new CLI entrypoint, deletes the legacy `scripts/generate-method-action-types.ts`, and updates generated `*-method-action-types.ts` outputs (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`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ca19d18. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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
Replace the local copy-pasted
scripts/generate-method-action-types.ts(759 lines) with the CLI from@metamask/messenger/generate-action-types.Currently uses a preview build (
@metamask-previews/messenger@0.3.0-preview-f11c28cc2) via npm alias. Once MetaMask/core#8264 is merged and released, the dependency should be updated to the released version.References
generate-action-typesCLI tool as subpath export core#8264