UNPKG

@mongez/gnz

Version:

Generator Z, the next generation of scaffolding tools.

39 lines (38 loc) 2.28 kB
'use strict';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 newWarlockRestfulCommand = new commander.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, 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 main.gnz.execute(index.generateWarlockRestful.execute({ name, saveTo: path__default.default.resolve(process.cwd(), path || ""), fileName, rules: rulesList, className, model, modelPath, repository, repositoryPath, exportName, })); });exports.newWarlockRestfulCommand=newWarlockRestfulCommand;//# sourceMappingURL=new-warlock-restful-command.js.map