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

@fnet/npm-list-versions

v0.1.34

Published

This project provides a simple utility to retrieve and manage the version history of a specified npm package. It allows users to efficiently view all versions of a package available on the npm repository, and provides options for grouping these versions b

Downloads

139

Readme

@fnet/npm-list-versions

This project provides a simple utility to retrieve and manage the version history of a specified npm package. It allows users to efficiently view all versions of a package available on the npm repository, and provides options for grouping these versions based on major, minor, or patch-level changes.

How It Works

The tool fetches the version list of a specified npm package directly from the npm registry using the npm view command. The results are then processed to provide a neat, reverse-sorted list of all available versions. If required, the versions can also be grouped by major, minor, or patch releases to better analyze the release pattern.

Key Features

  • Version Retrieval: Accesses the full list of versions for a given npm package.
  • Version Sorting: Provides versions in descending order for easy analysis.
  • Pre-release Filtering: Optionally excludes pre-release versions to focus on stable releases.
  • Version Grouping: Groups versions by major, minor, or patch increments to help users track progress at different levels of detail.

Conclusion

The @fnet/npm-list-versions utility offers a straightforward way to examine and categorize npm package versions, providing clarity and insight into the update history of any selected package. This can be especially helpful for developers seeking to understand version progression or determine compatibility with different versions.

Developer Guide for @fnet/npm-list-versions

Overview

The @fnet/npm-list-versions library is a helpful tool for developers who need to retrieve and organize version information for npm packages. This library allows you to list all available versions of a specified npm package and provides options to sort and group them by major, minor, or patch numbers. It also enables filtering out pre-release versions, providing you with a clean version history for your package management tasks.

Installation

You can install the @fnet/npm-list-versions library using either npm or yarn. Simply run one of the following commands in your terminal:

npm install @fnet/npm-list-versions

or

yarn add @fnet/npm-list-versions

Usage

Here's how you can use @fnet/npm-list-versions to fetch and organize package version information:

Basic Usage

To get a list of all stable versions of a package, you can simply call the exported index function with the package name:

import listVersions from '@fnet/npm-list-versions';

(async () => {
    try {
        const versions = await listVersions({ name: 'express' });
        console.log(versions);
    } catch (error) {
        console.error(error.message);
    }
})();

Excluding Pre-release Versions

If you want to exclude pre-release versions, ensure your call does not specify the prerelease option or sets it to false (which is the default behavior).

Grouping Versions

You can group versions by major, minor, or patch numbers by setting the corresponding options:

import listVersions from '@fnet/npm-list-versions';

(async () => {
    try {
        // Group by major version numbers
        const groupedByMajor = await listVersions({
            name: 'react',
            groupBy: { major: true }
        });
        console.log(groupedByMajor);

        // Group by minor version numbers
        const groupedByMinor = await listVersions({
            name: 'react',
            groupBy: { minor: true }
        });
        console.log(groupedByMinor);
    } catch (error) {
        console.error(error.message);
    }
})();

Examples

Retrieving All Versions

(async () => {
    try {
        const versions = await listVersions({ name: 'lodash' });
        console.log('All Stable Versions of Lodash:', versions);
    } catch (error) {
        console.error('Error:', error.message);
    }
})();

Grouping by Major Version

(async () => {
    try {
        const versions = await listVersions({
            name: 'vue',
            groupBy: { major: true }
        });
        console.log('Versions Grouped by Major:', versions);
    } catch (error) {
        console.error('Error:', error.message);
    }
})();

Acknowledgements

The @fnet/npm-list-versions library uses shelljs for executing shell commands and semver for version comparison and sorting, making it easier to handle version strings effectively.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  name:
    type: string
    description: The name of the npm package to query for versions.
  groupBy:
    type: object
    properties:
      major:
        type: boolean
        default: false
        description: Group versions by major version.
      minor:
        type: boolean
        default: false
        description: Group versions by minor version.
      patch:
        type: boolean
        default: false
        description: Group versions by patch version.
    description: Options for grouping versions.
  prerelease:
    type: boolean
    default: false
    description: Include prerelease versions in the results.
required:
  - name