Giter Club home page Giter Club logo

yarn-logical-tree's Introduction

yarn-logical-tree

Build Status Coverage Status JavaScript Style Guide
This package is a wrapper to getnpm-logical-tree working with a yarn.lock file - most code and tests are taken from that package. The API is the same except for address (and consequently path) which is not implemented (if you need path / address - issues/PRs are very much welcome!)

Install

npm install yarn-logical-tree / yarn add yarn-logical-tree

Example

const fs = require('fs')
const lockfile = require('@yarnpkg/lockfile')
const yarnLogicalTree = require('yarn-logical-tree')

const packagePath = '/path/to/package'
const pkg = fs.readFileSync(`${packagePath}/package.json`, 'utf-8')
const yarnLock = fs.readFileSync(`${packagePath}/yarn.lock`, 'utf-8')

const yarnLockParsed = lockfile.parse(yarnLock)
const pkgParsed = JSON.parse(pkg)
yarnLogicalTree(pkgParsed, yarnLockParsed.object)

// returns:
LogicalTree {
  name: 'some-package',
  version: '1.0.0',
  address: null,
  optional: false,
  dev: false,
  bundled: false,
  resolved: undefined,
  integrity: undefined,
  requiredBy: Set { },
  dependencies:
   Map {
     'foo' => LogicalTree {
       name: 'foo',
       version: '1.2.3',
       address: 'foo',
       optional: false,
       dev: true,
       bundled: false,
       resolved: 'https://registry.npmjs.org/foo/-/foo-1.2.3.tgz',
       integrity: 'sha1-rYUK/p261/SXByi0suR/7Rw4chw=',
       dependencies: Map { ... },
       requiredBy: Set { ... },
     },
     ...
  }
}

License

MIT

yarn-logical-tree's People

Contributors

imsnif avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

yarn-logical-tree's Issues

yarn2 lock file support

Looks like the documentation is for yarn v1 lock file. for Yarn v2 lock file (i.e. YAML) there is no documentation/support available in this library.

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.