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

abstract-npm-registry

v0.0.1

Published

An open and extendible test suite for you can use to test various functional areas of an npm registry.

Downloads

5

Readme

abstract-npm-registry

An open and extendible test suite for you can use to test various functional areas of an npm registry.

Motivation

Understanding the wire protocol expected by the npm CLI is incredibly important. Without a thorough, accurate, and open representation of this HTTP-based API a number of important scenarios to the success of the Node.js ecosystem are largely impossible and definitely improbable:

  • Interoperability between registries (e.g. migrating between two private registries).
  • Evaluation of local developer solutions (e.g. "Should I use sinopia or local-npm?").
  • More sophisticated developer tooling built on top of npm (e.g. a remote npm post-publish hook similar to a git post-commit hook).

This project is an attempt to document the public npm wire protocol for these reasons and more by creating an open and extendible test suite for anyone to use and contribute to. It pulls data from multiple sources:

  1. npm/npm-registry-couchapp: technically "deprecated", but largely the most accurate representation of the the public npm API.
  2. npm/npm-registry-client: all references to url.resolve represent one or more routes that Client instances consume when used by the npm CLI.
  3. npm/newwww and npm/public-api: a loosely coupled set of internal APIs that have added to the original API exposed in npm/npm-registry-couchapp.

Status & Completeness

The goal of this project is to have 100% coverage over all routes and important usage scenarios (e.g. attempting to publish a package that is not yours). We cannot do this without YOUR HELP!

  • [x] pkg/show
  • [x] ping
  • [ ] whoami (partial)
  • [ ] pkg/dist-tag (partial)
  • [ ] pkg/fetch
  • [ ] publish
  • [ ] unpublish
  • [ ] user/add
  • [ ] user/logout
  • [ ] pkg/update
  • [ ] team
  • [ ] access
  • [ ] views/all
  • [ ] views/query

Usage

abstract-npm-registry uses mocha and assume for test execution and assertion. Most common configurations can be accomplished by using the micro-runner provided by abstract-npm-registry.

const abstractNpmRegistry = require('abstract-npm-registry');

//
// Runs the entire suite of tests
//
abstractNpmRegistry({
  registry: 'https://registry.npmjs.org',
  headers: {
    'X-ANY-HEADER-YOU-WANT': true
  },
  //
  // By default all of these suites are
  // included.
  //
  suites: [
    'publish',
    'unpublish'
  ]
});

n.b. By default all test suites are included

  suites: [
    'pkg/show',
    'pkg/fetch',
    'publish',
    'unpublish',
    'pkg/dist-tag',
    'user/add',
    'user/logout',
    'pkg/update',
    'ping',
    'whoami',
    'team',
    'access',
    'views/all',
    'views/query'
  ]

Want more options or more granular options? Use abstract-npm-registry with mocha directly (see below) or open an issue!.

Using with mocha directly

Each named export on any requireable "suite" exposed by abstract-npm-registry is simply a function that returns an it function. The returned function can be passed to it in any mocha suite. e.g.

my.custom.test.js

const abstractNpmRegistry = require('../')({
  registry: 'https://registry.npmjs.org',
  headers: { 'X-ANY-HEADER-YOU-WANT': true }
});

console.log('\n\n> Starting my custom test suite using mocha...');

describe('My super custom test suite', function () {
  abstractNpmRegistry.it('pkg/dist-tag.add');
  abstractNpmRegistry.it('pkg/dist-tag.list');
  abstractNpmRegistry.it('pkg/dist-tag.remove');

  abstractNpmRegistry.it('pkg/fetch.found');
  abstractNpmRegistry.it('pkg/fetch.noVersion');
  abstractNpmRegistry.it('pkg/fetch.noPackage');
});
LICENSE: MIT
AUTHOR: Charlie Robbins