@mongez/gnz
Version:
Generator Z, the next generation of scaffolding tools.
39 lines (38 loc) • 2.12 kB
JavaScript
import {Command}from'commander';import path from'path';import {generateWarlockRestful}from'../../index.js';import {gnz}from'../../../../../main.js';const newWarlockRestfulCommand = new Command("warlock:restful")
.arguments("<name>")
.requiredOption("-p, --path <path>", "Path to save the file to, relative to the project root")
.option("-m, --model <model>", "Model name, if not provided, it will be generated from the restful name")
.option("-mp, --modelPath <modelPath>", "Model path, if not provided, it will be generated from the restful name")
.option("-r, --repository <repository>", "Repository name, if not provided, it will be generated from the restful name")
.option("-rp, --repositoryPath <repositoryPath>", "Repository path, if not provided, it will be generated from the restful name")
.option("-c, --className <className>", "Class name, if not provided, it will be generated from the restful name")
.option("-e, --exportName <exportName>", "Export name, if not provided, it will be generated from the restful name")
.option("-r, --rules <rules>", "Validation rules, input:rule|rule2|rule3,input2:rule|rule2|rule3")
.option("-f, --fileName <fileName>", "File name")
.action(async (name, options) => {
const { path: path$1, fileName, rules, className, model, modelPath, repository, repositoryPath, exportName, } = options;
const rulesList = {};
if (rules) {
const inputs = rules.split(",");
inputs.forEach(key => {
const [inputName, rules] = key.split(":");
if (!inputName)
return;
if (!rules)
return;
rulesList[inputName] = rules.split("|");
});
}
await gnz.execute(generateWarlockRestful.execute({
name,
saveTo: path.resolve(process.cwd(), path$1 || ""),
fileName,
rules: rulesList,
className,
model,
modelPath,
repository,
repositoryPath,
exportName,
}));
});export{newWarlockRestfulCommand};//# sourceMappingURL=new-warlock-restful-command.js.map