@monorepolint/utils 0.5.0-alpha.83 → 0.5.0-alpha.86
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/lib/AggregateTiming.d.ts +15 -0
- package/lib/AggregateTiming.d.ts.map +1 -0
- package/lib/AggregateTiming.js +70 -0
- package/lib/AggregateTiming.js.map +1 -0
- package/lib/CachingHost.d.ts +39 -0
- package/lib/CachingHost.d.ts.map +1 -0
- package/lib/CachingHost.js +366 -0
- package/lib/CachingHost.js.map +1 -0
- package/lib/Host.d.ts +38 -0
- package/lib/Host.d.ts.map +1 -0
- package/lib/Host.js +9 -0
- package/lib/Host.js.map +1 -0
- package/lib/SimpleHost.d.ts +35 -0
- package/lib/SimpleHost.d.ts.map +1 -0
- package/lib/SimpleHost.js +56 -0
- package/lib/SimpleHost.js.map +1 -0
- package/lib/Table.d.ts +53 -0
- package/lib/Table.d.ts.map +1 -0
- package/lib/Table.js +234 -0
- package/lib/Table.js.map +1 -0
- package/lib/Timing.d.ts +9 -0
- package/lib/Timing.d.ts.map +1 -0
- package/lib/Timing.js +57 -0
- package/lib/Timing.js.map +1 -0
- package/lib/__tests__/CachingHost.spec.d.ts +8 -0
- package/lib/__tests__/CachingHost.spec.d.ts.map +1 -0
- package/lib/__tests__/CachingHost.spec.js +178 -0
- package/lib/__tests__/CachingHost.spec.js.map +1 -0
- package/lib/findWorkspaceDir.d.ts +2 -1
- package/lib/findWorkspaceDir.d.ts.map +1 -1
- package/lib/findWorkspaceDir.js +4 -6
- package/lib/findWorkspaceDir.js.map +1 -1
- package/lib/getPackageNameToDir.d.ts +2 -1
- package/lib/getPackageNameToDir.d.ts.map +1 -1
- package/lib/getPackageNameToDir.js +4 -5
- package/lib/getPackageNameToDir.js.map +1 -1
- package/lib/getWorkspacePackageDirs.d.ts +2 -1
- package/lib/getWorkspacePackageDirs.d.ts.map +1 -1
- package/lib/getWorkspacePackageDirs.js +5 -6
- package/lib/getWorkspacePackageDirs.js.map +1 -1
- package/lib/index.d.ts +8 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -4
- package/lib/index.js.map +1 -1
- package/lib/matchesAnyGlob.d.ts +17 -0
- package/lib/matchesAnyGlob.d.ts.map +1 -0
- package/lib/matchesAnyGlob.js +131 -0
- package/lib/matchesAnyGlob.js.map +1 -0
- package/lib/mutateJson.d.ts +2 -1
- package/lib/mutateJson.d.ts.map +1 -1
- package/lib/mutateJson.js +3 -5
- package/lib/mutateJson.js.map +1 -1
- package/lib/nanosecondsToSanity.d.ts +8 -0
- package/lib/nanosecondsToSanity.d.ts.map +1 -0
- package/lib/nanosecondsToSanity.js +14 -0
- package/lib/nanosecondsToSanity.js.map +1 -0
- package/package.json +8 -6
- package/src/AggregateTiming.ts +71 -0
- package/src/CachingHost.ts +489 -0
- package/src/Host.ts +34 -0
- package/src/SimpleHost.ts +57 -0
- package/src/Table.ts +319 -0
- package/src/Timing.ts +55 -0
- package/src/__tests__/CachingHost.spec.ts +244 -0
- package/src/findWorkspaceDir.ts +5 -6
- package/src/getPackageNameToDir.ts +4 -4
- package/src/getWorkspacePackageDirs.ts +7 -3
- package/src/index.ts +8 -2
- package/src/matchesAnyGlob.ts +145 -0
- package/src/mutateJson.ts +4 -5
- package/src/nanosecondsToSanity.ts +10 -0
- package/tsconfig.tsbuildinfo +1 -4046
- package/lib/readJson.d.ts +0 -8
- package/lib/readJson.d.ts.map +0 -1
- package/lib/readJson.js +0 -16
- package/lib/readJson.js.map +0 -1
- package/lib/writeJson.d.ts +0 -8
- package/lib/writeJson.d.ts.map +0 -1
- package/lib/writeJson.js +0 -15
- package/lib/writeJson.js.map +0 -1
- package/src/readJson.ts +0 -13
- package/src/writeJson.ts +0 -12
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare class AggregateTiming {
|
|
8
|
+
#private;
|
|
9
|
+
private title;
|
|
10
|
+
constructor(title: string);
|
|
11
|
+
start(name: string): void;
|
|
12
|
+
stop(): void;
|
|
13
|
+
printResults(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=AggregateTiming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AggregateTiming.d.ts","sourceRoot":"","sources":["../src/AggregateTiming.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,qBAAa,eAAe;;IAId,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAE1B,KAAK,CAAC,IAAI,EAAE,MAAM;IAiBlB,IAAI;IAQJ,YAAY;CA6BpB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
// tslint:disable:no-console
|
|
9
|
+
var _AggregateTiming_data, _AggregateTiming_last;
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.AggregateTiming = void 0;
|
|
12
|
+
const tslib_1 = require("tslib");
|
|
13
|
+
const Table_1 = require("./Table");
|
|
14
|
+
class AggregateTiming {
|
|
15
|
+
constructor(title) {
|
|
16
|
+
this.title = title;
|
|
17
|
+
_AggregateTiming_data.set(this, new Map());
|
|
18
|
+
_AggregateTiming_last.set(this, void 0);
|
|
19
|
+
}
|
|
20
|
+
start(name) {
|
|
21
|
+
const time = process.hrtime.bigint();
|
|
22
|
+
if (tslib_1.__classPrivateFieldGet(this, _AggregateTiming_last, "f")) {
|
|
23
|
+
tslib_1.__classPrivateFieldGet(this, _AggregateTiming_last, "f").total += time;
|
|
24
|
+
}
|
|
25
|
+
let data = tslib_1.__classPrivateFieldGet(this, _AggregateTiming_data, "f").get(name);
|
|
26
|
+
if (data === undefined) {
|
|
27
|
+
data = { count: 1, total: -time };
|
|
28
|
+
tslib_1.__classPrivateFieldGet(this, _AggregateTiming_data, "f").set(name, data);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
data.total -= time;
|
|
32
|
+
data.count++;
|
|
33
|
+
}
|
|
34
|
+
tslib_1.__classPrivateFieldSet(this, _AggregateTiming_last, data, "f");
|
|
35
|
+
}
|
|
36
|
+
stop() {
|
|
37
|
+
const time = process.hrtime.bigint();
|
|
38
|
+
if (tslib_1.__classPrivateFieldGet(this, _AggregateTiming_last, "f")) {
|
|
39
|
+
tslib_1.__classPrivateFieldGet(this, _AggregateTiming_last, "f").total += time;
|
|
40
|
+
tslib_1.__classPrivateFieldSet(this, _AggregateTiming_last, undefined, "f");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
printResults() {
|
|
44
|
+
const table = new Table_1.Table({
|
|
45
|
+
sortColumn: -1,
|
|
46
|
+
showFooter: true,
|
|
47
|
+
showHeader: true,
|
|
48
|
+
title: this.title,
|
|
49
|
+
columns: [
|
|
50
|
+
{
|
|
51
|
+
header: "Duration",
|
|
52
|
+
type: "bigint",
|
|
53
|
+
renderAs: "nanoseconds",
|
|
54
|
+
footer: { aggregate: "sum" },
|
|
55
|
+
},
|
|
56
|
+
{ header: "Task", type: "string", alignment: "left", footer: "TOTAL" },
|
|
57
|
+
{ header: "Count", type: "bigint", footer: { aggregate: "sum" } },
|
|
58
|
+
{ header: "Avg", type: "bigint", footer: { aggregate: "average" } },
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
for (const [name, value] of tslib_1.__classPrivateFieldGet(this, _AggregateTiming_data, "f")) {
|
|
62
|
+
table.addRow(value.total, name, BigInt(value.count), // fixme this can be a number later
|
|
63
|
+
value.total / BigInt(value.count));
|
|
64
|
+
}
|
|
65
|
+
table.print();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.AggregateTiming = AggregateTiming;
|
|
69
|
+
_AggregateTiming_data = new WeakMap(), _AggregateTiming_last = new WeakMap();
|
|
70
|
+
//# sourceMappingURL=AggregateTiming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AggregateTiming.js","sourceRoot":"","sources":["../src/AggregateTiming.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,4BAA4B;;;;;AAE5B,mCAAgC;AAEhC,MAAa,eAAe;IAI1B,YAAoB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAHjC,gCAAQ,IAAI,GAAG,EAA4C,EAAC;QAC5D,wCAAoD;IAEhB,CAAC;IAE9B,KAAK,CAAC,IAAY;QACvB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrC,IAAI,+BAAA,IAAI,6BAAM,EAAE;YACd,+BAAA,IAAI,6BAAM,CAAC,KAAK,IAAI,IAAI,CAAC;SAC1B;QAED,IAAI,IAAI,GAAG,+BAAA,IAAI,6BAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YAClC,+BAAA,IAAI,6BAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAC5B;aAAM;YACL,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;YACnB,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;QACD,+BAAA,IAAI,yBAAS,IAAI,MAAA,CAAC;IACpB,CAAC;IAEM,IAAI;QACT,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrC,IAAI,+BAAA,IAAI,6BAAM,EAAE;YACd,+BAAA,IAAI,6BAAM,CAAC,KAAK,IAAI,IAAI,CAAC;YACzB,+BAAA,IAAI,yBAAS,SAAS,MAAA,CAAC;SACxB;IACH,CAAC;IAEM,YAAY;QACjB,MAAM,KAAK,GAAG,IAAI,aAAK,CAAmC;YACxD,UAAU,EAAE,CAAC,CAAC;YACd,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE;gBACP;oBACE,MAAM,EAAE,UAAU;oBAClB,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,aAAa;oBACvB,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;iBAC7B;gBACD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;gBACtE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE;gBACjE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE;aACpE;SACF,CAAC,CAAC;QAEH,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,+BAAA,IAAI,6BAAM,EAAE;YACtC,KAAK,CAAC,MAAM,CACV,KAAK,CAAC,KAAK,EACX,IAAI,EACJ,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,mCAAmC;YACxD,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAClC,CAAC;SACH;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;CACF;AA5DD,0CA4DC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
/// <reference types="graceful-fs" />
|
|
9
|
+
import * as realFs from "fs";
|
|
10
|
+
import { Host } from "./Host";
|
|
11
|
+
export declare class CachingHost implements Host {
|
|
12
|
+
#private;
|
|
13
|
+
private fs;
|
|
14
|
+
constructor(fs?: Pick<typeof realFs, "existsSync" | "lstatSync" | "mkdirSync" | "promises" | "readdirSync" | "readFileSync" | "readlinkSync" | "realpathSync" | "rmdirSync" | "statSync" | "unlinkSync" | "writeFileSync">);
|
|
15
|
+
mkdir(filePath: string, opts?: {
|
|
16
|
+
recursive: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
rmdir(directoryPath: string): void;
|
|
19
|
+
exists(filePath: string): boolean;
|
|
20
|
+
readFile(filePath: string, opts?: undefined): Buffer;
|
|
21
|
+
readFile(filePath: string, opts: {
|
|
22
|
+
encoding: BufferEncoding;
|
|
23
|
+
}): string;
|
|
24
|
+
readFile(filePath: string, opts: {
|
|
25
|
+
asJson: true;
|
|
26
|
+
}): object;
|
|
27
|
+
writeFile(filePath: string, buffer: Buffer): void;
|
|
28
|
+
writeFile(filePath: string, body: string, opts: {
|
|
29
|
+
encoding: BufferEncoding;
|
|
30
|
+
}): void;
|
|
31
|
+
writeFile(filePath: string, body: string, opts: {
|
|
32
|
+
encoding: BufferEncoding;
|
|
33
|
+
}): void;
|
|
34
|
+
deleteFile(filePath: string): void;
|
|
35
|
+
readJson(filePath: string): object;
|
|
36
|
+
writeJson(filePath: string, o: object): void;
|
|
37
|
+
flush(): Promise<any[]>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=CachingHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CachingHost.d.ts","sourceRoot":"","sources":["../src/CachingHost.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;AAEH,OAAO,KAAK,MAAM,MAAM,IAAI,CAAC;AAC7B,OAAO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AE,CAAC,EAAE,MAAM,GAAG,IAAI;IAoE5C,KAAK;CAON"}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
var _CachingHost_instances, _CachingHost_trees, _CachingHost_replaceNode, _CachingHost_unstubDirectory, _CachingHost_stubify, _CachingHost_getNearestAncestorNode, _CachingHost_getNode, _CachingHost_getNodeResolvingSymlinks, _CachingHost_flushFileNode, _CachingHost_flushSymlinkNode, _CachingHost_flushDirNode;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CachingHost = void 0;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const realFs = tslib_1.__importStar(require("fs"));
|
|
13
|
+
const path = tslib_1.__importStar(require("path"));
|
|
14
|
+
function assertNoTombstone(node) {
|
|
15
|
+
if (node.tombstone) {
|
|
16
|
+
throw new Error(`Unexpected tombstone ${JSON.stringify(node)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function assertNotType(node, type) {
|
|
20
|
+
if (node.type === type) {
|
|
21
|
+
throw new Error(`Unexpected node type ${JSON.stringify(node)}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function assertType(node, type) {
|
|
25
|
+
if (node.type !== type) {
|
|
26
|
+
throw new Error(`Unexpected node type ${JSON.stringify(node)}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function assertExists(node) {
|
|
30
|
+
if (!node) {
|
|
31
|
+
throw new Error(`Expected node to exist`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function assertHasParent(node) {
|
|
35
|
+
if (!node.parent) {
|
|
36
|
+
throw new Error("Expected node to have a parent directory");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class CachingHost {
|
|
40
|
+
constructor(fs = realFs) {
|
|
41
|
+
this.fs = fs;
|
|
42
|
+
_CachingHost_instances.add(this);
|
|
43
|
+
// We need many trees because of windows, key is the `root`
|
|
44
|
+
_CachingHost_trees.set(this, new Map());
|
|
45
|
+
}
|
|
46
|
+
mkdir(filePath, opts = { recursive: false }) {
|
|
47
|
+
const canonicalPath = path.resolve(filePath);
|
|
48
|
+
const { node, pathWithSymlinks } = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNearestAncestorNode).call(this, canonicalPath);
|
|
49
|
+
if (filePath === pathWithSymlinks) {
|
|
50
|
+
assertType(node, "dir");
|
|
51
|
+
assertHasParent(node);
|
|
52
|
+
if (!node.tombstone)
|
|
53
|
+
return; // already done
|
|
54
|
+
}
|
|
55
|
+
else if (path.dirname(filePath) === pathWithSymlinks) {
|
|
56
|
+
assertType(node, "dir");
|
|
57
|
+
assertNoTombstone(node);
|
|
58
|
+
node.dir.set(path.basename(filePath), {
|
|
59
|
+
type: "dir",
|
|
60
|
+
fullPath: filePath,
|
|
61
|
+
parent: node,
|
|
62
|
+
dir: new Map(),
|
|
63
|
+
needsFlush: true,
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!opts.recursive && path.dirname(canonicalPath) !== pathWithSymlinks) {
|
|
68
|
+
throw new Error("no such file or directory");
|
|
69
|
+
}
|
|
70
|
+
const rootPath = pathWithSymlinks;
|
|
71
|
+
let maybePath = canonicalPath;
|
|
72
|
+
const toMake = [];
|
|
73
|
+
while (maybePath !== rootPath) {
|
|
74
|
+
toMake.unshift(path.resolve(node.fullPath, path.relative(rootPath, maybePath)));
|
|
75
|
+
maybePath = path.dirname(maybePath);
|
|
76
|
+
}
|
|
77
|
+
for (const dirToMake of toMake) {
|
|
78
|
+
this.mkdir(dirToMake);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
rmdir(directoryPath) {
|
|
82
|
+
const node = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNode).call(this, directoryPath);
|
|
83
|
+
if (!node || node.tombstone) {
|
|
84
|
+
return; // this isnt how FS usually work but its what we are doing
|
|
85
|
+
}
|
|
86
|
+
assertType(node, "dir");
|
|
87
|
+
if (node.stub) {
|
|
88
|
+
tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_unstubDirectory).call(this, node);
|
|
89
|
+
}
|
|
90
|
+
if (node.dir.size === 0) {
|
|
91
|
+
tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_replaceNode).call(this, node, {
|
|
92
|
+
type: "dir",
|
|
93
|
+
tombstone: true,
|
|
94
|
+
needsFlush: true,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
throw new Error("directory not empty");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exists(filePath) {
|
|
102
|
+
const node = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNode).call(this, filePath); // canonicalizes for us
|
|
103
|
+
return !!node && !node.tombstone;
|
|
104
|
+
}
|
|
105
|
+
readFile(filePath, opts) {
|
|
106
|
+
let node = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNodeResolvingSymlinks).call(this, filePath); // canonicalizes for us
|
|
107
|
+
if (!node) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
assertNotType(node, "dir");
|
|
111
|
+
assertNoTombstone(node);
|
|
112
|
+
if (node.stub) {
|
|
113
|
+
node = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_replaceNode).call(this, node, {
|
|
114
|
+
type: "file",
|
|
115
|
+
file: this.fs.readFileSync(filePath),
|
|
116
|
+
needsFlush: false,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (!opts) {
|
|
120
|
+
return Buffer.from(node.file);
|
|
121
|
+
}
|
|
122
|
+
else if (opts.asJson) {
|
|
123
|
+
return JSON.parse(node.file.toString("utf-8"));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return node.file.toString(opts.encoding);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
writeFile(filePath, body, opts) {
|
|
130
|
+
const fileContentsAsBuffer = typeof body === "string" ? Buffer.from(body, opts === null || opts === void 0 ? void 0 : opts.encoding) : Buffer.from(body);
|
|
131
|
+
const canonicalPath = path.resolve(filePath);
|
|
132
|
+
const existingNode = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNodeResolvingSymlinks).call(this, canonicalPath);
|
|
133
|
+
if (existingNode) {
|
|
134
|
+
if (existingNode.type === "dir") {
|
|
135
|
+
throw new Error("cant write file to a dir");
|
|
136
|
+
}
|
|
137
|
+
tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_replaceNode).call(this, existingNode, {
|
|
138
|
+
file: fileContentsAsBuffer,
|
|
139
|
+
type: "file",
|
|
140
|
+
needsFlush: true,
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const maybeDirNode = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNodeResolvingSymlinks).call(this, path.dirname(canonicalPath));
|
|
145
|
+
assertExists(maybeDirNode);
|
|
146
|
+
assertType(maybeDirNode, "dir");
|
|
147
|
+
assertNoTombstone(maybeDirNode);
|
|
148
|
+
maybeDirNode.dir.set(path.basename(canonicalPath), {
|
|
149
|
+
type: "file",
|
|
150
|
+
fullPath: canonicalPath,
|
|
151
|
+
parent: maybeDirNode,
|
|
152
|
+
file: fileContentsAsBuffer,
|
|
153
|
+
needsFlush: true,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
deleteFile(filePath) {
|
|
157
|
+
const canonicalPath = path.resolve(filePath);
|
|
158
|
+
const node = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNode).call(this, canonicalPath);
|
|
159
|
+
if (!node || (node.type === "file" && node.tombstone === true))
|
|
160
|
+
return;
|
|
161
|
+
assertNotType(node, "dir");
|
|
162
|
+
tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_replaceNode).call(this, node, {
|
|
163
|
+
type: "file",
|
|
164
|
+
tombstone: true,
|
|
165
|
+
needsFlush: true,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
readJson(filePath) {
|
|
169
|
+
return this.readFile(filePath, { asJson: true });
|
|
170
|
+
}
|
|
171
|
+
writeJson(filePath, o) {
|
|
172
|
+
return this.writeFile(filePath, JSON.stringify(o, undefined, 2) + "\n", {
|
|
173
|
+
encoding: "utf-8",
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
flush() {
|
|
177
|
+
const promises = [];
|
|
178
|
+
for (const rootNode of tslib_1.__classPrivateFieldGet(this, _CachingHost_trees, "f").values()) {
|
|
179
|
+
promises.push(tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_flushDirNode).call(this, rootNode));
|
|
180
|
+
}
|
|
181
|
+
return Promise.all(promises);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.CachingHost = CachingHost;
|
|
185
|
+
_CachingHost_trees = new WeakMap(), _CachingHost_instances = new WeakSet(), _CachingHost_replaceNode = function _CachingHost_replaceNode(node, partialNewNode) {
|
|
186
|
+
if (!node.parent)
|
|
187
|
+
throw new Error("Cannot replace root node");
|
|
188
|
+
const newNode = {
|
|
189
|
+
...partialNewNode,
|
|
190
|
+
fullPath: node.fullPath,
|
|
191
|
+
parent: node.parent,
|
|
192
|
+
dir: node.dir,
|
|
193
|
+
};
|
|
194
|
+
node.parent.dir.set(path.basename(node.fullPath), newNode);
|
|
195
|
+
return newNode;
|
|
196
|
+
}, _CachingHost_unstubDirectory = function _CachingHost_unstubDirectory(node) {
|
|
197
|
+
// So the rules for our stub dirs. We assume the things in the map are authority but
|
|
198
|
+
// for things not in the map, the real FS is the authority
|
|
199
|
+
for (const child of this.fs.readdirSync(node.fullPath)) {
|
|
200
|
+
// just makign this call will populate the structure but its a little expensive.
|
|
201
|
+
// TODO: make an unknown stub
|
|
202
|
+
tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNode).call(this, path.join(node.fullPath, child));
|
|
203
|
+
}
|
|
204
|
+
node.stub = false;
|
|
205
|
+
}, _CachingHost_stubify = function _CachingHost_stubify(filePath, parent) {
|
|
206
|
+
const canonicalPath = path.resolve(filePath);
|
|
207
|
+
if (!parent && canonicalPath !== path.parse(canonicalPath).root) {
|
|
208
|
+
throw new Error(`parent can only be null if path is root. Instead got: ${canonicalPath}`);
|
|
209
|
+
}
|
|
210
|
+
const stat = this.fs.lstatSync(canonicalPath); // may throw
|
|
211
|
+
let node;
|
|
212
|
+
if (stat.isDirectory()) {
|
|
213
|
+
node = {
|
|
214
|
+
fullPath: canonicalPath,
|
|
215
|
+
type: "dir",
|
|
216
|
+
stub: true,
|
|
217
|
+
dir: new Map(),
|
|
218
|
+
parent,
|
|
219
|
+
needsFlush: false,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
else if (stat.isSymbolicLink()) {
|
|
223
|
+
node = {
|
|
224
|
+
fullPath: canonicalPath,
|
|
225
|
+
type: "symlink",
|
|
226
|
+
symlink: this.fs.readlinkSync(canonicalPath),
|
|
227
|
+
parent,
|
|
228
|
+
needsFlush: false,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
else if (stat.isFile()) {
|
|
232
|
+
node = {
|
|
233
|
+
fullPath: canonicalPath,
|
|
234
|
+
type: "file",
|
|
235
|
+
stub: true,
|
|
236
|
+
parent,
|
|
237
|
+
needsFlush: false,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
throw new Error(`what is not a file nor symlink nor directory? nothing we care about: ${canonicalPath}`);
|
|
242
|
+
}
|
|
243
|
+
if (!parent && node.type === "dir") {
|
|
244
|
+
tslib_1.__classPrivateFieldGet(this, _CachingHost_trees, "f").set(canonicalPath, node);
|
|
245
|
+
return node;
|
|
246
|
+
}
|
|
247
|
+
else if (parent) {
|
|
248
|
+
parent.dir.set(path.basename(canonicalPath), node);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
throw new Error(`root can only be a dir, got ${JSON.stringify(node)} for path: ${canonicalPath}`);
|
|
252
|
+
}
|
|
253
|
+
return node;
|
|
254
|
+
}, _CachingHost_getNearestAncestorNode = function _CachingHost_getNearestAncestorNode(filePath) {
|
|
255
|
+
var _a, _b;
|
|
256
|
+
const canonicalPath = path.resolve(filePath);
|
|
257
|
+
const { root } = path.parse(canonicalPath);
|
|
258
|
+
const parts = [];
|
|
259
|
+
let maybePath = canonicalPath;
|
|
260
|
+
while (maybePath !== root) {
|
|
261
|
+
parts.unshift(path.basename(maybePath));
|
|
262
|
+
maybePath = path.dirname(maybePath);
|
|
263
|
+
}
|
|
264
|
+
let curPath = root;
|
|
265
|
+
let curNode = (_a = tslib_1.__classPrivateFieldGet(this, _CachingHost_trees, "f").get(root)) !== null && _a !== void 0 ? _a : tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_stubify).call(this, curPath, undefined); // its okay to throw if there is no root
|
|
266
|
+
try {
|
|
267
|
+
for (const part of parts) {
|
|
268
|
+
assertNoTombstone(curNode);
|
|
269
|
+
assertNotType(curNode, "file");
|
|
270
|
+
if (curNode.type === "symlink") {
|
|
271
|
+
const linkedNode = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNodeResolvingSymlinks).call(this, path.resolve(path.dirname(curPath), curNode.symlink));
|
|
272
|
+
assertExists(linkedNode);
|
|
273
|
+
assertNoTombstone(linkedNode);
|
|
274
|
+
assertType(linkedNode, "dir");
|
|
275
|
+
curNode = linkedNode;
|
|
276
|
+
}
|
|
277
|
+
curNode = (_b = curNode.dir.get(part)) !== null && _b !== void 0 ? _b : tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_stubify).call(this, path.join(curNode.fullPath, part), curNode);
|
|
278
|
+
curPath = path.join(curPath, part);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
// This error is expected when things done exist.
|
|
283
|
+
// console.log(`Got EXPECTED error when trying to getNearestAncestorNode(${canonicalPath}): `, (e as any).message);
|
|
284
|
+
}
|
|
285
|
+
return { pathWithSymlinks: curPath, node: curNode };
|
|
286
|
+
}, _CachingHost_getNode = function _CachingHost_getNode(filePath) {
|
|
287
|
+
const canonicalPath = path.resolve(filePath);
|
|
288
|
+
const { pathWithSymlinks, node } = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNearestAncestorNode).call(this, canonicalPath);
|
|
289
|
+
if (pathWithSymlinks === canonicalPath) {
|
|
290
|
+
return node;
|
|
291
|
+
}
|
|
292
|
+
return undefined;
|
|
293
|
+
}, _CachingHost_getNodeResolvingSymlinks = function _CachingHost_getNodeResolvingSymlinks(filePath, follows = 100) {
|
|
294
|
+
const node = tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNode).call(this, filePath); // canonicalizes for us
|
|
295
|
+
if (!node || node.type !== "symlink")
|
|
296
|
+
return node;
|
|
297
|
+
// this is a really poor mans way of doing this. but who has 100's of symlinks hanging around?
|
|
298
|
+
if (follows === 0)
|
|
299
|
+
throw new Error("Exhausted symlink follows");
|
|
300
|
+
return tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_getNodeResolvingSymlinks).call(this, node.symlink, follows--);
|
|
301
|
+
}, _CachingHost_flushFileNode = async function _CachingHost_flushFileNode(node) {
|
|
302
|
+
// FIXME all tombstones need a flush, so we can get rid of needsFlush for them
|
|
303
|
+
if (node.tombstone) {
|
|
304
|
+
try {
|
|
305
|
+
await this.fs.promises.access(node.fullPath);
|
|
306
|
+
return this.fs.promises.unlink(node.fullPath);
|
|
307
|
+
}
|
|
308
|
+
catch (e) {
|
|
309
|
+
// should only throw if file doesnt exist which is no op
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else if (node.stub === true || node.needsFlush === false) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
// we dont do things with file stubs
|
|
318
|
+
return this.fs.promises.writeFile(node.fullPath, node.file);
|
|
319
|
+
}
|
|
320
|
+
}, _CachingHost_flushSymlinkNode = async function _CachingHost_flushSymlinkNode(node) {
|
|
321
|
+
if (!node.needsFlush)
|
|
322
|
+
return;
|
|
323
|
+
try {
|
|
324
|
+
const linkValue = await this.fs.promises.readlink(node.fullPath);
|
|
325
|
+
if (linkValue === node.symlink) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
330
|
+
// expected when the link doesnt exist
|
|
331
|
+
}
|
|
332
|
+
return this.fs.promises.symlink(node.symlink, node.fullPath);
|
|
333
|
+
}, _CachingHost_flushDirNode = async function _CachingHost_flushDirNode(node) {
|
|
334
|
+
if (!node.tombstone && node.needsFlush) {
|
|
335
|
+
try {
|
|
336
|
+
await this.fs.promises.access(node.fullPath); // throws if the file doesnt exist
|
|
337
|
+
}
|
|
338
|
+
catch (e) {
|
|
339
|
+
await this.fs.promises.mkdir(node.fullPath); // throws if it does :(
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const promises = [];
|
|
343
|
+
for (const child of node.dir.values()) {
|
|
344
|
+
if (node.tombstone && !child.tombstone) {
|
|
345
|
+
throw new Error("Unexpected failure during sanity check. A non-deleted child is on a deleted dir");
|
|
346
|
+
}
|
|
347
|
+
if (child.type === "dir") {
|
|
348
|
+
promises.push(tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_flushDirNode).call(this, child));
|
|
349
|
+
}
|
|
350
|
+
else if (child.type === "file") {
|
|
351
|
+
promises.push(tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_flushFileNode).call(this, child));
|
|
352
|
+
}
|
|
353
|
+
else if (child.type === "symlink") {
|
|
354
|
+
promises.push(tslib_1.__classPrivateFieldGet(this, _CachingHost_instances, "m", _CachingHost_flushSymlinkNode).call(this, child));
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
throw new Error("should never happen");
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
await Promise.all(promises);
|
|
361
|
+
if (node.tombstone) {
|
|
362
|
+
return this.fs.promises.rmdir(node.fullPath);
|
|
363
|
+
}
|
|
364
|
+
return;
|
|
365
|
+
};
|
|
366
|
+
//# sourceMappingURL=CachingHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CachingHost.js","sourceRoot":"","sources":["../src/CachingHost.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAEH,mDAA6B;AAE7B,mDAA6B;AAE7B,SAAS,iBAAiB,CAAC,IAAU;IACnC,IAAI,IAAI,CAAC,SAAS,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE;AACH,CAAC;AAED,SAAS,aAAa,CACpB,IAAO,EACP,IAAO;IAEP,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE;AACH,CAAC;AAED,SAAS,UAAU,CAAyC,IAAO,EAAE,IAAO;IAC1E,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE;AACH,CAAC;AAED,SAAS,YAAY,CAAiB,IAAmB;IACvD,IAAI,CAAC,IAAI,E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AAK,CAAC,CAAC,CAAC;SAC1C;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE;YAChC,QAAQ,CAAC,IAAI,CAAC,+BAAA,IAAI,0DAAe,MAAnB,IAAI,EAAgB,KAAK,CAAC,CAAC,CAAC;SAC3C;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;YACnC,QAAQ,CAAC,IAAI,CAAC,+BAAA,IAAI,6DAAkB,MAAtB,IAAI,EAAmB,KAAK,CAAC,CAAC,CAAC;SAC9C;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;SACxC;KACF;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,IAAI,IAAI,CAAC,SAAS,EAAE;QAClB,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9C;IACD,OAAO;AACT,CAAC"}
|
package/lib/Host.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
export interface Host {
|
|
9
|
+
/**
|
|
10
|
+
* Reads and parses a json file.
|
|
11
|
+
*/
|
|
12
|
+
readJson(filename: string): any;
|
|
13
|
+
/**
|
|
14
|
+
* Writes a json file.
|
|
15
|
+
* @param path path to write
|
|
16
|
+
* @param o object to write
|
|
17
|
+
*/
|
|
18
|
+
writeJson(path: string, o: object): void;
|
|
19
|
+
writeFile(path: string, buffer: Buffer): void;
|
|
20
|
+
writeFile(path: string, body: string, opts: {
|
|
21
|
+
encoding: BufferEncoding;
|
|
22
|
+
}): void;
|
|
23
|
+
readFile(path: string, opts?: undefined): Buffer;
|
|
24
|
+
readFile(path: string, opts: {
|
|
25
|
+
encoding: BufferEncoding;
|
|
26
|
+
}): string;
|
|
27
|
+
readFile(path: string, opts: {
|
|
28
|
+
asJson: true;
|
|
29
|
+
}): object;
|
|
30
|
+
exists(path: string): boolean;
|
|
31
|
+
mkdir(directoryPath: string, opts?: {
|
|
32
|
+
recursive: boolean;
|
|
33
|
+
}): void;
|
|
34
|
+
rmdir(directoryPath: string): void;
|
|
35
|
+
deleteFile(path: string): void;
|
|
36
|
+
flush(): Promise<unknown>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Host.d.ts","sourceRoot":"","sources":["../src/Host.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;IAEhC;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI,CAAC;IAEhF,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE,GAAG,MAAM,CAAC;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,MAAM,CAAC;IAEvD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAClE,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3B"}
|
package/lib/Host.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=Host.js.map
|
package/lib/Host.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Host.js","sourceRoot":"","sources":["../src/Host.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
/// <reference types="graceful-fs" />
|
|
9
|
+
import * as realFs from "fs";
|
|
10
|
+
import { Host } from "./Host";
|
|
11
|
+
export declare class SimpleHost implements Host {
|
|
12
|
+
private fs;
|
|
13
|
+
constructor(fs?: typeof realFs);
|
|
14
|
+
mkdir(directoryPath: string, opts?: {
|
|
15
|
+
recursive: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
rmdir(directoryPath: string): void;
|
|
18
|
+
exists(path: string): boolean;
|
|
19
|
+
writeFile(path: string, buffer: Buffer): void;
|
|
20
|
+
writeFile(path: string, body: string, opts: {
|
|
21
|
+
encoding: BufferEncoding;
|
|
22
|
+
}): void;
|
|
23
|
+
readFile(path: string, opts?: undefined): Buffer;
|
|
24
|
+
readFile(path: string, opts: {
|
|
25
|
+
encoding: BufferEncoding;
|
|
26
|
+
}): string;
|
|
27
|
+
readFile(path: string, opts: {
|
|
28
|
+
asJson: true;
|
|
29
|
+
}): object;
|
|
30
|
+
deleteFile(path: string): void;
|
|
31
|
+
readJson(filename: string): any;
|
|
32
|
+
writeJson(path: string, o: object): void;
|
|
33
|
+
flush(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=SimpleHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimpleHost.d.ts","sourceRoot":"","sources":["../src/SimpleHost.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;AAEH,OAAO,KAAK,MAAM,MAAM,IAAI,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,qBAAa,UAAW,YAAW,IAAI;IACzB,OAAO,CAAC,EAAE;gBAAF,EAAE,GAAE,OAAO,MAAe;IAC9C,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAGjE,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAIlC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI7B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAC7C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAQ/E,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,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