@sewing-kit/plugins
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -10,47 +10,12 @@ "use strict"; | ||
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); } | ||
class MissingPluginError extends _ui.DiagnosticError { | ||
constructor(plugin) { | ||
super({ | ||
title: `Missing hooks provided by ${plugin}`, | ||
suggestion: fmt => fmt`Run {command yarn add ${plugin}}, import it into your sewing-kit config file, and include it using the {code plugins} option.` | ||
}); | ||
} | ||
function _templateObject() { | ||
var data = _taggedTemplateLiteral(["Run {command yarn add ", "}, import it into your sewing-kit config file, and include it using the {code plugins} option."]); | ||
_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 _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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var MissingPluginError = | ||
/*#__PURE__*/ | ||
function (_DiagnosticError) { | ||
_inherits(MissingPluginError, _DiagnosticError); | ||
function MissingPluginError(plugin) { | ||
_classCallCheck(this, MissingPluginError); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(MissingPluginError).call(this, { | ||
title: "Missing hooks provided by ".concat(plugin), | ||
suggestion: function suggestion(fmt) { | ||
return fmt(_templateObject(), plugin); | ||
} | ||
})); | ||
} | ||
return MissingPluginError; | ||
}(_ui.DiagnosticError); | ||
exports.MissingPluginError = MissingPluginError; |
@@ -13,3 +13,3 @@ "use strict"; | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _api[key]; | ||
@@ -26,3 +26,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _plugins[key]; | ||
@@ -39,3 +39,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utilities[key]; | ||
@@ -52,3 +52,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _errors[key]; | ||
@@ -55,0 +55,0 @@ } |
@@ -11,12 +11,5 @@ "use strict"; | ||
exports.createWorkspaceTestPlugin = exports.createWorkspaceTypeCheckPlugin = exports.createWorkspaceLintPlugin = exports.createWorkspaceDevPlugin = exports.createWorkspaceBuildPlugin = exports.createProjectTestPlugin = exports.createProjectDevPlugin = exports.createProjectBuildPlugin = exports.PluginTarget = exports.PLUGIN_MARKER = void 0; | ||
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 PLUGIN_MARKER = Symbol('SewingKit.Plugin'); | ||
const PLUGIN_MARKER = Symbol('SewingKit.Plugin'); | ||
exports.PLUGIN_MARKER = PLUGIN_MARKER; | ||
var PluginTarget; | ||
let PluginTarget; | ||
exports.PluginTarget = PluginTarget; | ||
@@ -30,36 +23,17 @@ | ||
function createProjectPlugin(plugin) { | ||
return _objectSpread({}, plugin, _defineProperty({ | ||
target: PluginTarget.Project | ||
}, PLUGIN_MARKER, true)); | ||
return { ...plugin, | ||
target: PluginTarget.Project, | ||
[PLUGIN_MARKER]: true | ||
}; | ||
} | ||
function createComposedProjectPlugin(id, pluginsOrCompose) { | ||
var compose = typeof pluginsOrCompose === 'function' ? pluginsOrCompose : function (composer) { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = pluginsOrCompose[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var plugin = _step.value; | ||
composer.use(plugin); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
const compose = typeof pluginsOrCompose === 'function' ? pluginsOrCompose : composer => { | ||
for (const plugin of pluginsOrCompose) { | ||
composer.use(plugin); | ||
} | ||
}; | ||
return createProjectPlugin({ | ||
id: id, | ||
compose: compose | ||
id, | ||
compose | ||
}); | ||
@@ -69,5 +43,6 @@ } | ||
function createWorkspacePlugin(plugin) { | ||
return _objectSpread({}, plugin, _defineProperty({ | ||
target: PluginTarget.Workspace | ||
}, PLUGIN_MARKER, true)); | ||
return { ...plugin, | ||
target: PluginTarget.Workspace, | ||
[PLUGIN_MARKER]: true | ||
}; | ||
} | ||
@@ -77,93 +52,47 @@ | ||
return createWorkspacePlugin({ | ||
id: id, | ||
compose: function compose(composer) { | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
id, | ||
try { | ||
for (var _iterator2 = plugins[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var plugin = _step2.value; | ||
composer.use(plugin); | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { | ||
_iterator2["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
compose(composer) { | ||
for (const plugin of plugins) { | ||
composer.use(plugin); | ||
} | ||
} | ||
}); | ||
} | ||
var createProjectTaskPluginCreator = function createProjectTaskPluginCreator(task) { | ||
return function (id, run) { | ||
return createProjectPlugin({ | ||
id: id, | ||
run: function (_run) { | ||
function run(_x, _x2) { | ||
return _run.apply(this, arguments); | ||
} | ||
const createProjectTaskPluginCreator = task => (id, run) => createProjectPlugin({ | ||
id, | ||
run.toString = function () { | ||
return _run.toString(); | ||
}; | ||
run(tasks, api) { | ||
tasks[task].tapPromise(id, task => Promise.resolve(run(task, api))); | ||
} | ||
return run; | ||
}(function (tasks, api) { | ||
tasks[task].tapPromise(id, function (task) { | ||
return Promise.resolve(run(task, api)); | ||
}); | ||
}) | ||
}); | ||
}; | ||
}; | ||
}); | ||
var createProjectBuildPlugin = createProjectTaskPluginCreator('build'); | ||
const createProjectBuildPlugin = createProjectTaskPluginCreator('build'); | ||
exports.createProjectBuildPlugin = createProjectBuildPlugin; | ||
var createProjectDevPlugin = createProjectTaskPluginCreator('dev'); | ||
const createProjectDevPlugin = createProjectTaskPluginCreator('dev'); | ||
exports.createProjectDevPlugin = createProjectDevPlugin; | ||
var createProjectTestPlugin = createProjectTaskPluginCreator('test'); | ||
const createProjectTestPlugin = createProjectTaskPluginCreator('test'); | ||
exports.createProjectTestPlugin = createProjectTestPlugin; | ||
var createWorkspaceTaskPluginCreator = function createWorkspaceTaskPluginCreator(task) { | ||
return function (id, run) { | ||
return createWorkspacePlugin({ | ||
id: id, | ||
run: function (_run2) { | ||
function run(_x3, _x4) { | ||
return _run2.apply(this, arguments); | ||
} | ||
const createWorkspaceTaskPluginCreator = task => (id, run) => createWorkspacePlugin({ | ||
id, | ||
run.toString = function () { | ||
return _run2.toString(); | ||
}; | ||
run(tasks, api) { | ||
tasks[task].tapPromise(id, task => Promise.resolve(run(task, api))); | ||
} | ||
return run; | ||
}(function (tasks, api) { | ||
tasks[task].tapPromise(id, function (task) { | ||
return Promise.resolve(run(task, api)); | ||
}); | ||
}) | ||
}); | ||
}; | ||
}; | ||
}); | ||
var createWorkspaceBuildPlugin = createWorkspaceTaskPluginCreator('build'); | ||
const createWorkspaceBuildPlugin = createWorkspaceTaskPluginCreator('build'); | ||
exports.createWorkspaceBuildPlugin = createWorkspaceBuildPlugin; | ||
var createWorkspaceDevPlugin = createWorkspaceTaskPluginCreator('dev'); | ||
const createWorkspaceDevPlugin = createWorkspaceTaskPluginCreator('dev'); | ||
exports.createWorkspaceDevPlugin = createWorkspaceDevPlugin; | ||
var createWorkspaceLintPlugin = createWorkspaceTaskPluginCreator('lint'); | ||
const createWorkspaceLintPlugin = createWorkspaceTaskPluginCreator('lint'); | ||
exports.createWorkspaceLintPlugin = createWorkspaceLintPlugin; | ||
var createWorkspaceTypeCheckPlugin = createWorkspaceTaskPluginCreator('typeCheck'); | ||
const createWorkspaceTypeCheckPlugin = createWorkspaceTaskPluginCreator('typeCheck'); | ||
exports.createWorkspaceTypeCheckPlugin = createWorkspaceTypeCheckPlugin; | ||
var createWorkspaceTestPlugin = createWorkspaceTaskPluginCreator('test'); | ||
const createWorkspaceTestPlugin = createWorkspaceTaskPluginCreator('test'); | ||
exports.createWorkspaceTestPlugin = createWorkspaceTestPlugin; |
@@ -12,20 +12,4 @@ "use strict"; | ||
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; } } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function addHooks(adder) { | ||
return function (hooks) { | ||
return hooks => { | ||
Object.assign(hooks, adder()); | ||
@@ -35,28 +19,20 @@ }; | ||
function toArgs(flags) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref$dasherize = _ref.dasherize, | ||
dasherize = _ref$dasherize === void 0 ? false : _ref$dasherize; | ||
function toArgs(flags, { | ||
dasherize = false | ||
} = {}) { | ||
return Object.entries(flags).reduce((all, [key, value]) => { | ||
const newArgs = []; | ||
const normalizedKey = dasherize ? (0, _changeCase.paramCase)(key) : key; | ||
return Object.entries(flags).reduce(function (all, _ref2) { | ||
var _ref3 = _slicedToArray(_ref2, 2), | ||
key = _ref3[0], | ||
value = _ref3[1]; | ||
var newArgs = []; | ||
var normalizedKey = dasherize ? (0, _changeCase.paramCase)(key) : key; | ||
if (typeof value === 'boolean') { | ||
if (value) { | ||
newArgs.push("--".concat(normalizedKey)); | ||
newArgs.push(`--${normalizedKey}`); | ||
} | ||
} else if (Array.isArray(value)) { | ||
newArgs.push.apply(newArgs, _toConsumableArray(value.flatMap(function (subValue) { | ||
return ["--".concat(normalizedKey), String(subValue)]; | ||
}))); | ||
newArgs.push(...value.flatMap(subValue => [`--${normalizedKey}`, String(subValue)])); | ||
} else if (value != null) { | ||
newArgs.push("--".concat(normalizedKey), String(value)); | ||
newArgs.push(`--${normalizedKey}`, String(value)); | ||
} | ||
return [].concat(_toConsumableArray(all), newArgs); | ||
return [...all, ...newArgs]; | ||
}, []); | ||
@@ -66,23 +42,5 @@ } | ||
function lazy(asyncImport) { | ||
return function _callee() { | ||
var _args = arguments; | ||
return regeneratorRuntime.async(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return regeneratorRuntime.awrap(asyncImport()); | ||
case 2: | ||
_context.t0 = void 0; | ||
_context.t1 = _args; | ||
return _context.abrupt("return", _context.sent.apply(_context.t0, _context.t1)); | ||
case 5: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}); | ||
return async (...args) => { | ||
return (await asyncImport())(...args); | ||
}; | ||
} |
{ | ||
"name": "@sewing-kit/plugins", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"sideEffects": false, | ||
@@ -10,8 +10,8 @@ "publishConfig": { | ||
"dependencies": { | ||
"@sewing-kit/tasks": "^0.0.2", | ||
"@sewing-kit/ui": "^0.0.13", | ||
"@sewing-kit/tasks": "^0.0.3", | ||
"@sewing-kit/ui": "^0.0.14", | ||
"change-case": "^4.1.0", | ||
"tapable": "^1.1.3" | ||
}, | ||
"gitHead": "b10516a3b50627d57e128a1af99818dc78f65d68" | ||
"gitHead": "75439e801a34ecd042ae3347183736f42d0f9eea" | ||
} |
289390
865
+ Added@sewing-kit/hooks@0.0.9(transitive)
+ Added@sewing-kit/model@0.0.2(transitive)
+ Added@sewing-kit/tasks@0.0.3(transitive)
+ Added@sewing-kit/ui@0.0.14(transitive)
- Removed@sewing-kit/hooks@0.0.8(transitive)
- Removed@sewing-kit/model@0.0.1(transitive)
- Removed@sewing-kit/tasks@0.0.2(transitive)
- Removed@sewing-kit/ui@0.0.13(transitive)
Updated@sewing-kit/tasks@^0.0.3
Updated@sewing-kit/ui@^0.0.14