From ba5bd93c828466118537a98211c835fdeb39c42e Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 31 Oct 2018 22:27:07 +0000 Subject: [PATCH] Adding hosted-git-info --- .../hosted-git-info/hosted-git-info-tests.ts | 22 +++++ types/hosted-git-info/index.d.ts | 96 +++++++++++++++++++ types/hosted-git-info/tsconfig.json | 23 +++++ types/hosted-git-info/tslint.json | 1 + 4 files changed, 142 insertions(+) create mode 100644 types/hosted-git-info/hosted-git-info-tests.ts create mode 100644 types/hosted-git-info/index.d.ts create mode 100644 types/hosted-git-info/tsconfig.json create mode 100644 types/hosted-git-info/tslint.json diff --git a/types/hosted-git-info/hosted-git-info-tests.ts b/types/hosted-git-info/hosted-git-info-tests.ts new file mode 100644 index 0000000000..0e4ef56cb7 --- /dev/null +++ b/types/hosted-git-info/hosted-git-info-tests.ts @@ -0,0 +1,22 @@ +import info = require("hosted-git-info"); + +info.fromUrl(''); +const result = info.fromUrl('', {}); + +result.hashformat(''); +result.hash(); +result.ssh({}); +result.sshurl({}); +result.browse('', '', {}); +result.browse('', {}); +result.browse({}); +result.docs({}); +result.bugs({}); +result.https({}); +result.git({}); +result.shortcut({}); +result.path({}); +result.tarball({}); +result.file('', {}); +result.getDefaultRepresentation(); +result.toString({}); diff --git a/types/hosted-git-info/index.d.ts b/types/hosted-git-info/index.d.ts new file mode 100644 index 0000000000..a8e5cbdeda --- /dev/null +++ b/types/hosted-git-info/index.d.ts @@ -0,0 +1,96 @@ +// Type definitions for hosted-git-info 2.7 +// Project: https://github.com/npm/hosted-git-info +// Definitions by: Jason +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class HostedGitInfo { + host: HostedGitInfo.hosts; + user: string | null; + auth: string | null; + project: string | null; + committish: string | null; + default: string; + opts: HostedGitInfo.Options; + + constructor( + host: HostedGitInfo.hosts, + user: string | null, + auth: string | null, + project: string | null, + committish: string | null, + defaultRepresentation: string, + opts?: HostedGitInfo.Options + ); + + // From git-host-info + + // defaults + sshtemplate: string; + sshurltemplate: string; + browsetemplate: string; + docstemplate: string; + filetemplate: string; + shortcuttemplate: string; + pathtemplate: string; + + pathmatch: RegExp; + protocols_re: RegExp; + hashformat(fragment: string): string; + + // special + protocols: string[]; + domain: string; + bugstemplate: string; + gittemplate: string; + browsefiletemplate: string; + httpstemplate: string; + treepath: string; + tarballtemplate: string; + + // /From git-host-info + + hash(): string; + ssh(opts?: HostedGitInfo.FillOptions): string | undefined; + sshurl(opts?: HostedGitInfo.FillOptions): string | undefined; + browse( + path: string, + fragment: string, + opts?: HostedGitInfo.FillOptions + ): string | undefined; + browse(path: string, opts?: HostedGitInfo.FillOptions): string | undefined; + browse(opts?: HostedGitInfo.FillOptions): string | undefined; + docs(opts?: HostedGitInfo.FillOptions): string | undefined; + bugs(opts?: HostedGitInfo.FillOptions): string | undefined; + https(opts?: HostedGitInfo.FillOptions): string | undefined; + git(opts?: HostedGitInfo.FillOptions): string | undefined; + shortcut(opts?: HostedGitInfo.FillOptions): string | undefined; + path(opts?: HostedGitInfo.FillOptions): string | undefined; + tarball(opts?: HostedGitInfo.FillOptions): string | undefined; + file(path: string, opts?: HostedGitInfo.FillOptions): string | undefined; + getDefaultRepresentation(): string; + toString(opts?: HostedGitInfo.FillOptions): string | undefined; + + static fromUrl( + gitUrl: string, + options?: HostedGitInfo.Options + ): HostedGitInfo; +} + +declare namespace HostedGitInfo { + interface Options { + noCommittish?: boolean; + noGitPlus?: boolean; + } + + interface FillOptions extends Options { + path?: string; + auth?: string; + fragment?: string; + committish?: string; + treepath?: string; + } + + type hosts = 'github' | 'bitbucket' | 'gitlab' | 'gist'; +} + +export = HostedGitInfo; diff --git a/types/hosted-git-info/tsconfig.json b/types/hosted-git-info/tsconfig.json new file mode 100644 index 0000000000..5736539a96 --- /dev/null +++ b/types/hosted-git-info/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hosted-git-info-tests.ts" + ] +} diff --git a/types/hosted-git-info/tslint.json b/types/hosted-git-info/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hosted-git-info/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }