accessibility-checker 3.1.0 → 3.1.4

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 (54) hide show
  1. package/README.md +3 -2
  2. package/bin/achecker.d.ts +2 -0
  3. package/bin/achecker.js +293 -177
  4. package/bin/achecker.js.map +1 -0
  5. package/index.d.ts +317 -0
  6. package/index.js +359 -13
  7. package/index.js.map +1 -0
  8. package/lib/ACBrowserManager.d.ts +22 -0
  9. package/lib/ACBrowserManager.js +237 -0
  10. package/lib/ACBrowserManager.js.map +1 -0
  11. package/lib/ACConfigManager.d.ts +6 -0
  12. package/lib/ACConfigManager.js +399 -0
  13. package/lib/ACConfigManager.js.map +1 -0
  14. package/lib/ACConstants.d.ts +17 -0
  15. package/lib/ACConstants.js +12 -38
  16. package/lib/ACConstants.js.map +1 -0
  17. package/lib/ACEngineManager.d.ts +21 -0
  18. package/lib/ACEngineManager.js +220 -0
  19. package/lib/ACEngineManager.js.map +1 -0
  20. package/lib/ACHelper.d.ts +2 -0
  21. package/lib/ACHelper.js +485 -2085
  22. package/lib/ACHelper.js.map +1 -0
  23. package/lib/ACReportManager.d.ts +586 -0
  24. package/lib/ACReportManager.js +1150 -0
  25. package/lib/ACReportManager.js.map +1 -0
  26. package/lib/api/IChecker.d.ts +131 -0
  27. package/lib/api/IChecker.js +11 -0
  28. package/lib/api/IChecker.js.map +1 -0
  29. package/lib/api/IEngine.d.ts +124 -0
  30. package/lib/api/IEngine.js +110 -0
  31. package/lib/api/IEngine.js.map +1 -0
  32. package/lib/api/IMapper.d.ts +37 -0
  33. package/lib/api/IMapper.js +18 -0
  34. package/lib/api/IMapper.js.map +1 -0
  35. package/lib/log/ACMetricsLogger.d.ts +67 -0
  36. package/lib/log/ACMetricsLogger.js +40 -66
  37. package/lib/log/ACMetricsLogger.js.map +1 -0
  38. package/lib/reporters/ACReporterCSV.d.ts +103 -0
  39. package/lib/reporters/ACReporterCSV.js +83 -152
  40. package/lib/reporters/ACReporterCSV.js.map +1 -0
  41. package/lib/reporters/ACReporterHTML.d.ts +114 -0
  42. package/lib/reporters/ACReporterHTML.js +150 -293
  43. package/lib/reporters/ACReporterHTML.js.map +1 -0
  44. package/lib/reporters/ACReporterJSON.d.ts +114 -0
  45. package/lib/reporters/ACReporterJSON.js +95 -249
  46. package/lib/reporters/ACReporterJSON.js.map +1 -0
  47. package/lib/reporters/ReportUtil.d.ts +33 -0
  48. package/lib/reporters/ReportUtil.js +65 -0
  49. package/lib/reporters/ReportUtil.js.map +1 -0
  50. package/lib/reporters/genReport.d.ts +1 -0
  51. package/lib/reporters/genReport.js +13 -11
  52. package/lib/reporters/genReport.js.map +1 -0
  53. package/package.json +4 -3
  54. package/lib/ACConfigLoader.js +0 -358
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genReport.js","sourceRoot":"","sources":["../../../src-ts/lib/reporters/genReport.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC3E,sCAAsC;AACtC,SAAgB,SAAS,CAAC,MAAY;IAClC,IAAI,MAAM,GAAG,ky1uEAAky1uE;UAC7y1uE,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;UAC1C,sMAAsM,CAAC;IACzM,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AALD,8BAKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accessibility-checker",
3
- "version": "3.1.0",
3
+ "version": "3.1.4",
4
4
  "description": "An automated testing tools for accessibility testing using Puppeteer, Selenium, or Zombie",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,13 +14,14 @@
14
14
  "integration",
15
15
  "continuous"
16
16
  ],
17
+ "types": "index.d.ts",
17
18
  "author": "IBM Accessibility",
18
19
  "license": "Apache-2.0",
19
20
  "dependencies": {
20
- "chromedriver": "^83.0.0",
21
+ "chromedriver": "^87.0.5",
21
22
  "deep-diff": "^0.3.4",
22
23
  "js-yaml": "^3.13.1",
23
- "puppeteer": "^2.0.0",
24
+ "puppeteer": "^5.3.0",
24
25
  "request": "^2.88.2"
25
26
  },
26
27
  "repository": {
@@ -1,358 +0,0 @@
1
- /******************************************************************************
2
- Copyright:: 2020- IBM, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- *****************************************************************************/
16
- // Load all the modules that are needed
17
- var pathLib = require('path');
18
- var fs = require('fs');
19
- var YAML = require('js-yaml');
20
- var constants = require("./ACConstants");
21
- var uuid = require('uuid');
22
- var request = require("request");
23
-
24
- /**
25
- * This function is responsible converting policies into an Array based on string or Array.
26
- *
27
- * i.e. convert array into string version of array
28
- * "CI162_5_2_DCP070116,CI162_5_2_DCP070116"
29
- *
30
- * converts to:
31
- *
32
- * [
33
- * "CI162_5_2_DCP070116",
34
- * "CI162_5_2_DCP070116"
35
- * ]
36
- *
37
- * @param {Array or String} policies - Provide list of policies, single policy or comma seperated policies
38
- *
39
- * @return {Array} policies - return the policy converted into Array version
40
- *
41
- * @memberOf this
42
- */
43
- function convertPolicies(policies) {
44
- constants.DEBUG && console.log("START 'convertPolicies' function");
45
-
46
- constants.DEBUG && console.log("Converting policy provided to Array: ");
47
- constants.DEBUG && console.log(policies);
48
-
49
- constants.DEBUG && console.log("END 'convertPolicies' function");
50
-
51
- // In the case policies is an Array return it as engine expects list
52
- if (policies instanceof Array) {
53
- return policies;
54
- }
55
- // If the policies is string, we need to convert it to an array. Which includes comma seperated string support also
56
- else if (typeof policies === "string") {
57
- return policies.split(',');
58
- }
59
-
60
- return policies;
61
- }
62
-
63
- /**
64
- * This function is responsible processing the achecker config which was initialized to make sure it contains,
65
- * information which matches what the engine reads.
66
- *
67
- * i.e.
68
- * Need to change reportLevels and failLevels to match with level declerations in the engine.
69
- * replace violation with level.violation
70
- * Need to change array of policies into a string
71
- * ["CI162_5_2_DCP070116","CI162_5_2_DCP070116"] to "CI162_5_2_DCP070116,CI162_5_2_DCP070116"
72
- *
73
- * @param {Object} ACConfig - Provide the config object in which needs to be processed.
74
- *
75
- * @return {Object} ACConfig - return the config object which has been made engine readable
76
- *
77
- * @memberOf this
78
- */
79
- async function processACConfig(ACConfig) {
80
- constants.DEBUG && console.log("START 'processACConfig' function");
81
-
82
- // Convert the reportLevels and failLevels to match with what the engine provides
83
- // Don't need to convert the levels from the input as we are going to compare with out the level.
84
- // by using contains algo, so that in the reports we can add it without level, until the engine is
85
- // updated to pass back with out level.
86
- //ACConfig.reportLevels = mapLevelsToEngineReadableLevels(ACConfig.reportLevels);
87
- //ACConfig.failLevels = mapLevelsToEngineReadableLevels(ACConfig.failLevels);
88
-
89
- // Convert the policies into a comma seperated string
90
- ACConfig.policies = convertPolicies(ACConfig.policies);
91
-
92
- if (ACConfig.customRuleServer) {
93
- constants.DEBUG && console.log("Specified Usage of custom Rule Server, switching to custom rule server");
94
-
95
- // Set the ruleArchive to empty for custom rule server
96
- ACConfig.ruleArchive = "";
97
- // Set the rulePack with what is provided in the configuration
98
- ACConfig.rulePack = ACConfig.rulePack;
99
- } else {
100
- // In the case that baseA11yServerURL is provided in the config use that as the base otherwise switch to the default one from the constants object
101
- var baseA11yServerURL = ACConfig.baseA11yServerURL ? ACConfig.baseA11yServerURL : constants.baseA11yServerURL;
102
-
103
- // Get and parse the rule archive.
104
- var ruleArchiveFile = `${baseA11yServerURL}/archives.json`;
105
- let ruleArchiveParse;
106
- try {
107
- ruleArchiveParse = await new Promise((resolve, reject) => {
108
- request.get(ruleArchiveFile, function (error, response, body) {
109
- if (error) {
110
- reject(error);
111
- } else {
112
- resolve(JSON.parse(body));
113
- }
114
- });
115
- });
116
- } catch (err) {
117
- console.log(err);
118
- process.exit(-1);
119
- }
120
- if (ruleArchiveParse && ruleArchiveParse.length > 0) {
121
- constants.DEBUG && console.log("Found archiveFile: " + ruleArchiveFile);
122
- ACConfig.ruleArchiveSet = ruleArchiveParse;
123
- var ruleArchive = ACConfig.ruleArchive;
124
- var ruleArchivePath = null;
125
- for (var i = 0; i < ACConfig.ruleArchiveSet.length; i++) {
126
- if (ruleArchive == ACConfig.ruleArchiveSet[i].id && !ACConfig.ruleArchiveSet[i].sunset) {
127
- ruleArchivePath = ACConfig.ruleArchiveSet[i].path;
128
- ACConfig.ruleArchive = ruleArchiveParse[i].name + " (" + ruleArchiveParse[i].id + ")";
129
- break;
130
- }
131
- }
132
- if (!ruleArchivePath) {
133
- console.log("[ERROR] RuleArchiveInvalid: Make Sure correct rule archive is provided in the configuration file. More information is available in the README.md");
134
- process.exit(-1);
135
- }
136
- //}
137
- } else {
138
- console.log("[ERROR] UnableToParseArchive: Archives are unable to be parse. Contact support team.");
139
- process.exit(-1);
140
- }
141
-
142
- // Build the new rulePack based of the baseA11yServerURL
143
- ACConfig.rulePack = `${baseA11yServerURL}${ruleArchivePath}/js`;
144
-
145
- constants.DEBUG && console.log("Built new rulePack: " + ACConfig.rulePack);
146
- }
147
-
148
- constants.DEBUG && console.log("END 'processACConfig' function");
149
-
150
- // Return the updated ACConfig object
151
- return ACConfig;
152
- }
153
-
154
- /**
155
- * This function is responsible initializing all the default values for the configurations, in the case any
156
- * of the config options are missing.
157
- *
158
- * @param {Object} config - Provide the config object in which we need to initialize the default values.
159
- *
160
- * @return {Object} config - return the config object which has all the default values, in the case
161
- * some of the options are null or undefined.
162
- *
163
- * @memberOf this
164
- */
165
- function initializeDefaults(config) {
166
- constants.DEBUG && console.log("START 'initializeDefaults' function");
167
-
168
- constants.DEBUG && console.log("Config before initialization: ");
169
- constants.DEBUG && console.log(config);
170
-
171
- // Check to make sure the rule pack server is defined, if not then set the default vaule
172
- config.rulePack = config.rulePack || constants.rulePack;
173
-
174
- // Make sure all the following options are defined, otherwise reset them to default values.
175
- config.policies = config.policies || constants.policies;
176
- config.failLevels = config.failLevels || constants.failLevels;
177
- config.reportLevels = config.reportLevels || constants.reportLevels;
178
- config.outputFolder = config.outputFolder || constants.outputFolder;
179
- config.baselineFolder = config.baselineFolder || constants.baselineFolder;
180
- config.outputFormat = config.outputFormat || constants.outputFormat;
181
- config.checkHiddenContent = config.checkHiddenContent || constants.checkHiddenContent;
182
- config.extensions = config.extensions || constants.extensions;
183
- config.engineFileName = config.engineFileName || constants.engineFileName;
184
- config.ruleArchive = config.ruleArchive || constants.ruleArchive;
185
- // For capture screenshots need to check for null or undefined and then set default otherwise it will evaluate the
186
- // boolean which causes it to always comply with the default value and not user provided option
187
- if (config.captureScreenshots === null || config.captureScreenshots === undefined || typeof config.captureScreenshots === "undefined") {
188
- config.captureScreenshots = constants.captureScreenshots;
189
- }
190
-
191
- // Load in the package.json file so that we can extract the module name and the version to build
192
- // a toolID which needs to be used when results are build for the purpose of keeping track of
193
- // which tool is uploading the results.
194
- var packageObject = require('../package.json');
195
-
196
- // Build the toolID based on name and version
197
- config.toolID = packageObject.name + "-v" + packageObject.version;
198
-
199
- // Using the uuid module generate a uuid number which is used to assoiciate to the scans that
200
- // are done for a single run of karma.
201
- config.scanID = uuid.v4();
202
-
203
- constants.DEBUG && console.log("Config after initialization: ");
204
- constants.DEBUG && console.log(config);
205
-
206
- constants.DEBUG && console.log("END 'initializeDefaults' function");
207
- }
208
-
209
- /**
210
- * This function is responsible reading in the .yaml or .yml or .json and set the config options based on this.
211
- *
212
- * @return {Object} config - return the config object that was read in, refer to function initializeDefaults
213
- * to view how the object is to be constructed.
214
- *
215
- * @memberOf this
216
- */
217
- function loadConfigFromYAMLorJSONFile() {
218
- constants.DEBUG && console.log("START 'loadConfigFromYAMLorJSONFile' function");
219
-
220
- // Variable Decleration
221
- var config = {};
222
-
223
- // Get the current working directory, where we will look for the yaml, yml or json file
224
- var workingDir = process.cwd();
225
-
226
- constants.DEBUG && console.log("Working directory set to: " + workingDir);
227
-
228
- // List of files to look for in that order, in the case even one is found we stop and load that as the config.
229
- // Theses files will be checked for in the working directory:
230
- // ./.achecker.yml
231
- // ./.achecker.yaml
232
- // ./achecker.js
233
- // ./achecker.json
234
- // ./.config/.achecker.yml
235
- // ./.config/.achecker.yaml
236
- // ./.config/achecker.js
237
- // ./.config/achecker.json
238
- // The node module, require will load js or json depending on which one is present, in the case
239
- // both json and js are present it loads js first.
240
- // Refer to constants.js for more details
241
- var configFiles = constants.configFiles;
242
-
243
- // Loop over all the possible location where the config file can reside, if one is found load it and break out.
244
- for (var i = 0; i < configFiles.length; i++) {
245
-
246
- // Get the full path to the config file we are going to check
247
- var fileToCheck = pathLib.join(workingDir, configFiles[i]);
248
-
249
- constants.DEBUG && console.log("Checking file: " + fileToCheck);
250
-
251
- // Get the extension of the file we are about to scan
252
- var fileExtension = fileToCheck.substr(fileToCheck.lastIndexOf('.') + 1);
253
-
254
- // If this is a yml or yaml file verify that the file exists and then load as such.
255
- if (fileExtension === "yml" || fileExtension === "yaml") {
256
- // Start checking which files exists, if it exists then load it as the config that was read in
257
- // We only allow specifying a file, and the order it checks is based on what is specified in the array.
258
- // i.e. So in the case that it finds yml, it will load and not check the rest, etc...
259
- if (fs.existsSync(fileToCheck)) {
260
-
261
- constants.DEBUG && console.log("File: " + fileToCheck + " exists loading it.");
262
-
263
- constants.DEBUG && console.log("Loading as YAML file.");
264
-
265
- // Load in as yml or yaml file and return this object
266
- return YAML.safeLoad(fs.readFileSync(fileToCheck), 'utf8');
267
- }
268
- } else {
269
- constants.DEBUG && console.log("Trying to load as json or js.");
270
-
271
- // Need to use try/catch mech so that in the case the require throws an exception, we can
272
- // catch this and discatd the error, as in the case there is no config file provided then
273
- // we load in default values.
274
- try {
275
-
276
- // call the resolve to check if the file exists or not, and get the actualy path if it was js or json
277
- var jsOrJSONFile = require.resolve(fileToCheck);
278
-
279
- // Only try to load the achecker js or json file if it exists.
280
- if (jsOrJSONFile) {
281
-
282
- constants.DEBUG && console.log("Loading: " + jsOrJSONFile)
283
-
284
- // Load in as json or js and return this object
285
- return require(fileToCheck);
286
- }
287
- } catch (e) {
288
- constants.DEBUG && console.log("JSON or JS file does not exists, will load default config.")
289
- }
290
- }
291
- }
292
-
293
- constants.DEBUG && console.log("END 'loadConfigFromYAMLorJSONFile' function");
294
-
295
- return config;
296
- }
297
-
298
- /**
299
- * This function is responsible for processing the karma configuration for accessibility-checker.
300
- * The ACConfig provided in the Karma configuration will be processed by this
301
- * function and then the config variables will be assoiciated to the global space so that
302
- * they can be accessed from window.__karma__.config
303
- *
304
- * @param {Object} config - All the Karma configuration, we will extract what we need from this over
305
- * all object, we need the entire object so that we can reasign some config
306
- * variables to global scope so that all karma testscases/scripts can access
307
- * them.
308
- *
309
- * @return - N/A - Object will be processed and all the params that are needed for this module will
310
- * be extracted and then the entire object will be added to global space.
311
- *
312
- * @memberOf this
313
- */
314
- async function processConfiguration(config) {
315
- constants.DEBUG && console.log("START 'processConfiguration' function");
316
-
317
- // Variable Decleration
318
- var ACConfig = null;
319
- var configFromFile = null;
320
-
321
- // Read in the .yaml (.yml) or .json file to load in the configuration
322
- configFromFile = loadConfigFromYAMLorJSONFile();
323
-
324
- constants.DEBUG && console.log("Loaded config from file: ");
325
- constants.DEBUG && console.log(configFromFile);
326
-
327
- // In the case configuration was provided in a yaml, yml or json file, then set this as the configuration
328
- // otherwise load them from the Karma configuration.
329
- if (configFromFile !== null && typeof (configFromFile) !== "undefined" && Object.keys(configFromFile).length !== 0) {
330
- constants.DEBUG && console.log("Using config which was loaded from config file.");
331
-
332
- ACConfig = configFromFile;
333
- } else if (config !== null && typeof (config) !== "undefined" && Object.keys(config).length !== 0) {
334
- // Extract the ACConfig from the overall karma configuration, in the case config file
335
- // was not provided.
336
- ACConfig = config;
337
- } else {
338
- ACConfig = {};
339
- }
340
-
341
- // In the case the ACConfig object is not defined, then define it with default config options so
342
- // it can be set in window.__karma__.config.ACConfig, so that we know even in the testcases, other
343
- // wrapper scripts that there was nothing defined at all, and at the same time to make sure that this
344
- // code was actually executed.
345
- initializeDefaults(ACConfig);
346
-
347
- // Now we process the final accessibility-checker config object that is build to make sure it is valid, also need to perform some
348
- // mapping for provided paremeters to actualy read by the engine.
349
- await processACConfig(ACConfig);
350
-
351
- // In the case the Karma config is set to config.LOG_DEBUG then also enable the accessibility-checker debuging
352
- ACConfig.DEBUG = constants.DEBUG;
353
-
354
- constants.DEBUG && console.log("END 'processConfiguration' function");
355
- return ACConfig;
356
- }
357
-
358
- module.exports = processConfiguration();