@simonyea/holysheep-cli 1.7.28 → 1.7.30

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.28",
3
+ "version": "1.7.30",
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/index.js CHANGED
@@ -4,15 +4,8 @@
4
4
  const { program } = require('commander')
5
5
  const chalk = require('chalk')
6
6
  const pkg = require('../package.json')
7
- const { installWindowsCliShims, ensureWindowsUserPathHasNpmBin } = require('./utils/shell')
8
7
 
9
- // Windows 用户:检测 npm bin 路径是否在 PATH 中
10
- if (process.platform === 'win32') {
11
- try {
12
- installWindowsCliShims()
13
- ensureWindowsUserPathHasNpmBin()
14
- } catch {}
15
- }
8
+
16
9
 
17
10
  // 异步检查最新版本(不阻塞主流程)
18
11
  function checkLatestVersion() {
@@ -82,7 +82,7 @@ function ensureWindowsUserPathHasNpmBin() {
82
82
  let currentPath = ''
83
83
  try {
84
84
  currentPath = execSync(
85
- 'powershell.exe -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"',
85
+ 'powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"',
86
86
  { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }
87
87
  ).trim()
88
88
  } catch {
@@ -101,11 +101,17 @@ function ensureWindowsUserPathHasNpmBin() {
101
101
  try {
102
102
  const escapedPath = nextPath.replace(/'/g, "''")
103
103
  execSync(
104
- `powershell.exe -NoProfile -Command "[Environment]::SetEnvironmentVariable('Path', '${escapedPath}', 'User')"`,
104
+ `powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "[Environment]::SetEnvironmentVariable('Path', '${escapedPath}', 'User')"`,
105
105
  { stdio: 'ignore' }
106
106
  )
107
107
  return ['[用户 PATH] %APPDATA%\\npm']
108
108
  } catch {
109
+ try {
110
+ const chalk = require('chalk')
111
+ console.warn(chalk.yellow(
112
+ ` ⚠️ 无法自动更新 PATH,请手动将以下路径加入系统环境变量 PATH:\n ${npmBin}`
113
+ ))
114
+ } catch {}
109
115
  return []
110
116
  }
111
117
  }
@@ -119,11 +125,18 @@ function installWindowsCliShims() {
119
125
  const npmBin = path.join(appData, 'npm')
120
126
  fs.mkdirSync(npmBin, { recursive: true })
121
127
 
128
+ // 已 npm install -g:npm 自己生成的 hs.cmd 已可用,不覆盖
129
+ const globalEntry = path.join(npmBin, 'node_modules', '@simonyea', 'holysheep-cli', 'bin', 'hs.js')
130
+ if (fs.existsSync(globalEntry)) return []
131
+
122
132
  const cliSpec = `@simonyea/holysheep-cli@${pkg.version}`
133
+ // 优先使用本地安装的包(npm install -g 场景),避免依赖 PATH 中的 hs 命令
123
134
  const cmdContent = [
124
135
  '@echo off',
125
136
  'setlocal',
126
- 'if exist "%~dp0npx.cmd" (',
137
+ 'if exist "%~dp0node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js" (',
138
+ ' node "%~dp0node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js" %*',
139
+ ') else if exist "%~dp0npx.cmd" (',
127
140
  ` call "%~dp0npx.cmd" ${cliSpec} %*`,
128
141
  ') else (',
129
142
  ` call npx ${cliSpec} %*`,
@@ -132,9 +145,12 @@ function installWindowsCliShims() {
132
145
  ].join('\r\n')
133
146
 
134
147
  const ps1Content = [
135
- '$npxCmd = Join-Path $PSScriptRoot "npx.cmd"',
136
- 'if (Test-Path $npxCmd) {',
137
- ` & $npxCmd "${cliSpec}" @args`,
148
+ '$dir = $PSScriptRoot',
149
+ '$localPkg = Join-Path $dir "node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js"',
150
+ 'if (Test-Path $localPkg) {',
151
+ ' & node $localPkg @args',
152
+ '} elseif (Test-Path (Join-Path $dir "npx.cmd")) {',
153
+ ` & (Join-Path $dir "npx.cmd") "${cliSpec}" @args`,
138
154
  '} else {',
139
155
  ` & npx "${cliSpec}" @args`,
140
156
  '}',