/** * Implementation of a generic "create and/or update some file" task * @module */ import type { JsonObject, JsonValue } from 'type-fest'; import type { NormalizedPackageJson } from './utils/index.js'; /** * Options for a task which are not the {@link ScaffoldTaskOptions base options} */ export type TaskSpecificOpts = Omit; /** * A function which performs some scaffolding task. * * @see {@linkcode createScaffoldTask} */ export type ScaffoldTask = (opts: Opts) => Promise>; /** * Optional function which can be used to post-process the content of a file. Usually used to merge * various options with existing content */ export type ScaffoldTaskTransformer = (content: Readonly, opts: TaskSpecificOpts, pkg: Readonly) => T; /** * A function which deserializes a string into a JS value. */ export type ScaffoldTaskDeserializer = (content: string) => T; /** * A function which serializes a JS value into a string. */ export type ScaffoldTaskSerializer = (content: T) => string; /** * Options for {@linkcode createScaffoldTask} */ export interface CreateScaffoldTaskOptions { /** * Transformer function */ transform?: ScaffoldTaskTransformer; /** * Deserializer function */ deserialize?: ScaffoldTaskDeserializer; /** * Serializer function */ serialize?: ScaffoldTaskSerializer; } /** * Base options for all scaffold tasks */ export interface ScaffoldTaskOptions { /** * Current working directory */ cwd?: string; /** * Destination file */ dest?: string; /** * If `true` will not write files */ dryRun?: boolean; /** * If `true` will overwrite fields in `typedoc.json` */ overwrite?: boolean; /** * Path to `package.json` */ packageJson?: string; } /** * The return value of a {@linkcode ScaffoldTask} */ export interface ScaffoldTaskResult { /** * The content of whatever it wrote or would write */ content: T; /** * The filepath of whatever it wrote or would write */ path: string; } /** * Factory for a {@linkcode ScaffoldTask}. * * @param defaultFilename Default file to create * @param defaultContent Default content to use * @param description Description of task * @param opts Options * @returns A scaffold task */ export declare function createScaffoldTask(defaultFilename: string, defaultContent: T, description: string, { transform, deserialize, serialize, }?: CreateScaffoldTaskOptions): ScaffoldTask; //# sourceMappingURL=scaffold.d.ts.map