src/index.ts 1.7 K raw
1
#!/usr/bin/env node
2
// @ts-ignore: Shebang line
3
4
import { program } from "commander";
5
import chalk from "chalk";
6
import { displayBanner, createProject, DEFAULT_REPO } from "./utils";
7
8
program
9
	.name("create-bhvr")
10
	.description("Create a bhvr monorepo starter project")
11
	.argument("[project-directory]", "directory to create the project in")
12
	.option("-y, --yes", "skip confirmation prompts")
13
	.option("--ts, --typescript", "use TypeScript (default)")
14
	.option(
15
		"--repo <repo>",
16
		"specify a custom GitHub repository as source",
17
		DEFAULT_REPO,
18
	)
19
	.option(
20
		"--template <template>",
21
		"specify a template (default, tailwind, shadcn)",
22
		"default",
23
	)
24
	.option("--branch <branch>", "specify a branch to use from the repository")
25
	.option("--rpc", "use Hono RPC client for type-safe API communication")
26
	.action(async (projectDirectory, options) => {
27
		try {
28
			displayBanner();
29
			const result = await createProject(projectDirectory, options);
30
			if (result) {
31
				console.log(chalk.green.bold("🎉 Project created successfully!"));
32
				console.log("\nNext steps:");
33
34
				if (!result.dependenciesInstalled) {
35
					console.log(chalk.cyan(`  cd ${result.projectName}`));
36
					console.log(chalk.cyan("  bun install"));
37
				} else {
38
					console.log(chalk.cyan(`  cd ${result.projectName}`));
39
				}
40
41
				console.log(chalk.cyan("  bun run dev:client   # Start the client"));
42
				console.log(
43
					chalk.cyan(
44
						"  bun run dev:server   # Start the server in another terminal",
45
					),
46
				);
47
				console.log(chalk.cyan("  bun run dev          # Start all"));
48
				process.exit(0);
49
			}
50
		} catch (err) {
51
			console.error(chalk.red("Error creating project:"), err);
52
			process.exit(1);
53
		}
54
	});
55
56
program.parse();