@code-pushup/utils 0.5.0 → 0.5.2
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 +23 -22
- 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,10 +213,10 @@ 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
|
-
),
|
|
216
|
+
outputDir: filePathSchema("Artifacts folder").optional(),
|
|
217
|
+
filename: fileNameSchema(
|
|
218
|
+
"Artifacts file name (without extension)"
|
|
219
|
+
).optional(),
|
|
203
220
|
format: z3.array(formatSchema).default(["json"]).optional()
|
|
204
221
|
// @TODO remove default or optional value and otherwise it will not set defaults.
|
|
205
222
|
});
|
|
@@ -435,17 +452,10 @@ var unrefinedCoreConfigSchema = z11.object({
|
|
|
435
452
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
436
453
|
}),
|
|
437
454
|
/** portal configuration for persisting results */
|
|
438
|
-
persist: persistConfigSchema,
|
|
455
|
+
persist: persistConfigSchema.optional(),
|
|
439
456
|
/** portal configuration for uploading results */
|
|
440
457
|
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
|
-
)
|
|
458
|
+
categories: categoriesSchema
|
|
449
459
|
});
|
|
450
460
|
var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
|
|
451
461
|
function refineCoreConfig(schema) {
|
|
@@ -496,15 +506,6 @@ function getMissingRefsForCategories(coreCfg) {
|
|
|
496
506
|
}
|
|
497
507
|
return missingRefs.length ? missingRefs : false;
|
|
498
508
|
}
|
|
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
509
|
|
|
509
510
|
// packages/models/src/lib/report.ts
|
|
510
511
|
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;
|