2.1.0 • Published 7 months ago

hookpilot v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

HookPilot

HookPilot is a flexible and configurable Git hook manager that allows developers to automate workflows and enforce coding standards across the software development lifecycle. Whether you need to run linters, perform security checks, or trigger code formatting, HookPilot makes it seamless to integrate these tasks into Git hooks.


🚀 Features

  • Predefined Hooks: A library of ready-to-use hooks for common tasks like linting, formatting, testing, and more.
  • Customizable Configurations: Hooks can be configured to suit project-specific needs (e.g., branch protection, large file checks).
  • Lightweight and Fast: Designed to be minimal and efficient, avoiding unnecessary dependencies.
  • Extensible: Add custom scripts for unique workflows.

📦 Available Git Hooks

Below is the comprehensive list of hooks available in HookPilot, along with their specific tasks and configurations (where required).

🔹 pre-commit

Hooks that run before a commit is finalized.

NameDescriptionExternal DependencyAvailable Variables
LintingRun linting tools like ESLint to check code style and quality.Ensure linting tools (e.g., ESLint) are installed and configured.None
FormatAuto-format code using tools like Prettier.Ensure Prettier is installed and configured.files_to_format
Unit TestsRun unit tests to validate code changes.Nonetest_script_name
Security CheckPerform a security scan on dependencies using npm audit.Noneexcluded_files
Check DependenciesCheck for outdated dependencies.NoneNone
Build CheckVerify that the code compiles correctly before committing.Nonebuild_script_name

🔹 prepare-commit-msg

Hooks that prepare or modify the commit message.

NameDescriptionExternal DependencyAvailable Variables
Commit Message TemplatePre-fill commit message with a standard template.Nonetemplate
Add Version InfoAutomatically append version information to commit messages.NoneNone
Add Branch InfoAdd branch-specific information to commit messages.NoneNone

🔹 commit-msg

Hooks that validate commit messages.

NameDescriptionExternal DependencyAvailable Variables
Commit Message CheckEnforce Conventional Commit standards for messages.Noneallowed_commit_types
Check Message LengthEnsure commit messages adhere to length limits.Nonemax_length

🔹 post-commit

Hooks that run after a commit is finalized.

NameDescriptionExternal DependencyAvailable Variables
Log CommitLog commit information to a file or console.NoneNone
CleanupRemove unnecessary files and temporary data,NoneNone
Auto-update FilesAutomatically update files post-commit.NoneNone

🔹 pre-push

Hooks that run before code is pushed to a remote repository.

NameDescriptionExternal DependencyAvailable Variables
Unit Tests (npm test)Run unit tests before pushing code.NoneNone
Dependency CheckCheck for outdated or vulnerable dependencies.NoneNone
Block SecretsScan files for hardcoded secrets like keys and tokens.NoneNone
Check Large FilesBlock pushes containing large files.Set up large file limits in the script.None
Check Protected BranchesPrevent pushes to protected branches.Define protected branches in repository.None

🔹 post-merge

Hooks that run after a merge operation is completed.

NameDescriptionExternal DependencyAvailable Variables
Run MigrationsRun database migrations after a merge.Migration tools must be set up (e.g., Sequelize).None
Trigger DeploymentsTrigger deployments post-merge.Deployment pipelines must be configured.None
Reset ConfigurationsReset project configurations if required.NoneNone
Notify Teams (Slack)Notify teams about the merge.SLACK_WEBHOOK_URL must be set.None

🔹 post-checkout

Hooks that run after a branch or file checkout.

NameDescriptionExternal DependencyAvailable Variables
Reconfigure EnvironmentAdjust environment-specific configurations.Define environment configurations.None
Reset PermissionsReset file or directory permissions.Define permission settings.None
Handle Branch-specific TasksRun branch-specific scripts or tasks.Define branch-specific configurations.None

NOTE:The variable configuration for selected template can be updated from the hooks-config.json file under the config key.

📖 Usage

  1. Install HookPilot:

    npm install hookpilot --save-dev
  2. Initialize HookPilot in your project:

    npx hookpilot init
  3. Add or configure hooks using the interactive CLI:

    npx hookpilot add
  4. Restore hooks:

    npx hookpilot restore
  5. Remove hooks:

    npx hookpilot remove
  6. List hooks:
    npx hookpilot list

Here's the updated content with the added information about using --no-verify to override hooks:


Overriding Hooks

If you need to bypass the execution of Git hooks temporarily (e.g., for a quick commit or testing purposes), you can use the --no-verify flag. This skips all hooks for the specified Git operation.

Example:

git commit -m "Your commit message" --no-verify

Note: Use this flag cautiously, as skipping hooks might result in bypassing critical checks like linting, security scans, or tests.


🛠️ Configuration

Some hooks require additional configuration, like setting up environment variables, defining branch protection rules, or installing tools. See the Requires Configuration column for each hook to know what needs to be set up.


🔧 Extending HookPilot

HookPilot supports custom hooks through an interactive CLI process that guides you through hook creation and configuration.

Interactive Configuration Process

  1. Start the interactive hook configuration:

    npx hookpilot add
  2. Select the Git hook type you want to extend (e.g., pre-commit, post-merge, etc.)

  3. From the template menu, choose the "Custom (create your own)" option

  4. Specify the script path (shell script or Node.js)

Custom Script Example

Here's an example of a basic custom pre-commit hook:

#!/bin/bash
# Custom pre-commit hook

# Your custom logic here
echo "Running custom pre-commit hook..."

# Exit with appropriate status code
exit 0  # Success
exit 1  # Failure will abort the commit

Best Practices

Script Requirements

  • Ensure scripts are executable (chmod +x script.sh)
  • Follow exit code conventions:
    • 0 for success
    • Non-zero values for failure (will abort the Git operation)

Development Guidelines

  • Keep scripts focused on single responsibilities
  • Document any dependencies or configuration requirements
  • Test hooks thoroughly before deployment

Common Use Cases

  • Custom validation rules
  • Project-specific build processes
  • Integration with internal tools
  • Team-specific workflow automation

👨‍💻 Contributing

Contributions are welcome! Submit issues, feature requests, or pull requests to improve HookPilot.


📜 License

HookPilot is licensed under the MIT License.


📞 Support

For support or questions, reach out via GitHub Issues or at 123amitrana0123@gmail.com.

2.1.0

7 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.3

7 months ago

2.0.2

7 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.4.1

8 months ago

1.4.0

8 months ago

1.3.0

8 months ago

1.2.1

8 months ago

1.2.0

8 months ago

1.1.0

8 months ago

1.0.0

8 months ago