From 0b5cc30a88ee90f310e9d8982d3fa2fbcc6baf04 Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Wed, 5 Apr 2017 19:51:37 -0700 Subject: [PATCH] Updates for 0.11 (#84) * Updates for 0.11 * Add .travis.yml --- .gitignore | 1 + .travis.yml | 15 +++++++++++++++ README.md | 2 +- bower.json | 14 +++++++------- {docs => generated-docs}/Thermite.md | 0 package.json | 27 +++++++++++---------------- src/Thermite.purs | 5 ++--- test/Components/Task.purs | 2 +- test/Components/TaskList.purs | 7 +++++-- 9 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 .travis.yml rename {docs => generated-docs}/Thermite.md (100%) diff --git a/.gitignore b/.gitignore index 6008f4c..d3daad3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .* !/.bowerrc !/.gitignore +!/.travis.yml /output/ /node_modules/ /bower_components/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..78cde3d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: node_js +dist: trusty +sudo: required +node_js: 6 +install: + - npm install -g bower + - npm install + - bower install --production +script: + - npm run -s build +after_success: +- >- + test $TRAVIS_TAG && + echo $GITHUB_TOKEN | pulp login && + echo y | pulp publish --no-push diff --git a/README.md b/README.md index fde0073..892adda 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ `purescript-thermite` is a PureScript wrapper for [`purescript-react`](http://github.com/purescript-contrib/purescript-react). It does not provide all of the functionality of React, but instead to provide a clean API to the most commonly-used parts of its API. It is possible to use `purescript-react` for more specialized use cases. - [Try Thermite!](http://try.purescript.org/?backend=thermite) -- [Module Documentation](docs/) +- [Module Documentation](generated-docs/Thermite.md) - Example Project: [Code](test/), [Demo](http://functorial.com/purescript-thermite-todomvc/) ## Building diff --git a/bower.json b/bower.json index 5889e46..3249f03 100644 --- a/bower.json +++ b/bower.json @@ -16,12 +16,12 @@ "url": "git://github.com/paf31/purescript-thermite.git" }, "dependencies": { - "purescript-dom": "^3.1.0", - "purescript-profunctor-lenses": "^2.0.0", - "purescript-react": "^2.0.0", - "purescript-react-dom": "^2.0.0", - "purescript-freet": "^2.0.0", - "purescript-aff": "^2.0.0", - "purescript-coroutines": "^3.0.0" + "purescript-aff": "^3.0.0", + "purescript-coroutines": "^4.0.0", + "purescript-dom": "^4.0.0", + "purescript-freet": "^3.0.0", + "purescript-profunctor-lenses": "^3.0.0", + "purescript-react-dom": "^3.0.0", + "purescript-react": "^3.0.0" } } diff --git a/docs/Thermite.md b/generated-docs/Thermite.md similarity index 100% rename from docs/Thermite.md rename to generated-docs/Thermite.md diff --git a/package.json b/package.json index 7145cb8..2b9584c 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,18 @@ { - "name": "purescript-thermite", - "version": "1.0.0", - "description": "", + "private": true, "scripts": { - "pretest": "pulp build", - "test": "pulp test --runtime cat > html/index.js && open html/index.html" + "clean": "rimraf output && rimraf .pulp-cache", + "build": "pulp build -- --censor-lib --strict", + "example": "pulp test -r cat > html/index.js" }, - "repository": { - "type": "git", - "url": "git+https://github.com/paf31/purescript-thermite.git" - }, - "author": "", - "license": "MIT", - "bugs": { - "url": "https://github.com/paf31/purescript-thermite/issues" - }, - "homepage": "https://github.com/paf31/purescript-thermite#readme", - "devDependencies": { + "dependnecies": { "react": "^0.14.7", "react-dom": "^0.14.7" + }, + "devDependencies": { + "pulp": "^11.0.0", + "purescript-psa": "^0.5.0", + "purescript": "^0.11.1", + "rimraf": "^2.5.4" } } diff --git a/src/Thermite.purs b/src/Thermite.purs index 5b3b1f2..9ae0600 100644 --- a/src/Thermite.purs +++ b/src/Thermite.purs @@ -57,7 +57,6 @@ import Data.Lens (Prism', Lens', matching, view, review, preview, lens, over) import Data.List (List(..), (!!), modifyAt) import Data.Maybe (Maybe(Just), fromMaybe) import Data.Monoid (class Monoid) -import Data.Nullable (toMaybe) import Data.Tuple (Tuple(..)) import React (createFactory) import React.DOM (div') @@ -243,7 +242,7 @@ createReactSpec' wrap (Spec spec) = Right (CoTransform f k) -> do st <- liftEff (coerceEff (React.readState this)) let newState = f st - makeAff \_ k1 -> unsafeCoerceEff do + _ <- makeAff \_ k1 -> unsafeCoerceEff do void $ React.writeStateWithCallback this newState (unsafeCoerceEff (k1 newState)) pure (Loop (k (Just newState))) @@ -271,7 +270,7 @@ defaultMain defaultMain spec initialState props = void do let component = createClass spec initialState document <- DOM.window >>= DOM.document - container <- toMaybe <$> DOM.body document + container <- DOM.body document traverse_ (render (createFactory component props) <<< DOM.htmlElementToElement) container -- | This function captures the state of the `Spec` as a function argument. diff --git a/test/Components/Task.purs b/test/Components/Task.purs index d0a7c43..0cba7dd 100644 --- a/test/Components/Task.purs +++ b/test/Components/Task.purs @@ -52,6 +52,6 @@ taskSpec = T.simpleSpec performAction render performAction (ChangeCompleted b) _ _ = void do -- This is a test for issue #65. -- In practice, we only need one `modifyState` here. - T.modifyState id + _ <- T.modifyState id T.modifyState (_ { completed = b }) performAction _ _ _ = pure unit diff --git a/test/Components/TaskList.purs b/test/Components/TaskList.purs index fabee9f..f5378c4 100644 --- a/test/Components/TaskList.purs +++ b/test/Components/TaskList.purs @@ -87,8 +87,11 @@ taskList = container $ fold -- The `NewTask` action is handled here -- Everything else is handled by some other child component so is ignored here. performAction :: T.PerformAction eff TaskListState props TaskListAction - performAction (NewTask s) _ _ = void $ T.modifyState $ \state -> state { tasks = Cons (initialTask s) state.tasks } - performAction _ _ _ = pure unit + performAction (NewTask s) _ _ = void $ T.modifyState $ \state -> + state { tasks = Cons (initialTask s) state.tasks + , editText = "" + } + performAction _ _ _ = pure unit -- This function wraps a `Spec`'s `Render` function to filter out tasks. applyFilter :: forall action. Filter -> T.Spec eff Task props action -> T.Spec eff Task props action