@smoothbricks/nx-plugin 0.7.16 → 0.7.18

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 (119) hide show
  1. package/README.md +210 -64
  2. package/dist/.build-inputs.json +28 -23
  3. package/dist/bun-lock-scope.d.ts +128 -20
  4. package/dist/bun-lock-scope.d.ts.map +1 -1
  5. package/dist/bun-lock-scope.js +267 -44
  6. package/dist/cargo-closure-input.d.ts +8 -6
  7. package/dist/cargo-closure-input.d.ts.map +1 -1
  8. package/dist/cargo-closure-input.js +14 -11
  9. package/dist/cargo-source-hash.d.ts +23 -4
  10. package/dist/cargo-source-hash.d.ts.map +1 -1
  11. package/dist/cargo-source-hash.js +80 -14
  12. package/dist/cargo-workspace.d.ts +20 -2
  13. package/dist/cargo-workspace.d.ts.map +1 -1
  14. package/dist/cargo-workspace.js +42 -22
  15. package/dist/compile-environment.d.ts +8 -0
  16. package/dist/compile-environment.d.ts.map +1 -0
  17. package/dist/compile-environment.js +80 -0
  18. package/dist/dependency-manifests.d.ts +13 -0
  19. package/dist/dependency-manifests.d.ts.map +1 -0
  20. package/dist/dependency-manifests.js +20 -0
  21. package/dist/ensure-built-receipt.d.ts +3 -2
  22. package/dist/ensure-built-receipt.d.ts.map +1 -1
  23. package/dist/ensure-built-receipt.js +3 -2
  24. package/dist/eslint-config-closure.d.ts +8 -3
  25. package/dist/eslint-config-closure.d.ts.map +1 -1
  26. package/dist/eslint-config-closure.js +24 -5
  27. package/dist/executors/bounded-exec/bounds.d.ts +12 -1
  28. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  29. package/dist/executors/bounded-exec/bounds.js +8 -4
  30. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  31. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  32. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  33. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  34. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  35. package/dist/executors/bounded-exec/executor.js +54 -22
  36. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +8 -0
  37. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/hang-diagnostics.js +66 -6
  39. package/dist/executors/bounded-exec/mbx-pool.d.ts +16 -2
  40. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/mbx-pool.js +18 -2
  42. package/dist/executors/bounded-exec/mbx-reservations.d.ts +5 -2
  43. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  44. package/dist/executors/bounded-exec/mbx-reservations.js +5 -3
  45. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  46. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  48. package/dist/executors/bounded-exec/progress.d.ts +2 -1
  49. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  51. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  52. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  53. package/dist/executors/bounded-exec/schema.d.ts +5 -0
  54. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  55. package/dist/executors/bounded-exec/schema.js +17 -1
  56. package/dist/executors/bounded-exec/verdict.d.ts +13 -6
  57. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  58. package/dist/executors/bounded-exec/verdict.js +34 -9
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +216 -97
  61. package/dist/managed-files/files.d.ts +3 -3
  62. package/dist/managed-files/files.js +3 -3
  63. package/dist/managed-files/generator.d.ts +5 -1
  64. package/dist/managed-files/generator.d.ts.map +1 -1
  65. package/dist/managed-files/generator.js +22 -7
  66. package/dist/managed-files/render-memo.d.ts +13 -0
  67. package/dist/managed-files/render-memo.d.ts.map +1 -0
  68. package/dist/managed-files/render-memo.js +94 -0
  69. package/dist/test-program.d.ts +11 -6
  70. package/dist/test-program.d.ts.map +1 -1
  71. package/dist/test-program.js +39 -35
  72. package/dist/tool-bins.d.ts +12 -0
  73. package/dist/tool-bins.d.ts.map +1 -1
  74. package/dist/tool-bins.js +31 -6
  75. package/dist/typecheck-route.d.ts +3 -4
  76. package/dist/typecheck-route.d.ts.map +1 -1
  77. package/dist/typecheck-route.js +4 -15
  78. package/dist/typecheck-test-policy.d.ts +10 -1
  79. package/dist/typecheck-test-policy.d.ts.map +1 -1
  80. package/dist/typecheck-test-policy.js +40 -24
  81. package/dist/workspace-index.d.ts +14 -1
  82. package/dist/workspace-index.d.ts.map +1 -1
  83. package/dist/workspace-index.js +36 -4
  84. package/managed/raw/patches/nx@24.0.3.patch +703 -119
  85. package/managed/raw/patches/{ttsc@0.34.1.patch → ttsc@0.36.3.patch} +728 -71
  86. package/managed/raw/tooling/direnv/developer-links.ts +17 -3
  87. package/managed/raw/tooling/direnv/devenv.smoo.nix +1 -1
  88. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  89. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  90. package/package.json +5 -4
  91. package/src/bun-lock-scope.ts +293 -40
  92. package/src/cargo-closure-input.ts +19 -11
  93. package/src/cargo-source-hash.ts +103 -13
  94. package/src/cargo-workspace.ts +59 -20
  95. package/src/compile-environment.ts +35 -0
  96. package/src/dependency-manifests.ts +30 -0
  97. package/src/ensure-built-receipt.ts +3 -2
  98. package/src/eslint-config-closure.ts +27 -6
  99. package/src/executors/bounded-exec/bounds.ts +13 -4
  100. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  101. package/src/executors/bounded-exec/executor.ts +65 -21
  102. package/src/executors/bounded-exec/hang-diagnostics.ts +88 -6
  103. package/src/executors/bounded-exec/mbx-pool.ts +24 -3
  104. package/src/executors/bounded-exec/mbx-reservations.ts +7 -5
  105. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  106. package/src/executors/bounded-exec/progress.ts +2 -1
  107. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  108. package/src/executors/bounded-exec/schema.ts +19 -0
  109. package/src/executors/bounded-exec/verdict.ts +44 -16
  110. package/src/index.ts +272 -106
  111. package/src/managed-files/files.ts +3 -3
  112. package/src/managed-files/generator.ts +21 -6
  113. package/src/managed-files/render-memo.ts +135 -0
  114. package/src/test-program.ts +36 -41
  115. package/src/tool-bins.ts +35 -6
  116. package/src/typecheck-route.ts +5 -14
  117. package/src/typecheck-test-policy.ts +49 -24
  118. package/src/workspace-index.ts +40 -5
  119. package/test-timings.json +6 -0
@@ -1,9 +1,11 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { createProjectGraphAsync, getProjects, joinPathFragments, readJson } from 'nx/src/devkit-exports.js';
2
- import { renderTypecheckTestFiles } from '../typecheck-test-policy.js';
3
+ import { renderTypecheckTestFiles, treeSourceListing } from '../typecheck-test-policy.js';
3
4
  import { deriveManagedFileContext } from './context.js';
4
5
  import { renderManagedFiles } from './files.js';
5
6
  import { formatManagedContent } from './managed-format.js';
6
7
  import { inspectManagedPaths } from './paths.js';
8
+ import { renderedOnChange } from './render-memo.js';
7
9
  import { assertNoManagedConflicts, stageManagedFiles } from './tree.js';
8
10
  /**
9
11
  * All workspace content comes from Tree. The supplied graph is Nx's resolved
@@ -22,13 +24,26 @@ export async function generateManagedFiles(tree, projects, pathInfo) {
22
24
  });
23
25
  return generateManagedFilesForContext(tree, deriveManagedFileContext(manifest, packages, projects, tree.exists('bun.lock'), tree.read('.npmrc', 'utf8') ?? ''), pathInfo);
24
26
  }
25
- /** Shared rendering boundary; stage only after every consumer formatter has succeeded. */
27
+ /**
28
+ * Shared rendering boundary; stage only after every consumer formatter has succeeded. The render is a function of the
29
+ * context, the workspace's source listing and what it reads through the Tree, so it runs again only when one of those
30
+ * changed (`renderedOnChange`); staging always compares against the Tree as it is.
31
+ */
26
32
  export async function generateManagedFilesForContext(tree, context, pathInfo) {
27
- const files = [...renderManagedFiles(context), ...renderTypecheckTestFiles(tree)];
28
- for (const file of files) {
29
- if (file.content !== null)
30
- file.content = await formatManagedContent(tree.root, file.target, file.content);
31
- }
33
+ const listing = treeSourceListing(tree);
34
+ const key = createHash('sha256')
35
+ .update(JSON.stringify(context))
36
+ .update('\0')
37
+ .update(listing.join('\0'))
38
+ .digest('hex');
39
+ const files = await renderedOnChange(tree, key, async (reading) => {
40
+ const rendered = [...renderManagedFiles(context), ...renderTypecheckTestFiles(reading, listing)];
41
+ for (const file of rendered) {
42
+ if (file.content !== null)
43
+ file.content = await formatManagedContent(reading.root, file.target, file.content);
44
+ }
45
+ return rendered;
46
+ });
32
47
  const paths = pathInfo ??
33
48
  inspectManagedPaths(tree.root, files.filter((file) => file.content !== null).map((file) => file.target));
34
49
  return stageManagedFiles(tree, files, paths);
@@ -0,0 +1,13 @@
1
+ import type { Tree } from 'nx/src/devkit-exports.js';
2
+ import type { ManagedFile } from './tree.js';
3
+ /**
4
+ * The files `render` gives for `tree`, rendered again only when one of its inputs changed: `key`, which names what the
5
+ * render reads beside the Tree (the context, the source listing), or an answer the Tree gave it. Checking the answers
6
+ * reads each file the last render read, once; the render itself (policy, JSON edits, formatter runs) is skipped.
7
+ *
8
+ * A Tree with pending edits is rendered and nothing is kept: no later Tree shows those edits as they are here.
9
+ * The formatters' own configuration is not an answer: Prettier and Biome read it from disk, and Prettier keeps it for
10
+ * the life of the process, so a daemon already formats with what it first read.
11
+ */
12
+ export declare function renderedOnChange(tree: Tree, key: string, render: (tree: Tree) => Promise<ManagedFile[]>): Promise<readonly ManagedFile[]>;
13
+ //# sourceMappingURL=render-memo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-memo.d.ts","sourceRoot":"","sources":["../../src/managed-files/render-memo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAyG7C;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,GAC7C,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAcjC"}
@@ -0,0 +1,94 @@
1
+ import { createHash } from 'node:crypto';
2
+ /** The last render of each workspace root. Replaced by the next render of that root; never expired by time. */
3
+ const renders = new Map();
4
+ function readValue(bytes) {
5
+ return bytes === null ? 'absent' : createHash('sha256').update(bytes).digest('base64');
6
+ }
7
+ function answerOf(tree, question, path) {
8
+ switch (question) {
9
+ case 'read':
10
+ return readValue(tree.read(path));
11
+ case 'exists':
12
+ return String(tree.exists(path));
13
+ case 'isFile':
14
+ return String(tree.isFile(path));
15
+ case 'children':
16
+ return JSON.stringify(tree.children(path));
17
+ }
18
+ }
19
+ /**
20
+ * A Tree that answers from another and keeps every answer it gave. A render that reads the workspace only through
21
+ * it is a function of those answers and of what its caller keys it on. It refuses every write: a render reads the
22
+ * Tree, and staging alone writes it.
23
+ */
24
+ class AnsweringTree {
25
+ tree;
26
+ answers = new Map();
27
+ constructor(tree) {
28
+ this.tree = tree;
29
+ }
30
+ get root() {
31
+ return this.tree.root;
32
+ }
33
+ read(filePath, encoding) {
34
+ const bytes = this.tree.read(filePath);
35
+ this.keep('read', filePath, readValue(bytes));
36
+ return bytes === null || encoding === undefined ? bytes : bytes.toString(encoding);
37
+ }
38
+ exists(filePath) {
39
+ return this.keep('exists', filePath, String(this.tree.exists(filePath))) === 'true';
40
+ }
41
+ isFile(filePath) {
42
+ return this.keep('isFile', filePath, String(this.tree.isFile(filePath))) === 'true';
43
+ }
44
+ children(dirPath) {
45
+ const children = this.tree.children(dirPath);
46
+ this.keep('children', dirPath, JSON.stringify(children));
47
+ return children;
48
+ }
49
+ listChanges() {
50
+ return this.tree.listChanges();
51
+ }
52
+ write(filePath) {
53
+ throw readOnly(filePath);
54
+ }
55
+ delete(filePath) {
56
+ throw readOnly(filePath);
57
+ }
58
+ rename(from) {
59
+ throw readOnly(from);
60
+ }
61
+ changePermissions(filePath) {
62
+ throw readOnly(filePath);
63
+ }
64
+ keep(question, path, value) {
65
+ this.answers.set(`${question}\0${path}`, { question, path, value });
66
+ return value;
67
+ }
68
+ }
69
+ function readOnly(path) {
70
+ return new Error(`${path}: a managed-files render reads the Tree; only staging writes it`);
71
+ }
72
+ /**
73
+ * The files `render` gives for `tree`, rendered again only when one of its inputs changed: `key`, which names what the
74
+ * render reads beside the Tree (the context, the source listing), or an answer the Tree gave it. Checking the answers
75
+ * reads each file the last render read, once; the render itself (policy, JSON edits, formatter runs) is skipped.
76
+ *
77
+ * A Tree with pending edits is rendered and nothing is kept: no later Tree shows those edits as they are here.
78
+ * The formatters' own configuration is not an answer: Prettier and Biome read it from disk, and Prettier keeps it for
79
+ * the life of the process, so a daemon already formats with what it first read.
80
+ */
81
+ export async function renderedOnChange(tree, key, render) {
82
+ if (tree.listChanges().length > 0)
83
+ return render(tree);
84
+ const last = renders.get(tree.root);
85
+ if (last !== undefined &&
86
+ last.key === key &&
87
+ last.answers.every(({ question, path, value }) => answerOf(tree, question, path) === value)) {
88
+ return last.files;
89
+ }
90
+ const answering = new AnsweringTree(tree);
91
+ const files = await render(answering);
92
+ renders.set(tree.root, { key, answers: [...answering.answers.values()], files });
93
+ return files;
94
+ }
@@ -1,4 +1,3 @@
1
- import type { Tree } from 'nx/src/devkit-exports.js';
2
1
  /**
3
2
  * Everything the test typecheck needs to know about one project's files.
4
3
  *
@@ -16,8 +15,6 @@ export interface TestProgram {
16
15
  /** A tsconfig by workspace-relative path; null when the file is absent. */
17
16
  readonly readConfig: (path: string) => Record<string, unknown> | null;
18
17
  }
19
- /** A directory listing the walker can use: an Nx `Tree`, or the disk behind a small adapter. */
20
- export type ProjectTree = Pick<Tree, 'children' | 'isFile'>;
21
18
  /** Why a test program typechecks none of what it exists to typecheck. */
22
19
  export type TestProgramFault = {
23
20
  readonly kind: 'no-tests';
@@ -26,15 +23,23 @@ export type TestProgramFault = {
26
23
  readonly tests: readonly string[];
27
24
  };
28
25
  /**
29
- * The TypeScript sources of a project, project-relative and sorted.
26
+ * The files {@link typeScriptSourcesByProject} lists from: the TypeScript sources, and the manifests that make a
27
+ * directory a project of its own.
28
+ */
29
+ export declare const SOURCE_LISTING_GLOBS: string[];
30
+ /**
31
+ * The TypeScript sources of each of `projectRoots`, project-relative and sorted, from one listing of the workspace's
32
+ * files (workspace-relative; a file that is neither a source nor a manifest is passed over). One pass over the listing
33
+ * answers every project: no directory is listed and no file is probed.
30
34
  *
31
35
  * A directory below the project that is a project of its own (its own manifest or Nx project file) is not part of
32
36
  * this one: its files are its own tests, found by its own policy pass, and folding them in would count them twice.
33
37
  * A directory that merely carries a tsconfig is not that: in a monorepo of Bun programs such a file routes the
34
38
  * directory's files to the parent's program (a `tests/tsconfig.json` extending `../tsconfig.test.json`), and
35
- * nothing typechecks the directory but that program.
39
+ * nothing typechecks the directory but that program. Nothing beneath a build-output or dot directory is a source
40
+ * ({@link isNonSourceDirectory}).
36
41
  */
37
- export declare function listTypeScriptSources(tree: ProjectTree, projectRoot: string): string[];
42
+ export declare function typeScriptSourcesByProject(files: Iterable<string>, projectRoots: Iterable<string>): ReadonlyMap<string, readonly string[]>;
38
43
  /**
39
44
  * The globs a test program's `include` must carry, given the `include` it has.
40
45
  *
@@ -1 +1 @@
1
- {"version":3,"file":"test-program.d.ts","sourceRoot":"","sources":["../src/test-program.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IA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AO,CAAC,GAAG,IAAI,CAAC;CACvE;AAED,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAsB7E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UAAyD,CAAC;AAE3F;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC7B,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAiBxC;AAwDD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAS/G;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAO/G"}
@@ -20,48 +20,52 @@ const FIXTURE_DIRECTORY = 'fixtures';
20
20
  const PACKAGE_CONVENTION_ROOT = 'src';
21
21
  const TESTS_DIRECTORY = '__tests__';
22
22
  /**
23
- * The TypeScript sources of a project, project-relative and sorted.
23
+ * The files {@link typeScriptSourcesByProject} lists from: the TypeScript sources, and the manifests that make a
24
+ * directory a project of its own.
25
+ */
26
+ export const SOURCE_LISTING_GLOBS = ['**/*.{ts,tsx,mts,cts}', '**/{package,project}.json'];
27
+ /**
28
+ * The TypeScript sources of each of `projectRoots`, project-relative and sorted, from one listing of the workspace's
29
+ * files (workspace-relative; a file that is neither a source nor a manifest is passed over). One pass over the listing
30
+ * answers every project: no directory is listed and no file is probed.
24
31
  *
25
32
  * A directory below the project that is a project of its own (its own manifest or Nx project file) is not part of
26
33
  * this one: its files are its own tests, found by its own policy pass, and folding them in would count them twice.
27
34
  * A directory that merely carries a tsconfig is not that: in a monorepo of Bun programs such a file routes the
28
35
  * directory's files to the parent's program (a `tests/tsconfig.json` extending `../tsconfig.test.json`), and
29
- * nothing typechecks the directory but that program.
36
+ * nothing typechecks the directory but that program. Nothing beneath a build-output or dot directory is a source
37
+ * ({@link isNonSourceDirectory}).
30
38
  */
31
- export function listTypeScriptSources(tree, projectRoot) {
32
- const files = [];
33
- const walk = (directory) => {
34
- for (const name of childrenOf(tree, directory)) {
35
- const path = posix.join(directory, name);
36
- if (tree.isFile(path)) {
37
- if (TYPESCRIPT_SOURCE.test(name))
38
- files.push(posix.relative(projectRoot, path));
39
- }
40
- else if (!isNonSourceDirectory(name) && !isNestedProject(tree, path)) {
41
- walk(path);
42
- }
43
- }
44
- };
45
- walk(projectRoot);
46
- return files.sort();
47
- }
48
- /** A directory with its own manifest or Nx project file is a project, and its files are that project's. */
49
- function isNestedProject(tree, directory) {
50
- return childrenOf(tree, directory).some((name) => PROJECT_FILE.test(name) && tree.isFile(posix.join(directory, name)));
51
- }
52
- /** A dangling link (a collected build out-link) is neither a file nor a directory; anything else is a real fault. */
53
- function childrenOf(tree, directory) {
54
- try {
55
- return tree.children(directory);
39
+ export function typeScriptSourcesByProject(files, projectRoots) {
40
+ const sources = new Map();
41
+ for (const root of projectRoots)
42
+ sources.set(root === '' ? '.' : root, []);
43
+ const owners = new Set(sources.keys());
44
+ const listed = [];
45
+ for (const file of files) {
46
+ const name = posix.basename(file);
47
+ if (PROJECT_FILE.test(name))
48
+ owners.add(posix.dirname(file));
49
+ if (TYPESCRIPT_SOURCE.test(name))
50
+ listed.push(file);
56
51
  }
57
- catch (error) {
58
- // ELOOP is a link cycle: there is nothing beneath it to list.
59
- if (error instanceof Error &&
60
- 'code' in error &&
61
- (error.code === 'ENOENT' || error.code === 'ENOTDIR' || error.code === 'ELOOP')) {
62
- return [];
63
- }
64
- throw error;
52
+ for (const file of listed) {
53
+ const owner = ownerOf(file, owners);
54
+ if (owner === null)
55
+ continue;
56
+ sources.get(owner)?.push(owner === '.' ? file : file.slice(owner.length + 1));
57
+ }
58
+ for (const list of sources.values())
59
+ list.sort();
60
+ return sources;
61
+ }
62
+ /** The nearest directory holding a file that is a project, or null when a build-output or dot directory comes first. */
63
+ function ownerOf(file, owners) {
64
+ for (let directory = posix.dirname(file);; directory = posix.dirname(directory)) {
65
+ if (owners.has(directory))
66
+ return directory;
67
+ if (directory === '.' || isNonSourceDirectory(posix.basename(directory)))
68
+ return null;
65
69
  }
66
70
  }
67
71
  function isTestSource(file) {
@@ -14,6 +14,11 @@ export interface NativeTools {
14
14
  readonly target: string;
15
15
  /** Each tool package that is a project of this workspace, to its project name. */
16
16
  readonly projects: ReadonlyMap<NativeToolPackage, string>;
17
+ /**
18
+ * The Nx project of the plugin itself, when this workspace owns it: the executors it ships are files its own
19
+ * build writes. An installed plugin ships them built, so a consumer has none.
20
+ */
21
+ readonly plugin: string | undefined;
17
22
  }
18
23
  /**
19
24
  * The tools of the workspace at `workspaceRoot`, whose project manifests are `projectManifests` (workspace-relative):
@@ -27,5 +32,12 @@ export declare function resolveNativeTools(workspaceRoot: string, projectManifes
27
32
  export declare function nativeToolCommand(tools: Pick<NativeTools, 'platform'> | null, cwd: string, tool: NativeToolPackage, bin: string): string;
28
33
  /** The task producing a tool artifact, only when this workspace owns its package. */
29
34
  export declare function nativeToolDependsOn(tools: NativeTools | null, tool: NativeToolPackage, target?: string): TargetDependency[];
35
+ /**
36
+ * The task that leaves the plugin's executors built, for a target whose `executor` is one of them, only when this
37
+ * workspace owns the plugin's package (an installed plugin ships its executors built). The executor is a file the
38
+ * plugin's own build writes, so a target that starts before that build ends loads the dist a previous build left, which
39
+ * lacks an executor the plugin gained since, or none at all.
40
+ */
41
+ export declare function pluginBuildDependsOn(tools: NativeTools | null, executor: unknown): TargetDependency[];
30
42
  export {};
31
43
  //# sourceMappingURL=tool-bins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-bins.d.ts","sourceRoot":"","sources":["../src/tool-bins.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAsBpE,0EAA0E;AAC1E,QAAA,MAAM,oBAAoB,YAAI,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,CAAU,CAAC;AAErG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,KAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;CAC3D;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,SAAS,MAAM,EAAE,EACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAUD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,IAAI,EAC3C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,MAAM,GACV,MAAM,CAOR;AAED,qFAAqF;AACrF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,IAAI,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mB,CACjC,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,IAAI,EAAE,iBAAiB,EACvB,MAAM,CAAC,EAAE,MAAM,GACd,gBAAgB,EAAE,CAKpB;AAQD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAIrG"}
package/dist/tool-bins.js CHANGED
@@ -26,6 +26,7 @@ const NATIVE_TOOL_PACKAGES = ['build-inputs', 'cargo-retain', 'nextest-extract',
26
26
  */
27
27
  export async function resolveNativeTools(workspaceRoot, projectManifests, platform, target) {
28
28
  const projects = new Map();
29
+ let pluginProject;
29
30
  const plugin = await realpath(join(workspaceRoot, PLUGIN_LINK)).catch((error) => {
30
31
  // A workspace whose install has not linked the plugin yet has no tool package of its own either.
31
32
  if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
@@ -34,18 +35,24 @@ export async function resolveNativeTools(workspaceRoot, projectManifests, platfo
34
35
  });
35
36
  if (plugin !== null) {
36
37
  const root = await realpath(workspaceRoot);
37
- for (const tool of NATIVE_TOOL_PACKAGES) {
38
- const manifest = relative(root, join(dirname(plugin), tool, 'package.json')).replaceAll('\\', '/');
38
+ const owned = async (directory, package_) => {
39
+ const manifest = relative(root, join(directory, 'package.json')).replaceAll('\\', '/');
39
40
  if (!projectManifests.includes(manifest))
40
- continue;
41
+ return undefined;
41
42
  const parsed = JSON.parse(await readFile(join(root, manifest), 'utf8'));
42
43
  const name = projectName(parsed);
43
44
  if (name === undefined)
44
- throw new Error(`${manifest}: a tool package names its Nx project in name or nx.name`);
45
- projects.set(tool, name);
45
+ throw new Error(`${manifest}: ${package_} names its Nx project in name or nx.name`);
46
+ return name;
47
+ };
48
+ pluginProject = await owned(plugin, 'the plugin package');
49
+ for (const tool of NATIVE_TOOL_PACKAGES) {
50
+ const name = await owned(join(dirname(plugin), tool), 'a tool package');
51
+ if (name !== undefined)
52
+ projects.set(tool, name);
46
53
  }
47
54
  }
48
- return { platform, target, projects };
55
+ return { platform, target, projects, plugin: pluginProject };
49
56
  }
50
57
  function projectName(manifest) {
51
58
  if (typeof manifest !== 'object' || manifest === null)
@@ -72,3 +79,21 @@ export function nativeToolDependsOn(tools, tool, target) {
72
79
  ? []
73
80
  : [{ projects: [project], target: target ?? (tool === 'cowshed' ? 'napi-native' : tools.target) }];
74
81
  }
82
+ /** The plugin executors its own build runs: they load from a dist an earlier build left, so none can wait for it. */
83
+ const BOOTSTRAP_EXECUTORS = new Set([
84
+ '@smoothbricks/nx-plugin:typescript-emit',
85
+ '@smoothbricks/nx-plugin:scriptc-native',
86
+ ]);
87
+ /**
88
+ * The task that leaves the plugin's executors built, for a target whose `executor` is one of them, only when this
89
+ * workspace owns the plugin's package (an installed plugin ships its executors built). The executor is a file the
90
+ * plugin's own build writes, so a target that starts before that build ends loads the dist a previous build left, which
91
+ * lacks an executor the plugin gained since, or none at all.
92
+ */
93
+ export function pluginBuildDependsOn(tools, executor) {
94
+ if (tools?.plugin === undefined || typeof executor !== 'string')
95
+ return [];
96
+ if (!executor.startsWith('@smoothbricks/nx-plugin:') || BOOTSTRAP_EXECUTORS.has(executor))
97
+ return [];
98
+ return [{ projects: [tools.plugin], target: 'build' }];
99
+ }
@@ -1,3 +1,4 @@
1
+ import type { DependencyManifest } from './dependency-manifests.js';
1
2
  /**
2
3
  * What a package whose ttsc plugin lowers a dialect declares in its manifest, as `smoo.typecheck`: every project that
3
4
  * depends on it directly compiles sources the stock checker refuses (a construct the plugin's ProgramPlugin rewrites
@@ -19,10 +20,8 @@ export interface TypecheckRoute {
19
20
  readonly dependsOn: readonly string[];
20
21
  }
21
22
  /**
22
- * The typecheck route of the project whose manifest is `packageJsonPath`, over its direct dependencies (the ones ttsc
23
- * discovers plugins on: `dependencies` and `devDependencies`). Each dependency's manifest is the one Node resolution
24
- * reaches from the project, as ttsc reads it; a dependency that is not installed declares nothing. A manifest that
23
+ * The typecheck route of a project over its direct dependencies' manifests (dependency-manifests.ts). A manifest that
25
24
  * declares `smoo.typecheck` in another shape refuses the inference by its path and the field it got wrong.
26
25
  */
27
- export declare function typecheckRoute(packageJsonPath: string, dependencies: readonly string[]): TypecheckRoute;
26
+ export declare function typecheckRoute(manifests: readonly DependencyManifest[]): TypecheckRoute;
28
27
  //# sourceMappingURL=typecheck-route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typecheck-route.d.ts","sourceRoot":"","sources":["../src/typecheck-route.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AASD,yHAAyH;AACzH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAuBvG"}
1
+ {"version":3,"file":"typecheck-route.d.ts","sourceRoot":"","sources":["../src/typecheck-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AASD,yHAAyH;AACzH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,GAAG,cAAc,CAkBvF"}
@@ -1,8 +1,5 @@
1
1
  import * as _validateReport_1 from "typia/lib/internal/_validateReport";
2
2
  import * as _createStandardSchema_1 from "typia/lib/internal/_createStandardSchema";
3
- import { existsSync, readFileSync } from 'node:fs';
4
- import { createRequire } from 'node:module';
5
- import { join } from 'node:path';
6
3
  import typia from 'typia';
7
4
  const validateManifest = (() => {
8
5
  let errors;
@@ -76,22 +73,14 @@ const validateManifest = (() => {
76
73
  });
77
74
  })();
78
75
  /**
79
- * The typecheck route of the project whose manifest is `packageJsonPath`, over its direct dependencies (the ones ttsc
80
- * discovers plugins on: `dependencies` and `devDependencies`). Each dependency's manifest is the one Node resolution
81
- * reaches from the project, as ttsc reads it; a dependency that is not installed declares nothing. A manifest that
76
+ * The typecheck route of a project over its direct dependencies' manifests (dependency-manifests.ts). A manifest that
82
77
  * declares `smoo.typecheck` in another shape refuses the inference by its path and the field it got wrong.
83
78
  */
84
- export function typecheckRoute(packageJsonPath, dependencies) {
79
+ export function typecheckRoute(manifests) {
85
80
  const declaredBy = [];
86
81
  const dependsOn = [];
87
- const lookup = createRequire(packageJsonPath);
88
- for (const name of new Set(dependencies)) {
89
- const manifest = (lookup.resolve.paths(name) ?? [])
90
- .map((root) => join(root, ...name.split('/'), 'package.json'))
91
- .find((candidate) => existsSync(candidate));
92
- if (manifest === undefined)
93
- continue;
94
- const checked = validateManifest(JSON.parse(readFileSync(manifest, 'utf-8')));
82
+ for (const { name, path: manifest, json } of manifests) {
83
+ const checked = validateManifest(json);
95
84
  if (!checked.success) {
96
85
  throw new Error(`${manifest}: smoo.typecheck must be { compiler: 'ttsc', dependsOn: ['<project>:<target>', ...] }: ${checked.errors
97
86
  .map((error) => `${error.path} expected ${error.expected}`)
@@ -43,8 +43,17 @@ export declare function checkTypecheckTestPolicyTree(tree: Tree): NxPolicyIssue[
43
43
  /**
44
44
  * Render test typechecking policy from the caller's Tree. The managed generator
45
45
  * owns staging, permission checks, and flushing together with its other files.
46
+ * `listing` is {@link treeSourceListing} of the same Tree: the caller holds it, as the render's memo is keyed on it.
46
47
  */
47
- export declare function renderTypecheckTestFiles(tree: Tree): ManagedFile[];
48
+ export declare function renderTypecheckTestFiles(tree: Tree, listing: readonly string[]): ManagedFile[];
49
+ /**
50
+ * The files a Tree's source listing reads, workspace-relative and sorted: Nx's workspace file index for the Tree's
51
+ * root, with the Tree's pending edits over it, as devkit's own `getProjects` lists project files. The index applies
52
+ * .gitignore and .nxignore, so the listing is what the commit holds, the same in every checkout, and never build
53
+ * output one disk happens to carry; it is read from memory, so no directory is listed and no file probed. A path a
54
+ * pending edit writes is listed whatever its name: the listing passes over what is neither a source nor a manifest.
55
+ */
56
+ export declare function treeSourceListing(tree: Tree): string[];
48
57
  /**
49
58
  * Check all workspace packages for typecheck test policy compliance.
50
59
  *
@@ -1 +1 @@
1
- {"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAIL,KAAK,WAAW,EAGjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAI1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAAC,UAAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM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;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAiDxE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,EAAE,CAsE9F;AAuBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAOtD;AAkCD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CA6EtE"}
@@ -1,12 +1,14 @@
1
1
  import * as _assertGuard_1 from "typia/lib/internal/_assertGuard";
2
- import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
2
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
3
3
  import { dirname, join, posix, relative } from 'node:path';
4
4
  import { getProjects, parseJson, readJson, readProjectConfiguration } from 'nx/src/devkit-exports.js';
5
+ import { globWithWorkspaceContextSync } from 'nx/src/utils/workspace-context.js';
5
6
  import typia from 'typia';
6
7
  import { editJsonText } from './managed-files/json-edit.js';
7
8
  import { formatJsonWithBiome, jsonFileText } from './managed-files/managed-format.js';
8
- import { includeGlobsFor, listTypeScriptSources, testProgramFault, } from './test-program.js';
9
+ import { includeGlobsFor, SOURCE_LISTING_GLOBS, testProgramFault, typeScriptSourcesByProject, } from './test-program.js';
9
10
  import { isRecord } from './type-guards.js';
11
+ import { freshIndexedFiles } from './workspace-index.js';
10
12
  import { workspacePackagePatterns } from './workspace-manifest.js';
11
13
  const workspaceDependencyFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
12
14
  /**
@@ -202,7 +204,9 @@ export function removeTsconfigTestReference(projectTsconfig) {
202
204
  */
203
205
  export function checkTypecheckTestPolicyTree(tree) {
204
206
  const issues = [];
205
- for (const [projectName, config] of getProjects(tree)) {
207
+ const projects = getProjects(tree);
208
+ const sources = typeScriptSourcesByProject(treeSourceListing(tree), [...projects.values()].map((project) => project.root));
209
+ for (const [projectName, config] of projects) {
206
210
  const pkgPath = `${config.root}/package.json`;
207
211
  if (!tree.exists(pkgPath))
208
212
  continue;
@@ -227,7 +231,7 @@ export function checkTypecheckTestPolicyTree(tree) {
227
231
  // Check tsconfig.test.json contents
228
232
  const tsconfigTest = readJson(tree, tsconfigTestPath);
229
233
  issues.push(...checkTypecheckTestConfig(tsconfigTest, config.root));
230
- const fault = testProgramFault(treeProgram(tree, config.root), tsconfigTest);
234
+ const fault = testProgramFault(treeProgram(tree, config.root, sources), tsconfigTest);
231
235
  if (fault !== null) {
232
236
  issues.push({ path: tsconfigTestPath, message: testProgramFaultMessage(config.root, testRunners, fault) });
233
237
  }
@@ -243,11 +247,14 @@ export function checkTypecheckTestPolicyTree(tree) {
243
247
  /**
244
248
  * Render test typechecking policy from the caller's Tree. The managed generator
245
249
  * owns staging, permission checks, and flushing together with its other files.
250
+ * `listing` is {@link treeSourceListing} of the same Tree: the caller holds it, as the render's memo is keyed on it.
246
251
  */
247
- export function renderTypecheckTestFiles(tree) {
252
+ export function renderTypecheckTestFiles(tree, listing) {
248
253
  const files = [];
249
254
  const workspacePackages = collectWorkspacePackagesTree(tree);
250
- for (const [projectName, config] of getProjects(tree)) {
255
+ const projects = getProjects(tree);
256
+ const sources = typeScriptSourcesByProject(listing, [...projects.values()].map((project) => project.root));
257
+ for (const [projectName, config] of projects) {
251
258
  const pkgPath = `${config.root}/package.json`;
252
259
  if (!tree.exists(pkgPath))
253
260
  continue;
@@ -272,7 +279,7 @@ export function renderTypecheckTestFiles(tree) {
272
279
  const libCompilerOptions = libTsconfig ? recordProperty(libTsconfig, 'compilerOptions') : null;
273
280
  // Collect reference paths
274
281
  const referencePaths = collectReferencePathsTree(tree, config.root, pkg, workspacePackages);
275
- const program = treeProgram(tree, config.root);
282
+ const program = treeProgram(tree, config.root, sources);
276
283
  applyTypecheckTestDefaults(tsconfigTest, {
277
284
  testRunners,
278
285
  testExtends,
@@ -324,28 +331,34 @@ function renderTsconfig(tree, target, after) {
324
331
  }
325
332
  return { target, content: edited === current ? current : formatJsonWithBiome(path, edited) };
326
333
  }
327
- function treeProgram(tree, projectRoot) {
334
+ /**
335
+ * The files a Tree's source listing reads, workspace-relative and sorted: Nx's workspace file index for the Tree's
336
+ * root, with the Tree's pending edits over it, as devkit's own `getProjects` lists project files. The index applies
337
+ * .gitignore and .nxignore, so the listing is what the commit holds, the same in every checkout, and never build
338
+ * output one disk happens to carry; it is read from memory, so no directory is listed and no file probed. A path a
339
+ * pending edit writes is listed whatever its name: the listing passes over what is neither a source nor a manifest.
340
+ */
341
+ export function treeSourceListing(tree) {
342
+ const files = new Set(globWithWorkspaceContextSync(tree.root, SOURCE_LISTING_GLOBS));
343
+ for (const change of tree.listChanges()) {
344
+ if (change.type === 'DELETE')
345
+ files.delete(change.path);
346
+ else
347
+ files.add(change.path);
348
+ }
349
+ return [...files].sort();
350
+ }
351
+ function treeProgram(tree, projectRoot, sources) {
328
352
  return {
329
353
  projectRoot,
330
- files: listTypeScriptSources(tree, projectRoot),
354
+ files: sources.get(projectRoot) ?? [],
331
355
  readConfig: (path) => (tree.exists(path) ? readJson(tree, path) : null),
332
356
  };
333
357
  }
334
- function diskProgram(root, projectRoot) {
335
- const disk = {
336
- children: (directory) => readdirSync(join(root, directory)),
337
- isFile: (path) => {
338
- try {
339
- return statSync(join(root, path)).isFile();
340
- }
341
- catch {
342
- return false;
343
- }
344
- },
345
- };
358
+ function diskProgram(root, projectRoot, sources) {
346
359
  return {
347
360
  projectRoot,
348
- files: listTypeScriptSources(disk, projectRoot),
361
+ files: sources.get(projectRoot) ?? [],
349
362
  readConfig: (path) => readJsonObject(join(root, path)),
350
363
  };
351
364
  }
@@ -368,7 +381,10 @@ function testProgramFaultMessage(projectRoot, testRunners, fault) {
368
381
  export function checkTypecheckTestPolicy(root) {
369
382
  const issues = [];
370
383
  const workspaceNames = getWorkspacePackageNames(root);
371
- for (const packageJsonPath of listWorkspacePackageJsonPaths(root)) {
384
+ const packageJsonPaths = listWorkspacePackageJsonPaths(root);
385
+ // Files as they are on disk now, through the same ignore rules as the Tree listing.
386
+ const sources = typeScriptSourcesByProject(freshIndexedFiles(root, SOURCE_LISTING_GLOBS), packageJsonPaths.map((path) => relative(root, dirname(path))));
387
+ for (const packageJsonPath of packageJsonPaths) {
372
388
  const pkg = readJsonObject(packageJsonPath);
373
389
  if (!pkg) {
374
390
  continue;
@@ -398,7 +414,7 @@ export function checkTypecheckTestPolicy(root) {
398
414
  if (tsconfig) {
399
415
  const absoluteIssues = checkTypecheckTestConfig(tsconfig, join(root, packagePath));
400
416
  issues.push(...absoluteIssues);
401
- const program = diskProgram(root, packagePath);
417
+ const program = diskProgram(root, packagePath, sources);
402
418
  const fault = testProgramFault(program, tsconfig);
403
419
  if (fault !== null) {
404
420
  issues.push({ path: tsconfigTestPath, message: testProgramFaultMessage(packagePath, testRunners, fault) });