fix types

This commit is contained in:
Aman Varshney
2025-02-11 11:24:29 +05:30
parent 23f9b0adb7
commit e02ee56d74
3 changed files with 16 additions and 18 deletions

View File

@@ -2,15 +2,7 @@ import { execa } from "execa";
import fs from "fs-extra"; import fs from "fs-extra";
import ora from "ora"; import ora from "ora";
import path from "node:path"; import path from "node:path";
import type { ProjectOptions } from "./types";
interface ProjectOptions {
projectName: string;
typescript: boolean;
git: boolean;
database: "libsql" | "postgres";
auth: boolean;
features: string[];
}
export async function createProject(options: ProjectOptions) { export async function createProject(options: ProjectOptions) {
const spinner = ora("Creating project directory...").start(); const spinner = ora("Creating project directory...").start();

View File

@@ -3,7 +3,11 @@ import chalk from "chalk";
import { Command } from "commander"; import { Command } from "commander";
import { createProject } from "./create-project.js"; import { createProject } from "./create-project.js";
import { renderTitle } from "./render-title.js"; import { renderTitle } from "./render-title.js";
import type { ProjectOptions } from "./types.js"; import type {
ProjectFeature,
ProjectDatabase,
ProjectOptions,
} from "./types.js";
const program = new Command(); const program = new Command();
@@ -17,7 +21,7 @@ async function main() {
default: "my-better-t-app", default: "my-better-t-app",
}); });
const database = await select({ const database = await select<ProjectDatabase>({
message: chalk.cyan("Select database:"), message: chalk.cyan("Select database:"),
choices: [ choices: [
{ {
@@ -40,7 +44,7 @@ async function main() {
default: true, default: true,
}); });
const features = await checkbox({ const features = await checkbox<ProjectFeature>({
message: chalk.cyan("Select additional features:"), message: chalk.cyan("Select additional features:"),
choices: [ choices: [
{ {
@@ -69,7 +73,7 @@ async function main() {
features, features,
}; };
await createProject(projectOptions as ProjectOptions); await createProject(projectOptions);
} }
program program

View File

@@ -1,8 +1,10 @@
export interface ProjectOptions { export type ProjectFeature = "docker" | "github-actions" | "SEO";
export type ProjectDatabase = "libsql" | "postgres";
export type ProjectOptions = {
projectName: string; projectName: string;
typescript: boolean;
git: boolean; git: boolean;
database: "libsql" | "postgres"; database: ProjectDatabase;
auth: boolean; auth: boolean;
features: string[]; features: ProjectFeature[];
} };