Bbackstage

backstage/portable-schema-method-call

Backstage 1.51.0: Call PortableSchema.schema() as a method instead of property access

backstagemigrationPortableSchemaschemafrontend-plugin-api1.51.0
Public
0 executions

Run locally

npx codemod @backstage/portable-schema-method-call

@backstage/portable-schema-method-call

Backstage 1.51.0 migration codemod that rewrites PortableSchema.schema property access to method calls.

What it does

In Backstage 1.51.0, the deprecated property form of PortableSchema.schema was removed from @backstage/frontend-plugin-api. The schema member is now a plain method and must be called as schema().

This codemod rewrites:

  • portableSchema.schema.type -> portableSchema.schema().type
  • config.schema.properties -> config.schema().properties
  • Optional chaining: schema?.type -> schema()?.type

The codemod only rewrites .schema.<jsonSchemaProp> when the receiver is typed as PortableSchema (or a local alias), and only in files that import or reference PortableSchema. Unrelated .schema members — including config objects in files that import other symbols from @backstage/frontend-plugin-api — are left unchanged.

What is NOT migrated (AST step)

  • Bare assignments like const s = x.schema (no JSON Schema property access) — use --param aiFixup=true or migrate manually
  • Type-only references to the old property form
  • Unrelated config objects that happen to use a schema property name

Optional: AI fixup step

Enable with --param aiFixup=true:

  • Fixes remaining .schema.type / .schema.properties without ()
  • Migrates const s = portable.schema value assignments
  • Reverts false positives on non-PortableSchema .schema members
  • Updates type annotations referencing the old property form

Installation

bash

Usage (from this repo)

bash

Development

From the repo root:

bash

Or from this package directory:

bash

Ready to contribute?

Build your own codemod and share it with the community.