@mongez/gnz
Version:
Generator Z, the next generation of scaffolding tools.
30 lines (29 loc) • 1.57 kB
JavaScript
import {Command}from'commander';import path from'path';import {generateSuperTableComponent}from'../../index.js';import {gnz}from'../../../../main.js';const newSuperTableCommand = new Command("reactive:table")
.arguments("<name>")
.option("-p, --path <path>", "Path to save the component to")
.option("-m, --memo <memo>", "Whether to use memo or not")
.option("-c, --columns <columns>", "Inputs to add to the component")
.option("-sp, --service-path <servicePath>", "Path to the service")
.option("-s, --service-name <serviceName>", "Name of the service")
.option("-i, --index <withIndex>", "Whether to generate an index file or not")
.action(async (name, options) => {
const { memo, index, path: path$1, columns, servicePath, serviceName } = options;
const columnsList = {};
if (columns) {
// input will be name.string.required,email.email.required
// so we just need to split the name to be the key object and the rest of the string to be its value
columns.split(",").forEach((input) => {
const [inputName, ...restOfTypes] = input.split(".");
columnsList[inputName] = restOfTypes.join(".");
});
}
await gnz.execute(generateSuperTableComponent.execute({
name,
saveTo: path.resolve(process.cwd(), path$1 || ""),
memo: memo !== "false",
withIndex: index !== "false",
columns: columnsList,
serviceName,
servicePath,
}));
});export{newSuperTableCommand};//# sourceMappingURL=new-super-table-command.js.map