import { Pool } from "task-pool"; interface Cache { /** * Imports cache data from json file if it exists. * @param relativePath The relativePath to the cache json file. */ import(relativePath?: string): Cache; /** * Get the value for a given key in the cache. */ get(key: string): string; /** * Set a value for a given key in the cache. */ set(key: string, value: string): void; /** * Exports the cache data as a json file. * @param relativePath The relativePath to the cache json file. */ export(relativePath?: string): Promise; } interface FilterRegex { regex: RegExp; invert: boolean; } interface Context { debug: boolean; configPath: string; dryRun: boolean; filterRegex: FilterRegex[]; cache?: Cache; taskPool: Pool; } type TaskRunner = (prefix?: string) => Promise; declare enum TaskStatus { /** * This task has not started yet. * If group, all sub-tasks queued. */ Queued = 0, /** * This task is currently running. * If group, at least one sub-tasks is running. */ Running = 1, /** * This task has ran successfully. * If group, all sub-tasks success. */ Success = 2, /** * This task failed. * If group, all sub-tasks failed. */ Failed = 3, /** * This task was skipped. * If group, all sub-tasks skipped. */ Skipped = 4 } interface Task { /** * The key of the task. */ key: string; /** * Running this function actually runs the task. */ run: TaskRunner; /** * The current status of this generic task. */ status: TaskStatus; /** * Register a context with the task (and sub-tasks). */ useContext(context: Context): void; /** * Render the task. */ render(depth?: number): string; } declare class GenericTask implements Task { key: string; private executor; private hashFolders; protected context: Context; protected errorOutput: string; status: TaskStatus; /** * @param key The key of this generic task. * @param executor The TaskRunner used to run this task. * @param hashFolders Folders used to create caching hash. */ constructor(key: string, executor: TaskRunner, hashFolders?: string[]); /** * Register a context with the task (and sub-tasks). */ useContext(context: Context): void; /** * Run the task executor. */ run(prefix?: string): Promise; protected shouldSkip(taskKey?: string): boolean; protected shouldSkipRegex(taskKey: string): boolean; protected shouldSkipCache(taskKey: string): boolean; render(depth?: number): string; } type ExitStatus = TaskStatus.Success | TaskStatus.Skipped | TaskStatus.Failed; declare class DummyTask extends GenericTask { private exitStatus; constructor(key: string, delay?: number, exitStatus?: ExitStatus); protected shouldSkip(taskName: string): boolean; } declare class ExecTask extends GenericTask { constructor(key: string, command: string | string[], hashFolders?: string[]); } declare class TaskOfTasks implements Task { key: string; tasks: Task[]; private concurrent; private context; /** * @param key The key of this task of tasks. * @param tasks The array of tasks for this TaskOfTasks. * @param concurrent Whether the tasks should run concurrently. */ constructor(key: string, tasks: Task[], concurrent?: boolean); /** * Register a context with the task (and sub-tasks). */ useContext(context: Context): void; /** * Get the status - dynamically determined depending on sub-statuses. */ get status(): TaskStatus; /** * Run the task of tasks, sequentially or concurrently as required. */ run(prefix?: string): Promise; /** * Run tasks concurrently. Resolves when all have ran. */ concurrently(prefix: string): Promise; /** * Run tasks sequentially. Resolves when all have ran. */ sequentially(prefix: string): Promise; render(depth?: number): string; } export { DummyTask, ExecTask, GenericTask, TaskOfTasks, Task, TaskRunner, TaskStatus };