Skip to content
Open
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
33 changes: 17 additions & 16 deletions build-tools/packages/build-infrastructure/src/workspaceCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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";

Expand Down Expand Up @@ -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);
Expand Down