@hygiene/cli
Version:
Keep your TODOs and FIXMEs healthy
71 lines (59 loc) • 2.91 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createCommand = void 0;
var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
var _yargs = _interopRequireDefault(require("yargs"));
var _findUp = require("find-up");
var _run = require("./command/run");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, 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 createCommand = function createCommand(_ref) {
var plugins = _ref.plugins;
var cmd = _yargs.default.scriptName("hygiene").option("json", {
group: "Global Options",
describe: "Report as JSON",
type: "boolean",
default: false
}).option("ignore-pattern", {
group: "Global Options",
describe: "Pattern of files to ignore",
type: "string",
default: null
}).option("ignore-path", {
group: "Global Options",
describe: "Specify path of ignore file",
type: "string",
default: (0, _findUp.sync)(".gitignore")
}).option("ignore", {
group: "Global Options",
describe: "Disable use of ignore files and patterns",
type: "boolean",
default: true
}).command({
command: "run [glob]",
describe: "",
// @ts-ignore Type 'Argv<{}>' is missing the following properties from type 'Options': _, json, ignorePath
handler: (0, _run.run)({
plugins: plugins
}),
builder: function builder(yargs) {
return yargs.positional("glob", {
describe: "Pattern of target files",
default: "**/*"
}).example("$0 run --no-ignore", "Disable ignore feature").example("$0 run --repository Leko/hygiene", "Parse non-prefixed issue(ex. #123) as Leko/hygiene").example("GITHUB_TOKEN=xxx $0 run --no-ignore", "Set GitHub access token to fetch issue or pull request");
}
}).demandCommand().epilogue("For more information, find our manual at https://github.com/Leko/hygiene").help();
plugins.forEach(function (plugin) {
var options = (0, _mapValues.default)(plugin.getConfigDefinition(), function (option) {
return _objectSpread({
group: "Plugin Options: ".concat(plugin.name)
}, option);
});
cmd.options(options);
});
return cmd;
};
exports.createCommand = createCommand;