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

semantic-release-npm-deprecate-old-versions

v1.3.4

Published

A plugin for semantic-release, to automatically deprecate old versions on npm, based on a custom configuration

Downloads

320

Readme

npm versionMaintainability Test Coverage

Installation and usage

  • Install with: npm install semantic-release-npm-deprecate-old-versions --save-dev
  • Set the environment variable NPM_TOKEN (same config than @semantic-release/npm)
  • Update your releaserc configuration file

Configuration

{
  "plugins": [
    "@semantic-release/npm", 
    "semantic-release-npm-deprecate-old-versions"
  ]
}

Equivalent to:

{
  "plugins": [
    "@semantic-release/npm", 
    ["semantic-release-npm-deprecate-old-versions", {
      "rules": [
        "supportLatest",
        "supportPreReleaseIfNotReleased",
        "deprecateAll"
      ]
    }]
  ]
}

Equivalent to:

{
  "plugins": [
    "@semantic-release/npm", 
    ["semantic-release-npm-deprecate-old-versions", {
      "rules": [
        { 
          "rule": "supportLatest", 
          "options": {
            "numberOfMajorReleases": 1,
            "numberOfMinorReleases": 1,
            "numberOfPatchReleases": 1
          }
        },
        { 
          "rule": "supportPreReleaseIfNotReleased", 
          "options": {
            "numberOfPreReleases": 1,
          }
        },
        "deprecateAll"
      ]
    }]
  ]
}

Extend rules

If you have a javascript configuration file for releases, you can pass a function in the array:

module.exports = {
    "plugins": [
    "@semantic-release/npm", 
    ["semantic-release-npm-deprecate-old-versions", {
      "rules": [
        customSupportFunction,
        "deprecateAll"
      ]
    }]
  ]
};

/**
 * @param {import('semver').SemVer} version
 * @param {Array<import('semver').SemVer>} allVersionsSortedLatestFirst
 * @returns {import('semantic-release-npm-deprecate-old-versions/rule').RuleResult}
 */
function customSupportFunction(version, allVersionsSortedLatestFirst){
  if (version.major === 4){
    // This version cannot be deprecated by other rules
    return { action: 'support' }
  }

  if (version.major === 3){
    // This version will be deprecated, and other rules
    // will not be applied
    return {
      action: 'deprecate',
      reason: 'Because the new version is awesome'
    }
  }

  // Let other rules decide
  return { action: 'continue' }
}

Supported vs deprecated versions

This plugin considers that either a version is supported, or it is deprecated.

Every rule computes a status on each version. Rules are applied in order, they have 3 possible outputs:

  • continue: the rule does not enforce the status of the given version, it is left to the next rules to decide the status
  • deprecate: the rule declares that the given version is deprecated, no further rule will be able to change this status
  • support: the rule declares that the given version is supported, as a consequence, no further rule will be able to change its status

Available rules and options

support-latest

This rule allows to declare a certain number of releases as supported. This rule does not apply to pre-releases.

Options

Configuration format

{
  numberOfMajorReleases?: number | "all",
  numberOfMinorReleases?: number | "all",
  numberOfPatchReleases?: number | "all"
}

All these options are optional. If a value is not set, the default value will apply

{
  "numberOfMajorReleases": 1,
  "numberOfMinorReleases": 1,
  "numberOfPatchReleases": 1
}

Examples

Use a number to configure the number of supported values

options: numberOfMajorReleases=2

| 2.0.1 |2.0.0 | 1.0.2 | 1.0.1 | 1.0.0 | | :------------ | :--------: | :--------: | :--------: | ---------: | | support | continue | support| continue | continue |

continue means that the status of a version is not fixed by this rule

Specify that all versions will be supported

options:

  • numberOfMajorReleases=1
  • numberOfMinorReleases="all"

| 2.2.0 |2.1.0 | 2.0.1 | 2.0.0 | 1.0.0 | | :------------ | :--------: | :--------: | :--------: | ---------: | | support | support | support| continue | continue |

continue means that the status of a version is not fixed by this rule

support-prerelease-if-not-released

This rule allows to declare a certain number of pre-releases as supported. This rule only applies to pre-releases.

Options

Configuration format

{
  numberOfPreReleases: number | "all",
}

Default configuration option

{
  "numberOfPreReleases": 1,
}

Examples

options: numberOfPreReleases=2

| 3.0.0-alpha.2 | 3.0.0-alpha.1 | 3.0.0-alpha.0 | 2.0.0 | 2.0.0-alpha.0 | | :------------ | :-------------: | :-------------: | :------: | -----------------: | | support | support | continue | continue | continue |


options: numberOfPreReleases=2

| 2.0.0 | 2.0.0-alpha.0 | | :----- | -----------------: | | continue | continue |

continue means that the status of a version is not fixed by this rule

In this example the version 2.0.0-alpha.0 is not marked as supported because the version 2.0.0 has been released.

deprecate-all

This rule deprecate all remaining versions (not previously marked as supported).

It is meant to be used at the end of rules declaration.

Options

This rule does not have any option

Examples

options: numberOfPreReleases=2

| 2.0.0 | 1.0.0 | | :------------ | ----------------: | | deprecate | deprecate |