@code-pushup/js-packages-plugin 0.53.1 → 0.55.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/bin.js +25 -27
- package/index.js +19 -26
- package/package.json +3 -3
- package/src/lib/runner/outdated/transform.d.ts +2 -3
package/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/plugin-js-packages/src/lib/runner/index.ts
|
|
2
2
|
import { writeFile } from "node:fs/promises";
|
|
3
|
-
import { dirname } from "node:path";
|
|
3
|
+
import { dirname as dirname2 } from "node:path";
|
|
4
4
|
|
|
5
5
|
// packages/models/src/lib/implementation/schemas.ts
|
|
6
6
|
import { MATERIAL_ICONS } from "vscode-material-icons";
|
|
@@ -33,7 +33,7 @@ function exists(value) {
|
|
|
33
33
|
return value != null;
|
|
34
34
|
}
|
|
35
35
|
function getMissingRefsForCategories(categories, plugins) {
|
|
36
|
-
if (categories.length === 0) {
|
|
36
|
+
if (!categories || categories.length === 0) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
const auditRefsFromCategory = categories.flatMap(
|
|
@@ -110,7 +110,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
|
110
110
|
message: `The filename has to be valid`
|
|
111
111
|
}).min(1, { message: "file name is invalid" });
|
|
112
112
|
var positiveIntSchema = z.number().int().positive();
|
|
113
|
-
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
114
113
|
var nonnegativeNumberSchema = z.number().nonnegative();
|
|
115
114
|
function packageVersionSchema(options) {
|
|
116
115
|
const { versionDescription = "NPM version of the package", required } = options ?? {};
|
|
@@ -533,12 +532,9 @@ var unrefinedCoreConfigSchema = z14.object({
|
|
|
533
532
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
534
533
|
function refineCoreConfig(schema) {
|
|
535
534
|
return schema.refine(
|
|
536
|
-
(
|
|
537
|
-
(
|
|
538
|
-
message: missingRefsForCategoriesErrorMsg(
|
|
539
|
-
coreCfg.categories ?? [],
|
|
540
|
-
coreCfg.plugins
|
|
541
|
-
)
|
|
535
|
+
({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
|
|
536
|
+
({ categories, plugins }) => ({
|
|
537
|
+
message: missingRefsForCategoriesErrorMsg(categories, plugins)
|
|
542
538
|
})
|
|
543
539
|
);
|
|
544
540
|
}
|
|
@@ -590,19 +586,16 @@ var reportSchema = packageVersionSchema({
|
|
|
590
586
|
).merge(
|
|
591
587
|
z15.object(
|
|
592
588
|
{
|
|
593
|
-
categories: z15.array(categoryConfigSchema),
|
|
594
589
|
plugins: z15.array(pluginReportSchema).min(1),
|
|
590
|
+
categories: z15.array(categoryConfigSchema).optional(),
|
|
595
591
|
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
596
592
|
},
|
|
597
593
|
{ description: "Collect output data" }
|
|
598
594
|
)
|
|
599
595
|
).refine(
|
|
600
|
-
(
|
|
601
|
-
(
|
|
602
|
-
message: missingRefsForCategoriesErrorMsg(
|
|
603
|
-
report.categories,
|
|
604
|
-
report.plugins
|
|
605
|
-
)
|
|
596
|
+
({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
|
|
597
|
+
({ categories, plugins }) => ({
|
|
598
|
+
message: missingRefsForCategoriesErrorMsg(categories, plugins)
|
|
606
599
|
})
|
|
607
600
|
);
|
|
608
601
|
|
|
@@ -654,7 +647,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
654
647
|
z16.object({
|
|
655
648
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
656
649
|
z16.object({
|
|
657
|
-
diff: z16.number().
|
|
650
|
+
diff: z16.number().describe("Value change (`values.after - values.before`)")
|
|
658
651
|
})
|
|
659
652
|
).describe("Audit `value` comparison"),
|
|
660
653
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -739,6 +732,7 @@ function executeProcess(cfg) {
|
|
|
739
732
|
return new Promise((resolve, reject) => {
|
|
740
733
|
const spawnedProcess = spawn(command, args ?? [], {
|
|
741
734
|
shell: true,
|
|
735
|
+
windowsHide: true,
|
|
742
736
|
...options
|
|
743
737
|
});
|
|
744
738
|
let stdout = "";
|
|
@@ -772,7 +766,7 @@ function executeProcess(cfg) {
|
|
|
772
766
|
import { bold, gray } from "ansis";
|
|
773
767
|
import { bundleRequire } from "bundle-require";
|
|
774
768
|
import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
|
|
775
|
-
import { join } from "node:path";
|
|
769
|
+
import { dirname, join } from "node:path";
|
|
776
770
|
|
|
777
771
|
// packages/utils/src/lib/formatting.ts
|
|
778
772
|
function pluralize(text, amount) {
|
|
@@ -1498,7 +1492,8 @@ var yarnv2PackageManager = {
|
|
|
1498
1492
|
],
|
|
1499
1493
|
supportedDepGroups: ["prod", "dev"],
|
|
1500
1494
|
// Yarn v2 does not support audit for optional dependencies
|
|
1501
|
-
unifyResult: yarnv2ToAuditResult
|
|
1495
|
+
unifyResult: yarnv2ToAuditResult,
|
|
1496
|
+
ignoreExitCode: true
|
|
1502
1497
|
},
|
|
1503
1498
|
outdated: {
|
|
1504
1499
|
commandArgs: COMMON_OUTDATED_ARGS,
|
|
@@ -1623,13 +1618,16 @@ function outdatedResultToAuditOutput(result, packageManager, depGroup, totalDeps
|
|
|
1623
1618
|
const outdatedDependencies = validDependencies.filter(
|
|
1624
1619
|
(dep) => neq(dep.current, dep.latest)
|
|
1625
1620
|
);
|
|
1626
|
-
const outdatedStats = outdatedDependencies.reduce(
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1621
|
+
const outdatedStats = outdatedDependencies.reduce(
|
|
1622
|
+
(acc, dep) => {
|
|
1623
|
+
const outdatedLevel = diff(dep.current, dep.latest);
|
|
1624
|
+
if (outdatedLevel == null) {
|
|
1625
|
+
return acc;
|
|
1626
|
+
}
|
|
1627
|
+
return { ...acc, [outdatedLevel]: acc[outdatedLevel] + 1 };
|
|
1628
|
+
},
|
|
1629
|
+
objectFromEntries(RELEASE_TYPES.map((versionType) => [versionType, 0]))
|
|
1630
|
+
);
|
|
1633
1631
|
const issues = outdatedDependencies.length === 0 ? [] : outdatedToIssues(outdatedDependencies);
|
|
1634
1632
|
return {
|
|
1635
1633
|
slug: `${packageManager}-outdated-${depGroup}`,
|
|
@@ -1686,7 +1684,7 @@ async function executeRunner() {
|
|
|
1686
1684
|
const auditResults = checks.includes("audit") ? await processAudit(packageManager, depGroups, auditLevelMapping) : [];
|
|
1687
1685
|
const outdatedResults = checks.includes("outdated") ? await processOutdated(packageManager, depGroups, packageJsonPaths) : [];
|
|
1688
1686
|
const checkResults = [...auditResults, ...outdatedResults];
|
|
1689
|
-
await ensureDirectoryExists(
|
|
1687
|
+
await ensureDirectoryExists(dirname2(RUNNER_OUTPUT_PATH));
|
|
1690
1688
|
await writeFile(RUNNER_OUTPUT_PATH, JSON.stringify(checkResults));
|
|
1691
1689
|
}
|
|
1692
1690
|
async function processOutdated(id, depGroups, packageJsonPaths) {
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// packages/plugin-js-packages/src/lib/js-packages-plugin.ts
|
|
2
|
-
import { dirname as
|
|
2
|
+
import { dirname as dirname3, 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.55.0";
|
|
8
8
|
|
|
9
9
|
// packages/plugin-js-packages/src/lib/config.ts
|
|
10
10
|
import { z as z17 } from "zod";
|
|
@@ -40,7 +40,7 @@ function exists(value) {
|
|
|
40
40
|
return value != null;
|
|
41
41
|
}
|
|
42
42
|
function getMissingRefsForCategories(categories, plugins) {
|
|
43
|
-
if (categories.length === 0) {
|
|
43
|
+
if (!categories || categories.length === 0) {
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
const auditRefsFromCategory = categories.flatMap(
|
|
@@ -117,7 +117,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
|
117
117
|
message: `The filename has to be valid`
|
|
118
118
|
}).min(1, { message: "file name is invalid" });
|
|
119
119
|
var positiveIntSchema = z.number().int().positive();
|
|
120
|
-
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
121
120
|
var nonnegativeNumberSchema = z.number().nonnegative();
|
|
122
121
|
function packageVersionSchema(options) {
|
|
123
122
|
const { versionDescription = "NPM version of the package", required } = options ?? {};
|
|
@@ -540,12 +539,9 @@ var unrefinedCoreConfigSchema = z14.object({
|
|
|
540
539
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
541
540
|
function refineCoreConfig(schema) {
|
|
542
541
|
return schema.refine(
|
|
543
|
-
(
|
|
544
|
-
(
|
|
545
|
-
message: missingRefsForCategoriesErrorMsg(
|
|
546
|
-
coreCfg.categories ?? [],
|
|
547
|
-
coreCfg.plugins
|
|
548
|
-
)
|
|
542
|
+
({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
|
|
543
|
+
({ categories, plugins }) => ({
|
|
544
|
+
message: missingRefsForCategoriesErrorMsg(categories, plugins)
|
|
549
545
|
})
|
|
550
546
|
);
|
|
551
547
|
}
|
|
@@ -597,19 +593,16 @@ var reportSchema = packageVersionSchema({
|
|
|
597
593
|
).merge(
|
|
598
594
|
z15.object(
|
|
599
595
|
{
|
|
600
|
-
categories: z15.array(categoryConfigSchema),
|
|
601
596
|
plugins: z15.array(pluginReportSchema).min(1),
|
|
597
|
+
categories: z15.array(categoryConfigSchema).optional(),
|
|
602
598
|
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
603
599
|
},
|
|
604
600
|
{ description: "Collect output data" }
|
|
605
601
|
)
|
|
606
602
|
).refine(
|
|
607
|
-
(
|
|
608
|
-
(
|
|
609
|
-
message: missingRefsForCategoriesErrorMsg(
|
|
610
|
-
report.categories,
|
|
611
|
-
report.plugins
|
|
612
|
-
)
|
|
603
|
+
({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
|
|
604
|
+
({ categories, plugins }) => ({
|
|
605
|
+
message: missingRefsForCategoriesErrorMsg(categories, plugins)
|
|
613
606
|
})
|
|
614
607
|
);
|
|
615
608
|
|
|
@@ -661,7 +654,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
661
654
|
z16.object({
|
|
662
655
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
663
656
|
z16.object({
|
|
664
|
-
diff: z16.number().
|
|
657
|
+
diff: z16.number().describe("Value change (`values.after - values.before`)")
|
|
665
658
|
})
|
|
666
659
|
).describe("Audit `value` comparison"),
|
|
667
660
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -815,6 +808,7 @@ function executeProcess(cfg) {
|
|
|
815
808
|
return new Promise((resolve, reject) => {
|
|
816
809
|
const spawnedProcess = spawn(command, args ?? [], {
|
|
817
810
|
shell: true,
|
|
811
|
+
windowsHide: true,
|
|
818
812
|
...options
|
|
819
813
|
});
|
|
820
814
|
let stdout = "";
|
|
@@ -848,7 +842,7 @@ function executeProcess(cfg) {
|
|
|
848
842
|
import { bold, gray } from "ansis";
|
|
849
843
|
import { bundleRequire } from "bundle-require";
|
|
850
844
|
import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
|
|
851
|
-
import { join } from "node:path";
|
|
845
|
+
import { dirname, join } from "node:path";
|
|
852
846
|
|
|
853
847
|
// packages/utils/src/lib/logging.ts
|
|
854
848
|
import isaacs_cliui from "@isaacs/cliui";
|
|
@@ -1431,7 +1425,8 @@ var yarnv2PackageManager = {
|
|
|
1431
1425
|
],
|
|
1432
1426
|
supportedDepGroups: ["prod", "dev"],
|
|
1433
1427
|
// Yarn v2 does not support audit for optional dependencies
|
|
1434
|
-
unifyResult: yarnv2ToAuditResult
|
|
1428
|
+
unifyResult: yarnv2ToAuditResult,
|
|
1429
|
+
ignoreExitCode: true
|
|
1435
1430
|
},
|
|
1436
1431
|
outdated: {
|
|
1437
1432
|
commandArgs: COMMON_OUTDATED_ARGS,
|
|
@@ -1449,7 +1444,7 @@ var packageManagers = {
|
|
|
1449
1444
|
|
|
1450
1445
|
// packages/plugin-js-packages/src/lib/runner/index.ts
|
|
1451
1446
|
import { writeFile } from "node:fs/promises";
|
|
1452
|
-
import { dirname } from "node:path";
|
|
1447
|
+
import { dirname as dirname2 } from "node:path";
|
|
1453
1448
|
|
|
1454
1449
|
// packages/plugin-js-packages/src/lib/runner/audit/transform.ts
|
|
1455
1450
|
import { md as md7 } from "build-md";
|
|
@@ -1482,7 +1477,7 @@ var RELEASE_TYPES = objectToKeys(outdatedSeverity);
|
|
|
1482
1477
|
|
|
1483
1478
|
// packages/plugin-js-packages/src/lib/runner/index.ts
|
|
1484
1479
|
async function createRunnerConfig(scriptPath, config) {
|
|
1485
|
-
await ensureDirectoryExists(
|
|
1480
|
+
await ensureDirectoryExists(dirname2(PLUGIN_CONFIG_PATH));
|
|
1486
1481
|
await writeFile(PLUGIN_CONFIG_PATH, JSON.stringify(config));
|
|
1487
1482
|
return {
|
|
1488
1483
|
command: "node",
|
|
@@ -1532,9 +1527,7 @@ async function derivePackageManagerInPackageJson(currentDir = process.cwd()) {
|
|
|
1532
1527
|
return false;
|
|
1533
1528
|
}
|
|
1534
1529
|
async function derivePackageManager(currentDir = process.cwd()) {
|
|
1535
|
-
const pkgManagerFromPackageJson = await derivePackageManagerInPackageJson(
|
|
1536
|
-
currentDir
|
|
1537
|
-
);
|
|
1530
|
+
const pkgManagerFromPackageJson = await derivePackageManagerInPackageJson(currentDir);
|
|
1538
1531
|
if (pkgManagerFromPackageJson) {
|
|
1539
1532
|
return pkgManagerFromPackageJson;
|
|
1540
1533
|
}
|
|
@@ -1579,7 +1572,7 @@ async function normalizeConfig(config) {
|
|
|
1579
1572
|
async function jsPackagesPlugin(config) {
|
|
1580
1573
|
const { packageManager, checks, depGroups, ...jsPackagesPluginConfigRest } = await normalizeConfig(config);
|
|
1581
1574
|
const runnerScriptPath = join4(
|
|
1582
|
-
fileURLToPath(
|
|
1575
|
+
fileURLToPath(dirname3(import.meta.url)),
|
|
1583
1576
|
"bin.js"
|
|
1584
1577
|
);
|
|
1585
1578
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/js-packages-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Code PushUp plugin for JavaScript packages 🛡️",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-js-packages#readme",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"main": "./index.js",
|
|
40
40
|
"types": "./src/index.d.ts",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@code-pushup/models": "0.
|
|
43
|
-
"@code-pushup/utils": "0.
|
|
42
|
+
"@code-pushup/models": "0.55.0",
|
|
43
|
+
"@code-pushup/utils": "0.55.0",
|
|
44
44
|
"build-md": "^0.4.1",
|
|
45
45
|
"semver": "^7.6.0",
|
|
46
46
|
"zod": "^3.22.4"
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type ReleaseType } from 'semver';
|
|
2
1
|
import type { AuditOutput, Issue } from '@code-pushup/models';
|
|
3
2
|
import type { DependencyGroup, PackageManagerId } from '../../config';
|
|
4
|
-
import type { OutdatedResult } from './types';
|
|
3
|
+
import type { OutdatedResult, PackageVersion } from './types';
|
|
5
4
|
export declare function outdatedResultToAuditOutput(result: OutdatedResult, packageManager: PackageManagerId, depGroup: DependencyGroup, totalDeps: number): AuditOutput;
|
|
6
5
|
export declare function calculateOutdatedScore(majorOutdated: number, totalDeps: number): number;
|
|
7
|
-
export declare function outdatedToDisplayValue(stats:
|
|
6
|
+
export declare function outdatedToDisplayValue(stats: PackageVersion): string;
|
|
8
7
|
export declare function outdatedToIssues(dependencies: OutdatedResult): Issue[];
|