@nuxt/cli-nightly 3.26.0-20250607-210256-59f83b1 → 3.26.0-20250607-215204-1943f84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/nuxi.mjs +1 -0
- package/dist/chunks/add.mjs +308 -290
- package/dist/chunks/add2.mjs +291 -307
- package/dist/chunks/analyze.mjs +8 -7
- package/dist/chunks/build.mjs +11 -11
- package/dist/chunks/cleanup.mjs +8 -7
- package/dist/chunks/dev-child.mjs +11 -71
- package/dist/chunks/dev.mjs +142 -117
- package/dist/chunks/devtools.mjs +3 -2
- package/dist/chunks/generate.mjs +8 -8
- package/dist/chunks/index.mjs +379 -12
- package/dist/chunks/index2.mjs +15 -0
- package/dist/chunks/info.mjs +8 -6
- package/dist/chunks/init.mjs +4 -3
- package/dist/chunks/prepare.mjs +7 -6
- package/dist/chunks/preview.mjs +6 -5
- package/dist/chunks/search.mjs +3 -2
- package/dist/chunks/test.mjs +3 -2
- package/dist/chunks/typecheck.mjs +6 -6
- package/dist/chunks/upgrade.mjs +9 -8
- package/dist/dev/index.d.mts +75 -0
- package/dist/dev/index.d.ts +75 -0
- package/dist/dev/index.mjs +21 -0
- package/dist/index.mjs +2 -1
- package/dist/shared/{cli-nightly.DTVmTXKJ.mjs → cli-nightly.B4U5vhqQ.mjs} +7 -6
- package/dist/shared/cli-nightly.B9AmABr3.mjs +5 -0
- package/dist/shared/{cli-nightly.CjK7ZDKA.mjs → cli-nightly.BgFMCBoq.mjs} +9 -10
- package/dist/shared/{cli-nightly.DlcAx0De.mjs → cli-nightly.BrKZotr9.mjs} +11 -9
- package/dist/shared/{cli-nightly.DDBHWicM.mjs → cli-nightly.Bu_9IHj2.mjs} +2 -2
- package/dist/shared/{cli-nightly.DPQxxyDx.mjs → cli-nightly.Cf9T6EbF.mjs} +1 -1
- package/dist/shared/{cli-nightly.BnfAj4iy.mjs → cli-nightly.DPmMxQ6h.mjs} +1 -1
- package/dist/shared/cli-nightly.Dc8ncNQ_.mjs +27 -0
- package/dist/shared/{cli-nightly.DdmGgrsK.mjs → cli-nightly.DkO5RR_e.mjs} +1 -1
- package/package.json +2 -1
- package/dist/chunks/dev2.mjs +0 -293
- package/dist/shared/cli-nightly.COGWopdX.mjs +0 -26
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as listhen from 'listhen';
|
|
2
|
+
import { ListenURL, HTTPSOptions, Listener, ListenOptions } from 'listhen';
|
|
3
|
+
import { NuxtConfig } from '@nuxt/schema';
|
|
4
|
+
import { DotenvOptions } from 'c12';
|
|
5
|
+
import { RequestListener, IncomingMessage, ServerResponse } from 'node:http';
|
|
6
|
+
import EventEmitter from 'node:events';
|
|
7
|
+
|
|
8
|
+
interface NuxtDevContext {
|
|
9
|
+
cwd: string;
|
|
10
|
+
public?: boolean;
|
|
11
|
+
hostname?: string;
|
|
12
|
+
publicURLs?: string[];
|
|
13
|
+
args: {
|
|
14
|
+
clear: boolean;
|
|
15
|
+
logLevel: string;
|
|
16
|
+
dotenv: string;
|
|
17
|
+
envName: string;
|
|
18
|
+
};
|
|
19
|
+
proxy?: {
|
|
20
|
+
url?: string;
|
|
21
|
+
urls?: ListenURL[];
|
|
22
|
+
https?: boolean | HTTPSOptions;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface NuxtDevServerOptions {
|
|
26
|
+
cwd: string;
|
|
27
|
+
logLevel?: 'silent' | 'info' | 'verbose';
|
|
28
|
+
dotenv: DotenvOptions;
|
|
29
|
+
envName?: string;
|
|
30
|
+
clear?: boolean;
|
|
31
|
+
defaults: NuxtConfig;
|
|
32
|
+
overrides: NuxtConfig;
|
|
33
|
+
port?: string | number;
|
|
34
|
+
loadingTemplate?: ({ loading }: {
|
|
35
|
+
loading: string;
|
|
36
|
+
}) => string;
|
|
37
|
+
devContext: NuxtDevContext;
|
|
38
|
+
}
|
|
39
|
+
declare class NuxtDevServer extends EventEmitter {
|
|
40
|
+
private options;
|
|
41
|
+
private _handler?;
|
|
42
|
+
private _distWatcher?;
|
|
43
|
+
private _currentNuxt?;
|
|
44
|
+
private _loadingMessage?;
|
|
45
|
+
private _loadingError?;
|
|
46
|
+
private cwd;
|
|
47
|
+
loadDebounced: (reload?: boolean, reason?: string) => void;
|
|
48
|
+
handler: RequestListener;
|
|
49
|
+
listener: Listener;
|
|
50
|
+
constructor(options: NuxtDevServerOptions);
|
|
51
|
+
_renderError(req: IncomingMessage, res: ServerResponse): void;
|
|
52
|
+
resolveLoadingTemplate(): Promise<(params: {
|
|
53
|
+
loading: string;
|
|
54
|
+
}) => string>;
|
|
55
|
+
_renderLoadingScreen(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
56
|
+
init(): Promise<void>;
|
|
57
|
+
load(reload?: boolean, reason?: string): Promise<void>;
|
|
58
|
+
close(): Promise<void>;
|
|
59
|
+
_load(reload?: boolean, reason?: string): Promise<void>;
|
|
60
|
+
_watchConfig(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface InitializeOptions {
|
|
64
|
+
data?: {
|
|
65
|
+
overrides?: NuxtConfig;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
declare function initialize(devContext: NuxtDevContext, ctx?: InitializeOptions, listenOptions?: Partial<ListenOptions>): Promise<{
|
|
69
|
+
listener: listhen.Listener;
|
|
70
|
+
close: () => Promise<void>;
|
|
71
|
+
onReady: (callback: (port: number) => void) => void;
|
|
72
|
+
onRestart: (callback: (devServer: NuxtDevServer) => void) => void;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
export { initialize };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { i as initialize } from '../chunks/index.mjs';
|
|
2
|
+
import 'node:process';
|
|
3
|
+
import 'defu';
|
|
4
|
+
import 'node:events';
|
|
5
|
+
import 'chokidar';
|
|
6
|
+
import 'h3';
|
|
7
|
+
import 'listhen';
|
|
8
|
+
import 'pathe';
|
|
9
|
+
import 'perfect-debounce';
|
|
10
|
+
import 'std-env';
|
|
11
|
+
import 'ufo';
|
|
12
|
+
import '../shared/cli-nightly.DPmMxQ6h.mjs';
|
|
13
|
+
import 'node:fs';
|
|
14
|
+
import '../shared/cli-nightly.B9AmABr3.mjs';
|
|
15
|
+
import 'consola';
|
|
16
|
+
import '../shared/cli-nightly.BrKZotr9.mjs';
|
|
17
|
+
import 'node:url';
|
|
18
|
+
import 'exsolve';
|
|
19
|
+
import '../shared/cli-nightly.Bu_9IHj2.mjs';
|
|
20
|
+
import 'ohash';
|
|
21
|
+
import 'youch';
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { m as main, r as runCommand,
|
|
1
|
+
export { m as main, r as runCommand, g as runMain } from './shared/cli-nightly.BgFMCBoq.mjs';
|
|
2
2
|
import 'node:path';
|
|
3
3
|
import 'node:process';
|
|
4
4
|
import 'citty';
|
|
5
5
|
import 'std-env';
|
|
6
6
|
import 'consola';
|
|
7
|
+
import './shared/cli-nightly.B9AmABr3.mjs';
|
|
7
8
|
import 'node:url';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { defineCommand, runCommand as runCommand$1 } from 'citty';
|
|
4
|
-
import {
|
|
4
|
+
import { b as commands, c as cwdArgs, s as setupGlobalConsole, f as checkEngines } from './cli-nightly.BgFMCBoq.mjs';
|
|
5
5
|
import nodeCrypto from 'node:crypto';
|
|
6
6
|
import { resolve } from 'node:path';
|
|
7
7
|
import { provider } from 'std-env';
|
|
8
|
-
import { d as description, v as version, n as name } from './cli-nightly.
|
|
8
|
+
import { d as description, v as version, n as name } from './cli-nightly.Cf9T6EbF.mjs';
|
|
9
|
+
import { l as logger } from './cli-nightly.B9AmABr3.mjs';
|
|
9
10
|
|
|
10
11
|
if (!globalThis.crypto) {
|
|
11
12
|
globalThis.crypto = nodeCrypto;
|
|
@@ -60,10 +61,10 @@ globalThis.__nuxt_cli__ = globalThis.__nuxt_cli__ || {
|
|
|
60
61
|
// Programmatic usage fallback
|
|
61
62
|
startTime: Date.now(),
|
|
62
63
|
entry: fileURLToPath(
|
|
63
|
-
new URL(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
64
|
+
new URL("../../bin/nuxi.mjs", import.meta.url)
|
|
65
|
+
),
|
|
66
|
+
devEntry: fileURLToPath(
|
|
67
|
+
new URL("../dev/index.mjs", import.meta.url)
|
|
67
68
|
)
|
|
68
69
|
};
|
|
69
70
|
async function runCommand(name, argv = process.argv.slice(2), data = {}) {
|
|
@@ -3,11 +3,12 @@ import process from 'node:process';
|
|
|
3
3
|
import { defineCommand, runMain as runMain$1, runCommand as runCommand$1 } from 'citty';
|
|
4
4
|
import { provider } from 'std-env';
|
|
5
5
|
import { consola } from 'consola';
|
|
6
|
+
import { l as logger } from './cli-nightly.B9AmABr3.mjs';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
7
8
|
|
|
8
9
|
const _rDefault = (r) => r.default || r;
|
|
9
10
|
const commands = {
|
|
10
|
-
add: () => import('../chunks/
|
|
11
|
+
add: () => import('../chunks/add2.mjs').then(_rDefault),
|
|
11
12
|
analyze: () => import('../chunks/analyze.mjs').then(_rDefault),
|
|
12
13
|
build: () => import('../chunks/build.mjs').then(_rDefault),
|
|
13
14
|
cleanup: () => import('../chunks/cleanup.mjs').then(_rDefault),
|
|
@@ -17,7 +18,7 @@ const commands = {
|
|
|
17
18
|
generate: () => import('../chunks/generate.mjs').then(_rDefault),
|
|
18
19
|
info: () => import('../chunks/info.mjs').then(_rDefault),
|
|
19
20
|
init: () => import('../chunks/init.mjs').then(_rDefault),
|
|
20
|
-
module: () => import('../chunks/
|
|
21
|
+
module: () => import('../chunks/index2.mjs').then(_rDefault),
|
|
21
22
|
prepare: () => import('../chunks/prepare.mjs').then(_rDefault),
|
|
22
23
|
preview: () => import('../chunks/preview.mjs').then(_rDefault),
|
|
23
24
|
start: () => import('../chunks/preview.mjs').then(_rDefault),
|
|
@@ -105,8 +106,6 @@ function setupGlobalConsole(opts = {}) {
|
|
|
105
106
|
process.on("uncaughtException", (err) => consola.error("[uncaughtException]", err));
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
const logger = consola.withTag("nuxi");
|
|
109
|
-
|
|
110
109
|
async function checkEngines() {
|
|
111
110
|
const satisfies = await import('semver/functions/satisfies.js').then(
|
|
112
111
|
(r) => r.default || r
|
|
@@ -122,7 +121,7 @@ async function checkEngines() {
|
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
const name = "@nuxt/cli-nightly";
|
|
125
|
-
const version = "3.26.0-20250607-
|
|
124
|
+
const version = "3.26.0-20250607-215204-1943f84";
|
|
126
125
|
const description = "Nuxt CLI";
|
|
127
126
|
|
|
128
127
|
const main = defineCommand({
|
|
@@ -174,10 +173,10 @@ globalThis.__nuxt_cli__ = globalThis.__nuxt_cli__ || {
|
|
|
174
173
|
// Programmatic usage fallback
|
|
175
174
|
startTime: Date.now(),
|
|
176
175
|
entry: fileURLToPath(
|
|
177
|
-
new URL(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
)
|
|
176
|
+
new URL("../../bin/nuxi.mjs", import.meta.url)
|
|
177
|
+
),
|
|
178
|
+
devEntry: fileURLToPath(
|
|
179
|
+
new URL("../dev/index.mjs", import.meta.url)
|
|
181
180
|
)
|
|
182
181
|
};
|
|
183
182
|
const runMain = () => runMain$1(main);
|
|
@@ -194,4 +193,4 @@ async function runCommand(name, argv = process.argv.slice(2), data = {}) {
|
|
|
194
193
|
});
|
|
195
194
|
}
|
|
196
195
|
|
|
197
|
-
export {
|
|
196
|
+
export { logLevelArgs as a, commands as b, cwdArgs as c, dotEnvArgs as d, envNameArgs as e, checkEngines as f, runMain as g, legacyRootDirArgs as l, main as m, runCommand as r, setupGlobalConsole as s };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
2
|
+
import { resolveModulePath } from 'exsolve';
|
|
2
3
|
|
|
3
4
|
async function loadKit(rootDir) {
|
|
4
|
-
const jiti = createJiti(rootDir);
|
|
5
5
|
try {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let kitPath = resolveModulePath("@nuxt/kit", { try: true, from: rootDir });
|
|
7
|
+
if (!kitPath) {
|
|
8
|
+
const nuxtPath = tryResolveNuxt(rootDir);
|
|
9
|
+
kitPath = resolveModulePath("@nuxt/kit", { from: nuxtPath || rootDir });
|
|
10
|
+
}
|
|
11
|
+
let kit = await import(pathToFileURL(kitPath).href);
|
|
9
12
|
if (!kit.writeTypes) {
|
|
10
13
|
kit = {
|
|
11
14
|
...kit,
|
|
@@ -18,16 +21,15 @@ async function loadKit(rootDir) {
|
|
|
18
21
|
} catch (e) {
|
|
19
22
|
if (e.toString().includes("Cannot find module '@nuxt/kit'")) {
|
|
20
23
|
throw new Error(
|
|
21
|
-
"nuxi requires `@nuxt/kit` to be installed in your project. Try installing `nuxt` v3 or `@nuxt/bridge` first."
|
|
24
|
+
"nuxi requires `@nuxt/kit` to be installed in your project. Try installing `nuxt` v3+ or `@nuxt/bridge` first."
|
|
22
25
|
);
|
|
23
26
|
}
|
|
24
27
|
throw e;
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
const jiti = createJiti(rootDir);
|
|
30
|
+
function tryResolveNuxt(rootDir) {
|
|
29
31
|
for (const pkg of ["nuxt-nightly", "nuxt", "nuxt3", "nuxt-edge"]) {
|
|
30
|
-
const path =
|
|
32
|
+
const path = resolveModulePath(pkg, { from: rootDir, try: true });
|
|
31
33
|
if (path) {
|
|
32
34
|
return path;
|
|
33
35
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { promises } from 'node:fs';
|
|
2
2
|
import { hash } from 'ohash';
|
|
3
3
|
import { resolve, dirname } from 'pathe';
|
|
4
|
-
import {
|
|
5
|
-
import { r as rmRecursive } from './cli-nightly.
|
|
4
|
+
import { l as logger } from './cli-nightly.B9AmABr3.mjs';
|
|
5
|
+
import { r as rmRecursive } from './cli-nightly.DPmMxQ6h.mjs';
|
|
6
6
|
|
|
7
7
|
async function cleanupNuxtDirs(rootDir, buildDir) {
|
|
8
8
|
logger.info("Cleaning up generated Nuxt files and caches...");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { colors } from 'consola/utils';
|
|
3
|
+
import { resolveModulePath } from 'exsolve';
|
|
4
|
+
import { t as tryResolveNuxt } from './cli-nightly.BrKZotr9.mjs';
|
|
5
|
+
import { l as logger } from './cli-nightly.B9AmABr3.mjs';
|
|
6
|
+
|
|
7
|
+
function showVersions(cwd) {
|
|
8
|
+
const { bold, gray, green } = colors;
|
|
9
|
+
const nuxtDir = tryResolveNuxt(cwd);
|
|
10
|
+
function getPkgVersion(pkg) {
|
|
11
|
+
for (const url of [cwd, nuxtDir]) {
|
|
12
|
+
if (!url) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const p = resolveModulePath(`${pkg}/package.json`, { from: url, try: true });
|
|
16
|
+
if (p) {
|
|
17
|
+
return JSON.parse(readFileSync(p, "utf-8")).version;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
const nuxtVersion = getPkgVersion("nuxt") || getPkgVersion("nuxt-nightly") || getPkgVersion("nuxt3") || getPkgVersion("nuxt-edge");
|
|
23
|
+
const nitroVersion = getPkgVersion("nitropack") || getPkgVersion("nitropack-nightly") || getPkgVersion("nitropack-edge");
|
|
24
|
+
logger.log(gray(green(`Nuxt ${bold(nuxtVersion)}`) + (nitroVersion ? ` with Nitro ${bold(nitroVersion)}` : "")));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { showVersions as s };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/cli-nightly",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.26.0-20250607-
|
|
4
|
+
"version": "3.26.0-20250607-215204-1943f84",
|
|
5
5
|
"description": "Nuxt CLI",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"clipboardy": "^4.0.0",
|
|
40
40
|
"consola": "^3.4.2",
|
|
41
41
|
"defu": "^6.1.4",
|
|
42
|
+
"exsolve": "^1.0.5",
|
|
42
43
|
"fuse.js": "^7.1.0",
|
|
43
44
|
"giget": "^2.0.0",
|
|
44
45
|
"h3": "^1.15.3",
|
package/dist/chunks/dev2.mjs
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
|
-
import process from 'node:process';
|
|
3
|
-
import chokidar from 'chokidar';
|
|
4
|
-
import defu from 'defu';
|
|
5
|
-
import { toNodeListener } from 'h3';
|
|
6
|
-
import { createJiti } from 'jiti';
|
|
7
|
-
import { listen } from 'listhen';
|
|
8
|
-
import { resolve, join, relative } from 'pathe';
|
|
9
|
-
import { debounce } from 'perfect-debounce';
|
|
10
|
-
import { provider } from 'std-env';
|
|
11
|
-
import { joinURL } from 'ufo';
|
|
12
|
-
import { a as clearBuildDir } from '../shared/cli-nightly.BnfAj4iy.mjs';
|
|
13
|
-
import { l as loadKit } from '../shared/cli-nightly.DlcAx0De.mjs';
|
|
14
|
-
import { a as logger } from '../shared/cli-nightly.CjK7ZDKA.mjs';
|
|
15
|
-
import { l as loadNuxtManifest, r as resolveNuxtManifest, w as writeNuxtManifest } from '../shared/cli-nightly.DDBHWicM.mjs';
|
|
16
|
-
import { Youch } from 'youch';
|
|
17
|
-
|
|
18
|
-
async function renderError(req, res, error) {
|
|
19
|
-
const youch = new Youch();
|
|
20
|
-
res.statusCode = 500;
|
|
21
|
-
res.setHeader("Content-Type", "text/html");
|
|
22
|
-
const html = await youch.toHTML(error, {
|
|
23
|
-
request: {
|
|
24
|
-
url: req.url,
|
|
25
|
-
method: req.method,
|
|
26
|
-
headers: req.headers
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
res.end(html);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function createNuxtDevServer(options, listenOptions) {
|
|
33
|
-
const devServer = new NuxtDevServer(options);
|
|
34
|
-
devServer.listener = await listen(
|
|
35
|
-
devServer.handler,
|
|
36
|
-
listenOptions || {
|
|
37
|
-
port: options.port ?? 0,
|
|
38
|
-
hostname: "127.0.0.1",
|
|
39
|
-
showURL: false
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
devServer.listener._url = devServer.listener.url;
|
|
43
|
-
if (options.devContext.proxy?.url) {
|
|
44
|
-
devServer.listener.url = options.devContext.proxy.url;
|
|
45
|
-
}
|
|
46
|
-
if (options.devContext.proxy?.urls) {
|
|
47
|
-
const _getURLs = devServer.listener.getURLs.bind(devServer.listener);
|
|
48
|
-
devServer.listener.getURLs = async () => Array.from(
|
|
49
|
-
/* @__PURE__ */ new Set([...options.devContext.proxy.urls, ...await _getURLs()])
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
return devServer;
|
|
53
|
-
}
|
|
54
|
-
const RESTART_RE = /^(?:nuxt\.config\.[a-z0-9]+|\.nuxtignore|\.nuxtrc|\.config\/nuxt(?:\.config)?\.[a-z0-9]+)$/;
|
|
55
|
-
class NuxtDevServer extends EventEmitter {
|
|
56
|
-
constructor(options) {
|
|
57
|
-
super();
|
|
58
|
-
this.options = options;
|
|
59
|
-
this.loadDebounced = debounce(this.load);
|
|
60
|
-
let _initResolve;
|
|
61
|
-
const _initPromise = new Promise((resolve2) => {
|
|
62
|
-
_initResolve = resolve2;
|
|
63
|
-
});
|
|
64
|
-
this.once("ready", () => {
|
|
65
|
-
_initResolve();
|
|
66
|
-
});
|
|
67
|
-
this._jiti = createJiti(options.cwd);
|
|
68
|
-
this.handler = async (req, res) => {
|
|
69
|
-
if (this._loadingError) {
|
|
70
|
-
this._renderError(req, res);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
await _initPromise;
|
|
74
|
-
if (this._handler) {
|
|
75
|
-
this._handler(req, res);
|
|
76
|
-
} else {
|
|
77
|
-
this._renderLoadingScreen(req, res);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
this.listener = void 0;
|
|
81
|
-
}
|
|
82
|
-
_handler;
|
|
83
|
-
_distWatcher;
|
|
84
|
-
_currentNuxt;
|
|
85
|
-
_loadingMessage;
|
|
86
|
-
_jiti;
|
|
87
|
-
_loadingError;
|
|
88
|
-
loadDebounced;
|
|
89
|
-
handler;
|
|
90
|
-
listener;
|
|
91
|
-
_renderError(req, res) {
|
|
92
|
-
renderError(req, res, this._loadingError);
|
|
93
|
-
}
|
|
94
|
-
async _renderLoadingScreen(req, res) {
|
|
95
|
-
res.statusCode = 503;
|
|
96
|
-
res.setHeader("Content-Type", "text/html");
|
|
97
|
-
const loadingTemplate = this.options.loadingTemplate || this._currentNuxt?.options.devServer.loadingTemplate || await this._jiti.import("@nuxt/ui-templates").then((r) => r.loading).catch(() => {
|
|
98
|
-
}) || ((params) => `<h2>${params.loading}</h2>`);
|
|
99
|
-
res.end(
|
|
100
|
-
loadingTemplate({
|
|
101
|
-
loading: this._loadingMessage || "Loading..."
|
|
102
|
-
})
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
async init() {
|
|
106
|
-
await this.load();
|
|
107
|
-
await this._watchConfig();
|
|
108
|
-
}
|
|
109
|
-
async load(reload, reason) {
|
|
110
|
-
try {
|
|
111
|
-
await this._load(reload, reason);
|
|
112
|
-
this._loadingError = void 0;
|
|
113
|
-
} catch (error) {
|
|
114
|
-
logger.error(`Cannot ${reload ? "restart" : "start"} nuxt: `, error);
|
|
115
|
-
this._handler = void 0;
|
|
116
|
-
this._loadingError = error;
|
|
117
|
-
this._loadingMessage = "Error while loading Nuxt. Please check console and fix errors.";
|
|
118
|
-
this.emit("loading:error", error);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async close() {
|
|
122
|
-
if (this._currentNuxt) {
|
|
123
|
-
await this._currentNuxt.close();
|
|
124
|
-
}
|
|
125
|
-
if (this._distWatcher) {
|
|
126
|
-
await this._distWatcher.close();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async _load(reload, reason) {
|
|
130
|
-
const action = reload ? "Restarting" : "Starting";
|
|
131
|
-
this._loadingMessage = `${reason ? `${reason}. ` : ""}${action} Nuxt...`;
|
|
132
|
-
this._handler = void 0;
|
|
133
|
-
this.emit("loading", this._loadingMessage);
|
|
134
|
-
if (reload) {
|
|
135
|
-
logger.info(this._loadingMessage);
|
|
136
|
-
}
|
|
137
|
-
await this.close();
|
|
138
|
-
const kit = await loadKit(this.options.cwd);
|
|
139
|
-
const devServerDefaults = _getDevServerDefaults({}, await this.listener.getURLs().then((r) => r.map((r2) => r2.url)));
|
|
140
|
-
this._currentNuxt = await kit.loadNuxt({
|
|
141
|
-
cwd: this.options.cwd,
|
|
142
|
-
dev: true,
|
|
143
|
-
ready: false,
|
|
144
|
-
envName: this.options.envName,
|
|
145
|
-
dotenv: {
|
|
146
|
-
cwd: this.options.cwd,
|
|
147
|
-
fileName: this.options.dotenv.fileName
|
|
148
|
-
},
|
|
149
|
-
defaults: defu(this.options.defaults, devServerDefaults),
|
|
150
|
-
overrides: {
|
|
151
|
-
logLevel: this.options.logLevel,
|
|
152
|
-
...this.options.overrides,
|
|
153
|
-
vite: {
|
|
154
|
-
clearScreen: this.options.clear,
|
|
155
|
-
...this.options.overrides.vite
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
if (!process.env.NUXI_DISABLE_VITE_HMR) {
|
|
160
|
-
this._currentNuxt.hooks.hook("vite:extend", ({ config }) => {
|
|
161
|
-
if (config.server) {
|
|
162
|
-
config.server.hmr = {
|
|
163
|
-
protocol: void 0,
|
|
164
|
-
...config.server.hmr,
|
|
165
|
-
port: void 0,
|
|
166
|
-
host: void 0,
|
|
167
|
-
server: this.listener.server
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
this._currentNuxt.hooks.hookOnce("close", () => {
|
|
173
|
-
this.listener.server.removeAllListeners("upgrade");
|
|
174
|
-
});
|
|
175
|
-
if (!reload) {
|
|
176
|
-
const previousManifest = await loadNuxtManifest(this._currentNuxt.options.buildDir);
|
|
177
|
-
const newManifest = resolveNuxtManifest(this._currentNuxt);
|
|
178
|
-
const promise = writeNuxtManifest(this._currentNuxt, newManifest);
|
|
179
|
-
this._currentNuxt.hooks.hookOnce("ready", async () => {
|
|
180
|
-
await promise;
|
|
181
|
-
});
|
|
182
|
-
if (previousManifest && newManifest && previousManifest._hash !== newManifest._hash) {
|
|
183
|
-
await clearBuildDir(this._currentNuxt.options.buildDir);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
await this._currentNuxt.ready();
|
|
187
|
-
const unsub = this._currentNuxt.hooks.hook("restart", async (options) => {
|
|
188
|
-
unsub();
|
|
189
|
-
if (options?.hard) {
|
|
190
|
-
this.emit("restart");
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
await this.load(true);
|
|
194
|
-
});
|
|
195
|
-
if (this._currentNuxt.server && "upgrade" in this._currentNuxt.server) {
|
|
196
|
-
this.listener.server.on(
|
|
197
|
-
"upgrade",
|
|
198
|
-
async (req, socket, head) => {
|
|
199
|
-
const nuxt = this._currentNuxt;
|
|
200
|
-
if (!nuxt)
|
|
201
|
-
return;
|
|
202
|
-
const viteHmrPath = joinURL(
|
|
203
|
-
nuxt.options.app.baseURL.startsWith("./") ? nuxt.options.app.baseURL.slice(1) : nuxt.options.app.baseURL,
|
|
204
|
-
nuxt.options.app.buildAssetsDir
|
|
205
|
-
);
|
|
206
|
-
if (req.url.startsWith(viteHmrPath)) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
await nuxt.server.upgrade(req, socket, head);
|
|
210
|
-
}
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
await this._currentNuxt.hooks.callHook("listen", this.listener.server, this.listener);
|
|
214
|
-
const addr = this.listener.address;
|
|
215
|
-
this._currentNuxt.options.devServer.host = addr.address;
|
|
216
|
-
this._currentNuxt.options.devServer.port = addr.port;
|
|
217
|
-
this._currentNuxt.options.devServer.url = _getAddressURL(addr, !!this.listener.https);
|
|
218
|
-
this._currentNuxt.options.devServer.https = this.options.devContext.proxy?.https;
|
|
219
|
-
if (this.listener.https && !process.env.NODE_TLS_REJECT_UNAUTHORIZED) {
|
|
220
|
-
logger.warn("You might need `NODE_TLS_REJECT_UNAUTHORIZED=0` environment variable to make https work.");
|
|
221
|
-
}
|
|
222
|
-
await Promise.all([
|
|
223
|
-
kit.writeTypes(this._currentNuxt).catch(console.error),
|
|
224
|
-
kit.buildNuxt(this._currentNuxt)
|
|
225
|
-
]);
|
|
226
|
-
this._distWatcher = chokidar.watch(resolve(this._currentNuxt.options.buildDir, "dist"), {
|
|
227
|
-
ignoreInitial: true,
|
|
228
|
-
depth: 0
|
|
229
|
-
});
|
|
230
|
-
this._distWatcher.on("unlinkDir", () => {
|
|
231
|
-
this.loadDebounced(true, ".nuxt/dist directory has been removed");
|
|
232
|
-
});
|
|
233
|
-
this._handler = toNodeListener(this._currentNuxt.server.app);
|
|
234
|
-
this.emit("ready", addr);
|
|
235
|
-
}
|
|
236
|
-
async _watchConfig() {
|
|
237
|
-
const configWatcher = chokidar.watch([this.options.cwd, join(this.options.cwd, ".config")], {
|
|
238
|
-
ignoreInitial: true,
|
|
239
|
-
depth: 0
|
|
240
|
-
});
|
|
241
|
-
configWatcher.on("all", (event, _file) => {
|
|
242
|
-
if (event === "all" || event === "ready" || event === "error" || event === "raw") {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
const file = relative(this.options.cwd, _file);
|
|
246
|
-
if (file === (this.options.dotenv.fileName || ".env")) {
|
|
247
|
-
this.emit("restart");
|
|
248
|
-
}
|
|
249
|
-
if (RESTART_RE.test(file)) {
|
|
250
|
-
this.loadDebounced(true, `${file} updated`);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function _getAddressURL(addr, https) {
|
|
256
|
-
const proto = https ? "https" : "http";
|
|
257
|
-
let host = addr.address.includes(":") ? `[${addr.address}]` : addr.address;
|
|
258
|
-
if (host === "[::]") {
|
|
259
|
-
host = "localhost";
|
|
260
|
-
}
|
|
261
|
-
const port = addr.port || 3e3;
|
|
262
|
-
return `${proto}://${host}:${port}/`;
|
|
263
|
-
}
|
|
264
|
-
function _getDevServerOverrides(listenOptions) {
|
|
265
|
-
if (listenOptions.public || provider === "codesandbox") {
|
|
266
|
-
return {
|
|
267
|
-
devServer: { cors: { origin: "*" } },
|
|
268
|
-
vite: { server: { allowedHosts: true } }
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
return {};
|
|
272
|
-
}
|
|
273
|
-
function _getDevServerDefaults(listenOptions, urls = []) {
|
|
274
|
-
const defaultConfig = {};
|
|
275
|
-
if (urls) {
|
|
276
|
-
defaultConfig.vite = { server: { allowedHosts: urls.map((u) => new URL(u).hostname) } };
|
|
277
|
-
}
|
|
278
|
-
if (listenOptions.hostname) {
|
|
279
|
-
const protocol = listenOptions.https ? "https" : "http";
|
|
280
|
-
defaultConfig.devServer = { cors: { origin: [`${protocol}://${listenOptions.hostname}`, ...urls] } };
|
|
281
|
-
defaultConfig.vite = defu(defaultConfig.vite, { server: { allowedHosts: [listenOptions.hostname] } });
|
|
282
|
-
}
|
|
283
|
-
return defaultConfig;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const dev = {
|
|
287
|
-
__proto__: null,
|
|
288
|
-
_getDevServerDefaults: _getDevServerDefaults,
|
|
289
|
-
_getDevServerOverrides: _getDevServerOverrides,
|
|
290
|
-
createNuxtDevServer: createNuxtDevServer
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export { _getDevServerOverrides as _, _getDevServerDefaults as a, createNuxtDevServer as c, dev as d, renderError as r };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { colors } from 'consola/utils';
|
|
2
|
-
import { readPackageJSON } from 'pkg-types';
|
|
3
|
-
import { t as tryResolveNuxt } from './cli-nightly.DlcAx0De.mjs';
|
|
4
|
-
import { a as logger } from './cli-nightly.CjK7ZDKA.mjs';
|
|
5
|
-
|
|
6
|
-
async function showVersions(cwd) {
|
|
7
|
-
const { bold, gray, green } = colors;
|
|
8
|
-
const nuxtDir = await tryResolveNuxt(cwd);
|
|
9
|
-
async function getPkgVersion(pkg) {
|
|
10
|
-
for (const url of [cwd, nuxtDir]) {
|
|
11
|
-
if (!url) {
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
const p = await readPackageJSON(pkg, { url }).catch(() => null);
|
|
15
|
-
if (p) {
|
|
16
|
-
return p.version;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
|
-
const nuxtVersion = await getPkgVersion("nuxt") || await getPkgVersion("nuxt-nightly") || await getPkgVersion("nuxt3") || await getPkgVersion("nuxt-edge");
|
|
22
|
-
const nitroVersion = await getPkgVersion("nitropack") || await getPkgVersion("nitropack-nightly") || await getPkgVersion("nitropack-edge");
|
|
23
|
-
logger.log(gray(green(`Nuxt ${bold(nuxtVersion)}`) + (nitroVersion ? ` with Nitro ${bold(nitroVersion)}` : "")));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { showVersions as s };
|