initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions
+153
View File
@@ -0,0 +1,153 @@
import { existsSync, promises } from 'node:fs';
import { c as consola } from '../shared/nuxi.b2fdb45d.mjs';
import { l as loadKit } from '../shared/nuxi.8cc4a579.mjs';
import { u as upperFirst } from '../shared/nuxi.e5ae87db.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve, d as dirname } from '../shared/nuxi.a2d9d2e1.mjs';
import '../shared/nuxi.ed696fbc.mjs';
import 'util';
import 'path';
import 'fs';
import 'os';
import 'tty';
import '../shared/nuxi.e551a86b.mjs';
import 'node:module';
import 'node:url';
const httpMethods = ["connect", "delete", "get", "head", "options", "post", "put", "trace", "patch"];
const api = ({ name, args }) => ({
path: `server/api/${name}${applySuffix(args, httpMethods, "method")}.ts`,
contents: `
export default defineEventHandler((event) => {
return 'Hello ${name}'
})
`
});
const plugin = ({ name, args }) => ({
path: `plugins/${name}${applySuffix(args, ["client", "server"], "mode")}.ts`,
contents: `
export default defineNuxtPlugin((nuxtApp) => {})
`
});
const component = ({ name, args }) => ({
path: `components/${name}${applySuffix(args, ["client", "server"], "mode")}.vue`,
contents: `
<script lang="ts" setup><\/script>
<template>
<div>
Component: ${name}
</div>
</template>
<style scoped></style>
`
});
const composable = ({ name }) => {
const nameWithUsePrefix = name.startsWith("use") ? name : `use${upperFirst(name)}`;
return {
path: `composables/${name}.ts`,
contents: `
export const ${nameWithUsePrefix} = () => {
return ref()
}
`
};
};
const middleware = ({ name, args }) => ({
path: `middleware/${name}${applySuffix(args, ["global"])}.ts`,
contents: `
export default defineNuxtRouteMiddleware((to, from) => {})
`
});
const layout = ({ name }) => ({
path: `layouts/${name}.vue`,
contents: `
<script lang="ts" setup><\/script>
<template>
<div>
Layout: ${name}
<slot />
</div>
</template>
<style scoped></style>
`
});
const page = ({ name }) => ({
path: `pages/${name}.vue`,
contents: `
<script lang="ts" setup><\/script>
<template>
<div>
Page: foo
</div>
</template>
<style scoped></style>
`
});
const templates = {
api,
plugin,
component,
composable,
middleware,
layout,
page
};
function applySuffix(args, suffixes, unwrapFrom) {
let suffix = "";
for (const s of suffixes) {
if (args[s]) {
suffix += "." + s;
}
}
if (unwrapFrom && args[unwrapFrom] && suffixes.includes(args[unwrapFrom])) {
suffix += "." + args[unwrapFrom];
}
return suffix;
}
const add = defineNuxtCommand({
meta: {
name: "add",
usage: `npx nuxi add [--cwd] [--force] ${Object.keys(templates).join("|")} <name>`,
description: "Create a new template file."
},
async invoke(args) {
const cwd = resolve(args.cwd || ".");
const template = args._[0];
const name = args._[1];
if (!templates[template]) {
consola.error(`Template ${template} is not supported. Possible values: ${Object.keys(templates).join(", ")}`);
process.exit(1);
}
if (!name) {
consola.error("name argument is missing!");
process.exit(1);
}
const kit = await loadKit(cwd);
const config = await kit.loadNuxtConfig({ cwd });
const res = templates[template]({ name, args });
const path = resolve(config.srcDir, res.path);
if (!args.force && existsSync(path)) {
consola.error(`File exists: ${path} . Use --force to override or use a different name.`);
process.exit(1);
}
const parentDir = dirname(path);
if (!existsSync(parentDir)) {
consola.info("Creating directory", parentDir);
if (template === "page") {
consola.info("This enables vue-router functionality!");
}
await promises.mkdir(parentDir, { recursive: true });
}
await promises.writeFile(path, res.contents.trim() + "\n");
consola.info(`\u{1FA84} Generated a new ${template} in ${path}`);
}
});
export { add as default };
+89
View File
@@ -0,0 +1,89 @@
import { promises } from 'node:fs';
import { createApp, eventHandler, toNodeListener, lazyEventHandler } from './index2.mjs';
import { listen } from './index.mjs';
import { w as writeTypes } from '../shared/nuxi.30988785.mjs';
import { l as loadKit } from '../shared/nuxi.8cc4a579.mjs';
import { c as clearDir } from '../shared/nuxi.74850c25.mjs';
import { o as overrideEnv } from '../shared/nuxi.d21ab543.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve, j as join } from '../shared/nuxi.a2d9d2e1.mjs';
import '../shared/nuxi.af709901.mjs';
import '../shared/nuxi.e90bf846.mjs';
import 'node:http';
import 'node:https';
import 'node:util';
import 'node:os';
import '../shared/nuxi.a3b9dacd.mjs';
import 'tty';
import 'net';
import 'os';
import 'fs';
import 'path';
import 'http';
import 'https';
import '../shared/nuxi.d0ea9d71.mjs';
import 'node:child_process';
import 'node:path';
import '../shared/nuxi.e551a86b.mjs';
import 'node:module';
import 'node:url';
import '../shared/nuxi.b2fdb45d.mjs';
import '../shared/nuxi.ed696fbc.mjs';
import 'util';
const analyze = defineNuxtCommand({
meta: {
name: "analyze",
usage: "npx nuxi analyze [rootDir]",
description: "Build nuxt and analyze production bundle (experimental)"
},
async invoke(args) {
overrideEnv("production");
const rootDir = resolve(args._[0] || ".");
const statsDir = join(rootDir, ".nuxt/stats");
const { loadNuxt, buildNuxt } = await loadKit(rootDir);
const nuxt = await loadNuxt({
rootDir,
config: {
build: {
analyze: true
}
}
});
await clearDir(nuxt.options.buildDir);
await writeTypes(nuxt);
await buildNuxt(nuxt);
const app = createApp();
const serveFile = (filePath) => lazyEventHandler(async () => {
const contents = await promises.readFile(filePath, "utf-8");
return eventHandler((event) => {
event.node.res.end(contents);
});
});
console.warn("Do not deploy analyze results! Use `nuxi build` before deploying.");
console.info("Starting stats server...");
app.use("/client", serveFile(join(statsDir, "client.html")));
app.use("/nitro", serveFile(join(statsDir, "nitro.html")));
app.use(eventHandler(() => `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Nuxt Bundle Stats (experimental)</title>
</head>
<h1>Nuxt Bundle Stats (experimental)</h1>
<ul>
<li>
<a href="/nitro">Nitro server bundle stats</a>
</li>
<li>
<a href="/client">Client bundle stats</a>
</li>
</ul>
</html>
`));
await listen(toNodeListener(app));
return "wait";
}
});
export { analyze as default };
+49
View File
@@ -0,0 +1,49 @@
import { e as execa } from '../shared/nuxi.6b390535.mjs';
import { c as consola } from '../shared/nuxi.b2fdb45d.mjs';
import { b as tryResolveModule } from '../shared/nuxi.e551a86b.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve } from '../shared/nuxi.a2d9d2e1.mjs';
import 'node:buffer';
import 'node:path';
import 'node:child_process';
import 'node:process';
import '../shared/nuxi.30bccfab.mjs';
import 'child_process';
import 'path';
import '../shared/nuxi.ed696fbc.mjs';
import 'fs';
import 'assert';
import 'events';
import 'buffer';
import 'stream';
import 'util';
import 'node:url';
import 'os';
import 'node:os';
import 'tty';
import 'node:module';
const MODULE_BUILDER_PKG = "@nuxt/module-builder";
const buildModule = defineNuxtCommand({
meta: {
name: "build-module",
usage: "npx nuxi build-module [--stub] [rootDir]",
description: `Helper command for using ${MODULE_BUILDER_PKG}`
},
async invoke(args) {
const rootDir = resolve(args._[0] || ".");
const hasLocal = tryResolveModule(`${MODULE_BUILDER_PKG}/package.json`, rootDir);
const execArgs = Object.entries({
"--stub": args.stub
}).filter(([, value]) => value).map(([key]) => key);
let cmd = "nuxt-module-build";
if (!hasLocal) {
consola.warn(`Cannot find locally installed version of \`${MODULE_BUILDER_PKG}\` (>=0.2.0). Falling back to \`npx ${MODULE_BUILDER_PKG}\``);
cmd = "npx";
execArgs.unshift(MODULE_BUILDER_PKG);
}
await execa(cmd, execArgs, { preferLocal: true, stdio: "inherit", cwd: rootDir });
}
});
export { buildModule as default };
+65
View File
@@ -0,0 +1,65 @@
import { c as consola } from '../shared/nuxi.b2fdb45d.mjs';
import { w as writeTypes } from '../shared/nuxi.30988785.mjs';
import { l as loadKit } from '../shared/nuxi.8cc4a579.mjs';
import { c as clearDir } from '../shared/nuxi.74850c25.mjs';
import { o as overrideEnv } from '../shared/nuxi.d21ab543.mjs';
import { a as showVersions } from '../shared/nuxi.1b1e0b8b.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve, a as relative } from '../shared/nuxi.a2d9d2e1.mjs';
import '../shared/nuxi.ed696fbc.mjs';
import 'util';
import 'path';
import 'fs';
import 'os';
import 'tty';
import 'node:fs';
import '../shared/nuxi.d0ea9d71.mjs';
import '../shared/nuxi.e551a86b.mjs';
import 'node:module';
import 'node:url';
import 'assert';
import '../shared/nuxi.a3b9dacd.mjs';
const buildCommand = defineNuxtCommand({
meta: {
name: "build",
usage: "npx nuxi build [--prerender] [--dotenv] [rootDir]",
description: "Build nuxt for production deployment"
},
async invoke(args) {
overrideEnv("production");
const rootDir = resolve(args._[0] || ".");
showVersions(rootDir);
const { loadNuxt, buildNuxt, useNitro } = await loadKit(rootDir);
const nuxt = await loadNuxt({
rootDir,
dotenv: {
cwd: rootDir,
fileName: args.dotenv
},
defaults: {
experimental: {
payloadExtraction: args.prerender ? true : void 0
}
},
overrides: {
_generate: args.prerender
}
});
const nitro = useNitro?.();
await clearDir(nuxt.options.buildDir);
await writeTypes(nuxt);
nuxt.hook("build:error", (err) => {
consola.error("Nuxt Build Error:", err);
process.exit(1);
});
await buildNuxt(nuxt);
if (args.prerender) {
const dir = nitro?.options.output.publicDir;
const publicDir = dir ? relative(process.cwd(), dir) : ".output/public";
consola.success(`You can now deploy \`${publicDir}\` to any static hosting!`);
}
}
});
export { buildCommand as default };
+28117
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -0,0 +1,26 @@
import { c as cleanupNuxtDirs } from '../shared/nuxi.8adf0664.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve } from '../shared/nuxi.a2d9d2e1.mjs';
import 'node:fs';
import '../shared/nuxi.b2fdb45d.mjs';
import '../shared/nuxi.ed696fbc.mjs';
import 'util';
import 'path';
import 'fs';
import 'os';
import 'tty';
import '../shared/nuxi.74850c25.mjs';
const cleanup = defineNuxtCommand({
meta: {
name: "cleanup",
usage: "npx nuxi clean|cleanup",
description: "Cleanup generated nuxt files and caches"
},
async invoke(args) {
const rootDir = resolve(args._[0] || ".");
await cleanupNuxtDirs(rootDir);
}
});
export { cleanup as default };
+6845
View File
File diff suppressed because it is too large Load Diff
+36
View File
@@ -0,0 +1,36 @@
import buildCommand from './build.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import '../shared/nuxi.b2fdb45d.mjs';
import '../shared/nuxi.ed696fbc.mjs';
import 'util';
import 'path';
import 'fs';
import 'os';
import 'tty';
import '../shared/nuxi.30988785.mjs';
import 'node:fs';
import '../shared/nuxi.d0ea9d71.mjs';
import '../shared/nuxi.e551a86b.mjs';
import 'node:module';
import 'node:url';
import '../shared/nuxi.a2d9d2e1.mjs';
import '../shared/nuxi.8cc4a579.mjs';
import '../shared/nuxi.74850c25.mjs';
import '../shared/nuxi.d21ab543.mjs';
import '../shared/nuxi.1b1e0b8b.mjs';
import 'assert';
import '../shared/nuxi.a3b9dacd.mjs';
const generate = defineNuxtCommand({
meta: {
name: "generate",
usage: "npx nuxi generate [rootDir]",
description: "Build Nuxt and prerender static routes"
},
async invoke(args) {
args.prerender = true;
await buildCommand.invoke(args);
}
});
export { generate as default };
+824
View File
@@ -0,0 +1,824 @@
import { createServer as createServer$2 } from 'node:http';
import { createServer as createServer$1 } from 'node:https';
import { promisify } from 'node:util';
import { promises, existsSync, writeFileSync, chmodSync, readFileSync, constants, statSync } from 'node:fs';
import os, { networkInterfaces as networkInterfaces$1 } from 'node:os';
import { g as gray, c as cyan, u as underline, b as bold } from '../shared/nuxi.a3b9dacd.mjs';
import { createServer } from 'net';
import { networkInterfaces } from 'os';
import require$$0 from 'fs';
import require$$0$1 from 'path';
import require$$0$2 from 'http';
import require$$1 from 'https';
import { d as defu } from '../shared/nuxi.d0ea9d71.mjs';
import childProcess from 'node:child_process';
import { join } from 'node:path';
import 'tty';
var dist = {};
Object.defineProperty(dist, '__esModule', { value: true });
const fs = require$$0;
const path = require$$0$1;
const _memo = {
_pid: process.pid
};
async function getMemo(config) {
const options = getOptions(config);
try {
const memo = JSON.parse(await fs.promises.readFile(options.file, "utf-8")) || {};
if (!memo._pid) {
throw new Error("Memo lacks _pid");
}
if (memo._pid === _memo._pid || !isAlive(memo.pid)) {
Object.assign(_memo, memo);
_memo._pid = process.pid;
}
} catch (e) {
}
return _memo;
}
async function setMemo(memo, config) {
const options = getOptions(config);
Object.assign(_memo, memo);
_memo._pid = process.pid;
try {
await fs.promises.mkdir(options.dir);
} catch (e) {
}
try {
await fs.promises.writeFile(options.file, JSON.stringify(_memo), "utf-8");
} catch (e) {
}
}
function getOptions(config) {
const options = {...config};
options.name = options.name || "default";
options.dir = options.dir || path.resolve(process.cwd(), "node_modules/.cache/fs-memo");
options.file = options.file || path.resolve(options.dir, options.name + ".json");
return options;
}
function isAlive(pid) {
try {
process.kill(pid, 0);
return true;
} catch (e) {
return e.code === "EPERM";
}
}
var getMemo_1 = dist.getMemo = getMemo;
var setMemo_1 = dist.setMemo = setMemo;
const unsafePorts = /* @__PURE__ */ new Set([
1,
7,
9,
11,
13,
15,
17,
19,
20,
21,
22,
23,
25,
37,
42,
43,
53,
69,
77,
79,
87,
95,
101,
102,
103,
104,
109,
110,
111,
113,
115,
117,
119,
123,
135,
137,
139,
143,
161,
179,
389,
427,
465,
512,
513,
514,
515,
526,
530,
531,
532,
540,
548,
554,
556,
563,
587,
601,
636,
989,
990,
993,
995,
1719,
1720,
1723,
2049,
3659,
4045,
5060,
5061,
6e3,
6566,
6665,
6666,
6667,
6668,
6669,
6697,
10080
]);
function isUnsafePort(port) {
return unsafePorts.has(port);
}
function isSafePort(port) {
return !isUnsafePort(port);
}
function log(...args) {
console.log("[get-port]", ...args);
}
async function getPort(config = {}) {
if (typeof config === "number" || typeof config === "string") {
config = { port: parseInt(config + "") || 0 };
}
const options = {
name: "default",
random: false,
ports: [],
portRange: [],
alternativePortRange: [3e3, 3100],
host: void 0,
memoName: "port",
verbose: false,
...config,
port: parseInt(process.env.PORT || "") || config.port || 3e3
};
if (options.random) {
return getRandomPort(options.host);
}
const portsToCheck = [
options.port,
...options.ports,
...generateRange(...options.portRange)
].filter((port) => {
if (!port) {
return false;
}
if (!isSafePort(port)) {
if (options.verbose) {
log("Ignoring unsafe port:", port);
}
return false;
}
return true;
});
const memoOptions = { name: options.memoName, dir: options.memoDir };
const memoKey = "port_" + options.name;
const memo = await getMemo_1(memoOptions);
if (memo[memoKey]) {
portsToCheck.push(memo[memoKey]);
}
let availablePort = await findPort(portsToCheck, options.host, options.verbose, false);
if (!availablePort) {
availablePort = await findPort(generateRange(...options.alternativePortRange), options.host, options.verbose);
if (options.verbose) {
log(`Unable to find an available port (tried ${portsToCheck.join(", ") || "-"}). Using alternative port:`, availablePort);
}
}
await setMemo_1({ [memoKey]: availablePort }, memoOptions);
return availablePort;
}
async function getRandomPort(host) {
const port = await checkPort(0, host);
if (port === false) {
throw new Error("Unable to obtain an available random port number!");
}
return port;
}
async function checkPort(port, host = process.env.HOST, _verbose) {
if (!host) {
host = getLocalHosts([void 0, "0.0.0.0"]);
}
if (!Array.isArray(host)) {
return _checkPort(port, host);
}
for (const _host of host) {
const _port = await _checkPort(port, _host);
if (_port === false) {
if (port < 1024 && _verbose) {
log("Unable to listen to priviliged port:", `${_host}:${port}`);
}
return false;
}
if (port === 0 && _port !== 0) {
port = _port;
}
}
return port;
}
function generateRange(from, to) {
if (to < from) {
return [];
}
const r = [];
for (let i = from; i < to; i++) {
r.push(i);
}
return r;
}
function _checkPort(port, host) {
return new Promise((resolve) => {
const server = createServer();
server.unref();
server.on("error", (err) => {
if (err.code === "EINVAL" || err.code === "EADDRNOTAVAIL") {
resolve(port !== 0 && isSafePort(port) && port);
} else {
resolve(false);
}
});
server.listen({ port, host }, () => {
const { port: port2 } = server.address();
server.close(() => {
resolve(isSafePort(port2) && port2);
});
});
});
}
function getLocalHosts(additional) {
const hosts = new Set(additional);
for (const _interface of Object.values(networkInterfaces())) {
for (const config of _interface) {
hosts.add(config.address);
}
}
return Array.from(hosts);
}
async function findPort(ports, host, _verbose = false, _random = true) {
for (const port of ports) {
const r = await checkPort(port, host, _verbose);
if (r) {
return r;
}
}
if (_random) {
const randomPort = await getRandomPort(host);
if (_verbose) {
log(`Unable to find an available port (tried ${ports.join(", ") || "-"}). Using random port:`, randomPort);
}
return randomPort;
} else {
return 0;
}
}
var httpShutdown = {exports: {}};
(function (module, exports) {
var http = require$$0$2;
var https = require$$1;
/**
* Expose `addShutdown`.
*/
exports = module.exports = addShutdown;
/**
* Adds shutdown functionaility to the `http.Server` object
* @param {http.Server} server The server to add shutdown functionaility to
*/
function addShutdown(server) {
var connections = {};
var isShuttingDown = false;
var connectionCounter = 0;
function destroy(socket, force) {
if (force || (socket._isIdle && isShuttingDown)) {
socket.destroy();
delete connections[socket._connectionId];
}
}
function onConnection(socket) {
var id = connectionCounter++;
socket._isIdle = true;
socket._connectionId = id;
connections[id] = socket;
socket.on('close', function() {
delete connections[id];
});
}
server.on('request', function(req, res) {
req.socket._isIdle = false;
res.on('finish', function() {
req.socket._isIdle = true;
destroy(req.socket);
});
});
server.on('connection', onConnection);
server.on('secureConnection', onConnection);
function shutdown(force, cb) {
isShuttingDown = true;
server.close(function(err) {
if (cb) {
process.nextTick(function() { cb(err); });
}
});
Object.keys(connections).forEach(function(key) {
destroy(connections[key], force);
});
}
server.shutdown = function(cb) {
shutdown(false, cb);
};
server.forceShutdown = function(cb) {
shutdown(true, cb);
};
return server;
}
/**
* Extends the {http.Server} object with shutdown functionaility.
* @return {http.Server} The decorated server object
*/
exports.extend = function() {
http.Server.prototype.withShutdown = function() {
return addShutdown(this);
};
https.Server.prototype.withShutdown = function() {
return addShutdown(this);
};
};
} (httpShutdown, httpShutdown.exports));
const addShutdown = httpShutdown.exports;
const { platform, arch } = process;
const getWslDrivesMountPoint = (() => {
const defaultMountPoint = "/mnt/";
let mountPoint;
return async function() {
if (mountPoint) {
return mountPoint;
}
const configFilePath = "/etc/wsl.conf";
let isConfigFileExists = false;
try {
await promises.access(configFilePath, constants.F_OK);
isConfigFileExists = true;
} catch {
}
if (!isConfigFileExists) {
return defaultMountPoint;
}
const configContent = await promises.readFile(configFilePath, { encoding: "utf8" });
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
if (!configMountPoint) {
return defaultMountPoint;
}
mountPoint = configMountPoint.groups.mountPoint.trim();
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
return mountPoint;
};
})();
const pTryEach = async (array, mapper) => {
let latestError;
for (const item of array) {
try {
return await mapper(item);
} catch (error) {
latestError = error;
}
}
throw latestError;
};
const baseOpen = async (options) => {
options = {
wait: false,
background: false,
newInstance: false,
allowNonzeroExitCode: false,
...options
};
if (Array.isArray(options.app)) {
return pTryEach(options.app, (singleApp) => baseOpen({
...options,
app: singleApp
}));
}
let { name: app, arguments: appArguments = [] } = options.app || {};
appArguments = [...appArguments];
if (Array.isArray(app)) {
return pTryEach(app, (appName) => baseOpen({
...options,
app: {
name: appName,
arguments: appArguments
}
}));
}
let command;
const cliArguments = [];
const childProcessOptions = {};
if (platform === "darwin") {
command = "open";
if (options.wait) {
cliArguments.push("--wait-apps");
}
if (options.background) {
cliArguments.push("--background");
}
if (options.newInstance) {
cliArguments.push("--new");
}
if (app) {
cliArguments.push("-a", app);
}
} else if (platform === "win32" || isWsl() && !isDocker()) {
const mountPoint = await getWslDrivesMountPoint();
command = isWsl() ? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
cliArguments.push(
"-NoProfile",
"-NonInteractive",
"\u2013ExecutionPolicy",
"Bypass",
"-EncodedCommand"
);
if (!isWsl()) {
childProcessOptions.windowsVerbatimArguments = true;
}
const encodedArguments = ["Start"];
if (options.wait) {
encodedArguments.push("-Wait");
}
if (app) {
encodedArguments.push(`"\`"${app}\`""`, "-ArgumentList");
if (options.target) {
appArguments.unshift(options.target);
}
} else if (options.target) {
encodedArguments.push(`"${options.target}"`);
}
if (appArguments.length > 0) {
appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
encodedArguments.push(appArguments.join(","));
}
options.target = Buffer.from(encodedArguments.join(" "), "utf16le").toString("base64");
} else {
if (app) {
command = app;
} else {
command = "xdg-open";
const useSystemXdgOpen = process.versions.electron || platform === "android";
if (!useSystemXdgOpen) {
command = join(os.tmpdir(), "xdg-open");
if (!existsSync(command)) {
try {
writeFileSync(
join(os.tmpdir(), "xdg-open"),
await import('./xdg-open.mjs').then((r) => r.xdgOpenScript()),
"utf8"
);
chmodSync(command, 493);
} catch {
command = "xdg-open";
}
}
}
}
if (appArguments.length > 0) {
cliArguments.push(...appArguments);
}
if (!options.wait) {
childProcessOptions.stdio = "ignore";
childProcessOptions.detached = true;
}
}
if (options.target) {
cliArguments.push(options.target);
}
if (platform === "darwin" && appArguments.length > 0) {
cliArguments.push("--args", ...appArguments);
}
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
if (options.wait) {
return new Promise((resolve, reject) => {
subprocess.once("error", reject);
subprocess.once("close", (exitCode) => {
if (options.allowNonzeroExitCode && exitCode > 0) {
reject(new Error(`Exited with code ${exitCode}`));
return;
}
resolve(subprocess);
});
});
}
subprocess.unref();
return subprocess;
};
const open = (target, options = {}) => {
if (typeof target !== "string") {
throw new TypeError("Expected a `target`");
}
return baseOpen({
...options,
target
});
};
const openApp = (name, options) => {
if (typeof name !== "string") {
throw new TypeError("Expected a `name`");
}
const { arguments: appArguments = [] } = options || {};
if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {
throw new TypeError("Expected `appArguments` as Array type");
}
return baseOpen({
...options,
app: {
name,
arguments: appArguments
}
});
};
function detectArchBinary(binary) {
if (typeof binary === "string" || Array.isArray(binary)) {
return binary;
}
const { [arch]: archBinary } = binary;
if (!archBinary) {
throw new Error(`${arch} is not supported`);
}
return archBinary;
}
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
if (wsl && isWsl()) {
return detectArchBinary(wsl);
}
if (!platformBinary) {
throw new Error(`${platform} is not supported`);
}
return detectArchBinary(platformBinary);
}
const apps = {};
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
darwin: "google chrome",
win32: "chrome",
linux: ["google-chrome", "google-chrome-stable", "chromium"]
}, {
wsl: {
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
}
}));
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
darwin: "firefox",
win32: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
linux: "firefox"
}, {
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
}));
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
darwin: "microsoft edge",
win32: "msedge",
linux: ["microsoft-edge", "microsoft-edge-dev"]
}, {
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
}));
open.apps = apps;
open.openApp = openApp;
function defineLazyProperty(object, propertyName, valueGetter) {
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
Object.defineProperty(object, propertyName, {
configurable: true,
enumerable: true,
get() {
const result = valueGetter();
define(result);
return result;
},
set(value) {
define(value);
}
});
return object;
}
function _isWsl() {
if (process.platform !== "linux") {
return false;
}
if (os.release().toLowerCase().includes("microsoft")) {
if (isDocker()) {
return false;
}
return true;
}
try {
return readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isDocker() : false;
} catch {
return false;
}
}
let isWSLCached;
function isWsl() {
if (isWSLCached === void 0) {
isWSLCached = _isWsl();
}
return isWSLCached;
}
function hasDockerEnvironment() {
try {
statSync("/.dockerenv");
return true;
} catch {
return false;
}
}
function hasDockerCGroup() {
try {
return readFileSync("/proc/self/cgroup", "utf8").includes("docker");
} catch {
return false;
}
}
let isDockerCached;
function isDocker() {
if (isDockerCached === void 0) {
isDockerCached = hasDockerEnvironment() || hasDockerCGroup();
}
return isDockerCached;
}
async function listen(handle, options_ = {}) {
options_ = defu(options_, {
port: process.env.PORT || 3e3,
hostname: process.env.HOST || "",
showURL: true,
baseURL: "/",
open: false,
clipboard: false,
isTest: process.env.NODE_ENV === "test",
isProd: process.env.NODE_ENV === "production",
autoClose: true
});
if (options_.isTest) {
options_.showURL = false;
}
if (options_.isProd || options_.isTest) {
options_.open = false;
options_.clipboard = false;
}
const port = await getPort({
port: Number(options_.port),
verbose: !options_.isTest,
host: options_.hostname
});
let server;
let addr;
const getURL = (host, baseURL) => {
const anyV4 = addr?.addr === "0.0.0.0";
const anyV6 = addr?.addr === "[::]";
return `${addr.proto}://${host || options_.hostname || (anyV4 || anyV6 ? "localhost" : addr.addr)}:${addr.port}${baseURL || options_.baseURL}`;
};
let https = false;
if (options_.https) {
const { key, cert } = await resolveCert({ ...options_.https }, options_.hostname);
https = { key, cert };
server = createServer$1({ key, cert }, handle);
addShutdown(server);
await promisify(server.listen.bind(server))(port, options_.hostname);
const _addr = server.address();
addr = { proto: "https", addr: formatAddress(_addr), port: _addr.port };
} else {
server = createServer$2(handle);
addShutdown(server);
await promisify(server.listen.bind(server))(port, options_.hostname);
const _addr = server.address();
addr = { proto: "http", addr: formatAddress(_addr), port: _addr.port };
}
let _closed = false;
const close = () => {
if (_closed) {
return Promise.resolve();
}
_closed = true;
return promisify(server.shutdown)();
};
if (options_.clipboard) {
const clipboardy = await import('./index3.mjs').then((r) => r.default || r);
await clipboardy.write(getURL()).catch(() => {
options_.clipboard = false;
});
}
const showURL = (options) => {
const add = options_.clipboard ? gray("(copied to clipboard)") : "";
const lines = [];
const baseURL = options?.baseURL || options_.baseURL || "";
const name = options?.name ? ` (${options.name})` : "";
const anyV4 = addr?.addr === "0.0.0.0";
const anyV6 = addr?.addr === "[::]";
if (anyV4 || anyV6) {
lines.push(` > Local${name}: ${formatURL(getURL("localhost", baseURL))} ${add}`);
for (const addr2 of getNetworkInterfaces(anyV4)) {
lines.push(` > Network${name}: ${formatURL(getURL(addr2, baseURL))}`);
}
} else {
lines.push(` > Listening${name}: ${formatURL(getURL(void 0, baseURL))} ${add}`);
}
console.log("\n" + lines.join("\n") + "\n");
};
if (options_.showURL) {
showURL();
}
const _open = async () => {
await open(getURL()).catch(() => {
});
};
if (options_.open) {
await _open();
}
if (options_.autoClose) {
process.on("exit", () => close());
}
return {
url: getURL(),
https,
server,
open: _open,
showURL,
close
};
}
async function resolveCert(options, host) {
if (options.key && options.cert) {
const isInline = (s = "") => s.startsWith("--");
const r = (s) => isInline(s) ? s : promises.readFile(s, "utf8");
return {
key: await r(options.key),
cert: await r(options.cert)
};
}
const { generateCA, generateSSLCert } = await import('./cert.mjs');
const ca = await generateCA();
const cert = await generateSSLCert({
caCert: ca.cert,
caKey: ca.key,
domains: options.domains || ["localhost", "127.0.0.1", "::1", host].filter(Boolean),
validityDays: options.validityDays || 1
});
return cert;
}
function getNetworkInterfaces(v4Only = true) {
const addrs = /* @__PURE__ */ new Set();
for (const details of Object.values(networkInterfaces$1())) {
if (details) {
for (const d of details) {
if (!d.internal && !(d.mac === "00:00:00:00:00:00") && !d.address.startsWith("fe80::") && !(v4Only && (d.family === "IPv6" || +d.family === 6))) {
addrs.add(formatAddress(d));
}
}
}
}
return [...addrs].sort();
}
function formatAddress(addr) {
return addr.family === "IPv6" || addr.family === 6 ? `[${addr.address}]` : addr.address;
}
function formatURL(url) {
return cyan(underline(decodeURI(url).replace(/:(\d+)\//g, `:${bold("$1")}/`)));
}
export { listen };
+1099
View File
File diff suppressed because it is too large Load Diff
+1591
View File
File diff suppressed because it is too large Load Diff
+2136
View File
File diff suppressed because one or more lines are too long
+15232
View File
File diff suppressed because it is too large Load Diff
+468
View File
@@ -0,0 +1,468 @@
import 'node:fs';
import 'node:path';
import { F as FormData, a as File$1 } from './init.mjs';
import 'node:http';
import 'node:https';
import 'node:zlib';
import 'node:stream';
import 'node:buffer';
import 'node:util';
import 'node:url';
import 'node:net';
import 'node:fs/promises';
import '../shared/nuxi.b2fdb45d.mjs';
import '../shared/nuxi.ed696fbc.mjs';
import 'util';
import 'path';
import 'fs';
import 'os';
import 'tty';
import '../shared/nuxi.a865ab6b.mjs';
import 'node:os';
import 'events';
import 'stream';
import 'string_decoder';
import 'assert';
import 'buffer';
import 'zlib';
import '../shared/nuxi.cc8dd4a9.mjs';
import 'process';
import 'crypto';
import '../shared/nuxi.d0ea9d71.mjs';
import 'node:child_process';
import 'net';
import 'tls';
import 'url';
import '../shared/nuxi.a2d9d2e1.mjs';
let s = 0;
const S = {
START_BOUNDARY: s++,
HEADER_FIELD_START: s++,
HEADER_FIELD: s++,
HEADER_VALUE_START: s++,
HEADER_VALUE: s++,
HEADER_VALUE_ALMOST_DONE: s++,
HEADERS_ALMOST_DONE: s++,
PART_DATA_START: s++,
PART_DATA: s++,
END: s++
};
let f = 1;
const F = {
PART_BOUNDARY: f,
LAST_BOUNDARY: f *= 2
};
const LF = 10;
const CR = 13;
const SPACE = 32;
const HYPHEN = 45;
const COLON = 58;
const A = 97;
const Z = 122;
const lower = c => c | 0x20;
const noop = () => {};
class MultipartParser {
/**
* @param {string} boundary
*/
constructor(boundary) {
this.index = 0;
this.flags = 0;
this.onHeaderEnd = noop;
this.onHeaderField = noop;
this.onHeadersEnd = noop;
this.onHeaderValue = noop;
this.onPartBegin = noop;
this.onPartData = noop;
this.onPartEnd = noop;
this.boundaryChars = {};
boundary = '\r\n--' + boundary;
const ui8a = new Uint8Array(boundary.length);
for (let i = 0; i < boundary.length; i++) {
ui8a[i] = boundary.charCodeAt(i);
this.boundaryChars[ui8a[i]] = true;
}
this.boundary = ui8a;
this.lookbehind = new Uint8Array(this.boundary.length + 8);
this.state = S.START_BOUNDARY;
}
/**
* @param {Uint8Array} data
*/
write(data) {
let i = 0;
const length_ = data.length;
let previousIndex = this.index;
let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
const boundaryLength = this.boundary.length;
const boundaryEnd = boundaryLength - 1;
const bufferLength = data.length;
let c;
let cl;
const mark = name => {
this[name + 'Mark'] = i;
};
const clear = name => {
delete this[name + 'Mark'];
};
const callback = (callbackSymbol, start, end, ui8a) => {
if (start === undefined || start !== end) {
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
}
};
const dataCallback = (name, clear) => {
const markSymbol = name + 'Mark';
if (!(markSymbol in this)) {
return;
}
if (clear) {
callback(name, this[markSymbol], i, data);
delete this[markSymbol];
} else {
callback(name, this[markSymbol], data.length, data);
this[markSymbol] = 0;
}
};
for (i = 0; i < length_; i++) {
c = data[i];
switch (state) {
case S.START_BOUNDARY:
if (index === boundary.length - 2) {
if (c === HYPHEN) {
flags |= F.LAST_BOUNDARY;
} else if (c !== CR) {
return;
}
index++;
break;
} else if (index - 1 === boundary.length - 2) {
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
state = S.END;
flags = 0;
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
index = 0;
callback('onPartBegin');
state = S.HEADER_FIELD_START;
} else {
return;
}
break;
}
if (c !== boundary[index + 2]) {
index = -2;
}
if (c === boundary[index + 2]) {
index++;
}
break;
case S.HEADER_FIELD_START:
state = S.HEADER_FIELD;
mark('onHeaderField');
index = 0;
// falls through
case S.HEADER_FIELD:
if (c === CR) {
clear('onHeaderField');
state = S.HEADERS_ALMOST_DONE;
break;
}
index++;
if (c === HYPHEN) {
break;
}
if (c === COLON) {
if (index === 1) {
// empty header field
return;
}
dataCallback('onHeaderField', true);
state = S.HEADER_VALUE_START;
break;
}
cl = lower(c);
if (cl < A || cl > Z) {
return;
}
break;
case S.HEADER_VALUE_START:
if (c === SPACE) {
break;
}
mark('onHeaderValue');
state = S.HEADER_VALUE;
// falls through
case S.HEADER_VALUE:
if (c === CR) {
dataCallback('onHeaderValue', true);
callback('onHeaderEnd');
state = S.HEADER_VALUE_ALMOST_DONE;
}
break;
case S.HEADER_VALUE_ALMOST_DONE:
if (c !== LF) {
return;
}
state = S.HEADER_FIELD_START;
break;
case S.HEADERS_ALMOST_DONE:
if (c !== LF) {
return;
}
callback('onHeadersEnd');
state = S.PART_DATA_START;
break;
case S.PART_DATA_START:
state = S.PART_DATA;
mark('onPartData');
// falls through
case S.PART_DATA:
previousIndex = index;
if (index === 0) {
// boyer-moore derrived algorithm to safely skip non-boundary data
i += boundaryEnd;
while (i < bufferLength && !(data[i] in boundaryChars)) {
i += boundaryLength;
}
i -= boundaryEnd;
c = data[i];
}
if (index < boundary.length) {
if (boundary[index] === c) {
if (index === 0) {
dataCallback('onPartData', true);
}
index++;
} else {
index = 0;
}
} else if (index === boundary.length) {
index++;
if (c === CR) {
// CR = part boundary
flags |= F.PART_BOUNDARY;
} else if (c === HYPHEN) {
// HYPHEN = end boundary
flags |= F.LAST_BOUNDARY;
} else {
index = 0;
}
} else if (index - 1 === boundary.length) {
if (flags & F.PART_BOUNDARY) {
index = 0;
if (c === LF) {
// unset the PART_BOUNDARY flag
flags &= ~F.PART_BOUNDARY;
callback('onPartEnd');
callback('onPartBegin');
state = S.HEADER_FIELD_START;
break;
}
} else if (flags & F.LAST_BOUNDARY) {
if (c === HYPHEN) {
callback('onPartEnd');
state = S.END;
flags = 0;
} else {
index = 0;
}
} else {
index = 0;
}
}
if (index > 0) {
// when matching a possible boundary, keep a lookbehind reference
// in case it turns out to be a false lead
lookbehind[index - 1] = c;
} else if (previousIndex > 0) {
// if our boundary turned out to be rubbish, the captured lookbehind
// belongs to partData
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
callback('onPartData', 0, previousIndex, _lookbehind);
previousIndex = 0;
mark('onPartData');
// reconsider the current character even so it interrupted the sequence
// it could be the beginning of a new sequence
i--;
}
break;
case S.END:
break;
default:
throw new Error(`Unexpected state entered: ${state}`);
}
}
dataCallback('onHeaderField');
dataCallback('onHeaderValue');
dataCallback('onPartData');
// Update properties for the next call
this.index = index;
this.state = state;
this.flags = flags;
}
end() {
if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
(this.state === S.PART_DATA && this.index === this.boundary.length)) {
this.onPartEnd();
} else if (this.state !== S.END) {
throw new Error('MultipartParser.end(): stream ended unexpectedly');
}
}
}
function _fileName(headerValue) {
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
if (!m) {
return;
}
const match = m[2] || m[3] || '';
let filename = match.slice(match.lastIndexOf('\\') + 1);
filename = filename.replace(/%22/g, '"');
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
return String.fromCharCode(code);
});
return filename;
}
async function toFormData(Body, ct) {
if (!/multipart/i.test(ct)) {
throw new TypeError('Failed to fetch');
}
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
if (!m) {
throw new TypeError('no or bad content-type header, no multipart boundary');
}
const parser = new MultipartParser(m[1] || m[2]);
let headerField;
let headerValue;
let entryValue;
let entryName;
let contentType;
let filename;
const entryChunks = [];
const formData = new FormData();
const onPartData = ui8a => {
entryValue += decoder.decode(ui8a, {stream: true});
};
const appendToFile = ui8a => {
entryChunks.push(ui8a);
};
const appendFileToFormData = () => {
const file = new File$1(entryChunks, filename, {type: contentType});
formData.append(entryName, file);
};
const appendEntryToFormData = () => {
formData.append(entryName, entryValue);
};
const decoder = new TextDecoder('utf-8');
decoder.decode();
parser.onPartBegin = function () {
parser.onPartData = onPartData;
parser.onPartEnd = appendEntryToFormData;
headerField = '';
headerValue = '';
entryValue = '';
entryName = '';
contentType = '';
filename = null;
entryChunks.length = 0;
};
parser.onHeaderField = function (ui8a) {
headerField += decoder.decode(ui8a, {stream: true});
};
parser.onHeaderValue = function (ui8a) {
headerValue += decoder.decode(ui8a, {stream: true});
};
parser.onHeaderEnd = function () {
headerValue += decoder.decode();
headerField = headerField.toLowerCase();
if (headerField === 'content-disposition') {
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
if (m) {
entryName = m[2] || m[3] || '';
}
filename = _fileName(headerValue);
if (filename) {
parser.onPartData = appendToFile;
parser.onPartEnd = appendFileToFormData;
}
} else if (headerField === 'content-type') {
contentType = headerValue;
}
headerValue = '';
headerField = '';
};
for await (const chunk of Body) {
parser.write(chunk);
}
parser.end();
return formData;
}
export { toFormData };
+38
View File
@@ -0,0 +1,38 @@
import { buildNuxt } from '@nuxt/kit';
import { c as consola } from '../shared/nuxi.b2fdb45d.mjs';
import { c as clearDir } from '../shared/nuxi.74850c25.mjs';
import { l as loadKit } from '../shared/nuxi.8cc4a579.mjs';
import { w as writeTypes } from '../shared/nuxi.30988785.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve, a as relative } from '../shared/nuxi.a2d9d2e1.mjs';
import '../shared/nuxi.ed696fbc.mjs';
import 'util';
import 'path';
import 'fs';
import 'os';
import 'tty';
import 'node:fs';
import '../shared/nuxi.e551a86b.mjs';
import 'node:module';
import 'node:url';
import '../shared/nuxi.d0ea9d71.mjs';
const prepare = defineNuxtCommand({
meta: {
name: "prepare",
usage: "npx nuxi prepare",
description: "Prepare nuxt for development/build"
},
async invoke(args) {
process.env.NODE_ENV = process.env.NODE_ENV || "production";
const rootDir = resolve(args._[0] || ".");
const { loadNuxt } = await loadKit(rootDir);
const nuxt = await loadNuxt({ rootDir, config: { _prepare: true } });
await clearDir(nuxt.options.buildDir);
await buildNuxt(nuxt);
await writeTypes(nuxt);
consola.success("Types generated in", relative(process.cwd(), nuxt.options.buildDir));
}
});
export { prepare as default };
+67
View File
@@ -0,0 +1,67 @@
import { existsSync, promises } from 'node:fs';
import { dirname, relative } from 'node:path';
import { e as execa } from '../shared/nuxi.6b390535.mjs';
import { s as setupDotenv } from '../shared/nuxi.ff602b95.mjs';
import { c as consola } from '../shared/nuxi.b2fdb45d.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve } from '../shared/nuxi.a2d9d2e1.mjs';
import 'node:buffer';
import 'node:child_process';
import 'node:process';
import '../shared/nuxi.30bccfab.mjs';
import 'child_process';
import 'path';
import '../shared/nuxi.ed696fbc.mjs';
import 'fs';
import 'assert';
import 'events';
import 'buffer';
import 'stream';
import 'util';
import 'node:url';
import 'os';
import 'node:os';
import 'crypto';
import 'module';
import 'perf_hooks';
import 'vm';
import 'url';
import 'tty';
const preview = defineNuxtCommand({
meta: {
name: "preview",
usage: "npx nuxi preview|start [--dotenv] [rootDir]",
description: "Launches nitro server for local testing after `nuxi build`."
},
async invoke(args) {
process.env.NODE_ENV = process.env.NODE_ENV || "production";
const rootDir = resolve(args._[0] || ".");
const nitroJSONPaths = [".output/nitro.json", "nitro.json"].map((p) => resolve(rootDir, p));
const nitroJSONPath = nitroJSONPaths.find((p) => existsSync(p));
if (!nitroJSONPath) {
consola.error("Cannot find `nitro.json`. Did you run `nuxi build` first? Search path:\n", nitroJSONPaths);
process.exit(1);
}
const outputPath = dirname(nitroJSONPath);
const nitroJSON = JSON.parse(await promises.readFile(nitroJSONPath, "utf-8"));
consola.info("Node.js version:", process.versions.node);
consola.info("Preset:", nitroJSON.preset);
consola.info("Working dir:", relative(process.cwd(), outputPath));
if (!nitroJSON.commands.preview) {
consola.error("Preview is not supported for this build.");
process.exit(1);
}
const envExists = args.dotenv ? existsSync(resolve(rootDir, args.dotenv)) : existsSync(rootDir);
if (envExists) {
consola.info("Loading `.env`. This will not be loaded when running the server in production.");
await setupDotenv({ cwd: rootDir, fileName: args.dotenv });
}
consola.info("Starting preview command:", nitroJSON.commands.preview);
const [command, ...commandArgs] = nitroJSON.commands.preview.split(" ");
consola.log("");
await execa(command, commandArgs, { stdio: "inherit", cwd: outputPath });
}
});
export { preview as default };
+1662
View File
File diff suppressed because it is too large Load Diff
+41
View File
@@ -0,0 +1,41 @@
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve } from '../shared/nuxi.a2d9d2e1.mjs';
const test = defineNuxtCommand({
meta: {
name: "test",
usage: "npx nuxi test [--dev] [--watch] [rootDir]",
description: "Run tests"
},
async invoke(args) {
process.env.NODE_ENV = process.env.NODE_ENV || "test";
const rootDir = resolve(args._[0] || ".");
const { runTests } = await importTestUtils();
await runTests({
rootDir,
dev: !!args.dev,
watch: !!args.watch
});
if (args.watch) {
return "wait";
}
}
});
async function importTestUtils() {
let err;
for (const pkg of ["@nuxt/test-utils-edge", "@nuxt/test-utils"]) {
try {
const exports = await import(pkg);
if (!exports.runTests) {
throw new Error("Invalid version of `@nuxt/test-utils` is installed!");
}
return exports;
} catch (_err) {
err = _err;
}
}
console.error(err);
throw new Error("`@nuxt/test-utils-edge` seems missing. Run `npm i -D @nuxt/test-utils-edge` or `yarn add -D @nuxt/test-utils-edge` to install.");
}
export { test as default };
+51
View File
@@ -0,0 +1,51 @@
import { e as execa } from '../shared/nuxi.6b390535.mjs';
import { b as tryResolveModule } from '../shared/nuxi.e551a86b.mjs';
import { l as loadKit } from '../shared/nuxi.8cc4a579.mjs';
import { w as writeTypes } from '../shared/nuxi.30988785.mjs';
import { d as defineNuxtCommand } from '../shared/nuxi.a865ab6b.mjs';
import { r as resolve } from '../shared/nuxi.a2d9d2e1.mjs';
import 'node:buffer';
import 'node:path';
import 'node:child_process';
import 'node:process';
import '../shared/nuxi.30bccfab.mjs';
import 'child_process';
import 'path';
import '../shared/nuxi.ed696fbc.mjs';
import 'fs';
import 'assert';
import 'events';
import 'buffer';
import 'stream';
import 'util';
import 'node:url';
import 'os';
import 'node:os';
import 'node:module';
import 'node:fs';
import '../shared/nuxi.d0ea9d71.mjs';
const typecheck = defineNuxtCommand({
meta: {
name: "typecheck",
usage: "npx nuxi typecheck [rootDir]",
description: "Runs `vue-tsc` to check types throughout your app."
},
async invoke(args) {
process.env.NODE_ENV = process.env.NODE_ENV || "production";
const rootDir = resolve(args._[0] || ".");
const { loadNuxt, buildNuxt } = await loadKit(rootDir);
const nuxt = await loadNuxt({ rootDir, config: { _prepare: true } });
await writeTypes(nuxt);
await buildNuxt(nuxt);
await nuxt.close();
const hasLocalInstall = tryResolveModule("typescript", rootDir) && tryResolveModule("vue-tsc/package.json", rootDir);
if (hasLocalInstall) {
await execa("vue-tsc", ["--noEmit"], { preferLocal: true, stdio: "inherit", cwd: rootDir });
} else {
await execa("npx", "-p vue-tsc -p typescript vue-tsc --noEmit".split(" "), { stdio: "inherit", cwd: rootDir });
}
}
});
export { typecheck as default };
+6713
View File
File diff suppressed because it is too large Load Diff
+20
View File
@@ -0,0 +1,20 @@
import { c as cyan } from '../shared/nuxi.a3b9dacd.mjs';
import { s as showHelp } from '../shared/nuxi.2135311a.mjs';
import { d as defineNuxtCommand, c as commands } from '../shared/nuxi.a865ab6b.mjs';
import 'tty';
const usage = defineNuxtCommand({
meta: {
name: "help",
usage: "nuxt help",
description: "Show help"
},
invoke(_args) {
const sections = [];
sections.push(`Usage: ${cyan(`npx nuxi ${Object.keys(commands).join("|")} [args]`)}`);
console.log(sections.join("\n\n") + "\n");
showHelp({});
}
});
export { usage as default };
+1069
View File
File diff suppressed because it is too large Load Diff