@simonyea/holysheep-cli 1.7.28 → 1.7.29
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/utils/shell.js +18 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.29",
|
|
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/utils/shell.js
CHANGED
|
@@ -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
|
}
|
|
@@ -120,10 +126,13 @@ function installWindowsCliShims() {
|
|
|
120
126
|
fs.mkdirSync(npmBin, { recursive: true })
|
|
121
127
|
|
|
122
128
|
const cliSpec = `@simonyea/holysheep-cli@${pkg.version}`
|
|
129
|
+
// 优先使用本地安装的包(npm install -g 场景),避免依赖 PATH 中的 hs 命令
|
|
123
130
|
const cmdContent = [
|
|
124
131
|
'@echo off',
|
|
125
132
|
'setlocal',
|
|
126
|
-
'if exist "%~
|
|
133
|
+
'if exist "%~dp0node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js" (',
|
|
134
|
+
' node "%~dp0node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js" %*',
|
|
135
|
+
') else if exist "%~dp0npx.cmd" (',
|
|
127
136
|
` call "%~dp0npx.cmd" ${cliSpec} %*`,
|
|
128
137
|
') else (',
|
|
129
138
|
` call npx ${cliSpec} %*`,
|
|
@@ -132,9 +141,12 @@ function installWindowsCliShims() {
|
|
|
132
141
|
].join('\r\n')
|
|
133
142
|
|
|
134
143
|
const ps1Content = [
|
|
135
|
-
'$
|
|
136
|
-
'
|
|
137
|
-
|
|
144
|
+
'$dir = $PSScriptRoot',
|
|
145
|
+
'$localPkg = Join-Path $dir "node_modules\\@simonyea\\holysheep-cli\\bin\\hs.js"',
|
|
146
|
+
'if (Test-Path $localPkg) {',
|
|
147
|
+
' & node $localPkg @args',
|
|
148
|
+
'} elseif (Test-Path (Join-Path $dir "npx.cmd")) {',
|
|
149
|
+
` & (Join-Path $dir "npx.cmd") "${cliSpec}" @args`,
|
|
138
150
|
'} else {',
|
|
139
151
|
` & npx "${cliSpec}" @args`,
|
|
140
152
|
'}',
|