From 76cd44195602671cd30a7d15d1897c760179398d Mon Sep 17 00:00:00 2001 From: enoch Date: Mon, 7 Apr 2025 12:11:59 +0800 Subject: [PATCH] Keep calm and commit --- .husky/pre-commit | 1 + bun.lock | 13 +++++++++++++ node_modules/.bin/husky | 1 + node_modules/husky/LICENSE | 21 +++++++++++++++++++++ node_modules/husky/README.md | 1 + node_modules/husky/bin.js | 26 ++++++++++++++++++++++++++ node_modules/husky/husky | 22 ++++++++++++++++++++++ node_modules/husky/index.d.ts | 1 + node_modules/husky/index.js | 25 +++++++++++++++++++++++++ node_modules/husky/package.json | 25 +++++++++++++++++++++++++ package.json | 9 +++++++++ 11 files changed, 145 insertions(+) create mode 100644 .husky/pre-commit create mode 100644 bun.lock create mode 120000 node_modules/.bin/husky create mode 100644 node_modules/husky/LICENSE create mode 100644 node_modules/husky/README.md create mode 100755 node_modules/husky/bin.js create mode 100644 node_modules/husky/husky create mode 100644 node_modules/husky/index.d.ts create mode 100644 node_modules/husky/index.js create mode 100644 node_modules/husky/package.json create mode 100644 package.json diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..4dfead0 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +bun test diff --git a/bun.lock b/bun.lock new file mode 100644 index 0000000..043dd62 --- /dev/null +++ b/bun.lock @@ -0,0 +1,13 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "devDependencies": { + "husky": "^9.1.7", + }, + }, + }, + "packages": { + "husky": ["husky@9.1.7", "", { "bin": { "husky": "bin.js" } }, "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA=="], + } +} diff --git a/node_modules/.bin/husky b/node_modules/.bin/husky new file mode 120000 index 0000000..d5c33f5 --- /dev/null +++ b/node_modules/.bin/husky @@ -0,0 +1 @@ +../husky/bin.js \ No newline at end of file diff --git a/node_modules/husky/LICENSE b/node_modules/husky/LICENSE new file mode 100644 index 0000000..049c9dc --- /dev/null +++ b/node_modules/husky/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 typicode + +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. diff --git a/node_modules/husky/README.md b/node_modules/husky/README.md new file mode 100644 index 0000000..405cda7 --- /dev/null +++ b/node_modules/husky/README.md @@ -0,0 +1 @@ +https://typicode.github.io/husky diff --git a/node_modules/husky/bin.js b/node_modules/husky/bin.js new file mode 100755 index 0000000..244311b --- /dev/null +++ b/node_modules/husky/bin.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node +import f, { writeFileSync as w } from 'fs' +import i from './index.js' + +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] ?? 'npm') + ' test\n') + p.exit() +} + +d = c => console.error(`husky - ${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)) diff --git a/node_modules/husky/husky b/node_modules/husky/husky new file mode 100644 index 0000000..bf7c896 --- /dev/null +++ b/node_modules/husky/husky @@ -0,0 +1,22 @@ +#!/usr/bin/env sh +[ "$HUSKY" = "2" ] && set -x +n=$(basename "$0") +s=$(dirname "$(dirname "$0")")/$n + +[ ! -f "$s" ] && exit 0 + +if [ -f "$HOME/.huskyrc" ]; then + echo "husky - '~/.huskyrc' is DEPRECATED, please move your code to ~/.config/husky/init.sh" +fi +i="${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" +[ -f "$i" ] && . "$i" + +[ "${HUSKY-}" = "0" ] && exit 0 + +export PATH="node_modules/.bin:$PATH" +sh -e "$s" "$@" +c=$? + +[ $c != 0 ] && echo "husky - $n script failed (code $c)" +[ $c = 127 ] && echo "husky - command not found in PATH=$PATH" +exit $c diff --git a/node_modules/husky/index.d.ts b/node_modules/husky/index.d.ts new file mode 100644 index 0000000..72a5495 --- /dev/null +++ b/node_modules/husky/index.d.ts @@ -0,0 +1 @@ +export default function (dir?: string): string; \ No newline at end of file diff --git a/node_modules/husky/index.js b/node_modules/husky/index.js new file mode 100644 index 0000000..bebf0d5 --- /dev/null +++ b/node_modules/husky/index.js @@ -0,0 +1,25 @@ +import c from 'child_process' +import f, { readdir, writeFileSync as w } from 'fs' +import p from 'path' + +let l = [ 'pre-commit', 'pre-merge-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' ], + msg = `echo "husky - DEPRECATED\n\nPlease remove the following two lines from $0:\n\n#!/usr/bin/env sh\n. \\"\\$(dirname -- \\"\\$0\\")/_/husky.sh\\"\n\nThey WILL FAIL in v10.0.0\n"` + +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.rmSync(_('husky.sh'), { force: true }) + 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. "\$(dirname "\$0")/h"`, { mode: 0o755 })) + w(_('husky.sh'), msg) + return '' +} diff --git a/node_modules/husky/package.json b/node_modules/husky/package.json new file mode 100644 index 0000000..b9d3810 --- /dev/null +++ b/node_modules/husky/package.json @@ -0,0 +1,25 @@ +{ + "name": "husky", + "version": "9.1.7", + "type": "module", + "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.js" + }, + "exports": "./index.js", + "engines": { + "node": ">=18" + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b32e9a4 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": {}, + "devDependencies": { + "husky": "^9.1.7" + }, + "scripts": { + "prepare": "husky" + } +}