@monorepolint/utils 0.5.0-alpha.98 → 0.5.0-beta.0
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/CHANGELOG.md +7 -0
- package/package.json +43 -20
- package/src/AggregateTiming.ts +1 -2
- package/src/CachingHost.ts +9 -7
- package/src/Host.ts +1 -1
- package/src/PackageJson.ts +2 -1
- package/src/SimpleHost.ts +3 -4
- package/src/Table.ts +1 -2
- package/src/Timing.ts +1 -2
- package/src/__tests__/CachingHost.spec.ts +5 -5
- package/src/findWorkspaceDir.ts +11 -3
- package/src/getPackageNameToDir.ts +3 -4
- package/src/getWorkspacePackageDirs.ts +24 -9
- package/src/index.ts +13 -13
- package/src/matchesAnyGlob.ts +9 -8
- package/src/mutateJson.ts +2 -3
- package/tsconfig.json +7 -2
- package/lib/AggregateTiming.d.ts +0 -15
- package/lib/AggregateTiming.d.ts.map +0 -1
- package/lib/AggregateTiming.js +0 -70
- package/lib/AggregateTiming.js.map +0 -1
- package/lib/CachingHost.d.ts +0 -39
- package/lib/CachingHost.d.ts.map +0 -1
- package/lib/CachingHost.js +0 -366
- package/lib/CachingHost.js.map +0 -1
- package/lib/Host.d.ts +0 -38
- package/lib/Host.d.ts.map +0 -1
- package/lib/Host.js +0 -9
- package/lib/Host.js.map +0 -1
- package/lib/PackageJson.d.ts +0 -19
- package/lib/PackageJson.d.ts.map +0 -1
- package/lib/PackageJson.js +0 -9
- package/lib/PackageJson.js.map +0 -1
- package/lib/SimpleHost.d.ts +0 -35
- package/lib/SimpleHost.d.ts.map +0 -1
- package/lib/SimpleHost.js +0 -56
- package/lib/SimpleHost.js.map +0 -1
- package/lib/Table.d.ts +0 -53
- package/lib/Table.d.ts.map +0 -1
- package/lib/Table.js +0 -234
- package/lib/Table.js.map +0 -1
- package/lib/Timing.d.ts +0 -9
- package/lib/Timing.d.ts.map +0 -1
- package/lib/Timing.js +0 -57
- package/lib/Timing.js.map +0 -1
- package/lib/__tests__/CachingHost.spec.d.ts +0 -8
- package/lib/__tests__/CachingHost.spec.d.ts.map +0 -1
- package/lib/__tests__/CachingHost.spec.js +0 -178
- package/lib/__tests__/CachingHost.spec.js.map +0 -1
- package/lib/findWorkspaceDir.d.ts +0 -9
- package/lib/findWorkspaceDir.d.ts.map +0 -1
- package/lib/findWorkspaceDir.js +0 -34
- package/lib/findWorkspaceDir.js.map +0 -1
- package/lib/getPackageNameToDir.d.ts +0 -14
- package/lib/getPackageNameToDir.d.ts.map +0 -1
- package/lib/getPackageNameToDir.js +0 -31
- package/lib/getPackageNameToDir.js.map +0 -1
- package/lib/getWorkspacePackageDirs.d.ts +0 -9
- package/lib/getWorkspacePackageDirs.d.ts.map +0 -1
- package/lib/getWorkspacePackageDirs.js +0 -48
- package/lib/getWorkspacePackageDirs.js.map +0 -1
- package/lib/index.d.ts +0 -20
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -32
- package/lib/index.js.map +0 -1
- package/lib/matchesAnyGlob.d.ts +0 -17
- package/lib/matchesAnyGlob.d.ts.map +0 -1
- package/lib/matchesAnyGlob.js +0 -131
- package/lib/matchesAnyGlob.js.map +0 -1
- package/lib/mutateJson.d.ts +0 -9
- package/lib/mutateJson.d.ts.map +0 -1
- package/lib/mutateJson.js +0 -16
- package/lib/mutateJson.js.map +0 -1
- package/lib/nanosecondsToSanity.d.ts +0 -8
- package/lib/nanosecondsToSanity.d.ts.map +0 -1
- package/lib/nanosecondsToSanity.js +0 -14
- package/lib/nanosecondsToSanity.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
- /package/{jest.config.js → jest.config.cjs} +0 -0
package/CHANGELOG.md
ADDED
package/package.json
CHANGED
|
@@ -1,37 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monorepolint/utils",
|
|
3
|
-
"version": "0.5.0-
|
|
3
|
+
"version": "0.5.0-beta.0",
|
|
4
4
|
"author": "Eric L Anderson (https://github.com/ericanderson)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Mac Lockard (https://github.com/maclockard)"
|
|
7
7
|
],
|
|
8
8
|
"url": "https://github.com/monorepolint/monorepolint",
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./build/types/index.d.ts",
|
|
14
|
+
"import": "./build/js/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./*": {
|
|
17
|
+
"types": "./build/types/public/*.d.ts",
|
|
18
|
+
"import": "./build/js/public/*.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
19
23
|
},
|
|
20
24
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"glob": "^7.1.3",
|
|
25
|
+
"find-packages": "^10.0.4",
|
|
26
|
+
"find-up": "^7.0.0",
|
|
27
|
+
"glob": "^10.3.12",
|
|
25
28
|
"micromatch": "^4.0.5",
|
|
26
|
-
"
|
|
29
|
+
"read-yaml-file": "^2.1.0",
|
|
30
|
+
"tslib": "^2.6.2"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@types/
|
|
31
|
-
"@types/
|
|
33
|
+
"@jest/globals": "^29.7.0",
|
|
34
|
+
"@types/glob": "^8.1.0",
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"@types/micromatch": "^4.0.7",
|
|
37
|
+
"@types/node": "^18.18.14",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
|
39
|
+
"@typescript-eslint/parser": "^7.7.1",
|
|
40
|
+
"eslint": "^9.1.1",
|
|
41
|
+
"jest": "^29.7.0",
|
|
42
|
+
"prettier": "^3.2.5",
|
|
43
|
+
"ts-jest": "^29.1.2",
|
|
44
|
+
"tslib": "^2.6.2",
|
|
45
|
+
"tsup": "^8.0.2",
|
|
46
|
+
"typescript": "^5.4.5"
|
|
32
47
|
},
|
|
33
48
|
"publishConfig": {
|
|
34
49
|
"access": "public"
|
|
35
50
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
-
|
|
51
|
+
"gitHead": "74320e31cfce7555aece7a98d71d01d2f329be0f",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"clean": "rm -rf build dist lib node_modules *.tgz tsconfig.tsbuildinfo",
|
|
54
|
+
"compile-typescript": "tsc --build",
|
|
55
|
+
"lint": "eslint .",
|
|
56
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --colors --passWithNoTests",
|
|
57
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --colors --passWithNoTests --watch",
|
|
58
|
+
"transpile-typescript": "tsup --config ../../tsup.config.cjs"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/AggregateTiming.ts
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
// tslint:disable:no-console
|
|
8
8
|
|
|
9
|
-
import { Table } from "./Table";
|
|
10
|
-
|
|
9
|
+
import { Table } from "./Table.js";
|
|
11
10
|
export class AggregateTiming {
|
|
12
11
|
#data = new Map<string, { count: number; total: bigint }>();
|
|
13
12
|
#last: { count: number; total: bigint } | undefined;
|
package/src/CachingHost.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import * as realFs from "fs";
|
|
9
|
-
import { Host } from "./Host";
|
|
10
|
-
import * as path from "path";
|
|
8
|
+
import * as realFs from "node:fs";
|
|
9
|
+
import { Host } from "./Host.js";
|
|
10
|
+
import * as path from "node:path";
|
|
11
11
|
|
|
12
12
|
function assertNoTombstone(node: Node): asserts node is Node & { tombstone?: false } {
|
|
13
13
|
if (node.tombstone) {
|
|
@@ -129,11 +129,11 @@ export class CachingHost implements Host {
|
|
|
129
129
|
#replaceNode(node: DirNode, newNode: Omit<DirTombstoneNode, "fullPath" | "parent" | "dir">): DirTombstoneNode;
|
|
130
130
|
#replaceNode(node: Node, partialNewNode: Omit<Node, "fullPath" | "parent">): Node {
|
|
131
131
|
if (!node.parent) throw new Error("Cannot replace root node");
|
|
132
|
-
const newNode = {
|
|
132
|
+
const newNode: Node = {
|
|
133
133
|
...partialNewNode,
|
|
134
134
|
fullPath: node.fullPath,
|
|
135
135
|
parent: node.parent,
|
|
136
|
-
dir: (node as
|
|
136
|
+
dir: (node as DirNode).dir,
|
|
137
137
|
} as Node;
|
|
138
138
|
node.parent.dir.set(path.basename(node.fullPath), newNode);
|
|
139
139
|
return newNode;
|
|
@@ -238,7 +238,9 @@ export class CachingHost implements Host {
|
|
|
238
238
|
assertType(linkedNode, "dir");
|
|
239
239
|
curNode = linkedNode;
|
|
240
240
|
}
|
|
241
|
-
|
|
241
|
+
assertType(curNode, "dir");
|
|
242
|
+
assertNoTombstone(curNode);
|
|
243
|
+
curNode = curNode.dir.get(part) ?? this.#stubify(path.join(curNode.fullPath, part), curNode);
|
|
242
244
|
curPath = path.join(curPath, part);
|
|
243
245
|
}
|
|
244
246
|
} catch (e) {
|
|
@@ -480,7 +482,7 @@ export class CachingHost implements Host {
|
|
|
480
482
|
}
|
|
481
483
|
|
|
482
484
|
flush() {
|
|
483
|
-
const promises: Promise<
|
|
485
|
+
const promises: Promise<unknown>[] = [];
|
|
484
486
|
for (const rootNode of this.#trees.values()) {
|
|
485
487
|
promises.push(this.#flushDirNode(rootNode));
|
|
486
488
|
}
|
package/src/Host.ts
CHANGED
package/src/PackageJson.ts
CHANGED
|
@@ -11,11 +11,12 @@ export interface PackageJson {
|
|
|
11
11
|
dependencies?: Record<string, string>;
|
|
12
12
|
devDependencies?: Record<string, string>;
|
|
13
13
|
peerDependencies?: Record<string, string>;
|
|
14
|
+
optionalDependencies?: Record<string, string>;
|
|
14
15
|
workspaces?:
|
|
15
16
|
| {
|
|
16
17
|
packages?: string[];
|
|
17
18
|
nohoist?: string[];
|
|
18
19
|
}
|
|
19
20
|
| string[];
|
|
20
|
-
[otherKey: string]:
|
|
21
|
+
[otherKey: string]: unknown;
|
|
21
22
|
}
|
package/src/SimpleHost.ts
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import * as realFs from "fs";
|
|
9
9
|
|
|
10
|
-
import { Host } from "./Host";
|
|
11
|
-
|
|
10
|
+
import { Host } from "./Host.js";
|
|
12
11
|
export class SimpleHost implements Host {
|
|
13
12
|
constructor(private fs: typeof realFs = realFs) {}
|
|
14
13
|
mkdir(directoryPath: string, opts?: { recursive: boolean }): void {
|
|
@@ -24,7 +23,7 @@ export class SimpleHost implements Host {
|
|
|
24
23
|
|
|
25
24
|
writeFile(path: string, buffer: Buffer): void;
|
|
26
25
|
writeFile(path: string, body: string, opts: { encoding: BufferEncoding }): void;
|
|
27
|
-
writeFile(path:
|
|
26
|
+
writeFile(path: string, body: string | Buffer, opts?: { encoding: BufferEncoding }): void {
|
|
28
27
|
if (opts) {
|
|
29
28
|
this.fs.writeFileSync(path, body, { encoding: opts.encoding });
|
|
30
29
|
} else {
|
|
@@ -34,7 +33,7 @@ export class SimpleHost implements Host {
|
|
|
34
33
|
readFile(path: string, opts?: undefined): Buffer;
|
|
35
34
|
readFile(path: string, opts: { encoding: BufferEncoding }): string;
|
|
36
35
|
readFile(path: string, opts: { asJson: true }): object;
|
|
37
|
-
readFile(path:
|
|
36
|
+
readFile(path: string, opts?: { encoding?: BufferEncoding; asJson?: boolean }): string | object | Buffer {
|
|
38
37
|
if (opts?.asJson) {
|
|
39
38
|
return JSON.parse(this.fs.readFileSync(path, "utf-8"));
|
|
40
39
|
}
|
package/src/Table.ts
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
// tslint:disable:no-console
|
|
8
|
-
import { nanosecondsToSanity } from "./nanosecondsToSanity";
|
|
9
|
-
|
|
8
|
+
import { nanosecondsToSanity } from "./nanosecondsToSanity.js";
|
|
10
9
|
type HeaderFooterHelper<HB, FB, H, F> = (HB extends true ? { header: H } : { header?: H }) &
|
|
11
10
|
(FB extends true ? { footer: F } : { footer?: F });
|
|
12
11
|
|
package/src/Timing.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
import { CachingHost } from "../CachingHost";
|
|
9
|
-
import * as realfs from "fs";
|
|
10
|
-
import * as path from "path";
|
|
11
|
-
import * as os from "os";
|
|
7
|
+
import { describe, expect, it, beforeEach } from "@jest/globals";
|
|
8
|
+
import { CachingHost } from "../CachingHost.js";
|
|
9
|
+
import * as realfs from "node:fs";
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
import * as os from "node:os";
|
|
12
12
|
|
|
13
13
|
interface TestCase<T> {
|
|
14
14
|
getFs: () => T;
|
package/src/findWorkspaceDir.ts
CHANGED
|
@@ -6,9 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as path from "path";
|
|
9
|
-
import { Host } from "./Host";
|
|
10
|
-
import { PackageJson } from "./PackageJson";
|
|
11
|
-
import
|
|
9
|
+
import { Host } from "./Host.js";
|
|
10
|
+
import { PackageJson } from "./PackageJson.js";
|
|
11
|
+
import * as fs from "fs";
|
|
12
|
+
import { findUp } from "find-up";
|
|
13
|
+
|
|
14
|
+
export async function findPnpmWorkspaceDir(cwd: string) {
|
|
15
|
+
const workspaceManifestLocation = await findUp("pnpm-workspace.yaml", {
|
|
16
|
+
cwd: await fs.promises.realpath(cwd),
|
|
17
|
+
});
|
|
18
|
+
return workspaceManifestLocation && path.dirname(workspaceManifestLocation);
|
|
19
|
+
}
|
|
12
20
|
|
|
13
21
|
export async function findWorkspaceDir(
|
|
14
22
|
host: Pick<Host, "readJson" | "exists">,
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { join as pathJoin } from "path";
|
|
9
|
-
import { getWorkspacePackageDirs } from "./getWorkspacePackageDirs";
|
|
10
|
-
import { Host } from "./Host";
|
|
11
|
-
import { PackageJson } from "./PackageJson";
|
|
12
|
-
|
|
9
|
+
import { getWorkspacePackageDirs } from "./getWorkspacePackageDirs.js";
|
|
10
|
+
import { Host } from "./Host.js";
|
|
11
|
+
import { PackageJson } from "./PackageJson.js";
|
|
13
12
|
/**
|
|
14
13
|
* returns a map of package names to their directories in the workspace.
|
|
15
14
|
* if `resolvePaths` is true, the returned directory names are absolute paths
|
|
@@ -6,20 +6,35 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { existsSync } from "fs";
|
|
9
|
-
import glob from "glob";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
9
|
+
import * as glob from "glob";
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
import * as fs from "node:fs";
|
|
12
|
+
import { Host } from "./Host.js";
|
|
13
|
+
import { PackageJson } from "./PackageJson.js";
|
|
14
|
+
import * as readYamlFile from "read-yaml-file";
|
|
15
|
+
import { findPackages } from "find-packages";
|
|
16
|
+
|
|
17
|
+
async function findPNPMWorkspacePackages(workspaceRoot: string) {
|
|
18
|
+
workspaceRoot = fs.realpathSync(workspaceRoot);
|
|
19
|
+
const workspaceManifest = await readYamlFile.default<{ packages?: string[] }>(
|
|
20
|
+
path.join(workspaceRoot, "pnpm-workspace.yaml")
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return findPackages(workspaceRoot, {
|
|
24
|
+
ignore: ["**/node_modules/**", "**/bower_components/**"],
|
|
25
|
+
includeRoot: true,
|
|
26
|
+
patterns: workspaceManifest.packages,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
14
29
|
|
|
15
30
|
export async function getWorkspacePackageDirs(
|
|
16
31
|
host: Pick<Host, "readJson" | "exists">,
|
|
17
32
|
workspaceDir: string,
|
|
18
33
|
resolvePaths: boolean = false
|
|
19
34
|
) {
|
|
20
|
-
const packageJson
|
|
35
|
+
const packageJson = host.readJson(path.join(workspaceDir, "package.json")) as PackageJson;
|
|
21
36
|
|
|
22
|
-
const isPnpmWorkspace = host.exists(
|
|
37
|
+
const isPnpmWorkspace = host.exists(path.join(workspaceDir, "pnpm-workspace.yaml"));
|
|
23
38
|
if (isPnpmWorkspace) {
|
|
24
39
|
const workspacePackages = await findPNPMWorkspacePackages(workspaceDir);
|
|
25
40
|
if (workspacePackages.length === 0) {
|
|
@@ -39,11 +54,11 @@ export async function getWorkspacePackageDirs(
|
|
|
39
54
|
|
|
40
55
|
for (const pattern of packageGlobs) {
|
|
41
56
|
for (const packagePath of glob.sync(pattern, { cwd: workspaceDir })) {
|
|
42
|
-
const packageJsonPath =
|
|
57
|
+
const packageJsonPath = path.join(workspaceDir, packagePath, "package.json");
|
|
43
58
|
|
|
44
59
|
if (existsSync(packageJsonPath)) {
|
|
45
60
|
if (resolvePaths === true) {
|
|
46
|
-
ret.push(
|
|
61
|
+
ret.push(path.resolve(path.join(workspaceDir, packagePath)));
|
|
47
62
|
} else {
|
|
48
63
|
ret.push(packagePath);
|
|
49
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export { getWorkspacePackageDirs } from "./getWorkspacePackageDirs";
|
|
9
|
-
export { mutateJson } from "./mutateJson";
|
|
10
|
-
export { PackageJson } from "./PackageJson";
|
|
11
|
-
export { findWorkspaceDir } from "./findWorkspaceDir";
|
|
12
|
-
export { getPackageNameToDir } from "./getPackageNameToDir";
|
|
13
|
-
export { Host } from "./Host";
|
|
14
|
-
export { SimpleHost } from "./SimpleHost";
|
|
15
|
-
export { CachingHost } from "./CachingHost";
|
|
16
|
-
export { matchesAnyGlob } from "./matchesAnyGlob";
|
|
17
|
-
export { nanosecondsToSanity } from "./nanosecondsToSanity";
|
|
18
|
-
export { AggregateTiming } from "./AggregateTiming";
|
|
19
|
-
export { Timing } from "./Timing";
|
|
20
|
-
export { Table } from "./Table";
|
|
8
|
+
export { getWorkspacePackageDirs } from "./getWorkspacePackageDirs.js";
|
|
9
|
+
export { mutateJson } from "./mutateJson.js";
|
|
10
|
+
export { PackageJson } from "./PackageJson.js";
|
|
11
|
+
export { findWorkspaceDir } from "./findWorkspaceDir.js";
|
|
12
|
+
export { getPackageNameToDir } from "./getPackageNameToDir.js";
|
|
13
|
+
export { Host } from "./Host.js";
|
|
14
|
+
export { SimpleHost } from "./SimpleHost.js";
|
|
15
|
+
export { CachingHost } from "./CachingHost.js";
|
|
16
|
+
export { matchesAnyGlob } from "./matchesAnyGlob.js";
|
|
17
|
+
export { nanosecondsToSanity } from "./nanosecondsToSanity.js";
|
|
18
|
+
export { AggregateTiming } from "./AggregateTiming.js";
|
|
19
|
+
export { Timing } from "./Timing.js";
|
|
20
|
+
export { Table } from "./Table.js";
|
package/src/matchesAnyGlob.ts
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import { nanosecondsToSanity } from "./nanosecondsToSanity";
|
|
10
|
-
import { Table } from "./Table";
|
|
11
|
-
|
|
8
|
+
import micromatch from "micromatch";
|
|
9
|
+
import { nanosecondsToSanity } from "./nanosecondsToSanity.js";
|
|
10
|
+
import { Table } from "./Table.js";
|
|
12
11
|
// This file requires a LOT of caching to be performant. We have three layers to avoid work.
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -65,9 +64,10 @@ export const matchesAnyGlob: MatchesAnyGlob = function matchesAnyGlobFunc(needle
|
|
|
65
64
|
// N.B. true/false/undefined
|
|
66
65
|
result = patternCache.get(needle); // only thing different from the inline is we need to reuse `result`
|
|
67
66
|
if (result === undefined) {
|
|
68
|
-
let regexp = compiledGlobCache.get(pattern);
|
|
67
|
+
let regexp: RegExp | undefined | false = compiledGlobCache.get(pattern);
|
|
69
68
|
if (regexp === undefined) {
|
|
70
|
-
regexp = makeRe(pattern);
|
|
69
|
+
regexp = micromatch.makeRe(pattern);
|
|
70
|
+
// if (regexp === false) throw new Error("bad glob");
|
|
71
71
|
compiledGlobCache.set(pattern, regexp);
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -127,9 +127,10 @@ export function needleInPattern(needle: string, pattern: string) {
|
|
|
127
127
|
// N.B. true/false/undefined
|
|
128
128
|
let result = patternCache.get(needle);
|
|
129
129
|
if (result === undefined) {
|
|
130
|
-
let regexp = compiledGlobCache.get(pattern);
|
|
130
|
+
let regexp: RegExp | undefined | false = compiledGlobCache.get(pattern);
|
|
131
131
|
if (regexp === undefined) {
|
|
132
|
-
regexp = makeRe(pattern);
|
|
132
|
+
regexp = micromatch.makeRe(pattern);
|
|
133
|
+
// if (regexp === false) throw new Error("bad glob");
|
|
133
134
|
compiledGlobCache.set(pattern, regexp);
|
|
134
135
|
}
|
|
135
136
|
|
package/src/mutateJson.ts
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Host } from "./Host";
|
|
9
|
-
|
|
8
|
+
import { Host } from "./Host.js";
|
|
10
9
|
export function mutateJson<T extends object>(path: string, host: Host, mutator: (f: T) => T) {
|
|
11
|
-
let file
|
|
10
|
+
let file = host.readJson(path) as T;
|
|
12
11
|
file = mutator(file);
|
|
13
12
|
host.writeJson(path, file);
|
|
14
13
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": "./
|
|
5
|
-
"rootDir": "./src"
|
|
4
|
+
"outDir": "./build/js",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"declarationDir": "./build/types",
|
|
7
|
+
"tsBuildInfoFile": "./build/tsconfig.tsbuildinfo"
|
|
6
8
|
},
|
|
9
|
+
"include": [
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
7
12
|
"references": []
|
|
8
13
|
}
|
package/lib/AggregateTiming.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/lib/AggregateTiming.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/lib/CachingHost.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
package/lib/CachingHost.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAsF9B,qBAAa,WAAY,YAAW,IAAI;;IAKpC,OAAO,CAAC,EAAE;gBAAF,EAAE,GAAE,IAAI,CACd,OAAO,MAAM,EACX,YAAY,GACZ,WAAW,GACX,WAAW,GACX,UAAU,GACV,aAAa,GACb,cAAc,GACd,cAAc,GACd,cAAc,GACd,WAAW,GACX,UAAU,GACV,YAAY,GACZ,eAAe,CACT;IA2JZ,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAyB,GAAG,IAAI;IAqClF,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAqBlC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE,GAAG,MAAM;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,MAAM;IA8B1D,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IACjD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IACnF,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAgCnF,UAAU,CAAC,QAAQ,EAAE,MAAM;IAY3B,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAIzB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAoE5C,KAAK;CAON"}
|