Keep versioning utilities internal to CLI migrate module

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-02-25 14:09:25 +01:00
parent 61cb976207
commit 5033936401
11 changed files with 9 additions and 84 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/cli-node': patch
---
Added `toString()` method to `Lockfile` for serializing lockfiles back to string format. Also added new exports: `detectYarnVersion`, `fetchPackageInfo`, `mapDependencies`, and `YarnInfoInspectData`.
Added `toString()` method to `Lockfile` for serializing lockfiles back to string format.
-1
View File
@@ -38,7 +38,6 @@
"@yarnpkg/lockfile": "^1.1.0",
"@yarnpkg/parsers": "^3.0.0",
"fs-extra": "^11.2.0",
"minimatch": "^10.2.1",
"semver": "^7.5.3",
"zod": "^3.25.76"
},
-29
View File
@@ -93,12 +93,6 @@ export type ConcurrentTasksOptions<TItem> = {
worker: (item: TItem) => Promise<void>;
};
// @public
export function detectYarnVersion(dir?: string): Promise<'classic' | 'berry'>;
// @public
export function fetchPackageInfo(name: string): Promise<YarnInfoInspectData>;
// @public
export class GitUtils {
static listChangedFiles(ref: string): Promise<string[]>;
@@ -140,12 +134,6 @@ export type LockfileQueryEntry = {
dataKey: string;
};
// @public
export function mapDependencies(
targetDir: string,
pattern: string,
): Promise<Map<string, PkgVersionInfo[]>>;
// @public
export const packageFeatureType: readonly [
'@backstage/BackendFeature',
@@ -221,13 +209,6 @@ export class PackageRoles {
static getRoleInfo(role: string): PackageRoleInfo;
}
// @public
export type PkgVersionInfo = {
range: string;
name: string;
location: string;
};
// @public
export function runConcurrentTasks<TItem>(
options: ConcurrentTasksOptions<TItem>,
@@ -250,14 +231,4 @@ export type WorkerQueueThreadsOptions<TItem, TResult, TContext> = {
| Promise<(item: TItem) => Promise<TResult>>;
context?: TContext;
};
// @public
export type YarnInfoInspectData = {
name: string;
'dist-tags': Record<string, string>;
versions: string[];
time: {
[version: string]: string;
};
};
```
-1
View File
@@ -24,4 +24,3 @@ export * from './git';
export * from './monorepo';
export * from './concurrency';
export * from './roles';
export * from './versioning';
-19
View File
@@ -1,19 +0,0 @@
/*
* Copyright 2020 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.
*/
export { detectYarnVersion } from './yarn';
export { fetchPackageInfo, mapDependencies } from './packages';
export type { PkgVersionInfo, YarnInfoInspectData } from './packages';
@@ -19,7 +19,7 @@ import * as runObj from '@backstage/cli-common';
import { overrideTargetPaths } from '@backstage/cli-common/testUtils';
import bump, { bumpBackstageJsonVersion, createVersionFinder } from './bump';
import { registerMswTestHooks, withLogCollector } from '@backstage/test-utils';
import { YarnInfoInspectData } from '@backstage/cli-node';
import { YarnInfoInspectData } from '../../lib/versioning/packages';
import { setupServer } from 'msw/node';
import { rest } from 'msw';
import { NotFoundError } from '@backstage/errors';
@@ -69,8 +69,8 @@ jest.mock('@backstage/cli-common', () => {
});
const mockFetchPackageInfo = jest.fn();
jest.mock('@backstage/cli-node', () => {
const actual = jest.requireActual('@backstage/cli-node');
jest.mock('../../lib/versioning/packages', () => {
const actual = jest.requireActual('../../lib/versioning/packages');
return {
...actual,
fetchPackageInfo: (name: string) => mockFetchPackageInfo(name),
@@ -31,13 +31,12 @@ import { isError, NotFoundError } from '@backstage/errors';
import { resolve as resolvePath } from 'node:path';
import { getHasYarnPlugin } from '../../../../lib/yarnPlugin';
import { Lockfile, runConcurrentTasks } from '@backstage/cli-node';
import {
fetchPackageInfo,
Lockfile,
mapDependencies,
runConcurrentTasks,
YarnInfoInspectData,
} from '@backstage/cli-node';
} from '../../lib/versioning/packages';
import {
getManifestByReleaseLine,
getManifestByVersion,
@@ -27,11 +27,7 @@ const DEP_TYPES = [
'optionalDependencies',
] as const;
/**
* Package data as returned by `yarn info`.
*
* @public
*/
// Package data as returned by `yarn info`
export type YarnInfoInspectData = {
name: string;
'dist-tags': Record<string, string>;
@@ -45,22 +41,12 @@ type YarnInfo = {
data: YarnInfoInspectData | { type: string; data: unknown };
};
/**
* Version information for a package dependency.
*
* @public
*/
export type PkgVersionInfo = {
type PkgVersionInfo = {
range: string;
name: string;
location: string;
};
/**
* Fetches package information from the registry using `yarn info` or `yarn npm info`.
*
* @public
*/
export async function fetchPackageInfo(
name: string,
): Promise<YarnInfoInspectData> {
@@ -106,11 +92,7 @@ export async function fetchPackageInfo(
}
}
/**
* Map all dependencies in the repo as dependency to dependents.
*
* @public
*/
/** Map all dependencies in the repo as dependency => dependents */
export async function mapDependencies(
targetDir: string,
pattern: string,
@@ -19,11 +19,6 @@ import { runOutput } from '@backstage/cli-common';
const versions = new Map<string, Promise<'classic' | 'berry'>>();
/**
* Detects the version of Yarn in use.
*
* @public
*/
export function detectYarnVersion(dir?: string): Promise<'classic' | 'berry'> {
const cwd = dir ?? process.cwd();
if (versions.has(cwd)) {
-1
View File
@@ -3276,7 +3276,6 @@ __metadata:
"@yarnpkg/lockfile": "npm:^1.1.0"
"@yarnpkg/parsers": "npm:^3.0.0"
fs-extra: "npm:^11.2.0"
minimatch: "npm:^10.2.1"
semver: "npm:^7.5.3"
zod: "npm:^3.25.76"
languageName: unknown