UNPKG

2.78 kBTypeScriptView Raw
1import { TaskError } from "./task.errors";
2import { CrossbowInput } from "./index";
3import { CommandTrigger } from "./command.run";
4import { Task, Tasks } from "./task.resolve";
5import { ExternalFile } from "./file.utils";
6/**
7 * Function.name is es6 & >
8 */
9export interface CBFunction extends Function {
10 name: string;
11}
12export declare type IncomingTaskItem = string | CBFunction | Task;
13export declare type IncomingInlineArray = {
14 tasks: Array<IncomingTaskItem>;
15 runMode: TaskRunModes;
16};
17export declare type TaskCollection = Array<IncomingTaskItem>;
18export declare enum TaskTypes {
19 ExternalTask,
20 Adaptor,
21 TaskGroup,
22 ParentGroup,
23 InlineFunction,
24}
25export declare enum TaskOriginTypes {
26 CrossbowConfig,
27 NpmScripts,
28 FileSystem,
29 Adaptor,
30 InlineFunction,
31 InlineArray,
32 InlineObject,
33 InlineChildObject,
34}
35export declare enum TaskRunModes {
36 series,
37 parallel,
38}
39/**
40 * Factory for creating a new Task Item
41 * @param {object} obj
42 * @returns {object}
43 */
44export declare function createTask(obj: any): Task;
45/**
46 * When a circular reference is detected, exit with the appropriate error
47 */
48export declare function createCircularReferenceTask(incoming: Task, parents: string[]): Task;
49/**
50 * Match a task name with a top-level value from 'tasks'
51 */
52export declare function getTopLevelValue(baseTaskName: string, input: CrossbowInput): any;
53/**
54 * Anything that begins @ is always an adaptor and will skip
55 * file i/o etc.
56 * @param taskName
57 * @param parents
58 * @returns {Task}
59 */
60export declare function createAdaptorTask(taskName: any, parents: any): Task;
61/**
62 * Look at a hash and determine if the incoming 'taskName'
63 * could match a valid taskName.
64 * eg:
65 * $ crossbow run shane
66 *
67 * -> matches: 'shane' & 'shane@p'
68 */
69export declare function maybeTaskNames(tasks: {}, taskName: string): string[];
70export declare function resolveTasks(taskCollection: TaskCollection, trigger: CommandTrigger): Tasks;
71export interface Task {
72 adaptor?: string;
73 command?: string;
74 valid: boolean;
75 taskName: string;
76 baseTaskName: string;
77 subTasks: string[];
78 externalTasks: ExternalFile[];
79 tasks: Task[];
80 rawInput: string;
81 parents: string[];
82 errors: TaskError[];
83 runMode: TaskRunModes;
84 startTime?: number;
85 endTime?: number;
86 duration?: number;
87 query: any;
88 flags: any;
89 options: any;
90 cbflags: string[];
91 origin: TaskOriginTypes;
92 type: TaskTypes;
93 inlineFunctions: Array<CBFunction>;
94 env: any;
95 description: string;
96 skipped: boolean;
97 ifChanged: string[];
98}
99export interface TasknameWithOrigin {
100 items: string[];
101 origin: TaskOriginTypes;
102}
103export interface Tasks {
104 valid: Task[];
105 invalid: Task[];
106 all: Task[];
107}