@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,221 @@
1
+ /** `stackledger build <folder> --out <dir> [--date YYYY-MM-DD]` (build-command spec). Called by
2
+ * src/cli.ts; run node dist/cli.js build examples/northwind --out ./public.
3
+ *
4
+ * Order, so that a refusal never creates or changes anything: parse the options, load the catalogue
5
+ * folder, check the output folder (after resolving symbolic links: not the catalogue, not inside it,
6
+ * not containing it; no staging folder holding `old/` and no `.stackledger-tmp-*` link or file
7
+ * (staging.ts); then empty or marked by an earlier build with a regular marker file holding the
8
+ * marker text, and no published entry that is a symbolic link). Only then is the output folder
9
+ * created, stale staging folders removed, a new staging folder made, both sites prepared in it
10
+ * (build.ts) and published by renames (publish.ts).
11
+ *
12
+ * The output folder's real path, device and inode are recorded when it is checked (or created) and
13
+ * compared again immediately before every change (paths.ts); a mismatch stops with exit 1.
14
+ *
15
+ * Exit codes: usage and folder errors throw a plain Error (exit 2, with usage, from src/cli.ts). A
16
+ * failure while building or publishing throws InternalError (exit 1) after the output folder is
17
+ * restored and the staging folder removed. A failed undo, a staging folder left with `old/` and a
18
+ * moved output folder are exit 1 too, and the staging folder is kept. After the commit, a failure to
19
+ * remove the staging folder is a warning, with exit 0. stderr holds the build report only.
20
+ *
21
+ * Every filesystem call on the output folder goes through `ops` (fs-ops.ts). src/cli.ts passes none,
22
+ * so the CLI uses node:fs; tests pass a wrapper that fails or swaps the folder at a chosen call.
23
+ */
24
+ import { randomBytes } from 'node:crypto';
25
+ import { basename, dirname, join, resolve } from 'node:path';
26
+ import { parseArgs } from 'node:util';
27
+ import { isDate, localDate } from '../graph.js';
28
+ import { LAST_WINDOW_DATE, windowFits } from '../reports.js';
29
+ import { REPORT_DAYS } from './data.js';
30
+ import { loadFolder } from '../source.js';
31
+ import { internal } from '../errors.js';
32
+ import { problemCounts } from '../map/command.js';
33
+ import { prepareBuild, packageVersion } from './build.js';
34
+ import { validateLoaded } from '../validate.js';
35
+ import { refuseSkillsOutput, skillsInUse, skillsStops } from './skills-build.js';
36
+ import { NODE_FS } from './fs-ops.js';
37
+ import { MARKER, MARKER_NAME } from './policy.js';
38
+ import { assertSameFolder, FolderChanged, folderIdentity, lstatOrUndefined, within } from './paths.js';
39
+ import { ENTRIES, publish, UndoFailed } from './publish.js';
40
+ import { OLD_NAME, removeStaging, STAGING_PREFIX, staleStaging } from './staging.js';
41
+ const PROXY_REMINDER = 'Serve both folders only behind an identity-aware proxy: full/ for the people allowed to see costs, staff/ for everyone else.';
42
+ const PERSONAL_PROXY_REMINDER = 'Serve full/ only behind an identity-aware proxy, for the people allowed to see costs.';
43
+ /** The real path of `path`, or of its nearest existing ancestor joined with the missing rest. */
44
+ function realTarget(path, ops) {
45
+ const missing = [];
46
+ let current = path;
47
+ for (;;) {
48
+ try {
49
+ return join(ops.realpath(current), ...missing.reverse());
50
+ }
51
+ catch (error) {
52
+ if (error.code !== 'ENOENT')
53
+ throw new Error(`Output folder cannot be read: ${current}`);
54
+ // A dangling symbolic link exists but cannot be resolved: refuse it rather than write through it.
55
+ if (lstatOrUndefined(current, ops))
56
+ throw new Error('Output folder is a broken symbolic link');
57
+ const parent = dirname(current);
58
+ if (parent === current)
59
+ throw new Error('Output folder cannot be resolved');
60
+ missing.push(basename(current));
61
+ current = parent;
62
+ }
63
+ }
64
+ }
65
+ /** The output folder's own status and entries, or undefined when it does not exist yet. */
66
+ function readOutput(target, ops) {
67
+ try {
68
+ const stats = ops.lstat(target);
69
+ if (!stats.isDirectory())
70
+ throw new Error('Output path is not a folder');
71
+ return { stats, entries: ops.readdir(target) };
72
+ }
73
+ catch (error) {
74
+ const code = error.code;
75
+ if (code === 'ENOENT')
76
+ return undefined;
77
+ if (code === undefined)
78
+ throw error;
79
+ throw new Error('Output folder cannot be read');
80
+ }
81
+ }
82
+ /** Check the output folder; throws a usage error (exit 2) or InternalError (exit 1) to refuse it. */
83
+ function checkOutput(out, catalogue, ops) {
84
+ const target = realTarget(out, ops);
85
+ if (within(target, catalogue))
86
+ throw new Error('Output folder must not be the catalogue folder or inside it');
87
+ if (within(catalogue, target))
88
+ throw new Error('Output folder must not contain the catalogue folder');
89
+ const existing = readOutput(target, ops);
90
+ if (!existing)
91
+ return { target, identity: undefined, stale: [] };
92
+ // Staging folders first: one left with old/ needs the manual restore, whatever else is there.
93
+ const stale = staleStaging(target, existing.entries, ops);
94
+ const others = existing.entries.filter(name => !name.startsWith(STAGING_PREFIX));
95
+ if (others.length && !isMarker(join(target, MARKER_NAME), ops)) {
96
+ throw new Error(`Output folder is not empty and was not written by stackledger build (no ${MARKER_NAME} file with the marker text)`);
97
+ }
98
+ // A rename or removal through a link would act outside the output folder: refuse it up front.
99
+ const linked = ENTRIES.find(entry => lstatOrUndefined(join(target, entry.name), ops)?.isSymbolicLink());
100
+ if (linked)
101
+ throw new Error(`Output folder entry ${linked.name} is a symbolic link; stackledger build does not replace links`);
102
+ const identity = { path: target, real: target, dev: existing.stats.dev, ino: existing.stats.ino };
103
+ return { target, identity, stale };
104
+ }
105
+ /** True when `path` is a regular file (not a link, not a folder) holding exactly the marker text. */
106
+ function isMarker(path, ops) {
107
+ const stats = lstatOrUndefined(path, ops);
108
+ if (!stats?.isFile() || stats.size !== Buffer.byteLength(MARKER))
109
+ return false;
110
+ return ops.readFile(path) === MARKER;
111
+ }
112
+ /** Create the missing output folder and record its identity. */
113
+ function createOutput(target, ops) {
114
+ ops.mkdir(target, { recursive: true });
115
+ return folderIdentity(target, ops);
116
+ }
117
+ /** The error to throw for a failure before the commit. The staging folder is removed, unless the
118
+ * output folder moved (nothing may change) or the undo failed (it holds the previous entries). */
119
+ function failedBuild(error, staging, identity, ops) {
120
+ if (error instanceof FolderChanged || error instanceof UndoFailed)
121
+ return error;
122
+ const reason = error instanceof Error ? error.message : String(error);
123
+ assertSameFolder(identity, ops);
124
+ try {
125
+ ops.rm(staging);
126
+ }
127
+ catch (cleanupError) {
128
+ return internal('build', `${reason}; the staging folder ${staging} could not be removed (${cleanupError.message})`);
129
+ }
130
+ return internal('build', error);
131
+ }
132
+ /** After the commit: remove `old/` (the replaced build), then the staging folder. A failure is a
133
+ * warning line; a moved output folder still throws (exit 1, nothing removed). */
134
+ function cleanUp(staging, identity, ops) {
135
+ const steps = [
136
+ [join(staging, OLD_NAME), `it holds only the entries this build replaced: remove it by hand (until then stackledger build refuses this output folder)`],
137
+ [staging, 'the next build removes it'],
138
+ ];
139
+ for (const [path, advice] of steps) {
140
+ assertSameFolder(identity, ops);
141
+ try {
142
+ ops.rm(path);
143
+ }
144
+ catch (error) {
145
+ return [`Warning: the build is published, but ${staging} could not be removed (${error.message}); ${advice}`];
146
+ }
147
+ }
148
+ return [];
149
+ }
150
+ const plural = (count, word) => `${count} ${count === 1 ? word : `${word}s`}`;
151
+ function report(prepared, out, warnings) {
152
+ const lines = [
153
+ ...problemCounts('build', prepared.catalogue),
154
+ ...prepared.notes,
155
+ ...warnings,
156
+ ...(prepared.staff ? [`Built the staff site in ${join(out, 'staff')} (${plural(prepared.staff.pages, 'page')})`] : []),
157
+ `Built the full site in ${join(out, 'full')} (${plural(prepared.full.pages, 'page')})`,
158
+ prepared.staff ? PROXY_REMINDER : PERSONAL_PROXY_REMINDER,
159
+ ];
160
+ return lines.join('\n') + '\n';
161
+ }
162
+ /** Parse the command's arguments; throws a usage error for anything the spec refuses. */
163
+ function parseBuildArgs(args) {
164
+ const { values, positionals } = parseArgs({
165
+ args,
166
+ strict: true,
167
+ allowPositionals: true,
168
+ options: { out: { type: 'string' }, date: { type: 'string' }, skills: { type: 'string', multiple: true } },
169
+ });
170
+ const [, folder, ...extra] = positionals;
171
+ if (!folder)
172
+ throw new Error('A catalogue folder is required');
173
+ if (extra.length)
174
+ throw new Error('Only one folder is accepted');
175
+ if (values.out === undefined || values.out === '')
176
+ throw new Error('--out is required');
177
+ const skills = values.skills ?? [];
178
+ if (skills.some(value => value === ''))
179
+ throw new Error('--skills needs a folder');
180
+ const date = values.date ?? localDate();
181
+ if (!isDate(date))
182
+ throw new Error('Map date must be a real YYYY-MM-DD date');
183
+ if (!windowFits(date, REPORT_DAYS))
184
+ throw new Error(`--date plus the ${REPORT_DAYS}-day report window must be no later than ${LAST_WINDOW_DATE}`);
185
+ return { folder, out: values.out, date, skills };
186
+ }
187
+ export async function buildCommand(args, ops = NODE_FS) {
188
+ const options = parseBuildArgs(args);
189
+ // Usage checks first: loading the folder throws a usage error for a missing or unreadable folder.
190
+ const loaded = await loadFolder(resolve(options.folder));
191
+ const catalogue = ops.realpath(resolve(options.folder));
192
+ const out = resolve(options.out);
193
+ // The skill set (exit 2 for a folder that cannot be read), then the output folder against both inputs.
194
+ const validated = validateLoaded(loaded);
195
+ // Configured folders are relative to the catalogue folder as given, links in it not followed first.
196
+ const skills = await skillsInUse(options.skills, loaded, validated, resolve(options.folder), ops);
197
+ // The skill-set refusals (exit 2) come first: checkOutput can stop with exit 1 on a staging folder left with old/.
198
+ refuseSkillsOutput(realTarget(out, ops), skills, ops);
199
+ const checked = checkOutput(out, catalogue, ops);
200
+ const { target } = checked;
201
+ // Exit-1 stops come after every exit-2 check and before anything is created.
202
+ skillsStops(skills);
203
+ // From here on, every change first checks that the output folder is still the validated one.
204
+ const identity = checked.identity ?? createOutput(target, ops);
205
+ removeStaging(checked.stale, identity, ops);
206
+ const staging = join(target, `${STAGING_PREFIX}${randomBytes(8).toString('hex')}`);
207
+ assertSameFolder(identity, ops);
208
+ ops.mkdir(staging);
209
+ let prepared;
210
+ try {
211
+ prepared = await prepareBuild(loaded, staging, options.date, packageVersion(), skills.set);
212
+ publish(target, staging, identity, ops);
213
+ }
214
+ catch (error) {
215
+ throw failedBuild(error, staging, identity, ops);
216
+ }
217
+ // Committed: the new sites are in place. Removing the replaced entries is best effort.
218
+ const warnings = cleanUp(staging, identity, ops);
219
+ process.stderr.write(report(prepared, out, [...skills.notes, ...warnings]));
220
+ }
221
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/site/command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aA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MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,205 @@
1
+ import { type MapGeometry } from '../map/layout.js';
2
+ import { type ViewName } from '../views.js';
3
+ import type { Catalogue } from '../validate.js';
4
+ import { type SiteColorName } from '../schema.js';
5
+ import type { SkillsData } from './skills-data.js';
6
+ export declare const DEFAULT_TITLE = "stackledger";
7
+ /** The home banner's text when `spec.site.home.text` is not set (catalogue-site, Home page). */
8
+ export declare const DEFAULT_HOME_TEXT = "Your software and skills, mapped.";
9
+ /** The renewal window of the site's Reports page and calendar (licence-reports, Source and date). */
10
+ export declare const REPORT_DAYS = 90;
11
+ export declare const CALENDAR_FILE = "renewals.ics";
12
+ export interface Link {
13
+ ref: string;
14
+ title: string;
15
+ href?: string;
16
+ }
17
+ export interface Field {
18
+ label: string;
19
+ value: string;
20
+ }
21
+ export interface Themed {
22
+ light: string;
23
+ dark: string;
24
+ }
25
+ export interface Impact {
26
+ dependants: (Link & {
27
+ depth: number;
28
+ })[];
29
+ lines: Link[];
30
+ truncated: boolean;
31
+ }
32
+ export interface LineSummary {
33
+ ref: string;
34
+ slug: string;
35
+ title: string;
36
+ badge: string;
37
+ color: string;
38
+ badgeSvg: string;
39
+ stops: number;
40
+ href: string;
41
+ }
42
+ export interface SoftwareRow {
43
+ ref: string;
44
+ href: string;
45
+ title: string;
46
+ kind: 'component' | 'licence';
47
+ type: string;
48
+ state: string;
49
+ owner: string;
50
+ zone: string;
51
+ }
52
+ export interface ComponentPage {
53
+ ref: string;
54
+ slug: string;
55
+ name: string;
56
+ title: string;
57
+ description?: string;
58
+ type: string;
59
+ lifecycle: string;
60
+ owner: string;
61
+ zone?: string;
62
+ tags: string[];
63
+ licences: (Link & {
64
+ fields: Field[];
65
+ })[];
66
+ journeys: Link[];
67
+ unresolved: string[];
68
+ impact: Impact;
69
+ neighbourhood: Themed & {
70
+ dependencies: Link[];
71
+ dependants: Link[];
72
+ };
73
+ }
74
+ export interface LicencePage {
75
+ ref: string;
76
+ slug: string;
77
+ name: string;
78
+ title: string;
79
+ owner: string;
80
+ fields: Field[];
81
+ usedBy: Link[];
82
+ impact: Impact;
83
+ }
84
+ export interface JourneyPage extends LineSummary {
85
+ strip: Themed;
86
+ stopList: (Link & {
87
+ lines: Link[];
88
+ })[];
89
+ }
90
+ /** Report amounts as the page shows them: two decimals, or `—` when no complete licence adds to it. */
91
+ export interface MoneyRow {
92
+ currency: string;
93
+ monthly: string;
94
+ yearly: string;
95
+ incomplete: number;
96
+ }
97
+ export interface OneOffMoneyRow {
98
+ currency: string;
99
+ total: string;
100
+ incomplete: number;
101
+ }
102
+ export interface ReportRenewal extends Link {
103
+ date: string;
104
+ vendor: string;
105
+ cycle: string;
106
+ cost: string;
107
+ }
108
+ export interface ReportGrouping {
109
+ key: 'owner' | 'payer' | 'zone';
110
+ title: string;
111
+ column: string;
112
+ groups: {
113
+ label: string;
114
+ synthetic: boolean;
115
+ rows: MoneyRow[];
116
+ }[];
117
+ }
118
+ export interface ReportPage {
119
+ date: string;
120
+ to: string;
121
+ days: number;
122
+ empty: boolean;
123
+ calendar: string;
124
+ renewals: ReportRenewal[];
125
+ overdue: ReportRenewal[];
126
+ unknownDates: Link[];
127
+ recurring: MoneyRow[];
128
+ groupings: ReportGrouping[];
129
+ oneOff: {
130
+ items: (Link & {
131
+ cost: string;
132
+ renewsOn: string;
133
+ })[];
134
+ totals: OneOffMoneyRow[];
135
+ };
136
+ planned: {
137
+ items: (Link & {
138
+ cycle: string;
139
+ cost: string;
140
+ monthly: string;
141
+ yearly: string;
142
+ })[];
143
+ recurring: MoneyRow[];
144
+ oneOff: OneOffMoneyRow[];
145
+ };
146
+ incomplete: (Link & {
147
+ status: string;
148
+ unknown: string;
149
+ })[];
150
+ }
151
+ export interface HomeLink {
152
+ title: string;
153
+ url: string;
154
+ description?: string;
155
+ }
156
+ interface SiteBase {
157
+ version: string;
158
+ title: string;
159
+ colors: Partial<Record<SiteColorName, string>>;
160
+ /** The home page's banner text and links (catalogue-site, Home page and Home links). */
161
+ home: {
162
+ text: string;
163
+ links: HomeLink[];
164
+ };
165
+ map: Themed & {
166
+ lines: LineSummary[];
167
+ zones: {
168
+ name: string;
169
+ title: string;
170
+ }[];
171
+ symbols: (Themed & {
172
+ label: string;
173
+ })[];
174
+ };
175
+ rows: SoftwareRow[];
176
+ filters: {
177
+ kind: string[];
178
+ zone: string[];
179
+ state: string[];
180
+ owner: string[];
181
+ };
182
+ components: ComponentPage[];
183
+ licences: LicencePage[];
184
+ journeys: JourneyPage[];
185
+ /** The Skills section (src/site/skills-data.ts), the same object in every view; absent without a skill set. */
186
+ skills?: SkillsData;
187
+ }
188
+ export interface StaffSiteData extends SiteBase {
189
+ view: 'staff';
190
+ }
191
+ export interface FullSiteData extends SiteBase {
192
+ view: 'full';
193
+ report: ReportPage;
194
+ }
195
+ export type SiteData = StaffSiteData | FullSiteData;
196
+ /** The site title, as the header shows it; also the calendar name of `stackledger report --format ics`. */
197
+ export declare function siteTitle(catalogue: Catalogue): string;
198
+ /** SiteData of one view, plus the full map geometry for the build report (suggestions, unrouted
199
+ * hops) and, for the full view only, the text of renewals.ics. */
200
+ export declare function buildSiteData(catalogue: Catalogue, view: ViewName, version: string, date?: string, owners?: ReadonlyMap<string, string>): {
201
+ data: SiteData;
202
+ geometry: MapGeometry;
203
+ calendar?: string;
204
+ };
205
+ export {};