Skip to content

v0.1.0

Choose a tag to compare

@github-actions github-actions released this 11 Nov 17:55
· 74 commits to main since this release
v0.1.0
84637f9

First release of Ward: git hooks from one config file, with no hook folder in your repo. This version replaces husky.

Warning

Ward is in early development (0.x). Until 1.0, any minor release may change the config and behavior.

Install

npm install -D @hexlabelposition/ward
npm pkg set scripts.prepare=ward
npm run prepare

Published with npm provenance. Requires Node.js 24 or later. One runtime dependency (yaml), ESM-only.

What's in v0.1

Config

  • One config for all hooks: ward.config.ts, ward.yml / ward.yaml, or a "ward" section in package.json. Finding more than one is an error, not a silent pick.
  • defineConfig() gives types and autocomplete; the TS config is loaded by Node's built-in type stripping, with no loader dependency.
  • A hook is a command, a list of commands, or named tasks: "cmd", ["a", "b"], { tasks: { name: { run: "cmd" } } }.
  • The whole config is checked on every run. Every problem is listed with its place in the config, and typos get a suggestion: hooks.pre-comit: unknown hook. Did you mean "pre-commit"?
  • Options from later versions (glob, parallel, …) fail as "not supported yet" instead of being ignored.

Install

  • ward, run from prepare, writes a small stub for every git hook into .git/hooks. Only the config is committed.
  • The config is read at run time, so changes apply on the next git command, with no reinstall.
  • Existing hooks are never overwritten silently: Ward asks in a terminal and warns from prepare. --chain keeps them and runs them before Ward, --force replaces them.
  • core.hooksPath is detected and reported with the command that fixes it; --respect-hooks-path installs there instead.
  • Install does nothing in CI, outside a git repository and without git, so npm install does not fail.
  • ward uninstall removes only Ward's stubs and puts chained hooks back.

Run

  • Tasks run in order through the system shell from the repo root. The first failure stops the hook, and git gets its exit code.
  • {1}, {2}, … expand to the arguments git passed to the hook: commitlint --edit {1}.
  • A hook with no tasks exits right away.
  • WARD=0 skips Ward for one command; hooks are skipped automatically during a merge or rebase.

Moving from husky

Move the commands from .husky/* into the config, delete the folder and run git config --unset core.hooksPath. See Moving from husky.

Tested on

Ubuntu, macOS and Windows, on Node.js 24 and the current release.

What's next

  • v0.2: replace lint-staged: tasks on staged files with glob and {staged_files}, safe partial staging, parallel tasks.
  • v0.3: Bun and Deno.

See BACKLOG.md.

Full Changelog: https://github.com/hexlabelposition/ward/commits/v0.1.0