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
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /******************************************************************************
2
3
  Copyright:: 2020- IBM, Inc
3
4
 
@@ -13,16 +14,15 @@
13
14
  See the License for the specific language governing permissions and
14
15
  limitations under the License.
15
16
  *****************************************************************************/
16
-
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ACMetricsLogger = void 0;
17
19
  /*******************************************************************************
18
20
  * NAME: ACMetricsLogger.js
19
21
  * DESCRIPTION: Common Metrics logger object which can be shared between tools
20
22
  * to upload metrics of the tool to the metrics server.
21
23
  *******************************************************************************/
22
-
23
24
  // Load required modules
24
- var request = require('request');
25
-
25
+ var request = require("request");
26
26
  /**
27
27
  * This function is responsible for constructing the accessibility-checker Metrics object which contains all the function
28
28
  * that are needed to upload scan metrics to the metric server.
@@ -35,31 +35,17 @@ var request = require('request');
35
35
  *
36
36
  * @memberOf this
37
37
  */
38
- var ACMetricsLogger = function (toolName, logger, policies) {
39
-
40
- // Variable Decleration
41
- this.metricsURLV2 = "https://able.ibm.com/tools";
42
-
43
- // accessibility-checker Metrics Logger
44
- this.log = logger;
45
-
46
- // Init all the local object variables
47
- this.toolName = toolName;
48
-
49
- // Contains the time it took for a scan for the V1 metric server
50
- this.scanTimesV1 = [];
51
-
52
- // Contains the scan times indexed by profile for V2 metric server
53
- this.scanTimesV2 = {};
54
-
55
- // Additional details to upload to the metrics server
56
- this.policies = policies;
57
-
58
- // In the case that policies provided is an array convert it to a comma seperated list
59
- if (this.policies instanceof Array) {
60
- this.policies = this.policies.join(",");
38
+ var ACMetricsLogger = /** @class */ (function () {
39
+ function ACMetricsLogger(toolName, logger, policies) {
40
+ this.metricsURLV2 = "https://able.ibm.com/tools";
41
+ this.scanTimesV1 = [];
42
+ this.scanTimesV2 = {};
43
+ this.policies = policies.join(",");
44
+ // accessibility-checker Metrics Logger
45
+ this.log = logger;
46
+ // Init all the local object variables
47
+ this.toolName = toolName;
61
48
  }
62
-
63
49
  /**
64
50
  * This function is responsible for profiling the testcases and adding the scan time to the global
65
51
  * array which will be sent to the metrics server to log the number of scans that were performed.
@@ -76,19 +62,16 @@ var ACMetricsLogger = function (toolName, logger, policies) {
76
62
  *
77
63
  * @memberOf this
78
64
  */
79
- this.profileV2 = function (scanTime, profile) {
65
+ ACMetricsLogger.prototype.profileV2 = function (scanTime, profile) {
80
66
  this.log.debug("START 'profileV2' function");
81
-
82
67
  // URI encode the profile text provided
83
68
  profile = encodeURIComponent(profile);
84
-
85
69
  // Add the time it took for the testcase to run to the global array, indexed by the profile
86
70
  this.scanTimesV2[profile] = this.scanTimesV2[profile] || [];
87
71
  this.scanTimesV2[profile].push(scanTime);
88
-
89
72
  this.log.debug("END 'profileV2' function");
90
73
  };
91
-
74
+ ;
92
75
  /**
93
76
  * This function is responsible for uploading scan results to the metrics server:
94
77
  * https://aat.w3ibm.mybluemix.net
@@ -99,66 +82,55 @@ var ACMetricsLogger = function (toolName, logger, policies) {
99
82
  *
100
83
  * @memberOf this
101
84
  */
102
- this.sendLogsV2 = function (done, rulePack) {
85
+ ACMetricsLogger.prototype.sendLogsV2 = function (done, rulePack) {
103
86
  this.log.debug("START 'sendLogsV2' function");
104
-
105
87
  // Copy this.log into loggerInScope so that it can be used in callback function
106
88
  var loggerInScope = this.log;
107
-
108
89
  try {
109
90
  // Variable Decleration
110
- var numProfiles = 0;
91
+ var numProfiles_1 = 0;
111
92
  var accountId = "";
112
-
113
- // Reset the timeout to 0
114
- if (this.timeout) {
115
- this.timeout(0);
116
- }
117
-
118
93
  // Loop over all the profiles with in the scanTime Object
119
94
  for (var profile in this.scanTimesV2) {
120
-
121
- // Loop over all the V2 Scan Times until it reaches 0
122
- while (this.scanTimesV2[profile].length > 0) {
95
+ var _loop_1 = function () {
123
96
  // Build a truncatedScanTime Array to upload to the metrics server chunck by chunck
124
- var subScanTimes = this.scanTimesV2[profile].splice(0, 150);
125
-
97
+ var subScanTimes = this_1.scanTimesV2[profile].splice(0, 150);
126
98
  // Increment the num Profile
127
- ++numProfiles;
128
-
99
+ ++numProfiles_1;
129
100
  // Start building the Query string to be sent to the metrics server
130
- var qs = "?t=" + this.toolName + "&tag=" + profile + "&a=" + accountId + "&pol=" + this.policies + "&st=";
131
-
101
+ var qs = "?t=" + this_1.toolName + "&tag=" + profile + "&a=" + accountId + "&pol=" + this_1.policies + "&st=";
132
102
  subScanTimes.forEach(function (t) {
133
103
  qs += t;
134
104
  qs += ",";
135
105
  });
136
106
  qs = qs.substr(0, qs.length - 1);
137
-
138
- this.log.debug("Uploading: " + this.metricsURLV2 + "/api/pub/meter/v2" + qs);
139
-
107
+ this_1.log.debug("Uploading: " + this_1.metricsURLV2 + "/api/pub/meter/v2" + qs);
140
108
  // Dispatch the call to the metrics server
141
109
  // Istanbul is not able to capture the coverate of functions call in a callback therefore we need to skip
142
110
  /* istanbul ignore next */
143
- request.get(this.metricsURLV2 + "/api/pub/meter/v2" + qs, function () {
111
+ request.get(this_1.metricsURLV2 + "/api/pub/meter/v2" + qs, function () {
144
112
  // Decrement the numProfiles to identify that scan has finished
145
- --numProfiles;
146
-
113
+ --numProfiles_1;
147
114
  // Once all metrics for all profiles have been uploaded we end this function call
148
- if (numProfiles === 0) {
115
+ if (numProfiles_1 === 0) {
149
116
  loggerInScope.debug("END 'sendLogsV2' function");
150
117
  done && done();
151
118
  }
152
119
  });
120
+ };
121
+ var this_1 = this;
122
+ // Loop over all the V2 Scan Times until it reaches 0
123
+ while (this.scanTimesV2[profile].length > 0) {
124
+ _loop_1();
153
125
  }
154
126
  }
155
-
156
127
  // Once all metrics for all profiles have been uploaded we end this function call
157
- if (numProfiles === 0) {
128
+ if (numProfiles_1 === 0) {
158
129
  this.log.debug("END 'sendLogsV2' function");
159
130
  done && done();
160
131
  }
161
- } catch (e) {
132
+ }
133
+ catch (e) {
162
134
  /* istanbul ignore next */
163
135
  this.log.debug("Error uploading metrics logs: " + e);
164
136
  /* istanbul ignore next */
@@ -167,7 +139,9 @@ var ACMetricsLogger = function (toolName, logger, policies) {
167
139
  done && done();
168
140
  }
169
141
  };
170
- };
171
-
172
- // Export this function, which can be used to create a new metrics logger object
173
- module.exports = ACMetricsLogger;
142
+ ;
143
+ return ACMetricsLogger;
144
+ }());
145
+ exports.ACMetricsLogger = ACMetricsLogger;
146
+ ;
147
+ //# sourceMappingURL=ACMetricsLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ACMetricsLogger.js","sourceRoot":"","sources":["../../../src-ts/lib/log/ACMetricsLogger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;+EAc+E;;;AAE/E;;;;iFAIiF;AAEjF,wBAAwB;AACxB,iCAAmC;AAGnC;;;;;;;;;;;GAWG;AACH;IAUI,yBAAY,QAAgB,EAAE,MAAe,EAAE,QAAkB;QARjE,iBAAY,GAAW,4BAA4B,CAAC;QAGpD,gBAAW,GAAG,EAAE,CAAC;QACjB,gBAAW,GAEP,EAAE,CAAC;QAGH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEnC,uCAAuC;QACvC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC;QAElB,sCAAsC;QACtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;I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B,CAAC"}
@@ -0,0 +1,103 @@
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
+ import { IConfigUnsupported } from "../api/IChecker";
17
+ import { IScanSummary } from "./ReportUtil";
18
+ /**
19
+ * This function is responsible for constructing the aChecker Reporter which will be used to, report
20
+ * the scan results, such as writing the page results and the summary to a JSON file. This reporter function
21
+ * is registered with Karma server and triggered based on events that are triggered by the karma communication.
22
+ *
23
+ * @param {Object} baseReporterDecorator - the base karma reporter, which had the base functions which we override
24
+ * @param {Object} this.Config - All the Karma this.Configuration, we will extract what we need from this over
25
+ * all object, we need the entire object so that we detect any changes in the object
26
+ * as other plugins are loaded and the object is updated dynamically.
27
+ * @param {Object} logger - logger object which is used to log debug/error/info messages
28
+ * @param {Object} emitter - emitter object which allows to listem on any event that is triggered and allow to execute
29
+ * custom code, to handle the event that was triggered.
30
+ *
31
+ * @return - N/A
32
+ *
33
+ * @memberOf this
34
+ */
35
+ export declare class ACReporterCSV {
36
+ resultStr: string;
37
+ Config: IConfigUnsupported;
38
+ constructor(config: IConfigUnsupported, scanSummary: IScanSummary);
39
+ report(info: any): void;
40
+ /**
41
+ * This function is responsible for performing any action when the entire karma run is done.
42
+ * Overrides onRunComplete function from baseReporterDecorator
43
+ *
44
+ * @override
45
+ *
46
+ * @memberOf this
47
+ */
48
+ onRunComplete(): void;
49
+ /**
50
+ * This function is responsible for saving a single scans results to a file as JSON. On a side note
51
+ * this function will also extract the label which will be the file names where the results will be
52
+ * saved.
53
+ *
54
+ * @param {Object} this.Config - Karma this.Config object, used to extrat the outputFolder from the ACthis.Config.
55
+ * @param {Object} results - Provide the scan results for a single page that should be saved.
56
+ *
57
+ * @memberOf this
58
+ */
59
+ savePageResults(report: any): void;
60
+ /**
61
+ * This function is responsible for converting a javascript object into JSON and then writing that to a
62
+ * json file.
63
+ *
64
+ * @param {String} fileName - Full path of file where the JSON object should be stored
65
+ * @param {String} content - The javascript object which should be converted and saved to file as JSON.
66
+ *
67
+ * @memberOf this
68
+ */
69
+ writeObjectToFile(fileName: any, content: any): void;
70
+ /**
71
+ * This function is responsible for saving the summary object of the while scan to a summary file.
72
+ *
73
+ * @param {Object} summary - The summary object that needs to be written to the summary file.
74
+ *
75
+ * @memberOf this
76
+ */
77
+ saveSummary(): void;
78
+ /**
79
+ * This function is responsible for indexing the results into global spaces based on label.
80
+ *
81
+ * @param {Object} results - Results object which will be provided to the user/wroten to the file.
82
+ * Refer to aChecker.buildReport function's return to figure out what the object
83
+ * will look like.
84
+ *
85
+ * @return - N/A - Global object is updated with the results
86
+ *
87
+ * @memberOf this
88
+ */
89
+ addResultsToGlobal(results: any): void;
90
+ /**
91
+ * This function is responsible for updating/creating the global violation summary for the engine karma run
92
+ * for browser that it is running on. Will take the pageCount object which is part of the page object and
93
+ * add extract the values for each of the levels and add them to the global object. This will provide an overall
94
+ * summary of violations for all testcases run and all scans done.
95
+ *
96
+ * @param {Object} pageCount - Provide the page count object, in the following format:
97
+ *
98
+ * @return N/A - Global summary object is updated with the counts
99
+ *
100
+ * @memberOf this
101
+ */
102
+ addToSummaryCount(pageCount: any): void;
103
+ }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /******************************************************************************
2
3
  Copyright:: 2020- IBM, Inc
3
4
 
@@ -13,24 +14,31 @@
13
14
  See the License for the specific language governing permissions and
14
15
  limitations under the License.
15
16
  *****************************************************************************/
16
-
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ACReporterCSV = void 0;
17
19
  // Load all the modules that are needed
18
- var pathLib = require('path');
19
- var fs = require('fs');
20
- const path = require("path");
21
- // Variable Declearation
22
- var log;
23
-
24
- // Global aChecker Summary Holder
25
- var scanSummary = {};
26
-
20
+ var pathLib = require("path");
21
+ var fs = require("fs");
22
+ var ACEngineManager_1 = require("../ACEngineManager");
23
+ var toCSV = function (str) {
24
+ if (str === null) {
25
+ return '"null"';
26
+ }
27
+ else if (str.length == 0) {
28
+ return '""';
29
+ }
30
+ else {
31
+ str = str.replace(/"/g, '""');
32
+ return "\"" + str + "\"";
33
+ }
34
+ };
27
35
  /**
28
36
  * This function is responsible for constructing the aChecker Reporter which will be used to, report
29
37
  * the scan results, such as writing the page results and the summary to a JSON file. This reporter function
30
38
  * is registered with Karma server and triggered based on events that are triggered by the karma communication.
31
39
  *
32
40
  * @param {Object} baseReporterDecorator - the base karma reporter, which had the base functions which we override
33
- * @param {Object} config - All the Karma configuration, we will extract what we need from this over
41
+ * @param {Object} this.Config - All the Karma this.Configuration, we will extract what we need from this over
34
42
  * all object, we need the entire object so that we detect any changes in the object
35
43
  * as other plugins are loaded and the object is updated dynamically.
36
44
  * @param {Object} logger - logger object which is used to log debug/error/info messages
@@ -41,29 +49,38 @@ var scanSummary = {};
41
49
  *
42
50
  * @memberOf this
43
51
  */
44
- var ACReporter = function (aChecker) {
45
- let Config = aChecker.Config;
46
- Config.DEBUG && console.log("START ACReporter Constructor");
47
- // Override adapters
48
- this.adapters = [];
49
-
52
+ var ACReporterCSV = /** @class */ (function () {
53
+ function ACReporterCSV(config, scanSummary) {
54
+ this.resultStr = "Label,Level,RuleId,Message,Xpath,Help\n";
55
+ this.Config = config;
56
+ this.Config.DEBUG && console.log("START ACReporter Constructor");
57
+ var myThis = this;
58
+ if (typeof (after) !== "undefined") {
59
+ after(function (done) {
60
+ myThis.onRunComplete();
61
+ done && done();
62
+ });
63
+ }
64
+ else {
65
+ process.on('beforeExit', function () {
66
+ myThis.onRunComplete();
67
+ });
68
+ }
69
+ this.Config.DEBUG && console.log("END ACReporter Constructor");
70
+ }
50
71
  // This emitter function is responsible for calling this function when the info event is detected
51
- this.report = function(info) {
52
- Config.DEBUG && console.log("START 'info' emitter function");
53
-
72
+ ACReporterCSV.prototype.report = function (info) {
73
+ this.Config.DEBUG && console.log("START 'info' emitter function");
54
74
  // Save the results of a single scan to a JSON file based on the label provided
55
- savePageResults(info);
56
-
75
+ this.savePageResults(info);
57
76
  // Update the overall summary object count object to include the new scan that was performed
58
- addToSummaryCount(info.summary.counts);
59
-
77
+ this.addToSummaryCount(info.summary.counts);
60
78
  // Save the summary of this scan into global space of this reporter, to be logged
61
79
  // once the whole scan is done.
62
- addResultsToGlobal(info);
63
-
64
- Config.DEBUG && console.log("END 'info' emitter function");
80
+ this.addResultsToGlobal(info);
81
+ this.Config.DEBUG && console.log("END 'info' emitter function");
65
82
  };
66
-
83
+ ;
67
84
  /**
68
85
  * This function is responsible for performing any action when the entire karma run is done.
69
86
  * Overrides onRunComplete function from baseReporterDecorator
@@ -72,49 +89,31 @@ var ACReporter = function (aChecker) {
72
89
  *
73
90
  * @memberOf this
74
91
  */
75
- this.onRunComplete = function () {
76
- Config.DEBUG && console.log("START 'ACReporterCSV::onRunComplete' function");
77
-
78
- // Add End time when the whole karma run is done
79
- // End time will be in milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now.
80
- scanSummary.endReport = Date.now();
81
-
92
+ ACReporterCSV.prototype.onRunComplete = function () {
93
+ this.Config.DEBUG && console.log("START 'ACReporterCSV::onRunComplete' function");
82
94
  // Save summary object to a JSON file.
83
- saveSummary(scanSummary);
84
-
85
- Config.DEBUG && console.log("END 'ACReporterCSV::onRunComplete' function");
95
+ this.saveSummary();
96
+ this.Config.DEBUG && console.log("END 'ACReporterCSV::onRunComplete' function");
86
97
  };
87
-
88
- var toCSV = function(str) {
89
- if (str === null) {
90
- return '"null"';
91
- } else if (str.length == 0) {
92
- return '""';
93
- } else {
94
- str = str.replace(/"/g, '""');
95
- return `"${str}"`;
96
- }
97
- }
98
+ ;
98
99
  /**
99
100
  * This function is responsible for saving a single scans results to a file as JSON. On a side note
100
101
  * this function will also extract the label which will be the file names where the results will be
101
102
  * saved.
102
103
  *
103
- * @param {Object} config - Karma config object, used to extrat the outputFolder from the ACConfig.
104
+ * @param {Object} this.Config - Karma this.Config object, used to extrat the outputFolder from the ACthis.Config.
104
105
  * @param {Object} results - Provide the scan results for a single page that should be saved.
105
106
  *
106
107
  * @memberOf this
107
108
  */
108
- var savePageResults = function (report) {
109
- Config.DEBUG && console.log("START 'savePageResults' function");
110
-
111
- for (const result of report.results) {
112
- this.resultStr += `${toCSV(report.label)},${toCSV(result.level)},${toCSV(result.ruleId)},${toCSV(result.message)},${toCSV(result.path.dom)},${toCSV(aChecker.getHelpURL(result.ruleId))}\n`
109
+ ACReporterCSV.prototype.savePageResults = function (report) {
110
+ this.Config.DEBUG && console.log("START 'savePageResults' function");
111
+ for (var _i = 0, _a = report.results; _i < _a.length; _i++) {
112
+ var result = _a[_i];
113
+ this.resultStr += toCSV(report.label) + "," + toCSV(result.level) + "," + toCSV(result.ruleId) + "," + toCSV(result.message) + "," + toCSV(result.path.dom) + "," + toCSV(ACEngineManager_1.ACEngineManager.getHelpURL(result.ruleId)) + "\n";
113
114
  }
114
-
115
- Config.DEBUG && console.log("END 'savePageResults' function");
116
- }
117
-
115
+ this.Config.DEBUG && console.log("END 'savePageResults' function");
116
+ };
118
117
  /**
119
118
  * This function is responsible for converting a javascript object into JSON and then writing that to a
120
119
  * json file.
@@ -124,76 +123,25 @@ var ACReporter = function (aChecker) {
124
123
  *
125
124
  * @memberOf this
126
125
  */
127
- var writeObjectToFile = function (fileName, content) {
128
- Config.DEBUG && console.log("START 'writeObjectToFileAsCSV' function");
129
- fileName = path.join(aChecker.Config.outputFolder, fileName);
126
+ ACReporterCSV.prototype.writeObjectToFile = function (fileName, content) {
127
+ this.Config.DEBUG && console.log("START 'writeObjectToFileAsCSV' function");
128
+ fileName = pathLib.join(this.Config.outputFolder, fileName);
130
129
  // Extract the parent directory of the file name that is provided
131
130
  var parentDir = pathLib.dirname(fileName);
132
-
133
- Config.DEBUG && console.log("Parent Directoy: \"" + parentDir + "\"");
134
-
131
+ this.Config.DEBUG && console.log("Parent Directoy: \"" + parentDir + "\"");
135
132
  // In the case that the parent directoy does not exist, create the directories
136
133
  if (!fs.existsSync(parentDir)) {
137
-
138
134
  // Create the parent directory recerseivly if it does not exist.
139
- fs.mkdirSync(parentDir, { recursive: true});
135
+ fs.mkdirSync(parentDir, { recursive: true });
140
136
  }
141
-
142
- Config.DEBUG && console.log("Object will be written to file: \"" + fileName + "\"");
143
-
137
+ this.Config.DEBUG && console.log("Object will be written to file: \"" + fileName + "\"");
144
138
  // Convert the Object into JSON string and write that to the file
145
139
  // Make sure to use utf-8 encoding to avoid an issues specify to OS.
146
140
  // In terms of the JSON string that is constructed use 4 spaces to format the JSON object, before
147
141
  // writing it to the file.
148
142
  fs.writeFileSync(fileName, content, { encoding: 'utf-8' });
149
-
150
- Config.DEBUG && console.log("END 'writeObjectToFileAsCSV' function");
151
- }
152
-
153
- /**
154
- * This function is responsible for initializing the summary object which will store all informations about the
155
- * scans that will occurs while karma is still running and running compliance scans.
156
- *
157
- * @return {Object} scanSummary - return the built scan summary object, which will follow the following format:
158
- * {
159
- * "scanID": "ef3aec68-f073-4f9c-b372-421ae00bd55d",
160
- * "counts": {
161
- * "violation": 0,
162
- * "potentialviolation": 0,
163
- * "recommendation": 0,
164
- * "potentialrecommendation": 0,
165
- * "manual": 0
166
- * },
167
- * "startReport": "2016-06-06T00:52:41.603Z",
168
- * "endReport": "",
169
- * "toolID": "karma-ibma-v1.0.0",
170
- * "policies": [
171
- * "CI162_5_2_DCP070116",
172
- * "CI162_5_2_DCP080115"
173
- * ],
174
- * "reportLevels": [
175
- * "violation",
176
- * "potentialviolation",
177
- * "recommendation",
178
- * "potentialrecommendation",
179
- * "manual"
180
- * ],
181
- * "labels": [
182
- * "Firefox",
183
- * "master",
184
- * "V12",
185
- * "Linux"
186
- * ],
187
- * "pageScanSummary": {}
188
- * }
189
- *
190
- * @memberOf this
191
- */
192
- var initializeSummary = function (config) {
193
- this.resultStr = `Label,Level,RuleId,Message,Xpath,Help\n`
194
- return scanSummary;
195
- }
196
-
143
+ this.Config.DEBUG && console.log("END 'writeObjectToFileAsCSV' function");
144
+ };
197
145
  /**
198
146
  * This function is responsible for saving the summary object of the while scan to a summary file.
199
147
  *
@@ -201,15 +149,14 @@ var ACReporter = function (aChecker) {
201
149
  *
202
150
  * @memberOf this
203
151
  */
204
- var saveSummary = function (summary, done) {
205
- if (Config.outputFormat.indexOf("csv") === -1) {
152
+ ACReporterCSV.prototype.saveSummary = function () {
153
+ if (this.Config.outputFormat.indexOf("csv") === -1) {
206
154
  return;
207
155
  }
208
- Config.DEBUG && console.log("START 'saveSummary' function");
209
- writeObjectToFile("results.csv", this.resultStr);
210
- Config.DEBUG && console.log("END 'saveSummary' function");
211
- }
212
-
156
+ this.Config.DEBUG && console.log("START 'saveSummary' function");
157
+ this.writeObjectToFile("results.csv", this.resultStr);
158
+ this.Config.DEBUG && console.log("END 'saveSummary' function");
159
+ };
213
160
  /**
214
161
  * This function is responsible for indexing the results into global spaces based on label.
215
162
  *
@@ -221,11 +168,10 @@ var ACReporter = function (aChecker) {
221
168
  *
222
169
  * @memberOf this
223
170
  */
224
- var addResultsToGlobal = function (results) {
225
- Config.DEBUG && console.log("START 'addResultsToGlobal' function");
226
- Config.DEBUG && console.log("END 'addResultsToGlobal' function");
227
- }
228
-
171
+ ACReporterCSV.prototype.addResultsToGlobal = function (results) {
172
+ this.Config.DEBUG && console.log("START 'addResultsToGlobal' function");
173
+ this.Config.DEBUG && console.log("END 'addResultsToGlobal' function");
174
+ };
229
175
  /**
230
176
  * This function is responsible for updating/creating the global violation summary for the engine karma run
231
177
  * for browser that it is running on. Will take the pageCount object which is part of the page object and
@@ -238,25 +184,10 @@ var ACReporter = function (aChecker) {
238
184
  *
239
185
  * @memberOf this
240
186
  */
241
- var addToSummaryCount = function (pageCount) {
242
-
243
- }
244
-
245
- scanSummary = initializeSummary();
246
-
247
- var myThis = this;
248
- if (typeof(after) !== "undefined") {
249
- after(function(done) {
250
- myThis.onRunComplete();
251
- done && done();
252
- });
253
- } else {
254
- process.on('beforeExit', function() {
255
- myThis.onRunComplete();
256
- });
257
- }
258
- Config.DEBUG && console.log("END ACReporter Constructor");
259
- };
260
-
261
- // Export this function, which will be called when Karma loads the reporter
262
- module.exports = ACReporter;
187
+ ACReporterCSV.prototype.addToSummaryCount = function (pageCount) {
188
+ };
189
+ return ACReporterCSV;
190
+ }());
191
+ exports.ACReporterCSV = ACReporterCSV;
192
+ ;
193
+ //# sourceMappingURL=ACReporterCSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ACReporterCSV.js","sourceRoot":"","sources":["../../../src-ts/lib/reporters/ACReporterCSV.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;gFAcgF;;;AAEhF,uCAAuC;AACvC,8BAAgC;AAChC,uBAAyB;AACzB,sDAAqD;AAMrD,IAAI,KAAK,GAAG,UAAS,GAAG;IACpB,IAAI,GAAG,KAAK,IAAI,EAAE;QACd,OAAO,QAAQ,CAAC;KACnB;SAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE;QACxB,OAAO,IAAI,CAAC;KACf;SAAM;QACH,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9B,OAAO,OAAI,GAAG,OAAG,CAAC;KACrB;AACL,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH;IAII,uBAAY,MAA0B,EAAE,WAAyB;QAHjE,cAAS,GAAW,yCAAyC,CAAC;QAI1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QACjE,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,I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