@cc-claw/code 0.6.64 → 0.6.66
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 +60 -5
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -9,13 +9,15 @@ const { homedir } = require("os");
|
|
|
9
9
|
const VERSION = require("./package.json").version;
|
|
10
10
|
const REPO = "cc-claws/cc-code";
|
|
11
11
|
const BASE_URL = `https://github.com/${REPO}/releases/download/npm-v${VERSION}`;
|
|
12
|
+
const RG_VERSION = "15.0.1";
|
|
13
|
+
const RG_BASE_URL = `https://github.com/microsoft/ripgrep-prebuilt/releases/download/v${RG_VERSION}`;
|
|
12
14
|
|
|
13
15
|
const PLATFORMS = {
|
|
14
|
-
"linux-x64": { os: "linux", arch: "x64", suffix: "linux-x86_64", ext: "tar.gz" },
|
|
15
|
-
"linux-arm64": { os: "linux", arch: "arm64", suffix: "linux-aarch64", ext: "tar.gz" },
|
|
16
|
-
"darwin-x64": { os: "darwin", arch: "x64", suffix: "macos-x86_64", ext: "tar.gz" },
|
|
17
|
-
"darwin-arm64": { os: "darwin", arch: "arm64", suffix: "macos-aarch64", ext: "tar.gz" },
|
|
18
|
-
"win32-x64": { os: "win32", arch: "x64", suffix: "windows-x86_64", ext: "zip" },
|
|
16
|
+
"linux-x64": { os: "linux", arch: "x64", suffix: "linux-x86_64", ext: "tar.gz", rgSuffix: "x86_64-unknown-linux-musl" },
|
|
17
|
+
"linux-arm64": { os: "linux", arch: "arm64", suffix: "linux-aarch64", ext: "tar.gz", rgSuffix: "aarch64-unknown-linux-gnu" },
|
|
18
|
+
"darwin-x64": { os: "darwin", arch: "x64", suffix: "macos-x86_64", ext: "tar.gz", rgSuffix: "x86_64-apple-darwin" },
|
|
19
|
+
"darwin-arm64": { os: "darwin", arch: "arm64", suffix: "macos-aarch64", ext: "tar.gz", rgSuffix: "aarch64-apple-darwin" },
|
|
20
|
+
"win32-x64": { os: "win32", arch: "x64", suffix: "windows-x86_64", ext: "zip", rgSuffix: "x86_64-pc-windows-msvc" },
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
function getPlatformKey() {
|
|
@@ -210,6 +212,56 @@ function migrateFromClaudeCode(home = homedir()) {
|
|
|
210
212
|
return true;
|
|
211
213
|
}
|
|
212
214
|
|
|
215
|
+
async function downloadRipgrep(platform, binDir) {
|
|
216
|
+
const rgName = platform.os === "win32" ? "rg.exe" : "rg";
|
|
217
|
+
const rgPath = join(binDir, rgName);
|
|
218
|
+
|
|
219
|
+
// 已存在则跳过
|
|
220
|
+
if (existsSync(rgPath)) {
|
|
221
|
+
console.log(" ripgrep already installed.");
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
try {
|
|
226
|
+
const rgExt = platform.os === "win32" ? "zip" : "tar.gz";
|
|
227
|
+
const rgFileName = `ripgrep-v${RG_VERSION}-${platform.rgSuffix}.${rgExt}`;
|
|
228
|
+
const rgUrl = `${RG_BASE_URL}/${rgFileName}`;
|
|
229
|
+
|
|
230
|
+
console.log(` Downloading ripgrep ${RG_VERSION}...`);
|
|
231
|
+
const rgBuffer = await download(rgUrl);
|
|
232
|
+
|
|
233
|
+
// 解压 rg 二进制到 binDir
|
|
234
|
+
if (rgExt === "tar.gz") {
|
|
235
|
+
const tmpFile = join(binDir, "rg-download.tar.gz");
|
|
236
|
+
writeFileSync(tmpFile, rgBuffer);
|
|
237
|
+
// ripgrep tar.gz 内含目录 ripgrep-x.y.z-suffix/rg
|
|
238
|
+
execSync(`tar -xzf "${tmpFile}" -C "${binDir}" --strip-components=1 --wildcards "*/rg" 2>/dev/null || tar -xzf "${tmpFile}" -C "${binDir}" --strip-components=1 "ripgrep-v${RG_VERSION}-${platform.rgSuffix}/rg"`, { stdio: "ignore" });
|
|
239
|
+
unlinkSync(tmpFile);
|
|
240
|
+
} else {
|
|
241
|
+
const AdmZip = require("adm-zip");
|
|
242
|
+
const zip = new AdmZip(rgBuffer);
|
|
243
|
+
// Windows zip 内含 rg.exe 在根目录或子目录
|
|
244
|
+
const entries = zip.getEntries();
|
|
245
|
+
for (const entry of entries) {
|
|
246
|
+
if (entry.entryName.endsWith("rg.exe")) {
|
|
247
|
+
writeFileSync(rgPath, entry.getData());
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (existsSync(rgPath)) {
|
|
254
|
+
if (platform.os !== "win32") chmodSync(rgPath, 0o755);
|
|
255
|
+
console.log(" ripgrep installed (enhances Grep/Glob performance).");
|
|
256
|
+
} else {
|
|
257
|
+
console.log(" ripgrep extraction skipped (Grep/Glob will use built-in engine).");
|
|
258
|
+
}
|
|
259
|
+
} catch (err) {
|
|
260
|
+
// rg 下载失败不阻塞安装,Rust 内置引擎作为 fallback
|
|
261
|
+
console.log(` ripgrep download skipped: ${err.message} (Grep/Glob will use built-in engine).`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
213
265
|
async function main() {
|
|
214
266
|
const key = getPlatformKey();
|
|
215
267
|
const platform = PLATFORMS[key];
|
|
@@ -257,6 +309,9 @@ async function main() {
|
|
|
257
309
|
|
|
258
310
|
console.log(`cc-code ${VERSION} installed successfully.`);
|
|
259
311
|
|
|
312
|
+
// 下载 ripgrep 预编译二进制(增强 Grep/Glob 性能,失败不阻塞安装)
|
|
313
|
+
await downloadRipgrep(platform, binDir);
|
|
314
|
+
|
|
260
315
|
const migrated = migrateFromClaudeCode();
|
|
261
316
|
|
|
262
317
|
if (!migrated) {
|