@code-pushup/core 0.52.0 → 0.53.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/index.js +43 -30
- package/package.json +3 -3
- package/src/lib/implementation/report-to-gql.d.ts +1 -1
package/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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.0";
|
|
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,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core business logic for the used by the Code PushUp CLI",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@code-pushup/models": "0.
|
|
8
|
-
"@code-pushup/utils": "0.
|
|
7
|
+
"@code-pushup/models": "0.53.0",
|
|
8
|
+
"@code-pushup/utils": "0.53.0",
|
|
9
9
|
"ansis": "^3.3.0"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
@@ -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;
|