@visulima/vis 2.0.1 → 3.0.0
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 +48 -0
- package/LICENSE.md +850 -128
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +3 -3
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +67 -67
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +150 -148
- package/dist/packem_chunks/dispatch.js +1 -1
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +3 -3
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +3 -3
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +3 -3
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -2
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler4.js +4 -4
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +5 -5
- package/dist/packem_chunks/handler51.js +2 -2
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +4 -4
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +7 -7
- package/dist/packem_chunks/handler60.js +2 -2
- package/dist/packem_chunks/handler61.js +13 -13
- package/dist/packem_chunks/handler62.js +3 -3
- package/dist/packem_chunks/handler63.js +2 -2
- package/dist/packem_chunks/handler64.js +4 -4
- package/dist/packem_chunks/handler66.js +1 -1
- package/dist/packem_chunks/handler67.js +13 -13
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +15 -15
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +5 -5
- package/dist/packem_chunks/handler71.js +1 -1
- package/dist/packem_chunks/handler72.js +23 -23
- package/dist/packem_chunks/handler73.js +5 -5
- package/dist/packem_chunks/handler74.js +24 -24
- package/dist/packem_chunks/handler75.js +2 -2
- package/dist/packem_chunks/handler76.js +5 -5
- package/dist/packem_chunks/handler77.js +18 -18
- package/dist/packem_chunks/handler78.js +25 -25
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +4 -4
- package/dist/packem_chunks/help-command.js +46 -46
- package/dist/packem_chunks/index2.js +6 -4
- package/dist/packem_chunks/index3.js +3 -3
- package/dist/packem_chunks/index4.js +49 -49
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +2 -2
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/orchestrator.js +2 -2
- package/dist/packem_chunks/prompts.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/registry.js +10 -10
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/ts-loader.js +6 -6
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/{advisories-BGeuHJQg.js → advisories-DsXRmIA5.js} +1 -1
- package/dist/packem_shared/{affected-selection-B85ND6JV.js → affected-selection-BE6VFCDV.js} +1 -1
- package/dist/packem_shared/{affected-shas-BWRRAB47.js → affected-shas-BKEu4RZc.js} +1 -1
- package/dist/packem_shared/ai-analysis-DikAj6rX.js +68 -0
- package/dist/packem_shared/{ai-fix-BgBU0TOz.js → ai-fix-bfWo0cZX.js} +4 -4
- package/dist/packem_shared/{augment-HVeX6LpU.js → augment-BkJxi_GW.js} +1 -1
- package/dist/packem_shared/{bin-DKod8Iqo.js → bin-B-TytgzW.js} +1 -1
- package/dist/packem_shared/{build-scripts-CM8M1xcG.js → build-scripts-DWypBQ--.js} +1 -1
- package/dist/packem_shared/{command-runtime-BVi4lL8k.js → command-runtime-DQ7ZpLYL.js} +1 -1
- package/dist/packem_shared/{cyclonedx-y7VLI-1d.js → cyclonedx-DLBi65MV.js} +3 -3
- package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +1 -0
- package/dist/packem_shared/{docker-D1LStSlH.js → docker-B4zAZCZG.js} +28 -28
- package/dist/packem_shared/{en-BxrK-n-J.js → en-BDYMmM2_.js} +13 -13
- package/dist/packem_shared/{failure-log-ChuFC-8f.js → failure-log-DyhWPqno.js} +2 -2
- package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +1 -0
- package/dist/packem_shared/index-BLtnel38.js +35 -0
- package/dist/packem_shared/index-CuKDxOCI.js +1 -0
- package/dist/packem_shared/index-tNFGWxc0.js +39 -0
- package/dist/packem_shared/index.server-CusjRLCh.js +2 -0
- package/dist/packem_shared/{lifecycle-Db0qh6vR.js → lifecycle-KY9umOg6.js} +1 -1
- package/dist/packem_shared/{lockfile-CDQ0n4P5.js → lockfile-YAuZf1gh.js} +1 -1
- package/dist/packem_shared/{manifests-Da_no4ZH.js → manifests-BwTn_1ad.js} +1 -1
- package/dist/packem_shared/{min-release-age-V6L6dpiP.js → min-release-age-6avfn81h.js} +1 -1
- package/dist/packem_shared/missing-package-json-Cl0vdz6K.js +1 -0
- package/dist/packem_shared/{native-config-sync-C0pUePad.js → native-config-sync-CHMCJx7H.js} +7 -7
- package/dist/packem_shared/{osv-bloom-DNFpvSSO.js → osv-bloom-DdqDnLCt.js} +2 -2
- package/dist/packem_shared/package-version-BNRJ3o9C.js +4 -0
- package/dist/packem_shared/packument-B9-WqReu.js +1 -0
- package/dist/packem_shared/pm-runner-DRybtzOV.js +1 -0
- package/dist/packem_shared/{project-name-filter-u2Q7YpQH.js → project-name-filter-Dw0fC6IO.js} +1 -1
- package/dist/packem_shared/{provenance-9OT8sTqn.js → provenance-CLxuqCfL.js} +1 -1
- package/dist/packem_shared/{readJsonSync-BnWiH5-R-BpnwAB0Z.js → readJsonSync-DweZd5ZA-CtrDlqpb.js} +1 -1
- package/dist/packem_shared/{registry-keys-CYHd7qU2.js → registry-keys-cTN24144.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-DC3XssJa.js → resolve-explicit-Uw6WQl9R.js} +1 -1
- package/dist/packem_shared/{resolve-runtime-f5l4ODsH.js → resolve-runtime-DztanwkZ.js} +1 -1
- package/dist/packem_shared/{run-file-zB4ACnUy.js → run-file-CaE5_xBY.js} +1 -1
- package/dist/packem_shared/{runtime-check-CWvAfu5u.js → runtime-check-C32yE57I.js} +1 -1
- package/dist/packem_shared/{s1ngularity-DsmC71xt.js → s1ngularity-BIYhg82u.js} +1 -1
- package/dist/packem_shared/scan-progress-DWfY4zkp.js +2 -0
- package/dist/packem_shared/{selectors-CtxnIT4X.js → selectors-D2j4M9Ul.js} +1 -1
- package/dist/packem_shared/{signatures-Dwx5fD4g.js → signatures-C8iQ5fUq.js} +1 -1
- package/dist/packem_shared/target-merge-DLxJTcxn.js +11 -0
- package/dist/packem_shared/{target-options-BO4Uxt0k.js → target-options-3t4-2F-F.js} +1 -1
- package/dist/packem_shared/{toolchain-BY8lJaSN.js → toolchain-BPzbahcQ.js} +1 -1
- package/dist/packem_shared/{typosquats-BUGgotNu.js → typosquats-BWrmhh36.js} +1 -1
- package/dist/packem_shared/{use-measured-height-BLZt9dW2.js → use-measured-height-BwAwGHjw.js} +1 -1
- package/dist/packem_shared/verify-CzUPT6Uk.js +1 -0
- package/dist/packem_shared/vis-update-app-D6Wq8ZHM.js +1 -0
- package/dist/packem_shared/vis-user-error-CfM4_ORo.js +30 -0
- package/dist/packem_shared/{watch-CGrUW_JD.js → watch-D_oAxW_Z.js} +1 -1
- package/dist/packem_shared/{watch-loop-DIwSMjlA.js → watch-loop-BrjblOz5.js} +4 -4
- package/dist/runtime/preload.js +1 -1
- package/index.d.ts +204 -204
- package/index.js +52 -52
- package/package.json +16 -16
- package/dist/packem_shared/ai-analysis-oNMAj1wd.js +0 -68
- package/dist/packem_shared/dependency-scan-BAzKpXdW.js +0 -1
- package/dist/packem_shared/glob-BUjyjdE8-BSrdzgma.js +0 -1
- package/dist/packem_shared/index-BJw7gKD1.js +0 -1
- package/dist/packem_shared/index-DND6ptxQ.js +0 -35
- package/dist/packem_shared/index.server-qvZ-cy29.js +0 -2
- package/dist/packem_shared/missing-package-json-Jw8IEHct.js +0 -1
- package/dist/packem_shared/package-version-DjHDww_5.js +0 -4
- package/dist/packem_shared/packument-N3EWbZpL.js +0 -1
- package/dist/packem_shared/pm-runner-Bssje5qH.js +0 -1
- package/dist/packem_shared/public-api-WqUCiyIe.js +0 -131
- package/dist/packem_shared/scan-progress-Ch8s3Uwl.js +0 -2
- package/dist/packem_shared/target-merge-b7bE1AEx.js +0 -11
- package/dist/packem_shared/verify-B0ztxKMa.js +0 -1
- package/dist/packem_shared/vis-update-app-D1gLJB1O.js +0 -1
- package/dist/packem_shared/vis-user-error-DjFv8uxy.js +0 -28
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{y as L,z as q,m as P,l as M,J as W,B as K}from"../packem_shared/index-DND6ptxQ.js";import{j as t,l as a,e as c,r as v,d as Y,a as Q,P as U,p as Z,m as _,k as ee,x as re,c as N}from"./catalog.js";import"../packem_shared/en-BxrK-n-J.js";import{I as te}from"../packem_shared/index-BWl4DbMp.js";import se from"./index.js";import{sortPackageJsonStringWithOptions as H}from"#native";import{J as oe,I as ne,K as ie,p as S}from"./cli-main.js";import{ScrollView as le}from"@visulima/tui-kit/scroll-view";import{ScrollBar as ce}from"@visulima/tui-kit/scroll-bar";import{o as O}from"../packem_shared/utils-CRueU43T.js";const A={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>A[r.status]-A[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.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()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:l})=>{const i=s?"white":"gray";return r?t.jsxs(a,{borderColor:i,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(a,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(c,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(le,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(c,{}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(c,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Path:"})}),t.jsx(c,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Step:"})}),t.jsx(c,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Position:"})}),t.jsx(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(a,{marginTop:1,children:t.jsx(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(o=>{const n=`${o.isErrorLine?"❯":" "} ${String(o.lineNumber).padStart(4)} `;return t.jsxs(a,{children:[t.jsx(c,{color:o.isErrorLine?"red":"gray",children:n}),t.jsx(c,{color:o.isErrorLine?"white":"gray",wrap:"truncate-end",children:o.content||" "})]},o.lineNumber)}),r.error.context.column>0&&t.jsx(a,{children:t.jsx(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(o=>{const n=o.toIndex-o.fromIndex,d=n<0?`↑ ${String(Math.abs(n))}`:`↓ ${String(n)}`,g=n<0?"green":"yellow";return t.jsxs(a,{children:[t.jsx(a,{width:28,children:t.jsx(c,{wrap:"truncate",children:o.key})}),t.jsx(a,{width:10,children:t.jsxs(c,{dimColor:!0,children:[String(o.fromIndex)," → ",String(o.toIndex)]})}),t.jsx(c,{color:g,children:d})]},o.key)})}),e&&r.status==="would-rewrite"&&t.jsx(a,{marginTop:1,paddingLeft:2,children:t.jsx(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(c,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},X={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],V=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[X[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],l=ge[e.status];return t.jsxs(a,{flexShrink:0,height:1,children:[t.jsx(c,{children:r?">":" "}),t.jsx(c,{children:" "}),t.jsx(c,{bold:!0,color:s,children:`[${l}]`.padEnd(10)}),t.jsx(c,{children:" "}),t.jsx(a,{flexGrow:1,children:t.jsx(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},we=({color:e,count:r,label:s})=>t.jsx(a,{flexShrink:0,height:1,children:t.jsx(c,{bold:!0,color:e,children:`${s} (${String(r)})`})}),je=({counts:e,entries:r,filterType:s,focused:l,selectedIndex:i,totalEntries:o,viewportHeight:n})=>{const d=l?"white":"gray",g=V(r),m=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),y=s==="all"&&m>1,h=[];let w;for(const[u,p]of r.entries()){const b=X[p.status];y&&b!==w&&(w!==void 0&&h.push({kind:"spacer"}),h.push({color:b==="errors"?"red":b==="rewrites"?"yellow":"green",count:g[b],kind:"header",label:xe[b]}),w=b),h.push({entry:p,entryIndex:u,kind:"entry"})}const x=h.findIndex(u=>u.kind==="entry"&&u.entryIndex===i),k=x!==-1,j=h.length,$=Math.max(0,j-n);let f=0;k&&n>0&&(f=Math.min($,Math.max(0,x-n+1)));const E=j>n&&n>0;return t.jsxs(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(a,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(c,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(c,{wrap:"truncate",children:[o," ","file",o===1?"":"s"]})]}),t.jsx(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(u=>{const p=s===u.key,b=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!p,children:"["}),t.jsx(c,{bold:p,color:p?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!p,children:"]"}),t.jsxs(c,{color:p?"white":"gray",children:[" ",u.label]}),t.jsxs(c,{dimColor:!0,children:[" ","(",b,")"]})]},u.key)})}),t.jsxs(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(a,{flexDirection:"column",marginTop:-f,children:h.map((u,p)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(p)}`):u.kind==="header"?t.jsx(we,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(me,{entry:u.entry,isSelected:u.entryIndex===i},u.entry.filePath))})}),E&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ce,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:n})})]})]})},ye=100,D=10,be=6,Se=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},ke=({checkMode:e,store:r})=>{const{exit:s}=oe(),{columns:l,rows:i}=ne(),o=v.useSyncExternalStore(r.subscribe,r.getSnapshot),n=v.useRef(null),d=r.getFilteredEntries(),g=d[o.selectedIndex]??null,m=V(o.entries),y=l>=ye,h=Math.max(0,i-Se),w=y?h:Math.floor(h/2),x=Math.max(0,w-be),k=v.useCallback(()=>{s()},[s]),j=v.useRef(0),$=v.useRef(void 0),f=v.useRef(!1),E=v.useCallback((u,p)=>{j.current+=p,$.current=u,!f.current&&(f.current=!0,queueMicrotask(()=>{f.current=!1;const b=j.current,T=$.current;j.current=0,$.current=void 0,!(b===0||T===void 0)&&(T==="list"?r.selectStep(Math.sign(b)):n.current?.scrollBy(Math.sign(b)))}))},[r]);return ie((u,p)=>{if(u==="q"||p.escape){k();return}if(F[u]){r.setFilter(F[u]);return}if(p.tab){r.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}o.focusedPanel==="list"?p.upArrow||u==="k"?E("list",-1):(p.downArrow||u==="j")&&E("list",1):o.focusedPanel==="detail"&&(p.upArrow||u==="k"?E("detail",-1):(p.downArrow||u==="j")&&E("detail",1))}),i<D?t.jsx(a,{alignItems:"center",justifyContent:"center",children:t.jsxs(c,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(a,{flexDirection:"column",height:i,width:l,children:[t.jsxs(a,{flexDirection:y?"row":"column",flexGrow:1,children:[t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(je,{counts:m,entries:d,filterType:o.filterType,focused:o.focusedPanel==="list",selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:x})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:g,focused:o.focusedPanel==="detail",scrollRef:n})})]}),t.jsx(a,{flexShrink:0,paddingX:1,children:t.jsx(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},B=["types","node-addons","node","import","require","default"],$e=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,ve=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>R(s));const r={};for(const[s,l]of Object.entries(e))r[s]=R(l);return r},Ee=e=>{if(!C(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}},Pe=e=>e.endsWith(".git")?e.slice(0,-4):e,Oe=e=>{if(!C(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:s}=e;if(typeof s!="string")return{changed:!1,value:e};const l=$e.exec(s)??ve.exec(s);if(!l)return{changed:!1,value:e};const i=l[1],o=Pe(l[2]??"");if(!i||!o)return{changed:!1,value:e};const n=new Set(["type","url"]);for(const d of Object.keys(e))if(!n.has(d))return{changed:!1,value:e};return{changed:!0,value:`${i}/${o}`}},Ce=e=>{const r=Object.keys(e),s=[],l=[];for(const n of B)Object.hasOwn(e,n)&&s.push(n);for(const n of r)B.includes(n)||l.push(n);const i=[...s,...l];if(i.length===r.length&&i.every((n,d)=>n===r[d]))return{changed:!1,value:e};const o={};for(const n of i)o[n]=e[n];return{changed:!0,value:o}},z=e=>{if(!C(e))return{changed:!1,value:e};let r=!1;const s={};for(const[i,o]of Object.entries(e)){const n=z(o);s[i]=n.value,n.changed&&(r=!0)}const l=Ce(s);return{changed:r||l.changed,value:l.value}},Ie=(e,r)=>{const s=R(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const i=Ee(s.bugs);i.changed&&(s.bugs=i.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const i=Oe(s.repository);i.changed&&(s.repository=i.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&C(s.exports)){const i=z(s.exports);i.changed&&(s.exports=i.value,l=!0)}return{changed:l,pkg:s}},Re=/at position (\d+)/,Te=/\(?line (\d+) column (\d+)\)?/,Me=e=>{const r=new Set,s=[],l=o=>{const n=K(o);!r.has(n)&&M(n)&&(r.add(n),s.push(n))};l(P(e,"package.json"));const i=re(e);if(i){const o=N(e,i);for(const n of o)l(P(e,n,"package.json"))}else{const o=P(e,"package.json");if(M(o)){const n=JSON.parse(q(o)),d=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;if(d){const g=N(e,d);for(const m of g)l(P(e,m,"package.json"))}}}return s},Ne=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",Ae=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},I=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),De=e=>e.includes(`\r
|
|
2
|
-
`)?"crlf":"lf",Fe=new Set(["auto","crlf","lf"]),
|
|
3
|
-
`);if(r<1||r>l.length)return[];const i=Math.max(0,r-1-s),o=Math.min(l.length,r+s),n=[];for(let d=i;d<o;d++)n.push({content:l[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return n},
|
|
1
|
+
import{b as J,z as X,w as E,l as M,K as V,P as W}from"../packem_shared/index-BLtnel38.js";import{l as t,m as a,i as c,r as v,X as Y,R as Q,P as U,p as Z,o as _,s as ee,x as re,e as N}from"./catalog.js";import"../packem_shared/en-BDYMmM2_.js";import{I as te}from"../packem_shared/index-BWl4DbMp.js";import se from"./index.js";import{sortPackageJsonStringWithOptions as q}from"#native";import{J as oe,I as ne,K as ie,p as S}from"./cli-main.js";import{ScrollView as le}from"@visulima/tui-kit/scroll-view";import{ScrollBar as ce}from"@visulima/tui-kit/scroll-bar";import{o as O}from"../packem_shared/utils-CRueU43T.js";const A={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>A[r.status]-A[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.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()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:l})=>{const i=s?"white":"gray";return r?t.jsxs(a,{borderColor:i,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(a,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(c,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(le,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(c,{}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(c,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Path:"})}),t.jsx(c,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Step:"})}),t.jsx(c,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Position:"})}),t.jsx(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(a,{marginTop:1,children:t.jsx(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(o=>{const n=`${o.isErrorLine?"❯":" "} ${String(o.lineNumber).padStart(4)} `;return t.jsxs(a,{children:[t.jsx(c,{color:o.isErrorLine?"red":"gray",children:n}),t.jsx(c,{color:o.isErrorLine?"white":"gray",wrap:"truncate-end",children:o.content||" "})]},o.lineNumber)}),r.error.context.column>0&&t.jsx(a,{children:t.jsx(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(o=>{const n=o.toIndex-o.fromIndex,d=n<0?`↑ ${String(Math.abs(n))}`:`↓ ${String(n)}`,g=n<0?"green":"yellow";return t.jsxs(a,{children:[t.jsx(a,{width:28,children:t.jsx(c,{wrap:"truncate",children:o.key})}),t.jsx(a,{width:10,children:t.jsxs(c,{dimColor:!0,children:[String(o.fromIndex)," → ",String(o.toIndex)]})}),t.jsx(c,{color:g,children:d})]},o.key)})}),e&&r.status==="would-rewrite"&&t.jsx(a,{marginTop:1,paddingLeft:2,children:t.jsx(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(c,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},H={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],z=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[H[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],l=ge[e.status];return t.jsxs(a,{flexShrink:0,height:1,children:[t.jsx(c,{children:r?">":" "}),t.jsx(c,{children:" "}),t.jsx(c,{bold:!0,color:s,children:`[${l}]`.padEnd(10)}),t.jsx(c,{children:" "}),t.jsx(a,{flexGrow:1,children:t.jsx(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},we=({color:e,count:r,label:s})=>t.jsx(a,{flexShrink:0,height:1,children:t.jsx(c,{bold:!0,color:e,children:`${s} (${String(r)})`})}),je=({counts:e,entries:r,filterType:s,focused:l,selectedIndex:i,totalEntries:o,viewportHeight:n})=>{const d=l?"white":"gray",g=z(r),m=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),y=s==="all"&&m>1,h=[];let w;for(const[u,p]of r.entries()){const b=H[p.status];y&&b!==w&&(w!==void 0&&h.push({kind:"spacer"}),h.push({color:b==="errors"?"red":b==="rewrites"?"yellow":"green",count:g[b],kind:"header",label:xe[b]}),w=b),h.push({entry:p,entryIndex:u,kind:"entry"})}const x=h.findIndex(u=>u.kind==="entry"&&u.entryIndex===i),k=x!==-1,j=h.length,$=Math.max(0,j-n);let f=0;k&&n>0&&(f=Math.min($,Math.max(0,x-n+1)));const P=j>n&&n>0;return t.jsxs(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(a,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(c,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(c,{wrap:"truncate",children:[o," ","file",o===1?"":"s"]})]}),t.jsx(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(u=>{const p=s===u.key,b=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!p,children:"["}),t.jsx(c,{bold:p,color:p?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!p,children:"]"}),t.jsxs(c,{color:p?"white":"gray",children:[" ",u.label]}),t.jsxs(c,{dimColor:!0,children:[" ","(",b,")"]})]},u.key)})}),t.jsxs(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(a,{flexDirection:"column",marginTop:-f,children:h.map((u,p)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(p)}`):u.kind==="header"?t.jsx(we,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(me,{entry:u.entry,isSelected:u.entryIndex===i},u.entry.filePath))})}),P&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ce,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:n})})]})]})},ye=100,D=10,be=6,Se=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},ke=({checkMode:e,store:r})=>{const{exit:s}=oe(),{columns:l,rows:i}=ne(),o=v.useSyncExternalStore(r.subscribe,r.getSnapshot),n=v.useRef(null),d=r.getFilteredEntries(),g=d[o.selectedIndex]??null,m=z(o.entries),y=l>=ye,h=Math.max(0,i-Se),w=y?h:Math.floor(h/2),x=Math.max(0,w-be),k=v.useCallback(()=>{s()},[s]),j=v.useRef(0),$=v.useRef(void 0),f=v.useRef(!1),P=v.useCallback((u,p)=>{j.current+=p,$.current=u,!f.current&&(f.current=!0,queueMicrotask(()=>{f.current=!1;const b=j.current,T=$.current;j.current=0,$.current=void 0,!(b===0||T===void 0)&&(T==="list"?r.selectStep(Math.sign(b)):n.current?.scrollBy(Math.sign(b)))}))},[r]);return ie((u,p)=>{if(u==="q"||p.escape){k();return}if(F[u]){r.setFilter(F[u]);return}if(p.tab){r.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}o.focusedPanel==="list"?p.upArrow||u==="k"?P("list",-1):(p.downArrow||u==="j")&&P("list",1):o.focusedPanel==="detail"&&(p.upArrow||u==="k"?P("detail",-1):(p.downArrow||u==="j")&&P("detail",1))}),i<D?t.jsx(a,{alignItems:"center",justifyContent:"center",children:t.jsxs(c,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(a,{flexDirection:"column",height:i,width:l,children:[t.jsxs(a,{flexDirection:y?"row":"column",flexGrow:1,children:[t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(je,{counts:m,entries:d,filterType:o.filterType,focused:o.focusedPanel==="list",selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:x})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:g,focused:o.focusedPanel==="detail",scrollRef:n})})]}),t.jsx(a,{flexShrink:0,paddingX:1,children:t.jsx(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},G=["types","node-addons","node","import","require","default"],$e=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,ve=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>R(s));const r={};for(const[s,l]of Object.entries(e))r[s]=R(l);return r},Pe=e=>{if(!C(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}},Ee=e=>e.endsWith(".git")?e.slice(0,-4):e,Oe=e=>{if(!C(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:s}=e;if(typeof s!="string")return{changed:!1,value:e};const l=$e.exec(s)??ve.exec(s);if(!l)return{changed:!1,value:e};const i=l[1],o=Ee(l[2]??"");if(!i||!o)return{changed:!1,value:e};const n=new Set(["type","url"]);for(const d of Object.keys(e))if(!n.has(d))return{changed:!1,value:e};return{changed:!0,value:`${i}/${o}`}},Ce=e=>{const r=Object.keys(e),s=[],l=[];for(const n of G)Object.hasOwn(e,n)&&s.push(n);for(const n of r)G.includes(n)||l.push(n);const i=[...s,...l];if(i.length===r.length&&i.every((n,d)=>n===r[d]))return{changed:!1,value:e};const o={};for(const n of i)o[n]=e[n];return{changed:!0,value:o}},K=e=>{if(!C(e))return{changed:!1,value:e};let r=!1;const s={};for(const[i,o]of Object.entries(e)){const n=K(o);s[i]=n.value,n.changed&&(r=!0)}const l=Ce(s);return{changed:r||l.changed,value:l.value}},Ie=(e,r)=>{const s=R(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const i=Pe(s.bugs);i.changed&&(s.bugs=i.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const i=Oe(s.repository);i.changed&&(s.repository=i.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&C(s.exports)){const i=K(s.exports);i.changed&&(s.exports=i.value,l=!0)}return{changed:l,pkg:s}},Re=/at position (\d+)/,Te=/\(?line (\d+) column (\d+)\)?/,Me=e=>{const r=new Set,s=[],l=o=>{const n=W(o);!r.has(n)&&M(n)&&(r.add(n),s.push(n))};l(E(e,"package.json"));const i=re(e);if(i){const o=N(e,i);for(const n of o)l(E(e,n,"package.json"))}else{const o=E(e,"package.json");if(M(o)){const n=JSON.parse(X(o)),d=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;if(d){const g=N(e,d);for(const m of g)l(E(e,m,"package.json"))}}}return s},Ne=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",Ae=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},I=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),De=e=>e.includes(`\r
|
|
2
|
+
`)?"crlf":"lf",Fe=new Set(["auto","crlf","lf"]),Ge=e=>{if(e===void 0||e==="")return"auto";if(Fe.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Le=(e,r,s)=>r.length===0?e:e.filter(l=>{const i=J(s,l),o=V(l);return!r.some(n=>{const d=n.includes("/")?i:o;return se(n,d)})}),Be=(e,r)=>{if(r.length===0)return e;const s={},l=new Set;for(const i of r)Object.hasOwn(e,i)&&(s[i]=e[i],l.add(i));for(const i of Object.keys(e))l.has(i)||(s[i]=e[i]);return s},Je=(e,r,s)=>{if(s.length===0)return e;const l={...e};for(const i of s)Object.hasOwn(r,i)&&(l[i]=r[i]);return l},Xe=(e,r)=>{let s=1,l=1;const i=Math.min(r,e.length);for(let o=0;o<i;o++)e.codePointAt(o)===10?(s++,l=1):l++;return{column:l,line:s}},L=(e,r,s=2)=>{const l=e.split(`
|
|
3
|
+
`);if(r<1||r>l.length)return[];const i=Math.max(0,r-1-s),o=Math.min(l.length,r+s),n=[];for(let d=i;d<o;d++)n.push({content:l[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return n},B=(e,r)=>{if(!(e instanceof Error))return;const s=Re.exec(e.message);if(s){const{column:i,line:o}=Xe(r,Number.parseInt(s[1]??"0",10));return{column:i,line:o,snippet:L(r,o)}}const l=Te.exec(e.message);if(l){const i=Number.parseInt(l[1]??"1",10);return{column:Number.parseInt(l[2]??"1",10),line:i,snippet:L(r,i)}}},qe=(e,r)=>{const s=Object.keys(JSON.parse(e)),l=Object.keys(JSON.parse(r)),i=new Map(s.map((n,d)=>[n,d])),o=[];for(const[n,d]of l.entries()){const g=i.get(d);g!==void 0&&g!==n&&o.push({fromIndex:g,key:d,toIndex:n})}return o},He=(e,r,s)=>{const l=r.indent??s.indent??Ne(e),i=r.lineEnding==="auto"?s.lineEnding??De(e):r.lineEnding,o=q(e,{pretty:!1,sortScripts:r.sortScripts});let n=JSON.parse(o);if(r.unsorted.length>0){const y=JSON.parse(e);n=Je(n,y,r.unsorted)}n=Be(n,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},g=Ie(n,d);let m=JSON.stringify(g.pkg,null,l);return r.finalNewline&&(m+=`
|
|
4
4
|
`),i==="crlf"&&(m=m.replaceAll(`
|
|
5
5
|
`,`\r
|
|
6
|
-
`)),m},
|
|
6
|
+
`)),m},ze=(e,r)=>{const s=Me(e),l=U(e),i=Z({cwd:e,extraPatterns:_(l)}),o=s.filter(d=>!i.ignores(d)),n=Le(o,r,e);return{afterGitignore:o,allFiles:s,files:n}},Ke=async(e,{checkMode:r,cwd:s,fs:l,normalized:i})=>{const o=J(s,e)||e;let n;try{n=X(e)}catch(h){return{diff:[],error:{message:O(h),step:"read"},filePath:e,relativePath:o,status:"error"}}let d;try{d=q(n,{pretty:!1,sortScripts:i.sortScripts})}catch(h){const w={message:O(h),step:"native-sort"},x=B(h,n);return x&&(w.context=x),{diff:[],error:w,filePath:e,relativePath:o,status:"error"}}const g=i.editorconfig?ee(e):{};let m;try{m=He(n,i,g)}catch(h){const w={message:O(h),step:"json-parse"},x=B(h,n);return x&&(w.context=x),{diff:[],error:w,filePath:e,relativePath:o,status:"error"}}if(n===m)return{diff:[],filePath:e,relativePath:o,status:"unchanged"};let y;try{y=qe(n,d)}catch{y=[]}if(r)return{diff:y,filePath:e,relativePath:o,status:"would-rewrite"};try{await l.writeFile(e,m,"utf8")}catch(h){return{diff:y,error:{message:O(h),step:"write"},filePath:e,relativePath:o,status:"error"}}return{diff:y,filePath:e,relativePath:o,status:"rewritten"}},Ve=e=>{if(e.error&&(S.error(`${e.filePath}: ${e.error.message}`),S.info(` step: ${e.error.step}`),e.error.context)){S.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const s=r.isErrorLine?">":" ";S.info(` ${s} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},or=async({fs:e,options:r,visConfig:s,workspaceRoot:l})=>{const i=l??process.cwd(),o=s?.sortPackageJson,n=r.check||!1,d={editorconfig:r.editorconfig===!1?!1:o?.editorconfig??!0,finalNewline:r.finalNewline??o?.finalNewline??!0,formatBugs:r.formatBugs===!1?!1:o?.formatBugs??!0,formatRepository:r.formatRepository===!1?!1:o?.formatRepository??!0,ignore:[...I(r.ignore),...o?.ignore??[]],indent:Ae(r.indent??o?.indent),lineEnding:Ge(r.lineEnding??o?.lineEnding),sortExports:r.sortExports===!1?!1:o?.sortExports??!0,sortOrder:[...I(r.sortOrder),...o?.sortOrder??[]],sortScripts:r.sortScripts||o?.sortScripts||!1,unsorted:[...I(r.unsorted),...o?.unsorted??[]]},g=ze(i,d.ignore),{afterGitignore:m,allFiles:y,files:h}=g;if(h.length===0){y.length===0?S.info("No package.json files found."):m.length===0?S.info("All package.json files were excluded by .gitignore or workspace exclusions."):S.info("All package.json files were excluded by --ignore.");return}const w=[];for(const f of h)w.push(await Ke(f,{checkMode:n,cwd:i,fs:e,normalized:d}));let x=0,k=0,j=0;for(const f of w)f.status==="error"?j++:f.status==="rewritten"||f.status==="would-rewrite"?x++:k++;const $=x>0||j>0;if(process.stdout.isTTY&&!te&&$){const f=new ue(w);await Y(Q.createElement(ke,{checkMode:n,store:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const f of w)switch(f.status){case"error":{Ve(f);break}case"rewritten":{S.success(`Sorted ${f.filePath}`);break}case"would-rewrite":{S.warn(`${f.filePath} is not sorted`);break}}if(n)x>0?(S.info(`${String(x)} file${x===1?"":"s"} not sorted, ${String(k)} already sorted`),process.exitCode=1):j===0&&S.info(`All ${String(k)} package.json file${k===1?" is":"s are"} sorted`);else{const f=[];x>0&&f.push(`sorted ${String(x)} file${x===1?"":"s"}`),k>0&&f.push(`${String(k)} already sorted`),j>0&&f.push(`${String(j)} error${j===1?"":"s"}`),f.length>0&&S.info(f.join(", "))}j>0&&(process.exitCode=1)};export{L as buildSnippet,qe as computeKeyDiff,Xe as computeLineColumn,or as default,ze as discoverPackageJsonFiles,B as extractParseErrorContext,Ke as processFile};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as
|
|
1
|
+
import{createRequire as H}from"node:module";import{I as W}from"../packem_shared/index-BWl4DbMp.js";import{p as F}from"../packem_shared/prompt-BSAy8SMH.js";import{l as X,w as J,d as U,j as Q}from"../packem_shared/index-BLtnel38.js";import{f as D,A as Z,C as ee,r as te,z as se,i as A}from"../packem_shared/en-BDYMmM2_.js";import{a as re}from"../packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js";import{g as oe,r as ne}from"../packem_shared/packument-B9-WqReu.js";import{q as ie,j as ae,E as $,s as k,V as C,I as _}from"../packem_shared/index.server-CusjRLCh.js";import{h as ce,W as le}from"../packem_shared/pm-runner-DRybtzOV.js";import{r as fe,a as pe}from"../packem_shared/command-runtime-DQ7ZpLYL.js";let L;const q=e=>(L??=H(import.meta.url))(e),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,s]=v.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return v.getBuiltinModule(e)}return q(e)},{renameSync:Y}=G("node:fs"),{stripVTControlCharacters:z}=G("node:util"),ue=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},w=J(D(),"dlx-seen.json"),P=(e,t)=>`${e}@${t}`,ge=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},V=()=>{try{if(X(w)){const e=re(w);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))ge(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},me=e=>{try{U(D());const t=`${w}.${String(process.pid)}.tmp`;Q(t,JSON.stringify(e)),Y(t,w)}catch{}},de=(e,t,s)=>e.packages[P(t,s)],he=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},x=(e,t,s,r)=>{const o=V();o.packages[P(e,t)]={alertKeys:[...s].sort(),seenAt:r},me(o)},ye=/[\u0000-\u0008\u000B-\u001F\u007F]/g,B=e=>z(e).replaceAll(" "," ").replaceAll(ye,""),E=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],$e=4e3,j=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},$e),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const i=await fetch(e,{headers:s,signal:r.signal});return i.ok?await i.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},ve=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},R=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let i=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){i=c,u=f[1].length;break}}if(i===-1)return;const n=[];for(let c=i+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;n.push(s[c])}return n},I=(e,t=4)=>e.map(s=>s.trim()).filter(s=>s.length>0).map(s=>B(s.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(s=>s.length>0&&!/^\[.*\]:/.test(s)).slice(0,t),O=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=O(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],i=Date.parse(r[t]??""),u=Object.entries(r).filter(([n])=>n!=="created"&&n!=="modified"&&n!==t).sort((n,c)=>Date.parse(c[1])-Date.parse(n[1])).filter(([,n])=>Date.parse(n)<i).slice(0,3);for(const[n,c]of u)a.push(`- ${n} (${O(c,s)})`);return{lines:a,source:"npm-diff",version:t}},ke=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:i}=e;if(r)return o?N(o,i,s):void 0;for(const c of E){const l=`https://cdn.jsdelivr.net/npm/${t}@${i}/${c}`,f=await j(l,a);if(f){const d=R(f,i),p=I(d??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:i}}}const u=o?.versions[i],n=ve(u?.repository);if(n){const c=n.directory?`${n.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of E){const d=`https://raw.githubusercontent.com/${n.owner}/${n.repo}/${l}/${c}${f}`,p=await j(d,a);if(p){const h=R(p,i),m=I(h??p.split(/\r?\n/));if(m.length>0){const g=`https://github.com/${n.owner}/${n.repo}/blob/${l}/${c}${f}`;return{lines:m,source:"repo-file",url:g,version:i}}}}}if(o)return N(o,i,s)},be={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},we=["preinstall","install","postinstall"],Se=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Te=(e,t)=>{const s=we.filter(i=>!!e?.scripts?.[i]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(i=>B(i)),a=[...new Set(t.map(i=>be[i.type]).filter(i=>i!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},Ce=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:i,workspaceRoot:u}=e;let n;try{n=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{n=void 0}const c=n?ne(n,i):void 0;if(!c)return;const l=n?.versions[c],f=async()=>{if(!(r||!a))try{const y=await ee([{name:t,version:c}],{apiToken:a});return Ce(y,t,c)}catch{return}},d=ke({name:t,now:s,offline:r,packument:n,signal:o,version:c}).catch(()=>{}),[p,h]=await Promise.all([f(),d]),m=p?.alerts??[],g=[...new Set(m.filter(y=>y.severity==="critical"||y.severity==="high").map(y=>y.key))].sort(),S=p?Math.round((p.score.overall??Z(p.score))*100):void 0;return{changelog:h,name:t,permissions:Te(l,m),security:{alerts:m,available:!!p,highSeverityKeys:g,score:S},size:Se(l,p),version:c}},b=e=>te(z(e)),_e={critical:C,high:C,low:$,medium:k},K=e=>{if(!(e===void 0||e<0))return se(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=K(r),a=K(s);if(o&&a){const i=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${i})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ee=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return $("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?$:r>=70?_:r>=40?k:C,a=r===void 0?"n/a":`${String(r)}/100`,i=new Map;for(const l of t)i.set(l.severity,(i.get(l.severity)??0)+1);const u=[],n=["critical","high","medium","low"];for(const l of n){const f=i.get(l);f&&u.push(_e[l](`${String(f)} ${l}`))}const c=u.length>0?` ${k("!")} ${u.join(", ")}`:` ${_("no alerts")}`;return`${o(a)} ${$("(Socket.dev)")}${c}`},je=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(k(`${a} script`));for(const a of s)o.push(k(a));return t.length>0&&o.push($(`bins: ${t.join(", ")}`)),o.length>0?o.join($(" · ")):void 0},Re=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ee(e)]});const r=je(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,$(`source: ${o}`)]})}return t},M=6,Ie=e=>{const t=Re(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const n of t)n.values.forEach((c,l)=>{const f=l===0?ie(n.label.padEnd(M)):" ".repeat(M);r.push(`${f} ${c}`)});const o=Math.max(b(s),...r.map(n=>b(n))),a=n=>`${n}${" ".repeat(Math.max(0,o-b(n)))}`,i=`┌─${ae(s)}${"─".repeat(Math.max(0,o-b(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[i,...r.map(n=>`│ ${a(n)} │`),u]},Oe=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},Ne=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),Ke=6e3,Me=e=>{process.stdout.write(e)},Ge=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:i,yes:u=!1}=e;if(s||!Ne(o))return{proceed:!0};const n=e.now??Date.now(),c=u||!ue({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:d}=Oe(o),p=new AbortController;let h;const m=new Promise(T=>{h=setTimeout(()=>{p.abort(),T(void 0)},Ke)}),g=await Promise.race([Ae({name:f,now:n,offline:r,signal:p.signal,socketToken:a,spec:d,workspaceRoot:i}).catch(()=>{}),m]);if(h&&clearTimeout(h),!g)return{proceed:!0};const S=de(V(),g.name,g.version);if(!t&&!he(S,g.security.highSeverityKeys))return{proceed:!0};for(const T of Ie(g))l(`${T}
|
|
2
2
|
`);if(c)return x(g.name,g.version,g.security.highSeverityKeys,n),{proceed:!0};const y=await F("? Ok to proceed? (y/N) ",e.readline);return y&&x(g.name,g.version,g.security.highSeverityKeys,n),{proceed:y}},Ye=async({argument:e,logger:t,options:s,visConfig:r,workspaceRoot:o})=>{const a=e;if(!a||a.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[i,...u]=a,n=o??process.cwd(),c=s.package?Array.isArray(s.package)?s.package:[s.package]:[],l=s.shellMode?c:[i,...c];for(const h of l){const m=s.info||!1,g=m?!1:s.noInfo||A(process.env.VIS_DLX_NO_INFO);if(!(await Ge({forceInfo:m,noInfo:g,offline:s.offline||!1,pkg:h,socketToken:r?.security?.socket?.apiToken??process.env.VIS_SOCKET_TOKEN,workspaceRoot:n,yes:s.yes||A(process.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const f=fe({logger:t,options:s,visConfig:r},n),d=ce(n,{backend:pe(f),configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),p=le(d,{additionalPackages:c,args:u,package:i,shellMode:s.shellMode||!1,silent:s.silent||!1},n,t,{offline:s.offline||!1});p!==0&&(process.exitCode=p)};export{Ye as default};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{w as O,z as _,l as B,j as D,a as ce,P as ae}from"../packem_shared/index-BLtnel38.js";import{t as le,l as t,m as h,i as a,r as A,X as de,R as pe,x as fe,e as J}from"./catalog.js";import"../packem_shared/en-BDYMmM2_.js";import{I as he}from"../packem_shared/index-BWl4DbMp.js";import me from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import ue from"module-replacements/manifests/native.json"with{type:"json"};import ge from"module-replacements/manifests/preferred.json"with{type:"json"};import{s as Z}from"../packem_shared/index-BAe6e0XE.js";import{J as xe,I as ye,K as je,M as ke,p as y}from"./cli-main.js";import"../packem_shared/index-tNFGWxc0.js";import{A as we,y as ve}from"../packem_shared/pm-runner-DRybtzOV.js";import{ScrollView as $e}from"@visulima/tui-kit/scroll-view";import{ScrollBar as be}from"@visulima/tui-kit/scroll-bar";import{a as Q}from"../packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js";import{s as Ce}from"../packem_shared/glob-BUjyjdE8-Dp_QcayW.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
2
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
-
const Se=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Oe=["overrides","pnpm","resolutions"],Ne=["engines","files"],Ee=r=>{const e=Z.coerce(r)?.major;return e!==void 0&&e>=10},Pe=r=>{const e=O(r,"pnpm-workspace.yaml");if(!B(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:ce(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Te=(r,e)=>{let
|
|
3
|
+
const Se=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Oe=["overrides","pnpm","resolutions"],Ne=["engines","files"],Ee=r=>{const e=Z.coerce(r)?.major;return e!==void 0&&e>=10},Pe=r=>{const e=O(r,"pnpm-workspace.yaml");if(!B(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:ce(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Te=(r,e)=>{let o={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?o=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?o=r.resolutions??{}:o=r.overrides??{},{overrides:o,source:"package.json"})},Ae=(r,e,o)=>o.name==="pnpm"&&Ee(o.version)?Pe(r):Te(e,o.name),X=(r,e)=>{const o=e;for(const c of Oe){const i=r.indexOf(c);if(i!==-1&&c!==o)return o==="overrides"?i:i+1}let n=-1;for(const c of Se){const i=r.indexOf(c);i>n&&(n=i)}if(n!==-1)return n+1;for(const c of Ne){const i=r.indexOf(c);if(i!==-1)return i}return r.length},De=(r,e)=>{const o=O(r,"pnpm-workspace.yaml");if(!B(o))throw new Error(`pnpm-workspace.yaml not found at ${o}. Cannot write overrides for pnpm v10+.`);let n=_(o);const c=`overrides:
|
|
4
4
|
${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
|
|
5
5
|
`)}
|
|
6
|
-
`;
|
|
6
|
+
`;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,c):`${n.trimEnd()}
|
|
7
7
|
|
|
8
|
-
${c}`,D(n
|
|
9
|
-
`);else{const k=Object.keys(e),s=
|
|
10
|
-
`)}}else{const m=
|
|
11
|
-
`);else{const k=Object.keys(e),s=
|
|
12
|
-
`)}}},Ie=(r,e,n,o,c)=>{if(o.name==="deno")return{added:[],updated:[]};const i=_(e),l=JSON.parse(i),{overrides:m,source:k}=Ae(r,l,o),s=[],d=[],u=new Set;if(o.name==="npm")for(const f of["dependencies","devDependencies"]){const x=l[f];if(x)for(const $ of Object.keys(x))u.add($)}for(const f of n){const x=m[f.original];if(typeof x=="object")continue;let $=f.spec;o.name==="npm"&&u.has(f.original)&&($=`$${f.original}`),x!==$&&(x?d.push(f.original):s.push(f.original),m[f.original]=$)}if(s.length===0&&d.length===0)return{added:s,updated:d};const j=Object.fromEntries(Object.entries(m).sort(([f],[x])=>f.localeCompare(x)));return k==="pnpm-workspace.yaml"?De(r,j):_e(e,l,j,o.name,c),{added:s,updated:d}},Re=(r,e)=>{const n={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const o of n[e]??[]){const c=O(r,o);try{return _(c)}catch{continue}}return""},Fe=(r,e,n)=>{if(!r)return!1;const o=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(n){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);case"deno":return r.includes(`"${e}"`)||r.includes(`"npm:${e}@`)||r.includes(`"jsr:${e}@`);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${o}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);default:return!1}};var z={exports:{}},U,V;function K(){if(V)return U;V=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,c=(s,d)=>{for(var u in d)r(s,u,{get:d[u],enumerable:!0})},i=(s,d,u,j)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of n(d))!o.call(s,f)&&f!==u&&r(s,f,{get:()=>d[f],enumerable:!(j=e(d,f))||j.enumerable});return s},l=s=>i(r({},"__esModule",{value:!0}),s),m={};c(m,{PURL_Type:()=>k}),U=l(m);var k=(s=>(s.APK="apk",s.BITBUCKET="bitbucket",s.COCOAPODS="cocoapods",s.CARGO="cargo",s.CHROME="chrome",s.COMPOSER="composer",s.CONAN="conan",s.CONDA="conda",s.CRAN="cran",s.DEB="deb",s.DOCKER="docker",s.GEM="gem",s.GENERIC="generic",s.GITHUB="github",s.GOLANG="golang",s.HACKAGE="hackage",s.HEX="hex",s.HUGGINGFACE="huggingface",s.MAVEN="maven",s.MLFLOW="mlflow",s.NPM="npm",s.NUGET="nuget",s.OCI="oci",s.PUB="pub",s.PYPI="pypi",s.QPKG="qpkg",s.RPM="rpm",s.SWID="swid",s.SWIFT="swift",s.VCS="vcs",s))(k||{});return U}var X;function Me(){return X||(X=1,(function(r){var e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,i=(d,u)=>{for(var j in u)e(d,j,{get:u[j],enumerable:!0})},l=(d,u,j,f)=>{if(u&&typeof u=="object"||typeof u=="function")for(let x of o(u))!c.call(d,x)&&x!==j&&e(d,x,{get:()=>u[x],enumerable:!(f=n(u,x))||f.enumerable});return d},m=(d,u,j)=>(l(d,u,"default"),j&&l(j,u,"default")),k={};i(k,{getManifestData:()=>s}),m(k,K(),r.exports);function s(d,u){try{const j=require("../manifest.json");if(!d)return j;const f=j[d];if(!f)return;if(!u)return f;const x=f.find(([$,g])=>g.package===u);return x?x[1]:void 0}catch{return}}r.exports={getManifestData:s,...K()}})(z)),z.exports}var Ge=Me();const Le=(r,e,n)=>{let o=r;if(e!=="all"&&(o=o.filter(c=>c.category===e)),n){const c=n.toLowerCase();o=o.filter(i=>i.packageName.toLowerCase().includes(c))}return o};class ze{#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=()=>this.#e;subscribe=e=>(this.#t.add(e),()=>{this.#t.delete(e)});getFilteredEntries=()=>Le(this.#e.entries,this.#e.filterType,this.#e.filterText);#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const n=this.getFilteredEntries();this.#e.selectedIndex=n.length===0?-1:Math.max(0,Math.min(e,n.length-1)),this.#r()}toggleCheck(e){const n=new Set(this.#e.checkedEntries);n.has(e)?n.delete(e):n.add(e),this.#e.checkedEntries=n,this.#r()}toggleAll(){const e=this.getFilteredEntries(),n=new Set(this.#e.checkedEntries);if(e.every(o=>n.has(o.packageName)))for(const o of e)n.delete(o.packageName);else for(const o of e)n.add(o.packageName);this.#e.checkedEntries=n,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,n){this.#e.applyProgress={current:e,total:n},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 ee={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},Ue={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},qe={"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."},Be=({entry:r,focused:e,scrollRef:n})=>{const o=e?"white":"gray";if(!r)return t.jsx(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})});const c=ee[r.category]??"gray";return t.jsxs(h,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(h,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.packageName})}),t.jsxs($e,{flexGrow:1,flexShrink:1,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Category:"})}),t.jsx(a,{bold:!0,color:c,children:r.category})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Replace with:"})}),t.jsx(a,{children:r.replacement})]}),r.overrideSpec&&t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Override:"})}),t.jsx(a,{color:"cyan",children:r.overrideSpec})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Codemod:"})}),t.jsx(a,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"DESCRIPTION"}),t.jsx(h,{marginTop:1,paddingLeft:2,children:t.jsx(a,{children:qe[r.category]??""})})]}),r.category==="native"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"green",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),t.jsx(a,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),t.jsx(a,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"cyan",children:"ACTION"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),t.jsx(a,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"yellow",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),t.jsx(a,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?t.jsx(a,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):t.jsx(a,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"LINKS"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&t.jsx(a,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},Je=[{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"}],He=({checked:r,entry:e,isSelected:n})=>{const o=ee[e.category]??"white",c=Ue[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return t.jsxs(h,{flexShrink:0,height:1,children:[t.jsx(a,{children:n?">":" "}),t.jsxs(a,{color:r?"white":"gray",children:[" ",i," "]}),t.jsx(a,{bold:!0,color:o,children:`[${c}]`.padEnd(9)}),t.jsxs(a,{children:[" ",l," "]}),t.jsx(h,{flexGrow:1,children:t.jsx(a,{bold:n,inverse:n,wrap:"truncate",children:e.packageName})}),t.jsx(a,{dimColor:!0,children:" → "}),t.jsx(a,{wrap:"truncate",children:e.replacement})]})},Ve=({checkedEntries:r,entries:e,filterActive:n,filterText:o,filterType:c,focused:i,isDryRun:l,scrollOffset:m,selectedIndex:k,totalEntries:s,viewportHeight:d})=>{const u=i?"white":"gray";let j=0,f=0,x=0,$=0;for(const C of e)switch(C.category){case"micro-utility":{x++;break}case"native":{j++;break}case"preferred":{f++;break}case"socket":{$++;break}}const g=[];j>0&&g.push(`${j} native`),f>0&&g.push(`${f} preferred`),x>0&&g.push(`${x} micro`),$>0&&g.push(`${$} socket`);const w=g.length>0?` (${g.join(", ")})`:"",b=r.size,P=[];for(const[C,p]of e.entries())P.push(t.jsx(He,{checked:r.has(p.packageName),entry:p,isSelected:C===k},p.packageName));const N=e.length,T=N>d&&d>0;return t.jsxs(h,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(h,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),t.jsxs(a,{wrap:"truncate",children:[s," ","optimizations",w]}),!l&&b>0&&t.jsxs(a,{dimColor:!0,children:[" ","—",b," ","selected"]})]}),t.jsx(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Je.map(C=>{const p=c===C.key;return t.jsxs(h,{children:[t.jsx(a,{dimColor:!p,children:"["}),t.jsx(a,{bold:p,color:p?"cyan":"gray",children:C.shortcut}),t.jsx(a,{dimColor:!p,children:"]"}),t.jsxs(a,{color:p?"white":"gray",children:[" ",C.label]})]},C.key)})}),n&&t.jsxs(h,{flexShrink:0,paddingX:1,children:[t.jsx(a,{bold:!0,color:"white",children:"/ "}),t.jsx(a,{children:o}),t.jsx(a,{inverse:!0,children:" "})]}),t.jsxs(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(h,{flexDirection:"column",marginTop:-m,children:P})}),T&&t.jsx(h,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(be,{contentHeight:N,placement:"inset",scrollOffset:m,style:"block",viewportHeight:d})})]})]})},Ke=100,W=10,Y={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},Xe=({isDryRun:r,store:e})=>{const{exit:n}=xe(),{columns:o,rows:c}=ye(),i=A.useSyncExternalStore(e.subscribe,e.getSnapshot),l=A.useRef(null),[m,k]=A.useState(0),[s,d]=A.useState(!1),u=e.getFilteredEntries(),j=u[i.selectedIndex]??null,f=o>=Ke,x=Math.max(0,c-5),$=A.useCallback(g=>{n(g)},[n]);return je((g,w)=>{if(s){g==="y"||g==="Y"?$():d(!1);return}if(i.filterActive){w.escape?(e.setFilterActive(!1),e.setFilterText("")):w.return?e.setFilterActive(!1):w.backspace||w.delete?e.setFilterText(i.filterText.slice(0,-1)):g&&!w.ctrl&&!w.meta&&e.setFilterText(i.filterText+g);return}if(g==="q"){!r&&i.checkedEntries.size>0?d(!0):$();return}if(g==="/"){e.setFilterActive(!0);return}if(Y[g]){e.setFilter(Y[g]);return}if(w.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(w.upArrow||g==="k"){const b=Math.max(0,i.selectedIndex-1);e.select(b),b<m&&k(b)}else if(w.downArrow||g==="j"){const b=Math.min(u.length-1,i.selectedIndex+1);e.select(b),b>=m+x&&k(b-x+1)}else g===" "?j&&e.toggleCheck(j.packageName):g==="a"?e.toggleAll():w.return&&!r&&i.checkedEntries.size>0&&$(e.getCheckedEntries());else i.focusedPanel==="detail"&&(w.upArrow||g==="k"?l.current?.scrollBy(-1):(w.downArrow||g==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),c<W?t.jsx(h,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",W," ","rows."]})}):t.jsxs(h,{flexDirection:"column",height:c,width:o,children:[t.jsxs(h,{flexDirection:f?"row":"column",flexGrow:1,children:[t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Ve,{checkedEntries:i.checkedEntries,entries:u,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:x})}),t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Be,{entry:j,focused:i.focusedPanel==="detail",scrollRef:l})})]}),t.jsx(h,{flexShrink:0,paddingX:1,children:t.jsxs(a,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),t.jsx(ke,{autoExitSeconds:3,onCancel:()=>{d(!1)},visible:s})]})},q=(r,e)=>{const n=new Set;try{const o=Q(r),c=e?[o.dependencies,o.optionalDependencies]:[o.dependencies,o.devDependencies,o.peerDependencies,o.optionalDependencies];for(const i of c)if(i)for(const l of Object.keys(i))n.add(l)}catch{}return n},re=r=>{const e=fe(r);if(e)return J(r,e);const n=O(r,"package.json");if(!B(n))return[];try{const o=Q(n),c=Array.isArray(o.workspaces)?o.workspaces:o.workspaces?.packages;return c?J(r,c):[]}catch{return[]}},We="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",Ye=r=>`${We}/${r}.md`,Ze=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":""},te=r=>{const e=[],n=(o,c)=>{const i=o.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:c,docUrl:l.type==="documented"&&l.docPath?Ye(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:Ze(l)})};return n(ue,"native"),n(ge,"preferred"),n(me,"micro-utility"),e},ne=(r,e,n,o)=>{const c=Ge.getManifestData("npm")??[],i=[];for(const[,l]of c){if(l.deprecated)continue;const m=r.has(l.package),k=e?Fe(e,l.package,n.name):!1;if(!m&&!k)continue;const s=Z.coerce(l.version)?.major;if(s===void 0)continue;const d=o?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(s)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:d,packageName:l.package,replacement:l.name})}return i};let G;const oe=async()=>{if(G)return G;try{return G=(await import("module-replacements-codemods")).codemods,G}catch{return{}}},se=async r=>{try{const e=await oe();for(const n of r)n.category!=="socket"&&e[n.packageName]&&(n.hasCodemod=!0)}catch{}},ie=async(r,e,n)=>{let o=0;try{const c=(await oe())[n];if(!c)return{filesChanged:0,packageName:n};const i=c({}),l=await Qe(e);for(const m of l){const k=_(m);if(k.includes(n))try{const s=await i.transform({file:{filename:m,source:k}});s!==k&&(await r.writeFile(m,s,"utf8"),o++)}catch(s){process.stderr.write(`warn: codemod transform failed for ${m}: ${s instanceof Error?s.message:String(s)}
|
|
13
|
-
`)}}}catch{}return{filesChanged:
|
|
14
|
-
`);const j=Re(c,i.name),f=te(u),x=
|
|
8
|
+
${c}`,D(o,n)},_e=(r,e,o,n,c)=>{const i=_(r),l=le(r,i,{useEditorconfig:c});if(n==="pnpm"){const m=e.pnpm??{};if(m.overrides=o,e.pnpm)e.pnpm=m,D(r,`${JSON.stringify(e,null,l)}
|
|
9
|
+
`);else{const k=Object.keys(e),s=X(k,"pnpm"),d=Object.entries(e);d.splice(s,0,["pnpm",m]),D(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
|
|
10
|
+
`)}}else{const m=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[m])e[m]=o,D(r,`${JSON.stringify(e,null,l)}
|
|
11
|
+
`);else{const k=Object.keys(e),s=X(k,m),d=Object.entries(e);d.splice(s,0,[m,o]),D(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
|
|
12
|
+
`)}}},Ie=(r,e,o,n,c)=>{if(n.name==="deno")return{added:[],updated:[]};const i=_(e),l=JSON.parse(i),{overrides:m,source:k}=Ae(r,l,n),s=[],d=[],u=new Set;if(n.name==="npm")for(const f of["dependencies","devDependencies"]){const x=l[f];if(x)for(const $ of Object.keys(x))u.add($)}for(const f of o){const x=m[f.original];if(typeof x=="object")continue;let $=f.spec;n.name==="npm"&&u.has(f.original)&&($=`$${f.original}`),x!==$&&(x?d.push(f.original):s.push(f.original),m[f.original]=$)}if(s.length===0&&d.length===0)return{added:s,updated:d};const j=Object.fromEntries(Object.entries(m).sort(([f],[x])=>f.localeCompare(x)));return k==="pnpm-workspace.yaml"?De(r,j):_e(e,l,j,n.name,c),{added:s,updated:d}},Re=(r,e)=>{const o={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of o[e]??[]){const c=O(r,n);try{return _(c)}catch{continue}}return""},Fe=(r,e,o)=>{if(!r)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(o){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}};var z={exports:{}},U,H;function K(){if(H)return U;H=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,c=(s,d)=>{for(var u in d)r(s,u,{get:d[u],enumerable:!0})},i=(s,d,u,j)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of o(d))!n.call(s,f)&&f!==u&&r(s,f,{get:()=>d[f],enumerable:!(j=e(d,f))||j.enumerable});return s},l=s=>i(r({},"__esModule",{value:!0}),s),m={};c(m,{PURL_Type:()=>k}),U=l(m);var k=(s=>(s.APK="apk",s.BITBUCKET="bitbucket",s.COCOAPODS="cocoapods",s.CARGO="cargo",s.CHROME="chrome",s.COMPOSER="composer",s.CONAN="conan",s.CONDA="conda",s.CRAN="cran",s.DEB="deb",s.DOCKER="docker",s.GEM="gem",s.GENERIC="generic",s.GITHUB="github",s.GOLANG="golang",s.HACKAGE="hackage",s.HEX="hex",s.HUGGINGFACE="huggingface",s.MAVEN="maven",s.MLFLOW="mlflow",s.NPM="npm",s.NUGET="nuget",s.OCI="oci",s.PUB="pub",s.PYPI="pypi",s.QPKG="qpkg",s.RPM="rpm",s.SWID="swid",s.SWIFT="swift",s.VCS="vcs",s))(k||{});return U}var V;function Me(){return V||(V=1,(function(r){var e=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,i=(d,u)=>{for(var j in u)e(d,j,{get:u[j],enumerable:!0})},l=(d,u,j,f)=>{if(u&&typeof u=="object"||typeof u=="function")for(let x of n(u))!c.call(d,x)&&x!==j&&e(d,x,{get:()=>u[x],enumerable:!(f=o(u,x))||f.enumerable});return d},m=(d,u,j)=>(l(d,u,"default"),j&&l(j,u,"default")),k={};i(k,{getManifestData:()=>s}),m(k,K(),r.exports);function s(d,u){try{const j=require("../manifest.json");if(!d)return j;const f=j[d];if(!f)return;if(!u)return f;const x=f.find(([$,g])=>g.package===u);return x?x[1]:void 0}catch{return}}r.exports={getManifestData:s,...K()}})(z)),z.exports}var Ge=Me();const Le=(r,e,o)=>{let n=r;if(e!=="all"&&(n=n.filter(c=>c.category===e)),o){const c=o.toLowerCase();n=n.filter(i=>i.packageName.toLowerCase().includes(c))}return n};class ze{#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=()=>this.#e;subscribe=e=>(this.#t.add(e),()=>{this.#t.delete(e)});getFilteredEntries=()=>Le(this.#e.entries,this.#e.filterType,this.#e.filterText);#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const o=this.getFilteredEntries();this.#e.selectedIndex=o.length===0?-1:Math.max(0,Math.min(e,o.length-1)),this.#r()}toggleCheck(e){const o=new Set(this.#e.checkedEntries);o.has(e)?o.delete(e):o.add(e),this.#e.checkedEntries=o,this.#r()}toggleAll(){const e=this.getFilteredEntries(),o=new Set(this.#e.checkedEntries);if(e.every(n=>o.has(n.packageName)))for(const n of e)o.delete(n.packageName);else for(const n of e)o.add(n.packageName);this.#e.checkedEntries=o,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,o){this.#e.applyProgress={current:e,total:o},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 ee={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},Ue={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},qe={"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."},Be=({entry:r,focused:e,scrollRef:o})=>{const n=e?"white":"gray";if(!r)return t.jsx(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})});const c=ee[r.category]??"gray";return t.jsxs(h,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(h,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.packageName})}),t.jsxs($e,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Category:"})}),t.jsx(a,{bold:!0,color:c,children:r.category})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Replace with:"})}),t.jsx(a,{children:r.replacement})]}),r.overrideSpec&&t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Override:"})}),t.jsx(a,{color:"cyan",children:r.overrideSpec})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Codemod:"})}),t.jsx(a,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"DESCRIPTION"}),t.jsx(h,{marginTop:1,paddingLeft:2,children:t.jsx(a,{children:qe[r.category]??""})})]}),r.category==="native"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"green",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),t.jsx(a,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),t.jsx(a,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"cyan",children:"ACTION"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),t.jsx(a,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"yellow",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),t.jsx(a,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?t.jsx(a,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):t.jsx(a,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"LINKS"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&t.jsx(a,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},Je=[{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"}],Xe=({checked:r,entry:e,isSelected:o})=>{const n=ee[e.category]??"white",c=Ue[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return t.jsxs(h,{flexShrink:0,height:1,children:[t.jsx(a,{children:o?">":" "}),t.jsxs(a,{color:r?"white":"gray",children:[" ",i," "]}),t.jsx(a,{bold:!0,color:n,children:`[${c}]`.padEnd(9)}),t.jsxs(a,{children:[" ",l," "]}),t.jsx(h,{flexGrow:1,children:t.jsx(a,{bold:o,inverse:o,wrap:"truncate",children:e.packageName})}),t.jsx(a,{dimColor:!0,children:" → "}),t.jsx(a,{wrap:"truncate",children:e.replacement})]})},He=({checkedEntries:r,entries:e,filterActive:o,filterText:n,filterType:c,focused:i,isDryRun:l,scrollOffset:m,selectedIndex:k,totalEntries:s,viewportHeight:d})=>{const u=i?"white":"gray";let j=0,f=0,x=0,$=0;for(const C of e)switch(C.category){case"micro-utility":{x++;break}case"native":{j++;break}case"preferred":{f++;break}case"socket":{$++;break}}const g=[];j>0&&g.push(`${j} native`),f>0&&g.push(`${f} preferred`),x>0&&g.push(`${x} micro`),$>0&&g.push(`${$} socket`);const w=g.length>0?` (${g.join(", ")})`:"",b=r.size,P=[];for(const[C,p]of e.entries())P.push(t.jsx(Xe,{checked:r.has(p.packageName),entry:p,isSelected:C===k},p.packageName));const N=e.length,T=N>d&&d>0;return t.jsxs(h,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(h,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),t.jsxs(a,{wrap:"truncate",children:[s," ","optimizations",w]}),!l&&b>0&&t.jsxs(a,{dimColor:!0,children:[" ","—",b," ","selected"]})]}),t.jsx(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Je.map(C=>{const p=c===C.key;return t.jsxs(h,{children:[t.jsx(a,{dimColor:!p,children:"["}),t.jsx(a,{bold:p,color:p?"cyan":"gray",children:C.shortcut}),t.jsx(a,{dimColor:!p,children:"]"}),t.jsxs(a,{color:p?"white":"gray",children:[" ",C.label]})]},C.key)})}),o&&t.jsxs(h,{flexShrink:0,paddingX:1,children:[t.jsx(a,{bold:!0,color:"white",children:"/ "}),t.jsx(a,{children:n}),t.jsx(a,{inverse:!0,children:" "})]}),t.jsxs(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(h,{flexDirection:"column",marginTop:-m,children:P})}),T&&t.jsx(h,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(be,{contentHeight:N,placement:"inset",scrollOffset:m,style:"block",viewportHeight:d})})]})]})},Ke=100,W=10,Y={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},Ve=({isDryRun:r,store:e})=>{const{exit:o}=xe(),{columns:n,rows:c}=ye(),i=A.useSyncExternalStore(e.subscribe,e.getSnapshot),l=A.useRef(null),[m,k]=A.useState(0),[s,d]=A.useState(!1),u=e.getFilteredEntries(),j=u[i.selectedIndex]??null,f=n>=Ke,x=Math.max(0,c-5),$=A.useCallback(g=>{o(g)},[o]);return je((g,w)=>{if(s){g==="y"||g==="Y"?$():d(!1);return}if(i.filterActive){w.escape?(e.setFilterActive(!1),e.setFilterText("")):w.return?e.setFilterActive(!1):w.backspace||w.delete?e.setFilterText(i.filterText.slice(0,-1)):g&&!w.ctrl&&!w.meta&&e.setFilterText(i.filterText+g);return}if(g==="q"){!r&&i.checkedEntries.size>0?d(!0):$();return}if(g==="/"){e.setFilterActive(!0);return}if(Y[g]){e.setFilter(Y[g]);return}if(w.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(w.upArrow||g==="k"){const b=Math.max(0,i.selectedIndex-1);e.select(b),b<m&&k(b)}else if(w.downArrow||g==="j"){const b=Math.min(u.length-1,i.selectedIndex+1);e.select(b),b>=m+x&&k(b-x+1)}else g===" "?j&&e.toggleCheck(j.packageName):g==="a"?e.toggleAll():w.return&&!r&&i.checkedEntries.size>0&&$(e.getCheckedEntries());else i.focusedPanel==="detail"&&(w.upArrow||g==="k"?l.current?.scrollBy(-1):(w.downArrow||g==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),c<W?t.jsx(h,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",W," ","rows."]})}):t.jsxs(h,{flexDirection:"column",height:c,width:n,children:[t.jsxs(h,{flexDirection:f?"row":"column",flexGrow:1,children:[t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(He,{checkedEntries:i.checkedEntries,entries:u,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:x})}),t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Be,{entry:j,focused:i.focusedPanel==="detail",scrollRef:l})})]}),t.jsx(h,{flexShrink:0,paddingX:1,children:t.jsxs(a,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),t.jsx(ke,{autoExitSeconds:3,onCancel:()=>{d(!1)},visible:s})]})},q=(r,e)=>{const o=new Set;try{const n=Q(r),c=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const i of c)if(i)for(const l of Object.keys(i))o.add(l)}catch{}return o},re=r=>{const e=fe(r);if(e)return J(r,e);const o=O(r,"package.json");if(!B(o))return[];try{const n=Q(o),c=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return c?J(r,c):[]}catch{return[]}},We="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",Ye=r=>`${We}/${r}.md`,Ze=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":""},te=r=>{const e=[],o=(n,c)=>{const i=n.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:c,docUrl:l.type==="documented"&&l.docPath?Ye(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:Ze(l)})};return o(ue,"native"),o(ge,"preferred"),o(me,"micro-utility"),e},oe=(r,e,o,n)=>{const c=Ge.getManifestData("npm")??[],i=[];for(const[,l]of c){if(l.deprecated)continue;const m=r.has(l.package),k=e?Fe(e,l.package,o.name):!1;if(!m&&!k)continue;const s=Z.coerce(l.version)?.major;if(s===void 0)continue;const d=n?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(s)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:d,packageName:l.package,replacement:l.name})}return i};let G;const ne=async()=>{if(G)return G;try{return G=(await import("module-replacements-codemods")).codemods,G}catch{return{}}},se=async r=>{try{const e=await ne();for(const o of r)o.category!=="socket"&&e[o.packageName]&&(o.hasCodemod=!0)}catch{}},ie=async(r,e,o)=>{let n=0;try{const c=(await ne())[o];if(!c)return{filesChanged:0,packageName:o};const i=c({}),l=await Qe(e);for(const m of l){const k=_(m);if(k.includes(o))try{const s=await i.transform({file:{filename:m,source:k}});s!==k&&(await r.writeFile(m,s,"utf8"),n++)}catch(s){process.stderr.write(`warn: codemod transform failed for ${m}: ${s instanceof Error?s.message:String(s)}
|
|
13
|
+
`)}}}catch{}return{filesChanged:n,packageName:o}},Qe=async r=>Ce("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),er=async({fs:r,logger:e,options:o,visConfig:n,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=we(c),l=!!o.dryRun,m=!!o.prod,k=!!o.pin;y.info(`Detected ${i.name} v${i.version}.`);const s=q(O(c,"package.json"),m),d=re(c),u=new Set(s);for(const p of d){const I=q(O(ae(c,p),"package.json"),m);for(const E of I)u.add(E)}d.length>0&&y.info(`Scanned ${String(d.length)} workspace package${d.length===1?"":"s"}.`),y.info(`Scanning dependencies...
|
|
14
|
+
`);const j=Re(c,i.name),f=te(u),x=oe(u,j,i,k),$=new Set(f.map(p=>p.packageName)),g=x.filter(p=>!$.has(p.packageName)),w=[...f,...g];if(await se(w),w.length===0){y.info("No optimizations found for your dependencies.");return}const b=!!process.stdout.isTTY&&!he,P=o.format==="json"||!!o.json;if(b&&!l&&!P){const p=new ze(w),I=await de(pe.createElement(Ve,{isDryRun:!1,store:p}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),E=Array.isArray(I)?I:[];if(E.length===0){y.info("No optimizations selected.");return}const R=E.filter(v=>v.category!=="socket"&&v.hasCodemod),F=E.filter(v=>v.category!=="socket"&&!v.hasCodemod),L=E.filter(v=>v.category==="socket");if(R.length>0){y.info(`
|
|
15
15
|
Running ${String(R.length)} codemod${R.length===1?"":"s"}...
|
|
16
16
|
`);for(const v of R){const S=await ie(r,c,v.packageName);S.filesChanged>0?y.success(` ${v.packageName}: ${String(S.filesChanged)} file${S.filesChanged===1?"":"s"} updated`):y.info(` ${v.packageName}: no files changed`)}}if(F.length>0){y.warn(`
|
|
17
|
-
${String(F.length)} selected replacement${F.length===1?"":"s"} require manual migration (no codemod available):`);for(const v of F)y.info(` ${v.packageName} → ${v.replacement}`);y.notice(" Replace usage in your source code, then remove from dependencies.")}if(L.length>0){const v=L.filter(M=>M.overrideSpec).map(M=>({original:M.packageName,spec:M.overrideSpec})),S=Ie(c,O(c,"package.json"),v,i,
|
|
18
|
-
Added ${String(S.added.length)} override${S.added.length===1?"":"s"}.`),S.updated.length>0&&y.success(`Updated ${String(S.updated.length)} override${S.updated.length===1?"":"s"}.`)}if(L.length>0&&
|
|
17
|
+
${String(F.length)} selected replacement${F.length===1?"":"s"} require manual migration (no codemod available):`);for(const v of F)y.info(` ${v.packageName} → ${v.replacement}`);y.notice(" Replace usage in your source code, then remove from dependencies.")}if(L.length>0){const v=L.filter(M=>M.overrideSpec).map(M=>({original:M.packageName,spec:M.overrideSpec})),S=Ie(c,O(c,"package.json"),v,i,n?.editorconfig??!0);S.added.length>0&&y.success(`
|
|
18
|
+
Added ${String(S.added.length)} override${S.added.length===1?"":"s"}.`),S.updated.length>0&&y.success(`Updated ${String(S.updated.length)} override${S.updated.length===1?"":"s"}.`)}if(L.length>0&&o.install!==!1){y.info(`
|
|
19
19
|
Running ${i.name} install to update lockfile...`);const v=ve(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},c,e);v!==0&&y.warn(`${i.name} install exited with code ${String(v)}. Run it manually.`)}y.info(""),y.success("Optimization complete.");return}if(P){process.stdout.write(`${JSON.stringify({e18e:f.map(p=>({category:p.category,hasCodemod:p.hasCodemod,packageName:p.packageName,replacement:p.replacement})),packageManager:i.name,socket:g.map(p=>({overrideSpec:p.overrideSpec,packageName:p.packageName,replacement:p.replacement})),total:w.length,workspaces:d.length},void 0,2)}
|
|
20
20
|
`);return}const N=f.filter(p=>p.category==="native"),T=f.filter(p=>p.category==="preferred"),C=f.filter(p=>p.category==="micro-utility");if(N.length>0){y.info(`Native replacements (${String(N.length)}):`);for(const p of N)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(T.length>0){y.info(`
|
|
21
21
|
Preferred alternatives (${String(T.length)}):`);for(const p of T)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(C.length>0){y.info(`
|
|
22
22
|
Micro-utilities (${String(C.length)}):`);for(const p of C)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(g.length>0){y.info(`
|
|
23
23
|
Socket.dev overrides (${String(g.length)}):`);for(const p of g)y.info(` ${p.packageName} → ${p.overrideSpec}`)}y.info(`
|
|
24
|
-
Total: ${String(w.length)} optimizations available (⚙ = codemod available).`),l&&y.notice("Run without --dry-run for interactive selection.")},gr=Object.defineProperty({__proto__:null,buildE18eEntries:te,buildSocketEntries:
|
|
24
|
+
Total: ${String(w.length)} optimizations available (⚙ = codemod available).`),l&&y.notice("Run without --dry-run for interactive selection.")},gr=Object.defineProperty({__proto__:null,buildE18eEntries:te,buildSocketEntries:oe,collectDepsFromPkgJson:q,default:er,discoverWorkspacePackages:re,markCodemodAvailability:se,runCodemod:ie},Symbol.toStringTag,{value:"Module"});export{re as A,te as F,ie as I,Re as N,oe as T,se as U,Ie as a,gr as h,q as x};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as K}from"node:module";import{I as w,j as P,E as u,q as T,s as v,V as D}from"../packem_shared/index.server-
|
|
1
|
+
import{createRequire as K}from"node:module";import{I as w,j as P,E as u,q as T,s as v,V as D}from"../packem_shared/index.server-CusjRLCh.js";import{w as j,l as A,z as te,j as oe,q as W,b as $}from"../packem_shared/index-BLtnel38.js";import Z from"./index.js";import{T as se,Q as C,h as ne,Z as ae,_ as re,a0 as ie,a1 as pe}from"./cli-main.js";import{x as ce,e as q,k as I,a as B,u as L,b as fe}from"./catalog.js";import{a as S}from"../packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js";import{l as le}from"../packem_shared/missing-package-json-Cl0vdz6K.js";let X;const Y=e=>(X??=K(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ee=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,o]=V.versions.node.split(".").map(Number);if(a>22||a===22&&o>=3||a===20&&o>=16)return V.getBuiltinModule(e)}return Y(e)},{readFileSync:G,writeFileSync:O}=ee("node:fs"),ge=e=>/[*?[\]{}!]/.test(e),de=e=>typeof e=="string"?e:e.reason,ue=e=>typeof e=="string"?void 0:e.replacement,U=(e,a)=>e.some(o=>Z(o,a)),Q=(e,a)=>{if(typeof e=="string")return!0;const o=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!o&&!t||o&&a.packageName!==void 0&&U(e.packages,a.packageName)||t&&U(e.paths,a.packageDir))},me=(e,a)=>{const o=a[e.depName];if(o!==void 0&&Q(o,e))return{pattern:e.depName,rule:o};for(const[t,r]of Object.entries(a))if(ge(t)&&Z(t,e.depName)&&Q(r,e))return{pattern:t,rule:r}},he=(e,a)=>{if(Object.keys(a).length===0)return[];const o=[];for(const t of e){if(t.isInternal)continue;const r=me(t,a);r&&o.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:de(r.rule),replacement:ue(r.rule),specifier:t.specifier})}return o},ke=new Set(["dependencies","devDependencies","peerDependencies"]),ye=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),Pe=(e,a)=>{if(!e)return!1;for(const o of e.values())if(o.has(a))return!0;return!1},we=(e,a={})=>{const o=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ke.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const p=n.get(i.depName);p?p.push(i):n.set(i.depName,[i])}const s=[];for(const[i,p]of n){if(Pe(a.catalogs,i)||p.some(m=>ye(m.specifier)))continue;const c=new Map;for(const m of p){let d=c.get(m.specifier);d||(d=new Set,c.set(m.specifier,d)),d.add(m.packageJsonPath)}const f=[...c.entries()].sort((m,d)=>m[1].size!==d[1].size?d[1].size-m[1].size:m[0].localeCompare(d[0]))[0];!f||f[1].size<o||s.push({catalogName:"default",depName:i,instanceCount:f[1].size,specifier:f[0]})}return s.sort((i,p)=>i.depName.localeCompare(p.depName))},De=(e,a)=>{if(a.length===0)return;const o=j(e,"pnpm-workspace.yaml"),t=A(o)?G(o,"utf8"):"",r=t.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,n=a.filter(d=>d.catalogName==="default").sort((d,g)=>d.depName.localeCompare(g.depName));if(n.length===0)return;const s=t.length>0?t.split(r):[],i=s.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(i===-1){const d=["catalog:"];for(const y of n)d.push(` ${y.depName}: "${y.specifier}"`);let g=0;for(;g<s.length&&(s[g]??"").trim().length===0;)g+=1;const h=[...s.slice(0,g),...d,"",...s.slice(g)].join(r);return O(o,h.endsWith(r)?h:`${h}${r}`),o}let p=s.length;const c=new Set;for(let d=i+1;d<s.length;d+=1){const g=s[d]??"",h=g.trimStart();if(g.length===0)continue;if(g.length-h.length===0&&h.length>0&&!h.startsWith("#")){p=d;break}const y=/^([\w./@-]+)\s*:/.exec(h);y?.[1]&&c.add(y[1])}const f=[];for(const d of n)c.has(d.depName)||f.push(` ${d.depName}: "${d.specifier}"`);if(f.length===0)return;const m=[...s.slice(0,p),...f,...s.slice(p)].join(r);return O(o,m.endsWith(r)?m:`${m}${r}`),o},ve=(e,a)=>{if(a.length===0)return"";const o=j(e,"pnpm-workspace.yaml"),t=A(o)?G(o,"utf8"):"",r=[...a].sort((i,p)=>i.depName.localeCompare(p.depName)),n=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],s=t.includes(`\r
|