@caweb/cli 1.4.5 → 1.5.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/commands/index.js +13 -19
- package/commands/webpack/webpack.js +19 -102
- package/lib/cli.js +136 -125
- package/lib/helpers.js +3 -5
- package/lib/index.js +12 -18
- package/package.json +7 -31
- package/bin/css-audit/.editorconfig +0 -12
- package/bin/css-audit/.github/workflows/build-report.yml +0 -46
- package/bin/css-audit/.github/workflows/merge-trunk-to-report.yml +0 -17
- package/bin/css-audit/.github/workflows/node.yaml +0 -32
- package/bin/css-audit/.nvmrc +0 -1
- package/bin/css-audit/README.md +0 -131
- package/bin/css-audit/css-audit.config.js +0 -13
- package/bin/css-audit/index.js +0 -38
- package/bin/css-audit/package-lock.json +0 -6689
- package/bin/css-audit/package.json +0 -56
- package/bin/css-audit/public/.gitkeep +0 -1
- package/bin/css-audit/src/__tests__/alphas.js +0 -128
- package/bin/css-audit/src/__tests__/colors.js +0 -115
- package/bin/css-audit/src/__tests__/display-none.js +0 -52
- package/bin/css-audit/src/__tests__/important.js +0 -88
- package/bin/css-audit/src/__tests__/media-queries.js +0 -84
- package/bin/css-audit/src/__tests__/property-values.js +0 -55
- package/bin/css-audit/src/__tests__/run.js +0 -25
- package/bin/css-audit/src/__tests__/selectors.js +0 -66
- package/bin/css-audit/src/audits/alphas.js +0 -70
- package/bin/css-audit/src/audits/colors.js +0 -83
- package/bin/css-audit/src/audits/display-none.js +0 -39
- package/bin/css-audit/src/audits/important.js +0 -60
- package/bin/css-audit/src/audits/media-queries.js +0 -96
- package/bin/css-audit/src/audits/property-values.js +0 -65
- package/bin/css-audit/src/audits/selectors.js +0 -67
- package/bin/css-audit/src/audits/typography.js +0 -41
- package/bin/css-audit/src/formats/cli-table.js +0 -81
- package/bin/css-audit/src/formats/html/_audit-alpha.twig +0 -23
- package/bin/css-audit/src/formats/html/_audit-colors.twig +0 -23
- package/bin/css-audit/src/formats/html/_audit-default.twig +0 -24
- package/bin/css-audit/src/formats/html/index.twig +0 -88
- package/bin/css-audit/src/formats/html/style.css +0 -341
- package/bin/css-audit/src/formats/html.js +0 -52
- package/bin/css-audit/src/formats/json.js +0 -9
- package/bin/css-audit/src/run.js +0 -76
- package/bin/css-audit/src/utils/__tests__/cli.js +0 -70
- package/bin/css-audit/src/utils/__tests__/example-config.config.js +0 -12
- package/bin/css-audit/src/utils/__tests__/get-specificity.js +0 -39
- package/bin/css-audit/src/utils/cli.js +0 -133
- package/bin/css-audit/src/utils/format-report.js +0 -37
- package/bin/css-audit/src/utils/get-specificity.js +0 -97
- package/bin/css-audit/src/utils/get-values-count.js +0 -17
- package/configs/webpack.config.js +0 -192
- package/lib/webpack/plugins/css-audit/css-audit.config.cjs +0 -5
- package/lib/webpack/plugins/css-audit/default.config.js +0 -19
- package/lib/webpack/plugins/css-audit/index.js +0 -297
- package/lib/webpack/plugins/css-audit/package.json +0 -12
- package/lib/webpack/plugins/jshint/.jshintrc +0 -31
- package/lib/webpack/plugins/jshint/index.js +0 -286
- package/lib/webpack/plugins/jshint/package-lock.json +0 -22
- package/lib/webpack/plugins/jshint/package.json +0 -15
- package/lib/webpack/plugins/jshint/reporter.cjs +0 -663
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"exports": "./lib/env.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"author": "CAWebPublishing",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"bin": {
|
|
12
|
-
"caweb": "bin/caweb.js"
|
|
13
|
-
"auditor": "bin/css-audit/index.js"
|
|
12
|
+
"caweb": "bin/caweb.js"
|
|
14
13
|
},
|
|
15
14
|
"files": [
|
|
16
15
|
"bin",
|
|
@@ -21,8 +20,7 @@
|
|
|
21
20
|
],
|
|
22
21
|
"scripts": {
|
|
23
22
|
"doc": "node ./docs/tool/index.js",
|
|
24
|
-
"test": "echo \"Error: run tests from root\" && exit 0"
|
|
25
|
-
"postinstall": "cd bin/css-audit && npm ci"
|
|
23
|
+
"test": "echo \"Error: run tests from root\" && exit 0"
|
|
26
24
|
},
|
|
27
25
|
"homepage": "https://github.com/CAWebPublishing/cli#readme",
|
|
28
26
|
"repository": {
|
|
@@ -58,39 +56,17 @@
|
|
|
58
56
|
}
|
|
59
57
|
},
|
|
60
58
|
"dependencies": {
|
|
61
|
-
"@
|
|
62
|
-
"@wordpress/
|
|
63
|
-
"@wordpress/
|
|
64
|
-
"accessibility-checker": "^3.1.73",
|
|
65
|
-
"autoprefixer": "^10.4.19",
|
|
59
|
+
"@caweb/webpack": "^1.0.1",
|
|
60
|
+
"@wordpress/create-block": "^4.46.0",
|
|
61
|
+
"@wordpress/env": "^10.3.0",
|
|
66
62
|
"axios": "^1.7.2",
|
|
67
63
|
"axios-retry": "^4.4.1",
|
|
68
64
|
"chalk": "^5.3.0",
|
|
69
|
-
"check-valid-url": "^0.1.0",
|
|
70
65
|
"commander": "^12.1.0",
|
|
71
66
|
"cross-spawn": "^7.0.3",
|
|
72
|
-
"css-audit": "file:css-audit",
|
|
73
|
-
"css-loader": "^7.1.2",
|
|
74
|
-
"deepmerge": "^4.3.1",
|
|
75
67
|
"docker-compose": "^0.24.8",
|
|
76
|
-
"fs-extra": "^11.2.0",
|
|
77
|
-
"get-all-files": "^5.0.0",
|
|
78
|
-
"got": "^14.4.1",
|
|
79
|
-
"handlebars-loader": "^1.7.3",
|
|
80
|
-
"html-format": "^1.1.7",
|
|
81
|
-
"html-to-json-parser": "^2.0.1",
|
|
82
|
-
"html-webpack-plugin": "^5.6.0",
|
|
83
|
-
"html-webpack-skip-assets-plugin": "^1.0.4",
|
|
84
|
-
"jshint": "^2.13.6",
|
|
85
|
-
"mini-css-extract-plugin": "^2.9.0",
|
|
86
68
|
"ora": "^8.0.1",
|
|
87
|
-
"postcss-loader": "^8.1.1",
|
|
88
69
|
"resolve-bin": "^1.0.1",
|
|
89
|
-
"
|
|
90
|
-
"snyk": "^1.1292.1",
|
|
91
|
-
"terminal-link": "^3.0.0",
|
|
92
|
-
"url": "^0.11.3",
|
|
93
|
-
"webpack": "^5.92.1",
|
|
94
|
-
"webpack-dev-server": "^5.0.4"
|
|
70
|
+
"terminal-link": "^3.0.0"
|
|
95
71
|
}
|
|
96
72
|
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
name: Build Report
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
# Run only on pushes to report
|
|
6
|
-
- report
|
|
7
|
-
schedule:
|
|
8
|
-
# Run every day at 9am UTC.
|
|
9
|
-
# * is a special character in YAML so you have to quote this string
|
|
10
|
-
- cron: '0 9 * * *'
|
|
11
|
-
workflow_dispatch:
|
|
12
|
-
jobs:
|
|
13
|
-
run:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout CSS Audit
|
|
17
|
-
uses: actions/checkout@v2
|
|
18
|
-
with:
|
|
19
|
-
ref: report
|
|
20
|
-
- name: Checkout WordPress Core
|
|
21
|
-
uses: actions/checkout@v2
|
|
22
|
-
with:
|
|
23
|
-
repository: WordPress/wordpress-develop
|
|
24
|
-
path: wordpress
|
|
25
|
-
|
|
26
|
-
- name: Set up Node.js
|
|
27
|
-
uses: actions/setup-node@v1
|
|
28
|
-
with:
|
|
29
|
-
node-version: 14.x
|
|
30
|
-
|
|
31
|
-
- name: Install dependencies
|
|
32
|
-
run: npm install
|
|
33
|
-
|
|
34
|
-
- name: Build the audit report
|
|
35
|
-
run: npm run css-audit -- wordpress/src/wp-admin/css/*.css wordpress/src/wp-includes/css/*.css
|
|
36
|
-
|
|
37
|
-
- name: Commit changes
|
|
38
|
-
uses: EndBug/add-and-commit@v5
|
|
39
|
-
with:
|
|
40
|
-
author_name: github-actions
|
|
41
|
-
author_email: 41898282+github-actions[bot]@users.noreply.github.com
|
|
42
|
-
message: "[Automated] Update report"
|
|
43
|
-
branch: "report"
|
|
44
|
-
add: "public"
|
|
45
|
-
env:
|
|
46
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
name: Merge trunk into report branch
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
# Run on pushes to trunk
|
|
6
|
-
- 'trunk'
|
|
7
|
-
jobs:
|
|
8
|
-
merge-branch:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v2
|
|
12
|
-
- name: Merge trunk -> report
|
|
13
|
-
uses: devmasx/merge-branch@v1.3.1
|
|
14
|
-
with:
|
|
15
|
-
type: now
|
|
16
|
-
target_branch: report
|
|
17
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
name: Node.js CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
paths:
|
|
6
|
-
- '**.js'
|
|
7
|
-
pull_request:
|
|
8
|
-
paths:
|
|
9
|
-
- '**.js'
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
build:
|
|
13
|
-
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
|
|
16
|
-
strategy:
|
|
17
|
-
matrix:
|
|
18
|
-
node-version: [14.x]
|
|
19
|
-
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v2
|
|
22
|
-
|
|
23
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
24
|
-
uses: actions/setup-node@v1
|
|
25
|
-
with:
|
|
26
|
-
node-version: ${{ matrix.node-version }}
|
|
27
|
-
|
|
28
|
-
- run: npm install
|
|
29
|
-
|
|
30
|
-
- run: npm test
|
|
31
|
-
env:
|
|
32
|
-
CI: true
|
package/bin/css-audit/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
14
|
package/bin/css-audit/README.md
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# CSS Audit
|
|
2
|
-
|
|
3
|
-
This project contains an automated audit of the core WordPress CSS, including the number of distinct colors used, most specific selectors, how many properties use `!important`, and more. [View the audit report here.](https://wordpress.github.io/css-audit/public/wp-admin) This report is regenerated every day at 09:00 UTC, and runs over the latest CSS in [WordPress/wordpress-develop](https://github.com/WordPress/wordpress-develop/).
|
|
4
|
-
|
|
5
|
-
To generate this report, there is a tool `css-audit`, which runs a set of [audits](./src/audits).
|
|
6
|
-
|
|
7
|
-
## Local Environment
|
|
8
|
-
|
|
9
|
-
To run the audits yourself, download or clone this repo, then install the dependencies. You will need [node & npm](https://nodejs.org/en/) installed.
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
$ git clone git@github.com:wordpress/css-audit.git
|
|
13
|
-
$ cd css-audit
|
|
14
|
-
$ npm install
|
|
15
|
-
$ npm run css-audit -- <files...>
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
If you want to work on the audits yourself, [fork this repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) to your account first. You can submit issues or PRs.
|
|
19
|
-
|
|
20
|
-
## Running Audits
|
|
21
|
-
|
|
22
|
-
To run the audits, you need a list of CSS files, and to indicate which audits you want to run. `yarn` and `npm` both automatically expand globs (`folder/*`), so you can use that, or pass in a list of CSS files. The audits are described below, and can be run via the following CLI args, or via configuration file (described in the next section).
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
$ npm run css-audit -- <files ...> [options]
|
|
26
|
-
|
|
27
|
-
Usage: css-audit -- <files...> [options]
|
|
28
|
-
|
|
29
|
-
--colors Run colors audit.
|
|
30
|
-
--important Run !important audit.
|
|
31
|
-
--display-none Run display: none audit.
|
|
32
|
-
--selectors Run selectors audit.
|
|
33
|
-
--media-queries Run media queries audit.
|
|
34
|
-
--property-values Run audit for a given set of property values, comma-separated.
|
|
35
|
-
--recommended Run recommended audits (colors, important, selectors). Default: true.
|
|
36
|
-
--all Run all audits (except property values, as it requires a value).
|
|
37
|
-
--format Format to use for displaying report.
|
|
38
|
-
--filename If using a format that outputs to a file, specify the file name.
|
|
39
|
-
--help Show this message.
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Configuration File
|
|
44
|
-
|
|
45
|
-
The program will prioritize configuration from CLI arguments, and will fallback to configuration stored in a file called `css-audit.config.js`.
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
module.exports = {
|
|
49
|
-
format: 'json',
|
|
50
|
-
audits: [
|
|
51
|
-
'colors',
|
|
52
|
-
'important',
|
|
53
|
-
'display-none',
|
|
54
|
-
'selectors',
|
|
55
|
-
'media-queries',
|
|
56
|
-
[ 'property-values', 'font-size' ],
|
|
57
|
-
[ 'property-values', 'padding-top,padding-bottom' ],
|
|
58
|
-
],
|
|
59
|
-
};
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Generating HTML Reports
|
|
63
|
-
|
|
64
|
-
To generate an HTML report, use the `--format=html` option and specify a name for the file with the `--filename=name` option. This will output a `{name}.html` file in public/ that is viewable on Github Pages.
|
|
65
|
-
|
|
66
|
-
For example, generating a report for wp-admin using the below strategy for pulling down CSS files from SVN:
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
npm run css-audit -- v5.5/**/* --format=html --all --filename=wp-admin
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
In the configuration file, the argument `filename` can be added as a simple property: value combination, the same as `format` in the example. See the [default `css-audit.config.js`](./css-audit.config.js).
|
|
73
|
-
|
|
74
|
-
## Getting core CSS files
|
|
75
|
-
|
|
76
|
-
You can download the source files of CSS (not minified or RTL'd) from the svn repository. The following code will create a new directory, `v5.5`, and download just the files from each `css` folder.
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
mkdir v5.5
|
|
80
|
-
svn export https://develop.svn.wordpress.org/branches/5.5/src/wp-admin/css --depth files v5.5/admin
|
|
81
|
-
svn export https://develop.svn.wordpress.org/branches/5.5/src/wp-includes/css --depth files v5.5/includes
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
If you want to run this on trunk (code currently in development), you can swap out `branches/5.5` for `trunk`. You could also swap the `5.5` for `5.4`, etc. Example:
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
mkdir trunk
|
|
88
|
-
svn export https://develop.svn.wordpress.org/trunk/src/wp-admin/css --depth files trunk/admin
|
|
89
|
-
svn export https://develop.svn.wordpress.org/trunk/src/wp-includes/css --depth files trunk/includes
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Now you can run the audits:
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
npm run css-audit -- v5.5/**/* --recommended
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Available Audits
|
|
99
|
-
|
|
100
|
-
- `colors`
|
|
101
|
-
- Number of unique colors — normalizes hex colors so that uppercase & lowercase are not counted twice
|
|
102
|
-
- Number of unique colors (ignoring opacity)
|
|
103
|
-
- List of all colors
|
|
104
|
-
- Top 10 most-used colors
|
|
105
|
-
- Top 10 least-used colors
|
|
106
|
-
- `important`
|
|
107
|
-
- Number of times `!important` is used
|
|
108
|
-
- Top properties that use !important
|
|
109
|
-
- `property-values` — needs a list of properties to inspect.
|
|
110
|
-
- Usage: `--property-values=[properties]`. For example: `--property-values=display`, or `--property-values=padding,margin`
|
|
111
|
-
- Number of unique values for [property]
|
|
112
|
-
- Top 10 most-used values for [property]
|
|
113
|
-
- Top 10 least-used values for [property]
|
|
114
|
-
- `selectors`
|
|
115
|
-
- Total number of selectors
|
|
116
|
-
- Number of selectors with IDs — not "number of IDs", a lot of selectors use multiple IDs, but they'd only be counted once
|
|
117
|
-
- Top 10 selectors with the highest specificity
|
|
118
|
-
- Top 10 selectors by length
|
|
119
|
-
- `display-none`
|
|
120
|
-
- Number of times `display: none` is used
|
|
121
|
-
- Places where `display: none` is used
|
|
122
|
-
- `typography`
|
|
123
|
-
- A collection of information about various typography-related properties
|
|
124
|
-
|
|
125
|
-
## Technical details
|
|
126
|
-
|
|
127
|
-
This tool parses each CSS file and creates an AST, which the audits traverse to pull out data. It uses [`postcss`](https://postcss.org/) for most audits, but [`csstree`](https://github.com/csstree/csstree) for the `media-queries` audit. PostCSS gives us the plugins ecosystem so that we can use `postcss-values-parser`, while csstree generates a much more detailed AST that robustly identifies media queries.
|
|
128
|
-
|
|
129
|
-
- [PostCSS API documentation](https://postcss.org/api/)
|
|
130
|
-
- [csstree documentation](https://github.com/csstree/csstree/tree/master/docs)
|
|
131
|
-
- [AST Explorer](https://astexplorer.net/) — great tool for identifying how the CSS is parsed.
|
package/bin/css-audit/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node dependencies
|
|
3
|
-
*/
|
|
4
|
-
const fs = require( 'fs' );
|
|
5
|
-
const path = require( 'path' );
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
const { runAudits } = require( './src/run' );
|
|
11
|
-
const { getArg, getFileArgsFromCLI, getHelp } = require( './src/utils/cli' );
|
|
12
|
-
|
|
13
|
-
const input = getFileArgsFromCLI();
|
|
14
|
-
|
|
15
|
-
if ( getArg( '--help', true ) || ! input.length ) {
|
|
16
|
-
console.log( getHelp() );
|
|
17
|
-
process.exit( 0 );
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const cssFiles = [];
|
|
21
|
-
input.forEach( ( file ) => {
|
|
22
|
-
const filePath = path.resolve( process.env.INIT_CWD, file );
|
|
23
|
-
const stats = fs.statSync( filePath );
|
|
24
|
-
if ( stats.isDirectory() ) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if ( file.match( /min\.css$/ ) ) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
cssFiles.push( {
|
|
31
|
-
name: file,
|
|
32
|
-
content: String( fs.readFileSync( filePath ) ),
|
|
33
|
-
} );
|
|
34
|
-
} );
|
|
35
|
-
|
|
36
|
-
const result = runAudits( cssFiles );
|
|
37
|
-
|
|
38
|
-
console.log( result );
|