mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-21 10:41:39 +03:00
Address review errors.
This commit is contained in:
parent
3c5b171458
commit
43866be8d5
@ -83,7 +83,6 @@ So it's best to use that mental model to avoid confusion.
|
||||
|
||||
-}
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Pages.Internal.ApplicationType exposing (ApplicationType)
|
||||
import Pages.Internal.StaticHttpBody as Body
|
||||
import Pages.StaticHttp.Request as HashRequest
|
||||
|
@ -52,7 +52,6 @@ and describe your use case!
|
||||
-}
|
||||
|
||||
import DataSource exposing (DataSource)
|
||||
import Dict
|
||||
import Json.Decode
|
||||
import Json.Encode as Encode
|
||||
import Pages.Internal.StaticHttpBody as Body
|
||||
|
@ -266,43 +266,6 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
else
|
||||
True
|
||||
)
|
||||
|
||||
failedRequests : List BuildError
|
||||
failedRequests =
|
||||
staticResponses
|
||||
|> Dict.toList
|
||||
|> List.concatMap
|
||||
(\( path, NotFetched request _ ) ->
|
||||
let
|
||||
staticRequestsStatus : StaticHttpRequest.Status ()
|
||||
staticRequestsStatus =
|
||||
StaticHttpRequest.cacheRequestResolution
|
||||
ApplicationType.Cli
|
||||
request
|
||||
usableRawResponses
|
||||
|
||||
usableRawResponses : RequestsAndPending
|
||||
usableRawResponses =
|
||||
allRawResponses
|
||||
|
||||
maybePermanentError : Maybe StaticHttpRequest.Error
|
||||
maybePermanentError =
|
||||
case staticRequestsStatus of
|
||||
StaticHttpRequest.HasPermanentError theError ->
|
||||
Just theError
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
decoderErrors : List BuildError
|
||||
decoderErrors =
|
||||
maybePermanentError
|
||||
|> Maybe.map (StaticHttpRequest.toBuildError path)
|
||||
|> Maybe.map List.singleton
|
||||
|> Maybe.withDefault []
|
||||
in
|
||||
decoderErrors
|
||||
)
|
||||
in
|
||||
if pendingRequests then
|
||||
let
|
||||
@ -382,6 +345,49 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
-- )
|
||||
--
|
||||
-- Ok okSiteStaticData ->
|
||||
let
|
||||
allErrors : List BuildError
|
||||
allErrors =
|
||||
let
|
||||
failedRequests : List BuildError
|
||||
failedRequests =
|
||||
staticResponses
|
||||
|> Dict.toList
|
||||
|> List.concatMap
|
||||
(\( path, NotFetched request _ ) ->
|
||||
let
|
||||
staticRequestsStatus : StaticHttpRequest.Status ()
|
||||
staticRequestsStatus =
|
||||
StaticHttpRequest.cacheRequestResolution
|
||||
ApplicationType.Cli
|
||||
request
|
||||
usableRawResponses
|
||||
|
||||
usableRawResponses : RequestsAndPending
|
||||
usableRawResponses =
|
||||
allRawResponses
|
||||
|
||||
maybePermanentError : Maybe StaticHttpRequest.Error
|
||||
maybePermanentError =
|
||||
case staticRequestsStatus of
|
||||
StaticHttpRequest.HasPermanentError theError ->
|
||||
Just theError
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
decoderErrors : List BuildError
|
||||
decoderErrors =
|
||||
maybePermanentError
|
||||
|> Maybe.map (StaticHttpRequest.toBuildError path)
|
||||
|> Maybe.map List.singleton
|
||||
|> Maybe.withDefault []
|
||||
in
|
||||
decoderErrors
|
||||
)
|
||||
|
||||
generatedFileErrors : List BuildError
|
||||
generatedFileErrors =
|
||||
let
|
||||
generatedFiles : List (Result String { path : List String, content : String })
|
||||
generatedFiles =
|
||||
@ -392,13 +398,7 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
(buildTimeFilesRequest config)
|
||||
(allRawResponses |> Dict.Extra.filterMap (\_ value -> Just value))
|
||||
|
||||
allErrors : List BuildError
|
||||
allErrors =
|
||||
errors ++ failedRequests ++ generatedFileErrors
|
||||
|
||||
generatedFileErrors : List BuildError
|
||||
generatedFileErrors =
|
||||
in
|
||||
generatedFiles
|
||||
|> List.filterMap
|
||||
(\result ->
|
||||
@ -418,6 +418,8 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
}
|
||||
)
|
||||
in
|
||||
errors ++ failedRequests ++ generatedFileErrors
|
||||
in
|
||||
( model.staticResponses
|
||||
, case encode allRawResponses staticResponses of
|
||||
Ok encodedResponses ->
|
||||
@ -462,6 +464,44 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
)
|
||||
|
||||
Err error_ ->
|
||||
let
|
||||
failedRequests : List BuildError
|
||||
failedRequests =
|
||||
staticResponses
|
||||
|> Dict.toList
|
||||
|> List.concatMap
|
||||
(\( path, NotFetched request _ ) ->
|
||||
let
|
||||
staticRequestsStatus : StaticHttpRequest.Status ()
|
||||
staticRequestsStatus =
|
||||
StaticHttpRequest.cacheRequestResolution
|
||||
ApplicationType.Cli
|
||||
request
|
||||
usableRawResponses
|
||||
|
||||
usableRawResponses : RequestsAndPending
|
||||
usableRawResponses =
|
||||
allRawResponses
|
||||
|
||||
maybePermanentError : Maybe StaticHttpRequest.Error
|
||||
maybePermanentError =
|
||||
case staticRequestsStatus of
|
||||
StaticHttpRequest.HasPermanentError theError ->
|
||||
Just theError
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
decoderErrors : List BuildError
|
||||
decoderErrors =
|
||||
maybePermanentError
|
||||
|> Maybe.map (StaticHttpRequest.toBuildError path)
|
||||
|> Maybe.map List.singleton
|
||||
|> Maybe.withDefault []
|
||||
in
|
||||
decoderErrors
|
||||
)
|
||||
in
|
||||
( model.staticResponses
|
||||
, Finish
|
||||
(Errors <|
|
||||
|
Loading…
Reference in New Issue
Block a user