@code-pushup/cli 0.1.1 → 0.3.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 +72 -67
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,6 +24,11 @@ import { z as z2 } from "zod";
|
|
|
24
24
|
import { z } from "zod";
|
|
25
25
|
import { MATERIAL_ICONS } from "@code-pushup/portal-client";
|
|
26
26
|
|
|
27
|
+
// packages/models/src/lib/implementation/limits.ts
|
|
28
|
+
var MAX_SLUG_LENGTH = 128;
|
|
29
|
+
var MAX_TITLE_LENGTH = 256;
|
|
30
|
+
var MAX_DESCRIPTION_LENGTH = 65536;
|
|
31
|
+
|
|
27
32
|
// packages/models/src/lib/implementation/utils.ts
|
|
28
33
|
var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
29
34
|
var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
|
|
@@ -59,12 +64,12 @@ function executionMetaSchema(options2 = {
|
|
|
59
64
|
function slugSchema(description = "Unique ID (human-readable, URL-safe)") {
|
|
60
65
|
return z.string({ description }).regex(slugRegex, {
|
|
61
66
|
message: "The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug"
|
|
62
|
-
}).max(
|
|
63
|
-
message:
|
|
67
|
+
}).max(MAX_SLUG_LENGTH, {
|
|
68
|
+
message: `slug can be max ${MAX_SLUG_LENGTH} characters long`
|
|
64
69
|
});
|
|
65
70
|
}
|
|
66
71
|
function descriptionSchema(description = "Description (markdown)") {
|
|
67
|
-
return z.string({ description }).max(
|
|
72
|
+
return z.string({ description }).max(MAX_DESCRIPTION_LENGTH).optional();
|
|
68
73
|
}
|
|
69
74
|
function docsUrlSchema(description = "Documentation site") {
|
|
70
75
|
return urlSchema(description).optional().or(z.string().max(0));
|
|
@@ -73,7 +78,7 @@ function urlSchema(description) {
|
|
|
73
78
|
return z.string({ description }).url();
|
|
74
79
|
}
|
|
75
80
|
function titleSchema(description = "Descriptive name") {
|
|
76
|
-
return z.string({ description }).max(
|
|
81
|
+
return z.string({ description }).max(MAX_TITLE_LENGTH);
|
|
77
82
|
}
|
|
78
83
|
function metaSchema(options2) {
|
|
79
84
|
const {
|
|
@@ -606,6 +611,14 @@ function logPromiseResults(results, logMessage, callback) {
|
|
|
606
611
|
}
|
|
607
612
|
|
|
608
613
|
// packages/utils/src/lib/file-system.ts
|
|
614
|
+
async function readTextFile(path) {
|
|
615
|
+
const buffer = await readFile(path);
|
|
616
|
+
return buffer.toString();
|
|
617
|
+
}
|
|
618
|
+
async function readJsonFile(path) {
|
|
619
|
+
const text = await readTextFile(path);
|
|
620
|
+
return JSON.parse(text);
|
|
621
|
+
}
|
|
609
622
|
async function ensureDirectoryExists(baseDir) {
|
|
610
623
|
try {
|
|
611
624
|
await mkdir(baseDir, { recursive: true });
|
|
@@ -617,14 +630,6 @@ async function ensureDirectoryExists(baseDir) {
|
|
|
617
630
|
}
|
|
618
631
|
}
|
|
619
632
|
}
|
|
620
|
-
async function readTextFile(path) {
|
|
621
|
-
const buffer = await readFile(path);
|
|
622
|
-
return buffer.toString();
|
|
623
|
-
}
|
|
624
|
-
async function readJsonFile(path) {
|
|
625
|
-
const text = await readTextFile(path);
|
|
626
|
-
return JSON.parse(text);
|
|
627
|
-
}
|
|
628
633
|
function logMultipleFileResults(fileResults, messagePrefix) {
|
|
629
634
|
const succeededCallback = (result) => {
|
|
630
635
|
const [fileName, size] = result.value;
|
|
@@ -924,60 +929,6 @@ async function getLatestCommit() {
|
|
|
924
929
|
return log?.latest;
|
|
925
930
|
}
|
|
926
931
|
|
|
927
|
-
// packages/utils/src/lib/progress.ts
|
|
928
|
-
import chalk2 from "chalk";
|
|
929
|
-
import { MultiProgressBars } from "multi-progress-bars";
|
|
930
|
-
var barStyles = {
|
|
931
|
-
active: (s) => chalk2.green(s),
|
|
932
|
-
done: (s) => chalk2.gray(s),
|
|
933
|
-
idle: (s) => chalk2.gray(s)
|
|
934
|
-
};
|
|
935
|
-
var messageStyles = {
|
|
936
|
-
active: (s) => chalk2.black(s),
|
|
937
|
-
done: (s) => chalk2.green(chalk2.bold(s)),
|
|
938
|
-
idle: (s) => chalk2.gray(s)
|
|
939
|
-
};
|
|
940
|
-
var mpb;
|
|
941
|
-
function getSingletonProgressBars(options2) {
|
|
942
|
-
if (!mpb) {
|
|
943
|
-
mpb = new MultiProgressBars({
|
|
944
|
-
initMessage: "",
|
|
945
|
-
border: true,
|
|
946
|
-
...options2
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
return mpb;
|
|
950
|
-
}
|
|
951
|
-
function getProgressBar(taskName) {
|
|
952
|
-
const tasks = getSingletonProgressBars();
|
|
953
|
-
tasks.addTask(taskName, {
|
|
954
|
-
type: "percentage",
|
|
955
|
-
percentage: 0,
|
|
956
|
-
message: "",
|
|
957
|
-
barTransformFn: barStyles.idle
|
|
958
|
-
});
|
|
959
|
-
return {
|
|
960
|
-
incrementInSteps: (numPlugins) => {
|
|
961
|
-
tasks.incrementTask(taskName, {
|
|
962
|
-
percentage: 1 / numPlugins,
|
|
963
|
-
barTransformFn: barStyles.active
|
|
964
|
-
});
|
|
965
|
-
},
|
|
966
|
-
updateTitle: (title) => {
|
|
967
|
-
tasks.updateTask(taskName, {
|
|
968
|
-
message: title,
|
|
969
|
-
barTransformFn: barStyles.active
|
|
970
|
-
});
|
|
971
|
-
},
|
|
972
|
-
endProgress: (message = "") => {
|
|
973
|
-
tasks.done(taskName, {
|
|
974
|
-
message: messageStyles.done(message),
|
|
975
|
-
barTransformFn: barStyles.done
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
|
|
981
932
|
// packages/utils/src/lib/md/details.ts
|
|
982
933
|
function details(title, content, cfg = { open: false }) {
|
|
983
934
|
return `<details${cfg.open ? " open" : ""}>
|
|
@@ -1055,6 +1006,60 @@ function li(text, order = "unordered") {
|
|
|
1055
1006
|
return `${style2} ${text}`;
|
|
1056
1007
|
}
|
|
1057
1008
|
|
|
1009
|
+
// packages/utils/src/lib/progress.ts
|
|
1010
|
+
import chalk2 from "chalk";
|
|
1011
|
+
import { MultiProgressBars } from "multi-progress-bars";
|
|
1012
|
+
var barStyles = {
|
|
1013
|
+
active: (s) => chalk2.green(s),
|
|
1014
|
+
done: (s) => chalk2.gray(s),
|
|
1015
|
+
idle: (s) => chalk2.gray(s)
|
|
1016
|
+
};
|
|
1017
|
+
var messageStyles = {
|
|
1018
|
+
active: (s) => chalk2.black(s),
|
|
1019
|
+
done: (s) => chalk2.green(chalk2.bold(s)),
|
|
1020
|
+
idle: (s) => chalk2.gray(s)
|
|
1021
|
+
};
|
|
1022
|
+
var mpb;
|
|
1023
|
+
function getSingletonProgressBars(options2) {
|
|
1024
|
+
if (!mpb) {
|
|
1025
|
+
mpb = new MultiProgressBars({
|
|
1026
|
+
initMessage: "",
|
|
1027
|
+
border: true,
|
|
1028
|
+
...options2
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return mpb;
|
|
1032
|
+
}
|
|
1033
|
+
function getProgressBar(taskName) {
|
|
1034
|
+
const tasks = getSingletonProgressBars();
|
|
1035
|
+
tasks.addTask(taskName, {
|
|
1036
|
+
type: "percentage",
|
|
1037
|
+
percentage: 0,
|
|
1038
|
+
message: "",
|
|
1039
|
+
barTransformFn: barStyles.idle
|
|
1040
|
+
});
|
|
1041
|
+
return {
|
|
1042
|
+
incrementInSteps: (numPlugins) => {
|
|
1043
|
+
tasks.incrementTask(taskName, {
|
|
1044
|
+
percentage: 1 / numPlugins,
|
|
1045
|
+
barTransformFn: barStyles.active
|
|
1046
|
+
});
|
|
1047
|
+
},
|
|
1048
|
+
updateTitle: (title) => {
|
|
1049
|
+
tasks.updateTask(taskName, {
|
|
1050
|
+
message: title,
|
|
1051
|
+
barTransformFn: barStyles.active
|
|
1052
|
+
});
|
|
1053
|
+
},
|
|
1054
|
+
endProgress: (message = "") => {
|
|
1055
|
+
tasks.done(taskName, {
|
|
1056
|
+
message: messageStyles.done(message),
|
|
1057
|
+
barTransformFn: barStyles.done
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1058
1063
|
// packages/utils/src/lib/report-to-md.ts
|
|
1059
1064
|
function reportToMd(report, commitData) {
|
|
1060
1065
|
let md = reportToHeaderSection() + NEW_LINE;
|
|
@@ -1596,7 +1601,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1596
1601
|
|
|
1597
1602
|
// packages/core/package.json
|
|
1598
1603
|
var name = "@code-pushup/core";
|
|
1599
|
-
var version = "0.
|
|
1604
|
+
var version = "0.3.0";
|
|
1600
1605
|
|
|
1601
1606
|
// packages/core/src/lib/implementation/collect.ts
|
|
1602
1607
|
async function collect(options2) {
|