|
| 1 | +# @simple-release/hosted-git-info |
| 2 | + |
| 3 | +[![ESM-only package][package]][package-url] |
| 4 | +[![NPM version][npm]][npm-url] |
| 5 | +[![Node version][node]][node-url] |
| 6 | +[![Dependencies status][deps]][deps-url] |
| 7 | +[![Install size][size]][size-url] |
| 8 | +[![Build status][build]][build-url] |
| 9 | +[![Coverage status][coverage]][coverage-url] |
| 10 | + |
| 11 | +[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg |
| 12 | +[package-url]: https://nodejs.org/api/esm.html |
| 13 | + |
| 14 | +[npm]: https://img.shields.io/npm/v/@simple-release/hosted-git-info.svg |
| 15 | +[npm-url]: https://www.npmjs.com/package/@simple-release/hosted-git-info |
| 16 | + |
| 17 | +[node]: https://img.shields.io/node/v/@simple-release/hosted-git-info.svg |
| 18 | +[node-url]: https://nodejs.org |
| 19 | + |
| 20 | +[deps]: https://img.shields.io/librariesio/release/npm/@simple-release/hosted-git-info |
| 21 | +[deps-url]: https://libraries.io/npm/@simple-release%2Fhosted-git-info/tree |
| 22 | + |
| 23 | +[size]: https://packagephobia.com/badge?p=@simple-release/hosted-git-info |
| 24 | +[size-url]: https://packagephobia.com/result?p=@simple-release/hosted-git-info |
| 25 | + |
| 26 | +[build]: https://img.shields.io/github/actions/workflow/status/TrigenSoftware/simple-release-tools/tests.yml?branch=main |
| 27 | +[build-url]: https://github.com/TrigenSoftware/simple-release-tools/actions |
| 28 | + |
| 29 | +[coverage]: https://img.shields.io/codecov/c/github/TrigenSoftware/simple-release-tools.svg?flag=@simple-release/hosted-git-info |
| 30 | +[coverage-url]: https://app.codecov.io/gh/TrigenSoftware/simple-release-tools/tree/main/packages%2Fhosted-git-info |
| 31 | + |
| 32 | +A small library to parse hosted git info. |
| 33 | + |
| 34 | +## Install |
| 35 | + |
| 36 | +```bash |
| 37 | +# pnpm |
| 38 | +pnpm add @simple-release/hosted-git-info |
| 39 | +# yarn |
| 40 | +yarn add @simple-release/hosted-git-info |
| 41 | +# npm |
| 42 | +npm i @simple-release/hosted-git-info |
| 43 | +``` |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +```ts |
| 48 | +import { parseHostedGitUrl } from '@simple-release/hosted-git-info' |
| 49 | + |
| 50 | +parseHostedGitUrl('github:foo/bar') |
| 51 | +/* { |
| 52 | + type: 'github', |
| 53 | + url: 'https://github.com/foo/bar', |
| 54 | + host: 'https://github.com', |
| 55 | + owner: 'foo', |
| 56 | + project: 'bar' |
| 57 | +} */ |
| 58 | +parseHostedGitUrl('git+ssh://bitbucket.org:foo/bar.git') |
| 59 | +/* { |
| 60 | + type: 'bitbucket', |
| 61 | + url: 'https://bitbucket.org/foo/bar', |
| 62 | + host: 'https://bitbucket.org', |
| 63 | + owner: 'foo', |
| 64 | + project: 'bar' |
| 65 | +} */ |
| 66 | +parseHostedGitUrl( 'https://[email protected]/foo/bar.git#branch') |
| 67 | +/* { |
| 68 | + type: 'gitlab', |
| 69 | + url: 'https://gitlab.com/foo/bar/tree/branch', |
| 70 | + host: 'https://gitlab.com', |
| 71 | + owner: 'foo', |
| 72 | + project: 'bar' |
| 73 | +} */ |
| 74 | +``` |
0 commit comments