@sewing-kit/ui
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -8,16 +8,48 @@ "use strict"; | ||
class DiagnosticError extends Error { | ||
constructor({ | ||
title, | ||
content, | ||
suggestion | ||
}) { | ||
super(title); | ||
this.title = title; | ||
this.content = content; | ||
this.suggestion = suggestion; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var DiagnosticError = | ||
/*#__PURE__*/ | ||
function (_Error) { | ||
_inherits(DiagnosticError, _Error); | ||
function DiagnosticError(_ref) { | ||
var _this; | ||
var title = _ref.title, | ||
content = _ref.content, | ||
suggestion = _ref.suggestion; | ||
_classCallCheck(this, DiagnosticError); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(DiagnosticError).call(this, title)); | ||
_this.title = title; | ||
_this.content = content; | ||
_this.suggestion = suggestion; | ||
return _this; | ||
} | ||
} | ||
return DiagnosticError; | ||
}(_wrapNativeSuper(Error)); | ||
exports.DiagnosticError = DiagnosticError; |
@@ -6,2 +6,32 @@ "use strict"; | ||
}); | ||
var _exportNames = { | ||
Step: true, | ||
Formatter: true, | ||
Loggable: true, | ||
LogLevel: true | ||
}; | ||
Object.defineProperty(exports, "Step", { | ||
enumerable: true, | ||
get: function get() { | ||
return _types.Step; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Formatter", { | ||
enumerable: true, | ||
get: function get() { | ||
return _types.Formatter; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Loggable", { | ||
enumerable: true, | ||
get: function get() { | ||
return _types.Loggable; | ||
} | ||
}); | ||
Object.defineProperty(exports, "LogLevel", { | ||
enumerable: true, | ||
get: function get() { | ||
return _types.LogLevel; | ||
} | ||
}); | ||
@@ -12,5 +42,6 @@ var _runner = require("./runner"); | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
get: function get() { | ||
return _runner[key]; | ||
@@ -25,5 +56,6 @@ } | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
get: function get() { | ||
return _steps[key]; | ||
@@ -38,5 +70,6 @@ } | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
get: function get() { | ||
return _errors[key]; | ||
@@ -51,8 +84,11 @@ } | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
get: function get() { | ||
return _ui[key]; | ||
} | ||
}); | ||
}); | ||
}); | ||
var _types = require("./types"); |
@@ -10,306 +10,782 @@ "use strict"; | ||
var _types = require("@sewing-kit/types"); | ||
var _types = require("./types"); | ||
var _errors = require("./errors"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
const symbols = '⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆'; | ||
var PersistentLineState; | ||
function _templateObject23() { | ||
var data = _taggedTemplateLiteral(["\uD83E\uDDF5 The following unexpected error occurred. We want to provide more useful suggestions when errors occur, so please open an issue on {link the sewing-kit repo https://github.com/Shopify/sewing-kit} so that we can improve this message."]); | ||
(function (PersistentLineState) { | ||
PersistentLineState[PersistentLineState["Default"] = 0] = "Default"; | ||
PersistentLineState[PersistentLineState["Error"] = 1] = "Error"; | ||
})(PersistentLineState || (PersistentLineState = {})); | ||
_templateObject23 = function _templateObject23() { | ||
return data; | ||
}; | ||
async function run(ui, run) { | ||
let tick = 0; | ||
let hasLoggedSection = false; | ||
let lastPersistentContentSize = 0; | ||
const isInteractive = process.stdout.isTTY; | ||
const logQueue = []; | ||
const persistentLines = new Set(); | ||
return data; | ||
} | ||
const update = () => { | ||
if (!isInteractive) return; | ||
function _templateObject22() { | ||
var data = _taggedTemplateLiteral(["{subdued ", "}"]); | ||
if (lastPersistentContentSize > 0) { | ||
ui.stdout.moveCursor(0, -1 * Math.max(0, lastPersistentContentSize - 1)); | ||
ui.stdout.clearDown(); | ||
} | ||
_templateObject22 = function _templateObject22() { | ||
return data; | ||
}; | ||
for (const queued of logQueue) { | ||
ui.log(...queued); | ||
} | ||
return data; | ||
} | ||
logQueue.length = 0; | ||
const persistentLineText = [ui.stdout.stringify(fmt => fmt`{subdued -------------------------------------------------------------------------------------}`), ...[...persistentLines].map(({ | ||
loggable, | ||
state | ||
}) => ui.stdout.stringify(fmt => fmt`${state === PersistentLineState.Default ? fmt`{info ${symbols[tick % symbols.length]}}` : fmt`{error ✕}`} ${loggable}`))].join('\n'); | ||
lastPersistentContentSize = persistentLineText.split('\n').length; | ||
function _templateObject21() { | ||
var data = _taggedTemplateLiteral(["{emphasis What do I do next?}"]); | ||
if (persistentLineText.length > 0) { | ||
ui.stdout.write(persistentLineText); | ||
} | ||
_templateObject21 = function _templateObject21() { | ||
return data; | ||
}; | ||
const log = (loggable, options) => { | ||
var _ref; | ||
return data; | ||
} | ||
if (!ui.canLogLevel((_ref = options === null || options === void 0 ? void 0 : options.level) !== null && _ref !== void 0 ? _ref : _types.LogLevel.Info)) { | ||
return; | ||
} | ||
function _templateObject20() { | ||
var data = _taggedTemplateLiteral(["{error Error} ", ""]); | ||
if (isInteractive) { | ||
logQueue.push([loggable, options]); | ||
} else { | ||
ui.log(loggable, options); | ||
} | ||
_templateObject20 = function _templateObject20() { | ||
return data; | ||
}; | ||
const frame = () => { | ||
update(); | ||
tick += 1; | ||
return data; | ||
} | ||
function _templateObject19() { | ||
var data = _taggedTemplateLiteral(["\uD83E\uDDF5 {title ", "}\n"], ["\uD83E\uDDF5 {title ", "}\\n"]); | ||
_templateObject19 = function _templateObject19() { | ||
return data; | ||
}; | ||
const addPersistentLine = loggable => { | ||
if (!isInteractive) { | ||
log(loggable); | ||
return { | ||
remove: () => {}, | ||
fail: () => {}, | ||
update: () => {} | ||
}; | ||
} | ||
return data; | ||
} | ||
const persistentLine = { | ||
loggable, | ||
state: PersistentLineState.Default | ||
}; | ||
persistentLines.add(persistentLine); | ||
return { | ||
remove: () => persistentLines.delete(persistentLine), | ||
fail: () => { | ||
persistentLine.state = PersistentLineState.Error; | ||
}, | ||
update: loggable => { | ||
persistentLine.loggable = loggable; | ||
} | ||
}; | ||
function _templateObject18() { | ||
var data = _taggedTemplateLiteral(["failed during step: {info ", "}"]); | ||
_templateObject18 = function _templateObject18() { | ||
return data; | ||
}; | ||
const logSeparator = () => { | ||
if (!hasLoggedSection) { | ||
return; | ||
} | ||
return data; | ||
} | ||
log(fmt => fmt`{subdued ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}`); | ||
function _templateObject17() { | ||
var data = _taggedTemplateLiteral(["finished step: {info ", "}"]); | ||
_templateObject17 = function _templateObject17() { | ||
return data; | ||
}; | ||
const runNested = async ({ | ||
id, | ||
persistentLine: initialPersistentLine | ||
}, run) => { | ||
const nestedLog = (loggable, options) => { | ||
log(fmt => fmt`{emphasis [${id}]} {subdued [${timestamp()}]} ${loggable}`, options); | ||
}; | ||
return data; | ||
} | ||
const persistentLine = addPersistentLine(initialPersistentLine); | ||
function _templateObject16() { | ||
var data = _taggedTemplateLiteral(["starting step: {info ", "}"]); | ||
try { | ||
const result = await run({ | ||
log: nestedLog, | ||
persistentLine, | ||
stepRunner: () => ({ | ||
exec: _execa.default, | ||
_templateObject16 = function _templateObject16() { | ||
return data; | ||
}; | ||
log(loggable, options) { | ||
log(fmt => fmt`{emphasis [${id}]} {subdued [${timestamp()}]} {info info}`, options); | ||
log(fmt => fmt`{subdued └} ${loggable}`, options); | ||
} | ||
return data; | ||
} | ||
}) | ||
}); | ||
persistentLine.remove(); | ||
return result; | ||
} catch (error) { | ||
persistentLine.fail(); | ||
throw error; | ||
} finally { | ||
hasLoggedSection = true; | ||
} | ||
function _templateObject15() { | ||
var data = _taggedTemplateLiteral(["skipped step: {info ", "}"]); | ||
_templateObject15 = function _templateObject15() { | ||
return data; | ||
}; | ||
const runSteps = async (steps, { | ||
id, | ||
skip, | ||
separator | ||
}) => { | ||
if (steps.length === 0) { | ||
return; | ||
} | ||
return data; | ||
} | ||
const stepOrSteps = steps.length === 1 ? 'step' : 'steps'; | ||
let skippedPreSteps = 0; | ||
let finishedPreSteps = 0; | ||
let failedPreSteps = 0; | ||
function _templateObject14() { | ||
var data = _taggedTemplateLiteral(["{subdued , }"]); | ||
const createPersistentLabel = () => { | ||
const resolvedSteps = skippedPreSteps + finishedPreSteps + failedPreSteps; | ||
_templateObject14 = function _templateObject14() { | ||
return data; | ||
}; | ||
if (resolvedSteps === 0) { | ||
return fmt => fmt`{emphasis [${id}]} running ${steps.length.toLocaleString()} ${stepOrSteps}`; | ||
} | ||
return data; | ||
} | ||
return fmt => { | ||
const remainingSteps = steps.length - resolvedSteps; | ||
const errorPart = failedPreSteps > 0 ? fmt`{error ${failedPreSteps.toLocaleString()} failed}` : false; | ||
const finishedPart = finishedPreSteps > 0 ? fmt`{success ${finishedPreSteps.toLocaleString()} finished}` : false; | ||
const skippedPart = skippedPreSteps > 0 ? fmt`{subdued ${skippedPreSteps.toLocaleString()} skipped}` : false; | ||
const runningPart = remainingSteps > 0 ? `running ${remainingSteps.toLocaleString()}` : 'finished running'; | ||
return fmt`{emphasis [${id}]} ${runningPart} ${remainingSteps === 1 ? 'step' : 'steps'} {subdued (}${[errorPart, finishedPart, skippedPart].filter(Boolean).join(fmt`{subdued , }`)}{subdued )}`; | ||
}; | ||
}; | ||
function _templateObject13() { | ||
var data = _taggedTemplateLiteral(["{emphasis [", "]} ", " ", " {subdued (}", "{subdued )}"]); | ||
if (separator) { | ||
logSeparator(); | ||
} | ||
_templateObject13 = function _templateObject13() { | ||
return data; | ||
}; | ||
await runNested({ | ||
id, | ||
persistentLine: createPersistentLabel() | ||
}, async ({ | ||
log, | ||
stepRunner, | ||
persistentLine | ||
}) => { | ||
log(`starting ${stepOrSteps}`); | ||
return data; | ||
} | ||
for (const step of steps) { | ||
var _step$skip; | ||
function _templateObject12() { | ||
var data = _taggedTemplateLiteral(["{subdued ", " skipped}"]); | ||
if (skip && ((_step$skip = step.skip) === null || _step$skip === void 0 ? void 0 : _step$skip.call(step, skip))) { | ||
skippedPreSteps += 1; | ||
_templateObject12 = function _templateObject12() { | ||
return data; | ||
}; | ||
if (step.label) { | ||
log(fmt => fmt`skipped step: {info ${step.label}}`); | ||
} else { | ||
log(`skipped unlabeled step`); | ||
} | ||
return data; | ||
} | ||
persistentLine.update(createPersistentLabel()); | ||
continue; | ||
} | ||
function _templateObject11() { | ||
var data = _taggedTemplateLiteral(["{success ", " finished}"]); | ||
if (step.label) { | ||
log(fmt => fmt`starting step: {info ${step.label}}`); | ||
} else { | ||
log(`starting unlabeled step`); | ||
} | ||
_templateObject11 = function _templateObject11() { | ||
return data; | ||
}; | ||
try { | ||
await step.run(stepRunner(step)); | ||
finishedPreSteps += 1; | ||
persistentLine.update(createPersistentLabel()); | ||
return data; | ||
} | ||
if (step.label) { | ||
log(fmt => fmt`finished step: {info ${step.label}}`); | ||
} | ||
} catch (error) { | ||
failedPreSteps += 1; | ||
persistentLine.update(createPersistentLabel()); | ||
function _templateObject10() { | ||
var data = _taggedTemplateLiteral(["{error ", " failed}"]); | ||
if (step.label) { | ||
log(fmt => fmt`failed during step: {info ${step.label}}`); | ||
} else { | ||
log(`failed during unlabeled step`); | ||
} | ||
_templateObject10 = function _templateObject10() { | ||
return data; | ||
}; | ||
throw error; | ||
} | ||
} | ||
return data; | ||
} | ||
log(`finished ${stepOrSteps}`); | ||
}); | ||
function _templateObject9() { | ||
var data = _taggedTemplateLiteral(["{emphasis [", "]} running ", " ", ""]); | ||
_templateObject9 = function _templateObject9() { | ||
return data; | ||
}; | ||
let interval; | ||
return data; | ||
} | ||
if (isInteractive) { | ||
interval = setInterval(frame, 60); | ||
} | ||
function _templateObject8() { | ||
var data = _taggedTemplateLiteral(["{subdued \u2514} ", ""]); | ||
try { | ||
const result = await run({ | ||
log, | ||
nested: runNested, | ||
steps: runSteps, | ||
separator: logSeparator, | ||
epilogue: loggable => { | ||
logSeparator(); | ||
log(loggable); | ||
}, | ||
title: title => log(fmt => fmt`🧵 {title ${title}}\n`), | ||
pre: (steps, skip) => runSteps(steps, { | ||
id: 'pre', | ||
skip, | ||
separator: false | ||
}), | ||
post: (steps, skip) => runSteps(steps, { | ||
id: 'post', | ||
skip, | ||
separator: true | ||
}) | ||
}); | ||
update(); | ||
return result; | ||
} catch (error) { | ||
update(); | ||
_templateObject8 = function _templateObject8() { | ||
return data; | ||
}; | ||
if (error instanceof _errors.DiagnosticError) { | ||
ui.error('\n'); | ||
ui.error(fmt => fmt`{error Error} ${error.title || 'An unexpected error occurred'}`); | ||
return data; | ||
} | ||
if (error.content) { | ||
ui.error('\n'); | ||
ui.error(error.content); | ||
} | ||
function _templateObject7() { | ||
var data = _taggedTemplateLiteral(["{emphasis [", "]} {subdued [", "]} {info info}"]); | ||
if (error.suggestion) { | ||
ui.error('\n'); | ||
ui.error(fmt => fmt`{emphasis What do I do next?}`); | ||
ui.error(error.suggestion); | ||
} | ||
_templateObject7 = function _templateObject7() { | ||
return data; | ||
}; | ||
if (error.stack) { | ||
ui.error('\n'); | ||
ui.error(fmt => fmt`{subdued ${error.stack}}`); | ||
} | ||
} else { | ||
ui.error(fmt => fmt`🧵 The following unexpected error occurred. We want to provide more useful suggestions when errors occur, so please open an issue on {link the sewing-kit repo https://github.com/Shopify/sewing-kit} so that we can improve this message.`); // ui.log(error.message); | ||
return data; | ||
} | ||
if (error.all != null) { | ||
ui.error(error.all); | ||
ui.error(error.stack); | ||
} else if (error.stderr != null) { | ||
ui.error(error.stderr); | ||
ui.error(error.stack); | ||
} else if (error.stdout == null) { | ||
ui.error(error.stack); | ||
} else { | ||
ui.error(error.stdout); | ||
ui.error(error.stack); | ||
function _templateObject6() { | ||
var data = _taggedTemplateLiteral(["{emphasis [", "]} {subdued [", "]} ", ""]); | ||
_templateObject6 = function _templateObject6() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject5() { | ||
var data = _taggedTemplateLiteral(["{subdued ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}"]); | ||
_templateObject5 = function _templateObject5() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject4() { | ||
var data = _taggedTemplateLiteral(["{error \u2715}"]); | ||
_templateObject4 = function _templateObject4() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject3() { | ||
var data = _taggedTemplateLiteral(["{info ", "}"]); | ||
_templateObject3 = function _templateObject3() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject2() { | ||
var data = _taggedTemplateLiteral(["", " ", ""]); | ||
_templateObject2 = function _templateObject2() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["{subdued -------------------------------------------------------------------------------------}"]); | ||
_templateObject = function _templateObject() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
var symbols = '⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆'; | ||
var PersistentLineState; | ||
(function (PersistentLineState) { | ||
PersistentLineState[PersistentLineState["Default"] = 0] = "Default"; | ||
PersistentLineState[PersistentLineState["Error"] = 1] = "Error"; | ||
})(PersistentLineState || (PersistentLineState = {})); | ||
function run(ui, run) { | ||
var tick, hasLoggedSection, lastPersistentContentSize, isInteractive, logQueue, persistentLines, update, log, frame, addPersistentLine, logSeparator, runNested, runSteps, interval, result; | ||
return regeneratorRuntime.async(function run$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
tick = 0; | ||
hasLoggedSection = false; | ||
lastPersistentContentSize = 0; | ||
isInteractive = process.stdout.isTTY; | ||
logQueue = []; | ||
persistentLines = new Set(); | ||
update = function update() { | ||
if (!isInteractive) return; | ||
if (lastPersistentContentSize > 0) { | ||
ui.stdout.moveCursor(0, -1 * Math.max(0, lastPersistentContentSize - 1)); | ||
ui.stdout.clearDown(); | ||
} | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = logQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var queued = _step.value; | ||
ui.log.apply(ui, _toConsumableArray(queued)); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
logQueue.length = 0; | ||
var persistentLineText = [ui.stdout.stringify(function (fmt) { | ||
return fmt(_templateObject()); | ||
})].concat(_toConsumableArray(_toConsumableArray(persistentLines).map(function (_ref) { | ||
var loggable = _ref.loggable, | ||
state = _ref.state; | ||
return ui.stdout.stringify(function (fmt) { | ||
return fmt(_templateObject2(), state === PersistentLineState.Default ? fmt(_templateObject3(), symbols[tick % symbols.length]) : fmt(_templateObject4()), loggable); | ||
}); | ||
}))).join('\n'); | ||
lastPersistentContentSize = persistentLineText.split('\n').length; | ||
if (persistentLineText.length > 0) { | ||
ui.stdout.write(persistentLineText); | ||
} | ||
}; | ||
log = function log(loggable, options) { | ||
var _ref2; | ||
if (!ui.canLogLevel((_ref2 = options === null || options === void 0 ? void 0 : options.level) !== null && _ref2 !== void 0 ? _ref2 : _types.LogLevel.Info)) { | ||
return; | ||
} | ||
if (isInteractive) { | ||
logQueue.push([loggable, options]); | ||
} else { | ||
ui.log(loggable, options); | ||
} | ||
}; | ||
frame = function frame() { | ||
update(); | ||
tick += 1; | ||
}; | ||
addPersistentLine = function addPersistentLine(loggable) { | ||
if (!isInteractive) { | ||
log(loggable); | ||
return { | ||
remove: function remove() {}, | ||
fail: function fail() {}, | ||
update: function update() {} | ||
}; | ||
} | ||
var persistentLine = { | ||
loggable: loggable, | ||
state: PersistentLineState.Default | ||
}; | ||
persistentLines.add(persistentLine); | ||
return { | ||
remove: function remove() { | ||
return persistentLines["delete"](persistentLine); | ||
}, | ||
fail: function fail() { | ||
persistentLine.state = PersistentLineState.Error; | ||
}, | ||
update: function update(loggable) { | ||
persistentLine.loggable = loggable; | ||
} | ||
}; | ||
}; | ||
logSeparator = function logSeparator() { | ||
if (!hasLoggedSection) { | ||
return; | ||
} | ||
log(function (fmt) { | ||
return fmt(_templateObject5()); | ||
}); | ||
}; | ||
runNested = function runNested(_ref3, run) { | ||
var id, initialPersistentLine, nestedLog, persistentLine, result; | ||
return regeneratorRuntime.async(function runNested$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
id = _ref3.id, initialPersistentLine = _ref3.persistentLine; | ||
nestedLog = function nestedLog(loggable, options) { | ||
log(function (fmt) { | ||
return fmt(_templateObject6(), id, timestamp(), loggable); | ||
}, options); | ||
}; | ||
persistentLine = addPersistentLine(initialPersistentLine); | ||
_context.prev = 3; | ||
_context.next = 6; | ||
return regeneratorRuntime.awrap(run({ | ||
log: nestedLog, | ||
persistentLine: persistentLine, | ||
stepRunner: function stepRunner() { | ||
return { | ||
exec: _execa["default"], | ||
log: function (_log) { | ||
function log(_x, _x2) { | ||
return _log.apply(this, arguments); | ||
} | ||
log.toString = function () { | ||
return _log.toString(); | ||
}; | ||
return log; | ||
}(function (loggable, options) { | ||
log(function (fmt) { | ||
return fmt(_templateObject7(), id, timestamp()); | ||
}, options); | ||
log(function (fmt) { | ||
return fmt(_templateObject8(), loggable); | ||
}, options); | ||
}) | ||
}; | ||
} | ||
})); | ||
case 6: | ||
result = _context.sent; | ||
persistentLine.remove(); | ||
return _context.abrupt("return", result); | ||
case 11: | ||
_context.prev = 11; | ||
_context.t0 = _context["catch"](3); | ||
persistentLine.fail(); | ||
throw _context.t0; | ||
case 15: | ||
_context.prev = 15; | ||
hasLoggedSection = true; | ||
return _context.finish(15); | ||
case 18: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, null, null, [[3, 11, 15, 18]]); | ||
}; | ||
runSteps = function runSteps(steps, _ref4) { | ||
var id, skip, separator, stepOrSteps, skippedPreSteps, finishedPreSteps, failedPreSteps, createPersistentLabel; | ||
return regeneratorRuntime.async(function runSteps$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
id = _ref4.id, skip = _ref4.skip, separator = _ref4.separator; | ||
if (!(steps.length === 0)) { | ||
_context4.next = 3; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
case 3: | ||
stepOrSteps = steps.length === 1 ? 'step' : 'steps'; | ||
skippedPreSteps = 0; | ||
finishedPreSteps = 0; | ||
failedPreSteps = 0; | ||
createPersistentLabel = function createPersistentLabel() { | ||
var resolvedSteps = skippedPreSteps + finishedPreSteps + failedPreSteps; | ||
if (resolvedSteps === 0) { | ||
return function (fmt) { | ||
return fmt(_templateObject9(), id, steps.length.toLocaleString(), stepOrSteps); | ||
}; | ||
} | ||
return function (fmt) { | ||
var remainingSteps = steps.length - resolvedSteps; | ||
var errorPart = failedPreSteps > 0 ? fmt(_templateObject10(), failedPreSteps.toLocaleString()) : false; | ||
var finishedPart = finishedPreSteps > 0 ? fmt(_templateObject11(), finishedPreSteps.toLocaleString()) : false; | ||
var skippedPart = skippedPreSteps > 0 ? fmt(_templateObject12(), skippedPreSteps.toLocaleString()) : false; | ||
var runningPart = remainingSteps > 0 ? "running ".concat(remainingSteps.toLocaleString()) : 'finished running'; | ||
return fmt(_templateObject13(), id, runningPart, remainingSteps === 1 ? 'step' : 'steps', [errorPart, finishedPart, skippedPart].filter(Boolean).join(fmt(_templateObject14()))); | ||
}; | ||
}; | ||
if (separator) { | ||
logSeparator(); | ||
} | ||
_context4.next = 11; | ||
return regeneratorRuntime.awrap(runNested({ | ||
id: id, | ||
persistentLine: createPersistentLabel() | ||
}, function _callee(_ref5) { | ||
var log, stepRunner, persistentLine, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _loop, _iterator2, _step2, _ret; | ||
return regeneratorRuntime.async(function _callee$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
log = _ref5.log, stepRunner = _ref5.stepRunner, persistentLine = _ref5.persistentLine; | ||
log("starting ".concat(stepOrSteps)); | ||
_iteratorNormalCompletion2 = true; | ||
_didIteratorError2 = false; | ||
_iteratorError2 = undefined; | ||
_context3.prev = 5; | ||
_loop = function _loop() { | ||
var _step$skip; | ||
var step; | ||
return regeneratorRuntime.async(function _loop$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
step = _step2.value; | ||
if (!(skip && ((_step$skip = step.skip) === null || _step$skip === void 0 ? void 0 : _step$skip.call(step, skip)))) { | ||
_context2.next = 6; | ||
break; | ||
} | ||
skippedPreSteps += 1; | ||
if (step.label) { | ||
log(function (fmt) { | ||
return fmt(_templateObject15(), step.label); | ||
}); | ||
} else { | ||
log("skipped unlabeled step"); | ||
} | ||
persistentLine.update(createPersistentLabel()); | ||
return _context2.abrupt("return", "continue"); | ||
case 6: | ||
if (step.label) { | ||
log(function (fmt) { | ||
return fmt(_templateObject16(), step.label); | ||
}); | ||
} else { | ||
log("starting unlabeled step"); | ||
} | ||
_context2.prev = 7; | ||
_context2.next = 10; | ||
return regeneratorRuntime.awrap(step.run(stepRunner(step))); | ||
case 10: | ||
finishedPreSteps += 1; | ||
persistentLine.update(createPersistentLabel()); | ||
if (step.label) { | ||
log(function (fmt) { | ||
return fmt(_templateObject17(), step.label); | ||
}); | ||
} | ||
_context2.next = 21; | ||
break; | ||
case 15: | ||
_context2.prev = 15; | ||
_context2.t0 = _context2["catch"](7); | ||
failedPreSteps += 1; | ||
persistentLine.update(createPersistentLabel()); | ||
if (step.label) { | ||
log(function (fmt) { | ||
return fmt(_templateObject18(), step.label); | ||
}); | ||
} else { | ||
log("failed during unlabeled step"); | ||
} | ||
throw _context2.t0; | ||
case 21: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, null, null, [[7, 15]]); | ||
}; | ||
_iterator2 = steps[Symbol.iterator](); | ||
case 8: | ||
if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { | ||
_context3.next = 17; | ||
break; | ||
} | ||
_context3.next = 11; | ||
return regeneratorRuntime.awrap(_loop()); | ||
case 11: | ||
_ret = _context3.sent; | ||
if (!(_ret === "continue")) { | ||
_context3.next = 14; | ||
break; | ||
} | ||
return _context3.abrupt("continue", 14); | ||
case 14: | ||
_iteratorNormalCompletion2 = true; | ||
_context3.next = 8; | ||
break; | ||
case 17: | ||
_context3.next = 23; | ||
break; | ||
case 19: | ||
_context3.prev = 19; | ||
_context3.t0 = _context3["catch"](5); | ||
_didIteratorError2 = true; | ||
_iteratorError2 = _context3.t0; | ||
case 23: | ||
_context3.prev = 23; | ||
_context3.prev = 24; | ||
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { | ||
_iterator2["return"](); | ||
} | ||
case 26: | ||
_context3.prev = 26; | ||
if (!_didIteratorError2) { | ||
_context3.next = 29; | ||
break; | ||
} | ||
throw _iteratorError2; | ||
case 29: | ||
return _context3.finish(26); | ||
case 30: | ||
return _context3.finish(23); | ||
case 31: | ||
log("finished ".concat(stepOrSteps)); | ||
case 32: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, null, null, [[5, 19, 23, 31], [24,, 26, 30]]); | ||
})); | ||
case 11: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}); | ||
}; | ||
if (isInteractive) { | ||
interval = setInterval(frame, 60); | ||
} | ||
_context5.prev = 14; | ||
_context5.next = 17; | ||
return regeneratorRuntime.awrap(run({ | ||
log: log, | ||
nested: runNested, | ||
steps: runSteps, | ||
separator: logSeparator, | ||
epilogue: function epilogue(loggable) { | ||
logSeparator(); | ||
log(loggable); | ||
}, | ||
title: function (_title) { | ||
function title(_x3) { | ||
return _title.apply(this, arguments); | ||
} | ||
title.toString = function () { | ||
return _title.toString(); | ||
}; | ||
return title; | ||
}(function (title) { | ||
return log(function (fmt) { | ||
return fmt(_templateObject19(), title); | ||
}); | ||
}), | ||
pre: function pre(steps, skip) { | ||
return runSteps(steps, { | ||
id: 'pre', | ||
skip: skip, | ||
separator: false | ||
}); | ||
}, | ||
post: function post(steps, skip) { | ||
return runSteps(steps, { | ||
id: 'post', | ||
skip: skip, | ||
separator: true | ||
}); | ||
} | ||
})); | ||
case 17: | ||
result = _context5.sent; | ||
update(); | ||
return _context5.abrupt("return", result); | ||
case 22: | ||
_context5.prev = 22; | ||
_context5.t0 = _context5["catch"](14); | ||
update(); | ||
if (_context5.t0 instanceof _errors.DiagnosticError) { | ||
ui.error('\n'); | ||
ui.error(function (fmt) { | ||
return fmt(_templateObject20(), _context5.t0.title || 'An unexpected error occurred'); | ||
}); | ||
if (_context5.t0.content) { | ||
ui.error('\n'); | ||
ui.error(_context5.t0.content); | ||
} | ||
if (_context5.t0.suggestion) { | ||
ui.error('\n'); | ||
ui.error(function (fmt) { | ||
return fmt(_templateObject21()); | ||
}); | ||
ui.error(_context5.t0.suggestion); | ||
} | ||
if (_context5.t0.stack) { | ||
ui.error('\n'); | ||
ui.error(function (fmt) { | ||
return fmt(_templateObject22(), _context5.t0.stack); | ||
}); | ||
} | ||
} else { | ||
ui.error(function (fmt) { | ||
return fmt(_templateObject23()); | ||
}); // ui.log(error.message); | ||
if (_context5.t0.all != null) { | ||
ui.error(_context5.t0.all); | ||
ui.error(_context5.t0.stack); | ||
} else if (_context5.t0.stderr != null) { | ||
ui.error(_context5.t0.stderr); | ||
ui.error(_context5.t0.stack); | ||
} else if (_context5.t0.stdout == null) { | ||
ui.error(_context5.t0.stack); | ||
} else { | ||
ui.error(_context5.t0.stdout); | ||
ui.error(_context5.t0.stack); | ||
} | ||
} | ||
process.exitCode = 1; | ||
case 27: | ||
_context5.prev = 27; | ||
if (interval) clearInterval(interval); | ||
return _context5.finish(27); | ||
case 30: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
} | ||
process.exitCode = 1; | ||
} finally { | ||
if (interval) clearInterval(interval); | ||
} | ||
}, null, null, [[14, 22, 27, 30]]); | ||
} | ||
function timestamp(date = new Date()) { | ||
const milliseconds = date.getMilliseconds(); | ||
return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}.${milliseconds.toString().padStart(3, '0')}`; | ||
function timestamp() { | ||
var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date(); | ||
var milliseconds = date.getMilliseconds(); | ||
return "".concat(date.getHours().toString().padStart(2, '0'), ":").concat(date.getMinutes().toString().padStart(2, '0'), ":").concat(date.getSeconds().toString().padStart(2, '0'), ".").concat(milliseconds.toString().padStart(3, '0')); | ||
} |
@@ -8,4 +8,16 @@ "use strict"; | ||
const defaultSkip = () => false; | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var defaultSkip = function defaultSkip() { | ||
return false; | ||
}; | ||
function createStep(runOrStep, run) { | ||
@@ -15,19 +27,22 @@ return typeof runOrStep === 'function' ? { | ||
skip: defaultSkip | ||
} : { | ||
run: run, | ||
...normalizeOptions(runOrStep) | ||
}; | ||
} : _objectSpread({ | ||
run: run | ||
}, normalizeOptions(runOrStep)); | ||
} | ||
function normalizeOptions({ | ||
skip, | ||
...rest | ||
}) { | ||
return { ...rest, | ||
function normalizeOptions(_ref) { | ||
var skip = _ref.skip, | ||
rest = _objectWithoutProperties(_ref, ["skip"]); | ||
return _objectSpread({}, rest, { | ||
skip: skip ? normalizeSkip(skip) : defaultSkip | ||
}; | ||
}); | ||
} | ||
function normalizeSkip(skipper) { | ||
return typeof skipper === 'function' ? skipper : skipped => skipped.some(skip => skipper.test(skip)); | ||
return typeof skipper === 'function' ? skipper : function (skipped) { | ||
return skipped.some(function (skip) { | ||
return skipper.test(skip); | ||
}); | ||
}; | ||
} |
@@ -16,29 +16,48 @@ "use strict"; | ||
var _types = require("@sewing-kit/types"); | ||
var _types = require("./types"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
const CHALK_MAPPINGS = new Map([['success', 'green'], ['error', 'red'], ['info', 'blue'], ['subdued', 'dim'], ['emphasis', 'bold'], ['code', 'inverse'], ['command', 'bold'], ['title', 'bold.underline']]); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
var CHALK_MAPPINGS = new Map([['success', 'green'], ['error', 'red'], ['info', 'blue'], ['subdued', 'dim'], ['emphasis', 'bold'], ['code', 'inverse'], ['command', 'bold'], ['title', 'bold.underline']]); | ||
function createFormatter(stream) { | ||
const supportsLinks = (0, _supportsHyperlinks.supportsHyperlink)(stream); | ||
var supportsLinks = (0, _supportsHyperlinks.supportsHyperlink)(stream); | ||
const formatString = str => { | ||
const formattingRegex = /\{(success|error|info|subdued|emphasis|code|command|title)/g; | ||
const linkRegex = /\{link\s+(.*?)(?=http)([^}])*\}/; | ||
return str.replace(formattingRegex, (_, format) => { | ||
return `{${CHALK_MAPPINGS.get(format)}`; | ||
}).replace(linkRegex, (_, text, url) => { | ||
return supportsLinks ? (0, _ansiEscapes.link)(text.trim(), url) : `${text.trim()} (${url})`; | ||
var formatString = function formatString(str) { | ||
var formattingRegex = /\{(success|error|info|subdued|emphasis|code|command|title)/g; | ||
var linkRegex = /\{link\s+(.*?)(?=http)([^}])*\}/; | ||
return str.replace(formattingRegex, function (_, format) { | ||
return "{".concat(CHALK_MAPPINGS.get(format)); | ||
}).replace(linkRegex, function (_, text, url) { | ||
return supportsLinks ? (0, _ansiEscapes.link)(text.trim(), url) : "".concat(text.trim(), " (").concat(url, ")"); | ||
}); | ||
}; | ||
const processInterpolation = interpolated => { | ||
var processInterpolation = function processInterpolation(interpolated) { | ||
return typeof interpolated === 'function' ? interpolated(formatter) : interpolated || ''; | ||
}; | ||
const formatter = (strings, ...interpolated) => { | ||
const newStrings = strings.map(formatString); | ||
var formatter = function formatter(strings) { | ||
var newStrings = strings.map(formatString); | ||
newStrings.raw = newStrings; | ||
return (0, _chalk.default)(newStrings, ...interpolated.map(processInterpolation)); | ||
for (var _len = arguments.length, interpolated = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
interpolated[_key - 1] = arguments[_key]; | ||
} | ||
return _chalk["default"].apply(void 0, [newStrings].concat(_toConsumableArray(interpolated.map(processInterpolation)))); | ||
}; | ||
@@ -49,4 +68,8 @@ | ||
class FormattedStream { | ||
constructor(stream) { | ||
var FormattedStream = | ||
/*#__PURE__*/ | ||
function () { | ||
function FormattedStream(stream) { | ||
_classCallCheck(this, FormattedStream); | ||
this.stream = stream; | ||
@@ -56,30 +79,47 @@ this.formatter = createFormatter(stream); | ||
stringify(value) { | ||
return typeof value === 'function' ? value(this.formatter) : String(value); | ||
} | ||
_createClass(FormattedStream, [{ | ||
key: "stringify", | ||
value: function stringify(value) { | ||
return typeof value === 'function' ? value(this.formatter) : String(value); | ||
} | ||
}, { | ||
key: "write", | ||
value: function write(value) { | ||
var stringified = this.stringify(value); | ||
this.stream.write(stringified); | ||
return stringified; | ||
} | ||
}, { | ||
key: "moveCursor", | ||
value: function moveCursor() { | ||
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
(0, _readline.moveCursor)(this.stream, x, y); | ||
(0, _readline.cursorTo)(this.stream, x); | ||
} | ||
}, { | ||
key: "clearDown", | ||
value: function clearDown() { | ||
(0, _readline.clearScreenDown)(this.stream); | ||
(0, _readline.clearLine)(this.stream, 0); | ||
} | ||
}]); | ||
write(value) { | ||
const stringified = this.stringify(value); | ||
this.stream.write(stringified); | ||
return stringified; | ||
} | ||
return FormattedStream; | ||
}(); | ||
moveCursor(x = 0, y = 0) { | ||
(0, _readline.moveCursor)(this.stream, x, y); | ||
(0, _readline.cursorTo)(this.stream, x); | ||
} | ||
var Ui = | ||
/*#__PURE__*/ | ||
function () { | ||
function Ui() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$stdout = _ref.stdout, | ||
stdout = _ref$stdout === void 0 ? process.stdout : _ref$stdout, | ||
_ref$stderr = _ref.stderr, | ||
stderr = _ref$stderr === void 0 ? process.stderr : _ref$stderr, | ||
_ref$level = _ref.level, | ||
level = _ref$level === void 0 ? _types.LogLevel.Info : _ref$level; | ||
clearDown() { | ||
(0, _readline.clearScreenDown)(this.stream); | ||
(0, _readline.clearLine)(this.stream, 0); | ||
} | ||
_classCallCheck(this, Ui); | ||
} | ||
class Ui { | ||
constructor({ | ||
stdout = process.stdout, | ||
stderr = process.stderr, | ||
level = _types.LogLevel.Info | ||
} = {}) { | ||
this.stdout = new FormattedStream(stdout); | ||
@@ -90,30 +130,40 @@ this.stderr = new FormattedStream(stderr); | ||
log(value, { | ||
level = _types.LogLevel.Info | ||
} = {}) { | ||
if (!this.canLogLevel(level)) { | ||
return; | ||
} | ||
_createClass(Ui, [{ | ||
key: "log", | ||
value: function log(value) { | ||
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref2$level = _ref2.level, | ||
level = _ref2$level === void 0 ? _types.LogLevel.Info : _ref2$level; | ||
this.stdout.write(value); | ||
this.stdout.write('\n'); | ||
} | ||
if (!this.canLogLevel(level)) { | ||
return; | ||
} | ||
error(value, { | ||
level = _types.LogLevel.Info | ||
} = {}) { | ||
if (!this.canLogLevel(level)) { | ||
return; | ||
this.stdout.write(value); | ||
this.stdout.write('\n'); | ||
} | ||
}, { | ||
key: "error", | ||
value: function error(value) { | ||
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref3$level = _ref3.level, | ||
level = _ref3$level === void 0 ? _types.LogLevel.Info : _ref3$level; | ||
this.stderr.write(value); | ||
this.stderr.write('\n'); | ||
} | ||
if (!this.canLogLevel(level)) { | ||
return; | ||
} | ||
canLogLevel(level) { | ||
return this.level >= level; | ||
} | ||
this.stderr.write(value); | ||
this.stderr.write('\n'); | ||
} | ||
}, { | ||
key: "canLogLevel", | ||
value: function canLogLevel(level) { | ||
return this.level >= level; | ||
} | ||
}]); | ||
} | ||
return Ui; | ||
}(); | ||
exports.Ui = Ui; |
export * from './runner'; | ||
export * from './steps'; | ||
export * from './errors'; | ||
export * from './ui'; | ||
export * from './ui'; | ||
export { Step, Formatter, Loggable, LogLevel } from './types'; |
import exec from 'execa'; | ||
import { LogLevel } from '@sewing-kit/types'; | ||
import { LogLevel } from './types'; | ||
import { DiagnosticError } from './errors'; | ||
@@ -4,0 +4,0 @@ const symbols = '⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆'; |
@@ -5,3 +5,3 @@ import { clearScreenDown, clearLine, moveCursor, cursorTo } from 'readline'; | ||
import { supportsHyperlink } from 'supports-hyperlinks'; | ||
import { LogLevel } from '@sewing-kit/types'; | ||
import { LogLevel } from './types'; | ||
const CHALK_MAPPINGS = new Map([['success', 'green'], ['error', 'red'], ['info', 'blue'], ['subdued', 'dim'], ['emphasis', 'bold'], ['code', 'inverse'], ['command', 'bold'], ['title', 'bold.underline']]); | ||
@@ -8,0 +8,0 @@ |
@@ -5,2 +5,3 @@ export * from './runner'; | ||
export * from './ui'; | ||
export { Step, Formatter, Loggable, LogLevel } from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,1 +10,3 @@ "use strict"; | ||
__export(require("./ui")); | ||
var types_1 = require("./types"); | ||
exports.LogLevel = types_1.LogLevel; |
@@ -1,15 +0,34 @@ | ||
import { Step } from '@sewing-kit/types'; | ||
import { Step, Loggable, LogOptions, StepRunner as NestedStepRunner } from './types'; | ||
import { Ui } from './ui'; | ||
interface StepGroup { | ||
readonly steps: Step[]; | ||
readonly skip?: string[]; | ||
interface PersistentLineController { | ||
update(loggable: Loggable): void; | ||
remove(): void; | ||
fail(): void; | ||
} | ||
interface RunOptions { | ||
ui: Ui; | ||
title?: string; | ||
pre?: StepGroup; | ||
post?: StepGroup; | ||
interface RunStepsOptions { | ||
readonly id: Loggable; | ||
readonly skip?: readonly string[]; | ||
readonly separator?: boolean; | ||
} | ||
export declare function run({ steps, skip }: StepGroup, { ui, title, pre, post }: RunOptions): Promise<void>; | ||
interface StepsRunner { | ||
readonly persistentLine: PersistentLineController; | ||
log(loggable: Loggable, options?: LogOptions): void; | ||
stepRunner(step: Step): NestedStepRunner; | ||
} | ||
interface RunNestedOptions { | ||
readonly id: Loggable; | ||
readonly persistentLine: Loggable; | ||
} | ||
interface Runner { | ||
log(loggable: Loggable, options?: LogOptions): void; | ||
title(title: string): void; | ||
separator(): void; | ||
epilogue(loggable: Loggable): void; | ||
pre(steps: readonly Step[], skip?: readonly string[]): Promise<void>; | ||
post(steps: readonly Step[], skip?: readonly string[]): Promise<void>; | ||
steps(steps: readonly Step[], options: RunStepsOptions): Promise<void>; | ||
nested<T>(options: RunNestedOptions, run: (runner: StepsRunner) => Promise<T>): Promise<T>; | ||
} | ||
export declare function run<T>(ui: Ui, run: (runner: Runner) => T): Promise<T | undefined>; | ||
export {}; | ||
//# sourceMappingURL=runner.d.ts.map |
@@ -7,11 +7,20 @@ "use strict"; | ||
const execa_1 = __importDefault(require("execa")); | ||
const types_1 = require("./types"); | ||
const errors_1 = require("./errors"); | ||
const symbols = '⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆'; | ||
async function run({ steps, skip }, { ui, title, pre, post }) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var PersistentLineState; | ||
(function (PersistentLineState) { | ||
PersistentLineState[PersistentLineState["Default"] = 0] = "Default"; | ||
PersistentLineState[PersistentLineState["Error"] = 1] = "Error"; | ||
})(PersistentLineState || (PersistentLineState = {})); | ||
async function run(ui, run) { | ||
let tick = 0; | ||
let hasLoggedSection = false; | ||
let lastPersistentContentSize = 0; | ||
const isInteractive = process.stdout.isTTY; | ||
const logQueue = []; | ||
const persistentLines = new Set(); | ||
const update = () => { | ||
if (!isInteractive) | ||
return; | ||
if (lastPersistentContentSize > 0) { | ||
@@ -25,5 +34,8 @@ ui.stdout.moveCursor(0, -1 * Math.max(0, lastPersistentContentSize - 1)); | ||
logQueue.length = 0; | ||
const persistentLineText = [...persistentLines] | ||
.map((loggable) => ui.stdout.stringify((fmt) => fmt `${fmt `{info ${symbols[tick % symbols.length]}}`} ${loggable}`)) | ||
.join('\n'); | ||
const persistentLineText = [ | ||
ui.stdout.stringify((fmt) => fmt `{subdued -------------------------------------------------------------------------------------}`), | ||
...[...persistentLines].map(({ loggable, state }) => ui.stdout.stringify((fmt) => fmt `${state === PersistentLineState.Default | ||
? fmt `{info ${symbols[tick % symbols.length]}}` | ||
: fmt `{error ✕}`} ${loggable}`)), | ||
].join('\n'); | ||
lastPersistentContentSize = persistentLineText.split('\n').length; | ||
@@ -34,4 +46,13 @@ if (persistentLineText.length > 0) { | ||
}; | ||
const log = (...args) => { | ||
logQueue.push(args); | ||
const log = (loggable, options) => { | ||
var _a, _b; | ||
if (!ui.canLogLevel((_b = (_a = options) === null || _a === void 0 ? void 0 : _a.level, (_b !== null && _b !== void 0 ? _b : types_1.LogLevel.Info)))) { | ||
return; | ||
} | ||
if (isInteractive) { | ||
logQueue.push([loggable, options]); | ||
} | ||
else { | ||
ui.log(loggable, options); | ||
} | ||
}; | ||
@@ -42,88 +63,158 @@ const frame = () => { | ||
}; | ||
const addPersistentLabel = (loggable) => { | ||
persistentLines.add(loggable); | ||
return { remove: () => persistentLines.delete(loggable) }; | ||
const addPersistentLine = (loggable) => { | ||
if (!isInteractive) { | ||
log(loggable); | ||
return { remove: () => { }, fail: () => { }, update: () => { } }; | ||
} | ||
const persistentLine = { | ||
loggable, | ||
state: PersistentLineState.Default, | ||
}; | ||
persistentLines.add(persistentLine); | ||
return { | ||
remove: () => persistentLines.delete(persistentLine), | ||
fail: () => { | ||
persistentLine.state = PersistentLineState.Error; | ||
}, | ||
update: (loggable) => { | ||
persistentLine.loggable = loggable; | ||
}, | ||
}; | ||
}; | ||
const interval = setInterval(frame, 60); | ||
try { | ||
if (title) { | ||
log((fmt) => fmt `🧵 {emphasis ${title}}\n`); | ||
const logSeparator = () => { | ||
if (!hasLoggedSection) { | ||
return; | ||
} | ||
if (pre != null && pre.steps.length > 0) { | ||
const { remove } = addPersistentLabel(`Running pre-${title} steps`); | ||
const preRunner = { | ||
exec: execa_1.default, | ||
log(loggable) { | ||
log((fmt) => fmt `{subdued [pre]} {info info}`); | ||
log(loggable); | ||
}, | ||
log((fmt) => fmt `{subdued ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}`); | ||
}; | ||
const runNested = async ({ id, persistentLine: initialPersistentLine }, run) => { | ||
const nestedLog = (loggable, options) => { | ||
log((fmt) => fmt `{emphasis [${id}]} {subdued [${timestamp()}]} ${loggable}`, options); | ||
}; | ||
const persistentLine = addPersistentLine(initialPersistentLine); | ||
try { | ||
const result = await run({ | ||
log: nestedLog, | ||
persistentLine, | ||
stepRunner: () => ({ | ||
exec: execa_1.default, | ||
log(loggable, options) { | ||
log((fmt) => fmt `{emphasis [${id}]} {subdued [${timestamp()}]} {info info}`, options); | ||
log((fmt) => fmt `{subdued └} ${loggable}`, options); | ||
}, | ||
}), | ||
}); | ||
persistentLine.remove(); | ||
return result; | ||
} | ||
catch (error) { | ||
persistentLine.fail(); | ||
throw error; | ||
} | ||
finally { | ||
hasLoggedSection = true; | ||
} | ||
}; | ||
const runSteps = async (steps, { id, skip, separator }) => { | ||
if (steps.length === 0) { | ||
return; | ||
} | ||
const stepOrSteps = steps.length === 1 ? 'step' : 'steps'; | ||
let skippedPreSteps = 0; | ||
let finishedPreSteps = 0; | ||
let failedPreSteps = 0; | ||
const createPersistentLabel = () => { | ||
const resolvedSteps = skippedPreSteps + finishedPreSteps + failedPreSteps; | ||
if (resolvedSteps === 0) { | ||
return (fmt) => fmt `{emphasis [${id}]} running ${steps.length.toLocaleString()} ${stepOrSteps}`; | ||
} | ||
return (fmt) => { | ||
const remainingSteps = steps.length - resolvedSteps; | ||
const errorPart = failedPreSteps > 0 | ||
? fmt `{error ${failedPreSteps.toLocaleString()} failed}` | ||
: false; | ||
const finishedPart = finishedPreSteps > 0 | ||
? fmt `{success ${finishedPreSteps.toLocaleString()} finished}` | ||
: false; | ||
const skippedPart = skippedPreSteps > 0 | ||
? fmt `{subdued ${skippedPreSteps.toLocaleString()} skipped}` | ||
: false; | ||
const runningPart = remainingSteps > 0 | ||
? `running ${remainingSteps.toLocaleString()}` | ||
: 'finished running'; | ||
return fmt `{emphasis [${id}]} ${runningPart} ${remainingSteps === 1 ? 'step' : 'steps'} {subdued (}${[errorPart, finishedPart, skippedPart] | ||
.filter(Boolean) | ||
.join(fmt `{subdued , }`)}{subdued )}`; | ||
}; | ||
for (const step of pre.steps) { | ||
if (pre.skip && step.skip(pre.skip)) { | ||
}; | ||
if (separator) { | ||
logSeparator(); | ||
} | ||
await runNested({ id, persistentLine: createPersistentLabel() }, async ({ log, stepRunner, persistentLine }) => { | ||
var _a, _b; | ||
log(`starting ${stepOrSteps}`); | ||
for (const step of steps) { | ||
if (skip && ((_b = (_a = step).skip) === null || _b === void 0 ? void 0 : _b.call(_a, skip))) { | ||
skippedPreSteps += 1; | ||
if (step.label) { | ||
log((fmt) => fmt `{subdued [pre]} skipped step ${JSON.stringify(step.label)}`); | ||
log((fmt) => fmt `skipped step: {info ${step.label}}`); | ||
} | ||
else { | ||
log(`skipped unlabeled step`); | ||
} | ||
persistentLine.update(createPersistentLabel()); | ||
continue; | ||
} | ||
if (step.label) { | ||
preRunner.log(`Starting step ${JSON.stringify(step.label)}`); | ||
log((fmt) => fmt `starting step: {info ${step.label}}`); | ||
} | ||
await ((_b = (_a = step).run) === null || _b === void 0 ? void 0 : _b.call(_a, preRunner)); | ||
log((fmt) => fmt `{success ✓} Finished running pre steps`); | ||
} | ||
remove(); | ||
} | ||
if (steps.length > 0) { | ||
const stepRunner = { | ||
exec: execa_1.default, | ||
log(loggable) { | ||
log((fmt) => fmt `{subdued [main]} {info info}`); | ||
log(loggable); | ||
}, | ||
}; | ||
// eslint-disable-next-line require-atomic-updates | ||
for (const step of steps) { | ||
if (skip != null && step.skip(skip)) { | ||
else { | ||
log(`starting unlabeled step`); | ||
} | ||
try { | ||
await step.run(stepRunner(step)); | ||
finishedPreSteps += 1; | ||
persistentLine.update(createPersistentLabel()); | ||
if (step.label) { | ||
log((fmt) => fmt `{subdued [main]} skipped step ${JSON.stringify(step.label)}`); | ||
log((fmt) => fmt `finished step: {info ${step.label}}`); | ||
} | ||
continue; | ||
} | ||
const remove = step.label | ||
? addPersistentLabel(step.label).remove | ||
: () => { }; | ||
await ((_d = (_c = step).run) === null || _d === void 0 ? void 0 : _d.call(_c, stepRunner)); | ||
remove(); | ||
if (step.label != null) { | ||
log((fmt) => fmt `{success ✓} ${step.label}`); | ||
} | ||
} | ||
} | ||
if (post != null && post.steps.length > 0) { | ||
const { remove } = addPersistentLabel(`Running post-${title} steps`); | ||
const postRunner = { | ||
exec: execa_1.default, | ||
log(loggable) { | ||
log((fmt) => fmt `{subdued [post]} {info info}`); | ||
log(loggable); | ||
}, | ||
}; | ||
// eslint-disable-next-line require-atomic-updates | ||
for (const step of post.steps) { | ||
if (post.skip && step.skip(post.skip)) { | ||
catch (error) { | ||
failedPreSteps += 1; | ||
persistentLine.update(createPersistentLabel()); | ||
if (step.label) { | ||
log((fmt) => fmt `{subdued [post]} skipped step ${JSON.stringify(step.label)}`); | ||
log((fmt) => fmt `failed during step: {info ${step.label}}`); | ||
} | ||
continue; | ||
else { | ||
log(`failed during unlabeled step`); | ||
} | ||
throw error; | ||
} | ||
if (step.label) { | ||
postRunner.log(`Starting step ${JSON.stringify(step.label)}`); | ||
} | ||
await ((_f = (_e = step).run) === null || _f === void 0 ? void 0 : _f.call(_e, postRunner)); | ||
} | ||
remove(); | ||
log((fmt) => fmt `{success ✓} Finished running post steps`); | ||
} | ||
log(`finished ${stepOrSteps}`); | ||
}); | ||
}; | ||
let interval; | ||
if (isInteractive) { | ||
interval = setInterval(frame, 60); | ||
} | ||
try { | ||
const result = await run({ | ||
log, | ||
nested: runNested, | ||
steps: runSteps, | ||
separator: logSeparator, | ||
epilogue: (loggable) => { | ||
logSeparator(); | ||
log(loggable); | ||
}, | ||
title: (title) => log((fmt) => fmt `🧵 {title ${title}}\n`), | ||
pre: (steps, skip) => runSteps(steps, { id: 'pre', skip, separator: false }), | ||
post: (steps, skip) => runSteps(steps, { id: 'post', skip, separator: true }), | ||
}); | ||
update(); | ||
return result; | ||
} | ||
catch (error) { | ||
update(); | ||
if (error instanceof errors_1.DiagnosticError) { | ||
@@ -168,5 +259,19 @@ ui.error('\n'); | ||
finally { | ||
clearInterval(interval); | ||
if (interval) | ||
clearInterval(interval); | ||
} | ||
} | ||
exports.run = run; | ||
function timestamp(date = new Date()) { | ||
const milliseconds = date.getMilliseconds(); | ||
return `${date | ||
.getHours() | ||
.toString() | ||
.padStart(2, '0')}:${date | ||
.getMinutes() | ||
.toString() | ||
.padStart(2, '0')}:${date | ||
.getSeconds() | ||
.toString() | ||
.padStart(2, '0')}.${milliseconds.toString().padStart(3, '0')}`; | ||
} |
@@ -1,8 +0,8 @@ | ||
import { Step } from '@sewing-kit/types'; | ||
declare type Skipper = ((skipped: string[]) => boolean) | RegExp; | ||
import { Step } from './types'; | ||
declare type Skipper = ((skipped: readonly string[]) => boolean) | RegExp; | ||
export declare function createStep(run: Step['run']): Step; | ||
export declare function createStep(options: Omit<Step, 'run' | 'skip'> & { | ||
skip?: Skipper; | ||
}, run?: Step['run']): Step; | ||
}, run: Step['run']): Step; | ||
export {}; | ||
//# sourceMappingURL=steps.d.ts.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
? { run: runOrStep, skip: defaultSkip } | ||
: Object.assign({ run }, normalizeOptions(runOrStep)); | ||
: Object.assign({ run: run }, normalizeOptions(runOrStep)); | ||
} | ||
@@ -21,0 +21,0 @@ exports.createStep = createStep; |
/// <reference types="node" /> | ||
import { LogLevel, LogOptions, Loggable } from './types'; | ||
interface Options { | ||
@@ -6,6 +7,4 @@ stdin: NodeJS.ReadStream; | ||
stderr: NodeJS.WriteStream; | ||
level: LogLevel; | ||
} | ||
declare function createFormatter(stream: NodeJS.WriteStream): (strings: TemplateStringsArray, ...interpolated: Loggable[]) => string; | ||
declare type Formatter = ReturnType<typeof createFormatter>; | ||
export declare type Loggable = ((format: Formatter) => string) | string; | ||
declare class FormattedStream { | ||
@@ -23,8 +22,9 @@ private readonly stream; | ||
readonly stderr: FormattedStream; | ||
constructor({ stdout, stderr, }?: Partial<Options>); | ||
spin(_label: Loggable, wait: () => void): Promise<void>; | ||
log(value: Loggable): void; | ||
error(value: Loggable): void; | ||
readonly level: LogLevel; | ||
constructor({ stdout, stderr, level, }?: Partial<Options>); | ||
log(value: Loggable, { level }?: LogOptions): void; | ||
error(value: Loggable, { level }?: LogOptions): void; | ||
canLogLevel(level: LogLevel): boolean; | ||
} | ||
export {}; | ||
//# sourceMappingURL=ui.d.ts.map |
@@ -10,2 +10,3 @@ "use strict"; | ||
const supports_hyperlinks_1 = require("supports-hyperlinks"); | ||
const types_1 = require("./types"); | ||
const CHALK_MAPPINGS = new Map([ | ||
@@ -19,2 +20,3 @@ ['success', 'green'], | ||
['command', 'bold'], | ||
['title', 'bold.underline'], | ||
]); | ||
@@ -24,3 +26,3 @@ function createFormatter(stream) { | ||
const formatString = (str) => { | ||
const formattingRegex = /\{(success|error|info|subdued|emphasis|code|command)/g; | ||
const formattingRegex = /\{(success|error|info|subdued|emphasis|code|command|title)/g; | ||
const linkRegex = /\{link\s+(.*?)(?=http)([^}])*\}/; | ||
@@ -72,18 +74,25 @@ return str | ||
class Ui { | ||
constructor({ stdout = process.stdout, stderr = process.stderr, } = {}) { | ||
constructor({ stdout = process.stdout, stderr = process.stderr, level = types_1.LogLevel.Info, } = {}) { | ||
this.stdout = new FormattedStream(stdout); | ||
this.stderr = new FormattedStream(stderr); | ||
this.level = level; | ||
} | ||
async spin(_label, wait) { | ||
await wait(); | ||
} | ||
log(value) { | ||
log(value, { level = types_1.LogLevel.Info } = {}) { | ||
if (!this.canLogLevel(level)) { | ||
return; | ||
} | ||
this.stdout.write(value); | ||
this.stdout.write('\n'); | ||
} | ||
error(value) { | ||
error(value, { level = types_1.LogLevel.Info } = {}) { | ||
if (!this.canLogLevel(level)) { | ||
return; | ||
} | ||
this.stderr.write(value); | ||
this.stderr.write('\n'); | ||
} | ||
canLogLevel(level) { | ||
return this.level >= level; | ||
} | ||
} | ||
exports.Ui = Ui; |
@@ -1,1 +0,1 @@ | ||
module.exports = require("./build/cjs"); | ||
module.exports = require("./build/cjs/index"); |
{ | ||
"name": "@sewing-kit/ui", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"sideEffects": false, | ||
@@ -10,3 +10,2 @@ "publishConfig": { | ||
"dependencies": { | ||
"@sewing-kit/types": "^0.0.6", | ||
"@shopify/useful-types": "^2.1.2", | ||
@@ -18,3 +17,3 @@ "ansi-escapes": "^4.3.0", | ||
}, | ||
"gitHead": "e63eca9d8107384c8f36a62994a6a3d6466f80b1" | ||
"gitHead": "f171f492fee4bc77f20dbcc7cbc3898ac7b6058a" | ||
} |
import {createPackage, Runtime} from '@sewing-kit/config'; | ||
import {createSewingKitPackagePlugin} from '../../config/sewing-kit'; | ||
export default createPackage((pkg) => { | ||
pkg.runtime(Runtime.Node); | ||
pkg.plugin(createSewingKitPackagePlugin()); | ||
}); |
@@ -5,1 +5,2 @@ export * from './runner'; | ||
export * from './ui'; | ||
export {Step, Formatter, Loggable, LogLevel} from './types'; |
@@ -8,4 +8,3 @@ import exec from 'execa'; | ||
StepRunner as NestedStepRunner, | ||
} from '@sewing-kit/types'; | ||
} from './types'; | ||
import {Ui} from './ui'; | ||
@@ -36,3 +35,3 @@ import {DiagnosticError} from './errors'; | ||
readonly id: Loggable; | ||
readonly skip?: string[]; | ||
readonly skip?: readonly string[]; | ||
readonly separator?: boolean; | ||
@@ -58,5 +57,5 @@ } | ||
pre(steps: Step[], skip?: string[]): Promise<void>; | ||
post(steps: Step[], skip?: string[]): Promise<void>; | ||
steps(steps: Step[], options: RunStepsOptions): Promise<void>; | ||
pre(steps: readonly Step[], skip?: readonly string[]): Promise<void>; | ||
post(steps: readonly Step[], skip?: readonly string[]): Promise<void>; | ||
steps(steps: readonly Step[], options: RunStepsOptions): Promise<void>; | ||
nested<T>( | ||
@@ -63,0 +62,0 @@ options: RunNestedOptions, |
@@ -1,4 +0,4 @@ | ||
import {Step} from '@sewing-kit/types'; | ||
import {Step} from './types'; | ||
type Skipper = ((skipped: string[]) => boolean) | RegExp; | ||
type Skipper = ((skipped: readonly string[]) => boolean) | RegExp; | ||
@@ -31,3 +31,4 @@ const defaultSkip = () => false; | ||
? skipper | ||
: (skipped: string[]) => skipped.some((skip) => skipper.test(skip)); | ||
: (skipped: readonly string[]) => | ||
skipped.some((skip) => skipper.test(skip)); | ||
} |
@@ -6,4 +6,5 @@ import {clearScreenDown, clearLine, moveCursor, cursorTo} from 'readline'; | ||
import {supportsHyperlink} from 'supports-hyperlinks'; | ||
import {LogLevel, LogOptions, Loggable, Formatter} from '@sewing-kit/types'; | ||
import {LogLevel, LogOptions, Loggable, Formatter} from './types'; | ||
interface Options { | ||
@@ -10,0 +11,0 @@ stdin: NodeJS.ReadStream; |
@@ -15,3 +15,3 @@ { | ||
"include": ["src/**/*.ts"], | ||
"references": [{"path": "../types"}] | ||
"references": [] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
225698
5
50
3193
- Removed@sewing-kit/types@^0.0.6
- Removed@sewing-kit/types@0.0.6(transitive)
- Removed@types/tapable@1.0.12(transitive)
- Removedtapable@1.1.3(transitive)