Skip to content

Commit

Permalink
Merge pull request #25 from expressots/feature/24-add-module-scaffold
Browse files Browse the repository at this point in the history
feat: add module scaffold
  • Loading branch information
rsaz authored Sep 27, 2023
2 parents b1396db + 6491ffb commit dc42d5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/generate/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const coerceSchematicAliases = (arg: string) => {
return "provider";
case "e":
return "entity";
case "m":
return "module";
default:
return arg;
}
Expand All @@ -37,6 +39,7 @@ const generateProject = (): CommandModule<CommandModuleArgs, any> => {
"service",
"provider",
"entity",
"module",
] as const,
describe: "The schematic to generate",
type: "string",
Expand Down
9 changes: 8 additions & 1 deletion src/generate/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -278,6 +284,7 @@ export const createTemplate = async ({
}
}
}

if (schematic === "service") {
console.log(
" ",
Expand Down
3 changes: 3 additions & 0 deletions src/generate/templates/module-default.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CreateModule } from "@expressots/core";

export const {{moduleName}}Module = CreateModule([]);

0 comments on commit dc42d5b

Please sign in to comment.