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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { objectToKeys } from '@code-pushup/utils';
import type { DependencyGroup } from '../../config.js';
import { filterAuditResult } from '../../runner/utils.js';
import { COMMON_AUDIT_ARGS, COMMON_OUTDATED_ARGS } from '../constants.js';
import type { AuditResults, PackageManager } from '../types.js';
import { npmToAuditResult } from './audit-result.js';
import { npmToOutdatedResult } from './outdated-result.js';
Expand All @@ -24,9 +23,10 @@ export const npmPackageManager: PackageManager = {
},
audit: {
getCommandArgs: groupDep => [
...COMMON_AUDIT_ARGS,
'audit',
...npmDependencyOptions[groupDep],
'--audit-level=none',
'--json',
],
unifyResult: npmToAuditResult,
// prod dependencies need to be filtered out manually since v10
Expand All @@ -49,7 +49,7 @@ export const npmPackageManager: PackageManager = {
},
},
outdated: {
commandArgs: [...COMMON_OUTDATED_ARGS, '--long'],
commandArgs: ['outdated', '--long', '--json'],
unifyResult: npmToOutdatedResult,
},
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { objectToKeys } from '@code-pushup/utils';
import type { DependencyGroup } from '../../config.js';
import { filterAuditResult } from '../../runner/utils.js';
import { COMMON_AUDIT_ARGS, COMMON_OUTDATED_ARGS } from '../constants.js';
import type { AuditResults, PackageManager } from '../types.js';
import { pnpmToAuditResult } from './audit-result.js';
import { pnpmToOutdatedResult } from './outdated-result.js';
Expand All @@ -24,8 +23,9 @@ export const pnpmPackageManager: PackageManager = {
},
audit: {
getCommandArgs: groupDep => [
...COMMON_AUDIT_ARGS,
'audit',
...pnpmDependencyOptions[groupDep],
'--json',
],
ignoreExitCode: true,
unifyResult: pnpmToAuditResult,
Expand All @@ -49,7 +49,7 @@ export const pnpmPackageManager: PackageManager = {
},
},
outdated: {
commandArgs: COMMON_OUTDATED_ARGS,
commandArgs: ['outdated', '--json'],
unifyResult: pnpmToOutdatedResult,
},
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { dependencyGroupToLong } from '../../constants.js';
import { COMMON_AUDIT_ARGS, COMMON_OUTDATED_ARGS } from '../constants.js';
import type { PackageManager } from '../types.js';
import { yarnClassicToAuditResult } from './audit-result.js';
import { yarnClassicToOutdatedResult } from './outdated-result.js';
Expand All @@ -16,15 +15,15 @@ export const yarnClassicPackageManager: PackageManager = {
},
audit: {
getCommandArgs: groupDep => [
...COMMON_AUDIT_ARGS,
'--groups',
dependencyGroupToLong[groupDep],
'audit',
`--groups=${dependencyGroupToLong[groupDep]}`,
'--json',
],
ignoreExitCode: true,
unifyResult: yarnClassicToAuditResult,
},
outdated: {
commandArgs: COMMON_OUTDATED_ARGS,
commandArgs: ['outdated', '--json'],
unifyResult: yarnClassicToOutdatedResult,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import type { YarnBerryOutdatedResultJson } from './types.js';
export function yarnBerryToOutdatedResult(output: string): OutdatedResult {
const npmOutdated = JSON.parse(output) as YarnBerryOutdatedResultJson;

return npmOutdated.map(({ name, current, latest, type }) => ({
return npmOutdated.map(({ name, current, latest, type, url }) => ({
name,
current,
latest,
type,
...(url && { url }),
}));
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('yarnBerryToOutdatedResult', () => {
current: '16.8.1',
latest: '17.0.0',
type: 'dependencies',
url: 'https://nx.dev/',
},
{
name: 'vite',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export type YarnBerryOutdatedPackage = {
current: string;
latest: string;
name: string;
range?: string;
type: DependencyGroupLong;
url?: string;
workspace?: string;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Yarn v2 does not currently audit optional dependencies
import type { DependencyGroup } from '../../config.js';
import { COMMON_AUDIT_ARGS, COMMON_OUTDATED_ARGS } from '../constants.js';
import type { PackageManager } from '../types.js';
import { yarnBerryToAuditResult } from './audit-result.js';
import { yarnBerryToOutdatedResult } from './outdated-result.js';
Expand All @@ -23,18 +22,27 @@ export const yarnModernPackageManager: PackageManager = {
outdated: 'https://github.com/mskelton/yarn-plugin-outdated',
},
audit: {
getCommandArgs: groupDep => [
'npm',
...COMMON_AUDIT_ARGS,
'--environment',
yarnModernEnvironmentOptions[groupDep],
],
getCommandArgs: groupDep => {
const environment = yarnModernEnvironmentOptions[groupDep];
return [
'npm',
'audit',
'--recursive',
...(environment ? [`--environment=${environment}`] : []),
'--json',
];
},
supportedDepGroups: ['prod', 'dev'], // Yarn v2 does not support audit for optional dependencies
unifyResult: yarnBerryToAuditResult,
ignoreExitCode: true,
},
outdated: {
commandArgs: [...COMMON_OUTDATED_ARGS, '--workspace=.'], // filter out other packages in case of Yarn workspaces
commandArgs: [
'outdated',
'--workspace=.', // filter out other packages in case of Yarn workspaces
'--url',
'--json',
],
unifyResult: yarnBerryToOutdatedResult,
},
};