@nuxt/cli-nightly 3.26.0-20250607-210256-59f83b1 → 3.26.0-20250607-223602-1089c0e

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.
Files changed (36) hide show
  1. package/bin/nuxi.mjs +1 -0
  2. package/dist/chunks/add.mjs +308 -290
  3. package/dist/chunks/add2.mjs +291 -307
  4. package/dist/chunks/analyze.mjs +8 -7
  5. package/dist/chunks/build.mjs +11 -11
  6. package/dist/chunks/cleanup.mjs +8 -7
  7. package/dist/chunks/dev-child.mjs +11 -71
  8. package/dist/chunks/dev.mjs +142 -117
  9. package/dist/chunks/devtools.mjs +3 -2
  10. package/dist/chunks/generate.mjs +8 -8
  11. package/dist/chunks/index.mjs +379 -12
  12. package/dist/chunks/index2.mjs +15 -0
  13. package/dist/chunks/info.mjs +8 -6
  14. package/dist/chunks/init.mjs +7 -5
  15. package/dist/chunks/prepare.mjs +7 -6
  16. package/dist/chunks/preview.mjs +6 -5
  17. package/dist/chunks/search.mjs +3 -2
  18. package/dist/chunks/test.mjs +3 -2
  19. package/dist/chunks/typecheck.mjs +6 -6
  20. package/dist/chunks/upgrade.mjs +9 -8
  21. package/dist/dev/index.d.mts +75 -0
  22. package/dist/dev/index.d.ts +75 -0
  23. package/dist/dev/index.mjs +21 -0
  24. package/dist/index.mjs +2 -1
  25. package/dist/shared/cli-nightly.B9AmABr3.mjs +5 -0
  26. package/dist/shared/{cli-nightly.DPQxxyDx.mjs → cli-nightly.BUFTQIaz.mjs} +1 -1
  27. package/dist/shared/{cli-nightly.DlcAx0De.mjs → cli-nightly.BrKZotr9.mjs} +11 -9
  28. package/dist/shared/{cli-nightly.DDBHWicM.mjs → cli-nightly.Bu_9IHj2.mjs} +2 -2
  29. package/dist/shared/{cli-nightly.DTVmTXKJ.mjs → cli-nightly.Cq6GVhe3.mjs} +7 -6
  30. package/dist/shared/{cli-nightly.BnfAj4iy.mjs → cli-nightly.DPmMxQ6h.mjs} +1 -1
  31. package/dist/shared/{cli-nightly.CjK7ZDKA.mjs → cli-nightly.DSXVWJCf.mjs} +9 -10
  32. package/dist/shared/cli-nightly.Dc8ncNQ_.mjs +27 -0
  33. package/dist/shared/{cli-nightly.DdmGgrsK.mjs → cli-nightly.DkO5RR_e.mjs} +1 -1
  34. package/package.json +2 -1
  35. package/dist/chunks/dev2.mjs +0 -293
  36. package/dist/shared/cli-nightly.COGWopdX.mjs +0 -26
@@ -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 };