Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use electron-winstaller instead of self module #8344

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
87eb7bf
use electron-winstaller
Jul 17, 2024
3a0d1f5
fix ut
Jul 17, 2024
d209266
add nuspecTemplate
Jul 17, 2024
182eea7
custom template.nuspectemplat
Jul 17, 2024
b65450d
add patch for electron-winstaller: change exe to producname
Jul 17, 2024
272b4c8
update wine docker config
Jul 17, 2024
8910083
update snap
Jul 17, 2024
62c9bb5
update snap
Jul 17, 2024
e2d54ff
update wine docker
Jul 17, 2024
74316e3
update dockerfile
Jul 17, 2024
9f1a99a
update dockerimage
Jul 17, 2024
fd017b7
add appId and exe options
Jul 18, 2024
4202527
delete patch
Jul 18, 2024
5170902
change encode
Jul 18, 2024
a4a2f50
update 7zip
Jul 20, 2024
5ffdffd
use electron-squirrel-winstaller@1.0.2: update 7zip and nuget
Jul 20, 2024
8e5b9d2
update electron-squirrel-winstaller@1.0.3
Jul 20, 2024
6376b95
delete decompress-zip
Jul 20, 2024
006d3cb
remove directory
Jul 20, 2024
8c960cb
delete directory
Jul 20, 2024
b0e6941
update docker file
Jul 20, 2024
4bc85f2
update wine docker config
Jul 20, 2024
463c687
add vender path
Jul 21, 2024
4e5502d
change to getBin
Jul 21, 2024
d9459d9
add sign option
Jul 21, 2024
61c79cb
add shouldSign function
Jul 21, 2024
4d9cb0a
change shouldSign to async/await
Jul 21, 2024
232a90d
add template.nuspectemplate into files
beyondkmp Jul 22, 2024
b26c7a8
add vendorDirectory option
Jul 25, 2024
a5d6bee
Merge branch 'master' into win-installer
Jul 25, 2024
d36fefd
update 7zip arch
Jul 25, 2024
04c50fd
fix 7zip arch
Jul 26, 2024
2fb5700
fix name
Jul 26, 2024
023559f
Merge branch 'master' into win-installer
beyondkmp Nov 1, 2024
253c3aa
delete docker config
beyondkmp Nov 1, 2024
b7ff107
Merge branch 'master' into win-installer
beyondkmp Nov 1, 2024
10931d5
Merge branch 'master' into win-installer
beyondkmp Nov 2, 2024
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
4 changes: 4 additions & 0 deletions docker/wine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
ARG IMAGE_VERSION=latest
FROM electronuserland/builder:$IMAGE_VERSION

# Set up Wine environment for 64-bit
ENV WINEARCH=win64
ENV WINEPREFIX=/root/.wine64

RUN dpkg --add-architecture i386 && \
curl -Lo /usr/share/keyrings/winehq.asc https://dl.winehq.org/wine-builds/winehq.key && \
echo 'deb [signed-by=/usr/share/keyrings/winehq.asc] https://dl.winehq.org/wine-builds/ubuntu/ focal main' > /etc/apt/sources.list.d/winehq.list && \
Expand Down
7 changes: 7 additions & 0 deletions packages/app-builder-lib/src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ export class WinPackager extends PlatformPackager<WindowsConfiguration> {
return chooseNotNull(chooseNotNull(this.platformSpecificBuildOptions.certificatePassword, process.env.WIN_CSC_KEY_PASSWORD), super.doGetCscPassword())
}

async shouldSign(): Promise<boolean> {
if (await this.cscInfo.value) {
return true
}
return false
}

createTargets(targets: Array<string>, mapper: (name: string, factory: (outDir: string) => Target) => void): void {
let copyElevateHelper: CopyElevateHelper | null
const getCopyElevateHelper = () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder-squirrel-windows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
],
mmaietta marked this conversation as resolved.
Show resolved Hide resolved
"dependencies": {
"app-builder-lib": "workspace:*",
"archiver": "^5.3.1",
"builder-util": "workspace:*",
"fs-extra": "^10.1.0"
"electron-squirrel-winstaller":"1.0.4"
},
"devDependencies": {
"@types/archiver": "5.3.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { sanitizeFileName } from "app-builder-lib/out/util/filename"
import { InvalidConfigurationError, log, isEmptyOrSpaces } from "builder-util"
import { getBinFromUrl } from "app-builder-lib/out/binDownload"
import { Arch, getArchSuffix, SquirrelWindowsOptions, Target } from "app-builder-lib"
import { getBin } from "app-builder-lib/out/binDownload"
import { WinPackager } from "app-builder-lib/out/winPackager"
import * as path from "path"
import { convertVersion, SquirrelBuilder, SquirrelOptions } from "./squirrelPack"
import { Options as SquirrelOptions, createWindowsInstaller, convertVersion } from "electron-squirrel-winstaller"

export default class SquirrelWindowsTarget extends Target {
//tslint:disable-next-line:no-object-literal-type-assertion
Expand All @@ -22,10 +22,7 @@ export default class SquirrelWindowsTarget extends Target {
const version = packager.appInfo.version
const sanitizedName = sanitizeFileName(this.appName)

// tslint:disable-next-line:no-invalid-template-strings
const setupFile = packager.expandArtifactNamePattern(this.options, "exe", arch, "${productName} Setup ${version}.${ext}")
const packageFile = `${sanitizedName}-${convertVersion(version)}-full.nupkg`

const installerOutDir = path.join(this.outDir, `squirrel-windows${getArchSuffix(arch)}`)
const artifactPath = path.join(installerOutDir, setupFile)

Expand All @@ -40,8 +37,11 @@ export default class SquirrelWindowsTarget extends Target {
}

const distOptions = await this.computeEffectiveDistOptions()
const squirrelBuilder = new SquirrelBuilder(distOptions, installerOutDir, packager)
await squirrelBuilder.buildInstaller({ setupFile, packageFile }, appOutDir, this.outDir, arch)
await createWindowsInstaller({
...distOptions,
appDirectory: appOutDir,
outputDirectory: installerOutDir,
})

await packager.info.callArtifactBuildCompleted({
file: artifactPath,
Expand Down Expand Up @@ -100,24 +100,37 @@ export default class SquirrelWindowsTarget extends Target {
const appInfo = packager.appInfo
const projectUrl = await appInfo.computePackageUrl()
const appName = this.appName
const vendorDirectory = await getBin(
"Squirrel.Windows-2.0.1",
"https://github.com/beyondkmp/electron-builder-binaries/releases/download/Squirrel.Windows-2.0.1/Squirrel.Windows-2.0.1.7z",
"IGIosfkJ25mhpGS6LREBbaSq4uysb3lwXUzt0psM9UBeaVvpOfDz0ZUqat6WAaji35n0oXJqw63WXT24/7ksLA=="
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

)
const options: SquirrelOptions = {
name: appName,
productName: this.options.name || appInfo.productName,
appId: this.options.useAppIdAsId ? appInfo.id : appName,
version: appInfo.version,
description: appInfo.description,
// better to explicitly set to empty string, to avoid any nugget errors
exe: `${this.packager.platformSpecificBuildOptions.executableName || this.options.name || appInfo.productName}.exe`,
authors: appInfo.companyName || "",
iconUrl,
extraMetadataSpecs: projectUrl == null ? null : `\n <projectUrl>${projectUrl}</projectUrl>`,
copyright: appInfo.copyright,
packageCompressionLevel: parseInt((process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || packager.compression === "store" ? 0 : 9) as any, 10),
vendorPath: await getBinFromUrl("Squirrel.Windows", "1.9.0", "zJHk4CMATM7jHJ2ojRH1n3LkOnaIezDk5FAzJmlSEQSiEdRuB4GGLCegLDtsRCakfHIVfKh3ysJHLjynPkXwhQ=="),
mmaietta marked this conversation as resolved.
Show resolved Hide resolved
vendorDirectory,
nuspecTemplate: path.join(__dirname, "..", "template.nuspectemplate"),
...(this.options as any),
}

if (await packager.shouldSign()) {
options.windowsSign = {
hookFunction: async (file: string) => {
await packager.sign(file)
},
}
}

if (isEmptyOrSpaces(options.description)) {
options.description = options.productName
options.description = this.options.name || appInfo.productName
}

if (options.remoteToken == null) {
Expand Down
Loading
Loading