alepha
Version:
Easy-to-use modern TypeScript framework for building many kind of applications.
52 lines (49 loc) • 1.51 kB
text/typescript
import { $inject, z } from "alepha";
import { $command } from "alepha/command";
import { ProjectScaffolder } from "../services/ProjectScaffolder.ts";
export class InitCommand {
protected readonly scaffolder = $inject(ProjectScaffolder);
/**
* Ensure the project has the necessary Alepha configuration files.
* Add the correct dependencies to package.json and install them.
*/
public readonly init = $command({
name: "init",
description: "Add missing Alepha configuration files to the project",
args: z
.text({
title: "path",
trim: true,
lowercase: true,
})
.optional(),
flags: z.object({
pm: z
.enum(["yarn", "npm", "pnpm", "bun"])
.describe("Package manager to use")
.optional(),
// choose which modules to scaffold
api: z
.boolean()
.describe("Include API module structure (src/api/)")
.optional(),
react: z
.boolean()
.meta({ aliases: ["r"] })
.describe("Include React dependencies and web module (src/web/)")
.optional(),
tailwind: z
.boolean()
.describe("Include Tailwind CSS with Vite plugin. Implies --react")
.optional(),
force: z
.boolean()
.meta({ aliases: ["f"] })
.describe("Override existing files")
.optional(),
}),
handler: async ({ run, flags, root, args }) => {
await this.scaffolder.init({ run, flags, root, args });
},
});
}