CodeVetter · Repo Unpack · Behavior traces
yarnpkg/berry
Three concrete flows were followed through their implementation: CLI startup, installation through persistence, and script/binary execution. Startup can terminate by handing control to another Yarn executable. Installation and execution both restore project state, but apply different resolution, linking, and subprocess branches.
- Startup: cli.ts calls getPluginConfiguration(), which reads the standard bundle list and constructs modules/plugins; runExit then calls getBaseCli() and run().
- Startup dispatch: run() performs validateNodejsVersion → getCoreConfiguration → optional runYarnPath; otherwise checkCwd → initTelemetry → initCommands → cli.process → cli.run. Delegation sets YARN_IGNORE_PATH=1 in the child.
- Install setup: InstallCommand.execute finds Project, applies applicable lockfile migration settings, finds Cache, requires a workspace, restores state without resolutions, and derives refresh/check behavior from explicit flags or hardened mode before Project.install.
- Install resolution: Project.install runs validateProject, stops on validation errors, snapshots an immutable lockfile, invokes resolveEverything, emits peer warnings, and rejects changed generated lockfile content before fetching.
- Install persistence: fetchEverything → optional persist → linkEverything → persistInstallStateFile → post-install validation. UpdateLockfile mode fetches only missing checksums and skips linking; SkipBuild returns from linking before package builds.
- Run script: RunCommand.execute calls Configuration.find → Project.find → restoreInstallState → hasPackageScript → executePackageScript; initialization creates a temporary binary environment, then wrapScriptExecution wraps portable-shell execution.
- Run fallback: absent a selected script, RunCommand checks dependency binaries and forwards Node flags; otherwise it accepts one matching colon-named workspace script. Binary execution chooses Node or direct pipevp and removes its binary folder in finally.
- State recovery: restoreInstallState reads and gunzips the saved file, deserializes it, and restores requested categories. When resolution restoration is requested, unreadable state or a changed lockfile triggers applyLightResolution → resolveEverything(lockfileOnly) → persistInstallStateFile.