@code-pushup/js-packages-plugin 0.48.0 → 0.50.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/README.md +2 -2
  2. package/bin.js +104 -379
  3. package/index.js +200 -330
  4. package/package.json +6 -31
  5. package/src/lib/config.d.ts +5 -5
  6. package/src/lib/constants.d.ts +2 -2
  7. package/src/lib/js-packages-plugin.d.ts +2 -2
  8. package/src/lib/package-managers/derive-package-manager.d.ts +3 -0
  9. package/src/lib/package-managers/derive-yarn.d.ts +1 -0
  10. package/src/lib/package-managers/index.d.ts +1 -1
  11. package/src/lib/package-managers/npm/audit-result.d.ts +2 -2
  12. package/src/lib/package-managers/npm/npm.d.ts +1 -1
  13. package/src/lib/package-managers/npm/outdated-result.d.ts +1 -1
  14. package/src/lib/package-managers/npm/types.d.ts +3 -3
  15. package/src/lib/package-managers/package-managers.d.ts +2 -2
  16. package/src/lib/package-managers/pnpm/audit-result.d.ts +1 -1
  17. package/src/lib/package-managers/pnpm/outdated-result.d.ts +1 -1
  18. package/src/lib/package-managers/pnpm/pnpm.d.ts +1 -1
  19. package/src/lib/package-managers/pnpm/types.d.ts +2 -2
  20. package/src/lib/package-managers/types.d.ts +3 -3
  21. package/src/lib/package-managers/yarn-classic/audit-result.d.ts +1 -1
  22. package/src/lib/package-managers/yarn-classic/constants.d.ts +2 -2
  23. package/src/lib/package-managers/yarn-classic/outdated-result.d.ts +1 -1
  24. package/src/lib/package-managers/yarn-classic/types.d.ts +1 -1
  25. package/src/lib/package-managers/yarn-classic/yarn-classic.d.ts +1 -1
  26. package/src/lib/package-managers/yarn-modern/audit-result.d.ts +1 -1
  27. package/src/lib/package-managers/yarn-modern/outdated-result.d.ts +1 -1
  28. package/src/lib/package-managers/yarn-modern/types.d.ts +2 -2
  29. package/src/lib/package-managers/yarn-modern/yarn-modern.d.ts +1 -1
  30. package/src/lib/runner/audit/constants.d.ts +1 -1
  31. package/src/lib/runner/audit/transform.d.ts +2 -2
  32. package/src/lib/runner/audit/utils.d.ts +1 -1
  33. package/src/lib/runner/index.d.ts +1 -1
  34. package/src/lib/runner/outdated/transform.d.ts +3 -3
  35. package/src/lib/runner/utils.d.ts +2 -2
  36. package/src/lib/utils.d.ts +10 -0
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { IssueSeverity } from '@code-pushup/models';
2
+ import { type IssueSeverity } from '@code-pushup/models';
3
3
  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"]>;
@@ -21,7 +21,7 @@ export type AuditSeverity = Record<PackageAuditLevel, IssueSeverity>;
21
21
  export declare function fillAuditLevelMapping(mapping: Partial<AuditSeverity>): AuditSeverity;
22
22
  export declare const jsPackagesPluginConfigSchema: z.ZodObject<{
23
23
  checks: z.ZodDefault<z.ZodArray<z.ZodEnum<["audit", "outdated"]>, "many">>;
24
- packageManager: z.ZodEnum<["npm", "yarn-classic", "yarn-modern", "pnpm"]>;
24
+ packageManager: z.ZodOptional<z.ZodEnum<["npm", "yarn-classic", "yarn-modern", "pnpm"]>>;
25
25
  dependencyGroups: z.ZodDefault<z.ZodArray<z.ZodEnum<["prod", "dev", "optional"]>, "many">>;
26
26
  auditLevelMapping: z.ZodEffects<z.ZodDefault<z.ZodRecord<z.ZodEnum<["critical", "high", "moderate", "low", "info"]>, z.ZodEnum<["info", "warning", "error"]>>>, AuditSeverity, Partial<Record<"info" | "critical" | "high" | "moderate" | "low", "info" | "warning" | "error">> | undefined>;
27
27
  packageJsonPaths: z.ZodDefault<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
@@ -33,15 +33,15 @@ export declare const jsPackagesPluginConfigSchema: z.ZodObject<{
33
33
  }>]>>;
34
34
  }, "strip", z.ZodTypeAny, {
35
35
  checks: ("audit" | "outdated")[];
36
- packageManager: "npm" | "pnpm" | "yarn-classic" | "yarn-modern";
37
36
  dependencyGroups: ("prod" | "dev" | "optional")[];
38
37
  auditLevelMapping: AuditSeverity;
39
38
  packageJsonPaths: string[] | {
40
39
  autoSearch: true;
41
40
  };
41
+ packageManager?: "npm" | "pnpm" | "yarn-classic" | "yarn-modern" | undefined;
42
42
  }, {
43
- packageManager: "npm" | "pnpm" | "yarn-classic" | "yarn-modern";
44
43
  checks?: ("audit" | "outdated")[] | undefined;
44
+ packageManager?: "npm" | "pnpm" | "yarn-classic" | "yarn-modern" | undefined;
45
45
  dependencyGroups?: ("prod" | "dev" | "optional")[] | undefined;
46
46
  auditLevelMapping?: Partial<Record<"info" | "critical" | "high" | "moderate" | "low", "info" | "warning" | "error">> | undefined;
47
47
  packageJsonPaths?: string[] | {
@@ -49,5 +49,5 @@ export declare const jsPackagesPluginConfigSchema: z.ZodObject<{
49
49
  } | undefined;
50
50
  }>;
51
51
  export type JSPackagesPluginConfig = z.input<typeof jsPackagesPluginConfigSchema>;
52
- export type FinalJSPackagesPluginConfig = z.infer<typeof jsPackagesPluginConfigSchema>;
52
+ export type FinalJSPackagesPluginConfig = Required<z.infer<typeof jsPackagesPluginConfigSchema>>;
53
53
  export {};
@@ -1,6 +1,6 @@
1
- import { IssueSeverity } from '@code-pushup/models';
1
+ import type { IssueSeverity } from '@code-pushup/models';
2
2
  import type { DependencyGroup, PackageAuditLevel } from './config';
3
- import { DependencyGroupLong } from './runner/outdated/types';
3
+ import type { DependencyGroupLong } from './runner/outdated/types';
4
4
  export declare const defaultAuditLevelMapping: Record<PackageAuditLevel, IssueSeverity>;
5
5
  export declare const dependencyGroupToLong: Record<DependencyGroup, DependencyGroupLong>;
6
6
  export declare const dependencyGroupWeights: Record<DependencyGroup, number>;
@@ -1,5 +1,5 @@
1
1
  import type { PluginConfig } from '@code-pushup/models';
2
- import { JSPackagesPluginConfig } from './config';
2
+ import { type JSPackagesPluginConfig } from './config';
3
3
  /**
4
4
  * Instantiates Code PushUp JS packages plugin for core config.
5
5
  *
@@ -16,4 +16,4 @@ import { JSPackagesPluginConfig } from './config';
16
16
  *
17
17
  * @returns Plugin configuration.
18
18
  */
19
- export declare function jsPackagesPlugin(config: JSPackagesPluginConfig): Promise<PluginConfig>;
19
+ export declare function jsPackagesPlugin(config?: JSPackagesPluginConfig): Promise<PluginConfig>;
@@ -0,0 +1,3 @@
1
+ import type { PackageManagerId } from '../config';
2
+ export declare function derivePackageManagerInPackageJson(currentDir?: string): Promise<false | "npm" | "pnpm" | "yarn-classic" | "yarn-modern">;
3
+ export declare function derivePackageManager(currentDir?: string): Promise<PackageManagerId>;
@@ -0,0 +1 @@
1
+ export declare function deriveYarnVersion(): Promise<false | "yarn-classic" | "yarn-modern">;
@@ -1,2 +1,2 @@
1
1
  export { packageManagers } from './package-managers';
2
- export { PackageManager } from './types';
2
+ export type { PackageManager } from './types';
@@ -1,5 +1,5 @@
1
- import { AuditResult } from '../../runner/audit/types';
2
- import { NpmAdvisory, NpmFixInformation, NpmVulnerabilities } from './types';
1
+ import type { AuditResult } from '../../runner/audit/types';
2
+ import type { NpmAdvisory, NpmFixInformation, NpmVulnerabilities } from './types';
3
3
  export declare function npmToAuditResult(output: string): AuditResult;
4
4
  export declare function npmToFixInformation(fixAvailable: boolean | NpmFixInformation): string;
5
5
  export declare function npmToAdvisory(name: string, vulnerabilities: NpmVulnerabilities, prevNodes?: Set<string>): NpmAdvisory | null;
@@ -1,2 +1,2 @@
1
- import { PackageManager } from '../types';
1
+ import type { PackageManager } from '../types';
2
2
  export declare const npmPackageManager: PackageManager;
@@ -1,2 +1,2 @@
1
- import { OutdatedResult } from '../../runner/outdated/types';
1
+ import type { OutdatedResult } from '../../runner/outdated/types';
2
2
  export declare function npmToOutdatedResult(output: string): OutdatedResult;
@@ -1,6 +1,6 @@
1
- import { PackageAuditLevel } from '../../config';
2
- import { AuditSummary } from '../../runner/audit/types';
3
- import { DependencyGroupLong } from '../../runner/outdated/types';
1
+ import type { PackageAuditLevel } from '../../config';
2
+ import type { AuditSummary } from '../../runner/audit/types';
3
+ import type { DependencyGroupLong } from '../../runner/outdated/types';
4
4
  export type NpmAdvisory = {
5
5
  title: string;
6
6
  url: string;
@@ -1,3 +1,3 @@
1
- import { PackageManagerId } from '../config';
2
- import { PackageManager } from './types';
1
+ import type { PackageManagerId } from '../config';
2
+ import type { PackageManager } from './types';
3
3
  export declare const packageManagers: Record<PackageManagerId, PackageManager>;
@@ -1,3 +1,3 @@
1
- import { AuditResult } from '../../runner/audit/types';
1
+ import type { AuditResult } from '../../runner/audit/types';
2
2
  export declare function pnpmToAuditResult(output: string): AuditResult;
3
3
  export declare function pnpmToDirectDependency(path: string): string | true;
@@ -1,2 +1,2 @@
1
- import { OutdatedResult } from '../../runner/outdated/types';
1
+ import type { OutdatedResult } from '../../runner/outdated/types';
2
2
  export declare function pnpmToOutdatedResult(output: string): OutdatedResult;
@@ -1,2 +1,2 @@
1
- import { PackageManager } from '../types';
1
+ import type { PackageManager } from '../types';
2
2
  export declare const pnpmPackageManager: PackageManager;
@@ -1,5 +1,5 @@
1
- import { PackageAuditLevel } from '../../config';
2
- import { DependencyGroupLong } from '../../runner/outdated/types';
1
+ import type { PackageAuditLevel } from '../../config';
2
+ import type { DependencyGroupLong } from '../../runner/outdated/types';
3
3
  export type PnpmAuditAdvisory = {
4
4
  module_name: string;
5
5
  id: number;
@@ -1,7 +1,7 @@
1
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';
2
+ import type { DependencyGroup, PackageManagerId } from '../config';
3
+ import type { AuditResult } from '../runner/audit/types';
4
+ import type { OutdatedResult } from '../runner/outdated/types';
5
5
  export type AuditResults = Partial<Record<DependencyGroup, AuditResult>>;
6
6
  export type PackageManager = {
7
7
  slug: PackageManagerId;
@@ -1,2 +1,2 @@
1
- import { AuditResult } from '../../runner/audit/types';
1
+ import type { AuditResult } from '../../runner/audit/types';
2
2
  export declare function yarnv1ToAuditResult(output: string): AuditResult;
@@ -1,4 +1,4 @@
1
- import { OutdatedDependency } from '../../runner/outdated/types';
2
- import { Yarnv1FieldName } from './types';
1
+ import type { OutdatedDependency } from '../../runner/outdated/types';
2
+ import type { Yarnv1FieldName } from './types';
3
3
  export declare const outdatedtoFieldMapper: Record<keyof OutdatedDependency, Yarnv1FieldName>;
4
4
  export declare const REQUIRED_OUTDATED_FIELDS: Yarnv1FieldName[];
@@ -1,4 +1,4 @@
1
- import { OutdatedDependency, OutdatedResult } from '../../runner/outdated/types';
1
+ import type { OutdatedDependency, OutdatedResult } from '../../runner/outdated/types';
2
2
  export declare function yarnv1ToOutdatedResult(output: string): OutdatedResult;
3
3
  export declare function validateOutdatedFields(head: string[]): boolean;
4
4
  export declare function getOutdatedFieldIndexes(all: string[]): Record<keyof OutdatedDependency, number>;
@@ -1,4 +1,4 @@
1
- import { PackageAuditLevel } from '../../config';
1
+ import type { PackageAuditLevel } from '../../config';
2
2
  export type Yarnv1AuditAdvisory = {
3
3
  type: 'auditAdvisory';
4
4
  data: {
@@ -1,2 +1,2 @@
1
- import { PackageManager } from '../types';
1
+ import type { PackageManager } from '../types';
2
2
  export declare const yarnv1PackageManager: PackageManager;
@@ -1,2 +1,2 @@
1
- import { AuditResult } from '../../runner/audit/types';
1
+ import type { AuditResult } from '../../runner/audit/types';
2
2
  export declare function yarnv2ToAuditResult(output: string): AuditResult;
@@ -1,2 +1,2 @@
1
- import { OutdatedResult } from '../../runner/outdated/types';
1
+ import type { OutdatedResult } from '../../runner/outdated/types';
2
2
  export declare function yarnv2ToOutdatedResult(output: string): OutdatedResult;
@@ -1,5 +1,5 @@
1
- import { PackageAuditLevel } from '../../config';
2
- import { DependencyGroupLong } from '../../runner/outdated/types';
1
+ import type { PackageAuditLevel } from '../../config';
2
+ import type { DependencyGroupLong } from '../../runner/outdated/types';
3
3
  export type Yarnv2AuditAdvisory = {
4
4
  module_name: string;
5
5
  severity: PackageAuditLevel;
@@ -1,2 +1,2 @@
1
- import { PackageManager } from '../types';
1
+ import type { PackageManager } from '../types';
2
2
  export declare const yarnv2PackageManager: PackageManager;
@@ -1,2 +1,2 @@
1
- import { PackageAuditLevel } from '../../config';
1
+ import type { PackageAuditLevel } from '../../config';
2
2
  export declare const auditScoreModifiers: Record<PackageAuditLevel, number>;
@@ -1,6 +1,6 @@
1
1
  import type { AuditOutput, Issue } from '@code-pushup/models';
2
- import { AuditSeverity, DependencyGroup, PackageManagerId } from '../../config';
3
- import { AuditResult, AuditSummary, Vulnerability } from './types';
2
+ import { type AuditSeverity, type DependencyGroup, type PackageManagerId } from '../../config';
3
+ import type { AuditResult, AuditSummary, Vulnerability } from './types';
4
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;
@@ -1,2 +1,2 @@
1
- import { PackageAuditLevel } from '../../config';
1
+ import type { PackageAuditLevel } from '../../config';
2
2
  export declare function getVulnerabilitiesTotal(summary: Record<PackageAuditLevel, number>): number;
@@ -1,4 +1,4 @@
1
1
  import type { RunnerConfig } from '@code-pushup/models';
2
- import { FinalJSPackagesPluginConfig } from '../config';
2
+ import { type FinalJSPackagesPluginConfig } from '../config';
3
3
  export declare function createRunnerConfig(scriptPath: string, config: FinalJSPackagesPluginConfig): Promise<RunnerConfig>;
4
4
  export declare function executeRunner(): Promise<void>;
@@ -1,7 +1,7 @@
1
- import { ReleaseType } from 'semver';
1
+ import { type ReleaseType } from 'semver';
2
2
  import type { AuditOutput, Issue } from '@code-pushup/models';
3
- import { DependencyGroup, PackageManagerId } from '../../config';
4
- import { OutdatedResult } from './types';
3
+ import type { DependencyGroup, PackageManagerId } from '../../config';
4
+ import type { OutdatedResult } from './types';
5
5
  export declare function outdatedResultToAuditOutput(result: OutdatedResult, packageManager: PackageManagerId, depGroup: DependencyGroup, totalDeps: number): AuditOutput;
6
6
  export declare function calculateOutdatedScore(majorOutdated: number, totalDeps: number): number;
7
7
  export declare function outdatedToDisplayValue(stats: Record<ReleaseType, number>): string;
@@ -1,5 +1,5 @@
1
- import { AuditResult, Vulnerability } from './audit/types';
2
- import { DependencyTotals } from './outdated/types';
1
+ import type { AuditResult, Vulnerability } from './audit/types';
2
+ import { type DependencyTotals } from './outdated/types';
3
3
  export declare function filterAuditResult(result: AuditResult, key: keyof Vulnerability, referenceResult?: AuditResult): AuditResult;
4
4
  export declare function findAllPackageJson(): Promise<string[]>;
5
5
  export declare function getTotalDependencies(packageJsonPaths: string[]): Promise<DependencyTotals>;
@@ -0,0 +1,10 @@
1
+ import { type JSPackagesPluginConfig } from './config';
2
+ export declare function normalizeConfig(config?: JSPackagesPluginConfig): Promise<{
3
+ packageManager: import("./package-managers").PackageManager;
4
+ checks: ("audit" | "outdated")[];
5
+ depGroups: ("prod" | "dev" | "optional")[];
6
+ auditLevelMapping: import("./config").AuditSeverity;
7
+ packageJsonPaths: string[] | {
8
+ autoSearch: true;
9
+ };
10
+ }>;