myst-cli
Version:
Command line tools for MyST
76 lines • 3.63 kB
TypeScript
import type { ProjectConfig, SiteConfig } from 'myst-config';
import { VFile } from 'vfile';
import type { ISession } from './session/types.js';
export declare function defaultConfigFile(session: ISession, path: string): string;
/**
* Find config file at the specified path
*
* @param session with valid config filenames
* @param path directory to look for config file
* @returns the resolved path to the config file, or undefined if no config file is found
* @throws an error if multiple config files are found in the path
*/
export declare function configFromPath(session: ISession, path: string): string | undefined;
/**
* Mutate config object to coerce deprecated frontmatter fields to valid schema
*/
export declare function handleDeprecatedFields(conf: {
site?: Record<string, any>;
project?: Record<string, any>;
}, file: string, vfile: VFile): void;
/**
* Load site/project config from local path to redux store
*
* Validates the loaded config and stores raw/validated values in redux.
*
* @param session with logging and redux store
* @param path local directory to load config from
* @param opts.reloadProject if true, reload the project config even if it already exists in the redux store
* @returns the validated config, or undefined when no config file exists at the path
* @throws an error if the config is invalid
*/
export declare function loadConfig(session: ISession, path: string, opts?: {
reloadProject?: boolean;
}): Promise<import("./store/types.js").ValidatedRawConfig | {
site: SiteConfig | undefined;
project: ProjectConfig | undefined;
extend: string[] | undefined;
} | undefined>;
/**
* Resolve `parts` entries in a site or project config.
*
* This will process markdown written directly in the config file and save it to the session store.
* It will replace the `parts` entry in the config with a reference to the stored part.
*
* @param session session with logging
* @param path base path for config file directory
* @param configWithParts site/project config that may define `parts`
* @param file config file path for error reporting
* @param property config key used for validation messages (`site` or `project`)
* @returns a shallow copy of the config with resolved parts, or undefined if no config is provided
*/
export declare function loadAndResolveConfigParts<T extends {
parts?: Record<string, string[]>;
}>(session: ISession, path: string, configWithParts: T | undefined, file: string, property: 'project' | 'site'): Promise<T | undefined>;
/**
* Write site config and project config to file
*
* If newConfigs are provided, the redux store will be updated with these
* configs before writing.
*
* If a config file exists on the path, this will override only the new portions
* of the config and leave the rest (i.e. if `newConfigs.siteConfig` is undefined,
* everything under the `site` key in the existing config will be unchanged).
*
* @param session with logging and redux store
* @param path directory to write config to
* @param newConfigs site and project configs to write
*/
export declare function writeConfigs(session: ISession, path: string, newConfigs?: {
siteConfig?: Record<string, any>;
projectConfig?: Record<string, any>;
}): Promise<void>;
export declare function findCurrentProjectAndLoad(session: ISession, path: string): Promise<string | undefined>;
export declare function findCurrentSiteAndLoad(session: ISession, path: string): Promise<string | undefined>;
export declare function reloadAllConfigsForCurrentSite(session: ISession): Promise<void>;
//# sourceMappingURL=config.d.ts.map