@visulima/vis 1.0.0-alpha.26 → 1.0.0-alpha.27
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/CHANGELOG.md +23 -0
- package/LICENSE.md +17 -17
- package/README.md +24 -22
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +176 -16
- package/dist/packem_chunks/bin.js +263 -263
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/config.js +12 -12
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +8 -9
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler30.js +3 -3
- package/dist/packem_chunks/handler31.js +2 -2
- package/dist/packem_chunks/handler34.js +1 -1
- package/dist/packem_chunks/handler35.js +3 -22
- package/dist/packem_chunks/handler36.js +21 -60
- package/dist/packem_chunks/handler37.js +61 -6
- package/dist/packem_chunks/handler38.js +3 -24
- package/dist/packem_chunks/handler39.js +6 -153
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +24 -10
- package/dist/packem_chunks/handler41.js +153 -25
- package/dist/packem_chunks/handler42.js +10 -708
- package/dist/packem_chunks/handler43.js +25 -24
- package/dist/packem_chunks/handler44.js +659 -273
- package/dist/packem_chunks/handler45.js +24 -46
- package/dist/packem_chunks/handler46.js +322 -3
- package/dist/packem_chunks/handler47.js +48 -27
- package/dist/packem_chunks/handler48.js +3 -187
- package/dist/packem_chunks/handler49.js +23 -30
- package/dist/packem_chunks/handler5.js +6 -6
- package/dist/packem_chunks/handler50.js +196 -0
- package/dist/packem_chunks/handler51.js +34 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/{advisories-DS8JEB_g.js → advisories-xIOdLbAI.js} +1 -1
- package/dist/packem_shared/{cyclonedx-ja1cbU69.js → cyclonedx-B3ILsY74.js} +1 -1
- package/dist/packem_shared/{docker-Bw9gKo69.js → docker-BynKrOLe.js} +1 -1
- package/dist/packem_shared/{index-88UK-tt_.js → index-B_KtN1MB.js} +1 -1
- package/dist/packem_shared/{index-CS6a2wFB.js → index-efSniSRN.js} +1 -1
- package/dist/packem_shared/{lifecycle-ChCFTm5Q.js → lifecycle-CJRNbN3x.js} +2 -2
- package/dist/packem_shared/{min-release-age-heJgeP7o.js → min-release-age-aEn0x8Vy.js} +1 -1
- package/dist/packem_shared/{native-config-sync-BOeuyrBj.js → native-config-sync-DdhTLlKL.js} +1 -1
- package/dist/packem_shared/{osv-bloom-QSAn2Dcw.js → osv-bloom-BJhlc_I2.js} +2 -2
- package/dist/packem_shared/{pm-runner-BzGZmzYs.js → pm-runner-BwX5AL3W.js} +1 -1
- package/dist/packem_shared/{provenance-BsBn1f5S.js → provenance-BuiEsWbI.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-CBPr617N.js → resolve-explicit-RgRrUDZv.js} +1 -1
- package/dist/packem_shared/{s1ngularity-j_ArCZAs.js → s1ngularity-Bs9fUf3q.js} +1 -1
- package/dist/packem_shared/{scan-progress-EbvmIh4i.js → scan-progress-DjPT66jy.js} +2 -2
- package/dist/packem_shared/{signatures-CaXzNuEn.js → signatures-LYMy8OR5.js} +1 -1
- package/dist/packem_shared/{typosquats-C1e6RNjF.js → typosquats-znskIR5j.js} +1 -1
- package/dist/packem_shared/watch-BSVsZ_1I.js +1 -0
- package/dist/packem_shared/watch-loop-DLlMLg_J.js +11 -0
- package/index.js +751 -567
- package/package.json +11 -11
- package/schemas/project.schema.json +86 -1
- package/schemas/vis-config.schema.json +255 -7
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)){if(s.length===0)continue;const o=/^\s*(\d+)\s+(.+)$/.exec(s);if(!o)continue;const l=Number.parseInt(o[1]??"",10),d=(o[2]??"").toLowerCase();!Number.isFinite(l)||l===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(d)||/(?:^|[ /])vis\s+run\b/.test(d)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(d))&&i.push(l)}return i},"listOrphansUnix"),St=E(e=>{const t=vt("tasklist",["/FO","CSV","/NH"]),i=[];for(const s of t.split(/\r?\n/)){if(s.length===0)continue;const o=s.split(/","/).map(h=>h.replaceAll(/^"|"$/g,"")),l=(o[0]??"").toLowerCase(),d=Number.parseInt(o[1]??"",10);!Number.isFinite(d)||d===e||(l==="vis.exe"||l.startsWith("vis-native")||l.includes("task-runner"))&&i.push(d)}return i},"listOrphansWindows"),Ui=E(()=>{let e;try{const t=ze("watchman",["--version"],{encoding:"utf8",timeout:2e3});if(t.error||typeof t.status=="number"&&t.status!==0)throw t.error??new Error("watchman exited non-zero");e=typeof t.stdout=="string"?t.stdout.trim():void 0}catch{return{id:"watchman",message:"Watchman not found — `vis` uses native fs.watch (fine for small repos). Install Watchman + `fb-watchman` to scale watch mode on large monorepos.",status:"skip"}}return{detail:e?{version:e}:void 0,id:"watchman",message:e?`Watchman available (${e}) — scalable watch backend in use.`:"Watchman available — scalable watch backend in use.",status:"ok"}},"checkWatchmanAvailability"),_i=E((e=process.cwd())=>{let t="";try{t=mt(q(e,".gitattributes"),"utf8")}catch(i){if(i.code!=="ENOENT")return{id:"git-lfs",message:"Could not read .gitattributes.",status:"warn"}}if(!t.includes("filter=lfs"))return{id:"git-lfs",message:"No Git LFS tracking declared in .gitattributes.",status:"skip"};try{const i=ze("git",["lfs","version"],{encoding:"utf8",timeout:2e3});if(i.error||typeof i.status=="number"&&i.status!==0)throw i.error??new Error("git-lfs not available")}catch{return{id:"git-lfs",message:"Repo tracks files via Git LFS but `git-lfs` is not installed — checked-out LFS files are pointer stubs, not real content. Install git-lfs and run `git lfs pull`.",status:"warn"}}return{id:"git-lfs",message:"Git LFS tracking declared and `git-lfs` is installed.",status:"ok"}},"checkGitLfsTracking"),Gi=E(e=>[Oi(),Ni(),Ui(),_i(e),Mi()],"runRuntimeDiagnostics");var Hi=Object.defineProperty,ke=P((e,t)=>Hi(e,"name",{value:t,configurable:!0}),"s$2");const we=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],je=["dependencies","security","optimization","runtime"],me=ke(e=>{const t=new Map;for(const i of je)t.set(i,[]);for(const i of e)t.get(i.section).push(i);for(const[i,s]of t)s.length===0&&t.delete(i);return t},"groupBySection"),ye=ke((e,t,i,s)=>{let o=e.filter(l=>l.section===t);if(s&&(o=o.filter(l=>l.severity===s)),i){const l=i.toLowerCase();o=o.filter(d=>d.title.toLowerCase().includes(l))}return[...o]},"filterFindings"),Yi=ke(e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of je)e.has(i)&&(t[i]="idle");return t},"initialStatus");class nt{static{P(this,"DoctorStore")}static{ke(this,"DoctorStore")}#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,s=i.findings??[],o=i.activeSections??new Set(je),l=je.find(a=>o.has(a))??"dependencies",d=ye(s,l,"",void 0),h=Yi(o);if(s.length>0)for(const a of s)h[a.section]="done";this.#e={all:s,entries:d,filterActive:!1,filterText:"",filterType:l,focusedPanel:"list",grouped:me(d),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:h,selectedIndex:0,severityFilter:void 0}}getSnapshot=ke(()=>this.#e,"getSnapshot");subscribe=ke(t=>(this.#i.add(t),()=>{this.#i.delete(t)}),"subscribe");setSelectedIndex(t){const i=Math.max(0,Math.min(t,this.#e.entries.length-1));i!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:i})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const i=ye(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:me(i),selectedIndex:0})}setFilter(t){const i=ye(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:me(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=ye(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:me(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=ye(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:me(i),selectedIndex:0,severityFilter:t})}startSection(t,i){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,i){const s=[...this.#e.all,...i],o=ye(s,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),l={...this.#e.sectionMessage};delete l[t],this.#t({...this.#e,all:s,entries:o,grouped:me(o),sectionMessage:l,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,i){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const i of this.#i)try{i()}catch{}}}var Ki=Object.defineProperty,Ct=P((e,t)=>Ki(e,"name",{value:t,configurable:!0}),"r$1");const ot={error:0,warn:1},Wi=Ct(e=>!!e.acceptedRisk,"isAcknowledged"),xt=Ct(e=>{const t=[];if(e.sections.has("dependencies")){for(const i of e.outdated)t.push({entry:i,id:`outdated:${i.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${i.currentRange} → ${i.newRange} (${i.updateType})`,title:i.packageName});for(const i of e.duplicates)t.push({id:`duplicate:${i.name}`,kind:"duplicate",pkg:i,section:"dependencies",severity:"warn",subtitle:`${String(i.versions.length)} versions installed`,title:i.name})}if(e.sections.has("security"))for(const i of e.outdated){if(i.vulnerabilities&&i.vulnerabilities.length>0){const s=i.vulnerabilities[0],o=Wi(i)?"warn":"error",l=i.vulnerabilities.length;t.push({entry:i,id:`vuln:${i.packageName}`,kind:"vulnerability",packageName:i.packageName,section:"security",severity:o,subtitle:l===1?`${s.severity} · ${s.id}`:`${String(l)} advisories · top: ${s.severity} ${s.id}`,title:i.packageName})}if(i.socketReport&&i.socketReport.alerts.length>0){const s=Math.round(i.socketReport.score.overall*100);t.push({entry:i,id:`socket:${i.packageName}`,kind:"socket",packageName:i.packageName,section:"security",severity:"warn",subtitle:`${String(i.socketReport.alerts.length)} alert${i.socketReport.alerts.length===1?"":"s"} · score ${String(s)}%`,title:i.packageName})}}if(e.sections.has("optimization"))for(const i of e.optimizations)t.push({entry:i,id:`opt:${i.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${i.category} → ${i.replacement}`,title:i.packageName});if(e.sections.has("runtime"))for(const i of e.runtime)i.status==="warn"&&t.push({diagnostic:i,id:`runtime:${i.id}`,kind:"runtime",section:"runtime",severity:"warn",title:i.message});return t.sort((i,s)=>{if(i.section!==s.section){const o=["dependencies","security","optimization","runtime"];return o.indexOf(i.section)-o.indexOf(s.section)}return ot[i.severity]-ot[s.severity]}),t},"flattenFindings"),Rt={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"};var qi=Object.defineProperty,Ji=P((e,t)=>qi(e,"name",{value:t,configurable:!0}),"a$2");const Xi={error:"red",warn:"yellow"},Qi={error:"✖",warn:"⚠"},Zi={error:" ERROR ",warn:" WARN "},er=Ji(({children:e,hint:t,message:i,severity:s,title:o})=>{const l=Xi[s];return c(p,{borderColor:l,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[c(p,{gap:1,children:[r(n,{backgroundColor:l,bold:!0,color:"black",children:Zi[s]}),r(n,{bold:!0,color:l,children:Qi[s]}),r(n,{bold:!0,wrap:"truncate-end",children:o})]}),r(n,{wrap:"truncate-end",children:i}),t?r(n,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},"ConfigBanner");var tr=Object.defineProperty,te=P((e,t)=>tr(e,"name",{value:t,configurable:!0}),"d$2");const ir={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},rr={critical:"red",high:"red",low:"gray",medium:"yellow"},nr={major:"red",minor:"yellow",patch:"green"},A=te(({children:e,label:t,width:i=14})=>c(p,{children:[r(p,{width:i,children:c(n,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?r(n,{children:e}):e]}),"FieldRow"),oe=te(({children:e})=>r(p,{marginTop:1,children:r(n,{bold:!0,color:"white",children:e})}),"SectionTitle"),or=te(({finding:e})=>{const{entry:t}=e,i=nr[t.updateType]??"white";return c(p,{flexDirection:"column",children:[r(A,{label:"Current",children:t.currentRange}),c(A,{label:"Target",children:[r(n,{children:t.newRange}),c(n,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),r(A,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?r(A,{label:"Risk ack",children:r(n,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,r(oe,{children:"Action"}),c(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},"OutdatedDetail"),sr=te(({finding:e})=>c(p,{flexDirection:"column",children:[r(A,{label:"Versions",children:r(n,{children:String(e.pkg.versions.length)})}),r(oe,{children:"Installed versions"}),e.pkg.versions.map(t=>c(n,{children:[" · ",t]},t)),r(oe,{children:"Action"}),c(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),"DuplicateDetail"),lr=te(({finding:e})=>{const t=e.entry.vulnerabilities??[];return c(p,{flexDirection:"column",children:[r(A,{label:"Package",children:e.packageName}),r(A,{label:"Current",children:e.entry.currentRange}),r(A,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?r(A,{label:"Risk ack",children:r(n,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const s=ir[i.severity]??"gray";return c(p,{flexDirection:"column",marginTop:1,children:[c(p,{children:[r(n,{bold:!0,color:s,children:i.severity}),r(n,{children:" "}),r(n,{children:i.id}),typeof i.cvssScore=="number"?c(n,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),r(n,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?c(n,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?c(n,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},"VulnerabilityDetail"),ar=te(({finding:e})=>{const t=e.entry.socketReport;if(!t)return r(n,{dimColor:!0,children:"No Socket report attached."});const i=Math.round(t.score.overall*100),s=Je(t.score.overall);return c(p,{flexDirection:"column",children:[r(A,{label:"Package",children:e.packageName}),r(A,{label:"Overall",children:c(n,{color:s,children:[String(i),"%"]})}),r(A,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?r(A,{label:"Risk ack",children:r(n,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,r(oe,{children:"Score breakdown"}),Object.entries(t.score).map(([o,l])=>{if(o==="overall")return null;const d=typeof l=="number"?l:0,h=Math.round(d*100),a=Je(d);return c(p,{children:[r(p,{width:14,children:c(n,{dimColor:!0,children:[o,":"]})}),c(n,{color:a,children:[String(h),"%"]})]},o)}),r(oe,{children:"Alerts"}),t.alerts.map((o,l)=>{const d=rr[o.severity]??"gray";return c(p,{flexDirection:"column",marginBottom:1,children:[c(p,{children:[r(n,{bold:!0,color:d,children:o.severity}),r(n,{children:" "}),r(n,{children:o.type})]}),o.props?r(n,{dimColor:!0,wrap:"wrap",children:JSON.stringify(o.props)}):null]},`${o.type}-${String(l)}`)})]})},"SocketDetail"),cr=te(({finding:e})=>{const{entry:t}=e;return c(p,{flexDirection:"column",children:[r(A,{label:"Package",children:t.packageName}),r(A,{label:"Category",children:t.category}),r(A,{label:"Replacement",children:t.replacement}),t.overrideSpec?r(A,{label:"Override",children:t.overrideSpec}):null,r(A,{label:"Codemod",children:r(n,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?r(A,{label:"Guide",children:r(n,{color:"cyan",underline:!0,children:t.docUrl})}):null,r(oe,{children:"Action"}),t.hasCodemod?c(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?c(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?r(n,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):r(n,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},"OptimizationDetail"),dr=te(({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return c(p,{flexDirection:"column",children:[r(A,{label:"Check",children:t.id}),r(A,{label:"Status",children:r(n,{color:i,children:t.status})}),r(oe,{children:"Message"}),r(n,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?c(gi,{children:[r(oe,{children:"Details"}),Object.entries(t.detail).map(([s,o])=>c(p,{children:[r(p,{width:20,children:c(n,{dimColor:!0,children:[s,":"]})}),r(n,{children:String(o)})]},s))]}):null]})},"RuntimeDetail"),ur=te(({finding:e,focused:t,scrollRef:i})=>{const s=t?"white":"gray";if(!e)return r(p,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:r(n,{dimColor:!0,children:"No finding selected"})});let o;switch(e.kind){case"duplicate":{o=r(sr,{finding:e});break}case"optimization":{o=r(cr,{finding:e});break}case"outdated":{o=r(or,{finding:e});break}case"runtime":{o=r(dr,{finding:e});break}case"socket":{o=r(ar,{finding:e});break}case"vulnerability":{o=r(lr,{finding:e});break}default:{o=r(n,{dimColor:!0,children:"Unknown finding kind."});break}}return c(p,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c(p,{flexShrink:0,paddingTop:1,paddingX:2,children:[r(n,{bold:!0,color:"white",children:e.title}),c(n,{dimColor:!0,children:[" ",Rt[e.section]]})]}),c(ki,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[r(n,{}),o]})]})},"DoctorDetailPanel");var pr=Object.defineProperty,Oe=P((e,t)=>pr(e,"name",{value:t,configurable:!0}),"c$2");const Tt={error:"red",warn:"yellow"},hr={error:"✖",warn:"⚠"},gr=Oe(e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,"hasAcceptedRisk"),fr=Oe(({finding:e,isSelected:t})=>{const i=Tt[e.severity],s=gr(e);return c(p,{flexShrink:0,height:1,children:[r(n,{children:t?">":" "}),c(n,{color:i,children:[" ",hr[e.severity]," "]}),r(p,{flexGrow:1,children:r(n,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),s?r(n,{color:"cyan",children:" ack"}):null,e.subtitle?c(n,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},"FindingRow"),mr=Oe(({count:e,section:t})=>c(p,{flexShrink:0,height:1,marginTop:1,children:[r(n,{dimColor:!0,children:"▼ "}),r(n,{bold:!0,color:"white",children:Rt[t].toUpperCase()}),c(n,{dimColor:!0,children:[" (",e,")"]})]}),"SectionHeader"),yr=Oe(({count:e,label:t,status:i})=>c(n,{children:[t,i==="running"?c(n,{children:[" ",r(bt,{type:"dots"})]}):null,i==="error"?r(n,{bold:!0,color:"red",children:" ✖"}):c(n,{dimColor:!0,children:[" (",String(e),")"]})]}),"TabLabel"),wr=Oe(({elapsedMs:e,entries:t,filterActive:i,filterText:s,filterType:o,focused:l,fromCache:d=!1,grouped:h,onViewportHeightChange:a,scrollOffset:f,sectionCounts:k,sectionMessage:v,sectionStatus:I,selectedIndex:z,severityFilter:g,totalAll:D,viewportHeight:B})=>{const J=l?"white":"gray",{measuredHeight:V,ref:L}=Si(B,a);let R=0,_=0;for(const S of t)S.severity==="error"?R+=1:S.severity==="warn"&&(_+=1);const G=[];R>0&&G.push(`${String(R)} error${R===1?"":"s"}`),_>0&&G.push(`${String(_)} warn${_===1?"":"s"}`);const se=G.length>0?` (${G.join(", ")})`:"",ie=(e/1e3).toFixed(1),U=[];for(const[S,C]of h){U.push(r(mr,{count:C.length,section:S},`hdr-${S}`));for(const X of C){const T=t.indexOf(X);U.push(r(fr,{finding:X,isSelected:T===z},X.id))}}let j=0;for(const[,S]of h)j+=2+S.length;const Y=j>V&&V>0;return c(p,{borderColor:J,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c(p,{flexShrink:0,gap:1,paddingX:1,children:[r(n,{bold:!0,inverse:!0,children:" DOCTOR "}),c(n,{wrap:"truncate",children:[t.length,t.length===D?"":`/${String(D)}`," finding",t.length===1?"":"s",se]}),g?r(n,{bold:!0,color:Tt[g],inverse:!0,children:` ${g.toUpperCase()} ONLY `}):null,d?r(n,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,c(n,{dimColor:!0,children:[" · ",ie,"s"]})]}),r(p,{flexShrink:0,paddingX:1,paddingY:1,children:r($i,{isFocused:l,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:P(()=>{},"onChange"),showIndex:!1,value:o,children:we.map(({id:S,label:C})=>r(vi,{name:S,children:r(yr,{count:k[S],label:C,status:I[S]})},S))})}),(()=>{const S=Object.keys(I).filter(C=>I[C]==="running"&&v[C]).map(C=>v[C]);return S.length===0?null:r(p,{flexShrink:0,paddingX:1,children:c(n,{dimColor:!0,wrap:"truncate",children:[r(bt,{type:"dots"})," ",S.join(" · ")]})})})(),i&&c(p,{flexShrink:0,paddingX:1,children:[r(n,{bold:!0,color:"white",children:"/ "}),r(n,{children:s}),r(n,{inverse:!0,children:" "})]}),c(p,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:L,children:[r(p,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:r(p,{flexDirection:"column",marginTop:-f,children:U.length>0?U:r(p,{marginTop:1,children:r(n,{dimColor:!0,children:"No findings match the current filter."})})})}),Y&&r(p,{flexShrink:0,marginLeft:1,marginRight:1,children:r(bi,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:V})})]},`list-${o}-${s}`)]})},"DoctorListPanel");var kr=Object.defineProperty,Be=P((e,t)=>kr(e,"name",{value:t,configurable:!0}),"g$1");const br=Be(e=>{if(e.kind==="outdated")return{command:`vis update ${e.entry.packageName}`,description:`Update ${e.entry.packageName} to ${e.entry.newRange}`};if(e.kind==="duplicate")return{command:`vis dedupe ${e.pkg.name}`,description:`Dedupe ${e.pkg.name} (${String(e.pkg.versions.length)} versions)`}},"buildUpdateAction"),vr=Be(e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},"buildOptimizeAction"),$r=Be(e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,i=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
|
|
3
|
-
`);return{command:i,configSnippet:i,description:`Acknowledge risk for ${t}`}},"buildAckAction"),Sr=100,Cr=40,xr=10,Rr=Be(({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:s,store:o})=>{const{exit:l}=mi(),{columns:d,rows:h}=wi(),a=Xt(o.subscribe,o.getSnapshot),[f,k]=Re(!1),[v,I]=Re(!1),[z,g]=Re(0),[D,B]=Re(()=>Date.now());Qe(()=>{const w=setInterval(()=>{B(Date.now())},1e3);return()=>{clearInterval(w)}},[]);const J=D-s,V=Ze(null),L=Ze(null),R=a.entries[a.selectedIndex]??null,_=Ue(()=>{const w={dependencies:0,optimization:0,runtime:0,security:0};for(const y of a.all)w[y.section]+=1;return w},[a.all]),G=t?t.hint?5:4:0,se=Ue(()=>{for(const w of Object.keys(a.sectionStatus))if(a.sectionStatus[w]==="running"&&a.sectionMessage[w])return 1;return 0},[a.sectionStatus,a.sectionMessage]),ie=d>=Sr,U=ie?Math.max(1,h-G-2):Math.floor(h*.55),j=Math.max(1,U-6-se-(a.filterActive?1:0)),[Y,S]=Re(j),C=Y>0?Y:j,X=Ue(()=>{let w=0;for(const[,y]of a.grouped)w+=2+y.length;return w},[a.grouped]),T=Math.max(0,X-C),le=Math.min(z,T),ue=et(w=>{let y=0,b=0;for(const[,Ce]of a.grouped){y+=2;for(let ae=0;ae<Ce.length;ae++){if(b===w)return y;y+=1,b+=1}}return y},[a.grouped]),O=et(w=>{const y=ue(w);g(b=>y>b+C-2?Math.min(T,Math.max(0,y-C+2)):y<b+1?Math.max(0,y-1):b)},[ue,C,T]);if(Qe(()=>{L.current?.scrollToTop()},[R?.id]),yi((w,y)=>{if(w==="c"&&y.ctrl){l();return}if(!v){if(f){y.escape||w==="?"?k(!1):w==="q"?(k(!1),I(!0)):y.downArrow||w==="j"?V.current?.scrollBy(1):(y.upArrow||w==="k")&&V.current?.scrollBy(-1);return}if(w==="?"){k(!0);return}if(w==="q"){I(!0);return}if(y.tab){o.setFocusedPanel(a.focusedPanel==="list"?"detail":"list");return}if(a.filterActive){if(y.escape||y.return){o.setFilterActive(!1);return}if(y.backspace){g(0),o.setFilter(a.filterText.slice(0,-1));return}w&&!y.ctrl&&!y.meta&&(g(0),o.setFilter(a.filterText+w));return}if(a.focusedPanel==="list"&&(y.leftArrow||y.rightArrow)){const b=we.findIndex(ae=>ae.id===a.filterType),Ce=y.rightArrow?(b+1)%we.length:(b-1+we.length)%we.length;g(0),L.current?.scrollToTop(),o.setFilterType(we[Ce].id);return}if(a.focusedPanel==="list"){if(y.downArrow||w==="j"){const b=Math.min(a.selectedIndex+1,a.entries.length-1);o.setSelectedIndex(b),O(b);return}if(y.upArrow||w==="k"){const b=Math.max(a.selectedIndex-1,0);o.setSelectedIndex(b),O(b);return}if(y.pageDown){const b=Math.min(a.selectedIndex+10,a.entries.length-1);o.setSelectedIndex(b),O(b);return}if(y.pageUp){const b=Math.max(a.selectedIndex-10,0);o.setSelectedIndex(b),O(b);return}if(y.home){o.setSelectedIndex(0),g(0);return}if(y.end){const b=a.entries.length-1;o.setSelectedIndex(b),O(b);return}if(w==="/"){o.setFilterActive(!0);return}if(w==="e"){o.setSeverityFilter(a.severityFilter==="error"?void 0:"error"),g(0);return}if(w==="w"){o.setSeverityFilter(a.severityFilter==="warn"?void 0:"warn"),g(0);return}if(w==="u"&&R){const b=br(R);b&&(o.setPendingAction(b),l());return}if(w==="o"&&R){const b=vr(R);b&&(o.setPendingAction(b),l());return}if(w==="a"&&R){const b=$r(R);b&&(o.setPendingAction(b),l());return}if(w==="d"){o.setFocusedPanel("detail");return}return}if(y.escape||y.leftArrow){o.setFocusedPanel("list");return}if(y.downArrow||w==="j"){L.current?.scrollBy(1);return}if(y.upArrow||w==="k"){L.current?.scrollBy(-1);return}if(y.pageDown){L.current?.scrollBy(10);return}if(y.pageUp){L.current?.scrollBy(-10);return}if(y.home){L.current?.scrollToTop();return}y.end&&L.current?.scrollToBottom()}},{isActive:!0}),d<Cr||h<xr)return r(p,{alignItems:"center",height:h,justifyContent:"center",width:d,children:c(n,{color:"yellow",children:["Terminal too small (",d,"x",h,")"]})});const Q=a.focusedPanel==="detail",ee=[c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"q"}),r(n,{dimColor:!0,children:"QUIT"})]},"q"),c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"?"}),r(n,{dimColor:!0,children:"HELP"})]},"?"),c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"↑↓"}),r(n,{dimColor:!0,children:Q?"SCROLL":"NAV"})]},"nav"),Q?c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←/Esc"}),r(n,{dimColor:!0,children:"LIST"})]},"lr"):c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←→"}),r(n,{dimColor:!0,children:"SECTION"})]},"lr"),c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"/"}),r(n,{dimColor:!0,children:"SEARCH"})]},"search"),c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"e/w"}),r(n,{dimColor:!0,children:"SEVERITY"})]},"sev"),c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"u/o/a"}),r(n,{dimColor:!0,children:"ACTION"})]},"actions"),c(p,{gap:1,children:[r(n,{bold:!0,color:"white",children:"Tab"}),r(n,{dimColor:!0,children:"PANEL"})]},"tab")],pe=r(p,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(p,{gap:2,overflow:"hidden",paddingX:1,children:ee})}),he=c(fi,{footer:c(n,{dimColor:!0,children:[r(n,{bold:!0,color:"white",children:"↑↓"})," scroll ",r(n,{bold:!0,color:"white",children:"?"}),"/",r(n,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:V,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:f,width:56,children:[c(p,{flexDirection:"column",marginBottom:1,children:[c(p,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"NAVIGATION"})]}),c(p,{children:[r(p,{width:26,children:c(n,{children:[r(n,{bold:!0,color:"white",children:" ↑/k "}),r(n,{dimColor:!0,children:"Move up"})]})}),c(n,{children:[r(n,{bold:!0,color:"white",children:" ↓/j "}),r(n,{dimColor:!0,children:"Move down"})]})]}),c(p,{children:[r(p,{width:26,children:c(n,{children:[r(n,{bold:!0,color:"white",children:" PgUp"}),r(n,{dimColor:!0,children:" Jump up 10"})]})}),c(n,{children:[r(n,{bold:!0,color:"white",children:" PgDn"}),r(n,{dimColor:!0,children:" Jump down 10"})]})]}),c(p,{children:[r(p,{width:26,children:c(n,{children:[r(n,{bold:!0,color:"white",children:" Home"}),r(n,{dimColor:!0,children:" Jump to top"})]})}),c(n,{children:[r(n,{bold:!0,color:"white",children:" End"}),r(n,{dimColor:!0,children:" Jump to bottom"})]})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" Tab"}),r(n,{dimColor:!0,children:" Switch panel"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" →/←"}),r(n,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),c(p,{flexDirection:"column",marginBottom:1,children:[c(p,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"FILTER"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" /"}),r(n,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" e"}),r(n,{dimColor:!0,children:" Toggle errors-only filter"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" w"}),r(n,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),c(p,{flexDirection:"column",marginBottom:1,children:[c(p,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"ACTIONS"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" u"}),r(n,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" o"}),r(n,{dimColor:!0,children:" Exit + suggest optimize command"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" a"}),r(n,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" d"}),r(n,{dimColor:!0,children:" Focus detail panel"})]})]}),c(p,{flexDirection:"column",children:[c(p,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"EXIT"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" q"}),r(n,{dimColor:!0,children:" Quit (with countdown)"})]}),c(n,{children:[r(n,{bold:!0,color:"white",children:" Ctrl+C"}),r(n,{dimColor:!0,children:" Quit immediately"})]})]})]}),ge=r(wr,{elapsedMs:J,entries:a.entries,filterActive:a.filterActive,filterText:a.filterText,filterType:a.filterType,focused:a.focusedPanel==="list",fromCache:i,grouped:a.grouped,onViewportHeightChange:S,scrollOffset:le,sectionCounts:_,sectionMessage:a.sectionMessage,sectionStatus:a.sectionStatus,selectedIndex:a.selectedIndex,severityFilter:a.severityFilter,totalAll:a.all.length,viewportHeight:C}),fe=t?r(er,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,Se=r(ur,{finding:R,focused:a.focusedPanel==="detail",scrollRef:L});if(ie){const w=Math.floor(d*.4);return c(p,{flexDirection:"column",height:h,width:d,children:[fe,c(p,{flexDirection:"row",flexGrow:1,children:[r(p,{flexGrow:1,children:ge}),r(p,{width:w,children:Se})]}),pe,r(Xe,{autoExitSeconds:e||3,onCancel:P(()=>{I(!1)},"onCancel"),visible:v}),he]})}return c(p,{flexDirection:"column",height:h,width:d,children:[fe,r(p,{height:U,children:ge}),r(p,{flexGrow:1,children:Se}),pe,r(Xe,{autoExitSeconds:e||3,onCancel:P(()=>{I(!1)},"onCancel"),visible:v}),he]})},"VisDoctorApp");var Tr=Object.defineProperty,ve=P((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"n");const Ar=ve(e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),"escapeRegex"),Pr=ve(e=>{const t=e.split("*").map(i=>Ar(i));return new RegExp(`^${t.join(".*")}$`,"i")},"compilePattern"),Ir=ve(e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>Pr(t)):[],"parseFilterPatterns"),Me=ve((e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},"matchesAny"),Dr=ve((e,t,i)=>{if(t.length===0)return e;const s=e.outdated.filter(f=>Me(f.packageName,t)),o=e.duplicates.filter(f=>Me(f.name,t)),l=e.optimizations.filter(f=>Me(f.packageName,t));let d=0,h=0,a=0;for(const f of s)f.vulnerabilities&&(d+=f.vulnerabilities.length),f.socketReport&&(h+=f.socketReport.alerts.length,f.socketReport.score.overall<i&&(a+=1));return{...e,duplicates:o,optimizations:l,outdated:s,socketIssues:{alerts:h,lowScore:a},vulnCount:d}},"applyFilter"),At=ve((e,t)=>t.length===0?[...e]:e.filter(i=>{if(i.kind==="runtime")return!0;const s=i.kind==="duplicate"?i.pkg.name:i.kind==="outdated"||i.kind==="optimization"?i.entry.packageName:i.packageName;return Me(s,t)}),"filterFindingsByPattern");var Or=Object.defineProperty,$e=P((e,t)=>Or(e,"name",{value:t,configurable:!0}),"r");const Pt=["dependencies","security","optimization","runtime"],st=$e(e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const s=i.trim().toLowerCase();Pt.includes(s)&&t.add(s)}return t},"parseSectionList"),Nr=$e((e,t)=>{if(e!==void 0&&e!=="")return st(e);const i=st(t);return new Set(Pt.filter(s=>!i.has(s)))},"resolveSections"),It=$e(e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const i of e)switch(i.category){case"micro-utility":{t.micro+=1;break}case"native":{t.native+=1;break}case"preferred":{t.preferred+=1;break}case"socket":{t.socket+=1;break}}return t},"summarizeOptimizations"),ne=$e((e,t)=>{if(!e.sections.has(t))return"skip";switch(t){case"dependencies":return e.outdated.length>0||e.duplicates.length>0?"warn":"ok";case"optimization":return e.optimizations.length>0?"warn":"ok";case"runtime":return e.runtime.some(i=>i.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},"sectionStatus"),Fr=$e((e,t)=>{const i=It(e.optimizations),s={dependencies:ne(e,"dependencies"),optimization:ne(e,"optimization"),runtime:ne(e,"runtime"),security:ne(e,"security")},o=new Set([...Object.values(s),e.supplyChain.status]),l=o.has("error")?"error":o.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:s.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:i.micro,native:i.native,preferred:i.preferred,socket:i.socket,status:s.optimization,total:i.total},packageManager:t,runtime:e.runtime.map(d=>({detail:d.detail,id:d.id,message:d.message,status:d.status})),runtimeStatus:s.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:s.security,vulnerabilities:e.vulnCount},status:l,supplyChain:{findings:e.supplyChain.findings.map(d=>({detail:d.detail,label:d.label,severity:d.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},"buildJsonPayload"),lt=$e((e,t)=>{const i=e.runtime.some(o=>o.status==="warn"),s=e.vulnCount>0||e.socketIssues.alerts>0;return t?s||e.outdated.length>0||e.duplicates.length>0||i:s},"shouldFail");var Mr=Object.defineProperty,Le=P((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"u$1");const jr=["aube-workspace.yaml","pnpm-workspace.yaml"],Te=Le(e=>typeof e=="boolean"?e:void 0,"asBool"),Er=Le(e=>{if(e==="no-downgrade"||e==="off")return e},"asTrustPolicy"),zr=Le(e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const i of jr){const s=q(e,i);if(!Ie(s))continue;let o;try{o=Lt(Kt(s))}catch{continue}if(typeof o!="object"||o===null)continue;const l=o;return t.source=i,t.paranoid=Te(l.paranoid),t.trustPolicy=Er(l.trustPolicy),t.blockExoticSubdeps=Te(l.blockExoticSubdeps),t.jailBuilds=Te(l.jailBuilds),t.strictDepBuilds=Te(l.strictDepBuilds),t.minimumReleaseAgeStrict=Te(l.minimumReleaseAgeStrict),typeof l.minimumReleaseAge=="number"&&Number.isFinite(l.minimumReleaseAge)&&(t.minimumReleaseAge=l.minimumReleaseAge),l.allowBuilds&&typeof l.allowBuilds=="object"&&!Array.isArray(l.allowBuilds)&&(t.allowBuildsCount=Object.keys(l.allowBuilds).length),t}return t},"readAubeSecurityPosture"),Br=Le(e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,"applyAubeParanoidOverrides");var Lr=Object.defineProperty,Ge=P((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"i");const Vr=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,Ur=Ge(e=>{const t=Vr.exec(e);if(t)return{name:t[1],version:t[2]}},"parsePatchKey"),_r=Ge((e,t)=>{let i;try{if(t==="pnpm"){const o=q(e,"pnpm-workspace.yaml");Ie(o)&&(i=Vt(o)?.patchedDependencies)}else if(t==="bun"){const o=q(e,"package.json");Ie(o)&&(i=yt(o)?.patchedDependencies)}}catch{return[]}if(!i||typeof i!="object")return[];const s=[];for(const[o,l]of Object.entries(i)){if(typeof l!="string"||l.length===0)continue;const d=Ur(o);d&&s.push({name:d.name,patchFile:l,resolvedPatchFile:Wt(l)?l:ft(e,l),version:d.version})}return s},"readPatchedDependencies"),Gr=Ge(e=>{const t=[];for(const i of e)Ie(i.resolvedPatchFile)||t.push({entry:i,kind:"missing-file"});return t},"findPatchIssues");var Hr=Object.defineProperty,Dt=P((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"c");const at=Dt(e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok","rollUpStatus"),Yr=Dt((e,t={})=>{const i=[],s=e?.security;if(!s)return i.push({detail:"Use defineConfig() from '@visulima/vis/config' to apply secure defaults.",label:"No security config — running with the PM's native defaults",severity:"warn"}),{findings:i,status:at(i)};const o=s.policies?.firstSeen?.minutes,l=s.policies?.publisherChange,d=s.policies?.installScripts;o===void 0?i.push({detail:"Set security.policies.firstSeen.minutes to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"policies.firstSeen.minutes is not set",severity:"warn"}):o===0?i.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"policies.firstSeen.minutes is explicitly 0",severity:"warn"}):i.push({label:`policies.firstSeen.minutes: ${String(o)} minutes`,severity:"ok"}),l?.mode===void 0||l.mode==="off"?i.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`policies.publisherChange.mode: ${l?.mode??"not set"}`,severity:"warn"}):i.push({label:`policies.publisherChange.mode: ${l.mode}`,severity:"ok"}),s.blockExoticSubdeps===void 0||!s.blockExoticSubdeps?i.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(s.blockExoticSubdeps??!1)}`,severity:"warn"}):i.push({label:"blockExoticSubdeps: true",severity:"ok"});const h=d?.allow?Object.keys(d.allow).length:0;if(h===0?i.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"policies.installScripts.allow: not configured",severity:"warn"}):i.push({label:`policies.installScripts.allow: ${String(h)} ${h===1?"entry":"entries"}`,severity:"ok"}),d?.strict&&h===0&&i.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate the allow list.",label:"policies.installScripts.strict is on but allow is empty",severity:"error"}),t.workspaceRoot){const a=Ci(t.workspaceRoot);if(a.length>0){const f=[...new Set(a.map(k=>k.tool))].sort((k,v)=>k.localeCompare(v)).join(", ");i.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(a.length)} leftover ${a.length===1?"reference":"references"} to ${f}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const a=zr(t.workspaceRoot),f=Br(a),k=f.source?` (from ${f.source})`:"";f.paranoid===!0&&i.push({detail:"Forces jailBuilds, trustPolicy=no-downgrade, minimumReleaseAgeStrict, strictStoreIntegrity, and strictDepBuilds on.",label:`aube paranoid: true${k}`,severity:"ok"}),f.trustPolicy==="off"&&i.push({detail:"Trust downgrades between releases will not be blocked. Set trustPolicy: no-downgrade in aube-workspace.yaml.",label:`aube trustPolicy: off${k}`,severity:"warn"}),f.blockExoticSubdeps===!1&&i.push({detail:"Transitive deps from git+, file:, and tarball URLs will not be blocked. Re-enable with blockExoticSubdeps: true.",label:`aube blockExoticSubdeps: false${k}`,severity:"warn"}),f.minimumReleaseAge===0&&i.push({detail:"Newly published versions are not held in a cooling window. Restore with minimumReleaseAge: 1440 (24h) or higher.",label:`aube minimumReleaseAge: 0${k}`,severity:"warn"}),f.jailBuilds===!0&&i.push({label:`aube jailBuilds: true${k}`,severity:"ok"}),f.strictDepBuilds===!0&&i.push({label:`aube strictDepBuilds: true${k}`,severity:"ok"}),f.allowBuildsCount>0&&i.push({label:`aube allowBuilds: ${String(f.allowBuildsCount)} ${f.allowBuildsCount===1?"entry":"entries"}${k}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const a=_r(t.workspaceRoot,t.packageManager);if(a.length>0){const f=Gr(a);if(f.length===0)i.push({label:`patchedDependencies: ${String(a.length)} ${a.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const k of f)i.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${k.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${k.entry.name}@${k.entry.version}`,severity:"error"})}}return{findings:i,status:at(i)}},"buildSupplyChainPosture");var Kr=Object.defineProperty,x=P((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"u");const H=x(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,"fmtDuration"),Ne=x(async(e,t,i,s)=>{if(!e)return i();e.start(t);const o=Date.now();try{const l=await i(),d=Date.now()-o,{status:h,summary:a}=s(l,d);return e.finish(t,h,a),l}catch(l){const d=Date.now()-o,h=l instanceof Error?l.message:String(l);throw e.finish(t,"error",`${h} (${H(d)})`),l}},"tracked"),Wr=x((e,t)=>{const i={duplicates:t.duplicates,elapsedMs:0,installedCount:0,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e]),socketIssues:{alerts:0,lowScore:0},supplyChain:{findings:[],status:"ok"},vulnCount:0,workspaceCount:0};return xt(i)},"buildSectionFindings"),ct=x(async e=>{const{filterPatterns:t,installed:i,progress:s,resolveCodemods:o,sections:l,store:d,visConfig:h,workspaceRoot:a}=e,f=l.has("dependencies"),k=l.has("security"),v=l.has("optimization"),I=l.has("runtime"),z=x((m,N)=>At(Wr(m,N),t),"sectionFindings"),g=kt(a),{packageManager:D}=ut(a),B=it(q(a,"package.json"),!1),J=wt(a),V=new Set(B);for(const m of J){const N=it(q(ft(a,m),"package.json"),!1);for(const F of N)V.add(F)}const L=Ut(a),R=pt(a,D),_=ht(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),G=h?.security?.policies?.score?.minimum??gt,se=h?.security?.acceptedRisks,ie=ii(a,g.name),U={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},j=f?ui(a,g.name):[],Y=v?ri(V):[],S=v?ni(V,ie,g,!1):[],C=new Set(Y.map(m=>m.packageName)),X=S.filter(m=>!C.has(m.packageName)),T=[...Y,...X],le=I?Gi(a):[];d&&(f&&d.startSection("dependencies",R.size>0?"checking outdated catalog dependencies":"scanning duplicates"),k&&d.startSection("security",i.length>0?`scanning ${String(i.length)} packages for advisories`:"no installed packages to scan"),v&&d.startSection("optimization","matching e18e + socket overrides"),I&&d.startSection("runtime","running runtime diagnostics")),d&&I&&d.completeSection("runtime",z("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:le}));const ue=(f||k)&&R.size>0?Ne(s,"outdated",()=>_t(R,U,L,void 0,a,_,se),(m,N)=>{const F=m.outdated.length;return{status:F>0?"warn":"ok",summary:F>0?`${String(F)} outdated · ${H(N)}`:`up to date · ${H(N)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),O=k&&i.length>0?Ne(s,"vulnerabilities",()=>Gt(i.map(m=>({name:m.name,version:m.version}))),(m,N)=>{let F=0;for(const re of m.values())F+=re.length;return{status:F>0?"error":"ok",summary:F>0?`${String(F)} found · ${H(N)}`:`none found · ${H(N)}`}}):Promise.resolve(new Map),Q=k&&_.length>0&&i.length>0?Ne(s,"socket",()=>Ht(_,i.map(m=>({name:m.name,version:m.version}))),(m,N)=>{let F=0,re=0;for(const qe of m.values())F+=qe.alerts.length,qe.score.overall<G&&(re+=1);const We=F+re;return{status:We>0?"warn":"ok",summary:We>0?`${String(F)} alert${F===1?"":"s"}, ${String(re)} low-score · ${H(N)}`:`clean · ${H(N)}`}}):Promise.resolve(new Map);let ee,pe,he,ge;const fe=ue.catch(m=>(ee=m instanceof Error?m.message:String(m),d||u.warn(`Outdated scan failed: ${ee}`),{failed:[],ignored:[],outdated:[]})),Se=O.catch(m=>(pe=m instanceof Error?m.message:String(m),d||u.warn(`Vulnerability scan failed: ${pe}`),new Map)),w=Q.catch(m=>(he=m instanceof Error?m.message:String(m),d||u.warn(`Socket scan failed: ${he}`),new Map)),y=d&&f?fe.then(m=>{if(ee){d.failSection("dependencies",ee);return}d.completeSection("dependencies",z("dependencies",{duplicates:j,optimizations:[],outdated:m.outdated,runtime:[]}))}):void 0,b=d&&k?Promise.all([fe,Se,w]).then(([m])=>{const N=ee??pe??he;if(N){d.failSection("security",N);return}d.completeSection("security",z("security",{duplicates:[],optimizations:[],outdated:m.outdated,runtime:[]}))}):void 0,Ce=(async()=>{if(o&&v&&T.length>0&&await Ne(s,"codemods",async()=>(await oi(T),T),(m,N)=>{const F=m.filter(re=>re.hasCodemod||re.category==="socket").length;return{status:"ok",summary:`${String(F)} auto-fixable · ${H(N)}`}}).catch(m=>{ge=m instanceof Error?m.message:String(m)}),d&&v){if(ge){d.failSection("optimization",ge);return}d.completeSection("optimization",z("optimization",{duplicates:[],optimizations:T,outdated:[],runtime:[]}))}})(),[ae,Nt,Ft]=await Promise.all([fe,Se,w]);await Promise.all([y,b,Ce]);let Ye=0,Ke=0;if(k&&_.length>0)for(const m of Ft.values())Ye+=m.alerts.length,m.score.overall<G&&(Ke+=1);let Ve=0;if(k){for(const m of ae.outdated)m.vulnerabilities&&m.vulnerabilities.length>0&&(Ve+=m.vulnerabilities.length);for(const m of Nt.values())Ve+=m.length}return{duplicates:j,installedCount:i.length,optimizations:v?T:[],outdated:f?ae.outdated:[],runtime:le,sections:l,socketIssues:{alerts:Ye,lowScore:Ke},supplyChain:Yr(h,{packageManager:D,workspaceRoot:a}),vulnCount:Ve,workspaceCount:J.length}},"streamScans"),qr=x(e=>{switch(e){case"error":return Ae(M.failure);case"skip":return $(M.dash);case"warn":return Ee(M.warning);default:return be(M.success)}},"sectionIcon"),de=x((e,t)=>{const i=process.stderr.columns??80,s=Math.max(20,Math.min(i-2,60)),o=M.dash.repeat(2),l=`${qr(t)} ${ce(e)}`,d=l.replaceAll(/\[[0-9;]*m/g,"").length,h=Math.max(0,s-d-o.length-2);return`${o} ${l} ${$(M.dash.repeat(h))}`},"heading"),W=x(e=>` ${be(M.success)} ${e}`,"itemOk"),Z=x(e=>` ${Ee(M.warning)} ${e}`,"itemWarn"),He=x(e=>` ${Ae(M.failure)} ${e}`,"itemError"),Ot=x(e=>` ${$(M.dash)} ${$(e)}`,"itemSkip"),K=x((e,t,i)=>{const s=`${ce(String(e))} ${$(t)}`;return i?`${s} ${$(`(${i})`)}`:s},"countLine"),Jr=x(e=>{if(e.sections.has("dependencies")){if(u.log(""),u.log(de("Dependencies",ne(e,"dependencies"))),u.log(W(K(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(l=>l.updateType==="major").length,i=e.outdated.filter(l=>l.updateType==="minor").length,s=e.outdated.filter(l=>l.updateType==="patch").length,o=[];t>0&&o.push(`${String(t)} major`),i>0&&o.push(`${String(i)} minor`),s>0&&o.push(`${String(s)} patch`),u.log(Z(K(e.outdated.length,"outdated",o.join(", "))))}else u.log(W("All dependencies up to date"));e.duplicates.length>0?u.log(Z(K(e.duplicates.length,"packages with duplicate versions"))):u.log(W("No duplicate dependencies"))}},"displayDependencies"),Xr=x(e=>{e.sections.has("security")&&(u.log(""),u.log(de("Security",ne(e,"security"))),e.vulnCount>0?u.log(He(K(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):u.log(W("No known vulnerabilities")),e.socketIssues.alerts>0&&u.log(Z(K(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&u.log(Z(K(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&u.log(W("No security issues detected")))},"displaySecurity"),Qr=x(e=>{if(!e.sections.has("optimization"))return;u.log(""),u.log(de("Optimization",ne(e,"optimization")));const t=It(e.optimizations);if(t.total===0){u.log(W("No optimizations available"));return}t.native>0&&u.log(Z(K(t.native,"replaceable with native APIs"))),t.preferred>0&&u.log(Z(K(t.preferred,"with lighter alternatives"))),t.micro>0&&u.log(Z(K(t.micro,"trivial micro-utilities"))),t.socket>0&&u.log(Z(K(t.socket,"@socketregistry overrides available")))},"displayOptimization"),Zr=x(e=>{u.log(""),u.log(de("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?W(t.label):t.severity==="error"?He(t.label):Z(t.label);u.log(i),t.detail&&u.log(` ${$(M.arrow)} ${$(t.detail)}`)}e.supplyChain.status!=="ok"&&u.log(` ${$(M.arrow)} ${$("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},"displaySupplyChain"),en=x(e=>{if(e.sections.has("runtime")){u.log(""),u.log(de("Runtime",ne(e,"runtime")));for(const t of e.runtime)t.status==="ok"?u.log(W(t.message)):t.status==="skip"?u.log(Ot(t.message)):u.log(Z(t.message))}},"displayRuntime"),tn=x((e,t)=>{const i=e.vulnCount,s=e.runtime.filter(l=>l.status==="warn").length,o=e.outdated.length+e.duplicates.length+e.optimizations.length+s;if(t){if(i===0&&o===0)u.success(`Everything looks good! ${$(`(${H(e.elapsedMs)})`)}`);else{const l=[];i>0&&l.push(Ae(`${String(i)} security`)),o>0&&l.push(Ee(`${String(o)} improvement${o===1?"":"s"}`)),u.log(`${Ae(M.failure)} ${l.join(", ")} ${$(`(${H(e.elapsedMs)})`)}`)}return}u.log(""),u.log(de("Summary","ok")),i===0&&o===0?u.success(`Everything looks good! ${$(`(${H(e.elapsedMs)})`)}`):(i>0&&u.error(`${String(i)} security issue${i===1?"":"s"}`),o>0&&u.log(` ${Pe(M.arrow)} ${ce(String(o))} ${$(`improvement${o===1?"":"s"} available`)} ${$(`(${H(e.elapsedMs)})`)}`))},"displaySummary"),rn=x(e=>{const t=[];if(e.outdated.length>0&&t.push("vis update — update outdated dependencies"),(e.vulnCount>0||e.socketIssues.alerts>0)&&t.push("vis audit — detailed security analysis"),e.optimizations.length>0&&t.push("vis optimize — apply optimizations interactively"),e.duplicates.length>0&&t.push("vis dedupe — reduce duplicate versions"),t.length>0){u.log(""),u.log(ce("Next steps:"));for(const i of t)u.log(` ${$(M.arrow)} ${i}`)}u.log("")},"displayActions"),nn=x((e,t)=>{t||(Jr(e),Xr(e),Qr(e),en(e),Zr(e)),tn(e,t)},"displayResults"),on=x((e,t,i,s,o)=>{const l=[],d=e.has("dependencies"),h=e.has("security"),a=e.has("optimization");return(d||h)&&t>0&&l.push({id:"outdated",label:"Outdated catalog dependencies"}),h&&s>0&&l.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),h&&i&&s>0&&l.push({id:"socket",label:"Socket.dev supply-chain reports"}),a&&o&&l.push({id:"codemods",label:"Codemod availability"}),l},"planScanTasks"),sn=x(e=>{if(u.log(""),u.log(`${ce(Pe("vis doctor"))} ${$("— project health check")}`),u.log(W(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.workspaceCount!==void 0&&e.workspaceCount>0&&u.log(W(K(e.workspaceCount,`workspace package${e.workspaceCount===1?"":"s"}`))),e.runtimeFindings.length===0)u.log(W(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?Ae:Ee;u.log(He(`Runtime: ${i(t.message)}`))}u.log(` ${$(M.arrow)} Run ${be("vis toolchain install")} to install pinned versions, or ${be("vis toolchain status")} for the per-tool breakdown.`)}u.log("")},"printBanner"),Mn=x(async({logger:e,options:t,visConfig:i,visConfigError:s,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const l=t.format==="json"||t.json===!0,d=Nr(t.only,t.skip),h=!!t.quiet,a=t.progress===!1,f=Ir(t.filter);if(d.size===0){u.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const k=Date.now(),v=kt(o),I=ci(o),z=!!process.stdout.isTTY,g=!l&&z&&!Yt&&!h&&!a;!l&&!g&&sn({nodeVersion:process.versions.node,packageManagerName:v.name,packageManagerVersion:v.version,runtimeFindings:I,workspaceCount:void 0});const D=pt(o,ut(o).packageManager),B=pi(o,v.name),J=B.length,V=ht(i?.security).length>0,L=i?.security?.policies?.score?.minimum??gt,R=wt(o);if(!l&&!h&&!g){const O=R.length>0?$(` · ${String(R.length)} workspace package${R.length===1?"":"s"}`):"";u.log(`${$("·")} ${$("Found")} ${ce(String(J))} ${$(`installed package${J===1?"":"s"}`)}${O}`)}const _=s?{hint:s.file?`Continuing with default settings — fix or regenerate ${s.file} (vis init --force).`:"Continuing with default settings.",message:s.message,severity:"error",title:s.file?`Failed to load ${s.file}`:"Failed to load vis.config"}:void 0,G=hi(o,v.name)?.file,se=G?q(o,G):void 0,ie=ti(o),U=t.cache!==!1&&!t.fix?Ai({configPath:ie,lockfilePath:se,sections:d,socketEnabled:V,workspaceRoot:o}):void 0,j=U?Pi(U):void 0,Y=j!==void 0;let S,C;if(g){const O=j?new nt({activeSections:d,findings:At(xt(j),f)}):new nt({activeSections:d}),Q=qt(Jt.createElement(Rr,{banner:_,fromCache:Y,startedAt:k,store:O}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{S=j??await ct({filterPatterns:f,installed:B,resolveCodemods:!!t.fix,sections:d,store:O,visConfig:i,workspaceRoot:o})}catch(ee){throw Q.unmount(),ee}await Q.waitUntilExit(),C=O.getSnapshot().pendingAction}else if(j)S=j;else{const O=on(d,D.size,V,J,!!t.fix),Q=di(O,{live:!l&&!h&&!a});try{S=await ct({filterPatterns:f,installed:B,progress:Q,resolveCodemods:!!t.fix,sections:d,visConfig:i,workspaceRoot:o})}finally{Q.stop()}}const X={...S,elapsedMs:Date.now()-k};if(U&&!Y)try{Ii(U,X)}catch{}const T=Dr(X,f,L);if(l){process.stdout.write(`${JSON.stringify(Fr(T,v.name),void 0,2)}
|
|
4
|
-
|
|
5
|
-
`)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`),
|
|
10
|
-
`)
|
|
1
|
+
var me=Object.defineProperty;var S=(r,e)=>me(r,"name",{value:e,configurable:!0});import{createRequire as he}from"node:module";import"../packem_shared/index-efSniSRN.js";import{i as ke}from"../packem_shared/glob-MHJQjR39-CQ2GC0b_.js";import{M as j,i as X,$ as G,C as we}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{d as M,n as ne}from"./config.js";import{render as be}from"@visulima/tui";import{o as xe,aF as $e,au as Ce,h as Oe,J as K,p as b,s as Se}from"./bin.js";import Pe from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import Ne from"module-replacements/manifests/native.json"with{type:"json"};import Ee from"module-replacements/manifests/preferred.json"with{type:"json"};import _e,{useSyncExternalStore as je,useRef as Te,useState as Y,useCallback as Ae}from"react";import{s as ie,A as De,y as Re}from"../packem_shared/pm-runner-BwX5AL3W.js";import{jsx as n,jsxs as m,Fragment as U}from"react/jsx-runtime";import{Box as h}from"@visulima/tui/components/box";import{Text as s}from"@visulima/tui/components/text";import{useApp as Ie}from"@visulima/tui/hooks/use-app";import{useInput as Me}from"@visulima/tui/hooks/use-input";import{useWindowSize as Fe}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Ge}from"@visulima/tui/components/scroll-view";import{ScrollBar as Le}from"@visulima/tui/components/scroll-bar";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
+
const ge=he(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ye=S(r=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[e,t]=I.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return I.getBuiltinModule(r)}return ge(r)},"__cjs_getBuiltinModule"),{writeFileSync:ve}=ye("node:fs");var qe=Object.defineProperty,_=S((r,e)=>qe(r,"name",{value:e,configurable:!0}),"d$1");const ze=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ue=["overrides","pnpm","resolutions"],Be=["engines","files"],Je=_(r=>{const e=ie.coerce(r)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),Ve=_(r=>{const e=j(r,"pnpm-workspace.yaml");if(!X(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:xe(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),He=_((r,e)=>{let t={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?t=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?t=r.resolutions??{}:t=r.overrides??{},{overrides:t,source:"package.json"})},"readPkgJsonOverrides"),We=_((r,e,t)=>t.name==="pnpm"&&Je(t.version)?Ve(r):He(e,t.name),"readOverrides"),Q=_((r,e)=>{const t=e;for(const a of Ue){const i=r.indexOf(a);if(i!==-1&&a!==t)return t==="overrides"?i:i+1}let o=-1;for(const a of ze){const i=r.indexOf(a);i>o&&(o=i)}if(o!==-1)return o+1;for(const a of Be){const i=r.indexOf(a);if(i!==-1)return i}return r.length},"findInsertIndex"),Xe=_((r,e)=>{const t=j(r,"pnpm-workspace.yaml");if(!X(t))throw new Error(`pnpm-workspace.yaml not found at ${t}. Cannot write overrides for pnpm v10+.`);let o=G(t);const a=`overrides:
|
|
4
|
+
${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
|
|
5
|
+
`)}
|
|
6
|
+
`;o=/^overrides:\s*$/m.test(o)||/^overrides:\s*\n/m.test(o)?o.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,a):`${o.trimEnd()}
|
|
7
|
+
|
|
8
|
+
${a}`,M(t,o)},"writePnpmWorkspaceOverrides"),Ke=_((r,e,t,o,a)=>{const i=G(r),l=$e(r,i,{useEditorconfig:a});if(o==="pnpm"){const v=e.pnpm??{};if(v.overrides=t,e.pnpm)e.pnpm=v,M(r,`${JSON.stringify(e,null,l)}
|
|
9
|
+
`);else{const x=Object.keys(e),w=Q(x,"pnpm"),k=Object.entries(e);k.splice(w,0,["pnpm",v]),M(r,`${JSON.stringify(Object.fromEntries(k),null,l)}
|
|
10
|
+
`)}}else{const v=o==="yarn"||o==="bun"?"resolutions":"overrides";if(e[v])e[v]=t,M(r,`${JSON.stringify(e,null,l)}
|
|
11
|
+
`);else{const x=Object.keys(e),w=Q(x,v),k=Object.entries(e);k.splice(w,0,[v,t]),M(r,`${JSON.stringify(Object.fromEntries(k),null,l)}
|
|
12
|
+
`)}}},"writePkgJsonOverrides"),Ye=_((r,e,t,o,a)=>{if(o.name==="deno")return{added:[],updated:[]};const i=G(e),l=JSON.parse(i),{overrides:v,source:x}=We(r,l,o),w=[],k=[],c=new Set;if(o.name==="npm")for(const p of["dependencies","devDependencies"]){const g=l[p];if(g)for(const y of Object.keys(g))c.add(y)}for(const p of t){const g=v[p.original];if(typeof g=="object")continue;let y=p.spec;o.name==="npm"&&c.has(p.original)&&(y=`$${p.original}`),g!==y&&(g?k.push(p.original):w.push(p.original),v[p.original]=y)}if(w.length===0&&k.length===0)return{added:w,updated:k};const f=Object.fromEntries(Object.entries(v).sort(([p],[g])=>p.localeCompare(g)));return x==="pnpm-workspace.yaml"?Xe(r,f):Ke(e,l,f,o.name,a),{added:w,updated:k}},"applyOverrides"),Qe=_((r,e)=>{const t={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const o of t[e]??[]){const a=j(r,o);try{return G(a)}catch{continue}}return""},"readLockfileText"),Ze=_((r,e,t)=>{if(!r)return!1;const o=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(t){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);case"deno":return r.includes(`"${e}"`)||r.includes(`"npm:${e}@`)||r.includes(`"jsr:${e}@`);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${o}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);default:return!1}},"lockfileContainsPackage");var V={exports:{}},H,Z;function ee(){if(Z)return H;Z=1;var r=Object.defineProperty,e=S((c,f)=>r(c,"name",{value:f,configurable:!0}),"t"),t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,l=e((c,f)=>{for(var p in f)t(c,p,{get:f[p],enumerable:!0})},"__export"),v=e((c,f,p,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let y of a(f))!i.call(c,y)&&y!==p&&t(c,y,{get:e(()=>f[y],"get"),enumerable:!(g=o(f,y))||g.enumerable});return c},"__copyProps"),x=e(c=>v(t({},"__esModule",{value:!0}),c),"__toCommonJS"),w={};l(w,{PURL_Type:e(()=>k,"PURL_Type")}),H=x(w);var k=(c=>(c.APK="apk",c.BITBUCKET="bitbucket",c.COCOAPODS="cocoapods",c.CARGO="cargo",c.CHROME="chrome",c.COMPOSER="composer",c.CONAN="conan",c.CONDA="conda",c.CRAN="cran",c.DEB="deb",c.DOCKER="docker",c.GEM="gem",c.GENERIC="generic",c.GITHUB="github",c.GOLANG="golang",c.HACKAGE="hackage",c.HEX="hex",c.HUGGINGFACE="huggingface",c.MAVEN="maven",c.MLFLOW="mlflow",c.NPM="npm",c.NUGET="nuget",c.OCI="oci",c.PUB="pub",c.PYPI="pypi",c.QPKG="qpkg",c.RPM="rpm",c.SWID="swid",c.SWIFT="swift",c.VCS="vcs",c))(k||{});return H}S(ee,"requireTypes");var re;function er(){return re||(re=1,(function(r){var e=Object.defineProperty,t=S((f,p)=>e(f,"name",{value:p,configurable:!0}),"a"),o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,v=t((f,p)=>{for(var g in p)o(f,g,{get:p[g],enumerable:!0})},"__export"),x=t((f,p,g,y)=>{if(p&&typeof p=="object"||typeof p=="function")for(let u of i(p))!l.call(f,u)&&u!==g&&o(f,u,{get:t(()=>p[u],"get"),enumerable:!(y=a(p,u))||y.enumerable});return f},"__copyProps"),w=t((f,p,g)=>(x(f,p,"default"),g&&x(g,p,"default")),"__reExport"),k={};v(k,{getManifestData:t(()=>c,"getManifestData")}),w(k,ee(),r.exports);function c(f,p){try{const g=require("../manifest.json");if(!f)return g;const y=g[f];if(!y)return;if(!p)return y;const u=y.find(([C,O])=>O.package===p);return u?u[1]:void 0}catch{return}}S(c,"getManifestData"),t(c,"getManifestData"),r.exports={getManifestData:c,...ee()}})(V)),V.exports}S(er,"requireDist");var rr=er(),tr=Object.defineProperty,F=S((r,e)=>tr(r,"name",{value:e,configurable:!0}),"s");const or=F((r,e,t)=>{let o=r;if(e!=="all"&&(o=o.filter(a=>a.category===e)),t){const a=t.toLowerCase();o=o.filter(i=>i.packageName.toLowerCase().includes(a))}return o},"filterEntries");class nr{static{S(this,"h")}static{F(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=F(()=>this.#e,"getSnapshot");subscribe=F(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=F(()=>or(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(e,t.length-1)),this.#r()}toggleCheck(e){const t=new Set(this.#e.checkedEntries);t.has(e)?t.delete(e):t.add(e),this.#e.checkedEntries=t,this.#r()}toggleAll(){const e=this.getFilteredEntries(),t=new Set(this.#e.checkedEntries);if(e.every(o=>t.has(o.packageName)))for(const o of e)t.delete(o.packageName);else for(const o of e)t.add(o.packageName);this.#e.checkedEntries=t,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,t){this.#e.applyProgress={current:e,total:t},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ce={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},ir={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},cr={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var ar=Object.defineProperty,sr=S((r,e)=>ar(r,"name",{value:e,configurable:!0}),"d");const lr=sr(({entry:r,focused:e,scrollRef:t})=>{const o=e?"white":"gray";if(!r)return n(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(s,{dimColor:!0,children:"No entry selected"})});const a=ce[r.category]??"gray";return m(h,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n(h,{flexShrink:0,paddingTop:1,paddingX:2,children:n(s,{bold:!0,color:"white",children:r.packageName})}),m(Ge,{flexGrow:1,flexShrink:1,paddingX:2,ref:t,scrollbar:!0,scrollbarColor:"gray",children:[n(s,{}),m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Category:"})}),n(s,{bold:!0,color:a,children:r.category})]}),m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Replace with:"})}),n(s,{children:r.replacement})]}),r.overrideSpec&&m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Override:"})}),n(s,{color:"cyan",children:r.overrideSpec})]}),m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Codemod:"})}),n(s,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"white",children:"DESCRIPTION"}),n(h,{marginTop:1,paddingLeft:2,children:n(s,{children:cr[r.category]??""})})]}),r.category==="native"&&m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"green",children:"ACTION"}),n(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?m(U,{children:[m(s,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),n(s,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):m(U,{children:[m(s,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),n(s,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"cyan",children:"ACTION"}),m(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[m(s,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),n(s,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"yellow",children:"ACTION"}),n(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?m(U,{children:[m(s,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),n(s,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):m(U,{children:[m(s,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?n(s,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):n(s,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"white",children:"LINKS"}),m(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[m(s,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&n(s,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},"OptimizeDetailPanel");var dr=Object.defineProperty,ae=S((r,e)=>dr(r,"name",{value:e,configurable:!0}),"b$1");const pr=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],fr=ae(({checked:r,entry:e,isSelected:t})=>{const o=ce[e.category]??"white",a=ir[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return m(h,{flexShrink:0,height:1,children:[n(s,{children:t?">":" "}),m(s,{color:r?"white":"gray",children:[" ",i," "]}),n(s,{bold:!0,color:o,children:`[${a}]`.padEnd(9)}),m(s,{children:[" ",l," "]}),n(h,{flexGrow:1,children:n(s,{bold:t,inverse:t,wrap:"truncate",children:e.packageName})}),n(s,{dimColor:!0,children:" → "}),n(s,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),ur=ae(({checkedEntries:r,entries:e,filterActive:t,filterText:o,filterType:a,focused:i,isDryRun:l,scrollOffset:v,selectedIndex:x,totalEntries:w,viewportHeight:k})=>{const c=i?"white":"gray";let f=0,p=0,g=0,y=0;for(const d of e)switch(d.category){case"micro-utility":{g++;break}case"native":{f++;break}case"preferred":{p++;break}case"socket":{y++;break}}const u=[];f>0&&u.push(`${f} native`),p>0&&u.push(`${p} preferred`),g>0&&u.push(`${g} micro`),y>0&&u.push(`${y} socket`);const C=u.length>0?` (${u.join(", ")})`:"",O=r.size,T=[];for(const[d,P]of e.entries())T.push(n(fr,{checked:r.has(P.packageName),entry:P,isSelected:d===x},P.packageName));const A=e.length,R=A>k&&k>0;return m(h,{borderColor:c,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[m(h,{flexShrink:0,gap:1,paddingX:1,children:[n(s,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),m(s,{wrap:"truncate",children:[w," ","optimizations",C]}),!l&&O>0&&m(s,{dimColor:!0,children:[" ","—",O," ","selected"]})]}),n(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pr.map(d=>{const P=a===d.key;return m(h,{children:[n(s,{dimColor:!P,children:"["}),n(s,{bold:P,color:P?"cyan":"gray",children:d.shortcut}),n(s,{dimColor:!P,children:"]"}),m(s,{color:P?"white":"gray",children:[" ",d.label]})]},d.key)})}),t&&m(h,{flexShrink:0,paddingX:1,children:[n(s,{bold:!0,color:"white",children:"/ "}),n(s,{children:o}),n(s,{inverse:!0,children:" "})]}),m(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(h,{flexDirection:"column",marginTop:-v,children:T})}),R&&n(h,{flexShrink:0,marginLeft:1,marginRight:1,children:n(Le,{contentHeight:A,placement:"inset",scrollOffset:v,style:"block",viewportHeight:k})})]})]})},"OptimizeListPanel");var mr=Object.defineProperty,hr=S((r,e)=>mr(r,"name",{value:e,configurable:!0}),"I$1");const gr=100,te=10,oe={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},yr=hr(({isDryRun:r,store:e})=>{const{exit:t}=Ie(),{columns:o,rows:a}=Fe(),i=je(e.subscribe,e.getSnapshot),l=Te(null),[v,x]=Y(0),[w,k]=Y(!1),c=e.getFilteredEntries(),f=c[i.selectedIndex]??null,p=o>=gr,g=Math.max(0,a-5),y=Ae(u=>{t(u)},[t]);return Me((u,C)=>{if(w){u==="y"||u==="Y"?y():k(!1);return}if(i.filterActive){C.escape?(e.setFilterActive(!1),e.setFilterText("")):C.return?e.setFilterActive(!1):C.backspace||C.delete?e.setFilterText(i.filterText.slice(0,-1)):u&&!C.ctrl&&!C.meta&&e.setFilterText(i.filterText+u);return}if(u==="q"){!r&&i.checkedEntries.size>0?k(!0):y();return}if(u==="/"){e.setFilterActive(!0);return}if(oe[u]){e.setFilter(oe[u]);return}if(C.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(C.upArrow||u==="k"){const O=Math.max(0,i.selectedIndex-1);e.select(O),O<v&&x(O)}else if(C.downArrow||u==="j"){const O=Math.min(c.length-1,i.selectedIndex+1);e.select(O),O>=v+g&&x(O-g+1)}else u===" "?f&&e.toggleCheck(f.packageName):u==="a"?e.toggleAll():C.return&&!r&&i.checkedEntries.size>0&&y(e.getCheckedEntries());else i.focusedPanel==="detail"&&(C.upArrow||u==="k"?l.current?.scrollBy(-1):(C.downArrow||u==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),a<te?n(h,{alignItems:"center",justifyContent:"center",children:m(s,{color:"yellow",children:["Terminal too small. Resize to at least",te," ","rows."]})}):m(h,{flexDirection:"column",height:a,width:o,children:[m(h,{flexDirection:p?"row":"column",flexGrow:1,children:[n(h,{flexBasis:p?"50%":void 0,flexGrow:1,children:n(ur,{checkedEntries:i.checkedEntries,entries:c,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:v,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:g})}),n(h,{flexBasis:p?"50%":void 0,flexGrow:1,children:n(lr,{entry:f,focused:i.focusedPanel==="detail",scrollRef:l})})]}),n(h,{flexShrink:0,paddingX:1,children:m(s,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),n(Ce,{autoExitSeconds:3,onCancel:S(()=>{k(!1)},"onCancel"),visible:w})]})},"VisOptimizeApp");var vr=Object.defineProperty,N=S((r,e)=>vr(r,"name",{value:e,configurable:!0}),"p");const W=N((r,e)=>{const t=new Set;try{const o=ne(r),a=e?[o.dependencies,o.optionalDependencies]:[o.dependencies,o.devDependencies,o.peerDependencies,o.optionalDependencies];for(const i of a)if(i)for(const l of Object.keys(i))t.add(l)}catch{}return t},"collectDepsFromPkgJson"),se=N(r=>{const e=Oe(r);if(e)return K(r,e);const t=j(r,"package.json");if(!X(t))return[];try{const o=ne(t),a=Array.isArray(o.workspaces)?o.workspaces:o.workspaces?.packages;return a?K(r,a):[]}catch{return[]}},"discoverWorkspacePackages"),kr="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",wr=N(r=>`${kr}/${r}.md`,"buildE18eDocUrl"),br=N(r=>{if(r.type==="simple"&&r.replacement)return r.replacement;if(r.type==="native"){const e=r.nodeVersion?` (Node ${r.nodeVersion}+)`:"";return r.replacement?`${r.replacement}${e}`:`Native API${e}`}return r.type==="documented"&&r.docPath?"see migration guide":""},"e18eReplacementHint"),le=N(r=>{const e=[],t=N((o,a)=>{const i=o.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:a,docUrl:l.type==="documented"&&l.docPath?wr(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:br(l)})},"scanManifest");return t(Ne,"native"),t(Ee,"preferred"),t(Pe,"micro-utility"),e},"buildE18eEntries"),de=N((r,e,t,o)=>{const a=rr.getManifestData("npm")??[],i=[];for(const[,l]of a){if(l.deprecated)continue;const v=r.has(l.package),x=e?Ze(e,l.package,t.name):!1;if(!v&&!x)continue;const w=ie.coerce(l.version)?.major;if(w===void 0)continue;const k=o?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(w)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:k,packageName:l.package,replacement:l.name})}return i},"buildSocketEntries");let B;const pe=N(async()=>{if(B)return B;try{return B=(await import("module-replacements-codemods")).codemods,B}catch{return{}}},"loadCodemods"),fe=N(async r=>{try{const e=await pe();for(const t of r)t.category!=="socket"&&e[t.packageName]&&(t.hasCodemod=!0)}catch{}},"markCodemodAvailability"),ue=N(async(r,e)=>{let t=0;try{const o=(await pe())[e];if(!o)return{filesChanged:0,packageName:e};const a=o({}),i=await xr(r);for(const l of i){const v=G(l);if(v.includes(e))try{const x=await a.transform({file:{filename:l,source:v}});x!==v&&(ve(l,x,"utf8"),t++)}catch(x){process.stderr.write(`warn: codemod transform failed for ${l}: ${x instanceof Error?x.message:String(x)}
|
|
13
|
+
`)}}}catch{}return{filesChanged:t,packageName:e}},"runCodemod"),xr=N(async r=>ke("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),"collectSourceFiles"),$r=N(async({logger:r,options:e,visConfig:t,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const a=De(o),i=!!e.dryRun,l=!!e.prod,v=!!e.pin;b.info(`Detected ${a.name} v${a.version}.`);const x=W(j(o,"package.json"),l),w=se(o),k=new Set(x);for(const d of w){const P=W(j(we(o,d),"package.json"),l);for(const D of P)k.add(D)}w.length>0&&b.info(`Scanned ${String(w.length)} workspace package${w.length===1?"":"s"}.`),b.info(`Scanning dependencies...
|
|
14
|
+
`);const c=Qe(o,a.name),f=le(k),p=de(k,c,a,v),g=new Set(f.map(d=>d.packageName)),y=p.filter(d=>!g.has(d.packageName)),u=[...f,...y];if(await fe(u),u.length===0){b.info("No optimizations found for your dependencies.");return}const C=!!process.stdout.isTTY&&!Se,O=e.format==="json"||!!e.json;if(C&&!i&&!O){const d=new nr(u),P=await be(_e.createElement(yr,{isDryRun:!1,store:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),D=Array.isArray(P)?P:[];if(D.length===0){b.info("No optimizations selected.");return}const L=D.filter($=>$.category!=="socket"&&$.hasCodemod),q=D.filter($=>$.category!=="socket"&&!$.hasCodemod),J=D.filter($=>$.category==="socket");if(L.length>0){b.info(`
|
|
15
|
+
Running ${String(L.length)} codemod${L.length===1?"":"s"}...
|
|
16
|
+
`);for(const $ of L){const E=await ue(o,$.packageName);E.filesChanged>0?b.success(` ${$.packageName}: ${String(E.filesChanged)} file${E.filesChanged===1?"":"s"} updated`):b.info(` ${$.packageName}: no files changed`)}}if(q.length>0){b.warn(`
|
|
17
|
+
${String(q.length)} selected replacement${q.length===1?"":"s"} require manual migration (no codemod available):`);for(const $ of q)b.info(` ${$.packageName} → ${$.replacement}`);b.notice(" Replace usage in your source code, then remove from dependencies.")}if(J.length>0){const $=J.filter(z=>z.overrideSpec).map(z=>({original:z.packageName,spec:z.overrideSpec})),E=Ye(o,j(o,"package.json"),$,a,t?.editorconfig??!0);E.added.length>0&&b.success(`
|
|
18
|
+
Added ${String(E.added.length)} override${E.added.length===1?"":"s"}.`),E.updated.length>0&&b.success(`Updated ${String(E.updated.length)} override${E.updated.length===1?"":"s"}.`)}if(J.length>0&&e.install!==!1){b.info(`
|
|
19
|
+
Running ${a.name} install to update lockfile...`);const $=Re(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},o,r);$!==0&&b.warn(`${a.name} install exited with code ${String($)}. Run it manually.`)}b.info(""),b.success("Optimization complete.");return}if(O){process.stdout.write(`${JSON.stringify({e18e:f.map(d=>({category:d.category,hasCodemod:d.hasCodemod,packageName:d.packageName,replacement:d.replacement})),packageManager:a.name,socket:y.map(d=>({overrideSpec:d.overrideSpec,packageName:d.packageName,replacement:d.replacement})),total:u.length,workspaces:w.length},void 0,2)}
|
|
20
|
+
`);return}const T=f.filter(d=>d.category==="native"),A=f.filter(d=>d.category==="preferred"),R=f.filter(d=>d.category==="micro-utility");if(T.length>0){b.info(`Native replacements (${String(T.length)}):`);for(const d of T)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(A.length>0){b.info(`
|
|
21
|
+
Preferred alternatives (${String(A.length)}):`);for(const d of A)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(R.length>0){b.info(`
|
|
22
|
+
Micro-utilities (${String(R.length)}):`);for(const d of R)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(y.length>0){b.info(`
|
|
23
|
+
Socket.dev overrides (${String(y.length)}):`);for(const d of y)b.info(` ${d.packageName} → ${d.overrideSpec}`)}b.info(`
|
|
24
|
+
Total: ${String(u.length)} optimizations available (⚙ = codemod available).`),i&&b.notice("Run without --dry-run for interactive selection.")},"execute"),Jr=Object.defineProperty({__proto__:null,buildE18eEntries:le,buildSocketEntries:de,collectDepsFromPkgJson:W,default:$r,discoverWorkspacePackages:se,markCodemodAvailability:fe,runCodemod:ue},Symbol.toStringTag,{value:"Module"});export{se as A,le as F,ue as I,Qe as L,de as T,fe as U,Ye as a,Jr as h,W as x};
|