ssqch 0.7.1 → 0.9.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 (155) hide show
  1. package/README.md +8 -4
  2. package/bin/ssqch.js +14 -48
  3. package/bundled/README.md +1314 -0
  4. package/bundled/completions/bash +840 -0
  5. package/bundled/completions/elvish +286 -0
  6. package/bundled/completions/fish +182 -0
  7. package/bundled/completions/powershell +318 -0
  8. package/bundled/completions/zsh +510 -0
  9. package/bundled/ssqch.d.ts +540 -0
  10. package/bundled/starter/engines/index.edge +11 -0
  11. package/bundled/starter/engines/index.ejs +11 -0
  12. package/bundled/starter/engines/index.hbs +11 -0
  13. package/bundled/starter/engines/index.liquid +11 -0
  14. package/bundled/starter/engines/layout.edge +35 -0
  15. package/bundled/starter/engines/layout.ejs +35 -0
  16. package/bundled/starter/engines/layout.hbs +35 -0
  17. package/bundled/starter/engines/layout.liquid +35 -0
  18. package/bundled/starter/gitignore +3 -0
  19. package/bundled/starter/jsconfig.json +11 -0
  20. package/bundled/starter/src/404.md +8 -0
  21. package/bundled/starter/src/_blueprints/posts.md +5 -0
  22. package/bundled/starter/src/_data/site.json +4 -0
  23. package/bundled/starter/src/_includes/layout.jinja +35 -0
  24. package/bundled/starter/src/index.jinja +11 -0
  25. package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
  26. package/bundled/starter/src/posts/posts.json +4 -0
  27. package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
  28. package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
  29. package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
  30. package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
  31. package/bundled/starter/ssqch.config.js +29 -0
  32. package/bundled/starter-docs/engines/edge/base.edge +41 -0
  33. package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
  34. package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
  35. package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
  36. package/bundled/starter-docs/engines/edge/doc.edge +59 -0
  37. package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
  38. package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
  39. package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
  40. package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
  41. package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
  42. package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
  43. package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
  44. package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
  45. package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
  46. package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
  47. package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
  48. package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
  49. package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
  50. package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
  51. package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
  52. package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
  55. package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
  56. package/bundled/starter-docs/gitignore +4 -0
  57. package/bundled/starter-docs/src/404.md +12 -0
  58. package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
  59. package/bundled/starter-docs/src/_data/nav.yml +10 -0
  60. package/bundled/starter-docs/src/_data/site.json +5 -0
  61. package/bundled/starter-docs/src/_includes/base.jinja +41 -0
  62. package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
  63. package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
  64. package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
  65. package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
  66. package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
  67. package/bundled/starter-docs/src/assets/docs.css +257 -0
  68. package/bundled/starter-docs/src/assets/docs.js +67 -0
  69. package/bundled/starter-docs/src/docs/docs.json +1 -0
  70. package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
  71. package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
  72. package/bundled/starter-docs/src/docs/index.md +29 -0
  73. package/bundled/starter-docs/src/docs/install.md +42 -0
  74. package/bundled/starter-docs/src/index.md +13 -0
  75. package/bundled/starter-docs/ssqch.config.js +40 -0
  76. package/bundled/trailheads/from-component-frameworks.md +116 -0
  77. package/bundled/trailheads/from-docusaurus.md +55 -0
  78. package/bundled/trailheads/from-eleventy.md +140 -0
  79. package/bundled/trailheads/from-hexo.md +92 -0
  80. package/bundled/trailheads/from-jekyll.md +79 -0
  81. package/bundled/trailheads/from-mkdocs.md +45 -0
  82. package/bundled/trailheads/from-zola.md +71 -0
  83. package/lib/assets.js +235 -3
  84. package/lib/chunk-3A647I3N.js +384 -0
  85. package/lib/chunk-3GYLOC6Y.js +1017 -0
  86. package/lib/chunk-3K3ANWZ2.js +118 -0
  87. package/lib/chunk-3NYSSA2C.js +22 -0
  88. package/lib/chunk-47P4YREZ.js +1287 -0
  89. package/lib/chunk-4Q6WMTER.js +32 -0
  90. package/lib/chunk-76NTVE34.js +338 -0
  91. package/lib/chunk-7PWCYHTJ.js +1350 -0
  92. package/lib/chunk-7RDRZHJD.js +217 -0
  93. package/lib/chunk-7SD7K567.js +57 -0
  94. package/lib/chunk-7XLK2GEG.js +54 -0
  95. package/lib/chunk-AD3HAW3W.js +10 -0
  96. package/lib/chunk-BEGC7YP6.js +502 -0
  97. package/lib/chunk-CMUWRPSQ.js +113 -0
  98. package/lib/chunk-CZ4XQC56.js +999 -0
  99. package/lib/chunk-D2XE2GTY.js +71 -0
  100. package/lib/chunk-DDV6JEC2.js +46 -0
  101. package/lib/chunk-DELWRJAO.js +37409 -0
  102. package/lib/chunk-DELWRJAO.js.LEGAL.txt +27 -0
  103. package/lib/chunk-F65YUXZ7.js +334 -0
  104. package/lib/chunk-FVZ5JBRI.js +115 -0
  105. package/lib/chunk-GRWMGC7D.js +4435 -0
  106. package/lib/chunk-GRWMGC7D.js.LEGAL.txt +41 -0
  107. package/lib/chunk-GUKSZ2XM.js +207 -0
  108. package/lib/chunk-HPXAZ2HU.js +251 -0
  109. package/lib/chunk-HXCLCXRT.js +20 -0
  110. package/lib/chunk-I3PS26CI.js +48 -0
  111. package/lib/chunk-IAFM5ITE.js +11 -0
  112. package/lib/chunk-II5DEH3Q.js +209 -0
  113. package/lib/chunk-IJWHOFRP.js +44 -0
  114. package/lib/chunk-LPHNACE4.js +29 -0
  115. package/lib/chunk-MI6EJWA2.js +175 -0
  116. package/lib/chunk-NCWFYT74.js +1541 -0
  117. package/lib/chunk-NKXEPHRZ.js +136 -0
  118. package/lib/chunk-NNUKIGOO.js +160 -0
  119. package/lib/chunk-R7K3D5W5.js +3957 -0
  120. package/lib/chunk-RNJFPFXE.js +29 -0
  121. package/lib/chunk-SF4I6Z7S.js +25 -0
  122. package/lib/chunk-SURPOAW7.js +44 -0
  123. package/lib/chunk-SXMJ52IK.js +572 -0
  124. package/lib/chunk-TICWN55Z.js +20 -0
  125. package/lib/chunk-TVU3OPPK.js +146 -0
  126. package/lib/chunk-UU43WIZG.js +29 -0
  127. package/lib/chunk-VJWQSYEG.js +119 -0
  128. package/lib/chunk-XMXBHXZR.js +75 -0
  129. package/lib/chunk-YTHQBMDJ.js +211 -0
  130. package/lib/cli.js +547 -0
  131. package/lib/elements.js +180 -3
  132. package/lib/image.js +27 -3
  133. package/lib/links.js +464 -3
  134. package/lib/minify.js +69 -3
  135. package/lib/redirects.js +152 -3
  136. package/lib/rss.js +139 -3
  137. package/lib/sass.js +256 -3
  138. package/lib/sitemap.js +113 -3
  139. package/lib/ssqch.js +28 -0
  140. package/package.json +83 -80
  141. package/src/serve/live.js +174 -0
  142. package/src/serve/not-found.html +31 -0
  143. package/types/globals.d.ts +3 -2
  144. package/types/image.d.ts +7 -3
  145. package/types/index.d.ts +28 -9
  146. package/types/links.d.ts +1 -1
  147. package/types/minify.d.ts +1 -1
  148. package/types/rss.d.ts +1 -1
  149. package/types/sass.d.ts +1 -1
  150. package/types/sitemap.d.ts +2 -0
  151. package/wasm/markdown.wasm +0 -0
  152. package/wasm/minify.wasm +0 -0
  153. package/wasm/sass.wasm +0 -0
  154. package/lib/index.js +0 -3
  155. package/platforms.json +0 -6
@@ -0,0 +1,146 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ Options
5
+ } from "./chunk-7SD7K567.js";
6
+ import {
7
+ BUILTINS,
8
+ addImagePlugin,
9
+ currentProcessor,
10
+ defaultImageOptions,
11
+ imageOptionsFor,
12
+ meant,
13
+ parseFormat
14
+ } from "./chunk-R7K3D5W5.js";
15
+ import {
16
+ bail
17
+ } from "./chunk-GRWMGC7D.js";
18
+
19
+ // src/modules/image.ts
20
+ import fs from "node:fs";
21
+ import path from "node:path";
22
+ var FORMATS = ["avif", "webp", "jpeg", "jpg", "png", "gif", "svg", "auto"];
23
+ var IMAGE_OPTIONS = ["widths", "formats", "name"];
24
+ var PLUGIN_OPTIONS = ["formats", "widths", "defaultAttributes", "outputDir", "urlPath", "webpQuality", "avifQuality", "avifEffort", "jpegQuality", "minimumThreshold", "prune", "hashCache", "linkedImages", "cacheDir"];
25
+ function imagePlugin(options = {}) {
26
+ return { name: "ssqch/image", builtin: "ssqch/image", options };
27
+ }
28
+ function fail(message) {
29
+ throw new TypeError(`image(): ${message}`);
30
+ }
31
+ function checkFormats(formats) {
32
+ if (!Array.isArray(formats)) fail("formats must be an array");
33
+ for (const f of formats) {
34
+ if (!FORMATS.includes(f)) fail(`unknown format "${f}"${meant(f, FORMATS)} (use ${FORMATS.join(", ")})`);
35
+ }
36
+ return formats.map((f) => parseFormat(f));
37
+ }
38
+ function checkWidths(widths) {
39
+ if (!Array.isArray(widths)) fail("widths must be an array");
40
+ return widths.map((w) => {
41
+ if (w === "auto") return 0;
42
+ if (!(Number.isInteger(w) && w >= 0)) fail(`widths must be whole numbers or "auto", got ${JSON.stringify(w)}`);
43
+ return Math.min(w, 4294967295);
44
+ });
45
+ }
46
+ async function image(src, options = {}) {
47
+ if (typeof src !== "string") fail("the source must be a file path");
48
+ if (/^https?:\/\//.test(src)) fail(`remote images aren't supported (${src})`);
49
+ for (const key of Object.keys(options ?? {})) {
50
+ if (!IMAGE_OPTIONS.includes(key)) fail(`unknown option "${key}"${meant(key, IMAGE_OPTIONS)} (options: ${IMAGE_OPTIONS.join(", ")}; encoder settings go on imagePlugin())`);
51
+ }
52
+ const { formats = ["webp", "jpeg"], widths = ["auto"], name } = options ?? {};
53
+ if (!(name === void 0 || typeof name === "string" && name.trim())) fail('name must be a URL path without the width and extension, like "/assets/sponsors/acme"');
54
+ const file = path.resolve(src);
55
+ const checkedWidths = checkWidths(widths);
56
+ const checkedFormats = checkFormats(formats);
57
+ const p = currentProcessor();
58
+ if (!(fs.statSync(file, { throwIfNoEntry: false })?.isFile() ?? false)) bail(`image(): file not found: ${file}`);
59
+ let meta;
60
+ try {
61
+ meta = p.generateNamed(file, checkedWidths, checkedFormats, name);
62
+ } catch (e) {
63
+ bail(`image(): ${e.message}`);
64
+ }
65
+ const failed = await meta.ready;
66
+ if (failed) bail(`image(): ${failed.message}`);
67
+ const root = p.root();
68
+ const out = {};
69
+ for (const [format, entries] of meta.formats) {
70
+ out[format] = entries.map((e) => ({
71
+ format,
72
+ width: e.width,
73
+ height: e.height,
74
+ url: e.url,
75
+ sourceType: e.sourceType,
76
+ srcset: e.srcset,
77
+ filename: path.basename(e.path),
78
+ outputPath: e.path.startsWith(root + path.sep) ? e.path.slice(root.length + 1) : e.path,
79
+ size: fs.statSync(e.path, { throwIfNoEntry: false })?.size ?? 0
80
+ }));
81
+ }
82
+ if (meta.auto !== void 0 && out[meta.auto]) out.auto = out[meta.auto];
83
+ return out;
84
+ }
85
+ function imageUrl(src, options) {
86
+ if (typeof src !== "string") throw new TypeError('imageUrl(): the source must be a site path like "/content/logo.png"');
87
+ const [width, format] = imageOptionsFor("imageUrl()", options, 0);
88
+ return currentProcessor().imageUrl(src, width, format);
89
+ }
90
+ function feedImages(html, base, options) {
91
+ const [width, format] = imageOptionsFor("feedHtml()", options, 1200);
92
+ return currentProcessor().feedImages(html, base, width, format);
93
+ }
94
+ BUILTINS.set("ssqch/image", (config, given) => {
95
+ if (typeof given === "object" && given !== null && given.avifSpeed !== void 0) {
96
+ bail("avifSpeed is 0.7's option: ssqch 0.8 has avifEffort, sharp's AVIF effort from 0 (fastest) to 9 (smallest files). 0.7's speed 8 is effort 2 (the default) and speed 4 is effort 3");
97
+ }
98
+ const o = new Options(given, PLUGIN_OPTIONS);
99
+ const opts = defaultImageOptions();
100
+ const formats = o.list("formats");
101
+ if (formats !== void 0) {
102
+ opts.formats = formats.map((f) => parseFormat(f) ?? bail(`unknown image format "${f}" (use avif, webp, jpeg, png, gif, svg or auto)`));
103
+ if (!opts.formats.length) bail("formats can't be empty");
104
+ }
105
+ const widths = o.get("widths");
106
+ if (widths !== void 0) {
107
+ if (!Array.isArray(widths)) bail("widths must be an array of numbers");
108
+ opts.widths = widths.map((w) => Number.isInteger(w) && w >= 0 ? Math.min(w, 4294967295) : bail(`widths must be positive whole numbers, got ${JSON.stringify(w) ?? "null"}`));
109
+ }
110
+ const attributes = o.get("defaultAttributes");
111
+ if (attributes !== void 0) {
112
+ if (typeof attributes !== "object" || Array.isArray(attributes)) bail("defaultAttributes must be an object");
113
+ opts.defaultAttributes = Object.entries(attributes).map(([k, v]) => [k, typeof v === "string" ? v : JSON.stringify(v) ?? "null"]);
114
+ }
115
+ const outputDir = o.string("outputDir");
116
+ if (outputDir !== void 0) opts.outputSubdir = outputDir;
117
+ const urlPath = o.string("urlPath");
118
+ if (urlPath !== void 0) opts.urlPath = urlPath.endsWith("/") ? urlPath : `${urlPath}/`;
119
+ const whole = (key, low, high, what) => {
120
+ const n = o.number(key);
121
+ if (n === void 0) return;
122
+ if (!(Number.isInteger(n) && n >= low && n <= high)) bail(`${key} must be a whole number from ${low} to ${high} (${what}), got ${n}`);
123
+ opts[key] = n;
124
+ };
125
+ whole("webpQuality", 1, 100, "sharp's quality");
126
+ whole("avifQuality", 1, 100, "sharp's quality");
127
+ whole("jpegQuality", 1, 100, "sharp's quality");
128
+ whole("avifEffort", 0, 9, "0 is fastest, 9 makes the smallest files");
129
+ const threshold = o.number("minimumThreshold");
130
+ if (threshold !== void 0) opts.minimumThreshold = threshold;
131
+ opts.prune = o.bool("prune") ?? opts.prune;
132
+ opts.hashCache = o.bool("hashCache") ?? opts.hashCache;
133
+ opts.linkedImages = o.bool("linkedImages") ?? opts.linkedImages;
134
+ const cacheDir = o.get("cacheDir");
135
+ if (cacheDir === false) opts.cacheDir = null;
136
+ else if (typeof cacheDir === "string" && cacheDir.trim() !== "") opts.cacheDir = cacheDir;
137
+ else if (cacheDir !== void 0) bail('cacheDir must be a folder from the project root, like ".cache/ssqch/img", or false');
138
+ addImagePlugin(config, opts);
139
+ });
140
+
141
+ export {
142
+ imagePlugin,
143
+ image,
144
+ imageUrl,
145
+ feedImages
146
+ };
@@ -0,0 +1,29 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+
4
+ // src/voice.ts
5
+ var SQUATCH_WATCH = "Squatch Watch is on.";
6
+ var FRESH_TRACKS = "Fresh tracks in";
7
+ var FIRST_SITING = "First confirmed siting.";
8
+ var RECOVERED = "Build recovered. Back on the trail.";
9
+ var FIELD_NOTES = "Field notes started.";
10
+ var LEFT_NO_TRACE = "left no trace";
11
+ var CAMPSITE_DISTURBED = "Campsite disturbed:";
12
+ var PASSED_THIS_TREE = "we've passed this tree before";
13
+ var TRAIL_GOES_COLD = "the trail goes cold";
14
+ var SOMETHING_LARGE = "something large walked through the build";
15
+ var ISSUES_URL = "https://github.com/reverentgeek/sitesquatch/issues";
16
+
17
+ export {
18
+ SQUATCH_WATCH,
19
+ FRESH_TRACKS,
20
+ FIRST_SITING,
21
+ RECOVERED,
22
+ FIELD_NOTES,
23
+ LEFT_NO_TRACE,
24
+ CAMPSITE_DISTURBED,
25
+ PASSED_THIS_TREE,
26
+ TRAIL_GOES_COLD,
27
+ SOMETHING_LARGE,
28
+ ISSUES_URL
29
+ };
@@ -0,0 +1,119 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+
4
+ // src/paths.ts
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ var slashes = (p) => path.sep === "/" ? p : p.split(path.sep).join("/");
8
+ function displayPath(root, file) {
9
+ if (file === root) return "./";
10
+ return file.startsWith(root + path.sep) ? `./${slashes(file.slice(root.length + 1))}` : file;
11
+ }
12
+ var shown = (root, file) => displayPath(root, file).replace(/^\.\//, "");
13
+ var relative = (dir, file) => slashes(path.relative(dir, file));
14
+ var joinAsGiven = (base, rel) => path.isAbsolute(rel) || base === "" ? rel : /[\\/]$/.test(base) ? base + rel : base + path.sep + rel;
15
+ function parentAsGiven(p) {
16
+ const separators = path.sep === "/" ? "/" : "\\/";
17
+ let end = p.length;
18
+ while (end > 1 && separators.includes(p[end - 1])) end--;
19
+ let at = end - 1;
20
+ while (at >= 0 && !separators.includes(p[at])) at--;
21
+ if (at < 0) return "";
22
+ let parent = at;
23
+ while (parent > 0 && separators.includes(p[parent - 1])) parent--;
24
+ return parent === 0 ? p.slice(0, 1) : p.slice(0, parent);
25
+ }
26
+ var realPath = (p) => {
27
+ try {
28
+ return fs.realpathSync.native(p);
29
+ } catch {
30
+ return p;
31
+ }
32
+ };
33
+ var isFile = (p) => fs.statSync(p, { throwIfNoEntry: false })?.isFile() ?? false;
34
+ var isDir = (p) => fs.statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false;
35
+ var isInside = (dir, file) => file === dir || file.startsWith(dir.endsWith(path.sep) ? dir : dir + path.sep);
36
+ function compareText(a, b) {
37
+ const n = Math.min(a.length, b.length);
38
+ for (let i = 0; i < n; i++) {
39
+ let x = a.charCodeAt(i), y = b.charCodeAt(i);
40
+ if (x === y) continue;
41
+ if (x >= 55296 && y >= 55296) {
42
+ x = x >= 57344 ? x - 2048 : x + 8192;
43
+ y = y >= 57344 ? y - 2048 : y + 8192;
44
+ }
45
+ return x - y;
46
+ }
47
+ return a.length - b.length;
48
+ }
49
+ function comparePaths(a, b) {
50
+ if (a === b) return 0;
51
+ const x = a.split(path.sep), y = b.split(path.sep);
52
+ const n = Math.min(x.length, y.length);
53
+ for (let i = 0; i < n; i++) {
54
+ if (x[i] === y[i]) continue;
55
+ return compareText(x[i], y[i]);
56
+ }
57
+ return x.length - y.length;
58
+ }
59
+ function walkFiles(dir) {
60
+ const out = [];
61
+ const walk = (d) => {
62
+ let entries;
63
+ try {
64
+ entries = fs.readdirSync(d, { withFileTypes: true });
65
+ } catch {
66
+ return;
67
+ }
68
+ for (const entry of entries) {
69
+ const p = path.join(d, entry.name);
70
+ if (entry.isDirectory()) walk(p);
71
+ else if (entry.isFile()) out.push(p);
72
+ }
73
+ };
74
+ walk(dir);
75
+ return out;
76
+ }
77
+ function readFollowing(dir, above, onError) {
78
+ const out = [];
79
+ const here = above[above.length - 1] ?? realPath(dir);
80
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
81
+ const file = path.join(dir, entry.name);
82
+ if (!entry.isSymbolicLink()) {
83
+ out.push({ name: entry.name, path: file, isDirectory: entry.isDirectory(), isFile: entry.isFile(), real: path.join(here, entry.name) });
84
+ continue;
85
+ }
86
+ const stat = fs.statSync(file, { throwIfNoEntry: false });
87
+ if (!stat) {
88
+ onError({ path: file, broken: true });
89
+ continue;
90
+ }
91
+ const real = realPath(file);
92
+ if (stat.isDirectory()) {
93
+ const at = above.indexOf(real);
94
+ if (at !== -1) {
95
+ onError({ path: file, loop: above[at] });
96
+ continue;
97
+ }
98
+ }
99
+ out.push({ name: entry.name, path: file, isDirectory: stat.isDirectory(), isFile: stat.isFile(), real });
100
+ }
101
+ return out;
102
+ }
103
+
104
+ export {
105
+ slashes,
106
+ displayPath,
107
+ shown,
108
+ relative,
109
+ joinAsGiven,
110
+ parentAsGiven,
111
+ realPath,
112
+ isFile,
113
+ isDir,
114
+ isInside,
115
+ compareText,
116
+ comparePaths,
117
+ walkFiles,
118
+ readFollowing
119
+ };
@@ -0,0 +1,75 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ OUTPUT_LIST
5
+ } from "./chunk-DELWRJAO.js";
6
+ import "./chunk-4Q6WMTER.js";
7
+ import "./chunk-3A647I3N.js";
8
+ import "./chunk-II5DEH3Q.js";
9
+ import "./chunk-R7K3D5W5.js";
10
+ import "./chunk-7XLK2GEG.js";
11
+ import {
12
+ count
13
+ } from "./chunk-NKXEPHRZ.js";
14
+ import "./chunk-AD3HAW3W.js";
15
+ import "./chunk-DDV6JEC2.js";
16
+ import "./chunk-NCWFYT74.js";
17
+ import "./chunk-FVZ5JBRI.js";
18
+ import "./chunk-HPXAZ2HU.js";
19
+ import "./chunk-UU43WIZG.js";
20
+ import "./chunk-76NTVE34.js";
21
+ import "./chunk-CMUWRPSQ.js";
22
+ import "./chunk-GRWMGC7D.js";
23
+ import "./chunk-VJWQSYEG.js";
24
+ import "./chunk-I3PS26CI.js";
25
+
26
+ // src/commands/sighting.ts
27
+ import fs from "node:fs";
28
+ import path from "node:path";
29
+ var PHOTO = `
30
+ /\\ /\\
31
+ / \\ /\\ / \\
32
+ / \\ / \\ _ / \\
33
+ / \\ / \\ (_) / \\
34
+ / \\ / \\ /| |\\ / \\
35
+ /__________\\ /________\\ '| |' /__________\\
36
+ || || / \\ ||
37
+ || || / \\ ||
38
+ `;
39
+ function lastSiting(root, now) {
40
+ const none = "No confirmed sitings here yet. `ssqch build` would be the first.";
41
+ let list;
42
+ try {
43
+ list = JSON.parse(fs.readFileSync(path.join(root, OUTPUT_LIST), "utf8")) ?? {};
44
+ } catch {
45
+ return none;
46
+ }
47
+ const output = typeof list.output === "string" ? list.output : "";
48
+ const named = (value) => Array.isArray(value) ? value.filter((f) => typeof f === "string") : [];
49
+ const pages = Array.isArray(list.pages) ? named(list.pages) : named(list.files).filter((f) => f.endsWith(".html"));
50
+ let newest;
51
+ for (const page of pages) {
52
+ try {
53
+ const time = fs.statSync(path.resolve(root, output, page)).mtimeMs;
54
+ if (newest === void 0 || time > newest) newest = time;
55
+ } catch {
56
+ }
57
+ }
58
+ if (newest === void 0) return none;
59
+ const minutes = Math.max(0, Math.floor((now - newest) / 6e4));
60
+ const unit = (n, name) => `${n} ${name}${n === 1 ? "" : "s"} ago`;
61
+ const ago = minutes === 0 ? "just now" : minutes < 60 ? unit(minutes, "minute") : minutes < 1440 ? unit(Math.floor(minutes / 60), "hour") : unit(Math.floor(minutes / 1440), "day");
62
+ return `Last confirmed siting: ${count(pages.length)} page${pages.length === 1 ? "" : "s"} in ${output}/, ${ago}.`;
63
+ }
64
+ function runSighting(root) {
65
+ process.stdout.write(`${PHOTO}
66
+ Image quality meets cryptozoological standards.
67
+
68
+ ${lastSiting(root, Date.now())}
69
+ `);
70
+ return 0;
71
+ }
72
+ export {
73
+ lastSiting,
74
+ runSighting
75
+ };
@@ -0,0 +1,211 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ red
5
+ } from "./chunk-GRWMGC7D.js";
6
+ import {
7
+ joinAsGiven,
8
+ parentAsGiven,
9
+ slashes
10
+ } from "./chunk-VJWQSYEG.js";
11
+
12
+ // src/commands/init.ts
13
+ import fs2 from "node:fs";
14
+ import path2 from "node:path";
15
+
16
+ // src/bundled.ts
17
+ import fs from "node:fs";
18
+ import path from "node:path";
19
+ import { fileURLToPath } from "node:url";
20
+ var PACKAGE = path.dirname(path.dirname(fileURLToPath(new URL("../src/bundled.ts", import.meta.url).href)));
21
+ var BUNDLED = path.join(PACKAGE, "bundled");
22
+ var FROM_REPOSITORY = [
23
+ ["README.md", "README.md"],
24
+ ["trailheads", "docs/trailheads"]
25
+ ];
26
+ function bundledPath(rel) {
27
+ const inPackage = path.join(BUNDLED, rel);
28
+ if (fs.existsSync(inPackage)) return inPackage;
29
+ for (const [prefix, original] of FROM_REPOSITORY) {
30
+ if (rel === prefix || rel.startsWith(`${prefix}/`)) return path.join(PACKAGE, "../..", original + rel.slice(prefix.length));
31
+ }
32
+ return inPackage;
33
+ }
34
+ var cache = /* @__PURE__ */ new Map();
35
+ function bundled(rel) {
36
+ let text = cache.get(rel);
37
+ if (text === void 0) cache.set(rel, text = fs.readFileSync(bundledPath(rel), "utf8"));
38
+ return text;
39
+ }
40
+ function bundledNames(rel) {
41
+ return fs.readdirSync(bundledPath(rel)).sort();
42
+ }
43
+ var types = () => bundled("ssqch.d.ts");
44
+
45
+ // src/commands/init.ts
46
+ var STARTER = [
47
+ ["ssqch.config.js", "starter/ssqch.config.js"],
48
+ ["src/_data/site.json", "starter/src/_data/site.json"],
49
+ ["src/posts/posts.json", "starter/src/posts/posts.json"],
50
+ ["src/posts/i-know-what-i-saw.md", "starter/src/posts/i-know-what-i-saw.md"],
51
+ ["src/posts/upon-further-review-a-stump.md", "starter/src/posts/upon-further-review-a-stump.md"],
52
+ ["src/posts/the-stump-has-moved.md", "starter/src/posts/the-stump-has-moved.md"],
53
+ ["src/posts/raiders-of-the-lost-path.md", "starter/src/posts/raiders-of-the-lost-path.md"],
54
+ ["src/posts/the-cache-of-the-wild.md", "starter/src/posts/the-cache-of-the-wild.md"],
55
+ ["src/404.md", "starter/src/404.md"],
56
+ ["src/_blueprints/posts.md", "starter/src/_blueprints/posts.md"],
57
+ ["ssqch.d.ts", "ssqch.d.ts"],
58
+ ["jsconfig.json", "starter/jsconfig.json"],
59
+ [".gitignore", "starter/gitignore"]
60
+ ];
61
+ var DOCS_STARTER = [
62
+ ["ssqch.config.js", "starter-docs/ssqch.config.js"],
63
+ ["src/_data/site.json", "starter-docs/src/_data/site.json"],
64
+ ["src/_data/nav.yml", "starter-docs/src/_data/nav.yml"],
65
+ ["src/assets/docs.css", "starter-docs/src/assets/docs.css"],
66
+ ["src/assets/docs.js", "starter-docs/src/assets/docs.js"],
67
+ ["src/index.md", "starter-docs/src/index.md"],
68
+ ["src/404.md", "starter-docs/src/404.md"],
69
+ ["src/docs/docs.json", "starter-docs/src/docs/docs.json"],
70
+ ["src/docs/index.md", "starter-docs/src/docs/index.md"],
71
+ ["src/docs/install.md", "starter-docs/src/docs/install.md"],
72
+ ["src/docs/guides/writing.md", "starter-docs/src/docs/guides/writing.md"],
73
+ ["src/docs/guides/deploying.md", "starter-docs/src/docs/guides/deploying.md"],
74
+ ["src/_blueprints/docs.md", "starter-docs/src/_blueprints/docs.md"],
75
+ ["ssqch.d.ts", "ssqch.d.ts"],
76
+ ["jsconfig.json", "starter/jsconfig.json"],
77
+ [".gitignore", "starter-docs/gitignore"]
78
+ ];
79
+ var STARTERS = ["site", "docs"];
80
+ var ENGINES = ["jinja", "njk", "edge", "liquid", "hbs", "ejs"];
81
+ var DEFAULT_ENGINE = "jinja";
82
+ var starterEngines = () => [...ENGINES];
83
+ var SITE_TEMPLATES = {
84
+ jinja: [["src/_includes/layout", "starter/src/_includes/layout.jinja"], ["src/index", "starter/src/index.jinja"]],
85
+ ...Object.fromEntries(["edge", "liquid", "hbs", "ejs"].map((e) => [e, [["src/_includes/layout", `starter/engines/layout.${e}`], ["src/index", `starter/engines/index.${e}`]]]))
86
+ };
87
+ var DOCS_NAMES = ["base", "doc", "hooks/heading", "containers/tabs", "containers/tab", "containers/details"];
88
+ var docsTemplates = (dir, ext) => DOCS_NAMES.map((name) => [`src/_includes/${name}`, `${dir}${name}.${ext}`]);
89
+ var DOCS_TEMPLATES = {
90
+ jinja: docsTemplates("starter-docs/src/_includes/", "jinja"),
91
+ ...Object.fromEntries(["edge", "liquid", "hbs", "ejs"].map((e) => [e, docsTemplates(`starter-docs/engines/${e}/`, e)]))
92
+ };
93
+ function replaceOnce(contents, from, to) {
94
+ const at = contents.indexOf(from);
95
+ if (at === -1) throw new Error(`starter file is missing ${JSON.stringify(from)}`);
96
+ return contents.slice(0, at) + to + contents.slice(at + from.length);
97
+ }
98
+ var rename = (engine, contents) => engine === "jinja" ? contents : contents.replace(/\b([\w-]+)\.jinja\b/g, (_, name) => `${name}.${engine}`);
99
+ function adapt(engine, rel, contents) {
100
+ if (engine === "jinja") return contents;
101
+ if (rel === "ssqch.config.js") {
102
+ let config = replaceOnce(contents, 'templateFormats: ["jinja", "md"],', `templateFormats: ["${engine}", "md"],
103
+ markdownEngine: "${engine}",`);
104
+ if (config.includes("{{ readableDate(post.date) }}")) {
105
+ const call = { liquid: "{{ post.date | readableDate }}", hbs: "{{readableDate post.date}}", ejs: "<%= readableDate(post.date) %>" }[engine] ?? "{{ readableDate(post.date) }}";
106
+ config = replaceOnce(config, "{{ readableDate(post.date) }}", call);
107
+ }
108
+ if (engine === "hbs" && config.includes("data: { search },")) {
109
+ config = replaceOnce(config, " data: { search },", ' // The path after `site.editUrl` in each page\'s "Edit this page" link.\n filters: {\n sourcePath: (inputPath) => inputPath.replace("./", ""),\n },\n\n data: { search },');
110
+ }
111
+ return config;
112
+ }
113
+ if (rel.endsWith(".md") && engine === "ejs") {
114
+ return rename(engine, contents).replace(/\{\{ ([\w.]+) \}\}/g, "<%= $1 %>");
115
+ }
116
+ if (rel.endsWith(".md") || rel.endsWith(".json")) return rename(engine, contents);
117
+ return contents;
118
+ }
119
+ function agentsMd(site) {
120
+ let files;
121
+ if (site) {
122
+ const language = { njk: "Nunjucks", edge: "Edge", liquid: "Liquid", hbs: "Handlebars", ejs: "EJS" }[site.engine] ?? "Jinja";
123
+ const pages = site.starter === "docs" ? "`src/docs/` has the pages (Markdown, with `src/_data/nav.yml` for the sidebar)" : "`src/posts/` has the posts and `src/` the other pages (Markdown)";
124
+ files = `\`ssqch.config.js\` is the config. ${pages}, \`src/_includes/\` the layouts and templates (${language}), \`src/_data/\` the global data and \`src/_blueprints/\` the blueprints for new pages. \`dist/\` is the build: don't edit it.`;
125
+ } else {
126
+ files = "`ssqch.config.js` (or `sitesquatch.toml`) is the config, and its `dirs` say where the pages, layouts (`_includes/`), global data (`_data/`) and the build are. Don't edit the build.";
127
+ }
128
+ const newPage = !site ? '`ssqch new <folder> --title "..."`, from a blueprint in `_blueprints/`' : site.starter === "docs" ? '`ssqch new docs/guides --title "..."` (then list it in `src/_data/nav.yml`)' : '`ssqch new posts --title "..."`';
129
+ const out = site ? "dist" : "<output>";
130
+ return `# A SiteSquatch site
131
+
132
+ This site is built with SiteSquatch (\`ssqch\`), a static site generator. ${files}
133
+
134
+ - How to use something: \`ssqch docs <name>\` (a config option, template function, command or topic) answers for the installed version, and \`ssqch docs\` lists everything.
135
+ - What this ssqch supports: \`ssqch capabilities --format json\`.
136
+ - Check a change: \`ssqch build --format json\`. \`ok\` is the result, and each problem has a \`code\`, a \`file\` and a \`line\`.
137
+ - Why a page's value is what it is: \`ssqch inspect <url or file> --format json\`.
138
+ - Before changing layouts or the config: \`ssqch build --output ${out}-before\`, and afterwards \`ssqch build\` and \`ssqch diff ${out}-before ${out}\`.
139
+ - A new page: ${newPage}.
140
+ - \`ssqch serve\` is for a person watching the browser. Check with \`ssqch build\`.
141
+ - A \`note:\` or hint naming another generator's word (\`pathPrefix\`): use ssqch's name.
142
+ `;
143
+ }
144
+ function starterFiles(starter, engine) {
145
+ const common = (starter === "docs" ? DOCS_STARTER : STARTER).map(([rel, file]) => [rel, adapt(engine, rel, rel === "ssqch.d.ts" ? types() : bundled(file))]);
146
+ const set = (starter === "docs" ? DOCS_TEMPLATES : SITE_TEMPLATES)[engine === "njk" ? "jinja" : engine];
147
+ const templates = set.map(([rel, file]) => [`${rel}.${engine}`, rename(engine, bundled(file))]);
148
+ return [...common, ...templates, ["AGENTS.md", agentsMd({ starter, engine })], ["CLAUDE.md", "@AGENTS.md\n"]];
149
+ }
150
+ function write(file, contents, shown = file) {
151
+ const parent = parentAsGiven(shown);
152
+ if (parent !== "") {
153
+ try {
154
+ fs2.mkdirSync(path2.dirname(file), { recursive: true });
155
+ } catch (e) {
156
+ throw new Error(`creating ${parent}: ${e.message}`);
157
+ }
158
+ }
159
+ try {
160
+ fs2.writeFileSync(file, contents);
161
+ } catch (e) {
162
+ throw new Error(`writing ${shown}: ${e.message}`);
163
+ }
164
+ }
165
+ var isCurrentFolder = (dir) => dir.startsWith(".") && dir.split(path2.sep === "/" ? "/" : /[\\/]/).every((part) => part === "" || part === ".");
166
+ function runInit(options) {
167
+ const { dir, starter, engine, quiet } = options;
168
+ const written = [], skipped = [];
169
+ try {
170
+ if (!STARTERS.includes(starter)) throw new Error(`--starter ${starter}: not a starter (use ${STARTERS.join(" or ")})`);
171
+ if (!ENGINES.includes(engine)) throw new Error(`--engine ${engine}: not a starter engine (use ${ENGINES.join(", ")})`);
172
+ for (const [rel, contents] of starterFiles(starter, engine)) {
173
+ const file = path2.join(dir, rel);
174
+ if (fs2.existsSync(file)) skipped.push(rel);
175
+ else {
176
+ write(file, contents, joinAsGiven(dir, rel));
177
+ written.push(rel);
178
+ }
179
+ }
180
+ } catch (e) {
181
+ process.stderr.write(`${red("error:")} ${e.message}
182
+ `);
183
+ return 1;
184
+ }
185
+ if (quiet) return 0;
186
+ let out = "";
187
+ for (const rel of written) out += ` created ${slashes(rel)}
188
+ `;
189
+ for (const rel of skipped) out += ` kept ${slashes(rel)} (already there)
190
+ `;
191
+ if (written.length === 0) out += "Nothing to do: camp is already set up (every starter file is there).\n";
192
+ else out += `
193
+ Camp is set up. Next: ${isCurrentFolder(dir) ? "" : `cd ${dir} && `}ssqch serve, then open http://localhost:8080
194
+ `;
195
+ process.stdout.write(out);
196
+ return 0;
197
+ }
198
+
199
+ export {
200
+ bundled,
201
+ bundledNames,
202
+ types,
203
+ STARTERS,
204
+ ENGINES,
205
+ DEFAULT_ENGINE,
206
+ starterEngines,
207
+ agentsMd,
208
+ starterFiles,
209
+ write,
210
+ runInit
211
+ };