Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build-cli): Read layer config file without using require() #12689

Merged
merged 4 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build-tools/packages/build-cli/docs/check.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Checks that the dependencies between Fluid Framework packages are properly layer

```
USAGE
$ flub check layers [--md <value>] [--dot <value>] [--info <value>] [--logtime] [-v]
$ flub check layers --info <value> [--md <value>] [--dot <value>] [--logtime] [-v]

FLAGS
-v, --verbose Verbose logging.
--dot=<value> Generate *.dot for GraphViz
--info=<value> Path to the layer graph json file
--info=<value> (required) Path to the layer graph json file
--logtime Display the current time on every status message for logging
--md=<value> [default: .] Generate PACKAGES.md file at this path relative to repo root
--md=<value> Generate PACKAGES.md file at this path relative to repo root

DESCRIPTION
Checks that the dependencies between Fluid Framework packages are properly layered.
Expand Down
4 changes: 2 additions & 2 deletions build-tools/packages/build-cli/src/commands/check/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export class CheckLayers extends BaseCommand<typeof CheckLayers.flags> {
md: Flags.string({
description: `Generate ${packagesMdFileName} file at this path relative to repo root`,
required: false,
default: ".", // default is repo root (relative path to repo root)
}),
dot: Flags.file({
description: "Generate *.dot for GraphViz",
required: false,
}),
info: Flags.file({
description: "Path to the layer graph json file",
required: false,
required: true,
exists: true,
}),
logtime: Flags.boolean({
description: "Display the current time on every status message for logging",
Expand Down
7 changes: 4 additions & 3 deletions build-tools/packages/build-tools/src/layerCheck/layerGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as path from "path";

import { defaultLogger } from "../common/logging";
import { Package, Packages } from "../common/npmPackage";
import { readJsonSync } from "../common/utils";

const { verbose } = defaultLogger;

Expand Down Expand Up @@ -566,8 +567,8 @@ ${lines.join(newline)}
}

public static load(root: string, packages: Packages, info?: string): LayerGraph {
const layerInfoFile = require(info ??
path.join(__dirname, "..", "..", "data", "layerInfo.json"));
return new LayerGraph(root, layerInfoFile, packages);
const layerInfoFile = info ?? path.join(__dirname, "..", "..", "data", "layerInfo.json");
const layerData: ILayerInfoFile = readJsonSync(layerInfoFile);
return new LayerGraph(root, layerData, packages);
}
}