@grafema/cli 0.2.3-beta → 0.2.4-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/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +13 -79
- package/package.json +3 -3
- package/src/commands/server.ts +14 -86
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgDpC,eAAO,MAAM,aAAa,SAaxB,CAAC"}
|
package/dist/commands/server.js
CHANGED
|
@@ -7,74 +7,12 @@
|
|
|
7
7
|
* grafema server status - Check if server is running
|
|
8
8
|
*/
|
|
9
9
|
import { Command } from 'commander';
|
|
10
|
-
import { resolve, join
|
|
10
|
+
import { resolve, join } from 'path';
|
|
11
11
|
import { existsSync, unlinkSync, writeFileSync, readFileSync } from 'fs';
|
|
12
12
|
import { spawn } from 'child_process';
|
|
13
|
-
import { fileURLToPath } from 'url';
|
|
14
13
|
import { setTimeout as sleep } from 'timers/promises';
|
|
15
|
-
import { RFDBClient, loadConfig } from '@grafema/core';
|
|
14
|
+
import { RFDBClient, loadConfig, findRfdbBinary, getBinaryNotFoundMessage } from '@grafema/core';
|
|
16
15
|
import { exitWithError } from '../utils/errorFormatter.js';
|
|
17
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
-
const __dirname = dirname(__filename);
|
|
19
|
-
/**
|
|
20
|
-
* Find RFDB server binary in order of preference:
|
|
21
|
-
* 1. Explicit path (from --binary flag or config)
|
|
22
|
-
* 2. Monorepo development (target/release, target/debug)
|
|
23
|
-
* 3. @grafema/rfdb npm package (prebuilt binaries)
|
|
24
|
-
* 4. ~/.local/bin/rfdb-server (user-installed)
|
|
25
|
-
*/
|
|
26
|
-
function findServerBinary(explicitPath) {
|
|
27
|
-
// 1. Explicit path from --binary flag or config
|
|
28
|
-
if (explicitPath) {
|
|
29
|
-
const resolved = resolve(explicitPath);
|
|
30
|
-
if (existsSync(resolved)) {
|
|
31
|
-
return resolved;
|
|
32
|
-
}
|
|
33
|
-
// Explicit path specified but not found - this is an error
|
|
34
|
-
console.error(`Specified binary not found: ${resolved}`);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
// 2. Check packages/rfdb-server in monorepo (for development)
|
|
38
|
-
const projectRoot = join(__dirname, '../../../..');
|
|
39
|
-
const releaseBinary = join(projectRoot, 'packages/rfdb-server/target/release/rfdb-server');
|
|
40
|
-
if (existsSync(releaseBinary)) {
|
|
41
|
-
return releaseBinary;
|
|
42
|
-
}
|
|
43
|
-
const debugBinary = join(projectRoot, 'packages/rfdb-server/target/debug/rfdb-server');
|
|
44
|
-
if (existsSync(debugBinary)) {
|
|
45
|
-
return debugBinary;
|
|
46
|
-
}
|
|
47
|
-
// 3. Check @grafema/rfdb npm package
|
|
48
|
-
try {
|
|
49
|
-
const rfdbPkg = require.resolve('@grafema/rfdb');
|
|
50
|
-
const rfdbDir = dirname(rfdbPkg);
|
|
51
|
-
const platform = process.platform;
|
|
52
|
-
const arch = process.arch;
|
|
53
|
-
let platformDir;
|
|
54
|
-
if (platform === 'darwin') {
|
|
55
|
-
platformDir = arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
|
|
56
|
-
}
|
|
57
|
-
else if (platform === 'linux') {
|
|
58
|
-
platformDir = arch === 'arm64' ? 'linux-arm64' : 'linux-x64';
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
platformDir = `${platform}-${arch}`;
|
|
62
|
-
}
|
|
63
|
-
const npmBinary = join(rfdbDir, 'prebuilt', platformDir, 'rfdb-server');
|
|
64
|
-
if (existsSync(npmBinary)) {
|
|
65
|
-
return npmBinary;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
// @grafema/rfdb not installed
|
|
70
|
-
}
|
|
71
|
-
// 4. Check ~/.local/bin (user-installed binary for unsupported platforms)
|
|
72
|
-
const homeBinary = join(process.env.HOME || '', '.local', 'bin', 'rfdb-server');
|
|
73
|
-
if (existsSync(homeBinary)) {
|
|
74
|
-
return homeBinary;
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
16
|
/**
|
|
79
17
|
* Check if server is running by attempting to ping it
|
|
80
18
|
*/
|
|
@@ -151,10 +89,10 @@ serverCommand
|
|
|
151
89
|
unlinkSync(socketPath);
|
|
152
90
|
}
|
|
153
91
|
// Determine binary path: CLI flag > config > auto-detect
|
|
154
|
-
let
|
|
92
|
+
let explicitPath;
|
|
155
93
|
if (options.binary) {
|
|
156
94
|
// Explicit --binary flag
|
|
157
|
-
|
|
95
|
+
explicitPath = options.binary;
|
|
158
96
|
}
|
|
159
97
|
else {
|
|
160
98
|
// Try to read from config
|
|
@@ -162,26 +100,22 @@ serverCommand
|
|
|
162
100
|
const config = loadConfig(projectPath);
|
|
163
101
|
const serverConfig = config.server;
|
|
164
102
|
if (serverConfig?.binaryPath) {
|
|
165
|
-
|
|
103
|
+
explicitPath = serverConfig.binaryPath;
|
|
166
104
|
}
|
|
167
105
|
}
|
|
168
106
|
catch {
|
|
169
107
|
// Config not found or invalid - continue with auto-detect
|
|
170
108
|
}
|
|
171
|
-
// Auto-detect if not specified
|
|
172
|
-
if (!binaryPath) {
|
|
173
|
-
binaryPath = findServerBinary();
|
|
174
|
-
}
|
|
175
109
|
}
|
|
110
|
+
const binaryPath = findRfdbBinary({ explicitPath });
|
|
176
111
|
if (!binaryPath) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
]);
|
|
112
|
+
// If explicit path was given but not found, show specific error
|
|
113
|
+
if (explicitPath) {
|
|
114
|
+
exitWithError(`Specified binary not found: ${resolve(explicitPath)}`, [
|
|
115
|
+
'Check the path and try again'
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
exitWithError('RFDB server binary not found', getBinaryNotFoundMessage().split('\n').slice(2));
|
|
185
119
|
}
|
|
186
120
|
console.log(`Starting RFDB server...`);
|
|
187
121
|
console.log(` Binary: ${binaryPath}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafema/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4-beta",
|
|
4
4
|
"description": "CLI for Grafema code analysis toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"ink-text-input": "^6.0.0",
|
|
38
38
|
"react": "^19.2.3",
|
|
39
39
|
"yaml": "^2.8.2",
|
|
40
|
-
"@grafema/core": "0.2.
|
|
41
|
-
"@grafema/types": "0.2.
|
|
40
|
+
"@grafema/core": "0.2.4-beta",
|
|
41
|
+
"@grafema/types": "0.2.4-beta"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^25.0.8",
|
package/src/commands/server.ts
CHANGED
|
@@ -8,86 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Command } from 'commander';
|
|
11
|
-
import { resolve, join
|
|
11
|
+
import { resolve, join } from 'path';
|
|
12
12
|
import { existsSync, unlinkSync, writeFileSync, readFileSync } from 'fs';
|
|
13
13
|
import { spawn } from 'child_process';
|
|
14
|
-
import { fileURLToPath } from 'url';
|
|
15
14
|
import { setTimeout as sleep } from 'timers/promises';
|
|
16
|
-
import { RFDBClient, loadConfig } from '@grafema/core';
|
|
15
|
+
import { RFDBClient, loadConfig, findRfdbBinary, getBinaryNotFoundMessage } from '@grafema/core';
|
|
17
16
|
import { exitWithError } from '../utils/errorFormatter.js';
|
|
18
17
|
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
const __dirname = dirname(__filename);
|
|
21
|
-
|
|
22
18
|
// Extend config type for server settings
|
|
23
19
|
interface ServerConfig {
|
|
24
20
|
binaryPath?: string;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
/**
|
|
28
|
-
* Find RFDB server binary in order of preference:
|
|
29
|
-
* 1. Explicit path (from --binary flag or config)
|
|
30
|
-
* 2. Monorepo development (target/release, target/debug)
|
|
31
|
-
* 3. @grafema/rfdb npm package (prebuilt binaries)
|
|
32
|
-
* 4. ~/.local/bin/rfdb-server (user-installed)
|
|
33
|
-
*/
|
|
34
|
-
function findServerBinary(explicitPath?: string): string | null {
|
|
35
|
-
// 1. Explicit path from --binary flag or config
|
|
36
|
-
if (explicitPath) {
|
|
37
|
-
const resolved = resolve(explicitPath);
|
|
38
|
-
if (existsSync(resolved)) {
|
|
39
|
-
return resolved;
|
|
40
|
-
}
|
|
41
|
-
// Explicit path specified but not found - this is an error
|
|
42
|
-
console.error(`Specified binary not found: ${resolved}`);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 2. Check packages/rfdb-server in monorepo (for development)
|
|
47
|
-
const projectRoot = join(__dirname, '../../../..');
|
|
48
|
-
const releaseBinary = join(projectRoot, 'packages/rfdb-server/target/release/rfdb-server');
|
|
49
|
-
if (existsSync(releaseBinary)) {
|
|
50
|
-
return releaseBinary;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const debugBinary = join(projectRoot, 'packages/rfdb-server/target/debug/rfdb-server');
|
|
54
|
-
if (existsSync(debugBinary)) {
|
|
55
|
-
return debugBinary;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 3. Check @grafema/rfdb npm package
|
|
59
|
-
try {
|
|
60
|
-
const rfdbPkg = require.resolve('@grafema/rfdb');
|
|
61
|
-
const rfdbDir = dirname(rfdbPkg);
|
|
62
|
-
const platform = process.platform;
|
|
63
|
-
const arch = process.arch;
|
|
64
|
-
|
|
65
|
-
let platformDir: string;
|
|
66
|
-
if (platform === 'darwin') {
|
|
67
|
-
platformDir = arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
|
|
68
|
-
} else if (platform === 'linux') {
|
|
69
|
-
platformDir = arch === 'arm64' ? 'linux-arm64' : 'linux-x64';
|
|
70
|
-
} else {
|
|
71
|
-
platformDir = `${platform}-${arch}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const npmBinary = join(rfdbDir, 'prebuilt', platformDir, 'rfdb-server');
|
|
75
|
-
if (existsSync(npmBinary)) {
|
|
76
|
-
return npmBinary;
|
|
77
|
-
}
|
|
78
|
-
} catch {
|
|
79
|
-
// @grafema/rfdb not installed
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// 4. Check ~/.local/bin (user-installed binary for unsupported platforms)
|
|
83
|
-
const homeBinary = join(process.env.HOME || '', '.local', 'bin', 'rfdb-server');
|
|
84
|
-
if (existsSync(homeBinary)) {
|
|
85
|
-
return homeBinary;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
23
|
/**
|
|
92
24
|
* Check if server is running by attempting to ping it
|
|
93
25
|
*/
|
|
@@ -172,38 +104,34 @@ serverCommand
|
|
|
172
104
|
}
|
|
173
105
|
|
|
174
106
|
// Determine binary path: CLI flag > config > auto-detect
|
|
175
|
-
let
|
|
107
|
+
let explicitPath: string | undefined;
|
|
176
108
|
|
|
177
109
|
if (options.binary) {
|
|
178
110
|
// Explicit --binary flag
|
|
179
|
-
|
|
111
|
+
explicitPath = options.binary;
|
|
180
112
|
} else {
|
|
181
113
|
// Try to read from config
|
|
182
114
|
try {
|
|
183
115
|
const config = loadConfig(projectPath);
|
|
184
116
|
const serverConfig = (config as unknown as { server?: ServerConfig }).server;
|
|
185
117
|
if (serverConfig?.binaryPath) {
|
|
186
|
-
|
|
118
|
+
explicitPath = serverConfig.binaryPath;
|
|
187
119
|
}
|
|
188
120
|
} catch {
|
|
189
121
|
// Config not found or invalid - continue with auto-detect
|
|
190
122
|
}
|
|
191
|
-
|
|
192
|
-
// Auto-detect if not specified
|
|
193
|
-
if (!binaryPath) {
|
|
194
|
-
binaryPath = findServerBinary();
|
|
195
|
-
}
|
|
196
123
|
}
|
|
197
124
|
|
|
125
|
+
const binaryPath = findRfdbBinary({ explicitPath });
|
|
126
|
+
|
|
198
127
|
if (!binaryPath) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
]);
|
|
128
|
+
// If explicit path was given but not found, show specific error
|
|
129
|
+
if (explicitPath) {
|
|
130
|
+
exitWithError(`Specified binary not found: ${resolve(explicitPath)}`, [
|
|
131
|
+
'Check the path and try again'
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
exitWithError('RFDB server binary not found', getBinaryNotFoundMessage().split('\n').slice(2));
|
|
207
135
|
}
|
|
208
136
|
|
|
209
137
|
console.log(`Starting RFDB server...`);
|