@cannbot-ai/install-helper 0.0.2-beta.43 → 0.0.2-beta.45
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/dist/install.ps1 +164 -0
- package/package.json +6 -6
package/dist/install.ps1
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
3
|
+
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
|
4
|
+
# CANN Open Software License Agreement Version 2.0 (the "License").
|
|
5
|
+
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
|
6
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
|
7
|
+
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
8
|
+
# See LICENSE in the root of the software repository for the full text of the License.
|
|
9
|
+
# ----------------------------------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
# Ensure TLS 1.2 (Windows PowerShell 5.1 defaults to TLS 1.0)
|
|
12
|
+
try {
|
|
13
|
+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
14
|
+
} catch {}
|
|
15
|
+
|
|
16
|
+
$ErrorActionPreference = "Stop"
|
|
17
|
+
|
|
18
|
+
Write-Host ""
|
|
19
|
+
Write-Host " ____ _ _ _ _ _ ____ _ " -ForegroundColor Cyan
|
|
20
|
+
Write-Host " / ___| / \ | \ | | \ | | __ ) ___ | |_ " -ForegroundColor Cyan
|
|
21
|
+
Write-Host " | | / _ \ | \| | \| | _ \ / _ \| __|" -ForegroundColor Cyan
|
|
22
|
+
Write-Host " | |___ / ___ \| |\ | |\ | |_) | (_) | |_ " -ForegroundColor Cyan
|
|
23
|
+
Write-Host " \____/_/ \_\_| \_|_| \_|____/ \___/ \__|" -ForegroundColor Cyan
|
|
24
|
+
Write-Host ""
|
|
25
|
+
Write-Host " CANNBot Install Helper" -ForegroundColor Cyan
|
|
26
|
+
Write-Host ""
|
|
27
|
+
|
|
28
|
+
# 1. Detect platform
|
|
29
|
+
$Arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" }
|
|
30
|
+
$SubPkgName = "@cannbot-ai/install-helper-windows-$Arch"
|
|
31
|
+
$BinaryName = "install-helper.exe"
|
|
32
|
+
|
|
33
|
+
Write-Host " [OK] Platform: windows-$Arch" -ForegroundColor Green
|
|
34
|
+
Write-Host ""
|
|
35
|
+
|
|
36
|
+
# 2. Query latest version from npm registry
|
|
37
|
+
Write-Host " Querying latest version..." -ForegroundColor Cyan
|
|
38
|
+
|
|
39
|
+
$Mirrors = @(
|
|
40
|
+
"https://registry.npmmirror.com",
|
|
41
|
+
"https://registry.npmjs.org"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
$Version = $null
|
|
45
|
+
$Registry = $null
|
|
46
|
+
foreach ($url in $Mirrors) {
|
|
47
|
+
foreach ($tag in @("latest", "beta")) {
|
|
48
|
+
try {
|
|
49
|
+
$resp = Invoke-RestMethod "$url/$SubPkgName/$tag" -TimeoutSec 15
|
|
50
|
+
if ($resp.version -and ((-not $Version) -or ([version]$resp.version -gt [version]$Version))) {
|
|
51
|
+
$Version = $resp.version
|
|
52
|
+
$Registry = $url
|
|
53
|
+
}
|
|
54
|
+
} catch {}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if ($Version) {
|
|
58
|
+
Write-Host " [OK] Version: $Version (from $Registry)" -ForegroundColor Green
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (-not $Version) {
|
|
62
|
+
Write-Host " [ERROR] Failed to query version from all registries" -ForegroundColor Red
|
|
63
|
+
Write-Host ""
|
|
64
|
+
Write-Host " Alternative (requires Node.js 18+):"
|
|
65
|
+
Write-Host " npm install -g @cannbot-ai/install-helper"
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# 3. Download tarball
|
|
70
|
+
$InstallDir = Join-Path $env:USERPROFILE ".cannbot\bin"
|
|
71
|
+
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
|
72
|
+
|
|
73
|
+
$TarballName = "$($SubPkgName.Split('/')[1])-$Version.tgz"
|
|
74
|
+
$TarballUrl = "$Registry/$SubPkgName/-/$TarballName"
|
|
75
|
+
|
|
76
|
+
Write-Host ""
|
|
77
|
+
Write-Host " Downloading $TarballName ..." -ForegroundColor Cyan
|
|
78
|
+
|
|
79
|
+
$TempFile = Join-Path $env:TEMP "ih-tarball.tgz"
|
|
80
|
+
try {
|
|
81
|
+
Invoke-WebRequest $TarballUrl -OutFile $TempFile -TimeoutSec 300 -UseBasicParsing
|
|
82
|
+
Write-Host " [OK] Download complete" -ForegroundColor Green
|
|
83
|
+
} catch {
|
|
84
|
+
Write-Host " [ERROR] Download failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
85
|
+
Write-Host ""
|
|
86
|
+
Write-Host " Alternative (requires Node.js 18+):"
|
|
87
|
+
Write-Host " npm install -g @cannbot-ai/install-helper"
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# 4. Extract
|
|
92
|
+
Write-Host " Installing..." -ForegroundColor Cyan
|
|
93
|
+
|
|
94
|
+
$TempExtract = Join-Path $env:TEMP "ih-extract-$(Get-Random)"
|
|
95
|
+
New-Item -ItemType Directory -Force -Path $TempExtract | Out-Null
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
& tar xzf $TempFile -C $TempExtract 2>&1 | Out-Null
|
|
99
|
+
if ($LASTEXITCODE -ne 0) {
|
|
100
|
+
throw "tar exit code $LASTEXITCODE"
|
|
101
|
+
}
|
|
102
|
+
} catch {
|
|
103
|
+
Write-Host " [ERROR] Extraction failed. tar not found or error." -ForegroundColor Red
|
|
104
|
+
Write-Host " Windows 10 1803+ includes tar. For older Windows, use npm install."
|
|
105
|
+
Remove-Item $TempExtract -Recurse -Force -ErrorAction SilentlyContinue
|
|
106
|
+
Remove-Item $TempFile -Force -ErrorAction SilentlyContinue
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
$BinarySrc = Join-Path $TempExtract "package\$BinaryName"
|
|
111
|
+
$BinaryDest = Join-Path $InstallDir "install-helper.exe"
|
|
112
|
+
|
|
113
|
+
if (-not (Test-Path $BinarySrc)) {
|
|
114
|
+
Write-Host " [ERROR] Binary not found in tarball: $BinarySrc" -ForegroundColor Red
|
|
115
|
+
Remove-Item $TempExtract -Recurse -Force -ErrorAction SilentlyContinue
|
|
116
|
+
Remove-Item $TempFile -Force -ErrorAction SilentlyContinue
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Copy-Item $BinarySrc $BinaryDest -Force
|
|
121
|
+
Remove-Item $TempExtract -Recurse -Force -ErrorAction SilentlyContinue
|
|
122
|
+
Remove-Item $TempFile -Force -ErrorAction SilentlyContinue
|
|
123
|
+
|
|
124
|
+
Write-Host " [OK] Installation successful!" -ForegroundColor Green
|
|
125
|
+
Write-Host ""
|
|
126
|
+
|
|
127
|
+
# 5. PATH
|
|
128
|
+
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
129
|
+
if ($UserPath -notlike "*$InstallDir*") {
|
|
130
|
+
Write-Host " [INFO] Add to PATH:" -ForegroundColor Yellow
|
|
131
|
+
Write-Host " $InstallDir"
|
|
132
|
+
Write-Host ""
|
|
133
|
+
try {
|
|
134
|
+
$addPath = Read-Host " Add to user PATH now? [Y/n]"
|
|
135
|
+
if ($addPath -eq "" -or $addPath -match "^[Yy]$") {
|
|
136
|
+
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
|
|
137
|
+
Write-Host " [OK] Added to PATH (restart terminal to take effect)" -ForegroundColor Green
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
Write-Host " Run manually:" -ForegroundColor Yellow
|
|
141
|
+
Write-Host " [Environment]::SetEnvironmentVariable('Path', `"$UserPath;$InstallDir`", 'User')"
|
|
142
|
+
}
|
|
143
|
+
Write-Host ""
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# 6. Usage
|
|
147
|
+
Write-Host " Usage:"
|
|
148
|
+
Write-Host " install-helper # Interactive wizard"
|
|
149
|
+
Write-Host " install-helper list # List available plugins"
|
|
150
|
+
Write-Host " install-helper doctor # Health check"
|
|
151
|
+
Write-Host ""
|
|
152
|
+
Write-Host " Docs: https://gitcode.com/cann/cannbot-skills"
|
|
153
|
+
Write-Host ""
|
|
154
|
+
|
|
155
|
+
# 7. Run now
|
|
156
|
+
try {
|
|
157
|
+
$runNow = Read-Host " Run install-helper now? [Y/n]"
|
|
158
|
+
if ($runNow -eq "" -or $runNow -match "^[Yy]$") {
|
|
159
|
+
Write-Host ""
|
|
160
|
+
& $BinaryDest
|
|
161
|
+
}
|
|
162
|
+
} catch {
|
|
163
|
+
Write-Host " Run manually: $BinaryDest" -ForegroundColor Yellow
|
|
164
|
+
}
|
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.45",
|
|
4
4
|
"description": "Install Helper - Interactive installer for CANN operator development skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"yaml": "^2.6.0"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"@cannbot-ai/install-helper-linux-x64": "0.0.2-beta.
|
|
45
|
-
"@cannbot-ai/install-helper-linux-arm64": "0.0.2-beta.
|
|
46
|
-
"@cannbot-ai/install-helper-darwin-x64": "0.0.2-beta.
|
|
47
|
-
"@cannbot-ai/install-helper-darwin-arm64": "0.0.2-beta.
|
|
48
|
-
"@cannbot-ai/install-helper-windows-x64": "0.0.2-beta.
|
|
44
|
+
"@cannbot-ai/install-helper-linux-x64": "0.0.2-beta.45",
|
|
45
|
+
"@cannbot-ai/install-helper-linux-arm64": "0.0.2-beta.45",
|
|
46
|
+
"@cannbot-ai/install-helper-darwin-x64": "0.0.2-beta.45",
|
|
47
|
+
"@cannbot-ai/install-helper-darwin-arm64": "0.0.2-beta.45",
|
|
48
|
+
"@cannbot-ai/install-helper-windows-x64": "0.0.2-beta.45"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.0.0",
|