UNPKG

@atomist/sdm-core

Version:

Atomist Software Delivery Machine - Implementation

112 lines 4.62 kB
import { Configuration, ConfigurationPostProcessor } from "@atomist/automation-client"; import { Goal, GoalContribution, Goals, GoalWithFulfillment, PushListenerInvocation, PushTest, SdmContext, SoftwareDeliveryMachine } from "@atomist/sdm"; import { ConfigureOptions } from "../internal/machine/configureSdm"; import { LocalSoftwareDeliveryMachineConfiguration } from "../internal/machine/LocalSoftwareDeliveryMachineOptions"; /** * Data structure to configure goal contributions */ export interface GoalStructure { /** * Optional push tests to determine when to schedule provided goals * * If an array of push tests is provided, they will get wrapped with allSatisfied/and. */ test?: PushTest | PushTest[]; /** Optional pre conditions for goals; can be actual goal instances or names of goal contributions */ dependsOn?: string | Goal | Array<string | Goal>; /** * Goal instances to schedule * * The following cases are supported: * * goals: [ * autofix, * build * ] * * This means autofix will run after build * * goals: [ * [autofix, build] * ] * * This will schedule autofix and build concurrently * * goals: [ * [autofix, build], * dockerBuild * ] * * This will schedule autofix and build concurrently and dockerBuild once autofix and build are completed */ goals: Goal | Goals | Array<Goal | Goals | Array<Goal | Goals>>; } /** * Type to collect named GoalStructure instances * * The record key will be used to name the goal contribution. */ export declare type GoalData = Record<string, GoalStructure>; /** * Type to collect goal instances for this SDM */ export declare type DeliveryGoals = Record<string, Goal | GoalWithFulfillment>; /** * @deprecated use DeliveryGoals */ export declare type AllGoals = DeliveryGoals; /** * Type to create goal instances for this SDM */ export declare type GoalCreator<G extends DeliveryGoals> = (sdm: SoftwareDeliveryMachine) => Promise<G>; /** * Type to configure provided goals with fulfillments, listeners etc */ export declare type GoalConfigurer<G extends DeliveryGoals> = (sdm: SoftwareDeliveryMachine, goals: G) => Promise<void>; /** * Type to orchestrate the creation and configuration of goal instances for this SDM */ export declare type CreateGoals<G extends DeliveryGoals> = (creator: GoalCreator<G>, configurers?: GoalConfigurer<G> | Array<GoalConfigurer<G>>) => Promise<G>; /** * Configure a SoftwareDeliveryMachine instance by adding command, events etc and optionally returning * GoalData, an array of GoalContributions or void when no goals should be added to this SDM. */ export declare type Configurer<G extends DeliveryGoals, F extends SdmContext = PushListenerInvocation> = (sdm: SoftwareDeliveryMachine & { createGoals: CreateGoals<G>; }) => Promise<void | GoalData | Array<GoalContribution<F>>>; /** * Process the configuration before creating the SDM instance */ export declare type ConfigurationPreProcessor = (cfg: LocalSoftwareDeliveryMachineConfiguration) => Promise<LocalSoftwareDeliveryMachineConfiguration>; export interface ConfigureMachineOptions extends ConfigureOptions { /** * SDM name if you want to override the default which uses the * package name. */ name?: string; /** * These functions are called in the first postProcessor. * Specifically, the first post-processor is [[configureSdm]] * these functions are called in its * [[SoftwareDeliveryMachineMaker]] function prior to it calling * the [[createSoftwareDeliveryMachine]]. */ preProcessors?: ConfigurationPreProcessor | ConfigurationPreProcessor[]; /** * These functions are called after the [[configureSdm]] post-processor. */ postProcessors?: ConfigurationPostProcessor | ConfigurationPostProcessor[]; } /** * Function to create an SDM configuration constant to be exported from an index.ts/js. */ export declare function configure<G extends DeliveryGoals, T extends SdmContext = PushListenerInvocation>(configurer: Configurer<G, T>, options?: ConfigureMachineOptions): Configuration; /** * Convert the provided GoalData instance into an array of GoalContributions */ export declare function convertGoalData(goalData: GoalData): Array<GoalContribution<any>>; /** * Invoke the given configurer */ export declare function invokeConfigurer(sdm: SoftwareDeliveryMachine, configurer: Configurer<any, any>): Promise<void | GoalData | Array<GoalContribution<any>>>; //# sourceMappingURL=configure.d.ts.map