From 6e4e25a30e33a2269253b572c26dceffcdbf89c3 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Sun, 15 Jul 2018 21:47:32 +0200 Subject: [PATCH] add git-url-parse (#27233) --- types/git-url-parse/git-url-parse-tests.ts | 8 ++++ types/git-url-parse/index.d.ts | 48 ++++++++++++++++++++++ types/git-url-parse/tsconfig.json | 23 +++++++++++ types/git-url-parse/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/git-url-parse/git-url-parse-tests.ts create mode 100644 types/git-url-parse/index.d.ts create mode 100644 types/git-url-parse/tsconfig.json create mode 100644 types/git-url-parse/tslint.json diff --git a/types/git-url-parse/git-url-parse-tests.ts b/types/git-url-parse/git-url-parse-tests.ts new file mode 100644 index 0000000000..41fd0bd0f0 --- /dev/null +++ b/types/git-url-parse/git-url-parse-tests.ts @@ -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 diff --git a/types/git-url-parse/index.d.ts b/types/git-url-parse/index.d.ts new file mode 100644 index 0000000000..5c1d14ba7a --- /dev/null +++ b/types/git-url-parse/index.d.ts @@ -0,0 +1,48 @@ +// Type definitions for git-url-parse 9.0 +// Project: https://github.com/IonicaBizau/git-url-parse +// Definitions by: Klaus Meinhardt +// 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; diff --git a/types/git-url-parse/tsconfig.json b/types/git-url-parse/tsconfig.json new file mode 100644 index 0000000000..0261055b6f --- /dev/null +++ b/types/git-url-parse/tsconfig.json @@ -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" + ] +} diff --git a/types/git-url-parse/tslint.json b/types/git-url-parse/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/git-url-parse/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }