@caweb/cli 1.4.4 → 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.
- package/commands/index.js +13 -19
- package/commands/webpack/webpack.js +19 -102
- package/lib/cli.js +130 -124
- package/lib/helpers.js +3 -5
- package/lib/index.js +12 -18
- package/package.json +5 -28
- 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/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/commands/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
* These are default wp-env commands. No need to overwrite these commands
|
|
6
|
-
*/
|
|
4
|
+
// These are default wp-env commands. No need to overwrite these commands
|
|
7
5
|
import clean from '@wordpress/env/lib/commands/clean.js';
|
|
8
6
|
import logs from '@wordpress/env/lib/commands/logs.js';
|
|
9
7
|
import run from '@wordpress/env/lib/commands/run.js';
|
|
@@ -14,16 +12,15 @@ import installPath from '@wordpress/env/lib/commands/install-path.js';
|
|
|
14
12
|
*/
|
|
15
13
|
import webpack from './webpack/webpack.js';
|
|
16
14
|
|
|
15
|
+
import CSSAuditPlugin from '@caweb/css-audit-webpack-plugin';
|
|
16
|
+
const audit = new CSSAuditPlugin().audit;
|
|
17
17
|
|
|
18
|
-
import
|
|
19
|
-
const a11y = new A11yPlugin().a11yCheck;
|
|
20
|
-
|
|
21
|
-
import CSSAuditPlugin from '../lib/webpack/plugins/css-audit/index.js';
|
|
22
|
-
const audit = new CSSAuditPlugin({}).audit;
|
|
23
|
-
|
|
24
|
-
import JSHintPlugin from '../lib/webpack/plugins/jshint/index.js';
|
|
18
|
+
import JSHintPlugin from '@caweb/jshint-webpack-plugin';
|
|
25
19
|
const hint = new JSHintPlugin().hint;
|
|
26
20
|
|
|
21
|
+
import A11yPlugin from '@caweb/a11y-webpack-plugin';
|
|
22
|
+
const a11y = new A11yPlugin().a11yCheck;
|
|
23
|
+
|
|
27
24
|
import shell from './tasks/shell.js';
|
|
28
25
|
|
|
29
26
|
import sync from './sync.js';
|
|
@@ -34,14 +31,16 @@ import updateBlock from './blocks/update-block.js'
|
|
|
34
31
|
|
|
35
32
|
import test from './test.js';
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
* These are default wp-env commands, we overwrite these commands so we can run additional steps.
|
|
39
|
-
*/
|
|
34
|
+
// These are default wp-env commands, we overwrite these commands so we can run additional steps.
|
|
40
35
|
import start from './env/start.js';
|
|
41
36
|
import destroy from './env/destroy.js';
|
|
42
37
|
import stop from './env/stop.js';
|
|
43
38
|
|
|
44
39
|
export {
|
|
40
|
+
a11y,
|
|
41
|
+
audit,
|
|
42
|
+
hint,
|
|
43
|
+
webpack,
|
|
45
44
|
clean,
|
|
46
45
|
logs,
|
|
47
46
|
run,
|
|
@@ -49,14 +48,9 @@ export {
|
|
|
49
48
|
start,
|
|
50
49
|
stop,
|
|
51
50
|
destroy,
|
|
52
|
-
webpack,
|
|
53
|
-
a11y,
|
|
54
|
-
audit,
|
|
55
|
-
hint,
|
|
56
51
|
sync,
|
|
57
52
|
updatePlugins,
|
|
58
53
|
shell,
|
|
59
54
|
createBlock,
|
|
60
|
-
updateBlock
|
|
61
|
-
test
|
|
55
|
+
updateBlock
|
|
62
56
|
}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* External dependencies
|
|
5
3
|
*/
|
|
6
4
|
import path from 'path';
|
|
7
|
-
import fs
|
|
8
|
-
import deepmerge from 'deepmerge';
|
|
9
|
-
import Webpack from 'webpack';
|
|
10
|
-
import webpackServer from 'webpack-dev-server';
|
|
5
|
+
import fs from 'fs';
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
8
|
* Internal dependencies
|
|
14
9
|
*/
|
|
15
10
|
import {
|
|
16
|
-
runCmd,
|
|
17
|
-
projectPath,
|
|
18
11
|
appPath,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
wpRed
|
|
12
|
+
projectPath,
|
|
13
|
+
runCmd
|
|
22
14
|
} from '../../lib/index.js';
|
|
23
15
|
|
|
24
16
|
|
|
@@ -32,13 +24,11 @@ import {
|
|
|
32
24
|
export default async function webpack({
|
|
33
25
|
spinner,
|
|
34
26
|
debug,
|
|
35
|
-
audit,
|
|
36
|
-
a11y,
|
|
37
|
-
selectors
|
|
38
27
|
} ) {
|
|
39
28
|
const webpackCommand = 'build' === process.argv[2] ? 'build' : 'serve' ;
|
|
40
29
|
|
|
41
|
-
|
|
30
|
+
// we use our default config from the @caweb/html-webpack-plugin
|
|
31
|
+
const defaultConfigPath = path.resolve(projectPath, '..', 'webpack', 'webpack.config.js' );
|
|
42
32
|
let webpackConfig = await import('file://' + defaultConfigPath);
|
|
43
33
|
let customConfig = {};
|
|
44
34
|
|
|
@@ -46,16 +36,15 @@ export default async function webpack({
|
|
|
46
36
|
// the environment variables as well.
|
|
47
37
|
process.env.WP_COPY_PHP_FILES_TO_DIST = true;
|
|
48
38
|
|
|
49
|
-
// pass any arguments from the cli
|
|
50
39
|
// add our default config as an extension.
|
|
51
40
|
// users can overwrite any values by creating a webconfig of their own.
|
|
52
41
|
let webPackArgs = [
|
|
53
42
|
'--config',
|
|
54
|
-
defaultConfigPath
|
|
55
|
-
];
|
|
56
|
-
|
|
43
|
+
defaultConfigPath
|
|
44
|
+
].filter(e => e);
|
|
45
|
+
|
|
57
46
|
// CommonJS
|
|
58
|
-
if( fs.existsSync( path.join(appPath, 'webpack.config.cjs' ))){
|
|
47
|
+
if( fs.existsSync( path.join(appPath, 'webpack.config.cjs' ) ) ){
|
|
59
48
|
webPackArgs.push(
|
|
60
49
|
'--config',
|
|
61
50
|
path.join(appPath, 'webpack.config.cjs' ),
|
|
@@ -78,89 +67,17 @@ export default async function webpack({
|
|
|
78
67
|
if( customConfig.length ){
|
|
79
68
|
webpackConfig = deepmerge(webpackConfig.default, customConfig.default);
|
|
80
69
|
}
|
|
81
|
-
|
|
82
|
-
// we always run the build command.
|
|
83
|
-
let result = await runCmd(
|
|
84
|
-
'webpack',
|
|
85
|
-
['build', ...webPackArgs],
|
|
86
|
-
{stdio:'pipe'}
|
|
87
|
-
).then(({stdout, stderr}) => {
|
|
88
|
-
// we hide the punycode deprecation warning.
|
|
89
|
-
// this is caused by the wp-scripts package
|
|
90
|
-
// if an error was thrown
|
|
91
|
-
if( stderr ){
|
|
92
|
-
//console.log( stderr.toString().replace(/.*`punycode`.*\n.*/, '') )
|
|
93
|
-
}
|
|
94
70
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if( 'serve' === webpackCommand ){
|
|
103
|
-
let hostUrl = 'localhost' === webpackConfig.default.devServer.host ? `http://${webpackConfig.default.devServer.host}`: webpackConfig.default.devServer.host;
|
|
104
|
-
let hostPort = webpackConfig.default.devServer.port;
|
|
105
|
-
|
|
106
|
-
if( hostPort && 80 !== hostPort )
|
|
71
|
+
// run the webpackCommand command.
|
|
72
|
+
await runCmd(
|
|
73
|
+
'webpack',
|
|
74
|
+
[
|
|
75
|
+
webpackCommand,
|
|
76
|
+
...webPackArgs
|
|
77
|
+
],
|
|
107
78
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
console.log( `Webpack Server is preparing to launch ${ wpGreen(hostUrl) }` );
|
|
112
|
-
console.log( `Press ${ wpRed('Ctrl + C') } to shutdown the server.\n` );
|
|
113
|
-
|
|
114
|
-
// add a11y plugin
|
|
115
|
-
if( a11y ){
|
|
116
|
-
/*webpackConfig.default.plugins.push(new A11yPlugin({
|
|
117
|
-
outputFilename: 'a11y'
|
|
118
|
-
}) )
|
|
119
|
-
|
|
120
|
-
webpackConfig.default.devServer.static.push({
|
|
121
|
-
directory: path.join(appPath, 'a11y')
|
|
122
|
-
})*/
|
|
79
|
+
stdio: 'inherit',
|
|
80
|
+
argv0: process.argv.join(' ')
|
|
123
81
|
}
|
|
124
|
-
|
|
125
|
-
// add css-auditor plugin
|
|
126
|
-
if( audit ){
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const compiler = Webpack(webpackConfig.default);
|
|
130
|
-
const server = new webpackServer({...webpackConfig.default.devServer}, compiler);
|
|
131
|
-
|
|
132
|
-
await server.start();
|
|
133
|
-
|
|
134
|
-
//process.stdin.resume();
|
|
135
|
-
|
|
136
|
-
// run webpack serve command
|
|
137
|
-
/*await runCmd(
|
|
138
|
-
'webpack',
|
|
139
|
-
['serve', ...webPackArgs],
|
|
140
|
-
{
|
|
141
|
-
stdio: 'inherit'
|
|
142
|
-
}
|
|
143
|
-
).then(({stdout, stderr}) => {
|
|
144
|
-
// if an error was thrown, and no output
|
|
145
|
-
if( stderr && ! stdout){
|
|
146
|
-
console.log( stderr.toString() )
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if( stdout ){
|
|
150
|
-
spinner.text = "Webpack Server was closed.";
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
});*/
|
|
154
|
-
|
|
155
|
-
/*
|
|
156
|
-
const compiler = Webpack(webpackConfig.default);
|
|
157
|
-
const server = new webpackServer({...webpackConfig.default.devServer}, compiler);
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
// only build was ran.
|
|
161
|
-
}else{
|
|
162
|
-
//spinner.prefixText = result;
|
|
163
|
-
//spinner.text = "Done!";
|
|
164
|
-
}
|
|
165
|
-
|
|
82
|
+
);
|
|
166
83
|
};
|
package/lib/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
//const wpenv_cli = require('@wordpress/env/lib/cli');
|
|
5
4
|
|
|
6
5
|
import path from 'path';
|
|
7
6
|
import fs from 'fs';
|
|
@@ -11,9 +10,10 @@ import { Command, Argument, Option } from 'commander';
|
|
|
11
10
|
* Internal dependencies
|
|
12
11
|
*/
|
|
13
12
|
import * as env from '../commands/index.js';
|
|
13
|
+
|
|
14
14
|
import {
|
|
15
|
-
withSpinner,
|
|
16
15
|
projectPath,
|
|
16
|
+
withSpinner
|
|
17
17
|
} from './index.js';
|
|
18
18
|
|
|
19
19
|
const localFile = path.join(projectPath, 'package.json');
|
|
@@ -39,6 +39,85 @@ const envArg = new Argument('[environment]', 'Which environment to use.')
|
|
|
39
39
|
])
|
|
40
40
|
.default('development');
|
|
41
41
|
|
|
42
|
+
function addWebpackCmds(){
|
|
43
|
+
|
|
44
|
+
// Build Command.
|
|
45
|
+
program.command('build')
|
|
46
|
+
.description('Builds the current project.')
|
|
47
|
+
.allowUnknownOption(true)
|
|
48
|
+
.action(env.webpack)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
// Serve Command.
|
|
52
|
+
program.command('serve')
|
|
53
|
+
.description('Serve the current project')
|
|
54
|
+
.option( '--audit', 'Performs WordPress CSS-Audit.', true )
|
|
55
|
+
.option( '--no-audit', 'Skips WordPress CSS-Audit.', false )
|
|
56
|
+
.option( '--a11y', 'Performs IBM Accessibility Checker.', true )
|
|
57
|
+
.option( '--no-a11y', 'Skips IBM Accessibility Checker.', false )
|
|
58
|
+
.allowUnknownOption(true)
|
|
59
|
+
.action(env.webpack)
|
|
60
|
+
|
|
61
|
+
// a11y Command.
|
|
62
|
+
program.command('a11y')
|
|
63
|
+
.description('Runs accessibility checks.')
|
|
64
|
+
.addArgument(new Argument('<url>', 'URL to scan for accessibility checks.'))
|
|
65
|
+
.option( '--rule-archive <rule>', 'Specify the rule archive.', 'latest')
|
|
66
|
+
.option( '--policies <policy...>', 'Specify one or many policies to scan.', ['WCAG_2_1'])
|
|
67
|
+
.option( '--fail-levels <levels...>', 'Specify one or many violation levels on which to fail the test.', [
|
|
68
|
+
'violation',
|
|
69
|
+
'potentialviolation'
|
|
70
|
+
])
|
|
71
|
+
.option( '--report-levels <levels...>', 'Specify one or many violation levels that should be reported.', [
|
|
72
|
+
'violation',
|
|
73
|
+
'potentialviolation',
|
|
74
|
+
'recommendation',
|
|
75
|
+
'potentialrecommendation',
|
|
76
|
+
'manual',
|
|
77
|
+
'pass'
|
|
78
|
+
])
|
|
79
|
+
.option( '--labels <label...>', 'Specify labels that you would like associated to your scan.', [])
|
|
80
|
+
.option( '--output-format <format>', 'In which formats should the results be output.', ['html'])
|
|
81
|
+
.option( '--output-filename <name>', 'Filename for the scan results.', 'a11y')
|
|
82
|
+
.option( '--output-folder <folder>', 'Where the scan results should be saved.', 'a11y')
|
|
83
|
+
.option( '--output-filename-timestamp', 'Should the timestamp be included in the filename of the reports?', false)
|
|
84
|
+
.allowUnknownOption(true)
|
|
85
|
+
.action(env.a11y)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
// audit Command.
|
|
89
|
+
program.command('audit')
|
|
90
|
+
.description('Runs WordPress CSS Audit tool against projects.')
|
|
91
|
+
.addArgument(new Argument('[files...]', 'Files or directory path to CSS files.').default(['./build']))
|
|
92
|
+
.option('--format [format]', 'Format to use for displaying report.', 'html' )
|
|
93
|
+
.option('--filename [name]', 'If using a format that outputs to a file, specify the file name.', 'css-audit' )
|
|
94
|
+
.option('--colors', 'Runs colors audit.', true )
|
|
95
|
+
.addOption(new Option('--no-colors', 'Skips colors audit.', false ).hideHelp())
|
|
96
|
+
.option('--important', 'Runs !important audit.', true )
|
|
97
|
+
.addOption(new Option('--no-important', 'Skips !important audit.', false ).hideHelp())
|
|
98
|
+
.option('--display-none', 'Runs display: none audit.', true )
|
|
99
|
+
.addOption(new Option('--no-display-none', 'Skips display: none audit.', false ).hideHelp())
|
|
100
|
+
.option('--selectors', 'Runs selectors audit.', true )
|
|
101
|
+
.addOption(new Option('--no-selectors', 'Skips selectors audit.', false ).hideHelp())
|
|
102
|
+
.option('--media-queries', 'Runs media queries audit.', true )
|
|
103
|
+
.addOption(new Option('--no-media-queries', 'Skips media queries audit.', false ).hideHelp())
|
|
104
|
+
.option('--typography', 'Runs typography audit.', true )
|
|
105
|
+
.addOption(new Option('--no-typography', 'Skips typography audit.', false ).hideHelp())
|
|
106
|
+
.option('--property-values <values...>', 'Runs property value audit.', ['font-size', 'padding,padding-top,padding-bottom,padding-right,padding-left', 'margin,margin-top,marin-bottom,marin-right,marin-left'] )
|
|
107
|
+
.addOption(new Option('--no-property-values', 'Skips property values audit.', false ).hideHelp())
|
|
108
|
+
.allowUnknownOption(true)
|
|
109
|
+
.action(env.audit)
|
|
110
|
+
|
|
111
|
+
// JSHint Command.
|
|
112
|
+
program.command('jshint')
|
|
113
|
+
.description('Runs JSHint tool against projects.')
|
|
114
|
+
.addArgument(new Argument('[files...]', 'Files or directory path to JS files.').default(['./src']))
|
|
115
|
+
.option( '--output-filename <name>', 'Filename for the scan results.', 'jshint')
|
|
116
|
+
.option( '--output-folder <folder>', 'Where the hint results should be saved.', 'jshint')
|
|
117
|
+
.allowUnknownOption(true)
|
|
118
|
+
.action(env.hint)
|
|
119
|
+
}
|
|
120
|
+
|
|
42
121
|
|
|
43
122
|
/**
|
|
44
123
|
* Adds commands for wp-env
|
|
@@ -190,132 +269,59 @@ export default function cli() {
|
|
|
190
269
|
})
|
|
191
270
|
.helpCommand(false)
|
|
192
271
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
program.command('build')
|
|
196
|
-
.description('Builds the current project.')
|
|
197
|
-
.allowUnknownOption(true)
|
|
198
|
-
.action(env.webpack)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// Serve Command.
|
|
202
|
-
program.command('serve')
|
|
203
|
-
.description('Serve the current project')
|
|
204
|
-
.option( '--audit', 'Performs WordPress CSS-Audit.', true )
|
|
205
|
-
.option( '--no-audit', 'Skips WordPress CSS-Audit.', false )
|
|
206
|
-
.option( '--a11y', 'Performs IBM Accessibility Checker.', true )
|
|
207
|
-
.option( '--no-a11y', 'Skips IBM Accessibility Checker.', false )
|
|
208
|
-
.allowUnknownOption(true)
|
|
209
|
-
//.action(withSpinner(env.webpack))
|
|
210
|
-
.action(env.webpack)
|
|
272
|
+
// Add Webpack specific commands.
|
|
273
|
+
addWebpackCmds()
|
|
211
274
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.description('Runs accessibility checks.')
|
|
215
|
-
.addArgument(new Argument('<url>', 'URL to scan for accessibility checks.'))
|
|
216
|
-
.option( '--rule-archive <rule>', 'Specify the rule archive.', 'latest')
|
|
217
|
-
.option( '--policies <policy...>', 'Specify one or many policies to scan.', ['WCAG_2_1'])
|
|
218
|
-
.option( '--fail-levels <levels...>', 'Specify one or many violation levels on which to fail the test.', [
|
|
219
|
-
'violation',
|
|
220
|
-
'potentialviolation'
|
|
221
|
-
])
|
|
222
|
-
.option( '--report-levels <levels...>', 'Specify one or many violation levels that should be reported.', [
|
|
223
|
-
'violation',
|
|
224
|
-
'potentialviolation',
|
|
225
|
-
'recommendation',
|
|
226
|
-
'potentialrecommendation',
|
|
227
|
-
'manual',
|
|
228
|
-
'pass'
|
|
229
|
-
])
|
|
230
|
-
.option( '--labels <label...>', 'Specify labels that you would like associated to your scan.', [])
|
|
231
|
-
.option( '--output-format <format>', 'In which formats should the results be output.', ['html'])
|
|
232
|
-
.option( '--output-filename <name>', 'Filename for the scan results.')
|
|
233
|
-
.option( '--output-folder <folder>', 'Where the scan results should be saved.', 'a11y')
|
|
234
|
-
.option( '--output-filename-timestamp', 'Should the timestamp be included in the filename of the reports?', false)
|
|
235
|
-
.allowUnknownOption(true)
|
|
236
|
-
.action(env.a11y)
|
|
275
|
+
// Add wp-env specific commands.
|
|
276
|
+
addWPEnvCommands();
|
|
237
277
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
.option('--colors', 'Runs colors audit.', true )
|
|
246
|
-
.addOption(new Option('--no-colors', 'Skips colors audit.', false ).hideHelp())
|
|
247
|
-
.option('--important', 'Runs !important audit.', true )
|
|
248
|
-
.addOption(new Option('--no-important', 'Skips !important audit.', false ).hideHelp())
|
|
249
|
-
.option('--display-none', 'Runs display: none audit.', true )
|
|
250
|
-
.addOption(new Option('--no-display-none', 'Skips display: none audit.', false ).hideHelp())
|
|
251
|
-
.option('--selectors', 'Runs selectors audit.', true )
|
|
252
|
-
.addOption(new Option('--no-selectors', 'Skips selectors audit.', false ).hideHelp())
|
|
253
|
-
.option('--media-queries', 'Runs media queries audit.', true )
|
|
254
|
-
.addOption(new Option('--no-media-queries', 'Skips media queries audit.', false ).hideHelp())
|
|
255
|
-
.option('--typography', 'Runs typography audit.', true )
|
|
256
|
-
.addOption(new Option('--no-typography', 'Skips typography audit.', false ).hideHelp())
|
|
257
|
-
.option('--property-values <values...>', 'Runs property value audit.', ['font-size', 'padding,padding-top,padding-bottom,padding-right,padding-left', 'margin,margin-top,marin-bottom,marin-right,marin-left'] )
|
|
258
|
-
.addOption(new Option('--no-property-values', 'Skips property values audit.', false ).hideHelp())
|
|
259
|
-
.allowUnknownOption(true)
|
|
260
|
-
.action(env.audit)
|
|
278
|
+
// Update Plugins Command.
|
|
279
|
+
program.command('update-plugins')
|
|
280
|
+
.description('Updates all plugins in the WordPress environment.')
|
|
281
|
+
.argument('[slug]', 'Plugin slug to update.', 'all')
|
|
282
|
+
.addOption(new Option('--environment <env>', 'Which environment to use.').choices(['development', 'tests']).default('development'))
|
|
283
|
+
.allowUnknownOption(true)
|
|
284
|
+
.action( withSpinner(env.updatePlugins) )
|
|
261
285
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
.allowUnknownOption(true)
|
|
269
|
-
.action(env.hint)
|
|
286
|
+
// Create a Design System Block Command.
|
|
287
|
+
program.command('create-block')
|
|
288
|
+
.description('Scaffold for WordPress plugin to register CA.gov Design System Block.')
|
|
289
|
+
.argument('<slug>', 'Plugin slug to use.')
|
|
290
|
+
.allowUnknownOption(true)
|
|
291
|
+
.action( withSpinner(env.createBlock) )
|
|
270
292
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
.action( withSpinner(env.updatePlugins) )
|
|
278
|
-
|
|
279
|
-
// Create a Design System Block Command.
|
|
280
|
-
program.command('create-block')
|
|
281
|
-
.description('Scaffold for WordPress plugin to register CA.gov Design System Block.')
|
|
282
|
-
.argument('<slug>', 'Plugin slug to use.')
|
|
283
|
-
.allowUnknownOption(true)
|
|
284
|
-
.action( withSpinner(env.createBlock) )
|
|
293
|
+
// Update a Design System Block Command.
|
|
294
|
+
program.command('update-block')
|
|
295
|
+
.description('Updates a CA.gov Design System Block.')
|
|
296
|
+
.argument('<slug>', 'Plugin slug to update.')
|
|
297
|
+
.allowUnknownOption(true)
|
|
298
|
+
.action( withSpinner(env.updateBlock) )
|
|
285
299
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
// Ensure this is commented out.
|
|
312
|
-
/*program.command('test')
|
|
313
|
-
.description('Test commands on a WordPress environment')
|
|
314
|
-
//.addArgument(envArg)
|
|
315
|
-
.allowUnknownOption(true)
|
|
316
|
-
.action(withSpinner(env.test))
|
|
317
|
-
*/
|
|
318
|
-
addWPEnvCommands();
|
|
300
|
+
|
|
301
|
+
// Update a Design System Block Command.
|
|
302
|
+
program.command('sync')
|
|
303
|
+
.description('Sync changes from one WordPress instance to another.')
|
|
304
|
+
.argument('<from>', 'Target Site URL.')
|
|
305
|
+
.argument('<to>', 'Destination Site URL.')
|
|
306
|
+
.addOption(new Option(
|
|
307
|
+
'-t,--tax [tax...]',
|
|
308
|
+
'Taxonomy that should be synced. Omitting this option will sync the full site.'
|
|
309
|
+
).choices(['pages', 'posts', 'media', 'menus', 'settings']))
|
|
310
|
+
.addOption(new Option(
|
|
311
|
+
'-i,--include [include...]',
|
|
312
|
+
'IDs to of taxonomies to include. Omitting this option will sync all items for given taxonomy.'
|
|
313
|
+
))
|
|
314
|
+
.allowUnknownOption(true)
|
|
315
|
+
.action( withSpinner(env.sync) )
|
|
316
|
+
|
|
317
|
+
// Test Command.
|
|
318
|
+
// Ensure this is commented out.
|
|
319
|
+
/*program.command('test')
|
|
320
|
+
.description('Test commands on a WordPress environment')
|
|
321
|
+
//.addArgument(envArg)
|
|
322
|
+
.allowUnknownOption(true)
|
|
323
|
+
.action(withSpinner(env.test))
|
|
324
|
+
*/
|
|
319
325
|
|
|
320
326
|
return program;
|
|
321
|
-
};
|
|
327
|
+
};
|
package/lib/helpers.js
CHANGED
|
@@ -30,7 +30,7 @@ const appPath = path.resolve( projectPath, '../../../' );
|
|
|
30
30
|
*
|
|
31
31
|
* @returns {Promise}
|
|
32
32
|
*/
|
|
33
|
-
async function runCmd(cmd, args,opts = { stdio:
|
|
33
|
+
async function runCmd(cmd, args,opts = { stdio: 'pipe' }){
|
|
34
34
|
// fix various commands.
|
|
35
35
|
switch (cmd) {
|
|
36
36
|
case 'npm':
|
|
@@ -103,12 +103,10 @@ async function runCLICmds(
|
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
106
|
export {
|
|
109
107
|
currentPath,
|
|
110
108
|
projectPath,
|
|
111
109
|
appPath,
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
runCmd,
|
|
111
|
+
runCLICmds
|
|
114
112
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
wpRed,
|
|
5
|
-
wpYellow,
|
|
6
|
-
withSpinner,
|
|
7
|
-
} from './spinner.js';
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
runCmd,
|
|
11
|
-
runCLICmds,
|
|
12
|
-
currentPath,
|
|
2
|
+
appPath,
|
|
3
|
+
currentPath,
|
|
13
4
|
projectPath,
|
|
14
|
-
|
|
5
|
+
runCmd,
|
|
6
|
+
runCLICmds
|
|
15
7
|
} from './helpers.js';
|
|
16
8
|
|
|
9
|
+
// Spinner
|
|
10
|
+
import {
|
|
11
|
+
withSpinner,
|
|
12
|
+
} from './spinner.js';
|
|
13
|
+
|
|
14
|
+
// WordPress
|
|
17
15
|
import {
|
|
18
16
|
activateCAWeb,
|
|
19
17
|
configureCAWeb,
|
|
@@ -31,15 +29,11 @@ import {
|
|
|
31
29
|
} from './wordpress/index.js';
|
|
32
30
|
|
|
33
31
|
export {
|
|
32
|
+
appPath,
|
|
34
33
|
currentPath,
|
|
35
34
|
projectPath,
|
|
36
|
-
|
|
37
|
-
wpPrimary,
|
|
38
|
-
wpGreen,
|
|
39
|
-
wpRed,
|
|
40
|
-
wpYellow,
|
|
35
|
+
runCmd,
|
|
41
36
|
withSpinner,
|
|
42
|
-
runCmd,
|
|
43
37
|
runCLICmds,
|
|
44
38
|
activateCAWeb,
|
|
45
39
|
configureCAWeb,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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,38 +56,17 @@
|
|
|
58
56
|
}
|
|
59
57
|
},
|
|
60
58
|
"dependencies": {
|
|
59
|
+
"@caweb/webpack": "^1.0.0",
|
|
61
60
|
"@wordpress/create-block": "^4.45.0",
|
|
62
61
|
"@wordpress/env": "^10.2.0",
|
|
63
|
-
"@wordpress/scripts": "^28.2.0",
|
|
64
|
-
"accessibility-checker": "^3.1.73",
|
|
65
|
-
"autoprefixer": "^10.4.19",
|
|
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-to-json-parser": "^2.0.1",
|
|
81
|
-
"html-webpack-plugin": "^5.6.0",
|
|
82
|
-
"html-webpack-skip-assets-plugin": "^1.0.4",
|
|
83
|
-
"jshint": "^2.13.6",
|
|
84
|
-
"mini-css-extract-plugin": "^2.9.0",
|
|
85
68
|
"ora": "^8.0.1",
|
|
86
|
-
"postcss-loader": "^8.1.1",
|
|
87
69
|
"resolve-bin": "^1.0.1",
|
|
88
|
-
"
|
|
89
|
-
"snyk": "^1.1292.1",
|
|
90
|
-
"terminal-link": "^3.0.0",
|
|
91
|
-
"url": "^0.11.3",
|
|
92
|
-
"webpack": "^5.92.1",
|
|
93
|
-
"webpack-dev-server": "^5.0.4"
|
|
70
|
+
"terminal-link": "^3.0.0"
|
|
94
71
|
}
|
|
95
72
|
}
|