# @compgen/git-hooks

> A micro generator for essential git hooks:

Latest version **0.4.7** (published 2021-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @compgen/git-hooks
pnpm add @compgen/git-hooks
yarn add @compgen/git-hooks
bun add @compgen/git-hooks
```

Provides the command `git-hooks`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.7 |
| Published | 2021-03-30 |
| First published | 2020-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 1 |
| Unpacked size | 19.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | michal.jarnot |

## Links

- npm: https://www.npmjs.com/package/@compgen/git-hooks
- npm.io page: https://npm.io/package/@compgen/git-hooks

## Dependencies (1)

- [@compgen/core](https://npm.io/package/@compgen/core.md) ^0.9.0

## Recent versions

- 0.4.7 (latest) — 2021-03-30
- 0.4.6 — 2021-03-27
- 0.4.5 — 2021-02-21
- 0.4.4 — 2021-02-21
- 0.4.3 — 2021-02-21
- 0.4.2 — 2021-02-21
- 0.4.1 — 2021-02-21
- 0.4.0 — 2021-02-20
- 0.3.2 — 2021-02-20
- 0.3.1 — 2021-02-20
- 0.3.0 — 2021-02-20
- 0.2.0 — 2021-02-19
- 0.1.2 — 2021-02-19
- 0.1.1 — 2021-02-19
- 0.1.0 — 2021-02-19
- … 1 more at https://npm.io/package/@compgen/git-hooks/versions

## README

# @compgen/git-hooks

A micro generator for essential git hooks:

- [husky](https://github.com/typicode/husky)
- [lint-staged](https://github.com/okonet/lint-staged)
- [commitlint](https://github.com/conventional-changelog/commitlint)

### CLI

I highly recommend using `npx` so that you don't have to install anything globally, and you can always get the latest version from npm.

- **optional** `--path=target_folder`

```bash
npx @compgen/git-hooks
```

### Programmatically

You have to generate JSON schema and use `execute` function from `@compgen/core`:

```ts
// src/index.ts
import {
  execute,
  getProjectFolder,
  askYesNo,
  askAppType,
  AppType,
} from '@compgen/core'
import { createSchema } from '@compgen/git-hooks'

export const askIsEslint = () => askYesNo('Do you use eslint?')

export const askIsPrettier = () => askYesNo('Do you use prettier?')

export const askIsStylelint = () => askYesNo('Do you use stylelint?') // only ask in web projects

const generate = async () => {
  const projectFolder = getProjectFolder() ?? '.'
  const appType = await askAppType()
  const isEslint = await askIsEslint()
  const isPrettier = await askIsPrettier()

  let isStylelint = false

  if (appType !== AppType.NODE) {
    isStylelint = await askIsStylelint()
  }

  const schema = createSchema({
    appType,
    isEslint,
    isPrettier,
    isStylelint,
  })
  await execute(schema, projectFolder)
}

generate()
```

Now all you have to do is run:

```
ts-node src/index.ts
```

---
_Source: https://npm.io/package/@compgen/git-hooks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
