@code-pushup/core 0.1.0 → 0.2.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 +66 -64
- package/package.json +1 -1
- package/src/index.d.ts +1 -1
package/index.js
CHANGED
|
@@ -543,7 +543,8 @@ function slugify(text) {
|
|
|
543
543
|
return text.trim().toLowerCase().replace(/\s+|\//g, "-").replace(/[^a-z0-9-]/g, "");
|
|
544
544
|
}
|
|
545
545
|
function formatBytes(bytes, decimals = 2) {
|
|
546
|
-
|
|
546
|
+
bytes = Math.max(bytes, 0);
|
|
547
|
+
if (!bytes)
|
|
547
548
|
return "0 B";
|
|
548
549
|
const k = 1024;
|
|
549
550
|
const dm = decimals < 0 ? 0 : decimals;
|
|
@@ -597,6 +598,14 @@ function logPromiseResults(results, logMessage, callback) {
|
|
|
597
598
|
}
|
|
598
599
|
|
|
599
600
|
// packages/utils/src/lib/file-system.ts
|
|
601
|
+
async function readTextFile(path) {
|
|
602
|
+
const buffer = await readFile(path);
|
|
603
|
+
return buffer.toString();
|
|
604
|
+
}
|
|
605
|
+
async function readJsonFile(path) {
|
|
606
|
+
const text = await readTextFile(path);
|
|
607
|
+
return JSON.parse(text);
|
|
608
|
+
}
|
|
600
609
|
async function ensureDirectoryExists(baseDir) {
|
|
601
610
|
try {
|
|
602
611
|
await mkdir(baseDir, { recursive: true });
|
|
@@ -608,14 +617,6 @@ async function ensureDirectoryExists(baseDir) {
|
|
|
608
617
|
}
|
|
609
618
|
}
|
|
610
619
|
}
|
|
611
|
-
async function readTextFile(path) {
|
|
612
|
-
const buffer = await readFile(path);
|
|
613
|
-
return buffer.toString();
|
|
614
|
-
}
|
|
615
|
-
async function readJsonFile(path) {
|
|
616
|
-
const text = await readTextFile(path);
|
|
617
|
-
return JSON.parse(text);
|
|
618
|
-
}
|
|
619
620
|
function logMultipleFileResults(fileResults, messagePrefix) {
|
|
620
621
|
const succeededCallback = (result) => {
|
|
621
622
|
const [fileName, size] = result.value;
|
|
@@ -915,60 +916,6 @@ async function getLatestCommit() {
|
|
|
915
916
|
return log?.latest;
|
|
916
917
|
}
|
|
917
918
|
|
|
918
|
-
// packages/utils/src/lib/progress.ts
|
|
919
|
-
import chalk2 from "chalk";
|
|
920
|
-
import { MultiProgressBars } from "multi-progress-bars";
|
|
921
|
-
var barStyles = {
|
|
922
|
-
active: (s) => chalk2.green(s),
|
|
923
|
-
done: (s) => chalk2.gray(s),
|
|
924
|
-
idle: (s) => chalk2.gray(s)
|
|
925
|
-
};
|
|
926
|
-
var messageStyles = {
|
|
927
|
-
active: (s) => chalk2.black(s),
|
|
928
|
-
done: (s) => chalk2.green(chalk2.bold(s)),
|
|
929
|
-
idle: (s) => chalk2.gray(s)
|
|
930
|
-
};
|
|
931
|
-
var mpb;
|
|
932
|
-
function getSingletonProgressBars(options) {
|
|
933
|
-
if (!mpb) {
|
|
934
|
-
mpb = new MultiProgressBars({
|
|
935
|
-
initMessage: "",
|
|
936
|
-
border: true,
|
|
937
|
-
...options
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
return mpb;
|
|
941
|
-
}
|
|
942
|
-
function getProgressBar(taskName) {
|
|
943
|
-
const tasks = getSingletonProgressBars();
|
|
944
|
-
tasks.addTask(taskName, {
|
|
945
|
-
type: "percentage",
|
|
946
|
-
percentage: 0,
|
|
947
|
-
message: "",
|
|
948
|
-
barTransformFn: barStyles.idle
|
|
949
|
-
});
|
|
950
|
-
return {
|
|
951
|
-
incrementInSteps: (numPlugins) => {
|
|
952
|
-
tasks.incrementTask(taskName, {
|
|
953
|
-
percentage: 1 / numPlugins,
|
|
954
|
-
barTransformFn: barStyles.active
|
|
955
|
-
});
|
|
956
|
-
},
|
|
957
|
-
updateTitle: (title) => {
|
|
958
|
-
tasks.updateTask(taskName, {
|
|
959
|
-
message: title,
|
|
960
|
-
barTransformFn: barStyles.active
|
|
961
|
-
});
|
|
962
|
-
},
|
|
963
|
-
endProgress: (message = "") => {
|
|
964
|
-
tasks.done(taskName, {
|
|
965
|
-
message: messageStyles.done(message),
|
|
966
|
-
barTransformFn: barStyles.done
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
|
|
972
919
|
// packages/utils/src/lib/md/details.ts
|
|
973
920
|
function details(title, content, cfg = { open: false }) {
|
|
974
921
|
return `<details${cfg.open ? " open" : ""}>
|
|
@@ -1046,6 +993,60 @@ function li(text, order = "unordered") {
|
|
|
1046
993
|
return `${style2} ${text}`;
|
|
1047
994
|
}
|
|
1048
995
|
|
|
996
|
+
// packages/utils/src/lib/progress.ts
|
|
997
|
+
import chalk2 from "chalk";
|
|
998
|
+
import { MultiProgressBars } from "multi-progress-bars";
|
|
999
|
+
var barStyles = {
|
|
1000
|
+
active: (s) => chalk2.green(s),
|
|
1001
|
+
done: (s) => chalk2.gray(s),
|
|
1002
|
+
idle: (s) => chalk2.gray(s)
|
|
1003
|
+
};
|
|
1004
|
+
var messageStyles = {
|
|
1005
|
+
active: (s) => chalk2.black(s),
|
|
1006
|
+
done: (s) => chalk2.green(chalk2.bold(s)),
|
|
1007
|
+
idle: (s) => chalk2.gray(s)
|
|
1008
|
+
};
|
|
1009
|
+
var mpb;
|
|
1010
|
+
function getSingletonProgressBars(options) {
|
|
1011
|
+
if (!mpb) {
|
|
1012
|
+
mpb = new MultiProgressBars({
|
|
1013
|
+
initMessage: "",
|
|
1014
|
+
border: true,
|
|
1015
|
+
...options
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
return mpb;
|
|
1019
|
+
}
|
|
1020
|
+
function getProgressBar(taskName) {
|
|
1021
|
+
const tasks = getSingletonProgressBars();
|
|
1022
|
+
tasks.addTask(taskName, {
|
|
1023
|
+
type: "percentage",
|
|
1024
|
+
percentage: 0,
|
|
1025
|
+
message: "",
|
|
1026
|
+
barTransformFn: barStyles.idle
|
|
1027
|
+
});
|
|
1028
|
+
return {
|
|
1029
|
+
incrementInSteps: (numPlugins) => {
|
|
1030
|
+
tasks.incrementTask(taskName, {
|
|
1031
|
+
percentage: 1 / numPlugins,
|
|
1032
|
+
barTransformFn: barStyles.active
|
|
1033
|
+
});
|
|
1034
|
+
},
|
|
1035
|
+
updateTitle: (title) => {
|
|
1036
|
+
tasks.updateTask(taskName, {
|
|
1037
|
+
message: title,
|
|
1038
|
+
barTransformFn: barStyles.active
|
|
1039
|
+
});
|
|
1040
|
+
},
|
|
1041
|
+
endProgress: (message = "") => {
|
|
1042
|
+
tasks.done(taskName, {
|
|
1043
|
+
message: messageStyles.done(message),
|
|
1044
|
+
barTransformFn: barStyles.done
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1049
1050
|
// packages/utils/src/lib/report-to-md.ts
|
|
1050
1051
|
function reportToMd(report, commitData) {
|
|
1051
1052
|
let md = reportToHeaderSection() + NEW_LINE;
|
|
@@ -1587,7 +1588,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1587
1588
|
|
|
1588
1589
|
// packages/core/package.json
|
|
1589
1590
|
var name = "@code-pushup/core";
|
|
1590
|
-
var version = "0.
|
|
1591
|
+
var version = "0.2.0";
|
|
1591
1592
|
|
|
1592
1593
|
// packages/core/src/lib/implementation/collect.ts
|
|
1593
1594
|
async function collect(options) {
|
|
@@ -1750,6 +1751,7 @@ export {
|
|
|
1750
1751
|
PluginOutputMissingAuditError,
|
|
1751
1752
|
collect,
|
|
1752
1753
|
collectAndPersistReports,
|
|
1754
|
+
executePlugin,
|
|
1753
1755
|
executePlugins,
|
|
1754
1756
|
persistReport,
|
|
1755
1757
|
readCodePushupConfig,
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { persistReport, PersistError, PersistDirError, } from './lib/implementation/persist';
|
|
2
|
-
export { executePlugins, PluginOutputMissingAuditError, } from './lib/implementation/execute-plugin';
|
|
2
|
+
export { executePlugin, executePlugins, PluginOutputMissingAuditError, } from './lib/implementation/execute-plugin';
|
|
3
3
|
export { collect, CollectOptions } from './lib/implementation/collect';
|
|
4
4
|
export { upload, UploadOptions } from './lib/upload';
|
|
5
5
|
export { GlobalOptions } from './lib/types';
|