nx 23.1.0 → 23.1.2

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 (223) hide show
  1. package/dist/bin/nx.js +2 -1
  2. package/dist/release/changelog-renderer/index.js +4 -5
  3. package/dist/release/index.d.ts +1 -1
  4. package/dist/src/ai/configure-ai-agents-disclaimer.d.ts +5 -0
  5. package/dist/src/ai/configure-ai-agents-disclaimer.js +31 -0
  6. package/dist/src/analytics/analytics.d.ts +6 -0
  7. package/dist/src/analytics/analytics.js +16 -8
  8. package/dist/src/analytics/index.d.ts +1 -1
  9. package/dist/src/analytics/index.js +2 -1
  10. package/dist/src/command-line/add/add.js +13 -1
  11. package/dist/src/command-line/affected/affected.js +1 -0
  12. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +2 -2
  13. package/dist/src/command-line/graph/graph.d.ts +1 -0
  14. package/dist/src/command-line/graph/graph.js +15 -6
  15. package/dist/src/command-line/import/import.js +2 -3
  16. package/dist/src/command-line/init/ai-agent-prompts.d.ts +1 -1
  17. package/dist/src/command-line/init/ai-agent-prompts.js +7 -6
  18. package/dist/src/command-line/init/command-object.js +10 -2
  19. package/dist/src/command-line/init/configure-plugins.js +3 -2
  20. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +4 -2
  21. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +4 -3
  22. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +4 -3
  23. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +4 -3
  24. package/dist/src/command-line/init/implementation/angular/index.js +4 -2
  25. package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
  26. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +3 -0
  27. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +4 -1
  28. package/dist/src/command-line/init/implementation/utils.d.ts +3 -3
  29. package/dist/src/command-line/init/implementation/utils.js +22 -3
  30. package/dist/src/command-line/init/init-v2.js +4 -5
  31. package/dist/src/command-line/migrate/execute-migration.d.ts +72 -0
  32. package/dist/src/command-line/migrate/execute-migration.js +389 -0
  33. package/dist/src/command-line/migrate/migrate-ui-api.js +17 -12
  34. package/dist/src/command-line/migrate/migrate.d.ts +5 -45
  35. package/dist/src/command-line/migrate/migrate.js +122 -402
  36. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +1 -1
  37. package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
  38. package/dist/src/command-line/release/changelog.js +5 -0
  39. package/dist/src/command-line/release/index.d.ts +1 -1
  40. package/dist/src/command-line/release/utils/git.js +7 -3
  41. package/dist/src/command-line/release/utils/release-graph.d.ts +19 -2
  42. package/dist/src/command-line/release/utils/release-graph.js +71 -19
  43. package/dist/src/command-line/release/utils/remote-release-clients/github.js +7 -1
  44. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +1 -1
  45. package/dist/src/command-line/release/utils/shared.d.ts +2 -2
  46. package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
  47. package/dist/src/command-line/release/version/release-group-processor.js +80 -6
  48. package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
  49. package/dist/src/command-line/release/version/version-actions.js +9 -1
  50. package/dist/src/command-line/release/version.js +9 -5
  51. package/dist/src/command-line/reset/reset.js +6 -1
  52. package/dist/src/command-line/run/run-one.js +1 -0
  53. package/dist/src/command-line/run-many/run-many.js +1 -0
  54. package/dist/src/command-line/show/show-target/info.js +11 -2
  55. package/dist/src/command-line/show/show-target/inputs.js +50 -153
  56. package/dist/src/command-line/show/show-target/outputs.js +48 -173
  57. package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
  58. package/dist/src/command-line/show/show-target/utils.js +83 -3
  59. package/dist/src/command-line/watch/watch.js +13 -0
  60. package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
  61. package/dist/src/commands-runner/create-command-graph.js +5 -0
  62. package/dist/src/config/nx-json.d.ts +5 -3
  63. package/dist/src/core/graph/main.js +1 -1
  64. package/dist/src/core/graph/styles.js +1 -1
  65. package/dist/src/daemon/client/client.d.ts +52 -3
  66. package/dist/src/daemon/client/client.js +177 -55
  67. package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
  68. package/dist/src/daemon/client/daemon-environment.js +110 -2
  69. package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
  70. package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
  71. package/dist/src/daemon/message-types/daemon-message.js +25 -0
  72. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
  73. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
  74. package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
  75. package/dist/src/daemon/server/latest-nx.js +5 -2
  76. package/dist/src/daemon/server/server.js +31 -4
  77. package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
  78. package/dist/src/daemon/server/shutdown-utils.js +11 -4
  79. package/dist/src/daemon/socket-utils.d.ts +1 -0
  80. package/dist/src/daemon/socket-utils.js +24 -3
  81. package/dist/src/daemon/tmp-dir.d.ts +43 -3
  82. package/dist/src/daemon/tmp-dir.js +437 -15
  83. package/dist/src/devkit-internals.d.ts +96 -3
  84. package/dist/src/devkit-internals.js +200 -4
  85. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +5 -0
  86. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +9 -2
  87. package/dist/src/generators/tree.d.ts +4 -2
  88. package/dist/src/generators/utils/nx-json.js +13 -3
  89. package/dist/src/hasher/check-task-files.d.ts +86 -0
  90. package/dist/src/hasher/check-task-files.js +378 -0
  91. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  92. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  93. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  94. package/dist/src/native/index.d.ts +31 -2
  95. package/dist/src/native/index.js +71 -28
  96. package/dist/src/native/native-bindings.js +3 -0
  97. package/dist/src/native/native-file-cache-location.d.ts +17 -1
  98. package/dist/src/native/native-file-cache-location.js +86 -12
  99. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  100. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  101. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  102. package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
  103. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  104. package/dist/src/plugins/js/lock-file/npm-parser.js +71 -27
  105. package/dist/src/plugins/js/lock-file/pnpm-parser.js +110 -17
  106. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +15 -9
  107. package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -0
  108. package/dist/src/plugins/js/lock-file/yarn-parser.js +32 -5
  109. package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
  110. package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
  111. package/dist/src/plugins/js/utils/register.d.ts +18 -0
  112. package/dist/src/plugins/js/utils/register.js +81 -0
  113. package/dist/src/plugins/js/utils/typescript.d.ts +9 -0
  114. package/dist/src/plugins/js/utils/typescript.js +15 -0
  115. package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
  116. package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
  117. package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
  118. package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
  119. package/dist/src/project-graph/build-project-graph.js +7 -1
  120. package/dist/src/project-graph/error-types.d.ts +12 -1
  121. package/dist/src/project-graph/error-types.js +68 -3
  122. package/dist/src/project-graph/file-utils.js +6 -1
  123. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
  124. package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +22 -1
  125. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
  126. package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
  127. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
  128. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
  129. package/dist/src/project-graph/plugins/transpiler.js +4 -0
  130. package/dist/src/project-graph/project-graph.js +23 -0
  131. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +10 -12
  132. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +93 -63
  133. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +5 -8
  134. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +16 -15
  135. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
  136. package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
  137. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
  138. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
  139. package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
  140. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
  141. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
  142. package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
  143. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
  144. package/dist/src/project-graph/utils/project-configuration-utils.js +79 -101
  145. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +11 -4
  146. package/dist/src/tasks-runner/life-cycles/performance-analysis.js +15 -6
  147. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +5 -4
  148. package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +18 -8
  149. package/dist/src/tasks-runner/life-cycles/performance-report.js +66 -29
  150. package/dist/src/tasks-runner/run-command.js +4 -2
  151. package/dist/src/tasks-runner/task-env.d.ts +9 -0
  152. package/dist/src/tasks-runner/task-env.js +31 -4
  153. package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -1
  154. package/dist/src/tasks-runner/task-orchestrator.js +23 -10
  155. package/dist/src/tasks-runner/utils.js +2 -6
  156. package/dist/src/utils/acknowledge-build-scripts.d.ts +13 -0
  157. package/dist/src/utils/acknowledge-build-scripts.js +102 -0
  158. package/dist/src/utils/analytics-prompt.d.ts +0 -6
  159. package/dist/src/utils/analytics-prompt.js +0 -51
  160. package/dist/src/utils/assert-workspace-validity.js +7 -2
  161. package/dist/src/utils/catalog/manager-utils.d.ts +1 -2
  162. package/dist/src/utils/catalog/manager-utils.js +22 -5
  163. package/dist/src/utils/catalog/pnpm-manager.d.ts +1 -0
  164. package/dist/src/utils/catalog/pnpm-manager.js +3 -15
  165. package/dist/src/utils/catalog/yarn-manager.d.ts +1 -0
  166. package/dist/src/utils/catalog/yarn-manager.js +3 -15
  167. package/dist/src/utils/command-line-utils.js +30 -20
  168. package/dist/src/utils/fileutils.d.ts +5 -0
  169. package/dist/src/utils/fileutils.js +7 -2
  170. package/dist/src/utils/git-revision.d.ts +12 -0
  171. package/dist/src/utils/git-revision.js +25 -0
  172. package/dist/src/utils/git-utils.d.ts +16 -3
  173. package/dist/src/utils/git-utils.js +146 -52
  174. package/dist/src/utils/git-worktrees.d.ts +30 -0
  175. package/dist/src/utils/git-worktrees.js +212 -0
  176. package/dist/src/utils/ignore.d.ts +128 -1
  177. package/dist/src/utils/ignore.js +182 -12
  178. package/dist/src/utils/long-running-target.d.ts +10 -0
  179. package/dist/src/utils/long-running-target.js +19 -0
  180. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  181. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  182. package/dist/src/utils/min-release-age/behavior/pnpm.js +9 -7
  183. package/dist/src/utils/min-release-age/packument.js +1 -1
  184. package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
  185. package/dist/src/utils/nx-tmp-dir.js +40 -0
  186. package/dist/src/utils/owned-private-dir.d.ts +132 -0
  187. package/dist/src/utils/owned-private-dir.js +323 -0
  188. package/dist/src/utils/package-json.js +11 -7
  189. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  190. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  191. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  192. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  193. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  194. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  195. package/dist/src/utils/package-manager.d.ts +23 -2
  196. package/dist/src/utils/package-manager.js +264 -43
  197. package/dist/src/utils/provenance.js +18 -16
  198. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  199. package/dist/src/utils/registry-config/bun.js +257 -0
  200. package/dist/src/utils/registry-config/index.d.ts +13 -0
  201. package/dist/src/utils/registry-config/index.js +102 -0
  202. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  203. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  204. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  205. package/dist/src/utils/registry-config/utils.js +496 -0
  206. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  207. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  208. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  209. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  210. package/dist/src/utils/safe-spawn.d.ts +24 -0
  211. package/dist/src/utils/safe-spawn.js +104 -0
  212. package/dist/src/utils/shell-quoting.d.ts +15 -0
  213. package/dist/src/utils/shell-quoting.js +35 -0
  214. package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
  215. package/dist/src/utils/wait-for-socket-connection.js +14 -8
  216. package/dist/src/utils/workspace-id.d.ts +20 -0
  217. package/dist/src/utils/workspace-id.js +54 -0
  218. package/migrations.json +13 -1
  219. package/package.json +22 -17
  220. package/dist/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
  221. package/dist/src/migrations/update-17-3-0/nx-release-path.js +0 -47
  222. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  223. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -1,7 +1,134 @@
1
1
  import ignore = require('ignore');
2
2
  import { Tree } from '../generators/tree';
3
3
  export declare function getIgnoreObject(root?: string): ReturnType<typeof ignore>;
4
- export declare function getIgnoreObjectForTree(tree: Tree): ignore.Ignore;
4
+ /** One directory's ignore files, and the directory its patterns are rooted at. */
5
+ export type ScopedIgnoreMatcher = {
6
+ /** Workspace-relative POSIX directory, `''` for the workspace root. */
7
+ dir: string;
8
+ /** How they relate is decided at build time - see `merge`. */
9
+ matchers: ReturnType<typeof ignore>[];
10
+ };
11
+ /**
12
+ * Resolves the ignore files that apply to a directory: its own and every one
13
+ * above it, up to the workspace root.
14
+ *
15
+ * Ignore files cascade - a `.gitignore` covers its own directory and below, and
16
+ * its patterns are relative to *itself*, not to the workspace root. Reading only
17
+ * the root file, which is what `getIgnoreObject` does, silently misses every
18
+ * nested one.
19
+ *
20
+ * A directory's answer is its own files plus its parent's, so every directory on
21
+ * the way up is memoized rather than only the one asked for: sibling leaves
22
+ * share the whole trunk, and a later walk stops at the first directory already
23
+ * known.
24
+ *
25
+ * `read` decides where the files come from - `tree.read` for a generator, disk
26
+ * for a caller with no tree - and returns an empty string or null when there is
27
+ * no such file. Paths handed to it are workspace-relative POSIX.
28
+ *
29
+ * `merge` decides how the files *within one directory* relate, and the two
30
+ * consumers genuinely need different rules:
31
+ *
32
+ * - `false` is prettier's: one matcher per file, any of them excluding wins, and
33
+ * a negation counts only if none excluded. `createIsIgnoredFunction` builds an
34
+ * ignorer per `--ignore-path` and ORs them, so a `!x` in `.prettierignore`
35
+ * cannot re-include an `x` that `.gitignore` excluded.
36
+ * - `true` is git's and the native walker's: all files in one matcher, so
37
+ * `.nxignore`'s `!x` removes `.gitignore`'s exclusion of `x` outright. It has
38
+ * to be a merge rather than a precedence check between separate matchers,
39
+ * because a lone `!x` in its own matcher reports an opinion on `x/` but *none*
40
+ * on `x/a.ts` (measured), so the exclusion would still reach the children.
41
+ * The merge only removes the exclusion within that one directory - a negation
42
+ * in a nested file still loses to an ancestor's exclusion.
43
+ *
44
+ * When `merge` is true, `filenames` order matters: they go into one matcher in
45
+ * order and the last matching pattern decides, so list them lowest-authority
46
+ * first.
47
+ */
48
+ export declare function createIgnoreChainResolver(read: (path: string) => string | null | undefined, filenames: string[], merge: boolean): (dir: string) => ScopedIgnoreMatcher[];
49
+ /**
50
+ * True when the file is ignored, resolving the chain nearest file first.
51
+ *
52
+ * Each matcher is tested against the path relative to its own directory, which
53
+ * is what makes a nested pattern like `/build` mean that directory's `build`
54
+ * rather than the workspace's.
55
+ *
56
+ * Nearest directory with an *opinion* wins, not the first match: a nested
57
+ * `!keep.log` must override the root's `*.log`, which is git's rule for files.
58
+ * A nested negation of a *directory* does not reach its children - see the
59
+ * `merge` note on `createIgnoreChainResolver`.
60
+ *
61
+ * How the files of one directory relate is decided when the chain is built - see
62
+ * that same note. Here they are simply the entry's matchers: any one excluding
63
+ * wins, and a negation counts only if none excluded.
64
+ *
65
+ * Two preconditions, both satisfied by a pruning walk and neither enforced:
66
+ *
67
+ * - `filePath` is workspace-relative POSIX and must sit under every `dir` in the
68
+ * chain, which holds when the chain came from that file's own directory.
69
+ * - No ancestor directory of `filePath` may itself be ignored. git refuses to
70
+ * re-include a file inside an excluded directory, and this does not implement
71
+ * that rule: asked directly about `dist/keep.ts` with a root `dist/` and a
72
+ * nested `dist/.gitignore` holding `!keep.ts`, it answers "not ignored" where
73
+ * git says ignored (measured). `visitNotIgnoredFiles` never asks, because it
74
+ * prunes `dist/` before descending - which is what makes its answers match
75
+ * git, and why that pruning is load-bearing for correctness rather than speed.
76
+ */
77
+ export declare function isIgnoredByChain(chain: ScopedIgnoreMatcher[], filePath: string): boolean;
78
+ /**
79
+ * Directories that should never be walked, whatever the workspace's own ignore
80
+ * files say - `node_modules`, `.git`, the nx caches.
81
+ *
82
+ * The list comes from the native walker rather than a second copy here, so a
83
+ * filesystem walk and a tree walk cannot drift apart.
84
+ *
85
+ * Checked ahead of the cascading chain rather than folded into it: these are not
86
+ * re-includable, and as ordinary patterns a nested negation could resurrect
87
+ * `node_modules`.
88
+ */
89
+ export declare function isAlwaysIgnored(path: string): boolean;
90
+ /**
91
+ * The chain bound to a tree, as predicates over workspace-relative POSIX paths.
92
+ *
93
+ * Files and directories are asked separately because the answers differ: a
94
+ * pattern is only directory-only if it ends in a slash, and `ignore` will not
95
+ * match `dist/` against the path `dist`. Callers must not have to know that, so
96
+ * the slash is appended inside and never leaves this module.
97
+ */
98
+ export type TreeIgnoreChecker = {
99
+ isIgnoredFile: (path: string) => boolean;
100
+ isIgnoredDirectory: (path: string) => boolean;
101
+ };
102
+ /**
103
+ * What git ignores, which is also what the native walker ignores.
104
+ *
105
+ * `.nxignore` outranks `.gitignore` - `walker.rs` registers it with
106
+ * `add_custom_ignore_filename` - which a merge with `.nxignore` last reproduces.
107
+ * git itself does not read it.
108
+ *
109
+ * Reads from the tree rather than disk because a generator can create or amend
110
+ * an ignore file in the same run, which would leave the on-disk copy stale.
111
+ */
112
+ export declare function createGitIgnoreChecker(tree: Tree): TreeIgnoreChecker;
113
+ /**
114
+ * What prettier ignores: the workspace root only, and one ignorer per
115
+ * `--ignore-path` ORed rather than merged (both measured), so a `!` in
116
+ * `.prettierignore` cannot re-include what `.gitignore` excluded. That is the
117
+ * CLI `nx format:check` shells out to.
118
+ *
119
+ * Not an exact match for that command: `isAlwaysIgnored` is wider than
120
+ * prettier's built-ins, and `format.ts` filters its own patterns through
121
+ * `.nxignore`, which this does not read.
122
+ *
123
+ * Reads from the tree rather than disk, as above.
124
+ */
125
+ export declare function createPrettierIgnoreChecker(tree: Tree): TreeIgnoreChecker;
126
+ /**
127
+ * `path.dirname` for the workspace-relative POSIX paths the chain is keyed by,
128
+ * except that the workspace root is `''` rather than `.` - that is the key
129
+ * `createIgnoreChainResolver` terminates on.
130
+ */
131
+ export declare function posixDirname(relativePath: string): string;
5
132
  /**
6
133
  * Adds an entry to a .gitignore file if it's not already covered by existing patterns.
7
134
  * Creates the file if it doesn't exist.
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getIgnoreObject = getIgnoreObject;
4
- exports.getIgnoreObjectForTree = getIgnoreObjectForTree;
4
+ exports.createIgnoreChainResolver = createIgnoreChainResolver;
5
+ exports.isIgnoredByChain = isIgnoredByChain;
6
+ exports.isAlwaysIgnored = isAlwaysIgnored;
7
+ exports.createGitIgnoreChecker = createGitIgnoreChecker;
8
+ exports.createPrettierIgnoreChecker = createPrettierIgnoreChecker;
9
+ exports.posixDirname = posixDirname;
5
10
  exports.addEntryToGitIgnore = addEntryToGitIgnore;
6
11
  const ignore = require("ignore");
12
+ const index_1 = require("../native/index");
7
13
  const fileutils_1 = require("./fileutils");
8
14
  const workspace_root_1 = require("./workspace-root");
9
15
  function getIgnoreObject(root = workspace_root_1.workspaceRoot) {
@@ -12,18 +18,182 @@ function getIgnoreObject(root = workspace_root_1.workspaceRoot) {
12
18
  ig.add((0, fileutils_1.readFileIfExisting)(`${root}/.nxignore`));
13
19
  return ig;
14
20
  }
15
- function getIgnoreObjectForTree(tree) {
16
- let ig;
17
- if (tree.exists('.gitignore')) {
18
- ig = ignore();
19
- ig.add('.git');
20
- ig.add(tree.read('.gitignore', 'utf-8'));
21
- }
22
- if (tree.exists('.nxignore')) {
23
- ig ??= ignore();
24
- ig.add(tree.read('.nxignore', 'utf-8'));
21
+ /**
22
+ * Resolves the ignore files that apply to a directory: its own and every one
23
+ * above it, up to the workspace root.
24
+ *
25
+ * Ignore files cascade - a `.gitignore` covers its own directory and below, and
26
+ * its patterns are relative to *itself*, not to the workspace root. Reading only
27
+ * the root file, which is what `getIgnoreObject` does, silently misses every
28
+ * nested one.
29
+ *
30
+ * A directory's answer is its own files plus its parent's, so every directory on
31
+ * the way up is memoized rather than only the one asked for: sibling leaves
32
+ * share the whole trunk, and a later walk stops at the first directory already
33
+ * known.
34
+ *
35
+ * `read` decides where the files come from - `tree.read` for a generator, disk
36
+ * for a caller with no tree - and returns an empty string or null when there is
37
+ * no such file. Paths handed to it are workspace-relative POSIX.
38
+ *
39
+ * `merge` decides how the files *within one directory* relate, and the two
40
+ * consumers genuinely need different rules:
41
+ *
42
+ * - `false` is prettier's: one matcher per file, any of them excluding wins, and
43
+ * a negation counts only if none excluded. `createIsIgnoredFunction` builds an
44
+ * ignorer per `--ignore-path` and ORs them, so a `!x` in `.prettierignore`
45
+ * cannot re-include an `x` that `.gitignore` excluded.
46
+ * - `true` is git's and the native walker's: all files in one matcher, so
47
+ * `.nxignore`'s `!x` removes `.gitignore`'s exclusion of `x` outright. It has
48
+ * to be a merge rather than a precedence check between separate matchers,
49
+ * because a lone `!x` in its own matcher reports an opinion on `x/` but *none*
50
+ * on `x/a.ts` (measured), so the exclusion would still reach the children.
51
+ * The merge only removes the exclusion within that one directory - a negation
52
+ * in a nested file still loses to an ancestor's exclusion.
53
+ *
54
+ * When `merge` is true, `filenames` order matters: they go into one matcher in
55
+ * order and the last matching pattern decides, so list them lowest-authority
56
+ * first.
57
+ */
58
+ function createIgnoreChainResolver(read, filenames, merge) {
59
+ const cache = new Map();
60
+ const resolve = (dir) => {
61
+ const cached = cache.get(dir);
62
+ if (cached) {
63
+ return cached;
64
+ }
65
+ const contents = filenames
66
+ .map((name) => read(dir ? `${dir}/${name}` : name))
67
+ .filter((c) => !!c);
68
+ const matchers = merge
69
+ ? contents.length > 0
70
+ ? [contents.reduce((m, c) => m.add(c), ignore())]
71
+ : []
72
+ : contents.map((c) => ignore().add(c));
73
+ const inherited = dir === '' ? [] : resolve(posixDirname(dir));
74
+ const chain = matchers.length > 0 ? [{ dir, matchers }, ...inherited] : inherited;
75
+ cache.set(dir, chain);
76
+ return chain;
77
+ };
78
+ return resolve;
79
+ }
80
+ /**
81
+ * True when the file is ignored, resolving the chain nearest file first.
82
+ *
83
+ * Each matcher is tested against the path relative to its own directory, which
84
+ * is what makes a nested pattern like `/build` mean that directory's `build`
85
+ * rather than the workspace's.
86
+ *
87
+ * Nearest directory with an *opinion* wins, not the first match: a nested
88
+ * `!keep.log` must override the root's `*.log`, which is git's rule for files.
89
+ * A nested negation of a *directory* does not reach its children - see the
90
+ * `merge` note on `createIgnoreChainResolver`.
91
+ *
92
+ * How the files of one directory relate is decided when the chain is built - see
93
+ * that same note. Here they are simply the entry's matchers: any one excluding
94
+ * wins, and a negation counts only if none excluded.
95
+ *
96
+ * Two preconditions, both satisfied by a pruning walk and neither enforced:
97
+ *
98
+ * - `filePath` is workspace-relative POSIX and must sit under every `dir` in the
99
+ * chain, which holds when the chain came from that file's own directory.
100
+ * - No ancestor directory of `filePath` may itself be ignored. git refuses to
101
+ * re-include a file inside an excluded directory, and this does not implement
102
+ * that rule: asked directly about `dist/keep.ts` with a root `dist/` and a
103
+ * nested `dist/.gitignore` holding `!keep.ts`, it answers "not ignored" where
104
+ * git says ignored (measured). `visitNotIgnoredFiles` never asks, because it
105
+ * prunes `dist/` before descending - which is what makes its answers match
106
+ * git, and why that pruning is load-bearing for correctness rather than speed.
107
+ */
108
+ function isIgnoredByChain(chain, filePath) {
109
+ for (const { dir, matchers } of chain) {
110
+ const relative = dir === '' ? filePath : filePath.slice(dir.length + 1);
111
+ let unignored = false;
112
+ for (const matcher of matchers) {
113
+ const result = matcher.test(relative);
114
+ if (result.ignored) {
115
+ return true;
116
+ }
117
+ unignored ||= result.unignored;
118
+ }
119
+ if (unignored) {
120
+ return false;
121
+ }
25
122
  }
26
- return ig;
123
+ return false;
124
+ }
125
+ let alwaysIgnored;
126
+ /**
127
+ * Directories that should never be walked, whatever the workspace's own ignore
128
+ * files say - `node_modules`, `.git`, the nx caches.
129
+ *
130
+ * The list comes from the native walker rather than a second copy here, so a
131
+ * filesystem walk and a tree walk cannot drift apart.
132
+ *
133
+ * Checked ahead of the cascading chain rather than folded into it: these are not
134
+ * re-includable, and as ordinary patterns a nested negation could resurrect
135
+ * `node_modules`.
136
+ */
137
+ function isAlwaysIgnored(path) {
138
+ alwaysIgnored ??= ignore().add((0, index_1.getHardcodedIgnorePatterns)());
139
+ return alwaysIgnored.ignores(path);
140
+ }
141
+ /**
142
+ * What git ignores, which is also what the native walker ignores.
143
+ *
144
+ * `.nxignore` outranks `.gitignore` - `walker.rs` registers it with
145
+ * `add_custom_ignore_filename` - which a merge with `.nxignore` last reproduces.
146
+ * git itself does not read it.
147
+ *
148
+ * Reads from the tree rather than disk because a generator can create or amend
149
+ * an ignore file in the same run, which would leave the on-disk copy stale.
150
+ */
151
+ function createGitIgnoreChecker(tree) {
152
+ return createTreeIgnoreChecker(tree, {
153
+ filenames: ['.gitignore', '.nxignore'],
154
+ cascade: true,
155
+ merge: true,
156
+ });
157
+ }
158
+ /**
159
+ * What prettier ignores: the workspace root only, and one ignorer per
160
+ * `--ignore-path` ORed rather than merged (both measured), so a `!` in
161
+ * `.prettierignore` cannot re-include what `.gitignore` excluded. That is the
162
+ * CLI `nx format:check` shells out to.
163
+ *
164
+ * Not an exact match for that command: `isAlwaysIgnored` is wider than
165
+ * prettier's built-ins, and `format.ts` filters its own patterns through
166
+ * `.nxignore`, which this does not read.
167
+ *
168
+ * Reads from the tree rather than disk, as above.
169
+ */
170
+ function createPrettierIgnoreChecker(tree) {
171
+ return createTreeIgnoreChecker(tree, {
172
+ filenames: ['.gitignore', '.prettierignore'],
173
+ cascade: false,
174
+ merge: false,
175
+ });
176
+ }
177
+ function createTreeIgnoreChecker(tree, { filenames, cascade, merge }) {
178
+ const resolve = createIgnoreChainResolver((path) => tree.read(path, 'utf-8'), filenames, merge);
179
+ // `probe` may carry a trailing slash; `path` never does. The chain is keyed by
180
+ // real directories, and `posixDirname('dist/')` is `'dist'` rather than the
181
+ // parent, so the lookup always uses the slash-less form.
182
+ const check = (path, probe) => isAlwaysIgnored(probe) ||
183
+ isIgnoredByChain(resolve(cascade ? posixDirname(path) : ''), probe);
184
+ return {
185
+ isIgnoredFile: (path) => check(path, path),
186
+ isIgnoredDirectory: (path) => check(path, `${path}/`),
187
+ };
188
+ }
189
+ /**
190
+ * `path.dirname` for the workspace-relative POSIX paths the chain is keyed by,
191
+ * except that the workspace root is `''` rather than `.` - that is the key
192
+ * `createIgnoreChainResolver` terminates on.
193
+ */
194
+ function posixDirname(relativePath) {
195
+ const separator = relativePath.lastIndexOf('/');
196
+ return separator === -1 ? '' : relativePath.slice(0, separator);
27
197
  }
28
198
  /**
29
199
  * Adds an entry to a .gitignore file if it's not already covered by existing patterns.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Target names the pre-23 `longRunningTask` guard excluded from caching. Shared
3
+ * between that guard and the deprecated target-name cache fallback so the two
4
+ * cannot drift apart.
5
+ *
6
+ * The copy in `migrations/update-23-2-0/set-cache-on-executor-target-defaults.ts`
7
+ * deliberately does not use this: a migration's decision has to freeze at the
8
+ * semantics it shipped with.
9
+ */
10
+ export declare function isLongRunningTargetName(targetName: string): boolean;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLongRunningTargetName = isLongRunningTargetName;
4
+ /**
5
+ * Target names the pre-23 `longRunningTask` guard excluded from caching. Shared
6
+ * between that guard and the deprecated target-name cache fallback so the two
7
+ * cannot drift apart.
8
+ *
9
+ * The copy in `migrations/update-23-2-0/set-cache-on-executor-target-defaults.ts`
10
+ * deliberately does not use this: a migration's decision has to freeze at the
11
+ * semantics it shipped with.
12
+ */
13
+ function isLongRunningTargetName(targetName) {
14
+ return (targetName.endsWith(':watch') ||
15
+ targetName.endsWith('-watch') ||
16
+ targetName === 'serve' ||
17
+ targetName === 'dev' ||
18
+ targetName === 'start');
19
+ }
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readBunPolicy = readBunPolicy;
4
4
  exports.pickBunVersion = pickBunVersion;
5
- const fs_1 = require("fs");
6
5
  const path_1 = require("path");
7
6
  const semver_1 = require("semver");
8
- const smol_toml_1 = require("smol-toml");
7
+ const bunfig_1 = require("../../package-manager-config/bunfig");
9
8
  const constants_1 = require("../constants");
10
9
  const errors_1 = require("../errors");
11
10
  const pick_1 = require("../pick");
@@ -82,23 +81,20 @@ function readLocalBunInstall(root) {
82
81
  return readBunInstall((0, path_1.join)(root, 'bunfig.toml'));
83
82
  }
84
83
  function readGlobalBunInstall() {
85
- const xdg = process.env.XDG_CONFIG_HOME;
86
- const base = xdg || process.env.HOME;
84
+ const base = (0, bunfig_1.getBunGlobalConfigBase)(process.env);
87
85
  if (!base) {
88
86
  return {};
89
87
  }
90
88
  return readBunInstall((0, path_1.join)(base, '.bunfig.toml'));
91
89
  }
92
90
  function readBunInstall(path) {
93
- if (!(0, fs_1.existsSync)(path)) {
91
+ const parsed = (0, bunfig_1.readBunfigRaw)(path);
92
+ // bun skips a bunfig it cannot read and resolves on, so its settings do not
93
+ // apply. Only a parse failure kills the install.
94
+ if (parsed === null || parsed === 'unreadable') {
94
95
  return {};
95
96
  }
96
- let parsed;
97
- try {
98
- parsed = (0, smol_toml_1.parse)((0, fs_1.readFileSync)(path, 'utf-8'));
99
- }
100
- catch {
101
- // Unparseable bunfig makes bun's install die; treat as a hard error.
97
+ if (parsed === 'invalid') {
102
98
  return 'error';
103
99
  }
104
100
  const install = parsed.install;
@@ -8,7 +8,7 @@ const path_1 = require("path");
8
8
  const semver_1 = require("semver");
9
9
  const constants_1 = require("../constants");
10
10
  const errors_1 = require("../errors");
11
- const npmrc_1 = require("../npmrc");
11
+ const npmrc_1 = require("../../package-manager-config/npmrc");
12
12
  const pick_1 = require("../pick");
13
13
  const RANK_UNKNOWN = 0; // global/builtin/default - not detectable here
14
14
  const RANK_USER = 1;
@@ -116,7 +116,10 @@ function detectSurfaces(root, env) {
116
116
  }
117
117
  function readNpmrcKeys(override, fallback) {
118
118
  const present = { minReleaseAge: false, before: false };
119
- for (const { key } of (0, npmrc_1.readNpmrcEntries)(override ?? fallback) ?? []) {
119
+ // npm silently treats an .npmrc it cannot read as absent, so both non-array
120
+ // states scan nothing.
121
+ const entries = (0, npmrc_1.readNpmrcEntries)(override ?? fallback);
122
+ for (const { key } of Array.isArray(entries) ? entries : []) {
120
123
  if (key === 'min-release-age') {
121
124
  present.minReleaseAge = true;
122
125
  }
@@ -88,15 +88,17 @@ function readPnpmConfigList(root) {
88
88
  return null;
89
89
  }
90
90
  }
91
- // Extracts the cooldown keys from pnpm's reported config. pnpm reports the
92
- // kebab-case keys; the exclude list comes back as a JSON array (set in a yaml
93
- // surface) or a comma-joined string (set via .npmrc / env).
91
+ // Extracts the cooldown keys from pnpm's reported config. pnpm 11 reports them
92
+ // camelCase; pnpm 10 reported them kebab-case, so read both forms. The exclude
93
+ // list comes back as a JSON array (set in a yaml surface) or a comma-joined
94
+ // string (set via .npmrc / env).
94
95
  function parseCooldownConfig(config) {
96
+ const read = (camelKey, kebabKey) => config[camelKey] ?? config[kebabKey];
95
97
  return {
96
- windowMinutes: toNumber(config['minimum-release-age']) ?? undefined,
97
- excludes: parseExcludeValue(config['minimum-release-age-exclude']),
98
- strictExplicit: toBoolean(config['minimum-release-age-strict']),
99
- ignoreMissingTimeExplicit: toBoolean(config['minimum-release-age-ignore-missing-time']),
98
+ windowMinutes: toNumber(read('minimumReleaseAge', 'minimum-release-age')) ?? undefined,
99
+ excludes: parseExcludeValue(read('minimumReleaseAgeExclude', 'minimum-release-age-exclude')),
100
+ strictExplicit: toBoolean(read('minimumReleaseAgeStrict', 'minimum-release-age-strict')),
101
+ ignoreMissingTimeExplicit: toBoolean(read('minimumReleaseAgeIgnoreMissingTime', 'minimum-release-age-ignore-missing-time')),
100
102
  };
101
103
  }
102
104
  function parseExcludeValue(value) {
@@ -16,7 +16,7 @@ function toArray(value) {
16
16
  * `dist-tags` carries a hyphen.
17
17
  */
18
18
  async function fetchRegistryMetadata(pkg) {
19
- const raw = await (0, package_manager_1.packageRegistryView)(pkg, '', '--json');
19
+ const raw = await (0, package_manager_1.packageRegistryView)(pkg, '', ['--json']);
20
20
  const parsed = JSON.parse(raw);
21
21
  const time = parsed.time ?? null;
22
22
  if (time) {
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Stable root for Nx runtime artifacts that need an OS tmp location. On POSIX a
3
+ * literal `/tmp`, not `os.tmpdir()`, which honours `$TMPDIR` — per-user on
4
+ * macOS, rewritten by sandboxes, stripped from the daemon env, so client and
5
+ * daemon would disagree. Windows has no `/tmp`, and `%TMP%` is already per-user
6
+ * and stable, so it keeps `os.tmpdir()`.
7
+ *
8
+ * Consumed by the native binding loader, so keep this file limited to local
9
+ * helpers that themselves use Node builtins only.
10
+ */
11
+ export declare const NX_TMP_DIR: string;
12
+ /**
13
+ * Owner-only runtime root for the current user. No user segment on Windows —
14
+ * `%TMP%` is already per-account, and the segment would only cost path length.
15
+ */
16
+ export declare const NX_USER_TMP_DIR: string;
17
+ /** Runtime root under the user's home, used when the shared container cannot be established. */
18
+ export declare const NX_HOME_TMP_DIR: string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NX_HOME_TMP_DIR = exports.NX_USER_TMP_DIR = exports.NX_TMP_DIR = void 0;
4
+ const node_os_1 = require("node:os");
5
+ const node_path_1 = require("node:path");
6
+ const owned_private_dir_1 = require("./owned-private-dir");
7
+ /**
8
+ * Stable root for Nx runtime artifacts that need an OS tmp location. On POSIX a
9
+ * literal `/tmp`, not `os.tmpdir()`, which honours `$TMPDIR` — per-user on
10
+ * macOS, rewritten by sandboxes, stripped from the daemon env, so client and
11
+ * daemon would disagree. Windows has no `/tmp`, and `%TMP%` is already per-user
12
+ * and stable, so it keeps `os.tmpdir()`.
13
+ *
14
+ * Consumed by the native binding loader, so keep this file limited to local
15
+ * helpers that themselves use Node builtins only.
16
+ */
17
+ exports.NX_TMP_DIR = (0, node_os_1.platform)() === 'win32' ? (0, node_path_1.join)((0, node_os_1.tmpdir)(), '.nx') : '/tmp/.nx';
18
+ /**
19
+ * Owner-only runtime root for the current user. No user segment on Windows —
20
+ * `%TMP%` is already per-account, and the segment would only cost path length.
21
+ */
22
+ exports.NX_USER_TMP_DIR = (0, node_os_1.platform)() === 'win32' ? exports.NX_TMP_DIR : (0, node_path_1.join)(exports.NX_TMP_DIR, (0, owned_private_dir_1.getUserSegment)());
23
+ /** Runtime root under the user's home, used when the shared container cannot be established. */
24
+ exports.NX_HOME_TMP_DIR = resolveHomeTmpDir();
25
+ /**
26
+ * Absolute, not merely non-empty: a relative `$HOME` would make `join` return
27
+ * `.nx`, putting sockets under the cwd and aiming `removeSocketDir`'s recursive
28
+ * delete at it. A rootless container has no `$HOME` and no passwd entry, so
29
+ * `homedir()` throws or returns empty — caught here because this runs at module
30
+ * scope and the native binding loader imports this file.
31
+ */
32
+ function resolveHomeTmpDir() {
33
+ try {
34
+ const home = (0, node_os_1.homedir)();
35
+ return home && (0, node_path_1.isAbsolute)(home) ? (0, node_path_1.join)(home, '.nx') : undefined;
36
+ }
37
+ catch {
38
+ return undefined;
39
+ }
40
+ }