diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..925cf9d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [evanw] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..13c3032 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + node-version: [12.x, 14.x, 16.x, 17.x] + platform: + - os: ubuntu-latest + shell: bash + - os: macos-latest + shell: bash + - os: windows-latest + shell: bash + - os: windows-latest + shell: powershell + fail-fast: false + + runs-on: ${{ matrix.platform.os }} + defaults: + run: + shell: ${{ matrix.platform.shell }} + + steps: + - name: Checkout Repository + uses: actions/checkout@v1.1.0 + + - name: Use Nodejs ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm install + + - name: Run Tests + run: npm test -- -c -t0 diff --git a/.github/workflows/commit-if-modified.sh b/.github/workflows/commit-if-modified.sh new file mode 100644 index 0000000..e951d3f --- /dev/null +++ b/.github/workflows/commit-if-modified.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +git config --global user.email "$1" +shift +git config --global user.name "$1" +shift +message="$1" +shift +if [ $(git status --porcelain "$@" | egrep '^ M' | wc -l) -gt 0 ]; then + git add "$@" + git commit -m "$message" + git push || git pull --rebase + git push +fi diff --git a/.github/workflows/copyright-year.sh b/.github/workflows/copyright-year.sh new file mode 100644 index 0000000..92fdbe5 --- /dev/null +++ b/.github/workflows/copyright-year.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +dir=${1:-$PWD} +dates=($(git log --date=format:%Y --pretty=format:'%ad' --reverse | sort | uniq)) +if [ "${#dates[@]}" -eq 1 ]; then + datestr="${dates}" +else + datestr="${dates}-${dates[${#dates[@]}-1]}" +fi + +stripDate='s/^((.*)Copyright\b(.*?))((?:,\s*)?(([0-9]{4}\s*-\s*[0-9]{4})|(([0-9]{4},\s*)*[0-9]{4})))(?:,)?\s*(.*)\n$/$1$9\n/g' +addDate='s/^.*Copyright(?:\s*\(c\))? /Copyright \(c\) '$datestr' /g' +for l in $dir/LICENSE*; do + perl -pi -e "$stripDate" $l + perl -pi -e "$addDate" $l +done diff --git a/.github/workflows/isaacs-makework.yml b/.github/workflows/isaacs-makework.yml new file mode 100644 index 0000000..8eb5e85 --- /dev/null +++ b/.github/workflows/isaacs-makework.yml @@ -0,0 +1,37 @@ +name: "various tidying up tasks to silence nagging" + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + makework: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Use Node.js + uses: actions/setup-node@v2.1.4 + with: + node-version: 16.x + - name: put repo in package.json + run: node .github/workflows/package-json-repo.js + - name: check in package.json if modified + run: | + bash -x .github/workflows/commit-if-modified.sh \ + "package-json-repo-bot@example.com" \ + "package.json Repo Bot" \ + "chore: add repo to package.json" \ + package.json package-lock.json + - name: put all dates in license copyright line + run: bash .github/workflows/copyright-year.sh + - name: check in licenses if modified + run: | + bash .github/workflows/commit-if-modified.sh \ + "license-year-bot@example.com" \ + "License Year Bot" \ + "chore: add copyright year to license" \ + LICENSE* diff --git a/.github/workflows/package-json-repo.js b/.github/workflows/package-json-repo.js new file mode 100644 index 0000000..b28151b --- /dev/null +++ b/.github/workflows/package-json-repo.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +const pf = require.resolve(`${process.cwd()}/package.json`) +const pj = require(pf) + +if (!pj.repository && process.env.GITHUB_REPOSITORY) { + const fs = require('fs') + const server = process.env.GITHUB_SERVER_URL || 'https://github.com' + const repo = `${server}/${process.env.GITHUB_REPOSITORY}` + pj.repository = repo + const json = fs.readFileSync(pf, 'utf8') + const match = json.match(/^\s*\{[\r\n]+([ \t]*)"/) + const indent = match[1] + const output = JSON.stringify(pj, null, indent || 2) + '\n' + fs.writeFileSync(pf, output) +} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 004e1de..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: node_js -node_js: - - 10 - - 9 - - '8' - - '7' - - '6' - - '4' - - '0.12' - - '0.10' diff --git a/LICENSE.md b/LICENSE.md index 6247ca9..ec06479 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Evan Wallace +Copyright (c) 2013-2022 Evan Wallace Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal