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/ /bower_components/
/node_modules/ /node_modules/
/.pulp-cache/
/output/ /output/
/generated-docs/ /generated-docs/
/.psc-package/ .psc-ide-pord
/.psc* .purs-repl
/.purs* /.spago
/.psa*

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: 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 ```bash
$ spago install
You might need to set up a [custom package set](https://github.com/purescript/psc-package#add-a-package-to-the-package-set). ```
## Example ## Example
@ -28,29 +34,37 @@ From [basic example](examples/Basic.purs).
Imports: Imports:
import Cheerio (Cheerio, find, length) ```purescript
import Cheerio.Static (loadRoot) import Cheerio (Cheerio, find, length)
import Cheerio.Static (loadRoot)
```
Example html: Example html:
htmlEx :: String ```purescript
htmlEx = """ htmlEx :: String
<ul id="fruits"> htmlEx = """
<li class="apple">Apple</li> <ul id="fruits">
<li class="orange">Orange</li> <li class="apple">Apple</li>
<li class="pear">Pear</li> <li class="orange">Orange</li>
</ul> <li class="pear">Pear</li>
""" </ul>
"""
```
Load it and get the root element: Load it and get the root element:
root :: Cheerio ```purescript
root = loadRoot htmlEx root :: Cheerio
root = loadRoot htmlEx
```
Use the query functions: Use the query functions:
let fruitCount = find "#fruits" root # length ```purescript
in log $ "Number of fruits: " <> show fruitCount 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. 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", "test",
"tests" "tests"
], ],
"dependencies": { "dependencies":
"purescript-console": "^4.2.0", { "purescript-console": "^4.4.0"
"purescript-effect": "^2.0.1", , "purescript-effect": "^2.0.1"
"purescript-functions": "^4.0.0", , "purescript-functions": "^4.0.0"
"purescript-prelude": "^4.1.1", , "purescript-prelude": "^4.1.1"
"purescript-test-unit": "^15.0.0" , "purescript-test-unit": "^15.0.0"
}, },
"devDependencies": { "devDependencies": {
"purescript-psci-support": "^4.0.0" "purescript-psci-support": "^4.0.0"
} }

View File

@ -4,8 +4,8 @@ import Prelude
import Cheerio (Cheerio, find, length) import Cheerio (Cheerio, find, length)
import Cheerio.Static (loadRoot) import Cheerio.Static (loadRoot)
import Control.Monad.Eff (Eff) import Effect (Effect)
import Control.Monad.Eff.Console (CONSOLE, log) import Effect.Console (log)
htmlEx :: String htmlEx :: String
htmlEx = """ htmlEx = """
@ -19,7 +19,7 @@ htmlEx = """
root :: Cheerio root :: Cheerio
root = loadRoot htmlEx root = loadRoot htmlEx
example :: forall eff. Eff (console :: CONSOLE | eff) Unit main :: Effect Unit
example = main =
let fruitCount = find "#fruits" root # length let fruitCount = root # find "#fruits" # find "li" # length
in log $ "Number of fruits: " <> show fruitCount 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", "name": "purescript-cheerio",
"version": "0.2.1", "version": "0.2.2",
"description": "PureScript bindings for Cheerio", "description": "PureScript bindings for Cheerio",
"main": "index.js", "main": "index.js",
"directories": { "directories": {
"test": "test" "test": "test"
}, },
"scripts": { "scripts": {
"test": "pulp test" "test": "spago test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -20,8 +20,6 @@
}, },
"homepage": "https://github.com/icyrockcom/purescript-cheerio#readme", "homepage": "https://github.com/icyrockcom/purescript-cheerio#readme",
"dependencies": { "dependencies": {
"cheerio": "^1.0.0-rc.3", "cheerio": "^1.0.0-rc.3"
"lodash": "^4.17.15",
"npm": "^6.12.1"
} }
} }

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", "name": "purescript-cheerio",
"set": "psc-0.12.0-20180704", "set": "psc-0.13.6-20200404",
"source": "https://github.com/purescript/package-sets.git", "source": "https://github.com/purescript/package-sets.git",
"depends": [ "depends":
"functions", [ "console"
"test-unit", , "effect"
"psci-support", , "functions"
"console", , "prelude"
"effect", , "psci-support"
"prelude" , "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 ( module Cheerio
Cheerio, ( Cheerio
attr, , attr
children, , children
eq, , eq
first, , first
find, , find
hasClass, , hasClass
html, , html
last, , last
length, , length
next, , next
parent, , parent
prev, , prev
siblings, , siblings
text, , text
toArray , toArray
) where ) where
import Prelude hiding (eq) import Prelude hiding (eq)

View File

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