@d5render/cli 0.1.37 → 0.1.38
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/d5cli +37 -5
- package/package.json +1 -1
package/bin/d5cli
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name$1 = "@d5render/cli";
|
|
10
|
-
var version = "0.1.
|
|
10
|
+
var version = "0.1.38";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region copilot/server/config.ts
|
|
@@ -322,21 +322,53 @@ function getCopilotPackageNames() {
|
|
|
322
322
|
function findCopilopt() {
|
|
323
323
|
const packageNames = getCopilotPackageNames();
|
|
324
324
|
let copilot = "";
|
|
325
|
+
let foundPackageName = "";
|
|
325
326
|
for (const packageName of packageNames) try {
|
|
326
327
|
copilot = execSync(`npm list ${packageName} -g -p`).toString().trim();
|
|
327
|
-
if (copilot)
|
|
328
|
+
if (copilot) {
|
|
329
|
+
foundPackageName = packageName;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
328
332
|
} catch {}
|
|
329
333
|
if (!copilot) {
|
|
330
334
|
const first = platform === "win32" ? win : linux;
|
|
331
335
|
const second = platform === "win32" ? linux : win;
|
|
332
|
-
|
|
333
|
-
if (
|
|
336
|
+
const result = first();
|
|
337
|
+
if (result) {
|
|
338
|
+
copilot = result;
|
|
339
|
+
const pathParts = copilot.split(/[/\\]/);
|
|
340
|
+
const nodeModulesIndex = pathParts.indexOf("node_modules");
|
|
341
|
+
if (nodeModulesIndex !== -1 && pathParts[nodeModulesIndex + 1]) foundPackageName = pathParts[nodeModulesIndex + 1] === "@github" ? `${pathParts[nodeModulesIndex + 1]}/${pathParts[nodeModulesIndex + 2]}` : pathParts[nodeModulesIndex + 1];
|
|
342
|
+
} else {
|
|
343
|
+
copilot = second();
|
|
344
|
+
if (copilot) {
|
|
345
|
+
const pathParts = copilot.split(/[/\\]/);
|
|
346
|
+
const nodeModulesIndex = pathParts.indexOf("node_modules");
|
|
347
|
+
if (nodeModulesIndex !== -1 && pathParts[nodeModulesIndex + 1]) foundPackageName = pathParts[nodeModulesIndex + 1] === "@github" ? `${pathParts[nodeModulesIndex + 1]}/${pathParts[nodeModulesIndex + 2]}` : pathParts[nodeModulesIndex + 1];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
334
350
|
if (!copilot) throw new Error("没找到安装的包");
|
|
335
351
|
}
|
|
336
352
|
const pkg = join(copilot, "package.json");
|
|
337
353
|
if (!existsSync(pkg)) throw new Error("安装的包找不到正确版本 " + pkg);
|
|
338
354
|
const copilotPackage = JSON.parse(readFileSync(pkg, "utf8"));
|
|
339
|
-
|
|
355
|
+
let binPath;
|
|
356
|
+
if (typeof copilotPackage.bin === "string") binPath = copilotPackage.bin;
|
|
357
|
+
else if (copilotPackage.bin) {
|
|
358
|
+
const possibleKeys = foundPackageName ? [
|
|
359
|
+
foundPackageName,
|
|
360
|
+
"copilot",
|
|
361
|
+
"@github/copilot"
|
|
362
|
+
] : [
|
|
363
|
+
"copilot",
|
|
364
|
+
"@github/copilot",
|
|
365
|
+
...packageNames
|
|
366
|
+
];
|
|
367
|
+
for (const key of possibleKeys) if (copilotPackage.bin[key]) {
|
|
368
|
+
binPath = copilotPackage.bin[key];
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
340
372
|
if (!binPath) throw new Error("non copilot executable found");
|
|
341
373
|
const copilotVersion = copilotPackage.version || "unknown";
|
|
342
374
|
const copilotPath = join(copilot, binPath);
|