@stacksjs/launchpad
Version:
Like Homebrew, but faster.
16 lines (14 loc) • 34.6 kB
JavaScript
// @bun
import{a as bh,b as e,c as Ah,d as z,e as S,f as nh,g as Ch,h as Eh,i as jh,j as c,k as Mh,l as _h,m as P,n as Hh,o as Gh}from"../src/index.js";import{p as Th,q as xh,r as D}from"../chunk-kwdnr1ce.js";import{s as Vh}from"../chunk-s2bxmfad.js";import{B as qh}from"../chunk-0sthbje6.js";import{F as Q,I as hh,T as R,U as wh}from"../chunk-nn4zj7f2.js";import{W as G,X as $h}from"../chunk-7h9a332h.js";import{Y,Z}from"../chunk-e2w1vagk.js";import M from"fs";import T from"path";import q from"process";import{EventEmitter as Wh}from"events";function d(h){return h==null?[]:Array.isArray(h)?h:[h]}function Kh(h,m,u,l){var t,$=h[m],A=~l.string.indexOf(m)?u==null||u===!0?"":String(u):typeof u==="boolean"?u:~l.boolean.indexOf(m)?u==="false"?!1:u==="true"||(h._.push((t=+u,t*0===0)?t:u),!!u):(t=+u,t*0===0)?t:u;h[m]=$==null?A:Array.isArray($)?$.concat(A):[$,A]}function Qh(h,m){h=h||[],m=m||{};var u,l,t,$,A,b={_:[]},w=0,O=0,n=0,E=h.length;let H=m.alias!==void 0,U=m.unknown!==void 0,W=m.default!==void 0;if(m.alias=m.alias||{},m.string=d(m.string),m.boolean=d(m.boolean),H)for(u in m.alias){l=m.alias[u]=d(m.alias[u]);for(w=0;w<l.length;w++)(m.alias[l[w]]=l.concat(u)).splice(w,1)}for(w=m.boolean.length;w-- >0;){l=m.alias[m.boolean[w]]||[];for(O=l.length;O-- >0;)m.boolean.push(l[O])}for(w=m.string.length;w-- >0;){l=m.alias[m.string[w]]||[];for(O=l.length;O-- >0;)m.string.push(l[O])}if(W){for(u in m.default)if($=typeof m.default[u],l=m.alias[u]=m.alias[u]||[],m[$]!==void 0){m[$].push(u);for(w=0;w<l.length;w++)m[$].push(l[w])}}let j=U?Object.keys(m.alias):[];for(w=0;w<E;w++){if(t=h[w],t==="--"){b._=b._.concat(h.slice(++w));break}for(O=0;O<t.length;O++)if(t.charCodeAt(O)!==45)break;if(O===0)b._.push(t);else if(t.substring(O,O+3)==="no-"){if($=t.substring(O+3),U&&!~j.indexOf($))return m.unknown(t);b[$]=!1}else{for(n=O+1;n<t.length;n++)if(t.charCodeAt(n)===61)break;$=t.substring(O,n),A=t.substring(++n)||(w+1===E||(""+h[w+1]).charCodeAt(0)===45||h[++w]),l=O===2?[$]:$;for(n=0;n<l.length;n++){if($=l[n],U&&!~j.indexOf($))return m.unknown("-".repeat(O)+$);Kh(b,$,n+1<l.length||A,m)}}}if(W){for(u in m.default)if(b[u]===void 0)b[u]=m.default[u]}if(H)for(u in b){l=m.alias[u]||[];while(l.length>0)b[l.shift()]=b[u]}return b}var o=(h)=>h.replace(/[<[].+/,"").trim(),Xh=(h)=>{let m=/<([^>]+)>/g,u=/\[([^\]]+)\]/g,l=[],t=(b)=>{let w=!1,O=b[1];if(O.startsWith("..."))O=O.slice(3),w=!0;return{required:b[0].startsWith("<"),value:O,variadic:w}},$;while($=m.exec(h))l.push(t($));let A;while(A=u.exec(h))l.push(t(A));return l},Yh=(h)=>{let m={alias:{},boolean:[]};for(let[u,l]of h.entries()){if(l.names.length>1)m.alias[l.names[0]]=l.names.slice(1);if(l.isBoolean)if(l.negated){if(!h.some(($,A)=>{return A!==u&&$.names.some((b)=>l.names.includes(b))&&typeof $.required==="boolean"}))m.boolean.push(l.names[0])}else m.boolean.push(l.names[0])}return m},a=(h)=>{return h.sort((m,u)=>{return m.length>u.length?-1:1})[0]},i=(h,m)=>{return h.length>=m?h:`${h}${" ".repeat(m-h.length)}`},Zh=(h)=>{return h.replace(/([a-z])-([a-z])/g,(m,u,l)=>{return u+l.toUpperCase()})},vh=(h,m,u)=>{let l=0,t=m.length,$=h,A;for(;l<t;++l)A=$[m[l]],$=$[m[l]]=l===t-1?u:A!=null?A:!!~m[l+1].indexOf(".")||!(+m[l+1]>-1)?{}:[]},Jh=(h,m)=>{for(let u of Object.keys(m)){let l=m[u];if(l.shouldTransform){if(h[u]=Array.prototype.concat.call([],h[u]),typeof l.transformFunction==="function")h[u]=h[u].map(l.transformFunction)}}},fh=(h)=>{let m=/([^\\\/]+)$/.exec(h);return m?m[1]:""},p=(h)=>{return h.split(".").map((m,u)=>{return u===0?Zh(m):m}).join(".")};class N extends Error{constructor(h){super(h);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=new Error(h).stack}}class r{constructor(h,m,u){if(this.rawName=h,this.description=m,this.config=Object.assign({},u),h=h.replace(/\.\*/g,""),this.negated=!1,this.names=o(h).split(",").map((l)=>{let t=l.trim().replace(/^-{1,2}/,"");if(t.startsWith("no-"))this.negated=!0,t=t.replace(/^no-/,"");return p(t)}).sort((l,t)=>l.length>t.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(h.includes("<"))this.required=!0;else if(h.includes("["))this.required=!1;else this.isBoolean=!0}}var Nh=process.argv,Fh=`${process.platform}-${process.arch} node-${process.version}`;class y{constructor(h,m,u={},l){this.rawName=h,this.description=m,this.config=u,this.cli=l,this.options=[],this.aliasNames=[],this.name=o(h),this.args=Xh(h),this.examples=[]}usage(h){return this.usageText=h,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(h,m="-v, --version"){return this.versionNumber=h,this.option(m,"Display version number"),this}example(h){return this.examples.push(h),this}option(h,m,u){let l=new r(h,m,u);return this.options.push(l),this}alias(h){return this.aliasNames.push(h),this}action(h){return this.commandAction=h,this}isMatched(h){return this.name===h||this.aliasNames.includes(h)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof B}hasOption(h){return h=h.split(".")[0],this.options.find((m)=>{return m.names.includes(h)})}outputHelp(){let{name:h,commands:m}=this.cli,{versionNumber:u,options:l,helpCallback:t}=this.cli.globalCommand,$=[{body:`${h}${u?`/${u}`:""}`}];if($.push({title:"Usage",body:` $ ${h} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&m.length>0){let w=a(m.map((O)=>O.rawName));$.push({title:"Commands",body:m.map((O)=>{return` ${i(O.rawName,w.length)} ${O.description}`}).join(`
`)}),$.push({title:"For more info, run any command with the `--help` flag",body:m.map((O)=>` $ ${h}${O.name===""?"":` ${O.name}`} --help`).join(`
`)})}let b=this.isGlobalCommand?l:[...this.options,...l||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)b=b.filter((w)=>w.name!=="version");if(b.length>0){let w=a(b.map((O)=>O.rawName));$.push({title:"Options",body:b.map((O)=>{return` ${i(O.rawName,w.length)} ${O.description} ${O.config.default===void 0?"":`(default: ${O.config.default})`}`}).join(`
`)})}if(this.examples.length>0)$.push({title:"Examples",body:this.examples.map((w)=>{if(typeof w==="function")return w(h);return w}).join(`
`)});if(t)$=t($)||$;console.log($.map((w)=>{return w.title?`${w.title}:
${w.body}`:w.body}).join(`
`))}outputVersion(){let{name:h}=this.cli,{versionNumber:m}=this.cli.globalCommand;if(m)console.log(`${h}/${m} ${Fh}`)}checkRequiredArgs(){let h=this.args.filter((m)=>m.required).length;if(this.cli.args.length<h)throw new N(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:h,globalCommand:m}=this.cli;if(!this.config.allowUnknownOptions){for(let u of Object.keys(h))if(u!=="--"&&!this.hasOption(u)&&!m.hasOption(u))throw new N(`Unknown option \`${u.length>1?`--${u}`:`-${u}`}\``)}}checkOptionValue(){let{options:h,globalCommand:m}=this.cli,u=[...m.options,...this.options];for(let l of u){let t=h[l.name.split(".")[0]];if(l.required){let $=u.some((A)=>A.negated&&A.names.includes(l.name));if(t===!0||t===!1&&!$)throw new N(`option \`${l.rawName}\` value is missing`)}}}}class B extends y{constructor(h){super("@@global@@","",{},h)}}var f=Object.assign;class L extends Wh{constructor(h=""){super();this.name=h,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new B(this),this.globalCommand.usage("<command> [options]")}usage(h){return this.globalCommand.usage(h),this}command(h,m,u){let l=new y(h,m||"",u,this);return l.globalCommand=this.globalCommand,this.commands.push(l),l}option(h,m,u){return this.globalCommand.option(h,m,u),this}help(h){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=h,this.showHelpOnExit=!0,this}version(h,m="-v, --version"){return this.globalCommand.version(h,m),this.showVersionOnExit=!0,this}example(h){return this.globalCommand.example(h),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:h,options:m},u,l){if(this.args=h,this.options=m,u)this.matchedCommand=u;if(l)this.matchedCommandName=l;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(h=Nh,{run:m=!0}={}){if(this.rawArgs=h,!this.name)this.name=h[1]?fh(h[1]):"cli";let u=!0;for(let t of this.commands){let $=this.mri(h.slice(2),t),A=$.args[0];if(t.isMatched(A)){u=!1;let b=f(f({},$),{args:$.args.slice(1)});this.setParsedInfo(b,t,A),this.emit(`command:${A}`,t)}}if(u){for(let t of this.commands)if(t.name===""){u=!1;let $=this.mri(h.slice(2),t);this.setParsedInfo($,t),this.emit("command:!",t)}}if(u){let t=this.mri(h.slice(2));this.setParsedInfo(t)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),m=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),m=!1,this.unsetMatchedCommand();let l={args:this.args,options:this.options};if(m)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.emit("command:*");return l}mri(h,m){let u=[...this.globalCommand.options,...m?m.options:[]],l=Yh(u),t=[],$=h.indexOf("--");if($>-1)t=h.slice($+1),h=h.slice(0,$);let A=Qh(h,l);A=Object.keys(A).reduce((E,H)=>{return f(f({},E),{[p(H)]:A[H]})},{_:[]});let b=A._,w={"--":t},O=m&&m.config.ignoreOptionDefaultValue?m.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,n=Object.create(null);for(let E of u){if(!O&&E.config.default!==void 0)for(let H of E.names)w[H]=E.config.default;if(Array.isArray(E.config.type)){if(n[E.name]===void 0)n[E.name]=Object.create(null),n[E.name].shouldTransform=!0,n[E.name].transformFunction=E.config.type[0]}}for(let E of Object.keys(A))if(E!=="_"){let H=E.split(".");vh(w,H,A[E]),Jh(w,n)}return{args:b,options:w}}runMatchedCommand(){let{args:h,options:m,matchedCommand:u}=this;if(!u||!u.commandAction)return;u.checkUnknownOptions(),u.checkOptionValue(),u.checkRequiredArgs();let l=[];return u.args.forEach((t,$)=>{if(t.variadic)l.push(h.slice($));else l.push(h[$])}),l.push(m),u.commandAction.apply(this,l)}}function mh(h,m={}){let{includeVersions:u=!1,maxVersions:l=10}=m,t=R(h);if(!t)return null;let $={name:t.name,domain:t.domain,description:t.description,latestVersion:t.latestVersion,totalVersions:t.totalVersions,programs:t.programs,dependencies:t.dependencies,companions:t.companions};if(u){let A=hh(h);$.versions=A.slice(0,l)}return $}function uh(h,m={}){let{showVersions:u=!0,showPrograms:l=!0,showDependencies:t=!0,showCompanions:$=!0,compact:A=!1}=m,b=[];if(A){let w=h.description?` - ${h.description}`:"";if(b.push(`\uD83D\uDCE6 ${h.name} (${h.domain})${w}`),h.latestVersion)b.push(` Latest: ${h.latestVersion}`)}else{if(b.push("\uD83D\uDCE6 Package Information"),b.push(`${"=".repeat(50)}`),b.push(""),b.push(`Name: ${h.name}`),b.push(`Domain: ${h.domain}`),h.description)b.push(`Description: ${h.description}`);if(b.push(""),h.latestVersion)b.push(`Latest Version: ${h.latestVersion}`);if(h.totalVersions>0)b.push(`Total Versions: ${h.totalVersions}`);if(u&&h.versions&&h.versions.length>0){if(b.push(""),b.push("Available Versions:"),h.versions.slice(0,10).forEach((O,n)=>{let E=n===0?" (latest)":"";b.push(` \u2022 ${O}${E}`)}),h.versions.length>10)b.push(` ... and ${h.versions.length-10} more`)}if(l&&h.programs&&h.programs.length>0)b.push(""),b.push("Programs:"),h.programs.forEach((w)=>{b.push(` \u2022 ${w}`)});if(t&&h.dependencies&&h.dependencies.length>0)b.push(""),b.push("Dependencies:"),h.dependencies.forEach((w)=>{b.push(` \u2022 ${w}`)});if($&&h.companions&&h.companions.length>0)b.push(""),b.push("Companion Packages:"),h.companions.forEach((w)=>{b.push(` \u2022 ${w}`)});if(b.push(""),b.push("Installation:"),b.push(` launchpad install ${h.name}`),h.latestVersion)b.push(` launchpad install ${h.name}@${h.latestVersion}`)}return b.join(`
`)}function lh(h){return R(h)!==null}async function Ih(h,m=5){try{let{searchPackages:u}=await import("../chunk-kwdnr1ce.js");return u(h,{limit:m}).map((t)=>t.name)}catch{return[]}}async function th(h){let m=await Ih(h),u=[`\u274C Package '${h}' not found.`,""];if(m.length>0)u.push("Did you mean one of these?"),m.forEach((l)=>{u.push(` \u2022 ${l}`)}),u.push(""),u.push('Use "launchpad search <term>" to find packages.');else u.push('Use "launchpad search <term>" to find available packages.');return u.join(`
`)}var Oh=await import("../chunk-pe77cn21.js"),Uh=Oh.default?.version||Oh.version||"0.0.0",_=new L("launchpad");_.version(Uh);_.help();_.command("install [packages...]","Install packages").alias("i").alias("add").option("--verbose","Enable verbose output").option("--path <path>","Custom installation path").example("launchpad install node python").example("launchpad install --path ~/.local node python").example("launchpad add node python").action(async(h,m)=>{if(m.verbose)G.verbose=!0;let u=Array.isArray(h)?h:[h].filter(Boolean);if(u.length===0)console.error("No packages specified"),q.exit(1);try{let l=m.path||Q().string,t=await wh(u,l);if(t.length>0)console.log(`\uD83C\uDF89 Successfully installed ${u.join(", ")} (${t.length} ${t.length===1?"binary":"binaries"})`),t.forEach(($)=>{console.log(` ${$}`)});else console.log("\u26A0\uFE0F No binaries were installed")}catch(l){console.error("Installation failed:",l instanceof Error?l.message:String(l)),q.exit(1)}});_.command("search [term]","Search for available packages").alias("find").option("--limit <number>","Maximum number of results to show").option("--compact","Show compact output format").option("--no-programs","Exclude program names from search").option("--case-sensitive","Case sensitive search").example("launchpad search node").example('launchpad search "web server" --limit 10').example("launchpad search python --compact").action(async(h,m)=>{try{let u=m?.limit?Number.parseInt(m.limit,10):20;if(!h||h.trim().length===0){console.log(`\uD83C\uDF1F Popular Packages:
`);let t=xh(u);console.log(D(t,{compact:m?.compact,showPrograms:m?.programs!==!1}));return}let l=Th(h,{limit:u,includePrograms:m?.programs!==!1,caseSensitive:m?.caseSensitive||!1});if(l.length===0)console.log(`No packages found matching "${h}".`),console.log(`
Try:`),console.log(" \u2022 Using different keywords"),console.log(" \u2022 Checking spelling"),console.log(' \u2022 Using "launchpad search" without arguments to see popular packages');else console.log(D(l,{compact:m?.compact,showPrograms:m?.programs!==!1}))}catch(u){console.error("Search failed:",u instanceof Error?u.message:String(u)),q.exit(1)}});_.command("info <package>","Show detailed information about a package").alias("show").option("--versions","Show available versions").option("--no-programs","Hide program list").option("--no-dependencies","Hide dependencies").option("--no-companions","Hide companion packages").option("--compact","Show compact output format").example("launchpad info node").example("launchpad info python --versions").example("launchpad show rust --compact").action(async(h,m)=>{try{if(!lh(h)){let t=await th(h);console.error(t),q.exit(1)}let u=mh(h,{includeVersions:m?.versions||!1,maxVersions:15});if(!u)console.error(`\u274C Failed to get information for package '${h}'`),q.exit(1);let l=uh(u,{showVersions:m?.versions||!1,showPrograms:m?.programs!==!1,showDependencies:m?.dependencies!==!1,showCompanions:m?.companions!==!1,compact:m?.compact||!1});console.log(l)}catch(u){console.error("Failed to get package info:",u instanceof Error?u.message:String(u)),q.exit(1)}});_.command("doctor","Run health checks and diagnose installation issues").alias("health").alias("check").option("--verbose","Show detailed diagnostic information").example("launchpad doctor").example("launchpad health").action(async(h)=>{if(h?.verbose)G.verbose=!0;try{console.log(`\uD83D\uDD0D Running health checks...
`);let m=await Eh(),u=jh(m);if(console.log(u),m.overall==="critical")q.exit(1);else if(m.overall==="issues")q.exit(2)}catch(m){console.error("Health check failed:",m instanceof Error?m.message:String(m)),q.exit(1)}});_.command("tags","Browse packages by category and tags").alias("categories").alias("browse").option("--list","List all available categories").option("--category <name>","Show packages in a specific category").option("--search <term>","Search packages by tag or category").option("--compact","Use compact display format").option("--no-programs","Hide program listings").option("--no-versions","Hide version information").example("launchpad tags --list").example('launchpad tags --category "Programming Languages"').example("launchpad tags --search database").example("launchpad categories").action(async(h)=>{try{if(h?.list){let l=c(),t=P(l);console.log(t);return}if(h?.category){let l=Mh(h.category),t=Hh(h.category,l,{compact:h.compact,showPrograms:h.programs!==!1,showVersions:h.versions!==!1});console.log(t);return}if(h?.search){let l=_h(h.search),t=Gh(h.search,l,{compact:h.compact,groupByCategory:!0});console.log(t);return}let m=c(),u=P(m);console.log(u)}catch(m){console.error("Tags command failed:",m instanceof Error?m.message:String(m)),q.exit(1)}});_.command("list","List installed packages").alias("ls").option("--path <path>","Installation path to list packages from").option("--verbose","Enable verbose output").example("launchpad list").example("launchpad ls").action(async(h)=>{if(h?.verbose)G.verbose=!0;try{let m=h?.path||Q().string,u=await qh(m);if(u.length===0)console.log("No packages installed");else console.log("Installed packages:"),u.forEach((l)=>{console.log(` ${l.project}@${l.version}`)})}catch(m){console.error("Failed to list packages:",m instanceof Error?m.message:String(m)),q.exit(1)}});_.command("bootstrap","Install essential tools for a complete Launchpad setup").option("--verbose","Enable verbose output").option("--path <path>","Custom installation path (default: auto-detected)").option("--force","Force reinstall even if already installed").option("--no-auto-path","Do not automatically add to PATH").option("--skip-shell-integration","Skip shell integration setup").example("launchpad bootstrap").example("launchpad bootstrap --verbose --force").example("launchpad bootstrap --path ~/.local").action(async(h)=>{if(h?.verbose)G.verbose=!0;if(h?.force)G.forceReinstall=!0;if(h?.autoPath===!1)G.autoAddToPath=!1;console.log("\uD83D\uDE80 Bootstrapping Launchpad - Installing essential tools...");let m=h?.path?new $h(h.path):Q();console.log(`\uD83D\uDCCD Installation prefix: ${m.string}`),console.log("");let u=[],l=(O,n,E)=>{u.push({tool:O,status:n,message:E}),console.log(`${n==="success"?"\u2705":n==="failed"?"\u274C":n==="skipped"?"\u23ED\uFE0F":"\uD83D\uDD04"} ${O}: ${E||n}`)};console.log("\uD83D\uDCC1 Setting up directories...");let t=T.join(m.string,"bin"),$=T.join(m.string,"sbin");try{M.mkdirSync(t,{recursive:!0}),M.mkdirSync($,{recursive:!0}),l("directories","success","created bin/ and sbin/")}catch(O){l("directories","failed",O instanceof Error?O.message:String(O))}if(console.log(""),console.log("\uD83D\uDEE4\uFE0F Setting up PATH..."),G.autoAddToPath){let O=!1;if(!z(t))if(S(t))console.log(`\u2705 Added ${t} to PATH`),O=!0;else console.log(`\u26A0\uFE0F Could not automatically add ${t} to PATH`);else console.log(`\u2705 ${t} already in PATH`);if(!z($))if(S($))console.log(`\u2705 Added ${$} to PATH`),O=!0;else console.log(`\u26A0\uFE0F Could not automatically add ${$} to PATH`);else console.log(`\u2705 ${$} already in PATH`);if(O)l("PATH setup","success","PATH updated successfully");else l("PATH setup","success","PATH already configured")}else l("PATH setup","skipped","auto PATH setup disabled");if(console.log(""),!h?.skipShellIntegration){console.log("\uD83D\uDC1A Setting up shell integration...");try{await e("install",{dryrun:!1}),l("shell integration","success","hooks installed")}catch(O){l("shell integration","failed",O instanceof Error?O.message:String(O))}}else l("shell integration","skipped","skipped by user");console.log(""),console.log("\uD83D\uDCCB Bootstrap Summary:"),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");let A=u.filter((O)=>O.status==="success"||O.status==="already-installed"),b=u.filter((O)=>O.status==="failed"),w=u.filter((O)=>O.status==="skipped");if(A.forEach((O)=>console.log(`\u2705 ${O.tool}: ${O.message||O.status}`)),b.forEach((O)=>console.log(`\u274C ${O.tool}: ${O.message||O.status}`)),w.forEach((O)=>console.log(`\u23ED\uFE0F ${O.tool}: ${O.message||O.status}`)),console.log(""),b.length===0)console.log("\uD83C\uDF89 Bootstrap completed successfully!"),console.log(""),console.log("\uD83D\uDE80 Next steps:"),console.log("1. Restart your terminal or run: source ~/.zshrc (or your shell config)"),console.log("2. Install packages: launchpad install node python"),console.log("3. Create shims: launchpad shim node"),console.log("4. List installed: launchpad list");else console.log(`\u26A0\uFE0F Bootstrap completed with ${b.length} failed component(s)`),console.log(""),console.log("\uD83D\uDD27 You can continue using Launchpad, but some features may not work optimally")});_.command("shim [packages...]","Create shims for packages").alias("stub").option("--verbose","Enable verbose output").option("--path <path>","Custom shim installation path").option("--force","Force creation of shims even if they already exist").option("--no-auto-path","Do not automatically add shim directory to PATH").example("launchpad shim node").example("launchpad shim node python --path ~/bin").action(async(h,m)=>{if(m?.verbose)G.verbose=!0;if(m?.force)G.forceReinstall=!0;if(m?.autoPath===!1)G.autoAddToPath=!1;let u=Array.isArray(h)?h:[h].filter(Boolean);if(u.length===0)console.error("No packages specified"),q.exit(1);try{let l=m?.path||Ch().string;console.log(`Creating shims for: ${u.join(", ")}`);let t=await nh(u,l);if(t.length>0)console.log(`Successfully created ${t.length} shims:`),t.forEach(($)=>{console.log(` ${$}`)});else console.log("No shims were created")}catch(l){console.error("Failed to create shims:",l instanceof Error?l.message:String(l)),q.exit(1)}});_.command("dev:shellcode","Generate shell integration code").action(()=>{console.log(Ah())});_.command("dev:dump [dir]","Set up development environment for project dependencies").option("--dry-run","Show packages that would be installed without installing them").option("--quiet","Suppress non-error output").action(async(h,m)=>{try{let u=h?T.resolve(h):q.cwd();await bh(u,{dryrun:m?.dryRun||!1,quiet:m?.quiet||!1})}catch(u){console.error("Failed to dump dev environment:",u instanceof Error?u.message:String(u)),q.exit(1)}});_.command("dev:integrate","Install shell integration hooks").option("--uninstall","Remove shell integration hooks").option("--dry-run","Show what would be changed without making changes").action(async(h)=>{try{let m=h?.uninstall?"uninstall":"install",u=h?.dryRun||!1;await e(m,{dryrun:u})}catch(m){console.error("Failed to integrate shell hooks:",m instanceof Error?m.message:String(m)),q.exit(1)}});_.command("dev:on [dir]","Activate development environment").option("--silent","Suppress output messages").action(async(h,m)=>{try{let u=h?T.resolve(h):q.cwd();if(!m?.silent){if(G.showShellMessages&&G.shellActivationMessage){let l=G.shellActivationMessage.replace("{path}",u);console.warn(l)}}}catch(u){if(!m?.silent)console.error("Failed to activate dev environment:",u instanceof Error?u.message:String(u));q.exit(1)}});_.command("dev:off","Deactivate development environment").option("--silent","Suppress output messages").action(async(h)=>{try{if(!h?.silent){if(G.showShellMessages&&G.shellDeactivationMessage)console.warn(G.shellDeactivationMessage)}}catch(m){if(!h?.silent)console.error("Failed to deactivate dev environment:",m instanceof Error?m.message:String(m));q.exit(1)}});_.command("uninstall [packages...]","Remove installed packages").alias("remove").alias("rm").option("--verbose","Enable verbose output").option("--force","Skip confirmation prompts").option("--dry-run","Show what would be removed without actually removing it").example("launchpad uninstall node python").example("launchpad remove node@18 --force").action(async(h,m)=>{if(m?.verbose)G.verbose=!0;let u=Array.isArray(h)?h:[h].filter(Boolean);if(u.length===0)console.error("No packages specified for removal"),console.log(""),console.log("Usage examples:"),console.log(" launchpad uninstall node python"),console.log(" launchpad remove node@18 --force"),q.exit(1);let l=m?.dryRun||!1;if(l)console.log("\uD83D\uDD0D DRY RUN MODE - Nothing will actually be removed");if(console.log(`${l?"Would remove":"Removing"} packages: ${u.join(", ")}`),!m?.force&&!l)console.log("Use --force to skip confirmation or --dry-run to preview");let t=!0,$=[];for(let w of u)try{if(l)console.log(`Would uninstall: ${w}`),$.push({package:w,success:!0,message:"dry run"});else{let O=await Vh(w);if($.push({package:w,success:O}),!O)t=!1}}catch(O){console.error(`Failed to uninstall ${w}:`,O instanceof Error?O.message:String(O)),$.push({package:w,success:!1,message:O instanceof Error?O.message:String(O)}),t=!1}console.log(""),console.log("Uninstall Summary:");let A=$.filter((w)=>w.success),b=$.filter((w)=>!w.success);if(A.length>0)console.log(`\u2705 ${l?"Would remove":"Successfully removed"}: ${A.map((w)=>w.package).join(", ")}`);if(b.length>0)console.log(`\u274C Failed: ${b.map((w)=>w.package).join(", ")}`);if(!t)q.exit(1)});_.command("cache:clear","Clear all cached packages and downloads").alias("cache:clean").option("--verbose","Enable verbose output").option("--force","Skip confirmation prompts").option("--dry-run","Show what would be cleared without actually clearing it").example("launchpad cache:clear").example("launchpad cache:clean --force").action(async(h)=>{if(h?.verbose)G.verbose=!0;let m=h?.dryRun||!1;try{let l=(await import("os")).homedir(),t=T.join(l,".cache","launchpad"),$=T.join(l,".cache","launchpad","binaries","bun"),A=T.join(l,".cache","launchpad","binaries","packages");if(m)console.log("\uD83D\uDD0D DRY RUN MODE - Nothing will actually be cleared");if(console.log(`${m?"Would clear":"Clearing"} Launchpad cache...`),!h?.force&&!m)console.log("\u26A0\uFE0F This will remove all cached packages and downloads"),console.log("Use --force to skip confirmation or --dry-run to preview"),q.exit(0);let b=0,w=0,O=(E)=>{if(!M.existsSync(E))return;try{let H=[E];while(H.length>0){let U=H.pop();try{let W=M.readdirSync(U,{withFileTypes:!0});for(let j of W){let C=T.join(U,j.name);if(j.isFile())try{let V=M.statSync(C);b+=V.size,w++}catch{}else if(j.isDirectory())H.push(C)}}catch{continue}}}catch{}};if(M.existsSync(t))O(t);let n=(E)=>{let H=["B","KB","MB","GB"],U=E,W=0;while(U>=1024&&W<H.length-1)U/=1024,W++;return`${U.toFixed(1)} ${H[W]}`};if(m){if(M.existsSync(t)){if(console.log("\uD83D\uDCCA Cache statistics:"),console.log(` \u2022 Total size: ${n(b)}`),console.log(` \u2022 File count: ${w}`),console.log(` \u2022 Cache directory: ${t}`),console.log(""),console.log("Would remove:"),M.existsSync($))console.log(` \u2022 Bun cache: ${$}`);if(M.existsSync(A))console.log(` \u2022 Package cache: ${A}`)}else console.log("\uD83D\uDCED No cache found - nothing to clear");return}if(M.existsSync(t))console.log(`\uD83D\uDCCA Clearing ${n(b)} of cached data (${w} files)...`),M.rmSync(t,{recursive:!0,force:!0}),console.log("\u2705 Cache cleared successfully!"),console.log(` \u2022 Freed ${n(b)} of disk space`),console.log(` \u2022 Removed ${w} cached files`);else console.log("\uD83D\uDCED No cache found - nothing to clear")}catch(u){console.error("Failed to clear cache:",u instanceof Error?u.message:String(u)),q.exit(1)}});_.command("clean","Remove all Launchpad-installed packages and environments").option("--verbose","Enable verbose output").option("--force","Skip confirmation prompts").option("--dry-run","Show what would be removed without actually removing it").option("--keep-cache","Keep cached downloads (only remove installed packages)").example("launchpad clean --dry-run").example("launchpad clean --force").example("launchpad clean --keep-cache").action(async(h)=>{if(h?.verbose)G.verbose=!0;let m=h?.dryRun||!1;try{if(m)console.log("\uD83D\uDD0D DRY RUN MODE - Nothing will actually be removed");if(console.log(`${m?"Would perform":"Performing"} complete cleanup...`),!h?.force&&!m){if(console.log("\u26A0\uFE0F This will remove ALL Launchpad-installed packages and environments"),console.log("\u26A0\uFE0F This includes package metadata, binaries, and libraries:"),console.log(` \u2022 ${T.join(Q().string,"pkgs")} (package metadata)`),console.log(` \u2022 ${T.join(Q().string,"bin")} (Launchpad-installed binaries only)`),console.log(` \u2022 ${Q().string}/{domain}/v{version}/ (package files and libraries)`),console.log(" \u2022 ~/.local/share/launchpad/ (project environments)"),!h?.keepCache)console.log(" \u2022 ~/.cache/launchpad/ (cached downloads)");console.log(""),console.log("\u26A0\uFE0F This action cannot be undone!"),console.log(""),console.log("Use --force to skip confirmation or --dry-run to preview"),q.exit(0)}let l=(await import("os")).homedir(),t=Q().string,$=()=>{let j=[],C=T.join(t,"pkgs"),V=T.join(t,"bin");if(!M.existsSync(C))return j;try{let x=M.readdirSync(C,{withFileTypes:!0}).filter((K)=>K.isDirectory());for(let K of x){let J=T.join(C,K.name),v=M.readdirSync(J,{withFileTypes:!0}).filter((X)=>X.isDirectory());for(let X of v){let F=T.join(J,X.name),g=T.join(F,"metadata.json");if(M.existsSync(g))try{let I=JSON.parse(M.readFileSync(g,"utf8"));if(I.binaries&&Array.isArray(I.binaries))for(let k of I.binaries){let s=T.join(V,k);if(M.existsSync(s))j.push({binary:k,package:`${K.name}@${X.name.slice(1)}`,fullPath:s})}}catch{}}}}catch{}return j},A=T.join(l,".local","share","launchpad"),b=T.join(l,".cache","launchpad"),w=T.join(t,"pkgs"),O=[{path:w,name:"Package metadata"},{path:A,name:"Project environments"}];if(!h?.keepCache)O.push({path:b,name:"Cache directory"});try{let j=M.readdirSync(t,{withFileTypes:!0}).filter((C)=>C.isDirectory()&&C.name!=="bin"&&C.name!=="pkgs"&&C.name!==".tmp"&&C.name!==".cache"&&C.name!==".local");for(let C of j){let V=T.join(t,C.name);O.push({path:V,name:`Package files (${C.name})`})}}catch{}let n=$(),E=0,H=0,U=[];for(let j of O)if(M.existsSync(j.path)){let C=0,V=0;try{let x=[j.path];while(x.length>0){let K=x.pop();try{let J=M.readdirSync(K,{withFileTypes:!0});for(let v of J){let X=T.join(K,v.name);if(v.isFile())try{let F=M.statSync(X);C+=F.size,V++}catch{}else if(v.isDirectory())x.push(X)}}catch{continue}}}catch{}U.push({path:j.path,name:j.name,size:C,files:V}),E+=C,H+=V}for(let j of n)try{let C=M.statSync(j.fullPath);E+=C.size,H++}catch{}let W=(j)=>{let C=["B","KB","MB","GB"],V=j,x=0;while(V>=1024&&x<C.length-1)V/=1024,x++;return`${V.toFixed(1)} ${C[x]}`};if(m){if(U.length>0||n.length>0){if(console.log("\uD83D\uDCCA Cleanup statistics:"),console.log(` \u2022 Total size: ${W(E)}`),console.log(` \u2022 Total files: ${H}`),console.log(""),console.log("Would remove:"),U.forEach((j)=>{console.log(` \u2022 ${j.name}: ${j.path} (${W(j.size)}, ${j.files} files)`)}),n.length>0)console.log(` \u2022 Launchpad binaries: ${n.length} files`);if(M.existsSync(w))try{let j=M.readdirSync(w,{withFileTypes:!0}).filter((C)=>C.isDirectory()).map((C)=>C.name);if(j.length>0)console.log(""),console.log("\uD83D\uDCE6 Packages that would be removed:"),j.forEach((C)=>{console.log(` \u2022 ${C}`)})}catch{}if(n.length>0){console.log(""),console.log("\uD83D\uDD27 Binaries that would be removed:");let j=n.reduce((C,{binary:V,package:x})=>{if(!C[x])C[x]=[];return C[x].push(V),C},{});Object.entries(j).forEach(([C,V])=>{console.log(` \u2022 ${C}: ${V.join(", ")}`)})}}else console.log("\uD83D\uDCED Nothing found to clean");return}if(U.length>0||n.length>0){console.log(`\uD83D\uDCCA Cleaning ${W(E)} of data (${H} files)...`),console.log("");let j=0,C=0;for(let V of U)try{if(console.log(`\uD83D\uDDD1\uFE0F Removing ${V.name}...`),M.rmSync(V.path,{recursive:!0,force:!0}),j++,h?.verbose)console.log(` \u2705 Removed ${V.path} (${W(V.size)}, ${V.files} files)`)}catch(x){console.error(` \u274C Failed to remove ${V.path}:`,x instanceof Error?x.message:String(x))}if(n.length>0){console.log("\uD83D\uDDD1\uFE0F Removing Launchpad-installed binaries...");for(let{binary:V,fullPath:x}of n)try{if(M.unlinkSync(x),C++,h?.verbose)console.log(` \u2705 Removed binary: ${V}`)}catch(K){if(h?.verbose)console.error(` \u274C Failed to remove ${V}:`,K instanceof Error?K.message:String(K))}}if(console.log(""),console.log("\u2705 Cleanup completed!"),console.log(` \u2022 Removed ${j}/${U.length} directories`),n.length>0)console.log(` \u2022 Removed ${C}/${n.length} binaries`);if(console.log(` \u2022 Freed ${W(E)} of disk space`),h?.keepCache)console.log(""),console.log("\uD83D\uDCA1 Cache was preserved. Use `launchpad cache:clear` to remove cached downloads.")}else console.log("\uD83D\uDCED Nothing found to clean")}catch(u){console.error("Failed to perform cleanup:",u instanceof Error?u.message:String(u)),q.exit(1)}});_.command("outdated","Check for outdated packages").option("--verbose","Enable verbose output").action(async(h)=>{if(h?.verbose)G.verbose=!0;try{let{outdated:m}=await import("../chunk-0sthbje6.js");await m()}catch(m){console.error("Failed to check for outdated packages:",m instanceof Error?m.message:String(m)),q.exit(1)}});_.command("update [packages...]","Update packages to newer versions").alias("upgrade").alias("up").option("--verbose","Enable verbose output").option("--latest","Update to the latest version (ignoring current constraints)").option("--dry-run","Show what would be updated without actually updating").example("launchpad update").example("launchpad upgrade bun --latest").example("launchpad up node python --latest").example("launchpad update --dry-run").action(async(h,m)=>{if(m?.verbose)G.verbose=!0;let u=Array.isArray(h)?h:[h].filter(Boolean);try{if(u.length===0){let{update:l}=await import("../chunk-s2bxmfad.js");await l(void 0,{latest:m?.latest,dryRun:m?.dryRun})}else{let{update:l}=await import("../chunk-s2bxmfad.js");await l(u,{latest:m?.latest,dryRun:m?.dryRun})}}catch(l){console.error("Failed to update packages:",l instanceof Error?l.message:String(l)),q.exit(1)}});try{_.version(Uh),_.help(),_.parse()}catch(h){console.error("CLI error:",h instanceof Error?h.message:String(h)),q.exit(1)}