@code-pushup/models 0.8.20 → 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.
- package/index.js +12 -23
- package/package.json +1 -1
- package/src/lib/implementation/utils.d.ts +1 -1
package/index.js
CHANGED
|
@@ -12,59 +12,48 @@ var MAX_DESCRIPTION_LENGTH = 65536;
|
|
|
12
12
|
var MAX_ISSUE_MESSAGE_LENGTH = 1024;
|
|
13
13
|
|
|
14
14
|
// packages/models/src/lib/implementation/utils.ts
|
|
15
|
-
var slugRegex = /^[a-
|
|
15
|
+
var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
|
|
16
16
|
var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
|
|
17
17
|
function hasDuplicateStrings(strings) {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
18
|
+
const sortedStrings = [...strings].sort();
|
|
19
|
+
const duplStrings = sortedStrings.filter(
|
|
20
|
+
(item, index) => index !== 0 && item === sortedStrings[index - 1]
|
|
21
21
|
);
|
|
22
|
-
return
|
|
22
|
+
return duplStrings.length === 0 ? false : [...new Set(duplStrings)];
|
|
23
23
|
}
|
|
24
24
|
function hasMissingStrings(toCheck, existing) {
|
|
25
25
|
const nonExisting = toCheck.filter((s) => !existing.includes(s));
|
|
26
26
|
return nonExisting.length === 0 ? false : nonExisting;
|
|
27
27
|
}
|
|
28
|
-
function errorItems(items, transform = (
|
|
29
|
-
|
|
30
|
-
return transform(paredItems);
|
|
28
|
+
function errorItems(items, transform = (itemArr) => itemArr.join(", ")) {
|
|
29
|
+
return transform(items || []);
|
|
31
30
|
}
|
|
32
31
|
function exists(value) {
|
|
33
32
|
return value != null;
|
|
34
33
|
}
|
|
35
34
|
function getMissingRefsForCategories(categories, plugins) {
|
|
36
|
-
const missingRefs = [];
|
|
37
35
|
const auditRefsFromCategory = categories.flatMap(
|
|
38
36
|
({ refs }) => refs.filter(({ type }) => type === "audit").map(({ plugin, slug }) => `${plugin}/${slug}`)
|
|
39
37
|
);
|
|
40
38
|
const auditRefsFromPlugins = plugins.flatMap(
|
|
41
|
-
({ audits, slug: pluginSlug }) => {
|
|
42
|
-
return audits.map(({ slug }) => `${pluginSlug}/${slug}`);
|
|
43
|
-
}
|
|
39
|
+
({ audits, slug: pluginSlug }) => audits.map(({ slug }) => `${pluginSlug}/${slug}`)
|
|
44
40
|
);
|
|
45
41
|
const missingAuditRefs = hasMissingStrings(
|
|
46
42
|
auditRefsFromCategory,
|
|
47
43
|
auditRefsFromPlugins
|
|
48
44
|
);
|
|
49
|
-
if (Array.isArray(missingAuditRefs) && missingAuditRefs.length > 0) {
|
|
50
|
-
missingRefs.push(...missingAuditRefs);
|
|
51
|
-
}
|
|
52
45
|
const groupRefsFromCategory = categories.flatMap(
|
|
53
46
|
({ refs }) => refs.filter(({ type }) => type === "group").map(({ plugin, slug }) => `${plugin}#${slug} (group)`)
|
|
54
47
|
);
|
|
55
48
|
const groupRefsFromPlugins = plugins.flatMap(
|
|
56
|
-
({ groups, slug: pluginSlug }) => {
|
|
57
|
-
return Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : [];
|
|
58
|
-
}
|
|
49
|
+
({ groups, slug: pluginSlug }) => Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : []
|
|
59
50
|
);
|
|
60
51
|
const missingGroupRefs = hasMissingStrings(
|
|
61
52
|
groupRefsFromCategory,
|
|
62
53
|
groupRefsFromPlugins
|
|
63
54
|
);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
return missingRefs.length ? missingRefs : false;
|
|
55
|
+
const missingRefs = [missingAuditRefs, missingGroupRefs].filter((refs) => Array.isArray(refs) && refs.length > 0).flat();
|
|
56
|
+
return missingRefs.length > 0 ? missingRefs : false;
|
|
68
57
|
}
|
|
69
58
|
function missingRefsForCategoriesErrorMsg(categories, plugins) {
|
|
70
59
|
const missingRefs = getMissingRefsForCategories(categories, plugins);
|
|
@@ -108,7 +97,7 @@ function metaSchema(options) {
|
|
|
108
97
|
titleDescription,
|
|
109
98
|
docsUrlDescription,
|
|
110
99
|
description
|
|
111
|
-
} = options
|
|
100
|
+
} = options ?? {};
|
|
112
101
|
return z.object(
|
|
113
102
|
{
|
|
114
103
|
title: titleSchema(titleDescription),
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ export declare function hasMissingStrings(toCheck: string[], existing: string[])
|
|
|
28
28
|
/**
|
|
29
29
|
* helper for error items
|
|
30
30
|
*/
|
|
31
|
-
export declare function errorItems(items: string[] | false, transform?: (
|
|
31
|
+
export declare function errorItems(items: string[] | false, transform?: (itemArr: string[]) => string): string;
|
|
32
32
|
export declare function exists<T>(value: T): value is NonNullable<T>;
|
|
33
33
|
/**
|
|
34
34
|
* Get category references that do not point to any audit or group
|