@brunosouzas/stackledger 0.0.0-stage → 0.5.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 (323) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +261 -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 +64 -0
  103. package/dist/map/layout.js +228 -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 +137 -0
  110. package/dist/map/neighbourhood.js.map +1 -0
  111. package/dist/map/parallel.d.ts +35 -0
  112. package/dist/map/parallel.js +261 -0
  113. package/dist/map/parallel.js.map +1 -0
  114. package/dist/map/pieces.d.ts +12 -0
  115. package/dist/map/pieces.js +15 -0
  116. package/dist/map/pieces.js.map +1 -0
  117. package/dist/map/relations.d.ts +39 -0
  118. package/dist/map/relations.js +122 -0
  119. package/dist/map/relations.js.map +1 -0
  120. package/dist/map/route.d.ts +25 -0
  121. package/dist/map/route.js +165 -0
  122. package/dist/map/route.js.map +1 -0
  123. package/dist/map/strip.d.ts +29 -0
  124. package/dist/map/strip.js +120 -0
  125. package/dist/map/strip.js.map +1 -0
  126. package/dist/map/suggest.d.ts +21 -0
  127. package/dist/map/suggest.js +97 -0
  128. package/dist/map/suggest.js.map +1 -0
  129. package/dist/map/svg.d.ts +29 -0
  130. package/dist/map/svg.js +203 -0
  131. package/dist/map/svg.js.map +1 -0
  132. package/dist/map/themes.d.ts +64 -0
  133. package/dist/map/themes.js +94 -0
  134. package/dist/map/themes.js.map +1 -0
  135. package/dist/map/xml.d.ts +6 -0
  136. package/dist/map/xml.js +57 -0
  137. package/dist/map/xml.js.map +1 -0
  138. package/dist/map/zones.d.ts +19 -0
  139. package/dist/map/zones.js +46 -0
  140. package/dist/map/zones.js.map +1 -0
  141. package/dist/mcp.d.ts +2 -0
  142. package/dist/mcp.js +145 -0
  143. package/dist/mcp.js.map +1 -0
  144. package/dist/money.d.ts +32 -0
  145. package/dist/money.js +91 -0
  146. package/dist/money.js.map +1 -0
  147. package/dist/report-command.d.ts +3 -0
  148. package/dist/report-command.js +85 -0
  149. package/dist/report-command.js.map +1 -0
  150. package/dist/report-formats.d.ts +11 -0
  151. package/dist/report-formats.js +157 -0
  152. package/dist/report-formats.js.map +1 -0
  153. package/dist/reports.d.ts +105 -0
  154. package/dist/reports.js +247 -0
  155. package/dist/reports.js.map +1 -0
  156. package/dist/scaffold.d.ts +30 -0
  157. package/dist/scaffold.js +140 -0
  158. package/dist/scaffold.js.map +1 -0
  159. package/dist/schema.d.ts +345 -0
  160. package/dist/schema.js +120 -0
  161. package/dist/schema.js.map +1 -0
  162. package/dist/secrets.d.ts +7 -0
  163. package/dist/secrets.js +68 -0
  164. package/dist/secrets.js.map +1 -0
  165. package/dist/site/build.d.ts +22 -0
  166. package/dist/site/build.js +198 -0
  167. package/dist/site/build.js.map +1 -0
  168. package/dist/site/command.d.ts +2 -0
  169. package/dist/site/command.js +221 -0
  170. package/dist/site/command.js.map +1 -0
  171. package/dist/site/data.d.ts +225 -0
  172. package/dist/site/data.js +243 -0
  173. package/dist/site/data.js.map +1 -0
  174. package/dist/site/fs-ops.d.ts +35 -0
  175. package/dist/site/fs-ops.js +26 -0
  176. package/dist/site/fs-ops.js.map +1 -0
  177. package/dist/site/owners.d.ts +5 -0
  178. package/dist/site/owners.js +50 -0
  179. package/dist/site/owners.js.map +1 -0
  180. package/dist/site/paths.d.ts +34 -0
  181. package/dist/site/paths.js +48 -0
  182. package/dist/site/paths.js.map +1 -0
  183. package/dist/site/policy.d.ts +17 -0
  184. package/dist/site/policy.js +26 -0
  185. package/dist/site/policy.js.map +1 -0
  186. package/dist/site/publish.d.ts +14 -0
  187. package/dist/site/publish.js +90 -0
  188. package/dist/site/publish.js.map +1 -0
  189. package/dist/site/relative.d.ts +14 -0
  190. package/dist/site/relative.js +265 -0
  191. package/dist/site/relative.js.map +1 -0
  192. package/dist/site/skills-build.d.ts +22 -0
  193. package/dist/site/skills-build.js +126 -0
  194. package/dist/site/skills-build.js.map +1 -0
  195. package/dist/site/skills-data.d.ts +89 -0
  196. package/dist/site/skills-data.js +94 -0
  197. package/dist/site/skills-data.js.map +1 -0
  198. package/dist/site/staging.d.ts +19 -0
  199. package/dist/site/staging.js +76 -0
  200. package/dist/site/staging.js.map +1 -0
  201. package/dist/site/ui-icons.d.ts +4 -0
  202. package/dist/site/ui-icons.js +19 -0
  203. package/dist/site/ui-icons.js.map +1 -0
  204. package/dist/skills/command.d.ts +8 -0
  205. package/dist/skills/command.js +64 -0
  206. package/dist/skills/command.js.map +1 -0
  207. package/dist/skills/frontmatter.d.ts +37 -0
  208. package/dist/skills/frontmatter.js +219 -0
  209. package/dist/skills/frontmatter.js.map +1 -0
  210. package/dist/skills/graph.d.ts +39 -0
  211. package/dist/skills/graph.js +100 -0
  212. package/dist/skills/graph.js.map +1 -0
  213. package/dist/skills/ignore.d.ts +34 -0
  214. package/dist/skills/ignore.js +138 -0
  215. package/dist/skills/ignore.js.map +1 -0
  216. package/dist/skills/lines.d.ts +53 -0
  217. package/dist/skills/lines.js +221 -0
  218. package/dist/skills/lines.js.map +1 -0
  219. package/dist/skills/map-command.d.ts +28 -0
  220. package/dist/skills/map-command.js +533 -0
  221. package/dist/skills/map-command.js.map +1 -0
  222. package/dist/skills/mermaid.d.ts +29 -0
  223. package/dist/skills/mermaid.js +261 -0
  224. package/dist/skills/mermaid.js.map +1 -0
  225. package/dist/skills/metro.d.ts +8 -0
  226. package/dist/skills/metro.js +93 -0
  227. package/dist/skills/metro.js.map +1 -0
  228. package/dist/skills/read.d.ts +17 -0
  229. package/dist/skills/read.js +54 -0
  230. package/dist/skills/read.js.map +1 -0
  231. package/dist/skills/rules.d.ts +28 -0
  232. package/dist/skills/rules.js +57 -0
  233. package/dist/skills/rules.js.map +1 -0
  234. package/dist/skills/source.d.ts +66 -0
  235. package/dist/skills/source.js +281 -0
  236. package/dist/skills/source.js.map +1 -0
  237. package/dist/skills/walk.d.ts +64 -0
  238. package/dist/skills/walk.js +281 -0
  239. package/dist/skills/walk.js.map +1 -0
  240. package/dist/source.d.ts +40 -0
  241. package/dist/source.js +199 -0
  242. package/dist/source.js.map +1 -0
  243. package/dist/stdout.d.ts +2 -0
  244. package/dist/stdout.js +24 -0
  245. package/dist/stdout.js.map +1 -0
  246. package/dist/validate.d.ts +45 -0
  247. package/dist/validate.js +321 -0
  248. package/dist/validate.js.map +1 -0
  249. package/dist/views.d.ts +25 -0
  250. package/dist/views.js +58 -0
  251. package/dist/views.js.map +1 -0
  252. package/examples/catalogue-repository/.github/workflows/stackledger.yml +122 -0
  253. package/examples/catalogue-repository/README.md +96 -0
  254. package/examples/catalogue-repository/catalog/catalog-info.yaml +12 -0
  255. package/examples/hosting/Caddyfile +69 -0
  256. package/examples/northwind/catalog-info.yaml +680 -0
  257. package/examples/northwind/stackledger.yaml +16 -0
  258. package/examples/northwind-machine/snapshot.json +309 -0
  259. package/examples/northwind-skills/agents/builder.md +10 -0
  260. package/examples/northwind-skills/agents/reviewer.md +10 -0
  261. package/examples/northwind-skills/designer/SKILL.md +8 -0
  262. package/examples/northwind-skills/editor/SKILL.md +8 -0
  263. package/examples/northwind-skills/engineering/SKILL.md +12 -0
  264. package/examples/northwind-skills/linter/SKILL.md +8 -0
  265. package/examples/northwind-skills/linter/rules.md +5 -0
  266. package/examples/northwind-skills/publishing/SKILL.md +12 -0
  267. package/examples/northwind-skills/publishing/rules.md +5 -0
  268. package/examples/northwind-skills/spec-writer/SKILL.md +8 -0
  269. package/examples/northwind-skills/stackledger-skills.yaml +51 -0
  270. package/examples/northwind-skills/tester/SKILL.md +10 -0
  271. package/examples/northwind-skills/writer/SKILL.md +8 -0
  272. package/examples/northwind-skills/writer/rules.md +6 -0
  273. package/npm-shrinkwrap.json +5016 -0
  274. package/package.json +52 -4
  275. package/site/LICENSE-astroplate +21 -0
  276. package/site/README.md +18 -0
  277. package/site/package.json +6 -0
  278. package/site/public/brand-mark-dark.svg +7 -0
  279. package/site/public/favicon.svg +6 -0
  280. package/site/public/home-banner.svg +93 -0
  281. package/site/public/link-icons/email-dark.svg +7 -0
  282. package/site/public/link-icons/email-light.svg +6 -0
  283. package/site/public/link-icons/github-dark.svg +8 -0
  284. package/site/public/link-icons/github-light.svg +7 -0
  285. package/site/public/link-icons/linkedin-dark.svg +8 -0
  286. package/site/public/link-icons/linkedin-light.svg +7 -0
  287. package/site/public/link-icons/website-dark.svg +8 -0
  288. package/site/public/link-icons/website-light.svg +7 -0
  289. package/site/src/components/Footer.astro +25 -0
  290. package/site/src/components/Header.astro +35 -0
  291. package/site/src/components/Impact.astro +55 -0
  292. package/site/src/components/LinkOrText.astro +12 -0
  293. package/site/src/components/SkillItem.astro +141 -0
  294. package/site/src/components/SubNav.astro +40 -0
  295. package/site/src/components/ThemeSwitch.astro +13 -0
  296. package/site/src/components/Themed.astro +15 -0
  297. package/site/src/layouts/Base.astro +52 -0
  298. package/site/src/lib/site.ts +25 -0
  299. package/site/src/pages/[reports].astro +222 -0
  300. package/site/src/pages/agents/[file].astro +14 -0
  301. package/site/src/pages/index.astro +72 -0
  302. package/site/src/pages/journeys/[name].astro +50 -0
  303. package/site/src/pages/journeys/index.astro +37 -0
  304. package/site/src/pages/licences/[name].astro +56 -0
  305. package/site/src/pages/map/index.astro +78 -0
  306. package/site/src/pages/playbooks/[file].astro +14 -0
  307. package/site/src/pages/rules/[...rules].astro +61 -0
  308. package/site/src/pages/skill-map/[...map].astro +101 -0
  309. package/site/src/pages/skills/[...list].astro +75 -0
  310. package/site/src/pages/skills/[file].astro +14 -0
  311. package/site/src/pages/software/[name].astro +155 -0
  312. package/site/src/pages/software/index.astro +71 -0
  313. package/site/src/scripts/diagram.ts +8 -0
  314. package/site/src/scripts/links.ts +31 -0
  315. package/site/src/scripts/map.ts +133 -0
  316. package/site/src/scripts/software.ts +32 -0
  317. package/site/src/scripts/theme.ts +52 -0
  318. package/site/src/styles/base.css +481 -0
  319. package/site/src/styles/fonts.css +60 -0
  320. package/site/src/styles/override.css +1 -0
  321. package/site/src/styles/pages.css +315 -0
  322. package/site/src/styles/tokens.css +87 -0
  323. package/skills/stackledger/SKILL.md +155 -0
@@ -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;
@@ -0,0 +1,90 @@
1
+ /** Atomic publication of a prepared build into the output folder (build-command, Atomic replace and
2
+ * Interrupted publication; design D8). Called by src/site/command.ts.
3
+ *
4
+ * For each entry `staff`, `full`, `_headers`, `robots.txt`, `_redirects` and `.stackledger-build`, in
5
+ * that order, the existing entry (if any) is renamed into `<staging>/old/`, then the new one is renamed
6
+ * into place. A personal build (FULL_ONLY in the staging folder) has no new `staff`: an earlier one
7
+ * only moves into `old/`, so it is removed after the commit. `old/` is created just before the first rename, so a staging folder without it never held
8
+ * a published entry (staging.ts). The renames done are recorded in memory only. The rename of the
9
+ * marker is the commit point: a failure before it undoes the renames in reverse, so the output
10
+ * folder is byte for byte what it was. Renames stay on one filesystem because the staging folder is
11
+ * inside the output folder, and none goes through a symbolic link.
12
+ *
13
+ * The output folder's identity (paths.ts) is checked immediately before creating `old/` and before
14
+ * every rename, the undo's included. A mismatch (FolderChanged) stops at once: no further rename,
15
+ * not even to undo, because the paths may now lead somewhere else.
16
+ *
17
+ * What can go wrong: an undo rename can fail too (a folder made read-only meanwhile). The undo then
18
+ * stops and throws UndoFailed; the previous entries are in `<staging>/old/`, the command keeps the
19
+ * staging folder and the person running the build restores them by hand (RESTORE_GUIDE).
20
+ */
21
+ import { join } from 'node:path';
22
+ import { InternalError } from '../errors.js';
23
+ import { NODE_FS } from './fs-ops.js';
24
+ import { assertSameFolder, FolderChanged, lstatOrUndefined } from './paths.js';
25
+ import { MARKER_NAME } from './policy.js';
26
+ import { FULL_ONLY, OLD_NAME, RESTORE_GUIDE } from './staging.js';
27
+ /** Published entries, in publication order, with their place in the staging folder. The marker is last. */
28
+ export const ENTRIES = [
29
+ { name: 'staff', staged: 'site-staff' },
30
+ { name: 'full', staged: 'site-full' },
31
+ { name: '_headers', staged: join('root', '_headers') },
32
+ { name: 'robots.txt', staged: join('root', 'robots.txt') },
33
+ { name: '_redirects', staged: join('root', '_redirects') },
34
+ { name: MARKER_NAME, staged: join('root', MARKER_NAME) },
35
+ ];
36
+ /** A publication failed and its undo failed too: the staging folder must be kept. */
37
+ export class UndoFailed extends InternalError {
38
+ }
39
+ /** Publish the staged entries of `staging` into `out`. On a failure before the commit, undo every
40
+ * rename and rethrow; throws FolderChanged or UndoFailed when that is not possible. */
41
+ export function publish(out, staging, identity, ops = NODE_FS) {
42
+ const done = [];
43
+ const move = (from, to) => {
44
+ assertSameFolder(identity, ops);
45
+ ops.rename(from, to);
46
+ done.push({ from, to });
47
+ };
48
+ try {
49
+ assertSameFolder(identity, ops);
50
+ ops.mkdir(join(staging, OLD_NAME));
51
+ const fullOnly = lstatOrUndefined(join(staging, FULL_ONLY), ops) !== undefined;
52
+ for (const entry of ENTRIES) {
53
+ const target = join(out, entry.name);
54
+ const existing = lstatOrUndefined(target, ops);
55
+ // Never rename through a link (command.ts refuses them before the build; this is the last check).
56
+ if (existing?.isSymbolicLink())
57
+ throw new Error(`${target} is a symbolic link`);
58
+ if (existing)
59
+ move(target, join(staging, OLD_NAME, entry.name));
60
+ if (!(fullOnly && entry.name === 'staff'))
61
+ move(join(staging, entry.staged), target);
62
+ }
63
+ }
64
+ catch (error) {
65
+ if (error instanceof FolderChanged)
66
+ throw error;
67
+ undo(staging, done, identity, ops, error);
68
+ throw error;
69
+ }
70
+ }
71
+ /** Put back the renames in `done`, latest first. Stops at the first failure: the remaining entries
72
+ * stay where they are, which is the state the manual restore in docs/site.md starts from. */
73
+ function undo(staging, done, identity, ops, cause) {
74
+ for (const step of [...done].reverse()) {
75
+ assertSameFolder(identity, ops);
76
+ try {
77
+ ops.rename(step.to, step.from);
78
+ }
79
+ catch (error) {
80
+ throw new UndoFailed(undoFailedMessage(staging, cause, error));
81
+ }
82
+ }
83
+ }
84
+ function undoFailedMessage(staging, cause, error) {
85
+ const reason = (value) => (value instanceof Error ? value.message : String(value)).replace(/\s+/g, ' ').trim();
86
+ return `stackledger build: publication failed (${reason(cause)}) and could not be undone (${reason(error)}); `
87
+ + `the previous entries are in ${join(staging, OLD_NAME)}. The staging folder ${staging} was kept: `
88
+ + `restore by hand as ${RESTORE_GUIDE} explains; until that folder is removed, stackledger build refuses this output folder`;
89
+ }
90
+ //# sourceMappingURL=publish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/site/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAc,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAuB,MAAM,YAAY,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElE,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAgD;IAClE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE;IACvC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE;IACrC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;IACtD,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;IAC1D,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;IAC1D,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE;CACzD,CAAC;AAEF,qFAAqF;AACrF,MAAM,OAAO,UAAW,SAAQ,aAAa;CAAG;AAIhD;uFACuF;AACvF,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,OAAe,EAAE,QAAwB,EAAE,MAAa,OAAO;IAClG,MAAM,IAAI,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E,MAAM,KAAK,CAAC;QAChD,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;6FAC6F;AAC7F,SAAS,IAAI,CAAC,OAAe,EAAE,IAAqB,EAAE,QAAwB,EAAE,GAAU,EAAE,KAAc;IACxG,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QACvC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,UAAU,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe,EAAE,KAAc,EAAE,KAAc;IACxE,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACxH,OAAO,0CAA0C,MAAM,CAAC,KAAK,CAAC,8BAA8B,MAAM,CAAC,KAAK,CAAC,KAAK;UAC1G,+BAA+B,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,wBAAwB,OAAO,aAAa;UAClG,sBAAsB,aAAa,uFAAuF,CAAC;AACjI,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** Every file under a folder, as sorted paths relative to it with forward slashes. */
2
+ export declare function listFiles(dir: string, base?: string): string[];
3
+ /** The text of an HTML attribute value as a browser reads it, and the named references in it that
4
+ * are not in NAMED_REFERENCES (left as they are; a URL holding one is refused). */
5
+ export declare function decodeAttribute(value: string): {
6
+ text: string;
7
+ unknown: string[];
8
+ };
9
+ /** Rewrite every root-absolute Astro asset URL in the site's HTML and CSS files, in place. */
10
+ export declare function relativise(siteDir: string): void;
11
+ /** Every problem in a built site; an empty list means it may be published. `buildPaths` are the
12
+ * build's own paths (the staging folder, the working copy): none may appear in an output file.
13
+ * Only these exact paths count, so catalogue text that mentions `.stackledger-tmp-*` is fine. */
14
+ export declare function scan(siteDir: string, buildPaths?: readonly string[], homeLinks?: readonly string[]): string[];
@@ -0,0 +1,265 @@
1
+ /** Relative URLs and the output scan of one built site (design D3 and D4).
2
+ *
3
+ * Why: Astro has no relative base and writes root-absolute `/_astro/...` URLs. relativise(siteDir)
4
+ * rewrites them in HTML URL attributes and in CSS `url()` and `@import`, relative to the file that
5
+ * holds them, so a site works under any path prefix (`/full/`, `/staff/`). scan(siteDir, buildPaths)
6
+ * then lists every URL form the rewrite does not handle, every relative URL that resolves outside
7
+ * the site folder (`../../../full/` from a `staff` page), every piece of inline code, any page whose
8
+ * CSP differs from POLICY and any build path left in a file; the build fails on any problem, before
9
+ * anything is published.
10
+ *
11
+ * HTML is read tag by tag: catalogue text is escaped by Astro and the SVG renderers, so `<` and `>`
12
+ * never appear inside text or attribute values, and a hostile title cannot look like an attribute.
13
+ * Deterministic: files are visited in sorted order and only rewritten, never renamed.
14
+ *
15
+ * URLs are checked as a browser reads them: attribute values are decoded with the HTML character
16
+ * reference rules (`&#47;`, `&#x2f;`, `&sol;`, `&Tab;`…), ASCII tab, line feed and carriage return
17
+ * are dropped as the URL parser drops them, and the result is resolved with WHATWG URL against a
18
+ * made-up origin. A URL with a scheme, a leading `/` or `\`, another origin or a path outside the
19
+ * site folder is refused. Named references outside a small table of the ones that can form URL
20
+ * syntax are refused too, so an unknown name can never hide a separator. CSS escapes are not
21
+ * decoded: a CSS URL holding a backslash is refused instead.
22
+ */
23
+ import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
24
+ import { join, posix, relative, sep } from 'node:path';
25
+ import { POLICY } from './policy.js';
26
+ const URL_ATTRIBUTES = new Set(['href', 'src', 'action', 'formaction', 'poster', 'data', 'xlink:href']);
27
+ // Quoted attribute values may hold `>` (Astro escapes only `&` and `"`), so they are matched whole.
28
+ const TAG = /<([A-Za-z][A-Za-z0-9:-]*)((?:\s(?:"[^"]*"|'[^']*'|[^<>"'])*?)?)(\/?)>/g;
29
+ const ATTRIBUTE = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
30
+ const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/;
31
+ const ASTRO_ASSET = /^\/_astro\//;
32
+ /** Named character references that can spell URL syntax, or that Astro writes. Any other name in a
33
+ * URL is refused rather than decoded (see decodeAttribute). */
34
+ const NAMED_REFERENCES = {
35
+ amp: '&', AMP: '&', lt: '<', LT: '<', gt: '>', GT: '>', quot: '"', QUOT: '"', apos: "'",
36
+ sol: '/', bsol: '\\', colon: ':', Tab: '\t', NewLine: '\n', period: '.', percnt: '%', quest: '?',
37
+ num: '#', commat: '@', excl: '!', dollar: '$', lpar: '(', rpar: ')', ast: '*', midast: '*', plus: '+',
38
+ comma: ',', semi: ';', equals: '=', lsqb: '[', lbrack: '[', rsqb: ']', rbrack: ']', lcub: '{',
39
+ lbrace: '{', rcub: '}', rbrace: '}', verbar: '|', vert: '|', VerticalLine: '|', lowbar: '_',
40
+ UnderBar: '_', Hat: '^', grave: '`', DiacriticalGrave: '`', nbsp: '\u00a0', NonBreakingSpace: '\u00a0',
41
+ };
42
+ /** Numeric references to 0x80-0x9F mean Windows-1252 characters in browsers (HTML standard). */
43
+ const WINDOWS_1252 = {
44
+ 0x80: 0x20ac, 0x82: 0x201a, 0x83: 0x0192, 0x84: 0x201e, 0x85: 0x2026, 0x86: 0x2020, 0x87: 0x2021,
45
+ 0x88: 0x02c6, 0x89: 0x2030, 0x8a: 0x0160, 0x8b: 0x2039, 0x8c: 0x0152, 0x8e: 0x017d, 0x91: 0x2018,
46
+ 0x92: 0x2019, 0x93: 0x201c, 0x94: 0x201d, 0x95: 0x2022, 0x96: 0x2013, 0x97: 0x2014, 0x98: 0x02dc,
47
+ 0x99: 0x2122, 0x9a: 0x0161, 0x9b: 0x203a, 0x9c: 0x0153, 0x9e: 0x017e, 0x9f: 0x0178,
48
+ };
49
+ /** A numeric reference (the semicolon is optional for browsers) or a named one with its semicolon. */
50
+ const CHARACTER_REFERENCE = /&#(\d+);?|&#[xX]([0-9A-Fa-f]+);?|&([A-Za-z][A-Za-z0-9]*);/g;
51
+ /** Every file under a folder, as sorted paths relative to it with forward slashes. */
52
+ export function listFiles(dir, base = dir) {
53
+ const files = [];
54
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
55
+ const full = join(dir, entry.name);
56
+ if (entry.isDirectory())
57
+ files.push(...listFiles(full, base));
58
+ else
59
+ files.push(relative(base, full).split(sep).join('/'));
60
+ }
61
+ return files.sort();
62
+ }
63
+ function attributes(text) {
64
+ return [...text.matchAll(ATTRIBUTE)].map(match => ({ name: match[1].toLowerCase(), value: match[2] ?? match[3] ?? match[4] }));
65
+ }
66
+ /** The text of an HTML attribute value as a browser reads it, and the named references in it that
67
+ * are not in NAMED_REFERENCES (left as they are; a URL holding one is refused). */
68
+ export function decodeAttribute(value) {
69
+ const unknown = [];
70
+ const text = value.replace(CHARACTER_REFERENCE, (whole, decimal, hex, name) => {
71
+ if (name !== undefined) {
72
+ const named = NAMED_REFERENCES[name];
73
+ if (named === undefined)
74
+ unknown.push(whole);
75
+ return named ?? whole;
76
+ }
77
+ return fromCodePoint(decimal !== undefined ? Number.parseInt(decimal, 10) : Number.parseInt(hex, 16));
78
+ });
79
+ return { text, unknown };
80
+ }
81
+ /** The character a numeric reference stands for, with the browser's replacements. */
82
+ function fromCodePoint(code) {
83
+ const invalid = code === 0 || code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff) || Number.isNaN(code);
84
+ return invalid ? '\ufffd' : String.fromCodePoint(WINDOWS_1252[code] ?? code);
85
+ }
86
+ /** A made-up origin and folder for the site root; any URL resolving elsewhere leaves the site. */
87
+ const SITE_ORIGIN = 'https://site.invalid';
88
+ const SITE_FOLDER = '/root/';
89
+ /** Encoded `/` and `\`: a server that decodes them before resolving the path could climb out. */
90
+ const ENCODED_SEPARATOR = /%2f|%5c/i;
91
+ /** What the WHATWG URL parser removes before parsing: tab, line feed and carriage return anywhere,
92
+ * and C0 controls or spaces at either end. */
93
+ const URL_IGNORED = /[\t\n\r]/g;
94
+ const URL_TRIMMED = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
95
+ /** Why `url` (already decoded from HTML) is not a local URL of `file`, or undefined when it is.
96
+ * `file` is a path from the site root; the URL is resolved as a browser would resolve it there. */
97
+ function urlProblem(file, url) {
98
+ const cleaned = url.replace(URL_IGNORED, '').replace(URL_TRIMMED, '');
99
+ // Root-absolute, protocol-relative (a backslash counts as a slash) or with a scheme.
100
+ if (/^[\\/]/.test(cleaned) || SCHEME.test(cleaned))
101
+ return 'leaves the site';
102
+ let resolved;
103
+ try {
104
+ resolved = new URL(cleaned, `${SITE_ORIGIN}${SITE_FOLDER}${file}`);
105
+ }
106
+ catch {
107
+ return 'leaves the site';
108
+ }
109
+ if (resolved.origin !== SITE_ORIGIN)
110
+ return 'leaves the site';
111
+ if (!resolved.pathname.startsWith(SITE_FOLDER) || ENCODED_SEPARATOR.test(resolved.pathname))
112
+ return 'leaves the site folder';
113
+ return undefined;
114
+ }
115
+ /** Rewrite `/_astro/...` into a path relative to the folder of `file` (both relative to the site root). */
116
+ function toRelative(file, url) {
117
+ return posix.relative(posix.dirname(file), url.slice(1)) || './';
118
+ }
119
+ function relativiseHtml(file, html) {
120
+ return html.replace(TAG, (tag, name, attrs, close) => {
121
+ const rewritten = attrs.replace(/(\s)([A-Za-z:-]+)=(["'])([^"']*)\3/g, (whole, space, attr, quote, value) => {
122
+ const key = attr.toLowerCase();
123
+ if (URL_ATTRIBUTES.has(key) && ASTRO_ASSET.test(value))
124
+ return `${space}${attr}=${quote}${toRelative(file, value)}${quote}`;
125
+ if (key === 'srcset') {
126
+ const parts = value.split(',').map(part => part.trim().replace(/^\/_astro\/\S*/, url => toRelative(file, url)));
127
+ return `${space}${attr}=${quote}${parts.join(', ')}${quote}`;
128
+ }
129
+ return whole;
130
+ });
131
+ return `<${name}${rewritten}${close}>`;
132
+ });
133
+ }
134
+ function relativiseCss(file, css) {
135
+ return css
136
+ .replace(/url\(\s*(["']?)(\/_astro\/[^"')]*)\1\s*\)/g, (_, quote, url) => `url(${quote}${toRelative(file, url)}${quote})`)
137
+ .replace(/@import\s+(["'])(\/_astro\/[^"']*)\1/g, (_, quote, url) => `@import ${quote}${toRelative(file, url)}${quote}`);
138
+ }
139
+ /** Rewrite every root-absolute Astro asset URL in the site's HTML and CSS files, in place. */
140
+ export function relativise(siteDir) {
141
+ for (const file of listFiles(siteDir)) {
142
+ const path = join(siteDir, file);
143
+ if (file.endsWith('.html'))
144
+ writeFileSync(path, relativiseHtml(file, readFileSync(path, 'utf8')));
145
+ else if (file.endsWith('.css'))
146
+ writeFileSync(path, relativiseCss(file, readFileSync(path, 'utf8')));
147
+ }
148
+ }
149
+ /** `homeLinks`: the validated URLs of spec.site.home.links, allowed only as the href of an `a` element
150
+ * in the site's root index.html (site-security, No external requests). */
151
+ function scanHtml(file, html, homeLinks = []) {
152
+ const problems = [];
153
+ const policies = [];
154
+ for (const [, rawName, attrText] of html.matchAll(TAG)) {
155
+ const name = rawName.toLowerCase();
156
+ const attrs = attributes(attrText ?? '');
157
+ const has = (key) => attrs.some(attr => attr.name === key);
158
+ if (name === 'script' && !has('src'))
159
+ problems.push(`${file}: inline <script>`);
160
+ if (name === 'style')
161
+ problems.push(`${file}: <style> element`);
162
+ for (const attr of attrs) {
163
+ if (attr.name === 'style')
164
+ problems.push(`${file}: style attribute`);
165
+ if (attr.name.startsWith('on'))
166
+ problems.push(`${file}: event-handler attribute ${attr.name}`);
167
+ if (name === 'a' && attr.name === 'href' && file === 'index.html' && isHomeLink(attr, homeLinks))
168
+ continue;
169
+ if (URL_ATTRIBUTES.has(attr.name) || attr.name === 'srcset')
170
+ problems.push(...urlAttributeProblems(file, attr));
171
+ }
172
+ const equiv = attrs.find(attr => attr.name === 'http-equiv')?.value;
173
+ if (name === 'meta' && equiv?.toLowerCase() === 'content-security-policy') {
174
+ policies.push(decodeAttribute(attrs.find(attr => attr.name === 'content')?.value ?? '').text);
175
+ }
176
+ }
177
+ if (policies.length !== 1 || policies[0] !== POLICY)
178
+ problems.push(`${file}: CSP meta ${JSON.stringify(policies)}`);
179
+ return problems;
180
+ }
181
+ /** An anchor's href that is exactly one of the home links once decoded (no unknown references). */
182
+ function isHomeLink(attr, homeLinks) {
183
+ if (!homeLinks.length)
184
+ return false;
185
+ const { text, unknown } = decodeAttribute(attr.value ?? '');
186
+ return !unknown.length && homeLinks.includes(text);
187
+ }
188
+ /** The problems of one URL attribute (or each URL of a srcset), its value decoded first. */
189
+ function urlAttributeProblems(file, attr) {
190
+ const { text, unknown } = decodeAttribute(attr.value ?? '');
191
+ if (unknown.length)
192
+ return [`${file}: ${attr.name}="${attr.value}" has an unknown character reference ${unknown[0]}`];
193
+ if (attr.name !== 'srcset')
194
+ return urlProblems(file, `${attr.name}="${text}"`, text);
195
+ return text
196
+ .split(',')
197
+ .map(item => item.replace(ASCII_EDGE_SPACE, ''))
198
+ .flatMap(part => urlProblems(file, `srcset part "${part}"`, part.split(ASCII_SPACE)[0] ?? ''));
199
+ }
200
+ /** HTML's ASCII whitespace only: a no-break space (U+00A0) is part of a URL, not a separator. */
201
+ const ASCII_SPACE = /[\t\n\f\r ]+/;
202
+ const ASCII_EDGE_SPACE = /^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;
203
+ /** The problem with one URL of `file`, if any. `label` names the URL in the message. */
204
+ function urlProblems(file, label, url) {
205
+ const problem = urlProblem(file, url);
206
+ if (problem === 'leaves the site')
207
+ return [`${file}: ${label}`];
208
+ if (problem)
209
+ return [`${file}: ${label} ${problem}`];
210
+ return [];
211
+ }
212
+ function scanCss(file, css) {
213
+ const problems = [];
214
+ const check = (label, url) => {
215
+ // CSS escapes (`\2f`) are not decoded here: refuse any backslash instead.
216
+ if (url.includes('\\'))
217
+ problems.push(`${file}: ${label} has a CSS escape`);
218
+ else
219
+ problems.push(...urlProblems(file, label, url));
220
+ };
221
+ for (const match of css.matchAll(/url\(\s*(["']?)([^"')]*)\1\s*\)/g))
222
+ check(`url(${match[2]})`, match[2].trim());
223
+ for (const match of css.matchAll(/@import\s+(?:url\()?\s*(["']?)([^"')\s;]*)\1/g))
224
+ check(`@import ${match[2]}`, match[2]);
225
+ return problems;
226
+ }
227
+ function scanJs(file, js) {
228
+ const problems = [];
229
+ if (/\bimport\s*\(/.test(js))
230
+ problems.push(`${file}: dynamic import(`);
231
+ if (/import\.meta\.url/.test(js))
232
+ problems.push(`${file}: import.meta.url`);
233
+ if (/\/_astro\//.test(js))
234
+ problems.push(`${file}: /_astro/ string`);
235
+ for (const match of js.matchAll(/(?:\bimport|\bexport)\s*(?:[\w*{}\s,$]*?\bfrom\s*)?["']([^"']+)["']/g)) {
236
+ const specifier = match[1];
237
+ // String escapes (`\x2e`, `\u002e`) would change the specifier: refuse any backslash.
238
+ if (specifier.includes('\\'))
239
+ problems.push(`${file}: import specifier "${specifier}" has a string escape`);
240
+ else if (!specifier.startsWith('./') && !specifier.startsWith('../'))
241
+ problems.push(`${file}: import specifier "${specifier}"`);
242
+ else if (urlProblem(file, specifier))
243
+ problems.push(`${file}: import specifier "${specifier}" leaves the site folder`);
244
+ }
245
+ return problems;
246
+ }
247
+ /** Every problem in a built site; an empty list means it may be published. `buildPaths` are the
248
+ * build's own paths (the staging folder, the working copy): none may appear in an output file.
249
+ * Only these exact paths count, so catalogue text that mentions `.stackledger-tmp-*` is fine. */
250
+ export function scan(siteDir, buildPaths = [], homeLinks = []) {
251
+ const problems = [];
252
+ for (const file of listFiles(siteDir)) {
253
+ const text = readFileSync(join(siteDir, file), 'utf8');
254
+ if (file.endsWith('.html'))
255
+ problems.push(...scanHtml(file, text, homeLinks));
256
+ else if (file.endsWith('.css'))
257
+ problems.push(...scanCss(file, text));
258
+ else if (file.endsWith('.js') || file.endsWith('.mjs'))
259
+ problems.push(...scanJs(file, text));
260
+ if (buildPaths.some(path => text.includes(path)))
261
+ problems.push(`${file}: staging path in the output`);
262
+ }
263
+ return problems;
264
+ }
265
+ //# sourceMappingURL=relative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relative.js","sourceRoot":"","sources":["../../src/site/relative.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AACxG,oGAAoG;AACpG,MAAM,GAAG,GAAG,wEAAwE,CAAC;AACrF,MAAM,SAAS,GAAG,mEAAmE,CAAC;AACtF,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAC3C,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC;+DAC+D;AAC/D,MAAM,gBAAgB,GAAqC;IACzD,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EA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';
3
+ import type { Catalogue } from '../validate.js';
4
+ import { type SkillSet } from '../skills/source.js';
5
+ import type { FsOps } from './fs-ops.js';
6
+ export interface SkillsInUse {
7
+ set?: SkillSet;
8
+ /** Real paths of the folders in use. */
9
+ folders: string[];
10
+ /** A broken Settings holds a `spec.skills` key: exit 1 once the exit-2 checks have passed. */
11
+ brokenSettings: boolean;
12
+ /** Report lines known before the build (a Settings file that could not be parsed). */
13
+ notes: string[];
14
+ }
15
+ /** The folders in use and the set read from them; throws a usage error (exit 2) for a folder that cannot be read. */
16
+ export declare function skillsInUse(option: string[], loaded: Loaded, catalogue: Catalogue, catalogueFolder: string, ops: FsOps): Promise<SkillsInUse>;
17
+ /** Refuse an output folder (its real path `target`) that would touch the skill set (exit 2). */
18
+ export declare function refuseSkillsOutput(target: string, skills: SkillsInUse, ops: FsOps): void;
19
+ /** The exit-1 stops, after every exit-2 check and before anything is written. */
20
+ export declare function skillsStops(skills: SkillsInUse): void;
21
+ /** The report lines of the skill set: counts, problems, then the skills map's suggestions and unrouted hops. */
22
+ export declare function skillsReport(set: SkillSet, geometry: MapGeometry): string[];