Add check for outdated/duplicate packages to yarn start

This commit is contained in:
Kevin Lee
2021-01-28 14:35:08 -08:00
parent a22fc866eb
commit a08c4b0b05
2 changed files with 33 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Add check for outdated/duplicate packages to yarn start
+28
View File
@@ -15,12 +15,40 @@
*/
import fs from 'fs-extra';
import chalk from 'chalk';
import { Command } from 'commander';
import { serveBundle } from '../../lib/bundler';
import { loadCliConfig } from '../../lib/config';
import { paths } from '../../lib/paths';
import { Lockfile } from '../../lib/versioning';
import { includedFilter } from '../versions/lint';
export default async (cmd: Command) => {
const lockfile = await Lockfile.load(paths.resolveTargetRoot('yarn.lock'));
const result = lockfile.analyze({
filter: includedFilter,
});
const problemPackages = result.newVersions.map(({ name }) => name);
if (problemPackages.length > 1) {
console.log(
chalk.yellow(
`The following packages may be outdated or have duplicate installations:
${problemPackages.join(', ')}
`,
),
);
console.log(
chalk.yellow(
`This can be resolved using the following command:
yarn backstage-cli versions:check --fix
`,
),
);
}
const { name } = await fs.readJson(paths.resolveTarget('package.json'));
const waitForExit = await serveBundle({
entry: 'src/index',