Skip to content

Commit

Permalink
fixes #119
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalbanese committed Jan 19, 2024
1 parent 5f74d8a commit 7538a58
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion 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",
Expand Down
8 changes: 7 additions & 1 deletion src/commands/add/index.ts
Expand Up @@ -36,6 +36,7 @@ import {
askDbType,
askMiscPackages,
askOrm,
askPscale,
} from "./prompts.js";
import {
addContextProviderToLayout,
Expand Down Expand Up @@ -73,7 +74,7 @@ const promptUser = async (options?: InitOptions): Promise<InitOptions> => {
const dbType =
orm === null || config.driver ? undefined : await askDbType(options);

const dbProvider =
let dbProvider =
config.orm ||
orm === "prisma" ||
orm === null ||
Expand All @@ -82,6 +83,11 @@ const promptUser = async (options?: InitOptions): Promise<InitOptions> => {
? 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 =
Expand Down
7 changes: 1 addition & 6 deletions src/commands/add/orm/prisma/index.ts
Expand Up @@ -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";
Expand All @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions src/commands/add/prompts.ts
Expand Up @@ -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 ??
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -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")
Expand Down

0 comments on commit 7538a58

Please sign in to comment.