Skip to content
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

Configure GitHub Actions #1

Merged
merged 5 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
29 changes: 29 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parserOptions": {
"ecmaVersion": 5
},
"extends": "eslint:recommended",
"env": {
"commonjs": true,
"browser": true
},
"rules": {
"strict": [2, "global"],
"block-scoped-var": 2,
"consistent-return": 2,
"eqeqeq": [2, "smart"],
"guard-for-in": 2,
"no-caller": 2,
"no-extend-native": 2,
"no-loop-func": 2,
"no-new": 2,
"no-param-reassign": 2,
"no-return-assign": 2,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"radix": [2, "always"],
"indent": [2, 2],
"quotes": [2, "double"],
"semi": [2, "always", { "omitLastInOneLineBlock": true }]
}
}
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

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

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

- uses: purescript-contrib/setup-purescript@main

- uses: actions/setup-node@v1
with:
node-version: "10"

- name: Install dependencies
run: |
npm install -g bower
npm install
bower install --production
- name: Build source
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps separate these two steps with a newline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damnit I’ve copy pasted the same poorly formatted in web-streams and web-encoding.

run: npm run-script build

- name: Run tests
run: |
bower install
npm run-script test --if-present
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/.*
!/.gitignore
!/.eslintrc.json
!/.github/
package-lock.json
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# purescript-web-fetch

[![Latest release](http://img.shields.io/github/release/purescript-web/purescript-web-fetch.svg)](https://github.com/purescript-web/purescript-web-fetch/releases)
[![Build status](https://github.com/purescript/purescript-web-fetch/workflows/CI/badge.svg?branch=master)](https://github.com/purescript/purescript-web-fetch/actions?query=workflow%3ACI+branch%3Amaster)
[![Pursuit](https://pursuit.purescript.org/packages/purescript-web-fetch/badge)](https://pursuit.purescript.org/packages/purescript-web-fetch)

Types and low-level implementations for the [WHATWG Fetch Living Standard](https://fetch.spec.whatwg.org/).

## Installation

```
spago install web-fetch
```

## Documentation

Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-web-fetch).
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict"
},
"devDependencies": {
"eslint": "^7.15.0",
"pulp": "^15.0.0",
"purescript-psa": "^0.8.0",
"rimraf": "^3.0.2"
}
}
2 changes: 2 additions & 0 deletions src/Web/Fetch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

exports._fetch = function(a, b) {
return fetch(a, b);
};
4 changes: 3 additions & 1 deletion src/Web/Fetch/AbortController.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

exports.new = function() {
return new AbortController();
};
Expand All @@ -10,4 +12,4 @@ exports.abort = function(controller) {

exports.signal = function(controller) {
return controller.signal;
};
};
14 changes: 7 additions & 7 deletions src/Web/Fetch/Headers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

exports.unsafeNew = function() {
return new Headers();
};
Expand All @@ -11,13 +13,11 @@ exports.unsafeFromRecord = function(r) {
};

exports._toArray = function(tuple, headers) {
var arr = [];
for (var pair of headers.entries()) {
arr.push(tuple(pair[0])(pair[1]));
}
return arr;
}
return Array.from(headers.entries(), function (pair) {
return tuple(pair[0])(pair[1]);
});
};

exports.fromObject = function(obj) {
return new Headers(obj);
};
};
4 changes: 3 additions & 1 deletion src/Web/Fetch/Request.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"use strict";

exports._unsafeNew = function(url, options) {
try {
return new Request(url, options);
} catch (e) {
console.error(e);
throw e;
}
};
};
4 changes: 3 additions & 1 deletion src/Web/Fetch/RequestBody.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

exports.fromArrayBuffer = function(a) { return a };
exports.fromArrayView = function(a) { return a };
exports.fromString = function(a) { return a };
exports.fromReadableStream = function(a) { return a };
exports.empty = null;
exports.empty = null;
4 changes: 3 additions & 1 deletion src/Web/Fetch/Response.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

exports.headers = function (resp) {
return resp.headers;
};
Expand Down Expand Up @@ -44,4 +46,4 @@ exports.text = function (resp) {
return function() {
return resp.text();
};
};
};