feedkeeper 0.44.3 → 0.45.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/package.json +1 -1
- package/server/dist/cli.js +4 -0
- package/server/dist/doctor-cli.js +247 -0
- package/server/dist/feedkeeper.js +8 -0
- package/server/package.json +1 -1
- package/web/dist/assets/index-BSInpowW.js +113 -0
- package/web/dist/assets/index-Cq-H4L1-.css +2 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-BcKdqdmb.js +0 -113
- package/web/dist/assets/index-DKnVXchH.css +0 -2
package/package.json
CHANGED
package/server/dist/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ export const HELP = `FeedKeeper: a self-hosted RSS reader and remote MCP server
|
|
|
7
7
|
Usage:
|
|
8
8
|
feedkeeper [options] Start the server
|
|
9
9
|
feedkeeper mcp [options] Start in stdio MCP mode
|
|
10
|
+
feedkeeper doctor [options] Check configuration, paths, and SQLite health
|
|
10
11
|
feedkeeper backup <file> Back up the database (see docs for restore)
|
|
11
12
|
feedkeeper restore <file> --force Restore the database from a backup
|
|
12
13
|
|
|
@@ -73,6 +74,9 @@ export function parseArgs(argv) {
|
|
|
73
74
|
else if (options.action === "start" && argument === "mcp") {
|
|
74
75
|
options.action = "mcp";
|
|
75
76
|
}
|
|
77
|
+
else if (options.action === "start" && argument === "doctor") {
|
|
78
|
+
options.action = "doctor";
|
|
79
|
+
}
|
|
76
80
|
else if (options.action === "start" && (argument === "backup" || argument === "restore")) {
|
|
77
81
|
options.action = argument;
|
|
78
82
|
options.forwarded.push(argument);
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import { constants, accessSync, existsSync, readFileSync, readdirSync, statfsSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
import { APP_VERSION } from "./version.js";
|
|
7
|
+
const MIN_DISK_BYTES = 100 * 1024 * 1024; // 100 MiB
|
|
8
|
+
function parseSemver(version) {
|
|
9
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
|
|
10
|
+
if (!match)
|
|
11
|
+
return null;
|
|
12
|
+
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
13
|
+
}
|
|
14
|
+
export function isSupportedNodeVersion(version) {
|
|
15
|
+
const parsed = parseSemver(version);
|
|
16
|
+
if (!parsed)
|
|
17
|
+
return false;
|
|
18
|
+
const [major, minor, patch] = parsed;
|
|
19
|
+
if (major === 22)
|
|
20
|
+
return minor > 22 || (minor === 22 && patch >= 2);
|
|
21
|
+
if (major === 24)
|
|
22
|
+
return minor > 15 || (minor === 15 && patch >= 0);
|
|
23
|
+
return major >= 26;
|
|
24
|
+
}
|
|
25
|
+
function nearestExistingDir(target) {
|
|
26
|
+
let current = resolve(target);
|
|
27
|
+
while (!existsSync(current)) {
|
|
28
|
+
const parent = dirname(current);
|
|
29
|
+
if (parent === current)
|
|
30
|
+
return null;
|
|
31
|
+
current = parent;
|
|
32
|
+
}
|
|
33
|
+
return current;
|
|
34
|
+
}
|
|
35
|
+
function isWritable(target) {
|
|
36
|
+
const existing = nearestExistingDir(target);
|
|
37
|
+
if (!existing)
|
|
38
|
+
return { writable: false, existing: null };
|
|
39
|
+
try {
|
|
40
|
+
accessSync(existing, constants.R_OK | constants.W_OK);
|
|
41
|
+
return { writable: true, existing };
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return { writable: false, existing };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function formatMiB(bytes) {
|
|
48
|
+
return `${Math.round(bytes / (1024 * 1024))} MiB`;
|
|
49
|
+
}
|
|
50
|
+
/** Runs read-only diagnostics on the runtime, configuration, storage paths, and SQLite database. */
|
|
51
|
+
export function runDoctor(options = {}) {
|
|
52
|
+
const env = options.env ?? process.env;
|
|
53
|
+
const cwd = options.cwd ?? process.cwd();
|
|
54
|
+
const home = options.home ?? homedir();
|
|
55
|
+
const nodeVersion = options.nodeVersion ?? process.versions.node;
|
|
56
|
+
const checks = [];
|
|
57
|
+
if (isSupportedNodeVersion(nodeVersion)) {
|
|
58
|
+
checks.push({ name: "Node.js", status: "pass", detail: `v${nodeVersion} (supported)` });
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
checks.push({
|
|
62
|
+
name: "Node.js",
|
|
63
|
+
status: "fail",
|
|
64
|
+
detail: `v${nodeVersion} is unsupported (requires ^22.22.2 || ^24.15.0 || >=26.0.0)`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const configuredDb = env.DATABASE_PATH?.trim();
|
|
68
|
+
const dataDir = resolve(options.dataDir ?? (env.FEEDKEEPER_DATA_DIR?.trim() || (configuredDb ? dirname(resolve(configuredDb)) : join(home, ".feedkeeper"))));
|
|
69
|
+
const databasePath = options.dataDir !== undefined || !configuredDb ? join(dataDir, "feedkeeper.sqlite") : resolve(configuredDb);
|
|
70
|
+
const archivePath = env.ARCHIVE_PATH?.trim() ? resolve(env.ARCHIVE_PATH.trim()) : join(dirname(databasePath), "archive");
|
|
71
|
+
const imageCachePath = env.IMAGE_CACHE_PATH?.trim() ? resolve(env.IMAGE_CACHE_PATH.trim()) : join(dirname(databasePath), "image-cache");
|
|
72
|
+
const envSecret = env.SESSION_SECRET?.trim() ?? "";
|
|
73
|
+
const secretFilePath = join(dataDir, "session-secret");
|
|
74
|
+
let fileSecret = "";
|
|
75
|
+
if (!envSecret && existsSync(secretFilePath)) {
|
|
76
|
+
try {
|
|
77
|
+
fileSecret = readFileSync(secretFilePath, "utf8").trim();
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
checks.push({
|
|
81
|
+
name: "SESSION_SECRET",
|
|
82
|
+
status: "fail",
|
|
83
|
+
detail: `Could not read ${secretFilePath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const effectiveSecret = envSecret || fileSecret;
|
|
88
|
+
if (effectiveSecret) {
|
|
89
|
+
const source = envSecret ? "environment" : secretFilePath;
|
|
90
|
+
if (effectiveSecret.length < 32) {
|
|
91
|
+
checks.push({
|
|
92
|
+
name: "SESSION_SECRET",
|
|
93
|
+
status: "warn",
|
|
94
|
+
detail: `Set via ${source}, but shorter than 32 characters`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
checks.push({ name: "SESSION_SECRET", status: "pass", detail: `Configured via ${source}` });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (!checks.some(check => check.name === "SESSION_SECRET")) {
|
|
102
|
+
const envFile = resolve(cwd, ".env");
|
|
103
|
+
checks.push({
|
|
104
|
+
name: "SESSION_SECRET",
|
|
105
|
+
status: "warn",
|
|
106
|
+
detail: existsSync(envFile)
|
|
107
|
+
? `Not set in ${envFile} or ${secretFilePath} (generated on first start in CLI mode)`
|
|
108
|
+
: "Not set (generated on first start in CLI mode; set explicitly for Docker/production)",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const publicUrl = (options.publicUrl ?? env.PUBLIC_URL?.trim()) || `http://localhost:${env.PORT?.trim() || 3000}`;
|
|
112
|
+
try {
|
|
113
|
+
const parsed = new URL(publicUrl);
|
|
114
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
115
|
+
checks.push({ name: "PUBLIC_URL", status: "fail", detail: `Invalid protocol "${parsed.protocol}" in ${publicUrl}` });
|
|
116
|
+
}
|
|
117
|
+
else if ((env.NODE_ENV ?? "production") === "production" && parsed.hostname === "localhost" && !env.PUBLIC_URL?.trim()) {
|
|
118
|
+
checks.push({ name: "PUBLIC_URL", status: "warn", detail: `Defaults to ${publicUrl} (set PUBLIC_URL for remote access or OAuth)` });
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
checks.push({ name: "PUBLIC_URL", status: "pass", detail: publicUrl });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
checks.push({ name: "PUBLIC_URL", status: "fail", detail: `Invalid URL "${publicUrl}"` });
|
|
126
|
+
}
|
|
127
|
+
for (const [label, target] of [
|
|
128
|
+
["Data directory", dataDir],
|
|
129
|
+
["Archive directory", archivePath],
|
|
130
|
+
["Image cache directory", imageCachePath],
|
|
131
|
+
]) {
|
|
132
|
+
const access = isWritable(target);
|
|
133
|
+
if (access.writable) {
|
|
134
|
+
const suffix = existsSync(target) ? "" : ` (will be created under ${access.existing})`;
|
|
135
|
+
checks.push({ name: label, status: "pass", detail: `${target} is writable${suffix}` });
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
checks.push({
|
|
139
|
+
name: label,
|
|
140
|
+
status: "fail",
|
|
141
|
+
detail: `${target} is not writable${access.existing ? ` (checked ${access.existing})` : ""}`,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const diskTarget = nearestExistingDir(dataDir);
|
|
146
|
+
if (diskTarget) {
|
|
147
|
+
try {
|
|
148
|
+
const stats = statfsSync(diskTarget);
|
|
149
|
+
const freeBytes = Number(stats.bavail) * Number(stats.bsize);
|
|
150
|
+
if (freeBytes < MIN_DISK_BYTES) {
|
|
151
|
+
checks.push({ name: "Disk space", status: "warn", detail: `Only ${formatMiB(freeBytes)} free on ${diskTarget}` });
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
checks.push({ name: "Disk space", status: "pass", detail: `${formatMiB(freeBytes)} free on ${diskTarget}` });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
checks.push({
|
|
159
|
+
name: "Disk space",
|
|
160
|
+
status: "warn",
|
|
161
|
+
detail: `Could not inspect free space on ${diskTarget}: ${error instanceof Error ? error.message : String(error)}`,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (!existsSync(databasePath)) {
|
|
166
|
+
checks.push({
|
|
167
|
+
name: "SQLite database",
|
|
168
|
+
status: "warn",
|
|
169
|
+
detail: `${databasePath} does not exist yet (will be initialized on first start)`,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
let db = null;
|
|
174
|
+
try {
|
|
175
|
+
db = new Database(databasePath, { readonly: true, fileMustExist: true });
|
|
176
|
+
const integrity = db.pragma("quick_check", { simple: true });
|
|
177
|
+
if (integrity !== "ok") {
|
|
178
|
+
checks.push({ name: "SQLite database", status: "fail", detail: `${databasePath} failed quick_check: ${String(integrity)}` });
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const hasMigrations = db
|
|
182
|
+
.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '_migrations'")
|
|
183
|
+
.get();
|
|
184
|
+
if (!hasMigrations) {
|
|
185
|
+
checks.push({
|
|
186
|
+
name: "SQLite database",
|
|
187
|
+
status: "warn",
|
|
188
|
+
detail: `${databasePath} passed quick_check, but has no _migrations table yet`,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const applied = db.prepare("SELECT COUNT(*) AS count FROM _migrations").get()?.count ?? 0;
|
|
193
|
+
const migrationsDir = join(dirname(fileURLToPath(import.meta.url)), "db", "migrations");
|
|
194
|
+
const available = existsSync(migrationsDir)
|
|
195
|
+
? readdirSync(migrationsDir).filter(file => file.endsWith(".sql")).length
|
|
196
|
+
: applied;
|
|
197
|
+
const migrationInfo = applied < available ? `${applied}/${available} migrations applied` : `${applied} migrations applied`;
|
|
198
|
+
checks.push({ name: "SQLite database", status: "pass", detail: `${databasePath} ok (${migrationInfo})` });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
checks.push({
|
|
204
|
+
name: "SQLite database",
|
|
205
|
+
status: "fail",
|
|
206
|
+
detail: `Could not open ${databasePath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
finally {
|
|
210
|
+
db?.close();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
version: APP_VERSION,
|
|
215
|
+
ok: checks.every(check => check.status !== "fail"),
|
|
216
|
+
checks,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
export function formatDoctorReport(report) {
|
|
220
|
+
const tags = {
|
|
221
|
+
pass: "PASS",
|
|
222
|
+
warn: "WARN",
|
|
223
|
+
fail: "FAIL",
|
|
224
|
+
};
|
|
225
|
+
const lines = [`FeedKeeper doctor v${report.version}`, ""];
|
|
226
|
+
for (const check of report.checks) {
|
|
227
|
+
lines.push(`[${tags[check.status]}] ${check.name}: ${check.detail}`);
|
|
228
|
+
}
|
|
229
|
+
const fails = report.checks.filter(check => check.status === "fail").length;
|
|
230
|
+
const warns = report.checks.filter(check => check.status === "warn").length;
|
|
231
|
+
lines.push("");
|
|
232
|
+
lines.push(report.ok ? `Summary: ok (${warns} warning${warns === 1 ? "" : "s"})` : `Summary: ${fails} failed, ${warns} warning${warns === 1 ? "" : "s"}`);
|
|
233
|
+
return lines.join("\n");
|
|
234
|
+
}
|
|
235
|
+
export function runDoctorCli(options = {}) {
|
|
236
|
+
const envFile = resolve(options.cwd ?? process.cwd(), ".env");
|
|
237
|
+
if (existsSync(envFile) && !options.env) {
|
|
238
|
+
process.loadEnvFile(envFile);
|
|
239
|
+
}
|
|
240
|
+
const report = runDoctor(options);
|
|
241
|
+
console.log(formatDoctorReport(report));
|
|
242
|
+
return report.ok ? 0 : 1;
|
|
243
|
+
}
|
|
244
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
245
|
+
process.exitCode = runDoctorCli();
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=doctor-cli.js.map
|
|
@@ -14,6 +14,14 @@ async function main() {
|
|
|
14
14
|
const envFile = resolve(process.cwd(), ".env");
|
|
15
15
|
if (existsSync(envFile))
|
|
16
16
|
process.loadEnvFile(envFile);
|
|
17
|
+
if (options.action === "doctor") {
|
|
18
|
+
const { runDoctorCli } = await import("./doctor-cli.js");
|
|
19
|
+
process.exitCode = runDoctorCli({
|
|
20
|
+
dataDir: options.dataDir,
|
|
21
|
+
publicUrl: options.publicUrl,
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
17
25
|
const prepared = prepareEnvironment(options, process.env);
|
|
18
26
|
if (options.action === "backup" || options.action === "restore") {
|
|
19
27
|
process.argv.splice(2, process.argv.length, ...options.forwarded);
|