@code-pushup/cli 0.19.0 → 0.20.1
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/README.md +4 -0
- package/index.js +60 -72
- package/package.json +1 -1
- package/src/lib/implementation/only-plugins.utils.d.ts +1 -1
package/README.md
CHANGED
|
@@ -147,6 +147,10 @@ jobs:
|
|
|
147
147
|
- run: npx code-pushup autorun --upload.apiKey=${{ secrets.PORTAL_API_KEY }}
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
+
## Configuration
|
|
151
|
+
|
|
152
|
+
For a comprehensive list of all options available in the config file, refer to [`CoreConfig` docs](../models/docs/models-reference.md#coreconfig).
|
|
153
|
+
|
|
150
154
|
## Custom Plugins
|
|
151
155
|
|
|
152
156
|
We provide comprehensive documentation on [how to create a custom plugin](./docs/custom-plugins.md).
|
package/index.js
CHANGED
|
@@ -83,25 +83,15 @@ function executionMetaSchema(options2 = {
|
|
|
83
83
|
duration: z.number({ description: options2.descriptionDuration })
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
function docsUrlSchema(description = "Documentation site") {
|
|
97
|
-
return urlSchema(description).optional().or(z.string().max(0));
|
|
98
|
-
}
|
|
99
|
-
function urlSchema(description) {
|
|
100
|
-
return z.string({ description }).url();
|
|
101
|
-
}
|
|
102
|
-
function titleSchema(description = "Descriptive name") {
|
|
103
|
-
return z.string({ description }).max(MAX_TITLE_LENGTH);
|
|
104
|
-
}
|
|
86
|
+
var slugSchema = z.string({ description: "Unique ID (human-readable, URL-safe)" }).regex(slugRegex, {
|
|
87
|
+
message: "The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug"
|
|
88
|
+
}).max(MAX_SLUG_LENGTH, {
|
|
89
|
+
message: `slug can be max ${MAX_SLUG_LENGTH} characters long`
|
|
90
|
+
});
|
|
91
|
+
var descriptionSchema = z.string({ description: "Description (markdown)" }).max(MAX_DESCRIPTION_LENGTH).optional();
|
|
92
|
+
var urlSchema = z.string().url();
|
|
93
|
+
var docsUrlSchema = urlSchema.optional().or(z.literal("")).describe("Documentation site");
|
|
94
|
+
var titleSchema = z.string({ description: "Descriptive name" }).max(MAX_TITLE_LENGTH);
|
|
105
95
|
function metaSchema(options2) {
|
|
106
96
|
const {
|
|
107
97
|
descriptionDescription,
|
|
@@ -111,24 +101,19 @@ function metaSchema(options2) {
|
|
|
111
101
|
} = options2 ?? {};
|
|
112
102
|
return z.object(
|
|
113
103
|
{
|
|
114
|
-
title: titleSchema(titleDescription),
|
|
115
|
-
description: descriptionSchema(descriptionDescription),
|
|
116
|
-
docsUrl: docsUrlSchema(docsUrlDescription)
|
|
104
|
+
title: titleDescription ? titleSchema.describe(titleDescription) : titleSchema,
|
|
105
|
+
description: descriptionDescription ? descriptionSchema.describe(descriptionDescription) : descriptionSchema,
|
|
106
|
+
docsUrl: docsUrlDescription ? docsUrlSchema.describe(docsUrlDescription) : docsUrlSchema
|
|
117
107
|
},
|
|
118
108
|
{ description }
|
|
119
109
|
);
|
|
120
110
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}).min(1, { message: "file name is invalid" });
|
|
128
|
-
}
|
|
129
|
-
function positiveIntSchema(description) {
|
|
130
|
-
return z.number({ description }).int().nonnegative();
|
|
131
|
-
}
|
|
111
|
+
var filePathSchema = z.string().trim().min(1, { message: "path is invalid" });
|
|
112
|
+
var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
113
|
+
message: `The filename has to be valid`
|
|
114
|
+
}).min(1, { message: "file name is invalid" });
|
|
115
|
+
var positiveIntSchema = z.number().int().positive();
|
|
116
|
+
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
132
117
|
function packageVersionSchema(options2) {
|
|
133
118
|
const { versionDescription = "NPM version of the package", required } = options2 ?? {};
|
|
134
119
|
const packageSchema = z.string({ description: "NPM package name" });
|
|
@@ -141,14 +126,14 @@ function packageVersionSchema(options2) {
|
|
|
141
126
|
{ description: "NPM package name and version of a published package" }
|
|
142
127
|
);
|
|
143
128
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
129
|
+
var weightSchema = nonnegativeIntSchema.describe(
|
|
130
|
+
"Coefficient for the given score (use weight 0 if only for display)"
|
|
131
|
+
);
|
|
147
132
|
function weightedRefSchema(description, slugDescription) {
|
|
148
133
|
return z.object(
|
|
149
134
|
{
|
|
150
|
-
slug: slugSchema(slugDescription),
|
|
151
|
-
weight: weightSchema("Weight used to calculate score")
|
|
135
|
+
slug: slugSchema.describe(slugDescription),
|
|
136
|
+
weight: weightSchema.describe("Weight used to calculate score")
|
|
152
137
|
},
|
|
153
138
|
{ description }
|
|
154
139
|
);
|
|
@@ -156,14 +141,14 @@ function weightedRefSchema(description, slugDescription) {
|
|
|
156
141
|
function scorableSchema(description, refSchema, duplicateCheckFn, duplicateMessageFn) {
|
|
157
142
|
return z.object(
|
|
158
143
|
{
|
|
159
|
-
slug: slugSchema('Human-readable unique ID, e.g. "performance"'),
|
|
144
|
+
slug: slugSchema.describe('Human-readable unique ID, e.g. "performance"'),
|
|
160
145
|
refs: z.array(refSchema).min(1).refine(
|
|
161
146
|
(refs) => !duplicateCheckFn(refs),
|
|
162
147
|
(refs) => ({
|
|
163
148
|
message: duplicateMessageFn(refs)
|
|
164
149
|
})
|
|
165
|
-
).refine(
|
|
166
|
-
message:
|
|
150
|
+
).refine(hasNonZeroWeightedRef, () => ({
|
|
151
|
+
message: "In a category there has to be at least one ref with weight > 0"
|
|
167
152
|
}))
|
|
168
153
|
},
|
|
169
154
|
{ description }
|
|
@@ -172,13 +157,13 @@ function scorableSchema(description, refSchema, duplicateCheckFn, duplicateMessa
|
|
|
172
157
|
var materialIconSchema = z.enum(MATERIAL_ICONS, {
|
|
173
158
|
description: "Icon from VSCode Material Icons extension"
|
|
174
159
|
});
|
|
175
|
-
function
|
|
176
|
-
return
|
|
160
|
+
function hasNonZeroWeightedRef(refs) {
|
|
161
|
+
return refs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
177
162
|
}
|
|
178
163
|
|
|
179
164
|
// packages/models/src/lib/audit.ts
|
|
180
165
|
var auditSchema = z2.object({
|
|
181
|
-
slug: slugSchema("ID (unique within plugin)")
|
|
166
|
+
slug: slugSchema.describe("ID (unique within plugin)")
|
|
182
167
|
}).merge(
|
|
183
168
|
metaSchema({
|
|
184
169
|
titleDescription: "Descriptive name",
|
|
@@ -205,17 +190,20 @@ function getDuplicateSlugsInAudits(audits) {
|
|
|
205
190
|
return hasDuplicateStrings(audits.map(({ slug }) => slug));
|
|
206
191
|
}
|
|
207
192
|
|
|
208
|
-
// packages/models/src/lib/audit-
|
|
193
|
+
// packages/models/src/lib/audit-output.ts
|
|
194
|
+
import { z as z4 } from "zod";
|
|
195
|
+
|
|
196
|
+
// packages/models/src/lib/issue.ts
|
|
209
197
|
import { z as z3 } from "zod";
|
|
210
198
|
var sourceFileLocationSchema = z3.object(
|
|
211
199
|
{
|
|
212
|
-
file: filePathSchema("Relative path to source file in Git repo"),
|
|
200
|
+
file: filePathSchema.describe("Relative path to source file in Git repo"),
|
|
213
201
|
position: z3.object(
|
|
214
202
|
{
|
|
215
|
-
startLine: positiveIntSchema("Start line"),
|
|
216
|
-
startColumn: positiveIntSchema("Start column").optional(),
|
|
217
|
-
endLine: positiveIntSchema("End line").optional(),
|
|
218
|
-
endColumn: positiveIntSchema("End column").optional()
|
|
203
|
+
startLine: positiveIntSchema.describe("Start line"),
|
|
204
|
+
startColumn: positiveIntSchema.describe("Start column").optional(),
|
|
205
|
+
endLine: positiveIntSchema.describe("End line").optional(),
|
|
206
|
+
endColumn: positiveIntSchema.describe("End column").optional()
|
|
219
207
|
},
|
|
220
208
|
{ description: "Location in file" }
|
|
221
209
|
).optional()
|
|
@@ -235,21 +223,21 @@ var issueSchema = z3.object(
|
|
|
235
223
|
);
|
|
236
224
|
|
|
237
225
|
// packages/models/src/lib/audit-output.ts
|
|
238
|
-
|
|
226
|
+
var auditDetailsSchema = z4.object(
|
|
227
|
+
{
|
|
228
|
+
issues: z4.array(issueSchema, { description: "List of findings" })
|
|
229
|
+
},
|
|
230
|
+
{ description: "Detailed information" }
|
|
231
|
+
);
|
|
239
232
|
var auditOutputSchema = z4.object(
|
|
240
233
|
{
|
|
241
|
-
slug: slugSchema("Reference to audit"),
|
|
234
|
+
slug: slugSchema.describe("Reference to audit"),
|
|
242
235
|
displayValue: z4.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional(),
|
|
243
|
-
value:
|
|
236
|
+
value: nonnegativeIntSchema.describe("Raw numeric value"),
|
|
244
237
|
score: z4.number({
|
|
245
238
|
description: "Value between 0 and 1"
|
|
246
239
|
}).min(0).max(1),
|
|
247
|
-
details:
|
|
248
|
-
{
|
|
249
|
-
issues: z4.array(issueSchema, { description: "List of findings" })
|
|
250
|
-
},
|
|
251
|
-
{ description: "Detailed information" }
|
|
252
|
-
).optional()
|
|
240
|
+
details: auditDetailsSchema.optional()
|
|
253
241
|
},
|
|
254
242
|
{ description: "Audit information" }
|
|
255
243
|
);
|
|
@@ -279,7 +267,7 @@ var categoryRefSchema = weightedRefSchema(
|
|
|
279
267
|
type: z5.enum(["audit", "group"], {
|
|
280
268
|
description: "Discriminant for reference kind, affects where `slug` is looked up"
|
|
281
269
|
}),
|
|
282
|
-
plugin: slugSchema(
|
|
270
|
+
plugin: slugSchema.describe(
|
|
283
271
|
"Plugin slug (plugin should contain referenced audit or group)"
|
|
284
272
|
)
|
|
285
273
|
})
|
|
@@ -339,10 +327,8 @@ import { z as z11 } from "zod";
|
|
|
339
327
|
import { z as z6 } from "zod";
|
|
340
328
|
var formatSchema = z6.enum(["json", "md"]);
|
|
341
329
|
var persistConfigSchema = z6.object({
|
|
342
|
-
outputDir: filePathSchema("Artifacts folder").optional(),
|
|
343
|
-
filename: fileNameSchema(
|
|
344
|
-
"Artifacts file name (without extension)"
|
|
345
|
-
).optional(),
|
|
330
|
+
outputDir: filePathSchema.describe("Artifacts folder").optional(),
|
|
331
|
+
filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
|
|
346
332
|
format: z6.array(formatSchema).optional()
|
|
347
333
|
});
|
|
348
334
|
|
|
@@ -403,7 +389,7 @@ var runnerConfigSchema = z8.object(
|
|
|
403
389
|
description: "Shell command to execute"
|
|
404
390
|
}),
|
|
405
391
|
args: z8.array(z8.string({ description: "Command arguments" })).optional(),
|
|
406
|
-
outputFile: filePathSchema("Output path"),
|
|
392
|
+
outputFile: filePathSchema.describe("Output path"),
|
|
407
393
|
outputTransform: outputTransformSchema.optional()
|
|
408
394
|
},
|
|
409
395
|
{
|
|
@@ -423,7 +409,7 @@ var pluginMetaSchema = packageVersionSchema().merge(
|
|
|
423
409
|
})
|
|
424
410
|
).merge(
|
|
425
411
|
z9.object({
|
|
426
|
-
slug: slugSchema("Unique plugin slug within core config"),
|
|
412
|
+
slug: slugSchema.describe("Unique plugin slug within core config"),
|
|
427
413
|
icon: materialIconSchema
|
|
428
414
|
})
|
|
429
415
|
);
|
|
@@ -456,12 +442,14 @@ function getMissingRefsFromGroups(pluginCfg) {
|
|
|
456
442
|
// packages/models/src/lib/upload-config.ts
|
|
457
443
|
import { z as z10 } from "zod";
|
|
458
444
|
var uploadConfigSchema = z10.object({
|
|
459
|
-
server: urlSchema("URL of deployed portal API"),
|
|
445
|
+
server: urlSchema.describe("URL of deployed portal API"),
|
|
460
446
|
apiKey: z10.string({
|
|
461
447
|
description: "API key with write access to portal (use `process.env` for security)"
|
|
462
448
|
}),
|
|
463
|
-
organization: slugSchema(
|
|
464
|
-
|
|
449
|
+
organization: slugSchema.describe(
|
|
450
|
+
"Organization slug from Code PushUp portal"
|
|
451
|
+
),
|
|
452
|
+
project: slugSchema.describe("Project slug from Code PushUp portal"),
|
|
465
453
|
timeout: z10.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
|
|
466
454
|
});
|
|
467
455
|
|
|
@@ -1574,7 +1562,7 @@ var verboseUtils = (verbose = false) => ({
|
|
|
1574
1562
|
|
|
1575
1563
|
// packages/core/package.json
|
|
1576
1564
|
var name = "@code-pushup/core";
|
|
1577
|
-
var version = "0.
|
|
1565
|
+
var version = "0.20.1";
|
|
1578
1566
|
|
|
1579
1567
|
// packages/core/src/lib/implementation/execute-plugin.ts
|
|
1580
1568
|
import chalk5 from "chalk";
|
|
@@ -2269,10 +2257,10 @@ function filterCategoryByPluginSlug(categories, {
|
|
|
2269
2257
|
}
|
|
2270
2258
|
return categories.filter(
|
|
2271
2259
|
(category) => category.refs.every((ref) => {
|
|
2272
|
-
const isNotSkipped = onlyPlugins.includes(ref.
|
|
2260
|
+
const isNotSkipped = onlyPlugins.includes(ref.plugin);
|
|
2273
2261
|
if (!isNotSkipped && verbose) {
|
|
2274
2262
|
console.info(
|
|
2275
|
-
`${chalk10.yellow("\u26A0")} Category "${category.title}" is ignored because it references audits from skipped plugin "${ref.
|
|
2263
|
+
`${chalk10.yellow("\u26A0")} Category "${category.title}" is ignored because it references audits from skipped plugin "${ref.plugin}"`
|
|
2276
2264
|
);
|
|
2277
2265
|
}
|
|
2278
2266
|
return isNotSkipped;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CategoryConfig, CoreConfig } from '@code-pushup/models';
|
|
1
|
+
import type { CategoryConfig, CoreConfig } from '@code-pushup/models';
|
|
2
2
|
export declare function filterPluginsBySlug(plugins: CoreConfig['plugins'], { onlyPlugins }: {
|
|
3
3
|
onlyPlugins?: string[];
|
|
4
4
|
}): CoreConfig['plugins'];
|