Skip to content

Commit

Permalink
Fix switch case fall-through bug in CLI (#3525)
Browse files Browse the repository at this point in the history
* Fix redundant if

* Fix switch fallthrough cases

* Extract install map to top

* Create cool-horses-check.md

Co-authored-by: Dillon Raphael <[email protected]>
  • Loading branch information
Zeko369 and Dillon Raphael authored Jul 11, 2022
1 parent ffa7b5c commit f397cc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-horses-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"blitz": patch
---

Fixes issue when generating a new blitz app with the form flag that ends up installing the wrong form library
33 changes: 9 additions & 24 deletions packages/blitz/src/cli/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ const language = {
type TLanguage = keyof typeof language

type TPkgManager = "npm" | "yarn" | "pnpm"
type TTemplate = "full" | "minimal"
const installCommandMap: Record<TPkgManager, string> = {
yarn: "yarn",
pnpm: "pnpm install",
npm: "npm install",
}

type TTemplate = "full" | "minimal"
const templates: {[key in TTemplate]: AppGeneratorOptions["template"]} = {
full: {
path: "app",
Expand Down Expand Up @@ -132,14 +137,7 @@ const determineFormLib = async () => {

projectFormLib = res.form
} else {
switch (args["--form"] as TForms) {
case "react-final-form":
projectFormLib = forms["react-final-form"]
case "react-hook-form":
projectFormLib = forms["react-hook-form"]
case "formik":
projectFormLib = forms["formik"]
}
projectFormLib = forms[args["--form"] as TForms]
}
}

Expand Down Expand Up @@ -206,11 +204,7 @@ const determinePkgManagerToInstallDeps = async () => {

projectPkgManger = res.pkgManager

if (res.pkgManager === "skip") {
shouldInstallDeps = false
} else {
shouldInstallDeps = true
}
shouldInstallDeps = res.pkgManager !== "skip"
} else {
const res = await prompts({
type: "confirm",
Expand Down Expand Up @@ -282,16 +276,7 @@ const newApp: CliCommand = async (argv) => {
await generator.run()

if (requireManualInstall) {
let cmd
switch (projectPkgManger) {
case "yarn":
cmd = "yarn"
case "npm":
cmd = "npm install"
case "pnpm":
cmd = "pnpm install"
}
postInstallSteps.push(cmd)
postInstallSteps.push(installCommandMap[projectPkgManger])
postInstallSteps.push(
"blitz prisma migrate dev (when asked, you can name the migration anything)",
)
Expand Down

0 comments on commit f397cc2

Please sign in to comment.