UNPKG

10.3 kBTypeScriptView Raw
1/// <reference types="node" />
2import { OutgoingHttpHeaders } from "http";
3export type PublishProvider = "github" | "s3" | "spaces" | "generic" | "custom" | "snapStore" | "keygen" | "bitbucket";
4export type AllPublishOptions = string | GithubOptions | S3Options | SpacesOptions | GenericServerOptions | CustomPublishOptions | KeygenOptions | SnapStoreOptions | BitbucketOptions;
5export interface PublishConfiguration {
6 /**
7 * The provider.
8 */
9 readonly provider: PublishProvider;
10 /**
11 * @private
12 * win-only
13 */
14 publisherName?: Array<string> | null;
15 /**
16 * @private
17 * win-only
18 */
19 readonly updaterCacheDirName?: string | null;
20 /**
21 * Whether to publish auto update info files.
22 *
23 * Auto update relies only on the first provider in the list (you can specify several publishers).
24 * Thus, probably, there`s no need to upload the metadata files for the other configured providers. But by default will be uploaded.
25 *
26 * @default true
27 */
28 readonly publishAutoUpdate?: boolean;
29 /**
30 * Any custom request headers
31 */
32 readonly requestHeaders?: OutgoingHttpHeaders;
33 /**
34 * Request timeout in milliseconds. (Default is 2 minutes; O is ignored)
35 *
36 * @default 120000
37 */
38 readonly timeout?: number | null;
39}
40export interface CustomPublishOptions extends PublishConfiguration {
41 /**
42 * The provider. Must be `custom`.
43 */
44 readonly provider: "custom";
45 /**
46 * The Provider to provide UpdateInfo regarding available updates. Required
47 * to use custom providers with electron-updater.
48 */
49 updateProvider?: new (options: CustomPublishOptions, updater: any, runtimeOptions: any) => any;
50 [index: string]: any;
51}
52/**
53 * [GitHub](https://help.github.com/articles/about-releases/) options.
54 *
55 * GitHub [personal access token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) is required. You can generate by going to [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new). The access token should have the repo scope/permission.
56 * Define `GH_TOKEN` environment variable.
57 */
58export interface GithubOptions extends PublishConfiguration {
59 /**
60 * The provider. Must be `github`.
61 */
62 readonly provider: "github";
63 /**
64 * The repository name. [Detected automatically](#github-repository-and-bintray-package).
65 */
66 readonly repo?: string | null;
67 /**
68 * The owner.
69 */
70 readonly owner?: string | null;
71 /**
72 * Whether to use `v`-prefixed tag name.
73 * @default true
74 */
75 readonly vPrefixedTagName?: boolean;
76 /**
77 * The host (including the port if need).
78 * @default github.com
79 */
80 readonly host?: string | null;
81 /**
82 * The protocol. GitHub Publisher supports only `https`.
83 * @default https
84 */
85 readonly protocol?: "https" | "http" | null;
86 /**
87 * The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for [setFeedURL](/auto-update#appupdatersetfeedurloptions).
88 */
89 readonly token?: string | null;
90 /**
91 * Whether to use private github auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitHub Update Repo](/auto-update#private-github-update-repo).
92 */
93 readonly private?: boolean | null;
94 /**
95 * The channel.
96 * @default latest
97 */
98 readonly channel?: string | null;
99 /**
100 * The type of release. By default `draft` release will be created.
101 *
102 * Also you can set release type using environment variable. If `EP_DRAFT`is set to `true` — `draft`, if `EP_PRE_RELEASE`is set to `true` — `prerelease`.
103 * @default draft
104 */
105 releaseType?: "draft" | "prerelease" | "release" | null;
106}
107/** @private */
108export declare function githubUrl(options: GithubOptions, defaultHost?: string): string;
109/**
110 * Generic (any HTTP(S) server) options.
111 * In all publish options [File Macros](/file-patterns#file-macros) are supported.
112 */
113export interface GenericServerOptions extends PublishConfiguration {
114 /**
115 * The provider. Must be `generic`.
116 */
117 readonly provider: "generic";
118 /**
119 * The base url. e.g. `https://bucket_name.s3.amazonaws.com`.
120 */
121 readonly url: string;
122 /**
123 * The channel.
124 * @default latest
125 */
126 readonly channel?: string | null;
127 /**
128 * Whether to use multiple range requests for differential update. Defaults to `true` if `url` doesn't contain `s3.amazonaws.com`.
129 */
130 readonly useMultipleRangeRequest?: boolean;
131}
132/**
133 * Keygen options.
134 * https://keygen.sh/
135 * Define `KEYGEN_TOKEN` environment variable.
136 */
137export interface KeygenOptions extends PublishConfiguration {
138 /**
139 * The provider. Must be `keygen`.
140 */
141 readonly provider: "keygen";
142 /**
143 * Keygen account's UUID
144 */
145 readonly account: string;
146 /**
147 * Keygen product's UUID
148 */
149 readonly product: string;
150 /**
151 * The channel.
152 * @default stable
153 */
154 readonly channel?: "stable" | "rc" | "beta" | "alpha" | "dev" | null;
155 /**
156 * The target Platform. Is set programmatically explicitly during publishing.
157 */
158 readonly platform?: string | null;
159}
160/**
161 * Bitbucket options.
162 * https://bitbucket.org/
163 * Define `BITBUCKET_TOKEN` environment variable.
164 *
165 * For converting an app password to a usable token, you can utilize this
166```typescript
167convertAppPassword(owner: string, appPassword: string) {
168 const base64encodedData = Buffer.from(`${owner}:${appPassword.trim()}`).toString("base64")
169 return `Basic ${base64encodedData}`
170}
171```
172 */
173export interface BitbucketOptions extends PublishConfiguration {
174 /**
175 * The provider. Must be `bitbucket`.
176 */
177 readonly provider: "bitbucket";
178 /**
179 * Repository owner
180 */
181 readonly owner: string;
182 /**
183 * The [app password](https://bitbucket.org/account/settings/app-passwords) to support auto-update from private bitbucket repositories.
184 */
185 readonly token?: string | null;
186 /**
187 * The user name to support auto-update from private bitbucket repositories.
188 */
189 readonly username?: string | null;
190 /**
191 * Repository slug/name
192 */
193 readonly slug: string;
194 /**
195 * The channel.
196 * @default latest
197 */
198 readonly channel?: string | null;
199}
200/**
201 * [Snap Store](https://snapcraft.io/) options. To publish directly to Snapcraft, see <a href="https://snapcraft.io/docs/snapcraft-authentication">Snapcraft authentication options</a> for local or CI/CD authentication options.
202 */
203export interface SnapStoreOptions extends PublishConfiguration {
204 /**
205 * The provider. Must be `snapStore`.
206 */
207 readonly provider: "snapStore";
208 /**
209 * snapcraft repo name
210 */
211 readonly repo?: string;
212 /**
213 * The list of channels the snap would be released.
214 * @default ["edge"]
215 */
216 readonly channels?: string | Array<string> | null;
217}
218export interface BaseS3Options extends PublishConfiguration {
219 /**
220 * The update channel.
221 * @default latest
222 */
223 channel?: string | null;
224 /**
225 * The directory path.
226 * @default /
227 */
228 readonly path?: string | null;
229 /**
230 * The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).
231 *
232 * @default public-read
233 */
234 readonly acl?: "private" | "public-read" | null;
235}
236/**
237 * [Amazon S3](https://aws.amazon.com/s3/) options.
238 * AWS credentials are required, please see [getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html).
239 * Define `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` [environment variables](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html).
240 * Or in the [~/.aws/credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html).
241 *
242 * Example configuration:
243 *
244```json
245{
246 "build":
247 "publish": {
248 "provider": "s3",
249 "bucket": "bucket-name"
250 }
251 }
252}
253```
254 */
255export interface S3Options extends BaseS3Options {
256 /**
257 * The provider. Must be `s3`.
258 */
259 readonly provider: "s3";
260 /**
261 * The bucket name.
262 */
263 readonly bucket: string;
264 /**
265 * The region. Is determined and set automatically when publishing.
266 */
267 region?: string | null;
268 /**
269 * The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).
270 *
271 * Please see [required permissions for the S3 provider](https://github.com/electron-userland/electron-builder/issues/1618#issuecomment-314679128).
272 *
273 * @default public-read
274 */
275 readonly acl?: "private" | "public-read" | null;
276 /**
277 * The type of storage to use for the object.
278 * @default STANDARD
279 */
280 readonly storageClass?: "STANDARD" | "REDUCED_REDUNDANCY" | "STANDARD_IA" | null;
281 /**
282 * Server-side encryption algorithm to use for the object.
283 */
284 readonly encryption?: "AES256" | "aws:kms" | null;
285 /**
286 * The endpoint URI to send requests to. The default endpoint is built from the configured region.
287 * The endpoint should be a string like `https://{service}.{region}.amazonaws.com`.
288 */
289 readonly endpoint?: string | null;
290 /**
291 * If set to true, this will enable the s3 accelerated endpoint
292 * These endpoints have a particular format of:
293 * ${bucketname}.s3-accelerate.amazonaws.com
294 */
295 readonly accelerate?: boolean;
296}
297/**
298 * [DigitalOcean Spaces](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-spaces) options.
299 * Access key is required, define `DO_KEY_ID` and `DO_SECRET_KEY` environment variables.
300 */
301export interface SpacesOptions extends BaseS3Options {
302 /**
303 * The provider. Must be `spaces`.
304 */
305 readonly provider: "spaces";
306 /**
307 * The space name.
308 */
309 readonly name: string;
310 /**
311 * The region (e.g. `nyc3`).
312 */
313 readonly region: string;
314}
315export declare function getS3LikeProviderBaseUrl(configuration: PublishConfiguration): string;