Merge pull request #4295 from LeKeve/lekeve/update-start-version-check

Add check for outdated/duplicate packages to yarn start
This commit is contained in:
Fredrik Adelöw
2021-02-01 13:59:42 +01:00
committed by GitHub
2 changed files with 36 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Add check for outdated/duplicate packages to yarn start
+31
View File
@@ -15,12 +15,43 @@
*/
import fs from 'fs-extra';
import chalk from 'chalk';
import uniq from 'lodash/uniq';
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, ...result.newRanges].map(
({ name }) => name,
);
if (problemPackages.length > 1) {
console.log(
chalk.yellow(
`⚠️ Some of the following packages may be outdated or have duplicate installations:
${uniq(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',