@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,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.workspaceVersionPath = exports.packageVersionPath = exports.ReleaseError = void 0;
4
+ exports.isTable = isTable;
5
+ exports.parseManifest = parseManifest;
6
+ exports.crateVersion = crateVersion;
7
+ exports.workspaceVersion = workspaceVersion;
8
+ exports.dependencyEntries = dependencyEntries;
9
+ exports.tableName = tableName;
10
+ exports.patchEntries = patchEntries;
11
+ exports.replaceEntries = replaceEntries;
12
+ exports.profileSpecs = profileSpecs;
13
+ exports.parsePackageSpec = parsePackageSpec;
14
+ const smol_toml_1 = require("smol-toml");
15
+ /** Versioning cannot go on; the message says why and what to do. */
16
+ class ReleaseError extends Error {
17
+ constructor(message) {
18
+ super(message);
19
+ this.name = "ReleaseError";
20
+ }
21
+ }
22
+ exports.ReleaseError = ReleaseError;
23
+ /** Whether `value` is a TOML table. */
24
+ function isTable(value) {
25
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26
+ }
27
+ /**
28
+ * The manifest's text parsed.
29
+ *
30
+ * @param manifest The manifest's path, for the message.
31
+ * @throws {ReleaseError} When the text is no valid TOML.
32
+ */
33
+ function parseManifest(text, manifest) {
34
+ try {
35
+ return (0, smol_toml_1.parse)(text);
36
+ }
37
+ catch (error) {
38
+ throw new ReleaseError(`${manifest} is no valid TOML, so nx release version cannot read it: ${error.message.split("\n")[0]}. Correct the manifest and run the command again.`);
39
+ }
40
+ }
41
+ /** Where the crate whose parsed manifest is `manifest` takes its version from. */
42
+ function crateVersion(manifest) {
43
+ const version = isTable(manifest.package) ? manifest.package.version : undefined;
44
+ if (typeof version === "string") {
45
+ return { kind: "own", version };
46
+ }
47
+ if (isTable(version) && version.workspace === true) {
48
+ return { kind: "inherited" };
49
+ }
50
+ return { kind: "missing" };
51
+ }
52
+ /** The `[workspace.package].version` of a parsed root manifest, where it has one. */
53
+ function workspaceVersion(root) {
54
+ const workspace = isTable(root.workspace) ? root.workspace : undefined;
55
+ const version = isTable(workspace === null || workspace === void 0 ? void 0 : workspace.package) ? workspace.package.version : undefined;
56
+ return typeof version === "string" ? version : undefined;
57
+ }
58
+ /** The keys from the document root to `[package].version` and to `[workspace.package].version`. */
59
+ exports.packageVersionPath = ["package", "version"];
60
+ exports.workspaceVersionPath = ["workspace", "package", "version"];
61
+ const dependencyTables = [
62
+ ["dependencies", "normal"],
63
+ ["dev-dependencies", "dev"],
64
+ ["dev_dependencies", "dev"],
65
+ ["build-dependencies", "build"],
66
+ ["build_dependencies", "build"],
67
+ ];
68
+ /**
69
+ * Every entry of the dependency tables of a parsed manifest: those of each
70
+ * kind, under their old spellings with `_` too, their `[target.*]` forms,
71
+ * and `[workspace.dependencies]` where the manifest has it.
72
+ */
73
+ function dependencyEntries(manifest) {
74
+ const entries = [];
75
+ const add = (path, table, kind, target) => {
76
+ if (!isTable(table)) {
77
+ return;
78
+ }
79
+ for (const [key, value] of Object.entries(table)) {
80
+ const entry = typeof value === "string" ? { version: value } : isTable(value) ? value : {};
81
+ entries.push({ path: [...path, key], kind, target, key, entry });
82
+ }
83
+ };
84
+ for (const [name, kind] of dependencyTables) {
85
+ add([name], manifest[name], kind, null);
86
+ }
87
+ if (isTable(manifest.target)) {
88
+ for (const [platform, table] of Object.entries(manifest.target)) {
89
+ if (isTable(table)) {
90
+ for (const [name, kind] of dependencyTables) {
91
+ add(["target", platform, name], table[name], kind, platform);
92
+ }
93
+ }
94
+ }
95
+ }
96
+ if (isTable(manifest.workspace)) {
97
+ add(["workspace", "dependencies"], manifest.workspace.dependencies, "workspace", null);
98
+ }
99
+ return entries;
100
+ }
101
+ /** The table, as a header would name it, that holds the entry at `entry.path`. */
102
+ function tableName(entry) {
103
+ return entry.path
104
+ .slice(0, -1)
105
+ .map((key) => (/^[A-Za-z0-9_-]+$/.test(key) ? key : `'${key}'`))
106
+ .join(".");
107
+ }
108
+ /** Every entry of the `[patch.<source>]` tables of a parsed manifest or configuration file. */
109
+ function patchEntries(document) {
110
+ const entries = [];
111
+ if (isTable(document.patch)) {
112
+ for (const [source, table] of Object.entries(document.patch)) {
113
+ if (isTable(table)) {
114
+ for (const [key, entry] of Object.entries(table)) {
115
+ if (isTable(entry)) {
116
+ entries.push({ path: ["patch", source, key], source, key, entry });
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ return entries;
123
+ }
124
+ /** Every entry of the `[replace]` table of a parsed manifest. */
125
+ function replaceEntries(manifest) {
126
+ return isTable(manifest.replace)
127
+ ? Object.entries(manifest.replace)
128
+ .filter((entry) => isTable(entry[1]))
129
+ .map(([spec, entry]) => ({ spec, entry }))
130
+ : [];
131
+ }
132
+ /** Every package ID specification of the profiles' package tables of a parsed manifest or configuration file. */
133
+ function profileSpecs(document) {
134
+ const specs = [];
135
+ if (isTable(document.profile)) {
136
+ for (const [profile, table] of Object.entries(document.profile)) {
137
+ if (isTable(table) && isTable(table.package)) {
138
+ for (const spec of Object.keys(table.package)) {
139
+ specs.push({ profile, spec });
140
+ }
141
+ }
142
+ }
143
+ }
144
+ return specs;
145
+ }
146
+ /**
147
+ * The parts of a package ID specification, such as `base`, `base:0.1.0`,
148
+ * `base@0.1`, `https://github.com/rust-lang/crates.io-index#base@0.1.0` or
149
+ * `path+file:///repo/crates/base#0.1.0`, where the name is the URL's last
150
+ * segment. `undefined` for `*` and other forms that name no package.
151
+ */
152
+ function parsePackageSpec(spec) {
153
+ var _a, _b;
154
+ const hash = spec.indexOf("#");
155
+ const url = hash === -1 ? undefined : spec.slice(0, hash);
156
+ const rest = hash === -1 ? spec : spec.slice(hash + 1);
157
+ const match = (_a = /^([A-Za-z0-9_-]+)?(?:[@:]([0-9][^@:]*))?$/.exec(rest)) !== null && _a !== void 0 ? _a : /^()([0-9][^@:]*)$/.exec(rest);
158
+ if (match === null) {
159
+ return undefined;
160
+ }
161
+ const name = match[1] || (url === undefined ? "" : ((_b = url.replace(/\/+$/, "").split("/").pop()) !== null && _b !== void 0 ? _b : ""));
162
+ return name === "" ? undefined : { url, name, version: match[2] || undefined };
163
+ }
164
+ //# sourceMappingURL=manifests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifests.js","sourceRoot":"","sources":["../../../../nx-rust/src/release/manifests.ts"],"names":[],"mappings":";;;AAcA,0BAEC;AAQD,sCAQC;AAaD,oCASC;AAGD,4CAIC;AAiCD,8CAgCC;AAGD,8BAKC;AAcD,oCAcC;AASD,wCAMC;AASD,oCAYC;AAQD,4CAcC;AA5ND,yCAAkC;AAKlC,oEAAoE;AACpE,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,uCAAuC;AACvC,SAAgB,OAAO,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,QAAgB;IAC1D,IAAI,CAAC;QACH,OAAO,IAAA,iBAAK,EAAC,IAAI,CAAc,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,YAAY,CACpB,GAAG,QAAQ,4DAA6D,KAAe,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,mDAAmD,CAClK,CAAC;IACJ,CAAC;AACH,CAAC;AAYD,kFA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aseCrate, ReleaseRepository, ReleaseWorkspace } from "./repository";
4
+ /** A version requirement that names a crate by path, wherever cargo reads one. */
5
+ export interface Requirement {
6
+ /**
7
+ * The file that holds it: relative to the repository root with `/` inside
8
+ * the repository, absolute outside it.
9
+ */
10
+ file: string;
11
+ /** Whether the file lies inside the repository, where the version actions may write it. */
12
+ inRepository: boolean;
13
+ /** The table that holds the entry, as a header would name it, such as `target.'cfg(unix)'.dependencies`. */
14
+ table: string;
15
+ /** The keys from the document root to the requirement's string. */
16
+ versionPath: string[];
17
+ requirement: string;
18
+ /** `patch` for a `[patch.<source>]` entry, which never makes a dependent. */
19
+ kind: "normal" | "dev" | "build" | "workspace" | "patch";
20
+ /** The entry's key. */
21
+ key: string;
22
+ /** The workspace whose manifest or configuration holds it. */
23
+ workspace: ReleaseWorkspace;
24
+ /** The member whose manifest holds it, for the entry of a member's dependency table. */
25
+ holder?: ReleaseCrate;
26
+ }
27
+ /**
28
+ * Every version requirement on `crate` that names it by the real path of
29
+ * its folder (`DES-RELEASE`, "Requirements"): in the dependency tables of
30
+ * every kind of every member of the repository's workspaces and their
31
+ * `[target.*]` forms, in each root manifest's `[workspace.dependencies]` and
32
+ * `[patch.<source>]` tables, and in the `[patch.<source>]` tables of the
33
+ * Cargo configuration files that cargo reads for each workspace, inside
34
+ * the repository or not. Cargo ignores `[patch]` in a member's manifest, and
35
+ * so do the version actions.
36
+ */
37
+ export declare function requirementsOn(tree: Tree, repository: ReleaseRepository, crate: ReleaseCrate): Requirement[];
38
+ /**
39
+ * The reasons why `crate` cannot get `newVersion` that no rewritten
40
+ * requirement removes (`DES-RELEASE`, "Requirements"), each as a line for
41
+ * the message:
42
+ *
43
+ * - a `[replace]` entry that replaces a package with the crate's folder:
44
+ * cargo takes a replacement only with the version that it replaces, and
45
+ * fails after the bump, while an entry with the new version would be left
46
+ * unused (`EVD-CARGO-PATCH-AFTER-BUMP`);
47
+ * - a registry or git requirement that a `[patch]` entry naming the crate
48
+ * by path redirects to it, which the old version satisfies and the new one
49
+ * does not: cargo would then take the package from the registry instead,
50
+ * without an error (`EVD-CARGO-PATCH-AFTER-BUMP`);
51
+ * - a profile's package table whose specification names the crate with a
52
+ * version that the new one does not match: cargo would only warn, and the
53
+ * profile's settings would stop applying to the crate.
54
+ */
55
+ export declare function blockers(tree: Tree, repository: ReleaseRepository, crate: ReleaseCrate, newVersion: string): string[];
56
+ /**
57
+ * A manifest or configuration file as the run sees it: through the run's
58
+ * tree inside the repository ({@link readTreeText}), from disk outside it.
59
+ *
60
+ * @param file Relative to the repository root, or absolute outside it.
61
+ * @throws {ReleaseError} When the file does not exist or cannot be read,
62
+ * saying which.
63
+ */
64
+ export declare function readDocument(tree: Tree, repository: ReleaseRepository, file: string): TomlTable;
65
+ /**
66
+ * The path by which the run reads and writes a file inside the repository
67
+ * in Nx's tree: where the file lies once symbolic links are followed,
68
+ * relative to the real path of the repository root, with `/`. Nx stages the
69
+ * paths that its tree changed, and git keeps a link apart from the file it
70
+ * leads to, so a write through the path of a link would change the file
71
+ * without putting it into the commit (`DES-RELEASE`, "Writes"). A file that
72
+ * lies outside the repository, which the run does not write, keeps its path.
73
+ *
74
+ * @param file Relative to the repository root.
75
+ */
76
+ export declare function treePath(root: string, file: string): string;
77
+ /**
78
+ * The text of a file inside the repository, as the run's tree holds it at
79
+ * the file's {@link treePath}.
80
+ *
81
+ * @param file Relative to the repository root.
82
+ * @throws {ReleaseError} When the file does not exist or cannot be read,
83
+ * saying which: Nx's tree answers `null` for every file that it cannot
84
+ * read, so the file is read from disk once more to tell.
85
+ */
86
+ export declare function readTreeText(tree: Tree, file: string): string;
87
+ /**
88
+ * Whether a failure to read a file says that the file does not exist. Every
89
+ * other failure, such as a missing permission, says nothing about whether
90
+ * it exists.
91
+ */
92
+ export declare function isAbsence(error: unknown): boolean;
93
+ /** The message of an error, also of one from another realm, as Node's own errors are under Jest. */
94
+ export declare function errorMessage(error: unknown): string;
95
+ /** An entry of a member's dependency tables, with what it names and writes, its own or inherited. */
96
+ export interface MemberEntry extends DependencyEntry {
97
+ /** The real path of the folder it names, its own or that of the `[workspace.dependencies]` entry it inherits. */
98
+ folder?: string;
99
+ /** Its version requirement, its own or that of the entry it inherits. */
100
+ requirement?: string;
101
+ /** The name of the registry it asks, its own `registry` or that of the entry it inherits. */
102
+ registry?: string;
103
+ }
104
+ /**
105
+ * The entries of a member's dependency tables, each with the folder that it
106
+ * names, the requirement that it writes and the registry that it names, in
107
+ * itself or in the `[workspace.dependencies]` entry of the same key that it
108
+ * inherits.
109
+ */
110
+ export declare function memberEntries(tree: Tree, repository: ReleaseRepository, crate: ReleaseCrate): MemberEntry[];
111
+ /**
112
+ * Where a file that the run would write lies, links followed, where that is
113
+ * outside the repository: the real path of the file, or of the deepest
114
+ * folder of it that exists, compared with the real path of the repository
115
+ * root (`DES-RELEASE`, "Writes"). `undefined` inside.
116
+ *
117
+ * @param file Relative to the repository root.
118
+ */
119
+ export declare function outsideDestination(root: string, file: string): string | undefined;
120
+ /**
121
+ * A source as cargo compares a `[patch]` key with it: `crates-io` for
122
+ * crates.io, otherwise the URL of the git repository or of the registry's
123
+ * index without query, fragment, trailing slashes and `.git`, keeping
124
+ * `sparse+` for a sparse index, because a plain URL does not name a sparse
125
+ * registry for cargo (`EVD-CARGO-PATCH-AFTER-BUMP`).
126
+ */
127
+ export declare function sourceKey(source: string): string;
@@ -0,0 +1,368 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requirementsOn = requirementsOn;
4
+ exports.blockers = blockers;
5
+ exports.readDocument = readDocument;
6
+ exports.treePath = treePath;
7
+ exports.readTreeText = readTreeText;
8
+ exports.isAbsence = isAbsence;
9
+ exports.errorMessage = errorMessage;
10
+ exports.memberEntries = memberEntries;
11
+ exports.outsideDestination = outsideDestination;
12
+ exports.sourceKey = sourceKey;
13
+ const node_fs_1 = require("node:fs");
14
+ const node_path_1 = require("node:path");
15
+ const node_url_1 = require("node:url");
16
+ const version_req_1 = require("../cargo/version-req");
17
+ const real_path_1 = require("../graph/real-path");
18
+ const manifests_1 = require("./manifests");
19
+ const repository_1 = require("./repository");
20
+ /**
21
+ * Every version requirement on `crate` that names it by the real path of
22
+ * its folder (`DES-RELEASE`, "Requirements"): in the dependency tables of
23
+ * every kind of every member of the repository's workspaces and their
24
+ * `[target.*]` forms, in each root manifest's `[workspace.dependencies]` and
25
+ * `[patch.<source>]` tables, and in the `[patch.<source>]` tables of the
26
+ * Cargo configuration files that cargo reads for each workspace, inside
27
+ * the repository or not. Cargo ignores `[patch]` in a member's manifest, and
28
+ * so do the version actions.
29
+ */
30
+ // @mara implements DES-RELEASE
31
+ function requirementsOn(tree, repository, crate) {
32
+ const requirements = [];
33
+ const add = (file, base, workspace, entry, kind, holder) => {
34
+ const { path, version } = entry.entry;
35
+ if (typeof path !== "string" || typeof version !== "string") {
36
+ return;
37
+ }
38
+ if ((0, real_path_1.realPath)((0, node_path_1.resolve)(base, path)) !== crate.folder) {
39
+ return;
40
+ }
41
+ const inRepository = !isOutside(file);
42
+ requirements.push({
43
+ file,
44
+ inRepository,
45
+ table: (0, manifests_1.tableName)({ path: entry.path }),
46
+ versionPath: [...entry.path, "version"],
47
+ requirement: version,
48
+ kind,
49
+ key: entry.key,
50
+ workspace,
51
+ holder,
52
+ });
53
+ };
54
+ const crates = repository.workspaces.flatMap((workspace) => workspace.crates);
55
+ for (const workspace of repository.workspaces) {
56
+ const manifests = [
57
+ workspace.rootManifest,
58
+ ...workspace.crates
59
+ .map((member) => member.manifest)
60
+ .filter((manifest) => !isOutside(manifest)),
61
+ ];
62
+ for (const manifest of new Set(manifests)) {
63
+ const document = readDocument(tree, repository, manifest);
64
+ const base = (0, node_path_1.dirname)((0, node_path_1.join)(repository.root, manifest));
65
+ const holder = crates.find((candidate) => candidate.manifest === manifest);
66
+ for (const entry of (0, manifests_1.dependencyEntries)(document)) {
67
+ add(manifest, base, workspace, entry, entry.kind, entry.kind === "workspace" ? undefined : holder);
68
+ }
69
+ if (manifest === workspace.rootManifest) {
70
+ for (const entry of (0, manifests_1.patchEntries)(document)) {
71
+ add(manifest, base, workspace, entry, "patch");
72
+ }
73
+ }
74
+ }
75
+ }
76
+ for (const [file, workspace] of configFilesOf(repository)) {
77
+ const relativeFile = (0, repository_1.repositoryPath)(repository.root, file);
78
+ const document = readDocument(tree, repository, relativeFile);
79
+ for (const entry of (0, manifests_1.patchEntries)(document)) {
80
+ add(isOutside(relativeFile) ? file : relativeFile, (0, node_path_1.dirname)((0, node_path_1.dirname)(file)), workspace, entry, "patch");
81
+ }
82
+ }
83
+ return requirements;
84
+ }
85
+ /**
86
+ * The reasons why `crate` cannot get `newVersion` that no rewritten
87
+ * requirement removes (`DES-RELEASE`, "Requirements"), each as a line for
88
+ * the message:
89
+ *
90
+ * - a `[replace]` entry that replaces a package with the crate's folder:
91
+ * cargo takes a replacement only with the version that it replaces, and
92
+ * fails after the bump, while an entry with the new version would be left
93
+ * unused (`EVD-CARGO-PATCH-AFTER-BUMP`);
94
+ * - a registry or git requirement that a `[patch]` entry naming the crate
95
+ * by path redirects to it, which the old version satisfies and the new one
96
+ * does not: cargo would then take the package from the registry instead,
97
+ * without an error (`EVD-CARGO-PATCH-AFTER-BUMP`);
98
+ * - a profile's package table whose specification names the crate with a
99
+ * version that the new one does not match: cargo would only warn, and the
100
+ * profile's settings would stop applying to the crate.
101
+ */
102
+ // @mara implements DES-RELEASE
103
+ function blockers(tree, repository, crate, newVersion) {
104
+ const lines = [];
105
+ const names = (spec) => spec !== undefined &&
106
+ spec.name === crate.name &&
107
+ (spec.url === undefined ||
108
+ (/^(path\+)?file:\/\//.test(spec.url) &&
109
+ (0, real_path_1.realPath)((0, node_url_1.fileURLToPath)(spec.url.replace(/^path\+/, ""))) === crate.folder));
110
+ const matchedBefore = (version) => (0, version_req_1.satisfies)(`=${version}`, crate.version) === true;
111
+ const matchesNew = (version) => (0, version_req_1.satisfies)(`=${version}`, newVersion) === true;
112
+ for (const workspace of repository.workspaces) {
113
+ // The files whose [patch] and [profile] tables cargo applies to the
114
+ // workspace: its root manifest and the configuration files it reads.
115
+ const files = [
116
+ {
117
+ file: workspace.rootManifest,
118
+ base: (0, node_path_1.dirname)((0, node_path_1.join)(repository.root, workspace.rootManifest)),
119
+ },
120
+ ...workspace.configFiles.map((file) => ({
121
+ file: (0, repository_1.repositoryPath)(repository.root, file),
122
+ base: (0, node_path_1.dirname)((0, node_path_1.dirname)(file)),
123
+ })),
124
+ ];
125
+ const root = readDocument(tree, repository, workspace.rootManifest);
126
+ for (const { spec, entry } of (0, manifests_1.replaceEntries)(root)) {
127
+ const parsed = (0, manifests_1.parsePackageSpec)(spec);
128
+ if (typeof entry.path === "string" &&
129
+ (0, real_path_1.realPath)((0, node_path_1.resolve)(repository.root, (0, node_path_1.dirname)(workspace.rootManifest), entry.path)) ===
130
+ crate.folder &&
131
+ ((parsed === null || parsed === void 0 ? void 0 : parsed.version) === undefined || !matchesNew(parsed.version))) {
132
+ lines.push(`- [replace] "${spec}" in ${workspace.rootManifest} replaces a package with the folder of ${crate.name}, and cargo takes a replacement only with the version that it replaces, which ${newVersion} is not: write it as a [patch] entry, which nx release version keeps up to date, or leave ${crate.name} out of the release`);
133
+ }
134
+ }
135
+ for (const { file, base } of files) {
136
+ for (const patch of (0, manifests_1.patchEntries)(readDocument(tree, repository, file))) {
137
+ const path = patch.entry.path;
138
+ if (typeof path !== "string" || (0, real_path_1.realPath)((0, node_path_1.resolve)(base, path)) !== crate.folder) {
139
+ continue;
140
+ }
141
+ const patched = typeof patch.entry.package === "string" ? patch.entry.package : patch.key;
142
+ for (const member of workspace.crates) {
143
+ for (const dependency of member.dependencies) {
144
+ if (dependency.source !== null &&
145
+ dependency.path === undefined &&
146
+ dependency.name === crate.name &&
147
+ patched === crate.name &&
148
+ patchApplies(tree, repository, workspace, member, patch.source, dependency) &&
149
+ (0, version_req_1.satisfies)(dependency.req, crate.version) === true &&
150
+ (0, version_req_1.satisfies)(dependency.req, newVersion) !== true) {
151
+ lines.push(`- the requirement "${dependency.req}" of ${member.name} on ${crate.name} from ${patch.source}, in ${member.manifest}, which the [patch] entry in ${file} redirects to ${crate.name}'s folder, does not accept ${newVersion}, so cargo would take ${crate.name} from the registry instead: give the dependency a path, which nx release version keeps up to date, or change the requirement so that it accepts ${newVersion}`);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ for (const { file } of files) {
158
+ for (const { profile, spec } of (0, manifests_1.profileSpecs)(readDocument(tree, repository, file))) {
159
+ const parsed = (0, manifests_1.parsePackageSpec)(spec);
160
+ if (names(parsed) &&
161
+ (parsed === null || parsed === void 0 ? void 0 : parsed.version) !== undefined &&
162
+ matchedBefore(parsed.version) &&
163
+ !matchesNew(parsed.version)) {
164
+ lines.push(`- [profile.${profile}.package."${spec}"] in ${file} names ${crate.name} ${parsed.version}, which ${newVersion} does not match, so the profile's settings would stop applying to it: write the specification without its version, as [profile.${profile}.package.${crate.name}]`);
165
+ }
166
+ }
167
+ }
168
+ }
169
+ return [...new Set(lines)];
170
+ }
171
+ /** Each configuration file of the repository's workspaces once, with the first workspace that reads it. */
172
+ function configFilesOf(repository) {
173
+ const files = new Map();
174
+ for (const workspace of repository.workspaces) {
175
+ for (const file of workspace.configFiles) {
176
+ if (!files.has(file)) {
177
+ files.set(file, workspace);
178
+ }
179
+ }
180
+ }
181
+ return files;
182
+ }
183
+ // Whether a path relative to the repository root leads outside it.
184
+ function isOutside(path) {
185
+ return path === ".." || path.startsWith("../") || path.startsWith("/");
186
+ }
187
+ /**
188
+ * A manifest or configuration file as the run sees it: through the run's
189
+ * tree inside the repository ({@link readTreeText}), from disk outside it.
190
+ *
191
+ * @param file Relative to the repository root, or absolute outside it.
192
+ * @throws {ReleaseError} When the file does not exist or cannot be read,
193
+ * saying which.
194
+ */
195
+ function readDocument(tree, repository, file) {
196
+ if (!isOutside(file)) {
197
+ return (0, manifests_1.parseManifest)(readTreeText(tree, file), file);
198
+ }
199
+ let text;
200
+ try {
201
+ text = (0, node_fs_1.readFileSync)(file.startsWith("/") ? file : (0, node_path_1.join)(repository.root, file), "utf8");
202
+ }
203
+ catch (error) {
204
+ throw readFailure(file, error);
205
+ }
206
+ return (0, manifests_1.parseManifest)(text, file);
207
+ }
208
+ /**
209
+ * The path by which the run reads and writes a file inside the repository
210
+ * in Nx's tree: where the file lies once symbolic links are followed,
211
+ * relative to the real path of the repository root, with `/`. Nx stages the
212
+ * paths that its tree changed, and git keeps a link apart from the file it
213
+ * leads to, so a write through the path of a link would change the file
214
+ * without putting it into the commit (`DES-RELEASE`, "Writes"). A file that
215
+ * lies outside the repository, which the run does not write, keeps its path.
216
+ *
217
+ * @param file Relative to the repository root.
218
+ */
219
+ function treePath(root, file) {
220
+ if (isOutside(file)) {
221
+ return file;
222
+ }
223
+ const real = (0, node_path_1.relative)((0, real_path_1.realPath)(root), (0, real_path_1.physicalPath)((0, node_path_1.join)(root, file)));
224
+ return real === "" || real === ".." || real.startsWith(`..${node_path_1.sep}`) || (0, node_path_1.isAbsolute)(real)
225
+ ? file
226
+ : real.split(node_path_1.sep).join("/");
227
+ }
228
+ /**
229
+ * The text of a file inside the repository, as the run's tree holds it at
230
+ * the file's {@link treePath}.
231
+ *
232
+ * @param file Relative to the repository root.
233
+ * @throws {ReleaseError} When the file does not exist or cannot be read,
234
+ * saying which: Nx's tree answers `null` for every file that it cannot
235
+ * read, so the file is read from disk once more to tell.
236
+ */
237
+ function readTreeText(tree, file) {
238
+ const path = treePath(tree.root, file);
239
+ const text = tree.read(path, "utf-8");
240
+ if (text !== null) {
241
+ return text;
242
+ }
243
+ try {
244
+ (0, node_fs_1.readFileSync)((0, node_path_1.join)(tree.root, path));
245
+ }
246
+ catch (error) {
247
+ throw readFailure(file, error);
248
+ }
249
+ throw new manifests_1.ReleaseError(`nx release version cannot read ${file} through Nx's tree, although the file can be read. Run nx reset and the command again.`);
250
+ }
251
+ /**
252
+ * Whether a failure to read a file says that the file does not exist. Every
253
+ * other failure, such as a missing permission, says nothing about whether
254
+ * it exists.
255
+ */
256
+ function isAbsence(error) {
257
+ const code = error === null || error === void 0 ? void 0 : error.code;
258
+ return code === "ENOENT" || code === "ENOTDIR";
259
+ }
260
+ // The error for a file that the run cannot read: that it does not exist only
261
+ // where reading it says so, and otherwise why it cannot be read.
262
+ function readFailure(file, error) {
263
+ return isAbsence(error)
264
+ ? new manifests_1.ReleaseError(`${file} does not exist, so nx release version cannot read it. Run nx reset and the command again.`)
265
+ : new manifests_1.ReleaseError(`nx release version cannot read ${file}: ${errorMessage(error)}. Make it readable and run the command again.`);
266
+ }
267
+ /** The message of an error, also of one from another realm, as Node's own errors are under Jest. */
268
+ function errorMessage(error) {
269
+ const message = error === null || error === void 0 ? void 0 : error.message;
270
+ return typeof message === "string" ? message : String(error);
271
+ }
272
+ /**
273
+ * The entries of a member's dependency tables, each with the folder that it
274
+ * names, the requirement that it writes and the registry that it names, in
275
+ * itself or in the `[workspace.dependencies]` entry of the same key that it
276
+ * inherits.
277
+ */
278
+ function memberEntries(tree, repository, crate) {
279
+ const rootManifest = crate.workspace.rootManifest;
280
+ const inherited = new Map((0, manifests_1.dependencyEntries)(readDocument(tree, repository, rootManifest))
281
+ .filter((entry) => entry.kind === "workspace")
282
+ .map((entry) => [entry.key, entry]));
283
+ return (0, manifests_1.dependencyEntries)(readDocument(tree, repository, crate.manifest))
284
+ .filter((entry) => entry.kind !== "workspace")
285
+ .map((entry) => {
286
+ var _a;
287
+ const [source, manifest] = entry.entry.workspace === true
288
+ ? [inherited.get(entry.key), rootManifest]
289
+ : [entry, crate.manifest];
290
+ const { path, version, registry } = (_a = source === null || source === void 0 ? void 0 : source.entry) !== null && _a !== void 0 ? _a : {};
291
+ return Object.assign(Object.assign({}, entry), { folder: typeof path === "string"
292
+ ? (0, real_path_1.realPath)((0, node_path_1.resolve)(repository.root, (0, node_path_1.dirname)(manifest), path))
293
+ : undefined, requirement: typeof version === "string" ? version : undefined, registry: typeof registry === "string" ? registry : undefined });
294
+ });
295
+ }
296
+ /**
297
+ * Where a file that the run would write lies, links followed, where that is
298
+ * outside the repository: the real path of the file, or of the deepest
299
+ * folder of it that exists, compared with the real path of the repository
300
+ * root (`DES-RELEASE`, "Writes"). `undefined` inside.
301
+ *
302
+ * @param file Relative to the repository root.
303
+ */
304
+ function outsideDestination(root, file) {
305
+ const destination = (0, real_path_1.realPath)((0, node_path_1.join)(root, file));
306
+ const inside = (0, node_path_1.relative)((0, real_path_1.realPath)(root), destination);
307
+ return inside === "" || (!inside.startsWith("..") && !(0, node_path_1.isAbsolute)(inside))
308
+ ? undefined
309
+ : destination;
310
+ }
311
+ /**
312
+ * A source as cargo compares a `[patch]` key with it: `crates-io` for
313
+ * crates.io, otherwise the URL of the git repository or of the registry's
314
+ * index without query, fragment, trailing slashes and `.git`, keeping
315
+ * `sparse+` for a sparse index, because a plain URL does not name a sparse
316
+ * registry for cargo (`EVD-CARGO-PATCH-AFTER-BUMP`).
317
+ */
318
+ function sourceKey(source) {
319
+ const kind = /^(registry|sparse|git)\+/.exec(source);
320
+ let url = kind === null ? source : source.slice(kind[0].length);
321
+ const end = url.search(/[?#]/);
322
+ url = (end === -1 ? url : url.slice(0, end)).replace(/\/+$/, "").replace(/\.git$/, "");
323
+ const key = `${(kind === null || kind === void 0 ? void 0 : kind[1]) === "sparse" ? "sparse+" : ""}${url}`;
324
+ return key === "https://github.com/rust-lang/crates.io-index" ||
325
+ key === "sparse+https://index.crates.io"
326
+ ? "crates-io"
327
+ : key;
328
+ }
329
+ // Whether the `[patch.<source>]` table of `source` applies to a registry or
330
+ // git dependency of `member`: `crates-io`, a URL, or a registry's name, which
331
+ // the Cargo configuration of the workspace or `CARGO_REGISTRIES_<NAME>_INDEX`
332
+ // maps to its index. A registry's name also applies where the dependency's
333
+ // entry names that registry.
334
+ function patchApplies(tree, repository, workspace, member, source, dependency) {
335
+ var _a, _b, _c;
336
+ const dependencySource = sourceKey((_a = dependency.source) !== null && _a !== void 0 ? _a : "");
337
+ if (source === "crates-io" || source.includes("://")) {
338
+ return sourceKey(source) === dependencySource;
339
+ }
340
+ const index = registryIndex(tree, repository, workspace, source);
341
+ if (index !== undefined && sourceKey(index) === dependencySource) {
342
+ return true;
343
+ }
344
+ const kind = (_b = dependency.kind) !== null && _b !== void 0 ? _b : "normal";
345
+ const key = (_c = dependency.rename) !== null && _c !== void 0 ? _c : dependency.name;
346
+ return memberEntries(tree, repository, member).some((entry) => entry.kind === kind &&
347
+ entry.key === key &&
348
+ entry.folder === undefined &&
349
+ entry.registry === source);
350
+ }
351
+ // The index of the registry `name`, as cargo finds it for the workspace:
352
+ // `CARGO_REGISTRIES_<NAME>_INDEX`, or `[registries.<name>].index` in the
353
+ // first of the workspace's configuration files that sets it.
354
+ function registryIndex(tree, repository, workspace, name) {
355
+ const variable = process.env[`CARGO_REGISTRIES_${name.toUpperCase().replace(/-/g, "_")}_INDEX`];
356
+ if (variable) {
357
+ return variable;
358
+ }
359
+ for (const file of workspace.configFiles) {
360
+ const document = readDocument(tree, repository, (0, repository_1.repositoryPath)(repository.root, file));
361
+ const registry = (0, manifests_1.isTable)(document.registries) ? document.registries[name] : undefined;
362
+ if ((0, manifests_1.isTable)(registry) && typeof registry.index === "string") {
363
+ return registry.index;
364
+ }
365
+ }
366
+ return undefined;
367
+ }
368
+ //# sourceMappingURL=places.js.map