From a27300b23aa6c406e0db4dbb1fed62671ed1a883 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Tue, 8 Dec 2020 19:30:35 +0100 Subject: [PATCH 1/5] Migrate to GitHub Actions --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f449de1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 + run: npm run-script build + + - name: Run tests + run: | + bower install + npm run-script test --if-present From 495424aec79a05c8bebf71e5b490b97cd0602f1b Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Tue, 8 Dec 2020 19:42:58 +0100 Subject: [PATCH 2/5] Add package.json and update README --- .gitignore | 9 ++++----- README.md | 16 ++++++++++++++++ package.json | 13 +++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 20e090a..43d1621 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ +/.* +!/.gitignore +!/.github/ +package-lock.json /bower_components/ /node_modules/ -/.pulp-cache/ /output/ /generated-docs/ -/.psc-package/ -/.psc* -/.purs* -/.psa* diff --git a/README.md b/README.md index e21f9c0..c6a2d56 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/package.json b/package.json new file mode 100644 index 0000000..1c67b54 --- /dev/null +++ b/package.json @@ -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" + } +} From 0387fd769c16fbbd8576696ce9a8cb9470cdde16 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Tue, 8 Dec 2020 19:43:48 +0100 Subject: [PATCH 3/5] Add eslintrc --- .eslintrc.json | 29 +++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 30 insertions(+) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..cb9c786 --- /dev/null +++ b/.eslintrc.json @@ -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"] + } +} diff --git a/.gitignore b/.gitignore index 43d1621..a56845c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.* !/.gitignore +!/.eslintrc.json !/.github/ package-lock.json /bower_components/ From b2977cd8702d3bea57919f04145dbe1997e5941d Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Tue, 8 Dec 2020 19:56:37 +0100 Subject: [PATCH 4/5] Fix ESLint errors --- .eslintrc.json | 2 +- src/Web/Fetch.js | 2 ++ src/Web/Fetch/AbortController.js | 4 +++- src/Web/Fetch/Headers.js | 14 +++++++------- src/Web/Fetch/Request.js | 4 +++- src/Web/Fetch/RequestBody.js | 4 +++- src/Web/Fetch/Response.js | 4 +++- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index cb9c786..2322c4d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -24,6 +24,6 @@ "radix": [2, "always"], "indent": [2, 2], "quotes": [2, "double"], - "semi": [2, "always"] + "semi": [2, "always", { "omitLastInOneLineBlock": true }] } } diff --git a/src/Web/Fetch.js b/src/Web/Fetch.js index a83f153..3fc8e95 100644 --- a/src/Web/Fetch.js +++ b/src/Web/Fetch.js @@ -1,3 +1,5 @@ +"use strict"; + exports._fetch = function(a, b) { return fetch(a, b); }; diff --git a/src/Web/Fetch/AbortController.js b/src/Web/Fetch/AbortController.js index d77c3e9..2d2b61a 100644 --- a/src/Web/Fetch/AbortController.js +++ b/src/Web/Fetch/AbortController.js @@ -1,3 +1,5 @@ +"use strict"; + exports.new = function() { return new AbortController(); }; @@ -10,4 +12,4 @@ exports.abort = function(controller) { exports.signal = function(controller) { return controller.signal; -}; \ No newline at end of file +}; diff --git a/src/Web/Fetch/Headers.js b/src/Web/Fetch/Headers.js index 2a3c76e..3a54d9a 100644 --- a/src/Web/Fetch/Headers.js +++ b/src/Web/Fetch/Headers.js @@ -1,3 +1,5 @@ +"use strict"; + exports.unsafeNew = function() { return new Headers(); }; @@ -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); -}; \ No newline at end of file +}; diff --git a/src/Web/Fetch/Request.js b/src/Web/Fetch/Request.js index 2b18702..1c37d69 100644 --- a/src/Web/Fetch/Request.js +++ b/src/Web/Fetch/Request.js @@ -1,3 +1,5 @@ +"use strict"; + exports._unsafeNew = function(url, options) { try { return new Request(url, options); @@ -5,4 +7,4 @@ exports._unsafeNew = function(url, options) { console.error(e); throw e; } -}; \ No newline at end of file +}; diff --git a/src/Web/Fetch/RequestBody.js b/src/Web/Fetch/RequestBody.js index 7a7a717..6c436b4 100644 --- a/src/Web/Fetch/RequestBody.js +++ b/src/Web/Fetch/RequestBody.js @@ -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; \ No newline at end of file +exports.empty = null; diff --git a/src/Web/Fetch/Response.js b/src/Web/Fetch/Response.js index decb2c9..121883a 100644 --- a/src/Web/Fetch/Response.js +++ b/src/Web/Fetch/Response.js @@ -1,3 +1,5 @@ +"use strict"; + exports.headers = function (resp) { return resp.headers; }; @@ -44,4 +46,4 @@ exports.text = function (resp) { return function() { return resp.text(); }; -}; \ No newline at end of file +}; From 0c605ab495c32f549e5ae166564ae1552914d70c Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Tue, 8 Dec 2020 21:58:19 +0100 Subject: [PATCH 5/5] Add newline between the install and build jobs --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f449de1..063845e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,7 @@ jobs: npm install -g bower npm install bower install --production + - name: Build source run: npm run-script build