add git-url-parse (#27233)

This commit is contained in:
Klaus Meinhardt
2018-07-15 21:47:32 +02:00
committed by Ryan Cavanaugh
parent 6c93547985
commit 6e4e25a30e
4 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import gitUrlParse = require('git-url-parse');
gitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git"); // $ExpectType GitUrl
gitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git").toString(); // $ExpectType string
gitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git").toString('git+ssh'); // $ExpectType string
gitUrlParse.stringify(gitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git")); // $ExpectType string
gitUrlParse.stringify(gitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git"), 'https'); // $ExpectType string

48
types/git-url-parse/index.d.ts vendored Normal file
View File

@@ -0,0 +1,48 @@
// Type definitions for git-url-parse 9.0
// Project: https://github.com/IonicaBizau/git-url-parse
// Definitions by: Klaus Meinhardt <https://github.com/ajafff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace gitUrlParse {
interface GitUrl {
/** An array with the url protocols (usually it has one element). */
protocols: string[];
port: number | null;
/** The url domain (including subdomains). */
resource: string;
/** The authentication user (usually for ssh urls). */
user: string;
pathname: string;
hash: string;
search: string;
href: string;
protocol: string;
/** The oauth token (could appear in the https urls). */
token: string;
/** The Git provider (e.g. `"github.com"`). */
source: string;
/** The repository owner. */
owner: string;
/** The repository name. */
name: string;
/** The repository ref (e.g., "master" or "dev"). */
ref: string;
/** A filepath relative to the repository root. */
filepath: string;
/** The type of filepath in the url ("blob" or "tree"). */
filepathtype: string;
/** The owner and name values in the `owner/name` format. */
full_name: string;
/** The organization the owner belongs to. This is CloudForge specific. */
organization: string;
/** Whether to add the `.git` suffix or not. */
git_suffix?: boolean;
toString(type?: string): string;
}
function stringify(url: GitUrl, type?: string): string;
}
declare function gitUrlParse(url: string): gitUrlParse.GitUrl;
export = gitUrlParse;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"git-url-parse-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }