function compareVersion(v1, v2) {
  // https://github.com/microsoft/winget-cli/blob/ae566c7bf21cfcc75be7ec30e4036a30eede8396/src/AppInstallerSharedLib/Versions.cpp#L109-L173
  // This implementation does not parse s_Approximate_Greater_Than
  // and s_Approximate_Less_Than since they won't appear in directory name (package version parsed by shields.io)
  const v1Trimmed = trimPrefix(v1)
  const v2Trimmed = trimPrefix(v2)

  const v1Latest = v1Trimmed.trim().toLowerCase() === 'latest'
  const v2Latest = v2Trimmed.trim().toLowerCase() === 'latest'

  if (v1Latest && v2Latest) {
    return 0
  } else if (v1Latest) {
    return 1
  } else if (v2Latest) {
    return -1
  }

  const v1Unknown = v1Trimmed.trim().toLowerCase() === 'unknown'
  const v2Unknown = v2Trimmed.trim().toLowerCase() === 'unknown'

  if (v1Unknown && v2Unknown) {
    return 0
  } else if (v1Unknown) {
    return -1
  } else if (v2Unknown) {
    return 1
  }

  const parts1 = v1Trimmed.split('.')
  const parts2 = v2Trimmed.split('.')

  trimLastZeros(parts1)
  trimLastZeros(parts2)

  for (let i = 0; i < Math.min(parts1.length, parts2.length); i++) {
    const part1 = parts1[i]
    const part2 = parts2[i]

    const compare = compareVersionPart(part1, part2)
    if (compare !== 0) {
      return compare
    }
  }

  if (parts1.length === parts2.length) {
    return 0
  }

  if (parts1.length > parts2.length) {
    return 1
  } else if (parts1.length < parts2.length) {
    return -1
  }

  return 0
}
Compares two strings representing version numbers lexicographically and returns an integer value.

@param {string} v1 - The first version to compare
@param {string} v2 - The second version to compare
@returns {number} -1 if v1 is smaller than v2, 1 if v1 is larger than v2, 0 if v1 and v2 are equal
@example
compareVersion('1.2.3', '1.2.4') // returns -1 because numeric part of first version is smaller than the numeric part of second version.