feat: auto-install the project's package manager during mod/deploy#405
Merged
Conversation
Add a React-free packageManagers module with parsePackageManagerField and detectProjectPackageManager (precedence: packageManager field > lockfile > setup.sh reference > npm default), reusing detectPackageManager and detectReferencedPackageManagers.
Add pure command builders for Node (brew/NodeSource), pnpm, yarn (corepack) and bun via their official installers. Extract the shared sudo() prefix into a pure leaf module so packageManagers.ts stays off toolchain.ts and within the React-free build/deploy surface boundary.
Add PmTool installers (Node, pnpm, yarn via corepack, bun) wrapping the pure command builders, and the PM_TOOLS map giving the ordered prerequisite list per package manager (Node before pnpm/yarn; bun standalone). pnpm's post-install PATH fix resolves the platform-specific PNPM_HOME (~/Library/pnpm on macOS).
Add the orchestrator that detects a project's PM, checks which tools are missing, asks for one confirmation (auto-proceeds when no confirm callback is given), and installs the missing tools in order. PackageManagerUnavailableError is the soft user-declined outcome; install/platform failures reject as plain errors carrying the captured log.
runBuild now calls ensurePackageManager inside the install gate, before shelling out to the detected package manager, so a missing pnpm/yarn/bun/npm is auto-installed (with one confirmation) instead of failing cryptically. Adds an optional confirm option to RunBuildOptions; existing callers auto-proceed.
Add decidePmPhase (setup/confirm/install based on missing tools + TTY) and pmConfirmLabel for the SetupScreen package-manager phase, lifted into a React-free sibling module so the .tsx stays thin and the logic is unit-tested.
Add planPackageManagerForTools and the disk-backed planPackageManager, the read-only sibling of the orchestrator: they report which tools are missing without installing, so the mod SetupScreen can render its confirmation prompt before deciding whether to install.
Restructure SetupScreen into a phase machine: after downloading the app's source it detects the project's package manager and, when it (or Node) is missing, asks once to install it (auto-proceeds without a TTY) before running setup.sh. Declining is a soft outcome with a manual-install hint. Removes the old throw-only missing-package-manager gate.
findUnsatisfiedPackageManagers and missingPackageManagerMessage are no longer called now that SetupScreen auto-installs the project's package manager. detectReferencedPackageManagers stays as the setup.sh detection signal consumed by packageManagers.ts.
…setup.sh PLAIN_ENV was a module-load snapshot, so the bin dir the package-manager auto-install prepends to process.env.PATH never reached the setup.sh child — breaking the mod flow that installs pnpm/bun and then runs setup.sh. Build the child env per call instead. Adds a regression test for the live-PATH behavior.
- yarn: install corepack shims into a user-owned --install-directory and prependPath it, so a NodeSource Linux install no longer hits EACCES writing to the root-owned Node bin dir. - bun: honor $BUN_INSTALL when exposing the freshly-installed bin dir, instead of hardcoding ~/.bun/bin. - orchestrator: re-check each tool after install and fail with the manual hint if it is still not on PATH, instead of letting the next step die with a confusing "command not found". - orchestrator: single-flight installs by tool name so concurrent deploy-all builds sharing a missing manager don't race the same installer. - detect: recognise bun 1.2+'s text lockfile bun.lock (not just bun.lockb). - changeset: clarify that deploy/build auto-install while mod prompts.
Contributor
E2E Test Pass · ❌ FAILTag:
❌ Failed tests (3)
Sentry traces: view spans for this run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When
playground mod(andplayground deploy/build) needs a JavaScript package manager the user doesn't have, the CLI now detects which one the project uses (pnpm/yarn/bun/npm) and installs it — plus Node.js when needed — for macOS/Linux, instead of failing with a confusing "command not found".playground mod: after downloading an app's source, detects the project's package manager and, when it (or Node.js) is missing, asks once before installing, then runssetup.sh. Declining is a soft outcome with a manual-install hint.playground deploy/build: a missing manager is installed automatically as part of the build step (output streamed). Non-interactive runs install without prompting.How it works
packageManagerfield → lockfile →setup.shreference → npm default (src/utils/packageManagers.ts).get.pnpm.io; yarn via corepack (into a user-owned--install-directoryto avoid EACCES on a root-owned Node bin dir); bun viabun.sh/install.deploy-allbuilds don't race the same installer, and each tool is re-checked after install so a PATH mismatch fails with an actionable hint rather than later.Notes / scope
deploy/buildauto-install without an interactive prompt; onlymodprompts. Non-TTYsudo apt/NodeSource on Linux requires root or passwordless sudo (same as the existing login toolchain installs).Test Plan
pnpm typecheck,pnpm format:check,pnpm lint:licensecleanpnpm test— 973 passing (unit coverage for detection precedence, platform-aware install command builders, the orchestrator's confirm/auto-proceed/decline/failure-propagation/single-flight/post-install-recheck paths, the bun.lock detection, and therunCommandlive-PATH behavior)playground modon a pnpm project without pnpm installed (TTY) prompts once, installs Node + pnpm, then runs setup.sh