@cannbot-ai/install-helper 0.0.2-beta.73 → 0.0.2-beta.75
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/README.md +1 -1
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/install.ps1 +41 -57
- package/package.json +6 -6
package/dist/install.ps1
CHANGED
|
@@ -13,6 +13,13 @@ try {
|
|
|
13
13
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
14
14
|
} catch {}
|
|
15
15
|
|
|
16
|
+
# Auto-fix ExecutionPolicy for npm global tools (.ps1)
|
|
17
|
+
$execPolicy = Get-ExecutionPolicy -Scope CurrentUser
|
|
18
|
+
if ($execPolicy -eq "Restricted") {
|
|
19
|
+
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
|
|
20
|
+
Write-Host " [OK] ExecutionPolicy set to RemoteSigned (required for npm tools)" -ForegroundColor Green
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
$ErrorActionPreference = "Stop"
|
|
17
24
|
$ProgressPreference = "SilentlyContinue"
|
|
18
25
|
|
|
@@ -47,57 +54,7 @@ Write-Host ""
|
|
|
47
54
|
Write-Host " CANNBot Install Helper" -ForegroundColor Cyan
|
|
48
55
|
Write-Host ""
|
|
49
56
|
|
|
50
|
-
# 1.
|
|
51
|
-
$hasNode = $false
|
|
52
|
-
try {
|
|
53
|
-
$nodeVersion = & node --version 2>$null
|
|
54
|
-
if ($nodeVersion) {
|
|
55
|
-
$majorVersion = [int]($nodeVersion -replace '^v', '' -replace '\..*', '')
|
|
56
|
-
if ($majorVersion -ge 18) {
|
|
57
|
-
$hasNode = $true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} catch {}
|
|
61
|
-
|
|
62
|
-
if ($hasNode) {
|
|
63
|
-
Write-Host " [OK] Node.js $nodeVersion" -ForegroundColor Green
|
|
64
|
-
Write-Host ""
|
|
65
|
-
|
|
66
|
-
# Check if already installed
|
|
67
|
-
try {
|
|
68
|
-
$installedVersion = & install-helper --version 2>$null
|
|
69
|
-
if ($installedVersion) {
|
|
70
|
-
Write-Host " [OK] 检测到已安装 install-helper (版本: $installedVersion)" -ForegroundColor Yellow
|
|
71
|
-
}
|
|
72
|
-
} catch {}
|
|
73
|
-
|
|
74
|
-
Write-Host " Installing @cannbot-ai/install-helper..." -ForegroundColor Cyan
|
|
75
|
-
Write-Host ""
|
|
76
|
-
|
|
77
|
-
$prevEAP = $ErrorActionPreference
|
|
78
|
-
$ErrorActionPreference = "Continue"
|
|
79
|
-
& npm.cmd install -g @cannbot-ai/install-helper
|
|
80
|
-
$npmExit = $LASTEXITCODE
|
|
81
|
-
$ErrorActionPreference = $prevEAP
|
|
82
|
-
if ($npmExit -eq 0) {
|
|
83
|
-
Write-Host ""
|
|
84
|
-
Write-Host " [OK] 安装成功!" -ForegroundColor Green
|
|
85
|
-
Write-Host ""
|
|
86
|
-
Write-Host " 请运行: install-helper" -ForegroundColor Cyan
|
|
87
|
-
return
|
|
88
|
-
} else {
|
|
89
|
-
Write-Host ""
|
|
90
|
-
Write-Host " [ERROR] npm 安装失败" -ForegroundColor Red
|
|
91
|
-
Write-Host ""
|
|
92
|
-
Write-Host " 请尝试以管理员权限运行:"
|
|
93
|
-
Write-Host " npm install -g @cannbot-ai/install-helper"
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
# 2. Path B: No Node.js — download prebuilt binary
|
|
99
|
-
|
|
100
|
-
# Detect platform
|
|
57
|
+
# 1. Detect platform
|
|
101
58
|
$Arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" }
|
|
102
59
|
$SubPkgName = "@cannbot-ai/install-helper-windows-$Arch"
|
|
103
60
|
$BinaryName = "install-helper.exe"
|
|
@@ -151,8 +108,36 @@ if (-not $Version) {
|
|
|
151
108
|
return
|
|
152
109
|
}
|
|
153
110
|
|
|
154
|
-
# 3.
|
|
111
|
+
# 3. Check if already installed and up-to-date
|
|
155
112
|
$InstallDir = Join-Path $env:USERPROFILE ".cannbot\bin"
|
|
113
|
+
$BinaryDest = Join-Path $InstallDir "install-helper.exe"
|
|
114
|
+
if (Test-Path $BinaryDest) {
|
|
115
|
+
try {
|
|
116
|
+
$prevEAP = $ErrorActionPreference
|
|
117
|
+
$ErrorActionPreference = "Continue"
|
|
118
|
+
$localVersion = (& $BinaryDest --version 2>$null)
|
|
119
|
+
$ErrorActionPreference = $prevEAP
|
|
120
|
+
if ($localVersion -and $localVersion.Trim() -eq $Version) {
|
|
121
|
+
Write-Host " [OK] Already up-to-date (v$Version)" -ForegroundColor Green
|
|
122
|
+
Write-Host ""
|
|
123
|
+
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
124
|
+
if (-not $UserPath) {
|
|
125
|
+
[Environment]::SetEnvironmentVariable("Path", $InstallDir, "User")
|
|
126
|
+
} elseif ($UserPath -notlike "*$InstallDir*") {
|
|
127
|
+
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
|
|
128
|
+
}
|
|
129
|
+
Write-Host " Launching install-helper..." -ForegroundColor Cyan
|
|
130
|
+
Write-Host ""
|
|
131
|
+
& $BinaryDest
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
if ($localVersion) {
|
|
135
|
+
Write-Host " [INFO] Updating: v$($localVersion.Trim()) -> v$Version" -ForegroundColor Yellow
|
|
136
|
+
}
|
|
137
|
+
} catch {}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# 4. Download tarball (with mirror fallback)
|
|
156
141
|
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
|
157
142
|
|
|
158
143
|
$TarballName = "$($SubPkgName.Split('/')[1])-$Version.tgz"
|
|
@@ -183,8 +168,8 @@ if (-not $Downloaded) {
|
|
|
183
168
|
return
|
|
184
169
|
}
|
|
185
170
|
|
|
186
|
-
#
|
|
187
|
-
Write-Host " Installing..." -ForegroundColor Cyan
|
|
171
|
+
# 5. Extract
|
|
172
|
+
Write-Host " Installing v$Version..." -ForegroundColor Cyan
|
|
188
173
|
|
|
189
174
|
$TempExtract = Join-Path $env:TEMP "ih-extract-$(Get-Random)"
|
|
190
175
|
New-Item -ItemType Directory -Force -Path $TempExtract | Out-Null
|
|
@@ -203,7 +188,6 @@ try {
|
|
|
203
188
|
}
|
|
204
189
|
|
|
205
190
|
$BinarySrc = Join-Path $TempExtract "package\$BinaryName"
|
|
206
|
-
$BinaryDest = Join-Path $InstallDir "install-helper.exe"
|
|
207
191
|
|
|
208
192
|
if (-not (Test-Path $BinarySrc)) {
|
|
209
193
|
Write-Host " [ERROR] Binary not found in tarball: $BinarySrc" -ForegroundColor Red
|
|
@@ -219,7 +203,7 @@ Remove-Item $TempFile -Force -ErrorAction SilentlyContinue
|
|
|
219
203
|
Write-Host " [OK] Installation successful!" -ForegroundColor Green
|
|
220
204
|
Write-Host ""
|
|
221
205
|
|
|
222
|
-
#
|
|
206
|
+
# 6. PATH
|
|
223
207
|
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
224
208
|
if (-not $UserPath) {
|
|
225
209
|
[Environment]::SetEnvironmentVariable("Path", $InstallDir, "User")
|
|
@@ -231,7 +215,7 @@ if (-not $UserPath) {
|
|
|
231
215
|
Write-Host ""
|
|
232
216
|
}
|
|
233
217
|
|
|
234
|
-
#
|
|
218
|
+
# 7. Verify binary and launch
|
|
235
219
|
try {
|
|
236
220
|
$null = & $BinaryDest --version 2>$null
|
|
237
221
|
Write-Host " Launching install-helper..." -ForegroundColor Cyan
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cannbot-ai/install-helper",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.75",
|
|
4
4
|
"description": "Install Helper - Interactive installer for CANN operator development skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"yaml": "^2.6.0"
|
|
43
43
|
},
|
|
44
44
|
"optionalDependencies": {
|
|
45
|
-
"@cannbot-ai/install-helper-linux-x64": "0.0.2-beta.
|
|
46
|
-
"@cannbot-ai/install-helper-linux-arm64": "0.0.2-beta.
|
|
47
|
-
"@cannbot-ai/install-helper-darwin-x64": "0.0.2-beta.
|
|
48
|
-
"@cannbot-ai/install-helper-darwin-arm64": "0.0.2-beta.
|
|
49
|
-
"@cannbot-ai/install-helper-windows-x64": "0.0.2-beta.
|
|
45
|
+
"@cannbot-ai/install-helper-linux-x64": "0.0.2-beta.75",
|
|
46
|
+
"@cannbot-ai/install-helper-linux-arm64": "0.0.2-beta.75",
|
|
47
|
+
"@cannbot-ai/install-helper-darwin-x64": "0.0.2-beta.75",
|
|
48
|
+
"@cannbot-ai/install-helper-darwin-arm64": "0.0.2-beta.75",
|
|
49
|
+
"@cannbot-ai/install-helper-windows-x64": "0.0.2-beta.75"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^22.0.0",
|