@plugjs/plug 0.0.12 → 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/{types → dist}/assert.d.ts +0 -0
- package/dist/async.cjs +20 -19
- package/dist/async.cjs.map +1 -1
- package/dist/async.d.ts +20 -0
- 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 -0
- 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/{types → 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 +36 -0
- 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 +21 -0
- 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 +10 -0
- 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/{types → dist}/log/colors.d.ts +2 -2
- package/dist/log/colors.mjs +3 -1
- package/dist/log/colors.mjs.map +1 -1
- package/{types → dist}/log/emit.d.ts +1 -1
- package/{types → dist}/log/levels.d.ts +0 -0
- package/dist/log/logger.cjs +4 -0
- package/dist/log/logger.cjs.map +1 -1
- package/{types → dist}/log/logger.d.ts +4 -1
- package/dist/log/logger.mjs +4 -0
- package/dist/log/logger.mjs.map +1 -1
- package/{types → dist}/log/options.d.ts +1 -1
- package/dist/log/report.cjs +4 -13
- package/dist/log/report.cjs.map +1 -1
- package/{types → dist}/log/report.d.ts +36 -4
- package/dist/log/report.mjs +3 -12
- package/dist/log/report.mjs.map +1 -1
- package/{types → dist}/log/spinner.d.ts +0 -0
- package/dist/log.cjs +1 -1
- package/dist/log.cjs.map +1 -1
- package/{types → dist}/log.d.ts +6 -6
- package/dist/log.mjs +2 -2
- package/dist/log.mjs.map +1 -1
- package/{types → dist}/paths.d.ts +0 -0
- package/dist/pipe.cjs +41 -34
- package/dist/pipe.cjs.map +1 -1
- package/dist/pipe.d.ts +182 -0
- 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 +28 -0
- package/dist/plugs/copy.mjs +15 -17
- package/dist/plugs/copy.mjs.map +2 -2
- package/{types → dist}/plugs/coverage/analysis.d.ts +2 -2
- package/dist/plugs/coverage/report.cjs +4 -2
- package/dist/plugs/coverage/report.cjs.map +1 -1
- package/{types → dist}/plugs/coverage/report.d.ts +3 -3
- package/dist/plugs/coverage/report.mjs +4 -2
- package/dist/plugs/coverage/report.mjs.map +1 -1
- package/dist/plugs/coverage.cjs +23 -27
- package/dist/plugs/coverage.cjs.map +1 -1
- package/dist/plugs/coverage.d.ts +49 -0
- package/dist/plugs/coverage.mjs +24 -20
- 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 +7 -0
- package/dist/plugs/debug.mjs +24 -20
- package/dist/plugs/debug.mjs.map +1 -1
- package/{types → dist}/plugs/esbuild/bundle-locals.d.ts +0 -0
- package/{types → dist}/plugs/esbuild/fix-extensions.d.ts +0 -0
- 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 +18 -0
- 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 +8 -0
- 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 +90 -0
- 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 +29 -0
- package/dist/plugs/filter.mjs +10 -12
- package/dist/plugs/filter.mjs.map +1 -1
- package/dist/plugs/mocha/reporter.cjs +19 -6
- package/dist/plugs/mocha/reporter.cjs.map +1 -1
- package/{types → dist}/plugs/mocha/reporter.d.ts +0 -2
- package/dist/plugs/mocha/reporter.mjs +18 -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 +8 -0
- 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/{types/plugs/mocha/runner.d.ts → dist/plugs/mocha.d.ts} +9 -8
- 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 +11 -0
- package/dist/plugs/rmf.mjs +25 -20
- package/dist/plugs/rmf.mjs.map +1 -1
- package/{types → dist}/plugs/tsc/compiler.d.ts +1 -1
- package/{types → dist}/plugs/tsc/options.d.ts +1 -1
- package/{types → 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 +8 -0
- 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 -0
- 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/{types → dist}/utils/asyncfs.d.ts +0 -0
- package/dist/utils/caller.cjs +8 -11
- package/dist/utils/caller.cjs.map +2 -2
- package/dist/utils/caller.d.ts +2 -0
- package/dist/utils/caller.mjs +8 -11
- package/dist/utils/caller.mjs.map +2 -2
- package/{types → dist}/utils/match.d.ts +0 -0
- package/dist/utils/options.cjs +4 -6
- package/dist/utils/options.cjs.map +1 -1
- package/dist/utils/options.d.ts +16 -0
- package/dist/utils/options.mjs +4 -6
- package/dist/utils/options.mjs.map +1 -1
- package/{types → dist}/utils/walk.d.ts +2 -2
- package/extra/cli.mjs +31 -20
- package/extra/ts-loader.mjs +6 -5
- package/package.json +10 -10
- 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 +10 -24
- 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 +9 -6
- package/src/plugs/coverage.ts +68 -55
- 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 +19 -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.mjs +0 -65
- package/dist/run.mjs.map +0 -6
- package/dist/task.cjs.map +0 -6
- 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/types/async.d.ts +0 -20
- package/types/build.d.ts +0 -56
- package/types/fork.d.ts +0 -57
- package/types/helpers.d.ts +0 -43
- package/types/index.d.ts +0 -14
- package/types/pipe.d.ts +0 -152
- package/types/plugs/copy.d.ts +0 -27
- package/types/plugs/coverage.d.ts +0 -46
- package/types/plugs/debug.d.ts +0 -14
- package/types/plugs/esbuild.d.ts +0 -23
- package/types/plugs/eslint/runner.d.ts +0 -22
- package/types/plugs/exec.d.ts +0 -90
- package/types/plugs/filter.d.ts +0 -23
- package/types/plugs/rmf.d.ts +0 -15
- package/types/plugs/tsc/runner.d.ts +0 -13
- package/types/plugs.d.ts +0 -17
- package/types/run.d.ts +0 -89
- package/types/task.d.ts +0 -15
- package/types/utils/caller.d.ts +0 -7
- package/types/utils/options.d.ts +0 -15
package/dist/fork.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/fork.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAqB;AACrB,oBAAgC;AAChC,mBAAyB;AACzB,mBAAsB;AACtB,iBAAiD;AACjD,mBAA2D;AAC3D,kBAA0C;AAkCnC,IAAe,cAAf,MAAuD;AAAA,EAC5D,YACqB,aACA,YACnB;AAFmB;AACA;AAAA,EAClB;AAAA,EAEH,KAAK,OAAc,SAAuC;AACxD,UAAM,UAAoB;AAAA,MACxB,YAAY,KAAK;AAAA,MACjB,iBAAiB,KAAK;AAAA,MACtB,UAAU,QAAQ;AAAA,MAClB,WAAW,QAAQ;AAAA,MACnB,UAAU,MAAM;AAAA,MAChB,WAAW,CAAE,GAAG,MAAM,cAAc,CAAE;AAAA,MACtC,SAAS,sBAAW,KAAK,QAAQ,QAAQ;AAAA,IAC3C;AAGA,UAAM,aAAS,8BAAgB,UAAS;AACxC,YAAQ,IAAI,MAAM,+BAA2B,eAAG,MAAM,CAAC;AAGvD,UAAM,MAAM,EAAE,GAAG,QAAQ,IAAI;AAG7B,aAAS,IAAI,KAAK,WAAW,SAAS,GAAG,KAAK,GAAG,KAAM;AACrD,UAAI,KAAK,WAAW,MAAM;AAAM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|
+
import { Files } from './files';
|
|
2
|
+
import { LogOptions } from './log';
|
|
3
|
+
import { AbsolutePath } from './paths';
|
|
4
|
+
import { Plug, PlugResult, Context } from './pipe';
|
|
5
|
+
/** Fork data, from parent to child process */
|
|
6
|
+
export interface ForkData {
|
|
7
|
+
/** Script name for the Plug to execute */
|
|
8
|
+
scriptFile: AbsolutePath;
|
|
9
|
+
/** Plug constructor arguments */
|
|
10
|
+
constructorArgs: any[];
|
|
11
|
+
/** Task name (for logs) */
|
|
12
|
+
taskName: string;
|
|
13
|
+
/** Build file name */
|
|
14
|
+
buildFile: AbsolutePath;
|
|
15
|
+
/** Files directory */
|
|
16
|
+
filesDir: AbsolutePath;
|
|
17
|
+
/** All files to pipe */
|
|
18
|
+
filesList: AbsolutePath[];
|
|
19
|
+
/** Options for our logger in the child process */
|
|
20
|
+
logOpts: Partial<LogOptions>;
|
|
21
|
+
}
|
|
22
|
+
/** Fork result, from child to parent process */
|
|
23
|
+
export interface ForkResult {
|
|
24
|
+
/** If this is `true` we _might_ have `filesDir` and `filesList` */
|
|
25
|
+
failed: boolean;
|
|
26
|
+
/** Files directory of the result */
|
|
27
|
+
filesDir?: AbsolutePath | undefined;
|
|
28
|
+
/** All files returned by the plug */
|
|
29
|
+
filesList?: AbsolutePath[] | undefined;
|
|
30
|
+
}
|
|
31
|
+
export declare abstract class ForkingPlug implements Plug<PlugResult> {
|
|
32
|
+
private readonly _scriptFile;
|
|
33
|
+
private readonly _arguments;
|
|
34
|
+
constructor(_scriptFile: AbsolutePath, _arguments: any[]);
|
|
35
|
+
pipe(files: Files, context: Context): Promise<PlugResult>;
|
|
36
|
+
}
|
package/dist/fork.mjs
CHANGED
|
@@ -2,44 +2,35 @@
|
|
|
2
2
|
import { fork } from "node:child_process";
|
|
3
3
|
import { assert, failure } from "./assert.mjs";
|
|
4
4
|
import { runAsync } from "./async.mjs";
|
|
5
|
+
import { Files } from "./files.mjs";
|
|
5
6
|
import { $gry, $p, logOptions } from "./log.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { RunImpl } from "./run.mjs";
|
|
9
|
-
function installForking(plugName, scriptFile) {
|
|
10
|
-
const ctor = class extends ForkingPlug {
|
|
11
|
-
constructor(...args) {
|
|
12
|
-
super(scriptFile, args);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
install(plugName, ctor);
|
|
16
|
-
}
|
|
7
|
+
import { requireFilename, resolveFile } from "./paths.mjs";
|
|
8
|
+
import { Context } from "./pipe.mjs";
|
|
17
9
|
var ForkingPlug = class {
|
|
18
10
|
constructor(_scriptFile, _arguments) {
|
|
19
11
|
this._scriptFile = _scriptFile;
|
|
20
12
|
this._arguments = _arguments;
|
|
21
13
|
}
|
|
22
|
-
pipe(files,
|
|
14
|
+
pipe(files, context) {
|
|
23
15
|
const message = {
|
|
24
16
|
scriptFile: this._scriptFile,
|
|
25
17
|
constructorArgs: this._arguments,
|
|
26
|
-
taskName:
|
|
27
|
-
buildFile:
|
|
28
|
-
buildDir: run.buildDir,
|
|
18
|
+
taskName: context.taskName,
|
|
19
|
+
buildFile: context.buildFile,
|
|
29
20
|
filesDir: files.directory,
|
|
30
21
|
filesList: [...files.absolutePaths()],
|
|
31
|
-
logOpts: logOptions.fork(
|
|
22
|
+
logOpts: logOptions.fork(context.taskName)
|
|
32
23
|
};
|
|
33
24
|
const script = requireFilename(import.meta.url);
|
|
34
|
-
|
|
25
|
+
context.log.debug("About to fork plug from", $p(script));
|
|
35
26
|
const env = { ...process.env };
|
|
36
27
|
for (let i = this._arguments.length - 1; i >= 0; i--) {
|
|
37
28
|
if (this._arguments[i] == null)
|
|
38
29
|
continue;
|
|
39
30
|
if (typeof this._arguments[i] === "object") {
|
|
40
31
|
if (typeof this._arguments[i].coverageDir === "string") {
|
|
41
|
-
const dir = env.NODE_V8_COVERAGE =
|
|
42
|
-
|
|
32
|
+
const dir = env.NODE_V8_COVERAGE = context.resolve(this._arguments[i].coverageDir);
|
|
33
|
+
context.log.debug("Forked process will produce coverage in", $p(dir));
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
36
|
}
|
|
@@ -47,46 +38,46 @@ var ForkingPlug = class {
|
|
|
47
38
|
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
48
39
|
env
|
|
49
40
|
});
|
|
50
|
-
|
|
41
|
+
context.log.info("Running", $p(script), $gry(`(pid=${child.pid})`));
|
|
51
42
|
let done = false;
|
|
52
43
|
return new Promise((resolve, reject) => {
|
|
53
44
|
let result = void 0;
|
|
54
45
|
child.on("error", (error) => {
|
|
55
|
-
|
|
46
|
+
context.log.error("Child process error", error);
|
|
56
47
|
return done || reject(failure());
|
|
57
48
|
});
|
|
58
49
|
child.on("message", (message2) => {
|
|
59
|
-
|
|
50
|
+
context.log.debug("Message from child process", message2);
|
|
60
51
|
result = message2;
|
|
61
52
|
});
|
|
62
53
|
child.on("exit", (code, signal) => {
|
|
63
54
|
if (signal) {
|
|
64
|
-
|
|
55
|
+
context.log.error(`Child process exited with signal ${signal}`, $gry(`(pid=${child.pid})`));
|
|
65
56
|
return done || reject(failure());
|
|
66
57
|
} else if (code !== 0) {
|
|
67
|
-
|
|
58
|
+
context.log.error(`Child process exited with code ${code}`, $gry(`(pid=${child.pid})`));
|
|
68
59
|
return done || reject(failure());
|
|
69
60
|
} else if (!result) {
|
|
70
|
-
|
|
61
|
+
context.log.error("Child process exited with no result", $gry(`(pid=${child.pid})`));
|
|
71
62
|
return done || reject(failure());
|
|
72
63
|
} else if (result.failed) {
|
|
73
64
|
return done || reject(failure());
|
|
74
65
|
}
|
|
75
|
-
return done || resolve(message.filesDir && message.filesList ?
|
|
66
|
+
return done || resolve(message.filesDir && message.filesList ? Files.builder(message.filesDir).add(...message.filesList).build() : void 0);
|
|
76
67
|
});
|
|
77
68
|
try {
|
|
78
69
|
const result2 = child.send(message, (error) => {
|
|
79
70
|
if (error) {
|
|
80
|
-
|
|
71
|
+
context.log.error("Error sending message to child process (callback failure)", error);
|
|
81
72
|
reject(failure());
|
|
82
73
|
}
|
|
83
74
|
});
|
|
84
75
|
if (!result2) {
|
|
85
|
-
|
|
76
|
+
context.log.error("Error sending message to child process (send returned false)");
|
|
86
77
|
reject(failure());
|
|
87
78
|
}
|
|
88
79
|
} catch (error) {
|
|
89
|
-
|
|
80
|
+
context.log.error("Error sending message to child process (exception caught)", error);
|
|
90
81
|
reject(failure());
|
|
91
82
|
}
|
|
92
83
|
}).finally(() => done = true);
|
|
@@ -104,15 +95,14 @@ if (process.argv[1] === requireFilename(import.meta.url) && process.send) {
|
|
|
104
95
|
constructorArgs,
|
|
105
96
|
taskName,
|
|
106
97
|
buildFile,
|
|
107
|
-
buildDir,
|
|
108
98
|
filesDir,
|
|
109
99
|
filesList,
|
|
110
100
|
logOpts
|
|
111
101
|
} = message;
|
|
112
102
|
Object.assign(logOptions, logOpts);
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const result = runAsync(
|
|
103
|
+
const context = new Context(buildFile, taskName);
|
|
104
|
+
context.log.debug("Message from parent process", message);
|
|
105
|
+
const result = runAsync(context, taskName, async () => {
|
|
116
106
|
assert(resolveFile(scriptFile), `Script file ${$p(scriptFile)} not found`);
|
|
117
107
|
const script = await import(scriptFile);
|
|
118
108
|
let Ctor = script;
|
|
@@ -123,8 +113,8 @@ if (process.argv[1] === requireFilename(import.meta.url) && process.send) {
|
|
|
123
113
|
`Script ${$p(scriptFile)} does not export a default constructor`
|
|
124
114
|
);
|
|
125
115
|
const plug = new Ctor(...constructorArgs);
|
|
126
|
-
const files =
|
|
127
|
-
return plug.pipe(files,
|
|
116
|
+
const files = Files.builder(filesDir).add(...filesList).build();
|
|
117
|
+
return plug.pipe(files, context);
|
|
128
118
|
});
|
|
129
119
|
const promise = result.then((result2) => {
|
|
130
120
|
const message2 = result2 ? { failed: false, filesDir: result2.directory, filesList: [...result2.absolutePaths()] } : { failed: false };
|
|
@@ -132,22 +122,21 @@ if (process.argv[1] === requireFilename(import.meta.url) && process.send) {
|
|
|
132
122
|
process.send(message2, (err) => err ? reject(err) : resolve());
|
|
133
123
|
});
|
|
134
124
|
}, (error) => {
|
|
135
|
-
|
|
125
|
+
context.log.error(error);
|
|
136
126
|
return new Promise((resolve, reject) => {
|
|
137
127
|
process.send({ failed: true }, (err) => err ? reject(err) : resolve());
|
|
138
128
|
});
|
|
139
129
|
});
|
|
140
130
|
promise.then(() => {
|
|
141
|
-
|
|
131
|
+
context.log.debug("Forked plug exiting");
|
|
142
132
|
process.exit(0);
|
|
143
133
|
}, (error) => {
|
|
144
|
-
|
|
134
|
+
context.log.error("Error sending message back to parent process", error);
|
|
145
135
|
process.exit(1);
|
|
146
136
|
});
|
|
147
137
|
});
|
|
148
138
|
}
|
|
149
139
|
export {
|
|
150
|
-
ForkingPlug
|
|
151
|
-
installForking
|
|
140
|
+
ForkingPlug
|
|
152
141
|
};
|
|
153
142
|
//# sourceMappingURL=fork.mjs.map
|
package/dist/fork.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/fork.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,QAAQ,eAAe;AAChC,SAAS,gBAAgB;
|
|
4
|
+
"mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,QAAQ,eAAe;AAChC,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,MAAM,IAAgB,kBAAkB;AACjD,SAAuB,iBAAiB,mBAAmB;AAC3D,SAA2B,eAAe;AAkCnC,IAAe,cAAf,MAAuD;AAAA,EAC5D,YACqB,aACA,YACnB;AAFmB;AACA;AAAA,EAClB;AAAA,EAEH,KAAK,OAAc,SAAuC;AACxD,UAAM,UAAoB;AAAA,MACxB,YAAY,KAAK;AAAA,MACjB,iBAAiB,KAAK;AAAA,MACtB,UAAU,QAAQ;AAAA,MAClB,WAAW,QAAQ;AAAA,MACnB,UAAU,MAAM;AAAA,MAChB,WAAW,C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AAQ,IAAI,MAAM,qBAAqB;AACvC,cAAQ,KAAK,CAAC;AAAA,IAChB,GAAG,CAAC,UAAU;AACZ,cAAQ,IAAI,MAAM,gDAAgD,KAAK;AACvE,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;",
|
|
5
5
|
"names": ["message", "result"]
|
|
6
6
|
}
|
package/dist/helpers.cjs
CHANGED
|
@@ -20,32 +20,78 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// helpers.ts
|
|
21
21
|
var helpers_exports = {};
|
|
22
22
|
__export(helpers_exports, {
|
|
23
|
-
files: () => files,
|
|
24
23
|
find: () => find,
|
|
25
24
|
isDirectory: () => isDirectory,
|
|
26
25
|
isFile: () => isFile,
|
|
27
26
|
merge: () => merge,
|
|
28
|
-
|
|
29
|
-
resolve: () => resolve,
|
|
30
|
-
rmrf: () => rmrf,
|
|
31
|
-
setLogLevel: () => setLogLevel
|
|
27
|
+
rmrf: () => rmrf
|
|
32
28
|
});
|
|
33
29
|
module.exports = __toCommonJS(helpers_exports);
|
|
34
|
-
var import_paths = require("./paths.cjs");
|
|
35
30
|
var import_assert = require("./assert.cjs");
|
|
36
31
|
var import_async = require("./async.cjs");
|
|
32
|
+
var import_files = require("./files.cjs");
|
|
37
33
|
var import_log = require("./log.cjs");
|
|
34
|
+
var import_paths = require("./paths.cjs");
|
|
35
|
+
var import_pipe = require("./pipe.cjs");
|
|
38
36
|
var import_asyncfs = require("./utils/asyncfs.cjs");
|
|
37
|
+
var import_options = require("./utils/options.cjs");
|
|
38
|
+
var import_walk = require("./utils/walk.cjs");
|
|
39
|
+
var PipeImpl = class extends import_pipe.Pipe {
|
|
40
|
+
constructor(_start) {
|
|
41
|
+
super();
|
|
42
|
+
this._start = _start;
|
|
43
|
+
}
|
|
44
|
+
plug(arg) {
|
|
45
|
+
const plug = typeof arg === "function" ? { pipe: arg } : arg;
|
|
46
|
+
const parent = this;
|
|
47
|
+
return new PipeImpl(async (context) => {
|
|
48
|
+
const files = await parent._start(context);
|
|
49
|
+
const files2 = await plug.pipe(files, context);
|
|
50
|
+
(0, import_assert.assert)(files2, "Unable to extend pipe (part tres)");
|
|
51
|
+
return files2;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async run() {
|
|
55
|
+
return this._start((0, import_async.requireContext)());
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function find(...args) {
|
|
59
|
+
const { params: globs, options } = (0, import_options.parseOptions)(args, {});
|
|
60
|
+
return new PipeImpl(async (context) => {
|
|
61
|
+
const directory = options.directory ? context.resolve(options.directory) : (0, import_paths.getCurrentWorkingDirectory)();
|
|
62
|
+
const builder = import_files.Files.builder(directory);
|
|
63
|
+
for await (const file of (0, import_walk.walk)(directory, globs, options)) {
|
|
64
|
+
builder.add(file);
|
|
65
|
+
}
|
|
66
|
+
return builder.build();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function merge(...pipes) {
|
|
70
|
+
return new PipeImpl(async () => {
|
|
71
|
+
if (pipes.length === 0)
|
|
72
|
+
return import_files.Files.builder((0, import_paths.getCurrentWorkingDirectory)()).build();
|
|
73
|
+
const results = [];
|
|
74
|
+
for (const pipe of pipes) {
|
|
75
|
+
const result = await pipe.run();
|
|
76
|
+
(0, import_assert.assert)(result, "Pipe did not return a Files result");
|
|
77
|
+
results.push(result);
|
|
78
|
+
}
|
|
79
|
+
const [first, ...others] = results;
|
|
80
|
+
const firstDir = first.directory;
|
|
81
|
+
const otherDirs = others.map((f) => f.directory);
|
|
82
|
+
const directory = (0, import_paths.commonPath)(firstDir, ...otherDirs);
|
|
83
|
+
return import_files.Files.builder(directory).merge(first, ...others).build();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
39
86
|
async function rmrf(directory) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const dir = run.resolve(directory);
|
|
87
|
+
const context = (0, import_async.requireContext)();
|
|
88
|
+
const dir = context.resolve(directory);
|
|
43
89
|
(0, import_assert.assert)(
|
|
44
90
|
dir !== (0, import_paths.getCurrentWorkingDirectory)(),
|
|
45
91
|
`Cowardly refusing to wipe current working directory ${(0, import_log.$p)(dir)}`
|
|
46
92
|
);
|
|
47
93
|
(0, import_assert.assert)(
|
|
48
|
-
dir !==
|
|
94
|
+
dir !== context.resolve("@"),
|
|
49
95
|
`Cowardly refusing to wipe build file directory ${(0, import_log.$p)(dir)}`
|
|
50
96
|
);
|
|
51
97
|
if (!(0, import_paths.resolveDirectory)(dir)) {
|
|
@@ -55,68 +101,20 @@ async function rmrf(directory) {
|
|
|
55
101
|
import_log.log.notice("Removing directory", (0, import_log.$p)(dir), "recursively");
|
|
56
102
|
await (0, import_asyncfs.rm)(dir, { recursive: true });
|
|
57
103
|
}
|
|
58
|
-
function setLogLevel(level) {
|
|
59
|
-
const run = (0, import_async.currentRun)();
|
|
60
|
-
(0, import_assert.assert)(run, "Unable to find files outside a running task");
|
|
61
|
-
return run.setLogLevel(level);
|
|
62
|
-
}
|
|
63
|
-
function resolve(...paths) {
|
|
64
|
-
const run = (0, import_async.currentRun)();
|
|
65
|
-
(0, import_assert.assert)(run, "Unable to find files outside a running task");
|
|
66
|
-
return run.resolve(...paths);
|
|
67
|
-
}
|
|
68
|
-
function files(first, ...paths) {
|
|
69
|
-
const run = (0, import_async.currentRun)();
|
|
70
|
-
(0, import_assert.assert)(run, "Unable to create files builder outside a running task");
|
|
71
|
-
if (typeof first === "string") {
|
|
72
|
-
return run.files(first, ...paths);
|
|
73
|
-
} else if (first) {
|
|
74
|
-
return run.files(first);
|
|
75
|
-
} else {
|
|
76
|
-
return run.files();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function merge(args) {
|
|
80
|
-
const run = (0, import_async.currentRun)();
|
|
81
|
-
(0, import_assert.assert)(run, "Unable to create files builder outside a running task");
|
|
82
|
-
const promise = Promise.resolve().then(async () => {
|
|
83
|
-
if (args.length === 0)
|
|
84
|
-
return run.pipe(run.files().build());
|
|
85
|
-
const instances = await Promise.all(args);
|
|
86
|
-
const [first, ...others] = instances;
|
|
87
|
-
const firstDir = first.directory;
|
|
88
|
-
const otherDirs = others.map((f) => f.directory);
|
|
89
|
-
const directory = (0, import_paths.commonPath)(firstDir, ...otherDirs);
|
|
90
|
-
return run.files(directory).merge(first, ...others).build();
|
|
91
|
-
});
|
|
92
|
-
return run.pipe(promise);
|
|
93
|
-
}
|
|
94
|
-
function find(glob, ...args) {
|
|
95
|
-
const run = (0, import_async.currentRun)();
|
|
96
|
-
(0, import_assert.assert)(run, "Unable to find files outside a running task");
|
|
97
|
-
return run.find(glob, ...args);
|
|
98
|
-
}
|
|
99
|
-
function pipe(files2) {
|
|
100
|
-
const run = (0, import_async.currentRun)();
|
|
101
|
-
(0, import_assert.assert)(run, "Unable to create pipes outside a running task");
|
|
102
|
-
return run.pipe(files2);
|
|
103
|
-
}
|
|
104
104
|
function isFile(...paths) {
|
|
105
|
-
|
|
105
|
+
const path = (0, import_async.requireContext)().resolve(...paths);
|
|
106
|
+
return (0, import_paths.resolveFile)(path);
|
|
106
107
|
}
|
|
107
108
|
function isDirectory(...paths) {
|
|
108
|
-
|
|
109
|
+
const path = (0, import_async.requireContext)().resolve(...paths);
|
|
110
|
+
return (0, import_paths.resolveDirectory)(path);
|
|
109
111
|
}
|
|
110
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
113
|
0 && (module.exports = {
|
|
112
|
-
files,
|
|
113
114
|
find,
|
|
114
115
|
isDirectory,
|
|
115
116
|
isFile,
|
|
116
117
|
merge,
|
|
117
|
-
|
|
118
|
-
resolve,
|
|
119
|
-
rmrf,
|
|
120
|
-
setLogLevel
|
|
118
|
+
rmrf
|
|
121
119
|
});
|
|
122
120
|
//# sourceMappingURL=helpers.cjs.map
|
package/dist/helpers.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/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B,IAAI;AAC9B;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AbsolutePath } from './paths';
|
|
2
|
+
import { Pipe } from './pipe';
|
|
3
|
+
import { WalkOptions } from './utils/walk';
|
|
4
|
+
/** The {@link FindOptions} interface defines the options for finding files. */
|
|
5
|
+
export interface FindOptions extends WalkOptions {
|
|
6
|
+
/** The directory where to start looking for files. */
|
|
7
|
+
directory?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function find(glob: string): Pipe;
|
|
10
|
+
export declare function find(glob: string, ...globs: string[]): Pipe;
|
|
11
|
+
export declare function find(glob: string, options: FindOptions): Pipe;
|
|
12
|
+
export declare function find(glob: string, ...extra: [...globs: string[], options: FindOptions]): Pipe;
|
|
13
|
+
export declare function merge(...pipes: Pipe[]): Pipe;
|
|
14
|
+
/**
|
|
15
|
+
* Recursively remove the specified directory _**(use with care)**_.
|
|
16
|
+
*/
|
|
17
|
+
export declare function rmrf(directory: string): Promise<void>;
|
|
18
|
+
/** Return an absolute path of the file if it exist on disk */
|
|
19
|
+
export declare function isFile(...paths: [string, ...string[]]): AbsolutePath | undefined;
|
|
20
|
+
/** Return an absolute path of the file if it exist on disk */
|
|
21
|
+
export declare function isDirectory(...paths: [string, ...string[]]): AbsolutePath | undefined;
|
package/dist/helpers.mjs
CHANGED
|
@@ -1,24 +1,69 @@
|
|
|
1
1
|
// helpers.ts
|
|
2
|
-
import {
|
|
3
|
-
commonPath,
|
|
4
|
-
getCurrentWorkingDirectory,
|
|
5
|
-
resolveDirectory,
|
|
6
|
-
resolveFile
|
|
7
|
-
} from "./paths.mjs";
|
|
8
2
|
import { assert } from "./assert.mjs";
|
|
9
|
-
import {
|
|
3
|
+
import { requireContext } from "./async.mjs";
|
|
4
|
+
import { Files } from "./files.mjs";
|
|
10
5
|
import { $p, log } from "./log.mjs";
|
|
6
|
+
import { commonPath, getCurrentWorkingDirectory, resolveDirectory, resolveFile } from "./paths.mjs";
|
|
7
|
+
import { Pipe } from "./pipe.mjs";
|
|
11
8
|
import { rm } from "./utils/asyncfs.mjs";
|
|
9
|
+
import { parseOptions } from "./utils/options.mjs";
|
|
10
|
+
import { walk } from "./utils/walk.mjs";
|
|
11
|
+
var PipeImpl = class extends Pipe {
|
|
12
|
+
constructor(_start) {
|
|
13
|
+
super();
|
|
14
|
+
this._start = _start;
|
|
15
|
+
}
|
|
16
|
+
plug(arg) {
|
|
17
|
+
const plug = typeof arg === "function" ? { pipe: arg } : arg;
|
|
18
|
+
const parent = this;
|
|
19
|
+
return new PipeImpl(async (context) => {
|
|
20
|
+
const files = await parent._start(context);
|
|
21
|
+
const files2 = await plug.pipe(files, context);
|
|
22
|
+
assert(files2, "Unable to extend pipe (part tres)");
|
|
23
|
+
return files2;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async run() {
|
|
27
|
+
return this._start(requireContext());
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function find(...args) {
|
|
31
|
+
const { params: globs, options } = parseOptions(args, {});
|
|
32
|
+
return new PipeImpl(async (context) => {
|
|
33
|
+
const directory = options.directory ? context.resolve(options.directory) : getCurrentWorkingDirectory();
|
|
34
|
+
const builder = Files.builder(directory);
|
|
35
|
+
for await (const file of walk(directory, globs, options)) {
|
|
36
|
+
builder.add(file);
|
|
37
|
+
}
|
|
38
|
+
return builder.build();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function merge(...pipes) {
|
|
42
|
+
return new PipeImpl(async () => {
|
|
43
|
+
if (pipes.length === 0)
|
|
44
|
+
return Files.builder(getCurrentWorkingDirectory()).build();
|
|
45
|
+
const results = [];
|
|
46
|
+
for (const pipe of pipes) {
|
|
47
|
+
const result = await pipe.run();
|
|
48
|
+
assert(result, "Pipe did not return a Files result");
|
|
49
|
+
results.push(result);
|
|
50
|
+
}
|
|
51
|
+
const [first, ...others] = results;
|
|
52
|
+
const firstDir = first.directory;
|
|
53
|
+
const otherDirs = others.map((f) => f.directory);
|
|
54
|
+
const directory = commonPath(firstDir, ...otherDirs);
|
|
55
|
+
return Files.builder(directory).merge(first, ...others).build();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
12
58
|
async function rmrf(directory) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const dir = run.resolve(directory);
|
|
59
|
+
const context = requireContext();
|
|
60
|
+
const dir = context.resolve(directory);
|
|
16
61
|
assert(
|
|
17
62
|
dir !== getCurrentWorkingDirectory(),
|
|
18
63
|
`Cowardly refusing to wipe current working directory ${$p(dir)}`
|
|
19
64
|
);
|
|
20
65
|
assert(
|
|
21
|
-
dir !==
|
|
66
|
+
dir !== context.resolve("@"),
|
|
22
67
|
`Cowardly refusing to wipe build file directory ${$p(dir)}`
|
|
23
68
|
);
|
|
24
69
|
if (!resolveDirectory(dir)) {
|
|
@@ -28,67 +73,19 @@ async function rmrf(directory) {
|
|
|
28
73
|
log.notice("Removing directory", $p(dir), "recursively");
|
|
29
74
|
await rm(dir, { recursive: true });
|
|
30
75
|
}
|
|
31
|
-
function setLogLevel(level) {
|
|
32
|
-
const run = currentRun();
|
|
33
|
-
assert(run, "Unable to find files outside a running task");
|
|
34
|
-
return run.setLogLevel(level);
|
|
35
|
-
}
|
|
36
|
-
function resolve(...paths) {
|
|
37
|
-
const run = currentRun();
|
|
38
|
-
assert(run, "Unable to find files outside a running task");
|
|
39
|
-
return run.resolve(...paths);
|
|
40
|
-
}
|
|
41
|
-
function files(first, ...paths) {
|
|
42
|
-
const run = currentRun();
|
|
43
|
-
assert(run, "Unable to create files builder outside a running task");
|
|
44
|
-
if (typeof first === "string") {
|
|
45
|
-
return run.files(first, ...paths);
|
|
46
|
-
} else if (first) {
|
|
47
|
-
return run.files(first);
|
|
48
|
-
} else {
|
|
49
|
-
return run.files();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function merge(args) {
|
|
53
|
-
const run = currentRun();
|
|
54
|
-
assert(run, "Unable to create files builder outside a running task");
|
|
55
|
-
const promise = Promise.resolve().then(async () => {
|
|
56
|
-
if (args.length === 0)
|
|
57
|
-
return run.pipe(run.files().build());
|
|
58
|
-
const instances = await Promise.all(args);
|
|
59
|
-
const [first, ...others] = instances;
|
|
60
|
-
const firstDir = first.directory;
|
|
61
|
-
const otherDirs = others.map((f) => f.directory);
|
|
62
|
-
const directory = commonPath(firstDir, ...otherDirs);
|
|
63
|
-
return run.files(directory).merge(first, ...others).build();
|
|
64
|
-
});
|
|
65
|
-
return run.pipe(promise);
|
|
66
|
-
}
|
|
67
|
-
function find(glob, ...args) {
|
|
68
|
-
const run = currentRun();
|
|
69
|
-
assert(run, "Unable to find files outside a running task");
|
|
70
|
-
return run.find(glob, ...args);
|
|
71
|
-
}
|
|
72
|
-
function pipe(files2) {
|
|
73
|
-
const run = currentRun();
|
|
74
|
-
assert(run, "Unable to create pipes outside a running task");
|
|
75
|
-
return run.pipe(files2);
|
|
76
|
-
}
|
|
77
76
|
function isFile(...paths) {
|
|
78
|
-
|
|
77
|
+
const path = requireContext().resolve(...paths);
|
|
78
|
+
return resolveFile(path);
|
|
79
79
|
}
|
|
80
80
|
function isDirectory(...paths) {
|
|
81
|
-
|
|
81
|
+
const path = requireContext().resolve(...paths);
|
|
82
|
+
return resolveDirectory(path);
|
|
82
83
|
}
|
|
83
84
|
export {
|
|
84
|
-
files,
|
|
85
85
|
find,
|
|
86
86
|
isDirectory,
|
|
87
87
|
isFile,
|
|
88
88
|
merge,
|
|
89
|
-
|
|
90
|
-
resolve,
|
|
91
|
-
rmrf,
|
|
92
|
-
setLogLevel
|
|
89
|
+
rmrf
|
|
93
90
|
};
|
|
94
91
|
//# sourceMappingURL=helpers.mjs.map
|
package/dist/helpers.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/helpers.ts"],
|
|
4
|
-
"mappings": ";AAAA
|
|
5
|
-
"names": [
|
|
4
|
+
"mapp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