@plugjs/plug 0.0.2 → 0.0.3
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 +4 -2
- package/dist/async.cjs.map +1 -1
- package/dist/async.mjs +4 -2
- package/dist/async.mjs.map +1 -1
- package/dist/files.cjs +16 -2
- package/dist/files.cjs.map +1 -1
- package/dist/files.mjs +17 -3
- package/dist/files.mjs.map +1 -1
- package/dist/fork.cjs +2 -2
- package/dist/fork.cjs.map +1 -1
- package/dist/fork.mjs +2 -2
- package/dist/fork.mjs.map +1 -1
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.mjs +1 -1
- package/dist/helpers.mjs.map +1 -1
- package/dist/log/report.cjs +2 -1
- package/dist/log/report.cjs.map +1 -1
- package/dist/log/report.mjs +2 -1
- package/dist/log/report.mjs.map +1 -1
- package/dist/log.cjs +4 -1
- package/dist/log.cjs.map +1 -1
- package/dist/log.mjs +4 -1
- package/dist/log.mjs.map +1 -1
- package/dist/paths.cjs.map +1 -1
- package/dist/paths.mjs.map +1 -1
- package/dist/plugs/copy.cjs +1 -1
- package/dist/plugs/copy.cjs.map +1 -1
- package/dist/plugs/copy.mjs +1 -1
- package/dist/plugs/copy.mjs.map +1 -1
- package/dist/plugs/coverage/analysis.cjs +8 -3
- package/dist/plugs/coverage/analysis.cjs.map +2 -2
- package/dist/plugs/coverage/analysis.mjs +8 -3
- package/dist/plugs/coverage/analysis.mjs.map +2 -2
- package/dist/plugs/coverage/report.cjs +2 -1
- package/dist/plugs/coverage/report.cjs.map +1 -1
- package/dist/plugs/coverage/report.mjs +2 -1
- package/dist/plugs/coverage/report.mjs.map +1 -1
- package/dist/plugs/debug.cjs +6 -6
- package/dist/plugs/debug.cjs.map +1 -1
- package/dist/plugs/debug.mjs +7 -7
- package/dist/plugs/debug.mjs.map +1 -1
- package/dist/plugs/esbuild/fix-extensions.cjs +4 -3
- package/dist/plugs/esbuild/fix-extensions.cjs.map +1 -1
- package/dist/plugs/esbuild/fix-extensions.mjs +4 -3
- package/dist/plugs/esbuild/fix-extensions.mjs.map +1 -1
- package/dist/plugs/esbuild.cjs +34 -4
- package/dist/plugs/esbuild.cjs.map +2 -2
- package/dist/plugs/esbuild.mjs +35 -5
- package/dist/plugs/esbuild.mjs.map +2 -2
- package/dist/plugs/filter.cjs +2 -3
- package/dist/plugs/filter.cjs.map +1 -1
- package/dist/plugs/filter.mjs +2 -3
- package/dist/plugs/filter.mjs.map +1 -1
- package/dist/plugs/mocha/reporter.cjs +1 -1
- package/dist/plugs/mocha/reporter.cjs.map +1 -1
- package/dist/plugs/mocha/reporter.mjs +1 -1
- package/dist/plugs/mocha/reporter.mjs.map +1 -1
- package/dist/plugs/rmf.cjs +53 -0
- package/dist/plugs/rmf.cjs.map +6 -0
- package/dist/plugs/rmf.mjs +28 -0
- package/dist/plugs/rmf.mjs.map +6 -0
- package/dist/plugs.cjs +1 -0
- package/dist/plugs.cjs.map +1 -1
- package/dist/plugs.mjs +1 -0
- package/dist/plugs.mjs.map +1 -1
- package/dist/run.cjs +3 -3
- package/dist/run.cjs.map +1 -1
- package/dist/run.mjs +3 -3
- package/dist/run.mjs.map +1 -1
- package/package.json +2 -2
- package/src/files.ts +36 -4
- package/src/fork.ts +2 -2
- package/src/helpers.ts +4 -4
- package/src/paths.ts +1 -0
- package/src/plugs/copy.ts +1 -1
- package/src/plugs/debug.ts +7 -7
- package/src/plugs/esbuild.ts +69 -10
- package/src/plugs/filter.ts +2 -3
- package/src/plugs/rmf.ts +42 -0
- package/src/plugs.ts +1 -0
- package/src/run.ts +5 -5
- package/types/files.d.ts +12 -1
- package/types/helpers.d.ts +3 -3
- package/types/plugs/rmf.d.ts +15 -0
- package/types/plugs.d.ts +1 -0
- package/types/run.d.ts +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugs/mocha/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AsB,MAAM,IAAI,GAAG,WAAW,GAAG;AAC9D,cAAI;AAAQ,gBAAI,OAAO,KAAK,IAAI,MAAM,CAAC,GAAG,WAAW,IAAI,QAAQ,CAAC;AAClE,cAAI;AAAS,gBAAI,KAAK,KAAK,IAAI,OAAO,CAAC,GAAG,SAAS;AACnD,cAAIA;AAAU,gBAAI,MAAM,KAAK,IAAIA,SAAQ,CAAC,GAAG,SAAS;AAAA,QACxD;AAGA,YAAI,OAAO,EAAE;AAAA,MACf,SAAS,OAAP;AACA,YAAI,MAAM,gCAAgC,KAAK;AAAA,MACjD;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
|
|
5
5
|
"names": ["failures"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// plugs/rmf.ts
|
|
21
|
+
var rmf_exports = {};
|
|
22
|
+
__export(rmf_exports, {
|
|
23
|
+
Rmf: () => Rmf
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(rmf_exports);
|
|
26
|
+
var import_log = require("../log.cjs");
|
|
27
|
+
var import_pipe = require("../pipe.cjs");
|
|
28
|
+
var import_asyncfs = require("../utils/asyncfs.cjs");
|
|
29
|
+
var Rmf = class {
|
|
30
|
+
_dryRun;
|
|
31
|
+
constructor(dryRun) {
|
|
32
|
+
this._dryRun = !!dryRun;
|
|
33
|
+
}
|
|
34
|
+
async pipe(files, run) {
|
|
35
|
+
if (this._dryRun) {
|
|
36
|
+
for (const file of files.absolutePaths()) {
|
|
37
|
+
run.log.notice("Not removing file", (0, import_log.$p)(file), (0, import_log.$gry)("(dry-run)"));
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
for (const file of files.absolutePaths()) {
|
|
41
|
+
run.log.notice("Removing file", (0, import_log.$p)(file));
|
|
42
|
+
await (0, import_asyncfs.rm)(file);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
(0, import_pipe.install)("rmf", Rmf);
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
Rmf
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=rmf.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/plugs/rmf.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAyB;AACzB,kBAA8B;AAE9B,qBAAmB;AAGZ,IAAM,MAAN,MAAqC;AAAA,EACzB;AAAA,EAEjB,YAAY,QAAkB;AAC5B,SAAK,UAAU,CAAC,CAAE;AAAA,EACpB;AAAA,EAEA,MAAM,KAAK,OAAc,KAA8B;AACrD,QAAI,KAAK,SAAS;AAChB,iBAAW,QAAQ,MAAM,cAAc,GAAG;AACxC,YAAI,IAAI,OAAO,yBAAqB,eAAG,IAAI,OAAG,iBAAK,WAAW,CAAC;AAAA,MACjE;AAAA,IACF,OAAO;AACL,iBAAW,QAAQ,MAAM,cAAc,GAAG;AACxC,YAAI,IAAI,OAAO,qBAAiB,eAAG,IAAI,CAAC;AACxC,kBAAM,mBAAG,IAAI;AAAA,MACf;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAAA,IAMA,qBAAQ,OAAO,GAAG;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// plugs/rmf.ts
|
|
2
|
+
import { $gry, $p } from "../log.mjs";
|
|
3
|
+
import { install } from "../pipe.mjs";
|
|
4
|
+
import { rm } from "../utils/asyncfs.mjs";
|
|
5
|
+
var Rmf = class {
|
|
6
|
+
_dryRun;
|
|
7
|
+
constructor(dryRun) {
|
|
8
|
+
this._dryRun = !!dryRun;
|
|
9
|
+
}
|
|
10
|
+
async pipe(files, run) {
|
|
11
|
+
if (this._dryRun) {
|
|
12
|
+
for (const file of files.absolutePaths()) {
|
|
13
|
+
run.log.notice("Not removing file", $p(file), $gry("(dry-run)"));
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
for (const file of files.absolutePaths()) {
|
|
17
|
+
run.log.notice("Removing file", $p(file));
|
|
18
|
+
await rm(file);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
install("rmf", Rmf);
|
|
25
|
+
export {
|
|
26
|
+
Rmf
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=rmf.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/plugs/rmf.ts"],
|
|
4
|
+
"mappings": ";AACA,SAAS,MAAM,UAAU;AACzB,SAAS,eAAqB;AAE9B,SAAS,UAAU;AAGZ,IAAM,MAAN,MAAqC;AAAA,EACzB;AAAA,EAEjB,YAAY,QAAkB;AAC5B,SAAK,UAAU,CAAC,CAAE;AAAA,EACpB;AAAA,EAEA,MAAM,KAAK,OAAc,KAA8B;AACrD,QAAI,KAAK,SAAS;AAChB,iBAAW,QAAQ,MAAM,cAAc,GAAG;AACxC,YAAI,IAAI,OAAO,qBAAqB,GAAG,IAAI,GAAG,KAAK,WAAW,CAAC;AAAA,MACjE;AAAA,IACF,OAAO;AACL,iBAAW,QAAQ,MAAM,cAAc,GAAG;AACxC,YAAI,IAAI,OAAO,iBAAiB,GAAG,IAAI,CAAC;AACxC,cAAM,GAAG,IAAI;AAAA,MACf;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAMA,QAAQ,OAAO,GAAG;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/dist/plugs.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __reExport(plugs_exports, require("./plugs/debug.cjs"), module.exports);
|
|
|
25
25
|
__reExport(plugs_exports, require("./plugs/esbuild.cjs"), module.exports);
|
|
26
26
|
__reExport(plugs_exports, require("./plugs/exec.cjs"), module.exports);
|
|
27
27
|
__reExport(plugs_exports, require("./plugs/filter.cjs"), module.exports);
|
|
28
|
+
__reExport(plugs_exports, require("./plugs/rmf.cjs"), module.exports);
|
|
28
29
|
(0, import_fork.installForking)("eslint", (0, import_paths.requireResolve)(__filename, "./plugs/eslint/runner"));
|
|
29
30
|
(0, import_fork.installForking)("mocha", (0, import_paths.requireResolve)(__filename, "./plugs/mocha/runner"));
|
|
30
31
|
(0, import_fork.installForking)("tsc", (0, import_paths.requireResolve)(__filename, "./plugs/tsc/runner"));
|
package/dist/plugs.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/plugs.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAIA,kBAA+B;AAC/B,mBAA+B;AAsB/B,0BAAc,6BA3Bd;AA4BA,0BAAc,iCA5Bd;AA6BA,0BAAc,8BA7Bd;AA8BA,0BAAc,gCA9Bd;AA+BA,0BAAc,6BA/Bd;AAgCA,0BAAc,+BAhCd;AAAA,IAmBA,4BAAe,cAAU,6BAAe,YAAW,uBAAuB,CAAC;AAAA,IAC3E,4BAAe,aAAS,6BAAe,YAAW,sBAAsB,CAAC;AAAA,IACzE,4BAAe,WAAO,6BAAe,YAAW,oBAAoB,CAAC;",
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAIA,kBAA+B;AAC/B,mBAA+B;AAsB/B,0BAAc,6BA3Bd;AA4BA,0BAAc,iCA5Bd;AA6BA,0BAAc,8BA7Bd;AA8BA,0BAAc,gCA9Bd;AA+BA,0BAAc,6BA/Bd;AAgCA,0BAAc,+BAhCd;AAiCA,0BAAc,4BAjCd;AAAA,IAmBA,4BAAe,cAAU,6BAAe,YAAW,uBAAuB,CAAC;AAAA,IAC3E,4BAAe,aAAS,6BAAe,YAAW,sBAAsB,CAAC;AAAA,IACzE,4BAAe,WAAO,6BAAe,YAAW,oBAAoB,CAAC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/plugs.mjs
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./plugs/debug.mjs";
|
|
|
7
7
|
export * from "./plugs/esbuild.mjs";
|
|
8
8
|
export * from "./plugs/exec.mjs";
|
|
9
9
|
export * from "./plugs/filter.mjs";
|
|
10
|
+
export * from "./plugs/rmf.mjs";
|
|
10
11
|
installForking("eslint", requireResolve(import.meta.url, "./plugs/eslint/runner"));
|
|
11
12
|
installForking("mocha", requireResolve(import.meta.url, "./plugs/mocha/runner"));
|
|
12
13
|
installForking("tsc", requireResolve(import.meta.url, "./plugs/tsc/runner"));
|
package/dist/plugs.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/plugs.ts"],
|
|
4
|
-
"mappings": ";AAIA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAsB/B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;
|
|
4
|
+
"mappings": ";AAIA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAsB/B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAdd,eAAe,UAAU,eAAe,iBAAW,uBAAuB,CAAC;AAC3E,eAAe,SAAS,eAAe,iBAAW,sBAAsB,CAAC;AACzE,eAAe,OAAO,eAAe,iBAAW,oBAAoB,CAAC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/run.cjs
CHANGED
|
@@ -55,11 +55,11 @@ var RunImpl = class {
|
|
|
55
55
|
if (path.startsWith("@")) {
|
|
56
56
|
const relative = path.substring(1);
|
|
57
57
|
(0, import_assert.assert)(!(0, import_paths.isAbsolutePath)(relative), `Path component of "${path}" is absolute`);
|
|
58
|
-
return (0, import_paths.resolveAbsolutePath)(
|
|
58
|
+
return (0, import_paths.resolveAbsolutePath)(this.buildDir, relative);
|
|
59
59
|
}
|
|
60
60
|
if ((0, import_paths.isAbsolutePath)(path))
|
|
61
61
|
return path;
|
|
62
|
-
return (0, import_paths.resolveAbsolutePath)(
|
|
62
|
+
return (0, import_paths.resolveAbsolutePath)((0, import_paths.getCurrentWorkingDirectory)(), path);
|
|
63
63
|
}
|
|
64
64
|
files(first, ...paths) {
|
|
65
65
|
if (typeof first === "string") {
|
|
@@ -75,7 +75,7 @@ var RunImpl = class {
|
|
|
75
75
|
const promise = Promise.resolve().then(async () => {
|
|
76
76
|
const builder = this.files(directory || ".");
|
|
77
77
|
for await (const file of (0, import_walk.walk)(builder.directory, [glob, ...params], options)) {
|
|
78
|
-
builder.
|
|
78
|
+
builder.unchecked(file);
|
|
79
79
|
}
|
|
80
80
|
return builder.build();
|
|
81
81
|
});
|
package/dist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E,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,qBAAS,OAAO,IAAI;AAAA,EACjC;AAAA,EAEA,KAAK,MAA0C;AAC7C,UAAM,IAAI,MAAM,wBAAwB,OAAO;AAAA,EACjD;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/run.mjs
CHANGED
|
@@ -31,11 +31,11 @@ var RunImpl = class {
|
|
|
31
31
|
if (path.startsWith("@")) {
|
|
32
32
|
const relative = path.substring(1);
|
|
33
33
|
assert(!isAbsolutePath(relative), `Path component of "${path}" is absolute`);
|
|
34
|
-
return resolveAbsolutePath(
|
|
34
|
+
return resolveAbsolutePath(this.buildDir, relative);
|
|
35
35
|
}
|
|
36
36
|
if (isAbsolutePath(path))
|
|
37
37
|
return path;
|
|
38
|
-
return resolveAbsolutePath(
|
|
38
|
+
return resolveAbsolutePath(getCurrentWorkingDirectory(), path);
|
|
39
39
|
}
|
|
40
40
|
files(first, ...paths) {
|
|
41
41
|
if (typeof first === "string") {
|
|
@@ -51,7 +51,7 @@ var RunImpl = class {
|
|
|
51
51
|
const promise = Promise.resolve().then(async () => {
|
|
52
52
|
const builder = this.files(directory || ".");
|
|
53
53
|
for await (const file of walk(builder.directory, [glob, ...params], options)) {
|
|
54
|
-
builder.
|
|
54
|
+
builder.unchecked(file);
|
|
55
55
|
}
|
|
56
56
|
return builder.build();
|
|
57
57
|
});
|
package/dist/run.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/run.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,aAA2B;AACpC,SAAS,cAAc,gBAAgB,iBAAiD;AACxF,SAAuB,4BAA4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MAA0C;AAC7C,UAAM,IAAI,MAAM,wBAAwB,OAAO;AAAA,EACjD;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/plug",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@babel/types": "^7.18.10",
|
|
33
33
|
"@plugjs/cov8-html": "^0.0.1",
|
|
34
34
|
"diff": "^5.1.0",
|
|
35
|
-
"esbuild": "^0.15.
|
|
35
|
+
"esbuild": "^0.15.5",
|
|
36
36
|
"eslint": "^8.22.0",
|
|
37
37
|
"mocha": "^10.0.0",
|
|
38
38
|
"picomatch": "^2.3.1",
|
package/src/files.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { inspect } from 'node:util'
|
|
2
|
-
import {
|
|
2
|
+
import { assert } from './assert.js'
|
|
3
|
+
import { AbsolutePath, assertRelativeChildPath, getAbsoluteParent, isFile, resolveAbsolutePath } from './paths.js'
|
|
3
4
|
import { mkdir, writeFile } from './utils/asyncfs.js'
|
|
4
5
|
|
|
5
6
|
/** The {@link FilesBuilder} interface defines a builder for {@link Files}. */
|
|
6
7
|
export interface FilesBuilder {
|
|
7
8
|
/** The (resolved) directory the {@link Files} will be associated with */
|
|
8
9
|
readonly directory: AbsolutePath
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Push files into the {@link Files} instance being built **checking for
|
|
13
|
+
* their existance on disk**.
|
|
14
|
+
*
|
|
15
|
+
* This _will_ be slow, use {@link FilesBuilder.unchecked} when absolutely
|
|
16
|
+
* sure the file already exist.
|
|
17
|
+
*/
|
|
10
18
|
add(...files: string[]): this
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Push files into the {@link Files} instance being built without checking
|
|
22
|
+
* they exist on disk _(use with care!)_.
|
|
23
|
+
*/
|
|
24
|
+
unchecked(...files: string[]): this
|
|
25
|
+
|
|
11
26
|
/** Merge orther {@link Files} instance to the {@link Files} being built */
|
|
12
27
|
merge(...files: Files[]): this
|
|
28
|
+
|
|
13
29
|
/** Write a file and add it to the {@link Files} instance being built */
|
|
14
30
|
write(file: string, content: string | Buffer): Promise<AbsolutePath>
|
|
31
|
+
|
|
15
32
|
/** Build and return a {@link Files} instance */
|
|
16
33
|
build(): Files
|
|
17
34
|
}
|
|
@@ -83,6 +100,21 @@ export class Files {
|
|
|
83
100
|
add(...files: string[]): FilesBuilder {
|
|
84
101
|
if (built) throw new Error('FileBuilder "build()" already called')
|
|
85
102
|
|
|
103
|
+
if (typeof files === 'string') files = [ files ]
|
|
104
|
+
for (const file of files) {
|
|
105
|
+
const relative = assertRelativeChildPath(instance.directory, file)
|
|
106
|
+
const resolved = resolveAbsolutePath(instance.directory, file)
|
|
107
|
+
|
|
108
|
+
assert(isFile(resolved), `File "${resolved}" does not exist`)
|
|
109
|
+
set.add(relative)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return this
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
unchecked(...files: string[]): FilesBuilder {
|
|
116
|
+
if (built) throw new Error('FileBuilder "build()" already called')
|
|
117
|
+
|
|
86
118
|
if (typeof files === 'string') files = [ files ]
|
|
87
119
|
for (const file of files) {
|
|
88
120
|
const relative = assertRelativeChildPath(instance.directory, file)
|
|
@@ -97,7 +129,7 @@ export class Files {
|
|
|
97
129
|
|
|
98
130
|
for (const files of args) {
|
|
99
131
|
for (const file of files.absolutePaths()) {
|
|
100
|
-
this.
|
|
132
|
+
this.unchecked(file)
|
|
101
133
|
}
|
|
102
134
|
}
|
|
103
135
|
|
|
@@ -111,7 +143,7 @@ export class Files {
|
|
|
111
143
|
|
|
112
144
|
await mkdir(directory, { recursive: true })
|
|
113
145
|
await writeFile(absolute, content)
|
|
114
|
-
this.
|
|
146
|
+
this.unchecked(absolute)
|
|
115
147
|
|
|
116
148
|
return absolute
|
|
117
149
|
},
|
package/src/fork.ts
CHANGED
|
@@ -153,7 +153,7 @@ export abstract class ForkingPlug implements Plug<Files | undefined> {
|
|
|
153
153
|
|
|
154
154
|
/* We definitely have a successful result! */
|
|
155
155
|
return resolve(message.filesDir && message.filesList ?
|
|
156
|
-
run.files(message.filesDir).
|
|
156
|
+
run.files(message.filesDir).unchecked(...message.filesList).build() :
|
|
157
157
|
undefined)
|
|
158
158
|
})
|
|
159
159
|
|
|
@@ -233,7 +233,7 @@ if ((process.argv[1] === requireFilename(__fileurl)) && (process.send)) {
|
|
|
233
233
|
|
|
234
234
|
/* Create the Plug instance and our Files instance */
|
|
235
235
|
const plug = new Ctor(...constructorArgs) as Plug<Files | undefined>
|
|
236
|
-
const files = run.files(filesDir).
|
|
236
|
+
const files = run.files(filesDir).unchecked(...filesList).build()
|
|
237
237
|
|
|
238
238
|
/* Run and return the result */
|
|
239
239
|
return plug.pipe(files, run)
|
package/src/helpers.ts
CHANGED
|
@@ -27,7 +27,7 @@ export async function rmrf(directory: string): Promise<void> {
|
|
|
27
27
|
return
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
log.
|
|
30
|
+
log.notice('Removing directory', $p(dir), 'recursively')
|
|
31
31
|
await rm(dir, { recursive: true })
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -46,8 +46,8 @@ export function setLogLevel(level: LogLevelString): void {
|
|
|
46
46
|
* Resolve a path into an {@link AbsolutePath}.
|
|
47
47
|
*
|
|
48
48
|
* If the path starts with `@...` it is considered to be relative to the
|
|
49
|
-
*
|
|
50
|
-
*
|
|
49
|
+
* _directory containing the build file where the task was defined_, otherwise
|
|
50
|
+
* it will be relative to the {@link process.cwd | current working directory}.
|
|
51
51
|
*/
|
|
52
52
|
export function resolve(...paths: string[]): AbsolutePath {
|
|
53
53
|
const run = currentRun()
|
|
@@ -60,7 +60,7 @@ export function resolve(...paths: string[]): AbsolutePath {
|
|
|
60
60
|
* Create a new {@link Files} instance.
|
|
61
61
|
*/
|
|
62
62
|
export function files(files: Files): FilesBuilder
|
|
63
|
-
export function files(...paths: string[]): FilesBuilder
|
|
63
|
+
export function files(directory: string, ...paths: string[]): FilesBuilder
|
|
64
64
|
export function files(first: Files | string | undefined, ...paths: string[]): FilesBuilder {
|
|
65
65
|
const run = currentRun()
|
|
66
66
|
assert(run, 'Unable to create files builder outside a running task')
|
package/src/paths.ts
CHANGED
|
@@ -75,6 +75,7 @@ export function getCurrentWorkingDirectory(): AbsolutePath {
|
|
|
75
75
|
return cwd
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
|
|
78
79
|
/* ========================================================================== *
|
|
79
80
|
* MODULE RESOLUTION FUNCTIONS *
|
|
80
81
|
* ========================================================================== */
|
package/src/plugs/copy.ts
CHANGED
package/src/plugs/debug.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Files } from '../files.js'
|
|
2
|
-
import { $gry, $p, $und
|
|
2
|
+
import { $gry, $p, $und } from '../log.js'
|
|
3
3
|
import { install, Plug } from '../pipe.js'
|
|
4
4
|
import { Run } from '../run.js'
|
|
5
5
|
|
|
@@ -8,14 +8,14 @@ export class Debug implements Plug<Files> {
|
|
|
8
8
|
constructor() {}
|
|
9
9
|
|
|
10
10
|
async pipe(files: Files, run: Run): Promise<Files> {
|
|
11
|
-
log.notice('Debugging', files.length, 'files')
|
|
12
|
-
log.notice('- base dir:', $p(run.resolve('@')))
|
|
13
|
-
log.notice('- build file dir:', $p(run.resolve('.')))
|
|
14
|
-
log.notice('- files dir:', $p(files.directory))
|
|
11
|
+
run.log.notice('Debugging', files.length, 'files')
|
|
12
|
+
run.log.notice('- base dir:', $p(run.resolve('@')))
|
|
13
|
+
run.log.notice('- build file dir:', $p(run.resolve('.')))
|
|
14
|
+
run.log.notice('- files dir:', $p(files.directory))
|
|
15
15
|
if (files.length) {
|
|
16
16
|
const [ path, ...paths ] = files
|
|
17
|
-
log.notice('- relative paths:', $und($gry(path)))
|
|
18
|
-
for (const p of paths) log.notice('- :', $und($gry(p)))
|
|
17
|
+
run.log.notice('- relative paths:', $und($gry(path)))
|
|
18
|
+
for (const p of paths) run.log.notice('- :', $und($gry(p)))
|
|
19
19
|
}
|
|
20
20
|
return files
|
|
21
21
|
}
|
package/src/plugs/esbuild.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { build, BuildFailure, BuildOptions, BuildResult, Message, Metafile } from 'esbuild'
|
|
1
|
+
import { build, BuildFailure, BuildOptions, BuildResult, Format, Message, Metafile } from 'esbuild'
|
|
2
|
+
import { basename } from 'node:path'
|
|
2
3
|
import { assert } from '../assert.js'
|
|
3
4
|
import { Files, FilesBuilder } from '../files.js'
|
|
4
|
-
import { $p, ERROR, ReportLevel, ReportRecord, WARN } from '../log.js'
|
|
5
|
-
import { AbsolutePath, resolveAbsolutePath } from '../paths.js'
|
|
5
|
+
import { $p, ERROR, Logger, ReportLevel, ReportRecord, WARN } from '../log.js'
|
|
6
|
+
import { AbsolutePath, getAbsoluteParent, resolveAbsolutePath } from '../paths.js'
|
|
6
7
|
import { install, Plug } from '../pipe.js'
|
|
7
8
|
import { Run } from '../run.js'
|
|
9
|
+
import { readFile } from '../utils/asyncfs.js'
|
|
8
10
|
|
|
9
11
|
export type ESBuildOptions = Omit<BuildOptions, 'absWorkingDir' | 'entryPoints' | 'watch'>
|
|
10
12
|
|
|
@@ -20,20 +22,23 @@ export class ESBuild implements Plug<Files> {
|
|
|
20
22
|
const absWorkingDir = files.directory
|
|
21
23
|
|
|
22
24
|
const options: BuildOptions = {
|
|
23
|
-
/*
|
|
25
|
+
/* Default our platform/target to NodeJS, current major version */
|
|
24
26
|
platform: 'node',
|
|
25
|
-
target: `node${process.versions['node']}`,
|
|
26
|
-
format: 'cjs',
|
|
27
|
-
outbase: absWorkingDir,
|
|
27
|
+
target: `node${process.versions['node'].split('.')[0]}`,
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/* The default format (if not specified in options) is from package.json */
|
|
30
|
+
format: this._options.format || await _moduleFormat(files.directory, run.log),
|
|
31
|
+
|
|
32
|
+
/* Output bese directory */
|
|
33
|
+
outbase: absWorkingDir,
|
|
30
34
|
|
|
31
|
-
/*
|
|
35
|
+
/* Merge in the caller's options */
|
|
32
36
|
...this._options,
|
|
33
37
|
|
|
34
38
|
/* Always override */
|
|
35
39
|
absWorkingDir,
|
|
36
40
|
entryPoints,
|
|
41
|
+
logLevel: 'silent',
|
|
37
42
|
watch: false,
|
|
38
43
|
}
|
|
39
44
|
|
|
@@ -81,7 +86,7 @@ export class ESBuild implements Plug<Files> {
|
|
|
81
86
|
assert(esbuild, 'ESBuild did not produce any result')
|
|
82
87
|
|
|
83
88
|
for (const file in esbuild.metafile.outputs) {
|
|
84
|
-
builder.
|
|
89
|
+
builder.unchecked(resolveAbsolutePath(absWorkingDir, file))
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
const result = builder.build()
|
|
@@ -126,3 +131,57 @@ declare module '../pipe.js' {
|
|
|
126
131
|
export * from './esbuild/bundle-locals.js'
|
|
127
132
|
export * from './esbuild/check-dependencies.js'
|
|
128
133
|
export * from './esbuild/fix-extensions.js'
|
|
134
|
+
|
|
135
|
+
/* ========================================================================== *
|
|
136
|
+
* DEFAULT MODULE FORMAT FROM PACKAGE.JSON *
|
|
137
|
+
* ========================================================================== */
|
|
138
|
+
|
|
139
|
+
/** Cache for directory to module format as discovered in "package.json" */
|
|
140
|
+
const _moduleFormatCache = new Map<AbsolutePath, Format>()
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Figures out the _default_ module type for a directory, looking into the
|
|
144
|
+
* `package.json`'s `type` field (either `commonjs` or `module`)
|
|
145
|
+
*/
|
|
146
|
+
async function _moduleFormat(directory: AbsolutePath, log: Logger): Promise<Format> {
|
|
147
|
+
/* Before doing anything else, check our cache */
|
|
148
|
+
const type = _moduleFormatCache.get(directory)
|
|
149
|
+
if (type) return type
|
|
150
|
+
|
|
151
|
+
/* Try to read the "package.json" file from this directory */
|
|
152
|
+
const file = resolveAbsolutePath(directory, 'package.json')
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
const json = await readFile(file, 'utf-8')
|
|
156
|
+
const data = JSON.parse(json)
|
|
157
|
+
|
|
158
|
+
/* Be liberal in what you accept? Default to CommonJS if none found */
|
|
159
|
+
const type = data.type === 'module' ? 'esm' : 'cjs'
|
|
160
|
+
log.debug(`File "${file}" defines module type as "${data.type}" (${type})`)
|
|
161
|
+
_moduleFormatCache.set(directory, type)
|
|
162
|
+
return type
|
|
163
|
+
} catch (cause: any) {
|
|
164
|
+
/* We _accept_ a couple of errors, file not found, or file is directory */
|
|
165
|
+
if ((cause.code !== 'ENOENT') && (cause.code !== 'EISDIR')) throw cause
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/*
|
|
169
|
+
* We couldn't find "package.json" in this directory, go up if we can!
|
|
170
|
+
*
|
|
171
|
+
* That said, if we are at a directory called "node_modules" we stop here,
|
|
172
|
+
* as we don't want to inherit the default type from an _importing_ package,
|
|
173
|
+
* into the _imported_ one...
|
|
174
|
+
*/
|
|
175
|
+
const name = basename(directory)
|
|
176
|
+
const parent = getAbsoluteParent(directory)
|
|
177
|
+
|
|
178
|
+
if ((name === 'node_modules') || (parent === directory)) {
|
|
179
|
+
_moduleFormatCache.set(directory, 'cjs') // default
|
|
180
|
+
return 'cjs'
|
|
181
|
+
} else {
|
|
182
|
+
/* We also cache back, on the way up */
|
|
183
|
+
const type = await _moduleFormat(parent, log)
|
|
184
|
+
_moduleFormatCache.set(directory, type)
|
|
185
|
+
return type
|
|
186
|
+
}
|
|
187
|
+
}
|
package/src/plugs/filter.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Files } from '../files.js'
|
|
2
|
-
import { log } from '../log.js'
|
|
3
2
|
import { resolveRelativeChildPath } from '../paths.js'
|
|
4
3
|
import { install, Plug } from '../pipe.js'
|
|
5
4
|
import { Run } from '../run.js'
|
|
@@ -31,12 +30,12 @@ export class Filter implements Plug<Files> {
|
|
|
31
30
|
|
|
32
31
|
for (const file of files.absolutePaths()) {
|
|
33
32
|
const relative = resolveRelativeChildPath(builder.directory, file)
|
|
34
|
-
if (relative && matcher(relative)) builder.
|
|
33
|
+
if (relative && matcher(relative)) builder.unchecked(relative)
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
const result = builder.build()
|
|
38
37
|
const discarded = files.length - result.length
|
|
39
|
-
log.debug('Filtered', result.length, 'files (discarded', discarded, 'files)')
|
|
38
|
+
run.log.debug('Filtered', result.length, 'files (discarded', discarded, 'files)')
|
|
40
39
|
|
|
41
40
|
return result
|
|
42
41
|
}
|
package/src/plugs/rmf.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Files } from '../files.js'
|
|
2
|
+
import { $gry, $p } from '../log.js'
|
|
3
|
+
import { install, Plug } from '../pipe.js'
|
|
4
|
+
import { Run } from '../run.js'
|
|
5
|
+
import { rm } from '../utils/asyncfs.js'
|
|
6
|
+
|
|
7
|
+
/** Remove some files using globs. */
|
|
8
|
+
export class Rmf implements Plug<undefined> {
|
|
9
|
+
private readonly _dryRun: boolean
|
|
10
|
+
|
|
11
|
+
constructor(dryRun?: boolean) {
|
|
12
|
+
this._dryRun = !! dryRun
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async pipe(files: Files, run: Run): Promise<undefined> {
|
|
16
|
+
if (this._dryRun) {
|
|
17
|
+
for (const file of files.absolutePaths()) {
|
|
18
|
+
run.log.notice('Not removing file', $p(file), $gry('(dry-run)'))
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
for (const file of files.absolutePaths()) {
|
|
22
|
+
run.log.notice('Removing file', $p(file))
|
|
23
|
+
await rm(file)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return undefined
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ========================================================================== *
|
|
32
|
+
* INSTALLATION *
|
|
33
|
+
* ========================================================================== */
|
|
34
|
+
|
|
35
|
+
install('rmf', Rmf)
|
|
36
|
+
|
|
37
|
+
declare module '../pipe.js' {
|
|
38
|
+
export interface Pipe {
|
|
39
|
+
/** Remove all {@link Files} piped in. */
|
|
40
|
+
rmf: PipeExtension<typeof Rmf>
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/plugs.ts
CHANGED
package/src/run.ts
CHANGED
|
@@ -51,8 +51,8 @@ export interface Run {
|
|
|
51
51
|
* Resolve a path in the context of this {@link Run}.
|
|
52
52
|
*
|
|
53
53
|
* If the path starts with `@...` it is considered to be relative to the
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* _directory containing the build file where the task was defined_, otherwise
|
|
55
|
+
* it will be relative to the {@link process.cwd | current working directory}.
|
|
56
56
|
*/
|
|
57
57
|
resolve(...paths: string[]): AbsolutePath
|
|
58
58
|
|
|
@@ -116,12 +116,12 @@ export class RunImpl implements Run {
|
|
|
116
116
|
if (path.startsWith('@')) {
|
|
117
117
|
const relative = path.substring(1)
|
|
118
118
|
assert(! isAbsolutePath(relative), `Path component of "${path}" is absolute`)
|
|
119
|
-
return resolveAbsolutePath(
|
|
119
|
+
return resolveAbsolutePath(this.buildDir, relative)
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
if (isAbsolutePath(path)) return path
|
|
123
123
|
|
|
124
|
-
return resolveAbsolutePath(
|
|
124
|
+
return resolveAbsolutePath(getCurrentWorkingDirectory(), path)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
files(files: Files): FilesBuilder
|
|
@@ -142,7 +142,7 @@ export class RunImpl implements Run {
|
|
|
142
142
|
const promise = Promise.resolve().then(async () => {
|
|
143
143
|
const builder = this.files(directory || '.')
|
|
144
144
|
for await (const file of walk(builder.directory, [ glob, ...params ], options)) {
|
|
145
|
-
builder.
|
|
145
|
+
builder.unchecked(file)
|
|
146
146
|
}
|
|
147
147
|
return builder.build()
|
|
148
148
|
})
|