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-package

v1.0.3

Published

Package handling for the Ender CLI

Downloads

7

Readme

Ender Package Build Status

A component of the Ender CLI, providing an interface for working with source packages, including Ender-specific extensions to the package.json format.

About Ender

For more information check out http://ender.jit.su

API

loadPackage(root, callback)

loadPackage() will attempt to load the package located at the given root directory. It will try to read the package descriptor (including applying Ender-specific overrides) and then, if successful, return the LocalPackage object through the callback.


unloadPackage(root)

unloadPackage() should be used when a previously-loaded package has changed on disk. The ender-package module caches all package operations that touch the disk, so if the on-disk representation of the package changes, you must call unloadPackage() for those changes to be recognized.


findPackage(id, root, callback)

findPackage() is similar to loadPackage(), except that instead of taking a package root directory, it is passed a package id, which it will attempt to find using the standard Node search algorithm, walking up the directory tree from the given root directory to see if it can find the package in any parent, or any 'node_modules' directory. If the package id includes a version, only packages which satisfy the version requirement will be returned.

NOTE: Since this attempts to load parent packages to see if they match the given name, those packages will become cached, and you may need to call unloadPackage() if those packages change.


walkDependencies(ids, unique, strict, callback)

walkDependencies() will find all the package ids passed into it, as well as recursively loading all of their dependencies. The unique argument indicates whether duplicate packages with the same name (but perhaps different versions) should be filtered out. If the strict argument is true, any dependency that cannot be found will trigger an error. If the strict argument is false, missing dependencies will be collected and passed to the callback. If no error occurs (or strict is false), the callback will receive a list of LocalPackage objects in depth-first order, as well as a list of missing dependencies.


buildArchyTree(ids, pretty, callback)

archyTree() will take a list of package ids and returns through the callback an Archy tree showing the named packages and their dependencies. The pretty argument will add coloring to the output for display on the console.


LocalPackage.create(root)

LocalPackage objects should generally not be created directly, but rather with loadPackage() or findPackage(). If you use the create() function to create a LocalPackage object, you are responsible for calling loadDescriptor to load the package descriptor. This will allow you to lookup properties of the package like id, name, version, and description. The loadSources() method will load the package source files into pkg.sources with the key as the module name and the value as the contents of the file.


LocalPackage.loadDescriptor(callback)

LocalPackage.loadDescriptor() uses ender-repository to locate the package descriptor file for the given package and then return it modfied for use by Ender. The callback will signal whether an error has occured, and otherwise, the descriptor can be accessed as pkg.descriptor.

Given a standard package descriptor file, the following keys will be replaced if they exist in either the "ender" subkey, or the "overlay"->"ender" sub-subkey:

  • "name"
  • "main"
  • "bridge"
  • "files"
  • "dependencies"
  • "devDependencies"
  • "bare"

This allows package owners to provide packages that differ when used in Node and in Ender.

For example, given a package.json:

{
  "name": "foo",
  "main": "foo.js",
  "ender": {
    "main": "bar.js",
    "bridge": "ender.js"
  }
}

You will actually end up with a structure that looks like this, once processed:

{
  "name": "foo",
  "main": "bar.js",
  "bridge": "ender.js"
}

The original, unmolested, deserialized descriptor is available on the prototype, e.g.:

var original = Object.getPrototypeOf(pkg.descriptor)

LocalPackage.loadSources(callback)

LocalPackage.loadSources() causes all of the package source files to be loaded. The callback will signal whether an error has occured. The source files will be available as pkg.sources with the key as the module name and the value as the contents of the file. This method will also set the pkg.main and pkg.bridge properties with the path to those modules if they were found and loaded.


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 Package Util 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 Package Util 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.