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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@playwright/test": "catalog:cli",
"@types/markdown-it": "catalog:types",
"@types/node": "catalog:types",
"@types/semver": "catalog:types",
"@types/which": "catalog:types",
"@types/ws": "catalog:types",
"@unocss/eslint-config": "catalog:buildtools",
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/client/composables/npm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NpmCommandOptions } from '../../src/types'
import semver from 'semver'
import { satisfies } from 'verkit'
import { computed, ref } from 'vue'
import { useNuxtApp } from '#app/nuxt'
import { rpc } from './rpc'
Expand All @@ -25,7 +25,7 @@ export function satisfyNuxtVersion(range: string) {
return computed(() => {
if (!nuxt?.value?.current)
return false
return semver.satisfies(nuxt.value.current, range)
return satisfies(nuxt.value.current, range)
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@
"pathe": "catalog:frontend",
"perfect-debounce": "catalog:frontend",
"pkg-types": "catalog:prod",
"semver": "catalog:prod",
"sirv": "catalog:prod",
"structured-clone-es": "catalog:frontend",
"tinyexec": "catalog:prod",
"tinyglobby": "catalog:prod",
"unstorage": "catalog:prod",
"verkit": "catalog:prod",
"vite-plugin-inspect": "catalog:prod",
"vite-plugin-vue-tracer": "catalog:prod",
"which": "catalog:prod",
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/src/integrations/timeline.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Import } from 'unimport'
import type { NuxtDevtoolsServerContext } from '../types'
import { resolve } from 'pathe'
import semver from 'semver'
import { isGreaterOrEqual } from 'verkit'
import { runtimeDir } from '../dirs'

const DEFINE_UPPER_RE = /^define[A-Z]/
Expand Down Expand Up @@ -37,7 +37,7 @@ export function setup({ nuxt, options }: NuxtDevtoolsServerContext) {
nuxt.hook('imports:context', (unimport) => {
const ctx = unimport.getInternalContext()

if (!ctx.version || !semver.gte(ctx.version, '3.1.0'))
if (!ctx.version || !isGreaterOrEqual(ctx.version, '3.1.0'))
throw new Error(`[Nuxt DevTools] The timeline feature requires \`unimport\` >= v3.1.0, but got \`${ctx.version || '(unknown)'}\`. Please upgrade using \`nuxi upgrade --force\`.`)

ctx.addons.push(
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/src/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { logger, useNuxt } from '@nuxt/kit'
import { getPackageInfo } from 'local-pkg'
import { fetch } from 'ofetch'
import { readPackageJSON } from 'pkg-types'
import semver from 'semver'
import { isLess } from 'verkit'

export async function getMainPackageJSON(nuxt = useNuxt()) {
return readPackageJSON(nuxt.options.rootDir)
Expand Down Expand Up @@ -32,7 +32,7 @@ export async function checkForUpdateOf(name: string, current?: string, nuxt = us
fetch,
})

const needsUpdate = !!latest && latest !== current && semver.lt(current, latest)
const needsUpdate = !!latest && latest !== current && isLess(current, latest)

return {
name,
Expand Down
26 changes: 26 additions & 0 deletions packages/devtools/test/version-comparison.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { isGreaterOrEqual, isLess, satisfies } from 'verkit'
import { describe, expect, it } from 'vitest'

describe('version comparisons', () => {
it('checks the minimum supported unimport version', () => {
expect(isGreaterOrEqual('3.1.0', '3.1.0')).toBe(true)
expect(isGreaterOrEqual('3.0.9', '3.1.0')).toBe(false)
})

it('detects stable and prerelease package updates', () => {
expect(isLess('4.0.0', '4.0.1')).toBe(true)
expect(isLess('4.0.0-alpha.1', '4.0.0')).toBe(true)
expect(isLess('4.0.1', '4.0.0')).toBe(false)
})

it('preserves default prerelease range behavior', () => {
expect(satisfies('4.0.0-alpha.7', '^4.0.0-alpha.1')).toBe(true)
expect(satisfies('4.0.0-alpha.7', '^4.0.0')).toBe(false)
})

it('rejects invalid comparison inputs', () => {
expect(() => isLess('invalid', '4.0.0')).toThrow(TypeError)
expect(() => isGreaterOrEqual('invalid', '3.1.0')).toThrow(TypeError)
expect(satisfies('invalid', '^4.0.0')).toBe(false)
})
})
26 changes: 12 additions & 14 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ minimumReleaseAgeExclude:
- vite-plugin-inspect@12.0.2
- '@devframes/hub@0.6.1'
- devframe@0.6.1
- verkit@0.1.2
resolutionMode: highest
shamefullyHoist: true
shellEmulator: true
Expand Down Expand Up @@ -172,11 +173,11 @@ catalogs:
magicast: ^0.5.3
nostics: ^1.1.4
pkg-types: ^2.3.1
semver: ^7.8.5
sirv: ^3.0.2
tinyexec: ^1.2.4
tinyglobby: ^0.2.17
unstorage: ^1.17.5
verkit: ^0.1.2
vite-plugin-inspect: ^12.0.2
vite-plugin-vue-tracer: ^1.4.0
which: ^7.0.0
Expand All @@ -186,7 +187,6 @@ catalogs:
'@types/markdown-it': ^14.1.2
'@types/markdown-it-link-attributes': ^3.0.5
'@types/node': ^26.1.1
'@types/semver': ^7.7.1
'@types/which': ^3.0.4
'@types/ws': ^8.18.1
'@unhead/schema': ^3.1.8
Expand Down
Loading