Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ export function pnpmToOutdatedResult(output: string): OutdatedResult {
filterOutWarnings(output),
) as PnpmOutdatedResultJson;

// "current" may be missing if package is not installed
// Fallback to "wanted" - same approach as npm
return objectToEntries(pnpmOutdated).map(
([name, { current, latest, dependencyType: type }]) => ({
([name, { current, latest, wanted, dependencyType: type }]) => ({
name,
current,
current: current || wanted,
latest,
type,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ describe('pnpmToOutdatedResult', () => {
cypress: {
current: '8.5.0',
latest: '13.6.0',
wanted: '8.5.0',
dependencyType: 'devDependencies',
},
'@cypress/request': {
current: '2.88.10',
latest: '3.0.0',
wanted: '2.88.10',
dependencyType: 'devDependencies',
},
} satisfies PnpmOutdatedResultJson),
Expand Down Expand Up @@ -49,11 +51,13 @@ describe('pnpmToOutdatedResult', () => {
"cypress": {
"current": "8.5.0",
"latest": "13.6.0",
"wanted": "8.5.0",
"dependencyType": "devDependencies"
},
"@cypress/request": {
"current": "2.88.10",
"latest": "3.0.0",
"wanted": "2.88.10",
"dependencyType": "devDependencies"
}
}
Expand All @@ -74,4 +78,35 @@ describe('pnpmToOutdatedResult', () => {
},
]);
});

it('should handle dependencies with missing current version by falling back to wanted', () => {
const output = JSON.stringify({
'@angular/animations': {
latest: '21.0.1',
wanted: '20.3.12',
dependencyType: 'dependencies',
},
rxjs: {
current: '7.8.0',
latest: '7.8.1',
wanted: '7.8.0',
dependencyType: 'dependencies',
},
});

expect(pnpmToOutdatedResult(output)).toEqual([
{
name: '@angular/animations',
current: '20.3.12',
latest: '21.0.1',
type: 'dependencies',
},
{
name: 'rxjs',
current: '7.8.0',
latest: '7.8.1',
type: 'dependencies',
},
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export type PnpmAuditResultJson = {

// Subset of PNPM outdated JSON type
export type PnpmVersionOverview = {
current: string;
current?: string;
latest: string;
wanted: string;
dependencyType: DependencyGroupLong;
};
export type PnpmOutdatedResultJson = Record<string, PnpmVersionOverview>;