Comparing version 0.10.0 to 0.11.0
@@ -200,10 +200,10 @@ 'use strict'; | ||
if (stop) { | ||
output += '\n'; | ||
output += '\n\n'; | ||
output += this.tool.debugs.join('\n'); | ||
if (this.hasFailed) { | ||
output += '\n'; | ||
output += '\n\n'; | ||
output += this.tool.errors.join('\n'); | ||
} else { | ||
output += '\n'; | ||
output += '\n\n'; | ||
output += this.tool.logs.join('\n'); | ||
@@ -210,0 +210,0 @@ } |
@@ -58,4 +58,3 @@ 'use strict'; | ||
function Routine(key, title) { | ||
var defaultConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
function Routine(key, title, defaultConfig) { | ||
(0, _classCallCheck3.default)(this, Routine); | ||
@@ -62,0 +61,0 @@ |
@@ -32,6 +32,5 @@ 'use strict'; | ||
var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var defaultConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var defaultConfig = arguments[2]; | ||
(0, _classCallCheck3.default)(this, Task); | ||
this.action = null; | ||
this.config = {}; | ||
this.context = {}; | ||
@@ -38,0 +37,0 @@ this.frame = 0; |
@@ -157,9 +157,2 @@ 'use strict'; | ||
}, { | ||
key: 'openConsole', | ||
value: function openConsole(loader) { | ||
this.renderer.start(loader); | ||
return this; | ||
} | ||
}, { | ||
key: 'loadPlugins', | ||
@@ -189,2 +182,9 @@ value: function loadPlugins() { | ||
}, { | ||
key: 'openConsole', | ||
value: function openConsole(loader) { | ||
this.renderer.start(loader); | ||
return this; | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -191,0 +191,0 @@ value: function render() { |
{ | ||
"name": "boost", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "Robust pipeline for creating build tools that separate logic into routines and tasks.", | ||
@@ -45,5 +45,7 @@ "keywords": [], | ||
"log-update": "^2.3.0", | ||
"optimal": "^0.14.0", | ||
"pluralize": "^7.0.0" | ||
}, | ||
"peerDependencies": { | ||
"optimal": "^0.14.0" | ||
}, | ||
"devDependencies": { | ||
@@ -50,0 +52,0 @@ "@milesj/build-tool-config": "0.41.2", |
@@ -10,8 +10,8 @@ /** | ||
import type { Result, ResultPromise } from './types'; | ||
import type { Result, ResultPromise, ToolConfig } from './types'; | ||
export default class Pipeline<T: Object> extends Routine { | ||
tool: Tool<T>; | ||
export default class Pipeline extends Routine<ToolConfig> { | ||
tool: Tool; | ||
constructor(tool: Tool<T>) { | ||
constructor(tool: Tool) { | ||
super('root', 'Pipeline', tool ? tool.config : {}); | ||
@@ -18,0 +18,0 @@ |
@@ -19,3 +19,3 @@ /** | ||
tool: ?Tool<T> = null; | ||
tool: ?Tool = null; | ||
@@ -26,5 +26,5 @@ constructor(options?: T) { | ||
bootstrap(tool: Tool<T>) { | ||
bootstrap(tool: Tool) { | ||
this.tool = tool; | ||
} | ||
} |
@@ -15,6 +15,6 @@ /** | ||
export default class PluginLoader<T: Object> { | ||
export default class PluginLoader { | ||
options: ToolOptions; | ||
plugins: Plugin<T>[] = []; | ||
plugins: Plugin<*>[] = []; | ||
@@ -29,3 +29,3 @@ constructor(options: ToolOptions) { | ||
*/ | ||
importPlugin(name: string, options?: Object = {}): Plugin<T> { | ||
importPlugin(name: string, options?: Object = {}): Plugin<*> { | ||
const { appName, pluginName } = this.options; | ||
@@ -71,3 +71,3 @@ const moduleName = formatPluginModuleName(appName, pluginName, name); | ||
*/ | ||
importPluginFromOptions(baseOptions: Object): Plugin<T> { | ||
importPluginFromOptions(baseOptions: Object): Plugin<*> { | ||
const { pluginName } = this.options; | ||
@@ -93,3 +93,3 @@ const options = { ...baseOptions }; | ||
*/ | ||
loadPlugins(plugins: (string | Plugin<T>)[]): Plugin<T>[] { | ||
loadPlugins(plugins: (string | Plugin<*>)[]): Plugin<*>[] { | ||
const { pluginName } = this.options; | ||
@@ -96,0 +96,0 @@ |
@@ -37,3 +37,3 @@ /** | ||
tool: Tool<*>; | ||
tool: Tool; | ||
@@ -59,3 +59,3 @@ constructor(options?: Object = {}) { | ||
*/ | ||
render(tasks: Task[]): string { | ||
render(tasks: Task<*>[]): string { | ||
const output = []; | ||
@@ -74,3 +74,3 @@ | ||
*/ | ||
renderTask(task: Task, level?: number = 0, suffix?: string = ''): string[] { | ||
renderTask(task: Task<*>, level?: number = 0, suffix?: string = ''): string[] { | ||
const output = []; | ||
@@ -139,3 +139,3 @@ | ||
*/ | ||
renderStatus(task: Task): string { | ||
renderStatus(task: Task<*>): string { | ||
switch (task.status) { | ||
@@ -197,3 +197,3 @@ case STATUS_PENDING: | ||
*/ | ||
update(stop: boolean = false) { | ||
update(stop?: boolean = false) { | ||
if (!this.loader) { | ||
@@ -207,10 +207,10 @@ return; | ||
if (stop) { | ||
output += '\n'; | ||
output += '\n\n'; | ||
output += this.tool.debugs.join('\n'); | ||
if (this.hasFailed) { | ||
output += '\n'; | ||
output += '\n\n'; | ||
output += this.tool.errors.join('\n'); | ||
} else { | ||
output += '\n'; | ||
output += '\n\n'; | ||
output += this.tool.logs.join('\n'); | ||
@@ -217,0 +217,0 @@ } |
@@ -16,3 +16,2 @@ /** | ||
import type { | ||
Config, | ||
Result, | ||
@@ -24,8 +23,8 @@ ResultPromise, | ||
export default class Routine extends Task { | ||
export default class Routine<T: Object> extends Task<T> { | ||
key: string = ''; | ||
tool: Tool<*>; | ||
tool: Tool; | ||
constructor(key: string, title: string, defaultConfig?: Config = {}) { | ||
constructor(key: string, title: string, defaultConfig?: T) { | ||
super(title, null, defaultConfig); | ||
@@ -57,3 +56,3 @@ | ||
*/ | ||
configure(parent: Routine): this { | ||
configure(parent: Routine<*>): this { | ||
this.context = parent.context; | ||
@@ -95,3 +94,3 @@ this.tool = parent.tool; | ||
*/ | ||
executeTask = (value: Result, task: Task): ResultPromise => ( | ||
executeTask = (value: Result, task: Task<*>): ResultPromise => ( | ||
this.wrap(task.run(value, this.context)).finally(() => { | ||
@@ -123,3 +122,3 @@ this.tool.render(); | ||
*/ | ||
pipe(...routines: Routine[]): this { | ||
pipe(...routines: Routine<*>[]): this { | ||
routines.forEach((routine) => { | ||
@@ -154,8 +153,8 @@ if (routine instanceof Routine) { | ||
*/ | ||
serialize<T>( | ||
serialize<I>( | ||
initialValue: Result, | ||
items: T[], | ||
accumulator: ResultAccumulator<T>, | ||
items: I[], | ||
accumulator: ResultAccumulator<I>, | ||
): ResultPromise { | ||
return items.reduce((promise: ResultPromise, item: T) => ( | ||
return items.reduce((promise: ResultPromise, item: I) => ( | ||
promise.then(value => accumulator(value, item)) | ||
@@ -182,3 +181,3 @@ ), Promise.resolve(initialValue)); | ||
*/ | ||
task(title: string, action: TaskCallback, config?: Config = {}): this { | ||
task(title: string, action: TaskCallback, config?: Object = {}): this { | ||
if (typeof action !== 'function') { | ||
@@ -185,0 +184,0 @@ throw new TypeError('Tasks require an executable function.'); |
@@ -17,8 +17,8 @@ /** | ||
import type { Config, Result, ResultPromise, Status, TaskCallback } from './types'; | ||
import type { Result, ResultPromise, Status, TaskCallback } from './types'; | ||
export default class Task { | ||
export default class Task<T: Object> { | ||
action: ?TaskCallback = null; | ||
config: Config = {}; | ||
config: T; | ||
@@ -33,7 +33,7 @@ context: Object = {}; | ||
subroutines: Task[] = []; | ||
subroutines: Task<*>[] = []; | ||
subtasks: Task[] = []; | ||
subtasks: Task<*>[] = []; | ||
constructor(title: string, action?: ?TaskCallback = null, defaultConfig?: Config = {}) { | ||
constructor(title: string, action?: ?TaskCallback = null, defaultConfig?: T) { | ||
if (!title || typeof title !== 'string') { | ||
@@ -40,0 +40,0 @@ throw new Error('Tasks require a title.'); |
@@ -19,3 +19,3 @@ /** | ||
export default class Tool<T: Object> extends Emitter { | ||
export default class Tool extends Emitter { | ||
chalk: typeof chalk; | ||
@@ -41,5 +41,5 @@ | ||
pluginLoader: PluginLoader<T>; | ||
pluginLoader: PluginLoader; | ||
plugins: Plugin<T>[] = []; | ||
plugins: Plugin<*>[] = []; | ||
@@ -148,11 +148,2 @@ renderer: Renderer; | ||
/** | ||
* Open a new CLI instance. | ||
*/ | ||
openConsole(loader: TasksLoader): this { | ||
this.renderer.start(loader); | ||
return this; | ||
} | ||
/** | ||
* Register plugins from the loaded configuration. | ||
@@ -185,2 +176,11 @@ * | ||
/** | ||
* Open a new CLI instance. | ||
*/ | ||
openConsole(loader: TasksLoader): this { | ||
this.renderer.start(loader); | ||
return this; | ||
} | ||
/** | ||
* Trigger an update in the console. | ||
@@ -187,0 +187,0 @@ */ |
@@ -8,6 +8,5 @@ /** | ||
import Promise from 'bluebird'; | ||
import type Renderer from './Renderer'; | ||
import type Task from './Task'; | ||
export type Config = Object; | ||
export type ToolConfig = { | ||
@@ -23,2 +22,3 @@ debug?: boolean, | ||
pluginName: string, | ||
renderer: Renderer, | ||
root: string, | ||
@@ -43,3 +43,3 @@ }; | ||
export type TasksLoader = () => Task[]; | ||
export type TasksLoader = () => Task<*>[]; | ||
@@ -46,0 +46,0 @@ export type EventArguments = *[]; |
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
287451
40
2446
- Removedoptimal@^0.14.0