feat: allow explicit package-manager selection and inject resolved PM into init pipeline #4005
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summarize your changes:
ref
Summary
This PR improves support for alternative package managers (pnpm, Yarn Berry) during project initialization.
Previously,
npx create-electron-app
resolved tonpm
at init time (because lockfiles don’t exist yet and npx sets the npm user agent). As a result, templates depending on pnpm/yarn–specific setup were silently misconfigured.This change allows users to explicitly choose a package manager via CLI prompt or
--package-manager
flag, and ensures that decision is consistently propagated through the init pipeline.Problem
pnpm install
) did not re-run template logic (e.g..npmrc
,pnpm.onlyBuiltDependencies
).resolvePackageManager()
relied on user-agent or existing lockfile. Neither works at init time.Solution
--package-manager
flag (non-interactive / CI)resolvePackageManager()
to accept and cache an explicit argument.Alternatives Considered
FORGE_PACKAGE_MANAGER
): simple, but too implicit.Explicit selection + propagation was chosen for clarity and determinism.
Impact
Result / Outcome
npmrc
filepnpm.onlyBuiltDependencies
configuration.yarnrc
fileThis allows users to run Electron Forge out-of-the-box with their chosen package manager, without requiring any manual configuration.
Document