Move to spago

This commit is contained in:
icyrockcom 2020-04-17 13:23:07 -04:00
parent a2f0cb8c4e
commit ec0a903f7d
13 changed files with 197 additions and 3185 deletions

8
.gitignore vendored
View File

@ -1,9 +1,7 @@
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
.psc-ide-pord
.purs-repl
/.spago

1
.psc-ide-port Normal file
View File

@ -0,0 +1 @@
15855

1
.purs-repl Normal file
View File

@ -0,0 +1 @@
import Prelude

View File

@ -8,19 +8,25 @@ Basic bindings for [cheerio](https://cheerio.js.org/). Only includes read-only f
Install [cheerio](https://www.npmjs.com/package/cheerio) dependency:
$ npm install --save cheerio
```bash
$ npm install --save cheerio
```
Install this package:
Install this package using [spago](https://github.com/purescript/spago):
* Using [bower](https://bower.io/):
* Add package to your `spago.dhall`:
$ bower install --save purescript-cheerio
```dhall
...
dependencies = [ ..., "cheerio" ]
...
```
* Using [psc-package](https://github.com/purescript/psc-package):
* Install packages by running:
$ psc-package install cheerio
You might need to set up a [custom package set](https://github.com/purescript/psc-package#add-a-package-to-the-package-set).
```bash
$ spago install
```
## Example
@ -28,29 +34,37 @@ From [basic example](examples/Basic.purs).
Imports:
import Cheerio (Cheerio, find, length)
import Cheerio.Static (loadRoot)
```purescript
import Cheerio (Cheerio, find, length)
import Cheerio.Static (loadRoot)
```
Example html:
htmlEx :: String
htmlEx = """
<ul id="fruits">
<li class="apple">Apple</li>
<li class="orange">Orange</li>
<li class="pear">Pear</li>
</ul>
"""
```purescript
htmlEx :: String
htmlEx = """
<ul id="fruits">
<li class="apple">Apple</li>
<li class="orange">Orange</li>
<li class="pear">Pear</li>
</ul>
"""
```
Load it and get the root element:
root :: Cheerio
root = loadRoot htmlEx
```purescript
root :: Cheerio
root = loadRoot htmlEx
```
Use the query functions:
let fruitCount = find "#fruits" root # length
in log $ "Number of fruits: " <> show fruitCount
```purescript
let fruitCount = root # find "#fruits" # find "li" # length
in log $ "Number of fruits: " <> show fruitCount
```
For more examples, please take a look at the [unit tests](test/Test/Main.purs). They cover most of the read-only cheerio functions.

View File

@ -18,13 +18,13 @@
"test",
"tests"
],
"dependencies": {
"purescript-console": "^4.2.0",
"purescript-effect": "^2.0.1",
"purescript-functions": "^4.0.0",
"purescript-prelude": "^4.1.1",
"purescript-test-unit": "^15.0.0"
},
"dependencies":
{ "purescript-console": "^4.4.0"
, "purescript-effect": "^2.0.1"
, "purescript-functions": "^4.0.0"
, "purescript-prelude": "^4.1.1"
, "purescript-test-unit": "^15.0.0"
},
"devDependencies": {
"purescript-psci-support": "^4.0.0"
}

View File

@ -4,8 +4,8 @@ import Prelude
import Cheerio (Cheerio, find, length)
import Cheerio.Static (loadRoot)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Effect (Effect)
import Effect.Console (log)
htmlEx :: String
htmlEx = """
@ -19,7 +19,7 @@ htmlEx = """
root :: Cheerio
root = loadRoot htmlEx
example :: forall eff. Eff (console :: CONSOLE | eff) Unit
example =
let fruitCount = find "#fruits" root # length
main :: Effect Unit
main =
let fruitCount = root # find "#fruits" # find "li" # length
in log $ "Number of fruits: " <> show fruitCount

3193
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
{
"name": "purescript-cheerio",
"version": "0.2.1",
"version": "0.2.2",
"description": "PureScript bindings for Cheerio",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "pulp test"
"test": "spago test"
},
"repository": {
"type": "git",
@ -20,8 +20,6 @@
},
"homepage": "https://github.com/icyrockcom/purescript-cheerio#readme",
"dependencies": {
"cheerio": "^1.0.0-rc.3",
"lodash": "^4.17.15",
"npm": "^6.12.1"
"cheerio": "^1.0.0-rc.3"
}
}

8
packages.dhall Normal file
View File

@ -0,0 +1,8 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.13.6-20200404/packages.dhall sha256:f239f2e215d0cbd5c203307701748581938f74c4c78f4aeffa32c11c131ef7b6
let overrides = {=}
let additions = {=}
in upstream // overrides // additions

View File

@ -1,13 +1,13 @@
{
"name": "purescript-cheerio",
"set": "psc-0.12.0-20180704",
"set": "psc-0.13.6-20200404",
"source": "https://github.com/purescript/package-sets.git",
"depends": [
"functions",
"test-unit",
"psci-support",
"console",
"effect",
"prelude"
]
"depends":
[ "console"
, "effect"
, "functions"
, "prelude"
, "psci-support"
, "test-unit"
]
}

12
spago.dhall Normal file
View File

@ -0,0 +1,12 @@
{ name = "purescript-cheerio"
, dependencies =
[ "console"
, "effect"
, "functions"
, "prelude"
, "psci-support"
, "test-unit"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}

View File

@ -1,20 +1,20 @@
module Cheerio (
Cheerio,
attr,
children,
eq,
first,
find,
hasClass,
html,
last,
length,
next,
parent,
prev,
siblings,
text,
toArray
module Cheerio
( Cheerio
, attr
, children
, eq
, first
, find
, hasClass
, html
, last
, length
, next
, parent
, prev
, siblings
, text
, toArray
) where
import Prelude hiding (eq)

View File

@ -1,11 +1,12 @@
module Cheerio.Static (
CheerioStatic,
html,
load,
loadRoot,
select,
selectDeep,
root) where
module Cheerio.Static
( CheerioStatic
, html
, load
, loadRoot
, select
, selectDeep
, root
) where
import Prelude
import Cheerio (Cheerio)