feat: init
This commit is contained in:
44
node_modules/nitropack/dist/kit/index.d.mts
generated
vendored
Normal file
44
node_modules/nitropack/dist/kit/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { NitroPreset, NitroPresetMeta, Nitro } from 'nitropack/types';
|
||||
import { N as NitroModule } from '../shared/nitro.DLF2_KRt.mjs';
|
||||
import 'consola';
|
||||
import 'h3';
|
||||
import 'hookable';
|
||||
import 'nitropack/presets';
|
||||
import 'unimport';
|
||||
import 'unstorage';
|
||||
import '@rollup/plugin-commonjs';
|
||||
import 'c12';
|
||||
import 'chokidar';
|
||||
import 'compatx';
|
||||
import 'db0';
|
||||
import 'httpxy';
|
||||
import 'nitropack';
|
||||
import 'pkg-types';
|
||||
import 'rollup-plugin-visualizer';
|
||||
import 'unenv';
|
||||
import 'unimport/unplugin';
|
||||
import 'unwasm/plugin';
|
||||
import 'node:http';
|
||||
import 'node:stream';
|
||||
import 'node:worker_threads';
|
||||
import 'listhen';
|
||||
import 'unplugin-utils';
|
||||
import '@vercel/nft';
|
||||
import 'esbuild';
|
||||
import 'rollup';
|
||||
import '@scalar/api-reference';
|
||||
import 'std-env';
|
||||
|
||||
declare function defineNitroPreset<P extends NitroPreset, M extends NitroPresetMeta>(preset: P, meta?: M): P & {
|
||||
_meta: NitroPresetMeta;
|
||||
};
|
||||
|
||||
declare function defineNitroModule(def: NitroModule): NitroModule;
|
||||
|
||||
declare function writeFile(file: string, contents: Buffer | string, log?: boolean): Promise<void>;
|
||||
declare function isDirectory(path: string): Promise<boolean>;
|
||||
|
||||
declare function prettyPath(p: string, highlight?: boolean): string;
|
||||
declare function resolveNitroPath(path: string, nitroOptions: Nitro["options"], base?: string): string;
|
||||
|
||||
export { defineNitroModule, defineNitroPreset, isDirectory, prettyPath, resolveNitroPath, writeFile };
|
||||
44
node_modules/nitropack/dist/kit/index.d.ts
generated
vendored
Normal file
44
node_modules/nitropack/dist/kit/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { NitroPreset, NitroPresetMeta, Nitro } from 'nitropack/types';
|
||||
import { N as NitroModule } from '../shared/nitro.DLF2_KRt.js';
|
||||
import 'consola';
|
||||
import 'h3';
|
||||
import 'hookable';
|
||||
import 'nitropack/presets';
|
||||
import 'unimport';
|
||||
import 'unstorage';
|
||||
import '@rollup/plugin-commonjs';
|
||||
import 'c12';
|
||||
import 'chokidar';
|
||||
import 'compatx';
|
||||
import 'db0';
|
||||
import 'httpxy';
|
||||
import 'nitropack';
|
||||
import 'pkg-types';
|
||||
import 'rollup-plugin-visualizer';
|
||||
import 'unenv';
|
||||
import 'unimport/unplugin';
|
||||
import 'unwasm/plugin';
|
||||
import 'node:http';
|
||||
import 'node:stream';
|
||||
import 'node:worker_threads';
|
||||
import 'listhen';
|
||||
import 'unplugin-utils';
|
||||
import '@vercel/nft';
|
||||
import 'esbuild';
|
||||
import 'rollup';
|
||||
import '@scalar/api-reference';
|
||||
import 'std-env';
|
||||
|
||||
declare function defineNitroPreset<P extends NitroPreset, M extends NitroPresetMeta>(preset: P, meta?: M): P & {
|
||||
_meta: NitroPresetMeta;
|
||||
};
|
||||
|
||||
declare function defineNitroModule(def: NitroModule): NitroModule;
|
||||
|
||||
declare function writeFile(file: string, contents: Buffer | string, log?: boolean): Promise<void>;
|
||||
declare function isDirectory(path: string): Promise<boolean>;
|
||||
|
||||
declare function prettyPath(p: string, highlight?: boolean): string;
|
||||
declare function resolveNitroPath(path: string, nitroOptions: Nitro["options"], base?: string): string;
|
||||
|
||||
export { defineNitroModule, defineNitroPreset, isDirectory, prettyPath, resolveNitroPath, writeFile };
|
||||
71
node_modules/nitropack/dist/kit/index.mjs
generated
vendored
Normal file
71
node_modules/nitropack/dist/kit/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import fsp from 'node:fs/promises';
|
||||
import consola, { consola as consola$1 } from 'consola';
|
||||
import { relative, resolve, dirname } from 'pathe';
|
||||
import { colors } from 'consola/utils';
|
||||
import { getProperty } from 'dot-prop';
|
||||
|
||||
function defineNitroPreset(preset, meta) {
|
||||
if (meta?.url && typeof preset !== "function" && preset.entry && preset.entry.startsWith(".")) {
|
||||
preset.entry = fileURLToPath(new URL(preset.entry, meta.url));
|
||||
}
|
||||
return { ...preset, _meta: meta };
|
||||
}
|
||||
|
||||
function defineNitroModule(def) {
|
||||
if (typeof def?.setup !== "function") {
|
||||
def.setup = () => {
|
||||
throw new TypeError("NitroModule must implement a `setup` method!");
|
||||
};
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
function prettyPath(p, highlight = true) {
|
||||
p = relative(process.cwd(), p);
|
||||
return highlight ? colors.cyan(p) : p;
|
||||
}
|
||||
function resolveNitroPath(path, nitroOptions, base) {
|
||||
if (typeof path !== "string") {
|
||||
throw new TypeError("Invalid path: " + path);
|
||||
}
|
||||
path = _compilePathTemplate(path)(nitroOptions);
|
||||
for (const base2 in nitroOptions.alias) {
|
||||
if (path.startsWith(base2)) {
|
||||
path = nitroOptions.alias[base2] + path.slice(base2.length);
|
||||
}
|
||||
}
|
||||
return resolve(base || nitroOptions.srcDir, path);
|
||||
}
|
||||
function _compilePathTemplate(contents) {
|
||||
return (params) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
|
||||
const val = getProperty(params, match);
|
||||
if (!val) {
|
||||
consola.warn(
|
||||
`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`
|
||||
);
|
||||
}
|
||||
return val || `${match}`;
|
||||
});
|
||||
}
|
||||
|
||||
async function writeFile(file, contents, log = false) {
|
||||
await fsp.mkdir(dirname(file), { recursive: true });
|
||||
await fsp.writeFile(
|
||||
file,
|
||||
contents,
|
||||
typeof contents === "string" ? "utf8" : void 0
|
||||
);
|
||||
if (log) {
|
||||
consola$1.info("Generated", prettyPath(file));
|
||||
}
|
||||
}
|
||||
async function isDirectory(path) {
|
||||
try {
|
||||
return (await fsp.stat(path)).isDirectory();
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export { defineNitroModule, defineNitroPreset, isDirectory, prettyPath, resolveNitroPath, writeFile };
|
||||
Reference in New Issue
Block a user