Skip to main content

Module npm_install

Module npm_install 

Source
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_installed reads: the project, its bynk.toml setting, the toolbox and the runner.
RealProject
Project over the real file system and process environment.
SystemRunner
Runner over the real tools (crate::tools::run_to_completion).

Enums§

DetectError
Why detection chose nothing usable.
InstallError
Why the packages are not installed.
Mode
What an install request is allowed to do.
Outcome
What ensure_installed did.
PackageManager
A package manager bynk can install with.
Rule
The rule that chose the package manager, for bynk doctor and messages.

Constants§

NO_INSTALL_ENV
The environment form of --no-install (for bynk dev and bynk 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; SystemRunner is the real one.

Functions§

announce
The tool bynk dev/bynk deploy/bynk test print 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.json lists present in its node_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. Err is the message to print (without the bynk: prefix).
install_for_project_shown_as
install_for_project, with a dry run’s report naming shown_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_manager over the project’s real files and the process environment, reading [build] package_manager from its bynk.toml, with PATH seen through tb.
missing_npm_dependencies
The npm packages the emitted package.json lists (an adapter’s, and the toolchain’s own, ADR 0799 C) that node_modules beside it does not hold, sorted.
no_install_from_env
Whether BYNK_NO_INSTALL asks for --no-install: set, and not 0, false, no or off.
system_tool_manager
manager_in over 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.