@visulima/vis 1.0.0-alpha.44 → 1.0.0-alpha.45
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 +51 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +63 -62
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +172 -973
- package/dist/packem_chunks/detect.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +2 -2
- 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/handler21.js +1 -1
- package/dist/packem_chunks/handler24.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 +1 -1
- package/dist/packem_chunks/handler5.js +3 -3
- package/dist/packem_chunks/handler50.js +4 -4
- package/dist/packem_chunks/handler51.js +3 -3
- package/dist/packem_chunks/handler57.js +4 -4
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +6 -6
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +1 -1
- package/dist/packem_chunks/handler62.js +2 -2
- package/dist/packem_chunks/handler63.js +4 -4
- package/dist/packem_chunks/handler65.js +2 -2
- package/dist/packem_chunks/handler66.js +13 -13
- package/dist/packem_chunks/handler67.js +5 -5
- package/dist/packem_chunks/handler68.js +16 -16
- package/dist/packem_chunks/handler69.js +5 -5
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler71.js +1 -1
- package/dist/packem_chunks/handler72.js +2 -2
- package/dist/packem_chunks/handler73.js +13 -13
- package/dist/packem_chunks/handler74.js +3 -3
- package/dist/packem_chunks/handler75.js +3 -3
- package/dist/packem_chunks/handler76.js +5 -5
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index2.js +802 -7
- package/dist/packem_chunks/index3.js +7 -135
- package/dist/packem_chunks/index4.js +134 -73
- package/dist/packem_chunks/index5.js +74 -0
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/print-config.js +1 -1
- package/dist/packem_chunks/registry.js +2 -2
- package/dist/packem_chunks/shell-runner.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 +2 -2
- package/dist/packem_chunks/ts-loader.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +2 -2
- package/dist/packem_shared/{Table-CcVkyULl-DLWu6XHL.js → Table-BGIHvenQ-D2oJtNQj.js} +1 -1
- package/dist/packem_shared/affected-shas-CCxG4tvm.js +1 -0
- package/dist/packem_shared/{ai-analysis-CO6S0afy.js → ai-analysis-rC48NLfB.js} +4 -4
- package/dist/packem_shared/{ai-fix-CI0Vvqld.js → ai-fix-D_ijV3Rn.js} +3 -3
- package/dist/packem_shared/bin-CPMo34SM.js +1 -0
- package/dist/packem_shared/{command-runtime-BE-vKsGH.js → command-runtime-3FTGuUsK.js} +1 -1
- package/dist/packem_shared/{env-C2ZCnfP_.js → env-Ct3hMEYB.js} +1 -1
- package/dist/packem_shared/{failure-log-jFfZRJK9.js → failure-log-Dy2G-rKi.js} +1 -1
- package/dist/packem_shared/{index-CQjzW7m8.js → index-Cntyu-w8.js} +1 -1
- package/dist/packem_shared/{index-D7EZ612R.js → index-XAb0QGqA.js} +1 -1
- package/dist/packem_shared/{lifecycle-Dyb47wbD.js → lifecycle-CHcFuWf_.js} +1 -1
- package/dist/packem_shared/{osv-bloom-BsQ-aFiM.js → osv-bloom-DVMlkcAO.js} +2 -2
- package/dist/packem_shared/{packument-DquNPIq9.js → packument-C-A3Uhhx.js} +1 -1
- package/dist/packem_shared/pm-runner-CQcraCcu.js +1 -0
- package/dist/packem_shared/{provenance-DIq8KyBV.js → provenance-R2csDSNg.js} +1 -1
- package/dist/packem_shared/{registry-keys-C8K11ets.js → registry-keys-CMnS_Qt_.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-Dr4kIybR.js → resolve-explicit-C4oQMyoB.js} +1 -1
- package/dist/packem_shared/resolve-runtime-QRaQucfL.js +1 -0
- package/dist/packem_shared/{s1ngularity-CtMmtXJo.js → s1ngularity-BCDt28u0.js} +1 -1
- package/dist/packem_shared/scan-progress-YRpDs90j.js +2 -0
- package/dist/packem_shared/{signatures-CE8OAK-i.js → signatures-B3srzCEv.js} +1 -1
- package/dist/packem_shared/use-measured-height-DHi0xOPO.js +1 -0
- package/dist/packem_shared/{vis-update-app-Cpme_3Du.js → vis-update-app-B3I14Vfy.js} +1 -1
- package/index.js +52 -52
- package/package.json +11 -11
- package/dist/packem_shared/affected-shas-CwRY5aoc.js +0 -1
- package/dist/packem_shared/bin-P6Q5tKrP.js +0 -1
- package/dist/packem_shared/pm-runner-D4jM58Oz.js +0 -1
- package/dist/packem_shared/resolve-runtime-Tx0bvg0h.js +0 -1
- package/dist/packem_shared/scan-progress-D4yywI6P.js +0 -2
- package/dist/packem_shared/use-measured-height-XK9YSwtv.js +0 -1
- package/dist/packem_shared/window-ops-DDePlWLV.js +0 -2
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import{createRequire as ce}from"node:module";import{m as O,v as
|
|
1
|
+
import{createRequire as ce}from"node:module";import{m as O,v as D,f as z,T as A,B as ae}from"../packem_shared/index-CE6MsgcV.js";import{v as le,m as t,n as m,i as a,r as _,$ as de,d as pe,e as fe,W as J}from"./catalog.js";import"../packem_shared/env-Ct3hMEYB.js";import{I as me}from"../packem_shared/index-B0EsgdzO.js";import he 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 Q}from"../packem_shared/index-Cg0IHaFI.js";import{T as xe,_ as ye,U as je,Q as ke,y as ve,W as we,p as y}from"./cli-main.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as be}from"./ts-loader.js";import{A as $e,y as Ce}from"../packem_shared/pm-runner-CQcraCcu.js";import{a as Z}from"../packem_shared/readJsonSync-CvkZyKmL-ihoybKvs.js";import{s as Se}from"../packem_shared/glob-fqg4KepW-1S3z30c8.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
2
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
-
const or=ce(import.meta.url),nr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const Oe=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ne=["overrides","pnpm","resolutions"],Ee=["engines","files"],Te=r=>{const e=
|
|
3
|
+
const or=ce(import.meta.url),nr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const Oe=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ne=["overrides","pnpm","resolutions"],Ee=["engines","files"],Te=r=>{const e=Q.coerce(r)?.major;return e!==void 0&&e>=10},Pe=r=>{const e=O(r,"pnpm-workspace.yaml");if(!z(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:be(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},_e=(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"&&Te(o.version)?Pe(r):_e(e,o.name),H=(r,e)=>{const o=e;for(const c of Ne){const i=r.indexOf(c);if(i!==-1&&c!==o)return o==="overrides"?i:i+1}let n=-1;for(const c of Oe){const i=r.indexOf(c);i>n&&(n=i)}if(n!==-1)return n+1;for(const c of Ee){const i=r.indexOf(c);if(i!==-1)return i}return r.length},De=(r,e)=>{const o=O(r,"pnpm-workspace.yaml");if(!z(o))throw new Error(`pnpm-workspace.yaml not found at ${o}. Cannot write overrides for pnpm v10+.`);let n=D(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}`,
|
|
9
|
-
`);else{const k=Object.keys(e),s=H(k,"pnpm"),d=Object.entries(e);d.splice(s,0,["pnpm",h]),
|
|
10
|
-
`)}}else{const h=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[h])e[h]=o,
|
|
11
|
-
`);else{const k=Object.keys(e),s=H(k,h),d=Object.entries(e);d.splice(s,0,[h,o]),
|
|
12
|
-
`)}}},Ie=(r,e,o,n,c)=>{if(n.name==="deno")return{added:[],updated:[]};const i=A(e),l=JSON.parse(i),{overrides:h,source:k}=De(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 b of Object.keys(x))u.add(b)}for(const f of o){const x=h[f.original];if(typeof x=="object")continue;let b=f.spec;n.name==="npm"&&u.has(f.original)&&(b=`$${f.original}`),x!==b&&(x?d.push(f.original):s.push(f.original),h[f.original]=b)}if(s.length===0&&d.length===0)return{added:s,updated:d};const j=Object.fromEntries(Object.entries(h).sort(([f],[x])=>f.localeCompare(x)));return k==="pnpm-workspace.yaml"?Ae(r,j):Re(e,l,j,n.name,c),{added:s,updated:d}},Fe=(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 A(c)}catch{continue}}return""},Me=(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 q={exports:{}},B,V;function X(){if(V)return B;V=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),h={};c(h,{PURL_Type:()=>k}),B=l(h);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 B}var K;function Ge(){return K||(K=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},h=(d,u,j)=>(l(d,u,"default"),j&&l(j,u,"default")),k={};i(k,{getManifestData:()=>s}),h(k,X(),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(([b,g])=>g.package===u);return x?x[1]:void 0}catch{return}}r.exports={getManifestData:s,...X()}})(q)),q.exports}var Le=Ge();const qe=(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 Be{#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=()=>qe(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"},ze={"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."},Je=({entry:r,focused:e,scrollRef:o})=>{const n=e?"white":"gray";if(!r)return t.jsx(m,{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(m,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(m,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.packageName})}),t.jsxs(xe,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(m,{children:[t.jsx(m,{width:14,children:t.jsx(a,{dimColor:!0,children:"Category:"})}),t.jsx(a,{bold:!0,color:c,children:r.category})]}),t.jsxs(m,{children:[t.jsx(m,{width:14,children:t.jsx(a,{dimColor:!0,children:"Replace with:"})}),t.jsx(a,{children:r.replacement})]}),r.overrideSpec&&t.jsxs(m,{children:[t.jsx(m,{width:14,children:t.jsx(a,{dimColor:!0,children:"Override:"})}),t.jsx(a,{color:"cyan",children:r.overrideSpec})]}),t.jsxs(m,{children:[t.jsx(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"DESCRIPTION"}),t.jsx(m,{marginTop:1,paddingLeft:2,children:t.jsx(a,{children:ze[r.category]??""})})]}),r.category==="native"&&t.jsxs(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"green",children:"ACTION"}),t.jsx(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"cyan",children:"ACTION"}),t.jsxs(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"yellow",children:"ACTION"}),t.jsx(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"LINKS"}),t.jsxs(m,{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})]})]})]})]})},He=[{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"}],Ve=({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(m,{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(m,{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})]})},Xe=({checkedEntries:r,entries:e,filterActive:o,filterText:n,filterType:c,focused:i,isDryRun:l,scrollOffset:h,selectedIndex:k,totalEntries:s,viewportHeight:d})=>{const u=i?"white":"gray";let j=0,f=0,x=0,b=0;for(const C of e)switch(C.category){case"micro-utility":{x++;break}case"native":{j++;break}case"preferred":{f++;break}case"socket":{b++;break}}const g=[];j>0&&g.push(`${j} native`),f>0&&g.push(`${f} preferred`),x>0&&g.push(`${x} micro`),b>0&&g.push(`${b} socket`);const w=g.length>0?` (${g.join(", ")})`:"",$=r.size,T=[];for(const[C,p]of e.entries())T.push(t.jsx(Ve,{checked:r.has(p.packageName),entry:p,isSelected:C===k},p.packageName));const N=e.length,P=N>d&&d>0;return t.jsxs(m,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(m,{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&&$>0&&t.jsxs(a,{dimColor:!0,children:[" ","—",$," ","selected"]})]}),t.jsx(m,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:He.map(C=>{const p=c===C.key;return t.jsxs(m,{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(m,{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(m,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(m,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(m,{flexDirection:"column",marginTop:-h,children:T})}),P&&t.jsx(m,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ye,{contentHeight:N,placement:"inset",scrollOffset:h,style:"block",viewportHeight:d})})]})]})},Ke=100,W=10,Y={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},We=({isDryRun:r,store:e})=>{const{exit:o}=je(),{columns:n,rows:c}=ke(),i=_.useSyncExternalStore(e.subscribe,e.getSnapshot),l=_.useRef(null),[h,k]=_.useState(0),[s,d]=_.useState(!1),u=e.getFilteredEntries(),j=u[i.selectedIndex]??null,f=n>=Ke,x=Math.max(0,c-5),b=_.useCallback(g=>{o(g)},[o]);return we((g,w)=>{if(s){g==="y"||g==="Y"?b():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):b();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 $=Math.max(0,i.selectedIndex-1);e.select($),$<h&&k($)}else if(w.downArrow||g==="j"){const $=Math.min(u.length-1,i.selectedIndex+1);e.select($),$>=h+x&&k($-x+1)}else g===" "?j&&e.toggleCheck(j.packageName):g==="a"?e.toggleAll():w.return&&!r&&i.checkedEntries.size>0&&b(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(m,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",W," ","rows."]})}):t.jsxs(m,{flexDirection:"column",height:c,width:n,children:[t.jsxs(m,{flexDirection:f?"row":"column",flexGrow:1,children:[t.jsx(m,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Xe,{checkedEntries:i.checkedEntries,entries:u,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:h,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:x})}),t.jsx(m,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Je,{entry:j,focused:i.focusedPanel==="detail",scrollRef:l})})]}),t.jsx(m,{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(ve,{autoExitSeconds:3,onCancel:()=>{d(!1)},visible:s})]})},U=(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(!z(o))return[];try{const n=Q(o),c=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return c?J(r,c):[]}catch{return[]}},Ye="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",Ze=r=>`${Ye}/${r}.md`,Qe=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?Ze(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:Qe(l)})};return o(ue,"native"),o(ge,"preferred"),o(he,"micro-utility"),e},oe=(r,e,o,n)=>{const c=Le.getManifestData("npm")??[],i=[];for(const[,l]of c){if(l.deprecated)continue;const h=r.has(l.package),k=e?Me(e,l.package,o.name):!1;if(!h&&!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 er(e);for(const h of l){const k=A(h);if(k.includes(o))try{const s=await i.transform({file:{filename:h,source:k}});s!==k&&(await r.writeFile(h,s,"utf8"),n++)}catch(s){process.stderr.write(`warn: codemod transform failed for ${h}: ${s instanceof Error?s.message:String(s)}
|
|
13
|
-
`)}}}catch{}return{filesChanged:n,packageName:o}},er=async r=>Se("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),rr=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=$e(c),l=!!o.dryRun,h=!!o.prod,k=!!o.pin;y.info(`Detected ${i.name} v${i.version}.`);const s=
|
|
14
|
-
`);const j=Fe(c,i.name),f=te(u),x=oe(u,j,i,k),b=new Set(f.map(p=>p.packageName)),g=x.filter(p=>!b.has(p.packageName)),
|
|
8
|
+
${c}`,A(o,n)},Re=(r,e,o,n,c)=>{const i=D(r),l=le(r,i,{useEditorconfig:c});if(n==="pnpm"){const h=e.pnpm??{};if(h.overrides=o,e.pnpm)e.pnpm=h,A(r,`${JSON.stringify(e,null,l)}
|
|
9
|
+
`);else{const k=Object.keys(e),s=H(k,"pnpm"),d=Object.entries(e);d.splice(s,0,["pnpm",h]),A(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
|
|
10
|
+
`)}}else{const h=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[h])e[h]=o,A(r,`${JSON.stringify(e,null,l)}
|
|
11
|
+
`);else{const k=Object.keys(e),s=H(k,h),d=Object.entries(e);d.splice(s,0,[h,o]),A(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
|
|
12
|
+
`)}}},Ie=(r,e,o,n,c)=>{if(n.name==="deno")return{added:[],updated:[]};const i=D(e),l=JSON.parse(i),{overrides:h,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 b of Object.keys(x))u.add(b)}for(const f of o){const x=h[f.original];if(typeof x=="object")continue;let b=f.spec;n.name==="npm"&&u.has(f.original)&&(b=`$${f.original}`),x!==b&&(x?d.push(f.original):s.push(f.original),h[f.original]=b)}if(s.length===0&&d.length===0)return{added:s,updated:d};const j=Object.fromEntries(Object.entries(h).sort(([f],[x])=>f.localeCompare(x)));return k==="pnpm-workspace.yaml"?De(r,j):Re(e,l,j,n.name,c),{added:s,updated:d}},Fe=(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 D(c)}catch{continue}}return""},Me=(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 q={exports:{}},U,X;function K(){if(X)return U;X=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),h={};c(h,{PURL_Type:()=>k}),U=l(h);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 Ge(){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},h=(d,u,j)=>(l(d,u,"default"),j&&l(j,u,"default")),k={};i(k,{getManifestData:()=>s}),h(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(([b,g])=>g.package===u);return x?x[1]:void 0}catch{return}}r.exports={getManifestData:s,...K()}})(q)),q.exports}var Le=Ge();const qe=(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 Ue{#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=()=>qe(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"},Be={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},ze={"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."},Je=({entry:r,focused:e,scrollRef:o})=>{const n=e?"white":"gray";if(!r)return t.jsx(m,{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(m,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(m,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.packageName})}),t.jsxs(xe,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(m,{children:[t.jsx(m,{width:14,children:t.jsx(a,{dimColor:!0,children:"Category:"})}),t.jsx(a,{bold:!0,color:c,children:r.category})]}),t.jsxs(m,{children:[t.jsx(m,{width:14,children:t.jsx(a,{dimColor:!0,children:"Replace with:"})}),t.jsx(a,{children:r.replacement})]}),r.overrideSpec&&t.jsxs(m,{children:[t.jsx(m,{width:14,children:t.jsx(a,{dimColor:!0,children:"Override:"})}),t.jsx(a,{color:"cyan",children:r.overrideSpec})]}),t.jsxs(m,{children:[t.jsx(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"DESCRIPTION"}),t.jsx(m,{marginTop:1,paddingLeft:2,children:t.jsx(a,{children:ze[r.category]??""})})]}),r.category==="native"&&t.jsxs(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"green",children:"ACTION"}),t.jsx(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"cyan",children:"ACTION"}),t.jsxs(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"yellow",children:"ACTION"}),t.jsx(m,{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(m,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"LINKS"}),t.jsxs(m,{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})]})]})]})]})},He=[{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=Be[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return t.jsxs(m,{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(m,{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})]})},Ke=({checkedEntries:r,entries:e,filterActive:o,filterText:n,filterType:c,focused:i,isDryRun:l,scrollOffset:h,selectedIndex:k,totalEntries:s,viewportHeight:d})=>{const u=i?"white":"gray";let j=0,f=0,x=0,b=0;for(const C of e)switch(C.category){case"micro-utility":{x++;break}case"native":{j++;break}case"preferred":{f++;break}case"socket":{b++;break}}const g=[];j>0&&g.push(`${j} native`),f>0&&g.push(`${f} preferred`),x>0&&g.push(`${x} micro`),b>0&&g.push(`${b} socket`);const v=g.length>0?` (${g.join(", ")})`:"",$=r.size,T=[];for(const[C,p]of e.entries())T.push(t.jsx(Xe,{checked:r.has(p.packageName),entry:p,isSelected:C===k},p.packageName));const N=e.length,P=N>d&&d>0;return t.jsxs(m,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(m,{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",v]}),!l&&$>0&&t.jsxs(a,{dimColor:!0,children:[" ","—",$," ","selected"]})]}),t.jsx(m,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:He.map(C=>{const p=c===C.key;return t.jsxs(m,{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(m,{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(m,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(m,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(m,{flexDirection:"column",marginTop:-h,children:T})}),P&&t.jsx(m,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ye,{contentHeight:N,placement:"inset",scrollOffset:h,style:"block",viewportHeight:d})})]})]})},Ve=100,W=10,Y={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},We=({isDryRun:r,store:e})=>{const{exit:o}=je(),{columns:n,rows:c}=ke(),i=_.useSyncExternalStore(e.subscribe,e.getSnapshot),l=_.useRef(null),[h,k]=_.useState(0),[s,d]=_.useState(!1),u=e.getFilteredEntries(),j=u[i.selectedIndex]??null,f=n>=Ve,x=Math.max(0,c-5),b=_.useCallback(g=>{o(g)},[o]);return ve((g,v)=>{if(s){g==="y"||g==="Y"?b():d(!1);return}if(i.filterActive){v.escape?(e.setFilterActive(!1),e.setFilterText("")):v.return?e.setFilterActive(!1):v.backspace||v.delete?e.setFilterText(i.filterText.slice(0,-1)):g&&!v.ctrl&&!v.meta&&e.setFilterText(i.filterText+g);return}if(g==="q"){!r&&i.checkedEntries.size>0?d(!0):b();return}if(g==="/"){e.setFilterActive(!0);return}if(Y[g]){e.setFilter(Y[g]);return}if(v.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(v.upArrow||g==="k"){const $=Math.max(0,i.selectedIndex-1);e.select($),$<h&&k($)}else if(v.downArrow||g==="j"){const $=Math.min(u.length-1,i.selectedIndex+1);e.select($),$>=h+x&&k($-x+1)}else g===" "?j&&e.toggleCheck(j.packageName):g==="a"?e.toggleAll():v.return&&!r&&i.checkedEntries.size>0&&b(e.getCheckedEntries());else i.focusedPanel==="detail"&&(v.upArrow||g==="k"?l.current?.scrollBy(-1):(v.downArrow||g==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),c<W?t.jsx(m,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",W," ","rows."]})}):t.jsxs(m,{flexDirection:"column",height:c,width:n,children:[t.jsxs(m,{flexDirection:f?"row":"column",flexGrow:1,children:[t.jsx(m,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Ke,{checkedEntries:i.checkedEntries,entries:u,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:h,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:x})}),t.jsx(m,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Je,{entry:j,focused:i.focusedPanel==="detail",scrollRef:l})})]}),t.jsx(m,{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(we,{autoExitSeconds:3,onCancel:()=>{d(!1)},visible:s})]})},B=(r,e)=>{const o=new Set;try{const n=Z(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(!z(o))return[];try{const n=Z(o),c=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return c?J(r,c):[]}catch{return[]}},Ye="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",Qe=r=>`${Ye}/${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?Qe(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:Ze(l)})};return o(ue,"native"),o(ge,"preferred"),o(he,"micro-utility"),e},oe=(r,e,o,n)=>{const c=Le.getManifestData("npm")??[],i=[];for(const[,l]of c){if(l.deprecated)continue;const h=r.has(l.package),k=e?Me(e,l.package,o.name):!1;if(!h&&!k)continue;const s=Q.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 er(e);for(const h of l){const k=D(h);if(k.includes(o))try{const s=await i.transform({file:{filename:h,source:k}});s!==k&&(await r.writeFile(h,s,"utf8"),n++)}catch(s){process.stderr.write(`warn: codemod transform failed for ${h}: ${s instanceof Error?s.message:String(s)}
|
|
13
|
+
`)}}}catch{}return{filesChanged:n,packageName:o}},er=async r=>Se("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),rr=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=$e(c),l=!!o.dryRun,h=!!o.prod,k=!!o.pin;y.info(`Detected ${i.name} v${i.version}.`);const s=B(O(c,"package.json"),h),d=re(c),u=new Set(s);for(const p of d){const R=B(O(ae(c,p),"package.json"),h);for(const E of R)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=Fe(c,i.name),f=te(u),x=oe(u,j,i,k),b=new Set(f.map(p=>p.packageName)),g=x.filter(p=>!b.has(p.packageName)),v=[...f,...g];if(await se(v),v.length===0){y.info("No optimizations found for your dependencies.");return}const $=!!process.stdout.isTTY&&!me,T=o.format==="json"||!!o.json;if($&&!l&&!T){const p=new Ue(v),R=await de(pe.createElement(We,{isDryRun:!1,store:p}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),E=Array.isArray(R)?R:[];if(E.length===0){y.info("No optimizations selected.");return}const I=E.filter(w=>w.category!=="socket"&&w.hasCodemod),F=E.filter(w=>w.category!=="socket"&&!w.hasCodemod),L=E.filter(w=>w.category==="socket");if(I.length>0){y.info(`
|
|
15
15
|
Running ${String(I.length)} codemod${I.length===1?"":"s"}...
|
|
16
|
-
`);for(const
|
|
17
|
-
${String(F.length)} selected replacement${F.length===1?"":"s"} require manual migration (no codemod available):`);for(const
|
|
16
|
+
`);for(const w of I){const S=await ie(r,c,w.packageName);S.filesChanged>0?y.success(` ${w.packageName}: ${String(S.filesChanged)} file${S.filesChanged===1?"":"s"} updated`):y.info(` ${w.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 w of F)y.info(` ${w.packageName} → ${w.replacement}`);y.notice(" Replace usage in your source code, then remove from dependencies.")}if(L.length>0){const w=L.filter(M=>M.overrideSpec).map(M=>({original:M.packageName,spec:M.overrideSpec})),S=Ie(c,O(c,"package.json"),w,i,n?.editorconfig??!0);S.added.length>0&&y.success(`
|
|
18
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
|
-
Running ${i.name} install to update lockfile...`);const
|
|
19
|
+
Running ${i.name} install to update lockfile...`);const w=Ce(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);w!==0&&y.warn(`${i.name} install exited with code ${String(w)}. Run it manually.`)}y.info(""),y.success("Optimization complete.");return}if(T){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:v.length,workspaces:d.length},void 0,2)}
|
|
20
20
|
`);return}const N=f.filter(p=>p.category==="native"),P=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(P.length>0){y.info(`
|
|
21
21
|
Preferred alternatives (${String(P.length)}):`);for(const p of P)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(
|
|
24
|
+
Total: ${String(v.length)} optimizations available (⚙ = codemod available).`),l&&y.notice("Run without --dry-run for interactive selection.")},jr=Object.defineProperty({__proto__:null,buildE18eEntries:te,buildSocketEntries:oe,collectDepsFromPkgJson:B,default:rr,discoverWorkspacePackages:re,markCodemodAvailability:se,runCodemod:ie},Symbol.toStringTag,{value:"Module"});export{re as A,te as F,ie as I,Fe as N,oe as T,se as U,Ie as a,jr as h,B as x};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{createRequire as
|
|
1
|
+
import{createRequire as Q}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-J83sowC4.js";import{m as j,f as A,v as ee,T as te,O as R,y as $}from"../packem_shared/index-CE6MsgcV.js";import G from"./index.js";import{a0 as oe,Z as C,g as se,a1 as ne,a2 as ae,a3 as re,a4 as ie}from"./cli-main.js";import{e as pe,W as B,l as I,a as L,U as q,R as ce}from"./catalog.js";import{a as S}from"../packem_shared/readJsonSync-CvkZyKmL-ihoybKvs.js";import{l as fe}from"../packem_shared/missing-package-json-CTF71tE5.js";const X=Q(import.meta.url),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Y=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 X(e)},{readFileSync:H,writeFileSync:z}=Y("node:fs"),le=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,de=e=>typeof e=="string"?void 0:e.replacement,U=(e,a)=>e.some(o=>G(o,a)),Z=(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))},ue=(e,a)=>{const o=a[e.depName];if(o!==void 0&&Z(o,e))return{pattern:e.depName,rule:o};for(const[t,r]of Object.entries(a))if(le(t)&&G(t,e.depName)&&Z(r,e))return{pattern:t,rule:r}},me=(e,a)=>{if(Object.keys(a).length===0)return[];const o=[];for(const t of e){if(t.isInternal)continue;const r=ue(t,a);r&&o.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:de(r.rule),specifier:t.specifier})}return o},he=new Set(["dependencies","devDependencies","peerDependencies"]),ke=e=>e.startsWith("catalog:"),ye=e=>e.startsWith("workspace:"),$e=(e,a)=>{if(!e)return!1;for(const o of e.values())if(o.has(a))return!0;return!1},Pe=(e,a={})=>{const o=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!he.has(i.depType)||ye(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($e(a.catalogs,i)||p.some(m=>ke(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))},we=(e,a)=>{if(a.length===0)return;const o=j(e,"pnpm-workspace.yaml"),t=A(o)?H(o,"utf8"):"",r=t.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
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 z(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 z(o,m.endsWith(r)?m:`${m}${r}`),o},De=(e,a)=>{if(a.length===0)return"";const o=j(e,"pnpm-workspace.yaml"),t=A(o)?
|
|
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 z(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 z(o,m.endsWith(r)?m:`${m}${r}`),o},De=(e,a)=>{if(a.length===0)return"";const o=j(e,"pnpm-workspace.yaml"),t=A(o)?H(o,"utf8"):"",r=[...a].sort((i,p)=>i.depName.localeCompare(p.depName)),n=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],s=t.includes(`\r
|
|
5
5
|
`)?`\r
|
|
6
6
|
`:`
|
|
7
7
|
`;if((t.length>0?t.split(s):[]).findIndex(i=>/^catalog\s*:\s*$/.test(i))===-1){n.push("@@ +1 @@","+catalog:");for(const i of r)n.push(`+ ${i.depName}: "${i.specifier}"`)}else{n.push("@@ catalog: @@");for(const i of r)n.push(`+ ${i.depName}: "${i.specifier}"`)}return n.join(s)},ve=e=>{const a=[],o=pe(e);if(o){const r=j(e,"pnpm-workspace.yaml");for(const n of o)n.startsWith("!")||B(e,[n]).length===0&&a.push({pattern:n,source:"pnpm-workspace.yaml",sourcePath:r})}const t=j(e,"package.json");if(A(t)){const r=S(t).workspaces,n=Array.isArray(r)?r:r?.packages;if(n)for(const s of n)typeof s!="string"||s.startsWith("!")||B(e,[s]).length===0&&a.push({pattern:s,source:"package.json",sourcePath:t})}return a},Ne=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.sourcePath);s?s.push(n):t.set(n.sourcePath,[n])}const r=[];for(const[n,s]of t){const i=new Set(s.map(f=>f.pattern));if(n.endsWith(".yaml")||n.endsWith(".yml")){const f=ee(n).split(`
|
|
8
8
|
`).filter(m=>{const d=m.trim();if(!d.startsWith("- "))return!0;const g=d.slice(2).replaceAll(/^['"]|['"]$/g,"");return!i.has(g)}).join(`
|
|
9
|
-
`);te(n,f,{overwrite:!0}),r.push(n);continue}const p=S(n),c=p.workspaces;Array.isArray(c)?p.workspaces=c.filter(f=>typeof f!="string"||!i.has(f)):c&&Array.isArray(c.packages)&&(c.packages=c.packages.filter(f=>typeof f!="string"||!i.has(f))),R(n,p,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},be=["dependencies","devDependencies","peerDependencies","optionalDependencies"],xe=(e,a={})=>{const o=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const s=j(e,n,"package.json"),i=C(s);if(!i)continue;const p=typeof i.name=="string"?i.name:void 0;for(const c of be){if(o.has(c))continue;const f=i[c];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:c,packageDir:n,packageJsonPath:s,packageName:p})}}return r},Je=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s){const c=i[p.depType];typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.keys(c).length===0&&Reflect.deleteProperty(i,p.depType)}R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},Te=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Se=(e,a={})=>{const o=new Set(a.depTypes??Te),t=new Set(a.ignoreDeps),r=new Map;for(const s of e)s.packageDir!=="."||!o.has(s.depType)||r.set(s.depName,{depType:s.depType,specifier:s.specifier});if(r.size===0)return[];const n=[];for(const s of e){if(s.packageDir==="."||!o.has(s.depType)||t.has(s.depName))continue;const i=r.get(s.depName);i&&n.push({childSpecifier:s.specifier,depName:s.depName,depType:s.depType,packageDir:s.packageDir,packageJsonPath:s.packageJsonPath,packageName:s.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},Me=(e,a)=>{if(!a)return[];const o=j(e,"package.json"),t=C(o);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:o}]},je=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),s=n.dependencies;if(typeof s!="object"||s===null)continue;const i=s;n.devDependencies??={};const p=n.devDependencies;for(const c of r.depNames){const f=i[c];typeof f=="string"&&(c in p||(p[c]=f),Reflect.deleteProperty(i,c))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),R(r.packageJsonPath,n,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},We=/^[a-z][\w-]*@\S+$/i,Re=(e,a,o={})=>{if(!a)return[];const t=j(e,"package.json"),r=C(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&We.test(n)?[]:[{packageJsonPath:t,suggested:o.suggested}]},Ee=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,R(r.packageJsonPath,n,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ie=(e,a)=>{if(!a)return[];const o=j(e,"package.json"),t=C(o);return t?t.private===!0?[]:[{packageJsonPath:o,rawValue:t.private}]:[]},Fe=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let s=n;if("private"in n)n.private=!0;else{const{name:i,version:p,...c}=n,f={};i!==void 0&&(f.name=i),p!==void 0&&(f.version=p),f.private=!0;for(const[m,d]of Object.entries(c))f[m]=d;s=f}R(r.packageJsonPath,s,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ve=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Ae=new Set(["dependencies","devDependencies","peerDependencies"]),Ce=(e,a)=>{for(const o of e)if(o.members?.includes(a)||o.prefixes?.some(t=>a.startsWith(t)))return o},_e=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),Oe=(e,a={})=>{const o=new Set(a.ignoreFamilies),t=new Map;for(const i of Ve)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Ae.has(i.depType)||_e(i.specifier))continue;const p=Ce(r,i.depName);if(!p||o.has(p.id))continue;const c=n.get(p.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};c?c.push(f):n.set(p.id,[f])}const s=[];for(const[i,p]of n){const c=[...new Set(p.map(m=>m.specifier))];if(c.length<2)continue;const f=t.get(i);f&&s.push({family:i,familyLabel:f.label??i,members:p,specifiers:c})}return s},ze=e=>e.startsWith("@types/"),Be=(e,a={})=>{const o=new Set(a.ignoreDeps),t=new Map,r=s=>{const i=t.get(s);if(i!==void 0)return i;try{const p=S(s).private===!0;return t.set(s,p),p}catch{return t.set(s,!1),!1}},n=[];for(const s of e)s.depType==="dependencies"&&ze(s.depName)&&(o.has(s.depName)||r(s.packageJsonPath)&&n.push({childSpecifier:s.specifier,depName:s.depName,packageDir:s.packageDir,packageJsonPath:s.packageJsonPath,packageName:s.packageName}));return n},Le=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n),p=i.dependencies;if(typeof p!="object"||p===null)continue;const c=p;i.devDependencies??={};const f=i.devDependencies;for(const m of s){const d=c[m.depName];typeof d=="string"&&(m.depName in f||(f[m.depName]=d),Reflect.deleteProperty(c,m.depName))}Object.keys(c).length===0&&Reflect.deleteProperty(i,"dependencies"),R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ue=(e,a={})=>{const o=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:o,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ge=(e,a,o,t)=>{const r=a.split(".");let n=e;for(let p=0;p<r.length-1;p+=1){const c=r[p],f=n[c];(typeof f!="object"||f===null)&&(n[c]={}),n=n[c]}const s=r.at(-1);let i=n[s];(typeof i!="object"||i===null)&&(i={},n[s]=i),i[o]=t},He=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s)if(p.depType.includes("."))Ge(i,p.depType,p.depName,p.fix);else{const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},Ke=new Set(["dependencies","devDependencies","peerDependencies"]),Qe=e=>e.startsWith("catalog:"),Xe=e=>e.startsWith("workspace:"),Ye=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},Ze=(e,a)=>{if(e.get("default")?.has(a))return"default";const o=[...e.keys()].filter(t=>t!=="default").sort();for(const t of o)if(e.get(t)?.has(a))return t},et=e=>e==="default"?"catalog:":`catalog:${e}`,tt=(e,a)=>{const o=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of o){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const s=L(t.specifier);if(!s){t=r;continue}const i=q(s,n),p=q(n,s);(a==="highest"&&i||a==="lowest"&&p)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},ot=(e,a={})=>{const o=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!Ke.has(i.depType)||Xe(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),s=new Map;for(const i of n){const p=s.get(i.depName);p?p.push(i):s.set(i.depName,[i])}for(const[i,p]of s){const c=a.pinned?.get(i);if(c!==void 0){for(const g of p)g.specifier!==c&&r.push({canonicalSource:"cli:--pin",depName:i,depType:g.depType,fix:c,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier});continue}if(o==="catalog"){const{catalogs:g}=a;if(!g)continue;const h=Ze(g,i);if(!h)continue;const y=et(h);for(const x of p)Ye(x.specifier)!==h&&r.push({canonicalSource:`catalog:${h}`,depName:i,depType:x.depType,fix:y,packageDir:x.packageDir,packageJsonPath:x.packageJsonPath,packageName:x.packageName,specifier:x.specifier});continue}const f=p.filter(g=>!Qe(g.specifier));if(f.length<2||new Set(f.map(g=>g.specifier)).size<=1)continue;const m=tt(f,o);if(!m)continue;const d=m.canonical.specifier;for(const g of f)g.specifier!==d&&r.push({canonicalSource:m.canonicalSource,depName:i,depType:g.depType,fix:d,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier})}return r},st=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s){const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},nt=e=>{if(A(j(e,"pnpm-workspace.yaml")))return!0;const a=j(e,"package.json");if(!A(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},I=(e,a)=>{const o=new Map;for(const t of e){const r=a(t),n=o.get(r);n?n.push(t):o.set(r,[t])}return o},at=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ workspace-protocol: no violations"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[s,i]of I(e,p=>p.packageName??p.packageJsonPath)){const p=$(a,i[0].packageJsonPath);t.info(` ${P(s)} ${u(`(${p})`)}`);for(const c of i){const f=o?T("→"):v("→");t.info(` ${u(c.depType)} ${c.depName}: ${D(c.specifier)} ${f} ${w(c.fix)}`)}}o||t.info(u(" Run with --fix to rewrite specifiers in place."))},rt=(e,a,o)=>{if(e.length===0){o.info(w("✓ redefine-root: no violations"));return}o.info(v(P(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of I(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);o.info(` ${P(t)} ${u(`(${n})`)}`);for(const s of r)o.info(` ${u(s.depType)} ${s.depName}: ${D(s.childSpecifier)} ${u(`(root ${s.rootDepType}: ${s.rootSpecifier})`)}`)}o.info(u(" Remove these from child package.json files — root pin will resolve."))},it=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ workspace-versions: no drift"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[s,i]of I(e,p=>p.depName)){const p=i[0].fix,c=i[0].canonicalSource;t.info(` ${P(s)} ${u(`canonical: ${p} (from ${c})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),d=f.packageName??m,g=o?T("→"):v("→");t.info(` ${d} ${u(`(${m})`)} ${u(f.depType)}: ${D(f.specifier)} ${g} ${w(f.fix)}`)}}o||t.info(u(" Run with --fix to align drifting specifiers."))},pt=(e,a,o)=>{if(e.length===0){o.info(w("✓ banned-deps: no violations"));return}o.info(D(P(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of I(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);o.info(` ${P(t)} ${u(`(${n})`)}`);for(const s of r){const i=s.replacement?` ${u("→")} ${w(s.replacement)}`:"";o.info(` ${u(s.depType)} ${D(s.depName)}${i}`),o.info(` ${u(s.reason)}`)}}},ct=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ catalog-proposals: nothing worth promoting"));return}const r=o?"Added":"Would add",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const s of e)t.info(` ${P(s.depName)}: ${w(s.specifier)} ${u(`(${String(s.instanceCount)} packages agree)`)}`);if(!o){const s=De(a,e);if(s){t.info(""),t.info(u("Proposed pnpm-workspace.yaml changes:"));for(const i of s.split(`
|
|
10
|
-
`))i.startsWith("+")?t.info(w(i)):i.startsWith("-")?t.info(D(i)):t.info(u(i))}t.info(u(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ft=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ custom-types: no engines / packageManager / volta drift"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[s,i]of
|
|
9
|
+
`);te(n,f,{overwrite:!0}),r.push(n);continue}const p=S(n),c=p.workspaces;Array.isArray(c)?p.workspaces=c.filter(f=>typeof f!="string"||!i.has(f)):c&&Array.isArray(c.packages)&&(c.packages=c.packages.filter(f=>typeof f!="string"||!i.has(f))),R(n,p,{indent:I(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},be=["dependencies","devDependencies","peerDependencies","optionalDependencies"],xe=(e,a={})=>{const o=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const s=j(e,n,"package.json"),i=C(s);if(!i)continue;const p=typeof i.name=="string"?i.name:void 0;for(const c of be){if(o.has(c))continue;const f=i[c];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:c,packageDir:n,packageJsonPath:s,packageName:p})}}return r},Je=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s){const c=i[p.depType];typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.keys(c).length===0&&Reflect.deleteProperty(i,p.depType)}R(n,i,{indent:I(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},Te=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Se=(e,a={})=>{const o=new Set(a.depTypes??Te),t=new Set(a.ignoreDeps),r=new Map;for(const s of e)s.packageDir!=="."||!o.has(s.depType)||r.set(s.depName,{depType:s.depType,specifier:s.specifier});if(r.size===0)return[];const n=[];for(const s of e){if(s.packageDir==="."||!o.has(s.depType)||t.has(s.depName))continue;const i=r.get(s.depName);i&&n.push({childSpecifier:s.specifier,depName:s.depName,depType:s.depType,packageDir:s.packageDir,packageJsonPath:s.packageJsonPath,packageName:s.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},Me=(e,a)=>{if(!a)return[];const o=j(e,"package.json"),t=C(o);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:o}]},je=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),s=n.dependencies;if(typeof s!="object"||s===null)continue;const i=s;n.devDependencies??={};const p=n.devDependencies;for(const c of r.depNames){const f=i[c];typeof f=="string"&&(c in p||(p[c]=f),Reflect.deleteProperty(i,c))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),R(r.packageJsonPath,n,{indent:I(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},We=/^[a-z][\w-]*@\S+$/i,Re=(e,a,o={})=>{if(!a)return[];const t=j(e,"package.json"),r=C(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&We.test(n)?[]:[{packageJsonPath:t,suggested:o.suggested}]},Ie=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,R(r.packageJsonPath,n,{indent:I(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ee=(e,a)=>{if(!a)return[];const o=j(e,"package.json"),t=C(o);return t?t.private===!0?[]:[{packageJsonPath:o,rawValue:t.private}]:[]},Fe=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let s=n;if("private"in n)n.private=!0;else{const{name:i,version:p,...c}=n,f={};i!==void 0&&(f.name=i),p!==void 0&&(f.version=p),f.private=!0;for(const[m,d]of Object.entries(c))f[m]=d;s=f}R(r.packageJsonPath,s,{indent:I(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ve=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Ae=new Set(["dependencies","devDependencies","peerDependencies"]),Ce=(e,a)=>{for(const o of e)if(o.members?.includes(a)||o.prefixes?.some(t=>a.startsWith(t)))return o},Oe=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),_e=(e,a={})=>{const o=new Set(a.ignoreFamilies),t=new Map;for(const i of Ve)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Ae.has(i.depType)||Oe(i.specifier))continue;const p=Ce(r,i.depName);if(!p||o.has(p.id))continue;const c=n.get(p.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};c?c.push(f):n.set(p.id,[f])}const s=[];for(const[i,p]of n){const c=[...new Set(p.map(m=>m.specifier))];if(c.length<2)continue;const f=t.get(i);f&&s.push({family:i,familyLabel:f.label??i,members:p,specifiers:c})}return s},ze=e=>e.startsWith("@types/"),Be=(e,a={})=>{const o=new Set(a.ignoreDeps),t=new Map,r=s=>{const i=t.get(s);if(i!==void 0)return i;try{const p=S(s).private===!0;return t.set(s,p),p}catch{return t.set(s,!1),!1}},n=[];for(const s of e)s.depType==="dependencies"&&ze(s.depName)&&(o.has(s.depName)||r(s.packageJsonPath)&&n.push({childSpecifier:s.specifier,depName:s.depName,packageDir:s.packageDir,packageJsonPath:s.packageJsonPath,packageName:s.packageName}));return n},Le=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n),p=i.dependencies;if(typeof p!="object"||p===null)continue;const c=p;i.devDependencies??={};const f=i.devDependencies;for(const m of s){const d=c[m.depName];typeof d=="string"&&(m.depName in f||(f[m.depName]=d),Reflect.deleteProperty(c,m.depName))}Object.keys(c).length===0&&Reflect.deleteProperty(i,"dependencies"),R(n,i,{indent:I(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ue=(e,a={})=>{const o=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:o,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ze=(e,a,o,t)=>{const r=a.split(".");let n=e;for(let p=0;p<r.length-1;p+=1){const c=r[p],f=n[c];(typeof f!="object"||f===null)&&(n[c]={}),n=n[c]}const s=r.at(-1);let i=n[s];(typeof i!="object"||i===null)&&(i={},n[s]=i),i[o]=t},Ge=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s)if(p.depType.includes("."))Ze(i,p.depType,p.depName,p.fix);else{const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}R(n,i,{indent:I(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},He=new Set(["dependencies","devDependencies","peerDependencies"]),Ke=e=>e.startsWith("catalog:"),Qe=e=>e.startsWith("workspace:"),Xe=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},Ye=(e,a)=>{if(e.get("default")?.has(a))return"default";const o=[...e.keys()].filter(t=>t!=="default").sort();for(const t of o)if(e.get(t)?.has(a))return t},et=e=>e==="default"?"catalog:":`catalog:${e}`,tt=(e,a)=>{const o=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of o){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const s=L(t.specifier);if(!s){t=r;continue}const i=q(s,n),p=q(n,s);(a==="highest"&&i||a==="lowest"&&p)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},ot=(e,a={})=>{const o=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!He.has(i.depType)||Qe(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),s=new Map;for(const i of n){const p=s.get(i.depName);p?p.push(i):s.set(i.depName,[i])}for(const[i,p]of s){const c=a.pinned?.get(i);if(c!==void 0){for(const g of p)g.specifier!==c&&r.push({canonicalSource:"cli:--pin",depName:i,depType:g.depType,fix:c,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier});continue}if(o==="catalog"){const{catalogs:g}=a;if(!g)continue;const h=Ye(g,i);if(!h)continue;const y=et(h);for(const x of p)Xe(x.specifier)!==h&&r.push({canonicalSource:`catalog:${h}`,depName:i,depType:x.depType,fix:y,packageDir:x.packageDir,packageJsonPath:x.packageJsonPath,packageName:x.packageName,specifier:x.specifier});continue}const f=p.filter(g=>!Ke(g.specifier));if(f.length<2||new Set(f.map(g=>g.specifier)).size<=1)continue;const m=tt(f,o);if(!m)continue;const d=m.canonical.specifier;for(const g of f)g.specifier!==d&&r.push({canonicalSource:m.canonicalSource,depName:i,depType:g.depType,fix:d,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier})}return r},st=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s){const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}R(n,i,{indent:I(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},nt=e=>{if(A(j(e,"pnpm-workspace.yaml")))return!0;const a=j(e,"package.json");if(!A(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},E=(e,a)=>{const o=new Map;for(const t of e){const r=a(t),n=o.get(r);n?n.push(t):o.set(r,[t])}return o},at=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ workspace-protocol: no violations"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[s,i]of E(e,p=>p.packageName??p.packageJsonPath)){const p=$(a,i[0].packageJsonPath);t.info(` ${P(s)} ${u(`(${p})`)}`);for(const c of i){const f=o?T("→"):v("→");t.info(` ${u(c.depType)} ${c.depName}: ${D(c.specifier)} ${f} ${w(c.fix)}`)}}o||t.info(u(" Run with --fix to rewrite specifiers in place."))},rt=(e,a,o)=>{if(e.length===0){o.info(w("✓ redefine-root: no violations"));return}o.info(v(P(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of E(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);o.info(` ${P(t)} ${u(`(${n})`)}`);for(const s of r)o.info(` ${u(s.depType)} ${s.depName}: ${D(s.childSpecifier)} ${u(`(root ${s.rootDepType}: ${s.rootSpecifier})`)}`)}o.info(u(" Remove these from child package.json files — root pin will resolve."))},it=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ workspace-versions: no drift"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[s,i]of E(e,p=>p.depName)){const p=i[0].fix,c=i[0].canonicalSource;t.info(` ${P(s)} ${u(`canonical: ${p} (from ${c})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),d=f.packageName??m,g=o?T("→"):v("→");t.info(` ${d} ${u(`(${m})`)} ${u(f.depType)}: ${D(f.specifier)} ${g} ${w(f.fix)}`)}}o||t.info(u(" Run with --fix to align drifting specifiers."))},pt=(e,a,o)=>{if(e.length===0){o.info(w("✓ banned-deps: no violations"));return}o.info(D(P(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of E(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);o.info(` ${P(t)} ${u(`(${n})`)}`);for(const s of r){const i=s.replacement?` ${u("→")} ${w(s.replacement)}`:"";o.info(` ${u(s.depType)} ${D(s.depName)}${i}`),o.info(` ${u(s.reason)}`)}}},ct=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ catalog-proposals: nothing worth promoting"));return}const r=o?"Added":"Would add",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const s of e)t.info(` ${P(s.depName)}: ${w(s.specifier)} ${u(`(${String(s.instanceCount)} packages agree)`)}`);if(!o){const s=De(a,e);if(s){t.info(""),t.info(u("Proposed pnpm-workspace.yaml changes:"));for(const i of s.split(`
|
|
10
|
+
`))i.startsWith("+")?t.info(w(i)):i.startsWith("-")?t.info(D(i)):t.info(u(i))}t.info(u(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ft=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ custom-types: no engines / packageManager / volta drift"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[s,i]of E(e,p=>`${p.customType} ${p.depName}`)){const p=i[0].fix,c=i[0].canonicalSource;t.info(` ${P(s)} ${u(`canonical: ${p} (from ${c})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),d=f.packageName??m,g=o?T("→"):v("→");t.info(` ${d} ${u(`(${m})`)}: ${D(f.specifier)} ${g} ${w(f.fix)}`)}}o||t.info(u(" Run with --fix to align engines/packageManager/volta versions."))},lt=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ empty-deps: no empty dependency blocks"));return}const r=o?"Removed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[s,i]of E(e,p=>p.packageName??p.packageJsonPath)){const p=$(a,i[0].packageJsonPath);t.info(` ${P(s)} ${u(`(${p})`)}`);for(const c of i)t.info(` ${u(c.depType)}: ${D("{}")}`)}o||t.info(u(" Run with --fix to drop empty blocks."))},gt=(e,a,o,t)=>{if(e.length===0){t.info(w('✓ root-private: root package.json is "private": true'));return}const r=o?"Set":"Missing",n=o?T:D;for(const s of e){const i=$(a,s.packageJsonPath);if(t.info(n(P(`${r} "private": true on root ${u(`(${i})`)}`))),!o){const p=s.rawValue===void 0?"absent":JSON.stringify(s.rawValue);t.info(` ${u("current:")} ${D(p)}`)}}o||t.info(u(' Run with --fix to set "private": true.'))},dt=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ root-package-manager: packageManager field present"));return}const r=o?"Set":"Missing",n=o?T:D;for(const s of e){const i=$(a,s.packageJsonPath);t.info(n(P(`${r} packageManager on root ${u(`(${i})`)}`))),!o&&!s.suggested&&t.info(u(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}o||t.info(u(' e.g. "packageManager": "pnpm@10.32.1"'))},ut=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ root-deps: no runtime dependencies on private root"));return}const r=o?"Moved":"Found",n=o?T:v;for(const s of e){const i=$(a,s.packageJsonPath);t.info(n(P(`${r} ${String(s.depNames.length)} runtime dep${s.depNames.length===1?"":"s"} on private root ${u(`(${i})`)}`)));for(const p of s.depNames)t.info(` ${D(p)}`)}o||t.info(u(" Run with --fix to move them to devDependencies."))},mt=(e,a)=>{if(e.length===0){a.info(w("✓ missing-package-json: every workspace dir has a package.json"));return}a.info(v(P(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const o of e)a.info(` ${D(o.packageDir)}`);a.info(u(" Either delete the directory or scaffold a package.json (vis create)."))},ht=(e,a,o)=>{if(e.length===0){o.info(w("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=a?"Removed":"Found",r=a?T:v;o.info(r(P(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,s]of E(e,i=>i.source)){o.info(` ${P(n)}`);for(const i of s)o.info(` ${D(i.pattern)}`)}a||o.info(u(" Run with --fix to drop dead patterns."))},kt=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=o?"Moved":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[s,i]of E(e,p=>p.packageName??p.packageJsonPath)){const p=$(a,i[0].packageJsonPath);t.info(` ${P(s)} ${u(`(${p})`)}`);for(const c of i)t.info(` ${D(c.depName)} ${u(c.childSpecifier)}`)}o||t.info(u(" Run with --fix to move them to devDependencies."))},yt=(e,a,o)=>{if(e.length===0){o.info(w("✓ similar-deps: every related dep family is in sync"));return}o.info(v(P(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){o.info(` ${P(t.familyLabel)} ${u(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=$(a,r.packageJsonPath),s=r.packageName??n;o.info(` ${s} ${u(`(${n})`)} ${u(r.depType)}: ${D(r.depName)}@${v(r.specifier)}`)}}o.info(u(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},$t=(e,a,o,t,r)=>{let n=!0;const s=i=>{n||r.info(""),n=!1,i()};t.workspaceProtocol&&s(()=>{at(e.workspaceProtocol??[],a,o.workspaceProtocol,r)}),t.redefineRoot&&s(()=>{rt(e.redefineRoot??[],a,r)}),t.workspaceVersions&&s(()=>{it(e.workspaceVersions??[],a,o.workspaceVersions,r)}),t.customTypes&&s(()=>{ft(e.customTypes??[],a,o.customTypes,r)}),e.catalogProposals!==void 0&&s(()=>{ct(e.catalogProposals??[],a,o.catalogProposals,r)}),t.bannedDeps&&s(()=>{pt(e.bannedDeps??[],a,r)}),t.emptyDeps&&s(()=>{lt(e.emptyDeps??[],a,o.emptyDeps,r)}),t.rootPrivate&&s(()=>{gt(e.rootPrivate??[],a,o.rootPrivate,r)}),t.rootPackageManager&&s(()=>{dt(e.rootPackageManager??[],a,o.rootPackageManager,r)}),t.rootDeps&&s(()=>{ut(e.rootDeps??[],a,o.rootDeps,r)}),t.missingPackageJson&&s(()=>{mt(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&s(()=>{ht(e.deadWorkspacePatterns??[],o.deadWorkspacePatterns,r)}),t.typesInDeps&&s(()=>{kt(e.typesInDeps??[],a,o.typesInDeps,r)}),t.similarDeps&&s(()=>{yt(e.similarDeps??[],a,r)})},Pt=(e,a)=>{for(const o of e.workspaceProtocol??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${o.depType} ${o.depName} ${o.specifier} → ${o.fix}
|
|
11
11
|
`)}for(const o of e.redefineRoot??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`redefine-root ${t} ${o.depType} ${o.depName} ${o.childSpecifier}
|
|
12
12
|
`)}for(const o of e.workspaceVersions??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`workspace-versions ${t} ${o.depType} ${o.depName} ${o.specifier} → ${o.fix}
|
|
13
13
|
`)}for(const o of e.customTypes??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`custom-types ${t} ${o.customType} ${o.depName} ${o.specifier} → ${o.fix}
|
|
@@ -22,4 +22,4 @@ import{createRequire as X}from"node:module";import{I as w,j as P,E as u,q as T,s
|
|
|
22
22
|
`);for(const o of e.typesInDeps??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`types-in-deps ${t} ${o.depName} ${o.childSpecifier}
|
|
23
23
|
`)}for(const o of e.similarDeps??[])for(const t of o.members){const r=$(a,t.packageJsonPath);process.stdout.write(`similar-deps ${o.family} ${r} ${t.depType} ${t.depName} ${t.specifier}
|
|
24
24
|
`)}},wt=(e,a,o,t)=>{const r=s=>({...s,packageJsonPath:$(a,s.packageJsonPath)}),n={fixed:o};if(t.workspaceProtocol){const s=(e.workspaceProtocol??[]).map(i=>r(i));n.workspaceProtocol={issues:s,total:s.length}}if(t.redefineRoot){const s=(e.redefineRoot??[]).map(i=>r(i));n.redefineRoot={issues:s,total:s.length}}if(t.workspaceVersions){const s=(e.workspaceVersions??[]).map(i=>r(i));n.workspaceVersions={issues:s,total:s.length}}if(t.customTypes){const s=(e.customTypes??[]).map(i=>r(i));n.customTypes={issues:s,total:s.length}}if(t.bannedDeps){const s=(e.bannedDeps??[]).map(i=>r(i));n.bannedDeps={issues:s,total:s.length}}if(e.catalogProposals!==void 0){const s=e.catalogProposals;n.catalogProposals={proposals:s,total:s.length}}if(t.emptyDeps){const s=(e.emptyDeps??[]).map(i=>r(i));n.emptyDeps={issues:s,total:s.length}}if(t.rootPrivate){const s=(e.rootPrivate??[]).map(i=>r(i));n.rootPrivate={issues:s,total:s.length}}if(t.rootPackageManager){const s=(e.rootPackageManager??[]).map(i=>r(i));n.rootPackageManager={issues:s,total:s.length}}if(t.rootDeps){const s=(e.rootDeps??[]).map(i=>r(i));n.rootDeps={issues:s,total:s.length}}if(t.missingPackageJson){const s=e.missingPackageJson??[];n.missingPackageJson={issues:s,total:s.length}}if(t.deadWorkspacePatterns){const s=e.deadWorkspacePatterns??[];n.deadWorkspacePatterns={issues:s,total:s.length}}if(t.typesInDeps){const s=(e.typesInDeps??[]).map(i=>r(i));n.typesInDeps={issues:s,total:s.length}}if(t.similarDeps){const s=(e.similarDeps??[]).map(i=>({...i,members:i.members.map(p=>({...p,packageJsonPath:$(a,p.packageJsonPath)}))}));n.similarDeps={issues:s,total:s.length}}process.stdout.write(`${JSON.stringify(n,void 0,2)}
|
|
25
|
-
`)},J=(e,a,o)=>{const t=e[a];return typeof t=="boolean"?t:e[o]===!0},Dt=e=>{const a=e,o=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=J(a,"workspaceProtocol","workspace-protocol"),n=J(a,"redefineRoot","redefine-root"),s=J(a,"bannedDeps","banned-deps"),i=J(a,"workspaceVersions","workspace-versions"),p=J(a,"customTypes","custom-types"),c=J(a,"emptyDeps","empty-deps"),f=J(a,"rootPrivate","root-private"),m=J(a,"rootPackageManager","root-package-manager"),d=J(a,"rootDeps","root-deps"),g=J(a,"missingPackageJson","missing-package-json"),h=J(a,"deadWorkspacePatterns","dead-workspace-patterns"),y=J(a,"typesInDeps","types-in-deps"),x=J(a,"similarDeps","similar-deps");return r||n||s||i||p||c||f||m||d||g||h||y||x||o||t?{bannedDeps:s||o,customTypes:p,deadWorkspacePatterns:h,emptyDeps:c,missingPackageJson:g,redefineRoot:n,rootDeps:d,rootPackageManager:m,rootPrivate:f,similarDeps:x,typesInDeps:y,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},vt=e=>{const a=new Map;for(const o of e??[]){const t=o.lastIndexOf("@");if(t<=0||t===o.length-1)throw new Error(`Invalid --pin "${o}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=o.slice(0,t),n=o.slice(t+1);a.set(r,n)}return a},Nt=new Set(["catalog","highest","lowest"]),bt=e=>{if(e===void 0)return"highest";if(!Nt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},W=(e,a)=>e?a===void 0||a===!0:!1,xt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},
|
|
25
|
+
`)},J=(e,a,o)=>{const t=e[a];return typeof t=="boolean"?t:e[o]===!0},Dt=e=>{const a=e,o=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=J(a,"workspaceProtocol","workspace-protocol"),n=J(a,"redefineRoot","redefine-root"),s=J(a,"bannedDeps","banned-deps"),i=J(a,"workspaceVersions","workspace-versions"),p=J(a,"customTypes","custom-types"),c=J(a,"emptyDeps","empty-deps"),f=J(a,"rootPrivate","root-private"),m=J(a,"rootPackageManager","root-package-manager"),d=J(a,"rootDeps","root-deps"),g=J(a,"missingPackageJson","missing-package-json"),h=J(a,"deadWorkspacePatterns","dead-workspace-patterns"),y=J(a,"typesInDeps","types-in-deps"),x=J(a,"similarDeps","similar-deps");return r||n||s||i||p||c||f||m||d||g||h||y||x||o||t?{bannedDeps:s||o,customTypes:p,deadWorkspacePatterns:h,emptyDeps:c,missingPackageJson:g,redefineRoot:n,rootDeps:d,rootPackageManager:m,rootPrivate:f,similarDeps:x,typesInDeps:y,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},vt=e=>{const a=new Map;for(const o of e??[]){const t=o.lastIndexOf("@");if(t<=0||t===o.length-1)throw new Error(`Invalid --pin "${o}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=o.slice(0,t),n=o.slice(t+1);a.set(r,n)}return a},Nt=new Set(["catalog","highest","lowest"]),bt=e=>{if(e===void 0)return"highest";if(!Nt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},W=(e,a)=>e?a===void 0||a===!0:!1,xt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},_=(e,a,o,t)=>{const r=xt[a],n=o==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,s=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${a}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${s}`)},Et=async({logger:e,options:a,visConfig:o,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=a.fix??!1,s=a.format??"human",i=a.quiet??!1;if(!["human","json","minimal"].includes(s))throw new Error(`Invalid --format "${s}". Use: human, json, or minimal.`);const p=Dt(a),c=o?.policy??{},f=o?.editorconfig??!0,m=vt(a.pin),d=a.ban??[];(a.dep!==void 0||a.resolve!==void 0)&&!p.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const g=se(r),h={},y={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},x=nt(r);let N=0;if(p.workspaceProtocol){const l=Ue(g,{fixSpecifier:a.fixSpecifier}),k=W(n,c.workspaceProtocol?.autofix);k&&l.length>0&&(Ge(l,{useEditorconfig:f}),y.workspaceProtocol=!0),h.workspaceProtocol=l,k||(N+=l.length),n&&!k&&l.length>0&&!i&&_(e,"workspace-protocol",c.workspaceProtocol?.autofix,l.length)}if(p.redefineRoot){const l=Se(g,{ignoreDeps:c.redefineRoot?.ignore});h.redefineRoot=l,N+=l.length}if(p.workspaceVersions){const l=bt(a.resolve??c.workspaceVersions?.resolve),k=l==="catalog"?ce(r):void 0;l==="catalog"&&(!k||k.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const b=ot(g,{catalogs:k,dep:a.dep,ignoreDeps:c.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),F=W(n,c.workspaceVersions?.autofix);if(F&&b.length>0&&(st(b,{useEditorconfig:f}),y.workspaceVersions=!0),h.workspaceVersions=b,F||(N+=b.length),n&&!F&&b.length>0&&!i&&_(e,"workspace-versions",c.workspaceVersions?.autofix,b.length),a.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const M=Pe(g,{catalogs:k,ignoreDeps:c.workspaceVersions?.ignore,min:a.proposeMin});F&&M.length>0&&(we(r,M),y.catalogProposals=!0),h.catalogProposals=M}}}if(p.customTypes){const l=c.customTypes?.extraTypes,k=ne(l);if(k.length>0){for(const K of k)e.error(`policy.customTypes.${K}`);process.exitCode=1;return}const b=ae(r,l),F=(a.resolve??c.customTypes?.resolve)==="lowest"?"lowest":"highest",M=re(b,{dep:a.dep,ignoreDeps:c.customTypes?.ignore,resolve:F}),O=W(n,c.customTypes?.autofix);O&&M.length>0&&(ie(M,{useEditorconfig:f}),y.customTypes=!0),h.customTypes=M,O||(N+=M.length),n&&!O&&M.length>0&&!i&&_(e,"custom-types",c.customTypes?.autofix,M.length)}if(p.bannedDeps){const l={...c.bannedDeps};for(const b of d)l[b]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&a.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const k=me(g,l);h.bannedDeps=k,N+=k.length}if(p.emptyDeps){const l=xe(r,{ignoreBlocks:c.emptyDeps?.ignoreBlocks}),k=W(n,c.emptyDeps?.autofix);k&&l.length>0&&(Je(l,{useEditorconfig:f}),y.emptyDeps=!0),h.emptyDeps=l,k||(N+=l.length)}if(p.rootPrivate){const l=Ee(r,x),k=W(n,c.rootPrivate?.autofix);k&&l.length>0&&(Fe(l,{useEditorconfig:f}),y.rootPrivate=!0),h.rootPrivate=l,k||(N+=l.length)}if(p.rootPackageManager){const l=Re(r,x,{suggested:c.rootPackageManager?.suggested}),k=W(n,c.rootPackageManager?.autofix);k&&l.some(b=>b.suggested!==void 0)&&(Ie(l,{useEditorconfig:f}),y.rootPackageManager=!0),h.rootPackageManager=l,(!k||!y.rootPackageManager)&&(N+=l.filter(b=>b.suggested===void 0||!y.rootPackageManager).length)}if(p.rootDeps){const l=Me(r,x),k=W(n,c.rootDeps?.autofix);k&&l.length>0&&(je(l,{useEditorconfig:f}),y.rootDeps=!0),h.rootDeps=l,k||(N+=l.length)}if(p.missingPackageJson){const l=fe(r);h.missingPackageJson=l,N+=l.length}if(p.deadWorkspacePatterns){const l=ve(r),k=W(n,c.deadWorkspacePatterns?.autofix);k&&l.length>0&&(Ne(l,{useEditorconfig:f}),y.deadWorkspacePatterns=!0),h.deadWorkspacePatterns=l,k||(N+=l.length)}if(p.typesInDeps){const l=Be(g,{ignoreDeps:c.typesInDeps?.ignore}),k=W(n,c.typesInDeps?.autofix);k&&l.length>0&&(Le(l,{useEditorconfig:f}),y.typesInDeps=!0),h.typesInDeps=l,k||(N+=l.length)}if(p.similarDeps){const l=_e(g,{extraFamilies:c.similarDeps?.extraFamilies,ignoreFamilies:c.similarDeps?.ignoreFamilies});h.similarDeps=l,N+=l.length}i||(s==="json"?wt(h,r,y,p):s==="minimal"?Pt(h,r):$t(h,r,y,p,e)),N>0&&(process.exitCode=1)};export{Et as default};
|