From a6c082f346e62ff2d2ac783065e8f23ea9f02ad9 Mon Sep 17 00:00:00 2001 From: Michael Mitchell Date: Wed, 26 Feb 2020 06:02:14 +1100 Subject: [PATCH] [hosted-git-info] Update types for 3.0 (#42499) Not exactly sure where the original author got `host` from but from what I can see it's always been `type`. Also remove `fromUrl` from the class as it's not actually a part of the class --- types/hosted-git-info/index.d.ts | 99 +++++++++++++------------------- 1 file changed, 39 insertions(+), 60 deletions(-) diff --git a/types/hosted-git-info/index.d.ts b/types/hosted-git-info/index.d.ts index a8e5cbdeda..d7b621ff9d 100644 --- a/types/hosted-git-info/index.d.ts +++ b/types/hosted-git-info/index.d.ts @@ -1,82 +1,61 @@ -// Type definitions for hosted-git-info 2.7 +// Type definitions for hosted-git-info 3.0 // Project: https://github.com/npm/hosted-git-info -// Definitions by: Jason +// Definitions by: Jason , Michael // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare class HostedGitInfo { - host: HostedGitInfo.hosts; - user: string | null; - auth: string | null; - project: string | null; - committish: string | null; +declare class GitHost { + constructor(type: GitHost.Hosts, user: string, auth: string | undefined, project: string, committish: string | undefined, defaultRepresentation: string, opts?: GitHost.FillOptions); + + type: GitHost.Hosts; + user: string; + auth?: string; + project: string; + committish?: string; default: string; - opts: HostedGitInfo.Options; + opts: GitHost.Options; + protocols: string[]; + domain: string; + treepath?: string; - 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 + // Templates sshtemplate: string; sshurltemplate: string; browsetemplate: string; + browsefiletemplate: string; docstemplate: string; + httpstemplate: string; filetemplate: string; shortcuttemplate: string; pathtemplate: string; + bugstemplate: string; + gittemplate?: string; + tarballtemplate: 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; + ssh(opts?: GitHost.FillOptions): string; + sshurl(opts?: GitHost.FillOptions): string; + browse(opts?: GitHost.FillOptions): string; + browse(path: string, opts?: GitHost.FillOptions): string; + browse(path: string, fragment: string, opts?: GitHost.FillOptions): string; + docs(opts?: GitHost.FillOptions): string; + bugs(opts?: GitHost.FillOptions): string; + https(opts?: GitHost.FillOptions): string; + git(opts?: GitHost.FillOptions): string; + shortcut(opts?: GitHost.FillOptions): string; + path(opts?: GitHost.FillOptions): string; + tarball(opts?: GitHost.FillOptions): string; + file(path: string, opts?: GitHost.FillOptions): string; getDefaultRepresentation(): string; - toString(opts?: HostedGitInfo.FillOptions): string | undefined; - - static fromUrl( - gitUrl: string, - options?: HostedGitInfo.Options - ): HostedGitInfo; + toString(opts?: GitHost.FillOptions): string; } -declare namespace HostedGitInfo { +declare namespace GitHost { + function fromUrl(gitUrl: string, opts?: Options): GitHost; + interface Options { noCommittish?: boolean; noGitPlus?: boolean; @@ -90,7 +69,7 @@ declare namespace HostedGitInfo { treepath?: string; } - type hosts = 'github' | 'bitbucket' | 'gitlab' | 'gist'; + type Hosts = 'github' | 'bitbucket' | 'gitlab' | 'gist'; } -export = HostedGitInfo; +export = GitHost;