From c881921d016b2e551d251f0dd3020fd5acd9b2cc Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Tue, 8 Dec 2020 22:22:57 -0800 Subject: [PATCH 1/3] Migrate to GitHub Actions and update installation instructions. --- .eslintrc.json | 28 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ .gitignore | 3 ++- .jshintrc | 19 ------------------- .travis.yml | 23 ----------------------- README.md | 5 +++-- package.json | 9 +++++---- 7 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .github/workflows/ci.yml delete mode 100644 .jshintrc delete mode 100644 .travis.yml diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..84cef4f --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,28 @@ +{ + "parserOptions": { + "ecmaVersion": 5 + }, + "extends": "eslint:recommended", + "env": { + "commonjs": 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/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..49aff92 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: push + +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 diff --git a/.gitignore b/.gitignore index b215c44..b846b63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.* !/.gitignore -!/.travis.yml +!/.eslintrc.json +!/.github/ /bower_components/ /node_modules/ /output/ diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index f391159..0000000 --- a/.jshintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "bitwise": true, - "eqeqeq": true, - "forin": true, - "freeze": true, - "funcscope": true, - "futurehostile": true, - "globalstrict": true, - "latedef": true, - "maxparams": 1, - "noarg": true, - "nocomma": true, - "nonew": true, - "notypeof": true, - "singleGroups": true, - "undef": true, - "unused": true, - "eqnull": true -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8daa38c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: node_js -dist: trusty -sudo: required -node_js: stable -env: - - PATH=$HOME/purescript:$PATH -install: - - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest)) - - curl --location --output $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz - - tar -xvf $HOME/purescript.tar.gz -C $HOME/ - - chmod a+x $HOME/purescript - - npm install -g bower - - npm install -script: - - bower install --production - - npm run -s build - - bower install - - npm -s test -after_success: -- >- - test $TRAVIS_TAG && - echo $GITHUB_TOKEN | pulp login && - echo y | pulp publish --no-push diff --git a/README.md b/README.md index d7375e6..b4aa50d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # purescript-node-buffer [![Latest release](http://img.shields.io/github/release/purescript-node/purescript-node-buffer.svg)](https://github.com/purescript-node/purescript-node-buffer/releases) -[![Build Status](https://travis-ci.org/purescript-node/purescript-node-buffer.svg?branch=master)](https://travis-ci.org/purescript-node/purescript-node-buffer) +[![Build status](https://github.com/purescript-node/purescript-node-buffer/workflows/CI/badge.svg?branch=master)](https://github.com/purescript-node/purescript-node-buffer/actions?query=workflow%3ACI+branch%3Amaster) +[![Pursuit](https://pursuit.purescript.org/packages/purescript-node-buffer/badge)](https://pursuit.purescript.org/packages/purescript-node-buffer) Type declarations and FFI wrappers for Node's [Buffer API](https://nodejs.org/api/buffer.html). ## Installation ``` -bower install purescript-node-buffer +spago install node-buffer ``` ## Documentation diff --git a/package.json b/package.json index 662374c..4984fb1 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "pulp build -- --censor-lib --strict", + "build": "eslint src && pulp build -- --censor-lib --strict", "test": "pulp test" }, "devDependencies": { - "pulp": "^12.2.0", - "purescript-psa": "^0.6.0", - "rimraf": "^2.6.2" + "eslint": "^7.15.0", + "pulp": "^15.0.0", + "purescript-psa": "^0.8.0", + "rimraf": "^3.0.2" } } From e36d38cbc59f1bfb75971e70c3268dc88751db86 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Wed, 9 Dec 2020 12:00:44 -0800 Subject: [PATCH 2/3] Update ci.yml --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49aff92..063845e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: CI -on: push +on: + push: + branches: [master] + pull_request: + branches: [master] jobs: build: From b37ddff210a968d6d4612b06d8ebb20b323976d5 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Wed, 9 Dec 2020 12:40:01 -0800 Subject: [PATCH 3/3] Apply eslint suggestions --- src/Node/Buffer/Immutable.js | 25 +++++++++++-------------- src/Node/Buffer/Internal.js | 21 ++++++++++----------- src/Node/Encoding.js | 1 - 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/Node/Buffer/Immutable.js b/src/Node/Buffer/Immutable.js index 7b1d72c..f962257 100644 --- a/src/Node/Buffer/Immutable.js +++ b/src/Node/Buffer/Immutable.js @@ -1,21 +1,19 @@ -/* global exports */ /* global Buffer */ -/* global require */ "use strict"; -exports.showImpl = require('util').inspect; +exports.showImpl = require("util").inspect; -exports.eqImpl = function(a) { - return function(b) { +exports.eqImpl = function (a) { + return function (b) { return a.equals(b); - } + }; }; -exports.compareImpl = function(a) { +exports.compareImpl = function (a) { return function (b) { return a.compare(b); }; -} +}; exports.create = function (size) { return Buffer.alloc(size); @@ -30,15 +28,15 @@ exports.size = function (buff) { }; exports.toArray = function (buff) { - var json = buff.toJSON() + var json = buff.toJSON(); return json.data || json; }; -exports.toArrayBuffer = function(buff) { +exports.toArrayBuffer = function (buff) { return buff.buffer.slice(buff.byteOffset, buff.byteOffset + buff.byteLength); }; -exports.fromArrayBuffer = function(ab) { +exports.fromArrayBuffer = function (ab) { return Buffer.from(ab); }; @@ -51,7 +49,7 @@ exports.fromStringImpl = function (str) { exports.readImpl = function (ty) { return function (offset) { return function (buf) { - return buf['read' + ty](offset); + return buf["read" + ty](offset); }; }; }; @@ -71,8 +69,7 @@ exports.getAtOffsetImpl = function (just) { return function (offset) { return function (buff) { var octet = buff[offset]; - return octet == null ? nothing - : just(octet); + return octet == null ? nothing : just(octet); }; }; }; diff --git a/src/Node/Buffer/Internal.js b/src/Node/Buffer/Internal.js index 7cd3cd9..81eee15 100644 --- a/src/Node/Buffer/Internal.js +++ b/src/Node/Buffer/Internal.js @@ -1,9 +1,8 @@ -/* global exports */ /* global Buffer */ "use strict"; -exports.copyAll = function(a) { - return function() { +exports.copyAll = function (a) { + return function () { return Buffer.from(a); }; }; @@ -12,10 +11,10 @@ exports.writeInternal = function (ty) { return function (value) { return function (offset) { return function (buf) { - return function() { - buf['write' + ty](value, offset); + return function () { + buf["write" + ty](value, offset); return {}; - } + }; }; }; }; @@ -26,9 +25,9 @@ exports.writeStringInternal = function (encoding) { return function (length) { return function (value) { return function (buff) { - return function() { + return function () { return buff.write(value, offset, length, encoding); - } + }; }; }; }; @@ -38,7 +37,7 @@ exports.writeStringInternal = function (encoding) { exports.setAtOffset = function (value) { return function (offset) { return function (buff) { - return function() { + return function () { buff[offset] = value; return {}; }; @@ -51,7 +50,7 @@ exports.copy = function (srcStart) { return function (src) { return function (targStart) { return function (targ) { - return function() { + return function () { return src.copy(targ, targStart, srcStart, srcEnd); }; }; @@ -64,7 +63,7 @@ exports.fill = function (octet) { return function (start) { return function (end) { return function (buf) { - return function() { + return function () { buf.fill(octet, start, end); return {}; }; diff --git a/src/Node/Encoding.js b/src/Node/Encoding.js index f3dbe47..aaa2166 100644 --- a/src/Node/Encoding.js +++ b/src/Node/Encoding.js @@ -1,4 +1,3 @@ -/* global exports */ /* global Buffer */ "use strict";