From 6210b7fc01e41eff203a716d111a05709f6f296a Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Wed, 21 Jan 2026 17:35:00 -0800 Subject: [PATCH] Deprecate `getWorkspaces` and rename to `getWorkspaceInfos` --- .gitignore | 3 ++- ...hange-1c33b953-d911-4dbe-ac9d-9af7da0d5df1.json | 11 +++++++++++ .../workspace-tools/etc/workspace-tools.api.md | 14 ++++++++++---- packages/workspace-tools/src/index.ts | 7 ++++++- .../src/workspaces/getWorkspaces.ts | 10 ++++++++-- 5 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 change/change-1c33b953-d911-4dbe-ac9d-9af7da0d5df1.json diff --git a/.gitignore b/.gitignore index d3d6eb61..d77050a3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ temp/ **/__fixtures__/*/.yarn/cache/ install-state.gz /package-lock.json -!**/__fixtures__/**/package-lock.json \ No newline at end of file +!**/__fixtures__/**/package-lock.json +.claude/settings.local.json diff --git a/change/change-1c33b953-d911-4dbe-ac9d-9af7da0d5df1.json b/change/change-1c33b953-d911-4dbe-ac9d-9af7da0d5df1.json new file mode 100644 index 00000000..66e0d5f7 --- /dev/null +++ b/change/change-1c33b953-d911-4dbe-ac9d-9af7da0d5df1.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "type": "patch", + "comment": "Deprecate `getWorkspaces` and rename to `getWorkspaceInfos` (same with async version)", + "packageName": "workspace-tools", + "email": "elcraig@microsoft.com", + "dependentChangeType": "patch" + } + ] +} \ No newline at end of file diff --git a/packages/workspace-tools/etc/workspace-tools.api.md b/packages/workspace-tools/etc/workspace-tools.api.md index 928dc72f..7b9df871 100644 --- a/packages/workspace-tools/etc/workspace-tools.api.md +++ b/packages/workspace-tools/etc/workspace-tools.api.md @@ -340,6 +340,12 @@ export function getUserEmail(options: GitCommonOptions): string | null; // @public @deprecated (undocumented) export function getUserEmail(cwd: string): string | null; +// @public +export function getWorkspaceInfos(cwd: string): WorkspaceInfos; + +// @public +export function getWorkspaceInfosAsync(cwd: string): Promise; + // Warning: (ae-forgotten-export) The symbol "WorkspaceManager" needs to be exported by the entry point index.d.ts // // @public @@ -354,11 +360,11 @@ export function getWorkspacePackagePathsAsync(cwd: string): Promise; // @public @deprecated export function getWorkspaceRoot(cwd: string, preferredManager?: WorkspaceManager): string | undefined; -// @public -export function getWorkspaces(cwd: string): WorkspaceInfos; +// @public @deprecated (undocumented) +export const getWorkspaces: typeof getWorkspaceInfos; -// @public -export function getWorkspacesAsync(cwd: string): Promise; +// @public @deprecated (undocumented) +export const getWorkspacesAsync: typeof getWorkspaceInfosAsync; // @public @deprecated (undocumented) export function getYarnWorkspaceRoot(cwd: string): string; diff --git a/packages/workspace-tools/src/index.ts b/packages/workspace-tools/src/index.ts index 6ccdf5d5..b4891662 100644 --- a/packages/workspace-tools/src/index.ts +++ b/packages/workspace-tools/src/index.ts @@ -11,7 +11,12 @@ export type { PackageDependency, PackageGraph } from "./types/PackageGraph"; export type { PackageInfo, PackageInfos } from "./types/PackageInfo"; export type { WorkspacePackageInfo, WorkspaceInfos, WorkspaceInfo } from "./types/WorkspaceInfo"; export { findWorkspacePath } from "./workspaces/findWorkspacePath"; -export { getWorkspaces, getWorkspacesAsync } from "./workspaces/getWorkspaces"; +export { + getWorkspaces, + getWorkspacesAsync, + getWorkspaceInfos, + getWorkspaceInfosAsync, +} from "./workspaces/getWorkspaces"; export { getWorkspacePackagePaths, getWorkspacePackagePathsAsync } from "./workspaces/getWorkspacePackagePaths"; export { getWorkspaceManagerRoot, getWorkspaceRoot } from "./workspaces/getWorkspaceRoot"; export { getPackageInfo, getPackageInfoAsync } from "./getPackageInfo"; diff --git a/packages/workspace-tools/src/workspaces/getWorkspaces.ts b/packages/workspace-tools/src/workspaces/getWorkspaces.ts index 6a217f67..b7d8e630 100644 --- a/packages/workspace-tools/src/workspaces/getWorkspaces.ts +++ b/packages/workspace-tools/src/workspaces/getWorkspaces.ts @@ -6,11 +6,14 @@ import type { WorkspaceInfos } from "../types/WorkspaceInfo"; * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the * workspace/monorepo manager's config file. */ -export function getWorkspaces(cwd: string): WorkspaceInfos { +export function getWorkspaceInfos(cwd: string): WorkspaceInfos { const utils = getWorkspaceUtilities(cwd); return utils?.getWorkspaces(cwd) || []; } +/** @deprecated Use `getWorkspaceInfos` */ +export const getWorkspaces = getWorkspaceInfos; + /** * Get an array with names, paths, and package.json contents for each package ("workspace" in * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the @@ -19,7 +22,7 @@ export function getWorkspaces(cwd: string): WorkspaceInfos { * NOTE: As of writing, this will start promises to read all package.json files in parallel, * without direct concurrency control. */ -export async function getWorkspacesAsync(cwd: string): Promise { +export async function getWorkspaceInfosAsync(cwd: string): Promise { const utils = getWorkspaceUtilities(cwd); if (!utils) { @@ -33,3 +36,6 @@ export async function getWorkspacesAsync(cwd: string): Promise { return utils.getWorkspacesAsync(cwd); } + +/** @deprecated Use `getWorkspaceInfosAsync` */ +export const getWorkspacesAsync = getWorkspaceInfosAsync;