mirrorbook 0.3.0 → 0.4.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 +1 -1
  2. package/dist/cli.js +29 -2
  3. package/package.json +1 -1
package/SKILL.md CHANGED
@@ -32,4 +32,4 @@ Password protection: `--password <pw> [--expires 7d|12h|2026-12-31|never]` on `d
32
32
 
33
33
  Install this skill for Claude Code with `npx mirrorbook skill --install` (or `--dir ./.claude/skills` for one project); `mirrorbook skill` prints it.
34
34
 
35
- Other commands: `access <slug>`, `ls`, `status <slug>` (lists versions), `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.
35
+ 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`, `status <slug>` (lists versions), `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
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/cli.ts
4
4
  import { spawn } from "child_process";
5
- import { cp, mkdir as mkdir3, readFile as readFile4 } from "fs/promises";
5
+ import { cp, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
6
6
  import { homedir as homedir3, hostname, platform } from "os";
7
7
  import path4 from "path";
8
8
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -108,7 +108,24 @@ function createClient(apiUrl, token) {
108
108
  }
109
109
  return json;
110
110
  }
111
+ async function download(p) {
112
+ const headers = { "user-agent": "mirrorbook-cli/0.1" };
113
+ if (token) headers.authorization = `Bearer ${token}`;
114
+ let res;
115
+ try {
116
+ res = await fetch(`${apiUrl}/api${p}`, { headers });
117
+ } catch (e) {
118
+ throw new CliError("network", `Can't reach ${apiUrl}: ${e.message}`, 1);
119
+ }
120
+ if (!res.ok) {
121
+ const json = await res.json().catch(() => ({}));
122
+ const code = json.error?.code ?? "http_error";
123
+ throw new CliError(code, json.error?.message ?? `HTTP ${res.status}`, exitFor(res.status, code), res.status);
124
+ }
125
+ return Buffer.from(await res.arrayBuffer());
126
+ }
111
127
  return {
128
+ download: (slug, id) => download(`/sites/${encodeURIComponent(slug)}/deployments/${encodeURIComponent(id)}/download`),
112
129
  me: () => call("GET", "/me"),
113
130
  deviceStart: (clientName) => call(
114
131
  "POST",
@@ -229,7 +246,7 @@ import { fileURLToPath } from "url";
229
246
  // package.json
230
247
  var package_default = {
231
248
  name: "mirrorbook",
232
- version: "0.3.0",
249
+ version: "0.4.0",
233
250
  description: "Publish HTML to a shareable URL. Agent-friendly: non-interactive, --json output, stable exit codes.",
234
251
  type: "module",
235
252
  bin: {
@@ -609,6 +626,16 @@ program.command("rollback").alias("set-default").description("Make an approved v
609
626
  await api.rollback(slug, d.id);
610
627
  out(`${slug} now serves #${d.number}`, { ok: true, slug, deploymentId: d.id, number: d.number });
611
628
  });
629
+ program.command("pull").description("Download a version's files as a zip (owner only; defaults to the live version)").argument("<slug>").argument("[version]", "version number (3 or #3) or deployment id; default: the live version").option("-o, --output <file>", "where to save the zip (default: ./<slug>-v<N>.zip)").action(async (slug, ref, o) => {
630
+ const api = await client();
631
+ const { site, deployments } = await api.site(slug);
632
+ const d = ref ? await resolveVersion(api, slug, ref) : deployments.find((x) => x.id === site.activeDeploymentId);
633
+ if (!d) throw new CliError("not_found", `${slug} has no live version. Pass a version number`, EXIT.usage);
634
+ const file = path4.resolve(o.output ?? `${slug}-v${d.number}.zip`);
635
+ const buf = await api.download(slug, d.id);
636
+ await writeFile3(file, buf);
637
+ out(`Saved ${slug} #${d.number} to ${file} (${buf.length} bytes)`, { ok: true, slug, deploymentId: d.id, number: d.number, file, bytes: buf.length });
638
+ });
612
639
  program.command("rm-version").description("Delete one version (not the default one)").argument("<slug>").argument("<version>", "version number (3 or #3) or deployment id").option("-y, --yes", "skip the confirmation (required when not a TTY)").action(async (slug, ref, o) => {
613
640
  const api = await client();
614
641
  const d = await resolveVersion(api, slug, ref);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mirrorbook",
3
- "version": "0.3.0",
3
+ "version": "0.4.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": {