Upgrade everything to 0.18

This commit is contained in:
Richard Feldman
2016-12-11 15:07:00 -08:00
parent 80dbde12b4
commit 7fc5118626
24 changed files with 69 additions and 84 deletions

View File

@@ -6,14 +6,12 @@ have everything set up properly.
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.App as Html
import Auth import Auth
import Http import Http
import Task exposing (Task)
import Json.Decode exposing (Decoder) import Json.Decode exposing (Decoder)
main : Program Never main : Program Never Model Msg
main = main =
Html.program Html.program
{ view = view { view = view
@@ -35,10 +33,13 @@ type alias Model =
searchFeed : Cmd Msg searchFeed : Cmd Msg
searchFeed = searchFeed =
Auth.token let
|> (++) "https://api.github.com/search/repositories?q=test&access_token=" url =
|> Http.get (Json.Decode.succeed "") "https://api.github.com/search/repositories?q=test&access_token=" ++ Auth.token
|> Task.perform ItFailed (\_ -> ItWorked) in
Json.Decode.succeed ()
|> Http.get url
|> Http.send Response
view : Model -> Html Msg view : Model -> Html Msg
@@ -57,17 +58,16 @@ view model =
type Msg type Msg
= ItWorked = Response (Result Http.Error ())
| ItFailed Http.Error
update : Msg -> Model -> ( Model, Cmd Msg ) update : Msg -> Model -> ( Model, Cmd Msg )
update msg model = update msg model =
case msg of case msg of
ItWorked -> Response (Ok ()) ->
( { status = "You're all set!" }, Cmd.none ) ( { status = "You're all set!" }, Cmd.none )
ItFailed err -> Response (Err err) ->
let let
status = status =
case err of case err of
@@ -77,18 +77,21 @@ update msg model =
Http.NetworkError -> Http.NetworkError ->
"Network error. Check your Internet connection?" "Network error. Check your Internet connection?"
Http.UnexpectedPayload msg -> Http.BadUrl url ->
"Invalid test URL: " ++ url
Http.BadPayload msg _ ->
"Something is misconfigured: " ++ msg "Something is misconfigured: " ++ msg
Http.BadResponse code msg -> Http.BadStatus { status } ->
case code of case status.code of
401 -> 401 ->
"Auth.elm does not have a valid token. :( Try recreating Auth.elm by following the steps in the README under the section Create a GitHub Personal Access Token." "Auth.elm does not have a valid token. :( Try recreating Auth.elm by following the steps in the README under the section Create a GitHub Personal Access Token."
_ -> _ ->
"GitHub's Search API returned an error: " "GitHub's Search API returned an error: "
++ (toString code) ++ (toString status.code)
++ " " ++ " "
++ msg ++ status.message
in in
( { status = status }, Cmd.none ) ( { status = status }, Cmd.none )

View File

@@ -3,7 +3,7 @@ Getting Started
## Installation ## Installation
1. Install [Node.js](http://nodejs.org) 4.0.0 or higher 1. Install [Node.js](http://nodejs.org) 6.9.2 or higher
2. Add a plugin for your editor of choice: [Atom](https://atom.io/packages/language-elm), [Sublime Text](https://packagecontrol.io/packages/Elm%20Language%20Support), [VS Code](https://github.com/sbrink/vscode-elm), [Light Table](https://github.com/rundis/elm-light), [Vim](https://github.com/lambdatoast/elm.vim), [Emacs](https://github.com/jcollard/elm-mode), [Brackets](https://github.com/lepinay/elm-brackets) 2. Add a plugin for your editor of choice: [Atom](https://atom.io/packages/language-elm), [Sublime Text](https://packagecontrol.io/packages/Elm%20Language%20Support), [VS Code](https://github.com/sbrink/vscode-elm), [Light Table](https://github.com/rundis/elm-light), [Vim](https://github.com/lambdatoast/elm.vim), [Emacs](https://github.com/jcollard/elm-mode), [Brackets](https://github.com/lepinay/elm-brackets)
@@ -12,12 +12,9 @@ Getting Started
4. Run the following command to install everything else: 4. Run the following command to install everything else:
```bash ```bash
npm install -g elm elm-test elm-css elm-live@2.5.0 npm install -g elm elm-test elm-css elm-live@2.6.1
``` ```
**Note to macOS users:** If step 4 gives you an `EACCESS` error, try [this fix](https://docs.npmjs.com/getting-started/fixing-npm-permissions):
**Note to Windows 10 users running Bash:** There is [a bug in Windows Bash](https://github.com/Microsoft/BashOnWindows/issues/307) which will mess up the installers. This does not affect the normal Windows terminal, so if you use it instead of Windows Bash, you should be fine!
**Note to OS X users:** If step 4 gives you an `EACCESS` error on OS X, try [this fix](https://docs.npmjs.com/getting-started/fixing-npm-permissions):
``` ```

View File

@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value) import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
import Html.Events exposing (..) import Html.Events exposing (..)
import Html.App as Html
import Auth import Auth
import Json.Decode exposing (Decoder) import Json.Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (..) import Json.Decode.Pipeline exposing (..)

View File

@@ -1,10 +1,10 @@
module Main exposing (main) module Main exposing (main)
import ElmHub import ElmHub
import Html.App as Html import Html
main : Program Never main : Program Never ElmHub.Model ElmHub.Msg
main = main =
Html.program Html.program
{ view = ElmHub.view { view = ElmHub.view

View File

@@ -37,4 +37,4 @@ Then visit [localhost:8000](http://localhost:8000) and choose `HtmlRunner.elm`.
## References ## References
* [Html.map](http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html-App#map) * [Html.map](http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html#map)

View File

@@ -6,11 +6,11 @@ import Test.Runner.Html as Runner
-- To run this: -- To run this:
-- --
-- cd into part8/test -- cd into part10/test
-- elm-reactor -- elm-reactor
-- navigate to HtmlRunner.elm -- navigate to HtmlRunner.elm
main : Program Never main : Program Never Model Msg
main = main =
Runner.run Tests.all Runner.run Tests.all

View File

@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value) import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
import Html.Events exposing (..) import Html.Events exposing (..)
import Html.App as Html
import Auth import Auth
import Json.Decode exposing (Decoder) import Json.Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (..) import Json.Decode.Pipeline exposing (..)

View File

@@ -1,10 +1,10 @@
module Main exposing (main) module Main exposing (main)
import ElmHub import ElmHub
import Html.App as Html import Html
main : Program Never main : Program Never ElmHub.Model ElmHub.Msg
main = main =
Html.program Html.program
{ view = ElmHub.view { view = ElmHub.view

View File

@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value) import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
import Html.Events exposing (..) import Html.Events exposing (..)
import Html.App as Html
import Html.Lazy exposing (lazy, lazy3) import Html.Lazy exposing (lazy, lazy3)
import Auth import Auth
import Json.Decode exposing (Decoder) import Json.Decode exposing (Decoder)

View File

@@ -1,10 +1,10 @@
module Main exposing (main) module Main exposing (main)
import ElmHub import ElmHub
import Html.App as Html import Html
main : Program Never main : Program Never ElmHub.Model ElmHub.Msg
main = main =
Html.program Html.program
{ view = ElmHub.view { view = ElmHub.view

View File

@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value) import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
import Html.Events exposing (..) import Html.Events exposing (..)
import Html.App as Html
import Html.Lazy exposing (lazy, lazy3) import Html.Lazy exposing (lazy, lazy3)
import Auth import Auth
import Json.Decode exposing (Decoder) import Json.Decode exposing (Decoder)

View File

@@ -1,10 +1,10 @@
module Main exposing (main) module Main exposing (main)
import ElmHub import ElmHub
import Html.App as Html import Html
main : Program Never main : Program Never ElmHub.Model ElmHub.Msg
main = main =
Html.program Html.program
{ view = ElmHub.view { view = ElmHub.view

View File

@@ -3,7 +3,6 @@ port module Stylesheets exposing (..)
import Css.File exposing (..) import Css.File exposing (..)
import ElmHubCss import ElmHubCss
import Html exposing (div) import Html exposing (div)
import Html.App as Html
port files : CssFileStructure -> Cmd msg port files : CssFileStructure -> Cmd msg
@@ -14,7 +13,7 @@ cssFiles =
toFileStructure [ ( "style.css", compile [ ElmHubCss.css ] ) ] toFileStructure [ ( "style.css", compile [ ElmHubCss.css ] ) ]
main : Program Never main : Program Never Model Msg
main = main =
Html.program Html.program
{ init = ( (), files cssFiles ) { init = ( (), files cssFiles )

View File

@@ -3,7 +3,7 @@ port module ElmHub exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value) import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
import Html.Events exposing (..) import Html.Events exposing (..)
import Html.App as Html
import Html.Lazy exposing (lazy, lazy3) import Html.Lazy exposing (lazy, lazy3)
import Auth import Auth
import Json.Decode exposing (Decoder) import Json.Decode exposing (Decoder)

View File

@@ -1,10 +1,10 @@
module Main exposing (main) module Main exposing (main)
import ElmHub import ElmHub
import Html.App as Html import Html
main : Program Never main : Program Never ElmHub.Model ElmHub.Msg
main = main =
Html.program Html.program
{ view = ElmHub.view { view = ElmHub.view

View File

@@ -3,7 +3,7 @@ port module Stylesheets exposing (..)
import Css.File exposing (..) import Css.File exposing (..)
import ElmHubCss import ElmHubCss
import Html exposing (div) import Html exposing (div)
import Html.App as Html
port files : CssFileStructure -> Cmd msg port files : CssFileStructure -> Cmd msg
@@ -13,7 +13,7 @@ cssFiles =
toFileStructure [ ( "style.css", compile [ ElmHubCss.css ] ) ] toFileStructure [ ( "style.css", compile [ ElmHubCss.css ] ) ]
main : Program Never main : Program Never Model Msg
main = main =
Html.program Html.program
{ init = ( (), files cssFiles ) { init = ( (), files cssFiles )

View File

@@ -1,7 +1,6 @@
module Main exposing (..) module Main exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)

View File

@@ -1,7 +1,6 @@
module Main exposing (..) module Main exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)

View File

@@ -1,7 +1,6 @@
module Main exposing (..) module Main exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput) import Html.Events exposing (onClick, onInput)
@@ -98,7 +97,7 @@ update msg model =
model model
main : Program Never main : Program Never Model Msg
main = main =
Html.beginnerProgram Html.beginnerProgram
{ view = view { view = view

View File

@@ -1,7 +1,6 @@
module Main exposing (..) module Main exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (class, target, href, property, defaultValue) import Html.Attributes exposing (class, target, href, property, defaultValue)
import Html.Events exposing (..) import Html.Events exposing (..)
import Json.Decode exposing (..) import Json.Decode exposing (..)
@@ -9,7 +8,7 @@ import Json.Decode.Pipeline exposing (..)
import SampleResponse import SampleResponse
main : Program Never main : Program Never Model Msg
main = main =
Html.beginnerProgram Html.beginnerProgram
{ view = view { view = view

View File

@@ -5,13 +5,11 @@ import Html exposing (..)
import Html.Attributes exposing (class, target, href, property, defaultValue) import Html.Attributes exposing (class, target, href, property, defaultValue)
import Html.Events exposing (..) import Html.Events exposing (..)
import Http import Http
import Html.App as Html
import Task exposing (Task)
import Json.Decode exposing (Decoder) import Json.Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (..) import Json.Decode.Pipeline exposing (..)
main : Program Never main : Program Never Model Msg
main = main =
Html.program Html.program
{ view = view { view = view
@@ -32,17 +30,13 @@ searchFeed query =
++ "+language:elm&sort=stars&order=desc" ++ "+language:elm&sort=stars&order=desc"
-- HINT: responseDecoder may be useful here. -- HINT: responseDecoder may be useful here.
task = request =
"TODO replace this String with a Task using http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#get" "TODO replace this String with a Request built using http://package.elm-lang.org/packages/elm-lang/http/latest/Http#get"
in in
-- TODO replace this Cmd.none with a call to Task.perform -- TODO replace this Cmd.none with a call to Http.send
-- http://package.elm-lang.org/packages/elm-lang/core/latest/Task#perform -- http://package.elm-lang.org/packages/elm-lang/http/latest/Http#send
-- --
-- HINT: pass these to Task.perform, but in a different order than this! -- HINT: request and HandleSearchResponse may be useful here.
--
-- task
-- HandleSearchResponse
-- HandleSearchError
Cmd.none Cmd.none
@@ -120,8 +114,7 @@ type Msg
= Search = Search
| SetQuery String | SetQuery String
| DeleteById Int | DeleteById Int
| HandleSearchResponse (List SearchResult) | HandleSearchResponse (Result Http.Error (List SearchResult))
| HandleSearchError Http.Error
update : Msg -> Model -> ( Model, Cmd Msg ) update : Msg -> Model -> ( Model, Cmd Msg )
@@ -130,21 +123,23 @@ update msg model =
Search -> Search ->
( model, searchFeed model.query ) ( model, searchFeed model.query )
HandleSearchResponse results -> HandleSearchResponse result ->
( { model | results = results }, Cmd.none ) case result of
Ok results ->
( { model | results = results }, Cmd.none )
HandleSearchError error -> Err error ->
-- TODO if decoding failed, store the message in model.errorMessage -- TODO if decoding failed, store the message in model.errorMessage
-- --
-- HINT 1: Remember, model.errorMessage is a Maybe String - so it -- HINT 1: Remember, model.errorMessage is a Maybe String - so it
-- can only be set to either Nothing or (Just "some string here") -- can only be set to either Nothing or (Just "some string here")
-- --
-- Hint 2: look for "decode" in the documentation for this union type: -- Hint 2: look for "decode" in the documentation for this union type:
-- http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#Error -- http://package.elm-lang.org/packages/elm-lang/http/latest/Http#Error
-- --
-- Hint 3: to check if this is working, break responseDecoder -- Hint 3: to check if this is working, break responseDecoder
-- by changing "stargazers_count" to "description" -- by changing "stargazers_count" to "description"
( model, Cmd.none ) ( model, Cmd.none )
SetQuery query -> SetQuery query ->
( { model | query = query }, Cmd.none ) ( { model | query = query }, Cmd.none )

View File

@@ -1,6 +1,5 @@
port module Main exposing (..) port module Main exposing (..)
import Html.App as Html
import Json.Decode exposing (..) import Json.Decode exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (class, target, href, property, defaultValue) import Html.Attributes exposing (class, target, href, property, defaultValue)
@@ -10,7 +9,7 @@ import Json.Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (..) import Json.Decode.Pipeline exposing (..)
main : Program Never main : Program Never Model Msg
main = main =
Html.program Html.program
{ view = view { view = view

View File

@@ -1,10 +1,10 @@
module Main exposing (main) module Main exposing (main)
import ElmHub import ElmHub
import Html.App as Html import Html
main : Program Never main : Program Never ElmHub.Model ElmHub.Msg
main = main =
Html.program Html.program
{ view = ElmHub.view { view = ElmHub.view

View File

@@ -6,11 +6,11 @@ import Test.Runner.Html as Runner
-- To run this: -- To run this:
-- --
-- cd into part8/test -- cd into part9/test
-- elm-reactor -- elm-reactor
-- navigate to HtmlRunner.elm -- navigate to HtmlRunner.elm
main : Program Never main : Program Never Model Msg
main = main =
Runner.run Tests.all Runner.run Tests.all