ssqch 0.7.1 → 0.8.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.
- package/README.md +6 -4
- package/bin/ssqch.js +14 -48
- package/bundled/README.md +1247 -0
- package/bundled/completions/bash +840 -0
- package/bundled/completions/elvish +286 -0
- package/bundled/completions/fish +182 -0
- package/bundled/completions/powershell +318 -0
- package/bundled/completions/zsh +510 -0
- package/bundled/ssqch.d.ts +532 -0
- package/bundled/starter/engines/index.edge +11 -0
- package/bundled/starter/engines/index.ejs +11 -0
- package/bundled/starter/engines/index.hbs +11 -0
- package/bundled/starter/engines/index.liquid +11 -0
- package/bundled/starter/engines/layout.edge +35 -0
- package/bundled/starter/engines/layout.ejs +35 -0
- package/bundled/starter/engines/layout.hbs +35 -0
- package/bundled/starter/engines/layout.liquid +35 -0
- package/bundled/starter/gitignore +3 -0
- package/bundled/starter/jsconfig.json +11 -0
- package/bundled/starter/src/404.md +8 -0
- package/bundled/starter/src/_blueprints/posts.md +5 -0
- package/bundled/starter/src/_data/site.json +4 -0
- package/bundled/starter/src/_includes/layout.jinja +35 -0
- package/bundled/starter/src/index.jinja +11 -0
- package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
- package/bundled/starter/src/posts/posts.json +4 -0
- package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
- package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
- package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
- package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
- package/bundled/starter/ssqch.config.js +29 -0
- package/bundled/starter-docs/engines/edge/base.edge +41 -0
- package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
- package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
- package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
- package/bundled/starter-docs/engines/edge/doc.edge +59 -0
- package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
- package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
- package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
- package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
- package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
- package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
- package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
- package/bundled/starter-docs/gitignore +4 -0
- package/bundled/starter-docs/src/404.md +12 -0
- package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
- package/bundled/starter-docs/src/_data/nav.yml +10 -0
- package/bundled/starter-docs/src/_data/site.json +5 -0
- package/bundled/starter-docs/src/_includes/base.jinja +41 -0
- package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
- package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
- package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
- package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
- package/bundled/starter-docs/src/assets/docs.css +257 -0
- package/bundled/starter-docs/src/assets/docs.js +67 -0
- package/bundled/starter-docs/src/docs/docs.json +1 -0
- package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
- package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
- package/bundled/starter-docs/src/docs/index.md +29 -0
- package/bundled/starter-docs/src/docs/install.md +42 -0
- package/bundled/starter-docs/src/index.md +13 -0
- package/bundled/starter-docs/ssqch.config.js +40 -0
- package/bundled/trailheads/from-component-frameworks.md +116 -0
- package/bundled/trailheads/from-docusaurus.md +55 -0
- package/bundled/trailheads/from-eleventy.md +140 -0
- package/bundled/trailheads/from-hexo.md +92 -0
- package/bundled/trailheads/from-mkdocs.md +45 -0
- package/bundled/trailheads/from-zola.md +71 -0
- package/lib/assets.js +235 -3
- package/lib/chunk-37KSIVNY.js +29 -0
- package/lib/chunk-3GYLOC6Y.js +1017 -0
- package/lib/chunk-3NYSSA2C.js +22 -0
- package/lib/chunk-3PHCFZEU.js +209 -0
- package/lib/chunk-4Q6WMTER.js +32 -0
- package/lib/chunk-6XYSFG6V.js +4423 -0
- package/lib/chunk-6XYSFG6V.js.LEGAL.txt +41 -0
- package/lib/chunk-AD3HAW3W.js +10 -0
- package/lib/chunk-AMBFWPZ4.js +118 -0
- package/lib/chunk-BOBPVAX2.js +37088 -0
- package/lib/chunk-BOBPVAX2.js.LEGAL.txt +27 -0
- package/lib/chunk-BRK4MXXO.js +565 -0
- package/lib/chunk-C35KIPAR.js +247 -0
- package/lib/chunk-CDEPYU7W.js +25 -0
- package/lib/chunk-CMUWRPSQ.js +113 -0
- package/lib/chunk-DDV6JEC2.js +46 -0
- package/lib/chunk-DHHQKW4F.js +71 -0
- package/lib/chunk-EIT4ZDT4.js +1485 -0
- package/lib/chunk-EZZUUPI4.js +20 -0
- package/lib/chunk-F65YUXZ7.js +334 -0
- package/lib/chunk-FVZ5JBRI.js +115 -0
- package/lib/chunk-FYGE634X.js +44 -0
- package/lib/chunk-GOE4ZSAB.js +75 -0
- package/lib/chunk-GSKVRAHF.js +44 -0
- package/lib/chunk-HR2RU2LY.js +999 -0
- package/lib/chunk-HXCLCXRT.js +20 -0
- package/lib/chunk-I3PS26CI.js +48 -0
- package/lib/chunk-IAFM5ITE.js +11 -0
- package/lib/chunk-IRHRK7XB.js +54 -0
- package/lib/chunk-JRT7TQQP.js +57 -0
- package/lib/chunk-JSPSMIJ2.js +217 -0
- package/lib/chunk-KBGE5MCY.js +175 -0
- package/lib/chunk-N5QTGQ5N.js +207 -0
- package/lib/chunk-NKXEPHRZ.js +136 -0
- package/lib/chunk-NUKCUDC4.js +146 -0
- package/lib/chunk-RI2L3VGO.js +376 -0
- package/lib/chunk-TDGBQNGW.js +251 -0
- package/lib/chunk-TN6EEDX2.js +3935 -0
- package/lib/chunk-TWCVHOKO.js +1229 -0
- package/lib/chunk-UGEGUUBT.js +29 -0
- package/lib/chunk-UU43WIZG.js +29 -0
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/chunk-VVPZ5PDP.js +160 -0
- package/lib/chunk-WMOVCQO6.js +1287 -0
- package/lib/chunk-WP3RPVUM.js +211 -0
- package/lib/chunk-YSH2NMIE.js +502 -0
- package/lib/cli.js +540 -0
- package/lib/elements.js +180 -3
- package/lib/image.js +27 -3
- package/lib/links.js +464 -3
- package/lib/minify.js +69 -3
- package/lib/redirects.js +152 -3
- package/lib/rss.js +139 -3
- package/lib/sass.js +221 -3
- package/lib/sitemap.js +88 -3
- package/lib/ssqch.js +28 -0
- package/package.json +83 -80
- package/src/serve/live.js +174 -0
- package/src/serve/not-found.html +31 -0
- package/types/globals.d.ts +3 -2
- package/types/image.d.ts +7 -3
- package/types/index.d.ts +18 -5
- package/types/links.d.ts +1 -1
- package/types/minify.d.ts +1 -1
- package/types/rss.d.ts +1 -1
- package/types/sass.d.ts +1 -1
- package/wasm/markdown.wasm +0 -0
- package/wasm/minify.wasm +0 -0
- package/wasm/sass.wasm +0 -0
- package/lib/index.js +0 -3
- package/platforms.json +0 -6
package/lib/cli.js
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
BUILDER
|
|
5
|
+
} from "./chunk-KBGE5MCY.js";
|
|
6
|
+
import {
|
|
7
|
+
Printed,
|
|
8
|
+
UsageError,
|
|
9
|
+
parse
|
|
10
|
+
} from "./chunk-F65YUXZ7.js";
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_ENGINE,
|
|
13
|
+
bundled
|
|
14
|
+
} from "./chunk-WP3RPVUM.js";
|
|
15
|
+
import {
|
|
16
|
+
VERSION
|
|
17
|
+
} from "./chunk-AD3HAW3W.js";
|
|
18
|
+
import {
|
|
19
|
+
dirsOf,
|
|
20
|
+
parseEnvironment,
|
|
21
|
+
shownDir,
|
|
22
|
+
shownOutput
|
|
23
|
+
} from "./chunk-DDV6JEC2.js";
|
|
24
|
+
import {
|
|
25
|
+
describeThrown
|
|
26
|
+
} from "./chunk-C35KIPAR.js";
|
|
27
|
+
import {
|
|
28
|
+
prettyJson,
|
|
29
|
+
quoted
|
|
30
|
+
} from "./chunk-CMUWRPSQ.js";
|
|
31
|
+
import {
|
|
32
|
+
Locator,
|
|
33
|
+
aliasUsed,
|
|
34
|
+
aliasesKnown,
|
|
35
|
+
aliasesUsed,
|
|
36
|
+
bail,
|
|
37
|
+
capture,
|
|
38
|
+
find,
|
|
39
|
+
fromError,
|
|
40
|
+
hint,
|
|
41
|
+
isCapturing,
|
|
42
|
+
printError,
|
|
43
|
+
progress,
|
|
44
|
+
red,
|
|
45
|
+
setQuiet,
|
|
46
|
+
takeWarnings,
|
|
47
|
+
toJson,
|
|
48
|
+
toJson2,
|
|
49
|
+
warn,
|
|
50
|
+
warning
|
|
51
|
+
} from "./chunk-6XYSFG6V.js";
|
|
52
|
+
import {
|
|
53
|
+
relative
|
|
54
|
+
} from "./chunk-VJWQSYEG.js";
|
|
55
|
+
import "./chunk-I3PS26CI.js";
|
|
56
|
+
|
|
57
|
+
// src/cli.ts
|
|
58
|
+
import path from "node:path";
|
|
59
|
+
import util from "node:util";
|
|
60
|
+
var FORMAT = { long: "format", value: "FORMAT", help: "text or json", default: "text" };
|
|
61
|
+
var digits = (value) => /^\+?\d+$/.test(value) ? void 0 : value === "" ? "cannot parse integer from empty string" : "invalid digit found in string";
|
|
62
|
+
var number = (value) => digits(value) ?? (BigInt(value) > 0xffffffffffffffffn ? "number too large to fit in target type" : void 0);
|
|
63
|
+
var port = (value) => digits(value) ?? (BigInt(value) > 0x7fffffffffffffffn ? "number too large to fit in target type" : BigInt(value) > 65535n ? `${BigInt(value)} is not in 0..=65535` : void 0);
|
|
64
|
+
var GLOBALS = [
|
|
65
|
+
{ long: "root", value: "ROOT", path: true, help: "Project root (defaults to the current directory)" },
|
|
66
|
+
{ long: "output", short: "o", value: "OUTPUT", path: true, help: "Override the output directory (relative to the root)" },
|
|
67
|
+
{ long: "base", value: "BASE", help: "Serve the site under a path, like /repo/ (overrides the config's `base`)" },
|
|
68
|
+
{ long: "offline", help: "Don't use the network: `fetch()` answers from the copies its `cache` option saved" },
|
|
69
|
+
{ long: "env", value: "ENV", help: "development or production (default: $SSQCH_ENV, $NODE_ENV, then production for `build` and development for `serve`)" },
|
|
70
|
+
{ long: "quiet", short: "q", help: "Print only warnings and errors" },
|
|
71
|
+
{ long: "verbose", short: "v", help: "Also list the slowest images to encode" }
|
|
72
|
+
];
|
|
73
|
+
var SHELLS = ["bash", "elvish", "fish", "powershell", "zsh"];
|
|
74
|
+
var COMMANDS = [
|
|
75
|
+
{
|
|
76
|
+
name: "build",
|
|
77
|
+
about: "Build the site (default)",
|
|
78
|
+
options: [FORMAT],
|
|
79
|
+
positionals: [],
|
|
80
|
+
afterHelp: "With --format json, standard output is one JSON report: whether the build worked, what it wrote, and its\nwarnings and errors, each with a code, the file, the line when it's known, and the field for a content error.\nProgress lines and `console.log` go to standard error."
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "serve",
|
|
84
|
+
about: "Build, serve, watch for changes and live-reload the browser",
|
|
85
|
+
options: [
|
|
86
|
+
{ long: "port", short: "p", value: "PORT", help: "The port to listen on (0 picks a free one)", default: "8080", check: port },
|
|
87
|
+
{ long: "built", help: "Serve the output folder as it was built: no build, no watching, no reload script, gzip on" },
|
|
88
|
+
{ long: "ready-file", value: "FILE", path: true, help: "Write this file once the first build is done: JSON with the url, port and output folder" }
|
|
89
|
+
],
|
|
90
|
+
positionals: [],
|
|
91
|
+
afterHelp: "With --built, it serves the output folder as the last build left it, the way a host would: no build, no\nwatching, no reload script, and text compressed with gzip. For checking a production build (Lighthouse,\na deploy's files) before it goes out:\n\n ssqch build\n ssqch serve --built"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "new",
|
|
95
|
+
about: "Create a page from a blueprint (a file in _blueprints/), with its title and date filled in",
|
|
96
|
+
options: [
|
|
97
|
+
{ long: "title", value: "TITLE", help: "The page's title (default: from the file's name)" },
|
|
98
|
+
{ long: "date", value: "DATE", help: "The page's date, as it's written in front matter (default: today)" },
|
|
99
|
+
{ long: "blueprint", value: "NAME", help: "The blueprint to use (default: the page's folder, then `default`)" },
|
|
100
|
+
{ long: "set", value: "KEY=VALUE", help: "Another front matter key, with its value as it's written there (repeatable)", many: true },
|
|
101
|
+
FORMAT
|
|
102
|
+
],
|
|
103
|
+
positionals: [{ name: "PATH", help: "The new file, from the input folder (posts/pine-cones.md), or a folder, with --title", required: true }],
|
|
104
|
+
afterHelp: 'The blueprint is named after the page\'s folder (_blueprints/posts.md for posts/), then `default`.\nIts body is copied as it is; only front matter keys are filled in. Nothing is overwritten.\n\n ssqch new posts/pine-cones.md\n ssqch new posts --title "Pine cones" (named like the other pages in posts/)\n ssqch new docs/guides/install.md --set order=3 --set draft=true'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "inspect",
|
|
108
|
+
about: "Show where a page comes from, and which level of the data cascade set each value",
|
|
109
|
+
options: [{ long: "field", value: "NAME", help: "One field of its data, in full, with every level that set it (a dotted path reaches inside: hero.alt)" }, FORMAT],
|
|
110
|
+
positionals: [{ name: "PAGE", help: "The page: its URL (/about/), or its template's path", required: true }],
|
|
111
|
+
afterHelp: "The site is read as a build reads it, up to rendering: beforeBuild hooks run (data can depend on them),\nbut no page is rendered or written, and afterBuild hooks don't run. Standard output is only the report.\n\n ssqch inspect /guides/install/\n ssqch inspect src/guides/install.md --field title\n ssqch inspect /guides/install/ --field hero.alt --format json"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "completions",
|
|
115
|
+
about: "Print a completion script for your shell, so Tab finishes commands and options",
|
|
116
|
+
options: [],
|
|
117
|
+
positionals: [{ name: "SHELL", help: "bash, zsh, fish, powershell or elvish", required: true, values: SHELLS }],
|
|
118
|
+
afterHelp: "Put the script where your shell looks for completions:\n\n ssqch completions zsh > ~/.zfunc/_ssqch (with ~/.zfunc in $fpath, before compinit)\n ssqch completions bash > ~/.local/share/bash-completion/completions/ssqch\n ssqch completions fish > ~/.config/fish/completions/ssqch.fish\n ssqch completions powershell >> $PROFILE"
|
|
119
|
+
// Not `own`: in 0.7 it was one of the core's commands, so `-d` and `--pathprefix` work there.
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "diff",
|
|
123
|
+
about: "Compare two builds of a site: URLs added and removed, and what changed on each page",
|
|
124
|
+
options: [
|
|
125
|
+
{ long: "exact", help: "Compare bytes: don't match fingerprinted files or ignore whitespace" },
|
|
126
|
+
{ long: "ignore", value: "REGEX", help: "Leave out text matching this regular expression before comparing (repeatable)", many: true },
|
|
127
|
+
{ long: "only", value: "GLOB", help: "Only compare files matching this glob, like '**/*.html' (repeatable)", many: true },
|
|
128
|
+
{ long: "lines", value: "LINES", help: "Changed lines to show for each file (0 for all)", default: "10", check: number },
|
|
129
|
+
FORMAT
|
|
130
|
+
],
|
|
131
|
+
positionals: [{ name: "BEFORE", help: "The build from before the change", required: true, path: true }, { name: "AFTER", help: "The build from after it", required: true, path: true }],
|
|
132
|
+
afterHelp: "Build the site into one folder before a change and another after it:\n\n ssqch build --output dist-before\n (upgrade ssqch, edit a layout, ...)\n ssqch build\n ssqch diff dist-before dist\n\nExits with 0 when the builds are the same, 1 when they differ, and 2 on an error."
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "footprint",
|
|
136
|
+
about: "Show how much a build weighs: its files by kind, and the heaviest pages and files",
|
|
137
|
+
options: [{ long: "top", value: "TOP", help: "How many of the heaviest pages and files to list (0 for none)", default: "5", check: number }, FORMAT],
|
|
138
|
+
positionals: [{ name: "DIR", help: "The build folder (default: the site's output folder)", required: false, path: true }],
|
|
139
|
+
afterHelp: "It reads a build folder, so build first:\n\n ssqch build\n ssqch footprint (the site's output folder)\n ssqch footprint dist-before (any build)\n ssqch footprint --top 20 --format json"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "init",
|
|
143
|
+
about: "Create a starter site (config, layout, five posts, data and editor types)",
|
|
144
|
+
options: [
|
|
145
|
+
{ long: "starter", value: "NAME", help: "What to start with: site (a small blog) or docs (documentation with a sidebar, tabs and search)", default: "site" },
|
|
146
|
+
{ long: "engine", value: "NAME", help: "The template language for the starter's layouts and templates: jinja, njk, edge, liquid, hbs or ejs", default: DEFAULT_ENGINE }
|
|
147
|
+
],
|
|
148
|
+
positionals: [{ name: "dir", help: "Where to create it (default: the current folder)", required: false, default: "." }],
|
|
149
|
+
own: true
|
|
150
|
+
},
|
|
151
|
+
{ name: "types", about: "Write ssqch.d.ts, the types editors use for ssqch.config.js", options: [{ long: "out", value: "out", help: "Where to write it", default: "ssqch.d.ts" }], positionals: [], own: true },
|
|
152
|
+
{
|
|
153
|
+
name: "import",
|
|
154
|
+
about: "Move a site from another generator: rename and rewrite what's mechanical, and list the rest",
|
|
155
|
+
options: [{ long: "write", help: "Make the changes (without it, only list them)" }],
|
|
156
|
+
positionals: [{ name: "generator", help: "The generator the site is built with: eleventy or zola", required: true }, { name: "dir", help: "The site's folder (default: the current folder)", required: false, default: "." }],
|
|
157
|
+
afterHelp: "Run it in a clean git checkout, read the list, then run it again with --write. `ssqch docs --from <generator>` prints the trailhead for each generator.",
|
|
158
|
+
own: true
|
|
159
|
+
},
|
|
160
|
+
{ name: "capabilities", about: "Say what this binary supports: template languages, modules, config options and optional features", options: [FORMAT], positionals: [], own: true },
|
|
161
|
+
{
|
|
162
|
+
name: "docs",
|
|
163
|
+
about: "Read the documentation for this version: a command, config option, function or topic",
|
|
164
|
+
options: [
|
|
165
|
+
{ long: "from", value: "GENERATOR", help: "Another generator's words and ssqch's names for them: eleventy, hugo, jekyll, zola, ..." },
|
|
166
|
+
FORMAT
|
|
167
|
+
],
|
|
168
|
+
positionals: [{ name: "NAME OR WORDS", help: `A name (base, imagePlugin, toc, serve), another generator's word (pathPrefix), or words from a heading ("content schemas")`, required: false, many: true }],
|
|
169
|
+
afterHelp: `Without a name, it lists everything, one line each.
|
|
170
|
+
|
|
171
|
+
ssqch docs
|
|
172
|
+
ssqch docs base
|
|
173
|
+
ssqch docs "content schemas"
|
|
174
|
+
ssqch docs pathPrefix (another generator's word: says ssqch's)
|
|
175
|
+
ssqch docs --from eleventy
|
|
176
|
+
ssqch docs -- --starter (a flag: after --)
|
|
177
|
+
ssqch docs agents > AGENTS.md (instructions for coding agents)
|
|
178
|
+
|
|
179
|
+
The text is this version's README, built into the binary.`,
|
|
180
|
+
own: true
|
|
181
|
+
},
|
|
182
|
+
{ name: "sighting", about: "Photographic evidence", options: [], positionals: [], hidden: true, own: true }
|
|
183
|
+
];
|
|
184
|
+
var CAPABILITY_ORDER = (() => {
|
|
185
|
+
const names = COMMANDS.filter((c) => !c.hidden && c.name !== "completions").map((c) => c.name);
|
|
186
|
+
names.splice(names.indexOf("footprint") + 1, 0, "completions");
|
|
187
|
+
return names;
|
|
188
|
+
})();
|
|
189
|
+
var GRAMMAR = { name: "ssqch", about: "SiteSquatch (ssqch): a fast, pluggable static site generator", version: VERSION, globals: GLOBALS, commands: COMMANDS };
|
|
190
|
+
var VALUED = ["--root", "--output", "-o", "--base", "--env", "-d", "--destination", "--pathprefix", "--port", "-p", "--ready-file", "--format", "--title", "--date", "--blueprint", "--set", "--field", "--ignore", "--only", "--lines", "--top", "--starter", "--engine"];
|
|
191
|
+
var OWN = COMMANDS.filter((c) => c.raw || c.own).map((c) => c.name);
|
|
192
|
+
function aliased(given, own = OWN) {
|
|
193
|
+
const args = [...given];
|
|
194
|
+
let end = args.indexOf("--");
|
|
195
|
+
if (end === -1) end = args.length;
|
|
196
|
+
let command;
|
|
197
|
+
for (let i = 0; i < end; ) {
|
|
198
|
+
if (args[i].startsWith("-")) i += VALUED.includes(args[i]) ? 2 : 1;
|
|
199
|
+
else {
|
|
200
|
+
command = i;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const used = [];
|
|
205
|
+
const name = command === void 0 ? void 0 : args[command];
|
|
206
|
+
if (name !== void 0 && own.includes(name)) return [args, used];
|
|
207
|
+
const row = name === void 0 ? void 0 : find(name, "command");
|
|
208
|
+
if (command !== void 0 && row?.alias) {
|
|
209
|
+
const words = row.ssqch.split(" ");
|
|
210
|
+
args.splice(command, 1, ...words);
|
|
211
|
+
end += words.length - 1;
|
|
212
|
+
used.push(row);
|
|
213
|
+
}
|
|
214
|
+
let serve = false;
|
|
215
|
+
for (let i = 0; i < end; ) {
|
|
216
|
+
const arg = args[i];
|
|
217
|
+
const eq = arg.indexOf("=");
|
|
218
|
+
const [flag, value] = eq !== -1 && arg.startsWith("--") ? [arg.slice(0, eq), arg.slice(eq + 1)] : [arg, void 0];
|
|
219
|
+
const building = command === void 0 || args[command] === "build" || args[command] === "serve";
|
|
220
|
+
const found = flag.startsWith("-") ? find(flag, "flag") : void 0;
|
|
221
|
+
if (!found?.alias) {
|
|
222
|
+
i += value === void 0 && VALUED.includes(flag) && i !== command ? 2 : 1;
|
|
223
|
+
} else if (found.ssqch === "serve" && !building) {
|
|
224
|
+
i += 1;
|
|
225
|
+
} else if (found.ssqch === "serve") {
|
|
226
|
+
serve = true;
|
|
227
|
+
used.push(found);
|
|
228
|
+
args.splice(i, 1);
|
|
229
|
+
end -= 1;
|
|
230
|
+
if (command !== void 0 && command > i) command -= 1;
|
|
231
|
+
} else {
|
|
232
|
+
args[i] = value === void 0 ? found.ssqch : `${found.ssqch}=${value}`;
|
|
233
|
+
used.push(found);
|
|
234
|
+
i += value === void 0 ? 2 : 1;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (serve) {
|
|
238
|
+
if (command === void 0) args.unshift("serve");
|
|
239
|
+
else if (args[command] === "build") args[command] = "serve";
|
|
240
|
+
}
|
|
241
|
+
return [args, used];
|
|
242
|
+
}
|
|
243
|
+
function refusal(e) {
|
|
244
|
+
const equivalent = e.refused && find(e.refused.word, e.refused.kind);
|
|
245
|
+
if (!equivalent) return e.message;
|
|
246
|
+
const at = e.message.indexOf("\nUsage:");
|
|
247
|
+
const head = at === -1 ? e.message : e.message.slice(0, at);
|
|
248
|
+
const usage = at === -1 ? "" : e.message.slice(at + 1);
|
|
249
|
+
const lines = head.split("\n").filter((line) => !line.trimStart().startsWith("tip:")).filter((line, i, all) => !(line.trim() === "" && i > 0 && all[i - 1].trim() === ""));
|
|
250
|
+
const hint2 = hint(equivalent).split("\n").map((line) => ` ${line}
|
|
251
|
+
`).join("");
|
|
252
|
+
return `${lines.join("\n").trimEnd()}
|
|
253
|
+
|
|
254
|
+
${hint2}${usage === "" ? "" : `
|
|
255
|
+
${usage}`}`;
|
|
256
|
+
}
|
|
257
|
+
function routeConsole() {
|
|
258
|
+
const text = (args) => util.format(...args);
|
|
259
|
+
console.log = console.info = console.debug = (...args) => progress(text(args));
|
|
260
|
+
console.warn = (...args) => {
|
|
261
|
+
if (isCapturing()) warn(warning("console", text(args)));
|
|
262
|
+
else process.stderr.write(text(args) + "\n");
|
|
263
|
+
};
|
|
264
|
+
console.error = (...args) => {
|
|
265
|
+
process.stderr.write(text(args) + "\n");
|
|
266
|
+
};
|
|
267
|
+
const said = (name, message, code) => {
|
|
268
|
+
if (code === "MODULE_TYPELESS_PACKAGE_JSON" || name === "ExperimentalWarning") return;
|
|
269
|
+
console.warn(`${name}: ${message}`);
|
|
270
|
+
};
|
|
271
|
+
process.emitWarning = ((warning2, ...rest) => {
|
|
272
|
+
if (warning2 instanceof Error) return said(warning2.name, warning2.message, warning2.code);
|
|
273
|
+
const options = rest[0];
|
|
274
|
+
if (options !== null && typeof options === "object") return said(options.type ?? "Warning", String(warning2), options.code);
|
|
275
|
+
said(typeof options === "string" ? options : "Warning", String(warning2), typeof rest[1] === "string" ? rest[1] : void 0);
|
|
276
|
+
});
|
|
277
|
+
process.removeAllListeners("warning");
|
|
278
|
+
process.on("warning", (w) => said(w.name, w.message, w.code));
|
|
279
|
+
}
|
|
280
|
+
var siteRoot = process.cwd();
|
|
281
|
+
function crashed(e) {
|
|
282
|
+
process.stderr.write(`${red("error:")} ${describeThrown(e, siteRoot)}
|
|
283
|
+
`);
|
|
284
|
+
process.exit(1);
|
|
285
|
+
}
|
|
286
|
+
async function main(argv) {
|
|
287
|
+
let building;
|
|
288
|
+
if (argv[0] === BUILDER && process.send !== void 0) {
|
|
289
|
+
building = JSON.parse(argv[1]);
|
|
290
|
+
argv = argv.slice(2);
|
|
291
|
+
}
|
|
292
|
+
const [args, aliases] = aliased(argv);
|
|
293
|
+
let cli;
|
|
294
|
+
try {
|
|
295
|
+
cli = parse(GRAMMAR, args);
|
|
296
|
+
} catch (e) {
|
|
297
|
+
if (e instanceof Printed) {
|
|
298
|
+
process.stdout.write(e.text);
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
if (e instanceof UsageError) {
|
|
302
|
+
process.stderr.write(refusal(e));
|
|
303
|
+
return 2;
|
|
304
|
+
}
|
|
305
|
+
throw e;
|
|
306
|
+
}
|
|
307
|
+
const flag = (name) => cli.options[name] === true;
|
|
308
|
+
const value = (name) => typeof cli.options[name] === "string" ? cli.options[name] : void 0;
|
|
309
|
+
setQuiet(flag("quiet"));
|
|
310
|
+
const format = value("format") ?? "text";
|
|
311
|
+
const command = cli.command ?? "build";
|
|
312
|
+
if (command === "build" && format === "json") capture();
|
|
313
|
+
if (building) aliasesKnown(aliases);
|
|
314
|
+
else for (const row of aliases) aliasUsed(row);
|
|
315
|
+
const later = COMMANDS.find((c) => c.name === command)?.stage;
|
|
316
|
+
if (command !== "build" && later !== void 0) {
|
|
317
|
+
process.stderr.write(`${red("error:")} \`ssqch ${command}\` isn't in the Node build of ssqch yet (the move to Node, stage ${later}); ssqch 0.7 has it
|
|
318
|
+
`);
|
|
319
|
+
return 1;
|
|
320
|
+
}
|
|
321
|
+
if (command === "import") return (await import("./chunk-WMOVCQO6.js")).runImport(cli.positionals[0], cli.positionals[1] ?? ".", flag("write"));
|
|
322
|
+
switch (command) {
|
|
323
|
+
case "init":
|
|
324
|
+
return (await import("./chunk-CDEPYU7W.js")).runInit({ dir: cli.positionals[0] ?? ".", starter: value("starter") ?? "site", engine: value("engine") ?? DEFAULT_ENGINE, quiet: flag("quiet") });
|
|
325
|
+
case "capabilities":
|
|
326
|
+
return (await import("./chunk-UGEGUUBT.js")).runCapabilities(format, CAPABILITY_ORDER);
|
|
327
|
+
case "docs":
|
|
328
|
+
return (await import("./chunk-BRK4MXXO.js")).runDocs(GRAMMAR, { query: cli.positionals, from: value("from"), format });
|
|
329
|
+
case "sighting":
|
|
330
|
+
return (await import("./chunk-GOE4ZSAB.js")).runSighting(path.resolve(value("root") ?? "."));
|
|
331
|
+
case "completions": {
|
|
332
|
+
process.stdout.write(bundled(`completions/${cli.positionals[0]}`));
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
335
|
+
case "types": {
|
|
336
|
+
routeConsole();
|
|
337
|
+
return (await import("./chunk-DHHQKW4F.js")).runTypes({ root: value("root"), out: value("out") ?? "ssqch.d.ts" });
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const many = (name) => Array.isArray(cli.options[name]) ? cli.options[name] : typeof cli.options[name] === "string" ? [cli.options[name]] : [];
|
|
341
|
+
const top = Number(value("top") ?? "5");
|
|
342
|
+
if (command === "diff") return runDiff(cli.positionals[0], cli.positionals[1], { exact: flag("exact"), ignore: many("ignore"), only: many("only"), lines: Number(value("lines") ?? "10"), format });
|
|
343
|
+
if (command === "footprint" && cli.positionals[0] !== void 0) {
|
|
344
|
+
try {
|
|
345
|
+
await runFootprint(cli.positionals[0], cli.positionals[0], top, format);
|
|
346
|
+
return 0;
|
|
347
|
+
} catch (e) {
|
|
348
|
+
process.stderr.write(`${red("error:")} ${describeThrown(e, process.cwd())}
|
|
349
|
+
`);
|
|
350
|
+
return 1;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
const inspecting = command === "inspect";
|
|
354
|
+
if (inspecting) capture();
|
|
355
|
+
const serving = command === "serve";
|
|
356
|
+
const given = value("env") ?? process.env.SSQCH_ENV ?? process.env.NODE_ENV;
|
|
357
|
+
const env = (given === void 0 ? void 0 : parseEnvironment(given)) ?? (serving ? "development" : "production");
|
|
358
|
+
if (flag("offline")) process.env.SSQCH_OFFLINE = "1";
|
|
359
|
+
process.env.SSQCH_ENV ??= env;
|
|
360
|
+
const root = path.resolve(value("root") ?? ".");
|
|
361
|
+
siteRoot = root;
|
|
362
|
+
routeConsole();
|
|
363
|
+
const makeConfig = async () => (await import("./chunk-GSKVRAHF.js")).loadConfig({ root, rootGiven: value("root") ?? ".", env, serving, quiet: flag("quiet") || inspecting, verbose: flag("verbose"), output: value("output"), base: value("base") });
|
|
364
|
+
if (command === "new") return newPage(makeConfig, root, { path: cli.positionals[0], title: value("title"), date: value("date"), blueprint: value("blueprint"), set: cli.options.set ?? [], format });
|
|
365
|
+
if (serving) {
|
|
366
|
+
if (building) return (await import("./chunk-VVPZ5PDP.js")).runBuilder(building, makeConfig, root);
|
|
367
|
+
const readyFile = value("ready-file") === void 0 ? void 0 : path.resolve(value("ready-file"));
|
|
368
|
+
const options = { port: Number(value("port") ?? "8080"), readyFile, quiet: flag("quiet") };
|
|
369
|
+
if (!flag("built")) {
|
|
370
|
+
try {
|
|
371
|
+
return await (await import("./chunk-HR2RU2LY.js")).serve(argv, options);
|
|
372
|
+
} catch (e) {
|
|
373
|
+
printError("error:", e, "build", new Locator(root));
|
|
374
|
+
return 1;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
let config2;
|
|
378
|
+
try {
|
|
379
|
+
config2 = await makeConfig();
|
|
380
|
+
} catch (e) {
|
|
381
|
+
printError("error:", e, "config", new Locator(root));
|
|
382
|
+
return 1;
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
return await (await import("./chunk-HR2RU2LY.js")).serveBuilt(config2, options);
|
|
386
|
+
} catch (e) {
|
|
387
|
+
printError("error:", e, "build", locatorOf(config2));
|
|
388
|
+
return 1;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (command === "build" && format === "json") return buildJson(makeConfig, root, env);
|
|
392
|
+
if (command === "build" && format !== "text") {
|
|
393
|
+
process.stderr.write(`${red("error:")} --format ${format}: use text or json
|
|
394
|
+
`);
|
|
395
|
+
return 1;
|
|
396
|
+
}
|
|
397
|
+
let config;
|
|
398
|
+
try {
|
|
399
|
+
config = await makeConfig();
|
|
400
|
+
} catch (e) {
|
|
401
|
+
printError("error:", e, "config", new Locator(root));
|
|
402
|
+
return 1;
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
if (inspecting) {
|
|
406
|
+
await runInspect(config, cli.positionals[0], value("field"), format);
|
|
407
|
+
return 0;
|
|
408
|
+
}
|
|
409
|
+
if (command === "footprint") {
|
|
410
|
+
const dirs = dirsOf(config);
|
|
411
|
+
await runFootprint(shownDir(config, config.output), shownOutput(config), top, format);
|
|
412
|
+
return 0;
|
|
413
|
+
}
|
|
414
|
+
const [{ build }, { summary }] = await Promise.all([import("./chunk-FYGE634X.js"), import("./chunk-HXCLCXRT.js")]);
|
|
415
|
+
const report = await build(config);
|
|
416
|
+
if (!config.quiet) process.stdout.write(summary(config, report));
|
|
417
|
+
return 0;
|
|
418
|
+
} catch (e) {
|
|
419
|
+
printError("error:", e, "build", locatorOf(config));
|
|
420
|
+
return 1;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
async function newPage(makeConfig, root, command) {
|
|
424
|
+
let config;
|
|
425
|
+
try {
|
|
426
|
+
config = await makeConfig();
|
|
427
|
+
} catch (e) {
|
|
428
|
+
printError("error:", e, "config", new Locator(root));
|
|
429
|
+
return 1;
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
(await import("./chunk-YSH2NMIE.js")).runNew(config, command);
|
|
433
|
+
return 0;
|
|
434
|
+
} catch (e) {
|
|
435
|
+
printError("error:", e, "build", locatorOf(config));
|
|
436
|
+
return 1;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
var checkFormat = (format) => {
|
|
440
|
+
if (format !== "text" && format !== "json") bail(`--format ${format}: use text or json`);
|
|
441
|
+
};
|
|
442
|
+
async function runInspect(config, target, name, format) {
|
|
443
|
+
checkFormat(format);
|
|
444
|
+
const { field, fieldText, inspect, inspectionJson, inspectionText } = await import("./chunk-JSPSMIJ2.js");
|
|
445
|
+
let report;
|
|
446
|
+
try {
|
|
447
|
+
report = await inspect(config, target);
|
|
448
|
+
} finally {
|
|
449
|
+
for (const found of takeWarnings()) process.stderr.write(`warn: ${found.message}
|
|
450
|
+
`);
|
|
451
|
+
}
|
|
452
|
+
let one;
|
|
453
|
+
if (name !== void 0) {
|
|
454
|
+
one = field(report, name);
|
|
455
|
+
if (!one) bail(`${report.url ?? report.inputPath} has no \`${name.split(".")[0]}\` in its data (it has: ${report.fields.map((f) => f.name).join(", ")})`);
|
|
456
|
+
}
|
|
457
|
+
if (format === "json") process.stdout.write(prettyJson(inspectionJson(report, one)) + "\n");
|
|
458
|
+
else process.stdout.write(one ? fieldText(one) : inspectionText(report));
|
|
459
|
+
}
|
|
460
|
+
async function runDiff(before, after, options) {
|
|
461
|
+
try {
|
|
462
|
+
checkFormat(options.format);
|
|
463
|
+
const [{ rustRegExp }, { globProblem, globToRegExp }, { compare, diffJson, diffText, isSame }] = await Promise.all([import("./chunk-IAFM5ITE.js"), import("./chunk-EZZUUPI4.js"), import("./chunk-TWCVHOKO.js")]);
|
|
464
|
+
const ignore = options.ignore.map((pattern) => {
|
|
465
|
+
try {
|
|
466
|
+
return rustRegExp(pattern, "g");
|
|
467
|
+
} catch (e) {
|
|
468
|
+
return bail(`--ignore ${quoted(pattern)} isn't a regular expression: ${e.message}`);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
const only = options.only.length ? options.only.map((given) => {
|
|
472
|
+
const glob = given.replace(/^[./]+/, "");
|
|
473
|
+
const problem = globProblem(glob);
|
|
474
|
+
if (problem !== void 0) bail(`--only ${quoted(given)} isn't a glob: error parsing glob '${glob}': ${problem}`);
|
|
475
|
+
return globToRegExp(glob);
|
|
476
|
+
}) : void 0;
|
|
477
|
+
const report = await compare(before, after, { exact: options.exact, ignore, only, lines: options.lines });
|
|
478
|
+
if (options.format === "json") process.stdout.write(JSON.stringify(diffJson(report, options.lines), null, 2) + "\n");
|
|
479
|
+
else process.stdout.write(diffText(report, options.lines, process.stdout.isTTY === true));
|
|
480
|
+
return isSame(report) ? 0 : 1;
|
|
481
|
+
} catch (e) {
|
|
482
|
+
process.stderr.write(`${red("error:")} ${describeThrown(e, process.cwd())}
|
|
483
|
+
`);
|
|
484
|
+
return 2;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async function runFootprint(dir, shown, top, format) {
|
|
488
|
+
checkFormat(format);
|
|
489
|
+
const { footprintJson, footprintText, measure } = await import("./chunk-37KSIVNY.js");
|
|
490
|
+
const measured = await measure(dir);
|
|
491
|
+
if (format === "json") process.stdout.write(JSON.stringify(footprintJson(measured, shown, top), null, 2) + "\n");
|
|
492
|
+
else process.stdout.write(footprintText(measured, shown, top));
|
|
493
|
+
}
|
|
494
|
+
function locatorOf(config) {
|
|
495
|
+
const dirs = dirsOf(config);
|
|
496
|
+
return new Locator(dirs.root, [dirs.input, dirs.includes, dirs.data, ...config.themes.flatMap((theme) => [theme, path.join(theme, "_includes")])]);
|
|
497
|
+
}
|
|
498
|
+
var ms = (n) => Math.round(n * 1e3) / 1e3;
|
|
499
|
+
async function buildJson(makeConfig, root, env) {
|
|
500
|
+
capture();
|
|
501
|
+
const out = { schemaVersion: 1, ok: false, environment: env };
|
|
502
|
+
let errors;
|
|
503
|
+
let config;
|
|
504
|
+
try {
|
|
505
|
+
config = await makeConfig();
|
|
506
|
+
} catch (e) {
|
|
507
|
+
errors = fromError(e, "config", new Locator(root));
|
|
508
|
+
}
|
|
509
|
+
if (config) {
|
|
510
|
+
const dirs = dirsOf(config);
|
|
511
|
+
out.output = shownOutput(config);
|
|
512
|
+
try {
|
|
513
|
+
const report = await (await import("./chunk-FYGE634X.js")).build(config);
|
|
514
|
+
out.durationMs = ms(report.durationMs);
|
|
515
|
+
out.pages = { written: report.pagesWritten, templates: report.templates, bytes: report.pageBytes, new: report.pagesNew ?? null, gone: report.pagesGone ?? null };
|
|
516
|
+
out.copied = { files: report.filesCopied, unchanged: report.filesUnchanged, bytes: report.passthroughBytes };
|
|
517
|
+
out.removed = report.filesRemoved;
|
|
518
|
+
out.drafts = report.drafts;
|
|
519
|
+
out.written = report.written.map((file) => relative(dirs.output, file));
|
|
520
|
+
out.summary = report.summary.map(([label, text]) => ({ label, value: text }));
|
|
521
|
+
out.timings = report.timings.map(([phase, time]) => ({ phase, ms: ms(time) }));
|
|
522
|
+
errors = [];
|
|
523
|
+
} catch (e) {
|
|
524
|
+
errors = fromError(e, "build", locatorOf(config));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
out.ok = errors.length === 0;
|
|
528
|
+
out.warnings = takeWarnings().map(toJson2);
|
|
529
|
+
out.aliases = aliasesUsed().map(toJson);
|
|
530
|
+
out.errors = errors.map(toJson2);
|
|
531
|
+
process.stdout.write(JSON.stringify(out, null, 2) + "\n");
|
|
532
|
+
return errors.length === 0 ? 0 : 1;
|
|
533
|
+
}
|
|
534
|
+
export {
|
|
535
|
+
GRAMMAR,
|
|
536
|
+
aliased,
|
|
537
|
+
crashed,
|
|
538
|
+
locatorOf,
|
|
539
|
+
main
|
|
540
|
+
};
|