@code-pushup/cli 0.8.0 → 0.8.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 +145 -148
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { spawn } from "child_process";
|
|
|
17
17
|
// packages/utils/src/lib/report.ts
|
|
18
18
|
import { join } from "path";
|
|
19
19
|
|
|
20
|
-
// packages/models/src/lib/
|
|
20
|
+
// packages/models/src/lib/audit.ts
|
|
21
21
|
import { z as z2 } from "zod";
|
|
22
22
|
|
|
23
23
|
// packages/models/src/lib/implementation/schemas.ts
|
|
@@ -157,13 +157,107 @@ function hasWeightedRefsInCategories(categoryRefs) {
|
|
|
157
157
|
return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
// packages/models/src/lib/audit.ts
|
|
161
|
+
var auditSchema = z2.object({
|
|
162
|
+
slug: slugSchema("ID (unique within plugin)")
|
|
163
|
+
}).merge(
|
|
164
|
+
metaSchema({
|
|
165
|
+
titleDescription: "Descriptive name",
|
|
166
|
+
descriptionDescription: "Description (markdown)",
|
|
167
|
+
docsUrlDescription: "Link to documentation (rationale)",
|
|
168
|
+
description: "List of scorable metrics for the given plugin"
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
var pluginAuditsSchema = z2.array(auditSchema, {
|
|
172
|
+
description: "List of audits maintained in a plugin"
|
|
173
|
+
}).refine(
|
|
174
|
+
(auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
|
|
175
|
+
(auditMetadata) => ({
|
|
176
|
+
message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
|
|
177
|
+
})
|
|
178
|
+
);
|
|
179
|
+
function duplicateSlugsInAuditsErrorMsg(audits) {
|
|
180
|
+
const duplicateRefs = getDuplicateSlugsInAudits(audits);
|
|
181
|
+
return `In plugin audits the slugs are not unique: ${errorItems(
|
|
182
|
+
duplicateRefs
|
|
183
|
+
)}`;
|
|
184
|
+
}
|
|
185
|
+
function getDuplicateSlugsInAudits(audits) {
|
|
186
|
+
return hasDuplicateStrings(audits.map(({ slug }) => slug));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// packages/models/src/lib/audit-issue.ts
|
|
190
|
+
import { z as z3 } from "zod";
|
|
191
|
+
var sourceFileLocationSchema = z3.object(
|
|
192
|
+
{
|
|
193
|
+
file: filePathSchema("Relative path to source file in Git repo"),
|
|
194
|
+
position: z3.object(
|
|
195
|
+
{
|
|
196
|
+
startLine: positiveIntSchema("Start line"),
|
|
197
|
+
startColumn: positiveIntSchema("Start column").optional(),
|
|
198
|
+
endLine: positiveIntSchema("End line").optional(),
|
|
199
|
+
endColumn: positiveIntSchema("End column").optional()
|
|
200
|
+
},
|
|
201
|
+
{ description: "Location in file" }
|
|
202
|
+
).optional()
|
|
203
|
+
},
|
|
204
|
+
{ description: "Source file location" }
|
|
205
|
+
);
|
|
206
|
+
var issueSeveritySchema = z3.enum(["info", "warning", "error"], {
|
|
207
|
+
description: "Severity level"
|
|
208
|
+
});
|
|
209
|
+
var issueSchema = z3.object(
|
|
210
|
+
{
|
|
211
|
+
message: z3.string({ description: "Descriptive error message" }).max(512),
|
|
212
|
+
severity: issueSeveritySchema,
|
|
213
|
+
source: sourceFileLocationSchema.optional()
|
|
214
|
+
},
|
|
215
|
+
{ description: "Issue information" }
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
// packages/models/src/lib/audit-output.ts
|
|
219
|
+
import { z as z4 } from "zod";
|
|
220
|
+
var auditOutputSchema = z4.object(
|
|
221
|
+
{
|
|
222
|
+
slug: slugSchema("Reference to audit"),
|
|
223
|
+
displayValue: z4.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional(),
|
|
224
|
+
value: positiveIntSchema("Raw numeric value"),
|
|
225
|
+
score: z4.number({
|
|
226
|
+
description: "Value between 0 and 1"
|
|
227
|
+
}).min(0).max(1),
|
|
228
|
+
details: z4.object(
|
|
229
|
+
{
|
|
230
|
+
issues: z4.array(issueSchema, { description: "List of findings" })
|
|
231
|
+
},
|
|
232
|
+
{ description: "Detailed information" }
|
|
233
|
+
).optional()
|
|
234
|
+
},
|
|
235
|
+
{ description: "Audit information" }
|
|
236
|
+
);
|
|
237
|
+
var auditOutputsSchema = z4.array(auditOutputSchema, {
|
|
238
|
+
description: "List of JSON formatted audit output emitted by the runner process of a plugin"
|
|
239
|
+
}).refine(
|
|
240
|
+
(audits) => !getDuplicateSlugsInAudits2(audits),
|
|
241
|
+
(audits) => ({ message: duplicateSlugsInAuditsErrorMsg2(audits) })
|
|
242
|
+
);
|
|
243
|
+
function duplicateSlugsInAuditsErrorMsg2(audits) {
|
|
244
|
+
const duplicateRefs = getDuplicateSlugsInAudits2(audits);
|
|
245
|
+
return `In plugin audits the slugs are not unique: ${errorItems(
|
|
246
|
+
duplicateRefs
|
|
247
|
+
)}`;
|
|
248
|
+
}
|
|
249
|
+
function getDuplicateSlugsInAudits2(audits) {
|
|
250
|
+
return hasDuplicateStrings(audits.map(({ slug }) => slug));
|
|
251
|
+
}
|
|
252
|
+
|
|
160
253
|
// packages/models/src/lib/category-config.ts
|
|
254
|
+
import { z as z5 } from "zod";
|
|
161
255
|
var categoryRefSchema = weightedRefSchema(
|
|
162
256
|
"Weighted references to audits and/or groups for the category",
|
|
163
257
|
"Slug of an audit or group (depending on `type`)"
|
|
164
258
|
).merge(
|
|
165
|
-
|
|
166
|
-
type:
|
|
259
|
+
z5.object({
|
|
260
|
+
type: z5.enum(["audit", "group"], {
|
|
167
261
|
description: "Discriminant for reference kind, affects where `slug` is looked up"
|
|
168
262
|
}),
|
|
169
263
|
plugin: slugSchema(
|
|
@@ -184,8 +278,8 @@ var categoryConfigSchema = scorableSchema(
|
|
|
184
278
|
description: "Meta info for category"
|
|
185
279
|
})
|
|
186
280
|
).merge(
|
|
187
|
-
|
|
188
|
-
isBinary:
|
|
281
|
+
z5.object({
|
|
282
|
+
isBinary: z5.boolean({
|
|
189
283
|
description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
|
|
190
284
|
}).optional()
|
|
191
285
|
})
|
|
@@ -201,7 +295,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
201
295
|
metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
|
|
202
296
|
);
|
|
203
297
|
}
|
|
204
|
-
var categoriesSchema =
|
|
298
|
+
var categoriesSchema = z5.array(categoryConfigSchema, {
|
|
205
299
|
description: "Categorization of individual audits"
|
|
206
300
|
}).min(1).refine(
|
|
207
301
|
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
@@ -223,68 +317,38 @@ function getDuplicateSlugCategories(categories) {
|
|
|
223
317
|
import { z as z11 } from "zod";
|
|
224
318
|
|
|
225
319
|
// packages/models/src/lib/persist-config.ts
|
|
226
|
-
import { z as
|
|
227
|
-
var formatSchema =
|
|
228
|
-
var persistConfigSchema =
|
|
320
|
+
import { z as z6 } from "zod";
|
|
321
|
+
var formatSchema = z6.enum(["json", "md"]);
|
|
322
|
+
var persistConfigSchema = z6.object({
|
|
229
323
|
outputDir: filePathSchema("Artifacts folder").optional(),
|
|
230
324
|
filename: fileNameSchema(
|
|
231
325
|
"Artifacts file name (without extension)"
|
|
232
326
|
).optional(),
|
|
233
|
-
format:
|
|
327
|
+
format: z6.array(formatSchema).optional()
|
|
234
328
|
});
|
|
235
329
|
|
|
236
330
|
// packages/models/src/lib/plugin-config.ts
|
|
237
331
|
import { z as z9 } from "zod";
|
|
238
332
|
|
|
239
|
-
// packages/models/src/lib/
|
|
240
|
-
import { z as
|
|
241
|
-
var
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
metaSchema({
|
|
245
|
-
titleDescription: "Descriptive name",
|
|
246
|
-
descriptionDescription: "Description (markdown)",
|
|
247
|
-
docsUrlDescription: "Link to documentation (rationale)",
|
|
248
|
-
description: "List of scorable metrics for the given plugin"
|
|
249
|
-
})
|
|
250
|
-
);
|
|
251
|
-
var pluginAuditsSchema = z4.array(auditSchema, {
|
|
252
|
-
description: "List of audits maintained in a plugin"
|
|
253
|
-
}).refine(
|
|
254
|
-
(auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
|
|
255
|
-
(auditMetadata) => ({
|
|
256
|
-
message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
|
|
257
|
-
})
|
|
258
|
-
);
|
|
259
|
-
function duplicateSlugsInAuditsErrorMsg(audits) {
|
|
260
|
-
const duplicateRefs = getDuplicateSlugsInAudits(audits);
|
|
261
|
-
return `In plugin audits the slugs are not unique: ${errorItems(
|
|
262
|
-
duplicateRefs
|
|
263
|
-
)}`;
|
|
264
|
-
}
|
|
265
|
-
function getDuplicateSlugsInAudits(audits) {
|
|
266
|
-
return hasDuplicateStrings(audits.map(({ slug }) => slug));
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// packages/models/src/lib/plugin-config-groups.ts
|
|
270
|
-
import { z as z5 } from "zod";
|
|
271
|
-
var auditGroupRefSchema = weightedRefSchema(
|
|
272
|
-
"Weighted references to audits",
|
|
273
|
-
"Reference slug to an audit within this plugin (e.g. 'max-lines')"
|
|
333
|
+
// packages/models/src/lib/group.ts
|
|
334
|
+
import { z as z7 } from "zod";
|
|
335
|
+
var groupRefSchema = weightedRefSchema(
|
|
336
|
+
"Weighted reference to a group",
|
|
337
|
+
"Reference slug to a group within this plugin (e.g. 'max-lines')"
|
|
274
338
|
);
|
|
275
|
-
var
|
|
339
|
+
var groupMetaSchema = metaSchema({
|
|
276
340
|
titleDescription: "Descriptive name for the group",
|
|
277
341
|
descriptionDescription: "Description of the group (markdown)",
|
|
278
342
|
docsUrlDescription: "Group documentation site",
|
|
279
343
|
description: "Group metadata"
|
|
280
344
|
});
|
|
281
|
-
var
|
|
282
|
-
'
|
|
283
|
-
|
|
345
|
+
var groupSchema = scorableSchema(
|
|
346
|
+
'A group aggregates a set of audits into a single score which can be referenced from a category. E.g. the group slug "performance" groups audits and can be referenced in a category',
|
|
347
|
+
groupRefSchema,
|
|
284
348
|
getDuplicateRefsInGroups,
|
|
285
349
|
duplicateRefsInGroupsErrorMsg
|
|
286
|
-
).merge(
|
|
287
|
-
var
|
|
350
|
+
).merge(groupMetaSchema);
|
|
351
|
+
var groupsSchema = z7.array(groupSchema, {
|
|
288
352
|
description: "List of groups"
|
|
289
353
|
}).optional().refine(
|
|
290
354
|
(groups) => !getDuplicateSlugsInGroups(groups),
|
|
@@ -292,16 +356,14 @@ var auditGroupsSchema = z5.array(auditGroupSchema, {
|
|
|
292
356
|
message: duplicateSlugsInGroupsErrorMsg(groups)
|
|
293
357
|
})
|
|
294
358
|
);
|
|
295
|
-
function duplicateRefsInGroupsErrorMsg(
|
|
296
|
-
const duplicateRefs = getDuplicateRefsInGroups(
|
|
297
|
-
return `In plugin groups the
|
|
359
|
+
function duplicateRefsInGroupsErrorMsg(groups) {
|
|
360
|
+
const duplicateRefs = getDuplicateRefsInGroups(groups);
|
|
361
|
+
return `In plugin groups the following references are not unique: ${errorItems(
|
|
298
362
|
duplicateRefs
|
|
299
363
|
)}`;
|
|
300
364
|
}
|
|
301
|
-
function getDuplicateRefsInGroups(
|
|
302
|
-
return hasDuplicateStrings(
|
|
303
|
-
groupAudits.map(({ slug: ref }) => ref).filter(exists)
|
|
304
|
-
);
|
|
365
|
+
function getDuplicateRefsInGroups(groups) {
|
|
366
|
+
return hasDuplicateStrings(groups.map(({ slug: ref }) => ref).filter(exists));
|
|
305
367
|
}
|
|
306
368
|
function duplicateSlugsInGroupsErrorMsg(groups) {
|
|
307
369
|
const duplicateRefs = getDuplicateSlugsInGroups(groups);
|
|
@@ -311,76 +373,8 @@ function getDuplicateSlugsInGroups(groups) {
|
|
|
311
373
|
return Array.isArray(groups) ? hasDuplicateStrings(groups.map(({ slug }) => slug)) : false;
|
|
312
374
|
}
|
|
313
375
|
|
|
314
|
-
// packages/models/src/lib/
|
|
376
|
+
// packages/models/src/lib/runner-config.ts
|
|
315
377
|
import { z as z8 } from "zod";
|
|
316
|
-
|
|
317
|
-
// packages/models/src/lib/plugin-process-output.ts
|
|
318
|
-
import { z as z7 } from "zod";
|
|
319
|
-
|
|
320
|
-
// packages/models/src/lib/plugin-process-output-audit-issue.ts
|
|
321
|
-
import { z as z6 } from "zod";
|
|
322
|
-
var sourceFileLocationSchema = z6.object(
|
|
323
|
-
{
|
|
324
|
-
file: filePathSchema("Relative path to source file in Git repo"),
|
|
325
|
-
position: z6.object(
|
|
326
|
-
{
|
|
327
|
-
startLine: positiveIntSchema("Start line"),
|
|
328
|
-
startColumn: positiveIntSchema("Start column").optional(),
|
|
329
|
-
endLine: positiveIntSchema("End line").optional(),
|
|
330
|
-
endColumn: positiveIntSchema("End column").optional()
|
|
331
|
-
},
|
|
332
|
-
{ description: "Location in file" }
|
|
333
|
-
).optional()
|
|
334
|
-
},
|
|
335
|
-
{ description: "Source file location" }
|
|
336
|
-
);
|
|
337
|
-
var issueSeveritySchema = z6.enum(["info", "warning", "error"], {
|
|
338
|
-
description: "Severity level"
|
|
339
|
-
});
|
|
340
|
-
var issueSchema = z6.object(
|
|
341
|
-
{
|
|
342
|
-
message: z6.string({ description: "Descriptive error message" }).max(512),
|
|
343
|
-
severity: issueSeveritySchema,
|
|
344
|
-
source: sourceFileLocationSchema.optional()
|
|
345
|
-
},
|
|
346
|
-
{ description: "Issue information" }
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
// packages/models/src/lib/plugin-process-output.ts
|
|
350
|
-
var auditOutputSchema = z7.object(
|
|
351
|
-
{
|
|
352
|
-
slug: slugSchema("Reference to audit"),
|
|
353
|
-
displayValue: z7.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional(),
|
|
354
|
-
value: positiveIntSchema("Raw numeric value"),
|
|
355
|
-
score: z7.number({
|
|
356
|
-
description: "Value between 0 and 1"
|
|
357
|
-
}).min(0).max(1),
|
|
358
|
-
details: z7.object(
|
|
359
|
-
{
|
|
360
|
-
issues: z7.array(issueSchema, { description: "List of findings" })
|
|
361
|
-
},
|
|
362
|
-
{ description: "Detailed information" }
|
|
363
|
-
).optional()
|
|
364
|
-
},
|
|
365
|
-
{ description: "Audit information" }
|
|
366
|
-
);
|
|
367
|
-
var auditOutputsSchema = z7.array(auditOutputSchema, {
|
|
368
|
-
description: "List of JSON formatted audit output emitted by the runner process of a plugin"
|
|
369
|
-
}).refine(
|
|
370
|
-
(audits) => !getDuplicateSlugsInAudits2(audits),
|
|
371
|
-
(audits) => ({ message: duplicateSlugsInAuditsErrorMsg2(audits) })
|
|
372
|
-
);
|
|
373
|
-
function duplicateSlugsInAuditsErrorMsg2(audits) {
|
|
374
|
-
const duplicateRefs = getDuplicateSlugsInAudits2(audits);
|
|
375
|
-
return `In plugin audits the slugs are not unique: ${errorItems(
|
|
376
|
-
duplicateRefs
|
|
377
|
-
)}`;
|
|
378
|
-
}
|
|
379
|
-
function getDuplicateSlugsInAudits2(audits) {
|
|
380
|
-
return hasDuplicateStrings(audits.map(({ slug }) => slug));
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// packages/models/src/lib/plugin-config-runner.ts
|
|
384
378
|
var outputTransformSchema = z8.function().args(z8.unknown()).returns(z8.union([auditOutputsSchema, z8.promise(auditOutputsSchema)]));
|
|
385
379
|
var runnerConfigSchema = z8.object(
|
|
386
380
|
{
|
|
@@ -417,7 +411,7 @@ var pluginMetaSchema = packageVersionSchema({
|
|
|
417
411
|
var pluginDataSchema = z9.object({
|
|
418
412
|
runner: z9.union([runnerConfigSchema, runnerFunctionSchema]),
|
|
419
413
|
audits: pluginAuditsSchema,
|
|
420
|
-
groups:
|
|
414
|
+
groups: groupsSchema
|
|
421
415
|
});
|
|
422
416
|
var pluginConfigSchema = pluginMetaSchema.merge(pluginDataSchema).refine(
|
|
423
417
|
(pluginCfg) => !getMissingRefsFromGroups(pluginCfg),
|
|
@@ -535,7 +529,7 @@ var pluginReportSchema = pluginMetaSchema.merge(
|
|
|
535
529
|
).merge(
|
|
536
530
|
z12.object({
|
|
537
531
|
audits: z12.array(auditReportSchema),
|
|
538
|
-
groups: z12.array(
|
|
532
|
+
groups: z12.array(groupSchema).optional()
|
|
539
533
|
})
|
|
540
534
|
);
|
|
541
535
|
var reportSchema = packageVersionSchema({
|
|
@@ -752,25 +746,28 @@ function calcDuration(start, stop) {
|
|
|
752
746
|
return Math.floor(stop - start);
|
|
753
747
|
}
|
|
754
748
|
function countCategoryAudits(refs, plugins) {
|
|
755
|
-
const groupLookup = plugins.reduce(
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
return {
|
|
760
|
-
...lookup,
|
|
761
|
-
[plugin.slug]: {
|
|
762
|
-
...plugin.groups.reduce(
|
|
763
|
-
(groupLookup2, group) => {
|
|
764
|
-
return {
|
|
765
|
-
...groupLookup2,
|
|
766
|
-
[group.slug]: group
|
|
767
|
-
};
|
|
768
|
-
},
|
|
769
|
-
{}
|
|
770
|
-
)
|
|
749
|
+
const groupLookup = plugins.reduce(
|
|
750
|
+
(lookup, plugin) => {
|
|
751
|
+
if (!plugin.groups.length) {
|
|
752
|
+
return lookup;
|
|
771
753
|
}
|
|
772
|
-
|
|
773
|
-
|
|
754
|
+
return {
|
|
755
|
+
...lookup,
|
|
756
|
+
[plugin.slug]: {
|
|
757
|
+
...plugin.groups.reduce(
|
|
758
|
+
(groupLookup2, group) => {
|
|
759
|
+
return {
|
|
760
|
+
...groupLookup2,
|
|
761
|
+
[group.slug]: group
|
|
762
|
+
};
|
|
763
|
+
},
|
|
764
|
+
{}
|
|
765
|
+
)
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
},
|
|
769
|
+
{}
|
|
770
|
+
);
|
|
774
771
|
return refs.reduce((acc, ref) => {
|
|
775
772
|
if (ref.type === "group") {
|
|
776
773
|
const groupRefs = groupLookup[ref.plugin]?.[ref.slug]?.refs;
|
|
@@ -1647,7 +1644,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1647
1644
|
|
|
1648
1645
|
// packages/core/package.json
|
|
1649
1646
|
var name = "@code-pushup/core";
|
|
1650
|
-
var version = "0.8.
|
|
1647
|
+
var version = "0.8.2";
|
|
1651
1648
|
|
|
1652
1649
|
// packages/core/src/lib/implementation/collect.ts
|
|
1653
1650
|
async function collect(options2) {
|