@convesoft/nx-rust 0.0.0 → 1.0.0-rc.1

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 (391) hide show
  1. package/LICENSE-APACHE +201 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +47 -1
  4. package/executors.json +35 -0
  5. package/generators.json +19 -0
  6. package/package.json +17 -4
  7. package/src/cargo/build-settings.d.ts +54 -0
  8. package/src/cargo/build-settings.js +93 -0
  9. package/src/cargo/build-settings.js.map +1 -0
  10. package/src/cargo/configured-runner.d.ts +36 -0
  11. package/src/cargo/configured-runner.js +99 -0
  12. package/src/cargo/configured-runner.js.map +1 -0
  13. package/src/cargo/configured-tools.d.ts +35 -0
  14. package/src/cargo/configured-tools.js +46 -0
  15. package/src/cargo/configured-tools.js.map +1 -0
  16. package/src/cargo/dep-info-basedir.d.ts +18 -0
  17. package/src/cargo/dep-info-basedir.js +38 -0
  18. package/src/cargo/dep-info-basedir.js.map +1 -0
  19. package/src/cargo/directories.d.ts +40 -0
  20. package/src/cargo/directories.js +89 -0
  21. package/src/cargo/directories.js.map +1 -0
  22. package/src/cargo/host-triple.d.ts +7 -0
  23. package/src/cargo/host-triple.js +21 -0
  24. package/src/cargo/host-triple.js.map +1 -0
  25. package/src/cargo/lockfile.d.ts +63 -0
  26. package/src/cargo/lockfile.js +157 -0
  27. package/src/cargo/lockfile.js.map +1 -0
  28. package/src/cargo/metadata.d.ts +112 -0
  29. package/src/cargo/metadata.js +37 -0
  30. package/src/cargo/metadata.js.map +1 -0
  31. package/src/cargo/package-specs.d.ts +54 -0
  32. package/src/cargo/package-specs.js +109 -0
  33. package/src/cargo/package-specs.js.map +1 -0
  34. package/src/cargo/paths-crates.d.ts +27 -0
  35. package/src/cargo/paths-crates.js +69 -0
  36. package/src/cargo/paths-crates.js.map +1 -0
  37. package/src/cargo/print-artifact-folders.d.ts +1 -0
  38. package/src/cargo/print-artifact-folders.js +58 -0
  39. package/src/cargo/print-artifact-folders.js.map +1 -0
  40. package/src/cargo/redirections.d.ts +87 -0
  41. package/src/cargo/redirections.js +195 -0
  42. package/src/cargo/redirections.js.map +1 -0
  43. package/src/cargo/run-cargo.d.ts +31 -0
  44. package/src/cargo/run-cargo.js +75 -0
  45. package/src/cargo/run-cargo.js.map +1 -0
  46. package/src/cargo/target-triples.d.ts +98 -0
  47. package/src/cargo/target-triples.js +265 -0
  48. package/src/cargo/target-triples.js.map +1 -0
  49. package/src/cargo/version-req.d.ts +12 -0
  50. package/src/cargo/version-req.js +122 -0
  51. package/src/cargo/version-req.js.map +1 -0
  52. package/src/compatibility/cargo-version.d.ts +43 -0
  53. package/src/compatibility/cargo-version.js +83 -0
  54. package/src/compatibility/cargo-version.js.map +1 -0
  55. package/src/compatibility/nx-bridge.d.ts +312 -0
  56. package/src/compatibility/nx-bridge.js +407 -0
  57. package/src/compatibility/nx-bridge.js.map +1 -0
  58. package/src/compatibility/nx-version.d.ts +104 -0
  59. package/src/compatibility/nx-version.js +272 -0
  60. package/src/compatibility/nx-version.js.map +1 -0
  61. package/src/executors/affected-inputs.d.ts +29 -0
  62. package/src/executors/affected-inputs.js +259 -0
  63. package/src/executors/affected-inputs.js.map +1 -0
  64. package/src/executors/affected-run.d.ts +54 -0
  65. package/src/executors/affected-run.js +394 -0
  66. package/src/executors/affected-run.js.map +1 -0
  67. package/src/executors/affected.d.ts +239 -0
  68. package/src/executors/affected.js +589 -0
  69. package/src/executors/affected.js.map +1 -0
  70. package/src/executors/baseline-context.d.ts +85 -0
  71. package/src/executors/baseline-context.js +227 -0
  72. package/src/executors/baseline-context.js.map +1 -0
  73. package/src/executors/baseline.d.ts +123 -0
  74. package/src/executors/baseline.js +356 -0
  75. package/src/executors/baseline.js.map +1 -0
  76. package/src/executors/batch.d.ts +75 -0
  77. package/src/executors/batch.js +434 -0
  78. package/src/executors/batch.js.map +1 -0
  79. package/src/executors/build-records.d.ts +110 -0
  80. package/src/executors/build-records.js +267 -0
  81. package/src/executors/build-records.js.map +1 -0
  82. package/src/executors/cargo/executor.d.ts +28 -0
  83. package/src/executors/cargo/executor.js +58 -0
  84. package/src/executors/cargo/executor.js.map +1 -0
  85. package/src/executors/cargo/schema.json +54 -0
  86. package/src/executors/cargo-invocation.d.ts +81 -0
  87. package/src/executors/cargo-invocation.js +109 -0
  88. package/src/executors/cargo-invocation.js.map +1 -0
  89. package/src/executors/cargo-output.d.ts +212 -0
  90. package/src/executors/cargo-output.js +646 -0
  91. package/src/executors/cargo-output.js.map +1 -0
  92. package/src/executors/command.d.ts +318 -0
  93. package/src/executors/command.js +517 -0
  94. package/src/executors/command.js.map +1 -0
  95. package/src/executors/coverage-baseline.d.ts +23 -0
  96. package/src/executors/coverage-baseline.js +284 -0
  97. package/src/executors/coverage-baseline.js.map +1 -0
  98. package/src/executors/declared-options.d.ts +21 -0
  99. package/src/executors/declared-options.js +58 -0
  100. package/src/executors/declared-options.js.map +1 -0
  101. package/src/executors/digests.d.ts +94 -0
  102. package/src/executors/digests.js +190 -0
  103. package/src/executors/digests.js.map +1 -0
  104. package/src/executors/dotenv-check.d.ts +79 -0
  105. package/src/executors/dotenv-check.js +553 -0
  106. package/src/executors/dotenv-check.js.map +1 -0
  107. package/src/executors/group-invocations.d.ts +80 -0
  108. package/src/executors/group-invocations.js +253 -0
  109. package/src/executors/group-invocations.js.map +1 -0
  110. package/src/executors/group-run.d.ts +114 -0
  111. package/src/executors/group-run.js +591 -0
  112. package/src/executors/group-run.js.map +1 -0
  113. package/src/executors/groups.d.ts +113 -0
  114. package/src/executors/groups.js +285 -0
  115. package/src/executors/groups.js.map +1 -0
  116. package/src/executors/input-check.d.ts +52 -0
  117. package/src/executors/input-check.js +271 -0
  118. package/src/executors/input-check.js.map +1 -0
  119. package/src/executors/kept-files.d.ts +98 -0
  120. package/src/executors/kept-files.js +341 -0
  121. package/src/executors/kept-files.js.map +1 -0
  122. package/src/executors/lockfile/executor.d.ts +16 -0
  123. package/src/executors/lockfile/executor.js +37 -0
  124. package/src/executors/lockfile/executor.js.map +1 -0
  125. package/src/executors/lockfile/schema.json +50 -0
  126. package/src/executors/napi-build.d.ts +73 -0
  127. package/src/executors/napi-build.js +420 -0
  128. package/src/executors/napi-build.js.map +1 -0
  129. package/src/executors/nextest.d.ts +185 -0
  130. package/src/executors/nextest.js +498 -0
  131. package/src/executors/nextest.js.map +1 -0
  132. package/src/executors/nx-command.d.ts +95 -0
  133. package/src/executors/nx-command.js +205 -0
  134. package/src/executors/nx-command.js.map +1 -0
  135. package/src/executors/nx-task-files.d.ts +82 -0
  136. package/src/executors/nx-task-files.js +156 -0
  137. package/src/executors/nx-task-files.js.map +1 -0
  138. package/src/executors/print-test-mode.d.ts +1 -0
  139. package/src/executors/print-test-mode.js +25 -0
  140. package/src/executors/print-test-mode.js.map +1 -0
  141. package/src/executors/release-publish/executor.d.ts +24 -0
  142. package/src/executors/release-publish/executor.js +165 -0
  143. package/src/executors/release-publish/executor.js.map +1 -0
  144. package/src/executors/release-publish/schema.json +30 -0
  145. package/src/executors/run/executor.d.ts +12 -0
  146. package/src/executors/run/executor.js +27 -0
  147. package/src/executors/run/executor.js.map +1 -0
  148. package/src/executors/run/schema.json +45 -0
  149. package/src/executors/runner-script.d.ts +12 -0
  150. package/src/executors/runner-script.js +22 -0
  151. package/src/executors/runner-script.js.map +1 -0
  152. package/src/executors/runtime-input-check.d.ts +24 -0
  153. package/src/executors/runtime-input-check.js +87 -0
  154. package/src/executors/runtime-input-check.js.map +1 -0
  155. package/src/executors/shared-artifacts.d.ts +44 -0
  156. package/src/executors/shared-artifacts.js +132 -0
  157. package/src/executors/shared-artifacts.js.map +1 -0
  158. package/src/executors/split-words.d.ts +24 -0
  159. package/src/executors/split-words.js +111 -0
  160. package/src/executors/split-words.js.map +1 -0
  161. package/src/executors/stage.d.ts +163 -0
  162. package/src/executors/stage.js +526 -0
  163. package/src/executors/stage.js.map +1 -0
  164. package/src/executors/staged-run.d.ts +24 -0
  165. package/src/executors/staged-run.js +110 -0
  166. package/src/executors/staged-run.js.map +1 -0
  167. package/src/executors/task-env.d.ts +271 -0
  168. package/src/executors/task-env.js +494 -0
  169. package/src/executors/task-env.js.map +1 -0
  170. package/src/executors/task-execution.d.ts +61 -0
  171. package/src/executors/task-execution.js +122 -0
  172. package/src/executors/task-execution.js.map +1 -0
  173. package/src/executors/task-guards.d.ts +112 -0
  174. package/src/executors/task-guards.js +430 -0
  175. package/src/executors/task-guards.js.map +1 -0
  176. package/src/executors/task-options.d.ts +114 -0
  177. package/src/executors/task-options.js +258 -0
  178. package/src/executors/task-options.js.map +1 -0
  179. package/src/executors/task.d.ts +166 -0
  180. package/src/executors/task.js +520 -0
  181. package/src/executors/task.js.map +1 -0
  182. package/src/executors/test-mode.d.ts +182 -0
  183. package/src/executors/test-mode.js +391 -0
  184. package/src/executors/test-mode.js.map +1 -0
  185. package/src/executors/test-runner.d.ts +44 -0
  186. package/src/executors/test-runner.js +159 -0
  187. package/src/executors/test-runner.js.map +1 -0
  188. package/src/executors/test-steps.d.ts +109 -0
  189. package/src/executors/test-steps.js +535 -0
  190. package/src/executors/test-steps.js.map +1 -0
  191. package/src/executors/wasm-build.d.ts +56 -0
  192. package/src/executors/wasm-build.js +216 -0
  193. package/src/executors/wasm-build.js.map +1 -0
  194. package/src/generators/crate/binary.schema.json +28 -0
  195. package/src/generators/crate/crate.d.ts +24 -0
  196. package/src/generators/crate/crate.js +108 -0
  197. package/src/generators/crate/crate.js.map +1 -0
  198. package/src/generators/crate/enclosing-workspace.d.ts +25 -0
  199. package/src/generators/crate/enclosing-workspace.js +58 -0
  200. package/src/generators/crate/enclosing-workspace.js.map +1 -0
  201. package/src/generators/crate/library.schema.json +28 -0
  202. package/src/generators/init/graph-check.d.ts +81 -0
  203. package/src/generators/init/graph-check.js +299 -0
  204. package/src/generators/init/graph-check.js.map +1 -0
  205. package/src/generators/init/init.d.ts +23 -0
  206. package/src/generators/init/init.js +113 -0
  207. package/src/generators/init/init.js.map +1 -0
  208. package/src/generators/init/report.d.ts +19 -0
  209. package/src/generators/init/report.js +93 -0
  210. package/src/generators/init/report.js.map +1 -0
  211. package/src/generators/init/schema.json +9 -0
  212. package/src/graph/artifact-kinds.d.ts +29 -0
  213. package/src/graph/artifact-kinds.js +50 -0
  214. package/src/graph/artifact-kinds.js.map +1 -0
  215. package/src/graph/artifact-names.d.ts +97 -0
  216. package/src/graph/artifact-names.js +276 -0
  217. package/src/graph/artifact-names.js.map +1 -0
  218. package/src/graph/build-records.d.ts +74 -0
  219. package/src/graph/build-records.js +104 -0
  220. package/src/graph/build-records.js.map +1 -0
  221. package/src/graph/caching.d.ts +148 -0
  222. package/src/graph/caching.js +676 -0
  223. package/src/graph/caching.js.map +1 -0
  224. package/src/graph/collisions.d.ts +106 -0
  225. package/src/graph/collisions.js +156 -0
  226. package/src/graph/collisions.js.map +1 -0
  227. package/src/graph/computation-reports.d.ts +89 -0
  228. package/src/graph/computation-reports.js +216 -0
  229. package/src/graph/computation-reports.js.map +1 -0
  230. package/src/graph/declared-files.d.ts +190 -0
  231. package/src/graph/declared-files.js +600 -0
  232. package/src/graph/declared-files.js.map +1 -0
  233. package/src/graph/discovery.d.ts +175 -0
  234. package/src/graph/discovery.js +656 -0
  235. package/src/graph/discovery.js.map +1 -0
  236. package/src/graph/edges.d.ts +25 -0
  237. package/src/graph/edges.js +94 -0
  238. package/src/graph/edges.js.map +1 -0
  239. package/src/graph/entries.d.ts +83 -0
  240. package/src/graph/entries.js +259 -0
  241. package/src/graph/entries.js.map +1 -0
  242. package/src/graph/inputs.d.ts +420 -0
  243. package/src/graph/inputs.js +746 -0
  244. package/src/graph/inputs.js.map +1 -0
  245. package/src/graph/lockfile-task.d.ts +74 -0
  246. package/src/graph/lockfile-task.js +105 -0
  247. package/src/graph/lockfile-task.js.map +1 -0
  248. package/src/graph/names.d.ts +41 -0
  249. package/src/graph/names.js +34 -0
  250. package/src/graph/names.js.map +1 -0
  251. package/src/graph/napi.d.ts +107 -0
  252. package/src/graph/napi.js +206 -0
  253. package/src/graph/napi.js.map +1 -0
  254. package/src/graph/nx-glob.d.ts +36 -0
  255. package/src/graph/nx-glob.js +152 -0
  256. package/src/graph/nx-glob.js.map +1 -0
  257. package/src/graph/nx-internals.d.ts +57 -0
  258. package/src/graph/nx-internals.js +128 -0
  259. package/src/graph/nx-internals.js.map +1 -0
  260. package/src/graph/options.d.ts +32 -0
  261. package/src/graph/options.js +80 -0
  262. package/src/graph/options.js.map +1 -0
  263. package/src/graph/outputs.d.ts +75 -0
  264. package/src/graph/outputs.js +140 -0
  265. package/src/graph/outputs.js.map +1 -0
  266. package/src/graph/path-dependencies.d.ts +122 -0
  267. package/src/graph/path-dependencies.js +459 -0
  268. package/src/graph/path-dependencies.js.map +1 -0
  269. package/src/graph/plugin-package.d.ts +36 -0
  270. package/src/graph/plugin-package.js +132 -0
  271. package/src/graph/plugin-package.js.map +1 -0
  272. package/src/graph/plugin-version.d.ts +20 -0
  273. package/src/graph/plugin-version.js +153 -0
  274. package/src/graph/plugin-version.js.map +1 -0
  275. package/src/graph/projects.d.ts +141 -0
  276. package/src/graph/projects.js +182 -0
  277. package/src/graph/projects.js.map +1 -0
  278. package/src/graph/reached-projects.d.ts +46 -0
  279. package/src/graph/reached-projects.js +102 -0
  280. package/src/graph/reached-projects.js.map +1 -0
  281. package/src/graph/real-path.d.ts +47 -0
  282. package/src/graph/real-path.js +113 -0
  283. package/src/graph/real-path.js.map +1 -0
  284. package/src/graph/redirected-uses.d.ts +98 -0
  285. package/src/graph/redirected-uses.js +434 -0
  286. package/src/graph/redirected-uses.js.map +1 -0
  287. package/src/graph/registration.d.ts +121 -0
  288. package/src/graph/registration.js +233 -0
  289. package/src/graph/registration.js.map +1 -0
  290. package/src/graph/script-input.d.ts +46 -0
  291. package/src/graph/script-input.js +65 -0
  292. package/src/graph/script-input.js.map +1 -0
  293. package/src/graph/settings.d.ts +178 -0
  294. package/src/graph/settings.js +479 -0
  295. package/src/graph/settings.js.map +1 -0
  296. package/src/graph/target-defaults-causes.d.ts +33 -0
  297. package/src/graph/target-defaults-causes.js +202 -0
  298. package/src/graph/target-defaults-causes.js.map +1 -0
  299. package/src/graph/target-defaults-layers.d.ts +186 -0
  300. package/src/graph/target-defaults-layers.js +420 -0
  301. package/src/graph/target-defaults-layers.js.map +1 -0
  302. package/src/graph/target-defaults-meaning.d.ts +95 -0
  303. package/src/graph/target-defaults-meaning.js +292 -0
  304. package/src/graph/target-defaults-meaning.js.map +1 -0
  305. package/src/graph/target-defaults-report.d.ts +77 -0
  306. package/src/graph/target-defaults-report.js +242 -0
  307. package/src/graph/target-defaults-report.js.map +1 -0
  308. package/src/graph/target-defaults.d.ts +79 -0
  309. package/src/graph/target-defaults.js +425 -0
  310. package/src/graph/target-defaults.js.map +1 -0
  311. package/src/graph/target-fields.d.ts +16 -0
  312. package/src/graph/target-fields.js +134 -0
  313. package/src/graph/target-fields.js.map +1 -0
  314. package/src/graph/target-tables.d.ts +45 -0
  315. package/src/graph/target-tables.js +299 -0
  316. package/src/graph/target-tables.js.map +1 -0
  317. package/src/graph/targets.d.ts +367 -0
  318. package/src/graph/targets.js +404 -0
  319. package/src/graph/targets.js.map +1 -0
  320. package/src/graph/unification.d.ts +141 -0
  321. package/src/graph/unification.js +459 -0
  322. package/src/graph/unification.js.map +1 -0
  323. package/src/graph/unignored-directories.d.ts +25 -0
  324. package/src/graph/unignored-directories.js +89 -0
  325. package/src/graph/unignored-directories.js.map +1 -0
  326. package/src/graph/visibility.d.ts +17 -0
  327. package/src/graph/visibility.js +67 -0
  328. package/src/graph/visibility.js.map +1 -0
  329. package/src/graph/warnings.d.ts +38 -0
  330. package/src/graph/warnings.js +77 -0
  331. package/src/graph/warnings.js.map +1 -0
  332. package/src/graph/wasm.d.ts +56 -0
  333. package/src/graph/wasm.js +77 -0
  334. package/src/graph/wasm.js.map +1 -0
  335. package/src/index.d.ts +68 -0
  336. package/src/index.js +109 -0
  337. package/src/index.js.map +1 -0
  338. package/src/release/manifests.d.ts +95 -0
  339. package/src/release/manifests.js +164 -0
  340. package/src/release/manifests.js.map +1 -0
  341. package/src/release/places.d.ts +127 -0
  342. package/src/release/places.js +368 -0
  343. package/src/release/places.js.map +1 -0
  344. package/src/release/publish-cargo.d.ts +177 -0
  345. package/src/release/publish-cargo.js +351 -0
  346. package/src/release/publish-cargo.js.map +1 -0
  347. package/src/release/publish-crates.d.ts +124 -0
  348. package/src/release/publish-crates.js +242 -0
  349. package/src/release/publish-crates.js.map +1 -0
  350. package/src/release/publish-environments.d.ts +50 -0
  351. package/src/release/publish-environments.js +284 -0
  352. package/src/release/publish-environments.js.map +1 -0
  353. package/src/release/publish-messages.d.ts +66 -0
  354. package/src/release/publish-messages.js +273 -0
  355. package/src/release/publish-messages.js.map +1 -0
  356. package/src/release/publish-registry.d.ts +27 -0
  357. package/src/release/publish-registry.js +135 -0
  358. package/src/release/publish-registry.js.map +1 -0
  359. package/src/release/publish-settings.d.ts +26 -0
  360. package/src/release/publish-settings.js +56 -0
  361. package/src/release/publish-settings.js.map +1 -0
  362. package/src/release/publish.d.ts +59 -0
  363. package/src/release/publish.js +620 -0
  364. package/src/release/publish.js.map +1 -0
  365. package/src/release/repository.d.ts +73 -0
  366. package/src/release/repository.js +219 -0
  367. package/src/release/repository.js.map +1 -0
  368. package/src/release/requirements.d.ts +34 -0
  369. package/src/release/requirements.js +30 -0
  370. package/src/release/requirements.js.map +1 -0
  371. package/src/release/toml-edit.d.ts +67 -0
  372. package/src/release/toml-edit.js +453 -0
  373. package/src/release/toml-edit.js.map +1 -0
  374. package/src/release/version-actions.d.ts +133 -0
  375. package/src/release/version-actions.js +474 -0
  376. package/src/release/version-actions.js.map +1 -0
  377. package/src/release/version-checks.d.ts +21 -0
  378. package/src/release/version-checks.js +151 -0
  379. package/src/release/version-checks.js.map +1 -0
  380. package/src/release/version-lockfiles.d.ts +61 -0
  381. package/src/release/version-lockfiles.js +222 -0
  382. package/src/release/version-lockfiles.js.map +1 -0
  383. package/src/tools/napi-cli.d.ts +70 -0
  384. package/src/tools/napi-cli.js +63 -0
  385. package/src/tools/napi-cli.js.map +1 -0
  386. package/src/tools/optional-tools.d.ts +121 -0
  387. package/src/tools/optional-tools.js +303 -0
  388. package/src/tools/optional-tools.js.map +1 -0
  389. package/src/tools/print-napi-cli.d.ts +1 -0
  390. package/src/tools/print-napi-cli.js +24 -0
  391. package/src/tools/print-napi-cli.js.map +1 -0
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readRedirections = readRedirections;
4
+ exports.configFiles = configFiles;
5
+ const tslib_1 = require("tslib");
6
+ const node_fs_1 = require("node:fs");
7
+ const promises_1 = require("node:fs/promises");
8
+ const node_os_1 = require("node:os");
9
+ const node_path_1 = require("node:path");
10
+ const smol_toml_1 = require("smol-toml");
11
+ /**
12
+ * Reads the redirections that cargo applies when it builds the workspace
13
+ * whose root manifest is in `workspaceRoot`, without running cargo:
14
+ *
15
+ * - every `[patch.<source>]` and `[replace]` entry with a `path` in the root
16
+ * manifest, resolved against the manifest's folder; cargo ignores these
17
+ * tables in other manifests;
18
+ * - every `[patch.<source>]` entry with a `path`, and every `paths` entry, in
19
+ * the configuration of `workspaceRoot`, of every folder above it and of the
20
+ * Cargo home, following `include`. In each of these folders cargo reads
21
+ * `.cargo/config` where it exists, and `.cargo/config.toml` otherwise; in
22
+ * the Cargo home, `config` or `config.toml` in the same way. It resolves a
23
+ * path in such a file against the folder above the one that holds the file.
24
+ *
25
+ * The plugin's cargo commands start in the workspace root, so cargo reads
26
+ * these configuration files for them. An `include` is followed whatever the
27
+ * Cargo version: Cargo 1.91 ignores it, and a redirection that cargo does
28
+ * not apply only adds edges. For the same reason, an included file that
29
+ * cannot be read or parsed is skipped with a warning instead of failing.
30
+ * A file that does not exist is skipped.
31
+ *
32
+ * @param env Where `CARGO_HOME` is read from; without it, the Cargo home is
33
+ * `~/.cargo`.
34
+ * @throws {Error} When the root manifest or a configuration file that cargo
35
+ * reads in any version is no valid TOML, naming the file.
36
+ */
37
+ // @mara implements DES-METADATA-REPORT
38
+ function readRedirections(workspaceRoot_1) {
39
+ return tslib_1.__awaiter(this, arguments, void 0, function* (workspaceRoot, env = process.env) {
40
+ const manifest = (0, node_path_1.join)(workspaceRoot, "Cargo.toml");
41
+ const found = {
42
+ redirections: [],
43
+ includedFiles: [],
44
+ configFiles: [],
45
+ warnings: [],
46
+ };
47
+ const table = yield readToml(manifest);
48
+ if (table !== undefined) {
49
+ found.redirections.push(...patchEntries(table.patch, (0, node_path_1.dirname)(manifest), manifest));
50
+ for (const [key, entry] of Object.entries(asTable(table.replace))) {
51
+ const path = asTable(entry).path;
52
+ if (typeof path === "string") {
53
+ found.redirections.push({
54
+ table: "replace",
55
+ folder: (0, node_path_1.resolve)(workspaceRoot, path),
56
+ file: manifest,
57
+ key,
58
+ });
59
+ }
60
+ }
61
+ }
62
+ const read = new Set();
63
+ for (const [legacy, current] of configFiles(workspaceRoot, env)) {
64
+ yield readConfig((0, node_fs_1.existsSync)(legacy) ? legacy : current, read, found);
65
+ }
66
+ return found;
67
+ });
68
+ }
69
+ /**
70
+ * The configuration files cargo reads for a command started in `folder`, in
71
+ * descending precedence, as pairs of the older and the current name, of
72
+ * which cargo reads the older where it exists: those of the folder and each
73
+ * one above it, then those of the Cargo home, which cargo reads once where
74
+ * it is also one of the folders.
75
+ */
76
+ function configFiles(folder, env) {
77
+ const files = [];
78
+ let current = (0, node_path_1.resolve)(folder);
79
+ for (;;) {
80
+ files.push([(0, node_path_1.join)(current, ".cargo", "config"), (0, node_path_1.join)(current, ".cargo", "config.toml")]);
81
+ const parent = (0, node_path_1.dirname)(current);
82
+ if (parent === current) {
83
+ break;
84
+ }
85
+ current = parent;
86
+ }
87
+ const cargoHome = env.CARGO_HOME ? (0, node_path_1.resolve)(folder, env.CARGO_HOME) : (0, node_path_1.join)((0, node_os_1.homedir)(), ".cargo");
88
+ files.push([(0, node_path_1.join)(cargoHome, "config"), (0, node_path_1.join)(cargoHome, "config.toml")]);
89
+ return files;
90
+ }
91
+ // Adds the redirections of a configuration file and of the files it
92
+ // includes, reading each file once. An included file that cannot be read or
93
+ // parsed adds a warning instead.
94
+ function readConfig(file, read, found, includedFrom) {
95
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
96
+ if (read.has(file)) {
97
+ return;
98
+ }
99
+ read.add(file);
100
+ let table;
101
+ try {
102
+ table = yield readToml(file);
103
+ }
104
+ catch (error) {
105
+ if (includedFrom === undefined) {
106
+ throw error;
107
+ }
108
+ const reason = error instanceof TomlError ? error.reason : String(error);
109
+ found.warnings.push([
110
+ `nx-rust: ${file}, which ${includedFrom} includes, cannot be read: ${reason}`,
111
+ "nx-rust skips it, so a [patch] or paths entry in it gives no edges. Cargo 1.91 ignores include, and later versions fail on such a file.",
112
+ `Correct the file's TOML, or remove it from include in ${includedFrom}.`,
113
+ ].join("\n"));
114
+ return;
115
+ }
116
+ if (table === undefined) {
117
+ return;
118
+ }
119
+ if (includedFrom !== undefined) {
120
+ found.includedFiles.push(file);
121
+ }
122
+ found.configFiles.push({ file, keys: Object.keys(table) });
123
+ const base = (0, node_path_1.dirname)((0, node_path_1.dirname)(file));
124
+ found.redirections.push(...patchEntries(table.patch, base, file));
125
+ if (Array.isArray(table.paths)) {
126
+ for (const path of table.paths) {
127
+ if (typeof path === "string") {
128
+ found.redirections.push({ table: "paths", folder: (0, node_path_1.resolve)(base, path), file });
129
+ }
130
+ }
131
+ }
132
+ const includes = Array.isArray(table.include) ? table.include : [table.include];
133
+ for (const include of includes) {
134
+ const path = typeof include === "string" ? include : asTable(include).path;
135
+ if (typeof path === "string") {
136
+ yield readConfig((0, node_path_1.resolve)((0, node_path_1.dirname)(file), path), read, found, file);
137
+ }
138
+ }
139
+ });
140
+ }
141
+ // The `[patch.<source>]` entries with a path, resolved against `base`.
142
+ function patchEntries(patch, base, file) {
143
+ const redirections = [];
144
+ for (const [key, source] of Object.entries(asTable(patch))) {
145
+ for (const entry of Object.values(asTable(source))) {
146
+ const path = asTable(entry).path;
147
+ if (typeof path === "string") {
148
+ redirections.push({ table: "patch", folder: (0, node_path_1.resolve)(base, path), file, key });
149
+ }
150
+ }
151
+ }
152
+ return redirections;
153
+ }
154
+ /** A file that exists but is no valid TOML. */
155
+ class TomlError extends Error {
156
+ constructor(file,
157
+ /** The parser's message. */
158
+ reason) {
159
+ super([
160
+ `nx-rust could not parse ${file}: ${reason}`,
161
+ "nx-rust reads this file for the [patch], [replace] and paths entries that cargo applies, because a crate that cargo may build in place of a dependency needs an edge in the graph.",
162
+ "If cargo accepts the file, please report this at https://github.com/convesoft/nx-rust/issues.",
163
+ ].join("\n"));
164
+ this.reason = reason;
165
+ this.name = "TomlError";
166
+ }
167
+ }
168
+ // The parsed file, or undefined when it does not exist.
169
+ function readToml(file) {
170
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
171
+ let text;
172
+ try {
173
+ text = yield (0, promises_1.readFile)(file, "utf8");
174
+ }
175
+ catch (error) {
176
+ const code = error.code;
177
+ if (code === "ENOENT" || code === "ENOTDIR" || code === "EISDIR") {
178
+ return undefined;
179
+ }
180
+ throw error;
181
+ }
182
+ try {
183
+ return (0, smol_toml_1.parse)(text);
184
+ }
185
+ catch (error) {
186
+ throw new TomlError(file, error instanceof Error ? error.message : String(error));
187
+ }
188
+ });
189
+ }
190
+ function asTable(value) {
191
+ return typeof value === "object" && value !== null && !Array.isArray(value)
192
+ ? value
193
+ : {};
194
+ }
195
+ //# sourceMappingURL=redirections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirections.js","sourceRoot":"","sources":["../../../../nx-rust/src/cargo/redirections.ts"],"names":[],"mappings":";;AAwFA,4CA+BC;AASD,kCAiBC;;AAjJD,qCAAqC;AACrC,+CAA4C;AAC5C,qCAAkC;AAClC,yCAAmD;AACnD,yCAAkC;AAyDlC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,uCAAuC;AACvC,SAAsB,gBAAgB;iEACpC,aAAqB,E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AAS,OAAO,CAAC,KAAc;IAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
@@ -0,0 +1,31 @@
1
+ /** Cargo gave no result: it could not be started, or it failed. */
2
+ export declare class CargoError extends Error {
3
+ /** True when cargo could not be started at all, such as when it is not on `PATH`. */
4
+ readonly notStarted: boolean;
5
+ /** What cargo wrote to standard error. */
6
+ readonly stderr: string;
7
+ constructor(message: string,
8
+ /** True when cargo could not be started at all, such as when it is not on `PATH`. */
9
+ notStarted: boolean,
10
+ /** What cargo wrote to standard error. */
11
+ stderr: string);
12
+ }
13
+ /**
14
+ * Runs cargo for the creation of the project graph and returns what it wrote
15
+ * to standard output.
16
+ *
17
+ * Every cargo call that graph creation makes starts here, so that a setting
18
+ * that applies to graph creation only, and not to tasks, has one place.
19
+ *
20
+ * Cargo runs with `RUSTUP_AUTO_INSTALL=0`, set for this child only: where
21
+ * cargo is a rustup proxy, a toolchain that is pinned for `cwd` and not
22
+ * installed fails the call with rustup's message, which names the toolchain,
23
+ * instead of being downloaded. A cargo that is no rustup proxy ignores the
24
+ * variable. Tasks run cargo elsewhere and keep rustup's default.
25
+ *
26
+ * @param args The arguments after `cargo`.
27
+ * @param cwd The folder cargo starts in, which decides the toolchain that
28
+ * rustup picks and the configuration files that Cargo reads.
29
+ * @throws {CargoError} When cargo cannot be started or exits unsuccessfully.
30
+ */
31
+ export declare function runCargoForGraph(args: readonly string[], cwd: string): Promise<string>;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CargoError = void 0;
4
+ exports.runCargoForGraph = runCargoForGraph;
5
+ const node_child_process_1 = require("node:child_process");
6
+ /** Cargo gave no result: it could not be started, or it failed. */
7
+ class CargoError extends Error {
8
+ constructor(message,
9
+ /** True when cargo could not be started at all, such as when it is not on `PATH`. */
10
+ notStarted,
11
+ /** What cargo wrote to standard error. */
12
+ stderr) {
13
+ super(message);
14
+ this.notStarted = notStarted;
15
+ this.stderr = stderr;
16
+ this.name = "CargoError";
17
+ }
18
+ }
19
+ exports.CargoError = CargoError;
20
+ /**
21
+ * Runs cargo for the creation of the project graph and returns what it wrote
22
+ * to standard output.
23
+ *
24
+ * Every cargo call that graph creation makes starts here, so that a setting
25
+ * that applies to graph creation only, and not to tasks, has one place.
26
+ *
27
+ * Cargo runs with `RUSTUP_AUTO_INSTALL=0`, set for this child only: where
28
+ * cargo is a rustup proxy, a toolchain that is pinned for `cwd` and not
29
+ * installed fails the call with rustup's message, which names the toolchain,
30
+ * instead of being downloaded. A cargo that is no rustup proxy ignores the
31
+ * variable. Tasks run cargo elsewhere and keep rustup's default.
32
+ *
33
+ * @param args The arguments after `cargo`.
34
+ * @param cwd The folder cargo starts in, which decides the toolchain that
35
+ * rustup picks and the configuration files that Cargo reads.
36
+ * @throws {CargoError} When cargo cannot be started or exits unsuccessfully.
37
+ */
38
+ // @mara implements DES-METADATA-REPORT
39
+ function runCargoForGraph(args, cwd) {
40
+ return new Promise((resolve, reject) => {
41
+ let settled = false;
42
+ const settle = (finish) => {
43
+ if (!settled) {
44
+ settled = true;
45
+ finish();
46
+ }
47
+ };
48
+ const child = (0, node_child_process_1.spawn)("cargo", args, {
49
+ cwd,
50
+ env: Object.assign(Object.assign({}, process.env), { RUSTUP_AUTO_INSTALL: "0" }),
51
+ stdio: ["ignore", "pipe", "pipe"],
52
+ });
53
+ const stdout = [];
54
+ const stderr = [];
55
+ child.stdout.on("data", (chunk) => stdout.push(chunk));
56
+ child.stderr.on("data", (chunk) => stderr.push(chunk));
57
+ child.on("error", (error) => {
58
+ const reason = error.code === "ENOENT" ? `cargo was not found on PATH (${error.message})` : error.message;
59
+ settle(() => reject(new CargoError(reason, true, "")));
60
+ });
61
+ child.on("close", (code, signal) => {
62
+ const errorOutput = Buffer.concat(stderr).toString("utf8");
63
+ if (code === 0) {
64
+ settle(() => resolve(Buffer.concat(stdout).toString("utf8")));
65
+ }
66
+ else {
67
+ const reason = signal
68
+ ? `cargo was stopped by ${signal}`
69
+ : `cargo exited with status ${code}`;
70
+ settle(() => reject(new CargoError(reason, false, errorOutput)));
71
+ }
72
+ });
73
+ });
74
+ }
75
+ //# sourceMappingURL=run-cargo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-cargo.js","sourceRoot":"","sources":["../../../../nx-rust/src/cargo/run-cargo.ts"],"names":[],"mappings":";;;AAmCA,4CAmCC;AAtED,2DAA2C;AAE3C,mEAAmE;AACnE,MAAa,UAAW,SAAQ,KAAK;IACnC,YACE,OAAe;IACf,qFAAqF;IAC5E,UAAmB;IAC5B,0CAA0C;IACjC,MAAc;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,eAAU,GAAV,UAAU,CAAS;QAEnB,WAAM,GAAN,MAAM,CAAQ;QAGvB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAXD,gCAWC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,uCAAuC;AACvC,SAAgB,gBAAgB,CAAC,IAAuB,EAAE,GAAW;IACnE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAE,EAAE;YACpC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;gBACf,MAAM,EAAE,CAAC;YACX,CAAC;QACH,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,IAAA,0BAAK,EAAC,OAAO,EAAE,IAAI,EAAE;YACjC,GAAG;YACH,GAAG,kCAAO,OAAO,CAAC,GAAG,KAAE,mBAAmB,EAAE,GAAG,GAAE;YACjD,KAAK,EAAE,CAAC,QAAQ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AE,CAAC;gBACvC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACnE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The target triples that cargo builds for when a command started in a
3
+ * workspace root names none with `--target` (`DES-OUTPUTS`, "Paths"), from
4
+ * `build.target` in Cargo's configuration and `CARGO_BUILD_TARGET`.
5
+ */
6
+ export type PickedTriples =
7
+ /** Neither picks one: cargo builds for the host, without a triple folder. */
8
+ {
9
+ kind: "none";
10
+ }
11
+ /**
12
+ * The triples whose folders cargo writes to, each once. An empty list
13
+ * comes from `build.target = []`, for which cargo builds nothing.
14
+ */
15
+ | ({
16
+ kind: "triples";
17
+ triples: string[];
18
+ } & TripleSources)
19
+ /** A value whose folder the plugin cannot name, with the reason. */
20
+ | ({
21
+ kind: "unnamed";
22
+ value: string;
23
+ reason: string;
24
+ } & TripleSources);
25
+ /** Where picked triples come from. */
26
+ export interface TripleSources {
27
+ /** The absolute paths of the configuration files whose `build.target` counts. */
28
+ files: string[];
29
+ /** Whether `CARGO_BUILD_TARGET` counts. */
30
+ fromEnv: boolean;
31
+ }
32
+ /**
33
+ * The triples that cargo builds for in `workspaceRoot` without `--target`,
34
+ * as `build.target` in the configuration files that cargo reads there and
35
+ * `CARGO_BUILD_TARGET` in `env` pick them (`DES-OUTPUTS`, `EVD-CARGO-TRIPLE-FOLDERS`):
36
+ *
37
+ * - The files are those of `workspaceRoot`, of each folder above it and of
38
+ * the Cargo home, with the files they include. A string in a deeper
39
+ * folder wins over one above it, a file's own value over the files it
40
+ * includes, and a later include over an earlier one. Lists from several
41
+ * files are joined. A string beside a list is no configuration that
42
+ * cargo loads.
43
+ * - `CARGO_BUILD_TARGET`, also when empty, replaces a string or the absence
44
+ * of a value with one triple, its whole value. Where the configuration
45
+ * holds a list, the variable's words join the list instead.
46
+ * - Cargo 1.91 ignores `include`, later versions apply it. Where the two
47
+ * readings pick different triples, the triples cannot be named.
48
+ * - `host-tuple`, a target specification file, an empty triple and a name
49
+ * that an Nx output cannot hold cannot be named either.
50
+ *
51
+ * Files that do not exist or cannot be parsed are skipped: graph creation
52
+ * reports the latter, and cargo fails on them.
53
+ *
54
+ * @param host The host's triple, where the caller knows it: `host-tuple`
55
+ * then stands for it, as cargo replaces it, and is named.
56
+ */
57
+ export declare function pickedTriples(workspaceRoot: string, env: NodeJS.ProcessEnv, host?: string): PickedTriples;
58
+ /**
59
+ * The triples that Cargo's configuration alone picks in `workspaceRoot`,
60
+ * without `CARGO_BUILD_TARGET` ({@link pickedTriples}): what tells a
61
+ * configuration that changed after graph creation from a variable that only
62
+ * the task's environment sets.
63
+ */
64
+ export declare function configuredTriples(workspaceRoot: string, env: NodeJS.ProcessEnv): PickedTriples;
65
+ /**
66
+ * A pick as text that names its folders and nothing else, so that two
67
+ * checkouts in different folders give the same text: `none`, `triples` with
68
+ * the sorted triples, or `unnamed` with the value and the reason. The
69
+ * runtime input of `build` and `doc` prints it (`DES-INPUTS`), and target
70
+ * metadata records the configuration's pick in it.
71
+ */
72
+ export declare function pickText(picked: PickedTriples): string;
73
+ /** Whether two picks name the same folders. */
74
+ export declare function samePick(a: PickedTriples, b: PickedTriples): boolean;
75
+ /**
76
+ * What picks triples, for messages: `build.target in <files>`,
77
+ * `CARGO_BUILD_TARGET`, or both, with each file relative to `repositoryRoot`
78
+ * where it lies inside it.
79
+ */
80
+ export declare function tripleSource(sources: TripleSources, repositoryRoot: string): string;
81
+ /** What picks a triple whose folder the plugin cannot name, and why, for messages. */
82
+ export declare function unnamedTripleProblem(picked: Extract<PickedTriples, {
83
+ kind: "unnamed";
84
+ }>, repositoryRoot: string): string;
85
+ /** Picked triples, for messages: "the triple a", "the triples a and b", "no triple". */
86
+ export declare function describeTriples(picked: PickedTriples): string;
87
+ /** The folders that outputs name for picked triples, for messages. */
88
+ export declare function describeFolders(picked: PickedTriples): string;
89
+ /**
90
+ * Why cargo writes to another folder for a `targetTriple` option than the
91
+ * one that the outputs name with the option's value (`DES-OUTPUTS`):
92
+ * `host-tuple`, which cargo replaces with the host's triple, and the path
93
+ * of a target specification file, which cargo takes for any value that
94
+ * ends in `.json`; `undefined` for any other value. Cargo fails on the other
95
+ * values that {@link pickedTriples} cannot name, so no artifact is stored
96
+ * for them.
97
+ */
98
+ export declare function optionTripleReason(triple: string): string | undefined;