@visulima/vis 1.0.0-alpha.19 → 1.0.0-alpha.20
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 +164 -0
- package/LICENSE.md +187 -779
- package/README.md +1 -1
- package/dist/config/index.d.ts +535 -121
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/bin.js +380 -286
- package/dist/packem_chunks/config.js +15 -14
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/fix.js +9 -9
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -2
- package/dist/packem_chunks/handler11.js +5 -1
- package/dist/packem_chunks/handler12.js +1 -5
- package/dist/packem_chunks/handler13.js +27 -1
- package/dist/packem_chunks/handler14.js +5 -20
- 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 -5
- package/dist/packem_chunks/handler20.js +5 -2
- package/dist/packem_chunks/handler21.js +2 -18
- package/dist/packem_chunks/handler22.js +2 -1
- package/dist/packem_chunks/handler23.js +18 -1
- package/dist/packem_chunks/handler24.js +1 -5
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +5 -3
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +3 -1
- package/dist/packem_chunks/handler29.js +1 -7
- package/dist/packem_chunks/handler3.js +3 -3
- package/dist/packem_chunks/handler30.js +6 -22
- package/dist/packem_chunks/handler31.js +33 -3
- package/dist/packem_chunks/handler32.js +3 -1
- package/dist/packem_chunks/handler33.js +1 -2
- package/dist/packem_chunks/handler34.js +25 -24
- package/dist/packem_chunks/handler35.js +3 -3
- package/dist/packem_chunks/handler36.js +6 -21
- package/dist/packem_chunks/handler37.js +22 -428
- package/dist/packem_chunks/handler38.js +428 -6
- package/dist/packem_chunks/handler39.js +6 -5
- package/dist/packem_chunks/handler4.js +8 -2
- package/dist/packem_chunks/handler40.js +24 -10
- package/dist/packem_chunks/handler41.js +10 -24
- package/dist/packem_chunks/handler42.js +1 -1
- package/dist/packem_chunks/handler43.js +6 -6
- package/dist/packem_chunks/handler44.js +13 -13
- package/dist/packem_chunks/handler45.js +213 -3
- package/dist/packem_chunks/handler46.js +3 -27
- package/dist/packem_chunks/handler47.js +21 -161
- package/dist/packem_chunks/handler48.js +166 -33
- package/dist/packem_chunks/handler49.js +34 -0
- package/dist/packem_chunks/handler5.js +1 -8
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +2 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +6 -6
- package/dist/packem_chunks/keys-refresh.js +4 -0
- package/dist/packem_chunks/list.js +3 -0
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/prune.js +3 -0
- package/dist/packem_chunks/run.js +1 -0
- package/dist/packem_chunks/status.js +2 -0
- package/dist/packem_chunks/sync.js +2 -0
- package/dist/packem_chunks/sync2.js +2 -0
- package/dist/packem_chunks/tripwire.js +2 -0
- package/dist/packem_shared/advisories-DsynpacV.js +1 -0
- package/dist/packem_shared/{ai-analysis-C_GpXikx.js → ai-analysis-uYuTIIXi.js} +1 -1
- package/dist/packem_shared/{ai-cache-DrCLD4gc.js → ai-cache-DuwHYx2O.js} +1 -1
- package/dist/packem_shared/{ai-fix-CWOz12Om.js → ai-fix-DzrA-dVz.js} +4 -4
- package/dist/packem_shared/applyDefaults-BOVDw1jD.js +1 -0
- package/dist/packem_shared/build-scripts-DsWMSWDs.js +1 -0
- package/dist/packem_shared/{cache-directory-C_U1qsIw.js → cache-directory-DQak1Vjc.js} +1 -1
- package/dist/packem_shared/cyclonedx-CiHXuG8M.js +4 -0
- package/dist/packem_shared/dependency-scan-DC3nAFHS.js +1 -0
- package/dist/packem_shared/{docker-B4s1fjiN.js → docker-B-CIN_nj.js} +19 -19
- package/dist/packem_shared/{failure-log-CSC6KfcO.js → failure-log-C3LEMmkq.js} +1 -1
- package/dist/packem_shared/{flakiness-DUtrm-wS.js → flakiness-Dq6K4ymq.js} +1 -1
- package/dist/packem_shared/glob-MHJQjR39-CQ2GC0b_.js +1 -0
- package/dist/packem_shared/{lifecycle-CgK8pcfa.js → lifecycle-Dv3nAtoD.js} +2 -2
- package/dist/packem_shared/{lockfile-i-qvq_k8.js → lockfile-C5DYMHVq.js} +1 -1
- package/dist/packem_shared/manifests-B0fMp872.js +1 -0
- package/dist/packem_shared/min-release-age-BFozFonQ.js +34 -0
- package/dist/packem_shared/native-config-sync-Dvi1g2nQ.js +21 -0
- package/dist/packem_shared/registry-keys-CewRFW0e.js +1 -0
- package/dist/packem_shared/resolve-explicit-CC4Kifk5.js +5 -0
- package/dist/packem_shared/{run-summary-utils-CJv75pla.js → run-summary-utils-BaBGP3bo.js} +1 -1
- package/dist/packem_shared/{runtime-check-CBU6W8qG.js → runtime-check-BusAwPb2.js} +1 -1
- package/dist/packem_shared/scan-progress-CMynp3eA.js +2 -0
- package/dist/packem_shared/signatures-5ZdjJ2Pu.js +2 -0
- package/dist/packem_shared/{toolchain-B7dckBQ1.js → toolchain-Cc3cwyLP.js} +3 -3
- package/dist/packem_shared/typosquats-BCeR-sLf.js +1 -0
- package/dist/packem_shared/verify-07kUNTuP.js +1 -0
- package/dist/packem_shared/{vis-update-app-D0uL3eO5.js → vis-update-app-CFrlJ3mW.js} +1 -1
- package/index.d.ts +358 -0
- package/index.js +56 -53
- package/package.json +14 -13
- package/schemas/vis-config.schema.json +595 -100
- package/dist/packem_shared/applyDefaults-DLY94gWA.js +0 -1
- package/dist/packem_shared/dependency-scan-YdgNVvoz.js +0 -2
- package/dist/packem_shared/readTomlSync-1fKo0R52-DtxWULlF.js +0 -109
- package/dist/packem_shared/typosquats-B3A38-qx.js +0 -1
- package/dist/packem_shared/verify-WDStBFvK.js +0 -1
|
@@ -1,428 +1,22 @@
|
|
|
1
|
-
var ie=Object.defineProperty;var k=(o,e)=>ie(o,"name",{value:e,configurable:!0});import{createRequire as le}from"node:module";import{aJ as G,E,j as S,q as z,y as ae,m as pe,s as he}from"./bin.js";import{projectGraphToDot as ue}from"@visulima/task-runner";import{render as fe}from"@visulima/tui";import ge,{useSyncExternalStore as me,useState as $,useRef as W,useMemo as P,useCallback as q,useEffect as xe}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{Box as i}from"@visulima/tui/components/box";import{Dialog as be}from"@visulima/tui/components/dialog";import{Text as t}from"@visulima/tui/components/text";import{useApp as ye}from"@visulima/tui/hooks/use-app";import{useInput as we}from"@visulima/tui/hooks/use-input";import{useWindowSize as ve}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Ce}from"@visulima/tui/components/scroll-view";import{ScrollBar as Ae}from"@visulima/tui/components/scroll-bar";const de=le(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=k(o=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[e,l]=N.versions.node.split(".").map(Number);if(e>22||e===22&&l>=3||e===20&&l>=16)return N.getBuiltinModule(o)}return de(o)},"__cjs_getBuiltinModule"),{writeFileSync:ce}=se("node:fs");var Ee=Object.defineProperty,T=k((o,e)=>Ee(o,"name",{value:e,configurable:!0}),"l");const ke={application:0,library:3,service:1,tool:2},_=T(o=>ke[o]??Number.MAX_SAFE_INTEGER,"typeRank"),Me=T(o=>{const e=new Map;for(const[l,d]of Object.entries(o.dependencies))for(const c of d){const s=e.get(c.target)??[];s.push(l),e.set(c.target,s)}return Object.values(o.nodes).map(l=>({deps:o.dependencies[l.name]??[],name:l.name,reverseDeps:e.get(l.name)??[],type:l.type})).sort((l,d)=>l.type!==d.type?_(l.type)-_(d.type):l.name.localeCompare(d.name))},"buildNodes"),Se=T((o,e,l)=>{let d=o;if(e==="app"?d=d.filter(c=>c.type==="application"):e==="lib"&&(d=d.filter(c=>c.type!=="application")),l){const c=l.toLowerCase();d=d.filter(s=>s.name.toLowerCase().includes(c))}return d},"filterNodes");class Te{static{k(this,"GraphStore")}static{T(this,"GraphStore")}#e;#n=new Set;#r;constructor(e){this.#r=e;const l=Me(e);this.#e={allNodes:l,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=T(()=>this.#e,"getSnapshot");subscribe=T(e=>(this.#n.add(e),()=>{this.#n.delete(e)}),"subscribe");getFilteredNodes(){return Se(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(c=>c.type==="application").length,l=this.#e.allNodes.length,d=Object.values(this.#r.dependencies).reduce((c,s)=>c+s.length,0);return{apps:e,deps:d,libs:l-e,total:l}}setSelectedIndex(e){const l=this.getFilteredNodes(),d=l.length===0?-1:Math.max(0,Math.min(e,l.length-1));d!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:d})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#t({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#t(e){this.#e=e;for(const l of this.#n)try{l()}catch{}}}var je=Object.defineProperty,De=k((o,e)=>je(o,"name",{value:e,configurable:!0}),"p");const Ne=De(({focused:o,node:e,scrollRef:l})=>{const d=o?"white":"gray";if(!e)return n(i,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(t,{dimColor:!0,children:"No project selected"})});const c=e.type==="application",s=c?"yellow":"cyan",f=c?"Application":"Library";return n(i,{borderColor:d,borderStyle:"single",borderTopRightTitle:` ${f} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:r(Ce,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"DEPENDS ON"}),r(t,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.deps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"cyan",children:"→"}),n(t,{children:a.target}),a.type!=="static"&&r(t,{dimColor:!0,children:["(",a.type,")"]})]},a.target))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"REQUIRED BY"}),r(t,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No reverse dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"magenta",children:"←"}),n(t,{children:a})]},a))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"INFO"})]}),r(i,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Type:"})}),n(t,{color:s,children:f})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Dependencies:"})}),n(t,{children:String(e.deps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Required by:"})}),n(t,{children:String(e.reverseDeps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Connectivity:"})}),n(t,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var Ie=Object.defineProperty,L=k((o,e)=>Ie(o,"name",{value:e,configurable:!0}),"m");const $e=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],U=L(({isSelected:o,node:e})=>{const l=e.type==="application",d=l?"yellow":"cyan",c=l?"app":"lib";return r(i,{flexShrink:0,height:1,children:[r(t,{children:[o?"▶":" "," "]}),n(i,{flexGrow:1,children:n(t,{bold:o,inverse:o,wrap:"truncate",children:e.name})}),r(t,{color:d,children:[" ",c]}),r(t,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),Y=L(({count:o,label:e})=>r(i,{flexShrink:0,height:1,marginTop:1,children:[r(t,{dimColor:!0,children:["▼"," "]}),n(t,{bold:!0,color:"white",children:e.toUpperCase()}),r(t,{dimColor:!0,children:[" ","(",o,")"]})]}),"TypeHeader"),Pe=L(({filterActive:o,filterText:e,filterType:l,focused:d,nodes:c,scrollOffset:s,selectedIndex:f,stats:a,viewportHeight:y})=>{const m=d?"white":"gray",v=c.filter(w=>w.type==="application"),h=c.filter(w=>w.type!=="application"),g=[];let x=0;if(v.length>0){g.push(n(Y,{count:v.length,label:"Applications"},"hdr-apps"));for(const w of v){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}if(h.length>0){g.push(n(Y,{count:h.length,label:"Libraries"},"hdr-libs"));for(const w of h){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}let C=0;v.length>0&&(C+=2+v.length),h.length>0&&(C+=2+h.length);const M=C>y&&y>0;return r(i,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[r(i,{flexShrink:0,gap:1,paddingX:1,children:[n(t,{bold:!0,inverse:!0,children:" VIS "}),r(t,{wrap:"truncate",children:[a.total," ","packages"]}),r(t,{dimColor:!0,children:["(",a.apps," ","apps,"," ",a.libs," ","libs,"," ",a.deps," ","deps)"]})]}),n(i,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:$e.map(w=>{const A=l===w.key;return r(i,{children:[n(t,{dimColor:!A,children:"["}),n(t,{bold:A,color:A?"cyan":"gray",children:w.shortcut}),n(t,{dimColor:!A,children:"]"}),r(t,{color:A?"white":"gray",children:[" ",w.label]})]},w.key)})}),o&&r(i,{flexShrink:0,paddingX:1,children:[n(t,{bold:!0,color:"white",children:"/ "}),n(t,{children:e}),n(t,{inverse:!0,children:" "})]}),r(i,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(i,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(i,{flexDirection:"column",marginTop:-s,children:g})}),M&&n(i,{flexShrink:0,marginLeft:1,marginRight:1,children:n(Ae,{contentHeight:C,placement:"inset",scrollOffset:s,style:"block",viewportHeight:y})})]})]})},"ProjectListPanel");var Le=Object.defineProperty,Oe=k((o,e)=>Le(o,"name",{value:e,configurable:!0}),"E");const Re=100,Be=40,Fe=10,X={1:"all",2:"app",3:"lib"},He=Oe(({autoExitSeconds:o=0,store:e})=>{const{exit:l}=ye(),{columns:d,rows:c}=ve(),s=me(e.subscribe,e.getSnapshot),[f,a]=$(!1),y=W(null),m=W(null),[v,h]=$(0),[g,x]=$(!1),C=P(()=>e.getFilteredNodes(),[s.allNodes,s.filterType,s.filterText]),M=P(()=>e.getStats(),[s.allNodes]),w=C[s.selectedIndex]??null,A=P(()=>{let u=0,p=0;for(const b of C)b.type==="application"?u+=1:p+=1;return{appsCount:u,libsCount:p}},[C]),O=q(u=>{const{appsCount:p,libsCount:b}=A;if(u<p)return(p>0?2:0)+u;const re=p>0?2+p:0,oe=b>0?2:0;return re+oe+(u-p)},[A]),I=Math.max(1,c-8-(s.filterActive?1:0)),D=q(u=>{const p=O(u);h(b=>p>b+I-2?Math.max(0,p-I+2):p<b+1?Math.max(0,p-1):b)},[O,I]);if(xe(()=>{m.current?.scrollToTop()},[w?.name]),we((u,p)=>{if(u==="c"&&p.ctrl){l();return}if(!g){if(f){p.escape||u==="?"?a(!1):u==="q"?(a(!1),x(!0)):p.downArrow||u==="j"?y.current?.scrollBy(1):(p.upArrow||u==="k")&&y.current?.scrollBy(-1);return}if(u==="?"){a(!0);return}if(u==="q"){x(!0);return}if(p.tab){e.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(X[u]){e.setFilterType(X[u]);return}if(s.filterActive){if(p.escape){e.setFilterActive(!1);return}if(p.return){e.setFilterActive(!1);return}if(p.backspace){e.setFilter(s.filterText.slice(0,-1));return}if(u&&!p.ctrl&&!p.meta){e.setFilter(s.filterText+u);return}return}if(s.focusedPanel==="list"){if(C.length===0){u==="/"&&e.setFilterActive(!0);return}if(p.downArrow||u==="j"){const b=Math.min(s.selectedIndex+1,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.upArrow||u==="k"){const b=Math.max(s.selectedIndex-1,0);e.setSelectedIndex(b),D(b);return}if(p.pageDown){const b=Math.min(s.selectedIndex+10,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.pageUp){const b=Math.max(s.selectedIndex-10,0);e.setSelectedIndex(b),D(b);return}if(p.home){e.setSelectedIndex(0),h(0);return}if(p.end){const b=C.length-1;e.setSelectedIndex(b),D(b);return}if(u==="/"){e.setFilterActive(!0);return}if(p.rightArrow){e.setFocusedPanel("detail");return}return}if(s.focusedPanel==="detail"){if(p.escape||p.leftArrow){e.setFocusedPanel("list");return}if(p.downArrow||u==="j"){m.current?.scrollBy(1);return}if(p.upArrow||u==="k"){m.current?.scrollBy(-1);return}if(p.pageDown){m.current?.scrollBy(10);return}if(p.pageUp){m.current?.scrollBy(-10);return}if(p.home){m.current?.scrollToTop();return}p.end&&m.current?.scrollToBottom()}}},{isActive:!0}),d<Be||c<Fe)return n(i,{alignItems:"center",height:c,justifyContent:"center",width:d,children:r(t,{color:"yellow",children:["Terminal too small (",d,"x",c,")"]})});const te=d>=Re,R=n(i,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(i,{flexWrap:"wrap",gap:2,paddingX:1,children:[r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"q"}),n(t,{dimColor:!0,children:"QUIT"})]},"q"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"?"}),n(t,{dimColor:!0,children:"HELP"})]},"?"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"↑↓"}),n(t,{dimColor:!0,children:"NAV"})]},"nav"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"1-3 /"}),n(t,{dimColor:!0,children:"FILTER"})]},"f"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"Tab"}),n(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),B=r(be,{footer:r(t,{dimColor:!0,children:[n(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n(t,{bold:!0,color:"white",children:"?"}),"/",n(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:f,width:52,children:[r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),n(t,{dimColor:!0,children:" Move up"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),n(t,{dimColor:!0,children:" Move down"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Tab"]}),n(t,{dimColor:!0,children:" Switch panel"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),n(t,{dimColor:!0,children:" Focus detail/list"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),n(t,{dimColor:!0,children:" Jump 10 items"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Home/End"]}),n(t,{dimColor:!0,children:" Jump to start/end"})]})]}),r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"FILTERS"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","1"]}),n(t,{dimColor:!0,children:" All"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","2"]}),n(t,{dimColor:!0,children:" Apps only"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","3"]}),n(t,{dimColor:!0,children:" Libraries only"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","/"]}),n(t,{dimColor:!0,children:" Text filter"})]})]}),r(i,{flexDirection:"column",children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"ACTIONS"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","q"]}),n(t,{dimColor:!0,children:" Quit"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","?"]}),n(t,{dimColor:!0,children:" Toggle help"})]})]})]}),F=n(Pe,{filterActive:s.filterActive,filterText:s.filterText,filterType:s.filterType,focused:s.focusedPanel==="list",nodes:C,scrollOffset:v,selectedIndex:s.selectedIndex,stats:M,viewportHeight:I}),H=n(Ne,{focused:s.focusedPanel==="detail",node:w,scrollRef:m});if(te){const u=Math.floor(d*.35);return r(i,{flexDirection:"column",height:c,width:d,children:[r(i,{flexDirection:"row",flexGrow:1,children:[n(i,{flexGrow:1,children:F}),n(i,{width:u,children:H})]}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})}const ne=Math.floor(c*.55);return r(i,{flexDirection:"column",height:c,width:d,children:[n(i,{height:ne,children:F}),n(i,{flexGrow:1,children:H}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})},"VisGraphApp");var J=Object.freeze,Z=Object.defineProperty,j=k((o,e)=>Z(o,"name",{value:e,configurable:!0}),"x"),Ge=k((o,e)=>J(Z(o,"raw",{value:J(e||o.slice())})),"C");const ee=j((o,e,l,d,c,s,f,a)=>{const y=l?E("└── "):E("├── "),m=c.has(o),v=m?E(" (*)"):"",h=d.get(o),g=h?.type==="application"?S(o):o;if(s.push(`${e}${y}${g}${v}`),m)return;c.add(o);const x=h?.deps??[],C=l?`${e} `:`${e}${E("│")} `;if(a>=f&&x.length>0){s.push(`${C}${E(`... ${x.length} more`)}`);return}for(let M=0;M<x.length;M++){const w=x[M];w&&ee(w.target,C,M===x.length-1,d,c,s,f,a+1)}},"printDepsTree"),V=j((o,e,l,d,c,s)=>{const f=e.get(o),a=f?.type==="application"?S(o):o;d.push(`${s}${a}`),l.add(o);const y=f?.deps??[];if(y.length===0){d.push(`${s} ${E("(no dependencies)")}`);return}if(c<=0){d.push(`${s} ${E(`... ${y.length} dependencies`)}`);return}for(let m=0;m<y.length;m++){const v=y[m];v&&ee(v.target,s,m===y.length-1,e,l,d,c,1)}},"printRootProject"),Q=j((o,e)=>{const l=new Map;for(const[h,g]of Object.entries(o.nodes))l.set(h,{deps:(o.dependencies[h]??[]).map(x=>({target:x.target,type:x.type})),name:h,type:g.type});const d=[],c=[];for(const[h,g]of l)g.type==="application"?d.push(h):c.push(h);d.sort(),c.sort();const s=d.length+c.length,f=Object.values(o.dependencies).reduce((h,g)=>h+g.length,0),a=[S("Project Dependency Graph"),""];if(d.length>0){a.push(` ${S(z(`Applications (${d.length})`))}`,"");for(const h of d)V(h,l,new Set,a,e," "),a.push("")}if(c.length>0){a.push(` ${S(z(`Libraries (${c.length})`))}`,"");for(const h of c)V(h,l,new Set,a,e," "),a.push("")}const y=process.stdout.columns||80;a.push(E("─".repeat(Math.min(y,60)))),a.push(`${S(String(s))} packages ${E("·")} ${S(String(f))} dependencies ${E("·")} ${S(String(d.length))} apps${E(",")} ${S(String(c.length))} libraries`);const m=new Set;let v=!1;for(const h of[...d,...c]){const g=l.get(h)?.deps??[];for(const x of g)m.has(x.target)&&(v=!0),m.add(x.target);m.add(h)}return v&&a.push(E("(*) = already shown above")),a.join(`
|
|
2
|
-
`)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
#tooltip h3 { font-size: 14px; margin-bottom: 6px; }
|
|
24
|
-
#tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
|
|
25
|
-
#tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
|
|
26
|
-
#tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
|
|
27
|
-
#tooltip li { padding: 1px 0; color: #cbd5e1; }
|
|
28
|
-
#tooltip li::before { content: "92 "; color: #64748b; }
|
|
29
|
-
</style>
|
|
30
|
-
</head>
|
|
31
|
-
<body>
|
|
32
|
-
<div id="info">
|
|
33
|
-
<b class="app-count">`,`</b> apps ·
|
|
34
|
-
<b class="lib-count">`,`</b> libraries ·
|
|
35
|
-
<b class="dep-count">`,`</b> dependencies
|
|
36
|
-
</div>
|
|
37
|
-
<div id="legend">
|
|
38
|
-
<span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
|
|
39
|
-
<span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
|
|
40
|
-
<span style="color:#64748b">— solid = static - - - = implicit</span>
|
|
41
|
-
</div>
|
|
42
|
-
<div id="tooltip"></div>
|
|
43
|
-
<svg id="graph">
|
|
44
|
-
<defs>
|
|
45
|
-
<marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
|
|
46
|
-
<path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
|
|
47
|
-
</marker>
|
|
48
|
-
</defs>
|
|
49
|
-
</svg>
|
|
50
|
-
<script>
|
|
51
|
-
const data = `,`;
|
|
52
|
-
const svg = document.getElementById('graph');
|
|
53
|
-
const tooltip = document.getElementById('tooltip');
|
|
54
|
-
const W = window.innerWidth, H = window.innerHeight;
|
|
55
|
-
|
|
56
|
-
// Build adjacency
|
|
57
|
-
const depMap = {}, rdepMap = {};
|
|
58
|
-
data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
|
|
59
|
-
data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
|
|
60
|
-
|
|
61
|
-
// Escape text for safe DOM insertion
|
|
62
|
-
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
|
|
63
|
-
|
|
64
|
-
// Force-directed layout
|
|
65
|
-
const repulsion = 5000 + data.nodes.length * 150;
|
|
66
|
-
const nodes = data.nodes.map(n => ({
|
|
67
|
-
...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
|
|
68
|
-
y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
|
|
69
|
-
}));
|
|
70
|
-
const nodeMap = new Map(nodes.map(n => [n.name, n]));
|
|
71
|
-
const edges = data.edges.map(e => ({
|
|
72
|
-
source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
for (let iter = 0; iter < 400; iter++) {
|
|
76
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
77
|
-
for (let j = i+1; j < nodes.length; j++) {
|
|
78
|
-
let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
|
|
79
|
-
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
80
|
-
let f = repulsion / (d * d);
|
|
81
|
-
nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
|
|
82
|
-
nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
edges.forEach(e => {
|
|
86
|
-
if (!e.source || !e.target) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
90
|
-
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
91
|
-
let f = (d - 180) * 0.008;
|
|
92
|
-
e.source.vx += dx/d * f; e.source.vy += dy/d * f;
|
|
93
|
-
e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
|
|
94
|
-
});
|
|
95
|
-
nodes.forEach(n => {
|
|
96
|
-
n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
|
|
97
|
-
n.x += n.vx * 0.3; n.y += n.vy * 0.3;
|
|
98
|
-
n.vx *= 0.75; n.vy *= 0.75;
|
|
99
|
-
n.x = Math.max(80, Math.min(W-80, n.x));
|
|
100
|
-
n.y = Math.max(40, Math.min(H-40, n.y));
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Measure text widths
|
|
105
|
-
const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
106
|
-
measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
|
|
107
|
-
measure.setAttribute('font-family','system-ui');
|
|
108
|
-
svg.appendChild(measure);
|
|
109
|
-
const widths = {};
|
|
110
|
-
nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
|
|
111
|
-
svg.removeChild(measure);
|
|
112
|
-
|
|
113
|
-
// Render edges
|
|
114
|
-
edges.forEach(e => {
|
|
115
|
-
if (!e.source || !e.target) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const sw = (widths[e.source.name]||80)/2 + 12;
|
|
119
|
-
const tw = (widths[e.target.name]||80)/2 + 12;
|
|
120
|
-
const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
121
|
-
const d = Math.sqrt(dx*dx+dy*dy)||1;
|
|
122
|
-
const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
|
|
123
|
-
const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
|
|
124
|
-
const line = document.createElementNS('http://www.w3.org/2000/svg','line');
|
|
125
|
-
line.setAttribute('x1',x1); line.setAttribute('y1',y1);
|
|
126
|
-
line.setAttribute('x2',x2); line.setAttribute('y2',y2);
|
|
127
|
-
line.setAttribute('class','edge');
|
|
128
|
-
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
129
|
-
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
130
|
-
line.setAttribute('stroke-width', '1.5');
|
|
131
|
-
if (e.type === 'implicit' || e.type === 'peerDependency') {
|
|
132
|
-
line.setAttribute('stroke-dasharray', '6,4');
|
|
133
|
-
}
|
|
134
|
-
if (e.type === 'devDependency') {
|
|
135
|
-
line.setAttribute('stroke-dasharray', '3,3');
|
|
136
|
-
}
|
|
137
|
-
svg.appendChild(line);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Render nodes
|
|
141
|
-
nodes.forEach(n => {
|
|
142
|
-
const w = (widths[n.name]||80) + 24;
|
|
143
|
-
const h = 32;
|
|
144
|
-
const isApp = n.type === 'application';
|
|
145
|
-
const fill = isApp ? '#fbbf24' : '#38bdf8';
|
|
146
|
-
const textFill = '#0f172a';
|
|
147
|
-
const stroke = isApp ? '#f59e0b' : '#0284c7';
|
|
148
|
-
|
|
149
|
-
const g = document.createElementNS('http://www.w3.org/2000/svg','g');
|
|
150
|
-
g.setAttribute('class','node');
|
|
151
|
-
g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
|
|
152
|
-
const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
|
|
153
|
-
rect.setAttribute('width', w); rect.setAttribute('height', h);
|
|
154
|
-
rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
|
|
155
|
-
g.appendChild(rect);
|
|
156
|
-
const text = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
157
|
-
text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
|
|
158
|
-
text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
|
|
159
|
-
text.textContent = n.name;
|
|
160
|
-
g.appendChild(text);
|
|
161
|
-
|
|
162
|
-
g.addEventListener('mouseenter', (ev) => {
|
|
163
|
-
const deps = depMap[n.name] || [];
|
|
164
|
-
const rdeps = rdepMap[n.name] || [];
|
|
165
|
-
|
|
166
|
-
// Build tooltip using safe DOM methods
|
|
167
|
-
tooltip.textContent = '';
|
|
168
|
-
|
|
169
|
-
const heading = document.createElement('h3');
|
|
170
|
-
heading.textContent = n.name;
|
|
171
|
-
const badge = document.createElement('span');
|
|
172
|
-
badge.className = 'type-badge';
|
|
173
|
-
badge.style.background = fill;
|
|
174
|
-
badge.style.color = '#0f172a';
|
|
175
|
-
badge.textContent = n.type;
|
|
176
|
-
heading.appendChild(badge);
|
|
177
|
-
tooltip.appendChild(heading);
|
|
178
|
-
|
|
179
|
-
if (deps.length) {
|
|
180
|
-
const label = document.createElement('div');
|
|
181
|
-
label.className = 'dep-section';
|
|
182
|
-
label.textContent = 'Depends on:';
|
|
183
|
-
tooltip.appendChild(label);
|
|
184
|
-
const ul = document.createElement('ul');
|
|
185
|
-
deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
186
|
-
tooltip.appendChild(ul);
|
|
187
|
-
}
|
|
188
|
-
if (rdeps.length) {
|
|
189
|
-
const label = document.createElement('div');
|
|
190
|
-
label.className = 'dep-section';
|
|
191
|
-
label.textContent = 'Required by:';
|
|
192
|
-
tooltip.appendChild(label);
|
|
193
|
-
const ul = document.createElement('ul');
|
|
194
|
-
rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
195
|
-
tooltip.appendChild(ul);
|
|
196
|
-
}
|
|
197
|
-
if (!deps.length && !rdeps.length) {
|
|
198
|
-
const empty = document.createElement('div');
|
|
199
|
-
empty.style.marginTop = '6px';
|
|
200
|
-
empty.style.color = '#64748b';
|
|
201
|
-
empty.textContent = 'No dependencies';
|
|
202
|
-
tooltip.appendChild(empty);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
tooltip.style.display = 'block';
|
|
206
|
-
const rect = tooltip.getBoundingClientRect();
|
|
207
|
-
tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
|
|
208
|
-
tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
|
|
209
|
-
});
|
|
210
|
-
g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
|
|
211
|
-
svg.appendChild(g);
|
|
212
|
-
});
|
|
213
|
-
<\/script>
|
|
214
|
-
</body>
|
|
215
|
-
</html>`],[`<!DOCTYPE html>
|
|
216
|
-
<html lang="en">
|
|
217
|
-
<head>
|
|
218
|
-
<meta charset="UTF-8">
|
|
219
|
-
<title>Project Dependency Graph</title>
|
|
220
|
-
<style>
|
|
221
|
-
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
222
|
-
body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; overflow: hidden; }
|
|
223
|
-
svg { width: 100vw; height: 100vh; }
|
|
224
|
-
.edge { fill: none; marker-end: url(#arrow); }
|
|
225
|
-
.node rect { rx: 8; ry: 8; cursor: pointer; transition: stroke-width 0.15s; }
|
|
226
|
-
.node text { font-size: 12px; font-weight: 600; pointer-events: none; }
|
|
227
|
-
.node:hover rect { stroke-width: 2.5; stroke: #fff; }
|
|
228
|
-
#info { position: fixed; top: 16px; right: 16px; background: #1e293b; padding: 14px 20px; border-radius: 10px; font-size: 13px; border: 1px solid #334155; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
|
|
229
|
-
#info b { font-variant-numeric: tabular-nums; }
|
|
230
|
-
.app-count { color: #fbbf24; }
|
|
231
|
-
.lib-count { color: #38bdf8; }
|
|
232
|
-
.dep-count { color: #a78bfa; }
|
|
233
|
-
#legend { position: fixed; bottom: 16px; left: 16px; background: #1e293b; padding: 12px 16px; border-radius: 10px; font-size: 12px; border: 1px solid #334155; display: flex; gap: 16px; align-items: center; }
|
|
234
|
-
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; }
|
|
235
|
-
#tooltip { position: fixed; display: none; background: #1e293b; border: 1px solid #475569; border-radius: 8px; padding: 12px 16px; font-size: 12px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 10; pointer-events: none; }
|
|
236
|
-
#tooltip h3 { font-size: 14px; margin-bottom: 6px; }
|
|
237
|
-
#tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
|
|
238
|
-
#tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
|
|
239
|
-
#tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
|
|
240
|
-
#tooltip li { padding: 1px 0; color: #cbd5e1; }
|
|
241
|
-
#tooltip li::before { content: "\\2192 "; color: #64748b; }
|
|
242
|
-
</style>
|
|
243
|
-
</head>
|
|
244
|
-
<body>
|
|
245
|
-
<div id="info">
|
|
246
|
-
<b class="app-count">`,`</b> apps ·
|
|
247
|
-
<b class="lib-count">`,`</b> libraries ·
|
|
248
|
-
<b class="dep-count">`,`</b> dependencies
|
|
249
|
-
</div>
|
|
250
|
-
<div id="legend">
|
|
251
|
-
<span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
|
|
252
|
-
<span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
|
|
253
|
-
<span style="color:#64748b">— solid = static - - - = implicit</span>
|
|
254
|
-
</div>
|
|
255
|
-
<div id="tooltip"></div>
|
|
256
|
-
<svg id="graph">
|
|
257
|
-
<defs>
|
|
258
|
-
<marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
|
|
259
|
-
<path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
|
|
260
|
-
</marker>
|
|
261
|
-
</defs>
|
|
262
|
-
</svg>
|
|
263
|
-
<script>
|
|
264
|
-
const data = `,`;
|
|
265
|
-
const svg = document.getElementById('graph');
|
|
266
|
-
const tooltip = document.getElementById('tooltip');
|
|
267
|
-
const W = window.innerWidth, H = window.innerHeight;
|
|
268
|
-
|
|
269
|
-
// Build adjacency
|
|
270
|
-
const depMap = {}, rdepMap = {};
|
|
271
|
-
data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
|
|
272
|
-
data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
|
|
273
|
-
|
|
274
|
-
// Escape text for safe DOM insertion
|
|
275
|
-
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
|
|
276
|
-
|
|
277
|
-
// Force-directed layout
|
|
278
|
-
const repulsion = 5000 + data.nodes.length * 150;
|
|
279
|
-
const nodes = data.nodes.map(n => ({
|
|
280
|
-
...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
|
|
281
|
-
y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
|
|
282
|
-
}));
|
|
283
|
-
const nodeMap = new Map(nodes.map(n => [n.name, n]));
|
|
284
|
-
const edges = data.edges.map(e => ({
|
|
285
|
-
source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
|
|
286
|
-
}));
|
|
287
|
-
|
|
288
|
-
for (let iter = 0; iter < 400; iter++) {
|
|
289
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
290
|
-
for (let j = i+1; j < nodes.length; j++) {
|
|
291
|
-
let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
|
|
292
|
-
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
293
|
-
let f = repulsion / (d * d);
|
|
294
|
-
nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
|
|
295
|
-
nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
edges.forEach(e => {
|
|
299
|
-
if (!e.source || !e.target) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
303
|
-
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
304
|
-
let f = (d - 180) * 0.008;
|
|
305
|
-
e.source.vx += dx/d * f; e.source.vy += dy/d * f;
|
|
306
|
-
e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
|
|
307
|
-
});
|
|
308
|
-
nodes.forEach(n => {
|
|
309
|
-
n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
|
|
310
|
-
n.x += n.vx * 0.3; n.y += n.vy * 0.3;
|
|
311
|
-
n.vx *= 0.75; n.vy *= 0.75;
|
|
312
|
-
n.x = Math.max(80, Math.min(W-80, n.x));
|
|
313
|
-
n.y = Math.max(40, Math.min(H-40, n.y));
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// Measure text widths
|
|
318
|
-
const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
319
|
-
measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
|
|
320
|
-
measure.setAttribute('font-family','system-ui');
|
|
321
|
-
svg.appendChild(measure);
|
|
322
|
-
const widths = {};
|
|
323
|
-
nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
|
|
324
|
-
svg.removeChild(measure);
|
|
325
|
-
|
|
326
|
-
// Render edges
|
|
327
|
-
edges.forEach(e => {
|
|
328
|
-
if (!e.source || !e.target) {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
const sw = (widths[e.source.name]||80)/2 + 12;
|
|
332
|
-
const tw = (widths[e.target.name]||80)/2 + 12;
|
|
333
|
-
const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
334
|
-
const d = Math.sqrt(dx*dx+dy*dy)||1;
|
|
335
|
-
const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
|
|
336
|
-
const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
|
|
337
|
-
const line = document.createElementNS('http://www.w3.org/2000/svg','line');
|
|
338
|
-
line.setAttribute('x1',x1); line.setAttribute('y1',y1);
|
|
339
|
-
line.setAttribute('x2',x2); line.setAttribute('y2',y2);
|
|
340
|
-
line.setAttribute('class','edge');
|
|
341
|
-
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
342
|
-
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
343
|
-
line.setAttribute('stroke-width', '1.5');
|
|
344
|
-
if (e.type === 'implicit' || e.type === 'peerDependency') {
|
|
345
|
-
line.setAttribute('stroke-dasharray', '6,4');
|
|
346
|
-
}
|
|
347
|
-
if (e.type === 'devDependency') {
|
|
348
|
-
line.setAttribute('stroke-dasharray', '3,3');
|
|
349
|
-
}
|
|
350
|
-
svg.appendChild(line);
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// Render nodes
|
|
354
|
-
nodes.forEach(n => {
|
|
355
|
-
const w = (widths[n.name]||80) + 24;
|
|
356
|
-
const h = 32;
|
|
357
|
-
const isApp = n.type === 'application';
|
|
358
|
-
const fill = isApp ? '#fbbf24' : '#38bdf8';
|
|
359
|
-
const textFill = '#0f172a';
|
|
360
|
-
const stroke = isApp ? '#f59e0b' : '#0284c7';
|
|
361
|
-
|
|
362
|
-
const g = document.createElementNS('http://www.w3.org/2000/svg','g');
|
|
363
|
-
g.setAttribute('class','node');
|
|
364
|
-
g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
|
|
365
|
-
const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
|
|
366
|
-
rect.setAttribute('width', w); rect.setAttribute('height', h);
|
|
367
|
-
rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
|
|
368
|
-
g.appendChild(rect);
|
|
369
|
-
const text = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
370
|
-
text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
|
|
371
|
-
text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
|
|
372
|
-
text.textContent = n.name;
|
|
373
|
-
g.appendChild(text);
|
|
374
|
-
|
|
375
|
-
g.addEventListener('mouseenter', (ev) => {
|
|
376
|
-
const deps = depMap[n.name] || [];
|
|
377
|
-
const rdeps = rdepMap[n.name] || [];
|
|
378
|
-
|
|
379
|
-
// Build tooltip using safe DOM methods
|
|
380
|
-
tooltip.textContent = '';
|
|
381
|
-
|
|
382
|
-
const heading = document.createElement('h3');
|
|
383
|
-
heading.textContent = n.name;
|
|
384
|
-
const badge = document.createElement('span');
|
|
385
|
-
badge.className = 'type-badge';
|
|
386
|
-
badge.style.background = fill;
|
|
387
|
-
badge.style.color = '#0f172a';
|
|
388
|
-
badge.textContent = n.type;
|
|
389
|
-
heading.appendChild(badge);
|
|
390
|
-
tooltip.appendChild(heading);
|
|
391
|
-
|
|
392
|
-
if (deps.length) {
|
|
393
|
-
const label = document.createElement('div');
|
|
394
|
-
label.className = 'dep-section';
|
|
395
|
-
label.textContent = 'Depends on:';
|
|
396
|
-
tooltip.appendChild(label);
|
|
397
|
-
const ul = document.createElement('ul');
|
|
398
|
-
deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
399
|
-
tooltip.appendChild(ul);
|
|
400
|
-
}
|
|
401
|
-
if (rdeps.length) {
|
|
402
|
-
const label = document.createElement('div');
|
|
403
|
-
label.className = 'dep-section';
|
|
404
|
-
label.textContent = 'Required by:';
|
|
405
|
-
tooltip.appendChild(label);
|
|
406
|
-
const ul = document.createElement('ul');
|
|
407
|
-
rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
408
|
-
tooltip.appendChild(ul);
|
|
409
|
-
}
|
|
410
|
-
if (!deps.length && !rdeps.length) {
|
|
411
|
-
const empty = document.createElement('div');
|
|
412
|
-
empty.style.marginTop = '6px';
|
|
413
|
-
empty.style.color = '#64748b';
|
|
414
|
-
empty.textContent = 'No dependencies';
|
|
415
|
-
tooltip.appendChild(empty);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
tooltip.style.display = 'block';
|
|
419
|
-
const rect = tooltip.getBoundingClientRect();
|
|
420
|
-
tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
|
|
421
|
-
tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
|
|
422
|
-
});
|
|
423
|
-
g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
|
|
424
|
-
svg.appendChild(g);
|
|
425
|
-
});
|
|
426
|
-
<\/script>
|
|
427
|
-
</body>
|
|
428
|
-
</html>`])),s.apps,s.libs,s.edges.length,JSON.stringify(s).replaceAll("</",String.raw`<\/`))},"projectGraphToHtml"),it=j(async({logger:o,options:e,visConfig:l,workspaceRoot:d})=>{if(!d)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const c=d,{packageJsons:s,workspace:f}=ae(c,l),a=pe(c,f,s),y=!!process.stdout.isTTY&&!he,m=e.format??(y?"tui":"ascii"),v=e.output,h=e.depth??1/0;let g;switch(m){case"dot":{g=ue(a);break}case"html":{g=We(a);break}case"json":{g=JSON.stringify(ze(a),void 0,2);break}case"tui":{if(!y){g=Q(a,h);break}const x=l?.tui?.autoExit===!0?3:typeof l?.tui?.autoExit=="number"?l.tui.autoExit:0;process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const C=setInterval(()=>{},1e3),M=new Te(a);await fe(ge.createElement(He,{autoExitSeconds:x,store:M}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(C);return}default:g=Q(a,h)}v?(ce(v,g,"utf8"),o.info(`Graph written to ${v}`)):o.info(g)},"execute");export{it as default};
|
|
1
|
+
var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{ay as Y,E as f,j as b,q as T,p as l}from"./bin.js";import{i as _,M as N,g as Q,O as L,z as X,f as fe,b as Z,B as pe,C as ue}from"./config.js";import{f as we}from"../packem_shared/giget-CcEy_Elm.js";const le=ce(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=j(t=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,r]=x.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return x.getBuiltinModule(t)}return le(t)},"__cjs_getBuiltinModule"),{fileURLToPath:de}=P("node:url"),{createInterface:me}=P("node:readline"),{mkdtempSync:he,rmSync:ge}=P("node:fs"),{tmpdir:$e}=P("node:os"),{spawnSync:ye}=P("node:child_process");var ve=Object.defineProperty,y=j((t,e)=>ve(t,"name",{value:e,configurable:!0}),"i");const ee=[".ts",".mts",".cts",".js",".mjs",".cjs"],be="template.yml",Te=[".d",".test",".spec",".config",".bench",".stories"],Se=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],te=y(t=>{for(const e of ee)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),Oe=y(t=>{if(Se.some(r=>t.endsWith(r))||!ee.some(r=>t.endsWith(r)))return!1;const e=te(t);return!Te.some(r=>e.endsWith(r))},"isNativeFile"),J=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!Oe(s.name))continue;const n=te(s.name);r.push({load:y(()=>Ne(s.path),"load"),name:n,path:s.path,source:e})}return r},"scanNativeDirectory"),q=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=N(s.path,be);_(n)&&r.push({load:y(()=>Re(s.path,s.name),"load"),name:s.name,path:s.path,source:e})}return r},"scanMoonDirectory"),je=y(()=>{try{const t=de(import.meta.url),e=N(Q(t),"..","..","templates");return _(e)?e:void 0}catch{return}},"resolveBuiltinTemplatesDirectory"),I=y(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...J(N(s,".vis","templates"),"native"),...q(N(s,".vis","templates"),"moon"),...q(N(s,".moon","templates"),"moon")];for(const o of e)n.push(...q(o,"config")),n.push(...J(o,"config"));const i=je();i&&n.push(...q(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},"discoverTemplates"),Ne=y(async t=>{const{loadNativeTemplate:e}=await import("./loader.js");return e(t)},"loadNativeFromPath"),Re=y(async(t,e)=>{const{loadMoonTemplate:r}=await import("./index.js");return r(t,e)},"loadMoonFromPath");var Ee=Object.defineProperty,v=j((t,e)=>Ee(t,"name",{value:e,configurable:!0}),"c");const M=v((t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),"ask"),ke=v(async(t,e,r)=>{const s=await M(t,` ${e} ${f(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),xe=v(async(t,e,r,s)=>{process.stderr.write(` ${e}
|
|
2
|
+
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=i===s?f(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
3
|
+
`)}for(;;){const n=await M(t,`
|
|
4
|
+
${f(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${f("Invalid choice. Try again.")}
|
|
5
|
+
`)}},"selectOne"),_e=v(async(t,e,r,s)=>{process.stderr.write(` ${e} ${f("(comma-separated numbers)")}
|
|
6
|
+
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=s.includes(i)?f(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
7
|
+
`)}for(;;){const n=await M(t,`
|
|
8
|
+
${f("Enter choices:")} `);if(n===""&&s.length>0)return s;const i=n.split(",").map(a=>Number.parseInt(a.trim(),10)).filter(a=>Number.isInteger(a)&&a>=1&&a<=r.length);if(i.length>0)return i.map(a=>r[a-1]);process.stderr.write(` ${f("Invalid choice. Try again.")}
|
|
9
|
+
`)}},"selectMany"),Pe=v(t=>` ${f(`${t}:`)} `,"promptText"),De=v((t,e)=>e.prompt??t,"variableLabel"),We=v(t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),"sortVariables"),H=v((t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},"parseValue"),F=v((t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const n of s)if(typeof n!="string"||!e.values.includes(n))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(n)}")`)}},"validateValue"),Be=v(async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?me({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of We(n)){if(Object.hasOwn(s,o)){const $=H(c,s[o]??"");F(o,c,$),i[o]=$;continue}if(e||!r||c.internal){if(c.default!==void 0){F(o,c,c.default),i[o]=c.default;continue}if(c.required)throw new Error(`Required variable "${o}" not provided. Pass --${o}=<value> or remove --defaults.`);continue}const g=De(o,c);let m;if(c.type==="boolean")m=await ke(a,g,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const $=Array.isArray(c.default)?c.default:[];m=await _e(a,g,c.values,$)}else{const $=typeof c.default=="string"?c.default:void 0;m=await xe(a,g,c.values,$)}else{const $=c.default===void 0?"":` (${String(c.default)})`,S=await M(a,Pe(`${g}${$}`));if(S===""&&c.default!==void 0)m=c.default;else if(S===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else m=H(c,S)}F(o,c,m),i[o]=m}return i}finally{a?.close()}},"collectOptions");var qe=Object.defineProperty,V=j((t,e)=>qe(t,"name",{value:e,configurable:!0}),"o");const Ie=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],Me=V(t=>Ie.some(e=>t.startsWith(e)),"isRemoteSource"),Ce=V(async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??he(N($e(),"vis-generate-")),n=V(()=>{if(r)try{ge(s,{force:!0,recursive:!0})}catch{}},"cleanup");l.info(`Downloading ${t}…`);try{const i=await we(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:n,directory:i.dir}}catch(i){n();const a=i instanceof Error?i.message:String(i);throw l.warn(`Failed to download template: ${a}`),i}},"fetchRemoteTemplate");var Ae=Object.defineProperty,R=j((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"a");const re=R((t,e="")=>{const r=[];for(const[s,n]of Object.entries(t)){const i=e?`${e}/${s}`:s;typeof n=="string"||Buffer.isBuffer(n)?r.push({content:n,path:i}):n&&typeof n=="object"&&r.push(...re(n,i))}return r},"flattenTree"),Fe=R(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),Le=R((t,e)=>{if(L(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=N(t,e),s=X(t,r);if(s===".."||s.startsWith(`..${fe}`)||L(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),Ve=R((t,e)=>{Z(Q(t)),pe(t,e)},"writeOne"),ze=R((t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,n=typeof t=="string"?r:t.silent??r;for(const i of s){n||l.info(`$ ${i}`);const a=ye(i,{cwd:e,shell:!0,stdio:n?"ignore":"inherit"});if(a.status!==0)return l.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},"runScript"),Ke=R(t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,n=e.get(s);n?n.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},"groupByPhase"),Ue=R(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:X(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?re(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=Le(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${b(T("Plan"))} ${f("(dry-run, no files written)")}`);for(const o of a){const c=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${f("write")} ${o.file.path} ${f(`(${Fe(c)})`)}
|
|
10
|
+
`)}}else{Z(e.destination);let o=0,c=0;for(const g of a){const{file:m,meta:$,target:S}=g,C=_(S),O=e.force||$.force===!0;if(C&&!O){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ve(S,m.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=Ke(s.scripts);l.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,c]of o)if((await Promise.all(c.map(g=>Promise.resolve(ze(g,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
|
|
11
|
+
`),l.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${f("•")} ${o}
|
|
12
|
+
`)}},"runTemplate");var Ge=Object.defineProperty,w=j((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"u");const Je=w(async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},"toListEntry"),He=w((t,e)=>{const r={default:e.default,name:t,order:e.order,prompt:e.prompt,required:e.required,type:e.type};return e.type==="enum"&&(r.multiple=e.multiple,r.values=e.values),r},"summarizeVariable"),Ye=w(async t=>{const e=await t.load(),r=Object.entries(e.options??{}).sort(([s,n],[i,a])=>{const o=n.order??0,c=a.order??0;return o===c?s.localeCompare(i):o-c}).map(([s,n])=>He(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},"describeTemplate"),Qe=w(t=>{if(t.length===0){l.info("No templates found."),l.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}l.info("Available templates:");for(const e of t){const r=f(`(${e.source})`);process.stderr.write(` ${b(T(e.name))} ${r}
|
|
13
|
+
`)}},"printList"),Xe=w(t=>{const e={},r=[];for(const s of t){if(!s.startsWith("--")){r.push(s);continue}const n=s.indexOf("=");if(n===-1){const o=s.slice(2);o.startsWith("no-")?e[o.slice(3)]="false":e[o]="true";continue}const i=s.slice(2,n),a=s.slice(n+1);e[i]=a}return{overrides:e,remaining:r}},"parsePassthroughOverrides"),Ze=w(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${b(T("vis generate"))} ${f("— pick a template")}
|
|
14
|
+
|
|
15
|
+
`);for(const[s,n]of t.entries()){const i=b(T(` ${String(s+1)}.`));process.stderr.write(`${i} ${n.name} ${f(`(${n.source})`)}
|
|
16
|
+
`)}return new Promise((s,n)=>{r.question(`
|
|
17
|
+
${f(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?s(t[a-1].name):n(new Error("Invalid choice."))})})}finally{r.close()}},"pickInteractive"),nt=w(async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:n})=>{const i=e.cwd||n||process.cwd(),a=n??i,o=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const u=I({extraDirectories:o?.templates??[],onWarning:w(p=>{l.warn(p)},"onWarning"),workspaceRoot:a});if(e.json){const p=await Promise.all(u.map(d=>Je(d)));process.stdout.write(`${JSON.stringify(p,null,2)}
|
|
18
|
+
`);return}Qe(u);return}if(e.describe){const u=c[0];if(!u)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const p=I({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a}).find(h=>h.name===u);if(!p)throw new Error(`Template "${u}" not found. Run \`vis generate --list\` to see available templates.`);const d=await Ye(p);if(e.json){process.stdout.write(`${JSON.stringify(d,null,2)}
|
|
19
|
+
`);return}if(l.info(`Template: ${b(T(d.name))} ${f(`(${d.source})`)}`),d.description&&l.info(d.description),d.destination&&l.info(`Destination: ${f(d.destination)}`),d.variables.length===0)l.info("No variables.");else{l.info("Variables:");for(const h of d.variables){const B=[h.type];h.required&&B.push("required"),h.default!==void 0&&B.push(`default=${JSON.stringify(h.default)}`),h.values&&B.push(`values=${h.values.join("|")}`),process.stderr.write(` ${b(T(h.name))} ${f(`(${B.join(", ")})`)}
|
|
20
|
+
`)}}return}let g=[...r??[]];if(g.length===0){const u=process.argv.slice(2),p=u.indexOf("--");p!==-1&&(g=u.slice(p+1))}const m=c.indexOf("--"),$=m===-1?[]:c.slice(m+1),S=m===-1?c:c.slice(0,m),{overrides:C}=Xe([...$,...g]);let O,D,W;const k=S[0];let A;if(k&&Me(k)){const u=await Ce(k,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});A=u.cleanup;try{const p=I({extraDirectories:[u.directory],workspaceRoot:a}).find(d=>d.path.startsWith(u.directory));if(!p)throw new Error(`Downloaded template at ${u.directory} contains no template.yml or *.ts entrypoint.`);O=await p.load(),D=p.name,W=O.destination}catch(p){throw A(),p}}else{const u=I({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a});if(u.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let p;if(k)p=k;else{if(e.interactive===!1||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");p=await Ze(u)}const d=u.find(h=>h.name===p);if(!d)throw new Error(`Template "${p}" not found. Run 'vis generate --list' to see available templates.`);O=await d.load(),D=d.name,W=O.destination}const z=e.to,K=!!e.dryRun,se=!!e.force,U=!!e.defaults,oe=!!e.skipScripts,ne=e.interactive!==!1&&!!process.stdin.isTTY&&!U;let E;z?E=z:W?E=W:E=".";const G=L(E)?E:ue(i,E);l.info(`Template: ${b(T(D))}`),l.info(`Target: ${f(G)}`),process.stderr.write(`
|
|
21
|
+
`);const ie=await Be({defaults:U,interactive:ne,overrides:C,variables:O.options??{}});try{await Ue(O,{cwd:i,destination:G,dryRun:K,force:se,options:ie,skipScripts:oe,workspaceRoot:a}),K||(process.stderr.write(`
|
|
22
|
+
`),l.success(`Template '${D}' applied.`))}finally{A?.()}},"execute");export{nt as default};
|