@caweb/a11y-webpack-plugin 2.0.4 → 2.1.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.
Files changed (3) hide show
  1. package/index.js +6 -13
  2. package/package.json +5 -5
  3. package/reporter.js +6 -41
package/index.js CHANGED
@@ -13,8 +13,6 @@ import chalk from 'chalk';
13
13
  import { fileURLToPath, URL, pathToFileURL } from 'url';
14
14
  import { createRequire } from 'module';
15
15
 
16
- const require = createRequire(import.meta.url);
17
-
18
16
  /**
19
17
  * Internal dependencies
20
18
  */
@@ -23,10 +21,12 @@ import { landingPage } from './reporter.js';
23
21
  // default configuration
24
22
  import {default as DefaultConfig} from './aceconfig.js';
25
23
 
26
- const pluginName = 'CAWebA11yWebpackPlugin';
24
+ const require = createRequire(import.meta.url);
25
+
26
+ const pluginName = 'CAWebA11yPlugin';
27
27
 
28
28
  // IBM Accessibility Checker Plugin
29
- class CAWebA11yWebpackPlugin {
29
+ class CAWebA11yPlugin {
30
30
  config = {}
31
31
 
32
32
  constructor(opts = {}) {
@@ -133,16 +133,9 @@ class CAWebA11yWebpackPlugin {
133
133
  console.log('<i> \x1b[32m[webpack-dev-middleware] Running IBM Accessibility scan...\x1b[0m');
134
134
  /**
135
135
  * We run the accessibility checker
136
- *
137
- * we scan the output.publicPath if its set and not set to 'auto'
138
- * otherwise we scan the output.path
139
136
  */
140
- let scanDir = compiler.options.output.publicPath && 'auto' !== compiler.options.output.publicPath ?
141
- compiler.options.output.publicPath :
142
- compiler.options.output.path;
143
-
144
137
  this.a11yCheck(
145
- scanDir,
138
+ compiler.options.output.path,
146
139
  this.config
147
140
  );
148
141
 
@@ -286,4 +279,4 @@ class CAWebA11yWebpackPlugin {
286
279
  } // end of class
287
280
 
288
281
 
289
- export default CAWebA11yWebpackPlugin;
282
+ export default CAWebA11yPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/a11y-webpack-plugin",
3
- "version": "2.0.4",
3
+ "version": "2.1.1",
4
4
  "description": "CAWebPublishing Webpack Plugin to run Accessibility Scans",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -35,13 +35,13 @@
35
35
  "webpack"
36
36
  ],
37
37
  "dependencies": {
38
- "@caweb/webpack": "^1.6.3",
39
- "accessibility-checker": "^4.0.10",
38
+ "@caweb/webpack": "^1.6.6",
39
+ "accessibility-checker": "^4.0.12",
40
40
  "check-valid-url": "^0.1.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@caweb/html-webpack-plugin": "^2.0.2",
44
- "webpack": "^5.104.1",
43
+ "@caweb/html-webpack-plugin": "^2.1.5",
44
+ "webpack": "^5.105.1",
45
45
  "webpack-cli": "^6.0.1"
46
46
  }
47
47
  }
package/reporter.js CHANGED
@@ -3,26 +3,11 @@
3
3
  */
4
4
  import path from 'path';
5
5
  import fs from 'fs';
6
- import HandleBars from 'handlebars';
7
6
  import htmlFormat from 'html-format';
8
-
9
- import endsWith from '@caweb/webpack/helpers/logic/endsWith.js';
10
-
7
+ import HandleBars from '@caweb/webpack/lib/handlebars.js';
11
8
 
12
9
  const templateDir = path.resolve( 'node_modules', '@caweb', 'template' );
13
10
 
14
- let templatePartials = {
15
- 'header': 'semantics/header.html',
16
- 'footer': 'semantics/footer.html',
17
- 'utilityHeader': 'semantics/utility-header.html',
18
- 'branding': 'semantics/branding.html',
19
- 'mobileControls': 'semantics/mobile-controls.html',
20
- 'navHeader': 'semantics/nav-header.html',
21
- 'navFooter': 'semantics/nav-footer.html',
22
- 'alert': 'components/alert/alert.html',
23
- 'searchForm': 'forms/search.html'
24
- }
25
-
26
11
  let sortedReport = {
27
12
  errors: [],
28
13
  warnings: [],
@@ -165,18 +150,6 @@ function addBreakdown({
165
150
  </section>`;
166
151
  }
167
152
 
168
- function initHandleBars(){
169
- // Register partials.
170
- Object.entries(templatePartials).forEach(([p, f]) => HandleBars.registerPartial(p, fs.readFileSync(path.resolve(templateDir, f )).toString() ) );
171
-
172
-
173
- // Register custom helpers.
174
- HandleBars.registerHelper('endsWith', endsWith )
175
-
176
- return HandleBars.compile(fs.readFileSync(path.resolve(templateDir, 'patterns', 'default.html')).toString() )
177
-
178
- }
179
-
180
153
  /**
181
154
  * JSHint Reporter
182
155
  *
@@ -348,17 +321,16 @@ function landingPage(data, opts ){
348
321
  '<table class="table"><thead><tr><th>Page Auditted</th><th>Audit</th></thead><tbody>',
349
322
  ...data.sort().map(file => {
350
323
  // remove the .json extension from the file name
351
- file = file.replace(/\.json$/, '');
324
+ // we also replace backslashes with forward slashes for better readability
325
+ file = file.replace(/\.json$/, '').replace(/\\/g, '/');
352
326
 
353
- return `<tr><td><a href="/${file}" target="_blank">/${file}</a></td><td><a href="${file}" target="_blank">${file}</a></td></tr>`
327
+ return `<tr><td><a href="${file}" target="_blank">${file}</a></td><td><a href="${file}" target="_blank">${file}</a></td></tr>`
354
328
  }),
355
329
  '</tbody></table>',
356
330
  '</div></div></div>'
357
331
  )
358
332
 
359
- HandleBars.registerPartial('index', output.join('\n') );
360
-
361
- let template = initHandleBars();
333
+ let template = HandleBars.compile(fs.readFileSync(path.resolve(templateDir, 'patterns', 'default.html')).toString() )
362
334
 
363
335
  fs.mkdirSync( outputFolder, {recursive: true} );
364
336
 
@@ -369,10 +341,7 @@ function landingPage(data, opts ){
369
341
  template({
370
342
  title: `${title} for ${process.cwd().split('\\').pop()}`,
371
343
  scheme: 'oceanside',
372
- assets: [
373
- fs.existsSync( path.join(outputFolder, 'a11y.update.js' ) ) ?
374
- 'a11y.update.js' : '' // if the hot module update file exists, add it
375
- ].filter(Boolean)
344
+ partial: output.join('\n'),
376
345
  }),
377
346
  " ".repeat(4), 250
378
347
  )
@@ -380,10 +349,6 @@ function landingPage(data, opts ){
380
349
 
381
350
  }
382
351
 
383
- function capitalCase(str){
384
- return str.charAt(0).toUpperCase() + str.slice(1)
385
- }
386
-
387
352
  export {
388
353
  reporter,
389
354
  landingPage