@plugjs/plug 0.0.6 → 0.0.9
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/build.cjs.map +1 -1
- package/dist/build.mjs.map +1 -1
- package/dist/files.cjs +5 -8
- package/dist/files.cjs.map +1 -1
- package/dist/files.mjs +5 -8
- package/dist/files.mjs.map +1 -1
- package/dist/paths.cjs +1 -1
- package/dist/paths.cjs.map +1 -1
- package/dist/paths.mjs +2 -2
- package/dist/paths.mjs.map +1 -1
- package/dist/plugs/copy.cjs +6 -12
- package/dist/plugs/copy.cjs.map +2 -2
- package/dist/plugs/copy.mjs +6 -6
- package/dist/plugs/copy.mjs.map +1 -1
- package/dist/plugs/esbuild.cjs +0 -1
- package/dist/plugs/esbuild.cjs.map +1 -1
- package/dist/plugs/esbuild.mjs +0 -1
- package/dist/plugs/esbuild.mjs.map +1 -1
- package/dist/plugs/tsc/options.cjs +1 -2
- package/dist/plugs/tsc/options.cjs.map +1 -1
- package/dist/plugs/tsc/options.mjs +1 -2
- package/dist/plugs/tsc/options.mjs.map +1 -1
- package/dist/plugs/tsc/runner.cjs +31 -17
- package/dist/plugs/tsc/runner.cjs.map +1 -1
- package/dist/plugs/tsc/runner.mjs +32 -18
- package/dist/plugs/tsc/runner.mjs.map +1 -1
- package/dist/run.cjs +3 -2
- package/dist/run.cjs.map +1 -1
- package/dist/run.mjs +4 -3
- package/dist/run.mjs.map +1 -1
- package/dist/utils/asyncfs.cjs +4 -8
- package/dist/utils/asyncfs.cjs.map +2 -2
- package/dist/utils/asyncfs.mjs +3 -7
- package/dist/utils/asyncfs.mjs.map +2 -2
- package/dist/utils/walk.cjs +7 -4
- package/dist/utils/walk.cjs.map +1 -1
- package/dist/utils/walk.mjs +8 -5
- package/dist/utils/walk.mjs.map +1 -1
- package/package.json +4 -4
- package/src/files.ts +9 -12
- package/src/paths.ts +2 -2
- package/src/plugs/copy.ts +6 -7
- package/src/plugs/esbuild.ts +0 -1
- package/src/plugs/tsc/options.ts +3 -3
- package/src/plugs/tsc/runner.ts +52 -28
- package/src/run.ts +4 -3
- package/src/utils/asyncfs.ts +9 -8
- package/src/utils/walk.ts +10 -5
- package/types/build.d.ts +1 -1
- package/types/files.d.ts +1 -5
- package/types/plugs/esbuild.d.ts +0 -1
- package/types/plugs/tsc/options.d.ts +1 -1
- package/types/utils/asyncfs.d.ts +2 -5
- package/dist/plugs/esbuild/check-dependencies.cjs +0 -140
- package/dist/plugs/esbuild/check-dependencies.cjs.map +0 -6
- package/dist/plugs/esbuild/check-dependencies.mjs +0 -115
- package/dist/plugs/esbuild/check-dependencies.mjs.map +0 -6
- package/src/plugs/esbuild/check-dependencies.ts +0 -158
- package/types/plugs/esbuild/check-dependencies.d.ts +0 -12
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { failure } from "../../assert.mjs";
|
|
4
4
|
import { $p, log } from "../../log.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { isFile } from "../../paths.mjs";
|
|
6
6
|
import { parseOptions } from "../../utils/options.mjs";
|
|
7
7
|
import { TypeScriptHost } from "./compiler.mjs";
|
|
8
8
|
import { getCompilerOptions } from "./options.mjs";
|
|
@@ -16,35 +16,49 @@ var Tsc = class {
|
|
|
16
16
|
this._options = options;
|
|
17
17
|
}
|
|
18
18
|
async pipe(files, run) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const baseDir = run.resolve(".");
|
|
20
|
+
const report = run.report("TypeScript Report");
|
|
21
|
+
const overrides = { ...this._options };
|
|
22
|
+
const sourcesConfig = isFile(files.directory, "tsconfig.json");
|
|
23
|
+
const tsconfig = this._tsconfig ? run.resolve(this._tsconfig) : sourcesConfig || isFile(run.resolve("tsconfig.json"));
|
|
24
|
+
let rootDir;
|
|
25
|
+
if (overrides.rootDir) {
|
|
26
|
+
rootDir = overrides.rootDir = run.resolve(overrides.rootDir);
|
|
27
|
+
} else {
|
|
28
|
+
rootDir = overrides.rootDir = files.directory;
|
|
29
|
+
}
|
|
30
|
+
let outDir;
|
|
31
|
+
if (overrides.outDir) {
|
|
32
|
+
outDir = overrides.outDir = run.resolve(overrides.outDir);
|
|
33
|
+
} else {
|
|
34
|
+
outDir = overrides.outDir = rootDir;
|
|
35
|
+
}
|
|
36
|
+
if (overrides.rootDirs) {
|
|
37
|
+
overrides.rootDirs = overrides.rootDirs.map((dir) => run.resolve(dir));
|
|
38
|
+
}
|
|
39
|
+
if (overrides.baseUrl)
|
|
40
|
+
overrides.baseUrl = run.resolve(overrides.baseUrl);
|
|
24
41
|
const { errors, options } = await getCompilerOptions(
|
|
25
42
|
tsconfig,
|
|
26
43
|
overrides,
|
|
27
|
-
run.buildFile
|
|
44
|
+
run.buildFile,
|
|
45
|
+
baseDir
|
|
28
46
|
);
|
|
29
|
-
|
|
30
|
-
updateReport(report, errors, getCurrentWorkingDirectory());
|
|
47
|
+
updateReport(report, errors, baseDir);
|
|
31
48
|
if (report.errors)
|
|
32
49
|
report.done(true);
|
|
33
|
-
const { rootDir, outDir } = options;
|
|
34
|
-
const root = rootDir ? run.resolve(rootDir) : files.directory;
|
|
35
|
-
const out = outDir ? run.resolve(outDir) : root;
|
|
36
|
-
const host = new TypeScriptHost(root);
|
|
37
50
|
const paths = [...files.absolutePaths()];
|
|
38
51
|
for (const path of paths)
|
|
39
52
|
log.trace(`Compiling "${$p(path)}"`);
|
|
40
53
|
log.info("Compiling", paths.length, "files");
|
|
41
54
|
log.debug("Compliation options", options);
|
|
55
|
+
const host = new TypeScriptHost(rootDir);
|
|
42
56
|
const program = ts.createProgram(paths, options, host, void 0, errors);
|
|
43
57
|
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
44
|
-
updateReport(report, diagnostics,
|
|
58
|
+
updateReport(report, diagnostics, rootDir);
|
|
45
59
|
if (report.errors)
|
|
46
60
|
report.done(true);
|
|
47
|
-
const builder = run.files(
|
|
61
|
+
const builder = run.files(outDir);
|
|
48
62
|
const promises = [];
|
|
49
63
|
const result = program.emit(void 0, (fileName, code) => {
|
|
50
64
|
promises.push(builder.write(fileName, code).then((file) => {
|
|
@@ -54,13 +68,13 @@ var Tsc = class {
|
|
|
54
68
|
throw failure();
|
|
55
69
|
}));
|
|
56
70
|
});
|
|
57
|
-
updateReport(report, result.diagnostics, root);
|
|
58
|
-
if (report.errors)
|
|
59
|
-
report.done(true);
|
|
60
71
|
const settlements = await Promise.allSettled(promises);
|
|
61
72
|
const failures = settlements.reduce((failures2, s) => failures2 + s.status === "rejected" ? 1 : 0, 0);
|
|
62
73
|
if (failures)
|
|
63
74
|
throw failure();
|
|
75
|
+
updateReport(report, result.diagnostics, rootDir);
|
|
76
|
+
if (report.errors)
|
|
77
|
+
report.done(true);
|
|
64
78
|
const outputs = builder.build();
|
|
65
79
|
log.info("TSC produced", outputs.length, "files into", $p(outputs.directory));
|
|
66
80
|
return outputs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugs/tsc/runner.ts"],
|
|
4
|
-
"mappings": ";AAAA,OAAO,QAAQ;AAEf,SAAS,eAAe;AAExB,SAAS,IAAI,WAAW;AACxB,
|
|
4
|
+
"mappings": ";AAAA,OAAO,QAAQ;AAEf,SAAS,eAAe;AAExB,SAAS,IAAI,WAAW;AACxB,SAAuB,cAAc;AAGrC,SAAS,oBAAkC;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAM7B,IAAqB,MAArB,MAAgD;AAAA,EAC7B;AAAA,EACA;AAAA,EAOjB,eAAe,MAAwC;AACrD,UAAM,EAAE,QAAQ,CAAE,QAAS,GAAG,QAAQ,IAAI,aAAa,MAAM,CAAC,CAAC;AAC/D,SAAK,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,MAAM,KAAK,OAAc,KAA0B;AACjD,UA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B,OAAO;AAGpD,iBAAa,QAAQ,aAAa,OAAO;AACzC,QAAI,OAAO;AAAQ,aAAO,KAAK,IAAI;AAGnC,UAAM,UAAU,IAAI,MAAM,MAAM;AAChC,UAAM,WAA4B,CAAC;AACnC,UAAM,SAAS,QAAQ,KAAK,QAAW,CAAC,UAAU,SAAS;AACzD,eAAS,KAAK,QAAQ,MAAM,UAAU,IAAI,EAAE,KAAK,CAAC,SAAS;AACzD,YAAI,MAAM,WAAW,GAAG,IAAI,CAAC;AAAA,MAC/B,CAAC,EAAE,MAAM,CAAC,UAAU;AAClB,YAAI,IAAI,MAAM,oBAAoB,UAAU,KAAK;AACjD,cAAM,QAAQ;AAAA,MAChB,CAAC,CAAC;AAAA,IACJ,CAAC;AAGD,UAAM,cAAc,MAAM,QAAQ,WAAW,QAAQ;AACrD,UAAM,WAAW,YACZ,OAAO,CAACA,WAAU,MAAMA,YAAW,EAAE,WAAW,aAAa,IAAI,GAAG,CAAC;AAC1E,QAAI;AAAU,YAAM,QAAQ;AAG5B,iBAAa,QAAQ,OAAO,aAAa,OAAO;AAChD,QAAI,OAAO;AAAQ,aAAO,KAAK,IAAI;AAGnC,UAAM,UAAU,QAAQ,MAAM;AAC9B,QAAI,KAAK,gBAAgB,QAAQ,QAAQ,cAAc,GAAG,QAAQ,SAAS,CAAC;AAC5E,WAAO;AAAA,EACT;AACF;",
|
|
5
5
|
"names": ["failures"]
|
|
6
6
|
}
|
package/dist/run.cjs
CHANGED
|
@@ -53,8 +53,9 @@ var RunImpl = class {
|
|
|
53
53
|
if (!path)
|
|
54
54
|
return this.buildDir;
|
|
55
55
|
if (path.startsWith("@")) {
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const components = (0, import_node_path.normalize)(path.substring(1)).split(import_node_path.sep);
|
|
57
|
+
const relative = (0, import_node_path.join)(...components);
|
|
58
|
+
(0, import_assert.assert)(!(0, import_paths.isAbsolutePath)(relative), `Path "${path.substring(1)}" is absolute`);
|
|
58
59
|
return (0, import_paths.resolveAbsolutePath)(this.buildDir, relative);
|
|
59
60
|
}
|
|
60
61
|
if ((0, import_paths.isAbsolutePath)(path))
|
package/dist/run.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/run.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqC;AACrC,oBAAuB;AACvB,mBAAoC;AACpC,iBAAwF;AACxF,mBAA8F;AAC9F,kBAA+B;AAC/B,qBAA2C;AAC3C,kBAAkC;AAgF3B,IAAM,UAAN,MAA6B;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIT,YAAY,EAAE,UAAU,UAAU,WAAW,IAAI,GAA2B;AAC1E,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,MAAM,WAAO,sBAAU,QAAQ;AAAA,EACtC;AAAA,EAGA,YAAY,OAA6B;AACvC,SAAK,IAAI,YAAQ,2BAAe,KAAK;AAAA,EACvC;AAAA,EAEA,OAAO,OAAuB;AAC5B,eAAO,yBAAa,OAAO,KAAK,QAAQ;AAAA,EAC1C;AAAA,EAEA,WAAW,OAA+B;AACxC,UAAM,WAAO,uBAAK,GAAG,KAAK;AAC1B,QAAI,CAAE;AAAM,aAAO,KAAK;AAExB,QAAI,KAAK,WAAW,GAAG,GAAG;AACxB,YAAM,iBAAa,4BAAU,KAAK,UAAU,CAAC,CAAC,EAAE,MAAM,oBAAG;AACzD,YAAM,eAAW,uBAAK,GAAG,UAAU;AACnC,gCAAO,KAAE,6BAAe,QAAQ,GAAG,SAAS,KAAK,UAAU,CAAC,gBAAgB;AAC5E,iBAAO,kCAAoB,KAAK,UAAU,QAAQ;AAAA,IACpD;AAEA,YAAI,6BAAe,IAAI;AAAG,aAAO;AAEjC,eAAO,sCAAoB,yCAA2B,GAAG,IAAI;AAAA,EAC/D;AAAA,EAIA,MAAM,UAAsC,OAA+B;AACzE,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,mBAAM,QAAQ,KAAK,QAAQ,OAAO,GAAG,KAAK,CAAC;AAAA,IACpD,WAAW,OAAO;AAChB,aAAO,mBAAM,QAAQ,KAAK;AAAA,IAC5B,OAAO;AACL,aAAO,mBAAM,QAAQ,KAAK,QAAQ,CAAC;AAAA,IACrC;AAAA,EACF;AAAA,EAEA,KAAK,SAAiB,MAAwD;AAC5E,UAAM,EAAE,QAAQ,SAAS,EAAE,cAAc,QAAQ,EAAE,QAAI,6BAAa,MAAM,CAAC,CAAC;AAE5E,UAAM,UAAU,QAAQ,QAAQ,EAAE,KAAK,YAAY;AACjD,YAAM,UAAU,KAAK,MAAM,aAAa,GAAG;AAC3C,uBAAiB,YAAQ,kBAAK,QAAQ,WAAW,CAAE,MAAM,GAAG,MAAO,GAAG,OAAO,GAAG;AAC9E,gBAAQ,UAAU,IAAI;AAAA,MACxB;AACA,aAAO,QAAQ,MAAM;AAAA,IACvB,CAAC;AAED,WAAO,KAAK,KAAK,OAAO;AAAA,EAC1B;AAAA,EAEA,KAAK,OAAsD;AACzD,WAAO,IAAI,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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// run.ts
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { join, normalize, sep } from "node:path";
|
|
3
3
|
import { assert } from "./assert.mjs";
|
|
4
4
|
import { Files } from "./files.mjs";
|
|
5
5
|
import { createReport, getLevelNumber, getLogger } from "./log.mjs";
|
|
@@ -29,8 +29,9 @@ var RunImpl = class {
|
|
|
29
29
|
if (!path)
|
|
30
30
|
return this.buildDir;
|
|
31
31
|
if (path.startsWith("@")) {
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const components = normalize(path.substring(1)).split(sep);
|
|
33
|
+
const relative = join(...components);
|
|
34
|
+
assert(!isAbsolutePath(relative), `Path "${path.substring(1)}" is absolute`);
|
|
34
35
|
return resolveAbsolutePath(this.buildDir, relative);
|
|
35
36
|
}
|
|
36
37
|
if (isAbsolutePath(path))
|
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,
|
|
4
|
+
"mappings": ";AAAA,SAAS,MAAM,WAAW,WAAW;AACrC,SAAS,cAAc;AACvB,SAAS,aAA2B;AACpC,SAAS,cAAc,gBAAgB,iBAAiD;AACxF,SAAuB,4BAA4B,gBAAgB,2BAA2B;AAC9F,SAAe,gBAAgB;AAC/B,SAAuB,oBAAoB;AAC3C,SAAS,YAAyB;AAgF3B,IAAM,UAAN,MAA6B;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIT,YAAY,EAAE,UAAU,UAAU,WAAW,IAAI,GAA2B;AAC1E,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,MAAM,OAAO,UAAU,QAAQ;AAAA,EACtC;AAAA,EAGA,YAAY,OAA6B;AACvC,SAAK,IAAI,QAAQ,eAAe,KAAK;AAAA,EACvC;AAAA,EAEA,OAAO,OAAuB;AAC5B,WAAO,aAAa,OAAO,KAAK,QAAQ;AAAA,EAC1C;AAAA,EAEA,WAAW,OAA+B;AACxC,UAAM,OAAO,KAAK,GAAG,KAAK;AAC1B,QAAI,CAAE;AAAM,aAAO,KAAK;AAExB,QAAI,KAAK,WAAW,GAAG,GAAG;AACxB,YAAM,aAAa,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export(asyncfs_exports, {
|
|
|
30
30
|
appendFile: () => appendFile,
|
|
31
31
|
chmod: () => chmod,
|
|
32
32
|
chown: () => chown,
|
|
33
|
-
constants: () => import_node_fs2.constants,
|
|
34
33
|
copyFile: () => copyFile,
|
|
35
34
|
cp: () => cp,
|
|
36
|
-
|
|
35
|
+
fsConstants: () => fsConstants,
|
|
37
36
|
lchmod: () => lchmod,
|
|
38
37
|
lchown: () => lchown,
|
|
39
38
|
link: () => link,
|
|
@@ -61,7 +60,6 @@ __export(asyncfs_exports, {
|
|
|
61
60
|
module.exports = __toCommonJS(asyncfs_exports);
|
|
62
61
|
var import_node_fs = require("node:fs");
|
|
63
62
|
var import_promises = __toESM(require("node:fs/promises"));
|
|
64
|
-
var import_node_fs2 = require("node:fs");
|
|
65
63
|
var fs = Object.entries(import_promises.default).reduce((fs2, [key, val]) => {
|
|
66
64
|
if (typeof val === "function") {
|
|
67
65
|
const f = function(...args) {
|
|
@@ -72,12 +70,9 @@ var fs = Object.entries(import_promises.default).reduce((fs2, [key, val]) => {
|
|
|
72
70
|
};
|
|
73
71
|
Object.defineProperty(f, "name", { value: key });
|
|
74
72
|
fs2[key] = f;
|
|
75
|
-
} else {
|
|
76
|
-
fs2[key] = val;
|
|
77
73
|
}
|
|
78
74
|
return fs2;
|
|
79
|
-
}, {
|
|
80
|
-
var asyncfs_default = fs;
|
|
75
|
+
}, {});
|
|
81
76
|
var access = fs.access;
|
|
82
77
|
var copyFile = fs.copyFile;
|
|
83
78
|
var cp = fs.cp;
|
|
@@ -107,15 +102,16 @@ var writeFile = fs.writeFile;
|
|
|
107
102
|
var appendFile = fs.appendFile;
|
|
108
103
|
var readFile = fs.readFile;
|
|
109
104
|
var watch = fs.watch;
|
|
105
|
+
var fsConstants = import_node_fs.constants;
|
|
110
106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
107
|
0 && (module.exports = {
|
|
112
108
|
access,
|
|
113
109
|
appendFile,
|
|
114
110
|
chmod,
|
|
115
111
|
ch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,IAAM,SAAS,GAAG;AAClB,IAAM,WAAW,GAAG;AACpB,IAAM,KAAK,GAAG;AACd,IAAM,OAAO,GAAG;AAChB,IAAM,UAAU,GAAG;AACnB,IAAM,SAAS,GAAG;AAClB,IAAM,WAAW,GAAG;AACpB,IAAM,KAAK,GAAG;AACd,IAAM,QAAQ,GAAG;AACjB,IAAM,QAAQ,GAAG;AACjB,IAAM,UAAU,GAAG;AACnB,IAAM,WAAW,GAAG;AACpB,IAAM,UAAU,GAAG;AACnB,IAAM,QAAQ,GAAG;AACjB,IAAM,OAAO,GAAG;AAChB,IAAM,OAAO,GAAG;AAChB,IAAM,SAAS,GAAG;AAClB,IAAM,QAAQ,GAAG;AACjB,IAAM,SAAS,GAAG;AAClB,IAAM,SAAS,GAAG;AAClB,IAAM,QAAQ,GAAG;AACjB,IAAM,SAAS,GAAG;AAClB,IAAM,UAAU,GAAG;AACnB,IAAM,WAAW,GAAG;AACpB,IAAM,UAAU,GAAG;AACnB,IAAM,YAAY,GAAG;AACrB,IAAM,aAAa,GAAG;AACtB,IAAM,WAAW,GAAG;AACpB,IAAM,QAAQ,GAAG;AAGjB,IAAM,cAAc;",
|
|
5
|
+
"names": ["fsp", "fs"]
|
|
6
6
|
}
|
package/dist/utils/asyncfs.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// utils/asyncfs.ts
|
|
2
2
|
import { constants } from "node:fs";
|
|
3
3
|
import fsp from "node:fs/promises";
|
|
4
|
-
import { constants as constants2 } from "node:fs";
|
|
5
4
|
var fs = Object.entries(fsp).reduce((fs2, [key, val]) => {
|
|
6
5
|
if (typeof val === "function") {
|
|
7
6
|
const f = function(...args) {
|
|
@@ -12,12 +11,9 @@ var fs = Object.entries(fsp).reduce((fs2, [key, val]) => {
|
|
|
12
11
|
};
|
|
13
12
|
Object.defineProperty(f, "name", { value: key });
|
|
14
13
|
fs2[key] = f;
|
|
15
|
-
} else {
|
|
16
|
-
fs2[key] = val;
|
|
17
14
|
}
|
|
18
15
|
return fs2;
|
|
19
|
-
}, {
|
|
20
|
-
var asyncfs_default = fs;
|
|
16
|
+
}, {});
|
|
21
17
|
var access = fs.access;
|
|
22
18
|
var copyFile = fs.copyFile;
|
|
23
19
|
var cp = fs.cp;
|
|
@@ -47,15 +43,15 @@ var writeFile = fs.writeFile;
|
|
|
47
43
|
var appendFile = fs.appendFile;
|
|
48
44
|
var readFile = fs.readFile;
|
|
49
45
|
var watch = fs.watch;
|
|
46
|
+
var fsConstants = constants;
|
|
50
47
|
export {
|
|
51
48
|
access,
|
|
52
49
|
appendFile,
|
|
53
50
|
chmod,
|
|
54
51
|
chown,
|
|
55
|
-
constants2 as constants,
|
|
56
52
|
copyFile,
|
|
57
53
|
cp,
|
|
58
|
-
|
|
54
|
+
fsConstants,
|
|
59
55
|
lchmod,
|
|
60
56
|
lchown,
|
|
61
57
|
link,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/asyncfs.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,OAAO,SAAS;
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,OAAO,SAAS;AA0BhB,IAAM,KAAK,OAAO,QAAQ,GAAU,EAAE,OAAO,CAACA,KAAI,CAAE,KAAK,GAAI,MAAM;AACjE,MAAI,OAAO,QAAQ,YAAY;AAE7B,UAAM,IAAI,YAAY,MAAkB;AAEtC,aAAO,IAAI,MAAM,KAAK,IAAI,EAAE,MAAM,CAAC,UAAe;AAEhD,cAAM,kBAAkB,KAAK;AAC7B,cAAM;AAAA,MACR,CAAC;AAAA,IACH;AAGA,WAAO,eAAe,GAAG,QAAQ,EAAE,OAAO,IAAI,CAAC;AAE/C,IAAAA,IAAG,OAAO;AAAA,EACZ;AAGA,SAAOA;AACT,GAAG,CAAC,CAAQ;AAIL,IAAM,SAAS,GAAG;AAClB,IAAM,WAAW,GAAG;AACpB,IAAM,KAAK,GAAG;AACd,IAAM,OAAO,GAAG;AAChB,IAAM,UAAU,GAAG;AACnB,IAAM,SAAS,GAAG;AAClB,IAAM,WAAW,GAAG;AACpB,IAAM,KAAK,GAAG;AACd,IAAM,QAAQ,GAAG;AACjB,IAAM,QAAQ,GAAG;AACjB,IAAM,UAAU,GAAG;AACnB,IAAM,WAAW,GAAG;AACpB,IAAM,UAAU,GAAG;AACnB,IAAM,QAAQ,GAAG;AACjB,IAAM,OAAO,GAAG;AAChB,IAAM,OAAO,GAAG;AAChB,IAAM,SAAS,GAAG;AAClB,IAAM,QAAQ,GAAG;AACjB,IAAM,SAAS,GAAG;AAClB,IAAM,SAAS,GAAG;AAClB,IAAM,QAAQ,GAAG;AACjB,IAAM,SAAS,GAAG;AAClB,IAAM,UAAU,GAAG;AACnB,IAAM,WAAW,GAAG;AACpB,IAAM,UAAU,GAAG;AACnB,IAAM,YAAY,GAAG;AACrB,IAAM,aAAa,GAAG;AACtB,IAAM,WAAW,GAAG;AACpB,IAAM,QAAQ,GAAG;AAGjB,IAAM,cAAc;",
|
|
5
|
+
"names": ["fs"]
|
|
6
6
|
}
|
package/dist/utils/walk.cjs
CHANGED
|
@@ -71,13 +71,16 @@ async function* walker(args) {
|
|
|
71
71
|
if (!onDirectory(dir))
|
|
72
72
|
return;
|
|
73
73
|
import_log.log.trace("Reading directory", (0, import_log.$p)(dir));
|
|
74
|
-
|
|
74
|
+
let dirents;
|
|
75
|
+
try {
|
|
76
|
+
dirents = await (0, import_asyncfs.opendir)(dir);
|
|
77
|
+
} catch (error) {
|
|
75
78
|
if (error.code !== "ENOENT")
|
|
76
79
|
throw error;
|
|
77
80
|
import_log.log.warn("Directory", (0, import_log.$p)(dir), "not found");
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
for (const dirent of dirents) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for await (const dirent of dirents) {
|
|
81
84
|
const path = (0, import_node_path.join)(relative, dirent.name);
|
|
82
85
|
if (dirent.isFile() && positiveMatcher(path))
|
|
83
86
|
yield path;
|
package/dist/utils/walk.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/walk.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAA+B;AAC/B,iBAAwB;AACxB,mBAAkD;AAClD,qBAA8B;AAC9B,mBAAoC;AA8B7B,SAAS,KACZ,WACA,OACA,UAAuB,CAAC,GACU;AACpC,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,OAChB;AAAA,EACL,IAAI;AAGJ,QAAM,cAAc,CAAC,QAA+B;AAGlD,QAAI,QAAQ;AAAW,aAAO;AAC9B,UAAM,WAAO,2BAAS,GAAG;AACzB,QAAI,SAAS;AAAgB,aAAO,CAAC,CAAC;AACtC,QAAI,KAAK,WAAW,GAAG;AAAG,aAAO,CAAC,CAAC,KAAK;AACxC,WAAO;AAAA,EACT;AAGA,QAAM,sBAAkB,oBAAM,OAAO,IAAI;AAGzC,iBAAI,MAAM,yBAAqB,eAAG,SAAS,GAAG,EAAE,OAAO,QAAQ,CAAC;AAChE,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,IACV,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AACH;AAiBA,gBAAgB,OAAO,MAA2D;AAChF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAGJ,QAAM,UAAM,kCAAoB,WAAW,QAAQ;AACnD,MAAI,CAAE,YAAY,GAAG;AAAG;AACxB,iBAAI,MAAM,yBAAqB,eAAG,GAAG,CAAC;AAEtC,MAAI;AACJ,MAAI;AACF,cAAU,UAAM,wBAAQ,GAAG;AAAA,EAC7B,SAAS,OAAP;AACA,QAAI,MAAM,SAAS;AAAU,YAAM;AACnC,mBAAI,KAAK,iBAAa,eAAG,GAAG,GAAG,WAAW;AAC1C;AAAA,EACF;AAGA,mBAAiB,UAAU,SAAS;AAClC,UAAM,WAAO,uBAAK,UAAU,OAAO,IAAI;AAGvC,QAAI,OAAO,OAAO,KAAK,gBAAgB,IAAI;AAAG,YAAM;AAAA,aAG3C,OAAO,YAAY,KAAM,QAAQ,UAAW;AACnD,YAAM,WAAW,OAAO,EAAE,GAAG,MAAM,UAAU,MAAM,OAAO,QAAQ,EAAE,CAAC;AACrE,uBAAiB,SAAS;AAAU,cAAM;AAAA,IAG5C,WAAW,OAAO,eAAe,KAAK,gBAAgB;AACpD,YAAM,OAAO,UAAM,yBAAK,uBAAK,WAAW,IAAI,CAAC;AAG7C,UAAI,KAAK,OAAO,KAAK,gBAAgB,IAAI;AAAG,cAAM;AAAA,eAGzC,KAAK,YAAY,KAAM,QAAQ,UAAW;AACjD,cAAM,WAAW,OAAO,EAAE,GAAG,MAAM,UAAU,MAAM,OAAO,QAAQ,EAAE,CAAC;AACrE,yBAAiB,SAAS;AAAU,gBAAM;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/utils/walk.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { basename, join } from "node:path";
|
|
3
3
|
import { $p, log } from "../log.mjs";
|
|
4
4
|
import { resolveAbsolutePath } from "../paths.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { opendir, stat } from "./asyncfs.mjs";
|
|
6
6
|
import { match } from "./match.mjs";
|
|
7
7
|
function walk(directory, globs, options = {}) {
|
|
8
8
|
const {
|
|
@@ -47,13 +47,16 @@ async function* walker(args) {
|
|
|
47
47
|
if (!onDirectory(dir))
|
|
48
48
|
return;
|
|
49
49
|
log.trace("Reading directory", $p(dir));
|
|
50
|
-
|
|
50
|
+
let dirents;
|
|
51
|
+
try {
|
|
52
|
+
dirents = await opendir(dir);
|
|
53
|
+
} catch (error) {
|
|
51
54
|
if (error.code !== "ENOENT")
|
|
52
55
|
throw error;
|
|
53
56
|
log.warn("Directory", $p(dir), "not found");
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
for (const dirent of dirents) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
for await (const dirent of dirents) {
|
|
57
60
|
const path = join(relative, dirent.name);
|
|
58
61
|
if (dirent.isFile() && positiveMatcher(path))
|
|
59
62
|
yield path;
|
package/dist/utils/walk.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/walk.ts"],
|
|
4
|
-
"mappings": ";
|
|
4
|
+
"mappings": ";AACA,SAAS,UAAU,YAAY;AAC/B,SAAS,IAAI,WAAW;AACxB,SAAuB,2BAA2B;AAClD,SAAS,SAAS,YAAY;AAC9B,SAAS,aAA2B;AA8B7B,SAAS,KACZ,WACA,OACA,UAAuB,CAAC,GACU;AACpC,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,OAChB;AAAA,EACL,IAAI;AAGJ,QAAM,cAAc,CAAC,QAA+B;AAGlD,QAAI,QAAQ;AAAW,aAAO;AAC9B,UAAM,OAAO,SAAS,GAAG;AACzB,QAAI,SAAS;AAAgB,aAAO,CAAC,CAAC;AACtC,QAAI,KAAK,WAAW,GAAG;AAAG,aAAO,CAAC,CAAC,KAAK;AACxC,WAAO;AAAA,EACT;AAGA,QAAM,kBAAkB,MAAM,OAAO,IAAI;AAGzC,MAAI,MAAM,qBAAqB,GAAG,SAAS,GAAG,EAAE,OAA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",
|
|
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.9",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"bootstrap": "./bootstrap.sh",
|
|
25
|
-
"build": "
|
|
25
|
+
"build": "./runme.sh",
|
|
26
26
|
"dev": "npx nodemon -e .ts -w ./test -w ./src -x ./runme.sh"
|
|
27
27
|
},
|
|
28
28
|
"author": "",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@babel/parser": "^7.18.11",
|
|
32
32
|
"@babel/types": "^7.18.10",
|
|
33
33
|
"@plugjs/cov8-html": "^0.0.1",
|
|
34
|
+
"@types/node": "<17",
|
|
34
35
|
"diff": "^5.1.0",
|
|
35
36
|
"esbuild": "^0.15.5",
|
|
36
37
|
"eslint": "^8.22.0",
|
|
@@ -43,10 +44,9 @@
|
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/chai": "^4.3.3",
|
|
45
46
|
"@types/diff": "^5.0.2",
|
|
46
|
-
"@types/eslint": "^8.4.
|
|
47
|
+
"@types/eslint": "^8.4.6",
|
|
47
48
|
"@types/mocha": "^9.1.1",
|
|
48
49
|
"@types/ms": "^0.7.31",
|
|
49
|
-
"@types/node": "<17",
|
|
50
50
|
"@types/picomatch": "^2.3.0",
|
|
51
51
|
"@types/yargs-parser": "^21.0.0",
|
|
52
52
|
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
package/src/files.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { inspect } from 'node:util'
|
|
2
1
|
import { assert } from './assert.js'
|
|
3
2
|
import { AbsolutePath, assertRelativeChildPath, getAbsoluteParent, isFile, resolveAbsolutePath } from './paths.js'
|
|
4
3
|
import { mkdir, writeFile } from './utils/asyncfs.js'
|
|
@@ -27,7 +26,7 @@ export interface FilesBuilder {
|
|
|
27
26
|
merge(...files: Files[]): this
|
|
28
27
|
|
|
29
28
|
/** Write a file and add it to the {@link Files} instance being built */
|
|
30
|
-
write(file: string, content: string |
|
|
29
|
+
write(file: string, content: string | Uint8Array): Promise<AbsolutePath>
|
|
31
30
|
|
|
32
31
|
/** Build and return a {@link Files} instance */
|
|
33
32
|
build(): Files
|
|
@@ -48,6 +47,13 @@ export class Files {
|
|
|
48
47
|
constructor(directory: AbsolutePath) {
|
|
49
48
|
this._directory = directory
|
|
50
49
|
this._files = []
|
|
50
|
+
|
|
51
|
+
// Nicety for "console.log" / "util.inspect"...
|
|
52
|
+
const inspect = Symbol.for('nodejs.util.inspect.custom')
|
|
53
|
+
Object.defineProperty(this, inspect, { value: () => ({
|
|
54
|
+
directory: this._directory,
|
|
55
|
+
files: [ ...this._files ],
|
|
56
|
+
}) })
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
/** Return the _directory_ where this {@link Files} is rooted */
|
|
@@ -75,15 +81,6 @@ export class Files {
|
|
|
75
81
|
for (const file of this) yield [ file, resolveAbsolutePath(this._directory, file) ]
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
/* Nicety for logging */
|
|
79
|
-
[inspect.custom](): any {
|
|
80
|
-
const self = this
|
|
81
|
-
return new class Files {
|
|
82
|
-
directory = self._directory
|
|
83
|
-
files = [ ...self._files ]
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
84
|
/** Create a new {@link FilesBuilder} creating {@link Files} instances. */
|
|
88
85
|
static builder(files: Files): FilesBuilder
|
|
89
86
|
static builder(directory: AbsolutePath): FilesBuilder
|
|
@@ -136,7 +133,7 @@ export class Files {
|
|
|
136
133
|
return this
|
|
137
134
|
},
|
|
138
135
|
|
|
139
|
-
async write(file: string, content: string |
|
|
136
|
+
async write(file: string, content: string | Uint8Array): Promise<AbsolutePath> {
|
|
140
137
|
const relative = assertRelativeChildPath(instance.directory, file)
|
|
141
138
|
const absolute = resolveAbsolutePath(instance.directory, relative)
|
|
142
139
|
const directory = getAbsoluteParent(absolute)
|
package/src/paths.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { statSync } from 'node:fs'
|
|
2
2
|
import { createRequire } from 'node:module'
|
|
3
|
-
import { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
3
|
+
import { dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path'
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
5
5
|
import { assert } from './assert.js'
|
|
6
6
|
|
|
@@ -158,7 +158,7 @@ export function commonPath(path: AbsolutePath, ...paths: string[]): AbsolutePath
|
|
|
158
158
|
// Here the first path will be split into its components
|
|
159
159
|
// on win => [ 'C:', 'Windows', 'System32' ]
|
|
160
160
|
// on unx => [ '', 'usr'
|
|
161
|
-
const components = path.split(sep)
|
|
161
|
+
const components = normalize(path).split(sep)
|
|
162
162
|
|
|
163
163
|
let length = components.length
|
|
164
164
|
for (const current of paths) {
|
package/src/plugs/copy.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import fs from '../utils/asyncfs.js'
|
|
2
|
-
|
|
3
1
|
import { assert } from '../assert.js'
|
|
4
2
|
import { Files } from '../files.js'
|
|
5
3
|
import { $p } from '../log.js'
|
|
6
4
|
import { assertAbsolutePath, getAbsoluteParent, resolveAbsolutePath } from '../paths.js'
|
|
7
5
|
import { install, Plug } from '../pipe.js'
|
|
8
6
|
import { Run } from '../run.js'
|
|
7
|
+
import { chmod, copyFile, fsConstants, mkdir } from '../utils/asyncfs.js'
|
|
9
8
|
|
|
10
9
|
/** Options for copying files */
|
|
11
10
|
export interface CopyOptions {
|
|
@@ -30,7 +29,7 @@ export class Copy implements Plug<Files> {
|
|
|
30
29
|
async pipe(files: Files, run: Run): Promise<Files> {
|
|
31
30
|
/* Destructure our options with some defaults and compute write flags */
|
|
32
31
|
const { mode, dirMode, overwrite, rename = (s): string => s } = this._options
|
|
33
|
-
const flags = overwrite ?
|
|
32
|
+
const flags = overwrite ? fsConstants.COPYFILE_EXCL : 0
|
|
34
33
|
const dmode = parseMode(dirMode)
|
|
35
34
|
const fmode = parseMode(mode)
|
|
36
35
|
|
|
@@ -51,26 +50,26 @@ export class Copy implements Plug<Files> {
|
|
|
51
50
|
|
|
52
51
|
/* Create the parent directory, recursively */
|
|
53
52
|
const directory = getAbsoluteParent(target)
|
|
54
|
-
const firstParent = await
|
|
53
|
+
const firstParent = await mkdir(directory, { recursive: true })
|
|
55
54
|
|
|
56
55
|
/* Set the mode for all created directories */
|
|
57
56
|
if (firstParent && (dmode !== undefined)) {
|
|
58
57
|
assertAbsolutePath(firstParent)
|
|
59
58
|
for (let dir = directory; ; dir = getAbsoluteParent(dir)) {
|
|
60
59
|
run.log.trace(`Setting mode ${stringifyMode(dmode)} for directory`, $p(dir))
|
|
61
|
-
await
|
|
60
|
+
await chmod(dir, dmode)
|
|
62
61
|
if (dir === firstParent) break
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
/* Actually _copy_ the file */
|
|
67
66
|
run.log.trace(`Copying "${$p(absolute)}" to "${$p(target)}"`)
|
|
68
|
-
await
|
|
67
|
+
await copyFile(absolute, target, flags)
|
|
69
68
|
|
|
70
69
|
/* Set the mode, if we need to */
|
|
71
70
|
if (fmode !== undefined) {
|
|
72
71
|
run.log.trace(`Setting mode ${stringifyMode(fmode)} for file`, $p(target))
|
|
73
|
-
await
|
|
72
|
+
await chmod(target, fmode)
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
/* Record this file */
|
package/src/plugs/esbuild.ts
CHANGED
|
@@ -129,7 +129,6 @@ declare module '../pipe.js' {
|
|
|
129
129
|
* ========================================================================== */
|
|
130
130
|
|
|
131
131
|
export * from './esbuild/bundle-locals.js'
|
|
132
|
-
export * from './esbuild/check-dependencies.js'
|
|
133
132
|
export * from './esbuild/fix-extensions.js'
|
|
134
133
|
|
|
135
134
|
/* ========================================================================== *
|
package/src/plugs/tsc/options.ts
CHANGED
|
@@ -72,12 +72,13 @@ export async function getCompilerOptions(
|
|
|
72
72
|
file: AbsolutePath | undefined,
|
|
73
73
|
overrides: ts.CompilerOptions,
|
|
74
74
|
overridesFile: AbsolutePath,
|
|
75
|
+
overridesBasePath: AbsolutePath,
|
|
75
76
|
): Promise<CompilerOptionsAndDiagnostics>
|
|
76
77
|
|
|
77
78
|
/** Load compiler options from a JSON file, and merge in the overrides */
|
|
78
79
|
export async function getCompilerOptions(
|
|
79
80
|
file?: AbsolutePath,
|
|
80
|
-
...override: [ ts.CompilerOptions, AbsolutePath ] | []
|
|
81
|
+
...override: [ ts.CompilerOptions, AbsolutePath, AbsolutePath ] | []
|
|
81
82
|
): Promise<CompilerOptionsAndDiagnostics> {
|
|
82
83
|
let result: CompilerOptionsAndDiagnostics = { options: ts.getDefaultCompilerOptions(), errors: [] }
|
|
83
84
|
|
|
@@ -86,8 +87,7 @@ export async function getCompilerOptions(
|
|
|
86
87
|
|
|
87
88
|
// If we have overrides, merge them
|
|
88
89
|
if (override.length) {
|
|
89
|
-
const [ overrides, overridesFile ] = override
|
|
90
|
-
const overridesDir = getAbsoluteParent(overridesFile)
|
|
90
|
+
const [ overrides, overridesFile, overridesDir ] = override
|
|
91
91
|
const options = ts.convertCompilerOptionsFromJson(overrides, overridesDir, overridesFile)
|
|
92
92
|
result = mergeResults(result, options)
|
|
93
93
|
}
|