Comparing version 0.0.6 to 0.0.8
@@ -7,28 +7,20 @@ 'use strict'; | ||
var _promise = require('babel-runtime/core-js/promise'); | ||
var _Routine = require('./Routine'); | ||
var _promise2 = _interopRequireDefault(_promise); | ||
var _Routine2 = _interopRequireDefault(_Routine); | ||
var _chalk = require('chalk'); | ||
var _Console = require('./Console'); | ||
var _chalk2 = _interopRequireDefault(_chalk); | ||
var _Console2 = _interopRequireDefault(_Console); | ||
var _readline = require('readline'); | ||
var _readline2 = _interopRequireDefault(_readline); | ||
var _Routine = require('./Routine'); | ||
var _Routine2 = _interopRequireDefault(_Routine); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/*:: import type { RoutineConfig, Result, ResultPromise } from './types';*/ /** | ||
* @copyright 2017, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
* @flow | ||
*/ | ||
/** | ||
* @copyright 2017, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
* @flow | ||
*/ | ||
/*:: import type { RoutineConfig, Result, ResultPromise } from './types';*/ | ||
class Pipeline extends _Routine2.default { | ||
constructor(name /*: string*/, config /*: RoutineConfig*/ = {}) { | ||
@@ -40,12 +32,8 @@ super(name, config); | ||
this.console = _readline2.default.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
// Initialize the root console | ||
this.console = new _Console2.default(config); | ||
} | ||
/** | ||
* Execute the routines in sequential order while passing the result | ||
* from the previous routine to the next routine. The initial value can | ||
* be passed by the consumer. | ||
* Execute all subroutines in order. | ||
*/ | ||
@@ -55,31 +43,3 @@ execute(initialValue /*: Result<*>*/ = null) /*: ResultPromise<*>*/ { | ||
} | ||
/** | ||
* Request input from the console. | ||
*/ | ||
askQuestion(question /*: string*/) /*: Promise<string>*/ { | ||
return new _promise2.default((resolve /*: (string) => void*/) => { | ||
this.console.question(_chalk2.default.magenta(question), (answer /*: string*/) => { | ||
resolve(answer); | ||
this.console.close(); | ||
}); | ||
}); | ||
} | ||
/** | ||
* Output a message to the console. | ||
*/ | ||
log(message /*: string*/) /*: this*/ { | ||
this.console.write(message); | ||
return this; | ||
} | ||
/** | ||
* Output a title for the current routing phase. | ||
*/ | ||
logTitle(step /*: string*/, message /*: string*/) /*: this*/ { | ||
return this.log(`${_chalk2.default.gray(`[${step}]`)} ${_chalk2.default.reset(message)}`); | ||
} | ||
} | ||
exports.default = Pipeline; |
@@ -23,11 +23,14 @@ 'use strict'; | ||
var _Console = require('./Console'); | ||
var _Console2 = _interopRequireDefault(_Console); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* @copyright 2017, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
* @flow | ||
*/ | ||
/*:: import type { RoutineConfig, Result, ResultPromise, ResultAccumulator, Task } from './types';*/ /** | ||
* @copyright 2017, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
* @flow | ||
*/ | ||
/*:: import type { RoutineConfig, Result, ResultPromise, ResultAccumulator, Task } from './types';*/ | ||
class Routine { | ||
@@ -59,2 +62,3 @@ | ||
// Inherit config from parent | ||
const config = parentConfig[this.name]; | ||
@@ -67,2 +71,5 @@ | ||
// Initialize setup | ||
this.setup(); | ||
return this; | ||
@@ -112,3 +119,8 @@ } | ||
if (routine instanceof Routine) { | ||
this.subroutines.push(routine.configure(this.config, this.globalConfig)); | ||
routine.configure(this.config, this.globalConfig); | ||
// eslint-disable-next-line no-param-reassign | ||
routine.console = this.console; | ||
this.subroutines.push(routine); | ||
} else { | ||
@@ -146,2 +158,7 @@ throw new TypeError('Routine must be an instance of `Routine`.'); | ||
/** | ||
* Called once the routine has been configured and is ready to execute. | ||
*/ | ||
setup() {} | ||
/** | ||
* Wrap a value in a promise if it has not already been. | ||
@@ -148,0 +165,0 @@ */ |
@@ -10,5 +10,3 @@ "use strict"; | ||
/*:: export type PrimitiveType = string | number | boolean;*/ | ||
/*:: export type RoutineConfig = { | ||
[key: string]: PrimitiveType | PrimitiveType[] | RoutineConfig, | ||
};*/ | ||
/*:: export type RoutineConfig = { [key: string]: PrimitiveType | PrimitiveType[] | RoutineConfig };*/ | ||
/*:: export type Result<T> = T;*/ | ||
@@ -15,0 +13,0 @@ /*:: export type ResultPromise<T> = Promise<Result<T>>;*/ |
{ | ||
"name": "boost", | ||
"version": "0.0.6", | ||
"version": "0.0.8", | ||
"description": "Robust pipeline for creating build tools that separate logic into routines and tasks.", | ||
@@ -59,4 +59,5 @@ "keywords": [], | ||
"engines": { | ||
"node": "^6.0.0" | ||
} | ||
"node": ">=6.0.0" | ||
}, | ||
"engineStrict": true | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15298
10
319
0