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

fix: two-package.json electron version query #7511

Merged
merged 7 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: utilizing frameworkInfo as primary manner of fetching electron v…
…ersion for installation. (fixes: #7494)
  • Loading branch information
mmaietta committed Mar 29, 2023
commit feb79ef6f42a1ce60e4eeaa3a694097e6f5fdd53
6 changes: 6 additions & 0 deletions .changeset/new-cats-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"app-builder-lib": patch
"electron-builder": patch
---

fix: utilizing frameworkInfo as primary manner of fetching electron version for installation. (fixes: #7494)
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export class Packager {
const frameworkInfo = { version: this.framework.version, useCustomDist: true }
const config = this.config
if (config.nodeGypRebuild === true) {
await nodeGypRebuild(Arch[arch])
await nodeGypRebuild(frameworkInfo, Arch[arch])
}

if (config.npmRebuild === false) {
Expand Down
17 changes: 8 additions & 9 deletions packages/app-builder-lib/src/util/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { homedir } from "os"
import * as path from "path"
import { Configuration } from "../configuration"
import { NodeModuleDirInfo } from "./packageDependencies"
import { getElectronVersion } from "../electron/electronVersion"
import * as electronRebuild from "@electron/rebuild"
import * as searchModule from "@electron/rebuild/lib/src/search-module"

Expand All @@ -26,7 +25,7 @@ export async function installOrRebuild(config: Configuration, appDir: string, op
}
await installDependencies(appDir, effectiveOptions)
} else {
await rebuild(appDir, config.buildDependenciesFromSource === true, options.arch)
await rebuild(appDir, config.buildDependenciesFromSource === true, options.frameworkInfo, options.arch)
}
}

Expand Down Expand Up @@ -119,8 +118,8 @@ function installDependencies(appDir: string, options: RebuildOptions): Promise<a
})
}

export async function nodeGypRebuild(arch: string) {
return rebuild(process.cwd(), false, arch)
export async function nodeGypRebuild(frameworkInfo: DesktopFrameworkInfo, arch: string) {
return rebuild(process.cwd(), false, frameworkInfo, arch)
}

function getPackageToolPath() {
Expand Down Expand Up @@ -149,15 +148,15 @@ export interface RebuildOptions {
}

/** @internal */
export async function rebuild(appDir: string, buildFromSource: boolean, arch = process.arch) {
log.info({ appDir, arch }, "executing @electron/rebuild")
export async function rebuild(appDir: string, buildFromSource: boolean, frameworkInfo: DesktopFrameworkInfo, arch = process.arch) {
log.info({ appDir, ...frameworkInfo }, "executing @electron/rebuild")
const rootPath = await searchModule.getProjectRootPath(appDir)
const options: electronRebuild.RebuildOptions = {
buildPath: appDir,
electronVersion: await getElectronVersion(appDir),
electronVersion: frameworkInfo.version,
arch,
force: true,
debug: log.isDebugEnabled,
projectRootPath: await searchModule.getProjectRootPath(appDir),
projectRootPath: rootPath,
}
if (buildFromSource) {
options.prebuildTagPrefix = "totally-not-a-real-prefix-to-force-rebuild"
Expand Down
4 changes: 3 additions & 1 deletion packages/electron-builder/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createSelfSignedCert } from "./create-self-signed-cert"
import { configureInstallAppDepsCommand, installAppDeps } from "./install-app-deps"
import { start } from "./start"
import { nodeGypRebuild } from "app-builder-lib/out/util/yarn"
import { getElectronVersion } from "app-builder-lib/out/electron/electronVersion"

// tslint:disable:no-unused-expression
void createYargs()
Expand Down Expand Up @@ -75,6 +76,7 @@ async function checkIsOutdated() {
}

async function rebuildAppNativeCode(args: any) {
const projectDir = process.cwd()
// this script must be used only for electron
return nodeGypRebuild(args.arch)
return nodeGypRebuild({ version: await getElectronVersion(projectDir), useCustomDist: true }, args.arch)
}