@code-pushup/cli 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.
Files changed (2) hide show
  1. package/index.js +65 -64
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -551,7 +551,8 @@ function slugify(text) {
551
551
  return text.trim().toLowerCase().replace(/\s+|\//g, "-").replace(/[^a-z0-9-]/g, "");
552
552
  }
553
553
  function formatBytes(bytes, decimals = 2) {
554
- if (!+bytes)
554
+ bytes = Math.max(bytes, 0);
555
+ if (!bytes)
555
556
  return "0 B";
556
557
  const k = 1024;
557
558
  const dm = decimals < 0 ? 0 : decimals;
@@ -605,6 +606,14 @@ function logPromiseResults(results, logMessage, callback) {
605
606
  }
606
607
 
607
608
  // packages/utils/src/lib/file-system.ts
609
+ async function readTextFile(path) {
610
+ const buffer = await readFile(path);
611
+ return buffer.toString();
612
+ }
613
+ async function readJsonFile(path) {
614
+ const text = await readTextFile(path);
615
+ return JSON.parse(text);
616
+ }
608
617
  async function ensureDirectoryExists(baseDir) {
609
618
  try {
610
619
  await mkdir(baseDir, { recursive: true });
@@ -616,14 +625,6 @@ async function ensureDirectoryExists(baseDir) {
616
625
  }
617
626
  }
618
627
  }
619
- async function readTextFile(path) {
620
- const buffer = await readFile(path);
621
- return buffer.toString();
622
- }
623
- async function readJsonFile(path) {
624
- const text = await readTextFile(path);
625
- return JSON.parse(text);
626
- }
627
628
  function logMultipleFileResults(fileResults, messagePrefix) {
628
629
  const succeededCallback = (result) => {
629
630
  const [fileName, size] = result.value;
@@ -923,60 +924,6 @@ async function getLatestCommit() {
923
924
  return log?.latest;
924
925
  }
925
926
 
926
- // packages/utils/src/lib/progress.ts
927
- import chalk2 from "chalk";
928
- import { MultiProgressBars } from "multi-progress-bars";
929
- var barStyles = {
930
- active: (s) => chalk2.green(s),
931
- done: (s) => chalk2.gray(s),
932
- idle: (s) => chalk2.gray(s)
933
- };
934
- var messageStyles = {
935
- active: (s) => chalk2.black(s),
936
- done: (s) => chalk2.green(chalk2.bold(s)),
937
- idle: (s) => chalk2.gray(s)
938
- };
939
- var mpb;
940
- function getSingletonProgressBars(options2) {
941
- if (!mpb) {
942
- mpb = new MultiProgressBars({
943
- initMessage: "",
944
- border: true,
945
- ...options2
946
- });
947
- }
948
- return mpb;
949
- }
950
- function getProgressBar(taskName) {
951
- const tasks = getSingletonProgressBars();
952
- tasks.addTask(taskName, {
953
- type: "percentage",
954
- percentage: 0,
955
- message: "",
956
- barTransformFn: barStyles.idle
957
- });
958
- return {
959
- incrementInSteps: (numPlugins) => {
960
- tasks.incrementTask(taskName, {
961
- percentage: 1 / numPlugins,
962
- barTransformFn: barStyles.active
963
- });
964
- },
965
- updateTitle: (title) => {
966
- tasks.updateTask(taskName, {
967
- message: title,
968
- barTransformFn: barStyles.active
969
- });
970
- },
971
- endProgress: (message = "") => {
972
- tasks.done(taskName, {
973
- message: messageStyles.done(message),
974
- barTransformFn: barStyles.done
975
- });
976
- }
977
- };
978
- }
979
-
980
927
  // packages/utils/src/lib/md/details.ts
981
928
  function details(title, content, cfg = { open: false }) {
982
929
  return `<details${cfg.open ? " open" : ""}>
@@ -1054,6 +1001,60 @@ function li(text, order = "unordered") {
1054
1001
  return `${style2} ${text}`;
1055
1002
  }
1056
1003
 
1004
+ // packages/utils/src/lib/progress.ts
1005
+ import chalk2 from "chalk";
1006
+ import { MultiProgressBars } from "multi-progress-bars";
1007
+ var barStyles = {
1008
+ active: (s) => chalk2.green(s),
1009
+ done: (s) => chalk2.gray(s),
1010
+ idle: (s) => chalk2.gray(s)
1011
+ };
1012
+ var messageStyles = {
1013
+ active: (s) => chalk2.black(s),
1014
+ done: (s) => chalk2.green(chalk2.bold(s)),
1015
+ idle: (s) => chalk2.gray(s)
1016
+ };
1017
+ var mpb;
1018
+ function getSingletonProgressBars(options2) {
1019
+ if (!mpb) {
1020
+ mpb = new MultiProgressBars({
1021
+ initMessage: "",
1022
+ border: true,
1023
+ ...options2
1024
+ });
1025
+ }
1026
+ return mpb;
1027
+ }
1028
+ function getProgressBar(taskName) {
1029
+ const tasks = getSingletonProgressBars();
1030
+ tasks.addTask(taskName, {
1031
+ type: "percentage",
1032
+ percentage: 0,
1033
+ message: "",
1034
+ barTransformFn: barStyles.idle
1035
+ });
1036
+ return {
1037
+ incrementInSteps: (numPlugins) => {
1038
+ tasks.incrementTask(taskName, {
1039
+ percentage: 1 / numPlugins,
1040
+ barTransformFn: barStyles.active
1041
+ });
1042
+ },
1043
+ updateTitle: (title) => {
1044
+ tasks.updateTask(taskName, {
1045
+ message: title,
1046
+ barTransformFn: barStyles.active
1047
+ });
1048
+ },
1049
+ endProgress: (message = "") => {
1050
+ tasks.done(taskName, {
1051
+ message: messageStyles.done(message),
1052
+ barTransformFn: barStyles.done
1053
+ });
1054
+ }
1055
+ };
1056
+ }
1057
+
1057
1058
  // packages/utils/src/lib/report-to-md.ts
1058
1059
  function reportToMd(report, commitData) {
1059
1060
  let md = reportToHeaderSection() + NEW_LINE;
@@ -1595,7 +1596,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
1595
1596
 
1596
1597
  // packages/core/package.json
1597
1598
  var name = "@code-pushup/core";
1598
- var version = "0.1.0";
1599
+ var version = "0.2.0";
1599
1600
 
1600
1601
  // packages/core/src/lib/implementation/collect.ts
1601
1602
  async function collect(options2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "bin": {
5
5
  "code-pushup": "index.js"
6
6
  },