Skip to content

Add format for --report to generate HTML report#4

Merged
ryelle merged 36 commits into
WordPress:masterfrom
laras126:master
Oct 8, 2020
Merged

Add format for --report to generate HTML report#4
ryelle merged 36 commits into
WordPress:masterfrom
laras126:master

Conversation

@laras126

@laras126 laras126 commented Aug 20, 2020

Copy link
Copy Markdown
Collaborator

Add a format and templating system to generate an HTML report that can be published on Github pages, for example: https://laras126.github.io/css-audit/public/wp-admin.html

npm run css-audit -- <files...> --all --format=html --filename=wp-admin

Fixes #5.

@laras126 laras126 changed the title Write output of CSS audit to file Experimenting with report generation Aug 28, 2020
@ryelle

ryelle commented Sep 21, 2020

Copy link
Copy Markdown
Collaborator

@laras126 FYI, I've cherry-picked a few commits from this branch into master — mostly meta things like adding an .editorconfig & kicking off some testing using the scaffold here. You'll probably want to to rebase to sycn up with those changes.

Comment thread src/formats/report.js Outdated
@laras126 laras126 force-pushed the master branch 2 times, most recently from 25bb5c7 to fc0fed9 Compare October 1, 2020 14:19
@laras126 laras126 marked this pull request as ready for review October 1, 2020 14:32
@laras126

laras126 commented Oct 1, 2020

Copy link
Copy Markdown
Collaborator Author

@laras126 FYI, I've cherry-picked a few commits from this branch into master — mostly meta things like adding an .editorconfig & kicking off some testing using the scaffold here. You'll probably want to to rebase to sycn up with those changes.

Updated!

@laras126 laras126 changed the title Experimenting with report generation Add format for --report to generate HTML report Oct 1, 2020
Comment thread src/audits/colors.js Outdated
Comment on lines +40 to +41
audit: 'colors',
data: [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is breaking the default CLI result:

yarn css-audit ../css/style.css --colors              

undefined:

undefined

I know the grouping is needed for the HTML sections, but it could be done with a group ID in each result object? Then the HTML formatter can group them by that key. Like…

// in audits/colors.js
{
	id: 'top-10-colors',
	audit: 'colors',
	label: 'Top 10 most-used colors',
	value: colorsByCount.slice( 0, 10 ),
},
// in formats/report.js
const colorReports = reports.filter( ( { audit } ) => 'colors' === audit );

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah whoops 🤦🏻‍♀️ - yes, this can work! Thanks.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryelle I updated the PR to use this structure, and the CLI is working. We can send each audit separately to the templates to support different partials that can have varied markup, and there is a default.twig partial that can be used as a catch all where needed.

Comment thread src/audits/colors.js Outdated
data: [
{
label: 'Number of unique colors',
value: uniqColors.length,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are missing the ID values, looks like they got lost in the merge

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Thanks.

Comment thread src/formats/report.js Outdated
@ryelle

ryelle commented Oct 1, 2020

Copy link
Copy Markdown
Collaborator

Re: package-lock.json (it's too big for commenting on) — I've been using yarn, so we have a yarn.lock already. I don't have a super strong preference either way (npm vs yarn), but this project should probably stick to one. If we want to switch to npm (probably the more common process for WP) we can do that in another PR.

@laras126 laras126 requested a review from ryelle October 8, 2020 20:31

@ryelle ryelle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Working great in testing, with all report formats.

@ryelle ryelle merged commit dd0baa2 into WordPress:master Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Store audit data on Github (this repo?)

2 participants