Skip to content

Commit 6141518

Browse files
committed
feat(hosted-git-info): a small library to parse hosted git info
1 parent e8e8e02 commit 6141518

File tree

12 files changed

+10184
-10
lines changed

12 files changed

+10184
-10
lines changed

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,16 @@
1515

1616
A set of packages with simple utilities.
1717

18-
<!--
19-
2018
## Available tools
2119

2220
| Name | Description | Version | Dependencies |
2321
|------|-------------|---------|--------------|
24-
| [`simple-github-release`](packages/simple-github-release#readme) | A simple tool to create GitHub releases. | [![NPM version][simple-github-release-npm]][simple-github-release-npm-url] | [![Dependencies status][simple-github-release-deps]][simple-github-release-deps-url] |
25-
26-
<!-- simple-github-release - - >
22+
| [`@simple-libs/hosted-git-info`](packages/hosted-git-info#readme) | A small library to parse hosted git info. | [![NPM version][hosted-git-info-npm]][hosted-git-info-npm-url] | [![Dependencies status][hosted-git-info-deps]][hosted-git-info-deps-url] |
2723

28-
[simple-github-release-npm]: https://img.shields.io/npm/v/simple-github-release.svg
29-
[simple-github-release-npm-url]: https://www.npmjs.com/package/simple-github-release
24+
<!-- hosted-git-info -->
3025

31-
[simple-github-release-deps]: https://img.shields.io/librariesio/release/npm/simple-github-release
32-
[simple-github-release-deps-url]: https://libraries.io/npm/simple-github-release/tree
26+
[hosted-git-info-npm]: https://img.shields.io/npm/v/@simple-libs/hosted-git-info.svg
27+
[hosted-git-info-npm-url]: https://www.npmjs.com/package/@simple-libs/hosted-git-info
3328

34-
-->
29+
[hosted-git-info-deps]: https://img.shields.io/librariesio/release/npm/@simple-libs/hosted-git-info
30+
[hosted-git-info-deps-url]: https://libraries.io/npm/@simple-libs%2hosted-git-info/tree
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": [
3+
"@trigen/eslint-config/typescript",
4+
"@trigen/eslint-config/typescript-requiring-type-checking",
5+
"@trigen/eslint-config/jest"
6+
],
7+
"parserOptions": {
8+
"tsconfigRootDir": "./packages/hosted-git-info",
9+
"project": ["./tsconfig.json"]
10+
},
11+
"rules": {
12+
"prefer-destructuring": "off"
13+
}
14+
}

packages/hosted-git-info/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# @simple-libs/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-libs/hosted-git-info.svg
15+
[npm-url]: https://www.npmjs.com/package/@simple-libs/hosted-git-info
16+
17+
[node]: https://img.shields.io/node/v/@simple-libs/hosted-git-info.svg
18+
[node-url]: https://nodejs.org
19+
20+
[deps]: https://img.shields.io/librariesio/release/npm/@simple-libs/hosted-git-info
21+
[deps-url]: https://libraries.io/npm/@simple-libs%2Fhosted-git-info/tree
22+
23+
[size]: https://packagephobia.com/badge?p=@simple-libs/hosted-git-info
24+
[size-url]: https://packagephobia.com/result?p=@simple-libs/hosted-git-info
25+
26+
[build]: https://img.shields.io/github/actions/workflow/status/TrigenSoftware/simple-libs/tests.yml?branch=main
27+
[build-url]: https://github.com/TrigenSoftware/simple-libs/actions
28+
29+
[coverage]: https://img.shields.io/codecov/c/github/TrigenSoftware/simple-libs.svg?flag=@simple-libs/hosted-git-info
30+
[coverage-url]: https://app.codecov.io/gh/TrigenSoftware/simple-libs/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-libs/hosted-git-info
39+
# yarn
40+
yarn add @simple-libs/hosted-git-info
41+
# npm
42+
npm i @simple-libs/hosted-git-info
43+
```
44+
45+
## Usage
46+
47+
```ts
48+
import { parseHostedGitUrl } from '@simple-libs/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+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "@simple-libs/hosted-git-info",
3+
"type": "module",
4+
"version": "1.0.0",
5+
"description": "A small library to parse hosted git info.",
6+
"author": {
7+
"name": "Dan Onoshko",
8+
"email": "[email protected]",
9+
"url": "https://github.com/dangreen"
10+
},
11+
"license": "MIT",
12+
"homepage": "https://github.com/TrigenSoftware/simple-libs/tree/master/packages/hosted-git-info#readme",
13+
"funding": "https://ko-fi.com/dangreen",
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/TrigenSoftware/simple-libs.git",
17+
"directory": "packages/hosted-git-info"
18+
},
19+
"bugs": {
20+
"url": "https://github.com/TrigenSoftware/simple-libs/issues"
21+
},
22+
"keywords": [
23+
"git",
24+
"github",
25+
"bitbucket",
26+
"gitlab",
27+
"hosted-git-info"
28+
],
29+
"engines": {
30+
"node": ">=18"
31+
},
32+
"exports": "./src/index.ts",
33+
"publishConfig": {
34+
"exports": {
35+
"types": "./dist/index.d.ts",
36+
"import": "./dist/index.js"
37+
},
38+
"directory": "package",
39+
"linkDirectory": false
40+
},
41+
"files": [
42+
"dist"
43+
],
44+
"scripts": {
45+
"clear:package": "del ./package",
46+
"clear:dist": "del ./dist",
47+
"clear": "del ./package ./dist ./coverage",
48+
"prepublishOnly": "run build clear:package clean-publish",
49+
"postpublish": "pnpm clear:package",
50+
"build": "tsc -p tsconfig.build.json",
51+
"lint": "eslint --parser-options tsconfigRootDir:. '**/*.{js,ts}'",
52+
"test:unit": "vitest run --coverage",
53+
"test:types": "tsc --noEmit",
54+
"test": "run -p lint test:unit test:types"
55+
}
56+
}

0 commit comments

Comments
 (0)