refactor providers again
This commit is contained in:
parent
109155631d
commit
a74bafd3a1
2 changed files with 9 additions and 11 deletions
|
@ -56,7 +56,7 @@ export class IndexFileEntry {
|
|||
return new ModrinthProvider(
|
||||
parsed.download.hash,
|
||||
parsed.download["hash-format"],
|
||||
parsed.download.url,
|
||||
new Resource(parsed.download.url),
|
||||
parsed.update.modrinth["mod-id"],
|
||||
parsed.update.modrinth["version"],
|
||||
);
|
||||
|
@ -72,7 +72,7 @@ export class IndexFileEntry {
|
|||
return new GitHubProvider(
|
||||
parsed.download.hash,
|
||||
parsed.download["hash-format"],
|
||||
parsed.download.url,
|
||||
new Resource(parsed.download.url),
|
||||
parsed.update.github.branch,
|
||||
parsed.update.github.regex,
|
||||
parsed.update.github.slug,
|
||||
|
@ -82,7 +82,7 @@ export class IndexFileEntry {
|
|||
return new UrlProvider(
|
||||
parsed.download.hash,
|
||||
parsed.download["hash-format"],
|
||||
parsed.download.url,
|
||||
new Resource(parsed.download.url),
|
||||
);
|
||||
} else {
|
||||
throw new Error("Unknown provider in TOML.");
|
||||
|
|
|
@ -4,19 +4,15 @@ export class UrlProvider {
|
|||
constructor(
|
||||
public hash: string,
|
||||
public hashFormat: string,
|
||||
private url: string,
|
||||
public url: Resource,
|
||||
) {}
|
||||
|
||||
get downloadUrl(): Resource {
|
||||
return new Resource(this.url);
|
||||
}
|
||||
}
|
||||
|
||||
export class ModrinthProvider extends UrlProvider {
|
||||
constructor(
|
||||
hash: string,
|
||||
hashFormat: string,
|
||||
url: string,
|
||||
url: Resource,
|
||||
public modId: string,
|
||||
public versionId: string,
|
||||
) {
|
||||
|
@ -28,7 +24,7 @@ export class GitHubProvider extends UrlProvider {
|
|||
constructor(
|
||||
hash: string,
|
||||
hashFormat: string,
|
||||
url: string,
|
||||
url: Resource,
|
||||
public branch: string,
|
||||
public regex: string,
|
||||
public slug: string,
|
||||
|
@ -49,7 +45,9 @@ export class CurseForgeProvider extends UrlProvider {
|
|||
super(
|
||||
hash,
|
||||
hashFormat,
|
||||
`https://www.curseforge.com/api/v1/mods/${projectId}/files/${fileId}/download`,
|
||||
new Resource(
|
||||
`https://www.curseforge.com/api/v1/mods/${projectId}/files/${fileId}/download`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue