@homepages/concrete 11.0.0 → 13.0.0

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 (322) hide show
  1. package/CHANGELOG.md +203 -0
  2. package/README.md +8 -10
  3. package/codemods/fixtures-are-data.mjs +7 -0
  4. package/codemods/fixtures-list-properties.mjs +6 -0
  5. package/codemods/manifest.json +17 -0
  6. package/codemods/steps/fixtures-list-properties.mjs +16 -0
  7. package/codemods/steps/fixtures-to-data.mjs +41 -0
  8. package/dist/artifact/playground/client/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  9. package/dist/artifact/playground/client/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  10. package/dist/artifact/playground/client/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  11. package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +1338 -0
  12. package/dist/artifact/playground/client/assets/index-C01UCAWD.css +1 -0
  13. package/dist/artifact/playground/client/index.html +2 -2
  14. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
  15. package/dist/artifact/playground/host.mjs +110 -60
  16. package/dist/base.css +19 -59
  17. package/dist/cli/build/icons.js +1 -1
  18. package/dist/cli/build/index.js +11 -10
  19. package/dist/cli/build/manifest.js +44 -0
  20. package/dist/cli/build/record.js +123 -0
  21. package/dist/cli/build/sections.js +28 -18
  22. package/dist/cli/build/source.js +1 -1
  23. package/dist/cli/build/static.js +8 -5
  24. package/dist/cli/build/template-build.js +614 -0
  25. package/dist/cli/check/analyze.js +18 -1
  26. package/dist/cli/check/load-workspace.js +2 -2
  27. package/dist/cli/check/portable-names.js +1 -1
  28. package/dist/cli/check/render/corpus.js +119 -0
  29. package/dist/cli/check/render/invariants.js +1 -0
  30. package/dist/cli/check/stages/bundles.js +15 -18
  31. package/dist/cli/check/stages/composition.js +8 -25
  32. package/dist/cli/check/stages/fixtures.js +14 -10
  33. package/dist/cli/check/stages/logic.js +7 -23
  34. package/dist/cli/check/stages/render.js +12 -14
  35. package/dist/cli/check/stages/sections.js +22 -66
  36. package/dist/cli/check/stages/stylesheet.js +4 -26
  37. package/dist/cli/check/stages/workspace.js +27 -22
  38. package/dist/cli/commands.js +51 -23
  39. package/dist/cli/currency/preamble.js +1 -1
  40. package/dist/cli/currency/resolve-latest.js +3 -2
  41. package/dist/cli/dev/capture-browser.js +26 -0
  42. package/dist/cli/dev/fixture-schema.js +441 -0
  43. package/dist/cli/dev/folder-files.js +244 -0
  44. package/dist/cli/dev/index.js +7 -3
  45. package/dist/cli/dev/playground-server.js +34 -0
  46. package/dist/cli/dev/section-ladders.js +76 -0
  47. package/dist/cli/dev/server.js +120 -304
  48. package/dist/cli/install/background.js +16 -0
  49. package/dist/cli/install/index.js +45 -0
  50. package/dist/cli/install/tools.js +27 -0
  51. package/dist/cli/media/derive.js +19 -13
  52. package/dist/cli/media/deriver-plugin.js +14 -3
  53. package/dist/cli/property/fixture-list.js +46 -0
  54. package/dist/cli/property/index.js +12 -9
  55. package/dist/cli/property/library.js +12 -10
  56. package/dist/cli/publish/artifact.js +90 -0
  57. package/dist/cli/publish/captures.js +61 -0
  58. package/dist/cli/publish/fixtures.js +17 -0
  59. package/dist/cli/publish/index.js +10 -18
  60. package/dist/cli/{build → publish}/playground.js +3 -3
  61. package/dist/cli/publish/report.js +15 -33
  62. package/dist/cli/upgrade/codemod.d.ts +14 -0
  63. package/dist/cli/upgrade/fixture-conversion.d.ts +11 -0
  64. package/dist/cli/upgrade/fixture-conversion.js +54 -0
  65. package/dist/cli/upgrade/fixture-modules.js +125 -0
  66. package/dist/cli/upgrade/fixtures-to-data.d.ts +40 -0
  67. package/dist/cli/upgrade/fixtures-to-data.js +498 -0
  68. package/dist/cli/upgrade/index.js +18 -2
  69. package/dist/cli/upgrade/legacy-fixtures.d.ts +34 -0
  70. package/dist/cli/upgrade/legacy-fixtures.js +22 -0
  71. package/dist/cli/upgrade/stage.js +1 -1
  72. package/dist/cli/workspace-fixtures.js +80 -0
  73. package/dist/cli.js +1 -0
  74. package/dist/css/compile.js +9 -3
  75. package/dist/fixtures/bundle-rule.js +16 -16
  76. package/dist/fixtures/media-plugin.js +12 -33
  77. package/dist/fixtures/synthesize-empties.js +3 -2
  78. package/dist/index.d.ts +7 -7
  79. package/dist/{playground-island-runtime.d.ts → island-runtime.d.ts} +1 -2
  80. package/dist/{playground-island-runtime.js → island-runtime.js} +1 -2
  81. package/dist/islands/client-module.js +1 -1
  82. package/dist/{cli/dev → islands}/tsconfig-paths.js +2 -14
  83. package/dist/islands/wrap.js +40 -0
  84. package/dist/node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js +5119 -0
  85. package/dist/packages/external/concrete/package.js +1 -1
  86. package/dist/packages/internal/bundle-evaluation/dist/cache.js +36 -0
  87. package/dist/packages/internal/bundle-evaluation/dist/evaluate.js +174 -0
  88. package/dist/packages/internal/bundle-evaluation/dist/index.js +5 -0
  89. package/dist/packages/internal/bundle-evaluation/dist/section-code.js +10 -0
  90. package/dist/packages/internal/capture-settle/dist/index.js +2 -2
  91. package/dist/packages/internal/capture-settle/dist/settle.js +88 -13
  92. package/dist/packages/internal/code-fingerprint/dist/index.js +57 -0
  93. package/dist/packages/internal/content-doc-ops/dist/index.js +176 -0
  94. package/dist/packages/internal/content-doc-ops/dist/made-rows.js +15 -0
  95. package/dist/packages/internal/deliverable-reads/dist/bootstrap.js +81 -0
  96. package/dist/packages/internal/deliverable-reads/dist/display.js +21 -0
  97. package/dist/packages/internal/deliverable-reads/dist/format.js +15 -0
  98. package/dist/packages/internal/deliverable-reads/dist/index.js +7 -0
  99. package/dist/packages/internal/deliverable-reads/dist/pages.js +29 -0
  100. package/dist/packages/internal/deliverable-reads/dist/requirements.js +72 -0
  101. package/dist/{cli/capture → packages/internal/download-files/dist}/bundle.js +8 -4
  102. package/dist/packages/internal/download-files/dist/capture-origin.js +126 -0
  103. package/dist/packages/internal/download-files/dist/capture-routes.js +139 -0
  104. package/dist/packages/internal/download-files/dist/capture-shell.js +38 -0
  105. package/dist/packages/internal/download-files/dist/capture.js +74 -0
  106. package/dist/packages/internal/download-files/dist/egress-watch.js +38 -0
  107. package/dist/packages/internal/download-files/dist/files.js +7 -0
  108. package/dist/packages/internal/download-files/dist/finish.js +35 -0
  109. package/dist/packages/internal/download-files/dist/fleet.js +94 -0
  110. package/dist/packages/internal/download-files/dist/format.js +40 -0
  111. package/dist/packages/internal/download-files/dist/make.js +105 -0
  112. package/dist/packages/internal/download-files/dist/master-tally.js +32 -0
  113. package/dist/packages/internal/download-files/dist/names.js +24 -0
  114. package/dist/packages/internal/download-files/dist/pdf-boxes.js +33 -0
  115. package/dist/packages/internal/download-files/dist/pdf-image-placements.js +194 -0
  116. package/dist/packages/internal/download-files/dist/pdf-images.js +289 -0
  117. package/dist/packages/internal/file-store/dist/files.js +8 -0
  118. package/dist/packages/internal/file-store/dist/lru.js +40 -0
  119. package/dist/packages/internal/file-store/dist/refusal.js +12 -0
  120. package/dist/packages/internal/file-store/dist/trees.js +151 -0
  121. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +1 -1
  122. package/dist/packages/internal/fill-bake/dist/compute-reads.js +48 -22
  123. package/dist/packages/internal/fill-bake/dist/held-rows.js +2 -0
  124. package/dist/packages/internal/fill-bake/dist/index.js +6 -1
  125. package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
  126. package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
  127. package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
  128. package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
  129. package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
  130. package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
  131. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
  132. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
  133. package/dist/packages/internal/format-geometry/dist/capture.js +3 -11
  134. package/dist/packages/internal/format-geometry/dist/format.d.ts +2 -8
  135. package/dist/packages/internal/format-geometry/dist/geometry.js +2 -13
  136. package/dist/packages/internal/island-runtime/dist/index.js +1 -10
  137. package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
  138. package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
  139. package/dist/packages/internal/media-resolution/dist/video.js +6 -2
  140. package/dist/packages/internal/page-render/dist/addresses.js +57 -0
  141. package/dist/packages/internal/page-render/dist/index.js +6 -0
  142. package/dist/packages/internal/page-render/dist/kept.js +30 -0
  143. package/dist/packages/internal/page-render/dist/nav.js +42 -0
  144. package/dist/packages/internal/page-render/dist/render.js +152 -0
  145. package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
  146. package/dist/packages/internal/page-shell/dist/escape.js +10 -0
  147. package/dist/packages/internal/page-shell/dist/frame.js +23 -0
  148. package/dist/packages/internal/page-shell/dist/index.js +26 -0
  149. package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
  150. package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
  151. package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
  152. package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
  153. package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
  154. package/dist/packages/internal/playground/dist/host/built.js +202 -0
  155. package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
  156. package/dist/packages/internal/playground/dist/host/download.js +34 -0
  157. package/dist/packages/internal/playground/dist/host/env.js +11 -0
  158. package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
  159. package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
  160. package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
  161. package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
  162. package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
  163. package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
  164. package/dist/packages/internal/playground/dist/host/leads.js +41 -0
  165. package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
  166. package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
  167. package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
  168. package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
  169. package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
  170. package/dist/packages/internal/playground/dist/host/program.js +54 -0
  171. package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
  172. package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
  173. package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
  174. package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
  175. package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
  176. package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
  177. package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
  178. package/dist/packages/internal/playground/dist/host/save.js +429 -0
  179. package/dist/packages/internal/playground/dist/host/serve.js +952 -0
  180. package/dist/packages/internal/playground/dist/host/site.js +79 -0
  181. package/dist/packages/internal/playground/dist/host/slots.js +202 -0
  182. package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
  183. package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
  184. package/dist/packages/internal/playground/dist/host/violations.js +7 -0
  185. package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
  186. package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
  187. package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
  188. package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
  189. package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
  190. package/dist/packages/internal/playground/dist/layout.js +14 -0
  191. package/dist/packages/internal/playground/dist/platform.js +33 -0
  192. package/dist/packages/internal/playground/dist/server/changes.js +57 -0
  193. package/dist/packages/internal/playground/dist/server/crop.js +47 -0
  194. package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
  195. package/dist/packages/internal/playground/dist/server/download.js +158 -0
  196. package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
  197. package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
  198. package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
  199. package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
  200. package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
  201. package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
  202. package/dist/packages/internal/playground/dist/server/verification.js +75 -0
  203. package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
  204. package/dist/packages/internal/playground/dist/wire.js +78 -0
  205. package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
  206. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
  207. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
  208. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
  209. package/dist/packages/internal/site-files/dist/head.js +59 -0
  210. package/dist/packages/internal/site-files/dist/index.js +4 -0
  211. package/dist/packages/internal/site-files/dist/site.js +211 -0
  212. package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
  213. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
  214. package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
  215. package/dist/packages/internal/template-artifact/dist/build.js +148 -0
  216. package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
  217. package/dist/packages/internal/template-artifact/dist/index.js +2 -2
  218. package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
  219. package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
  220. package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
  221. package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
  222. package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
  223. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
  224. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
  225. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
  226. package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
  227. package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
  228. package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
  229. package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
  230. package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
  231. package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
  232. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
  233. package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
  234. package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
  235. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
  236. package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
  237. package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
  238. package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
  239. package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
  240. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
  241. package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
  242. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
  243. package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
  244. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
  245. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
  246. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
  247. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
  248. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
  249. package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
  250. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
  251. package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
  252. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
  253. package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
  254. package/dist/packages/internal/upload-formats/dist/index.js +80 -0
  255. package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
  256. package/dist/platform/paths.js +1 -0
  257. package/dist/platform/process.js +49 -1
  258. package/dist/primitives/FrameShell.d.ts +5 -2
  259. package/dist/primitives/FrameShell.js +2 -1
  260. package/dist/rules/registry.js +28 -4
  261. package/dist/schema/fact.d.ts +2 -2
  262. package/dist/schema/facts-view.d.ts +1 -1
  263. package/dist/schema/format.d.ts +0 -1
  264. package/dist/schema/format.js +1 -2
  265. package/dist/schema/manifest.js +18 -24
  266. package/dist/schema/section-props.d.ts +1 -1
  267. package/dist/schema/section-schema.d.ts +1 -1
  268. package/dist/schema/section-schema.js +1 -0
  269. package/dist/section/declare.d.ts +1 -1
  270. package/dist/section/discovery.js +6 -2
  271. package/dist/section/publish-shape.js +38 -0
  272. package/dist/section/section.d.ts +1 -1
  273. package/dist/site-analytics.js +6 -1
  274. package/dist/site-runtime/window-height.js +19 -0
  275. package/dist/template/define-template.d.ts +25 -4
  276. package/dist/template/define-template.js +3 -0
  277. package/dist/template/logic-shim.d.ts +1 -1
  278. package/dist/template/materialize.js +3 -1
  279. package/dist/template/running-copy.js +0 -1
  280. package/dist/template/section-reads.js +1 -1
  281. package/guide/reference/cli/INDEX.md +6 -5
  282. package/guide/reference/cli/build.md +10 -8
  283. package/guide/reference/cli/check.md +4 -2
  284. package/guide/reference/cli/dev.md +6 -2
  285. package/guide/reference/cli/install.md +41 -0
  286. package/guide/reference/cli/property-add.md +5 -4
  287. package/guide/reference/cli/property-list.md +2 -2
  288. package/guide/reference/cli/publish.md +5 -5
  289. package/guide/reference/cli/upgrade.md +1 -1
  290. package/guide/reference/rules/INDEX.md +9 -5
  291. package/package.json +14 -30
  292. package/dist/artifact/playground/client/assets/index-ByeGGedv.js +0 -1259
  293. package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
  294. package/dist/cli/build/artifact.js +0 -220
  295. package/dist/cli/build/captures.js +0 -48
  296. package/dist/cli/build/fixtures.js +0 -92
  297. package/dist/cli/capture/capture-browser.js +0 -37
  298. package/dist/cli/capture/capture.js +0 -113
  299. package/dist/cli/check/render/inputs.js +0 -60
  300. package/dist/cli/check/render/nav.js +0 -31
  301. package/dist/cli/dev/crop.js +0 -20
  302. package/dist/cli/dev/fixture-ladders.js +0 -96
  303. package/dist/cli/dev/hmr.js +0 -26
  304. package/dist/cli/dev/islands.js +0 -234
  305. package/dist/cli/dev/load-template.js +0 -52
  306. package/dist/cli/dev/vite.js +0 -114
  307. package/dist/cli/dev/workspace-reader.js +0 -248
  308. package/dist/cli/publish/freshness.js +0 -64
  309. package/dist/fixtures/brand.d.ts +0 -4
  310. package/dist/fixtures/brand.js +0 -8
  311. package/dist/fixtures/load.js +0 -159
  312. package/dist/fixtures/resolve.js +0 -392
  313. package/dist/fixtures.d.ts +0 -429
  314. package/dist/fixtures.js +0 -23
  315. package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
  316. package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
  317. package/dist/playground/canvas-island-host.d.ts +0 -11
  318. package/dist/playground/canvas-island-host.js +0 -29
  319. package/dist/playground/canvas-markers.js +0 -14
  320. package/dist/playground/host/paths.js +0 -8
  321. package/dist/playground/layout.js +0 -17
  322. package/dist/playground/wire.js +0 -28
@@ -0,0 +1,46 @@
1
+ import { resolveReference } from "../../packages/internal/playground/dist/host/fixture-documents.js";
2
+ import { join } from "node:path";
3
+ import ts from "typescript";
4
+ import { readFile } from "node:fs/promises";
5
+
6
+ //#region src/cli/property/fixture-list.ts
7
+ const TEMPLATE_FILE = "template.ts";
8
+ const DEFAULT_FIXTURE_LIST = "fixtures/index.json";
9
+ function statedFixtureList(source) {
10
+ const file = ts.createSourceFile(TEMPLATE_FILE, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
11
+ let stated = null;
12
+ const visit = (node) => {
13
+ if (stated !== null) return;
14
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "defineTemplate") {
15
+ const arg = node.arguments[0];
16
+ if (arg === void 0 || !ts.isObjectLiteralExpression(arg)) return;
17
+ for (const member of arg.properties) {
18
+ if (!ts.isPropertyAssignment(member)) continue;
19
+ if ((ts.isIdentifier(member.name) || ts.isStringLiteral(member.name) ? member.name.text : null) === "fixtures" && ts.isStringLiteralLike(member.initializer)) stated = member.initializer.text;
20
+ }
21
+ return;
22
+ }
23
+ ts.forEachChild(node, visit);
24
+ };
25
+ visit(file);
26
+ return stated;
27
+ }
28
+ async function fixtureListOf(root) {
29
+ let source;
30
+ try {
31
+ source = await readFile(join(root, TEMPLATE_FILE), "utf8");
32
+ } catch {
33
+ return DEFAULT_FIXTURE_LIST;
34
+ }
35
+ const stated = statedFixtureList(source);
36
+ if (stated === null) return DEFAULT_FIXTURE_LIST;
37
+ const resolved = resolveReference(TEMPLATE_FILE, stated);
38
+ return "path" in resolved ? resolved.path : DEFAULT_FIXTURE_LIST;
39
+ }
40
+ function folderOf(path) {
41
+ const slash = path.lastIndexOf("/");
42
+ return slash === -1 ? "" : path.slice(0, slash);
43
+ }
44
+
45
+ //#endregion
46
+ export { DEFAULT_FIXTURE_LIST, TEMPLATE_FILE, fixtureListOf, folderOf, statedFixtureList };
@@ -1,5 +1,6 @@
1
1
  import { parseSpec } from "../commands.js";
2
2
  import { findWorkspaceRoot } from "../workspace.js";
3
+ import { fixtureListOf, folderOf } from "./fixture-list.js";
3
4
  import { LIBRARY_PACKAGE, openLibrary } from "./library.js";
4
5
  import { dirname, join } from "node:path";
5
6
  import { cp, lstat, mkdir, readFile, stat } from "node:fs/promises";
@@ -54,9 +55,6 @@ const COUNT_NOUNS = [
54
55
  "documents"
55
56
  ]
56
57
  ];
57
- function exportNameFor(slug) {
58
- return slug.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
59
- }
60
58
  function listingLines(index) {
61
59
  const width = Math.max(0, ...index.properties.map((p) => p.slug.length));
62
60
  return index.properties.map((property) => {
@@ -125,8 +123,11 @@ async function runAdd(argv, io, environment) {
125
123
  return 1;
126
124
  }
127
125
  const root = await findWorkspaceRoot(io.cwd);
128
- const shown = `fixtures/properties/${slug}/`;
129
- const destination = join(root, "fixtures", "properties", slug);
126
+ const list = await fixtureListOf(root);
127
+ const folder = folderOf(list);
128
+ const listDir = folder === "" ? "" : `${folder}/`;
129
+ const shown = `${listDir}properties/${slug}/`;
130
+ const destination = join(root, ...shown.split("/").filter(Boolean));
130
131
  if (await exists(destination)) {
131
132
  say(io.stderr, `${prefix}: ${shown} already exists. Nothing was copied — move or delete that folder to take the library's copy.`);
132
133
  return 1;
@@ -148,12 +149,14 @@ async function runAdd(argv, io, environment) {
148
149
  errorOnExist: true,
149
150
  force: false
150
151
  });
151
- const name = exportNameFor(slug);
152
152
  say(io.stdout, [
153
153
  `Copied ${shown} from ${LIBRARY_PACKAGE} ${library.version}. It is yours now: edit it freely.`,
154
- `Build a fixture on it in any module under fixtures/:`,
154
+ `List it: add "properties/${slug}/property.json" to the "properties" list in ${list}.`,
155
+ `Make a fixture on it: a content fixture beside ${list}, say ${listDir}${slug}.json, named by its file name,`,
156
+ "",
157
+ ` { "property": "properties/${slug}/property.json" }`,
155
158
  "",
156
- ` import { ${name} } from "./properties/${slug}/property";`
159
+ `and add "${slug}.json" to the "fixtures" list in ${list}.`
157
160
  ].join("\n"));
158
161
  return 0;
159
162
  }
@@ -168,4 +171,4 @@ function createPropertyCommand(environment = {}) {
168
171
  const runProperty = createPropertyCommand();
169
172
 
170
173
  //#endregion
171
- export { createPropertyCommand, exportNameFor, listingLines, runProperty };
174
+ export { createPropertyCommand, listingLines, runProperty };
@@ -8,7 +8,8 @@ import { createHash } from "node:crypto";
8
8
 
9
9
  //#region src/cli/property/library.ts
10
10
  const LIBRARY_PACKAGE = "@homepages/sample-properties";
11
- const LIBRARY_CACHE_RELATIVE = join("homepages", "sample-properties");
11
+ const LIBRARY_DIST_TAG = "documents";
12
+ const LIBRARY_CACHE_RELATIVE = join("homepages", "sample-property-documents");
12
13
  const REGISTRY_TIMEOUT_MS = 1e4;
13
14
  const DOWNLOAD_TIMEOUT_MS = 6e4;
14
15
  async function isDirectory(path) {
@@ -74,22 +75,22 @@ async function unpack(bytes, dir, version) {
74
75
  }
75
76
  }
76
77
  async function fromRegistry(root, registry, doFetch) {
77
- const latest = await resolveLatest(registry);
78
- if (latest === null || parseVersion(latest) === null) return null;
79
- const dir = join(root, latest);
78
+ const tagged = await resolveLatest(registry);
79
+ if (tagged === null || parseVersion(tagged) === null) return null;
80
+ const dir = join(root, tagged);
80
81
  if (await isDirectory(dir)) return {
81
- version: latest,
82
+ version: tagged,
82
83
  dir,
83
84
  source: "registry"
84
85
  };
85
- const dist = await readPublishedDist(latest, registry);
86
+ const dist = await readPublishedDist(tagged, registry);
86
87
  if (dist === null) return null;
87
88
  const bytes = await download(dist.tarball, doFetch);
88
89
  if (bytes === null) return null;
89
- if (!matchesDigest(bytes, dist)) throw new Error(`the tarball of ${LIBRARY_PACKAGE}@${latest} does not match the digest the registry published for it. Nothing was unpacked.`);
90
- await unpack(bytes, dir, latest);
90
+ if (!matchesDigest(bytes, dist)) throw new Error(`the tarball of ${LIBRARY_PACKAGE}@${tagged} does not match the digest the registry published for it. Nothing was unpacked.`);
91
+ await unpack(bytes, dir, tagged);
91
92
  return {
92
- version: latest,
93
+ version: tagged,
93
94
  dir,
94
95
  source: "registry"
95
96
  };
@@ -99,6 +100,7 @@ async function openLibrary(options) {
99
100
  const doFetch = options.fetchImpl ?? fetch;
100
101
  const published = await fromRegistry(root, {
101
102
  packageName: LIBRARY_PACKAGE,
103
+ distTag: LIBRARY_DIST_TAG,
102
104
  cwd: options.cwd,
103
105
  env: options.env,
104
106
  timeoutMs: REGISTRY_TIMEOUT_MS,
@@ -116,4 +118,4 @@ async function openLibrary(options) {
116
118
  }
117
119
 
118
120
  //#endregion
119
- export { DOWNLOAD_TIMEOUT_MS, LIBRARY_CACHE_RELATIVE, LIBRARY_PACKAGE, REGISTRY_TIMEOUT_MS, matchesDigest, openLibrary };
121
+ export { DOWNLOAD_TIMEOUT_MS, LIBRARY_CACHE_RELATIVE, LIBRARY_DIST_TAG, LIBRARY_PACKAGE, REGISTRY_TIMEOUT_MS, matchesDigest, openLibrary };
@@ -0,0 +1,90 @@
1
+ import { qualify } from "../../rules/registry.js";
2
+ import { MANIFEST_FILE, fixturePath } from "../../packages/internal/template-artifact/dist/layout.js";
3
+ import { ArtifactManifest } from "../../packages/internal/template-artifact/dist/manifest.js";
4
+ import { verifyArtifact } from "../../packages/internal/template-artifact/dist/verify.js";
5
+ import "../../packages/internal/template-artifact/dist/index.js";
6
+ import { unportablePaths } from "../../platform/names.js";
7
+ import { readBuiltFiles } from "../build/template-build.js";
8
+ import { analyzeWorkspace } from "../check/analyze.js";
9
+ import { captureFiles } from "./captures.js";
10
+ import { fixtureFiles } from "./fixtures.js";
11
+ import { playgroundFiles } from "./playground.js";
12
+ import { dirname, join, relative } from "node:path";
13
+ import { mkdir, writeFile } from "node:fs/promises";
14
+
15
+ //#region src/cli/publish/artifact.ts
16
+ async function gather(options) {
17
+ const { root } = options;
18
+ const { report, context } = await analyzeWorkspace({
19
+ root,
20
+ out: options.buildDir,
21
+ ...options.runCommand === void 0 ? {} : { runCommand: options.runCommand }
22
+ });
23
+ if (!report.ok) return {
24
+ ok: false,
25
+ report
26
+ };
27
+ const { build, fixtureFiles: fixtureSet } = context;
28
+ const template = build.workspace.template;
29
+ if (build.output === null || template === null || fixtureSet === void 0) throw new Error("publish: check passed without a written build and the fixtures an artifact carries.");
30
+ const passthrough = build.sections.flatMap((section) => section.bundles?.ok === true ? [...section.bundles.value.passthrough] : []);
31
+ if (passthrough.length > 0) throw new Error(`The template imports images that could not be derived because \`sharp\` did not load: ${passthrough.map((p) => relative(root, p)).join(", ")}. An artifact carries every image's responsive ladder; reinstall so sharp's native binary lands, then publish again.`);
32
+ const built = await readBuiltFiles(build.output);
33
+ const written = built.get(MANIFEST_FILE);
34
+ if (written === void 0) throw new Error(`publish: the build wrote no ${MANIFEST_FILE}.`);
35
+ const manifest = ArtifactManifest.parse(JSON.parse(new TextDecoder().decode(written)));
36
+ if (manifest.fixture_list !== fixtureSet.list) throw new Error(`publish: the build's ${MANIFEST_FILE} names the fixture list ${manifest.fixture_list}; check read ${fixtureSet.list}.`);
37
+ return {
38
+ ok: true,
39
+ report,
40
+ manifest,
41
+ built,
42
+ fixtures: await fixtureFiles({
43
+ root,
44
+ files: fixtureSet.files
45
+ }),
46
+ captureInput: {
47
+ root,
48
+ output: template.output,
49
+ build: build.output
50
+ }
51
+ };
52
+ }
53
+ const byPath = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
54
+ async function assembleArtifact(options) {
55
+ const gathered = await gather(options);
56
+ if (!gathered.ok) return gathered;
57
+ const { report, manifest } = gathered;
58
+ const files = new Map(gathered.built);
59
+ const put = (path, bytes) => {
60
+ const prior = files.get(path);
61
+ if (prior !== void 0 && Buffer.compare(prior, bytes) !== 0) throw new Error(`Two different files would be written as ${path}. Content-addressed names cannot collide; rename one of the sources.`);
62
+ files.set(path, bytes);
63
+ };
64
+ for (const [path, bytes] of gathered.fixtures) put(fixturePath(path), bytes);
65
+ for (const [path, bytes] of await playgroundFiles()) put(path, bytes);
66
+ const captures = await captureFiles({
67
+ ...gathered.captureInput,
68
+ ...options.browser === void 0 ? {} : { browser: options.browser }
69
+ });
70
+ for (const [path, bytes] of captures) put(path, bytes);
71
+ const verdict = verifyArtifact(files);
72
+ if (verdict.problems.length > 0) throw new Error(`publish: the artifact failed its own verification:\n${verdict.problems.map((p) => ` ${p.path}: ${p.message}`).join("\n")}`);
73
+ const unportable = unportablePaths(files.keys());
74
+ if (unportable.length > 0) throw new Error(`the artifact would not write the same files on Windows and macOS (${qualify("workspace/unportable-name")}):\n` + unportable.map((found) => ` ${found.paths.join(" and ")}: ${found.reason}`).join("\n") + "\nRename the source files these names come from.");
75
+ const sorted = [...files].sort(byPath);
76
+ for (const [path, bytes] of sorted) {
77
+ const target = join(options.out, ...path.split("/"));
78
+ await mkdir(dirname(target), { recursive: true });
79
+ await writeFile(target, bytes);
80
+ }
81
+ return {
82
+ ok: true,
83
+ report,
84
+ manifest,
85
+ files: new Map(sorted)
86
+ };
87
+ }
88
+
89
+ //#endregion
90
+ export { assembleArtifact };
@@ -0,0 +1,61 @@
1
+ import { CAPTURE_FILES, capturePath } from "../../packages/internal/template-artifact/dist/layout.js";
2
+ import "../../packages/internal/template-artifact/dist/index.js";
3
+ import { folderFiles } from "../dev/folder-files.js";
4
+ import { ROUTES } from "../../packages/internal/playground/dist/wire.js";
5
+ import { freeDevPort } from "../../packages/internal/playground/dist/server/listen.js";
6
+ import { startPlaygroundServer } from "../dev/playground-server.js";
7
+ import { Writable } from "node:stream";
8
+
9
+ //#region src/cli/publish/captures.ts
10
+ const silent = new Writable({ write: (_chunk, _encoding, done) => done() });
11
+ const DOWNLOAD_PATIENCE_MS = 10 * 6e4;
12
+ async function downloaded(url, what, optional) {
13
+ const deadline = Date.now() + DOWNLOAD_PATIENCE_MS;
14
+ for (;;) {
15
+ const answer = await fetch(url);
16
+ if (answer.status === 202 && Date.now() < deadline) continue;
17
+ if (optional && answer.status === 404) return null;
18
+ if (!answer.ok) throw new Error(`publish: downloading ${what} failed (${String(answer.status)}): ${await answer.text()}`);
19
+ return new Uint8Array(await answer.arrayBuffer());
20
+ }
21
+ }
22
+ async function captureFiles(options) {
23
+ const files = /* @__PURE__ */ new Map();
24
+ if (options.output === "website") return files;
25
+ const server = await startPlaygroundServer({
26
+ root: options.root,
27
+ port: await freeDevPort(),
28
+ log: silent,
29
+ files: folderFiles({
30
+ root: options.root,
31
+ build: { output: options.build }
32
+ }),
33
+ ...options.browser === void 0 ? {} : { browser: options.browser }
34
+ });
35
+ try {
36
+ const catalog = await (await fetch(new URL(ROUTES.catalog, server.url))).json();
37
+ if (catalog.error !== void 0) throw new Error(`publish: the playground did not open over the build for capture:\n${catalog.error}`);
38
+ for (const property of catalog.properties) for (const fixture of property.content) for (const format of catalog.template.formats) {
39
+ const of = `of fixture "${fixture.name}" at ${format.id}`;
40
+ const take = async (page, file, optional = false) => {
41
+ const bytes = await downloaded(new URL(ROUTES.download(property.name, fixture.name, {
42
+ format: format.id,
43
+ page
44
+ }), server.url), `${file} ${of}`, optional);
45
+ if (bytes !== null) files.set(capturePath(fixture.name, format.id, file), bytes);
46
+ };
47
+ if (catalog.template.output === "document") {
48
+ await take(null, CAPTURE_FILES.document);
49
+ continue;
50
+ }
51
+ for (const page of catalog.template.pages) await take(page.id, `${page.id}.png`, true);
52
+ if (catalog.template.pages.filter((page) => !(fixture.pagesOff ?? []).includes(page.id)).length > 1) await take(null, CAPTURE_FILES.bundle);
53
+ }
54
+ } finally {
55
+ await server.close();
56
+ }
57
+ return files;
58
+ }
59
+
60
+ //#endregion
61
+ export { captureFiles };
@@ -0,0 +1,17 @@
1
+ import { isFixtureFilePath } from "../../packages/internal/template-artifact/dist/layout.js";
2
+ import "../../packages/internal/template-artifact/dist/index.js";
3
+ import { join } from "node:path";
4
+ import { readFile } from "node:fs/promises";
5
+
6
+ //#region src/cli/publish/fixtures.ts
7
+ async function fixtureFiles(input) {
8
+ const out = /* @__PURE__ */ new Map();
9
+ for (const path of [...input.files].sort()) {
10
+ if (!isFixtureFilePath(path)) throw new Error(`The fixture file ${path} cannot ride in an artifact: a published fixture file's path is segments of letters, digits, ".", "_" and "-". Rename it.`);
11
+ out.set(path, new Uint8Array(await readFile(join(input.root, ...path.split("/")))));
12
+ }
13
+ return out;
14
+ }
15
+
16
+ //#endregion
17
+ export { fixtureFiles };
@@ -1,14 +1,13 @@
1
1
  import { DEFAULT_BUILD_DIR, booleanFlag, parseSpec, stringFlag } from "../commands.js";
2
- import { findWorkspaceRoot } from "../workspace.js";
3
2
  import { removeTree } from "../../platform/fs.js";
3
+ import { findWorkspaceRoot } from "../workspace.js";
4
4
  import { formatHuman } from "../check/report.js";
5
5
  import { TERMINAL_STATES } from "./wire.js";
6
6
  import { publicationClient } from "./client.js";
7
- import { assessFreshness } from "./freshness.js";
8
7
  import { readSourceFacts } from "./git.js";
9
8
  import { packArtifact } from "./pack.js";
10
9
  import { API_URL_VARIABLE, TOKEN_VARIABLE, TargetError, maskToken, resolveTarget } from "./target.js";
11
- import { adoptText, builtText, freshnessText, refusalText, stageLine, summaryText, targetText, uploadText, writeText } from "./report.js";
10
+ import { adoptText, builtText, refusalText, stageLine, summaryText, targetText, uploadText, writeText } from "./report.js";
12
11
  import { join, resolve } from "node:path";
13
12
  import { mkdtemp, stat } from "node:fs/promises";
14
13
  import { tmpdir } from "node:os";
@@ -21,11 +20,10 @@ const EXIT_USAGE = 2;
21
20
  const POLL_INTERVAL_MS = 2e3;
22
21
  const POLL_FAILURES_TOLERATED = 30;
23
22
  const DEFAULT_DEPS = {
24
- build: async (options) => (await import("../build/artifact.js")).buildArtifact(options),
23
+ artifact: async (options) => (await import("./artifact.js")).assembleArtifact(options),
25
24
  client: publicationClient,
26
25
  sourceFacts: readSourceFacts,
27
26
  sleep: (ms) => new Promise((done) => setTimeout(done, ms)),
28
- now: () => /* @__PURE__ */ new Date(),
29
27
  pollIntervalMs: POLL_INTERVAL_MS
30
28
  };
31
29
  var Ending = class extends Error {
@@ -54,19 +52,13 @@ function unwrap(answer, target, doing) {
54
52
  if (answer.kind === "ok") return answer.value;
55
53
  throw endingFor(answer, target, doing);
56
54
  }
57
- async function ensureArtifact(run, root, out, rebuild) {
55
+ async function produceArtifact(run, root, out) {
58
56
  const { io, deps } = run;
59
- const freshness = await assessFreshness({
60
- root,
61
- out,
62
- rebuild
63
- });
64
- io.stderr.write(stageLine("build", freshnessText(freshness, deps.now())));
65
- if (freshness.kind === "reuse") return freshness.manifest;
66
57
  let outcome;
67
58
  try {
68
- outcome = await deps.build({
59
+ outcome = await deps.artifact({
69
60
  root,
61
+ buildDir: resolve(root, DEFAULT_BUILD_DIR),
70
62
  out
71
63
  });
72
64
  } catch (cause) {
@@ -116,13 +108,13 @@ async function follow(run, client, target, first) {
116
108
  record = answer.value;
117
109
  }
118
110
  }
119
- async function publishWorkspace(run, root, target, rebuild) {
111
+ async function publishWorkspace(run, root, target) {
120
112
  const { io, deps } = run;
121
113
  io.stderr.write(stageLine("target", targetText(target)));
122
- const out = resolve(root, DEFAULT_BUILD_DIR);
123
- const manifest = await ensureArtifact(run, root, out, rebuild);
124
114
  const scratch = await mkdtemp(join(tmpdir(), "concrete-publish-"));
125
115
  try {
116
+ const out = join(scratch, "artifact");
117
+ const manifest = await produceArtifact(run, root, out);
126
118
  const tarball = join(scratch, "artifact.tar.gz");
127
119
  await packArtifact(out, tarball);
128
120
  const size = (await stat(tarball)).size;
@@ -185,7 +177,7 @@ async function publish(argv, io, deps) {
185
177
  deps,
186
178
  json: booleanFlag(values, "json"),
187
179
  dryRun: booleanFlag(values, "dry-run")
188
- }, root, target, booleanFlag(values, "rebuild"));
180
+ }, root, target);
189
181
  } catch (cause) {
190
182
  if (cause instanceof Ending) {
191
183
  io.stderr.write(cause.sentence);
@@ -1,13 +1,13 @@
1
1
  import { packageRoot, workspacePath } from "../../platform/paths.js";
2
+ import { byCodeUnit } from "../../platform/order.js";
2
3
  import { PLAYGROUND_FILES, playgroundPath } from "../../packages/internal/template-artifact/dist/layout.js";
3
4
  import "../../packages/internal/template-artifact/dist/index.js";
4
- import { byCodeUnit } from "../../platform/order.js";
5
- import { playgroundDistDir } from "../../playground/layout.js";
5
+ import { playgroundDistDir } from "../../packages/internal/playground/dist/layout.js";
6
6
  import { existsSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
  import { readFile, readdir } from "node:fs/promises";
9
9
 
10
- //#region src/cli/build/playground.ts
10
+ //#region src/cli/publish/playground.ts
11
11
  async function listFiles(dir) {
12
12
  return (await readdir(dir, {
13
13
  withFileTypes: true,
@@ -11,66 +11,48 @@ function formatBytes(bytes) {
11
11
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
12
12
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
13
13
  }
14
- function formatAge(then, now) {
15
- const seconds = Math.max(0, Math.round((now.getTime() - then.getTime()) / 1e3));
16
- if (seconds < 60) return "just now";
17
- if (seconds < 3600) return `${String(Math.floor(seconds / 60))}m ago`;
18
- if (seconds < 86400) return `${String(Math.floor(seconds / 3600))}h ago`;
19
- const days = Math.floor(seconds / 86400);
20
- return `${String(days)} ${days === 1 ? "day" : "days"} ago`;
21
- }
22
14
  const plural = (count, one, many) => `${String(count)} ${count === 1 ? one : many}`;
23
15
  function targetText(target) {
24
16
  return `${target.environmentName} · key ${maskToken(target.token)} · ${target.endpoint}${target.overridden ? " (CONCRETE_API_URL)" : ""}`;
25
17
  }
26
- function freshnessText(freshness, now) {
27
- if (freshness.kind === "reuse") return `tree matches artifact ${shortHash(freshness.manifest.template.content_hash)} (built ${formatAge(freshness.builtAt, now)}), reusing`;
28
- const previous = freshness.previous === null ? "" : ` ${shortHash(freshness.previous.template.content_hash)}`;
29
- switch (freshness.reason) {
30
- case "forced": return "--rebuild, building";
31
- case "missing": return "no artifact yet, building";
32
- case "unreadable": return "the artifact on disk cannot be read, rebuilding";
33
- case "framework": return `artifact${previous} was built by @homepages/concrete ${freshness.previous?.framework_version ?? "?"}, rebuilding`;
34
- case "changed": return `tree changed since artifact${previous}, rebuilding`;
35
- }
36
- }
37
18
  function builtText(manifest) {
38
- return `built ${shortHash(manifest.template.content_hash)} · ${plural(manifest.sections.length, "section", "sections")}`;
19
+ return `built ${shortHash(manifest.template.content_hash)} · ${plural(manifest.sections.length, "section", "sections")} · check passed`;
39
20
  }
40
21
  function uploadText(manifest, bytes, publisher) {
41
22
  return `${manifest.key} ${shortHash(manifest.template.content_hash)} · ${formatBytes(bytes)} · publisher "${publisher}"`;
42
23
  }
43
- function versionsOf(record) {
44
- const entries = record.section_versions ?? {};
24
+ function buildsOf(record) {
25
+ const entries = record.builds ?? {};
45
26
  return {
46
27
  template: entries[record.template_key],
47
28
  sections: Object.entries(entries).filter(([key]) => key !== record.template_key).map(([, entry]) => entry)
48
29
  };
49
30
  }
50
31
  function isAlreadyCurrent(record) {
51
- const { template, sections } = versionsOf(record);
52
- return template !== void 0 && template.status === "unchanged" && !template.latest_moved && sections.every((entry) => entry.status === "unchanged" && !entry.latest_moved);
32
+ const { template, sections } = buildsOf(record);
33
+ return template !== void 0 && template.status === "unchanged" && sections.every((entry) => entry.status === "unchanged");
53
34
  }
54
35
  function sectionCounts(sections) {
55
- const created = sections.filter((entry) => entry.status === "new").length;
56
- return `sections: ${String(created)} new, ${String(sections.length - created)} unchanged`;
36
+ const count = (status) => String(sections.filter((entry) => entry.status === status).length);
37
+ return `sections: ${count("new")} new, ${count("changed")} changed, ${count("unchanged")} unchanged`;
57
38
  }
58
39
  function writeText(record) {
59
40
  const hash = shortHash(record.artifact_hash);
60
- const { template, sections } = versionsOf(record);
41
+ const { template, sections } = buildsOf(record);
61
42
  if (record.state === "dry_run") {
62
- if (template?.status === "new") return `would write template version ${hash} as new · ${sectionCounts(sections)}`;
63
- return `would write nothing new · template version ${hash} already exists`;
43
+ if (template?.status === "new") return `would write template ${hash} as new · ${sectionCounts(sections)}`;
44
+ if (template?.status === "changed") return `would replace the template's build with ${hash} · ${sectionCounts(sections)}`;
45
+ return `would write nothing new · template build ${hash} is already current`;
64
46
  }
65
- if (isAlreadyCurrent(record)) return `already current · template version ${hash}`;
66
- return `${template?.status === "new" ? `template version ${hash} is new` : template?.latest_moved === true ? `template version ${hash} is current again` : `template version ${hash} unchanged`} · ${sectionCounts(sections)}`;
47
+ if (isAlreadyCurrent(record)) return `already current · template build ${hash}`;
48
+ return `${template?.status === "new" ? `template ${hash} is new` : `template build ${hash} replaces the previous one`} · ${sectionCounts(sections)}`;
67
49
  }
68
50
  function adoptText(record) {
69
51
  const summary = record.adopt_summary;
70
52
  if (summary === null) return "nothing reported";
71
53
  const checked = plural(summary.scanned, "deliverable checked", "deliverables checked");
72
54
  if (summary.enqueued === 0) return `no deliverable to move · ${checked}`;
73
- return `${plural(summary.enqueued, "deliverable", "deliverables")} adopting this version · ${checked}`;
55
+ return `${plural(summary.enqueued, "deliverable", "deliverables")} adopting this build · ${checked}`;
74
56
  }
75
57
  function summaryText(record) {
76
58
  if (record.state === "dry_run") return `Dry run passed: ${record.template_key} verified, and nothing was written.`;
@@ -89,4 +71,4 @@ function refusalText(record) {
89
71
  }
90
72
 
91
73
  //#endregion
92
- export { adoptText, builtText, formatAge, formatBytes, freshnessText, isAlreadyCurrent, refusalText, shortHash, stageLine, summaryText, targetText, uploadText, writeText };
74
+ export { adoptText, builtText, formatBytes, isAlreadyCurrent, refusalText, shortHash, stageLine, summaryText, targetText, uploadText, writeText };
@@ -0,0 +1,14 @@
1
+ //#region src/cli/upgrade/codemod.d.ts
2
+ interface NotRewritten {
3
+ /** Relative to the workspace root, with `/` separators. */
4
+ readonly file: string;
5
+ readonly reason: string;
6
+ }
7
+ interface CodemodReport {
8
+ /** Files the codemod changed, relative to the workspace root. */
9
+ readonly rewritten: readonly string[];
10
+ /** Files it would have changed and could not, each with why. */
11
+ readonly notRewritten: readonly NotRewritten[];
12
+ }
13
+ //#endregion
14
+ export { CodemodReport, NotRewritten };
@@ -0,0 +1,11 @@
1
+ import { FixtureConversion } from "../../packages/internal/playground/dist/fixture-formats.js";
2
+ import { CodemodReport } from "./codemod.js";
3
+ //#region src/cli/upgrade/fixture-conversion.d.ts
4
+ /**
5
+ * Runs the registered conversion `slug` over the fixtures of the workspace at `root`,
6
+ * writing and removing what it answers. Throws when no conversion has that slug, or when
7
+ * the conversion throws or breaks its contract; nothing is written then.
8
+ */
9
+ declare function convertWorkspaceFixtures(root: string, slug: string, conversions?: readonly FixtureConversion[]): Promise<CodemodReport>;
10
+ //#endregion
11
+ export { convertWorkspaceFixtures };
@@ -0,0 +1,54 @@
1
+ import { removeTree } from "../../platform/fs.js";
2
+ import { FIXTURES_DIR } from "../../packages/internal/template-artifact/dist/layout.js";
3
+ import { FIXTURE_CONVERSIONS, runFixtureConversion } from "../../packages/internal/playground/dist/fixture-formats.js";
4
+ import { dirname, join } from "node:path";
5
+ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
6
+
7
+ //#region src/cli/upgrade/fixture-conversion.ts
8
+ async function fixturePaths(root) {
9
+ const paths = [];
10
+ const walk = async (dir) => {
11
+ let entries;
12
+ try {
13
+ entries = await readdir(join(root, dir), { withFileTypes: true });
14
+ } catch (cause) {
15
+ if (cause.code === "ENOENT") return;
16
+ throw cause;
17
+ }
18
+ for (const entry of entries) {
19
+ const path = `${dir}/${entry.name}`;
20
+ if (entry.isDirectory()) await walk(path);
21
+ else if (entry.isFile()) paths.push(path);
22
+ }
23
+ };
24
+ await walk(FIXTURES_DIR);
25
+ return paths.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
26
+ }
27
+ async function convertWorkspaceFixtures(root, slug, conversions = FIXTURE_CONVERSIONS) {
28
+ const conversion = conversions.find((c) => c.slug === slug);
29
+ if (conversion === void 0) throw new Error(`no fixture conversion is called "${slug}"`);
30
+ const paths = await fixturePaths(root);
31
+ const known = new Set(paths);
32
+ const { edits, notes } = await runFixtureConversion(conversion, {
33
+ paths,
34
+ read: async (path) => known.has(path) ? new Uint8Array(await readFile(join(root, path))) : null
35
+ });
36
+ for (const edit of edits) {
37
+ const file = join(root, edit.path);
38
+ if ("remove" in edit) await removeTree(file);
39
+ else {
40
+ await mkdir(dirname(file), { recursive: true });
41
+ await writeFile(file, edit.bytes);
42
+ }
43
+ }
44
+ return {
45
+ rewritten: edits.map((e) => e.path),
46
+ notRewritten: notes.map((n) => ({
47
+ file: n.path,
48
+ reason: `Manual: ${n.note}`
49
+ }))
50
+ };
51
+ }
52
+
53
+ //#endregion
54
+ export { convertWorkspaceFixtures };