bvm-core 1.1.4 → 1.1.5
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 +49 -8
- package/README.zh-CN.md +43 -12
- package/dist/index.js +1 -1
- package/install.ps1 +4 -4
- package/install.sh +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -41,27 +41,68 @@ BVM was engineered to solve the common pitfalls of traditional version managers:
|
|
|
41
41
|
|
|
42
42
|
## Installation
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
BVM provides several installation channels. Choose the one that best fits your network environment:
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
### 1. Fast Installation (Recommended for China 🇨🇳)
|
|
47
|
+
Downloads the full package directly from the mirror registry. This method **does not depend on CDN sync** and is available seconds after release.
|
|
47
48
|
|
|
48
49
|
**macOS / Linux / WSL:**
|
|
49
50
|
```bash
|
|
50
|
-
curl -
|
|
51
|
+
curl -L https://registry.npmmirror.com/bvm-core/-/bvm-core-1.1.5.tgz | tar -xz && bash package/install.sh && rm -rf package
|
|
51
52
|
```
|
|
52
53
|
|
|
53
|
-
**Windows (
|
|
54
|
+
**Windows (PowerShell):**
|
|
54
55
|
```powershell
|
|
55
|
-
|
|
56
|
+
curl.exe -L https://registry.npmmirror.com/bvm-core/-/bvm-core-1.1.5.tgz -o bvm.tgz; tar -xf bvm.tgz; ./package/install.ps1; Remove-Item bvm.tgz, package -Recurse -Force
|
|
56
57
|
```
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### 2. CDN Installation
|
|
62
|
+
Install via global CDNs. Note: there might be a few minutes of cache delay after a new release.
|
|
63
|
+
|
|
64
|
+
#### jsDelivr (Recommended)
|
|
65
|
+
**macOS / Linux / WSL:**
|
|
66
|
+
```bash
|
|
67
|
+
curl -fsSL https://cdn.jsdelivr.net/npm/bvm-core/install.sh | bash
|
|
68
|
+
```
|
|
69
|
+
**Windows (PowerShell):**
|
|
70
|
+
```powershell
|
|
71
|
+
irm https://cdn.jsdelivr.net/npm/bvm-core/install.ps1 | iex
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### unpkg
|
|
75
|
+
**macOS / Linux / WSL:**
|
|
76
|
+
```bash
|
|
77
|
+
curl -fsSL https://unpkg.com/bvm-core/install.sh | bash
|
|
78
|
+
```
|
|
79
|
+
**Windows (PowerShell):**
|
|
80
|
+
```powershell
|
|
81
|
+
irm https://unpkg.com/bvm-core/install.ps1 | iex
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### 3. Developer Installation (GitHub Raw)
|
|
87
|
+
Get the latest script directly from the source repository.
|
|
59
88
|
|
|
60
|
-
|
|
89
|
+
**macOS / Linux / WSL:**
|
|
61
90
|
```bash
|
|
62
|
-
bvm
|
|
91
|
+
curl -fsSL https://raw.githubusercontent.com/EricLLLLLL/bvm/main/install.sh | bash
|
|
63
92
|
```
|
|
64
93
|
|
|
94
|
+
**Windows (PowerShell):**
|
|
95
|
+
```powershell
|
|
96
|
+
irm https://raw.githubusercontent.com/EricLLLLLL/bvm/main/install.ps1 | iex
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Verification
|
|
102
|
+
|
|
103
|
+
After installation, restart your terminal or source your profile, then verify:
|
|
104
|
+
|
|
105
|
+
|
|
65
106
|
### Manual Update
|
|
66
107
|
|
|
67
108
|
If you already have BVM installed, you can upgrade to the latest version using the built-in command:
|
package/README.zh-CN.md
CHANGED
|
@@ -39,38 +39,69 @@ BVM 旨在解决传统版本管理器常见的两大痛点:终端启动延迟
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
-
##
|
|
42
|
+
## 安装
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
BVM 提供了多种安装渠道。请根据您的网络环境选择最合适的方式:
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
### 1. 极速安装 (推荐 🇨🇳)
|
|
47
|
+
直接从淘宝 NPM 镜像下载完整 Tarball。该方式**不依赖 CDN 同步**,发布后秒级可用,成功率 100%。
|
|
47
48
|
|
|
48
49
|
**macOS / Linux / WSL:**
|
|
49
50
|
```bash
|
|
50
|
-
curl -
|
|
51
|
+
curl -L https://registry.npmmirror.com/bvm-core/-/bvm-core-1.1.5.tgz | tar -xz && bash package/install.sh && rm -rf package
|
|
51
52
|
```
|
|
52
53
|
|
|
53
|
-
**Windows (
|
|
54
|
+
**Windows (PowerShell):**
|
|
54
55
|
```powershell
|
|
55
|
-
|
|
56
|
+
curl.exe -L https://registry.npmmirror.com/bvm-core/-/bvm-core-1.1.5.tgz -o bvm.tgz; tar -xf bvm.tgz; ./package/install.ps1; Remove-Item bvm.tgz, package -Recurse -Force
|
|
56
57
|
```
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### 2. CDN 安装
|
|
62
|
+
通过各大公共 CDN 加速安装脚本。注意:新版本发布后可能存在数分钟的缓存延迟。
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
#### jsDelivr (推荐)
|
|
65
|
+
**macOS / Linux / WSL:**
|
|
61
66
|
```bash
|
|
62
|
-
bvm
|
|
67
|
+
curl -fsSL https://cdn.jsdelivr.net/npm/bvm-core/install.sh | bash
|
|
68
|
+
```
|
|
69
|
+
**Windows (PowerShell):**
|
|
70
|
+
```powershell
|
|
71
|
+
irm https://cdn.jsdelivr.net/npm/bvm-core/install.ps1 | iex
|
|
63
72
|
```
|
|
64
73
|
|
|
65
|
-
|
|
74
|
+
#### unpkg
|
|
75
|
+
**macOS / Linux / WSL:**
|
|
76
|
+
```bash
|
|
77
|
+
curl -fsSL https://unpkg.com/bvm-core/install.sh | bash
|
|
78
|
+
```
|
|
79
|
+
**Windows (PowerShell):**
|
|
80
|
+
```powershell
|
|
81
|
+
irm https://unpkg.com/bvm-core/install.ps1 | iex
|
|
82
|
+
```
|
|
66
83
|
|
|
67
|
-
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### 3. 开发者安装 (GitHub 直连)
|
|
87
|
+
直接从 GitHub 源代码库获取最新的安装脚本。
|
|
88
|
+
|
|
89
|
+
**macOS / Linux / WSL:**
|
|
68
90
|
```bash
|
|
69
|
-
bvm
|
|
91
|
+
curl -fsSL https://raw.githubusercontent.com/EricLLLLLL/bvm/main/install.sh | bash
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Windows (PowerShell):**
|
|
95
|
+
```powershell
|
|
96
|
+
irm https://raw.githubusercontent.com/EricLLLLLL/bvm/main/install.ps1 | iex
|
|
70
97
|
```
|
|
71
98
|
|
|
72
99
|
---
|
|
73
100
|
|
|
101
|
+
## 验证安装
|
|
102
|
+
|
|
103
|
+
安装完成后,请重启终端或执行 `source` 命令刷新环境变量,然后验证:
|
|
104
|
+
|
|
74
105
|
## 基本用法
|
|
75
106
|
|
|
76
107
|
### 常用命令
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var i1=Object.create;var{getPrototypeOf:o1,defineProperty:M$,getOwnPropertyNames:a1}=Object;var s1=Object.prototype.hasOwnProperty;var W$=($,q,Q)=>{Q=$!=null?i1(o1($)):{};let J=q||!$||!$.__esModule?M$(Q,"default",{value:$,enumerable:!0}):Q;for(let Z of a1($))if(!s1.call(J,Z))M$(J,Z,{get:()=>$[Z],enumerable:!0});return J};var s$=($,q)=>{for(var Q in q)M$($,Q,{get:q[Q],enumerable:!0,configurable:!0,set:(J)=>q[Q]=()=>J})};var y$=($,q)=>()=>($&&(q=$($=0)),q);var U$=import.meta.require;var e$={};s$(e$,{getBvmDir:()=>r$,getBunAssetName:()=>T$,USER_AGENT:()=>J$,TEST_REMOTE_VERSIONS:()=>X$,REPO_FOR_BVM_CLI:()=>s,OS_PLATFORM:()=>D,IS_TEST_MODE:()=>T,EXECUTABLE_NAME:()=>A,CPU_ARCH:()=>x$,BVM_VERSIONS_DIR:()=>L,BVM_SRC_DIR:()=>$4,BVM_SHIMS_DIR:()=>E,BVM_FINGERPRINTS_FILE:()=>z$,BVM_DIR:()=>k,BVM_CURRENT_DIR:()=>b$,BVM_COMPONENTS:()=>f$,BVM_CDN_ROOT:()=>w$,BVM_CACHE_DIR:()=>v,BVM_BIN_DIR:()=>M,BVM_ALIAS_DIR:()=>j,BUN_GITHUB_RELEASES_API:()=>q4,ASSET_NAME_FOR_BVM:()=>B$});import{homedir as e1}from"os";import{join as n}from"path";function r$(){let $=process.env.HOME||e1();return n($,".bvm")}function T$($){return`bun-${D==="win32"?"windows":D}-${x$==="arm64"?"aarch64":"x64"}.zip`}var D,x$,T,X$,k,$4,L,M,E,b$,j,v,z$,A,q4="https://api.github.com/repos/oven-sh/bun/releases",s="EricLLLLLL/bvm",B$,J$="bvm (Bun Version Manager)",w$,f$;var N=y$(()=>{D=process.platform,x$=process.arch,T=process.env.BVM_TEST_MODE==="true",X$=["v1.3.4","v1.2.23","v1.0.0","bun-v1.4.0-canary"];k=r$(),$4=n(k,"src"),L=n(k,"versions"),M=n(k,"bin"),E=n(k,"shims"),b$=n(k,"current"),j=n(k,"aliases"),v=n(k,"cache"),z$=n(k,"fingerprints.json"),A=D==="win32"?"bun.exe":"bun",B$=D==="win32"?"bvm.exe":"bvm",w$=process.env.BVM_CDN_URL||"https://cdn.jsdelivr.net/gh/EricLLLLLL/bvm",f$=[{name:"CLI Core",remotePath:"index.js",localPath:"src/index.js"},{name:"Windows Shim",remotePath:"bvm-shim.js",localPath:"bin/bvm-shim.js",platform:"win32"},{name:"Unix Shim",remotePath:"bvm-shim.sh",localPath:"bin/bvm-shim.sh",platform:"posix"}]});function V($){if(!$)return null;return $.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/)?$:null}function $1($){let q=V($);return q?q.replace(/^v/,""):null}function Y$($){if(!$)return null;let q=$.replace(/^v/,""),J=q.split(/[-+]/)[0].split(".").map(Number);if(J.length===0||J.some((Y)=>isNaN(Y)))return null;let Z=q.includes("-")?q.split("-")[1].split("+")[0]:void 0;return{major:J[0],minor:J[1],patch:J[2],pre:Z}}function R$($,q){if(!$||!q)return 0;if($.major!==q.major)return $.major-q.major;if($.minor!==q.minor)return $.minor-q.minor;if($.patch!==q.patch)return $.patch-q.patch;if($.pre&&!q.pre)return-1;if(!$.pre&&q.pre)return 1;if($.pre&&q.pre)return $.pre.localeCompare(q.pre);return 0}function q1($,q){let Q=Y$($),J=Y$(q);return R$(Q,J)}function Z$($,q){return q1(q,$)}function C$($,q){return q1($,q)>0}function Q1($,q){if(q==="*"||q===""||q==="latest")return!0;let Q=Y$($);if(!Q)return!1;let J=q;if(q.startsWith("v"))J=q.substring(1);if($1($)===$1(q))return!0;let Z=J.split(".");if(Z.length===1){let Y=Number(Z[0]);if(Q.major===Y)return!0}else if(Z.length===2){let Y=Number(Z[0]),X=Number(Z[1]);if(Q.major===Y&&Q.minor===X)return!0}if(q.startsWith("~")){let Y=Y$(q.substring(1));if(!Y)return!1;let X=Y.patch??0;return Q.major===Y.major&&Q.minor===Y.minor&&Q.patch>=X}if(q.startsWith("^")){let Y=Y$(q.substring(1));if(!Y)return!1;let X=Y.patch??0,b=Y.minor??0;if(Y.major===0){if(Q.major!==0)return!1;if(Q.minor!==b)return!1;return Q.patch>=X}if(Q.major!==Y.major)return!1;if(Q.minor<b)return!1;if(Q.minor===b&&Q.patch<X)return!1;return!0}return!1}import{readdir as J4,mkdir as Y4,stat as Z4,symlink as K4,unlink as J1,rm as Y1,readlink as X4}from"fs/promises";import{join as j$,dirname as b4,basename as G4}from"path";async function O($){await Y4($,{recursive:!0})}async function G($){try{return await Z4($),!0}catch(q){if(q.code==="ENOENT")return!1;throw q}}async function Z1($,q){try{await J1(q)}catch(J){try{await Y1(q,{recursive:!0,force:!0})}catch(Z){}}let Q=process.platform==="win32"?"junction":"dir";await K4($,q,Q)}async function K1($){try{return await X4($)}catch(q){if(q.code==="ENOENT"||q.code==="EINVAL")return null;throw q}}async function r($){await Y1($,{recursive:!0,force:!0})}async function c($){try{return await J4($)}catch(q){if(q.code==="ENOENT")return[];throw q}}async function R($){return await Bun.file($).text()}async function i($,q){await Bun.write($,q)}async function X1($,q,Q={}){let{backup:J=!0}=Q,Z=b4($);await O(Z);let Y=`${$}.tmp-${Date.now()}`,X=`${$}.bak`;try{if(await i(Y,q),J&&await G($))try{let{rename:W,unlink:z}=await import("fs/promises");if(await G(X))await z(X).catch(()=>{});await W($,X)}catch(W){}let{rename:b}=await import("fs/promises");try{await b(Y,$)}catch(W){await Bun.write($,q),await J1(Y).catch(()=>{})}}catch(b){let{unlink:W}=await import("fs/promises");throw await W(Y).catch(()=>{}),b}}function y($){let q=$.trim();if(q.startsWith("bun-v"))q=q.substring(4);if(!q.startsWith("v")&&/^\d/.test(q))q=`v${q}`;return q}async function u(){return await O(L),(await c(L)).filter((q)=>V(y(q))).sort(Z$)}async function p(){if(process.env.BVM_ACTIVE_VERSION)return{version:y(process.env.BVM_ACTIVE_VERSION),source:"env"};let $=j$(process.cwd(),".bvmrc");if(await G($)){let X=(await R($)).trim();return{version:y(X),source:".bvmrc"}}let{getBvmDir:q}=await Promise.resolve().then(() => (N(),e$)),Q=q(),J=j$(Q,"current"),Z=j$(Q,"aliases");if(await G(J)){let{realpath:X}=await import("fs/promises");try{let b=await X(J);return{version:y(G4(b)),source:"current"}}catch(b){}}let Y=j$(Z,"default");if(await G(Y)){let X=(await R(Y)).trim();return{version:y(X),source:"default"}}return{version:null,source:null}}function e($,q){if(!$||q.length===0)return null;let Q=y($);if(q.includes(Q))return Q;if($.toLowerCase()==="latest")return q[0];if(/^\d+\.\d+\.\d+$/.test($.replace(/^v/,"")))return null;if(!/^[v\d]/.test($))return null;let Z=$.startsWith("v")?`~${$.substring(1)}`:`~${$}`,Y=q.filter((X)=>Q1(X,Z));if(Y.length>0)return Y.sort(Z$)[0];return null}var C=y$(()=>{N()});import{createInterface as H4}from"readline";class S${timer=null;frames=process.platform==="win32"?["-"]:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];frameIndex=0;text;isWindows=process.platform==="win32";constructor($){this.text=$}start($){if($)this.text=$;if(this.timer)return;if(this.isWindows){process.stdout.write(`${K.cyan(">")} ${this.text}
|
|
3
3
|
`);return}this.timer=setInterval(()=>{process.stdout.write(`\r\x1B[K${K.cyan(this.frames[this.frameIndex])} ${this.text}`),this.frameIndex=(this.frameIndex+1)%this.frames.length},80)}stop(){if(this.isWindows)return;if(this.timer)clearInterval(this.timer),this.timer=null,process.stdout.write("\r\x1B[K");process.stdout.write("\x1B[?25h")}succeed($){this.stop(),console.log(`${K.green(" \u2713")} ${$||this.text}`)}fail($){this.stop(),console.log(`${K.red(" \u2716")} ${$||this.text}`)}info($){this.stop(),console.log(`${K.blue(" \u2139")} ${$||this.text}`)}update($){if(this.text=$,this.isWindows)console.log(K.dim(` ... ${this.text}`))}}class I${total;current=0;width=20;constructor($){this.total=$}start(){process.stdout.write("\x1B[?25l"),this.render()}update($,q){this.current=$,this.render(q)}stop(){process.stdout.write(`\x1B[?25h
|
|
4
|
-
`)}render($){let q=Math.min(1,this.current/this.total),Q=Math.round(this.width*q),J=this.width-Q,Z=process.platform==="win32",Y=Z?"=":"\u2588",X=Z?"-":"\u2591",b=K.green(Y.repeat(Q))+K.gray(X.repeat(J)),W=(q*100).toFixed(0).padStart(3," "),z=(this.current/1048576).toFixed(1),w=(this.total/1048576).toFixed(1),H=$?` ${$.speed}KB/s`:"";process.stdout.write(`\r\x1B[2K ${b} ${W}% | ${z}/${w}MB${H}`)}}async function b1($){let q=H4({input:process.stdin,output:process.stdout});return new Promise((Q)=>{q.question(`${K.yellow("?")} ${$} (Y/n) `,(J)=>{q.close(),Q(J.toLowerCase()!=="n")})})}var W4,y4=($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=($,q,Q=$)=>(J)=>W4?$+J.replace(new RegExp(y4(q),"g"),Q)+q:J,K;var F=y$(()=>{W4=!process.env.NO_COLOR,K={red:o("\x1B[1;31m","\x1B[39m"),green:o("\x1B[1;32m","\x1B[39m"),yellow:o("\x1B[1;33m","\x1B[39m"),blue:o("\x1B[1;34m","\x1B[39m"),magenta:o("\x1B[1;35m","\x1B[39m"),cyan:o("\x1B[1;36m","\x1B[39m"),gray:o("\x1B[90m","\x1B[39m"),bold:o("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:o("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m")}});async function U($,q,Q){if(process.platform==="win32"){console.log(K.cyan(`> ${$}`));let Y={start:(X)=>{if(X)console.log(K.cyan(`> ${X}`))},stop:()=>{},succeed:(X)=>console.log(K.green(` \u2713 ${X}`)),fail:(X)=>console.log(K.red(` \u2716 ${X}`)),info:(X)=>console.log(K.cyan(` \u2139 ${X}`)),update:(X)=>console.log(K.dim(` ... ${X}`)),isSpinning:!1};try{return await q(Y)}catch(X){let b=k1(X,Q?.failMessage);if(console.log(K.red(` \u2716 ${b}`)),process.env.BVM_DEBUG,console.log(K.dim(` Details: ${X.message}`)),X.code)console.log(K.dim(` Code: ${X.code}`));throw X.reported=!0,X}}let Z=new S$($);Z.start();try{let Y=await q(Z);return Z.stop(),Y}catch(Y){let X=k1(Y,Q?.failMessage);throw Z.fail(K.red(X)),Y.reported=!0,Y}}function k1($,q){let Q=$ instanceof Error?$.message:String($);if(!q)return Q;if(typeof q==="function")return q($);return`${q}: ${Q}`}var f=y$(()=>{F()});var L1={};s$(L1,{resolveLocalVersion:()=>d,displayVersion:()=>h$});import{join as P4}from"path";async function d($){if($==="current"){let{version:Z}=await p();return Z}if($==="latest"){let Z=await u();if(Z.length>0)return Z[0];return null}let q=P4(j,$);if(await G(q))try{let Z=(await R(q)).trim();return y(Z)}catch{return null}let Q=y($),J=await u();return e($,J)}async function h$($){await U(`Resolving version '${$}'...`,async()=>{let q=await d($);if(q)console.log(q);else throw Error("N/A")},{failMessage:`Failed to resolve version '${$}'`})}var q$=y$(()=>{N();C();f()});import{parseArgs as K6}from"util";var K$={name:"bvm-core",version:"1.1.
|
|
4
|
+
`)}render($){let q=Math.min(1,this.current/this.total),Q=Math.round(this.width*q),J=this.width-Q,Z=process.platform==="win32",Y=Z?"=":"\u2588",X=Z?"-":"\u2591",b=K.green(Y.repeat(Q))+K.gray(X.repeat(J)),W=(q*100).toFixed(0).padStart(3," "),z=(this.current/1048576).toFixed(1),w=(this.total/1048576).toFixed(1),H=$?` ${$.speed}KB/s`:"";process.stdout.write(`\r\x1B[2K ${b} ${W}% | ${z}/${w}MB${H}`)}}async function b1($){let q=H4({input:process.stdin,output:process.stdout});return new Promise((Q)=>{q.question(`${K.yellow("?")} ${$} (Y/n) `,(J)=>{q.close(),Q(J.toLowerCase()!=="n")})})}var W4,y4=($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=($,q,Q=$)=>(J)=>W4?$+J.replace(new RegExp(y4(q),"g"),Q)+q:J,K;var F=y$(()=>{W4=!process.env.NO_COLOR,K={red:o("\x1B[1;31m","\x1B[39m"),green:o("\x1B[1;32m","\x1B[39m"),yellow:o("\x1B[1;33m","\x1B[39m"),blue:o("\x1B[1;34m","\x1B[39m"),magenta:o("\x1B[1;35m","\x1B[39m"),cyan:o("\x1B[1;36m","\x1B[39m"),gray:o("\x1B[90m","\x1B[39m"),bold:o("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:o("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m")}});async function U($,q,Q){if(process.platform==="win32"){console.log(K.cyan(`> ${$}`));let Y={start:(X)=>{if(X)console.log(K.cyan(`> ${X}`))},stop:()=>{},succeed:(X)=>console.log(K.green(` \u2713 ${X}`)),fail:(X)=>console.log(K.red(` \u2716 ${X}`)),info:(X)=>console.log(K.cyan(` \u2139 ${X}`)),update:(X)=>console.log(K.dim(` ... ${X}`)),isSpinning:!1};try{return await q(Y)}catch(X){let b=k1(X,Q?.failMessage);if(console.log(K.red(` \u2716 ${b}`)),process.env.BVM_DEBUG,console.log(K.dim(` Details: ${X.message}`)),X.code)console.log(K.dim(` Code: ${X.code}`));throw X.reported=!0,X}}let Z=new S$($);Z.start();try{let Y=await q(Z);return Z.stop(),Y}catch(Y){let X=k1(Y,Q?.failMessage);throw Z.fail(K.red(X)),Y.reported=!0,Y}}function k1($,q){let Q=$ instanceof Error?$.message:String($);if(!q)return Q;if(typeof q==="function")return q($);return`${q}: ${Q}`}var f=y$(()=>{F()});var L1={};s$(L1,{resolveLocalVersion:()=>d,displayVersion:()=>h$});import{join as P4}from"path";async function d($){if($==="current"){let{version:Z}=await p();return Z}if($==="latest"){let Z=await u();if(Z.length>0)return Z[0];return null}let q=P4(j,$);if(await G(q))try{let Z=(await R(q)).trim();return y(Z)}catch{return null}let Q=y($),J=await u();return e($,J)}async function h$($){await U(`Resolving version '${$}'...`,async()=>{let q=await d($);if(q)console.log(q);else throw Error("N/A")},{failMessage:`Failed to resolve version '${$}'`})}var q$=y$(()=>{N();C();f()});import{parseArgs as K6}from"util";var K$={name:"bvm-core",version:"1.1.5",description:"The native version manager for Bun. Cross-platform, shell-agnostic, and zero-dependency.",main:"dist/index.js",bin:{bvm:"dist/index.js"},publishConfig:{access:"public"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --target=bun --outfile dist/index.js --minify && bun run scripts/sync-runtime.ts",test:"bun test",bvm:"bun run src/index.ts","bvm:sandbox":'mkdir -p "$PWD/.sandbox-home" && HOME="$PWD/.sandbox-home" bun run src/index.ts',release:"bun run scripts/release.ts","sync-runtime":"bun run scripts/sync-runtime.ts"},repository:{type:"git",url:"git+https://github.com/EricLLLLLL/bvm.git"},keywords:["bun","version-manager","cli","bvm","nvm","nvm-windows","fnm","nodenv","bun-nvm","version-switching"],files:["dist/index.js","dist/bvm-shim.sh","dist/bvm-shim.js","install.sh","install.ps1","README.md"],author:"EricLLLLLL",license:"MIT",type:"commonjs",dependencies:{"@oven/bun-darwin-aarch64":"^1.3.5","cli-progress":"^3.12.0"},devDependencies:{"@types/bun":"^1.3.4","@types/cli-progress":"^3.11.6","@types/node":"^24.10.2",bun:"^1.3.5",esbuild:"^0.27.2",execa:"^9.6.1",typescript:"^5"},peerDependencies:{typescript:"^5"}};N();C();import{join as t,basename as g4,dirname as h4}from"path";N();C();F();import{join as z4}from"path";function G1($,q){if($==="darwin"){if(q==="arm64")return"@oven/bun-darwin-aarch64";if(q==="x64")return"@oven/bun-darwin-x64"}if($==="linux"){if(q==="arm64")return"@oven/bun-linux-aarch64";if(q==="x64")return"@oven/bun-linux-x64"}if($==="win32"){if(q==="x64")return"@oven/bun-windows-x64"}return null}function H1($,q,Q){let J=Q;if(!J.endsWith("/"))J+="/";let Z=$.startsWith("@"),Y=$;if(Z){let b=$.split("/");if(b.length===2)Y=b[1]}let X=`${Y}-${q}.tgz`;return`${J}${$}/-/${X}`}F();async function a($,q={}){let{cwd:Q,env:J,prependPath:Z,stdin:Y="inherit",stdout:X="inherit",stderr:b="inherit"}=q,W={...process.env,...J};if(Z){let H=W.PATH||"",x=process.platform==="win32"?";":":";W.PATH=`${Z}${x}${H}`}let w=await Bun.spawn({cmd:$,cwd:Q,env:W,stdin:Y,stdout:X,stderr:b}).exited;if((w??0)!==0)throw Error(`${K.red("Command failed")}: ${$.join(" ")} (code ${w})`);return w??0}async function g($,q={}){let{timeout:Q=5000,...J}=q,Z=new AbortController,Y=setTimeout(()=>Z.abort(),Q);try{let X=await fetch($,{...J,signal:Z.signal});return clearTimeout(Y),X}catch(X){if(clearTimeout(Y),X.name==="AbortError")throw Error(`Request to ${$} timed out after ${Q}ms`);throw X}}async function U4($,q=2000){if($.length===0)throw Error("No URLs to race");if($.length===1)return $[0];return new Promise((Q,J)=>{let Z=0,Y=!1;$.forEach((X)=>{g(X,{method:"HEAD",timeout:q}).then((b)=>{if(b.ok&&!Y)Y=!0,Q(X);else if(!Y){if(Z++,Z===$.length)J(Error("All requests failed"))}}).catch(()=>{if(!Y){if(Z++,Z===$.length)J(Error("All requests failed"))}})})})}async function x4(){try{let $=await g("https://1.1.1.1/cdn-cgi/trace",{timeout:500});if(!$.ok)return null;let Q=(await $.text()).match(/loc=([A-Z]{2})/);return Q?Q[1]:null}catch($){return null}}var E$=null,k$={NPM:"https://registry.npmjs.org",TAOBAO:"https://registry.npmmirror.com",TENCENT:"https://mirrors.cloud.tencent.com/npm/"};async function L$(){if(E$)return E$;let $=await x4(),q=[];if($==="CN")q=[k$.TAOBAO,k$.TENCENT,k$.NPM];else q=[k$.NPM,k$.TAOBAO];try{let Q=await U4(q,2000);return E$=Q,Q}catch(Q){return q[0]}}C();var w4="bun-versions.json",k4=3600000;async function L4(){if(T)return[...X$];let $=z4(v,w4);try{if(await G($)){let Z=await R($),Y=JSON.parse(Z);if(Date.now()-Y.timestamp<k4&&Array.isArray(Y.versions))return Y.versions}}catch(Z){}let q=await L$(),Q=[q];if(q!=="https://registry.npmjs.org")Q.push("https://registry.npmjs.org");let J=null;for(let Z of Q){let Y=`${Z.replace(/\/$/,"")}/bun`;try{let X=await g(Y,{headers:{"User-Agent":J$,Accept:"application/vnd.npm.install-v1+json"},timeout:1e4});if(!X.ok)throw Error(`Status ${X.status}`);let b=await X.json();if(!b.versions)throw Error("Invalid response (no versions)");let W=Object.keys(b.versions);try{await O(v),await i($,JSON.stringify({timestamp:Date.now(),versions:W}))}catch(z){}return W}catch(X){J=X}}throw J||Error("Failed to fetch versions from any registry.")}async function O4(){if(T)return[...X$];return new Promise(($,q)=>{let Q=[];try{let J=Bun.spawn(["git","ls-remote","--tags","https://github.com/oven-sh/bun.git"],{stdout:"pipe",stderr:"pipe"}),Z=setTimeout(()=>{J.kill(),q(Error("Git operation timed out"))},1e4);new Response(J.stdout).text().then((X)=>{clearTimeout(Z);let b=X.split(`
|
|
5
5
|
`);for(let W of b){let z=W.match(/refs\/tags\/bun-v?(\d+\.\d+\.\d+.*)$/);if(z)Q.push(z[1])}$(Q)}).catch((X)=>{clearTimeout(Z),q(X)})}catch(J){q(Error(`Failed to run git: ${J.message}`))}})}async function W1(){if(T)return[...X$];try{let q=(await L4()).filter((Q)=>V(Q)).map((Q)=>({v:Q,parsed:Y$(Q)}));return q.sort((Q,J)=>R$(J.parsed,Q.parsed)),q.map((Q)=>Q.v)}catch($){try{let q=await O4();if(q.length>0)return Array.from(new Set(q.filter((J)=>V(J)))).sort(Z$);throw Error("No versions found via Git")}catch(q){throw Error(`Failed to fetch versions. NPM: ${$.message}. Git: ${q.message}`)}}}async function y1($){if(T)return X$.includes($)||$==="latest";let q=await L$(),Q=$.replace(/^v/,""),J=`${q}/bun/${Q}`,Z=D==="win32"?"curl.exe":"curl",Y=async()=>{try{return await a([Z,"-I","-f","-m","5","-s",J],{stdout:"ignore",stderr:"ignore"}),!0}catch(b){return!1}},X=new Promise((b)=>setTimeout(()=>b(!1),1e4));return Promise.race([Y(),X])}async function U1(){if(T)return{latest:"1.1.20"};let q=`${await L$()}/-/package/bun/dist-tags`;try{let Q=await g(q,{headers:{"User-Agent":J$},timeout:5000});if(Q.ok)return await Q.json()}catch(Q){}return{}}async function x1($){let q=y($);if(!V(q))return console.error(K.red(`Invalid version provided to findBunDownloadUrl: ${$}`)),null;if(T)return{url:`https://example.com/${T$(q)}`,foundVersion:q};let Z=G1(D==="win32"?"win32":D,x$==="arm64"?"arm64":"x64");if(!Z)throw Error(`Unsupported platform/arch for NPM download: ${D}-${x$}`);let Y="";if(process.env.BVM_REGISTRY)Y=process.env.BVM_REGISTRY;else if(process.env.BVM_DOWNLOAD_MIRROR)Y=process.env.BVM_DOWNLOAD_MIRROR;else Y=await L$();let X=q.replace(/^v/,"");return{url:H1(Z,X,Y),foundVersion:q}}async function F$(){let $=B$;try{let J=await g(`https://cdn.jsdelivr.net/gh/${s}@latest/package.json`,{headers:{"User-Agent":J$},timeout:2000});if(J.ok){let Z=await J.json();if(Z&&Z.version){let Y=`v${Z.version}`;return{tagName:Y,downloadUrl:`https://github.com/${s}/releases/download/${Y}/${$}`}}}}catch(J){}try{let J=`https://github.com/${s}/releases/latest`,Z=await g(J,{method:"HEAD",redirect:"manual",headers:{"User-Agent":J$},timeout:2000});if(Z.status===302||Z.status===301){let Y=Z.headers.get("location");if(Y){let X=Y.split("/"),b=X[X.length-1];if(b&&V(b))return{tagName:b,downloadUrl:`https://github.com/${s}/releases/download/${b}/${$}`}}}}catch(J){}let q={"User-Agent":J$},Q=`https://api.github.com/repos/${s}/releases/latest`;try{let J=await g(Q,{headers:q,timeout:2000});if(!J.ok)return null;let Y=(await J.json()).tag_name,X=`https://github.com/${s}/releases/download/${Y}/${$}`;return{tagName:Y,downloadUrl:X}}catch(J){return null}}F();N();import{spawn as C4}from"child_process";async function z1($,q){if($.endsWith(".zip"))if(D==="win32")await a(["powershell","-Command",`Expand-Archive -Path "${$}" -DestinationPath "${q}" -Force`],{stdout:"ignore",stderr:"inherit"});else await a(["unzip","-o","-q",$,"-d",q],{stdout:"ignore",stderr:"inherit"});else if($.endsWith(".tar.gz")||$.endsWith(".tgz"))await new Promise((Q,J)=>{let Z=C4("tar",["-xzf",$,"-C",q],{stdio:"inherit",shell:!1});Z.on("close",(Y)=>{if(Y===0)Q();else J(Error(`tar exited with code ${Y}`))}),Z.on("error",(Y)=>J(Y))});else throw Error(`Unsupported archive format: ${$}`)}import{chmod as c$}from"fs/promises";C();N();F();import{join as B,dirname as f4,delimiter as T4}from"path";import{homedir as $$}from"os";import{chmod as O$}from"fs/promises";var v$=`#!/bin/bash
|
|
6
6
|
|
|
7
7
|
# bvm-init.sh: Initializes bvm default version on shell startup
|
package/install.ps1
CHANGED
|
@@ -44,7 +44,7 @@ $CURL_CMD = "curl.exe"
|
|
|
44
44
|
if (-not (Get-Command $CURL_CMD -ErrorAction SilentlyContinue)) { $CURL_CMD = "curl" }
|
|
45
45
|
|
|
46
46
|
# --- 1. Resolve BVM and Bun Versions ---
|
|
47
|
-
$DEFAULT_BVM_VER = "v1.1.
|
|
47
|
+
$DEFAULT_BVM_VER = "v1.1.5"
|
|
48
48
|
$BVM_VER = if ($env:BVM_INSTALL_VERSION) { $env:BVM_INSTALL_VERSION } else { "" }
|
|
49
49
|
|
|
50
50
|
# Resolve BVM Version dynamically if not provided
|
|
@@ -113,15 +113,15 @@ if (-not (Test-Path (Join-Path $TARGET_DIR "bin\$BUN_EXE_NAME"))) {
|
|
|
113
113
|
# Sync to runtime for BVM execution
|
|
114
114
|
$RUNTIME_VER_DIR = Join-Path $BVM_RUNTIME_DIR "v$BUN_VER"
|
|
115
115
|
if (-not (Test-Path $RUNTIME_VER_DIR)) {
|
|
116
|
-
# Windows Junction or Unix Symlink
|
|
117
|
-
if ($IsWin) {
|
|
116
|
+
# Windows Junction (no admin req) or Unix Symlink
|
|
117
|
+
if ($PSVersionTable.PSVersion.Major -ge 6 -and $IsWin -or $env:OS -like "*Windows*") {
|
|
118
118
|
New-Item -ItemType Junction -Path $RUNTIME_VER_DIR -Target $TARGET_DIR | Out-Null
|
|
119
119
|
} else {
|
|
120
120
|
New-Item -ItemType SymbolicLink -Path $RUNTIME_VER_DIR -Target $TARGET_DIR | Out-Null
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
$CURRENT_LINK = Join-Path $BVM_RUNTIME_DIR "current"
|
|
124
|
-
if ($IsWin) {
|
|
124
|
+
if ($PSVersionTable.PSVersion.Major -ge 6 -and $IsWin -or $env:OS -like "*Windows*") {
|
|
125
125
|
New-Item -ItemType Junction -Path $CURRENT_LINK -Target $RUNTIME_VER_DIR -Force | Out-Null
|
|
126
126
|
} else {
|
|
127
127
|
New-Item -ItemType SymbolicLink -Path $CURRENT_LINK -Target $RUNTIME_VER_DIR -Force | Out-Null
|
package/install.sh
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bvm-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "The native version manager for Bun. Cross-platform, shell-agnostic, and zero-dependency.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"typescript": "^5"
|
|
63
63
|
},
|
|
64
64
|
"bvm_fingerprints": {
|
|
65
|
-
"cli": "
|
|
65
|
+
"cli": "6e2c28556acab4112b6d7e4ea309c457",
|
|
66
66
|
"shim_win": "c6f43afddfb205e130633fe00ee860d8",
|
|
67
67
|
"shim_unix": "8aa89a0324b52c9c81b96c0c03afe36c",
|
|
68
|
-
"install_sh": "
|
|
69
|
-
"install_ps1": "
|
|
68
|
+
"install_sh": "8ae6e92bfdc8ee99b6227dd81327bbec",
|
|
69
|
+
"install_ps1": "6b5fa5d9226843b8f2f47b96c6c8ab51"
|
|
70
70
|
}
|
|
71
71
|
}
|