@akal/supaforge 0.0.0-stage → 0.0.32
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 +350 -2
- package/bin/dev.js +10 -0
- package/bin/run.js +18 -0
- package/dist/base-command.d.ts +135 -0
- package/dist/base-command.js +9 -0
- package/dist/base-command.js.map +1 -0
- package/dist/branch-C4ndfoj5.d.ts +58 -0
- package/dist/chunk-2SELREHW.js +156 -0
- package/dist/chunk-2SELREHW.js.map +1 -0
- package/dist/chunk-3HGAV5CC.js +2073 -0
- package/dist/chunk-3HGAV5CC.js.map +1 -0
- package/dist/chunk-4IVN7QVY.js +632 -0
- package/dist/chunk-4IVN7QVY.js.map +1 -0
- package/dist/chunk-6LJERPUN.js +499 -0
- package/dist/chunk-6LJERPUN.js.map +1 -0
- package/dist/chunk-6Q7MHFBM.js +13 -0
- package/dist/chunk-6Q7MHFBM.js.map +1 -0
- package/dist/chunk-6WAMNZLO.js +336 -0
- package/dist/chunk-6WAMNZLO.js.map +1 -0
- package/dist/chunk-7NAZGZPV.js +868 -0
- package/dist/chunk-7NAZGZPV.js.map +1 -0
- package/dist/chunk-BLKJWDTL.js +153 -0
- package/dist/chunk-BLKJWDTL.js.map +1 -0
- package/dist/chunk-BUOWHE36.js +1311 -0
- package/dist/chunk-BUOWHE36.js.map +1 -0
- package/dist/chunk-DMIWAJRB.js +602 -0
- package/dist/chunk-DMIWAJRB.js.map +1 -0
- package/dist/chunk-DQQ5E563.js +64 -0
- package/dist/chunk-DQQ5E563.js.map +1 -0
- package/dist/chunk-G2DIPIYU.js +94 -0
- package/dist/chunk-G2DIPIYU.js.map +1 -0
- package/dist/chunk-GEHPTPNZ.js +240 -0
- package/dist/chunk-GEHPTPNZ.js.map +1 -0
- package/dist/chunk-GZREXCQZ.js +207 -0
- package/dist/chunk-GZREXCQZ.js.map +1 -0
- package/dist/chunk-MIRLB5JM.js +1292 -0
- package/dist/chunk-MIRLB5JM.js.map +1 -0
- package/dist/chunk-NTUASFQ3.js +248 -0
- package/dist/chunk-NTUASFQ3.js.map +1 -0
- package/dist/chunk-ORQJVE57.js +642 -0
- package/dist/chunk-ORQJVE57.js.map +1 -0
- package/dist/chunk-SC2XHGIS.js +122 -0
- package/dist/chunk-SC2XHGIS.js.map +1 -0
- package/dist/chunk-SQPCWGQO.js +657 -0
- package/dist/chunk-SQPCWGQO.js.map +1 -0
- package/dist/chunk-UWAVXC57.js +916 -0
- package/dist/chunk-UWAVXC57.js.map +1 -0
- package/dist/commands/clone.d.ts +66 -0
- package/dist/commands/clone.js +416 -0
- package/dist/commands/clone.js.map +1 -0
- package/dist/commands/diff.d.ts +81 -0
- package/dist/commands/diff.js +23 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/help.d.ts +32 -0
- package/dist/commands/help.js +36 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/hukam.d.ts +13 -0
- package/dist/commands/hukam.js +28 -0
- package/dist/commands/hukam.js.map +1 -0
- package/dist/commands/init.d.ts +47 -0
- package/dist/commands/init.js +388 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +13 -0
- package/dist/commands/mcp.js +43 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate/baseline.d.ts +24 -0
- package/dist/commands/migrate/baseline.js +69 -0
- package/dist/commands/migrate/baseline.js.map +1 -0
- package/dist/commands/migrate/create.d.ts +36 -0
- package/dist/commands/migrate/create.js +127 -0
- package/dist/commands/migrate/create.js.map +1 -0
- package/dist/commands/migrate/list.d.ts +23 -0
- package/dist/commands/migrate/list.js +110 -0
- package/dist/commands/migrate/list.js.map +1 -0
- package/dist/commands/migrate/run.d.ts +61 -0
- package/dist/commands/migrate/run.js +18 -0
- package/dist/commands/migrate/run.js.map +1 -0
- package/dist/commands/report.d.ts +27 -0
- package/dist/commands/report.js +210 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/restore.d.ts +26 -0
- package/dist/commands/restore.js +266 -0
- package/dist/commands/restore.js.map +1 -0
- package/dist/commands/snapshot.d.ts +33 -0
- package/dist/commands/snapshot.js +249 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/sync.d.ts +16 -0
- package/dist/commands/sync.js +38 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/config-CTbeRlJk.d.ts +134 -0
- package/dist/help.d.ts +28 -0
- package/dist/help.js +64 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +498 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sanitizeForReport
|
|
3
|
+
} from "../chunk-6Q7MHFBM.js";
|
|
4
|
+
import {
|
|
5
|
+
BaseCommand,
|
|
6
|
+
readRunLog,
|
|
7
|
+
runLogPath
|
|
8
|
+
} from "../chunk-GZREXCQZ.js";
|
|
9
|
+
import "../chunk-SQPCWGQO.js";
|
|
10
|
+
import {
|
|
11
|
+
bold,
|
|
12
|
+
cmd,
|
|
13
|
+
dim,
|
|
14
|
+
ok,
|
|
15
|
+
warn
|
|
16
|
+
} from "../chunk-6WAMNZLO.js";
|
|
17
|
+
|
|
18
|
+
// src/commands/report.ts
|
|
19
|
+
import { Flags } from "@oclif/core";
|
|
20
|
+
import { createInterface } from "readline/promises";
|
|
21
|
+
var REPORT_ENDPOINT = process.env["SUPAFORGE_REPORT_URL"] ?? "https://supaforge.dev/api/bug-reports";
|
|
22
|
+
var PRIVACY_URL = "https://supaforge.dev/privacy";
|
|
23
|
+
var DATA_RETENTION_DAYS = 90;
|
|
24
|
+
var Report = class _Report extends BaseCommand {
|
|
25
|
+
static description = "Show recent supaforge command history from the local run log";
|
|
26
|
+
static examples = [
|
|
27
|
+
"<%= config.bin %> report",
|
|
28
|
+
"<%= config.bin %> report --last=20",
|
|
29
|
+
"<%= config.bin %> report --send",
|
|
30
|
+
"<%= config.bin %> report --json"
|
|
31
|
+
];
|
|
32
|
+
static flags = {
|
|
33
|
+
last: Flags.integer({
|
|
34
|
+
char: "n",
|
|
35
|
+
description: "Number of recent entries to show",
|
|
36
|
+
default: 10
|
|
37
|
+
}),
|
|
38
|
+
send: Flags.boolean({
|
|
39
|
+
description: "Interactively select entries to send as anonymous bug reports",
|
|
40
|
+
default: false
|
|
41
|
+
}),
|
|
42
|
+
json: Flags.boolean({ description: "Output as JSON" })
|
|
43
|
+
};
|
|
44
|
+
async run() {
|
|
45
|
+
const { flags } = await this.parse(_Report);
|
|
46
|
+
const all = await readRunLog();
|
|
47
|
+
const entries = all.slice(-flags.last);
|
|
48
|
+
if (flags.json) {
|
|
49
|
+
this.json(entries);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (flags.send) {
|
|
53
|
+
await this.sendFlow(entries);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.displayEntries(entries);
|
|
57
|
+
}
|
|
58
|
+
displayEntries(entries) {
|
|
59
|
+
const logFile = runLogPath();
|
|
60
|
+
if (entries.length === 0) {
|
|
61
|
+
this.log(`
|
|
62
|
+
${dim("No command history found.")}`);
|
|
63
|
+
this.log(` ${dim(`Log file: ${logFile}`)}`);
|
|
64
|
+
this.log(` ${dim("Run any supaforge command to start logging.")}
|
|
65
|
+
`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.log(`
|
|
69
|
+
${bold(`Last ${entries.length} command(s)`)} ${dim(`\xB7 log: ${logFile}`)}
|
|
70
|
+
`);
|
|
71
|
+
for (const entry of entries) {
|
|
72
|
+
const ts = new Date(entry.timestamp).toLocaleString();
|
|
73
|
+
const dur = entry.durationMs < 1e3 ? `${entry.durationMs}ms` : `${(entry.durationMs / 1e3).toFixed(1)}s`;
|
|
74
|
+
const icon = entry.exitStatus === "success" ? ok("\u2713") : warn("\u2717");
|
|
75
|
+
this.log(` ${icon} ${bold(entry.command)} ${dim(entry.args.join(" "))}`);
|
|
76
|
+
this.log(` ${dim(`${ts} \xB7 ${dur}`)}`);
|
|
77
|
+
if (entry.error) {
|
|
78
|
+
this.log(` ${warn(entry.error)}`);
|
|
79
|
+
}
|
|
80
|
+
if (entry.checkSummaries) {
|
|
81
|
+
for (const c of entry.checkSummaries.filter((s) => s.status === "error" || s.issueCount > 0)) {
|
|
82
|
+
const icon2 = c.status === "error" ? warn("\u2717") : dim("\u25CF");
|
|
83
|
+
const detail = c.status === "error" ? warn(c.error ?? "error") : `${c.issueCount} issues`;
|
|
84
|
+
this.log(` ${icon2} ${dim(`[${c.check}]`)} ${detail}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.log("");
|
|
88
|
+
}
|
|
89
|
+
this.log(dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
90
|
+
this.log(dim(" Data is stored only on this machine (~/.supaforge/run-log.jsonl)."));
|
|
91
|
+
this.log(dim(` To send a bug report: ${cmd("supaforge report --send")}`));
|
|
92
|
+
this.log(dim(" To delete history: rm ~/.supaforge/run-log.jsonl\n"));
|
|
93
|
+
}
|
|
94
|
+
async sendFlow(entries) {
|
|
95
|
+
if (!process.stdin.isTTY) {
|
|
96
|
+
this.error("--send requires an interactive terminal.");
|
|
97
|
+
}
|
|
98
|
+
if (entries.length === 0) {
|
|
99
|
+
this.log(`
|
|
100
|
+
${dim("No command history to send.")}
|
|
101
|
+
`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.log(`
|
|
105
|
+
${bold("Recent commands")}
|
|
106
|
+
`);
|
|
107
|
+
for (let i = 0; i < entries.length; i++) {
|
|
108
|
+
const e = entries[i];
|
|
109
|
+
const ts = new Date(e.timestamp).toLocaleString();
|
|
110
|
+
const dur = (e.durationMs / 1e3).toFixed(1);
|
|
111
|
+
const icon = e.exitStatus === "success" ? ok("\u2713") : warn("\u2717");
|
|
112
|
+
this.log(` ${dim(`[${i + 1}]`)} ${icon} ${bold(e.command)} ${dim(e.args.join(" "))} ${dim(`${ts} \xB7 ${dur}s`)}`);
|
|
113
|
+
if (e.error) this.log(` ${warn(e.error)}`);
|
|
114
|
+
}
|
|
115
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
116
|
+
let selected;
|
|
117
|
+
let confirmed = false;
|
|
118
|
+
try {
|
|
119
|
+
const rawSelection = await rl.question(
|
|
120
|
+
"\n Enter numbers to send (e.g. 1,3 or all, or press Enter to cancel): "
|
|
121
|
+
);
|
|
122
|
+
if (!rawSelection.trim()) {
|
|
123
|
+
this.log(`
|
|
124
|
+
${dim("Cancelled.")}
|
|
125
|
+
`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (rawSelection.trim().toLowerCase() === "all") {
|
|
129
|
+
selected = entries.map((_, i) => i);
|
|
130
|
+
} else {
|
|
131
|
+
selected = rawSelection.split(",").map((s) => parseInt(s.trim(), 10) - 1).filter((n) => !isNaN(n) && n >= 0 && n < entries.length);
|
|
132
|
+
}
|
|
133
|
+
if (selected.length === 0) {
|
|
134
|
+
this.log(`
|
|
135
|
+
${dim("No valid entries selected. Cancelled.")}
|
|
136
|
+
`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const payloads2 = selected.map((i) => this.buildPayload(entries[i]));
|
|
140
|
+
this.log(`
|
|
141
|
+
${bold("Exactly this data will be sent")} ${dim("\u2014 nothing else:")}
|
|
142
|
+
`);
|
|
143
|
+
for (const payload of payloads2) {
|
|
144
|
+
const lines = JSON.stringify(payload, null, 4).split("\n");
|
|
145
|
+
for (const line of lines) this.log(` ${line}`);
|
|
146
|
+
this.log("");
|
|
147
|
+
}
|
|
148
|
+
this.log(dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
149
|
+
this.log(dim(" Included: command name \xB7 duration \xB7 exit status \xB7 version"));
|
|
150
|
+
this.log(dim(" per-check status and issue counts"));
|
|
151
|
+
this.log(dim(" error messages (URLs and file paths redacted)"));
|
|
152
|
+
this.log(dim(" Excluded: SQL \xB7 table/column names \xB7 data values"));
|
|
153
|
+
this.log(dim(" database URLs \xB7 file paths \xB7 IP addresses"));
|
|
154
|
+
this.log(dim(` Retention: deleted after ${DATA_RETENTION_DAYS} days \xB7 ${PRIVACY_URL}`));
|
|
155
|
+
this.log(dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n"));
|
|
156
|
+
const answer = await rl.question(` Send ${selected.length} report(s)? [y/N] `);
|
|
157
|
+
confirmed = answer.trim().toLowerCase() === "y";
|
|
158
|
+
} finally {
|
|
159
|
+
rl.close();
|
|
160
|
+
}
|
|
161
|
+
if (!confirmed) {
|
|
162
|
+
this.log(`
|
|
163
|
+
${dim("Cancelled. Nothing was sent.")}
|
|
164
|
+
`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const payloads = selected.map((i) => this.buildPayload(entries[i]));
|
|
168
|
+
this.log("");
|
|
169
|
+
let sent = 0;
|
|
170
|
+
for (const payload of payloads) {
|
|
171
|
+
try {
|
|
172
|
+
const res = await fetch(REPORT_ENDPOINT, {
|
|
173
|
+
method: "POST",
|
|
174
|
+
headers: { "Content-Type": "application/json", "User-Agent": `supaforge-cli/${payload.version ?? "unknown"}` },
|
|
175
|
+
body: JSON.stringify(payload),
|
|
176
|
+
signal: AbortSignal.timeout(1e4)
|
|
177
|
+
});
|
|
178
|
+
if (res.ok) {
|
|
179
|
+
const body = await res.json();
|
|
180
|
+
this.log(` ${ok("\u2713")} Sent${body.reportId ? ` ${dim(`ref: ${body.reportId}`)}` : ""}`);
|
|
181
|
+
sent++;
|
|
182
|
+
} else {
|
|
183
|
+
this.log(` ${warn("\u2717")} Failed (HTTP ${res.status})`);
|
|
184
|
+
}
|
|
185
|
+
} catch {
|
|
186
|
+
this.log(` ${warn("\u2717")} Failed (network error \u2014 check your connection)`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
this.log("");
|
|
190
|
+
if (sent > 0) {
|
|
191
|
+
this.log(dim(` ${sent} report(s) sent. Thank you \u2014 this helps us fix bugs faster.
|
|
192
|
+
`));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
buildPayload(entry) {
|
|
196
|
+
return {
|
|
197
|
+
command: entry.command,
|
|
198
|
+
args: entry.args,
|
|
199
|
+
durationMs: entry.durationMs,
|
|
200
|
+
exitStatus: entry.exitStatus,
|
|
201
|
+
...entry.error ? { error: sanitizeForReport(entry.error) } : {},
|
|
202
|
+
...entry.version ? { version: entry.version } : {},
|
|
203
|
+
...entry.checkSummaries?.length ? { checkSummaries: entry.checkSummaries } : {}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export {
|
|
208
|
+
Report as default
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/commands/report.ts"],"sourcesContent":["import { Flags } from '@oclif/core'\nimport { createInterface } from 'node:readline/promises'\nimport { BaseCommand } from '../base-command.js'\nimport { readRunLog, runLogPath, type RunLogEntry } from '../run-log.js'\nimport { ok, dim, bold, warn, cmd } from '../ui.js'\nimport { sanitizeForReport } from '../utils/sanitize.js'\n\nconst REPORT_ENDPOINT =\n process.env['SUPAFORGE_REPORT_URL'] ?? 'https://supaforge.dev/api/bug-reports'\nconst PRIVACY_URL = 'https://supaforge.dev/privacy'\nconst DATA_RETENTION_DAYS = 90\n\n/**\n * Display recent supaforge command history from the local run log.\n *\n * With --send: interactively select entries to send as anonymous bug reports.\n * The user sees exactly what data will be transmitted before confirming.\n * No SQL, table names, schema content, or identifying information is ever sent.\n */\nexport default class Report extends BaseCommand {\n static override description = 'Show recent supaforge command history from the local run log'\n\n static override examples = [\n '<%= config.bin %> report',\n '<%= config.bin %> report --last=20',\n '<%= config.bin %> report --send',\n '<%= config.bin %> report --json',\n ]\n\n static override flags = {\n last: Flags.integer({\n char: 'n',\n description: 'Number of recent entries to show',\n default: 10,\n }),\n send: Flags.boolean({\n description: 'Interactively select entries to send as anonymous bug reports',\n default: false,\n }),\n json: Flags.boolean({ description: 'Output as JSON' }),\n }\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Report)\n const all = await readRunLog()\n const entries = all.slice(-flags.last)\n\n if (flags.json) {\n this.json(entries)\n return\n }\n\n if (flags.send) {\n await this.sendFlow(entries)\n return\n }\n\n this.displayEntries(entries)\n }\n\n private displayEntries(entries: RunLogEntry[]): void {\n const logFile = runLogPath()\n\n if (entries.length === 0) {\n this.log(`\\n ${dim('No command history found.')}`)\n this.log(` ${dim(`Log file: ${logFile}`)}`)\n this.log(` ${dim('Run any supaforge command to start logging.')}\\n`)\n return\n }\n\n this.log(`\\n ${bold(`Last ${entries.length} command(s)`)} ${dim(`· log: ${logFile}`)}\\n`)\n\n for (const entry of entries) {\n const ts = new Date(entry.timestamp).toLocaleString()\n const dur = entry.durationMs < 1000\n ? `${entry.durationMs}ms`\n : `${(entry.durationMs / 1000).toFixed(1)}s`\n const icon = entry.exitStatus === 'success' ? ok('✓') : warn('✗')\n this.log(` ${icon} ${bold(entry.command)} ${dim(entry.args.join(' '))}`)\n this.log(` ${dim(`${ts} · ${dur}`)}`)\n if (entry.error) {\n this.log(` ${warn(entry.error)}`)\n }\n if (entry.checkSummaries) {\n for (const c of entry.checkSummaries.filter(s => s.status === 'error' || s.issueCount > 0)) {\n const icon2 = c.status === 'error' ? warn('✗') : dim('●')\n const detail = c.status === 'error' ? warn(c.error ?? 'error') : `${c.issueCount} issues`\n this.log(` ${icon2} ${dim(`[${c.check}]`)} ${detail}`)\n }\n }\n this.log('')\n }\n\n this.log(dim(' ──────────────────────────────────────────────────────────'))\n this.log(dim(' Data is stored only on this machine (~/.supaforge/run-log.jsonl).'))\n this.log(dim(` To send a bug report: ${cmd('supaforge report --send')}`))\n this.log(dim(' To delete history: rm ~/.supaforge/run-log.jsonl\\n'))\n }\n\n private async sendFlow(entries: RunLogEntry[]): Promise<void> {\n if (!process.stdin.isTTY) {\n this.error('--send requires an interactive terminal.')\n }\n\n if (entries.length === 0) {\n this.log(`\\n ${dim('No command history to send.')}\\n`)\n return\n }\n\n this.log(`\\n ${bold('Recent commands')}\\n`)\n for (let i = 0; i < entries.length; i++) {\n const e = entries[i]\n const ts = new Date(e.timestamp).toLocaleString()\n const dur = (e.durationMs / 1000).toFixed(1)\n const icon = e.exitStatus === 'success' ? ok('✓') : warn('✗')\n this.log(` ${dim(`[${i + 1}]`)} ${icon} ${bold(e.command)} ${dim(e.args.join(' '))} ${dim(`${ts} · ${dur}s`)}`)\n if (e.error) this.log(` ${warn(e.error)}`)\n }\n\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n\n let selected: number[]\n let confirmed = false\n\n try {\n const rawSelection = await rl.question(\n '\\n Enter numbers to send (e.g. 1,3 or all, or press Enter to cancel): '\n )\n\n if (!rawSelection.trim()) {\n this.log(`\\n ${dim('Cancelled.')}\\n`)\n return\n }\n\n if (rawSelection.trim().toLowerCase() === 'all') {\n selected = entries.map((_, i) => i)\n } else {\n selected = rawSelection\n .split(',')\n .map(s => parseInt(s.trim(), 10) - 1)\n .filter(n => !isNaN(n) && n >= 0 && n < entries.length)\n }\n\n if (selected.length === 0) {\n this.log(`\\n ${dim('No valid entries selected. Cancelled.')}\\n`)\n return\n }\n\n const payloads = selected.map(i => this.buildPayload(entries[i]))\n\n this.log(`\\n ${bold('Exactly this data will be sent')} ${dim('— nothing else:')}\\n`)\n for (const payload of payloads) {\n const lines = JSON.stringify(payload, null, 4).split('\\n')\n for (const line of lines) this.log(` ${line}`)\n this.log('')\n }\n\n this.log(dim(' ──────────────────────────────────────────────────────────'))\n this.log(dim(' Included: command name · duration · exit status · version'))\n this.log(dim(' per-check status and issue counts'))\n this.log(dim(' error messages (URLs and file paths redacted)'))\n this.log(dim(' Excluded: SQL · table/column names · data values'))\n this.log(dim(' database URLs · file paths · IP addresses'))\n this.log(dim(` Retention: deleted after ${DATA_RETENTION_DAYS} days · ${PRIVACY_URL}`))\n this.log(dim(' ──────────────────────────────────────────────────────────\\n'))\n\n const answer = await rl.question(` Send ${selected.length} report(s)? [y/N] `)\n confirmed = answer.trim().toLowerCase() === 'y'\n } finally {\n rl.close()\n }\n\n if (!confirmed) {\n this.log(`\\n ${dim('Cancelled. Nothing was sent.')}\\n`)\n return\n }\n\n const payloads = selected.map(i => this.buildPayload(entries[i]))\n\n this.log('')\n let sent = 0\n for (const payload of payloads) {\n try {\n const res = await fetch(REPORT_ENDPOINT, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'User-Agent': `supaforge-cli/${payload.version ?? 'unknown'}` },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(10_000),\n })\n if (res.ok) {\n const body = await res.json() as { reportId?: string }\n this.log(` ${ok('✓')} Sent${body.reportId ? ` ${dim(`ref: ${body.reportId}`)}` : ''}`)\n sent++\n } else {\n this.log(` ${warn('✗')} Failed (HTTP ${res.status})`)\n }\n } catch {\n this.log(` ${warn('✗')} Failed (network error — check your connection)`)\n }\n }\n\n this.log('')\n if (sent > 0) {\n this.log(dim(` ${sent} report(s) sent. Thank you — this helps us fix bugs faster.\\n`))\n }\n }\n\n private buildPayload(entry: RunLogEntry): Record<string, unknown> {\n return {\n command: entry.command,\n args: entry.args,\n durationMs: entry.durationMs,\n exitStatus: entry.exitStatus,\n ...(entry.error ? { error: sanitizeForReport(entry.error) } : {}),\n ...(entry.version ? { version: entry.version } : {}),\n ...(entry.checkSummaries?.length ? { checkSummaries: entry.checkSummaries } : {}),\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAMhC,IAAM,kBACJ,QAAQ,IAAI,sBAAsB,KAAK;AACzC,IAAM,cAAc;AACpB,IAAM,sBAAsB;AAS5B,IAAqB,SAArB,MAAqB,gBAAe,YAAY;AAAA,EAC9C,OAAgB,cAAc;AAAA,EAE9B,OAAgB,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,OAAgB,QAAQ;AAAA,IACtB,MAAM,MAAM,QAAQ;AAAA,MAClB,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,IACD,MAAM,MAAM,QAAQ;AAAA,MAClB,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,IACD,MAAM,MAAM,QAAQ,EAAE,aAAa,iBAAiB,CAAC;AAAA,EACvD;AAAA,EAEA,MAAM,MAAqB;AACzB,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,MAAM,OAAM;AACzC,UAAM,MAAM,MAAM,WAAW;AAC7B,UAAM,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI;AAErC,QAAI,MAAM,MAAM;AACd,WAAK,KAAK,OAAO;AACjB;AAAA,IACF;AAEA,QAAI,M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AI;AAAA,CAA+D,CAAC;AAAA,IACxF;AAAA,EACF;AAAA,EAEQ,aAAa,OAA6C;AAChE,WAAO;AAAA,MACL,SAAS,MAAM;AAAA,MACf,MAAM,MAAM;AAAA,MACZ,YAAY,MAAM;AAAA,MAClB,YAAY,MAAM;AAAA,MAClB,GAAI,MAAM,QAAQ,EAAE,OAAO,kBAAkB,MAAM,KAAK,EAAE,IAAI,CAAC;AAAA,MAC/D,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;AAAA,MAClD,GAAI,MAAM,gBAAgB,SAAS,EAAE,gBAAgB,MAAM,eAAe,IAAI,CAAC;AAAA,IACjF;AAAA,EACF;AACF;","names":["payloads"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as _oclif_core_interfaces from '@oclif/core/interfaces';
|
|
2
|
+
import { BaseCommand } from '../base-command.js';
|
|
3
|
+
import '@oclif/core';
|
|
4
|
+
import '../config-CTbeRlJk.js';
|
|
5
|
+
|
|
6
|
+
declare class Restore extends BaseCommand {
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static flags: {
|
|
10
|
+
env: _oclif_core_interfaces.OptionFlag<string, _oclif_core_interfaces.CustomOptions>;
|
|
11
|
+
'from-snapshot': _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
12
|
+
'from-migrations': _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
13
|
+
to: _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
14
|
+
from: _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
15
|
+
apply: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
16
|
+
'no-transaction': _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
17
|
+
force: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
18
|
+
json: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
private handleSnapshotRestore;
|
|
22
|
+
private handleMigrationRestore;
|
|
23
|
+
private renderResult;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { Restore as default };
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getPublicTables,
|
|
3
|
+
previewMigrationRestore,
|
|
4
|
+
previewSnapshotRestore,
|
|
5
|
+
restoreFromMigrations,
|
|
6
|
+
restoreFromSnapshot,
|
|
7
|
+
summarizeStatement
|
|
8
|
+
} from "../chunk-7NAZGZPV.js";
|
|
9
|
+
import "../chunk-NTUASFQ3.js";
|
|
10
|
+
import "../chunk-SC2XHGIS.js";
|
|
11
|
+
import "../chunk-DMIWAJRB.js";
|
|
12
|
+
import "../chunk-UWAVXC57.js";
|
|
13
|
+
import "../chunk-BUOWHE36.js";
|
|
14
|
+
import "../chunk-G2DIPIYU.js";
|
|
15
|
+
import {
|
|
16
|
+
renderTip
|
|
17
|
+
} from "../chunk-BLKJWDTL.js";
|
|
18
|
+
import {
|
|
19
|
+
BaseCommand
|
|
20
|
+
} from "../chunk-GZREXCQZ.js";
|
|
21
|
+
import {
|
|
22
|
+
findLatestSnapshot,
|
|
23
|
+
listSnapshots
|
|
24
|
+
} from "../chunk-MIRLB5JM.js";
|
|
25
|
+
import "../chunk-DQQ5E563.js";
|
|
26
|
+
import "../chunk-SQPCWGQO.js";
|
|
27
|
+
import {
|
|
28
|
+
cmd,
|
|
29
|
+
warn
|
|
30
|
+
} from "../chunk-6WAMNZLO.js";
|
|
31
|
+
|
|
32
|
+
// src/commands/restore.ts
|
|
33
|
+
import { Flags } from "@oclif/core";
|
|
34
|
+
var Restore = class _Restore extends BaseCommand {
|
|
35
|
+
static description = "Restore a Supabase environment from a snapshot or migration history";
|
|
36
|
+
static examples = [
|
|
37
|
+
"<%= config.bin %> restore --env=local --from-snapshot=latest",
|
|
38
|
+
"<%= config.bin %> restore --env=local --from-snapshot=latest --apply",
|
|
39
|
+
"<%= config.bin %> restore --env=local --from-migrations --apply",
|
|
40
|
+
"<%= config.bin %> restore --env=local --from-migrations --to=20260407T120000Z --apply",
|
|
41
|
+
"<%= config.bin %> restore --env=local --from-snapshot=latest --apply --force"
|
|
42
|
+
];
|
|
43
|
+
static flags = {
|
|
44
|
+
env: Flags.string({
|
|
45
|
+
char: "e",
|
|
46
|
+
description: "Target environment to restore into",
|
|
47
|
+
required: true
|
|
48
|
+
}),
|
|
49
|
+
"from-snapshot": Flags.string({
|
|
50
|
+
description: 'Restore from a snapshot ("latest" or a timestamp)',
|
|
51
|
+
exclusive: ["from-migrations"]
|
|
52
|
+
}),
|
|
53
|
+
"from-migrations": Flags.boolean({
|
|
54
|
+
description: "Restore by replaying migration files",
|
|
55
|
+
exclusive: ["from-snapshot"]
|
|
56
|
+
}),
|
|
57
|
+
to: Flags.string({
|
|
58
|
+
description: "Replay migrations up to this version (timestamp)"
|
|
59
|
+
}),
|
|
60
|
+
from: Flags.string({
|
|
61
|
+
description: "Replay migrations from this version (timestamp)"
|
|
62
|
+
}),
|
|
63
|
+
apply: Flags.boolean({
|
|
64
|
+
description: "Actually execute the restore (default: dry-run preview)",
|
|
65
|
+
default: false
|
|
66
|
+
}),
|
|
67
|
+
"no-transaction": Flags.boolean({
|
|
68
|
+
description: "Apply each statement on its own, keeping whatever succeeds. Off by default: a snapshot restore runs in one transaction, so a failure leaves the target exactly as it was rather than half-restored. Applies to --from-snapshot.",
|
|
69
|
+
default: false
|
|
70
|
+
}),
|
|
71
|
+
force: Flags.boolean({
|
|
72
|
+
description: "Allow restore into a non-empty database (destructive)",
|
|
73
|
+
default: false
|
|
74
|
+
}),
|
|
75
|
+
json: Flags.boolean({ description: "Output results as JSON" })
|
|
76
|
+
};
|
|
77
|
+
async run() {
|
|
78
|
+
const { flags } = await this.parse(_Restore);
|
|
79
|
+
if (!flags["from-snapshot"] && !flags["from-migrations"]) {
|
|
80
|
+
this.error("Specify --from-snapshot or --from-migrations");
|
|
81
|
+
}
|
|
82
|
+
const config = await this.loadConfigOrFail();
|
|
83
|
+
const envName = flags.env;
|
|
84
|
+
const { env } = this.resolveEnv(config, envName);
|
|
85
|
+
const pre = this.createPreflight("Restore preflight checks").addDatabase("Target", envName, env.dbUrl);
|
|
86
|
+
await this.runPreflight(pre, "Restore");
|
|
87
|
+
if (flags.apply) {
|
|
88
|
+
const tables = await getPublicTables(env.dbUrl);
|
|
89
|
+
if (tables.length > 0 && !flags.force) {
|
|
90
|
+
if (flags.json) {
|
|
91
|
+
this.json({ error: "Target database is not empty", tables });
|
|
92
|
+
this.exit(1);
|
|
93
|
+
}
|
|
94
|
+
this.log(`
|
|
95
|
+
${warn("Target database is not empty.")} Found ${tables.length} table(s) in public schema:`);
|
|
96
|
+
for (const t of tables.slice(0, 10)) {
|
|
97
|
+
this.log(` \u2022 ${t}`);
|
|
98
|
+
}
|
|
99
|
+
if (tables.length > 10) {
|
|
100
|
+
this.log(` ... and ${tables.length - 10} more`);
|
|
101
|
+
}
|
|
102
|
+
this.log(`
|
|
103
|
+
Restore replays SQL into the target and may conflict with existing data.`);
|
|
104
|
+
this.log(` \u2192 Use ${cmd("supaforge sync")} to apply only the differences instead.`);
|
|
105
|
+
this.log(` \u2192 Add ${cmd("--force")} to drop and replace the schemas this snapshot covers.
|
|
106
|
+
`);
|
|
107
|
+
this.exit(1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (flags["from-snapshot"]) {
|
|
111
|
+
await this.handleSnapshotRestore(flags, env.dbUrl);
|
|
112
|
+
} else {
|
|
113
|
+
await this.handleMigrationRestore(flags, env.dbUrl);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async handleSnapshotRestore(flags, targetUrl) {
|
|
117
|
+
const snapshotRef = flags["from-snapshot"];
|
|
118
|
+
let snapshotDir;
|
|
119
|
+
if (snapshotRef === "latest") {
|
|
120
|
+
const latest = await findLatestSnapshot();
|
|
121
|
+
if (!latest) {
|
|
122
|
+
this.error('No snapshots found. Create one with "supaforge snapshot" first.');
|
|
123
|
+
}
|
|
124
|
+
snapshotDir = latest;
|
|
125
|
+
} else {
|
|
126
|
+
const snapshots = await listSnapshots();
|
|
127
|
+
const match = snapshots.find((s) => s.manifest.timestamp === snapshotRef);
|
|
128
|
+
if (!match) {
|
|
129
|
+
this.error(`Snapshot "${snapshotRef}" not found. Use --from-snapshot=latest or a valid timestamp.`);
|
|
130
|
+
}
|
|
131
|
+
snapshotDir = match.dir;
|
|
132
|
+
}
|
|
133
|
+
if (!flags.apply) {
|
|
134
|
+
const preview = await previewSnapshotRestore(snapshotDir);
|
|
135
|
+
if (flags.json) {
|
|
136
|
+
this.json({ dryRun: true, snapshot: snapshotDir, layers: preview });
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.log("\nRestore preview (dry-run) -- from snapshot\n");
|
|
140
|
+
if (preview.length === 0) {
|
|
141
|
+
this.log(" No executable SQL found in snapshot.");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
for (const { layer, statements } of preview) {
|
|
145
|
+
this.log(` Layer: ${layer} (${statements.length} statements)`);
|
|
146
|
+
for (const stmt of statements.slice(0, 3)) {
|
|
147
|
+
this.log(` ${summarizeStatement(stmt)}`);
|
|
148
|
+
}
|
|
149
|
+
if (statements.length > 3) {
|
|
150
|
+
this.log(` ... and ${statements.length - 3} more`);
|
|
151
|
+
}
|
|
152
|
+
this.log("");
|
|
153
|
+
}
|
|
154
|
+
this.log(` \u2192 Add --apply to execute the restore.
|
|
155
|
+
`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!flags.json) this.log(`
|
|
159
|
+
Restoring from snapshot...
|
|
160
|
+
`);
|
|
161
|
+
const result = await restoreFromSnapshot({
|
|
162
|
+
targetUrl,
|
|
163
|
+
snapshotDir,
|
|
164
|
+
noTransaction: flags["no-transaction"],
|
|
165
|
+
// --force means replace: the schemas the snapshot covers are dropped
|
|
166
|
+
// before it is replayed. It used to only skip the not-empty check, so a
|
|
167
|
+
// restore over an existing database failed on every object already there
|
|
168
|
+
// and replaced nothing (issue #95).
|
|
169
|
+
replace: flags.force
|
|
170
|
+
});
|
|
171
|
+
this.renderResult(result, flags.json);
|
|
172
|
+
}
|
|
173
|
+
async handleMigrationRestore(flags, targetUrl) {
|
|
174
|
+
const toVersion = flags.to;
|
|
175
|
+
const fromVersion = flags.from;
|
|
176
|
+
if (!flags.apply) {
|
|
177
|
+
const migrations = await previewMigrationRestore(process.cwd(), toVersion, fromVersion);
|
|
178
|
+
if (flags.json) {
|
|
179
|
+
this.json({
|
|
180
|
+
dryRun: true,
|
|
181
|
+
migrations: migrations.map((m) => ({
|
|
182
|
+
version: m.version,
|
|
183
|
+
description: m.description,
|
|
184
|
+
layers: m.layers,
|
|
185
|
+
sqlStatements: m.up.sql.length,
|
|
186
|
+
apiActions: m.up.api.length
|
|
187
|
+
}))
|
|
188
|
+
});
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.log("\nRestore preview (dry-run) -- from migrations\n");
|
|
192
|
+
if (migrations.length === 0) {
|
|
193
|
+
this.log(" No migrations found.");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
for (const m of migrations) {
|
|
197
|
+
this.log(` ${m.version} ${m.description}`);
|
|
198
|
+
this.log(` Layers: ${m.layers.join(", ")}`);
|
|
199
|
+
this.log(` SQL: ${m.up.sql.length} statements`);
|
|
200
|
+
this.log(` API: ${m.up.api.length} actions`);
|
|
201
|
+
this.log("");
|
|
202
|
+
}
|
|
203
|
+
this.log(` \u2192 Add --apply to execute the restore.
|
|
204
|
+
`);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (!flags.json) this.log(`
|
|
208
|
+
Restoring from migrations...
|
|
209
|
+
`);
|
|
210
|
+
const result = await restoreFromMigrations({
|
|
211
|
+
targetUrl,
|
|
212
|
+
toVersion,
|
|
213
|
+
fromVersion
|
|
214
|
+
});
|
|
215
|
+
this.renderResult(result, flags.json);
|
|
216
|
+
}
|
|
217
|
+
renderResult(result, json) {
|
|
218
|
+
if (json) {
|
|
219
|
+
this.json(result);
|
|
220
|
+
if (result.errors.length > 0 || result.incomplete) this.exit(1);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (result.applied.length > 0) {
|
|
224
|
+
this.log(`\u2705 Applied ${result.applied.length} operation(s):`);
|
|
225
|
+
for (const op of result.applied.slice(0, 20)) {
|
|
226
|
+
this.log(` \u2713 [${op.type}] ${op.label}`);
|
|
227
|
+
}
|
|
228
|
+
if (result.applied.length > 20) {
|
|
229
|
+
this.log(` ... and ${result.applied.length - 20} more`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (result.skipped.length > 0) {
|
|
233
|
+
this.log(`
|
|
234
|
+
\u23ED Skipped ${result.skipped.length} operation(s):`);
|
|
235
|
+
for (const op of result.skipped) {
|
|
236
|
+
this.log(` \u25CB [${op.type}] ${op.label}: ${op.reason}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (result.rolledBack && result.rolledBack.length > 0) {
|
|
240
|
+
this.log(`
|
|
241
|
+
\u21A9 Rolled back ${result.rolledBack.length} operation(s) \u2014 the target is unchanged.`);
|
|
242
|
+
}
|
|
243
|
+
if (result.incomplete && result.errors.length === 0) {
|
|
244
|
+
this.log(`
|
|
245
|
+
\u26A0 Restored everything this target can hold. What it cannot is listed above as skipped.`);
|
|
246
|
+
process.exitCode = 1;
|
|
247
|
+
}
|
|
248
|
+
if (result.errors.length > 0) {
|
|
249
|
+
this.log(`
|
|
250
|
+
\u274C ${result.errors.length} error(s):`);
|
|
251
|
+
for (const op of result.errors) {
|
|
252
|
+
this.log(` \u2716 [${op.type}] ${op.label}: ${op.error}`);
|
|
253
|
+
}
|
|
254
|
+
if (result.rolledBack && result.rolledBack.length > 0) {
|
|
255
|
+
this.log(`
|
|
256
|
+
Nothing was written. Re-run with ${cmd("--no-transaction")} to keep the parts that work.`);
|
|
257
|
+
}
|
|
258
|
+
this.exit(1);
|
|
259
|
+
}
|
|
260
|
+
this.log(renderTip({ command: "restore" }));
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
export {
|
|
264
|
+
Restore as default
|
|
265
|
+
};
|
|
266
|
+
//# sourceMappingURL=restore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/commands/restore.ts"],"sourcesContent":["import { Flags } from '@oclif/core'\nimport { BaseCommand } from '../base-command.js'\nimport { findLatestSnapshot, listSnapshots } from '../snapshot'\nimport {\n restoreFromSnapshot,\n restoreFromMigrations,\n previewSnapshotRestore,\n previewMigrationRestore,\n getPublicTables,\n summarizeStatement,\n} from '../restore'\nimport { warn, cmd } from '../ui.js'\nimport { renderTip } from '../tips.js'\n\nexport default class Restore extends BaseCommand {\n static override description = 'Restore a Supabase environment from a snapshot or migration history'\n\n static override examples = [\n '<%= config.bin %> restore --env=local --from-snapshot=latest',\n '<%= config.bin %> restore --env=local --from-snapshot=latest --apply',\n '<%= config.bin %> restore --env=local --from-migrations --apply',\n '<%= config.bin %> restore --env=local --from-migrations --to=20260407T120000Z --apply',\n '<%= config.bin %> restore --env=local --from-snapshot=latest --apply --force',\n ]\n\n static override flags = {\n env: Flags.string({\n char: 'e',\n description: 'Target environment to restore into',\n required: true,\n }),\n 'from-snapshot': Flags.string({\n description: 'Restore from a snapshot (\"latest\" or a timestamp)',\n exclusive: ['from-migrations'],\n }),\n 'from-migrations': Flags.boolean({\n description: 'Restore by replaying migration files',\n exclusive: ['from-snapshot'],\n }),\n to: Flags.string({\n description: 'Replay migrations up to this version (timestamp)',\n }),\n from: Flags.string({\n description: 'Replay migrations from this version (timestamp)',\n }),\n apply: Flags.boolean({\n description: 'Actually execute the restore (default: dry-run preview)',\n default: false,\n }),\n 'no-transaction': Flags.boolean({\n description:\n 'Apply each statement on its own, keeping whatever succeeds. Off by default: '\n + 'a snapshot restore runs in one transaction, so a failure leaves the target '\n + 'exactly as it was rather than half-restored. Applies to --from-snapshot.',\n default: false,\n }),\n force: Flags.boolean({\n description: 'Allow restore into a non-empty database (destructive)',\n default: false,\n }),\n json: Flags.boolean({ description: 'Output results as JSON' }),\n }\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Restore)\n\n if (!flags['from-snapshot'] && !flags['from-migrations']) {\n this.error('Specify --from-snapshot or --from-migrations')\n }\n\n const config = await this.loadConfigOrFail()\n\n const envName = flags.env\n const { env } = this.resolveEnv(config, envName)\n\n // Preflight: verify database is reachable. Under --json too, where its\n // lines go to stderr and a failure is reported as JSON.\n const pre = this.createPreflight('Restore preflight checks')\n .addDatabase('Target', envName, env.dbUrl)\n await this.runPreflight(pre, 'Restore')\n\n // Safety: check if target DB has existing tables before destructive restore\n if (flags.apply) {\n const tables = await getPublicTables(env.dbUrl)\n if (tables.length > 0 && !flags.force) {\n if (flags.json) {\n this.json({ error: 'Target database is not empty', tables })\n this.exit(1)\n }\n this.log(`\\n${warn('Target database is not empty.')} Found ${tables.length} table(s) in public schema:`)\n for (const t of tables.slice(0, 10)) {\n this.log(` • ${t}`)\n }\n if (tables.length > 10) {\n this.log(` ... and ${tables.length - 10} more`)\n }\n this.log(`\\n Restore replays SQL into the target and may conflict with existing data.`)\n this.log(` → Use ${cmd('supaforge sync')} to apply only the differences instead.`)\n this.log(` → Add ${cmd('--force')} to drop and replace the schemas this snapshot covers.\\n`)\n // --apply was asked for and refused, so this is not success. Returning\n // 0 made `supaforge restore ... --apply && deploy` continue as though\n // the restore had happened, which is the worst possible reading of a\n // safety guard: it protects the data and then lets the pipeline act on\n // the assumption it did not have to.\n this.exit(1)\n }\n }\n\n if (flags['from-snapshot']) {\n await this.handleSnapshotRestore(flags, env.dbUrl)\n } else {\n await this.handleMigrationRestore(flags, env.dbUrl)\n }\n }\n\n private async handleSnapshotRestore(\n flags: Record<string, unknown>,\n targetUrl: string,\n ): Promise<void> {\n const snapshotRef = flags['from-snapshot'] as string\n let snapshotDir: string\n\n if (snapshotRef === 'latest') {\n const latest = await findLatestSnapshot()\n if (!latest) {\n this.error('No snapshots found. Create one with \"supaforge snapshot\" first.')\n }\n snapshotDir = latest\n } else {\n // Assume it's a timestamp — resolve to path\n const snapshots = await listSnapshots()\n const match = snapshots.find(s => s.manifest.timestamp === snapshotRef)\n if (!match) {\n this.error(`Snapshot \"${snapshotRef}\" not found. Use --from-snapshot=latest or a valid timestamp.`)\n }\n snapshotDir = match.dir\n }\n\n if (!flags.apply) {\n const preview = await previewSnapshotRestore(snapshotDir)\n if (flags.json) {\n this.json({ dryRun: true, snapshot: snapshotDir, layers: preview })\n return\n }\n this.log('\\nRestore preview (dry-run) -- from snapshot\\n')\n if (preview.length === 0) {\n this.log(' No executable SQL found in snapshot.')\n return\n }\n\n for (const { layer, statements } of preview) {\n this.log(` Layer: ${layer} (${statements.length} statements)`)\n // `summarizeStatement`, not the first line: a statement carrying a\n // leading comment — which every layer file's first one does, since the\n // header lands in the same chunk — showed the comment instead of the\n // SQL. A preview you cannot read is the one thing a preview must not\n // be. It is also what the apply path prints, so the two now describe\n // the same statement the same way.\n for (const stmt of statements.slice(0, 3)) {\n this.log(` ${summarizeStatement(stmt)}`)\n }\n if (statements.length > 3) {\n this.log(` ... and ${statements.length - 3} more`)\n }\n this.log('')\n }\n this.log(` → Add --apply to execute the restore.\\n`)\n return\n }\n\n if (!flags.json) this.log(`\\nRestoring from snapshot...\\n`)\n\n const result = await restoreFromSnapshot({\n targetUrl,\n snapshotDir,\n noTransaction: flags['no-transaction'] as boolean,\n // --force means replace: the schemas the snapshot covers are dropped\n // before it is replayed. It used to only skip the not-empty check, so a\n // restore over an existing database failed on every object already there\n // and replaced nothing (issue #95).\n replace: flags.force as boolean,\n })\n\n this.renderResult(result, flags.json as boolean)\n }\n\n private async handleMigrationRestore(\n flags: Record<string, unknown>,\n targetUrl: string,\n ): Promise<void> {\n const toVersion = flags.to as string | undefined\n const fromVersion = flags.from as string | undefined\n\n if (!flags.apply) {\n const migrations = await previewMigrationRestore(process.cwd(), toVersion, fromVersion)\n if (flags.json) {\n this.json({\n dryRun: true,\n migrations: migrations.map(m => ({\n version: m.version,\n description: m.description,\n layers: m.layers,\n sqlStatements: m.up.sql.length,\n apiActions: m.up.api.length,\n })),\n })\n return\n }\n this.log('\\nRestore preview (dry-run) -- from migrations\\n')\n if (migrations.length === 0) {\n this.log(' No migrations found.')\n return\n }\n\n for (const m of migrations) {\n this.log(` ${m.version} ${m.description}`)\n this.log(` Layers: ${m.layers.join(', ')}`)\n this.log(` SQL: ${m.up.sql.length} statements`)\n this.log(` API: ${m.up.api.length} actions`)\n this.log('')\n }\n this.log(` → Add --apply to execute the restore.\\n`)\n return\n }\n\n if (!flags.json) this.log(`\\nRestoring from migrations...\\n`)\n\n // --no-transaction is deliberately not forwarded: the migration path\n // applies and records one migration at a time, so wrapping the set in a\n // single transaction would roll back migrations that had already been\n // recorded as applied. Per-migration transactions belong with the rest of\n // the migration work in #92 rather than here.\n const result = await restoreFromMigrations({\n targetUrl,\n toVersion,\n fromVersion,\n })\n\n this.renderResult(result, flags.json as boolean)\n }\n\n private renderResult(\n result: Awaited<ReturnType<typeof restoreFromSnapshot>>,\n json: boolean,\n ): void {\n if (json) {\n // Only the JSON on stdout, so it parses, and the same exit code as the\n // text report: a restore that failed or left things out is not one a\n // script should read as success.\n this.json(result)\n if (result.errors.length > 0 || result.incomplete) this.exit(1)\n return\n }\n\n if (result.applied.length > 0) {\n this.log(`✅ Applied ${result.applied.length} operation(s):`)\n for (const op of result.applied.slice(0, 20)) {\n this.log(` ✓ [${op.type}] ${op.label}`)\n }\n if (result.applied.length > 20) {\n this.log(` ... and ${result.applied.length - 20} more`)\n }\n }\n\n if (result.skipped.length > 0) {\n this.log(`\\n⏭ Skipped ${result.skipped.length} operation(s):`)\n for (const op of result.skipped) {\n this.log(` ○ [${op.type}] ${op.label}: ${op.reason}`)\n }\n }\n\n if (result.rolledBack && result.rolledBack.length > 0) {\n // Reported apart from `applied`, which is empty: a restore that rolled\n // back applied nothing, and saying otherwise would be the most\n // misleading thing this command could print (issue #95).\n this.log(`\\n↩ Rolled back ${result.rolledBack.length} operation(s) — the target is unchanged.`)\n }\n\n if (result.incomplete && result.errors.length === 0) {\n // Restored, but not all of it: what was left out is listed above, each\n // with what it needed. Not a success a script should take as one.\n this.log(`\\n⚠ Restored everything this target can hold. What it cannot is listed above as skipped.`)\n process.exitCode = 1\n }\n\n if (result.errors.length > 0) {\n this.log(`\\n❌ ${result.errors.length} error(s):`)\n for (const op of result.errors) {\n this.log(` ✖ [${op.type}] ${op.label}: ${op.error}`)\n }\n if (result.rolledBack && result.rolledBack.length > 0) {\n this.log(`\\n Nothing was written. Re-run with ${cmd('--no-transaction')} to keep the parts that work.`)\n }\n this.exit(1)\n }\n\n this.log(renderTip({ command: 'restore' }))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AActB,IAAqB,UAArB,MAAqB,iBAAgB,YAAY;AAAA,EAC/C,OAAgB,cAAc;AAAA,EAE9B,OAAgB,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,OAAgB,QAAQ;AAAA,IACtB,KAAK,MAAM,OAAO;AAAA,MAChB,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU;AAAA,IACZ,CAAC;AAAA,IACD,iBAAiB,MAAM,OAAO;AAAA,MAC5B,aAAa;AAAA,MACb,WAAW,CAAC,iBAAiB;AAAA,IAC/B,CAAC;AAAA,IACD,mBAAmB,MAAM,QAAQ;AAAA,MAC/B,aAAa;AAAA,MACb,WAAW,CAAC,eAAe;AAAA,IAC7B,CAAC;AAAA,IACD,IAAI,MAAM,OAAO;AAAA,MACf,aAAa;AAAA,IACf,CAAC;AAAA,IACD,MAAM,MAAM,OAAO;AAAA,MACjB,aAAa;AAAA,IACf,CAAC;AAAA,IACD,OAAO,MAAM,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A2F;AACpG,cAAQ,WAAW;AAAA,IACrB;AAEA,QAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,WAAK,IAAI;AAAA,SAAO,OAAO,OAAO,MAAM,YAAY;AAChD,iBAAW,MAAM,OAAO,QAAQ;AAC9B,aAAK,IAAI,aAAQ,GAAG,IAAI,KAAK,GAAG,KAAK,KAAK,GAAG,KAAK,EAAE;AAAA,MACtD;AACA,UAAI,OAAO,cAAc,OAAO,WAAW,SAAS,GAAG;AACrD,aAAK,IAAI;AAAA,qCAAwC,IAAI,kBAAkB,CAAC,+BAA+B;AAAA,MACzG;AACA,WAAK,KAAK,CAAC;AAAA,IACb;AAEA,SAAK,IAAI,UAAU,EAAE,SAAS,UAAU,CAAC,CAAC;AAAA,EAC5C;AACF;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as _oclif_core_interfaces from '@oclif/core/interfaces';
|
|
2
|
+
import { BaseCommand } from '../base-command.js';
|
|
3
|
+
import '@oclif/core';
|
|
4
|
+
import '../config-CTbeRlJk.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Capture and manage environment state snapshots.
|
|
8
|
+
*
|
|
9
|
+
* Default: dry-run preview of what would be captured (requires --apply)
|
|
10
|
+
* --apply: actually capture the snapshot
|
|
11
|
+
* --migration: also generate an incremental migration diff (was: backup)
|
|
12
|
+
* --list: list existing snapshots
|
|
13
|
+
* --prune: delete old snapshots
|
|
14
|
+
*/
|
|
15
|
+
declare class Snapshot extends BaseCommand {
|
|
16
|
+
static description: string;
|
|
17
|
+
static examples: string[];
|
|
18
|
+
static flags: {
|
|
19
|
+
env: _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
20
|
+
migration: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
21
|
+
description: _oclif_core_interfaces.OptionFlag<string, _oclif_core_interfaces.CustomOptions>;
|
|
22
|
+
list: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
23
|
+
prune: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
24
|
+
keep: _oclif_core_interfaces.OptionFlag<number, _oclif_core_interfaces.CustomOptions>;
|
|
25
|
+
apply: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
26
|
+
json: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
27
|
+
output: _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
28
|
+
};
|
|
29
|
+
run(): Promise<void>;
|
|
30
|
+
private logSnapshotResult;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Snapshot as default };
|