-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor Publishers out of app-builder-lib into electron-publi…
…sh and add to docs site (#8596)
- Loading branch information
Showing
33 changed files
with
198 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"app-builder-lib": patch | ||
"builder-util": patch | ||
"dmg-builder": patch | ||
"electron-builder": patch | ||
"electron-builder-squirrel-windows": patch | ||
"electron-publish": patch | ||
--- | ||
|
||
chore: refactor files for publishing to electron-publish |
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
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
2 changes: 1 addition & 1 deletion
2
packages/app-builder-lib/src/options/CommonWindowsInstallerConfiguration.ts
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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
packages/electron-builder-squirrel-windows/src/SquirrelWindowsTarget.ts
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
3 changes: 2 additions & 1 deletion
3
...der-lib/src/publish/BitbucketPublisher.ts → ...lectron-publish/src/bitbucketPublisher.ts
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,69 @@ | ||
import { Arch } from "builder-util" | ||
import { stat } from "fs-extra" | ||
import { ClientRequest } from "http" | ||
import { basename } from "path/posix" | ||
import { Publisher } from "./publisher" | ||
import { PublishContext, UploadTask } from "." | ||
|
||
export abstract class HttpPublisher extends Publisher { | ||
protected constructor( | ||
protected readonly context: PublishContext, | ||
private readonly useSafeArtifactName = false | ||
) { | ||
super(context) | ||
} | ||
|
||
async upload(task: UploadTask): Promise<any> { | ||
const fileName = (this.useSafeArtifactName ? task.safeArtifactName : null) || basename(task.file) | ||
|
||
if (task.fileContent != null) { | ||
await this.doUpload( | ||
fileName, | ||
task.arch || Arch.x64, | ||
task.fileContent.length, | ||
(request, reject) => { | ||
if (task.timeout) { | ||
request.setTimeout(task.timeout, () => { | ||
request.destroy() | ||
reject(new Error("Request timed out")) | ||
}) | ||
} | ||
return request.end(task.fileContent) | ||
}, | ||
task.file | ||
) | ||
return | ||
} | ||
|
||
const fileStat = await stat(task.file) | ||
|
||
const progressBar = this.createProgressBar(fileName, fileStat.size) | ||
return this.doUpload( | ||
fileName, | ||
task.arch || Arch.x64, | ||
fileStat.size, | ||
(request, reject) => { | ||
if (progressBar != null) { | ||
// reset (because can be called several times (several attempts) | ||
progressBar.update(0) | ||
} | ||
if (task.timeout) { | ||
request.setTimeout(task.timeout, () => { | ||
request.destroy() | ||
reject(new Error("Request timed out")) | ||
}) | ||
} | ||
return this.createReadStreamAndProgressBar(task.file, fileStat, progressBar, reject).pipe(request) | ||
}, | ||
task.file | ||
) | ||
} | ||
|
||
protected abstract doUpload( | ||
fileName: string, | ||
arch: Arch, | ||
dataLength: number, | ||
requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, | ||
file: string | ||
): Promise<any> | ||
} |
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,35 @@ | ||
import { CancellationToken } from "builder-util-runtime" | ||
import { MultiProgress } from "./multiProgress" | ||
import { Arch } from "builder-util" | ||
|
||
export { SpacesPublisher } from "./s3/spacesPublisher" | ||
export { KeygenPublisher } from "./keygenPublisher" | ||
export { SnapStorePublisher } from "./snapStorePublisher" | ||
export { S3Publisher } from "./s3/s3Publisher" | ||
export { GitHubPublisher } from "./gitHubPublisher" | ||
export { BitbucketPublisher } from "./bitbucketPublisher" | ||
|
||
export type PublishPolicy = "onTag" | "onTagOrDraft" | "always" | "never" | ||
|
||
export { ProgressCallback } from "./progress" | ||
|
||
export interface PublishOptions { | ||
publish?: PublishPolicy | null | ||
} | ||
|
||
export { Publisher, getCiTag } from "./publisher" | ||
export { HttpPublisher } from "./httpPublisher" | ||
|
||
export interface PublishContext { | ||
readonly cancellationToken: CancellationToken | ||
readonly progress: MultiProgress | null | ||
} | ||
|
||
export interface UploadTask { | ||
file: string | ||
fileContent?: Buffer | null | ||
|
||
arch: Arch | null | ||
safeArtifactName?: string | null | ||
timeout?: number | null | ||
} |
5 changes: 3 additions & 2 deletions
5
...uilder-lib/src/publish/KeygenPublisher.ts → ...s/electron-publish/src/keygenPublisher.ts
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
Oops, something went wrong.