Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mindscreen/yarnlock
A php-package for parsing and evaluating the yarn.lock format
https://github.com/mindscreen/yarnlock
lockfile yarn
Last synced: about 2 months ago
JSON representation
A php-package for parsing and evaluating the yarn.lock format
- Host: GitHub
- URL: https://github.com/mindscreen/yarnlock
- Owner: mindscreen
- Created: 2018-02-20T21:31:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T21:05:27.000Z (11 months ago)
- Last Synced: 2024-04-26T06:22:10.080Z (9 months ago)
- Topics: lockfile, yarn
- Language: PHP
- Size: 51.8 KB
- Stars: 5
- Watchers: 5
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mindscreen\YarnLock
[![CircleCI](https://circleci.com/gh/mindscreen/yarnlock/tree/master.svg?style=svg)](https://circleci.com/gh/mindscreen/yarnlock/?branch=master)
[![codecov](https://codecov.io/gh/mindscreen/yarnlock/branch/master/graph/badge.svg?token=HSF16OGPyr)](https://app.codecov.io/gh/mindscreen/yarnlock/branch/master)A php-package for parsing and evaluating the [yarn.lock](https://yarnpkg.com/lang/en/docs/yarn-lock/) format.
## Basic Usage
```php
getPackages();
$hasBabelCore = $yarnLock->hasPackage('babel-core', '^6.0.0');
$babelCorePackages = $yarnLock->getPackagesByName('babel-core');
$babelCoreDependencies = $babelCorePackages[0]->getDependencies();
```## Package Depth
If you maybe don't just want all packages but only the direct dependencies plus one level of indirection, you have to go a little extra mile:
```php
dependencies;
// get these packages from the yarn lock-file
$rootDependencies = array_map(function($packageName, $packageVersion) use ($yarnLock) {
return $yarnLock->getPackage($packageName, $packageVersion);
}, array_keys($packageDependencies), array_values($packageDependencies));
// some of our dependencies might be used by other dependencies deeper down the tree so
// they wouldn't appear in the top levels, if we wouldn't explicitly set them there.
$yarnLock->calculateDepth($rootDependencies);// get the first two levels; the second argument is the exclusive upper limit
$yarnLock->getPackagesByDepth(0, 2);
```