0.4.7 • Published 3 years ago

@compgen/git-hooks v0.4.7

Weekly downloads
260
License
MIT
Repository
-
Last release
3 years ago

@compgen/git-hooks

A micro generator for essential git hooks:

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
npx @compgen/git-hooks

Programmatically

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

// 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
0.4.7

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.3.0

3 years ago

0.3.2

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

1.0.0

4 years ago