import { JITI } from 'jiti'; import { JITIOptions } from 'jiti/dist/types'; import { DownloadTemplateOptions } from 'giget'; import { WatchOptions } from 'chokidar'; import { diff } from 'ohash'; interface DotenvOptions { /** * The project root directory (either absolute or relative to the current working directory). */ cwd: string; /** * What file to look in for environment variables (either absolute or relative * to the current working directory). For example, `.env`. */ fileName?: string; /** * Whether to interpolate variables within .env. * * @example * ```env * BASE_DIR="/test" * # resolves to "/test/further" * ANOTHER_DIR="${BASE_DIR}/further" * ``` */ interpolate?: boolean; /** * An object describing environment variables (key, value pairs). */ env?: NodeJS.ProcessEnv; } type Env = typeof process.env; /** * Load and interpolate environment variables into `process.env`. * If you need more control (or access to the values), consider using `loadDotenv` instead * */ declare function setupDotenv(options: DotenvOptions): Promise; /** Load environment variables into an object. */ declare function loadDotenv(options: DotenvOptions): Promise; interface ConfigLayerMeta { name?: string; [key: string]: any; } type UserInputConfig = Record; interface C12InputConfig { $test?: T; $development?: T; $production?: T; $env?: Record; $meta?: MT; } type InputConfig = C12InputConfig & T; interface SourceOptions { /** Custom meta for layer */ meta?: MT; /** Layer config overrides */ overrides?: T; [key: string]: any; /** * Options for cloning remote sources * * @see https://giget.unjs.io */ giget?: DownloadTemplateOptions; /** * Install dependencies after cloning * * @see https://nypm.unjs.io */ install?: boolean; /** * Token for cloning private sources * * @see https://giget.unjs.io#providing-token-for-private-repositories */ auth?: string; } interface ConfigLayer { config: T | null; source?: string; sourceOptions?: SourceOptions; meta?: MT; cwd?: string; configFile?: string; } interface ResolvedConfig extends ConfigLayer { config: T; layers?: ConfigLayer[]; cwd?: string; } interface ResolvableConfigContext { configs: Record<"overrides" | "main" | "rc" | "packageJson" | "defaultConfig", T | null | undefined>; } type MaybePromise = T | Promise; type ResolvableConfig = MaybePromise | ((ctx: ResolvableConfigContext) => MaybePromise); interface LoadConfigOptions { name?: string; cwd?: string; configFile?: string; rcFile?: false | string; globalRc?: boolean; dotenv?: boolean | DotenvOptions; envName?: string | false; packageJson?: boolean | string | string[]; defaults?: T; defaultConfig?: ResolvableConfig; overrides?: ResolvableConfig; omit$Keys?: boolean; resolve?: (id: string, options: LoadConfigOptions) => null | undefined | ResolvedConfig | Promise | undefined | null>; jiti?: JITI; jitiOptions?: JITIOptions; giget?: DownloadTemplateOptions; merger?: (...sources: Array) => T; extend?: false | { extendKey?: string | string[]; }; } type DefineConfig = (input: InputConfig) => InputConfig; declare function createDefineConfig(): DefineConfig; declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts", ".json", ".jsonc", ".json5", ".yaml", ".yml", ".toml"]; declare function loadConfig(options: LoadConfigOptions): Promise>; type ConfigWatcher = ResolvedConfig & { watchingFiles: string[]; unwatch: () => Promise; }; interface WatchConfigOptions extends LoadConfigOptions { chokidarOptions?: WatchOptions; debounce?: false | number; onWatch?: (event: { type: "created" | "updated" | "removed"; path: string; }) => void | Promise; acceptHMR?: (context: { getDiff: () => ReturnType; newConfig: ResolvedConfig; oldConfig: ResolvedConfig; }) => void | boolean | Promise; onUpdate?: (context: { getDiff: () => ReturnType; newConfig: ResolvedConfig; oldConfig: ResolvedConfig; }) => void | Promise; } declare function watchConfig(options: WatchConfigOptions): Promise>; export { type C12InputConfig, type ConfigLayer, type ConfigLayerMeta, type ConfigWatcher, type DefineConfig, type DotenvOptions, type Env, type InputConfig, type LoadConfigOptions, type ResolvableConfig, type ResolvableConfigContext, type ResolvedConfig, SUPPORTED_EXTENSIONS, type SourceOptions, type UserInputConfig, type WatchConfigOptions, createDefineConfig, loadConfig, loadDotenv, setupDotenv, watchConfig };