Repository navigation
Conversation
Steps 1-5 of #193: move removed @backstage/frontend-plugin-api/alpha and relocated exports, replace removed type aliases and AnyApiRef/AnyApiFactory, migrate deprecated core API refs to coreApis, replace createSpecializedApp with prepareSpecializedApp().finalize(), and replace removed frontend-test-utils mock API types.
Steps 6-7 of #193: keep timestamps in custom root logger JSON formats, pass a logger to createGitlabTokenValidator, and flag events.modules webhook config without a secret.
Steps 8-10 of #193: preserve pre-1.57 LDAP search attributes, remove auth.experimentalDynamicClientRegistration, and remove the ignored alert display anchorOrigin.
Steps 11-12 of #193: rename deprecated --mkdocs-* serve flags in package.json scripts, GitHub Actions and shell scripts, and drop React 16/17 alternatives from peerDependencies ranges.
Steps 13-16 of #193: wrap IconBundleBlueprint icons in elements, migrate RouterBlueprint to AppRootWrapperBlueprint, migrate custom nav items to navItems, and flag executable-scheme Backstage UI hrefs.
Sarabadu
force-pushed
the
feat/v1.57.0-migration-recipe
branch
from
November 22, 2026 22:20
7ae43e6 to
d828886
Compare
Author
|
@schultzp2020, first codemod for me here, and this one look a bit massive, did some local test and look ok but not covering every single codemod in real project. If you get some time I would appreciate to get some comments to see if i'm in the right direction here or if you spot anything evidently wrong |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #193
Adds
@backstage/v1-57-0-migration-recipe(codemods/v1.57.0/): one package and one workflow node running every Backstage 1.57.0 transform in the #193 step order (19 workflow entries for 16 steps). All transforms are deterministicjs-ast-grepscripts, plus the host-run TechDocs shell step. There is no AI step.Steps
scripts/migrate-frontend-plugin-api-imports.ts@backstage/frontend-plugin-api/alphaimports; movesExtensionFactoryMiddlewareandAnalyticsImplementation*scripts/replace-removed-frontend-plugin-api-types.tsPageTab,PluginOptions,ExtensionAttachTo,ProgressProps) and deprecatedAnyApiRef/AnyApiFactory; flagsIconComponentscripts/migrate-api-refs-to-core-apis.tscoreApis.*scripts/replace-create-specialized-app.tscreateSpecializedApp(opts)→prepareSpecializedApp(opts).finalize()scripts/replace-removed-mock-api-types.ts@backstage/frontend-test-utilsmock API types with types derived frommockApisscripts/add-timestamp-to-root-logger-json-format.tstimestampin customWinstonLoggerJSON formatsscripts/add-logger-to-gitlab-token-validator.ts+scripts/flag-webhook-secret-config-yaml.tscreateGitlabTokenValidator; flagsevents.modules.{github,gitlab,azureDevOps}config without a webhook secret (TODO only)scripts/migrate-ldap-search-attributes-yaml.tsattributes: ['*', '+']to LDAP user/group search options inapp-configthat don't setattributes(pre-1.57 behavior)scripts/remove-dynamic-client-registration-config.tsauth.experimentalDynamicClientRegistrationfromapp-configscripts/remove-alert-display-anchor-origin.tsanchorOriginfrom the alert display extension configscripts/rename-techdocs-cli-serve-flags-package-json.ts+-ci-yaml.ts+-shell.ts(helper-command.ts)--mkdocs-*serve flags inpackage.jsonscripts, GitHub Actions and shell scriptsscripts/update-react-peer-dependency-ranges.tspeerDependenciesranges that also allow React 18+, in every workspacepackage.jsonscripts/wrap-icon-bundle-icons-in-elements.tsIconBundleBlueprinticon components in elementsscripts/migrate-router-blueprint-to-app-root-wrapper.tsRouterBlueprint→AppRootWrapperBlueprint(unwrapsBrowserRouter); removesconvertLegacyAppOptionscomponents.Router; flags other routers andapp/rootrouter attachmentsscripts/migrate-nav-content-items-to-nav-items.tsitems→navItems.rest()scripts/flag-bui-standalone-routing.tsjavascript:/data:/vbscript:hrefs on Backstage UI elements (TODO only)Step 7c (webhook secrets in
app-config) and step 16 (executable-scheme BUI hrefs) only insertTODO(backstage-codemod)markers. The recipe takes no parameters.Clarifications and deviations from #193
These were decided during implementation and review. #193 itself is unchanged.
export * as ns from '…/alpha'is rewritten to the main entry;/alphastrings outside import/export declarations (jest.mock,import(), bareexport * from) are left unchanged (README).extends/implements ProgressPropsentries are dropped ({}can't appear there). Re-exports of only the deprecatedAnyApiRef/AnyApiFactoryget no TODO (still exported). Re-export TODOs (spec gives no text) name the replacement per symbol./alpha) import is rewritten in place to importcoreApis.satisfies/aswrappers are unwrapped before the object-literal check. Non-call references (typeof createSpecializedApp) are renamed without a TODO (TypeScript reports mismatches).import type { mockApis }in place.format.json()call, skip if any enclosingformat.combine(...)(up to theformat:value) has aformat.timestamp()argument before the argument containing the json call; otherwise insertformat.timestamp()as the first argument of the outermost enclosing combine, or wrap a bareformat.json()asformat.combine(format.timestamp(), format.json()). Soprod ? format.json() : format.combine(format.timestamp(), …)gets a timestamp on the JSON branch, andformat.combine(format.timestamp(), prod ? format.json() : …)is left alone. Quoted'format'keys are matched.X.configaccepted for side-effect-free identifier /this/ non-computed member chains (optional chaining preserved); importedloggerbindings are not used.app-configprecisely.BUIProvider-without-useNavigationTODO is dropped: inside a Backstage app navigation is inherited, so it flagged every app (all real hits were framework-internal).dangerouslyAllowUnauthenticatedEventsonly suppresses the TODO when it istrue(afalseopt-out still gets the TODO). Empty/null module values are flagged; flow-stylemodules: { … }maps are not handled (README).null/~webhookSecretcounts as not configured (module andintegrations.github[].apps[]); env substitutions and$env/$fileobjects count as configured.ldapPreserveAllAttributesparam): only the YAML half remains and it always addsattributes: ['*', '+']to block-style LDAP user/group search options inapp-configthat don't setattributes, with# Preserves pre-1.57 behavior (all attributes). Narrow this list to the attributes your mappings and transformers use to benefit from attribute selection.The recipe runs right after the upgrade, so it keeps the pre-1.57 behavior instead of silently dropping attributes that custom transformers read; an explicit list replaces the defaults (1.57 docs), so['*', '+']is the only safe automatic value. With that in place the TypeScript transformer TODO was noise, so it was removed.enabledtruthiness follows BackstageConfigReader(yes/on/1/'true';${ENV}treated as possibly enabled → TODO). Whenauthonly held the DCR key,authis removed and the TODO is left at its former position. Flow-styleauth: { … }is left unchanged (README).if: state.targetDirEncodedso targets without anypackage.jsonskip it instead of failing; the package.json step sets the state on everypackage.jsonit visits. The shell step writes files even under--dry-run(host-run, as in v1.54).^16.13.1 || ^17.0.2). React-17-only and comparator ranges (>=17) are left for manual review (README).myIcon) get the TODO instead of<myIcon />(JSX would treat it as an intrinsic element).createElement(...)/React.createElement(...)icon values count as migrated;makeWithOverridesis handled viaoriginalFactory({...})(it has noparams); namespace-qualified blueprint access is not handled (README).basename) is kept with a TODO; opaqueparams.component(imported, wrapped, unresolvable) is renamed with a "check this component no longer renders a router" TODO;unstable_HistoryRouter/HistoryRouter/Router/StaticRoutercount as other routers.makeWithOverridesis handled throughoriginalFactory({...})(steps 13–15).({ children }) => <>{children}</>(not barechildren, which doesn't satisfyJSX.Element | null) and keeps the delete TODO; an emptiedcomponents: {}inconvertLegacyAppOptionsis removed; exported/shorthandRouterBlueprintreferences get a rename-review TODO.formatimport from winston (nowinston.format.*); step 7a does not verify thatX.loggerexists (TypeScript reports it).@backstage/frontend-app-api/@backstage/plugin-app-reactthemselves (framework repo only), step 1 would emit self-package imports; built-in packages are out of scope (spec Notes).Notes for reviewers
add-logger-to-gitlab-token-validator-todo.ts. Steps 1, 2, 4 and 5 sharereplace-removed-frontend-plugin-api-types-common.ts. Steps 9 and 10 shareremove-dynamic-client-registration-config-helpers.ts. Steps 13 to 16 sharemigrate-router-blueprint-to-app-root-wrapper-helpers.ts. Step 11 usesrename-techdocs-cli-serve-flags-command.ts. These are listed in the README..shfiles even under--dry-run. It is skipped (if: state.targetDirEncoded) when the target has nopackage.json. Its rewrites don't appear in the metrics.@jssg/utils. The scripts uselistImports,importBindingOf,resolveDefinition,renameReferences,updateImport/addImport/removeImportand the style helpers where they fit. Some import-removal and offset code is bespoke becauseremoveImportalso matches CJSrequireand slices strings by UTF-8 byte offsets, which breaks after non-ASCII text. Tree-sitter columns are code points; the scripts convert them before slicing. An upstream issue is worth filing.migrate-blueprints-to-plugin-app-reactand v1.50dialog-api-show-to-openfirst if those releases were skipped. Adding@backstage/frontend-app-api/@backstage/plugin-app-reactdependencies is manual. UsecoreApis.appHistory(appHistoryApiRefis not exported by@backstage/frontend-plugin-api@1.0.0). The README's "Known limitations" and "Manual-only migration work" sections mirror [DRAFT]feat: Backstage 1.57.0 migration - add v1.57.0 migration recipe #193's out-of-scope table.QA
The full recipe ran on throwaway clones (the real repos were not modified) and on a synthetic adopter monorepo:
backstage/backstage@0b05c6c(pre-1.57)backstage/community-plugins@bbb02b2<SidebarItem {...item} />spread inworkspaces/{announcements,manage}/packages/app-next, which is rewritten exactly as in [DRAFT]feat: Backstage 1.57.0 migration - add v1.57.0 migration recipe #193. Step 12 updated 169 and 214 peer ranges, and step 9 removed DCR config inworkspaces/feedback.@backstage/frontend-app-api/@backstage/plugin-app-reactthemselves, step 1 produces 5@backstage/no-self-package-importslint errors. This is framework-internal code; built-ins are out of scope per [DRAFT]feat: Backstage 1.57.0 migration - add v1.57.0 migration recipe #193.Size
After a simplification pass (consolidated fixtures, removed hardening for exotic shapes, rules beyond #193 and TODOs that fired on every app): 24 scripts (~4.4K lines, incl. 5 shared helpers) and 147 fixture cases / 420 test files. The full-recipe output on the backstage and community-plugins clones is unchanged apart from the intentionally removed TODOs (LDAP transformer, webhook modules in code,
BUIProvider).Tests
yarn testincodemods/v1.57.0: 18 JSSG suites (147 fixture cases, metrics snapshots on changing cases),tscfor everytests/**/tsconfig.json, node suites for the TechDocs command helper, shell walker and workflow state, andtests/workflow.test.ts(step order, selectors, shellrun:line andif:guard, no params). The workflow also passescodemod workflow validate.yarn lint,yarn format:checkandyarn check:changed origin/mainpass.Changeset
.changeset/v1-57-0-migration-recipe.md:'@backstage/v1-57-0-migration-recipe': minor. The initial version is0.1.0, as in v1.56. No versions were hand-edited, and the root README is untouched.