chore: remove PackageManager getMonorepoPackages

Unused, prefer @manypkg/get-packages's getPackages instead.

Signed-off-by: Gabriel Dugny <gabriel.dugny@believe.com>
This commit is contained in:
Gabriel Dugny
2026-02-22 17:26:35 +01:00
parent 0e5fd0fd27
commit bc6c024a4c
3 changed files with 0 additions and 89 deletions
@@ -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<string[]>;
/** Uses the package manager to run a command in the repo. */
run(args: string[], options?: RunOptions): Promise<void>;
@@ -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([]);
});
});
});
-15
View File
@@ -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';