2017 © Pedro Peláez
 

library yarnlock

A package for parsing and interpreting yarn.lock files

image

mindscreen/yarnlock

A package for parsing and interpreting yarn.lock files

  • Friday, February 23, 2018
  • by theilm
  • Repository
  • 3 Watchers
  • 1 Stars
  • 20 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 67 % Grown

The README.md

Mindscreen\YarnLock

CircleCI codecov, (*1)

A php-package for parsing and evaluating the yarn.lock format., (*2)

Basic Usage

<?php
use Mindscreen\YarnLock;

$yarnLock = YarnLock::fromString(file_get_contents('yarn.lock'));

$allPackages = $yarnLock->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:, (*3)

<?php
use Mindscreen\YarnLock;
// read the dependencies from the package.json file
$packageDependencies = (json_decode(file_get_contents('package.json')))->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);

The Versions

23/02 2018

dev-master

9999999-dev

A package for parsing and interpreting yarn.lock files

  Sources   Download

MIT

The Development Requires

by Matthias Klatte

23/02 2018

v1.0.1

1.0.1.0

A package for parsing and interpreting yarn.lock files

  Sources   Download

MIT

The Development Requires

by Matthias Klatte

21/02 2018

v1.0.0

1.0.0.0

A package for parsing and interpreting yarn.lock files

  Sources   Download

MIT

The Development Requires

by Matthias Klatte