Add automatic discovery of CLI modules from project dependencies

The CLI now scans the project root's dependencies and devDependencies
for packages with the cli-module role, loading them automatically.
Falls back to the built-in set with a deprecation warning when no
modules are found. Updated create-app templates and the monorepo root
to include all CLI modules as explicit devDependencies.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-14 12:34:24 +01:00
parent 64a96d9d9f
commit d806b0cc9f
8 changed files with 191 additions and 22 deletions
+31
View File
@@ -0,0 +1,31 @@
---
'@backstage/cli': minor
---
The CLI now automatically discovers CLI modules from the project root's `dependencies` and `devDependencies`. Any installed package with the `cli-module` Backstage role will be loaded automatically without needing to be hardcoded in the CLI itself.
If no CLI modules are found in the project dependencies, the CLI falls back to the built-in set of modules and prints a deprecation warning. This fallback will be removed in a future release. To prepare for this, add the following CLI modules as `devDependencies` in your root `package.json`:
```json
{
"devDependencies": {
"@backstage/cli-module-auth": "backstage:^",
"@backstage/cli-module-build": "backstage:^",
"@backstage/cli-module-config": "backstage:^",
"@backstage/cli-module-create-github-app": "backstage:^",
"@backstage/cli-module-info": "backstage:^",
"@backstage/cli-module-lint": "backstage:^",
"@backstage/cli-module-maintenance": "backstage:^",
"@backstage/cli-module-migrate": "backstage:^",
"@backstage/cli-module-new": "backstage:^",
"@backstage/cli-module-test-jest": "backstage:^",
"@backstage/cli-module-translations": "backstage:^"
}
}
```
If you are not using the Backstage Yarn plugin, run the following instead:
```sh
yarn workspace root add --dev @backstage/cli-module-auth @backstage/cli-module-build @backstage/cli-module-config @backstage/cli-module-create-github-app @backstage/cli-module-info @backstage/cli-module-lint @backstage/cli-module-maintenance @backstage/cli-module-migrate @backstage/cli-module-new @backstage/cli-module-test-jest @backstage/cli-module-translations
```
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/create-app': patch
---
The create-app templates now include all standard `@backstage/cli-module-*` packages as `devDependencies`, enabling the CLI's automatic module discovery for newly created projects.