Skip to content

Commit b33e284

Browse files
authored
feat: migrate to spago@next (#154)
* feat: update to spago@next * feat: update github ci * feat: purs-tidy * refactor: use lambdas * refactor: review changes
1 parent 074fc77 commit b33e284

15 files changed

+210
-150
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Bug report
3+
about: Report an issue
4+
title: ""
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of the bug.
11+
12+
**To Reproduce**
13+
A minimal code example (preferably a runnable example on [Try PureScript](https://try.purescript.org)!) or steps to reproduce the issue.
14+
15+
**Expected behavior**
16+
A clear and concise description of what you expected to happen.
17+
18+
**Additional context**
19+
Add any other context about the problem here.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Change request
3+
about: Propose an improvement to this library
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
**Is your change request related to a problem? Please describe.**
10+
A clear and concise description of the problem.
11+
12+
Examples:
13+
14+
- It's frustrating to have to [...]
15+
- I was looking for a function to [...]
16+
17+
**Describe the solution you'd like**
18+
A clear and concise description of what a good solution to you looks like, including any solutions you've already considered.
19+
20+
**Additional context**
21+
Add any other context about the change request here.

.github/ISSUE_TEMPLATE/config.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: PureScript Discourse
4+
url: https://discourse.purescript.org/
5+
about: Ask and answer questions on the PureScript discussion forum.
6+
- name: PureScript Discord
7+
url: https://purescript.org/chat
8+
about: Ask and answer questions on the PureScript chat.

.github/PULL_REQUEST_TEMPLATE.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**Description of the change**
2+
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.
3+
4+
---
5+
6+
**Checklist:**
7+
8+
- [ ] Added the change to the changelog's "Unreleased" section with a link to this PR and your username
9+
- [ ] Linked any existing issues or proposals that this pull request should close
10+
- [ ] Updated or added relevant documentation in the README and/or documentation directory
11+
- [ ] Added a test for the contribution (if applicable)

.github/workflows/ci.yml

+13-40
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,29 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
1312
steps:
14-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
1514

1615
- name: Set up PureScript toolchain
17-
uses: purescript-contrib/setup-purescript@v2.0.0
16+
uses: purescript-contrib/setup-purescript@main
1817
with:
19-
purescript: "0.15.0"
20-
purs-tidy: "latest"
18+
purescript: "latest"
19+
purs-tidy: "0.11.0" # "latest"
20+
spago: "unstable"
2121

2222
- name: Cache PureScript dependencies
23-
uses: actions/cache@v2
23+
uses: actions/cache@v4
2424
with:
25-
key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }}
25+
key: ${{ runner.os }}-spago-${{ hashFiles('**/spago.lock') }}
2626
path: |
2727
.spago
2828
output
29-
- name: Set up Node toolchain
30-
uses: actions/setup-node@v2
31-
with:
32-
node-version: "14.x"
33-
34-
- name: Cache NPM dependencies
35-
uses: actions/cache@v2
36-
env:
37-
cache-name: cache-node-modules
38-
with:
39-
path: ~/.npm
40-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
41-
restore-keys: |
42-
${{ runner.os }}-build-${{ env.cache-name }}-
43-
${{ runner.os }}-build-
44-
${{ runner.os }}-
45-
- name: Install NPM dependencies
46-
run: npm install
47-
48-
- name: Build the project
49-
run: npm run build
5029
51-
- name: Run tests
52-
run: npm run test
30+
- name: Build source
31+
run: spago build --censor-stats --strict --ensure-ranges --pedantic-packages
5332

54-
# - name: Check formatting
55-
# run: purs-tidy check src test
33+
# - name: Run tests
34+
# run: spago test --offline --censor-stats --strict --pedantic-packages
5635

57-
- name: Verify Bower & Pulp
58-
run: |
59-
npm install bower [email protected]
60-
npx bower install
61-
npx pulp build -- --censor-lib --strict
62-
if [ -d "test" ]; then
63-
npx pulp test
64-
fi
36+
- name: Verify formatting
37+
run: purs-tidy check src test

bower.json

-21
This file was deleted.

package.json

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414
},
1515
"homepage": "https://github.com/lumihq/purescript-react-basic#readme",
1616
"devDependencies": {
17-
"bower": "^1.8.14",
18-
"npm-run-all": "^4.1.5",
19-
"pulp": "^16.0.1",
20-
"purescript": "^0.15.0",
21-
"spago": "^0.20.9"
17+
"npm-run-all": "^4.1.5"
2218
},
2319
"dependencies": {
24-
"react": "^18.1.0"
20+
"react": "^19.0.0"
2521
},
2622
"scripts": {
2723
"build": "spago build",
2824
"clean": "rm -rf .spago bower_components output output-pulp node_modules"
2925
}
30-
}
26+
}

packages.dhall

-5
This file was deleted.

spago.dhall

-11
This file was deleted.

spago.lock

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"workspace": {
3+
"packages": {
4+
"react-basic": {
5+
"path": "./",
6+
"core": {
7+
"dependencies": [
8+
{
9+
"effect": ">=4.0.0 <5.0.0"
10+
},
11+
{
12+
"prelude": ">=6.0.2 <7.0.0"
13+
},
14+
{
15+
"record": ">=4.0.0 <5.0.0"
16+
}
17+
],
18+
"build_plan": [
19+
"effect",
20+
"functions",
21+
"prelude",
22+
"record",
23+
"unsafe-coerce"
24+
]
25+
},
26+
"test": {
27+
"dependencies": [],
28+
"build_plan": []
29+
}
30+
}
31+
},
32+
"extra_packages": {}
33+
},
34+
"packages": {
35+
"effect": {
36+
"type": "registry",
37+
"version": "4.0.0",
38+
"integrity": "sha256-eBtZu+HZcMa5HilvI6kaDyVX3ji8p0W9MGKy2K4T6+M=",
39+
"dependencies": [
40+
"prelude"
41+
]
42+
},
43+
"functions": {
44+
"type": "registry",
45+
"version": "6.0.0",
46+
"integrity": "sha256-adMyJNEnhGde2unHHAP79gPtlNjNqzgLB8arEOn9hLI=",
47+
"dependencies": [
48+
"prelude"
49+
]
50+
},
51+
"prelude": {
52+
"type": "registry",
53+
"version": "6.0.2",
54+
"integrity": "sha256-kiAPZxihtAel8uRiTNdccf4qylp/9J3jNkEHNAD0MsE=",
55+
"dependencies": []
56+
},
57+
"record": {
58+
"type": "registry",
59+
"version": "4.0.0",
60+
"integrity": "sha256-Za5U85bTRJEfGK5Sk4hM41oXy84YQI0I8TL3WUn1Qzg=",
61+
"dependencies": [
62+
"functions",
63+
"prelude",
64+
"unsafe-coerce"
65+
]
66+
},
67+
"unsafe-coerce": {
68+
"type": "registry",
69+
"version": "6.0.0",
70+
"integrity": "sha256-IqIYW4Vkevn8sI+6aUwRGvd87tVL36BBeOr0cGAE7t0=",
71+
"dependencies": []
72+
}
73+
}
74+
}

spago.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package:
2+
name: react-basic
3+
publish:
4+
license: Apache-2.0
5+
version: 17.0.0
6+
location:
7+
githubOwner: purescript-react
8+
githubRepo: purescript-react-basic
9+
dependencies:
10+
- effect: ">=4.0.0 <5.0.0"
11+
- prelude: ">=6.0.2 <7.0.0"
12+
- record: ">=4.0.0 <5.0.0"
13+
workspace: {}

src/React/Basic.js

+21-36
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,24 @@
1-
import React from "react";
2-
const createElement = React.createElement;
3-
const Fragment = React.Fragment;
1+
import * as React from "react";
42

53
export const empty = null;
64

7-
export function keyed(key) {
8-
return (child) =>
9-
createElement(Fragment, { key: key }, child);
10-
}
11-
12-
export function element(component) {
13-
return (props) =>
14-
Array.isArray(props.children)
15-
? createElement.apply(null, [component, props].concat(props.children))
16-
: createElement(component, props);
17-
}
18-
19-
export function elementKeyed(component) {
20-
return (props) =>
21-
createElement(component, props);
22-
}
23-
24-
export function fragment(children) {
25-
return createElement.apply(null, [Fragment, null].concat(children));
26-
}
27-
28-
export function createContext(defaultValue) {
29-
return () =>
30-
React.createContext(defaultValue);
31-
}
32-
33-
export function contextProvider(context) {
34-
return context.Provider;
35-
}
36-
37-
export function contextConsumer(context) {
38-
return context.Consumer;
39-
}
5+
export const keyed = (key) => (child) =>
6+
React.createElement(React.Fragment, { key: key }, child);
7+
8+
export const element = (component) => (props) =>
9+
Array.isArray(props.children)
10+
? React.createElement.apply(null, [component, props].concat(props.children))
11+
: React.createElement(component, props);
12+
13+
export const elementKeyed = (component) => (props) =>
14+
React.createElement(component, props);
15+
16+
export const fragment = (children) =>
17+
React.createElement.apply(null, [React.Fragment, null].concat(children));
18+
19+
export const createContext = (defaultValue) => () =>
20+
React.createContext(defaultValue);
21+
22+
export const contextProvider = (context) => context.Provider;
23+
24+
export const contextConsumer = (context) => context.Consumer;

0 commit comments

Comments
 (0)