Skip to content

Commit

Permalink
Update Node.js support to 18-20 from 12-16, dependencies, documentati…
Browse files Browse the repository at this point in the history
…on, some practices (#19)

* Update name of repo for repository, homepage, bugs

* Remove unused Grunt task 'ci'

* Update sinon to 16 from 1.7, to fix circular dependency warnings involving fakeServer

* Use github: syntax for package.repository

* Update copyright range end to 2023 from 2019

* Update year in examples to 2023 from 2013

* Remove $ from example code blocks of type shell

* Use const instead of var

* Upgrade native actions (checkout, setup-node); remove repetition present in comments, names

* Run on pull_request regardless of target branch

* Run on push to main as well as master, pending rename

* Fix Node.js version format (use N not N.x); also use array syntax

* Add Node.js 18, 20; drop 12

* Replace deprecated 'es3: false' with 'esversion: 6'

* Set minimum package.engines.node to 14

* Upgrade Grunt and plugins to latest

* Upgrade mockery to 2.1 from 1.4 (soft major)

* Update Mocha to 10.2 from 8.4

* Use const instead of var for some constants

* Retire recommendation for grunt-cli installed globally

* Make small changes to readme for clarity

* Separate tool usage code blocks to allow them to be copied individually

* Clarify inferred support policy

* Recommend npm >=8 and update lockfile using this version (also upgrades lockfileVersion to 2 from 1)

* Prepare version 4's details for README and MIGRATION; sunset <= 3

* Remove support symbols since their validity is affected by the passage of time

* Fix build badge and info link

* Rename job 'checkout_and_test' to 'test'

* Recommend npm version 8 or above, or equivalent, in migration guide for v4

* End support for post-LTS Node.js versions 14 and 16

* Reverse change to support policy section pending discussion
  • Loading branch information
danyalaytekin authored Oct 11, 2023
1 parent 01ded41 commit 31bed98
Show file tree
Hide file tree
Showing 8 changed files with 3,066 additions and 528 deletions.
30 changes: 8 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests.
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Build and lint

on:
push:
branches: # Run actions when code is committed to these branches
branches:
- master
- main
pull_request:
branches: # Run actions when a PR is pushed based on one of these branches
- master

jobs:
checkout_and_test:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- node-version: 12.x
- node-version: 14.x
- node-version: 16.x

node-version: [18, 20]
steps:
- name: Checkout code from ${{ github.repository }}
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- run: npm ci
- run: npm test
3 changes: 1 addition & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function (grunt) {
jshint: {
all: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'],
options: {
es3: false,
esversion: 6,
indent: 4,
latedef: false,
maxcomplexity: 5,
Expand Down Expand Up @@ -50,6 +50,5 @@ module.exports = function (grunt) {
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test', ['mochaTest']);
grunt.registerTask('default', ['lint', 'test']);
grunt.registerTask('ci', ['lint', 'test']);

};
14 changes: 9 additions & 5 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Migration Guide

Pa11y's API changes between major versions. This is a guide to help you make the switch when this happens.
This package's API and/or supported set of environments changes between major versions. This is a guide to help you update your project to use a new major version.

## Migrating from 2.x to 3.x
## Migrating to 4 from 3

Pa11y Webservice Client 3.x only supports Node.js v12 and higher, you'll need to upgrade to be able to use it.
1. Upgrade to Node.js 18 or above.

## Migrating from 1.x to 2.x
## Migrating to 3 from 2

Pa11y Webservice Client 2.x only supports Node.js v8.0.0 and higher, you'll need to upgrade to be able to use it.
1. Upgrade to Node.js 12 or above.

## Migrating to 2 from 1

1. Upgrade to Node.js 8 or above.
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

This is a Node.js client library for [Pa11y Webservice][pa11y-webservice].

[![NPM version][shield-npm]][info-npm]
[![Latest version published to npm][shield-npm]][info-npm]
[![Node.js version support][shield-node]][info-node]
[![Build status][shield-build]][info-build]
[![LGPL-3.0 licensed][shield-license]][info-license]

## Installing

Install Pa11y Webservice Node.js Client with npm:
Add this client to your project with your preferred package manager. For example, to install it as a development dependency with npm:

```sh
$ npm install pa11y-webservice-client-node
npm install --save-dev pa11y-webservice-client-node
```

## Usage

For more information on the actual webservice endpoints and resource types, [read the documentation][wiki-web-service].
For information about Pa11y Webservice's endpoints and resource types, [read the documentation][wiki-web-service].

```js
var createClient = require('pa11y-webservice-client-node');
const createClient = require('pa11y-webservice-client-node');

// Create client with the base URL of the web-service
var client = createClient('http://localhost:3000/');
// Create client with the base URL of your instance of Pa11y Webservice
const client = createClient('http://localhost:3000/');

// Create a task
client.tasks.create({
Expand Down Expand Up @@ -53,8 +53,8 @@ client.tasks.results({}, function (err, results) {

// Get results for all tasks within a date range
client.tasks.results({
from: '2013-01-01',
to: '2013-01-31'
from: '2023-01-01',
to: '2023-01-31'
}, function (err, results) {
// results = array of objects representing results, or null if an error occurred
});
Expand Down Expand Up @@ -102,8 +102,8 @@ client.task('5231c687bbdf0f94fa000007').results({}, function (err, results) {

// Get results for a task within a date range
client.task('5231c687bbdf0f94fa000007').results({
from: '2013-01-01',
to: '2013-01-31'
from: '2023-01-01',
to: '2023-01-31'
}, function (err, results) {
// results = array of objects representing results, or null if an error occurred
});
Expand All @@ -130,21 +130,24 @@ client.task('5231c687bbdf0f94fa000007').result('523c0ee0ca452f0000000009').get({

## Contributing

There are many ways to contribute to Pa11y Webservice Node.js Client, we cover these in the [contributing guide](CONTRIBUTING.md) for this repo.
There are many ways to contribute to Pa11y Webservice Node.js Client; we cover these in this repo's [contributing guide](CONTRIBUTING.md).

If you're ready to contribute some code, you'll need to clone the repo locally and run `npm install`. You'll also need [Grunt][grunt] to be installed globally in order to run tests, you can do this with `npm install -g grunt-cli`.

Now you'll be able to run the following commands:
If you'd like to contribute code, get started by cloning the repo and running `npm install`. Now you'll be able to run the following commands. Please use these build tools to avoid your contribution being delayed by a lint error or a failing test:

```sh
$ grunt # Run the lint and test tasks together
$ grunt lint # Run JSHint with the correct config
$ grunt test # Run unit tests
# Lint your contribution
grunt lint
```

Code with lint errors or failing tests will not be accepted, please use the build tools outlined above.
```sh
# Test your contribution
grunt test
```

For users with push-access, don't commit to the master branch. Code should be in `develop` until it's ready to be released.
```sh
# Lint and test with a single command
grunt
```

## Support and Migration

Expand All @@ -163,17 +166,17 @@ If you're opening issues related to these, please mention the version that the i
## License

Licensed under the [GNU General Public License 3.0](LICENSE.txt).<br/>
Copyright &copy; 2013–2019, Team Pa11y
Copyright &copy; 2013–2023, Team Pa11y

[gpl]: http://www.gnu.org/licenses/gpl-3.0.html
[grunt]: http://gruntjs.com/
[pa11y-webservice]: https://github.com/pa11y/pa11y-webservice
[wiki-web-service]: https://github.com/pa11y/pa11y-webservice/wiki/Web-Service-Endpoints
[info-build]: https://github.com/pa11y/pa11y-webservice-client-node/actions/workflows/build-and-test.yml
[info-build]: https://github.com/pa11y/pa11y-webservice-client-node/actions/workflows/tests.yml
[info-license]: LICENSE
[info-node]: package.json
[info-npm]: https://www.npmjs.com/package/pa11y-webservice-client-node
[shield-build]: https://github.com/pa11y/pa11y-webservice-client-node/actions/workflows/build-and-test.yml/badge.svg
[shield-build]: https://github.com/pa11y/pa11y-webservice-client-node/actions/workflows/tests.yml/badge.svg
[shield-license]: https://img.shields.io/badge/license-LGPL%203.0-blue.svg
[shield-node]: https://img.shields.io/node/v/pa11y-webservice-client-node.svg
[shield-npm]: https://img.shields.io/npm/v/pa11y-webservice-client-node.svg
Loading

0 comments on commit 31bed98

Please sign in to comment.