Expand description
Installing the npm packages a generated build directory lists, with the package manager the user already has (#3350).
bynk test, bynk dev and bynk deploy all build into a directory bynk
generates (out/, .bynk/dev, .bynk/deploy) whose package.json pins the
toolchain’s own npm packages (postal-mime for inbound email, ADR 0799 C)
and any adapter’s approved ones. This module is the one routine that makes
those packages present, and it runs a tool only when a listed package is
missing, so a warm re-run needs no network.
Which tool downloads the packages is decided by detect, a pure function
over an injected Project view (files and environment) and a
Toolbox (PATH), so every rule is unit-tested without a real tool. The
install runs through a Runner for the same reason.
Lifecycle scripts are always off. The approval of a fetched adapter’s npm
packages (ADR 0575) is enforced when the project compiles, before the build
directory exists, so nothing here can install an unapproved package: the
package.json this reads only lists approved ones and the toolchain’s own.
Structs§
- Detection
- The detected package manager and the rule that chose it.
- Install
- Everything
ensure_installedreads: the project, itsbynk.tomlsetting, the toolbox and the runner. - Real
Project Projectover the real file system and process environment.- System
Runner Runnerover the real tools (crate::tools::run_to_completion).
Enums§
- Detect
Error - Why detection chose nothing usable.
- Install
Error - Why the packages are not installed.
- Mode
- What an install request is allowed to do.
- Outcome
- What
ensure_installeddid. - Package
Manager - A package manager bynk can install with.
- Rule
- The rule that chose the package manager, for
bynk doctorand messages.
Constants§
- NO_
INSTALL_ ENV - The environment form of
--no-install(forbynk devandbynk deploy). - PACKAGE_
MANAGER_ ENV - The environment variable that overrides
bynk.toml’s[build] package_manager.
Traits§
- Project
- The files and environment of the project, as a view detection reads.
- Runner
- Runs a tool to completion. The seam for tests;
SystemRunneris the real one.
Functions§
- announce
- The tool
bynk dev/bynk deploy/bynk testprint before a real install, so a slow download does not read as a hang. - configured_
manager bynk.toml’s[build] package_manager, if it sets one and the manifest reads. A malformed manifest is reported by the build, not here.- detect
- Choose the package manager, first match wins:
- dry_
run_ message - The dry-run line: what would be installed, and with which tool.
- ensure_
installed - Make the packages
build_dir/package.jsonlists present in itsnode_modules. Nothing runs when none is missing. - install_
for_ project - The whole step for a caller with the real file system, tools and process
environment: detect, install, and print the announcements.
Erris the message to print (without thebynk:prefix). - install_
for_ project_ shown_ as install_for_project, with a dry run’s report namingshown_dir: where a real run would install. #3796: a deploy dry run builds in a scratch directory, but a real deploy installs in.bynk/deploy.- manager_
in tool_managerover the project’s real files and the process environment, reading[build] package_managerfrom itsbynk.toml, with PATH seen throughtb.- missing_
npm_ dependencies - The npm packages the emitted
package.jsonlists (an adapter’s, and the toolchain’s own, ADR 0799 C) thatnode_modulesbeside it does not hold, sorted. - no_
install_ from_ env - Whether
BYNK_NO_INSTALLasks for--no-install: set, and not0,false,nooroff. - system_
tool_ manager manager_inover the real PATH.- tool_
manager - The package manager the toolchain’s own tool fallbacks and install hints follow: the detected one, or npm (today’s behaviour) when detection finds none or names an unknown tool.