Bbackstage

backstage/migrate-permissioned-route

Migrate PermissionedRoute to Route + RequirePermission for @backstage/plugin-permission-react

backstagemigrationpermission-reactPermissionedRouteRequirePermission1.50.0
Public
1 executions

Run locally

npx codemod @backstage/migrate-permissioned-route

@backstage/migrate-permissioned-route

Migrates deprecated PermissionedRoute from @backstage/plugin-permission-react to Route (from react-router-dom) wrapping RequirePermission.

Targets Backstage v1.50+ where PermissionedRoute was removed.

Installation

bash

Usage (from this repo)

bash

Optional: AI fixup step

Enable with --param aiFixup=true to address edge cases the AST codemod cannot handle mechanically:

  • Remaining PermissionedRoute references in re-exports, type annotations, or dynamic rendering patterns
  • Dynamic element props with conditional expressions where the RequirePermission wrapping needs verification
  • Type annotations or generic parameters referencing PermissionedRoute

Development

From the repo root:

bash

Or from this package directory:

bash

License

MIT

Before

This is one example from the codemod's test cases. The codemod may handle many more cases.

Ready to contribute?

Build your own codemod and share it with the community.