mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 22:55:13 +00:00
refactor!: rename nuxt3 to nuxt (#4449)
This commit is contained in:
parent
896d1404a3
commit
4712e99411
@ -27,13 +27,13 @@
|
||||
{
|
||||
"zones": [
|
||||
{
|
||||
"from": "packages/nuxt3/src/!(core)/**/*",
|
||||
"target": "packages/nuxt3/src/core",
|
||||
"from": "packages/nuxt/src/!(core)/**/*",
|
||||
"target": "packages/nuxt/src/core",
|
||||
"message": "core should not directly import from modules."
|
||||
},
|
||||
{
|
||||
"from": "packages/nuxt3/src/!(app)/**/*",
|
||||
"target": "packages/nuxt3/src/app",
|
||||
"from": "packages/nuxt/src/!(app)/**/*",
|
||||
"target": "packages/nuxt/src/app",
|
||||
"message": "app should not directly import from modules."
|
||||
},
|
||||
{
|
||||
|
@ -42,19 +42,19 @@ Open a terminal, or from [Visual Studio Code](https://code.visualstudio.com/), o
|
||||
::code-group
|
||||
|
||||
```bash [npx]
|
||||
npx nuxi init nuxt3-app
|
||||
npx nuxi init nuxt-app
|
||||
```
|
||||
|
||||
```bash [pnpm]
|
||||
pnpm dlx nuxi init nuxt3-app
|
||||
pnpm dlx nuxi init nuxt-app
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
Open `nuxt3-app` folder in visual studio code:
|
||||
Open `nuxt-app` folder in visual studio code:
|
||||
|
||||
```bash
|
||||
code nuxt3-app
|
||||
code nuxt-app
|
||||
```
|
||||
|
||||
Install the dependencies:
|
||||
|
@ -25,7 +25,7 @@ On top of this setup, Nuxt provides a [directory structure](/guide/directory-str
|
||||
Nuxt is composed of different [core packages](https://github.com/nuxt/framework/tree/main/packages):
|
||||
::list{type=info}
|
||||
|
||||
- Core Engine: [nuxt3](https://github.com/nuxt/framework/tree/main/packages/nuxt3)
|
||||
- Core Engine: [nuxt](https://github.com/nuxt/framework/tree/main/packages/nuxt)
|
||||
- Bundlers: [@nuxt/vite-builder](https://github.com/nuxt/framework/tree/main/packages/vite) and [@nuxt/webpack-builder](https://github.com/nuxt/framework/tree/main/packages/webpack)
|
||||
- Command line interface: [nuxi](https://github.com/nuxt/framework/tree/main/packages/nuxi)
|
||||
- Server engine: [nitro](https://github.com/unjs/nitro)
|
||||
|
@ -9,7 +9,7 @@ head.title: Nuxt configuration file
|
||||
Nuxt can be easily configured with a single `nuxt.config` file, which can have either a `.js`, `.ts` or `.mjs` extension.
|
||||
|
||||
```ts
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
// My Nuxt config
|
||||
|
@ -66,8 +66,8 @@ const MyButton = resolveComponent('MyButton')
|
||||
Alternatively, though not recommended, you can register all your components globally, which will create async chunks for all your components and make them available throughout your application.
|
||||
|
||||
```diff
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
components: {
|
||||
+ global: true,
|
||||
|
@ -14,7 +14,7 @@ Therefore only one instance of Nuxt is allowed to run per process.
|
||||
|
||||
To extend the Nuxt interface and hook into different stages of the build process, we can use [Nuxt Modules](/guide/going-further/modules).
|
||||
|
||||
For more details, check out [the source code](https://github.com/nuxt/framework/blob/main/packages/nuxt3/src/core/nuxt.ts).
|
||||
For more details, check out [the source code](https://github.com/nuxt/framework/blob/main/packages/nuxt/src/core/nuxt.ts).
|
||||
|
||||
## The NuxtApp interface
|
||||
|
||||
@ -38,7 +38,7 @@ const nuxtApp = {
|
||||
vueApp, // the global Vue application: https://vuejs.org/api/application.html#application-api
|
||||
|
||||
// These let you call and add runtime NuxtApp hooks
|
||||
// https://github.com/nuxt/framework/blob/main/packages/nuxt3/src/app/nuxt.ts#L18
|
||||
// https://github.com/nuxt/framework/blob/main/packages/nuxt/src/app/nuxt.ts#L18
|
||||
hooks,
|
||||
hook,
|
||||
callHook,
|
||||
@ -63,7 +63,7 @@ const nuxtApp = {
|
||||
}
|
||||
```
|
||||
|
||||
For more details, check out [the source code](https://github.com/nuxt/framework/blob/main/packages/nuxt3/src/app/nuxt.ts).
|
||||
For more details, check out [the source code](https://github.com/nuxt/framework/blob/main/packages/nuxt/src/app/nuxt.ts).
|
||||
|
||||
## Runtime Context vs. Build Context
|
||||
|
||||
|
@ -117,7 +117,7 @@ If you encounter these errors, the issue is almost certainly with the upstream l
|
||||
In the meantime, you can tell Nuxt not to try to import these libraries by adding them to `build.transpile`:
|
||||
|
||||
```js
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
build: {
|
||||
@ -133,7 +133,7 @@ You may find that you _also_ need to add other packages that are being imported
|
||||
In some cases, you may also need to manually alias the library to the CJS version, for example:
|
||||
|
||||
```js
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
alias: {
|
||||
|
@ -148,7 +148,7 @@ To test the modules we create, we could set up some Nuxt apps as fixtures and te
|
||||
|
||||
```ts
|
||||
// nuxt.config.js
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
import MyModule from '../../src'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
# App Hooks (runtime)
|
||||
|
||||
Check the [app source code](https://github.com/nuxt/framework/blob/main/packages/nuxt3/src/app/nuxt.ts#L18) for all available hooks.
|
||||
Check the [app source code](https://github.com/nuxt/framework/blob/main/packages/nuxt/src/app/nuxt.ts#L18) for all available hooks.
|
||||
|
||||
Hook | Arguments | Description
|
||||
-----------------------|-------------------|---------------
|
||||
|
@ -26,7 +26,7 @@ Nuxt configuration will be loaded using [`unjs/jiti`](https://github.com/unjs/ji
|
||||
```
|
||||
|
||||
```ts [Nuxt 3]
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
// ...
|
||||
@ -50,7 +50,7 @@ Nuxt configuration will be loaded using [`unjs/jiti`](https://github.com/unjs/ji
|
||||
```
|
||||
|
||||
```ts [Nuxt 3]
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
hooks: {
|
||||
|
@ -21,7 +21,7 @@ When referencing these variables within your components, you will have to use th
|
||||
::code-group
|
||||
|
||||
```ts [nuxt.config.ts]
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
runtimeConfig: {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
autoImports: {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
extends: [
|
||||
|
@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "nuxi dev",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
components: [
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
})
|
||||
|
@ -7,6 +7,6 @@
|
||||
"start": "nuxi preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
})
|
||||
|
@ -7,6 +7,6 @@
|
||||
"start": "nuxi preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
nitro: {
|
||||
|
@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "nuxi dev",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineNuxtConfig } from 'nuxt3'
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
|
@ -8,6 +8,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.0",
|
||||
"nuxt3": "latest"
|
||||
"nuxt": "npm:nuxt3@latest"
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
"resolutions": {
|
||||
"jiti": "^1.13.0",
|
||||
"nitropack-dev": "link:../nitropack",
|
||||
"nuxt3": "workspace:./packages/nuxt3",
|
||||
"nuxt": "workspace:./packages/nuxt",
|
||||
"vite": "^2.9.5",
|
||||
"unbuild": "^0.7.4"
|
||||
},
|
||||
|
@ -27,7 +27,7 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
||||
// Apply dev as config override
|
||||
opts.overrides.dev = !!opts.dev
|
||||
|
||||
const nearestNuxtPkg = await Promise.all(['nuxt3', 'nuxt-edge', 'nuxt']
|
||||
const nearestNuxtPkg = await Promise.all(['nuxt3', 'nuxt', 'nuxt-edge']
|
||||
.map(pkg => resolvePackageJSON(pkg, { url: opts.cwd }).catch(() => null)))
|
||||
.then(r => r.filter(Boolean).sort((a, b) => b.length - a.length)[0])
|
||||
if (!nearestNuxtPkg) {
|
||||
@ -38,7 +38,7 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
||||
|
||||
// Nuxt 3
|
||||
if (majorVersion === 3) {
|
||||
const { loadNuxt } = await importModule('nuxt3', resolveOpts)
|
||||
const { loadNuxt } = await importModule(pkg.name, resolveOpts)
|
||||
const nuxt = await loadNuxt(opts)
|
||||
return nuxt
|
||||
}
|
||||
@ -61,11 +61,11 @@ export async function buildNuxt (nuxt: Nuxt): Promise<any> {
|
||||
|
||||
// Nuxt 3
|
||||
if (nuxt.options._majorVersion === 3) {
|
||||
const { build } = await importModule('nuxt3', resolveOpts)
|
||||
const { build } = await tryImportModule('nuxt3', resolveOpts) || await importModule('nuxt', resolveOpts)
|
||||
return build(nuxt)
|
||||
}
|
||||
|
||||
// Nuxt 2
|
||||
const { build } = await tryImportModule('nuxt-edge', resolveOpts) || await tryImportModule('nuxt', resolveOpts)
|
||||
const { build } = await tryImportModule('nuxt-edge', resolveOpts) || await importModule('nuxt', resolveOpts)
|
||||
return build(nuxt)
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ import { getPackageManager, packageManagerLocks } from '../utils/packageManagers
|
||||
import { defineNuxtCommand } from './index'
|
||||
|
||||
async function getNuxtVersion (paths: string | string[]) {
|
||||
const pkgJson = resolveModule('nuxt3/package.json', paths)
|
||||
const pkgJson = resolveModule('nuxt/package.json', paths)
|
||||
const pkg = pkgJson && JSON.parse(await fsp.readFile(pkgJson, 'utf8'))
|
||||
if (!pkg.version) {
|
||||
consola.warn('Cannot find any installed nuxt3 versions in ', paths)
|
||||
consola.warn('Cannot find any installed nuxt versions in ', paths)
|
||||
}
|
||||
return pkg.version || '0.0.0'
|
||||
}
|
||||
@ -19,7 +19,7 @@ export default defineNuxtCommand({
|
||||
meta: {
|
||||
name: 'upgrade',
|
||||
usage: 'npx nuxi upgrade [--force|-f]',
|
||||
description: 'Upgrade nuxt3'
|
||||
description: 'Upgrade nuxt'
|
||||
},
|
||||
async invoke (args) {
|
||||
const rootDir = resolve(args._[0] || '.')
|
||||
@ -47,14 +47,14 @@ export default defineNuxtCommand({
|
||||
await Promise.all(['node_modules/.cache', resolve(rootDir, '.nuxt'), 'node_modules/.vite'].map((path) => {
|
||||
return existsSync(path) ? fsp.rm(path, { recursive: true }) : undefined
|
||||
}))
|
||||
execSync(`${packageManager} ${packageManager === 'yarn' ? 'add' : 'install'} -D nuxt3@latest`, { stdio: 'inherit' })
|
||||
execSync(`${packageManager} ${packageManager === 'yarn' ? 'add' : 'install'} -D nuxt@latest`, { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
const upgradedVersion = await getNuxtVersion(rootDir)
|
||||
consola.info('Upgraded nuxt version:', upgradedVersion)
|
||||
|
||||
if (upgradedVersion === currentVersion) {
|
||||
consola.success('You\'re already using the latest version of nuxt3.')
|
||||
consola.success('You\'re already using the latest version of nuxt.')
|
||||
} else {
|
||||
consola.success('Successfully upgraded nuxt from', currentVersion, 'to', upgradedVersion)
|
||||
const commitA = currentVersion.split('.').pop()
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "nuxt3",
|
||||
"name": "nuxt",
|
||||
"version": "3.0.0",
|
||||
"repository": "nuxt/framework",
|
||||
"license": "MIT",
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user