Code Monkey home page Code Monkey logo

yarnlock's Introduction

Mindscreen\YarnLock

CircleCI codecov

A php-package for parsing and evaluating the yarn.lock format.

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:

<?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);

yarnlock's People

Contributors

prgfx avatar sweetchuck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

yarnlock's Issues

Scoped package names

Splitting package name and version at @ breaks for scoped packages like @gulp-sourcemaps/identity-map so that these packages aren't found and throw an error.

CircleCI and codecov

Some initial setup is required on

Codecov provides a token and it has to be added on CircleCI as CODECOV_TOKEN environment variable.

On the WebUI of CircleCI a build can be trigger manually for a branch.
Currently the badge says: "No builds"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.