import { Jiti, JitiOptions } from 'jiti'; import { DownloadTemplateOptions } from 'giget'; import { ChokidarOptions } from 'chokidar'; import { diff } from 'ohash/utils'; interface DotenvOptions { /** * The project root directory (either absolute or relative to the current working directory). * * Defaults to `options.cwd` in `loadConfig` context, or `process.cwd()` when used as standalone. */ cwd?: string; /** * What file or files to look in for environment variables (either absolute or relative * to the current working directory). For example, `.env`. * With the array type, the order enforce the env loading priority (last one overrides). */ fileName?: string | 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; declare global { var __c12_dotenv_vars__: Map, Set>; } 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; _configFile?: string; } type ConfigSource = "overrides" | "main" | "rc" | "packageJson" | "defaultConfig"; interface ConfigFunctionContext { [key: string]: any; } interface ResolvableConfigContext { configs: Record; rawConfigs: Record | 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; /** Context passed to config functions */ context?: ConfigFunctionContext; resolve?: (id: string, options: LoadConfigOptions) => null | undefined | ResolvedConfig | Promise | undefined | null>; jiti?: Jiti; jitiOptions?: JitiOptions; giget?: false | DownloadTemplateOptions; merger?: (...sources: Array) => T; extend?: false | { extendKey?: string | string[]; }; configFileRequired?: boolean; } type DefineConfig = (input: InputConfig) => InputConfig; declare function createDefineConfig(): DefineConfig; declare const SUPPORTED_EXTENSIONS: string[]; declare function loadConfig(options: LoadConfigOptions): Promise>; type DiffEntries = ReturnType; type ConfigWatcher = ResolvedConfig & { watchingFiles: string[]; unwatch: () => Promise; }; interface WatchConfigOptions extends LoadConfigOptions { chokidarOptions?: ChokidarOptions; debounce?: false | number; onWatch?: (event: { type: "created" | "updated" | "removed"; path: string; }) => void | Promise; acceptHMR?: (context: { getDiff: () => DiffEntries; newConfig: ResolvedConfig; oldConfig: ResolvedConfig; }) => void | boolean | Promise; onUpdate?: (context: { getDiff: () => ReturnType; newConfig: ResolvedConfig; oldConfig: ResolvedConfig; }) => void | Promise; } declare function watchConfig(options: WatchConfigOptions): Promise>; export { SUPPORTED_EXTENSIONS, createDefineConfig, loadConfig, loadDotenv, setupDotenv, watchConfig }; export type { C12InputConfig, ConfigFunctionContext, ConfigLayer, ConfigLayerMeta, ConfigSource, ConfigWatcher, DefineConfig, DotenvOptions, Env, InputConfig, LoadConfigOptions, ResolvableConfig, ResolvableConfigContext, ResolvedConfig, SourceOptions, UserInputConfig, WatchConfigOptions };