mirrorbook 0.6.0 → 0.7.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 (3) hide show
  1. package/SKILL.md +12 -2
  2. package/dist/cli.js +370 -3
  3. package/package.json +8 -9
package/SKILL.md CHANGED
@@ -21,7 +21,7 @@ npx mirrorbook deploy ./dist --slug my-demo --wait --json
21
21
  - If the slug is taken by someone else, a 4-character suffix is added (`demo` → `demo-k3x9`) and `slugAdjusted` is `true`. Always read the final `url`/`slug` from the output. Re-deploying with the original `--slug demo` keeps updating that same `demo-k3x9` site. Pass `--strict-slug` to fail (exit 2, `slug_taken`) instead.
22
22
  - Output (with `--json`): `{"url","previewUrl","slug","deploymentId","status","error","errorCode","errorParams","number","created","requestedSlug","slugAdjusted","lockTitle","lockMessage"}`.
23
23
  - When `status` is `failed`, `errorCode` says why: `missing_index` (no index.html at the zip root), `zip_invalid`, `zip_path_invalid`, `zip_encrypted`, `file_too_large`, `unzipped_too_large`, `too_many_files`, `quota_exceeded`, `upload_missing`, `file_read_failed`, `owner_missing`, `processing_failed`.
24
- - Sites go live as soon as processing finishes (`status: "approved"`); admins review afterwards and may take a version down (`rejected`). A new account needs admin approval once before it can publish (exit 3, `pending_approval`).
24
+ - Sites go live as soon as processing finishes (`status: "approved"`); admins review afterwards and may take a version down (`rejected`). A new account has to be approved once before it can publish (exit 3, `pending_approval`): it is approved automatically when the user clicks the verification link emailed at sign-up, otherwise an admin approves it.
25
25
  - Each account has a site limit (default 10) and a storage quota (default 100 MB); going over exits with 4 (`quota_exceeded`).
26
26
 
27
27
  Exit codes: 0 ok · 2 usage (bad path or slug) · 3 auth (missing token, account pending) · 4 quota · 5 failed or rejected.
@@ -40,6 +40,16 @@ npx mirrorbook access my-demo --clear-lock # back to the default copy
40
40
 
41
41
  The copy only appears on password-protected sites — setting it on a site with no password stores it but visitors never see it (the CLI prints a `note:` line in that case). Passing the option alone is enough to change it; you don't need to re-supply `--password`.
42
42
 
43
+ Cover: each site can have its own cover image, shown on site lists, picks and the author's profile. It must be an SVG (max 32 KB, 16:10 works best, e.g. `viewBox="0 0 320 200"`). Scripts, event handlers, links and external images/fonts are stripped; for dark mode use `@media (prefers-color-scheme: dark)` inside `<style>`. Without one, a pattern generated from the slug is shown.
44
+
45
+ ```bash
46
+ npx mirrorbook cover my-demo cover.svg # set (or - to read stdin)
47
+ npx mirrorbook deploy ./dist --slug my-demo --cover cover.svg
48
+ npx mirrorbook cover my-demo --remove # back to the default pattern
49
+ ```
50
+
51
+ An invalid SVG exits with 2 before anything is uploaded. `--json` returns `coverUrl` and `dropped` (what was removed).
52
+
43
53
  Install this skill for Claude Code with `npx mirrorbook skill --install` (or `--dir ./.claude/skills` for one project); `mirrorbook skill` prints it.
44
54
 
45
- Other commands: `pull <slug> [version] [-o file.zip]` (download a version's files as a zip; owner only, defaults to the live version), `access <slug>`, `ls` (shows each entry's kind: `site` or `collection`; collections are curated pages made in the console and can't be deployed to), `status <slug>` (lists versions, or the member sites of a collection), `rollback <slug> <version>` (alias `set-default`; version is `3`, `#3`, or a deployment id), `rm-version <slug> <version> --yes`, `rm <slug> --yes`, `whoami`. Add `--json` to any of them.
55
+ Other commands: `pull <slug> [version] [-o file.zip]` (download a version's files as a zip; owner only, defaults to the live version), `access <slug>`, `cover <slug> [file.svg] [--remove]`, `ls` (shows each entry's kind: `site` or `collection`; collections are curated pages made in the console and can't be deployed to), `status <slug>` (lists versions, or the member sites of a collection), `rollback <slug> <version>` (alias `set-default`; version is `3`, `#3`, or a deployment id), `rm-version <slug> <version> --yes`, `rm <slug> --yes`, `whoami`. Add `--json` to any of them.
package/dist/cli.js CHANGED
@@ -72,6 +72,320 @@ var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".svn", ".hg",
72
72
  var SKIP_FILES = /* @__PURE__ */ new Set([".DS_Store", "Thumbs.db", ".env"]);
73
73
  var isSkippedFile = (name) => SKIP_FILES.has(name) || name.startsWith(".env.");
74
74
 
75
+ // ../shared/src/cover-svg.ts
76
+ var COVER_MAX_BYTES = 32 * 1024;
77
+ var MAX_ELEMENTS = 2e3;
78
+ var MAX_DEPTH = 48;
79
+ var ELEMENTS = /* @__PURE__ */ new Set([
80
+ "svg",
81
+ "g",
82
+ "defs",
83
+ "symbol",
84
+ "use",
85
+ "title",
86
+ "desc",
87
+ "style",
88
+ "path",
89
+ "rect",
90
+ "circle",
91
+ "ellipse",
92
+ "line",
93
+ "polyline",
94
+ "polygon",
95
+ "text",
96
+ "tspan",
97
+ "linearGradient",
98
+ "radialGradient",
99
+ "stop",
100
+ "pattern",
101
+ "clipPath",
102
+ "mask",
103
+ "marker",
104
+ "filter",
105
+ "feBlend",
106
+ "feColorMatrix",
107
+ "feComponentTransfer",
108
+ "feComposite",
109
+ "feFlood",
110
+ "feGaussianBlur",
111
+ "feMerge",
112
+ "feMergeNode",
113
+ "feMorphology",
114
+ "feOffset",
115
+ "feTurbulence",
116
+ "feDisplacementMap",
117
+ "feFuncR",
118
+ "feFuncG",
119
+ "feFuncB",
120
+ "feFuncA",
121
+ "feDropShadow"
122
+ ]);
123
+ var ATTRS = /* @__PURE__ */ new Set([
124
+ // 通用
125
+ "id",
126
+ "class",
127
+ "style",
128
+ "transform",
129
+ "opacity",
130
+ "visibility",
131
+ "display",
132
+ // 布局 / 几何
133
+ "viewBox",
134
+ "preserveAspectRatio",
135
+ "width",
136
+ "height",
137
+ "x",
138
+ "y",
139
+ "x1",
140
+ "y1",
141
+ "x2",
142
+ "y2",
143
+ "cx",
144
+ "cy",
145
+ "r",
146
+ "rx",
147
+ "ry",
148
+ "fx",
149
+ "fy",
150
+ "fr",
151
+ "d",
152
+ "points",
153
+ "pathLength",
154
+ // 填充 / 描边
155
+ "fill",
156
+ "fill-opacity",
157
+ "fill-rule",
158
+ "stroke",
159
+ "stroke-width",
160
+ "stroke-opacity",
161
+ "stroke-linecap",
162
+ "stroke-linejoin",
163
+ "stroke-miterlimit",
164
+ "stroke-dasharray",
165
+ "stroke-dashoffset",
166
+ "vector-effect",
167
+ "color",
168
+ "paint-order",
169
+ "shape-rendering",
170
+ "mix-blend-mode",
171
+ "isolation",
172
+ "clip-path",
173
+ "clip-rule",
174
+ "mask",
175
+ "filter",
176
+ "marker-start",
177
+ "marker-mid",
178
+ "marker-end",
179
+ // 文字
180
+ "font-family",
181
+ "font-size",
182
+ "font-weight",
183
+ "font-style",
184
+ "font-variant",
185
+ "letter-spacing",
186
+ "word-spacing",
187
+ "text-anchor",
188
+ "dominant-baseline",
189
+ "alignment-baseline",
190
+ "baseline-shift",
191
+ "text-decoration",
192
+ "writing-mode",
193
+ "dx",
194
+ "dy",
195
+ "rotate",
196
+ "textLength",
197
+ "lengthAdjust",
198
+ "xml:space",
199
+ // 渐变 / 图案 / 遮罩 / 标记
200
+ "offset",
201
+ "stop-color",
202
+ "stop-opacity",
203
+ "gradientUnits",
204
+ "gradientTransform",
205
+ "spreadMethod",
206
+ "patternUnits",
207
+ "patternContentUnits",
208
+ "patternTransform",
209
+ "clipPathUnits",
210
+ "maskUnits",
211
+ "maskContentUnits",
212
+ "markerWidth",
213
+ "markerHeight",
214
+ "markerUnits",
215
+ "refX",
216
+ "refY",
217
+ "orient",
218
+ // 滤镜
219
+ "filterUnits",
220
+ "primitiveUnits",
221
+ "in",
222
+ "in2",
223
+ "result",
224
+ "mode",
225
+ "type",
226
+ "values",
227
+ "stdDeviation",
228
+ "operator",
229
+ "k1",
230
+ "k2",
231
+ "k3",
232
+ "k4",
233
+ "flood-color",
234
+ "flood-opacity",
235
+ "baseFrequency",
236
+ "numOctaves",
237
+ "seed",
238
+ "stitchTiles",
239
+ "scale",
240
+ "xChannelSelector",
241
+ "yChannelSelector",
242
+ "radius",
243
+ "tableValues",
244
+ "slope",
245
+ "intercept",
246
+ "amplitude",
247
+ "exponent",
248
+ "color-interpolation-filters",
249
+ // 引用:只允许指向文档内部的 #id,下面单独检查
250
+ "href",
251
+ "xlink:href"
252
+ ]);
253
+ var NS_ATTRS = /* @__PURE__ */ new Set(["xmlns", "xmlns:xlink", "version"]);
254
+ var NAME = /^[A-Za-z_][\w.:-]*$/;
255
+ var ENTITY = /&(?:amp|lt|gt|quot|apos|#\d{1,7}|#x[0-9a-fA-F]{1,6});/g;
256
+ function cssSafe(css) {
257
+ if (/@import|expression\s*\(|\\|javascript:/i.test(css)) return false;
258
+ for (const m of css.matchAll(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gi)) {
259
+ if (!/^#[\w.:-]+$/.test(m[2])) return false;
260
+ }
261
+ return !/url\s*\(/i.test(css.replace(/url\s*\(\s*(['"]?)#[\w.:-]+\1\s*\)/gi, ""));
262
+ }
263
+ function textSafe(s) {
264
+ return !s.includes("<") && !s.replace(ENTITY, "").includes("&");
265
+ }
266
+ var escAttr = (v) => v.replace(/"/g, "&quot;");
267
+ function parseAttrs(src) {
268
+ const out2 = [];
269
+ const re = /\s*([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/y;
270
+ let i = 0;
271
+ while (i < src.length) {
272
+ if (/^\s*$/.test(src.slice(i))) break;
273
+ re.lastIndex = i;
274
+ const m = re.exec(src);
275
+ if (!m) return null;
276
+ out2.push([m[1], m[2] ?? m[3] ?? ""]);
277
+ i = re.lastIndex;
278
+ }
279
+ return out2;
280
+ }
281
+ function sanitizeCoverSvg(input) {
282
+ const src = input.replace(/^/, "").trim();
283
+ if (!src) return { ok: false, error: "empty" };
284
+ if (new TextEncoder().encode(src).length > COVER_MAX_BYTES) return { ok: false, error: "too_large" };
285
+ const out2 = [];
286
+ const dropped = /* @__PURE__ */ new Set();
287
+ const stack = [];
288
+ let elements = 0;
289
+ let sawRoot = false;
290
+ let rootClosed = false;
291
+ let i = 0;
292
+ const skipping = () => stack.some((s) => s.skip);
293
+ const fail = (error, detail) => ({ ok: false, error, detail });
294
+ while (i < src.length) {
295
+ const lt = src.indexOf("<", i);
296
+ const text = src.slice(i, lt === -1 ? src.length : lt);
297
+ if (text) {
298
+ if (!textSafe(text)) return fail("parse_error", "bad text");
299
+ if (stack.length === 0) {
300
+ if (text.trim()) return fail("parse_error", "text outside <svg>");
301
+ } else if (!skipping()) {
302
+ const cur = stack[stack.length - 1].name;
303
+ if (cur === "style" && !cssSafe(text)) return fail("parse_error", "unsafe css");
304
+ out2.push(text);
305
+ }
306
+ }
307
+ if (lt === -1) break;
308
+ i = lt;
309
+ if (src.startsWith("<!--", i)) {
310
+ const end = src.indexOf("-->", i + 4);
311
+ if (end === -1) return fail("parse_error", "unclosed comment");
312
+ i = end + 3;
313
+ continue;
314
+ }
315
+ if (src.startsWith("<?", i)) {
316
+ if (sawRoot || !/^<\?xml[\s?]/.test(src.slice(i, i + 6))) return fail("parse_error", "processing instruction");
317
+ const end = src.indexOf("?>", i);
318
+ if (end === -1) return fail("parse_error", "unclosed declaration");
319
+ i = end + 2;
320
+ continue;
321
+ }
322
+ if (src.startsWith("<!", i)) {
323
+ return fail(/^<!doctype/i.test(src.slice(i, i + 9)) ? "doctype" : "parse_error", "markup declaration");
324
+ }
325
+ const gt = src.indexOf(">", i);
326
+ if (gt === -1) return fail("parse_error", "unclosed tag");
327
+ const raw = src.slice(i + 1, gt);
328
+ i = gt + 1;
329
+ if (raw.startsWith("/")) {
330
+ const name2 = raw.slice(1).trim();
331
+ const top = stack.pop();
332
+ if (!top || top.name !== name2) return fail("parse_error", `mismatched </${name2}>`);
333
+ if (!top.skip && !skipping()) out2.push(`</${name2}>`);
334
+ if (stack.length === 0) rootClosed = true;
335
+ continue;
336
+ }
337
+ const selfClose = raw.endsWith("/");
338
+ const body = selfClose ? raw.slice(0, -1) : raw;
339
+ const nameMatch = /^([^\s/>]+)/.exec(body);
340
+ if (!nameMatch || !NAME.test(nameMatch[1])) return fail("parse_error", "bad tag name");
341
+ const name = nameMatch[1];
342
+ const attrs = parseAttrs(body.slice(name.length));
343
+ if (!attrs) return fail("parse_error", `bad attributes on <${name}>`);
344
+ for (const [, v] of attrs) if (!textSafe(v)) return fail("parse_error", `bad attribute value on <${name}>`);
345
+ const tag = { name, attrs, selfClose };
346
+ if (stack.length === 0) {
347
+ if (sawRoot || rootClosed) return fail("parse_error", "more than one root element");
348
+ if (name !== "svg") return fail("not_svg");
349
+ sawRoot = true;
350
+ }
351
+ if (++elements > MAX_ELEMENTS || stack.length >= MAX_DEPTH) return fail("too_complex");
352
+ const parentSkip = skipping();
353
+ const allowed = ELEMENTS.has(name);
354
+ if (!allowed) dropped.add(`<${name}>`);
355
+ if (!parentSkip && allowed) out2.push(renderOpen(tag, stack.length === 0, dropped));
356
+ if (!selfClose) stack.push({ name, skip: !allowed });
357
+ }
358
+ if (!sawRoot) return fail("not_svg");
359
+ if (stack.length) return fail("parse_error", `unclosed <${stack[stack.length - 1].name}>`);
360
+ const svg = out2.join("");
361
+ if (!/^<svg\b[^>]*\sviewBox="/.test(svg)) return fail("no_viewbox");
362
+ return { ok: true, svg, dropped: [...dropped] };
363
+ }
364
+ function renderOpen(tag, isRoot, dropped) {
365
+ const parts = [tag.name];
366
+ if (isRoot) parts.push('xmlns="http://www.w3.org/2000/svg"', 'xmlns:xlink="http://www.w3.org/1999/xlink"');
367
+ const seen = /* @__PURE__ */ new Set();
368
+ for (const [k, v] of tag.attrs) {
369
+ if (seen.has(k)) continue;
370
+ seen.add(k);
371
+ if (NS_ATTRS.has(k)) continue;
372
+ if (!ATTRS.has(k)) {
373
+ dropped.add(k);
374
+ continue;
375
+ }
376
+ if ((k === "href" || k === "xlink:href") && !/^#[\w.:-]+$/.test(v.trim())) {
377
+ dropped.add(`${k} (external)`);
378
+ continue;
379
+ }
380
+ if (/url\s*\(|@import|expression|javascript:/i.test(v) && !cssSafe(v)) {
381
+ dropped.add(`${k} (url)`);
382
+ continue;
383
+ }
384
+ parts.push(`${k}="${escAttr(v)}"`);
385
+ }
386
+ return `<${parts.join(" ")}${tag.selfClose ? "/>" : ">"}`;
387
+ }
388
+
75
389
  // src/api.ts
76
390
  var CliError = class extends Error {
77
391
  constructor(code, message, exitCode, status) {
@@ -139,6 +453,8 @@ function createClient(apiUrl, token) {
139
453
  deployment: (id) => call("GET", `/deployments/${encodeURIComponent(id)}`),
140
454
  updateSite: (slug, body) => call("PATCH", `/sites/${encodeURIComponent(slug)}`, body),
141
455
  rollback: (slug, deploymentId) => call("POST", `/sites/${encodeURIComponent(slug)}/rollback`, { deploymentId }),
456
+ setCover: (slug, svg) => call("PUT", `/sites/${encodeURIComponent(slug)}/cover`, { svg }),
457
+ removeCover: (slug) => call("DELETE", `/sites/${encodeURIComponent(slug)}/cover`),
142
458
  remove: (slug) => call("DELETE", `/sites/${encodeURIComponent(slug)}`),
143
459
  removeDeployment: (slug, id) => call("DELETE", `/sites/${encodeURIComponent(slug)}/deployments/${encodeURIComponent(id)}`)
144
460
  };
@@ -246,7 +562,7 @@ import { fileURLToPath } from "url";
246
562
  // package.json
247
563
  var package_default = {
248
564
  name: "mirrorbook",
249
- version: "0.6.0",
565
+ version: "0.7.0",
250
566
  description: "Publish HTML to a shareable URL. Agent-friendly: non-interactive, --json output, stable exit codes.",
251
567
  type: "module",
252
568
  bin: {
@@ -371,6 +687,7 @@ Recommended workflow:
371
687
  Update a site ls (find the existing slug) \u2192 deploy <path> --slug <slug> --wait \u2192 status <slug>
372
688
  Share privately deploy <path> --slug <slug> --password <pw> --expires 7d (or: access <slug> ...)
373
689
  Went wrong status <slug> \u2192 rollback <slug> <version>
690
+ Set a cover cover <slug> cover.svg (or: deploy <path> --slug <slug> --cover cover.svg)
374
691
  Use with AI agents mirrorbook skill --install (installs the usage guide into Claude Code)
375
692
  After upgrading mirrorbook update (new CLI version? skill out of date? prints the fix commands)
376
693
 
@@ -587,7 +904,33 @@ var lockLines = (s) => {
587
904
  ...s.passwordProtected ? [] : [" note: no password set, so visitors never see this copy"]
588
905
  ];
589
906
  };
590
- program.command("deploy").description("Publish a directory, .zip, .html, .md, or .txt file. Markdown and text are turned into a web page. Re-deploying the same slug publishes a new version.").argument("<path>", "directory (with index.html or README.md), a .zip/.html/.md/.txt file, or - for stdin").option("-s, --slug <slug>", "subdomain: <slug>.mirrorbook.store (random if omitted; a suffix is added if it's taken)").option("--strict-slug", "fail with exit code 2 instead of adding a suffix when the slug is taken").option("-t, --title <title>", "site title").addOption(new Option("-f, --format <format>", "treat the input as html, markdown, or text (default: from the file extension; stdin is auto-detected)").choices(["html", "markdown", "text"])).option("-w, --wait", "wait until processing finishes").option("--timeout <sec>", "max seconds to wait", "300").option("--password <password>", "protect the site with a password (makes it unlisted; env MIRRORBOOK_SITE_PASSWORD avoids shell history)").option("--expires <when>", "how long the password stays valid: 7d, 12h, a date like 2026-12-31, or never").option("--lock-title <text>", `title shown on the password page (max ${LOCK_TITLE_MAX} chars)`).option("--lock-message <text>", `message shown above the password box, e.g. how to get the password (max ${LOCK_MESSAGE_MAX} chars)`).option("--clear-lock", "restore the default password page copy").action(async (input, o) => {
907
+ async function readCover(file) {
908
+ const svg = file === "-" ? await readStdin2() : await readFile4(path4.resolve(file), "utf8").catch((e) => {
909
+ throw new CliError("usage", e.code === "ENOENT" ? `No such file: ${file}` : `Can't read ${file}: ${e.message}`, EXIT.usage);
910
+ });
911
+ const r = sanitizeCoverSvg(svg);
912
+ if (!r.ok) {
913
+ const why = {
914
+ empty: "the SVG is empty",
915
+ too_large: `it is larger than ${COVER_MAX_BYTES / 1024} KB`,
916
+ not_svg: "it is not an <svg> document",
917
+ parse_error: "the SVG could not be read (check that every tag is closed and attributes are quoted)",
918
+ doctype: "DOCTYPE declarations are not allowed",
919
+ no_viewbox: 'the <svg> needs a viewBox, e.g. viewBox="0 0 320 200"',
920
+ too_complex: "it has too many or too deeply nested elements"
921
+ };
922
+ throw new CliError(`cover_${r.error}`, `Can't use ${file} as a cover: ${why[r.error]}${r.detail ? ` (${r.detail})` : ""}`, EXIT.usage);
923
+ }
924
+ return svg;
925
+ }
926
+ async function applyCover(api, slug, svg) {
927
+ const r = await api.setCover(slug, svg);
928
+ if (r.dropped.length) info(`Cover saved. Removed: ${r.dropped.join(", ")}`);
929
+ return r;
930
+ }
931
+ program.command("deploy").description("Publish a directory, .zip, .html, .md, or .txt file. Markdown and text are turned into a web page. Re-deploying the same slug publishes a new version.").argument("<path>", "directory (with index.html or README.md), a .zip/.html/.md/.txt file, or - for stdin").option("-s, --slug <slug>", "subdomain: <slug>.mirrorbook.store (random if omitted; a suffix is added if it's taken)").option("--strict-slug", "fail with exit code 2 instead of adding a suffix when the slug is taken").option("-t, --title <title>", "site title").addOption(new Option("-f, --format <format>", "treat the input as html, markdown, or text (default: from the file extension; stdin is auto-detected)").choices(["html", "markdown", "text"])).option("-w, --wait", "wait until processing finishes").option("--timeout <sec>", "max seconds to wait", "300").option("--password <password>", "protect the site with a password (makes it unlisted; env MIRRORBOOK_SITE_PASSWORD avoids shell history)").option("--expires <when>", "how long the password stays valid: 7d, 12h, a date like 2026-12-31, or never").option("--lock-title <text>", `title shown on the password page (max ${LOCK_TITLE_MAX} chars)`).option("--lock-message <text>", `message shown above the password box, e.g. how to get the password (max ${LOCK_MESSAGE_MAX} chars)`).option("--clear-lock", "restore the default password page copy").option("--cover <file.svg>", "set the site's cover from an SVG file (see `mirrorbook cover --help`)").action(async (input, o) => {
932
+ if (o.cover === "-" && input === "-") throw new CliError("usage", "Only one of <path> and --cover can read from stdin", EXIT.usage);
933
+ const coverSvg = o.cover ? await readCover(o.cover) : void 0;
591
934
  const api = await client();
592
935
  const { blob, name, files, format } = await pack(input, o.format);
593
936
  const form = new FormData();
@@ -600,6 +943,7 @@ program.command("deploy").description("Publish a directory, .zip, .html, .md, or
600
943
  const { created, requestedSlug, slugAdjusted } = res;
601
944
  let { site, deployment } = res;
602
945
  site = await applyAccess(api, site.slug, o) ?? site;
946
+ if (coverSvg) site = (await applyCover(api, site.slug, coverSvg)).site;
603
947
  if (o.wait) ({ site, deployment } = await waitFor(api, deployment.id, Number(o.timeout)));
604
948
  out(
605
949
  [
@@ -611,7 +955,7 @@ program.command("deploy").description("Publish a directory, .zip, .html, .md, or
611
955
  ` preview: ${deployment.previewUrl}`,
612
956
  ` status: ${describe(deployment)}`
613
957
  ].join("\n"),
614
- { url: site.url, visibility: site.visibility, passwordProtected: site.passwordProtected, passwordExpiresAt: site.passwordExpiresAt, lockTitle: site.lockTitle, lockMessage: site.lockMessage, previewUrl: deployment.previewUrl, slug: site.slug, siteId: site.id, deploymentId: deployment.id, status: deployment.status, error: deployment.error, errorCode: deployment.errorCode, errorParams: deployment.errorParams, number: deployment.number, created, requestedSlug, slugAdjusted }
958
+ { url: site.url, coverUrl: site.coverUrl, visibility: site.visibility, passwordProtected: site.passwordProtected, passwordExpiresAt: site.passwordExpiresAt, lockTitle: site.lockTitle, lockMessage: site.lockMessage, previewUrl: deployment.previewUrl, slug: site.slug, siteId: site.id, deploymentId: deployment.id, status: deployment.status, error: deployment.error, errorCode: deployment.errorCode, errorParams: deployment.errorParams, number: deployment.number, created, requestedSlug, slugAdjusted }
615
959
  );
616
960
  process.exitCode = deploymentExit(deployment);
617
961
  });
@@ -624,6 +968,29 @@ program.command("access").description("Set or change who can open a site: a pass
624
968
  { slug: site.slug, visibility: site.visibility, passwordProtected: site.passwordProtected, passwordExpiresAt: site.passwordExpiresAt, lockTitle: site.lockTitle, lockMessage: site.lockMessage }
625
969
  );
626
970
  });
971
+ program.command("cover").description("Set a site's cover (an SVG shown on site lists and your profile), or go back to the default pattern").argument("<slug>").argument("[file]", "an .svg file, or - for stdin").option("--remove", "remove the custom cover and use the default pattern").addHelpText(
972
+ "after",
973
+ `
974
+ SVG only, up to ${COVER_MAX_BYTES / 1024} KB, 16:10 works best (viewBox="0 0 320 200").
975
+ Scripts, event handlers, links, external images/fonts and url(...) to other files are removed.
976
+ For dark mode, use @media (prefers-color-scheme: dark) inside a <style> element.
977
+
978
+ Examples:
979
+ mirrorbook cover my-demo cover.svg
980
+ mirrorbook cover my-demo --remove`
981
+ ).action(async (slug, file, o) => {
982
+ if (!!file === !!o.remove) throw new CliError("usage", "Pass an .svg file (or - for stdin), or --remove", EXIT.usage);
983
+ const svg = file ? await readCover(file) : void 0;
984
+ const api = await client();
985
+ if (!svg) {
986
+ const { site: site2 } = await api.removeCover(slug);
987
+ out(`${site2.slug}: using the default cover`, { ok: true, slug: site2.slug, coverUrl: null });
988
+ return;
989
+ }
990
+ const { site, dropped } = await applyCover(api, slug, svg);
991
+ out(`${site.slug}: cover set
992
+ cover: ${site.coverUrl}`, { ok: true, slug: site.slug, coverUrl: site.coverUrl, dropped });
993
+ });
627
994
  program.command("ls").description("List your sites").action(async () => {
628
995
  const { sites } = await (await client()).sites();
629
996
  const state = (s) => s.kind === "collection" ? `${s.itemCount} sites` : s.activeDeploymentId ? "live" : "not live";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mirrorbook",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Publish HTML to a shareable URL. Agent-friendly: non-interactive, --json output, stable exit codes.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,17 +14,16 @@
14
14
  "engines": {
15
15
  "node": ">=20"
16
16
  },
17
- "scripts": {
18
- "dev": "tsx src/cli.ts",
19
- "build": "tsup",
20
- "typecheck": "tsc -p .",
21
- "prepack": "tsup"
22
- },
23
17
  "devDependencies": {
24
- "@mirrorbook/shared": "workspace:*"
18
+ "@mirrorbook/shared": "0.0.0"
25
19
  },
26
20
  "dependencies": {
27
21
  "commander": "^15.0.0",
28
22
  "fflate": "^0.8.3"
23
+ },
24
+ "scripts": {
25
+ "dev": "tsx src/cli.ts",
26
+ "build": "tsup",
27
+ "typecheck": "tsc -p ."
29
28
  }
30
- }
29
+ }