function normalizeVersions(versions) {
  const sortedVersions = versions
    .map((version) => ({ version, parsed: semver.parse(version) }))
    .filter(({ parsed }) => parsed !== null) // Remove invalid versions
    .sort((a, b) => {
      if (a.parsed && b.parsed) {
        return semver.compare(a.parsed, b.parsed)
      }
      return 0
    })
    .map(({ version }) => version)

  const versionObjects = sortedVersions.map((version, index) => ({
    version,
    isdefault: index === sortedVersions.length - 1,
  }))

  return versionObjects
}
Normalizes and validates versions using semver.
@param {string[]} versions - An array of version strings.
@returns {Array<{ version: string, isdefault: boolean }>} - A sorted array of valid version objects.