@simonyea/holysheep-cli 1.7.9 → 1.7.10

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.9",
3
+ "version": "1.7.10",
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",
@@ -7,7 +7,11 @@ const ora = require('ora')
7
7
  const { execSync, spawnSync } = require('child_process')
8
8
  const pkg = require('../../package.json')
9
9
  const { saveConfig, getApiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI, SHOP_URL } = require('../utils/config')
10
- const { writeEnvToShell, ensureWindowsUserPathHasNpmBin } = require('../utils/shell')
10
+ const {
11
+ writeEnvToShell,
12
+ ensureWindowsUserPathHasNpmBin,
13
+ installWindowsCliShims,
14
+ } = require('../utils/shell')
11
15
  const { commandExists } = require('../utils/which')
12
16
  const TOOLS = require('../tools')
13
17
 
@@ -122,6 +126,14 @@ async function tryAutoInstall(tool) {
122
126
  }
123
127
 
124
128
  async function setup(options) {
129
+ let windowsCliArtifacts = []
130
+ if (process.platform === 'win32') {
131
+ windowsCliArtifacts = [
132
+ ...installWindowsCliShims(),
133
+ ...ensureWindowsUserPathHasNpmBin(),
134
+ ]
135
+ }
136
+
125
137
  console.log()
126
138
  console.log(chalk.bold('🐑 HolySheep CLI — 一键配置 AI 工具'))
127
139
  console.log(chalk.gray('━'.repeat(50)))
@@ -322,6 +334,11 @@ async function setup(options) {
322
334
  }
323
335
  }
324
336
 
337
+ if (process.platform === 'win32' && windowsCliArtifacts.length > 0) {
338
+ console.log(chalk.gray(`Windows 启动器已就绪: ${windowsCliArtifacts.map(item => chalk.cyan(item)).join(', ')}`))
339
+ console.log()
340
+ }
341
+
325
342
  // Step 6: 保存 API Key
326
343
  saveConfig({ apiKey })
327
344
 
package/src/index.js CHANGED
@@ -4,12 +4,13 @@
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')
7
8
 
8
9
  // Windows 用户:检测 npm bin 路径是否在 PATH 中
9
10
  if (process.platform === 'win32') {
10
- const { execSync } = require('child_process')
11
11
  try {
12
- // 静默检查,只在首次遇到问题时才会走到这(因为已经能运行 node 了)
12
+ installWindowsCliShims()
13
+ ensureWindowsUserPathHasNpmBin()
13
14
  } catch {}
14
15
  }
15
16
 
@@ -109,6 +109,46 @@ function ensureWindowsUserPathHasNpmBin() {
109
109
  }
110
110
  }
111
111
 
112
+ function installWindowsCliShims() {
113
+ if (process.platform !== 'win32') return []
114
+
115
+ const appData = process.env.APPDATA
116
+ if (!appData) return []
117
+
118
+ const npmBin = path.join(appData, 'npm')
119
+ fs.mkdirSync(npmBin, { recursive: true })
120
+
121
+ const cmdContent = [
122
+ '@echo off',
123
+ 'setlocal',
124
+ 'if exist "%~dp0npx.cmd" (',
125
+ ' call "%~dp0npx.cmd" @simonyea/holysheep-cli@latest %*',
126
+ ') else (',
127
+ ' call npx @simonyea/holysheep-cli@latest %*',
128
+ ')',
129
+ ''
130
+ ].join('\r\n')
131
+
132
+ const ps1Content = [
133
+ '$npxCmd = Join-Path $PSScriptRoot "npx.cmd"',
134
+ 'if (Test-Path $npxCmd) {',
135
+ ' & $npxCmd "@simonyea/holysheep-cli@latest" @args',
136
+ '} else {',
137
+ ' & npx "@simonyea/holysheep-cli@latest" @args',
138
+ '}',
139
+ ''
140
+ ].join('\r\n')
141
+
142
+ const written = []
143
+ for (const name of ['hs', 'holysheep']) {
144
+ fs.writeFileSync(path.join(npmBin, `${name}.cmd`), cmdContent, 'utf8')
145
+ fs.writeFileSync(path.join(npmBin, `${name}.ps1`), ps1Content, 'utf8')
146
+ written.push(`[启动器] %APPDATA%\\npm\\${name}.cmd`)
147
+ }
148
+
149
+ return written
150
+ }
151
+
112
152
  function writeEnvToShell(envVars) {
113
153
  // Windows: 用 setx 写入用户级环境变量(需重启终端生效)
114
154
  if (process.platform === 'win32') {
@@ -119,6 +159,7 @@ function writeEnvToShell(envVars) {
119
159
  written.push(`[系统环境变量] ${k}`)
120
160
  } catch {}
121
161
  }
162
+ written.push(...installWindowsCliShims())
122
163
  written.push(...ensureWindowsUserPathHasNpmBin())
123
164
  if (written.length > 0) {
124
165
  const chalk = require('chalk')
@@ -174,4 +215,10 @@ function escapeRegex(s) {
174
215
  return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
175
216
  }
176
217
 
177
- module.exports = { getShellRcFiles, writeEnvToShell, removeEnvFromShell, ensureWindowsUserPathHasNpmBin }
218
+ module.exports = {
219
+ getShellRcFiles,
220
+ writeEnvToShell,
221
+ removeEnvFromShell,
222
+ ensureWindowsUserPathHasNpmBin,
223
+ installWindowsCliShims
224
+ }