From 02d37ce59b65830c62d957aca3c4a262587c3a7f Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Wed, 26 Oct 2022 14:53:30 -0700 Subject: [PATCH 1/4] fix(build-cli): Read layer config file without using require() --- .../packages/build-tools/src/layerCheck/layerGraph.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts b/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts index 880777ebc8e3..d99248ab5209 100644 --- a/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts +++ b/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts @@ -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; @@ -566,8 +567,9 @@ ${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); } } From 431dbaacfd25b303ab83ce6a317e9ca601a4f2de Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Wed, 26 Oct 2022 15:01:41 -0700 Subject: [PATCH 2/4] remove default md argument --- build-tools/packages/build-cli/src/commands/check/layers.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/build-tools/packages/build-cli/src/commands/check/layers.ts b/build-tools/packages/build-cli/src/commands/check/layers.ts index 16716addb7a3..a487813247f1 100644 --- a/build-tools/packages/build-cli/src/commands/check/layers.ts +++ b/build-tools/packages/build-cli/src/commands/check/layers.ts @@ -19,7 +19,6 @@ export class CheckLayers extends BaseCommand { 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", From 7041cd48e4b0aca2a7dea8ab0f008123caef0bc8 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Wed, 26 Oct 2022 15:05:47 -0700 Subject: [PATCH 3/4] fix --- build-tools/packages/build-cli/src/commands/check/layers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-tools/packages/build-cli/src/commands/check/layers.ts b/build-tools/packages/build-cli/src/commands/check/layers.ts index a487813247f1..3ebe29c1b3f4 100644 --- a/build-tools/packages/build-cli/src/commands/check/layers.ts +++ b/build-tools/packages/build-cli/src/commands/check/layers.ts @@ -26,7 +26,8 @@ export class CheckLayers extends BaseCommand { }), 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", From 8d7257478c64462993090df9daf45d1d05fd617a Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Wed, 26 Oct 2022 15:12:02 -0700 Subject: [PATCH 4/4] more --- build-tools/packages/build-cli/docs/check.md | 6 +++--- .../packages/build-tools/src/layerCheck/layerGraph.ts | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build-tools/packages/build-cli/docs/check.md b/build-tools/packages/build-cli/docs/check.md index 78bc4493d209..18e5b12d4d8b 100644 --- a/build-tools/packages/build-cli/docs/check.md +++ b/build-tools/packages/build-cli/docs/check.md @@ -12,14 +12,14 @@ Checks that the dependencies between Fluid Framework packages are properly layer ``` USAGE - $ flub check layers [--md ] [--dot ] [--info ] [--logtime] [-v] + $ flub check layers --info [--md ] [--dot ] [--logtime] [-v] FLAGS -v, --verbose Verbose logging. --dot= Generate *.dot for GraphViz - --info= Path to the layer graph json file + --info= (required) Path to the layer graph json file --logtime Display the current time on every status message for logging - --md= [default: .] Generate PACKAGES.md file at this path relative to repo root + --md= Generate PACKAGES.md file at this path relative to repo root DESCRIPTION Checks that the dependencies between Fluid Framework packages are properly layered. diff --git a/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts b/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts index d99248ab5209..47f45eb55589 100644 --- a/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts +++ b/build-tools/packages/build-tools/src/layerCheck/layerGraph.ts @@ -567,9 +567,8 @@ ${lines.join(newline)} } public static load(root: string, packages: Packages, info?: string): LayerGraph { - const layerInfoFile = info ?? - path.join(__dirname, "..", "..", "data", "layerInfo.json"); - const layerData: ILayerInfoFile = readJsonSync(layerInfoFile); + const layerInfoFile = info ?? path.join(__dirname, "..", "..", "data", "layerInfo.json"); + const layerData: ILayerInfoFile = readJsonSync(layerInfoFile); return new LayerGraph(root, layerData, packages); } }