From e02ee56d74616171f3dba713b24ccdcc53076204 Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Tue, 11 Feb 2025 11:24:29 +0530 Subject: [PATCH] fix types --- src/create-project.ts | 10 +--------- src/index.ts | 12 ++++++++---- src/types.ts | 12 +++++++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/create-project.ts b/src/create-project.ts index 997e89f..cb6ce0c 100644 --- a/src/create-project.ts +++ b/src/create-project.ts @@ -2,15 +2,7 @@ import { execa } from "execa"; import fs from "fs-extra"; import ora from "ora"; import path from "node:path"; - -interface ProjectOptions { - projectName: string; - typescript: boolean; - git: boolean; - database: "libsql" | "postgres"; - auth: boolean; - features: string[]; -} +import type { ProjectOptions } from "./types"; export async function createProject(options: ProjectOptions) { const spinner = ora("Creating project directory...").start(); diff --git a/src/index.ts b/src/index.ts index 4c87e0c..a0e8a6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,11 @@ import chalk from "chalk"; import { Command } from "commander"; import { createProject } from "./create-project.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(); @@ -17,7 +21,7 @@ async function main() { default: "my-better-t-app", }); - const database = await select({ + const database = await select({ message: chalk.cyan("Select database:"), choices: [ { @@ -40,7 +44,7 @@ async function main() { default: true, }); - const features = await checkbox({ + const features = await checkbox({ message: chalk.cyan("Select additional features:"), choices: [ { @@ -69,7 +73,7 @@ async function main() { features, }; - await createProject(projectOptions as ProjectOptions); + await createProject(projectOptions); } program diff --git a/src/types.ts b/src/types.ts index 764975d..7be5738 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,10 @@ -export interface ProjectOptions { +export type ProjectFeature = "docker" | "github-actions" | "SEO"; +export type ProjectDatabase = "libsql" | "postgres"; + +export type ProjectOptions = { projectName: string; - typescript: boolean; git: boolean; - database: "libsql" | "postgres"; + database: ProjectDatabase; auth: boolean; - features: string[]; -} + features: ProjectFeature[]; +};