@0xobelisk/sui-cli 1.2.0-pre.122 → 1.2.0-pre.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dubhe.js CHANGED
@@ -129,7 +129,7 @@ Watch stopped.`),h()})}},Gt=Bo;import Jt from"wait-on";import ve from"ora";impor
129
129
  - Sui localnode on port 9000
130
130
  - Sui faucet on port 9123
131
131
  - PostgreSQL database on port 5432
132
- - Dubhe GraphQL server on port 4000`):t["local-database"]?(s="Timeout waiting for local database",r="Please make sure PostgreSQL is running on port 5432"):t["local-node"]?(s="Timeout waiting for local Sui node",r="Please make sure Sui localnode is running on port 9123"):t["local-indexer"]&&(s="Timeout waiting for local indexer",r="Please make sure indexer is running and health endpoint is available at http://127.0.0.1:8080/health"),o.fail(le.red(s)),console.error(le.yellow(r)),h(1)}}},Zt=Xo;var Qo={command:"switch-env",describe:"Switch environment",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],default:"localnet",desc:"Switch to node network (mainnet/testnet/devnet/localnet)"},"rpc-url":{type:"string",desc:"Custom RPC endpoint URL (overrides the default for the selected network)"}})},async handler(e){await Y(e.network,e["rpc-url"]),h()}},en=Qo;import Zo from"dotenv";import ce from"chalk";Zo.config();var es={command:"info",describe:"Get information about the current Sui node",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet","default"],default:"default",desc:"Node network (mainnet/testnet/devnet/localnet)"},"rpc-url":{type:"string",desc:"Custom RPC endpoint URL (overrides the default for the selected network)"}})},handler:async({network:e,"rpc-url":t})=>{try{e=="default"&&(e=await M(),console.log(ce.yellow(`Use default network: [${e}]`)));let o=z({network:e,fullnodeUrls:t?[t]:void 0}),s=o.getSigner();console.log(ce.blue("Account Information:")),console.log(` Network: ${ce.green(e)}`),console.log(` Address: ${ce.green(s.toSuiAddress())}`);try{let r=await o.getBalance("0x2::sui::SUI"),i=(Number(r.totalBalance)/10**9).toFixed(4);console.log(` Balance: ${ce.green(i)} SUI`)}catch{console.log(` Balance: ${ce.red("Failed to fetch balance")} ${ce.gray("(Network error)")}`)}h()}catch(n){B(n),h(1)}}},tn=es;import{loadConfig as ts}from"@0xobelisk/sui-common";async function nn(e,t,n,o){if(n)await Se(e.name,t,n,o);else{let s=`${process.cwd()}/src/${e.name}`,r=await _e(s,t);await Se(e.name,t,r,o)}}import ns from"chalk";var os={command:"load-metadata",describe:"Load metadata for a package",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet","default"],default:"default",desc:"Node network (mainnet/testnet/devnet/localnet)"},"config-path":{type:"string",desc:"Configuration file path",default:"dubhe.config.ts"},"package-id":{type:"string",desc:"Package ID to load metadata for",optional:!0},"rpc-url":{type:"string",desc:"Custom RPC endpoint URL (overrides the default for the selected network)"}})},async handler({network:e,"config-path":t,"package-id":n,"rpc-url":o}){try{e=="default"&&(e=await M(),console.log(ns.yellow(`Use default network: [${e}]`)));let s=await ts(t);await nn(s,e,n,o?[o]:void 0)}catch(s){B(s),h(1)}h()}},on=os;import l from"chalk";import{spawn as as}from"child_process";import ln from"cli-table3";import We from"inquirer";import*as I from"fs";import*as O from"path";import*as ue from"os";import*as dn from"net";import ls from"axios";var de={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.122",description:"Tookit for interacting with move eps framework",keywords:["sui","obelisk labs","move","blockchain"],homepage:"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme",bugs:"https://github.com/0xobelisk/dubhe/issues",repository:{type:"git",url:"https://github.com/0xobelisk/dubhe.git"},license:"Apache-2.0",author:"team@obelisk.build",type:"module",exports:{".":"./dist/index.js"},types:"src/index.ts",bin:{dubhe:"./dist/dubhe.js"},scripts:{build:"pnpm run type-check && pnpm run build:js","build:js":"tsup && chmod +x ./dist/dubhe.js",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch",format:"prettier --write .","format:check":"prettier --check .",lint:"eslint . --ext .ts",test:"vitest run","test:all":"pnpm test && pnpm test:integration","test:coverage":"vitest run --coverage","test:integration":"vitest run --config vitest.integration.config.ts","test:localnet":"vitest run --config vitest.integration.config.ts tests/integration/localnet.test.ts","test:testnet":"vitest run --config vitest.integration.config.ts tests/integration/testnet.test.ts","test:watch":"vitest","type-check":"tsc --noEmit",validate:"pnpm format:check && pnpm type-check"},dependencies:{"@0xobelisk/sui-client":"workspace:*","@0xobelisk/sui-common":"workspace:*","@mysten/sui":"1.35.0","@types/wait-on":"^5.3.4",axios:"^1.12.0",chalk:"^5.0.1",child_process:"^1.0.2",chokidar:"^3.5.3","cli-progress":"^3.12.0","cli-table3":"^0.6.5",dotenv:"^16.0.3",ejs:"^3.1.8",execa:"^7.0.0",glob:"^8.0.3","http-proxy-agent":"^7.0.2","https-proxy-agent":"^7.0.6",inquirer:"^9.2.15",ora:"^5.4.1",path:"^0.12.7",typescript:"^5.8.3","wait-on":"^7.0.1",yargs:"^17.7.1",zod:"^3.22.3","zod-validation-error":"^1.3.0"},devDependencies:{"@types/cli-progress":"^3.11.5","@types/ejs":"^3.1.1","@types/glob":"^7.2.0","@types/inquirer":"^9.0.7","@types/node":"^22.16.0","@types/yargs":"^17.0.10",eslint:"^9.0.0","eslint-config-prettier":"^9.1.0",prettier:"3.3.3","ts-node":"^10.9.1",tsup:"^6.7.0",tsx:"^3.12.6",vitest:"0.31.4"},engines:{node:">=22.0.0"},publishConfig:{access:"public"}};import Ve from"chalk";import*as sn from"cli-progress";import*as rn from"fs";import rs from"axios";async function an(e,t){try{let n=await rs.get(e,{responseType:"stream",timeout:3e4,headers:{"User-Agent":"dubhe-cli"},maxRedirects:5,validateStatus:o=>o<400});await is(n,t),console.log(Ve.green(" \u2713 Successfully downloaded"))}catch(n){if(n.code==="ENOTFOUND")throw new Error(`DNS resolution failed: ${n.message}. Please check your internet connection.`);if(n.code==="ECONNRESET")throw new Error(`Connection reset: ${n.message}. Please check your network connection.`);if(n.code==="ETIMEDOUT")throw new Error(`Connection timeout: ${n.message}. Please check your network connection.`);if(n.message.includes("protocol mismatch"))throw new Error(`Protocol mismatch: ${n.message}. Please check your network configuration.`);if(n.response)throw new Error(`HTTP ${n.response.status}: ${n.response.statusText}`);{let o=n instanceof Error?n.message:String(n);throw new Error(`Download failed: ${o}`)}}}async function is(e,t){let n=parseInt(e.headers["content-length"]||"0"),o=new sn.SingleBar({format:Ve.cyan("Download Progress")+" |{bar}| {percentage}% | {value}/{total} MB | Speed: {speed} MB/s | ETA: {eta}s",barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0,barsize:30,forceRedraw:!0});n>0?o.start(Math.round(n/1024/1024*100)/100,0,{speed:"0.00"}):console.log(Ve.blue("\u{1F4E5} Downloading... (unable to get file size)"));let s=rn.createWriteStream(t),r=0,i=Date.now();return new Promise((c,a)=>{e.data.on("data",d=>{if(r+=d.length,n>0){let u=Math.round(r/1024/1024*100)/100,g=(Date.now()-i)/1e3,f=g>0?Math.round(u/g*100)/100:0;o.update(u,{speed:f.toFixed(2)})}}),e.data.pipe(s),s.on("finish",()=>{n>0&&o.stop();let d=Math.round(r/1024/1024*100)/100,u=(Date.now()-i)/1e3,g=u>0?Math.round(d/u*100)/100:0;console.log(Ve.green(`\u2713 Download completed! ${d} MB, average speed: ${g} MB/s`)),c()}),s.on("error",d=>{n>0&&o.stop(),a(d)})})}function it(){let e=process.platform,t=process.arch,n,o;switch(e){case"darwin":n="macos";break;case"win32":n="windows";break;case"linux":n="ubuntu";break;default:n=e}switch(t){case"x64":o="x86_64";break;case"arm64":o="aarch64";break;default:o=t}return{platform:e,arch:t,platformForAsset:n,archForAsset:o}}var L={sui:{name:"sui",repo:"MystenLabs/sui",binaryName:"sui",installDir:O.join(ue.homedir(),".dubhe","bin")},"dubhe-indexer":{name:"dubhe-indexer",repo:"0xobelisk/dubhe",binaryName:"dubhe-indexer",installDir:O.join(ue.homedir(),".dubhe","bin")}};async function q(e,t=[]){return new Promise(n=>{let o=as(e,t,{shell:!0}),s="",r="";o.stdout?.on("data",i=>{s+=i.toString()}),o.stderr?.on("data",i=>{r+=i.toString()}),o.on("close",i=>{n({code:i||0,stdout:s,stderr:r})}),o.on("error",()=>{n({code:-1,stdout:s,stderr:r})})})}async function un(e,t={}){try{let n={timeout:3e4,maxRedirects:5,validateStatus:s=>s<500,...t},o=await ls(e,n);return{ok:o.status>=200&&o.status<300,status:o.status,statusText:o.statusText,json:async()=>o.data,headers:o.headers}}catch(n){let o=n.response?.status||0,s=n.response?.statusText||n.message;return n.code==="ENOTFOUND"?s="DNS resolution failed - please check your internet connection":n.code==="ECONNRESET"?s="Connection reset - please check your network connection":n.code==="ETIMEDOUT"?s="Connection timeout - please check your network connection":n.message.includes("protocol mismatch")&&(s="Protocol mismatch - please check your network configuration"),{ok:!1,status:o,statusText:s,json:async()=>n.response?.data||{},headers:n.response?.headers||{}}}}async function at(e,t=10,n=3){let o=`https://api.github.com/repos/${e}/releases?per_page=${t}`;for(let s=1;s<=n;s++)try{s>1&&console.log(l.gray(` Retry ${s}/${n}...`));let r=await un(o,{headers:{"User-Agent":"dubhe-cli",Accept:"application/vnd.github.v3+json"}});if(!r.ok)throw r.status===403?new Error(`GitHub API rate limit: ${r.status}. Please retry later or set GITHUB_TOKEN environment variable`):new Error(`GitHub API request failed: ${r.status} ${r.statusText}`);return await r.json()}catch(r){if(s>1&&console.log(l.yellow(` \u26A0\uFE0F Attempt ${s} failed: ${r instanceof Error?r.message:String(r)}`)),s===n)return console.error(l.red(` \u274C Failed to fetch releases after ${n} attempts`)),[];await new Promise(i=>setTimeout(i,1e3*s))}return[]}function De(e,t){return e.assets.filter(o=>{let s=o.name.toLowerCase(),r=[t.platformForAsset.toLowerCase(),...t.platformForAsset==="macos"?["darwin","apple"]:[],...t.platformForAsset==="windows"?["win","win32","windows"]:[],...t.platformForAsset==="ubuntu"?["linux","gnu"]:[]],i=[t.archForAsset.toLowerCase(),...t.archForAsset==="x86_64"?["amd64","x64"]:[],...t.archForAsset==="aarch64"?["arm64"]:[]],c=r.some(u=>s.includes(u)),a=i.some(u=>s.includes(u)),d=s.endsWith(".tar.gz")||s.endsWith(".zip")||s.endsWith(".tgz")||s.endsWith(".tar.bz2")||s.endsWith(".tar.xz");return c&&a&&d}).map(o=>o.name)}async function cs(e,t){let n=L[e];return n?(await at(n.repo,10)).map(s=>({version:s.tag_name,hasCompatibleAsset:De(s,t).length>0})):[]}async function ds(e){try{let t=Ae();if(!t){console.log(l.gray(`Please add to PATH: export PATH="$PATH:${e}"`));return}let{shellName:n,configFile:o}=t,s=n==="fish"?`set -gx PATH $PATH ${e}`:`export PATH="$PATH:${e}"`;if(I.existsSync(o)&&I.readFileSync(o,"utf8").includes(e)){console.log(l.green(` \u2713 PATH already configured in ${o}`));return}let i=`# Added by dubhe doctor
132
+ - Dubhe GraphQL server on port 4000`):t["local-database"]?(s="Timeout waiting for local database",r="Please make sure PostgreSQL is running on port 5432"):t["local-node"]?(s="Timeout waiting for local Sui node",r="Please make sure Sui localnode is running on port 9123"):t["local-indexer"]&&(s="Timeout waiting for local indexer",r="Please make sure indexer is running and health endpoint is available at http://127.0.0.1:8080/health"),o.fail(le.red(s)),console.error(le.yellow(r)),h(1)}}},Zt=Xo;var Qo={command:"switch-env",describe:"Switch environment",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],default:"localnet",desc:"Switch to node network (mainnet/testnet/devnet/localnet)"},"rpc-url":{type:"string",desc:"Custom RPC endpoint URL (overrides the default for the selected network)"}})},async handler(e){await Y(e.network,e["rpc-url"]),h()}},en=Qo;import Zo from"dotenv";import ce from"chalk";Zo.config();var es={command:"info",describe:"Get information about the current Sui node",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet","default"],default:"default",desc:"Node network (mainnet/testnet/devnet/localnet)"},"rpc-url":{type:"string",desc:"Custom RPC endpoint URL (overrides the default for the selected network)"}})},handler:async({network:e,"rpc-url":t})=>{try{e=="default"&&(e=await M(),console.log(ce.yellow(`Use default network: [${e}]`)));let o=z({network:e,fullnodeUrls:t?[t]:void 0}),s=o.getSigner();console.log(ce.blue("Account Information:")),console.log(` Network: ${ce.green(e)}`),console.log(` Address: ${ce.green(s.toSuiAddress())}`);try{let r=await o.getBalance("0x2::sui::SUI"),i=(Number(r.totalBalance)/10**9).toFixed(4);console.log(` Balance: ${ce.green(i)} SUI`)}catch{console.log(` Balance: ${ce.red("Failed to fetch balance")} ${ce.gray("(Network error)")}`)}h()}catch(n){B(n),h(1)}}},tn=es;import{loadConfig as ts}from"@0xobelisk/sui-common";async function nn(e,t,n,o){if(n)await Se(e.name,t,n,o);else{let s=`${process.cwd()}/src/${e.name}`,r=await _e(s,t);await Se(e.name,t,r,o)}}import ns from"chalk";var os={command:"load-metadata",describe:"Load metadata for a package",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet","default"],default:"default",desc:"Node network (mainnet/testnet/devnet/localnet)"},"config-path":{type:"string",desc:"Configuration file path",default:"dubhe.config.ts"},"package-id":{type:"string",desc:"Package ID to load metadata for",optional:!0},"rpc-url":{type:"string",desc:"Custom RPC endpoint URL (overrides the default for the selected network)"}})},async handler({network:e,"config-path":t,"package-id":n,"rpc-url":o}){try{e=="default"&&(e=await M(),console.log(ns.yellow(`Use default network: [${e}]`)));let s=await ts(t);await nn(s,e,n,o?[o]:void 0)}catch(s){B(s),h(1)}h()}},on=os;import l from"chalk";import{spawn as as}from"child_process";import ln from"cli-table3";import We from"inquirer";import*as I from"fs";import*as O from"path";import*as ue from"os";import*as dn from"net";import ls from"axios";var de={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.123",description:"Tookit for interacting with move eps framework",keywords:["sui","obelisk labs","move","blockchain"],homepage:"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme",bugs:"https://github.com/0xobelisk/dubhe/issues",repository:{type:"git",url:"https://github.com/0xobelisk/dubhe.git"},license:"Apache-2.0",author:"team@obelisk.build",type:"module",exports:{".":"./dist/index.js"},types:"src/index.ts",bin:{dubhe:"./dist/dubhe.js"},scripts:{build:"pnpm run type-check && pnpm run build:js","build:js":"tsup && chmod +x ./dist/dubhe.js",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch",format:"prettier --write .","format:check":"prettier --check .",lint:"eslint . --ext .ts",test:"vitest run","test:all":"pnpm test && pnpm test:integration","test:coverage":"vitest run --coverage","test:integration":"vitest run --config vitest.integration.config.ts","test:localnet":"vitest run --config vitest.integration.config.ts tests/integration/localnet.test.ts","test:testnet":"vitest run --config vitest.integration.config.ts tests/integration/testnet.test.ts","test:watch":"vitest","type-check":"tsc --noEmit",validate:"pnpm format:check && pnpm type-check"},dependencies:{"@0xobelisk/sui-client":"workspace:*","@0xobelisk/sui-common":"workspace:*","@mysten/sui":"1.35.0","@types/wait-on":"^5.3.4",axios:"^1.12.0",chalk:"^5.0.1",child_process:"^1.0.2",chokidar:"^3.5.3","cli-progress":"^3.12.0","cli-table3":"^0.6.5",dotenv:"^16.0.3",ejs:"^3.1.8",execa:"^7.0.0",glob:"^8.0.3","http-proxy-agent":"^7.0.2","https-proxy-agent":"^7.0.6",inquirer:"^9.2.15",ora:"^5.4.1",path:"^0.12.7",typescript:"^5.8.3","wait-on":"^7.0.1",yargs:"^17.7.1",zod:"^3.22.3","zod-validation-error":"^1.3.0"},devDependencies:{"@types/cli-progress":"^3.11.5","@types/ejs":"^3.1.1","@types/glob":"^7.2.0","@types/inquirer":"^9.0.7","@types/node":"^22.16.0","@types/yargs":"^17.0.10",eslint:"^9.0.0","eslint-config-prettier":"^9.1.0",prettier:"3.3.3","ts-node":"^10.9.1",tsup:"^6.7.0",tsx:"^3.12.6",vitest:"0.31.4"},engines:{node:">=22.0.0"},publishConfig:{access:"public"}};import Ve from"chalk";import*as sn from"cli-progress";import*as rn from"fs";import rs from"axios";async function an(e,t){try{let n=await rs.get(e,{responseType:"stream",timeout:3e4,headers:{"User-Agent":"dubhe-cli"},maxRedirects:5,validateStatus:o=>o<400});await is(n,t),console.log(Ve.green(" \u2713 Successfully downloaded"))}catch(n){if(n.code==="ENOTFOUND")throw new Error(`DNS resolution failed: ${n.message}. Please check your internet connection.`);if(n.code==="ECONNRESET")throw new Error(`Connection reset: ${n.message}. Please check your network connection.`);if(n.code==="ETIMEDOUT")throw new Error(`Connection timeout: ${n.message}. Please check your network connection.`);if(n.message.includes("protocol mismatch"))throw new Error(`Protocol mismatch: ${n.message}. Please check your network configuration.`);if(n.response)throw new Error(`HTTP ${n.response.status}: ${n.response.statusText}`);{let o=n instanceof Error?n.message:String(n);throw new Error(`Download failed: ${o}`)}}}async function is(e,t){let n=parseInt(e.headers["content-length"]||"0"),o=new sn.SingleBar({format:Ve.cyan("Download Progress")+" |{bar}| {percentage}% | {value}/{total} MB | Speed: {speed} MB/s | ETA: {eta}s",barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0,barsize:30,forceRedraw:!0});n>0?o.start(Math.round(n/1024/1024*100)/100,0,{speed:"0.00"}):console.log(Ve.blue("\u{1F4E5} Downloading... (unable to get file size)"));let s=rn.createWriteStream(t),r=0,i=Date.now();return new Promise((c,a)=>{e.data.on("data",d=>{if(r+=d.length,n>0){let u=Math.round(r/1024/1024*100)/100,g=(Date.now()-i)/1e3,f=g>0?Math.round(u/g*100)/100:0;o.update(u,{speed:f.toFixed(2)})}}),e.data.pipe(s),s.on("finish",()=>{n>0&&o.stop();let d=Math.round(r/1024/1024*100)/100,u=(Date.now()-i)/1e3,g=u>0?Math.round(d/u*100)/100:0;console.log(Ve.green(`\u2713 Download completed! ${d} MB, average speed: ${g} MB/s`)),c()}),s.on("error",d=>{n>0&&o.stop(),a(d)})})}function it(){let e=process.platform,t=process.arch,n,o;switch(e){case"darwin":n="macos";break;case"win32":n="windows";break;case"linux":n="ubuntu";break;default:n=e}switch(t){case"x64":o="x86_64";break;case"arm64":o="aarch64";break;default:o=t}return{platform:e,arch:t,platformForAsset:n,archForAsset:o}}var L={sui:{name:"sui",repo:"MystenLabs/sui",binaryName:"sui",installDir:O.join(ue.homedir(),".dubhe","bin")},"dubhe-indexer":{name:"dubhe-indexer",repo:"0xobelisk/dubhe",binaryName:"dubhe-indexer",installDir:O.join(ue.homedir(),".dubhe","bin")}};async function q(e,t=[]){return new Promise(n=>{let o=as(e,t,{shell:!0}),s="",r="";o.stdout?.on("data",i=>{s+=i.toString()}),o.stderr?.on("data",i=>{r+=i.toString()}),o.on("close",i=>{n({code:i||0,stdout:s,stderr:r})}),o.on("error",()=>{n({code:-1,stdout:s,stderr:r})})})}async function un(e,t={}){try{let n={timeout:3e4,maxRedirects:5,validateStatus:s=>s<500,...t},o=await ls(e,n);return{ok:o.status>=200&&o.status<300,status:o.status,statusText:o.statusText,json:async()=>o.data,headers:o.headers}}catch(n){let o=n.response?.status||0,s=n.response?.statusText||n.message;return n.code==="ENOTFOUND"?s="DNS resolution failed - please check your internet connection":n.code==="ECONNRESET"?s="Connection reset - please check your network connection":n.code==="ETIMEDOUT"?s="Connection timeout - please check your network connection":n.message.includes("protocol mismatch")&&(s="Protocol mismatch - please check your network configuration"),{ok:!1,status:o,statusText:s,json:async()=>n.response?.data||{},headers:n.response?.headers||{}}}}async function at(e,t=10,n=3){let o=`https://api.github.com/repos/${e}/releases?per_page=${t}`;for(let s=1;s<=n;s++)try{s>1&&console.log(l.gray(` Retry ${s}/${n}...`));let r=await un(o,{headers:{"User-Agent":"dubhe-cli",Accept:"application/vnd.github.v3+json"}});if(!r.ok)throw r.status===403?new Error(`GitHub API rate limit: ${r.status}. Please retry later or set GITHUB_TOKEN environment variable`):new Error(`GitHub API request failed: ${r.status} ${r.statusText}`);return await r.json()}catch(r){if(s>1&&console.log(l.yellow(` \u26A0\uFE0F Attempt ${s} failed: ${r instanceof Error?r.message:String(r)}`)),s===n)return console.error(l.red(` \u274C Failed to fetch releases after ${n} attempts`)),[];await new Promise(i=>setTimeout(i,1e3*s))}return[]}function De(e,t){return e.assets.filter(o=>{let s=o.name.toLowerCase(),r=[t.platformForAsset.toLowerCase(),...t.platformForAsset==="macos"?["darwin","apple"]:[],...t.platformForAsset==="windows"?["win","win32","windows"]:[],...t.platformForAsset==="ubuntu"?["linux","gnu"]:[]],i=[t.archForAsset.toLowerCase(),...t.archForAsset==="x86_64"?["amd64","x64"]:[],...t.archForAsset==="aarch64"?["arm64"]:[]],c=r.some(u=>s.includes(u)),a=i.some(u=>s.includes(u)),d=s.endsWith(".tar.gz")||s.endsWith(".zip")||s.endsWith(".tgz")||s.endsWith(".tar.bz2")||s.endsWith(".tar.xz");return c&&a&&d}).map(o=>o.name)}async function cs(e,t){let n=L[e];return n?(await at(n.repo,10)).map(s=>({version:s.tag_name,hasCompatibleAsset:De(s,t).length>0})):[]}async function ds(e){try{let t=Ae();if(!t){console.log(l.gray(`Please add to PATH: export PATH="$PATH:${e}"`));return}let{shellName:n,configFile:o}=t,s=n==="fish"?`set -gx PATH $PATH ${e}`:`export PATH="$PATH:${e}"`;if(I.existsSync(o)&&I.readFileSync(o,"utf8").includes(e)){console.log(l.green(` \u2713 PATH already configured in ${o}`));return}let i=`# Added by dubhe doctor
133
133
  ${s}`;I.appendFileSync(o,`
134
134
  ${i}
135
135
  `),console.log(l.green(` \u2713 Automatically added to PATH in ${o}`)),console.log(l.blue(` \u{1F4DD} To apply changes: source ${o} or restart terminal`))}catch(t){console.log(l.yellow(` \u26A0\uFE0F Could not auto-configure PATH: ${t instanceof Error?t.message:String(t)}`)),console.log(l.gray(` Please manually add to PATH: export PATH="$PATH:${e}"`))}}function Ae(){let e=ue.homedir(),t=process.env.SHELL;if(t){if(t.includes("zsh"))return{shellName:"zsh",configFile:O.join(e,".zshrc")};if(t.includes("bash")){let o=O.join(e,".bash_profile"),s=O.join(e,".bashrc");return{shellName:"bash",configFile:process.platform==="darwin"&&I.existsSync(o)?o:s}}else if(t.includes("fish")){let o=O.join(e,".config","fish");return I.existsSync(o)||I.mkdirSync(o,{recursive:!0}),{shellName:"fish",configFile:O.join(o,"config.fish")}}}let n=[{name:"zsh",file:O.join(e,".zshrc")},{name:"bash",file:process.platform==="darwin"?O.join(e,".bash_profile"):O.join(e,".bashrc")},{name:"bash",file:O.join(e,".bashrc")}];for(let o of n)if(I.existsSync(o.file))return{shellName:o.name,configFile:o.file};return process.env.ZSH||I.existsSync("/bin/zsh")?{shellName:"zsh",configFile:O.join(e,".zshrc")}:null}async function rt(e,t){let n=L[e];if(!n)return console.error(`Unknown tool: ${e}`),!1;let o=it();console.log(l.gray(` System: ${o.platform}/${o.arch}`));try{console.log(l.gray(" Fetching release information..."));let s=await at(n.repo,10);if(s.length===0)return console.error(l.red(` \u274C Unable to fetch releases for ${n.name}`)),!1;let r=null;if(t){if(t.startsWith("v")||(t=`v${t}`),r=s.find(p=>p.tag_name===t)||null,!r)return console.error(`Version ${t} not found`),!1}else for(let p of s)if(De(p,o).length>0){r=p;break}if(!r)return console.error("No compatible version found"),!1;let i=De(r,o);if(i.length===0)return console.error(`Version ${r.tag_name} has no compatible binaries`),!1;let c=i[0],a=r.assets.find(p=>p.name===c);if(!a)return console.error(`Asset file not found: ${c}`),!1;console.log(l.green(` \u2713 Found compatible version: ${r.tag_name}`)),console.log(l.gray(` Download file: ${a.name}`));try{let p=await un(a.browser_download_url,{method:"HEAD",headers:{"User-Agent":"dubhe-cli"}});if(!p.ok)console.log(l.yellow(` \u26A0\uFE0F Warning: Unable to access download file (${p.status})`));else{let b=p.headers["content-length"];b&&console.log(l.gray(` File size: ${Math.round(parseInt(b)/1024/1024*100)/100} MB`))}}catch{console.log(l.yellow(" \u26A0\uFE0F Warning: Unable to verify download file"))}I.existsSync(n.installDir)||(I.mkdirSync(n.installDir,{recursive:!0}),console.log(l.gray(` Created install directory: ${n.installDir}`))),console.log(l.blue(" \u{1F4E5} Downloading..."));let d=O.join(ue.tmpdir(),a.name),u=3;for(let p=1;p<=u;p++)try{p>1&&console.log(l.gray(` Attempt ${p} to download...`)),await an(a.browser_download_url,d);break}catch(b){let m=b instanceof Error?b.message:String(b);if(console.log(l.yellow(` \u26A0\uFE0F Download failed (attempt ${p}): ${m}`)),p===u)throw new Error(`Download failed after ${u} attempts: ${m}`);console.log(l.gray(` Waiting ${p*2} seconds before retry...`)),await new Promise(C=>setTimeout(C,p*2e3))}console.log(l.blue(" \u{1F4E6} Extracting and installing..."));let g=O.join(ue.tmpdir(),`extract_${Date.now()}`);if(I.mkdirSync(g,{recursive:!0}),a.name.endsWith(".tar.gz")||a.name.endsWith(".tgz")){let p=await q("tar",["-xzf",d,"-C",g]);if(p.code!==0)throw new Error(`Extraction failed: ${p.stderr}`)}else if(a.name.endsWith(".tar.bz2")){let p=await q("tar",["-xjf",d,"-C",g]);if(p.code!==0)throw new Error(`Extraction failed: ${p.stderr}`)}else if(a.name.endsWith(".tar.xz")){let p=await q("tar",["-xJf",d,"-C",g]);if(p.code!==0)throw new Error(`Extraction failed: ${p.stderr}`)}else if(a.name.endsWith(".zip")){let p=await q("unzip",["-q",d,"-d",g]);if(p.code!==0)throw new Error(`Extraction failed: ${p.stderr}`)}else throw new Error(`Unsupported compression format: ${a.name}`);let f=p=>{let b=I.readdirSync(p,{withFileTypes:!0});for(let m of b){let C=O.join(p,m.name);if(m.isDirectory()){let S=f(C);if(S)return S}else if(m.name===n.binaryName||m.name===`${n.binaryName}.exe`)return C}return null},y=f(g);if(!y)throw new Error(`Cannot find ${n.binaryName} binary in extracted files`);let w=O.join(n.installDir,n.binaryName+(process.platform==="win32"?".exe":""));return I.copyFileSync(y,w),process.platform!=="win32"&&I.chmodSync(w,493),I.rmSync(d,{force:!0}),I.rmSync(g,{recursive:!0,force:!0}),console.log(l.green(" \u2705 Installation completed!")),console.log(l.gray(` Location: ${w}`)),console.log(l.gray(` Version: ${r.tag_name}`)),(process.env.PATH||"").includes(n.installDir)||(console.log(l.yellow(" \u26A0\uFE0F Warning: Install directory is not in PATH environment variable")),process.platform==="win32"?console.log(l.gray(` Please add to PATH: set PATH=%PATH%;${n.installDir}`)):await ds(n.installDir)),!0}catch(s){return console.error(l.red(`\u274C Installation failed: ${s}`)),!1}}async function us(e){let t=it(),n=await cs(e,t);if(n.length===0)return console.log(l.red(`Unable to get version information for ${e}`)),null;let o=n.filter(r=>r.hasCompatibleAsset).slice(0,5);if(o.length===0)return console.log(l.red("No compatible versions found for current system")),null;console.log(l.blue(`