nx 23.2.0-beta.7 → 23.2.0-beta.9

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 (188) hide show
  1. package/dist/bin/init-local.js +3 -5
  2. package/dist/release/changelog-renderer/index.js +4 -5
  3. package/dist/src/adapter/ngcli-adapter.js +60 -1
  4. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +2 -2
  5. package/dist/src/command-line/completion/command-object.js +7 -12
  6. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +17 -23
  7. package/dist/src/command-line/format/format.js +84 -101
  8. package/dist/src/command-line/generate/generate.js +35 -35
  9. package/dist/src/command-line/import/import.js +30 -40
  10. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  11. package/dist/src/command-line/init/command-object.js +4 -2
  12. package/dist/src/command-line/init/configure-plugins.js +4 -1
  13. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  14. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
  15. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  16. package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
  17. package/dist/src/command-line/init/implementation/angular/index.js +10 -15
  18. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
  19. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
  20. package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
  21. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
  22. package/dist/src/command-line/init/implementation/format.d.ts +18 -0
  23. package/dist/src/command-line/init/implementation/format.js +114 -0
  24. package/dist/src/command-line/init/implementation/utils.js +8 -0
  25. package/dist/src/command-line/init/init-v1.js +15 -18
  26. package/dist/src/command-line/init/init-v2.js +37 -56
  27. package/dist/src/command-line/migrate/agentic/definitions.js +35 -8
  28. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +22 -3
  29. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +13 -10
  30. package/dist/src/command-line/migrate/agentic/handoff.d.ts +3 -1
  31. package/dist/src/command-line/migrate/agentic/handoff.js +4 -2
  32. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  33. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  34. package/dist/src/command-line/migrate/agentic/select.js +20 -30
  35. package/dist/src/command-line/migrate/agentic/types.d.ts +19 -3
  36. package/dist/src/command-line/migrate/agentic/types.js +13 -4
  37. package/dist/src/command-line/migrate/command-object.d.ts +3 -0
  38. package/dist/src/command-line/migrate/command-object.js +13 -0
  39. package/dist/src/command-line/migrate/execute-migration.d.ts +14 -0
  40. package/dist/src/command-line/migrate/execute-migration.js +30 -9
  41. package/dist/src/command-line/migrate/migrate-analytics.d.ts +28 -0
  42. package/dist/src/command-line/migrate/migrate-analytics.js +51 -1
  43. package/dist/src/command-line/migrate/migrate-commits.d.ts +8 -2
  44. package/dist/src/command-line/migrate/migrate-commits.js +66 -19
  45. package/dist/src/command-line/migrate/migrate-config.d.ts +4 -2
  46. package/dist/src/command-line/migrate/migrate-config.js +12 -4
  47. package/dist/src/command-line/migrate/migrate.d.ts +13 -2
  48. package/dist/src/command-line/migrate/migrate.js +243 -80
  49. package/dist/src/command-line/migrate/multi-major.js +7 -10
  50. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  51. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  52. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  53. package/dist/src/command-line/migrate/run/index.d.ts +7 -0
  54. package/dist/src/command-line/migrate/run/index.js +19 -1
  55. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  56. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  57. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  58. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  59. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  60. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  61. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  62. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  63. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  64. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  65. package/dist/src/command-line/migrate/run/util.d.ts +58 -0
  66. package/dist/src/command-line/migrate/run/util.js +139 -7
  67. package/dist/src/command-line/migrate/run/worker.d.ts +1 -0
  68. package/dist/src/command-line/migrate/run/worker.js +308 -45
  69. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  70. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  71. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  72. package/dist/src/command-line/migrate/step-actions.js +12 -0
  73. package/dist/src/command-line/migrate/text.d.ts +18 -0
  74. package/dist/src/command-line/migrate/text.js +26 -0
  75. package/dist/src/command-line/migrate/version-skew-guard.d.ts +6 -4
  76. package/dist/src/command-line/migrate/version-skew-guard.js +34 -14
  77. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
  78. package/dist/src/command-line/release/changelog.js +6 -17
  79. package/dist/src/command-line/release/plan.js +15 -28
  80. package/dist/src/command-line/release/release.js +6 -17
  81. package/dist/src/command-line/release/utils/remote-release-clients/github.js +16 -22
  82. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
  83. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  84. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  85. package/dist/src/command-line/release/version.js +2 -2
  86. package/dist/src/core/graph/main.js +1 -1
  87. package/dist/src/daemon/client/client.js +11 -2
  88. package/dist/src/devkit-internals.d.ts +7 -2
  89. package/dist/src/devkit-internals.js +22 -6
  90. package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
  91. package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
  92. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
  93. package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
  94. package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
  95. package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
  96. package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
  97. package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
  98. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
  99. package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
  100. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
  101. package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
  102. package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
  103. package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
  104. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
  105. package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
  106. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
  107. package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
  108. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
  109. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
  110. package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
  111. package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
  112. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
  113. package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
  114. package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
  115. package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
  116. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
  117. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  118. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  119. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  120. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  121. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  122. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
  123. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  124. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +128 -2
  125. package/dist/src/tasks-runner/run-command.js +17 -32
  126. package/dist/src/tasks-runner/task-env.js +5 -2
  127. package/dist/src/tasks-runner/utils.js +2 -6
  128. package/dist/src/utils/analytics-prompt.js +4 -7
  129. package/dist/src/utils/chunkify.d.ts +7 -1
  130. package/dist/src/utils/chunkify.js +10 -3
  131. package/dist/src/utils/exit-codes.d.ts +9 -0
  132. package/dist/src/utils/exit-codes.js +19 -0
  133. package/dist/src/utils/fileutils.d.ts +5 -0
  134. package/dist/src/utils/fileutils.js +7 -2
  135. package/dist/src/utils/formatters/index.d.ts +13 -0
  136. package/dist/src/utils/formatters/index.js +74 -0
  137. package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
  138. package/dist/src/utils/formatters/oxfmt.js +764 -0
  139. package/dist/src/utils/formatters/prettier.d.ts +26 -0
  140. package/dist/src/utils/formatters/prettier.js +201 -0
  141. package/dist/src/utils/formatters/shared.d.ts +5 -0
  142. package/dist/src/utils/formatters/shared.js +8 -0
  143. package/dist/src/utils/git-utils.d.ts +33 -2
  144. package/dist/src/utils/git-utils.js +156 -8
  145. package/dist/src/utils/ignore.d.ts +47 -5
  146. package/dist/src/utils/ignore.js +93 -11
  147. package/dist/src/utils/long-running-target.d.ts +10 -0
  148. package/dist/src/utils/long-running-target.js +19 -0
  149. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  150. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  151. package/dist/src/utils/min-release-age/packument.js +1 -1
  152. package/dist/src/utils/nx-console-prompt.js +3 -6
  153. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  154. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  155. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  156. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  157. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  158. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  159. package/dist/src/utils/package-manager.d.ts +21 -2
  160. package/dist/src/utils/package-manager.js +244 -47
  161. package/dist/src/utils/params.d.ts +7 -1
  162. package/dist/src/utils/params.js +64 -6
  163. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  164. package/dist/src/utils/prompt-helpers.js +111 -0
  165. package/dist/src/utils/provenance.js +6 -14
  166. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  167. package/dist/src/utils/registry-config/bun.js +257 -0
  168. package/dist/src/utils/registry-config/index.d.ts +13 -0
  169. package/dist/src/utils/registry-config/index.js +102 -0
  170. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  171. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  172. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  173. package/dist/src/utils/registry-config/utils.js +496 -0
  174. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  175. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  176. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  177. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  178. package/dist/src/utils/safe-spawn.d.ts +24 -0
  179. package/dist/src/utils/safe-spawn.js +104 -0
  180. package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
  181. package/dist/src/utils/write-formatted-json-file.js +5 -4
  182. package/migrations.json +6 -0
  183. package/package.json +17 -13
  184. package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
  185. package/dist/src/utils/is-using-prettier.d.ts +0 -3
  186. package/dist/src/utils/is-using-prettier.js +0 -62
  187. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  188. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OXFMT_IGNORE_OPTIONS = void 0;
3
4
  exports.getIgnoreObject = getIgnoreObject;
4
5
  exports.createIgnoreChainResolver = createIgnoreChainResolver;
5
6
  exports.isIgnoredByChain = isIgnoredByChain;
7
+ exports.createAncestorAwareIgnoreChecker = createAncestorAwareIgnoreChecker;
6
8
  exports.isAlwaysIgnored = isAlwaysIgnored;
7
9
  exports.createGitIgnoreChecker = createGitIgnoreChecker;
8
10
  exports.createPrettierIgnoreChecker = createPrettierIgnoreChecker;
11
+ exports.createOxfmtIgnoreChecker = createOxfmtIgnoreChecker;
9
12
  exports.posixDirname = posixDirname;
10
13
  exports.addEntryToGitIgnore = addEntryToGitIgnore;
11
14
  const ignore = require("ignore");
@@ -93,7 +96,7 @@ function createIgnoreChainResolver(read, filenames, merge) {
93
96
  * that same note. Here they are simply the entry's matchers: any one excluding
94
97
  * wins, and a negation counts only if none excluded.
95
98
  *
96
- * Two preconditions, both satisfied by a pruning walk and neither enforced:
99
+ * Two preconditions, neither enforced here:
97
100
  *
98
101
  * - `filePath` is workspace-relative POSIX and must sit under every `dir` in the
99
102
  * chain, which holds when the chain came from that file's own directory.
@@ -101,9 +104,10 @@ function createIgnoreChainResolver(read, filenames, merge) {
101
104
  * re-include a file inside an excluded directory, and this does not implement
102
105
  * that rule: asked directly about `dist/keep.ts` with a root `dist/` and a
103
106
  * 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
+ * git says ignored (measured). A pruning walk like `visitNotIgnoredFiles`
108
+ * satisfies it by never asking about anything under `dist/`; a per-file
109
+ * caller cannot, so it goes through `createAncestorAwareIgnoreChecker`,
110
+ * which checks the ancestors before asking the chain.
107
111
  */
108
112
  function isIgnoredByChain(chain, filePath) {
109
113
  for (const { dir, matchers } of chain) {
@@ -122,6 +126,45 @@ function isIgnoredByChain(chain, filePath) {
122
126
  }
123
127
  return false;
124
128
  }
129
+ /**
130
+ * The chain's answers plus git's excluded-ancestor rule: nothing inside an
131
+ * ignored directory can be re-included, so a nested negation must not
132
+ * resurrect a file whose ancestor an outer file excluded - the case
133
+ * `isIgnoredByChain` alone gets wrong (see its second precondition). The
134
+ * oxfmt CLI follows the same rule (measured against 0.60.0: a scan skips a
135
+ * nested `!keep.ts` under a root-ignored `dist/`), so every per-file caller -
136
+ * the cascading tree checkers and the disk-backed resolver in
137
+ * `formatters/oxfmt.ts` - goes through here.
138
+ *
139
+ * A directory's own ignore files cannot un-ignore the directory itself, so
140
+ * its verdict comes from its parent's chain - probed with a trailing slash,
141
+ * which is what makes a directory-only pattern like `dist/` match. Verdicts
142
+ * are memoized per directory, so a batch of files shares its ancestor walks.
143
+ */
144
+ function createAncestorAwareIgnoreChecker(resolve) {
145
+ const ignoredDirs = new Map();
146
+ const isIgnoredDirectory = (dir) => {
147
+ if (dir === '') {
148
+ return false;
149
+ }
150
+ const cached = ignoredDirs.get(dir);
151
+ if (cached !== undefined) {
152
+ return cached;
153
+ }
154
+ const parent = posixDirname(dir);
155
+ const ignored = isIgnoredDirectory(parent) ||
156
+ isIgnoredByChain(resolve(parent), `${dir}/`);
157
+ ignoredDirs.set(dir, ignored);
158
+ return ignored;
159
+ };
160
+ return {
161
+ isIgnoredFile: (filePath) => {
162
+ const dir = posixDirname(filePath);
163
+ return (isIgnoredDirectory(dir) || isIgnoredByChain(resolve(dir), filePath));
164
+ },
165
+ isIgnoredDirectory,
166
+ };
167
+ }
125
168
  let alwaysIgnored;
126
169
  /**
127
170
  * Directories that should never be walked, whatever the workspace's own ignore
@@ -174,16 +217,55 @@ function createPrettierIgnoreChecker(tree) {
174
217
  merge: false,
175
218
  });
176
219
  }
220
+ /**
221
+ * What oxfmt ignores: prettier's two files, but resolved from each file's own
222
+ * directory upwards rather than the workspace root - measured against the
223
+ * oxfmt 0.60.0 CLI, which differs from prettier on exactly that axis. Still
224
+ * one matcher per file rather than merged.
225
+ *
226
+ * A config's `ignorePatterns` is not an ignore file and is not read here;
227
+ * `formatFilesWithOxfmt` applies it rooted at that config's directory.
228
+ */
229
+ function createOxfmtIgnoreChecker(tree) {
230
+ return createTreeIgnoreChecker(tree, exports.OXFMT_IGNORE_OPTIONS);
231
+ }
232
+ /**
233
+ * Exported, unlike git's and prettier's, because oxfmt has two consumers:
234
+ * this tree-backed checker and the disk-backed resolver in
235
+ * `formatters/oxfmt.ts`. A shared value is the only thing that keeps them
236
+ * agreeing, so do not restate these three anywhere.
237
+ *
238
+ * `satisfies` rather than an annotation keeps the values literal - an
239
+ * annotation widens `cascade` and `merge` to `boolean` (measured in the
240
+ * declaration emit).
241
+ */
242
+ exports.OXFMT_IGNORE_OPTIONS = {
243
+ filenames: ['.gitignore', '.prettierignore'],
244
+ cascade: true,
245
+ merge: false,
246
+ };
177
247
  function createTreeIgnoreChecker(tree, { filenames, cascade, merge }) {
178
248
  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);
249
+ if (cascade) {
250
+ // Cascading resolution and the excluded-ancestor rule travel together:
251
+ // both come from git, and the one cascading tool that is not git - oxfmt -
252
+ // applies both (measured, see `createAncestorAwareIgnoreChecker`).
253
+ const checker = createAncestorAwareIgnoreChecker(resolve);
254
+ return {
255
+ isIgnoredFile: (path) => isAlwaysIgnored(path) || checker.isIgnoredFile(path),
256
+ // The trailing slash is what makes a directory-only pattern like `dist/`
257
+ // match - `ignore` will not match it against the bare `dist`.
258
+ isIgnoredDirectory: (path) => isAlwaysIgnored(`${path}/`) || checker.isIgnoredDirectory(path),
259
+ };
260
+ }
261
+ // Root-only: the whole chain is the root's, so no ancestor holds ignore
262
+ // files of its own, and within one matcher `ignore` itself refuses to
263
+ // re-include under an excluded directory (measured). Nothing is left for an
264
+ // ancestor walk to add.
265
+ const check = (probe) => isAlwaysIgnored(probe) || isIgnoredByChain(resolve(''), probe);
184
266
  return {
185
- isIgnoredFile: (path) => check(path, path),
186
- isIgnoredDirectory: (path) => check(path, `${path}/`),
267
+ isIgnoredFile: (path) => check(path),
268
+ isIgnoredDirectory: (path) => check(`${path}/`),
187
269
  };
188
270
  }
189
271
  /**
@@ -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
  }
@@ -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) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureNxConsoleInstalled = ensureNxConsoleInstalled;
4
- const enquirer_1 = require("enquirer");
4
+ const prompt_helpers_1 = require("./prompt-helpers");
5
5
  const os_1 = require("os");
6
6
  const output_1 = require("./output");
7
7
  const native_1 = require("../native");
@@ -50,13 +50,10 @@ async function promptForNxConsoleInstallation() {
50
50
  '- Explore your workspace visually',
51
51
  ],
52
52
  });
53
- const { shouldInstallNxConsole } = await (0, enquirer_1.prompt)({
54
- type: 'confirm',
55
- name: 'shouldInstallNxConsole',
53
+ return await (0, prompt_helpers_1.confirmationPrompt)({
56
54
  message: 'Install Nx Console? (you can uninstall anytime)',
57
- initial: true,
55
+ onCancel: () => false,
58
56
  });
59
- return shouldInstallNxConsole;
60
57
  }
61
58
  catch (error) {
62
59
  return false;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The directory holding bun's global config files (.bunfig.toml and, for bun's
3
+ * npmrc support, .npmrc): $XDG_CONFIG_HOME when set, else the home dir (bun's
4
+ * getHomeConfigPath). Null when neither is set, where bun reads no global
5
+ * config.
6
+ */
7
+ export declare function getBunGlobalConfigBase(env: NodeJS.ProcessEnv): string | null;
8
+ /**
9
+ * Parses a bunfig.toml: null when absent, 'unreadable' when it cannot be read
10
+ * (bun skips it and resolves on, so most callers collapse the two), 'invalid'
11
+ * when bun's own TOML parser would reject it (bun hard-errors there, so no
12
+ * resolution is left for a caller to reproduce).
13
+ */
14
+ export declare function readBunfigRaw(path: string): Record<string, unknown> | 'unreadable' | 'invalid' | null;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBunGlobalConfigBase = getBunGlobalConfigBase;
4
+ exports.readBunfigRaw = readBunfigRaw;
5
+ const fs_1 = require("fs");
6
+ /**
7
+ * The directory holding bun's global config files (.bunfig.toml and, for bun's
8
+ * npmrc support, .npmrc): $XDG_CONFIG_HOME when set, else the home dir (bun's
9
+ * getHomeConfigPath). Null when neither is set, where bun reads no global
10
+ * config.
11
+ */
12
+ function getBunGlobalConfigBase(env) {
13
+ // bun's getenvZ treats a set-but-empty var as present, so an exported empty
14
+ // XDG_CONFIG_HOME still short-circuits HOME (bun: `XDG_CONFIG_HOME orelse HOME`).
15
+ if (env.XDG_CONFIG_HOME !== undefined) {
16
+ return env.XDG_CONFIG_HOME;
17
+ }
18
+ // Mirrors bun's platform-specific HOME accessor (env_var.zig).
19
+ const home = process.platform === 'win32' ? env.USERPROFILE : env.HOME;
20
+ return home ?? null;
21
+ }
22
+ /**
23
+ * Parses a bunfig.toml: null when absent, 'unreadable' when it cannot be read
24
+ * (bun skips it and resolves on, so most callers collapse the two), 'invalid'
25
+ * when bun's own TOML parser would reject it (bun hard-errors there, so no
26
+ * resolution is left for a caller to reproduce).
27
+ */
28
+ function readBunfigRaw(path) {
29
+ // Outside the try because a parser that will not load is a broken
30
+ // installation, not a corrupt bunfig.
31
+ const { parse } = require('smol-toml');
32
+ let raw;
33
+ try {
34
+ raw = (0, fs_1.readFileSync)(path, 'utf-8');
35
+ }
36
+ catch (error) {
37
+ // ENOTDIR (a path through a non-directory) is another shape of absent, the
38
+ // same way the .npmrc reader classifies it.
39
+ return error?.code === 'ENOENT' || error?.code === 'ENOTDIR'
40
+ ? null
41
+ : 'unreadable';
42
+ }
43
+ try {
44
+ return parse(raw);
45
+ }
46
+ catch {
47
+ return 'invalid';
48
+ }
49
+ }
@@ -0,0 +1,23 @@
1
+ export interface NpmrcEntry {
2
+ key: string;
3
+ value: string;
4
+ /** True when the source used ini's `key[]` array-append syntax. */
5
+ array?: boolean;
6
+ }
7
+ /**
8
+ * Parses an .npmrc file into its `key = value` entries the way npm/yarn/pnpm do
9
+ * (via the `ini` package). Returns null when the file is missing, and
10
+ * 'unreadable' when it exists but cannot be read (permissions, a directory):
11
+ * package managers diverge on that state, so each caller decides whether to
12
+ * skip, warn, or abort rather than having it collapsed into "absent" here.
13
+ */
14
+ export declare function readNpmrcEntries(path: string): NpmrcEntry[] | 'unreadable' | null;
15
+ export declare function parseNpmrcContent(raw: string): NpmrcEntry[];
16
+ /**
17
+ * Reads an .npmrc-format file into a map with ini's semantics for repeated
18
+ * keys: scalars last-write-wins, `key[]` values joined. Null and 'unreadable'
19
+ * pass through from {@link readNpmrcEntries}.
20
+ */
21
+ export declare function readNpmrcMap(path: string): Map<string, string> | 'unreadable' | null;
22
+ /** Those entries under ini's semantics for repeated keys. */
23
+ export declare function npmrcEntriesToMap(entries: NpmrcEntry[]): Map<string, string>;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readNpmrcEntries = readNpmrcEntries;
4
+ exports.parseNpmrcContent = parseNpmrcContent;
5
+ exports.readNpmrcMap = readNpmrcMap;
6
+ exports.npmrcEntriesToMap = npmrcEntriesToMap;
7
+ const fs_1 = require("fs");
8
+ /**
9
+ * Parses an .npmrc file into its `key = value` entries the way npm/yarn/pnpm do
10
+ * (via the `ini` package). Returns null when the file is missing, and
11
+ * 'unreadable' when it exists but cannot be read (permissions, a directory):
12
+ * package managers diverge on that state, so each caller decides whether to
13
+ * skip, warn, or abort rather than having it collapsed into "absent" here.
14
+ */
15
+ function readNpmrcEntries(path) {
16
+ let raw;
17
+ try {
18
+ raw = (0, fs_1.readFileSync)(path, 'utf-8');
19
+ }
20
+ catch (e) {
21
+ // ENOTDIR (a path through a non-directory) is another shape of absent, not an
22
+ // unreadable file.
23
+ return e?.code === 'ENOENT' || e?.code === 'ENOTDIR' ? null : 'unreadable';
24
+ }
25
+ return parseNpmrcContent(raw);
26
+ }
27
+ function parseNpmrcContent(raw) {
28
+ const entries = [];
29
+ // ini breaks lines on any run of CR/LF, so splitting on `\r?\n` here would
30
+ // hide everything after a bare CR that npm still reads.
31
+ for (const line of raw.split(/[\r\n]+/)) {
32
+ const trimmed = line.trim();
33
+ if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith(';')) {
34
+ continue;
35
+ }
36
+ // ini matches the header on the raw line, so an indented one stays a literal
37
+ // bare-flag key. Everything after a header nests under it, out of npm's flat
38
+ // lookup, so stop here.
39
+ if (/^\[[^\]]*\]\s*$/.test(line)) {
40
+ break;
41
+ }
42
+ // ini reads a valueless line as the flag `true`; dropping it would lose a bare
43
+ // `always-auth`/`strict-ssl` and flip the credential/TLS decision built on it.
44
+ const eq = trimmed.indexOf('=');
45
+ const rawKey = iniUnsafe(eq === -1 ? trimmed : trimmed.slice(0, eq));
46
+ const value = eq === -1 ? 'true' : iniUnsafe(trimmed.slice(eq + 1));
47
+ // ini enables bracketedArray by default, so a `key[]` suffix appends under the
48
+ // bare key instead of making a literal `key[]` entry.
49
+ if (rawKey.length > 2 && rawKey.endsWith('[]')) {
50
+ entries.push({ key: rawKey.slice(0, -2), value, array: true });
51
+ }
52
+ else {
53
+ entries.push({ key: rawKey, value });
54
+ }
55
+ }
56
+ return entries;
57
+ }
58
+ /**
59
+ * Reads an .npmrc-format file into a map with ini's semantics for repeated
60
+ * keys: scalars last-write-wins, `key[]` values joined. Null and 'unreadable'
61
+ * pass through from {@link readNpmrcEntries}.
62
+ */
63
+ function readNpmrcMap(path) {
64
+ const entries = readNpmrcEntries(path);
65
+ return Array.isArray(entries) ? npmrcEntriesToMap(entries) : entries;
66
+ }
67
+ /** Those entries under ini's semantics for repeated keys. */
68
+ function npmrcEntriesToMap(entries) {
69
+ const map = new Map();
70
+ for (const { key, value, array } of entries) {
71
+ // ini collects repeated `key[]` values into an array under the bare key, and
72
+ // npm rebuilds a config array from the env by splitting on a blank line, so
73
+ // join them that way.
74
+ const existing = map.get(key);
75
+ map.set(key, array && existing !== undefined ? `${existing}\n\n${value}` : value);
76
+ }
77
+ return map;
78
+ }
79
+ function isQuoted(val) {
80
+ return (val.length >= 2 &&
81
+ ((val.startsWith('"') && val.endsWith('"')) ||
82
+ (val.startsWith("'") && val.endsWith("'"))));
83
+ }
84
+ /**
85
+ * Mirrors the `ini` package's `unsafe()`, except that ini JSON-decodes a
86
+ * single-quoted value's contents and we keep them verbatim; that only differs
87
+ * when the contents are valid JSON, never true for a registry, token, or path.
88
+ * See https://github.com/isaacs/ini/blob/a0c72fe9e335a3f949d734fb5ef13371a850bbe3/lib/ini.js#L230
89
+ */
90
+ function iniUnsafe(raw) {
91
+ const val = raw.trim();
92
+ if (isQuoted(val)) {
93
+ if (val.startsWith("'")) {
94
+ return val.slice(1, -1);
95
+ }
96
+ try {
97
+ return JSON.parse(val);
98
+ }
99
+ catch {
100
+ return val;
101
+ }
102
+ }
103
+ let esc = false;
104
+ let unesc = '';
105
+ for (const c of val) {
106
+ if (esc) {
107
+ unesc += '\\;#'.includes(c) ? c : `\\${c}`;
108
+ esc = false;
109
+ }
110
+ else if (c === ';' || c === '#') {
111
+ break;
112
+ }
113
+ else if (c === '\\') {
114
+ esc = true;
115
+ }
116
+ else {
117
+ unesc += c;
118
+ }
119
+ }
120
+ if (esc) {
121
+ unesc += '\\';
122
+ }
123
+ return unesc.trim();
124
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Mirrors pnpm's getConfigDir. Hosts pnpm's global config.yaml and (v11+)
3
+ * auth.ini.
4
+ * See https://github.com/pnpm/pnpm/blob/b7195db5c8469c80908d625c648302b26c2f9977/config/reader/src/dirs.ts#L73-L92
5
+ */
6
+ export declare function getPnpmConfigDir(env: NodeJS.ProcessEnv): string;
7
+ /**
8
+ * Reads a pnpm YAML config file (pnpm-workspace.yaml or the global
9
+ * config.yaml). An absent file returns null so callers can fall through to
10
+ * lower surfaces; everything else returns 'unusable', which every caller turns
11
+ * into a throw. pnpm's own reader tolerates ENOENT alone and rethrows the rest,
12
+ * and it dies the same way on a document it cannot parse or that is not a
13
+ * mapping, so the two failures need no separate states. Requiring an object
14
+ * also keeps the sentinel out of the success domain: a returned string can only
15
+ * ever mean unusable.
16
+ */
17
+ export declare function readPnpmYamlConfig(path: string): Record<string, unknown> | 'unusable' | null;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPnpmConfigDir = getPnpmConfigDir;
4
+ exports.readPnpmYamlConfig = readPnpmYamlConfig;
5
+ const os_1 = require("os");
6
+ const path_1 = require("path");
7
+ const fileutils_1 = require("../fileutils");
8
+ /**
9
+ * Mirrors pnpm's getConfigDir. Hosts pnpm's global config.yaml and (v11+)
10
+ * auth.ini.
11
+ * See https://github.com/pnpm/pnpm/blob/b7195db5c8469c80908d625c648302b26c2f9977/config/reader/src/dirs.ts#L73-L92
12
+ */
13
+ function getPnpmConfigDir(env) {
14
+ if (env.XDG_CONFIG_HOME) {
15
+ return (0, path_1.join)(env.XDG_CONFIG_HOME, 'pnpm');
16
+ }
17
+ if (process.platform === 'darwin') {
18
+ return (0, path_1.join)((0, os_1.homedir)(), 'Library/Preferences/pnpm');
19
+ }
20
+ if (process.platform !== 'win32') {
21
+ return (0, path_1.join)((0, os_1.homedir)(), '.config/pnpm');
22
+ }
23
+ if (env.LOCALAPPDATA) {
24
+ return (0, path_1.join)(env.LOCALAPPDATA, 'pnpm/config');
25
+ }
26
+ return (0, path_1.join)((0, os_1.homedir)(), '.config/pnpm');
27
+ }
28
+ /**
29
+ * Reads a pnpm YAML config file (pnpm-workspace.yaml or the global
30
+ * config.yaml). An absent file returns null so callers can fall through to
31
+ * lower surfaces; everything else returns 'unusable', which every caller turns
32
+ * into a throw. pnpm's own reader tolerates ENOENT alone and rethrows the rest,
33
+ * and it dies the same way on a document it cannot parse or that is not a
34
+ * mapping, so the two failures need no separate states. Requiring an object
35
+ * also keeps the sentinel out of the success domain: a returned string can only
36
+ * ever mean unusable.
37
+ */
38
+ function readPnpmYamlConfig(path) {
39
+ let doc;
40
+ try {
41
+ doc = (0, fileutils_1.readYamlFile)(path);
42
+ }
43
+ catch (e) {
44
+ // Only ENOENT resolves on, so a path through a non-directory or a file that
45
+ // will not open is fatal here. Callers whose pnpm counterpart looks the file
46
+ // up before reading it widen "absent" themselves.
47
+ if (e?.code === 'ENOENT') {
48
+ return null;
49
+ }
50
+ return 'unusable';
51
+ }
52
+ // An empty file declares nothing; pnpm accepts it.
53
+ if (doc === null || doc === undefined) {
54
+ return {};
55
+ }
56
+ if (typeof doc !== 'object' || Array.isArray(doc)) {
57
+ return 'unusable';
58
+ }
59
+ return doc;
60
+ }
@@ -118,14 +118,33 @@ export declare function resolvePackageVersionUsingRegistry(packageName: string,
118
118
  * package.json.
119
119
  */
120
120
  export declare function resolvePackageVersionUsingInstallation(packageName: string, version: string): Promise<string>;
121
- export declare function packageRegistryView(pkg: string, version: string, args: string, options?: {
121
+ /**
122
+ * The registry the fetch for `pkg` went to, with its userinfo masked because a
123
+ * registry URL can carry a bare token. The lookup is spawned the way
124
+ * `packageRegistryView` spawns the fetch this describes (same manager, same
125
+ * environment), so a registry the package manager keeps outside the .npmrc
126
+ * chain and a scope resolved for itself both land on the value that fetch used.
127
+ * Null where the manager yields no usable registry URL; throws where it cannot be run.
128
+ */
129
+ export declare function getWorkspaceRegistryUrlForDisplay(pkg: string): string | null;
130
+ export declare function packageRegistryView(pkg: string, version: string, args: string[], options?: {
122
131
  forceNpm?: boolean;
123
132
  }): Promise<string>;
124
- export declare function packageRegistryPack(cwd: string, pkg: string, version: string, options?: {
133
+ /**
134
+ * Only `npm pack` supports downloading a tarball of a specified remote
135
+ * package. `yarn` packs the active workspace, `pnpm pack` only packs
136
+ * the local project, and `bun` doesn't support pack.
137
+ *
138
+ * @param packDestination Directory passed to npm's `--pack-destination`, where
139
+ * the `.tgz` is written.
140
+ * @see https://github.com/nrwl/nx/pull/9667#discussion_r842553994
141
+ */
142
+ export declare function packageRegistryPack(packDestination: string, pkg: string, version: string, options?: {
125
143
  bypassMinReleaseAge?: boolean;
126
144
  }): Promise<{
127
145
  tarballPath: string;
128
146
  }>;
147
+ export declare function clearPackageManagerVersionCache(): void;
129
148
  /**
130
149
  * Gets the workspaces defined in the package manager configuration.
131
150
  * @returns workspaces defined in the package manager configuration, empty array if none are defined