Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eager-mugs-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

feat: add writeUpdateInfo option for zip builds
71 changes: 71 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -6982,6 +6982,66 @@
}
},
"type": "object"
},
"ZipOptions": {
"additionalProperties": false,
"properties": {
"artifactName": {
"description": "The [artifact file name template](./configuration.md#artifact-file-name-template).",
"type": [
"null",
"string"
]
},
"publish": {
"anyOf": [
{
"$ref": "#/definitions/GithubOptions"
},
{
"$ref": "#/definitions/GitlabOptions"
},
{
"$ref": "#/definitions/S3Options"
},
{
"$ref": "#/definitions/SpacesOptions"
},
{
"$ref": "#/definitions/GenericServerOptions"
},
{
"$ref": "#/definitions/CustomPublishOptions"
},
{
"$ref": "#/definitions/KeygenOptions"
},
{
"$ref": "#/definitions/SnapStoreOptions"
},
{
"$ref": "#/definitions/BitbucketOptions"
},
{
"items": {
"$ref": "#/definitions/AllPublishOptions"
},
"type": "array"
},
{
"type": [
"null",
"string"
]
}
]
},
"writeUpdateInfo": {
"default": true,
"type": "boolean"
}
},
"type": "object"
}
},
"properties": {
Expand Down Expand Up @@ -7909,6 +7969,17 @@
],
"description": "Options related to how build Windows targets."
},
"zip": {
"anyOf": [
{
"$ref": "#/definitions/ZipOptions"
},
{
"type": "null"
}
],
"description": "macOS zip options."
},
"$schema": {
"description": "JSON Schema for this document.",
"type": [
Expand Down
6 changes: 5 additions & 1 deletion packages/app-builder-lib/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ElectronBrandingOptions, ElectronDownloadOptions } from "./electron/Ele
import { PrepareApplicationStageDirectoryOptions } from "./Framework"
import { AppXOptions } from "./options/AppXOptions"
import { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from "./options/linuxOptions"
import { DmgOptions, MacConfiguration, MasConfiguration } from "./options/macOptions"
import { DmgOptions, MacConfiguration, MasConfiguration, ZipOptions } from "./options/macOptions"
import { MsiOptions } from "./options/MsiOptions"
import { MsiWrappedOptions } from "./options/MsiWrappedOptions"
import { PkgOptions } from "./options/pkgOptions"
Expand Down Expand Up @@ -66,6 +66,10 @@ export interface CommonConfiguration {
* macOS PKG options.
*/
readonly pkg?: PkgOptions | null
/**
* macOS zip options.
*/
readonly zip?: ZipOptions | null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm definitely not a fan of this tbh for a couple reasons:

  • zip target is more than just macOS specific
  • ArchiveTarget supports a plethora of archive formats. Creating a zip target opens the door for other archive types having their own options too. That's a very slippery slope on an already-complex Configuration object

We need a different approach to this that scales and keeps complexity low for the end-user.

Before making further edits to this PR, let's please discuss the approach first so that we can limit the back n forth and time spent on your side 🙂


/**
* Options related to how build Windows targets.
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class MacPackager extends PlatformPackager<MacConfiguration> {

case "zip":
// https://github.com/electron-userland/electron-builder/issues/2313
mapper(name, outDir => new ArchiveTarget(name, outDir, this, true))
mapper(name, outDir => new ArchiveTarget(name, outDir, this))
break

case "pkg":
Expand Down
8 changes: 8 additions & 0 deletions packages/app-builder-lib/src/options/macOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,11 @@ export interface MasConfiguration extends MacConfiguration {
*/
readonly binaries?: Array<string> | null
}

export interface ZipOptions extends TargetSpecificOptions {
/**
* @private
* @default true
*/
writeUpdateInfo?: boolean
}
18 changes: 14 additions & 4 deletions packages/app-builder-lib/src/targets/ArchiveTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@ import { Arch, defaultArchFromString } from "builder-util"
import * as path from "path"
import { Platform, Target, TargetSpecificOptions } from "../core"
import { copyFiles, getFileMatchers } from "../fileMatcher"
import { ZipOptions } from "../options/macOptions"
import { PlatformPackager } from "../platformPackager"
import { archive, tar } from "./archive"
import { appendBlockmap, createBlockmap } from "./differentialUpdateInfoBuilder"

export class ArchiveTarget extends Target {
readonly options: TargetSpecificOptions = (this.packager.config as any)[this.name]
readonly options: TargetSpecificOptions = (this.packager.config as any)[this.name] ?? {}

constructor(
name: string,
readonly outDir: string,
private readonly packager: PlatformPackager<any>,
private readonly isWriteUpdateInfo = false
private readonly isWriteUpdateInfo: boolean | null = null
) {
super(name)
}

private shouldWriteUpdateInfo(): boolean {
// Constructor parameter takes precedence (for backward compatibility)
if (this.isWriteUpdateInfo !== null) {
return this.isWriteUpdateInfo
}
// Otherwise read from options, default to true
return (this.options as ZipOptions).writeUpdateInfo !== false
}

async build(appOutDir: string, arch: Arch): Promise<any> {
const packager = this.packager
const isMac = packager.platform === Platform.MAC
Expand Down Expand Up @@ -70,7 +80,7 @@ export class ArchiveTarget extends Target {
}
await archive(format, artifactPath, dirToArchive, archiveOptions)

if (this.isWriteUpdateInfo && format === "zip") {
if (this.shouldWriteUpdateInfo() && format === "zip") {
if (isMac) {
updateInfo = await createBlockmap(artifactPath, this, packager, artifactName)
} else {
Expand All @@ -94,7 +104,7 @@ export class ArchiveTarget extends Target {
target: this,
arch,
packager,
isWriteUpdateInfo: this.isWriteUpdateInfo,
isWriteUpdateInfo: this.shouldWriteUpdateInfo(),
})
})
return Promise.resolve()
Expand Down
Loading