Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): bump husky from 6.0.0 to 7.0.0 #992

Merged
merged 2 commits into from
Jul 5, 2021

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Jul 5, 2021

Bumps husky from 6.0.0 to 7.0.0.

Release notes

Sourced from husky's releases.

v7.0.0

  • Improve .husky/ directory structure. .husky/.gitignore is now unnecessary and can be removed.
  • Improve error output (shorter)
  • Update husky-init CLI
  • Update husky-4-to-7 CLI
  • Drop Node 10 support

Please help me develop and release OSS projects ❤️ on GitHub Sponsors or Open Collective. Thank you for your support!

Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Jul 5, 2021
@ybiquitous ybiquitous changed the title build(deps): bump husky from 6.0.0 to 7.0.0 feat(deps): bump husky from 6.0.0 to 7.0.0 Jul 5, 2021
@ybiquitous
Copy link
Owner

@dependabot rebase

@ybiquitous ybiquitous self-assigned this Jul 5, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2021

npm diff --diff=husky@6.0.0 --diff=husky@7.0.0 --diff-unified=2
diff --git a/lib/bin.js b/lib/bin.js
old mode 100644
new mode 100755
index v6.0.0..v7.0.0 
--- a/lib/bin.js
+++ b/lib/bin.js
@@ -2,38 +2,29 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-const fs = require("fs");
-const path = require("path");
-const _1 = require("./");
-function readPkg() {
-    return JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8'));
-}
-const pkg = readPkg();
-const [, , cmd, ...args] = process.argv;
-function version() {
-    console.log(pkg.version);
-}
-function help() {
-    console.log(`Usage
+const p = require("path");
+const h = require("./");
+function help(code) {
+    console.log(`Usage:
   husky install [dir] (default: .husky)
   husky uninstall
   husky set|add <file> [cmd]`);
+    process.exit(code);
 }
-function misuse() {
-    help();
-    process.exit(2);
-}
+const [, , cmd, ...args] = process.argv;
+const ln = args.length;
+const [x, y] = args;
+const hook = (fn) => () => !ln || ln > 2 ? help(2) : fn(x, y);
 const cmds = {
-    install(dir) {
-        args.length > 1 ? misuse() : _1.install(dir);
-    },
-    uninstall: _1.uninstall,
-    set(...args) {
-        args.length === 0 || args.length > 2 ? misuse() : _1.set(args[0], args[1]);
-    },
-    add(...args) {
-        args.length === 0 || args.length > 2 ? misuse() : _1.add(args[0], args[1]);
-    },
-    '--version': version,
-    '-v': version,
+    install: () => (ln > 1 ? help(2) : h.install(x)),
+    uninstall: h.uninstall,
+    set: hook(h.set),
+    add: hook(h.add),
+    ['-v']: () => console.log(require(p.join(__dirname, '../package.json')).version),
 };
-cmds[cmd] ? cmds[cmd](...args) : help();
+try {
+    cmds[cmd] ? cmds[cmd]() : help(0);
+}
+catch (e) {
+    console.error(e.message);
+    process.exit(1);
+}
diff --git a/lib/index.js b/lib/index.js
index v6.0.0..v7.0.0 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -2,17 +2,15 @@
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.uninstall = exports.add = exports.set = exports.install = void 0;
+const cp = require("child_process");
 const fs = require("fs");
-const cp = require("child_process");
-const path = require("path");
-function l(msg) {
-    console.log(`husky - ${msg}`);
-}
+const p = require("path");
+const l = (msg) => console.log(`husky - ${msg}`);
+const git = (args) => cp.spawnSync('git', args, { stdio: 'inherit' });
 function install(dir = '.husky') {
-    if (cp.spawnSync('git', ['rev-parse']).status !== 0) {
-        l('not a Git repository, skipping hooks installation');
+    if (git(['rev-parse']).status) {
         return;
     }
-    const url = 'https://typicode.github.io/husky/#/?id=custom-directory';
-    if (!path.resolve(process.cwd(), dir).startsWith(process.cwd())) {
+    const url = 'https://git.io/Jc3F9';
+    if (!p.resolve(process.cwd(), dir).startsWith(process.cwd())) {
         throw new Error(`.. not allowed (see ${url})`);
     }
@@ -21,8 +19,8 @@
     }
     try {
-        fs.mkdirSync(path.join(dir, '_'), { recursive: true });
-        fs.writeFileSync(path.join(dir, '.gitignore'), '_\n');
-        fs.copyFileSync(path.join(__dirname, 'husky.sh'), path.join(dir, '_/husky.sh'));
-        const { error } = cp.spawnSync('git', ['config', 'core.hooksPath', dir]);
+        fs.mkdirSync(p.join(dir, '_'), { recursive: true });
+        fs.writeFileSync(p.join(dir, '_/.gitignore'), '*');
+        fs.copyFileSync(p.join(__dirname, '../husky.sh'), p.join(dir, '_/husky.sh'));
+        const { error } = git(['config', 'core.hooksPath', dir]);
         if (error) {
             throw error;
@@ -37,5 +35,5 @@
 exports.install = install;
 function set(file, cmd) {
-    const dir = path.dirname(file);
+    const dir = p.dirname(file);
     if (!fs.existsSync(dir)) {
         throw new Error(`can't create hook, ${dir} directory doesn't exist (try running husky install)`);
@@ -60,7 +58,5 @@
 exports.add = add;
 function uninstall() {
-    cp.spawnSync('git', ['config', '--unset', 'core.hooksPath'], {
-        stdio: 'inherit',
-    });
+    git(['config', '--unset', 'core.hooksPath']);
 }
 exports.uninstall = uninstall;
diff --git a/package.json b/package.json
index v6.0.0..v7.0.0 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,6 @@
 {
   "name": "husky",
-  "version": "6.0.0",
+  "version": "7.0.0",
   "description": "Modern native Git hooks made easy",
-  "bin": "lib/bin.js",
-  "main": "lib/index.js",
-  "files": [
-    "lib"
-  ],
   "keywords": [
     "git",
@@ -13,9 +8,32 @@
     "pre-commit"
   ],
-  "author": "Typicode <typicode@gmail.com>",
-  "license": "MIT",
   "homepage": "https://typicode.github.io/husky",
-  "repository": "github:typicode/husky",
+  "repository": "typicode/husky",
   "funding": "https://github.com/sponsors/typicode",
-  "gitHead": "cb4e3b913e2d8963af3179650ed550d3a0e210f5"
+  "license": "MIT",
+  "author": "Typicode <typicode@gmail.com>",
+  "bin": "lib/bin.js",
+  "main": "lib/index.js",
+  "files": [
+    "lib",
+    "husky.sh"
+  ],
+  "scripts": {
+    "build": "tsc",
+    "test": "sh test/all.sh",
+    "serve": "docsify serve docs",
+    "prepare": "npm run build && node lib/bin install"
+  },
+  "devDependencies": {
+    "@commitlint/cli": "^12.0.1",
+    "@commitlint/config-conventional": "^12.0.1",
+    "@tsconfig/node12": "^1.0.7",
+    "@types/node": "^15.3.1",
+    "@typicode/eslint-config": "^0.1.2",
+    "docsify-cli": "^4.4.3",
+    "typescript": "^4.2.3"
+  },
+  "engines": {
+    "node": ">=12"
+  }
 }
diff --git a/README.md b/README.md
index v6.0.0..v7.0.0 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,14 @@
 # husky
 
-[![Open Collective](https://opencollective.com/husky/all/badge.svg?label=financial+contributors)](https://opencollective.com/husky) 
-
 > Modern native Git hooks made easy
 
 Husky improves your commits and more 🐶 *woof!*
 
+# Install
+
+```
+npm install husky --save-dev
+```
+
 # Usage
 
@@ -12,5 +16,6 @@
 
 ```sh
-npm set-script prepare "husky install" && npm run prepare
+npm set-script prepare "husky install"
+npm run prepare
 ```
 
@@ -25,4 +30,5 @@
 ```sh
 $ git commit -m "Keep calm and commit"
+# `npm test` will run
 ```
 
@@ -30,8 +36,2 @@
 
 https://typicode.github.io/husky
-
-__Important__ upgrading from v4 to v6 requires additional steps, please see the docs.
-
-## License
-
-MIT
diff --git a/lib/husky.sh b/lib/husky.sh
deleted file mode 100644
index v6.0.0..v7.0.0 
--- a/lib/husky.sh
+++ b/lib/husky.sh
@@ -1,30 +0,0 @@
-#!/bin/sh
-if [ -z "$husky_skip_init" ]; then
-  debug () {
-    [ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
-  }
-
-  readonly hook_name="$(basename "$0")"
-  debug "starting $hook_name..."
-
-  if [ "$HUSKY" = "0" ]; then
-    debug "HUSKY env variable is set to 0, skipping hook"
-    exit 0
-  fi
-
-  if [ -f ~/.huskyrc ]; then
-    debug "sourcing ~/.huskyrc"
-    . ~/.huskyrc
-  fi
-
-  export readonly husky_skip_init=1
-  sh -e "$0" "$@"
-  exitCode="$?"
-
-  if [ $exitCode != 0 ]; then
-    echo "husky - $hook_name hook exited with code $exitCode (error)"
-    exit $exitCode
-  fi
-
-  exit 0
-fi
\ No newline at end of file
diff --git a/husky.sh b/husky.sh
new file mode 100644
index v6.0.0..v7.0.0 
--- a/husky.sh
+++ b/husky.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+if [ -z "$husky_skip_init" ]; then
+  debug () {
+    [ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
+  }
+
+  readonly hook_name="$(basename "$0")"
+  debug "starting $hook_name..."
+
+  if [ "$HUSKY" = "0" ]; then
+    debug "HUSKY env variable is set to 0, skipping hook"
+    exit 0
+  fi
+
+  if [ -f ~/.huskyrc ]; then
+    debug "sourcing ~/.huskyrc"
+    . ~/.huskyrc
+  fi
+
+  export readonly husky_skip_init=1
+  sh -e "$0" "$@"
+  exitCode="$?"
+
+  if [ $exitCode != 0 ]; then
+    echo "husky - $hook_name hook exited with code $exitCode (error)"
+  fi
+
+  exit $exitCode
+fi

Posted by ybiquitous/npm-diff-action

Bumps [husky](https://github.com/typicode/husky) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](typicode/husky@v6.0.0...v7.0.0)

---
updated-dependencies:
- dependency-name: husky
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/husky-7.0.0 branch from 6ae8905 to 004660b Compare July 5, 2021 03:44
@ybiquitous ybiquitous merged commit 3076a00 into main Jul 5, 2021
@ybiquitous ybiquitous deleted the dependabot/npm_and_yarn/husky-7.0.0 branch July 5, 2021 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant