@2api-store/activate 0.3.2 → 0.3.3

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/lib/detect.mjs CHANGED
@@ -62,11 +62,13 @@ function findBinary(name, isWindows) {
62
62
  function getVersion(bin, isWindows) {
63
63
  // --version 是通用约定;codex/claude/gemini/opencode/grok 都支持
64
64
  try {
65
- const result = spawnSync(isWindows ? `${bin}.cmd` : bin, ['--version'], {
65
+ const cmdBin = isWindows ? process.env.COMSPEC || 'cmd.exe' : bin
66
+ const cmdArgs = isWindows ? ['/c', bin, '--version'] : ['--version']
67
+ const result = spawnSync(cmdBin, cmdArgs, {
66
68
  encoding: 'utf8',
67
69
  stdio: ['ignore', 'pipe', 'pipe'],
68
70
  timeout: 5000,
69
- // 不用 shell:true(node 22+ DEP0190);Windows 用 <bin>.cmd 直调
71
+ // Windows: CLI 是 <bin>.cmd batch,必须经 cmd.exe /c 解析;不用 shell:true(DEP0190)
70
72
  })
71
73
  if (result.status === 0 && result.stdout) {
72
74
  const firstLine = result.stdout.trim().split(/\r?\n/)[0]
package/lib/install.mjs CHANGED
@@ -38,15 +38,20 @@ export function installCLI(meta, opts = {}) {
38
38
 
39
39
  console.log(` 正在执行:${cmd}…`)
40
40
  try {
41
- const result = spawnSync(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['install', '-g', pkg], {
41
+ const isWin = process.platform === 'win32'
42
+ const npmBin = isWin ? process.env.COMSPEC || 'cmd.exe' : 'npm'
43
+ const npmArgs = isWin ? ['/c', 'npm', 'install', '-g', pkg] : ['install', '-g', pkg]
44
+ const result = spawnSync(npmBin, npmArgs, {
42
45
  stdio: 'inherit', // npm 进度/输出直接透传到当前终端
43
- // 不用 shell:true(node 22+ DEP0190 警告 + 安全风险);Windows 用 npm.cmd 直调
46
+ // Windows: npm 是 npm.cmd batch,必须经 cmd.exe /c 解析;不用 shell:true(node 22+ DEP0190)
44
47
  })
48
+ if (result.error) {
49
+ return { ok: false, error: result.error.message }
50
+ }
45
51
  if (result.status === 0) {
46
52
  return { ok: true }
47
53
  }
48
- const errText = `npm exit ${result.status}`
49
- return { ok: false, error: errText }
54
+ return { ok: false, error: `npm exit ${result.status}` }
50
55
  } catch (err) {
51
56
  return { ok: false, error: err.message }
52
57
  }
package/lib/platforms.mjs CHANGED
@@ -53,7 +53,7 @@ export const CLI_META = {
53
53
  ' codex --sandbox read-only --ask-for-approval never 只读(最安全)',
54
54
  ' codex --help 查看所有选项',
55
55
  ].join('\n'),
56
- isPrimary: true,
56
+ isPrimary: false, // codex 的 WebSocket 变体(同 CLI 同 config.toml,默认不选避免覆盖 codex 模式)
57
57
  },
58
58
  claude: {
59
59
  name: 'Claude Code',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2api-store/activate",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "TokenShop CLI 一键激活:配置本地 codex/claude/gemini/grok/opencode 指向 2api.store 中转(彩色输出 + 自动安装 CLI)",
5
5
  "type": "module",
6
6
  "bin": {