@simonyea/holysheep-cli 1.7.36 → 1.7.37

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.7.36",
3
+ "version": "1.7.37",
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",
@@ -17,6 +17,60 @@ const {
17
17
  const { commandExists } = require('../utils/which')
18
18
  const TOOLS = require('../tools')
19
19
 
20
+ async function getLatestHolysheepVersion() {
21
+ return new Promise((resolve) => {
22
+ const https = require('https')
23
+ const req = https.get(
24
+ 'https://registry.npmjs.org/@simonyea/holysheep-cli/latest',
25
+ { timeout: 5000 },
26
+ (res) => {
27
+ let data = ''
28
+ res.on('data', chunk => { data += chunk })
29
+ res.on('end', () => {
30
+ try { resolve(JSON.parse(data).version || null) } catch { resolve(null) }
31
+ })
32
+ }
33
+ )
34
+ req.on('error', () => resolve(null))
35
+ req.setTimeout(5000, () => { req.destroy(); resolve(null) })
36
+ })
37
+ }
38
+
39
+ async function checkAndUpdateSelf() {
40
+ process.stdout.write(chalk.gray('检查 HolySheep CLI 版本... '))
41
+ const latest = await getLatestHolysheepVersion()
42
+
43
+ if (!latest || latest === pkg.version) {
44
+ console.log(chalk.green(`v${pkg.version} 已是最新`))
45
+ return
46
+ }
47
+
48
+ console.log(chalk.yellow(`发现新版本 v${latest}(当前 v${pkg.version})`))
49
+
50
+ const { doUpdate } = await inquirer.prompt([{
51
+ type: 'confirm',
52
+ name: 'doUpdate',
53
+ message: `立即更新到 v${latest}?(推荐,确保配置逻辑最新)`,
54
+ default: true,
55
+ }])
56
+
57
+ if (!doUpdate) {
58
+ console.log(chalk.gray(' 跳过更新,继续使用当前版本配置...'))
59
+ return
60
+ }
61
+
62
+ const spinner = ora(`更新 HolySheep CLI → v${latest}...`).start()
63
+ try {
64
+ execSync('npm install -g @simonyea/holysheep-cli@latest', { stdio: 'ignore', timeout: 60000 })
65
+ spinner.succeed(`HolySheep CLI 已更新到 v${latest}`)
66
+ console.log(chalk.cyan(' 请重新运行 hs setup 以使用最新版本完成配置'))
67
+ process.exit(0)
68
+ } catch (e) {
69
+ spinner.fail(`更新失败: ${e.message}`)
70
+ console.log(chalk.gray(' 可手动运行: npm install -g @simonyea/holysheep-cli@latest'))
71
+ }
72
+ }
73
+
20
74
  // 工具的自动安装命令(npm/pip)
21
75
  const AUTO_INSTALL = {
22
76
  'claude-code': {
@@ -152,6 +206,9 @@ async function setup(options) {
152
206
  console.log(chalk.gray('━'.repeat(50)))
153
207
  console.log()
154
208
 
209
+ await checkAndUpdateSelf()
210
+ console.log()
211
+
155
212
  // Step 1: 获取 API Key
156
213
  let apiKey = options.key || getApiKey()
157
214