From 6491ffbf6ab1f96edf41d5e80cf2642dbcc58569 Mon Sep 17 00:00:00 2001 From: Richard Zampieri Date: Tue, 26 Sep 2023 19:30:06 -0700 Subject: [PATCH] feat: add module scaffold --- src/generate/cli.ts | 3 +++ src/generate/form.ts | 9 ++++++++- src/generate/templates/module-default.tpl | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/generate/templates/module-default.tpl 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([]);