@xqli02/mneme 0.1.1 → 0.1.2
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/src/commands/doctor.mjs +11 -4
- package/src/commands/init.mjs +22 -12
package/package.json
CHANGED
package/src/commands/doctor.mjs
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { has, run, log, color } from "../utils.mjs";
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
7
|
-
import { readdirSync } from "node:fs";
|
|
6
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Check a single dependency. Returns true if OK.
|
|
@@ -20,13 +19,21 @@ function checkCmd(name, versionCmd) {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
|
-
* Check if dolt server is reachable by bd.
|
|
22
|
+
* Check if dolt server is reachable by bd. Show which database is in use.
|
|
24
23
|
*/
|
|
25
24
|
function checkDoltServer() {
|
|
26
25
|
if (!has("bd")) return false;
|
|
27
26
|
const result = run("bd list --status=open 2>&1");
|
|
28
27
|
if (result !== null && !result.includes("unreachable") && !result.includes("Error")) {
|
|
29
|
-
|
|
28
|
+
// Show which database this project uses
|
|
29
|
+
let dbInfo = "";
|
|
30
|
+
if (existsSync(".beads/metadata.json")) {
|
|
31
|
+
try {
|
|
32
|
+
const meta = JSON.parse(readFileSync(".beads/metadata.json", "utf-8"));
|
|
33
|
+
if (meta.dolt_database) dbInfo = ` ${color.dim(`(db: ${meta.dolt_database})`)}`;
|
|
34
|
+
} catch { /* ignore */ }
|
|
35
|
+
}
|
|
36
|
+
log.ok(`dolt server reachable${dbInfo}`);
|
|
30
37
|
return true;
|
|
31
38
|
}
|
|
32
39
|
log.warn("dolt server not running or not reachable");
|
package/src/commands/init.mjs
CHANGED
|
@@ -221,24 +221,34 @@ function installBd() {
|
|
|
221
221
|
|
|
222
222
|
// ── Dolt server + bd init ───────────────────────────────────────────────────
|
|
223
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Shared dolt data directory. All projects store their databases here,
|
|
226
|
+
* isolated by database name (e.g. beads_projectA, beads_projectB).
|
|
227
|
+
* One dolt server on port 3307 serves all projects on this machine.
|
|
228
|
+
*/
|
|
229
|
+
const DOLT_DATA_DIR = process.env.MNEME_DOLT_DATA_DIR
|
|
230
|
+
|| join(process.env.HOME, ".dolt", "databases");
|
|
231
|
+
|
|
232
|
+
const DOLT_PORT = parseInt(process.env.MNEME_DOLT_PORT || "3307", 10);
|
|
233
|
+
|
|
224
234
|
function ensureDoltServer() {
|
|
225
|
-
|
|
235
|
+
if (!existsSync(DOLT_DATA_DIR)) {
|
|
236
|
+
mkdirSync(DOLT_DATA_DIR, { recursive: true });
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Check if a dolt server is already running and reachable
|
|
226
240
|
const test = run("bd list --status=open 2>&1");
|
|
227
241
|
if (test !== null && !test.includes("unreachable") && !test.includes("connection refused")) {
|
|
228
|
-
log.ok(
|
|
242
|
+
log.ok(`dolt server already running ${color.dim(`(port ${DOLT_PORT})`)}`);
|
|
229
243
|
return true;
|
|
230
244
|
}
|
|
231
245
|
|
|
232
|
-
log.info(
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
if (!existsSync(dataDir)) {
|
|
236
|
-
mkdirSync(dataDir, { recursive: true });
|
|
237
|
-
}
|
|
246
|
+
log.info(`Starting dolt server (port ${DOLT_PORT}, data-dir ${DOLT_DATA_DIR})...`);
|
|
247
|
+
const logFile = join(DOLT_DATA_DIR, "server.log");
|
|
238
248
|
|
|
239
|
-
// Start in background
|
|
249
|
+
// Start in background — shared data dir, all project databases coexist
|
|
240
250
|
run(
|
|
241
|
-
`nohup dolt sql-server --host 127.0.0.1 --port
|
|
251
|
+
`nohup dolt sql-server --host 127.0.0.1 --port ${DOLT_PORT} --data-dir "${DOLT_DATA_DIR}" > "${logFile}" 2>&1 &`,
|
|
242
252
|
);
|
|
243
253
|
|
|
244
254
|
// Wait for server to be ready (up to 10s)
|
|
@@ -246,12 +256,12 @@ function ensureDoltServer() {
|
|
|
246
256
|
run("sleep 1");
|
|
247
257
|
const check = run("bd list --status=open 2>&1");
|
|
248
258
|
if (check !== null && !check.includes("unreachable") && !check.includes("connection refused")) {
|
|
249
|
-
log.ok(
|
|
259
|
+
log.ok(`dolt server started ${color.dim(`(port ${DOLT_PORT})`)}`);
|
|
250
260
|
return true;
|
|
251
261
|
}
|
|
252
262
|
}
|
|
253
263
|
|
|
254
|
-
log.fail(
|
|
264
|
+
log.fail(`dolt server failed to start. Check ${logFile}`);
|
|
255
265
|
return false;
|
|
256
266
|
}
|
|
257
267
|
|