Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import chalk from 'chalk';
import { Reporter, MutantResult, MutantStatus, ScoreResult } from 'stryker-api/report';
import { Position, StrykerOptions } from 'stryker-api/core';
import ClearTextScoreTable from './ClearTextScoreTable';
import * as os from 'os';
import { tokens } from 'typed-inject';
import { commonTokens } from 'stryker-api/plugin';
import { Logger } from 'stryker-api/logging';
export default class ClearTextReporter implements Reporter {
public static inject = tokens(commonTokens.logger, commonTokens.options);
constructor(private readonly log: Logger, private readonly options: StrykerOptions) {
this.configConsoleColor();
}
private readonly out: NodeJS.WritableStream = process.stdout;
private writeLine(output?: string) {
this.out.write(`${output || ''}${os.EOL}`);
}
private configConsoleColor() {
if (!this.options.allowConsoleColors) {
chalk.level = 0; // All colors disabled
}
}
import * as os from 'os';
import { Position, StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens } from '@stryker-mutator/api/plugin';
import { MutantResult, MutantStatus, mutationTestReportSchema, Reporter } from '@stryker-mutator/api/report';
import { calculateMetrics } from 'mutation-testing-metrics';
import { tokens } from 'typed-inject';
import chalk = require('chalk');
import ClearTextScoreTable from './ClearTextScoreTable';
export default class ClearTextReporter implements Reporter {
public static inject = tokens(commonTokens.logger, commonTokens.options);
constructor(private readonly log: Logger, private readonly options: StrykerOptions) {
this.configConsoleColor();
}
private readonly out: NodeJS.WritableStream = process.stdout;
private writeLine(output?: string) {
this.out.write(`${output || ''}${os.EOL}`);
}
private configConsoleColor() {
if (!this.options.allowConsoleColors) {
chalk.level = 0; // All colors disabled
}
}
import { Config, ConfigEditor } from '@stryker-mutator/api/config';
import { commonTokens, PluginKind, PluginResolver } from '@stryker-mutator/api/plugin';
import { tokens } from 'typed-inject';
import { coreTokens } from '../di';
import { PluginCreator } from '../di/PluginCreator';
/**
* Class that applies all config editor plugins
*/
export class ConfigEditorApplier implements ConfigEditor {
public static inject = tokens(commonTokens.pluginResolver, coreTokens.pluginCreatorConfigEditor);
constructor(private readonly pluginResolver: PluginResolver, private readonly pluginCreator: PluginCreator) {}
public edit(config: Config): void {
this.pluginResolver.resolveAll(PluginKind.ConfigEditor).forEach(plugin => {
const configEditor = this.pluginCreator.create(plugin.name);
configEditor.edit(config);
});
}
}
import { Config, ConfigEditor } from 'stryker-api/config';
import { tokens } from 'typed-inject';
import { PluginResolver, PluginKind, commonTokens } from 'stryker-api/plugin';
import { PluginCreator } from '../di/PluginCreator';
import { coreTokens } from '../di';
/**
* Class that applies all config editor plugins
*/
export class ConfigEditorApplier implements ConfigEditor {
public static inject = tokens(commonTokens.pluginResolver, coreTokens.pluginCreatorConfigEditor);
constructor(private readonly pluginResolver: PluginResolver,
private readonly pluginCreator: PluginCreator) { }
public edit(config: Config): void {
this.pluginResolver.resolveAll(PluginKind.ConfigEditor).forEach(plugin => {
const configEditor = this.pluginCreator.create(plugin.name);
configEditor.edit(config);
});
}
}
import { tokens } from 'typed-inject';
import { importModule } from '../utils/fileUtils';
import * as coreTokens from './coreTokens';
const IGNORED_PACKAGES = ['core', 'api', 'util'];
interface PluginModule {
strykerPlugins: Array>;
}
export class PluginLoader implements PluginResolver {
private readonly pluginsByKind: Map>> = new Map();
public static inject = tokens(commonTokens.logger, coreTokens.pluginDescriptors);
constructor(private readonly log: Logger, private readonly pluginDescriptors: readonly string[]) {}
public load() {
this.resolvePluginModules().forEach(moduleName => {
this.requirePlugin(moduleName);
});
}
public resolve(kind: T, name: string): Plugins[T] {
const plugins = this.pluginsByKind.get(kind);
if (plugins) {
const plugin = plugins.find(plugin => plugin.name.toLowerCase() === name.toLowerCase());
if (plugin) {
return plugin as any;
} else {
throw new Error(
import { copy } from '../utils/objectUtils';
import NodeMutator from './NodeMutator';
import BinaryOperatorMutator from './BinaryOperatorMutator';
import BlockStatementMutator from './BlockStatementMutator';
import LogicalOperatorMutator from './LogicalOperatorMutator';
import RemoveConditionalsMutator from './RemoveConditionalsMutator';
import UnaryOperatorMutator from './UnaryOperatorMutator';
import UpdateOperatorMutator from './UpdateOperatorMutator';
import ArrayDeclaratorMutator from './ArrayDeclaratorMutator';
import BooleanSubstitutionMutator from './BooleanSubstitutionMutator';
import { tokens } from 'typed-inject';
import { commonTokens } from 'stryker-api/plugin';
export default class ES5Mutator implements Mutator {
public static inject = tokens(commonTokens.logger);
constructor(
private readonly log: Logger,
private readonly mutators: NodeMutator[] = [
new BinaryOperatorMutator(),
new BlockStatementMutator(),
new LogicalOperatorMutator(),
new RemoveConditionalsMutator(),
new UnaryOperatorMutator(),
new UpdateOperatorMutator(),
new ArrayDeclaratorMutator(),
new BooleanSubstitutionMutator()
]) {
this.log.warn(`DEPRECATED: The es5 mutator is deprecated and will be removed in the future. Please upgrade to the stryker-javascript-mutator (npm install --save-dev stryker-javascript-mutator) and set "mutator: 'javascript'" in your stryker.conf.js! If you have a plugins array in your stryker.conf.js, be sure to add 'stryker-javascript-mutator'.`);
}
public mutate(files: File[]): Mutant[] {
import { StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, PluginKind } from '@stryker-mutator/api/plugin';
import { MatchedMutant, MutantResult, mutationTestReportSchema, Reporter, ScoreResult, SourceFile } from '@stryker-mutator/api/report';
import { tokens } from 'typed-inject';
import { coreTokens } from '../di';
import { PluginCreator } from '../di/PluginCreator';
import StrictReporter from './StrictReporter';
export default class BroadcastReporter implements StrictReporter {
public static readonly inject = tokens(commonTokens.options, coreTokens.pluginCreatorReporter, commonTokens.logger);
public readonly reporters: {
[name: string]: Reporter;
};
constructor(
private readonly options: StrykerOptions,
private readonly pluginCreator: PluginCreator,
private readonly log: Logger
) {
this.reporters = {};
this.options.reporters.forEach(reporterName => this.createReporter(reporterName));
this.logAboutReporters();
}
private createReporter(reporterName: string): void {
if (reporterName === 'progress' && !process.stdout.isTTY) {
import { Reporter, SourceFile, MutantResult, MatchedMutant, ScoreResult } from 'stryker-api/report';
import { Logger } from 'stryker-api/logging';
import { isPromise } from '../utils/objectUtils';
import StrictReporter from './StrictReporter';
import { commonTokens, PluginKind } from 'stryker-api/plugin';
import { StrykerOptions } from 'stryker-api/core';
import { tokens } from 'typed-inject';
import { coreTokens } from '../di';
import { PluginCreator } from '../di/PluginCreator';
export default class BroadcastReporter implements StrictReporter {
public static readonly inject = tokens(
commonTokens.options,
coreTokens.pluginCreatorReporter,
commonTokens.logger);
public readonly reporters: {
[name: string]: Reporter;
};
constructor(
private readonly options: StrykerOptions,
private readonly pluginCreator: PluginCreator,
private readonly log: Logger) {
this.reporters = {};
this.options.reporters.forEach(reporterName => this.createReporter(reporterName));
this.logAboutReporters();
}
import { tokens } from 'typed-inject';
import { importModule } from '../utils/fileUtils';
import { fsAsPromised } from '@stryker-mutator/util';
import { Plugin, PluginKind, PluginResolver, Plugins, commonTokens } from 'stryker-api/plugin';
import * as coreTokens from './coreTokens';
const IGNORED_PACKAGES = ['stryker-cli', 'stryker-api'];
interface PluginModule {
strykerPlugins: Plugin[];
}
export class PluginLoader implements PluginResolver {
private readonly pluginsByKind: Map[]> = new Map();
public static inject = tokens(commonTokens.logger, coreTokens.pluginDescriptors);
constructor(private readonly log: Logger, private readonly pluginDescriptors: ReadonlyArray) { }
public load() {
this.resolvePluginModules().forEach(moduleName => this.requirePlugin(moduleName));
}
public resolve(kind: T, name: string): Plugins[T] {
const plugins = this.pluginsByKind.get(kind);
if (plugins) {
const plugin = plugins.find(plugin => plugin.name.toLowerCase() === name.toLowerCase());
if (plugin) {
return plugin as any;
} else {
throw new Error(`Cannot load ${kind} plugin "${name}". Did you forget to install it? Loaded ${kind
} plugins were: ${plugins.map(p => p.name).join(', ')}`);
}