@backstage/add-update-location-method
Backstage 1.50.0 migration codemod that adds the required updateLocation method to CatalogApi and CatalogService implementations.
What it does
Starting in Backstage 1.50.0, the CatalogApi (from @backstage/catalog-client) and CatalogService (from @backstage/plugin-catalog-node) interfaces require an updateLocation method. The default CatalogClient already includes it -- this codemod only affects custom implementations and test mocks.
Class implementations
For classes with implements CatalogApi or implements CatalogService, the codemod adds a throwing stub method:
ts
The codemod also adds missing Location and options type imports as needed.
Test mocks
For mock objects typed as jest.Mocked<CatalogApi>, vi.Mocked<CatalogApi>, Partial<jest.Mocked<CatalogApi>>, or cast via as unknown as jest.Mocked<CatalogApi>, the codemod adds:
ts
Skipped cases
- Classes/mocks that already have
updateLocationdefined are left unchanged - Objects not typed with
CatalogApiorCatalogServiceare left unchanged - Duck-typed objects (no explicit
implementsclause orMocked<CatalogApi>type) require manual migration
Known limitations
- Duck-typed objects: Objects that satisfy the CatalogApi interface without an explicit type annotation are not detected. Use the AI fixup step or migrate manually.
- Factory functions: Functions that return
CatalogApi-typed objects are not detected. - Proxy/wrapper patterns: Dynamic implementations wrapping CatalogApi are not detected.
Optional: AI fixup step
Enable with --param aiFixup=true to address edge cases the AST codemod cannot handle mechanically (duck-typed objects, factory functions, proxy patterns).
Installation
bash
Usage (from this repo)
bash
Development
From the repo root:
bash
Or from this package directory:
bash
License
MIT