@acot/reporter
Advanced tools
Comparing version 0.0.1 to 0.0.2-canary.0
@@ -6,2 +6,8 @@ # Change Log | ||
## [0.0.2-canary.0](https://github.com/acot-a11y/acot/compare/@acot/reporter@0.0.1...@acot/reporter@0.0.2-canary.0) (2020-11-02) | ||
### Bug Fixes | ||
- **reporter:** Fix a bug that PrettyReporter hangs in the case of many URLs ([7248532](https://github.com/acot-a11y/acot/commit/7248532c0380a0483a537c124173f2191027dd54)) | ||
## 0.0.1 (2020-10-31) | ||
@@ -8,0 +14,0 @@ |
@@ -17,16 +17,8 @@ "use strict"; | ||
const plur_1 = __importDefault(require("plur")); | ||
const strip_ansi_1 = __importDefault(require("strip-ansi")); | ||
const html_pickup_1 = require("@acot/html-pickup"); | ||
const factory_1 = require("../factory"); | ||
const readFile = util_1.promisify(fs_1.default.readFile); | ||
const getSymbol = (result) => { | ||
let symbol = log_symbols_1.default.success; | ||
if (result.errorCount > 0) { | ||
symbol = log_symbols_1.default.error; | ||
} | ||
else { | ||
symbol = log_symbols_1.default.warning; | ||
} | ||
return symbol; | ||
}; | ||
const count = (s, n) => `${n} ${plur_1.default(s, n)}`; | ||
const stringLength = (s) => strip_ansi_1.default(s).length; | ||
class AuditProgress { | ||
@@ -36,20 +28,15 @@ constructor(urls, stream) { | ||
this._timer = null; | ||
this._text = 'Waiting...'; | ||
this._urls = urls; | ||
this._stream = stream; | ||
this._map = new Map(); | ||
this._spinner = ora_1.default({ color: 'gray', stream }); | ||
this._update = log_update_1.default.create(stream); | ||
} | ||
isComplete() { | ||
return this._current >= this._urls.length; | ||
} | ||
start() { | ||
this._urls.forEach((url) => { | ||
const text = chalk_1.default.bold(url); | ||
this._map.set(url, [ | ||
ora_1.default({ color: 'gray', stream: this._stream }), | ||
text, | ||
null, | ||
]); | ||
}); | ||
this._loop(); | ||
} | ||
increment(result) { | ||
const entry = this._map.get(result.url); | ||
const summary = [ | ||
@@ -60,8 +47,6 @@ count('error', result.errorCount), | ||
].join(', '); | ||
const text = chalk_1.default `{bold ${result.url}} {gray (${summary})}`; | ||
this._map.set(result.url, [entry[0], text, result]); | ||
this._text = `${result.url} (${summary})`; | ||
this._current++; | ||
if (this._current >= this._urls.length) { | ||
this.stop(); | ||
this._render(); | ||
if (this.isComplete()) { | ||
this.done(); | ||
} | ||
@@ -75,14 +60,28 @@ } | ||
} | ||
done() { | ||
this.stop(); | ||
this._text = 'DONE'; | ||
this._render(); | ||
} | ||
_render() { | ||
const total = this._urls.length; | ||
const percent = Math.floor((this._current / total) * 100); | ||
let output = chalk_1.default `{bold Running on ${total} URLs:} {cyan ${percent}%}\n`; | ||
this._map.forEach(([spinner, text, result]) => { | ||
if (result != null) { | ||
output += `${getSymbol(result)} ${text}\n`; | ||
} | ||
else { | ||
output += `${spinner.frame()}${text}\n`; | ||
} | ||
}); | ||
const progress = this._current / total; | ||
const percent = `${Math.floor(progress * 100)}`.padStart(3); | ||
const format = { | ||
size: 30, | ||
complete: '\u2588', | ||
incomplete: '\u2591', | ||
}; | ||
const complete = Math.round(progress * format.size); | ||
const incomplete = format.size - complete; | ||
const bar = format.complete.repeat(complete) + | ||
chalk_1.default.gray(format.incomplete.repeat(incomplete)); | ||
const spinner = this.isComplete() ? '' : `${this._spinner.frame()}`; | ||
let output = [ | ||
chalk_1.default.bold(`Running on ${total} URLs:`), | ||
chalk_1.default `{cyan ${percent}%} ${bar} ${spinner}{gray ${this._text}}`, | ||
].join('\n'); | ||
if (this.isComplete()) { | ||
output += '\n'; | ||
} | ||
this._update(output); | ||
@@ -112,3 +111,3 @@ } | ||
this._stream.write(`${output}\n`); | ||
if (this._current >= total) { | ||
if (this.isComplete()) { | ||
this._stream.write('\n'); | ||
@@ -125,7 +124,13 @@ } | ||
let spinner; | ||
stdout.write(boxen_1.default(text_table_1.default([ | ||
['acot core:', chalk_1.default.green `v${runner.version.core}`], | ||
['runner:', chalk_1.default.green `${runner.name} (v${runner.version.self})`], | ||
['origin:', chalk_1.default.green.underline `${config.origin}`], | ||
]), { borderColor: 'gray', padding: 1 }) + '\n\n'); | ||
stdout.write(boxen_1.default([ | ||
chalk_1.default.bold.green('Audit by acot'), | ||
text_table_1.default([ | ||
[chalk_1.default.bold('acot core:'), `v${runner.version.core}`], | ||
[ | ||
chalk_1.default.bold('runner:'), | ||
`${runner.name} (v${runner.version.self})`, | ||
], | ||
[chalk_1.default.bold('origin:'), chalk_1.default.underline(`${config.origin}`)], | ||
], { stringLength }), | ||
].join('\n\n'), { borderColor: 'gray', padding: 1 }) + '\n\n'); | ||
let progress = null; | ||
@@ -143,3 +148,3 @@ runner.on('setup:start', () => { | ||
runner.on('connect:complete', () => { | ||
spinner.succeed(`Connected (${config.origin})`); | ||
spinner.succeed(chalk_1.default `Connected {gray.underline (${config.origin})}`); | ||
}); | ||
@@ -150,3 +155,3 @@ runner.on('collect:start', () => { | ||
runner.on('collect:complete', ([results]) => { | ||
spinner.succeed(`Collected (${results.length} cases)`); | ||
spinner.succeed(chalk_1.default `Collected {gray ({bold ${results.length}} cases)}`); | ||
}); | ||
@@ -196,3 +201,3 @@ runner.on('launch:start', () => { | ||
const rule = chalk_1.default.gray(res.rule); | ||
const lines = [indent_string_1.default([status, msg, rule].join(' '), 2)]; | ||
const lines = [[status, msg, rule].join(' ')]; | ||
const meta = []; | ||
@@ -214,3 +219,3 @@ if (res.tags.length > 0) { | ||
.join('\n'); | ||
lines.push(indent_string_1.default(chalk_1.default.gray(metaStr), 5)); | ||
lines.push(indent_string_1.default(chalk_1.default.gray(metaStr), 3)); | ||
} | ||
@@ -226,4 +231,10 @@ return `${lines.join('\n')}`; | ||
: chalk_1.default.bgYellow.black.bold(' WARN '); | ||
const url = chalk_1.default.bold(result.url); | ||
stdout.write(`${label} ${url}\n${filtered.join('\n\n')}\n\n`); | ||
const url = chalk_1.default.bold.underline(result.url); | ||
const short = [ | ||
chalk_1.default.green(`${strip_ansi_1.default(log_symbols_1.default.success)} ${result.passCount}`), | ||
chalk_1.default.red(`${strip_ansi_1.default(log_symbols_1.default.error)} ${result.errorCount}`), | ||
chalk_1.default.yellow(`${strip_ansi_1.default(log_symbols_1.default.warning)} ${result.warningCount}`), | ||
].join(' '); | ||
stdout.write(`${label} ${url} - ${short}\n`); | ||
stdout.write(`${filtered.join('\n\n')}\n\n`); | ||
})); | ||
@@ -230,0 +241,0 @@ if (summary.errorCount > 0) { |
{ | ||
"name": "@acot/reporter", | ||
"version": "0.0.1", | ||
"version": "0.0.2-canary.0", | ||
"description": "A reporter toolset and built-in reporters for @acot/cli.", | ||
"homepage": "https://github.com/acot-a11y/acot#readme", | ||
"homepage": "https://github.com/acot-a11y/acot/tree/master/packages/reporter", | ||
"bugs": { | ||
@@ -33,5 +33,5 @@ "url": "https://github.com/acot-a11y/acot/issues" | ||
"dependencies": { | ||
"@acot/html-pickup": "0.0.1", | ||
"@acot/module-loader": "0.0.1", | ||
"@acot/utils": "0.0.1", | ||
"@acot/html-pickup": "0.0.2-canary.0", | ||
"@acot/module-loader": "0.0.2-canary.0", | ||
"@acot/utils": "0.0.2-canary.0", | ||
"boxen": "^4.2.0", | ||
@@ -49,3 +49,3 @@ "chalk": "^4.0.0", | ||
"devDependencies": { | ||
"@acot/types": "0.0.1", | ||
"@acot/types": "0.0.2-canary.0", | ||
"@types/text-table": "^0.2.1" | ||
@@ -56,3 +56,3 @@ }, | ||
}, | ||
"gitHead": "564fb61b40646392ed163b122531ad4ae3ba65e4" | ||
"gitHead": "61cca80b5953b0ee87f2b3de4b7764ada4d057fb" | ||
} |
21819
459
+ Added@acot/html-pickup@0.0.2-canary.0(transitive)
+ Added@acot/module-loader@0.0.2-canary.0(transitive)
+ Added@acot/utils@0.0.2-canary.0(transitive)
- Removed@acot/html-pickup@0.0.1(transitive)
- Removed@acot/module-loader@0.0.1(transitive)
- Removed@acot/utils@0.0.1(transitive)
Updated@acot/utils@0.0.2-canary.0