code-context-graph 0.5.2
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/install.js +116 -0
- package/package.json +29 -0
package/install.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
const http = require("http");
|
|
8
|
+
|
|
9
|
+
const pkg = require("./package.json");
|
|
10
|
+
const version = pkg.version;
|
|
11
|
+
const repo = "tae2089/code-context-graph";
|
|
12
|
+
|
|
13
|
+
const PLATFORMS = {
|
|
14
|
+
"darwin-arm64": "ccg-darwin-arm64",
|
|
15
|
+
"darwin-x64": "ccg-darwin-amd64",
|
|
16
|
+
"linux-x64": "ccg-linux-amd64",
|
|
17
|
+
"linux-arm64": "ccg-linux-arm64",
|
|
18
|
+
"win32-x64": "ccg-windows-amd64",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function getPlatformKey() {
|
|
22
|
+
const platform = process.platform;
|
|
23
|
+
const arch = process.arch;
|
|
24
|
+
return `${platform}-${arch}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getBinaryName() {
|
|
28
|
+
const key = getPlatformKey();
|
|
29
|
+
const name = PLATFORMS[key];
|
|
30
|
+
if (!name) {
|
|
31
|
+
console.error(`Unsupported platform: ${key}`);
|
|
32
|
+
console.error(`Supported: ${Object.keys(PLATFORMS).join(", ")}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
return name;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getDownloadUrl(binaryName) {
|
|
39
|
+
const isWindows = process.platform === "win32";
|
|
40
|
+
const ext = isWindows ? ".zip" : ".tar.gz";
|
|
41
|
+
return `https://github.com/${repo}/releases/download/v${version}/${binaryName}${ext}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function download(url) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const follow = (url) => {
|
|
47
|
+
const client = url.startsWith("https") ? https : http;
|
|
48
|
+
client.get(url, (res) => {
|
|
49
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
50
|
+
follow(res.headers.location);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (res.statusCode !== 200) {
|
|
54
|
+
reject(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const chunks = [];
|
|
58
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
59
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
60
|
+
res.on("error", reject);
|
|
61
|
+
}).on("error", reject);
|
|
62
|
+
};
|
|
63
|
+
follow(url);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function install() {
|
|
68
|
+
const binaryName = getBinaryName();
|
|
69
|
+
const url = getDownloadUrl(binaryName);
|
|
70
|
+
const binDir = path.join(__dirname, "bin");
|
|
71
|
+
const isWindows = process.platform === "win32";
|
|
72
|
+
const binPath = path.join(binDir, isWindows ? "ccg.exe" : "ccg");
|
|
73
|
+
|
|
74
|
+
// Skip if binary already exists
|
|
75
|
+
if (fs.existsSync(binPath)) {
|
|
76
|
+
console.log(`ccg already installed at ${binPath}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
console.log(`Downloading ccg v${version} for ${getPlatformKey()}...`);
|
|
81
|
+
console.log(` ${url}`);
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const data = await download(url);
|
|
85
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
86
|
+
|
|
87
|
+
if (isWindows) {
|
|
88
|
+
// Write zip and extract
|
|
89
|
+
const zipPath = path.join(binDir, "ccg.zip");
|
|
90
|
+
fs.writeFileSync(zipPath, data);
|
|
91
|
+
execSync(`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${binDir}' -Force"`, { stdio: "ignore" });
|
|
92
|
+
fs.unlinkSync(zipPath);
|
|
93
|
+
} else {
|
|
94
|
+
// Write tar.gz and extract
|
|
95
|
+
const tarPath = path.join(binDir, "ccg.tar.gz");
|
|
96
|
+
fs.writeFileSync(tarPath, data);
|
|
97
|
+
execSync(`tar xzf "${tarPath}" -C "${binDir}"`, { stdio: "ignore" });
|
|
98
|
+
fs.unlinkSync(tarPath);
|
|
99
|
+
|
|
100
|
+
// Rename platform-specific binary to 'ccg'
|
|
101
|
+
const extracted = path.join(binDir, binaryName);
|
|
102
|
+
if (fs.existsSync(extracted) && extracted !== binPath) {
|
|
103
|
+
fs.renameSync(extracted, binPath);
|
|
104
|
+
}
|
|
105
|
+
fs.chmodSync(binPath, 0o755);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log(`ccg v${version} installed successfully.`);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.error(`Failed to install ccg: ${err.message}`);
|
|
111
|
+
console.error(`You can build manually: CGO_ENABLED=1 go build -tags "fts5" -o ccg ./cmd/ccg/`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
install();
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "code-context-graph",
|
|
3
|
+
"version": "0.5.2",
|
|
4
|
+
"description": "Local code analysis tool — parse codebases into knowledge graphs with 15 language support, annotation search, and Cypher queries",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"code-analysis",
|
|
7
|
+
"knowledge-graph",
|
|
8
|
+
"tree-sitter",
|
|
9
|
+
"mcp",
|
|
10
|
+
"cypher",
|
|
11
|
+
"apache-age",
|
|
12
|
+
"annotations"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/tae2089/code-context-graph"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"bin": {
|
|
20
|
+
"ccg": "bin/ccg"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"postinstall": "node install.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"install.js",
|
|
27
|
+
"bin/"
|
|
28
|
+
]
|
|
29
|
+
}
|