mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add auth, drizzle, prisma setup logic with template
This commit is contained in:
@@ -5,24 +5,28 @@ import type {
|
||||
ProjectConfig,
|
||||
ProjectDatabase,
|
||||
ProjectFeature,
|
||||
ProjectORM,
|
||||
ProjectOrm,
|
||||
} from "../types";
|
||||
import { getAuthChoice } from "./auth";
|
||||
import { getDatabaseChoice } from "./database";
|
||||
import { getFeaturesChoice } from "./features";
|
||||
import { getGitChoice } from "./git";
|
||||
import { getNoInstallChoice } from "./install";
|
||||
import { getORMChoice } from "./orm";
|
||||
import { getPackageManagerChoice } from "./package-manager";
|
||||
import { getProjectName } from "./project-name";
|
||||
import { getTursoSetupChoice } from "./turso";
|
||||
|
||||
interface PromptGroupResults {
|
||||
projectName: string;
|
||||
database: ProjectDatabase;
|
||||
orm: ProjectORM;
|
||||
orm: ProjectOrm;
|
||||
auth: boolean;
|
||||
features: ProjectFeature[];
|
||||
git: boolean;
|
||||
packageManager: PackageManager;
|
||||
noInstall: boolean;
|
||||
turso: boolean;
|
||||
}
|
||||
|
||||
export async function gatherConfig(
|
||||
@@ -38,9 +42,14 @@ export async function gatherConfig(
|
||||
getORMChoice(flags.orm, results.database !== "none"),
|
||||
auth: ({ results }) =>
|
||||
getAuthChoice(flags.auth, results.database !== "none"),
|
||||
turso: ({ results }) =>
|
||||
results.database === "sqlite"
|
||||
? getTursoSetupChoice(flags.turso)
|
||||
: Promise.resolve(false),
|
||||
features: () => getFeaturesChoice(flags.features),
|
||||
git: () => getGitChoice(flags.git),
|
||||
packageManager: () => getPackageManagerChoice(flags.packageManager),
|
||||
noInstall: () => getNoInstallChoice(flags.noInstall),
|
||||
},
|
||||
{
|
||||
onCancel: () => {
|
||||
@@ -58,5 +67,7 @@ export async function gatherConfig(
|
||||
features: result.features,
|
||||
git: result.git,
|
||||
packageManager: result.packageManager,
|
||||
noInstall: result.noInstall,
|
||||
turso: result.turso,
|
||||
};
|
||||
}
|
||||
|
||||
21
apps/cli/src/prompts/install.ts
Normal file
21
apps/cli/src/prompts/install.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { cancel, confirm, isCancel } from "@clack/prompts";
|
||||
import pc from "picocolors";
|
||||
import { DEFAULT_CONFIG } from "../constants";
|
||||
|
||||
export async function getNoInstallChoice(
|
||||
noInstall?: boolean,
|
||||
): Promise<boolean> {
|
||||
if (noInstall !== undefined) return noInstall;
|
||||
|
||||
const response = await confirm({
|
||||
message: "Install dependencies after creating project?",
|
||||
initialValue: !DEFAULT_CONFIG.noInstall,
|
||||
});
|
||||
|
||||
if (isCancel(response)) {
|
||||
cancel(pc.red("Operation cancelled"));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
return !response;
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
import { cancel, isCancel, select } from "@clack/prompts";
|
||||
import pc from "picocolors";
|
||||
import type { ProjectORM } from "../types";
|
||||
import type { ProjectOrm } from "../types";
|
||||
|
||||
export async function getORMChoice(
|
||||
orm: ProjectORM | undefined,
|
||||
orm: ProjectOrm | undefined,
|
||||
hasDatabase: boolean,
|
||||
): Promise<ProjectORM> {
|
||||
): Promise<ProjectOrm> {
|
||||
if (!hasDatabase) return "none";
|
||||
if (orm !== undefined) return orm;
|
||||
|
||||
const response = await select<ProjectORM>({
|
||||
const response = await select<ProjectOrm>({
|
||||
message: "Which ORM would you like to use?",
|
||||
options: [
|
||||
{
|
||||
|
||||
18
apps/cli/src/prompts/turso.ts
Normal file
18
apps/cli/src/prompts/turso.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { cancel, confirm, isCancel } from "@clack/prompts";
|
||||
import pc from "picocolors";
|
||||
|
||||
export async function getTursoSetupChoice(turso?: boolean): Promise<boolean> {
|
||||
if (turso !== undefined) return turso;
|
||||
|
||||
const response = await confirm({
|
||||
message: "Set up a Turso database for this project?",
|
||||
initialValue: true,
|
||||
});
|
||||
|
||||
if (isCancel(response)) {
|
||||
cancel(pc.red("Operation cancelled"));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
Reference in New Issue
Block a user