zcf 2.9.4 → 2.9.5
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/dist/chunks/simple-config.mjs +35 -24
- package/dist/cli.mjs +6 -9
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ import { promisify as promisify$1 } from 'node:util';
|
|
|
18
18
|
import { homedir, platform } from 'node:os';
|
|
19
19
|
import { join as join$2 } from 'node:path';
|
|
20
20
|
|
|
21
|
-
const version = "2.9.
|
|
21
|
+
const version = "2.9.5";
|
|
22
22
|
const homepage = "https://github.com/UfoMiao/zcf";
|
|
23
23
|
|
|
24
24
|
const common$1 = {
|
|
@@ -2583,39 +2583,51 @@ async function cleanupOldVersionFiles(scriptLang) {
|
|
|
2583
2583
|
|
|
2584
2584
|
const execAsync$1 = promisify$1(exec$2);
|
|
2585
2585
|
async function isCcrInstalled() {
|
|
2586
|
+
let commandExists = false;
|
|
2586
2587
|
try {
|
|
2587
2588
|
await execAsync$1("ccr version");
|
|
2588
|
-
|
|
2589
|
+
commandExists = true;
|
|
2589
2590
|
} catch {
|
|
2590
2591
|
try {
|
|
2591
2592
|
await execAsync$1("which ccr");
|
|
2592
|
-
|
|
2593
|
+
commandExists = true;
|
|
2593
2594
|
} catch {
|
|
2594
|
-
|
|
2595
|
+
commandExists = false;
|
|
2595
2596
|
}
|
|
2596
2597
|
}
|
|
2597
|
-
|
|
2598
|
-
async function installCcr(scriptLang) {
|
|
2599
|
-
const i18n = getTranslation(scriptLang);
|
|
2600
|
-
let hasIncorrectPackage = false;
|
|
2598
|
+
let hasCorrectPackage = false;
|
|
2601
2599
|
try {
|
|
2602
|
-
await execAsync$1("npm list -g claude-code-router");
|
|
2603
|
-
|
|
2604
|
-
console.log(ansis.yellow(`\u26A0 ${i18n.ccr.detectedIncorrectPackage}`));
|
|
2605
|
-
try {
|
|
2606
|
-
await execAsync$1("npm uninstall -g claude-code-router");
|
|
2607
|
-
console.log(ansis.green(`\u2714 ${i18n.ccr.uninstalledIncorrectPackage}`));
|
|
2608
|
-
} catch (uninstallError) {
|
|
2609
|
-
console.log(ansis.yellow(`\u26A0 ${i18n.ccr.failedToUninstallIncorrectPackage}`));
|
|
2610
|
-
}
|
|
2600
|
+
await execAsync$1("npm list -g @musistudio/claude-code-router");
|
|
2601
|
+
hasCorrectPackage = true;
|
|
2611
2602
|
} catch {
|
|
2603
|
+
hasCorrectPackage = false;
|
|
2612
2604
|
}
|
|
2613
|
-
|
|
2614
|
-
|
|
2605
|
+
return {
|
|
2606
|
+
isInstalled: commandExists,
|
|
2607
|
+
hasCorrectPackage
|
|
2608
|
+
};
|
|
2609
|
+
}
|
|
2610
|
+
async function installCcr(scriptLang) {
|
|
2611
|
+
const i18n = getTranslation(scriptLang);
|
|
2612
|
+
const { isInstalled, hasCorrectPackage } = await isCcrInstalled();
|
|
2613
|
+
if (hasCorrectPackage) {
|
|
2615
2614
|
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled}`));
|
|
2616
2615
|
await updateCcr(scriptLang);
|
|
2617
2616
|
return;
|
|
2618
2617
|
}
|
|
2618
|
+
if (isInstalled && !hasCorrectPackage) {
|
|
2619
|
+
try {
|
|
2620
|
+
await execAsync$1("npm list -g claude-code-router");
|
|
2621
|
+
console.log(ansis.yellow(`\u26A0 ${i18n.ccr.detectedIncorrectPackage}`));
|
|
2622
|
+
try {
|
|
2623
|
+
await execAsync$1("npm uninstall -g claude-code-router");
|
|
2624
|
+
console.log(ansis.green(`\u2714 ${i18n.ccr.uninstalledIncorrectPackage}`));
|
|
2625
|
+
} catch (uninstallError) {
|
|
2626
|
+
console.log(ansis.yellow(`\u26A0 ${i18n.ccr.failedToUninstallIncorrectPackage}`));
|
|
2627
|
+
}
|
|
2628
|
+
} catch {
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2619
2631
|
console.log(ansis.cyan(`\u{1F4E6} ${i18n.ccr.installingCcr}`));
|
|
2620
2632
|
try {
|
|
2621
2633
|
await execAsync$1("npm install -g @musistudio/claude-code-router --force");
|
|
@@ -3168,9 +3180,8 @@ async function init(options = {}) {
|
|
|
3168
3180
|
} else if (apiAction === "modify-all") {
|
|
3169
3181
|
apiConfig = await configureApiCompletely(i18n, scriptLang);
|
|
3170
3182
|
} else if (apiAction === "use-ccr") {
|
|
3171
|
-
const
|
|
3172
|
-
if (!
|
|
3173
|
-
console.log(ansis.yellow(`${i18n.ccr.installingCcr}`));
|
|
3183
|
+
const ccrStatus = await isCcrInstalled();
|
|
3184
|
+
if (!ccrStatus.hasCorrectPackage) {
|
|
3174
3185
|
await installCcr(scriptLang);
|
|
3175
3186
|
} else {
|
|
3176
3187
|
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled}`));
|
|
@@ -3213,8 +3224,8 @@ async function init(options = {}) {
|
|
|
3213
3224
|
process.exit(0);
|
|
3214
3225
|
}
|
|
3215
3226
|
if (apiChoice === "ccr_proxy") {
|
|
3216
|
-
const
|
|
3217
|
-
if (!
|
|
3227
|
+
const ccrStatus = await isCcrInstalled();
|
|
3228
|
+
if (!ccrStatus.hasCorrectPackage) {
|
|
3218
3229
|
await installCcr(scriptLang);
|
|
3219
3230
|
} else {
|
|
3220
3231
|
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled}`));
|
package/dist/cli.mjs
CHANGED
|
@@ -67,9 +67,8 @@ async function configureApiFeature(scriptLang) {
|
|
|
67
67
|
await modifyApiConfigPartially(existingApiConfig, i18n, scriptLang);
|
|
68
68
|
return;
|
|
69
69
|
} else if (action === "use-ccr") {
|
|
70
|
-
const
|
|
71
|
-
if (!
|
|
72
|
-
console.log(ansis.yellow(`${i18n.ccr.installingCcr}`));
|
|
70
|
+
const ccrStatus = await isCcrInstalled();
|
|
71
|
+
if (!ccrStatus.hasCorrectPackage) {
|
|
73
72
|
await installCcr(scriptLang);
|
|
74
73
|
} else {
|
|
75
74
|
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled}`));
|
|
@@ -108,9 +107,8 @@ async function configureApiFeature(scriptLang) {
|
|
|
108
107
|
return;
|
|
109
108
|
}
|
|
110
109
|
if (apiChoice === "ccr_proxy") {
|
|
111
|
-
const
|
|
112
|
-
if (!
|
|
113
|
-
console.log(ansis.yellow(`${i18n.ccr.installingCcr}`));
|
|
110
|
+
const ccrStatus = await isCcrInstalled();
|
|
111
|
+
if (!ccrStatus.hasCorrectPackage) {
|
|
114
112
|
await installCcr(scriptLang);
|
|
115
113
|
} else {
|
|
116
114
|
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled}`));
|
|
@@ -562,9 +560,8 @@ async function showCcrMenu(scriptLang) {
|
|
|
562
560
|
});
|
|
563
561
|
switch (choice) {
|
|
564
562
|
case "1":
|
|
565
|
-
const
|
|
566
|
-
if (!
|
|
567
|
-
console.log(ansis.yellow(`${i18n.ccr.installingCcr}`));
|
|
563
|
+
const ccrStatus = await isCcrInstalled();
|
|
564
|
+
if (!ccrStatus.hasCorrectPackage) {
|
|
568
565
|
await installCcr(scriptLang);
|
|
569
566
|
} else {
|
|
570
567
|
console.log(ansis.green(`\u2714 ${i18n.ccr.ccrAlreadyInstalled}`));
|
package/package.json
CHANGED