From bc6c024a4ce0bc4cced64f9a7f83403c67ff7523 Mon Sep 17 00:00:00 2001 From: Gabriel Dugny Date: Sun, 22 Feb 2026 17:26:35 +0100 Subject: [PATCH] chore: remove PackageManager getMonorepoPackages Unused, prefer @manypkg/get-packages's getPackages instead. Signed-off-by: Gabriel Dugny --- .../cli-node/src/pacman/PackageManager.ts | 6 -- .../cli-node/src/pacman/yarn/Yarn.test.ts | 68 ------------------- packages/cli-node/src/pacman/yarn/Yarn.ts | 15 ---- 3 files changed, 89 deletions(-) delete mode 100644 packages/cli-node/src/pacman/yarn/Yarn.test.ts diff --git a/packages/cli-node/src/pacman/PackageManager.ts b/packages/cli-node/src/pacman/PackageManager.ts index 44c0849705..0029652544 100644 --- a/packages/cli-node/src/pacman/PackageManager.ts +++ b/packages/cli-node/src/pacman/PackageManager.ts @@ -49,12 +49,6 @@ export interface PackageManager { /** The file name of the lockfile used by the package manager. */ lockfileName(): string; - /** - * If this repo is a monorepo, returns the patterns specified by the package - * manager's monorepo configuration. Does not attempt to resolve any globs. - */ - getMonorepoPackages(): Promise; - /** Uses the package manager to run a command in the repo. */ run(args: string[], options?: RunOptions): Promise; diff --git a/packages/cli-node/src/pacman/yarn/Yarn.test.ts b/packages/cli-node/src/pacman/yarn/Yarn.test.ts deleted file mode 100644 index f13b5a0296..0000000000 --- a/packages/cli-node/src/pacman/yarn/Yarn.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createMockDirectory } from '@backstage/backend-test-utils'; -import { Yarn } from './Yarn'; - -const mockDir = createMockDirectory(); - -jest.mock('../../paths', () => ({ - ...jest.requireActual('../../paths'), - paths: { resolveTargetRoot: (...args: string[]) => mockDir.resolve(...args) }, -})); - -const yarnClassic = new Yarn({ version: '1.0.0', codename: 'classic' }); -const yarnBerry = new Yarn({ version: '3.0.0', codename: 'berry' }); -const allYarnVersions = [yarnClassic, yarnBerry]; - -describe('Yarn', () => { - describe.each(allYarnVersions)('%s.getMonorepoPackages', yarn => { - it('should detect a monorepo with workspaces.packages field', async () => { - mockDir.setContent({ - 'package.json': JSON.stringify({ - name: 'foo', - workspaces: { - packages: ['packages/*'], - }, - }), - }); - await expect(yarn.getMonorepoPackages()).resolves.toEqual(['packages/*']); - }); - it('should detect a monorepo', async () => { - mockDir.setContent({ - 'package.json': JSON.stringify({ - name: 'foo', - workspaces: ['packages/*'], - }), - }); - await expect(yarn.getMonorepoPackages()).resolves.toEqual(['packages/*']); - }); - - it('should detect a non-monorepo', async () => { - mockDir.setContent({ - 'package.json': JSON.stringify({ - name: 'foo', - }), - }); - await expect(yarn.getMonorepoPackages()).resolves.toEqual([]); - }); - - it('should return false if package.json is missing', async () => { - mockDir.setContent({}); - await expect(yarn.getMonorepoPackages()).resolves.toEqual([]); - }); - }); -}); diff --git a/packages/cli-node/src/pacman/yarn/Yarn.ts b/packages/cli-node/src/pacman/yarn/Yarn.ts index 9c242c90da..7aee7bdebf 100644 --- a/packages/cli-node/src/pacman/yarn/Yarn.ts +++ b/packages/cli-node/src/pacman/yarn/Yarn.ts @@ -22,8 +22,6 @@ import { import { PackageInfo, PackageManager } from '../PackageManager'; import { Lockfile } from '../Lockfile'; import { YarnVersion } from './types'; -import fs from 'fs-extra'; -import { paths } from '../../paths'; import { run, runOutput, RunOptions } from '@backstage/cli-common'; export class Yarn implements PackageManager { @@ -46,19 +44,6 @@ export class Yarn implements PackageManager { return 'yarn.lock'; } - async getMonorepoPackages() { - const rootPackageJsonPath = paths.resolveTargetRoot('package.json'); - try { - const pkg = await fs.readJson(rootPackageJsonPath); - const workspaces = pkg?.workspaces; - return Array.isArray(workspaces) - ? workspaces - : workspaces?.packages ?? []; - } catch (error) { - return []; - } - } - async pack(out: string, packageDir: string) { const outArg = this.yarnVersion.codename === 'classic' ? '--filename' : '--out';