Simplify scaffolding script.

This commit is contained in:
Dillon Kearns 2023-02-06 14:23:04 -08:00
parent 57a3ecf13f
commit 8887770ecb
2 changed files with 15 additions and 16 deletions

View File

@ -31,7 +31,7 @@ import Pages.Script as Script exposing (Script)
type alias CliOptions =
{ moduleName : List String
, rest : List ( String, AddFormHelp.Kind )
, fields : List ( String, AddFormHelp.Kind )
}
@ -39,15 +39,9 @@ run : Script
run =
Script.withCliOptions program
(\cliOptions ->
let
file : Elm.File
file =
createFile cliOptions.moduleName cliOptions.rest
in
Script.writeFile
{ path = "app/" ++ file.path
, body = file.contents
}
cliOptions
|> createFile
|> Script.writeFile
|> BackendTask.allowFatal
)
@ -62,8 +56,8 @@ program =
)
createFile : List String -> List ( String, AddFormHelp.Kind ) -> Elm.File
createFile moduleName fields =
createFile : CliOptions -> { path : String, body : String }
createFile { moduleName, fields } =
let
formHelpers :
Maybe

View File

@ -164,7 +164,7 @@ buildNoState :
{ view : { maybeUrl : Elm.Expression, sharedModel : Elm.Expression, app : Elm.Expression } -> Elm.Expression
}
-> Builder
-> Elm.File
-> { path : String, body : String }
buildNoState definitions builder_ =
case builder_ of
ServerRender declarations builder ->
@ -256,7 +256,7 @@ buildWithLocalState :
, model : Type
}
-> Builder
-> Elm.File
-> { path : String, body : String }
buildWithLocalState definitions builder_ =
case builder_ of
ServerRender declarations builder ->
@ -395,7 +395,7 @@ buildWithSharedState :
, model : Type
}
-> Builder
-> Elm.File
-> { path : String, body : String }
buildWithSharedState definitions builder_ =
case builder_ of
ServerRender declarations builder ->
@ -532,7 +532,7 @@ userFunction :
, types : { model : Type, msg : Type, data : Type, actionData : Type }
, declarations : List Elm.Declaration
}
-> Elm.File
-> { path : String, body : String }
userFunction moduleName definitions =
let
viewFn :
@ -858,6 +858,11 @@ userFunction moduleName definitions =
)
++ definitions.declarations
)
|> (\{ path, contents } ->
{ path = "app/" ++ path
, body = contents
}
)
localType : String -> Elm.Annotation.Annotation