@plugjs/plug 0.0.14 → 0.0.15
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 +144 -110
- package/dist/build.cjs.map +2 -2
- package/dist/build.d.ts +12 -56
- package/dist/build.mjs +146 -112
- 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 +61 -63
- package/dist/helpers.cjs.map +2 -2
- package/dist/helpers.d.ts +15 -37
- package/dist/helpers.mjs +61 -64
- package/dist/helpers.mjs.map +2 -2
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -13
- package/dist/index.mjs +3 -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 +41 -34
- package/dist/pipe.cjs.map +1 -1
- package/dist/pipe.d.ts +149 -119
- package/dist/pipe.mjs +38 -32
- 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 +19 -25
- package/dist/plugs/coverage.cjs.map +1 -1
- package/dist/plugs/coverage.d.ts +33 -30
- package/dist/plugs/coverage.mjs +20 -18
- package/dist/plugs/coverage.mjs.map +1 -1
- package/dist/plugs/debug.cjs +8 -37
- package/dist/plugs/debug.cjs.map +1 -1
- package/dist/plugs/debug.d.ts +4 -11
- package/dist/plugs/debug.mjs +24 -20
- 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 +72 -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 +6 -6
- package/src/async.ts +27 -19
- package/src/files.ts +6 -30
- package/src/fork.ts +35 -76
- package/src/helpers.ts +89 -101
- 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 +191 -178
- 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 +22 -27
- 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 +123 -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/log.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/log.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,oBAA+B;AAC/B,qBAA6B;AAE7B,wBAAc,6BAJd;AAKA,wBAAc,6BALd;AAMA,wBAAc,6BANd;AAOA,wBAAc,8BAPd;AAQA,wBAAc,6BARd;AAAA,IAeA,6BAAa;AAUN,IAAM,OAAoB,MAAmB;AAElD,QAAM,SAAS,MAAQ;AA3BzB;AA2B6B,mDAAe,MAAf,mBAAkB,YAAO,yBAAU;AAAA;AAG9D,QAAM,UAAe;AAAA,IACnB,SAAS,MAA4B;AACnC,aAAO,EAAE,MAAM,GAAG,IAAI;AACtB,aAAO;AAAA,IACT;AAAA,IAEA,SAAS,MAA4B;AACnC,aAAO,EAAE,MAAM,GAAG,IAAI;AACtB,aAAO;AAAA,IACT;AAAA,IAEA,QAAQ,MAA4B;AAClC,aAAO,EAAE,KAAK,GAAG,IAAI;AACrB,aAAO;AAAA,IACT;AAAA,IAEA,UAAU,MAA4B;AACpC,aAAO,EAAE,OAAO,GAAG,IAAI;AACvB,aAAO;AAAA,IACT;AAAA,IAEA,QAAQ,MAA4B;AAClC,aAAO,EAAE,KAAK,GAAG,IAAI;AACrB,aAAO;AAAA,IACT;AAAA,IAEA,SAAS,MAA4B;AACnC,aAAO,EAAE,MAAM,GAAG,IAAI;AACtB,aAAO;AAAA,IACT;AAAA,EACF;AAGA,QAAMA,OAAM,IAAI,SAAgC,KAAK,QAAQ,OAAO,GAAG,IAAI;AAG3E,SAAO,OAAO,OAAOA,MAAK,OAAO;AACnC,GAAG;",
|
|
5
5
|
"names": ["log"]
|
|
6
6
|
}
|
package/dist/log.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Log } from './log/logger
|
|
2
|
-
export * from './log/colors
|
|
3
|
-
export * from './log/levels
|
|
4
|
-
export * from './log/logger
|
|
5
|
-
export * from './log/options
|
|
6
|
-
export * from './log/report
|
|
1
|
+
import { Log } from './log/logger';
|
|
2
|
+
export * from './log/colors';
|
|
3
|
+
export * from './log/levels';
|
|
4
|
+
export * from './log/logger';
|
|
5
|
+
export * from './log/options';
|
|
6
|
+
export * from './log/report';
|
|
7
7
|
/** The generic, shared `log` function type. */
|
|
8
8
|
export declare type LogFunction = ((...args: [any, ...any]) => void) & Log;
|
|
9
9
|
/** Our logging function (defaulting to the `NOTICE` level) */
|
package/dist/log.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// log.ts
|
|
2
|
-
import {
|
|
2
|
+
import { currentContext } from "./async.mjs";
|
|
3
3
|
import { getLogger } from "./log/logger.mjs";
|
|
4
4
|
import { setupSpinner } from "./log/spinner.mjs";
|
|
5
5
|
export * from "./log/colors.mjs";
|
|
@@ -11,7 +11,7 @@ setupSpinner();
|
|
|
11
11
|
var log = (() => {
|
|
12
12
|
const logger = () => {
|
|
13
13
|
var _a;
|
|
14
|
-
return ((_a =
|
|
14
|
+
return ((_a = currentContext()) == null ? void 0 : _a.log) || getLogger();
|
|
15
15
|
};
|
|
16
16
|
const wrapper = {
|
|
17
17
|
trace(...args) {
|
package/dist/log.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/log.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,
|
|
4
|
+
"mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,iBAAsB;AAC/B,SAAS,oBAAoB;AAE7B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAOd,aAAa;AAUN,IAAM,OAAoB,MAAmB;AAElD,QAAM,SAAS,MAAQ;AA3BzB;AA2B6B,iCAAe,MAAf,mBAAkB,QAAO,UAAU;AAAA;AAG9D,QAAM,UAAe;AAAA,IACnB,SAAS,MAA4B;AACnC,aAAO,EAAE,MAAM,GAAG,IAAI;AACtB,aAAO;AAAA,IACT;AAAA,IAEA,SAAS,MAA4B;AACnC,aAAO,EAAE,MAAM,GAAG,IAAI;AACtB,aAAO;AAAA,IACT;AAAA,IAEA,QAAQ,MAA4B;AAClC,aAAO,EAAE,KAAK,GAAG,IAAI;AACrB,aAAO;AAAA,IACT;AAAA,IAEA,UAAU,MAA4B;AACpC,aAAO,EAAE,OAAO,GAAG,IAAI;AACvB,aAAO;AAAA,IACT;AAAA,IAEA,QAAQ,MAA4B;AAClC,aAAO,EAAE,KAAK,GAAG,IAAI;AACrB,aAAO;AAAA,IACT;AAAA,IAEA,SAAS,MAA4B;AACnC,aAAO,EAAE,MAAM,GAAG,IAAI;AACtB,aAAO;AAAA,IACT;AAAA,EACF;AAGA,QAAMA,OAAM,IAAI,SAAgC,KAAK,QAAQ,OAAO,GAAG,IAAI;AAG3E,SAAO,OAAO,OAAOA,MAAK,OAAO;AACnC,GAAG;",
|
|
5
5
|
"names": ["log"]
|
|
6
6
|
}
|
package/dist/pipe.cjs
CHANGED
|
@@ -20,52 +20,59 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// pipe.ts
|
|
21
21
|
var pipe_exports = {};
|
|
22
22
|
__export(pipe_exports, {
|
|
23
|
+
Context: () => Context,
|
|
23
24
|
Pipe: () => Pipe,
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
install: () => install,
|
|
26
|
+
installForking: () => installForking
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(pipe_exports);
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this
|
|
37
|
-
this
|
|
38
|
-
}
|
|
39
|
-
plug(arg) {
|
|
40
|
-
const plug = typeof arg === "function" ? { pipe: arg } : arg;
|
|
41
|
-
const promise = this.#promise.then((files) => {
|
|
42
|
-
(0, import_assert.assert)(files, "Pipe can not be further extended");
|
|
43
|
-
return plug.pipe(files, this.#run);
|
|
44
|
-
});
|
|
45
|
-
return new PipeImpl(promise, this.#run);
|
|
46
|
-
}
|
|
47
|
-
then(onfulfilled, onrejected) {
|
|
48
|
-
return this.#promise.then(onfulfilled, onrejected);
|
|
49
|
-
}
|
|
50
|
-
catch(onrejected) {
|
|
51
|
-
return this.#promise.catch(onrejected);
|
|
29
|
+
var import_log = require("./log.cjs");
|
|
30
|
+
var import_paths = require("./paths.cjs");
|
|
31
|
+
var import_fork = require("./fork.cjs");
|
|
32
|
+
var import_path = require("path");
|
|
33
|
+
var Context = class {
|
|
34
|
+
constructor(buildFile, taskName) {
|
|
35
|
+
this.buildFile = buildFile;
|
|
36
|
+
this.taskName = taskName;
|
|
37
|
+
this.buildDir = (0, import_paths.getAbsoluteParent)(buildFile);
|
|
38
|
+
this.log = (0, import_log.getLogger)(taskName);
|
|
52
39
|
}
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
buildDir;
|
|
41
|
+
log;
|
|
42
|
+
resolve(path, ...paths) {
|
|
43
|
+
if (path && path.startsWith("@")) {
|
|
44
|
+
const components = path.substring(1).split(import_path.sep).filter((s) => !!s);
|
|
45
|
+
return (0, import_paths.resolveAbsolutePath)(this.buildDir, ...components, ...paths);
|
|
46
|
+
}
|
|
47
|
+
if (!path)
|
|
48
|
+
return (0, import_paths.getCurrentWorkingDirectory)();
|
|
49
|
+
return (0, import_paths.resolveAbsolutePath)((0, import_paths.getCurrentWorkingDirectory)(), path, ...paths);
|
|
55
50
|
}
|
|
56
|
-
|
|
51
|
+
};
|
|
52
|
+
var PipeProto = class {
|
|
53
|
+
};
|
|
54
|
+
var Pipe = class extends PipeProto {
|
|
57
55
|
};
|
|
58
56
|
function install(name, ctor) {
|
|
59
|
-
function
|
|
57
|
+
function plug(...args) {
|
|
60
58
|
return this.plug(new ctor(...args));
|
|
61
59
|
}
|
|
62
|
-
Object.defineProperty(
|
|
63
|
-
Object.defineProperty(
|
|
60
|
+
Object.defineProperty(plug, "name", { value: name });
|
|
61
|
+
Object.defineProperty(PipeProto.prototype, name, { value: plug });
|
|
62
|
+
}
|
|
63
|
+
function installForking(plugName, scriptFile) {
|
|
64
|
+
const ctor = class extends import_fork.ForkingPlug {
|
|
65
|
+
constructor(...args) {
|
|
66
|
+
super(scriptFile, args);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
install(plugName, ctor);
|
|
64
70
|
}
|
|
65
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
72
|
0 && (module.exports = {
|
|
73
|
+
Context,
|
|
67
74
|
Pipe,
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
install,
|
|
76
|
+
installForking
|
|
70
77
|
});
|
|
71
78
|
//# sourceMappingURL=pipe.cjs.map
|
package/dist/pipe.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/pipe.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAkC;AAClC,mBAAiG;AAEjG,kBAA4B;AAC5B,kBAAoB;AA+Bb,IAAM,UAAN,MAAc;AAAA,EAMnB,YAEoB,WAEA,UAClB;AAHkB;AAEA;AAElB,SAAK,eAAW,gCAAkB,SAAS;AAC3C,SAAK,UAAM,sBAAU,QAAQ;AAAA,EAC/B;AAAA,EAZgB;AAAA,EAEA;AAAA,EAYhB,QAAQ,SAAiB,OAA+B;AAEtD,QAAI,QAAQ,KAAK,WAAW,GAAG,GAAG;AAEhC,YAAM,aAAa,KAAK,UAAU,CAAC,EAAE,MAAM,eAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACjE,iBAAO,kCAAoB,KAAK,UAAU,GAAG,YAAY,GAAG,KAAK;AAAA,IACnE;AAGA,QAAI,CAAE;AAAM,iBAAO,yCAA2B;AAG9C,eAAO,sCAAoB,yCAA2B,GAAG,MAAM,GAAG,KAAK;AAAA,EACzE;AACF;AAUA,IAAe,YAAf,MAAyB;AAEzB;AAMO,IAAe,OAAf,cAA4B,UAAU;AAO7C;AAyGO,SAAS,QAGd,MAAY,MAAkB;AAE9B,WAAS,QAAyB,MAAuD;AAEvF,WAAO,KAAK,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC;AAAA,EACpC;AAGA,SAAO,eAAe,MAAM,QAAQ,EAAE,OAAO,KAAK,CAAC;AAGnD,SAAO,eAAe,UAAU,WAAW,MAAM,EAAE,OAAO,KAAK,CAAC;AAClE;AAmBO,SAAS,eACZ,UACA,YACI;AAEN,QAAM,OAAO,cAAc,wBAAY;AAAA,IACrC,eAAe,MAAa;AAC1B,YAAM,YAAY,IAAI;AAAA,IACxB;AAAA,EACF;AAGA,UAAQ,UAAU,IAAI;AACxB;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/pipe.d.ts
CHANGED
|
@@ -1,128 +1,138 @@
|
|
|
1
|
-
import { Files } from './files
|
|
2
|
-
import {
|
|
1
|
+
import type { Files } from './files';
|
|
2
|
+
import { Logger } from './log';
|
|
3
|
+
import { AbsolutePath } from './paths';
|
|
4
|
+
/** A convenience type indicating what can be returned by a {@link Plug}. */
|
|
5
|
+
export declare type PlugResult = Files | undefined | void;
|
|
3
6
|
/**
|
|
4
|
-
* The {@link Plug} interface describes
|
|
7
|
+
* The {@link Plug} interface describes _build plugin_.
|
|
8
|
+
*
|
|
9
|
+
* A {@link Plug} receives a {@link Files} instance in its input (for example
|
|
10
|
+
* a list of _source `.ts` files_) and optionally produces a possibly different
|
|
11
|
+
* list (for example the _compiled `.js` files_).
|
|
5
12
|
*/
|
|
6
|
-
export interface Plug<T extends
|
|
7
|
-
pipe(files: Files,
|
|
13
|
+
export interface Plug<T extends PlugResult> {
|
|
14
|
+
pipe(files: Files, context: Context): T | Promise<T>;
|
|
8
15
|
}
|
|
16
|
+
/** A type identifying a {@link Plug} as a `function` */
|
|
17
|
+
export declare type PlugFunction<T extends PlugResult> = Plug<T>['pipe'];
|
|
9
18
|
/**
|
|
10
|
-
*
|
|
19
|
+
* The {@link Context} class defines the context in which a {@link Plug}
|
|
20
|
+
* is invoked.
|
|
11
21
|
*/
|
|
12
|
-
export declare
|
|
22
|
+
export declare class Context {
|
|
23
|
+
/** The absolute file name where the task was defined. */
|
|
24
|
+
readonly buildFile: AbsolutePath;
|
|
25
|
+
/** The _name_ of the task associated with this {@link Context}. */
|
|
26
|
+
readonly taskName: string;
|
|
27
|
+
/** The directory of the file where the task was defined (convenience). */
|
|
28
|
+
readonly buildDir: AbsolutePath;
|
|
29
|
+
/** The {@link Logger} associated with this instance. */
|
|
30
|
+
readonly log: Logger;
|
|
31
|
+
constructor(
|
|
32
|
+
/** The absolute file name where the task was defined. */
|
|
33
|
+
buildFile: AbsolutePath,
|
|
34
|
+
/** The _name_ of the task associated with this {@link Context}. */
|
|
35
|
+
taskName: string);
|
|
36
|
+
resolve(path: string, ...paths: string[]): AbsolutePath;
|
|
37
|
+
}
|
|
13
38
|
/**
|
|
14
|
-
* A {@link Pipe}
|
|
15
|
-
*
|
|
39
|
+
* A class that will be extended by {@link Pipe} where {@link install} will
|
|
40
|
+
* add prototype properties from installed {@link Plug}s
|
|
16
41
|
*/
|
|
17
|
-
|
|
42
|
+
declare abstract class PipeProto {
|
|
43
|
+
abstract plug(plug: Plug<PlugResult>): Pipe | Promise<undefined>;
|
|
18
44
|
}
|
|
19
45
|
/**
|
|
20
|
-
* The {@link Pipe} abstract
|
|
21
|
-
*
|
|
46
|
+
* The {@link Pipe} abstract defines processing pipeline where multiple
|
|
47
|
+
* {@link Plug}s can transform lists of {@link Files}.
|
|
22
48
|
*/
|
|
23
|
-
export declare abstract class Pipe
|
|
24
|
-
abstract plug(plug: Plug<Files>
|
|
25
|
-
abstract plug(plug:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
#private;
|
|
30
|
-
constructor(start: T | Promise<T>, run: Run);
|
|
31
|
-
plug<T extends Files | undefined>(arg: Plug<T> | PlugFunction<T>): Pipe & Promise<T>;
|
|
32
|
-
then<T1 = T, T2 = never>(onfulfilled?: ((value: T) => T1 | PromiseLike<T1>) | null | undefined, onrejected?: ((reason: any) => T2 | PromiseLike<T2>) | null | undefined): Promise<T1 | T2>;
|
|
33
|
-
catch<T0 = never>(onrejected?: ((reason: any) => T0 | PromiseLike<T0>) | null | undefined): Promise<T0 | T>;
|
|
34
|
-
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
|
|
35
|
-
[Symbol.toStringTag]: string;
|
|
49
|
+
export declare abstract class Pipe extends PipeProto {
|
|
50
|
+
abstract plug(plug: Plug<Files>): Pipe;
|
|
51
|
+
abstract plug(plug: PlugFunction<Files>): Pipe;
|
|
52
|
+
abstract plug(plug: Plug<void | undefined>): Promise<undefined>;
|
|
53
|
+
abstract plug(plug: PlugFunction<void | undefined>): Promise<undefined>;
|
|
54
|
+
abstract run(): Promise<Files>;
|
|
36
55
|
}
|
|
37
56
|
/** The names which can be installed as direct plugs. */
|
|
38
|
-
export declare type PlugName = string & Exclude<keyof Pipe, 'plug' |
|
|
39
|
-
/**
|
|
40
|
-
export declare type
|
|
41
|
-
/**
|
|
42
|
-
declare type
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} ?
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
57
|
+
export declare type PlugName = string & Exclude<keyof Pipe, 'plug' | 'run'>;
|
|
58
|
+
/** The parameters of the plug extension with the given name */
|
|
59
|
+
export declare type PipeParameters<Name extends PlugName> = PipeOverloads<Name>['args'];
|
|
60
|
+
/** Extract arguments and return types from function overloads. */
|
|
61
|
+
declare type PipeOverloads<Name extends PlugName> = Pipe[Name] extends {
|
|
62
|
+
(...args: infer A0): infer R0;
|
|
63
|
+
(...args: infer A1): infer R1;
|
|
64
|
+
(...args: infer A2): infer R2;
|
|
65
|
+
(...args: infer A3): infer R3;
|
|
66
|
+
(...args: infer A4): infer R4;
|
|
67
|
+
} ? (R0 extends (Pipe | Promise<undefined>) ? {
|
|
68
|
+
args: A0;
|
|
69
|
+
ret: R0;
|
|
70
|
+
} : never) | (R1 extends (Pipe | Promise<undefined>) ? {
|
|
71
|
+
args: A1;
|
|
72
|
+
ret: R1;
|
|
73
|
+
} : never) | (R2 extends (Pipe | Promise<undefined>) ? {
|
|
74
|
+
args: A2;
|
|
75
|
+
ret: R2;
|
|
76
|
+
} : never) | (R3 extends (Pipe | Promise<undefined>) ? {
|
|
77
|
+
args: A3;
|
|
78
|
+
ret: R3;
|
|
79
|
+
} : never) | (R4 extends (Pipe | Promise<undefined>) ? {
|
|
80
|
+
args: A4;
|
|
81
|
+
ret: R4;
|
|
82
|
+
} : never) : Pipe[Name] extends {
|
|
83
|
+
(...args: infer A0): infer R0;
|
|
84
|
+
(...args: infer A1): infer R1;
|
|
85
|
+
(...args: infer A2): infer R2;
|
|
86
|
+
(...args: infer A3): infer R3;
|
|
87
|
+
} ? (R0 extends (Pipe | Promise<undefined>) ? {
|
|
88
|
+
args: A0;
|
|
89
|
+
ret: R0;
|
|
90
|
+
} : never) | (R1 extends (Pipe | Promise<undefined>) ? {
|
|
91
|
+
args: A1;
|
|
92
|
+
ret: R1;
|
|
93
|
+
} : never) | (R2 extends (Pipe | Promise<undefined>) ? {
|
|
94
|
+
args: A2;
|
|
95
|
+
ret: R2;
|
|
96
|
+
} : never) | (R3 extends (Pipe | Promise<undefined>) ? {
|
|
97
|
+
args: A3;
|
|
98
|
+
ret: R3;
|
|
99
|
+
} : never) : Pipe[Name] extends {
|
|
100
|
+
(...args: infer A0): infer R0;
|
|
101
|
+
(...args: infer A1): infer R1;
|
|
102
|
+
(...args: infer A2): infer R2;
|
|
103
|
+
} ? (R0 extends (Pipe | Promise<undefined>) ? {
|
|
104
|
+
args: A0;
|
|
105
|
+
ret: R0;
|
|
106
|
+
} : never) | (R1 extends (Pipe | Promise<undefined>) ? {
|
|
107
|
+
args: A1;
|
|
108
|
+
ret: R1;
|
|
109
|
+
} : never) | (R2 extends (Pipe | Promise<undefined>) ? {
|
|
110
|
+
args: A2;
|
|
111
|
+
ret: R2;
|
|
112
|
+
} : never) : Pipe[Name] extends {
|
|
113
|
+
(...args: infer A0): infer R0;
|
|
114
|
+
(...args: infer A1): infer R1;
|
|
115
|
+
} ? (R0 extends (Pipe | Promise<undefined>) ? {
|
|
116
|
+
args: A0;
|
|
117
|
+
ret: R0;
|
|
118
|
+
} : never) | (R1 extends (Pipe | Promise<undefined>) ? {
|
|
119
|
+
args: A1;
|
|
120
|
+
ret: R1;
|
|
121
|
+
} : never) : Pipe[Name] extends {
|
|
122
|
+
(...args: infer A0): infer R0;
|
|
123
|
+
} ? (R0 extends (Pipe | Promise<undefined>) ? {
|
|
124
|
+
args: A0;
|
|
125
|
+
ret: R0;
|
|
126
|
+
} : never) : never;
|
|
127
|
+
/** The parameters of the plug extension with the given name */
|
|
128
|
+
declare type PipeResult<Name extends PlugName> = PipeOverloads<Name>['ret'];
|
|
103
129
|
/**
|
|
104
|
-
* A
|
|
105
|
-
*
|
|
106
|
-
* See also {@link install}.
|
|
107
|
-
*
|
|
108
|
-
* ```
|
|
109
|
-
* export class Write implements Plug {
|
|
110
|
-
* // ... the plug implementation lives here
|
|
111
|
-
* }
|
|
112
|
-
*
|
|
113
|
-
* install('write', Write)
|
|
114
|
-
*
|
|
115
|
-
* declare module '../pipe' {
|
|
116
|
-
* export interface Pipe {
|
|
117
|
-
* write: PipeExtension<typeof Write>
|
|
118
|
-
* }
|
|
119
|
-
* }
|
|
120
|
-
* ```
|
|
130
|
+
* A type defining the correct constructor for a {@link Plug}, inferring
|
|
131
|
+
* argument types and instance type from the definitions in {@link Pipe}.
|
|
121
132
|
*/
|
|
122
|
-
|
|
133
|
+
declare type PlugConstructor<Name extends PlugName> = PipeResult<Name> extends Pipe ? new (...args: PipeParameters<Name>) => Plug<Files> : PipeResult<Name> extends Promise<undefined> ? new (...args: PipeParameters<Name>) => Plug<void | undefined> : PipeResult<Name> extends (Pipe | Promise<undefined>) ? new (...args: PipeParameters<Name>) => Plug<Files | void | undefined> : never;
|
|
123
134
|
/**
|
|
124
|
-
* Install a {@link Plug} into our {@link Pipe} prototype
|
|
125
|
-
* creator function for the {@link Plug} itself.
|
|
135
|
+
* Install a {@link Plug} into our {@link Pipe} prototype.
|
|
126
136
|
*
|
|
127
137
|
* This allows our shorthand syntax for well-defined plugs such as:
|
|
128
138
|
*
|
|
@@ -135,18 +145,38 @@ export declare type PipeExtension<T extends PlugConstructor, A = PlugConstructor
|
|
|
135
145
|
* Use this alongside interface merging like:
|
|
136
146
|
*
|
|
137
147
|
* ```
|
|
138
|
-
*
|
|
139
|
-
* // ... the plug implementation lives here
|
|
140
|
-
* }
|
|
141
|
-
*
|
|
142
|
-
* install('write', Write)
|
|
143
|
-
*
|
|
144
|
-
* declare module '../pipe' {
|
|
148
|
+
* declare module '@plugjs/plug/pipe' {
|
|
145
149
|
* export interface Pipe {
|
|
146
|
-
* write:
|
|
150
|
+
* write(): Pipe
|
|
147
151
|
* }
|
|
148
152
|
* }
|
|
153
|
+
*
|
|
154
|
+
* install('write', class Write implements Plug {
|
|
155
|
+
* constructorg(...args: PipeParams<'write'>) {
|
|
156
|
+
* // here `args` is automatically inferred by whatever was declared above
|
|
157
|
+
* }
|
|
158
|
+
*
|
|
159
|
+
* // ... the plug implementation lives here
|
|
160
|
+
* })
|
|
149
161
|
* ```
|
|
150
162
|
*/
|
|
151
|
-
export declare function install<
|
|
163
|
+
export declare function install<Name extends PlugName, Ctor extends PlugConstructor<Name>>(name: Name, ctor: Ctor): void;
|
|
164
|
+
/**
|
|
165
|
+
* Install a _forking_ {@link Plug} in the {@link Pipe}, in other words
|
|
166
|
+
* execute the plug in a separate process.
|
|
167
|
+
*
|
|
168
|
+
* As a contract, if the _last non-null_ parameter of the constructor is an
|
|
169
|
+
* object and contains the key `coverageDir`, the process will be forked with
|
|
170
|
+
* the approptiately resolved `NODE_V8_COVERAGE` environment variable.
|
|
171
|
+
*
|
|
172
|
+
* Also, forking plugs require some special attention:
|
|
173
|
+
*
|
|
174
|
+
* * plug functions are not supported, only classes implementing the
|
|
175
|
+
* {@link Plug} interface can be used with this.
|
|
176
|
+
*
|
|
177
|
+
* * the class itself _MUST_ be exported as the _default_ export for the
|
|
178
|
+
* `scriptFile` specified below. This is to simplify interoperability between
|
|
179
|
+
* CommonJS and ESM modules as we use dynamic `import(...)` statements.
|
|
180
|
+
*/
|
|
181
|
+
export declare function installForking<Name extends PlugName>(plugName: Name, scriptFile: AbsolutePath): void;
|
|
152
182
|
export {};
|
package/dist/pipe.mjs
CHANGED
|
@@ -1,44 +1,50 @@
|
|
|
1
1
|
// pipe.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this
|
|
11
|
-
this
|
|
12
|
-
}
|
|
13
|
-
plug(arg) {
|
|
14
|
-
const plug = typeof arg === "function" ? { pipe: arg } : arg;
|
|
15
|
-
const promise = this.#promise.then((files) => {
|
|
16
|
-
assert(files, "Pipe can not be further extended");
|
|
17
|
-
return plug.pipe(files, this.#run);
|
|
18
|
-
});
|
|
19
|
-
return new PipeImpl(promise, this.#run);
|
|
20
|
-
}
|
|
21
|
-
then(onfulfilled, onrejected) {
|
|
22
|
-
return this.#promise.then(onfulfilled, onrejected);
|
|
23
|
-
}
|
|
24
|
-
catch(onrejected) {
|
|
25
|
-
return this.#promise.catch(onrejected);
|
|
2
|
+
import { getLogger } from "./log.mjs";
|
|
3
|
+
import { getAbsoluteParent, getCurrentWorkingDirectory, resolveAbsolutePath } from "./paths.mjs";
|
|
4
|
+
import { ForkingPlug } from "./fork.mjs";
|
|
5
|
+
import { sep } from "path";
|
|
6
|
+
var Context = class {
|
|
7
|
+
constructor(buildFile, taskName) {
|
|
8
|
+
this.buildFile = buildFile;
|
|
9
|
+
this.taskName = taskName;
|
|
10
|
+
this.buildDir = getAbsoluteParent(buildFile);
|
|
11
|
+
this.log = getLogger(taskName);
|
|
26
12
|
}
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
buildDir;
|
|
14
|
+
log;
|
|
15
|
+
resolve(path, ...paths) {
|
|
16
|
+
if (path && path.startsWith("@")) {
|
|
17
|
+
const components = path.substring(1).split(sep).filter((s) => !!s);
|
|
18
|
+
return resolveAbsolutePath(this.buildDir, ...components, ...paths);
|
|
19
|
+
}
|
|
20
|
+
if (!path)
|
|
21
|
+
return getCurrentWorkingDirectory();
|
|
22
|
+
return resolveAbsolutePath(getCurrentWorkingDirectory(), path, ...paths);
|
|
29
23
|
}
|
|
30
|
-
|
|
24
|
+
};
|
|
25
|
+
var PipeProto = class {
|
|
26
|
+
};
|
|
27
|
+
var Pipe = class extends PipeProto {
|
|
31
28
|
};
|
|
32
29
|
function install(name, ctor) {
|
|
33
|
-
function
|
|
30
|
+
function plug(...args) {
|
|
34
31
|
return this.plug(new ctor(...args));
|
|
35
32
|
}
|
|
36
|
-
Object.defineProperty(
|
|
37
|
-
Object.defineProperty(
|
|
33
|
+
Object.defineProperty(plug, "name", { value: name });
|
|
34
|
+
Object.defineProperty(PipeProto.prototype, name, { value: plug });
|
|
35
|
+
}
|
|
36
|
+
function installForking(plugName, scriptFile) {
|
|
37
|
+
const ctor = class extends ForkingPlug {
|
|
38
|
+
constructor(...args) {
|
|
39
|
+
super(scriptFile, args);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
install(plugName, ctor);
|
|
38
43
|
}
|
|
39
44
|
export {
|
|
45
|
+
Context,
|
|
40
46
|
Pipe,
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
install,
|
|
48
|
+
installForking
|
|
43
49
|
};
|
|
44
50
|
//# sourceMappingURL=pipe.mjs.map
|
package/dist/pipe.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/pipe.ts"],
|
|
4
|
-
"mappings": ";
|
|
4
|
+
"mappings": ";AACA,SAAS,iBAAyB;AAClC,SAAuB,mBAAmB,4BAA4B,2BAA2B;AAEjG,SAAS,mBAAmB;AAC5B,SAAS,WAAW;AA+Bb,IAAM,UAAN,MAAc;AAAA,EAMnB,YAEoB,WAEA,UAClB;AAHkB;AAEA;AAElB,SAAK,WAAW,kBAAkB,SAAS;AAC3C,SAAK,MAAM,UAAU,QAAQ;AAAA,EAC/B;AAAA,EAZgB;AAAA,EAEA;AAAA,EAYhB,QAAQ,SAAiB,OAA+B;AAEtD,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;AACF;AAUA,IAAe,YAAf,MAAyB;AAEzB;AAMO,IAAe,OAAf,cAA4B,UAAU;AAO7C;AAyGO,SAAS,QAGd,MAAY,MAAkB;AAE9B,WAAS,QAAyB,MAAuD;AAEvF,WAAO,KAAK,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC;AAAA,EACpC;AAGA,SAAO,eAAe,MAAM,QAAQ,EAAE,OAAO,KAAK,CAAC;AAGnD,SAAO,eAAe,UAAU,WAAW,MAAM,EAAE,OAAO,KAAK,CAAC;AAClE;AAmBO,SAAS,eACZ,UACA,YACI;AAEN,QAAM,OAAO,cAAc,YAAY;AAAA,IACrC,eAAe,MAAa;AAC1B,YAAM,YAAY,IAAI;AAAA,IACxB;AAAA,EACF;AAGA,UAAQ,UAAU,IAAI;AACxB;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|