forked from electron-userland/electron-builder
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(electron-updater): Allow to more friendly set autoUpdater.channel
Close electron-userland#2172
- Loading branch information
Showing
6 changed files
with
94 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { AllPublishOptions, BaseS3Options, BintrayOptions, GenericServerOptions, getS3LikeProviderBaseUrl, GithubOptions, PublishConfiguration } from "builder-util-runtime" | ||
import { AppUpdater } from "./AppUpdater" | ||
import { BintrayProvider } from "./BintrayProvider" | ||
import { GenericProvider } from "./GenericProvider" | ||
import { GitHubProvider } from "./GitHubProvider" | ||
import { PrivateGitHubProvider } from "./PrivateGitHubProvider" | ||
|
||
export function createClient(data: PublishConfiguration | AllPublishOptions, updater: AppUpdater) { | ||
if (typeof data === "string") { | ||
throw new Error("Please pass PublishConfiguration object") | ||
} | ||
|
||
const httpExecutor = updater.httpExecutor | ||
const provider = data.provider | ||
switch (provider) { | ||
case "github": | ||
const githubOptions = data as GithubOptions | ||
const token = (githubOptions.private ? process.env.GH_TOKEN : null) || githubOptions.token | ||
if (token == null) { | ||
return new GitHubProvider(githubOptions, updater, httpExecutor) | ||
} | ||
else { | ||
return new PrivateGitHubProvider(githubOptions, token, httpExecutor) | ||
} | ||
|
||
case "s3": | ||
case "spaces": | ||
return new GenericProvider({ | ||
provider: "generic", | ||
url: getS3LikeProviderBaseUrl(data), | ||
channel: (data as BaseS3Options).channel || "" | ||
}, updater) | ||
|
||
case "generic": | ||
return new GenericProvider(data as GenericServerOptions, updater) | ||
|
||
case "bintray": | ||
return new BintrayProvider(data as BintrayOptions, httpExecutor) | ||
|
||
default: | ||
throw new Error(`Unsupported provider: ${provider}`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters