@code-pushup/js-packages-plugin 0.34.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CONTRIBUTING.md +15 -5
  2. package/README.md +17 -3
  3. package/bin.js +289 -195
  4. package/index.js +497 -97
  5. package/package.json +3 -3
  6. package/src/lib/config.d.ts +2 -2
  7. package/src/lib/constants.d.ts +3 -8
  8. package/src/lib/package-managers/constants.d.ts +2 -0
  9. package/src/lib/package-managers/index.d.ts +2 -0
  10. package/src/lib/package-managers/npm/audit-result.d.ts +5 -0
  11. package/src/lib/package-managers/npm/npm.d.ts +2 -0
  12. package/src/lib/package-managers/npm/outdated-result.d.ts +2 -0
  13. package/src/lib/package-managers/npm/types.d.ts +38 -0
  14. package/src/lib/package-managers/package-managers.d.ts +3 -0
  15. package/src/lib/package-managers/pnpm/audit-result.d.ts +3 -0
  16. package/src/lib/package-managers/pnpm/outdated-result.d.ts +2 -0
  17. package/src/lib/package-managers/pnpm/pnpm.d.ts +2 -0
  18. package/src/lib/package-managers/pnpm/types.d.ts +26 -0
  19. package/src/lib/package-managers/types.d.ts +26 -0
  20. package/src/lib/package-managers/yarn-classic/audit-result.d.ts +2 -0
  21. package/src/lib/package-managers/yarn-classic/outdated-result.d.ts +2 -0
  22. package/src/lib/package-managers/yarn-classic/types.d.ts +49 -0
  23. package/src/lib/package-managers/yarn-classic/yarn-classic.d.ts +2 -0
  24. package/src/lib/package-managers/yarn-modern/audit-result.d.ts +2 -0
  25. package/src/lib/package-managers/yarn-modern/outdated-result.d.ts +2 -0
  26. package/src/lib/package-managers/yarn-modern/types.d.ts +26 -0
  27. package/src/lib/package-managers/yarn-modern/yarn-modern.d.ts +2 -0
  28. package/src/lib/runner/audit/constants.d.ts +1 -5
  29. package/src/lib/runner/audit/transform.d.ts +2 -2
  30. package/src/lib/runner/audit/types.d.ts +0 -87
  31. package/src/lib/runner/audit/utils.d.ts +2 -0
  32. package/src/lib/runner/outdated/constants.d.ts +2 -5
  33. package/src/lib/runner/outdated/transform.d.ts +2 -2
  34. package/src/lib/runner/outdated/types.d.ts +0 -43
  35. package/src/lib/runner/audit/unify-type.d.ts +0 -8
  36. package/src/lib/runner/outdated/unify-type.d.ts +0 -5
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@code-pushup/js-packages-plugin",
3
- "version": "0.34.0",
3
+ "version": "0.39.0",
4
4
  "dependencies": {
5
- "@code-pushup/models": "0.34.0",
6
- "@code-pushup/utils": "0.34.0",
5
+ "@code-pushup/models": "0.39.0",
6
+ "@code-pushup/utils": "0.39.0",
7
7
  "zod": "^3.22.4"
8
8
  },
9
9
  "license": "MIT",
@@ -4,8 +4,8 @@ export declare const dependencyGroups: readonly ["prod", "dev", "optional"];
4
4
  export type DependencyGroup = (typeof dependencyGroups)[number];
5
5
  declare const packageCommandSchema: z.ZodEnum<["audit", "outdated"]>;
6
6
  export type PackageCommand = z.infer<typeof packageCommandSchema>;
7
- declare const packageManagerSchema: z.ZodEnum<["npm", "yarn-classic", "yarn-modern", "pnpm"]>;
8
- export type PackageManager = z.infer<typeof packageManagerSchema>;
7
+ declare const packageManagerIdSchema: z.ZodEnum<["npm", "yarn-classic", "yarn-modern", "pnpm"]>;
8
+ export type PackageManagerId = z.infer<typeof packageManagerIdSchema>;
9
9
  export declare const packageAuditLevels: readonly ["critical", "high", "moderate", "low", "info"];
10
10
  declare const packageAuditLevelSchema: z.ZodEnum<["critical", "high", "moderate", "low", "info"]>;
11
11
  export type PackageAuditLevel = z.infer<typeof packageAuditLevelSchema>;
@@ -1,12 +1,7 @@
1
- import { IssueSeverity, MaterialIcon } from '@code-pushup/models';
2
- import type { DependencyGroup, PackageAuditLevel, PackageManager } from './config';
1
+ import { IssueSeverity } from '@code-pushup/models';
2
+ import type { DependencyGroup, PackageAuditLevel } from './config';
3
3
  import { DependencyGroupLong } from './runner/outdated/types';
4
4
  export declare const defaultAuditLevelMapping: Record<PackageAuditLevel, IssueSeverity>;
5
5
  export declare const dependencyGroupToLong: Record<DependencyGroup, DependencyGroupLong>;
6
- export declare const pkgManagerCommands: Record<PackageManager, string>;
7
- export declare const pkgManagerNames: Record<PackageManager, string>;
8
- export declare const pkgManagerIcons: Record<PackageManager, MaterialIcon>;
9
- export declare const pkgManagerDocs: Record<PackageManager, string>;
10
- export declare const auditDocs: Record<PackageManager, string>;
11
- export declare const outdatedDocs: Record<PackageManager, string>;
6
+ export declare const dependencyGroupWeights: Record<DependencyGroup, number>;
12
7
  export declare const dependencyDocs: Record<DependencyGroup, string>;
@@ -0,0 +1,2 @@
1
+ export declare const COMMON_AUDIT_ARGS: string[];
2
+ export declare const COMMON_OUTDATED_ARGS: string[];
@@ -0,0 +1,2 @@
1
+ export { packageManagers } from './package-managers';
2
+ export { PackageManager } from './types';
@@ -0,0 +1,5 @@
1
+ import { AuditResult } from '../../runner/audit/types';
2
+ import { NpmAdvisory, NpmFixInformation, NpmVulnerabilities } from './types';
3
+ export declare function npmToAuditResult(output: string): AuditResult;
4
+ export declare function npmToFixInformation(fixAvailable: boolean | NpmFixInformation): string;
5
+ export declare function npmToAdvisory(name: string, vulnerabilities: NpmVulnerabilities, prevNodes?: Set<string>): NpmAdvisory | null;
@@ -0,0 +1,2 @@
1
+ import { PackageManager } from '../types';
2
+ export declare const npmPackageManager: PackageManager;
@@ -0,0 +1,2 @@
1
+ import { OutdatedResult } from '../../runner/outdated/types';
2
+ export declare function npmToOutdatedResult(output: string): OutdatedResult;
@@ -0,0 +1,38 @@
1
+ import { PackageAuditLevel } from '../../config';
2
+ import { AuditSummary } from '../../runner/audit/types';
3
+ import { DependencyGroupLong } from '../../runner/outdated/types';
4
+ export type NpmAdvisory = {
5
+ title: string;
6
+ url: string;
7
+ };
8
+ export type NpmFixInformation = {
9
+ name: string;
10
+ version: string;
11
+ isSemVerMajor: boolean;
12
+ };
13
+ export type NpmVulnerability = {
14
+ name: string;
15
+ severity: PackageAuditLevel;
16
+ isDirect: boolean;
17
+ effects: string[];
18
+ via: NpmAdvisory[] | string[];
19
+ range: string;
20
+ fixAvailable: boolean | NpmFixInformation;
21
+ };
22
+ export type NpmVulnerabilities = Record<string, NpmVulnerability>;
23
+ export type NpmAuditResultJson = {
24
+ vulnerabilities: NpmVulnerabilities;
25
+ metadata: {
26
+ vulnerabilities: AuditSummary;
27
+ };
28
+ };
29
+ export type NpmVersionOverview = {
30
+ current?: string;
31
+ latest: string;
32
+ type: DependencyGroupLong;
33
+ homepage?: string;
34
+ };
35
+ export type NpmNormalizedOverview = Omit<NpmVersionOverview, 'current'> & {
36
+ current: string;
37
+ };
38
+ export type NpmOutdatedResultJson = Record<string, NpmVersionOverview>;
@@ -0,0 +1,3 @@
1
+ import { PackageManagerId } from '../config';
2
+ import { PackageManager } from './types';
3
+ export declare const packageManagers: Record<PackageManagerId, PackageManager>;
@@ -0,0 +1,3 @@
1
+ import { AuditResult } from '../../runner/audit/types';
2
+ export declare function pnpmToAuditResult(output: string): AuditResult;
3
+ export declare function pnpmToDirectDependency(path: string): string | true;
@@ -0,0 +1,2 @@
1
+ import { OutdatedResult } from '../../runner/outdated/types';
2
+ export declare function pnpmToOutdatedResult(output: string): OutdatedResult;
@@ -0,0 +1,2 @@
1
+ import { PackageManager } from '../types';
2
+ export declare const pnpmPackageManager: PackageManager;
@@ -0,0 +1,26 @@
1
+ import { PackageAuditLevel } from '../../config';
2
+ import { DependencyGroupLong } from '../../runner/outdated/types';
3
+ export type PnpmAuditAdvisory = {
4
+ module_name: string;
5
+ id: number;
6
+ severity: PackageAuditLevel;
7
+ vulnerable_versions: string;
8
+ recommendation: string;
9
+ title: string;
10
+ url: string;
11
+ findings: {
12
+ paths: string[];
13
+ }[];
14
+ };
15
+ export type PnpmAuditResultJson = {
16
+ advisories: Record<string, PnpmAuditAdvisory>;
17
+ metadata: {
18
+ vulnerabilities: Record<PackageAuditLevel, number>;
19
+ };
20
+ };
21
+ export type PnpmVersionOverview = {
22
+ current: string;
23
+ latest: string;
24
+ dependencyType: DependencyGroupLong;
25
+ };
26
+ export type PnpmOutdatedResultJson = Record<string, PnpmVersionOverview>;
@@ -0,0 +1,26 @@
1
+ import type { MaterialIcon } from '@code-pushup/models';
2
+ import { DependencyGroup, PackageManagerId } from '../config';
3
+ import { AuditResult } from '../runner/audit/types';
4
+ import { OutdatedResult } from '../runner/outdated/types';
5
+ export type PackageManager = {
6
+ slug: PackageManagerId;
7
+ name: string;
8
+ command: string;
9
+ icon: MaterialIcon;
10
+ docs: {
11
+ homepage: string;
12
+ audit: string;
13
+ outdated: string;
14
+ };
15
+ audit: {
16
+ getCommandArgs: (groupDep: DependencyGroup) => string[];
17
+ ignoreExitCode?: boolean;
18
+ supportedDepGroups?: DependencyGroup[];
19
+ unifyResult: (output: string) => AuditResult;
20
+ postProcessResult?: (result: Record<DependencyGroup, AuditResult>) => Record<DependencyGroup, AuditResult>;
21
+ };
22
+ outdated: {
23
+ commandArgs: string[];
24
+ unifyResult: (output: string) => OutdatedResult;
25
+ };
26
+ };
@@ -0,0 +1,2 @@
1
+ import { AuditResult } from '../../runner/audit/types';
2
+ export declare function yarnv1ToAuditResult(output: string): AuditResult;
@@ -0,0 +1,2 @@
1
+ import { OutdatedResult } from '../../runner/outdated/types';
2
+ export declare function yarnv1ToOutdatedResult(output: string): OutdatedResult;
@@ -0,0 +1,49 @@
1
+ import { PackageAuditLevel } from '../../config';
2
+ import { DependencyGroupLong } from '../../runner/outdated/types';
3
+ export type Yarnv1AuditAdvisory = {
4
+ type: 'auditAdvisory';
5
+ data: {
6
+ resolution: {
7
+ id: number;
8
+ path: string;
9
+ };
10
+ advisory: {
11
+ module_name: string;
12
+ severity: PackageAuditLevel;
13
+ vulnerable_versions: string;
14
+ recommendation: string;
15
+ title: string;
16
+ url: string;
17
+ };
18
+ };
19
+ };
20
+ export type Yarnv1AuditSummary = {
21
+ type: 'auditSummary';
22
+ data: {
23
+ vulnerabilities: Record<PackageAuditLevel, number>;
24
+ };
25
+ };
26
+ export type Yarnv1AuditResultJson = [
27
+ ...Yarnv1AuditAdvisory[],
28
+ Yarnv1AuditSummary
29
+ ];
30
+ export type Yarnv1VersionOverview = [
31
+ string,
32
+ string,
33
+ string,
34
+ string,
35
+ string,
36
+ DependencyGroupLong,
37
+ string
38
+ ];
39
+ type Yarnv1Info = {
40
+ type: 'info';
41
+ };
42
+ type Yarnv1Table = {
43
+ type: 'table';
44
+ data: {
45
+ body: Yarnv1VersionOverview[];
46
+ };
47
+ };
48
+ export type Yarnv1OutdatedResultJson = [Yarnv1Info, Yarnv1Table];
49
+ export {};
@@ -0,0 +1,2 @@
1
+ import { PackageManager } from '../types';
2
+ export declare const yarnv1PackageManager: PackageManager;
@@ -0,0 +1,2 @@
1
+ import { AuditResult } from '../../runner/audit/types';
2
+ export declare function yarnv2ToAuditResult(output: string): AuditResult;
@@ -0,0 +1,2 @@
1
+ import { OutdatedResult } from '../../runner/outdated/types';
2
+ export declare function yarnv2ToOutdatedResult(output: string): OutdatedResult;
@@ -0,0 +1,26 @@
1
+ import { PackageAuditLevel } from '../../config';
2
+ import { DependencyGroupLong } from '../../runner/outdated/types';
3
+ export type Yarnv2AuditAdvisory = {
4
+ module_name: string;
5
+ severity: PackageAuditLevel;
6
+ vulnerable_versions: string;
7
+ recommendation: string;
8
+ title: string;
9
+ url: string;
10
+ findings: {
11
+ paths: string[];
12
+ }[];
13
+ };
14
+ export type Yarnv2AuditResultJson = {
15
+ advisories: Record<string, Yarnv2AuditAdvisory>;
16
+ metadata: {
17
+ vulnerabilities: Record<PackageAuditLevel, number>;
18
+ };
19
+ };
20
+ export type Yarnv2VersionOverview = {
21
+ current: string;
22
+ latest: string;
23
+ name: string;
24
+ type: DependencyGroupLong;
25
+ };
26
+ export type Yarnv2OutdatedResultJson = Yarnv2VersionOverview[];
@@ -0,0 +1,2 @@
1
+ import { PackageManager } from '../types';
2
+ export declare const yarnv2PackageManager: PackageManager;
@@ -1,6 +1,2 @@
1
- import { DependencyGroup, PackageAuditLevel, PackageManager } from '../../config';
2
- import { AuditResult } from './types';
1
+ import { PackageAuditLevel } from '../../config';
3
2
  export declare const auditScoreModifiers: Record<PackageAuditLevel, number>;
4
- export declare const normalizeAuditMapper: Record<PackageManager, (output: string) => AuditResult>;
5
- export declare const postProcessingAuditMapper: Partial<Record<PackageManager, (result: Record<DependencyGroup, AuditResult>) => Record<DependencyGroup, AuditResult>>>;
6
- export declare const auditArgs: (groupDep: DependencyGroup) => Record<PackageManager, string[]>;
@@ -1,7 +1,7 @@
1
1
  import type { AuditOutput, Issue } from '@code-pushup/models';
2
- import { AuditSeverity, DependencyGroup, PackageManager } from '../../config';
2
+ import { AuditSeverity, DependencyGroup, PackageManagerId } from '../../config';
3
3
  import { AuditResult, AuditSummary, Vulnerability } from './types';
4
- export declare function auditResultToAuditOutput(result: AuditResult, packageManager: PackageManager, dependenciesType: DependencyGroup, auditLevelMapping: AuditSeverity): AuditOutput;
4
+ export declare function auditResultToAuditOutput(result: AuditResult, id: PackageManagerId, depGroup: DependencyGroup, auditLevelMapping: AuditSeverity): AuditOutput;
5
5
  export declare function calculateAuditScore(stats: AuditSummary): number;
6
6
  export declare function summaryToDisplayValue(summary: AuditSummary): string;
7
7
  export declare function vulnerabilitiesToIssues(vulnerabilities: Vulnerability[], auditLevelMapping: AuditSeverity): Issue[];
@@ -14,90 +14,3 @@ export type AuditResult = {
14
14
  vulnerabilities: Vulnerability[];
15
15
  summary: AuditSummary;
16
16
  };
17
- export type NpmAdvisory = {
18
- title: string;
19
- url: string;
20
- };
21
- export type NpmFixInformation = {
22
- name: string;
23
- version: string;
24
- isSemVerMajor: boolean;
25
- };
26
- export type NpmVulnerability = {
27
- name: string;
28
- severity: PackageAuditLevel;
29
- isDirect: boolean;
30
- effects: string[];
31
- via: NpmAdvisory[] | string[];
32
- range: string;
33
- fixAvailable: boolean | NpmFixInformation;
34
- };
35
- export type NpmVulnerabilities = Record<string, NpmVulnerability>;
36
- export type NpmAuditResultJson = {
37
- vulnerabilities: NpmVulnerabilities;
38
- metadata: {
39
- vulnerabilities: AuditSummary;
40
- };
41
- };
42
- export type Yarnv1AuditAdvisory = {
43
- type: 'auditAdvisory';
44
- data: {
45
- resolution: {
46
- id: number;
47
- path: string;
48
- };
49
- advisory: {
50
- module_name: string;
51
- severity: PackageAuditLevel;
52
- vulnerable_versions: string;
53
- recommendation: string;
54
- title: string;
55
- url: string;
56
- };
57
- };
58
- };
59
- export type Yarnv1AuditSummary = {
60
- type: 'auditSummary';
61
- data: {
62
- vulnerabilities: Record<PackageAuditLevel, number>;
63
- };
64
- };
65
- export type Yarnv1AuditResultJson = [
66
- ...Yarnv1AuditAdvisory[],
67
- Yarnv1AuditSummary
68
- ];
69
- export type Yarnv2AuditAdvisory = {
70
- module_name: string;
71
- severity: PackageAuditLevel;
72
- vulnerable_versions: string;
73
- recommendation: string;
74
- title: string;
75
- url: string;
76
- findings: {
77
- paths: string[];
78
- }[];
79
- };
80
- export type Yarnv2AuditResultJson = {
81
- advisories: Record<string, Yarnv2AuditAdvisory>;
82
- metadata: {
83
- vulnerabilities: Record<PackageAuditLevel, number>;
84
- };
85
- };
86
- export type PnpmAuditAdvisory = {
87
- module_name: string;
88
- id: number;
89
- severity: PackageAuditLevel;
90
- vulnerable_versions: string;
91
- recommendation: string;
92
- title: string;
93
- url: string;
94
- findings: {
95
- paths: string[];
96
- }[];
97
- };
98
- export type PnpmAuditResultJson = {
99
- advisories: Record<string, PnpmAuditAdvisory>;
100
- metadata: {
101
- vulnerabilities: Record<PackageAuditLevel, number>;
102
- };
103
- };
@@ -0,0 +1,2 @@
1
+ import { PackageAuditLevel } from '../../config';
2
+ export declare function getVulnerabilitiesTotal(summary: Record<PackageAuditLevel, number>): number;
@@ -1,6 +1,3 @@
1
- import { IssueSeverity } from '@code-pushup/models';
2
- import { PackageManager } from '../../config';
3
- import { OutdatedResult, VersionType } from './types';
1
+ import type { IssueSeverity } from '@code-pushup/models';
2
+ import { VersionType } from './types';
4
3
  export declare const outdatedSeverity: Record<VersionType, IssueSeverity>;
5
- export declare const normalizeOutdatedMapper: Record<PackageManager, (output: string) => OutdatedResult>;
6
- export declare const outdatedArgs: Record<PackageManager, string[]>;
@@ -1,7 +1,7 @@
1
1
  import { Issue } from '@code-pushup/models';
2
- import { DependencyGroup, PackageManager } from '../../config';
2
+ import { DependencyGroup, PackageManagerId } from '../../config';
3
3
  import { OutdatedResult, PackageVersion, VersionType } from './types';
4
- export declare function outdatedResultToAuditOutput(result: OutdatedResult, packageManager: PackageManager, dependencyGroup: DependencyGroup): {
4
+ export declare function outdatedResultToAuditOutput(result: OutdatedResult, packageManager: PackageManagerId, depGroup: DependencyGroup): {
5
5
  details?: {
6
6
  issues: {
7
7
  message: string;
@@ -9,46 +9,3 @@ export type OutdatedResult = {
9
9
  type: DependencyGroupLong;
10
10
  url?: string;
11
11
  }[];
12
- export type NpmVersionOverview = {
13
- current?: string;
14
- latest: string;
15
- type: DependencyGroupLong;
16
- homepage?: string;
17
- };
18
- export type NpmNormalizedOverview = Omit<NpmVersionOverview, 'current'> & {
19
- current: string;
20
- };
21
- export type NpmOutdatedResultJson = Record<string, NpmVersionOverview>;
22
- export type Yarnv1VersionOverview = [
23
- string,
24
- string,
25
- string,
26
- string,
27
- string,
28
- DependencyGroupLong,
29
- string
30
- ];
31
- type Yarnv1Info = {
32
- type: 'info';
33
- };
34
- type Yarnv1Table = {
35
- type: 'table';
36
- data: {
37
- body: Yarnv1VersionOverview[];
38
- };
39
- };
40
- export type Yarnv1OutdatedResultJson = [Yarnv1Info, Yarnv1Table];
41
- export type Yarnv2VersionOverview = {
42
- current: string;
43
- latest: string;
44
- name: string;
45
- type: DependencyGroupLong;
46
- };
47
- export type Yarnv2OutdatedResultJson = Yarnv2VersionOverview[];
48
- export type PnpmVersionOverview = {
49
- current: string;
50
- latest: string;
51
- dependencyType: DependencyGroupLong;
52
- };
53
- export type PnpmOutdatedResultJson = Record<string, PnpmVersionOverview>;
54
- export {};
@@ -1,8 +0,0 @@
1
- import { AuditResult, NpmAdvisory, NpmFixInformation, NpmVulnerabilities } from './types';
2
- export declare function npmToAuditResult(output: string): AuditResult;
3
- export declare function npmToFixInformation(fixAvailable: boolean | NpmFixInformation): string;
4
- export declare function npmToAdvisory(name: string, vulnerabilities: NpmVulnerabilities, prevNodes?: Set<string>): NpmAdvisory | null;
5
- export declare function yarnv1ToAuditResult(output: string): AuditResult;
6
- export declare function yarnv2ToAuditResult(output: string): AuditResult;
7
- export declare function pnpmToAuditResult(output: string): AuditResult;
8
- export declare function pnpmToDirectDependency(path: string): string | true;
@@ -1,5 +0,0 @@
1
- import { OutdatedResult } from './types';
2
- export declare function npmToOutdatedResult(output: string): OutdatedResult;
3
- export declare function yarnv1ToOutdatedResult(output: string): OutdatedResult;
4
- export declare function yarnv2ToOutdatedResult(output: string): OutdatedResult;
5
- export declare function pnpmToOutdatedResult(output: string): OutdatedResult;