Commit 7f0ee6b
authored
feat(messenger): add
## 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 -->generate-action-types CLI tool as subpath export (#8264)1 parent ebb4317 commit 7f0ee6b
70 files changed
Lines changed: 2738 additions & 892 deletions
File tree
- packages
- account-tree-controller
- accounts-controller
- address-book-controller
- analytics-controller
- analytics-data-regulation-controller
- announcement-controller
- approval-controller
- assets-controllers
- assets-controller
- base-data-service
- claims-controller
- client-controller
- compliance-controller
- config-registry-controller
- src/config-registry-api-service
- connectivity-controller
- core-backend
- delegation-controller
- earn-controller
- ens-controller
- gas-fee-controller
- gator-permissions-controller
- geolocation-controller
- src/geolocation-api-service
- logging-controller
- messenger
- src/generate-action-types
- multichain-account-service
- name-controller
- network-controller
- network-enablement-controller
- notification-services-controller
- permission-controller
- permission-log-controller
- perps-controller/src
- phishing-controller
- preferences-controller
- profile-metrics-controller
- profile-sync-controller
- ramps-controller
- remote-feature-flag-controller
- sample-controllers
- src/sample-gas-prices-service
- seedless-onboarding-controller
- selected-network-controller
- shield-controller
- signature-controller
- social-controllers
- storage-service
- subscription-controller
- transaction-controller
- transaction-pay-controller
- user-operation-controller
- scripts
- create-package/package-template
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
224 | 230 | | |
225 | 231 | | |
226 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments