Skip to content

Commit 72b2996

Browse files
authored
Merge branch 'master' into master
2 parents 6dcca6e + c83f765 commit 72b2996

File tree

37 files changed

+331
-180
lines changed

37 files changed

+331
-180
lines changed

.changeset/purple-tigers-guess.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/actions/pretest/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
- name: Setup python
2424
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
2525
with:
26-
python-version: '3.11'
26+
python-version: '3.13'
2727

2828
- name: Setup node
2929
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
docker save -o ${{ runner.temp }}/electron-builder-all-${{ env.NODE_TAG }}.tar electronuserland/builder
3535
3636
- name: Bundle all images
37-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
37+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
3838
with:
3939
name: electron-builder-all-${{ env.NODE_TAG }}
4040
path: ${{ runner.temp }}/electron-builder-all-${{ env.NODE_TAG }}.tar

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# [](https://github.com/electron-userland/electron-builder/compare/v26.0.14...v) (2025-05-04)
2+
3+
4+
### Bug Fixes
5+
6+
* **deps:** update dependency @electron/osx-sign to v1.3.3 ([#9083](https://github.com/electron-userland/electron-builder/issues/9083)) ([0ce7b90](https://github.com/electron-userland/electron-builder/commit/0ce7b90e5eec0cf3049e2b3957b4d076fbdd615d))
7+
* **deps:** update dependency @electron/universal to v2.0.3 ([#9082](https://github.com/electron-userland/electron-builder/issues/9082)) ([6f3aec8](https://github.com/electron-userland/electron-builder/commit/6f3aec8106be0d365e59923410c1eb55cd0328d1))
8+
* **electron-updater:** allow forceDevUpdateConfig also on Linux ([#9024](https://github.com/electron-userland/electron-builder/issues/9024)) ([e641751](https://github.com/electron-userland/electron-builder/commit/e641751ce36cdf099d62a897c591b2763705dbff))
9+
* update package manager detection and improve type handling ([#9067](https://github.com/electron-userland/electron-builder/issues/9067)) ([312938d](https://github.com/electron-userland/electron-builder/commit/312938d8519a29992e75e1f544c41ca50ae591e3))
10+
* update regex for multipart content-type parsing in multipleRange ([#9064](https://github.com/electron-userland/electron-builder/issues/9064)) ([444b791](https://github.com/electron-userland/electron-builder/commit/444b791f9d2812f2a0f60481f7b25297585d9c5a))
11+
12+
13+
### Features
14+
15+
* support upgrading from ARM to ARM, rather than upgrading to x64 in window and linux ([#9059](https://github.com/electron-userland/electron-builder/issues/9059)) ([cb77508](https://github.com/electron-userland/electron-builder/commit/cb775088427d25e9ce0489067445716d35e09997))
16+
17+
18+
119
# [](https://github.com/electron-userland/electron-builder/compare/v26.0.13...v) (2025-04-27)
220

321

packages/app-builder-lib/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# app-builder-lib
22

3+
## 26.0.15
4+
5+
### Patch Changes
6+
7+
- [#9067](https://github.com/electron-userland/electron-builder/pull/9067) [`312938d8`](https://github.com/electron-userland/electron-builder/commit/312938d8519a29992e75e1f544c41ca50ae591e3) Thanks [@beyondkmp](https://github.com/beyondkmp)! - refactor: update package manager detection and improve type handling
8+
9+
- [#9082](https://github.com/electron-userland/electron-builder/pull/9082) [`6f3aec81`](https://github.com/electron-userland/electron-builder/commit/6f3aec8106be0d365e59923410c1eb55cd0328d1) Thanks [@mmaietta](https://github.com/mmaietta)! - fix(deps): update dependency @electron/universal to v2.0.2
10+
11+
- [#9038](https://github.com/electron-userland/electron-builder/pull/9038) [`d97e7eb2`](https://github.com/electron-userland/electron-builder/commit/d97e7eb20d6cdf53f7fd75d51818de3cf65e011a) Thanks [@beyondkmp](https://github.com/beyondkmp)! - refactor: improve resource directory handling for macOS
12+
13+
- [#9083](https://github.com/electron-userland/electron-builder/pull/9083) [`0ce7b90e`](https://github.com/electron-userland/electron-builder/commit/0ce7b90e5eec0cf3049e2b3957b4d076fbdd615d) Thanks [@mmaietta](https://github.com/mmaietta)! - fix(deps): update dependency @electron/osx-sign to v1.3.3
14+
15+
- Updated dependencies []:
16+
17+
18+
319
## 26.0.14
420

521
### Patch Changes

packages/app-builder-lib/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "app-builder-lib",
33
"description": "electron-builder lib",
4-
"version": "26.0.14",
4+
"version": "26.0.15",
55
"main": "out/index.js",
66
"files": [
77
"out",
@@ -50,9 +50,9 @@
5050
"@electron/asar": "3.4.1",
5151
"@electron/fuses": "^1.8.0",
5252
"@electron/notarize": "2.5.0",
53-
"@electron/osx-sign": "1.3.1",
53+
"@electron/osx-sign": "1.3.3",
5454
"@electron/rebuild": "3.7.2",
55-
"@electron/universal": "2.0.1",
55+
"@electron/universal": "2.0.3",
5656
"@malept/flatpak-bundler": "^0.4.0",
5757
"@types/fs-extra": "9.0.13",
5858
"async-exit-hook": "^2.0.1",

packages/app-builder-lib/src/electron/ElectronFramework.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,29 @@ async function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOption
9797
return
9898
}
9999

100-
const { dir, langFileExt } = getLocalesConfig(options)
100+
const { dirs, langFileExt } = getLocalesConfig(options)
101101
// noinspection SpellCheckingInspection
102-
await asyncPool(MAX_FILE_REQUESTS, await readdir(dir), async file => {
103-
if (!file.endsWith(langFileExt)) {
104-
return
105-
}
102+
const deletedFiles = async (dir: string) => {
103+
await asyncPool(MAX_FILE_REQUESTS, await readdir(dir), async file => {
104+
if (path.extname(file) !== langFileExt) {
105+
return
106+
}
106107

107-
const language = file.substring(0, file.length - langFileExt.length)
108-
if (!wantedLanguages.includes(language)) {
109-
return fs.rm(path.join(dir, file), { recursive: true, force: true })
110-
}
111-
return
112-
})
108+
const language = path.basename(file, langFileExt)
109+
if (!wantedLanguages.includes(language)) {
110+
return fs.rm(path.join(dir, file), { recursive: true, force: true })
111+
}
112+
return
113+
})
114+
}
115+
await Promise.all(dirs.map(deletedFiles))
113116

114117
function getLocalesConfig(options: BeforeCopyExtraFilesOptions) {
115118
const { appOutDir, packager } = options
116119
if (packager.platform === Platform.MAC) {
117-
return { dir: packager.getResourcesDir(appOutDir), langFileExt: ".lproj" }
118-
} else {
119-
return { dir: path.join(packager.getResourcesDir(appOutDir), "..", "locales"), langFileExt: ".pak" }
120+
return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: ".lproj" }
120121
}
122+
return { dirs: [path.join(packager.getResourcesDir(appOutDir), "..", "locales")], langFileExt: ".pak" }
121123
}
122124
}
123125

packages/app-builder-lib/src/node-module-collector/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NpmNodeModulesCollector } from "./npmNodeModulesCollector"
22
import { PnpmNodeModulesCollector } from "./pnpmNodeModulesCollector"
33
import { YarnNodeModulesCollector } from "./yarnNodeModulesCollector"
4-
import { detect, PM, getPackageManagerVersion } from "./packageManager"
4+
import { detectPackageManager, PM, getPackageManagerCommand } from "./packageManager"
55
import { NodeModuleInfo } from "./types"
66
import { exec } from "builder-util"
77

@@ -13,16 +13,16 @@ async function isPnpmProjectHoisted(rootDir: string) {
1313
}
1414

1515
export async function getCollectorByPackageManager(rootDir: string) {
16-
const manager: PM = await detect({ cwd: rootDir })
16+
const manager: PM = detectPackageManager(rootDir)
1717
switch (manager) {
18-
case "pnpm":
18+
case PM.PNPM:
1919
if (await isPnpmProjectHoisted(rootDir)) {
2020
return new NpmNodeModulesCollector(rootDir)
2121
}
2222
return new PnpmNodeModulesCollector(rootDir)
23-
case "npm":
23+
case PM.NPM:
2424
return new NpmNodeModulesCollector(rootDir)
25-
case "yarn":
25+
case PM.YARN:
2626
return new YarnNodeModulesCollector(rootDir)
2727
default:
2828
return new NpmNodeModulesCollector(rootDir)
@@ -34,4 +34,4 @@ export async function getNodeModules(rootDir: string): Promise<NodeModuleInfo[]>
3434
return collector.getNodeModules()
3535
}
3636

37-
export { detect, getPackageManagerVersion, PM }
37+
export { detectPackageManager, PM, getPackageManagerCommand }
Lines changed: 82 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,103 @@
1-
// copy from https://github.com/egoist/detect-package-manager/blob/main/src/index.ts
2-
// and merge https://github.com/egoist/detect-package-manager/pull/9 to support Monorepo
3-
import { resolve, dirname } from "path"
4-
import { exec, exists } from "builder-util"
5-
6-
export type PM = "npm" | "yarn" | "pnpm" | "bun"
7-
8-
const cache = new Map()
9-
const globalInstallationCache = new Map<string, boolean>()
10-
const lockfileCache = new Map<string, PM>()
11-
12-
/**
13-
* Check if a global pm is available
14-
*/
15-
function hasGlobalInstallation(pm: PM): Promise<boolean> {
16-
const key = `has_global_${pm}`
17-
if (globalInstallationCache.has(key)) {
18-
return Promise.resolve(globalInstallationCache.get(key)!)
19-
}
1+
import * as path from "path"
2+
import * as fs from "fs"
203

21-
return exec(pm, ["--version"], { shell: true })
22-
.then(res => {
23-
return /^\d+.\d+.\d+$/.test(res)
24-
})
25-
.then(value => {
26-
globalInstallationCache.set(key, value)
27-
return value
28-
})
29-
.catch(() => false)
4+
export enum PM {
5+
NPM = "npm",
6+
YARN = "yarn",
7+
PNPM = "pnpm",
8+
YARN_BERRY = "yarn-berry",
309
}
3110

32-
function getTypeofLockFile(cwd = process.cwd()): Promise<PM> {
33-
const key = `lockfile_${cwd}`
34-
if (lockfileCache.has(key)) {
35-
return Promise.resolve(lockfileCache.get(key)!)
36-
}
11+
function detectPackageManagerByEnv(): PM {
12+
if (process.env.npm_config_user_agent) {
13+
const userAgent = process.env.npm_config_user_agent
3714

38-
return Promise.all([
39-
exists(resolve(cwd, "yarn.lock")),
40-
exists(resolve(cwd, "package-lock.json")),
41-
exists(resolve(cwd, "pnpm-lock.yaml")),
42-
exists(resolve(cwd, "bun.lockb")),
43-
]).then(([isYarn, _, isPnpm, isBun]) => {
44-
let value: PM
45-
46-
if (isYarn) {
47-
value = "yarn"
48-
} else if (isPnpm) {
49-
value = "pnpm"
50-
} else if (isBun) {
51-
value = "bun"
52-
} else {
53-
value = "npm"
15+
if (userAgent.includes("pnpm")) {
16+
return PM.PNPM
5417
}
5518

56-
cache.set(key, value)
57-
return value
58-
})
59-
}
19+
if (userAgent.includes("yarn")) {
20+
if (userAgent.includes("yarn/")) {
21+
const version = userAgent.match(/yarn\/(\d+)\./)
22+
if (version && parseInt(version[1]) >= 2) {
23+
return PM.YARN_BERRY
24+
}
25+
}
26+
return PM.YARN
27+
}
6028

61-
export const detect = async ({ cwd, includeGlobalBun }: { cwd?: string; includeGlobalBun?: boolean } = {}) => {
62-
let type = await getTypeofLockFile(cwd)
63-
if (type) {
64-
return type
29+
if (userAgent.includes("npm")) {
30+
return PM.NPM
31+
}
6532
}
6633

67-
let tmpCwd = cwd || "."
68-
for (let i = 1; i <= 5; i++) {
69-
tmpCwd = dirname(tmpCwd)
70-
type = await getTypeofLockFile(tmpCwd)
71-
if (type) {
72-
return type
34+
if (process.env.npm_execpath) {
35+
const execPath = process.env.npm_execpath.toLowerCase()
36+
37+
if (execPath.includes("pnpm")) {
38+
return PM.PNPM
39+
}
40+
41+
if (execPath.includes("yarn")) {
42+
if (execPath.includes("berry") || process.env.YARN_VERSION?.startsWith("2.") || process.env.YARN_VERSION?.startsWith("3.")) {
43+
return PM.YARN_BERRY
44+
}
45+
return PM.YARN
46+
}
47+
48+
if (execPath.includes("npm")) {
49+
return PM.NPM
7350
}
7451
}
7552

76-
if (await hasGlobalInstallation("yarn")) {
77-
return "yarn"
53+
if (process.env.PNPM_HOME) {
54+
return PM.PNPM
7855
}
79-
if (await hasGlobalInstallation("pnpm")) {
80-
return "yarn"
56+
57+
if (process.env.YARN_REGISTRY) {
58+
if (process.env.YARN_VERSION?.startsWith("2.") || process.env.YARN_VERSION?.startsWith("3.")) {
59+
return PM.YARN_BERRY
60+
}
61+
return PM.YARN
8162
}
8263

83-
if (includeGlobalBun && (await hasGlobalInstallation("bun"))) {
84-
return "bun"
64+
if (process.env.npm_package_json) {
65+
return PM.NPM
8566
}
86-
return "npm"
67+
68+
// return default
69+
return PM.NPM
8770
}
8871

89-
export function getPackageManagerVersion(pm: PM) {
90-
return exec(pm, ["--version"], { shell: true }).then(res => res.trim())
72+
export function getPackageManagerCommand(pm: PM) {
73+
let cmd = pm
74+
if (pm === PM.YARN_BERRY || process.env.FORCE_YARN === "true") {
75+
cmd = PM.YARN
76+
}
77+
return `${cmd}${process.platform === "win32" ? ".cmd" : ""}`
9178
}
9279

93-
export function clearCache() {
94-
return cache.clear()
80+
export function detectPackageManager(cwd: string) {
81+
const isYarnLockFileExists = fs.existsSync(path.join(cwd, "yarn.lock"))
82+
const isPnpmLockFileExists = fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))
83+
const isNpmLockFileExists = fs.existsSync(path.join(cwd, "package-lock.json"))
84+
85+
if (isYarnLockFileExists && !isPnpmLockFileExists && !isNpmLockFileExists) {
86+
// check if yarn is berry
87+
const pm = detectPackageManagerByEnv()
88+
if (pm === PM.YARN_BERRY) {
89+
return PM.YARN_BERRY
90+
}
91+
return PM.YARN
92+
}
93+
94+
if (isPnpmLockFileExists && !isYarnLockFileExists && !isNpmLockFileExists) {
95+
return PM.PNPM
96+
}
97+
98+
if (isNpmLockFileExists && !isYarnLockFileExists && !isPnpmLockFileExists) {
99+
return PM.NPM
100+
}
101+
// if there are no lock files or multiple lock files, return the package manager from env
102+
return detectPackageManagerByEnv()
95103
}

packages/app-builder-lib/src/platformPackager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,17 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
608608
getResourcesDir(appOutDir: string): string {
609609
if (this.platform === Platform.MAC) {
610610
return this.getMacOsResourcesDir(appOutDir)
611-
} else if (isElectronBased(this.info.framework)) {
611+
}
612+
if (isElectronBased(this.info.framework)) {
612613
return path.join(appOutDir, "resources")
613-
} else {
614-
return appOutDir
615614
}
615+
return appOutDir
616616
}
617617

618+
public getMacOsElectronFrameworkResourcesDir(appOutDir: string): string {
619+
const electronFrameworkName = path.basename(this.info.framework.distMacOsAppName, ".app") + " " + "Framework.framework"
620+
return path.join(appOutDir, `${this.appInfo.productFilename}.app`, "Contents", "Frameworks", electronFrameworkName, "Resources")
621+
}
618622
public getMacOsResourcesDir(appOutDir: string): string {
619623
return path.join(appOutDir, `${this.appInfo.productFilename}.app`, "Contents", "Resources")
620624
}

0 commit comments

Comments
 (0)