From 01edd97fb142cd2db3a440d5fff5ceb954c0abbe Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 29 Jul 2026 13:33:37 +0100 Subject: [PATCH] chore: remove unused version utils --- app/utils/versions.ts | 26 +----------- test/unit/app/utils/versions.spec.ts | 59 ---------------------------- 2 files changed, 1 insertion(+), 84 deletions(-) diff --git a/app/utils/versions.ts b/app/utils/versions.ts index 2d31c2cdc1..b848bf3442 100644 --- a/app/utils/versions.ts +++ b/app/utils/versions.ts @@ -1,20 +1,9 @@ -import { compare, isValid, normalizeRange, satisfies, tryParse } from 'verkit' +import { compare, normalizeRange, satisfies, tryParse } from 'verkit' /** * Utilities for handling npm package versions and dist-tags */ -/** - * Check if a version string is an exact semver version. - * Returns true for "1.2.3", "1.0.0-beta.1", etc. - * Returns false for ranges like "^1.2.3", ">=1.0.0", tags like "latest", etc. - * @param version - The version string to check - * @returns true if the version is an exact semver version - */ -export function isExactVersion(version: string): boolean { - return isValid(version) -} - /** Parsed semver version components */ export interface ParsedVersion { major: number @@ -121,19 +110,6 @@ export function compareVersionGroupKeys(a: string, b: string): number { return (minorB ?? -1) - (minorA ?? -1) } -/** - * Sort tags with 'latest' first, then alphabetically - * @param tags - Array of tag names - * @returns New sorted array - */ -export function sortTags(tags: string[]): string[] { - return [...tags].sort((a, b) => { - if (a === 'latest') return -1 - if (b === 'latest') return 1 - return a.localeCompare(b) - }) -} - /** * Build a map from version strings to their associated dist-tags * Handles the case where multiple tags point to the same version diff --git a/test/unit/app/utils/versions.spec.ts b/test/unit/app/utils/versions.spec.ts index 9dd6f8359a..bd06dca885 100644 --- a/test/unit/app/utils/versions.spec.ts +++ b/test/unit/app/utils/versions.spec.ts @@ -9,45 +9,10 @@ import { getPrereleaseChannel, getVersionGroupKey, getVersionGroupLabel, - isExactVersion, isSameVersionGroup, parseStableVersion, - sortTags, } from '~/utils/versions' -describe('isExactVersion', () => { - it('returns true for stable versions', () => { - expect(isExactVersion('1.0.0')).toBe(true) - expect(isExactVersion('0.1.0')).toBe(true) - expect(isExactVersion('10.20.30')).toBe(true) - }) - - it('returns true for prerelease versions', () => { - expect(isExactVersion('1.0.0-beta.1')).toBe(true) - expect(isExactVersion('1.0.0-alpha.0')).toBe(true) - expect(isExactVersion('5.8.0-rc')).toBe(true) - }) - - it('returns false for ranges', () => { - expect(isExactVersion('^1.0.0')).toBe(false) - expect(isExactVersion('~1.0.0')).toBe(false) - expect(isExactVersion('>=1.0.0')).toBe(false) - expect(isExactVersion('1.0.x')).toBe(false) - expect(isExactVersion('*')).toBe(false) - }) - - it('returns false for dist-tags', () => { - expect(isExactVersion('latest')).toBe(false) - expect(isExactVersion('next')).toBe(false) - expect(isExactVersion('beta')).toBe(false) - }) - - it('returns false for invalid strings', () => { - expect(isExactVersion('')).toBe(false) - expect(isExactVersion('not-a-version')).toBe(false) - }) -}) - describe('getPrereleaseChannel', () => { it('returns empty string for stable versions', () => { expect(getPrereleaseChannel('1.0.0')).toBe('') @@ -79,30 +44,6 @@ describe('getPrereleaseChannel', () => { }) }) -describe('sortTags', () => { - it('puts latest first', () => { - expect(sortTags(['beta', 'latest', 'alpha'])).toEqual(['latest', 'alpha', 'beta']) - }) - - it('sorts alphabetically when no latest', () => { - expect(sortTags(['beta', 'canary', 'alpha'])).toEqual(['alpha', 'beta', 'canary']) - }) - - it('handles single tag', () => { - expect(sortTags(['latest'])).toEqual(['latest']) - }) - - it('handles empty array', () => { - expect(sortTags([])).toEqual([]) - }) - - it('does not mutate original array', () => { - const original = ['beta', 'latest'] - sortTags(original) - expect(original).toEqual(['beta', 'latest']) - }) -}) - describe('buildVersionToTagsMap', () => { it('builds map from simple dist-tags', () => { const distTags = {