1 |
|
2 | import { Task } from './task';
|
3 | import { ShellContext } from './exec';
|
4 | import { ILoggerProps, Logger } from './logger';
|
5 | export interface GlobalOptions {
|
6 | |
7 |
|
8 |
|
9 | loading?: boolean;
|
10 | indent?: number;
|
11 | |
12 |
|
13 |
|
14 |
|
15 | strict?: boolean;
|
16 | logger?: ILoggerProps;
|
17 | logCommand?: boolean;
|
18 | options?: any;
|
19 | rawArgs?: string[];
|
20 | }
|
21 | export interface RunDepOptions {
|
22 | rawArgs?: string[];
|
23 | parentCtx?: TaskContext | null;
|
24 |
|
25 | loading?: boolean;
|
26 | indent?: number;
|
27 | }
|
28 | export interface RunTaskOptions extends RunDepOptions {
|
29 | options?: any;
|
30 | rawArgs?: string[];
|
31 | parentCtx?: TaskContext | null;
|
32 | force?: boolean;
|
33 | }
|
34 | export declare enum TaskState {
|
35 | waiting = "waiting",
|
36 | pending = "pending",
|
37 | skipped = "skipped",
|
38 | loading = "loading",
|
39 | succeeded = "succeeded",
|
40 | failed = "failed"
|
41 | }
|
42 | export interface DepsTree {
|
43 | uid: string;
|
44 | task: Task;
|
45 | asyncDeps: DepsTree[][];
|
46 | syncDeps: DepsTree[];
|
47 | state: TaskState;
|
48 | depth: number;
|
49 | priority: number;
|
50 | }
|
51 | export declare class TaskContext<O = any> extends ShellContext {
|
52 | task: Task<O>;
|
53 | global: GlobalOptions;
|
54 | fs: {
|
55 | access: typeof import("fs").access.__promisify__;
|
56 | open: typeof import("fs").open.__promisify__;
|
57 | rename: typeof import("fs").rename.__promisify__;
|
58 | truncate: typeof import("fs").truncate.__promisify__;
|
59 | rmdir: typeof import("fs").rmdir.__promisify__;
|
60 | mkdir: typeof import("fs").mkdir.__promisify__;
|
61 | readdir: typeof import("fs").readdir.__promisify__;
|
62 | readlink: typeof import("fs").readlink.__promisify__;
|
63 | symlink: typeof import("fs").symlink.__promisify__;
|
64 | lstat: typeof import("fs").lstat.__promisify__;
|
65 | stat: typeof import("fs").stat.__promisify__;
|
66 | link: typeof import("fs").link.__promisify__;
|
67 | unlink: typeof import("fs").unlink.__promisify__;
|
68 | chmod: typeof import("fs").chmod.__promisify__;
|
69 | chown: typeof import("fs").chown.__promisify__;
|
70 | utimes: typeof import("fs").utimes.__promisify__;
|
71 | realpath: typeof import("fs").realpath.__promisify__;
|
72 | mkdtemp: typeof import("fs").mkdtemp.__promisify__;
|
73 | writeFile: typeof import("fs").writeFile.__promisify__;
|
74 | appendFile: typeof import("fs").appendFile.__promisify__;
|
75 | readFile: typeof import("fs").readFile.__promisify__;
|
76 | existsSync: typeof import("fs").existsSync;
|
77 | createReadString: typeof import("fs").createReadStream;
|
78 | createWriteStream: typeof import("fs").createWriteStream;
|
79 | constants: typeof import("fs").constants;
|
80 | watchDir: {
|
81 | (dir: string, cb: import("./fs").WatchDirHandler): void;
|
82 | (dir: string, options: import("./fs").WatchDirOptions, cb: import("./fs").WatchDirHandler): void;
|
83 | };
|
84 | copy: (src: string, dist: string, opts?: {
|
85 | skip?: ((file: string, stat: import("fs").Stats) => boolean | void | Promise<boolean | void>) | undefined;
|
86 | override?: boolean | undefined;
|
87 | } | undefined) => Promise<void>;
|
88 | exists(path: import("fs").PathLike): Promise<boolean>;
|
89 | lexists(path: import("fs").PathLike): Promise<boolean>;
|
90 | isFile(path: import("fs").PathLike): Promise<boolean>;
|
91 | isDirectory(path: import("fs").PathLike): Promise<boolean>;
|
92 | isSymbolicLink(path: import("fs").PathLike): Promise<boolean>;
|
93 | copyFile: typeof import("fs").copyFile.__promisify__ | ((src: import("fs").PathLike, dist: import("fs").PathLike) => Promise<unknown>);
|
94 | mkdirp(dir: string): Promise<void>;
|
95 | mkdirpSync(dir: string): void;
|
96 | rmrf(path: string): Promise<void>;
|
97 | outputFile(path: string, data: any, options?: string | (import("fs").BaseEncodingOptions & {
|
98 | mode?: string | number | undefined;
|
99 | flag?: string | undefined;
|
100 | }) | null | undefined): Promise<void>;
|
101 | outputFileSync(path: string, data: any, options?: string | (import("fs").BaseEncodingOptions & {
|
102 | mode?: string | number | undefined;
|
103 | flag?: string | undefined;
|
104 | }) | null | undefined): void;
|
105 | outputJson(path: string, data: object, options?: ({
|
106 | space?: number | undefined;
|
107 | replacer?: ((key: string, value: any) => any) | undefined;
|
108 | } & string) | ({
|
109 | space?: number | undefined;
|
110 | replacer?: ((key: string, value: any) => any) | undefined;
|
111 | } & import("fs").BaseEncodingOptions & {
|
112 | mode?: string | number | undefined;
|
113 | flag?: string | undefined;
|
114 | }) | undefined): Promise<void>;
|
115 | outputJsonSync(path: string, data: any, options?: ({
|
116 | space?: number | undefined;
|
117 | replacer?: ((key: string, value: any) => any) | undefined;
|
118 | } & string) | ({
|
119 | space?: number | undefined;
|
120 | replacer?: ((key: string, value: any) => any) | undefined;
|
121 | } & import("fs").BaseEncodingOptions & {
|
122 | mode?: string | number | undefined;
|
123 | flag?: string | undefined;
|
124 | }) | undefined): void;
|
125 | readJson<T = any>(path: string, options?: {
|
126 | encoding?: null | undefined;
|
127 | flag?: string | undefined;
|
128 | } | null | undefined): Promise<T>;
|
129 | readJsonSync<T_1 = any>(path: string, options?: {
|
130 | encoding?: null | undefined;
|
131 | flag?: string | undefined;
|
132 | } | null | undefined): T_1;
|
133 | iter(dir: string, skip: (path: string, stat: import("fs").Stats) => boolean | void | Promise<boolean | void>): Promise<void>;
|
134 | renameSync(oldPath: import("fs").PathLike, newPath: import("fs").PathLike): void;
|
135 | truncateSync(path: import("fs").PathLike, len?: number | null | undefined): void;
|
136 | ftruncate: typeof import("fs").ftruncate;
|
137 | ftruncateSync(fd: number, len?: number | null | undefined): void;
|
138 | chownSync(path: import("fs").PathLike, uid: number, gid: number): void;
|
139 | fchown: typeof import("fs").fchown;
|
140 | fchownSync(fd: number, uid: number, gid: number): void;
|
141 | lchown: typeof import("fs").lchown;
|
142 | lchownSync(path: import("fs").PathLike, uid: number, gid: number): void;
|
143 | chmodSync(path: import("fs").PathLike, mode: string | number): void;
|
144 | fchmod: typeof import("fs").fchmod;
|
145 | fchmodSync(fd: number, mode: string | number): void;
|
146 | lchmod: typeof import("fs").lchmod;
|
147 | lchmodSync(path: import("fs").PathLike, mode: string | number): void;
|
148 | statSync(path: import("fs").PathLike, options: import("fs").BigIntOptions): import("fs").BigIntStats;
|
149 | statSync(path: import("fs").PathLike, options: import("fs").StatOptions): import("fs").Stats | import("fs").BigIntStats;
|
150 | statSync(path: import("fs").PathLike): import("fs").Stats;
|
151 | fstat: typeof import("fs").fstat;
|
152 | fstatSync(fd: number): import("fs").Stats;
|
153 | lstatSync(path: import("fs").PathLike): import("fs").Stats;
|
154 | linkSync(existingPath: import("fs").PathLike, newPath: import("fs").PathLike): void;
|
155 | symlinkSync(target: import("fs").PathLike, path: import("fs").PathLike, type?: "dir" | "file" | "junction" | null | undefined): void;
|
156 | readlinkSync(path: import("fs").PathLike, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | import("fs").BaseEncodingOptions | null | undefined): string;
|
157 | readlinkSync(path: import("fs").PathLike, options: import("fs").BufferEncodingOption): Buffer;
|
158 | readlinkSync(path: import("fs").PathLike, options?: string | import("fs").BaseEncodingOptions | null | undefined): string | Buffer;
|
159 | realpathSync: typeof import("fs").realpathSync;
|
160 | unlinkSync(path: import("fs").PathLike): void;
|
161 | rmdirSync(path: import("fs").PathLike, options?: import("fs").RmDirOptions | undefined): void;
|
162 | mkdirSync(path: import("fs").PathLike, options: import("fs").MakeDirectoryOptions & {
|
163 | recursive: true;
|
164 | }): string;
|
165 | mkdirSync(path: import("fs").PathLike, options?: string | number | (import("fs").MakeDirectoryOptions & {
|
166 | recursive?: false | undefined;
|
167 | }) | null | undefined): void;
|
168 | mkdirSync(path: import("fs").PathLike, options?: string | number | import("fs").MakeDirectoryOptions | null | undefined): string | undefined;
|
169 | mkdtempSync(prefix: string, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | import("fs").BaseEncodingOptions | null | undefined): string;
|
170 | mkdtempSync(prefix: string, options: import("fs").BufferEncodingOption): Buffer;
|
171 | mkdtempSync(prefix: string, options?: string | import("fs").BaseEncodingOptions | null | undefined): string | Buffer;
|
172 | readdirSync(path: import("fs").PathLike, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | {
|
173 | encoding: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | null;
|
174 | withFileTypes?: false | undefined;
|
175 | } | null | undefined): string[];
|
176 | readdirSync(path: import("fs").PathLike, options: "buffer" | {
|
177 | encoding: "buffer";
|
178 | withFileTypes?: false | undefined;
|
179 | }): Buffer[];
|
180 | readdirSync(path: import("fs").PathLike, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | (import("fs").BaseEncodingOptions & {
|
181 | withFileTypes?: false | undefined;
|
182 | }) | null | undefined): string[] | Buffer[];
|
183 | readdirSync(path: import("fs").PathLike, options: import("fs").BaseEncodingOptions & {
|
184 | withFileTypes: true;
|
185 | }): import("fs").Dirent[];
|
186 | close: typeof import("fs").close;
|
187 | closeSync(fd: number): void;
|
188 | openSync(path: import("fs").PathLike, flags: string | number, mode?: string | number | null | undefined): number;
|
189 | utimesSync(path: import("fs").PathLike, atime: string | number | Date, mtime: string | number | Date): void;
|
190 | futimes: typeof import("fs").futimes;
|
191 | futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
|
192 | fsync: typeof import("fs").fsync;
|
193 | fsyncSync(fd: number): void;
|
194 | write: typeof import("fs").write;
|
195 | writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null | undefined, length?: number | null | undefined, position?: number | null | undefined): number;
|
196 | writeSync(fd: number, string: string, position?: number | null | undefined, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | null | undefined): number;
|
197 | read: typeof import("fs").read;
|
198 | readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
|
199 | readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: import("fs").ReadSyncOptions | undefined): number;
|
200 | readFileSync(path: string | number | Buffer | import("url").URL, options?: {
|
201 | encoding?: null | undefined;
|
202 | flag?: string | undefined;
|
203 | } | null | undefined): Buffer;
|
204 | readFileSync(path: string | number | Buffer | import("url").URL, options: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | {
|
205 | encoding: BufferEncoding;
|
206 | flag?: string | undefined;
|
207 | }): string;
|
208 | readFileSync(path: string | number | Buffer | import("url").URL, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | (import("fs").BaseEncodingOptions & {
|
209 | flag?: string | undefined;
|
210 | }) | null | undefined): string | Buffer;
|
211 | writeFileSync(path: string | number | Buffer | import("url").URL, data: string | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array, options?: string | (import("fs").BaseEncodingOptions & {
|
212 | mode?: string | number | undefined;
|
213 | flag?: string | undefined;
|
214 | }) | null | undefined): void;
|
215 | appendFileSync(file: string | number | Buffer | import("url").URL, data: string | Uint8Array, options?: string | (import("fs").BaseEncodingOptions & {
|
216 | mode?: string | number | undefined;
|
217 | flag?: string | undefined;
|
218 | }) | null | undefined): void;
|
219 | watchFile(filename: import("fs").PathLike, options: {
|
220 | persistent?: boolean | undefined;
|
221 | interval?: number | undefined;
|
222 | } | undefined, listener: (curr: import("fs").Stats, prev: import("fs").Stats) => void): void;
|
223 | watchFile(filename: import("fs").PathLike, listener: (curr: import("fs").Stats, prev: import("fs").Stats) => void): void;
|
224 | unwatchFile(filename: import("fs").PathLike, listener?: ((curr: import("fs").Stats, prev: import("fs").Stats) => void) | undefined): void;
|
225 | watch(filename: import("fs").PathLike, options: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | {
|
226 | encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | null | undefined;
|
227 | persistent?: boolean | undefined;
|
228 | recursive?: boolean | undefined;
|
229 | } | null | undefined, listener?: ((event: string, filename: string) => void) | undefined): import("fs").FSWatcher;
|
230 | watch(filename: import("fs").PathLike, options: "buffer" | {
|
231 | encoding: "buffer";
|
232 | persistent?: boolean | undefined;
|
233 | recursive?: boolean | undefined;
|
234 | }, listener?: ((event: string, filename: Buffer) => void) | undefined): import("fs").FSWatcher;
|
235 | watch(filename: import("fs").PathLike, options: string | {
|
236 | encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | null | undefined;
|
237 | persistent?: boolean | undefined;
|
238 | recursive?: boolean | undefined;
|
239 | } | null, listener?: ((event: string, filename: string | Buffer) => void) | undefined): import("fs").FSWatcher;
|
240 | watch(filename: import("fs").PathLike, listener?: ((event: string, filename: string) => any) | undefined): import("fs").FSWatcher;
|
241 | accessSync(path: import("fs").PathLike, mode?: number | undefined): void;
|
242 | createReadStream(path: import("fs").PathLike, options?: string | {
|
243 | flags?: string | undefined;
|
244 | encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined;
|
245 | fd?: number | undefined;
|
246 | mode?: number | undefined;
|
247 | autoClose?: boolean | undefined;
|
248 | emitClose?: boolean | undefined;
|
249 | start?: number | undefined;
|
250 | end?: number | undefined;
|
251 | highWaterMark?: number | undefined;
|
252 | } | undefined): import("fs").ReadStream;
|
253 | fdatasync: typeof import("fs").fdatasync;
|
254 | fdatasyncSync(fd: number): void;
|
255 | copyFileSync(src: import("fs").PathLike, dest: import("fs").PathLike, flags?: number | undefined): void;
|
256 | writev: typeof import("fs").writev;
|
257 | writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | undefined): number;
|
258 | readv: typeof import("fs").readv;
|
259 | readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | undefined): number;
|
260 | opendirSync(path: string, options?: import("fs").OpenDirOptions | undefined): import("fs").Dir;
|
261 | opendir: typeof import("fs").opendir;
|
262 | promises: typeof import("fs/promises");
|
263 | Stats: typeof import("fs").Stats;
|
264 | Dirent: typeof import("fs").Dirent;
|
265 | Dir: typeof import("fs").Dir;
|
266 | ReadStream: typeof import("fs").ReadStream;
|
267 | WriteStream: typeof import("fs").WriteStream;
|
268 | BigIntStats: typeof import("fs").BigIntStats;
|
269 | };
|
270 | protected _logger: Logger;
|
271 | get debug(): (...args: any[]) => void;
|
272 | get info(): (...args: any[]) => void;
|
273 | get log(): (...args: any[]) => void;
|
274 | get warn(): (...args: any[]) => void;
|
275 | get error(): (...args: any[]) => void;
|
276 | constructor(task: Task<O>, global: GlobalOptions);
|
277 | /**
|
278 | * get task options
|
279 | */
|
280 | get options(): O;
|
281 | /**
|
282 | * run a task manually
|
283 | * @param task
|
284 | * @param options
|
285 | */
|
286 | run(task: string | Task, options?: RunTaskOptions): Promise<void>;
|
287 | }
|
288 | export declare type Callback = {
|
289 | fn: (args?: any) => void | Promise<void>;
|
290 | namespaces: string[];
|
291 | };
|
292 | export declare type ListenerNames = 'before' | 'after' | 'onerror';
|
293 | export declare class TaskManager {
|
294 | private _tasks;
|
295 | private _didMap;
|
296 | namespaces: string[];
|
297 | listeners: {
|
298 | before: Callback[];
|
299 | after: Callback[];
|
300 | onerror: Callback[];
|
301 | };
|
302 | globalOptions: GlobalOptions;
|
303 | getTasks(): Task<any>[];
|
304 | addTask(task: Task): Task<any>;
|
305 | resolveDependencyTree(t: Task, depth?: number): DepsTree;
|
306 | isLoading(t: Task, props: RunTaskOptions): boolean;
|
307 | runDepsTree(depsTree: DepsTree, props: RunTaskOptions): Promise<void>;
|
308 | runListner(name: ListenerNames, ns: string[], args?: any[]): Promise<void>;
|
309 | run(name?: string | Task, props?: RunTaskOptions): Promise<void>;
|
310 | }
|