Semver icon

Semver

Semantic Versioning utilities for version management

Overview

This node provides utilities for working with semantic versioning (SemVer) strings. It supports parsing, validating, comparing, incrementing, cleaning, coercing, sorting, and range operations on version strings following the SemVer specification.

Common scenarios where this node is beneficial include:

  • Validating if a version string conforms to SemVer.
  • Extracting components like major, minor, patch, or prerelease from a version.
  • Comparing two versions to determine ordering or equality.
  • Incrementing versions according to release types (major, minor, patch, prerelease).
  • Checking if a version satisfies a given range or if ranges intersect.
  • Cleaning or coercing non-standard version strings into valid SemVer format.
  • Sorting lists of versions in ascending or descending order.

Practical examples:

  • Automatically bumping the patch version after a successful build.
  • Filtering package versions that satisfy a specific version range.
  • Validating user input for version fields in deployment pipelines.
  • Parsing version strings to extract major/minor numbers for conditional logic.

Properties

Name Meaning
Version The version string to process (e.g., "1.2.3").
Options Collection of options affecting parsing behavior:
- Loose Whether to use loose parsing for version strings (boolean).
- Include Prerelease Whether to include prerelease versions in range matching (boolean).
- RTL (Right to Left) Whether to coerce version strings right to left (boolean). Only for coercion.

Output

The output JSON contains the original input data merged with a result object describing the outcome of the operation performed. The structure of result depends on the specific parsing operation:

For the Parsing - Minor operation specifically:

  • operation: "minor"
  • version: The input version string.
  • result: The minor version number extracted as an integer, or null if invalid.

Example output JSON snippet for minor parsing:

{
  "operation": "minor",
  "version": "1.2.3",
  "result": 2
}

In general, the result field varies by operation but typically includes:

  • Boolean flags (e.g., validity).
  • Parsed version components (major, minor, patch, prerelease, build).
  • Comparison results (true/false or numeric).
  • Cleaned or coerced version strings.
  • Lists of versions or comparators.

No binary data output is produced by this node.

Dependencies

  • Uses the external semver library for all semantic versioning operations.
  • No external API calls or services are required.
  • No special environment variables or credentials needed.

Troubleshooting

  • Invalid version strings: If the input version string is malformed or not SemVer compliant, parsing operations may return null or throw errors. Use the "Loose" option to allow more permissive parsing.
  • Empty or missing inputs: Ensure the "Version" property is provided and correctly formatted.
  • Unsupported resource or operation: The node throws an error if an unknown resource or operation is specified.
  • Range operations require valid range strings: Invalid range expressions will cause errors or null results.
  • Continue On Fail: If enabled, errors per item will be returned in the output JSON under an error field instead of stopping execution.

Links and References

Discussion