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 "Valid Range" operation checks if a given version range string is valid according to semver rules. This is useful in scenarios where you need to validate user input or configuration files that specify version constraints, ensuring they conform to expected semver syntax.

Practical examples include:

  • Validating dependency version ranges in package manifests.
  • Ensuring version constraints in deployment pipelines are correctly formatted before proceeding.
  • Automating checks in CI/CD workflows to prevent invalid version ranges from causing errors downstream.

Properties

Name Meaning
Range The version range string to validate, e.g., ^1.2.0.
Options Collection of optional flags:
  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 relevant for coercion resource, not used here.

Output

The output JSON contains the following fields:

  • operation: The operation performed, here always "validRange".
  • range: The input version range string.
  • result: The validated and possibly normalized version range string if valid; otherwise, null.

Example output JSON snippet:

{
  "operation": "validRange",
  "range": "^1.2.0",
  "result": "^1.2.0"
}

If the range is invalid, result will be null.

Dependencies

  • Uses the external semver library for all semantic version parsing and validation.
  • No external API keys or services are required.
  • No special environment variables or n8n credentials needed.

Troubleshooting

  • Common issues:
    • Inputting an incorrectly formatted version range string will result in result being null.
    • Using options like "Loose" may affect parsing behavior; ensure this matches your intended strictness.
  • Error messages:
    • If an unknown resource or operation is selected, the node throws an error indicating the unknown resource.
    • If the version range string is empty or malformed, the node does not throw but returns null in result.
  • Resolution:
    • Verify the version range string format against semver specifications.
    • Use the "Loose" option if your version strings do not strictly follow semver.
    • Ensure the correct resource ("Range") and operation ("Valid Range") are selected.

Links and References

Discussion