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