@code-pushup/js-packages-plugin 0.49.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.
- package/README.md +2 -2
- package/bin.js +38 -26
- package/index.js +179 -21
- package/package.json +5 -31
- package/src/lib/config.d.ts +5 -5
- package/src/lib/constants.d.ts +2 -2
- package/src/lib/js-packages-plugin.d.ts +2 -2
- package/src/lib/package-managers/derive-package-manager.d.ts +3 -0
- package/src/lib/package-managers/derive-yarn.d.ts +1 -0
- package/src/lib/package-managers/index.d.ts +1 -1
- package/src/lib/package-managers/npm/audit-result.d.ts +2 -2
- package/src/lib/package-managers/npm/npm.d.ts +1 -1
- package/src/lib/package-managers/npm/outdated-result.d.ts +1 -1
- package/src/lib/package-managers/npm/types.d.ts +3 -3
- package/src/lib/package-managers/package-managers.d.ts +2 -2
- package/src/lib/package-managers/pnpm/audit-result.d.ts +1 -1
- package/src/lib/package-managers/pnpm/outdated-result.d.ts +1 -1
- package/src/lib/package-managers/pnpm/pnpm.d.ts +1 -1
- package/src/lib/package-managers/pnpm/types.d.ts +2 -2
- package/src/lib/package-managers/types.d.ts +3 -3
- package/src/lib/package-managers/yarn-classic/audit-result.d.ts +1 -1
- package/src/lib/package-managers/yarn-classic/constants.d.ts +2 -2
- package/src/lib/package-managers/yarn-classic/outdated-result.d.ts +1 -1
- package/src/lib/package-managers/yarn-classic/types.d.ts +1 -1
- package/src/lib/package-managers/yarn-classic/yarn-classic.d.ts +1 -1
- package/src/lib/package-managers/yarn-modern/audit-result.d.ts +1 -1
- package/src/lib/package-managers/yarn-modern/outdated-result.d.ts +1 -1
- package/src/lib/package-managers/yarn-modern/types.d.ts +2 -2
- package/src/lib/package-managers/yarn-modern/yarn-modern.d.ts +1 -1
- package/src/lib/runner/audit/constants.d.ts +1 -1
- package/src/lib/runner/audit/transform.d.ts +2 -2
- package/src/lib/runner/audit/utils.d.ts +1 -1
- package/src/lib/runner/index.d.ts +1 -1
- package/src/lib/runner/outdated/transform.d.ts +3 -3
- package/src/lib/runner/utils.d.ts +2 -2
- package/src/lib/utils.d.ts +10 -0
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ It supports the following package managers:
|
|
|
45
45
|
// ...
|
|
46
46
|
plugins: [
|
|
47
47
|
// ...
|
|
48
|
-
await jsPackagesPlugin({ packageManager: 'npm' }
|
|
48
|
+
await jsPackagesPlugin(), // the package manager is automatically derived from your file system. Use { packageManager: 'npm' } to configure it.
|
|
49
49
|
],
|
|
50
50
|
};
|
|
51
51
|
```
|
|
@@ -59,7 +59,7 @@ It supports the following package managers:
|
|
|
59
59
|
// ...
|
|
60
60
|
plugins: [
|
|
61
61
|
// ...
|
|
62
|
-
await jsPackagesPlugin({ packageManager:
|
|
62
|
+
await jsPackagesPlugin({ packageManager: 'yarn-classic', checks: ['audit'], dependencyGroups: ['prod'] }),
|
|
63
63
|
],
|
|
64
64
|
};
|
|
65
65
|
```
|
package/bin.js
CHANGED
|
@@ -670,6 +670,8 @@ var auditResultSchema = scorableWithPluginMetaSchema.merge(
|
|
|
670
670
|
);
|
|
671
671
|
var reportsDiffSchema = z15.object({
|
|
672
672
|
commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
|
|
673
|
+
portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
|
|
674
|
+
label: z15.string().optional().describe("Label (e.g. project name)"),
|
|
673
675
|
categories: makeArraysComparisonSchema(
|
|
674
676
|
categoryDiffSchema,
|
|
675
677
|
categoryResultSchema,
|
|
@@ -698,7 +700,9 @@ var reportsDiffSchema = z15.object({
|
|
|
698
700
|
);
|
|
699
701
|
|
|
700
702
|
// packages/utils/src/lib/execute-process.ts
|
|
701
|
-
import {
|
|
703
|
+
import {
|
|
704
|
+
spawn
|
|
705
|
+
} from "node:child_process";
|
|
702
706
|
|
|
703
707
|
// packages/utils/src/lib/reports/utils.ts
|
|
704
708
|
import ansis from "ansis";
|
|
@@ -725,25 +729,29 @@ var ProcessError = class extends Error {
|
|
|
725
729
|
}
|
|
726
730
|
};
|
|
727
731
|
function executeProcess(cfg) {
|
|
728
|
-
const {
|
|
729
|
-
const { onStdout, onError, onComplete } = observer ?? {};
|
|
732
|
+
const { command, args, observer, ignoreExitCode = false, ...options } = cfg;
|
|
733
|
+
const { onStdout, onStderr, onError, onComplete } = observer ?? {};
|
|
730
734
|
const date = (/* @__PURE__ */ new Date()).toISOString();
|
|
731
735
|
const start = performance.now();
|
|
732
736
|
return new Promise((resolve, reject) => {
|
|
733
|
-
const
|
|
737
|
+
const spawnedProcess = spawn(command, args ?? [], {
|
|
738
|
+
shell: true,
|
|
739
|
+
...options
|
|
740
|
+
});
|
|
734
741
|
let stdout = "";
|
|
735
742
|
let stderr = "";
|
|
736
|
-
|
|
743
|
+
spawnedProcess.stdout.on("data", (data) => {
|
|
737
744
|
stdout += String(data);
|
|
738
|
-
onStdout?.(String(data));
|
|
745
|
+
onStdout?.(String(data), spawnedProcess);
|
|
739
746
|
});
|
|
740
|
-
|
|
747
|
+
spawnedProcess.stderr.on("data", (data) => {
|
|
741
748
|
stderr += String(data);
|
|
749
|
+
onStderr?.(String(data), spawnedProcess);
|
|
742
750
|
});
|
|
743
|
-
|
|
751
|
+
spawnedProcess.on("error", (err) => {
|
|
744
752
|
stderr += err.toString();
|
|
745
753
|
});
|
|
746
|
-
|
|
754
|
+
spawnedProcess.on("close", (code2) => {
|
|
747
755
|
const timings = { date, duration: calcDuration(start) };
|
|
748
756
|
if (code2 === 0 || ignoreExitCode) {
|
|
749
757
|
onComplete?.();
|
|
@@ -893,17 +901,23 @@ import { MultiProgressBars } from "multi-progress-bars";
|
|
|
893
901
|
import { MarkdownDocument as MarkdownDocument3, md as md4 } from "build-md";
|
|
894
902
|
|
|
895
903
|
// packages/utils/src/lib/reports/formatting.ts
|
|
896
|
-
import {
|
|
904
|
+
import {
|
|
905
|
+
MarkdownDocument,
|
|
906
|
+
md as md2
|
|
907
|
+
} from "build-md";
|
|
897
908
|
|
|
898
909
|
// packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
|
|
899
910
|
import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
|
|
900
911
|
|
|
901
912
|
// packages/utils/src/lib/reports/generate-md-reports-diff.ts
|
|
902
913
|
import {
|
|
903
|
-
MarkdownDocument as
|
|
904
|
-
md as
|
|
914
|
+
MarkdownDocument as MarkdownDocument5,
|
|
915
|
+
md as md6
|
|
905
916
|
} from "build-md";
|
|
906
917
|
|
|
918
|
+
// packages/utils/src/lib/reports/generate-md-reports-diff-utils.ts
|
|
919
|
+
import { MarkdownDocument as MarkdownDocument4, md as md5 } from "build-md";
|
|
920
|
+
|
|
907
921
|
// packages/utils/src/lib/reports/log-stdout-summary.ts
|
|
908
922
|
import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
|
|
909
923
|
|
|
@@ -961,9 +975,7 @@ var jsPackagesPluginConfigSchema = z16.object({
|
|
|
961
975
|
checks: z16.array(packageCommandSchema, {
|
|
962
976
|
description: "Package manager commands to be run. Defaults to both audit and outdated."
|
|
963
977
|
}).min(1).default(["audit", "outdated"]),
|
|
964
|
-
packageManager: packageManagerIdSchema.describe(
|
|
965
|
-
"Package manager to be used."
|
|
966
|
-
),
|
|
978
|
+
packageManager: packageManagerIdSchema.describe("Package manager to be used.").optional(),
|
|
967
979
|
dependencyGroups: z16.array(dependencyGroupSchema).min(1).default(["prod", "dev"]),
|
|
968
980
|
auditLevelMapping: z16.record(packageAuditLevelSchema, issueSeveritySchema, {
|
|
969
981
|
description: "Mapping of audit levels to issue severity. Custom mapping or overrides may be entered manually, otherwise has a default preset."
|
|
@@ -1493,7 +1505,7 @@ var packageManagers = {
|
|
|
1493
1505
|
};
|
|
1494
1506
|
|
|
1495
1507
|
// packages/plugin-js-packages/src/lib/runner/audit/transform.ts
|
|
1496
|
-
import { md as
|
|
1508
|
+
import { md as md7 } from "build-md";
|
|
1497
1509
|
|
|
1498
1510
|
// packages/plugin-js-packages/src/lib/runner/audit/constants.ts
|
|
1499
1511
|
var auditScoreModifiers = {
|
|
@@ -1545,16 +1557,16 @@ function vulnerabilitiesToIssues(vulnerabilities, auditLevelMapping) {
|
|
|
1545
1557
|
return [];
|
|
1546
1558
|
}
|
|
1547
1559
|
return vulnerabilities.map((detail) => {
|
|
1548
|
-
const versionRange = detail.versionRange === "*" ?
|
|
1549
|
-
const directDependency = typeof detail.directDependency === "string" && detail.directDependency !== "" ?
|
|
1550
|
-
const depHierarchy = directDependency ?
|
|
1551
|
-
const vulnerabilitySummary =
|
|
1560
|
+
const versionRange = detail.versionRange === "*" ? md7`${md7.bold("all")} versions` : md7`versions ${md7.bold(detail.versionRange)}`;
|
|
1561
|
+
const directDependency = typeof detail.directDependency === "string" && detail.directDependency !== "" ? md7.code(detail.directDependency) : "";
|
|
1562
|
+
const depHierarchy = directDependency ? md7`${directDependency}'s dependency ${md7.code(detail.name)}` : md7`${md7.code(detail.name)} dependency`;
|
|
1563
|
+
const vulnerabilitySummary = md7`has a ${md7.bold(
|
|
1552
1564
|
detail.severity
|
|
1553
1565
|
)} vulnerability in ${versionRange}.`;
|
|
1554
1566
|
const fixInfo = detail.fixInformation ? ` ${detail.fixInformation}` : "";
|
|
1555
|
-
const additionalInfo = detail.title != null && detail.url != null ?
|
|
1567
|
+
const additionalInfo = detail.title != null && detail.url != null ? md7` More information: ${md7.link(detail.url, detail.title)}` : "";
|
|
1556
1568
|
return {
|
|
1557
|
-
message:
|
|
1569
|
+
message: md7`${depHierarchy} ${vulnerabilitySummary}${fixInfo}${additionalInfo}`.toString(),
|
|
1558
1570
|
severity: auditLevelMapping[detail.severity]
|
|
1559
1571
|
};
|
|
1560
1572
|
});
|
|
@@ -1571,7 +1583,7 @@ var PLUGIN_CONFIG_PATH = join2(
|
|
|
1571
1583
|
);
|
|
1572
1584
|
|
|
1573
1585
|
// packages/plugin-js-packages/src/lib/runner/outdated/transform.ts
|
|
1574
|
-
import { md as
|
|
1586
|
+
import { md as md8 } from "build-md";
|
|
1575
1587
|
import { clean, diff, neq } from "semver";
|
|
1576
1588
|
|
|
1577
1589
|
// packages/plugin-js-packages/src/lib/runner/outdated/constants.ts
|
|
@@ -1642,11 +1654,11 @@ function outdatedToIssues(dependencies) {
|
|
|
1642
1654
|
return dependencies.map((dep) => {
|
|
1643
1655
|
const { name, current, latest, url } = dep;
|
|
1644
1656
|
const outdatedLevel = diff(current, latest);
|
|
1645
|
-
const packageReference = url == null ?
|
|
1657
|
+
const packageReference = url == null ? md8.code(name) : md8.link(url, md8.code(name));
|
|
1646
1658
|
return {
|
|
1647
|
-
message:
|
|
1659
|
+
message: md8`Package ${packageReference} requires a ${md8.bold(
|
|
1648
1660
|
outdatedLevel
|
|
1649
|
-
)} update from ${
|
|
1661
|
+
)} update from ${md8.bold(current)} to ${md8.bold(latest)}.`.toString(),
|
|
1650
1662
|
severity: outdatedSeverity[outdatedLevel]
|
|
1651
1663
|
};
|
|
1652
1664
|
});
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// packages/plugin-js-packages/src/lib/js-packages-plugin.ts
|
|
2
|
-
import { dirname as dirname2, join as
|
|
2
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
5
|
// packages/plugin-js-packages/package.json
|
|
6
6
|
var name = "@code-pushup/js-packages-plugin";
|
|
7
|
-
var version = "0.
|
|
7
|
+
var version = "0.50.0";
|
|
8
8
|
|
|
9
9
|
// packages/plugin-js-packages/src/lib/config.ts
|
|
10
10
|
import { z as z16 } from "zod";
|
|
@@ -677,6 +677,8 @@ var auditResultSchema = scorableWithPluginMetaSchema.merge(
|
|
|
677
677
|
);
|
|
678
678
|
var reportsDiffSchema = z15.object({
|
|
679
679
|
commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
|
|
680
|
+
portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
|
|
681
|
+
label: z15.string().optional().describe("Label (e.g. project name)"),
|
|
680
682
|
categories: makeArraysComparisonSchema(
|
|
681
683
|
categoryDiffSchema,
|
|
682
684
|
categoryResultSchema,
|
|
@@ -765,9 +767,7 @@ var jsPackagesPluginConfigSchema = z16.object({
|
|
|
765
767
|
checks: z16.array(packageCommandSchema, {
|
|
766
768
|
description: "Package manager commands to be run. Defaults to both audit and outdated."
|
|
767
769
|
}).min(1).default(["audit", "outdated"]),
|
|
768
|
-
packageManager: packageManagerIdSchema.describe(
|
|
769
|
-
"Package manager to be used."
|
|
770
|
-
),
|
|
770
|
+
packageManager: packageManagerIdSchema.describe("Package manager to be used.").optional(),
|
|
771
771
|
dependencyGroups: z16.array(dependencyGroupSchema).min(1).default(["prod", "dev"]),
|
|
772
772
|
auditLevelMapping: z16.record(packageAuditLevelSchema, issueSeveritySchema, {
|
|
773
773
|
description: "Mapping of audit levels to issue severity. Custom mapping or overrides may be entered manually, otherwise has a default preset."
|
|
@@ -775,6 +775,11 @@ var jsPackagesPluginConfigSchema = z16.object({
|
|
|
775
775
|
packageJsonPaths: packageJsonPathSchema
|
|
776
776
|
});
|
|
777
777
|
|
|
778
|
+
// packages/utils/src/lib/execute-process.ts
|
|
779
|
+
import {
|
|
780
|
+
spawn
|
|
781
|
+
} from "node:child_process";
|
|
782
|
+
|
|
778
783
|
// packages/utils/src/lib/reports/utils.ts
|
|
779
784
|
import ansis from "ansis";
|
|
780
785
|
import { md } from "build-md";
|
|
@@ -782,6 +787,60 @@ import { md } from "build-md";
|
|
|
782
787
|
// packages/utils/src/lib/reports/constants.ts
|
|
783
788
|
var TERMINAL_WIDTH = 80;
|
|
784
789
|
|
|
790
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
791
|
+
function calcDuration(start, stop) {
|
|
792
|
+
return Math.round((stop ?? performance.now()) - start);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// packages/utils/src/lib/execute-process.ts
|
|
796
|
+
var ProcessError = class extends Error {
|
|
797
|
+
code;
|
|
798
|
+
stderr;
|
|
799
|
+
stdout;
|
|
800
|
+
constructor(result) {
|
|
801
|
+
super(result.stderr);
|
|
802
|
+
this.code = result.code;
|
|
803
|
+
this.stderr = result.stderr;
|
|
804
|
+
this.stdout = result.stdout;
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
function executeProcess(cfg) {
|
|
808
|
+
const { command, args, observer, ignoreExitCode = false, ...options } = cfg;
|
|
809
|
+
const { onStdout, onStderr, onError, onComplete } = observer ?? {};
|
|
810
|
+
const date = (/* @__PURE__ */ new Date()).toISOString();
|
|
811
|
+
const start = performance.now();
|
|
812
|
+
return new Promise((resolve, reject) => {
|
|
813
|
+
const spawnedProcess = spawn(command, args ?? [], {
|
|
814
|
+
shell: true,
|
|
815
|
+
...options
|
|
816
|
+
});
|
|
817
|
+
let stdout = "";
|
|
818
|
+
let stderr = "";
|
|
819
|
+
spawnedProcess.stdout.on("data", (data) => {
|
|
820
|
+
stdout += String(data);
|
|
821
|
+
onStdout?.(String(data), spawnedProcess);
|
|
822
|
+
});
|
|
823
|
+
spawnedProcess.stderr.on("data", (data) => {
|
|
824
|
+
stderr += String(data);
|
|
825
|
+
onStderr?.(String(data), spawnedProcess);
|
|
826
|
+
});
|
|
827
|
+
spawnedProcess.on("error", (err) => {
|
|
828
|
+
stderr += err.toString();
|
|
829
|
+
});
|
|
830
|
+
spawnedProcess.on("close", (code2) => {
|
|
831
|
+
const timings = { date, duration: calcDuration(start) };
|
|
832
|
+
if (code2 === 0 || ignoreExitCode) {
|
|
833
|
+
onComplete?.();
|
|
834
|
+
resolve({ code: code2, stdout, stderr, ...timings });
|
|
835
|
+
} else {
|
|
836
|
+
const errorMsg = new ProcessError({ code: code2, stdout, stderr, ...timings });
|
|
837
|
+
onError?.(errorMsg);
|
|
838
|
+
reject(errorMsg);
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
|
|
785
844
|
// packages/utils/src/lib/file-system.ts
|
|
786
845
|
import { bold, gray } from "ansis";
|
|
787
846
|
import { bundleRequire } from "bundle-require";
|
|
@@ -816,6 +875,14 @@ function logListItem(args) {
|
|
|
816
875
|
}
|
|
817
876
|
|
|
818
877
|
// packages/utils/src/lib/file-system.ts
|
|
878
|
+
async function fileExists(path) {
|
|
879
|
+
try {
|
|
880
|
+
const stats = await stat(path);
|
|
881
|
+
return stats.isFile();
|
|
882
|
+
} catch {
|
|
883
|
+
return false;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
819
886
|
async function ensureDirectoryExists(baseDir) {
|
|
820
887
|
try {
|
|
821
888
|
await mkdir(baseDir, { recursive: true });
|
|
@@ -870,17 +937,23 @@ import { MultiProgressBars } from "multi-progress-bars";
|
|
|
870
937
|
import { MarkdownDocument as MarkdownDocument3, md as md4 } from "build-md";
|
|
871
938
|
|
|
872
939
|
// packages/utils/src/lib/reports/formatting.ts
|
|
873
|
-
import {
|
|
940
|
+
import {
|
|
941
|
+
MarkdownDocument,
|
|
942
|
+
md as md2
|
|
943
|
+
} from "build-md";
|
|
874
944
|
|
|
875
945
|
// packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
|
|
876
946
|
import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
|
|
877
947
|
|
|
878
948
|
// packages/utils/src/lib/reports/generate-md-reports-diff.ts
|
|
879
949
|
import {
|
|
880
|
-
MarkdownDocument as
|
|
881
|
-
md as
|
|
950
|
+
MarkdownDocument as MarkdownDocument5,
|
|
951
|
+
md as md6
|
|
882
952
|
} from "build-md";
|
|
883
953
|
|
|
954
|
+
// packages/utils/src/lib/reports/generate-md-reports-diff-utils.ts
|
|
955
|
+
import { MarkdownDocument as MarkdownDocument4, md as md5 } from "build-md";
|
|
956
|
+
|
|
884
957
|
// packages/utils/src/lib/reports/log-stdout-summary.ts
|
|
885
958
|
import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
|
|
886
959
|
|
|
@@ -1369,7 +1442,7 @@ import { writeFile } from "node:fs/promises";
|
|
|
1369
1442
|
import { dirname } from "node:path";
|
|
1370
1443
|
|
|
1371
1444
|
// packages/plugin-js-packages/src/lib/runner/audit/transform.ts
|
|
1372
|
-
import { md as
|
|
1445
|
+
import { md as md7 } from "build-md";
|
|
1373
1446
|
|
|
1374
1447
|
// packages/plugin-js-packages/src/lib/runner/constants.ts
|
|
1375
1448
|
import { join as join2 } from "node:path";
|
|
@@ -1382,7 +1455,7 @@ var PLUGIN_CONFIG_PATH = join2(
|
|
|
1382
1455
|
);
|
|
1383
1456
|
|
|
1384
1457
|
// packages/plugin-js-packages/src/lib/runner/outdated/transform.ts
|
|
1385
|
-
import { md as
|
|
1458
|
+
import { md as md8 } from "build-md";
|
|
1386
1459
|
import { clean, diff, neq } from "semver";
|
|
1387
1460
|
|
|
1388
1461
|
// packages/plugin-js-packages/src/lib/runner/outdated/constants.ts
|
|
@@ -1408,28 +1481,113 @@ async function createRunnerConfig(scriptPath, config) {
|
|
|
1408
1481
|
};
|
|
1409
1482
|
}
|
|
1410
1483
|
|
|
1484
|
+
// packages/plugin-js-packages/src/lib/package-managers/derive-package-manager.ts
|
|
1485
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
1486
|
+
import { join as join3 } from "node:path";
|
|
1487
|
+
|
|
1488
|
+
// packages/plugin-js-packages/src/lib/package-managers/derive-yarn.ts
|
|
1489
|
+
async function deriveYarnVersion() {
|
|
1490
|
+
const { stdout } = await executeProcess({
|
|
1491
|
+
command: "yarn",
|
|
1492
|
+
args: ["-v"]
|
|
1493
|
+
});
|
|
1494
|
+
const yarnVersion = Number.parseInt(stdout.toString().trim().at(0) ?? "", 10);
|
|
1495
|
+
if (yarnVersion >= 2) {
|
|
1496
|
+
return "yarn-modern";
|
|
1497
|
+
} else if (yarnVersion === 1) {
|
|
1498
|
+
return "yarn-classic";
|
|
1499
|
+
}
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
// packages/plugin-js-packages/src/lib/package-managers/derive-package-manager.ts
|
|
1504
|
+
async function derivePackageManagerInPackageJson(currentDir = process.cwd()) {
|
|
1505
|
+
if (await fileExists(join3(currentDir, "package.json"))) {
|
|
1506
|
+
const content = JSON.parse(
|
|
1507
|
+
(await readFile2(join3("package.json"))).toString()
|
|
1508
|
+
);
|
|
1509
|
+
const { packageManager: packageManagerData = "" } = content;
|
|
1510
|
+
const [manager = "", version2 = ""] = packageManagerData.split("@");
|
|
1511
|
+
if (manager === "npm") {
|
|
1512
|
+
return manager;
|
|
1513
|
+
}
|
|
1514
|
+
if (manager === "pnpm") {
|
|
1515
|
+
return manager;
|
|
1516
|
+
}
|
|
1517
|
+
if (manager === "yarn") {
|
|
1518
|
+
const majorVersion = Number(version2.split(".")[0]);
|
|
1519
|
+
return majorVersion > 1 ? "yarn-modern" : "yarn-classic";
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
return false;
|
|
1523
|
+
}
|
|
1524
|
+
async function derivePackageManager(currentDir = process.cwd()) {
|
|
1525
|
+
const pkgManagerFromPackageJson = await derivePackageManagerInPackageJson(
|
|
1526
|
+
currentDir
|
|
1527
|
+
);
|
|
1528
|
+
if (pkgManagerFromPackageJson) {
|
|
1529
|
+
return pkgManagerFromPackageJson;
|
|
1530
|
+
}
|
|
1531
|
+
if (await fileExists(join3(currentDir, "package-lock.json"))) {
|
|
1532
|
+
return "npm";
|
|
1533
|
+
} else if (await fileExists(join3(currentDir, "pnpm-lock.yaml"))) {
|
|
1534
|
+
return "pnpm";
|
|
1535
|
+
} else if (await fileExists(join3(currentDir, "yarn.lock"))) {
|
|
1536
|
+
const yarnVersion = await deriveYarnVersion();
|
|
1537
|
+
if (yarnVersion) {
|
|
1538
|
+
return yarnVersion;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
throw new Error(
|
|
1542
|
+
"Could not detect package manager. Please provide it in the js-packages plugin config."
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
// packages/plugin-js-packages/src/lib/utils.ts
|
|
1547
|
+
async function normalizeConfig(config) {
|
|
1548
|
+
const jsPackagesPluginConfig = jsPackagesPluginConfigSchema.parse(
|
|
1549
|
+
config ?? {}
|
|
1550
|
+
);
|
|
1551
|
+
const {
|
|
1552
|
+
packageManager,
|
|
1553
|
+
dependencyGroups: dependencyGroupsCfg = [],
|
|
1554
|
+
checks: checksCfg = [],
|
|
1555
|
+
...jsPackagesPluginConfigRest
|
|
1556
|
+
} = jsPackagesPluginConfig;
|
|
1557
|
+
const checks = [...new Set(checksCfg)];
|
|
1558
|
+
const depGroups = [...new Set(dependencyGroupsCfg)];
|
|
1559
|
+
const pm = packageManagers[packageManager ?? await derivePackageManager()];
|
|
1560
|
+
return {
|
|
1561
|
+
...jsPackagesPluginConfigRest,
|
|
1562
|
+
packageManager: pm,
|
|
1563
|
+
checks,
|
|
1564
|
+
depGroups
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1411
1568
|
// packages/plugin-js-packages/src/lib/js-packages-plugin.ts
|
|
1412
1569
|
async function jsPackagesPlugin(config) {
|
|
1413
|
-
const
|
|
1414
|
-
const
|
|
1415
|
-
const depGroups = [...new Set(jsPackagesPluginConfig.dependencyGroups)];
|
|
1416
|
-
const id = jsPackagesPluginConfig.packageManager;
|
|
1417
|
-
const pm = packageManagers[id];
|
|
1418
|
-
const runnerScriptPath = join3(
|
|
1570
|
+
const { packageManager, checks, depGroups, ...jsPackagesPluginConfigRest } = await normalizeConfig(config);
|
|
1571
|
+
const runnerScriptPath = join4(
|
|
1419
1572
|
fileURLToPath(dirname2(import.meta.url)),
|
|
1420
1573
|
"bin.js"
|
|
1421
1574
|
);
|
|
1422
1575
|
return {
|
|
1423
1576
|
slug: "js-packages",
|
|
1424
1577
|
title: "JS Packages",
|
|
1425
|
-
icon:
|
|
1578
|
+
icon: packageManager.icon,
|
|
1426
1579
|
description: "This plugin runs audit to uncover vulnerabilities and lists outdated dependencies. It supports npm, yarn classic, yarn modern, and pnpm package managers.",
|
|
1427
|
-
docsUrl:
|
|
1580
|
+
docsUrl: packageManager.docs.homepage,
|
|
1428
1581
|
packageName: name,
|
|
1429
1582
|
version,
|
|
1430
|
-
audits: createAudits(
|
|
1431
|
-
groups: createGroups(
|
|
1432
|
-
runner: await createRunnerConfig(runnerScriptPath,
|
|
1583
|
+
audits: createAudits(packageManager.slug, checks, depGroups),
|
|
1584
|
+
groups: createGroups(packageManager.slug, checks, depGroups),
|
|
1585
|
+
runner: await createRunnerConfig(runnerScriptPath, {
|
|
1586
|
+
...jsPackagesPluginConfigRest,
|
|
1587
|
+
checks,
|
|
1588
|
+
packageManager: packageManager.slug,
|
|
1589
|
+
dependencyGroups: depGroups
|
|
1590
|
+
})
|
|
1433
1591
|
};
|
|
1434
1592
|
}
|
|
1435
1593
|
function createGroups(id, checks, depGroups) {
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/js-packages-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
|
+
"description": "Code PushUp plugin for JavaScript packages 🛡️",
|
|
4
5
|
"dependencies": {
|
|
5
|
-
"@code-pushup/models": "0.
|
|
6
|
-
"@code-pushup/utils": "0.
|
|
6
|
+
"@code-pushup/models": "0.50.0",
|
|
7
|
+
"@code-pushup/utils": "0.50.0",
|
|
7
8
|
"build-md": "^0.4.1",
|
|
8
9
|
"semver": "^7.6.0",
|
|
9
10
|
"zod": "^3.22.4"
|
|
10
11
|
},
|
|
11
12
|
"license": "MIT",
|
|
12
|
-
"homepage": "https://github.com/code-pushup/cli#readme",
|
|
13
|
+
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-js-packages#readme",
|
|
13
14
|
"bugs": {
|
|
14
15
|
"url": "https://github.com/code-pushup/cli/issues"
|
|
15
16
|
},
|
|
@@ -18,33 +19,6 @@
|
|
|
18
19
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
19
20
|
"directory": "packages/plugin-js-packages"
|
|
20
21
|
},
|
|
21
|
-
"contributors": [
|
|
22
|
-
{
|
|
23
|
-
"name": "Igor Katsuba",
|
|
24
|
-
"email": "igor@katsuba.dev",
|
|
25
|
-
"url": "https://katsuba.dev"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"name": "Kateřina Pilátová",
|
|
29
|
-
"email": "katerina.pilatova@flowup.cz",
|
|
30
|
-
"url": "https://github.com/Tlacenka"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "Matěj Chalk",
|
|
34
|
-
"email": "matej.chalk@flowup.cz",
|
|
35
|
-
"url": "https://github.com/matejchalk"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"name": "Michael Hladky",
|
|
39
|
-
"email": "michael.hladky@push-based.io",
|
|
40
|
-
"url": "https://push-based.io"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"name": "Michael Seredenko",
|
|
44
|
-
"email": "misha.seredenko@push-based.io",
|
|
45
|
-
"url": "https://github.com/MishaSeredenkoPushBased"
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
22
|
"type": "module",
|
|
49
23
|
"main": "./index.js",
|
|
50
24
|
"types": "./src/index.d.ts"
|
package/src/lib/config.d.ts
CHANGED
|
@@ -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 {};
|
package/src/lib/constants.d.ts
CHANGED
|
@@ -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
|
|
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,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,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
|
+
}>;
|