npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ender-dependency-graph

v0.0.2

Published

Dependency graph construction and processing for the Ender CLI

Downloads

35

Readme

Ender Dependency Graph Build Status

A component of the Ender CLI, used to build a dependency graph of installed packages given a list of parent packages.

Similar to the npm ls command, this package understands Ender-specific packages by using ender-package-util to interpret the package.json files (which may contain Ender-specific overrides for some root keys).

The DependencyGraph object returned by this package can be used to iterate over packages in the dependency graph. This is used for package-bundling in the Ender CLI.

The ender-js package (or alternative client-lib, supplied with the 'client-lib' option), where it exists in the list of packages, will be automatically shifted to the top of the dependency graph so it is always processed first.

About Ender

For more information checkout http://ender.jit.su

API

enderDependencyGraph(options, packages, callback)

enderDependencyGraph() called as a function, will construct a DependencyGraph object for the given list of packages, working in the current working directory, and return it to via the callback function.

The options object may contain an optional 'client-lib' key that will override the default 'ender-js'. The client-lib will be automatically shifted to the begining of the graph so that it will always be processed first.

Each node in the graph takes the form:

{
    "packageJSON": {} // the package.json data, interpreted by ender-package-util
  , "parents": [] // an array of parent names/paths, useful for locating the package on disk
  , "dependencies": {} // any child-nodes of this node
}

Any dependencies in the tree, including root packages, that are not found on disk, will be identified by replacing the node object with the sring: 'missing'.


enderDependencyGraph.getClientPackageName(options)

getClientPackageName() is a simple utility to work out the client-lib from the given options. By default it is 'ender-js' but the 'client-lib' property in the options object may override this value.


enderDependencyGraph.archyTree(packages, dependencyGraph, preparePretty)

archyTree() will take a list of packages and a DependencyGraph object and return an archy-compatible tree out of the data. Each node takes the following structure:

{
    "label": "" // the name of the package
  , "version": x.y.z // the semver for the packake
  , "description": "" // the package description from package.json
  , "nodes": [] // child nodes of this package
}

archy only cares about the 'label' and 'nodes' properties, the rest are there to allow for non-archy output methods.

By providing true for the third argument to archyTree(), preparePretty, you will receive back a string, already passed through archy, complete with versions, descriptions and colouring, ready for printing to stdout.


Executable

If you install with npm install ender-dependency-graph -g (why would you?) then you'll get an ender-dependency-graph executable that you can run with a list of packages. It will scan your node_modules directory, understand the Ender-specific dependency structure and pretty-print a tree for you.

Contributing

Contributions are more than welcome! Just fork and submit a GitHub pull request! If you have changes that need to be synchronized across the various Ender CLI repositories then please make that clear in your pull requests.

Tests

Ender Dependency Graph uses Buster for unit testing. You'll get it (and a bazillion unnecessary dependencies) when you npm install in your cloned local repository. Simply run npm test to run the test suite.

Licence

Ender Dependency Graph is Copyright (c) 2012 @rvagg, @ded, @fat and other contributors. It is licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.