@visulima/vis 1.0.0-alpha.10 → 1.0.0-alpha.12
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 +185 -42
- package/LICENSE.md +586 -0
- package/README.md +26 -4
- package/dist/config/index.d.ts +1739 -0
- package/dist/config/index.js +1 -0
- package/dist/generate/index.d.ts +1 -1
- package/dist/packem_chunks/applyDefaults.js +2 -0
- package/dist/packem_chunks/bin.js +232 -60
- package/dist/packem_chunks/doctor-probe.js +2 -0
- package/dist/packem_chunks/fix.js +11 -53
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +2 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +5 -2
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +18 -5
- package/dist/packem_chunks/handler15.js +20 -1
- package/dist/packem_chunks/handler16.js +1 -20
- 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 +2 -1
- package/dist/packem_chunks/handler20.js +5 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -5
- package/dist/packem_chunks/handler23.js +5 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +3 -5
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -3
- package/dist/packem_chunks/handler28.js +7 -1
- package/dist/packem_chunks/handler29.js +22 -6
- package/dist/packem_chunks/handler3.js +4 -2
- package/dist/packem_chunks/handler30.js +3 -23
- package/dist/packem_chunks/handler31.js +1 -3
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +24 -23
- package/dist/packem_chunks/handler34.js +2 -2
- package/dist/packem_chunks/handler35.js +3 -19
- package/dist/packem_chunks/handler36.js +22 -428
- package/dist/packem_chunks/handler37.js +428 -22
- package/dist/packem_chunks/handler38.js +20 -20
- package/dist/packem_chunks/handler39.js +21 -21
- package/dist/packem_chunks/handler4.js +2 -4
- package/dist/packem_chunks/handler40.js +22 -3
- package/dist/packem_chunks/handler41.js +6 -10
- package/dist/packem_chunks/handler42.js +5 -153
- package/dist/packem_chunks/handler43.js +10 -42
- package/dist/packem_chunks/handler44.js +153 -3
- package/dist/packem_chunks/handler45.js +25 -27
- package/dist/packem_chunks/handler46.js +3 -0
- package/dist/packem_chunks/handler47.js +27 -0
- package/dist/packem_chunks/handler48.js +42 -0
- package/dist/packem_chunks/handler5.js +8 -2
- package/dist/packem_chunks/handler6.js +1 -13
- package/dist/packem_chunks/handler7.js +1 -8
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +10 -0
- package/dist/packem_chunks/heal.js +14 -0
- package/dist/packem_chunks/index.js +3 -3
- package/dist/packem_chunks/tar.js +3 -0
- package/dist/packem_shared/ai-analysis-hm8d2W7z.js +67 -0
- package/dist/packem_shared/{ai-cache-Bynt6Y9x.js → ai-cache-DoiF80AR.js} +1 -1
- package/dist/packem_shared/ai-fix-nn4zOE95.js +43 -0
- package/dist/packem_shared/cache-directory-CwHlJhgx.js +1 -0
- package/dist/packem_shared/dependency-scan-COr5n63B.js +2 -0
- package/dist/packem_shared/{docker-BcfqH4Av.js → docker-D6OGr5_S.js} +1 -1
- package/dist/packem_shared/{failure-log-DqYen0LC.js → failure-log-iUVLf6ts.js} +1 -1
- package/dist/packem_shared/flakiness-D9wf0t56.js +1 -0
- package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
- package/dist/packem_shared/index-DH-5hsrC.js +1 -0
- package/dist/packem_shared/otel-DxDUPJJH.js +6 -0
- package/dist/packem_shared/otelPlugin-CQq6poq8.js +1 -0
- package/dist/packem_shared/registry-CkubDdiY.js +2 -0
- package/dist/packem_shared/run-summary-utils-BfBvjzhY.js +1 -0
- package/dist/packem_shared/{runtime-check-CGHal8SO.js → runtime-check-BXZ43CBW.js} +1 -1
- package/dist/packem_shared/{selectors-CfH9ZY08.js → selectors-BylODRiM.js} +1 -1
- package/dist/packem_shared/toolchain-BgBOUHII.js +5 -0
- package/dist/packem_shared/typosquats-CcZl99B1.js +1 -0
- package/dist/packem_shared/verify-Baj5mFJ7.js +1 -0
- package/dist/packem_shared/vis-update-app-D1jl0UZZ.js +1 -0
- package/index.js +54 -53
- package/package.json +34 -26
- package/schemas/project.schema.json +739 -299
- package/schemas/vis-config.schema.json +3383 -278
- package/skills/vis/SKILL.md +96 -0
- package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
- package/templates/buildkite-ci/template.yml +20 -0
- package/dist/errors/index.d.ts +0 -26
- package/dist/errors/index.js +0 -1
- package/dist/packem_chunks/config.js +0 -2
- package/dist/packem_shared/VisConfigCycleError-CAYNC7d-.js +0 -1
- package/dist/packem_shared/VisConfigError-B5LP1zRf.js +0 -1
- package/dist/packem_shared/VisConfigLoadError-CeqBSd2Z.js +0 -2
- package/dist/packem_shared/VisConfigNotFoundError-DZ9KC527.js +0 -5
- package/dist/packem_shared/VisUpdateApp-D-L4_-Iu.js +0 -1
- package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +0 -1
- package/dist/packem_shared/ai-analysis-CGuy7dfE.js +0 -67
- package/dist/packem_shared/cache-directory-D72ZEag2.js +0 -1
- package/dist/packem_shared/catalog-BVPerCwG.js +0 -12
- package/dist/packem_shared/dependency-scan-Du0tBu64.js +0 -2
- package/dist/packem_shared/flakiness-DSIHZGBT.js +0 -1
- package/dist/packem_shared/run-summary-utils-C24Aaf9E.js +0 -1
- package/dist/packem_shared/target-merge-DNa-6eWu.js +0 -1
- package/dist/packem_shared/toolchain-DQfTQY8E.js +0 -5
- package/dist/packem_shared/typosquats-DOR8izpX.js +0 -1
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var le=Object.defineProperty;var E=(r,e)=>le(r,"name",{value:e,configurable:!0});import{createRequire as de}from"node:module";import{getManifestData as he}from"@socketsecurity/registry";import{isAccessibleSync as X,readFileSync as z,writeFileSync as _,readJsonSync as Q,glob as ue}from"@visulima/fs";import{join as P,resolve as ge}from"@visulima/path";import{Box as p,Text as c,ScrollView as ye,ScrollBar as ke,useApp as ve,useWindowSize as we,useInput as be,render as $e}from"@visulima/tui";import{w as ee,av as xe,an as Se,aA as Ce,aB as W,A as Ne,p as h,h as Oe,s as je}from"./bin.js";import Ee from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import Te from"module-replacements/manifests/native.json"with{type:"json"};import Pe from"module-replacements/manifests/preferred.json"with{type:"json"};import Ae,{useSyncExternalStore as De,useRef as Ie,useState as H,useCallback as Re}from"react";import{readYamlSync as Fe}from"@visulima/fs/yaml";import{jsx as o,jsxs as d,Fragment as q}from"react/jsx-runtime";const pe=de(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fe=E(r=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[e,t]=F.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return F.getBuiltinModule(r)}return pe(r)},"__cjs_getBuiltinModule"),{writeFileSync:me}=fe("node:fs");var _e=Object.defineProperty,T=E((r,e)=>_e(r,"name",{value:e,configurable:!0}),"d$1");const Me=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],ze=["overrides","pnpm","resolutions"],Le=["engines","files"],Je=T(r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),Ge=T(r=>{const e=P(r,"pnpm-workspace.yaml");if(!X(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Fe(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),qe=T((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"),Be=T((r,e,t)=>t.name==="pnpm"&&Je(t.version)?Ge(r):qe(e,t.name),"readOverrides"),Y=T((r,e)=>{const t=e;for(const a of ze){const i=r.indexOf(a);if(i!==-1&&a!==t)return t==="overrides"?i:i+1}let n=-1;for(const a of Me){const i=r.indexOf(a);i>n&&(n=i)}if(n!==-1)return n+1;for(const a of Le){const i=r.indexOf(a);if(i!==-1)return i}return r.length},"findInsertIndex"),Ue=T((r,e)=>{const t=P(r,"pnpm-workspace.yaml");if(!X(t))throw new Error(`pnpm-workspace.yaml not found at ${t}. Cannot write overrides for pnpm v10+.`);let n=z(t);const a=`overrides:
|
|
2
|
+
${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
|
|
3
|
+
`)}
|
|
4
|
+
`;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,a):`${n.trimEnd()}
|
|
5
|
+
|
|
6
|
+
${a}`,_(t,n)},"writePnpmWorkspaceOverrides"),Ve=T((r,e,t,n,a)=>{const i=z(r),l=xe(r,i,{useEditorconfig:a});if(n==="pnpm"){const m=e.pnpm??{};if(m.overrides=t,e.pnpm)e.pnpm=m,_(r,`${JSON.stringify(e,null,l)}
|
|
7
|
+
`);else{const y=Object.keys(e),g=Y(y,"pnpm"),u=Object.entries(e);u.splice(g,0,["pnpm",m]),_(r,`${JSON.stringify(Object.fromEntries(u),null,l)}
|
|
8
|
+
`)}}else{const m=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[m])e[m]=t,_(r,`${JSON.stringify(e,null,l)}
|
|
9
|
+
`);else{const y=Object.keys(e),g=Y(y,m),u=Object.entries(e);u.splice(g,0,[m,t]),_(r,`${JSON.stringify(Object.fromEntries(u),null,l)}
|
|
10
|
+
`)}}},"writePkgJsonOverrides"),Xe=T((r,e,t,n,a)=>{if(n.name==="deno")return{added:[],updated:[]};const i=z(e),l=JSON.parse(i),{overrides:m,source:y}=Be(r,l,n),g=[],u=[],O=new Set;if(n.name==="npm")for(const k of["dependencies","devDependencies"]){const b=l[k];if(b)for(const v of Object.keys(b))O.add(v)}for(const k of t){const b=m[k.original];if(typeof b=="object")continue;let v=k.spec;n.name==="npm"&&O.has(k.original)&&(v=`$${k.original}`),b!==v&&(b?u.push(k.original):g.push(k.original),m[k.original]=v)}if(g.length===0&&u.length===0)return{added:g,updated:u};const $=Object.fromEntries(Object.entries(m).sort(([k],[b])=>k.localeCompare(b)));return y==="pnpm-workspace.yaml"?Ue(r,$):Ve(e,l,$,n.name,a),{added:g,updated:u}},"applyOverrides"),We=T((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 n of t[e]??[]){const a=P(r,n);try{return z(a)}catch{continue}}return""},"readLockfileText"),He=T((r,e,t)=>{if(!r)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(t){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"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|['"/])${n}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);default:return!1}},"lockfileContainsPackage");var Ye=Object.defineProperty,M=E((r,e)=>Ye(r,"name",{value:e,configurable:!0}),"s");const Ke=M((r,e,t)=>{let n=r;if(e!=="all"&&(n=n.filter(a=>a.category===e)),t){const a=t.toLowerCase();n=n.filter(i=>i.packageName.toLowerCase().includes(a))}return n},"filterEntries");class Ze{static{E(this,"h")}static{M(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=M(()=>this.#e,"getSnapshot");subscribe=M(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=M(()=>Ke(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(n=>t.has(n.packageName)))for(const n of e)t.delete(n.packageName);else for(const n of e)t.add(n.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 re={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},Qe={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},er={"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 rr=Object.defineProperty,tr=E((r,e)=>rr(r,"name",{value:e,configurable:!0}),"d");const nr=tr(({entry:r,focused:e,scrollRef:t})=>{const n=e?"white":"gray";if(!r)return o(p,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:o(c,{dimColor:!0,children:"No entry selected"})});const a=re[r.category]??"gray";return d(p,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[o(p,{flexShrink:0,paddingTop:1,paddingX:2,children:o(c,{bold:!0,color:"white",children:r.packageName})}),d(ye,{flexGrow:1,flexShrink:1,paddingX:2,ref:t,scrollbar:!0,scrollbarColor:"gray",children:[o(c,{}),d(p,{children:[o(p,{width:14,children:o(c,{dimColor:!0,children:"Category:"})}),o(c,{bold:!0,color:a,children:r.category})]}),d(p,{children:[o(p,{width:14,children:o(c,{dimColor:!0,children:"Replace with:"})}),o(c,{children:r.replacement})]}),r.overrideSpec&&d(p,{children:[o(p,{width:14,children:o(c,{dimColor:!0,children:"Override:"})}),o(c,{color:"cyan",children:r.overrideSpec})]}),d(p,{children:[o(p,{width:14,children:o(c,{dimColor:!0,children:"Codemod:"})}),o(c,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),d(p,{flexDirection:"column",marginTop:1,children:[o(c,{dimColor:!0,children:"── "}),o(c,{bold:!0,color:"white",children:"DESCRIPTION"}),o(p,{marginTop:1,paddingLeft:2,children:o(c,{children:er[r.category]??""})})]}),r.category==="native"&&d(p,{flexDirection:"column",marginTop:1,children:[o(c,{dimColor:!0,children:"── "}),o(c,{bold:!0,color:"green",children:"ACTION"}),o(p,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?d(q,{children:[d(c,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),o(c,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):d(q,{children:[d(c,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),o(c,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&d(p,{flexDirection:"column",marginTop:1,children:[o(c,{dimColor:!0,children:"── "}),o(c,{bold:!0,color:"cyan",children:"ACTION"}),d(p,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[d(c,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),o(c,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&d(p,{flexDirection:"column",marginTop:1,children:[o(c,{dimColor:!0,children:"── "}),o(c,{bold:!0,color:"yellow",children:"ACTION"}),o(p,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?d(q,{children:[d(c,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),o(c,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):d(q,{children:[d(c,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?o(c,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):o(c,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),d(p,{flexDirection:"column",marginTop:1,children:[o(c,{dimColor:!0,children:"── "}),o(c,{bold:!0,color:"white",children:"LINKS"}),d(p,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[d(c,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&o(c,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},"OptimizeDetailPanel");var or=Object.defineProperty,te=E((r,e)=>or(r,"name",{value:e,configurable:!0}),"b$1");const ir=[{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"}],cr=te(({checked:r,entry:e,isSelected:t})=>{const n=re[e.category]??"white",a=Qe[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return d(p,{flexShrink:0,height:1,children:[o(c,{children:t?">":" "}),d(c,{color:r?"white":"gray",children:[" ",i," "]}),o(c,{bold:!0,color:n,children:`[${a}]`.padEnd(9)}),d(c,{children:[" ",l," "]}),o(p,{flexGrow:1,children:o(c,{bold:t,inverse:t,wrap:"truncate",children:e.packageName})}),o(c,{dimColor:!0,children:" → "}),o(c,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),ar=te(({checkedEntries:r,entries:e,filterActive:t,filterText:n,filterType:a,focused:i,isDryRun:l,scrollOffset:m,selectedIndex:y,totalEntries:g,viewportHeight:u})=>{const O=i?"white":"gray";let $=0,k=0,b=0,v=0;for(const s of e)switch(s.category){case"micro-utility":{b++;break}case"native":{$++;break}case"preferred":{k++;break}case"socket":{v++;break}}const f=[];$>0&&f.push(`${$} native`),k>0&&f.push(`${k} preferred`),b>0&&f.push(`${b} micro`),v>0&&f.push(`${v} socket`);const x=f.length>0?` (${f.join(", ")})`:"",C=r.size,A=[];for(const[s,S]of e.entries())A.push(o(cr,{checked:r.has(S.packageName),entry:S,isSelected:s===y},S.packageName));const D=e.length,R=D>u&&u>0;return d(p,{borderColor:O,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[d(p,{flexShrink:0,gap:1,paddingX:1,children:[o(c,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),d(c,{wrap:"truncate",children:[g," ","optimizations",x]}),!l&&C>0&&d(c,{dimColor:!0,children:[" ","—",C," ","selected"]})]}),o(p,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:ir.map(s=>{const S=a===s.key;return d(p,{children:[o(c,{dimColor:!S,children:"["}),o(c,{bold:S,color:S?"cyan":"gray",children:s.shortcut}),o(c,{dimColor:!S,children:"]"}),d(c,{color:S?"white":"gray",children:[" ",s.label]})]},s.key)})}),t&&d(p,{flexShrink:0,paddingX:1,children:[o(c,{bold:!0,color:"white",children:"/ "}),o(c,{children:n}),o(c,{inverse:!0,children:" "})]}),d(p,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[o(p,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:o(p,{flexDirection:"column",marginTop:-m,children:A})}),R&&o(p,{flexShrink:0,marginLeft:1,marginRight:1,children:o(ke,{contentHeight:D,placement:"inset",scrollOffset:m,style:"block",viewportHeight:u})})]})]})},"OptimizeListPanel");var sr=Object.defineProperty,lr=E((r,e)=>sr(r,"name",{value:e,configurable:!0}),"I$1");const dr=100,K=10,Z={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},pr=lr(({isDryRun:r,store:e})=>{const{exit:t}=ve(),{columns:n,rows:a}=we(),i=De(e.subscribe,e.getSnapshot),l=Ie(null),[m,y]=H(0),[g,u]=H(!1),O=e.getFilteredEntries(),$=O[i.selectedIndex]??null,k=n>=dr,b=Math.max(0,a-5),v=Re(f=>{t(f)},[t]);return be((f,x)=>{if(g){f==="y"||f==="Y"?v():u(!1);return}if(i.filterActive){x.escape?(e.setFilterActive(!1),e.setFilterText("")):x.return?e.setFilterActive(!1):x.backspace||x.delete?e.setFilterText(i.filterText.slice(0,-1)):f&&!x.ctrl&&!x.meta&&e.setFilterText(i.filterText+f);return}if(f==="q"){!r&&i.checkedEntries.size>0?u(!0):v();return}if(f==="/"){e.setFilterActive(!0);return}if(Z[f]){e.setFilter(Z[f]);return}if(x.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(x.upArrow||f==="k"){const C=Math.max(0,i.selectedIndex-1);e.select(C),C<m&&y(C)}else if(x.downArrow||f==="j"){const C=Math.min(O.length-1,i.selectedIndex+1);e.select(C),C>=m+b&&y(C-b+1)}else f===" "?$&&e.toggleCheck($.packageName):f==="a"?e.toggleAll():x.return&&!r&&i.checkedEntries.size>0&&v(e.getCheckedEntries());else i.focusedPanel==="detail"&&(x.upArrow||f==="k"?l.current?.scrollBy(-1):(x.downArrow||f==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),a<K?o(p,{alignItems:"center",justifyContent:"center",children:d(c,{color:"yellow",children:["Terminal too small. Resize to at least",K," ","rows."]})}):d(p,{flexDirection:"column",height:a,width:n,children:[d(p,{flexDirection:k?"row":"column",flexGrow:1,children:[o(p,{flexBasis:k?"50%":void 0,flexGrow:1,children:o(ar,{checkedEntries:i.checkedEntries,entries:O,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:m,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:b})}),o(p,{flexBasis:k?"50%":void 0,flexGrow:1,children:o(nr,{entry:$,focused:i.focusedPanel==="detail",scrollRef:l})})]}),o(p,{flexShrink:0,paddingX:1,children:d(c,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),o(Se,{autoExitSeconds:3,onCancel:E(()=>{u(!1)},"onCancel"),visible:g})]})},"VisOptimizeApp");var fr=Object.defineProperty,N=E((r,e)=>fr(r,"name",{value:e,configurable:!0}),"p");const V=N((r,e)=>{const t=new Set;try{const n=Q(r),a=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const i of a)if(i)for(const l of Object.keys(i))t.add(l)}catch{}return t},"collectDepsFromPkgJson"),ne=N(r=>{const e=Ce(r);if(e)return W(r,e);const t=P(r,"package.json");if(!X(t))return[];try{const n=Q(t),a=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return a?W(r,a):[]}catch{return[]}},"discoverWorkspacePackages"),mr="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",hr=N(r=>`${mr}/${r}.md`,"buildE18eDocUrl"),ur=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"),oe=N(r=>{const e=[],t=N((n,a)=>{const i=n.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:a,docUrl:l.type==="documented"&&l.docPath?hr(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:ur(l)})},"scanManifest");return t(Te,"native"),t(Pe,"preferred"),t(Ee,"micro-utility"),e},"buildE18eEntries"),ie=N((r,e,t,n)=>{const a=he("npm")??[],i=[];for(const[,l]of a){if(l.deprecated)continue;const m=r.has(l.package),y=e?He(e,l.package,t.name):!1;if(!m&&!y)continue;const g=ee.coerce(l.version)?.major;if(g===void 0)continue;const u=n?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(g)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:u,packageName:l.package,replacement:l.name})}return i},"buildSocketEntries");let B;const ce=N(async()=>{if(B)return B;try{return B=(await import("module-replacements-codemods")).codemods,B}catch{return{}}},"loadCodemods"),ae=N(async r=>{try{const e=await ce();for(const t of r)t.category!=="socket"&&e[t.packageName]&&(t.hasCodemod=!0)}catch{}},"markCodemodAvailability"),se=N(async(r,e)=>{let t=0;try{const n=(await ce())[e];if(!n)return{filesChanged:0,packageName:e};const a=n({}),i=await gr(r);for(const l of i){const m=z(l);if(m.includes(e))try{const y=await a.transform({file:{filename:l,source:m}});y!==m&&(me(l,y,"utf8"),t++)}catch(y){process.stderr.write(`warn: codemod transform failed for ${l}: ${y instanceof Error?y.message:String(y)}
|
|
11
|
+
`)}}}catch{}return{filesChanged:t,packageName:e}},"runCodemod"),gr=N(async r=>ue("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),"collectSourceFiles"),yr=N(async({logger:r,options:e,visConfig:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const a=Ne(n),i=!!e.dryRun,l=!!e.prod,m=!!e.pin;h.info(`Detected ${a.name} v${a.version}.`);const y=V(P(n,"package.json"),l),g=ne(n),u=new Set(y);for(const s of g){const S=V(P(ge(n,s),"package.json"),l);for(const I of S)u.add(I)}g.length>0&&h.info(`Scanned ${String(g.length)} workspace package${g.length===1?"":"s"}.`),h.info(`Scanning dependencies...
|
|
12
|
+
`);const O=We(n,a.name),$=oe(u),k=ie(u,O,a,m),b=new Set($.map(s=>s.packageName)),v=k.filter(s=>!b.has(s.packageName)),f=[...$,...v];if(await ae(f),f.length===0){h.info("No optimizations found for your dependencies.");return}const x=!!process.stdout.isTTY&&!je,C=e.format==="json"||!!e.json;if(x&&!i&&!C){const s=new Ze(f),S=await $e(Ae.createElement(pr,{isDryRun:!1,store:s}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),I=Array.isArray(S)?S:[];if(I.length===0){h.info("No optimizations selected.");return}const L=I.filter(w=>w.category!=="socket"&&w.hasCodemod),J=I.filter(w=>w.category!=="socket"&&!w.hasCodemod),U=I.filter(w=>w.category==="socket");if(L.length>0){h.info(`
|
|
13
|
+
Running ${String(L.length)} codemod${L.length===1?"":"s"}...
|
|
14
|
+
`);for(const w of L){const j=await se(n,w.packageName);j.filesChanged>0?h.success(` ${w.packageName}: ${String(j.filesChanged)} file${j.filesChanged===1?"":"s"} updated`):h.info(` ${w.packageName}: no files changed`)}}if(J.length>0){h.warn(`
|
|
15
|
+
${String(J.length)} selected replacement${J.length===1?"":"s"} require manual migration (no codemod available):`);for(const w of J)h.info(` ${w.packageName} → ${w.replacement}`);h.notice(" Replace usage in your source code, then remove from dependencies.")}if(U.length>0){const w=U.filter(G=>G.overrideSpec).map(G=>({original:G.packageName,spec:G.overrideSpec})),j=Xe(n,P(n,"package.json"),w,a,t?.editorconfig??!0);j.added.length>0&&h.success(`
|
|
16
|
+
Added ${String(j.added.length)} override${j.added.length===1?"":"s"}.`),j.updated.length>0&&h.success(`Updated ${String(j.updated.length)} override${j.updated.length===1?"":"s"}.`)}if(U.length>0&&!e.noInstall){h.info(`
|
|
17
|
+
Running ${a.name} install to update lockfile...`);const w=Oe(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,r);w!==0&&h.warn(`${a.name} install exited with code ${String(w)}. Run it manually.`)}h.info(""),h.success("Optimization complete.");return}if(C){process.stdout.write(`${JSON.stringify({e18e:$.map(s=>({category:s.category,hasCodemod:s.hasCodemod,packageName:s.packageName,replacement:s.replacement})),packageManager:a.name,socket:v.map(s=>({overrideSpec:s.overrideSpec,packageName:s.packageName,replacement:s.replacement})),total:f.length,workspaces:g.length},void 0,2)}
|
|
18
|
+
`);return}const A=$.filter(s=>s.category==="native"),D=$.filter(s=>s.category==="preferred"),R=$.filter(s=>s.category==="micro-utility");if(A.length>0){h.info(`Native replacements (${String(A.length)}):`);for(const s of A)h.info(` ${s.hasCodemod?"⚙":" "} ${s.packageName} → ${s.replacement}`)}if(D.length>0){h.info(`
|
|
19
|
+
Preferred alternatives (${String(D.length)}):`);for(const s of D)h.info(` ${s.hasCodemod?"⚙":" "} ${s.packageName} → ${s.replacement}`)}if(R.length>0){h.info(`
|
|
20
|
+
Micro-utilities (${String(R.length)}):`);for(const s of R)h.info(` ${s.hasCodemod?"⚙":" "} ${s.packageName} → ${s.replacement}`)}if(v.length>0){h.info(`
|
|
21
|
+
Socket.dev overrides (${String(v.length)}):`);for(const s of v)h.info(` ${s.packageName} → ${s.overrideSpec}`)}h.info(`
|
|
22
|
+
Total: ${String(f.length)} optimizations available (⚙ = codemod available).`),i&&h.notice("Run without --dry-run for interactive selection.")},"execute"),Pr=Object.defineProperty({__proto__:null,buildE18eEntries:oe,buildSocketEntries:ie,collectDepsFromPkgJson:V,default:yr,discoverWorkspacePackages:ne,markCodemodAvailability:ae,runCodemod:se},Symbol.toStringTag,{value:"Module"});export{ne as A,oe as F,ae as I,We as L,ie as T,se as U,Xe as a,Pr as h,V as x};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
var Tt=Object.defineProperty;var N=(e,t)=>Tt(e,"name",{value:t,configurable:!0});import{createRequire as At}from"node:module";import{green as ke,yellow as Fe,dim as S,red as Re,bold as se,cyan as Te}from"@visulima/colorize";import{findPackageManagerSync as st}from"@visulima/package";import{join as le,resolve as Pt}from"@visulima/path";import{Box as h,Text as n,ScrollView as Dt,Spinner as lt,Tabs as Ot,Tab as Nt,ScrollBar as Mt,useApp as Ft,useWindowSize as zt,useInput as jt,Dialog as Et,render as Bt}from"@visulima/tui";import{B as Ke,M as Je,b as Be,c as at,V as ct,U as Lt,p as u,j,d as _t,g as Vt}from"./bin.js";import Ut,{useSyncExternalStore as Ht,useState as xe,useEffect as Ee,useRef as qe,useMemo as Pe,useCallback as Xe}from"react";import{X as qt}from"../packem_shared/xxh3-DrAUNq4n.js";import{isAccessibleSync as Xt,readJsonSync as Wt,ensureDirSync as Qt}from"@visulima/fs";import{findVisConfigFile as Zt}from"./config.js";import{x as Qe,A as dt,a as ei,F as ti,T as ii,B as ri,b as ni,I as oi}from"./handler39.js";import{c as si}from"../packem_shared/runtime-check-CGHal8SO.js";import{f as li,l as ai,s as ci}from"../packem_shared/dependency-scan-Du0tBu64.js";import{jsxs as a,jsx as r,Fragment as di}from"react/jsx-runtime";import{u as ui}from"../packem_shared/use-measured-height-DjYgUOKk.js";import{o as hi,a as ht,w as pi,m as gi}from"../packem_shared/catalog-BVPerCwG.js";const It=At(import.meta.url),Ce=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_e=N(e=>{if(typeof Ce<"u"&&Ce.versions&&Ce.versions.node){const[t,i]=Ce.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Ce.getBuiltinModule(e)}return It(e)},"__cjs_getBuiltinModule"),{statSync:Gt,rmSync:We,writeFileSync:Yt,readFileSync:Kt}=_e("node:fs"),{homedir:Jt}=_e("node:os"),{spawnSync:ut}=_e("node:child_process");var fi=Object.defineProperty,Ae=N((e,t)=>fi(e,"name",{value:t,configurable:!0}),"r$2");const Le=Ae(()=>le(Jt(),".vis","cache","doctor"),"getCacheDirectory"),mi=1800*1e3,Ze=Ae(e=>{if(!e)return"";try{return String(Gt(e).mtimeMs)}catch{return""}},"safeMtime"),yi=2,ki=Ae(e=>{const t=JSON.stringify({configMtime:Ze(e.configPath),lockfileMtime:Ze(e.lockfilePath),schema:yi,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return qt(Buffer.from(t))},"buildDoctorCacheKey"),wi=Ae(e=>{const t=le(Le(),`${e}.json`);if(Xt(t))try{const i=Wt(t);if(Date.now()-i.createdAt>i.ttlMs){We(t,{force:!0});return}return{...i.results,sections:new Set(i.results.sections)}}catch{We(t,{force:!0});return}},"readDoctorCache"),vi=Ae((e,t,i=mi)=>{Qt(Le());const s={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};Yt(le(Le(),`${e}.json`),JSON.stringify(s,void 0,2),"utf8")},"writeDoctorCache");var bi=Object.defineProperty,_=N((e,t)=>bi(e,"name",{value:t,configurable:!0}),"i$2");const Oe="orphans",Si=_(()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=Kt("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e=i)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},"checkInotifyCapacity"),$i=_(()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},"checkTtyAvailability"),Ci=_(()=>{const e=process.pid;try{return process.platform==="win32"?ft(e):gt(e)}catch{return[]}},"listOrphanPids"),xi=_(()=>{const e=process.pid;let t;try{t=process.platform==="win32"?ft(e):gt(e)}catch{return{id:Oe,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:Oe,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:Oe,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const i=process.platform==="win32"?t.map(s=>`taskkill /F /PID ${String(s)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${i}`,status:"warn"}},"checkOrphanedRunners"),Ri=_((e={})=>{const t=e.enumerate??Ci,i=e.force===!0?"SIGKILL":"SIGTERM",s=e.kill??Di,o=t(),l=[],d=[];for(const p of o)try{s(p,i),l.push(p)}catch(c){const $=c.code??c.message;if($==="ESRCH"){l.push(p);continue}d.push({pid:p,reason:$})}return{failed:d,killed:l}},"killOrphanedRunners"),Ti=_(e=>ut("taskkill",e,{encoding:"utf8"}),"defaultTaskkillRunner"),Ai=_((e,t)=>{process.kill(e,t)},"defaultProcessKill"),Ii=_((e,t,i=Ti)=>{const s=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],o=i(s);if(o.error)throw o.error;if(typeof o.status=="number"&&o.status!==0){const l=o.status===128?"ESRCH":`taskkill exited with code ${String(o.status)}`,d=new Error(l);throw d.code=l,d}},"killViaTaskkill"),Pi=_((e,t,i=Ai)=>{i(e,t)},"killViaSignal"),Di=_((e,t)=>{if(process.platform==="win32"){Ii(e,t);return}Pi(e,t)},"defaultKill"),pt=_((e,t)=>{const i=ut(e,t,{encoding:"utf8"});if(i.error)throw i.error;if(typeof i.status=="number"&&i.status!==0)throw new Error(`${e} exited with code ${String(i.status)}`);return typeof i.stdout=="string"?i.stdout:""},"runProcessListing"),gt=_(e=>{const t=pt("ps",["-Ao","pid=,command="]),i=[];for(const s of t.split(`
|
|
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"),ft=_(e=>{const t=pt("tasklist",["/FO","CSV","/NH"]),i=[];for(const s of t.split(/\r?\n/)){if(s.length===0)continue;const o=s.split(/","/).map(p=>p.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"),Oi=_(()=>[Si(),$i(),xi()],"runRuntimeDiagnostics");var Ni=Object.defineProperty,ye=N((e,t)=>Ni(e,"name",{value:t,configurable:!0}),"s$2");const me=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Me=["dependencies","security","optimization","runtime"],ge=ye(e=>{const t=new Map;for(const i of Me)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"),fe=ye((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"),Mi=ye(e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of Me)e.has(i)&&(t[i]="idle");return t},"initialStatus");class et{static{N(this,"DoctorStore")}static{ye(this,"DoctorStore")}#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,s=i.findings??[],o=i.activeSections??new Set(Me),l=Me.find(c=>o.has(c))??"dependencies",d=fe(s,l,"",void 0),p=Mi(o);if(s.length>0)for(const c of s)p[c.section]="done";this.#e={all:s,entries:d,filterActive:!1,filterText:"",filterType:l,focusedPanel:"list",grouped:ge(d),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:p,selectedIndex:0,severityFilter:void 0}}getSnapshot=ye(()=>this.#e,"getSnapshot");subscribe=ye(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=fe(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:ge(i),selectedIndex:0})}setFilter(t){const i=fe(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:ge(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=fe(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:ge(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=fe(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:ge(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=fe(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:ge(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 Fi=Object.defineProperty,mt=N((e,t)=>Fi(e,"name",{value:t,configurable:!0}),"r$1");const tt={error:0,warn:1},zi=mt(e=>!!e.acceptedRisk,"isAcknowledged"),yt=mt(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=zi(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 tt[i.severity]-tt[s.severity]}),t},"flattenFindings"),kt={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"};var ji=Object.defineProperty,Ei=N((e,t)=>ji(e,"name",{value:t,configurable:!0}),"i$1");const Bi={error:"red",warn:"yellow"},Li={error:"✖",warn:"⚠"},_i={error:" ERROR ",warn:" WARN "},Vi=Ei(({children:e,hint:t,message:i,severity:s,title:o})=>{const l=Bi[s];return a(h,{borderColor:l,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[a(h,{gap:1,children:[r(n,{backgroundColor:l,bold:!0,color:"black",children:_i[s]}),r(n,{bold:!0,color:l,children:Li[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 Ui=Object.defineProperty,te=N((e,t)=>Ui(e,"name",{value:t,configurable:!0}),"d");const Hi={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Gi={critical:"red",high:"red",low:"gray",medium:"yellow"},Yi={major:"red",minor:"yellow",patch:"green"},T=te(({children:e,label:t,width:i=14})=>a(h,{children:[r(h,{width:i,children:a(n,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?r(n,{children:e}):e]}),"FieldRow"),oe=te(({children:e})=>r(h,{marginTop:1,children:r(n,{bold:!0,color:"white",children:e})}),"SectionTitle"),Ki=te(({finding:e})=>{const{entry:t}=e,i=Yi[t.updateType]??"white";return a(h,{flexDirection:"column",children:[r(T,{label:"Current",children:t.currentRange}),a(T,{label:"Target",children:[r(n,{children:t.newRange}),a(n,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),r(T,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?r(T,{label:"Risk ack",children:r(n,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,r(oe,{children:"Action"}),a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},"OutdatedDetail"),Ji=te(({finding:e})=>a(h,{flexDirection:"column",children:[r(T,{label:"Versions",children:r(n,{children:String(e.pkg.versions.length)})}),r(oe,{children:"Installed versions"}),e.pkg.versions.map(t=>a(n,{children:[" · ",t]},t)),r(oe,{children:"Action"}),a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),"DuplicateDetail"),qi=te(({finding:e})=>{const t=e.entry.vulnerabilities??[];return a(h,{flexDirection:"column",children:[r(T,{label:"Package",children:e.packageName}),r(T,{label:"Current",children:e.entry.currentRange}),r(T,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?r(T,{label:"Risk ack",children:r(n,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const s=Hi[i.severity]??"gray";return a(h,{flexDirection:"column",marginTop:1,children:[a(h,{children:[r(n,{bold:!0,color:s,children:i.severity}),r(n,{children:" "}),r(n,{children:i.id}),typeof i.cvssScore=="number"?a(n,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),r(n,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?a(n,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?a(n,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},"VulnerabilityDetail"),Xi=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=Ke(t.score.overall);return a(h,{flexDirection:"column",children:[r(T,{label:"Package",children:e.packageName}),r(T,{label:"Overall",children:a(n,{color:s,children:[String(i),"%"]})}),r(T,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?r(T,{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,p=Math.round(d*100),c=Ke(d);return a(h,{children:[r(h,{width:14,children:a(n,{dimColor:!0,children:[o,":"]})}),a(n,{color:c,children:[String(p),"%"]})]},o)}),r(oe,{children:"Alerts"}),t.alerts.map((o,l)=>{const d=Gi[o.severity]??"gray";return a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{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"),Wi=te(({finding:e})=>{const{entry:t}=e;return a(h,{flexDirection:"column",children:[r(T,{label:"Package",children:t.packageName}),r(T,{label:"Category",children:t.category}),r(T,{label:"Replacement",children:t.replacement}),t.overrideSpec?r(T,{label:"Override",children:t.overrideSpec}):null,r(T,{label:"Codemod",children:r(n,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?r(T,{label:"Guide",children:r(n,{color:"cyan",underline:!0,children:t.docUrl})}):null,r(oe,{children:"Action"}),t.hasCodemod?a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?a(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"),Qi=te(({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return a(h,{flexDirection:"column",children:[r(T,{label:"Check",children:t.id}),r(T,{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?a(di,{children:[r(oe,{children:"Details"}),Object.entries(t.detail).map(([s,o])=>a(h,{children:[r(h,{width:20,children:a(n,{dimColor:!0,children:[s,":"]})}),r(n,{children:String(o)})]},s))]}):null]})},"RuntimeDetail"),Zi=te(({finding:e,focused:t,scrollRef:i})=>{const s=t?"white":"gray";if(!e)return r(h,{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(Ji,{finding:e});break}case"optimization":{o=r(Wi,{finding:e});break}case"outdated":{o=r(Ki,{finding:e});break}case"runtime":{o=r(Qi,{finding:e});break}case"socket":{o=r(Xi,{finding:e});break}case"vulnerability":{o=r(qi,{finding:e});break}default:{o=r(n,{dimColor:!0,children:"Unknown finding kind."});break}}return a(h,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[a(h,{flexShrink:0,paddingTop:1,paddingX:2,children:[r(n,{bold:!0,color:"white",children:e.title}),a(n,{dimColor:!0,children:[" ",kt[e.section]]})]}),a(Dt,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[r(n,{}),o]})]})},"DoctorDetailPanel");var er=Object.defineProperty,Ie=N((e,t)=>er(e,"name",{value:t,configurable:!0}),"c$1");const wt={error:"red",warn:"yellow"},tr={error:"✖",warn:"⚠"},ir=Ie(e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,"hasAcceptedRisk"),rr=Ie(({finding:e,isSelected:t})=>{const i=wt[e.severity],s=ir(e);return a(h,{flexShrink:0,height:1,children:[r(n,{children:t?">":" "}),a(n,{color:i,children:[" ",tr[e.severity]," "]}),r(h,{flexGrow:1,children:r(n,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),s?r(n,{color:"cyan",children:" ack"}):null,e.subtitle?a(n,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},"FindingRow"),nr=Ie(({count:e,section:t})=>a(h,{flexShrink:0,height:1,marginTop:1,children:[a(n,{dimColor:!0,children:["▼"," "]}),r(n,{bold:!0,color:"white",children:kt[t].toUpperCase()}),a(n,{dimColor:!0,children:[" (",e,")"]})]}),"SectionHeader"),or=Ie(({count:e,label:t,status:i})=>a(n,{children:[t,i==="running"?a(n,{children:[" ",r(lt,{type:"dots"})]}):null,i==="error"?r(n,{bold:!0,color:"red",children:" ✖"}):a(n,{dimColor:!0,children:[" (",String(e),")"]})]}),"TabLabel"),sr=Ie(({elapsedMs:e,entries:t,filterActive:i,filterText:s,filterType:o,focused:l,fromCache:d=!1,grouped:p,onViewportHeightChange:c,scrollOffset:$,sectionCounts:x,sectionMessage:b,sectionStatus:I,selectedIndex:f,severityFilter:w,totalAll:E,viewportHeight:Z})=>{const q=l?"white":"gray",{measuredHeight:B,ref:M}=ui(Z,c);let P=0,L=0;for(const v of t)v.severity==="error"?P+=1:v.severity==="warn"&&(L+=1);const X=[];P>0&&X.push(`${String(P)} error${P===1?"":"s"}`),L>0&&X.push(`${String(L)} warn${L===1?"":"s"}`);const ie=X.length>0?` (${X.join(", ")})`:"",G=(e/1e3).toFixed(1),D=[];for(const[v,A]of p){D.push(r(nr,{count:A.length,section:v},`hdr-${v}`));for(const R of A){const U=t.indexOf(R);D.push(r(rr,{finding:R,isSelected:U===f},R.id))}}let V=0;for(const[,v]of p)V+=2+v.length;const Y=V>B&&B>0;return a(h,{borderColor:q,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[a(h,{flexShrink:0,gap:1,paddingX:1,children:[r(n,{bold:!0,inverse:!0,children:" DOCTOR "}),a(n,{wrap:"truncate",children:[t.length,t.length===E?"":`/${String(E)}`," finding",t.length===1?"":"s",ie]}),w?r(n,{bold:!0,color:wt[w],inverse:!0,children:` ${w.toUpperCase()} ONLY `}):null,d?r(n,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,a(n,{dimColor:!0,children:[" · ",G,"s"]})]}),r(h,{flexShrink:0,paddingX:1,paddingY:1,children:r(Ot,{isFocused:l,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:N(()=>{},"onChange"),showIndex:!1,value:o,children:me.map(({id:v,label:A})=>r(Nt,{name:v,children:r(or,{count:x[v],label:A,status:I[v]})},v))})}),(()=>{const v=Object.keys(I).filter(A=>I[A]==="running"&&b[A]).map(A=>b[A]);return v.length===0?null:r(h,{flexShrink:0,paddingX:1,children:a(n,{dimColor:!0,wrap:"truncate",children:[r(lt,{type:"dots"})," ",v.join(" · ")]})})})(),i&&a(h,{flexShrink:0,paddingX:1,children:[r(n,{bold:!0,color:"white",children:"/ "}),r(n,{children:s}),r(n,{inverse:!0,children:" "})]}),a(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:M,children:[r(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:r(h,{flexDirection:"column",marginTop:-$,children:D.length>0?D:r(h,{marginTop:1,children:r(n,{dimColor:!0,children:"No findings match the current filter."})})})}),Y&&r(h,{flexShrink:0,marginLeft:1,marginRight:1,children:r(Mt,{contentHeight:V,placement:"inset",scrollOffset:$,style:"block",viewportHeight:B})})]},`list-${o}-${s}`)]})},"DoctorListPanel");var lr=Object.defineProperty,ze=N((e,t)=>lr(e,"name",{value:t,configurable:!0}),"g$1");const ar=ze(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"),cr=ze(e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},"buildOptimizeAction"),dr=ze(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"),ur=100,hr=40,pr=10,gr=ze(({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:s,store:o})=>{const{exit:l}=Ft(),{columns:d,rows:p}=zt(),c=Ht(o.subscribe,o.getSnapshot),[$,x]=xe(!1),[b,I]=xe(!1),[f,w]=xe(0),[E,Z]=xe(()=>Date.now());Ee(()=>{const y=setInterval(()=>{Z(Date.now())},1e3);return()=>{clearInterval(y)}},[]);const q=E-s,B=qe(null),M=qe(null),P=c.entries[c.selectedIndex]??null,L=Pe(()=>{const y={dependencies:0,optimization:0,runtime:0,security:0};for(const m of c.all)y[m.section]+=1;return y},[c.all]),X=t?t.hint?5:4:0,ie=Pe(()=>{for(const y of Object.keys(c.sectionStatus))if(c.sectionStatus[y]==="running"&&c.sectionMessage[y])return 1;return 0},[c.sectionStatus,c.sectionMessage]),G=d>=ur,D=G?Math.max(1,p-X-2):Math.floor(p*.55),V=Pe(()=>Math.max(1,D-6-ie-(c.filterActive?1:0)),[D,ie,c.filterActive]),[Y,v]=xe(V),A=Y>0?Y:V,R=Pe(()=>{let y=0;for(const[,m]of c.grouped)y+=2+m.length;return y},[c.grouped]),U=Math.max(0,R-A);Ee(()=>{w(y=>Math.min(y,U))},[U]);const ce=Xe(y=>{let m=0,k=0;for(const[,Se]of c.grouped){m+=2;for(const $e of Se){if(k===y)return m;m+=1,k+=1}}return m},[c.grouped]),O=Xe(y=>{const m=ce(y);w(k=>m>k+A-2?Math.min(U,Math.max(0,m-A+2)):m<k+1?Math.max(0,m-1):k)},[ce,A,U]);if(Ee(()=>{M.current?.scrollToTop()},[P?.id]),jt((y,m)=>{if(y==="c"&&m.ctrl){l();return}if(!b){if($){m.escape||y==="?"?x(!1):y==="q"?(x(!1),I(!0)):m.downArrow||y==="j"?B.current?.scrollBy(1):(m.upArrow||y==="k")&&B.current?.scrollBy(-1);return}if(y==="?"){x(!0);return}if(y==="q"){I(!0);return}if(m.tab){o.setFocusedPanel(c.focusedPanel==="list"?"detail":"list");return}if(c.filterActive){if(m.escape||m.return){o.setFilterActive(!1);return}if(m.backspace){w(0),o.setFilter(c.filterText.slice(0,-1));return}y&&!m.ctrl&&!m.meta&&(w(0),o.setFilter(c.filterText+y));return}if(c.focusedPanel==="list"&&(m.leftArrow||m.rightArrow)){const k=me.findIndex($e=>$e.id===c.filterType),Se=m.rightArrow?(k+1)%me.length:(k-1+me.length)%me.length;w(0),M.current?.scrollToTop(),o.setFilterType(me[Se].id);return}if(c.focusedPanel==="list"){if(m.downArrow||y==="j"){const k=Math.min(c.selectedIndex+1,c.entries.length-1);o.setSelectedIndex(k),O(k);return}if(m.upArrow||y==="k"){const k=Math.max(c.selectedIndex-1,0);o.setSelectedIndex(k),O(k);return}if(m.pageDown){const k=Math.min(c.selectedIndex+10,c.entries.length-1);o.setSelectedIndex(k),O(k);return}if(m.pageUp){const k=Math.max(c.selectedIndex-10,0);o.setSelectedIndex(k),O(k);return}if(m.home){o.setSelectedIndex(0),w(0);return}if(m.end){const k=c.entries.length-1;o.setSelectedIndex(k),O(k);return}if(y==="/"){o.setFilterActive(!0);return}if(y==="e"){o.setSeverityFilter(c.severityFilter==="error"?void 0:"error"),w(0);return}if(y==="w"){o.setSeverityFilter(c.severityFilter==="warn"?void 0:"warn"),w(0);return}if(y==="u"&&P){const k=ar(P);k&&(o.setPendingAction(k),l());return}if(y==="o"&&P){const k=cr(P);k&&(o.setPendingAction(k),l());return}if(y==="a"&&P){const k=dr(P);k&&(o.setPendingAction(k),l());return}if(y==="d"){o.setFocusedPanel("detail");return}return}if(m.escape||m.leftArrow){o.setFocusedPanel("list");return}if(m.downArrow||y==="j"){M.current?.scrollBy(1);return}if(m.upArrow||y==="k"){M.current?.scrollBy(-1);return}if(m.pageDown){M.current?.scrollBy(10);return}if(m.pageUp){M.current?.scrollBy(-10);return}if(m.home){M.current?.scrollToTop();return}m.end&&M.current?.scrollToBottom()}},{isActive:!0}),d<hr||p<pr)return r(h,{alignItems:"center",height:p,justifyContent:"center",width:d,children:a(n,{color:"yellow",children:["Terminal too small (",d,"x",p,")"]})});const W=c.focusedPanel==="detail",ee=[a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"q"}),r(n,{dimColor:!0,children:"QUIT"})]},"q"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"?"}),r(n,{dimColor:!0,children:"HELP"})]},"?"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"↑↓"}),r(n,{dimColor:!0,children:W?"SCROLL":"NAV"})]},"nav"),W?a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←/Esc"}),r(n,{dimColor:!0,children:"LIST"})]},"lr"):a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←→"}),r(n,{dimColor:!0,children:"SECTION"})]},"lr"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"/"}),r(n,{dimColor:!0,children:"SEARCH"})]},"search"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"e/w"}),r(n,{dimColor:!0,children:"SEVERITY"})]},"sev"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"u/o/a"}),r(n,{dimColor:!0,children:"ACTION"})]},"actions"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"Tab"}),r(n,{dimColor:!0,children:"PANEL"})]},"tab")],de=r(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(h,{gap:2,overflow:"hidden",paddingX:1,children:ee})}),ue=a(Et,{footer:a(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:B,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:$,width:56,children:[a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"NAVIGATION"})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" ↑/k "}),r(n,{dimColor:!0,children:"Move up"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" ↓/j "}),r(n,{dimColor:!0,children:"Move down"})]})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" PgUp"}),r(n,{dimColor:!0,children:" Jump up 10"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" PgDn"}),r(n,{dimColor:!0,children:" Jump down 10"})]})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" Home"}),r(n,{dimColor:!0,children:" Jump to top"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" End"}),r(n,{dimColor:!0,children:" Jump to bottom"})]})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" Tab"}),r(n,{dimColor:!0,children:" Switch panel"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" →/←"}),r(n,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"FILTER"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" /"}),r(n,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" e"}),r(n,{dimColor:!0,children:" Toggle errors-only filter"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" w"}),r(n,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"ACTIONS"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" u"}),r(n,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" o"}),r(n,{dimColor:!0,children:" Exit + suggest optimize command"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" a"}),r(n,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" d"}),r(n,{dimColor:!0,children:" Focus detail panel"})]})]}),a(h,{flexDirection:"column",children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"EXIT"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" q"}),r(n,{dimColor:!0,children:" Quit (with countdown)"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" Ctrl+C"}),r(n,{dimColor:!0,children:" Quit immediately"})]})]})]}),he=r(sr,{elapsedMs:q,entries:c.entries,filterActive:c.filterActive,filterText:c.filterText,filterType:c.filterType,focused:c.focusedPanel==="list",fromCache:i,grouped:c.grouped,onViewportHeightChange:v,scrollOffset:f,sectionCounts:L,sectionMessage:c.sectionMessage,sectionStatus:c.sectionStatus,selectedIndex:c.selectedIndex,severityFilter:c.severityFilter,totalAll:c.all.length,viewportHeight:A}),pe=t?r(Vi,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,be=r(Zi,{finding:P,focused:c.focusedPanel==="detail",scrollRef:M});if(G){const y=Math.floor(d*.4);return a(h,{flexDirection:"column",height:p,width:d,children:[pe,a(h,{flexDirection:"row",flexGrow:1,children:[r(h,{flexGrow:1,children:he}),r(h,{width:y,children:be})]}),de,r(Je,{autoExitSeconds:e||3,onCancel:N(()=>{I(!1)},"onCancel"),visible:b}),ue]})}return a(h,{flexDirection:"column",height:p,width:d,children:[pe,r(h,{height:D,children:he}),r(h,{flexGrow:1,children:be}),de,r(Je,{autoExitSeconds:e||3,onCancel:N(()=>{I(!1)},"onCancel"),visible:b}),ue]})},"VisDoctorApp");var fr=Object.defineProperty,we=N((e,t)=>fr(e,"name",{value:t,configurable:!0}),"n$1");const mr=we(e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),"escapeRegex"),yr=we(e=>{const t=e.split("*").map(mr);return new RegExp(`^${t.join(".*")}$`,"i")},"compilePattern"),kr=we(e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(yr):[],"parseFilterPatterns"),Ne=we((e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},"matchesAny"),wr=we((e,t)=>{if(t.length===0)return e;const i=e.outdated.filter(c=>Ne(c.packageName,t)),s=e.duplicates.filter(c=>Ne(c.name,t)),o=e.optimizations.filter(c=>Ne(c.packageName,t));let l=0,d=0,p=0;for(const c of i)c.vulnerabilities&&(l+=c.vulnerabilities.length),c.socketReport&&(d+=c.socketReport.alerts.length,c.socketReport.score.overall<Be&&(p+=1));return{...e,duplicates:s,optimizations:o,outdated:i,socketIssues:{alerts:d,lowScore:p},vulnCount:l}},"applyFilter"),vt=we((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 Ne(s,t)}),"filterFindingsByPattern");var vr=Object.defineProperty,ve=N((e,t)=>vr(e,"name",{value:t,configurable:!0}),"r");const bt=["dependencies","security","optimization","runtime"],it=ve(e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const s=i.trim().toLowerCase();bt.includes(s)&&t.add(s)}return t},"parseSectionList"),br=ve((e,t)=>{if(e!==void 0&&e!=="")return it(e);const i=it(t);return new Set(bt.filter(s=>!i.has(s)))},"resolveSections"),St=ve(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=ve((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"),Sr=ve((e,t)=>{const i=St(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"),rt=ve((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 $r=Object.defineProperty,$t=N((e,t)=>$r(e,"name",{value:t,configurable:!0}),"l");const nt=$t(e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok","rollUpStatus"),Cr=$t(e=>{const t=[],i=e?.security;if(!i)return t.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:t,status:nt(t)};i.minimumReleaseAge===void 0?t.push({detail:"Set security.minimumReleaseAge to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"minimumReleaseAge is not set",severity:"warn"}):i.minimumReleaseAge===0?t.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"minimumReleaseAge is explicitly 0",severity:"warn"}):t.push({label:`minimumReleaseAge: ${String(i.minimumReleaseAge)} minutes`,severity:"ok"}),i.trustPolicy===void 0||i.trustPolicy==="off"?t.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`trustPolicy: ${i.trustPolicy??"not set"}`,severity:"warn"}):t.push({label:`trustPolicy: ${i.trustPolicy}`,severity:"ok"}),i.blockExoticSubdeps===void 0||!i.blockExoticSubdeps?t.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(i.blockExoticSubdeps??!1)}`,severity:"warn"}):t.push({label:"blockExoticSubdeps: true",severity:"ok"});const s=i.allowBuilds?Object.keys(i.allowBuilds).length:0;return s===0?t.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"allowBuilds: not configured",severity:"warn"}):t.push({label:`allowBuilds: ${String(s)} ${s===1?"entry":"entries"}`,severity:"ok"}),i.strictDepBuilds&&s===0&&t.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate allowBuilds.",label:"strictDepBuilds is on but allowBuilds is empty",severity:"error"}),{findings:t,status:nt(t)}},"buildSupplyChainPosture");var xr=Object.defineProperty,C=N((e,t)=>xr(e,"name",{value:t,configurable:!0}),"u");const H=C(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,"fmtDuration"),De=C(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:p,summary:c}=s(l,d);return e.finish(t,p,c),l}catch(l){const d=Date.now()-o,p=l instanceof Error?l.message:String(l);throw e.finish(t,"error",`${p} (${H(d)})`),l}},"tracked"),Rr=C((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 yt(i)},"buildSectionFindings"),ot=C(async e=>{const{filterPatterns:t,installed:i,progress:s,resolveCodemods:o,sections:l,store:d,visConfig:p,workspaceRoot:c}=e,$=l.has("dependencies"),x=l.has("security"),b=l.has("optimization"),I=l.has("runtime"),f=C((g,F)=>vt(Rr(g,F),t),"sectionFindings"),w=at(c),{packageManager:E}=st(c),Z=Qe(le(c,"package.json"),!1),q=dt(c),B=new Set(Z);for(const g of q){const F=Qe(le(Pt(c,g),"package.json"),!1);for(const z of F)B.add(z)}const M=hi(c),P=ht(c,E),L=ct(p?.security?.socket),X=p?.security?.socket?.acceptedRisks,ie=ei(c,w.name),G={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},D=$?li(c,w.name):[],V=b?ti(B):[],Y=b?ii(B,ie,w,!1):[],v=new Set(V.map(g=>g.packageName)),A=Y.filter(g=>!v.has(g.packageName)),R=[...V,...A],U=I?Oi():[];d&&($&&d.startSection("dependencies",P.size>0?"checking outdated catalog dependencies":"scanning duplicates"),x&&d.startSection("security",i.length>0?`scanning ${String(i.length)} packages for advisories`:"no installed packages to scan"),b&&d.startSection("optimization","matching e18e + socket overrides"),I&&d.startSection("runtime","running runtime diagnostics")),d&&I&&d.completeSection("runtime",f("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:U}));const ce=($||x)&&P.size>0?De(s,"outdated",()=>pi(P,G,M,void 0,c,L,X),(g,F)=>{const z=g.outdated.length;return{status:z>0?"warn":"ok",summary:z>0?`${String(z)} outdated · ${H(F)}`:`up to date · ${H(F)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),O=x&&i.length>0?De(s,"vulnerabilities",()=>gi(i.map(g=>({name:g.name,version:g.version}))),(g,F)=>{let z=0;for(const re of g.values())z+=re.length;return{status:z>0?"error":"ok",summary:z>0?`${String(z)} found · ${H(F)}`:`none found · ${H(F)}`}}):Promise.resolve(new Map),W=x&&L&&i.length>0?De(s,"socket",()=>Lt(i.map(g=>({name:g.name,version:g.version})),L),(g,F)=>{let z=0,re=0;for(const Ye of g.values())z+=Ye.alerts.length,Ye.score.overall<Be&&(re+=1);const Ge=z+re;return{status:Ge>0?"warn":"ok",summary:Ge>0?`${String(z)} alert${z===1?"":"s"}, ${String(re)} low-score · ${H(F)}`:`clean · ${H(F)}`}}):Promise.resolve(new Map);let ee,de,ue,he;const pe=ce.catch(g=>(ee=g instanceof Error?g.message:String(g),d||u.warn(`Outdated scan failed: ${ee}`),{failed:[],ignored:[],outdated:[]})),be=O.catch(g=>(de=g instanceof Error?g.message:String(g),d||u.warn(`Vulnerability scan failed: ${de}`),new Map)),y=W.catch(g=>(ue=g instanceof Error?g.message:String(g),d||u.warn(`Socket scan failed: ${ue}`),new Map)),m=d&&$?pe.then(g=>{if(ee){d.failSection("dependencies",ee);return}d.completeSection("dependencies",f("dependencies",{duplicates:D,optimizations:[],outdated:g.outdated,runtime:[]}))}):void 0,k=d&&x?Promise.all([pe,be,y]).then(([g])=>{const F=ee??de??ue;if(F){d.failSection("security",F);return}d.completeSection("security",f("security",{duplicates:[],optimizations:[],outdated:g.outdated,runtime:[]}))}):void 0,Se=(async()=>{if(o&&b&&R.length>0&&await De(s,"codemods",async()=>(await ri(R),R),(g,F)=>{const z=g.filter(re=>re.hasCodemod||re.category==="socket").length;return{status:"ok",summary:`${String(z)} auto-fixable · ${H(F)}`}}).catch(g=>{he=g instanceof Error?g.message:String(g)}),d&&b){if(he){d.failSection("optimization",he);return}d.completeSection("optimization",f("optimization",{duplicates:[],optimizations:R,outdated:[],runtime:[]}))}})(),[$e,xt,Rt]=await Promise.all([pe,be,y]);await Promise.all([m,k,Se]);let Ue=0,He=0;if(x&&L)for(const g of Rt.values())Ue+=g.alerts.length,g.score.overall<Be&&(He+=1);let je=0;if(x){for(const g of $e.outdated)g.vulnerabilities&&g.vulnerabilities.length>0&&(je+=g.vulnerabilities.length);for(const g of xt.values())je+=g.length}return{duplicates:D,installedCount:i.length,optimizations:b?R:[],outdated:$?$e.outdated:[],runtime:U,sections:l,socketIssues:{alerts:Ue,lowScore:He},supplyChain:Cr(p),vulnCount:je,workspaceCount:q.length}},"streamScans"),Tr=C(e=>{switch(e){case"error":return Re(j.failure);case"skip":return S(j.dash);case"warn":return Fe(j.warning);default:return ke(j.success)}},"sectionIcon"),ae=C((e,t)=>{const i=process.stderr.columns??80,s=Math.max(20,Math.min(i-2,60)),o=j.dash.repeat(2),l=`${Tr(t)} ${se(e)}`,d=l.replaceAll(/\[[0-9;]*m/g,"").length,p=Math.max(0,s-d-o.length-2);return`${o} ${l} ${S(j.dash.repeat(p))}`},"heading"),J=C(e=>` ${ke(j.success)} ${e}`,"itemOk"),Q=C(e=>` ${Fe(j.warning)} ${e}`,"itemWarn"),Ve=C(e=>` ${Re(j.failure)} ${e}`,"itemError"),Ct=C(e=>` ${S(j.dash)} ${S(e)}`,"itemSkip"),K=C((e,t,i)=>{const s=`${se(String(e))} ${S(t)}`;return i?`${s} ${S(`(${i})`)}`:s},"countLine"),Ar=C(e=>{if(e.sections.has("dependencies")){if(u.log(""),u.log(ae("Dependencies",ne(e,"dependencies"))),u.log(J(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(Q(K(e.outdated.length,"outdated",o.join(", "))))}else u.log(J("All dependencies up to date"));e.duplicates.length>0?u.log(Q(K(e.duplicates.length,"packages with duplicate versions"))):u.log(J("No duplicate dependencies"))}},"displayDependencies"),Ir=C(e=>{e.sections.has("security")&&(u.log(""),u.log(ae("Security",ne(e,"security"))),e.vulnCount>0?u.log(Ve(K(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):u.log(J("No known vulnerabilities")),e.socketIssues.alerts>0&&u.log(Q(K(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&u.log(Q(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(J("No security issues detected")))},"displaySecurity"),Pr=C(e=>{if(!e.sections.has("optimization"))return;u.log(""),u.log(ae("Optimization",ne(e,"optimization")));const t=St(e.optimizations);if(t.total===0){u.log(J("No optimizations available"));return}t.native>0&&u.log(Q(K(t.native,"replaceable with native APIs"))),t.preferred>0&&u.log(Q(K(t.preferred,"with lighter alternatives"))),t.micro>0&&u.log(Q(K(t.micro,"trivial micro-utilities"))),t.socket>0&&u.log(Q(K(t.socket,"@socketregistry overrides available")))},"displayOptimization"),Dr=C(e=>{u.log(""),u.log(ae("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?J(t.label):t.severity==="error"?Ve(t.label):Q(t.label);u.log(i),t.detail&&u.log(` ${S(j.arrow)} ${S(t.detail)}`)}e.supplyChain.status!=="ok"&&u.log(` ${S(j.arrow)} ${S("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},"displaySupplyChain"),Or=C(e=>{if(e.sections.has("runtime")){u.log(""),u.log(ae("Runtime",ne(e,"runtime")));for(const t of e.runtime)t.status==="ok"?u.log(J(t.message)):t.status==="skip"?u.log(Ct(t.message)):u.log(Q(t.message))}},"displayRuntime"),Nr=C((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! ${S(`(${H(e.elapsedMs)})`)}`);else{const l=[];i>0&&l.push(Re(`${String(i)} security`)),o>0&&l.push(Fe(`${String(o)} improvement${o===1?"":"s"}`)),u.log(`${Re(j.failure)} ${l.join(", ")} ${S(`(${H(e.elapsedMs)})`)}`)}return}u.log(""),u.log(ae("Summary","ok")),i===0&&o===0?u.success(`Everything looks good! ${S(`(${H(e.elapsedMs)})`)}`):(i>0&&u.error(`${String(i)} security issue${i===1?"":"s"}`),o>0&&u.log(` ${Te(j.arrow)} ${se(String(o))} ${S(`improvement${o===1?"":"s"} available`)} ${S(`(${H(e.elapsedMs)})`)}`))},"displaySummary"),Mr=C(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(se("Next steps:"));for(const i of t)u.log(` ${S(j.arrow)} ${i}`)}u.log("")},"displayActions"),Fr=C((e,t)=>{t||(Ar(e),Ir(e),Pr(e),Or(e),Dr(e)),Nr(e,t)},"displayResults"),zr=C((e,t,i,s,o)=>{const l=[],d=e.has("dependencies"),p=e.has("security"),c=e.has("optimization");return(d||p)&&t>0&&l.push({id:"outdated",label:"Outdated catalog dependencies"}),p&&s>0&&l.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),p&&i&&s>0&&l.push({id:"socket",label:"Socket.dev supply-chain reports"}),c&&o&&l.push({id:"codemods",label:"Codemod availability"}),l},"planScanTasks"),jr=C(e=>{if(u.log(""),u.log(`${se(Te("vis doctor"))} ${S("— project health check")}`),u.log(J(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.workspaceCount!==void 0&&e.workspaceCount>0&&u.log(J(K(e.workspaceCount,`workspace package${e.workspaceCount===1?"":"s"}`))),e.runtimeFindings.length===0)u.log(J(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?Re:Fe;u.log(Ve(`Runtime: ${i(t.message)}`))}u.log(` ${S(j.arrow)} Run ${ke("vis toolchain install")} to install pinned versions, or ${ke("vis toolchain status")} for the per-tool breakdown.`)}u.log("")},"printBanner"),rn=C(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=br(t.only,t.skip),p=!!t.quiet,c=!!t.noProgress,$=kr(t.filter);if(d.size===0){u.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const x=Date.now(),b=at(o),I=si(o),f=!!process.stdout.isTTY,w=!l&&f&&!_t&&!p&&!c;!l&&!w&&jr({nodeVersion:process.versions.node,packageManagerName:b.name,packageManagerVersion:b.version,runtimeFindings:I,workspaceCount:void 0});const E=ht(o,st(o).packageManager),Z=ai(o,b.name),q=Z.length,B=!!ct(i?.security?.socket),M=dt(o);if(!l&&!p&&!w){const O=M.length>0?S(` · ${String(M.length)} workspace package${M.length===1?"":"s"}`):"";u.log(`${S("·")} ${S("Found")} ${se(String(q))} ${S(`installed package${q===1?"":"s"}`)}${O}`)}const P=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,L={bun:"bun.lock",npm:"package-lock.json",pnpm:"pnpm-lock.yaml",yarn:"yarn.lock"}[b.name],X=L?le(o,L):void 0,ie=Zt(o),G=!t.noCache&&!t.fix?ki({configPath:ie,lockfilePath:X,sections:d,socketEnabled:B,workspaceRoot:o}):void 0,D=G?wi(G):void 0,V=D!==void 0;let Y,v;if(w){const O=D?new et({activeSections:d,findings:vt(yt(D),$)}):new et({activeSections:d}),W=Bt(Ut.createElement(gr,{banner:P,fromCache:V,startedAt:x,store:O}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{Y=D??await ot({filterPatterns:$,installed:Z,resolveCodemods:!!t.fix,sections:d,store:O,visConfig:i,workspaceRoot:o})}catch(ee){throw W.unmount(),ee}await W.waitUntilExit(),v=O.getSnapshot().pendingAction}else if(D)Y=D;else{const O=zr(d,E.size,B,q,!!t.fix),W=ci(O,{live:!l&&!p&&!c});try{Y=await ot({filterPatterns:$,installed:Z,progress:W,resolveCodemods:!!t.fix,sections:d,visConfig:i,workspaceRoot:o})}finally{W.stop()}}const A={...Y,elapsedMs:Date.now()-x};if(G&&!V)try{vi(G,A)}catch{}const R=wr(A,$);if(l){process.stdout.write(`${JSON.stringify(Sr(R,b.name),void 0,2)}
|
|
4
|
-
`),
|
|
5
|
-
|
|
6
|
-
`),v.
|
|
7
|
-
`),process.stdout.write(`${S(v.configSnippet)}
|
|
8
|
-
`)):process.stdout.write(` ${Te(v.command)}
|
|
9
|
-
`),process.stdout.write(`
|
|
10
|
-
`)),t.exitCode&&rt(R,!!t.strict)&&(process.exitCode=1)},"execute"),Er=C(async e=>{const{force:t,logger:i,pm:s,recoverOrphans:o,results:l,workspaceRoot:d}=e;u.log(""),u.log(ae("Applying fixes","ok"));const p=l.optimizations.filter(f=>f.category==="socket"&&f.overrideSpec).map(f=>({original:f.packageName,spec:f.overrideSpec})),c=l.optimizations.filter(f=>f.category!=="socket"&&f.hasCodemod),$=l.optimizations.filter(f=>f.category!=="socket"&&!f.hasCodemod);let x=!1,b=0;const I=[];if(o){const f=Ri({force:t});if(f.killed.length>0&&(u.success(`Cleaned up ${String(f.killed.length)} orphaned process${f.killed.length===1?"":"es"} (PIDs: ${f.killed.join(", ")}).`),x=!0),f.failed.length>0){const w=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";u.warn(`Could not signal ${String(f.failed.length)} orphan${f.failed.length===1?"":"s"}: ${f.failed.map(E=>`${String(E.pid)} (${E.reason})`).join(", ")}.${w}`)}}if(p.length>0){const f=ni(d,le(d,"package.json"),p,s);f.added.length>0&&(u.success(`Added ${String(f.added.length)} security override${f.added.length===1?"":"s"}.`),x=!0),f.updated.length>0&&(u.success(`Updated ${String(f.updated.length)} override${f.updated.length===1?"":"s"}.`),x=!0)}for(const f of c)try{const w=await oi(d,f.packageName);w.filesChanged>0&&(u.success(`${f.packageName}: ${String(w.filesChanged)} file${w.filesChanged===1?"":"s"} updated`),b+=1,x=!0)}catch(w){const E=w instanceof Error?w.message:String(w);I.push({error:E,package:f.packageName}),u.warn(`${f.packageName}: codemod failed — ${E}`)}p.length>0&&(u.log(`${Te(j.arrow)} Running ${s.name} install to update lockfile…`),Vt(s,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},d,i),x=!0),u.log(""),x?u.success(`Fixes applied. ${b>0?`${String(b)} codemod${b===1?"":"s"} applied.`:""}`.trim()):u.log(Ct("No auto-fixable items in the current run.")),I.length>0&&u.warn(`${String(I.length)} codemod${I.length===1?"":"s"} failed (run ${ke("vis optimize")} for the interactive picker).`),$.length>0&&u.notice(`${String($.length)} optimization${$.length===1?"":"s"} need manual review (no codemod). Run ${ke("vis optimize")} to inspect them.`)},"runFixes");export{rn as default};
|
|
1
|
+
var se=Object.defineProperty;var P=(e,r)=>se(e,"name",{value:r,configurable:!0});import{createRequire as le}from"node:module";import{isAccessibleSync as q,readFileSync as re}from"@visulima/fs";import{resolve as D,isAbsolute as W,relative as J,join as M,basename as fe}from"@visulima/path";import{Box as d,Text as c,ScrollView as he,ScrollBar as ge,useApp as pe,useWindowSize as me,useInput as we,render as ye}from"@visulima/tui";import{aA as xe,aB as H,aC as be,aD as Se,p as v,s as ve}from"./bin.js";import ke,{useSyncExternalStore as $e,useRef as A,useCallback as X}from"react";import{o as Pe}from"../packem_shared/index-DH-5hsrC.js";import{sortPackageJsonStringWithOptions as te}from"#native";import{jsxs as f,jsx as l,Fragment as Ee}from"react/jsx-runtime";import z from"ignore";import{f as N}from"../packem_shared/utils-DrNg0XTR.js";const ce=le(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ae=P(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[r,t]=F.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return F.getBuiltinModule(e)}return ce(e)},"__cjs_getBuiltinModule"),{readFileSync:de,writeFileSync:ue}=ae("node:fs");var Oe=Object.defineProperty,T=P((e,r)=>Oe(e,"name",{value:r,configurable:!0}),"i$2");const K={error:0,rewritten:1,"would-rewrite":1,unchanged:2},je=T(e=>[...e].sort((r,t)=>K[r.status]-K[t.status]),"sortByStatusRank"),Ce=T((e,r)=>r==="all"?e:r==="errors"?e.filter(t=>t.status==="error"):r==="rewritten"?e.filter(t=>t.status==="rewritten"||t.status==="would-rewrite"):e.filter(t=>t.status==="unchanged"),"filterEntries");class Ie{static{P(this,"a")}static{T(this,"SortPackageJsonStore")}#e;#r=new Set;constructor(r){this.#e={entries:je(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=T(()=>this.#e,"getSnapshot");subscribe=T(r=>(this.#r.add(r),()=>{this.#r.delete(r)}),"subscribe");getFilteredEntries=T(()=>Ce(this.#e.entries,this.#e.filterType),"getFilteredEntries");#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(r,t.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}var Re=Object.defineProperty,Te=P((e,r)=>Re(e,"name",{value:r,configurable:!0}),"c$2");const Fe=Te(({checkMode:e,entry:r,focused:t,scrollRef:s})=>r?f(d,{borderColor:t?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[l(d,{flexShrink:0,paddingTop:1,paddingX:2,children:l(c,{bold:!0,color:"white",children:r.relativePath})}),f(he,{flexGrow:1,flexShrink:1,paddingX:2,ref:s,scrollbar:!0,scrollbarColor:"gray",children:[l(c,{}),f(d,{children:[l(d,{width:10,children:l(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?l(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?l(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?l(c,{bold:!0,color:"yellow",children:"rewritten"}):l(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),f(d,{children:[l(d,{width:10,children:l(c,{dimColor:!0,children:"Path:"})}),l(c,{children:r.filePath})]}),r.error?f(Ee,{children:[f(d,{flexDirection:"column",marginTop:1,children:[l(c,{dimColor:!0,children:"── "}),l(c,{bold:!0,color:"red",children:"ERROR"}),f(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(d,{children:[l(d,{width:10,children:l(c,{dimColor:!0,children:"Step:"})}),l(c,{color:"yellow",children:r.error.step})]}),r.error.context&&f(d,{children:[l(d,{width:10,children:l(c,{dimColor:!0,children:"Position:"})}),l(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),l(d,{marginTop:1,children:l(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&f(d,{flexDirection:"column",marginTop:1,children:[l(c,{dimColor:!0,children:"── "}),l(c,{bold:!0,color:"white",children:"SNIPPET"}),f(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(o=>{const i=`${o.isErrorLine?"❯":" "} ${String(o.lineNumber).padStart(4)} `;return f(d,{children:[l(c,{color:o.isErrorLine?"red":"gray",children:i}),l(c,{color:o.isErrorLine?"white":"gray",wrap:"truncate-end",children:o.content||" "})]},o.lineNumber)}),r.error.context.column>0&&l(d,{children:l(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):f(d,{flexDirection:"column",marginTop:1,children:[l(c,{dimColor:!0,children:"── "}),l(c,{bold:!0,color:"white",children:"KEY DIFF"}),l(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?l(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(o=>{const i=o.toIndex-o.fromIndex,a=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,g=i<0?"green":"yellow";return f(d,{children:[l(d,{width:28,children:l(c,{wrap:"truncate",children:o.key})}),l(d,{width:10,children:f(c,{dimColor:!0,children:[String(o.fromIndex)," → ",String(o.toIndex)]})}),l(c,{color:g,children:a})]},o.key)})}),e&&r.status==="would-rewrite"&&l(d,{marginTop:1,paddingLeft:2,children:l(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):l(d,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:l(c,{dimColor:!0,children:"No entry selected"})}),"SortDetailPanel");var Me=Object.defineProperty,O=P((e,r)=>Me(e,"name",{value:r,configurable:!0}),"i$1");const Ae={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},Ne={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},oe={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},De={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},Ge=[{count:O(e=>e.errors+e.rewrites+e.sorted,"count"),key:"all",label:"All",shortcut:"1"},{count:O(e=>e.rewrites,"count"),key:"rewritten",label:"Rewrites",shortcut:"2"},{count:O(e=>e.errors,"count"),key:"errors",label:"Errors",shortcut:"3"},{count:O(e=>e.sorted,"count"),key:"unchanged",label:"Sorted",shortcut:"4"}],ne=O(e=>{const r={errors:0,rewrites:0,sorted:0};for(const t of e)r[oe[t.status]]++;return r},"computeGroupCounts"),Be=O(({entry:e,isSelected:r})=>{const t=Ae[e.status],s=Ne[e.status];return f(d,{flexShrink:0,height:1,children:[l(c,{children:r?">":" "}),l(c,{children:" "}),l(c,{bold:!0,color:t,children:`[${s}]`.padEnd(10)}),l(c,{children:" "}),l(d,{flexGrow:1,children:l(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&l(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},"EntryRow"),Le=O(({color:e,count:r,label:t})=>l(d,{flexShrink:0,height:1,children:l(c,{bold:!0,color:e,children:`${t} (${String(r)})`})}),"SectionHeader"),Je=O(({counts:e,entries:r,filterType:t,focused:s,selectedIndex:n,totalEntries:o,viewportHeight:i})=>{const a=s?"white":"gray",g=ne(r),b=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),w=t==="all"&&b>1,p=[];let m;for(const[u,y]of r.entries()){const S=oe[y.status];w&&S!==m&&(m!==void 0&&p.push({kind:"spacer"}),p.push({color:S==="errors"?"red":S==="rewrites"?"yellow":"green",count:g[S],kind:"header",label:De[S]}),m=S),p.push({entry:y,entryIndex:u,kind:"entry"})}const k=p.findIndex(u=>u.kind==="entry"&&u.entryIndex===n),$=k!==-1,E=p.length,h=Math.max(0,E-i);let C=0;$&&i>0&&(C=Math.min(h,Math.max(0,k-i+1)));const R=E>i&&i>0;return f(d,{borderColor:a,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(d,{flexShrink:0,gap:1,paddingX:1,children:[l(c,{bold:!0,inverse:!0,children:" VIS SORT "}),f(c,{wrap:"truncate",children:[o," ","file",o===1?"":"s"]})]}),l(d,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ge.map(u=>{const y=t===u.key,S=u.count(e);return f(d,{children:[l(c,{dimColor:!y,children:"["}),l(c,{bold:y,color:y?"cyan":"gray",children:u.shortcut}),l(c,{dimColor:!y,children:"]"}),f(c,{color:y?"white":"gray",children:[" ",u.label]}),f(c,{dimColor:!0,children:[" ","(",S,")"]})]},u.key)})}),f(d,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[l(d,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:l(d,{flexDirection:"column",marginTop:-C,children:p.map((u,y)=>u.kind==="spacer"?l(d,{flexShrink:0,height:1},`s-${String(y)}`):u.kind==="header"?l(Le,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):l(Be,{entry:u.entry,isSelected:u.entryIndex===n},u.entry.filePath))})}),R&&l(d,{flexShrink:0,marginLeft:1,marginRight:1,children:l(ge,{contentHeight:E,placement:"inset",scrollOffset:C,style:"block",viewportHeight:i})})]})]})},"SortListPanel");var _e=Object.defineProperty,qe=P((e,r)=>_e(e,"name",{value:r,configurable:!0}),"T");const We=100,V=10,He=6,Xe=1,Y={1:"all",2:"rewritten",3:"errors",4:"unchanged"},ze=qe(({checkMode:e,store:r})=>{const{exit:t}=pe(),{columns:s,rows:n}=me(),o=$e(r.subscribe,r.getSnapshot),i=A(null),a=r.getFilteredEntries(),g=a[o.selectedIndex]??null,b=ne(o.entries),w=s>=We,p=Math.max(0,n-Xe),m=w?p:Math.floor(p/2),k=Math.max(0,m-He),$=X(()=>{t()},[t]),E=A(0),h=A(void 0),C=A(!1),R=X((u,y)=>{E.current+=y,h.current=u,!C.current&&(C.current=!0,queueMicrotask(()=>{C.current=!1;const S=E.current,_=h.current;E.current=0,h.current=void 0,!(S===0||_===void 0)&&(_==="list"?r.selectStep(Math.sign(S)):i.current?.scrollBy(Math.sign(S)))}))},[r]);return we((u,y)=>{if(u==="q"||y.escape){$();return}if(Y[u]){r.setFilter(Y[u]);return}if(y.tab){r.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}o.focusedPanel==="list"?y.upArrow||u==="k"?R("list",-1):(y.downArrow||u==="j")&&R("list",1):o.focusedPanel==="detail"&&(y.upArrow||u==="k"?R("detail",-1):(y.downArrow||u==="j")&&R("detail",1))}),n<V?l(d,{alignItems:"center",justifyContent:"center",children:f(c,{color:"yellow",children:["Terminal too small. Resize to at least",V," ","rows."]})}):f(d,{flexDirection:"column",height:n,width:s,children:[f(d,{flexDirection:w?"row":"column",flexGrow:1,children:[l(d,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:l(Je,{counts:b,entries:a,filterType:o.filterType,focused:o.focusedPanel==="list",selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:k})}),l(d,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:l(Fe,{checkMode:e,entry:g,focused:o.focusedPanel==="detail",scrollRef:i})})]}),l(d,{flexShrink:0,paddingX:1,children:l(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},"VisSortPackageJsonApp");var Ke=Object.defineProperty,j=P((e,r)=>Ke(e,"name",{value:r,configurable:!0}),"c$1");const U=["types","node-addons","node","import","require","default"],Ve=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Ye=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,G=j(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),L=j(e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(t=>L(t));const r={};for(const[t,s]of Object.entries(e))r[t]=L(s);return r},"cloneDeep"),Ue=j(e=>{if(!G(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},"tryFormatBugs"),Qe=j(e=>e.endsWith(".git")?e.slice(0,-4):e,"stripGitSuffix"),Ze=j(e=>{if(!G(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:t}=e;if(typeof t!="string")return{changed:!1,value:e};const s=Ve.exec(t)??Ye.exec(t);if(!s)return{changed:!1,value:e};const n=s[1],o=Qe(s[2]??"");if(!n||!o)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const a of Object.keys(e))if(!i.has(a))return{changed:!1,value:e};return{changed:!0,value:`${n}/${o}`}},"tryFormatRepository"),er=j(e=>{const r=Object.keys(e),t=[],s=[];for(const i of U)Object.hasOwn(e,i)&&t.push(i);for(const i of r)U.includes(i)||s.push(i);const n=[...t,...s];if(n.length===r.length&&n.every((i,a)=>i===r[a]))return{changed:!1,value:e};const o={};for(const i of n)o[i]=e[i];return{changed:!0,value:o}},"orderConditions"),ie=j(e=>{if(!G(e))return{changed:!1,value:e};let r=!1;const t={};for(const[n,o]of Object.entries(e)){const i=ie(o);t[n]=i.value,i.changed&&(r=!0)}const s=er(t);return{changed:r||s.changed,value:s.value}},"sortExportsRecursive"),rr=j((e,r)=>{const t=L(e);let s=!1;if(r.formatBugs!==!1&&Object.hasOwn(t,"bugs")){const n=Ue(t.bugs);n.changed&&(t.bugs=n.value,s=!0)}if(r.formatRepository!==!1&&Object.hasOwn(t,"repository")){const n=Ze(t.repository);n.changed&&(t.repository=n.value,s=!0)}if(r.sortExports!==!1&&Object.hasOwn(t,"exports")&&G(t.exports)){const n=ie(t.exports);n.changed&&(t.exports=n.value,s=!0)}return{changed:s,pkg:t}},"formatPackageJsonFields");var tr=Object.defineProperty,I=P((e,r)=>tr(e,"name",{value:r,configurable:!0}),"i");const or=z.default??z,nr=[".git/","node_modules/"],ir=/\/+$/,Q=I(e=>{try{return de(e,"utf8")}catch{return}},"safeRead"),sr=I(e=>e.replaceAll("\\","/"),"toForwardSlashes"),lr=I(e=>{if(!e||e.length===0)return[];const r=[];for(const t of e){const s=t.replace(ir,"");if(s.startsWith("!")){const n=s.slice(1);n.length>0&&r.push(n)}}return r},"extractWorkspaceExcludePatterns"),cr=I(e=>{const{cwd:r}=e,t=or();if(e.builtinExcludes!==!1&&t.add(nr),e.rootGitignore!==!1){const o=Q(D(r,".gitignore"));o!==void 0&&t.add(o)}for(const o of e.extraIgnoreFiles??[]){const i=W(o)?o:D(r,o),a=Q(i);a!==void 0&&t.add(a)}e.extraPatterns&&e.extraPatterns.length>0&&t.add(e.extraPatterns);const s=I(o=>{const i=W(o)?o:D(r,o),a=sr(J(r,i));return a===""||a.startsWith("../")||a===".."?!1:t.ignores(a)},"ignores"),n={add:I(o=>(t.add(o),n),"add"),filter:I(o=>o.filter(i=>!s(i)),"filter"),ignores:s};return n},"buildGitignoreMatcher");var ar=Object.defineProperty,x=P((e,r)=>ar(e,"name",{value:r,configurable:!0}),"c");const dr=/at position (\d+)/,ur=/\(?line (\d+) column (\d+)\)?/,fr=x(e=>{const r=new Set,t=[],s=x(o=>{const i=D(o);!r.has(i)&&q(i)&&(r.add(i),t.push(i))},"addFile");s(M(e,"package.json"));const n=xe(e);if(n){const o=H(e,n);for(const i of o)s(M(e,i,"package.json"))}else{const o=M(e,"package.json");if(q(o)){const i=JSON.parse(re(o)),a=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(a){const g=H(e,a);for(const b of g)s(M(e,b,"package.json"))}}}return t},"findPackageJsonFiles"),hr=x(e=>/\n([ \t]+)/.exec(e)?.[1]??" ","detectIndent"),gr=x(e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},"resolveIndentOverride"),B=x(e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),"splitList"),pr=x(e=>e.includes(`\r
|
|
2
|
+
`)?"crlf":"lf","detectLineEnding"),mr=new Set(["auto","crlf","lf"]),wr=x(e=>{if(e===void 0||e==="")return"auto";if(mr.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},"validateLineEnding"),yr=x((e,r,t)=>r.length===0?e:e.filter(s=>{const n=J(t,s),o=fe(s);return!r.some(i=>{const a=i.includes("/")?n:o;return Pe(i,a)})}),"filterByIgnore"),xr=x((e,r)=>{if(r.length===0)return e;const t={},s=new Set;for(const n of r)Object.hasOwn(e,n)&&(t[n]=e[n],s.add(n));for(const n of Object.keys(e))s.has(n)||(t[n]=e[n]);return t},"applySortOrder"),br=x((e,r,t)=>{if(t.length===0)return e;const s={...e};for(const n of t)Object.hasOwn(r,n)&&(s[n]=r[n]);return s},"restoreUnsortedSections"),Sr=x((e,r)=>{let t=1,s=1;const n=Math.min(r,e.length);for(let o=0;o<n;o++)e.codePointAt(o)===10?(t++,s=1):s++;return{column:s,line:t}},"computeLineColumn"),Z=x((e,r,t=2)=>{const s=e.split(`
|
|
3
|
+
`);if(r<1||r>s.length)return[];const n=Math.max(0,r-1-t),o=Math.min(s.length,r+t),i=[];for(let a=n;a<o;a++)i.push({content:s[a]??"",isErrorLine:a+1===r,lineNumber:a+1});return i},"buildSnippet"),ee=x((e,r)=>{if(!(e instanceof Error))return;const t=dr.exec(e.message);if(t){const{column:n,line:o}=Sr(r,Number.parseInt(t[1]??"0",10));return{column:n,line:o,snippet:Z(r,o)}}const s=ur.exec(e.message);if(s){const n=Number.parseInt(s[1]??"1",10);return{column:Number.parseInt(s[2]??"1",10),line:n,snippet:Z(r,n)}}},"extractParseErrorContext"),vr=x((e,r)=>{const t=Object.keys(JSON.parse(e)),s=Object.keys(JSON.parse(r)),n=new Map(t.map((i,a)=>[i,a])),o=[];for(const[i,a]of s.entries()){const g=n.get(a);g!==void 0&&g!==i&&o.push({fromIndex:g,key:a,toIndex:i})}return o},"computeKeyDiff"),kr=x((e,r,t)=>{const s=r.indent??t.indent??hr(e),n=r.lineEnding==="auto"?t.lineEnding??pr(e):r.lineEnding,o=te(e,{pretty:!1,sortScripts:r.sortScripts});let i=JSON.parse(o);if(r.unsorted.length>0){const w=JSON.parse(e);i=br(i,w,r.unsorted)}i=xr(i,r.sortOrder);const a={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},g=rr(i,a);let b=JSON.stringify(g.pkg,null,s);return r.finalNewline&&(b+=`
|
|
4
|
+
`),n==="crlf"&&(b=b.replaceAll(`
|
|
5
|
+
`,`\r
|
|
6
|
+
`)),b},"sortContents"),$r=x((e,r)=>{const t=fr(e),s=be(e),n=cr({cwd:e,extraPatterns:lr(s)}),o=t.filter(a=>!n.ignores(a)),i=yr(o,r,e);return{afterGitignore:o,allFiles:t,files:i}},"discoverPackageJsonFiles"),Pr=x((e,{checkMode:r,cwd:t,normalized:s})=>{const n=J(t,e)||e;let o;try{o=re(e)}catch(w){return{diff:[],error:{message:N(w),step:"read"},filePath:e,relativePath:n,status:"error"}}let i;try{i=te(o,{pretty:!1,sortScripts:s.sortScripts})}catch(w){const p={message:N(w),step:"native-sort"},m=ee(w,o);return m&&(p.context=m),{diff:[],error:p,filePath:e,relativePath:n,status:"error"}}const a=s.editorconfig?Se(e):{};let g;try{g=kr(o,s,a)}catch(w){const p={message:N(w),step:"json-parse"},m=ee(w,o);return m&&(p.context=m),{diff:[],error:p,filePath:e,relativePath:n,status:"error"}}if(o===g)return{diff:[],filePath:e,relativePath:n,status:"unchanged"};let b;try{b=vr(o,i)}catch{b=[]}if(r)return{diff:b,filePath:e,relativePath:n,status:"would-rewrite"};try{ue(e,g,"utf8")}catch(w){return{diff:b,error:{message:N(w),step:"write"},filePath:e,relativePath:n,status:"error"}}return{diff:b,filePath:e,relativePath:n,status:"rewritten"}},"processFile"),Er=x(e=>{if(e.error&&(v.error(`${e.filePath}: ${e.error.message}`),v.info(` step: ${e.error.step}`),e.error.context)){v.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const t=r.isErrorLine?">":" ";v.info(` ${t} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},"printStaticError"),Br=x(async({options:e,visConfig:r,workspaceRoot:t})=>{const s=t??process.cwd(),n=r?.sortPackageJson,o=e.check||!1,i={editorconfig:e.editorconfig===!1?!1:n?.editorconfig??!0,finalNewline:e.finalNewline??n?.finalNewline??!0,formatBugs:e.formatBugs===!1?!1:n?.formatBugs??!0,formatRepository:e.formatRepository===!1?!1:n?.formatRepository??!0,ignore:[...B(e.ignore),...n?.ignore??[]],indent:gr(e.indent??n?.indent),lineEnding:wr(e.lineEnding??n?.lineEnding),sortExports:e.sortExports===!1?!1:n?.sortExports??!0,sortOrder:[...B(e.sortOrder),...n?.sortOrder??[]],sortScripts:e.sortScripts||n?.sortScripts||!1,unsorted:[...B(e.unsorted),...n?.unsorted??[]]},a=$r(s,i.ignore),{afterGitignore:g,allFiles:b,files:w}=a;if(w.length===0){b.length===0?v.info("No package.json files found."):g.length===0?v.info("All package.json files were excluded by .gitignore or workspace exclusions."):v.info("All package.json files were excluded by --ignore.");return}const p=[];for(const h of w)p.push(Pr(h,{checkMode:o,cwd:s,normalized:i}));let m=0,k=0,$=0;for(const h of p)h.status==="error"?$++:h.status==="rewritten"||h.status==="would-rewrite"?m++:k++;const E=m>0||$>0;if(process.stdout.isTTY&&!ve&&E){const h=new Ie(p);await ye(ke.createElement(ze,{checkMode:o,store:h}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const h of p)switch(h.status){case"error":{Er(h);break}case"rewritten":{v.success(`Sorted ${h.filePath}`);break}case"would-rewrite":{v.warn(`${h.filePath} is not sorted`);break}}if(o)m>0?(v.info(`${String(m)} file${m===1?"":"s"} not sorted, ${String(k)} already sorted`),process.exitCode=1):$===0&&v.info(`All ${String(k)} package.json file${k===1?" is":"s are"} sorted`);else{const h=[];m>0&&h.push(`sorted ${String(m)} file${m===1?"":"s"}`),k>0&&h.push(`${String(k)} already sorted`),$>0&&h.push(`${String($)} error${$===1?"":"s"}`),h.length>0&&v.info(h.join(", "))}$>0&&(process.exitCode=1)},"execute");export{Z as buildSnippet,vr as computeKeyDiff,Sr as computeLineColumn,Br as default,$r as discoverPackageJsonFiles,ee as extractParseErrorContext,Pr as processFile};
|