diff --git a/src/generate/cli.ts b/src/generate/cli.ts index 68e71a2..79455de 100644 --- a/src/generate/cli.ts +++ b/src/generate/cli.ts @@ -18,6 +18,8 @@ const coerceSchematicAliases = (arg: string) => { return "provider"; case "e": return "entity"; + case "m": + return "module"; default: return arg; } @@ -37,6 +39,7 @@ const generateProject = (): CommandModule => { "service", "provider", "entity", + "module", ] as const, describe: "The schematic to generate", type: "string", diff --git a/src/generate/form.ts b/src/generate/form.ts index 075bc67..099f99a 100644 --- a/src/generate/form.ts +++ b/src/generate/form.ts @@ -73,12 +73,18 @@ export const createTemplate = async ({ routeSchema = path.replace(/\/$/, ""); } + let templateBasedSchematic = schematic; + if (schematic === "module") { + templateBasedSchematic = "module-default"; + } + writeTemplate({ outputPath: `${usecaseDir}/${path}/${file}`, template: { - path: `./templates/${schematic}.tpl`, + path: `./templates/${templateBasedSchematic}.tpl`, data: { className, + moduleName: className, route: routeSchema, construct: anyCaseToKebabCase(className), method: getHttpMethod(method), @@ -278,6 +284,7 @@ export const createTemplate = async ({ } } } + if (schematic === "service") { console.log( " ", diff --git a/src/generate/templates/module-default.tpl b/src/generate/templates/module-default.tpl new file mode 100644 index 0000000..e512824 --- /dev/null +++ b/src/generate/templates/module-default.tpl @@ -0,0 +1,3 @@ +import { CreateModule } from "@expressots/core"; + +export const {{moduleName}}Module = CreateModule([]);