Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions cli/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"direct": {
"MaybeJustJames/yaml": "2.1.7",
"dillonkearns/elm-cli-options-parser": "4.0.0",
"dillonkearns/elm-pages": "11.0.0",
"dillonkearns/elm-pages": "12.0.2",
"elm/bytes": "1.0.8",
"elm/core": "1.0.5",
"elm/json": "1.1.4",
Expand All @@ -19,7 +19,7 @@
"json-tools/json-schema": "1.0.2",
"json-tools/json-value": "1.0.1",
"mdgriffith/elm-codegen": "6.0.1",
"miniBill/elm-fast-dict": "1.2.4",
"miniBill/elm-fast-dict": "1.2.5",
"robinheghan/murmur3": "1.0.0",
"the-sett/elm-pretty-printer": "3.3.0",
"wolfadex/elm-ansi": "3.0.1",
Expand All @@ -29,7 +29,6 @@
"Chadtech/elm-bool-extra": "2.4.2",
"NoRedInk/elm-json-decode-pipeline": "1.0.1",
"avh4/elm-color": "1.0.0",
"danfishgold/base64-bytes": "1.1.0",
"danyx23/elm-mimetype": "4.0.1",
"dillonkearns/elm-bcp47-language-tag": "2.0.0",
"dillonkearns/elm-date-or-date-time": "2.0.0",
Expand Down
68 changes: 9 additions & 59 deletions cli/src/Cli.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import Ansi
import Ansi.Color
import Ansi.Font
import BackendTask exposing (BackendTask)
import BackendTask.Custom
import BackendTask.Env
import BackendTask.Extra
import BackendTask.File
import BackendTask.Http
Expand Down Expand Up @@ -398,25 +396,16 @@ parseCliOptions cliOptions =


type alias Step a =
( Pages.Script.Spinner.Steps FatalError a
, BackendTask FatalError a
)
Pages.Script.Spinner.Steps FatalError a


withStep :
String
-> (a -> BackendTask FatalError b)
-> Step a
-> Step b
withStep label toTask ( steps, task ) =
( Pages.Script.Spinner.withStep label toTask steps
, task
|> BackendTask.andThen
(\input ->
Pages.Script.log label
|> BackendTask.andThen (\() -> toTask input)
)
)
withStep label toTask steps =
Pages.Script.Spinner.withStep label toTask steps


withInnerStep :
Expand All @@ -426,7 +415,7 @@ withInnerStep :
-> (a -> BackendTask FatalError b)
-> Step ( a, c, d )
-> Step ( b, c, d )
withInnerStep index total label toTask ( steps, task ) =
withInnerStep index total label toTask steps =
let
fullLabel : String
fullLabel =
Expand All @@ -436,16 +425,9 @@ withInnerStep index total label toTask ( steps, task ) =
combinedTask ( input, acc1, acc2 ) =
toTask input |> BackendTask.map (\result -> ( result, acc1, acc2 ))
in
( Pages.Script.Spinner.withStep fullLabel
Pages.Script.Spinner.withStep fullLabel
combinedTask
steps
, task
|> BackendTask.andThen
(\( input, acc1, acc2 ) ->
Pages.Script.log fullLabel
|> BackendTask.andThen (\() -> combinedTask ( input, acc1, acc2 ))
)
)


withConfig : OpenApi.Config.Config -> BackendTask FatalError ()
Expand Down Expand Up @@ -527,10 +509,8 @@ withConfig config =
)
)
( 1
, ( Pages.Script.Spinner.steps
|> Pages.Script.Spinner.withStep "Collecting configuration" (\_ -> BackendTask.succeed ( (), [], [] ))
, Pages.Script.log "Collecting configuration" |> BackendTask.map (\() -> ( (), [], [] ))
)
, Pages.Script.Spinner.steps
|> Pages.Script.Spinner.withStep "Collecting configuration" (\_ -> BackendTask.succeed ( (), [], [] ))
)
(OpenApi.Config.inputs config)
|> Tuple.second
Expand All @@ -546,31 +526,11 @@ withConfig config =
withStep "Format with elm-format" (onFirst attemptToFormat)
)
|> withStep "Write to disk" (onFirst (writeSdkToDisk (OpenApi.Config.outputDirectory config)))
|> (\( steps, task ) ->
terminalInfo
|> BackendTask.andThen
(\{ isTTY, noColor } ->
if isTTY && not noColor then
Pages.Script.Spinner.runSteps steps

else
task
)
)
|> Pages.Script.Spinner.runSteps
|> BackendTask.map convertElmCodegenWarnings
|> BackendTask.andThen printSuccessMessageAndWarnings


terminalInfo : BackendTask FatalError { isTTY : Bool, noColor : Bool }
terminalInfo =
BackendTask.map2 (\isTTY noColor -> { isTTY = isTTY, noColor = noColor })
(BackendTask.Custom.run "isTTY" Json.Encode.null Json.Decode.bool
|> BackendTask.allowFatal
|> BackendTask.quiet
)
(BackendTask.Env.get "NO_COLOR" |> BackendTask.map (\nc -> nc /= Nothing && nc /= Just ""))


convertElmCodegenWarnings :
( List ( String, List { declaration : String, warning : String } )
, { warnings : List OpenApi.Generate.Message, requiredPackages : FastSet.Set String }
Expand Down Expand Up @@ -806,17 +766,7 @@ convertToSwaggerAndThenDecode config input value =
parseOriginal input swagger
|> BackendTask.andThen mergeOverrides
)
|> (\task ->
terminalInfo
|> BackendTask.andThen
(\{ isTTY, noColor } ->
if isTTY && not noColor then
Pages.Script.Spinner.runTask "Convert Swagger to Open API" task

else
task
)
)
|> Pages.Script.Spinner.runTask "Convert Swagger to Open API"
|> BackendTask.andThen (\converted -> decodeOpenApiSpecOrFail { hasAttemptedToConvertFromSwagger = True } config input converted)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"elm-codegen": "^0.6.3",
"elm-format": "0.8.7",
"elm-optimize-level-2": "0.3.5",
"elm-pages": "^3.1.1",
"elm-pages": "^3.2.0",
"elm-review": "^2.13.5",
"elm-test": "^0.19.1-revision17",
"lamdera": "^0.19.1-1.4.0",
Expand Down