@nuxt/cli-nightly 3.29.4-20251009-171833-0915ec9 → 3.29.4-20251021-190716-bbf70fc

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 (69) hide show
  1. package/dist/_shared-C3vB2YLc.mjs +42 -0
  2. package/dist/_utils-DTrPahho.mjs +29 -0
  3. package/dist/add-BGMHIn5L.mjs +333 -0
  4. package/dist/add-CRBwIlDF.mjs +298 -0
  5. package/dist/add-hFFIzkcy.mjs +10 -0
  6. package/dist/analyze-CUKAi_IN.mjs +115 -0
  7. package/dist/banner-CqfM_0Qo.mjs +55 -0
  8. package/dist/build-BSxJLNs_.mjs +78 -0
  9. package/dist/build-KNIBU0AI.mjs +9 -0
  10. package/dist/cleanup-8GRakeLu.mjs +31 -0
  11. package/dist/dev/index.d.mts +87 -83
  12. package/dist/dev/index.mjs +7 -23
  13. package/dist/dev-Bs_0dzlh.mjs +591 -0
  14. package/dist/dev-CnQwDUaD.mjs +7 -0
  15. package/dist/dev-L7lhoThJ.mjs +438 -0
  16. package/dist/dev-child-CSiX6Uyv.mjs +37 -0
  17. package/dist/devtools-BLGzUSNU.mjs +44 -0
  18. package/dist/env-Dz4K_NkM.mjs +12 -0
  19. package/dist/fs-ewAp6tjM.mjs +40 -0
  20. package/dist/generate-CGy3-x2K.mjs +35 -0
  21. package/dist/index.d.mts +9 -18
  22. package/dist/index.mjs +129 -8
  23. package/dist/info-BDdsghj1.mjs +120 -0
  24. package/dist/init-_n9DXzzY.mjs +336 -0
  25. package/dist/kit-xFxVGu6d.mjs +37 -0
  26. package/dist/logger-Dk0gkCkX.mjs +7 -0
  27. package/dist/module-CqBrGD-s.mjs +17 -0
  28. package/dist/nuxt-Cc9ZTk7m.mjs +44 -0
  29. package/dist/packageManagers-DbVB5cXf.mjs +9 -0
  30. package/dist/prepare-B0KOhO-L.mjs +7 -0
  31. package/dist/prepare-xI978yFg.mjs +49 -0
  32. package/dist/preview-C5fNqrC6.mjs +109 -0
  33. package/dist/search-DCyXfxzn.mjs +113 -0
  34. package/dist/test-CBt1emEB.mjs +55 -0
  35. package/dist/typecheck-DCWe7Iej.mjs +102 -0
  36. package/dist/upgrade-BMSFcUWJ.mjs +184 -0
  37. package/dist/versions-CSy_3o_-.mjs +18 -0
  38. package/package.json +13 -13
  39. package/dist/chunks/add.mjs +0 -381
  40. package/dist/chunks/add2.mjs +0 -319
  41. package/dist/chunks/analyze.mjs +0 -139
  42. package/dist/chunks/build.mjs +0 -94
  43. package/dist/chunks/cleanup.mjs +0 -34
  44. package/dist/chunks/dev-child.mjs +0 -38
  45. package/dist/chunks/dev.mjs +0 -709
  46. package/dist/chunks/devtools.mjs +0 -46
  47. package/dist/chunks/generate.mjs +0 -45
  48. package/dist/chunks/index.mjs +0 -507
  49. package/dist/chunks/index2.mjs +0 -15
  50. package/dist/chunks/info.mjs +0 -150
  51. package/dist/chunks/init.mjs +0 -413
  52. package/dist/chunks/prepare.mjs +0 -57
  53. package/dist/chunks/preview.mjs +0 -131
  54. package/dist/chunks/search.mjs +0 -114
  55. package/dist/chunks/test.mjs +0 -62
  56. package/dist/chunks/typecheck.mjs +0 -85
  57. package/dist/chunks/upgrade.mjs +0 -214
  58. package/dist/dev/index.d.ts +0 -94
  59. package/dist/index.d.ts +0 -23
  60. package/dist/shared/cli-nightly.B9AmABr3.mjs +0 -5
  61. package/dist/shared/cli-nightly.BRlCc6aT.mjs +0 -204
  62. package/dist/shared/cli-nightly.BSm0_9Hr.mjs +0 -7
  63. package/dist/shared/cli-nightly.Bu_9IHj2.mjs +0 -51
  64. package/dist/shared/cli-nightly.Cr-OCgdO.mjs +0 -37
  65. package/dist/shared/cli-nightly.DHenkA1C.mjs +0 -14
  66. package/dist/shared/cli-nightly.DPmMxQ6h.mjs +0 -33
  67. package/dist/shared/cli-nightly.DS8guhZv.mjs +0 -52
  68. package/dist/shared/cli-nightly.DkO5RR_e.mjs +0 -14
  69. package/dist/shared/cli-nightly.qKvs7FJ2.mjs +0 -36
@@ -1,709 +0,0 @@
1
- import { fork } from 'node:child_process';
2
- import process from 'node:process';
3
- import { defineCommand } from 'citty';
4
- import { isSocketSupported } from 'get-port-please';
5
- import { listen } from 'listhen';
6
- import { getArgs, parseArgs } from 'listhen/cli';
7
- import { resolve } from 'pathe';
8
- import { satisfies } from 'semver';
9
- import { isWindows, isTest, isBun, isDeno } from 'std-env';
10
- import { i as initialize, r as resolveLoadingTemplate, a as renderError, b as isSocketURL, p as parseSocketURL } from './index.mjs';
11
- import { request } from 'node:http';
12
- import { Readable } from 'node:stream';
13
- import { pipeline } from 'node:stream/promises';
14
- import { NodeRequest } from 'srvx/node';
15
- import { Agent } from 'undici';
16
- import { connect } from 'node:net';
17
- import { a as showVersionsFromConfig } from '../shared/cli-nightly.DS8guhZv.mjs';
18
- import { o as overrideEnv } from '../shared/cli-nightly.DkO5RR_e.mjs';
19
- import { l as loadKit } from '../shared/cli-nightly.qKvs7FJ2.mjs';
20
- import { l as logger } from '../shared/cli-nightly.B9AmABr3.mjs';
21
- import { e as extendsArgs, b as envNameArgs, l as legacyRootDirArgs, d as dotEnvArgs, a as logLevelArgs, c as cwdArgs } from '../shared/cli-nightly.BRlCc6aT.mjs';
22
- import 'defu';
23
- import 'node:events';
24
- import 'node:fs';
25
- import 'node:fs/promises';
26
- import 'node:url';
27
- import 'exsolve';
28
- import 'h3';
29
- import 'perfect-debounce';
30
- import 'ufo';
31
- import '../shared/cli-nightly.DPmMxQ6h.mjs';
32
- import '../shared/cli-nightly.Bu_9IHj2.mjs';
33
- import 'ohash';
34
- import 'youch';
35
- import 'consola/utils';
36
- import 'consola';
37
- import 'node:path';
38
-
39
- function fetchSocketOptions(socketPath) {
40
- if ("Bun" in globalThis) {
41
- return { unix: socketPath };
42
- }
43
- if ("Deno" in globalThis) {
44
- return {
45
- client: globalThis.Deno.createHttpClient({
46
- transport: "unix",
47
- path: socketPath
48
- })
49
- };
50
- }
51
- return {
52
- dispatcher: new Agent({ connect: { socketPath } })
53
- };
54
- }
55
- function fetchWithNodeHttp(socketPath, url, init) {
56
- return new Promise((resolve, reject) => {
57
- const headers = {};
58
- if (init?.headers) {
59
- if (init.headers instanceof Headers) {
60
- for (const [key, value] of init.headers.entries()) {
61
- headers[key] = value;
62
- }
63
- } else if (Array.isArray(init.headers)) {
64
- for (const [key, value] of init.headers) {
65
- headers[key] = value;
66
- }
67
- } else {
68
- Object.assign(headers, init.headers);
69
- }
70
- }
71
- const req = request({
72
- socketPath,
73
- path: url.pathname + url.search,
74
- method: init?.method || "GET",
75
- headers
76
- }, (res) => {
77
- const responseHeaders = new Headers();
78
- for (const [key, value] of Object.entries(res.headers)) {
79
- if (value !== void 0) {
80
- if (key.toLowerCase() === "set-cookie") {
81
- if (Array.isArray(value)) {
82
- for (const cookie of value) {
83
- responseHeaders.append("set-cookie", cookie);
84
- }
85
- } else {
86
- responseHeaders.append("set-cookie", value);
87
- }
88
- } else {
89
- responseHeaders.set(key, Array.isArray(value) ? value.join(", ") : value);
90
- }
91
- }
92
- }
93
- res.on("error", (err) => {
94
- if (err && err.message && !err.message.includes("aborted")) {
95
- reject(err);
96
- }
97
- });
98
- resolve({
99
- status: res.statusCode || 200,
100
- statusText: res.statusMessage || "OK",
101
- headers: responseHeaders,
102
- body: res
103
- });
104
- });
105
- req.on("error", reject);
106
- if (init?.body) {
107
- if (typeof init.body === "string") {
108
- req.write(init.body);
109
- } else if (init.body instanceof ReadableStream) {
110
- const reader = init.body.getReader();
111
- const pump = async () => {
112
- try {
113
- while (true) {
114
- const { done, value } = await reader.read();
115
- if (done) {
116
- break;
117
- }
118
- req.write(value);
119
- }
120
- req.end();
121
- } catch (err) {
122
- req.destroy(err);
123
- }
124
- };
125
- pump();
126
- return;
127
- }
128
- }
129
- req.end();
130
- });
131
- }
132
- function fetchAddress(addr, input, inputInit) {
133
- let url;
134
- let init;
135
- if (input instanceof Request) {
136
- url = new URL(input.url);
137
- init = {
138
- method: input.method,
139
- headers: input.headers,
140
- body: input.body,
141
- ...inputInit
142
- };
143
- } else {
144
- url = new URL(input);
145
- init = inputInit;
146
- }
147
- init = {
148
- duplex: "half",
149
- redirect: "manual",
150
- ...init
151
- };
152
- if (addr.socketPath && isWindows) {
153
- url.protocol = "http:";
154
- return fetchWithNodeHttp(addr.socketPath, url, init);
155
- }
156
- if (addr.socketPath) {
157
- url.protocol = "http:";
158
- return fetch(url, {
159
- ...init,
160
- ...fetchSocketOptions(addr.socketPath)
161
- });
162
- }
163
- const origin = `http://${addr.host}${addr.port ? `:${addr.port}` : ""}`;
164
- const outURL = new URL(url.pathname + url.search, origin);
165
- return fetch(outURL, init);
166
- }
167
- async function sendWebResponse(res, webResponse) {
168
- res.statusCode = webResponse.status;
169
- res.statusMessage = webResponse.statusText;
170
- const setCookies = webResponse.headers.getSetCookie?.();
171
- if (setCookies && setCookies.length > 0) {
172
- for (const cookie of setCookies) {
173
- res.appendHeader("set-cookie", cookie);
174
- }
175
- }
176
- for (const [key, value] of webResponse.headers.entries()) {
177
- if (key.toLowerCase() !== "set-cookie") {
178
- res.setHeader(key, value);
179
- }
180
- }
181
- if (webResponse.body) {
182
- if (webResponse.body instanceof Readable) {
183
- try {
184
- await pipeline(webResponse.body, res, { end: true });
185
- } catch (error) {
186
- if (!res.writableEnded) {
187
- res.end();
188
- }
189
- throw error;
190
- }
191
- return;
192
- }
193
- const reader = webResponse.body.getReader();
194
- try {
195
- while (true) {
196
- const { done, value } = await reader.read();
197
- if (done) {
198
- break;
199
- }
200
- if (!res.write(value)) {
201
- await new Promise((resolve) => res.once("drain", resolve));
202
- }
203
- }
204
- } catch (error) {
205
- reader.releaseLock();
206
- if (!res.writableEnded) {
207
- res.end();
208
- }
209
- throw error;
210
- } finally {
211
- reader.releaseLock();
212
- }
213
- }
214
- res.end();
215
- }
216
- function createFetchHandler(getAddress, onError, onLoading) {
217
- return async (req, res) => {
218
- try {
219
- const address = getAddress();
220
- if (!address) {
221
- await onLoading(req, res);
222
- return;
223
- }
224
- const isWebSocketUpgrade = req.headers.upgrade?.toLowerCase() === "websocket";
225
- if (isWebSocketUpgrade) {
226
- res.statusCode = 426;
227
- res.setHeader("Connection", "close");
228
- res.end("Upgrade Required");
229
- return;
230
- }
231
- const webRequest = new NodeRequest({ req, res });
232
- const webResponse = await fetchAddress(address, webRequest);
233
- await sendWebResponse(res, webResponse);
234
- } catch (error) {
235
- const errorMessage = error instanceof Error ? error.message : String(error);
236
- const isWebSocketError = errorMessage.toLowerCase().includes("websocket") || errorMessage.toLowerCase().includes("upgrade");
237
- if (!isWebSocketError) {
238
- console.error("Fetch handler error:", error);
239
- }
240
- if (!res.headersSent) {
241
- await onError(req, res);
242
- } else if (!res.writableEnded) {
243
- res.end();
244
- }
245
- }
246
- };
247
- }
248
-
249
- function connectToChildSocket(socketPath, req, clientSocket, head) {
250
- const childSocket = connect(socketPath);
251
- let isConnected = false;
252
- childSocket.on("error", (error) => {
253
- const errorMessage = error.message || "";
254
- if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !errorMessage.includes("premature close")) {
255
- console.error("Child socket connection error:", error);
256
- }
257
- if (!clientSocket.destroyed) {
258
- clientSocket.destroy();
259
- }
260
- });
261
- clientSocket.on("error", (error) => {
262
- const errorMessage = error.message || "";
263
- if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !isConnected) {
264
- console.error("Client socket error:", error);
265
- }
266
- if (!childSocket.destroyed) {
267
- childSocket.destroy();
268
- }
269
- });
270
- childSocket.on("connect", () => {
271
- isConnected = true;
272
- const requestLine = `${req.method} ${req.url} HTTP/${req.httpVersion}\r
273
- `;
274
- const headers = Object.entries(req.headers).map(([key, value]) => {
275
- if (Array.isArray(value)) {
276
- return value.map((v) => `${key}: ${v}`).join("\r\n");
277
- }
278
- return `${key}: ${value}`;
279
- }).join("\r\n");
280
- const httpRequest = `${requestLine}${headers}\r
281
- \r
282
- `;
283
- childSocket.write(httpRequest);
284
- if (head && head.length > 0) {
285
- childSocket.write(head);
286
- }
287
- clientSocket.pipe(childSocket);
288
- childSocket.pipe(clientSocket);
289
- });
290
- const cleanup = () => {
291
- if (!clientSocket.destroyed) {
292
- clientSocket.destroy();
293
- }
294
- if (!childSocket.destroyed) {
295
- childSocket.destroy();
296
- }
297
- };
298
- clientSocket.on("close", cleanup);
299
- childSocket.on("close", cleanup);
300
- }
301
- function connectToChildNetwork(host, port, req, clientSocket, head) {
302
- const childSocket = connect(port, host);
303
- let isConnected = false;
304
- childSocket.on("error", (error) => {
305
- const errorMessage = error.message || "";
306
- if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !errorMessage.includes("premature close")) {
307
- console.error("Child network connection error:", error);
308
- }
309
- if (!clientSocket.destroyed) {
310
- clientSocket.destroy();
311
- }
312
- });
313
- clientSocket.on("error", (error) => {
314
- const errorMessage = error.message || "";
315
- if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !isConnected) {
316
- console.error("Client socket error:", error);
317
- }
318
- if (!childSocket.destroyed) {
319
- childSocket.destroy();
320
- }
321
- });
322
- childSocket.on("connect", () => {
323
- isConnected = true;
324
- const requestLine = `${req.method} ${req.url} HTTP/${req.httpVersion}\r
325
- `;
326
- const headers = Object.entries(req.headers).map(([key, value]) => {
327
- if (Array.isArray(value)) {
328
- return value.map((v) => `${key}: ${v}`).join("\r\n");
329
- }
330
- return `${key}: ${value}`;
331
- }).join("\r\n");
332
- const httpRequest = `${requestLine}${headers}\r
333
- \r
334
- `;
335
- childSocket.write(httpRequest);
336
- if (head && head.length > 0) {
337
- childSocket.write(head);
338
- }
339
- clientSocket.pipe(childSocket);
340
- childSocket.pipe(clientSocket);
341
- });
342
- const cleanup = () => {
343
- if (!clientSocket.destroyed) {
344
- clientSocket.destroy();
345
- }
346
- if (!childSocket.destroyed) {
347
- childSocket.destroy();
348
- }
349
- };
350
- clientSocket.on("close", cleanup);
351
- childSocket.on("close", cleanup);
352
- }
353
-
354
- const startTime = Date.now();
355
- const forkSupported = !isTest && (!isBun || isBunForkSupported());
356
- const listhenArgs = getArgs();
357
- const command = defineCommand({
358
- meta: {
359
- name: "dev",
360
- description: "Run Nuxt development server"
361
- },
362
- args: {
363
- ...cwdArgs,
364
- ...logLevelArgs,
365
- ...dotEnvArgs,
366
- ...legacyRootDirArgs,
367
- ...envNameArgs,
368
- ...extendsArgs,
369
- clear: {
370
- type: "boolean",
371
- description: "Clear console on restart",
372
- default: false
373
- },
374
- fork: {
375
- type: "boolean",
376
- description: forkSupported ? "Disable forked mode" : "Enable forked mode",
377
- negativeDescription: "Disable forked mode",
378
- default: forkSupported,
379
- alias: ["f"]
380
- },
381
- ...{
382
- ...listhenArgs,
383
- "port": {
384
- ...listhenArgs.port,
385
- description: "Port to listen on (default: `NUXT_PORT || NITRO_PORT || PORT || nuxtOptions.devServer.port`)",
386
- alias: ["p"]
387
- },
388
- "open": {
389
- ...listhenArgs.open,
390
- alias: ["o"],
391
- default: false
392
- },
393
- "host": {
394
- ...listhenArgs.host,
395
- alias: ["h"],
396
- description: "Host to listen on (default: `NUXT_HOST || NITRO_HOST || HOST || nuxtOptions.devServer?.host`)"
397
- },
398
- "clipboard": { ...listhenArgs.clipboard, default: false },
399
- "https.domains": {
400
- ...listhenArgs["https.domains"],
401
- description: "Comma separated list of domains and IPs, the autogenerated certificate should be valid for (https: true)"
402
- }
403
- },
404
- sslCert: {
405
- type: "string",
406
- description: "(DEPRECATED) Use `--https.cert` instead."
407
- },
408
- sslKey: {
409
- type: "string",
410
- description: "(DEPRECATED) Use `--https.key` instead."
411
- }
412
- },
413
- async run(ctx) {
414
- overrideEnv("development");
415
- const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
416
- const { loadNuxtConfig } = await loadKit(cwd);
417
- const nuxtOptions = await loadNuxtConfig({
418
- cwd,
419
- dotenv: { cwd, fileName: ctx.args.dotenv },
420
- envName: ctx.args.envName,
421
- // c12 will fall back to NODE_ENV
422
- overrides: {
423
- dev: true,
424
- logLevel: ctx.args.logLevel,
425
- ...ctx.args.extends && { extends: ctx.args.extends },
426
- ...ctx.data?.overrides
427
- }
428
- });
429
- showVersionsFromConfig(cwd, nuxtOptions);
430
- const listenOptions = resolveListenOptions(nuxtOptions, ctx.args);
431
- if (!ctx.args.fork) {
432
- const { listener, close: close2 } = await initialize({
433
- cwd,
434
- args: ctx.args,
435
- hostname: listenOptions.hostname,
436
- public: listenOptions.public,
437
- publicURLs: void 0,
438
- proxy: {
439
- https: listenOptions.https
440
- }
441
- }, { data: ctx.data }, listenOptions);
442
- return {
443
- listener,
444
- async close() {
445
- await close2();
446
- await listener.close();
447
- }
448
- };
449
- }
450
- const devHandler = await createDevHandler(cwd, nuxtOptions, listenOptions);
451
- const nuxtSocketEnv = process.env.NUXT_SOCKET ? process.env.NUXT_SOCKET === "1" : void 0;
452
- const useSocket = nuxtSocketEnv ?? (nuxtOptions._majorVersion === 4 && await isSocketSupported());
453
- const urls = await devHandler.listener.getURLs();
454
- const { onRestart, onReady, close } = await initialize({
455
- cwd,
456
- args: ctx.args,
457
- hostname: listenOptions.hostname,
458
- public: listenOptions.public,
459
- publicURLs: urls.map((r) => r.url),
460
- proxy: {
461
- url: devHandler.listener.url,
462
- urls,
463
- https: devHandler.listener.https,
464
- addr: devHandler.listener.address
465
- }
466
- // if running with nuxt v4 or `NUXT_SOCKET=1`, we use the socket listener
467
- // otherwise pass 'true' to listen on a random port instead
468
- }, {}, useSocket ? void 0 : true);
469
- onReady((address) => devHandler.setAddress(address));
470
- const fork2 = startSubprocess(cwd, ctx.args, ctx.rawArgs, listenOptions);
471
- onRestart(async (devServer) => {
472
- const [subprocess] = await Promise.all([
473
- fork2,
474
- devServer.close().catch(() => {
475
- })
476
- ]);
477
- await subprocess.initialize(devHandler, useSocket);
478
- });
479
- return {
480
- listener: devHandler.listener,
481
- async close() {
482
- await close();
483
- const subprocess = await fork2;
484
- subprocess.kill(0);
485
- await devHandler.listener.close();
486
- }
487
- };
488
- }
489
- });
490
- async function createDevHandler(cwd, nuxtOptions, listenOptions) {
491
- let loadingMessage = "Nuxt dev server is starting...";
492
- let error;
493
- let address;
494
- let loadingTemplate = nuxtOptions.devServer.loadingTemplate;
495
- const fetchHandler = createFetchHandler(
496
- () => {
497
- if (!address) {
498
- return void 0;
499
- }
500
- if (isSocketURL(address)) {
501
- const { socketPath } = parseSocketURL(address);
502
- return { socketPath };
503
- }
504
- try {
505
- const url = new URL(address);
506
- return {
507
- host: url.hostname,
508
- port: Number.parseInt(url.port) || 80
509
- };
510
- } catch {
511
- return void 0;
512
- }
513
- },
514
- // Error handler
515
- async (req, res) => {
516
- renderError(req, res, error);
517
- },
518
- // Loading handler
519
- async (req, res) => {
520
- if (res.headersSent) {
521
- if (!res.writableEnded) {
522
- res.end();
523
- }
524
- return;
525
- }
526
- res.statusCode = 503;
527
- res.setHeader("Content-Type", "text/html");
528
- res.setHeader("Cache-Control", "no-store");
529
- if (loadingTemplate) {
530
- res.end(loadingTemplate({ loading: loadingMessage }));
531
- return;
532
- }
533
- async function resolveLoadingMessage() {
534
- loadingTemplate = await resolveLoadingTemplate(cwd);
535
- res.end(loadingTemplate({ loading: loadingMessage }));
536
- }
537
- return resolveLoadingMessage();
538
- }
539
- );
540
- const listener = await listen(fetchHandler, listenOptions);
541
- listener.server.on("upgrade", (req, socket, head) => {
542
- if (!address) {
543
- if (!socket.destroyed) {
544
- socket.end();
545
- }
546
- return;
547
- }
548
- if (isSocketURL(address)) {
549
- const { socketPath } = parseSocketURL(address);
550
- connectToChildSocket(socketPath, req, socket, head);
551
- } else {
552
- try {
553
- const url = new URL(address);
554
- const host = url.hostname;
555
- const port = Number.parseInt(url.port) || 80;
556
- connectToChildNetwork(host, port, req, socket, head);
557
- } catch {
558
- if (!socket.destroyed) {
559
- socket.end();
560
- }
561
- }
562
- }
563
- });
564
- return {
565
- listener,
566
- setAddress: (_addr) => {
567
- address = _addr;
568
- },
569
- setLoadingMessage: (_msg) => {
570
- loadingMessage = _msg;
571
- },
572
- setError: (_error) => {
573
- error = _error;
574
- },
575
- clearError() {
576
- error = void 0;
577
- }
578
- };
579
- }
580
- async function startSubprocess(cwd, args, rawArgs, listenOptions) {
581
- let childProc;
582
- let devHandler;
583
- let ready;
584
- const kill = (signal) => {
585
- if (childProc) {
586
- childProc.kill(signal === 0 && isDeno ? "SIGTERM" : signal);
587
- childProc = void 0;
588
- }
589
- };
590
- async function initialize2(handler, socket) {
591
- devHandler = handler;
592
- const urls = await devHandler.listener.getURLs();
593
- await ready;
594
- childProc.send({
595
- type: "nuxt:internal:dev:context",
596
- socket,
597
- context: {
598
- cwd,
599
- args,
600
- hostname: listenOptions.hostname,
601
- public: listenOptions.public,
602
- publicURLs: urls.map((r) => r.url),
603
- proxy: {
604
- url: devHandler.listener.url,
605
- urls,
606
- https: devHandler.listener.https
607
- }
608
- }
609
- });
610
- }
611
- async function restart() {
612
- devHandler?.clearError();
613
- if (process.platform === "win32") {
614
- kill("SIGTERM");
615
- } else {
616
- kill("SIGHUP");
617
- }
618
- childProc = fork(globalThis.__nuxt_cli__.devEntry, rawArgs, {
619
- execArgv: ["--enable-source-maps", process.argv.find((a) => a.includes("--inspect"))].filter(Boolean),
620
- env: {
621
- ...process.env,
622
- __NUXT__FORK: "true"
623
- }
624
- });
625
- childProc.on("close", (errorCode) => {
626
- if (errorCode) {
627
- process.exit(errorCode);
628
- }
629
- });
630
- ready = new Promise((resolve2, reject) => {
631
- childProc.on("error", reject);
632
- childProc.on("message", (message) => {
633
- if (message.type === "nuxt:internal:dev:fork-ready") {
634
- resolve2();
635
- } else if (message.type === "nuxt:internal:dev:ready") {
636
- devHandler.setAddress(message.address);
637
- if (startTime) {
638
- logger.debug(`Dev server ready for connections in ${Date.now() - startTime}ms`);
639
- }
640
- } else if (message.type === "nuxt:internal:dev:loading") {
641
- devHandler.setAddress(void 0);
642
- devHandler.setLoadingMessage(message.message);
643
- devHandler.clearError();
644
- } else if (message.type === "nuxt:internal:dev:loading:error") {
645
- devHandler.setAddress(void 0);
646
- devHandler.setError(message.error);
647
- } else if (message.type === "nuxt:internal:dev:restart") {
648
- restart();
649
- } else if (message.type === "nuxt:internal:dev:rejection") {
650
- logger.info(`Restarting Nuxt due to error: \`${message.message}\``);
651
- restart();
652
- }
653
- });
654
- });
655
- }
656
- for (const signal of [
657
- "exit",
658
- "SIGTERM",
659
- "SIGINT",
660
- "SIGQUIT"
661
- ]) {
662
- process.once(signal, () => {
663
- kill(signal === "exit" ? 0 : signal);
664
- });
665
- }
666
- await restart();
667
- return {
668
- initialize: initialize2,
669
- restart,
670
- kill
671
- };
672
- }
673
- function resolveListenOptions(nuxtOptions, args) {
674
- const _port = args.port ?? args.p ?? process.env.NUXT_PORT ?? process.env.NITRO_PORT ?? process.env.PORT ?? nuxtOptions.devServer.port;
675
- const _hostname = typeof args.host === "string" ? args.host : args.host === true ? "" : process.env.NUXT_HOST ?? process.env.NITRO_HOST ?? process.env.HOST ?? (nuxtOptions.devServer?.host || void 0) ?? void 0;
676
- const _public = args.public ?? (_hostname && !["localhost", "127.0.0.1", "::1"].includes(_hostname)) ? true : void 0;
677
- const _httpsCert = args["https.cert"] || args.sslCert || process.env.NUXT_SSL_CERT || process.env.NITRO_SSL_CERT || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "cert" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.cert || "";
678
- const _httpsKey = args["https.key"] || args.sslKey || process.env.NUXT_SSL_KEY || process.env.NITRO_SSL_KEY || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "key" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.key || "";
679
- const _httpsPfx = args["https.pfx"] || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "pfx" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.pfx || "";
680
- const _httpsPassphrase = args["https.passphrase"] || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "passphrase" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.passphrase || "";
681
- const httpsEnabled = !!(args.https ?? nuxtOptions.devServer.https);
682
- const _listhenOptions = parseArgs({
683
- ...args,
684
- "open": args.o || args.open,
685
- "https": httpsEnabled,
686
- "https.cert": _httpsCert,
687
- "https.key": _httpsKey,
688
- "https.pfx": _httpsPfx,
689
- "https.passphrase": _httpsPassphrase
690
- });
691
- const httpsOptions = httpsEnabled && {
692
- ...nuxtOptions.devServer.https,
693
- ..._listhenOptions.https
694
- };
695
- return {
696
- ..._listhenOptions,
697
- port: _port,
698
- hostname: _hostname,
699
- public: _public,
700
- https: httpsOptions,
701
- baseURL: nuxtOptions.app.baseURL.startsWith("./") ? nuxtOptions.app.baseURL.slice(1) : nuxtOptions.app.baseURL
702
- };
703
- }
704
- function isBunForkSupported() {
705
- const bunVersion = globalThis.Bun.version;
706
- return satisfies(bunVersion, ">=1.2");
707
- }
708
-
709
- export { command as default };