@intentius/chant 0.124.86 → 0.124.88

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 (384) hide show
  1. package/dist/action-pins.d.ts +1 -0
  2. package/dist/action-pins.d.ts.map +1 -1
  3. package/dist/action-pins.js +2 -0
  4. package/dist/actor.d.ts +12 -0
  5. package/dist/actor.d.ts.map +1 -0
  6. package/dist/actor.js +18 -0
  7. package/dist/bundle-check.d.ts +20 -5
  8. package/dist/bundle-check.d.ts.map +1 -1
  9. package/dist/bundle-check.js +20 -5
  10. package/dist/chant-install.d.ts +98 -0
  11. package/dist/chant-install.d.ts.map +1 -1
  12. package/dist/chant-install.js +204 -2
  13. package/dist/ci-commit.d.ts.map +1 -1
  14. package/dist/ci-commit.js +1 -2
  15. package/dist/ci-control.d.ts +1 -1
  16. package/dist/ci-control.d.ts.map +1 -1
  17. package/dist/ci-control.js +1 -1
  18. package/dist/ci-evidence-claims.d.ts +59 -0
  19. package/dist/ci-evidence-claims.d.ts.map +1 -0
  20. package/dist/ci-evidence-claims.js +87 -0
  21. package/dist/ci-evidence-from-job.d.ts +103 -0
  22. package/dist/ci-evidence-from-job.d.ts.map +1 -0
  23. package/dist/ci-evidence-from-job.js +162 -0
  24. package/dist/ci-evidence-jobs.d.ts +69 -10
  25. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  26. package/dist/ci-evidence-jobs.js +72 -8
  27. package/dist/ci-handover.d.ts +12 -0
  28. package/dist/ci-handover.d.ts.map +1 -1
  29. package/dist/ci-handover.js +15 -3
  30. package/dist/ci-identity.d.ts +32 -6
  31. package/dist/ci-identity.d.ts.map +1 -1
  32. package/dist/ci-identity.js +40 -8
  33. package/dist/ci-image.d.ts +47 -9
  34. package/dist/ci-image.d.ts.map +1 -1
  35. package/dist/ci-image.js +45 -18
  36. package/dist/ci-jobs.d.ts +1 -1
  37. package/dist/ci-jobs.d.ts.map +1 -1
  38. package/dist/ci-jobs.js +7 -2
  39. package/dist/ci-login.d.ts +75 -13
  40. package/dist/ci-login.d.ts.map +1 -1
  41. package/dist/ci-login.js +89 -37
  42. package/dist/ci-product-words.d.ts +20 -1
  43. package/dist/ci-product-words.d.ts.map +1 -1
  44. package/dist/ci-product-words.js +27 -1
  45. package/dist/ci-product.d.ts +20 -1
  46. package/dist/ci-product.d.ts.map +1 -1
  47. package/dist/ci-product.js +21 -2
  48. package/dist/cli/handlers/approve-confirm.d.ts +14 -0
  49. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
  50. package/dist/cli/handlers/approve-confirm.js +46 -0
  51. package/dist/cli/handlers/build.d.ts +1 -1
  52. package/dist/cli/handlers/build.d.ts.map +1 -1
  53. package/dist/cli/handlers/build.js +22 -1
  54. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  55. package/dist/cli/handlers/ci-check.js +38 -14
  56. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  57. package/dist/cli/handlers/ci-evidence.js +238 -26
  58. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
  59. package/dist/cli/handlers/ci-forge-check.js +34 -17
  60. package/dist/cli/handlers/generated-check.d.ts +3 -0
  61. package/dist/cli/handlers/generated-check.d.ts.map +1 -0
  62. package/dist/cli/handlers/generated-check.js +41 -0
  63. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  64. package/dist/cli/handlers/lifecycle.js +3 -0
  65. package/dist/cli/handlers/local-chant.d.ts +13 -0
  66. package/dist/cli/handlers/local-chant.d.ts.map +1 -1
  67. package/dist/cli/handlers/local-chant.js +42 -1
  68. package/dist/cli/handlers/pr.d.ts.map +1 -1
  69. package/dist/cli/handlers/pr.js +42 -5
  70. package/dist/cli/handlers/run-wave.js +8 -0
  71. package/dist/cli/main.d.ts.map +1 -1
  72. package/dist/cli/main.js +38 -4
  73. package/dist/cli/parse-args.d.ts.map +1 -1
  74. package/dist/cli/parse-args.js +66 -0
  75. package/dist/cli/registry.d.ts +24 -0
  76. package/dist/cli/registry.d.ts.map +1 -1
  77. package/dist/components/check-hooks.d.ts +10 -0
  78. package/dist/components/check-hooks.d.ts.map +1 -1
  79. package/dist/components/check-hooks.js +21 -3
  80. package/dist/components/check-steps.js +1 -1
  81. package/dist/components/pr-checks.d.ts +105 -0
  82. package/dist/components/pr-checks.d.ts.map +1 -0
  83. package/dist/components/pr-checks.js +119 -0
  84. package/dist/components/pr-pipeline.d.ts +34 -0
  85. package/dist/components/pr-pipeline.d.ts.map +1 -1
  86. package/dist/components/pr-pipeline.js +14 -1
  87. package/dist/components/product-pipeline.d.ts +16 -1
  88. package/dist/components/product-pipeline.d.ts.map +1 -1
  89. package/dist/components/product-pipeline.js +17 -2
  90. package/dist/components/product-plan.d.ts +262 -3
  91. package/dist/components/product-plan.d.ts.map +1 -1
  92. package/dist/components/product-plan.js +243 -11
  93. package/dist/config.d.ts +10 -6
  94. package/dist/config.d.ts.map +1 -1
  95. package/dist/config.js +11 -6
  96. package/dist/control/consumers.d.ts +6 -0
  97. package/dist/control/consumers.d.ts.map +1 -1
  98. package/dist/control/consumers.js +6 -0
  99. package/dist/dead-guards.d.ts.map +1 -1
  100. package/dist/dead-guards.js +9 -6
  101. package/dist/discovery/files.d.ts +1 -1
  102. package/dist/discovery/files.js +1 -1
  103. package/dist/drift-issue.d.ts +20 -3
  104. package/dist/drift-issue.d.ts.map +1 -1
  105. package/dist/drift-issue.js +16 -0
  106. package/dist/drift-record.d.ts +45 -5
  107. package/dist/drift-record.d.ts.map +1 -1
  108. package/dist/drift-record.js +27 -6
  109. package/dist/floor-table.d.ts +6 -6
  110. package/dist/floor-table.d.ts.map +1 -1
  111. package/dist/floor-table.data.d.ts.map +1 -1
  112. package/dist/floor-table.data.js +58 -20
  113. package/dist/floor-table.js +10 -7
  114. package/dist/forge-check/contract.d.ts +8 -0
  115. package/dist/forge-check/contract.d.ts.map +1 -1
  116. package/dist/forge-check/contract.js +4 -1
  117. package/dist/forge-check/index.d.ts +2 -0
  118. package/dist/forge-check/index.d.ts.map +1 -1
  119. package/dist/forge-check/index.js +2 -0
  120. package/dist/forge-flags.d.ts +10 -0
  121. package/dist/forge-flags.d.ts.map +1 -1
  122. package/dist/forge-flags.js +31 -0
  123. package/dist/forge-remote.d.ts +47 -0
  124. package/dist/forge-remote.d.ts.map +1 -0
  125. package/dist/forge-remote.js +69 -0
  126. package/dist/generated-check.d.ts +74 -0
  127. package/dist/generated-check.d.ts.map +1 -0
  128. package/dist/generated-check.js +216 -0
  129. package/dist/lexicon.d.ts +16 -0
  130. package/dist/lexicon.d.ts.map +1 -1
  131. package/dist/lifecycle/publish-npm.d.ts +15 -0
  132. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  133. package/dist/lifecycle/publish-npm.js +49 -3
  134. package/dist/lifecycle/release-images.d.ts +22 -1
  135. package/dist/lifecycle/release-images.d.ts.map +1 -1
  136. package/dist/lifecycle/release-images.js +27 -3
  137. package/dist/lifecycle/release-ledger.d.ts +4 -3
  138. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  139. package/dist/lifecycle/release-ledger.js +3 -2
  140. package/dist/local-chant.d.ts +57 -3
  141. package/dist/local-chant.d.ts.map +1 -1
  142. package/dist/local-chant.js +122 -13
  143. package/dist/op/op-waves-evidence-jobs.d.ts +92 -0
  144. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
  145. package/dist/op/op-waves-evidence-jobs.js +112 -0
  146. package/dist/op/op-waves-evidence.d.ts +17 -4
  147. package/dist/op/op-waves-evidence.d.ts.map +1 -1
  148. package/dist/op/op-waves-evidence.js +32 -10
  149. package/dist/op/op-waves-run.d.ts +12 -1
  150. package/dist/op/op-waves-run.d.ts.map +1 -1
  151. package/dist/op/op-waves-run.js +54 -3
  152. package/dist/op/op-waves.d.ts +8 -0
  153. package/dist/op/op-waves.d.ts.map +1 -1
  154. package/dist/op/op-waves.js +10 -0
  155. package/dist/op/schedule-overdue.d.ts +39 -2
  156. package/dist/op/schedule-overdue.d.ts.map +1 -1
  157. package/dist/op/schedule-overdue.js +89 -7
  158. package/dist/pr-forge-reads.d.ts +21 -1
  159. package/dist/pr-forge-reads.d.ts.map +1 -1
  160. package/dist/pr-forge-reads.js +19 -1
  161. package/dist/pr-forge.d.ts +7 -1
  162. package/dist/pr-forge.d.ts.map +1 -1
  163. package/dist/pr-forge.js +7 -2
  164. package/dist/pr-plan-note.d.ts +24 -0
  165. package/dist/pr-plan-note.d.ts.map +1 -1
  166. package/dist/pr-plan-note.js +11 -1
  167. package/dist/pr-plan-record.d.ts +47 -0
  168. package/dist/pr-plan-record.d.ts.map +1 -0
  169. package/dist/pr-plan-record.js +89 -0
  170. package/dist/pr-post.d.ts +40 -0
  171. package/dist/pr-post.d.ts.map +1 -1
  172. package/dist/pr-post.js +79 -6
  173. package/dist/pr-requires.d.ts +8 -0
  174. package/dist/pr-requires.d.ts.map +1 -1
  175. package/dist/pr-requires.js +3 -1
  176. package/dist/ref-gate-init.d.ts +76 -0
  177. package/dist/ref-gate-init.d.ts.map +1 -0
  178. package/dist/ref-gate-init.js +144 -0
  179. package/dist/ref-gate-rules.d.ts +19 -0
  180. package/dist/ref-gate-rules.d.ts.map +1 -0
  181. package/dist/ref-gate-rules.js +17 -0
  182. package/dist/release-floors.d.ts +51 -1
  183. package/dist/release-floors.d.ts.map +1 -1
  184. package/dist/release-floors.js +66 -16
  185. package/dist/state-migration.d.ts +23 -0
  186. package/dist/state-migration.d.ts.map +1 -1
  187. package/dist/state-migration.js +39 -3
  188. package/dist/state-unlock.d.ts +32 -1
  189. package/dist/state-unlock.d.ts.map +1 -1
  190. package/dist/state-unlock.js +31 -0
  191. package/dist/wave-runtime.mjs +310 -303
  192. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  193. package/dist/workspace/ci-green-cli.js +13 -7
  194. package/dist/workspace/ci-green.d.ts.map +1 -1
  195. package/dist/workspace/ci-green.js +4 -3
  196. package/dist/workspace/drift-cli.d.ts +1 -1
  197. package/dist/workspace/drift-cli.d.ts.map +1 -1
  198. package/dist/workspace/drift-cli.js +5 -12
  199. package/dist/workspace/forge-work.d.ts +3 -2
  200. package/dist/workspace/forge-work.d.ts.map +1 -1
  201. package/dist/workspace/forge-work.js +7 -17
  202. package/dist/workspace/lexicon-outputs.js +2 -2
  203. package/dist/workspace/release-workflow.d.ts +26 -3
  204. package/dist/workspace/release-workflow.d.ts.map +1 -1
  205. package/dist/workspace/release-workflow.js +48 -6
  206. package/dist/workspace/trust/check-evidence-report.d.ts +25 -0
  207. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  208. package/dist/workspace/trust/check-evidence-report.js +20 -0
  209. package/dist/workspace/trust/check-evidence.d.ts +59 -13
  210. package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
  211. package/dist/workspace/trust/check-evidence.js +101 -24
  212. package/dist/workspace/trust/ci-tag-statement.d.ts +2 -2
  213. package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
  214. package/dist/workspace/trust/dsse.d.ts +40 -2
  215. package/dist/workspace/trust/dsse.d.ts.map +1 -1
  216. package/dist/workspace/trust/dsse.js +34 -2
  217. package/dist/workspace/trust/evidence.d.ts +7 -2
  218. package/dist/workspace/trust/evidence.d.ts.map +1 -1
  219. package/dist/workspace/trust/evidence.js +5 -0
  220. package/dist/workspace/trust/keyless-fixture.d.ts +41 -0
  221. package/dist/workspace/trust/keyless-fixture.d.ts.map +1 -0
  222. package/dist/workspace/trust/keyless-fixture.js +161 -0
  223. package/dist/workspace/trust/keyless.d.ts +202 -0
  224. package/dist/workspace/trust/keyless.d.ts.map +1 -0
  225. package/dist/workspace/trust/keyless.js +488 -0
  226. package/dist/workspace/trust/local-evidence.d.ts +3 -0
  227. package/dist/workspace/trust/local-evidence.d.ts.map +1 -1
  228. package/dist/workspace/trust/op-run-statement.d.ts +2 -2
  229. package/dist/workspace/trust/op-run-statement.d.ts.map +1 -1
  230. package/dist/workspace/trust/open-evidence.d.ts +67 -0
  231. package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
  232. package/dist/workspace/trust/open-evidence.js +92 -0
  233. package/dist/workspace/trust/policy.d.ts +56 -1
  234. package/dist/workspace/trust/policy.d.ts.map +1 -1
  235. package/dist/workspace/trust/policy.js +103 -2
  236. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  237. package/dist/workspace/trust/ref-gate-cli.js +65 -3
  238. package/dist/workspace/trust/ref-gate.d.ts +62 -3
  239. package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
  240. package/dist/workspace/trust/ref-gate.js +75 -8
  241. package/dist/workspace/trust/run-statement.d.ts +3 -3
  242. package/dist/workspace/trust/run-statement.d.ts.map +1 -1
  243. package/dist/workspace/trust/runner-identity.d.ts +56 -0
  244. package/dist/workspace/trust/runner-identity.d.ts.map +1 -0
  245. package/dist/workspace/trust/runner-identity.js +65 -0
  246. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  247. package/dist/workspace/trust/trust-files.js +8 -1
  248. package/package.json +1 -1
  249. package/src/action-pins.ts +2 -0
  250. package/src/actor.test.ts +12 -0
  251. package/src/actor.ts +19 -0
  252. package/src/bundle-check.test.ts +22 -0
  253. package/src/bundle-check.ts +33 -5
  254. package/src/chant-install.test.ts +109 -1
  255. package/src/chant-install.ts +243 -2
  256. package/src/ci-commit.test.ts +51 -5
  257. package/src/ci-commit.ts +1 -2
  258. package/src/ci-control.ts +1 -0
  259. package/src/ci-evidence-claims.ts +102 -0
  260. package/src/ci-evidence-from-job.test.ts +147 -0
  261. package/src/ci-evidence-from-job.ts +195 -0
  262. package/src/ci-evidence-jobs.ts +85 -10
  263. package/src/ci-handover.ts +16 -3
  264. package/src/ci-identity.test.ts +3 -3
  265. package/src/ci-identity.ts +51 -11
  266. package/src/ci-image.test.ts +60 -10
  267. package/src/ci-image.ts +78 -19
  268. package/src/ci-jobs.ts +7 -2
  269. package/src/ci-login.test.ts +131 -3
  270. package/src/ci-login.token-drop.test.ts +204 -0
  271. package/src/ci-login.ts +137 -39
  272. package/src/ci-product-words.ts +30 -0
  273. package/src/ci-product.ts +26 -1
  274. package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
  275. package/src/cli/handlers/approve-confirm.test.ts +35 -0
  276. package/src/cli/handlers/approve-confirm.ts +44 -0
  277. package/src/cli/handlers/build-source-dir.test.ts +4 -0
  278. package/src/cli/handlers/build.ts +20 -2
  279. package/src/cli/handlers/ci-check.ts +35 -13
  280. package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
  281. package/src/cli/handlers/ci-evidence.ts +223 -24
  282. package/src/cli/handlers/ci-forge-check.ts +22 -9
  283. package/src/cli/handlers/generated-check.ts +39 -0
  284. package/src/cli/handlers/lifecycle.test.ts +20 -0
  285. package/src/cli/handlers/lifecycle.ts +4 -0
  286. package/src/cli/handlers/local-chant.ts +39 -1
  287. package/src/cli/handlers/pr.ts +43 -5
  288. package/src/cli/handlers/run-wave.ts +7 -0
  289. package/src/cli/main.ts +38 -4
  290. package/src/cli/parse-args.ts +46 -0
  291. package/src/cli/registry.ts +24 -0
  292. package/src/components/check-hooks.ts +25 -3
  293. package/src/components/check-report-summary.test.ts +78 -0
  294. package/src/components/check-steps.ts +1 -1
  295. package/src/components/pr-checks.ts +159 -0
  296. package/src/components/pr-pipeline.ts +41 -1
  297. package/src/components/product-pipeline.ts +25 -3
  298. package/src/components/product-plan.test.ts +102 -1
  299. package/src/components/product-plan.ts +419 -14
  300. package/src/config.ts +13 -8
  301. package/src/control/consumers.ts +7 -0
  302. package/src/dead-guards.test.ts +27 -5
  303. package/src/dead-guards.ts +9 -6
  304. package/src/discovery/files.ts +1 -1
  305. package/src/drift-issue.test.ts +29 -1
  306. package/src/drift-issue.ts +28 -3
  307. package/src/drift-record.test.ts +25 -0
  308. package/src/drift-record.ts +55 -6
  309. package/src/floor-table.data.ts +58 -20
  310. package/src/floor-table.ts +12 -9
  311. package/src/forge-check/contract.ts +11 -1
  312. package/src/forge-check/forge-check.test.ts +8 -0
  313. package/src/forge-check/index.ts +2 -0
  314. package/src/forge-flags.test.ts +25 -1
  315. package/src/forge-flags.ts +34 -0
  316. package/src/forge-remote.test.ts +37 -0
  317. package/src/forge-remote.ts +79 -0
  318. package/src/generated-check.e2e.test.ts +98 -0
  319. package/src/generated-check.test.ts +104 -0
  320. package/src/generated-check.ts +269 -0
  321. package/src/lexicon.ts +17 -0
  322. package/src/lifecycle/publish-npm.ts +56 -3
  323. package/src/lifecycle/release-catalog.test.ts +2 -2
  324. package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
  325. package/src/lifecycle/release-images.test.ts +44 -0
  326. package/src/lifecycle/release-images.ts +39 -3
  327. package/src/lifecycle/release-ledger.ts +4 -3
  328. package/src/local-chant.e2e.test.ts +81 -6
  329. package/src/local-chant.test.ts +22 -3
  330. package/src/local-chant.ts +130 -13
  331. package/src/op/op-waves-evidence-jobs.ts +134 -0
  332. package/src/op/op-waves-evidence.test.ts +37 -4
  333. package/src/op/op-waves-evidence.ts +32 -11
  334. package/src/op/op-waves-run.ts +57 -2
  335. package/src/op/op-waves.ts +11 -0
  336. package/src/op/schedule-overdue.test.ts +83 -1
  337. package/src/op/schedule-overdue.ts +107 -9
  338. package/src/pr-forge-reads-compare.test.ts +2 -1
  339. package/src/pr-forge-reads.ts +37 -1
  340. package/src/pr-forge.ts +14 -3
  341. package/src/pr-plan-note.ts +32 -3
  342. package/src/pr-plan-record.test.ts +75 -0
  343. package/src/pr-plan-record.ts +101 -0
  344. package/src/pr-post-plan-note.test.ts +60 -0
  345. package/src/pr-post.test.ts +30 -0
  346. package/src/pr-post.ts +110 -6
  347. package/src/pr-requires.test.ts +20 -0
  348. package/src/pr-requires.ts +10 -1
  349. package/src/ref-gate-init.ts +189 -0
  350. package/src/ref-gate-rules.ts +26 -0
  351. package/src/release-floors.ts +88 -16
  352. package/src/state-migration-record.test.ts +90 -0
  353. package/src/state-migration.test.ts +1 -1
  354. package/src/state-migration.ts +52 -3
  355. package/src/state-unlock.test.ts +33 -1
  356. package/src/state-unlock.ts +49 -1
  357. package/src/workspace/ci-green-cli.ts +12 -6
  358. package/src/workspace/ci-green.ts +4 -3
  359. package/src/workspace/drift-cli.ts +6 -18
  360. package/src/workspace/forge-work.ts +7 -14
  361. package/src/workspace/lexicon-outputs.ts +2 -2
  362. package/src/workspace/release-workflow.test.ts +70 -0
  363. package/src/workspace/release-workflow.ts +56 -8
  364. package/src/workspace/trust/check-evidence-report.ts +33 -0
  365. package/src/workspace/trust/check-evidence.test.ts +3 -3
  366. package/src/workspace/trust/check-evidence.ts +110 -28
  367. package/src/workspace/trust/ci-tag-statement.ts +2 -2
  368. package/src/workspace/trust/dsse.ts +48 -4
  369. package/src/workspace/trust/evidence.ts +7 -2
  370. package/src/workspace/trust/keyless-fixture.ts +214 -0
  371. package/src/workspace/trust/keyless.test.ts +220 -0
  372. package/src/workspace/trust/keyless.ts +557 -0
  373. package/src/workspace/trust/local-evidence.ts +3 -1
  374. package/src/workspace/trust/op-run-statement.ts +2 -2
  375. package/src/workspace/trust/open-evidence.ts +129 -0
  376. package/src/workspace/trust/policy.ts +129 -2
  377. package/src/workspace/trust/ref-gate-cli.ts +59 -3
  378. package/src/workspace/trust/ref-gate-pieces.test.ts +175 -0
  379. package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
  380. package/src/workspace/trust/ref-gate.ts +90 -8
  381. package/src/workspace/trust/run-statement.ts +3 -3
  382. package/src/workspace/trust/runner-identity.ts +92 -0
  383. package/src/workspace/trust/trust-files.test.ts +6 -0
  384. package/src/workspace/trust/trust-files.ts +14 -1
@@ -3,13 +3,16 @@
3
3
  * feature-detect on, as one table, and the version compare a product asks it
4
4
  * with.
5
5
  *
6
- * A floor is a constant `<NAME>_FLOOR` in chant core naming the first chant
7
- * release with a part (an export, a field chant writes, a flag). A product
6
+ * A floor is a constant `<NAME>_FLOOR` in chant core, or in a lexicon's
7
+ * src/chant-floors.ts (#4916), naming the first chant release with a part
8
+ * (an export, a field chant writes, a flag). Lexicons release with chant at
9
+ * the same version, so a lexicon's floor is a chant version too. A product
8
10
  * that runs on several chant releases checks one before it calls the part. The
9
11
  * rows are written by scripts/floor-table.ts from the constants themselves
10
12
  * (./floor-table.data.ts), and scripts/release-floors.ts fails while a floor
11
13
  * is missing from them. A floor added since the last release has the version
12
- * of the next one, NEXT_RELEASE, which the release moves on.
14
+ * of the next one, NEXT_RELEASE, which the release moves on. Each name is
15
+ * declared once (#4916), and scripts/floor-table.ts fails on a second.
13
16
  *
14
17
  * `chant dev dead-guards` (./dead-guards.ts) reads this table against a
15
18
  * product's chant pin and names each check the pin already meets.
@@ -26,24 +29,24 @@ export interface FloorRow {
26
29
  gates: string;
27
30
  /** The issue that added it, `#4784`, or a product's (`terragucci issue 1303`). */
28
31
  issue?: string;
29
- /** The file under packages/core/src that declares it. */
32
+ /** The file under packages/core/src that declares it, or a lexicon's floors file from the repository root (`lexicons/terraform/src/chant-floors.ts`). */
30
33
  file: string;
31
- /** The `@intentius/chant` subpaths a product can import the constant from. */
34
+ /** The subpaths a product can import the constant from: `@intentius/chant/...`, or the lexicon's own. */
32
35
  modules: readonly string[];
33
36
  }
34
37
 
35
- /** Every floor, in the order the files declare them. Two files may declare the same name; each is a row. */
38
+ /** Every floor, core's in the order its files declare them, then each lexicon's. */
36
39
  export const FLOOR_TABLE: readonly FloorRow[] = FLOOR_ROWS;
37
40
 
38
- /** The rows named `name`: one, or more when two files declare it. */
41
+ /** The rows named `name`: one, or none. A table a caller builds may hold more. */
39
42
  export function floorRows(name: string): FloorRow[] {
40
43
  return FLOOR_TABLE.filter((r) => r.name === name);
41
44
  }
42
45
 
43
46
  /**
44
47
  * The version a product must reach for the floor `name`, or undefined when no
45
- * file declares it. When two files declare the name, the higher version, so a
46
- * check that passes holds for either.
48
+ * file declares it. Should a name ever have two rows, the higher version, so
49
+ * a check that passes holds for either.
47
50
  */
48
51
  export function floorVersion(name: string): string | undefined {
49
52
  const rows = floorRows(name);
@@ -174,6 +174,14 @@ export interface PipelineContractInput {
174
174
  protectedBranches?: string[];
175
175
  /** Default: each pipeline's plan status, such as `chant/plan` or `plywood/preview/<member>`. */
176
176
  requiredStatuses?: string[];
177
+ /**
178
+ * The ref gate's status (#4913), added to the required statuses: the one
179
+ * the generated `ref-gate` job sets when the pipeline renders it
180
+ * (`refGateStatus`, `--ref-gate-status`). Read it with `refGateRulesAt`
181
+ * (`@intentius/chant/ref-gate-rules`): its `status` for the default branch,
182
+ * by default `chant/ref-gate`.
183
+ */
184
+ refGateStatus?: string;
177
185
  gitlabVariables?: string[];
178
186
  }
179
187
 
@@ -204,12 +212,14 @@ export function pipelineContract(input: PipelineContractInput): ForgeCheckContra
204
212
  const ctx = productStatusContext(words, "plan", p.member);
205
213
  if (!statuses.includes(ctx)) statuses.push(ctx);
206
214
  }
215
+ const required = [...(input.requiredStatuses ?? statuses)];
216
+ if (input.refGateStatus && !required.includes(input.refGateStatus)) required.push(input.refGateStatus);
207
217
  return {
208
218
  forge,
209
219
  repository,
210
220
  jobs,
211
221
  protectedBranches: input.protectedBranches ?? [repository.defaultBranch],
212
- requiredStatuses: input.requiredStatuses ?? statuses,
222
+ requiredStatuses: required,
213
223
  ...(input.gitlabVariables ? { gitlabVariables: input.gitlabVariables } : {}),
214
224
  };
215
225
  }
@@ -165,6 +165,14 @@ describe("the contract chant's pipelines make (#4608)", () => {
165
165
  expect(c.jobs[2]!.pulumi).toEqual({ organization: "acme", tokens: ["team:deployers"], audience: "urn:pulumi:org:acme", apiUrl: PULUMI_API });
166
166
  });
167
167
 
168
+ test("the ref gate's status is required beside the plan status when the pipeline sets it (#4913)", () => {
169
+ const c = pipelineContract({ forge: "github", repository: repo(), pipelines: [{ name: "production", identity: awsIdentity }], refGateStatus: "chant/ref-gate" });
170
+ expect(c.requiredStatuses).toEqual(["chant/plan", "chant/ref-gate"]);
171
+ const given = pipelineContract({ forge: "github", repository: repo(), pipelines: [{ name: "production", identity: awsIdentity }], requiredStatuses: ["acme/ci", "acme/gate"], refGateStatus: "acme/gate" });
172
+ expect(given.requiredStatuses).toEqual(["acme/ci", "acme/gate"]);
173
+ expect(pipelineContract({ forge: "github", repository: repo(), pipelines: [{ name: "production", identity: awsIdentity }] }).requiredStatuses).toEqual(["chant/plan"]);
174
+ });
175
+
168
176
  test("Forgejo has no environments, so an apply environment is left out", () => {
169
177
  const c = pipelineContract({ forge: "forgejo", repository: { ...repo(), host: "code.example.com" }, pipelines: [{ name: "p", identity: awsIdentity, forgeEnvironment: "prod" }] });
170
178
  expect(c.jobs[2]!.forgeEnvironment).toBeUndefined();
@@ -40,4 +40,6 @@ export {
40
40
  type FederatedCredential,
41
41
  } from "./trust";
42
42
  export { pulumiRows, policyGrants, PULUMI_TOKEN_ENV } from "./pulumi";
43
+ /** `refGateStatus` in `pipelineContract` (#4913). */
44
+ export { REF_GATE_PIECES_FLOOR } from "../release-floors";
43
45
  export { forgeCheck, forgeCheckExit, describeForgeCheck, countRows, forgeCheckCommand, forgeCheckSchema, forgeCheckTarget, uncheckedClouds, ForgeCheckTargetError, type ForgeCheckInput } from "./check";
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { describe, expect, test } from "vitest";
8
- import { apiBaseOf, ForgeFlagError, forgeFlagHints, forgeTargetFromFlags, forgeTargetOptionsFromFlags, forgeTargetWith } from "./forge-flags";
8
+ import { apiBaseOf, ForgeFlagError, forgeFlagHints, forgeTargetFromFlags, forgeTargetOptionsFromFlags, forgeTargetWith, jobForgeTarget } from "./forge-flags";
9
9
  import { ForgeEnvironmentError } from "./pr-forge";
10
10
 
11
11
  const SHA = "a".repeat(40);
@@ -108,3 +108,27 @@ describe("forgeTargetFromFlags (#4800)", () => {
108
108
  expect(forgeFlagHints(missing as ForgeEnvironmentError, { requirePr: true })).toEqual(["outside CI pass --repo, --pr and --api-url", "name another token variable with --token-env"]);
109
109
  });
110
110
  });
111
+
112
+ // #4888: the one target type terragucci needs: the web origin on it, and undefined where the job cannot reach the forge.
113
+ describe("the target's web origin and jobForgeTarget (#4888)", () => {
114
+ test("the origin is --url, else the job's server, else https on the host", () => {
115
+ expect(forgeTargetWith({ FORGEJO_TOKEN: "f" }, { kind: "forgejo", repo: "a/b", url: "http://forgejo:3000/" }).origin).toBe("http://forgejo:3000");
116
+ expect(forgeTargetWith({ GITHUB_ACTIONS: "true", GITHUB_REPOSITORY: "a/b", GITHUB_SERVER_URL: "https://ghe.example", GITHUB_API_URL: "https://ghe.example/api/v3", GITHUB_TOKEN: "t" }).origin).toBe("https://ghe.example");
117
+ expect(forgeTargetWith({ GITLAB_CI: "true", CI_SERVER_URL: "https://gl.example", CI_API_V4_URL: "https://gl.example/api/v4", CI_PROJECT_ID: "7", GITLAB_TOKEN: "g" }).origin).toBe("https://gl.example");
118
+ expect(forgeTargetWith({ GITHUB_TOKEN: "t" }, { kind: "github", repo: "a/b", apiUrl: "https://api.github.com" }).origin).toBe("https://github.com");
119
+ });
120
+
121
+ const job = { GITHUB_ACTIONS: "true", GITHUB_REPOSITORY: "acme/infra", GITHUB_SERVER_URL: "https://github.com", TG_TOKEN: "tg" };
122
+
123
+ test("a job's target with the token the product holds, or with none for a read", () => {
124
+ expect(jobForgeTarget({ token: "given" }, job)).toMatchObject({ kind: "github", repo: "acme/infra", token: "given", origin: "https://github.com" });
125
+ expect(jobForgeTarget({ tokenEnv: "TG_TOKEN" }, job)).toMatchObject({ token: "tg", tokenSource: "TG_TOKEN" });
126
+ expect(jobForgeTarget({ tokenEnv: "TG_TOKEN" }, { ...job, TG_TOKEN: "" }, { tokenOptional: true })).toMatchObject({ token: "", repo: "acme/infra" });
127
+ });
128
+
129
+ test("undefined where the job names no forge or lacks a piece, and a bad flag still throws", () => {
130
+ expect(jobForgeTarget({ tokenEnv: "TG_TOKEN" }, {})).toBeUndefined();
131
+ expect(jobForgeTarget({ tokenEnv: "TG_TOKEN" }, { ...job, TG_TOKEN: "" })).toBeUndefined();
132
+ expect(() => jobForgeTarget({ forge: "svn" }, job)).toThrow(ForgeFlagError);
133
+ });
134
+ });
@@ -34,6 +34,15 @@ export interface ForgeOverrides {
34
34
 
35
35
  const trimUrl = (u: string | undefined): string | undefined => u?.trim().replace(/\/+$/, "") || undefined;
36
36
 
37
+ /** `scheme://host[:port]` of a URL, the path dropped. */
38
+ const originOf = (url: string): string => {
39
+ try {
40
+ return new URL(url).origin;
41
+ } catch {
42
+ return url;
43
+ }
44
+ };
45
+
37
46
  const hostOf = (url: string): string | undefined => {
38
47
  try {
39
48
  return new URL(url).host.toLowerCase();
@@ -102,6 +111,9 @@ export function forgeTargetWith(env: Record<string, string | undefined> = proces
102
111
  const out: ForgeTarget = { ...t };
103
112
  if (noToken) Object.assign(out, { token: "", tokenSource: "" });
104
113
  if (kind !== "gitlab" && apiUrl && !url) out.host = hostOf(apiUrl)!.replace(/^api\.github\.com$/, "github.com");
114
+ // #4888: the web origin, for a product's links and messages: `url`, else the job's server when it is the target's host, else https on the host.
115
+ const server = url ?? trimUrl(kind === "gitlab" ? e.CI_SERVER_URL : ((fj ? e.FORGEJO_SERVER_URL : undefined) ?? e.GITHUB_SERVER_URL));
116
+ out.origin = server && /^https?:\/\//i.test(server) && hostOf(server) === out.host ? originOf(server) : `https://${out.host}`;
105
117
  if (kind !== "gitlab" && (repo || url)) {
106
118
  const server = trimUrl(job("SERVER_URL"));
107
119
  const jobRepo = job("REPOSITORY");
@@ -193,6 +205,28 @@ export function forgeTargetFromFlags(
193
205
  return { ...t, tokenSource: "the token given" };
194
206
  }
195
207
 
208
+ /**
209
+ * {@link forgeTargetFromFlags}, or undefined where it would throw
210
+ * {@link ForgeEnvironmentError} (#4888): the environment names no forge, or
211
+ * lacks the repository or the token. For a product step that does its
212
+ * forge work only when the job can, as terragucci's own `targetFromEnv`
213
+ * did: give the token the product holds as `token`, the one variable to
214
+ * read as `tokenEnv`, and `tokenOptional` for a read a public repository
215
+ * answers with none.
216
+ */
217
+ export function jobForgeTarget(
218
+ flags: ForgeFlags,
219
+ env: Record<string, string | undefined> = process.env,
220
+ opts: Pick<ForgeTargetOptions, "requirePr" | "readFile"> & Pick<ForgeOverrides, "tokenOptional"> = {},
221
+ ): ForgeTarget | undefined {
222
+ try {
223
+ return forgeTargetFromFlags(flags, env, opts);
224
+ } catch (err) {
225
+ if (err instanceof ForgeEnvironmentError) return undefined;
226
+ throw err;
227
+ }
228
+ }
229
+
196
230
  /**
197
231
  * The flags that would supply what a {@link ForgeEnvironmentError} says is
198
232
  * missing, for a product's message: `outside CI pass --repo, --pr and
@@ -0,0 +1,37 @@
1
+ /**
2
+ * #4920: the forge a checkout's origin remote names, public, so a laptop
3
+ * command needs no repository setting.
4
+ */
5
+ import { execFileSync } from "node:child_process";
6
+ import { mkdtempSync } from "node:fs";
7
+ import { tmpdir } from "node:os";
8
+ import { join } from "node:path";
9
+ import { describe, expect, test } from "vitest";
10
+ import { forgeKindOfHost, forgeOfCheckout, forgeOfRemote } from "./forge-remote";
11
+
12
+ describe("forgeOfRemote (#4920)", () => {
13
+ test("https, ssh and scp remotes on each forge", () => {
14
+ expect(forgeOfRemote("https://github.com/acme/infra.git")).toEqual({ kind: "github", host: "github.com", url: "https://github.com", repo: "acme/infra" });
15
+ expect(forgeOfRemote("git@gitlab.com:group/sub/proj.git")).toEqual({ kind: "gitlab", host: "gitlab.com", url: "https://gitlab.com", repo: "group/sub/proj" });
16
+ expect(forgeOfRemote("ssh://git@codeberg.org:22/acme/infra")).toEqual({ kind: "forgejo", host: "codeberg.org", url: "https://codeberg.org", repo: "acme/infra" });
17
+ expect(forgeOfRemote("http://forgejo.lan:3000/acme/infra.git")).toEqual({ kind: "forgejo", host: "forgejo.lan:3000", url: "http://forgejo.lan:3000", repo: "acme/infra" });
18
+ });
19
+
20
+ test("a host no forge is named for, unless the kind is given; no repository path is none", () => {
21
+ expect(forgeOfRemote("git@git.corp.example:acme/infra.git")).toBeUndefined();
22
+ expect(forgeOfRemote("git@git.corp.example:acme/infra.git", { kind: "gitlab" })).toMatchObject({ kind: "gitlab", repo: "acme/infra", url: "https://git.corp.example" });
23
+ expect(forgeOfRemote("https://github.com/")).toBeUndefined();
24
+ expect(forgeOfRemote(undefined)).toBeUndefined();
25
+ expect(forgeKindOfHost("GitHub.example.com")).toBe("github");
26
+ });
27
+
28
+ test("a checkout's origin, read with git", () => {
29
+ // A temporary checkout, left for the OS to clear.
30
+ const dir = mkdtempSync(join(tmpdir(), "chant-forge-remote-"));
31
+ execFileSync("git", ["-C", dir, "init", "-q"]);
32
+ expect(forgeOfCheckout(dir)).toBeUndefined();
33
+ execFileSync("git", ["-C", dir, "remote", "add", "origin", "git@github.com:acme/infra.git"]);
34
+ expect(forgeOfCheckout(dir)).toMatchObject({ kind: "github", repo: "acme/infra" });
35
+ expect(forgeOfCheckout(dir, { remote: "upstream" })).toBeUndefined();
36
+ });
37
+ });
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The forge a checkout's origin remote names (#4920): its kind, host, web
3
+ * origin and repository, for a command run on a laptop with no CI variables
4
+ * and no repository setting, such as plywood's `cancel`.
5
+ *
6
+ * It is the reading chant's own laptop paths make when the environment
7
+ * names no forge (`forgeWorkReader` in ./workspace/forge-work.ts): the
8
+ * host from the remote's URL, the kind from the host's name, and the
9
+ * repository path. Kept out of `pr-forge.ts`, which is in the pr-forge and
10
+ * pr-loop bundles.
11
+ */
12
+
13
+ import { execFileSync } from "node:child_process";
14
+ import type { ForgeKind } from "./pr-forge";
15
+ import { remoteRepoPath } from "./op/activities/forge-pull-request";
16
+ import { remoteHost } from "./op/activities/gh-host";
17
+
18
+ export { remoteRepoPath, remoteHost };
19
+
20
+ /** The forge kind a remote host is: github.com and hosts named for GitHub, GitLab, or Forgejo and Gitea (codeberg.org too). Null for any other. */
21
+ export function forgeKindOfHost(host: string): ForgeKind | null {
22
+ const h = host.toLowerCase().replace(/:\d+$/, "");
23
+ if (h === "github.com" || /(^|[.-])github([.-]|$)/.test(h)) return "github";
24
+ if (h === "gitlab.com" || /(^|[.-])gitlab([.-]|$)/.test(h)) return "gitlab";
25
+ if (h === "codeberg.org" || /(^|[.-])(forgejo|gitea)([.-]|$)/.test(h)) return "forgejo";
26
+ return null;
27
+ }
28
+
29
+ /** The forge a git remote names. */
30
+ export interface RemoteForge {
31
+ kind: ForgeKind;
32
+ /** Lower-cased, with an http(s) remote's port. */
33
+ host: string;
34
+ /** The web origin, `https://host` (an http remote keeps its scheme and port), as `--url` takes it. */
35
+ url: string;
36
+ /** `owner/name`, or a GitLab group path and name. */
37
+ repo: string;
38
+ }
39
+
40
+ /**
41
+ * The forge a remote URL names (`https://host/o/r.git`, `ssh://git@host/o/r`,
42
+ * `git@host:o/r`), or undefined when it names no repository path or its host
43
+ * is none {@link forgeKindOfHost} knows. `kind` stands in for the host's
44
+ * guess, for a self-hosted forge whose name says nothing.
45
+ */
46
+ export function forgeOfRemote(remoteUrl: string | undefined, opts: { kind?: ForgeKind } = {}): RemoteForge | undefined {
47
+ const host = remoteHost(remoteUrl);
48
+ const repo = remoteRepoPath(remoteUrl);
49
+ if (!host || !repo) return undefined;
50
+ const kind = opts.kind ?? forgeKindOfHost(host);
51
+ if (!kind) return undefined;
52
+ let url = `https://${host.replace(/:\d+$/, "")}`;
53
+ try {
54
+ const u = new URL(remoteUrl!.trim());
55
+ if (u.protocol === "http:" || u.protocol === "https:") url = `${u.protocol}//${u.host.toLowerCase()}`;
56
+ } catch {
57
+ // An scp-style remote is ssh, whose port is not the web's.
58
+ }
59
+ return { kind, host, url, repo };
60
+ }
61
+
62
+ /** `git remote get-url <remote>` in `cwd`, or undefined when there is none. */
63
+ function gitRemoteUrl(cwd: string, remote: string): string | undefined {
64
+ try {
65
+ return execFileSync("git", ["remote", "get-url", remote], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim() || undefined;
66
+ } catch {
67
+ return undefined;
68
+ }
69
+ }
70
+
71
+ /**
72
+ * The forge the checkout at `cwd` names by its `origin` remote (or
73
+ * `remote`), as {@link forgeOfRemote} reads it. Undefined outside a
74
+ * checkout, with no such remote, or for a host no forge kind is known for.
75
+ */
76
+ export function forgeOfCheckout(cwd: string, opts: { remote?: string; kind?: ForgeKind; remoteUrl?: (cwd: string, remote: string) => string | undefined } = {}): RemoteForge | undefined {
77
+ const url = (opts.remoteUrl ?? gitRemoteUrl)(cwd, opts.remote ?? "origin");
78
+ return forgeOfRemote(url, opts.kind ? { kind: opts.kind } : {});
79
+ }
@@ -0,0 +1,98 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
+ import { describe, expect, it } from "vitest";
7
+
8
+ /**
9
+ * #4909 end to end: `chant dev generated-check` through the real CLI, on a
10
+ * product whose release workflow `chant release workflow` writes, the render
11
+ * terragucci's `just ci-check` had to strip `--output` from with sed; and
12
+ * `chant dev local-image` on a pinned and a local chant.
13
+ */
14
+
15
+ const here = dirname(fileURLToPath(import.meta.url));
16
+ const mainTs = resolve(here, "cli/main.ts");
17
+ const tsxLoader = pathToFileURL(resolve(here, "../../../node_modules/tsx/dist/loader.mjs")).href;
18
+ const chantCommand = `${JSON.stringify(process.execPath)} --import ${tsxLoader} ${JSON.stringify(mainTs)}`;
19
+
20
+ const write = (file: string, body: string | object) => {
21
+ mkdirSync(dirname(file), { recursive: true });
22
+ writeFileSync(file, typeof body === "string" ? body : JSON.stringify(body, null, 2) + "\n");
23
+ };
24
+
25
+ const chant = (cwd: string, ...args: string[]) => spawnSync(process.execPath, ["--import", tsxLoader, mainTs, ...args], { cwd, encoding: "utf8", env: { ...process.env, NO_COLOR: "1" }, timeout: 110_000 });
26
+
27
+ /** A git repository holding a chant workspace with a committed release workflow. */
28
+ function product(): string {
29
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), "chant-4909-e2e-")));
30
+ write(join(dir, "chant.workspace.json"), { name: "product", schema: 1, members: [] });
31
+ write(join(dir, "chant.config.json"), { lexicons: [] });
32
+ write(join(dir, "package.json"), {
33
+ name: "product",
34
+ private: true,
35
+ chantGenerated: {
36
+ regenerate: "chant release workflow --forge github",
37
+ renders: [{ name: "release", run: `${chantCommand} release workflow --forge github --output {out}/.github/workflows/chant-release.yml`, files: [".github/workflows/chant-release.yml"] }],
38
+ },
39
+ });
40
+ mkdirSync(join(dir, ".github/workflows"), { recursive: true });
41
+ expect(spawnSync("git", ["init", "-q"], { cwd: dir }).status).toBe(0);
42
+ return dir;
43
+ }
44
+
45
+ describe("chant dev generated-check (#4909)", () => {
46
+ it("passes on the committed release workflow, then fails a hand edit and leaves the render tree", () => {
47
+ const dir = product();
48
+ const written = chant(dir, "release", "workflow", "--forge", "github");
49
+ expect(written.status).toBe(0);
50
+ const committed = readFileSync(join(dir, ".github/workflows/chant-release.yml"), "utf8");
51
+ expect(committed.split("\n")[0]).not.toContain("--output");
52
+
53
+ const ok = chant(dir, "dev", "generated-check", "--json");
54
+ expect(ok.status).toBe(0);
55
+ const result = JSON.parse(ok.stdout);
56
+ expect(result.matched).toEqual([".github/workflows/chant-release.yml"]);
57
+ // The check rendered beside the product and wrote nothing in it.
58
+ expect(readFileSync(join(dir, ".github/workflows/chant-release.yml"), "utf8")).toBe(committed);
59
+ expect(readFileSync(join(result.out, ".github/workflows/chant-release.yml"), "utf8")).toBe(committed);
60
+
61
+ writeFileSync(join(dir, ".github/workflows/chant-release.yml"), committed.replace("name: chant release", "name: hand edited"));
62
+ const bad = chant(dir, "dev", "generated-check");
63
+ expect(bad.status).toBe(1);
64
+ expect(bad.stderr).toContain(".github/workflows/chant-release.yml is not what 'release' renders. Run 'chant release workflow --forge github' and commit the result.");
65
+ expect(bad.stderr).toContain("+ name: chant release");
66
+ expect(bad.stderr).toMatch(/the renders are in .*chant-generated-/);
67
+ }, 120_000);
68
+
69
+ it("refuses a product with no chantGenerated", () => {
70
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), "chant-4909-e2e-none-")));
71
+ write(join(dir, "package.json"), { name: "none" });
72
+ const r = chant(dir, "dev", "generated-check");
73
+ expect(r.status).toBe(2);
74
+ expect(r.stderr).toContain("declares no chantGenerated");
75
+ }, 60_000);
76
+ });
77
+
78
+ describe("chant dev local-image (#4909)", () => {
79
+ it("names the pin, then the local build and its build context, and refuses a missing tarball", () => {
80
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), "chant-4909-e2e-image-")));
81
+ write(join(dir, "package.json"), { name: "product", private: true, devDependencies: { "@intentius/chant": "1.2.3" } });
82
+ write(join(dir, "node_modules/@intentius/chant/package.json"), { name: "@intentius/chant", version: "1.2.3" });
83
+ const pinned = chant(dir, "dev", "local-image");
84
+ expect(pinned.status).toBe(0);
85
+ expect(pinned.stdout.trim()).toBe("1.2.3");
86
+
87
+ write(join(dir, "node_modules/@intentius/chant/package.json"), { name: "@intentius/chant", version: "1.3.0", chantLocal: { commit: "abc123", dir: "/chant" } });
88
+ write(join(dir, ".chant-local/commit"), "abc123\n");
89
+ write(join(dir, ".chant-local/intentius-chant.tgz"), "tgz");
90
+ const local = chant(dir, "dev", "local-image", "--json");
91
+ expect(local.status).toBe(0);
92
+ expect(JSON.parse(local.stdout).args).toEqual(["--build-context", `chant-local=${join(dir, ".chant-local")}`, "--build-arg", "CHANT_VERSION=local-abc123"]);
93
+
94
+ const missing = chant(dir, "dev", "local-image", "--with", "@intentius/chant-lexicon-fountain");
95
+ expect(missing.status).toBe(1);
96
+ expect(missing.stderr).toContain("no tarball for @intentius/chant-lexicon-fountain; run chant dev local again with --with @intentius/chant-lexicon-fountain");
97
+ }, 60_000);
98
+ });
@@ -0,0 +1,104 @@
1
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { dirname, join } from "node:path";
4
+ import { afterEach, describe, expect, it } from "vitest";
5
+ import { checkGenerated, committedPathOf, diffLines, GENERATED_OUT_ENV, GENERATED_ROOT_ENV, isRenderPath, readGeneratedCheckConfig, renderPathOf, type GeneratedCheckConfig } from "./generated-check";
6
+
7
+ /** #4909: a product's generated files checked by chant instead of terragucci's `just ci-check` and plywood's `--check` scripts. */
8
+
9
+ const write = (file: string, body: string | object) => {
10
+ mkdirSync(dirname(file), { recursive: true });
11
+ writeFileSync(file, typeof body === "string" ? body : JSON.stringify(body, null, 2) + "\n");
12
+ };
13
+
14
+ /** A product whose committed files are what its renders write: a workflow, two Dockerfiles by pattern, and a script that checks itself. */
15
+ function product(): { dir: string; config: GeneratedCheckConfig } {
16
+ const dir = mkdtempSync(join(tmpdir(), "chant-4909-product-"));
17
+ write(join(dir, ".github/workflows/ci.yml"), "name: ci\non: push\n");
18
+ write(join(dir, "images/Dockerfile.tofu"), "FROM tofu\n");
19
+ write(join(dir, "images/Dockerfile.node"), "FROM node\n");
20
+ write(join(dir, "images/images.ts"), "// the source\n");
21
+ const config: GeneratedCheckConfig = {
22
+ regenerate: "just ci",
23
+ renders: [
24
+ { name: "ci", run: "mkdir -p {out}/.github/workflows && printf 'name: ci\\non: push\\n' > {out}/.github/workflows/ci.yml", files: [".github/workflows/ci.yml"] },
25
+ { name: "images", run: 'mkdir -p "$CHANT_GENERATED_OUT/images" && printf "FROM tofu\\n" > "$CHANT_GENERATED_OUT/images/Dockerfile.tofu" && printf "FROM node\\n" > "$CHANT_GENERATED_OUT/images/Dockerfile.node"', files: ["images/Dockerfile.*"] },
26
+ { name: "dashboards", run: "true" },
27
+ ],
28
+ };
29
+ write(join(dir, "package.json"), { name: "product", private: true, chantGenerated: config });
30
+ return { dir, config };
31
+ }
32
+
33
+ describe("checkGenerated (#4909)", () => {
34
+ it("passes when every committed file is its render, and leaves the render tree", async () => {
35
+ const { dir, config } = product();
36
+ const r = await checkGenerated(dir, config);
37
+ expect(r.problems).toEqual([]);
38
+ expect(r.ok).toBe(true);
39
+ expect(r.matched).toEqual([".github/workflows/ci.yml", "images/Dockerfile.node", "images/Dockerfile.tofu"]);
40
+ expect(r.out).toContain("chant-generated-");
41
+ expect(readFileSync(join(r.out, "images/Dockerfile.tofu"), "utf8")).toBe("FROM tofu\n");
42
+ });
43
+
44
+ it("fails a hand edit with a diff and the regenerate command, and a file on one side only", async () => {
45
+ const { dir, config } = product();
46
+ write(join(dir, ".github/workflows/ci.yml"), "name: ci\non: pull_request\n");
47
+ write(join(dir, "images/Dockerfile.old"), "FROM old\n");
48
+ const r = await checkGenerated(dir, config);
49
+ expect(r.ok).toBe(false);
50
+ expect(r.problems[0]).toContain(".github/workflows/ci.yml is not what 'ci' renders. Run 'just ci' and commit the result.");
51
+ expect(r.problems[0]).toContain("- on: pull_request");
52
+ expect(r.problems[0]).toContain("+ on: push");
53
+ expect(r.problems[1]).toBe("images/Dockerfile.old is committed, but 'images' no longer renders it. Run 'just ci' and commit the result.");
54
+ expect(existsSync(r.out)).toBe(true);
55
+ });
56
+
57
+ it("fails a render that exits non-zero or writes nothing, and a name it does not have", async () => {
58
+ const { dir } = product();
59
+ const r = await checkGenerated(dir, {
60
+ renders: [
61
+ { name: "broken", run: "echo nope >&2; exit 3", files: ["a.yml"] },
62
+ { name: "silent", run: "true", files: [".github/workflows/ci.yml"] },
63
+ ],
64
+ }, { only: ["broken", "silent", "absent"] });
65
+ expect(r.problems).toEqual([
66
+ "chantGenerated has no render named 'absent'",
67
+ "render 'broken' exited 3: echo nope >&2; exit 3\n nope",
68
+ "render 'silent' wrote no .github/workflows/ci.yml under the render tree",
69
+ ]);
70
+ });
71
+
72
+ it("reads chantGenerated and refuses a malformed one", () => {
73
+ const { dir, config } = product();
74
+ expect(readGeneratedCheckConfig(dir)).toEqual(config);
75
+ write(join(dir, "package.json"), { chantGenerated: { renders: [{ name: "x", run: "true", files: ["../outside"] }] } });
76
+ expect(() => readGeneratedCheckConfig(dir)).toThrow("must be paths inside the product");
77
+ write(join(dir, "package.json"), { name: "none" });
78
+ expect(readGeneratedCheckConfig(dir)).toBeUndefined();
79
+ });
80
+
81
+ it("diffs from the first line that differs", () => {
82
+ expect(diffLines("a\nb\nc\nd\n", "a\nb\nX\nd\n")).toEqual(["@@ line 3 @@", " a", " b", "- c", "+ X"]);
83
+ });
84
+ });
85
+
86
+ describe("chant's writers under a check (#4909)", () => {
87
+ afterEach(() => {
88
+ delete process.env[GENERATED_OUT_ENV];
89
+ delete process.env[GENERATED_ROOT_ENV];
90
+ });
91
+
92
+ it("move a product path into the render tree and name a render path as the committed one", () => {
93
+ expect(renderPathOf("/p/.github/workflows/a.yml")).toBe("/p/.github/workflows/a.yml");
94
+ process.env[GENERATED_OUT_ENV] = "/t/out";
95
+ process.env[GENERATED_ROOT_ENV] = "/p";
96
+ expect(renderPathOf("/p/.github/workflows/a.yml")).toBe("/t/out/.github/workflows/a.yml");
97
+ expect(renderPathOf("/elsewhere/a.yml")).toBe("/elsewhere/a.yml");
98
+ expect(renderPathOf("/t/out/a.yml")).toBe("/t/out/a.yml");
99
+ expect(committedPathOf("/t/out/.github/workflows/a.yml")).toBe("/p/.github/workflows/a.yml");
100
+ expect(committedPathOf("/p/a.yml")).toBe("/p/a.yml");
101
+ expect(isRenderPath("/t/out/x")).toBe(true);
102
+ expect(isRenderPath("/t/outside/x")).toBe(false);
103
+ });
104
+ });