@grafema/rfdb 0.2.0-beta → 0.2.3-beta
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/rfdb-server.js +27 -10
- package/package.json +1 -1
- package/scripts/postinstall.js +44 -15
package/bin/rfdb-server.js
CHANGED
|
@@ -24,19 +24,36 @@ function getBinaryPath() {
|
|
|
24
24
|
process.exit(1);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// Check prebuilt binary first
|
|
28
|
+
const prebuiltPath = path.join(__dirname, '..', 'prebuilt', platformDir, 'rfdb-server');
|
|
29
|
+
if (fs.existsSync(prebuiltPath)) {
|
|
30
|
+
return prebuiltPath;
|
|
31
|
+
}
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
process.
|
|
33
|
+
// Fallback: check for locally built binary in common locations
|
|
34
|
+
const localPaths = [
|
|
35
|
+
// Cargo release build (when building from source)
|
|
36
|
+
path.join(__dirname, '..', 'target', 'release', 'rfdb-server'),
|
|
37
|
+
// Monorepo development
|
|
38
|
+
path.join(__dirname, '..', '..', '..', 'packages', 'rfdb-server', 'target', 'release', 'rfdb-server'),
|
|
39
|
+
// Home directory fallback for manual builds
|
|
40
|
+
path.join(process.env.HOME || '', '.local', 'bin', 'rfdb-server'),
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
for (const localPath of localPaths) {
|
|
44
|
+
if (fs.existsSync(localPath)) {
|
|
45
|
+
return localPath;
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
console.error(`Binary not found for ${platform}-${arch}`);
|
|
50
|
+
console.error(`Expected at: ${prebuiltPath}`);
|
|
51
|
+
console.error('');
|
|
52
|
+
console.error('Available options:');
|
|
53
|
+
console.error('1. Build from source: cargo build --release');
|
|
54
|
+
console.error('2. Copy binary to: ~/.local/bin/rfdb-server');
|
|
55
|
+
console.error('3. Download from GitHub releases');
|
|
56
|
+
process.exit(1);
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
const binaryPath = getBinaryPath();
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* RFDB postinstall script
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Ensures the RFDB server binary is available:
|
|
6
|
+
* 1. Check for prebuilt binary (fastest)
|
|
7
|
+
* 2. Check ~/.local/bin/rfdb-server (user-installed)
|
|
8
|
+
* 3. Provide clear instructions for unsupported platforms
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
const path = require('path');
|
|
@@ -12,31 +14,58 @@ const fs = require('fs');
|
|
|
12
14
|
const platform = process.platform;
|
|
13
15
|
const arch = process.arch;
|
|
14
16
|
|
|
17
|
+
// Determine platform directory name
|
|
15
18
|
let platformDir;
|
|
16
19
|
if (platform === 'darwin') {
|
|
17
20
|
platformDir = arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
|
|
18
21
|
} else if (platform === 'linux') {
|
|
19
22
|
platformDir = arch === 'arm64' ? 'linux-arm64' : 'linux-x64';
|
|
20
23
|
} else {
|
|
21
|
-
console.warn(`\n⚠️ @grafema/rfdb:
|
|
22
|
-
console.warn(' Build from source with: cargo build --release\n');
|
|
24
|
+
console.warn(`\n⚠️ @grafema/rfdb: Platform ${platform} is not supported yet.\n`);
|
|
23
25
|
process.exit(0);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
const
|
|
28
|
+
const prebuiltDir = path.join(__dirname, '..', 'prebuilt', platformDir);
|
|
29
|
+
const binaryPath = path.join(prebuiltDir, 'rfdb-server');
|
|
30
|
+
const homeBinaryPath = path.join(process.env.HOME || '', '.local', 'bin', 'rfdb-server');
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// 1. Check for prebuilt binary
|
|
33
|
+
if (fs.existsSync(binaryPath)) {
|
|
34
|
+
try {
|
|
35
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
// Ignore chmod errors
|
|
38
|
+
}
|
|
39
|
+
console.log(`✓ @grafema/rfdb: Binary ready for ${platform}-${arch}`);
|
|
32
40
|
process.exit(0);
|
|
33
41
|
}
|
|
34
42
|
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Ignore chmod errors on Windows
|
|
43
|
+
// 2. Check if user already has binary in ~/.local/bin
|
|
44
|
+
if (fs.existsSync(homeBinaryPath)) {
|
|
45
|
+
console.log(`✓ @grafema/rfdb: Found user binary at ${homeBinaryPath}`);
|
|
46
|
+
process.exit(0);
|
|
40
47
|
}
|
|
41
48
|
|
|
42
|
-
|
|
49
|
+
// 3. No binary available - provide instructions
|
|
50
|
+
console.log(`
|
|
51
|
+
⚠️ @grafema/rfdb: No prebuilt binary for ${platform}-${arch}
|
|
52
|
+
|
|
53
|
+
To use Grafema, build the server binary from source:
|
|
54
|
+
|
|
55
|
+
# Clone and build
|
|
56
|
+
git clone https://github.com/Disentinel/grafema.git
|
|
57
|
+
cd grafema/packages/rfdb-server
|
|
58
|
+
cargo build --release
|
|
59
|
+
|
|
60
|
+
# Install to ~/.local/bin (Grafema will find it automatically)
|
|
61
|
+
mkdir -p ~/.local/bin
|
|
62
|
+
cp target/release/rfdb-server ~/.local/bin/
|
|
63
|
+
|
|
64
|
+
# Or specify in config.yaml:
|
|
65
|
+
# server:
|
|
66
|
+
# binaryPath: /path/to/rfdb-server
|
|
67
|
+
|
|
68
|
+
Requires Rust: https://rustup.rs
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
process.exit(0);
|