UNPKG

@rushstack/heft

Version:

Build all your JavaScript projects the same way: A way that works.

225 lines 7.42 kB
import type { IHeftPlugin } from '../pluginFramework/IHeftPlugin'; import type { IScopedLogger } from '../pluginFramework/logging/ScopedLogger'; import type { HeftLifecycleSession } from '../pluginFramework/HeftLifecycleSession'; import type { HeftTaskSession } from '../pluginFramework/HeftTaskSession'; /** * "baseParameter" from heft-plugin.schema.json * @public */ export interface IBaseParameterJson { /** * Indicates the kind of syntax for this command-line parameter. */ parameterKind: 'choice' | 'choiceList' | 'flag' | 'integer' | 'integerList' | 'string' | 'stringList'; /** * The name of the parameter (e.g. \"--verbose\"). This is a required field. */ longName: string; /** * An optional short form of the parameter (e.g. \"-v\" instead of \"--verbose\"). */ shortName?: string; /** * A detailed description of the parameter, which appears when requesting help for the command (e.g. \"rush --help my-command\"). */ description: string; /** * If true, then this parameter must be included on the command line. */ required?: boolean; } /** * Part of "choiceParameter" from command-line.schema.json * @public */ export interface IChoiceParameterAlternativeJson { /** * A token that is one of the alternatives that can be used with the choice parameter, e.g. \"vanilla\" in \"--flavor vanilla\". */ name: string; /** * A detailed description for the alternative that will be shown in the command-line help. */ description: string; } /** * A custom command-line parameter whose list of arguments must be chosen from a list of allowable alternatives. * @public */ export interface IChoiceListParameterJson extends IBaseParameterJson { /** * Denotes that this is a choice list parameter. */ parameterKind: 'choiceList'; /** * A list of alternative argument values that can be chosen for this parameter. */ alternatives: IChoiceParameterAlternativeJson[]; } /** * A custom command-line parameter whose argument must be chosen from a list of allowable alternatives. * @public */ export interface IChoiceParameterJson extends IBaseParameterJson { /** * Denotes that this is a choice parameter. */ parameterKind: 'choice'; /** * A list of alternative argument values that can be chosen for this parameter. */ alternatives: IChoiceParameterAlternativeJson[]; /** * If the parameter is omitted from the command line, this value will be inserted by default. */ defaultValue?: string; } /** * A custom command-line parameter whose presence acts as an on/off switch. * @public */ export interface IFlagParameterJson extends IBaseParameterJson { /** * Denotes that this is a flag (boolean) parameter. */ parameterKind: 'flag'; } /** * A custom command-line parameter whose list of values are interpreted as integers. * @public */ export interface IIntegerListParameterJson extends IBaseParameterJson { /** * Denotes that this is an integer list parameter. */ parameterKind: 'integerList'; /** * The name of the argument for this parameter. */ argumentName: string; } /** * A custom command-line parameter whose value is interpreted as an integer. * @public */ export interface IIntegerParameterJson extends IBaseParameterJson { /** * Denotes that this is an integer parameter. */ parameterKind: 'integer'; /** * The name of the argument for this parameter. */ argumentName: string; /** * If the parameter is omitted from the command line, this value will be inserted by default. */ defaultValue?: number; } /** * A custom command-line parameter whose list of values are interpreted as strings. * @public */ export interface IStringListParameterJson extends IBaseParameterJson { /** * Denotes that this is a string list parameter. */ parameterKind: 'stringList'; /** * The name of the argument for this parameter. */ argumentName: string; } /** * A custom command-line parameter whose value is interpreted as a string. * @public */ export interface IStringParameterJson extends IBaseParameterJson { /** * Denotes that this is a string parameter. */ parameterKind: 'string'; /** * The name of the argument for this parameter. */ argumentName: string; /** * If the parameter is omitted from the command line, this value will be inserted by default. */ defaultValue?: string; } export type IParameterJson = IChoiceListParameterJson | IChoiceParameterJson | IFlagParameterJson | IIntegerListParameterJson | IIntegerParameterJson | IStringListParameterJson | IStringParameterJson; export interface IHeftPluginDefinitionJson { pluginName: string; entryPoint: string; optionsSchema?: string; parameterScope?: string; parameters?: IParameterJson[]; } export interface IHeftLifecyclePluginDefinitionJson extends IHeftPluginDefinitionJson { } export interface IHeftTaskPluginDefinitionJson extends IHeftPluginDefinitionJson { } export interface IHeftPluginDefinitionOptions { heftPluginDefinitionJson: IHeftPluginDefinitionJson; packageName: string; packageRoot: string; } export declare abstract class HeftPluginDefinitionBase { private _heftPluginDefinitionJson; private _pluginPackageName; private _resolvedEntryPoint; private _optionsSchema; protected constructor(options: IHeftPluginDefinitionOptions); /** * The package name containing the target plugin. */ get pluginPackageName(): string; /** * The name of the target plugin. */ get pluginName(): string; /** * The resolved entry point to the plugin. */ get entryPoint(): string; /** * The scope for all parameters defined by this plugin. */ get pluginParameterScope(): string; /** * The parameters that are defined for this plugin. */ get pluginParameters(): ReadonlyArray<IParameterJson>; /** * Load the plugin associated with the definition. */ loadPluginAsync(logger: IScopedLogger): Promise<IHeftPlugin>; /** * Validate the provided plugin options against the plugin's options schema, if one is provided. */ validateOptions(options: unknown): void; } export declare class HeftLifecyclePluginDefinition extends HeftPluginDefinitionBase { /** * Load a lifecycle plugin definition given the provided plugin definition options. */ static loadFromObject(options: IHeftPluginDefinitionOptions): HeftLifecyclePluginDefinition; /** * {@inheritDoc HeftPluginDefinitionBase.loadPluginAsync} * @override */ loadPluginAsync(logger: IScopedLogger): Promise<IHeftPlugin<HeftLifecycleSession, object | void>>; } export declare class HeftTaskPluginDefinition extends HeftPluginDefinitionBase { /** * Load a task plugin definition given the provided plugin definition options. */ static loadFromObject(options: IHeftPluginDefinitionOptions): HeftTaskPluginDefinition; /** * {@inheritDoc HeftPluginDefinitionBase.loadPluginAsync} * @override */ loadPluginAsync(logger: IScopedLogger): Promise<IHeftPlugin<HeftTaskSession, object | void>>; } //# sourceMappingURL=HeftPluginDefinition.d.ts.map