-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(cli): add docs for custom plugins (#312)
- Loading branch information
Showing
12 changed files
with
873 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# file-size-plugin | ||
|
||
🕵️ **Code PushUp plugin for detecting changes in file size using different compressions** 📋 | ||
|
||
--- | ||
|
||
The plugin crawls the file base depending on your configuration and reports about their file size. | ||
|
||
You can configure the plugin with the following options: | ||
|
||
- directory to crawl | ||
- file name pattern | ||
- budget as number in bytes | ||
|
||
## Getting started | ||
|
||
1. If you haven't already, install [@code-pushup/cli](../cli/README.md) and create a configuration file. | ||
|
||
2. Copy the [plugin source](../file-size) as is into your project | ||
|
||
3. Add this plugin to the `plugins` array in your Code PushUp CLI config file (e.g. `code-pushup.config.js`). | ||
|
||
Pass in the path on the directory to crawl (relative to `process.cwd()`), as well as patterns and a budget. | ||
|
||
```js | ||
import fileSizePlugin from './file-size.plugin'; | ||
|
||
export default { | ||
// ... | ||
plugins: [ | ||
// ... | ||
fileSizePlugin({ | ||
directory: 'dist', | ||
patterns: /.js$/, | ||
budget: 42000, | ||
}), | ||
], | ||
}; | ||
``` | ||
|
||
4. (Optional) Reference audits (or groups) that you wish to include in custom categories (use `npx code-pushup print-config` to list audits and groups). | ||
|
||
Assign weights based on what influence each audit and group should have on the overall category score (assign weight 0 to only include it for extra info, without influencing the category score). | ||
|
||
```js | ||
import fileSizePlugin, { recommendedRefs as fileSizeRecommendedRefs } from './file-size.plugin'; | ||
|
||
export default { | ||
// ... | ||
categories: [ | ||
// ... | ||
{ | ||
slug: 'performance', | ||
title: 'Performance', | ||
refs: [...fileSizeRecommendedRefs], | ||
}, | ||
], | ||
}; | ||
``` | ||
|
||
5. Run the CLI with `npx code-pushup collect` and view or upload report (refer to [CLI docs](../cli/README.md)). | ||
|
||
## Audits | ||
|
||
Detailed information about the audits can be found in the docs folder of the plugin. | ||
|
||
The following audits are present: | ||
|
||
- [file-size-unmodified](@TODO - link to docs/file-size-unmodified.audit.md) |
58 changes: 58 additions & 0 deletions
58
examples/plugins/src/file-size/docs/file-size-unmodified.audit.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# File Size Audit - Unmodified | ||
|
||
🕵️ **An audit to check JavaScript file size in a directory. The files are not modified and takes as they are.** 📏 | ||
|
||
--- | ||
|
||
The audit evaluates the size of a file by using the `stat` function for the `fs:promises` node package. | ||
|
||
You can configure the plugin with the following options: | ||
|
||
- `budget` as number in bytes | ||
|
||
## Details | ||
|
||
The audit provides details in cases a file result is given. | ||
|
||
### Issues | ||
|
||
**Audit passed** | ||
A `Issue` with severity `info` is present and names to the given file. | ||
|
||
```md | ||
<table> | ||
<tr> | ||
<th>Severity</th> | ||
<th>Message</th> | ||
<th>Source file</th> | ||
<th>Line(s)</th> | ||
</tr> | ||
<tr> | ||
<td>ℹ️ <i>info</i></td> | ||
<td>File file.js OK</td> | ||
<td><code>src/file.js</code></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
``` | ||
|
||
**Audit failed** | ||
A `Issue` with severity `error` is present and names to the given file. | ||
The file sizes of the given file, the budget as well as the size difference is mentioned in the message. | ||
|
||
```md | ||
<table> | ||
<tr> | ||
<th>Severity</th> | ||
<th>Message</th> | ||
<th>Source file</th> | ||
<th>Line(s)</th> | ||
</tr> | ||
<tr> | ||
<td>🚨 <i>error</i></td> | ||
<td>File file.js is 17.31 kB bytes too big. (budget: 41.02 kB)</td> | ||
<td><code>src/file.js</code></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.