Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .changeset/wild-pandas-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"app-builder-lib": patch
"builder-util-runtime": patch
"electron-builder": patch
---

fix: improve package manager detection for Yarn Berry and update Yarn install arguments
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ export function detectPackageManagerByEnv(): PM {
const execPath = process.env.npm_execpath?.toLowerCase() ?? ""

const yarnVersion = process.env.YARN_VERSION
const isBerry = yarnVersion?.startsWith("2.") || yarnVersion?.startsWith("3.")
const isBerry = yarnVersion ? !yarnVersion.startsWith("1.") : false

if (ua.includes("pnpm") || execPath.includes("pnpm") || process.env.PNPM_HOME) {
return PM.PNPM
}

if (ua.includes("yarn") || execPath.includes("yarn") || process.env.YARN_REGISTRY) {
return isBerry || ua.includes("yarn/2") || ua.includes("yarn/3") ? PM.YARN_BERRY : PM.YARN
// Check if it's Berry by version or user agent (yarn/1.x is classic, everything else is Berry)
const isBerryFromUA = /yarn\/(?!1\.)/.test(ua)
return isBerry || isBerryFromUA ? PM.YARN_BERRY : PM.YARN
}

if (ua.includes("npm") || execPath.includes("npm") || process.env.npm_package_json) {
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/util/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function installDependencies(config: Configuration, { appDir, proje
}

if (pm === PM.YARN) {
execArgs.push("--prefer-offline")
execArgs.push("--cached")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this only be for === PM.YARN_BERRY and kept as --prefer-offline for PM.YARN?

}

const execPath = getPackageManagerCommand(pm)
Expand Down
2 changes: 1 addition & 1 deletion packages/builder-util-runtime/src/httpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ Please double check that your authentication token is correct. Due to security r
// Special case: allow http -> https redirect on same host with standard ports
// This matches the behavior of Python requests library for backward compatibility
// url.port returns an empty string if the port is omitted
// or explicitly set to the default port for a given protocol.
// or explicitly set to the default port for a given protocol.
if (
originalUrl.protocol === "http:" &&
// This can be replaced with `!originalUrl.port`, but for the sake of clarity.
Expand Down
3 changes: 2 additions & 1 deletion packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ export function configureBuildCommand(yargs: yargs.Argv): yargs.Argv {
alias: ["c"],
group: buildGroup,
description:
"The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see " + chalk.underline("https://www.electron.build/configuration"),
"The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see " +
chalk.underline("https://www.electron.build/configuration"),
})
.group(["help", "version"], "Other:")
.example("electron-builder -mwl", "build for macOS, Windows and Linux")
Expand Down
Loading