@farhan0431/db-snap 0.0.0-stage → 0.3.7
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/bin/dbsnap.js +57 -0
- package/package.json +37 -4
- package/README.md +0 -3
package/bin/dbsnap.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Launcher for the dbsnap Rust binary. The npm meta package "db-snap"
|
|
5
|
+
// declares per-platform packages (db-snap-<platform>-<arch>) as
|
|
6
|
+
// optionalDependencies; npm installs only the matching one and this script
|
|
7
|
+
// finds and execs it, passing stdin/stdout through untouched (required for
|
|
8
|
+
// MCP mode).
|
|
9
|
+
|
|
10
|
+
const { spawn } = require("child_process");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const fs = require("fs");
|
|
13
|
+
|
|
14
|
+
const PKGS_BY_TARGET = {
|
|
15
|
+
"win32-x64": ["@farhan0431/db-snap-win32-x64"],
|
|
16
|
+
"darwin-arm64": ["db-snap-darwin-arm64"],
|
|
17
|
+
"darwin-x64": ["db-snap-darwin-x64"],
|
|
18
|
+
"linux-x64": ["db-snap-linux-x64-gnu", "db-snap-linux-x64-musl"],
|
|
19
|
+
"linux-arm64": ["db-snap-linux-arm64"],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function fail(msg) {
|
|
23
|
+
console.error("dbsnap: " + msg);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function resolveBinary() {
|
|
28
|
+
const target = `${process.platform}-${process.arch}`;
|
|
29
|
+
const candidates = PKGS_BY_TARGET[target];
|
|
30
|
+
if (!candidates) {
|
|
31
|
+
fail(
|
|
32
|
+
`no prebuilt binary for ${target}. Supported: ${Object.keys(PKGS_BY_TARGET).join(", ")}. ` +
|
|
33
|
+
`Build from source: cargo install --git https://github.com/farhan0431/db-snap`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
for (const pkg of candidates) {
|
|
37
|
+
try {
|
|
38
|
+
const pkgJson = require.resolve(path.join(pkg, "package.json"), {
|
|
39
|
+
paths: [__dirname, process.cwd()],
|
|
40
|
+
});
|
|
41
|
+
const dir = path.dirname(pkgJson);
|
|
42
|
+
const bin = path.join(dir, "bin", process.platform === "win32" ? "dbsnap.exe" : "dbsnap");
|
|
43
|
+
if (fs.existsSync(bin)) return bin;
|
|
44
|
+
} catch {
|
|
45
|
+
// try the next candidate (e.g. musl fallback)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
fail(
|
|
49
|
+
`binary for ${target} is not installed. Reinstall with: npm i -g @farhan0431/db-snap ` +
|
|
50
|
+
`(if you installed with --no-optional / --ignore-scripts the platform package was skipped)`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const bin = resolveBinary();
|
|
55
|
+
const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
56
|
+
child.on("error", (err) => fail(`failed to launch ${bin}: ${err.message}`));
|
|
57
|
+
child.on("close", (code) => process.exit(code ?? 1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farhan0431/db-snap",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.7",
|
|
4
|
+
"description": "Instant physical database time-machine and MCP server for AI coding agents — git commit/checkout for your local database, powered by Rust.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"dbsnap": "bin/dbsnap.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=16"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"database",
|
|
17
|
+
"sqlite",
|
|
18
|
+
"mcp",
|
|
19
|
+
"snapshot",
|
|
20
|
+
"ai",
|
|
21
|
+
"cursor",
|
|
22
|
+
"claude",
|
|
23
|
+
"windsurf",
|
|
24
|
+
"backup",
|
|
25
|
+
"migration"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/farhan0431/db-snap.git"
|
|
30
|
+
},
|
|
31
|
+
"optionalDependencies": {
|
|
32
|
+
"@farhan0431/db-snap-win32-x64": "0.3.7",
|
|
33
|
+
"db-snap-darwin-arm64": "0.3.7",
|
|
34
|
+
"db-snap-darwin-x64": "0.3.7",
|
|
35
|
+
"db-snap-linux-x64-gnu": "0.3.7",
|
|
36
|
+
"db-snap-linux-x64-musl": "0.3.7",
|
|
37
|
+
"db-snap-linux-arm64": "0.3.7"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/README.md
DELETED