Made factory for the different publishers

This commit is contained in:
Kir_Antipov 2021-09-24 17:36:38 +03:00
parent 22df1b7930
commit f73c20d76f

View file

@ -0,0 +1,24 @@
import Publisher from "./publisher";
import PublisherTarget from "./publisher-target";
import GitHubPublisher from "./github-publisher";
import ModrinthPublisher from "./modrinth-publisher";
import CurseForgePublisher from "./curseforge-publisher";
import Logger from "../utils/logger";
export default class PublisherFactory {
public create(target: PublisherTarget, options: Record<string, unknown>, logger?: Logger): Publisher<unknown> {
switch(target) {
case PublisherTarget.GitHub:
return new GitHubPublisher(<any>options, logger);
case PublisherTarget.Modrinth:
return new ModrinthPublisher(<any>options, logger);
case PublisherTarget.CurseForge:
return new CurseForgePublisher(<any>options, logger);
default:
throw new Error(`Unknown target "${PublisherTarget.toString(target)}"`);
}
}
}