initial commit
This commit is contained in:
+153
@@ -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
@@ -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
@@ -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
@@ -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
File diff suppressed because it is too large
Load Diff
+26
@@ -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
File diff suppressed because it is too large
Load Diff
+36
@@ -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
@@ -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
File diff suppressed because it is too large
Load Diff
+1591
File diff suppressed because it is too large
Load Diff
+2136
File diff suppressed because one or more lines are too long
+15232
File diff suppressed because it is too large
Load Diff
+468
@@ -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
@@ -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
@@ -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
File diff suppressed because it is too large
Load Diff
+41
@@ -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
@@ -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
File diff suppressed because it is too large
Load Diff
+20
@@ -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
File diff suppressed because it is too large
Load Diff
+3
@@ -0,0 +1,3 @@
|
||||
declare function main(): void;
|
||||
|
||||
export { main };
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
import { m as mri, c as commands } from './shared/nuxi.a865ab6b.mjs';
|
||||
import { r as red } from './shared/nuxi.a3b9dacd.mjs';
|
||||
import { c as consola } from './shared/nuxi.b2fdb45d.mjs';
|
||||
import { e as engines, s as showBanner } from './shared/nuxi.1b1e0b8b.mjs';
|
||||
import { s as showHelp } from './shared/nuxi.2135311a.mjs';
|
||||
import 'tty';
|
||||
import './shared/nuxi.ed696fbc.mjs';
|
||||
import 'util';
|
||||
import 'path';
|
||||
import 'fs';
|
||||
import 'os';
|
||||
import 'assert';
|
||||
import './shared/nuxi.e551a86b.mjs';
|
||||
import 'node:module';
|
||||
import 'node:url';
|
||||
import './shared/nuxi.a2d9d2e1.mjs';
|
||||
|
||||
async function checkEngines() {
|
||||
const satisfies = await import('./chunks/satisfies.mjs').then(function (n) { return n.s; }).then((r) => r.default || r);
|
||||
const currentNode = process.versions.node;
|
||||
const nodeRange = engines.node;
|
||||
if (!satisfies(currentNode, nodeRange)) {
|
||||
console.warn(`Current version of Node.js (\`${currentNode}\`) is unsupported and might cause issues.
|
||||
Please upgrade to a compatible version (${nodeRange}).`);
|
||||
}
|
||||
}
|
||||
|
||||
async function _main() {
|
||||
const _argv = process.argv.slice(2);
|
||||
const args = mri(_argv, {
|
||||
boolean: [
|
||||
"no-clear"
|
||||
]
|
||||
});
|
||||
const command = args._.shift() || "usage";
|
||||
showBanner(command === "dev" && args.clear !== false && !args.help);
|
||||
if (!(command in commands)) {
|
||||
console.log("\n" + red("Invalid command " + command));
|
||||
await commands.usage().then((r) => r.invoke());
|
||||
process.exit(1);
|
||||
}
|
||||
setTimeout(() => {
|
||||
checkEngines().catch(() => {
|
||||
});
|
||||
}, 1e3);
|
||||
const cmd = await commands[command]();
|
||||
if (args.h || args.help) {
|
||||
showHelp(cmd.meta);
|
||||
} else {
|
||||
const result = await cmd.invoke(args);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
consola.wrapAll();
|
||||
const wrapReporter = (reporter) => ({
|
||||
log(logObj, ctx) {
|
||||
if (!logObj.args || !logObj.args.length) {
|
||||
return;
|
||||
}
|
||||
const msg = logObj.args[0];
|
||||
if (typeof msg === "string" && !process.env.DEBUG) {
|
||||
if (msg.startsWith("[Vue Router warn]: No match found for location with path")) {
|
||||
return;
|
||||
}
|
||||
if (msg.startsWith("Sourcemap") && msg.includes("node_modules")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return reporter.log(logObj, ctx);
|
||||
}
|
||||
});
|
||||
consola._reporters = consola._reporters.map(wrapReporter);
|
||||
process.on("unhandledRejection", (err) => consola.error("[unhandledRejection]", err));
|
||||
process.on("uncaughtException", (err) => consola.error("[uncaughtException]", err));
|
||||
function main() {
|
||||
_main().then((result) => {
|
||||
if (result === "error") {
|
||||
process.exit(1);
|
||||
} else if (result !== "wait") {
|
||||
process.exit(0);
|
||||
}
|
||||
}).catch((error) => {
|
||||
consola.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
export { main };
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
declare function runCommand(command: string, argv?: string[]): Promise<void>;
|
||||
|
||||
export { runCommand };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { m as mri, c as commands } from './shared/nuxi.a865ab6b.mjs';
|
||||
|
||||
async function runCommand(command, argv = process.argv.slice(2)) {
|
||||
const args = mri(argv);
|
||||
args.clear = false;
|
||||
const cmd = await commands[command]();
|
||||
if (!cmd) {
|
||||
throw new Error(`Invalid command ${command}`);
|
||||
}
|
||||
await cmd.invoke(args);
|
||||
}
|
||||
|
||||
export { runCommand };
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
import require$$0 from 'assert';
|
||||
import { g as gray, b as bold, a as green } from './nuxi.a3b9dacd.mjs';
|
||||
import { t as tryRequireModule } from './nuxi.e551a86b.mjs';
|
||||
|
||||
const version = "3.0.0";
|
||||
const engines = {
|
||||
node: "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
};
|
||||
|
||||
var assert = require$$0;
|
||||
|
||||
var clear = function clear(opts) {
|
||||
if (typeof (opts) === 'boolean') {
|
||||
opts = {
|
||||
fullClear: opts
|
||||
};
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
assert(typeof (opts) === 'object', 'opts must be an object');
|
||||
|
||||
opts.fullClear = opts.hasOwnProperty('fullClear') ?
|
||||
opts.fullClear : true;
|
||||
|
||||
assert(typeof (opts.fullClear) === 'boolean',
|
||||
'opts.fullClear must be a boolean');
|
||||
|
||||
if (opts.fullClear === true) {
|
||||
process.stdout.write('\x1b[2J');
|
||||
}
|
||||
|
||||
process.stdout.write('\x1b[0f');
|
||||
};
|
||||
|
||||
function showBanner(_clear) {
|
||||
if (_clear) {
|
||||
clear();
|
||||
}
|
||||
console.log(gray(`Nuxi ${bold(version)}`));
|
||||
}
|
||||
function showVersions(cwd) {
|
||||
const getPkgVersion = (pkg) => {
|
||||
return tryRequireModule(`${pkg}/package.json`, cwd)?.version || "";
|
||||
};
|
||||
const nuxtVersion = getPkgVersion("nuxt") || getPkgVersion("nuxt-edge");
|
||||
const nitroVersion = getPkgVersion("nitropack");
|
||||
console.log(gray(
|
||||
green(`Nuxt ${bold(nuxtVersion)}`) + (nitroVersion ? ` with Nitro ${bold(nitroVersion)}` : "")
|
||||
));
|
||||
}
|
||||
|
||||
export { showVersions as a, engines as e, showBanner as s };
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { m as magenta, c as cyan } from './nuxi.a3b9dacd.mjs';
|
||||
|
||||
function showHelp(meta) {
|
||||
const sections = [];
|
||||
if (meta) {
|
||||
if (meta.usage) {
|
||||
sections.push(magenta("> ") + "Usage: " + cyan(meta.usage));
|
||||
}
|
||||
if (meta.description) {
|
||||
sections.push(magenta("\u22EE ") + meta.description);
|
||||
}
|
||||
}
|
||||
sections.push(`Use ${cyan("npx nuxi [command] --help")} to see help for each command`);
|
||||
console.log(sections.join("\n\n") + "\n");
|
||||
}
|
||||
|
||||
export { showHelp as s };
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { f as findup } from './nuxi.74850c25.mjs';
|
||||
import { r as resolve } from './nuxi.a2d9d2e1.mjs';
|
||||
|
||||
const packageManagerLocks = {
|
||||
yarn: "yarn.lock",
|
||||
npm: "package-lock.json",
|
||||
pnpm: "pnpm-lock.yaml"
|
||||
};
|
||||
function getPackageManager(rootDir) {
|
||||
return findup(rootDir, (dir) => {
|
||||
for (const name in packageManagerLocks) {
|
||||
const path = packageManagerLocks[name];
|
||||
if (path && existsSync(resolve(dir, path))) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function getPackageManagerVersion(name) {
|
||||
return execSync(`${name} --version`).toString("utf8").trim();
|
||||
}
|
||||
|
||||
export { getPackageManagerVersion as a, getPackageManager as g, packageManagerLocks as p };
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
import { promises } from 'node:fs';
|
||||
import { d as defu } from './nuxi.d0ea9d71.mjs';
|
||||
import { g as getModulePaths, a as getNearestPackage } from './nuxi.e551a86b.mjs';
|
||||
import { a as relative, j as join, r as resolve, i as isAbsolute } from './nuxi.a2d9d2e1.mjs';
|
||||
|
||||
const writeTypes = async (nuxt) => {
|
||||
const modulePaths = getModulePaths(nuxt.options.modulesDir);
|
||||
const tsConfig = defu(nuxt.options.typescript?.tsConfig, {
|
||||
compilerOptions: {
|
||||
jsx: "preserve",
|
||||
target: "ESNext",
|
||||
module: "ESNext",
|
||||
moduleResolution: "Node",
|
||||
skipLibCheck: true,
|
||||
strict: nuxt.options.typescript?.strict ?? false,
|
||||
allowJs: true,
|
||||
noEmit: true,
|
||||
resolveJsonModule: true,
|
||||
allowSyntheticDefaultImports: true,
|
||||
types: ["node"],
|
||||
baseUrl: relative(nuxt.options.buildDir, nuxt.options.rootDir),
|
||||
paths: {}
|
||||
},
|
||||
include: [
|
||||
"./nuxt.d.ts",
|
||||
join(relative(nuxt.options.buildDir, nuxt.options.rootDir), "**/*"),
|
||||
...nuxt.options.srcDir !== nuxt.options.rootDir ? [join(relative(nuxt.options.buildDir, nuxt.options.srcDir), "**/*")] : [],
|
||||
...nuxt.options.typescript.includeWorkspace && nuxt.options.workspaceDir !== nuxt.options.rootDir ? [join(relative(nuxt.options.buildDir, nuxt.options.workspaceDir), "**/*")] : []
|
||||
],
|
||||
exclude: [
|
||||
relative(nuxt.options.buildDir, resolve(nuxt.options.rootDir, "dist"))
|
||||
]
|
||||
});
|
||||
const aliases = {
|
||||
...nuxt.options.alias,
|
||||
"#build": nuxt.options.buildDir
|
||||
};
|
||||
const excludedAlias = [/^@vue\/.*$/];
|
||||
for (const alias in aliases) {
|
||||
if (excludedAlias.some((re) => re.test(alias))) {
|
||||
continue;
|
||||
}
|
||||
const relativePath = isAbsolute(aliases[alias]) ? relative(nuxt.options.rootDir, aliases[alias]) || "." : aliases[alias];
|
||||
const stats = await promises.stat(resolve(nuxt.options.rootDir, relativePath)).catch(() => null);
|
||||
tsConfig.compilerOptions = tsConfig.compilerOptions || {};
|
||||
if (stats?.isDirectory()) {
|
||||
tsConfig.compilerOptions.paths[alias] = [relativePath];
|
||||
tsConfig.compilerOptions.paths[`${alias}/*`] = [`${relativePath}/*`];
|
||||
} else {
|
||||
tsConfig.compilerOptions.paths[alias] = [relativePath.replace(/(?<=\w)\.\w+$/g, "")];
|
||||
}
|
||||
}
|
||||
const references = [
|
||||
...nuxt.options.modules,
|
||||
...nuxt.options._modules
|
||||
].filter((f) => typeof f === "string").map((id) => ({ types: getNearestPackage(id, modulePaths)?.name || id }));
|
||||
if (nuxt.options.experimental?.reactivityTransform) {
|
||||
references.push({ types: "vue/macros-global" });
|
||||
}
|
||||
const declarations = [];
|
||||
await nuxt.callHook("prepare:types", { references, declarations, tsConfig });
|
||||
const declaration = [
|
||||
...references.map((ref) => {
|
||||
if ("path" in ref && isAbsolute(ref.path)) {
|
||||
ref.path = relative(nuxt.options.buildDir, ref.path);
|
||||
}
|
||||
return `/// <reference ${renderAttrs(ref)} />`;
|
||||
}),
|
||||
...declarations,
|
||||
"",
|
||||
"export {}",
|
||||
""
|
||||
].join("\n");
|
||||
async function writeFile() {
|
||||
const GeneratedBy = "// Generated by nuxi";
|
||||
const tsConfigPath = resolve(nuxt.options.buildDir, "tsconfig.json");
|
||||
await promises.mkdir(nuxt.options.buildDir, { recursive: true });
|
||||
await promises.writeFile(tsConfigPath, GeneratedBy + "\n" + JSON.stringify(tsConfig, null, 2));
|
||||
const declarationPath = resolve(nuxt.options.buildDir, "nuxt.d.ts");
|
||||
await promises.writeFile(declarationPath, GeneratedBy + "\n" + declaration);
|
||||
}
|
||||
nuxt.hook("builder:prepared", writeFile);
|
||||
await writeFile();
|
||||
};
|
||||
function renderAttrs(obj) {
|
||||
return Object.entries(obj).map((e) => renderAttr(e[0], e[1])).join(" ");
|
||||
}
|
||||
function renderAttr(key, value) {
|
||||
return value ? `${key}="${value}"` : "";
|
||||
}
|
||||
|
||||
export { writeTypes as w };
|
||||
+1065
File diff suppressed because it is too large
Load Diff
+1071
File diff suppressed because it is too large
Load Diff
+33
@@ -0,0 +1,33 @@
|
||||
import { promises } from 'node:fs';
|
||||
import { c as consola } from './nuxi.b2fdb45d.mjs';
|
||||
import { d as dirname } from './nuxi.a2d9d2e1.mjs';
|
||||
|
||||
async function clearDir(path) {
|
||||
await promises.rm(path, { recursive: true, force: true });
|
||||
await promises.mkdir(path, { recursive: true });
|
||||
}
|
||||
async function rmRecursive(paths) {
|
||||
await Promise.all(paths.filter((p) => typeof p === "string").map(async (path) => {
|
||||
consola.debug("Removing recursive path", path);
|
||||
await promises.rm(path, { recursive: true, force: true }).catch(() => {
|
||||
});
|
||||
}));
|
||||
}
|
||||
async function touchFile(path) {
|
||||
const time = new Date();
|
||||
await promises.utimes(path, time, time).catch(() => {
|
||||
});
|
||||
}
|
||||
function findup(rootDir, fn) {
|
||||
let dir = rootDir;
|
||||
while (dir !== dirname(dir)) {
|
||||
const res = fn(dir);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
dir = dirname(dir);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export { clearDir as c, findup as f, rmRecursive as r, touchFile as t };
|
||||
+530
@@ -0,0 +1,530 @@
|
||||
import { promises } from 'node:fs';
|
||||
import { c as consola } from './nuxi.b2fdb45d.mjs';
|
||||
import { r as rmRecursive } from './nuxi.74850c25.mjs';
|
||||
import { r as resolve, d as dirname } from './nuxi.a2d9d2e1.mjs';
|
||||
|
||||
const defaults = {
|
||||
ignoreUnknown: false,
|
||||
respectType: false,
|
||||
respectFunctionNames: false,
|
||||
respectFunctionProperties: false,
|
||||
unorderedObjects: true,
|
||||
unorderedArrays: false,
|
||||
unorderedSets: false
|
||||
};
|
||||
function objectHash(object, options = {}) {
|
||||
options = { ...defaults, ...options };
|
||||
const hasher = createHasher(options);
|
||||
hasher.dispatch(object);
|
||||
return hasher.toString();
|
||||
}
|
||||
function createHasher(options) {
|
||||
const buff = [];
|
||||
let context = [];
|
||||
const write = (str) => {
|
||||
buff.push(str);
|
||||
};
|
||||
return {
|
||||
toString() {
|
||||
return buff.join("");
|
||||
},
|
||||
getContext() {
|
||||
return context;
|
||||
},
|
||||
dispatch(value) {
|
||||
if (options.replacer) {
|
||||
value = options.replacer(value);
|
||||
}
|
||||
const type = value === null ? "null" : typeof value;
|
||||
return this["_" + type](value);
|
||||
},
|
||||
_object(object) {
|
||||
const pattern = /\[object (.*)]/i;
|
||||
const objString = Object.prototype.toString.call(object);
|
||||
const _objType = pattern.exec(objString);
|
||||
const objType = _objType ? _objType[1].toLowerCase() : "unknown:[" + objString.toLowerCase() + "]";
|
||||
let objectNumber = null;
|
||||
if ((objectNumber = context.indexOf(object)) >= 0) {
|
||||
return this.dispatch("[CIRCULAR:" + objectNumber + "]");
|
||||
} else {
|
||||
context.push(object);
|
||||
}
|
||||
if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
||||
write("buffer:");
|
||||
return write(object.toString("utf8"));
|
||||
}
|
||||
if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
|
||||
if (this["_" + objType]) {
|
||||
this["_" + objType](object);
|
||||
} else if (options.ignoreUnknown) {
|
||||
return write("[" + objType + "]");
|
||||
} else {
|
||||
throw new Error('Unknown object type "' + objType + '"');
|
||||
}
|
||||
} else {
|
||||
let keys = Object.keys(object);
|
||||
if (options.unorderedObjects) {
|
||||
keys = keys.sort();
|
||||
}
|
||||
if (options.respectType !== false && !isNativeFunction(object)) {
|
||||
keys.splice(0, 0, "prototype", "__proto__", "letructor");
|
||||
}
|
||||
if (options.excludeKeys) {
|
||||
keys = keys.filter(function(key) {
|
||||
return !options.excludeKeys(key);
|
||||
});
|
||||
}
|
||||
write("object:" + keys.length + ":");
|
||||
for (const key of keys) {
|
||||
this.dispatch(key);
|
||||
write(":");
|
||||
if (!options.excludeValues) {
|
||||
this.dispatch(object[key]);
|
||||
}
|
||||
write(",");
|
||||
}
|
||||
}
|
||||
},
|
||||
_array(arr, unordered) {
|
||||
unordered = typeof unordered !== "undefined" ? unordered : options.unorderedArrays !== false;
|
||||
write("array:" + arr.length + ":");
|
||||
if (!unordered || arr.length <= 1) {
|
||||
for (const entry of arr) {
|
||||
this.dispatch(entry);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const contextAdditions = [];
|
||||
const entries = arr.map((entry) => {
|
||||
const hasher = createHasher(options);
|
||||
hasher.dispatch(entry);
|
||||
contextAdditions.push(hasher.getContext());
|
||||
return hasher.toString();
|
||||
});
|
||||
context = [...context, ...contextAdditions];
|
||||
entries.sort();
|
||||
return this._array(entries, false);
|
||||
},
|
||||
_date(date) {
|
||||
return write("date:" + date.toJSON());
|
||||
},
|
||||
_symbol(sym) {
|
||||
return write("symbol:" + sym.toString());
|
||||
},
|
||||
_error(err) {
|
||||
return write("error:" + err.toString());
|
||||
},
|
||||
_boolean(bool) {
|
||||
return write("bool:" + bool.toString());
|
||||
},
|
||||
_string(string) {
|
||||
write("string:" + string.length + ":");
|
||||
write(string.toString());
|
||||
},
|
||||
_function(fn) {
|
||||
write("fn:");
|
||||
if (isNativeFunction(fn)) {
|
||||
this.dispatch("[native]");
|
||||
} else {
|
||||
this.dispatch(fn.toString());
|
||||
}
|
||||
if (options.respectFunctionNames !== false) {
|
||||
this.dispatch("function-name:" + String(fn.name));
|
||||
}
|
||||
if (options.respectFunctionProperties) {
|
||||
this._object(fn);
|
||||
}
|
||||
},
|
||||
_number(number) {
|
||||
return write("number:" + number.toString());
|
||||
},
|
||||
_xml(xml) {
|
||||
return write("xml:" + xml.toString());
|
||||
},
|
||||
_null() {
|
||||
return write("Null");
|
||||
},
|
||||
_undefined() {
|
||||
return write("Undefined");
|
||||
},
|
||||
_regexp(regex) {
|
||||
return write("regex:" + regex.toString());
|
||||
},
|
||||
_uint8array(arr) {
|
||||
write("uint8array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_uint8clampedarray(arr) {
|
||||
write("uint8clampedarray:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_int8array(arr) {
|
||||
write("int8array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_uint16array(arr) {
|
||||
write("uint16array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_int16array(arr) {
|
||||
write("int16array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_uint32array(arr) {
|
||||
write("uint32array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_int32array(arr) {
|
||||
write("int32array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_float32array(arr) {
|
||||
write("float32array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_float64array(arr) {
|
||||
write("float64array:");
|
||||
return this.dispatch(Array.prototype.slice.call(arr));
|
||||
},
|
||||
_arraybuffer(arr) {
|
||||
write("arraybuffer:");
|
||||
return this.dispatch(new Uint8Array(arr));
|
||||
},
|
||||
_url(url) {
|
||||
return write("url:" + url.toString());
|
||||
},
|
||||
_map(map) {
|
||||
write("map:");
|
||||
const arr = [...map];
|
||||
return this._array(arr, options.unorderedSets !== false);
|
||||
},
|
||||
_set(set) {
|
||||
write("set:");
|
||||
const arr = [...set];
|
||||
return this._array(arr, options.unorderedSets !== false);
|
||||
},
|
||||
_file(file) {
|
||||
write("file:");
|
||||
return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
|
||||
},
|
||||
_blob() {
|
||||
if (options.ignoreUnknown) {
|
||||
return write("[blob]");
|
||||
}
|
||||
throw new Error('Hashing Blob objects is currently not supported\nUse "options.replacer" or "options.ignoreUnknown"\n');
|
||||
},
|
||||
_domwindow() {
|
||||
return write("domwindow");
|
||||
},
|
||||
_bigint(number) {
|
||||
return write("bigint:" + number.toString());
|
||||
},
|
||||
_process() {
|
||||
return write("process");
|
||||
},
|
||||
_timer() {
|
||||
return write("timer");
|
||||
},
|
||||
_pipe() {
|
||||
return write("pipe");
|
||||
},
|
||||
_tcp() {
|
||||
return write("tcp");
|
||||
},
|
||||
_udp() {
|
||||
return write("udp");
|
||||
},
|
||||
_tty() {
|
||||
return write("tty");
|
||||
},
|
||||
_statwatcher() {
|
||||
return write("statwatcher");
|
||||
},
|
||||
_securecontext() {
|
||||
return write("securecontext");
|
||||
},
|
||||
_connection() {
|
||||
return write("connection");
|
||||
},
|
||||
_zlib() {
|
||||
return write("zlib");
|
||||
},
|
||||
_context() {
|
||||
return write("context");
|
||||
},
|
||||
_nodescript() {
|
||||
return write("nodescript");
|
||||
},
|
||||
_httpparser() {
|
||||
return write("httpparser");
|
||||
},
|
||||
_dataview() {
|
||||
return write("dataview");
|
||||
},
|
||||
_signal() {
|
||||
return write("signal");
|
||||
},
|
||||
_fsevent() {
|
||||
return write("fsevent");
|
||||
},
|
||||
_tlswrap() {
|
||||
return write("tlswrap");
|
||||
}
|
||||
};
|
||||
}
|
||||
function isNativeFunction(f) {
|
||||
if (typeof f !== "function") {
|
||||
return false;
|
||||
}
|
||||
const exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code]\s+}$/i;
|
||||
return exp.exec(Function.prototype.toString.call(f)) != null;
|
||||
}
|
||||
|
||||
class WordArray {
|
||||
constructor(words, sigBytes) {
|
||||
words = this.words = words || [];
|
||||
this.sigBytes = sigBytes !== void 0 ? sigBytes : words.length * 4;
|
||||
}
|
||||
toString(encoder) {
|
||||
return (encoder || Hex).stringify(this);
|
||||
}
|
||||
concat(wordArray) {
|
||||
this.clamp();
|
||||
if (this.sigBytes % 4) {
|
||||
for (let i = 0; i < wordArray.sigBytes; i++) {
|
||||
const thatByte = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
||||
this.words[this.sigBytes + i >>> 2] |= thatByte << 24 - (this.sigBytes + i) % 4 * 8;
|
||||
}
|
||||
} else {
|
||||
for (let j = 0; j < wordArray.sigBytes; j += 4) {
|
||||
this.words[this.sigBytes + j >>> 2] = wordArray.words[j >>> 2];
|
||||
}
|
||||
}
|
||||
this.sigBytes += wordArray.sigBytes;
|
||||
return this;
|
||||
}
|
||||
clamp() {
|
||||
this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8;
|
||||
this.words.length = Math.ceil(this.sigBytes / 4);
|
||||
}
|
||||
clone() {
|
||||
return new WordArray([...this.words]);
|
||||
}
|
||||
}
|
||||
const Hex = {
|
||||
stringify(wordArray) {
|
||||
const hexChars = [];
|
||||
for (let i = 0; i < wordArray.sigBytes; i++) {
|
||||
const bite = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
||||
hexChars.push(
|
||||
(bite >>> 4).toString(16),
|
||||
(bite & 15).toString(16)
|
||||
);
|
||||
}
|
||||
return hexChars.join("");
|
||||
}
|
||||
};
|
||||
const Base64 = {
|
||||
stringify(wordArray) {
|
||||
const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const base64Chars = [];
|
||||
for (let i = 0; i < wordArray.sigBytes; i += 3) {
|
||||
const byte1 = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
||||
const byte2 = wordArray.words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
|
||||
const byte3 = wordArray.words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
|
||||
const triplet = byte1 << 16 | byte2 << 8 | byte3;
|
||||
for (let j = 0; j < 4 && i * 8 + j * 6 < wordArray.sigBytes * 8; j++) {
|
||||
base64Chars.push(keyStr.charAt(triplet >>> 6 * (3 - j) & 63));
|
||||
}
|
||||
}
|
||||
return base64Chars.join("");
|
||||
}
|
||||
};
|
||||
const Latin1 = {
|
||||
parse(latin1Str) {
|
||||
const latin1StrLength = latin1Str.length;
|
||||
const words = [];
|
||||
for (let i = 0; i < latin1StrLength; i++) {
|
||||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
|
||||
}
|
||||
return new WordArray(words, latin1StrLength);
|
||||
}
|
||||
};
|
||||
const Utf8 = {
|
||||
parse(utf8Str) {
|
||||
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
||||
}
|
||||
};
|
||||
class BufferedBlockAlgorithm {
|
||||
constructor() {
|
||||
this._minBufferSize = 0;
|
||||
this.blockSize = 512 / 32;
|
||||
this.reset();
|
||||
}
|
||||
reset() {
|
||||
this._data = new WordArray();
|
||||
this._nDataBytes = 0;
|
||||
}
|
||||
_append(data) {
|
||||
if (typeof data === "string") {
|
||||
data = Utf8.parse(data);
|
||||
}
|
||||
this._data.concat(data);
|
||||
this._nDataBytes += data.sigBytes;
|
||||
}
|
||||
_doProcessBlock(_dataWords, _offset) {
|
||||
}
|
||||
_process(doFlush) {
|
||||
let processedWords;
|
||||
let nBlocksReady = this._data.sigBytes / (this.blockSize * 4);
|
||||
if (doFlush) {
|
||||
nBlocksReady = Math.ceil(nBlocksReady);
|
||||
} else {
|
||||
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
||||
}
|
||||
const nWordsReady = nBlocksReady * this.blockSize;
|
||||
const nBytesReady = Math.min(nWordsReady * 4, this._data.sigBytes);
|
||||
if (nWordsReady) {
|
||||
for (let offset = 0; offset < nWordsReady; offset += this.blockSize) {
|
||||
this._doProcessBlock(this._data.words, offset);
|
||||
}
|
||||
processedWords = this._data.words.splice(0, nWordsReady);
|
||||
this._data.sigBytes -= nBytesReady;
|
||||
}
|
||||
return new WordArray(processedWords, nBytesReady);
|
||||
}
|
||||
}
|
||||
class Hasher extends BufferedBlockAlgorithm {
|
||||
update(messageUpdate) {
|
||||
this._append(messageUpdate);
|
||||
this._process();
|
||||
return this;
|
||||
}
|
||||
finalize(messageUpdate) {
|
||||
if (messageUpdate) {
|
||||
this._append(messageUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const H = [1779033703, -1150833019, 1013904242, -1521486534, 1359893119, -1694144372, 528734635, 1541459225];
|
||||
const K = [1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998];
|
||||
const W = [];
|
||||
class SHA256 extends Hasher {
|
||||
constructor() {
|
||||
super();
|
||||
this.reset();
|
||||
}
|
||||
reset() {
|
||||
super.reset();
|
||||
this._hash = new WordArray([...H]);
|
||||
}
|
||||
_doProcessBlock(M, offset) {
|
||||
const H2 = this._hash.words;
|
||||
let a = H2[0];
|
||||
let b = H2[1];
|
||||
let c = H2[2];
|
||||
let d = H2[3];
|
||||
let e = H2[4];
|
||||
let f = H2[5];
|
||||
let g = H2[6];
|
||||
let h = H2[7];
|
||||
for (let i = 0; i < 64; i++) {
|
||||
if (i < 16) {
|
||||
W[i] = M[offset + i] | 0;
|
||||
} else {
|
||||
const gamma0x = W[i - 15];
|
||||
const gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
|
||||
const gamma1x = W[i - 2];
|
||||
const gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
|
||||
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
||||
}
|
||||
const ch = e & f ^ ~e & g;
|
||||
const maj = a & b ^ a & c ^ b & c;
|
||||
const sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
|
||||
const sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
|
||||
const t1 = h + sigma1 + ch + K[i] + W[i];
|
||||
const t2 = sigma0 + maj;
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + t1 | 0;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = t1 + t2 | 0;
|
||||
}
|
||||
H2[0] = H2[0] + a | 0;
|
||||
H2[1] = H2[1] + b | 0;
|
||||
H2[2] = H2[2] + c | 0;
|
||||
H2[3] = H2[3] + d | 0;
|
||||
H2[4] = H2[4] + e | 0;
|
||||
H2[5] = H2[5] + f | 0;
|
||||
H2[6] = H2[6] + g | 0;
|
||||
H2[7] = H2[7] + h | 0;
|
||||
}
|
||||
finalize(messageUpdate) {
|
||||
super.finalize(messageUpdate);
|
||||
const nBitsTotal = this._nDataBytes * 8;
|
||||
const nBitsLeft = this._data.sigBytes * 8;
|
||||
this._data.words[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
||||
this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296);
|
||||
this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
|
||||
this._data.sigBytes = this._data.words.length * 4;
|
||||
this._process();
|
||||
return this._hash;
|
||||
}
|
||||
}
|
||||
function sha256base64(message) {
|
||||
return new SHA256().finalize(message).toString(Base64);
|
||||
}
|
||||
|
||||
function hash(object, options = {}) {
|
||||
const hashed = typeof object === "string" ? object : objectHash(object, options);
|
||||
return sha256base64(hashed).slice(0, 10);
|
||||
}
|
||||
|
||||
async function cleanupNuxtDirs(rootDir) {
|
||||
consola.info("Cleaning up generated nuxt files and caches...");
|
||||
await rmRecursive([
|
||||
".nuxt",
|
||||
".output",
|
||||
"dist",
|
||||
"node_modules/.vite",
|
||||
"node_modules/.cache"
|
||||
].map((dir) => resolve(rootDir, dir)));
|
||||
}
|
||||
function nuxtVersionToGitIdentifier(version) {
|
||||
const id = /\.([0-9a-f]{7,8})$/.exec(version);
|
||||
if (id?.[1]) {
|
||||
return id[1];
|
||||
}
|
||||
return `v${version}`;
|
||||
}
|
||||
function resolveNuxtManifest(nuxt) {
|
||||
const manifest = {
|
||||
_hash: null,
|
||||
project: {
|
||||
rootDir: nuxt.options.rootDir
|
||||
},
|
||||
versions: {
|
||||
nuxt: nuxt._version
|
||||
}
|
||||
};
|
||||
manifest._hash = hash(manifest);
|
||||
return manifest;
|
||||
}
|
||||
async function writeNuxtManifest(nuxt) {
|
||||
const manifest = resolveNuxtManifest(nuxt);
|
||||
const manifestPath = resolve(nuxt.options.buildDir, "nuxt.json");
|
||||
await promises.mkdir(dirname(manifestPath), { recursive: true });
|
||||
await promises.writeFile(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
|
||||
return manifest;
|
||||
}
|
||||
async function loadNuxtManifest(buildDir) {
|
||||
const manifestPath = resolve(buildDir, "nuxt.json");
|
||||
const manifest = await promises.readFile(manifestPath, "utf-8").then((data) => JSON.parse(data)).catch(() => null);
|
||||
return manifest;
|
||||
}
|
||||
|
||||
export { cleanupNuxtDirs as c, loadNuxtManifest as l, nuxtVersionToGitIdentifier as n, writeNuxtManifest as w };
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { i as importModule } from './nuxi.e551a86b.mjs';
|
||||
|
||||
const loadKit = async (rootDir) => {
|
||||
try {
|
||||
return await importModule("@nuxt/kit", rootDir);
|
||||
} catch (e) {
|
||||
if (e.toString().includes("Cannot find module '@nuxt/kit'")) {
|
||||
throw new Error("nuxi requires `@nuxt/kit` to be installed in your project. Try installing `nuxt3` or `@nuxt/bridge` first.");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
export { loadKit as l };
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
function normalizeWindowsPath(input = "") {
|
||||
if (!input || !input.includes("\\")) {
|
||||
return input;
|
||||
}
|
||||
return input.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
const _UNC_REGEX = /^[/\\]{2}/;
|
||||
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
||||
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
||||
const normalize = function(path) {
|
||||
if (path.length === 0) {
|
||||
return ".";
|
||||
}
|
||||
path = normalizeWindowsPath(path);
|
||||
const isUNCPath = path.match(_UNC_REGEX);
|
||||
const isPathAbsolute = isAbsolute(path);
|
||||
const trailingSeparator = path[path.length - 1] === "/";
|
||||
path = normalizeString(path, !isPathAbsolute);
|
||||
if (path.length === 0) {
|
||||
if (isPathAbsolute) {
|
||||
return "/";
|
||||
}
|
||||
return trailingSeparator ? "./" : ".";
|
||||
}
|
||||
if (trailingSeparator) {
|
||||
path += "/";
|
||||
}
|
||||
if (_DRIVE_LETTER_RE.test(path)) {
|
||||
path += "/";
|
||||
}
|
||||
if (isUNCPath) {
|
||||
if (!isPathAbsolute) {
|
||||
return `//./${path}`;
|
||||
}
|
||||
return `//${path}`;
|
||||
}
|
||||
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
||||
};
|
||||
const join = function(...arguments_) {
|
||||
if (arguments_.length === 0) {
|
||||
return ".";
|
||||
}
|
||||
let joined;
|
||||
for (const argument of arguments_) {
|
||||
if (argument && argument.length > 0) {
|
||||
if (joined === void 0) {
|
||||
joined = argument;
|
||||
} else {
|
||||
joined += `/${argument}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (joined === void 0) {
|
||||
return ".";
|
||||
}
|
||||
return normalize(joined.replace(/\/\/+/g, "/"));
|
||||
};
|
||||
const resolve = function(...arguments_) {
|
||||
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
||||
let resolvedPath = "";
|
||||
let resolvedAbsolute = false;
|
||||
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
||||
const path = index >= 0 ? arguments_[index] : process.cwd().replace(/\\/g, "/");
|
||||
if (!path || path.length === 0) {
|
||||
continue;
|
||||
}
|
||||
resolvedPath = `${path}/${resolvedPath}`;
|
||||
resolvedAbsolute = isAbsolute(path);
|
||||
}
|
||||
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
||||
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
||||
return `/${resolvedPath}`;
|
||||
}
|
||||
return resolvedPath.length > 0 ? resolvedPath : ".";
|
||||
};
|
||||
function normalizeString(path, allowAboveRoot) {
|
||||
let res = "";
|
||||
let lastSegmentLength = 0;
|
||||
let lastSlash = -1;
|
||||
let dots = 0;
|
||||
let char = null;
|
||||
for (let index = 0; index <= path.length; ++index) {
|
||||
if (index < path.length) {
|
||||
char = path[index];
|
||||
} else if (char === "/") {
|
||||
break;
|
||||
} else {
|
||||
char = "/";
|
||||
}
|
||||
if (char === "/") {
|
||||
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
||||
if (res.length > 2) {
|
||||
const lastSlashIndex = res.lastIndexOf("/");
|
||||
if (lastSlashIndex === -1) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
} else {
|
||||
res = res.slice(0, lastSlashIndex);
|
||||
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
} else if (res.length > 0) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (allowAboveRoot) {
|
||||
res += res.length > 0 ? "/.." : "..";
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
if (res.length > 0) {
|
||||
res += `/${path.slice(lastSlash + 1, index)}`;
|
||||
} else {
|
||||
res = path.slice(lastSlash + 1, index);
|
||||
}
|
||||
lastSegmentLength = index - lastSlash - 1;
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
} else if (char === "." && dots !== -1) {
|
||||
++dots;
|
||||
} else {
|
||||
dots = -1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
const isAbsolute = function(p) {
|
||||
return _IS_ABSOLUTE_RE.test(p);
|
||||
};
|
||||
const relative = function(from, to) {
|
||||
const _from = resolve(from).split("/");
|
||||
const _to = resolve(to).split("/");
|
||||
const _fromCopy = [..._from];
|
||||
for (const segment of _fromCopy) {
|
||||
if (_to[0] !== segment) {
|
||||
break;
|
||||
}
|
||||
_from.shift();
|
||||
_to.shift();
|
||||
}
|
||||
return [..._from.map(() => ".."), ..._to].join("/");
|
||||
};
|
||||
const dirname = function(p) {
|
||||
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
||||
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
||||
segments[0] += "/";
|
||||
}
|
||||
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
||||
};
|
||||
|
||||
export { relative as a, dirname as d, isAbsolute as i, join as j, normalize as n, resolve as r };
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
import * as tty from 'tty';
|
||||
|
||||
const {
|
||||
env = {},
|
||||
argv = [],
|
||||
platform = "",
|
||||
} = typeof process === "undefined" ? {} : process;
|
||||
|
||||
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
||||
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
||||
const isWindows = platform === "win32";
|
||||
const isDumbTerminal = env.TERM === "dumb";
|
||||
|
||||
const isCompatibleTerminal =
|
||||
tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
||||
|
||||
const isCI =
|
||||
"CI" in env &&
|
||||
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
||||
|
||||
const isColorSupported =
|
||||
!isDisabled &&
|
||||
(isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI);
|
||||
|
||||
const replaceClose = (
|
||||
index,
|
||||
string,
|
||||
close,
|
||||
replace,
|
||||
head = string.substring(0, index) + replace,
|
||||
tail = string.substring(index + close.length),
|
||||
next = tail.indexOf(close)
|
||||
) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
||||
|
||||
const clearBleed = (index, string, open, close, replace) =>
|
||||
index < 0
|
||||
? open + string + close
|
||||
: open + replaceClose(index, string, close, replace) + close;
|
||||
|
||||
const filterEmpty =
|
||||
(open, close, replace = open, at = open.length + 1) =>
|
||||
(string) =>
|
||||
string || !(string === "" || string === undefined)
|
||||
? clearBleed(
|
||||
("" + string).indexOf(close, at),
|
||||
string,
|
||||
open,
|
||||
close,
|
||||
replace
|
||||
)
|
||||
: "";
|
||||
|
||||
const init = (open, close, replace) =>
|
||||
filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
||||
|
||||
const colors = {
|
||||
reset: init(0, 0),
|
||||
bold: init(1, 22, "\x1b[22m\x1b[1m"),
|
||||
dim: init(2, 22, "\x1b[22m\x1b[2m"),
|
||||
italic: init(3, 23),
|
||||
underline: init(4, 24),
|
||||
inverse: init(7, 27),
|
||||
hidden: init(8, 28),
|
||||
strikethrough: init(9, 29),
|
||||
black: init(30, 39),
|
||||
red: init(31, 39),
|
||||
green: init(32, 39),
|
||||
yellow: init(33, 39),
|
||||
blue: init(34, 39),
|
||||
magenta: init(35, 39),
|
||||
cyan: init(36, 39),
|
||||
white: init(37, 39),
|
||||
gray: init(90, 39),
|
||||
bgBlack: init(40, 49),
|
||||
bgRed: init(41, 49),
|
||||
bgGreen: init(42, 49),
|
||||
bgYellow: init(43, 49),
|
||||
bgBlue: init(44, 49),
|
||||
bgMagenta: init(45, 49),
|
||||
bgCyan: init(46, 49),
|
||||
bgWhite: init(47, 49),
|
||||
blackBright: init(90, 39),
|
||||
redBright: init(91, 39),
|
||||
greenBright: init(92, 39),
|
||||
yellowBright: init(93, 39),
|
||||
blueBright: init(94, 39),
|
||||
magentaBright: init(95, 39),
|
||||
cyanBright: init(96, 39),
|
||||
whiteBright: init(97, 39),
|
||||
bgBlackBright: init(100, 49),
|
||||
bgRedBright: init(101, 49),
|
||||
bgGreenBright: init(102, 49),
|
||||
bgYellowBright: init(103, 49),
|
||||
bgBlueBright: init(104, 49),
|
||||
bgMagentaBright: init(105, 49),
|
||||
bgCyanBright: init(106, 49),
|
||||
bgWhiteBright: init(107, 49),
|
||||
};
|
||||
|
||||
const createColors = ({ useColor = isColorSupported } = {}) =>
|
||||
useColor
|
||||
? colors
|
||||
: Object.keys(colors).reduce(
|
||||
(colors, key) => ({ ...colors, [key]: String }),
|
||||
{}
|
||||
);
|
||||
|
||||
const {
|
||||
reset,
|
||||
bold,
|
||||
dim,
|
||||
italic,
|
||||
underline,
|
||||
inverse,
|
||||
hidden,
|
||||
strikethrough,
|
||||
black,
|
||||
red,
|
||||
green,
|
||||
yellow,
|
||||
blue,
|
||||
magenta,
|
||||
cyan,
|
||||
white,
|
||||
gray,
|
||||
bgBlack,
|
||||
bgRed,
|
||||
bgGreen,
|
||||
bgYellow,
|
||||
bgBlue,
|
||||
bgMagenta,
|
||||
bgCyan,
|
||||
bgWhite,
|
||||
blackBright,
|
||||
redBright,
|
||||
greenBright,
|
||||
yellowBright,
|
||||
blueBright,
|
||||
magentaBright,
|
||||
cyanBright,
|
||||
whiteBright,
|
||||
bgBlackBright,
|
||||
bgRedBright,
|
||||
bgGreenBright,
|
||||
bgYellowBright,
|
||||
bgBlueBright,
|
||||
bgMagentaBright,
|
||||
bgCyanBright,
|
||||
bgWhiteBright,
|
||||
} = createColors();
|
||||
|
||||
export { green as a, bold as b, cyan as c, gray as g, magenta as m, red as r, underline as u };
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
function toArr(any) {
|
||||
return any == null ? [] : Array.isArray(any) ? any : [any];
|
||||
}
|
||||
|
||||
function toVal(out, key, val, opts) {
|
||||
var x, old=out[key], nxt=(
|
||||
!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
|
||||
: typeof val === 'boolean' ? val
|
||||
: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
|
||||
: (x = +val,x * 0 === 0) ? x : val
|
||||
);
|
||||
out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
|
||||
}
|
||||
|
||||
function mri (args, opts) {
|
||||
args = args || [];
|
||||
opts = opts || {};
|
||||
|
||||
var k, arr, arg, name, val, out={ _:[] };
|
||||
var i=0, j=0, idx=0, len=args.length;
|
||||
|
||||
const alibi = opts.alias !== void 0;
|
||||
const strict = opts.unknown !== void 0;
|
||||
const defaults = opts.default !== void 0;
|
||||
|
||||
opts.alias = opts.alias || {};
|
||||
opts.string = toArr(opts.string);
|
||||
opts.boolean = toArr(opts.boolean);
|
||||
|
||||
if (alibi) {
|
||||
for (k in opts.alias) {
|
||||
arr = opts.alias[k] = toArr(opts.alias[k]);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=opts.boolean.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.boolean[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
||||
}
|
||||
|
||||
for (i=opts.string.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.string[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
name = typeof opts.default[k];
|
||||
arr = opts.alias[k] = opts.alias[k] || [];
|
||||
if (opts[name] !== void 0) {
|
||||
opts[name].push(k);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
opts[name].push(arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const keys = strict ? Object.keys(opts.alias) : [];
|
||||
|
||||
for (i=0; i < len; i++) {
|
||||
arg = args[i];
|
||||
|
||||
if (arg === '--') {
|
||||
out._ = out._.concat(args.slice(++i));
|
||||
break;
|
||||
}
|
||||
|
||||
for (j=0; j < arg.length; j++) {
|
||||
if (arg.charCodeAt(j) !== 45) break; // "-"
|
||||
}
|
||||
|
||||
if (j === 0) {
|
||||
out._.push(arg);
|
||||
} else if (arg.substring(j, j + 3) === 'no-') {
|
||||
name = arg.substring(j + 3);
|
||||
if (strict && !~keys.indexOf(name)) {
|
||||
return opts.unknown(arg);
|
||||
}
|
||||
out[name] = false;
|
||||
} else {
|
||||
for (idx=j+1; idx < arg.length; idx++) {
|
||||
if (arg.charCodeAt(idx) === 61) break; // "="
|
||||
}
|
||||
|
||||
name = arg.substring(j, idx);
|
||||
val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
|
||||
arr = (j === 2 ? [name] : name);
|
||||
|
||||
for (idx=0; idx < arr.length; idx++) {
|
||||
name = arr[idx];
|
||||
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
||||
toVal(out, name, (idx + 1 < arr.length) || val, opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
if (out[k] === void 0) {
|
||||
out[k] = opts.default[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alibi) {
|
||||
for (k in out) {
|
||||
arr = opts.alias[k] || [];
|
||||
while (arr.length > 0) {
|
||||
out[arr.shift()] = out[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
const _rDefault = (r) => r.default || r;
|
||||
const commands = {
|
||||
dev: () => import('../chunks/dev.mjs').then(_rDefault),
|
||||
build: () => import('../chunks/build.mjs').then(_rDefault),
|
||||
"build-module": () => import('../chunks/build-module.mjs').then(_rDefault),
|
||||
cleanup: () => import('../chunks/cleanup.mjs').then(_rDefault),
|
||||
clean: () => import('../chunks/cleanup.mjs').then(_rDefault),
|
||||
preview: () => import('../chunks/preview.mjs').then(_rDefault),
|
||||
start: () => import('../chunks/preview.mjs').then(_rDefault),
|
||||
analyze: () => import('../chunks/analyze.mjs').then(_rDefault),
|
||||
generate: () => import('../chunks/generate.mjs').then(_rDefault),
|
||||
prepare: () => import('../chunks/prepare.mjs').then(_rDefault),
|
||||
typecheck: () => import('../chunks/typecheck.mjs').then(_rDefault),
|
||||
usage: () => import('../chunks/usage.mjs').then(_rDefault),
|
||||
info: () => import('../chunks/info.mjs').then(_rDefault),
|
||||
init: () => import('../chunks/init.mjs').then(function (n) { return n.i; }).then(_rDefault),
|
||||
create: () => import('../chunks/init.mjs').then(function (n) { return n.i; }).then(_rDefault),
|
||||
upgrade: () => import('../chunks/upgrade.mjs').then(_rDefault),
|
||||
test: () => import('../chunks/test.mjs').then(_rDefault),
|
||||
add: () => import('../chunks/add.mjs').then(_rDefault),
|
||||
new: () => import('../chunks/add.mjs').then(_rDefault)
|
||||
};
|
||||
function defineNuxtCommand(command) {
|
||||
return command;
|
||||
}
|
||||
|
||||
export { commands as c, defineNuxtCommand as d, mri as m };
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
const PLUS_RE = /\+/g;
|
||||
function decode(text = "") {
|
||||
try {
|
||||
return decodeURIComponent("" + text);
|
||||
} catch {
|
||||
return "" + text;
|
||||
}
|
||||
}
|
||||
function decodeQueryValue(text) {
|
||||
return decode(text.replace(PLUS_RE, " "));
|
||||
}
|
||||
|
||||
function parseQuery(parametersString = "") {
|
||||
const object = {};
|
||||
if (parametersString[0] === "?") {
|
||||
parametersString = parametersString.slice(1);
|
||||
}
|
||||
for (const parameter of parametersString.split("&")) {
|
||||
const s = parameter.match(/([^=]+)=?(.*)/) || [];
|
||||
if (s.length < 2) {
|
||||
continue;
|
||||
}
|
||||
const key = decode(s[1]);
|
||||
if (key === "__proto__" || key === "constructor") {
|
||||
continue;
|
||||
}
|
||||
const value = decodeQueryValue(s[2] || "");
|
||||
if (object[key]) {
|
||||
if (Array.isArray(object[key])) {
|
||||
object[key].push(value);
|
||||
} else {
|
||||
object[key] = [object[key], value];
|
||||
}
|
||||
} else {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
const PROTOCOL_REGEX = /^\w+:(\/\/)?/;
|
||||
const PROTOCOL_RELATIVE_REGEX = /^\/\/[^/]+/;
|
||||
function hasProtocol(inputString, acceptProtocolRelative = false) {
|
||||
return PROTOCOL_REGEX.test(inputString) || acceptProtocolRelative && PROTOCOL_RELATIVE_REGEX.test(inputString);
|
||||
}
|
||||
const TRAILING_SLASH_RE = /\/$|\/\?/;
|
||||
function hasTrailingSlash(input = "", queryParameters = false) {
|
||||
if (!queryParameters) {
|
||||
return input.endsWith("/");
|
||||
}
|
||||
return TRAILING_SLASH_RE.test(input);
|
||||
}
|
||||
function withoutTrailingSlash(input = "", queryParameters = false) {
|
||||
if (!queryParameters) {
|
||||
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
||||
}
|
||||
if (!hasTrailingSlash(input, true)) {
|
||||
return input || "/";
|
||||
}
|
||||
const [s0, ...s] = input.split("?");
|
||||
return (s0.slice(0, -1) || "/") + (s.length > 0 ? `?${s.join("?")}` : "");
|
||||
}
|
||||
function withTrailingSlash(input = "", queryParameters = false) {
|
||||
if (!queryParameters) {
|
||||
return input.endsWith("/") ? input : input + "/";
|
||||
}
|
||||
if (hasTrailingSlash(input, true)) {
|
||||
return input || "/";
|
||||
}
|
||||
const [s0, ...s] = input.split("?");
|
||||
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "");
|
||||
}
|
||||
function hasLeadingSlash(input = "") {
|
||||
return input.startsWith("/");
|
||||
}
|
||||
function withoutLeadingSlash(input = "") {
|
||||
return (hasLeadingSlash(input) ? input.slice(1) : input) || "/";
|
||||
}
|
||||
function withoutBase(input, base) {
|
||||
if (isEmptyURL(base)) {
|
||||
return input;
|
||||
}
|
||||
const _base = withoutTrailingSlash(base);
|
||||
if (!input.startsWith(_base)) {
|
||||
return input;
|
||||
}
|
||||
const trimmed = input.slice(_base.length);
|
||||
return trimmed[0] === "/" ? trimmed : "/" + trimmed;
|
||||
}
|
||||
function getQuery(input) {
|
||||
return parseQuery(parseURL(input).search);
|
||||
}
|
||||
function isEmptyURL(url) {
|
||||
return !url || url === "/";
|
||||
}
|
||||
function isNonEmptyURL(url) {
|
||||
return url && url !== "/";
|
||||
}
|
||||
function joinURL(base, ...input) {
|
||||
let url = base || "";
|
||||
for (const index of input.filter((url2) => isNonEmptyURL(url2))) {
|
||||
url = url ? withTrailingSlash(url) + withoutLeadingSlash(index) : index;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function parseURL(input = "", defaultProto) {
|
||||
if (!hasProtocol(input, true)) {
|
||||
return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
|
||||
}
|
||||
const [protocol = "", auth, hostAndPath = ""] = (input.replace(/\\/g, "/").match(/([^/:]+:)?\/\/([^/@]+@)?(.*)/) || []).splice(1);
|
||||
const [host = "", path = ""] = (hostAndPath.match(/([^#/?]*)(.*)?/) || []).splice(1);
|
||||
const { pathname, search, hash } = parsePath(path.replace(/\/(?=[A-Za-z]:)/, ""));
|
||||
return {
|
||||
protocol,
|
||||
auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
|
||||
host,
|
||||
pathname,
|
||||
search,
|
||||
hash
|
||||
};
|
||||
}
|
||||
function parsePath(input = "") {
|
||||
const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
||||
return {
|
||||
pathname,
|
||||
search,
|
||||
hash
|
||||
};
|
||||
}
|
||||
|
||||
export { withoutTrailingSlash as a, withoutBase as b, getQuery as g, joinURL as j, withTrailingSlash as w };
|
||||
+14
File diff suppressed because one or more lines are too long
+443
@@ -0,0 +1,443 @@
|
||||
var iterator;
|
||||
var hasRequiredIterator;
|
||||
|
||||
function requireIterator () {
|
||||
if (hasRequiredIterator) return iterator;
|
||||
hasRequiredIterator = 1;
|
||||
iterator = function (Yallist) {
|
||||
Yallist.prototype[Symbol.iterator] = function* () {
|
||||
for (let walker = this.head; walker; walker = walker.next) {
|
||||
yield walker.value;
|
||||
}
|
||||
};
|
||||
};
|
||||
return iterator;
|
||||
}
|
||||
|
||||
var yallist = Yallist;
|
||||
|
||||
Yallist.Node = Node;
|
||||
Yallist.create = Yallist;
|
||||
|
||||
function Yallist (list) {
|
||||
var self = this;
|
||||
if (!(self instanceof Yallist)) {
|
||||
self = new Yallist();
|
||||
}
|
||||
|
||||
self.tail = null;
|
||||
self.head = null;
|
||||
self.length = 0;
|
||||
|
||||
if (list && typeof list.forEach === 'function') {
|
||||
list.forEach(function (item) {
|
||||
self.push(item);
|
||||
});
|
||||
} else if (arguments.length > 0) {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
self.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
Yallist.prototype.removeNode = function (node) {
|
||||
if (node.list !== this) {
|
||||
throw new Error('removing node which does not belong to this list')
|
||||
}
|
||||
|
||||
var next = node.next;
|
||||
var prev = node.prev;
|
||||
|
||||
if (next) {
|
||||
next.prev = prev;
|
||||
}
|
||||
|
||||
if (prev) {
|
||||
prev.next = next;
|
||||
}
|
||||
|
||||
if (node === this.head) {
|
||||
this.head = next;
|
||||
}
|
||||
if (node === this.tail) {
|
||||
this.tail = prev;
|
||||
}
|
||||
|
||||
node.list.length--;
|
||||
node.next = null;
|
||||
node.prev = null;
|
||||
node.list = null;
|
||||
|
||||
return next
|
||||
};
|
||||
|
||||
Yallist.prototype.unshiftNode = function (node) {
|
||||
if (node === this.head) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node);
|
||||
}
|
||||
|
||||
var head = this.head;
|
||||
node.list = this;
|
||||
node.next = head;
|
||||
if (head) {
|
||||
head.prev = node;
|
||||
}
|
||||
|
||||
this.head = node;
|
||||
if (!this.tail) {
|
||||
this.tail = node;
|
||||
}
|
||||
this.length++;
|
||||
};
|
||||
|
||||
Yallist.prototype.pushNode = function (node) {
|
||||
if (node === this.tail) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node);
|
||||
}
|
||||
|
||||
var tail = this.tail;
|
||||
node.list = this;
|
||||
node.prev = tail;
|
||||
if (tail) {
|
||||
tail.next = node;
|
||||
}
|
||||
|
||||
this.tail = node;
|
||||
if (!this.head) {
|
||||
this.head = node;
|
||||
}
|
||||
this.length++;
|
||||
};
|
||||
|
||||
Yallist.prototype.push = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
push(this, arguments[i]);
|
||||
}
|
||||
return this.length
|
||||
};
|
||||
|
||||
Yallist.prototype.unshift = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
unshift(this, arguments[i]);
|
||||
}
|
||||
return this.length
|
||||
};
|
||||
|
||||
Yallist.prototype.pop = function () {
|
||||
if (!this.tail) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.tail.value;
|
||||
this.tail = this.tail.prev;
|
||||
if (this.tail) {
|
||||
this.tail.next = null;
|
||||
} else {
|
||||
this.head = null;
|
||||
}
|
||||
this.length--;
|
||||
return res
|
||||
};
|
||||
|
||||
Yallist.prototype.shift = function () {
|
||||
if (!this.head) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.head.value;
|
||||
this.head = this.head.next;
|
||||
if (this.head) {
|
||||
this.head.prev = null;
|
||||
} else {
|
||||
this.tail = null;
|
||||
}
|
||||
this.length--;
|
||||
return res
|
||||
};
|
||||
|
||||
Yallist.prototype.forEach = function (fn, thisp) {
|
||||
thisp = thisp || this;
|
||||
for (var walker = this.head, i = 0; walker !== null; i++) {
|
||||
fn.call(thisp, walker.value, i, this);
|
||||
walker = walker.next;
|
||||
}
|
||||
};
|
||||
|
||||
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
||||
thisp = thisp || this;
|
||||
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
||||
fn.call(thisp, walker.value, i, this);
|
||||
walker = walker.prev;
|
||||
}
|
||||
};
|
||||
|
||||
Yallist.prototype.get = function (n) {
|
||||
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.next;
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
};
|
||||
|
||||
Yallist.prototype.getReverse = function (n) {
|
||||
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.prev;
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
};
|
||||
|
||||
Yallist.prototype.map = function (fn, thisp) {
|
||||
thisp = thisp || this;
|
||||
var res = new Yallist();
|
||||
for (var walker = this.head; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this));
|
||||
walker = walker.next;
|
||||
}
|
||||
return res
|
||||
};
|
||||
|
||||
Yallist.prototype.mapReverse = function (fn, thisp) {
|
||||
thisp = thisp || this;
|
||||
var res = new Yallist();
|
||||
for (var walker = this.tail; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this));
|
||||
walker = walker.prev;
|
||||
}
|
||||
return res
|
||||
};
|
||||
|
||||
Yallist.prototype.reduce = function (fn, initial) {
|
||||
var acc;
|
||||
var walker = this.head;
|
||||
if (arguments.length > 1) {
|
||||
acc = initial;
|
||||
} else if (this.head) {
|
||||
walker = this.head.next;
|
||||
acc = this.head.value;
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = 0; walker !== null; i++) {
|
||||
acc = fn(acc, walker.value, i);
|
||||
walker = walker.next;
|
||||
}
|
||||
|
||||
return acc
|
||||
};
|
||||
|
||||
Yallist.prototype.reduceReverse = function (fn, initial) {
|
||||
var acc;
|
||||
var walker = this.tail;
|
||||
if (arguments.length > 1) {
|
||||
acc = initial;
|
||||
} else if (this.tail) {
|
||||
walker = this.tail.prev;
|
||||
acc = this.tail.value;
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = this.length - 1; walker !== null; i--) {
|
||||
acc = fn(acc, walker.value, i);
|
||||
walker = walker.prev;
|
||||
}
|
||||
|
||||
return acc
|
||||
};
|
||||
|
||||
Yallist.prototype.toArray = function () {
|
||||
var arr = new Array(this.length);
|
||||
for (var i = 0, walker = this.head; walker !== null; i++) {
|
||||
arr[i] = walker.value;
|
||||
walker = walker.next;
|
||||
}
|
||||
return arr
|
||||
};
|
||||
|
||||
Yallist.prototype.toArrayReverse = function () {
|
||||
var arr = new Array(this.length);
|
||||
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
||||
arr[i] = walker.value;
|
||||
walker = walker.prev;
|
||||
}
|
||||
return arr
|
||||
};
|
||||
|
||||
Yallist.prototype.slice = function (from, to) {
|
||||
to = to || this.length;
|
||||
if (to < 0) {
|
||||
to += this.length;
|
||||
}
|
||||
from = from || 0;
|
||||
if (from < 0) {
|
||||
from += this.length;
|
||||
}
|
||||
var ret = new Yallist();
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0;
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length;
|
||||
}
|
||||
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
||||
walker = walker.next;
|
||||
}
|
||||
for (; walker !== null && i < to; i++, walker = walker.next) {
|
||||
ret.push(walker.value);
|
||||
}
|
||||
return ret
|
||||
};
|
||||
|
||||
Yallist.prototype.sliceReverse = function (from, to) {
|
||||
to = to || this.length;
|
||||
if (to < 0) {
|
||||
to += this.length;
|
||||
}
|
||||
from = from || 0;
|
||||
if (from < 0) {
|
||||
from += this.length;
|
||||
}
|
||||
var ret = new Yallist();
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0;
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length;
|
||||
}
|
||||
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
||||
walker = walker.prev;
|
||||
}
|
||||
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
||||
ret.push(walker.value);
|
||||
}
|
||||
return ret
|
||||
};
|
||||
|
||||
Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
|
||||
if (start > this.length) {
|
||||
start = this.length - 1;
|
||||
}
|
||||
if (start < 0) {
|
||||
start = this.length + start;
|
||||
}
|
||||
|
||||
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
||||
walker = walker.next;
|
||||
}
|
||||
|
||||
var ret = [];
|
||||
for (var i = 0; walker && i < deleteCount; i++) {
|
||||
ret.push(walker.value);
|
||||
walker = this.removeNode(walker);
|
||||
}
|
||||
if (walker === null) {
|
||||
walker = this.tail;
|
||||
}
|
||||
|
||||
if (walker !== this.head && walker !== this.tail) {
|
||||
walker = walker.prev;
|
||||
}
|
||||
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
walker = insert(this, walker, nodes[i]);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Yallist.prototype.reverse = function () {
|
||||
var head = this.head;
|
||||
var tail = this.tail;
|
||||
for (var walker = head; walker !== null; walker = walker.prev) {
|
||||
var p = walker.prev;
|
||||
walker.prev = walker.next;
|
||||
walker.next = p;
|
||||
}
|
||||
this.head = tail;
|
||||
this.tail = head;
|
||||
return this
|
||||
};
|
||||
|
||||
function insert (self, node, value) {
|
||||
var inserted = node === self.head ?
|
||||
new Node(value, null, node, self) :
|
||||
new Node(value, node, node.next, self);
|
||||
|
||||
if (inserted.next === null) {
|
||||
self.tail = inserted;
|
||||
}
|
||||
if (inserted.prev === null) {
|
||||
self.head = inserted;
|
||||
}
|
||||
|
||||
self.length++;
|
||||
|
||||
return inserted
|
||||
}
|
||||
|
||||
function push (self, item) {
|
||||
self.tail = new Node(item, self.tail, null, self);
|
||||
if (!self.head) {
|
||||
self.head = self.tail;
|
||||
}
|
||||
self.length++;
|
||||
}
|
||||
|
||||
function unshift (self, item) {
|
||||
self.head = new Node(item, null, self.head, self);
|
||||
if (!self.tail) {
|
||||
self.tail = self.head;
|
||||
}
|
||||
self.length++;
|
||||
}
|
||||
|
||||
function Node (value, prev, next, list) {
|
||||
if (!(this instanceof Node)) {
|
||||
return new Node(value, prev, next, list)
|
||||
}
|
||||
|
||||
this.list = list;
|
||||
this.value = value;
|
||||
|
||||
if (prev) {
|
||||
prev.next = this;
|
||||
this.prev = prev;
|
||||
} else {
|
||||
this.prev = null;
|
||||
}
|
||||
|
||||
if (next) {
|
||||
next.prev = this;
|
||||
this.next = next;
|
||||
} else {
|
||||
this.next = null;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// add if support for Symbol.iterator is present
|
||||
requireIterator()(Yallist);
|
||||
} catch (er) {}
|
||||
|
||||
export { yallist as y };
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
function isObject(value) {
|
||||
return value !== null && typeof value === "object";
|
||||
}
|
||||
function _defu(baseObject, defaults, namespace = ".", merger) {
|
||||
if (!isObject(defaults)) {
|
||||
return _defu(baseObject, {}, namespace, merger);
|
||||
}
|
||||
const object = Object.assign({}, defaults);
|
||||
for (const key in baseObject) {
|
||||
if (key === "__proto__" || key === "constructor") {
|
||||
continue;
|
||||
}
|
||||
const value = baseObject[key];
|
||||
if (value === null || value === void 0) {
|
||||
continue;
|
||||
}
|
||||
if (merger && merger(object, key, value, namespace)) {
|
||||
continue;
|
||||
}
|
||||
if (Array.isArray(value) && Array.isArray(object[key])) {
|
||||
object[key] = [...value, ...object[key]];
|
||||
} else if (isObject(value) && isObject(object[key])) {
|
||||
object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
||||
} else {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
function createDefu(merger) {
|
||||
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
||||
}
|
||||
const defu = createDefu();
|
||||
|
||||
export { defu as d };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
const overrideEnv = (targetEnv) => {
|
||||
const currentEnv = process.env.NODE_ENV;
|
||||
if (currentEnv && currentEnv !== targetEnv) {
|
||||
console.warn(`Changing \`NODE_ENV\` from \`${currentEnv}\` to \`${targetEnv}\`, to avoid unintended behavior.`);
|
||||
}
|
||||
process.env.NODE_ENV = targetEnv;
|
||||
};
|
||||
|
||||
export { overrideEnv as o };
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { n as normalize, d as dirname } from './nuxi.a2d9d2e1.mjs';
|
||||
|
||||
function getModulePaths(paths) {
|
||||
return [].concat(
|
||||
global.__NUXT_PREPATHS__,
|
||||
paths,
|
||||
process.cwd(),
|
||||
global.__NUXT_PATHS__
|
||||
).filter(Boolean);
|
||||
}
|
||||
const _require = createRequire(process.cwd());
|
||||
function resolveModule(id, paths) {
|
||||
return normalize(_require.resolve(id, { paths: getModulePaths(paths) }));
|
||||
}
|
||||
function tryResolveModule(id, paths) {
|
||||
try {
|
||||
return resolveModule(id, paths);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function requireModule(id, paths) {
|
||||
return _require(resolveModule(id, paths));
|
||||
}
|
||||
function tryRequireModule(id, paths) {
|
||||
try {
|
||||
return requireModule(id, paths);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function importModule(id, paths) {
|
||||
const resolvedPath = resolveModule(id, paths);
|
||||
return import(pathToFileURL(resolvedPath).href);
|
||||
}
|
||||
function getNearestPackage(id, paths) {
|
||||
while (dirname(id) !== id) {
|
||||
try {
|
||||
return requireModule(id + "/package.json", paths);
|
||||
} catch {
|
||||
}
|
||||
id = dirname(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export { getNearestPackage as a, tryResolveModule as b, getModulePaths as g, importModule as i, tryRequireModule as t };
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
const NUMBER_CHAR_RE = /\d/;
|
||||
const STR_SPLITTERS = ["-", "_", "/", "."];
|
||||
function isUppercase(char = "") {
|
||||
if (NUMBER_CHAR_RE.test(char)) {
|
||||
return void 0;
|
||||
}
|
||||
return char.toUpperCase() === char;
|
||||
}
|
||||
function splitByCase(string_, separators) {
|
||||
const splitters = separators ?? STR_SPLITTERS;
|
||||
const parts = [];
|
||||
if (!string_ || typeof string_ !== "string") {
|
||||
return parts;
|
||||
}
|
||||
let buff = "";
|
||||
let previousUpper;
|
||||
let previousSplitter;
|
||||
for (const char of string_) {
|
||||
const isSplitter = splitters.includes(char);
|
||||
if (isSplitter === true) {
|
||||
parts.push(buff);
|
||||
buff = "";
|
||||
previousUpper = void 0;
|
||||
continue;
|
||||
}
|
||||
const isUpper = isUppercase(char);
|
||||
if (previousSplitter === false) {
|
||||
if (previousUpper === false && isUpper === true) {
|
||||
parts.push(buff);
|
||||
buff = char;
|
||||
previousUpper = isUpper;
|
||||
continue;
|
||||
}
|
||||
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
||||
const lastChar = buff[buff.length - 1];
|
||||
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
||||
buff = lastChar + char;
|
||||
previousUpper = isUpper;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
buff += char;
|
||||
previousUpper = isUpper;
|
||||
previousSplitter = isSplitter;
|
||||
}
|
||||
parts.push(buff);
|
||||
return parts;
|
||||
}
|
||||
function upperFirst(string_) {
|
||||
return !string_ ? "" : string_[0].toUpperCase() + string_.slice(1);
|
||||
}
|
||||
|
||||
export { splitByCase as s, upperFirst as u };
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
|
||||
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
||||
const JsonSigRx = /^["[{]|^-?\d[\d.]{0,14}$/;
|
||||
function jsonParseTransform(key, value) {
|
||||
if (key === "__proto__" || key === "constructor") {
|
||||
return;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function destr(value, options = {}) {
|
||||
if (typeof value !== "string") {
|
||||
return value;
|
||||
}
|
||||
const _lval = value.toLowerCase();
|
||||
if (_lval === "true") {
|
||||
return true;
|
||||
}
|
||||
if (_lval === "false") {
|
||||
return false;
|
||||
}
|
||||
if (_lval === "null") {
|
||||
return null;
|
||||
}
|
||||
if (_lval === "nan") {
|
||||
return Number.NaN;
|
||||
}
|
||||
if (_lval === "infinity") {
|
||||
return Number.POSITIVE_INFINITY;
|
||||
}
|
||||
if (_lval === "undefined") {
|
||||
return void 0;
|
||||
}
|
||||
if (!JsonSigRx.test(value)) {
|
||||
if (options.strict) {
|
||||
throw new SyntaxError("Invalid JSON");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
|
||||
return JSON.parse(value, jsonParseTransform);
|
||||
}
|
||||
return JSON.parse(value);
|
||||
} catch (error) {
|
||||
if (options.strict) {
|
||||
throw error;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
export { destr as d };
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
||||
function getDefaultExportFromCjs (x) {
|
||||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
||||
}
|
||||
|
||||
function getAugmentedNamespace(n) {
|
||||
var f = n.default;
|
||||
if (typeof f == "function") {
|
||||
var a = function () {
|
||||
return f.apply(this, arguments);
|
||||
};
|
||||
a.prototype = f.prototype;
|
||||
} else a = {};
|
||||
Object.defineProperty(a, '__esModule', {value: true});
|
||||
Object.keys(n).forEach(function (k) {
|
||||
var d = Object.getOwnPropertyDescriptor(n, k);
|
||||
Object.defineProperty(a, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return n[k];
|
||||
}
|
||||
});
|
||||
});
|
||||
return a;
|
||||
}
|
||||
|
||||
export { getDefaultExportFromCjs as a, commonjsGlobal as c, getAugmentedNamespace as g };
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
import { existsSync, promises } from 'node:fs';
|
||||
import require$$0 from 'fs';
|
||||
import require$$0$1 from 'path';
|
||||
import require$$0$2 from 'os';
|
||||
import { g as getAugmentedNamespace } from './nuxi.ed696fbc.mjs';
|
||||
import 'node:os';
|
||||
import 'crypto';
|
||||
import 'module';
|
||||
import 'util';
|
||||
import 'perf_hooks';
|
||||
import 'vm';
|
||||
import 'url';
|
||||
import 'assert';
|
||||
import 'buffer';
|
||||
import 'tty';
|
||||
import { r as resolve } from './nuxi.a2d9d2e1.mjs';
|
||||
|
||||
var main$1 = {exports: {}};
|
||||
|
||||
const name = "dotenv";
|
||||
const version$1 = "16.0.3";
|
||||
const description = "Loads environment variables from .env file";
|
||||
const main = "lib/main.js";
|
||||
const types = "lib/main.d.ts";
|
||||
const exports = {
|
||||
".": {
|
||||
require: "./lib/main.js",
|
||||
types: "./lib/main.d.ts",
|
||||
"default": "./lib/main.js"
|
||||
},
|
||||
"./config": "./config.js",
|
||||
"./config.js": "./config.js",
|
||||
"./lib/env-options": "./lib/env-options.js",
|
||||
"./lib/env-options.js": "./lib/env-options.js",
|
||||
"./lib/cli-options": "./lib/cli-options.js",
|
||||
"./lib/cli-options.js": "./lib/cli-options.js",
|
||||
"./package.json": "./package.json"
|
||||
};
|
||||
const scripts = {
|
||||
"dts-check": "tsc --project tests/types/tsconfig.json",
|
||||
lint: "standard",
|
||||
"lint-readme": "standard-markdown",
|
||||
pretest: "npm run lint && npm run dts-check",
|
||||
test: "tap tests/*.js --100 -Rspec",
|
||||
prerelease: "npm test",
|
||||
release: "standard-version"
|
||||
};
|
||||
const repository = {
|
||||
type: "git",
|
||||
url: "git://github.com/motdotla/dotenv.git"
|
||||
};
|
||||
const keywords = [
|
||||
"dotenv",
|
||||
"env",
|
||||
".env",
|
||||
"environment",
|
||||
"variables",
|
||||
"config",
|
||||
"settings"
|
||||
];
|
||||
const readmeFilename = "README.md";
|
||||
const license = "BSD-2-Clause";
|
||||
const devDependencies = {
|
||||
"@types/node": "^17.0.9",
|
||||
decache: "^4.6.1",
|
||||
dtslint: "^3.7.0",
|
||||
sinon: "^12.0.1",
|
||||
standard: "^16.0.4",
|
||||
"standard-markdown": "^7.1.0",
|
||||
"standard-version": "^9.3.2",
|
||||
tap: "^15.1.6",
|
||||
tar: "^6.1.11",
|
||||
typescript: "^4.5.4"
|
||||
};
|
||||
const engines = {
|
||||
node: ">=12"
|
||||
};
|
||||
const _package = {
|
||||
name: name,
|
||||
version: version$1,
|
||||
description: description,
|
||||
main: main,
|
||||
types: types,
|
||||
exports: exports,
|
||||
scripts: scripts,
|
||||
repository: repository,
|
||||
keywords: keywords,
|
||||
readmeFilename: readmeFilename,
|
||||
license: license,
|
||||
devDependencies: devDependencies,
|
||||
engines: engines
|
||||
};
|
||||
|
||||
const _package$1 = {
|
||||
__proto__: null,
|
||||
name: name,
|
||||
version: version$1,
|
||||
description: description,
|
||||
main: main,
|
||||
types: types,
|
||||
exports: exports,
|
||||
scripts: scripts,
|
||||
repository: repository,
|
||||
keywords: keywords,
|
||||
readmeFilename: readmeFilename,
|
||||
license: license,
|
||||
devDependencies: devDependencies,
|
||||
engines: engines,
|
||||
default: _package
|
||||
};
|
||||
|
||||
const require$$3 = /*@__PURE__*/getAugmentedNamespace(_package$1);
|
||||
|
||||
const fs = require$$0;
|
||||
const path = require$$0$1;
|
||||
const os = require$$0$2;
|
||||
const packageJson = require$$3;
|
||||
|
||||
const version = packageJson.version;
|
||||
|
||||
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
||||
|
||||
// Parser src into an Object
|
||||
function parse (src) {
|
||||
const obj = {};
|
||||
|
||||
// Convert buffer to string
|
||||
let lines = src.toString();
|
||||
|
||||
// Convert line breaks to same format
|
||||
lines = lines.replace(/\r\n?/mg, '\n');
|
||||
|
||||
let match;
|
||||
while ((match = LINE.exec(lines)) != null) {
|
||||
const key = match[1];
|
||||
|
||||
// Default undefined or null to empty string
|
||||
let value = (match[2] || '');
|
||||
|
||||
// Remove whitespace
|
||||
value = value.trim();
|
||||
|
||||
// Check if double quoted
|
||||
const maybeQuote = value[0];
|
||||
|
||||
// Remove surrounding quotes
|
||||
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
||||
|
||||
// Expand newlines if double quoted
|
||||
if (maybeQuote === '"') {
|
||||
value = value.replace(/\\n/g, '\n');
|
||||
value = value.replace(/\\r/g, '\r');
|
||||
}
|
||||
|
||||
// Add to object
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
function _log (message) {
|
||||
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
||||
}
|
||||
|
||||
function _resolveHome (envPath) {
|
||||
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
||||
}
|
||||
|
||||
// Populates process.env from .env file
|
||||
function config (options) {
|
||||
let dotenvPath = path.resolve(process.cwd(), '.env');
|
||||
let encoding = 'utf8';
|
||||
const debug = Boolean(options && options.debug);
|
||||
const override = Boolean(options && options.override);
|
||||
|
||||
if (options) {
|
||||
if (options.path != null) {
|
||||
dotenvPath = _resolveHome(options.path);
|
||||
}
|
||||
if (options.encoding != null) {
|
||||
encoding = options.encoding;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Specifying an encoding returns a string instead of a buffer
|
||||
const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
|
||||
|
||||
Object.keys(parsed).forEach(function (key) {
|
||||
if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
|
||||
process.env[key] = parsed[key];
|
||||
} else {
|
||||
if (override === true) {
|
||||
process.env[key] = parsed[key];
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
if (override === true) {
|
||||
_log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
|
||||
} else {
|
||||
_log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return { parsed }
|
||||
} catch (e) {
|
||||
if (debug) {
|
||||
_log(`Failed to load ${dotenvPath} ${e.message}`);
|
||||
}
|
||||
|
||||
return { error: e }
|
||||
}
|
||||
}
|
||||
|
||||
const DotenvModule = {
|
||||
config,
|
||||
parse
|
||||
};
|
||||
|
||||
main$1.exports.config = DotenvModule.config;
|
||||
var parse_1 = main$1.exports.parse = DotenvModule.parse;
|
||||
main$1.exports = DotenvModule;
|
||||
|
||||
async function setupDotenv(options) {
|
||||
const targetEnvironment = options.env ?? process.env;
|
||||
const environment = await loadDotenv({
|
||||
cwd: options.cwd,
|
||||
fileName: options.fileName ?? ".env",
|
||||
env: targetEnvironment,
|
||||
interpolate: options.interpolate ?? true
|
||||
});
|
||||
for (const key in environment) {
|
||||
if (!key.startsWith("_") && targetEnvironment[key] === void 0) {
|
||||
targetEnvironment[key] = environment[key];
|
||||
}
|
||||
}
|
||||
return environment;
|
||||
}
|
||||
async function loadDotenv(options) {
|
||||
const environment = /* @__PURE__ */ Object.create(null);
|
||||
const dotenvFile = resolve(options.cwd, options.fileName);
|
||||
if (existsSync(dotenvFile)) {
|
||||
const parsed = parse_1(await promises.readFile(dotenvFile, "utf8"));
|
||||
Object.assign(environment, parsed);
|
||||
}
|
||||
if (!options.env._applied) {
|
||||
Object.assign(environment, options.env);
|
||||
environment._applied = true;
|
||||
}
|
||||
if (options.interpolate) {
|
||||
interpolate(environment);
|
||||
}
|
||||
return environment;
|
||||
}
|
||||
function interpolate(target, source = {}, parse = (v) => v) {
|
||||
function getValue(key) {
|
||||
return source[key] !== void 0 ? source[key] : target[key];
|
||||
}
|
||||
function interpolate2(value, parents = []) {
|
||||
if (typeof value !== "string") {
|
||||
return value;
|
||||
}
|
||||
const matches = value.match(/(.?\${?(?:[\w:]+)?}?)/g) || [];
|
||||
return parse(matches.reduce((newValue, match) => {
|
||||
const parts = /(.?)\${?([\w:]+)?}?/g.exec(match);
|
||||
const prefix = parts[1];
|
||||
let value2, replacePart;
|
||||
if (prefix === "\\") {
|
||||
replacePart = parts[0];
|
||||
value2 = replacePart.replace("\\$", "$");
|
||||
} else {
|
||||
const key = parts[2];
|
||||
replacePart = parts[0].slice(prefix.length);
|
||||
if (parents.includes(key)) {
|
||||
console.warn(`Please avoid recursive environment variables ( loop: ${parents.join(" > ")} > ${key} )`);
|
||||
return "";
|
||||
}
|
||||
value2 = getValue(key);
|
||||
value2 = interpolate2(value2, [...parents, key]);
|
||||
}
|
||||
return value2 !== void 0 ? newValue.replace(replacePart, value2) : newValue;
|
||||
}, value));
|
||||
}
|
||||
for (const key in target) {
|
||||
target[key] = interpolate2(getValue(key));
|
||||
}
|
||||
}
|
||||
|
||||
export { setupDotenv as s };
|
||||
Reference in New Issue
Block a user