Skip to content

Commit 8f459e3

Browse files
chore(deps): update to Nuxt v4
1 parent a21a4ed commit 8f459e3

File tree

9 files changed

+88
-164
lines changed

9 files changed

+88
-164
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"test:types": "nuxt-module-build prepare && nuxt prepare playground && vue-tsc --noEmit"
4545
},
4646
"dependencies": {
47-
"@nuxt/kit": "^3.20.1",
47+
"@nuxt/kit": "^4.2.1",
4848
"citty": "^0.1.6",
4949
"consola": "^3.4.2",
5050
"destr": "^2.0.5",
@@ -60,7 +60,7 @@
6060
"devDependencies": {
6161
"@nuxt/eslint-config": "^1.10.0",
6262
"@nuxt/module-builder": "^1.0.2",
63-
"@nuxt/schema": "^3.20.1",
63+
"@nuxt/schema": "^4.2.1",
6464
"@nuxt/test-utils": "^3.20.1",
6565
"@types/git-url-parse": "^16.0.2",
6666
"@vitest/coverage-v8": "^4.0.6",
@@ -70,7 +70,7 @@
7070
"h3": "^1.15.4",
7171
"installed-check": "^9.3.0",
7272
"knip": "^5.67.1",
73-
"nuxt": "^3.20.1",
73+
"nuxt": "^4.2.1",
7474
"typescript": "^5.9.3",
7575
"unbuild": "^3.6.1",
7676
"vitest": "^4.0.6",

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"build": "nuxt build"
66
},
77
"dependencies": {
8-
"nuxt": "^3.20.1"
8+
"nuxt": "^4.2.1"
99
}
1010
}

pnpm-lock.yaml

Lines changed: 66 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async function _checkDisabled(dir: string): Promise<string | false | undefined>
121121
const config = await loadNuxtConfig({ cwd: dir })
122122
for (const layer of config._layers) {
123123
if (disabledByConf(layer.config)) {
124-
return 'by ' + config._layers[0].configFile
124+
return 'by ' + config._layers[0]!.configFile
125125
}
126126
}
127127
}

src/context.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import os from 'node:os'
22
import { execSync } from 'node:child_process'
33
import gitUrlParse from 'git-url-parse'
4-
import { getNuxtVersion, isNuxt3 } from '@nuxt/kit'
4+
import { getNuxtVersion, isNuxtMajorVersion } from '@nuxt/kit'
55
import isDocker from 'is-docker'
66
import { provider } from 'std-env'
77
import type { Nuxt } from '@nuxt/schema'
88
import { detect } from 'package-manager-detector'
99
import type { Context, GitData, TelemetryOptions } from './types'
1010
import { hash } from './utils/hash'
1111

12+
function getNuxtMajorVersion(nuxt: Nuxt) {
13+
for (let i = 4; i >= 2; i--) {
14+
const j = i as (2 | 3 | 4)
15+
if (isNuxtMajorVersion(j, nuxt)) {
16+
return j
17+
}
18+
}
19+
return 2
20+
}
21+
1222
export async function createContext(nuxt: Nuxt, options: Required<TelemetryOptions>): Promise<Context> {
1323
const rootDir = nuxt.options.rootDir || process.cwd()
1424
const git = await getGit(rootDir)
@@ -19,7 +29,7 @@ export async function createContext(nuxt: Nuxt, options: Required<TelemetryOptio
1929
const projectSession = getProjectSession(projectHash, seed)
2030

2131
const nuxtVersion = getNuxtVersion(nuxt)
22-
const nuxtMajorVersion = isNuxt3(nuxt) ? 3 : 2
32+
const nuxtMajorVersion = getNuxtMajorVersion(nuxt)
2333
const nodeVersion = process.version.replace('v', '')
2434
const isEdge = nuxtVersion.includes('edge')
2535

@@ -54,7 +64,7 @@ function getEnv(): Context['environment'] {
5464
}
5565

5666
function getCLI() {
57-
const entry = process.argv[1]
67+
const entry = process.argv[1] ?? ''
5868

5969
const knownCLIs = {
6070
'nuxt-ts.js': 'nuxt-ts',

src/events/command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const command = <EventFactory<CommandEvent>> function ({ nuxt }) {
2020
for (const _flag in flagMap) {
2121
// TODO: remove legacy nuxt 2 flags _export and _serve
2222
const flag = _flag as Exclude<keyof typeof flagMap, '_export' | '_serve'>
23+
// @ts-expect-error no _generate?
2324
if (nuxt.options[flag]) {
2425
command = flagMap[flag]
2526
break

src/events/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const project = <EventFactory<ProjectEvent>> function (context) {
1414
name: 'project',
1515
type: (context.git && context.git.url) ? 'git' : 'local',
1616
isSSR: options.ssr !== false,
17-
target: options._generate ? 'static' : 'server',
17+
target: options.server ? 'server' : 'static',
1818
packageManager: context.packageManager,
1919
}
2020
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface Context {
1616
projectHash: string
1717
projectSession: string
1818
nuxtVersion: string
19-
nuxtMajorVersion: 2 | 3
19+
nuxtMajorVersion: 2 | 3 | 4
2020
isEdge: boolean
2121
nodeVersion: string
2222
os: string

test/e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('@nuxt/telemetry', () => {
6868
"context": {
6969
"cli": "programmatic",
7070
"isEdge": false,
71-
"nuxtMajorVersion": 3,
71+
"nuxtMajorVersion": 4,
7272
},
7373
"events": [
7474
{

0 commit comments

Comments
 (0)