@code-pushup/core 0.52.0 → 0.53.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/index.js +50 -37
- package/package.json +39 -17
- package/src/lib/implementation/report-to-gql.d.ts +1 -1
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var MAX_ISSUE_MESSAGE_LENGTH = 1024;
|
|
|
12
12
|
var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
|
|
13
13
|
var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
|
|
14
14
|
function hasDuplicateStrings(strings) {
|
|
15
|
-
const sortedStrings =
|
|
15
|
+
const sortedStrings = strings.toSorted();
|
|
16
16
|
const duplStrings = sortedStrings.filter(
|
|
17
17
|
(item, index) => index !== 0 && item === sortedStrings[index - 1]
|
|
18
18
|
);
|
|
@@ -1474,7 +1474,7 @@ function getColumnAlignments(tableData) {
|
|
|
1474
1474
|
(_, idx) => getColumnAlignmentForIndex(idx, columns)
|
|
1475
1475
|
);
|
|
1476
1476
|
}
|
|
1477
|
-
const biggestRow =
|
|
1477
|
+
const biggestRow = rows.toSorted((a, b) => Object.keys(a).length - Object.keys(b).length).at(-1);
|
|
1478
1478
|
if (columns.length > 0) {
|
|
1479
1479
|
return columns.map(
|
|
1480
1480
|
(column, idx) => typeof column === "string" ? column : getColumnAlignmentForKeyAndIndex(
|
|
@@ -1494,25 +1494,30 @@ import {
|
|
|
1494
1494
|
} from "build-md";
|
|
1495
1495
|
import { posix as pathPosix } from "node:path";
|
|
1496
1496
|
|
|
1497
|
-
// packages/utils/src/lib/reports/
|
|
1497
|
+
// packages/utils/src/lib/reports/types.ts
|
|
1498
|
+
var SUPPORTED_ENVIRONMENTS = [
|
|
1499
|
+
"vscode",
|
|
1500
|
+
"github",
|
|
1501
|
+
"gitlab",
|
|
1502
|
+
"other"
|
|
1503
|
+
];
|
|
1504
|
+
|
|
1505
|
+
// packages/utils/src/lib/reports/environment-type.ts
|
|
1506
|
+
var environmentChecks = {
|
|
1507
|
+
vscode: () => process.env["TERM_PROGRAM"] === "vscode",
|
|
1508
|
+
github: () => process.env["GITHUB_ACTIONS"] === "true",
|
|
1509
|
+
gitlab: () => process.env["GITLAB_CI"] === "true",
|
|
1510
|
+
other: () => true
|
|
1511
|
+
};
|
|
1498
1512
|
function getEnvironmentType() {
|
|
1499
|
-
|
|
1500
|
-
return "vscode";
|
|
1501
|
-
}
|
|
1502
|
-
if (isGitHub()) {
|
|
1503
|
-
return "github";
|
|
1504
|
-
}
|
|
1505
|
-
return "other";
|
|
1506
|
-
}
|
|
1507
|
-
function isVSCode() {
|
|
1508
|
-
return process.env["TERM_PROGRAM"] === "vscode";
|
|
1509
|
-
}
|
|
1510
|
-
function isGitHub() {
|
|
1511
|
-
return process.env["GITHUB_ACTIONS"] === "true";
|
|
1513
|
+
return SUPPORTED_ENVIRONMENTS.find((env) => environmentChecks[env]()) ?? "other";
|
|
1512
1514
|
}
|
|
1513
1515
|
function getGitHubBaseUrl() {
|
|
1514
1516
|
return `${process.env["GITHUB_SERVER_URL"]}/${process.env["GITHUB_REPOSITORY"]}/blob/${process.env["GITHUB_SHA"]}`;
|
|
1515
1517
|
}
|
|
1518
|
+
function getGitLabBaseUrl() {
|
|
1519
|
+
return `${process.env["CI_SERVER_URL"]}/${process.env["CI_PROJECT_PATH"]}/-/blob/${process.env["CI_COMMIT_SHA"]}`;
|
|
1520
|
+
}
|
|
1516
1521
|
|
|
1517
1522
|
// packages/utils/src/lib/reports/formatting.ts
|
|
1518
1523
|
function tableSection(tableData, options) {
|
|
@@ -1578,6 +1583,15 @@ function formatGitHubLink(file, position) {
|
|
|
1578
1583
|
const lineRange = end && start !== end ? `${start}-${end}` : start;
|
|
1579
1584
|
return `${baseUrl}/${file}#${lineRange}`;
|
|
1580
1585
|
}
|
|
1586
|
+
function formatGitLabLink(file, position) {
|
|
1587
|
+
const baseUrl = getGitLabBaseUrl();
|
|
1588
|
+
if (!position) {
|
|
1589
|
+
return `${baseUrl}/${file}`;
|
|
1590
|
+
}
|
|
1591
|
+
const { startLine, endLine } = position;
|
|
1592
|
+
const lineRange = endLine && startLine !== endLine ? `${startLine}-${endLine}` : startLine;
|
|
1593
|
+
return `${baseUrl}/${file}#L${lineRange}`;
|
|
1594
|
+
}
|
|
1581
1595
|
function formatFileLink(file, position, outputDir) {
|
|
1582
1596
|
const relativePath = pathPosix.relative(outputDir, file);
|
|
1583
1597
|
const env = getEnvironmentType();
|
|
@@ -1586,6 +1600,8 @@ function formatFileLink(file, position, outputDir) {
|
|
|
1586
1600
|
return position ? `${relativePath}#L${position.startLine}` : relativePath;
|
|
1587
1601
|
case "github":
|
|
1588
1602
|
return formatGitHubLink(file, position);
|
|
1603
|
+
case "gitlab":
|
|
1604
|
+
return formatGitLabLink(file, position);
|
|
1589
1605
|
default:
|
|
1590
1606
|
return relativePath;
|
|
1591
1607
|
}
|
|
@@ -1637,7 +1653,7 @@ function getSortableGroupByRef({ plugin, slug, weight }, plugins) {
|
|
|
1637
1653
|
throwIsNotPresentError(`Group ${slug}`, groupPlugin.slug);
|
|
1638
1654
|
}
|
|
1639
1655
|
const sortedAudits = getSortedGroupAudits(group, groupPlugin.slug, plugins);
|
|
1640
|
-
const sortedAuditRefs =
|
|
1656
|
+
const sortedAuditRefs = group.refs.toSorted((a, b) => {
|
|
1641
1657
|
const aIndex = sortedAudits.findIndex((ref) => ref.slug === a.slug);
|
|
1642
1658
|
const bIndex = sortedAudits.findIndex((ref) => ref.slug === b.slug);
|
|
1643
1659
|
return aIndex - bIndex;
|
|
@@ -1666,7 +1682,7 @@ function sortReport(report) {
|
|
|
1666
1682
|
const sortedAuditsAndGroups = [...audits, ...groups].sort(
|
|
1667
1683
|
compareCategoryAuditsAndGroups
|
|
1668
1684
|
);
|
|
1669
|
-
const sortedRefs =
|
|
1685
|
+
const sortedRefs = category.refs.toSorted((a, b) => {
|
|
1670
1686
|
const aIndex = sortedAuditsAndGroups.findIndex(
|
|
1671
1687
|
(ref) => ref.slug === a.slug && ref.plugin === a.plugin
|
|
1672
1688
|
);
|
|
@@ -1686,12 +1702,12 @@ function sortReport(report) {
|
|
|
1686
1702
|
function sortPlugins(plugins) {
|
|
1687
1703
|
return plugins.map((plugin) => ({
|
|
1688
1704
|
...plugin,
|
|
1689
|
-
audits:
|
|
1705
|
+
audits: plugin.audits.toSorted(compareAudits).map(
|
|
1690
1706
|
(audit) => audit.details?.issues ? {
|
|
1691
1707
|
...audit,
|
|
1692
1708
|
details: {
|
|
1693
1709
|
...audit.details,
|
|
1694
|
-
issues:
|
|
1710
|
+
issues: audit.details.issues.toSorted(compareIssues)
|
|
1695
1711
|
}
|
|
1696
1712
|
} : audit
|
|
1697
1713
|
)
|
|
@@ -1968,7 +1984,7 @@ function formatPortalLink(portalUrl) {
|
|
|
1968
1984
|
return portalUrl && md5.link(portalUrl, "\u{1F575}\uFE0F See full comparison in Code PushUp portal \u{1F50D}");
|
|
1969
1985
|
}
|
|
1970
1986
|
function sortChanges(changes) {
|
|
1971
|
-
return
|
|
1987
|
+
return changes.toSorted(
|
|
1972
1988
|
(a, b) => Math.abs(b.scores.diff) - Math.abs(a.scores.diff) || Math.abs(b.values?.diff ?? 0) - Math.abs(a.values?.diff ?? 0)
|
|
1973
1989
|
);
|
|
1974
1990
|
}
|
|
@@ -2434,7 +2450,7 @@ var verboseUtils = (verbose = false) => ({
|
|
|
2434
2450
|
|
|
2435
2451
|
// packages/core/package.json
|
|
2436
2452
|
var name = "@code-pushup/core";
|
|
2437
|
-
var version = "0.
|
|
2453
|
+
var version = "0.53.1";
|
|
2438
2454
|
|
|
2439
2455
|
// packages/core/src/lib/implementation/execute-plugin.ts
|
|
2440
2456
|
import { bold as bold5 } from "ansis";
|
|
@@ -2933,12 +2949,6 @@ async function fetchPortalComparisonLink(uploadConfig, commits) {
|
|
|
2933
2949
|
}
|
|
2934
2950
|
|
|
2935
2951
|
// packages/core/src/lib/implementation/report-to-gql.ts
|
|
2936
|
-
import {
|
|
2937
|
-
CategoryConfigRefType as PortalCategoryRefType,
|
|
2938
|
-
IssueSeverity as PortalIssueSeverity,
|
|
2939
|
-
IssueSourceType as PortalIssueSourceType,
|
|
2940
|
-
TableAlignment as PortalTableAlignment
|
|
2941
|
-
} from "@code-pushup/portal-client";
|
|
2942
2952
|
function reportToGQL(report) {
|
|
2943
2953
|
return {
|
|
2944
2954
|
packageName: report.packageName,
|
|
@@ -3005,7 +3015,7 @@ function issueToGQL(issue) {
|
|
|
3005
3015
|
message: issue.message,
|
|
3006
3016
|
severity: issueSeverityToGQL(issue.severity),
|
|
3007
3017
|
...issue.source?.file && {
|
|
3008
|
-
sourceType:
|
|
3018
|
+
sourceType: safeEnum("SourceCode"),
|
|
3009
3019
|
sourceFilePath: issue.source.file,
|
|
3010
3020
|
sourceStartLine: issue.source.position?.startLine,
|
|
3011
3021
|
sourceStartColumn: issue.source.position?.startColumn,
|
|
@@ -3051,31 +3061,34 @@ function categoryToGQL(category) {
|
|
|
3051
3061
|
function categoryRefTypeToGQL(type) {
|
|
3052
3062
|
switch (type) {
|
|
3053
3063
|
case "audit":
|
|
3054
|
-
return
|
|
3064
|
+
return safeEnum("Audit");
|
|
3055
3065
|
case "group":
|
|
3056
|
-
return
|
|
3066
|
+
return safeEnum("Group");
|
|
3057
3067
|
}
|
|
3058
3068
|
}
|
|
3059
3069
|
function issueSeverityToGQL(severity) {
|
|
3060
3070
|
switch (severity) {
|
|
3061
3071
|
case "info":
|
|
3062
|
-
return
|
|
3072
|
+
return safeEnum("Info");
|
|
3063
3073
|
case "error":
|
|
3064
|
-
return
|
|
3074
|
+
return safeEnum("Error");
|
|
3065
3075
|
case "warning":
|
|
3066
|
-
return
|
|
3076
|
+
return safeEnum("Warning");
|
|
3067
3077
|
}
|
|
3068
3078
|
}
|
|
3069
3079
|
function tableAlignmentToGQL(alignment) {
|
|
3070
3080
|
switch (alignment) {
|
|
3071
3081
|
case "left":
|
|
3072
|
-
return
|
|
3082
|
+
return safeEnum("Left");
|
|
3073
3083
|
case "center":
|
|
3074
|
-
return
|
|
3084
|
+
return safeEnum("Center");
|
|
3075
3085
|
case "right":
|
|
3076
|
-
return
|
|
3086
|
+
return safeEnum("Right");
|
|
3077
3087
|
}
|
|
3078
3088
|
}
|
|
3089
|
+
function safeEnum(value) {
|
|
3090
|
+
return value;
|
|
3091
|
+
}
|
|
3079
3092
|
|
|
3080
3093
|
// packages/core/src/lib/upload.ts
|
|
3081
3094
|
async function upload(options) {
|
package/package.json
CHANGED
|
@@ -1,34 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core business logic for the used by the Code PushUp CLI",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@code-pushup/models": "0.52.0",
|
|
8
|
-
"@code-pushup/utils": "0.52.0",
|
|
9
|
-
"ansis": "^3.3.0"
|
|
10
|
-
},
|
|
11
|
-
"peerDependencies": {
|
|
12
|
-
"@code-pushup/portal-client": "^0.9.0"
|
|
13
|
-
},
|
|
14
|
-
"peerDependenciesMeta": {
|
|
15
|
-
"@code-pushup/portal-client": {
|
|
16
|
-
"optional": true
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/core#readme",
|
|
20
7
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/code-pushup/cli/issues"
|
|
8
|
+
"url": "https://github.com/code-pushup/cli/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20label%3A\"🧩%20core\""
|
|
22
9
|
},
|
|
23
10
|
"repository": {
|
|
24
11
|
"type": "git",
|
|
25
12
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
26
13
|
"directory": "packages/core"
|
|
27
14
|
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"CLI",
|
|
17
|
+
"Code PushUp",
|
|
18
|
+
"automation",
|
|
19
|
+
"developer tools",
|
|
20
|
+
"code quality",
|
|
21
|
+
"conformance",
|
|
22
|
+
"build tools",
|
|
23
|
+
"KPI tracking",
|
|
24
|
+
"tech debt",
|
|
25
|
+
"automated feedback",
|
|
26
|
+
"regression guard",
|
|
27
|
+
"CI integration",
|
|
28
|
+
"code management",
|
|
29
|
+
"actionable feedback",
|
|
30
|
+
"trend analysis",
|
|
31
|
+
"static analysis",
|
|
32
|
+
"linting",
|
|
33
|
+
"audit",
|
|
34
|
+
"performance",
|
|
35
|
+
"score monitoring"
|
|
36
|
+
],
|
|
28
37
|
"publishConfig": {
|
|
29
38
|
"access": "public"
|
|
30
39
|
},
|
|
31
40
|
"type": "module",
|
|
32
41
|
"main": "./index.js",
|
|
33
|
-
"types": "./src/index.d.ts"
|
|
34
|
-
|
|
42
|
+
"types": "./src/index.d.ts",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@code-pushup/models": "0.53.1",
|
|
45
|
+
"@code-pushup/utils": "0.53.1",
|
|
46
|
+
"ansis": "^3.3.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@code-pushup/portal-client": "^0.9.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"@code-pushup/portal-client": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AuditReportIssue as PortalIssue, AuditReportTable as PortalTable, SaveReportMutationVariables } from '@code-pushup/portal-client';
|
|
2
2
|
import type { Issue, Report, Table } from '@code-pushup/models';
|
|
3
3
|
export declare function reportToGQL(report: Report): Omit<SaveReportMutationVariables, 'organization' | 'project' | 'commit'>;
|
|
4
4
|
export declare function issueToGQL(issue: Issue): PortalIssue;
|