From e7b957bc7fc16e54b0eb4dbc259664107cfe11aa Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Sat, 22 Jul 2023 23:53:59 +0200 Subject: [PATCH 1/7] Fix a bug in layouts with props using type variables If the project has a layout with props using type variables, there's an error in the code generation that throws: ``` Props type needs 1 argument, but I see 0 instead: in .elm-land/src/Layouts.elm ``` This commit updates the array of layout paths sent to the code generator, including a boolean variable indicating if the layout uses Props with type variables. In such case, the code generator creates valid code for that layout, avoiding the current error. --- .../cli/src/codegen/src/Commands/Generate.elm | 2 +- projects/cli/src/codegen/src/LayoutFile.elm | 41 +++++++++++-------- projects/cli/src/effects.js | 13 ++++-- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/projects/cli/src/codegen/src/Commands/Generate.elm b/projects/cli/src/codegen/src/Commands/Generate.elm index 113a9076..a78a99be 100644 --- a/projects/cli/src/codegen/src/Commands/Generate.elm +++ b/projects/cli/src/codegen/src/Commands/Generate.elm @@ -1396,7 +1396,7 @@ toViewCaseExpression layouts = let settings : String settings = - if original == current then + if original == current || isTopLevel == False then "settings" else diff --git a/projects/cli/src/codegen/src/LayoutFile.elm b/projects/cli/src/codegen/src/LayoutFile.elm index 95fb8b2c..a9ea063c 100644 --- a/projects/cli/src/codegen/src/LayoutFile.elm +++ b/projects/cli/src/codegen/src/LayoutFile.elm @@ -42,24 +42,23 @@ import Json.Decode {-| Represents an item in the "src/Layouts" folder -} type LayoutFile - = LayoutFile - { filepath : List String - , isUsingTypeVariable : Bool - } + = LayoutFile LayoutFileData + + +type alias LayoutFileData = + { filepath : List String + , isUsingTypeVariable : Bool + } {-| Attempts to convert a raw JSON array of strings into a `LayoutFile` -} decoder : Json.Decode.Decoder LayoutFile decoder = - Json.Decode.map - (\filepath -> - LayoutFile - { filepath = filepath - , isUsingTypeVariable = False --|> Debug.log "TODO: Learn if parent is using type variable" - } - ) - (Json.Decode.list Json.Decode.string) + Json.Decode.map LayoutFile <| + Json.Decode.map2 LayoutFileData + (Json.Decode.field "segments" <| Json.Decode.list Json.Decode.string) + (Json.Decode.field "isUsingTypeVariable" Json.Decode.bool) sortByFilepath : List LayoutFile -> List LayoutFile @@ -122,10 +121,16 @@ toLayoutTypeDeclaration layouts = else let toLayoutVariant : LayoutFile -> ( String, List CodeGen.Annotation ) - toLayoutVariant (LayoutFile { filepath }) = - ( String.join "_" filepath - , [ CodeGen.Annotation.type_ ("Layouts." ++ String.join "." filepath ++ ".Props") ] - ) + toLayoutVariant (LayoutFile { filepath, isUsingTypeVariable }) = + if isUsingTypeVariable then + ( String.join "_" filepath + , [ CodeGen.Annotation.type_ ("(Layouts." ++ String.join "." filepath ++ ".Props msg)") ] + ) + + else + ( String.join "_" filepath + , [ CodeGen.Annotation.type_ ("Layouts." ++ String.join "." filepath ++ ".Props") ] + ) in CodeGen.Declaration.customType { name = "Layout msg" @@ -149,7 +154,9 @@ toMapFunction layouts = if isUsingTypeVariable then { name = String.join "_" filepath , arguments = [ CodeGen.Argument.new "data" ] - , expression = CodeGen.Expression.value (String.join "_" filepath ++ " data") + , expression = + CodeGen.Expression.value + (String.join "_" filepath ++ " (Layouts." ++ String.join "." filepath ++ ".map" ++ " fn " ++ " data)") } else diff --git a/projects/cli/src/effects.js b/projects/cli/src/effects.js index 27f584bb..8f5c79a4 100644 --- a/projects/cli/src/effects.js +++ b/projects/cli/src/effects.js @@ -240,12 +240,19 @@ let generateElmFiles = async (config, server = undefined) => { server.ws.send('elm:success', { msg: 'Success!' }) } - let layoutFilepathSegments = - layoutFilepaths.map(filepath => filepath.split('/')) + let layoutsData = layouts.map(({ filepath, contents}) => { + const typeVariablePattern = 'type alias Props contentMsg'; + const isUsingTypeVariable = contents.includes(typeVariablePattern); + + return { + segments: filepath, + isUsingTypeVariable + } + }) let newFiles = await Codegen.generateElmLandFiles({ pages, - layouts: layoutFilepathSegments, + layouts: layoutsData, router }) From 704c46ef632edb25325aa369659782ddbff51faa Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Sun, 23 Jul 2023 00:01:01 +0200 Subject: [PATCH 2/7] Rename all `settings` variables in `.elm-land/src/Main.elm` to props --- .../cli/src/codegen/src/Commands/Generate.elm | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/projects/cli/src/codegen/src/Commands/Generate.elm b/projects/cli/src/codegen/src/Commands/Generate.elm index a78a99be..dcc46564 100644 --- a/projects/cli/src/codegen/src/Commands/Generate.elm +++ b/projects/cli/src/codegen/src/Commands/Generate.elm @@ -846,7 +846,7 @@ toLayoutUrlHookCmd layouts = toBranch : LayoutFile -> CodeGen.Expression.Branch toBranch layout = { name = - "( Just (Layouts.{{name}} settings), Just (Main.Layouts.Model.{{name}} layoutModel) )" + "( Just (Layouts.{{name}} props), Just (Main.Layouts.Model.{{name}} layoutModel) )" |> String.replace "{{name}}" (LayoutFile.toVariantName layout) , arguments = [] @@ -1382,7 +1382,7 @@ toViewCaseExpression layouts = LayoutFile.toListOfSelfAndParents layout in { name = - "( Just (Layouts.{{name}} settings), Just (Main.Layouts.Model.{{name}} layoutModel) )" + "( Just (Layouts.{{name}} props), Just (Main.Layouts.Model.{{name}} layoutModel) )" |> String.replace "{{name}}" (LayoutFile.toVariantName layout) , arguments = [] , expression = toViewBranchExpression True layout selfAndParentLayouts @@ -1394,10 +1394,10 @@ toViewCaseExpression layouts = toNestedLayoutExpression : LayoutFile -> List LayoutFile -> CodeGen.Expression toNestedLayoutExpression current parents = let - settings : String - settings = + props : String + props = if original == current || isTopLevel == False then - "settings" + "props" else toLayoutPropsVariableName current @@ -1409,8 +1409,8 @@ toViewCaseExpression layouts = [ CodeGen.Expression.function { name = LayoutFile.toModuleName current ++ ".layout" , arguments = - [ "{{settings}} model.shared route" - |> String.replace "{{settings}}" settings + [ "{{props}} model.shared route" + |> String.replace "{{props}}" props |> CodeGen.Expression.value ] } @@ -1783,7 +1783,7 @@ toUpdateLayoutCaseExpression layouts = } in { name = - "( Just (Layouts.{{name}} settings), Just (Main.Layouts.Model.{{name}} layoutModel), Main.Layouts.Msg.{{layoutSendingMsg}} layoutMsg )" + "( Just (Layouts.{{name}} props), Just (Main.Layouts.Model.{{name}} layoutModel), Main.Layouts.Msg.{{layoutSendingMsg}} layoutMsg )" |> String.replace "{{name}}" (LayoutFile.toVariantName layoutOptions.currentLayout) |> String.replace "{{layoutSendingMsg}}" (LayoutFile.toVariantName layoutOptions.layoutSendingMsg) , arguments = [] @@ -1877,7 +1877,7 @@ a child layout of the layout sending a message: == [ { parent = Sidebar, child = Sidebar.Header } ] -Used with `let` expressions to define the settings for a layout within an update function +Used with `let` expressions to define the props for a layout within an update function -} toParentsBetween : @@ -1907,19 +1907,19 @@ toParentsBetween options = ) -{-| Example: Layouts.Sidebar.layout settings model.shared route +{-| Example: Layouts.Sidebar.layout props model.shared route -} callLayoutFunction : Maybe LayoutFile -> LayoutFile -> CodeGen.Expression callLayoutFunction maybeParent layout = - "{{moduleName}}.layout {{settings}} model.shared route" + "{{moduleName}}.layout {{props}} model.shared route" |> String.replace "{{moduleName}}" (LayoutFile.toModuleName layout) - |> String.replace "{{settings}}" + |> String.replace "{{props}}" (case maybeParent of Just parent -> toLayoutPropsVariableName parent Nothing -> - "settings" + "props" ) |> CodeGen.Expression.value @@ -2007,7 +2007,7 @@ toSubscriptionLayoutCaseExpression layouts = toBranch : LayoutFile -> CodeGen.Expression.Branch toBranch layout = { name = - "( Just (Layouts.{{name}} settings), Just (Main.Layouts.Model.{{name}} layoutModel) )" + "( Just (Layouts.{{name}} props), Just (Main.Layouts.Model.{{name}} layoutModel) )" |> String.replace "{{name}}" (LayoutFile.toVariantName layout) , arguments = [] @@ -2103,11 +2103,11 @@ toParentLayoutProps { self, child, parent } = , annotation = Nothing , expression = CodeGen.Expression.pipeline - [ "{{moduleName}}.layout {{settings}} model.shared route" + [ "{{moduleName}}.layout {{props}} model.shared route" |> String.replace "{{moduleName}}" (LayoutFile.toModuleName child) - |> String.replace "{{settings}}" + |> String.replace "{{props}}" (if self == child then - "settings" + "props" else toLayoutPropsVariableName child From b761298b203a78144e853df7b0abe63989791791 Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Wed, 23 Aug 2023 16:40:33 +0200 Subject: [PATCH 3/7] Include example for layout props using type variables --- examples/17-layout-props-types/elm-land.json | 28 ++++++ examples/17-layout-props-types/elm.json | 25 +++++ .../src/Layouts/Sidebar.elm | 97 +++++++++++++++++++ .../src/Layouts/Sidebar/Header.elm | 94 ++++++++++++++++++ .../17-layout-props-types/src/Pages/Home_.elm | 90 +++++++++++++++++ .../17-layout-props-types/static/main.css | 30 ++++++ 6 files changed, 364 insertions(+) create mode 100644 examples/17-layout-props-types/elm-land.json create mode 100644 examples/17-layout-props-types/elm.json create mode 100644 examples/17-layout-props-types/src/Layouts/Sidebar.elm create mode 100644 examples/17-layout-props-types/src/Layouts/Sidebar/Header.elm create mode 100644 examples/17-layout-props-types/src/Pages/Home_.elm create mode 100644 examples/17-layout-props-types/static/main.css diff --git a/examples/17-layout-props-types/elm-land.json b/examples/17-layout-props-types/elm-land.json new file mode 100644 index 00000000..999fb98a --- /dev/null +++ b/examples/17-layout-props-types/elm-land.json @@ -0,0 +1,28 @@ +{ + "app": { + "elm": { + "development": { "debugger": true }, + "production": { "debugger": false } + }, + "env": [], + "html": { + "attributes": { + "html": { "lang": "en" }, + "head": {} + }, + "title": "Elm Land", + "meta": [ + { "charset": "UTF-8" }, + { "http-equiv": "X-UA-Compatible", "content": "IE=edge" }, + { "name": "viewport", "content": "width=device-width, initial-scale=1.0" } + ], + "link": [ + { "rel": "stylesheet", "href": "/main.css" } + ], + "script": [] + }, + "router": { + "useHashRouting": false + } + } +} \ No newline at end of file diff --git a/examples/17-layout-props-types/elm.json b/examples/17-layout-props-types/elm.json new file mode 100644 index 00000000..5868b5e1 --- /dev/null +++ b/examples/17-layout-props-types/elm.json @@ -0,0 +1,25 @@ +{ + "type": "application", + "source-directories": [ + "src", + ".elm-land/src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/browser": "1.0.2", + "elm/core": "1.0.5", + "elm/html": "1.0.0", + "elm/json": "1.1.3", + "elm/url": "1.0.0" + }, + "indirect": { + "elm/time": "1.0.0", + "elm/virtual-dom": "1.0.3" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} + } +} diff --git a/examples/17-layout-props-types/src/Layouts/Sidebar.elm b/examples/17-layout-props-types/src/Layouts/Sidebar.elm new file mode 100644 index 00000000..32f25d25 --- /dev/null +++ b/examples/17-layout-props-types/src/Layouts/Sidebar.elm @@ -0,0 +1,97 @@ +module Layouts.Sidebar exposing (Model, Msg, Props, layout) + +import Effect exposing (Effect) +import Html exposing (Html) +import Html.Attributes exposing (class, style) +import Html.Events +import Layout exposing (Layout) +import Route exposing (Route) +import Route.Path +import Shared +import View exposing (View) + + +type alias Props = + {} + + +layout : Props -> Shared.Model -> Route () -> Layout () Model Msg contentMsg +layout props shared route = + Layout.new + { init = init + , update = update + , view = view + , subscriptions = subscriptions + } + + + +-- MODEL + + +type alias Model = + {} + + +init : () -> ( Model, Effect Msg ) +init _ = + ( {}, Effect.none ) + + + +-- UPDATE + + +type Msg + = NoOp + + +update : Msg -> Model -> ( Model, Effect Msg ) +update msg model = + ( model, Effect.none ) + + +subscriptions : Model -> Sub Msg +subscriptions model = + Sub.none + + + +-- VIEW + + +view : { toContentMsg : Msg -> contentMsg, content : View contentMsg, model : Model } -> View contentMsg +view { toContentMsg, model, content } = + { title = content.title ++ " | MyCoolApp" + , body = + [ Html.div [ style "display" "flex", style "height" "100%" ] + [ Html.aside [ class "sidebar" ] + [ Html.div + [ style "display" "flex" + , style "flex-direction" "column" + , style "gap" "2rem" + ] + [ Html.strong [ style "font-size" "1.5rem" ] + [ Html.text "🌈 MyCoolApp" ] + , Html.div + [ style "display" "flex" + , style "flex-direction" "column" + , style "gap" "1rem" + ] + (List.map viewSidebarLink + [ ( "Dashboard", Route.Path.Home_ ) + ] + ) + ] + ] + , Html.main_ [ style "flex" "1 1 auto" ] content.body + ] + ] + } + + +viewSidebarLink : ( String, Route.Path.Path ) -> Html msg +viewSidebarLink ( label, routePath ) = + Html.a + [ Route.Path.href routePath ] + [ Html.text label ] diff --git a/examples/17-layout-props-types/src/Layouts/Sidebar/Header.elm b/examples/17-layout-props-types/src/Layouts/Sidebar/Header.elm new file mode 100644 index 00000000..6e00759a --- /dev/null +++ b/examples/17-layout-props-types/src/Layouts/Sidebar/Header.elm @@ -0,0 +1,94 @@ +module Layouts.Sidebar.Header exposing (Model, Msg, Props, layout, map) + +import Effect exposing (Effect) +import Html exposing (Html) +import Html.Attributes exposing (..) +import Layout exposing (Layout) +import Layouts.Sidebar +import Route exposing (Route) +import Shared +import View exposing (View) + + +type alias Props contentMsg = + { title : String + , shouldPadContent : Bool + , button : Html contentMsg + } + + +map : (msg1 -> msg2) -> Props msg1 -> Props msg2 +map fn props = + { title = props.title + , shouldPadContent = props.shouldPadContent + , button = Html.map fn props.button + } + + +layout : Props contentMsg -> Shared.Model -> Route () -> Layout Layouts.Sidebar.Props Model Msg contentMsg +layout props shared route = + Layout.new + { init = init + , update = update + , view = view props + , subscriptions = subscriptions + } + |> Layout.withParentProps {} + + + +-- MODEL + + +type alias Model = + {} + + +init : () -> ( Model, Effect Msg ) +init _ = + ( {} + , Effect.none + ) + + + +-- UPDATE + + +type Msg + = ReplaceMe + + +update : Msg -> Model -> ( Model, Effect Msg ) +update msg model = + case msg of + ReplaceMe -> + ( model + , Effect.none + ) + + +subscriptions : Model -> Sub Msg +subscriptions model = + Sub.none + + + +-- VIEW + + +view : Props contentMsg -> { toContentMsg : Msg -> contentMsg, content : View contentMsg, model : Model } -> View contentMsg +view props { toContentMsg, model, content } = + { title = content.title + , body = + [ Html.header [] + [ Html.text props.title + , props.button + ] + , Html.div + [ class "page" + , classList [ ( "pad-16", props.shouldPadContent ) ] + ] + content.body + ] + } diff --git a/examples/17-layout-props-types/src/Pages/Home_.elm b/examples/17-layout-props-types/src/Pages/Home_.elm new file mode 100644 index 00000000..848c7a32 --- /dev/null +++ b/examples/17-layout-props-types/src/Pages/Home_.elm @@ -0,0 +1,90 @@ +module Pages.Home_ exposing (Model, Msg, page) + +import Effect exposing (Effect) +import Html +import Html.Attributes exposing (class) +import Html.Events +import Layouts +import Page exposing (Page) +import Route exposing (Route) +import Shared +import View exposing (View) + + +page : Shared.Model -> Route () -> Page Model Msg +page shared route = + Page.new + { init = init + , update = update + , subscriptions = subscriptions + , view = view + } + |> Page.withLayout toLayout + + +toLayout : Model -> Layouts.Layout Msg +toLayout model = + Layouts.Sidebar_Header + { title = "Dashboard" + , shouldPadContent = True + , button = + Html.button [ class "btn", Html.Events.onClick Increment ] + [ Html.text ("Counter: " ++ String.fromInt model.counter) + ] + } + + + +-- INIT + + +type alias Model = + { counter : Int + } + + +init : () -> ( Model, Effect Msg ) +init () = + ( { counter = 0 } + , Effect.none + ) + + + +-- UPDATE + + +type Msg + = Increment + + +update : Msg -> Model -> ( Model, Effect Msg ) +update msg model = + case msg of + Increment -> + ( { model | counter = model.counter + 1 } + , Effect.none + ) + + + +-- SUBSCRIPTIONS + + +subscriptions : Model -> Sub Msg +subscriptions model = + Sub.none + + + +-- VIEW + + +view : Model -> View Msg +view model = + { title = "Dashboard" + , body = + [ Html.div [ class "page" ] + [ Html.text "Welcome to the dashboard!" ] + ] + } diff --git a/examples/17-layout-props-types/static/main.css b/examples/17-layout-props-types/static/main.css new file mode 100644 index 00000000..475984bd --- /dev/null +++ b/examples/17-layout-props-types/static/main.css @@ -0,0 +1,30 @@ +/* RESETS */ +html, body { height: 100%; } +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; +} +* { box-sizing: border-box; color: inherit; } + +/* LAYOUT BASICS */ +.pad-16 { padding: 1rem; } + +/* SIDEBAR LAYOUT */ +.sidebar { + display: flex; + flex-direction: column; + gap: 2rem; + background: #435; + color: white; + padding: 2rem; + width: 280px; + justify-content: space-between; +} + + +/* HEADER LAYOUT */ +header { display: flex; flex-direction: row; align-items: center; padding: 1.5rem; border-bottom: solid 1px #eee; font-size: 2rem; font-weight: bold; } + +/* BUTTONS */ +.btn { background: #435; margin-left: 1rem; padding: 0.7rem 1.2rem; color: white; border-radius: 0.25rem; } +.btn:hover { opacity: 0.75; } From 4644ffe7bee52b4d7430a8499b66141aa85ab19b Mon Sep 17 00:00:00 2001 From: Fernando Espinosa Date: Fri, 25 Aug 2023 08:29:09 +0200 Subject: [PATCH 4/7] Fix error in `Generate.toViewCasExpression` --- projects/cli/src/codegen/src/Commands/Generate.elm | 2 +- projects/cli/tests/08-examples.bats | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/cli/src/codegen/src/Commands/Generate.elm b/projects/cli/src/codegen/src/Commands/Generate.elm index dcc46564..85856a8d 100644 --- a/projects/cli/src/codegen/src/Commands/Generate.elm +++ b/projects/cli/src/codegen/src/Commands/Generate.elm @@ -1396,7 +1396,7 @@ toViewCaseExpression layouts = let props : String props = - if original == current || isTopLevel == False then + if LayoutFile.toList original == LayoutFile.toList current then "props" else diff --git a/projects/cli/tests/08-examples.bats b/projects/cli/tests/08-examples.bats index b8dbf452..7c6938cf 100644 --- a/projects/cli/tests/08-examples.bats +++ b/projects/cli/tests/08-examples.bats @@ -83,4 +83,9 @@ load helpers @test "'16-hash-based-routing' example builds successfully" { cd ../../examples/16-hash-based-routing expectElmExampleBuilds +} + +@test "'17-layout-props-types' example builds successfully" { + cd ../../examples/17-layout-props-types + expectElmExampleBuilds } \ No newline at end of file From 1573b72a495b8db3de7822ee1e36d02a89652f57 Mon Sep 17 00:00:00 2001 From: Ryan Haskell-Glatz Date: Wed, 30 Aug 2023 12:48:22 -0400 Subject: [PATCH 5/7] =?UTF-8?q?@ferdev=20did=20it=20real=20good=20?= =?UTF-8?q?=F0=9F=92=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config.js | 2 +- docs/concepts/cli.md | 2 +- docs/guide/deploying.md | 2 +- docs/guide/pages-and-routes.md | 2 +- examples/01-hello-world/README.md | 16 +++++++++++++ examples/02-pages-and-routes/README.md | 16 +++++++++++++ examples/03-user-input/README.md | 16 +++++++++++++ examples/04-rest-apis/README.md | 16 +++++++++++++ examples/05-user-auth/README.md | 16 +++++++++++++ examples/06-query-parameters/README.md | 16 +++++++++++++ examples/07-working-with-js/README.md | 16 +++++++++++++ examples/08-nested-layouts/README.md | 16 +++++++++++++ examples/08-nested-layouts/package-lock.json | 6 +++++ examples/09-catch-all-routes/README.md | 16 +++++++++++++ .../09-catch-all-routes/package-lock.json | 6 +++++ examples/10-typescript-interop/README.md | 16 +++++++++++++ examples/11-error-reporting/README.md | 16 +++++++++---- examples/12-elm-ui/README.md | 16 +++++++++++++ examples/13-elm-css/README.md | 16 +++++++++++++ examples/14-scss-and-assets/README.md | 16 +++++++++++++ examples/15-custom-404-pages/README.md | 16 +++++++++++++ examples/16-hash-based-routing/README.md | 16 +++++++++++++ examples/17-layout-props-types/.gitignore | 3 +++ examples/17-layout-props-types/README.md | 16 +++++++++++++ .../.gitignore | 0 examples/18-shared-subscriptions/README.md | 16 +++++++++++++ .../elm-land.json | 0 .../elm.json | 0 .../src/Pages/Home_.elm | 0 .../src/Shared.elm | 0 .../src/Shared/Model.elm | 0 .../src/Shared/Msg.elm | 0 .../src/interop.ts | 0 examples/README.md | 5 ++-- projects/cli/README.md | 2 +- projects/cli/package-lock.json | 4 ++-- projects/cli/package.json | 2 +- projects/cli/src/commands/init.js | 24 +++++++++++++++++++ projects/cli/src/effects.js | 4 ++-- .../cli/src/templates/_elm-land/src/Main.elm | 2 +- projects/cli/tests/08-examples.bats | 5 ++++ projects/cli/tests/09-elm-binary.bats | 6 ++--- projects/graphql/README.md | 8 +++---- projects/graphql/package-lock.json | 4 ++-- projects/graphql/package.json | 2 +- 45 files changed, 352 insertions(+), 27 deletions(-) create mode 100644 examples/01-hello-world/README.md create mode 100644 examples/02-pages-and-routes/README.md create mode 100644 examples/03-user-input/README.md create mode 100644 examples/04-rest-apis/README.md create mode 100644 examples/05-user-auth/README.md create mode 100644 examples/06-query-parameters/README.md create mode 100644 examples/07-working-with-js/README.md create mode 100644 examples/08-nested-layouts/README.md create mode 100644 examples/08-nested-layouts/package-lock.json create mode 100644 examples/09-catch-all-routes/README.md create mode 100644 examples/09-catch-all-routes/package-lock.json create mode 100644 examples/10-typescript-interop/README.md create mode 100644 examples/12-elm-ui/README.md create mode 100644 examples/13-elm-css/README.md create mode 100644 examples/14-scss-and-assets/README.md create mode 100644 examples/15-custom-404-pages/README.md create mode 100644 examples/16-hash-based-routing/README.md create mode 100644 examples/17-layout-props-types/.gitignore create mode 100644 examples/17-layout-props-types/README.md rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/.gitignore (100%) create mode 100644 examples/18-shared-subscriptions/README.md rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/elm-land.json (100%) rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/elm.json (100%) rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/src/Pages/Home_.elm (100%) rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/src/Shared.elm (100%) rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/src/Shared/Model.elm (100%) rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/src/Shared/Msg.elm (100%) rename examples/{17-shared-subscriptions => 18-shared-subscriptions}/src/interop.ts (100%) diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index a04bd7be..cb87c4c0 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -1,4 +1,4 @@ -const version = '0.19.2' +const version = '0.19.3' const sidebar = [ { diff --git a/docs/concepts/cli.md b/docs/concepts/cli.md index 83da2d47..125cd1c1 100644 --- a/docs/concepts/cli.md +++ b/docs/concepts/cli.md @@ -172,7 +172,7 @@ Here's example output of what you'd see if you ran this command in the ["Pages a ```txt - 🌈 Elm Land (v0.19.2) found 5 pages in your application + 🌈 Elm Land (v0.19.3) found 5 pages in your application ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ src/Pages/Home_.elm ............... http://localhost:1234/ src/Pages/SignIn.elm .............. http://localhost:1234/sign-in diff --git a/docs/guide/deploying.md b/docs/guide/deploying.md index 14a10cd1..450bdeba 100644 --- a/docs/guide/deploying.md +++ b/docs/guide/deploying.md @@ -16,7 +16,7 @@ elm-land build ```txt -🌈 Elm Land (v0.19.2) build was successful. +🌈 Elm Land (v0.19.3) build was successful. ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ ``` diff --git a/docs/guide/pages-and-routes.md b/docs/guide/pages-and-routes.md index da399ae3..54176a6f 100644 --- a/docs/guide/pages-and-routes.md +++ b/docs/guide/pages-and-routes.md @@ -326,7 +326,7 @@ elm-land routes ```txt - 🌈 Elm Land (v0.19.2) found 6 pages in your application + 🌈 Elm Land (v0.19.3) found 6 pages in your application ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ src/Pages/Home_.elm ........................... / src/Pages/SignIn.elm .......................... /sign-in diff --git a/examples/01-hello-world/README.md b/examples/01-hello-world/README.md new file mode 100644 index 00000000..af81a980 --- /dev/null +++ b/examples/01-hello-world/README.md @@ -0,0 +1,16 @@ +# 01-hello-world +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/02-pages-and-routes/README.md b/examples/02-pages-and-routes/README.md new file mode 100644 index 00000000..31aca3fa --- /dev/null +++ b/examples/02-pages-and-routes/README.md @@ -0,0 +1,16 @@ +# 02-pages-and-routes +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/03-user-input/README.md b/examples/03-user-input/README.md new file mode 100644 index 00000000..0f393eaf --- /dev/null +++ b/examples/03-user-input/README.md @@ -0,0 +1,16 @@ +# 03-user-input +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/04-rest-apis/README.md b/examples/04-rest-apis/README.md new file mode 100644 index 00000000..9a28a3c0 --- /dev/null +++ b/examples/04-rest-apis/README.md @@ -0,0 +1,16 @@ +# 04-rest-apis +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/05-user-auth/README.md b/examples/05-user-auth/README.md new file mode 100644 index 00000000..56f10c6c --- /dev/null +++ b/examples/05-user-auth/README.md @@ -0,0 +1,16 @@ +# 05-user-auth +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/06-query-parameters/README.md b/examples/06-query-parameters/README.md new file mode 100644 index 00000000..b1162662 --- /dev/null +++ b/examples/06-query-parameters/README.md @@ -0,0 +1,16 @@ +# 06-query-parameters +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/07-working-with-js/README.md b/examples/07-working-with-js/README.md new file mode 100644 index 00000000..1f5ff062 --- /dev/null +++ b/examples/07-working-with-js/README.md @@ -0,0 +1,16 @@ +# 07-working-with-js +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/08-nested-layouts/README.md b/examples/08-nested-layouts/README.md new file mode 100644 index 00000000..e3ffef11 --- /dev/null +++ b/examples/08-nested-layouts/README.md @@ -0,0 +1,16 @@ +# 08-nested-layouts +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/08-nested-layouts/package-lock.json b/examples/08-nested-layouts/package-lock.json new file mode 100644 index 00000000..f6707f2f --- /dev/null +++ b/examples/08-nested-layouts/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "08-nested-layouts", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/examples/09-catch-all-routes/README.md b/examples/09-catch-all-routes/README.md new file mode 100644 index 00000000..cb0fa91f --- /dev/null +++ b/examples/09-catch-all-routes/README.md @@ -0,0 +1,16 @@ +# 09-catch-all-routes +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/09-catch-all-routes/package-lock.json b/examples/09-catch-all-routes/package-lock.json new file mode 100644 index 00000000..f39d228e --- /dev/null +++ b/examples/09-catch-all-routes/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "09-catch-all-routes", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/examples/10-typescript-interop/README.md b/examples/10-typescript-interop/README.md new file mode 100644 index 00000000..5f60eeeb --- /dev/null +++ b/examples/10-typescript-interop/README.md @@ -0,0 +1,16 @@ +# 10-typescript-interop +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/11-error-reporting/README.md b/examples/11-error-reporting/README.md index 81b256e1..29b2e327 100644 --- a/examples/11-error-reporting/README.md +++ b/examples/11-error-reporting/README.md @@ -1,8 +1,7 @@ # 11-error-reporting +> Built with [Elm Land](https://elm.land) 🌈 -An example of how to report all HTTP errors to an error reporting service, like Sentry! - -## Trying it out +## Local development ### 1. Create a free Sentry project @@ -38,4 +37,13 @@ When you visit the homepage in this example, an HTTP API call will fail and that Click into the error message to see the "Additional data" section, including the URL, JSON Response, and Json.Decode.Error message sent from Elm! -![A screenshot of Sentry's "Additional data" section, showing that the JSON payload and specific error have been reported successfully.](./sentry-error-details.jpg) \ No newline at end of file +![A screenshot of Sentry's "Additional data" section, showing that the JSON payload and specific error have been reported successfully.](./sentry-error-details.jpg) + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. + +An example of how to report all HTTP errors to an error reporting service, like Sentry! \ No newline at end of file diff --git a/examples/12-elm-ui/README.md b/examples/12-elm-ui/README.md new file mode 100644 index 00000000..abef4901 --- /dev/null +++ b/examples/12-elm-ui/README.md @@ -0,0 +1,16 @@ +# 12-elm-ui +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/13-elm-css/README.md b/examples/13-elm-css/README.md new file mode 100644 index 00000000..75b76c78 --- /dev/null +++ b/examples/13-elm-css/README.md @@ -0,0 +1,16 @@ +# 13-elm-css +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/14-scss-and-assets/README.md b/examples/14-scss-and-assets/README.md new file mode 100644 index 00000000..ff623b85 --- /dev/null +++ b/examples/14-scss-and-assets/README.md @@ -0,0 +1,16 @@ +# 14-scss-and-assets +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/15-custom-404-pages/README.md b/examples/15-custom-404-pages/README.md new file mode 100644 index 00000000..db5cf3bb --- /dev/null +++ b/examples/15-custom-404-pages/README.md @@ -0,0 +1,16 @@ +# 15-custom-404-pages +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/16-hash-based-routing/README.md b/examples/16-hash-based-routing/README.md new file mode 100644 index 00000000..996c5b07 --- /dev/null +++ b/examples/16-hash-based-routing/README.md @@ -0,0 +1,16 @@ +# 16-hash-based-routing +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/17-layout-props-types/.gitignore b/examples/17-layout-props-types/.gitignore new file mode 100644 index 00000000..8b3af8bb --- /dev/null +++ b/examples/17-layout-props-types/.gitignore @@ -0,0 +1,3 @@ +dist +.elm-land +elm-stuff \ No newline at end of file diff --git a/examples/17-layout-props-types/README.md b/examples/17-layout-props-types/README.md new file mode 100644 index 00000000..14db8c81 --- /dev/null +++ b/examples/17-layout-props-types/README.md @@ -0,0 +1,16 @@ +# 17-layout-props-types +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/17-shared-subscriptions/.gitignore b/examples/18-shared-subscriptions/.gitignore similarity index 100% rename from examples/17-shared-subscriptions/.gitignore rename to examples/18-shared-subscriptions/.gitignore diff --git a/examples/18-shared-subscriptions/README.md b/examples/18-shared-subscriptions/README.md new file mode 100644 index 00000000..eda40cec --- /dev/null +++ b/examples/18-shared-subscriptions/README.md @@ -0,0 +1,16 @@ +# 18-shared-subscriptions +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +```bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +``` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. \ No newline at end of file diff --git a/examples/17-shared-subscriptions/elm-land.json b/examples/18-shared-subscriptions/elm-land.json similarity index 100% rename from examples/17-shared-subscriptions/elm-land.json rename to examples/18-shared-subscriptions/elm-land.json diff --git a/examples/17-shared-subscriptions/elm.json b/examples/18-shared-subscriptions/elm.json similarity index 100% rename from examples/17-shared-subscriptions/elm.json rename to examples/18-shared-subscriptions/elm.json diff --git a/examples/17-shared-subscriptions/src/Pages/Home_.elm b/examples/18-shared-subscriptions/src/Pages/Home_.elm similarity index 100% rename from examples/17-shared-subscriptions/src/Pages/Home_.elm rename to examples/18-shared-subscriptions/src/Pages/Home_.elm diff --git a/examples/17-shared-subscriptions/src/Shared.elm b/examples/18-shared-subscriptions/src/Shared.elm similarity index 100% rename from examples/17-shared-subscriptions/src/Shared.elm rename to examples/18-shared-subscriptions/src/Shared.elm diff --git a/examples/17-shared-subscriptions/src/Shared/Model.elm b/examples/18-shared-subscriptions/src/Shared/Model.elm similarity index 100% rename from examples/17-shared-subscriptions/src/Shared/Model.elm rename to examples/18-shared-subscriptions/src/Shared/Model.elm diff --git a/examples/17-shared-subscriptions/src/Shared/Msg.elm b/examples/18-shared-subscriptions/src/Shared/Msg.elm similarity index 100% rename from examples/17-shared-subscriptions/src/Shared/Msg.elm rename to examples/18-shared-subscriptions/src/Shared/Msg.elm diff --git a/examples/17-shared-subscriptions/src/interop.ts b/examples/18-shared-subscriptions/src/interop.ts similarity index 100% rename from examples/17-shared-subscriptions/src/interop.ts rename to examples/18-shared-subscriptions/src/interop.ts diff --git a/examples/README.md b/examples/README.md index d261817c..2e427b82 100644 --- a/examples/README.md +++ b/examples/README.md @@ -20,7 +20,8 @@ - [SCSS and assets](./14-scss-and-assets/) - [Custom 404 pages](./15-custom-404-pages/) - [Hash-bashed routing](./16-hash-based-routing/) -- [Shared subscriptions](./17-shared-subscriptions/) +- [Layouts with props](./17-layout-props-types/) +- [Shared subscriptions](./18-shared-subscriptions/) ## 1. Hello world! @@ -75,7 +76,7 @@ Learn how to work with URL parameters to build an interactive table with filteri ## 7. Working with JS -Learn how to work with existing NPM packages, run JavaScript from Elm, and +Learn how to work with existing NPM packages, run JavaScript from Elm, and web components. [Example code](./07-working-with-js/) • [The guide](https://elm.land/guide/working-with-js) diff --git a/projects/cli/README.md b/projects/cli/README.md index 746cf46a..ee0d06b0 100644 --- a/projects/cli/README.md +++ b/projects/cli/README.md @@ -17,7 +17,7 @@ The `elm-land` CLI comes with everything you need to create your next web applic ``` $ elm-land -🌈 Welcome to Elm Land! (v0.19.2) +🌈 Welcome to Elm Land! (v0.19.3) ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ Here are the available commands: diff --git a/projects/cli/package-lock.json b/projects/cli/package-lock.json index 9e76b190..1a8cc259 100644 --- a/projects/cli/package-lock.json +++ b/projects/cli/package-lock.json @@ -1,12 +1,12 @@ { "name": "elm-land", - "version": "0.19.2", + "version": "0.19.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "elm-land", - "version": "0.19.2", + "version": "0.19.3", "license": "ISC", "dependencies": { "@lydell/elm": "^0.19.1-12", diff --git a/projects/cli/package.json b/projects/cli/package.json index a005b18d..daa2757f 100644 --- a/projects/cli/package.json +++ b/projects/cli/package.json @@ -1,6 +1,6 @@ { "name": "elm-land", - "version": "0.19.2", + "version": "0.19.3", "description": "Reliable web apps for everyone", "main": "index.js", "types": "./index.d.ts", diff --git a/projects/cli/src/commands/init.js b/projects/cli/src/commands/init.js index 14ac0e58..6dde7d75 100644 --- a/projects/cli/src/commands/init.js +++ b/projects/cli/src/commands/init.js @@ -71,6 +71,11 @@ let run = async (options = {}) => { return { message, files: [ + { + kind: 'file', + name: `${name}/README.md`, + content: toReadmeFileWithName({ name }) + }, { kind: 'file', name: `${name}/elm.json`, @@ -148,6 +153,25 @@ let run = async (options = {}) => { } } +const toReadmeFileWithName = ({ name }) => ` +# ${name} +> Built with [Elm Land](https://elm.land) 🌈 + +## Local development + +\`\`\`bash +# Requires Node.js v18+ (https://nodejs.org) +npx elm-land server +\`\`\` + +## Deploying to production + +Elm Land projects are most commonly deployed as static websites. + +Please visit [the "Deployment" guide](https://elm.land/guide/deploying) to learn more +about deploying your app for free using Netlify or Vercel. +`.trim() + module.exports = { Init: { run, printHelpInfo } } \ No newline at end of file diff --git a/projects/cli/src/effects.js b/projects/cli/src/effects.js index d3ddf6cc..e755b008 100644 --- a/projects/cli/src/effects.js +++ b/projects/cli/src/effects.js @@ -256,7 +256,7 @@ let generateElmFiles = async (config, server = undefined) => { server.ws.send('elm:success', { msg: 'Success!' }) } - let layoutsData = layouts.map(({ filepath, contents}) => { + let layoutsData = layouts.map(({ filepath, contents }) => { const typeVariablePattern = 'type alias Props contentMsg'; const isUsingTypeVariable = contents.includes(typeVariablePattern); @@ -552,7 +552,7 @@ const generateHtml = async (config) => { ? [toHtmlTag('title', {}, config.app.html.title)] : [] let metaTags = toSelfClosingHtmlTags('meta', [ - { name: 'elm-land', content: '0.19.2' } + { name: 'elm-land', content: '0.19.3' } ].concat(attempt(_ => config.app.html.meta))) let linkTags = toSelfClosingHtmlTags('link', attempt(_ => config.app.html.link)) let scriptTags = toHtmlTags('script', attempt(_ => config.app.html.script)) diff --git a/projects/cli/src/templates/_elm-land/src/Main.elm b/projects/cli/src/templates/_elm-land/src/Main.elm index 831f174c..89dc1290 100644 --- a/projects/cli/src/templates/_elm-land/src/Main.elm +++ b/projects/cli/src/templates/_elm-land/src/Main.elm @@ -5,4 +5,4 @@ import Html exposing (Html) main : Html msg main = - Html.text "Hello, Elm Land!" + Html.text "Generating..." diff --git a/projects/cli/tests/08-examples.bats b/projects/cli/tests/08-examples.bats index 7c6938cf..a75ec237 100644 --- a/projects/cli/tests/08-examples.bats +++ b/projects/cli/tests/08-examples.bats @@ -88,4 +88,9 @@ load helpers @test "'17-layout-props-types' example builds successfully" { cd ../../examples/17-layout-props-types expectElmExampleBuilds +} + +@test "'18-shared-subscriptions' example builds successfully" { + cd ../../examples/18-shared-subscriptions + expectElmExampleBuilds } \ No newline at end of file diff --git a/projects/cli/tests/09-elm-binary.bats b/projects/cli/tests/09-elm-binary.bats index 4fe35cf9..cfbaff24 100644 --- a/projects/cli/tests/09-elm-binary.bats +++ b/projects/cli/tests/09-elm-binary.bats @@ -54,7 +54,7 @@ load helpers cp -r ../../examples/01-hello-world ../../examples/01-local-hello cd ../../examples/01-local-hello - echo '{ "dependencies": { "elm-land": "file:../../projects/cli/elm-land-0.19.2.tgz" } }' > package.json + echo '{ "dependencies": { "elm-land": "file:../../projects/cli/elm-land-0.19.3.tgz" } }' > package.json npm install run npx elm-land build @@ -72,7 +72,7 @@ load helpers cp -r ../../examples/01-hello-world ../../examples/01-local-hello cd ../../examples/01-local-hello - echo '{ "dependencies": { "elm-land": "file:../../projects/cli/elm-land-0.19.2.tgz" } }' > package.json + echo '{ "dependencies": { "elm-land": "file:../../projects/cli/elm-land-0.19.3.tgz" } }' > package.json npm install -g yarn yarn @@ -91,7 +91,7 @@ load helpers cp -r ../../examples/01-hello-world ../../examples/01-local-hello cd ../../examples/01-local-hello - echo '{ "dependencies": { "elm-land": "file:../../projects/cli/elm-land-0.19.2.tgz" } }' > package.json + echo '{ "dependencies": { "elm-land": "file:../../projects/cli/elm-land-0.19.3.tgz" } }' > package.json npm install -g pnpm pnpm install diff --git a/projects/graphql/README.md b/projects/graphql/README.md index 8b686829..f84c5abc 100644 --- a/projects/graphql/README.md +++ b/projects/graphql/README.md @@ -23,7 +23,7 @@ npm install -g elm-land@latest ```txt $ elm-land graphql -🌈 Elm Land (v0.19.2) wants to add a plugin! +🌈 Elm Land (v0.19.3) wants to add a plugin! ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ To use the `@elm-land/graphql` plugin, I'll need to install the NPM package and add a bit of JSON @@ -35,14 +35,14 @@ $ elm-land graphql ```txt $ elm-land graphql build -🌈 Elm Land (v0.19.2) successfully generated Elm files +🌈 Elm Land (v0.19.3) successfully generated Elm files ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ ``` ```txt $ elm-land graphql watch -🌈 Elm Land (v0.19.2) is watching "./graphql/*" for changes... +🌈 Elm Land (v0.19.3) is watching "./graphql/*" for changes... ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ ``` @@ -55,7 +55,7 @@ Here’s what running the CLI looks like when there’s no schema provided: ``` $ elm-land graphql build -🌈 Elm Land (v0.19.2) needs a GraphQL schema +🌈 Elm Land (v0.19.3) needs a GraphQL schema ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ You can provide one by customizing the "elm-land.json" file to include a "graphql.schema" field. diff --git a/projects/graphql/package-lock.json b/projects/graphql/package-lock.json index d7cb0a50..3ef44955 100644 --- a/projects/graphql/package-lock.json +++ b/projects/graphql/package-lock.json @@ -1,12 +1,12 @@ { "name": "@elm-land/graphql", - "version": "0.19.2", + "version": "0.19.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@elm-land/graphql", - "version": "0.19.2", + "version": "0.19.3", "license": "ISC", "dependencies": { "graphql": "16.6.0" diff --git a/projects/graphql/package.json b/projects/graphql/package.json index 2f096e39..15030c93 100644 --- a/projects/graphql/package.json +++ b/projects/graphql/package.json @@ -1,6 +1,6 @@ { "name": "@elm-land/graphql", - "version": "0.19.2", + "version": "0.19.3", "description": "Generate Elm code from GraphQL files", "main": "src/index.js", "scripts": { From 88d37eae3f4f2766959315a82ed53514ae6c98e1 Mon Sep 17 00:00:00 2001 From: Ryan Haskell-Glatz Date: Wed, 30 Aug 2023 13:04:28 -0400 Subject: [PATCH 6/7] Add "elm-land generate" command --- docs/concepts/cli.md | 15 ++++++++ projects/cli/README.md | 1 + projects/cli/src/cli.js | 11 +++++- projects/cli/src/commands/generate.js | 54 +++++++++++++++++++++++++++ projects/cli/src/effects.js | 18 +++++++-- projects/cli/tests/06-build.bats | 12 ++++++ 6 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 projects/cli/src/commands/generate.js diff --git a/docs/concepts/cli.md b/docs/concepts/cli.md index 125cd1c1..ab471eb1 100644 --- a/docs/concepts/cli.md +++ b/docs/concepts/cli.md @@ -71,6 +71,21 @@ This command builds your Elm Land app in production-mode. This includes running Visit the [Deploying to production](../guide/deploying) guide to learn how to correctly set up SPA redirects to the single `dist/index.html` file. + + +## elm-land generate + +```txt +🪄 elm-land generate ............. generate Elm Land files +``` + +#### Description + +The first step of the `elm-land build` command generates some `.elm` files in the `.elm-land/src` folder. Some projects don't need a full build step (generating a JS file, HTML file, etc), +and want to manually run `elm make` on the generated code. + +For those advanced use cases, we've added a specific `generate` command that doesn't involve the unnecessary build steps. + ## elm-land add page ```txt diff --git a/projects/cli/README.md b/projects/cli/README.md index ee0d06b0..8bf38632 100644 --- a/projects/cli/README.md +++ b/projects/cli/README.md @@ -24,6 +24,7 @@ $ elm-land ✨ elm-land init ...... create a new project 🚀 elm-land server ................ run a local dev server 📦 elm-land build .......... build your app for production + 🪄 elm-land generate ............. generate Elm Land files 📄 elm-land add page ................ add a new page 🍱 elm-land add layout ........... add a new layout 🔧 elm-land customize .. customize a default module diff --git a/projects/cli/src/cli.js b/projects/cli/src/cli.js index a13a6ab7..be9b5d64 100644 --- a/projects/cli/src/cli.js +++ b/projects/cli/src/cli.js @@ -1,6 +1,7 @@ const { Init } = require('./commands/init') const { Add } = require('./commands/add') const { Server } = require('./commands/server') +const { Generate } = require('./commands/generate') const { Build } = require('./commands/build') const { Customize } = require('./commands/customize') const { Routes } = require('./commands/routes') @@ -14,10 +15,11 @@ let subcommandList = [ ` ✨ elm-land ${Terminal.pink('init ')} ...... create a new project`, ` 🚀 elm-land ${Terminal.pink('server')} ................ run a local dev server`, ` 📦 elm-land ${Terminal.pink('build')} .......... build your app for production`, + ` 🪄 elm-land ${Terminal.pink('generate')} ............. generate Elm Land files`, ` 📄 elm-land ${Terminal.pink('add page ')} ................ add a new page`, ` 🍱 elm-land ${Terminal.pink('add layout ')} ........... add a new layout`, ` 🔧 elm-land ${Terminal.pink('customize ')} .. customize a default module`, - ` 🔍 elm-land ${Terminal.pink('routes')} ........... list all routes in your app` + ` 🔍 elm-land ${Terminal.pink('routes')} ........... list all routes in your app`, ] @@ -69,6 +71,13 @@ let run = async (commandFromCli) => { return Server.run({}) } }, + 'generate': (args = []) => { + if (isHelpFlag(args[0])) { + return Generate.printHelpInfo() + } else { + return Generate.run({}) + } + }, 'build': (args = []) => { if (isHelpFlag(args[0])) { return Build.printHelpInfo() diff --git a/projects/cli/src/commands/generate.js b/projects/cli/src/commands/generate.js new file mode 100644 index 00000000..fc2a21e8 --- /dev/null +++ b/projects/cli/src/commands/generate.js @@ -0,0 +1,54 @@ +const { Files } = require("../files") +const { Utils, Terminal } = require("./_utils") + +let printHelpInfo = () => { + return { + message: [ + '', + Utils.intro.success(`detected the ${Terminal.green('help')} command`), + ` When you are ready to ship your app to production, the`, + ` ${Terminal.cyan('elm-land generate')} command will generate some Elm code`, + ` for your project in the ${Terminal.pink('./elm-land/src')} folder`, + '', + ` From there, you can decide how to compile it to JS, and deploy the`, + ` app however you like. This is like elm-land build, but without the extra steps.`, + '', + ].join('\n'), + files: [], + effects: [] + } +} + +let run = async () => { + + let rawTextConfig = undefined + try { + rawTextConfig = await Files.readFromUserFolder('elm-land.json') + } catch (_) { + return Promise.reject(Utils.notInElmLandProject) + } + + let config = {} + try { + config = JSON.parse(rawTextConfig) + } catch (err) { + // TODO: Warn user about invalid config JSON + } + + return { + message: [ + '', + Utils.intro.success(`generated files successfully.`), + ].join('\n'), + files: [], + effects: [ + { kind: 'generate', config } + ] + } +} + +module.exports = { + Generate: { + run, printHelpInfo + } +} \ No newline at end of file diff --git a/projects/cli/src/effects.js b/projects/cli/src/effects.js index e755b008..ef870396 100644 --- a/projects/cli/src/effects.js +++ b/projects/cli/src/effects.js @@ -399,17 +399,24 @@ const handleElmLandFiles = async () => { }) } -const build = async (config) => { +const generate = async (config) => { // Create default files in `.elm-land/src` if they aren't already // defined by the user in the `src` folder await handleElmLandFiles() - // Ensure environment variables work as expected - handleEnvironmentVariables({ config }) - // Generate Elm files await generateElmFiles(config) + return { problem: null } +} + +const build = async (config) => { + // Generates remaining Elm files in .elm-land/src + await generate(config) + + // Ensure environment variables work as expected + handleEnvironmentVariables({ config }) + // Typecheck any TypeScript interop await TypeScriptPlugin.verifyTypescriptCompiles() @@ -604,6 +611,9 @@ let run = async (effects) => { case 'build': results.push(await build(effect.config)) break + case 'generate': + results.push(await generate(effect.config)) + break case 'customize': results.push(await customize(effect.filepaths)) break diff --git a/projects/cli/tests/06-build.bats b/projects/cli/tests/06-build.bats index 4f0917ae..f40a90e8 100644 --- a/projects/cli/tests/06-build.bats +++ b/projects/cli/tests/06-build.bats @@ -42,6 +42,18 @@ load helpers cd ../../projects/cli } + +@test "'elm-land generate' works with hello world example" { + cd ../../examples/01-hello-world + run elm-land generate + expectToPass + + expectOutputContains "success" + + rm -r .elm-land + cd ../../projects/cli +} + @test "cleanup" { cleanupTmpFolder } \ No newline at end of file From 0210e11e640e342860ec946c840c32ad82677024 Mon Sep 17 00:00:00 2001 From: Ryan Haskell-Glatz Date: Wed, 30 Aug 2023 15:15:12 -0400 Subject: [PATCH 7/7] Change "ExampleMsgReplaceMe" to "NoOp", because some pages/layouts won't have user input --- docs/guide/rest-apis.md | 10 +++++----- docs/guide/user-input.md | 4 ++-- examples/05-user-auth/src/Pages/Home_.elm | 4 ++-- examples/05-user-auth/src/Pages/Profile/Me.elm | 4 ++-- examples/05-user-auth/src/Pages/Settings.elm | 4 ++-- examples/07-working-with-js/src/Shared.elm | 2 +- examples/07-working-with-js/src/Shared/Msg.elm | 2 +- examples/08-nested-layouts/src/Pages/Home_.elm | 4 ++-- examples/08-nested-layouts/src/Pages/Settings.elm | 4 ++-- .../08-nested-layouts/src/Pages/Settings/Account.elm | 4 ++-- .../src/Pages/Settings/Notifications.elm | 4 ++-- examples/08-nested-layouts/src/Pages/SignIn.elm | 4 ++-- examples/15-custom-404-pages/src/Pages/NotFound_.elm | 4 ++-- examples/18-shared-subscriptions/src/Pages/Home_.elm | 4 ++-- projects/cli/src/codegen.js | 4 ++-- projects/cli/src/codegen/src/Commands/AddPage.elm | 12 ++++++------ .../_elm-land/customizable/Pages/NotFound_.elm | 4 ++-- .../src/templates/_elm-land/customizable/Shared.elm | 2 +- .../templates/_elm-land/customizable/Shared/Msg.elm | 2 +- projects/cli/src/validate/src/Worker.elm | 2 +- 20 files changed, 42 insertions(+), 42 deletions(-) diff --git a/docs/guide/rest-apis.md b/docs/guide/rest-apis.md index dcba42c5..a3d5e9bb 100644 --- a/docs/guide/rest-apis.md +++ b/docs/guide/rest-apis.md @@ -83,13 +83,13 @@ init = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Cmd.none ) @@ -135,7 +135,7 @@ init = update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Cmd.none ) @@ -847,13 +847,13 @@ init = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Cmd.none ) diff --git a/docs/guide/user-input.md b/docs/guide/user-input.md index d83f6370..7454c3fd 100644 --- a/docs/guide/user-input.md +++ b/docs/guide/user-input.md @@ -70,13 +70,13 @@ init = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> Model update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> model diff --git a/examples/05-user-auth/src/Pages/Home_.elm b/examples/05-user-auth/src/Pages/Home_.elm index b642acbb..0d6bd6c4 100644 --- a/examples/05-user-auth/src/Pages/Home_.elm +++ b/examples/05-user-auth/src/Pages/Home_.elm @@ -49,13 +49,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/05-user-auth/src/Pages/Profile/Me.elm b/examples/05-user-auth/src/Pages/Profile/Me.elm index 163792f2..cabe4a02 100644 --- a/examples/05-user-auth/src/Pages/Profile/Me.elm +++ b/examples/05-user-auth/src/Pages/Profile/Me.elm @@ -49,13 +49,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/05-user-auth/src/Pages/Settings.elm b/examples/05-user-auth/src/Pages/Settings.elm index b98111ff..6b9e9f89 100644 --- a/examples/05-user-auth/src/Pages/Settings.elm +++ b/examples/05-user-auth/src/Pages/Settings.elm @@ -49,13 +49,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/07-working-with-js/src/Shared.elm b/examples/07-working-with-js/src/Shared.elm index e021b19b..77c37121 100644 --- a/examples/07-working-with-js/src/Shared.elm +++ b/examples/07-working-with-js/src/Shared.elm @@ -61,7 +61,7 @@ type alias Msg = update : Route () -> Msg -> Model -> ( Model, Effect Msg ) update route msg model = case msg of - Shared.Msg.ExampleMsgReplaceMe -> + Shared.Msg.NoOp -> ( model , Effect.none ) diff --git a/examples/07-working-with-js/src/Shared/Msg.elm b/examples/07-working-with-js/src/Shared/Msg.elm index 34b98b55..cccb82df 100644 --- a/examples/07-working-with-js/src/Shared/Msg.elm +++ b/examples/07-working-with-js/src/Shared/Msg.elm @@ -11,4 +11,4 @@ own file, so they can be imported by `Effect.elm` -} type Msg - = ExampleMsgReplaceMe + = NoOp diff --git a/examples/08-nested-layouts/src/Pages/Home_.elm b/examples/08-nested-layouts/src/Pages/Home_.elm index 089ffa11..15c9c034 100644 --- a/examples/08-nested-layouts/src/Pages/Home_.elm +++ b/examples/08-nested-layouts/src/Pages/Home_.elm @@ -49,13 +49,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/08-nested-layouts/src/Pages/Settings.elm b/examples/08-nested-layouts/src/Pages/Settings.elm index 400cf4fc..ac58ea22 100644 --- a/examples/08-nested-layouts/src/Pages/Settings.elm +++ b/examples/08-nested-layouts/src/Pages/Settings.elm @@ -45,13 +45,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/08-nested-layouts/src/Pages/Settings/Account.elm b/examples/08-nested-layouts/src/Pages/Settings/Account.elm index 4719efb7..d9cd2e39 100644 --- a/examples/08-nested-layouts/src/Pages/Settings/Account.elm +++ b/examples/08-nested-layouts/src/Pages/Settings/Account.elm @@ -45,13 +45,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/08-nested-layouts/src/Pages/Settings/Notifications.elm b/examples/08-nested-layouts/src/Pages/Settings/Notifications.elm index a39eda12..52dec0f5 100644 --- a/examples/08-nested-layouts/src/Pages/Settings/Notifications.elm +++ b/examples/08-nested-layouts/src/Pages/Settings/Notifications.elm @@ -46,13 +46,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/08-nested-layouts/src/Pages/SignIn.elm b/examples/08-nested-layouts/src/Pages/SignIn.elm index a694a3c5..a0195853 100644 --- a/examples/08-nested-layouts/src/Pages/SignIn.elm +++ b/examples/08-nested-layouts/src/Pages/SignIn.elm @@ -40,13 +40,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/15-custom-404-pages/src/Pages/NotFound_.elm b/examples/15-custom-404-pages/src/Pages/NotFound_.elm index 1ffe6e9e..55bac9c6 100644 --- a/examples/15-custom-404-pages/src/Pages/NotFound_.elm +++ b/examples/15-custom-404-pages/src/Pages/NotFound_.elm @@ -39,13 +39,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/examples/18-shared-subscriptions/src/Pages/Home_.elm b/examples/18-shared-subscriptions/src/Pages/Home_.elm index a4760ca5..428329ba 100644 --- a/examples/18-shared-subscriptions/src/Pages/Home_.elm +++ b/examples/18-shared-subscriptions/src/Pages/Home_.elm @@ -38,13 +38,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/projects/cli/src/codegen.js b/projects/cli/src/codegen.js index 19b9570a..8ec19306 100644 --- a/projects/cli/src/codegen.js +++ b/projects/cli/src/codegen.js @@ -120,13 +120,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/projects/cli/src/codegen/src/Commands/AddPage.elm b/projects/cli/src/codegen/src/Commands/AddPage.elm index db52f072..5943cfba 100644 --- a/projects/cli/src/codegen/src/Commands/AddPage.elm +++ b/projects/cli/src/codegen/src/Commands/AddPage.elm @@ -179,7 +179,7 @@ newSandboxPageModule { hasViewBeenCustomized, page, url } = CodeGen.Declaration.customType { name = "Msg" , variants = - [ ( "ExampleMsgReplaceMe", [] ) + [ ( "NoOp", [] ) ] } @@ -200,7 +200,7 @@ newSandboxPageModule { hasViewBeenCustomized, page, url } = CodeGen.Expression.caseExpression { value = CodeGen.Argument.new "msg" , branches = - [ { name = "ExampleMsgReplaceMe" + [ { name = "NoOp" , arguments = [] , expression = CodeGen.Expression.value "model" } @@ -311,7 +311,7 @@ newElementPageModule { hasViewBeenCustomized, page, url } = CodeGen.Declaration.customType { name = "Msg" , variants = - [ ( "ExampleMsgReplaceMe", [] ) + [ ( "NoOp", [] ) ] } @@ -332,7 +332,7 @@ newElementPageModule { hasViewBeenCustomized, page, url } = CodeGen.Expression.caseExpression { value = CodeGen.Argument.new "msg" , branches = - [ { name = "ExampleMsgReplaceMe" + [ { name = "NoOp" , arguments = [] , expression = CodeGen.Expression.multilineTuple @@ -461,7 +461,7 @@ newAdvancedPageModule { hasViewBeenCustomized, page, url } = CodeGen.Declaration.customType { name = "Msg" , variants = - [ ( "ExampleMsgReplaceMe", [] ) + [ ( "NoOp", [] ) ] } @@ -482,7 +482,7 @@ newAdvancedPageModule { hasViewBeenCustomized, page, url } = CodeGen.Expression.caseExpression { value = CodeGen.Argument.new "msg" , branches = - [ { name = "ExampleMsgReplaceMe" + [ { name = "NoOp" , arguments = [] , expression = CodeGen.Expression.multilineTuple diff --git a/projects/cli/src/templates/_elm-land/customizable/Pages/NotFound_.elm b/projects/cli/src/templates/_elm-land/customizable/Pages/NotFound_.elm index 3f9d16a6..581cf200 100644 --- a/projects/cli/src/templates/_elm-land/customizable/Pages/NotFound_.elm +++ b/projects/cli/src/templates/_elm-land/customizable/Pages/NotFound_.elm @@ -39,13 +39,13 @@ init () = type Msg - = ExampleMsgReplaceMe + = NoOp update : Msg -> Model -> ( Model, Effect Msg ) update msg model = case msg of - ExampleMsgReplaceMe -> + NoOp -> ( model , Effect.none ) diff --git a/projects/cli/src/templates/_elm-land/customizable/Shared.elm b/projects/cli/src/templates/_elm-land/customizable/Shared.elm index 2cd13fa2..0f5ba2f6 100644 --- a/projects/cli/src/templates/_elm-land/customizable/Shared.elm +++ b/projects/cli/src/templates/_elm-land/customizable/Shared.elm @@ -59,7 +59,7 @@ type alias Msg = update : Route () -> Msg -> Model -> ( Model, Effect Msg ) update route msg model = case msg of - Shared.Msg.ExampleMsgReplaceMe -> + Shared.Msg.NoOp -> ( model , Effect.none ) diff --git a/projects/cli/src/templates/_elm-land/customizable/Shared/Msg.elm b/projects/cli/src/templates/_elm-land/customizable/Shared/Msg.elm index 34b98b55..cccb82df 100644 --- a/projects/cli/src/templates/_elm-land/customizable/Shared/Msg.elm +++ b/projects/cli/src/templates/_elm-land/customizable/Shared/Msg.elm @@ -11,4 +11,4 @@ own file, so they can be imported by `Effect.elm` -} type Msg - = ExampleMsgReplaceMe + = NoOp diff --git a/projects/cli/src/validate/src/Worker.elm b/projects/cli/src/validate/src/Worker.elm index 324d8bf1..5bfd6a9e 100644 --- a/projects/cli/src/validate/src/Worker.elm +++ b/projects/cli/src/validate/src/Worker.elm @@ -653,7 +653,7 @@ unexpectedAnnotationError { functionName, validAnnotations } options = type Msg - = DoNothing + = NoOp update : Msg -> Model -> ( Model, Cmd Msg )