Skip to content

Commit

Permalink
feat(release): replace deprecated ghooks with husky for git hook impl…
Browse files Browse the repository at this point in the history
…ementation

ISSUES CLOSED: #113
  • Loading branch information
uglow authored Feb 3, 2017
1 parent 21d8d68 commit 98aa141
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8,088 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,20 @@ before_install:
# Repo for newer Node.js versions
#- curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
# Repo for Yarn
- npm install -g yarn
#- npm install -g yarn

# Install NPM 3.9.5
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3.9.5; fi
- npm prune
- npm set progress=false

install:
- yarn global add yo
- yarn install
- yarn link
- npm install -g yo
- npm install
- npm link
# - yarn global add yo
# - yarn install
# - yarn link

before_script:
- export DISPLAY=:99.0
Expand Down
109 changes: 0 additions & 109 deletions CHECKLIST.md

This file was deleted.

17 changes: 11 additions & 6 deletions lib/buildTool/npm/npmResources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ release:
toolModules:
- condition: <%- release.checkCodeCoverage %>
packages:
- <<: *pkg_ghooks
packageJsonConfig:
- config.ghooks.pre-push: npm-run-all verify test:coverage --silent
- <<: *pkg_husky
tasks:
- name: prepush
tasks: ['npm-run-all verify test:coverage --silent']
description: Git pre-push hook that verifies code and checks unit test coverage meet minimum thresholds.

# Coveralls works for BitBucket and GitHub only
- condition: <%- release.checkCodeCoverage && (app.repositoryType === 'BitBucket' || app.repositoryType === 'GitHub') && app.publicRepository %>
Expand All @@ -147,12 +149,15 @@ release:
packages:
- <<: *pkg_cz-customizable
- <<: *pkg_commitizen
- <<: *pkg_ghooks
- <<: *pkg_husky
- <<: *pkg_cz-customizable-ghooks
tasks:
- name: commitmsg
tasks: ['cz-customizable-ghooks']
description: Git commit message hook that validates the commit message conforms to your commit message conventions.
packageJsonConfig:
- config.commitizen.path: node_modules/cz-customizable
- config.cz-customizable.config: <%- paths.config.configDir + resources.release.configSubDir %>commitMessageConfig.js
- config.ghooks.commit-msg: node ./node_modules/cz-customizable-ghooks/lib/index.js $2
templateFiles:
- src: commitMessageConfig.js
dest: <%- paths.config.configDir + resources.release.configSubDir %>commitMessageConfig.js
Expand All @@ -162,7 +167,7 @@ release:
commit:
commit:
command: git cz
description: Commit changes to local repository using Commitizen
description: Commit changes to local repository using Commitizen.
features:
- Asks questions about the change to generate a valid conventional commit message
- Can be customised by modifying <%- link(paths.config.configDir + resources.release.configSubDir + 'commitMessageConfig.js') %>
Expand Down
10 changes: 5 additions & 5 deletions lib/core/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ $packages:

- &pkg_cz-customizable-ghooks
name: cz-customizable-ghooks
version: 1.4.0
version: 1.5.0

- &pkg_enzyme
name: enzyme
Expand Down Expand Up @@ -271,10 +271,6 @@ $packages:
name: gh-pages
version: 0.12.0

- &pkg_ghooks
name: ghooks
version: 1.3.2

- &pkg_glob # For Backstop
name: glob
version: 7.1.1
Expand All @@ -295,6 +291,10 @@ $packages:
name: http-server
version: 0.9.0

- &pkg_husky
name: husky
version: 0.13.1

- &pkg_istanbul # Seems to some work towards an alpha version, but hundreds of open issues and tens of pull requests
name: istanbul
version: 0.4.5
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"build": "cross-env NODE_ENV=production npm run clean:prod",
"check-for-updates": "node config/check-update/checkForUpdates.js",
"clean:prod": "rimraf dist/",
"commitmsg": "cz-customizable-ghooks",
"coverage": "npm-run-all test:coverage test:check-coverage",
"dev": "cross-env NODE_ENV=development npm run verify:watch",
"docs:_publish": "node config/docs/publish.js",
Expand All @@ -65,6 +66,8 @@
"docs:prepublish": "node config/docs/prepublish.js",
"docs:publish": "npm-run-all docs:prepublish docs:clean docs:build docs:_publish docs:postpublish",
"docs:serve": "http-server website/ -o",
"precommit": "exact-semver",
"prepush": "npm-run-all verify test:coverage --silent",
"semantic-release": "semantic-release pre && npm publish && semantic-release post && npm run docs:publish",
"start": "npm run dev",
"test": "npm-run-all updateFixtures test:unit:once test:int",
Expand All @@ -87,11 +90,6 @@
},
"cz-customizable": {
"config": "config/release/commitMessageConfig.js"
},
"ghooks": {
"pre-commit": "exact-semver && npm-run-all test:unit:once",
"commit-msg": "node ./node_modules/cz-customizable-ghooks/lib/index.js $2",
"pre-push": "npm-run-all verify test:coverage --silent"
}
},
"dependencies": {
Expand All @@ -116,16 +114,16 @@
"coveralls": "2.11.15",
"cross-env": "3.1.4",
"cz-customizable": "4.0.0",
"cz-customizable-ghooks": "1.4.0",
"cz-customizable-ghooks": "1.5.0",
"eslint": "3.14.1",
"eslint-config-google": "0.7.1",
"eslint-plugin-node": "3.0.5",
"exact-semver": "1.2.0",
"freeport": "1.0.5",
"gh-pages": "0.12.0",
"ghooks": "1.3.2",
"highlightjs": "9.8.0",
"http-server": "0.9.0",
"husky": "0.13.1",
"istanbul": "0.4.5",
"latest-version": "2.0.0",
"mocha": "3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion test/spec/integration/testSystemTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function(confitConfig, SERVER_MAX_WAIT_TIME) {
} else {
configFn = modifyConfitServerConfig;
configData = 'serverDev';
serverStartedRegEx = /webpack: bundle is now VALID\.\n$/;
serverStartedRegEx = /webpack\: Compiled/;
}

// Start up the confit DEV webserver
Expand Down
19 changes: 9 additions & 10 deletions test/spec/unit/releaseGenerator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('Release Generator', () => {
// There should also be some configuration in package.json/config
let pkg = fs.readJsonSync('package.json');

assert.equal(pkg.config.ghooks['commit-msg'], 'node ./node_modules/cz-customizable-ghooks/lib/index.js $2');
assert.equal(pkg.config.ghooks['pre-push'], undefined);
assert.equal(pkg.scripts.commitmsg, 'cz-customizable-ghooks');
assert.equal(pkg.scripts.prepush, undefined);

done();
}
Expand Down Expand Up @@ -50,8 +50,8 @@ describe('Release Generator', () => {

assert.equal(pkg.config.commitizen.path, 'node_modules/cz-customizable');
assert.equal(pkg.config['cz-customizable'].config, 'config/release/commitMessageConfig.js');
assert.equal(pkg.config.ghooks['commit-msg'], 'node ./node_modules/cz-customizable-ghooks/lib/index.js $2');
assert.equal(pkg.config.ghooks['pre-push'], 'npm-run-all verify test:coverage --silent');
assert.equal(pkg.scripts.commitmsg, 'cz-customizable-ghooks');
assert.equal(pkg.scripts.prepush, 'npm-run-all verify test:coverage --silent');

done();
}
Expand All @@ -77,10 +77,9 @@ describe('Release Generator', () => {
// There should not be also be some configuration in package.json/config
let pkg = fs.readJsonSync('package.json');

assert.equal(pkg.config.commitizen, undefined);
assert.equal(pkg.config['cz-customizable'], undefined);
assert.equal(pkg.config.ghooks['commit-msg'], undefined);
assert.equal(pkg.config.ghooks['pre-push'], 'npm-run-all verify test:coverage --silent');
assert.equal(pkg.config, undefined);
assert.equal(pkg.scripts.commitmsg, undefined);
assert.equal(pkg.scripts.prepush, 'npm-run-all verify test:coverage --silent');

done();
}
Expand Down Expand Up @@ -197,9 +196,9 @@ describe('Release Generator', () => {

let pkg = fs.readJsonSync('package.json');

assert(pkg.devDependencies.ghooks, 'ghooks package included');
assert(pkg.devDependencies.husky, 'git hook package included');
assert(pkg.devDependencies.coveralls, 'coveralls package included');
assert(pkg.devDependencies['corp-semantic-release'], 'ghooks package included');
assert(pkg.devDependencies['corp-semantic-release'], 'corp-semantic-release package included');

assert.equal(pkg.scripts['semantic-release'], 'corp-semantic-release --changelogpreset angular-bitbucket');

Expand Down
Loading

0 comments on commit 98aa141

Please sign in to comment.