Skip to content

Commit

Permalink
feat(keygen): Add host property to support self-hosted Keygen insta…
Browse files Browse the repository at this point in the history
…nces (#8711)
  • Loading branch information
hrueger authored Dec 6, 2024
1 parent 4c394d5 commit 6f0fb8e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .changeset/kind-poems-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"app-builder-lib": minor
"builder-util-runtime": minor
"electron-publish": minor
"electron-updater": minor
---

Add `host` property to support self-hosted Keygen instances
5 changes: 5 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,11 @@
"default": "stable",
"description": "The channel."
},
"host": {
"default": "api.keygen.sh",
"description": "Keygen host for self-hosted instances",
"type": "string"
},
"platform": {
"description": "The target Platform. Is set programmatically explicitly during publishing.",
"type": [
Expand Down
6 changes: 6 additions & 0 deletions packages/builder-util-runtime/src/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export interface KeygenOptions extends PublishConfiguration {
*/
readonly provider: "keygen"

/**
* Keygen host for self-hosted instances
* @default "api.keygen.sh"
*/
readonly host?: string

/**
* Keygen account's UUID
*/
Expand Down
6 changes: 5 additions & 1 deletion packages/electron-publish/src/keygenPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ export interface KeygenArtifact {

export class KeygenPublisher extends HttpPublisher {
readonly providerName = "keygen"
readonly hostname = "api.keygen.sh"
readonly defaultHostname = "api.keygen.sh"

private readonly info: KeygenOptions
private readonly auth: string
private readonly version: string
private readonly basePath: string

get hostname() {
return this.info.host || this.defaultHostname
}

constructor(context: PublishContext, info: KeygenOptions, version: string) {
super(context)

Expand Down
4 changes: 3 additions & 1 deletion packages/electron-updater/src/providers/KeygenProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getChannelFilename, newBaseUrl, newUrlFromBase } from "../util"
import { parseUpdateInfo, Provider, ProviderRuntimeOptions, resolveFiles } from "./Provider"

export class KeygenProvider extends Provider<UpdateInfo> {
private readonly defaultHostname = "api.keygen.sh"
private readonly baseUrl: URL

constructor(
Expand All @@ -16,7 +17,8 @@ export class KeygenProvider extends Provider<UpdateInfo> {
...runtimeOptions,
isUseMultipleRangeRequest: false,
})
this.baseUrl = newBaseUrl(`https://api.keygen.sh/v1/accounts/${this.configuration.account}/artifacts?product=${this.configuration.product}`)
const host = this.configuration.host || this.defaultHostname
this.baseUrl = newBaseUrl(`https://${host}/v1/accounts/${this.configuration.account}/artifacts?product=${this.configuration.product}`)
}

private get channel(): string {
Expand Down

0 comments on commit 6f0fb8e

Please sign in to comment.