Skip to content

feat: migrate to spago@next #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Bug report
about: Report an issue
title: ""
labels: bug
assignees: ""
---

**Describe the bug**
A clear and concise description of the bug.

**To Reproduce**
A minimal code example (preferably a runnable example on [Try PureScript](https://try.purescript.org)!) or steps to reproduce the issue.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/change-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Change request
about: Propose an improvement to this library
title: ""
labels: ""
assignees: ""
---

**Is your change request related to a problem? Please describe.**
A clear and concise description of the problem.

Examples:

- It's frustrating to have to [...]
- I was looking for a function to [...]

**Describe the solution you'd like**
A clear and concise description of what a good solution to you looks like, including any solutions you've already considered.

**Additional context**
Add any other context about the change request here.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: PureScript Discourse
url: https://discourse.purescript.org/
about: Ask and answer questions on the PureScript discussion forum.
- name: PureScript Discord
url: https://purescript.org/chat
about: Ask and answer questions on the PureScript chat.
11 changes: 11 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**Description of the change**
Clearly and concisely describe the purpose of the pull request. If this PR relates to an existing issue or change proposal, please link to it. Include any other background context that would help reviewers understand the motivation for this PR.

---

**Checklist:**

- [ ] Added the change to the changelog's "Unreleased" section with a link to this PR and your username
- [ ] Linked any existing issues or proposals that this pull request should close
- [ ] Updated or added relevant documentation in the README and/or documentation directory
- [ ] Added a test for the contribution (if applicable)
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up a PureScript toolchain
uses: purescript-contrib/setup-purescript@main
with:
purescript: "latest"
purs-tidy: "latest"
spago: "unstable"

- name: Cache PureScript dependencies
uses: actions/cache@v4
with:
key: ${{ runner.os }}-spago-${{ hashFiles('**/spago.lock') }}
path: |
.spago
output

- name: Build source
run: spago build --censor-stats --strict --ensure-ranges --pedantic-packages

- name: Run tests
run: spago test --offline --censor-stats --strict --pedantic-packages

- name: Verify formatting
run: purs-tidy check src test
25 changes: 0 additions & 25 deletions .github/workflows/node.js.yml

This file was deleted.

51 changes: 0 additions & 51 deletions bower.json

This file was deleted.

9,599 changes: 1,933 additions & 7,666 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 8 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -5,20 +5,16 @@
"main": "index.js",
"module": "true",
"dependencies": {
"react": "^18.1.0",
"react-dom": "^18.1.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^14.2.0",
"bower": "^1.8.14",
"global-jsdom": "^8.4.0",
"jsdom": "^19.0.0",
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^14.6.1",
"global-jsdom": "^26.0.0",
"jsdom": "^26.0.0",
"jsdom-global": "^3.0.2",
"npm-run-all": "^4.1.5",
"pulp": "^16.0.1",
"purescript": "^0.15.2",
"spago": "^0.20.9"
"npm-run-all": "^4.1.5"
},
"scripts": {
"deps": "run-s deps:*",
@@ -41,4 +37,4 @@
"url": "https://github.com/spicydonuts/purescript-react-basic-hooks/issues"
},
"homepage": "https://github.com/spicydonuts/purescript-react-basic-hooks#readme"
}
}
31 changes: 0 additions & 31 deletions packages.dhall

This file was deleted.

38 changes: 0 additions & 38 deletions spago.dhall

This file was deleted.

1,932 changes: 1,932 additions & 0 deletions spago.lock

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions spago.test.dhall

This file was deleted.

62 changes: 62 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package:
name: react-basic-hooks
publish:
license: Apache-2.0
version: 8.2.0
location:
githubOwner: megamaddu
githubRepo: purescript-react-basic-hooks
dependencies:
- aff: ">=8.0.0 <9.0.0"
- aff-promise: ">=4.0.0 <5.0.0"
- bifunctors: ">=6.0.0 <7.0.0"
- console: ">=6.1.0 <7.0.0"
- control: ">=6.0.0 <7.0.0"
- datetime: ">=6.1.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
- either: ">=6.1.0 <7.0.0"
- exceptions: ">=6.1.0 <7.0.0"
- foldable-traversable: ">=6.0.0 <7.0.0"
- functions: ">=6.0.0 <7.0.0"
- indexed-monad: ">=3.0.0 <4.0.0"
- integers: ">=6.0.0 <7.0.0"
- maybe: ">=6.0.0 <7.0.0"
- newtype: ">=5.0.0 <6.0.0"
- now: ">=6.0.0 <7.0.0"
- nullable: ">=6.0.0 <7.0.0"
- ordered-collections: ">=3.2.0 <4.0.0"
- prelude: ">=6.0.2 <7.0.0"
- react-basic: ">=17.0.0 <18.0.0"
- refs: ">=6.0.0 <7.0.0"
- tuples: ">=7.0.0 <8.0.0"
- type-equality: ">=4.0.1 <5.0.0"
- unsafe-coerce: ">=6.0.0 <7.0.0"
- unsafe-reference: ">=5.0.0 <6.0.0"
- web-html: ">=4.1.0 <5.0.0"
test:
main: Test.Main
dependencies:
- console
- effect
- react-testing-library
- react-basic
- react-basic-dom
- spec-discovery
workspace:
extraPackages:
# react-basic:
# git: https://github.com/purescript-react/purescript-react-basic
# ref: master
# # path: /home/srghma/projects/purescript-react-basic
# react-basic-dom:
# git: https://github.com/purescript-react/purescript-react-basic-dom
# ref: master
# # path: /home/srghma/projects/purescript-react-basic-dom
react-testing-library:
# git: https://github.com/i-am-the-slime/purescript-react-testing-library
# ref: master
git: https://github.com/srghma/purescript-react-testing-library
ref: update
# path: /home/srghma/projects/purescript-react-testing-library
packageSet:
registry: 63.6.0
4 changes: 2 additions & 2 deletions src/React/Basic/Hooks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import * as React from "react";

const useEqCache = (eq, a) => {
const memoRef = React.useRef(a);
@@ -105,4 +105,4 @@ export function displayName(component) {
return typeof component === "string"
? component
: component.displayName || "[unknown]";
}
}
34 changes: 16 additions & 18 deletions src/React/Basic/Hooks/ErrorBoundary.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import React from "react";
import * as React from "react";

export function errorBoundary_(name) {
return () => {
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { error: null };
}
render() {
return this.props.render({
error: this.state.error,
dismissError: () => this.setState({ error: null })
});
}
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { error: null };
}
ErrorBoundary.displayName = name;
ErrorBoundary.getDerivedStateFromError = (error) => ({ error });
return ErrorBoundary;
};
}
render() {
return this.props.render({
error: this.state.error,
dismissError: () => this.setState({ error: null })
});
}
}
ErrorBoundary.displayName = name;
ErrorBoundary.getDerivedStateFromError = (error) => ({ error });
return ErrorBoundary;
}
37 changes: 19 additions & 18 deletions src/React/Basic/Hooks/ErrorBoundary.purs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ module React.Basic.Hooks.ErrorBoundary
) where

import Prelude
import Effect.Uncurried (EffectFn1, runEffectFn1)
import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toMaybe)
import Effect (Effect)
@@ -12,14 +13,14 @@ import React.Basic.Hooks (JSX, ReactComponent, element)
--| Create a React error boundary with the given name. The resulting
--| component takes a render callback which exposes the error if one
--| exists and an effect for dismissing the error.
mkErrorBoundary ::
String ->
Effect
( ({ error :: Maybe Error, dismissError :: Effect Unit } -> JSX) ->
JSX
)
mkErrorBoundary
:: String
-> Effect
( ({ error :: Maybe Error, dismissError :: Effect Unit } -> JSX)
-> JSX
)
mkErrorBoundary name = do
c <- errorBoundary_ name
c <- runEffectFn1 errorBoundary_ name
pure $ element c <<< mapProps
where
mapProps render =
@@ -28,14 +29,14 @@ mkErrorBoundary name = do
render { error: toMaybe error, dismissError }
}

foreign import errorBoundary_ ::
String ->
Effect
( ReactComponent
{ render ::
{ error :: Nullable Error
, dismissError :: Effect Unit
} ->
JSX
}
)
foreign import errorBoundary_
:: EffectFn1
String
( ReactComponent
{ render ::
{ error :: Nullable Error
, dismissError :: Effect Unit
}
-> JSX
}
)
4 changes: 1 addition & 3 deletions src/React/Basic/Hooks/Suspense.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import React from "react";

export const suspense_ = React.Suspense;
export { Suspense as suspense_ } from "react"
24 changes: 4 additions & 20 deletions test/Main.purs
Original file line number Diff line number Diff line change
@@ -2,25 +2,9 @@ module Test.Main where

import Prelude

import Data.Maybe (Maybe(..))
import Data.Time.Duration (Seconds(..), fromDuration)
import Effect (Effect)
import Effect.Aff (delay, launchAff_)
import Test.Spec.Discovery (discover)
import Test.Spec.Reporter (consoleReporter)
import Test.Spec.Runner (defaultConfig, runSpec')
import Test.Spec.Discovery (discoverAndRunSpecs)
import Test.Spec.Reporter.Console (consoleReporter)

main Effect Unit
main = launchAff_ do
specs <- discover "\\.*Spec"
delay (1.0 # Seconds # fromDuration)
runSpec'
config
[ consoleReporter ]
specs
where
config =
defaultConfig
{ slow = 5.0 # Seconds # fromDuration
, timeout = Nothing
}
main :: Effect Unit
main = discoverAndRunSpecs [ consoleReporter ] "Test\\..*Spec"