Skip to content

Commit

Permalink
show reason for incompatible update
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Apr 26, 2021
1 parent 9778689 commit a61b7f5
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 35 deletions.
109 changes: 82 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"inquirer": "7.3.3",
"libnpmconfig": "1.2.1",
"lodash": "4.17.21",
"npm-check-updates": "11.4.0",
"npm-check-updates": "11.5.3",
"open": "7.4.2",
"pacote": "11.2.7",
"semver": "7.3.4",
Expand Down
26 changes: 19 additions & 7 deletions src/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,25 @@ export const handler = catchAsyncError(async opts => {
.filter(({name}) => opts[name])
.map(({ncuValue}) => ncuValue)
.join(',');

const currentVersions = ncu.getCurrentDependencies(packageJson, {dep: ncuDepGroups});
const peerDependencies = ncu.getPeerDependencies(currentVersions, {});
const compatibleVersions = await ncu.queryVersions(currentVersions, {versionTarget: 'latest', peerDependencies});
const latestVersions = await ncu.queryVersions(currentVersions, {versionTarget: 'latest', loglevel: 'silent'});

const [upgradedCompatibleVersionsFull, compatibleVersions, upgradedPeerDependencies] =
await ncu.upgradePackageDefinitions(
currentVersions,
{versionTarget: 'latest', peer: true, peerDependencies}
);
const [upgradedLatestVersionsFull, latestVersions] = await ncu.upgradePackageDefinitions(
currentVersions,
{versionTarget: 'latest', loglevel: 'silent'}
);
// Filtering modules that have to be updated
const upgradedLatestVersions = _.pickBy(
ncu.upgradeDependencies(currentVersions, latestVersions),
upgradedLatestVersionsFull,
(newVersion, moduleName) => filterModuleName(moduleName)
);
const upgradedCompatibleVersions = _.pickBy(
ncu.upgradeDependencies(currentVersions, compatibleVersions),
upgradedCompatibleVersionsFull,
(newVersion, moduleName) => filterModuleName(moduleName)
);

Expand Down Expand Up @@ -135,10 +142,15 @@ export const handler = catchAsyncError(async opts => {
if (!_.isEmpty(incompatibleVersions)) {
const rows = _.map(Object.entries(incompatibleVersions), ([name, to]) => [
strong(name),
currentVersions[name], '→', colorizeDiff(currentVersions[name], to)
currentVersions[name], '→', colorizeDiff(currentVersions[name], to),
'cause: ' + Object.entries(upgradedPeerDependencies)
.filter(([, peers]) => peers[name] !== undefined && !semver.satisfies(latestVersions[name], peers[name]))
.map(([pkg, peers]) => pkg + ' requires ' + peers[name])
.join(', ')
]);

console.log(`\n${strong('Ignored incompatible updates (peer dependencies):')}\n\n${createSimpleTable(rows)}`);
console.log(`\n${strong('Ignored incompatible updates (peer dependencies):')}\n`);
console.log(`\n${createSimpleTable(rows, {colAligns: 'lrrrl'})}`);
}

if (!_.isEmpty(ignoredModules)) {
Expand Down

0 comments on commit a61b7f5

Please sign in to comment.