Address review feedback

- Remove cli changeset, piggy-back on existing ones
- Rename getHasYarnPlugin -> hasYarnPlugin(workspaceDir?)
- Make SuccessCache constructor private, add static create()
- Consolidate duplicate @backstage/cli-node imports

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-02-25 12:46:55 +01:00
parent 3c811bf8a9
commit 968570bbb5
11 changed files with 49 additions and 44 deletions
@@ -24,11 +24,11 @@ import {
BackstagePackageJson,
Lockfile,
runWorkerQueueThreads,
SuccessCache,
} from '@backstage/cli-node';
import { targetPaths } from '@backstage/cli-common';
import { createScriptOptionsParser } from '../../lib/optionsParser';
import { SuccessCache } from '@backstage/cli-node';
function depCount(pkg: BackstagePackageJson) {
const deps = pkg.dependencies ? Object.keys(pkg.dependencies).length : 0;
@@ -41,7 +41,7 @@ function depCount(pkg: BackstagePackageJson) {
export async function command(opts: OptionValues, cmd: Command): Promise<void> {
let packages = await PackageGraph.listTargetPackages();
const cache = new SuccessCache('lint', opts.successCacheDir);
const cache = SuccessCache.create('lint', opts.successCacheDir);
const cacheContext = opts.successCache
? {
entries: await cache.read(),
@@ -31,7 +31,7 @@ import { isError, NotFoundError } from '@backstage/errors';
import { resolve as resolvePath } from 'node:path';
import {
getHasYarnPlugin,
hasYarnPlugin,
Lockfile,
runConcurrentTasks,
} from '@backstage/cli-node';
@@ -76,7 +76,7 @@ function extendsDefaultPattern(pattern: string): boolean {
export default async (opts: OptionValues) => {
const lockfilePath = targetPaths.resolveRoot('yarn.lock');
const lockfile = await Lockfile.load(lockfilePath);
const hasYarnPlugin = await getHasYarnPlugin();
const yarnPluginEnabled = await hasYarnPlugin();
let pattern = opts.pattern;
@@ -130,7 +130,7 @@ export default async (opts: OptionValues) => {
});
}
if (hasYarnPlugin) {
if (yarnPluginEnabled) {
console.log();
console.log(
`Updating yarn plugin to v${releaseManifest.releaseVersion}...`,
@@ -214,7 +214,7 @@ export default async (opts: OptionValues) => {
const oldLockfileRange = await asLockfileVersion(oldRange);
const useBackstageRange =
hasYarnPlugin &&
yarnPluginEnabled &&
// Only use backstage:^ versions if the package is present in
// the manifest for the release we're bumping to.
releaseManifest.packages.find(
@@ -254,7 +254,7 @@ export default async (opts: OptionValues) => {
if (extendsDefaultPattern(pattern)) {
await bumpBackstageJsonVersion(
releaseManifest.releaseVersion,
hasYarnPlugin,
yarnPluginEnabled,
);
} else {
console.log(
@@ -319,7 +319,7 @@ export default async (opts: OptionValues) => {
console.log();
}
if (hasYarnPlugin) {
if (yarnPluginEnabled) {
console.log();
console.log(
chalk.blue(
@@ -28,7 +28,7 @@ import { Lockfile } from '@backstage/cli-node';
import { targetPaths } from '@backstage/cli-common';
import { createPackageVersionProvider } from '../../../../lib/version';
import { getHasYarnPlugin } from '@backstage/cli-node';
import { hasYarnPlugin } from '@backstage/cli-node';
const builtInHelpers = {
camelCase,
@@ -55,9 +55,9 @@ export class PortableTemplater {
/* ignored */
}
const hasYarnPlugin = await getHasYarnPlugin();
const yarnPluginEnabled = await hasYarnPlugin();
const versionProvider = createPackageVersionProvider(lockfile, {
preferBackstageProtocol: hasYarnPlugin,
preferBackstageProtocol: yarnPluginEnabled,
});
const templater = new PortableTemplater(
@@ -22,7 +22,7 @@ import yargs from 'yargs';
import { run as runJest, yargsOptions as jestYargsOptions } from 'jest-cli';
import { relative as relativePath } from 'node:path';
import { Command, OptionValues } from 'commander';
import { Lockfile, PackageGraph } from '@backstage/cli-node';
import { Lockfile, PackageGraph, SuccessCache } from '@backstage/cli-node';
import {
runCheck,
@@ -31,7 +31,6 @@ import {
findOwnPaths,
isChildPath,
} from '@backstage/cli-common';
import { SuccessCache } from '@backstage/cli-node';
type JestProject = {
displayName: string;
@@ -333,7 +332,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
);
}
const cache = new SuccessCache('test', opts.successCacheDir);
const cache = SuccessCache.create('test', opts.successCacheDir);
const graph = await getPackageGraph();
// Shared state for the bridge