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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
globBase,
|
|
5
|
+
globProblem,
|
|
6
|
+
globSet,
|
|
7
|
+
globToRegExp,
|
|
8
|
+
isGlob
|
|
9
|
+
} from "./chunk-TDGBQNGW.js";
|
|
10
|
+
import "./chunk-CMUWRPSQ.js";
|
|
11
|
+
import "./chunk-6XYSFG6V.js";
|
|
12
|
+
import "./chunk-VJWQSYEG.js";
|
|
13
|
+
import "./chunk-I3PS26CI.js";
|
|
14
|
+
export {
|
|
15
|
+
globBase,
|
|
16
|
+
globProblem,
|
|
17
|
+
globSet,
|
|
18
|
+
globToRegExp,
|
|
19
|
+
isGlob
|
|
20
|
+
};
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/args.ts
|
|
5
|
+
var UsageError = class extends Error {
|
|
6
|
+
/** What kind of word was refused, for the hint from the table of other generators' words. */
|
|
7
|
+
refused;
|
|
8
|
+
constructor(message, refused) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.refused = refused;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var Printed = class extends Error {
|
|
14
|
+
text;
|
|
15
|
+
constructor(text) {
|
|
16
|
+
super("printed");
|
|
17
|
+
this.text = text;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var HELP = { long: "help", short: "h", help: "Print help" };
|
|
21
|
+
var VERSION = { long: "version", short: "V", help: "Print version" };
|
|
22
|
+
var optionLabel = (o) => `${o.short ? `-${o.short}, ` : " "}--${o.long}${o.value ? ` <${o.value}>` : ""}`;
|
|
23
|
+
var usageOf = (grammar, command) => {
|
|
24
|
+
if (!command) return `Usage: ${grammar.name} [OPTIONS] [COMMAND]`;
|
|
25
|
+
const args = command.positionals.map((p) => (p.required ? `<${p.name}>` : `[${p.name}]`) + (p.many ? "..." : ""));
|
|
26
|
+
return `Usage: ${grammar.name} ${command.name} ${["[OPTIONS]", ...args].join(" ")}`;
|
|
27
|
+
};
|
|
28
|
+
function table(rows) {
|
|
29
|
+
const width = Math.max(...rows.map(([left]) => left.length));
|
|
30
|
+
return rows.map(([left, right]) => ` ${left.padEnd(width)} ${right}`.trimEnd()).join("\n");
|
|
31
|
+
}
|
|
32
|
+
function help(grammar, command) {
|
|
33
|
+
const describe = (o) => o.help + (o.default !== void 0 ? ` [default: ${o.default}]` : "") + (o.values ? ` [possible values: ${o.values.join(", ")}]` : "");
|
|
34
|
+
if (!command) {
|
|
35
|
+
const commands = grammar.commands.filter((c) => !c.hidden).map((c) => [c.name, c.about]);
|
|
36
|
+
commands.push(["help", "Print this message or the help of the given subcommand(s)"]);
|
|
37
|
+
const options = [...grammar.globals, HELP, VERSION].map((o) => [optionLabel(o), describe(o)]);
|
|
38
|
+
return `${grammar.about}
|
|
39
|
+
|
|
40
|
+
${usageOf(grammar, void 0)}
|
|
41
|
+
|
|
42
|
+
Commands:
|
|
43
|
+
${table(commands)}
|
|
44
|
+
|
|
45
|
+
Options:
|
|
46
|
+
${table(options)}
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
let out = `${command.about}
|
|
50
|
+
|
|
51
|
+
${usageOf(grammar, command)}
|
|
52
|
+
`;
|
|
53
|
+
if (command.positionals.length) {
|
|
54
|
+
out += `
|
|
55
|
+
Arguments:
|
|
56
|
+
${table(command.positionals.map((p) => [(p.required ? `<${p.name}>` : `[${p.name}]`) + (p.many ? "..." : ""), p.help + (p.default !== void 0 ? ` [default: ${p.default}]` : "") + (p.values ? ` [possible values: ${p.values.join(", ")}]` : "")]))}
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
out += `
|
|
60
|
+
Options:
|
|
61
|
+
${table([...command.options, ...grammar.globals, HELP].map((o) => [optionLabel(o), describe(o)]))}
|
|
62
|
+
`;
|
|
63
|
+
if (command.afterHelp) out += `
|
|
64
|
+
${command.afterHelp}
|
|
65
|
+
`;
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
function longHelp(grammar, command) {
|
|
69
|
+
const entry = (label, text, notes) => ` ${label}
|
|
70
|
+
${text}
|
|
71
|
+
${notes.length ? `
|
|
72
|
+
${notes.map((n) => ` ${n}
|
|
73
|
+
`).join("")}` : ""}`;
|
|
74
|
+
const notesOf = (o) => [...o.default !== void 0 ? [`[default: ${o.default}]`] : [], ...o.values ? [`[possible values: ${o.values.join(", ")}]`] : []];
|
|
75
|
+
let out = `${command.about}
|
|
76
|
+
|
|
77
|
+
${usageOf(grammar, command)}
|
|
78
|
+
`;
|
|
79
|
+
if (command.positionals.length) {
|
|
80
|
+
out += `
|
|
81
|
+
Arguments:
|
|
82
|
+
${command.positionals.map((p) => entry((p.required ? `<${p.name}>` : `[${p.name}]`) + (p.many ? "..." : ""), p.help, notesOf(p))).join("\n")}`;
|
|
83
|
+
}
|
|
84
|
+
out += `
|
|
85
|
+
Options:
|
|
86
|
+
${[...command.options, ...grammar.globals, HELP].map((o) => entry(optionLabel(o), o.help, notesOf(o))).join("\n")}`;
|
|
87
|
+
if (command.afterHelp) out += `
|
|
88
|
+
${command.afterHelp}
|
|
89
|
+
`;
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
function jaro(a, b) {
|
|
93
|
+
if (a === b) return 1;
|
|
94
|
+
if (!a.length || !b.length) return 0;
|
|
95
|
+
const range = Math.max(0, Math.floor(Math.max(a.length, b.length) / 2) - 1);
|
|
96
|
+
const inA = new Array(a.length).fill(false), inB = new Array(b.length).fill(false);
|
|
97
|
+
let matches = 0;
|
|
98
|
+
for (let i = 0; i < a.length; i++) {
|
|
99
|
+
for (let j = Math.max(0, i - range); j < Math.min(b.length, i + range + 1); j++) {
|
|
100
|
+
if (inB[j] || a[i] !== b[j]) continue;
|
|
101
|
+
inA[i] = inB[j] = true;
|
|
102
|
+
matches++;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!matches) return 0;
|
|
107
|
+
let transpositions = 0;
|
|
108
|
+
for (let i = 0, j = 0; i < a.length; i++) {
|
|
109
|
+
if (!inA[i]) continue;
|
|
110
|
+
while (!inB[j]) j++;
|
|
111
|
+
if (a[i] !== b[j]) transpositions++;
|
|
112
|
+
j++;
|
|
113
|
+
}
|
|
114
|
+
return (matches / a.length + matches / b.length + (matches - transpositions / 2) / matches) / 3;
|
|
115
|
+
}
|
|
116
|
+
function similar(word, candidates) {
|
|
117
|
+
return candidates.map((c) => [jaro(word, c), c]).filter(([score]) => score > 0.7).sort((x, y) => x[0] - y[0]).map(([, c]) => c);
|
|
118
|
+
}
|
|
119
|
+
var tail = "For more information, try '--help'.\n";
|
|
120
|
+
function similarValue(value, values) {
|
|
121
|
+
const like = similar(value, values).pop();
|
|
122
|
+
return like ? ` tip: a similar value exists: '${like}'
|
|
123
|
+
|
|
124
|
+
` : "";
|
|
125
|
+
}
|
|
126
|
+
function parse(grammar, argv) {
|
|
127
|
+
const out = { command: void 0, options: {}, positionals: [] };
|
|
128
|
+
let command;
|
|
129
|
+
const find = (test) => command?.options.find(test) ?? grammar.globals.find(test) ?? [HELP, ...command ? [] : [VERSION]].find(test);
|
|
130
|
+
const usage = () => usageOf(grammar, command);
|
|
131
|
+
const used = [];
|
|
132
|
+
const usageUsed = (also) => {
|
|
133
|
+
const shown = [...used];
|
|
134
|
+
if (also) {
|
|
135
|
+
const named = `--${also.long}${also.value ? ` <${also.value}>` : ""}`;
|
|
136
|
+
if (!shown.includes(named)) shown.push(named);
|
|
137
|
+
}
|
|
138
|
+
if (!command) return shown.length ? `Usage: ${grammar.name} ${shown.join(" ")}` : usage();
|
|
139
|
+
if (!shown.length && !out.positionals.length) return usage();
|
|
140
|
+
const args = command.positionals.map((p, i) => p.required || i < out.positionals.length ? `<${p.name}>` : `[${p.name}]`);
|
|
141
|
+
return `Usage: ${grammar.name} ${command.name} ${[...shown, ...args].join(" ")}`;
|
|
142
|
+
};
|
|
143
|
+
const required = (option) => new UsageError(`error: a value is required for '--${option.long} <${option.value}>' but none was supplied
|
|
144
|
+
|
|
145
|
+
${tail}`);
|
|
146
|
+
const set = (option, value, shown) => {
|
|
147
|
+
if (option === HELP) throw new Printed(help(grammar, command));
|
|
148
|
+
if (option === VERSION) throw new Printed(`${grammar.name} ${grammar.version}
|
|
149
|
+
`);
|
|
150
|
+
if (typeof value === "string") {
|
|
151
|
+
const label = `'--${option.long} <${option.value}>'`;
|
|
152
|
+
if (value === "" && option.path) throw required(option);
|
|
153
|
+
if (option.values && !option.values.includes(value)) throw new UsageError(`error: invalid value '${value}' for ${label}
|
|
154
|
+
[possible values: ${option.values.join(", ")}]
|
|
155
|
+
|
|
156
|
+
${similarValue(value, option.values)}${tail}`);
|
|
157
|
+
const wrong = option.check?.(value);
|
|
158
|
+
if (wrong !== void 0) throw new UsageError(`error: invalid value '${value}' for ${label}: ${wrong}
|
|
159
|
+
|
|
160
|
+
${tail}`);
|
|
161
|
+
}
|
|
162
|
+
if (option.many) {
|
|
163
|
+
const list = out.options[option.long] ??= [];
|
|
164
|
+
list.push(value);
|
|
165
|
+
} else {
|
|
166
|
+
if (option.long in out.options) throw new UsageError(`error: the argument '${shown}' cannot be used multiple times
|
|
167
|
+
|
|
168
|
+
${usage()}
|
|
169
|
+
|
|
170
|
+
${tail}`);
|
|
171
|
+
out.options[option.long] = value;
|
|
172
|
+
}
|
|
173
|
+
const named = `--${option.long}${option.value ? ` <${option.value}>` : ""}`;
|
|
174
|
+
if (!used.includes(named)) used.push(named);
|
|
175
|
+
};
|
|
176
|
+
const unexpected = (arg, tips, line) => {
|
|
177
|
+
const flag = arg.startsWith("--") ? arg.split("=")[0] : arg;
|
|
178
|
+
const body = tips.length ? `${tips.map((t) => ` tip: ${t}`).join("\n")}
|
|
179
|
+
|
|
180
|
+
` : "";
|
|
181
|
+
throw new UsageError(`error: unexpected argument '${flag}' found
|
|
182
|
+
|
|
183
|
+
${body}${line}
|
|
184
|
+
|
|
185
|
+
${tail}`, arg.startsWith("-") ? { word: flag, kind: "flag" } : void 0);
|
|
186
|
+
};
|
|
187
|
+
const unknownCommand = (arg) => {
|
|
188
|
+
const like = similar(arg, grammar.commands.filter((c) => !c.hidden).map((c) => c.name));
|
|
189
|
+
const tip = like.length === 1 ? ` tip: a similar subcommand exists: '${like[0]}'
|
|
190
|
+
|
|
191
|
+
` : like.length ? ` tip: some similar subcommands exist: ${like.map((c) => `'${c}'`).join(", ")}
|
|
192
|
+
|
|
193
|
+
` : "";
|
|
194
|
+
throw new UsageError(`error: unrecognized subcommand '${arg}'
|
|
195
|
+
|
|
196
|
+
${tip}${usage()}
|
|
197
|
+
|
|
198
|
+
${tail}`, { word: arg, kind: "command" });
|
|
199
|
+
};
|
|
200
|
+
const valueAfter = (option, at) => {
|
|
201
|
+
const next = argv[at + 1];
|
|
202
|
+
if (next === void 0 || next === "--") throw required(option);
|
|
203
|
+
if (!next.startsWith("-") || next === "-") return next;
|
|
204
|
+
const name = next.split("=")[0];
|
|
205
|
+
if (find((o) => name.startsWith("--") ? o.long === name.slice(2) : o.short === name[1])) throw required(option);
|
|
206
|
+
return unexpected(next, command?.positionals.length ? [`to pass '${next}' as a value, use '-- ${next}'`] : [], next.startsWith("--") ? usageUsed() : usage());
|
|
207
|
+
};
|
|
208
|
+
let onlyPositionals = false;
|
|
209
|
+
for (let i = 0; i < argv.length; i++) {
|
|
210
|
+
const arg = argv[i];
|
|
211
|
+
if (command?.raw) {
|
|
212
|
+
out.positionals.push(arg);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (onlyPositionals || arg === "-" || !arg.startsWith("-")) {
|
|
216
|
+
if (!command && onlyPositionals) {
|
|
217
|
+
if (arg === "help" || grammar.commands.some((c) => c.name === arg)) throw new UsageError(`error: unexpected argument '${arg}' found
|
|
218
|
+
|
|
219
|
+
tip: subcommand '${arg}' exists; to use it, remove the '--' before it
|
|
220
|
+
|
|
221
|
+
${usage()}
|
|
222
|
+
|
|
223
|
+
${tail}`);
|
|
224
|
+
unknownCommand(arg);
|
|
225
|
+
}
|
|
226
|
+
if (!command && !onlyPositionals) {
|
|
227
|
+
if (arg === "help") {
|
|
228
|
+
const name = argv[i + 1];
|
|
229
|
+
if (name === "help") throw new Printed(`Print this message or the help of the given subcommand(s)
|
|
230
|
+
|
|
231
|
+
Usage: ${grammar.name} help [COMMAND]...
|
|
232
|
+
|
|
233
|
+
Arguments:
|
|
234
|
+
[COMMAND]... Print help for the subcommand(s)
|
|
235
|
+
`);
|
|
236
|
+
const about = name === void 0 ? void 0 : grammar.commands.find((c) => c.name === name);
|
|
237
|
+
if (name !== void 0 && !about) throw new UsageError(`error: unrecognized subcommand '${name}'
|
|
238
|
+
|
|
239
|
+
${usage()}
|
|
240
|
+
|
|
241
|
+
${tail}`);
|
|
242
|
+
const more = argv[i + 2];
|
|
243
|
+
if (about && more !== void 0) throw new UsageError(`error: unrecognized subcommand '${more}'
|
|
244
|
+
|
|
245
|
+
${usageOf(grammar, about)}
|
|
246
|
+
|
|
247
|
+
${tail}`);
|
|
248
|
+
throw new Printed(help(grammar, about));
|
|
249
|
+
}
|
|
250
|
+
command = grammar.commands.find((c) => c.name === arg) ?? unknownCommand(arg);
|
|
251
|
+
out.command = command.name;
|
|
252
|
+
used.length = 0;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (!command || out.positionals.length >= command.positionals.length && !command.positionals.at(-1)?.many) unexpected(arg, [], usage());
|
|
256
|
+
const positional = command.positionals[Math.min(out.positionals.length, command.positionals.length - 1)];
|
|
257
|
+
if (arg === "" && positional.path) throw new UsageError(`error: a value is required for '${positional.required ? `<${positional.name}>` : `[${positional.name}]`}' but none was supplied
|
|
258
|
+
|
|
259
|
+
${tail}`);
|
|
260
|
+
if (positional.values && !positional.values.includes(arg)) throw new UsageError(`error: invalid value '${arg}' for '<${positional.name}>'
|
|
261
|
+
[possible values: ${positional.values.join(", ")}]
|
|
262
|
+
|
|
263
|
+
${similarValue(arg, positional.values)}${tail}`);
|
|
264
|
+
out.positionals.push(arg);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (arg === "--") {
|
|
268
|
+
onlyPositionals = true;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (arg.startsWith("--")) {
|
|
272
|
+
const eq = arg.indexOf("=");
|
|
273
|
+
const name = eq === -1 ? arg.slice(2) : arg.slice(2, eq);
|
|
274
|
+
const option = find((o) => o.long === name);
|
|
275
|
+
if (!option) {
|
|
276
|
+
const longs = [...command?.options ?? [], ...grammar.globals, HELP].map((o) => o.long);
|
|
277
|
+
const like = similar(name, longs).pop();
|
|
278
|
+
const suggested = like === void 0 ? void 0 : find((o) => o.long === like);
|
|
279
|
+
unexpected(arg, like ? [`a similar argument exists: '--${like}'`] : command?.positionals.length ? [`to pass '${arg}' as a value, use '-- ${arg}'`] : [], usageUsed(suggested));
|
|
280
|
+
}
|
|
281
|
+
if (!option.value) {
|
|
282
|
+
if (eq !== -1) {
|
|
283
|
+
if (!used.includes(`--${name}`)) used.push(`--${name}`);
|
|
284
|
+
throw new UsageError(`error: unexpected value '${arg.slice(eq + 1)}' for '--${name}' found; no more were expected
|
|
285
|
+
|
|
286
|
+
${usageUsed()}
|
|
287
|
+
|
|
288
|
+
${tail}`);
|
|
289
|
+
}
|
|
290
|
+
set(option, true, `--${name}`);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
let value = eq === -1 ? void 0 : arg.slice(eq + 1);
|
|
294
|
+
if (value === void 0) value = valueAfter(option, i++);
|
|
295
|
+
set(option, value, `--${name} <${option.value}>`);
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
for (let j = 1; j < arg.length; j++) {
|
|
299
|
+
const letter = arg[j];
|
|
300
|
+
const option = find((o) => o.short === letter);
|
|
301
|
+
if (!option) {
|
|
302
|
+
const word = `-${letter}`;
|
|
303
|
+
unexpected(word, command?.positionals.length ? [`to pass '${word}' as a value, use '-- ${word}'`] : [], usage());
|
|
304
|
+
}
|
|
305
|
+
if (!option.value) {
|
|
306
|
+
set(option, true, `--${option.long}`);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
let value = arg.slice(j + 1);
|
|
310
|
+
if (value.startsWith("=")) value = value.slice(1);
|
|
311
|
+
if (value === "") value = valueAfter(option, i++);
|
|
312
|
+
set(option, value, `--${option.long} <${option.value}>`);
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (command && !command.raw) {
|
|
317
|
+
const missing = command.positionals.slice(out.positionals.length).filter((p) => p.required);
|
|
318
|
+
const needed = `Usage: ${grammar.name} ${command.name} ${[...used, ...command.positionals.map((p) => p.required ? `<${p.name}>` : `[${p.name}]`)].join(" ")}`;
|
|
319
|
+
if (missing.length) throw new UsageError(`error: the following required arguments were not provided:
|
|
320
|
+
${missing.map((p) => ` <${p.name}>`).join("\n")}
|
|
321
|
+
|
|
322
|
+
${needed}
|
|
323
|
+
|
|
324
|
+
${tail}`);
|
|
325
|
+
}
|
|
326
|
+
return out;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export {
|
|
330
|
+
UsageError,
|
|
331
|
+
Printed,
|
|
332
|
+
longHelp,
|
|
333
|
+
parse
|
|
334
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/suggest.ts
|
|
5
|
+
function closest(key, candidates) {
|
|
6
|
+
let best;
|
|
7
|
+
let bestEdits = Infinity;
|
|
8
|
+
for (const candidate of candidates) {
|
|
9
|
+
const edits = editDistance(key, candidate);
|
|
10
|
+
if (edits <= 2 && edits < candidate.length && edits < bestEdits) {
|
|
11
|
+
best = candidate;
|
|
12
|
+
bestEdits = edits;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return best;
|
|
16
|
+
}
|
|
17
|
+
function closestPath(wanted, candidates) {
|
|
18
|
+
const trimmedWanted = wanted.replace(/\/+$/, "");
|
|
19
|
+
const length = [...trimmedWanted].length;
|
|
20
|
+
let best;
|
|
21
|
+
let bestEdits = Infinity;
|
|
22
|
+
for (const candidate of candidates) {
|
|
23
|
+
const trimmed = candidate.replace(/\/+$/, "");
|
|
24
|
+
const candidateLength = [...trimmed].length;
|
|
25
|
+
if (Math.abs(candidateLength - length) > 3 || trimmed === trimmedWanted) continue;
|
|
26
|
+
const edits = editDistance(trimmedWanted, trimmed);
|
|
27
|
+
if (edits <= 3 && edits * 3 <= candidateLength && edits < bestEdits) {
|
|
28
|
+
best = candidate;
|
|
29
|
+
bestEdits = edits;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return best;
|
|
33
|
+
}
|
|
34
|
+
function closestPathFinder(candidates) {
|
|
35
|
+
const byLength = /* @__PURE__ */ new Map();
|
|
36
|
+
let order = 0;
|
|
37
|
+
for (const candidate of candidates) {
|
|
38
|
+
const trimmed = candidate.replace(/\/+$/, "");
|
|
39
|
+
const length = codePoints(trimmed);
|
|
40
|
+
let bucket = byLength.get(length);
|
|
41
|
+
if (bucket === void 0) byLength.set(length, bucket = []);
|
|
42
|
+
bucket.push({ order: order++, candidate, trimmed, chars: void 0 });
|
|
43
|
+
}
|
|
44
|
+
return (wanted) => {
|
|
45
|
+
const trimmedWanted = wanted.replace(/\/+$/, "");
|
|
46
|
+
const length = codePoints(trimmedWanted);
|
|
47
|
+
const chars = lowerCodePoints(trimmedWanted);
|
|
48
|
+
let best;
|
|
49
|
+
let bestEdits = Infinity;
|
|
50
|
+
let bestOrder = Infinity;
|
|
51
|
+
for (let candidateLength = Math.max(0, length - 3); candidateLength <= length + 3; candidateLength++) {
|
|
52
|
+
for (const c of byLength.get(candidateLength) ?? []) {
|
|
53
|
+
if (c.trimmed === trimmedWanted) continue;
|
|
54
|
+
c.chars ??= lowerCodePoints(c.trimmed);
|
|
55
|
+
const edits = editsWithin(chars, c.chars, 3);
|
|
56
|
+
if (edits <= 3 && edits * 3 <= candidateLength && (edits < bestEdits || edits === bestEdits && c.order < bestOrder)) {
|
|
57
|
+
best = c.candidate;
|
|
58
|
+
bestEdits = edits;
|
|
59
|
+
bestOrder = c.order;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return best;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function codePoints(s) {
|
|
67
|
+
let n = s.length;
|
|
68
|
+
for (let i = 0; i < s.length; i++) {
|
|
69
|
+
const c = s.charCodeAt(i);
|
|
70
|
+
if (c >= 55296 && c <= 56319 && i + 1 < s.length && (s.charCodeAt(i + 1) & 64512) === 56320) {
|
|
71
|
+
n--;
|
|
72
|
+
i++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return n;
|
|
76
|
+
}
|
|
77
|
+
var lowerCodePoints = (s) => Array.from(s.toLowerCase(), (c) => c.codePointAt(0));
|
|
78
|
+
function editsWithin(x, y, limit) {
|
|
79
|
+
if (Math.abs(x.length - y.length) > limit) return limit + 1;
|
|
80
|
+
const row = new Int32Array(y.length + 1);
|
|
81
|
+
for (let j = 0; j <= y.length; j++) row[j] = j;
|
|
82
|
+
for (let i = 0; i < x.length; i++) {
|
|
83
|
+
let previous = row[0];
|
|
84
|
+
row[0] = i + 1;
|
|
85
|
+
let least = row[0];
|
|
86
|
+
for (let j = 0; j < y.length; j++) {
|
|
87
|
+
const current = row[j + 1];
|
|
88
|
+
row[j + 1] = x[i] === y[j] ? previous : 1 + Math.min(previous, current, row[j]);
|
|
89
|
+
previous = current;
|
|
90
|
+
if (row[j + 1] < least) least = row[j + 1];
|
|
91
|
+
}
|
|
92
|
+
if (least > limit) return limit + 1;
|
|
93
|
+
}
|
|
94
|
+
return row[y.length];
|
|
95
|
+
}
|
|
96
|
+
function editDistance(a, b) {
|
|
97
|
+
const x = [...a.toLowerCase()], y = [...b.toLowerCase()];
|
|
98
|
+
const row = Array.from({ length: y.length + 1 }, (_, i) => i);
|
|
99
|
+
for (let i = 0; i < x.length; i++) {
|
|
100
|
+
let previous = row[0];
|
|
101
|
+
row[0] = i + 1;
|
|
102
|
+
for (let j = 0; j < y.length; j++) {
|
|
103
|
+
const current = row[j + 1];
|
|
104
|
+
row[j + 1] = x[i] === y[j] ? previous : 1 + Math.min(previous, current, row[j]);
|
|
105
|
+
previous = current;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return row[y.length];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
closest,
|
|
113
|
+
closestPath,
|
|
114
|
+
closestPathFinder
|
|
115
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
OUTPUT_LIST,
|
|
5
|
+
asTextForTest,
|
|
6
|
+
build,
|
|
7
|
+
edgeCodeMentionsForTest,
|
|
8
|
+
inEdgeCode,
|
|
9
|
+
inspectPages,
|
|
10
|
+
runCommand,
|
|
11
|
+
sameContentsForTest
|
|
12
|
+
} from "./chunk-BOBPVAX2.js";
|
|
13
|
+
import {
|
|
14
|
+
commandLine,
|
|
15
|
+
toolPath
|
|
16
|
+
} from "./chunk-4Q6WMTER.js";
|
|
17
|
+
import "./chunk-RI2L3VGO.js";
|
|
18
|
+
import "./chunk-3PHCFZEU.js";
|
|
19
|
+
import "./chunk-TN6EEDX2.js";
|
|
20
|
+
import "./chunk-IRHRK7XB.js";
|
|
21
|
+
import "./chunk-NKXEPHRZ.js";
|
|
22
|
+
import "./chunk-AD3HAW3W.js";
|
|
23
|
+
import "./chunk-DDV6JEC2.js";
|
|
24
|
+
import "./chunk-EIT4ZDT4.js";
|
|
25
|
+
import "./chunk-FVZ5JBRI.js";
|
|
26
|
+
import "./chunk-TDGBQNGW.js";
|
|
27
|
+
import "./chunk-UU43WIZG.js";
|
|
28
|
+
import "./chunk-C35KIPAR.js";
|
|
29
|
+
import "./chunk-CMUWRPSQ.js";
|
|
30
|
+
import "./chunk-6XYSFG6V.js";
|
|
31
|
+
import "./chunk-VJWQSYEG.js";
|
|
32
|
+
import "./chunk-I3PS26CI.js";
|
|
33
|
+
export {
|
|
34
|
+
OUTPUT_LIST,
|
|
35
|
+
asTextForTest,
|
|
36
|
+
build,
|
|
37
|
+
commandLine,
|
|
38
|
+
edgeCodeMentionsForTest,
|
|
39
|
+
inEdgeCode,
|
|
40
|
+
inspectPages,
|
|
41
|
+
runCommand,
|
|
42
|
+
sameContentsForTest,
|
|
43
|
+
toolPath
|
|
44
|
+
};
|
|
@@ -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-BOBPVAX2.js";
|
|
6
|
+
import "./chunk-4Q6WMTER.js";
|
|
7
|
+
import "./chunk-RI2L3VGO.js";
|
|
8
|
+
import "./chunk-3PHCFZEU.js";
|
|
9
|
+
import "./chunk-TN6EEDX2.js";
|
|
10
|
+
import "./chunk-IRHRK7XB.js";
|
|
11
|
+
import {
|
|
12
|
+
count
|
|
13
|
+
} from "./chunk-NKXEPHRZ.js";
|
|
14
|
+
import "./chunk-AD3HAW3W.js";
|
|
15
|
+
import "./chunk-DDV6JEC2.js";
|
|
16
|
+
import "./chunk-EIT4ZDT4.js";
|
|
17
|
+
import "./chunk-FVZ5JBRI.js";
|
|
18
|
+
import "./chunk-TDGBQNGW.js";
|
|
19
|
+
import "./chunk-UU43WIZG.js";
|
|
20
|
+
import "./chunk-C35KIPAR.js";
|
|
21
|
+
import "./chunk-CMUWRPSQ.js";
|
|
22
|
+
import "./chunk-6XYSFG6V.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,44 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
BUILTINS,
|
|
5
|
+
DEFAULTS,
|
|
6
|
+
configOptions,
|
|
7
|
+
findConfig,
|
|
8
|
+
loadConfig,
|
|
9
|
+
meant,
|
|
10
|
+
tomlKeyLine
|
|
11
|
+
} from "./chunk-TN6EEDX2.js";
|
|
12
|
+
import "./chunk-IRHRK7XB.js";
|
|
13
|
+
import "./chunk-NKXEPHRZ.js";
|
|
14
|
+
import "./chunk-AD3HAW3W.js";
|
|
15
|
+
import {
|
|
16
|
+
CONFIG_FILES,
|
|
17
|
+
dirsOf,
|
|
18
|
+
parseEnvironment,
|
|
19
|
+
shownDir,
|
|
20
|
+
shownOutput
|
|
21
|
+
} from "./chunk-DDV6JEC2.js";
|
|
22
|
+
import "./chunk-EIT4ZDT4.js";
|
|
23
|
+
import "./chunk-FVZ5JBRI.js";
|
|
24
|
+
import "./chunk-TDGBQNGW.js";
|
|
25
|
+
import "./chunk-UU43WIZG.js";
|
|
26
|
+
import "./chunk-C35KIPAR.js";
|
|
27
|
+
import "./chunk-CMUWRPSQ.js";
|
|
28
|
+
import "./chunk-6XYSFG6V.js";
|
|
29
|
+
import "./chunk-VJWQSYEG.js";
|
|
30
|
+
import "./chunk-I3PS26CI.js";
|
|
31
|
+
export {
|
|
32
|
+
BUILTINS,
|
|
33
|
+
CONFIG_FILES,
|
|
34
|
+
DEFAULTS,
|
|
35
|
+
configOptions,
|
|
36
|
+
dirsOf,
|
|
37
|
+
findConfig,
|
|
38
|
+
loadConfig,
|
|
39
|
+
meant,
|
|
40
|
+
parseEnvironment,
|
|
41
|
+
shownDir,
|
|
42
|
+
shownOutput,
|
|
43
|
+
tomlKeyLine
|
|
44
|
+
};
|