@grafeo-db/cli 0.4.4
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/README.md +63 -0
- package/bin/grafeo.js +85 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @grafeo-db/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for [Grafeo](https://grafeo.dev) graph database, distributed via npm.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @grafeo-db/cli
|
|
9
|
+
# or
|
|
10
|
+
npx @grafeo-db/cli --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The correct platform-specific binary is installed automatically via optional dependencies.
|
|
14
|
+
|
|
15
|
+
## Supported Platforms
|
|
16
|
+
|
|
17
|
+
| Platform | Package |
|
|
18
|
+
|----------|---------|
|
|
19
|
+
| Linux x64 | `@grafeo-db/cli-linux-x64` |
|
|
20
|
+
| Linux ARM64 | `@grafeo-db/cli-linux-arm64` |
|
|
21
|
+
| macOS x64 | `@grafeo-db/cli-darwin-x64` |
|
|
22
|
+
| macOS ARM64 | `@grafeo-db/cli-darwin-arm64` |
|
|
23
|
+
| Windows x64 | `@grafeo-db/cli-win32-x64` |
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Database management
|
|
29
|
+
grafeo info ./my-db
|
|
30
|
+
grafeo stats ./my-db
|
|
31
|
+
grafeo validate ./my-db
|
|
32
|
+
|
|
33
|
+
# Query execution
|
|
34
|
+
grafeo query ./my-db "MATCH (n:Person) RETURN n.name"
|
|
35
|
+
|
|
36
|
+
# Interactive shell
|
|
37
|
+
grafeo shell ./my-db
|
|
38
|
+
|
|
39
|
+
# Create a new database
|
|
40
|
+
grafeo init ./new-db
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Alternative Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Via Rust
|
|
47
|
+
cargo install grafeo-cli
|
|
48
|
+
|
|
49
|
+
# Via pip
|
|
50
|
+
pip install grafeo-cli
|
|
51
|
+
|
|
52
|
+
# Direct download
|
|
53
|
+
# https://github.com/GrafeoDB/grafeo/releases
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Links
|
|
57
|
+
|
|
58
|
+
- [Documentation](https://grafeo.dev)
|
|
59
|
+
- [GitHub](https://github.com/GrafeoDB/grafeo)
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
AGPL-3.0-or-later
|
package/bin/grafeo.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Grafeo CLI launcher for npm.
|
|
5
|
+
*
|
|
6
|
+
* Resolves the platform-specific binary from optional dependencies
|
|
7
|
+
* and spawns it with all arguments forwarded.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";
|
|
11
|
+
|
|
12
|
+
const { execFileSync } = require("child_process");
|
|
13
|
+
const { existsSync } = require("fs");
|
|
14
|
+
const { join } = require("path");
|
|
15
|
+
const { platform, arch } = require("os");
|
|
16
|
+
|
|
17
|
+
/** Map of Node.js platform/arch to package names and binary paths. */
|
|
18
|
+
const PLATFORMS = {
|
|
19
|
+
"linux-x64": { pkg: "@grafeo-db/cli-linux-x64", bin: "grafeo" },
|
|
20
|
+
"linux-arm64": { pkg: "@grafeo-db/cli-linux-arm64", bin: "grafeo" },
|
|
21
|
+
"darwin-x64": { pkg: "@grafeo-db/cli-darwin-x64", bin: "grafeo" },
|
|
22
|
+
"darwin-arm64": { pkg: "@grafeo-db/cli-darwin-arm64", bin: "grafeo" },
|
|
23
|
+
"win32-x64": { pkg: "@grafeo-db/cli-win32-x64", bin: "grafeo.exe" },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function findBinary() {
|
|
27
|
+
const key = `${platform()}-${arch()}`;
|
|
28
|
+
const entry = PLATFORMS[key];
|
|
29
|
+
|
|
30
|
+
if (!entry) {
|
|
31
|
+
console.error(
|
|
32
|
+
`error: unsupported platform ${key}\n` +
|
|
33
|
+
`Supported: ${Object.keys(PLATFORMS).join(", ")}\n` +
|
|
34
|
+
"Install the binary manually: cargo install grafeo-cli"
|
|
35
|
+
);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 1. Try platform-specific optional dependency
|
|
40
|
+
try {
|
|
41
|
+
const pkgDir = require.resolve(`${entry.pkg}/package.json`);
|
|
42
|
+
const binPath = join(pkgDir, "..", entry.bin);
|
|
43
|
+
if (existsSync(binPath)) {
|
|
44
|
+
return binPath;
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
// Package not installed (optional dependency)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 2. Try binary adjacent to this package (development installs)
|
|
51
|
+
const adjacent = join(__dirname, "..", entry.bin);
|
|
52
|
+
if (existsSync(adjacent)) {
|
|
53
|
+
return adjacent;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 3. Fall back to system PATH
|
|
57
|
+
return entry.bin;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const binary = findBinary();
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const result = execFileSync(binary, process.argv.slice(2), {
|
|
64
|
+
stdio: "inherit",
|
|
65
|
+
windowsHide: true,
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (error.status != null) {
|
|
69
|
+
process.exit(error.status);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (error.code === "ENOENT") {
|
|
73
|
+
console.error(
|
|
74
|
+
`error: grafeo binary not found.\n\n` +
|
|
75
|
+
`Install via one of:\n` +
|
|
76
|
+
` npm install @grafeo-db/cli\n` +
|
|
77
|
+
` cargo install grafeo-cli\n` +
|
|
78
|
+
` Download from https://github.com/GrafeoDB/grafeo/releases\n`
|
|
79
|
+
);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.error(`error: ${error.message}`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grafeo-db/cli",
|
|
3
|
+
"version": "0.4.4",
|
|
4
|
+
"description": "Command-line interface for Grafeo graph database",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/GrafeoDB/grafeo",
|
|
9
|
+
"directory": "packages/grafeo-cli-npm"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://grafeo.dev",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"grafeo",
|
|
14
|
+
"graph",
|
|
15
|
+
"database",
|
|
16
|
+
"gql",
|
|
17
|
+
"cli"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"grafeo": "bin/grafeo.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"bin/",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"optionalDependencies": {
|
|
28
|
+
"@grafeo-db/cli-linux-x64": "0.4.4",
|
|
29
|
+
"@grafeo-db/cli-linux-arm64": "0.4.4",
|
|
30
|
+
"@grafeo-db/cli-darwin-x64": "0.4.4",
|
|
31
|
+
"@grafeo-db/cli-darwin-arm64": "0.4.4",
|
|
32
|
+
"@grafeo-db/cli-win32-x64": "0.4.4"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
}
|
|
37
|
+
}
|