@code-pushup/js-packages-plugin 0.26.1
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.
- package/README.md +190 -0
- package/bin.js +1040 -0
- package/index.js +910 -0
- package/package.json +49 -0
- package/src/bin.d.ts +1 -0
- package/src/index.d.ts +3 -0
- package/src/lib/config.d.ts +28 -0
- package/src/lib/constants.d.ts +9 -0
- package/src/lib/js-packages-plugin.d.ts +19 -0
- package/src/lib/runner/audit/constants.d.ts +2 -0
- package/src/lib/runner/audit/transform.d.ts +7 -0
- package/src/lib/runner/audit/types.d.ts +27 -0
- package/src/lib/runner/constants.d.ts +3 -0
- package/src/lib/runner/index.d.ts +4 -0
- package/src/lib/runner/outdated/constants.d.ts +3 -0
- package/src/lib/runner/outdated/transform.d.ts +29 -0
- package/src/lib/runner/outdated/types.d.ts +15 -0
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@code-pushup/js-packages-plugin",
|
|
3
|
+
"version": "0.26.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@code-pushup/models": "*",
|
|
6
|
+
"@code-pushup/utils": "*",
|
|
7
|
+
"zod": "^3.22.4"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"homepage": "https://github.com/code-pushup/cli#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/code-pushup/cli/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/code-pushup/cli.git",
|
|
17
|
+
"directory": "packages/plugin-js-packages"
|
|
18
|
+
},
|
|
19
|
+
"contributors": [
|
|
20
|
+
{
|
|
21
|
+
"name": "Igor Katsuba",
|
|
22
|
+
"email": "igor@katsuba.dev",
|
|
23
|
+
"url": "https://katsuba.dev"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Kateřina Pilátová",
|
|
27
|
+
"email": "katerina.pilatova@flowup.cz",
|
|
28
|
+
"url": "https://github.com/Tlacenka"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Matěj Chalk",
|
|
32
|
+
"email": "matej.chalk@flowup.cz",
|
|
33
|
+
"url": "https://github.com/matejchalk"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "Michael Hladky",
|
|
37
|
+
"email": "michael.hladky@push-based.io",
|
|
38
|
+
"url": "https://push-based.io"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Michael Seredenko",
|
|
42
|
+
"email": "misha.seredenko@push-based.io",
|
|
43
|
+
"url": "https://github.com/MishaSeredenkoPushBased"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"type": "module",
|
|
47
|
+
"main": "./index.js",
|
|
48
|
+
"types": "./src/index.d.ts"
|
|
49
|
+
}
|
package/src/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { IssueSeverity } from '@code-pushup/models';
|
|
3
|
+
export declare const dependencyGroups: readonly ["prod", "dev", "optional"];
|
|
4
|
+
export type DependencyGroup = (typeof dependencyGroups)[number];
|
|
5
|
+
declare const packageCommandSchema: z.ZodEnum<["audit", "outdated"]>;
|
|
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>;
|
|
9
|
+
export declare const packageAuditLevels: readonly ["critical", "high", "moderate", "low", "info"];
|
|
10
|
+
declare const packageAuditLevelSchema: z.ZodEnum<["critical", "high", "moderate", "low", "info"]>;
|
|
11
|
+
export type PackageAuditLevel = z.infer<typeof packageAuditLevelSchema>;
|
|
12
|
+
export declare function fillAuditLevelMapping(mapping: Partial<Record<PackageAuditLevel, IssueSeverity>>): Record<PackageAuditLevel, IssueSeverity>;
|
|
13
|
+
export declare const jsPackagesPluginConfigSchema: z.ZodObject<{
|
|
14
|
+
checks: z.ZodDefault<z.ZodArray<z.ZodEnum<["audit", "outdated"]>, "many">>;
|
|
15
|
+
packageManager: z.ZodEnum<["npm", "yarn-classic", "yarn-modern", "pnpm"]>;
|
|
16
|
+
auditLevelMapping: z.ZodEffects<z.ZodDefault<z.ZodRecord<z.ZodEnum<["critical", "high", "moderate", "low", "info"]>, z.ZodEnum<["info", "warning", "error"]>>>, Record<"info" | "critical" | "high" | "moderate" | "low", "error" | "info" | "warning">, Partial<Record<"info" | "critical" | "high" | "moderate" | "low", "error" | "info" | "warning">> | undefined>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
checks: ("audit" | "outdated")[];
|
|
19
|
+
packageManager: "npm" | "pnpm" | "yarn-classic" | "yarn-modern";
|
|
20
|
+
auditLevelMapping: Record<"info" | "critical" | "high" | "moderate" | "low", "error" | "info" | "warning">;
|
|
21
|
+
}, {
|
|
22
|
+
packageManager: "npm" | "pnpm" | "yarn-classic" | "yarn-modern";
|
|
23
|
+
checks?: ("audit" | "outdated")[] | undefined;
|
|
24
|
+
auditLevelMapping?: Partial<Record<"info" | "critical" | "high" | "moderate" | "low", "error" | "info" | "warning">> | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export type JSPackagesPluginConfig = z.input<typeof jsPackagesPluginConfigSchema>;
|
|
27
|
+
export type FinalJSPackagesPluginConfig = z.infer<typeof jsPackagesPluginConfigSchema>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IssueSeverity, MaterialIcon } from '@code-pushup/models';
|
|
2
|
+
import type { DependencyGroup, PackageAuditLevel, PackageManager } from './config';
|
|
3
|
+
export declare const defaultAuditLevelMapping: Record<PackageAuditLevel, IssueSeverity>;
|
|
4
|
+
export declare const pkgManagerNames: Record<PackageManager, string>;
|
|
5
|
+
export declare const pkgManagerIcons: Record<PackageManager, MaterialIcon>;
|
|
6
|
+
export declare const pkgManagerDocs: Record<PackageManager, string>;
|
|
7
|
+
export declare const auditDocs: Record<PackageManager, string>;
|
|
8
|
+
export declare const outdatedDocs: Record<PackageManager, string>;
|
|
9
|
+
export declare const dependencyDocs: Record<DependencyGroup, string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PluginConfig } from '@code-pushup/models';
|
|
2
|
+
import { JSPackagesPluginConfig } from './config';
|
|
3
|
+
/**
|
|
4
|
+
* Instantiates Code PushUp JS packages plugin for core config.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import jsPackagesPlugin from '@code-pushup/js-packages-plugin'
|
|
8
|
+
*
|
|
9
|
+
* export default {
|
|
10
|
+
* // ... core config ...
|
|
11
|
+
* plugins: [
|
|
12
|
+
* // ... other plugins ...
|
|
13
|
+
* await jsPackagesPlugin({ packageManager: 'npm' })
|
|
14
|
+
* ]
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @returns Plugin configuration.
|
|
18
|
+
*/
|
|
19
|
+
export declare function jsPackagesPlugin(config: JSPackagesPluginConfig): Promise<PluginConfig>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AuditOutput, Issue, IssueSeverity } from '@code-pushup/models';
|
|
2
|
+
import { DependencyGroup, PackageAuditLevel } from '../../config';
|
|
3
|
+
import { NpmAuditResultJson, Vulnerabilities } from './types';
|
|
4
|
+
export declare function auditResultToAuditOutput(result: NpmAuditResultJson, dependenciesType: DependencyGroup, auditLevelMapping: Record<PackageAuditLevel, IssueSeverity>): AuditOutput;
|
|
5
|
+
export declare function calculateAuditScore(stats: Record<PackageAuditLevel | 'total', number>): number;
|
|
6
|
+
export declare function vulnerabilitiesToDisplayValue(vulnerabilities: Record<PackageAuditLevel | 'total', number>): string;
|
|
7
|
+
export declare function vulnerabilitiesToIssues(vulnerabilities: Vulnerabilities, auditLevelMapping: Record<PackageAuditLevel, IssueSeverity>): Issue[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PackageAuditLevel } from '../../config';
|
|
2
|
+
type Advisory = {
|
|
3
|
+
title: string;
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
6
|
+
type FixInformation = {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
isSemVerMajor: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type Vulnerability = {
|
|
12
|
+
name: string;
|
|
13
|
+
severity: PackageAuditLevel;
|
|
14
|
+
via: Advisory[] | string[];
|
|
15
|
+
range: string;
|
|
16
|
+
fixAvailable: boolean | FixInformation;
|
|
17
|
+
};
|
|
18
|
+
export type Vulnerabilities = {
|
|
19
|
+
[key: string]: Vulnerability;
|
|
20
|
+
};
|
|
21
|
+
export type NpmAuditResultJson = {
|
|
22
|
+
vulnerabilities: Vulnerabilities;
|
|
23
|
+
metadata: {
|
|
24
|
+
vulnerabilities: Record<PackageAuditLevel | 'total', number>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RunnerConfig } from '@code-pushup/models';
|
|
2
|
+
import { FinalJSPackagesPluginConfig } from '../config';
|
|
3
|
+
export declare function createRunnerConfig(scriptPath: string, config: FinalJSPackagesPluginConfig): Promise<RunnerConfig>;
|
|
4
|
+
export declare function executeRunner(): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Issue } from '@code-pushup/models';
|
|
2
|
+
import { DependencyGroup } from '../../config';
|
|
3
|
+
import { NormalizedOutdatedEntries, NpmOutdatedResultJson, PackageVersion, VersionType } from './types';
|
|
4
|
+
export declare function outdatedResultToAuditOutput(result: NpmOutdatedResultJson, dependenciesType: DependencyGroup): {
|
|
5
|
+
details?: {
|
|
6
|
+
issues: {
|
|
7
|
+
message: string;
|
|
8
|
+
severity: "error" | "info" | "warning";
|
|
9
|
+
source?: {
|
|
10
|
+
file: string;
|
|
11
|
+
position?: {
|
|
12
|
+
startLine: number;
|
|
13
|
+
startColumn?: number | undefined;
|
|
14
|
+
endLine?: number | undefined;
|
|
15
|
+
endColumn?: number | undefined;
|
|
16
|
+
} | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}[];
|
|
19
|
+
} | undefined;
|
|
20
|
+
slug: string;
|
|
21
|
+
score: number;
|
|
22
|
+
value: number;
|
|
23
|
+
displayValue: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function calculateOutdatedScore(majorOutdated: number, totalDeps: number): number;
|
|
26
|
+
export declare function outdatedToDisplayValue(majorOutdated: number, totalOutdated: number): string;
|
|
27
|
+
export declare function outdatedToIssues(dependencies: NormalizedOutdatedEntries): Issue[];
|
|
28
|
+
export declare function getOutdatedLevel(currentFullVersion: string, wantedFullVersion: string): VersionType;
|
|
29
|
+
export declare function splitPackageVersion(fullVersion: string): PackageVersion;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type VersionType = 'major' | 'minor' | 'patch';
|
|
2
|
+
export type PackageVersion = Record<VersionType, number>;
|
|
3
|
+
export type VersionOverview = {
|
|
4
|
+
current?: string;
|
|
5
|
+
wanted: string;
|
|
6
|
+
type: 'dependencies' | 'devDependencies' | 'optionalDependencies';
|
|
7
|
+
homepage?: string;
|
|
8
|
+
};
|
|
9
|
+
export type NormalizedVersionOverview = Omit<VersionOverview, 'current'> & {
|
|
10
|
+
current: string;
|
|
11
|
+
};
|
|
12
|
+
export type NormalizedOutdatedEntries = [string, NormalizedVersionOverview][];
|
|
13
|
+
export type NpmOutdatedResultJson = {
|
|
14
|
+
[key: string]: VersionOverview;
|
|
15
|
+
};
|