@monorepolint/rules 0.5.0-alpha.98 → 0.5.0-beta.1

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 (156) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.json +47 -26
  3. package/src/__tests__/alphabeticalScripts.spec.ts +6 -5
  4. package/src/__tests__/bannedDependencies.spec.ts +5 -7
  5. package/src/__tests__/consistentDependencies.spec.ts +6 -5
  6. package/src/__tests__/consistentVersions.spec.ts +5 -4
  7. package/src/__tests__/fileContents.spec.ts +44 -17
  8. package/src/__tests__/mustSatisfyPeerDependencies.spec.ts +39 -38
  9. package/src/__tests__/nestedWorkspaces.spec.ts +5 -4
  10. package/src/__tests__/packageEntry.spec.ts +43 -32
  11. package/src/__tests__/packageOrder.spec.ts +23 -14
  12. package/src/__tests__/packageScript.spec.ts +61 -43
  13. package/src/__tests__/requireDependency.spec.ts +8 -7
  14. package/src/__tests__/utils.ts +8 -4
  15. package/src/alphabeticalDependencies.ts +7 -12
  16. package/src/alphabeticalScripts.ts +7 -12
  17. package/src/bannedDependencies.ts +9 -12
  18. package/src/consistentDependencies.ts +9 -10
  19. package/src/consistentVersions.ts +6 -8
  20. package/src/fileContents.ts +17 -16
  21. package/src/index.ts +13 -13
  22. package/src/mustSatisfyPeerDependencies.ts +16 -17
  23. package/src/nestedWorkspaces.ts +10 -12
  24. package/src/packageEntry.ts +7 -9
  25. package/src/packageOrder.ts +12 -10
  26. package/src/packageScript.ts +12 -19
  27. package/src/public/util.ts +1 -0
  28. package/src/requireDependency.ts +9 -10
  29. package/src/standardTsconfig.ts +10 -11
  30. package/src/util/checkAlpha.ts +1 -1
  31. package/src/util/makeRule.ts +29 -0
  32. package/src/util/packageDependencyGraphService.ts +2 -2
  33. package/tsconfig.json +7 -2
  34. package/lib/__tests__/alphabeticalScripts.spec.d.ts +0 -8
  35. package/lib/__tests__/alphabeticalScripts.spec.d.ts.map +0 -1
  36. package/lib/__tests__/alphabeticalScripts.spec.js +0 -61
  37. package/lib/__tests__/alphabeticalScripts.spec.js.map +0 -1
  38. package/lib/__tests__/bannedDependencies.spec.d.ts +0 -2
  39. package/lib/__tests__/bannedDependencies.spec.d.ts.map +0 -1
  40. package/lib/__tests__/bannedDependencies.spec.js +0 -161
  41. package/lib/__tests__/bannedDependencies.spec.js.map +0 -1
  42. package/lib/__tests__/consistentDependencies.spec.d.ts +0 -2
  43. package/lib/__tests__/consistentDependencies.spec.d.ts.map +0 -1
  44. package/lib/__tests__/consistentDependencies.spec.js +0 -115
  45. package/lib/__tests__/consistentDependencies.spec.js.map +0 -1
  46. package/lib/__tests__/consistentVersions.spec.d.ts +0 -8
  47. package/lib/__tests__/consistentVersions.spec.d.ts.map +0 -1
  48. package/lib/__tests__/consistentVersions.spec.js +0 -183
  49. package/lib/__tests__/consistentVersions.spec.js.map +0 -1
  50. package/lib/__tests__/fileContents.spec.d.ts +0 -8
  51. package/lib/__tests__/fileContents.spec.d.ts.map +0 -1
  52. package/lib/__tests__/fileContents.spec.js +0 -59
  53. package/lib/__tests__/fileContents.spec.js.map +0 -1
  54. package/lib/__tests__/mustSatisfyPeerDependencies.spec.d.ts +0 -8
  55. package/lib/__tests__/mustSatisfyPeerDependencies.spec.d.ts.map +0 -1
  56. package/lib/__tests__/mustSatisfyPeerDependencies.spec.js +0 -1063
  57. package/lib/__tests__/mustSatisfyPeerDependencies.spec.js.map +0 -1
  58. package/lib/__tests__/nestedWorkspaces.spec.d.ts +0 -2
  59. package/lib/__tests__/nestedWorkspaces.spec.d.ts.map +0 -1
  60. package/lib/__tests__/nestedWorkspaces.spec.js +0 -124
  61. package/lib/__tests__/nestedWorkspaces.spec.js.map +0 -1
  62. package/lib/__tests__/packageEntry.spec.d.ts +0 -8
  63. package/lib/__tests__/packageEntry.spec.d.ts.map +0 -1
  64. package/lib/__tests__/packageEntry.spec.js +0 -144
  65. package/lib/__tests__/packageEntry.spec.js.map +0 -1
  66. package/lib/__tests__/packageOrder.spec.d.ts +0 -8
  67. package/lib/__tests__/packageOrder.spec.d.ts.map +0 -1
  68. package/lib/__tests__/packageOrder.spec.js +0 -116
  69. package/lib/__tests__/packageOrder.spec.js.map +0 -1
  70. package/lib/__tests__/packageScript.spec.d.ts +0 -8
  71. package/lib/__tests__/packageScript.spec.d.ts.map +0 -1
  72. package/lib/__tests__/packageScript.spec.js +0 -171
  73. package/lib/__tests__/packageScript.spec.js.map +0 -1
  74. package/lib/__tests__/requireDependency.spec.d.ts +0 -2
  75. package/lib/__tests__/requireDependency.spec.d.ts.map +0 -1
  76. package/lib/__tests__/requireDependency.spec.js +0 -123
  77. package/lib/__tests__/requireDependency.spec.js.map +0 -1
  78. package/lib/__tests__/utils.d.ts +0 -76
  79. package/lib/__tests__/utils.d.ts.map +0 -1
  80. package/lib/__tests__/utils.js +0 -83
  81. package/lib/__tests__/utils.js.map +0 -1
  82. package/lib/alphabeticalDependencies.d.ts +0 -23
  83. package/lib/alphabeticalDependencies.d.ts.map +0 -1
  84. package/lib/alphabeticalDependencies.js +0 -24
  85. package/lib/alphabeticalDependencies.js.map +0 -1
  86. package/lib/alphabeticalScripts.d.ts +0 -23
  87. package/lib/alphabeticalScripts.d.ts.map +0 -1
  88. package/lib/alphabeticalScripts.js +0 -22
  89. package/lib/alphabeticalScripts.js.map +0 -1
  90. package/lib/bannedDependencies.d.ts +0 -134
  91. package/lib/bannedDependencies.d.ts.map +0 -1
  92. package/lib/bannedDependencies.js +0 -133
  93. package/lib/bannedDependencies.js.map +0 -1
  94. package/lib/consistentDependencies.d.ts +0 -38
  95. package/lib/consistentDependencies.d.ts.map +0 -1
  96. package/lib/consistentDependencies.js +0 -77
  97. package/lib/consistentDependencies.js.map +0 -1
  98. package/lib/consistentVersions.d.ts +0 -47
  99. package/lib/consistentVersions.d.ts.map +0 -1
  100. package/lib/consistentVersions.js +0 -96
  101. package/lib/consistentVersions.js.map +0 -1
  102. package/lib/fileContents.d.ts +0 -111
  103. package/lib/fileContents.d.ts.map +0 -1
  104. package/lib/fileContents.js +0 -84
  105. package/lib/fileContents.js.map +0 -1
  106. package/lib/index.d.ts +0 -20
  107. package/lib/index.d.ts.map +0 -1
  108. package/lib/index.js +0 -49
  109. package/lib/index.js.map +0 -1
  110. package/lib/mustSatisfyPeerDependencies.d.ts +0 -721
  111. package/lib/mustSatisfyPeerDependencies.d.ts.map +0 -1
  112. package/lib/mustSatisfyPeerDependencies.js +0 -638
  113. package/lib/mustSatisfyPeerDependencies.js.map +0 -1
  114. package/lib/nestedWorkspaces.d.ts +0 -24
  115. package/lib/nestedWorkspaces.d.ts.map +0 -1
  116. package/lib/nestedWorkspaces.js +0 -52
  117. package/lib/nestedWorkspaces.js.map +0 -1
  118. package/lib/packageEntry.d.ts +0 -115
  119. package/lib/packageEntry.d.ts.map +0 -1
  120. package/lib/packageEntry.js +0 -77
  121. package/lib/packageEntry.js.map +0 -1
  122. package/lib/packageOrder.d.ts +0 -33
  123. package/lib/packageOrder.d.ts.map +0 -1
  124. package/lib/packageOrder.js +0 -105
  125. package/lib/packageOrder.js.map +0 -1
  126. package/lib/packageScript.d.ts +0 -102
  127. package/lib/packageScript.d.ts.map +0 -1
  128. package/lib/packageScript.js +0 -92
  129. package/lib/packageScript.js.map +0 -1
  130. package/lib/requireDependency.d.ts +0 -99
  131. package/lib/requireDependency.d.ts.map +0 -1
  132. package/lib/requireDependency.js +0 -67
  133. package/lib/requireDependency.js.map +0 -1
  134. package/lib/standardTsconfig.d.ts +0 -113
  135. package/lib/standardTsconfig.d.ts.map +0 -1
  136. package/lib/standardTsconfig.js +0 -118
  137. package/lib/standardTsconfig.js.map +0 -1
  138. package/lib/util/checkAlpha.d.ts +0 -10
  139. package/lib/util/checkAlpha.d.ts.map +0 -1
  140. package/lib/util/checkAlpha.js +0 -51
  141. package/lib/util/checkAlpha.js.map +0 -1
  142. package/lib/util/createNewRuleConversion.d.ts +0 -30
  143. package/lib/util/createNewRuleConversion.d.ts.map +0 -1
  144. package/lib/util/createNewRuleConversion.js +0 -33
  145. package/lib/util/createNewRuleConversion.js.map +0 -1
  146. package/lib/util/makeDirectory.d.ts +0 -8
  147. package/lib/util/makeDirectory.d.ts.map +0 -1
  148. package/lib/util/makeDirectory.js +0 -28
  149. package/lib/util/makeDirectory.js.map +0 -1
  150. package/lib/util/packageDependencyGraphService.d.ts +0 -37
  151. package/lib/util/packageDependencyGraphService.d.ts.map +0 -1
  152. package/lib/util/packageDependencyGraphService.js +0 -70
  153. package/lib/util/packageDependencyGraphService.js.map +0 -1
  154. package/src/util/createNewRuleConversion.ts +0 -38
  155. package/tsconfig.tsbuildinfo +0 -1
  156. /package/{jest.config.js → jest.config.cjs} +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # @monorepolint/rules
2
+
3
+ ## 0.5.0-beta.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @monorepolint/config@0.5.0-beta.1
8
+ - @monorepolint/core@0.5.0-beta.1
9
+ - @monorepolint/utils@0.5.0-beta.1
10
+
11
+ ## 0.5.0-beta.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 45fb496: I failed to take good notes over the last few years. Sorry.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [45fb496]
20
+ - @monorepolint/config@0.5.0-beta.0
21
+ - @monorepolint/core@0.5.0-beta.0
22
+ - @monorepolint/utils@0.5.0-beta.0
package/package.json CHANGED
@@ -1,42 +1,63 @@
1
1
  {
2
2
  "name": "@monorepolint/rules",
3
- "version": "0.5.0-alpha.98+32ec612",
3
+ "version": "0.5.0-beta.1",
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",
12
- "scripts": {
13
- "clean": "rm -rf build lib node_modules *.tgz tsconfig.tsbuildinfo",
14
- "compile:typescript": "../../node_modules/.bin/tsc",
15
- "jest": "../../node_modules/.bin/jest --config ../../jest.config.js",
16
- "jest:watch": "../../node_modules/.bin/jest --watch",
17
- "lint:typescript": "../../node_modules/.bin/tslint --config ../../tslint.json --project .",
18
- "test": "../../node_modules/.bin/jest --colors --passWithNoTests",
19
- "test:watch": "../../node_modules/.bin/jest --colors --passWithNoTests --watch"
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"
20
23
  },
21
24
  "dependencies": {
22
- "@monorepolint/config": "^0.5.0-alpha.98+32ec612",
23
- "@monorepolint/core": "^0.5.0-alpha.98+32ec612",
24
- "@monorepolint/utils": "^0.5.0-alpha.98+32ec612",
25
- "globby": "^11.0.1",
26
- "jest-diff": "^26.0.1",
27
- "resolve-package-path": "^3.1.0",
28
- "runtypes": "^6.5.1",
29
- "semver": "^7.3.2",
30
- "tslib": "^2.3.1"
25
+ "globby": "^14.0.1",
26
+ "jest-diff": "^29.7.0",
27
+ "resolve-package-path": "^4.0.3",
28
+ "runtypes": "^6.7.0",
29
+ "semver": "^7.6.0",
30
+ "tslib": "^2.6.2",
31
+ "@monorepolint/core": "^0.5.0-beta.1",
32
+ "@monorepolint/config": "^0.5.0-beta.1",
33
+ "@monorepolint/utils": "^0.5.0-beta.1"
31
34
  },
32
35
  "devDependencies": {
33
- "@types/jest-diff": "^24.3.0",
34
- "@types/semver": "^7.2.0",
35
- "@types/tmp": "^0.2.0",
36
- "tmp": "^0.2.1"
36
+ "@jest/globals": "^29.7.0",
37
+ "@types/jest": "^29.5.12",
38
+ "@types/semver": "^7.5.8",
39
+ "@types/tmp": "^0.2.6",
40
+ "@typescript-eslint/eslint-plugin": "^7.7.1",
41
+ "@typescript-eslint/parser": "^7.7.1",
42
+ "eslint": "^9.1.1",
43
+ "jest": "^29.7.0",
44
+ "prettier": "^3.2.5",
45
+ "tmp": "^0.2.3",
46
+ "ts-jest": "^29.1.2",
47
+ "tslib": "^2.6.2",
48
+ "tsup": "^8.0.2",
49
+ "typescript": "^5.4.5"
37
50
  },
38
51
  "publishConfig": {
39
52
  "access": "public"
40
53
  },
41
- "gitHead": "32ec6128225ca7b5462bb02375b2d9b03c1d7c3a"
42
- }
54
+ "gitHead": "74320e31cfce7555aece7a98d71d01d2f329be0f",
55
+ "scripts": {
56
+ "clean": "rm -rf build dist lib node_modules *.tgz tsconfig.tsbuildinfo",
57
+ "compile-typescript": "tsc --build",
58
+ "lint": "eslint .",
59
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --colors --passWithNoTests",
60
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --colors --passWithNoTests --watch",
61
+ "transpile-typescript": "tsup --config ../../tsup.config.cjs"
62
+ }
63
+ }
@@ -6,10 +6,11 @@
6
6
  */
7
7
 
8
8
  // tslint:disable:no-console
9
- import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, jsonToString, TestingWorkspace } from "./utils";
9
+ import { describe, expect, it, beforeEach, jest } from "@jest/globals";
10
+ import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, jsonToString, TestingWorkspace } from "./utils.js";
10
11
  import { Context, Failure } from "@monorepolint/config";
11
- import { alphabeticalScripts } from "../alphabeticalScripts";
12
- import { createIncorrectOrderErrorMessage } from "../util/checkAlpha";
12
+ import { alphabeticalScripts } from "../alphabeticalScripts.js";
13
+ import { createIncorrectOrderErrorMessage } from "../util/checkAlpha.js";
13
14
 
14
15
  const PACKAGE_SCRIPTS_SORTED = jsonToString({
15
16
  name: "foo-lib",
@@ -48,7 +49,7 @@ describe.each(HOST_FACTORIES)("alphabeticalScripts ($name)", (hostFactory) => {
48
49
  it("fixes unsorted scripts", () => {
49
50
  workspace.writeFile("package.json", PACKAGE_SCRIPTS_UNSORTED);
50
51
 
51
- alphabeticalScripts.check(context, undefined);
52
+ alphabeticalScripts({}).check(context);
52
53
 
53
54
  expect(spy).toHaveBeenCalledTimes(1);
54
55
 
@@ -67,7 +68,7 @@ describe.each(HOST_FACTORIES)("alphabeticalScripts ($name)", (hostFactory) => {
67
68
  it("does nothing if already sorted", () => {
68
69
  workspace.writeFile("package.json", PACKAGE_SCRIPTS_SORTED);
69
70
 
70
- alphabeticalScripts.check(context, undefined);
71
+ alphabeticalScripts({}).check(context);
71
72
 
72
73
  expect(spy).toHaveBeenCalledTimes(0);
73
74
  });
@@ -4,15 +4,15 @@
4
4
  * Licensed under the MIT license. See LICENSE file in the project root for details.
5
5
  *
6
6
  */
7
+ import { describe, expect, it, beforeEach, jest, afterEach } from "@jest/globals";
7
8
  import { WorkspaceContextImpl } from "@monorepolint/core";
8
9
  import { SimpleHost } from "@monorepolint/utils";
9
10
  import { writeFileSync } from "fs";
10
11
  import * as path from "path";
11
12
  import * as tmp from "tmp";
12
- import { bannedDependencies, Options } from "../bannedDependencies";
13
- import { makeDirectoryRecursively } from "../util/makeDirectory";
14
- import { jsonToString } from "./utils";
15
-
13
+ import { bannedDependencies, Options } from "../bannedDependencies.js";
14
+ import { makeDirectoryRecursively } from "../util/makeDirectory.js";
15
+ import { jsonToString } from "./utils.js";
16
16
  const EMPTY_PACKAGE = jsonToString({});
17
17
 
18
18
  describe("bannedDependencies", () => {
@@ -51,9 +51,7 @@ describe("bannedDependencies", () => {
51
51
 
52
52
  function checkAndSpy(options: Options) {
53
53
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
54
- bannedDependencies.check(workspaceContext, {
55
- ...options,
56
- });
54
+ bannedDependencies({ options }).check(workspaceContext);
57
55
  return { addErrorSpy };
58
56
  }
59
57
 
@@ -9,9 +9,10 @@ import { SimpleHost } from "@monorepolint/utils";
9
9
  import { readFileSync, writeFileSync } from "fs";
10
10
  import * as path from "path";
11
11
  import * as tmp from "tmp";
12
- import { consistentDependencies, Options } from "../consistentDependencies";
13
- import { makeDirectoryRecursively } from "../util/makeDirectory";
14
- import { jsonToString } from "./utils";
12
+ import { consistentDependencies, Options } from "../consistentDependencies.js";
13
+ import { makeDirectoryRecursively } from "../util/makeDirectory.js";
14
+ import { jsonToString } from "./utils.js";
15
+ import { describe, expect, it, afterEach, jest } from "@jest/globals";
15
16
 
16
17
  const PACKAGE_ROOT = jsonToString({
17
18
  workspaces: {
@@ -76,7 +77,7 @@ describe("consistentDependencies", () => {
76
77
  function checkAndSpy(q: string, opts?: Options) {
77
78
  const context = workspaceContext.createChildContext(path.resolve(dir.name, q));
78
79
  const addErrorSpy = jest.spyOn(context, "addError");
79
- consistentDependencies.check(context, opts);
80
+ consistentDependencies({ options: opts }).check(context);
80
81
  return { context, addErrorSpy };
81
82
  }
82
83
 
@@ -103,7 +104,7 @@ describe("consistentDependencies", () => {
103
104
  addFile("./packages/right/package.json", PACKAGE_CHILD_WITH_RIGHT_VERSION);
104
105
  addFile("./packages/wrong/package.json", PACKAGE_CHILD_WITH_WRONG_VERSION);
105
106
 
106
- consistentDependencies.check(workspaceContext, undefined);
107
+ consistentDependencies({}).check(workspaceContext);
107
108
 
108
109
  const star = checkAndSpy("./packages/star");
109
110
  expect(star.addErrorSpy).toHaveBeenCalledTimes(0);
@@ -9,8 +9,9 @@ import { WorkspaceContextImpl } from "@monorepolint/core";
9
9
  import { Host, PackageJson, SimpleHost } from "@monorepolint/utils";
10
10
  import * as path from "path";
11
11
  import * as tmp from "tmp";
12
- import { consistentVersions, Options } from "../consistentVersions";
13
- import { makeDirectoryRecursively } from "../util/makeDirectory";
12
+ import { consistentVersions, Options } from "../consistentVersions.js";
13
+ import { makeDirectoryRecursively } from "../util/makeDirectory.js";
14
+ import { describe, expect, it, beforeEach, afterEach, jest } from "@jest/globals";
14
15
 
15
16
  describe("consistentVersions", () => {
16
17
  tmp.setGracefulCleanup();
@@ -49,7 +50,7 @@ describe("consistentVersions", () => {
49
50
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
50
51
 
51
52
  function check(options: Options = { matchDependencyVersions: {} }) {
52
- consistentVersions.check(workspaceContext, options);
53
+ consistentVersions({ options }).check(workspaceContext);
53
54
  }
54
55
 
55
56
  return { addErrorSpy, check, host };
@@ -62,7 +63,7 @@ describe("consistentVersions", () => {
62
63
  makeDirectoryRecursively(dirPath);
63
64
  host.writeJson(resolvedFilePath, packageJson);
64
65
  return (): PackageJson => {
65
- return host.readJson(resolvedFilePath);
66
+ return host.readJson(resolvedFilePath) as PackageJson;
66
67
  };
67
68
  }
68
69
 
@@ -6,16 +6,17 @@
6
6
  */
7
7
 
8
8
  // tslint:disable:no-console
9
- import { createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils";
9
+ import { createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
10
10
  import { AddErrorOptions, Failure } from "@monorepolint/config";
11
- import { fileContents } from "../fileContents";
11
+ import { fileContents } from "../fileContents.js";
12
+ import { describe, expect, it, beforeEach, jest } from "@jest/globals";
12
13
 
13
14
  const EXPECTED_FOO_FILE = "hello world";
14
15
 
15
16
  describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
16
17
  describe("fix: true", () => {
17
18
  let workspace: TestingWorkspace;
18
- let spy: jest.SpyInstance<void, [AddErrorOptions]>;
19
+ let spy: jest.SpiedFunction<(opts: AddErrorOptions) => void>;
19
20
 
20
21
  beforeEach(async () => {
21
22
  workspace = await createTestingWorkspace({
@@ -27,13 +28,13 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
27
28
  spy = jest.spyOn(workspace.context, "addError");
28
29
  });
29
30
 
30
- it("fixes missing file", () => {
31
- fileContents.check(workspace.context, {
32
- file: "foo.txt",
33
- templateFile: "shared/foo-template.txt",
34
- generator: undefined,
35
- template: undefined,
36
- });
31
+ it("works with async generator", async () => {
32
+ await fileContents({
33
+ options: {
34
+ file: "foo.txt",
35
+ generator: () => Promise.resolve(EXPECTED_FOO_FILE),
36
+ },
37
+ }).check(workspace.context);
37
38
 
38
39
  expect(spy).toHaveBeenCalledTimes(1);
39
40
 
@@ -49,13 +50,39 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
49
50
  expect(workspace.readFile("foo.txt")).toEqual(EXPECTED_FOO_FILE);
50
51
  });
51
52
 
52
- it("fixes missing nested file", () => {
53
- fileContents.check(workspace.context, {
54
- file: "nested/foo.txt",
55
- templateFile: "shared/foo-template.txt",
56
- generator: undefined,
57
- template: undefined,
58
- });
53
+ it("fixes missing file", async () => {
54
+ await fileContents({
55
+ options: {
56
+ file: "foo.txt",
57
+ templateFile: "shared/foo-template.txt",
58
+ generator: undefined,
59
+ template: undefined,
60
+ },
61
+ }).check(workspace.context);
62
+
63
+ expect(spy).toHaveBeenCalledTimes(1);
64
+
65
+ const failure: Failure = spy.mock.calls[0][0];
66
+ expect(failure).toMatchObject(
67
+ workspace.failureMatcher({
68
+ file: "foo.txt",
69
+ hasFixer: true,
70
+ message: "Expect file contents to match",
71
+ })
72
+ );
73
+
74
+ expect(workspace.readFile("foo.txt")).toEqual(EXPECTED_FOO_FILE);
75
+ });
76
+
77
+ it("fixes missing nested file", async () => {
78
+ await fileContents({
79
+ options: {
80
+ file: "nested/foo.txt",
81
+ templateFile: "shared/foo-template.txt",
82
+ generator: undefined,
83
+ template: undefined,
84
+ },
85
+ }).check(workspace.context);
59
86
 
60
87
  expect(spy).toHaveBeenCalledTimes(1);
61
88
 
@@ -19,8 +19,9 @@ import {
19
19
  mustSatisfyPeerDependencies,
20
20
  Options,
21
21
  RANGE_REGEX,
22
- } from "../mustSatisfyPeerDependencies";
23
- import { makeDirectoryRecursively } from "../util/makeDirectory";
22
+ } from "../mustSatisfyPeerDependencies.js";
23
+ import { makeDirectoryRecursively } from "../util/makeDirectory.js";
24
+ import { describe, expect, it, beforeEach, afterEach, jest } from "@jest/globals";
24
25
 
25
26
  const doesASatisfyB = (a: string, b: string) => {
26
27
  if (!isValidRange(a)) {
@@ -78,8 +79,8 @@ describe("mustSatisfyPeerDependencies", () => {
78
79
  );
79
80
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
80
81
 
81
- function check(options: Options) {
82
- mustSatisfyPeerDependencies.check(workspaceContext, options);
82
+ async function check(options: Options) {
83
+ await mustSatisfyPeerDependencies({ options }).check(workspaceContext);
83
84
  }
84
85
 
85
86
  return { addErrorSpy, check, host };
@@ -92,7 +93,7 @@ describe("mustSatisfyPeerDependencies", () => {
92
93
  makeDirectoryRecursively(dirPath);
93
94
  host.writeJson(resolvedFilePath, packageJson);
94
95
  return (): PackageJson => {
95
- return host.readJson(resolvedFilePath);
96
+ return host.readJson(resolvedFilePath) as PackageJson;
96
97
  };
97
98
  }
98
99
 
@@ -844,7 +845,7 @@ describe("mustSatisfyPeerDependencies", () => {
844
845
  };
845
846
  addPackageJson(host, "./node_modules/greatLib/package.json", greatLibPackageJson);
846
847
 
847
- check({});
848
+ await check({});
848
849
  expect(addErrorSpy).toHaveBeenCalledTimes(1);
849
850
  expect(addErrorSpy.mock.calls[0][0].message).toEqual(
850
851
  `[0] Package ${testPackageJson.name} has overloaded greatLib dependencies.\n\t` +
@@ -894,7 +895,7 @@ describe("mustSatisfyPeerDependencies", () => {
894
895
  };
895
896
  addPackageJson(host, "./node_modules/ccc/package.json", cccPackageJson);
896
897
 
897
- check({});
898
+ await check({});
898
899
  expect(addErrorSpy).toHaveBeenCalledTimes(1);
899
900
  expect(addErrorSpy.mock.calls[0][0].message).toEqual(
900
901
  `[1] Package ${testPackageJson.name} has conflicting inherited greatLib peer dependencies.\n\t` +
@@ -903,7 +904,7 @@ describe("mustSatisfyPeerDependencies", () => {
903
904
  );
904
905
  addErrorSpy.mockReset();
905
906
 
906
- check({ enforceForDevDependencies: true });
907
+ await check({ enforceForDevDependencies: true });
907
908
  expect(addErrorSpy).toHaveBeenCalledTimes(2);
908
909
  expect(addErrorSpy.mock.calls[1][0].message).toEqual(
909
910
  `[1] Package ${testPackageJson.name} has conflicting inherited greatestLib peer dependencies.\n\t` +
@@ -955,7 +956,7 @@ describe("mustSatisfyPeerDependencies", () => {
955
956
  };
956
957
  addPackageJson(host, "./node_modules/ccc/package.json", cccPackageJson);
957
958
 
958
- check({});
959
+ await check({});
959
960
  expect(addErrorSpy).toHaveBeenCalledTimes(1);
960
961
  expect(addErrorSpy.mock.calls[0][0].message).toEqual(
961
962
  `[2] Package ${testPackageJson.name} dependency on greatLib '${testPackageJson.dependencies.greatLib}' does not satisfy inherited peer dependencies.\n\t` +
@@ -963,7 +964,7 @@ describe("mustSatisfyPeerDependencies", () => {
963
964
  );
964
965
  addErrorSpy.mockReset();
965
966
 
966
- check({ enforceForDevDependencies: true });
967
+ await check({ enforceForDevDependencies: true });
967
968
  expect(addErrorSpy).toHaveBeenCalledTimes(1);
968
969
  expect(addErrorSpy.mock.calls[0][0].message).toEqual(
969
970
  `[2] Package ${testPackageJson.name} dependency on greatLib '${testPackageJson.dependencies.greatLib}' does not satisfy inherited peer dependencies.\n\t` +
@@ -984,32 +985,32 @@ describe("mustSatisfyPeerDependencies", () => {
984
985
  devDependencies: {
985
986
  ccc: "0.0.1",
986
987
  },
987
- };
988
+ } as const;
988
989
  const readTestPackageJson = addPackageJson(host, "./package.json", testPackageJson);
989
990
 
990
991
  const aaaPackageJson = {
991
- name: "a",
992
+ name: "aaa",
992
993
  peerDependencies: {
993
994
  greatLib: "15 || ^16.2",
994
995
  },
995
- };
996
+ } as const;
996
997
  addPackageJson(host, "./node_modules/aaa/package.json", aaaPackageJson);
997
998
  const bbbPackageJson = {
998
- name: "b",
999
+ name: "bbbb",
999
1000
  peerDependencies: {
1000
1001
  greatLib: "^16",
1001
1002
  },
1002
- };
1003
+ } as const;
1003
1004
  addPackageJson(host, "./node_modules/bbb/package.json", bbbPackageJson);
1004
1005
  const cccPackageJson = {
1005
- name: "c",
1006
+ name: "ccc",
1006
1007
  peerDependencies: {
1007
1008
  greatestLib: "100",
1008
1009
  },
1009
- };
1010
+ } as const;
1010
1011
  addPackageJson(host, "./node_modules/ccc/package.json", cccPackageJson);
1011
1012
 
1012
- check({});
1013
+ await check({});
1013
1014
  expect(addErrorSpy).toHaveBeenCalledTimes(1);
1014
1015
  expect(addErrorSpy.mock.calls[0][0].message).toEqual(
1015
1016
  `[3] Package ${testPackageJson.name} is missing required greatLib dependency.\n\t` +
@@ -1020,9 +1021,9 @@ describe("mustSatisfyPeerDependencies", () => {
1020
1021
  expect(readTestPackageJson().peerDependencies!.greatLib).toEqual("^16.2");
1021
1022
  addErrorSpy.mockReset();
1022
1023
 
1023
- check({ enforceForDevDependencies: true });
1024
- expect(addErrorSpy).toHaveBeenCalledTimes(2);
1025
- expect(addErrorSpy.mock.calls[1][0].message).toEqual(
1024
+ await check({ enforceForDevDependencies: true });
1025
+ expect(addErrorSpy).toHaveBeenCalledTimes(1);
1026
+ expect(addErrorSpy.mock.calls[0][0].message).toEqual(
1026
1027
  `[3] Package ${testPackageJson.name} is missing required greatestLib dependency.\n\t` +
1027
1028
  `Dependency ${cccPackageJson.name} requires '${cccPackageJson.peerDependencies.greatestLib}'.`
1028
1029
  );
@@ -1044,32 +1045,32 @@ describe("mustSatisfyPeerDependencies", () => {
1044
1045
  devDependencies: {
1045
1046
  ccc: "0.0.1",
1046
1047
  },
1047
- };
1048
+ } as const;
1048
1049
  const readTestPackageJson = addPackageJson(host, "./package.json", testPackageJson);
1049
1050
 
1050
1051
  const aaaPackageJson = {
1051
- name: "a",
1052
+ name: "aaa",
1052
1053
  peerDependencies: {
1053
1054
  greatLib: "15 || ^16",
1054
1055
  },
1055
- };
1056
+ } as const;
1056
1057
  addPackageJson(host, "./node_modules/aaa/package.json", aaaPackageJson);
1057
1058
  const bbbPackageJson = {
1058
- name: "b",
1059
+ name: "bbb",
1059
1060
  peerDependencies: {
1060
1061
  greatLib: "^16",
1061
1062
  },
1062
- };
1063
+ } as const;
1063
1064
  addPackageJson(host, "./node_modules/bbb/package.json", bbbPackageJson);
1064
1065
  const cccPackageJson = {
1065
- name: "c",
1066
+ name: "ccc",
1066
1067
  peerDependencies: {
1067
1068
  greatLib: "^16.2",
1068
1069
  },
1069
- };
1070
+ } as const;
1070
1071
  addPackageJson(host, "./node_modules/ccc/package.json", cccPackageJson);
1071
1072
 
1072
- check({});
1073
+ await check({});
1073
1074
  expect(addErrorSpy).toHaveBeenCalledTimes(1);
1074
1075
  expect(addErrorSpy.mock.calls[0][0].message).toEqual(
1075
1076
  `[4] Package ${testPackageJson.name} peer dependency on greatLib '${testPackageJson.peerDependencies.greatLib}' is not strict enough.\n\t` +
@@ -1078,10 +1079,10 @@ describe("mustSatisfyPeerDependencies", () => {
1078
1079
  expect(readTestPackageJson().peerDependencies!.greatLib).toEqual(bbbPackageJson.peerDependencies.greatLib);
1079
1080
  addErrorSpy.mockReset();
1080
1081
 
1081
- check({ enforceForDevDependencies: true });
1082
+ await check({ enforceForDevDependencies: true });
1082
1083
  expect(addErrorSpy).toHaveBeenCalledTimes(1);
1083
1084
  expect(addErrorSpy.mock.calls[0][0].message).toEqual(
1084
- `[4] Package ${testPackageJson.name} peer dependency on greatLib '${testPackageJson.peerDependencies.greatLib}' is not strict enough.\n\t` +
1085
+ `[4] Package ${testPackageJson.name} peer dependency on greatLib '${bbbPackageJson.peerDependencies.greatLib}' is not strict enough.\n\t` +
1085
1086
  `Dependency ${cccPackageJson.name} requires '${cccPackageJson.peerDependencies.greatLib}'.`
1086
1087
  );
1087
1088
  addErrorSpy.mockReset();
@@ -1127,9 +1128,9 @@ describe("mustSatisfyPeerDependencies", () => {
1127
1128
  };
1128
1129
  addPackageJson(host, "./node_modules/bbb/package.json", bbbPackageJson);
1129
1130
 
1130
- check({ dependencyWhitelist: ["startHere"] });
1131
+ await check({ dependencyWhitelist: ["startHere"] });
1131
1132
  expect(addErrorSpy).toHaveBeenCalledTimes(0);
1132
- check({ dependencyWhitelist: ["startHere", "greatLib"] });
1133
+ await check({ dependencyWhitelist: ["startHere", "greatLib"] });
1133
1134
  expect(addErrorSpy).toHaveBeenCalledTimes(2);
1134
1135
  });
1135
1136
 
@@ -1159,29 +1160,29 @@ describe("mustSatisfyPeerDependencies", () => {
1159
1160
  };
1160
1161
  addPackageJson(host, "./node_modules/greatLib/package.json", greatLibPackageJson);
1161
1162
  const aaaPackageJson = {
1162
- name: "a",
1163
+ name: "aaa",
1163
1164
  peerDependencies: {
1164
1165
  greatLib: "15",
1165
1166
  },
1166
1167
  };
1167
1168
  addPackageJson(host, "./node_modules/aaa/package.json", aaaPackageJson);
1168
1169
  const bbbPackageJson = {
1169
- name: "b",
1170
+ name: "bbb",
1170
1171
  peerDependencies: {
1171
1172
  greatLib: "16",
1172
1173
  },
1173
1174
  };
1174
1175
  addPackageJson(host, "./node_modules/bbb/package.json", bbbPackageJson);
1175
1176
 
1176
- check({ dependencyBlacklist: ["greatLib"] });
1177
+ await check({ dependencyBlacklist: ["greatLib"] });
1177
1178
  expect(addErrorSpy).toHaveBeenCalledTimes(0);
1178
1179
  addErrorSpy.mockReset();
1179
1180
 
1180
- check({ dependencyBlacklist: ["greatLib"], dependencyWhitelist: ["greatLib"] });
1181
+ await check({ dependencyBlacklist: ["greatLib"], dependencyWhitelist: ["greatLib"] });
1181
1182
  expect(addErrorSpy).toHaveBeenCalledTimes(0);
1182
1183
  addErrorSpy.mockReset();
1183
1184
 
1184
- check({});
1185
+ await check({});
1185
1186
  expect(addErrorSpy).toHaveBeenCalledTimes(2);
1186
1187
  addErrorSpy.mockReset();
1187
1188
  });
@@ -9,9 +9,10 @@ import { SimpleHost } from "@monorepolint/utils";
9
9
  import { writeFileSync } from "fs";
10
10
  import * as path from "path";
11
11
  import * as tmp from "tmp";
12
- import { nestedWorkspaces } from "../nestedWorkspaces";
13
- import { makeDirectoryRecursively } from "../util/makeDirectory";
14
- import { jsonToString } from "./utils";
12
+ import { nestedWorkspaces } from "../nestedWorkspaces.js";
13
+ import { makeDirectoryRecursively } from "../util/makeDirectory.js";
14
+ import { jsonToString } from "./utils.js";
15
+ import { describe, expect, it, beforeEach, afterEach, jest } from "@jest/globals";
15
16
 
16
17
  const EMPTY_PACKAGE = jsonToString({});
17
18
 
@@ -71,7 +72,7 @@ describe("nestedWorkspaces", () => {
71
72
  async function checkAndSpy() {
72
73
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
73
74
 
74
- await nestedWorkspaces.check(workspaceContext, undefined);
75
+ await nestedWorkspaces({}).check(workspaceContext);
75
76
  return { addErrorSpy };
76
77
  }
77
78