Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execFileSync } from 'node:child_process'
import { basename, extname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { ofetch } from 'ofetch'
import semver from 'semver'
import { compare, findMinimumForRange, isGreaterThanOrEqual, normalizeRange, satisfies } from 'verkit'
import type { Packument } from '@npm/types'

export const rootDir = fileURLToPath(new URL('..', import.meta.url))
Expand Down Expand Up @@ -105,12 +105,12 @@ export async function getMajorVersions(npmPackage: string): Promise<string[]> {
const current = majorVersionMap.get(major)

// Keep the highest version for each major
if (!current || semver.compare(version, current) > 0) {
if (!current || compare(version, current) > 0) {
majorVersionMap.set(major, version)
}
}

return Array.from(majorVersionMap.values()).sort((a, b) => semver.compare(b, a))
return Array.from(majorVersionMap.values()).sort((a, b) => compare(b, a))
}

export function uniq<T>(items: T[]) {
Expand All @@ -132,7 +132,7 @@ function parseRangeComponent(range: string): ParsedRange | null {
const trimmed = range.trim()

// Check if it's a valid semver range first
if (!semver.validRange(trimmed)) {
if (!normalizeRange(trimmed)) {
return null
}

Expand Down Expand Up @@ -195,15 +195,15 @@ function parseRangeComponent(range: string): ParsedRange | null {
}

// Complex range - we can still get minVersion from it
const minVersion = semver.minVersion(trimmed)
const minVersion = findMinimumForRange(trimmed)
if (minVersion) {
return {
original: trimmed,
type: 'complex',
major: minVersion.major,
minor: minVersion.minor,
patch: minVersion.patch,
prerelease: minVersion.prerelease.length > 0 ? minVersion.prerelease.join('.') : null,
prerelease: minVersion.prerelease?.length ? minVersion.prerelease.join('.') : null,
hasUpperBound: true, // Assume complex ranges have upper bounds
}
}
Expand All @@ -218,9 +218,9 @@ function parseRangeComponent(range: string): ParsedRange | null {
function isRangeCoveredBy(a: ParsedRange, b: ParsedRange): boolean {
// An open-ended >= range covers another range if its minimum is <= the other's minimum
if (b.type === 'gte' && !b.hasUpperBound) {
const aMin = semver.minVersion(a.original)
const bMin = semver.minVersion(b.original)
if (aMin && bMin && semver.gte(aMin, bMin)) {
const aMin = findMinimumForRange(a.original)
const bMin = findMinimumForRange(b.original)
if (aMin && bMin && isGreaterThanOrEqual(aMin, bMin)) {
// b starts at or before a, and b has no upper bound
// So if a has an upper bound, b covers all of a's range and more
// If a also has no upper bound, they overlap from a's min onward
Expand Down Expand Up @@ -315,7 +315,7 @@ export function mergeCompatibilityRanges(ranges: string[]): string {
if (allRangeStrings.length === 0) return ''
if (allRangeStrings.length === 1) {
// Single range - validate and return
const valid = semver.validRange(allRangeStrings[0]!)
const valid = normalizeRange(allRangeStrings[0]!)
return valid ? allRangeStrings[0]! : ''
}

Expand Down Expand Up @@ -416,7 +416,7 @@ export function isNuxt4Compatible(range: string): boolean {
if (!range) return false
try {
// Test against a Nuxt 4 version
return semver.satisfies('4.0.0', range)
return satisfies('4.0.0', range)
}
catch {
return false
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@octokit/rest": "^22.0.1",
"@types/js-yaml": "^4.0.9",
"@types/node": "^24.13.6",
"@types/semver": "^7.8.0",
"defu": "^6.1.7",
"dotenv": "^18.0.1",
"eslint": "^10.11.0",
Expand All @@ -38,9 +37,9 @@
"ofetch": "^1.5.1",
"p-limit": "^7.3.3",
"picocolors": "^1.1.1",
"semver": "^7.8.5",
"std-env": "^4.2.0",
"typescript": "^6.0.3"
"typescript": "^6.0.3",
"verkit": "^0.5.0"
},
"devEngines": {
"runtime": {
Expand Down
20 changes: 9 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading