mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 03:11:30 +03:00
Simplify scaffolding script.
This commit is contained in:
parent
57a3ecf13f
commit
8887770ecb
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user