@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.
Files changed (212) hide show
  1. package/dist/async.cjs +20 -19
  2. package/dist/async.cjs.map +1 -1
  3. package/dist/async.d.ts +9 -9
  4. package/dist/async.mjs +18 -17
  5. package/dist/async.mjs.map +1 -1
  6. package/dist/build.cjs +113 -110
  7. package/dist/build.cjs.map +2 -2
  8. package/dist/build.d.ts +14 -56
  9. package/dist/build.mjs +114 -111
  10. package/dist/build.mjs.map +2 -2
  11. package/dist/files.cjs +2 -16
  12. package/dist/files.cjs.map +1 -1
  13. package/dist/files.d.ts +3 -10
  14. package/dist/files.mjs +3 -17
  15. package/dist/files.mjs.map +1 -1
  16. package/dist/fork.cjs +28 -40
  17. package/dist/fork.cjs.map +1 -1
  18. package/dist/fork.d.ts +6 -27
  19. package/dist/fork.mjs +29 -40
  20. package/dist/fork.mjs.map +1 -1
  21. package/dist/helpers.cjs +27 -61
  22. package/dist/helpers.cjs.map +2 -2
  23. package/dist/helpers.d.ts +29 -31
  24. package/dist/helpers.mjs +27 -62
  25. package/dist/helpers.mjs.map +2 -2
  26. package/dist/index.cjs +15 -2
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +9 -13
  29. package/dist/index.mjs +7 -2
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/log/colors.cjs +3 -1
  32. package/dist/log/colors.cjs.map +1 -1
  33. package/dist/log/colors.d.ts +2 -2
  34. package/dist/log/colors.mjs +3 -1
  35. package/dist/log/colors.mjs.map +1 -1
  36. package/dist/log/emit.d.ts +1 -1
  37. package/dist/log/logger.cjs +4 -0
  38. package/dist/log/logger.cjs.map +1 -1
  39. package/dist/log/logger.d.ts +4 -1
  40. package/dist/log/logger.mjs +4 -0
  41. package/dist/log/logger.mjs.map +1 -1
  42. package/dist/log/options.d.ts +1 -1
  43. package/dist/log/report.cjs +2 -11
  44. package/dist/log/report.cjs.map +1 -1
  45. package/dist/log/report.d.ts +36 -4
  46. package/dist/log/report.mjs +1 -10
  47. package/dist/log/report.mjs.map +1 -1
  48. package/dist/log.cjs +1 -1
  49. package/dist/log.cjs.map +1 -1
  50. package/dist/log.d.ts +6 -6
  51. package/dist/log.mjs +2 -2
  52. package/dist/log.mjs.map +1 -1
  53. package/dist/pipe.cjs +69 -26
  54. package/dist/pipe.cjs.map +1 -1
  55. package/dist/pipe.d.ts +178 -119
  56. package/dist/pipe.mjs +71 -24
  57. package/dist/pipe.mjs.map +1 -1
  58. package/dist/plugs/copy.cjs +15 -25
  59. package/dist/plugs/copy.cjs.map +2 -2
  60. package/dist/plugs/copy.d.ts +14 -13
  61. package/dist/plugs/copy.mjs +15 -17
  62. package/dist/plugs/copy.mjs.map +2 -2
  63. package/dist/plugs/coverage/analysis.d.ts +2 -2
  64. package/dist/plugs/coverage/report.cjs +1 -1
  65. package/dist/plugs/coverage/report.cjs.map +1 -1
  66. package/dist/plugs/coverage/report.d.ts +3 -3
  67. package/dist/plugs/coverage/report.mjs +1 -1
  68. package/dist/plugs/coverage/report.mjs.map +1 -1
  69. package/dist/plugs/coverage.cjs +20 -26
  70. package/dist/plugs/coverage.cjs.map +1 -1
  71. package/dist/plugs/coverage.d.ts +33 -30
  72. package/dist/plugs/coverage.mjs +21 -19
  73. package/dist/plugs/coverage.mjs.map +1 -1
  74. package/dist/plugs/debug.cjs +12 -36
  75. package/dist/plugs/debug.cjs.map +1 -1
  76. package/dist/plugs/debug.d.ts +4 -11
  77. package/dist/plugs/debug.mjs +30 -21
  78. package/dist/plugs/debug.mjs.map +1 -1
  79. package/dist/plugs/esbuild/fix-extensions.mjs +1 -1
  80. package/dist/plugs/esbuild/fix-extensions.mjs.map +1 -1
  81. package/dist/plugs/esbuild.cjs +14 -25
  82. package/dist/plugs/esbuild.cjs.map +1 -1
  83. package/dist/plugs/esbuild.d.ts +11 -16
  84. package/dist/plugs/esbuild.mjs +14 -17
  85. package/dist/plugs/esbuild.mjs.map +1 -1
  86. package/dist/plugs/eslint/runner.cjs +5 -6
  87. package/dist/plugs/eslint/runner.cjs.map +1 -1
  88. package/dist/plugs/eslint/runner.d.ts +6 -20
  89. package/dist/plugs/eslint/runner.mjs +6 -7
  90. package/dist/plugs/eslint/runner.mjs.map +1 -1
  91. package/dist/{task.cjs → plugs/eslint.cjs} +7 -24
  92. package/dist/plugs/eslint.cjs.map +6 -0
  93. package/dist/plugs/eslint.d.ts +34 -0
  94. package/dist/plugs/eslint.mjs +5 -0
  95. package/dist/plugs/eslint.mjs.map +6 -0
  96. package/dist/plugs/exec.cjs +20 -24
  97. package/dist/plugs/exec.cjs.map +1 -1
  98. package/dist/plugs/exec.d.ts +53 -53
  99. package/dist/plugs/exec.mjs +20 -23
  100. package/dist/plugs/exec.mjs.map +1 -1
  101. package/dist/plugs/filter.cjs +9 -19
  102. package/dist/plugs/filter.cjs.map +1 -1
  103. package/dist/plugs/filter.d.ts +21 -15
  104. package/dist/plugs/filter.mjs +10 -12
  105. package/dist/plugs/filter.mjs.map +1 -1
  106. package/dist/plugs/mocha/reporter.cjs +12 -6
  107. package/dist/plugs/mocha/reporter.cjs.map +1 -1
  108. package/dist/plugs/mocha/reporter.d.ts +0 -2
  109. package/dist/plugs/mocha/reporter.mjs +11 -4
  110. package/dist/plugs/mocha/reporter.mjs.map +1 -1
  111. package/dist/plugs/mocha/runner.cjs +4 -5
  112. package/dist/plugs/mocha/runner.cjs.map +1 -1
  113. package/dist/plugs/mocha/runner.d.ts +5 -31
  114. package/dist/plugs/mocha/runner.mjs +5 -6
  115. package/dist/plugs/mocha/runner.mjs.map +1 -1
  116. package/dist/plugs/mocha.cjs +22 -0
  117. package/dist/plugs/mocha.cjs.map +6 -0
  118. package/dist/plugs/mocha.d.ts +35 -0
  119. package/dist/plugs/mocha.mjs +5 -0
  120. package/dist/plugs/mocha.mjs.map +6 -0
  121. package/dist/plugs/rmf.cjs +4 -32
  122. package/dist/plugs/rmf.cjs.map +1 -1
  123. package/dist/plugs/rmf.d.ts +8 -12
  124. package/dist/plugs/rmf.mjs +25 -20
  125. package/dist/plugs/rmf.mjs.map +1 -1
  126. package/dist/plugs/tsc/compiler.d.ts +1 -1
  127. package/dist/plugs/tsc/options.d.ts +1 -1
  128. package/dist/plugs/tsc/report.d.ts +2 -2
  129. package/dist/plugs/tsc/runner.cjs +12 -11
  130. package/dist/plugs/tsc/runner.cjs.map +1 -1
  131. package/dist/plugs/tsc/runner.d.ts +4 -9
  132. package/dist/plugs/tsc/runner.mjs +12 -11
  133. package/dist/plugs/tsc/runner.mjs.map +1 -1
  134. package/dist/plugs/tsc.cjs +7 -0
  135. package/dist/plugs/tsc.cjs.map +6 -0
  136. package/dist/plugs/tsc.d.ts +36 -0
  137. package/dist/plugs/tsc.mjs +15 -0
  138. package/dist/plugs/tsc.mjs.map +6 -0
  139. package/dist/plugs.cjs +3 -5
  140. package/dist/plugs.cjs.map +1 -1
  141. package/dist/plugs.d.ts +10 -17
  142. package/dist/plugs.mjs +3 -5
  143. package/dist/plugs.mjs.map +1 -1
  144. package/dist/types.cjs +19 -0
  145. package/dist/types.cjs.map +6 -0
  146. package/dist/types.d.ts +71 -0
  147. package/dist/types.mjs +1 -0
  148. package/dist/types.mjs.map +6 -0
  149. package/dist/utils/caller.cjs +8 -11
  150. package/dist/utils/caller.cjs.map +2 -2
  151. package/dist/utils/caller.d.ts +2 -7
  152. package/dist/utils/caller.mjs +8 -11
  153. package/dist/utils/caller.mjs.map +2 -2
  154. package/dist/utils/options.cjs +4 -6
  155. package/dist/utils/options.cjs.map +1 -1
  156. package/dist/utils/options.d.ts +16 -15
  157. package/dist/utils/options.mjs +4 -6
  158. package/dist/utils/options.mjs.map +1 -1
  159. package/dist/utils/walk.d.ts +2 -2
  160. package/extra/cli.mjs +31 -20
  161. package/extra/ts-loader.mjs +6 -5
  162. package/package.json +8 -9
  163. package/src/async.ts +27 -19
  164. package/src/files.ts +6 -30
  165. package/src/fork.ts +35 -76
  166. package/src/helpers.ts +66 -99
  167. package/src/index.ts +10 -15
  168. package/src/log/colors.ts +4 -3
  169. package/src/log/emit.ts +4 -4
  170. package/src/log/logger.ts +12 -4
  171. package/src/log/options.ts +1 -1
  172. package/src/log/report.ts +8 -22
  173. package/src/log/spinner.ts +3 -3
  174. package/src/log.ts +9 -9
  175. package/src/paths.ts +1 -1
  176. package/src/pipe.ts +255 -170
  177. package/src/plugs/copy.ts +40 -31
  178. package/src/plugs/coverage/analysis.ts +4 -4
  179. package/src/plugs/coverage/report.ts +6 -5
  180. package/src/plugs/coverage.ts +64 -53
  181. package/src/plugs/debug.ts +28 -26
  182. package/src/plugs/esbuild/fix-extensions.ts +2 -2
  183. package/src/plugs/esbuild.ts +42 -46
  184. package/src/plugs/eslint/runner.ts +16 -31
  185. package/src/plugs/eslint.ts +42 -0
  186. package/src/plugs/exec.ts +93 -82
  187. package/src/plugs/filter.ts +42 -27
  188. package/src/plugs/mocha/reporter.ts +10 -5
  189. package/src/plugs/mocha/runner.ts +12 -38
  190. package/src/plugs/mocha.ts +41 -0
  191. package/src/plugs/rmf.ts +21 -25
  192. package/src/plugs/tsc/compiler.ts +1 -1
  193. package/src/plugs/tsc/options.ts +2 -2
  194. package/src/plugs/tsc/report.ts +2 -2
  195. package/src/plugs/tsc/runner.ts +24 -30
  196. package/src/plugs/tsc.ts +45 -0
  197. package/src/plugs.ts +10 -25
  198. package/src/types.ts +116 -0
  199. package/src/utils/caller.ts +11 -22
  200. package/src/utils/options.ts +49 -17
  201. package/src/utils/walk.ts +4 -4
  202. package/dist/run.cjs +0 -90
  203. package/dist/run.cjs.map +0 -6
  204. package/dist/run.d.ts +0 -89
  205. package/dist/run.mjs +0 -65
  206. package/dist/run.mjs.map +0 -6
  207. package/dist/task.cjs.map +0 -6
  208. package/dist/task.d.ts +0 -15
  209. package/dist/task.mjs +0 -14
  210. package/dist/task.mjs.map +0 -6
  211. package/src/run.ts +0 -159
  212. 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
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/task.ts"],
4
- "mappings": ";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/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
- }