@brunosouzas/stackledger 0.0.0-stage → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +260 -2
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +97 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/control.d.ts +2 -0
  7. package/dist/control.js +22 -0
  8. package/dist/control.js.map +1 -0
  9. package/dist/discover-command.d.ts +7 -0
  10. package/dist/discover-command.js +60 -0
  11. package/dist/discover-command.js.map +1 -0
  12. package/dist/discovery/annotations.d.ts +24 -0
  13. package/dist/discovery/annotations.js +37 -0
  14. package/dist/discovery/annotations.js.map +1 -0
  15. package/dist/discovery/host.d.ts +47 -0
  16. package/dist/discovery/host.js +56 -0
  17. package/dist/discovery/host.js.map +1 -0
  18. package/dist/discovery/index.d.ts +15 -0
  19. package/dist/discovery/index.js +30 -0
  20. package/dist/discovery/index.js.map +1 -0
  21. package/dist/discovery/machine.d.ts +14 -0
  22. package/dist/discovery/machine.js +17 -0
  23. package/dist/discovery/machine.js.map +1 -0
  24. package/dist/discovery/run.d.ts +39 -0
  25. package/dist/discovery/run.js +130 -0
  26. package/dist/discovery/run.js.map +1 -0
  27. package/dist/discovery/snapshot.d.ts +60 -0
  28. package/dist/discovery/snapshot.js +161 -0
  29. package/dist/discovery/snapshot.js.map +1 -0
  30. package/dist/discovery/sources/apps.d.ts +3 -0
  31. package/dist/discovery/sources/apps.js +136 -0
  32. package/dist/discovery/sources/apps.js.map +1 -0
  33. package/dist/discovery/sources/brew.d.ts +15 -0
  34. package/dist/discovery/sources/brew.js +69 -0
  35. package/dist/discovery/sources/brew.js.map +1 -0
  36. package/dist/discovery/sources/common.d.ts +39 -0
  37. package/dist/discovery/sources/common.js +70 -0
  38. package/dist/discovery/sources/common.js.map +1 -0
  39. package/dist/discovery/sources/index.d.ts +8 -0
  40. package/dist/discovery/sources/index.js +12 -0
  41. package/dist/discovery/sources/index.js.map +1 -0
  42. package/dist/discovery/sources/launchd.d.ts +3 -0
  43. package/dist/discovery/sources/launchd.js +65 -0
  44. package/dist/discovery/sources/launchd.js.map +1 -0
  45. package/dist/discovery/sources/mas.d.ts +9 -0
  46. package/dist/discovery/sources/mas.js +25 -0
  47. package/dist/discovery/sources/mas.js.map +1 -0
  48. package/dist/discovery/sources/mise.d.ts +5 -0
  49. package/dist/discovery/sources/mise.js +64 -0
  50. package/dist/discovery/sources/mise.js.map +1 -0
  51. package/dist/discovery/sources/npm.d.ts +12 -0
  52. package/dist/discovery/sources/npm.js +34 -0
  53. package/dist/discovery/sources/npm.js.map +1 -0
  54. package/dist/discovery/sources/pipx.d.ts +4 -0
  55. package/dist/discovery/sources/pipx.js +82 -0
  56. package/dist/discovery/sources/pipx.js.map +1 -0
  57. package/dist/discovery/types.d.ts +73 -0
  58. package/dist/discovery/types.js +10 -0
  59. package/dist/discovery/types.js.map +1 -0
  60. package/dist/discovery/write.d.ts +50 -0
  61. package/dist/discovery/write.js +196 -0
  62. package/dist/discovery/write.js.map +1 -0
  63. package/dist/drift-command.d.ts +62 -0
  64. package/dist/drift-command.js +375 -0
  65. package/dist/drift-command.js.map +1 -0
  66. package/dist/drift-formats.d.ts +3 -0
  67. package/dist/drift-formats.js +54 -0
  68. package/dist/drift-formats.js.map +1 -0
  69. package/dist/drift.d.ts +95 -0
  70. package/dist/drift.js +206 -0
  71. package/dist/drift.js.map +1 -0
  72. package/dist/errors.d.ts +15 -0
  73. package/dist/errors.js +26 -0
  74. package/dist/errors.js.map +1 -0
  75. package/dist/graph.d.ts +103 -0
  76. package/dist/graph.js +181 -0
  77. package/dist/graph.js.map +1 -0
  78. package/dist/ics.d.ts +18 -0
  79. package/dist/ics.js +103 -0
  80. package/dist/ics.js.map +1 -0
  81. package/dist/identity.d.ts +18 -0
  82. package/dist/identity.js +36 -0
  83. package/dist/identity.js.map +1 -0
  84. package/dist/index.d.ts +14 -0
  85. package/dist/index.js +9 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/map/badges.d.ts +20 -0
  88. package/dist/map/badges.js +95 -0
  89. package/dist/map/badges.js.map +1 -0
  90. package/dist/map/command.d.ts +8 -0
  91. package/dist/map/command.js +86 -0
  92. package/dist/map/command.js.map +1 -0
  93. package/dist/map/heap.d.ts +15 -0
  94. package/dist/map/heap.js +57 -0
  95. package/dist/map/heap.js.map +1 -0
  96. package/dist/map/ink.d.ts +11 -0
  97. package/dist/map/ink.js +10 -0
  98. package/dist/map/ink.js.map +1 -0
  99. package/dist/map/labels.d.ts +43 -0
  100. package/dist/map/labels.js +172 -0
  101. package/dist/map/labels.js.map +1 -0
  102. package/dist/map/layout.d.ts +59 -0
  103. package/dist/map/layout.js +197 -0
  104. package/dist/map/layout.js.map +1 -0
  105. package/dist/map/model.d.ts +46 -0
  106. package/dist/map/model.js +84 -0
  107. package/dist/map/model.js.map +1 -0
  108. package/dist/map/neighbourhood.d.ts +18 -0
  109. package/dist/map/neighbourhood.js +138 -0
  110. package/dist/map/neighbourhood.js.map +1 -0
  111. package/dist/map/parallel.d.ts +21 -0
  112. package/dist/map/parallel.js +174 -0
  113. package/dist/map/parallel.js.map +1 -0
  114. package/dist/map/relations.d.ts +39 -0
  115. package/dist/map/relations.js +127 -0
  116. package/dist/map/relations.js.map +1 -0
  117. package/dist/map/route.d.ts +25 -0
  118. package/dist/map/route.js +165 -0
  119. package/dist/map/route.js.map +1 -0
  120. package/dist/map/strip.d.ts +29 -0
  121. package/dist/map/strip.js +122 -0
  122. package/dist/map/strip.js.map +1 -0
  123. package/dist/map/suggest.d.ts +21 -0
  124. package/dist/map/suggest.js +97 -0
  125. package/dist/map/suggest.js.map +1 -0
  126. package/dist/map/svg.d.ts +22 -0
  127. package/dist/map/svg.js +232 -0
  128. package/dist/map/svg.js.map +1 -0
  129. package/dist/map/themes.d.ts +61 -0
  130. package/dist/map/themes.js +78 -0
  131. package/dist/map/themes.js.map +1 -0
  132. package/dist/map/xml.d.ts +8 -0
  133. package/dist/map/xml.js +68 -0
  134. package/dist/map/xml.js.map +1 -0
  135. package/dist/map/zones.d.ts +19 -0
  136. package/dist/map/zones.js +46 -0
  137. package/dist/map/zones.js.map +1 -0
  138. package/dist/mcp.d.ts +2 -0
  139. package/dist/mcp.js +145 -0
  140. package/dist/mcp.js.map +1 -0
  141. package/dist/money.d.ts +32 -0
  142. package/dist/money.js +91 -0
  143. package/dist/money.js.map +1 -0
  144. package/dist/report-command.d.ts +3 -0
  145. package/dist/report-command.js +85 -0
  146. package/dist/report-command.js.map +1 -0
  147. package/dist/report-formats.d.ts +11 -0
  148. package/dist/report-formats.js +157 -0
  149. package/dist/report-formats.js.map +1 -0
  150. package/dist/reports.d.ts +105 -0
  151. package/dist/reports.js +247 -0
  152. package/dist/reports.js.map +1 -0
  153. package/dist/scaffold.d.ts +30 -0
  154. package/dist/scaffold.js +140 -0
  155. package/dist/scaffold.js.map +1 -0
  156. package/dist/schema.d.ts +330 -0
  157. package/dist/schema.js +116 -0
  158. package/dist/schema.js.map +1 -0
  159. package/dist/secrets.d.ts +7 -0
  160. package/dist/secrets.js +68 -0
  161. package/dist/secrets.js.map +1 -0
  162. package/dist/site/build.d.ts +22 -0
  163. package/dist/site/build.js +196 -0
  164. package/dist/site/build.js.map +1 -0
  165. package/dist/site/command.d.ts +2 -0
  166. package/dist/site/command.js +221 -0
  167. package/dist/site/command.js.map +1 -0
  168. package/dist/site/data.d.ts +205 -0
  169. package/dist/site/data.js +241 -0
  170. package/dist/site/data.js.map +1 -0
  171. package/dist/site/fs-ops.d.ts +35 -0
  172. package/dist/site/fs-ops.js +26 -0
  173. package/dist/site/fs-ops.js.map +1 -0
  174. package/dist/site/owners.d.ts +5 -0
  175. package/dist/site/owners.js +50 -0
  176. package/dist/site/owners.js.map +1 -0
  177. package/dist/site/paths.d.ts +34 -0
  178. package/dist/site/paths.js +48 -0
  179. package/dist/site/paths.js.map +1 -0
  180. package/dist/site/policy.d.ts +17 -0
  181. package/dist/site/policy.js +26 -0
  182. package/dist/site/policy.js.map +1 -0
  183. package/dist/site/publish.d.ts +14 -0
  184. package/dist/site/publish.js +90 -0
  185. package/dist/site/publish.js.map +1 -0
  186. package/dist/site/relative.d.ts +14 -0
  187. package/dist/site/relative.js +265 -0
  188. package/dist/site/relative.js.map +1 -0
  189. package/dist/site/skills-build.d.ts +22 -0
  190. package/dist/site/skills-build.js +126 -0
  191. package/dist/site/skills-build.js.map +1 -0
  192. package/dist/site/skills-data.d.ts +89 -0
  193. package/dist/site/skills-data.js +94 -0
  194. package/dist/site/skills-data.js.map +1 -0
  195. package/dist/site/staging.d.ts +19 -0
  196. package/dist/site/staging.js +76 -0
  197. package/dist/site/staging.js.map +1 -0
  198. package/dist/skills/command.d.ts +8 -0
  199. package/dist/skills/command.js +64 -0
  200. package/dist/skills/command.js.map +1 -0
  201. package/dist/skills/frontmatter.d.ts +37 -0
  202. package/dist/skills/frontmatter.js +219 -0
  203. package/dist/skills/frontmatter.js.map +1 -0
  204. package/dist/skills/graph.d.ts +39 -0
  205. package/dist/skills/graph.js +100 -0
  206. package/dist/skills/graph.js.map +1 -0
  207. package/dist/skills/ignore.d.ts +34 -0
  208. package/dist/skills/ignore.js +138 -0
  209. package/dist/skills/ignore.js.map +1 -0
  210. package/dist/skills/lines.d.ts +53 -0
  211. package/dist/skills/lines.js +221 -0
  212. package/dist/skills/lines.js.map +1 -0
  213. package/dist/skills/map-command.d.ts +28 -0
  214. package/dist/skills/map-command.js +533 -0
  215. package/dist/skills/map-command.js.map +1 -0
  216. package/dist/skills/mermaid.d.ts +29 -0
  217. package/dist/skills/mermaid.js +261 -0
  218. package/dist/skills/mermaid.js.map +1 -0
  219. package/dist/skills/metro.d.ts +8 -0
  220. package/dist/skills/metro.js +93 -0
  221. package/dist/skills/metro.js.map +1 -0
  222. package/dist/skills/read.d.ts +17 -0
  223. package/dist/skills/read.js +54 -0
  224. package/dist/skills/read.js.map +1 -0
  225. package/dist/skills/rules.d.ts +28 -0
  226. package/dist/skills/rules.js +57 -0
  227. package/dist/skills/rules.js.map +1 -0
  228. package/dist/skills/source.d.ts +66 -0
  229. package/dist/skills/source.js +281 -0
  230. package/dist/skills/source.js.map +1 -0
  231. package/dist/skills/walk.d.ts +64 -0
  232. package/dist/skills/walk.js +281 -0
  233. package/dist/skills/walk.js.map +1 -0
  234. package/dist/source.d.ts +40 -0
  235. package/dist/source.js +199 -0
  236. package/dist/source.js.map +1 -0
  237. package/dist/stdout.d.ts +2 -0
  238. package/dist/stdout.js +24 -0
  239. package/dist/stdout.js.map +1 -0
  240. package/dist/validate.d.ts +45 -0
  241. package/dist/validate.js +321 -0
  242. package/dist/validate.js.map +1 -0
  243. package/dist/views.d.ts +25 -0
  244. package/dist/views.js +58 -0
  245. package/dist/views.js.map +1 -0
  246. package/examples/catalogue-repository/.github/workflows/stackledger.yml +122 -0
  247. package/examples/catalogue-repository/README.md +96 -0
  248. package/examples/catalogue-repository/catalog/catalog-info.yaml +12 -0
  249. package/examples/hosting/Caddyfile +69 -0
  250. package/examples/northwind/catalog-info.yaml +680 -0
  251. package/examples/northwind/stackledger.yaml +16 -0
  252. package/examples/northwind-machine/snapshot.json +309 -0
  253. package/examples/northwind-skills/agents/builder.md +10 -0
  254. package/examples/northwind-skills/agents/reviewer.md +10 -0
  255. package/examples/northwind-skills/designer/SKILL.md +8 -0
  256. package/examples/northwind-skills/editor/SKILL.md +8 -0
  257. package/examples/northwind-skills/engineering/SKILL.md +12 -0
  258. package/examples/northwind-skills/linter/SKILL.md +8 -0
  259. package/examples/northwind-skills/linter/rules.md +5 -0
  260. package/examples/northwind-skills/publishing/SKILL.md +12 -0
  261. package/examples/northwind-skills/publishing/rules.md +5 -0
  262. package/examples/northwind-skills/spec-writer/SKILL.md +8 -0
  263. package/examples/northwind-skills/stackledger-skills.yaml +51 -0
  264. package/examples/northwind-skills/tester/SKILL.md +10 -0
  265. package/examples/northwind-skills/writer/SKILL.md +8 -0
  266. package/examples/northwind-skills/writer/rules.md +6 -0
  267. package/npm-shrinkwrap.json +4995 -0
  268. package/package.json +51 -4
  269. package/site/LICENSE-astroplate +21 -0
  270. package/site/README.md +18 -0
  271. package/site/package.json +6 -0
  272. package/site/public/favicon.svg +1 -0
  273. package/site/src/components/Footer.astro +25 -0
  274. package/site/src/components/Header.astro +35 -0
  275. package/site/src/components/Impact.astro +55 -0
  276. package/site/src/components/LinkOrText.astro +12 -0
  277. package/site/src/components/SkillItem.astro +141 -0
  278. package/site/src/components/SubNav.astro +40 -0
  279. package/site/src/components/ThemeSwitch.astro +16 -0
  280. package/site/src/components/Themed.astro +14 -0
  281. package/site/src/layouts/Base.astro +52 -0
  282. package/site/src/lib/site.ts +25 -0
  283. package/site/src/pages/[reports].astro +222 -0
  284. package/site/src/pages/agents/[file].astro +14 -0
  285. package/site/src/pages/index.astro +71 -0
  286. package/site/src/pages/journeys/[name].astro +50 -0
  287. package/site/src/pages/journeys/index.astro +37 -0
  288. package/site/src/pages/licences/[name].astro +56 -0
  289. package/site/src/pages/map/index.astro +78 -0
  290. package/site/src/pages/playbooks/[file].astro +14 -0
  291. package/site/src/pages/rules/[...rules].astro +61 -0
  292. package/site/src/pages/skill-map/[...map].astro +101 -0
  293. package/site/src/pages/skills/[...list].astro +75 -0
  294. package/site/src/pages/skills/[file].astro +14 -0
  295. package/site/src/pages/software/[name].astro +155 -0
  296. package/site/src/pages/software/index.astro +71 -0
  297. package/site/src/scripts/diagram.ts +8 -0
  298. package/site/src/scripts/links.ts +31 -0
  299. package/site/src/scripts/map.ts +133 -0
  300. package/site/src/scripts/software.ts +32 -0
  301. package/site/src/scripts/theme.ts +52 -0
  302. package/site/src/styles/base.css +470 -0
  303. package/site/src/styles/fonts.css +60 -0
  304. package/site/src/styles/override.css +1 -0
  305. package/site/src/styles/pages.css +299 -0
  306. package/site/src/styles/tokens.css +71 -0
  307. package/skills/stackledger/SKILL.md +155 -0
@@ -0,0 +1,241 @@
1
+ /** SiteData: the one plain JSON object a site's Astro pages read, built from one view only.
2
+ *
3
+ * Why: pages never import the catalogue code (design D1). Every text, link, list and SVG a page
4
+ * shows is prepared here from applyView's output, so the staff site cannot reach a hidden value.
5
+ * Call buildSiteData(catalogue, 'staff', version) or buildSiteData(catalogue, 'full', version, date).
6
+ *
7
+ * The staff data never reads the date (the map model ignores it for staff), so staff output depends
8
+ * only on what the staff view serves. A full build without a real date throws. Links are paths from
9
+ * the site's root without a leading slash ('software/editor/'); the layout makes them relative.
10
+ * Owners show by name when `owners` (from src/site/owners.ts) names them, else as the raw reference.
11
+ * The map is drawn without its title band and legend: the page shows both in HTML (`symbols`).
12
+ *
13
+ * The full data also carries the licence report (src/reports.ts) for the Reports page, at the map's
14
+ * date with a 90-day window, and the full build returns the renewal calendar text (src/ics.ts) for
15
+ * renewals.ics. Only FullSiteData has a `report` field, so staff data holding one is a type error.
16
+ */
17
+ import { compareRefs } from '../identity.js';
18
+ import { buildGraph, impact, linesOf, summary } from '../graph.js';
19
+ import { buildMapModel } from '../map/model.js';
20
+ import { layoutMap } from '../map/layout.js';
21
+ import { neighbourhood, renderNeighbourhood } from '../map/neighbourhood.js';
22
+ import { renderLineBadge, renderStrip, strip } from '../map/strip.js';
23
+ import { renderSvg, renderSymbol } from '../map/svg.js';
24
+ import { displayOwner } from './owners.js';
25
+ import { inkOf, themes, widestInk } from '../map/themes.js';
26
+ import { applyView, resolveHidden, settingsInError } from '../views.js';
27
+ import { licenceFields } from '../schema.js';
28
+ import { calendarNamespace, renderCalendar } from '../ics.js';
29
+ import { formatAmount } from '../money.js';
30
+ import { buildReport } from '../reports.js';
31
+ export const DEFAULT_TITLE = 'stackledger';
32
+ /** The home banner's text when `spec.site.home.text` is not set (catalogue-site, Home page). */
33
+ export const DEFAULT_HOME_TEXT = 'Your software and skills, mapped.';
34
+ /** The renewal window of the site's Reports page and calendar (licence-reports, Source and date). */
35
+ export const REPORT_DAYS = 90;
36
+ export const CALENDAR_FILE = 'renewals.ics';
37
+ const fieldLabels = {
38
+ vendor: 'Vendor', status: 'Status', cycle: 'Cycle', cost: 'Cost', currency: 'Currency', renewsOn: 'Renews on',
39
+ seats: 'Seats', paidBy: 'Paid by', vaultItem: 'Vault item', note: 'Note',
40
+ };
41
+ /** Page path of an item, or undefined when it has no page (other resources, lines). */
42
+ function pagePath(item) {
43
+ if (item.kind === 'component')
44
+ return `software/${item.name.toLowerCase()}/`;
45
+ if (item.kind === 'licence')
46
+ return `licences/${item.name.toLowerCase()}/`;
47
+ return undefined;
48
+ }
49
+ function titleOf(item) {
50
+ return summary(item).title ?? item.name;
51
+ }
52
+ /** The licence fields the view kept, in catalogue order. */
53
+ function fields(licence) {
54
+ const details = (licence.spec.licence ?? {});
55
+ return licenceFields.filter(field => details[field] !== undefined).map(field => ({ label: fieldLabels[field], value: String(details[field]) }));
56
+ }
57
+ /** Title, colours and home from spec.site; the defaults, and no links, when the Settings in use has an error. */
58
+ function siteSettings(catalogue) {
59
+ const site = settingsInError(catalogue) ? undefined : catalogue.served.settings[0]?.spec.site;
60
+ const colors = {};
61
+ for (const [key, value] of Object.entries(site?.colors ?? {}))
62
+ if (value !== undefined)
63
+ colors[key] = value;
64
+ const links = (site?.home?.links ?? []).map(link => ({ title: link.title, url: link.url, ...(link.description === undefined ? {} : { description: link.description }) }));
65
+ return { title: site?.title ?? DEFAULT_TITLE, colors, home: { text: site?.home?.text ?? DEFAULT_HOME_TEXT, links } };
66
+ }
67
+ /** The site title, as the header shows it; also the calendar name of `stackledger report --format ics`. */
68
+ export function siteTitle(catalogue) {
69
+ return siteSettings(catalogue).title;
70
+ }
71
+ class PageBuilder {
72
+ graph;
73
+ model;
74
+ owners;
75
+ drawn;
76
+ constructor(graph, model, owners) {
77
+ this.graph = graph;
78
+ this.model = model;
79
+ this.owners = owners;
80
+ this.drawn = new Map(model.lines.map(line => [line.ref.toLowerCase(), line]));
81
+ }
82
+ link(ref) {
83
+ const item = this.graph.items.get(ref.toLowerCase());
84
+ const href = item.kind === 'line' ? this.lineHref(item.ref) : pagePath(item);
85
+ return { ref: item.ref, title: titleOf(item), ...(href === undefined ? {} : { href }) };
86
+ }
87
+ /** A line links to its journey page only when it is drawn. */
88
+ lineHref(ref) {
89
+ const line = this.drawn.get(ref.toLowerCase());
90
+ return line ? `journeys/${line.name.toLowerCase()}/` : undefined;
91
+ }
92
+ nodeLink(node) {
93
+ return this.link(node.ref);
94
+ }
95
+ impact(item) {
96
+ const result = impact(this.graph, item);
97
+ return {
98
+ dependants: result.dependants.map(entry => ({ ...this.link(entry.ref), depth: entry.depth })),
99
+ lines: result.lines.map(ref => this.link(ref)),
100
+ truncated: result.truncated,
101
+ };
102
+ }
103
+ component(item) {
104
+ const { metadata, spec } = item.entity;
105
+ const near = neighbourhood(this.graph, item);
106
+ const licences = (this.graph.dependsOn.get(item.key) ?? [])
107
+ .map(ref => this.graph.items.get(ref.toLowerCase()))
108
+ .filter((dependency) => dependency.kind === 'licence')
109
+ .sort((one, two) => compareRefs(one.ref, two.ref))
110
+ .map(licence => ({ ...this.link(licence.ref), fields: fields(licence.entity) }));
111
+ const zone = summary(item).zone;
112
+ return {
113
+ ref: item.ref, slug: item.name.toLowerCase(), name: item.name, title: titleOf(item),
114
+ ...(metadata.description === undefined ? {} : { description: metadata.description }),
115
+ type: spec.type, lifecycle: spec.lifecycle, owner: displayOwner(this.owners, spec.owner), ...(zone === undefined ? {} : { zone }),
116
+ tags: (metadata.tags ?? []).filter(tag => typeof tag === 'string'),
117
+ licences,
118
+ journeys: linesOf(this.graph, item).map(ref => this.link(ref)),
119
+ unresolved: [...this.graph.unresolved.get(item.key) ?? []],
120
+ impact: this.impact(item),
121
+ neighbourhood: {
122
+ ...themed(theme => renderNeighbourhood(near, theme)),
123
+ dependencies: near.dependencies.map(node => this.nodeLink(node)),
124
+ dependants: near.dependants.map(node => this.nodeLink(node)),
125
+ },
126
+ };
127
+ }
128
+ licence(item) {
129
+ const near = neighbourhood(this.graph, item);
130
+ return {
131
+ ref: item.ref, slug: item.name.toLowerCase(), name: item.name, title: titleOf(item), owner: displayOwner(this.owners, item.entity.spec.owner),
132
+ fields: fields(item.entity),
133
+ usedBy: near.dependants.map(node => this.nodeLink(node)),
134
+ impact: this.impact(item),
135
+ };
136
+ }
137
+ lineSummary(line) {
138
+ return {
139
+ ref: line.ref, slug: line.name.toLowerCase(), title: line.title, badge: line.badge, color: line.color,
140
+ badgeSvg: renderLineBadge(line), stops: line.stops.length, href: this.lineHref(line.ref),
141
+ };
142
+ }
143
+ journey(line) {
144
+ const input = strip(this.model, line);
145
+ return {
146
+ ...this.lineSummary(line),
147
+ strip: themed(theme => renderStrip(input, theme)),
148
+ stopList: input.stops.map(stop => ({ ...this.link(stop.ref), lines: stop.interchanges.map(other => this.link(other.ref)) })),
149
+ };
150
+ }
151
+ }
152
+ const NO_AMOUNT = '—';
153
+ const shown = (amount) => (amount === null ? NO_AMOUNT : formatAmount(amount));
154
+ const currencyLabel = (currency) => currency ?? 'Unknown currency';
155
+ const moneyRows = (rows) => rows.map(row => ({ currency: currencyLabel(row.currency), monthly: shown(row.monthly), yearly: shown(row.yearly), incomplete: row.incomplete }));
156
+ const oneOffRows = (rows) => rows.map(row => ({ currency: currencyLabel(row.currency), total: shown(row.total), incomplete: row.incomplete }));
157
+ const priced = (cost, currency) => (cost === null ? 'unknown' : `${formatAmount(cost)} ${currency ?? 'unknown currency'}`);
158
+ /** The Reports page's data: the report's lists with page links and shown amounts. */
159
+ function reportPage(report, pages) {
160
+ const link = (entry) => pages.link(entry.ref);
161
+ const renewal = (entry) => ({ ...link(entry), date: entry.renewsOn, vendor: entry.vendor, cycle: entry.cycle, cost: priced(entry.cost, entry.currency) });
162
+ const grouping = (key, title, column, groups) => ({ key, title, column, groups: groups.map(group => ({ label: group.label, synthetic: group.synthetic, rows: moneyRows(group.totals) })) });
163
+ return {
164
+ date: report.date, to: report.to, days: report.days, empty: report.licences === 0, calendar: CALENDAR_FILE,
165
+ renewals: report.renewals.map(renewal), overdue: report.overdue.map(renewal), unknownDates: report.unknownDates.map(link),
166
+ recurring: moneyRows(report.recurring),
167
+ groupings: [
168
+ grouping('owner', 'By owner', 'Owner', report.groups.owner),
169
+ grouping('payer', 'By payer', 'Paid by', report.groups.payer),
170
+ grouping('zone', 'By zone', 'Zone', report.groups.zone),
171
+ ],
172
+ oneOff: {
173
+ items: report.oneOff.items.map(item => ({ ...link(item), cost: priced(item.cost, item.currency), renewsOn: item.renewsOn ?? NO_AMOUNT })),
174
+ totals: oneOffRows(report.oneOff.totals),
175
+ },
176
+ planned: {
177
+ items: report.planned.items.map(item => ({ ...link(item), cycle: item.cycle, cost: priced(item.cost, item.currency), monthly: shown(item.monthly), yearly: shown(item.yearly) })),
178
+ recurring: moneyRows(report.planned.recurring),
179
+ oneOff: oneOffRows(report.planned.oneOff),
180
+ },
181
+ incomplete: report.incomplete.map(item => ({ ...link(item), status: item.status, unknown: item.unknown.join(', ') })),
182
+ };
183
+ }
184
+ function themed(render) {
185
+ return { light: render(themes.light), dark: render(themes.dark) };
186
+ }
187
+ function row(item, owners) {
188
+ const info = summary(item);
189
+ const state = item.kind === 'component' ? item.entity.spec.lifecycle : item.entity.spec.licence?.status ?? '';
190
+ return {
191
+ ref: item.ref, href: pagePath(item), title: info.title ?? item.name, kind: item.kind,
192
+ type: info.type ?? '', state, owner: info.owner === undefined ? '' : displayOwner(owners, info.owner), zone: info.zone ?? '',
193
+ };
194
+ }
195
+ /** Distinct non-empty values of one column, sorted by code point, for a filter's options. */
196
+ function options(rows, column) {
197
+ return [...new Set(rows.map(entry => entry[column]).filter(value => value !== ''))].sort((one, two) => (one < two ? -1 : one > two ? 1 : 0));
198
+ }
199
+ /** SiteData of one view, plus the full map geometry for the build report (suggestions, unrouted
200
+ * hops) and, for the full view only, the text of renewals.ics. */
201
+ export function buildSiteData(catalogue, view, version, date, owners = new Map()) {
202
+ if (view === 'full' && date === undefined)
203
+ throw new Error('A full site needs the map date');
204
+ const served = applyView(catalogue.served, view, resolveHidden(catalogue));
205
+ const graph = buildGraph(served);
206
+ // The staff model never evaluates the date; pass none so nothing date-like can reach staff data.
207
+ const model = buildMapModel(served, view === 'full' ? date : '');
208
+ // One ink for both copies, so labels sit in the same places and zoom moves both maps alike.
209
+ const ink = widestInk(inkOf(themes.light), inkOf(themes.dark));
210
+ const geometry = layoutMap(model, themes.light.lineWidth, ink);
211
+ const darkGeometry = themes.dark.lineWidth === themes.light.lineWidth ? geometry : layoutMap(model, themes.dark.lineWidth, ink);
212
+ const pages = new PageBuilder(graph, model, owners);
213
+ const items = [...graph.items.values()].sort((one, two) => compareRefs(one.ref, two.ref));
214
+ const components = items.filter((item) => item.kind === 'component');
215
+ const licences = items.filter((item) => item.kind === 'licence');
216
+ const rows = [...components, ...licences].sort((one, two) => compareRefs(one.ref, two.ref)).map(item => row(item, owners));
217
+ const settings = siteSettings(catalogue);
218
+ const base = {
219
+ version,
220
+ ...settings,
221
+ map: {
222
+ light: renderSvg(geometry, themes.light, { chrome: false }),
223
+ dark: renderSvg(darkGeometry, themes.dark, { chrome: false }),
224
+ lines: model.lines.map(line => pages.lineSummary(line)),
225
+ zones: geometry.zones.map(zone => ({ name: zone.name.toLowerCase(), title: zone.title })),
226
+ symbols: geometry.legend.symbols.map(symbol => ({ label: symbol[0].toUpperCase() + symbol.slice(1), ...themed(theme => renderSymbol(symbol, theme)) })),
227
+ },
228
+ rows,
229
+ filters: { kind: options(rows, 'kind'), zone: options(rows, 'zone'), state: options(rows, 'state'), owner: options(rows, 'owner') },
230
+ components: components.map(item => pages.component(item)),
231
+ licences: licences.map(item => pages.licence(item)),
232
+ journeys: model.lines.map(line => pages.journey(line)),
233
+ };
234
+ if (view === 'staff')
235
+ return { data: { view, ...base }, geometry };
236
+ // The report exists only here, after the staff branch: nothing of it is computed for staff.
237
+ const report = buildReport(graph, date, REPORT_DAYS, { ownerLabel: owner => displayOwner(owners, owner) });
238
+ const calendar = renderCalendar(report, { title: settings.title, namespace: calendarNamespace(catalogue) });
239
+ return { data: { view, ...base, report: reportPage(report, pages) }, geometry, calendar };
240
+ }
241
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/site/data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAyB,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAoB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAoB,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAc,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAiB,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAuD,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,WAAW,EAA+F,MAAM,eAAe,CAAC;AAEzI,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAC3C,gGAAgG;AAChG,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AACrE,qGAAqG;AACrG,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,aAAa,GAA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KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,35 @@
1
+ /** The filesystem calls the build command makes on its output folder (design D8).
2
+ *
3
+ * Why an interface: command.ts and publish.ts reach the output folder only through an FsOps object,
4
+ * so a test can pass a wrapper that fails or swaps the folder at a chosen call and prove the undo,
5
+ * the refusals and the identity checks. The shipped code always uses NODE_FS and has no test-only
6
+ * branch; src/cli.ts passes nothing, so a user cannot change how the build touches the disk.
7
+ *
8
+ * Every call is synchronous and throws the error node:fs throws. Writing the sites into the staging
9
+ * folder (build.ts, Astro) does not go through here: it happens before anything published changes.
10
+ */
11
+ import { type Stats } from 'node:fs';
12
+ export interface FsOps {
13
+ /** The entry's own status; a symbolic link is not followed. */
14
+ lstat(path: string): Stats;
15
+ /** The status of what the path points to (links followed). */
16
+ stat(path: string): Stats;
17
+ /** The path with every symbolic link resolved. */
18
+ realpath(path: string): string;
19
+ /** The names in a folder. */
20
+ readdir(path: string): string[];
21
+ /** A text file read as UTF-8. */
22
+ readFile(path: string): string;
23
+ /** Create a folder; with `recursive`, its missing parents too and no error when it exists. */
24
+ mkdir(path: string, options?: {
25
+ recursive: boolean;
26
+ }): void;
27
+ /** Rename an entry within one filesystem (atomic). */
28
+ rename(from: string, to: string): void;
29
+ /** Remove an empty folder. */
30
+ rmdir(path: string): void;
31
+ /** Remove an entry and, for a folder, everything in it; links inside are removed, not followed. */
32
+ rm(path: string): void;
33
+ }
34
+ /** The real filesystem: what the CLI uses. */
35
+ export declare const NODE_FS: FsOps;
@@ -0,0 +1,26 @@
1
+ /** The filesystem calls the build command makes on its output folder (design D8).
2
+ *
3
+ * Why an interface: command.ts and publish.ts reach the output folder only through an FsOps object,
4
+ * so a test can pass a wrapper that fails or swaps the folder at a chosen call and prove the undo,
5
+ * the refusals and the identity checks. The shipped code always uses NODE_FS and has no test-only
6
+ * branch; src/cli.ts passes nothing, so a user cannot change how the build touches the disk.
7
+ *
8
+ * Every call is synchronous and throws the error node:fs throws. Writing the sites into the staging
9
+ * folder (build.ts, Astro) does not go through here: it happens before anything published changes.
10
+ */
11
+ import { lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmdirSync, rmSync, statSync } from 'node:fs';
12
+ /** The real filesystem: what the CLI uses. */
13
+ export const NODE_FS = {
14
+ lstat: path => lstatSync(path),
15
+ stat: path => statSync(path),
16
+ realpath: path => realpathSync.native(path),
17
+ readdir: path => readdirSync(path),
18
+ readFile: path => readFileSync(path, 'utf8'),
19
+ mkdir: (path, options) => {
20
+ mkdirSync(path, options);
21
+ },
22
+ rename: (from, to) => renameSync(from, to),
23
+ rmdir: path => rmdirSync(path),
24
+ rm: path => rmSync(path, { recursive: true, force: true }),
25
+ };
26
+ //# sourceMappingURL=fs-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-ops.js","sourceRoot":"","sources":["../../src/site/fs-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAc,MAAM,SAAS,CAAC;AAuB7I,8CAA8C;AAC9C,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;IAC3C,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC;IAC5C,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QACvB,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;IAC1C,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;IAC9B,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;CAC3D,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Source } from '../source.js';
2
+ /** Owner reference (lower case `group:name` or `user:name`) -> display name. */
3
+ export declare function ownerNames(sources: readonly Source[]): Map<string, string>;
4
+ /** The display name of an owner reference, or the reference itself when no document names it. */
5
+ export declare function displayOwner(names: ReadonlyMap<string, string>, owner: string): string;
@@ -0,0 +1,50 @@
1
+ /** Display names of owners for the site: `group:northwind` shows as the title of the Group document
2
+ * `northwind` when the catalogue has one (catalogue-site polish; pages show owners by name).
3
+ *
4
+ * Why here and not in the views: Group and User are ignored kinds (docs/catalogue-format.md), so
5
+ * validation never reads them and no view serves them. The site only borrows their display name,
6
+ * and only from a document that passes the same identity and secret checks as a served one:
7
+ * apiVersion backstage.io/v1alpha1, a valid metadata.name, and no secret-scan error. The name is
8
+ * `metadata.title`, else `spec.profile.displayName`, else `metadata.name`. When two documents
9
+ * name the same owner differently, neither is used, so the result never depends on file order.
10
+ * Owner fields are not hidden in any view, so both sites show the same names.
11
+ *
12
+ * Call ownerNames(loaded.sources), then displayOwner(names, 'group:northwind').
13
+ */
14
+ import { name as nameSchema } from '../schema.js';
15
+ import { scanSecrets } from '../secrets.js';
16
+ const OWNER_KINDS = new Set(['Group', 'User']);
17
+ const API_VERSION = 'backstage.io/v1alpha1';
18
+ const record = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
19
+ function text(value) {
20
+ return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
21
+ }
22
+ /** Owner reference (lower case `group:name` or `user:name`) -> display name. */
23
+ export function ownerNames(sources) {
24
+ const names = new Map();
25
+ const conflicting = new Set();
26
+ for (const source of sources) {
27
+ const { apiVersion, kind, metadata, spec } = source.value;
28
+ if (typeof kind !== 'string' || !OWNER_KINDS.has(kind) || apiVersion !== API_VERSION)
29
+ continue;
30
+ const parsed = nameSchema.safeParse(record(metadata).name);
31
+ if (!parsed.success)
32
+ continue;
33
+ if (scanSecrets(source).some(problem => problem.severity === 'error'))
34
+ continue;
35
+ const display = text(record(metadata).title) ?? text(record(record(spec).profile).displayName) ?? parsed.data;
36
+ const ref = `${kind}:${parsed.data}`.toLowerCase();
37
+ const earlier = names.get(ref);
38
+ if (earlier !== undefined && earlier !== display)
39
+ conflicting.add(ref);
40
+ names.set(ref, display);
41
+ }
42
+ for (const ref of conflicting)
43
+ names.delete(ref);
44
+ return names;
45
+ }
46
+ /** The display name of an owner reference, or the reference itself when no document names it. */
47
+ export function displayOwner(names, owner) {
48
+ return names.get(owner.toLowerCase()) ?? owner;
49
+ }
50
+ //# sourceMappingURL=owners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owners.js","sourceRoot":"","sources":["../../src/site/owners.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAE5C,MAAM,MAAM,GAAG,CAAC,KAAc,EAA2B,EAAE,CACzD,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CA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D,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,OAAO;YAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,WAAW;QAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,YAAY,CAAC,KAAkC,EAAE,KAAa;IAC5E,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,KAAK,CAAC;AACjD,CAAC"}
@@ -0,0 +1,34 @@
1
+ /** Path checks shared by the build command (command.ts) and the publication (publish.ts).
2
+ *
3
+ * Why one module: both decide whether a path is inside the output folder, look at entries without
4
+ * following symbolic links, and re-check that the output folder is still the folder validated.
5
+ *
6
+ * Limit: Node.js has no directory handles (no openat, no O_NOFOLLOW on folders), so the build works
7
+ * on path strings. FolderIdentity narrows the gap: the output folder's real path and its device and
8
+ * inode numbers are recorded once validated and compared again immediately before each change.
9
+ * Another process that renames the output folder or a parent between a check and the next change is
10
+ * outside what this can catch; docs/site.md (Security) states that trust.
11
+ */
12
+ import type { Stats } from 'node:fs';
13
+ import { InternalError } from '../errors.js';
14
+ import { type FsOps } from './fs-ops.js';
15
+ /** True when `child` is `parent` or inside it (both absolute paths). Only a `..` segment leaves
16
+ * `parent`: a child named `..review-probe` is inside it. */
17
+ export declare function within(child: string, parent: string): boolean;
18
+ /** The entry's own status (a link is not followed), or undefined when nothing is there. */
19
+ export declare function lstatOrUndefined(path: string, ops?: FsOps): Stats | undefined;
20
+ /** What makes the output folder the one the build validated: its real path, device and inode. */
21
+ export interface FolderIdentity {
22
+ path: string;
23
+ real: string;
24
+ dev: number;
25
+ ino: number;
26
+ }
27
+ /** The identity of the folder at `path`, which must be a real folder, not a link. */
28
+ export declare function folderIdentity(path: string, ops?: FsOps): FolderIdentity;
29
+ /** The output folder is no longer the one the build validated. Callers stop at once, even an undo. */
30
+ export declare class FolderChanged extends InternalError {
31
+ }
32
+ /** Throw FolderChanged, before any further change, when the folder at `expected.path` is no longer
33
+ * the same one: moved, replaced by another folder, or replaced by a link (a parent included). */
34
+ export declare function assertSameFolder(expected: FolderIdentity, ops?: FsOps): void;
@@ -0,0 +1,48 @@
1
+ import { isAbsolute, relative, sep } from 'node:path';
2
+ import { InternalError } from '../errors.js';
3
+ import { NODE_FS } from './fs-ops.js';
4
+ /** True when `child` is `parent` or inside it (both absolute paths). Only a `..` segment leaves
5
+ * `parent`: a child named `..review-probe` is inside it. */
6
+ export function within(child, parent) {
7
+ const path = relative(parent, child);
8
+ const outside = path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path);
9
+ return !outside;
10
+ }
11
+ /** The entry's own status (a link is not followed), or undefined when nothing is there. */
12
+ export function lstatOrUndefined(path, ops = NODE_FS) {
13
+ try {
14
+ return ops.lstat(path);
15
+ }
16
+ catch (error) {
17
+ if (error.code === 'ENOENT')
18
+ return undefined;
19
+ throw error;
20
+ }
21
+ }
22
+ /** The identity of the folder at `path`, which must be a real folder, not a link. */
23
+ export function folderIdentity(path, ops = NODE_FS) {
24
+ const stats = ops.lstat(path);
25
+ if (!stats.isDirectory())
26
+ throw new InternalError(`stackledger build: the output folder ${path} is not a folder`);
27
+ return { path, real: ops.realpath(path), dev: stats.dev, ino: stats.ino };
28
+ }
29
+ /** The output folder is no longer the one the build validated. Callers stop at once, even an undo. */
30
+ export class FolderChanged extends InternalError {
31
+ }
32
+ /** Throw FolderChanged, before any further change, when the folder at `expected.path` is no longer
33
+ * the same one: moved, replaced by another folder, or replaced by a link (a parent included). */
34
+ export function assertSameFolder(expected, ops = NODE_FS) {
35
+ let now;
36
+ try {
37
+ now = folderIdentity(expected.path, ops);
38
+ }
39
+ catch {
40
+ // Missing, unreadable or not a folder: in every case not the folder the build validated.
41
+ now = undefined;
42
+ }
43
+ const same = now !== undefined && now.real === expected.real && now.dev === expected.dev && now.ino === expected.ino;
44
+ if (!same) {
45
+ throw new FolderChanged(`stackledger build: the output folder ${expected.path} was moved or replaced during the build; stopped without further changes`);
46
+ }
47
+ }
48
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/site/paths.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAc,MAAM,aAAa,CAAC;AAElD;4DAC4D;AAC5D,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,MAAc;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACjF,OAAO,CAAC,OAAO,CAAC;AAClB,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,MAAa,OAAO;IACjE,IAAI,CAAC;QACH,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QACzE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAKD,qFAAqF;AACrF,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,MAAa,OAAO;IAC/D,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;QAAE,MAAM,IAAI,aAAa,CAAC,wCAAwC,IAAI,kBAAkB,CAAC,CAAC;IAClH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;AAC5E,CAAC;AAED,sGAAsG;AACtG,MAAM,OAAO,aAAc,SAAQ,aAAa;CAAG;AAEnD;iGACiG;AACjG,MAAM,UAAU,gBAAgB,CAAC,QAAwB,EAAE,MAAa,OAAO;IAC7E,IAAI,GAA+B,CAAC;IACpC,IAAI,CAAC;QACH,GAAG,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,yFAAyF;QACzF,GAAG,GAAG,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,CAAC;IACrH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,aAAa,CAAC,wCAAwC,QAAQ,CAAC,IAAI,0EAA0E,CAAC,CAAC;IAC3J,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Fixed files and policy of every built site: the Content Security Policy, `_headers`, `robots.txt`
2
+ * and the output-folder marker (site-security, build-command specs).
3
+ *
4
+ * Why one module: the layout's CSP meta (written into each working copy as src/data/policy.json),
5
+ * the `_headers` file and the output scan all read POLICY from here, so they cannot drift apart.
6
+ * Nothing here depends on the catalogue, the date or the version.
7
+ */
8
+ export declare const POLICY = "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'";
9
+ /** Cloudflare Pages / Netlify style headers for every path; `frame-ancestors` only works as a header. */
10
+ export declare const HEADERS: string;
11
+ export declare const ROBOTS = "User-agent: *\nDisallow: /\n";
12
+ /** Cloudflare Pages / Netlify style root redirect: `/` leads to the staff site, or to the full site
13
+ * in the personal mode, where there is no staff site. */
14
+ export declare const redirects: (sites: readonly string[]) => string;
15
+ /** Written at the root of the output folder; its presence lets a later build replace the folder. */
16
+ export declare const MARKER_NAME = ".stackledger-build";
17
+ export declare const MARKER = "This folder is written by stackledger build. The next build replaces it.\n";
@@ -0,0 +1,26 @@
1
+ /** Fixed files and policy of every built site: the Content Security Policy, `_headers`, `robots.txt`
2
+ * and the output-folder marker (site-security, build-command specs).
3
+ *
4
+ * Why one module: the layout's CSP meta (written into each working copy as src/data/policy.json),
5
+ * the `_headers` file and the output scan all read POLICY from here, so they cannot drift apart.
6
+ * Nothing here depends on the catalogue, the date or the version.
7
+ */
8
+ export const POLICY = "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'";
9
+ /** Cloudflare Pages / Netlify style headers for every path; `frame-ancestors` only works as a header. */
10
+ export const HEADERS = [
11
+ '/*',
12
+ ` Content-Security-Policy: ${POLICY}; frame-ancestors 'none'`,
13
+ ' X-Content-Type-Options: nosniff',
14
+ ' Referrer-Policy: no-referrer',
15
+ ' X-Robots-Tag: noindex, nofollow',
16
+ ' Permissions-Policy: camera=(), microphone=(), geolocation=()',
17
+ '',
18
+ ].join('\n');
19
+ export const ROBOTS = 'User-agent: *\nDisallow: /\n';
20
+ /** Cloudflare Pages / Netlify style root redirect: `/` leads to the staff site, or to the full site
21
+ * in the personal mode, where there is no staff site. */
22
+ export const redirects = (sites) => `/ /${sites.includes('staff') ? 'staff' : 'full'}/ 302\n`;
23
+ /** Written at the root of the output folder; its presence lets a later build replace the folder. */
24
+ export const MARKER_NAME = '.stackledger-build';
25
+ export const MARKER = 'This folder is written by stackledger build. The next build replaces it.\n';
26
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/site/policy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,4KAA4K,CAAC;AAEnM,yGAAyG;AACzG,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;IACJ,8BAA8B,MAAM,0BAA0B;IAC9D,mCAAmC;IACnC,gCAAgC;IAChC,mCAAmC;IACnC,gEAAgE;IAChE,EAAE;CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,MAAM,GAAG,8BAA8B,CAAC;AAErD;yDACyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAwB,EAAE,EAAE,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC;AAEjH,oGAAoG;AACpG,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAChD,MAAM,CAAC,MAAM,MAAM,GAAG,4EAA4E,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { InternalError } from '../errors.js';
2
+ import { type FsOps } from './fs-ops.js';
3
+ import { type FolderIdentity } from './paths.js';
4
+ /** Published entries, in publication order, with their place in the staging folder. The marker is last. */
5
+ export declare const ENTRIES: readonly {
6
+ name: string;
7
+ staged: string;
8
+ }[];
9
+ /** A publication failed and its undo failed too: the staging folder must be kept. */
10
+ export declare class UndoFailed extends InternalError {
11
+ }
12
+ /** Publish the staged entries of `staging` into `out`. On a failure before the commit, undo every
13
+ * rename and rethrow; throws FolderChanged or UndoFailed when that is not possible. */
14
+ export declare function publish(out: string, staging: string, identity: FolderIdentity, ops?: FsOps): void;