Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/migrate-bui-props-to-intersection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/migrate-bui-props-to-intersection': minor
---

Add codemod to migrate ComboboxProps/SelectProps interface extends to type intersection for Backstage 1.52.0
5 changes: 5 additions & 0 deletions .changeset/migrate-select-combobox-deprecated-props.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/migrate-select-combobox-deprecated-props': minor
---

Add codemod to migrate deprecated Select/Combobox search props and option value to id for Backstage 1.52.0
5 changes: 5 additions & 0 deletions .changeset/remove-stitching-strategy-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/remove-stitching-strategy-mode': minor
---

Add codemod to remove deprecated catalog.stitchingStrategy.mode from app-config for Backstage 1.52.0
5 changes: 5 additions & 0 deletions .changeset/rename-bui-css-tokens-v1-52.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/rename-bui-css-tokens-v1-52': minor
---

Add codemod to rename deprecated BUI semantic color tokens for Backstage 1.52.0
5 changes: 5 additions & 0 deletions .changeset/v1-52-0-migration-recipe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/v1-52-0-migration-recipe': minor
---

Add v1.52.0 migration recipe that runs every @backstage v1.52.0 codemod in a safe order
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ See the [Codemod docs](https://docs.codemod.com) for more on building and runnin

<!-- CODEMODS_START -->

### v1.52.0

Run the [`migration-recipe`](./codemods/v1.52.0/migration-recipe) to apply every codemod below in one pass, or run any individual codemod on its own.

| Codemod | Description |
| ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [migrate-bui-props-to-intersection](./codemods/v1.52.0/migrate-bui-props-to-intersection) | Migrate ComboboxProps/SelectProps interface extends to type intersection |
| [migrate-select-combobox-deprecated-props](./codemods/v1.52.0/migrate-select-combobox-deprecated-props) | Migrate deprecated Select/Combobox search props and option value to id |
| [migration-recipe](./codemods/v1.52.0/migration-recipe) | Migration recipe that runs every @backstage v1.52.0 codemod from the registry in a safe order. |
| [remove-stitching-strategy-mode](./codemods/v1.52.0/remove-stitching-strategy-mode) | Remove deprecated catalog.stitchingStrategy.mode from app-config |
| [rename-bui-css-tokens-v1-52](./codemods/v1.52.0/rename-bui-css-tokens-v1-52) | Rename deprecated BUI semantic color tokens |

### v1.51.0

Run the [`migration-recipe`](./codemods/v1.51.0/migration-recipe) to apply every codemod below in one pass, or run any individual codemod on its own.
Expand All @@ -26,25 +38,6 @@ Run the [`migration-recipe`](./codemods/v1.51.0/migration-recipe) to apply every
| [rename-header-main-class](./codemods/v1.51.0/rename-header-main-class) | Rename removed .bui-Header to .bui-HeaderContent and classNames.root to classNames.content |
| [render-test-app-nav-migration](./codemods/v1.51.0/render-test-app-nav-migration) | Migrate renderInTestApp nav-item tests to renderTestApp for Backstage 1.51.0 |

### v1.50.0

Run the [`migration-recipe`](./codemods/v1.50.0/migration-recipe) to apply every codemod below in one pass, or run any individual codemod on its own.

| Codemod | Description |
| --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [add-entity-ref-to-location](./codemods/v1.50.0/add-entity-ref-to-location) | Add required entityRef field to Location object literals from @backstage/catalog-client |
| [add-update-location-method](./codemods/v1.50.0/add-update-location-method) | Add required updateLocation method to CatalogApi and CatalogService implementations |
| [catalog-node-alpha-to-stable](./codemods/v1.50.0/catalog-node-alpha-to-stable) | Replace deprecated @backstage/plugin-catalog-node/alpha exports with stable equivalents |
| [dialog-api-show-to-open](./codemods/v1.50.0/dialog-api-show-to-open) | Replace deprecated DialogApi .show() and .showModal() with .open() |
| [header-tab-to-nav-tab-item](./codemods/v1.50.0/header-tab-to-nav-tab-item) | Rename HeaderTab to HeaderNavTabItem and remove matchStrategy property in @backstage/ui |
| [humanize-entity-ref-to-presentation](./codemods/v1.50.0/humanize-entity-ref-to-presentation) | Replace deprecated humanizeEntityRef/humanizeEntity with Catalog Presentation API |
| [migrate-permissioned-route](./codemods/v1.50.0/migrate-permissioned-route) | Migrate PermissionedRoute to Route + RequirePermission for @backstage/plugin-permission-react |
| [migrate-signals-service](./codemods/v1.50.0/migrate-signals-service) | Rename deprecated SignalService exports to SignalsService in @backstage/plugin-signals-node |
| [migration-recipe](./codemods/v1.50.0/migration-recipe) | Migration recipe that runs every @backstage v1.50.0 codemod from the registry in a safe order. |
| [remove-bootstrap-env-proxy](./codemods/v1.50.0/remove-bootstrap-env-proxy) | Remove deprecated bootstrapEnvProxyAgents() call and import from @backstage/cli-common |
| [rename-plugin-header-toolbar](./codemods/v1.50.0/rename-plugin-header-toolbar) | Rename .bui-PluginHeaderToolbarWrapper to .bui-PluginHeaderToolbar and classNames.toolbarWrapper to classNames.toolbar |
| [replace-create-schema-from-zod](./codemods/v1.50.0/replace-create-schema-from-zod) | Replace createSchemaFromZod and config.schema with configSchema |

Older versions are available in the [`codemods/`](./codemods) directory.

<!-- CODEMODS_END -->
Expand Down
20 changes: 20 additions & 0 deletions codemods/v1.52.0/migrate-bui-props-to-intersection/codemod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
schema_version: '1.0'

name: '@backstage/migrate-bui-props-to-intersection'
version: '0.1.0'
description: 'Backstage 1.52.0: Migrate ComboboxProps/SelectProps interface extends to type intersection'
author: 'Paul Schultz<pschultz@redhat.com>'
license: 'Apache-2.0'
repository: 'https://github.com/backstage/codemods'
workflow: 'workflow.yaml'

targets:
languages: ['tsx', 'ts', 'css']

keywords: ['backstage', 'migration', 'ui', 'combobox', 'select', 'props', '1.52.0']

registry:
access: 'public'
visibility: 'public'

capabilities: []
13 changes: 13 additions & 0 deletions codemods/v1.52.0/migrate-bui-props-to-intersection/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@backstage/migrate-bui-props-to-intersection",
"version": "0.1.0",
"description": "Backstage 1.52.0: Migrate ComboboxProps/SelectProps interface extends to type intersection",
"type": "module",
"scripts": {
"test": "yarn exec codemod jssg test -l tsx ./scripts/codemod.ts ./tests && yarn exec codemod jssg test -l css ./scripts/codemod-css.ts ./tests-css && yarn exec codemod workflow validate -w workflow.yaml"
},
"devDependencies": {
"@codemod.com/jssg-types": "1.5.2",
"codemod": "1.7.15"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Codemod, Edit } from 'codemod:ast-grep'
import type CSS from 'codemod:ast-grep/langs/css'
import { useMetricAtom } from 'codemod:metrics'

const migrationMetric = useMetricAtom('migrate-bui-props-to-intersection')

const TODO_COMMENT =
'/* TODO(backstage-codemod): Select popover DOM structure changed — list content is now inside .bui-PopoverContent wrapper */'

const transform: Codemod<CSS> = async (root) => {
const rootNode = root.root()
const edits: Edit[] = []

// Find all rule_set nodes (CSS rulesets) and check their selectors
const rulesets = rootNode.findAll({
rule: {
kind: 'rule_set',
},
})

for (const ruleset of rulesets) {
const selectors = ruleset.find({
rule: { kind: 'selectors' },
})
if (!selectors) {
continue
}

const selectorText = selectors.text()

// Check if selector contains .bui-SelectPopover followed by > (direct child combinator)
if (!/\.bui-SelectPopover\s*>/.test(selectorText)) {
continue
}

// Prepend the TODO comment at the same indentation as the rule set
const rulesetText = ruleset.text()
const indentMatch = rulesetText.match(/^(\s*)/)
const indent = indentMatch ? indentMatch[1] : ''
edits.push(ruleset.replace(`${indent}${TODO_COMMENT}\n${rulesetText}`))
migrationMetric.increment({ action: 'css-selector-todo-added' })
}

const result = await Promise.resolve(edits.length > 0 ? rootNode.commitEdits(edits) : null)
return result
}

export default transform
Loading