Skip to main content

Crate vivacity_core

Crate vivacity_core 

Source
Expand description

vivacity-core: manifests, platform, fetch and installation.

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

binproxy
vendor/bin proxies: byte-for-byte port of BinaryInstaller::generateUnixyProxyCode (docs/reference/BinaryInstaller.php). Three shapes: PHP target with shebang (anti-shebang stream wrapper for PHP<8, special phpunit hack), bare PHP target, non-PHP target (sh proxy). Parity is held by the differential test against the proxies generated by Composer in the Laravel fixture (tests/fixtures_binproxy.rs).
clone
Clone of a store tree into vendor/, the hot path of the install. macOS/APFS: clonefile(2) of the whole directory (one syscall, copy-on-write, measured 8x faster than extraction in M0). Elsewhere, or if clonefile fails (other FS, different volume): recursive walk with hardlinks (pnpm model), and a real copy as a last resort. Always towards an ABSENT destination (the caller removes the previous version first), so no mixed states.
constraint
Subset of composer/semver constraints for the platform check. Port of VersionParser::parseConstraint(s) (pinned source: docs/reference/SemverVersionParser.php, extracted from the 2.10.3 phar).
content_hash
Port of Composer\Package\Locker::getContentHash (2.10.3, see docs/reference/Locker.php): md5 of a subset of composer.json re-encoded through JsonFile::encode($relevantContent, 0).
dirs
config.vendor-dir and config.bin-dir, resolved like Config::get('vendor-dir' | 'bin-dir') (Composer 2.10.3):
error
extract
Extraction of a zip dist into a directory, stripping the single root directory of GitHub/Packagist zipballs (ArchiveDownloader’s rule: strip iff the archive has exactly one top-level entry and it is a directory; otherwise everything is extracted as is), and a DISTRUSTFUL extraction:
fetch
Dist downloads, interoperable with Composer’s cache: same layout (<cache>/files/<vendor>/<pkg>/<sha1-of-url>.zip), both read AND fed, so a cache warmed by one serves the other. Minimal v1 auth: github-oauth, http-basic, bearer (project auth.json, COMPOSER_AUTH, then the COMPOSER_HOME auth.json). The lock’s shasum, when present, is checked on download AND when reading back from the cache (meta-analysis F7: a shared cache is read back with suspicion).
glob
The glob() a path repository runs (PathRepository::getUrlMatches: GLOB_MARK | GLOB_ONLYDIR | GLOB_BRACE) and Platform::expandPath, reproduced from the libc semantics PHP exposes on Linux and macOS:
installer
The install transaction: diff (lock vs installed state), parallel fetch into the store, store-to-vendor clone, bin proxies, state files, runtime stub. Idempotent (rerun after an interruption, it converges): the reference state is installed.json + the presence of the directories, and each package is laid out by cloning into a previously removed vendor/.
installers
Port of composer/installers (Installer + BaseInstaller, tags 2.0.0 to 2.3.0; docs/reference/installers/ holds the 2.3.0 source). The logic is identical across the whole 2.x series; only the location tables change, hence one table per tag in assets/installers/.json (generated by tools/gen-installers-table.php, never edited by hand).
jsonfile
One parse per JSON file per process: installed.json and the global config.json are read by the scope analysis, the layout, the transaction, the installer and the autoloader in the same run. The parsed value is kept by path and validated on each read against the file’s (mtime ns, size) — a file rewritten mid-run (installed.json by the installer) is parsed again; a file removed comes back as absent.
layout
Where each package of the lock gets installed: vendor/<name>[/<target-dir>] by LibraryInstaller, or the path composer/installers gives it when that plugin is locked, allowed (config.allow-plugins) and ported (installers::table_for). A single pass, before touching the disk; anything not reproducible byte for byte becomes an issue (falls back to Composer).
lock
Reading composer.lock. Minimal typed view over the raw JSON: installed.json/installed.php will have to serve the entries back unchanged, so each package keeps its raw value (raw) and only exposes as typed fields what the installer needs.
path_install
Composer\Downloader\PathDownloader (docs/reference/PathDownloader.php) for Linux and macOS: a path package is laid out as a symbolic link to its source — relative through findShortestPath(..., preferRelative) when transport-options.relative (the default), absolute otherwise — or as a mirror (symlink: false, or COMPOSER_MIRROR_PATH_REPOS) copied through the ArchivableFilesFinder rules (docs/reference/ ArchivableFilesFinder.php, GitExcludeFilter.php, BaseExcludeFilter.php, symfony-finder-Glob.php) and Symfony’s Filesystem::mirror/copy (docs/reference/symfony-Filesystem.php):
pathutil
Exact ports of Composer\Util\Filesystem: normalizePath, findShortestPath, findShortestPathCode (Composer 2.10.3). They decide the paths written into installed.json/installed.php, the autoload files and the bin proxies; checked by tests/oracle_installers.rs. Unix paths only (no C:/file:// prefix).
pest_plugin
Emulation of the pestphp/pest-plugin Composer plugin (docs/reference/plugins/pest-plugin/, MIT): on post-autoload-dump its DumpCommand writes vendor/pest-plugins.jsonjson_encode(..., JSON_PRETTY_PRINT) of the array_merge of every installed package’s extra.pest.plugins list, in the local repository’s order (getCanonicalPackages(): aliases excluded), the root package last. Identical from v1.0.0 to v5.0.0 (the four versions the corpus holds).
phparray
PHP array operations on JSON values, as the merge plugin and Composer apply them to manifest sections: a JSON object is a string-keyed PHP array, a JSON array an integer-keyed one.
phpcs_installer
Emulation of dealerdirect/phpcodesniffer-composer-installer (docs/reference/plugins/phpcodesniffer-composer-installer/, MIT; 0.7.2 to 1.2.1 behave alike on an install): on post-install-cmd / post-update-cmd, when squizlabs/php_codesniffer is installed, the plugin registers every coding standard found in the packages of type phpcodesniffer-standard (and in the project when the root package is one) as PHP_CodeSniffer’s installed_paths, through phpcs --config-set installed_paths <a>,<b>:
phpjson
JSON re-encoding reproducing PHP’s json_encode($data, 0) applied to data coming from json_decode($json, true) (the JsonFile::parseJson -> JsonFile::encode pipeline, Composer 2.10.3, see docs/reference/JsonFile.php).
phpserialize
PHP serialize() of a value that came out of json_decode($json, true): what PathRepository::initialize hashes (sha1($json . serialize($this ->options))) to build the dist reference of a path package. Only the shapes a JSON document can produce are covered: assoc arrays in insertion order (a:n:{…}; a key that PHP would have turned into an integer — a canonical decimal in the int range — is written i:), lists, strings (s:<bytes>:"…";), integers, floats in PHP’s shortest round-trip form (d:), booleans and null.
platform
What a platform check reports (PlatformFailure, the shared --ignore-platform-req matching) and the per-platform switches (parallel_io, cache_dir). The probe of the local PHP and the check of a lock against it live in vivacity_resolver::platform (probe, platform_packages, check_install), the port of PlatformRepository that install and update both use.
root_version
Root package version: port of RootPackageLoader::load + VersionGuesser::guessGitVersion (docs/reference/RootPackageLoader.php, VersionGuesser.php, Composer 2.10.3). Order: version from composer.json, else COMPOSER_ROOT_VERSION, else git (current branch; detached HEAD -> dev-<sha> then exact tag; feature branch -> closest parent branch by git rev-list), else 1.0.0+no-version-set. hg/fossil/svn are not ported (fallback to the default, as without a VCS).
runtime_stub
Emulation of the symfony/runtime plugin (plan r2): the plugin only generates vendor/autoload_runtime.php at autoload dump time. The template below is the observed output of the real plugin (symfony-demo fixture, default options); the drift test (ignored by default, slow) regenerates the reference through a real composer install with plugins.
scope
Out-of-scope detector: decides, BEFORE touching the disk, whether vivacity can install this lock natively or must delegate to composer install (default fallback) / fail explicitly (when Composer is not available).
state
Generation of the vendor/composer/ state files:
store
Local content-addressed store: each (package, version, dist reference) is extracted ONCE into <cache>/store/<vendor>/<pkg>/<key>/, then cloned into the projects’ vendor/ (see clone.rs). Atomic write: extraction into a sibling temporary directory then rename; the final directory only exists complete, and two concurrent processes converge (the loser of the rename discards its temporary directory).
version
Subset of Composer versioning needed by the platform check: numeric versions X[.Y[.Z[.W]]] with an optional stability suffix (-dev, -alpha.N, -beta.N, -RC.N, -patch.N), compared like composer/semver (4-component normalisation, dev < alpha < beta < RC < stable < patch). Branches (dev-master, 1.x-dev) are outside this subset: parse returns an error and the caller treats the package as out of scope rather than guessing.

Functions§

random_bytes
random_bytes($n) for the few places Composer draws randomness (the APCu prefix): the OS entropy source, or the hasher seed as a fallback.