UNPKG

@atomist/sdm-core

Version:

Atomist Software Delivery Machine - Implementation

108 lines 4.72 kB
import { GitProject } from "@atomist/automation-client"; import { GoalInvocation, GoalProjectListenerRegistration, PushTest } from "@atomist/sdm"; export declare const CacheInputGoalDataKey = "@atomist/sdm/input"; export declare const CacheOutputGoalDataKey = "@atomist/sdm/output"; /** * Goal cache interface for storing and retrieving arbitrary files produced * by the execution of a goal. * @see FileSystemGoalCache` */ export interface GoalCache { /** * Add a set of files (or directories) to the cache. * @param gi The goal invocation for which the cache needs to be stored. * @param p The project where the files (or directories) reside. * @param files The files (or directories) to be cached. * @param classifier An optional classifier to identify the set of files (or directories to be cached). */ put(gi: GoalInvocation, p: GitProject, files: string | string[], classifier?: string): Promise<void>; /** * Retrieve files from the cache. * @param gi The goal invocation for which the cache needs to be restored. * @param p he project where the files (or directories) need to be restored in. * @param classifier Optionally the classifier of the cache for the files to be restored. If not defined, * all caches for the GoalInvocation are restored. */ retrieve(gi: GoalInvocation, p: GitProject, classifier?: string): Promise<void>; /** * Remove files from the cache. * @param gi The goal invocation for which the cache needs to be removed. * @param classifier Optionally the classifier of the cache for the files to be removed. If not defined, * all classifiers are removed. */ remove(gi: GoalInvocation, classifier?: string): Promise<void>; } /** * Suitable for a limited set of files adhering to a pattern. */ export interface GlobFilePattern { globPattern: string | string[]; } /** * Suitable for caching complete directories, possibly containing a lot of files. */ export interface DirectoryPattern { directory: string; } export interface CacheEntry { classifier: string; pattern: GlobFilePattern | DirectoryPattern; } /** * Core options for goal caching. */ export interface GoalCacheCoreOptions { /** * Optional push test on when to trigger caching */ pushTest?: PushTest; /** * Optional listener functions that should be called when no cache entry is found. */ onCacheMiss?: GoalProjectListenerRegistration | GoalProjectListenerRegistration[]; } /** * Options for putting goal cache entries. */ export interface GoalCacheOptions extends GoalCacheCoreOptions { /** * Collection of glob patterns with classifiers to determine which * files need to be cached between goal invocations, possibly * excluding paths using regular expressions. */ entries: CacheEntry[]; } /** * Options for restoring goal cache entries. */ export interface GoalCacheRestoreOptions extends GoalCacheCoreOptions { entries?: Array<{ classifier: string; }>; } /** * Goal listener that performs caching after a goal has been run. * @param options The options for caching * @param classifier Whether only a specific classifier, as defined in the options, * needs to be cached. If omitted, all classifiers are cached. * @param classifiers Additional classifiers that need to be created. */ export declare function cachePut(options: GoalCacheOptions, classifier?: string, ...classifiers: string[]): GoalProjectListenerRegistration; export declare const NoOpGoalProjectListenerRegistration: GoalProjectListenerRegistration; /** * Goal listener that performs cache restores before a goal has been run. * @param options The options for caching * @param classifier Whether only a specific classifier, as defined in the options, * needs to be restored. If omitted, all classifiers defined in the options are restored. * @param classifiers Additional classifiers that need to be restored. */ export declare function cacheRestore(options: GoalCacheRestoreOptions, classifier?: string, ...classifiers: string[]): GoalProjectListenerRegistration; /** * Goal listener that cleans up the cache restores after a goal has been run. * @param options The options for caching * @param classifier Whether only a specific classifier, as defined in the options, * needs to be removed. If omitted, all classifiers are removed. * @param classifiers Additional classifiers that need to be removed. */ export declare function cacheRemove(options: GoalCacheOptions, classifier?: string, ...classifiers: string[]): GoalProjectListenerRegistration; //# sourceMappingURL=goalCaching.d.ts.map