UNPKG

@withstudiocms/config-utils

Version:

Utilities for managing configuration files

28 lines (27 loc) 1.88 kB
import type { z } from 'astro/zod'; import type { ConfigResolverBuilderOpts, WatchConfigFileOptions } from './types.js'; /** * Builds a config resolver utility for Astro integrations. * * This function creates a utility that loads, validates, and merges configuration * from both inline options and config files, using a provided Zod schema for validation. * If both inline config and a config file are present, the config file takes precedence during merging. * * @template ConfigType - The shape of the configuration object. * @template Schema - The Zod schema type used for validation. * @param params - The configuration resolver options. * @param params.configPaths - Array of possible config file paths to search for. * @param params.label - A label used for logging. * @param params.zodSchema - The Zod schema used to validate and parse the config. * @returns A utility function to be used in the Astro config setup hook, which loads, validates, and merges configuration. */ export declare const configResolverBuilder: <S extends z.ZodTypeAny>({ configPaths, label, zodSchema, }: ConfigResolverBuilderOpts<S>) => import("astro-integration-kit").HookUtility<"astro:config:setup", [options: S["_input"]], Promise<S["_output"]>>; /** * Creates an Astro integration utility that watches for changes in the first existing configuration file * found in the provided `configPaths`. When a configuration file is detected, it is registered for watching * using Astro's `addWatchFile` mechanism. * * @param configPaths - An array of possible configuration file paths to check for existence. * @returns An Astro integration utility function for the `astro:config:setup` hook. */ export declare const watchConfigFileBuilder: ({ configPaths, _test_report }: WatchConfigFileOptions) => import("astro-integration-kit").HookUtility<"astro:config:setup", [], void>;