code-context-graph 0.5.2 → 0.5.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/bin/ccg.js +28 -0
- package/install.js +13 -5
- package/package.json +2 -2
package/bin/ccg.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
|
|
7
|
+
const isWindows = process.platform === "win32";
|
|
8
|
+
const binName = isWindows ? "ccg-binary.exe" : "ccg-binary";
|
|
9
|
+
const binPath = path.join(__dirname, binName);
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(binPath)) {
|
|
12
|
+
console.error("Error: ccg binary not found. Please try re-installing the package.");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
17
|
+
stdio: "inherit",
|
|
18
|
+
shell: false,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
child.on("error", (err) => {
|
|
22
|
+
console.error(`Failed to start ccg binary: ${err.message}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
child.on("exit", (code) => {
|
|
27
|
+
process.exit(code || 0);
|
|
28
|
+
});
|
package/install.js
CHANGED
|
@@ -15,7 +15,7 @@ const PLATFORMS = {
|
|
|
15
15
|
"darwin-x64": "ccg-darwin-amd64",
|
|
16
16
|
"linux-x64": "ccg-linux-amd64",
|
|
17
17
|
"linux-arm64": "ccg-linux-arm64",
|
|
18
|
-
"win32-x64": "ccg-windows-amd64",
|
|
18
|
+
"win32-x64": "ccg-windows-amd64", // This is the zip name, the file inside is .exe
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
function getPlatformKey() {
|
|
@@ -69,11 +69,11 @@ async function install() {
|
|
|
69
69
|
const url = getDownloadUrl(binaryName);
|
|
70
70
|
const binDir = path.join(__dirname, "bin");
|
|
71
71
|
const isWindows = process.platform === "win32";
|
|
72
|
-
const binPath = path.join(binDir, isWindows ? "ccg.exe" : "ccg");
|
|
72
|
+
const binPath = path.join(binDir, isWindows ? "ccg-binary.exe" : "ccg-binary");
|
|
73
73
|
|
|
74
74
|
// Skip if binary already exists
|
|
75
75
|
if (fs.existsSync(binPath)) {
|
|
76
|
-
console.log(`ccg already installed at ${binPath}`);
|
|
76
|
+
console.log(`ccg binary already installed at ${binPath}`);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -82,7 +82,9 @@ async function install() {
|
|
|
82
82
|
|
|
83
83
|
try {
|
|
84
84
|
const data = await download(url);
|
|
85
|
-
fs.
|
|
85
|
+
if (!fs.existsSync(binDir)) {
|
|
86
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
87
|
+
}
|
|
86
88
|
|
|
87
89
|
if (isWindows) {
|
|
88
90
|
// Write zip and extract
|
|
@@ -90,6 +92,12 @@ async function install() {
|
|
|
90
92
|
fs.writeFileSync(zipPath, data);
|
|
91
93
|
execSync(`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${binDir}' -Force"`, { stdio: "ignore" });
|
|
92
94
|
fs.unlinkSync(zipPath);
|
|
95
|
+
|
|
96
|
+
// In Windows, the file inside ccg-windows-amd64.zip is ccg-windows-amd64.exe
|
|
97
|
+
const extracted = path.join(binDir, `${binaryName}.exe`);
|
|
98
|
+
if (fs.existsSync(extracted) && extracted !== binPath) {
|
|
99
|
+
fs.renameSync(extracted, binPath);
|
|
100
|
+
}
|
|
93
101
|
} else {
|
|
94
102
|
// Write tar.gz and extract
|
|
95
103
|
const tarPath = path.join(binDir, "ccg.tar.gz");
|
|
@@ -97,7 +105,7 @@ async function install() {
|
|
|
97
105
|
execSync(`tar xzf "${tarPath}" -C "${binDir}"`, { stdio: "ignore" });
|
|
98
106
|
fs.unlinkSync(tarPath);
|
|
99
107
|
|
|
100
|
-
// Rename platform-specific binary to 'ccg'
|
|
108
|
+
// Rename platform-specific binary to 'ccg-binary'
|
|
101
109
|
const extracted = path.join(binDir, binaryName);
|
|
102
110
|
if (fs.existsSync(extracted) && extracted !== binPath) {
|
|
103
111
|
fs.renameSync(extracted, binPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-context-graph",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Local code analysis tool — parse codebases into knowledge graphs with 15 language support, annotation search, and Cypher queries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-analysis",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"bin": {
|
|
20
|
-
"ccg": "bin/ccg"
|
|
20
|
+
"ccg": "bin/ccg.js"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"postinstall": "node install.js"
|