@code-pushup/core 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.
Files changed (2) hide show
  1. package/index.js +72 -67
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -16,6 +16,11 @@ import { z as z2 } from "zod";
16
16
  import { z } from "zod";
17
17
  import { MATERIAL_ICONS } from "@code-pushup/portal-client";
18
18
 
19
+ // packages/models/src/lib/implementation/limits.ts
20
+ var MAX_SLUG_LENGTH = 128;
21
+ var MAX_TITLE_LENGTH = 256;
22
+ var MAX_DESCRIPTION_LENGTH = 65536;
23
+
19
24
  // packages/models/src/lib/implementation/utils.ts
20
25
  var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
21
26
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
@@ -51,12 +56,12 @@ function executionMetaSchema(options = {
51
56
  function slugSchema(description = "Unique ID (human-readable, URL-safe)") {
52
57
  return z.string({ description }).regex(slugRegex, {
53
58
  message: "The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug"
54
- }).max(128, {
55
- message: "slug can be max 128 characters long"
59
+ }).max(MAX_SLUG_LENGTH, {
60
+ message: `slug can be max ${MAX_SLUG_LENGTH} characters long`
56
61
  });
57
62
  }
58
63
  function descriptionSchema(description = "Description (markdown)") {
59
- return z.string({ description }).max(65536).optional();
64
+ return z.string({ description }).max(MAX_DESCRIPTION_LENGTH).optional();
60
65
  }
61
66
  function docsUrlSchema(description = "Documentation site") {
62
67
  return urlSchema(description).optional().or(z.string().max(0));
@@ -65,7 +70,7 @@ function urlSchema(description) {
65
70
  return z.string({ description }).url();
66
71
  }
67
72
  function titleSchema(description = "Descriptive name") {
68
- return z.string({ description }).max(256);
73
+ return z.string({ description }).max(MAX_TITLE_LENGTH);
69
74
  }
70
75
  function metaSchema(options) {
71
76
  const {
@@ -598,6 +603,14 @@ function logPromiseResults(results, logMessage, callback) {
598
603
  }
599
604
 
600
605
  // packages/utils/src/lib/file-system.ts
606
+ async function readTextFile(path) {
607
+ const buffer = await readFile(path);
608
+ return buffer.toString();
609
+ }
610
+ async function readJsonFile(path) {
611
+ const text = await readTextFile(path);
612
+ return JSON.parse(text);
613
+ }
601
614
  async function ensureDirectoryExists(baseDir) {
602
615
  try {
603
616
  await mkdir(baseDir, { recursive: true });
@@ -609,14 +622,6 @@ async function ensureDirectoryExists(baseDir) {
609
622
  }
610
623
  }
611
624
  }
612
- async function readTextFile(path) {
613
- const buffer = await readFile(path);
614
- return buffer.toString();
615
- }
616
- async function readJsonFile(path) {
617
- const text = await readTextFile(path);
618
- return JSON.parse(text);
619
- }
620
625
  function logMultipleFileResults(fileResults, messagePrefix) {
621
626
  const succeededCallback = (result) => {
622
627
  const [fileName, size] = result.value;
@@ -916,60 +921,6 @@ async function getLatestCommit() {
916
921
  return log?.latest;
917
922
  }
918
923
 
919
- // packages/utils/src/lib/progress.ts
920
- import chalk2 from "chalk";
921
- import { MultiProgressBars } from "multi-progress-bars";
922
- var barStyles = {
923
- active: (s) => chalk2.green(s),
924
- done: (s) => chalk2.gray(s),
925
- idle: (s) => chalk2.gray(s)
926
- };
927
- var messageStyles = {
928
- active: (s) => chalk2.black(s),
929
- done: (s) => chalk2.green(chalk2.bold(s)),
930
- idle: (s) => chalk2.gray(s)
931
- };
932
- var mpb;
933
- function getSingletonProgressBars(options) {
934
- if (!mpb) {
935
- mpb = new MultiProgressBars({
936
- initMessage: "",
937
- border: true,
938
- ...options
939
- });
940
- }
941
- return mpb;
942
- }
943
- function getProgressBar(taskName) {
944
- const tasks = getSingletonProgressBars();
945
- tasks.addTask(taskName, {
946
- type: "percentage",
947
- percentage: 0,
948
- message: "",
949
- barTransformFn: barStyles.idle
950
- });
951
- return {
952
- incrementInSteps: (numPlugins) => {
953
- tasks.incrementTask(taskName, {
954
- percentage: 1 / numPlugins,
955
- barTransformFn: barStyles.active
956
- });
957
- },
958
- updateTitle: (title) => {
959
- tasks.updateTask(taskName, {
960
- message: title,
961
- barTransformFn: barStyles.active
962
- });
963
- },
964
- endProgress: (message = "") => {
965
- tasks.done(taskName, {
966
- message: messageStyles.done(message),
967
- barTransformFn: barStyles.done
968
- });
969
- }
970
- };
971
- }
972
-
973
924
  // packages/utils/src/lib/md/details.ts
974
925
  function details(title, content, cfg = { open: false }) {
975
926
  return `<details${cfg.open ? " open" : ""}>
@@ -1047,6 +998,60 @@ function li(text, order = "unordered") {
1047
998
  return `${style2} ${text}`;
1048
999
  }
1049
1000
 
1001
+ // packages/utils/src/lib/progress.ts
1002
+ import chalk2 from "chalk";
1003
+ import { MultiProgressBars } from "multi-progress-bars";
1004
+ var barStyles = {
1005
+ active: (s) => chalk2.green(s),
1006
+ done: (s) => chalk2.gray(s),
1007
+ idle: (s) => chalk2.gray(s)
1008
+ };
1009
+ var messageStyles = {
1010
+ active: (s) => chalk2.black(s),
1011
+ done: (s) => chalk2.green(chalk2.bold(s)),
1012
+ idle: (s) => chalk2.gray(s)
1013
+ };
1014
+ var mpb;
1015
+ function getSingletonProgressBars(options) {
1016
+ if (!mpb) {
1017
+ mpb = new MultiProgressBars({
1018
+ initMessage: "",
1019
+ border: true,
1020
+ ...options
1021
+ });
1022
+ }
1023
+ return mpb;
1024
+ }
1025
+ function getProgressBar(taskName) {
1026
+ const tasks = getSingletonProgressBars();
1027
+ tasks.addTask(taskName, {
1028
+ type: "percentage",
1029
+ percentage: 0,
1030
+ message: "",
1031
+ barTransformFn: barStyles.idle
1032
+ });
1033
+ return {
1034
+ incrementInSteps: (numPlugins) => {
1035
+ tasks.incrementTask(taskName, {
1036
+ percentage: 1 / numPlugins,
1037
+ barTransformFn: barStyles.active
1038
+ });
1039
+ },
1040
+ updateTitle: (title) => {
1041
+ tasks.updateTask(taskName, {
1042
+ message: title,
1043
+ barTransformFn: barStyles.active
1044
+ });
1045
+ },
1046
+ endProgress: (message = "") => {
1047
+ tasks.done(taskName, {
1048
+ message: messageStyles.done(message),
1049
+ barTransformFn: barStyles.done
1050
+ });
1051
+ }
1052
+ };
1053
+ }
1054
+
1050
1055
  // packages/utils/src/lib/report-to-md.ts
1051
1056
  function reportToMd(report, commitData) {
1052
1057
  let md = reportToHeaderSection() + NEW_LINE;
@@ -1588,7 +1593,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
1588
1593
 
1589
1594
  // packages/core/package.json
1590
1595
  var name = "@code-pushup/core";
1591
- var version = "0.1.1";
1596
+ var version = "0.3.0";
1592
1597
 
1593
1598
  // packages/core/src/lib/implementation/collect.ts
1594
1599
  async function collect(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/core",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "dependencies": {
5
5
  "@code-pushup/models": "*",
6
6
  "@code-pushup/utils": "*",