@smoothbricks/nx-plugin 0.7.17 → 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 (102) hide show
  1. package/README.md +204 -64
  2. package/dist/.build-inputs.json +24 -21
  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/ensure-built-receipt.d.ts +3 -2
  16. package/dist/ensure-built-receipt.d.ts.map +1 -1
  17. package/dist/ensure-built-receipt.js +3 -2
  18. package/dist/eslint-config-closure.d.ts +8 -3
  19. package/dist/eslint-config-closure.d.ts.map +1 -1
  20. package/dist/eslint-config-closure.js +24 -5
  21. package/dist/executors/bounded-exec/bounds.d.ts +12 -1
  22. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  23. package/dist/executors/bounded-exec/bounds.js +8 -4
  24. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  25. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  26. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  27. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  28. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  29. package/dist/executors/bounded-exec/executor.js +54 -22
  30. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +8 -0
  31. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  32. package/dist/executors/bounded-exec/hang-diagnostics.js +66 -6
  33. package/dist/executors/bounded-exec/mbx-pool.d.ts +16 -2
  34. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  35. package/dist/executors/bounded-exec/mbx-pool.js +18 -2
  36. package/dist/executors/bounded-exec/mbx-reservations.d.ts +5 -2
  37. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/mbx-reservations.js +5 -3
  39. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  40. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  41. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  42. package/dist/executors/bounded-exec/progress.d.ts +2 -1
  43. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  44. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  45. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  46. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  47. package/dist/executors/bounded-exec/schema.d.ts +5 -0
  48. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  49. package/dist/executors/bounded-exec/schema.js +17 -1
  50. package/dist/executors/bounded-exec/verdict.d.ts +13 -6
  51. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  52. package/dist/executors/bounded-exec/verdict.js +34 -9
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +199 -89
  55. package/dist/managed-files/generator.d.ts +5 -1
  56. package/dist/managed-files/generator.d.ts.map +1 -1
  57. package/dist/managed-files/generator.js +22 -7
  58. package/dist/managed-files/render-memo.d.ts +13 -0
  59. package/dist/managed-files/render-memo.d.ts.map +1 -0
  60. package/dist/managed-files/render-memo.js +94 -0
  61. package/dist/test-program.d.ts +11 -6
  62. package/dist/test-program.d.ts.map +1 -1
  63. package/dist/test-program.js +39 -35
  64. package/dist/tool-bins.d.ts +12 -0
  65. package/dist/tool-bins.d.ts.map +1 -1
  66. package/dist/tool-bins.js +31 -6
  67. package/dist/typecheck-test-policy.d.ts +10 -1
  68. package/dist/typecheck-test-policy.d.ts.map +1 -1
  69. package/dist/typecheck-test-policy.js +40 -24
  70. package/dist/workspace-index.d.ts +14 -1
  71. package/dist/workspace-index.d.ts.map +1 -1
  72. package/dist/workspace-index.js +36 -4
  73. package/managed/raw/patches/nx@24.0.3.patch +703 -119
  74. package/managed/raw/tooling/direnv/developer-links.ts +17 -3
  75. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  76. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  77. package/package.json +3 -2
  78. package/src/bun-lock-scope.ts +293 -40
  79. package/src/cargo-closure-input.ts +19 -11
  80. package/src/cargo-source-hash.ts +103 -13
  81. package/src/cargo-workspace.ts +59 -20
  82. package/src/ensure-built-receipt.ts +3 -2
  83. package/src/eslint-config-closure.ts +27 -6
  84. package/src/executors/bounded-exec/bounds.ts +13 -4
  85. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  86. package/src/executors/bounded-exec/executor.ts +65 -21
  87. package/src/executors/bounded-exec/hang-diagnostics.ts +88 -6
  88. package/src/executors/bounded-exec/mbx-pool.ts +24 -3
  89. package/src/executors/bounded-exec/mbx-reservations.ts +7 -5
  90. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  91. package/src/executors/bounded-exec/progress.ts +2 -1
  92. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  93. package/src/executors/bounded-exec/schema.ts +19 -0
  94. package/src/executors/bounded-exec/verdict.ts +44 -16
  95. package/src/index.ts +255 -98
  96. package/src/managed-files/generator.ts +21 -6
  97. package/src/managed-files/render-memo.ts +135 -0
  98. package/src/test-program.ts +36 -41
  99. package/src/tool-bins.ts +35 -6
  100. package/src/typecheck-test-policy.ts +49 -24
  101. package/src/workspace-index.ts +40 -5
  102. package/test-timings.json +6 -0
@@ -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;IAClC,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACvE;AAED,gGAAgG;AAChG,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC,CAAC;AAE5D,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI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,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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  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
+ }
@@ -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,0BAA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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,OAAO,EAAE;IACP,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,mDAAmD;IACnD,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,iFAAiF;IACjF,OAAO,EAAE,WAAW,CAAC;IACrB,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,OAAO,CAiET;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM1F;AAED;;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) });
@@ -1,3 +1,4 @@
1
+ import { type FileData } from 'nx/src/native/index.js';
1
2
  /**
2
3
  * The files of Nx's workspace file index that match `globs`, workspace-relative:
3
4
  * .gitignore and .nxignore applied, `node_modules` never entered. These are
@@ -6,7 +7,10 @@
6
7
  * output happens to be on disk.
7
8
  *
8
9
  * The daemon serves only its own workspace's index. Any other root, such as a
9
- * test fixture or a foreign checkout, is indexed by this process's context.
10
+ * test fixture or a foreign checkout, is read from the filesystem now
11
+ * ({@link freshIndexedFiles}), under that root's own data directory: Nx's
12
+ * process context for it would resolve the inherited NX_WORKSPACE_DATA_DIRECTORY,
13
+ * this workspace's, and take its files lock and archive.
10
14
  */
11
15
  export declare function globIndexedFiles(workspaceRoot: string, globs: string[]): Promise<string[]>;
12
16
  /**
@@ -16,4 +20,13 @@ export declare function globIndexedFiles(workspaceRoot: string, globs: string[])
16
20
  * runs on the files as they are asks here; what describes a graph asks {@link globIndexedFiles}.
17
21
  */
18
22
  export declare function freshIndexedFiles(workspaceRoot: string, globs: string[]): string[];
23
+ /**
24
+ * Every file of Nx's workspace file index with Nx's content hash of it, workspace-relative: the hashes Nx's task
25
+ * hasher keys every fileset on, kept current by its watcher, so a caller can tell an unchanged file without reading
26
+ * it. The daemon serves its own workspace; any other root, such as a test fixture, is read from the filesystem now
27
+ * ({@link freshIndexedFileData}), since the daemon's answer would be about another tree.
28
+ */
29
+ export declare function indexedFileData(workspaceRoot: string): Promise<FileData[]>;
30
+ /** Like {@link indexedFileData}, read from the filesystem now, as {@link freshIndexedFiles} lists it. */
31
+ export declare function freshIndexedFileData(workspaceRoot: string): FileData[];
19
32
  //# sourceMappingURL=workspace-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-index.d.ts","sourceRoot":"","sources":["../src/workspace-index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhG;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElF"}
1
+ {"version":3,"file":"workspace-index.d.ts","sourceRoot":"","sources":["../src/workspace-index.ts"],"names":[],"mappings":"AACA,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAK/D;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhG;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElF;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAIhF;AAED,yGAAyG;AACzG,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEtE"}
@@ -1,6 +1,7 @@
1
+ import { join } from 'node:path';
1
2
  import native from 'nx/src/native/index.js';
2
3
  import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
3
- import { globWithWorkspaceContext, globWithWorkspaceContextSync } from 'nx/src/utils/workspace-context.js';
4
+ import { getAllFileDataInContext, globWithWorkspaceContext } from 'nx/src/utils/workspace-context.js';
4
5
  import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-root.js';
5
6
  /**
6
7
  * The files of Nx's workspace file index that match `globs`, workspace-relative:
@@ -10,12 +11,15 @@ import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-roo
10
11
  * output happens to be on disk.
11
12
  *
12
13
  * The daemon serves only its own workspace's index. Any other root, such as a
13
- * test fixture or a foreign checkout, is indexed by this process's context.
14
+ * test fixture or a foreign checkout, is read from the filesystem now
15
+ * ({@link freshIndexedFiles}), under that root's own data directory: Nx's
16
+ * process context for it would resolve the inherited NX_WORKSPACE_DATA_DIRECTORY,
17
+ * this workspace's, and take its files lock and archive.
14
18
  */
15
19
  export async function globIndexedFiles(workspaceRoot, globs) {
16
20
  return workspaceRoot === daemonWorkspaceRoot
17
21
  ? globWithWorkspaceContext(workspaceRoot, globs)
18
- : globWithWorkspaceContextSync(workspaceRoot, globs);
22
+ : freshIndexedFiles(workspaceRoot, globs);
19
23
  }
20
24
  /**
21
25
  * Like {@link globIndexedFiles}, read from the filesystem now: a new native context, the same walk and the same ignore
@@ -24,5 +28,33 @@ export async function globIndexedFiles(workspaceRoot, globs) {
24
28
  * runs on the files as they are asks here; what describes a graph asks {@link globIndexedFiles}.
25
29
  */
26
30
  export function freshIndexedFiles(workspaceRoot, globs) {
27
- return new native.WorkspaceContext(workspaceRoot, workspaceDataDirectoryForWorkspace(workspaceRoot)).glob(globs);
31
+ return new native.WorkspaceContext(workspaceRoot, indexDataDirectory(workspaceRoot)).glob(globs);
32
+ }
33
+ /**
34
+ * Every file of Nx's workspace file index with Nx's content hash of it, workspace-relative: the hashes Nx's task
35
+ * hasher keys every fileset on, kept current by its watcher, so a caller can tell an unchanged file without reading
36
+ * it. The daemon serves its own workspace; any other root, such as a test fixture, is read from the filesystem now
37
+ * ({@link freshIndexedFileData}), since the daemon's answer would be about another tree.
38
+ */
39
+ export async function indexedFileData(workspaceRoot) {
40
+ return workspaceRoot === daemonWorkspaceRoot
41
+ ? getAllFileDataInContext(workspaceRoot)
42
+ : freshIndexedFileData(workspaceRoot);
43
+ }
44
+ /** Like {@link indexedFileData}, read from the filesystem now, as {@link freshIndexedFiles} lists it. */
45
+ export function freshIndexedFileData(workspaceRoot) {
46
+ return new native.WorkspaceContext(workspaceRoot, indexDataDirectory(workspaceRoot)).allFileData();
47
+ }
48
+ /**
49
+ * Where a fresh native context of `workspaceRoot` keeps its files lock and archive. Nx's
50
+ * `workspaceDataDirectoryForWorkspace` answers `NX_WORKSPACE_DATA_DIRECTORY` for every root, and that variable names
51
+ * this process's workspace's data (CI points it at a shared directory outside the checkout). A walk of another root
52
+ * there takes this workspace's files lock, and when another process holds it, loads the archive that process writes,
53
+ * this workspace's files, as the other root's (CI's Lint, run 42738719423: the compiled-in fixtures found no crate).
54
+ * Any other root walks under Nx's default for it, inside itself.
55
+ */
56
+ function indexDataDirectory(workspaceRoot) {
57
+ return workspaceRoot === daemonWorkspaceRoot
58
+ ? workspaceDataDirectoryForWorkspace(workspaceRoot)
59
+ : join(workspaceRoot, '.nx', 'workspace-data');
28
60
  }