@convesoft/nx-rust 0.0.0-stage → 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 +48 -2
  4. package/executors.json +35 -0
  5. package/generators.json +19 -0
  6. package/package.json +26 -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,746 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.variablesEnd = exports.crateInputTargets = exports.environmentVariables = exports.defaultInputSettings = exports.crateInputName = void 0;
4
+ exports.namedInputs = namedInputs;
5
+ exports.repositoryDefaultInputs = repositoryDefaultInputs;
6
+ exports.targetInputs = targetInputs;
7
+ exports.wholeWorkspaceKey = wholeWorkspaceKey;
8
+ exports.holdsEveryDigest = holdsEveryDigest;
9
+ exports.memberManifests = memberManifests;
10
+ exports.externalDependencyInputs = externalDependencyInputs;
11
+ exports.lockfileInputs = lockfileInputs;
12
+ exports.environmentInputs = environmentInputs;
13
+ exports.toolchainCommand = toolchainCommand;
14
+ exports.artifactFoldersCommand = artifactFoldersCommand;
15
+ exports.testModeCommand = testModeCommand;
16
+ exports.pluginVersionInput = pluginVersionInput;
17
+ const node_path_1 = require("node:path");
18
+ const configured_tools_1 = require("../cargo/configured-tools");
19
+ const lockfile_task_1 = require("./lockfile-task");
20
+ const napi_1 = require("./napi");
21
+ const script_input_1 = require("./script-input");
22
+ const wasm_1 = require("./wasm");
23
+ /**
24
+ * The name of the crate's own named input: the files that decide what the
25
+ * crate is when another crate builds it, the folders of the crates without a
26
+ * project that it reaches, what the repository adds to its key, and the
27
+ * repository's own `default` apart from its patterns under the project's
28
+ * folder (`DES-INPUTS`). Dependents hash it through `^default`.
29
+ *
30
+ * It is `default` because a `^` input fails the hash of a task when a project
31
+ * that the task's project depends on has no named input of that name
32
+ * (`EVD-NX-24-INPUTS-OUTPUTS`), and a crate can depend on a project of another
33
+ * plugin, such as a JS project. Every project has a `default`: Nx's own,
34
+ * `{projectRoot}/**\/*`, or the one in `nx.json`.
35
+ */
36
+ exports.crateInputName = "default";
37
+ /** The settings of a workspace that sets none of them. */
38
+ exports.defaultInputSettings = {
39
+ featureUnification: "workspace-build",
40
+ testRunner: "cargo",
41
+ added: { envInputs: [], runtimeInputs: [], fileInputs: [] },
42
+ };
43
+ /**
44
+ * The environment variables of `DES-INPUTS` that every cached target hashes,
45
+ * apart from those for a triple and those for some targets only.
46
+ */
47
+ exports.environmentVariables = [
48
+ "RUSTFLAGS",
49
+ "CARGO_ENCODED_RUSTFLAGS",
50
+ "RUSTDOCFLAGS",
51
+ "CARGO_ENCODED_RUSTDOCFLAGS",
52
+ "RUSTC",
53
+ "RUSTC_WRAPPER",
54
+ "RUSTC_WORKSPACE_WRAPPER",
55
+ "RUSTDOC",
56
+ "RUSTC_BOOTSTRAP",
57
+ "CARGO_BUILD_TARGET",
58
+ "CARGO_BUILD_RUSTFLAGS",
59
+ "CARGO_BUILD_RUSTDOCFLAGS",
60
+ "CARGO_BUILD_RUSTC",
61
+ "CARGO_BUILD_RUSTC_WRAPPER",
62
+ "CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER",
63
+ "CARGO_BUILD_RUSTDOC",
64
+ "CC",
65
+ "CXX",
66
+ "AR",
67
+ "CFLAGS",
68
+ "CXXFLAGS",
69
+ "PKG_CONFIG_PATH",
70
+ "MACOSX_DEPLOYMENT_TARGET",
71
+ "OPENSSL_DIR",
72
+ "OPENSSL_LIB_DIR",
73
+ "OPENSSL_INCLUDE_DIR",
74
+ "OPENSSL_STATIC",
75
+ "OPENSSL_NO_VENDOR",
76
+ ];
77
+ /** The targets that compile, which hash `CARGO_BUILD_WARNINGS` (`DES-INPUTS`). */
78
+ const compilingTargets = new Set([
79
+ "build",
80
+ "check",
81
+ "lint",
82
+ "test",
83
+ "bench",
84
+ "run",
85
+ "napi-build",
86
+ "wasm-build",
87
+ "doc",
88
+ ]);
89
+ /**
90
+ * The targets that get the inputs of `DES-INPUTS`: the cached targets of
91
+ * `DES-TARGETS`, and `fmt`, `bench` and `run`, which are not cached but
92
+ * whose inputs make `nx affected` select them.
93
+ */
94
+ exports.crateInputTargets = new Set([
95
+ "build",
96
+ "check",
97
+ "lint",
98
+ "test",
99
+ "fmt-check",
100
+ "fmt",
101
+ "bench",
102
+ "run",
103
+ "napi-build",
104
+ "wasm-build",
105
+ "doc",
106
+ ]);
107
+ /**
108
+ * The files of the toolchain and of Cargo's configuration that apply in a
109
+ * folder and below it. Cargo reads `.cargo/config`, the older name, where it
110
+ * exists, in place of `.cargo/config.toml`.
111
+ */
112
+ const workspaceFileNames = [
113
+ "rust-toolchain.toml",
114
+ "rust-toolchain",
115
+ ".cargo/config.toml",
116
+ ".cargo/config",
117
+ ];
118
+ /** The configuration files of the tool that a target runs, looked up from the crate up to the root. */
119
+ const toolFileNames = {
120
+ lint: ["clippy.toml", ".clippy.toml"],
121
+ "fmt-check": ["rustfmt.toml", ".rustfmt.toml"],
122
+ fmt: ["rustfmt.toml", ".rustfmt.toml"],
123
+ };
124
+ /**
125
+ * The project's named inputs: {@link crateInputName}, which its targets and
126
+ * those of its dependents hash.
127
+ *
128
+ * It holds every file of the project's folder that belongs to no nested
129
+ * project, except the files that `napi-build` writes there
130
+ * ({@link napiOutputFiles}), the package folder that `wasm-build` writes
131
+ * there ({@link wasmPackageFolder}) and the workspace's `Cargo.lock` where the
132
+ * folder is the workspace root, which reaches the keys of the crate and of those that
133
+ * depend on it only through the digests of the lockfile task
134
+ * ({@link externalDependencyInputs}); the root manifest of the crate's
135
+ * workspace, whose fields the crate can inherit, also when another
136
+ * workspace builds it (`EVD-CARGO-DEPENDENCY-SIDE`); the folder and
137
+ * workspace manifest of every crate without a project that the crate
138
+ * reaches, with what each of them declares and adds; what the repository
139
+ * adds; and the repository's own `default` without its patterns under the
140
+ * project's folder. A variable or command that a crate without a project
141
+ * adds appears once, and not where the crate's own additions or the
142
+ * repository's `default` hold it ({@link withoutRepeatedAdditions}). A
143
+ * pattern that the repository negates in a target's own `inputs` takes
144
+ * files out of it, on the repository's responsibility.
145
+ */
146
+ // @mara implements DES-INPUTS
147
+ // @mara implements REQ-INPUT-FILES
148
+ function namedInputs(subject, context, settings = exports.defaultInputSettings) {
149
+ var _a;
150
+ const crateFiles = ["{projectRoot}/**/*"];
151
+ if (subject.isWorkspaceProject) {
152
+ crateFiles.push("!{projectRoot}/Cargo.lock");
153
+ }
154
+ // The files that `napi-build` and `wasm-build` write into the crate's
155
+ // folder are their outputs and no input (`DES-ARTIFACT-STEPS`).
156
+ if ((0, napi_1.producesNodeAddon)(subject)) {
157
+ crateFiles.push(...(0, napi_1.napiOutputFiles)((0, napi_1.napiAddon)(subject, context)).map((file) => `!{projectRoot}/${file}`));
158
+ }
159
+ if ((0, wasm_1.producesWasmPackage)(subject)) {
160
+ crateFiles.push(`!{projectRoot}/${wasm_1.wasmPackageFolder}/**/*`);
161
+ }
162
+ const workspaceRoot = workspaceFolder(subject, context);
163
+ if (workspaceRoot !== subject.root) {
164
+ crateFiles.push(fromRoot(workspaceRoot, "Cargo.toml"));
165
+ }
166
+ const pathDependencies = subject.pkg
167
+ ? ((_a = context.pathDependencyInputs.get(subject.pkg.manifest_path)) !== null && _a !== void 0 ? _a : [])
168
+ : [];
169
+ const own = [
170
+ ...settings.added.fileInputs,
171
+ ...settings.added.envInputs.map((env) => ({ env })),
172
+ ...settings.added.runtimeInputs.map((runtime) => ({ runtime })),
173
+ ...context.repositoryDefault,
174
+ ];
175
+ return {
176
+ [exports.crateInputName]: [...crateFiles, ...withoutRepeatedAdditions(pathDependencies, own), ...own],
177
+ };
178
+ }
179
+ /**
180
+ * `inputs` without the `env` and `runtime` entries whose variable or
181
+ * command `elsewhere` holds already, so that a variable or command that
182
+ * several crates add, or that the crate adds itself, is declared once
183
+ * (`DES-INPUTS`, "Added variables and commands"). Other entries stay.
184
+ */
185
+ function withoutRepeatedAdditions(inputs, elsewhere) {
186
+ const held = new Set(elsewhere.map(additionKey).filter((key) => key !== undefined));
187
+ return inputs.filter((input) => {
188
+ const key = additionKey(input);
189
+ return key === undefined || !held.has(key);
190
+ });
191
+ }
192
+ // What an `env` or `runtime` entry names, as one string; `undefined` for
193
+ // any other input.
194
+ function additionKey(input) {
195
+ if (typeof input !== "object" || input === null) {
196
+ return undefined;
197
+ }
198
+ if ("env" in input && typeof input.env === "string") {
199
+ return `env:${input.env}`;
200
+ }
201
+ if ("runtime" in input && typeof input.runtime === "string") {
202
+ return `runtime:${input.runtime}`;
203
+ }
204
+ return undefined;
205
+ }
206
+ /**
207
+ * The entries of the repository's `default` named input, from `nx.json`,
208
+ * that a crate's own `default` keeps: every entry but a file set under
209
+ * `{projectRoot}`, negated or not, and a reference to `default` itself.
210
+ * Named inputs such as `sharedGlobals`, `env`, `runtime` and
211
+ * `externalDependencies` entries and file sets under `{workspaceRoot}` thus
212
+ * still reach a crate's key, while what the crate hashes of its own folder
213
+ * is the plugin's to say (`DES-INPUTS`). Nx's own `default`, where `nx.json`
214
+ * has none, holds nothing else.
215
+ */
216
+ // @mara implements DES-INPUTS
217
+ function repositoryDefaultInputs(namedInputs) {
218
+ const entries = namedInputs === null || namedInputs === void 0 ? void 0 : namedInputs[exports.crateInputName];
219
+ if (!Array.isArray(entries)) {
220
+ return [];
221
+ }
222
+ return entries.filter((entry) => {
223
+ if (typeof entry === "string") {
224
+ return entry !== exports.crateInputName && !/^!?\{projectRoot\}/.test(entry);
225
+ }
226
+ if (typeof entry !== "object" || entry === null) {
227
+ return false;
228
+ }
229
+ const fileset = entry.fileset;
230
+ return typeof fileset !== "string" || !/^!?\{projectRoot\}/.test(fileset);
231
+ });
232
+ }
233
+ /**
234
+ * The inputs of one of the project's targets, in the order of the table in
235
+ * `DES-INPUTS`: the crate's files and those of its dependencies, the
236
+ * workspace files, the redirected crates that the crate may use without an
237
+ * edge, the members' manifests, the path crates outside the workspace that
238
+ * any member reaches, the tool's configuration, the external dependencies,
239
+ * the environment, the toolchain with Cargo's profile and target
240
+ * variables, and the plugin. A variable or command that a redirected crate
241
+ * without an edge or a crate outside the workspace adds appears once, and
242
+ * not where the crate's named input or another entry of the target holds
243
+ * it.
244
+ *
245
+ * Under the `cargo` and `workspace-build` strategies, a target that reads
246
+ * digests holds what a build of the whole workspace compiles the crate
247
+ * with: the digests of every member ({@link holdsEveryDigest}) and the
248
+ * crates outside the workspace that any member reaches
249
+ * ({@link InputContext.outsideCrateInputs}), beside every member's manifest
250
+ * (`DES-INPUTS`, "Whole-workspace builds").
251
+ *
252
+ * @param readsDigest Whether the target depends on the workspace's lockfile
253
+ * task and hashes digests of it: a cached target other than `fmt-check`
254
+ * (`DES-LOCKFILE-HASHING`).
255
+ * @returns `undefined` for a target that `DES-INPUTS` gives no such inputs:
256
+ * `lockfile`, `audit`, `deny` and `update` keep theirs from
257
+ * `DES-WORKSPACE-TARGETS`.
258
+ */
259
+ // @mara implements DES-INPUTS
260
+ // @mara implements REQ-INPUT-FILES
261
+ // @mara implements REQ-ENV-ALLOWLIST
262
+ // @mara implements REQ-TOOLCHAIN-KEY
263
+ function targetInputs(target, subject, context, settings = exports.defaultInputSettings, readsDigest = false) {
264
+ var _a, _b, _c, _d;
265
+ if (!exports.crateInputTargets.has(target)) {
266
+ return undefined;
267
+ }
268
+ const workspaceRoot = workspaceFolder(subject, context);
269
+ const redirected = subject.pkg === undefined
270
+ ? []
271
+ : ((_a = context.redirectedInputs.get(subject.pkg.manifest_path)) !== null && _a !== void 0 ? _a : []);
272
+ const named = namedInputs(subject, context, settings)[exports.crateInputName];
273
+ const outside = readsDigest && settings.featureUnification !== "hakari"
274
+ ? withoutHeldInputs((_c = (_b = context.outsideCrateInputs) === null || _b === void 0 ? void 0 : _b.get(wholeWorkspaceKey(subject))) !== null && _c !== void 0 ? _c : [], [
275
+ ...named,
276
+ ...redirected,
277
+ ])
278
+ : [];
279
+ const after = [
280
+ ...(settings.featureUnification === "hakari"
281
+ ? hackCrateInputs(settings, readsDigest)
282
+ : memberManifestInputs(subject, context)),
283
+ ...outside,
284
+ ...toolConfigurationInputs(target, subject, workspaceRoot, settings),
285
+ ...(target === "fmt" || target === "fmt-check"
286
+ ? []
287
+ : externalDependencyInputs(target, subject, workspaceRoot, readsDigest, settings)),
288
+ ...environmentInputs(target),
289
+ {
290
+ runtime: toolchainCommand(workspaceRoot, (_d = subject.workspace.configuredTools) !== null && _d !== void 0 ? _d : configured_tools_1.noConfiguredTools, rustdocTargets.has(target), target === "test" && settings.testRunner === "nextest"),
291
+ },
292
+ ...(target === "test" && settings.affectedTests === true
293
+ ? [{ runtime: testModeCommand(workspaceRoot) }]
294
+ : []),
295
+ pluginVersionInput(context.plugin),
296
+ ];
297
+ return [
298
+ exports.crateInputName,
299
+ `^${exports.crateInputName}`,
300
+ ...workspaceFiles(subject, context.repositoryRoot),
301
+ ...withoutRepeatedAdditions(redirected, [...named, ...after]),
302
+ ...after,
303
+ ];
304
+ }
305
+ /**
306
+ * The inputs that stand in for the other members' manifests under `hakari`
307
+ * (`DES-INPUTS`, "Hack crate"), on every target that reads a digest: the
308
+ * hack crate's manifest and the configuration file of cargo-hakari, as file
309
+ * inputs from the repository root. A member reaches the hack crate's folder
310
+ * through its edge already; the manifest is named directly as well, so that
311
+ * it is in the key of a member whose dependency on the hack crate is
312
+ * missing, until the drift check reports that.
313
+ */
314
+ // @mara implements DES-INPUTS
315
+ function hackCrateInputs(settings, readsDigest) {
316
+ if (!readsDigest || settings.hakari === undefined) {
317
+ return [];
318
+ }
319
+ return [
320
+ `{workspaceRoot}/${settings.hakari.hackManifest}`,
321
+ `{workspaceRoot}/${settings.hakari.configFile}`,
322
+ ];
323
+ }
324
+ /**
325
+ * The key under which {@link InputContext.outsideCrateInputs} holds a
326
+ * project's inputs: the manifest of its crate, or for a workspace project
327
+ * without one, the root manifest of its workspace, whose `doc` builds every
328
+ * member.
329
+ */
330
+ function wholeWorkspaceKey(subject) {
331
+ var _a, _b;
332
+ return (_b = (_a = subject.pkg) === null || _a === void 0 ? void 0 : _a.manifest_path) !== null && _b !== void 0 ? _b : (0, node_path_1.join)(subject.workspace.report.workspace_root, "Cargo.toml");
333
+ }
334
+ /**
335
+ * Whether a target that depends on the lockfile task holds the digests of
336
+ * every member of its workspace rather than its crate's own
337
+ * (`DES-LOCKFILE-HASHING`, "Crate targets"): `doc`, which builds every
338
+ * member, a workspace project without a crate, and every such target under
339
+ * the `cargo` and `workspace-build` strategies, which build each crate with
340
+ * the features of the whole workspace (`DES-INPUTS`, "External
341
+ * dependencies"). Under `hakari`, the others hold their crate's own.
342
+ */
343
+ // @mara implements DES-LOCKFILE-HASHING
344
+ function holdsEveryDigest(target, subject, settings) {
345
+ return target === "doc" || subject.pkg === undefined || settings.featureUnification !== "hakari";
346
+ }
347
+ /**
348
+ * `inputs` without those that `held` holds already: an entry equal to one
349
+ * of `held`, and an `env` or `runtime` entry whose variable or command
350
+ * `held` names, so that what the crate's own inputs hold, through its path
351
+ * dependencies or a redirection, is not named again.
352
+ */
353
+ function withoutHeldInputs(inputs, held) {
354
+ const entries = new Set(held.map((input) => JSON.stringify(input)));
355
+ return withoutRepeatedAdditions(inputs, held).filter((input) => !entries.has(JSON.stringify(input)));
356
+ }
357
+ /** The targets whose cargo command runs rustdoc: `doc`, and `test` for doctests. */
358
+ const rustdocTargets = new Set(["doc", "test"]);
359
+ /**
360
+ * The files of the context that cargo runs in: each `rust-toolchain.toml`,
361
+ * `rust-toolchain`, `.cargo/config.toml` and `.cargo/config` in the folders
362
+ * above the project's, up to the repository root. Those in the project's own
363
+ * folder are among its files, and the workspace's root manifest is in its
364
+ * named input. The files that a configuration's `include` adds count too.
365
+ * Each is named by its path, whether or not it exists, so that
366
+ * adding one changes the key. They stay out of the named input: cargo takes
367
+ * them from the folder it starts in, not from a dependency's
368
+ * (`EVD-CARGO-DEPENDENCY-SIDE`).
369
+ *
370
+ * @param own Whether the files in the project's own folder count too.
371
+ */
372
+ function workspaceFiles(subject, repositoryRoot, own = false) {
373
+ var _a;
374
+ const files = [];
375
+ // The files that a configuration's `include` adds, inside the repository.
376
+ for (const included of (_a = subject.workspace.configIncludes) !== null && _a !== void 0 ? _a : []) {
377
+ const path = repositoryPath(repositoryRoot, included);
378
+ if (path !== undefined && path !== "") {
379
+ files.push(`{workspaceRoot}/${path}`);
380
+ }
381
+ }
382
+ for (const folder of [...(own ? [subject.root] : []), ...foldersAbove(subject.root)]) {
383
+ files.push(...workspaceFileNames.map((name) => fromRoot(folder, name)));
384
+ }
385
+ return files;
386
+ }
387
+ /**
388
+ * The manifests of the workspace's other members inside the repository,
389
+ * which the `cargo` and `workspace-build` strategies make inputs of every
390
+ * member (`DES-INPUTS`, "Member manifests").
391
+ */
392
+ function memberManifestInputs(subject, context) {
393
+ var _a;
394
+ const own = (_a = subject.pkg) === null || _a === void 0 ? void 0 : _a.manifest_path;
395
+ return memberManifests(subject.workspace, context.repositoryRoot, own);
396
+ }
397
+ /**
398
+ * The manifests of the workspace's members as `{workspaceRoot}` paths, those
399
+ * inside the repository only, because Nx hashes no file outside it; sorted,
400
+ * and without `except`.
401
+ */
402
+ function memberManifests(workspace, repositoryRoot, except) {
403
+ const members = new Set(workspace.report.workspace_members);
404
+ return workspace.report.packages
405
+ .filter((pkg) => members.has(pkg.id) && pkg.manifest_path !== except)
406
+ .map((pkg) => repositoryPath(repositoryRoot, pkg.manifest_path))
407
+ .filter((path) => path !== undefined && path !== "")
408
+ .sort()
409
+ .map((path) => `{workspaceRoot}/${path}`);
410
+ }
411
+ /**
412
+ * The configuration of the tool the target runs: clippy's for `lint`,
413
+ * rustfmt's for `fmt-check` and `fmt`, in each folder above the crate's, and
414
+ * the workspace's `.config/nextest.toml` for a `test` that nextest runs.
415
+ */
416
+ function toolConfigurationInputs(target, subject, workspaceRoot, settings) {
417
+ var _a;
418
+ if (target === "test") {
419
+ return settings.testRunner === "nextest" && workspaceRoot !== subject.root
420
+ ? [fromRoot(workspaceRoot, ".config/nextest.toml")]
421
+ : [];
422
+ }
423
+ const names = (_a = toolFileNames[target]) !== null && _a !== void 0 ? _a : [];
424
+ return foldersAbove(subject.root).flatMap((folder) => names.map((name) => fromRoot(folder, name)));
425
+ }
426
+ /**
427
+ * The external dependencies of the crate (`DES-INPUTS`, "External
428
+ * dependencies"). A target that depends on the workspace's lockfile task
429
+ * hashes digests among that task's outputs: those of every member where
430
+ * {@link holdsEveryDigest} says so, otherwise the crate's own, through a
431
+ * `dependentTasksOutputFiles` input, with an `env` input for
432
+ * `NX_RUST_RUN_ID`, which a run that excludes task dependencies sets to a
433
+ * new value (`DES-LOCKFILE-HASHING`). It has no
434
+ * `Cargo.lock` as a file input: Nx hashes such an input before the run
435
+ * starts, before the lockfile task can update the file
436
+ * (`EVD-NX-24-LOCKFILE-UPDATE`).
437
+ *
438
+ * A target that is not cached, `bench` and `run`, or `build` and `doc`
439
+ * where the plugin leaves them uncached, does not depend on the lockfile
440
+ * task. Its inputs only decide what `nx affected` selects, so it names the
441
+ * workspace's `Cargo.lock`, read also where Git ignores it, as `audit` and
442
+ * `update` do (`DES-INPUTS`, "Uncached targets").
443
+ *
444
+ * `fmt` and `fmt-check` have neither: `cargo fmt` reads no lockfile.
445
+ */
446
+ // @mara implements DES-LOCKFILE-HASHING
447
+ // @mara implements REQ-EXTERNAL-DEPS
448
+ function externalDependencyInputs(target, subject, workspaceRoot, readsDigest, settings = exports.defaultInputSettings) {
449
+ if (!readsDigest) {
450
+ return [{ fileset: fromRoot(workspaceRoot, "Cargo.lock"), includeIgnored: true }];
451
+ }
452
+ const digests = subject.pkg === undefined || holdsEveryDigest(target, subject, settings)
453
+ ? `${(0, lockfile_task_1.digestFolder)(workspaceRoot)}/*.digest`
454
+ : (0, lockfile_task_1.digestFile)(workspaceRoot, subject.pkg.name);
455
+ return [{ dependentTasksOutputFiles: digests }, { env: lockfile_task_1.runIdVariable }];
456
+ }
457
+ /**
458
+ * The inputs of the lockfile task (`DES-WORKSPACE-TARGETS`), which only
459
+ * decide what `nx affected` selects, since the task is not cached: the
460
+ * workspace's `Cargo.lock`, read also where Git ignores it, its root
461
+ * manifest, the manifests of its members and of the path packages they
462
+ * reach inside the repository, the workspace files that apply in the
463
+ * workspace root, where the task's cargo runs, and the plugin's input
464
+ * ({@link pluginVersionInput}). The files are named from the repository
465
+ * root, because a pattern under the workspace project's root misses the
466
+ * files of the crate projects nested in it (`EVD-NX-24-LOCKFILE-UPDATE`).
467
+ */
468
+ // @mara implements DES-WORKSPACE-TARGETS
469
+ // @mara implements DES-LOCKFILE-HASHING
470
+ function lockfileInputs(subject, context) {
471
+ var _a, _b;
472
+ const workspaceRoot = workspaceFolder(subject, context);
473
+ const manifests = new Set([
474
+ ...memberManifests(subject.workspace, context.repositoryRoot),
475
+ ...((_b = (_a = context.pathPackageManifests) === null || _a === void 0 ? void 0 : _a.get(workspaceRoot)) !== null && _b !== void 0 ? _b : []),
476
+ ]);
477
+ manifests.delete(fromRoot(workspaceRoot, "Cargo.toml"));
478
+ return [
479
+ { fileset: fromRoot(workspaceRoot, "Cargo.lock"), includeIgnored: true },
480
+ fromRoot(workspaceRoot, "Cargo.toml"),
481
+ ...[...manifests].sort(),
482
+ ...workspaceFiles(Object.assign(Object.assign({}, subject), { root: workspaceRoot }), context.repositoryRoot, true),
483
+ pluginVersionInput(context.plugin),
484
+ ];
485
+ }
486
+ /**
487
+ * One `env` input per variable of `DES-INPUTS` that applies to the target:
488
+ * the fixed list, `CARGO_BUILD_WARNINGS` on the targets that compile, and
489
+ * `CLIPPY_CONF_DIR` on `lint`. The variables whose names start with
490
+ * `CARGO_PROFILE_` or `CARGO_TARGET_` are in the toolchain command instead
491
+ * ({@link toolchainCommand}).
492
+ */
493
+ function environmentInputs(target) {
494
+ const names = [...exports.environmentVariables];
495
+ if (compilingTargets.has(target)) {
496
+ names.push("CARGO_BUILD_WARNINGS");
497
+ }
498
+ if (target === "lint") {
499
+ names.push("CLIPPY_CONF_DIR");
500
+ }
501
+ return names.map((env) => ({ env }));
502
+ }
503
+ /**
504
+ * The command of the toolchain input, one shell per task's key (`DES-INPUTS`,
505
+ * `REQ-TOOLCHAIN-KEY`). In the workspace root, where the plugin's cargo
506
+ * commands run, it prints:
507
+ *
508
+ * - what `rustc -Vv` writes, as rustup or `PATH` resolve it there with the
509
+ * task's environment: the toolchain of the task's cargo, and the compiler
510
+ * that cargo runs where no setting names another;
511
+ * - where a setting names another compiler, what that compiler's `-Vv`
512
+ * writes: the one that `RUSTC` in the task's environment names, else
513
+ * `CARGO_BUILD_RUSTC`, else `build.rustc` of Cargo's configuration as
514
+ * graph creation read it, which may name two (`configuredTools`);
515
+ * - with `rustdoc`, for the targets that run it, the same for the rustdoc
516
+ * that `RUSTDOC`, `CARGO_BUILD_RUSTDOC` or `build.rustdoc` names;
517
+ * - every variable of the task's environment whose name starts with
518
+ * `CARGO_PROFILE_` or `CARGO_TARGET_`, with its value, sorted, apart from
519
+ * `CARGO_TARGET_DIR`, which says where the artifacts go and not what they
520
+ * are (`REQ-ENV-ALLOWLIST`). Those two families are open ended, with a
521
+ * profile's or a triple's name in each variable, so no list of `env`
522
+ * inputs can name them;
523
+ * - on a `test` that nextest runs, what `cargo nextest --version` writes in
524
+ * the workspace root, as cargo finds nextest there with the task's
525
+ * environment, or `cargo-nextest: not found` where it fails, so that
526
+ * another version of nextest, or none, changes the key, and every
527
+ * variable whose name starts with `NEXTEST_`, with its value, sorted in
528
+ * with the others: they choose nextest's profile or change what its run
529
+ * does, and no list names them all either.
530
+ *
531
+ * A named program runs as cargo runs it: a path with a `/` from the
532
+ * workspace root, which is also cargo's folder, and a bare name through
533
+ * `PATH`. Where nothing names a compiler or a rustdoc, the command prints
534
+ * what it printed before these settings counted, so those keys stay the
535
+ * same: Nx keys a runtime input on what it prints, not on its text
536
+ * (`EVD-CARGO-COMPILER-SELECTION`). Nx runs the command through `sh -c` in
537
+ * the repository root, with the task's dotenv files loaded
538
+ * (`EVD-NX-24-INPUT-SEMANTICS`).
539
+ *
540
+ * rustup may not install a toolchain for it (`ADR-GRAPH-NO-TOOLCHAIN-INSTALL`).
541
+ * When a version query fails, as for a pinned toolchain that is not
542
+ * installed, for a named compiler that does not exist or for an empty
543
+ * `RUSTC`, on which cargo fails too, or when the folder is missing, the
544
+ * command prints a random value in its place, new at each evaluation, so
545
+ * that no result stored under the key is ever restored and the task runs
546
+ * as plain cargo would (`EVD-RUSTUP-MISSING-TOOLCHAIN`). The command always
547
+ * ends with status 0; Nx keys a task on what a runtime input prints
548
+ * whatever its status.
549
+ *
550
+ * @param workspaceRoot The workspace's root folder, relative to the repository root.
551
+ * @param tools What `build.rustc` and `build.rustdoc` name in the workspace root.
552
+ * @param rustdoc Whether the target's cargo command runs rustdoc.
553
+ * @param nextest Whether nextest runs the target's tests; without it the
554
+ * command is the one it has always been, so that no other key changes.
555
+ */
556
+ // @mara implements REQ-TOOLCHAIN-KEY
557
+ // @mara implements REQ-ENV-ALLOWLIST
558
+ function toolchainCommand(workspaceRoot, tools = configured_tools_1.noConfiguredTools, rustdoc = false, nextest = false) {
559
+ const folder = workspaceRoot === "." ? "." : `./${workspaceRoot}`;
560
+ const versions = [
561
+ versionCommand("rustc"),
562
+ namedToolVersion("RUSTC", tools.rustc),
563
+ ...(rustdoc ? [namedToolVersion("RUSTDOC", tools.rustdoc)] : []),
564
+ ];
565
+ return [
566
+ // In a subshell before the toolchain's versions, whose `cd` stays in
567
+ // effect for the rest of the command.
568
+ ...(nextest
569
+ ? [
570
+ `( cd ${shellQuote(folder)} && ${versionCommand("cargo nextest", "--version")} ) || echo 'cargo-nextest: not found'`,
571
+ ]
572
+ : []),
573
+ `{ cd ${shellQuote(folder)} && ${versions.join(" && ")} || ${script_input_1.unrepeatableValue}; }`,
574
+ variablesCommand(nextest ? "^(CARGO_(PROFILE|TARGET)_|NEXTEST_)" : "^CARGO_(PROFILE|TARGET)_"),
575
+ "true",
576
+ ].join("; ");
577
+ }
578
+ /**
579
+ * Shell text that prints each variable of the environment whose name
580
+ * matches the extended regular expression `pattern`, apart from
581
+ * `CARGO_TARGET_DIR`, as one line `NAME=value`, sorted bytewise
582
+ * (`DES-INPUTS`, "Variables"). It reads the variables with POSIX awk's
583
+ * `ENVIRON`, so that a value holds whatever it holds: a line of `env`'s
584
+ * output cannot tell the continuation of a multi-line value from another
585
+ * variable, which let the end of such a value leave the key and a variable
586
+ * of another name enter it. In a name or value that holds a backslash or a
587
+ * line break, a backslash becomes `\\` and a line break `\n`, so that each
588
+ * variable keeps one line and two environments never print the same text;
589
+ * any other line is what `env` printed, so that those keys stay the same.
590
+ * After the last variable it prints the line {@link variablesEnd}, since
591
+ * Nx trims the whitespace at the end of what a runtime input prints, which
592
+ * would otherwise take a trailing space off the last value
593
+ * (`EVD-RUNTIME-INPUT-SCRIPTS`). Where awk fails, the text prints a value
594
+ * that no other evaluation prints ({@link unrepeatableValue}), as the
595
+ * toolchain's versions do.
596
+ */
597
+ /** The line after the variables of the toolchain command ({@link variablesCommand}). */
598
+ exports.variablesEnd = "end of variables";
599
+ function variablesCommand(pattern) {
600
+ const program = [
601
+ "function escaped(text, out, i, c) {",
602
+ 'out = ""; for (i = 1; i <= length(text); i++) { c = substr(text, i, 1);',
603
+ 'if (c == "\\\\") out = out "\\\\\\\\"; else if (c == "\\n") out = out "\\\\n"; else out = out c }',
604
+ "return out }",
605
+ "BEGIN { n = 0; for (name in ENVIRON) {",
606
+ `if (name !~ /${pattern}/ || name == "CARGO_TARGET_DIR") continue;`,
607
+ 'line = name "=" ENVIRON[name];',
608
+ 'if (index(line, "\\\\") || index(line, "\\n")) line = escaped(line);',
609
+ "for (i = n++; i > 0 && lines[i - 1] > line; i--) lines[i] = lines[i - 1];",
610
+ "lines[i] = line }",
611
+ `for (i = 0; i < n; i++) print lines[i]; print "${exports.variablesEnd}" }`,
612
+ ].join(" ");
613
+ return `{ LC_ALL=C awk '${program}' || ${script_input_1.unrepeatableValue}; }`;
614
+ }
615
+ /**
616
+ * Shell text that prints the `-Vv` of the program that `variable`, else
617
+ * `CARGO_BUILD_<variable>`, else Cargo's configuration names, and nothing
618
+ * where none names one. A variable that is set but empty counts as it is,
619
+ * so the query fails, as cargo does.
620
+ */
621
+ function namedToolVersion(variable, configured) {
622
+ const setting = `CARGO_BUILD_${variable}`;
623
+ const fromEnvironment = versionCommand(`"\${${variable}-$${setting}}"`);
624
+ const fromConfiguration = configured
625
+ .map((program) => versionCommand(shellQuote(program)))
626
+ .join(" && ");
627
+ return [
628
+ `if [ -n "\${${variable}+x}\${${setting}+x}" ]; then ${fromEnvironment};`,
629
+ ...(fromConfiguration === "" ? [] : [`else ${fromConfiguration};`]),
630
+ "fi",
631
+ ].join(" ");
632
+ }
633
+ /**
634
+ * The version of a program, given as shell text, `-Vv` unless `flag` names
635
+ * another, without rustup installing a toolchain for it.
636
+ */
637
+ function versionCommand(program, flag = "-Vv") {
638
+ return `RUSTUP_AUTO_INSTALL=0 ${program} ${flag} 2>/dev/null`;
639
+ }
640
+ /**
641
+ * The plugin's script that prints the triples that cargo builds for and its
642
+ * artifact directory (`print-artifact-folders.ts`), compiled beside this
643
+ * module.
644
+ */
645
+ const artifactFoldersScript = (0, node_path_1.join)(__dirname, "..", "cargo", "print-artifact-folders.js");
646
+ /**
647
+ * The command of the artifact input of a cached `build` and `doc`, one per
648
+ * workspace (`DES-INPUTS`, `DES-OUTPUTS`): the plugin's own script prints
649
+ * the triples that cargo will build for in the workspace root without
650
+ * `--target`, read with the function that graph creation uses, and the
651
+ * artifact directory that cargo reports there, as the outputs name it,
652
+ * both with the task's environment. The key thereby follows the folders
653
+ * that the task's cargo will write to, also where the graph that the Nx
654
+ * daemon keeps is older than a change to a configuration file that Nx does
655
+ * not watch, such as the Cargo home's, and where a dotenv file that Nx loads
656
+ * only for the task moves the artifact directory; the outputs still name
657
+ * the graph's folders, and the executor then fails the task before cargo
658
+ * runs (`taskInvocation` in `task.ts`).
659
+ *
660
+ * The command names Node, the script and the workspace root, relative to
661
+ * the repository root where Nx runs it, by paths that reach no key: Nx keys
662
+ * a task on what a runtime input prints and not on its command, and the
663
+ * script prints no path of the checkout, so checkouts in other folders
664
+ * share the keys (`EVD-CARGO-TRIPLE-FOLDERS`). Where the script cannot run,
665
+ * as for a plugin that Nx loads from its TypeScript source, or cargo fails,
666
+ * as for a pinned toolchain that is not installed, the command prints a
667
+ * line that says so and a random value, new at each evaluation, so that no
668
+ * result stored under the key is ever restored ({@link scriptInputCommand}),
669
+ * and the executor says why when the task runs. It always ends with status
670
+ * 0, like {@link toolchainCommand}.
671
+ *
672
+ * @param workspaceRoot The workspace's root folder, relative to the repository root.
673
+ */
674
+ // @mara implements DES-INPUTS
675
+ function artifactFoldersCommand(workspaceRoot, script = artifactFoldersScript) {
676
+ return (0, script_input_1.scriptInputCommand)(script, workspaceRoot);
677
+ }
678
+ /**
679
+ * The plugin's script that prints the test mode (`print-test-mode.ts`),
680
+ * compiled beside the executors.
681
+ */
682
+ const testModeScript = (0, node_path_1.join)(__dirname, "..", "executors", "print-test-mode.js");
683
+ /**
684
+ * The command of the test mode input of a `test` in a workspace that uses
685
+ * selection (`DES-TEST-MODE`, `REQ-TEST-MODE-KEY`): the plugin's own script
686
+ * prints `full`, `affected:<baseline commits>`, or a line that names an
687
+ * invalid `NX_RUST_TEST_MODE`, from the task's environment and
688
+ * cargo-affected's database in the workspace root, read without writing to
689
+ * it and without starting cargo-affected. Nx runs it in the repository
690
+ * root with the task's environment, afresh for every task of every run
691
+ * (`EVD-NX-24-INPUT-SEMANTICS`), and the test executor decides the mode by
692
+ * the same rule. Like {@link artifactFoldersCommand}, it names Node, the
693
+ * script and the workspace root by paths that reach no key, and where the
694
+ * script cannot run, as for a plugin that Nx loads from its TypeScript
695
+ * source, it prints a line that says so and a random value, new at each
696
+ * evaluation, so that no stored result is restored
697
+ * ({@link scriptInputCommand}). It always ends with status 0.
698
+ *
699
+ * @param workspaceRoot The workspace's root folder, relative to the repository root.
700
+ */
701
+ // @mara implements DES-TEST-MODE
702
+ // @mara implements REQ-TEST-MODE-KEY
703
+ function testModeCommand(workspaceRoot, script = testModeScript) {
704
+ return (0, script_input_1.scriptInputCommand)(script, workspaceRoot);
705
+ }
706
+ /**
707
+ * The input that carries the plugin's own version into the key
708
+ * (`DES-INPUTS`, "Plugin"): the plugin's package, where Nx has an npm node
709
+ * for it, and no external node otherwise. Every inferred target has it. On
710
+ * an uncached target it only decides what `nx affected` selects: an upgrade
711
+ * of the plugin selects the target, and a change to the JS lockfile outside
712
+ * the plugin's package does not, as it would without an
713
+ * `externalDependencies` input (`EVD-NX-24-EXTERNAL-NODES`).
714
+ */
715
+ function pluginVersionInput(plugin) {
716
+ return { externalDependencies: plugin.kind === "node" ? [plugin.packageName] : [] };
717
+ }
718
+ /** The workspace's root folder relative to the repository root, `.` for the root itself. */
719
+ function workspaceFolder(subject, context) {
720
+ return repositoryPath(context.repositoryRoot, subject.workspace.report.workspace_root) || ".";
721
+ }
722
+ /** The folders above `folder`, from its parent up to the repository root `.`; none for the root. */
723
+ function foldersAbove(folder) {
724
+ const folders = [];
725
+ let current = folder;
726
+ while (current !== ".") {
727
+ current = node_path_1.posix.dirname(current);
728
+ folders.push(current);
729
+ }
730
+ return folders;
731
+ }
732
+ /** `{workspaceRoot}/<folder>/<file>`, without a `.` segment. */
733
+ function fromRoot(folder, file) {
734
+ return folder === "." ? `{workspaceRoot}/${file}` : `{workspaceRoot}/${folder}/${file}`;
735
+ }
736
+ /** The path relative to the repository root, or `undefined` outside it. */
737
+ function repositoryPath(repositoryRoot, path) {
738
+ const inside = (0, node_path_1.relative)(repositoryRoot, path);
739
+ return inside === ".." || inside.startsWith("../") || node_path_1.posix.isAbsolute(inside)
740
+ ? undefined
741
+ : inside;
742
+ }
743
+ function shellQuote(value) {
744
+ return `'${value.split("'").join(`'"'"'`)}'`;
745
+ }
746
+ //# sourceMappingURL=inputs.js.map