@plugjs/plug 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async.cjs +20 -19
- package/dist/async.cjs.map +1 -1
- package/dist/async.d.ts +9 -9
- package/dist/async.mjs +18 -17
- package/dist/async.mjs.map +1 -1
- package/dist/build.cjs +113 -110
- package/dist/build.cjs.map +2 -2
- package/dist/build.d.ts +14 -56
- package/dist/build.mjs +114 -111
- package/dist/build.mjs.map +2 -2
- package/dist/files.cjs +2 -16
- package/dist/files.cjs.map +1 -1
- package/dist/files.d.ts +3 -10
- package/dist/files.mjs +3 -17
- package/dist/files.mjs.map +1 -1
- package/dist/fork.cjs +28 -40
- package/dist/fork.cjs.map +1 -1
- package/dist/fork.d.ts +6 -27
- package/dist/fork.mjs +29 -40
- package/dist/fork.mjs.map +1 -1
- package/dist/helpers.cjs +27 -61
- package/dist/helpers.cjs.map +2 -2
- package/dist/helpers.d.ts +29 -31
- package/dist/helpers.mjs +27 -62
- package/dist/helpers.mjs.map +2 -2
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -13
- package/dist/index.mjs +7 -2
- package/dist/index.mjs.map +1 -1
- package/dist/log/colors.cjs +3 -1
- package/dist/log/colors.cjs.map +1 -1
- package/dist/log/colors.d.ts +2 -2
- package/dist/log/colors.mjs +3 -1
- package/dist/log/colors.mjs.map +1 -1
- package/dist/log/emit.d.ts +1 -1
- package/dist/log/logger.cjs +4 -0
- package/dist/log/logger.cjs.map +1 -1
- package/dist/log/logger.d.ts +4 -1
- package/dist/log/logger.mjs +4 -0
- package/dist/log/logger.mjs.map +1 -1
- package/dist/log/options.d.ts +1 -1
- package/dist/log/report.cjs +2 -11
- package/dist/log/report.cjs.map +1 -1
- package/dist/log/report.d.ts +36 -4
- package/dist/log/report.mjs +1 -10
- package/dist/log/report.mjs.map +1 -1
- package/dist/log.cjs +1 -1
- package/dist/log.cjs.map +1 -1
- package/dist/log.d.ts +6 -6
- package/dist/log.mjs +2 -2
- package/dist/log.mjs.map +1 -1
- package/dist/pipe.cjs +69 -26
- package/dist/pipe.cjs.map +1 -1
- package/dist/pipe.d.ts +178 -119
- package/dist/pipe.mjs +71 -24
- package/dist/pipe.mjs.map +1 -1
- package/dist/plugs/copy.cjs +15 -25
- package/dist/plugs/copy.cjs.map +2 -2
- package/dist/plugs/copy.d.ts +14 -13
- package/dist/plugs/copy.mjs +15 -17
- package/dist/plugs/copy.mjs.map +2 -2
- package/dist/plugs/coverage/analysis.d.ts +2 -2
- package/dist/plugs/coverage/report.cjs +1 -1
- package/dist/plugs/coverage/report.cjs.map +1 -1
- package/dist/plugs/coverage/report.d.ts +3 -3
- package/dist/plugs/coverage/report.mjs +1 -1
- package/dist/plugs/coverage/report.mjs.map +1 -1
- package/dist/plugs/coverage.cjs +20 -26
- package/dist/plugs/coverage.cjs.map +1 -1
- package/dist/plugs/coverage.d.ts +33 -30
- package/dist/plugs/coverage.mjs +21 -19
- package/dist/plugs/coverage.mjs.map +1 -1
- package/dist/plugs/debug.cjs +12 -36
- package/dist/plugs/debug.cjs.map +1 -1
- package/dist/plugs/debug.d.ts +4 -11
- package/dist/plugs/debug.mjs +30 -21
- package/dist/plugs/debug.mjs.map +1 -1
- package/dist/plugs/esbuild/fix-extensions.mjs +1 -1
- package/dist/plugs/esbuild/fix-extensions.mjs.map +1 -1
- package/dist/plugs/esbuild.cjs +14 -25
- package/dist/plugs/esbuild.cjs.map +1 -1
- package/dist/plugs/esbuild.d.ts +11 -16
- package/dist/plugs/esbuild.mjs +14 -17
- package/dist/plugs/esbuild.mjs.map +1 -1
- package/dist/plugs/eslint/runner.cjs +5 -6
- package/dist/plugs/eslint/runner.cjs.map +1 -1
- package/dist/plugs/eslint/runner.d.ts +6 -20
- package/dist/plugs/eslint/runner.mjs +6 -7
- package/dist/plugs/eslint/runner.mjs.map +1 -1
- package/dist/{task.cjs → plugs/eslint.cjs} +7 -24
- package/dist/plugs/eslint.cjs.map +6 -0
- package/dist/plugs/eslint.d.ts +34 -0
- package/dist/plugs/eslint.mjs +5 -0
- package/dist/plugs/eslint.mjs.map +6 -0
- package/dist/plugs/exec.cjs +20 -24
- package/dist/plugs/exec.cjs.map +1 -1
- package/dist/plugs/exec.d.ts +53 -53
- package/dist/plugs/exec.mjs +20 -23
- package/dist/plugs/exec.mjs.map +1 -1
- package/dist/plugs/filter.cjs +9 -19
- package/dist/plugs/filter.cjs.map +1 -1
- package/dist/plugs/filter.d.ts +21 -15
- package/dist/plugs/filter.mjs +10 -12
- package/dist/plugs/filter.mjs.map +1 -1
- package/dist/plugs/mocha/reporter.cjs +12 -6
- package/dist/plugs/mocha/reporter.cjs.map +1 -1
- package/dist/plugs/mocha/reporter.d.ts +0 -2
- package/dist/plugs/mocha/reporter.mjs +11 -4
- package/dist/plugs/mocha/reporter.mjs.map +1 -1
- package/dist/plugs/mocha/runner.cjs +4 -5
- package/dist/plugs/mocha/runner.cjs.map +1 -1
- package/dist/plugs/mocha/runner.d.ts +5 -31
- package/dist/plugs/mocha/runner.mjs +5 -6
- package/dist/plugs/mocha/runner.mjs.map +1 -1
- package/dist/plugs/mocha.cjs +22 -0
- package/dist/plugs/mocha.cjs.map +6 -0
- package/dist/plugs/mocha.d.ts +35 -0
- package/dist/plugs/mocha.mjs +5 -0
- package/dist/plugs/mocha.mjs.map +6 -0
- package/dist/plugs/rmf.cjs +4 -32
- package/dist/plugs/rmf.cjs.map +1 -1
- package/dist/plugs/rmf.d.ts +8 -12
- package/dist/plugs/rmf.mjs +25 -20
- package/dist/plugs/rmf.mjs.map +1 -1
- package/dist/plugs/tsc/compiler.d.ts +1 -1
- package/dist/plugs/tsc/options.d.ts +1 -1
- package/dist/plugs/tsc/report.d.ts +2 -2
- package/dist/plugs/tsc/runner.cjs +12 -11
- package/dist/plugs/tsc/runner.cjs.map +1 -1
- package/dist/plugs/tsc/runner.d.ts +4 -9
- package/dist/plugs/tsc/runner.mjs +12 -11
- package/dist/plugs/tsc/runner.mjs.map +1 -1
- package/dist/plugs/tsc.cjs +7 -0
- package/dist/plugs/tsc.cjs.map +6 -0
- package/dist/plugs/tsc.d.ts +36 -0
- package/dist/plugs/tsc.mjs +15 -0
- package/dist/plugs/tsc.mjs.map +6 -0
- package/dist/plugs.cjs +3 -5
- package/dist/plugs.cjs.map +1 -1
- package/dist/plugs.d.ts +10 -17
- package/dist/plugs.mjs +3 -5
- package/dist/plugs.mjs.map +1 -1
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +6 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +6 -0
- package/dist/utils/caller.cjs +8 -11
- package/dist/utils/caller.cjs.map +2 -2
- package/dist/utils/caller.d.ts +2 -7
- package/dist/utils/caller.mjs +8 -11
- package/dist/utils/caller.mjs.map +2 -2
- package/dist/utils/options.cjs +4 -6
- package/dist/utils/options.cjs.map +1 -1
- package/dist/utils/options.d.ts +16 -15
- package/dist/utils/options.mjs +4 -6
- package/dist/utils/options.mjs.map +1 -1
- package/dist/utils/walk.d.ts +2 -2
- package/extra/cli.mjs +31 -20
- package/extra/ts-loader.mjs +6 -5
- package/package.json +8 -9
- package/src/async.ts +27 -19
- package/src/files.ts +6 -30
- package/src/fork.ts +35 -76
- package/src/helpers.ts +66 -99
- package/src/index.ts +10 -15
- package/src/log/colors.ts +4 -3
- package/src/log/emit.ts +4 -4
- package/src/log/logger.ts +12 -4
- package/src/log/options.ts +1 -1
- package/src/log/report.ts +8 -22
- package/src/log/spinner.ts +3 -3
- package/src/log.ts +9 -9
- package/src/paths.ts +1 -1
- package/src/pipe.ts +255 -170
- package/src/plugs/copy.ts +40 -31
- package/src/plugs/coverage/analysis.ts +4 -4
- package/src/plugs/coverage/report.ts +6 -5
- package/src/plugs/coverage.ts +64 -53
- package/src/plugs/debug.ts +28 -26
- package/src/plugs/esbuild/fix-extensions.ts +2 -2
- package/src/plugs/esbuild.ts +42 -46
- package/src/plugs/eslint/runner.ts +16 -31
- package/src/plugs/eslint.ts +42 -0
- package/src/plugs/exec.ts +93 -82
- package/src/plugs/filter.ts +42 -27
- package/src/plugs/mocha/reporter.ts +10 -5
- package/src/plugs/mocha/runner.ts +12 -38
- package/src/plugs/mocha.ts +41 -0
- package/src/plugs/rmf.ts +21 -25
- package/src/plugs/tsc/compiler.ts +1 -1
- package/src/plugs/tsc/options.ts +2 -2
- package/src/plugs/tsc/report.ts +2 -2
- package/src/plugs/tsc/runner.ts +24 -30
- package/src/plugs/tsc.ts +45 -0
- package/src/plugs.ts +10 -25
- package/src/types.ts +116 -0
- package/src/utils/caller.ts +11 -22
- package/src/utils/options.ts +49 -17
- package/src/utils/walk.ts +4 -4
- package/dist/run.cjs +0 -90
- package/dist/run.cjs.map +0 -6
- package/dist/run.d.ts +0 -89
- package/dist/run.mjs +0 -65
- package/dist/run.mjs.map +0 -6
- package/dist/task.cjs.map +0 -6
- package/dist/task.d.ts +0 -15
- package/dist/task.mjs +0 -14
- package/dist/task.mjs.map +0 -6
- package/src/run.ts +0 -159
- package/src/task.ts +0 -26
package/dist/run.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// run.ts
|
|
2
|
-
import { sep } from "node:path";
|
|
3
|
-
import { Files } from "./files.mjs";
|
|
4
|
-
import { createReport, getLevelNumber, getLogger } from "./log.mjs";
|
|
5
|
-
import { getCurrentWorkingDirectory, resolveAbsolutePath } from "./paths.mjs";
|
|
6
|
-
import { PipeImpl } from "./pipe.mjs";
|
|
7
|
-
import { parseOptions } from "./utils/options.mjs";
|
|
8
|
-
import { walk } from "./utils/walk.mjs";
|
|
9
|
-
var RunImpl = class {
|
|
10
|
-
taskName;
|
|
11
|
-
buildFile;
|
|
12
|
-
buildDir;
|
|
13
|
-
log;
|
|
14
|
-
constructor({ taskName, buildDir, buildFile, log }) {
|
|
15
|
-
this.taskName = taskName;
|
|
16
|
-
this.buildDir = buildDir;
|
|
17
|
-
this.buildFile = buildFile;
|
|
18
|
-
this.log = log || getLogger(taskName);
|
|
19
|
-
}
|
|
20
|
-
setLogLevel(level) {
|
|
21
|
-
this.log.level = getLevelNumber(level);
|
|
22
|
-
}
|
|
23
|
-
report(title) {
|
|
24
|
-
return createReport(title, this.taskName);
|
|
25
|
-
}
|
|
26
|
-
resolve(path, ...paths) {
|
|
27
|
-
if (path && path.startsWith("@")) {
|
|
28
|
-
const components = path.substring(1).split(sep).filter((s) => !!s);
|
|
29
|
-
return resolveAbsolutePath(this.buildDir, ...components, ...paths);
|
|
30
|
-
}
|
|
31
|
-
if (!path)
|
|
32
|
-
return getCurrentWorkingDirectory();
|
|
33
|
-
return resolveAbsolutePath(getCurrentWorkingDirectory(), path, ...paths);
|
|
34
|
-
}
|
|
35
|
-
files(first, ...paths) {
|
|
36
|
-
if (typeof first === "string") {
|
|
37
|
-
return Files.builder(this.resolve(first, ...paths));
|
|
38
|
-
} else if (first) {
|
|
39
|
-
return Files.builder(first);
|
|
40
|
-
} else {
|
|
41
|
-
return Files.builder(this.resolve());
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
find(glob, ...args) {
|
|
45
|
-
const { params, options: { directory, ...options } } = parseOptions(args, {});
|
|
46
|
-
const promise = Promise.resolve().then(async () => {
|
|
47
|
-
const builder = this.files(directory || ".");
|
|
48
|
-
for await (const file of walk(builder.directory, [glob, ...params], options)) {
|
|
49
|
-
builder.unchecked(file);
|
|
50
|
-
}
|
|
51
|
-
return builder.build();
|
|
52
|
-
});
|
|
53
|
-
return this.pipe(promise);
|
|
54
|
-
}
|
|
55
|
-
pipe(files) {
|
|
56
|
-
return new PipeImpl(files, this);
|
|
57
|
-
}
|
|
58
|
-
call(name) {
|
|
59
|
-
throw new Error(`Unable to call task "${name}"`);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
RunImpl
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=run.mjs.map
|
package/dist/run.mjs.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/run.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,WAAW;AACpB,SAAS,aAA2B;AACpC,SAAS,cAAc,gBAAgB,iBAAiD;AACxF,SAAuB,4BAA4B,2BAA2B;AAC9E,SAAe,gBAAgB;AAC/B,SAAuB,oBAAoB;AAC3C,SAAS,YAAyB;AAgF3B,IAAM,UAAN,MAA6B;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIT,YAAY,EAAE,UAAU,UAAU,WAAW,IAAI,GAA2B;AAC1E,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,MAAM,OAAO,UAAU,QAAQ;AAAA,EACtC;AAAA,EAGA,YAAY,OAA6B;AACvC,SAAK,IAAI,QAAQ,eAAe,KAAK;AAAA,EACvC;AAAA,EAEA,OAAO,OAAuB;AAC5B,WAAO,aAAa,OAAO,KAAK,QAAQ;AAAA,EAC1C;AAAA,EAEA,QAAQ,SAAkB,OAA+B;AAEvD,QAAI,QAAQ,KAAK,WAAW,GAAG,GAAG;AAEhC,YAAM,aAAa,KAAK,UAAU,CAAC,EAAE,MAAM,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACjE,aAAO,oBAAoB,KAAK,UAAU,GAAG,YAAY,GAAG,KAAK;AAAA,IACnE;AAGA,QAAI,CAAE;AAAM,aAAO,2BAA2B;AAG9C,WAAO,oBAAoB,2BAA2B,GAAG,MAAM,GAAG,KAAK;AAAA,EACzE;AAAA,EAIA,MAAM,UAAsC,OAA+B;AACzE,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,MAAM,QAAQ,KAAK,QAAQ,OAAO,GAAG,KAAK,CAAC;AAAA,IACpD,WAAW,OAAO;AAChB,aAAO,MAAM,QAAQ,KAAK;AAAA,IAC5B,OAAO;AACL,aAAO,MAAM,QAAQ,KAAK,QAAQ,CAAC;AAAA,IACrC;AAAA,EACF;AAAA,EAEA,KAAK,SAAiB,MAAwD;AAC5E,UAAM,EAAE,QAAQ,SAAS,EAAE,cAAc,QAAQ,EAAE,IAAI,aAAa,MAAM,CAAC,CAAC;AAE5E,UAAM,UAAU,QAAQ,QAAQ,EAAE,KAAK,YAAY;AACjD,YAAM,UAAU,KAAK,MAAM,aAAa,GAAG;AAC3C,uBAAiB,QAAQ,KAAK,QAAQ,WAAW,CAAE,MAAM,GAAG,MAAO,GAAG,OAAO,GAAG;AAC9E,gBAAQ,UAAU,IAAI;AAAA,MACxB;AACA,aAAO,QAAQ,MAAM;AAAA,IACvB,CAAC;AAED,WAAO,KAAK,KAAK,OAAO;AAAA,EAC1B;AAAA,EAEA,KAAK,OAAsD;AACzD,WAAO,IAAI,SAAS,OAAO,IAAI;AAAA,EACjC;AAAA,EAEA,KAAK,MAA0C;AAC7C,UAAM,IAAI,MAAM,wBAAwB,OAAO;AAAA,EACjD;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/task.cjs.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/task.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,IAAM,WAAN,MAAkD;AAAA,EACvD,YACa,SACQ,aACnB;AAFW;AACQ;AAAA,EAClB;AAAA,EAEH,MAAM,KAAK,MAAsB,KAAsC;AACrE,WAAQ,MAAM,KAAK,YAAY,KAAK,MAAM,MAAM,GAAG,KAAM;AAAA,EAC3D;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/task.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { BuildContext, TaskDefinition, ThisBuild } from './build.js';
|
|
2
|
-
import type { Files } from './files.js';
|
|
3
|
-
import type { Run } from './run.js';
|
|
4
|
-
export interface Task<T extends Files | undefined = Files | undefined> {
|
|
5
|
-
/** The {@link BuildContext} of where this task was originally defined */
|
|
6
|
-
readonly context: BuildContext;
|
|
7
|
-
/** Invoked by the {@link Run} when actually executing this {@link Task} */
|
|
8
|
-
call(thisBuild: ThisBuild<any>, run: Run): Promise<T>;
|
|
9
|
-
}
|
|
10
|
-
export declare class TaskImpl implements Task<Files | undefined> {
|
|
11
|
-
readonly context: BuildContext;
|
|
12
|
-
private readonly _definition;
|
|
13
|
-
constructor(context: BuildContext, _definition: TaskDefinition<any>);
|
|
14
|
-
call(self: ThisBuild<any>, run: Run): Promise<Files | undefined>;
|
|
15
|
-
}
|
package/dist/task.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// task.ts
|
|
2
|
-
var TaskImpl = class {
|
|
3
|
-
constructor(context, _definition) {
|
|
4
|
-
this.context = context;
|
|
5
|
-
this._definition = _definition;
|
|
6
|
-
}
|
|
7
|
-
async call(self, run) {
|
|
8
|
-
return await this._definition.call(self, self, run) || void 0;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
TaskImpl
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=task.mjs.map
|
package/dist/task.mjs.map
DELETED
package/src/run.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { sep } from 'node:path'
|
|
2
|
-
import { Files, FilesBuilder } from './files.js'
|
|
3
|
-
import { createReport, getLevelNumber, getLogger, Logger, LogLevelString, Report } from './log.js'
|
|
4
|
-
import { AbsolutePath, getCurrentWorkingDirectory, resolveAbsolutePath } from './paths.js'
|
|
5
|
-
import { Pipe, PipeImpl } from './pipe.js'
|
|
6
|
-
import { ParseOptions, parseOptions } from './utils/options.js'
|
|
7
|
-
import { walk, WalkOptions } from './utils/walk.js'
|
|
8
|
-
|
|
9
|
-
/** The {@link FindOptions} interface defines the options for finding files. */
|
|
10
|
-
export interface FindOptions extends WalkOptions {
|
|
11
|
-
/**
|
|
12
|
-
* The directory where to start looking for files according to the rules
|
|
13
|
-
* specified in {@link Run.resolve}.
|
|
14
|
-
*/
|
|
15
|
-
directory?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The {@link Run} interface defines the context in which a {@link Task} is
|
|
20
|
-
* invoked.
|
|
21
|
-
*
|
|
22
|
-
* Runs keep track of the invocation stack (to avoid circular dependencies) and
|
|
23
|
-
* of the cached results for {@link Task} invocations.
|
|
24
|
-
*/
|
|
25
|
-
export interface Run {
|
|
26
|
-
/**
|
|
27
|
-
* The _name_ of the task associated with this {@link Run} (if one is).
|
|
28
|
-
*
|
|
29
|
-
* Tasks can have different names in different builds, this refers to the
|
|
30
|
-
* _task name_ in the build being executed.
|
|
31
|
-
*/
|
|
32
|
-
readonly taskName: string
|
|
33
|
-
/** The absolute file name of the build */
|
|
34
|
-
readonly buildFile: AbsolutePath,
|
|
35
|
-
/** For convenience, the directory of the build file */
|
|
36
|
-
readonly buildDir: AbsolutePath,
|
|
37
|
-
/** The {@link Logger} associated with this instance. */
|
|
38
|
-
readonly log: Logger
|
|
39
|
-
|
|
40
|
-
/** Set the logging level within this {@link Run} */
|
|
41
|
-
setLogLevel(level: LogLevelString): void
|
|
42
|
-
|
|
43
|
-
/** Call another {@link Task} from this one. */
|
|
44
|
-
call(name: string): Promise<Files | undefined>
|
|
45
|
-
|
|
46
|
-
/** Create a new {@link Report} with the given _title_ */
|
|
47
|
-
report(title: string): Report
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Resolve a path in the context of this {@link Run}.
|
|
51
|
-
*
|
|
52
|
-
* If the path starts with `@...` it is considered to be relative to the
|
|
53
|
-
* _directory containing the build file where the task was defined_, otherwise
|
|
54
|
-
* it will be relative to the {@link process.cwd | current working directory}.
|
|
55
|
-
*/
|
|
56
|
-
resolve(...paths: string[]): AbsolutePath
|
|
57
|
-
|
|
58
|
-
/** Create a {@link FilesBuilder} cloning an existing {@link Files}. */
|
|
59
|
-
files(files: Files): FilesBuilder
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Create a {@link FilesBuilder} instance resolving the directory specified
|
|
63
|
-
* according to the rules specified in {@link Run.resolve}.
|
|
64
|
-
*/
|
|
65
|
-
files(...paths: string[]): FilesBuilder
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Find files according to the globs and {@link FindOptions} specified.
|
|
69
|
-
*/
|
|
70
|
-
find(glob: string, ...args: ParseOptions<FindOptions>): Pipe & Promise<Files>
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Create a new {@link Pipe} wrapping the specified {@link Files}.
|
|
74
|
-
*/
|
|
75
|
-
pipe(files: Files | Promise<Files>): Pipe & Promise<Files>
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** Constructor options for our default {@link Run} implementation */
|
|
79
|
-
export interface RunConstructionOptions {
|
|
80
|
-
readonly taskName: string,
|
|
81
|
-
readonly buildDir: AbsolutePath,
|
|
82
|
-
readonly buildFile: AbsolutePath,
|
|
83
|
-
readonly log?: Logger,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Our default {@link Run} implementation */
|
|
87
|
-
export class RunImpl implements Run {
|
|
88
|
-
readonly taskName: string
|
|
89
|
-
readonly buildFile: AbsolutePath
|
|
90
|
-
readonly buildDir: AbsolutePath
|
|
91
|
-
readonly log: Logger
|
|
92
|
-
|
|
93
|
-
constructor(options: RunConstructionOptions)
|
|
94
|
-
|
|
95
|
-
constructor({ taskName, buildDir, buildFile, log }: RunConstructionOptions) {
|
|
96
|
-
this.taskName = taskName
|
|
97
|
-
this.buildDir = buildDir
|
|
98
|
-
this.buildFile = buildFile
|
|
99
|
-
this.log = log || getLogger(taskName)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** Set the logging level within this {@link Run} */
|
|
103
|
-
setLogLevel(level: LogLevelString): void {
|
|
104
|
-
this.log.level = getLevelNumber(level)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
report(title: string): Report {
|
|
108
|
-
return createReport(title, this.taskName)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
resolve(path?: string, ...paths: string[]): AbsolutePath {
|
|
112
|
-
// Paths starting with "@" are relative to the build file directory
|
|
113
|
-
if (path && path.startsWith('@')) {
|
|
114
|
-
// We can have paths like "@/../foo/bar" or "@../foo/bar"... both are ok
|
|
115
|
-
const components = path.substring(1).split(sep).filter((s) => !!s)
|
|
116
|
-
return resolveAbsolutePath(this.buildDir, ...components, ...paths)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// No path? Resolve to the CWD!
|
|
120
|
-
if (! path) return getCurrentWorkingDirectory()
|
|
121
|
-
|
|
122
|
-
// For all the rest, normal resolution!
|
|
123
|
-
return resolveAbsolutePath(getCurrentWorkingDirectory(), path, ...paths)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
files(files: Files): FilesBuilder
|
|
127
|
-
files(...paths: string[]): FilesBuilder
|
|
128
|
-
files(first: Files | string | undefined, ...paths: string[]): FilesBuilder {
|
|
129
|
-
if (typeof first === 'string') {
|
|
130
|
-
return Files.builder(this.resolve(first, ...paths))
|
|
131
|
-
} else if (first) {
|
|
132
|
-
return Files.builder(first)
|
|
133
|
-
} else {
|
|
134
|
-
return Files.builder(this.resolve())
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
find(glob: string, ...args: ParseOptions<FindOptions>): Pipe & Promise<Files> {
|
|
139
|
-
const { params, options: { directory, ...options } } = parseOptions(args, {})
|
|
140
|
-
|
|
141
|
-
const promise = Promise.resolve().then(async () => {
|
|
142
|
-
const builder = this.files(directory || '.')
|
|
143
|
-
for await (const file of walk(builder.directory, [ glob, ...params ], options)) {
|
|
144
|
-
builder.unchecked(file)
|
|
145
|
-
}
|
|
146
|
-
return builder.build()
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
return this.pipe(promise)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
pipe(files: Files | Promise<Files>): Pipe & Promise<Files> {
|
|
153
|
-
return new PipeImpl(files, this)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
call(name: string): Promise<Files | undefined> {
|
|
157
|
-
throw new Error(`Unable to call task "${name}"`)
|
|
158
|
-
}
|
|
159
|
-
}
|
package/src/task.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { BuildContext, TaskDefinition, ThisBuild } from './build.js'
|
|
2
|
-
import type { Files } from './files.js'
|
|
3
|
-
import type { Run } from './run.js'
|
|
4
|
-
|
|
5
|
-
/* ========================================================================== *
|
|
6
|
-
* TASK *
|
|
7
|
-
* ========================================================================== */
|
|
8
|
-
|
|
9
|
-
export interface Task<T extends Files | undefined = Files | undefined> {
|
|
10
|
-
/** The {@link BuildContext} of where this task was originally defined */
|
|
11
|
-
readonly context: BuildContext
|
|
12
|
-
|
|
13
|
-
/** Invoked by the {@link Run} when actually executing this {@link Task} */
|
|
14
|
-
call(thisBuild: ThisBuild<any>, run: Run): Promise<T>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class TaskImpl implements Task<Files | undefined> {
|
|
18
|
-
constructor(
|
|
19
|
-
readonly context: BuildContext,
|
|
20
|
-
private readonly _definition: TaskDefinition<any>,
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
async call(self: ThisBuild<any>, run: Run): Promise<Files | undefined> {
|
|
24
|
-
return (await this._definition.call(self, self, run)) || undefined
|
|
25
|
-
}
|
|
26
|
-
}
|