Comparing version 0.62.0 to 0.63.0
@@ -5,6 +5,8 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
import { ToolInterface } from './Tool'; | ||
import Tool from './Tool'; | ||
import { Debugger, ToolConfig, PackageConfig } from './types'; | ||
export declare type ConfigPathOrStruct = string | Struct; | ||
export declare type ConfigObject = { | ||
[key: string]: any; | ||
}; | ||
export declare type ConfigPathOrObject = string | ConfigObject; | ||
export default class ConfigLoader { | ||
@@ -16,17 +18,17 @@ debug: Debugger; | ||
}; | ||
tool: ToolInterface; | ||
tool: Tool; | ||
workspaceRoot: string; | ||
constructor(tool: ToolInterface); | ||
constructor(tool: Tool); | ||
/** | ||
* Find the config in the package.json block under the application name. | ||
*/ | ||
findConfigInPackageJSON(pkg: PackageConfig): ConfigPathOrStruct | null; | ||
findConfigInPackageJSON(pkg: PackageConfig): ConfigPathOrObject | null; | ||
/** | ||
* Find the config using local files commonly located in a configs/ folder. | ||
*/ | ||
findConfigInLocalFiles(root: string): ConfigPathOrStruct | null; | ||
findConfigInLocalFiles(root: string): ConfigPathOrObject | null; | ||
/** | ||
* Find the config within the root when in a workspace. | ||
*/ | ||
findConfigInWorkspaceRoot(root: string): ConfigPathOrStruct | null; | ||
findConfigInWorkspaceRoot(root: string): ConfigPathOrObject | null; | ||
/** | ||
@@ -54,3 +56,3 @@ * Handle special cases when merging 2 configuration values. | ||
*/ | ||
parseAndExtend(fileOrConfig: ConfigPathOrStruct): Struct; | ||
parseAndExtend(fileOrConfig: ConfigPathOrObject): ConfigObject; | ||
/** | ||
@@ -62,3 +64,3 @@ * Parse a configuration file at the defined file system path. | ||
*/ | ||
parseFile(filePath: string, args?: any[]): Struct; | ||
parseFile(filePath: string, args?: any[]): ConfigObject; | ||
/** | ||
@@ -65,0 +67,0 @@ * Resolve file system paths for the `extends` configuration value |
@@ -6,8 +6,7 @@ /** | ||
/// <reference types="node" /> | ||
import { Struct } from 'optimal'; | ||
import Emitter, { EmitterInterface } from './Emitter'; | ||
import Emitter from './Emitter'; | ||
export declare const REFRESH_RATE = 100; | ||
export declare const BG_REFRESH_RATE = 500; | ||
export declare type WrappedStream = (message: string) => void; | ||
export interface ConsoleOptions extends Struct { | ||
export interface ConsoleOptions { | ||
footer: string; | ||
@@ -19,12 +18,2 @@ header: string; | ||
} | ||
export interface ConsoleInterface extends EmitterInterface { | ||
err: WrappedStream; | ||
out: WrappedStream; | ||
options: ConsoleOptions; | ||
exit(message: string | Error | null, code: number): void; | ||
log(message: string): this; | ||
logError(message: string): this; | ||
render(): this; | ||
write(message: string, nl?: number): this; | ||
} | ||
export default class Console extends Emitter { | ||
@@ -31,0 +20,0 @@ bufferedOutput: string; |
@@ -5,5 +5,3 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
export default class Context { | ||
constructor(properties?: Struct); | ||
} |
@@ -8,6 +8,3 @@ "use strict"; | ||
var Context = /** @class */ (function () { | ||
// eslint-disable-next-line no-useless-constructor | ||
function Context(properties) { | ||
if (properties === void 0) { properties = {}; } | ||
// Map properties in sub-class | ||
function Context() { | ||
} | ||
@@ -14,0 +11,0 @@ return Context; |
@@ -5,7 +5,7 @@ /** | ||
*/ | ||
import { ToolInterface } from './Tool'; | ||
import Tool from './Tool'; | ||
export default class CrashLogger { | ||
contents: string; | ||
logPath: string; | ||
constructor({ config, options }: ToolInterface); | ||
constructor({ config, options }: Tool); | ||
add(label: string, message: string | number): void; | ||
@@ -12,0 +12,0 @@ addTitle(title: string): void; |
@@ -7,10 +7,3 @@ /** | ||
export declare type EventListener = (...args: EventArguments) => false | void; | ||
export interface EmitterInterface { | ||
emit(name: string, args?: EventArguments): this; | ||
off(eventName: string, listener: EventListener): this; | ||
on(eventName: string, listener: EventListener): this; | ||
setEventNamespace(namespace: string): this; | ||
removeEventNamespace(): this; | ||
} | ||
export default class Emitter implements EmitterInterface { | ||
export default class Emitter { | ||
listeners: { | ||
@@ -17,0 +10,0 @@ [eventName: string]: Set<EventListener>; |
@@ -5,7 +5,6 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
import Context from './Context'; | ||
import { RoutineInterface } from './Routine'; | ||
import { TaskInterface } from './Task'; | ||
import { ToolInterface } from './Tool'; | ||
import Routine from './Routine'; | ||
import Task from './Task'; | ||
import Tool from './Tool'; | ||
import { Debugger } from './types'; | ||
@@ -16,8 +15,8 @@ export interface AggregatedResponse { | ||
} | ||
export default class Executor<To extends Struct = {}> { | ||
context: Context; | ||
export default class Executor<Ctx extends Context, Options = {}> { | ||
context: Ctx; | ||
debug: Debugger; | ||
options: To; | ||
tool: ToolInterface; | ||
constructor(tool: ToolInterface, context: Context, options?: Partial<To>); | ||
options: Options; | ||
tool: Tool; | ||
constructor(tool: Tool, context: Ctx, options?: Partial<Options>); | ||
/** | ||
@@ -30,20 +29,20 @@ * Aggregate and partition errors and results into separate collections. | ||
*/ | ||
execute<T>(task: TaskInterface | RoutineInterface, value?: T, wasParallel?: boolean): Promise<any>; | ||
execute<T>(task: Task<Ctx> | Routine<Ctx>, value?: T, wasParallel?: boolean): Promise<any>; | ||
/** | ||
* Execute a routine with the provided value. | ||
*/ | ||
executeRoutine<T>(routine: RoutineInterface, value?: T, wasParallel?: boolean): Promise<any>; | ||
executeRoutine<T>(routine: Routine<Ctx>, value?: T, wasParallel?: boolean): Promise<any>; | ||
/** | ||
* Execute a task with the provided value. | ||
*/ | ||
executeTask<T>(task: TaskInterface, value?: T, wasParallel?: boolean): Promise<any>; | ||
executeTask<T>(task: Task<Ctx>, value?: T, wasParallel?: boolean): Promise<any>; | ||
/** | ||
* Importing Routine causes a circular reference, so we can't use an instanceof check, | ||
* so we need to hackily check this another way. | ||
* */ | ||
getInstanceType(task: TaskInterface | RoutineInterface): string; | ||
*/ | ||
getInstanceType(task: Task<Ctx> | Routine<Ctx>): string; | ||
/** | ||
* Method to execute tasks. Must be defined in sub-classes. | ||
*/ | ||
run<T>(tasks: TaskInterface[], value?: T): void; | ||
run<T>(tasks: Task<Ctx>[], value?: T): void; | ||
} |
@@ -86,3 +86,3 @@ "use strict"; | ||
* so we need to hackily check this another way. | ||
* */ | ||
*/ | ||
Executor.prototype.getInstanceType = function (task) { | ||
@@ -89,0 +89,0 @@ var instance = task; |
@@ -5,9 +5,10 @@ /** | ||
*/ | ||
import Context from '../Context'; | ||
import Executor from '../Executor'; | ||
import { TaskInterface } from '../Task'; | ||
export default class ParallelExecutor extends Executor { | ||
import Task from '../Task'; | ||
export default class ParallelExecutor<Ctx extends Context> extends Executor<Ctx> { | ||
/** | ||
* Execute tasks in parallel. | ||
*/ | ||
run<T>(tasks: TaskInterface[], value?: T): Promise<any[]>; | ||
run<T>(tasks: Task<Ctx>[], value?: T): Promise<any[]>; | ||
} |
@@ -8,4 +8,4 @@ /** | ||
import Executor, { AggregatedResponse } from '../Executor'; | ||
import { TaskInterface } from '../Task'; | ||
import { ToolInterface } from '../Tool'; | ||
import Task from '../Task'; | ||
import Tool from '../Tool'; | ||
export interface PoolExecutorOptions { | ||
@@ -16,13 +16,13 @@ concurrency: number; | ||
} | ||
export default class PoolExecutor extends Executor<PoolExecutorOptions> { | ||
queue: TaskInterface[]; | ||
export default class PoolExecutor<Ctx extends Context> extends Executor<Ctx, PoolExecutorOptions> { | ||
queue: Task<Ctx>[]; | ||
resolver: ((response: AggregatedResponse) => void) | null; | ||
results: any[]; | ||
running: TaskInterface[]; | ||
running: Task<Ctx>[]; | ||
timeoutTimer?: NodeJS.Timer; | ||
constructor(tool: ToolInterface, context: Context, options?: Partial<PoolExecutorOptions>); | ||
constructor(tool: Tool, context: Ctx, options?: Partial<PoolExecutorOptions>); | ||
/** | ||
* Execute tasks using a pool with a max concurrency. | ||
*/ | ||
run<T>(tasks: TaskInterface[], value?: T): Promise<AggregatedResponse>; | ||
run<T>(tasks: Task<Ctx>[], value?: T): Promise<AggregatedResponse>; | ||
/** | ||
@@ -29,0 +29,0 @@ * Resolve the execution with the current results. |
@@ -5,5 +5,6 @@ /** | ||
*/ | ||
import Context from '../Context'; | ||
import Executor from '../Executor'; | ||
import { TaskInterface } from '../Task'; | ||
export default class SerialExecutor extends Executor { | ||
import Task from '../Task'; | ||
export default class SerialExecutor<Ctx extends Context> extends Executor<Ctx> { | ||
/** | ||
@@ -13,3 +14,3 @@ * Execute tasks in sequential order with the output of each | ||
*/ | ||
run<T>(tasks: TaskInterface[], value?: T): Promise<any>; | ||
run<T>(tasks: Task<Ctx>[], value?: T): Promise<any>; | ||
} |
@@ -5,5 +5,6 @@ /** | ||
*/ | ||
import Context from '../Context'; | ||
import Executor, { AggregatedResponse } from '../Executor'; | ||
import { TaskInterface } from '../Task'; | ||
export default class SyncExecutor extends Executor { | ||
import Task from '../Task'; | ||
export default class SyncExecutor<Ctx extends Context> extends Executor<Ctx> { | ||
/** | ||
@@ -13,3 +14,3 @@ * Execute tasks in parallel with a value being passed to each task. | ||
*/ | ||
run<T>(tasks: TaskInterface[], value?: T): Promise<AggregatedResponse>; | ||
run<T>(tasks: Task<Ctx>[], value?: T): Promise<AggregatedResponse>; | ||
} |
@@ -6,14 +6,14 @@ /** | ||
import ConfigLoader from './ConfigLoader'; | ||
import { ConsoleInterface } from './Console'; | ||
import Console from './Console'; | ||
import Context from './Context'; | ||
import Emitter, { EmitterInterface, EventArguments, EventListener } from './Emitter'; | ||
import Module, { ModuleInterface } from './Module'; | ||
import Emitter, { EventArguments, EventListener } from './Emitter'; | ||
import Module from './Module'; | ||
import ModuleLoader from './ModuleLoader'; | ||
import Pipeline from './Pipeline'; | ||
import Plugin, { PluginInterface } from './Plugin'; | ||
import Reporter, { ReporterInterface } from './Reporter'; | ||
import Routine, { RoutineInterface } from './Routine'; | ||
import { TaskInterface } from './Task'; | ||
import Tool, { ToolInterface, ToolOptions } from './Tool'; | ||
export { ConfigLoader, ConsoleInterface, Context, Emitter, EmitterInterface, EventArguments, EventListener, Module, ModuleInterface, ModuleLoader, Pipeline, Plugin, PluginInterface, Reporter, ReporterInterface, Routine, RoutineInterface, TaskInterface, Tool, ToolInterface, ToolOptions, }; | ||
import Plugin from './Plugin'; | ||
import Reporter from './Reporter'; | ||
import Routine from './Routine'; | ||
import Task from './Task'; | ||
import Tool, { ToolOptions } from './Tool'; | ||
export { ConfigLoader, Console, Context, Emitter, EventArguments, EventListener, Module, ModuleLoader, Pipeline, Plugin, Reporter, Routine, Task, Tool, ToolOptions, }; | ||
export * from './types'; |
@@ -12,2 +12,4 @@ "use strict"; | ||
exports.ConfigLoader = ConfigLoader_1.default; | ||
var Console_1 = __importDefault(require("./Console")); | ||
exports.Console = Console_1.default; | ||
var Context_1 = __importDefault(require("./Context")); | ||
@@ -29,3 +31,5 @@ exports.Context = Context_1.default; | ||
exports.Routine = Routine_1.default; | ||
var Task_1 = __importDefault(require("./Task")); | ||
exports.Task = Task_1.default; | ||
var Tool_1 = __importDefault(require("./Tool")); | ||
exports.Tool = Tool_1.default; |
@@ -5,12 +5,7 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
export interface ModuleInterface { | ||
export default class Module<Options> { | ||
moduleName: string; | ||
name: string; | ||
options: Options; | ||
constructor(options?: Partial<Options>); | ||
} | ||
export default class Module<To extends Struct> implements ModuleInterface { | ||
moduleName: string; | ||
name: string; | ||
options: To; | ||
constructor(options?: Partial<To>); | ||
} |
@@ -5,13 +5,15 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
import { ModuleInterface } from './Module'; | ||
import { ToolInterface } from './Tool'; | ||
import Module from './Module'; | ||
import Tool from './Tool'; | ||
import { Debugger } from './types'; | ||
export declare type Constructor<T> = new (...args: any[]) => T; | ||
export default class ModuleLoader<Tm extends ModuleInterface> { | ||
export declare type OptionsObject = { | ||
[key: string]: any; | ||
}; | ||
export default class ModuleLoader<Tm extends Module<any>> { | ||
classReference: Constructor<Tm>; | ||
debug: Debugger; | ||
tool: ToolInterface; | ||
tool: Tool; | ||
typeName: string; | ||
constructor(tool: ToolInterface, typeName: string, classReference: Constructor<Tm>); | ||
constructor(tool: Tool, typeName: string, classReference: Constructor<Tm>); | ||
/** | ||
@@ -26,3 +28,3 @@ * Import a class definition from a Node module and instantiate the class | ||
*/ | ||
importModuleFromOptions(baseOptions: Struct, args?: any[]): Tm; | ||
importModuleFromOptions(baseOptions: OptionsObject, args?: any[]): Tm; | ||
/** | ||
@@ -33,7 +35,7 @@ * Load and or instantiate a module for the `typeName` configuration property. | ||
*/ | ||
loadModule(module: string | Struct | Tm, args?: any[]): Tm; | ||
loadModule(module: string | OptionsObject | Tm, args?: any[]): Tm; | ||
/** | ||
* Load multiple modules. | ||
*/ | ||
loadModules(modules?: (string | Struct | Tm)[], args?: any[]): Tm[]; | ||
loadModules(modules?: (string | OptionsObject | Tm)[], args?: any[]): Tm[]; | ||
} |
@@ -7,6 +7,6 @@ /** | ||
import Routine from './Routine'; | ||
import { ToolInterface } from './Tool'; | ||
import Tool from './Tool'; | ||
import { ToolConfig } from './types'; | ||
export default class Pipeline<Tx extends Context> extends Routine<ToolConfig, Tx> { | ||
constructor(tool: ToolInterface, context: Tx); | ||
export default class Pipeline<Ctx extends Context> extends Routine<Ctx, ToolConfig> { | ||
constructor(tool: Tool, context: Ctx); | ||
/** | ||
@@ -13,0 +13,0 @@ * Execute all routines in order. |
@@ -23,5 +23,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var CrashLogger_1 = __importDefault(require("./CrashLogger")); | ||
var Routine_1 = __importDefault(require("./Routine")); | ||
var Tool_1 = __importDefault(require("./Tool")); | ||
var CrashLogger_1 = __importDefault(require("./CrashLogger")); | ||
var Pipeline = /** @class */ (function (_super) { | ||
@@ -28,0 +28,0 @@ __extends(Pipeline, _super); |
@@ -5,15 +5,9 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
import Module, { ModuleInterface } from './Module'; | ||
import { ToolInterface } from './Tool'; | ||
import Module from './Module'; | ||
import Tool from './Tool'; | ||
export declare const DEFAULT_PLUGIN_PRIORITY: number; | ||
export interface PluginInterface extends ModuleInterface { | ||
export default class Plugin<Options> extends Module<Options> { | ||
priority: number; | ||
tool: ToolInterface; | ||
tool: Tool; | ||
bootstrap(): void; | ||
} | ||
export default class Plugin<To extends Struct> extends Module<To> implements PluginInterface { | ||
priority: number; | ||
tool: ToolInterface; | ||
bootstrap(): void; | ||
} |
@@ -5,16 +5,10 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
import { ConsoleInterface } from './Console'; | ||
import Module, { ModuleInterface } from './Module'; | ||
import { TaskInterface } from './Task'; | ||
import Console from './Console'; | ||
import Module from './Module'; | ||
import Task from './Task'; | ||
import { ColorType, ColorPalette } from './types'; | ||
export declare const SLOW_THRESHOLD = 10000; | ||
export interface ReporterInterface<T = any> extends ModuleInterface { | ||
console: ConsoleInterface; | ||
lines: T[]; | ||
bootstrap(): void; | ||
} | ||
export default class Reporter<T, To extends Struct = {}> extends Module<To> implements ReporterInterface { | ||
console: ConsoleInterface; | ||
lines: T[]; | ||
export default class Reporter<Line = string, Options = {}> extends Module<Options> { | ||
console: Console; | ||
lines: Line[]; | ||
startTime: number; | ||
@@ -29,3 +23,3 @@ stopTime: number; | ||
*/ | ||
addLine(line: T): this; | ||
addLine(line: Line): this; | ||
/** | ||
@@ -38,3 +32,3 @@ * Display an error and it's stack. | ||
*/ | ||
findLine(callback: (item: T) => boolean): T | undefined; | ||
findLine(callback: (item: Line) => boolean): Line | undefined; | ||
/** | ||
@@ -47,3 +41,3 @@ * Return specific colors based on chosen theme. | ||
*/ | ||
getColorType(task: TaskInterface): ColorType; | ||
getColorType(task: Task<any>): ColorType; | ||
/** | ||
@@ -68,3 +62,3 @@ * Calculate the elapsed time and highlight as red if over the threshold. | ||
*/ | ||
removeLine(callback: (item: T) => boolean): this; | ||
removeLine(callback: (line: Line) => boolean): this; | ||
/** | ||
@@ -71,0 +65,0 @@ * Create a chalk formatted string with accessible colors and modifiers applied. |
@@ -6,18 +6,17 @@ /** | ||
import Reporter from '../Reporter'; | ||
import { TaskInterface } from '../Task'; | ||
import { RoutineInterface } from '../Routine'; | ||
declare type TaskID = { | ||
import Task from '../Task'; | ||
import Routine from '../Routine'; | ||
export declare type TaskID = { | ||
id?: number; | ||
}; | ||
export default class CIReporter extends Reporter<any> { | ||
export default class CIReporter extends Reporter { | ||
taskID: number; | ||
bootstrap(): void; | ||
handleTask: (task: TaskInterface & TaskID) => void; | ||
handleTaskPass: (task: TaskInterface & TaskID) => void; | ||
handleTaskFail: (task: TaskInterface & TaskID, error: Error) => void; | ||
handleRoutine: (routine: RoutineInterface) => void; | ||
handleRoutinePass: (routine: RoutineInterface) => void; | ||
handleRoutineFail: (routine: RoutineInterface, error: Error) => void; | ||
handleTask: (task: Task<any, {}> & TaskID) => void; | ||
handleTaskPass: (task: Task<any, {}> & TaskID) => void; | ||
handleTaskFail: (task: Task<any, {}> & TaskID, error: Error) => void; | ||
handleRoutine: (routine: Routine<any, {}>) => void; | ||
handleRoutinePass: (routine: Routine<any, {}>) => void; | ||
handleRoutineFail: (routine: Routine<any, {}>, error: Error) => void; | ||
handleStop: () => void; | ||
} | ||
export {}; |
@@ -6,9 +6,9 @@ /** | ||
import Reporter from '../Reporter'; | ||
import { RoutineInterface } from '../Routine'; | ||
import { TaskInterface } from '../Task'; | ||
export interface Line { | ||
import Routine from '../Routine'; | ||
import Task from '../Task'; | ||
export declare type Line = { | ||
depth: number; | ||
routine: RoutineInterface; | ||
tasks: TaskInterface[]; | ||
} | ||
routine: Routine<any>; | ||
tasks: Task<any>[]; | ||
}; | ||
export default class DefaultReporter extends Reporter<Line> { | ||
@@ -21,19 +21,19 @@ depth: number; | ||
*/ | ||
calculateKeyLength(routines: RoutineInterface[], depth?: number): number; | ||
calculateKeyLength(routines: Routine<any>[], depth?: number): number; | ||
/** | ||
* Calculate the current number of tasks that have completed. | ||
*/ | ||
calculateTaskCompletion(tasks: TaskInterface[]): number; | ||
calculateTaskCompletion(tasks: Task<any>[]): number; | ||
/** | ||
* Return the task title with additional metadata. | ||
*/ | ||
getLineTitle(task: TaskInterface | RoutineInterface, usedColumns?: number): string; | ||
handleStart: (routines: RoutineInterface[]) => void; | ||
getLineTitle(task: Task<any> | Routine<any>, usedColumns?: number): string; | ||
handleStart: (routines: Routine<any, {}>[]) => void; | ||
handleCommand: () => void; | ||
handleTask: (task: TaskInterface, routine: RoutineInterface) => void; | ||
handleTaskComplete: (task: TaskInterface, routine: RoutineInterface) => void; | ||
handleTask: (task: Task<any, {}>, routine: Routine<any, {}>) => void; | ||
handleTaskComplete: (task: Task<any, {}>, routine: Routine<any, {}>) => void; | ||
handleRender: () => void; | ||
handleRoutine: (routine: RoutineInterface, value: any, wasParallel: boolean) => void; | ||
handleRoutineComplete: (routine: RoutineInterface, result: any, wasParallel: boolean) => void; | ||
renderLine(routine: RoutineInterface, task: TaskInterface | null, depth: number): void; | ||
handleRoutine: (routine: Routine<any, {}>, value: any, wasParallel: boolean) => void; | ||
handleRoutineComplete: (routine: Routine<any, {}>, result: any, wasParallel: boolean) => void; | ||
renderLine(routine: Routine<any>, task: Task<any> | null, depth: number): void; | ||
} |
@@ -6,5 +6,5 @@ /** | ||
import Reporter from '../Reporter'; | ||
export default class ErrorReporter extends Reporter<any> { | ||
export default class ErrorReporter extends Reporter { | ||
bootstrap(): void; | ||
handleError: (error: Error) => void; | ||
} |
@@ -6,27 +6,20 @@ /** | ||
import { Options as ExecaOptions, SyncOptions as ExecaSyncOptions, ExecaChildProcess, ExecaReturns } from 'execa'; | ||
import { Struct } from 'optimal'; | ||
import Context from './Context'; | ||
import Task, { TaskAction, TaskInterface } from './Task'; | ||
import { ToolInterface } from './Tool'; | ||
import { Debugger } from './types'; | ||
import Task, { TaskAction } from './Task'; | ||
import Tool from './Tool'; | ||
import { AggregatedResponse } from './Executor'; | ||
import { PoolExecutorOptions } from './executors/Pool'; | ||
export interface CommandOptions extends Struct { | ||
import { Debugger } from './types'; | ||
export interface CommandOptions { | ||
sync?: boolean; | ||
task?: TaskInterface; | ||
task?: Task<any>; | ||
wrap?: (process: ExecaChildProcess) => void; | ||
} | ||
export interface RoutineInterface extends TaskInterface { | ||
key: string; | ||
routines: RoutineInterface[]; | ||
tool: ToolInterface; | ||
run<T>(context: Context, initialValue?: T | null, wasParallel?: boolean): Promise<any>; | ||
} | ||
export default class Routine<To extends Struct, Tx extends Context> extends Task<To, Tx> implements RoutineInterface { | ||
export default class Routine<Ctx extends Context, Options = {}> extends Task<Ctx, Options> { | ||
exit: boolean; | ||
debug: Debugger; | ||
key: string; | ||
routines: RoutineInterface[]; | ||
tool: ToolInterface; | ||
constructor(key: string, title: string, options?: Partial<To>); | ||
routines: Routine<Ctx, any>[]; | ||
tool: Tool; | ||
constructor(key: string, title: string, options?: Partial<Options>); | ||
/** | ||
@@ -39,3 +32,3 @@ * Called once the routine has been configured and is ready to execute. | ||
*/ | ||
configure(parent: Routine<Struct, Tx>): this; | ||
configure(parent: Routine<Ctx>): this; | ||
/** | ||
@@ -45,3 +38,3 @@ * Execute the current routine and return a new value. | ||
*/ | ||
execute<T>(context: Tx, value?: T): Promise<any>; | ||
execute<T>(context: Ctx, value?: T): Promise<any>; | ||
/** | ||
@@ -54,43 +47,43 @@ * Execute a command with the given arguments and pass the results through a promise. | ||
*/ | ||
parallelizeRoutines<T>(value?: T, routines?: RoutineInterface[]): Promise<any[]>; | ||
parallelizeRoutines<T>(value?: T, routines?: Routine<Ctx>[]): Promise<any[]>; | ||
/** | ||
* Execute tasks in parallel. | ||
*/ | ||
parallelizeTasks<T>(value?: T, tasks?: TaskInterface[]): Promise<any[]>; | ||
parallelizeTasks<T>(value?: T, tasks?: Task<Ctx>[]): Promise<any[]>; | ||
/** | ||
* Add a new routine within this routine. | ||
*/ | ||
pipe(routine: RoutineInterface): this; | ||
pipe(routine: Routine<Ctx>): this; | ||
/** | ||
* Execute routines in a pool. | ||
*/ | ||
poolRoutines<T>(value?: T, options?: Partial<PoolExecutorOptions>, routines?: RoutineInterface[]): Promise<AggregatedResponse>; | ||
poolRoutines<T>(value?: T, options?: Partial<PoolExecutorOptions>, routines?: Routine<Ctx>[]): Promise<AggregatedResponse>; | ||
/** | ||
* Execute tasks in a pool. | ||
*/ | ||
poolTasks<T>(value?: T, options?: Partial<PoolExecutorOptions>, tasks?: TaskInterface[]): Promise<AggregatedResponse>; | ||
poolTasks<T>(value?: T, options?: Partial<PoolExecutorOptions>, tasks?: Task<Ctx>[]): Promise<AggregatedResponse>; | ||
/** | ||
* Trigger processes before and after execution. | ||
*/ | ||
run<T>(context: Tx, value?: T, wasParallel?: boolean): Promise<any>; | ||
run<T>(context: Ctx, value?: T, wasParallel?: boolean): Promise<any>; | ||
/** | ||
* Execute routines in sequential (serial) order. | ||
*/ | ||
serializeRoutines<T>(value?: T, routines?: RoutineInterface[]): Promise<any>; | ||
serializeRoutines<T>(value?: T, routines?: Routine<Ctx>[]): Promise<any>; | ||
/** | ||
* Execute tasks in sequential (serial) order. | ||
*/ | ||
serializeTasks<T>(value?: T, tasks?: TaskInterface[]): Promise<any>; | ||
serializeTasks<T>(value?: T, tasks?: Task<Ctx>[]): Promise<any>; | ||
/** | ||
* Execute routines in sync. | ||
*/ | ||
synchronizeRoutines<T>(value?: T, routines?: RoutineInterface[]): Promise<AggregatedResponse>; | ||
synchronizeRoutines<T>(value?: T, routines?: Routine<Ctx>[]): Promise<AggregatedResponse>; | ||
/** | ||
* Execute tasks in sync. | ||
*/ | ||
synchronizeTasks<T>(value?: T, tasks?: TaskInterface[]): Promise<AggregatedResponse>; | ||
synchronizeTasks<T>(value?: T, tasks?: Task<Ctx>[]): Promise<AggregatedResponse>; | ||
/** | ||
* Define an individual task. | ||
*/ | ||
task<Tp extends Struct>(title: string, action: TaskAction<Tx>, options?: Tp): TaskInterface; | ||
task<Tp>(title: string, action: TaskAction<Ctx>, options?: Tp): Task<Ctx, Tp>; | ||
} |
@@ -26,3 +26,2 @@ "use strict"; | ||
var Task_1 = __importDefault(require("./Task")); | ||
var constants_1 = require("./constants"); | ||
var Parallel_1 = __importDefault(require("./executors/Parallel")); | ||
@@ -33,2 +32,3 @@ var Pool_1 = __importDefault(require("./executors/Pool")); | ||
var wrapWithPromise_1 = __importDefault(require("./helpers/wrapWithPromise")); | ||
var constants_1 = require("./constants"); | ||
var Routine = /** @class */ (function (_super) { | ||
@@ -35,0 +35,0 @@ __extends(Routine, _super); |
@@ -5,26 +5,10 @@ /** | ||
*/ | ||
import { Struct } from 'optimal'; | ||
import Context from './Context'; | ||
import { Status } from './types'; | ||
export interface TaskInterface { | ||
startTime: number; | ||
status: Status; | ||
statusText: string; | ||
stopTime: number; | ||
tasks: TaskInterface[]; | ||
export declare type TaskAction<Ctx extends Context> = (context: Ctx, value: any, task: Task<Ctx, any>) => any | Promise<any>; | ||
export default class Task<Ctx extends Context, Options = {}> { | ||
action: TaskAction<Ctx> | null; | ||
context: Ctx; | ||
options: Options; | ||
title: string; | ||
isPending(): boolean; | ||
isRunning(): boolean; | ||
isSkipped(): boolean; | ||
hasFailed(): boolean; | ||
hasPassed(): boolean; | ||
run<T>(context: Context, initialValue?: T | null): Promise<any>; | ||
skip(condition?: boolean): this; | ||
} | ||
export declare type TaskAction<Tx extends Context> = (context: Tx, value: any, task: TaskInterface) => any | Promise<any>; | ||
export default class Task<To extends Struct, Tx extends Context> implements TaskInterface { | ||
action: TaskAction<Tx> | null; | ||
context: Tx; | ||
options: To; | ||
title: string; | ||
startTime: number; | ||
@@ -34,4 +18,4 @@ status: Status; | ||
stopTime: number; | ||
tasks: TaskInterface[]; | ||
constructor(title: string, action?: TaskAction<Tx> | null, options?: Partial<To>); | ||
tasks: Task<Ctx, any>[]; | ||
constructor(title: string, action?: TaskAction<Ctx> | null, options?: Partial<Options>); | ||
/** | ||
@@ -60,7 +44,7 @@ * Return true if the task failed when executing. | ||
*/ | ||
run<T>(context: Tx, initialValue?: T): Promise<any>; | ||
run<T>(context: Ctx, initialValue?: T): Promise<any>; | ||
/** | ||
* Set the context to be passed around. | ||
*/ | ||
setContext(context: Tx): this; | ||
setContext(context: Ctx): this; | ||
/** | ||
@@ -67,0 +51,0 @@ * Mark a task as skipped if the condition is true. |
@@ -37,2 +37,3 @@ "use strict"; | ||
this.action = action; | ||
// @ts-ignore | ||
this.options = __assign({}, options); | ||
@@ -39,0 +40,0 @@ this.status = action ? constants_1.STATUS_PENDING : constants_1.STATUS_SKIPPED; |
@@ -5,9 +5,9 @@ /** | ||
*/ | ||
import { Blueprint, Struct } from 'optimal'; | ||
import { ConsoleInterface, ConsoleOptions } from './Console'; | ||
import Emitter, { EmitterInterface } from './Emitter'; | ||
import { PluginInterface } from './Plugin'; | ||
import { ReporterInterface } from './Reporter'; | ||
import { Blueprint } from 'optimal'; | ||
import Console, { ConsoleOptions } from './Console'; | ||
import Emitter from './Emitter'; | ||
import Plugin from './Plugin'; | ||
import Reporter from './Reporter'; | ||
import { Debugger, ToolConfig, PackageConfig } from './types'; | ||
export interface ToolOptions extends Struct { | ||
export interface ToolOptions { | ||
appName: string; | ||
@@ -22,29 +22,12 @@ configBlueprint: Blueprint; | ||
} | ||
export interface ToolInterface extends EmitterInterface { | ||
export default class Tool extends Emitter { | ||
argv: string[]; | ||
config: ToolConfig; | ||
console: ConsoleInterface; | ||
console: Console; | ||
debug: Debugger; | ||
options: ToolOptions; | ||
package: PackageConfig; | ||
plugins: PluginInterface[]; | ||
reporters: ReporterInterface[]; | ||
createDebugger(...namespaces: string[]): Debugger; | ||
initialize(): this; | ||
getPlugin(name: string): PluginInterface; | ||
getReporter(name: string): ReporterInterface; | ||
getThemeList(): string[]; | ||
log(message: string, ...args: any[]): this; | ||
logError(message: string, ...args: any[]): this; | ||
} | ||
export default class Tool<Tp extends PluginInterface, Tr extends ReporterInterface> extends Emitter implements ToolInterface { | ||
argv: string[]; | ||
config: ToolConfig; | ||
console: ConsoleInterface; | ||
debug: Debugger; | ||
initialized: boolean; | ||
options: ToolOptions; | ||
package: PackageConfig; | ||
plugins: Tp[]; | ||
reporters: Tr[]; | ||
plugins: Plugin<any>[]; | ||
reporters: Reporter<any>[]; | ||
constructor(options: Partial<ToolOptions>, argv?: string[]); | ||
@@ -54,3 +37,3 @@ /** | ||
*/ | ||
addReporter(reporter: Tr): this; | ||
addReporter(reporter: Reporter<any>): this; | ||
/** | ||
@@ -67,7 +50,7 @@ * Create a debugger with a namespace. | ||
*/ | ||
getPlugin(name: string): Tp; | ||
getPlugin(name: string): Plugin<any>; | ||
/** | ||
* Get a reporter by name. | ||
*/ | ||
getReporter(name: string): Tr; | ||
getReporter(name: string): Reporter<any>; | ||
/** | ||
@@ -74,0 +57,0 @@ * Return a list of all theme names. |
@@ -222,3 +222,2 @@ "use strict"; | ||
var loader = new ModuleLoader_1.default(this, pluginAlias, Plugin_1.default); | ||
// @ts-ignore | ||
this.plugins = loader.loadModules(this.config[pluralPluginAlias]); | ||
@@ -225,0 +224,0 @@ // Sort plugins by priority |
@@ -6,5 +6,4 @@ /** | ||
import debug from 'debug'; | ||
import { Struct } from 'optimal'; | ||
import { PluginInterface } from './Plugin'; | ||
import { ReporterInterface } from './Reporter'; | ||
import Plugin from './Plugin'; | ||
import Reporter from './Reporter'; | ||
export interface Debugger extends debug.IDebugger { | ||
@@ -22,11 +21,12 @@ (message: any, ...args: any[]): void; | ||
} | ||
export interface ToolConfig extends Struct { | ||
export interface ToolConfig { | ||
debug: boolean; | ||
extends: string | string[]; | ||
plugins: (string | PluginConfig | PluginInterface)[]; | ||
reporters: (string | ReporterConfig | ReporterInterface)[]; | ||
plugins: (string | PluginConfig | Plugin<any>)[]; | ||
reporters: (string | ReporterConfig | Reporter<any>)[]; | ||
[key: string]: any; | ||
} | ||
export interface PackageConfig extends Struct { | ||
export interface PackageConfig { | ||
name: string; | ||
[key: string]: any; | ||
} | ||
@@ -33,0 +33,0 @@ export declare type Status = 'pending' | 'running' | 'skipped' | 'passed' | 'failed'; |
{ | ||
"name": "boost", | ||
"version": "0.62.0", | ||
"version": "0.63.0", | ||
"description": "Robust pipeline for creating build tools that separate logic into routines and tasks.", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "429e6a02d99d75c6c8bd60208c550c24dd358420" | ||
"gitHead": "e2662f4b8d3ffbfa71b0ca250c705f2ff2353884" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137850
3704