Semver icon

Semver

Semantic Versioning utilities for version management

Overview

This node provides utilities for working with semantic versioning (semver) ranges. Specifically, the "Range" resource with the "Subset" operation checks if one semver range is a subset of another. This means it determines whether all versions allowed by the first range are also allowed by the second range.

Common scenarios include:

  • Validating dependency constraints in software projects.
  • Ensuring compatibility between different package version requirements.
  • Automating version checks in CI/CD pipelines to enforce stricter or compatible version ranges.

For example, you might want to check if the range ^1.2.0 is a subset of ^1.3.0, which would return false because ^1.2.0 includes versions less than 1.3.0.

Properties

Name Meaning
Range 1 The first semver range string to test as a potential subset (e.g., ^1.2.0).
Range 2 The second semver range string to test against (e.g., ^1.3.0).
Options Additional options affecting parsing and comparison:
- Loose: Whether to use loose parsing for version strings (boolean).
- Include Prerelease: Whether to include prerelease versions in range matching (boolean).

Output

The output JSON contains the following structure:

{
  "operation": "subset",
  "range1": "<first range string>",
  "range2": "<second range string>",
  "result": <boolean>
}
  • result: A boolean indicating whether range1 is a subset of range2.
  • The output is paired with the input item that triggered the execution.

No binary data is produced by this node.

Dependencies

  • This node depends on the external semver library for semantic version parsing and comparison.
  • No external API keys or services are required.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Invalid Range Strings: If either range1 or range2 is not a valid semver range, the node may throw an error or return unexpected results. Ensure inputs conform to semver range syntax.
  • Loose Parsing Option: Enabling "Loose" parsing can allow non-standard version strings but may lead to ambiguous results.
  • Prerelease Inclusion: If your ranges involve prerelease versions, ensure "Include Prerelease" is set accordingly; otherwise, the subset check might ignore these versions.
  • Error Handling: If the node encounters an error and "Continue On Fail" is enabled, it will output an error message in the result field instead of stopping execution.

Links and References

Discussion