Semver icon

Semver

Semantic Versioning utilities for version management

Overview

This node provides utilities for working with semantic versioning (SemVer) strings. It supports parsing version components, validating versions, comparing versions, incrementing versions, cleaning and coercing version strings, handling version ranges, and sorting versions.

The Parsing - Parse operation specifically extracts detailed components from a version string, such as major, minor, patch numbers, prerelease identifiers, build metadata, and the raw version string. This is useful when you need to analyze or manipulate individual parts of a version string in workflows, for example:

  • Extracting the major version to decide deployment strategies.
  • Checking prerelease tags to handle beta or alpha releases differently.
  • Parsing version strings before comparison or validation steps.

Properties

Name Meaning
Version The semantic version string to parse, e.g., "1.2.3".
Options Collection of options affecting parsing behavior:
  Loose Whether to use loose parsing mode (allows more flexible version formats).
  Include Prerelease Whether to include prerelease versions in range matching (not applicable here).
  RTL (Right to Left) Not applicable for parsing resource; used only in coercion resource.

Output

The output JSON contains a result field with the parsed SemVer object or null if parsing fails. The parsed object includes:

  • version: The normalized version string.
  • major: Major version number (integer).
  • minor: Minor version number (integer).
  • patch: Patch version number (integer).
  • prerelease: Array of prerelease components (strings or numbers), e.g., ["beta", 1].
  • build: Array of build metadata components (strings).
  • raw: The original raw version string input.

Example output JSON snippet:

{
  "result": {
    "version": "1.2.3-beta.1+exp.sha.5114f85",
    "major": 1,
    "minor": 2,
    "patch": 3,
    "prerelease": ["beta", 1],
    "build": ["exp", "sha", "5114f85"],
    "raw": "1.2.3-beta.1+exp.sha.5114f85"
  }
}

If the version string cannot be parsed, result will be null.

Dependencies

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

Troubleshooting

  • Invalid version string: If the input version string is malformed or not compliant with SemVer, the result will be null. Ensure the version string follows semantic versioning format.
  • Loose parsing option: Enabling loose parsing allows non-strict version strings but may produce unexpected results. Use it only if necessary.
  • Empty version input: Providing an empty version string will result in no parsed output (null).

Common error messages:

  • "Unknown resource: parsing" — indicates the resource parameter is incorrect; ensure it is set to "parsing".
  • Errors related to invalid parameters usually stem from missing or malformed version strings.

Links and References

Discussion