@code-pushup/core 0.8.19 → 0.8.21

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 +13 -24
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -22,59 +22,48 @@ var MAX_DESCRIPTION_LENGTH = 65536;
22
22
  var MAX_ISSUE_MESSAGE_LENGTH = 1024;
23
23
 
24
24
  // packages/models/src/lib/implementation/utils.ts
25
- var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
25
+ var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
26
26
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
27
27
  function hasDuplicateStrings(strings) {
28
- const uniqueStrings = Array.from(new Set(strings));
29
- const duplicatedStrings = strings.filter(
30
- /* @__PURE__ */ ((i) => (v) => uniqueStrings[i] !== v || !++i)(0)
28
+ const sortedStrings = [...strings].sort();
29
+ const duplStrings = sortedStrings.filter(
30
+ (item, index) => index !== 0 && item === sortedStrings[index - 1]
31
31
  );
32
- return duplicatedStrings.length === 0 ? false : duplicatedStrings;
32
+ return duplStrings.length === 0 ? false : [...new Set(duplStrings)];
33
33
  }
34
34
  function hasMissingStrings(toCheck, existing) {
35
35
  const nonExisting = toCheck.filter((s) => !existing.includes(s));
36
36
  return nonExisting.length === 0 ? false : nonExisting;
37
37
  }
38
- function errorItems(items, transform = (items2) => items2.join(", ")) {
39
- const paredItems = items ? items : [];
40
- return transform(paredItems);
38
+ function errorItems(items, transform = (itemArr) => itemArr.join(", ")) {
39
+ return transform(items || []);
41
40
  }
42
41
  function exists(value) {
43
42
  return value != null;
44
43
  }
45
44
  function getMissingRefsForCategories(categories, plugins) {
46
- const missingRefs = [];
47
45
  const auditRefsFromCategory = categories.flatMap(
48
46
  ({ refs }) => refs.filter(({ type }) => type === "audit").map(({ plugin, slug }) => `${plugin}/${slug}`)
49
47
  );
50
48
  const auditRefsFromPlugins = plugins.flatMap(
51
- ({ audits, slug: pluginSlug }) => {
52
- return audits.map(({ slug }) => `${pluginSlug}/${slug}`);
53
- }
49
+ ({ audits, slug: pluginSlug }) => audits.map(({ slug }) => `${pluginSlug}/${slug}`)
54
50
  );
55
51
  const missingAuditRefs = hasMissingStrings(
56
52
  auditRefsFromCategory,
57
53
  auditRefsFromPlugins
58
54
  );
59
- if (Array.isArray(missingAuditRefs) && missingAuditRefs.length > 0) {
60
- missingRefs.push(...missingAuditRefs);
61
- }
62
55
  const groupRefsFromCategory = categories.flatMap(
63
56
  ({ refs }) => refs.filter(({ type }) => type === "group").map(({ plugin, slug }) => `${plugin}#${slug} (group)`)
64
57
  );
65
58
  const groupRefsFromPlugins = plugins.flatMap(
66
- ({ groups, slug: pluginSlug }) => {
67
- return Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : [];
68
- }
59
+ ({ groups, slug: pluginSlug }) => Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : []
69
60
  );
70
61
  const missingGroupRefs = hasMissingStrings(
71
62
  groupRefsFromCategory,
72
63
  groupRefsFromPlugins
73
64
  );
74
- if (Array.isArray(missingGroupRefs) && missingGroupRefs.length > 0) {
75
- missingRefs.push(...missingGroupRefs);
76
- }
77
- return missingRefs.length ? missingRefs : false;
65
+ const missingRefs = [missingAuditRefs, missingGroupRefs].filter((refs) => Array.isArray(refs) && refs.length > 0).flat();
66
+ return missingRefs.length > 0 ? missingRefs : false;
78
67
  }
79
68
  function missingRefsForCategoriesErrorMsg(categories, plugins) {
80
69
  const missingRefs = getMissingRefsForCategories(categories, plugins);
@@ -118,7 +107,7 @@ function metaSchema(options) {
118
107
  titleDescription,
119
108
  docsUrlDescription,
120
109
  description
121
- } = options || {};
110
+ } = options ?? {};
122
111
  return z.object(
123
112
  {
124
113
  title: titleSchema(titleDescription),
@@ -1717,7 +1706,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
1717
1706
 
1718
1707
  // packages/core/package.json
1719
1708
  var name = "@code-pushup/core";
1720
- var version = "0.8.19";
1709
+ var version = "0.8.21";
1721
1710
 
1722
1711
  // packages/core/src/lib/implementation/collect.ts
1723
1712
  async function collect(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/core",
3
- "version": "0.8.19",
3
+ "version": "0.8.21",
4
4
  "dependencies": {
5
5
  "@code-pushup/models": "*",
6
6
  "@code-pushup/utils": "*",