Expand description
vivacity-core: manifests, platform, fetch and installation.
Re-exports§
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 throughJsonFile::encode($relevantContent, 0). - dirs
config.vendor-dirandconfig.bin-dir, resolved likeConfig::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()apathrepository runs (PathRepository::getUrlMatches:GLOB_MARK | GLOB_ONLYDIR | GLOB_BRACE) andPlatform::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). - 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 anissue(falls back to Composer). - lock
- Reading composer.lock. Minimal typed view over the raw JSON:
installed.json/installed.phpwill 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: apathpackage is laid out as a symbolic link to its source — relative throughfindShortestPath(..., preferRelative)whentransport-options.relative(the default), absolute otherwise — or as a mirror (symlink: false, orCOMPOSER_MIRROR_PATH_REPOS) copied through theArchivableFilesFinderrules (docs/reference/ ArchivableFilesFinder.php, GitExcludeFilter.php, BaseExcludeFilter.php, symfony-finder-Glob.php) and Symfony’sFilesystem::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 (noC:/file://prefix). - pest_
plugin - Emulation of the
pestphp/pest-pluginComposer plugin (docs/reference/plugins/pest-plugin/, MIT): onpost-autoload-dumpitsDumpCommandwritesvendor/pest-plugins.json—json_encode(..., JSON_PRETTY_PRINT)of thearray_mergeof every installed package’sextra.pest.pluginslist, 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): onpost-install-cmd/post-update-cmd, whensquizlabs/php_codesnifferis installed, the plugin registers every coding standard found in the packages of typephpcodesniffer-standard(and in the project when the root package is one) as PHP_CodeSniffer’sinstalled_paths, throughphpcs --config-set installed_paths <a>,<b>: - phpjson
- JSON re-encoding reproducing PHP’s
json_encode($data, 0)applied to data coming fromjson_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 ofjson_decode($json, true): whatPathRepository::initializehashes (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 theintrange — is writteni:), lists, strings (s:<bytes>:"…";), integers, floats in PHP’s shortest round-trip form (d:), booleans and null. - platform
- Detection of the local platform (PHP, extensions) and check that the lock
is installable on it, the practical equivalent of Composer’s “lock
installability” step, without a solver:
platform/platform-devconstraints of the lock + php/ext-*requireof each locked package. - root_
version - Root package version: port of
RootPackageLoader::load+VersionGuesser::guessGitVersion(docs/reference/RootPackageLoader.php, VersionGuesser.php, Composer 2.10.3). Order:versionfrom composer.json, elseCOMPOSER_ROOT_VERSION, else git (current branch; detached HEAD ->dev-<sha>then exact tag; feature branch -> closest parent branch bygit rev-list), else1.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/runtimeplugin (plan r2): the plugin only generatesvendor/autoload_runtime.phpat 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 realcomposer installwith 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 thenrename; 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 likecomposer/semver(4-component normalisation, dev < alpha < beta < RC < stable < patch). Branches (dev-master,1.x-dev) are outside this subset:parsereturns 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.