This commit is contained in:
eric sciple 2020-01-24 12:21:24 -05:00
parent fc725ba36b
commit 422b9fdb15
7395 changed files with 1786235 additions and 3476 deletions

20
node_modules/husky/.eslintrc.js generated vendored Normal file
View file

@ -0,0 +1,20 @@
module.exports = {
"parser": "@typescript-eslint/parser",
"extends": [
"xo-space/esnext",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"plugins": [
"@typescript-eslint",
"prettier"
],
"rules": {
"prettier/prettier": "error"
},
"env": {
"jest": true,
"node": true,
}
}

2
node_modules/husky/.github/FUNDING.yml generated vendored Normal file
View file

@ -0,0 +1,2 @@
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: typicode

4
node_modules/husky/.prettierrc generated vendored Normal file
View file

@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}

284
node_modules/husky/CHANGELOG.md generated vendored Normal file
View file

@ -0,0 +1,284 @@
# CHANGELOG
## 2.4.1
* Fix husky crash on install/uninstall with very old Node versions
## 2.4.0
* Add `HUSKY_SKIP_HOOKS` to skip all hooks
## 2.3.0
* Make `HUSKY_DEBUG=1` effective like `HUSKY_DEBUG=true`
* Refactor script to point to `run-node/run-node` rather than `.bin/run-node`
## 2.2.0
* Improve Git worktree support
## 2.1.0
* Improve shell script portability by using `.` rather than `source`
## 2.0.0
* Update dependencies
* Update messages
* __Breaking change__ drop `Node 6` support
## 1.3.1
* Update docs
* Upgrade `is-ci` and support more CIs
* Disable `1.3.0` change related to `stdin` due to a bug on Windows
## 1.3.0
* Enable `stdin` if hook is running in a terminal
## 1.2.1
* Fix don't fail if directory in project contains whitespace
## 1.2.0
* Add comments to generated hooks to specify which package has installed husky and when
## 1.1.4
* Upgrade `execa` dependency
## 1.1.3
* Fix don't fail if `package.json` doesn't exist
## 1.1.2
* Add debug message
## 1.1.1
* Check `HUSKY_SKIP_INSTALL` value first before checking if `.git` exists
* Check Node version before running hooks
## 1.1.0
* Create `.git/hooks` if it doesn't exist
## 1.0.1
* Various `husky-upgrade` changes ([#362](https://github.com/typicode/husky/pull/362), [#360](https://github.com/typicode/husky/pull/360), [#359](https://github.com/typicode/husky/pull/359))
## 1.0.0
After a year of pre-releases and a complete rewrite, this marks the first stable release of husky 🐶🎉.
### Notable changes
Below you'll find consolidated changes since `0.14.3`. There's no change in code between `1.0.0-rc.15` and `1.0.0`.
* Hooks
* Add `sendemail-validate` hook
* Config
* Move hooks config from `scripts` field to `husky` field
* Prefer raw names for hooks (e.g. `pre-commit` rather than `precommit`)
* Support `.huskyrc` config
* Package managers
* Support environments where [yarn](https://github.com/yarnpkg/yarn/) is the only package manager installed
* Support [pnpm](https://github.com/pnpm/pnpm) package manager
* Environment variables
* Add `HUSKY_SKIP_INSTALL` environment variable for skipping git hooks installation
* Add `HUSKY_GIT_STDIN` environment variable for `pre-push`, `pre-receive`, `post-receive` and `post-rewrite` to access arguments passed by Git via stdin
* Rename `GIT_PARAMS` to `HUSKY_GIT_PARAMS`
* Messages
* Add many more messages in case of errors
* Add [please-upgrade-node](https://github.com/typicode/please-upgrade-node) message if using with unsupported Node version
* Make `--no-verify` message more accurate and only show it for hooks that can be skipped
* Upgrade
* Add `husky-upgrade` command to automatically migrate hooks in `package.json`
* Add deprecation warning for hooks that are still defined in `scripts`
* Other
* Drop `Node 4` support
* Drop integrated `nvm` support (see Node version management in docs)
### Credits
Huge thanks to all the Contributors and [Patreon Supporters](https://thanks.typicode.com)! 🙏
## 1.0.0-rc.15
* Update docs
## 1.0.0-rc.14
* Make `--no-verify` message more accurate and only show it for hooks that can be skipped
* Improve error messages
## 1.0.0-rc.13
* Show a message when Node can't be found in PATH
## 1.0.0-rc.12
* Fix exit code when used with unsupported Node version
* Update dependencies
## 1.0.0-rc.11
* Show a message instead of crashing if Node version is unsupported by Husky
## 1.0.0-rc.10
* Fix `HUSKY_GIT_PARAMS` containing only the first Git param
## 1.0.0-rc.9
* If `node_modules/husky` is missing, show message but do not crash
* Remove and upgrade some `dependencies`
## 1.0.0-rc.8
* Add `HUSKY_GIT_STDIN` environment variable for `pre-push`, `pre-receive`, `post-receive` and `post-rewrite` to access arguments passed by Git via stdin.
## 1.0.0-rc.7
* Update `cosmiconfig` dependency
* Fix `package.json` normalization error
## 1.0.0-rc.6
* Fix install error with `pnpm`
## 1.0.0-rc.5
* Auto migrate `yorkie` hooks
## 1.0.0-rc.4
* Re-enable Git submodule and worktree support
## 1.0.0-rc.3
* Re-enable subdirectory support
## 1.0.0-rc.2
* Upgrade `run-node` dependency
## 1.0.0-rc.1
* Namespace environment variable created by husky
* `GIT_PARAMS` becomes `HUSKY_GIT_PARAMS`
* Starting also with `1.0.0` versioning
## 0.15.0-rc.13
* Revert `GIT_STDIN` for the moment. Needs more testing.
`rc.10`, `rc.11` and `rc.12` are broken for some GUI clients due to `read` command
## 0.15.0-rc.9
* Handle case where `.git/hooks` directory doesn't exit
## 0.15.0-rc.8
* Handle case where `v0.14` git hooks wouldn't have been uninstalled
## 0.15.0-rc.7
* Move `postinstall` script to `install`
* Fix line ending error when running `upgrader` from OS X/Linux
## 0.15.0-rc.6
* Fix `[[` error
## 0.15.0-rc.5
* Fix error with GitHub Desktop on Windows
## 0.15.0-rc.4
* Catch error if `git` command fails
## 0.15.0-rc.3
* Fix `husky-upgrade`
* Drop `Node 4` support
## 0.15.0-rc.2
* Fix install error
## 0.15.0-rc.1
* `sendemail-validate` hook [#173](https://github.com/typicode/husky/pull/173)
* `HUSKY_SKIP_INSTALL` environment variable for skipping git hooks installation [#178](https://github.com/typicode/husky/pull/178)
* `.huskyrc` config [#209](https://github.com/typicode/husky/pull/209)
* [`pnpm`](https://github.com/pnpm/pnpm) support
* Support environments where `yarn` is the only package manager installed
* Move config from `scripts` field to `husky` field
* Prefer raw names for Git hooks (`pre-commit` rather than `precommit`)
* Drop integrated `nvm` support
* To ease upgrade:
* Provide `husky-upgrade` command
* Add deprecation warning for hooks that are defined in `scripts` (but still run them)
## 0.14.3
* Fix handle space in `PATH` [#150](https://github.com/typicode/husky/pull/114)
## 0.14.2
* Fix handle space in `HOME`
## 0.14.1
* Fix Git hooks install on Windows
* Fix hook script when `nvm` was installed with Brew
## 0.14.0
* Fix `npm@5` `Error: Cannot find module` warning when uninstalling
* Drop `Node 0.12` support
* Don't reload `nvm` if it's already in `PATH`
* Add Git worktree support [#114](https://github.com/typicode/husky/pull/114)
* Hide irrelevant `--no-verify` message for `prepare-commit-msg` [#137](https://github.com/typicode/husky/issues/137)
## 0.13.4
* Add Node version to husky output
## 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.

125
node_modules/husky/DOCS.md generated vendored Normal file
View file

@ -0,0 +1,125 @@
# Documentation
## Supported hooks
`husky` supports all Git hooks defined [here](https://git-scm.com/docs/githooks).
Server-side hooks (`pre-receive`, `update` and `post-receive`) aren't supported.
## Access Git params and stdin
Git hooks can get parameters via command-line arguments and stdin. `husky` makes them accessible via `HUSKY_GIT_PARAMS` and `HUSKY_GIT_STDIN` environment variables.
```
{
"husky": {
"hooks": {
"commit-msg": "echo $HUSKY_GIT_PARAMS"
}
}
}
```
## Disable auto-install
If you don't want `husky` to automatically install Git hooks, simply set `HUSKY_SKIP_INSTALL` environment variable to `1`.
```sh
HUSKY_SKIP_INSTALL=1 npm install
```
## Skip all hooks
During a rebase you may want to skip all hooks, you can set `HUSKY_SKIP_HOOKS` environment variable to `1`.
```sh
HUSKY_SKIP_HOOKS=1 git rebase ...
```
## Multi-package repository (monorepo)
If you have a multi-package repository, it's __recommended__ to use tools like [lerna](https://github.com/lerna/lerna) and have `husky` installed ONLY in the root `package.json` to act as the source of truth.
Generally speaking, you should AVOID defining `husky` in multiple `package.json`, as each package would overwrite previous `husky` installations.
```sh
.
└── root
├── .git
├── package.json 🐶 # Add husky here
└── packages
├── A
│ └── package.json
├── B
│ └── package.json
└── C
└── package.json
```
```js
// root/package.json
{
"private": true,
"devDependencies": {
"husky": "..."
},
"husky": {
"hooks": {
"pre-commit": "lerna run test"
}
}
}
```
## Node version management
If you're on Windows, husky will simply use the version installed globally on your system.
For macOS and Linux users:
- if you're running `git` commands in the terminal, `husky` will use the version defined in your shell `PATH`. In other words, if you're a `nvm` user, husky will use the version that you've set with `nvm`.
- if you're using a GUI client and `nvm`, it may have a different `PATH` and not load `nvm`, in this case the highest `node` version installed by `nvm` will usually be picked. You can also check `~/.node_path` to see which version is used by GUIs and edit if you want to use something else.
## ~/.huskyrc
`husky` will source `~/.huskyrc` file if it exists before running hook scripts.
You can use it, for example, to load a node version manager or run some `shell` commands before hooks.
```sh
# ~/.huskyrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
```
_This feature is experimental 🧪. Feedbacks are welcome._
## Debug
It's basic for the moment, but you can use `HUSKY_DEBUG=1` to log debug messages.
## Multiple commands
By design, `husky` will run hook scripts as a single command. Just like `scripts` defined in `package.json` are run.
```json
{
"pre-commit": "cmd && cmd && cmd"
}
```
That said, for readability, you may want to use an array. In this case, the recommended way is to define them in a `.huskyrc.js`
```js
const tasks = arr => arr.join(' && ')
module.exports = {
'hooks': {
'pre-commit': tasks([
'cmd',
'cmd',
'cmd'
])
}
}
```
Tools like [npm-run-all](https://github.com/mysticatea/npm-run-all) can help too.

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

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017
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.

112
node_modules/husky/README.md generated vendored Normal file
View file

@ -0,0 +1,112 @@
# husky
> Git hooks made easy
[![](https://img.shields.io/npm/dm/husky.svg?style=flat)](https://www.npmjs.org/package/husky) [![Mac/Linux Build Status](https://img.shields.io/travis/typicode/husky.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/typicode/husky) [![Windows Build status](https://img.shields.io/appveyor/ci/typicode/husky/master.svg?label=Windows)](https://ci.appveyor.com/project/typicode/husky)
Husky can prevent bad `git commit`, `git push` and more 🐶 _woof!_
## Sponsors
[__Support Husky and have your company logo here__](https://www.patreon.com/typicode)
Visit [thanks.typicode.com](https://thanks.typicode.com) 🌵 to view all the people supporting husky.
## Install
```sh
npm install husky --save-dev
```
```js
// package.json
{
"husky": {
"hooks": {
"pre-commit": "npm test",
"pre-push": "npm test",
"...": "..."
}
}
}
```
```sh
git commit -m 'Keep calm and commit'
```
To go further, see the docs [here](https://github.com/typicode/husky/blob/master/DOCS.md).
__Note__: there's a known issue with Node `v12.0`, please use `v12.1` or higher.
## Uninstall
```sh
npm uninstall husky
```
## Upgrading from 0.14
Simply move your existing hooks to `husky.hooks` field and use raw Git hooks names. Also, if you're using the `GIT_PARAMS` env variable, rename it to `HUSKY_GIT_PARAMS`.
```diff
{
"scripts": {
- "precommit": "npm test",
- "commitmsg": "commitlint -E GIT_PARAMS"
},
+ "husky": {
+ "hooks": {
+ "pre-commit": "npm test",
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
+ }
+ }
}
```
Alternatively, you can run the following command which will do the same automatically for you ;)
```
./node_modules/.bin/husky-upgrade
```
Starting with `1.0.0`, you can also configure hooks using `.huskyrc`, `.huskyrc.json` or `.huskyrc.js` file.
```js
// .huskyrc
{
"hooks": {
"pre-commit": "npm test"
}
}
```
To view the full list of changes, please see the [CHANGELOG](https://github.com/typicode/husky/blob/master/CHANGELOG.md).
## Features
* Keeps existing user hooks
* Supports GUI Git clients
* Supports all Git hooks (`pre-commit`, `pre-push`, ...)
## Used by
* [jQuery](https://github.com/jquery/jquery)
* [babel](https://github.com/babel/babel)
* [create-react-app](https://github.com/facebookincubator/create-react-app)
* [Next.js](https://github.com/zeit/next.js)
* [Hyper](https://github.com/zeit/hyper)
* [Kibana](https://github.com/elastic/kibana)
* [JSON Server](https://github.com/typicode/json-server)
* [Hotel](https://github.com/typicode/hotel)
* ... and many other awesome projects
## See also
* [pkg-ok](https://github.com/typicode/pkg-ok) - Prevents publishing a module with bad paths or incorrect line endings
* [please-upgrade-node](https://github.com/typicode/please-upgrade-node) - Show a message to upgrade Node instead of a stacktrace in your CLIs
* [pinst](https://github.com/typicode/pinst) - dev only postinstall hook
## License
MIT

15
node_modules/husky/husky.js generated vendored Normal file
View file

@ -0,0 +1,15 @@
/* eslint-disable */
const pleaseUpgradeNode = require('please-upgrade-node')
const pkg = require('./package.json')
// Node version isn't supported, skip install
pleaseUpgradeNode(pkg, {
exitCode: 0,
message: function(requiredVersion) {
return 'Husky requires Node ' + requiredVersion + ', skipping Git hooks installation.'
}
})
// Node version is supported, continue
require('./lib/installer/bin')

15
node_modules/husky/lib/getConf.js generated vendored Normal file
View file

@ -0,0 +1,15 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const cosmiconfig_1 = __importDefault(require("cosmiconfig"));
function getConf(dir) {
const explorer = cosmiconfig_1.default('husky');
const { config = {} } = explorer.searchSync(dir) || {};
const defaults = {
skipCI: true
};
return Object.assign({}, defaults, config);
}
exports.default = getConf;

29
node_modules/husky/lib/installer/bin.js generated vendored Normal file
View file

@ -0,0 +1,29 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const is_ci_1 = __importDefault(require("is-ci"));
const path_1 = __importDefault(require("path"));
const _1 = require("./");
// Just for testing
if (process.env.HUSKY_DEBUG === 'true' || process.env.HUSKY_DEBUG === '1') {
console.log(`husky:debug INIT_CWD=${process.env.INIT_CWD}`);
}
// Action can be "install" or "uninstall"
// huskyDir is ONLY used in dev, don't use this arguments
const [, , action, huskyDir = path_1.default.join(__dirname, '../..')] = process.argv;
// Find Git dir
try {
// Run installer
if (action === 'install') {
_1.install(huskyDir, undefined, is_ci_1.default);
}
else {
_1.uninstall(huskyDir);
}
}
catch (error) {
console.log(`husky > failed to ${action}`);
console.log(error.message);
}

99
node_modules/husky/lib/installer/getScript.js generated vendored Normal file
View file

@ -0,0 +1,99 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const slash_1 = __importDefault(require("slash"));
// Used to identify scripts created by Husky
exports.huskyIdentifier = '# husky';
// Experimental
const huskyrc = '~/.huskyrc';
// Render script
const render = ({ createdAt, homepage, node, pkgDirectory, pkgHomepage, platform, runScriptPath, version }) => `#!/bin/sh
${exports.huskyIdentifier}
# Hook created by Husky
# Version: ${version}
# At: ${createdAt}
# See: ${homepage}
# From
# Directory: ${pkgDirectory}
# Homepage: ${pkgHomepage}
scriptPath="${runScriptPath}.js"
hookName=\`basename "$0"\`
gitParams="$*"
debug() {
if [ "$\{HUSKY_DEBUG}" = "true" ] || [ "$\{HUSKY_DEBUG}" = "1" ]; then
echo "husky:debug $1"
fi
}
debug "$hookName hook started"
if [ "$\{HUSKY_SKIP_HOOKS}" = "true" ] || [ "$\{HUSKY_SKIP_HOOKS}" = "1" ]; then
debug "HUSKY_SKIP_HOOKS is set to $\{HUSKY_SKIP_HOOKS}, skipping hook"
exit 0
fi
${platform === 'win32'
? ''
: `
if ! command -v node >/dev/null 2>&1; then
echo "Info: can't find node in PATH, trying to find a node binary on your system"
fi
`}
if [ -f "$scriptPath" ]; then
# if [ -t 1 ]; then
# exec < /dev/tty
# fi
if [ -f ${huskyrc} ]; then
debug "source ${huskyrc}"
. ${huskyrc}
fi
${node} "$scriptPath" $hookName "$gitParams"
else
echo "Can't find Husky, skipping $hookName hook"
echo "You can reinstall it using 'npm install husky --save-dev' or delete this hook"
fi
`;
/**
* @param {string} rootDir - e.g. /home/typicode/project/
* @param {string} huskyDir - e.g. /home/typicode/project/node_modules/husky/
* @param {string} requireRunNodePath - path to run-node resolved by require e.g. /home/typicode/project/node_modules/run-node/run-node
* @param {string} platform - platform husky installer is running on (used to produce win32 specific script)
* @returns {string} script
*/
function default_1(rootDir, huskyDir, requireRunNodePath,
// Additional param used for testing only
platform = os_1.default.platform()) {
const runNodePath = slash_1.default(path_1.default.relative(rootDir, requireRunNodePath));
// On Windows do not rely on run-node
const node = platform === 'win32' ? 'node' : runNodePath;
// Env variable
const pkgHomepage = process && process.env && process.env.npm_package_homepage;
const pkgDirectory = process && process.env && process.env.PWD;
// Husky package.json
const { homepage, version } = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../package.json'), 'utf-8'));
// Path to run.js
const runScriptPath = slash_1.default(path_1.default.join(path_1.default.relative(rootDir, huskyDir), 'run'));
// Created at
const createdAt = new Date().toLocaleString();
// Render script
return render({
createdAt,
homepage,
node,
pkgDirectory,
pkgHomepage,
platform,
runScriptPath,
version
});
}
exports.default = default_1;

171
node_modules/husky/lib/installer/index.js generated vendored Normal file
View file

@ -0,0 +1,171 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const find_up_1 = __importDefault(require("find-up"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const pkg_dir_1 = __importDefault(require("pkg-dir"));
const getConf_1 = __importDefault(require("../getConf"));
const getScript_1 = __importDefault(require("./getScript"));
const is_1 = require("./is");
const resolveGitDir_1 = __importDefault(require("./resolveGitDir"));
const hookList = [
'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',
'sendemail-validate'
];
function writeHook(filename, script) {
fs_1.default.writeFileSync(filename, script, 'utf-8');
fs_1.default.chmodSync(filename, 0o0755);
}
function createHook(filename, script) {
// Get name, used for logging
const name = path_1.default.basename(filename);
// Check if hook exist
if (fs_1.default.existsSync(filename)) {
const hook = fs_1.default.readFileSync(filename, 'utf-8');
// Migrate
if (is_1.isGhooks(hook)) {
console.log(`migrating existing ghooks script: ${name}`);
return writeHook(filename, script);
}
// Migrate
if (is_1.isPreCommit(hook)) {
console.log(`migrating existing pre-commit script: ${name}`);
return writeHook(filename, script);
}
// Update
if (is_1.isHusky(hook) || is_1.isYorkie(hook)) {
return writeHook(filename, script);
}
// Skip
console.log(`skipping existing user hook: ${name}`);
return;
}
// Create hook if it doesn't exist
writeHook(filename, script);
}
function createHooks(filenames, script) {
filenames.forEach((filename) => createHook(filename, script));
}
function canRemove(filename) {
if (fs_1.default.existsSync(filename)) {
const data = fs_1.default.readFileSync(filename, 'utf-8');
return is_1.isHusky(data);
}
return false;
}
function removeHook(filename) {
fs_1.default.unlinkSync(filename);
}
function removeHooks(filenames) {
filenames.filter(canRemove).forEach(removeHook);
}
// This prevents the case where someone would want to debug a node_module that has
// husky as devDependency and run npm install from node_modules directory
function isInNodeModules(dir) {
// INIT_CWD holds the full path you were in when you ran npm install (supported also by yarn and pnpm)
// See https://docs.npmjs.com/cli/run-script
if (process.env.INIT_CWD) {
return process.env.INIT_CWD.indexOf('node_modules') !== -1;
}
// Old technique
return (dir.match(/node_modules/g) || []).length > 1;
}
function getHooks(gitDir) {
const gitHooksDir = path_1.default.join(gitDir, 'hooks');
return hookList.map((hookName) => path_1.default.join(gitHooksDir, hookName));
}
/**
* @param {string} huskyDir - e.g. /home/typicode/project/node_modules/husky/
* @param {string} requireRunNodePath - path to run-node resolved by require e.g. /home/typicode/project/node_modules/run-node/run-node
* @param {string} isCI - true if running in CI
*/
function install(huskyDir, requireRunNodePath = require.resolve('run-node/run-node'), isCI) {
console.log('husky > Setting up git hooks');
// First directory containing user's package.json
const userPkgDir = pkg_dir_1.default.sync(path_1.default.join(huskyDir, '..'));
if (userPkgDir === undefined) {
console.log("Can't find package.json, skipping Git hooks installation.");
console.log('Please check that your project has a package.json or create it and reinstall husky.');
return;
}
// Get conf from package.json or .huskyrc
const conf = getConf_1.default(userPkgDir);
// Get directory containing .git directory or in the case of Git submodules, the .git file
const gitDirOrFile = find_up_1.default.sync('.git', { cwd: userPkgDir });
// Resolve git directory (e.g. .git/ or .git/modules/path/to/submodule)
const resolvedGitDir = resolveGitDir_1.default(userPkgDir);
// Checks
if (process.env.HUSKY_SKIP_INSTALL === 'true') {
console.log("HUSKY_SKIP_INSTALL environment variable is set to 'true',", 'skipping Git hooks installation.');
return;
}
if (gitDirOrFile === null || gitDirOrFile === undefined) {
console.log("Can't find .git, skipping Git hooks installation.");
console.log("Please check that you're in a cloned repository", "or run 'git init' to create an empty Git repository and reinstall husky.");
return;
}
if (resolvedGitDir === null) {
console.log("Can't find resolved .git directory, skipping Git hooks installation.");
return;
}
if (isCI && conf.skipCI) {
console.log('CI detected, skipping Git hooks installation.');
return;
}
if (isInNodeModules(huskyDir)) {
console.log('Trying to install from node_modules directory, skipping Git hooks installation.');
return;
}
// Create hooks directory if doesn't exist
if (!fs_1.default.existsSync(path_1.default.join(resolvedGitDir, 'hooks'))) {
fs_1.default.mkdirSync(path_1.default.join(resolvedGitDir, 'hooks'));
}
// Create hooks
// Get root dir based on the first .git directory of file found
const rootDir = path_1.default.dirname(gitDirOrFile);
const hooks = getHooks(resolvedGitDir);
const script = getScript_1.default(rootDir, huskyDir, requireRunNodePath);
createHooks(hooks, script);
console.log(`husky > Done`);
console.log('husky > Like husky? You can support the project on Patreon:');
console.log('husky > \x1b[36m%s\x1b[0m 🐕', 'https://www.patreon.com/typicode');
}
exports.install = install;
function uninstall(huskyDir) {
console.log('husky > Uninstalling git hooks');
const userPkgDir = pkg_dir_1.default.sync(path_1.default.join(huskyDir, '..'));
const resolvedGitDir = resolveGitDir_1.default(userPkgDir);
if (resolvedGitDir === null) {
console.log("Can't find resolved .git directory, skipping Git hooks uninstallation.");
return;
}
if (isInNodeModules(huskyDir)) {
console.log('Trying to uninstall from node_modules directory, skipping Git hooks uninstallation.');
return;
}
// Remove hooks
const hooks = getHooks(resolvedGitDir);
removeHooks(hooks);
console.log('husky > Done');
}
exports.uninstall = uninstall;

24
node_modules/husky/lib/installer/is.js generated vendored Normal file
View file

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getScript_1 = require("./getScript");
function isHusky(data) {
// Husky v0.14 and prior used #husky as an identifier.
// Just in case some previous hooks weren't correctly uninstalled,
// and for a better transition this will allow v0.15+ to uninstall them as well.
const previousHuskyIdentifier = '#husky';
return (data.indexOf(getScript_1.huskyIdentifier) !== -1 ||
data.indexOf(previousHuskyIdentifier) !== -1);
}
exports.isHusky = isHusky;
function isYorkie(data) {
return data.indexOf('#yorkie') !== -1;
}
exports.isYorkie = isYorkie;
function isGhooks(data) {
return data.indexOf('// Generated by ghooks. Do not edit this file.') !== -1;
}
exports.isGhooks = isGhooks;
function isPreCommit(data) {
return data.indexOf('./node_modules/pre-commit/hook') !== -1;
}
exports.isPreCommit = isPreCommit;

39
node_modules/husky/lib/installer/resolveGitDir.js generated vendored Normal file
View file

@ -0,0 +1,39 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const find_up_1 = __importDefault(require("find-up"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
function default_1(cwd) {
const foundPath = find_up_1.default.sync('.git', { cwd });
if (foundPath) {
const stats = fs_1.default.lstatSync(foundPath);
// If it's a .git file resolve path
if (stats.isFile()) {
// Expect following format
// git: pathToGit
// On Windows pathToGit can contain ':' (example "gitdir: C:/Some/Path")
const gitFileData = fs_1.default.readFileSync(foundPath, 'utf-8');
const gitDir = gitFileData
.split(':')
.slice(1)
.join(':')
.trim();
const resolvedGitDir = path_1.default.resolve(path_1.default.dirname(foundPath), gitDir);
// For git-worktree, check if commondir file exists and return that path
const pathCommonDir = path_1.default.join(resolvedGitDir, 'commondir');
if (fs_1.default.existsSync(pathCommonDir)) {
const commondir = fs_1.default.readFileSync(pathCommonDir, 'utf-8').trim();
const resolvedCommonGitDir = path_1.default.join(resolvedGitDir, commondir);
return resolvedCommonGitDir;
}
return resolvedGitDir;
}
// Else return path to .git directory
return foundPath;
}
return null;
}
exports.default = default_1;

12
node_modules/husky/lib/runner/bin.js generated vendored Normal file
View file

@ -0,0 +1,12 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = __importDefault(require("./"));
_1.default(process.argv)
.then((status) => process.exit(status))
.catch((err) => {
console.log('Husky > unexpected error', err);
process.exit(1);
});

83
node_modules/husky/lib/runner/index.js generated vendored Normal file
View file

@ -0,0 +1,83 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const execa_1 = __importDefault(require("execa"));
const get_stdin_1 = __importDefault(require("get-stdin"));
const path_1 = __importDefault(require("path"));
const read_pkg_1 = __importDefault(require("read-pkg"));
const getConf_1 = __importDefault(require("../getConf"));
/**
* @param {array} argv - process.argv
* @param {promise} getStdinFn - used for mocking only
*/
function run([, scriptPath, hookName = '', HUSKY_GIT_PARAMS], getStdinFn = get_stdin_1.default) {
return __awaiter(this, void 0, void 0, function* () {
const cwd = path_1.default.resolve(scriptPath.split('node_modules')[0]);
// In some cases, package.json may not exist
// For example, when switching to gh-page branch
let pkg;
try {
pkg = read_pkg_1.default.sync({ cwd, normalize: false });
}
catch (err) {
if (err.code !== 'ENOENT') {
throw err;
}
}
const config = getConf_1.default(cwd);
const command = config && config.hooks && config.hooks[hookName];
const oldCommand = pkg && pkg.scripts && pkg.scripts[hookName.replace('-', '')];
// Run command
try {
const env = {};
if (HUSKY_GIT_PARAMS) {
env.HUSKY_GIT_PARAMS = HUSKY_GIT_PARAMS;
}
if (['pre-push', 'pre-receive', 'post-receive', 'post-rewrite'].includes(hookName)) {
// Wait for stdin
env.HUSKY_GIT_STDIN = yield getStdinFn();
}
if (command) {
console.log(`husky > ${hookName} (node ${process.version})`);
execa_1.default.shellSync(command, { cwd, env, stdio: 'inherit' });
return 0;
}
if (oldCommand) {
console.log();
console.log(`Warning: Setting ${hookName} script in package.json > scripts will be deprecated`);
console.log(`Please move it to husky.hooks in package.json, a .huskyrc file, or a husky.config.js file`);
console.log(`Or run ./node_modules/.bin/husky-upgrade for automatic update`);
console.log();
console.log(`See https://github.com/typicode/husky for usage`);
console.log();
console.log(`husky > ${hookName} (node ${process.version})`);
execa_1.default.shellSync(oldCommand, { cwd, env, stdio: 'inherit' });
return 0;
}
return 0;
}
catch (err) {
const noVerifyMessage = [
'commit-msg',
'pre-commit',
'pre-rebase',
'pre-push'
].includes(hookName)
? '(add --no-verify to bypass)'
: '(cannot be bypassed with --no-verify due to Git specs)';
console.log(`husky > ${hookName} hook failed ${noVerifyMessage}`);
return err.code;
}
});
}
exports.default = run;

8
node_modules/husky/lib/upgrader/bin.js generated vendored Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = __importDefault(require("./index"));
index_1.default(process.cwd());

64
node_modules/husky/lib/upgrader/index.js generated vendored Normal file
View file

@ -0,0 +1,64 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const read_pkg_1 = __importDefault(require("read-pkg"));
const hookList = {
applypatchmsg: 'applypatch-msg',
commitmsg: 'commit-msg',
postapplypatch: 'post-applypatch',
postcheckout: 'post-checkout',
postcommit: 'post-commit',
postmerge: 'post-merge',
postreceive: 'post-receive',
postrewrite: 'post-rewrite',
postupdate: 'post-update',
preapplypatch: 'pre-applypatch',
preautogc: 'pre-auto-gc',
precommit: 'pre-commit',
preparecommitmsg: 'prepare-commit-msg',
prepush: 'pre-push',
prerebase: 'pre-rebase',
prereceive: 'pre-receive',
pushtocheckout: 'push-to-checkout',
sendemailvalidate: 'sendemail-validate',
update: 'update'
};
function upgrade(cwd) {
const pkgFile = path_1.default.join(cwd, 'package.json');
if (fs_1.default.existsSync(pkgFile)) {
const pkg = read_pkg_1.default.sync({ cwd, normalize: false });
console.log(`husky > upgrading ${pkgFile}`);
// Don't overwrite 'husky' field if it exists
if (pkg.husky) {
return console.log(`husky field in package.json isn't empty, skipping automatic upgrade`);
}
const hooks = {};
// Find hooks in package.json 'scripts' field
Object.keys(hookList).forEach((name) => {
if (pkg.scripts) {
const script = pkg.scripts[name];
if (script) {
delete pkg.scripts[name];
const newName = hookList[name];
hooks[newName] = script.replace(/\bGIT_PARAMS\b/g, 'HUSKY_GIT_PARAMS');
console.log(`moved scripts.${name} to husky.hooks.${newName}`);
}
}
});
// Move found hooks to 'husky.hooks' field
if (Object.keys(hooks).length) {
pkg.husky = { hooks };
}
else {
console.log('no hooks found');
}
// Update package.json
fs_1.default.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8');
console.log(`husky > done`);
}
}
exports.default = upgrade;

105
node_modules/husky/package.json generated vendored Normal file
View file

@ -0,0 +1,105 @@
{
"name": "husky",
"version": "2.4.1",
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)",
"bin": {
"husky-upgrade": "./lib/upgrader/bin.js"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "npm run lint && jest",
"install": "node husky install",
"preuninstall": "node husky uninstall",
"devinstall": "npm run build && npm run _install -- node_modules/husky && node scripts/dev-fix-path",
"devuninstall": "npm run build && npm run preuninstall -- node_modules/husky",
"build": "del-cli lib && tsc",
"version": "jest -u && git add -A src/installer/__tests__/__snapshots__",
"postversion": "git push && git push --tags",
"prepublishOnly": "npm run test && npm run build && pinst --enable && pkg-ok",
"postpublish": "pinst --disable",
"lint": "eslint . --ext .js,.ts --ignore-path .gitignore",
"fix": "npm run lint -- --fix"
},
"repository": {
"type": "git",
"url": "git+https://github.com/typicode/husky.git"
},
"keywords": [
"git",
"hook",
"hooks",
"pre-commit",
"precommit",
"post-commit",
"postcommit",
"pre-push",
"prepush",
"post-merge",
"postmerge",
"test",
"lint"
],
"author": "Typicode <typicode@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/typicode/husky/issues"
},
"homepage": "https://github.com/typicode/husky#readme",
"dependencies": {
"cosmiconfig": "^5.2.0",
"execa": "^1.0.0",
"find-up": "^3.0.0",
"get-stdin": "^7.0.0",
"is-ci": "^2.0.0",
"pkg-dir": "^4.1.0",
"please-upgrade-node": "^3.1.1",
"read-pkg": "^5.1.1",
"run-node": "^1.0.0",
"slash": "^3.0.0"
},
"devDependencies": {
"@types/cosmiconfig": "^5.0.3",
"@types/find-up": "^2.1.1",
"@types/jest": "^24.0.13",
"@types/mkdirp": "^0.5.2",
"@types/node": "^12.0.1",
"@types/read-pkg": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"del": "^4.1.1",
"del-cli": "^1.1.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.2.0",
"eslint-config-xo-space": "^0.21.0",
"eslint-plugin-prettier": "^3.1.0",
"formatree": "^1.0.2",
"jest": "^24.8.0",
"mkdirp": "^0.5.1",
"pinst": "^1.1.1",
"pkg-ok": "^2.3.1",
"prettier": "^1.17.1",
"tempy": "^0.3.0",
"ts-jest": "^24.0.2",
"typescript": "^3.4.5"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
,"_resolved": "https://registry.npmjs.org/husky/-/husky-2.4.1.tgz"
,"_integrity": "sha512-ZRwMWHr7QruR22dQ5l3rEGXQ7rAQYsJYqaeCd+NyOsIFczAtqaApZQP3P4HwLZjCtFbm3SUNYoKuoBXX3AYYfw=="
,"_from": "husky@2.4.1"
}

13
node_modules/husky/run.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const pleaseUpgradeNode = require('please-upgrade-node')
const pkg = require('./package.json')
// Node version isn't supported, skip
pleaseUpgradeNode(pkg, {
message(requiredVersion) {
return 'Husky requires Node ' + requiredVersion + ", can't run Git hook."
}
})
// Node version is supported, continue
require('./lib/runner/bin')