@code-pushup/core 0.2.0 → 0.3.1

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 +21 -10
  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 {
@@ -606,6 +611,14 @@ async function readJsonFile(path) {
606
611
  const text = await readTextFile(path);
607
612
  return JSON.parse(text);
608
613
  }
614
+ async function fileExists(path) {
615
+ try {
616
+ const stats = await stat(path);
617
+ return stats.isFile();
618
+ } catch {
619
+ return false;
620
+ }
621
+ }
609
622
  async function ensureDirectoryExists(baseDir) {
610
623
  try {
611
624
  await mkdir(baseDir, { recursive: true });
@@ -1588,7 +1601,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
1588
1601
 
1589
1602
  // packages/core/package.json
1590
1603
  var name = "@code-pushup/core";
1591
- var version = "0.2.0";
1604
+ var version = "0.3.1";
1592
1605
 
1593
1606
  // packages/core/src/lib/implementation/collect.ts
1594
1607
  async function collect(options) {
@@ -1723,18 +1736,16 @@ async function collectAndPersistReports(options) {
1723
1736
  }
1724
1737
 
1725
1738
  // packages/core/src/lib/implementation/read-code-pushup-config.ts
1726
- import { stat as stat3 } from "fs/promises";
1727
1739
  var ConfigPathError = class extends Error {
1728
1740
  constructor(configPath) {
1729
- super(`Config path ${configPath} is not a file.`);
1741
+ super(`Provided path '${configPath}' is not valid.`);
1730
1742
  }
1731
1743
  };
1732
1744
  async function readCodePushupConfig(filepath) {
1733
1745
  if (!filepath.length) {
1734
- throw new Error("No filepath provided");
1746
+ throw new Error("The configuration path is empty.");
1735
1747
  }
1736
- const isFile = (await stat3(filepath)).isFile();
1737
- if (!isFile) {
1748
+ if (!await fileExists(filepath)) {
1738
1749
  throw new ConfigPathError(filepath);
1739
1750
  }
1740
1751
  return importEsmModule(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/core",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "dependencies": {
5
5
  "@code-pushup/models": "*",
6
6
  "@code-pushup/utils": "*",