UNPKG

europa-build

Version:

Tool for generating and maintaining Europa plugins and presets

108 lines (107 loc) 2.95 kB
import { TemplateGenerator } from "../TemplateGenerator"; import { TemplateProviderType } from "./TemplateProviderType"; /** * Provides the logic to interact with and render a named template. */ export interface TemplateProvider<C extends TemplateContext> { /** * Creates a command-line options to be supported for the command-line interface of this {@link TemplateProvider}. * * @return Command-line options. */ createCliOptions(): TemplateCliOption[]; /** * Creates a context to be passed to the template during rendering based on the `options` provided. * * @param options - The options to be used. * @return A template context. */ createContext(options: Partial<C>): Promise<C>; /** * Creates a template generator for this {@link TemplateProvider}. * * @return A template generator. */ createGenerator(): TemplateGenerator<C>; /** * The paths of the directories relative to the bundled `templates` directory that contain the template files to be * applied. * * @return The template directories to be applied. */ getDirectories(): string[]; /** * Returns the general name of this {@link TemplateProvider}. * * @return The general template name. */ getName(): string; /** * Returns the general type of this {@link TemplateProvider}. * * @return The general template type. */ getType(): TemplateProviderType; } /** * A command-line option to be supported for the command-line interface of a {@link TemplateProvider}. */ export interface TemplateCliOption { /** * The name of the option's argument, where applicable. */ readonly arg?: string; /** * The default value of the option, where applicable. */ readonly defaultValue?: any; /** * The description of the option's default value, where applicable. */ readonly defaultValueDescription?: string; /** * The description of the option. */ readonly description: string; /** * The long name of the option. */ readonly longName: string; /** * The short name of the option, where applicable. */ readonly shortName?: string; } /** * The context passed to a template during rendering. */ export interface TemplateContext { /** * The name of the package's author. */ readonly authorName: string; /** * The copyright year. */ readonly copyrightYear: number; /** * The description of the package. */ readonly description: string; /** * The version of Europa. */ readonly europaVersion: string; /** * The keywords for the package. */ readonly keywords: readonly string[]; /** * The name of the package. */ readonly name: string; /** * The version of the package. */ readonly version: string; }