@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.
- package/dist/_shared-C3vB2YLc.mjs +42 -0
- package/dist/_utils-DTrPahho.mjs +29 -0
- package/dist/add-BGMHIn5L.mjs +333 -0
- package/dist/add-CRBwIlDF.mjs +298 -0
- package/dist/add-hFFIzkcy.mjs +10 -0
- package/dist/analyze-CUKAi_IN.mjs +115 -0
- package/dist/banner-CqfM_0Qo.mjs +55 -0
- package/dist/build-BSxJLNs_.mjs +78 -0
- package/dist/build-KNIBU0AI.mjs +9 -0
- package/dist/cleanup-8GRakeLu.mjs +31 -0
- package/dist/dev/index.d.mts +87 -83
- package/dist/dev/index.mjs +7 -23
- package/dist/dev-Bs_0dzlh.mjs +591 -0
- package/dist/dev-CnQwDUaD.mjs +7 -0
- package/dist/dev-L7lhoThJ.mjs +438 -0
- package/dist/dev-child-CSiX6Uyv.mjs +37 -0
- package/dist/devtools-BLGzUSNU.mjs +44 -0
- package/dist/env-Dz4K_NkM.mjs +12 -0
- package/dist/fs-ewAp6tjM.mjs +40 -0
- package/dist/generate-CGy3-x2K.mjs +35 -0
- package/dist/index.d.mts +9 -18
- package/dist/index.mjs +129 -8
- package/dist/info-BDdsghj1.mjs +120 -0
- package/dist/init-_n9DXzzY.mjs +336 -0
- package/dist/kit-xFxVGu6d.mjs +37 -0
- package/dist/logger-Dk0gkCkX.mjs +7 -0
- package/dist/module-CqBrGD-s.mjs +17 -0
- package/dist/nuxt-Cc9ZTk7m.mjs +44 -0
- package/dist/packageManagers-DbVB5cXf.mjs +9 -0
- package/dist/prepare-B0KOhO-L.mjs +7 -0
- package/dist/prepare-xI978yFg.mjs +49 -0
- package/dist/preview-C5fNqrC6.mjs +109 -0
- package/dist/search-DCyXfxzn.mjs +113 -0
- package/dist/test-CBt1emEB.mjs +55 -0
- package/dist/typecheck-DCWe7Iej.mjs +102 -0
- package/dist/upgrade-BMSFcUWJ.mjs +184 -0
- package/dist/versions-CSy_3o_-.mjs +18 -0
- package/package.json +13 -13
- package/dist/chunks/add.mjs +0 -381
- package/dist/chunks/add2.mjs +0 -319
- package/dist/chunks/analyze.mjs +0 -139
- package/dist/chunks/build.mjs +0 -94
- package/dist/chunks/cleanup.mjs +0 -34
- package/dist/chunks/dev-child.mjs +0 -38
- package/dist/chunks/dev.mjs +0 -709
- package/dist/chunks/devtools.mjs +0 -46
- package/dist/chunks/generate.mjs +0 -45
- package/dist/chunks/index.mjs +0 -507
- package/dist/chunks/index2.mjs +0 -15
- package/dist/chunks/info.mjs +0 -150
- package/dist/chunks/init.mjs +0 -413
- package/dist/chunks/prepare.mjs +0 -57
- package/dist/chunks/preview.mjs +0 -131
- package/dist/chunks/search.mjs +0 -114
- package/dist/chunks/test.mjs +0 -62
- package/dist/chunks/typecheck.mjs +0 -85
- package/dist/chunks/upgrade.mjs +0 -214
- package/dist/dev/index.d.ts +0 -94
- package/dist/index.d.ts +0 -23
- package/dist/shared/cli-nightly.B9AmABr3.mjs +0 -5
- package/dist/shared/cli-nightly.BRlCc6aT.mjs +0 -204
- package/dist/shared/cli-nightly.BSm0_9Hr.mjs +0 -7
- package/dist/shared/cli-nightly.Bu_9IHj2.mjs +0 -51
- package/dist/shared/cli-nightly.Cr-OCgdO.mjs +0 -37
- package/dist/shared/cli-nightly.DHenkA1C.mjs +0 -14
- package/dist/shared/cli-nightly.DPmMxQ6h.mjs +0 -33
- package/dist/shared/cli-nightly.DS8guhZv.mjs +0 -52
- package/dist/shared/cli-nightly.DkO5RR_e.mjs +0 -14
- package/dist/shared/cli-nightly.qKvs7FJ2.mjs +0 -36
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { t as clearBuildDir } from "./fs-ewAp6tjM.mjs";
|
|
2
|
+
import { t as loadKit } from "./kit-xFxVGu6d.mjs";
|
|
3
|
+
import { a as writeNuxtManifest, i as resolveNuxtManifest, n as loadNuxtManifest } from "./nuxt-Cc9ZTk7m.mjs";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { provider } from "std-env";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import defu from "defu";
|
|
8
|
+
import { listen } from "listhen";
|
|
9
|
+
import { Server } from "node:http";
|
|
10
|
+
import { cleanSocket, getSocketAddress } from "get-port-please";
|
|
11
|
+
import EventEmitter from "node:events";
|
|
12
|
+
import { existsSync, statSync, watch } from "node:fs";
|
|
13
|
+
import { mkdir } from "node:fs/promises";
|
|
14
|
+
import { resolveModulePath } from "exsolve";
|
|
15
|
+
import { toNodeListener } from "h3";
|
|
16
|
+
import { resolve } from "pathe";
|
|
17
|
+
import { debounce } from "perfect-debounce";
|
|
18
|
+
import { joinURL } from "ufo";
|
|
19
|
+
import { Youch } from "youch";
|
|
20
|
+
|
|
21
|
+
//#region ../nuxi/src/dev/socket.ts
|
|
22
|
+
function formatSocketURL(socketPath, ssl = false) {
|
|
23
|
+
return `${ssl ? "https" : "http"}+unix://${process.platform === "win32" ? encodeURIComponent(socketPath) : socketPath.replace(/\//g, "%2F")}`;
|
|
24
|
+
}
|
|
25
|
+
function isSocketURL(url) {
|
|
26
|
+
return url.startsWith("http+unix://") || url.startsWith("https+unix://");
|
|
27
|
+
}
|
|
28
|
+
function parseSocketURL(url) {
|
|
29
|
+
if (!isSocketURL(url)) throw new Error(`Invalid socket URL: ${url}`);
|
|
30
|
+
const ssl = url.startsWith("https+unix://");
|
|
31
|
+
const path = url.slice(ssl ? 13 : 12);
|
|
32
|
+
return {
|
|
33
|
+
socketPath: decodeURIComponent(path.replace(/%2F/g, "/")),
|
|
34
|
+
protocol: ssl ? "https" : "http"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function createSocketListener(handler, proxyAddress) {
|
|
38
|
+
const socketPath = getSocketAddress({
|
|
39
|
+
name: "nuxt-dev",
|
|
40
|
+
random: true
|
|
41
|
+
});
|
|
42
|
+
const server = new Server(handler);
|
|
43
|
+
await cleanSocket(socketPath);
|
|
44
|
+
await new Promise((resolve$1) => server.listen({ path: socketPath }, resolve$1));
|
|
45
|
+
const url = formatSocketURL(socketPath);
|
|
46
|
+
return {
|
|
47
|
+
url,
|
|
48
|
+
address: {
|
|
49
|
+
address: "localhost",
|
|
50
|
+
port: 3e3,
|
|
51
|
+
...proxyAddress,
|
|
52
|
+
socketPath
|
|
53
|
+
},
|
|
54
|
+
async close() {
|
|
55
|
+
try {
|
|
56
|
+
server.removeAllListeners();
|
|
57
|
+
await new Promise((resolve$1, reject) => server.close((err) => err ? reject(err) : resolve$1()));
|
|
58
|
+
} finally {
|
|
59
|
+
await cleanSocket(socketPath);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
getURLs: async () => [{
|
|
63
|
+
url,
|
|
64
|
+
type: "network"
|
|
65
|
+
}],
|
|
66
|
+
https: false,
|
|
67
|
+
server
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region ../nuxi/src/dev/error.ts
|
|
73
|
+
async function renderError(req, res, error) {
|
|
74
|
+
if (res.headersSent) {
|
|
75
|
+
if (!res.writableEnded) res.end();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const youch = new Youch();
|
|
79
|
+
res.statusCode = 500;
|
|
80
|
+
res.setHeader("Content-Type", "text/html");
|
|
81
|
+
const html = await youch.toHTML(error, { request: {
|
|
82
|
+
url: req.url,
|
|
83
|
+
method: req.method,
|
|
84
|
+
headers: req.headers
|
|
85
|
+
} });
|
|
86
|
+
res.end(html);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region ../nuxi/src/dev/utils.ts
|
|
91
|
+
const RESTART_RE = /^(?:nuxt\.config\.[a-z0-9]+|\.nuxtignore|\.nuxtrc|\.config\/nuxt(?:\.config)?\.[a-z0-9]+)$/;
|
|
92
|
+
var FileChangeTracker = class {
|
|
93
|
+
mtimes = /* @__PURE__ */ new Map();
|
|
94
|
+
shouldEmitChange(filePath) {
|
|
95
|
+
try {
|
|
96
|
+
const currentMtime = statSync(filePath).mtimeMs;
|
|
97
|
+
const lastMtime = this.mtimes.get(filePath);
|
|
98
|
+
this.mtimes.set(filePath, currentMtime);
|
|
99
|
+
return lastMtime === void 0 || currentMtime !== lastMtime;
|
|
100
|
+
} catch {
|
|
101
|
+
this.mtimes.delete(filePath);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var NuxtDevServer = class extends EventEmitter {
|
|
107
|
+
_handler;
|
|
108
|
+
_distWatcher;
|
|
109
|
+
_configWatcher;
|
|
110
|
+
_currentNuxt;
|
|
111
|
+
_loadingMessage;
|
|
112
|
+
_loadingError;
|
|
113
|
+
_fileChangeTracker = new FileChangeTracker();
|
|
114
|
+
cwd;
|
|
115
|
+
loadDebounced;
|
|
116
|
+
handler;
|
|
117
|
+
listener;
|
|
118
|
+
constructor(options) {
|
|
119
|
+
super();
|
|
120
|
+
this.options = options;
|
|
121
|
+
this.loadDebounced = debounce(this.load);
|
|
122
|
+
let _initResolve;
|
|
123
|
+
const _initPromise = new Promise((resolve$1) => {
|
|
124
|
+
_initResolve = resolve$1;
|
|
125
|
+
});
|
|
126
|
+
this.once("ready", () => {
|
|
127
|
+
_initResolve();
|
|
128
|
+
});
|
|
129
|
+
this.cwd = options.cwd;
|
|
130
|
+
this.handler = async (req, res) => {
|
|
131
|
+
if (this._loadingError) {
|
|
132
|
+
this._renderError(req, res);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
await _initPromise;
|
|
136
|
+
if (this._handler) this._handler(req, res);
|
|
137
|
+
else this._renderLoadingScreen(req, res);
|
|
138
|
+
};
|
|
139
|
+
this.listener = void 0;
|
|
140
|
+
}
|
|
141
|
+
_renderError(req, res) {
|
|
142
|
+
renderError(req, res, this._loadingError);
|
|
143
|
+
}
|
|
144
|
+
async _renderLoadingScreen(req, res) {
|
|
145
|
+
if (res.headersSent) {
|
|
146
|
+
if (!res.writableEnded) res.end();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
res.statusCode = 503;
|
|
150
|
+
res.setHeader("Content-Type", "text/html");
|
|
151
|
+
const loadingTemplate = this.options.loadingTemplate || this._currentNuxt?.options.devServer.loadingTemplate || await resolveLoadingTemplate(this.cwd);
|
|
152
|
+
res.end(loadingTemplate({ loading: this._loadingMessage || "Loading..." }));
|
|
153
|
+
}
|
|
154
|
+
async init() {
|
|
155
|
+
await this.load();
|
|
156
|
+
this._watchConfig();
|
|
157
|
+
}
|
|
158
|
+
closeWatchers() {
|
|
159
|
+
this._distWatcher?.close();
|
|
160
|
+
this._configWatcher?.();
|
|
161
|
+
}
|
|
162
|
+
async load(reload, reason) {
|
|
163
|
+
try {
|
|
164
|
+
this.closeWatchers();
|
|
165
|
+
await this._load(reload, reason);
|
|
166
|
+
this._watchConfig();
|
|
167
|
+
this._loadingError = void 0;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.error(`Cannot ${reload ? "restart" : "start"} nuxt: `, error);
|
|
170
|
+
this._handler = void 0;
|
|
171
|
+
this._loadingError = error;
|
|
172
|
+
this._loadingMessage = "Error while loading Nuxt. Please check console and fix errors.";
|
|
173
|
+
this.emit("loading:error", error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async close() {
|
|
177
|
+
if (this._currentNuxt) await this._currentNuxt.close();
|
|
178
|
+
}
|
|
179
|
+
async _load(reload, reason) {
|
|
180
|
+
const action = reload ? "Restarting" : "Starting";
|
|
181
|
+
this._loadingMessage = `${reason ? `${reason}. ` : ""}${action} Nuxt...`;
|
|
182
|
+
this._handler = void 0;
|
|
183
|
+
this.emit("loading", this._loadingMessage);
|
|
184
|
+
if (reload) console.info(this._loadingMessage);
|
|
185
|
+
await this.close();
|
|
186
|
+
const kit = await loadKit(this.options.cwd);
|
|
187
|
+
const devServerDefaults = resolveDevServerDefaults({}, await this.listener.getURLs().then((r) => r.map((r$1) => r$1.url)));
|
|
188
|
+
this._currentNuxt = await kit.loadNuxt({
|
|
189
|
+
cwd: this.options.cwd,
|
|
190
|
+
dev: true,
|
|
191
|
+
ready: false,
|
|
192
|
+
envName: this.options.envName,
|
|
193
|
+
dotenv: {
|
|
194
|
+
cwd: this.options.cwd,
|
|
195
|
+
fileName: this.options.dotenv.fileName
|
|
196
|
+
},
|
|
197
|
+
defaults: defu(this.options.defaults, devServerDefaults),
|
|
198
|
+
overrides: {
|
|
199
|
+
logLevel: this.options.logLevel,
|
|
200
|
+
...this.options.overrides,
|
|
201
|
+
vite: {
|
|
202
|
+
clearScreen: this.options.clear,
|
|
203
|
+
...this.options.overrides.vite
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
if (!process.env.NUXI_DISABLE_VITE_HMR) this._currentNuxt.hooks.hook("vite:extend", ({ config }) => {
|
|
208
|
+
if (config.server) config.server.hmr = {
|
|
209
|
+
protocol: void 0,
|
|
210
|
+
...config.server.hmr,
|
|
211
|
+
port: void 0,
|
|
212
|
+
host: void 0,
|
|
213
|
+
server: this.listener.server
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
this._currentNuxt.hooks.hookOnce("close", () => {
|
|
217
|
+
this.listener.server.removeAllListeners("upgrade");
|
|
218
|
+
});
|
|
219
|
+
if (!reload) {
|
|
220
|
+
const previousManifest = await loadNuxtManifest(this._currentNuxt.options.buildDir);
|
|
221
|
+
const newManifest = resolveNuxtManifest(this._currentNuxt);
|
|
222
|
+
const promise = writeNuxtManifest(this._currentNuxt, newManifest);
|
|
223
|
+
this._currentNuxt.hooks.hookOnce("ready", async () => {
|
|
224
|
+
await promise;
|
|
225
|
+
});
|
|
226
|
+
if (previousManifest && newManifest && previousManifest._hash !== newManifest._hash) await clearBuildDir(this._currentNuxt.options.buildDir);
|
|
227
|
+
}
|
|
228
|
+
await this._currentNuxt.ready();
|
|
229
|
+
const unsub = this._currentNuxt.hooks.hook("restart", async (options) => {
|
|
230
|
+
unsub();
|
|
231
|
+
if (options?.hard) {
|
|
232
|
+
this.emit("restart");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
await this.load(true);
|
|
236
|
+
});
|
|
237
|
+
if (this._currentNuxt.server && "upgrade" in this._currentNuxt.server) this.listener.server.on("upgrade", (req, socket, head) => {
|
|
238
|
+
const nuxt = this._currentNuxt;
|
|
239
|
+
if (!nuxt || !nuxt.server) return;
|
|
240
|
+
const viteHmrPath = joinURL(nuxt.options.app.baseURL.startsWith("./") ? nuxt.options.app.baseURL.slice(1) : nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir);
|
|
241
|
+
if (req.url?.startsWith(viteHmrPath)) return;
|
|
242
|
+
nuxt.server.upgrade(req, socket, head);
|
|
243
|
+
});
|
|
244
|
+
await this._currentNuxt.hooks.callHook("listen", this.listener.server, this.listener);
|
|
245
|
+
const addr = this.listener.address;
|
|
246
|
+
this._currentNuxt.options.devServer.host = addr.address;
|
|
247
|
+
this._currentNuxt.options.devServer.port = addr.port;
|
|
248
|
+
this._currentNuxt.options.devServer.url = getAddressURL(addr, !!this.listener.https);
|
|
249
|
+
this._currentNuxt.options.devServer.https = this.options.devContext.proxy?.https;
|
|
250
|
+
if (this.listener.https && !process.env.NODE_TLS_REJECT_UNAUTHORIZED) console.warn("You might need `NODE_TLS_REJECT_UNAUTHORIZED=0` environment variable to make https work.");
|
|
251
|
+
await Promise.all([kit.writeTypes(this._currentNuxt).catch(console.error), kit.buildNuxt(this._currentNuxt)]);
|
|
252
|
+
if (!this._currentNuxt.server) throw new Error("Nitro server has not been initialized.");
|
|
253
|
+
const distDir = resolve(this._currentNuxt.options.buildDir, "dist");
|
|
254
|
+
await mkdir(distDir, { recursive: true });
|
|
255
|
+
this._distWatcher = watch(distDir);
|
|
256
|
+
this._distWatcher.on("change", (_event, file) => {
|
|
257
|
+
if (!this._fileChangeTracker.shouldEmitChange(resolve(distDir, file || ""))) return;
|
|
258
|
+
this.loadDebounced(true, ".nuxt/dist directory has been removed");
|
|
259
|
+
});
|
|
260
|
+
this._handler = toNodeListener(this._currentNuxt.server.app);
|
|
261
|
+
this.emit("ready", "socketPath" in addr ? formatSocketURL(addr.socketPath, !!this.listener.https) : `http://127.0.0.1:${addr.port}`);
|
|
262
|
+
}
|
|
263
|
+
_watchConfig() {
|
|
264
|
+
this._configWatcher = createConfigWatcher(this.cwd, this.options.dotenv.fileName, () => this.emit("restart"), (file) => this.loadDebounced(true, `${file} updated`));
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
function getAddressURL(addr, https) {
|
|
268
|
+
const proto = https ? "https" : "http";
|
|
269
|
+
let host = addr.address.includes(":") ? `[${addr.address}]` : addr.address;
|
|
270
|
+
if (host === "[::]") host = "localhost";
|
|
271
|
+
const port = addr.port || 3e3;
|
|
272
|
+
return `${proto}://${host}:${port}/`;
|
|
273
|
+
}
|
|
274
|
+
function resolveDevServerOverrides(listenOptions) {
|
|
275
|
+
if (listenOptions.public || provider === "codesandbox") return {
|
|
276
|
+
devServer: { cors: { origin: "*" } },
|
|
277
|
+
vite: { server: { allowedHosts: true } }
|
|
278
|
+
};
|
|
279
|
+
return {};
|
|
280
|
+
}
|
|
281
|
+
function resolveDevServerDefaults(listenOptions, urls = []) {
|
|
282
|
+
const defaultConfig = {};
|
|
283
|
+
if (urls) defaultConfig.vite = { server: { allowedHosts: urls.filter((u) => !isSocketURL(u)).map((u) => new URL(u).hostname) } };
|
|
284
|
+
if (listenOptions.hostname) {
|
|
285
|
+
defaultConfig.devServer = { cors: { origin: [`${listenOptions.https ? "https" : "http"}://${listenOptions.hostname}`, ...urls] } };
|
|
286
|
+
defaultConfig.vite = defu(defaultConfig.vite, { server: { allowedHosts: [listenOptions.hostname] } });
|
|
287
|
+
}
|
|
288
|
+
return defaultConfig;
|
|
289
|
+
}
|
|
290
|
+
function createConfigWatcher(cwd, dotenvFileName = ".env", onRestart, onReload) {
|
|
291
|
+
const configWatcher = watch(cwd);
|
|
292
|
+
let configDirWatcher = existsSync(resolve(cwd, ".config")) ? createConfigDirWatcher(cwd, onReload) : void 0;
|
|
293
|
+
const dotenvFileNames = new Set(Array.isArray(dotenvFileName) ? dotenvFileName : [dotenvFileName]);
|
|
294
|
+
const fileWatcher = new FileChangeTracker();
|
|
295
|
+
configWatcher.on("change", (_event, file) => {
|
|
296
|
+
if (!fileWatcher.shouldEmitChange(resolve(cwd, file))) return;
|
|
297
|
+
if (dotenvFileNames.has(file)) onRestart();
|
|
298
|
+
if (RESTART_RE.test(file)) onReload(file);
|
|
299
|
+
if (file === ".config") configDirWatcher ||= createConfigDirWatcher(cwd, onReload);
|
|
300
|
+
});
|
|
301
|
+
return () => {
|
|
302
|
+
configWatcher.close();
|
|
303
|
+
configDirWatcher?.();
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function createConfigDirWatcher(cwd, onReload) {
|
|
307
|
+
const configDir = resolve(cwd, ".config");
|
|
308
|
+
const fileWatcher = new FileChangeTracker();
|
|
309
|
+
const configDirWatcher = watch(configDir);
|
|
310
|
+
configDirWatcher.on("change", (_event, file) => {
|
|
311
|
+
if (!fileWatcher.shouldEmitChange(resolve(configDir, file))) return;
|
|
312
|
+
if (RESTART_RE.test(file)) onReload(file);
|
|
313
|
+
});
|
|
314
|
+
return () => configDirWatcher.close();
|
|
315
|
+
}
|
|
316
|
+
async function resolveLoadingTemplate(cwd) {
|
|
317
|
+
return (await import(pathToFileURL(resolveModulePath("@nuxt/ui-templates", { from: resolveModulePath("nuxt", {
|
|
318
|
+
from: cwd,
|
|
319
|
+
try: true
|
|
320
|
+
}) || cwd })).href)).loading || ((params) => `<h2>${params.loading}</h2>`);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region ../nuxi/src/dev/index.ts
|
|
325
|
+
const start = Date.now();
|
|
326
|
+
process.env.NODE_ENV = "development";
|
|
327
|
+
var IPC = class {
|
|
328
|
+
enabled = !!process.send && !process.title?.includes("vitest") && process.env.__NUXT__FORK;
|
|
329
|
+
constructor() {
|
|
330
|
+
if (this.enabled) process.once("unhandledRejection", (reason) => {
|
|
331
|
+
this.send({
|
|
332
|
+
type: "nuxt:internal:dev:rejection",
|
|
333
|
+
message: reason instanceof Error ? reason.toString() : "Unhandled Rejection"
|
|
334
|
+
});
|
|
335
|
+
process.exit();
|
|
336
|
+
});
|
|
337
|
+
process.on("message", (message) => {
|
|
338
|
+
if (message.type === "nuxt:internal:dev:context") initialize(message.context, {}, message.socket ? void 0 : true);
|
|
339
|
+
});
|
|
340
|
+
this.send({ type: "nuxt:internal:dev:fork-ready" });
|
|
341
|
+
}
|
|
342
|
+
send(message) {
|
|
343
|
+
if (this.enabled) process.send?.(message);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const ipc = new IPC();
|
|
347
|
+
async function initialize(devContext, ctx = {}, _listenOptions) {
|
|
348
|
+
const devServerOverrides = resolveDevServerOverrides({ public: devContext.public });
|
|
349
|
+
const devServerDefaults = resolveDevServerDefaults({
|
|
350
|
+
hostname: devContext.hostname,
|
|
351
|
+
https: devContext.proxy?.https
|
|
352
|
+
}, devContext.publicURLs);
|
|
353
|
+
const devServer = new NuxtDevServer({
|
|
354
|
+
cwd: devContext.cwd,
|
|
355
|
+
overrides: defu(ctx.data?.overrides, { extends: devContext.args.extends }, devServerOverrides),
|
|
356
|
+
defaults: devServerDefaults,
|
|
357
|
+
logLevel: devContext.args.logLevel,
|
|
358
|
+
clear: devContext.args.clear,
|
|
359
|
+
dotenv: {
|
|
360
|
+
cwd: devContext.cwd,
|
|
361
|
+
fileName: devContext.args.dotenv
|
|
362
|
+
},
|
|
363
|
+
envName: devContext.args.envName,
|
|
364
|
+
devContext: { proxy: devContext.proxy }
|
|
365
|
+
});
|
|
366
|
+
const listenOptions = _listenOptions === true || process.env._PORT ? {
|
|
367
|
+
port: process.env._PORT ?? 0,
|
|
368
|
+
hostname: "127.0.0.1",
|
|
369
|
+
showURL: false
|
|
370
|
+
} : _listenOptions;
|
|
371
|
+
devServer.listener = listenOptions ? await listen(devServer.handler, listenOptions) : await createSocketListener(devServer.handler, devContext.proxy?.addr);
|
|
372
|
+
if (process.env.DEBUG) console.debug(`Using ${listenOptions ? "network" : "socket"} listener for Nuxt dev server.`);
|
|
373
|
+
devServer.listener._url = devServer.listener.url;
|
|
374
|
+
if (devContext.proxy?.url) devServer.listener.url = devContext.proxy.url;
|
|
375
|
+
if (devContext.proxy?.urls) {
|
|
376
|
+
const _getURLs = devServer.listener.getURLs.bind(devServer.listener);
|
|
377
|
+
devServer.listener.getURLs = async () => Array.from(new Set([...devContext.proxy?.urls || [], ...await _getURLs()]));
|
|
378
|
+
}
|
|
379
|
+
let address;
|
|
380
|
+
if (ipc.enabled) {
|
|
381
|
+
devServer.on("loading:error", (_error) => {
|
|
382
|
+
ipc.send({
|
|
383
|
+
type: "nuxt:internal:dev:loading:error",
|
|
384
|
+
error: {
|
|
385
|
+
message: _error.message,
|
|
386
|
+
stack: _error.stack,
|
|
387
|
+
name: _error.name,
|
|
388
|
+
code: "code" in _error ? _error.code : void 0
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
devServer.on("loading", (message) => {
|
|
393
|
+
ipc.send({
|
|
394
|
+
type: "nuxt:internal:dev:loading",
|
|
395
|
+
message
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
devServer.on("restart", () => {
|
|
399
|
+
ipc.send({ type: "nuxt:internal:dev:restart" });
|
|
400
|
+
});
|
|
401
|
+
devServer.on("ready", (payload) => {
|
|
402
|
+
ipc.send({
|
|
403
|
+
type: "nuxt:internal:dev:ready",
|
|
404
|
+
address: payload
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
} else devServer.on("ready", (payload) => {
|
|
408
|
+
address = payload;
|
|
409
|
+
});
|
|
410
|
+
await devServer.init();
|
|
411
|
+
if (process.env.DEBUG) console.debug(`Dev server (internal) initialized in ${Date.now() - start}ms`);
|
|
412
|
+
return {
|
|
413
|
+
listener: devServer.listener,
|
|
414
|
+
close: async () => {
|
|
415
|
+
devServer.closeWatchers();
|
|
416
|
+
await devServer.close();
|
|
417
|
+
},
|
|
418
|
+
onReady: (callback) => {
|
|
419
|
+
if (address) callback(address);
|
|
420
|
+
else devServer.once("ready", (payload) => callback(payload));
|
|
421
|
+
},
|
|
422
|
+
onRestart: (callback) => {
|
|
423
|
+
let restarted = false;
|
|
424
|
+
function restart() {
|
|
425
|
+
if (!restarted) {
|
|
426
|
+
restarted = true;
|
|
427
|
+
callback(devServer);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
devServer.once("restart", restart);
|
|
431
|
+
process.once("uncaughtException", restart);
|
|
432
|
+
process.once("unhandledRejection", restart);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
//#endregion
|
|
438
|
+
export { parseSocketURL as a, isSocketURL as i, resolveLoadingTemplate as n, renderError as r, initialize as t };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { a as legacyRootDirArgs, n as dotEnvArgs, o as logLevelArgs, r as envNameArgs, t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { defineCommand } from "citty";
|
|
4
|
+
import { isTest } from "std-env";
|
|
5
|
+
import { resolve } from "pathe";
|
|
6
|
+
|
|
7
|
+
//#region ../nuxi/src/commands/dev-child.ts
|
|
8
|
+
var dev_child_default = defineCommand({
|
|
9
|
+
meta: {
|
|
10
|
+
name: "_dev",
|
|
11
|
+
description: "Run Nuxt development server (internal command to start child process)"
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
...cwdArgs,
|
|
15
|
+
...logLevelArgs,
|
|
16
|
+
...envNameArgs,
|
|
17
|
+
...dotEnvArgs,
|
|
18
|
+
...legacyRootDirArgs,
|
|
19
|
+
clear: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
description: "Clear console on restart",
|
|
22
|
+
negativeDescription: "Disable clear console on restart"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
async run(ctx) {
|
|
26
|
+
if (!process.send && !isTest) console.warn("`nuxi _dev` is an internal command and should not be used directly. Please use `nuxi dev` instead.");
|
|
27
|
+
const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
|
|
28
|
+
const { initialize } = await import("./dev-CnQwDUaD.mjs");
|
|
29
|
+
await initialize({
|
|
30
|
+
cwd,
|
|
31
|
+
args: ctx.args
|
|
32
|
+
}, ctx);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { dev_child_default as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { a as legacyRootDirArgs, t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
+
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
import { resolve } from "pathe";
|
|
6
|
+
import { x } from "tinyexec";
|
|
7
|
+
|
|
8
|
+
//#region ../nuxi/src/commands/devtools.ts
|
|
9
|
+
var devtools_default = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "devtools",
|
|
12
|
+
description: "Enable or disable devtools in a Nuxt project"
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
...cwdArgs,
|
|
16
|
+
command: {
|
|
17
|
+
type: "positional",
|
|
18
|
+
description: "Command to run",
|
|
19
|
+
valueHint: "enable|disable"
|
|
20
|
+
},
|
|
21
|
+
...legacyRootDirArgs
|
|
22
|
+
},
|
|
23
|
+
async run(ctx) {
|
|
24
|
+
const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
|
|
25
|
+
if (!["enable", "disable"].includes(ctx.args.command)) {
|
|
26
|
+
logger.error(`Unknown command \`${ctx.args.command}\`.`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
await x("npx", [
|
|
30
|
+
"@nuxt/devtools-wizard@latest",
|
|
31
|
+
ctx.args.command,
|
|
32
|
+
cwd
|
|
33
|
+
], {
|
|
34
|
+
throwOnError: true,
|
|
35
|
+
nodeOptions: {
|
|
36
|
+
stdio: "inherit",
|
|
37
|
+
cwd
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { devtools_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
|
|
4
|
+
//#region ../nuxi/src/utils/env.ts
|
|
5
|
+
function overrideEnv(targetEnv) {
|
|
6
|
+
const currentEnv = process.env.NODE_ENV;
|
|
7
|
+
if (currentEnv && currentEnv !== targetEnv) logger.warn(`Changing \`NODE_ENV\` from \`${currentEnv}\` to \`${targetEnv}\`, to avoid unintended behavior.`);
|
|
8
|
+
process.env.NODE_ENV = targetEnv;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { overrideEnv as t };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
2
|
+
import { existsSync, promises } from "node:fs";
|
|
3
|
+
import { join } from "pathe";
|
|
4
|
+
|
|
5
|
+
//#region ../nuxi/src/utils/fs.ts
|
|
6
|
+
async function clearDir(path, exclude) {
|
|
7
|
+
if (!exclude) await promises.rm(path, {
|
|
8
|
+
recursive: true,
|
|
9
|
+
force: true
|
|
10
|
+
});
|
|
11
|
+
else if (existsSync(path)) {
|
|
12
|
+
const files = await promises.readdir(path);
|
|
13
|
+
await Promise.all(files.map(async (name) => {
|
|
14
|
+
if (!exclude.includes(name)) await promises.rm(join(path, name), {
|
|
15
|
+
recursive: true,
|
|
16
|
+
force: true
|
|
17
|
+
});
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
await promises.mkdir(path, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
function clearBuildDir(path) {
|
|
23
|
+
return clearDir(path, [
|
|
24
|
+
"cache",
|
|
25
|
+
"analyze",
|
|
26
|
+
"nuxt.json"
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
async function rmRecursive(paths) {
|
|
30
|
+
await Promise.all(paths.filter((p) => typeof p === "string").map(async (path) => {
|
|
31
|
+
logger.debug("Removing recursive path", path);
|
|
32
|
+
await promises.rm(path, {
|
|
33
|
+
recursive: true,
|
|
34
|
+
force: true
|
|
35
|
+
}).catch(() => {});
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { clearDir as n, rmRecursive as r, clearBuildDir as t };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { a as legacyRootDirArgs, i as extendsArgs, n as dotEnvArgs, o as logLevelArgs, r as envNameArgs, t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
+
import "./logger-Dk0gkCkX.mjs";
|
|
3
|
+
import "./fs-ewAp6tjM.mjs";
|
|
4
|
+
import "./kit-xFxVGu6d.mjs";
|
|
5
|
+
import "./env-Dz4K_NkM.mjs";
|
|
6
|
+
import "./banner-CqfM_0Qo.mjs";
|
|
7
|
+
import { t as build_default } from "./build-BSxJLNs_.mjs";
|
|
8
|
+
import { defineCommand } from "citty";
|
|
9
|
+
|
|
10
|
+
//#region ../nuxi/src/commands/generate.ts
|
|
11
|
+
var generate_default = defineCommand({
|
|
12
|
+
meta: {
|
|
13
|
+
name: "generate",
|
|
14
|
+
description: "Build Nuxt and prerender all routes"
|
|
15
|
+
},
|
|
16
|
+
args: {
|
|
17
|
+
...cwdArgs,
|
|
18
|
+
...logLevelArgs,
|
|
19
|
+
preset: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Nitro server preset"
|
|
22
|
+
},
|
|
23
|
+
...dotEnvArgs,
|
|
24
|
+
...envNameArgs,
|
|
25
|
+
...extendsArgs,
|
|
26
|
+
...legacyRootDirArgs
|
|
27
|
+
},
|
|
28
|
+
async run(ctx) {
|
|
29
|
+
ctx.args.prerender = true;
|
|
30
|
+
await build_default.run(ctx);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { generate_default as default };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare const main: citty.CommandDef<{
|
|
4
|
-
command: {
|
|
5
|
-
type: "positional";
|
|
6
|
-
required: false;
|
|
7
|
-
};
|
|
8
|
-
cwd: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly description: "Specify the working directory";
|
|
11
|
-
readonly valueHint: "directory";
|
|
12
|
-
readonly default: ".";
|
|
13
|
-
};
|
|
14
|
-
}>;
|
|
1
|
+
import { CommandDef } from "citty";
|
|
15
2
|
|
|
3
|
+
//#region src/main.d.ts
|
|
4
|
+
declare const main: CommandDef<any>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/run.d.ts
|
|
16
7
|
declare const runMain: () => Promise<void>;
|
|
17
8
|
declare function runCommand(name: string, argv?: string[], data?: {
|
|
18
|
-
|
|
9
|
+
overrides?: Record<string, any>;
|
|
19
10
|
}): Promise<{
|
|
20
|
-
|
|
11
|
+
result: unknown;
|
|
21
12
|
}>;
|
|
22
|
-
|
|
23
|
-
export { main, runCommand, runMain };
|
|
13
|
+
//#endregion
|
|
14
|
+
export { main, runCommand, runMain };
|