diff --git a/node_modules/.bin/husky b/node_modules/.bin/husky index adfcbbbaa..cef97e11c 120000 --- a/node_modules/.bin/husky +++ b/node_modules/.bin/husky @@ -1 +1 @@ -../husky/lib/bin.js \ No newline at end of file +../husky/bin.mjs \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 5c394008c..8272cc46f 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -3978,15 +3978,15 @@ } }, "node_modules/husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", + "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", "dev": true, "bin": { - "husky": "lib/bin.js" + "husky": "bin.mjs" }, "engines": { - "node": ">=14" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/typicode" diff --git a/node_modules/husky/README.md b/node_modules/husky/README.md index adfd3773f..405cda7da 100644 --- a/node_modules/husky/README.md +++ b/node_modules/husky/README.md @@ -1,38 +1 @@ -# husky - -> Modern native Git hooks made easy - -Husky improves your commits and more 🐶 *woof!* - -# Install - -``` -npm install husky --save-dev -``` - -# Usage - -Edit `package.json > prepare` script and run it once: - -```sh -npm pkg set scripts.prepare="husky install" -npm run prepare -``` - -Add a hook: - -```sh -npx husky add .husky/pre-commit "npm test" -git add .husky/pre-commit -``` - -Make a commit: - -```sh -git commit -m "Keep calm and commit" -# `npm test` will run -``` - -# Documentation - https://typicode.github.io/husky diff --git a/node_modules/husky/bin.mjs b/node_modules/husky/bin.mjs new file mode 100755 index 000000000..d954ed9ac --- /dev/null +++ b/node_modules/husky/bin.mjs @@ -0,0 +1,26 @@ +#!/usr/bin/env node +import f, { writeFileSync as w } from 'fs' +import i from './index.mjs' + +let p, a, n, s, o, d + +p = process +a = p.argv[2] + +if (a == 'init') { + n = 'package.json' + s = f.readFileSync(n) + o = JSON.parse(s) + ;(o.scripts ||= {}).prepare = 'husky' + w(n, JSON.stringify(o, 0, /\t/.test(s) ? '\t' : 2) + '\n') + p.stdout.write(i()) + try { f.mkdirSync('.husky') } catch {} + w('.husky/pre-commit', p.env.npm_config_user_agent.split('/')[0] + ' test\n') + p.exit() +} + +d = c => console.error(`${c} command is deprecated`) +if (['add', 'set', 'uninstall'].includes(a)) { d(a); p.exit(1) } +if (a == 'install') d(a) + +p.stdout.write(i(a == 'install' ? undefined : a)) \ No newline at end of file diff --git a/node_modules/husky/husky b/node_modules/husky/husky new file mode 100644 index 000000000..86bd0ba5f --- /dev/null +++ b/node_modules/husky/husky @@ -0,0 +1,20 @@ +#!/usr/bin/env sh +[ "$HUSKY" = "2" ] && set -x +h="${0##*/}" +s="${0%/*/*}/$h" + +[ ! -f "$s" ] && exit 0 + +for f in "${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" "$HOME/.huskyrc"; do + # shellcheck disable=SC1090 + [ -f "$f" ] && . "$f" +done + +[ "${HUSKY-}" = "0" ] && exit 0 + +sh -e "$s" "$@" +c=$? + +[ $c != 0 ] && echo "husky - $h script failed (code $c)" +[ $c = 127 ] && echo "husky - command not found in PATH=$PATH" +exit $c \ No newline at end of file diff --git a/node_modules/husky/husky.sh b/node_modules/husky/husky.sh deleted file mode 100644 index cec959a6b..000000000 --- a/node_modules/husky/husky.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env sh -if [ -z "$husky_skip_init" ]; then - debug () { - if [ "$HUSKY_DEBUG" = "1" ]; then - echo "husky (debug) - $1" - fi - } - - 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 - - readonly husky_skip_init=1 - export husky_skip_init - sh -e "$0" "$@" - exitCode="$?" - - if [ $exitCode != 0 ]; then - echo "husky - $hook_name hook exited with code $exitCode (error)" - fi - - if [ $exitCode = 127 ]; then - echo "husky - command not found in PATH=$PATH" - fi - - exit $exitCode -fi diff --git a/node_modules/husky/index.d.mts b/node_modules/husky/index.d.mts new file mode 100644 index 000000000..72a5495a8 --- /dev/null +++ b/node_modules/husky/index.d.mts @@ -0,0 +1 @@ +export default function (dir?: string): string; \ No newline at end of file diff --git a/node_modules/husky/index.mjs b/node_modules/husky/index.mjs new file mode 100644 index 000000000..f3a419cd0 --- /dev/null +++ b/node_modules/husky/index.mjs @@ -0,0 +1,23 @@ +import c from 'child_process' +import f, { writeFileSync as w } from 'fs' +import p from 'path' + +let l = [ 'pre-commit', 'prepare-commit-msg', 'commit-msg', 'post-commit', 'applypatch-msg', 'pre-applypatch', 'post-applypatch', 'pre-rebase', 'post-rewrite', 'post-checkout', 'post-merge', 'pre-push', 'pre-auto-gc' ] + +export default (d = '.husky') => { + if (process.env.HUSKY === '0') return 'HUSKY=0 skip install' + if (d.includes('..')) return '.. not allowed' + if (!f.existsSync('.git')) return `.git can't be found` + + let _ = (x = '') => p.join(d, '_', x) + let { status: s, stderr: e } = c.spawnSync('git', ['config', 'core.hooksPath', `${d}/_`]) + if (s == null) return 'git command not found' + if (s) return '' + e + + f.mkdirSync(_(), { recursive: true }) + w(_('.gitignore'), '*') + f.copyFileSync(new URL('husky', import.meta.url), _('h')) + l.forEach(h => w(_(h), `#!/usr/bin/env sh\n. "\${0%/*}/h"`, { mode: 0o755 })) + w(_('husky.sh'), '') + return '' +} \ No newline at end of file diff --git a/node_modules/husky/lib/bin.d.ts b/node_modules/husky/lib/bin.d.ts deleted file mode 100644 index b7988016d..000000000 --- a/node_modules/husky/lib/bin.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -export {}; diff --git a/node_modules/husky/lib/bin.js b/node_modules/husky/lib/bin.js deleted file mode 100755 index b867ba587..000000000 --- a/node_modules/husky/lib/bin.js +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env node -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const p = require("path"); -const h = require("./"); -function help(code) { - console.log(`Usage: - husky install [dir] (default: .husky) - husky uninstall - husky set|add [cmd]`); - process.exit(code); -} -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: () => (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), -}; -try { - cmds[cmd] ? cmds[cmd]() : help(0); -} -catch (e) { - console.error(e instanceof Error ? `husky - ${e.message}` : e); - process.exit(1); -} diff --git a/node_modules/husky/lib/index.d.ts b/node_modules/husky/lib/index.d.ts deleted file mode 100644 index 52062a040..000000000 --- a/node_modules/husky/lib/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare function install(dir?: string): void; -export declare function set(file: string, cmd: string): void; -export declare function add(file: string, cmd: string): void; -export declare function uninstall(): void; diff --git a/node_modules/husky/lib/index.js b/node_modules/husky/lib/index.js deleted file mode 100644 index 37ef89c7b..000000000 --- a/node_modules/husky/lib/index.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -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 p = require("path"); -const l = (msg) => console.log(`husky - ${msg}`); -const git = (args) => cp.spawnSync('git', args, { stdio: 'inherit' }); -function install(dir = '.husky') { - if (process.env.HUSKY === '0') { - l('HUSKY env variable is set to 0, skipping install'); - return; - } - if (git(['rev-parse']).status !== 0) { - l(`git command not found, skipping install`); - return; - } - const url = 'https://typicode.github.io/husky/#/?id=custom-directory'; - if (!p.resolve(process.cwd(), dir).startsWith(process.cwd())) { - throw new Error(`.. not allowed (see ${url})`); - } - if (!fs.existsSync('.git')) { - throw new Error(`.git can't be found (see ${url})`); - } - try { - 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; - } - } - catch (e) { - l('Git hooks failed to install'); - throw e; - } - l('Git hooks installed'); -} -exports.install = install; -function set(file, cmd) { - 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)`); - } - fs.writeFileSync(file, `#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -${cmd} -`, { mode: 0o0755 }); - l(`created ${file}`); -} -exports.set = set; -function add(file, cmd) { - if (fs.existsSync(file)) { - fs.appendFileSync(file, `${cmd}\n`); - l(`updated ${file}`); - } - else { - set(file, cmd); - } -} -exports.add = add; -function uninstall() { - git(['config', '--unset', 'core.hooksPath']); -} -exports.uninstall = uninstall; diff --git a/node_modules/husky/package.json b/node_modules/husky/package.json index 079ddd7fd..c1890fdc8 100644 --- a/node_modules/husky/package.json +++ b/node_modules/husky/package.json @@ -1,40 +1,24 @@ { - "name": "husky", - "version": "8.0.3", - "description": "Modern native Git hooks made easy", - "keywords": [ - "git", - "hooks", - "pre-commit" - ], - "homepage": "https://typicode.github.io/husky", - "repository": "typicode/husky", - "funding": "https://github.com/sponsors/typicode", - "license": "MIT", - "author": "Typicode ", - "bin": "lib/bin.js", - "main": "lib/index.js", - "files": [ - "lib", - "husky.sh" - ], - "scripts": { - "build": "tsc", - "test": "sh test/all.sh", - "lint": "eslint src --ext .ts", - "serve": "docsify serve docs", - "prepare": "npm run build && node lib/bin install" - }, - "devDependencies": { - "@commitlint/cli": "^17.3.0", - "@commitlint/config-conventional": "^17.3.0", - "@tsconfig/node14": "^1.0.3", - "@types/node": "^18.11.18", - "@typicode/eslint-config": "^1.1.0", - "docsify-cli": "^4.4.4", - "typescript": "^4.9.4" - }, - "engines": { - "node": ">=14" - } + "name": "husky", + "version": "9.0.11", + "description": "Modern native Git hooks", + "keywords": [ + "git", + "hooks", + "pre-commit" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/typicode/husky.git" + }, + "funding": "https://github.com/sponsors/typicode", + "license": "MIT", + "author": "typicode", + "bin": { + "husky": "bin.mjs" + }, + "exports": "./index.mjs", + "engines": { + "node": ">=18" + } } diff --git a/package-lock.json b/package-lock.json index dadcbb5b4..c2dddf69a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@types/jest": "^29.2.5", "@types/node": "^20.11.5", "depcheck": "^1.4.7", - "husky": "^8.0.3", + "husky": "^9.0.11", "jest": "^26.6.3", "prettier": "^3.2.5", "ts-jest": "^26.5.6", @@ -4013,15 +4013,15 @@ } }, "node_modules/husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", + "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", "dev": true, "bin": { - "husky": "lib/bin.js" + "husky": "bin.mjs" }, "engines": { - "node": ">=14" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/typicode" @@ -12082,9 +12082,9 @@ "dev": true }, "husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", + "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", "dev": true }, "iconv-lite": { diff --git a/package.json b/package.json index 6cb196a20..fb2481ef4 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@types/jest": "^29.2.5", "@types/node": "^20.11.5", "depcheck": "^1.4.7", - "husky": "^8.0.3", + "husky": "^9.0.11", "jest": "^26.6.3", "prettier": "^3.2.5", "ts-jest": "^26.5.6",