-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build-infrastructure): Add default implementations for core inte…
…rfaces (#22865) This change adds default implementations of the `IFluidRepo`, `IWorkspace`, `IReleaseGroup`, and `IPackage` interfaces. These implementations are sufficient for most uses in build-tools and build-cli. They may be further extended for specific scenarios in future changes. I disabled the TypeDoc generation in this PR to make the code changes easier to review. Once this series of PRs lands, we can enable TypeDoc or api-markdown-documenter and regen the docs. --------- Co-authored-by: Alex Villarreal <[email protected]>
- Loading branch information
1 parent
59441f3
commit 199b9d0
Showing
24 changed files
with
1,891 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
91 changes: 91 additions & 0 deletions
91
build-tools/packages/build-infrastructure/src/commands/list.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/*! | ||
* Copyright (c) Microsoft Corporation and contributors. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { Command, Flags } from "@oclif/core"; | ||
import colors from "picocolors"; | ||
|
||
import { getAllDependenciesInRepo, loadFluidRepo } from "../fluidRepo.js"; | ||
import type { IFluidRepo } from "../types.js"; | ||
|
||
/** | ||
* This command is intended for testing and debugging use only. | ||
*/ | ||
export class ListCommand extends Command { | ||
static override description = | ||
"List objects in the Fluid repo, like release groups, workspaces, and packages. USED FOR TESTING ONLY."; | ||
|
||
static override flags = { | ||
path: Flags.directory({ | ||
description: "Path to start searching for the Fluid repo.", | ||
default: ".", | ||
}), | ||
full: Flags.boolean({ | ||
description: "Output the full report.", | ||
}), | ||
} as const; | ||
|
||
async run(): Promise<void> { | ||
const { flags } = await this.parse(ListCommand); | ||
const { path: searchPath, full } = flags; | ||
|
||
// load the Fluid repo | ||
const repo = loadFluidRepo(searchPath); | ||
const _ = full ? await this.logFullReport(repo) : await this.logCompactReport(repo); | ||
} | ||
|
||
private async logFullReport(repo: IFluidRepo): Promise<void> { | ||
this.logIndent(colors.underline("Repository layout")); | ||
for (const workspace of repo.workspaces.values()) { | ||
this.log(); | ||
this.logIndent(colors.blue(workspace.toString()), 1); | ||
for (const releaseGroup of workspace.releaseGroups.values()) { | ||
this.log(); | ||
this.logIndent(colors.green(releaseGroup.toString()), 2); | ||
this.logIndent(colors.bold("Packages"), 3); | ||
for (const pkg of releaseGroup.packages) { | ||
const pkgMessage = colors.white( | ||
`${pkg.name}${pkg.isReleaseGroupRoot ? colors.bold(" (root)") : ""}`, | ||
); | ||
this.logIndent(pkgMessage, 4); | ||
} | ||
|
||
const { releaseGroups, workspaces } = getAllDependenciesInRepo( | ||
repo, | ||
releaseGroup.packages, | ||
); | ||
if (releaseGroups.length > 0 || workspaces.length > 0) { | ||
this.log(); | ||
this.logIndent(colors.bold("Depends on:"), 3); | ||
for (const depReleaseGroup of releaseGroups) { | ||
this.logIndent(depReleaseGroup.toString(), 4); | ||
} | ||
for (const depWorkspace of workspaces) { | ||
this.logIndent(depWorkspace.toString(), 4); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private async logCompactReport(repo: IFluidRepo): Promise<void> { | ||
this.logIndent(colors.underline("Repository layout")); | ||
for (const workspace of repo.workspaces.values()) { | ||
this.log(); | ||
this.logIndent(colors.blue(workspace.toString()), 1); | ||
this.logIndent(colors.bold("Packages"), 2); | ||
for (const pkg of workspace.packages) { | ||
const pkgMessage = colors.white( | ||
`${pkg.isReleaseGroupRoot ? colors.bold("(root) ") : ""}${pkg.name} ${colors.black(colors.bgGreen(pkg.releaseGroup))}`, | ||
); | ||
this.logIndent(pkgMessage, 3); | ||
} | ||
} | ||
} | ||
|
||
private logIndent(message: string, indent: number = 0): void { | ||
const spaces = " ".repeat(2 * indent); | ||
this.log(`${spaces}${message}`); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: repo-layout -- the build-infrastructure CLI | ||
--- | ||
|
||
# repo-layout -- the build-infrastructure CLI | ||
|
||
# Table of contents | ||
|
||
<!-- toc --> | ||
* [repo-layout -- the build-infrastructure CLI](#repo-layout----the-build-infrastructure-cli) | ||
* [Table of contents](#table-of-contents) | ||
* [Commands](#commands) | ||
<!-- tocstop --> | ||
|
||
# Commands | ||
|
||
<!-- commands --> | ||
* [`repo-layout list`](#repo-layout-list) | ||
|
||
## `repo-layout list` | ||
|
||
List objects in the Fluid repo, like release groups, workspaces, and packages. USED FOR TESTING ONLY. | ||
|
||
``` | ||
USAGE | ||
$ repo-layout list [--path <value>] [--full] | ||
FLAGS | ||
--full Output the full report. | ||
--path=<value> [default: .] Path to start searching for the Fluid repo. | ||
DESCRIPTION | ||
List objects in the Fluid repo, like release groups, workspaces, and packages. USED FOR TESTING ONLY. | ||
``` | ||
|
||
_See code: [src/commands/list.ts](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/build-infrastructure/src/commands/list.ts)_ | ||
<!-- commandsstop --> |
This file contains 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
Oops, something went wrong.