@cannbot-ai/install-helper 0.0.2-beta.43 → 0.0.2-beta.44

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.
Files changed (2) hide show
  1. package/dist/install.ps1 +165 -0
  2. package/package.json +6 -6
@@ -0,0 +1,165 @@
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
+ if ($Version) {
57
+ Write-Host " [OK] Version: $Version (from $Registry)" -ForegroundColor Green
58
+ break
59
+ }
60
+ }
61
+
62
+ if (-not $Version) {
63
+ Write-Host " [ERROR] Failed to query version from all registries" -ForegroundColor Red
64
+ Write-Host ""
65
+ Write-Host " Alternative (requires Node.js 18+):"
66
+ Write-Host " npm install -g @cannbot-ai/install-helper"
67
+ return
68
+ }
69
+
70
+ # 3. Download tarball
71
+ $InstallDir = Join-Path $env:USERPROFILE ".cannbot\bin"
72
+ New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
73
+
74
+ $TarballName = "$($SubPkgName.Split('/')[1])-$Version.tgz"
75
+ $TarballUrl = "$Registry/$SubPkgName/-/$TarballName"
76
+
77
+ Write-Host ""
78
+ Write-Host " Downloading $TarballName ..." -ForegroundColor Cyan
79
+
80
+ $TempFile = Join-Path $env:TEMP "ih-tarball.tgz"
81
+ try {
82
+ Invoke-WebRequest $TarballUrl -OutFile $TempFile -TimeoutSec 300 -UseBasicParsing
83
+ Write-Host " [OK] Download complete" -ForegroundColor Green
84
+ } catch {
85
+ Write-Host " [ERROR] Download failed: $($_.Exception.Message)" -ForegroundColor Red
86
+ Write-Host ""
87
+ Write-Host " Alternative (requires Node.js 18+):"
88
+ Write-Host " npm install -g @cannbot-ai/install-helper"
89
+ return
90
+ }
91
+
92
+ # 4. Extract
93
+ Write-Host " Installing..." -ForegroundColor Cyan
94
+
95
+ $TempExtract = Join-Path $env:TEMP "ih-extract-$(Get-Random)"
96
+ New-Item -ItemType Directory -Force -Path $TempExtract | Out-Null
97
+
98
+ try {
99
+ & tar xzf $TempFile -C $TempExtract 2>&1 | Out-Null
100
+ if ($LASTEXITCODE -ne 0) {
101
+ throw "tar exit code $LASTEXITCODE"
102
+ }
103
+ } catch {
104
+ Write-Host " [ERROR] Extraction failed. tar not found or error." -ForegroundColor Red
105
+ Write-Host " Windows 10 1803+ includes tar. For older Windows, use npm install."
106
+ Remove-Item $TempExtract -Recurse -Force -ErrorAction SilentlyContinue
107
+ Remove-Item $TempFile -Force -ErrorAction SilentlyContinue
108
+ return
109
+ }
110
+
111
+ $BinarySrc = Join-Path $TempExtract "package\$BinaryName"
112
+ $BinaryDest = Join-Path $InstallDir "install-helper.exe"
113
+
114
+ if (-not (Test-Path $BinarySrc)) {
115
+ Write-Host " [ERROR] Binary not found in tarball: $BinarySrc" -ForegroundColor Red
116
+ Remove-Item $TempExtract -Recurse -Force -ErrorAction SilentlyContinue
117
+ Remove-Item $TempFile -Force -ErrorAction SilentlyContinue
118
+ return
119
+ }
120
+
121
+ Copy-Item $BinarySrc $BinaryDest -Force
122
+ Remove-Item $TempExtract -Recurse -Force -ErrorAction SilentlyContinue
123
+ Remove-Item $TempFile -Force -ErrorAction SilentlyContinue
124
+
125
+ Write-Host " [OK] Installation successful!" -ForegroundColor Green
126
+ Write-Host ""
127
+
128
+ # 5. PATH
129
+ $UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
130
+ if ($UserPath -notlike "*$InstallDir*") {
131
+ Write-Host " [INFO] Add to PATH:" -ForegroundColor Yellow
132
+ Write-Host " $InstallDir"
133
+ Write-Host ""
134
+ try {
135
+ $addPath = Read-Host " Add to user PATH now? [Y/n]"
136
+ if ($addPath -eq "" -or $addPath -match "^[Yy]$") {
137
+ [Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
138
+ Write-Host " [OK] Added to PATH (restart terminal to take effect)" -ForegroundColor Green
139
+ }
140
+ } catch {
141
+ Write-Host " Run manually:" -ForegroundColor Yellow
142
+ Write-Host " [Environment]::SetEnvironmentVariable('Path', `"$UserPath;$InstallDir`", 'User')"
143
+ }
144
+ Write-Host ""
145
+ }
146
+
147
+ # 6. Usage
148
+ Write-Host " Usage:"
149
+ Write-Host " install-helper # Interactive wizard"
150
+ Write-Host " install-helper list # List available plugins"
151
+ Write-Host " install-helper doctor # Health check"
152
+ Write-Host ""
153
+ Write-Host " Docs: https://gitcode.com/cann/cannbot-skills"
154
+ Write-Host ""
155
+
156
+ # 7. Run now
157
+ try {
158
+ $runNow = Read-Host " Run install-helper now? [Y/n]"
159
+ if ($runNow -eq "" -or $runNow -match "^[Yy]$") {
160
+ Write-Host ""
161
+ & $BinaryDest
162
+ }
163
+ } catch {
164
+ Write-Host " Run manually: $BinaryDest" -ForegroundColor Yellow
165
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cannbot-ai/install-helper",
3
- "version": "0.0.2-beta.43",
3
+ "version": "0.0.2-beta.44",
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.43",
45
- "@cannbot-ai/install-helper-linux-arm64": "0.0.2-beta.43",
46
- "@cannbot-ai/install-helper-darwin-x64": "0.0.2-beta.43",
47
- "@cannbot-ai/install-helper-darwin-arm64": "0.0.2-beta.43",
48
- "@cannbot-ai/install-helper-windows-x64": "0.0.2-beta.43"
44
+ "@cannbot-ai/install-helper-linux-x64": "0.0.2-beta.44",
45
+ "@cannbot-ai/install-helper-linux-arm64": "0.0.2-beta.44",
46
+ "@cannbot-ai/install-helper-darwin-x64": "0.0.2-beta.44",
47
+ "@cannbot-ai/install-helper-darwin-arm64": "0.0.2-beta.44",
48
+ "@cannbot-ai/install-helper-windows-x64": "0.0.2-beta.44"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.0.0",