bvm-core 1.1.33 → 1.1.35
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/README.zh-CN.md +1 -1
- package/dist/index.js +41 -34
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ npm install -g bvm-core@latest
|
|
|
59
59
|
- **🚀 Zero Latency**: Shim-based design ensures ~0ms shell startup overhead.
|
|
60
60
|
- **🛡️ Bunker Architecture**: BVM manages its own isolated Bun runtime, ensuring stability even if your system Bun is broken or missing.
|
|
61
61
|
- **🛡️ Atomic Isolation**: Each Bun version has its own global package directory. No more conflicts.
|
|
62
|
-
- **🌏 Smart Mirroring**: Automatically
|
|
62
|
+
- **🌏 Smart Mirroring & Auto-Config**: Automatically selects the fastest registry for downloads AND auto-configures `bunfig.toml` for instant, "no-magic" `bun install` speeds.
|
|
63
63
|
- **📦 Zero Dependency**: BVM bootstraps itself. No pre-requisites required (it can reuse your system Bun or download its own).
|
|
64
64
|
|
|
65
65
|
---
|
package/README.zh-CN.md
CHANGED
|
@@ -59,7 +59,7 @@ npm install -g bvm-core@latest
|
|
|
59
59
|
- **🚀 零延迟启动**:采用 Shim 架构设计,Shell 启动耗时约为 0ms。
|
|
60
60
|
- **🛡️ 地堡架构 (Bunker Architecture)**:BVM 拥有独立的私有运行环境,即使卸载系统 Bun,BVM 依然能稳定工作并自愈。
|
|
61
61
|
- **🛡️ 原子化隔离**:每个 Bun 版本拥有独立的全局包目录,彻底告别依赖冲突。
|
|
62
|
-
- **🌏
|
|
62
|
+
- **🌏 零魔法全网通**:不仅安装 Bun 时飞快,更能自动检测并配置最佳镜像源(如 npmmirror),确保后续的 `bun install` 开箱即用,无需手动配置。
|
|
63
63
|
- **📦 零依赖自举**:BVM 自身能够实现环境自举。安装无需预设环境(它会自动复用系统 Bun 或按需下载)。
|
|
64
64
|
|
|
65
65
|
---
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`);return}this.timer=setInterval(()=>{process.stdout.write(`\r\x1B[K${Y.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(`${Y.green(" \u2713")} ${$||this.text}`)}fail($){this.stop(),console.log(`${Y.red(" \u2716")} ${$||this.text}`)}info($){this.stop(),console.log(`${Y.blue(" \u2139")} ${$||this.text}`)}update($){if(this.text=$,this.isWindows)console.log(Y.dim(` ... ${this.text}`))}}class
|
|
5
|
-
`)}render($){let b=Math.min(1,this.current/this.total),q=Math.round(this.width*b),Q=this.width-q,K=process.platform==="win32",J=K?"=":"\u2588",Z=K?"-":"\u2591",G=Y.green(J.repeat(q))+Y.gray(Z.repeat(Q)),W=(b*100).toFixed(0).padStart(3," "),L=(this.current/1048576).toFixed(1),O=(this.total/1048576).toFixed(1),
|
|
6
|
-
`);for(let W of G){let L=W.match(/refs\/tags\/bun-v?(\d+\.\d+\.\d+.*)$/);if(L)q.push(L[1])}$(q)}).catch((Z)=>{clearTimeout(K),b(Z)})}catch(Q){b(Error(`Failed to run git: ${Q.message}`))}})}async function
|
|
7
|
-
\u26A0\uFE0F Warning: Global bin directory is not in your PATH.`)),console.log(Y.yellow(" Global packages (e.g., 'bun install -g') may not be found.")),console.log(Y.gray(" Please add the following to your PATH:")),console.log(Y.white(` ${O}`)),K)K.start()}}catch(O){}if(K)K.succeed(Y.green(`Now using Bun ${G} (immediate effect).`))};if(b.silent)await Q();else await
|
|
3
|
+
var Q6=Object.create;var{getPrototypeOf:J6,defineProperty:T$,getOwnPropertyNames:K6}=Object;var Y6=Object.prototype.hasOwnProperty;var O$=($,b,q)=>{q=$!=null?Q6(J6($)):{};let Q=b||!$||!$.__esModule?T$(q,"default",{value:$,enumerable:!0}):q;for(let K of K6($))if(!Y6.call(Q,K))T$(Q,K,{get:()=>$[K],enumerable:!0});return Q};var q1=($,b)=>{for(var q in b)T$($,q,{get:b[q],enumerable:!0,configurable:!0,set:(Q)=>b[q]=()=>Q})};var k$=($,b)=>()=>($&&(b=$($=0)),b);var X$=import.meta.require;var J1={};q1(J1,{getBvmDir:()=>Q1,getBunAssetName:()=>v$,USER_AGENT:()=>y$,TEST_REMOTE_VERSIONS:()=>U$,REPO_FOR_BVM_CLI:()=>y6,OS_PLATFORM:()=>k,IS_TEST_MODE:()=>M,HAS_AVX2:()=>f$,EXECUTABLE_NAME:()=>R,CPU_ARCH:()=>$$,BVM_VERSIONS_DIR:()=>C,BVM_SRC_DIR:()=>E$,BVM_SHIMS_DIR:()=>E,BVM_FINGERPRINTS_FILE:()=>I$,BVM_DIR:()=>z,BVM_CURRENT_DIR:()=>K$,BVM_COMPONENTS:()=>z6,BVM_CDN_ROOT:()=>L6,BVM_CACHE_DIR:()=>_,BVM_BIN_DIR:()=>j,BVM_ALIAS_DIR:()=>F,BUN_GITHUB_RELEASES_API:()=>U6,ASSET_NAME_FOR_BVM:()=>H6});import{homedir as G6}from"os";import{join as o}from"path";import{spawnSync as R$}from"child_process";function X6(){let $=process.arch;if(k==="darwin"&&$==="x64")try{if(R$("sysctl",["-n","sysctl.proc_translated"],{encoding:"utf-8"}).stdout.trim()==="1")return"arm64"}catch(b){}return $}function W6(){if(k==="win32")return!0;try{if(k==="darwin")return R$("sysctl",["-a"],{encoding:"utf-8"}).stdout.includes("AVX2");else if(k==="linux")return R$("cat",["/proc/cpuinfo"],{encoding:"utf-8"}).stdout.includes("avx2")}catch($){}return!0}function Q1(){let $=process.env.HOME||G6();return o($,".bvm")}function v$($){let b=k==="win32"?"windows":k,q=$$==="arm64"?"aarch64":"x64";return`bun-${b}-${q}${!f$&&q==="x64"?"-baseline":""}.zip`}var k,M,U$,$$,f$,z,E$,C,j,E,K$,F,_,I$,R,U6="https://api.github.com/repos/oven-sh/bun/releases",y6="EricLLLLLL/bvm",H6,y$="bvm (Bun Version Manager)",L6,z6;var f=k$(()=>{k=process.platform,M=process.env.BVM_TEST_MODE==="true",U$=["v1.3.4","v1.2.23","v1.0.0","bun-v1.4.0-canary"];$$=X6(),f$=W6();z=Q1(),E$=o(z,"src"),C=o(z,"versions"),j=o(z,"bin"),E=o(z,"shims"),K$=o(z,"current"),F=o(z,"aliases"),_=o(z,"cache"),I$=o(z,"fingerprints.json"),R=k==="win32"?"bun.exe":"bun",H6=k==="win32"?"bvm.exe":"bvm",L6=process.env.BVM_CDN_URL||"https://cdn.jsdelivr.net/gh/EricLLLLLL/bvm",z6=[{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 p($){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 K1($){let b=p($);return b?b.replace(/^v/,""):null}function Y$($){if(!$)return null;let b=$.replace(/^v/,""),Q=b.split(/[-+]/)[0].split(".").map(Number);if(Q.length===0||Q.some((J)=>isNaN(J)))return null;let K=b.includes("-")?b.split("-")[1].split("+")[0]:void 0;return{major:Q[0],minor:Q[1],patch:Q[2],pre:K}}function _$($,b){if(!$||!b)return 0;if($.major!==b.major)return $.major-b.major;if($.minor!==b.minor)return $.minor-b.minor;if($.patch!==b.patch)return $.patch-b.patch;if($.pre&&!b.pre)return-1;if(!$.pre&&b.pre)return 1;if($.pre&&b.pre)return $.pre.localeCompare(b.pre);return 0}function Y1($,b){let q=Y$($),Q=Y$(b);return _$(q,Q)}function Z$($,b){return Y1(b,$)}function A$($,b){return Y1($,b)>0}function Z1($,b){if(b==="*"||b===""||b==="latest")return!0;let q=Y$($);if(!q)return!1;let Q=b;if(b.startsWith("v"))Q=b.substring(1);if(K1($)===K1(b))return!0;let K=Q.split(".");if(K.length===1){let J=Number(K[0]);if(q.major===J)return!0}else if(K.length===2){let J=Number(K[0]),Z=Number(K[1]);if(q.major===J&&q.minor===Z)return!0}if(b.startsWith("~")){let J=Y$(b.substring(1));if(!J)return!1;let Z=J.patch??0;return q.major===J.major&&q.minor===J.minor&&q.patch>=Z}if(b.startsWith("^")){let J=Y$(b.substring(1));if(!J)return!1;let Z=J.patch??0,G=J.minor??0;if(J.major===0){if(q.major!==0)return!1;if(q.minor!==G)return!1;return q.patch>=Z}if(q.major!==J.major)return!1;if(q.minor<G)return!1;if(q.minor===G&&q.patch<Z)return!1;return!0}return!1}import{readdir as O6,mkdir as k6,stat as G1,symlink as C6,unlink as X1,rm as W1,readlink as x6}from"fs/promises";import{join as j$,dirname as N6,basename as F6}from"path";async function T($){try{await k6($,{recursive:!0})}catch(b){if(b.code==="EEXIST")try{if((await G1($)).isDirectory())return}catch{}throw b}}async function X($){try{return await G1($),!0}catch(b){if(b.code==="ENOENT")return!1;throw b}}async function U1($,b){try{await X1(b)}catch(Q){try{await W1(b,{recursive:!0,force:!0})}catch(K){}}let q=process.platform==="win32"?"junction":"dir";await C6($,b,q)}async function y1($){try{return await x6($)}catch(b){if(b.code==="ENOENT"||b.code==="EINVAL")return null;throw b}}async function H$($){await W1($,{recursive:!0,force:!0})}async function l($){try{return await O6($)}catch(b){if(b.code==="ENOENT")return[];throw b}}async function D($){return await Bun.file($).text()}async function d($,b){await Bun.write($,b)}async function C$($,b,q={}){let{backup:Q=!0}=q,K=N6($);await T(K);let J=`${$}.tmp-${Date.now()}`,Z=`${$}.bak`;try{if(await d(J,b),Q&&await X($))try{let{rename:W,unlink:L}=await import("fs/promises");if(await X(Z))await L(Z).catch(()=>{});await W($,Z)}catch(W){}let{rename:G}=await import("fs/promises");try{await G(J,$)}catch(W){await Bun.write($,b),await X1(J).catch(()=>{})}}catch(G){let{unlink:W}=await import("fs/promises");throw await W(J).catch(()=>{}),G}}function H($){let b=$.trim();if(b.startsWith("bun-v"))b=b.substring(4);if(!b.startsWith("v")&&/^\d/.test(b))b=`v${b}`;return b}async function V(){return await T(C),(await l(C)).filter((b)=>p(H(b))).sort(Z$)}async function t(){if(process.env.BVM_ACTIVE_VERSION)return{version:H(process.env.BVM_ACTIVE_VERSION),source:"env"};let $=j$(process.cwd(),".bvmrc");if(await X($)){let Z=(await D($)).trim();return{version:H(Z),source:".bvmrc"}}let{getBvmDir:b}=await Promise.resolve().then(() => (f(),J1)),q=b(),Q=j$(q,"current"),K=j$(q,"aliases");if(await X(Q)){let{realpath:Z}=await import("fs/promises");try{let G=await Z(Q);return{version:H(F6(G)),source:"current"}}catch(G){}}let J=j$(K,"default");if(await X(J)){let Z=(await D(J)).trim();return{version:H(Z),source:"default"}}return{version:null,source:null}}function b$($,b){if(!$||b.length===0)return null;let q=H($);if(b.includes(q))return q;if($.toLowerCase()==="latest")return b[0];if(/^\d+\.\d+\.\d+$/.test($.replace(/^v/,"")))return null;if(!/^[v\d]/.test($))return null;let K=$.startsWith("v")?`~${$.substring(1)}`:`~${$}`,J=b.filter((Z)=>Z1(Z,K));if(J.length>0)return J.sort(Z$)[0];return null}var x=k$(()=>{f()});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(`${Y.cyan(">")} ${this.text}
|
|
4
|
+
`);return}this.timer=setInterval(()=>{process.stdout.write(`\r\x1B[K${Y.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(`${Y.green(" \u2713")} ${$||this.text}`)}fail($){this.stop(),console.log(`${Y.red(" \u2716")} ${$||this.text}`)}info($){this.stop(),console.log(`${Y.blue(" \u2139")} ${$||this.text}`)}update($){if(this.text=$,this.isWindows)console.log(Y.dim(` ... ${this.text}`))}}class P${total;current=0;width=20;constructor($){this.total=$}start(){process.stdout.write("\x1B[?25l"),this.render()}update($,b){this.current=$,this.render(b)}stop(){process.stdout.write(`\x1B[?25h
|
|
5
|
+
`)}render($){let b=Math.min(1,this.current/this.total),q=Math.round(this.width*b),Q=this.width-q,K=process.platform==="win32",J=K?"=":"\u2588",Z=K?"-":"\u2591",G=Y.green(J.repeat(q))+Y.gray(Z.repeat(Q)),W=(b*100).toFixed(0).padStart(3," "),L=(this.current/1048576).toFixed(1),O=(this.total/1048576).toFixed(1),y=$?` ${$.speed}KB/s`:"";process.stdout.write(`\r\x1B[2K ${G} ${W}% | ${L}/${O}MB${y}`)}}var f6,A6=($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=($,b,q=$)=>(Q)=>f6?$+Q.replace(new RegExp(A6(b),"g"),q)+b:Q,Y;var N=k$(()=>{f6=!process.env.NO_COLOR,Y={red:a("\x1B[1;31m","\x1B[39m"),green:a("\x1B[1;32m","\x1B[39m"),yellow:a("\x1B[1;33m","\x1B[39m"),blue:a("\x1B[1;34m","\x1B[39m"),magenta:a("\x1B[1;35m","\x1B[39m"),cyan:a("\x1B[1;36m","\x1B[39m"),gray:a("\x1B[90m","\x1B[39m"),bold:a("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:a("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m")}});async function U($,b,q){if(process.platform==="win32"){console.log(Y.cyan(`> ${$}`));let J={start:(Z)=>{if(Z)console.log(Y.cyan(`> ${Z}`))},stop:()=>{},succeed:(Z)=>console.log(Y.green(` \u2713 ${Z}`)),fail:(Z)=>console.log(Y.red(` \u2716 ${Z}`)),info:(Z)=>console.log(Y.cyan(` \u2139 ${Z}`)),update:(Z)=>console.log(Y.dim(` ... ${Z}`)),isSpinning:!1};try{return await b(J)}catch(Z){let G=x1(Z,q?.failMessage);if(console.log(Y.red(` \u2716 ${G}`)),process.env.BVM_DEBUG,console.log(Y.dim(` Details: ${Z.message}`)),Z.code)console.log(Y.dim(` Code: ${Z.code}`));throw Z.reported=!0,Z}}let K=new S$($);K.start();try{let J=await b(K);return K.stop(),J}catch(J){let Z=x1(J,q?.failMessage);throw K.fail(Y.red(Z)),J.reported=!0,J}}function x1($,b){let q=$ instanceof Error?$.message:String($);if(!b)return q;if(typeof b==="function")return b($);return`${b}: ${q}`}var B=k$(()=>{N()});var N1={};q1(N1,{resolveLocalVersion:()=>h,displayVersion:()=>g$});import{join as S6}from"path";async function h($){if($==="current"){let{version:K}=await t();return K}if($==="latest"){let K=await V();if(K.length>0)return K[0];return null}let b=S6(F,$);if(await X(b))try{let K=(await D(b)).trim();return H(K)}catch{return null}let q=H($),Q=await V();return b$($,Q)}async function g$($){await U(`Resolving version '${$}'...`,async()=>{let b=await h($);if(b)console.log(b);else throw Error("N/A")},{failMessage:`Failed to resolve version '${$}'`})}var Q$=k$(()=>{f();x();B()});import{parseArgs as O4}from"util";var W$={name:"bvm-core",version:"1.1.35",description:"The native version manager for Bun. Cross-platform, shell-agnostic, and zero-dependency.",main:"dist/index.js",bin:{bvm:"bin/bvm-npm.js"},publishConfig:{access:"public"},homepage:"https://bvm-core.pages.dev",bugs:{url:"https://github.com/EricLLLLLL/bvm/issues"},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/check-integrity.ts && bun run build && bun run scripts/release.ts","check-integrity":"bun run scripts/check-integrity.ts","test:e2e:npm":"bun run scripts/verify-e2e-npm.ts","sync-runtime":"bun run scripts/sync-runtime.ts",postinstall:"node scripts/postinstall.js"},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","bin/bvm-npm.js","scripts/postinstall.js","install.sh","install.ps1","README.md"],author:"EricLLLLLL",license:"MIT",type:"commonjs",dependencies:{"cli-progress":"^3.12.0"},optionalDependencies:{"@oven/bun-darwin-aarch64":"^1.3.6","@oven/bun-darwin-x64":"^1.3.6","@oven/bun-linux-aarch64":"^1.3.6","@oven/bun-linux-x64":"^1.3.6","@oven/bun-windows-x64":"^1.3.6"},devDependencies:{"@types/bun":"^1.3.4","@types/cli-progress":"^3.11.6","@types/node":"^24.10.2",bun:"^1.3.6",esbuild:"^0.27.2",execa:"^9.6.1",typescript:"^5"},peerDependencies:{typescript:"^5"}};f();x();import{join as i,basename as r6,dirname as e6}from"path";f();x();N();import{join as M6}from"path";function H1($,b){if($==="darwin"){if(b==="arm64")return"@oven/bun-darwin-aarch64";if(b==="x64")return"@oven/bun-darwin-x64"}if($==="linux"){if(b==="arm64")return"@oven/bun-linux-aarch64";if(b==="x64")return"@oven/bun-linux-x64"}if($==="win32"){if(b==="x64")return"@oven/bun-windows-x64"}return null}function L1($,b,q){let Q=q;if(!Q.endsWith("/"))Q+="/";let K=$.startsWith("@"),J=$;if(K){let G=$.split("/");if(G.length===2)J=G[1]}let Z=`${J}-${b}.tgz`;return`${Q}${$}/-/${Z}`}N();async function m($,b={}){let{cwd:q,env:Q,prependPath:K,stdin:J="inherit",stdout:Z="inherit",stderr:G="inherit"}=b,W={...process.env,...Q};if(K){let y=W.PATH||"",A=process.platform==="win32"?";":":";W.PATH=`${K}${A}${y}`}let O=await Bun.spawn({cmd:$,cwd:q,env:W,stdin:J,stdout:Z,stderr:G}).exited;if((O??0)!==0)throw Error(`${Y.red("Command failed")}: ${$.join(" ")} (code ${O})`);return O??0}async function s($,b={}){let{timeout:q=5000,...Q}=b,K=new AbortController,J=setTimeout(()=>K.abort(),q);try{let Z=await fetch($,{...Q,signal:K.signal});return clearTimeout(J),Z}catch(Z){if(clearTimeout(J),Z.name==="AbortError")throw Error(`Request to ${$} timed out after ${q}ms`);throw Z}}async function j6($,b=2000){if($.length===0)throw Error("No URLs to race");if($.length===1)return $[0];return new Promise((q,Q)=>{let K=0,J=!1;$.forEach((Z)=>{s(Z,{method:"HEAD",timeout:b}).then((G)=>{if(G.ok&&!J)J=!0,q(Z);else if(!J){if(K++,K===$.length)Q(Error("All requests failed"))}}).catch(()=>{if(!J){if(K++,K===$.length)Q(Error("All requests failed"))}})})})}async function B6(){try{let $=await s("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 u$=null,x$={NPM:"https://registry.npmjs.org",TAOBAO:"https://registry.npmmirror.com",TENCENT:"https://mirrors.cloud.tencent.com/npm/"};async function q$(){if(u$)return u$;let $=await B6(),b=[];if($==="CN")b=[x$.TAOBAO,x$.TENCENT,x$.NPM];else b=[x$.NPM,x$.TAOBAO];try{let q=await j6(b,2000);return u$=q,q}catch(q){return b[0]}}x();var D6="bun-versions.json",T6=3600000;async function R6(){if(M)return[...U$];let $=M6(_,D6);try{if(await X($)){let K=await D($),J=JSON.parse(K);if(Date.now()-J.timestamp<T6&&Array.isArray(J.versions))return J.versions}}catch(K){}let b=await q$(),q=[b];if(b!=="https://registry.npmjs.org")q.push("https://registry.npmjs.org");let Q=null;for(let K of q){let J=`${K.replace(/\/$/,"")}/bun`;try{let Z=await s(J,{headers:{"User-Agent":y$,Accept:"application/vnd.npm.install-v1+json"},timeout:1e4});if(!Z.ok)throw Error(`Status ${Z.status}`);let G=await Z.json();if(!G.versions)throw Error("Invalid response (no versions)");let W=Object.keys(G.versions);try{await T(_),await d($,JSON.stringify({timestamp:Date.now(),versions:W}))}catch(L){}return W}catch(Z){Q=Z}}throw Q||Error("Failed to fetch versions from any registry.")}async function E6(){if(M)return[...U$];return new Promise(($,b)=>{let q=[];try{let Q=Bun.spawn(["git","ls-remote","--tags","https://github.com/oven-sh/bun.git"],{stdout:"pipe",stderr:"pipe"}),K=setTimeout(()=>{Q.kill(),b(Error("Git operation timed out"))},1e4);new Response(Q.stdout).text().then((Z)=>{clearTimeout(K);let G=Z.split(`
|
|
6
|
+
`);for(let W of G){let L=W.match(/refs\/tags\/bun-v?(\d+\.\d+\.\d+.*)$/);if(L)q.push(L[1])}$(q)}).catch((Z)=>{clearTimeout(K),b(Z)})}catch(Q){b(Error(`Failed to run git: ${Q.message}`))}})}async function z1(){if(M)return[...U$];try{let b=(await R6()).filter((q)=>p(q)).map((q)=>({v:q,parsed:Y$(q)}));return b.sort((q,Q)=>_$(Q.parsed,q.parsed)),b.map((q)=>q.v)}catch($){try{let b=await E6();if(b.length>0)return Array.from(new Set(b.filter((Q)=>p(Q)))).sort(Z$);throw Error("No versions found via Git")}catch(b){throw Error(`Failed to fetch versions. NPM: ${$.message}. Git: ${b.message}`)}}}async function w1($){if(M)return U$.includes($)||$==="latest";let b=await q$(),q=$.replace(/^v/,""),Q=`${b}/bun/${q}`,K=k==="win32"?"curl.exe":"curl",J=async()=>{try{return await m([K,"-I","-f","-m","5","-s",Q],{stdout:"ignore",stderr:"ignore"}),!0}catch(G){return!1}},Z=new Promise((G)=>setTimeout(()=>G(!1),1e4));return Promise.race([J(),Z])}async function O1(){if(M)return{latest:"1.1.20"};let b=`${await q$()}/-/package/bun/dist-tags`;try{let q=await s(b,{headers:{"User-Agent":y$},timeout:5000});if(q.ok)return await q.json()}catch(q){}return{}}async function k1($){let b=H($);if(!p(b))return console.error(Y.red(`Invalid version provided to findBunDownloadUrl: ${$}`)),null;if(M)return{url:`https://example.com/${v$(b)}`,foundVersion:b};let K=H1(k==="win32"?"win32":k,$$==="arm64"?"arm64":"x64");if(!K)throw Error(`Unsupported platform/arch for NPM download: ${k}-${$$}`);let J="";if(process.env.BVM_REGISTRY)J=process.env.BVM_REGISTRY;else if(process.env.BVM_DOWNLOAD_MIRROR)J=process.env.BVM_DOWNLOAD_MIRROR;else J=await q$();let Z=b.replace(/^v/,"");return{url:L1(K,Z,J),foundVersion:b}}async function B$(){try{let b=(await q$()).replace(/\/$/,""),q=await s(`${b}/-/package/bvm-core/dist-tags`,{headers:{"User-Agent":y$},timeout:5000});if(!q.ok)return null;let K=(await q.json()).latest;if(!K)return null;let J=await s(`${b}/bvm-core/${K}`,{headers:{"User-Agent":y$},timeout:5000});if(J.ok){let Z=await J.json();return{version:K,tarball:Z.dist.tarball,integrity:Z.dist.integrity,shasum:Z.dist.shasum}}}catch($){}return null}N();f();import{spawn as I6}from"child_process";async function C1($,b){if($.endsWith(".zip"))if(k==="win32")await m(["powershell","-Command",`Expand-Archive -Path "${$}" -DestinationPath "${b}" -Force`],{stdout:"ignore",stderr:"inherit"});else await m(["unzip","-o","-q",$,"-d",b],{stdout:"ignore",stderr:"inherit"});else if($.endsWith(".tar.gz")||$.endsWith(".tgz"))await new Promise((q,Q)=>{let K=I6("tar",["-xzf",$,"-C",b],{stdio:"inherit",shell:!1});K.on("close",(J)=>{if(J===0)q();else Q(Error(`tar exited with code ${J}`))}),K.on("error",(J)=>Q(J))});else throw Error(`Unsupported archive format: ${$}`)}import{chmod as i$}from"fs/promises";x();f();N();import{join as w,dirname as F1}from"path";import{homedir as g}from"os";import{mkdir as f1}from"fs/promises";import{chmod as N$}from"fs/promises";f();x();N();import{join as V$}from"path";x();import{join as v6,dirname as _6}from"path";async function M$(){let $=process.cwd();while(!0){let b=v6($,".bvmrc");if(await X(b))try{return(await Bun.file(b).text()).trim()}catch(Q){return null}let q=_6($);if(q===$)break;$=q}return null}Q$();B();async function L$($,b={}){let q=$;if(!q)q=await M$()||void 0;if(!q){if(!b.silent)console.error(Y.red("No version specified. Usage: bvm use <version>"));throw Error("No version specified.")}let Q=async(K)=>{let J=null,Z=await h(q);if(Z)J=Z;else{let O=(await V()).map((y)=>H(y));J=b$(q,O)}if(!J)throw Error(`Bun version '${q}' is not installed.`);let G=H(J),W=V$(C,G),L=V$(W,"bin",R);if(!await X(L))throw Error(`Version ${G} is not properly installed (binary missing).`);await U1(W,K$);try{let O=V$(K$,"bin"),y=O.replace(/\\/g,"/"),A=X$("path").delimiter;if(!(process.env.PATH||"").split(A).some((P)=>{let u=P.replace(/\\/g,"/");return u.includes(y)||u.endsWith("/.bvm/current/bin")})&&!b.silent){if(K)K.stop();if(console.log(Y.yellow(`
|
|
7
|
+
\u26A0\uFE0F Warning: Global bin directory is not in your PATH.`)),console.log(Y.yellow(" Global packages (e.g., 'bun install -g') may not be found.")),console.log(Y.gray(" Please add the following to your PATH:")),console.log(Y.white(` ${O}`)),K)K.start()}}catch(O){}if(K)K.succeed(Y.green(`Now using Bun ${G} (immediate effect).`))};if(b.silent)await Q();else await U(`Switching to Bun ${q}...`,(K)=>Q(K),{failMessage:()=>`Failed to switch to Bun ${q}`})}var d$=`#!/bin/bash
|
|
8
8
|
|
|
9
9
|
# bvm-init.sh: Initializes bvm default version on shell startup
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ fi
|
|
|
15
15
|
|
|
16
16
|
# Try to switch to the 'default' version silently.
|
|
17
17
|
"\${BVM_DIR}/bin/bvm" use default --silent >/dev/null 2>&1 || true
|
|
18
|
-
`;var
|
|
18
|
+
`;var m$=`# bvm-init.fish: Initializes bvm default version on shell startup
|
|
19
19
|
|
|
20
20
|
# Check if BVM_DIR is set
|
|
21
21
|
if not set -q BVM_DIR
|
|
@@ -24,7 +24,7 @@ end
|
|
|
24
24
|
|
|
25
25
|
# Try to switch to the 'default' version silently.
|
|
26
26
|
eval "$BVM_DIR/bin/bvm" use default --silent >/dev/null 2>&1 || true
|
|
27
|
-
`;var
|
|
27
|
+
`;var h$=`#!/bin/bash
|
|
28
28
|
# Shim managed by BVM (Bun Version Manager)
|
|
29
29
|
# Optimized for performance via Bash-native syntax.
|
|
30
30
|
|
|
@@ -89,7 +89,7 @@ else
|
|
|
89
89
|
echo "BVM Error: Command '$CMD_NAME' not found in Bun $VERSION." >&2
|
|
90
90
|
exit 127
|
|
91
91
|
fi
|
|
92
|
-
`;var
|
|
92
|
+
`;var c$=`const path = require('path');
|
|
93
93
|
const { spawn } = require('child_process');
|
|
94
94
|
const os = require('os');
|
|
95
95
|
const fs = require('fs');
|
|
@@ -195,7 +195,7 @@ child.on('error', (err) => {
|
|
|
195
195
|
console.error("BVM Error: Failed to start child process: " + err.message);
|
|
196
196
|
process.exit(1);
|
|
197
197
|
});
|
|
198
|
-
`;var
|
|
198
|
+
`;var p$=`@echo off
|
|
199
199
|
set "BVM_DIR=%USERPROFILE%\\.bvm"
|
|
200
200
|
set "BUN_INSTALL=%BVM_DIR%\\current"
|
|
201
201
|
|
|
@@ -208,7 +208,7 @@ if not exist ".bvmrc" (
|
|
|
208
208
|
:: Slow-path: Hand over to JS shim for version resolution
|
|
209
209
|
"%BVM_DIR%\\runtime\\current\\bin\\bun.exe" "%BVM_DIR%\\bin\\bvm-shim.js" "bun" %*
|
|
210
210
|
|
|
211
|
-
`;var
|
|
211
|
+
`;var l$=`@echo off
|
|
212
212
|
set "BVM_DIR=%USERPROFILE%\\.bvm"
|
|
213
213
|
set "BUN_INSTALL=%BVM_DIR%\\current"
|
|
214
214
|
|
|
@@ -219,10 +219,10 @@ if not exist ".bvmrc" (
|
|
|
219
219
|
|
|
220
220
|
"%BVM_DIR%\\runtime\\current\\bin\\bun.exe" "%BVM_DIR%\\bin\\bvm-shim.js" "bunx" %*
|
|
221
221
|
|
|
222
|
-
`;var
|
|
222
|
+
`;var t$=`@echo off
|
|
223
223
|
set "BVM_DIR=%USERPROFILE%\\.bvm"
|
|
224
224
|
"%BVM_DIR%\\runtime\\current\\bin\\bun.exe" "%BVM_DIR%\\src\\index.js" %*
|
|
225
|
-
`;async function
|
|
225
|
+
`;async function z$($=!0){if(await c6($),process.platform==="win32"){await p6($);return}let b=process.env.SHELL||"",q="",Q="";if(b.includes("zsh"))Q="zsh",q=w(g(),".zshrc");else if(b.includes("bash"))if(Q="bash",process.platform==="darwin")if(await X(w(g(),".bashrc")))q=w(g(),".bashrc");else q=w(g(),".bash_profile");else q=w(g(),".bashrc");else if(b.includes("fish"))Q="fish",q=w(g(),".config","fish","config.fish");else if(await X(w(g(),".zshrc")))Q="zsh",q=w(g(),".zshrc");else if(await X(w(g(),".config","fish","config.fish")))Q="fish",q=w(g(),".config","fish","config.fish");else if(await X(w(g(),".bashrc")))Q="bash",q=w(g(),".bashrc");else if(await X(w(g(),".bash_profile")))Q="bash",q=w(g(),".bash_profile");else{if($)console.log(Y.yellow(`Could not detect a supported shell (zsh, bash, fish). Please manually add ${j} to your PATH.`));return}let K=w(j,"bvm-init.sh");await Bun.write(K,d$),await N$(K,493);let J=w(j,"bvm-init.fish");await Bun.write(J,m$),await N$(J,493);let Z="";try{Z=await Bun.file(q).text()}catch(y){if(y.code==="ENOENT")await Bun.write(q,""),Z="";else throw y}let G="# >>> bvm initialize >>>",W="# <<< bvm initialize <<<",L=`${G}
|
|
226
226
|
# !! Contents within this block are managed by 'bvm setup' !!
|
|
227
227
|
export BVM_DIR="${z}"
|
|
228
228
|
export PATH="$BVM_DIR/shims:$BVM_DIR/bin:$BVM_DIR/current/bin:$PATH"
|
|
@@ -242,10 +242,10 @@ if not test -L "$BVM_DIR/current"
|
|
|
242
242
|
ln -sf "$BVM_DIR/versions/$(cat "$BVM_DIR/aliases/default")" "$BVM_DIR/current"
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
|
-
# <<< bvm initialize <<<`;if($)console.log(Y.cyan(`Configuring ${Q} environment in ${q}...`));try{let
|
|
245
|
+
# <<< bvm initialize <<<`;if($)console.log(Y.cyan(`Configuring ${Q} environment in ${q}...`));try{let y=Z,A=G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),S=new RegExp(`${A}[\\s\\S]*?${c}`,"g");if(Z.includes(G))y=Z.replace(S,"").trim();let P=Q==="fish"?O:L;if(y=(y?y+`
|
|
246
246
|
|
|
247
247
|
`:"")+P+`
|
|
248
|
-
`,
|
|
248
|
+
`,y!==Z){if(await Bun.write(q,y),$)console.log(Y.green(`\u2713 Successfully updated BVM configuration in ${q}`)),console.log(Y.gray(" (Moved configuration to the end of file to ensure PATH precedence)"))}if($)console.log(Y.yellow(`Please restart your terminal or run "source ${q}" to apply changes.`));try{await L$("default",{silent:!0})}catch(u){}}catch(y){console.error(Y.red(`Failed to write to ${q}: ${y.message}`))}}async function c6($){if($)console.log(Y.cyan("Refreshing shims and wrappers..."));if(!$)console.log(`[DEBUG] BIN_DIR: ${j}`),console.log(`[DEBUG] SHIMS_DIR: ${E}`);if(await f1(j,{recursive:!0}),await f1(E,{recursive:!0}),process.platform==="win32")await Bun.write(w(j,"bvm-shim.js"),c$),await Bun.write(w(j,"bvm.cmd"),t$),await Bun.write(w(E,"bun.cmd"),p$),await Bun.write(w(E,"bunx.cmd"),l$);else{let q=w(j,"bvm-shim.sh");await Bun.write(q,h$),await N$(q,493);let Q="",K=w(z,"runtime","current","bin","bun"),J=w(E$,"index.js");if(process.env.BVM_INSTALL_SOURCE==="npm")Q=`#!/bin/bash
|
|
249
249
|
export BVM_DIR="${z}"
|
|
250
250
|
export BVM_INSTALL_SOURCE="npm"
|
|
251
251
|
if [ -f "${K}" ]; then
|
|
@@ -261,9 +261,9 @@ else
|
|
|
261
261
|
fi
|
|
262
262
|
`;else Q=`#!/bin/bash
|
|
263
263
|
export BVM_DIR="${z}"
|
|
264
|
-
exec "${K}" "${J}" "$@"`;let Z=w(j,"bvm");await Bun.write(Z,Q),await
|
|
264
|
+
exec "${K}" "${J}" "$@"`;let Z=w(j,"bvm");await Bun.write(Z,Q),await N$(Z,493);for(let G of["bun","bunx"]){let W=`#!/bin/bash
|
|
265
265
|
export BVM_DIR="${z}"
|
|
266
|
-
exec "${z}/bin/bvm-shim.sh" "${G}" "$@"`,L=w(
|
|
266
|
+
exec "${z}/bin/bvm-shim.sh" "${G}" "$@"`,L=w(E,G);await Bun.write(L,W),await N$(L,493)}}}async function p6($=!0){let b=w(j),q=w(E),Q=w(z,"current","bin");if($)console.log(Y.cyan("Configuring Windows environment variables (Registry)..."));let K=`
|
|
267
267
|
$targetDir = "${z}";
|
|
268
268
|
$shimsPath = "${q}";
|
|
269
269
|
$binPath = "${b}";
|
|
@@ -287,7 +287,7 @@ exec "${z}/bin/bvm-shim.sh" "${G}" "$@"`,L=w(I,G);await Bun.write(L,W),await k$(
|
|
|
287
287
|
return "SUCCESS"
|
|
288
288
|
}
|
|
289
289
|
return "ALREADY_SET"
|
|
290
|
-
`;try{let Z=Bun.spawnSync({cmd:["powershell","-NoProfile","-Command",K],stdout:"pipe",stderr:"pipe"}),G=Z.stdout.toString().trim();if(Z.success){if($)if(G==="SUCCESS")console.log(Y.green("\u2713 Successfully updated User PATH and BVM_DIR in Registry."));else console.log(Y.gray("\u2713 Environment variables are already up to date."))}else throw Error(Z.stderr.toString())}catch(Z){console.error(Y.red(`Failed to update environment variables: ${Z.message}`))}let J="";try{if(J=Bun.spawnSync({cmd:["powershell","-NoProfile","-Command","echo $PROFILE.CurrentUserAllHosts"],stdout:"pipe"}).stdout.toString().trim(),J)Bun.spawnSync({cmd:["powershell","-NoProfile","-Command",`if (!(Test-Path "${
|
|
290
|
+
`;try{let Z=Bun.spawnSync({cmd:["powershell","-NoProfile","-Command",K],stdout:"pipe",stderr:"pipe"}),G=Z.stdout.toString().trim();if(Z.success){if($)if(G==="SUCCESS")console.log(Y.green("\u2713 Successfully updated User PATH and BVM_DIR in Registry."));else console.log(Y.gray("\u2713 Environment variables are already up to date."))}else throw Error(Z.stderr.toString())}catch(Z){console.error(Y.red(`Failed to update environment variables: ${Z.message}`))}let J="";try{if(J=Bun.spawnSync({cmd:["powershell","-NoProfile","-Command","echo $PROFILE.CurrentUserAllHosts"],stdout:"pipe"}).stdout.toString().trim(),J)Bun.spawnSync({cmd:["powershell","-NoProfile","-Command",`if (!(Test-Path "${F1(J)}")) { New-Item -ItemType Directory -Force -Path "${F1(J)}" }`],stderr:"pipe"}),await l6(J,!1)}catch(Z){}if($)console.log(Y.yellow("Please restart your terminal or IDE to apply the new PATH."))}async function l6($,b=!0){let q=`
|
|
291
291
|
# BVM Configuration
|
|
292
292
|
$env:BVM_DIR = "${z}"
|
|
293
293
|
$env:PATH = "$env:BVM_DIR\\shims;$env:BVM_DIR\\bin;$env:BVM_DIR\\current\\bin;$env:PATH"
|
|
@@ -296,49 +296,56 @@ if (Test-Path "$env:BVM_DIR\\bin\\bvm.cmd") {
|
|
|
296
296
|
& "$env:BVM_DIR\\bin\\bvm.cmd" use default --silent *>$null
|
|
297
297
|
}
|
|
298
298
|
`;try{let Q="";if(await X($))Q=await Bun.file($).text();else await Bun.write($,"");if(Q.includes("$env:BVM_DIR")){if(b)console.log(Y.gray("\u2713 Configuration is already up to date."));return}if(b)console.log(Y.cyan(`Configuring PowerShell environment in ${$}...`));if(await Bun.write($,Q+`\r
|
|
299
|
-
${q}`),b)console.log(Y.green(`\u2713 Successfully configured BVM path in ${$}`)),console.log(Y.yellow("Please restart your terminal to apply changes."))}catch(Q){console.error(Y.red(`Failed to write to ${$}: ${Q.message}`))}}
|
|
300
|
-
`),K)K.succeed(Y.green(`Alias '${$}' created for Bun ${J}.`))};if(q.silent)await Q();else await
|
|
299
|
+
${q}`),b)console.log(Y.green(`\u2713 Successfully configured BVM path in ${$}`)),console.log(Y.yellow("Please restart your terminal to apply changes."))}catch(Q){console.error(Y.red(`Failed to write to ${$}: ${Q.message}`))}}N();f();x();Q$();B();import{join as A1}from"path";async function w$($,b,q={}){let Q=async(K)=>{let J=await h(b);if(!J){if(!q.silent)console.log(Y.blue(`Please install Bun ${b} first using: bvm install ${b}`));throw Error(`Bun version '${b}' is not installed. Cannot create alias.`)}let Z=A1(C,J);if(!await X(Z))throw Error(`Internal Error: Resolved Bun version ${J} not found.`);await T(F);let G=A1(F,$);if($!=="default"&&await X(G))throw Error(`Alias '${$}' already exists. Use 'bvm alias ${$} <new-version>' to update or 'bvm unalias ${$}' to remove.`);if(await d(G,`${J}
|
|
300
|
+
`),K)K.succeed(Y.green(`Alias '${$}' created for Bun ${J}.`))};if(q.silent)await Q();else await U(`Creating alias '${$}' for Bun ${b}...`,(K)=>Q(K),{failMessage:`Failed to create alias '${$}'`})}B();f();x();N();import{join as n,dirname as j1}from"path";import{chmod as B1,unlink as t6}from"fs/promises";var __dirname="/home/runner/work/bvm/bvm/src/commands",n6=($)=>`@echo off
|
|
301
301
|
set "BVM_DIR=%USERPROFILE%.bvm"
|
|
302
302
|
if exist "%BVM_DIR%\runtimecurrent\bin\bun.exe" (
|
|
303
303
|
"%BVM_DIR%\runtimecurrent\bin\bun.exe" "%BVM_DIR%\bin\bvm-shim.js" "${$}" %*
|
|
304
304
|
) else (
|
|
305
305
|
echo BVM Error: Bun runtime not found.
|
|
306
306
|
exit /b 1
|
|
307
|
-
)`,
|
|
307
|
+
)`,i6=($)=>`#!/bin/bash
|
|
308
308
|
export BVM_DIR="${z}"
|
|
309
|
-
exec "${n(j,"bvm-shim.sh")}" "${$}" "$@"`;async function
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
exec "${n(j,"bvm-shim.sh")}" "${$}" "$@"`;async function J$(){await T(E),await T(j);let $=k==="win32";try{let q=n(j1(j1(__dirname)),"src","templates");if($){let Q=await Bun.file(n(q,"bvm-shim.js")).text();await Bun.write(n(j,"bvm-shim.js"),Q)}else{let Q=await Bun.file(n(q,"bvm-shim.sh")).text(),K=n(j,"bvm-shim.sh");await Bun.write(K,Q),await B1(K,493)}}catch(q){}let b=new Set(["bun","bunx"]);if(await X(C)){let q=await l(C);for(let Q of q){if(Q.startsWith("."))continue;let K=n(C,Q,"bin");if(await X(K)){let J=await l(K);for(let Z of J){let G=Z.replace(/\.(exe|ps1|cmd)$/i,"");if(G)b.add(G)}}}}for(let q of b)if($){await Bun.write(n(E,`${q}.cmd`),n6(q));let Q=n(E,`${q}.ps1`);if(await X(Q))await t6(Q)}else{let Q=n(E,q);await Bun.write(Q,i6(q)),await B1(Q,493)}console.log(Y.green(`\u2713 Regenerated ${b.size} shims in ${E}`))}import{rename as $4,rm as R1}from"fs/promises";var r={NPM:"https://registry.npmjs.org",NPM_MIRROR:"https://registry.npmmirror.com"};class F${timeoutMs;constructor($=3000){this.timeoutMs=$}async getFastestRegistry(){let $=async(b)=>{let q=Date.now();try{let Q=new AbortController,K=setTimeout(()=>Q.abort(),this.timeoutMs),J=await fetch(b,{method:"HEAD",signal:Q.signal});if(clearTimeout(K),!J.ok)throw Error(`Status ${J.status}`);return b}catch(Q){throw Q}};try{return await Promise.any([$(r.NPM).then(()=>r.NPM),$(r.NPM_MIRROR).then(()=>r.NPM_MIRROR)])}catch(b){return r.NPM}}}import{existsSync as M1,readFileSync as D1,writeFileSync as o6}from"fs";import{homedir as a6}from"os";import{join as s6}from"path";class G${configPath;constructor($){this.configPath=$||s6(a6(),".bunfig.toml")}getPath(){return this.configPath}getRegistry(){if(!M1(this.configPath))return null;let $=D1(this.configPath,"utf-8"),b=$.indexOf("[install]");if(b===-1)return null;let q=$.indexOf("[",b+1),K=$.substring(b,q===-1?void 0:q).match(/registry\s*=\s*\"(.*?)\"/);return K?K[1]:null}setRegistry($){let b="";if(M1(this.configPath))b=D1(this.configPath,"utf-8");let q="[install]",Q=b.indexOf(q);if(Q===-1){let K=b.length>0&&!b.endsWith(`
|
|
310
|
+
`)?`
|
|
311
|
+
`:"";b+=`${K}${q}
|
|
312
|
+
registry = "${$}"
|
|
313
|
+
`}else{let K=b.indexOf("[",Q+1),J=K===-1?b.length:K,Z=b.substring(0,Q),G=b.substring(Q,J),W=b.substring(J);if(G.match(/registry\s*=/)){let L=G.replace(/registry\s*=\s*".*?"/,`registry = "${$}"`);b=Z+L+W}else{let L=G.replace(q,`${q}
|
|
314
|
+
registry = "${$}"`);b=Z+L+W}}o6(this.configPath,b,"utf-8")}}async function n$($,b){try{await $4($,b)}catch(q){await Bun.write(Bun.file(b),Bun.file($)),await R1($,{force:!0})}}async function T1($,b,q,Q){let K=await fetch($);if(!K.ok)throw Error(`Status ${K.status}`);let J=+(K.headers.get("Content-Length")||0),Z=0,G=K.body?.getReader();if(!G)throw Error("No response body");let W=Bun.file(b).writer(),L=k==="win32";q.stop();let O=null,y=-1;if(!L)O=new P$(J||41943040),O.start();else console.log(`Downloading Bun ${Q}...`);try{let A=Date.now();while(!0){let{done:c,value:S}=await G.read();if(c)break;if(W.write(S),Z+=S.length,!L&&O){let P=(Date.now()-A)/1000,u=P>0?(Z/1024/P).toFixed(0):"0";O.update(Z,{speed:u})}else if(L&&J){let P=Math.floor(Z/J*10);if(P>y)console.log(` > ${P*10}%`),y=P}}if(await W.end(),!L&&O)O.stop();else console.log(" > 100% [Done]")}catch(A){try{W.end()}catch(c){}if(!L&&O)O.stop();else console.log(" > Download Failed");throw q.start(),A}q.start()}async function o$($,b={}){let q=$,Q=null,K=!1;if(!q)q=await M$()||void 0;if(!q){console.error(Y.red("No version specified and no .bvmrc found. Usage: bvm install <version>"));return}try{await U(`Finding Bun ${q} release...`,async(J)=>{let Z=null,G=H(q);if(/^v?\d+\.\d+\.\d+$/.test(q)&&!q.includes("canary"))if(J.update(`Checking if Bun ${G} exists...`),await w1(G))Z=G;else throw J.fail(Y.red(`Bun version ${G} not found on registry.`)),Error(`Bun version ${G} not found on registry.`);else if(q==="latest"){J.update("Checking latest version...");let P=await O1();if(P.latest)Z=H(P.latest);else throw Error('Could not resolve "latest" version.')}else throw J.fail(Y.yellow('Fuzzy matching (e.g. "1.1") is disabled for stability.')),console.log(Y.dim(' Please specify the exact version (e.g. "1.1.20") or "latest".')),console.log(Y.dim(" To see available versions, run: bvm ls-remote")),Error("Fuzzy matching disabled");if(!Z)throw J.fail(Y.red(`Could not find a Bun release for '${q}' compatible with your system.`)),Error(`Could not find a Bun release for '${q}' compatible with your system.`);let W=await k1(Z);if(!W)throw Error(`Could not find a Bun release for ${Z} compatible with your system.`);let{url:L,mirrorUrl:O,foundVersion:y}=W,A=i(C,y),c=i(A,"bin"),S=i(c,R);if(await X(S))J.succeed(Y.green(`Bun ${y} is already installed.`)),Q=y,K=!0;else if(H(Bun.version)===y&&!M){J.info(Y.cyan(`Requested version ${y} matches current BVM runtime. Creating symlink...`)),await T(c);let u=process.execPath;try{let{symlink:e}=await import("fs/promises");await e(u,S)}catch(e){await Bun.write(Bun.file(S),Bun.file(u)),await i$(S,493)}J.succeed(Y.green(`Bun ${y} linked from local runtime.`)),Q=y,K=!0}else if(M)await T(c),await b4(S,y),Q=y,K=!0;else{J.update(`Downloading Bun ${y} to cache...`),await T(_);let u=i(_,`${y}-${r6(L)}`);if(await X(u))J.succeed(Y.green(`Using cached Bun ${y} archive.`));else{let I=`${u}.${Date.now()}.tmp`;try{await T1(L,I,J,y),await n$(I,u)}catch(b1){try{await R1(I,{force:!0})}catch{}if(J.update("Download failed, trying mirror..."),console.log(Y.dim(`
|
|
315
|
+
Debug: ${b1.message}`)),O){let q6=new URL(O).hostname;J.update(`Downloading from mirror (${q6})...`),await T1(O,I,J,y),await n$(I,u)}else throw b1}}J.update(`Extracting Bun ${y}...`),await T(A),await C1(u,A);let e="",D$=[i(A,R),i(A,"bin",R),i(A,"package","bin",R)],b6=await l(A);for(let I of b6)if(I.startsWith("bun-"))D$.push(i(A,I,R)),D$.push(i(A,I,"bin",R));for(let I of D$)if(await X(I)){e=I;break}if(!e)throw Error(`Could not find bun executable in ${A}`);if(await T(c),e!==S){await n$(e,S);let I=e6(e);if(I!==A&&I!==c)await H$(I)}await i$(S,493),J.succeed(Y.green(`Bun ${y} installed successfully.`)),Q=y,K=!0}},{failMessage:`Failed to install Bun ${q}`})}catch(J){throw Error(`Failed to install Bun: ${J.message}`)}if(K)await z$(!1);if(Q)try{await L$(Q,{silent:!0});let J=i(F,"default");if(!await X(J))await w$("default",Q,{silent:!0})}catch(J){}if(await J$(),Q&&!M)try{let J=new G$;if(!J.getRegistry())await U("Checking network speed for registry optimization...",async(Z)=>{if(await new F$(3000).getFastestRegistry()===r.NPM_MIRROR)J.setRegistry(r.NPM_MIRROR),Z.succeed(Y.green("\u26A1 Auto-configured global bunfig.toml to use npmmirror.com for faster installs."));else Z.stop()},{failMessage:"Registry check failed (harmless)"})}catch(J){}if(Q)console.log(Y.cyan(`
|
|
316
|
+
\u2713 Bun ${Q} installed and active.`)),console.log(Y.dim(" To verify, run: bun --version or bvm ls"))}async function b4($,b){let q=b.replace(/^v/,""),Q=`#!/usr/bin/env bash
|
|
312
317
|
set -euo pipefail
|
|
313
318
|
if [[ $# -gt 0 && "$1" == "--version" ]]; then echo "${q}"; exit 0; fi
|
|
314
319
|
echo "Bun ${q} stub invoked with: $@"
|
|
315
320
|
exit 0
|
|
316
|
-
`;await Bun.write($,Q),await
|
|
317
|
-
Aliases:`));for(let Z of J)try{let G=(await
|
|
318
|
-
System`)),console.log(` OS: ${Y.cyan(
|
|
319
|
-
Directories`)),console.log(` BVM_DIR: ${Y.cyan($.env.BVM_DIR||"")}`),console.log(` BIN_DIR: ${Y.cyan(j)}`),console.log(` SHIMS_DIR: ${Y.cyan(
|
|
321
|
+
`;await Bun.write($,Q),await i$($,493)}N();x();B();async function E1(){await U("Fetching remote Bun versions...",async($)=>{let q=(await z1()).filter((Q)=>p(Q)).filter((Q)=>!Q.includes("canary")).sort(Z$);if(q.length===0)throw Error("No remote Bun versions found.");$.succeed(Y.green("Available remote Bun versions:")),q.forEach((Q)=>{console.log(` ${H(Q)}`)})},{failMessage:"Failed to fetch remote Bun versions"})}N();x();f();B();import{join as q4}from"path";async function I1(){await U("Fetching locally installed Bun versions...",async($)=>{let b=await V(),Q=(await t()).version;if($.succeed(Y.green("Locally installed Bun versions:")),b.length===0)console.log(" (No versions installed yet)");else b.forEach((J)=>{if(J===Q)console.log(`* ${Y.green(J)} ${Y.dim("(current)")}`);else console.log(` ${J}`)});if(await X(F)){let J=await l(F);if(J.length>0){console.log(Y.green(`
|
|
322
|
+
Aliases:`));for(let Z of J)try{let G=(await D(q4(F,Z))).trim(),W=H(G),L=`-> ${Y.cyan(W)}`;if(W===Q)L+=` ${Y.dim("(current)")}`;console.log(` ${Z} ${Y.gray(L)}`)}catch(G){}}}},{failMessage:"Failed to list local Bun versions"})}N();x();B();async function v1(){await U("Checking current Bun version...",async($)=>{let{version:b,source:q}=await t();if(b)$.stop(),console.log(`${Y.green("\u2713")} Current Bun version: ${Y.green(b)} ${Y.dim(`(${q})`)}`);else $.info(Y.blue("No Bun version is currently active.")),console.log(Y.yellow("Use 'bvm install <version>' to set a default, or create a .bvmrc file."))},{failMessage:"Failed to determine current Bun version"})}N();f();x();B();import{join as a$,basename as Q4}from"path";import{unlink as J4}from"fs/promises";async function _1($){await U(`Attempting to uninstall Bun ${$}...`,async(b)=>{let q=H($),Q=a$(C,q),K=a$(Q,"bin",R);if(!await X(K))throw Error(`Bun ${$} is not installed.`);let J=!1;try{let Z=a$(F,"default");if(await X(Z)){let G=(await D(Z)).trim();if(H(G)===q)J=!0}}catch(Z){}if(J)throw console.log(Y.yellow("Hint: Set a new default using 'bvm default <new_version>'")),Error(`Bun ${$} is currently set as default. Please set another default before uninstalling.`);try{let Z=await y1(K$);if(Z){if(H(Q4(Z))===q)await J4(K$)}}catch(Z){}await H$(Q),b.succeed(Y.green(`Bun ${q} uninstalled successfully.`)),await J$()},{failMessage:`Failed to uninstall Bun ${$}`})}N();f();x();B();import{join as K4}from"path";import{unlink as Y4}from"fs/promises";async function S1($){await U(`Removing alias '${$}'...`,async(b)=>{let q=K4(F,$);if(!await X(q))throw Error(`Alias '${$}' does not exist.`);await Y4(q),b.succeed(Y.green(`Alias '${$}' removed successfully.`))},{failMessage:`Failed to remove alias '${$}'`})}N();f();x();Q$();B();import{join as s$}from"path";async function P1($,b){await U(`Preparing to run with Bun ${$}...`,async(q)=>{let Q=await h($);if(!Q)Q=H($);let K=s$(C,Q),J=s$(K,"bin"),Z=s$(J,R);if(!await X(Z)){q.fail(Y.red(`Bun ${$} (resolved: ${Q}) is not installed.`)),console.log(Y.yellow(`You can install it using: bvm install ${$}`));return}q.stop();try{await m([Z,...b],{cwd:process.cwd(),prependPath:J}),process.exit(0)}catch(G){console.error(G.message),process.exit(1)}},{failMessage:`Failed to run command with Bun ${$}`})}N();f();x();Q$();B();import{join as r$}from"path";async function u1($,b,q){await U(`Preparing environment for Bun ${$} to execute '${b}'...`,async(Q)=>{let K=await h($);if(!K)K=H($);let J=r$(C,K),Z=r$(J,"bin"),G=r$(Z,R);if(!await X(G)){Q.fail(Y.red(`Bun ${$} (resolved: ${K}) is not installed.`)),console.log(Y.yellow(`You can install it using: bvm install ${$}`));return}Q.stop();try{await m([b,...q],{cwd:process.cwd(),prependPath:Z}),process.exit(0)}catch(W){console.error(W.message),process.exit(1)}},{failMessage:`Failed to execute command with Bun ${$}'s environment`})}f();x();B();import{join as Z4}from"path";async function g1($){await U("Resolving path...",async()=>{let b=null,q="bun",{version:Q}=await t();if(!$||$==="current"){if(b=Q,!b)throw Error("No active Bun version found.")}else{let{resolveLocalVersion:J}=await Promise.resolve().then(() => (Q$(),N1));if(b=await J($),!b)if(Q)b=Q,q=$;else throw Error(`Bun version or command '${$}' not found.`)}let K=Z4(C,b,"bin",q==="bun"?R:q);if(await X(K))console.log(K);else throw Error(`Command '${q}' not found in Bun ${b}.`)},{failMessage:"Failed to resolve path"})}N();x();B();Q$();async function V1($){await U(`Resolving session version for Bun ${$}...`,async(b)=>{let q=null,Q=await h($);if(Q)q=Q;else{let J=(await V()).map((Z)=>H(Z));q=b$($,J)}if(!q)throw Error(`Bun version '${$}' is not installed or cannot be resolved.`);let K=H(q);b.succeed(Y.green(`Bun ${K} will be active in this session.`)),console.log(`export BVM_ACTIVE_VERSION=${K}`),console.log(Y.dim("Run `eval $(bvm shell <version>)` or `export BVM_ACTIVE_VERSION=...` to activate."))},{failMessage:`Failed to set session version for Bun ${$}`})}N();f();x();B();import{join as G4}from"path";async function d1($){let b=G4(F,"default");if(!$)await U("Checking current default Bun version...",async(q)=>{if(await X(b)){let Q=await D(b);q.succeed(Y.green(`Default Bun version: ${H(Q.trim())}`))}else q.info(Y.blue("No global default Bun version is set.")),console.log(Y.yellow("Use 'bvm default <version>' to set one."))},{failMessage:"Failed to retrieve default Bun version"});else await U(`Setting global default to Bun ${$}...`,async(q)=>{let Q=(await V()).map((J)=>H(J)),K=b$($,Q);if(!K)throw Error(`Bun version '${$}' is not installed.`);await w$("default",K,{silent:!0}),q.succeed(Y.green(`\u2713 Default set to ${K}. New terminals will now start with this version.`))},{failMessage:`Failed to set global default to Bun ${$}`})}f();x();N();B();import{unlink as X4}from"fs/promises";import{join as W4}from"path";async function m1(){await U("Deactivating current Bun version...",async($)=>{let b=W4(F,"default");if(await X(b))await X4(b),$.succeed(Y.green("Default Bun version deactivated.")),console.log(Y.gray("Run `bvm use <version>` to reactivate.")),await J$();else $.info("No default Bun version is currently active.")},{failMessage:"Failed to deactivate"})}Q$();f();x();N();B();async function h1($){if($==="dir"){console.log(_);return}if($==="clear"){await U("Clearing cache...",async(b)=>{await H$(_),await T(_),b.succeed(Y.green("Cache cleared."))},{failMessage:"Failed to clear cache"});return}console.error(Y.red(`Unknown cache command: ${$}`)),console.log("Usage: bvm cache dir | bvm cache clear")}N();f();B();x();import{join as v}from"path";import{tmpdir as U4}from"os";import{rm as c1,mkdir as p1}from"fs/promises";var __dirname="/home/runner/work/bvm/bvm/src/commands",e$=W$.version;async function l1(){let $=process.env.BVM_INSTALL_SOURCE;if($==="npm"||$==="bun"||__dirname.includes("node_modules")){await U(`Upgrading BVM via ${$||"package manager"}...`,async(q)=>{let Q=await q$(),K=$==="bun"?"bun":"npm";q.text=`Upgrading BVM via ${K} using ${Q}...`;try{await m([K,"install","-g","bvm-core","--registry",Q]),q.succeed(Y.green(`BVM upgraded via ${K} successfully.`))}catch(J){throw Error(`${K} upgrade failed: ${J.message}`)}});return}try{await U("Checking for BVM updates...",async(q)=>{let Q=M?{version:process.env.BVM_TEST_LATEST_VERSION?.replace("v","")||e$,tarball:"https://example.com/bvm-test.tgz",shasum:"mock",integrity:"mock"}:await B$();if(!Q)throw Error("Unable to determine the latest BVM version from NPM Registry.");let K=Q.version;if(!p(K))throw Error(`Unrecognized version received: ${K}`);if(!A$(K,e$)){q.succeed(Y.green(`BVM is already up to date (v${e$}).`)),console.log(Y.blue("You are using the latest version."));return}if(q.text=`Updating BVM to v${K}...`,M&&!process.env.BVM_TEST_REAL_UPGRADE){q.succeed(Y.green("BVM updated successfully (test mode)."));return}q.update("Downloading update package...");let J=v(U4(),`bvm-upgrade-${Date.now()}`);await p1(J,{recursive:!0});let Z=v(J,"bvm-core.tgz");if(M){await d(Z,"mock-tarball");let W=v(J,"package","dist");await p1(W,{recursive:!0}),await d(v(W,"index.js"),"// new cli"),await d(v(W,"bvm-shim.sh"),"# new shim"),await d(v(W,"bvm-shim.js"),"// new shim")}else{let W=await s(Q.tarball,{timeout:30000});if(!W.ok)throw Error(`Failed to download tarball: ${W.statusText}`);let L=await W.arrayBuffer();await C$(Z,new Uint8Array(L)),q.update("Extracting update...");try{await m(["tar","-xzf",Z,"-C",J])}catch(O){throw Error('Failed to extract update package. Ensure "tar" is available.')}}q.update("Applying updates...");let G=v(J,"package","dist");if(await X(v(G,"index.js")))await C$(v(z,"src","index.js"),await D(v(G,"index.js")));if(k!=="win32"&&await X(v(G,"bvm-shim.sh")))await C$(v(z,"bin","bvm-shim.sh"),await D(v(G,"bvm-shim.sh")));if(k==="win32"&&await X(v(G,"bvm-shim.js")))await C$(v(z,"bin","bvm-shim.js"),await D(v(G,"bvm-shim.js")));try{await c1(J,{recursive:!0,force:!0})}catch(W){}try{await c1(I$,{force:!0})}catch(W){}q.update("Finalizing environment..."),await z$(!1),q.succeed(Y.green(`BVM updated to v${K} successfully.`)),console.log(Y.yellow("Please restart your terminal to apply changes."))},{failMessage:"Failed to upgrade BVM"})}catch(q){throw Error(`Failed to upgrade BVM: ${q.message}`)}}N();f();x();B();import{homedir as y4}from"os";import{join as H4}from"path";async function t1(){await U("Gathering BVM diagnostics...",async()=>{let $=new G$,b={currentVersion:(await t()).version,installedVersions:await V(),aliases:await L4(),env:{BVM_DIR:z,BVM_BIN_DIR:j,BVM_SHIMS_DIR:E,BVM_VERSIONS_DIR:C,BVM_TEST_MODE:process.env.BVM_TEST_MODE,HOME:process.env.HOME||y4()},bunfig:{path:$.getPath(),registry:$.getRegistry()}};z4(b)})}async function L4(){if(!await X(F))return[];let $=await l(F),b=[];for(let q of $){let Q=H4(F,q);if(await X(Q)){let K=await Bun.file(Q).text();b.push({name:q,target:H(K.trim())})}}return b}function z4($){if(console.log(Y.bold(`
|
|
323
|
+
System`)),console.log(` OS: ${Y.cyan(k)}`),console.log(` Arch: ${Y.cyan($$)} ${process.arch!==$$?Y.yellow(`(Process: ${process.arch})`):""}`),console.log(` AVX2: ${f$?Y.green("Supported"):Y.yellow("Not Supported (Baseline fallback enabled)")}`),console.log(Y.bold(`
|
|
324
|
+
Directories`)),console.log(` BVM_DIR: ${Y.cyan($.env.BVM_DIR||"")}`),console.log(` BIN_DIR: ${Y.cyan(j)}`),console.log(` SHIMS_DIR: ${Y.cyan(E)}`),console.log(` VERSIONS_DIR: ${Y.cyan(C)}`),console.log(Y.bold(`
|
|
320
325
|
Environment`)),console.log(` HOME: ${$.env.HOME||"n/a"}`),console.log(` BVM_TEST_MODE: ${$.env.BVM_TEST_MODE||"false"}`),console.log(Y.bold(`
|
|
321
326
|
Installed Versions`)),$.installedVersions.length===0)console.log(" (none installed)");else $.installedVersions.forEach((b)=>{let q=b===$.currentVersion,Q=q?Y.green("*"):" ",K=q?Y.green(b):b,J=q?Y.green(" (current)"):"";console.log(` ${Q} ${K}${J}`)});if(console.log(Y.bold(`
|
|
327
|
+
Configuration`)),console.log(` Bunfig: ${Y.cyan($.bunfig.path)}`),console.log(` Registry: ${$.bunfig.registry?Y.green($.bunfig.registry):Y.dim("default")}`),console.log(Y.bold(`
|
|
322
328
|
Aliases`)),$.aliases.length===0)console.log(" (no aliases configured)");else $.aliases.forEach((b)=>{console.log(` ${b.name} ${Y.gray("->")} ${Y.cyan(b.target)}`)});console.log(`
|
|
323
|
-
`+Y.green("Diagnostics complete."))}
|
|
329
|
+
`+Y.green("Diagnostics complete."))}N();B();async function n1($){let[b,q,Q]=$,K=new G$;if(b==="ls"||!b){console.log(Y.bold(`
|
|
330
|
+
BVM Configuration (via ~/.bunfig.toml)`)),console.log(`Path: ${Y.dim(K.getPath())}`);let J=K.getRegistry();console.log(`Registry: ${J?Y.green(J):Y.yellow("(not set, using Bun default)")}`);return}if(b==="registry"){if(q==="auto")await U("Racing registries for optimal speed...",async(J)=>{let G=await new F$().getFastestRegistry();K.setRegistry(G),J.succeed(Y.green(`\u2713 Set registry to ${G}`))});else if(q)K.setRegistry(q),console.log(Y.green(`\u2713 Registry set to ${q}`));else{let J=K.getRegistry();console.log(`Current registry: ${J||"default"}`)}return}console.log(Y.red(`Unknown config command: ${b}`)),console.log("Usage:"),console.log(" bvm config ls"),console.log(" bvm config registry <url|auto>")}var $1=["install","uninstall","use","ls","ls-remote","current","alias","unalias","run","exec","which","cache","setup","upgrade","doctor","completion","deactivate","help"],i1={bash:`#!/usr/bin/env bash
|
|
324
331
|
_bvm_completions() {
|
|
325
|
-
COMPREPLY=( $(compgen -W "${
|
|
332
|
+
COMPREPLY=( $(compgen -W "${$1.join(" ")}" -- "\${COMP_WORDS[COMP_CWORD]}") )
|
|
326
333
|
}
|
|
327
334
|
complete -F _bvm_completions bvm
|
|
328
335
|
`,zsh:`#compdef bvm
|
|
329
336
|
_bvm() {
|
|
330
337
|
local -a commands
|
|
331
|
-
commands=( ${
|
|
338
|
+
commands=( ${$1.join(" ")} )
|
|
332
339
|
_describe 'command' commands
|
|
333
340
|
}
|
|
334
341
|
compdef _bvm bvm
|
|
335
|
-
`,fish:`complete -c bvm -f -a "${
|
|
336
|
-
`};function
|
|
342
|
+
`,fish:`complete -c bvm -f -a "${$1.join(" ")}"
|
|
343
|
+
`};function o1($){let b=i1[$];if(!b)throw Error(`Unsupported shell '${$}'. Supported shells: ${Object.keys(i1).join(", ")}`);console.log(b)}N();f();x();import{join as a1}from"path";N();var s1="update-check.json",w4=86400000;async function r1(){if(process.env.CI||M)return;let $=a1(_,s1);try{if(await X($)){let b=await D($),q=JSON.parse(b);if(Date.now()-q.lastCheck<w4)return}}catch(b){}try{let b=await B$();if(b){let q=b.tagName.startsWith("v")?b.tagName.slice(1):b.tagName;await T(_),await d($,JSON.stringify({lastCheck:Date.now(),latestVersion:q}))}}catch(b){}}async function e1(){if(process.env.CI||M)return null;let $=W$.version,b=a1(_,s1);try{if(await X(b)){let q=await D(b),Q=JSON.parse(q);if(Q.latestVersion&&A$(Q.latestVersion,$))return`
|
|
337
344
|
${Y.gray("Update available:")} ${Y.green(`v${Q.latestVersion}`)} ${Y.dim(`(current: v${$})`)}
|
|
338
|
-
${Y.gray("Run")} ${Y.cyan("bvm upgrade")} ${Y.gray("to update.")}`}}catch(q){}return null}class
|
|
345
|
+
${Y.gray("Run")} ${Y.cyan("bvm upgrade")} ${Y.gray("to update.")}`}}catch(q){}return null}class $6{commands={};helpEntries=[];name;versionStr;constructor($){this.name=$,this.versionStr=W$.version}command($,b,q={}){let Q=$.split(" ")[0],K={description:b,usage:`${this.name} ${$}`,action:async()=>{},aliases:q.aliases};if(this.commands[Q]=K,this.helpEntries.push(` ${$.padEnd(35)} ${b}`),q.aliases)q.aliases.forEach((Z)=>{this.commands[Z]=K});let J={action:(Z)=>{return K.action=Z,J},option:(Z,G)=>J};return J}async run(){try{r1().catch(()=>{})}catch(Z){}let{values:$,positionals:b}=O4({args:Bun.argv.slice(2),strict:!1,allowPositionals:!0,options:{help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"},silent:{type:"boolean",short:"s"}}}),q=b[0],Q=!!($.silent||$.s),K=!!($.version||$.v||$.help||$.h);if(!q){if($.version||$.v)console.log(this.versionStr),process.exit(0);if($.help||$.h)this.showHelp(),process.exit(0);this.showHelp(),process.exit(1)}if($.help||$.h)this.showHelp(),process.exit(0);let J=this.commands[q];if(!J)console.error(Y.yellow(`Unknown command '${q}'`)),this.showHelp(),process.exit(0);try{if(await J.action(b.slice(1),$),!K&&!Q&&["ls","current","doctor","default"].includes(q)){let Z=await e1();if(Z)console.log(Z)}}catch(Z){if(!Z.reported)console.error(Y.red(`\u2716 ${Z.message}`));process.exit(1)}}showHelp(){console.log(`Bun Version Manager (bvm) v${this.versionStr}`),console.log(`Built with Bun \xB7 Runs with Bun \xB7 Tested on Bun
|
|
339
346
|
`),console.log("Usage:"),console.log(` ${this.name} <command> [flags]
|
|
340
347
|
`),console.log("Commands:"),console.log(this.helpEntries.join(`
|
|
341
348
|
`)),console.log(`
|
|
342
349
|
Global Flags:`),console.log(" --help, -h Show this help message"),console.log(" --version, -v Show version number"),console.log(`
|
|
343
|
-
Examples:`),console.log(" bvm install 1.0.0"),console.log(" bvm use 1.0.0"),console.log(" bvm run 1.0.0 index.ts")}}async function
|
|
350
|
+
Examples:`),console.log(" bvm install 1.0.0"),console.log(" bvm use 1.0.0"),console.log(" bvm run 1.0.0 index.ts")}}async function k4(){let $=new $6("bvm");$.command("rehash","Regenerate shims for all installed binaries").action(async()=>{await J$()}),$.command("install [version]","Install a Bun version and set as current").option("--global, -g","Install as a global tool (not just default)").action(async(b,q)=>{await o$(b[0],{global:q.global||q.g})}),$.command("i [version]","Alias for install").action(async(b,q)=>{await o$(b[0],{global:q.global||q.g})}),$.command("ls","List installed Bun versions",{aliases:["list"]}).action(async()=>{await I1()}),$.command("ls-remote","List all available remote Bun versions").action(async()=>{await E1()}),$.command("use <version>","Switch the active Bun version immediately (all terminals)").action(async(b)=>{if(!b[0])throw Error("Version is required");await L$(b[0])}),$.command("shell <version>","Switch Bun version for the current shell session").action(async(b)=>{if(!b[0])throw Error("Version is required");await V1(b[0])}),$.command("default [version]","Display or set the global default Bun version").action(async(b)=>{await d1(b[0])}),$.command("current","Display the currently active Bun version").action(async()=>{await v1()}),$.command("uninstall <version>","Uninstall a Bun version").action(async(b)=>{if(!b[0])throw Error("Version is required");await _1(b[0])}),$.command("alias <name> <version>","Create an alias for a Bun version").action(async(b)=>{if(!b[0]||!b[1])throw Error("Name and version are required");await w$(b[0],b[1])}),$.command("unalias <name>","Remove an existing alias").action(async(b)=>{if(!b[0])throw Error("Alias name is required");await S1(b[0])}),$.command("run <version> [...args]","Run a command with a specific Bun version").action(async(b)=>{let q=b[0];if(!q)throw Error("Version is required");let Q=process.argv.indexOf("run"),K=Q!==-1?process.argv.slice(Q+2):[];await P1(q,K)}),$.command("exec <version> <cmd> [...args]","Execute a command with a specific Bun version's environment").action(async(b)=>{let q=b[0],Q=b[1];if(!q||!Q)throw Error("Version and command are required");let K=process.argv.indexOf("exec"),J=K!==-1?process.argv.slice(K+3):[];await u1(q,Q,J)}),$.command("which [version]","Display path to installed bun version").action(async(b)=>{await g1(b[0])}),$.command("deactivate","Undo effects of bvm on current shell").action(async()=>{await m1()}),$.command("version <spec>","Resolve the given description to a single local version").action(async(b)=>{if(!b[0])throw Error("Version specifier is required");await g$(b[0])}),$.command("cache <action>","Manage bvm cache").action(async(b)=>{if(!b[0])throw Error("Action is required");await h1(b[0])}),$.command("setup","Configure shell environment automatically").option("--silent, -s","Suppress output").action(async(b,q)=>{await z$(!(q.silent||q.s))}),$.command("upgrade","Upgrade bvm to the latest version",{aliases:["self-update"]}).action(async()=>{await l1()}),$.command("config <subcommand>","Manage BVM configuration (registry)").action(async(b)=>{await n1(b)}),$.command("doctor","Show diagnostics for Bun/BVM setup").action(async()=>{await t1()}),$.command("completion <shell>","Generate shell completion script (bash|zsh|fish)").action(async(b)=>{if(!b[0])throw Error("Shell name is required");o1(b[0])}),await $.run(),process.exit(0)}k4().catch(($)=>{console.error(Y.red(`
|
|
344
351
|
[FATAL ERROR] Unexpected Crash:`)),console.error($),process.exit(1)});
|
package/install.ps1
CHANGED
|
@@ -39,7 +39,7 @@ function Detect-NetworkZone {
|
|
|
39
39
|
$BVM_REGION = Detect-NetworkZone
|
|
40
40
|
$REGISTRY = if ($BVM_REGION -eq "cn") { "registry.npmmirror.com" } else { "registry.npmjs.org" }
|
|
41
41
|
|
|
42
|
-
$DEFAULT_BVM_VER = "v1.1.
|
|
42
|
+
$DEFAULT_BVM_VER = "v1.1.35"
|
|
43
43
|
$BVM_VER = if ($env:BVM_INSTALL_VERSION) { $env:BVM_INSTALL_VERSION } else { "" }
|
|
44
44
|
if (-not $BVM_VER) {
|
|
45
45
|
try {
|
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.35",
|
|
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": {
|
|
@@ -77,10 +77,10 @@
|
|
|
77
77
|
"typescript": "^5"
|
|
78
78
|
},
|
|
79
79
|
"bvm_fingerprints": {
|
|
80
|
-
"cli": "
|
|
80
|
+
"cli": "b9cc047cc5f8b0f79becbedce8ea9ef8",
|
|
81
81
|
"shim_win": "413506e6934869b9cbe832ba9cefaf2b",
|
|
82
82
|
"shim_unix": "8aa89a0324b52c9c81b96c0c03afe36c",
|
|
83
|
-
"install_sh": "
|
|
84
|
-
"install_ps1": "
|
|
83
|
+
"install_sh": "e27f903105154a8b5513fdb8146de134",
|
|
84
|
+
"install_ps1": "951a53850905e567b4a1dd3f6ea025e3"
|
|
85
85
|
}
|
|
86
86
|
}
|