@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,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkVersionedTogether = checkVersionedTogether;
4
+ exports.graphBumpLines = graphBumpLines;
5
+ exports.checkDependentsVersioned = checkDependentsVersioned;
6
+ exports.isOn = isOn;
7
+ exports.writesRequirement = writesRequirement;
8
+ exports.inheritingCrates = inheritingCrates;
9
+ exports.writable = writable;
10
+ exports.editedFile = editedFile;
11
+ exports.sentenceList = sentenceList;
12
+ const node_fs_1 = require("node:fs");
13
+ const real_path_1 = require("../graph/real-path");
14
+ const manifests_1 = require("./manifests");
15
+ const places_1 = require("./places");
16
+ const toml_edit_1 = require("./toml-edit");
17
+ // Fails where the run versions only some of the crates that share the inherited version.
18
+ function checkVersionedTogether(projects, crate, sharing) {
19
+ const left = sharing.filter((other) => other.project === undefined || !projects.has(other.project));
20
+ if (left.length > 0) {
21
+ const versioned = sharing.filter((other) => !left.includes(other));
22
+ throw new manifests_1.ReleaseError(`nx release version would version ${sentenceList(versioned.map((other) => other.name))} but not ${sentenceList(left.map((other) => other.name))}, although they inherit version.workspace = true from ${crate.workspace.rootManifest} and share one version. Nx adds a crate to a run as a dependent of a crate in another release group without the rest of its group: run the command for their whole release group as well, such as with --groups naming it, or without --projects and --groups.`);
23
+ }
24
+ }
25
+ // The lines that name the edges of the project graph through which Nx
26
+ // bumps this project's fixed group: those into a project of another
27
+ // release group in which the run has written a new version.
28
+ function graphBumpLines(project, group, versioned, graph, repository, groupOf) {
29
+ var _a;
30
+ const bumpedGroups = new Set([...versioned].map(groupOf));
31
+ const edges = ((_a = graph.dependencies[project]) !== null && _a !== void 0 ? _a : []).filter((edge) => {
32
+ const target = groupOf(edge.target);
33
+ return target !== undefined && target !== group && bumpedGroups.has(target);
34
+ });
35
+ if (edges.length === 0) {
36
+ return [
37
+ `⚠️ Nx bumps the fixed release group "${group}" as a whole, because ${project} has an edge in the project graph to a project of a release group that it bumped before; nx-rust's guide lists this as a known limit of Nx release.`,
38
+ ];
39
+ }
40
+ return [...new Set(edges.map((edge) => edge.target))].map((target) => `⚠️ Nx bumps the fixed release group "${group}" as a whole, because the project graph has an edge from ${project} to ${target}, whose release group "${groupOf(target)}" it bumped before. ${edgeInCargo(repository, project, target)} nx-rust's guide lists this as a known limit of Nx release.`);
41
+ }
42
+ // What the edge between two crates' projects is in Cargo, as a sentence.
43
+ function edgeInCargo(repository, source, target) {
44
+ const from = repository === null || repository === void 0 ? void 0 : repository.crateOfProject(source);
45
+ const to = repository === null || repository === void 0 ? void 0 : repository.crateOfProject(target);
46
+ if (from === undefined || to === undefined) {
47
+ return "";
48
+ }
49
+ const uses = from.dependencies.filter((dependency) => dependency.path !== undefined && (0, real_path_1.realPath)(dependency.path) === to.folder);
50
+ if (uses.length === 0) {
51
+ return `In Cargo, ${from.name} names ${to.name} in no dependency: nx-rust adds the edge for the cache key, as through a crate without a project or a [patch].`;
52
+ }
53
+ const kinds = [
54
+ ...new Set(uses.map((dependency) => dependency.kind === "dev"
55
+ ? "a dev-dependency"
56
+ : `a ${dependency.kind === "build" ? "build" : "normal"} dependency`)),
57
+ ];
58
+ return `In Cargo, ${from.name} depends on ${to.name} through ${sentenceList(kinds)}.`;
59
+ }
60
+ // Stops the run where a crate of the release would get a rewritten
61
+ // requirement on a bumped crate without a new version (nxr-5a9w1y, part 2).
62
+ function checkDependentsVersioned(tree, repository, rewrites, versioned, groupOf) {
63
+ const lines = new Set();
64
+ for (const { requirement, crate, to } of rewrites) {
65
+ if (requirement.kind !== "normal" &&
66
+ requirement.kind !== "build" &&
67
+ requirement.kind !== "workspace") {
68
+ continue;
69
+ }
70
+ // A [workspace.dependencies] entry is the requirement of each member
71
+ // that inherits it in a normal or build table.
72
+ const holders = requirement.kind === "workspace"
73
+ ? requirement.workspace.crates.filter((member) => (0, places_1.memberEntries)(tree, repository, member).some((entry) => (entry.kind === "normal" || entry.kind === "build") &&
74
+ entry.entry.workspace === true &&
75
+ entry.key === requirement.key))
76
+ : requirement.holder === undefined
77
+ ? []
78
+ : [requirement.holder];
79
+ for (const holder of holders) {
80
+ const group = groupOf(holder.project);
81
+ if (holder.project === undefined || group === undefined || versioned.has(holder.project)) {
82
+ continue;
83
+ }
84
+ lines.add(`- ${holder.name}, in the release group "${group}": its requirement on ${crate.name} in ${requirement.file} [${requirement.table}] becomes "${to}", but Nx gives ${holder.name} no new version`);
85
+ }
86
+ }
87
+ if (lines.size > 0) {
88
+ throw new manifests_1.ReleaseError([
89
+ "nx release version would rewrite requirements of crates in the release on crates that it bumps, without bumping those crates:",
90
+ ...lines,
91
+ "Release each of them in the same run: give it a bump of its own, through a version plan or a conventional commit, or name a version on the command line, which applies to every crate of the run. Nx bumps no crate of an independent group for a dependency in a fixed group. No file has been changed.",
92
+ ].join("\n"));
93
+ }
94
+ }
95
+ // The setting is on as `true`, and as a list, which names npm's dependency
96
+ // collections and so means nothing more specific for a crate, while it is
97
+ // not empty.
98
+ function isOn(setting) {
99
+ return Array.isArray(setting) ? setting.length > 0 : setting === true;
100
+ }
101
+ // Whether the manifest's entries for a dependency whose report gives the
102
+ // requirement `*` write a version: the entries of its kind and key that
103
+ // name its folder, in any target table, however the table's header spells
104
+ // the platform. Fails where the manifest has no such entry.
105
+ function writesRequirement(tree, repository, crate, dependency) {
106
+ var _a, _b;
107
+ const kind = dependency.kind === "build" ? "build" : "normal";
108
+ const key = (_a = dependency.rename) !== null && _a !== void 0 ? _a : dependency.name;
109
+ const folder = (0, real_path_1.realPath)((_b = dependency.path) !== null && _b !== void 0 ? _b : "");
110
+ const entries = (0, places_1.memberEntries)(tree, repository, crate).filter((entry) => entry.kind === kind && entry.key === key && entry.folder === folder);
111
+ if (entries.length === 0) {
112
+ throw new manifests_1.ReleaseError(`cargo reports that ${crate.name} depends on the crate in ${dependency.path} as ${key}, but nx release version finds no such entry in ${crate.manifest} to tell whether it writes a version requirement. Run nx reset and the command again; if this stays, report the manifest to nx-rust.`);
113
+ }
114
+ return entries.some((entry) => entry.requirement !== undefined);
115
+ }
116
+ // The members of the crate's workspace that inherit their version, the crate among them.
117
+ function inheritingCrates(tree, repository, crate) {
118
+ return crate.workspace.crates.filter((other) => other === crate ||
119
+ (0, manifests_1.crateVersion)((0, places_1.readDocument)(tree, repository, other.manifest)).kind === "inherited");
120
+ }
121
+ // Whether the file at `path` exists and the run may write it.
122
+ function writable(path) {
123
+ try {
124
+ (0, node_fs_1.accessSync)(path, node_fs_1.constants.W_OK);
125
+ return true;
126
+ }
127
+ catch (_a) {
128
+ return false;
129
+ }
130
+ }
131
+ // The file with the edits made, read at its tree path (`treePath`).
132
+ function editedFile(tree, file, edits) {
133
+ const text = (0, places_1.readTreeText)(tree, file);
134
+ try {
135
+ return (0, toml_edit_1.replaceStrings)(text, edits);
136
+ }
137
+ catch (error) {
138
+ if (!(error instanceof toml_edit_1.TomlEditError)) {
139
+ throw error;
140
+ }
141
+ throw new manifests_1.ReleaseError(`nx release version could not change the version strings in ${file} without changing anything else of it: ${error.message}. No file has been changed; change the versions by hand, and report the file to nx-rust.`);
142
+ }
143
+ }
144
+ // "a", "a and b", "a, b and c".
145
+ function sentenceList(items) {
146
+ var _a;
147
+ return items.length <= 1
148
+ ? ((_a = items[0]) !== null && _a !== void 0 ? _a : "")
149
+ : `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
150
+ }
151
+ //# sourceMappingURL=version-checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-checks.js","sourceRoot":"","sources":["../../../../nx-rust/src/release/version-checks.ts"],"names":[],"mappings":";;AAkBA,wDAcC;AAKD,wCAsBC;A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E,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { Tree } from "@nx/devkit";
2
+ import { type ReleaseCrate, type ReleaseRepository, type ReleaseWorkspace } from "./repository";
3
+ /** A package that a lockfile locks. */
4
+ interface LockedPackage {
5
+ name?: unknown;
6
+ version?: unknown;
7
+ source?: unknown;
8
+ }
9
+ /** A lockfile as the run read it before it changed anything. */
10
+ export type LockfileState = {
11
+ kind: "absent";
12
+ } | {
13
+ kind: "unreadable";
14
+ reason: string;
15
+ } | {
16
+ kind: "read";
17
+ packages: LockedPackage[];
18
+ };
19
+ /** The lockfile state that a version run records for `afterAllProjectsVersioned`. */
20
+ export interface LockfileRun {
21
+ /**
22
+ * The lockfiles that `afterAllProjectsVersioned` brings up to date, relative
23
+ * to the repository root, with their workspaces.
24
+ */
25
+ lockfiles: Map<string, ReleaseWorkspace>;
26
+ /**
27
+ * The files that the run writes through Nx's tree, by their
28
+ * {@link treePath}: where they lie once symbolic links are followed.
29
+ */
30
+ written: Set<string>;
31
+ /** The lockfiles that the run has read, by their absolute path, as they were before it. */
32
+ lockfileStates: Map<string, LockfileState>;
33
+ }
34
+ /**
35
+ * Brings the `Cargo.lock` of each Cargo workspace that `run` changed up to
36
+ * date (`DES-RELEASE`, "Lockfile"), for `afterAllProjectsVersioned`.
37
+ */
38
+ export declare function updateVersionedLockfiles(run: LockfileRun | undefined, cwd: string, options: {
39
+ dryRun?: boolean;
40
+ }): {
41
+ changedFiles: string[];
42
+ deletedFiles: string[];
43
+ };
44
+ /**
45
+ * The lockfiles, by their path relative to the repository root, that the new
46
+ * version of `crate` makes stale, with their workspaces: those of the
47
+ * workspaces whose root manifest, member manifests or Cargo configuration
48
+ * files are among `files`, and those that lock the crate as a path package
49
+ * at its old version, as the lockfile of a workspace does whose member
50
+ * depends on the crate by path without a version requirement, whose
51
+ * manifests stay as they are (`EVD-CARGO-LOCKFILE-UPDATE`). A workspace
52
+ * without a `Cargo.lock` has none. A lockfile that cannot be read or parsed
53
+ * is among `unreadable`, with the reason, because then nx-rust can tell
54
+ * neither whether it is stale nor bring it up to date; only a lockfile that
55
+ * does not exist is absent.
56
+ */
57
+ export declare function staleLockfiles(tree: Tree, repository: ReleaseRepository, run: LockfileRun, crate: ReleaseCrate, files: readonly string[]): {
58
+ lockfiles: Map<string, ReleaseWorkspace>;
59
+ unreadable: string[];
60
+ };
61
+ export {};
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateVersionedLockfiles = updateVersionedLockfiles;
4
+ exports.staleLockfiles = staleLockfiles;
5
+ const node_child_process_1 = require("node:child_process");
6
+ const node_fs_1 = require("node:fs");
7
+ const node_path_1 = require("node:path");
8
+ const smol_toml_1 = require("smol-toml");
9
+ const cargo_invocation_1 = require("../executors/cargo-invocation");
10
+ const manifests_1 = require("./manifests");
11
+ const places_1 = require("./places");
12
+ const repository_1 = require("./repository");
13
+ const version_checks_1 = require("./version-checks");
14
+ /**
15
+ * Brings the `Cargo.lock` of each Cargo workspace that `run` changed up to
16
+ * date (`DES-RELEASE`, "Lockfile"), for `afterAllProjectsVersioned`.
17
+ */
18
+ function updateVersionedLockfiles(run, cwd, options) {
19
+ var _a, _b;
20
+ if (options.dryRun || run === undefined || run.lockfiles.size === 0) {
21
+ return { changedFiles: [], deletedFiles: [] };
22
+ }
23
+ const changed = [];
24
+ const failures = [];
25
+ for (const [lockfile, workspace] of [...run.lockfiles].sort(([a], [b]) => a.localeCompare(b))) {
26
+ const file = (0, node_path_1.join)(cwd, lockfile);
27
+ const before = readLockfile(file);
28
+ if (before.kind === "absent") {
29
+ continue;
30
+ }
31
+ if (before.kind === "unreadable") {
32
+ failures.push({
33
+ workspace,
34
+ reason: `nx release version cannot read ${lockfile}: ${before.reason}`,
35
+ output: "",
36
+ cargoFailed: false,
37
+ });
38
+ continue;
39
+ }
40
+ const update = (0, node_child_process_1.spawnSync)("cargo", ["update", "--workspace"], {
41
+ cwd: (0, node_path_1.dirname)(file),
42
+ env: process.env,
43
+ encoding: "utf8",
44
+ maxBuffer: 64 * 1024 * 1024,
45
+ stdio: ["ignore", "pipe", "pipe"],
46
+ });
47
+ if (update.error !== undefined || update.status !== 0) {
48
+ const code = (_a = update.error) === null || _a === void 0 ? void 0 : _a.code;
49
+ failures.push({
50
+ workspace,
51
+ reason: code === "ENOENT"
52
+ ? "cargo was not found on PATH"
53
+ : update.error !== undefined
54
+ ? update.error.message
55
+ : update.signal
56
+ ? `cargo was stopped by ${update.signal}`
57
+ : `cargo exited with status ${update.status}`,
58
+ output: ((_b = update.stderr) !== null && _b !== void 0 ? _b : "").trim(),
59
+ cargoFailed: true,
60
+ });
61
+ continue;
62
+ }
63
+ const after = readLockfile(file);
64
+ if (after.kind !== "read") {
65
+ failures.push({
66
+ workspace,
67
+ reason: `nx release version cannot read ${lockfile} after cargo update --workspace: ${after.kind === "absent" ? "it does not exist" : after.reason}`,
68
+ output: "",
69
+ cargoFailed: false,
70
+ });
71
+ continue;
72
+ }
73
+ if (after.text !== before.text) {
74
+ const path = (0, places_1.treePath)(cwd, lockfile);
75
+ changed.push(path);
76
+ console.log(path === lockfile
77
+ ? `Updated ${lockfile} with cargo update --workspace`
78
+ : `Updated ${path}, to which ${lockfile} leads, with cargo update --workspace`);
79
+ }
80
+ }
81
+ const staged = changed.filter((path) => !gitIgnores(cwd, path));
82
+ if (failures.length > 0) {
83
+ throw new manifests_1.ReleaseError(recoveryMessage(cwd, run, failures, changed, staged));
84
+ }
85
+ return { changedFiles: staged, deletedFiles: [] };
86
+ }
87
+ /**
88
+ * The message for a lockfile step that failed: each failure, and the
89
+ * commands, quoted for a POSIX shell, that take back what Nx and cargo
90
+ * wrote or bring the lockfiles up to date by hand.
91
+ */
92
+ function recoveryMessage(cwd, run, failures, changed, staged) {
93
+ const one = failures.length === 1;
94
+ const workspaces = `${one ? "the Cargo workspace" : "the Cargo workspaces"} ${(0, version_checks_1.sentenceList)(failures.map(({ workspace }) => workspace.rootManifest))}`;
95
+ const written = [...new Set([...run.written, ...staged])].sort();
96
+ const untracked = untrackedFiles(cwd, written);
97
+ const restorable = written.filter((file) => !untracked.includes(file));
98
+ const folders = failures.map(({ workspace }) => node_path_1.posix.dirname(workspace.rootManifest));
99
+ const byHand = untracked.length === 0
100
+ ? ""
101
+ : `take back ${(0, version_checks_1.sentenceList)(untracked)}, which git does not track, by hand`;
102
+ return [
103
+ failures.every(({ cargoFailed }) => cargoFailed)
104
+ ? `cargo update --workspace failed in ${workspaces}, so nx release version cannot bring ${one ? "its" : "their"} Cargo.lock up to date:`
105
+ : `nx release version cannot bring the Cargo.lock of ${workspaces} up to date:`,
106
+ ...failures.flatMap(({ workspace, reason, output }) => [
107
+ `- ${workspace.rootManifest}: ${reason}`,
108
+ ...(output === "" ? [] : output.split("\n").map((line) => ` ${line}`)),
109
+ ]),
110
+ `Nx has written the new versions${changed.length > 0 ? ` and cargo has updated ${(0, version_checks_1.sentenceList)(changed)}` : ""}, and made no commit or tag.`,
111
+ ...(restorable.length === 0
112
+ ? [`To go back, ${byHand}, and run nx release version again once cargo works.`]
113
+ : [
114
+ `To go back, run this in the root of the Nx workspace,${byHand === "" ? "" : ` ${byHand},`} and run nx release version again once cargo works:`,
115
+ // git reads a path in `*`, `?`, `[` or `\` as a pattern otherwise.
116
+ ` git ${restorable.some((file) => /[*?[\\]/.test(file)) ? "--literal-pathspecs " : ""}checkout -- ${restorable.map(cargo_invocation_1.shellWord).join(" ")}`,
117
+ ]),
118
+ `To go on instead, correct what cargo reports, run ${folders.length === 1 ? "this" : "these"} in the root of the Nx workspace, and commit and tag the release yourself:`,
119
+ // cd would read a folder that starts with `-` as an option.
120
+ ...folders.map((folder) => ` (cd ${(0, cargo_invocation_1.shellWord)(folder.startsWith("-") ? `./${folder}` : folder)} && cargo update --workspace)`),
121
+ ].join("\n");
122
+ }
123
+ /** The lockfile of a workspace, relative to the repository root with `/`. */
124
+ function lockfileOf(workspace) {
125
+ return node_path_1.posix.join(node_path_1.posix.dirname(workspace.rootManifest), "Cargo.lock");
126
+ }
127
+ /**
128
+ * The lockfiles, by their path relative to the repository root, that the new
129
+ * version of `crate` makes stale, with their workspaces: those of the
130
+ * workspaces whose root manifest, member manifests or Cargo configuration
131
+ * files are among `files`, and those that lock the crate as a path package
132
+ * at its old version, as the lockfile of a workspace does whose member
133
+ * depends on the crate by path without a version requirement, whose
134
+ * manifests stay as they are (`EVD-CARGO-LOCKFILE-UPDATE`). A workspace
135
+ * without a `Cargo.lock` has none. A lockfile that cannot be read or parsed
136
+ * is among `unreadable`, with the reason, because then nx-rust can tell
137
+ * neither whether it is stale nor bring it up to date; only a lockfile that
138
+ * does not exist is absent.
139
+ */
140
+ function staleLockfiles(tree, repository, run, crate, files) {
141
+ const lockfiles = new Map();
142
+ const unreadable = [];
143
+ for (const workspace of repository.workspaces) {
144
+ const lockfile = lockfileOf(workspace);
145
+ const file = (0, node_path_1.join)(tree.root, lockfile);
146
+ let state = run.lockfileStates.get(file);
147
+ if (state === undefined) {
148
+ state = lockfileState(file);
149
+ run.lockfileStates.set(file, state);
150
+ }
151
+ if (state.kind === "unreadable") {
152
+ unreadable.push(`- ${lockfile}: ${state.reason}`);
153
+ }
154
+ else if (state.kind === "read" &&
155
+ (changesWorkspace(repository, workspace, files) ||
156
+ // A lockfile names no path, and another path crate of that name and
157
+ // version only costs an update that changes nothing.
158
+ state.packages.some((pkg) => pkg.name === crate.name && pkg.version === crate.version && pkg.source === undefined))) {
159
+ lockfiles.set(lockfile, workspace);
160
+ }
161
+ }
162
+ return { lockfiles, unreadable };
163
+ }
164
+ // Whether `files` holds the workspace's root manifest, a member's manifest
165
+ // or one of its Cargo configuration files.
166
+ function changesWorkspace(repository, workspace, files) {
167
+ return files.some((file) => file === workspace.rootManifest ||
168
+ workspace.crates.some((member) => member.manifest === file) ||
169
+ workspace.configFiles.some((configFile) => (0, repository_1.repositoryPath)(repository.root, configFile) === file));
170
+ }
171
+ // The packages that the lockfile at `file` locks.
172
+ function lockfileState(file) {
173
+ const read = readLockfile(file);
174
+ if (read.kind !== "read") {
175
+ return read;
176
+ }
177
+ try {
178
+ const lock = (0, smol_toml_1.parse)(read.text);
179
+ return {
180
+ kind: "read",
181
+ packages: Array.isArray(lock.package) ? lock.package : [],
182
+ };
183
+ }
184
+ catch (error) {
185
+ return { kind: "unreadable", reason: `no valid TOML: ${(0, places_1.errorMessage)(error).split("\n")[0]}` };
186
+ }
187
+ }
188
+ // The text of the lockfile at `file`; absent only where it does not exist.
189
+ function readLockfile(file) {
190
+ try {
191
+ return { kind: "read", text: (0, node_fs_1.readFileSync)(file, "utf8") };
192
+ }
193
+ catch (error) {
194
+ return (0, places_1.isAbsence)(error)
195
+ ? { kind: "absent" }
196
+ : { kind: "unreadable", reason: (0, places_1.errorMessage)(error) };
197
+ }
198
+ }
199
+ // Whether git ignores a path of the repository; outside a git repository nothing is.
200
+ function gitIgnores(cwd, path) {
201
+ return ((0, node_child_process_1.spawnSync)("git", ["check-ignore", "--quiet", "--", path], { cwd, stdio: "ignore" }).status === 0);
202
+ }
203
+ // The files among `files` that git does not track, which `git checkout`
204
+ // cannot take back and refuses to take back anything beside; none where git
205
+ // cannot tell, as outside a git repository.
206
+ function untrackedFiles(cwd, files) {
207
+ if (files.length === 0) {
208
+ return [];
209
+ }
210
+ const listed = (0, node_child_process_1.spawnSync)("git", ["--literal-pathspecs", "ls-files", "-z", "--", ...files], {
211
+ cwd,
212
+ encoding: "utf8",
213
+ maxBuffer: 64 * 1024 * 1024,
214
+ stdio: ["ignore", "pipe", "ignore"],
215
+ });
216
+ if (listed.status !== 0) {
217
+ return [];
218
+ }
219
+ const tracked = new Set(listed.stdout.split("\0"));
220
+ return files.filter((file) => !tracked.has(file));
221
+ }
222
+ //# sourceMappingURL=version-lockfiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-lockfiles.js","sourceRoot":"","sources":["../../../../nx-rust/src/release/version-lockfiles.ts"],"names":[],"mappings":";;AAiDA,4DA+EC;AAwED,wCAiCC;AAx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CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,70 @@
1
+ /** The napi CLI that a crate's `napi-build` uses. */
2
+ export interface InstalledNapiCli {
3
+ /** The absolute path of the package's `package.json`. */
4
+ manifest: string;
5
+ /** The package's version, such as `3.10.12`. */
6
+ version: string;
7
+ }
8
+ /**
9
+ * The package `@napi-rs/cli` as Node resolves it from `folder`, the crate's
10
+ * folder, through the `node_modules` folders from there up to the file
11
+ * system's root, as the workspace's package manager installs it for the
12
+ * crate's own `package.json` or for the repository; `undefined` where
13
+ * none is installed or its `package.json` names no version.
14
+ */
15
+ export declare function installedNapiCli(folder: string): InstalledNapiCli | undefined;
16
+ /** The CLI's exported functions that `napi-build` calls (`DES-NAPI`, `EVD-NAPI-POSTPROCESS`). */
17
+ export interface NapiCliFunctions {
18
+ readNapiConfig(path: string, configPath?: string): Promise<{
19
+ binaryName: string;
20
+ packageName: string;
21
+ dtsHeader?: string;
22
+ dtsHeaderFile?: string;
23
+ constEnum?: boolean;
24
+ runtimeStringEnum?: boolean;
25
+ targets: {
26
+ platform: string;
27
+ platformArchABI: string;
28
+ triple: string;
29
+ }[];
30
+ packageJson: {
31
+ version: string;
32
+ };
33
+ }>;
34
+ parseTriple(triple: string): {
35
+ platformArchABI: string;
36
+ platform: string;
37
+ };
38
+ generateTypeDef(options: {
39
+ typeDefDir: string;
40
+ cwd: string;
41
+ configDtsHeader?: string;
42
+ configDtsHeaderFile?: string;
43
+ constEnum?: boolean;
44
+ runtimeStringEnum?: boolean;
45
+ declareBindingTarget?: (exports: readonly string[]) => boolean;
46
+ }): Promise<{
47
+ exports: string[];
48
+ dts: string;
49
+ }>;
50
+ writeJsBinding(options: {
51
+ platform: boolean;
52
+ idents: string[];
53
+ binaryName: string;
54
+ packageName: string;
55
+ version: string;
56
+ outputDir: string;
57
+ wasiFlavors?: string[];
58
+ }): Promise<unknown>;
59
+ }
60
+ /**
61
+ * Loads the CLI's CommonJS entry point, which every release from 3.4.0 has,
62
+ * and returns its functions, or throws where one is missing.
63
+ */
64
+ export declare function loadNapiCli(cli: InstalledNapiCli): NapiCliFunctions;
65
+ /**
66
+ * Whether `napi-build` supports a version of `@napi-rs/cli`: major 3, from
67
+ * 3.4.0, the first release that exports every function it calls
68
+ * (`ADR-NAPI-RS-3`).
69
+ */
70
+ export declare function supportedNapiCli(version: string): boolean;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installedNapiCli = installedNapiCli;
4
+ exports.loadNapiCli = loadNapiCli;
5
+ exports.supportedNapiCli = supportedNapiCli;
6
+ const node_fs_1 = require("node:fs");
7
+ const node_module_1 = require("node:module");
8
+ const node_path_1 = require("node:path");
9
+ /**
10
+ * The package `@napi-rs/cli` as Node resolves it from `folder`, the crate's
11
+ * folder, through the `node_modules` folders from there up to the file
12
+ * system's root, as the workspace's package manager installs it for the
13
+ * crate's own `package.json` or for the repository; `undefined` where
14
+ * none is installed or its `package.json` names no version.
15
+ */
16
+ function installedNapiCli(folder) {
17
+ let manifest;
18
+ try {
19
+ manifest = (0, node_module_1.createRequire)((0, node_path_1.join)(folder, "package.json")).resolve("@napi-rs/cli/package.json");
20
+ }
21
+ catch (_a) {
22
+ return undefined;
23
+ }
24
+ try {
25
+ const version = JSON.parse((0, node_fs_1.readFileSync)(manifest, "utf8")).version;
26
+ return typeof version === "string" && version !== "" ? { manifest, version } : undefined;
27
+ }
28
+ catch (_b) {
29
+ return undefined;
30
+ }
31
+ }
32
+ /**
33
+ * Loads the CLI's CommonJS entry point, which every release from 3.4.0 has,
34
+ * and returns its functions, or throws where one is missing.
35
+ */
36
+ function loadNapiCli(cli) {
37
+ const loaded = (0, node_module_1.createRequire)(cli.manifest)((0, node_path_1.dirname)(cli.manifest));
38
+ for (const name of [
39
+ "readNapiConfig",
40
+ "parseTriple",
41
+ "generateTypeDef",
42
+ "writeJsBinding",
43
+ ]) {
44
+ if (typeof loaded[name] !== "function") {
45
+ throw new Error(`@napi-rs/cli ${cli.version} exports no function ${name}`);
46
+ }
47
+ }
48
+ return loaded;
49
+ }
50
+ /**
51
+ * Whether `napi-build` supports a version of `@napi-rs/cli`: major 3, from
52
+ * 3.4.0, the first release that exports every function it calls
53
+ * (`ADR-NAPI-RS-3`).
54
+ */
55
+ function supportedNapiCli(version) {
56
+ const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
57
+ if (match === null) {
58
+ return false;
59
+ }
60
+ const [major, minor] = [Number(match[1]), Number(match[2])];
61
+ return major === 3 && minor >= 4;
62
+ }
63
+ //# sourceMappingURL=napi-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"napi-cli.js","sourceRoot":"","sources":["../../../../nx-rust/src/tools/napi-cli.ts"],"names":[],"mappings":";;AAmBA,4CAaC;AA0CD,kCAaC;AAOD,4CAOC;AArGD,qCAAuC;AACvC,6CAA4C;AAC5C,yCAA0C;AAU1C;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAA,2BAAa,EAAC,IAAA,gBAAI,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC9F,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,OAAO,GAAI,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAA2B,CAAC,OAAO,CAAC;QAC9F,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC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