@rehearsal-db/core 0.1.0-beta.4 → 0.1.0-beta.5
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/CHANGELOG.md +25 -1
- package/README.md +11 -2
- package/SUPPORT.md +5 -0
- package/docs/commands.md +15 -4
- package/docs/getting-started.md +12 -4
- package/docs/sanitization.md +8 -5
- package/package.json +2 -2
- package/scripts/lib/rehearsal/baseline_preparation.mjs +138 -23
- package/scripts/lib/rehearsal/diagnostics.mjs +1 -1
- package/scripts/lib/rehearsal/input_discovery.mjs +155 -0
- package/scripts/lib/rehearsal/policy_review.mjs +45 -5
- package/scripts/lib/rehearsal/support_report.mjs +102 -0
- package/scripts/operations/rehearsal/rehearsal_cli.mjs +393 -128
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a copy-ready, data-free support report. The report intentionally omits
|
|
3
|
+
* project names, paths, command output, environment-variable names, row data,
|
|
4
|
+
* migration contents, and baseline identifiers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { arch, platform, release } from "node:os";
|
|
9
|
+
import { REHEARSAL_VERSION, redactDiagnosticValue } from "./diagnostics.mjs";
|
|
10
|
+
import { runRehearsalDoctor } from "./plan.mjs";
|
|
11
|
+
|
|
12
|
+
export const REHEARSAL_SUPPORT_URL =
|
|
13
|
+
"https://github.com/Ddupasquier/rehearsal-db/issues/new?template=bug.yml";
|
|
14
|
+
|
|
15
|
+
const safeEnvironment = () =>
|
|
16
|
+
Object.fromEntries(
|
|
17
|
+
["HOME", "LANG", "LC_ALL", "PATH", "SHELL", "TMPDIR"].flatMap((key) =>
|
|
18
|
+
process.env[key] === undefined ? [] : [[key, process.env[key]]],
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const runVersionCommand = (command, args) =>
|
|
23
|
+
spawnSync(command, args, {
|
|
24
|
+
encoding: "utf8",
|
|
25
|
+
env: safeEnvironment(),
|
|
26
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
27
|
+
timeout: 5_000,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const inspectTool = ({ command, args, runCommand }) => {
|
|
31
|
+
const result = runCommand(command, args);
|
|
32
|
+
if (result.error?.code === "ENOENT") return { status: "not_installed" };
|
|
33
|
+
if (result.status !== 0) return { status: "unavailable" };
|
|
34
|
+
const version = String(result.stdout || result.stderr)
|
|
35
|
+
.trim()
|
|
36
|
+
.split(/\r?\n/u)[0]
|
|
37
|
+
.slice(0, 200);
|
|
38
|
+
return {
|
|
39
|
+
status: "available",
|
|
40
|
+
version: redactDiagnosticValue(version || "version not reported"),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const collectRehearsalSupportReport = async (
|
|
45
|
+
options = {},
|
|
46
|
+
{
|
|
47
|
+
runDoctor = runRehearsalDoctor,
|
|
48
|
+
runCommand = runVersionCommand,
|
|
49
|
+
system = {
|
|
50
|
+
platform: platform(),
|
|
51
|
+
release: release(),
|
|
52
|
+
architecture: arch(),
|
|
53
|
+
node: process.versions.node,
|
|
54
|
+
},
|
|
55
|
+
} = {},
|
|
56
|
+
) => {
|
|
57
|
+
const doctor = await runDoctor(options);
|
|
58
|
+
return {
|
|
59
|
+
rehearsalVersion: REHEARSAL_VERSION,
|
|
60
|
+
system,
|
|
61
|
+
tools: {
|
|
62
|
+
npm: inspectTool({ command: "npm", args: ["--version"], runCommand }),
|
|
63
|
+
supabase: inspectTool({
|
|
64
|
+
command: "supabase",
|
|
65
|
+
args: ["--version"],
|
|
66
|
+
runCommand,
|
|
67
|
+
}),
|
|
68
|
+
dockerClient: inspectTool({
|
|
69
|
+
command: "docker",
|
|
70
|
+
args: ["--version"],
|
|
71
|
+
runCommand,
|
|
72
|
+
}),
|
|
73
|
+
dockerServer: inspectTool({
|
|
74
|
+
command: "docker",
|
|
75
|
+
args: ["info", "--format", "{{.ServerVersion}}"],
|
|
76
|
+
runCommand,
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
readiness: {
|
|
80
|
+
state: doctor.state,
|
|
81
|
+
checks: doctor.checks.map(({ id, label, status, remediation }) => ({
|
|
82
|
+
id,
|
|
83
|
+
label,
|
|
84
|
+
status,
|
|
85
|
+
...(status === "fail" && remediation ? { remediation } : {}),
|
|
86
|
+
})),
|
|
87
|
+
quarantinedHostedVariableCount:
|
|
88
|
+
doctor.ambientHostedVariables?.presentButQuarantined.length ?? 0,
|
|
89
|
+
},
|
|
90
|
+
privacy: {
|
|
91
|
+
omits: [
|
|
92
|
+
"row values",
|
|
93
|
+
"credentials",
|
|
94
|
+
"project paths",
|
|
95
|
+
"migration SQL",
|
|
96
|
+
"baseline identifiers",
|
|
97
|
+
],
|
|
98
|
+
reviewBeforeSharing: true,
|
|
99
|
+
},
|
|
100
|
+
supportUrl: REHEARSAL_SUPPORT_URL,
|
|
101
|
+
};
|
|
102
|
+
};
|