///
import { Task } from './task';
import { ShellContext } from './exec';
import { ILoggerProps, Logger } from './logger';
export interface GlobalOptions {
/**
* @default true
*/
loading?: boolean;
indent?: number;
/**
* @description Whether task options only allow defined options, default false
* @default false
*/
strict?: boolean;
logger?: ILoggerProps;
logCommand?: boolean;
options?: any;
rawArgs?: string[];
}
export interface RunDepOptions {
rawArgs?: string[];
parentCtx?: TaskContext | null;
/** default is false */
loading?: boolean;
indent?: number;
}
export interface RunTaskOptions extends RunDepOptions {
options?: any;
rawArgs?: string[];
parentCtx?: TaskContext | null;
force?: boolean;
}
export declare enum TaskState {
waiting = "waiting",
pending = "pending",
skipped = "skipped",
loading = "loading",
succeeded = "succeeded",
failed = "failed"
}
export interface DepsTree {
uid: string;
task: Task;
asyncDeps: DepsTree[][];
syncDeps: DepsTree[];
state: TaskState;
depth: number;
priority: number;
}
export declare class TaskContext extends ShellContext {
task: Task;
global: GlobalOptions;
fs: {
access: typeof import("fs").access.__promisify__;
open: typeof import("fs").open.__promisify__;
rename: typeof import("fs").rename.__promisify__;
truncate: typeof import("fs").truncate.__promisify__;
rmdir: typeof import("fs").rmdir.__promisify__;
mkdir: typeof import("fs").mkdir.__promisify__;
readdir: typeof import("fs").readdir.__promisify__;
readlink: typeof import("fs").readlink.__promisify__;
symlink: typeof import("fs").symlink.__promisify__;
lstat: typeof import("fs").lstat.__promisify__;
stat: typeof import("fs").stat.__promisify__;
link: typeof import("fs").link.__promisify__;
unlink: typeof import("fs").unlink.__promisify__;
chmod: typeof import("fs").chmod.__promisify__;
chown: typeof import("fs").chown.__promisify__;
utimes: typeof import("fs").utimes.__promisify__;
realpath: typeof import("fs").realpath.__promisify__;
mkdtemp: typeof import("fs").mkdtemp.__promisify__;
writeFile: typeof import("fs").writeFile.__promisify__;
appendFile: typeof import("fs").appendFile.__promisify__;
readFile: typeof import("fs").readFile.__promisify__;
existsSync: typeof import("fs").existsSync;
createReadString: typeof import("fs").createReadStream;
createWriteStream: typeof import("fs").createWriteStream;
constants: typeof import("fs").constants;
watchDir: {
(dir: string, cb: import("./fs").WatchDirHandler): void;
(dir: string, options: import("./fs").WatchDirOptions, cb: import("./fs").WatchDirHandler): void;
};
copy: (src: string, dist: string, opts?: {
skip?: ((file: string, stat: import("fs").Stats) => boolean | void | Promise) | undefined;
override?: boolean | undefined;
} | undefined) => Promise;
exists(path: import("fs").PathLike): Promise;
lexists(path: import("fs").PathLike): Promise;
isFile(path: import("fs").PathLike): Promise;
isDirectory(path: import("fs").PathLike): Promise;
isSymbolicLink(path: import("fs").PathLike): Promise;
copyFile: typeof import("fs").copyFile.__promisify__ | ((src: import("fs").PathLike, dist: import("fs").PathLike) => Promise);
mkdirp(dir: string): Promise;
mkdirpSync(dir: string): void;
rmrf(path: string): Promise;
outputFile(path: string, data: any, options?: string | (import("fs").BaseEncodingOptions & {
mode?: string | number | undefined;
flag?: string | undefined;
}) | null | undefined): Promise;
outputFileSync(path: string, data: any, options?: string | (import("fs").BaseEncodingOptions & {
mode?: string | number | undefined;
flag?: string | undefined;
}) | null | undefined): void;
outputJson(path: string, data: object, options?: ({
space?: number | undefined;
replacer?: ((key: string, value: any) => any) | undefined;
} & string) | ({
space?: number | undefined;
replacer?: ((key: string, value: any) => any) | undefined;
} & import("fs").BaseEncodingOptions & {
mode?: string | number | undefined;
flag?: string | undefined;
}) | undefined): Promise;
outputJsonSync(path: string, data: any, options?: ({
space?: number | undefined;
replacer?: ((key: string, value: any) => any) | undefined;
} & string) | ({
space?: number | undefined;
replacer?: ((key: string, value: any) => any) | undefined;
} & import("fs").BaseEncodingOptions & {
mode?: string | number | undefined;
flag?: string | undefined;
}) | undefined): void;
readJson(path: string, options?: {
encoding?: null | undefined;
flag?: string | undefined;
} | null | undefined): Promise;
readJsonSync(path: string, options?: {
encoding?: null | undefined;
flag?: string | undefined;
} | null | undefined): T_1;
iter(dir: string, skip: (path: string, stat: import("fs").Stats) => boolean | void | Promise): Promise;
renameSync(oldPath: import("fs").PathLike, newPath: import("fs").PathLike): void;
truncateSync(path: import("fs").PathLike, len?: number | null | undefined): void;
ftruncate: typeof import("fs").ftruncate;
ftruncateSync(fd: number, len?: number | null | undefined): void;
chownSync(path: import("fs").PathLike, uid: number, gid: number): void;
fchown: typeof import("fs").fchown;
fchownSync(fd: number, uid: number, gid: number): void;
lchown: typeof import("fs").lchown;
lchownSync(path: import("fs").PathLike, uid: number, gid: number): void;
chmodSync(path: import("fs").PathLike, mode: string | number): void;
fchmod: typeof import("fs").fchmod;
fchmodSync(fd: number, mode: string | number): void;
lchmod: typeof import("fs").lchmod;
lchmodSync(path: import("fs").PathLike, mode: string | number): void;
statSync(path: import("fs").PathLike, options: import("fs").BigIntOptions): import("fs").BigIntStats;
statSync(path: import("fs").PathLike, options: import("fs").StatOptions): import("fs").Stats | import("fs").BigIntStats;
statSync(path: import("fs").PathLike): import("fs").Stats;
fstat: typeof import("fs").fstat;
fstatSync(fd: number): import("fs").Stats;
lstatSync(path: import("fs").PathLike): import("fs").Stats;
linkSync(existingPath: import("fs").PathLike, newPath: import("fs").PathLike): void;
symlinkSync(target: import("fs").PathLike, path: import("fs").PathLike, type?: "dir" | "file" | "junction" | null | undefined): void;
readlinkSync(path: import("fs").PathLike, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | import("fs").BaseEncodingOptions | null | undefined): string;
readlinkSync(path: import("fs").PathLike, options: import("fs").BufferEncodingOption): Buffer;
readlinkSync(path: import("fs").PathLike, options?: string | import("fs").BaseEncodingOptions | null | undefined): string | Buffer;
realpathSync: typeof import("fs").realpathSync;
unlinkSync(path: import("fs").PathLike): void;
rmdirSync(path: import("fs").PathLike, options?: import("fs").RmDirOptions | undefined): void;
mkdirSync(path: import("fs").PathLike, options: import("fs").MakeDirectoryOptions & {
recursive: true;
}): string;
mkdirSync(path: import("fs").PathLike, options?: string | number | (import("fs").MakeDirectoryOptions & {
recursive?: false | undefined;
}) | null | undefined): void;
mkdirSync(path: import("fs").PathLike, options?: string | number | import("fs").MakeDirectoryOptions | null | undefined): string | undefined;
mkdtempSync(prefix: string, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | import("fs").BaseEncodingOptions | null | undefined): string;
mkdtempSync(prefix: string, options: import("fs").BufferEncodingOption): Buffer;
mkdtempSync(prefix: string, options?: string | import("fs").BaseEncodingOptions | null | undefined): string | Buffer;
readdirSync(path: import("fs").PathLike, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | {
encoding: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | null;
withFileTypes?: false | undefined;
} | null | undefined): string[];
readdirSync(path: import("fs").PathLike, options: "buffer" | {
encoding: "buffer";
withFileTypes?: false | undefined;
}): Buffer[];
readdirSync(path: import("fs").PathLike, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | (import("fs").BaseEncodingOptions & {
withFileTypes?: false | undefined;
}) | null | undefined): string[] | Buffer[];
readdirSync(path: import("fs").PathLike, options: import("fs").BaseEncodingOptions & {
withFileTypes: true;
}): import("fs").Dirent[];
close: typeof import("fs").close;
closeSync(fd: number): void;
openSync(path: import("fs").PathLike, flags: string | number, mode?: string | number | null | undefined): number;
utimesSync(path: import("fs").PathLike, atime: string | number | Date, mtime: string | number | Date): void;
futimes: typeof import("fs").futimes;
futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
fsync: typeof import("fs").fsync;
fsyncSync(fd: number): void;
write: typeof import("fs").write;
writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null | undefined, length?: number | null | undefined, position?: number | null | undefined): number;
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;
read: typeof import("fs").read;
readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: import("fs").ReadSyncOptions | undefined): number;
readFileSync(path: string | number | Buffer | import("url").URL, options?: {
encoding?: null | undefined;
flag?: string | undefined;
} | null | undefined): Buffer;
readFileSync(path: string | number | Buffer | import("url").URL, options: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | {
encoding: BufferEncoding;
flag?: string | undefined;
}): string;
readFileSync(path: string | number | Buffer | import("url").URL, options?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | (import("fs").BaseEncodingOptions & {
flag?: string | undefined;
}) | null | undefined): string | Buffer;
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 & {
mode?: string | number | undefined;
flag?: string | undefined;
}) | null | undefined): void;
appendFileSync(file: string | number | Buffer | import("url").URL, data: string | Uint8Array, options?: string | (import("fs").BaseEncodingOptions & {
mode?: string | number | undefined;
flag?: string | undefined;
}) | null | undefined): void;
watchFile(filename: import("fs").PathLike, options: {
persistent?: boolean | undefined;
interval?: number | undefined;
} | undefined, listener: (curr: import("fs").Stats, prev: import("fs").Stats) => void): void;
watchFile(filename: import("fs").PathLike, listener: (curr: import("fs").Stats, prev: import("fs").Stats) => void): void;
unwatchFile(filename: import("fs").PathLike, listener?: ((curr: import("fs").Stats, prev: import("fs").Stats) => void) | undefined): void;
watch(filename: import("fs").PathLike, options: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | {
encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | null | undefined;
persistent?: boolean | undefined;
recursive?: boolean | undefined;
} | null | undefined, listener?: ((event: string, filename: string) => void) | undefined): import("fs").FSWatcher;
watch(filename: import("fs").PathLike, options: "buffer" | {
encoding: "buffer";
persistent?: boolean | undefined;
recursive?: boolean | undefined;
}, listener?: ((event: string, filename: Buffer) => void) | undefined): import("fs").FSWatcher;
watch(filename: import("fs").PathLike, options: string | {
encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | null | undefined;
persistent?: boolean | undefined;
recursive?: boolean | undefined;
} | null, listener?: ((event: string, filename: string | Buffer) => void) | undefined): import("fs").FSWatcher;
watch(filename: import("fs").PathLike, listener?: ((event: string, filename: string) => any) | undefined): import("fs").FSWatcher;
accessSync(path: import("fs").PathLike, mode?: number | undefined): void;
createReadStream(path: import("fs").PathLike, options?: string | {
flags?: string | undefined;
encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined;
fd?: number | undefined;
mode?: number | undefined;
autoClose?: boolean | undefined;
emitClose?: boolean | undefined;
start?: number | undefined;
end?: number | undefined;
highWaterMark?: number | undefined;
} | undefined): import("fs").ReadStream;
fdatasync: typeof import("fs").fdatasync;
fdatasyncSync(fd: number): void;
copyFileSync(src: import("fs").PathLike, dest: import("fs").PathLike, flags?: number | undefined): void;
writev: typeof import("fs").writev;
writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | undefined): number;
readv: typeof import("fs").readv;
readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | undefined): number;
opendirSync(path: string, options?: import("fs").OpenDirOptions | undefined): import("fs").Dir;
opendir: typeof import("fs").opendir;
promises: typeof import("fs/promises");
Stats: typeof import("fs").Stats;
Dirent: typeof import("fs").Dirent;
Dir: typeof import("fs").Dir;
ReadStream: typeof import("fs").ReadStream;
WriteStream: typeof import("fs").WriteStream;
BigIntStats: typeof import("fs").BigIntStats;
};
protected _logger: Logger;
get debug(): (...args: any[]) => void;
get info(): (...args: any[]) => void;
get log(): (...args: any[]) => void;
get warn(): (...args: any[]) => void;
get error(): (...args: any[]) => void;
constructor(task: Task, global: GlobalOptions);
/**
* get task options
*/
get options(): O;
/**
* run a task manually
* @param task
* @param options
*/
run(task: string | Task, options?: RunTaskOptions): Promise;
}
export declare type Callback = {
fn: (args?: any) => void | Promise;
namespaces: string[];
};
export declare type ListenerNames = 'before' | 'after' | 'onerror';
export declare class TaskManager {
private _tasks;
private _didMap;
namespaces: string[];
listeners: {
before: Callback[];
after: Callback[];
onerror: Callback[];
};
globalOptions: GlobalOptions;
getTasks(): Task[];
addTask(task: Task): Task;
resolveDependencyTree(t: Task, depth?: number): DepsTree;
isLoading(t: Task, props: RunTaskOptions): boolean;
runDepsTree(depsTree: DepsTree, props: RunTaskOptions): Promise;
runListner(name: ListenerNames, ns: string[], args?: any[]): Promise;
run(name?: string | Task, props?: RunTaskOptions): Promise;
}