stub reporters, test invoke
This commit is contained in:
parent
84afd78b69
commit
441f1d3cdf
|
@ -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);
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { Source } from '../source';
|
||||
|
||||
export interface Loader {
|
||||
load(path: string): Source;
|
||||
}
|
||||
|
||||
class FileLoader { }
|
||||
class FetchLoader { }
|
||||
class ImportLoader { }
|
||||
class StreamLoader { }
|
|
@ -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.');
|
||||
}
|
||||
}
|
|
@ -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`;
|
||||
}
|
||||
}
|
|
@ -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.');
|
||||
}
|
||||
}
|
|
@ -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 { }
|
||||
|
|
Loading…
Reference in New Issue