1
0
Fork 0

stub reporters, test invoke

This commit is contained in:
Sean Sube 2022-02-16 08:20:43 -06:00
parent 84afd78b69
commit 441f1d3cdf
6 changed files with 34 additions and 15 deletions

View File

@ -4,6 +4,8 @@ import yargs from 'yargs';
import { CONFIG_ARGS_NAME, CONFIG_ARGS_PATH, MODE, parseArgs } from './config/args.js';
import { loadConfig } from './config/index.js';
import { YamlParser } from './parser/YamlParser.js';
import { SummaryReporter } from './reporter/SummaryReporter.js';
import { TableReporter } from './reporter/TableReporter.js';
import { createRuleSources, loadRules } from './rule/load.js';
import { createRuleSelector, resolveRules } from './rule/resolve.js';
import { validateConfig } from './rule/validate.js';
@ -82,6 +84,11 @@ export async function main(argv: Array<string>): Promise<number> {
}
}
// invoke reporter
const reporter = new TableReporter();
const report = await reporter.report([ctx]);
logger.info(report);
if (ctx.errors.length === 0) {
logger.info('all rules passed');
const output = parser.dump(...docs);

View File

@ -1,10 +0,0 @@
import { Source } from '../source';
export interface Loader {
load(path: string): Source;
}
class FileLoader { }
class FetchLoader { }
class ImportLoader { }
class StreamLoader { }

View File

@ -0,0 +1,8 @@
import { Reporter } from './index.js';
import { RuleResult } from '../rule/index.js';
export class SummaryReporter implements Reporter {
public report(results: Array<RuleResult>): Promise<string> {
throw new Error('Method not implemented.');
}
}

View File

@ -0,0 +1,10 @@
import { Reporter } from './index.js';
import { RuleResult } from '../rule/index.js';
export class TableReporter implements Reporter {
public async report(results: Array<RuleResult>): Promise<string> {
const errors = results.reduce((p, c) => p + c.errors.length, 0);
return `${errors} errors in run`;
}
}

View File

@ -0,0 +1,8 @@
import { Reporter } from './index.js';
import { RuleResult } from '../rule/index.js';
export class YamlReporter implements Reporter {
public report(results: Array<RuleResult>): Promise<string> {
throw new Error('Method not implemented.');
}
}

View File

@ -1,9 +1,5 @@
import { RuleResult } from '../rule';
export interface Reporter {
report(results: Array<RuleResult>): Promise<void>;
report(results: Array<RuleResult>): Promise<string>;
}
class SummaryReporter { }
class TableReporter { }
class YamlReporter { }