Semver icon

Semver

Semantic Versioning utilities for version management

Overview

This node provides semantic versioning (semver) utilities, allowing users to perform various operations on version strings following the semver specification. Specifically, for the Comparison resource with the Less Than or Equal operation, it compares two version strings and determines if the first version is less than or equal to the second version.

Common scenarios where this node is beneficial include:

  • Automating deployment pipelines by checking if a software version meets certain criteria.
  • Validating version constraints before upgrading dependencies.
  • Comparing software versions in CI/CD workflows to decide conditional steps.

For example, you can use this node to check if version "1.2.3" is less than or equal to "1.2.4", which would return true.

Properties

Name Meaning
Version 1 The first version string to compare (e.g., "1.2.3").
Version 2 The second version string to compare (e.g., "1.2.4").
Options Collection of options affecting comparison 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): Not applicable for this resource-operation combination.

Output

The output JSON contains the following structure:

{
  "operation": "lte",
  "version1": "1.2.3",
  "version2": "1.2.4",
  "result": true
}
  • operation: The performed operation, here always "lte" (less than or equal).
  • version1: The first input version string.
  • version2: The second input version string.
  • result: A boolean indicating whether version1 is less than or equal to version2.

No binary data output is produced by this node.

Dependencies

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

Troubleshooting

  • Invalid version strings: If either version string is not a valid semver format, the comparison may fail or throw an error. Ensure inputs conform to semantic versioning standards.
  • Loose parsing option: Enabling the "Loose" option allows more permissive parsing but might lead to unexpected results if version strings are malformed.
  • Prerelease handling: By default, prerelease versions are excluded from some comparisons unless "Include Prerelease" is enabled.
  • Error messages: Errors typically indicate invalid input versions or unknown resources/operations. Verify that the resource is set to "comparison" and operation to "lte".

Links and References

Discussion