@mongez/gnz
Version:
Generator Z, the next generation of scaffolding tools.
29 lines (28 loc) • 1.49 kB
JavaScript
;var commander=require('commander'),path=require('path'),index=require('../../index.js'),main=require('../../../../../main.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var path__default=/*#__PURE__*/_interopDefault(path);const newWarlockHandlerCommand = new commander.Command("warlock:handler")
.arguments("<name>")
.requiredOption("-p, --path <path>", "Path to save the file to, relative to the project root")
.option("-wv, --withValidation <withValidation>", "If set to true, the handler will be generated with validation")
.option("-f, --rules <rules>", "rules, email:like,id:int,name:=")
.option("-f, --fileName <fileName>", "File name")
.action(async (name, options) => {
const { path, fileName, rules, withValidation } = options;
const rulesKeysList = {};
if (rules) {
const keys = rules.split(",");
keys.forEach(key => {
const [keyName, keyType] = key.split(":");
if (!keyName)
return;
if (!keyType)
return;
rulesKeysList[keyName] = keyType;
});
}
await main.gnz.execute(index.generateWarlockHandler.execute({
name,
saveTo: path__default.default.resolve(process.cwd(), path || ""),
fileName,
rules: rulesKeysList,
withValidation,
}));
});exports.newWarlockHandlerCommand=newWarlockHandlerCommand;//# sourceMappingURL=new-warlock-handler-command.js.map