@code-pushup/utils 0.5.0 → 0.5.3
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 +24 -24
- package/package.json +1 -1
- package/src/lib/file-system.d.ts +1 -1
package/index.js
CHANGED
|
@@ -188,6 +188,23 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
188
188
|
metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
|
+
var categoriesSchema = z2.array(categoryConfigSchema, {
|
|
192
|
+
description: "Categorization of individual audits"
|
|
193
|
+
}).min(1).refine(
|
|
194
|
+
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
195
|
+
(categoryCfg) => ({
|
|
196
|
+
message: duplicateSlugCategoriesErrorMsg(categoryCfg)
|
|
197
|
+
})
|
|
198
|
+
);
|
|
199
|
+
function duplicateSlugCategoriesErrorMsg(categories) {
|
|
200
|
+
const duplicateStringSlugs = getDuplicateSlugCategories(categories);
|
|
201
|
+
return `In the categories, the following slugs are duplicated: ${errorItems(
|
|
202
|
+
duplicateStringSlugs
|
|
203
|
+
)}`;
|
|
204
|
+
}
|
|
205
|
+
function getDuplicateSlugCategories(categories) {
|
|
206
|
+
return hasDuplicateStrings(categories.map(({ slug }) => slug));
|
|
207
|
+
}
|
|
191
208
|
|
|
192
209
|
// packages/models/src/lib/core-config.ts
|
|
193
210
|
import { z as z11 } from "zod";
|
|
@@ -196,12 +213,11 @@ import { z as z11 } from "zod";
|
|
|
196
213
|
import { z as z3 } from "zod";
|
|
197
214
|
var formatSchema = z3.enum(["json", "md"]);
|
|
198
215
|
var persistConfigSchema = z3.object({
|
|
199
|
-
outputDir: filePathSchema("Artifacts folder"),
|
|
200
|
-
filename: fileNameSchema(
|
|
201
|
-
"
|
|
202
|
-
),
|
|
203
|
-
format: z3.array(formatSchema).
|
|
204
|
-
// @TODO remove default or optional value and otherwise it will not set defaults.
|
|
216
|
+
outputDir: filePathSchema("Artifacts folder").optional(),
|
|
217
|
+
filename: fileNameSchema(
|
|
218
|
+
"Artifacts file name (without extension)"
|
|
219
|
+
).optional(),
|
|
220
|
+
format: z3.array(formatSchema).optional()
|
|
205
221
|
});
|
|
206
222
|
|
|
207
223
|
// packages/models/src/lib/plugin-config.ts
|
|
@@ -435,17 +451,10 @@ var unrefinedCoreConfigSchema = z11.object({
|
|
|
435
451
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
436
452
|
}),
|
|
437
453
|
/** portal configuration for persisting results */
|
|
438
|
-
persist: persistConfigSchema,
|
|
454
|
+
persist: persistConfigSchema.optional(),
|
|
439
455
|
/** portal configuration for uploading results */
|
|
440
456
|
upload: uploadConfigSchema.optional(),
|
|
441
|
-
categories:
|
|
442
|
-
description: "Categorization of individual audits"
|
|
443
|
-
}).min(1).refine(
|
|
444
|
-
(categories) => !getDuplicateSlugCategories(categories),
|
|
445
|
-
(categories) => ({
|
|
446
|
-
message: duplicateSlugCategoriesErrorMsg(categories)
|
|
447
|
-
})
|
|
448
|
-
)
|
|
457
|
+
categories: categoriesSchema
|
|
449
458
|
});
|
|
450
459
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
451
460
|
function refineCoreConfig(schema) {
|
|
@@ -496,15 +505,6 @@ function getMissingRefsForCategories(coreCfg) {
|
|
|
496
505
|
}
|
|
497
506
|
return missingRefs.length ? missingRefs : false;
|
|
498
507
|
}
|
|
499
|
-
function duplicateSlugCategoriesErrorMsg(categories) {
|
|
500
|
-
const duplicateStringSlugs = getDuplicateSlugCategories(categories);
|
|
501
|
-
return `In the categories, the following slugs are duplicated: ${errorItems(
|
|
502
|
-
duplicateStringSlugs
|
|
503
|
-
)}`;
|
|
504
|
-
}
|
|
505
|
-
function getDuplicateSlugCategories(categories) {
|
|
506
|
-
return hasDuplicateStrings(categories.map(({ slug }) => slug));
|
|
507
|
-
}
|
|
508
508
|
|
|
509
509
|
// packages/models/src/lib/report.ts
|
|
510
510
|
import { z as z12 } from "zod";
|
package/package.json
CHANGED
package/src/lib/file-system.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function logMultipleFileResults(fileResults: MultipleFileResults,
|
|
|
12
12
|
export declare class NoExportError extends Error {
|
|
13
13
|
constructor(filepath: string);
|
|
14
14
|
}
|
|
15
|
-
export declare function importEsmModule<T = unknown>(options: Options, parse?: (d:
|
|
15
|
+
export declare function importEsmModule<T = unknown>(options: Options, parse?: (d: any) => T): Promise<T>;
|
|
16
16
|
export declare function pluginWorkDir(slug: string): string;
|
|
17
17
|
export type CrawlFileSystemOptions<T> = {
|
|
18
18
|
directory: string;
|