Swiftpack.co - lordcodes/swifthooks as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by lordcodes.
lordcodes/swifthooks v0.3.0
Share Git hooks between contributors and install using Tuist
⭐️ 1
🕓 4 weeks ago
macOS
.package(url: "https://github.com/lordcodes/swifthooks.git", from: "v0.3.0")

SwiftHooks

Swift Package Manager Latest release Twitter: @lordcodes


This is SwiftHooks - a tool and Tuist plugin to install Git hooks that can be distributed alongside a project and shared by all the contributors.

 

FeaturesInstallUsageContributing

Features

☑️ Store Git hooks within a project

Provide Git hooks for all project contributors to share.

☑️ Easily install into Git

Simply run a single command and a Git hook will be installed that runs your project-specific Git hooks.

☑️ Easily uninstall

A command is provided to remove any installed hooks.

 

Install

The primary intention was to use SwiftHooks as a Tuist plugin, however, it can also be used as a standard CLI tool as well.

▶︎ 🖥 As a Tuist Plugin

To set up as a Tuist plugin in your project simply follow the Tuist plugin install instructions using the latest version.

Add the plugin to Config.swift.

import ProjectDescription

let config = Config(
    plugins: [
        .git(url: "https://github.com/lordcodes/swifthooks.git", tag: "VERSION")
    ]
)

▶︎ 🖥 Standalone via Swift Package Manager

SwiftHooks can be easily installed globally using Swift Package Manager.

 git clone https://github.com/lordcodes/swifthooks-swift
 cd swifthooks-swift
 make install

This will install swifthooks into /usr/local/bin. If you get a permission error it may be that you don't have permission to write there in which case you just need to adjust permissions using sudo chown -R $(whoami) /usr/local/bin.

You can uninstall it again using make uninstall which simply deletes it from /usr/local/bin.

▶︎ 🍺 Homebrew

Support for Homebrew may be planned in the future.

▶︎ 📦 As a Swift package

To install SwiftHooks for use in your own Swift code, add it is a Swift Package Manager dependency within your Package.swift file. For help in doing this, please check out the Swift Package Manager documentation.

.package(url: "https://github.com/lordcodes/swifthooks", exact: "VERSION")

 

Usage

Configure project hooks

Git hooks should be stored inside a .git-hooks directory, which should be relative to the working directory. Inside create a folder named according to the required Git hook and then place the scripts you wish to run in an executable form within the hook folder.

For example:

.git-hooks/commit-msg/prepend-jira-issue-id.sh
.git-hooks/prepare-commit-msg/prepend-jira-issue-id.sh

Ensure the scripts are executable with chmod a+x .git-hooks/commit-msg/prepend-jira-issue-id.sh.

🖥 Via the Tuist Plugin

Ensure you have fetched with tuist fetch and you will then be able to run the plugin's tasks.

USAGE: tuist hooks <install|uninstall|version> [-q|--quiet]

ARGUMENTS:
  <install>               Installs Git hooks that run's hooks stored in project.
  <uninstall>             Uninstalls Git hooks that were installed.
  <version>               Prints out the current version of the tool.

OPTIONS:
  -q, --quiet             Silence any output except errors 

🖥 Via the Standalone CLI

USAGE: swifthooks <install|uninstall|version> [-q|--quiet]

ARGUMENTS:
  <install>               Installs Git hooks that run's hooks stored in project.
  <uninstall>             Uninstalls Git hooks that were installed.
  <version>               Prints out the current version of the tool.

OPTIONS:
  -q, --quiet             Silence any output except errors 

📦 As a Swift Package

To use SwiftHooks within your own Swift code, import and use the public API of SwiftHooksKit.

import SwiftHooksKit

// Configure printing
SwiftHooks.shared.printer = ConsolePrinter(quiet: false)

// Install hooks
try InstallHooksService().run()

// Uninstall hooks
try UninstallHooksService().run()

Contributing or Help

If you notice any bugs or have a new feature to suggest, please check out the contributing guide. If you want to make changes, please make sure to discuss anything big before putting in the effort of creating the PR.

To reach out, please contact @lordcodes on Twitter.

GitHub

link
Stars: 1
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Related Packages

Release Notes

0.3.0
4 weeks ago

Added

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics