From c169a6f9b0d8ee8e1d6f358fdd410e53b04f33a3 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 29 Jun 2026 12:02:36 -0700 Subject: [PATCH] refactor(build-infra): use gitignore utils --- .../src/workspaceCompat.ts | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/build-tools/packages/build-infrastructure/src/workspaceCompat.ts b/build-tools/packages/build-infrastructure/src/workspaceCompat.ts index 6dfb78f85b6..352f137cdde 100644 --- a/build-tools/packages/build-infrastructure/src/workspaceCompat.ts +++ b/build-tools/packages/build-infrastructure/src/workspaceCompat.ts @@ -6,8 +6,7 @@ import { existsSync } from "node:fs"; import path from "node:path"; -import globby from "globby"; - +import { globSync } from "tinyglobby"; import type { // eslint-disable-next-line import-x/no-deprecated -- back-compat code IFluidBuildDir, @@ -16,6 +15,7 @@ import type { ReleaseGroupDefinition, WorkspaceDefinition, } from "./config.js"; +import { filterByGitignoreSync } from "./gitignore.js"; import type { IBuildProject, IWorkspace, WorkspaceName } from "./types.js"; import { Workspace } from "./workspace.js"; @@ -99,20 +99,21 @@ function loadWorkspacesFromLegacyConfigEntry( ]; } - const packageJsonPaths = globby - .sync(["**/package.json"], { - cwd: path.dirname(packagePath), - gitignore: true, - onlyFiles: true, - absolute: true, - // BACK-COMPAT HACK - only search two levels below entries for package.jsons. This avoids finding some test - // files and treating them as packages. This is only needed when loading old configs. - deep: 2, - }) - .map( - // Make the paths relative to the repo root - (filePath) => path.relative(buildProject.root, filePath), - ); + const cwd = path.dirname(packagePath); + const allFiles = globSync(["**/package.json"], { + cwd, + onlyFiles: true, + absolute: true, + // BACK-COMPAT HACK - only search two levels below entries for package.jsons. This avoids finding some test + // files and treating them as packages. This is only needed when loading old configs. + deep: 2, + }); + + // Apply gitignore filtering + const packageJsonPaths = filterByGitignoreSync(allFiles, cwd).map( + // Make the paths relative to the buildProject root + (filePath) => path.relative(buildProject.root, filePath), + ); const workspaces = packageJsonPaths.flatMap((pkgPath) => { const dir = path.dirname(pkgPath); return loadWorkspacesFromLegacyConfigEntry(dir, buildProject);