@caweb/cli 1.4.0 → 1.4.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/a11y.js CHANGED
@@ -3,9 +3,10 @@
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
+ import achecker from 'accessibility-checker';
6
7
  import path from 'path';
8
+ import { isUrl } from 'check-valid-url';
7
9
  import fs from 'fs';
8
- import resolveBin from 'resolve-bin';
9
10
 
10
11
  /**
11
12
  * Internal dependencies
@@ -16,7 +17,7 @@ import defaultConfig from '../configs/aceconfig.js';
16
17
  import {
17
18
  runCmd,
18
19
  } from '../lib/index.js';
19
-
20
+ import { stderr, stdout } from 'process';
20
21
 
21
22
 
22
23
  /**
@@ -25,14 +26,17 @@ import {
25
26
  * @param {Object} options
26
27
  * @param {Object} options.spinner A CLI spinner which indicates progress.
27
28
  * @param {boolean} options.debug True if debug mode is enabled.
29
+ * @param {boolean} options.url True if debug mode is enabled.
28
30
  */
29
31
  export default async function a11y({
30
32
  spinner,
31
33
  debug,
34
+ url
32
35
  } ) {
33
36
 
34
37
  // Spinner not needed at the moment
35
- spinner.stop()
38
+ spinner.stop();
39
+
36
40
  const {
37
41
  ruleArchive,
38
42
  policies,
@@ -62,13 +66,30 @@ export default async function a11y({
62
66
  outputFormat,
63
67
  '---outputFilenameTimestamp',
64
68
  outputFilenameTimestamp,
65
- process.argv.pop()
69
+ url
66
70
  ];
67
71
 
68
- // run webpack with our arguments.
69
- await runCmd(
70
- 'achecker',
71
- acheckerArgs,
72
- )
72
+ // run accessibility checker with our arguments.
73
+ if( isUrl( url ) || fs.existsSync( url ) ){
74
+ let outputDir = path.resolve('.', outputFolder);
75
+ let outputFileName = isUrl( url ) ?
76
+ url.replace(/http[s]+:\/\//, '')
77
+ :
78
+ path.resolve(url).replace(':', '_');
79
+
80
+
81
+ let reportFile = path.resolve(outputDir, outputFileName ) + '.html'
82
+
83
+ await runCmd(
84
+ 'achecker',
85
+ acheckerArgs,
86
+ ).then(({stderr, stdout}) => {
87
+ console.log( reportFile );
88
+ })
89
+
90
+ }else{
91
+ console.log( `${url} is not a valid url.` )
92
+ }
93
+
73
94
 
74
95
  };
package/commands/serve.js CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  runCmd
16
16
  } from '../lib/index.js';
17
17
 
18
+ import a11y from './a11y.js';
19
+
18
20
  /**
19
21
  * Serves the current project
20
22
  *
@@ -79,6 +81,11 @@ export default async function serve({
79
81
  if( stderr && ! stdout.toString() ){
80
82
  console.log( stderr.toString() )
81
83
  }else{
84
+
85
+ // run a11y checker as well
86
+ //await a11y({spinner, debug, url: './public/index.html' })
87
+
88
+ //return;
82
89
  spinner.text = 'Done'
83
90
  }
84
91
  });
@@ -7,7 +7,7 @@
7
7
  import path from 'node:path';
8
8
  import fs from 'fs-extra';
9
9
 
10
- import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../../lib/options.js';
10
+ import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../../lib/index.js';
11
11
 
12
12
  generateOverridesMD()
13
13
 
package/lib/cli.js CHANGED
@@ -227,6 +227,7 @@ export default function cli() {
227
227
 
228
228
  // a11y Command.
229
229
  program.command('a11y')
230
+ .addArgument(new Argument('<url>', 'URL to scan for accessibility checks.'))
230
231
  .description('Runs accessibility checks.')
231
232
  .allowUnknownOption(true)
232
233
  .action(withSpinner(env.a11y))
package/lib/helpers.js CHANGED
@@ -40,9 +40,12 @@ async function runCmd(cmd, args,opts = { stdio: ['inherit', 'pipe'] }){
40
40
  */
41
41
  cmd += /^win/.test(process.platform) ? '.cmd' : '';
42
42
  break;
43
+ case 'achecker':
44
+ cmd = resolveBin('accessibility-checker', {executable: 'achecker'})
45
+ break;
43
46
  case 'webpack':
44
47
  cmd = resolveBin(cmd)
45
- break
48
+ break;
46
49
  }
47
50
 
48
51
  return spawn.sync( cmd, args, {...opts, env: process.env});
package/lib/index.js CHANGED
@@ -25,7 +25,9 @@ import {
25
25
  convertToMultisite,
26
26
  generateHTAccess,
27
27
  getTaxonomies,
28
- createTaxonomies
28
+ createTaxonomies,
29
+ CAWEB_OPTIONS,
30
+ DIVI_OPTIONS
29
31
  } from './wordpress/index.js';
30
32
 
31
33
  export {
@@ -49,5 +51,7 @@ export {
49
51
  convertToMultisite,
50
52
  generateHTAccess,
51
53
  getTaxonomies,
52
- createTaxonomies
54
+ createTaxonomies,
55
+ CAWEB_OPTIONS,
56
+ DIVI_OPTIONS
53
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/cli",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "CAWebPublishing Command Line Interface.",
5
5
  "exports": "./lib/env.js",
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  "template"
23
23
  ],
24
24
  "scripts": {
25
+ "doc": "node ./docs/tool/index.js",
25
26
  "test": "echo \"Error: run tests from root\" && exit 0"
26
27
  },
27
28
  "homepage": "https://github.com/CAWebPublishing/cli#readme",
@@ -58,14 +59,15 @@
58
59
  }
59
60
  },
60
61
  "dependencies": {
61
- "@wordpress/create-block": "^4.43.0",
62
- "@wordpress/env": "^10.0.0",
63
- "@wordpress/scripts": "^28.0.0",
64
- "accessibility-checker": "^3.1.72",
62
+ "@wordpress/create-block": "^4.44.0",
63
+ "@wordpress/env": "^10.1.0",
64
+ "@wordpress/scripts": "^28.1.0",
65
+ "accessibility-checker": "^3.1.73",
65
66
  "autoprefixer": "^10.4.19",
66
67
  "axios": "^1.7.2",
67
68
  "axios-retry": "^4.4.0",
68
69
  "chalk": "^5.3.0",
70
+ "check-valid-url": "^0.1.0",
69
71
  "commander": "^12.1.0",
70
72
  "cross-spawn": "^7.0.3",
71
73
  "css-loader": "^7.1.2",
@@ -82,6 +84,6 @@
82
84
  "sass-loader": "^14.2.1",
83
85
  "terminal-link": "^3.0.0",
84
86
  "url": "^0.11.3",
85
- "webpack": "^5.92.0"
87
+ "webpack": "^5.92.1"
86
88
  }
87
89
  }