UNPKG

@mongez/gnz

Version:

Generator Z, the next generation of scaffolding tools.

31 lines (30 loc) 1.56 kB
import {Command}from'commander';import path from'path';import {generateWarlockOutput}from'../../index.js';import {gnz}from'../../../../../main.js';const newWarlockOutputCommand = new Command("warlock:output") .arguments("<name>") .option("-p, --path <path>", "Path to save the file to, relative to the project root") .option("-we, --withExtend <withExtend>", "Whether add extend method or not") .option("-wo, --withBaseOutputDetails <withBaseOutputDetails>", "Whether to merge output keys with base output") .option("-o, --outputKeys <outputKeys>", 'Output keys, separated by comma, e.g. "name:string,age:number"') .option("-f, --fileName <fileName>", "File name") .action(async (name, options) => { const { withExtend, path: path$1, withBaseOutputDetails, fileName, outputKeys } = options; const outputKeysList = {}; if (outputKeys) { const keys = outputKeys.split(","); keys.forEach(key => { const [keyName, keyType] = key.split(":"); if (!keyName) return; if (!keyType) return; outputKeysList[keyName] = keyType; }); } await gnz.execute(generateWarlockOutput.execute({ name, saveTo: path.resolve(process.cwd(), path$1 || ""), withExtend: withExtend !== "false", withBaseOutputDetails: withBaseOutputDetails !== "false", fileName, outputKeys: outputKeysList, })); });export{newWarlockOutputCommand};//# sourceMappingURL=new-warlock-output-command.js.map