@conventional-changelog/git-client
Version:
Simple git client for conventional changelog packages.
135 lines (86 loc) • 4.19 kB
Markdown
[![ESM-only package][package]][package-url]
[![NPM version][npm]][npm-url]
[![Node version][node]][node-url]
[![Dependencies status][deps]][deps-url]
[![Install size][size]][size-url]
[![Build status][build]][build-url]
[![Coverage status][coverage]][coverage-url]
[]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[]: https://nodejs.org/api/esm.html
[]: https://img.shields.io/npm/v/@conventional-changelog/git-client.svg
[]: https://npmjs.com/package/@conventional-changelog/git-client
[]: https://img.shields.io/node/v/@conventional-changelog/git-client.svg
[]: https://nodejs.org
[]: https://img.shields.io/librariesio/release/npm/@conventional-changelog/git-client
[]: https://libraries.io/npm/@conventional-changelog%2Fgit-client/tree
[]: https://packagephobia.com/badge?p=@conventional-changelog/git-client
[]: https://packagephobia.com/result?p=@conventional-changelog/git-client
[]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/tests.yaml?branch=master
[]: https://github.com/conventional-changelog/conventional-changelog/actions
[]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
[]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
Simple git client for conventional changelog packages.
<hr />
<a href="#install">Install</a>
<span> • </span>
<a href="#usage">Usage</a>
<span> • </span>
<a href="#api">API</a>
<br />
<hr />
```bash
pnpm add @conventional-changelog/git-client conventional-commits-filter conventional-commits-parser
yarn add @conventional-changelog/git-client conventional-commits-filter conventional-commits-parser
npm i @conventional-changelog/git-client conventional-commits-filter conventional-commits-parser
```
Note: `conventional-commits-filter` and `conventional-commits-parser` are required only if you need `ConventionalGitClient
```js
import {
GitClient,
ConventionalGitClient
} from '@conventional-changelog/git-client'
// Basic git client
const client = new GitClient(process.cwd())
await client.add('package.json')
await client.commit({ message: 'chore: release v1.0.0' })
await client.tag({ name: 'v1.0.0' })
await client.push('master')
// Conventional git client, which extends basic git client
const conventionalClient = new ConventionalGitClient(process.cwd())
console.log(await conventionalClient.getVersionFromTags()) // v1.0.0
```
Create a wrapper around `git` CLI instance.
Get raw commits stream.
Get tags stream.
Check file is ignored via .gitignore.
Add files to git index.
Commit changes.
Create a tag for the current commit.
Get current branch name.
Push changes to remote.
Wrapper around Git CLI with conventional commits support.
Get parsed commits stream.
Get semver tags stream.
Get current sematic version from git tags.
MIT © [Dan Onoshko](https://github.com/dangreen)