mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-23 11:55:41 +03:00
Remove obsolete jest test suite.
This commit is contained in:
parent
b38bec802a
commit
b0ac40cb2e
6
examples/routing/package-lock.json
generated
6
examples/routing/package-lock.json
generated
@ -39,13 +39,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/jest": "^25.2.2",
|
||||
"@types/micromatch": "^4.0.1",
|
||||
"@types/node": "^12.7.7",
|
||||
"@types/serve-static": "^1.13.9",
|
||||
"elm-review": "^2.5.0",
|
||||
"elm-test": "^0.19.1-revision6",
|
||||
"elm-tooling": "^1.3.0",
|
||||
"jest": "^26.0.1",
|
||||
"mocha": "^8.3.2",
|
||||
"typescript": "^4.2.3"
|
||||
}
|
||||
@ -1489,9 +1488,9 @@
|
||||
"version": "file:../..",
|
||||
"requires": {
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/jest": "^25.2.2",
|
||||
"@types/micromatch": "^4.0.1",
|
||||
"@types/node": "^12.7.7",
|
||||
"@types/serve-static": "^1.13.9",
|
||||
"chokidar": "^3.5.1",
|
||||
"commander": "^7.2.0",
|
||||
"connect": "^3.7.0",
|
||||
@ -1503,7 +1502,6 @@
|
||||
"elm-tooling": "^1.3.0",
|
||||
"globby": "^11.0.3",
|
||||
"gray-matter": "^4.0.2",
|
||||
"jest": "^26.0.1",
|
||||
"kleur": "^3.0.3",
|
||||
"micromatch": "^4.0.2",
|
||||
"mocha": "^8.3.2",
|
||||
|
@ -1,769 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`generate UI file 1`] = `
|
||||
"port module Pages exposing (PathKey, allPages, allImages, internals, images, isValidRoute, pages, builtAt)
|
||||
|
||||
import Color exposing (Color)
|
||||
import Pages.Internal
|
||||
import Head
|
||||
import Html exposing (Html)
|
||||
import Json.Decode
|
||||
import Json.Encode
|
||||
import Pages.Platform
|
||||
import Pages.Manifest exposing (DisplayMode, Orientation)
|
||||
import Pages.Manifest.Category as Category exposing (Category)
|
||||
import Url.Parser as Url exposing ((</>), s)
|
||||
import Pages.ImagePath as ImagePath exposing (ImagePath)
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.Directory as Directory exposing (Directory)
|
||||
import Time
|
||||
|
||||
|
||||
builtAt : Time.Posix
|
||||
builtAt =
|
||||
Time.millisToPosix 1589734402000
|
||||
|
||||
|
||||
type PathKey
|
||||
= PathKey
|
||||
|
||||
|
||||
buildImage : List String -> ImagePath.Dimensions -> ImagePath PathKey
|
||||
buildImage path dimensions =
|
||||
ImagePath.build PathKey (\\"images\\" :: path) dimensions
|
||||
|
||||
|
||||
buildPage : List String -> PagePath PathKey
|
||||
buildPage path =
|
||||
PagePath.build PathKey path
|
||||
|
||||
|
||||
directoryWithIndex : List String -> Directory PathKey Directory.WithIndex
|
||||
directoryWithIndex path =
|
||||
Directory.withIndex PathKey allPages path
|
||||
|
||||
|
||||
directoryWithoutIndex : List String -> Directory PathKey Directory.WithoutIndex
|
||||
directoryWithoutIndex path =
|
||||
Directory.withoutIndex PathKey allPages path
|
||||
|
||||
|
||||
port toJsPort : Json.Encode.Value -> Cmd msg
|
||||
|
||||
port fromJsPort : (Json.Decode.Value -> msg) -> Sub msg
|
||||
|
||||
|
||||
internals : Pages.Internal.Internal PathKey
|
||||
internals =
|
||||
{ applicationType = Pages.Internal.Browser
|
||||
, toJsPort = toJsPort
|
||||
, fromJsPort = fromJsPort identity
|
||||
, content = content
|
||||
, pathKey = PathKey
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
allPages : List (PagePath PathKey)
|
||||
allPages =
|
||||
[
|
||||
]
|
||||
|
||||
pages =
|
||||
{ directory = directoryWithoutIndex []
|
||||
}
|
||||
|
||||
images =
|
||||
{ staticHttpError = (buildImage [ \\"static-http-error.png\\" ] { width = 919, height = 105 })
|
||||
, directory = directoryWithoutIndex []
|
||||
}
|
||||
|
||||
|
||||
allImages : List (ImagePath PathKey)
|
||||
allImages =
|
||||
[(buildImage [ \\"static-http-error.png\\" ] { width = 919, height = 105 })
|
||||
]
|
||||
|
||||
|
||||
isValidRoute : String -> Result String ()
|
||||
isValidRoute route =
|
||||
let
|
||||
validRoutes =
|
||||
List.map PagePath.toString allPages
|
||||
in
|
||||
if
|
||||
(route |> String.startsWith \\"http://\\")
|
||||
|| (route |> String.startsWith \\"https://\\")
|
||||
|| (route |> String.startsWith \\"#\\")
|
||||
|| (validRoutes |> List.member route)
|
||||
then
|
||||
Ok ()
|
||||
|
||||
else
|
||||
(\\"Valid routes:\\\\n\\"
|
||||
++ String.join \\"\\\\n\\\\n\\" validRoutes
|
||||
)
|
||||
|> Err
|
||||
|
||||
|
||||
content : List ( List String, { extension: String, frontMatter : String, body : Maybe String } )
|
||||
content =
|
||||
[
|
||||
]
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`generate template module connector 1`] = `
|
||||
"module TemplateModulesBeta exposing (..)
|
||||
|
||||
import Browser
|
||||
import Pages.Manifest as Manifest
|
||||
import Shared
|
||||
import TemplateType as M exposing (TemplateType)
|
||||
import Head
|
||||
import Html exposing (Html)
|
||||
import Pages
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.Platform
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Template.BlogIndex
|
||||
import Template.BlogPost
|
||||
import Template.Documentation
|
||||
import Template.Page
|
||||
import Template.Showcase
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ global : Shared.Model
|
||||
, page : TemplateModel
|
||||
, current :
|
||||
Maybe
|
||||
{ path :
|
||||
{ path : PagePath Pages.PathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
, metadata : TemplateType
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
type TemplateModel
|
||||
= ModelBlogIndex Template.BlogIndex.Model
|
||||
| ModelBlogPost Template.BlogPost.Model
|
||||
| ModelDocumentation Template.Documentation.Model
|
||||
| ModelPage Template.Page.Model
|
||||
| ModelShowcase Template.Showcase.Model
|
||||
|
||||
| NotFound
|
||||
|
||||
|
||||
|
||||
type Msg
|
||||
= MsgGlobal Shared.Msg
|
||||
| OnPageChange
|
||||
{ path : PagePath Pages.PathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
, metadata : TemplateType
|
||||
}
|
||||
| MsgBlogIndex Template.BlogIndex.Msg
|
||||
| MsgBlogPost Template.BlogPost.Msg
|
||||
| MsgDocumentation Template.Documentation.Msg
|
||||
| MsgPage Template.Page.Msg
|
||||
| MsgShowcase Template.Showcase.Msg
|
||||
|
||||
|
||||
|
||||
view :
|
||||
List ( PagePath Pages.PathKey, TemplateType )
|
||||
->
|
||||
{ path : PagePath Pages.PathKey
|
||||
, frontmatter : TemplateType
|
||||
}
|
||||
->
|
||||
StaticHttp.Request
|
||||
{ view : Model -> Shared.RenderedBody -> { title : String, body : Html Msg }
|
||||
, head : List (Head.Tag Pages.PathKey)
|
||||
}
|
||||
view siteMetadata page =
|
||||
case page.frontmatter of
|
||||
M.BlogIndex metadata ->
|
||||
StaticHttp.map2
|
||||
(\\\\data globalData ->
|
||||
{ view =
|
||||
\\\\model rendered ->
|
||||
case model.page of
|
||||
ModelBlogIndex subModel ->
|
||||
Template.BlogIndex.template.view
|
||||
subModel
|
||||
model.global
|
||||
siteMetadata
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
rendered
|
||||
|> (\\\\{ title, body } ->
|
||||
Shared.template.view
|
||||
globalData
|
||||
page
|
||||
model.global
|
||||
MsgGlobal
|
||||
({ title = title, body = body }
|
||||
|> Shared.template.map MsgBlogIndex
|
||||
)
|
||||
)
|
||||
|
||||
_ ->
|
||||
{ title = \\"\\", body = Html.text \\"\\" }
|
||||
, head = Template.BlogIndex.template.head
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
}
|
||||
)
|
||||
(Template.BlogIndex.template.staticData siteMetadata)
|
||||
(Shared.template.staticData siteMetadata)
|
||||
|
||||
|
||||
M.BlogPost metadata ->
|
||||
StaticHttp.map2
|
||||
(\\\\data globalData ->
|
||||
{ view =
|
||||
\\\\model rendered ->
|
||||
case model.page of
|
||||
ModelBlogPost subModel ->
|
||||
Template.BlogPost.template.view
|
||||
subModel
|
||||
model.global
|
||||
siteMetadata
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
rendered
|
||||
|> (\\\\{ title, body } ->
|
||||
Shared.template.view
|
||||
globalData
|
||||
page
|
||||
model.global
|
||||
MsgGlobal
|
||||
({ title = title, body = body }
|
||||
|> Shared.template.map MsgBlogPost
|
||||
)
|
||||
)
|
||||
|
||||
_ ->
|
||||
{ title = \\"\\", body = Html.text \\"\\" }
|
||||
, head = Template.BlogPost.template.head
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
}
|
||||
)
|
||||
(Template.BlogPost.template.staticData siteMetadata)
|
||||
(Shared.template.staticData siteMetadata)
|
||||
|
||||
|
||||
M.Documentation metadata ->
|
||||
StaticHttp.map2
|
||||
(\\\\data globalData ->
|
||||
{ view =
|
||||
\\\\model rendered ->
|
||||
case model.page of
|
||||
ModelDocumentation subModel ->
|
||||
Template.Documentation.template.view
|
||||
subModel
|
||||
model.global
|
||||
siteMetadata
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
rendered
|
||||
|> (\\\\{ title, body } ->
|
||||
Shared.template.view
|
||||
globalData
|
||||
page
|
||||
model.global
|
||||
MsgGlobal
|
||||
({ title = title, body = body }
|
||||
|> Shared.template.map MsgDocumentation
|
||||
)
|
||||
)
|
||||
|
||||
_ ->
|
||||
{ title = \\"\\", body = Html.text \\"\\" }
|
||||
, head = Template.Documentation.template.head
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
}
|
||||
)
|
||||
(Template.Documentation.template.staticData siteMetadata)
|
||||
(Shared.template.staticData siteMetadata)
|
||||
|
||||
|
||||
M.Page metadata ->
|
||||
StaticHttp.map2
|
||||
(\\\\data globalData ->
|
||||
{ view =
|
||||
\\\\model rendered ->
|
||||
case model.page of
|
||||
ModelPage subModel ->
|
||||
Template.Page.template.view
|
||||
subModel
|
||||
model.global
|
||||
siteMetadata
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
rendered
|
||||
|> (\\\\{ title, body } ->
|
||||
Shared.template.view
|
||||
globalData
|
||||
page
|
||||
model.global
|
||||
MsgGlobal
|
||||
({ title = title, body = body }
|
||||
|> Shared.template.map MsgPage
|
||||
)
|
||||
)
|
||||
|
||||
_ ->
|
||||
{ title = \\"\\", body = Html.text \\"\\" }
|
||||
, head = Template.Page.template.head
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
}
|
||||
)
|
||||
(Template.Page.template.staticData siteMetadata)
|
||||
(Shared.template.staticData siteMetadata)
|
||||
|
||||
|
||||
M.Showcase metadata ->
|
||||
StaticHttp.map2
|
||||
(\\\\data globalData ->
|
||||
{ view =
|
||||
\\\\model rendered ->
|
||||
case model.page of
|
||||
ModelShowcase subModel ->
|
||||
Template.Showcase.template.view
|
||||
subModel
|
||||
model.global
|
||||
siteMetadata
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
rendered
|
||||
|> (\\\\{ title, body } ->
|
||||
Shared.template.view
|
||||
globalData
|
||||
page
|
||||
model.global
|
||||
MsgGlobal
|
||||
({ title = title, body = body }
|
||||
|> Shared.template.map MsgShowcase
|
||||
)
|
||||
)
|
||||
|
||||
_ ->
|
||||
{ title = \\"\\", body = Html.text \\"\\" }
|
||||
, head = Template.Showcase.template.head
|
||||
{ static = data
|
||||
, sharedStatic = globalData
|
||||
, metadata = metadata
|
||||
, path = page.path
|
||||
}
|
||||
}
|
||||
)
|
||||
(Template.Showcase.template.staticData siteMetadata)
|
||||
(Shared.template.staticData siteMetadata)
|
||||
|
||||
|
||||
|
||||
init :
|
||||
Maybe Shared.Model
|
||||
->
|
||||
Maybe
|
||||
{ path :
|
||||
{ path : PagePath Pages.PathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
, metadata : TemplateType
|
||||
}
|
||||
-> ( Model, Cmd Msg )
|
||||
init currentGlobalModel maybePagePath =
|
||||
let
|
||||
( sharedModel, globalCmd ) =
|
||||
currentGlobalModel |> Maybe.map (\\\\m -> ( m, Cmd.none )) |> Maybe.withDefault (Shared.template.init maybePagePath)
|
||||
|
||||
( templateModel, templateCmd ) =
|
||||
case maybePagePath |> Maybe.map .metadata of
|
||||
Nothing ->
|
||||
( NotFound, Cmd.none )
|
||||
|
||||
Just meta ->
|
||||
case meta of
|
||||
M.BlogIndex metadata ->
|
||||
Template.BlogIndex.template.init metadata
|
||||
|> Tuple.mapBoth ModelBlogIndex (Cmd.map MsgBlogIndex)
|
||||
|
||||
|
||||
M.BlogPost metadata ->
|
||||
Template.BlogPost.template.init metadata
|
||||
|> Tuple.mapBoth ModelBlogPost (Cmd.map MsgBlogPost)
|
||||
|
||||
|
||||
M.Documentation metadata ->
|
||||
Template.Documentation.template.init metadata
|
||||
|> Tuple.mapBoth ModelDocumentation (Cmd.map MsgDocumentation)
|
||||
|
||||
|
||||
M.Page metadata ->
|
||||
Template.Page.template.init metadata
|
||||
|> Tuple.mapBoth ModelPage (Cmd.map MsgPage)
|
||||
|
||||
|
||||
M.Showcase metadata ->
|
||||
Template.Showcase.template.init metadata
|
||||
|> Tuple.mapBoth ModelShowcase (Cmd.map MsgShowcase)
|
||||
|
||||
|
||||
in
|
||||
( { global = sharedModel
|
||||
, page = templateModel
|
||||
, current = maybePagePath
|
||||
}
|
||||
, Cmd.batch
|
||||
[ templateCmd
|
||||
, globalCmd |> Cmd.map MsgGlobal
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
MsgGlobal msg_ ->
|
||||
let
|
||||
( sharedModel, globalCmd ) =
|
||||
Shared.template.update msg_ model.global
|
||||
in
|
||||
( { model | global = sharedModel }
|
||||
, globalCmd |> Cmd.map MsgGlobal
|
||||
)
|
||||
|
||||
OnPageChange record ->
|
||||
(init (Just model.global) <|
|
||||
Just
|
||||
{ path =
|
||||
{ path = record.path
|
||||
, query = record.query
|
||||
, fragment = record.fragment
|
||||
}
|
||||
, metadata = record.metadata
|
||||
}
|
||||
)
|
||||
|> (\\\\( updatedModel, cmd ) ->
|
||||
case Shared.template.onPageChange of
|
||||
Nothing ->
|
||||
( updatedModel, cmd )
|
||||
|
||||
Just thingy ->
|
||||
let
|
||||
( updatedGlobalModel, globalCmd ) =
|
||||
Shared.template.update
|
||||
(thingy
|
||||
{ path = record.path
|
||||
, query = record.query
|
||||
, fragment = record.fragment
|
||||
}
|
||||
)
|
||||
model.global
|
||||
in
|
||||
( { updatedModel
|
||||
| global = updatedGlobalModel
|
||||
}
|
||||
, Cmd.batch [ cmd, Cmd.map MsgGlobal globalCmd ]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
MsgBlogIndex msg_ ->
|
||||
let
|
||||
( updatedPageModel, pageCmd, ( newGlobalModel, newGlobalCmd ) ) =
|
||||
case ( model.page, model.current |> Maybe.map .metadata ) of
|
||||
( ModelBlogIndex pageModel, Just (M.BlogIndex metadata) ) ->
|
||||
Template.BlogIndex.template.update
|
||||
metadata
|
||||
msg_
|
||||
pageModel
|
||||
model.global
|
||||
|> mapBoth ModelBlogIndex (Cmd.map MsgBlogIndex)
|
||||
|> (\\\\( a, b, c ) ->
|
||||
case c of
|
||||
Just sharedMsg ->
|
||||
( a, b, Shared.template.update (Shared.SharedMsg sharedMsg) model.global )
|
||||
|
||||
Nothing ->
|
||||
( a, b, ( model.global, Cmd.none ) )
|
||||
)
|
||||
|
||||
_ ->
|
||||
( model.page, Cmd.none, ( model.global, Cmd.none ) )
|
||||
in
|
||||
( { model | page = updatedPageModel, global = newGlobalModel }
|
||||
, Cmd.batch [ pageCmd, newGlobalCmd |> Cmd.map MsgGlobal ]
|
||||
)
|
||||
|
||||
|
||||
MsgBlogPost msg_ ->
|
||||
let
|
||||
( updatedPageModel, pageCmd, ( newGlobalModel, newGlobalCmd ) ) =
|
||||
case ( model.page, model.current |> Maybe.map .metadata ) of
|
||||
( ModelBlogPost pageModel, Just (M.BlogPost metadata) ) ->
|
||||
Template.BlogPost.template.update
|
||||
metadata
|
||||
msg_
|
||||
pageModel
|
||||
model.global
|
||||
|> mapBoth ModelBlogPost (Cmd.map MsgBlogPost)
|
||||
|> (\\\\( a, b, c ) ->
|
||||
case c of
|
||||
Just sharedMsg ->
|
||||
( a, b, Shared.template.update (Shared.SharedMsg sharedMsg) model.global )
|
||||
|
||||
Nothing ->
|
||||
( a, b, ( model.global, Cmd.none ) )
|
||||
)
|
||||
|
||||
_ ->
|
||||
( model.page, Cmd.none, ( model.global, Cmd.none ) )
|
||||
in
|
||||
( { model | page = updatedPageModel, global = newGlobalModel }
|
||||
, Cmd.batch [ pageCmd, newGlobalCmd |> Cmd.map MsgGlobal ]
|
||||
)
|
||||
|
||||
|
||||
MsgDocumentation msg_ ->
|
||||
let
|
||||
( updatedPageModel, pageCmd, ( newGlobalModel, newGlobalCmd ) ) =
|
||||
case ( model.page, model.current |> Maybe.map .metadata ) of
|
||||
( ModelDocumentation pageModel, Just (M.Documentation metadata) ) ->
|
||||
Template.Documentation.template.update
|
||||
metadata
|
||||
msg_
|
||||
pageModel
|
||||
model.global
|
||||
|> mapBoth ModelDocumentation (Cmd.map MsgDocumentation)
|
||||
|> (\\\\( a, b, c ) ->
|
||||
case c of
|
||||
Just sharedMsg ->
|
||||
( a, b, Shared.template.update (Shared.SharedMsg sharedMsg) model.global )
|
||||
|
||||
Nothing ->
|
||||
( a, b, ( model.global, Cmd.none ) )
|
||||
)
|
||||
|
||||
_ ->
|
||||
( model.page, Cmd.none, ( model.global, Cmd.none ) )
|
||||
in
|
||||
( { model | page = updatedPageModel, global = newGlobalModel }
|
||||
, Cmd.batch [ pageCmd, newGlobalCmd |> Cmd.map MsgGlobal ]
|
||||
)
|
||||
|
||||
|
||||
MsgPage msg_ ->
|
||||
let
|
||||
( updatedPageModel, pageCmd, ( newGlobalModel, newGlobalCmd ) ) =
|
||||
case ( model.page, model.current |> Maybe.map .metadata ) of
|
||||
( ModelPage pageModel, Just (M.Page metadata) ) ->
|
||||
Template.Page.template.update
|
||||
metadata
|
||||
msg_
|
||||
pageModel
|
||||
model.global
|
||||
|> mapBoth ModelPage (Cmd.map MsgPage)
|
||||
|> (\\\\( a, b, c ) ->
|
||||
case c of
|
||||
Just sharedMsg ->
|
||||
( a, b, Shared.template.update (Shared.SharedMsg sharedMsg) model.global )
|
||||
|
||||
Nothing ->
|
||||
( a, b, ( model.global, Cmd.none ) )
|
||||
)
|
||||
|
||||
_ ->
|
||||
( model.page, Cmd.none, ( model.global, Cmd.none ) )
|
||||
in
|
||||
( { model | page = updatedPageModel, global = newGlobalModel }
|
||||
, Cmd.batch [ pageCmd, newGlobalCmd |> Cmd.map MsgGlobal ]
|
||||
)
|
||||
|
||||
|
||||
MsgShowcase msg_ ->
|
||||
let
|
||||
( updatedPageModel, pageCmd, ( newGlobalModel, newGlobalCmd ) ) =
|
||||
case ( model.page, model.current |> Maybe.map .metadata ) of
|
||||
( ModelShowcase pageModel, Just (M.Showcase metadata) ) ->
|
||||
Template.Showcase.template.update
|
||||
metadata
|
||||
msg_
|
||||
pageModel
|
||||
model.global
|
||||
|> mapBoth ModelShowcase (Cmd.map MsgShowcase)
|
||||
|> (\\\\( a, b, c ) ->
|
||||
case c of
|
||||
Just sharedMsg ->
|
||||
( a, b, Shared.template.update (Shared.SharedMsg sharedMsg) model.global )
|
||||
|
||||
Nothing ->
|
||||
( a, b, ( model.global, Cmd.none ) )
|
||||
)
|
||||
|
||||
_ ->
|
||||
( model.page, Cmd.none, ( model.global, Cmd.none ) )
|
||||
in
|
||||
( { model | page = updatedPageModel, global = newGlobalModel }
|
||||
, Cmd.batch [ pageCmd, newGlobalCmd |> Cmd.map MsgGlobal ]
|
||||
)
|
||||
|
||||
|
||||
|
||||
type alias SiteConfig =
|
||||
{ canonicalUrl : String
|
||||
, manifest : Manifest.Config Pages.PathKey
|
||||
}
|
||||
|
||||
templateSubscriptions : TemplateType -> PagePath Pages.PathKey -> Model -> Sub Msg
|
||||
templateSubscriptions metadata path model =
|
||||
case model.page of
|
||||
|
||||
ModelBlogIndex templateModel ->
|
||||
case metadata of
|
||||
M.BlogIndex templateMetadata ->
|
||||
Template.BlogIndex.template.subscriptions
|
||||
templateMetadata
|
||||
path
|
||||
templateModel
|
||||
model.global
|
||||
|> Sub.map MsgBlogIndex
|
||||
|
||||
_ ->
|
||||
Sub.none
|
||||
|
||||
|
||||
ModelBlogPost templateModel ->
|
||||
case metadata of
|
||||
M.BlogPost templateMetadata ->
|
||||
Template.BlogPost.template.subscriptions
|
||||
templateMetadata
|
||||
path
|
||||
templateModel
|
||||
model.global
|
||||
|> Sub.map MsgBlogPost
|
||||
|
||||
_ ->
|
||||
Sub.none
|
||||
|
||||
|
||||
ModelDocumentation templateModel ->
|
||||
case metadata of
|
||||
M.Documentation templateMetadata ->
|
||||
Template.Documentation.template.subscriptions
|
||||
templateMetadata
|
||||
path
|
||||
templateModel
|
||||
model.global
|
||||
|> Sub.map MsgDocumentation
|
||||
|
||||
_ ->
|
||||
Sub.none
|
||||
|
||||
|
||||
ModelPage templateModel ->
|
||||
case metadata of
|
||||
M.Page templateMetadata ->
|
||||
Template.Page.template.subscriptions
|
||||
templateMetadata
|
||||
path
|
||||
templateModel
|
||||
model.global
|
||||
|> Sub.map MsgPage
|
||||
|
||||
_ ->
|
||||
Sub.none
|
||||
|
||||
|
||||
ModelShowcase templateModel ->
|
||||
case metadata of
|
||||
M.Showcase templateMetadata ->
|
||||
Template.Showcase.template.subscriptions
|
||||
templateMetadata
|
||||
path
|
||||
templateModel
|
||||
model.global
|
||||
|> Sub.map MsgShowcase
|
||||
|
||||
_ ->
|
||||
Sub.none
|
||||
|
||||
|
||||
|
||||
NotFound ->
|
||||
Sub.none
|
||||
|
||||
|
||||
mainTemplate { documents, site } =
|
||||
Pages.Platform.init
|
||||
{ init = init Nothing
|
||||
, view = view
|
||||
, update = update
|
||||
, subscriptions =
|
||||
\\\\metadata path model ->
|
||||
Sub.batch
|
||||
[ Shared.template.subscriptions metadata path model.global |> Sub.map MsgGlobal
|
||||
, templateSubscriptions metadata path model
|
||||
]
|
||||
, documents = documents
|
||||
, onPageChange = Just OnPageChange
|
||||
, manifest = site.manifest
|
||||
, canonicalSiteUrl = site.canonicalUrl
|
||||
, internals = Pages.internals
|
||||
}
|
||||
|
||||
|
||||
|
||||
mapDocument : Browser.Document Never -> Browser.Document mapped
|
||||
mapDocument document =
|
||||
{ title = document.title
|
||||
, body = document.body |> List.map (Html.map never)
|
||||
}
|
||||
|
||||
|
||||
mapBoth fnA fnB ( a, b, c ) =
|
||||
( fnA a, fnB b, c )
|
||||
"
|
||||
`;
|
@ -1,18 +0,0 @@
|
||||
const { elmPagesCliFile, elmPagesUiFile } = require("../generator/src/elm-file-constants.js");
|
||||
const { generateTemplateModuleConnector } = require("../generator/src/generate-template-module-connector.js");
|
||||
const generateRecords = require("../generator/src/generate-records.js");
|
||||
|
||||
test('generate UI file', async () => {
|
||||
process.chdir(__dirname);
|
||||
const staticRoutes = await generateRecords();
|
||||
|
||||
global.builtAt = new Date("Sun, 17 May 2020 16:53:22 GMT");
|
||||
expect(elmPagesUiFile(staticRoutes, [])).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('generate template module connector', async () => {
|
||||
process.chdir(__dirname);
|
||||
const generated = await generateTemplateModuleConnector();
|
||||
|
||||
expect(generated).toMatchSnapshot();
|
||||
});
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
@ -1,190 +0,0 @@
|
||||
module Template.BlogPost exposing (Model, Msg, decoder, template)
|
||||
|
||||
import Data.Author as Author exposing (Author)
|
||||
import Date exposing (Date)
|
||||
import Element exposing (Element)
|
||||
import Element.Font as Font
|
||||
import Element.Region
|
||||
import Head
|
||||
import Head.Seo as Seo
|
||||
import Json.Decode as Decode
|
||||
import List.Extra
|
||||
import OptimizedDecoder as D
|
||||
import Pages
|
||||
import Pages.ImagePath as ImagePath exposing (ImagePath)
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Palette
|
||||
import Secrets
|
||||
import Site
|
||||
import StructuredData
|
||||
import Page
|
||||
import Page.Metadata exposing (BlogPost)
|
||||
import PageDocument exposing (TemplateDocument)
|
||||
import PageType
|
||||
|
||||
|
||||
type alias Model =
|
||||
()
|
||||
|
||||
|
||||
type alias Msg =
|
||||
Never
|
||||
|
||||
|
||||
template : TemplateDocument BlogPost Data Model Msg
|
||||
template =
|
||||
Template.withData staticData head
|
||||
|> Template.buildNoState { view = view }
|
||||
|
||||
|
||||
decoder : Decode.Decoder BlogPost
|
||||
decoder =
|
||||
Decode.map6 BlogPost
|
||||
(Decode.field "title" Decode.string)
|
||||
(Decode.field "description" Decode.string)
|
||||
(Decode.field "published"
|
||||
(Decode.string
|
||||
|> Decode.andThen
|
||||
(\isoString ->
|
||||
case Date.fromIsoString isoString of
|
||||
Ok date ->
|
||||
Decode.succeed date
|
||||
|
||||
Err error ->
|
||||
Decode.fail error
|
||||
)
|
||||
)
|
||||
)
|
||||
(Decode.field "author" Author.decoder)
|
||||
(Decode.field "image" imageDecoder)
|
||||
(Decode.field "draft" Decode.bool
|
||||
|> Decode.maybe
|
||||
|> Decode.map (Maybe.withDefault False)
|
||||
)
|
||||
|
||||
|
||||
imageDecoder : Decode.Decoder (ImagePath Pages.PathKey)
|
||||
imageDecoder =
|
||||
Decode.string
|
||||
|> Decode.andThen
|
||||
(\imageAssetPath ->
|
||||
case findMatchingImage imageAssetPath of
|
||||
Nothing ->
|
||||
Decode.fail "Couldn't find image."
|
||||
|
||||
Just imagePath ->
|
||||
Decode.succeed imagePath
|
||||
)
|
||||
|
||||
|
||||
findMatchingImage : String -> Maybe (ImagePath Pages.PathKey)
|
||||
findMatchingImage imageAssetPath =
|
||||
List.Extra.find
|
||||
(\image -> ImagePath.toString image == imageAssetPath)
|
||||
Pages.allImages
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
staticData : a -> StaticHttp.Request Data
|
||||
staticData siteMetadata =
|
||||
StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||
(D.field "stargazers_count" D.int)
|
||||
|
||||
|
||||
type alias Data =
|
||||
Int
|
||||
|
||||
|
||||
view : List ( PagePath, TemplateType.Metadata ) -> Data -> Model -> BlogPost -> ( a, List (Element msg) ) -> { title : String, body : Element msg }
|
||||
view allMetadata static model blogPost rendered =
|
||||
{ title = blogPost.title
|
||||
, body =
|
||||
Element.column [ Element.width Element.fill ]
|
||||
[ Element.column
|
||||
[ Element.padding 30
|
||||
, Element.spacing 40
|
||||
, Element.Region.mainContent
|
||||
, Element.width (Element.fill |> Element.maximum 800)
|
||||
, Element.centerX
|
||||
]
|
||||
(Element.column [ Element.spacing 10 ]
|
||||
[ Element.row [ Element.spacing 10 ]
|
||||
[ Author.view [] blogPost.author
|
||||
, Element.column [ Element.spacing 10, Element.width Element.fill ]
|
||||
[ Element.paragraph [ Font.bold, Font.size 24 ]
|
||||
[ Element.text blogPost.author.name
|
||||
]
|
||||
, Element.paragraph [ Font.size 16 ]
|
||||
[ Element.text blogPost.author.bio ]
|
||||
]
|
||||
]
|
||||
]
|
||||
:: (publishedDateView blogPost |> Element.el [ Font.size 16, Font.color (Element.rgba255 0 0 0 0.6) ])
|
||||
:: Palette.blogHeading blogPost.title
|
||||
:: articleImageView blogPost.image
|
||||
:: Tuple.second rendered
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
head : Data -> PagePath.PagePath -> BlogPost -> List (Head.Tag Pages.PathKey)
|
||||
head static currentPath meta =
|
||||
Head.structuredData
|
||||
(StructuredData.article
|
||||
{ title = meta.title
|
||||
, description = meta.description
|
||||
, author = StructuredData.person { name = meta.author.name }
|
||||
, publisher = StructuredData.person { name = "Dillon Kearns" }
|
||||
, url = Site.canonicalUrl ++ "/" ++ PagePath.toString currentPath
|
||||
, imageUrl = Site.canonicalUrl ++ "/" ++ ImagePath.toString meta.image
|
||||
, datePublished = Date.toIsoString meta.published
|
||||
, mainEntityOfPage =
|
||||
StructuredData.softwareSourceCode
|
||||
{ codeRepositoryUrl = "https://github.com/dillonkearns/elm-pages"
|
||||
, description = "A statically typed site generator for Elm."
|
||||
, author = "Dillon Kearns"
|
||||
, programmingLanguage = StructuredData.elmLang
|
||||
}
|
||||
}
|
||||
)
|
||||
:: (Seo.summaryLarge
|
||||
{ canonicalUrlOverride = Nothing
|
||||
, siteName = "elm-pages"
|
||||
, image =
|
||||
{ url = meta.image
|
||||
, alt = meta.description
|
||||
, dimensions = Nothing
|
||||
, mimeType = Nothing
|
||||
}
|
||||
, description = meta.description
|
||||
, locale = Nothing
|
||||
, title = meta.title
|
||||
}
|
||||
|> Seo.article
|
||||
{ tags = []
|
||||
, section = Nothing
|
||||
, publishedTime = Just (Date.toIsoString meta.published)
|
||||
, modifiedTime = Nothing
|
||||
, expirationTime = Nothing
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
publishedDateView : { a | published : Date.Date } -> Element msg
|
||||
publishedDateView metadata =
|
||||
Element.text
|
||||
(metadata.published
|
||||
|> Date.format "MMMM ddd, yyyy"
|
||||
)
|
||||
|
||||
|
||||
articleImageView : ImagePath Pages.PathKey -> Element msg
|
||||
articleImageView articleImage =
|
||||
Element.image [ Element.width Element.fill ]
|
||||
{ src = ImagePath.toString articleImage
|
||||
, description = "Article cover photo"
|
||||
}
|
@ -1 +0,0 @@
|
||||
module Main exposing (..)
|
@ -1 +0,0 @@
|
||||
module Main exposing (..)
|
185
jest.config.js
185
jest.config.js
@ -1,185 +0,0 @@
|
||||
// For a detailed explanation regarding each configuration property, visit:
|
||||
// https://jestjs.io/docs/en/configuration.html
|
||||
|
||||
module.exports = {
|
||||
// All imported modules in your tests should be mocked automatically
|
||||
// automock: false,
|
||||
|
||||
// Stop running tests after `n` failures
|
||||
// bail: 0,
|
||||
|
||||
// The directory where Jest should store its cached dependency information
|
||||
// cacheDirectory: "/private/var/folders/_7/hdfy_25n3cn736ryf5z2wzy40000gn/T/jest_dx",
|
||||
|
||||
// Automatically clear mock calls and instances between every test
|
||||
clearMocks: true,
|
||||
|
||||
// Indicates whether the coverage information should be collected while executing the test
|
||||
// collectCoverage: false,
|
||||
|
||||
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
||||
// collectCoverageFrom: undefined,
|
||||
|
||||
// The directory where Jest should output its coverage files
|
||||
// coverageDirectory: undefined,
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
// coveragePathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// A list of reporter names that Jest uses when writing coverage reports
|
||||
// coverageReporters: [
|
||||
// "json",
|
||||
// "text",
|
||||
// "lcov",
|
||||
// "clover"
|
||||
// ],
|
||||
|
||||
// An object that configures minimum threshold enforcement for coverage results
|
||||
// coverageThreshold: undefined,
|
||||
|
||||
// A path to a custom dependency extractor
|
||||
// dependencyExtractor: undefined,
|
||||
|
||||
// Make calling deprecated APIs throw helpful error messages
|
||||
// errorOnDeprecated: false,
|
||||
|
||||
// Force coverage collection from ignored files using an array of glob patterns
|
||||
// forceCoverageMatch: [],
|
||||
|
||||
// A path to a module which exports an async function that is triggered once before all test suites
|
||||
// globalSetup: undefined,
|
||||
|
||||
// A path to a module which exports an async function that is triggered once after all test suites
|
||||
// globalTeardown: undefined,
|
||||
|
||||
// A set of global variables that need to be available in all test environments
|
||||
// globals: {},
|
||||
|
||||
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
||||
// maxWorkers: "50%",
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
// moduleDirectories: [
|
||||
// "node_modules"
|
||||
// ],
|
||||
|
||||
// An array of file extensions your modules use
|
||||
// moduleFileExtensions: [
|
||||
// "js",
|
||||
// "json",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "tsx",
|
||||
// "node"
|
||||
// ],
|
||||
|
||||
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
||||
// moduleNameMapper: {},
|
||||
|
||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
||||
// modulePathIgnorePatterns: [],
|
||||
|
||||
// Activates notifications for test results
|
||||
// notify: false,
|
||||
|
||||
// An enum that specifies notification mode. Requires { notify: true }
|
||||
// notifyMode: "failure-change",
|
||||
|
||||
// A preset that is used as a base for Jest's configuration
|
||||
// preset: undefined,
|
||||
|
||||
// Run tests from one or more projects
|
||||
// projects: undefined,
|
||||
|
||||
// Use this configuration option to add custom reporters to Jest
|
||||
// reporters: undefined,
|
||||
|
||||
// Automatically reset mock state between every test
|
||||
// resetMocks: false,
|
||||
|
||||
// Reset the module registry before running each individual test
|
||||
// resetModules: false,
|
||||
|
||||
// A path to a custom resolver
|
||||
// resolver: undefined,
|
||||
|
||||
// Automatically restore mock state between every test
|
||||
// restoreMocks: false,
|
||||
|
||||
// The root directory that Jest should scan for tests and modules within
|
||||
// rootDir: undefined,
|
||||
|
||||
// A list of paths to directories that Jest should use to search for files in
|
||||
// roots: [
|
||||
// "<rootDir>"
|
||||
// ],
|
||||
|
||||
// Allows you to use a custom runner instead of Jest's default test runner
|
||||
// runner: "jest-runner",
|
||||
|
||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
||||
// setupFiles: [],
|
||||
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
||||
// setupFilesAfterEnv: [],
|
||||
|
||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: "node",
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
|
||||
// Adds a location field to test results
|
||||
// testLocationInResults: false,
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
// testMatch: [
|
||||
// "**/__tests__/**/*.[jt]s?(x)",
|
||||
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
// testPathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
|
||||
// This option allows the use of a custom results processor
|
||||
// testResultsProcessor: undefined,
|
||||
|
||||
// This option allows use of a custom test runner
|
||||
// testRunner: "jasmine2",
|
||||
|
||||
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
||||
// testURL: "http://localhost",
|
||||
|
||||
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
||||
// timers: "real",
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
// transform: undefined,
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
// transformIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
|
||||
// Indicates whether each individual test should be reported during the run
|
||||
// verbose: undefined,
|
||||
|
||||
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
||||
// watchPathIgnorePatterns: [],
|
||||
|
||||
// Whether to use watchman for file crawling
|
||||
// watchman: true,
|
||||
};
|
10068
package-lock.json
generated
10068
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/jest": "^25.2.2",
|
||||
"@types/micromatch": "^4.0.1",
|
||||
"@types/node": "^12.7.7",
|
||||
"@types/serve-static": "^1.13.9",
|
||||
"elm-review": "^2.5.0",
|
||||
"elm-test": "^0.19.1-revision6",
|
||||
"elm-tooling": "^1.3.0",
|
||||
"jest": "^26.0.1",
|
||||
"mocha": "^8.3.2",
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user