cli: add --since flag for repo build

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-03-05 11:44:20 +01:00
parent c3bc369a54
commit 2c528506aa
3 changed files with 21 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Added `--since <ref>` flag for `repo build` command.`
+4
View File
@@ -41,6 +41,10 @@ export function registerRepoCommand(program: CommanderStatic) {
'--all',
'Build all packages, including bundled app and backend packages.',
)
.option(
'--since <ref>',
'Only build packages and their dev dependents that changed since the specified ref',
)
.action(lazy(() => import('./repo/build').then(m => m.command)));
command
+12 -1
View File
@@ -78,7 +78,18 @@ function createScriptOptionsParser(anyCmd: Command, commandPath: string[]) {
}
export async function command(cmd: Command): Promise<void> {
const packages = await PackageGraph.listTargetPackages();
let packages = await PackageGraph.listTargetPackages();
if (cmd.since) {
const graph = PackageGraph.fromPackages(packages);
const changedPackages = await graph.listChangedPackages({ ref: cmd.since });
const withDevDependents = graph.collectPackageNames(
changedPackages.map(pkg => pkg.name),
pkg => pkg.localDevDependents.keys(),
);
packages = Array.from(withDevDependents).map(name => graph.get(name)!);
}
const apps = new Array<ExtendedPackage>();
const backends = new Array<ExtendedPackage>();