@convesoft/nx-rust 0.0.0 → 1.0.0-rc.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 (418) hide show
  1. package/LICENSE-APACHE +201 -0
  2. package/LICENSE-MIT +21 -0
  3. package/PLUGIN.md +106 -0
  4. package/README.md +51 -1
  5. package/docs/artifacts.mara.md +374 -0
  6. package/docs/caching.mara.md +999 -0
  7. package/docs/ci.mara.md +308 -0
  8. package/docs/configuration.mara.md +508 -0
  9. package/docs/decisions.mara.md +3267 -0
  10. package/docs/execution.mara.md +533 -0
  11. package/docs/index.mara.md +51 -0
  12. package/docs/product.mara.md +366 -0
  13. package/docs/release.mara.md +493 -0
  14. package/docs/setup.mara.md +486 -0
  15. package/docs/targets.mara.md +704 -0
  16. package/docs/testing.mara.md +431 -0
  17. package/docs/verification.mara.md +465 -0
  18. package/docs/workspaces.mara.md +445 -0
  19. package/executors.json +35 -0
  20. package/generators.json +19 -0
  21. package/package.json +17 -4
  22. package/src/cargo/build-settings.d.ts +61 -0
  23. package/src/cargo/build-settings.js +103 -0
  24. package/src/cargo/build-settings.js.map +1 -0
  25. package/src/cargo/configured-runner.d.ts +36 -0
  26. package/src/cargo/configured-runner.js +99 -0
  27. package/src/cargo/configured-runner.js.map +1 -0
  28. package/src/cargo/configured-tools.d.ts +35 -0
  29. package/src/cargo/configured-tools.js +46 -0
  30. package/src/cargo/configured-tools.js.map +1 -0
  31. package/src/cargo/dep-info-basedir.d.ts +18 -0
  32. package/src/cargo/dep-info-basedir.js +38 -0
  33. package/src/cargo/dep-info-basedir.js.map +1 -0
  34. package/src/cargo/directories.d.ts +40 -0
  35. package/src/cargo/directories.js +89 -0
  36. package/src/cargo/directories.js.map +1 -0
  37. package/src/cargo/host-triple.d.ts +7 -0
  38. package/src/cargo/host-triple.js +21 -0
  39. package/src/cargo/host-triple.js.map +1 -0
  40. package/src/cargo/lockfile.d.ts +63 -0
  41. package/src/cargo/lockfile.js +157 -0
  42. package/src/cargo/lockfile.js.map +1 -0
  43. package/src/cargo/metadata.d.ts +114 -0
  44. package/src/cargo/metadata.js +37 -0
  45. package/src/cargo/metadata.js.map +1 -0
  46. package/src/cargo/package-specs.d.ts +54 -0
  47. package/src/cargo/package-specs.js +109 -0
  48. package/src/cargo/package-specs.js.map +1 -0
  49. package/src/cargo/paths-crates.d.ts +27 -0
  50. package/src/cargo/paths-crates.js +69 -0
  51. package/src/cargo/paths-crates.js.map +1 -0
  52. package/src/cargo/print-artifact-folders.d.ts +1 -0
  53. package/src/cargo/print-artifact-folders.js +58 -0
  54. package/src/cargo/print-artifact-folders.js.map +1 -0
  55. package/src/cargo/redirections.d.ts +90 -0
  56. package/src/cargo/redirections.js +200 -0
  57. package/src/cargo/redirections.js.map +1 -0
  58. package/src/cargo/run-cargo.d.ts +31 -0
  59. package/src/cargo/run-cargo.js +75 -0
  60. package/src/cargo/run-cargo.js.map +1 -0
  61. package/src/cargo/target-triples.d.ts +98 -0
  62. package/src/cargo/target-triples.js +265 -0
  63. package/src/cargo/target-triples.js.map +1 -0
  64. package/src/cargo/version-req.d.ts +12 -0
  65. package/src/cargo/version-req.js +122 -0
  66. package/src/cargo/version-req.js.map +1 -0
  67. package/src/cargo/warnings-setting.d.ts +24 -0
  68. package/src/cargo/warnings-setting.js +81 -0
  69. package/src/cargo/warnings-setting.js.map +1 -0
  70. package/src/compatibility/cargo-version.d.ts +43 -0
  71. package/src/compatibility/cargo-version.js +83 -0
  72. package/src/compatibility/cargo-version.js.map +1 -0
  73. package/src/compatibility/nx-bridge.d.ts +312 -0
  74. package/src/compatibility/nx-bridge.js +407 -0
  75. package/src/compatibility/nx-bridge.js.map +1 -0
  76. package/src/compatibility/nx-version.d.ts +104 -0
  77. package/src/compatibility/nx-version.js +272 -0
  78. package/src/compatibility/nx-version.js.map +1 -0
  79. package/src/executors/affected-inputs.d.ts +29 -0
  80. package/src/executors/affected-inputs.js +259 -0
  81. package/src/executors/affected-inputs.js.map +1 -0
  82. package/src/executors/affected-run.d.ts +54 -0
  83. package/src/executors/affected-run.js +394 -0
  84. package/src/executors/affected-run.js.map +1 -0
  85. package/src/executors/affected.d.ts +239 -0
  86. package/src/executors/affected.js +589 -0
  87. package/src/executors/affected.js.map +1 -0
  88. package/src/executors/baseline-context.d.ts +85 -0
  89. package/src/executors/baseline-context.js +227 -0
  90. package/src/executors/baseline-context.js.map +1 -0
  91. package/src/executors/baseline.d.ts +123 -0
  92. package/src/executors/baseline.js +356 -0
  93. package/src/executors/baseline.js.map +1 -0
  94. package/src/executors/batch.d.ts +75 -0
  95. package/src/executors/batch.js +434 -0
  96. package/src/executors/batch.js.map +1 -0
  97. package/src/executors/build-records.d.ts +110 -0
  98. package/src/executors/build-records.js +267 -0
  99. package/src/executors/build-records.js.map +1 -0
  100. package/src/executors/cargo/executor.d.ts +28 -0
  101. package/src/executors/cargo/executor.js +58 -0
  102. package/src/executors/cargo/executor.js.map +1 -0
  103. package/src/executors/cargo/schema.json +58 -0
  104. package/src/executors/cargo-invocation.d.ts +81 -0
  105. package/src/executors/cargo-invocation.js +109 -0
  106. package/src/executors/cargo-invocation.js.map +1 -0
  107. package/src/executors/cargo-output.d.ts +218 -0
  108. package/src/executors/cargo-output.js +660 -0
  109. package/src/executors/cargo-output.js.map +1 -0
  110. package/src/executors/command.d.ts +331 -0
  111. package/src/executors/command.js +547 -0
  112. package/src/executors/command.js.map +1 -0
  113. package/src/executors/coverage-baseline.d.ts +23 -0
  114. package/src/executors/coverage-baseline.js +284 -0
  115. package/src/executors/coverage-baseline.js.map +1 -0
  116. package/src/executors/declared-options.d.ts +21 -0
  117. package/src/executors/declared-options.js +58 -0
  118. package/src/executors/declared-options.js.map +1 -0
  119. package/src/executors/denied-warnings.d.ts +99 -0
  120. package/src/executors/denied-warnings.js +188 -0
  121. package/src/executors/denied-warnings.js.map +1 -0
  122. package/src/executors/digests.d.ts +94 -0
  123. package/src/executors/digests.js +190 -0
  124. package/src/executors/digests.js.map +1 -0
  125. package/src/executors/dotenv-check.d.ts +79 -0
  126. package/src/executors/dotenv-check.js +553 -0
  127. package/src/executors/dotenv-check.js.map +1 -0
  128. package/src/executors/group-invocations.d.ts +80 -0
  129. package/src/executors/group-invocations.js +253 -0
  130. package/src/executors/group-invocations.js.map +1 -0
  131. package/src/executors/group-run.d.ts +114 -0
  132. package/src/executors/group-run.js +601 -0
  133. package/src/executors/group-run.js.map +1 -0
  134. package/src/executors/groups.d.ts +118 -0
  135. package/src/executors/groups.js +304 -0
  136. package/src/executors/groups.js.map +1 -0
  137. package/src/executors/input-check.d.ts +52 -0
  138. package/src/executors/input-check.js +271 -0
  139. package/src/executors/input-check.js.map +1 -0
  140. package/src/executors/kept-files.d.ts +98 -0
  141. package/src/executors/kept-files.js +341 -0
  142. package/src/executors/kept-files.js.map +1 -0
  143. package/src/executors/lockfile/executor.d.ts +16 -0
  144. package/src/executors/lockfile/executor.js +37 -0
  145. package/src/executors/lockfile/executor.js.map +1 -0
  146. package/src/executors/lockfile/schema.json +50 -0
  147. package/src/executors/napi-build.d.ts +73 -0
  148. package/src/executors/napi-build.js +420 -0
  149. package/src/executors/napi-build.js.map +1 -0
  150. package/src/executors/nextest.d.ts +189 -0
  151. package/src/executors/nextest.js +504 -0
  152. package/src/executors/nextest.js.map +1 -0
  153. package/src/executors/nx-command.d.ts +95 -0
  154. package/src/executors/nx-command.js +205 -0
  155. package/src/executors/nx-command.js.map +1 -0
  156. package/src/executors/nx-task-files.d.ts +82 -0
  157. package/src/executors/nx-task-files.js +156 -0
  158. package/src/executors/nx-task-files.js.map +1 -0
  159. package/src/executors/print-test-mode.d.ts +1 -0
  160. package/src/executors/print-test-mode.js +25 -0
  161. package/src/executors/print-test-mode.js.map +1 -0
  162. package/src/executors/release-publish/executor.d.ts +24 -0
  163. package/src/executors/release-publish/executor.js +165 -0
  164. package/src/executors/release-publish/executor.js.map +1 -0
  165. package/src/executors/release-publish/schema.json +30 -0
  166. package/src/executors/run/executor.d.ts +12 -0
  167. package/src/executors/run/executor.js +27 -0
  168. package/src/executors/run/executor.js.map +1 -0
  169. package/src/executors/run/schema.json +45 -0
  170. package/src/executors/runner-script.d.ts +12 -0
  171. package/src/executors/runner-script.js +22 -0
  172. package/src/executors/runner-script.js.map +1 -0
  173. package/src/executors/runtime-input-check.d.ts +24 -0
  174. package/src/executors/runtime-input-check.js +87 -0
  175. package/src/executors/runtime-input-check.js.map +1 -0
  176. package/src/executors/shared-artifacts.d.ts +44 -0
  177. package/src/executors/shared-artifacts.js +132 -0
  178. package/src/executors/shared-artifacts.js.map +1 -0
  179. package/src/executors/split-words.d.ts +24 -0
  180. package/src/executors/split-words.js +111 -0
  181. package/src/executors/split-words.js.map +1 -0
  182. package/src/executors/stage.d.ts +163 -0
  183. package/src/executors/stage.js +526 -0
  184. package/src/executors/stage.js.map +1 -0
  185. package/src/executors/staged-run.d.ts +24 -0
  186. package/src/executors/staged-run.js +110 -0
  187. package/src/executors/staged-run.js.map +1 -0
  188. package/src/executors/task-env.d.ts +271 -0
  189. package/src/executors/task-env.js +494 -0
  190. package/src/executors/task-env.js.map +1 -0
  191. package/src/executors/task-execution.d.ts +61 -0
  192. package/src/executors/task-execution.js +122 -0
  193. package/src/executors/task-execution.js.map +1 -0
  194. package/src/executors/task-guards.d.ts +112 -0
  195. package/src/executors/task-guards.js +435 -0
  196. package/src/executors/task-guards.js.map +1 -0
  197. package/src/executors/task-options.d.ts +114 -0
  198. package/src/executors/task-options.js +258 -0
  199. package/src/executors/task-options.js.map +1 -0
  200. package/src/executors/task.d.ts +166 -0
  201. package/src/executors/task.js +527 -0
  202. package/src/executors/task.js.map +1 -0
  203. package/src/executors/test-mode.d.ts +185 -0
  204. package/src/executors/test-mode.js +397 -0
  205. package/src/executors/test-mode.js.map +1 -0
  206. package/src/executors/test-runner.d.ts +44 -0
  207. package/src/executors/test-runner.js +159 -0
  208. package/src/executors/test-runner.js.map +1 -0
  209. package/src/executors/test-steps.d.ts +121 -0
  210. package/src/executors/test-steps.js +566 -0
  211. package/src/executors/test-steps.js.map +1 -0
  212. package/src/executors/wasm-build.d.ts +56 -0
  213. package/src/executors/wasm-build.js +216 -0
  214. package/src/executors/wasm-build.js.map +1 -0
  215. package/src/generators/crate/binary.schema.json +28 -0
  216. package/src/generators/crate/crate.d.ts +24 -0
  217. package/src/generators/crate/crate.js +108 -0
  218. package/src/generators/crate/crate.js.map +1 -0
  219. package/src/generators/crate/enclosing-workspace.d.ts +25 -0
  220. package/src/generators/crate/enclosing-workspace.js +58 -0
  221. package/src/generators/crate/enclosing-workspace.js.map +1 -0
  222. package/src/generators/crate/library.schema.json +28 -0
  223. package/src/generators/init/graph-check.d.ts +81 -0
  224. package/src/generators/init/graph-check.js +299 -0
  225. package/src/generators/init/graph-check.js.map +1 -0
  226. package/src/generators/init/init.d.ts +23 -0
  227. package/src/generators/init/init.js +113 -0
  228. package/src/generators/init/init.js.map +1 -0
  229. package/src/generators/init/report.d.ts +19 -0
  230. package/src/generators/init/report.js +93 -0
  231. package/src/generators/init/report.js.map +1 -0
  232. package/src/generators/init/schema.json +9 -0
  233. package/src/graph/artifact-kinds.d.ts +29 -0
  234. package/src/graph/artifact-kinds.js +50 -0
  235. package/src/graph/artifact-kinds.js.map +1 -0
  236. package/src/graph/artifact-names.d.ts +97 -0
  237. package/src/graph/artifact-names.js +276 -0
  238. package/src/graph/artifact-names.js.map +1 -0
  239. package/src/graph/build-records.d.ts +74 -0
  240. package/src/graph/build-records.js +104 -0
  241. package/src/graph/build-records.js.map +1 -0
  242. package/src/graph/caching.d.ts +148 -0
  243. package/src/graph/caching.js +681 -0
  244. package/src/graph/caching.js.map +1 -0
  245. package/src/graph/clippy-input.d.ts +53 -0
  246. package/src/graph/clippy-input.js +107 -0
  247. package/src/graph/clippy-input.js.map +1 -0
  248. package/src/graph/collisions.d.ts +113 -0
  249. package/src/graph/collisions.js +156 -0
  250. package/src/graph/collisions.js.map +1 -0
  251. package/src/graph/computation-reports.d.ts +89 -0
  252. package/src/graph/computation-reports.js +216 -0
  253. package/src/graph/computation-reports.js.map +1 -0
  254. package/src/graph/declared-files.d.ts +190 -0
  255. package/src/graph/declared-files.js +600 -0
  256. package/src/graph/declared-files.js.map +1 -0
  257. package/src/graph/discovery.d.ts +190 -0
  258. package/src/graph/discovery.js +661 -0
  259. package/src/graph/discovery.js.map +1 -0
  260. package/src/graph/edges.d.ts +25 -0
  261. package/src/graph/edges.js +94 -0
  262. package/src/graph/edges.js.map +1 -0
  263. package/src/graph/entries.d.ts +83 -0
  264. package/src/graph/entries.js +259 -0
  265. package/src/graph/entries.js.map +1 -0
  266. package/src/graph/inputs.d.ts +422 -0
  267. package/src/graph/inputs.js +756 -0
  268. package/src/graph/inputs.js.map +1 -0
  269. package/src/graph/lockfile-task.d.ts +74 -0
  270. package/src/graph/lockfile-task.js +105 -0
  271. package/src/graph/lockfile-task.js.map +1 -0
  272. package/src/graph/names.d.ts +41 -0
  273. package/src/graph/names.js +34 -0
  274. package/src/graph/names.js.map +1 -0
  275. package/src/graph/napi.d.ts +107 -0
  276. package/src/graph/napi.js +206 -0
  277. package/src/graph/napi.js.map +1 -0
  278. package/src/graph/nx-glob.d.ts +36 -0
  279. package/src/graph/nx-glob.js +152 -0
  280. package/src/graph/nx-glob.js.map +1 -0
  281. package/src/graph/nx-internals.d.ts +57 -0
  282. package/src/graph/nx-internals.js +128 -0
  283. package/src/graph/nx-internals.js.map +1 -0
  284. package/src/graph/options.d.ts +32 -0
  285. package/src/graph/options.js +80 -0
  286. package/src/graph/options.js.map +1 -0
  287. package/src/graph/outputs.d.ts +75 -0
  288. package/src/graph/outputs.js +140 -0
  289. package/src/graph/outputs.js.map +1 -0
  290. package/src/graph/path-dependencies.d.ts +122 -0
  291. package/src/graph/path-dependencies.js +459 -0
  292. package/src/graph/path-dependencies.js.map +1 -0
  293. package/src/graph/plugin-package.d.ts +36 -0
  294. package/src/graph/plugin-package.js +132 -0
  295. package/src/graph/plugin-package.js.map +1 -0
  296. package/src/graph/plugin-version.d.ts +20 -0
  297. package/src/graph/plugin-version.js +153 -0
  298. package/src/graph/plugin-version.js.map +1 -0
  299. package/src/graph/projects.d.ts +141 -0
  300. package/src/graph/projects.js +193 -0
  301. package/src/graph/projects.js.map +1 -0
  302. package/src/graph/reached-projects.d.ts +46 -0
  303. package/src/graph/reached-projects.js +102 -0
  304. package/src/graph/reached-projects.js.map +1 -0
  305. package/src/graph/real-path.d.ts +47 -0
  306. package/src/graph/real-path.js +113 -0
  307. package/src/graph/real-path.js.map +1 -0
  308. package/src/graph/redirected-uses.d.ts +98 -0
  309. package/src/graph/redirected-uses.js +434 -0
  310. package/src/graph/redirected-uses.js.map +1 -0
  311. package/src/graph/registration.d.ts +121 -0
  312. package/src/graph/registration.js +233 -0
  313. package/src/graph/registration.js.map +1 -0
  314. package/src/graph/rustfmt-config.d.ts +42 -0
  315. package/src/graph/rustfmt-config.js +173 -0
  316. package/src/graph/rustfmt-config.js.map +1 -0
  317. package/src/graph/script-input.d.ts +46 -0
  318. package/src/graph/script-input.js +65 -0
  319. package/src/graph/script-input.js.map +1 -0
  320. package/src/graph/settings.d.ts +178 -0
  321. package/src/graph/settings.js +479 -0
  322. package/src/graph/settings.js.map +1 -0
  323. package/src/graph/target-defaults-causes.d.ts +33 -0
  324. package/src/graph/target-defaults-causes.js +202 -0
  325. package/src/graph/target-defaults-causes.js.map +1 -0
  326. package/src/graph/target-defaults-layers.d.ts +186 -0
  327. package/src/graph/target-defaults-layers.js +420 -0
  328. package/src/graph/target-defaults-layers.js.map +1 -0
  329. package/src/graph/target-defaults-meaning.d.ts +95 -0
  330. package/src/graph/target-defaults-meaning.js +292 -0
  331. package/src/graph/target-defaults-meaning.js.map +1 -0
  332. package/src/graph/target-defaults-report.d.ts +77 -0
  333. package/src/graph/target-defaults-report.js +242 -0
  334. package/src/graph/target-defaults-report.js.map +1 -0
  335. package/src/graph/target-defaults.d.ts +79 -0
  336. package/src/graph/target-defaults.js +425 -0
  337. package/src/graph/target-defaults.js.map +1 -0
  338. package/src/graph/target-fields.d.ts +16 -0
  339. package/src/graph/target-fields.js +134 -0
  340. package/src/graph/target-fields.js.map +1 -0
  341. package/src/graph/target-tables.d.ts +45 -0
  342. package/src/graph/target-tables.js +299 -0
  343. package/src/graph/target-tables.js.map +1 -0
  344. package/src/graph/targets.d.ts +371 -0
  345. package/src/graph/targets.js +408 -0
  346. package/src/graph/targets.js.map +1 -0
  347. package/src/graph/unification.d.ts +141 -0
  348. package/src/graph/unification.js +459 -0
  349. package/src/graph/unification.js.map +1 -0
  350. package/src/graph/unignored-directories.d.ts +25 -0
  351. package/src/graph/unignored-directories.js +89 -0
  352. package/src/graph/unignored-directories.js.map +1 -0
  353. package/src/graph/visibility.d.ts +17 -0
  354. package/src/graph/visibility.js +67 -0
  355. package/src/graph/visibility.js.map +1 -0
  356. package/src/graph/warnings.d.ts +38 -0
  357. package/src/graph/warnings.js +77 -0
  358. package/src/graph/warnings.js.map +1 -0
  359. package/src/graph/wasm.d.ts +56 -0
  360. package/src/graph/wasm.js +77 -0
  361. package/src/graph/wasm.js.map +1 -0
  362. package/src/index.d.ts +68 -0
  363. package/src/index.js +109 -0
  364. package/src/index.js.map +1 -0
  365. package/src/release/manifests.d.ts +95 -0
  366. package/src/release/manifests.js +164 -0
  367. package/src/release/manifests.js.map +1 -0
  368. package/src/release/places.d.ts +127 -0
  369. package/src/release/places.js +368 -0
  370. package/src/release/places.js.map +1 -0
  371. package/src/release/publish-cargo.d.ts +177 -0
  372. package/src/release/publish-cargo.js +351 -0
  373. package/src/release/publish-cargo.js.map +1 -0
  374. package/src/release/publish-crates.d.ts +124 -0
  375. package/src/release/publish-crates.js +242 -0
  376. package/src/release/publish-crates.js.map +1 -0
  377. package/src/release/publish-environments.d.ts +50 -0
  378. package/src/release/publish-environments.js +284 -0
  379. package/src/release/publish-environments.js.map +1 -0
  380. package/src/release/publish-messages.d.ts +66 -0
  381. package/src/release/publish-messages.js +273 -0
  382. package/src/release/publish-messages.js.map +1 -0
  383. package/src/release/publish-registry.d.ts +27 -0
  384. package/src/release/publish-registry.js +135 -0
  385. package/src/release/publish-registry.js.map +1 -0
  386. package/src/release/publish-settings.d.ts +26 -0
  387. package/src/release/publish-settings.js +56 -0
  388. package/src/release/publish-settings.js.map +1 -0
  389. package/src/release/publish.d.ts +59 -0
  390. package/src/release/publish.js +620 -0
  391. package/src/release/publish.js.map +1 -0
  392. package/src/release/repository.d.ts +73 -0
  393. package/src/release/repository.js +219 -0
  394. package/src/release/repository.js.map +1 -0
  395. package/src/release/requirements.d.ts +34 -0
  396. package/src/release/requirements.js +30 -0
  397. package/src/release/requirements.js.map +1 -0
  398. package/src/release/toml-edit.d.ts +67 -0
  399. package/src/release/toml-edit.js +453 -0
  400. package/src/release/toml-edit.js.map +1 -0
  401. package/src/release/version-actions.d.ts +133 -0
  402. package/src/release/version-actions.js +474 -0
  403. package/src/release/version-actions.js.map +1 -0
  404. package/src/release/version-checks.d.ts +21 -0
  405. package/src/release/version-checks.js +151 -0
  406. package/src/release/version-checks.js.map +1 -0
  407. package/src/release/version-lockfiles.d.ts +61 -0
  408. package/src/release/version-lockfiles.js +222 -0
  409. package/src/release/version-lockfiles.js.map +1 -0
  410. package/src/tools/napi-cli.d.ts +70 -0
  411. package/src/tools/napi-cli.js +63 -0
  412. package/src/tools/napi-cli.js.map +1 -0
  413. package/src/tools/optional-tools.d.ts +121 -0
  414. package/src/tools/optional-tools.js +303 -0
  415. package/src/tools/optional-tools.js.map +1 -0
  416. package/src/tools/print-napi-cli.d.ts +1 -0
  417. package/src/tools/print-napi-cli.js +24 -0
  418. package/src/tools/print-napi-cli.js.map +1 -0
@@ -0,0 +1,661 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.discoverWorkspaces = discoverWorkspaces;
4
+ exports.discoverReportedWorkspaces = discoverReportedWorkspaces;
5
+ exports.describeWorkspaces = describeWorkspaces;
6
+ const tslib_1 = require("tslib");
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = require("node:path");
9
+ const configured_tools_1 = require("../cargo/configured-tools");
10
+ const paths_crates_1 = require("../cargo/paths-crates");
11
+ const redirections_1 = require("../cargo/redirections");
12
+ const target_triples_1 = require("../cargo/target-triples");
13
+ const run_cargo_1 = require("../cargo/run-cargo");
14
+ const cargo_version_1 = require("../compatibility/cargo-version");
15
+ const clippy_input_1 = require("./clippy-input");
16
+ const computation_reports_1 = require("./computation-reports");
17
+ const real_path_1 = require("./real-path");
18
+ const rustfmt_config_1 = require("./rustfmt-config");
19
+ const visibility_1 = require("./visibility");
20
+ /**
21
+ * Finds the Cargo workspaces among the manifests that Nx hands to the plugin
22
+ * and reads each one's `cargo metadata` report as cargo gives it in the
23
+ * workspace's root folder, where the workspace's tasks run cargo: where Nx
24
+ * does not hand the root manifest, that takes a second request
25
+ * ({@link readWorkspace}).
26
+ *
27
+ * Until every manifest is claimed, the shallowest unclaimed one is read, and
28
+ * the workspace its report describes claims its root manifest and its
29
+ * members. A crate outside every workspace, or excluded by the workspace
30
+ * around it, is still unclaimed after that workspace's step and becomes a
31
+ * workspace of one. Each workspace's redirections are read from its root
32
+ * manifest and the configuration files that apply to it.
33
+ *
34
+ * A manifest whose folder holds `.cargo-checksum.json` belongs to a package
35
+ * of a directory source, such as a crate that `cargo vendor` wrote, and is
36
+ * never read: such a crate gets a project only as a member of a workspace
37
+ * that another manifest's report describes, as when a path dependency makes
38
+ * cargo enrol it ({@link isDirectorySourcePackage}).
39
+ *
40
+ * Afterwards, every path dependency without a project, and every crate
41
+ * without a project that `[patch]`, `[replace]` or `paths` redirects to,
42
+ * whose crate no report covers yet gets a report of its own, so that the
43
+ * path dependencies behind it are known. A package of a directory source
44
+ * gets none. The crates of a `paths` entry are found below its folder as
45
+ * cargo finds them, once per folder, and only where a workspace has such an
46
+ * entry ({@link cratesBelowPathsFolder}), together with their path
47
+ * dependencies of every kind ({@link pathsCandidates}).
48
+ *
49
+ * @param manifests The `Cargo.toml` files, relative to `workspaceRoot`.
50
+ * @param workspaceRoot The absolute path of the repository root.
51
+ * @param reports Where the reports come from: the reports of the graph
52
+ * computation, which other plugin entries may share.
53
+ * @throws {Error} When cargo cannot be started or a report fails, naming the
54
+ * manifest, or when a manifest or configuration file is no valid TOML.
55
+ */
56
+ // @mara implements DES-DISCOVERY
57
+ function discoverWorkspaces(manifests_1, workspaceRoot_1) {
58
+ return tslib_1.__awaiter(this, arguments, void 0, function* (manifests, workspaceRoot, reports = new computation_reports_1.ComputationReports()) {
59
+ var _a, e_1, _b, _c;
60
+ const handed = new Set(manifests);
61
+ const workspaces = [];
62
+ const warnings = [];
63
+ try {
64
+ for (var _d = true, _e = tslib_1.__asyncValues(claimWorkspaces(manifests, workspaceRoot, reports)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
65
+ _c = _f.value;
66
+ _d = false;
67
+ const { report, rootManifest, memberPackages } = _c;
68
+ const found = yield (0, redirections_1.readRedirections)(report.workspace_root);
69
+ warnings.push(...found.warnings);
70
+ workspaces.push({
71
+ root: repositoryPath(workspaceRoot, report.workspace_root) || ".",
72
+ rootManifest,
73
+ rootManifestHanded: handed.has(rootManifest),
74
+ report,
75
+ members: memberPackages
76
+ .filter((pkg) => handed.has(repositoryPath(workspaceRoot, pkg.manifest_path)))
77
+ .sort((a, b) => compare(a.manifest_path, b.manifest_path)),
78
+ redirections: found.redirections,
79
+ triples: (0, target_triples_1.pickedTriples)(report.workspace_root, process.env),
80
+ configuredTriples: (0, target_triples_1.configuredTriples)(report.workspace_root, process.env),
81
+ configuredTools: (0, configured_tools_1.configuredTools)(report.workspace_root, process.env),
82
+ clippyFolders: (0, clippy_input_1.configuredClippyFolders)(report.workspace_root, process.env),
83
+ configIncludes: found.includedFiles,
84
+ configFiles: found.configFiles,
85
+ warnings: [...new Set(found.warnings)],
86
+ configurationWarnings: [],
87
+ formattingWarnings: new Map(),
88
+ });
89
+ }
90
+ }
91
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
92
+ finally {
93
+ try {
94
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
95
+ }
96
+ finally { if (e_1) throw e_1.error; }
97
+ }
98
+ const unreportedPathDependencies = new Map();
99
+ const pathsFolders = pathsFolderCrates(workspaces);
100
+ const { pathDependencyReports, candidates } = yield readPathDependencies(workspaces, workspaceRoot, reports, warnings, unreportedPathDependencies, pathsFolders);
101
+ for (const workspace of workspaces) {
102
+ const paths = workspace.redirections.filter((redirection) => redirection.table === "paths");
103
+ if (paths.length > 0) {
104
+ workspace.pathsCrates = new Map(paths.map(({ folder }) => { var _a; return [folder, (_a = candidates.get((0, real_path_1.realPath)(folder))) !== null && _a !== void 0 ? _a : []]; }));
105
+ }
106
+ }
107
+ warnings.push(...(yield unhashedConfigurationWarnings(workspaces, workspaceRoot)));
108
+ warnings.push(...(0, rustfmt_config_1.rustfmtConfigurationWarnings)(workspaces, workspaceRoot));
109
+ return {
110
+ workspaceRoot,
111
+ workspaces,
112
+ pathDependencyReports,
113
+ warnings: [...new Set(warnings)],
114
+ unreportedPathDependencies,
115
+ };
116
+ });
117
+ }
118
+ /**
119
+ * The workspaces that the manifests make up, each as its root folder and
120
+ * report, found as {@link discoverWorkspaces} finds them: the shallowest
121
+ * unclaimed manifest is read until every manifest is claimed. Nothing else
122
+ * of the workspaces is read. For the workspaces that other entries of the
123
+ * plugin receive, whose artifact directories graph creation compares with
124
+ * its own (`DES-OUTPUTS`, "Files of one name").
125
+ *
126
+ * @throws {Error} As {@link discoverWorkspaces} does for a report.
127
+ */
128
+ function discoverReportedWorkspaces(manifests_1, workspaceRoot_1) {
129
+ return tslib_1.__awaiter(this, arguments, void 0, function* (manifests, workspaceRoot, reports = new computation_reports_1.ComputationReports()) {
130
+ var _a, e_2, _b, _c;
131
+ const workspaces = [];
132
+ try {
133
+ for (var _d = true, _e = tslib_1.__asyncValues(claimWorkspaces(manifests, workspaceRoot, reports)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
134
+ _c = _f.value;
135
+ _d = false;
136
+ const { report } = _c;
137
+ workspaces.push({ root: repositoryPath(workspaceRoot, report.workspace_root) || ".", report });
138
+ }
139
+ }
140
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
141
+ finally {
142
+ try {
143
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
144
+ }
145
+ finally { if (e_2) throw e_2.error; }
146
+ }
147
+ return workspaces;
148
+ });
149
+ }
150
+ // The workspaces that the manifests make up, in the order of discovery:
151
+ // the shallowest unclaimed manifest is read, and the workspace that its
152
+ // report describes claims its root manifest and its members. A manifest of
153
+ // a directory source is never read (`isDirectorySourcePackage`).
154
+ function claimWorkspaces(manifests, workspaceRoot, reports) {
155
+ return tslib_1.__asyncGenerator(this, arguments, function* claimWorkspaces_1() {
156
+ const claimed = new Set();
157
+ const readable = manifests.filter((manifest) => !isDirectorySourcePackage((0, node_path_1.join)(workspaceRoot, manifest)));
158
+ for (const manifest of [...readable].sort(shallowestFirst)) {
159
+ if (claimed.has(manifest)) {
160
+ continue;
161
+ }
162
+ const report = yield tslib_1.__await(readWorkspace(manifest, workspaceRoot, reports));
163
+ const members = new Set(report.workspace_members);
164
+ const memberPackages = report.packages.filter((pkg) => members.has(pkg.id));
165
+ const rootManifest = repositoryPath(workspaceRoot, (0, node_path_1.join)(report.workspace_root, "Cargo.toml"));
166
+ claimed.add(manifest);
167
+ claimed.add(rootManifest);
168
+ for (const pkg of memberPackages) {
169
+ claimed.add(repositoryPath(workspaceRoot, pkg.manifest_path));
170
+ }
171
+ yield yield tslib_1.__await({ report, rootManifest, memberPackages });
172
+ }
173
+ });
174
+ }
175
+ /**
176
+ * The top-level keys of a Cargo configuration file whose settings can
177
+ * change what cargo builds or checks: the compiler, its flags and the
178
+ * linker, the profiles, the environment, the sources and the unstable
179
+ * features (`DES-DIAGNOSTICS`). `[resolver]`, `[registry]` and
180
+ * `[registries]` change only what `Cargo.lock` records, which the keys
181
+ * follow through the lockfile task's digests.
182
+ */
183
+ const buildTables = [
184
+ "build",
185
+ "target",
186
+ "host",
187
+ "profile",
188
+ "env",
189
+ "patch",
190
+ "source",
191
+ "paths",
192
+ "unstable",
193
+ "doc",
194
+ ];
195
+ /**
196
+ * One warning for each file that cargo reads for a workspace, that Nx does
197
+ * not hash, and that sets something that can change a build or a check
198
+ * ({@link buildTables}) or redirects dependencies: a configuration file
199
+ * outside the repository, such as the Cargo home's, and a configuration
200
+ * file or root manifest inside it that an ignore rule, such as one in
201
+ * `.gitignore` or `.nxignore`, leaves out of the files that Nx reads
202
+ * ({@link filesNxSees}). A result cached before a change to such a file can
203
+ * be restored after it, and where the file redirects dependencies, the Nx
204
+ * daemon keeps the graph's edges until it creates the graph again for
205
+ * another reason (`EVD-CARGO-REDIRECTIONS`, `RISK-HOST-ENVIRONMENT`).
206
+ *
207
+ * Each warning joins the {@link CargoWorkspace.configurationWarnings} of
208
+ * the workspaces it names, and stays out of their projects' keys, so that a
209
+ * Cargo configuration of one machine gives no keys of their own. It is
210
+ * printed at the start of every task, so it is kept to a few lines, and
211
+ * points to the caching guide for more.
212
+ */
213
+ // @mara implements DES-DIAGNOSTICS
214
+ function unhashedConfigurationWarnings(workspaces, workspaceRoot) {
215
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
216
+ const byFile = new Map();
217
+ const entry = (file, workspace) => {
218
+ var _a;
219
+ const found = (_a = byFile.get(file)) !== null && _a !== void 0 ? _a : { concerned: [], tables: new Set(), redirects: new Set() };
220
+ if (!found.concerned.includes(workspace)) {
221
+ found.concerned.push(workspace);
222
+ }
223
+ byFile.set(file, found);
224
+ return found;
225
+ };
226
+ for (const workspace of workspaces) {
227
+ for (const { file, keys } of workspace.configFiles) {
228
+ const counted = keys.filter((key) => buildTables.includes(key));
229
+ if (counted.length > 0) {
230
+ const found = entry(file, workspace);
231
+ counted.forEach((key) => found.tables.add(key));
232
+ }
233
+ }
234
+ for (const { file, table } of workspace.redirections) {
235
+ entry(file, workspace).redirects.add(table);
236
+ }
237
+ }
238
+ const inside = [...byFile.keys()]
239
+ .filter((file) => !isOutside(workspaceRoot, file))
240
+ .map((file) => repositoryPath(workspaceRoot, file));
241
+ const seen = yield (0, visibility_1.filesNxSees)(workspaceRoot, inside);
242
+ const messages = [];
243
+ for (const [file, { concerned, tables, redirects }] of byFile) {
244
+ const outside = isOutside(workspaceRoot, file);
245
+ if (!outside && seen.has(repositoryPath(workspaceRoot, file))) {
246
+ continue;
247
+ }
248
+ const shown = displayPath(workspaceRoot, file);
249
+ const subject = describeWorkspaces(concerned.map((workspace) => workspace.root));
250
+ const through = tableList(["patch", "replace", "paths"].filter((table) => redirects.has(table)));
251
+ const graph = `with the Nx daemon, the graph keeps these edges until a file that Nx reads changes or the daemon restarts (\`nx reset\`)`;
252
+ const guide = 'see "Cargo configuration that Nx does not hash" in the nx-rust caching guide';
253
+ // A root manifest sets nothing else that this warning names.
254
+ const message = (tables.size === 0
255
+ ? [
256
+ `nx-rust: ${shown} redirects dependencies of ${subject} through ${through}, so nx-rust gives the crates that may use the redirected crates edges to them.`,
257
+ outside
258
+ ? `The file lies outside the repository, so Nx does not see when it changes: ${graph}.`
259
+ : `An ignore rule, such as one in .gitignore or .nxignore, leaves the file out of the files that Nx reads, so Nx does not see when it changes: ${graph}.`,
260
+ outside
261
+ ? "To let Nx follow the redirections, move them into the root Cargo.toml of the workspace that needs them or into a .cargo/config.toml inside the repository."
262
+ : "To let Nx follow the redirections, stop ignoring the file, or run `nx reset` after each change to it.",
263
+ ]
264
+ : [
265
+ `nx-rust: ${shown} sets ${tableList(buildTables.filter((table) => tables.has(table)))} for ${subject}, but ${outside ? "lies outside the repository" : "an ignore rule leaves it out of the files that Nx reads"}, so Nx does not hash it, and a result cached before a change to it can be restored afterwards.`,
266
+ ...(redirects.size === 0
267
+ ? []
268
+ : [
269
+ `It redirects dependencies through ${through}; with the Nx daemon, the graph's edges follow a change to it only once Nx creates the graph again.`,
270
+ ]),
271
+ `${outside ? "Run" : "Stop ignoring it to have Nx hash it, or run"} \`nx reset\` after each change to it; --skip-nx-cache covers only the command it is given to (${guide}).`,
272
+ ]).join("\n");
273
+ for (const workspace of concerned) {
274
+ if (!workspace.configurationWarnings.includes(message)) {
275
+ workspace.configurationWarnings.push(message);
276
+ }
277
+ }
278
+ messages.push(message);
279
+ }
280
+ return messages;
281
+ });
282
+ }
283
+ // "[build]", "[build] and paths", or "[build], [env] and paths".
284
+ function tableList(tables) {
285
+ const named = tables.map((table) => (table === "paths" ? table : `[${table}]`));
286
+ return named.length <= 1
287
+ ? named.join("")
288
+ : `${named.slice(0, -1).join(", ")} and ${named[named.length - 1]}`;
289
+ }
290
+ // Adds a warning to those that the workspace's projects repeat, once.
291
+ function addWarning(workspace, message) {
292
+ if (!workspace.warnings.includes(message)) {
293
+ workspace.warnings.push(message);
294
+ }
295
+ }
296
+ /** "the Cargo workspace in rust", or "the Cargo workspaces in rust and shared". */
297
+ function describeWorkspaces(folders) {
298
+ const named = folders.map((folder) => (folder === "." ? "the repository root" : folder));
299
+ if (named.length === 1) {
300
+ return folders[0] === "."
301
+ ? "the Cargo workspace at the repository root"
302
+ : `the Cargo workspace in ${named[0]}`;
303
+ }
304
+ return `the Cargo workspaces in ${named.slice(0, -1).join(", ")} and ${named[named.length - 1]}`;
305
+ }
306
+ /**
307
+ * The folders of the crates that cargo finds below the folder of each
308
+ * `paths` entry of the workspaces ({@link cratesBelowPathsFolder}), by the
309
+ * real path of the entry's folder, each folder walked once. Without a
310
+ * `paths` entry, nothing is walked.
311
+ */
312
+ // @mara implements DES-METADATA-REPORT
313
+ function pathsFolderCrates(workspaces) {
314
+ const found = new Map();
315
+ for (const workspace of workspaces) {
316
+ for (const redirection of workspace.redirections) {
317
+ const real = (0, real_path_1.realPath)(redirection.folder);
318
+ if (redirection.table === "paths" && !found.has(real)) {
319
+ found.set(real, (0, paths_crates_1.cratesBelowPathsFolder)(real));
320
+ }
321
+ }
322
+ }
323
+ return found;
324
+ }
325
+ /**
326
+ * The crates that a `paths` entry can redirect to, by real folder: those
327
+ * that cargo finds below its folder (`found`) and, as cargo takes them as
328
+ * well, the path dependencies of each, of every kind, dev-dependencies and
329
+ * those for other platforms included, to any depth, inside or outside the
330
+ * folder, through crates with a project or without
331
+ * (`EVD-CARGO-REDIRECTIONS`). A crate that no report describes counts,
332
+ * but what it depends on is not known.
333
+ *
334
+ * This is not the walk that says what cargo builds with a crate, which
335
+ * takes normal and build dependencies only (`projectsBehindDependency` in
336
+ * `reached-projects.ts`): cargo takes these crates as candidates whether or
337
+ * not it compiles the crate that names them.
338
+ */
339
+ // @mara implements DES-METADATA-REPORT
340
+ function pathsCandidates(found, known) {
341
+ var _a, _b;
342
+ const candidates = [];
343
+ const visited = new Set();
344
+ const queue = [...found];
345
+ while (queue.length > 0) {
346
+ const folder = queue.shift();
347
+ if (visited.has(folder)) {
348
+ continue;
349
+ }
350
+ visited.add(folder);
351
+ candidates.push(folder);
352
+ for (const dependency of (_b = (_a = known.get(folder)) === null || _a === void 0 ? void 0 : _a.dependencies) !== null && _b !== void 0 ? _b : []) {
353
+ if (typeof dependency.path === "string") {
354
+ queue.push((0, real_path_1.realPath)(dependency.path));
355
+ }
356
+ }
357
+ }
358
+ return candidates;
359
+ }
360
+ /**
361
+ * Requests a report for each crate that the members reach through path
362
+ * dependencies, directly or through other such crates, and for each crate
363
+ * that a workspace's `[patch]` or `[replace]` entry redirects to, or that
364
+ * cargo takes from the folder of a `paths` entry (`pathsFolders`), that has
365
+ * no project and that no report covers yet; then for the crates that those
366
+ * reach through path dependencies, of every kind. Then it returns, by the
367
+ * real path of each `paths` folder, the crates that the entry can redirect
368
+ * to ({@link pathsCandidates}), without a folder whose report describes no
369
+ * package there, which holds a virtual manifest and no crate, as the root
370
+ * folder of a workspace whose report lists no package there does. Cargo
371
+ * starts in the root folder of the workspace whose member the walk started
372
+ * from, or whose table redirects to the crate: there the member's tasks
373
+ * run, and so there plain cargo reads the crate. A redirection to a folder
374
+ * without a `Cargo.toml` gets no report: cargo fails when it applies one,
375
+ * and the plugin leaves that failure to the cargo of the tasks. A crate,
376
+ * whether a path or a redirection names it, is compared with the crates
377
+ * that have projects and with those that a report describes by the real
378
+ * path of its folder, through symbolic links, so a path through a link to a
379
+ * crate with a project asks for no report.
380
+ *
381
+ * When cargo fails for a redirected crate, as for a crate inside a
382
+ * workspace's folder that is not its member, which cargo builds as a patch
383
+ * but does not report, graph creation goes on: a warning in `warnings` names
384
+ * the manifest and cargo's message, and the crate has no report. So it does
385
+ * for a path dependency whose report cargo refuses for a reason that it
386
+ * checks only for the crate it reports, which it builds as a dependency all
387
+ * the same ({@link isUnreportedPathDependency}); any other failure of a
388
+ * path dependency's report fails graph creation. Such a path dependency's warning
389
+ * also goes into `unreported`, by the real path of the crate's folder, and
390
+ * the warning of a redirected crate joins the {@link CargoWorkspace.warnings}
391
+ * of each workspace whose table redirects to it.
392
+ *
393
+ * A package of a directory source that no workspace report lists as a
394
+ * member gets no report ({@link isDirectorySourcePackage}); like any crate
395
+ * without a project, its folder is an input of the crates that use it.
396
+ */
397
+ // @mara implements DES-METADATA-REPORT
398
+ function readPathDependencies(workspaces, workspaceRoot, reports, warnings, unreported, pathsFolders) {
399
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
400
+ var _a;
401
+ // Crates by the real paths of their folders: a path names the crate at
402
+ // the real path of its folder, also where it passes a symbolic link.
403
+ const folderOf = (manifest) => (0, real_path_1.realPath)((0, node_path_1.dirname)(manifest));
404
+ const withProject = new Set(workspaces.flatMap((workspace) => workspace.members.map((pkg) => folderOf(pkg.manifest_path))));
405
+ const known = new Map();
406
+ for (const workspace of workspaces) {
407
+ for (const pkg of workspace.report.packages) {
408
+ known.set(folderOf(pkg.manifest_path), pkg);
409
+ }
410
+ }
411
+ // The root folders of the workspaces, whose reports describe any package there.
412
+ const workspaceRoots = new Set(workspaces.map((workspace) => (0, real_path_1.realPath)(workspace.report.workspace_root)));
413
+ const pathDependencyReports = [];
414
+ const noCrate = new Set();
415
+ const visited = new Set();
416
+ // The warning for each crate whose report cargo refused, by its real folder.
417
+ const failures = new Map();
418
+ const queue = [];
419
+ // Requests the report of a crate without a project, unless one covers it
420
+ // already, and queues the crate so that its path dependencies follow. A
421
+ // failure of cargo that graph creation goes on after, for a crate reached
422
+ // by path or by redirection, becomes a warning and leaves the crate
423
+ // without a report.
424
+ const reach = (manifest, cwd, subject, via) => tslib_1.__awaiter(this, void 0, void 0, function* () {
425
+ const folder = folderOf(manifest);
426
+ if (withProject.has(folder) || visited.has(folder)) {
427
+ return;
428
+ }
429
+ visited.add(folder);
430
+ if (!known.has(folder) && workspaceRoots.has(folder)) {
431
+ noCrate.add(folder);
432
+ return;
433
+ }
434
+ if (!known.has(folder) && isDirectorySourcePackage(manifest)) {
435
+ return;
436
+ }
437
+ if (!known.has(folder)) {
438
+ const report = yield readPathDependency(manifest, subject(), cwd, workspaceRoot, reports, via === "path" ? (error) => isUnreportedPathDependency(error, manifest) : () => true);
439
+ if (typeof report === "string") {
440
+ warnings.push(report);
441
+ failures.set(folder, report);
442
+ if (via === "path") {
443
+ unreported.set(folder, report);
444
+ }
445
+ return;
446
+ }
447
+ pathDependencyReports.push({ manifest: repositoryPath(workspaceRoot, manifest), report });
448
+ for (const pkg of report.packages) {
449
+ if (!known.has(folderOf(pkg.manifest_path))) {
450
+ known.set(folderOf(pkg.manifest_path), pkg);
451
+ }
452
+ }
453
+ }
454
+ const pkg = known.get(folder);
455
+ if (pkg) {
456
+ queue.push({ pkg, cwd });
457
+ }
458
+ else {
459
+ noCrate.add(folder);
460
+ }
461
+ });
462
+ const drain = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
463
+ while (queue.length > 0) {
464
+ const { pkg: dependent, cwd } = queue.shift();
465
+ for (const dependency of dependent.dependencies) {
466
+ if (typeof dependency.path === "string") {
467
+ yield reach((0, node_path_1.join)(dependency.path, "Cargo.toml"), cwd, () => `a path dependency of ${displayPath(workspaceRoot, dependent.manifest_path)} that has no project of its own`, "path");
468
+ }
469
+ }
470
+ }
471
+ });
472
+ for (const workspace of workspaces) {
473
+ for (const pkg of workspace.members) {
474
+ queue.push({ pkg, cwd: workspace.report.workspace_root });
475
+ }
476
+ }
477
+ yield drain();
478
+ for (const workspace of workspaces) {
479
+ for (const { table, folder, file } of workspace.redirections) {
480
+ const manifests = table === "paths"
481
+ ? ((_a = pathsFolders.get((0, real_path_1.realPath)(folder))) !== null && _a !== void 0 ? _a : []).map((crate) => (0, node_path_1.join)(crate, "Cargo.toml"))
482
+ : [(0, node_path_1.join)(folder, "Cargo.toml")];
483
+ for (const manifest of manifests.filter((manifest) => (0, node_fs_1.existsSync)(manifest))) {
484
+ yield reach(manifest, workspace.report.workspace_root, () => `a crate that ${displayPath(workspaceRoot, file)} redirects dependencies of the Cargo workspace in ${workspace.root} to, which has no project of its own`, "redirection");
485
+ const failure = failures.get(folderOf(manifest));
486
+ if (failure !== undefined) {
487
+ addWarning(workspace, failure);
488
+ }
489
+ yield drain();
490
+ }
491
+ }
492
+ }
493
+ const candidates = new Map();
494
+ for (const [folder, found] of pathsFolders) {
495
+ candidates.set(folder, pathsCandidates(found, known).filter((crate) => !noCrate.has(crate)));
496
+ }
497
+ return { pathDependencyReports, candidates };
498
+ });
499
+ }
500
+ /**
501
+ * Whether the crate of a manifest, by its absolute path, is a package of a
502
+ * directory source, such as one that `cargo vendor` wrote: its folder holds
503
+ * `.cargo-checksum.json`, which `cargo vendor` writes for every crate it
504
+ * vendors and without which cargo refuses such a package. It is a package of
505
+ * the source that the directory replaces, not a crate of the repository,
506
+ * whatever configuration names the folder and wherever it lies.
507
+ */
508
+ // @mara implements DES-DISCOVERY
509
+ function isDirectorySourcePackage(manifest) {
510
+ return (0, node_fs_1.existsSync)((0, node_path_1.join)((0, node_path_1.dirname)(manifest), ".cargo-checksum.json"));
511
+ }
512
+ /**
513
+ * Reads the workspace of a manifest that Nx handed to the plugin. The
514
+ * report requested in the manifest's folder names the workspace root. Where
515
+ * that is another folder, because Nx did not hand the root manifest to the
516
+ * plugin, one more report is requested in the root folder, where the
517
+ * workspace's tasks run cargo, and replaces the first: cargo takes its
518
+ * configuration files, a relative `CARGO_TARGET_DIR` and rustup its
519
+ * toolchain from the folder it starts in, so only that report names the
520
+ * artifact and build directories that the tasks use (`DES-DISCOVERY`).
521
+ */
522
+ // @mara implements DES-DISCOVERY
523
+ function readWorkspace(manifest, workspaceRoot, reports) {
524
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
525
+ const path = (0, node_path_1.join)(workspaceRoot, manifest);
526
+ const found = yield requestWorkspace(manifest, workspaceRoot, (0, node_path_1.dirname)(path), () => reports.request(path, (0, node_path_1.dirname)(path)));
527
+ if (reports.fromRoot(found)) {
528
+ return found;
529
+ }
530
+ const root = found.workspace_root;
531
+ return requestWorkspace(manifest, workspaceRoot, root, () => reports.requestFromRoot((0, node_path_1.join)(root, "Cargo.toml")));
532
+ });
533
+ }
534
+ // Makes one request of `readWorkspace`, with cargo started in `cwd`.
535
+ function requestWorkspace(manifest, workspaceRoot, cwd, request) {
536
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
537
+ try {
538
+ return yield request();
539
+ }
540
+ catch (error) {
541
+ const folder = displayPath(workspaceRoot, cwd) || "the repository root";
542
+ throw new Error(failureMessage(error, `the Cargo workspace of ${manifest}`, [
543
+ `Fix what cargo reports, so that \`cargo metadata --no-deps\` succeeds in ${folder}.`,
544
+ `If Nx should not read this manifest, add its path to "exclude" on the @convesoft/nx-rust entry in nx.json.`,
545
+ ]));
546
+ }
547
+ });
548
+ }
549
+ /**
550
+ * Whether cargo refused the report of a crate for a reason that it checks
551
+ * only for the crate it reports, never for a path dependency or patch that
552
+ * it builds for another workspace, so that such a crate builds as before
553
+ * (`EVD-CARGO-UNREPORTED-CRATES`). Cargo 1.91 and later state each reason
554
+ * with one message:
555
+ *
556
+ * - "current package believes it's in a workspace when it's not": the crate
557
+ * lies in the folder of a workspace, or names one in `package.workspace`,
558
+ * without being its member;
559
+ * - "root of a workspace inferred but wasn't a root": the manifest that the
560
+ * crate's `package.workspace`, or that of a crate above it, names has no
561
+ * `[workspace]` table;
562
+ * - "failed to read" a manifest other than the crate's own: cargo cannot
563
+ * read that manifest, as where `package.workspace` names a missing folder.
564
+ *
565
+ * The last two count only as cargo's error itself, the first line of its
566
+ * output that starts with `error:`. Cargo prints them also below another
567
+ * error, as the cause of a manifest that it rejects, such as one that takes
568
+ * a key from a workspace that it cannot read, and then it fails to build the
569
+ * crate as a dependency as well. "failed to load manifest for workspace
570
+ * member" stays an error: cargo prints it also where the member that fails
571
+ * to load is one that the crate depends on.
572
+ *
573
+ * @param manifest The absolute path of the crate's manifest, which cargo
574
+ * names where it cannot read that manifest itself.
575
+ */
576
+ function isUnreportedPathDependency(error, manifest) {
577
+ var _a, _b, _c;
578
+ if (error.stderr.includes("current package believes it's in a workspace when it's not")) {
579
+ return true;
580
+ }
581
+ const failure = (_b = (_a = /^error: (.*)$/m.exec(error.stderr)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : "";
582
+ if (failure.startsWith("root of a workspace inferred but wasn't a root: ")) {
583
+ return true;
584
+ }
585
+ const unread = (_c = /^failed to read `(.+)`$/.exec(failure)) === null || _c === void 0 ? void 0 : _c[1];
586
+ return unread !== undefined && (0, real_path_1.realPath)(unread) !== (0, real_path_1.realPath)(manifest);
587
+ }
588
+ // Reads a crate without a project. A failure of cargo itself that `goesOn`
589
+ // accepts gives the warning to print instead of a report.
590
+ function readPathDependency(manifest, subject, cwd, workspaceRoot, reports, goesOn) {
591
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
592
+ const shown = displayPath(workspaceRoot, manifest);
593
+ const folder = displayPath(workspaceRoot, cwd) || "the repository root";
594
+ try {
595
+ return yield reports.request(manifest, cwd);
596
+ }
597
+ catch (error) {
598
+ if (error instanceof run_cargo_1.CargoError && !error.notStarted && goesOn(error)) {
599
+ const output = error.stderr.trim();
600
+ return [
601
+ `nx-rust: \`cargo metadata\` failed for ${shown}, ${subject}: ${error.message}.`,
602
+ ...(output === "" ? [] : [output]),
603
+ "nx-rust goes on without its report, so it does not follow the crates that this crate depends on by path: the crates that use it take only its own folder into their cache keys, and a change in a crate behind it can leave their keys unchanged.",
604
+ `To have those crates followed, fix what cargo reports, so that \`cargo metadata --no-deps --manifest-path ${shown}\` succeeds in ${folder}, or declare their files with fileInputs in the [package.metadata.nx] or [workspace.metadata.nx] table of the crates that use it.`,
605
+ ].join("\n");
606
+ }
607
+ throw new Error(failureMessage(error, `${shown}, ${subject}`, [
608
+ "nx-rust reads such a manifest to find the path dependencies behind it.",
609
+ `Fix what cargo reports, so that \`cargo metadata --no-deps --manifest-path ${shown}\` succeeds in ${folder}.`,
610
+ ]));
611
+ }
612
+ });
613
+ }
614
+ // A message that names what failed, for what, and what to do.
615
+ function failureMessage(error, subject, fixes) {
616
+ if (error instanceof cargo_version_1.UnsupportedCargoError) {
617
+ return error.messageFor(subject);
618
+ }
619
+ if (error instanceof run_cargo_1.CargoError && error.notStarted) {
620
+ return [
621
+ `nx-rust could not read ${subject}: ${error.message}.`,
622
+ "nx-rust asks cargo for the crates whenever Nx creates the project graph, so every machine that runs nx in this repository needs cargo.",
623
+ "Install a Rust toolchain or put cargo on PATH, then run the command again.",
624
+ ].join("\n");
625
+ }
626
+ if (error instanceof run_cargo_1.CargoError) {
627
+ const output = error.stderr.trim();
628
+ return [
629
+ `\`cargo metadata\` failed for ${subject}: ${error.message}.`,
630
+ ...(output === "" ? [] : [output]),
631
+ ...fixes,
632
+ ].join("\n");
633
+ }
634
+ const reason = error instanceof Error ? error.message : String(error);
635
+ return [
636
+ `\`cargo metadata\` printed no report that nx-rust can read for ${subject}: ${reason}.`,
637
+ "Check that the cargo on PATH is Cargo 1.91 or later.",
638
+ ].join("\n");
639
+ }
640
+ // The path relative to the repository root, with `/` separators, or "" for
641
+ // the root itself. A path outside the repository starts with "..".
642
+ function repositoryPath(workspaceRoot, path) {
643
+ return (0, node_path_1.relative)(workspaceRoot, path);
644
+ }
645
+ // A path for a message: relative to the repository root where it lies
646
+ // inside, absolute otherwise.
647
+ function displayPath(workspaceRoot, path) {
648
+ return isOutside(workspaceRoot, path) ? path : repositoryPath(workspaceRoot, path);
649
+ }
650
+ // Whether the path lies outside the repository.
651
+ function isOutside(workspaceRoot, path) {
652
+ const inside = repositoryPath(workspaceRoot, path);
653
+ return inside === ".." || inside.startsWith("../") || (0, node_path_1.isAbsolute)(inside);
654
+ }
655
+ function shallowestFirst(a, b) {
656
+ return a.split("/").length - b.split("/").length || compare(a, b);
657
+ }
658
+ function compare(a, b) {
659
+ return a < b ? -1 : a > b ? 1 : 0;
660
+ }
661
+ //# sourceMappingURL=discovery.js.map