@simonyea/holysheep-cli 1.7.6 → 1.7.8
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/package.json +1 -1
- package/src/commands/setup.js +33 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai-china",
|
package/src/commands/setup.js
CHANGED
|
@@ -5,8 +5,10 @@ const inquirer = require('inquirer')
|
|
|
5
5
|
const chalk = require('chalk')
|
|
6
6
|
const ora = require('ora')
|
|
7
7
|
const { execSync, spawnSync } = require('child_process')
|
|
8
|
+
const pkg = require('../../package.json')
|
|
8
9
|
const { saveConfig, getApiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI, SHOP_URL } = require('../utils/config')
|
|
9
10
|
const { writeEnvToShell, ensureWindowsUserPathHasNpmBin } = require('../utils/shell')
|
|
11
|
+
const { commandExists } = require('../utils/which')
|
|
10
12
|
const TOOLS = require('../tools')
|
|
11
13
|
|
|
12
14
|
// 工具的自动安装命令(npm/pip)
|
|
@@ -45,6 +47,28 @@ function getWindowsImmediateLaunchCmd(tool) {
|
|
|
45
47
|
return null
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
function getPreferredCliPrefix() {
|
|
51
|
+
const mainEntry = String(require.main?.filename || '')
|
|
52
|
+
const runningFromNpxCache =
|
|
53
|
+
/[\\/]_npx[\\/]/i.test(mainEntry) ||
|
|
54
|
+
/[\\/]npm-cache[\\/]/i.test(mainEntry)
|
|
55
|
+
|
|
56
|
+
if (runningFromNpxCache) {
|
|
57
|
+
return `npx @simonyea/holysheep-cli@${pkg.version}`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return commandExists('hs')
|
|
61
|
+
? 'hs'
|
|
62
|
+
: `npx @simonyea/holysheep-cli@${pkg.version}`
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getPreferredLaunchCmd(tool) {
|
|
66
|
+
if (!tool?.launchCmd) return null
|
|
67
|
+
if (!tool.launchCmd.startsWith('hs')) return tool.launchCmd
|
|
68
|
+
const prefix = getPreferredCliPrefix()
|
|
69
|
+
return tool.launchCmd.replace(/^hs\b/, prefix)
|
|
70
|
+
}
|
|
71
|
+
|
|
48
72
|
function canAutoInstall(toolId) {
|
|
49
73
|
return !!AUTO_INSTALL[toolId]
|
|
50
74
|
}
|
|
@@ -317,12 +341,13 @@ async function setup(options) {
|
|
|
317
341
|
console.log(` ${chalk.gray(` ${i + 1}.`)} ${chalk.cyan.bold(s.cmd)} ${chalk.gray(s.note)}`)
|
|
318
342
|
})
|
|
319
343
|
} else if (r.tool.launchCmd) {
|
|
344
|
+
const preferredLaunchCmd = getPreferredLaunchCmd(r.tool)
|
|
320
345
|
if (r.tool._winJustInstalled) {
|
|
321
|
-
const immediateCmd = getWindowsImmediateLaunchCmd(r.tool)
|
|
322
|
-
console.log(` ${chalk.gray('▶ 立即启动:')} ${chalk.cyan.bold(immediateCmd || r.tool.launchCmd)}`)
|
|
323
|
-
console.log(` ${chalk.gray('▶ 新开终端后:')} ${chalk.cyan.bold(r.tool.launchCmd)}`)
|
|
346
|
+
const immediateCmd = getWindowsImmediateLaunchCmd({ ...r.tool, launchCmd: preferredLaunchCmd || r.tool.launchCmd })
|
|
347
|
+
console.log(` ${chalk.gray('▶ 立即启动:')} ${chalk.cyan.bold(immediateCmd || preferredLaunchCmd || r.tool.launchCmd)}`)
|
|
348
|
+
console.log(` ${chalk.gray('▶ 新开终端后:')} ${chalk.cyan.bold(preferredLaunchCmd || r.tool.launchCmd)}`)
|
|
324
349
|
} else {
|
|
325
|
-
console.log(` ${chalk.gray('▶ 启动命令:')} ${chalk.cyan.bold(r.tool.launchCmd)}`)
|
|
350
|
+
console.log(` ${chalk.gray('▶ 启动命令:')} ${chalk.cyan.bold(preferredLaunchCmd || r.tool.launchCmd)}`)
|
|
326
351
|
}
|
|
327
352
|
if (r.tool.launchNote) console.log(` ${chalk.gray(' ' + r.tool.launchNote)}`)
|
|
328
353
|
} else if (r.tool.launchNote) {
|
|
@@ -343,9 +368,10 @@ async function setup(options) {
|
|
|
343
368
|
console.log()
|
|
344
369
|
}
|
|
345
370
|
|
|
346
|
-
|
|
347
|
-
console.log(chalk.gray(
|
|
348
|
-
console.log(chalk.gray(
|
|
371
|
+
const cliPrefix = getPreferredCliPrefix()
|
|
372
|
+
console.log(chalk.gray(`如需切换其他工具,运行: ${cliPrefix} setup`))
|
|
373
|
+
console.log(chalk.gray(`查看余额: ${cliPrefix} balance`))
|
|
374
|
+
console.log(chalk.gray(`检查配置: ${cliPrefix} doctor`))
|
|
349
375
|
console.log()
|
|
350
376
|
|
|
351
377
|
// 注册引导 banner
|