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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/LICENSE-APACHE +201 -0
  2. package/LICENSE-MIT +21 -0
  3. package/PLUGIN.md +106 -0
  4. package/README.md +51 -1
  5. package/docs/artifacts.mara.md +374 -0
  6. package/docs/caching.mara.md +999 -0
  7. package/docs/ci.mara.md +308 -0
  8. package/docs/configuration.mara.md +508 -0
  9. package/docs/decisions.mara.md +3267 -0
  10. package/docs/execution.mara.md +533 -0
  11. package/docs/index.mara.md +51 -0
  12. package/docs/product.mara.md +366 -0
  13. package/docs/release.mara.md +493 -0
  14. package/docs/setup.mara.md +486 -0
  15. package/docs/targets.mara.md +704 -0
  16. package/docs/testing.mara.md +431 -0
  17. package/docs/verification.mara.md +465 -0
  18. package/docs/workspaces.mara.md +445 -0
  19. package/executors.json +35 -0
  20. package/generators.json +19 -0
  21. package/package.json +17 -4
  22. package/src/cargo/build-settings.d.ts +61 -0
  23. package/src/cargo/build-settings.js +103 -0
  24. package/src/cargo/build-settings.js.map +1 -0
  25. package/src/cargo/configured-runner.d.ts +36 -0
  26. package/src/cargo/configured-runner.js +99 -0
  27. package/src/cargo/configured-runner.js.map +1 -0
  28. package/src/cargo/configured-tools.d.ts +35 -0
  29. package/src/cargo/configured-tools.js +46 -0
  30. package/src/cargo/configured-tools.js.map +1 -0
  31. package/src/cargo/dep-info-basedir.d.ts +18 -0
  32. package/src/cargo/dep-info-basedir.js +38 -0
  33. package/src/cargo/dep-info-basedir.js.map +1 -0
  34. package/src/cargo/directories.d.ts +40 -0
  35. package/src/cargo/directories.js +89 -0
  36. package/src/cargo/directories.js.map +1 -0
  37. package/src/cargo/host-triple.d.ts +7 -0
  38. package/src/cargo/host-triple.js +21 -0
  39. package/src/cargo/host-triple.js.map +1 -0
  40. package/src/cargo/lockfile.d.ts +63 -0
  41. package/src/cargo/lockfile.js +157 -0
  42. package/src/cargo/lockfile.js.map +1 -0
  43. package/src/cargo/metadata.d.ts +114 -0
  44. package/src/cargo/metadata.js +37 -0
  45. package/src/cargo/metadata.js.map +1 -0
  46. package/src/cargo/package-specs.d.ts +54 -0
  47. package/src/cargo/package-specs.js +109 -0
  48. package/src/cargo/package-specs.js.map +1 -0
  49. package/src/cargo/paths-crates.d.ts +27 -0
  50. package/src/cargo/paths-crates.js +69 -0
  51. package/src/cargo/paths-crates.js.map +1 -0
  52. package/src/cargo/print-artifact-folders.d.ts +1 -0
  53. package/src/cargo/print-artifact-folders.js +58 -0
  54. package/src/cargo/print-artifact-folders.js.map +1 -0
  55. package/src/cargo/redirections.d.ts +90 -0
  56. package/src/cargo/redirections.js +200 -0
  57. package/src/cargo/redirections.js.map +1 -0
  58. package/src/cargo/run-cargo.d.ts +31 -0
  59. package/src/cargo/run-cargo.js +75 -0
  60. package/src/cargo/run-cargo.js.map +1 -0
  61. package/src/cargo/target-triples.d.ts +98 -0
  62. package/src/cargo/target-triples.js +265 -0
  63. package/src/cargo/target-triples.js.map +1 -0
  64. package/src/cargo/version-req.d.ts +12 -0
  65. package/src/cargo/version-req.js +122 -0
  66. package/src/cargo/version-req.js.map +1 -0
  67. package/src/cargo/warnings-setting.d.ts +24 -0
  68. package/src/cargo/warnings-setting.js +81 -0
  69. package/src/cargo/warnings-setting.js.map +1 -0
  70. package/src/compatibility/cargo-version.d.ts +43 -0
  71. package/src/compatibility/cargo-version.js +83 -0
  72. package/src/compatibility/cargo-version.js.map +1 -0
  73. package/src/compatibility/nx-bridge.d.ts +312 -0
  74. package/src/compatibility/nx-bridge.js +407 -0
  75. package/src/compatibility/nx-bridge.js.map +1 -0
  76. package/src/compatibility/nx-version.d.ts +104 -0
  77. package/src/compatibility/nx-version.js +272 -0
  78. package/src/compatibility/nx-version.js.map +1 -0
  79. package/src/executors/affected-inputs.d.ts +29 -0
  80. package/src/executors/affected-inputs.js +259 -0
  81. package/src/executors/affected-inputs.js.map +1 -0
  82. package/src/executors/affected-run.d.ts +54 -0
  83. package/src/executors/affected-run.js +394 -0
  84. package/src/executors/affected-run.js.map +1 -0
  85. package/src/executors/affected.d.ts +239 -0
  86. package/src/executors/affected.js +589 -0
  87. package/src/executors/affected.js.map +1 -0
  88. package/src/executors/baseline-context.d.ts +85 -0
  89. package/src/executors/baseline-context.js +227 -0
  90. package/src/executors/baseline-context.js.map +1 -0
  91. package/src/executors/baseline.d.ts +123 -0
  92. package/src/executors/baseline.js +356 -0
  93. package/src/executors/baseline.js.map +1 -0
  94. package/src/executors/batch.d.ts +75 -0
  95. package/src/executors/batch.js +434 -0
  96. package/src/executors/batch.js.map +1 -0
  97. package/src/executors/build-records.d.ts +110 -0
  98. package/src/executors/build-records.js +267 -0
  99. package/src/executors/build-records.js.map +1 -0
  100. package/src/executors/cargo/executor.d.ts +28 -0
  101. package/src/executors/cargo/executor.js +58 -0
  102. package/src/executors/cargo/executor.js.map +1 -0
  103. package/src/executors/cargo/schema.json +58 -0
  104. package/src/executors/cargo-invocation.d.ts +81 -0
  105. package/src/executors/cargo-invocation.js +109 -0
  106. package/src/executors/cargo-invocation.js.map +1 -0
  107. package/src/executors/cargo-output.d.ts +218 -0
  108. package/src/executors/cargo-output.js +660 -0
  109. package/src/executors/cargo-output.js.map +1 -0
  110. package/src/executors/command.d.ts +331 -0
  111. package/src/executors/command.js +547 -0
  112. package/src/executors/command.js.map +1 -0
  113. package/src/executors/coverage-baseline.d.ts +23 -0
  114. package/src/executors/coverage-baseline.js +284 -0
  115. package/src/executors/coverage-baseline.js.map +1 -0
  116. package/src/executors/declared-options.d.ts +21 -0
  117. package/src/executors/declared-options.js +58 -0
  118. package/src/executors/declared-options.js.map +1 -0
  119. package/src/executors/denied-warnings.d.ts +99 -0
  120. package/src/executors/denied-warnings.js +188 -0
  121. package/src/executors/denied-warnings.js.map +1 -0
  122. package/src/executors/digests.d.ts +94 -0
  123. package/src/executors/digests.js +190 -0
  124. package/src/executors/digests.js.map +1 -0
  125. package/src/executors/dotenv-check.d.ts +79 -0
  126. package/src/executors/dotenv-check.js +553 -0
  127. package/src/executors/dotenv-check.js.map +1 -0
  128. package/src/executors/group-invocations.d.ts +80 -0
  129. package/src/executors/group-invocations.js +253 -0
  130. package/src/executors/group-invocations.js.map +1 -0
  131. package/src/executors/group-run.d.ts +114 -0
  132. package/src/executors/group-run.js +601 -0
  133. package/src/executors/group-run.js.map +1 -0
  134. package/src/executors/groups.d.ts +118 -0
  135. package/src/executors/groups.js +304 -0
  136. package/src/executors/groups.js.map +1 -0
  137. package/src/executors/input-check.d.ts +52 -0
  138. package/src/executors/input-check.js +271 -0
  139. package/src/executors/input-check.js.map +1 -0
  140. package/src/executors/kept-files.d.ts +98 -0
  141. package/src/executors/kept-files.js +341 -0
  142. package/src/executors/kept-files.js.map +1 -0
  143. package/src/executors/lockfile/executor.d.ts +16 -0
  144. package/src/executors/lockfile/executor.js +37 -0
  145. package/src/executors/lockfile/executor.js.map +1 -0
  146. package/src/executors/lockfile/schema.json +50 -0
  147. package/src/executors/napi-build.d.ts +73 -0
  148. package/src/executors/napi-build.js +420 -0
  149. package/src/executors/napi-build.js.map +1 -0
  150. package/src/executors/nextest.d.ts +189 -0
  151. package/src/executors/nextest.js +504 -0
  152. package/src/executors/nextest.js.map +1 -0
  153. package/src/executors/nx-command.d.ts +95 -0
  154. package/src/executors/nx-command.js +205 -0
  155. package/src/executors/nx-command.js.map +1 -0
  156. package/src/executors/nx-task-files.d.ts +82 -0
  157. package/src/executors/nx-task-files.js +156 -0
  158. package/src/executors/nx-task-files.js.map +1 -0
  159. package/src/executors/print-test-mode.d.ts +1 -0
  160. package/src/executors/print-test-mode.js +25 -0
  161. package/src/executors/print-test-mode.js.map +1 -0
  162. package/src/executors/release-publish/executor.d.ts +24 -0
  163. package/src/executors/release-publish/executor.js +165 -0
  164. package/src/executors/release-publish/executor.js.map +1 -0
  165. package/src/executors/release-publish/schema.json +30 -0
  166. package/src/executors/run/executor.d.ts +12 -0
  167. package/src/executors/run/executor.js +27 -0
  168. package/src/executors/run/executor.js.map +1 -0
  169. package/src/executors/run/schema.json +45 -0
  170. package/src/executors/runner-script.d.ts +12 -0
  171. package/src/executors/runner-script.js +22 -0
  172. package/src/executors/runner-script.js.map +1 -0
  173. package/src/executors/runtime-input-check.d.ts +24 -0
  174. package/src/executors/runtime-input-check.js +87 -0
  175. package/src/executors/runtime-input-check.js.map +1 -0
  176. package/src/executors/shared-artifacts.d.ts +44 -0
  177. package/src/executors/shared-artifacts.js +132 -0
  178. package/src/executors/shared-artifacts.js.map +1 -0
  179. package/src/executors/split-words.d.ts +24 -0
  180. package/src/executors/split-words.js +111 -0
  181. package/src/executors/split-words.js.map +1 -0
  182. package/src/executors/stage.d.ts +163 -0
  183. package/src/executors/stage.js +526 -0
  184. package/src/executors/stage.js.map +1 -0
  185. package/src/executors/staged-run.d.ts +24 -0
  186. package/src/executors/staged-run.js +110 -0
  187. package/src/executors/staged-run.js.map +1 -0
  188. package/src/executors/task-env.d.ts +271 -0
  189. package/src/executors/task-env.js +494 -0
  190. package/src/executors/task-env.js.map +1 -0
  191. package/src/executors/task-execution.d.ts +61 -0
  192. package/src/executors/task-execution.js +122 -0
  193. package/src/executors/task-execution.js.map +1 -0
  194. package/src/executors/task-guards.d.ts +112 -0
  195. package/src/executors/task-guards.js +435 -0
  196. package/src/executors/task-guards.js.map +1 -0
  197. package/src/executors/task-options.d.ts +114 -0
  198. package/src/executors/task-options.js +258 -0
  199. package/src/executors/task-options.js.map +1 -0
  200. package/src/executors/task.d.ts +166 -0
  201. package/src/executors/task.js +527 -0
  202. package/src/executors/task.js.map +1 -0
  203. package/src/executors/test-mode.d.ts +185 -0
  204. package/src/executors/test-mode.js +397 -0
  205. package/src/executors/test-mode.js.map +1 -0
  206. package/src/executors/test-runner.d.ts +44 -0
  207. package/src/executors/test-runner.js +159 -0
  208. package/src/executors/test-runner.js.map +1 -0
  209. package/src/executors/test-steps.d.ts +121 -0
  210. package/src/executors/test-steps.js +566 -0
  211. package/src/executors/test-steps.js.map +1 -0
  212. package/src/executors/wasm-build.d.ts +56 -0
  213. package/src/executors/wasm-build.js +216 -0
  214. package/src/executors/wasm-build.js.map +1 -0
  215. package/src/generators/crate/binary.schema.json +28 -0
  216. package/src/generators/crate/crate.d.ts +24 -0
  217. package/src/generators/crate/crate.js +108 -0
  218. package/src/generators/crate/crate.js.map +1 -0
  219. package/src/generators/crate/enclosing-workspace.d.ts +25 -0
  220. package/src/generators/crate/enclosing-workspace.js +58 -0
  221. package/src/generators/crate/enclosing-workspace.js.map +1 -0
  222. package/src/generators/crate/library.schema.json +28 -0
  223. package/src/generators/init/graph-check.d.ts +81 -0
  224. package/src/generators/init/graph-check.js +299 -0
  225. package/src/generators/init/graph-check.js.map +1 -0
  226. package/src/generators/init/init.d.ts +23 -0
  227. package/src/generators/init/init.js +113 -0
  228. package/src/generators/init/init.js.map +1 -0
  229. package/src/generators/init/report.d.ts +19 -0
  230. package/src/generators/init/report.js +93 -0
  231. package/src/generators/init/report.js.map +1 -0
  232. package/src/generators/init/schema.json +9 -0
  233. package/src/graph/artifact-kinds.d.ts +29 -0
  234. package/src/graph/artifact-kinds.js +50 -0
  235. package/src/graph/artifact-kinds.js.map +1 -0
  236. package/src/graph/artifact-names.d.ts +97 -0
  237. package/src/graph/artifact-names.js +276 -0
  238. package/src/graph/artifact-names.js.map +1 -0
  239. package/src/graph/build-records.d.ts +74 -0
  240. package/src/graph/build-records.js +104 -0
  241. package/src/graph/build-records.js.map +1 -0
  242. package/src/graph/caching.d.ts +148 -0
  243. package/src/graph/caching.js +681 -0
  244. package/src/graph/caching.js.map +1 -0
  245. package/src/graph/clippy-input.d.ts +53 -0
  246. package/src/graph/clippy-input.js +107 -0
  247. package/src/graph/clippy-input.js.map +1 -0
  248. package/src/graph/collisions.d.ts +113 -0
  249. package/src/graph/collisions.js +156 -0
  250. package/src/graph/collisions.js.map +1 -0
  251. package/src/graph/computation-reports.d.ts +89 -0
  252. package/src/graph/computation-reports.js +216 -0
  253. package/src/graph/computation-reports.js.map +1 -0
  254. package/src/graph/declared-files.d.ts +190 -0
  255. package/src/graph/declared-files.js +600 -0
  256. package/src/graph/declared-files.js.map +1 -0
  257. package/src/graph/discovery.d.ts +190 -0
  258. package/src/graph/discovery.js +661 -0
  259. package/src/graph/discovery.js.map +1 -0
  260. package/src/graph/edges.d.ts +25 -0
  261. package/src/graph/edges.js +94 -0
  262. package/src/graph/edges.js.map +1 -0
  263. package/src/graph/entries.d.ts +83 -0
  264. package/src/graph/entries.js +259 -0
  265. package/src/graph/entries.js.map +1 -0
  266. package/src/graph/inputs.d.ts +422 -0
  267. package/src/graph/inputs.js +756 -0
  268. package/src/graph/inputs.js.map +1 -0
  269. package/src/graph/lockfile-task.d.ts +74 -0
  270. package/src/graph/lockfile-task.js +105 -0
  271. package/src/graph/lockfile-task.js.map +1 -0
  272. package/src/graph/names.d.ts +41 -0
  273. package/src/graph/names.js +34 -0
  274. package/src/graph/names.js.map +1 -0
  275. package/src/graph/napi.d.ts +107 -0
  276. package/src/graph/napi.js +206 -0
  277. package/src/graph/napi.js.map +1 -0
  278. package/src/graph/nx-glob.d.ts +36 -0
  279. package/src/graph/nx-glob.js +152 -0
  280. package/src/graph/nx-glob.js.map +1 -0
  281. package/src/graph/nx-internals.d.ts +57 -0
  282. package/src/graph/nx-internals.js +128 -0
  283. package/src/graph/nx-internals.js.map +1 -0
  284. package/src/graph/options.d.ts +32 -0
  285. package/src/graph/options.js +80 -0
  286. package/src/graph/options.js.map +1 -0
  287. package/src/graph/outputs.d.ts +75 -0
  288. package/src/graph/outputs.js +140 -0
  289. package/src/graph/outputs.js.map +1 -0
  290. package/src/graph/path-dependencies.d.ts +122 -0
  291. package/src/graph/path-dependencies.js +459 -0
  292. package/src/graph/path-dependencies.js.map +1 -0
  293. package/src/graph/plugin-package.d.ts +36 -0
  294. package/src/graph/plugin-package.js +132 -0
  295. package/src/graph/plugin-package.js.map +1 -0
  296. package/src/graph/plugin-version.d.ts +20 -0
  297. package/src/graph/plugin-version.js +153 -0
  298. package/src/graph/plugin-version.js.map +1 -0
  299. package/src/graph/projects.d.ts +141 -0
  300. package/src/graph/projects.js +193 -0
  301. package/src/graph/projects.js.map +1 -0
  302. package/src/graph/reached-projects.d.ts +46 -0
  303. package/src/graph/reached-projects.js +102 -0
  304. package/src/graph/reached-projects.js.map +1 -0
  305. package/src/graph/real-path.d.ts +47 -0
  306. package/src/graph/real-path.js +113 -0
  307. package/src/graph/real-path.js.map +1 -0
  308. package/src/graph/redirected-uses.d.ts +98 -0
  309. package/src/graph/redirected-uses.js +434 -0
  310. package/src/graph/redirected-uses.js.map +1 -0
  311. package/src/graph/registration.d.ts +121 -0
  312. package/src/graph/registration.js +233 -0
  313. package/src/graph/registration.js.map +1 -0
  314. package/src/graph/rustfmt-config.d.ts +42 -0
  315. package/src/graph/rustfmt-config.js +173 -0
  316. package/src/graph/rustfmt-config.js.map +1 -0
  317. package/src/graph/script-input.d.ts +46 -0
  318. package/src/graph/script-input.js +65 -0
  319. package/src/graph/script-input.js.map +1 -0
  320. package/src/graph/settings.d.ts +178 -0
  321. package/src/graph/settings.js +479 -0
  322. package/src/graph/settings.js.map +1 -0
  323. package/src/graph/target-defaults-causes.d.ts +33 -0
  324. package/src/graph/target-defaults-causes.js +202 -0
  325. package/src/graph/target-defaults-causes.js.map +1 -0
  326. package/src/graph/target-defaults-layers.d.ts +186 -0
  327. package/src/graph/target-defaults-layers.js +420 -0
  328. package/src/graph/target-defaults-layers.js.map +1 -0
  329. package/src/graph/target-defaults-meaning.d.ts +95 -0
  330. package/src/graph/target-defaults-meaning.js +292 -0
  331. package/src/graph/target-defaults-meaning.js.map +1 -0
  332. package/src/graph/target-defaults-report.d.ts +77 -0
  333. package/src/graph/target-defaults-report.js +242 -0
  334. package/src/graph/target-defaults-report.js.map +1 -0
  335. package/src/graph/target-defaults.d.ts +79 -0
  336. package/src/graph/target-defaults.js +425 -0
  337. package/src/graph/target-defaults.js.map +1 -0
  338. package/src/graph/target-fields.d.ts +16 -0
  339. package/src/graph/target-fields.js +134 -0
  340. package/src/graph/target-fields.js.map +1 -0
  341. package/src/graph/target-tables.d.ts +45 -0
  342. package/src/graph/target-tables.js +299 -0
  343. package/src/graph/target-tables.js.map +1 -0
  344. package/src/graph/targets.d.ts +371 -0
  345. package/src/graph/targets.js +408 -0
  346. package/src/graph/targets.js.map +1 -0
  347. package/src/graph/unification.d.ts +141 -0
  348. package/src/graph/unification.js +459 -0
  349. package/src/graph/unification.js.map +1 -0
  350. package/src/graph/unignored-directories.d.ts +25 -0
  351. package/src/graph/unignored-directories.js +89 -0
  352. package/src/graph/unignored-directories.js.map +1 -0
  353. package/src/graph/visibility.d.ts +17 -0
  354. package/src/graph/visibility.js +67 -0
  355. package/src/graph/visibility.js.map +1 -0
  356. package/src/graph/warnings.d.ts +38 -0
  357. package/src/graph/warnings.js +77 -0
  358. package/src/graph/warnings.js.map +1 -0
  359. package/src/graph/wasm.d.ts +56 -0
  360. package/src/graph/wasm.js +77 -0
  361. package/src/graph/wasm.js.map +1 -0
  362. package/src/index.d.ts +68 -0
  363. package/src/index.js +109 -0
  364. package/src/index.js.map +1 -0
  365. package/src/release/manifests.d.ts +95 -0
  366. package/src/release/manifests.js +164 -0
  367. package/src/release/manifests.js.map +1 -0
  368. package/src/release/places.d.ts +127 -0
  369. package/src/release/places.js +368 -0
  370. package/src/release/places.js.map +1 -0
  371. package/src/release/publish-cargo.d.ts +177 -0
  372. package/src/release/publish-cargo.js +351 -0
  373. package/src/release/publish-cargo.js.map +1 -0
  374. package/src/release/publish-crates.d.ts +124 -0
  375. package/src/release/publish-crates.js +242 -0
  376. package/src/release/publish-crates.js.map +1 -0
  377. package/src/release/publish-environments.d.ts +50 -0
  378. package/src/release/publish-environments.js +284 -0
  379. package/src/release/publish-environments.js.map +1 -0
  380. package/src/release/publish-messages.d.ts +66 -0
  381. package/src/release/publish-messages.js +273 -0
  382. package/src/release/publish-messages.js.map +1 -0
  383. package/src/release/publish-registry.d.ts +27 -0
  384. package/src/release/publish-registry.js +135 -0
  385. package/src/release/publish-registry.js.map +1 -0
  386. package/src/release/publish-settings.d.ts +26 -0
  387. package/src/release/publish-settings.js +56 -0
  388. package/src/release/publish-settings.js.map +1 -0
  389. package/src/release/publish.d.ts +59 -0
  390. package/src/release/publish.js +620 -0
  391. package/src/release/publish.js.map +1 -0
  392. package/src/release/repository.d.ts +73 -0
  393. package/src/release/repository.js +219 -0
  394. package/src/release/repository.js.map +1 -0
  395. package/src/release/requirements.d.ts +34 -0
  396. package/src/release/requirements.js +30 -0
  397. package/src/release/requirements.js.map +1 -0
  398. package/src/release/toml-edit.d.ts +67 -0
  399. package/src/release/toml-edit.js +453 -0
  400. package/src/release/toml-edit.js.map +1 -0
  401. package/src/release/version-actions.d.ts +133 -0
  402. package/src/release/version-actions.js +474 -0
  403. package/src/release/version-actions.js.map +1 -0
  404. package/src/release/version-checks.d.ts +21 -0
  405. package/src/release/version-checks.js +151 -0
  406. package/src/release/version-checks.js.map +1 -0
  407. package/src/release/version-lockfiles.d.ts +61 -0
  408. package/src/release/version-lockfiles.js +222 -0
  409. package/src/release/version-lockfiles.js.map +1 -0
  410. package/src/tools/napi-cli.d.ts +70 -0
  411. package/src/tools/napi-cli.js +63 -0
  412. package/src/tools/napi-cli.js.map +1 -0
  413. package/src/tools/optional-tools.d.ts +121 -0
  414. package/src/tools/optional-tools.js +303 -0
  415. package/src/tools/optional-tools.js.map +1 -0
  416. package/src/tools/print-napi-cli.d.ts +1 -0
  417. package/src/tools/print-napi-cli.js +24 -0
  418. package/src/tools/print-napi-cli.js.map +1 -0
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Registration = void 0;
4
+ exports.registrationOf = registrationOf;
5
+ exports.entryRegistration = entryRegistration;
6
+ const tslib_1 = require("tslib");
7
+ const nx_version_1 = require("../compatibility/nx-version");
8
+ const caching_1 = require("./caching");
9
+ const computation_reports_1 = require("./computation-reports");
10
+ const discovery_1 = require("./discovery");
11
+ const entries_1 = require("./entries");
12
+ const projects_1 = require("./projects");
13
+ const settings_1 = require("./settings");
14
+ const target_defaults_causes_1 = require("./target-defaults-causes");
15
+ const unification_1 = require("./unification");
16
+ /**
17
+ * One entry of the plugin in `nx.json`, with what its `createNodes` hook
18
+ * found for its `createDependencies` and `createMetadata` hooks.
19
+ *
20
+ * Nx loads the plugin module once per process and copies its properties for
21
+ * each entry, reading `createNodes` anew for each copy. Each read creates a
22
+ * registration with a `createNodes` of its own ({@link Registration.createNodes}).
23
+ * Nx calls the function of the copy's `createNodes` tuple as an element of
24
+ * that tuple, so that its `this` is the tuple and not the copy, and
25
+ * `createDependencies` and `createMetadata` as methods of the entry's copy, so {@link registrationOf}
26
+ * finds the registration through the copy's `createNodes`. Nothing else that
27
+ * Nx passes to the hooks tells the entries apart: their context is the same
28
+ * for all, and the options of an entry without options are `undefined`
29
+ * (EVD-NX-24-PLUGIN-ENTRIES). An entry's later hooks therefore see only what
30
+ * its own `createNodes` discovered, whether Nx runs the entries in one
31
+ * process or each in a worker of its own.
32
+ *
33
+ * Where a call shows that this does not hold, the hook fails rather than
34
+ * answer with another entry's projects ({@link entryRegistration}).
35
+ */
36
+ // @mara implements DES-DISCOVERY
37
+ // @mara implements DES-METADATA-REPORT
38
+ // @mara implements DES-PROJECT-GRAPH
39
+ // @mara implements DES-TARGET-DEFAULT-GUARD
40
+ class Registration {
41
+ constructor() {
42
+ this.started = 0;
43
+ this.createNodes = [
44
+ entries_1.manifestPattern,
45
+ (manifests, options, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
46
+ const graph = yield this.discover(manifests, context.workspaceRoot, options, context.nxJsonConfiguration);
47
+ // Nx's plugin interface has no channel for warnings; standard error
48
+ // reaches the terminal without the daemon and its log file with it.
49
+ // The warnings of the projects' caching are printed where they are
50
+ // found (`cacheContext` in `caching.ts`).
51
+ for (const warning of graph.discovery.warnings) {
52
+ console.warn(warning);
53
+ }
54
+ // A copy: in its own process, Nx merges the lists of the nodes it
55
+ // receives without copying them and rewrites the project names in
56
+ // their dependsOn and inputs in place (EVD-NX-24-PLUGIN-NODES). The
57
+ // graph kept for createDependencies has to stay what the plugin
58
+ // inferred, which DES-TARGET-DEFAULT-GUARD compares with what Nx
59
+ // merged.
60
+ return structuredClone((0, projects_1.projectNodes)(graph.projects));
61
+ }),
62
+ ];
63
+ registrations.set(this.createNodes, this);
64
+ }
65
+ /**
66
+ * Discovers the Cargo workspaces for this entry's `createNodes`, infers
67
+ * their projects and targets and keeps both for its `createDependencies`.
68
+ * Every call requests the reports afresh, sharing them only with the other
69
+ * entries of the same graph computation.
70
+ *
71
+ * Nx calls `createDependencies` after `createNodes` in the same process. A
72
+ * daemon can start a computation while an earlier one is still running and
73
+ * then drops the earlier one, so the result of the call that started last
74
+ * is kept, even if an earlier call finishes after it. Nx 24 hands an entry
75
+ * all its manifests in one call, so each call is taken as a computation of
76
+ * its own.
77
+ *
78
+ * @param options The entry's plugin options.
79
+ * @param nxJson `nx.json`, whose `plugins` name the entries of the plugin,
80
+ * no two of which may receive manifests of one workspace (`checkEntries`
81
+ * in `entries.ts`), which says whether Nx analyses the JS lockfile
82
+ * (`pluginInput` in `plugin-package.ts`), and whose `namedInputs` give
83
+ * the repository's `default` (`cacheContext` in `caching.ts`).
84
+ * @throws {Error} When the call cannot be this entry's alone (see
85
+ * {@link Registration.claim}), when the installed Nx is not supported (see
86
+ * {@link checkNxForGraph}), when the options are invalid, when discovery
87
+ * fails (see {@link discoverWorkspaces}), when a metadata table is
88
+ * invalid (see {@link readSettings}), when two entries of the plugin
89
+ * receive manifests of one workspace, or the plugin cannot tell whether
90
+ * they do (see {@link checkEntries}), when a `fileInputs` pattern resolves where
91
+ * Nx cannot hash it, or when the targets cannot be given their names
92
+ * and tables (see {@link inferProjects}).
93
+ */
94
+ discover(manifests, workspaceRoot, options, nxJson) {
95
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
96
+ var _a;
97
+ // Before the first await: it decides which computation this call joins.
98
+ const reports = (0, computation_reports_1.computationReports)();
99
+ this.claim(options);
100
+ const sequence = ++this.started;
101
+ let graph;
102
+ try {
103
+ const nxWarning = (0, nx_version_1.checkNxForGraph)(workspaceRoot, reports);
104
+ const pluginOptions = (0, settings_1.readPluginOptions)(options);
105
+ const discovery = yield (0, discovery_1.discoverWorkspaces)(manifests, workspaceRoot, reports);
106
+ const settings = (0, settings_1.readSettings)(discovery, pluginOptions);
107
+ const view = yield (0, entries_1.checkEntries)(discovery, manifests, nxJson);
108
+ const strategies = (0, unification_1.workspaceStrategies)(discovery, settings);
109
+ const context = yield (0, caching_1.cacheContext)(discovery, nxJson, nxWarning === undefined ? [] : [nxWarning], reports, view, strategies);
110
+ const projects = (0, projects_1.inferProjects)(discovery, settings, context);
111
+ const causes = yield (0, target_defaults_causes_1.targetDefaultCauses)(projects, nxJson, workspaceRoot);
112
+ graph = {
113
+ discovery,
114
+ strategies,
115
+ projects: (0, projects_1.withWarningsInputs)(projects, workspaceRoot, causes),
116
+ declaredPatterns: [
117
+ ...projects.flatMap((project) => project.declaredPatterns),
118
+ ...((_a = context.declaredPatterns) !== null && _a !== void 0 ? _a : []),
119
+ ],
120
+ };
121
+ return graph;
122
+ }
123
+ finally {
124
+ if (this.latest === undefined || this.latest.sequence < sequence) {
125
+ this.latest = { sequence, workspaceRoot, graph };
126
+ }
127
+ }
128
+ });
129
+ }
130
+ /**
131
+ * Takes a `createNodes` call for this entry, or fails where it comes with
132
+ * other options than the entry's first call, which shows that entries
133
+ * share this registration. Calls with the entry's options may overlap, as
134
+ * where the daemon starts a graph computation before an earlier one has
135
+ * finished; {@link Registration.discover} keeps the newest.
136
+ */
137
+ claim(options) {
138
+ var _a;
139
+ if (this.options !== undefined && this.options.value !== options) {
140
+ throw entryError("createNodes", "it got other options than the entry's earlier call");
141
+ }
142
+ (_a = this.options) !== null && _a !== void 0 ? _a : (this.options = { value: options });
143
+ }
144
+ /**
145
+ * This registration, for a later hook of the entry, which Nx calls with the
146
+ * options that it passed to the entry's `createNodes`.
147
+ *
148
+ * @throws {Error} When `options` are not those.
149
+ */
150
+ forHook(hook, options) {
151
+ if (this.options !== undefined && this.options.value !== options) {
152
+ throw entryError(hook, "it got other options than the entry's createNodes");
153
+ }
154
+ return this;
155
+ }
156
+ /**
157
+ * What this entry's `createNodes` found for the graph computation that
158
+ * `createDependencies` belongs to, or `undefined` when it failed: Nx still
159
+ * calls `createDependencies` then, and graph creation fails with the error
160
+ * of `createNodes`.
161
+ *
162
+ * @throws {Error} When `createNodes` has not run for `workspaceRoot`.
163
+ */
164
+ graphForDependencies(workspaceRoot) {
165
+ if (this.latest === undefined || this.latest.workspaceRoot !== workspaceRoot) {
166
+ throw new Error(`nx-rust found no Cargo workspaces for ${workspaceRoot}: Nx asked for the dependencies before the projects. Please report this at https://github.com/convesoft/nx-rust/issues together with the Nx version and command.`);
167
+ }
168
+ return this.latest.graph;
169
+ }
170
+ /**
171
+ * Keeps the warnings that `createDependencies` found for targets of this
172
+ * entry's projects with the graph computation they belong to, for
173
+ * `createMetadata`, which Nx calls after it in the same process.
174
+ */
175
+ recordTargetWarnings(workspaceRoot, warnings) {
176
+ var _a;
177
+ if (((_a = this.latest) === null || _a === void 0 ? void 0 : _a.workspaceRoot) === workspaceRoot) {
178
+ this.latest.targetWarnings = warnings;
179
+ }
180
+ }
181
+ /**
182
+ * The warnings that `createDependencies` found in the graph computation
183
+ * that `createMetadata` belongs to, by project name, each with its target;
184
+ * none where it found none or did not run.
185
+ */
186
+ targetWarnings(workspaceRoot) {
187
+ var _a, _b, _c;
188
+ const byProject = new Map();
189
+ if (((_a = this.latest) === null || _a === void 0 ? void 0 : _a.workspaceRoot) !== workspaceRoot) {
190
+ return byProject;
191
+ }
192
+ for (const { project, target, warning } of (_b = this.latest.targetWarnings) !== null && _b !== void 0 ? _b : []) {
193
+ byProject.set(project, [...((_c = byProject.get(project)) !== null && _c !== void 0 ? _c : []), { target, warning }]);
194
+ }
195
+ return byProject;
196
+ }
197
+ }
198
+ exports.Registration = Registration;
199
+ const registrations = new WeakMap();
200
+ /**
201
+ * The registration of the plugin entry that `plugin`, Nx's copy of the
202
+ * plugin module for that entry, belongs to.
203
+ *
204
+ * @throws {Error} When `plugin` is no such copy, as where a later hook is
205
+ * called detached from the copy, after destructuring, rather than as a
206
+ * method of the copy.
207
+ */
208
+ function registrationOf(plugin, hook = "createDependencies") {
209
+ const createNodes = plugin === null || plugin === void 0 ? void 0 : plugin.createNodes;
210
+ const registration = typeof createNodes === "object" && createNodes !== null
211
+ ? registrations.get(createNodes)
212
+ : undefined;
213
+ if (registration === undefined) {
214
+ throw entryError(hook, "Nx did not call it as a method of its copy of the plugin for the entry");
215
+ }
216
+ return registration;
217
+ }
218
+ /**
219
+ * The registration of the entry whose `hook` Nx called as a method of
220
+ * `plugin` with `options`: {@link registrationOf}, checked against the
221
+ * options of the entry's `createNodes` ({@link Registration.forHook}).
222
+ *
223
+ * @throws {Error} When the plugin cannot tell that the call is the entry's.
224
+ */
225
+ function entryRegistration(plugin, hook, options) {
226
+ return registrationOf(plugin, hook).forHook(hook, options);
227
+ }
228
+ // A wrong graph is worse than none (GOAL-TRUSTED-CACHE): where a call may
229
+ // belong to another entry, the hook fails instead of answering.
230
+ function entryError(hook, reason) {
231
+ return new Error(`nx-rust could not tell which of its entries in nx.json Nx called ${hook} for: ${reason}. It stops rather than answer with the projects of another entry. Please report this at https://github.com/convesoft/nx-rust/issues together with the Nx version, the plugin's entries in nx.json and the command.`);
232
+ }
233
+ //# sourceMappingURL=registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../nx-rust/src/graph/registration.ts"],"names":[],"mappings":";;;AAyPA,wCAaC;AASD,8CAEC;;AAhRD,4DAA8D;AAC9D,uCAAyC;AACzC,+DAA2D;AAC3D,2CAAiD;AACjD,uCAA0D;AAE1D,yCAAyF;AACzF,yCAA6D;AAC7D,qEAA+D;AA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AC,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAED,0EAA0E;AAC1E,gEAAgE;AAChE,SAAS,UAAU,CAAC,IAAY,EAAE,MAAc;IAC9C,OAAO,IAAI,KAAK,CACd,oEAAoE,IAAI,SAAS,MAAM,oNAAoN,CAC5S,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { CargoWorkspace } from "./discovery";
2
+ /**
3
+ * The rustfmt configuration file that rustfmt takes for a file of the
4
+ * repository where no folder from the file's up to the repository root
5
+ * holds one, or `undefined` where it takes none or fails
6
+ * (`DES-DIAGNOSTICS`, "Rustfmt configuration outside the repository").
7
+ * rustfmt looks in each folder above the file's, up to the file system's
8
+ * root, then in the home folder and then in `rustfmt` in the user's
9
+ * configuration folder, and in each for `.rustfmt.toml` before
10
+ * `rustfmt.toml`, and takes the first file it finds; an error other than a
11
+ * missing file or folder stops it (`EVD-CLIPPY-RUSTFMT-CONFIG-LOOKUP`).
12
+ * This repeats only the folders above the repository's real path and the
13
+ * two per-user folders: the home folder from `HOME`, or the user's entry
14
+ * where it is unset or empty, and the configuration folder from an absolute
15
+ * `XDG_CONFIG_HOME`, else `.config` in the home folder, and on macOS
16
+ * `Library/Application Support` there.
17
+ *
18
+ * @param repositoryRoot The absolute path of the repository root.
19
+ * @param env The environment of graph creation, whose `HOME` and
20
+ * `XDG_CONFIG_HOME` rustfmt reads too unless a task's own dotenv files
21
+ * change them.
22
+ */
23
+ export declare function outsideRustfmtConfiguration(repositoryRoot: string, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string | undefined;
24
+ /**
25
+ * The warning about a rustfmt configuration file that rustfmt takes for
26
+ * crates of the workspaces from outside the repository, or from a per-user
27
+ * folder inside it, because no folder from a source file of the crate up to
28
+ * the repository root holds `rustfmt.toml` or `.rustfmt.toml`
29
+ * ({@link outsideRustfmtConfiguration}), one for all the workspaces that it
30
+ * concerns, or none. The folders are those of the source files of the
31
+ * crate's targets, `src_path` in the report, where rustfmt starts looking
32
+ * for each of them. A file inside the repository concerns only the crates
33
+ * whose folder does not hold it, since a crate's key holds the files of its
34
+ * folder. The warning joins the {@link CargoWorkspace.formattingWarnings} of
35
+ * each crate that it concerns, whose `fmt-check` and `fmt` tasks print it at
36
+ * their start; like the warning about Cargo configuration that Nx does not
37
+ * hash, no key holds it, so that a machine's rustfmt configuration gives no
38
+ * keys of their own (`RISK-HOST-ENVIRONMENT`, `DES-DIAGNOSTICS`).
39
+ *
40
+ * @param repositoryRoot The absolute path of the repository root.
41
+ */
42
+ export declare function rustfmtConfigurationWarnings(workspaces: CargoWorkspace[], repositoryRoot: string, env?: NodeJS.ProcessEnv): string[];
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.outsideRustfmtConfiguration = outsideRustfmtConfiguration;
4
+ exports.rustfmtConfigurationWarnings = rustfmtConfigurationWarnings;
5
+ const node_fs_1 = require("node:fs");
6
+ const node_os_1 = require("node:os");
7
+ const node_path_1 = require("node:path");
8
+ const discovery_1 = require("./discovery");
9
+ const real_path_1 = require("./real-path");
10
+ /** The names of rustfmt's configuration file, in the order in which rustfmt looks for them in a folder. */
11
+ const fileNames = [".rustfmt.toml", "rustfmt.toml"];
12
+ /**
13
+ * The rustfmt configuration file that rustfmt takes for a file of the
14
+ * repository where no folder from the file's up to the repository root
15
+ * holds one, or `undefined` where it takes none or fails
16
+ * (`DES-DIAGNOSTICS`, "Rustfmt configuration outside the repository").
17
+ * rustfmt looks in each folder above the file's, up to the file system's
18
+ * root, then in the home folder and then in `rustfmt` in the user's
19
+ * configuration folder, and in each for `.rustfmt.toml` before
20
+ * `rustfmt.toml`, and takes the first file it finds; an error other than a
21
+ * missing file or folder stops it (`EVD-CLIPPY-RUSTFMT-CONFIG-LOOKUP`).
22
+ * This repeats only the folders above the repository's real path and the
23
+ * two per-user folders: the home folder from `HOME`, or the user's entry
24
+ * where it is unset or empty, and the configuration folder from an absolute
25
+ * `XDG_CONFIG_HOME`, else `.config` in the home folder, and on macOS
26
+ * `Library/Application Support` there.
27
+ *
28
+ * @param repositoryRoot The absolute path of the repository root.
29
+ * @param env The environment of graph creation, whose `HOME` and
30
+ * `XDG_CONFIG_HOME` rustfmt reads too unless a task's own dotenv files
31
+ * change them.
32
+ */
33
+ function outsideRustfmtConfiguration(repositoryRoot, env = process.env, platform = process.platform) {
34
+ const folders = [];
35
+ for (let folder = (0, real_path_1.realPath)(repositoryRoot); (0, node_path_1.dirname)(folder) !== folder;) {
36
+ folder = (0, node_path_1.dirname)(folder);
37
+ folders.push(folder);
38
+ }
39
+ const home = env.HOME !== undefined && env.HOME !== "" ? env.HOME : userHome();
40
+ const xdg = env.XDG_CONFIG_HOME;
41
+ const configuration = platform === "darwin"
42
+ ? home === undefined
43
+ ? undefined
44
+ : (0, node_path_1.join)(home, "Library", "Application Support")
45
+ : xdg !== undefined && (0, node_path_1.isAbsolute)(xdg)
46
+ ? xdg
47
+ : home === undefined
48
+ ? undefined
49
+ : (0, node_path_1.join)(home, ".config");
50
+ for (const folder of [
51
+ ...folders,
52
+ ...(home === undefined ? [] : [home]),
53
+ ...(configuration === undefined ? [] : [(0, node_path_1.join)(configuration, "rustfmt")]),
54
+ ]) {
55
+ const found = lookIn(folder);
56
+ if (found === "stop") {
57
+ return undefined;
58
+ }
59
+ if (found !== "none") {
60
+ return found;
61
+ }
62
+ }
63
+ return undefined;
64
+ }
65
+ /**
66
+ * The warning about a rustfmt configuration file that rustfmt takes for
67
+ * crates of the workspaces from outside the repository, or from a per-user
68
+ * folder inside it, because no folder from a source file of the crate up to
69
+ * the repository root holds `rustfmt.toml` or `.rustfmt.toml`
70
+ * ({@link outsideRustfmtConfiguration}), one for all the workspaces that it
71
+ * concerns, or none. The folders are those of the source files of the
72
+ * crate's targets, `src_path` in the report, where rustfmt starts looking
73
+ * for each of them. A file inside the repository concerns only the crates
74
+ * whose folder does not hold it, since a crate's key holds the files of its
75
+ * folder. The warning joins the {@link CargoWorkspace.formattingWarnings} of
76
+ * each crate that it concerns, whose `fmt-check` and `fmt` tasks print it at
77
+ * their start; like the warning about Cargo configuration that Nx does not
78
+ * hash, no key holds it, so that a machine's rustfmt configuration gives no
79
+ * keys of their own (`RISK-HOST-ENVIRONMENT`, `DES-DIAGNOSTICS`).
80
+ *
81
+ * @param repositoryRoot The absolute path of the repository root.
82
+ */
83
+ // @mara implements DES-DIAGNOSTICS
84
+ function rustfmtConfigurationWarnings(workspaces, repositoryRoot, env = process.env) {
85
+ const file = outsideRustfmtConfiguration(repositoryRoot, env);
86
+ if (file === undefined) {
87
+ return [];
88
+ }
89
+ const root = (0, real_path_1.realPath)(repositoryRoot);
90
+ const insidePath = (path) => {
91
+ const inside = (0, node_path_1.relative)(root, (0, real_path_1.realPath)(path));
92
+ return inside === ".." || inside.startsWith("../") || (0, node_path_1.isAbsolute)(inside) ? undefined : inside;
93
+ };
94
+ const shown = insidePath(file);
95
+ const real = (0, real_path_1.realPath)(file);
96
+ const covered = new Map();
97
+ // Whether rustfmt takes a file of the repository, or fails, before it
98
+ // leaves the repository, starting in `folder`, a real path inside it.
99
+ const isCovered = (folder) => {
100
+ const known = covered.get(folder);
101
+ if (known !== undefined) {
102
+ return known;
103
+ }
104
+ const found = lookIn(folder);
105
+ const result = found !== "none" || (folder !== root && isCovered((0, node_path_1.dirname)(folder)));
106
+ covered.set(folder, result);
107
+ return result;
108
+ };
109
+ const concerned = workspaces
110
+ .map((workspace) => ({
111
+ workspace,
112
+ crates: workspace.members
113
+ .filter((pkg) => shown === undefined || !isWithin((0, real_path_1.realPath)((0, node_path_1.dirname)(pkg.manifest_path)), real))
114
+ .filter((pkg) => pkg.targets.some((target) => {
115
+ var _a;
116
+ const folder = (0, real_path_1.realPath)((0, node_path_1.dirname)((_a = target.src_path) !== null && _a !== void 0 ? _a : pkg.manifest_path));
117
+ return insidePath(folder) !== undefined && !isCovered(folder);
118
+ }))
119
+ .map((pkg) => pkg.manifest_path),
120
+ }))
121
+ .filter(({ crates }) => crates.length > 0);
122
+ if (concerned.length === 0) {
123
+ return [];
124
+ }
125
+ const subject = (0, discovery_1.describeWorkspaces)(concerned.map(({ workspace }) => workspace.root));
126
+ const guide = 'see "Rustfmt configuration outside the repository" in the nx-rust caching guide';
127
+ const message = [
128
+ shown === undefined
129
+ ? `nx-rust: rustfmt takes its configuration from ${file} for the crates of ${subject} that no rustfmt.toml or .rustfmt.toml in the repository covers, but the file lies outside the repository, so Nx does not hash it, and a fmt-check result cached before a change to it can be restored afterwards.`
130
+ : `nx-rust: rustfmt takes its configuration from ${shown}, a per-user file that HOME or XDG_CONFIG_HOME places in the repository, for the crates of ${subject} that no other rustfmt.toml or .rustfmt.toml covers, but the file lies outside the folders of those crates, so their keys do not hold it, and a fmt-check result cached before a change to it can be restored afterwards.`,
131
+ `Add a rustfmt.toml to the repository root to have every machine format alike and Nx hash it, or run \`nx reset\` after each change to the file; --skip-nx-cache covers only the command it is given to (${guide}).`,
132
+ ].join("\n");
133
+ for (const { workspace, crates } of concerned) {
134
+ for (const manifest of crates) {
135
+ workspace.formattingWarnings.set(manifest, message);
136
+ }
137
+ }
138
+ return [message];
139
+ }
140
+ // What rustfmt finds in the folder: the first of its names that is a file,
141
+ // following symbolic links; "none" where neither is, as for a missing name
142
+ // or folder; and "stop" for another error, on which rustfmt fails.
143
+ function lookIn(folder) {
144
+ for (const name of fileNames) {
145
+ const path = (0, node_path_1.join)(folder, name);
146
+ try {
147
+ if ((0, node_fs_1.statSync)(path).isFile()) {
148
+ return path;
149
+ }
150
+ }
151
+ catch (error) {
152
+ const code = error.code;
153
+ if (code !== "ENOENT" && code !== "ENOTDIR") {
154
+ return "stop";
155
+ }
156
+ }
157
+ }
158
+ return "none";
159
+ }
160
+ // Whether `path` lies in `folder` or below it, both real paths.
161
+ function isWithin(folder, path) {
162
+ const inside = (0, node_path_1.relative)(folder, path);
163
+ return inside !== "" && inside !== ".." && !inside.startsWith("../") && !(0, node_path_1.isAbsolute)(inside);
164
+ }
165
+ function userHome() {
166
+ try {
167
+ return (0, node_os_1.userInfo)().homedir || undefined;
168
+ }
169
+ catch (_a) {
170
+ return undefined;
171
+ }
172
+ }
173
+ //# sourceMappingURL=rustfmt-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rustfmt-config.js","sourceRoot":"","sources":["../../../../nx-rust/src/graph/rustfmt-config.ts"],"names":[],"mappings":";;AAqCA,kEAoCC;AAqBD,oEA8DC;AA5JD,qCAAmC;AACnC,qCAAmC;AACnC,yCAAgE;AAChE,2CAAiE;AACjE,2CAAuC;AAEvC,2GAA2G;AAC3G,MAAM,SAAS,GAAG,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AASpD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,2BAA2B,CACzC,cAAsB,EACtB,MAAyB,OAAO,CAAC,GAAG,EACpC,WAA4B,OAAO,CAAC,QAAQ;IAE5C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,MAAM,GAAG,IAAA,oBAAQ,EAAC,cAAc,CAAC,EAAE,IAAA,mBAAO,EAAC,MAAM,CAAC,KAAK,MAAM,GAAG,CAAC;QACxE,MAAM,GAAG,IAAA,mBAAO,EAAC,MAAM,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC/E,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC;IAChC,MAAM,aAAa,GACjB,QAAQ,KAAK,QAAQ;QACnB,CAAC,CAAC,IAAI,KAAK,SAAS;YAClB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAA,gBAAI,EAAC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node scripts prints, before its random value, where the script cannot run
4
+ * or fails (`DES-INPUTS`, "Failing runtime inputs"). The executor looks for
5
+ * it when it runs such a command again (`failedInputWarnings`).
6
+ */
7
+ export declare const failedInputLine = "@convesoft/nx-rust: this runtime input failed";
8
+ /**
9
+ * The variable that names the file descriptor to which the command of a
10
+ * script input sends the script's standard error: where it is unset, as
11
+ * when Nx hashes a task, descriptor 3, which the command opens on
12
+ * `/dev/null`; and `2`, the command's own standard error, where the
13
+ * executor runs the command again to say why it failed.
14
+ */
15
+ export declare const inputErrorsVariable = "NX_RUST_INPUT_ERRORS";
16
+ /**
17
+ * Shell text that prints a value that no other evaluation prints, for a
18
+ * runtime input whose query failed, so that Nx never restores a result
19
+ * stored under that key (`DES-INPUTS`, "Failing runtime inputs"). It asks
20
+ * `od` for 16 bytes of `/dev/urandom`, and where `od` is missing or fails,
21
+ * as on a `PATH` that leaves it out with the tool whose failure the value
22
+ * covers, it reads them from `/dev/urandom` with the shell's own `read` and
23
+ * prints each as two hexadecimal digits with its own `printf`, in a
24
+ * subshell with `LC_ALL=C`, so that it needs no program besides the shell.
25
+ * Where `/dev/urandom` cannot be read either, it prints the process ids of
26
+ * the shell and of its parent and, where `date` exists, the time; without
27
+ * `date`, two such runs in fresh process namespaces can repeat it
28
+ * (nxr-ntvnds). It writes nothing to standard error, which
29
+ * Nx would hash as well.
30
+ */
31
+ export declare const unrepeatableValue: string;
32
+ /**
33
+ * The command of a runtime input that runs one of the plugin's Node scripts
34
+ * in the repository root with `argument`, a folder relative to it
35
+ * (`DES-INPUTS`): the Node that creates the graph, the script and the folder,
36
+ * by paths that reach no key, since Nx keys a task on what a runtime input
37
+ * prints and not on its command. Where the script cannot run, as for a
38
+ * plugin that Nx loads from its TypeScript source or a Node that is gone, or
39
+ * fails, the command prints {@link failedInputLine} on a line of its own,
40
+ * also after output without a final line break, and then
41
+ * {@link unrepeatableValue}, so that no result stored under the key is ever
42
+ * restored. It always ends with status 0, as Nx keys a task on what a
43
+ * runtime input prints whatever its status (`EVD-RUSTUP-MISSING-TOOLCHAIN`).
44
+ * The script's standard error goes where {@link inputErrorsVariable} says.
45
+ */
46
+ export declare function scriptInputCommand(script: string, argument: string): string;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unrepeatableValue = exports.inputErrorsVariable = exports.failedInputLine = void 0;
4
+ exports.scriptInputCommand = scriptInputCommand;
5
+ const artifact_kinds_1 = require("./artifact-kinds");
6
+ /**
7
+ * The line that the command of a runtime input running one of the plugin's
8
+ * Node scripts prints, before its random value, where the script cannot run
9
+ * or fails (`DES-INPUTS`, "Failing runtime inputs"). The executor looks for
10
+ * it when it runs such a command again (`failedInputWarnings`).
11
+ */
12
+ exports.failedInputLine = "@convesoft/nx-rust: this runtime input failed";
13
+ /**
14
+ * The variable that names the file descriptor to which the command of a
15
+ * script input sends the script's standard error: where it is unset, as
16
+ * when Nx hashes a task, descriptor 3, which the command opens on
17
+ * `/dev/null`; and `2`, the command's own standard error, where the
18
+ * executor runs the command again to say why it failed.
19
+ */
20
+ exports.inputErrorsVariable = "NX_RUST_INPUT_ERRORS";
21
+ /**
22
+ * Shell text that prints a value that no other evaluation prints, for a
23
+ * runtime input whose query failed, so that Nx never restores a result
24
+ * stored under that key (`DES-INPUTS`, "Failing runtime inputs"). It asks
25
+ * `od` for 16 bytes of `/dev/urandom`, and where `od` is missing or fails,
26
+ * as on a `PATH` that leaves it out with the tool whose failure the value
27
+ * covers, it reads them from `/dev/urandom` with the shell's own `read` and
28
+ * prints each as two hexadecimal digits with its own `printf`, in a
29
+ * subshell with `LC_ALL=C`, so that it needs no program besides the shell.
30
+ * Where `/dev/urandom` cannot be read either, it prints the process ids of
31
+ * the shell and of its parent and, where `date` exists, the time; without
32
+ * `date`, two such runs in fresh process namespaces can repeat it
33
+ * (nxr-ntvnds). It writes nothing to standard error, which
34
+ * Nx would hash as well.
35
+ */
36
+ exports.unrepeatableValue = [
37
+ "{ od -An -N16 -tx1 /dev/urandom 2>/dev/null ||",
38
+ "( LC_ALL=C; n=0; i=0;",
39
+ "while [ $i -lt 16 ] && [ $n -lt 64 ]; do n=$((n + 1)); IFS= read -r c </dev/urandom;",
40
+ `while [ -n "$c" ] && [ $i -lt 16 ]; do printf %02x "'$c"; c=\${c#?}; i=$((i + 1)); done; done;`,
41
+ "[ $i -eq 16 ] && echo ) 2>/dev/null ||",
42
+ 'echo "process $$ $PPID $(date +%s.%N 2>/dev/null)"; }',
43
+ ].join(" ");
44
+ /**
45
+ * The command of a runtime input that runs one of the plugin's Node scripts
46
+ * in the repository root with `argument`, a folder relative to it
47
+ * (`DES-INPUTS`): the Node that creates the graph, the script and the folder,
48
+ * by paths that reach no key, since Nx keys a task on what a runtime input
49
+ * prints and not on its command. Where the script cannot run, as for a
50
+ * plugin that Nx loads from its TypeScript source or a Node that is gone, or
51
+ * fails, the command prints {@link failedInputLine} on a line of its own,
52
+ * also after output without a final line break, and then
53
+ * {@link unrepeatableValue}, so that no result stored under the key is ever
54
+ * restored. It always ends with status 0, as Nx keys a task on what a
55
+ * runtime input prints whatever its status (`EVD-RUSTUP-MISSING-TOOLCHAIN`).
56
+ * The script's standard error goes where {@link inputErrorsVariable} says.
57
+ */
58
+ // @mara implements DES-INPUTS
59
+ function scriptInputCommand(script, argument) {
60
+ return [
61
+ `{ ${(0, artifact_kinds_1.shellQuote)(process.execPath)} ${(0, artifact_kinds_1.shellQuote)(script)} ${(0, artifact_kinds_1.shellQuote)(argument)} 2>&"\${${exports.inputErrorsVariable}:-3}" || { echo; echo ${(0, artifact_kinds_1.shellQuote)(exports.failedInputLine)}; ${exports.unrepeatableValue}; }; } 3>/dev/null`,
62
+ "true",
63
+ ].join("; ");
64
+ }
65
+ //# sourceMappingURL=script-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-input.js","sourceRoot":"","sources":["../../../../nx-rust/src/graph/script-input.ts"],"names":[],"mappings":";;;AA0DA,gDAKC;AA/DD,qDAA8C;AAE9C;;;;;GAKG;AACU,QAAA,eAAe,GAAG,+CAA+C,CAAC;AAE/E;;;;;;GAMG;AACU,QAAA,mBAAmB,GAAG,sBAAsB,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACU,QAAA,iBAAiB,GAAG;IAC/B,gDAAgD;IAChD,uBAAuB;IACvB,sFAAsF;IACtF,gGAAgG;IAChG,wCAAwC;IACxC,uDAAuD;CACxD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ;;;;;;;;;;;;;GAaG;AACH,8BAA8B;AAC9B,SAAgB,kBAAkB,CAAC,MAAc,EAAE,QAAgB;IACjE,OAAO;QACL,KAAK,IAAA,2BAAU,EAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAA,2BAAU,EAAC,MAAM,CAAC,IAAI,IAAA,2BAAU,EAAC,QAAQ,CAAC,WAAW,2BAAmB,yBAAyB,IAAA,2BAAU,EAAC,uBAAe,CAAC,KAAK,yBAAiB,oBAAoB;QAC3M,MAAM;KACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}