@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 +4 -2
- package/lib/install.mjs +9 -4
- package/lib/platforms.mjs +1 -1
- package/package.json +1 -1
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
|
|
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
|
-
//
|
|
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
|
|
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
|
-
//
|
|
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
|
-
|
|
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:
|
|
56
|
+
isPrimary: false, // codex 的 WebSocket 变体(同 CLI 同 config.toml,默认不选避免覆盖 codex 模式)
|
|
57
57
|
},
|
|
58
58
|
claude: {
|
|
59
59
|
name: 'Claude Code',
|