A Backstage frontend plugin to list and delete the locations registered in the software catalog.
You register a component and Backstage answers that the location already exists. You search the catalog UI and find nothing.
The location is still registered in the catalog API even though no entity from it shows up in the UI. Until now the fix was to do it by hand:
curl -s https://backstage.example.com/api/catalog/locations | jq
# ...find the id in a wall of JSON...
curl -X DELETE https://backstage.example.com/api/catalog/locations/507d46dd-ac5e-4152-8a4c-37eb8dfe3fcfThis plugin gives you a page with every registered location, search, and a delete button with confirmation.
yarn --cwd packages/app add @ruivalim/catalog-cleanupIf your app uses createApp from @backstage/frontend-defaults (what @backstage/create-app generates today) and has app.packages: all in app-config.yaml, installing the package is enough. The page is discovered automatically at /catalog-cleanup and gets an entry in the sidebar.
Without package discovery, add the plugin to your features:
import catalogCleanupPlugin from '@ruivalim/catalog-cleanup/alpha';
export default createApp({
features: [catalogCleanupPlugin /* , ...other features */],
});The path can be changed in app-config.yaml:
app:
extensions:
- page:catalog-cleanup:
config:
path: /admin/catalog-cleanupAdd the route in packages/app/src/App.tsx:
import { CatalogCleanupPage } from '@ruivalim/catalog-cleanup';
// inside <FlatRoutes>
<Route path="/catalog-cleanup" element={<CatalogCleanupPage />} />And optionally a sidebar item in packages/app/src/components/Root/Root.tsx:
import DeleteSweepIcon from '@material-ui/icons/DeleteSweep';
<SidebarItem icon={DeleteSweepIcon} to="catalog-cleanup" text="Catalog Cleanup" />The page talks to the catalog through the standard CatalogApi, so the catalog backend enforces its own permissions:
catalog.location.readto list locations;catalog.location.deleteto delete them. Without it the delete buttons are disabled.
Deleting a location orphans the entities that came only from it. With the default catalog.orphanStrategy: delete the catalog then removes them; with keep they stay, marked as orphans.
The
catalogCleanupViewPermissionandcatalogCleanupDeletePermissionexports are deprecated. They were never checked by anything. Use the catalog permissions above in your policy instead.
- Tested on Backstage 1.55
- React 17 or 18
yarn install
yarn tsc
yarn lint
yarn test
yarn buildApache-2.0
Releases are automated. Commits follow Conventional Commits: fix: and feat: go into the next release, feat!: or a BREAKING CHANGE: footer marks a breaking one.
release-please keeps a release PR open with the next version and changelog. Merging it tags the release and publishes it to npm with provenance, through npm trusted publishing.
Dependencies are kept up to date by Renovate: every Monday, one PR with all non-major updates and a separate one for Backstage packages, both reviewed by hand.
