From e21f5d743104ba8b1bed185ee85fb20e064e0bef Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Sun, 1 Nov 2020 11:39:24 +0100 Subject: [PATCH] Fixed new line missing in generated code in Routes.hs --- IHP/IDE/CodeGen/ControllerGenerator.hs | 2 +- Test/IDE/CodeGeneration/ControllerGenerator.hs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/IHP/IDE/CodeGen/ControllerGenerator.hs b/IHP/IDE/CodeGen/ControllerGenerator.hs index d398f3865..c6d66cfea 100644 --- a/IHP/IDE/CodeGen/ControllerGenerator.hs +++ b/IHP/IDE/CodeGen/ControllerGenerator.hs @@ -32,7 +32,7 @@ buildPlan' schema applicationName controllerName modelName = viewPlans = generateViews schema applicationName controllerName in [ CreateFile { filePath = applicationName <> "/Controller/" <> controllerName <> ".hs", fileContent = (generateController schema config) } - , AppendToFile { filePath = applicationName <> "/Routes.hs", fileContent = (controllerInstance config) } + , AppendToFile { filePath = applicationName <> "/Routes.hs", fileContent = "\n" <> (controllerInstance config) } , AppendToFile { filePath = applicationName <> "/Types.hs", fileContent = (generateControllerData config) } , AppendToMarker { marker = "-- Controller Imports", filePath = applicationName <> "/FrontController.hs", fileContent = ("import " <> applicationName <> ".Controller." <> controllerName) } , AppendToMarker { marker = "-- Generator Marker", filePath = applicationName <> "/FrontController.hs", fileContent = (" , parseRoute @" <> controllerName <> "Controller") } diff --git a/Test/IDE/CodeGeneration/ControllerGenerator.hs b/Test/IDE/CodeGeneration/ControllerGenerator.hs index 594b657e5..7b44c00a8 100644 --- a/Test/IDE/CodeGeneration/ControllerGenerator.hs +++ b/Test/IDE/CodeGeneration/ControllerGenerator.hs @@ -41,7 +41,7 @@ tests = do builtPlan `shouldBe` [ CreateFile {filePath = "Web/Controller/Pages.hs", fileContent = "module Web.Controller.Pages where\n\nimport Web.Controller.Prelude\nimport Web.View.Pages.Index\nimport Web.View.Pages.New\nimport Web.View.Pages.Edit\nimport Web.View.Pages.Show\n\ninstance Controller PagesController where\n action PagesAction = do\n pages <- query @Page |> fetch\n render IndexView { .. }\n\n action NewPageAction = do\n let page = newRecord\n render NewView { .. }\n\n action ShowPageAction { pageId } = do\n page <- fetch pageId\n render ShowView { .. }\n\n action EditPageAction { pageId } = do\n page <- fetch pageId\n render EditView { .. }\n\n action UpdatePageAction { pageId } = do\n page <- fetch pageId\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render EditView { .. }\n Right page -> do\n page <- page |> updateRecord\n setSuccessMessage \"Page updated\"\n redirectTo EditPageAction { .. }\n\n action CreatePageAction = do\n let page = newRecord @Page\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render NewView { .. } \n Right page -> do\n page <- page |> createRecord\n setSuccessMessage \"Page created\"\n redirectTo PagesAction\n\n action DeletePageAction { pageId } = do\n page <- fetch pageId\n deleteRecord page\n setSuccessMessage \"Page deleted\"\n redirectTo PagesAction\n\nbuildPage page = page\n |> fill @'[]\n"} - , AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PagesController\ntype instance ModelControllerMap WebApplication Page = PagesController\n\n"} + , AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PagesController\ntype instance ModelControllerMap WebApplication Page = PagesController\n\n"} , AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PagesController\n = PagesAction\n | NewPageAction\n | ShowPageAction { pageId :: !(Id Page) }\n | CreatePageAction\n | EditPageAction { pageId :: !(Id Page) }\n | UpdatePageAction { pageId :: !(Id Page) }\n | DeletePageAction { pageId :: !(Id Page) }\n deriving (Eq, Show, Data)\n"} , AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.Pages"} , AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PagesController"} @@ -68,7 +68,7 @@ tests = do builtPlan `shouldBe` [ CreateFile {filePath = "Web/Controller/Page.hs", fileContent = "module Web.Controller.Page where\n\nimport Web.Controller.Prelude\nimport Web.View.Page.Index\nimport Web.View.Page.New\nimport Web.View.Page.Edit\nimport Web.View.Page.Show\n\ninstance Controller PageController where\n action PagesAction = do\n page <- query @Page |> fetch\n render IndexView { .. }\n\n action NewPageAction = do\n let page = newRecord\n render NewView { .. }\n\n action ShowPageAction { pageId } = do\n page <- fetch pageId\n render ShowView { .. }\n\n action EditPageAction { pageId } = do\n page <- fetch pageId\n render EditView { .. }\n\n action UpdatePageAction { pageId } = do\n page <- fetch pageId\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render EditView { .. }\n Right page -> do\n page <- page |> updateRecord\n setSuccessMessage \"Page updated\"\n redirectTo EditPageAction { .. }\n\n action CreatePageAction = do\n let page = newRecord @Page\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render NewView { .. } \n Right page -> do\n page <- page |> createRecord\n setSuccessMessage \"Page created\"\n redirectTo PagesAction\n\n action DeletePageAction { pageId } = do\n page <- fetch pageId\n deleteRecord page\n setSuccessMessage \"Page deleted\"\n redirectTo PagesAction\n\nbuildPage page = page\n |> fill @'[]\n"} - , AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PageController\ntype instance ModelControllerMap WebApplication Page = PageController\n\n"} + , AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PageController\ntype instance ModelControllerMap WebApplication Page = PageController\n\n"} , AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PageController\n = PagesAction\n | NewPageAction\n | ShowPageAction { pageId :: !(Id Page) }\n | CreatePageAction\n | EditPageAction { pageId :: !(Id Page) }\n | UpdatePageAction { pageId :: !(Id Page) }\n | DeletePageAction { pageId :: !(Id Page) }\n deriving (Eq, Show, Data)\n"} , AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.Page"} , AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PageController"} @@ -95,7 +95,7 @@ tests = do builtPlan `shouldBe` [ CreateFile {filePath = "Web/Controller/PageComment.hs", fileContent = "module Web.Controller.PageComment where\n\nimport Web.Controller.Prelude\nimport Web.View.PageComment.Index\nimport Web.View.PageComment.New\nimport Web.View.PageComment.Edit\nimport Web.View.PageComment.Show\n\ninstance Controller PageCommentController where\n action PageCommentsAction = do\n pageComment <- query @PageComment |> fetch\n render IndexView { .. }\n\n action NewPageCommentAction = do\n let pageComment = newRecord\n render NewView { .. }\n\n action ShowPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render ShowView { .. }\n\n action EditPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render EditView { .. }\n\n action UpdatePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render EditView { .. }\n Right pageComment -> do\n pageComment <- pageComment |> updateRecord\n setSuccessMessage \"PageComment updated\"\n redirectTo EditPageCommentAction { .. }\n\n action CreatePageCommentAction = do\n let pageComment = newRecord @PageComment\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render NewView { .. } \n Right pageComment -> do\n pageComment <- pageComment |> createRecord\n setSuccessMessage \"PageComment created\"\n redirectTo PageCommentsAction\n\n action DeletePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n deleteRecord pageComment\n setSuccessMessage \"PageComment deleted\"\n redirectTo PageCommentsAction\n\nbuildPageComment pageComment = pageComment\n |> fill @'[]\n"} - , AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"} + , AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"} , AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PageCommentController\n = PageCommentsAction\n | NewPageCommentAction\n | ShowPageCommentAction { pageCommentId :: !(Id PageComment) }\n | CreatePageCommentAction\n | EditPageCommentAction { pageCommentId :: !(Id PageComment) }\n | UpdatePageCommentAction { pageCommentId :: !(Id PageComment) }\n | DeletePageCommentAction { pageCommentId :: !(Id PageComment) }\n deriving (Eq, Show, Data)\n"} , AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.PageComment"} , AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PageCommentController"} @@ -121,7 +121,7 @@ tests = do builtPlan `shouldBe` [ CreateFile {filePath = "Web/Controller/PageComment.hs", fileContent = "module Web.Controller.PageComment where\n\nimport Web.Controller.Prelude\nimport Web.View.PageComment.Index\nimport Web.View.PageComment.New\nimport Web.View.PageComment.Edit\nimport Web.View.PageComment.Show\n\ninstance Controller PageCommentController where\n action PageCommentsAction = do\n pageComment <- query @PageComment |> fetch\n render IndexView { .. }\n\n action NewPageCommentAction = do\n let pageComment = newRecord\n render NewView { .. }\n\n action ShowPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render ShowView { .. }\n\n action EditPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render EditView { .. }\n\n action UpdatePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render EditView { .. }\n Right pageComment -> do\n pageComment <- pageComment |> updateRecord\n setSuccessMessage \"PageComment updated\"\n redirectTo EditPageCommentAction { .. }\n\n action CreatePageCommentAction = do\n let pageComment = newRecord @PageComment\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render NewView { .. } \n Right pageComment -> do\n pageComment <- pageComment |> createRecord\n setSuccessMessage \"PageComment created\"\n redirectTo PageCommentsAction\n\n action DeletePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n deleteRecord pageComment\n setSuccessMessage \"PageComment deleted\"\n redirectTo PageCommentsAction\n\nbuildPageComment pageComment = pageComment\n |> fill @'[]\n"} - , AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"} + , AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"} , AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PageCommentController\n = PageCommentsAction\n | NewPageCommentAction\n | ShowPageCommentAction { pageCommentId :: !(Id PageComment) }\n | CreatePageCommentAction\n | EditPageCommentAction { pageCommentId :: !(Id PageComment) }\n | UpdatePageCommentAction { pageCommentId :: !(Id PageComment) }\n | DeletePageCommentAction { pageCommentId :: !(Id PageComment) }\n deriving (Eq, Show, Data)\n"} , AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.PageComment"} , AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PageCommentController"}