fix(tools): make cli available even conficts exist (#9678)

This commit is contained in:
forehalo
2025-01-14 09:31:23 +00:00
parent e418465c0c
commit 13d40e5f52
5 changed files with 48 additions and 27 deletions
+3 -22
View File
@@ -1,11 +1,8 @@
import { once } from 'lodash-es';
import { Logger } from './logger';
import { Package, readPackageJson } from './package';
import { ProjectRoot } from './path';
import { exec } from './process';
import type { CommonPackageJsonContent, YarnWorkspaceItem } from './types';
import { PackageList, type PackageName } from './workspace.gen';
import type { CommonPackageJsonContent } from './types';
import { PackageList, type PackageName, yarnList } from './yarn';
class CircularDependenciesError extends Error {
constructor(public currentName: string) {
@@ -147,25 +144,9 @@ export class Workspace {
building.delete(pkg.name);
}
yarnList = once(() => {
const output = exec('', 'yarn workspaces list -v --json', { silent: true });
let packageList = JSON.parse(
`[${output.trim().replace(/\r\n|\n/g, ',')}]`
) as YarnWorkspaceItem[];
packageList.forEach(p => {
p.location = p.location.replaceAll(/\\/g, '/');
delete p['mismatchedWorkspaceDependencies'];
});
// ignore root package
return packageList.filter(p => p.location !== '.');
});
forEach(callback: (pkg: Package) => void) {
this.packages.forEach(callback);
}
}
export { Package, type PackageName };
export { Package, type PackageName, yarnList };