NativeInstaller
API reference › Foxy › Native › NativeInstaller
Installs the frontend dependencies of a package.json into a flat directory (node_modules by default) without a
Node.js package manager.
Registry packages are resolved (or read from a fresh foxy.lock), downloaded, and extracted into
<install directory>/.foxy-tmp before being moved into place; file: packages are copied from their local
directory. Top-level entries of the install directory outside the install set are removed, except dot-entries such
as .bin. A registry package already in place with its recorded lock entry is kept; see InstalledState.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates the native package installer. | NativeInstaller |
install() | Installs the dependencies declared by the manifest, reading or rewriting the lock file. | NativeInstaller |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(Composer\IO\IOInterface $io, Composer\Util\Filesystem $fs, Foxy\Native\NpmRegistryInterface $registry, Foxy\Native\DependencyResolver $resolver, Foxy\Native\TarballExtractor $extractor)Creates the native package installer.
Parameters
| Parameter | Type | Description |
|---|---|---|
$io | Composer\ | Output that receives one line per changed package, and per kept package at verbose level. |
$fs | Composer\ | Filesystem used to copy, move, and remove package directories. |
$registry | NpmRegistryInterface | Registry that provides the tarballs. |
$resolver | DependencyResolver | Resolver of the registry requirements. |
$extractor | TarballExtractor | Extractor of the downloaded tarballs. |
install()
Section titled “install() ”public function install(string $manifestPath, string $lockPath, string $installDirectory, bool $update): voidInstalls the dependencies declared by the manifest, reading or rewriting the lock file.
A missing manifest declares no dependency. An optional file: package whose package.json is missing is skipped
with a warning. The dependencies, devDependencies, and optionalDependencies maps
are merged, an optional entry overriding a mandatory one of the same name as npm does; an unsatisfiable optional
entry is skipped with a warning. The lock file is reused when it is fresh (same requirements, same
local package versions) and $update is false; otherwise the requirements are resolved again and the lock
file is written before any package is installed, so a download failure leaves a usable lock file.
Parameters
| Parameter | Type | Description |
|---|---|---|
$manifestPath | string | Path of the root package.json. |
$lockPath | string | Path of the foxy.lock file. |
$installDirectory | string | Path of the directory to populate (node_modules by default). |
$update | bool | Whether to resolve again even when the lock file is fresh. |
Throws
Foxy\Exception\RuntimeException: if a manifest is invalid, a mandatory local package is missing, a local package overlaps the install directory, a requirement cannot be resolved or downloaded, the lock file is malformed, a local package cannot be copied, or an existing package directory cannot be removed.