europa-build
Version:
Tool for generating and maintaining Europa plugins and presets
95 lines (94 loc) • 3.87 kB
TypeScript
import { Logger } from 'winston';
import { TemplateGenerator } from "../TemplateGenerator";
import { TemplateCliOption, TemplateContext, TemplateProvider } from "./TemplateProvider";
import { TemplateProviderType } from "./TemplateProviderType";
declare const _parentLogger: unique symbol;
/**
* An abstract {@link TemplateProvider} that provides common logic that is useful for the majority of implementations.
*/
export declare abstract class CommonTemplateProvider<C extends O, O extends TemplateContext> implements TemplateProvider<C> {
private readonly [_parentLogger];
/**
* Creates an instance of {@link CommonTemplateProvider} using the `options` provided.
*
* @param options - The options to be used.
*/
protected constructor(options: CommonTemplateProviderOptions);
createCliOptions(): TemplateCliOption[];
/**
* Creates common command-line options to be supported for the command-line interface of this
* {@link CommonTemplateProvider}.
*
* These can be extended with provider-specific command-line options to build the complete set by overriding
* {@link CommonTemplateProvider#extendCommonCliOptions}.
*
* @return Common command-line options.
*/
abstract createCommonCliOptions(): TemplateCliOption[];
/**
* Creates a common context to be passed to the template during rendering based on the `options` provided.
*
* These can be extended with a provider-specific context to build the complete context by overriding
* {@link CommonTemplateProvider#extendCommonContext}.
*
* @param options - The options to be used.
* @return A common template context.
*/
abstract createCommonContext(options: Partial<C>): Promise<O>;
createContext(options: Partial<C>): Promise<C>;
createGenerator(): TemplateGenerator<C>;
/**
* Extends the specified common command-line options with provider-specific command-line options.
*
* By default, this method returns a copy of `commonCliOptions`.
*
* @param commonCliOptions - The common command-line options to be extended.
* @return The extended command-line options.
*/
protected extendCommonCliOptions(commonCliOptions: TemplateCliOption[]): TemplateCliOption[];
/**
* Extends the specified common context with a provider-specific context.
*
* By default, this method returns a copy of `commonContext`.
*
* @param commonContext - The common context to be extended.
* @param options - The options to be used.
* @return The extended context.
*/
protected extendCommonContext(commonContext: O, options: Partial<C>): C;
/**
* Returns the package's author name.
*
* @param options - The options to be used.
* @return The package's author name.
*/
protected abstract getAuthorName(options: Partial<C>): string;
/**
* Returns the default package's version.
*
* @return The default package's version.
*/
protected abstract getDefaultVersion(): Promise<string>;
getDirectories(): string[];
abstract getName(): string;
/**
* Returns the value of the named option.
*
* @param options - The options to be used.
* @param name - The name of the option whose value is to be returned.
* @return The value of the named option.
* @throws If the named option does not exist.
*/
protected getRequiredContextOption<N extends keyof OP, OP extends Partial<C>>(options: OP, name: N): Exclude<OP[N], undefined>;
abstract getType(): TemplateProviderType;
}
/**
* The options used by {@link CommonTemplateProvider}.
*/
export declare type CommonTemplateProviderOptions = {
/**
* The parent logger to be used to create any children loggers.
*/
readonly parentLogger: Logger;
};
export {};