diff --git a/package.json b/package.json index 842e34af..6b4fa298 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kirimase", - "version": "0.0.44", + "version": "0.0.45", "description": "A Rails-like CLI for building full-stack Next.js apps faster", "main": "index.js", "type": "module", diff --git a/src/commands/add/index.ts b/src/commands/add/index.ts index 7823a22e..155bd074 100644 --- a/src/commands/add/index.ts +++ b/src/commands/add/index.ts @@ -36,6 +36,7 @@ import { askDbType, askMiscPackages, askOrm, + askPscale, } from "./prompts.js"; import { addContextProviderToLayout, @@ -73,7 +74,7 @@ const promptUser = async (options?: InitOptions): Promise => { const dbType = orm === null || config.driver ? undefined : await askDbType(options); - const dbProvider = + let dbProvider = config.orm || orm === "prisma" || orm === null || @@ -82,6 +83,11 @@ const promptUser = async (options?: InitOptions): Promise => { ? undefined : await askDbProvider(options, dbType, config.preferredPackageManager); + if (orm === "prisma" && dbType === "mysql") { + const usePscale = await askPscale(options); + if (usePscale) dbProvider = "planetscale"; + } + const auth = config.auth || !orm ? undefined : await askAuth(options); const authProviders = diff --git a/src/commands/add/orm/prisma/index.ts b/src/commands/add/orm/prisma/index.ts index 53f3d05d..0e7a54c0 100644 --- a/src/commands/add/orm/prisma/index.ts +++ b/src/commands/add/orm/prisma/index.ts @@ -21,7 +21,6 @@ import { prismaGenerate, updateTsConfigPrismaTypeAlias, } from "../utils.js"; -import { consola } from "consola"; import { addToPrismaSchema } from "../../../generate/utils.js"; import { formatFilePath, getDbIndexPath } from "../../../filePaths/index.js"; import { addToInstallList } from "../../utils.js"; @@ -39,14 +38,10 @@ export const addPrisma = async ( // if mysql, ask if planetscale if (dbType === "mysql") { - const usingPlanetscale = await confirm({ - message: "Are you using PlanetScale?", - default: false, - }); // scaffold planetscale specific schema createFile( `prisma/schema.prisma`, - generatePrismaSchema(dbType, usingPlanetscale) + generatePrismaSchema(dbType, initOptions.dbProvider === "planetscale") ); updateConfigFile({ provider: "planetscale" }); createDotEnv( diff --git a/src/commands/add/prompts.ts b/src/commands/add/prompts.ts index 9d25704a..db860177 100644 --- a/src/commands/add/prompts.ts +++ b/src/commands/add/prompts.ts @@ -76,6 +76,16 @@ export const askDbProvider = async ( ); }; +export const askPscale = async (options: InitOptions) => { + return ( + options.dbProvider ?? + (await confirm({ + message: "Are you using PlanetScale?", + default: false, + })) + ); +}; + export const askExampleModel = async (options: InitOptions) => { return ( options.includeExample ?? diff --git a/src/index.ts b/src/index.ts index 4884c99e..ed371b79 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import { buildSchema } from "./commands/generate/index.js"; import { addPackage } from "./commands/add/index.js"; const program = new Command(); -program.name("kirimase").description("Kirimase CLI").version("0.0.44"); +program.name("kirimase").description("Kirimase CLI").version("0.0.45"); addCommonOptions(program.command("init")) .description("initialise and configure kirimase within directory")