@monorepolint/utils 0.5.0-alpha.13 → 0.5.0-alpha.131

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.
Files changed (87) hide show
  1. package/.turbo/turbo-clean.log +4 -0
  2. package/.turbo/turbo-compile-typescript.log +4 -0
  3. package/.turbo/turbo-lint.log +56 -0
  4. package/.turbo/turbo-test.log +26 -0
  5. package/.turbo/turbo-transpile-typescript.log +14 -0
  6. package/build/js/index.js +893 -0
  7. package/build/js/index.js.map +1 -0
  8. package/build/tsconfig.tsbuildinfo +1 -0
  9. package/build/types/AggregateTiming.d.ts +15 -0
  10. package/build/types/AggregateTiming.d.ts.map +1 -0
  11. package/build/types/CachingHost.d.ts +39 -0
  12. package/build/types/CachingHost.d.ts.map +1 -0
  13. package/build/types/Host.d.ts +38 -0
  14. package/build/types/Host.d.ts.map +1 -0
  15. package/build/types/PackageJson.d.ts.map +1 -0
  16. package/build/types/SimpleHost.d.ts +35 -0
  17. package/build/types/SimpleHost.d.ts.map +1 -0
  18. package/build/types/Table.d.ts +53 -0
  19. package/build/types/Table.d.ts.map +1 -0
  20. package/build/types/Timing.d.ts +9 -0
  21. package/build/types/Timing.d.ts.map +1 -0
  22. package/build/types/__tests__/CachingHost.spec.d.ts +2 -0
  23. package/build/types/__tests__/CachingHost.spec.d.ts.map +1 -0
  24. package/build/types/findWorkspaceDir.d.ts +10 -0
  25. package/build/types/findWorkspaceDir.d.ts.map +1 -0
  26. package/{lib → build/types}/getPackageNameToDir.d.ts +2 -1
  27. package/build/types/getPackageNameToDir.d.ts.map +1 -0
  28. package/build/types/getWorkspacePackageDirs.d.ts +9 -0
  29. package/build/types/getWorkspacePackageDirs.d.ts.map +1 -0
  30. package/build/types/index.d.ts +20 -0
  31. package/build/types/index.d.ts.map +1 -0
  32. package/build/types/matchesAnyGlob.d.ts +17 -0
  33. package/build/types/matchesAnyGlob.d.ts.map +1 -0
  34. package/{lib → build/types}/mutateJson.d.ts +2 -1
  35. package/build/types/mutateJson.d.ts.map +1 -0
  36. package/build/types/nanosecondsToSanity.d.ts +8 -0
  37. package/build/types/nanosecondsToSanity.d.ts.map +1 -0
  38. package/package.json +42 -14
  39. package/src/AggregateTiming.ts +70 -0
  40. package/src/CachingHost.ts +490 -0
  41. package/src/Host.ts +34 -0
  42. package/src/SimpleHost.ts +56 -0
  43. package/src/Table.ts +318 -0
  44. package/src/Timing.ts +54 -0
  45. package/src/__tests__/CachingHost.spec.ts +244 -0
  46. package/src/findWorkspaceDir.ts +25 -7
  47. package/src/getPackageNameToDir.ts +11 -7
  48. package/src/getWorkspacePackageDirs.ts +39 -11
  49. package/src/index.ts +13 -7
  50. package/src/matchesAnyGlob.ts +146 -0
  51. package/src/mutateJson.ts +4 -6
  52. package/src/nanosecondsToSanity.ts +10 -0
  53. package/tsconfig.json +7 -2
  54. package/lib/PackageJson.d.ts.map +0 -1
  55. package/lib/PackageJson.js +0 -9
  56. package/lib/PackageJson.js.map +0 -1
  57. package/lib/findWorkspaceDir.d.ts +0 -8
  58. package/lib/findWorkspaceDir.d.ts.map +0 -1
  59. package/lib/findWorkspaceDir.js +0 -28
  60. package/lib/findWorkspaceDir.js.map +0 -1
  61. package/lib/getPackageNameToDir.d.ts.map +0 -1
  62. package/lib/getPackageNameToDir.js +0 -30
  63. package/lib/getPackageNameToDir.js.map +0 -1
  64. package/lib/getWorkspacePackageDirs.d.ts +0 -8
  65. package/lib/getWorkspacePackageDirs.d.ts.map +0 -1
  66. package/lib/getWorkspacePackageDirs.js +0 -39
  67. package/lib/getWorkspacePackageDirs.js.map +0 -1
  68. package/lib/index.d.ts +0 -14
  69. package/lib/index.d.ts.map +0 -1
  70. package/lib/index.js +0 -21
  71. package/lib/index.js.map +0 -1
  72. package/lib/mutateJson.d.ts.map +0 -1
  73. package/lib/mutateJson.js +0 -17
  74. package/lib/mutateJson.js.map +0 -1
  75. package/lib/readJson.d.ts +0 -8
  76. package/lib/readJson.d.ts.map +0 -1
  77. package/lib/readJson.js +0 -15
  78. package/lib/readJson.js.map +0 -1
  79. package/lib/writeJson.d.ts +0 -8
  80. package/lib/writeJson.d.ts.map +0 -1
  81. package/lib/writeJson.js +0 -14
  82. package/lib/writeJson.js.map +0 -1
  83. package/src/readJson.ts +0 -13
  84. package/src/writeJson.ts +0 -12
  85. package/tsconfig.tsbuildinfo +0 -1586
  86. /package/{lib → build/types}/PackageJson.d.ts +0 -0
  87. /package/{jest.config.js → jest.config.cjs} +0 -0
@@ -0,0 +1,20 @@
1
+ /*!
2
+ * Copyright 2019 Palantir Technologies, Inc.
3
+ *
4
+ * Licensed under the MIT license. See LICENSE file in the project root for details.
5
+ *
6
+ */
7
+ export { getWorkspacePackageDirs } from "./getWorkspacePackageDirs.js";
8
+ export { mutateJson } from "./mutateJson.js";
9
+ export { PackageJson } from "./PackageJson.js";
10
+ export { findWorkspaceDir } from "./findWorkspaceDir.js";
11
+ export { getPackageNameToDir } from "./getPackageNameToDir.js";
12
+ export { Host } from "./Host.js";
13
+ export { SimpleHost } from "./SimpleHost.js";
14
+ export { CachingHost } from "./CachingHost.js";
15
+ export { matchesAnyGlob } from "./matchesAnyGlob.js";
16
+ export { nanosecondsToSanity } from "./nanosecondsToSanity.js";
17
+ export { AggregateTiming } from "./AggregateTiming.js";
18
+ export { Timing } from "./Timing.js";
19
+ export { Table } from "./Table.js";
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,17 @@
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
+ interface MatchesAnyGlob {
8
+ (needle: string, haystack: readonly string[]): boolean | undefined;
9
+ printStats?: () => void;
10
+ }
11
+ export declare const matchesAnyGlob: MatchesAnyGlob;
12
+ /**
13
+ * @deprecated Don't use this directly. We manually inline it above
14
+ */
15
+ export declare function needleInPattern(needle: string, pattern: string): boolean;
16
+ export {};
17
+ //# sourceMappingURL=matchesAnyGlob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchesAnyGlob.d.ts","sourceRoot":"","sources":["../../src/matchesAnyGlob.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH,UAAU,cAAc;IACtB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,CAAC;IACnE,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AACD,eAAO,MAAM,cAAc,EAAE,cAiD5B,CAAC;AAsBF;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WA8B9D"}
@@ -4,5 +4,6 @@
4
4
  * Licensed under the MIT license. See LICENSE file in the project root for details.
5
5
  *
6
6
  */
7
- export declare function mutateJson<T extends object>(path: string, mutator: (f: T) => T): void;
7
+ import { Host } from "./Host.js";
8
+ export declare function mutateJson<T extends object>(path: string, host: Host, mutator: (f: T) => T): void;
8
9
  //# sourceMappingURL=mutateJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutateJson.d.ts","sourceRoot":"","sources":["../../src/mutateJson.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAI1F"}
@@ -0,0 +1,8 @@
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 function nanosecondsToSanity(n: bigint, precision?: number): string;
8
+ //# sourceMappingURL=nanosecondsToSanity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nanosecondsToSanity.d.ts","sourceRoot":"","sources":["../../src/nanosecondsToSanity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,UAEnE"}
package/package.json CHANGED
@@ -1,32 +1,60 @@
1
1
  {
2
2
  "name": "@monorepolint/utils",
3
- "version": "0.5.0-alpha.13+8057489",
3
+ "version": "0.5.0-alpha.131+4a2b5f4",
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
- "main": "lib/index.js",
11
- "typings": "lib/index.d.ts",
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"
23
+ },
12
24
  "scripts": {
13
- "clean": "rm -rf build lib node_modules *.tgz",
14
- "compile:typescript": "../../node_modules/.bin/tsc",
15
- "jest": "../../node_modules/.bin/jest --config ../../jest.config.js",
16
- "jest:watch": "../../node_modules/.bin/jest --config ../../jest.config.js --watch",
17
- "lint": "../../node_modules/.bin/tslint --config ../../tslint.json --project .",
18
- "lint:typescript": "../../node_modules/.bin/tslint --config ../../tslint.json --project .",
19
- "test": "../../node_modules/.bin/jest --colors --passWithNoTests",
20
- "test:watch": "../../node_modules/.bin/jest --colors --passWithNoTests --watch"
25
+ "clean": "rm -rf build dist lib node_modules *.tgz tsconfig.tsbuildinfo",
26
+ "compile-typescript": "tsc --build",
27
+ "lint": "eslint .",
28
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --colors --passWithNoTests",
29
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --colors --passWithNoTests --watch",
30
+ "transpile-typescript": "tsup --config ../../tsup.config.cjs"
21
31
  },
22
32
  "dependencies": {
23
- "glob": "^7.1.3"
33
+ "find-packages": "^10.0.4",
34
+ "find-up": "^7.0.0",
35
+ "glob": "^10.3.0",
36
+ "micromatch": "^4.0.5",
37
+ "read-yaml-file": "^2.1.0",
38
+ "tslib": "^2.6.2"
24
39
  },
25
40
  "devDependencies": {
26
- "@types/glob": "^7.1.1"
41
+ "@jest/globals": "^29.7.0",
42
+ "@types/glob": "^8.1.0",
43
+ "@types/jest": "^29.5.10",
44
+ "@types/micromatch": "^4.0.6",
45
+ "@types/node": "^18.18.14",
46
+ "@typescript-eslint/eslint-plugin": "^6.13.1",
47
+ "@typescript-eslint/parser": "^6.13.1",
48
+ "eslint": "^8.54.0",
49
+ "jest": "^29.7.0",
50
+ "prettier": "^3.1.0",
51
+ "ts-jest": "^29.1.1",
52
+ "tslib": "^2.6.2",
53
+ "tsup": "^8.0.1",
54
+ "typescript": "^5.3.2"
27
55
  },
28
56
  "publishConfig": {
29
57
  "access": "public"
30
58
  },
31
- "gitHead": "805748984b4f67f6e1d067a4dadcd366846c1db5"
59
+ "gitHead": "4a2b5f492e34f088227384b494c018d8fe04d216"
32
60
  }
@@ -0,0 +1,70 @@
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
+ // tslint:disable:no-console
8
+
9
+ import { Table } from "./Table.js";
10
+ export class AggregateTiming {
11
+ #data = new Map<string, { count: number; total: bigint }>();
12
+ #last: { count: number; total: bigint } | undefined;
13
+
14
+ constructor(private title: string) {}
15
+
16
+ public start(name: string) {
17
+ const time = process.hrtime.bigint();
18
+ if (this.#last) {
19
+ this.#last.total += time;
20
+ }
21
+
22
+ let data = this.#data.get(name);
23
+ if (data === undefined) {
24
+ data = { count: 1, total: -time };
25
+ this.#data.set(name, data);
26
+ } else {
27
+ data.total -= time;
28
+ data.count++;
29
+ }
30
+ this.#last = data;
31
+ }
32
+
33
+ public stop() {
34
+ const time = process.hrtime.bigint();
35
+ if (this.#last) {
36
+ this.#last.total += time;
37
+ this.#last = undefined;
38
+ }
39
+ }
40
+
41
+ public printResults() {
42
+ const table = new Table<[bigint, string, bigint, bigint]>({
43
+ sortColumn: -1,
44
+ showFooter: true,
45
+ showHeader: true,
46
+ title: this.title,
47
+ columns: [
48
+ {
49
+ header: "Duration",
50
+ type: "bigint",
51
+ renderAs: "nanoseconds",
52
+ footer: { aggregate: "sum" },
53
+ },
54
+ { header: "Task", type: "string", alignment: "left", footer: "TOTAL" },
55
+ { header: "Count", type: "bigint", footer: { aggregate: "sum" } },
56
+ { header: "Avg", type: "bigint", footer: { aggregate: "average" } },
57
+ ],
58
+ });
59
+
60
+ for (const [name, value] of this.#data) {
61
+ table.addRow(
62
+ value.total,
63
+ name,
64
+ BigInt(value.count), // fixme this can be a number later
65
+ value.total / BigInt(value.count)
66
+ );
67
+ }
68
+ table.print();
69
+ }
70
+ }