@caweb/cli 1.4.5 → 1.5.0

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.
Files changed (58) hide show
  1. package/commands/index.js +13 -19
  2. package/commands/webpack/webpack.js +19 -102
  3. package/lib/cli.js +130 -124
  4. package/lib/helpers.js +3 -5
  5. package/lib/index.js +12 -18
  6. package/package.json +5 -29
  7. package/bin/css-audit/.editorconfig +0 -12
  8. package/bin/css-audit/.github/workflows/build-report.yml +0 -46
  9. package/bin/css-audit/.github/workflows/merge-trunk-to-report.yml +0 -17
  10. package/bin/css-audit/.github/workflows/node.yaml +0 -32
  11. package/bin/css-audit/.nvmrc +0 -1
  12. package/bin/css-audit/README.md +0 -131
  13. package/bin/css-audit/css-audit.config.js +0 -13
  14. package/bin/css-audit/index.js +0 -38
  15. package/bin/css-audit/package-lock.json +0 -6689
  16. package/bin/css-audit/package.json +0 -56
  17. package/bin/css-audit/public/.gitkeep +0 -1
  18. package/bin/css-audit/src/__tests__/alphas.js +0 -128
  19. package/bin/css-audit/src/__tests__/colors.js +0 -115
  20. package/bin/css-audit/src/__tests__/display-none.js +0 -52
  21. package/bin/css-audit/src/__tests__/important.js +0 -88
  22. package/bin/css-audit/src/__tests__/media-queries.js +0 -84
  23. package/bin/css-audit/src/__tests__/property-values.js +0 -55
  24. package/bin/css-audit/src/__tests__/run.js +0 -25
  25. package/bin/css-audit/src/__tests__/selectors.js +0 -66
  26. package/bin/css-audit/src/audits/alphas.js +0 -70
  27. package/bin/css-audit/src/audits/colors.js +0 -83
  28. package/bin/css-audit/src/audits/display-none.js +0 -39
  29. package/bin/css-audit/src/audits/important.js +0 -60
  30. package/bin/css-audit/src/audits/media-queries.js +0 -96
  31. package/bin/css-audit/src/audits/property-values.js +0 -65
  32. package/bin/css-audit/src/audits/selectors.js +0 -67
  33. package/bin/css-audit/src/audits/typography.js +0 -41
  34. package/bin/css-audit/src/formats/cli-table.js +0 -81
  35. package/bin/css-audit/src/formats/html/_audit-alpha.twig +0 -23
  36. package/bin/css-audit/src/formats/html/_audit-colors.twig +0 -23
  37. package/bin/css-audit/src/formats/html/_audit-default.twig +0 -24
  38. package/bin/css-audit/src/formats/html/index.twig +0 -88
  39. package/bin/css-audit/src/formats/html/style.css +0 -341
  40. package/bin/css-audit/src/formats/html.js +0 -52
  41. package/bin/css-audit/src/formats/json.js +0 -9
  42. package/bin/css-audit/src/run.js +0 -76
  43. package/bin/css-audit/src/utils/__tests__/cli.js +0 -70
  44. package/bin/css-audit/src/utils/__tests__/example-config.config.js +0 -12
  45. package/bin/css-audit/src/utils/__tests__/get-specificity.js +0 -39
  46. package/bin/css-audit/src/utils/cli.js +0 -133
  47. package/bin/css-audit/src/utils/format-report.js +0 -37
  48. package/bin/css-audit/src/utils/get-specificity.js +0 -97
  49. package/bin/css-audit/src/utils/get-values-count.js +0 -17
  50. package/lib/webpack/plugins/css-audit/css-audit.config.cjs +0 -5
  51. package/lib/webpack/plugins/css-audit/default.config.js +0 -19
  52. package/lib/webpack/plugins/css-audit/index.js +0 -297
  53. package/lib/webpack/plugins/css-audit/package.json +0 -12
  54. package/lib/webpack/plugins/jshint/.jshintrc +0 -31
  55. package/lib/webpack/plugins/jshint/index.js +0 -286
  56. package/lib/webpack/plugins/jshint/package-lock.json +0 -22
  57. package/lib/webpack/plugins/jshint/package.json +0 -15
  58. package/lib/webpack/plugins/jshint/reporter.cjs +0 -663
@@ -1,12 +0,0 @@
1
- # http://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- indent_style = tab
6
- end_of_line = lf
7
- charset = utf-8
8
- trim_trailing_whitespace = true
9
- insert_final_newline = true
10
-
11
- [*.md]
12
- trim_trailing_whitespace = false
@@ -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
@@ -1 +0,0 @@
1
- 14
@@ -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.
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- format: 'html',
3
- filename: 'wp-admin',
4
- audits: [
5
- 'colors',
6
- 'alphas',
7
- 'important',
8
- 'display-none',
9
- 'selectors',
10
- 'media-queries',
11
- 'typography',
12
- ],
13
- };
@@ -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 );