chore(package): re-init package with commitizen and standard-release

This commit is contained in:
Pavel Pertsev
2018-05-16 12:54:46 +03:00
parent cb4e7a5643
commit eaf2328575
10640 changed files with 609660 additions and 117 deletions

3
node_modules/husky/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
test/
.travis.yml

27
node_modules/husky/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,27 @@
# CHANGELOG
## 0.13.3
* Revert `Fixes issue with OS X + brew where nvm was loaded even when npm was already present` that was introduced in `v0.13.0` as it was preventing Husky to load `nvm` in some cases [#106](https://github.com/typicode/husky/issues/106)
## 0.13.2
* Fixes issue [#103](https://github.com/typicode/husky/issues/103)
## 0.13.1
* Makes it easier for projects to transition from [ghooks](https://github.com/gtramontina/ghooks) by detecting ghooks installed scripts and automatically migrating them
## 0.13.0
* Makes `husky` a little less verbose by default
* Fixes issue with `OS X + brew` where `nvm` was loaded even when `npm` was already present
* Fixes issue with Git `v1.9` on Windows
* Prevents Git hooks being installed when husky is in a sub `node_modules` directory (i.e. `./node_modules/A/node_modules/husky`)
## 0.12.0
* Adds Git submodule support
* Adds Cygwin support
* Improves edge cases support (`.git` not found and `git` not in `PATH`)
* If `npm` is already present in path, doesn't load `nvm` default or `.nvmrc` version, which makes things faster in terminal. In GUI apps, the behavior is unchanged.

24
node_modules/husky/HOOKS.md generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# Hooks
Husky supports all git hooks (https://git-scm.com/docs/githooks). Simply add the corresponding `npm script` to your `package.json`.
| Git hook | npm script |
| -------- | ---------- |
| applypatch-msg | applypatchmsg |
| commit-msg | commitmsg |
| post-applypatch | postapplypatch |
| post-checkout | postcheckout |
| post-commit | postcommit |
| post-merge | postmerge |
| post-receive | postreceive |
| post-rewrite | postrewrite |
| post-update | postupdate |
| pre-applypatch | preapplypatch |
| pre-auto-gc | preautogc |
| pre-commit | precommit |
| pre-push | prepush |
| pre-rebase | prerebase |
| pre-receive | prereceive |
| prepare-commit-msg | preparecommitmsg |
| push-to-checkout | pushtocheckout |
| update | update |

21
node_modules/husky/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

105
node_modules/husky/README.md generated vendored Normal file
View File

@@ -0,0 +1,105 @@
# husky [![](http://img.shields.io/npm/dm/husky.svg?style=flat)](https://www.npmjs.org/package/husky) [![npm version](https://badge.fury.io/js/husky.svg)](https://www.npmjs.com/package/husky) [![Build Status](https://travis-ci.org/typicode/husky.svg?branch=master)](https://travis-ci.org/typicode/husky)
> Git hooks made easy
Husky can prevent bad commit, push and more :dog: _woof!_
## Install
```sh
npm install husky --save-dev
```
```javascript
// Edit package.json
{
"scripts": {
"precommit": "npm test",
"prepush": "npm test",
"...": "..."
}
}
```
```bash
git commit -m "Keep calm and commit"
```
_Existing hooks aren't replaced and you can use [any Git hook](HOOKS.md)._
_If you're migrating from `ghooks`, simply run `npm uninstall ghooks --save-dev && npm install husky --save-dev` and edit `package.json`. Husky will automatically migrate `ghooks` hooks._
## Used by
* [jQuery](https://github.com/jquery/jquery)
* [Next.js](https://github.com/zeit/next.js)
* [Hyper](https://github.com/zeit/hyper)
* [Paper.js](https://github.com/paperjs/paper.js)
* [Kibana](https://github.com/elastic/kibana)
* [JSON Server](https://github.com/typicode/json-server)
* [Hotel](https://github.com/typicode/hotel)
* ... and almost 4000 [other awesome projects](https://libraries.io/npm/husky/dependent-repositories).
## Uninstall
```bash
npm uninstall husky --save-dev
```
## Tricks
<details>
### Debug hooks easily
If you need to debug hooks, simply use `npm run <script-name>`. For example:
```bash
npm run precommit
```
### Git GUI clients support
If you've installed Node using the [standard installer](https://nodejs.org/en/), [nvm](https://github.com/creationix/nvm) or [homebrew](http://brew.sh/), Git hooks will be executed in GUI applications.
### Working with multiple version of Node
If [`nvm`](https://github.com/creationix/nvm) is installed, husky will try to use the `default`/`current` installed Node version or use the project `.nvmrc`.
__Tip__ to use the system-installed version of node, `nvm` provides a [`system`](https://github.com/creationix/nvm#system-version-of-node) alias
### Accessing Git params
Git params can be found in `GIT_PARAMS` environment variable.
### Setting a different log level
By default, husky will run scripts using `--silent` to make the output more readable. If you want to override this, simply pass a different log level to your scripts:
```json
"precommit": "npm run some-script -q"
```
_`-q/--quiet` is equivalent to `--loglevel warn` which is npm default log level._
### Git submodule support
Yes
### Cygwin support
Yes
### Yarn support
Please use `yarn` `v0.24+`
</details>
## See also
* [pkg-ok](https://github.com/typicode/pkg-ok) - prevents publishing modules with bad paths
## License
MIT - [Typicode :cactus:](https://github.com/typicode)

17
node_modules/husky/bin/install.js generated vendored Executable file
View File

@@ -0,0 +1,17 @@
// Run when package is installed
var path = require('path')
var chalk = require('chalk')
var isCI = require('is-ci')
var husky = require('../src/')
console.log(chalk.cyan.underline('husky'))
if (isCI) {
console.log('CI detected, skipping Git hooks installation')
process.exit(0)
}
console.log('setting up hooks')
var huskyDir = path.join(__dirname, '..')
husky.installFrom(huskyDir)

10
node_modules/husky/bin/uninstall.js generated vendored Executable file
View File

@@ -0,0 +1,10 @@
// Run when package is uninstalled
var path = require('path')
var chalk = require('chalk')
var husky = require('../src/')
console.log(chalk.cyan.underline('husky'))
console.log('uninstalling')
var huskyDir = path.join(__dirname, '..')
husky.uninstallFrom(huskyDir)

1
node_modules/husky/node_modules/.bin/is-ci generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../is-ci/bin.js

56
node_modules/husky/package.json generated vendored Normal file
View File

@@ -0,0 +1,56 @@
{
"name": "husky",
"version": "0.13.4",
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)",
"main": "./src/index.js",
"scripts": {
"test": "mocha && standard",
"precommit": "npm test",
"prepublish": "pkg-ok",
"install": "node ./bin/install.js",
"uninstall": "node ./bin/uninstall.js"
},
"repository": {
"type": "git",
"url": "git://github.com/typicode/husky.git"
},
"keywords": [
"git",
"hook",
"hooks",
"pre-commit",
"precommit",
"post-commit",
"postcommit",
"pre-push",
"prepush",
"post-merge",
"postmerge",
"test"
],
"author": "Typicode <typicode@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/typicode/husky/issues"
},
"homepage": "https://github.com/typicode/husky",
"devDependencies": {
"expect": "^1.20.2",
"mocha": "^3.2.0",
"mock-fs": "^3.12.1",
"pkg-ok": "^1.0.1",
"rimraf": "^2.2.8",
"standard": "^8.6.0"
},
"dependencies": {
"chalk": "^1.1.3",
"find-parent-dir": "^0.3.0",
"is-ci": "^1.0.9",
"normalize-path": "^1.0.0"
},
"standard": {
"env": {
"mocha": true
}
}
}

20
node_modules/husky/src/hooks.json generated vendored Normal file
View File

@@ -0,0 +1,20 @@
[
"applypatch-msg",
"pre-applypatch",
"post-applypatch",
"pre-commit",
"prepare-commit-msg",
"commit-msg",
"post-commit",
"pre-rebase",
"post-checkout",
"post-merge",
"pre-push",
"pre-receive",
"update",
"post-receive",
"post-update",
"push-to-checkout",
"pre-auto-gc",
"post-rewrite"
]

265
node_modules/husky/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,265 @@
var fs = require('fs')
var path = require('path')
var normalize = require('normalize-path')
var findParentDir = require('find-parent-dir')
var hooks = require('./hooks.json')
var pkg = require('../package.json')
var SKIP = 'SKIP'
var UPDATE = 'UPDATE'
var MIGRATE = 'MIGRATE'
var CREATE = 'CREATE'
function write (filename, data) {
fs.writeFileSync(filename, data)
fs.chmodSync(filename, parseInt('0755', 8))
}
function isHusky (filename) {
var data = fs.readFileSync(filename, 'utf-8')
return data.indexOf('#husky') !== -1
}
function isGhooks (filename) {
var data = fs.readFileSync(filename, 'utf-8')
return data.indexOf('// Generated by ghooks. Do not edit this file.') !== -1
}
function findHooksDir (dirname) {
var dir = findParentDir.sync(dirname, '.git')
if (dir) {
var gitDir = path.join(dir, '.git')
var stats = fs.lstatSync(gitDir)
if (stats.isFile()) {
// Expect following format
// git: pathToGit
gitDir = fs
.readFileSync(gitDir, 'utf-8')
.split(':')[1]
.trim()
return path.join(dir, gitDir, 'hooks')
}
return path.join(gitDir, 'hooks')
}
}
function getHookScript (hookName, relativePath, cmd) {
// On Windows normalize path (i.e. convert \ to /)
var normalizedPath = normalize(relativePath)
// Hook script
var arr = [
'#!/bin/sh',
'#husky ' + pkg.version,
'',
'command_exists () {',
' command -v "$1" >/dev/null 2>&1',
'}',
'',
'load_nvm () {',
' export $1=$2',
' [ -s "$2/nvm.sh" ] && . $2/nvm.sh',
' command_exists nvm && [ -f .nvmrc ] && nvm use',
'}',
'',
// https://github.com/typicode/husky/issues/76
'has_hook_script () {',
' [ -f package.json ] && cat package.json | grep -q "\\"$1\\"[[:space:]]*:"',
'}',
''
]
arr = arr.concat([
'cd ' + normalizedPath,
'',
// Fix for issue #16 #24
// If script is not defined in package.json then exit
'has_hook_script ' + cmd + ' || exit 0',
''
])
// On OS X and Linux, try to use nvm if it's installed
if (process.platform !== 'win32') {
// ~ is unavaible, so $HOME is used
var home = process.env.HOME
if (process.platform === 'darwin') {
// Add
// Brew standard installation path /usr/local/bin
// Node standard installation path /usr/local
// for GUI apps
// https://github.com/typicode/husky/issues/49
arr = arr.concat([
'export PATH=$PATH:/usr/local/bin:/usr/local'
])
}
if (process.platform === 'darwin') {
arr = arr.concat([
// Load nvm with BREW_NVM_DIR set to /usr/local/opt/nvm
'load_nvm BREW_NVM_DIR /usr/local/opt/nvm',
''
])
}
arr = arr.concat([
// Load nvm with NVM_DIR set to $HOME/.nvm
'load_nvm NVM_DIR ' + home + '/.nvm',
''
])
} else {
// Add
// Node standard installation path /c/Program Files/nodejs
// for GUI apps
// https://github.com/typicode/husky/issues/49
arr = arr.concat([
'export PATH="$PATH:/c/Program Files/nodejs"'
])
}
// Can't find npm message
var npmNotFound = '> husky - Can\'t find npm in PATH. Skipping ' + cmd + ' script in package.json'
var scriptName = hookName.replace(/-/g, '')
arr = arr.concat([
// Test if npm is in PATH
'command_exists npm || {',
' echo >&2 "' + npmNotFound + '"',
' exit 0',
'}',
'',
// Run script
'echo',
'echo "> husky - npm run -s ' + cmd + '"',
'echo "> husky - node `node -v`"',
'echo',
'',
'export GIT_PARAMS="$*"',
'npm run -s ' + cmd + ' || {',
' echo',
' echo "> husky - ' + hookName + ' hook failed (add --no-verify to bypass)"',
' echo "> husky - to debug, use \'npm run ' + scriptName + '\'"',
' exit 1',
'}',
''
])
return arr.join('\n')
}
function createHook (huskyDir, hooksDir, hookName, cmd) {
var filename = path.join(hooksDir, hookName)
// Assuming that this file is in node_modules/husky
var packageDir = path.join(huskyDir, '..', '..')
// Get project directory
// When used in submodule, the project dir is the first .git that is found
var projectDir = findParentDir.sync(huskyDir, '.git')
// In order to support projects with package.json in a different directory
// than .git, find relative path from project directory to package.json
var relativePath = path.join('.', path.relative(projectDir, packageDir))
var hookScript = getHookScript(hookName, relativePath, cmd)
// Create hooks directory if needed
if (!fs.existsSync(hooksDir)) fs.mkdirSync(hooksDir)
if (!fs.existsSync(filename)) {
write(filename, hookScript)
return CREATE
}
if (isGhooks(filename)) {
write(filename, hookScript)
return MIGRATE
}
if (isHusky(filename)) {
write(filename, hookScript)
return UPDATE
}
return SKIP
}
function removeHook (dir, name) {
var filename = dir + '/' + name
if (fs.existsSync(filename) && isHusky(filename)) {
fs.unlinkSync(dir + '/' + name)
}
}
function installFrom (huskyDir) {
try {
var isInSubNodeModule = (huskyDir.match(/node_modules/g) || []).length > 1
if (isInSubNodeModule) {
return console.log(
'Trying to install from sub \'node_module\' directory,',
'skipping Git hooks installation'
)
}
var hooksDir = findHooksDir(huskyDir)
if (hooksDir) {
hooks
.map(function (hookName) {
var npmScriptName = hookName.replace(/-/g, '')
return {
hookName: hookName,
action: createHook(huskyDir, hooksDir, hookName, npmScriptName)
}
})
.forEach(function (item) {
switch (item.action) {
case MIGRATE:
console.log('migrating ghooks ' + item.hookName + ' script')
break
case UPDATE:
break
case SKIP:
console.log('skipping ' + item.hookName + ' hook (existing user hook)')
break
case CREATE:
break
default:
console.error('Unknown action')
}
})
console.log('done\n')
} else {
console.log('Can\'t find .git directory, skipping Git hooks installation')
}
} catch (e) {
console.error(e)
}
}
function uninstallFrom (huskyDir) {
try {
var hooksDir = findHooksDir(huskyDir)
hooks.forEach(function (hookName) {
removeHook(hooksDir, hookName)
})
console.log('done\n')
} catch (e) {
console.error(e)
}
}
module.exports = {
installFrom: installFrom,
uninstallFrom: uninstallFrom
}