UNPKG

2.91 kBTypeScriptView Raw
1// Type definitions for hosted-git-info 3.0
2// Project: https://github.com/npm/hosted-git-info
3// Definitions by: Jason <https://github.com/OiyouYeahYou>, Michael <https://github.com/Ovyerus>, Daniel Cassidy <https://github.com/djcsdy>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6declare class GitHost {
7 constructor(
8 type: GitHost.Hosts,
9 user: string,
10 auth: string | undefined,
11 project: string,
12 committish?: string,
13 defaultRepresentation?: GitHost.Representation,
14 opts?: GitHost.FillOptions,
15 );
16
17 type: GitHost.Hosts;
18 user: string;
19 auth?: string | undefined;
20 project: string;
21 committish?: string | undefined;
22 default?: string | undefined;
23 opts: GitHost.Options;
24 protocols: string[];
25 domain: string;
26 treepath?: string | undefined;
27
28 // Templates
29 sshtemplate: string;
30 sshurltemplate: string;
31 browsetemplate: string;
32 browsefiletemplate: string;
33 docstemplate: string;
34 httpstemplate: string;
35 filetemplate: string;
36 shortcuttemplate: string;
37 pathtemplate: string;
38 bugstemplate: string;
39 gittemplate?: string | undefined;
40 tarballtemplate: string;
41
42 pathmatch: RegExp;
43 protocols_re: RegExp;
44 hashformat(fragment: string): string;
45
46 hash(): string;
47 ssh(opts?: GitHost.FillOptions): string;
48 sshurl(opts?: GitHost.FillOptions): string;
49 browse(opts?: GitHost.FillOptions): string;
50 browse(path: string, opts?: GitHost.FillOptions): string;
51 browse(path: string, fragment: string, opts?: GitHost.FillOptions): string;
52 docs(opts?: GitHost.FillOptions): string;
53 bugs(opts?: GitHost.FillOptions): string;
54 https(opts?: GitHost.FillOptions): string;
55 git(opts?: GitHost.FillOptions): string;
56 shortcut(opts?: GitHost.FillOptions): string;
57 path(opts?: GitHost.FillOptions): string;
58 tarball(opts?: GitHost.FillOptions): string;
59 file(path: string, opts?: GitHost.FillOptions): string;
60 getDefaultRepresentation(): GitHost.Representation | undefined;
61 toString(opts?: GitHost.FillOptions): string;
62}
63
64declare namespace GitHost {
65 function fromUrl(gitUrl: string, opts?: Options): GitHost | undefined;
66
67 interface Options {
68 noCommittish?: boolean | undefined;
69 noGitPlus?: boolean | undefined;
70 }
71
72 interface FillOptions extends Options {
73 path?: string | undefined;
74 auth?: string | undefined;
75 fragment?: string | undefined;
76 committish?: string | undefined;
77 treepath?: string | undefined;
78 }
79
80 type Hosts = 'github' | 'bitbucket' | 'gitlab' | 'gist';
81
82 type Representation =
83 | 'hash'
84 | 'ssh'
85 | 'sshurl'
86 | 'browse'
87 | 'docs'
88 | 'bugs'
89 | 'https'
90 | 'git'
91 | 'shortcut'
92 | 'path'
93 | 'tarball'
94 | 'file';
95}
96
97export = GitHost;