diff --git a/.travis.yml b/.travis.yml index 3dc4de647..c7bad2dd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,11 +21,7 @@ jobs: - node_js: "14" script: - npm run init - - echo "TRAVIS_COMMIT $TRAVIS_COMMIT" - - echo "TRAVIS_PULL_REQUEST_SHA $TRAVIS_PULL_REQUEST_SHA" - - COMMIT_TO_VALIDATE=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} - - echo "COMMIT_TO_VALIDATE $COMMIT_TO_VALIDATE" - - ./scripts/validate-commit-msg.sh $COMMIT_TO_VALIDATE + - commitlint-travis - npm run lint - npm run build - npm run test:unit diff --git a/gruntfile.js b/gruntfile.js index 0986546ee..7cf595762 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -7,8 +7,7 @@ module.exports = function (grunt) { client: ['client/**/*.js'], common: ['common/**/*.js'], context: ['context/**/*.js'], - grunt: ['grunt.js', 'tasks/*.js'], - scripts: ['scripts/init-dev-env.js'] + grunt: ['grunt.js', 'tasks/*.js'] }, browserify: { client: { diff --git a/package-lock.json b/package-lock.json index 3a0605790..f9cf4f510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -715,6 +715,58 @@ } } }, + "@commitlint/travis-cli": { + "version": "8.3.5", + "resolved": "https://registry.npmjs.org/@commitlint/travis-cli/-/travis-cli-8.3.5.tgz", + "integrity": "sha512-E456A36Ya9Zrr0+ONfkPoHNdWnX4zfR6seHjuzTy0393iSHNc9cZ250mGw0SKQiYQu8x1QHrQyWwyRXLb2iASw==", + "dev": true, + "requires": { + "@commitlint/cli": "^8.3.5", + "babel-runtime": "6.26.0", + "execa": "0.11.0" + }, + "dependencies": { + "execa": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.11.0.tgz", + "integrity": "sha512-k5AR22vCt1DcfeiRixW46U5tMLtBg44ssdJM9PiXw3D8Bn5qyxFCSnKY/eR22y+ctFDGPqafpaXg2G4Emyua4A==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + } + } + }, "@marionebl/sander": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/@marionebl/sander/-/sander-0.6.1.tgz", @@ -3600,12 +3652,6 @@ } } }, - "conventional-commit-types": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/conventional-commit-types/-/conventional-commit-types-2.1.1.tgz", - "integrity": "sha512-0Ts+fEdmjqYDOQ1yZ+LNgdSPO335XZw9qC10M7CxtLP3nIMGmeMhmkM8Taffa4+MXN13bRPlp0CtH+QfOzKTzw==", - "dev": true - }, "conventional-commits-filter": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.1.6.tgz", @@ -5478,12 +5524,6 @@ "unpipe": "~1.0.0" } }, - "find-parent-dir": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/find-parent-dir/-/find-parent-dir-0.3.0.tgz", - "integrity": "sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=", - "dev": true - }, "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", @@ -5510,30 +5550,6 @@ } } }, - "findup": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/findup/-/findup-0.1.5.tgz", - "integrity": "sha1-itkpozk7rGJ5V6fl3kYjsGsOLOs=", - "dev": true, - "requires": { - "colors": "~0.6.0-1", - "commander": "~2.1.0" - }, - "dependencies": { - "colors": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", - "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", - "dev": true - }, - "commander": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.1.0.tgz", - "integrity": "sha1-0SG7roYNmZKj1Re6lvVliOR8Z4E=", - "dev": true - } - } - }, "findup-sync": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", @@ -15454,18 +15470,6 @@ "homedir-polyfill": "^1.0.1" } }, - "validate-commit-msg": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/validate-commit-msg/-/validate-commit-msg-2.14.0.tgz", - "integrity": "sha1-5Tg2kQEsuycNzAvCpO/+vhSJDqw=", - "dev": true, - "requires": { - "conventional-commit-types": "^2.0.0", - "find-parent-dir": "^0.3.0", - "findup": "0.1.5", - "semver-regex": "1.0.0" - } - }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", diff --git a/package.json b/package.json index c97962791..bd79da30c 100644 --- a/package.json +++ b/package.json @@ -418,6 +418,7 @@ "devDependencies": { "@commitlint/cli": "^8.3.4", "@commitlint/config-conventional": "^8.3.4", + "@commitlint/travis-cli": "^8.3.5", "@semantic-release/changelog": "^3.0.6", "@semantic-release/git": "^7.0.18", "browserify": "^16.2.3", @@ -466,7 +467,6 @@ "sinon-chai": "^3.0.0", "supertest": "^4.0.2", "timer-shim": "^0.3.0", - "validate-commit-msg": "^2.11.1", "which": "^1.3.1" }, "main": "./lib/index", diff --git a/scripts/validate-commit-msg.sh b/scripts/validate-commit-msg.sh deleted file mode 100755 index 489d5fae7..000000000 --- a/scripts/validate-commit-msg.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# Validate commit message matches our expected format -# -# Arguments: -# Commit revision to validate -# -# Example: -# ./validate-commit-msg.sh abcdef0 - -# Exit on first error -set -e - -# If we didn't receive a commit, then error out -# DEV: If want the HEAD commit, then use `git rev-parse HEAD` -COMMIT_REV="$1" -if [ -z "$COMMIT_REV" ]; then - echo "Expected a commit revision to validate but received nothing" 1>&2 - exit 1 -fi - - -# Resolve our file for output -# DEV: We use `.git` to avoid cluttering the working directory -GIT_DIR="$(git rev-parse --git-dir)" -TARGET_FILENAME=VALIDATE_COMMIT_MSG -TARGET_FILE="$GIT_DIR/$TARGET_FILENAME" - -echo "Retrieving relevant commit message for $COMMIT_REV" -# Output our log message to a file -# DEV: We use `--no-merges` to skip merge commits introduced by GitHub -git log --no-merges --format=format:"%s" -n 1 "$COMMIT_REV" > "$TARGET_FILE" - -echo "Validating contents of $TARGET_FILE" -cat "$TARGET_FILE" - -# Validate our message -./node_modules/.bin/validate-commit-msg "$TARGET_FILENAME" diff --git a/tasks/init-dev-env.js b/tasks/init-dev-env.js deleted file mode 100644 index adf0bf948..000000000 --- a/tasks/init-dev-env.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = function (grunt) { - /** - * Initialize development environment for Karma - * - * - register git hooks (commit-msg) - */ - grunt.registerTask('init-dev-env', 'Initialize dev environment.', function () { - const fs = require('fs') - const done = this.async() - - fs.symlink('../../tasks/lib/validate-commit-msg.js', '.git/hooks/commit-msg', function (e) { - if (!e) { - grunt.log.ok('Hook "validate-commit-msg" installed.') - } - done() - }) - }) -}