包详细信息

semantic-release-npm-deprecate-old-versions

ghusse211ISC1.3.4

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

semantic-release, deprecate, npm, version

自述文件

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

更新日志

1.3.4 (2022-05-17)

1.3.3 (2022-05-17)

1.3.2 (2022-01-07)

Bug Fixes

  • :bug: don't quotes versions, only ignore 400 errors (#39) (638dbba)
  • :bug: don't quotes versions, only ignore 400 errors (#40) (1c14322)
  • :bug: quote the version number to deprecate to avoid errors 400 returned by npm (#36) (85a3fd7)

1.3.2-beta.3 (2022-01-07)

Bug Fixes

  • :bug: don't quotes versions, only ignore 400 errors (#40) (1c14322)

1.3.2-beta.2 (2022-01-07)

Bug Fixes

  • :bug: don't quotes versions, only ignore 400 errors (#39) (638dbba)

1.3.2-beta.1 (2022-01-07)

Bug Fixes

  • :bug: quote the version number to deprecate to avoid errors 400 returned by npm (#36) (85a3fd7)

1.3.2-alpha.1 (2022-01-07)

Bug Fixes

  • :bug: quote the version number to deprecate to avoid errors 400 returned by npm (#36) (85a3fd7)

1.3.1 (2022-01-03)

Bug Fixes

  • :bug: list all versions, including the newly published one when computing deprecations (#34) (24e3067)
  • 🐛 list all versions, including the newly published one when computing deprecations (eae29b2)

1.3.1-alpha.1 (2022-01-03)

Bug Fixes

  • :bug: list all versions, including the newly published one when computing deprecations (#34) (24e3067)

1.3.0 (2021-12-31)

Bug Fixes

  • :lock: don't write the auth token in npmrc (#31) (7669fce)

Features

  • :lock: check that authentication is correctly set up before publishing (ea0ed27)
  • :lock: check that authentication is correctly set up before publishing (#30) (883fd07)

1.3.0-alpha.3 (2021-12-31)

Bug Fixes

  • :bug: list active versions after publishing the new version (#27) (2ae2370)

1.2.3 (2021-12-31)

Bug Fixes

  • :bug: list active versions after publishing the new version (#27) (2ae2370)

1.3.0-alpha.2 (2021-12-31)

Bug Fixes

  • :lock: don't write the auth token in npmrc (#31) (7669fce)

1.3.0-alpha.1 (2021-12-31)

Features

  • :lock: check that authentication is correctly set up before publishing (#30) (883fd07)

1.2.2 (2021-12-31)

Bug Fixes

  • :bug: ignore 404s when deprecating a version (#29) (de58be1)

1.2.1 (2021-12-26)

Bug Fixes

  • :bug: ignore 404 errors when deprecating a version, because of a bug of the registry (#28) (ba95e73)

1.2.0 (2021-12-26)

Features

  • ✨ only deprecate active versions (#26) (edb317c)

1.2.0-beta.1 (2021-12-26)

Features

  • ✨ only deprecate active versions (#25) (b843758)

1.2.0-alpha.1 (2021-12-25)

Bug Fixes

  • :bug: downgrade node-fetch to fix an error related to require (#23) (804963c)
  • :bug: revert the upgrade of execa to fix an error related to require (#22) (a2f3fbe)

Features

  • :sparkles: only deprecate active versions (#20) (dbe0bc1)

1.1.7 (2021-12-22)

Bug Fixes

1.1.6 (2021-12-22)

Bug Fixes

  • ignore 422 errors and log unexpected errors when deprecating packages (#9) (e34f67b)
  • release an empty release to force upgrade (a34122d)
  • remove force on the call to deprecate (d575f49)

1.1.6 (2021-12-22)

Bug Fixes

  • ignore 422 errors and log unexpected errors when deprecating packages (#9) (e34f67b)
  • remove force on the call to deprecate (d575f49)

1.1.5 (2021-03-19)

Bug Fixes

  • correctly wait for the depreciation to finish before setting the task as completed (#6) (949f7a4)

1.1.4 (2021-03-19)

Bug Fixes

  • "invalid version range" error when deprecating versions (#5) (2b4712e)

1.1.3 (2021-03-19)

Bug Fixes

  • ignore npm errors when versions are already deprecated (#4) (f386c74)

1.1.2 (2021-01-22)

Bug Fixes

  • configuration of the supportPreReleaseIfNotReleased rule (2d0939c)
  • correctly detect configurtion for the rule supportPreReleaseIfNotReleased (1432c50)

1.1.1 (2021-01-22)

Bug Fixes

  • correctly detect configuration for the rume supportPreReleaseIfNotReleased (4593bcf)

1.1.0 (2021-01-08)

Features

  • add a configuration option to support all major/minor/patch versions (#2) (ac26b69)

1.0.1 (2020-10-23)

Bug Fixes

  • :memo: minor change to update the published README on npm (e4a9095)

1.0.0 (2020-10-23)

Bug Fixes

  • :bug: correctly set the authentication token before deprecating versions (cc5528d)
  • fix the instanciation of a service (6638b77)
  • fix warnings by removing useless methods, fix method names (65572e5)
  • remove nonsense (5c52851)

Features

  • :sparkles: support configuration (259bf6b)
  • create a new plugin and use it in the release process (78951ac)
  • depreciate versions (8b11967)
  • detect already published versions (f27e8fe)
  • detect versions to deprecate by applying rules (54ae121)
  • implement and test new rules, that can take options (fec9e9c)
  • initial release (298cc9a)

1.0.0-alpha.8 (2020-10-23)

Bug Fixes

  • fix the instanciation of a service (6638b77)

Features

  • :sparkles: support configuration (259bf6b)

1.0.0-alpha.7 (2020-10-23)

Features

  • implement and test new rules, that can take options (fec9e9c)