@visulima/vis 1.0.0-alpha.3 → 1.0.0-alpha.5
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 +151 -24
- package/LICENSE.md +27 -0
- package/README.md +15 -9
- package/dist/audit-config.d.ts +24 -0
- package/dist/bin.js +784 -70
- package/dist/catalog.d.ts +37 -11
- package/dist/commands/add.d.ts +3 -0
- package/dist/commands/approve-builds.d.ts +3 -0
- package/dist/commands/audit.d.ts +23 -0
- package/dist/commands/clean.d.ts +3 -0
- package/dist/commands/create/discovery.d.ts +42 -0
- package/dist/commands/create/index.d.ts +13 -0
- package/dist/commands/create/prompts.d.ts +31 -0
- package/dist/commands/create/random-name.d.ts +15 -0
- package/dist/commands/create/templates/builtin.d.ts +15 -0
- package/dist/commands/create/templates/generator.d.ts +14 -0
- package/dist/commands/create/templates/index.d.ts +13 -0
- package/dist/commands/create/templates/monorepo.d.ts +16 -0
- package/dist/commands/create/templates/remote.d.ts +41 -0
- package/dist/commands/create/templates/types.d.ts +46 -0
- package/dist/commands/create/utils.d.ts +42 -0
- package/dist/commands/dedupe.d.ts +3 -0
- package/dist/commands/devcontainer.d.ts +3 -0
- package/dist/commands/dlx.d.ts +3 -0
- package/dist/commands/doctor.d.ts +15 -0
- package/dist/commands/exec.d.ts +3 -0
- package/dist/commands/implode.d.ts +3 -0
- package/dist/commands/init.d.ts +14 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/link.d.ts +3 -0
- package/dist/commands/optimize.d.ts +38 -0
- package/dist/commands/pm.d.ts +3 -0
- package/dist/commands/remove.d.ts +3 -0
- package/dist/commands/sort-package-json.d.ts +3 -0
- package/dist/commands/unlink.d.ts +3 -0
- package/dist/commands/upgrade.d.ts +3 -0
- package/dist/commands/why.d.ts +3 -0
- package/dist/config.d.ts +38 -11
- package/dist/config.js +1 -1
- package/dist/native-binding.d.ts +151 -0
- package/dist/output.d.ts +40 -0
- package/dist/overrides.d.ts +82 -0
- package/dist/plugins/config-loader.d.ts +3 -0
- package/dist/plugins/post-command.d.ts +3 -0
- package/dist/plugins/security-enforcement.d.ts +3 -0
- package/dist/pm-runner.d.ts +23 -0
- package/dist/security.d.ts +64 -0
- package/dist/socket-security.d.ts +129 -0
- package/dist/tips.d.ts +41 -0
- package/dist/tui/components/CheckProgressApp.d.ts +6 -0
- package/dist/tui/components/CommandSummary.d.ts +17 -0
- package/dist/tui/components/Header.d.ts +13 -0
- package/dist/tui/components/OutputPanel.d.ts +16 -0
- package/dist/tui/components/QuitDialog.d.ts +15 -0
- package/dist/tui/components/TaskListPanel.d.ts +19 -0
- package/dist/tui/components/TaskRow.d.ts +12 -0
- package/dist/tui/components/TaskStore.d.ts +80 -0
- package/dist/tui/components/VisTaskRunnerApp.d.ts +17 -0
- package/dist/tui/components/devcontainer/DevcontainerStore.d.ts +66 -0
- package/dist/tui/components/devcontainer/VisDevcontainerApp.d.ts +9 -0
- package/dist/tui/components/devcontainer/catalogs/extensions.d.ts +8 -0
- package/dist/tui/components/devcontainer/catalogs/features.d.ts +8 -0
- package/dist/tui/components/devcontainer/catalogs/filters.d.ts +4 -0
- package/dist/tui/components/devcontainer/catalogs/mount-suggestions.d.ts +19 -0
- package/dist/tui/components/devcontainer/catalogs/templates.d.ts +8 -0
- package/dist/tui/components/devcontainer/devcontainer-io.d.ts +14 -0
- package/dist/tui/components/devcontainer/sections/DockerComposeSection.d.ts +11 -0
- package/dist/tui/components/devcontainer/sections/EnvironmentSection.d.ts +16 -0
- package/dist/tui/components/devcontainer/sections/ExtensionsSection.d.ts +11 -0
- package/dist/tui/components/devcontainer/sections/FeaturesSection.d.ts +11 -0
- package/dist/tui/components/devcontainer/sections/GeneralSection.d.ts +12 -0
- package/dist/tui/components/devcontainer/sections/LifecycleSection.d.ts +13 -0
- package/dist/tui/components/devcontainer/sections/MountsSection.d.ts +16 -0
- package/dist/tui/components/devcontainer/sections/PortsSection.d.ts +10 -0
- package/dist/tui/components/devcontainer/sections/PreviewPanel.d.ts +11 -0
- package/dist/tui/components/devcontainer/types.d.ts +53 -0
- package/dist/tui/components/devcontainer/validate.d.ts +16 -0
- package/dist/tui/components/graph/GraphStore.d.ts +42 -0
- package/dist/tui/components/graph/ProjectDetailPanel.d.ts +10 -0
- package/dist/tui/components/graph/ProjectListPanel.d.ts +20 -0
- package/dist/tui/components/graph/VisGraphApp.d.ts +8 -0
- package/dist/tui/components/optimize/OptimizeDetailPanel.d.ts +9 -0
- package/dist/tui/components/optimize/OptimizeListPanel.d.ts +16 -0
- package/dist/tui/components/optimize/OptimizeStore.d.ts +50 -0
- package/dist/tui/components/optimize/VisOptimizeApp.d.ts +8 -0
- package/dist/tui/components/optimize/constants.d.ts +7 -0
- package/dist/tui/components/update/PackageDetailPanel.d.ts +12 -0
- package/dist/tui/components/update/PackageListPanel.d.ts +21 -0
- package/dist/tui/components/update/UpdateStore.d.ts +62 -0
- package/dist/tui/components/update/VisUpdateApp.d.ts +18 -0
- package/dist/tui/dynamic-life-cycle.d.ts +21 -0
- package/dist/tui/formatting-utils.d.ts +17 -0
- package/dist/tui/pretty-time.d.ts +8 -0
- package/dist/tui/static-life-cycle.d.ts +22 -0
- package/dist/tui/status-utils.d.ts +20 -0
- package/dist/tui/symbols.d.ts +7 -0
- package/dist/tui/types.d.ts +11 -0
- package/dist/typosquats.d.ts +70 -0
- package/dist/upgrade-check.d.ts +30 -0
- package/dist/utils.d.ts +22 -0
- package/dist/workspace.d.ts +302 -5
- package/index.js +600 -0
- package/package.json +34 -11
package/dist/bin.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var La=Object.defineProperty;var $=(t,e)=>La(t,"name",{value:e,configurable:!0});import{createRequire as Fa}from"node:module";import{createCerebro as Ua}from"@visulima/cerebro";import Ga from"@visulima/cerebro/compile-cache";import{applyHeapTuning as za}from"@visulima/cerebro/heap-tuning";import{errorHandlerPlugin as Wa}from"@visulima/cerebro/plugins/error-handler";import{isAccessibleSync as le,readFileSync as Xe,walkSync as Mn,readJsonSync as Ue,ensureDirSync as xn,writeJsonSync as Bn,writeFileSync as dr,removeSync as _a}from"@visulima/fs";import{findPackageManagerSync as Jr,getPackageManagerVersion as Ha,findMonorepoRootSync as Ti}from"@visulima/package";import{join as T,resolve as Ft,dirname as Ln}from"@visulima/path";import{red as ct,yellow as Ie,dim as Be,green as Ai,cyan as $t,magenta as Ii,bold as bo}from"@visulima/colorize";import{coerce as qr,rcompare as Ja,parse as qa}from"semver";import{hyperlink as Ka}from"@visulima/ansi";import{getAffectedProjects as oc,projectGraphToDot as ic,TerminalBuffer as Ni,runConcurrently as Di,enforceProjectConstraints as sc,parsePartition as ac,TaskScheduler as cc,createTaskGraph as lc,defaultTaskRunner as $o,generateRunSummary as dc,writeRunSummary as uc}from"@visulima/task-runner";import"lint-staged";import{runProvider as Mi,PROVIDER_NAMES as pc,detectProvider as fc,detectAvailableProviders as gc,detectAllProviders as hc}from"@visulima/find-ai-runner";import{renderToString as ge,Box as g,Text as a,Table as Vn,useWindowSize as Ut,Spinner as Bi,useApp as Gt,useInput as De,Dialog as xt,ScrollView as zt,Tabs as Li,Tab as Fi,ScrollBar as ur,render as dt,TextInput as Un,StaticRender as xo}from"@visulima/tui";import _,{useState as ce,useRef as be,useEffect as qe,useCallback as Ye,useSyncExternalStore as pr,useMemo as Ke}from"react";import{findCacheDirSync as Vi}from"@visulima/find-cache-dir";import{parse as mc}from"lockparse";import{readYamlSync as Kr}from"@visulima/fs/yaml";import{jsxs as u,jsx as c,Fragment as Zt}from"react/jsx-runtime";import{getRandomWord as So}from"@nkzw/safe-word-list";import yc from"validate-npm-package-name";import{downloadTemplate as vc}from"giget";import{stripJsonComments as wc}from"@visulima/fs/utils";import{getManifestData as kc}from"@socketsecurity/registry";import bc from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import $c from"module-replacements/manifests/native.json"with{type:"json"};import xc from"module-replacements/manifests/preferred.json"with{type:"json"};import{findVisConfigFile as nr,loadVisConfig as Co}from"./config.js";import{duration as Ui}from"@visulima/humanizer";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
3
3
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
4
|
-
const
|
|
5
|
-
`)){const s=o.trim();if(s==="packages:"){r=!0;continue}if(r){if(s.startsWith("- ")){const i=s.slice(2).replaceAll(Pa,"");n.push(i)}else if(s&&!s.startsWith("#"))break}}return n.length>0?n:void 0},"readPnpmWorkspacePatterns"),Va=L((e,t)=>{const a={};for(const[n,r]of Object.entries(e)){const o=t?.[n];a[n]={...o,command:r}}return a},"createTargetsFromScripts"),ye=L((e,t={})=>{const a={},n=Ma(e),r=ie(u(e,"package.json"));let o;if(n?o=n:r?.workspaces&&(o=Array.isArray(r.workspaces)?r.workspaces:r.workspaces.packages),!o)throw new Error("No workspace configuration found. Expected pnpm-workspace.yaml or package.json workspaces field.");const s=gt(e,o);for(const i of s){const c=u(e,i,"package.json"),l=ie(c);if(!l?.name)continue;const p=u(e,i,"project.json"),g=ie(p),f=l.scripts?Va(l.scripts,t.targetDefaults):{};a[l.name]={projectType:g?.projectType??"library",root:i,sourceRoot:g?.sourceRoot??`${i}/src`,tags:g?.tags,targets:f}}return{config:t,workspace:{projects:a}}},"discoverWorkspace"),Ae=L((e,t)=>{const a={},n={},r=new Set(Object.keys(t.projects));for(const[o,s]of Object.entries(t.projects)){a[o]={data:s,name:o,type:s.projectType??"library"},n[o]=[];const i=ie(u(e,s.root,"package.json"));if(!i)continue;const c={...i.dependencies,...i.devDependencies,...i.peerDependencies};for(const l of Object.keys(c))r.has(l)&&n[o]?.push({source:o,target:l,type:"static"})}return{dependencies:n,nodes:a}},"buildProjectGraph");var Fa=Object.defineProperty,Da=y((e,t)=>Fa(e,"name",{value:t,configurable:!0}),"f$6");const Ja={argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target only on projects affected by recent changes",examples:[["vis affected build","Run build on affected projects"],["vis affected test --base=main","Run tests on projects changed since main"]],execute:Da(async({argument:e,logger:t,options:a,runtime:n,visConfig:r,workspaceRoot:o})=>{const s=e[0];if(!s)throw new Error("Missing target. Usage: vis affected <target>");if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=o,{workspace:c}=ye(i,r),l=Ae(i,c),p={base:a.base,head:a.head,projectGraph:l,projects:c.projects,workspaceRoot:i},g=await pa(p);if(g.changedFiles.length===0){t.info("No files changed. Nothing to run.");return}if(g.affectedProjects.length===0){t.info("No projects affected by the changes.");return}t.info(`Affected projects: ${g.affectedProjects.join(", ")}`);const f=[s,`--projects=${g.affectedProjects.join(",")}`];a.parallel!==void 0&&f.push(`--parallel=${String(a.parallel)}`),a.cache||f.push("--no-cache"),a.dryRun&&f.push("--dry-run"),await n.runCommand("run",{argv:f})},"execute"),name:"affected",options:[{defaultValue:"HEAD~1",description:"Git base ref for comparison",name:"base",type:String},{defaultValue:"HEAD",description:"Git head ref for comparison",name:"head",type:String},{defaultValue:3,description:"Maximum number of parallel tasks",name:"parallel",type:Number},{defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean},{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean}]};var Wa=Object.defineProperty,h=y((e,t)=>Wa(e,"name",{value:t,configurable:!0}),"f$5");const Y=(1n<<128n)-1n,m=(1n<<64n)-1n,pe=(1n<<32n)-1n,ft=0x9E3779B1n,mt=0x85EBCA77n,_a=0xC2B2AE3Dn,J=0x9E3779B185EBCA87n,q=0xC2B2AE3D27D4EB4Fn,ht=0x165667B19E3779F9n,Le=0x85EBCA77C2B2AE63n,za=0x27D4EB2F165667C5n,Ha=0x165667919E3779F9n,Ga=0x9FB21C651E98DF25n,M=64,yt=M/8,qa=8,I=Buffer.from("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e","hex"),v=h((e,t=0)=>Buffer.from(e.buffer,e.byteOffset+t,e.length-t),"getView"),Ka=h(e=>{const t=Buffer.allocUnsafe(8);return t.writeBigUInt64LE(e),t.readBigUInt64BE()},"bswap64"),Ya=h(e=>{let t=e;return t=(t&0x0000FFFFn)<<16n|(t&0xFFFF0000n)>>16n,t=(t&0x00FF00FFn)<<8n|(t&0xFF00FF00n)>>8n,t},"bswap32"),Xa=h((e,t)=>(e&pe)*(t&pe)&m,"multU32ToU64"),Za=h((e,t)=>(e<<t|e>>32n-t)&pe,"rotl32"),Se=h((e,t)=>e^e>>t,"xorshift64"),je=h(e=>~e+1n&m,"inv64"),vt=h((e,t)=>{const a=e*t&Y;return a&m^a>>64n},"mul128Fold64"),P=h(e=>{let t=e;return t^=t>>37n,t=t*Ha&m,t^=t>>32n,t},"avalanche"),ue=h(e=>{let t=e;return t^=t>>33n,t=t*q&m,t^=t>>29n,t=t*ht&m,t^=t>>32n,t},"avalanche64"),kt=h((e,t,a)=>{for(let n=0;n<yt;n++){const r=t.readBigUInt64LE(n*8),o=r^a.readBigUInt64LE(n*8);e[n^1]+=r,e[n]+=Xa(o,o>>32n)}return e},"accumulate512"),qe=h((e,t,a,n)=>{for(let r=0;r<n;r++)kt(e,v(t,r*M),v(a,r*8));return e},"accumulate"),Qa=h((e,t)=>{for(let a=0;a<yt;a++){const n=t.readBigUInt64LE(a*8);let r=e[a];r=Se(r,47n),r^=n,r*=ft,e[a]=r&m}return e},"scrambleAcc"),oe=h((e,t)=>vt(e[0]^t.readBigUInt64LE(0),e[1]^t.readBigUInt64LE(qa)),"mix2Accs"),Ke=h((e,t,a)=>{let n=a;return n+=oe(e.slice(0),v(t,0)),n+=oe(e.slice(2),v(t,16)),n+=oe(e.slice(4),v(t,32)),n+=oe(e.slice(6),v(t,48)),P(n&m)},"mergeAccs"),en=h((e,t,a)=>{const n=Math.floor((a.byteLength-M)/8),r=M*n,o=Math.floor((t.byteLength-1)/r);for(let i=0;i<o;i++)qe(e,v(t,i*r),a,n),Qa(e,v(a,a.byteLength-M));const s=Math.floor((t.byteLength-1-r*o)/M);return qe(e,v(t,o*r),a,s),kt(e,v(t,t.byteLength-M),v(a,a.byteLength-M-7)),e},"hashLong"),tn=h((e,t)=>{const a=new BigUint64Array([_a,J,q,ht,Le,mt,za,ft]);en(a,e,t);const n=Ke(a,v(t,11),BigInt(e.byteLength)*J&m);return Ke(a,v(t,t.byteLength-M-11),~(BigInt(e.byteLength)*q)&m)<<64n|n},"hashLong128b"),Ye=h((e,t,a)=>vt((e.readBigUInt64LE(0)^t.readBigUInt64LE(0)+a)&m,(e.readBigUInt64LE(8)^t.readBigUInt64LE(8)-a)&m),"mix16B"),ce=h((e,t,a,n,r)=>{let o=e&m,s=e>>64n&m;return o+=Ye(t,n,r),o^=a.readBigUInt64LE(0)+a.readBigUInt64LE(8),o&=m,s+=Ye(a,v(n,16),r),s^=t.readBigUInt64LE(0)+t.readBigUInt64LE(8),s&=m,s<<64n|o},"mix32B"),an=h((e,t,a)=>{const n=e.byteLength,r=BigInt(e.readUInt8(n-1))|BigInt(n<<8)|BigInt(e.readUInt8(0)<<16)|BigInt(e.readUInt8(n>>1)<<24),o=(BigInt(t.readUInt32LE(0))^BigInt(t.readUInt32LE(4)))+a,s=(r^o)&m,i=(BigInt(t.readUInt32LE(8))^BigInt(t.readUInt32LE(12)))-a,c=(Za(Ya(r),13n)^i)&m;return(ue(c)&m)<<64n|ue(s)},"len1to3_128b"),nn=h((e,t,a)=>{const n=e.byteLength,r=e.readUInt32LE(0),o=e.readUInt32LE(n-4),s=BigInt(r)|BigInt(o)<<32n,i=(t.readBigUInt64LE(16)^t.readBigUInt64LE(24))+a&m;let c=(s^i)*(J+(BigInt(n)<<2n))&Y;return c+=(c&m)<<65n,c&=Y,c^=c>>67n,Se(Se(c&m,35n)*Ga&m,28n)|P(c>>64n)<<64n},"len4to8_128b"),rn=h((e,t,a)=>{const n=e.byteLength,r=(t.readBigUInt64LE(32)^t.readBigUInt64LE(40))+a&m,o=(t.readBigUInt64LE(48)^t.readBigUInt64LE(56))-a&m,s=e.readBigUInt64LE();let i=e.readBigUInt64LE(n-8),c=(s^i^r)*J;const l=(c&m)+(BigInt(n-1)<<54n);c=c&(Y^m)|l,i^=o,c+=i+(i&pe)*(mt-1n)<<64n,c&=Y,c^=Ka(c>>64n);let p=(c&m)*q;return p+=(c>>64n)*q<<64n,p&=Y,P(p&m)|P(p>>64n)<<64n},"len9to16_128b"),on=h((e,t)=>{const a=e.byteLength;return a>8?rn(e,I,t):a>=4?nn(e,I,t):a>0?an(e,I,t):ue(t^I.readBigUInt64LE(64)^I.readBigUInt64LE(72))|ue(t^I.readBigUInt64LE(80)^I.readBigUInt64LE(88))<<64n},"len0to16_128b"),sn=h((e,t,a)=>{let n=BigInt(e.byteLength)*J&m,r=BigInt(e.byteLength-1)/32n;for(;r>=0n;){const i=Number(r);n=ce(n,v(e,16*i),v(e,e.byteLength-16*(i+1)),v(t,32*i),a),r--}let o=n+(n>>64n)&m;o=P(o);let s=(n&m)*J+(n>>64n)*Le+(BigInt(e.byteLength)-a&m)*q;return s&=m,s=je(P(s)),o|s<<64n},"len17to128_128b"),cn=h((e,t,a)=>{let n=BigInt(e.byteLength)*J&m;for(let s=32;s<160;s+=32)n=ce(n,v(e,s-32),v(e,s-16),v(t,s-32),a);n=P(n&m)|P(n>>64n)<<64n;for(let s=160;s<=e.byteLength;s+=32)n=ce(n,v(e,s-32),v(e,s-16),v(t,3+s-160),a);n=ce(n,v(e,e.byteLength-16),v(e,e.byteLength-32),v(t,103),je(a));let r=n+(n>>64n)&m;r=P(r);let o=(n&m)*J+(n>>64n)*Le+(BigInt(e.byteLength)-a&m)*q;return o&=m,o=je(P(o)),r|o<<64n},"len129to240_128b"),ln=h((e,t=0n)=>{const a=e.byteLength;return a<=16?on(e,t):a<=128?sn(e,I,t):a<=240?cn(e,I,t):tn(e,I)},"xxh3_128"),pn=h(e=>{const t=e>>64n&m,a=e&m;return t.toString(16).padStart(16,"0")+a.toString(16).padStart(16,"0")},"bigintToHex"),$t=h(e=>pn(ln(e)),"xxh3Hash");class un{static{y(this,"gn")}static{h(this,"Xxh3Hasher")}#e=[];update(t){return typeof t=="string"?this.#e.push(Buffer.from(t)):this.#e.push(t),this}digest(){return $t(Buffer.concat(this.#e))}}h(()=>new un,"createXxh3Hasher");var dn=Object.defineProperty,_=y((e,t)=>dn(e,"name",{value:t,configurable:!0}),"i$4");const ae=_(()=>u(ja(),".vis","cache","ai"),"getCacheDirectory"),gn=3600*1e3,fn=1800*1e3,mn=_(()=>{const e=ae();k(e)||Oe(e,{recursive:!0})},"ensureCacheDirectory"),hn=_((e,t,a)=>{const n=a.map(o=>({currentRange:o.currentRange,name:o.packageName,targetVersion:o.targetVersion})).toSorted((o,s)=>o.name.localeCompare(s.name)),r=JSON.stringify({analysisType:t,packages:n,provider:e});return $t(Buffer.from(r))},"buildCacheKey"),yn=_(e=>{const t=u(ae(),`${e}.json`);if(k(t))try{const a=B(t,"utf8"),n=JSON.parse(a);if(Date.now()-n.createdAt>n.ttlMs){ee(t,{force:!0});return}return n.result}catch{ee(t,{force:!0});return}},"getCachedAnalysis"),vn=_((e,t,a)=>{mn();const n=ae(),r={createdAt:Date.now(),result:t,ttlMs:a};E(u(n,`${e}.json`),JSON.stringify(r,void 0,2),"utf8")},"setCachedAnalysis"),kn=_((e,t)=>t!==void 0&&t>0?t:e==="security"?fn:gn,"getTtlForAnalysisType"),$n=_(()=>{const e=ae();if(!k(e))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const t=Be(e).filter(o=>o.endsWith(".json"));let a=0,n,r;for(const o of t){const s=u(e,o),i=Ie(s);a+=i.size;const{mtimeMs:c}=i;(n===void 0||c<n)&&(n=c),(r===void 0||c>r)&&(r=c)}return{entries:t.length,newestEntry:r,oldestEntry:n,totalSizeBytes:a}},"getCacheStats"),wn=_(()=>{const e=ae();if(!k(e))return 0;const t=Be(e).filter(a=>a.endsWith(".json"));for(const a of t)ee(u(e,a),{force:!0});return t.length},"clearCache");var bn=Object.defineProperty,S=y((e,t)=>bn(e,"name",{value:t,configurable:!0}),"a$2");const le={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},Te=S(e=>{if(e?.provider){if(!ka.includes(e.provider))return;const n=$a(e.provider);return n.available?n:void 0}const t=wa();if(t.length===0)return;const a={...le,...e?.priority};return t.toSorted((n,r)=>(a[r.name]??0)-(a[n.name]??0))[0]},"resolveProvider"),Sn=new Set(["defer","review","skip","update"]),jn=new Set(["critical","high","low","medium"]),Cn=new Set(["high","low","medium"]),xn=50,$e=30,En=2,Rn=1e3,Nn=12e4,On=S(e=>e.map(t=>{const a=t.vulnerabilities&&t.vulnerabilities.length>0?` [VULNERABILITIES: ${t.vulnerabilities.map(n=>`${n.severity} ${n.id}`).join(", ")}]`:"";return`- ${t.packageName}: ${t.currentRange} → ${t.newRange} (${t.updateType})${a}`}).join(`
|
|
6
|
-
`),"
|
|
4
|
+
const Va=Fa(import.meta.url),Nt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,At=$(t=>{if(typeof Nt<"u"&&Nt.versions&&Nt.versions.node){const[e,r]=Nt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Nt.getBuiltinModule(t)}return Va(t)},"__cjs_getBuiltinModule"),{createInterface:Vt}=At("node:readline"),{readFileSync:K,existsSync:F,readdirSync:ft,rmSync:lt,mkdirSync:$e,writeFileSync:H,statSync:Yr,lstatSync:Ya,unlinkSync:Ri,chmodSync:Xa}=At("node:fs"),{env:fn,cwd:Oi}=Nt,{join:L,dirname:Pi,parse:Qa,resolve:rt,basename:Za,relative:Fn,sep:ec,isAbsolute:tc}=At("node:path"),{createRequire:rc}=At("node:module"),{homedir:Oe}=At("node:os"),{fileURLToPath:nc}=At("node:url"),{execSync:Xr,spawnSync:Le}=At("node:child_process");var Sc="1.0.0-alpha.4";const Gi={version:Sc};var Cc=Object.defineProperty,Ec=$((t,e)=>Cc(t,"name",{value:e,configurable:!0}),"t$c");const Eo=Ec(t=>t in fn&&fn[t]!=="0"&&fn[t]!=="false","check"),Ge=Eo("CI")||Eo("CONTINUOUS_INTEGRATION");var jc=Object.defineProperty,Re=$((t,e)=>jc(t,"name",{value:e,configurable:!0}),"s$m");const Tc=Re(()=>process.env.NO_COLOR!==void 0?!1:process.env.FORCE_COLOR!==void 0?!0:!!process.stderr.isTTY,"supportsColor"),Ac=Tc(),gt=Re((t,e)=>r=>Ac?`\x1B[${t}m${r}\x1B[${e}m`:r,"ansi"),pe=gt("1","22"),re=gt("2","22"),zi=gt("31","39"),Wi=gt("32","39"),_i=gt("33","39"),Ic=gt("34","39"),Pe=gt("36","39"),Rc=gt("90","39"),Oc=Re(()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux","isUnicodeSupported"),gn=Oc(),Gn={arrow:gn?"→":"->",failure:gn?"✗":"x",success:gn?"✓":"v"},k=Re(t=>{process.stderr.write(`${pe(Ic("info:"))} ${t}
|
|
5
|
+
`)},"info"),ae=Re(t=>{process.stderr.write(`${pe(_i("warn:"))} ${t}
|
|
6
|
+
`)},"warn"),St=Re(t=>{process.stderr.write(`${pe(zi("error:"))} ${t}
|
|
7
|
+
`)},"error"),te=Re(t=>{process.stderr.write(`${pe(Rc("note:"))} ${t}
|
|
8
|
+
`)},"note"),Q=Re(t=>{process.stderr.write(`${Wi(Gn.success)} ${t}
|
|
9
|
+
`)},"success"),or=Re(t=>{process.stderr.write(`${zi(Gn.failure)} ${t}
|
|
10
|
+
`)},"failure");Re((t,e)=>!process.stderr.isTTY||process.env.TERM==="dumb"?t===e?e:`${t} (${re(e)})`:Ka(t,e),"link");const Pc=Re(()=>{if(process.env.VIS_VERSION)return process.env.VIS_VERSION;try{const t=new URL("../../package.json",import.meta.url);return JSON.parse(K(t,"utf8")).version}catch{return"0.0.0"}},"getVersion"),Nc=Re(()=>{process.env.VIS_VERSION=Pc()},"injectVersion"),Dc=Re(t=>{!process.stdout.isTTY||Ge||process.env.TERM==="dumb"||process.stdout.write(`\x1B]0;${t}\x07`)},"setTerminalTitle");var Mc=Object.defineProperty,Hi=$((t,e)=>Mc(t,"name",{value:e,configurable:!0}),"n$8");let xr,jo=!1;const Bc=rc(import.meta.url),Qr=Hi(()=>{if(jo)return xr;jo=!0;try{const t=Bc("../index.js");typeof t.detectPackageManager=="function"&&typeof t.execPmCommand=="function"&&(xr=t)}catch{xr=void 0}return xr},"loadNativeBindings");Hi(()=>Qr()!==void 0,"isNativeAvailable");var Lc=Object.defineProperty,xe=$((t,e)=>Lc(t,"name",{value:e,configurable:!0}),"s$k");const zn=xe(()=>{const t=Qr();if(!t)throw new Error("Native bindings for package manager operations failed to load. Ensure the correct platform binary is installed.");return t},"requireNative"),Sr=xe((t,e)=>{try{const r=L(t,"package.json");if(F(r)){const n=JSON.parse(K(r,"utf8"));if(n.packageManager?.startsWith(`${e}@`))return n.packageManager.slice(e.length+1)}}catch{}},"readPackageManagerVersion"),Fc=xe(t=>{if(F(L(t,"pnpm-lock.yaml"))||F(L(t,"pnpm-workspace.yaml")))return{name:"pnpm",version:Sr(t,"pnpm")??"latest"};if(F(L(t,"yarn.lock")))return{name:"yarn",version:Sr(t,"yarn")??"latest"};if(F(L(t,"bun.lock"))||F(L(t,"bun.lockb")))return{name:"bun",version:Sr(t,"bun")??"latest"};if(F(L(t,"package-lock.json"))||F(L(t,"npm-shrinkwrap.json")))return{name:"npm",version:Sr(t,"npm")??"latest"};try{const e=L(t,"package.json");if(F(e)){const r=JSON.parse(K(e,"utf8"));if(r.packageManager){const n=/^(pnpm|yarn|npm|bun)@(.+)$/.exec(r.packageManager);if(n)return{name:n[1],version:n[2]}}}}catch{}},"detectPmInDir"),Vc=xe(t=>{let e=t;for(;;){const r=Fc(e);if(r)return r;const n=Pi(e);if(n===e||Qa(e).root===e)break;e=n}throw new Error(`Could not detect package manager in ${t}. No lockfile or packageManager field found.`)},"detectPmFallback"),me=xe(t=>{if(!F(t))throw new Error(`Could not detect package manager in ${t}. Directory does not exist.`);try{const e=zn().detectPackageManager(t);return{name:e.name,version:e.version||"latest"}}catch{return Vc(t)}},"detectPm"),Uc=xe((t,e,r)=>{for(const n of t.warnings)r.warn(`warning: ${n}`);return zn().execPmCommandInteractive(t.bin,t.args,e)},"runResolved"),ze=xe((t,e,r)=>{const n=t(zn());return Uc(n,e,r)},"resolveAndRun"),Zr=xe((t,e,r,n)=>ze(i=>i.resolveInstall(t.name,t.version,e),r,n),"runInstall"),Gc=xe((t,e,r,n)=>ze(i=>i.resolveAdd(t.name,t.version,e),r,n),"runAdd"),zc=xe((t,e,r,n)=>ze(i=>i.resolveRemove(t.name,t.version,e),r,n),"runRemove"),Wc=xe((t,e,r,n)=>ze(i=>i.resolveDedupe(t.name,t.version,e),r,n),"runDedupe"),_c=xe((t,e,r,n)=>ze(i=>i.resolveWhy(t.name,t.version,e),r,n),"runWhy");xe((t,e,r,n)=>ze(i=>i.resolveOutdated(t.name,t.version,e),r,n),"runOutdated");const Hc=xe((t,e,r,n)=>ze(i=>i.resolveLink(t.name,e),r,n),"runLink"),Jc=xe((t,e,r,n,i)=>ze(o=>o.resolveUnlink(t.name,t.version,e,r),n,i),"runUnlink"),Wn=xe((t,e,r,n)=>ze(i=>i.resolveDlx(t.name,t.version,e),r,n),"runDlx"),qc=xe((t,e,r,n)=>ze(i=>i.resolveExec(t.name,t.version,e),r,n),"runExec"),Yc=xe((t,e,r,n,i)=>ze(o=>o.resolvePmCommand(t.name,t.version,e,r),n,i),"runPmSubcommand");var Xc=Object.defineProperty,we=$((t,e)=>Xc(t,"name",{value:e,configurable:!0}),"c$j");const Kc="https://api.socket.dev/v0/purl?alerts=true",en=we(()=>T(Oe(),".vis","cache","socket-security"),"getCacheDirectory"),Qc=3600*1e3,at=.4,To=100,Zc=we(t=>typeof t=="object"&&t!=null&&"id"in t&&"type"in t&&"name"in t&&"version"in t&&"alerts"in t&&"score"in t&&t.type==="npm","isPackageReportData"),el=we(()=>{const t=en();F(t)||$e(t,{recursive:!0})},"ensureCacheDirectory"),Ji=we((t,e)=>`${encodeURIComponent(t)}@${encodeURIComponent(e)}`,"buildCacheKey"),tl=we((t,e)=>{const r=Ji(t,e),n=T(en(),`${r}.json`);try{const i=K(n,"utf8"),o=JSON.parse(i);if(Date.now()-o.createdAt>o.ttlMs){lt(n,{force:!0});return}return o.report}catch{return}},"getCachedReport"),rl=we((t,e,r,n)=>{const i=Ji(t,e),o={createdAt:Date.now(),report:r,ttlMs:n};H(T(en(),`${i}.json`),JSON.stringify(o),"utf8")},"setCachedReport"),nl=we(t=>{const e=[t.license,t.maintenance,t.quality,t.supplyChain,t.vulnerability];return Number((e.reduce((r,n)=>r+n,0)/e.length).toFixed(2))},"calculateOverallScore"),Wt=we(async(t,e={})=>{const{apiToken:r,cacheTtlMs:n=Qc,timeoutMs:i=15e3}=e,o=new Map;if(t.length===0||!r)return o;const s=[];for(const f of t){const p=tl(f.name,f.version);p?o.set(`${f.name}@${f.version}`,p):s.push(f)}if(s.length===0)return o;const l=`Basic ${Buffer.from(`${r}:`).toString("base64")}`;el();const d=[];for(let f=0;f<s.length;f+=To)d.push(s.slice(f,f+To));for(const f of d){const p=f.map(y=>({purl:`pkg:npm/${y.name}@${y.version}`})),h=new AbortController,m=setTimeout(()=>{h.abort()},i);try{const y=await fetch(Kc,{body:JSON.stringify({components:p}),headers:{Authorization:l,"Content-Type":"application/json","User-Agent":"@visulima/vis"},method:"POST",signal:h.signal});if(!y.ok)continue;const b=await y.text();ol(b,f,o,n)}catch{}finally{clearTimeout(m)}}return o},"fetchSocketReports"),ol=we((t,e,r,n)=>{const i=new Map;for(const s of e)i.set(`${s.name}@${s.version}`,s);const o=t.split(`}
|
|
11
|
+
`);for(const s of o){const l=s.trim();if(l)try{const d=JSON.parse(l.endsWith("}")?l:`${l}}`),f=`${d.namespace?`${d.namespace}/`:""}${d.name}`,p=`${f}@${d.version}`;if(!i.has(p))continue;const h=d.score.overall??nl(d.score),m={alerts:d.alerts,author:d.author,id:d.id,license:d.license,name:d.name,score:{...d.score,overall:h},size:d.size,type:"npm",version:d.version};d.namespace&&(m.namespace=d.namespace),Zc(m)&&(r.set(p,m),rl(f,d.version,m,n))}catch{}}},"parseNdjsonResponse"),Mt=we(t=>t.namespace?`${t.namespace}/${t.name}`:t.name,"getFullPackageName"),_n=we(t=>t>=.8?"excellent":t>=.6?"good":t>=.4?"fair":t>=.2?"poor":"critical","scoreLabel"),fr=we(t=>t>=.6?"green":t>=.4?"yellow":"red","scoreColor"),Ao=we(t=>{const e=Mt(t),r=`score: ${String(Math.round(t.score.overall*100))}%`,n=t.alerts.length,i=n>0?`${String(n)} alert${n===1?"":"s"}`:"no alerts";return`${e}@${t.version} (${r}, ${i})`},"formatReportSummary");we(t=>{const e=[`${Mt(t)}@${t.version}`,` License: ${t.license||"unknown"}`];if(e.push(` Overall Score: ${String(Math.round(t.score.overall*100))}% (${_n(t.score.overall)})`),e.push(` Supply Chain: ${String(Math.round(t.score.supplyChain*100))}%`),e.push(` Quality: ${String(Math.round(t.score.quality*100))}%`),e.push(` Maintenance: ${String(Math.round(t.score.maintenance*100))}%`),e.push(` Vulnerability: ${String(Math.round(t.score.vulnerability*100))}%`),e.push(` License: ${String(Math.round(t.score.license*100))}%`),t.alerts.length>0){e.push(` Alerts (${String(t.alerts.length)}):`);for(const r of t.alerts){const n=r.props?.cveId?` (${r.props.cveId})`:"";e.push(` [${r.severity.toUpperCase()}] ${r.type}${n} — ${r.category}`)}}return e.join(`
|
|
12
|
+
`)},"formatReportDetailed");const il=we(t=>{if(t.size===0)return"";let e=0,r=0,n=0,i=0,o=0,s=0;for(const d of t.values()){for(const f of d.alerts)switch(e++,f.severity){case"critical":{r++;break}case"high":{n++;break}case"medium":{i++;break}default:o++}d.score.overall<at&&s++}const l=[];if(l.push(`Socket.dev: scanned ${String(t.size)} package${t.size===1?"":"s"}`),e>0){const d=[];r>0&&d.push(`${String(r)} critical`),n>0&&d.push(`${String(n)} high`),i>0&&d.push(`${String(i)} medium`),o>0&&d.push(`${String(o)} low`),l.push(` Alerts: ${String(e)} total (${d.join(", ")})`)}else l.push(" No security alerts found.");return s>0&&l.push(` ${String(s)} package${s===1?"":"s"} with low security score (<40%)`),l.join(`
|
|
13
|
+
`)},"formatSecurityOverview"),sl=we(()=>{const t=en();if(!F(t))return 0;const e=ft(t).filter(r=>r.endsWith(".json"));for(const r of e)lt(T(t,r),{force:!0});return e.length},"clearSocketCache"),It=we(t=>t?.enabled?{apiToken:t.apiToken??process.env.VIS_SOCKET_TOKEN,cacheTtlMs:t.cacheTtlMs,minimumScore:t.minimumScore,timeoutMs:t.timeoutMs}:void 0,"buildSocketOptions"),Hn=we((t,e,r)=>{if(!r)return;const n=`${t}@${e}`;if(r[n])return r[n];if(r[t])return r[t];for(const[i,o]of Object.entries(r))if(i.endsWith("*")&&t.startsWith(i.slice(0,-1)))return o},"findAcceptedRisk"),al=we((t,e,r,n)=>[" // Add to security.socket.acceptedRisks in vis.config.ts:",` ${`"${t}"`}: {`,` reason: "${n}",`,` acceptedAt: "${new Date().toISOString()}",`,` acceptedScore: ${String(r)},`," },"].join(`
|
|
14
|
+
`),"formatAcceptedRiskSnippet");var cl=Object.defineProperty,Ne=$((t,e)=>cl(t,"name",{value:e,configurable:!0}),"o$g");const ll={a:["4","e"],b:["d"],d:["b"],e:["3","a"],g:["9","q"],i:["1","l"],l:["1","i"],m:["n"],n:["m"],o:["0"],s:["5","z"],t:["7"],u:["v"],v:["u"]},dl=Ne(t=>{const e=new Set;if(t.length<3)return e;for(let n=0;n<t.length;n++){const i=t[n]==="-"||t[n]==="."||t[n]==="_";if(i||e.add(t.slice(0,n)+t.slice(n+1)),i||e.add(t.slice(0,n)+t[n]+t.slice(n)),n<t.length-1&&t[n]!==t[n+1]){const l=t[n+1]==="-"||t[n+1]==="."||t[n+1]==="_";if(!i&&!l){const d=t.split("");[d[n],d[n+1]]=[d[n+1],d[n]],e.add(d.join(""))}}const o=t[n].toLowerCase(),s=ll[o];if(s)for(const l of s)e.add(t.slice(0,n)+l+t.slice(n+1))}const r=/[-._]/g;if(r.test(t))e.add(t.replaceAll(r,"")),e.add(t.replaceAll(r,"-")),e.add(t.replaceAll(r,".")),e.add(t.replaceAll(r,"_"));else if(t.length>5)for(let n=2;n<t.length-2;n++)e.add(`${t.slice(0,n)}-${t.slice(n)}`),e.add(`${t.slice(0,n)}.${t.slice(n)}`),e.add(`${t.slice(0,n)}_${t.slice(n)}`);return t.startsWith("@")||(e.add(`${t}-js`),e.add(`${t}js`),e.add(`${t}-node`)),e.delete(t),e},"generateVariants");let hn,Cr;const qi=Ne(()=>{if(!hn){const t=rt(Pi(nc(import.meta.url)),"../data/typosquats.json");hn=JSON.parse(K(t,"utf8"))}return hn},"loadBlocklist"),ul=Ne(()=>{if(!Cr){Cr=new Map;for(const[t,e]of Object.entries(qi()))for(const r of e)Cr.set(r,t)}return Cr},"getReverseLookup"),pl=Ne(t=>t.startsWith("@")?t.split("/")[1]??t:t,"bareName"),fl=Ne(t=>{const e=pl(t),r=ul().get(e);if(r)return{input:t,legitimate:r,method:"blocklist"};for(const n of Object.keys(qi()))if(dl(n).has(e))return{input:t,legitimate:n,method:"heuristic"}},"checkTyposquat"),Yi=Ne((t,e)=>{const r=e?new Set(e):void 0,n=[];for(const i of t){if(r?.has(i))continue;const o=fl(i);o&&n.push(o)}return n},"checkTyposquats"),Xi=Ne((t,e)=>{ae(""),ae(ct(`Possible typosquat${t.length===1?"":"s"} ${e}:`));for(const r of t){const n=r.method==="blocklist"?"known typosquat":"similar name";ae(` ${Ie("⚠")} ${ct(r.input)} — did you mean ${Ie(r.legitimate)}? (${n})`)}ae("")},"printTyposquatWarnings"),Ki=Ne(async t=>{if(!process.stdin.isTTY){ae("Aborting: potential typosquat detected in non-interactive mode. Use --no-typosquat-check to skip.");return}const e=Vt({input:process.stdin,output:process.stdout}),r=await new Promise(n=>{e.question(t,i=>{n(i.trim().toLowerCase())})});return e.close(),r},"askConfirmation"),Qi=Ne(async(t,e)=>{const r=Yi(t,e);if(r.length===0)return{ok:!0,packages:t};Xi(r,"detected");const n=await Ki(`Use suggested package${r.length===1?"":"s"} instead? [S]uggested / [y]es, keep original / [N]o, abort (default: N) `);if(n===void 0)return{ok:!1,packages:t};if(n==="s"||n==="suggested"){const i=new Map(r.map(o=>[o.input,o.legitimate]));return{ok:!0,packages:t.map(o=>i.get(o)??o)}}return n==="y"||n==="yes"?{ok:!0,packages:t}:{ok:!1,packages:t}},"runTyposquatCheck"),gl=/^(?:npm|pnpm|yarn):(.+?)(?:@.*)?$/,hl=Ne(t=>gl.exec(t)?.[1],"parseAliasTarget"),ml=Ne(t=>{if(!F(t))return[];const e=JSON.parse(K(t,"utf8")),r={...e.dependencies,...e.devDependencies,...e.optionalDependencies,...e.peerDependencies},n=new Set;for(const[i,o]of Object.entries(r)){n.add(i);const s=hl(o);s&&n.add(s)}return[...n]},"readDepsFromPackageJson"),Zi=Ne(async(t,e)=>{const r=L(t,"package.json"),n=ml(r);if(n.length===0)return!0;const i=Yi(n,e);if(i.length===0)return!0;Xi(i,"in package.json dependencies"),ae("Fix the package name in package.json before proceeding.");const o=await Ki("Continue anyway? [y/N] ");return o==="y"||o==="yes"},"scanDepsForTyposquats");var yl=Object.defineProperty,Jn=$((t,e)=>yl(t,"name",{value:e,configurable:!0}),"s$j");const gr=Jn(t=>t?Array.isArray(t)?t:[t]:[],"toStringArray"),Sn=Jn(t=>t instanceof Error?t.message:typeof t=="string"?t:String(t),"errorMessage"),vl=/^(.+?)(?:@(.+))?$/,qn=Jn(t=>{if(t.startsWith("@")){const r=t.indexOf("/");if(r===-1)return{name:t,versionSpec:void 0};const n=t.slice(r+1),i=n.indexOf("@");return i===-1?{name:t,versionSpec:void 0}:{name:t.slice(0,r+1+i),versionSpec:n.slice(i+1)}}const e=vl.exec(t);return e?{name:e[1],versionSpec:e[2]}:{name:t,versionSpec:void 0}},"parsePackageArgument");var wl=Object.defineProperty,Bt=$((t,e)=>wl(t,"name",{value:e,configurable:!0}),"m$k");const kl=Bt(async(t,e=1e4)=>{const r=new Map,n=new AbortController,i=setTimeout(()=>{n.abort()},e);try{const o=t.map(async s=>{try{const l=await fetch(`https://registry.npmjs.org/${s}/latest`,{headers:{Accept:"application/json"},signal:n.signal});if(l.ok){const d=await l.json();d.version&&r.set(s,d.version)}}catch{}});await Promise.all(o)}finally{clearTimeout(i)}return r},"resolveLatestVersions"),bl=Bt((t,e,r)=>{const n=[];for(const i of t.values()){const{overall:o}=i.score,s=fr(o),l=`${String(Math.round(o*100))}%`,d=i.alerts.length,f=Mt(i),p=Hn(f,i.version,r),h=s==="red"?ct:s==="yellow"?Ie:Ai;if(k(p?` ${h(l)} ${Ao(i)} ${Be(`[accepted: ${p.reason}]`)}`:` ${h(l)} ${Ao(i)}`),d>0){const m=i.alerts.filter(y=>y.severity==="critical"||y.severity==="high").length;m>0&&ae(` ${String(m)} critical/high alert${m===1?"":"s"}`)}o<e&&!p&&n.push(i)}return n},"displaySecurityReports"),$l=Bt(async(t,e)=>{const r=Vt({input:process.stdin,output:process.stdout}),n=Bt(l=>new Promise(d=>{r.question(l,f=>{d(f.trim())})}),"ask"),i=String(Math.round(e*100));ae(""),ae(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const l of t){const d=Mt(l),f=`${String(Math.round(l.score.overall*100))}%`;ae(` • ${d}@${l.version} — score: ${f} (${_n(l.score.overall)})`)}ae("");const o=await n("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return r.close(),!1;const s=await n("Remember this decision? (prints config snippet) [y/N] ");if(r.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){te(""),te("Add the following to security.socket.acceptedRisks in vis.config.ts:"),te("");for(const l of t){const d=Mt(l),f=al(d,l.version,l.score.overall,"Reviewed and accepted");te(f)}te("")}return!0},"confirmLowScorePackages"),xl=Bt(async(t,e,r,n)=>{const i=t.map(qn),o=new Map;for(const h of i)if(h.versionSpec){const m=qr(h.versionSpec);m&&o.set(h.name,m.version)}const s=i.filter(h=>!o.has(h.name)).map(h=>h.name),l=s.length>0?await kl(s):new Map,d=[];for(const h of i){const m=o.get(h.name)??l.get(h.name);m&&d.push({name:h.name,version:m})}if(d.length===0)return!0;k(""),k("Socket.dev security check:");const f=await Wt(d,e);if(f.size===0)return k(" Could not fetch security data. Proceeding."),!0;const p=bl(f,r,n);return p.length===0?(k(""),!0):process.stdin.isTTY?$l(p,r):(ae(`Aborting: ${String(p.length)} package${p.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),Sl={group:"Dependencies",argument:{description:"Packages to add (e.g., react react-dom)",name:"packages",type:String},description:"Add packages using the detected package manager",examples:[["vis add react react-dom","Add packages"],["vis add -D typescript @types/react","Add as dev dependencies"],["vis add react --filter app","Add to specific workspace package"],["vis add -g typescript","Add globally (uses npm)"],["vis add lodash -w","Add to workspace root"],["vis add lodash --no-socket-check","Add without Socket.dev check"],["vis add lodash --no-typosquat-check","Skip typosquat name check"]],execute:Bt(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(!r.noTyposquatCheck){const f=o.map(h=>qn(h)),p=await Qi(f.map(h=>h.name),n?.security?.typosquatAllowlist);if(!p.ok){process.exitCode=1;return}o=f.map((h,m)=>{const y=p.packages[m];return y!==h.name?h.versionSpec?`${y}@${h.versionSpec}`:y:o[m]})}if(!r.noSocketCheck){const f=It(n?.security?.socket);if(f){const p=f.minimumScore??at;if(!await xl(o,f,p,n?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),l=me(i??s),d=Gc(l,{exact:r.exact||!1,filter:gr(r.filter),global:r.global||!1,optional:r.saveOptional||!1,packages:o,peer:r.savePeer||!1,saveDev:r.saveDev||!1,workspace:r.workspace||!1,workspaceRoot:r.workspaceRoot||!1},s,e);d!==0&&(process.exitCode=d)},"execute"),name:"add",options:[{alias:"D",defaultValue:!1,description:"Add as dev dependency",name:"save-dev",type:Boolean},{alias:"E",defaultValue:!1,description:"Save exact version",name:"exact",type:Boolean},{alias:"P",defaultValue:!1,description:"Add as peer dependency",name:"save-peer",type:Boolean},{alias:"O",defaultValue:!1,description:"Add as optional dependency",name:"save-optional",type:Boolean},{alias:"g",defaultValue:!1,description:"Install globally (uses npm)",name:"global",type:Boolean},{alias:"w",defaultValue:!1,description:"Add to workspace root",name:"workspace-root",type:Boolean},{defaultValue:!1,description:"Use workspace protocol (pnpm)",name:"workspace",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Skip typosquat name check before adding",name:"no-typosquat-check",type:Boolean},{defaultValue:!1,description:"Skip Socket.dev security check before adding",name:"no-socket-check",type:Boolean}]};var Cl=Object.defineProperty,Qe=$((t,e)=>Cl(t,"name",{value:e,configurable:!0}),"a$b");const El=/\/+$/,jl=/\/\*\*$/,Tl=/\/\*\/\*$/,Al=/^['"]|['"]$/g,es=/node_modules/,ts=/\.git/,Rr=Qe(t=>{try{return Ue(t)}catch{return}},"readJsonFileSafe"),Il=Qe((t,e,r)=>{for(const n of Mn(t,{includeFiles:!1,includeSymlinks:!1,skip:[es,ts]}))if(n.path!==t&&le(T(n.path,"package.json"))){const i=n.path.slice(t.length+1);r.push(`${e}/${i}`)}},"scanDirectoryRecursive"),Rl=Qe((t,e,r)=>{const n=e.slice(0,-2),i=Ft(t,n);if(le(i))for(const o of Mn(i,{includeFiles:!1,includeSymlinks:!1,maxDepth:1,skip:[es,ts]}))o.path!==i&&le(T(o.path,"package.json"))&&r.push(T(n,o.name))},"resolveSimpleGlob"),Ol=Qe((t,e,r)=>{const n=e.replace(jl,"").replace(Tl,""),i=Ft(t,n);le(i)&&Il(i,n,r)},"resolveDoubleGlob"),Pl=Qe((t,e,r)=>{const n=Ft(t,e);le(n)&&le(T(n,"package.json"))&&r.push(e)},"resolveExactDirectory"),Ct=Qe((t,e)=>{const r=[];for(const n of e){const i=n.replace(El,"");i.startsWith("!")||(i.endsWith("/*")?Rl(t,i,r):i.endsWith("/**")||i.endsWith("/*/*")?Ol(t,i,r):Pl(t,i,r))}return r},"resolveWorkspacePatterns"),tn=Qe(t=>{const e=T(t,"pnpm-workspace.yaml");if(!le(e))return;const r=Xe(e),n=[];let i=!1;for(const o of r.split(`
|
|
15
|
+
`)){const s=o.trim();if(s==="packages:"){i=!0;continue}if(i){if(s.startsWith("- ")){const l=s.slice(2).replaceAll(Al,"");n.push(l)}else if(s&&!s.startsWith("#"))break}}return n.length>0?n:void 0},"readPnpmWorkspacePatterns"),Nl=Qe((t,e)=>{const r={};for(const[n,i]of Object.entries(t)){const o=e?.[n];r[n]={...o,command:i}}return r},"createTargetsFromScripts"),rn=Qe((t,e={})=>{const r={},n=tn(t),i=Rr(T(t,"package.json"));let o;if(n?o=n:i?.workspaces&&(o=Array.isArray(i.workspaces)?i.workspaces:i.workspaces.packages),!o)throw new Error("No workspace configuration found. Expected pnpm-workspace.yaml or package.json workspaces field.");const s=Ct(t,o);for(const l of s){const d=T(t,l,"package.json"),f=Rr(d);if(!f?.name)continue;const p=T(t,l,"project.json"),h=Rr(p),m=f.scripts?Nl(f.scripts,e.targetDefaults):{};let y="library";h?.projectType?y=h.projectType:f.bin!==void 0&&(y="application"),r[f.name]={projectType:y,root:l,sourceRoot:h?.sourceRoot??`${l}/src`,tags:h?.tags,targets:m}}return{config:e,workspace:{projects:r}}},"discoverWorkspace"),Yn=Qe((t,e)=>{const r={},n={},i=new Set(Object.keys(e.projects));for(const[o,s]of Object.entries(e.projects)){r[o]={data:s,name:o,type:s.projectType??"library"},n[o]=[];const l=Rr(T(t,s.root,"package.json"));if(!l)continue;const d=[[l.dependencies,"static"],[l.devDependencies,"devDependency"],[l.peerDependencies,"peerDependency"]],f=new Set;for(const[p,h]of d)if(p)for(const m of Object.keys(p))i.has(m)&&!f.has(m)&&(f.add(m),n[o]?.push({source:o,target:m,type:h}))}return{dependencies:n,nodes:r}},"buildProjectGraph");var Dl=Object.defineProperty,Ml=$((t,e)=>Dl(t,"name",{value:e,configurable:!0}),"u$f");const Bl={group:"Run & Execute",argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target only on projects affected by recent changes",examples:[["vis affected build","Run build on affected projects"],["vis affected test --base=main","Run tests on projects changed since main"]],execute:Ml(async({argument:t,logger:e,options:r,runtime:n,visConfig:i,workspaceRoot:o})=>{const s=t[0];if(!s)throw new Error("Missing target. Usage: vis affected <target>");if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const l=o,{workspace:d}=rn(l,i),f=Yn(l,d),p=new Set(["deep","direct","none"]),h=r.downstream??"deep",m=r.upstream??"none";if(!p.has(h))throw new Error(`Invalid --downstream value: "${h}". Must be "none", "direct", or "deep".`);if(!p.has(m))throw new Error(`Invalid --upstream value: "${m}". Must be "none", "direct", or "deep".`);const y={base:r.base,downstream:h,head:r.head,projectGraph:f,projects:d.projects,upstream:m,workspaceRoot:l},b=await oc(y);if(b.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}if(b.affectedProjects.length===0){e.info("No projects affected by the changes.");return}e.info(`Affected projects: ${b.affectedProjects.join(", ")}`);const x=[s,`--projects=${b.affectedProjects.join(",")}`];r.parallel!==void 0&&x.push(`--parallel=${String(r.parallel)}`),r.cache||x.push("--no-cache"),r.dryRun&&x.push("--dry-run"),r.partition&&x.push(`--partition=${String(r.partition)}`),await n.runCommand("run",{argv:x})},"execute"),name:"affected",options:[{defaultValue:"HEAD~1",description:"Git base ref for comparison",name:"base",type:String},{defaultValue:"HEAD",description:"Git head ref for comparison",name:"head",type:String},{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep" — controls how far to include dependents of changed projects',name:"downstream",type:String},{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep" — controls how far to include dependencies of changed projects',name:"upstream",type:String},{defaultValue:3,description:"Maximum number of parallel tasks",name:"parallel",type:Number},{defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean},{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean},{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',name:"partition",type:String}]};var Ll=Object.defineProperty,de=$((t,e)=>Ll(t,"name",{value:e,configurable:!0}),"f$g");const Dt=(1n<<128n)-1n,ee=(1n<<64n)-1n,Dr=(1n<<32n)-1n,rs=0x9E3779B1n,ns=0x85EBCA77n,Fl=0xC2B2AE3Dn,ut=0x9E3779B185EBCA87n,Et=0xC2B2AE3D27D4EB4Fn,os=0x165667B19E3779F9n,Xn=0x85EBCA77C2B2AE63n,Vl=0x27D4EB2F165667C5n,Ul=0x165667919E3779F9n,Gl=0x9FB21C651E98DF25n,tt=64,is=tt/8,zl=8,He=Buffer.from("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e","hex"),ue=de((t,e=0)=>Buffer.from(t.buffer,t.byteOffset+e,t.length-e),"getView"),Wl=de(t=>{const e=Buffer.allocUnsafe(8);return e.writeBigUInt64LE(t),e.readBigUInt64BE()},"bswap64"),_l=de(t=>{let e=t;return e=(e&0x0000FFFFn)<<16n|(e&0xFFFF0000n)>>16n,e=(e&0x00FF00FFn)<<8n|(e&0xFF00FF00n)>>8n,e},"bswap32"),Hl=de((t,e)=>(t&Dr)*(e&Dr)&ee,"multU32ToU64"),Jl=de((t,e)=>(t<<e|t>>32n-e)&Dr,"rotl32"),Cn=de((t,e)=>t^t>>e,"xorshift64"),En=de(t=>~t+1n&ee,"inv64"),ss=de((t,e)=>{const r=t*e&Dt;return r&ee^r>>64n},"mul128Fold64"),Je=de(t=>{let e=t;return e^=e>>37n,e=e*Ul&ee,e^=e>>32n,e},"avalanche"),Mr=de(t=>{let e=t;return e^=e>>33n,e=e*Et&ee,e^=e>>29n,e=e*os&ee,e^=e>>32n,e},"avalanche64"),as=de((t,e,r)=>{for(let n=0;n<is;n++){const i=e.readBigUInt64LE(n*8),o=i^r.readBigUInt64LE(n*8);t[n^1]+=i,t[n]+=Hl(o,o>>32n)}return t},"accumulate512"),Io=de((t,e,r,n)=>{for(let i=0;i<n;i++)as(t,ue(e,i*tt),ue(r,i*8));return t},"accumulate"),ql=de((t,e)=>{for(let r=0;r<is;r++){const n=e.readBigUInt64LE(r*8);let i=t[r];i=Cn(i,47n),i^=n,i*=rs,t[r]=i&ee}return t},"scrambleAcc"),Er=de((t,e)=>ss(t[0]^e.readBigUInt64LE(0),t[1]^e.readBigUInt64LE(zl)),"mix2Accs"),Ro=de((t,e,r)=>{let n=r;return n+=Er(t.slice(0),ue(e,0)),n+=Er(t.slice(2),ue(e,16)),n+=Er(t.slice(4),ue(e,32)),n+=Er(t.slice(6),ue(e,48)),Je(n&ee)},"mergeAccs"),Yl=de((t,e,r)=>{const n=Math.floor((r.byteLength-tt)/8),i=tt*n,o=Math.floor((e.byteLength-1)/i);for(let l=0;l<o;l++)Io(t,ue(e,l*i),r,n),ql(t,ue(r,r.byteLength-tt));const s=Math.floor((e.byteLength-1-i*o)/tt);return Io(t,ue(e,o*i),r,s),as(t,ue(e,e.byteLength-tt),ue(r,r.byteLength-tt-7)),t},"hashLong"),Xl=de((t,e)=>{const r=new BigUint64Array([Fl,ut,Et,os,Xn,ns,Vl,rs]);Yl(r,t,e);const n=Ro(r,ue(e,11),BigInt(t.byteLength)*ut&ee);return Ro(r,ue(e,e.byteLength-tt-11),~(BigInt(t.byteLength)*Et)&ee)<<64n|n},"hashLong128b"),Oo=de((t,e,r)=>ss((t.readBigUInt64LE(0)^e.readBigUInt64LE(0)+r)&ee,(t.readBigUInt64LE(8)^e.readBigUInt64LE(8)-r)&ee),"mix16B"),Or=de((t,e,r,n,i)=>{let o=t&ee,s=t>>64nⅇreturn o+=Oo(e,n,i),o^=r.readBigUInt64LE(0)+r.readBigUInt64LE(8),o&=ee,s+=Oo(r,ue(n,16),i),s^=e.readBigUInt64LE(0)+e.readBigUInt64LE(8),s&=ee,s<<64n|o},"mix32B"),Kl=de((t,e,r)=>{const n=t.byteLength,i=BigInt(t.readUInt8(n-1))|BigInt(n<<8)|BigInt(t.readUInt8(0)<<16)|BigInt(t.readUInt8(n>>1)<<24),o=(BigInt(e.readUInt32LE(0))^BigInt(e.readUInt32LE(4)))+r,s=(i^o)&ee,l=(BigInt(e.readUInt32LE(8))^BigInt(e.readUInt32LE(12)))-r,d=(Jl(_l(i),13n)^l)ⅇreturn(Mr(d)&ee)<<64n|Mr(s)},"len1to3_128b"),Ql=de((t,e,r)=>{const n=t.byteLength,i=t.readUInt32LE(0),o=t.readUInt32LE(n-4),s=BigInt(i)|BigInt(o)<<32n,l=(e.readBigUInt64LE(16)^e.readBigUInt64LE(24))+rⅇlet d=(s^l)*(ut+(BigInt(n)<<2n))&Dt;return d+=(d&ee)<<65n,d&=Dt,d^=d>>67n,Cn(Cn(d&ee,35n)*Gl&ee,28n)|Je(d>>64n)<<64n},"len4to8_128b"),Zl=de((t,e,r)=>{const n=t.byteLength,i=(e.readBigUInt64LE(32)^e.readBigUInt64LE(40))+r&ee,o=(e.readBigUInt64LE(48)^e.readBigUInt64LE(56))-r&ee,s=t.readBigUInt64LE();let l=t.readBigUInt64LE(n-8),d=(s^l^i)*ut;const f=(d&ee)+(BigInt(n-1)<<54n);d=d&(Dt^ee)|f,l^=o,d+=l+(l&Dr)*(ns-1n)<<64n,d&=Dt,d^=Wl(d>>64n);let p=(d&ee)*Et;return p+=(d>>64n)*Et<<64n,p&=Dt,Je(p&ee)|Je(p>>64n)<<64n},"len9to16_128b"),ed=de((t,e)=>{const r=t.byteLength;return r>8?Zl(t,He,e):r>=4?Ql(t,He,e):r>0?Kl(t,He,e):Mr(e^He.readBigUInt64LE(64)^He.readBigUInt64LE(72))|Mr(e^He.readBigUInt64LE(80)^He.readBigUInt64LE(88))<<64n},"len0to16_128b"),td=de((t,e,r)=>{let n=BigInt(t.byteLength)*ut&ee,i=BigInt(t.byteLength-1)/32n;for(;i>=0n;){const l=Number(i);n=Or(n,ue(t,16*l),ue(t,t.byteLength-16*(l+1)),ue(e,32*l),r),i--}let o=n+(n>>64n)ⅇo=Je(o);let s=(n&ee)*ut+(n>>64n)*Xn+(BigInt(t.byteLength)-r&ee)*Et;return s&=ee,s=En(Je(s)),o|s<<64n},"len17to128_128b"),rd=de((t,e,r)=>{let n=BigInt(t.byteLength)*utⅇfor(let s=32;s<160;s+=32)n=Or(n,ue(t,s-32),ue(t,s-16),ue(e,s-32),r);n=Je(n&ee)|Je(n>>64n)<<64n;for(let s=160;s<=t.byteLength;s+=32)n=Or(n,ue(t,s-32),ue(t,s-16),ue(e,3+s-160),r);n=Or(n,ue(t,t.byteLength-16),ue(t,t.byteLength-32),ue(e,103),En(r));let i=n+(n>>64n)ⅇi=Je(i);let o=(n&ee)*ut+(n>>64n)*Xn+(BigInt(t.byteLength)-r&ee)*Et;return o&=ee,o=En(Je(o)),i|o<<64n},"len129to240_128b"),nd=de((t,e=0n)=>{const r=t.byteLength;return r<=16?ed(t,e):r<=128?td(t,He,e):r<=240?rd(t,He,e):Xl(t,He)},"xxh3_128"),od=de(t=>{const e=t>>64n&ee,r=tⅇreturn e.toString(16).padStart(16,"0")+r.toString(16).padStart(16,"0")},"bigintToHex"),cs=de(t=>od(nd(t)),"xxh3Hash");class id{static{$(this,"gn")}static{de(this,"Xxh3Hasher")}#e=[];update(e){return typeof e=="string"?this.#e.push(Buffer.from(e)):this.#e.push(e),this}digest(){return cs(Buffer.concat(this.#e))}}de(()=>new id,"createXxh3Hasher");var sd=Object.defineProperty,ht=$((t,e)=>sd(t,"name",{value:e,configurable:!0}),"i$8");const hr=ht(()=>T(Oe(),".vis","cache","ai"),"getCacheDirectory"),ad=3600*1e3,cd=1800*1e3,ld=ht(()=>{const t=hr();F(t)||$e(t,{recursive:!0})},"ensureCacheDirectory"),dd=ht((t,e,r)=>{const n=r.map(o=>({currentRange:o.currentRange,name:o.packageName,targetVersion:o.targetVersion})).toSorted((o,s)=>o.name.localeCompare(s.name)),i=JSON.stringify({analysisType:e,packages:n,provider:t});return cs(Buffer.from(i))},"buildCacheKey"),ud=ht(t=>{const e=T(hr(),`${t}.json`);if(F(e))try{const r=K(e,"utf8"),n=JSON.parse(r);if(Date.now()-n.createdAt>n.ttlMs){lt(e,{force:!0});return}return n.result}catch{lt(e,{force:!0});return}},"getCachedAnalysis"),pd=ht((t,e,r)=>{ld();const n=hr(),i={createdAt:Date.now(),result:e,ttlMs:r};H(T(n,`${t}.json`),JSON.stringify(i,void 0,2),"utf8")},"setCachedAnalysis"),fd=ht((t,e)=>e!==void 0&&e>0?e:t==="security"?cd:ad,"getTtlForAnalysisType"),gd=ht(()=>{const t=hr();if(!F(t))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const e=ft(t).filter(o=>o.endsWith(".json"));let r=0,n,i;for(const o of e){const s=T(t,o),l=Yr(s);r+=l.size;const{mtimeMs:d}=l;(n===void 0||d<n)&&(n=d),(i===void 0||d>i)&&(i=d)}return{entries:e.length,newestEntry:i,oldestEntry:n,totalSizeBytes:r}},"getCacheStats"),hd=ht(()=>{const t=hr();if(!F(t))return 0;const e=ft(t).filter(r=>r.endsWith(".json"));for(const r of e)lt(T(t,r),{force:!0});return e.length},"clearCache");var md=Object.defineProperty,ve=$((t,e)=>md(t,"name",{value:e,configurable:!0}),"o$d");const Pr={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},Kn=ve(t=>{if(t?.provider){if(!pc.includes(t.provider))return;const n=fc(t.provider);return n.available?n:void 0}const e=gc();if(e.length===0)return;const r={...Pr,...t?.priority};return e.toSorted((n,i)=>(r[i.name]??0)-(r[n.name]??0))[0]},"resolveProvider"),yd=new Set(["defer","review","skip","update"]),vd=new Set(["critical","high","low","medium"]),wd=new Set(["high","low","medium"]),kd=50,mn=30,bd=2,$d=1e3,xd=12e4,Sd=ve(t=>t.map(e=>{const r=e.vulnerabilities&&e.vulnerabilities.length>0?` [VULNERABILITIES: ${e.vulnerabilities.map(i=>`${i.severity} ${i.id}`).join(", ")}]`:"";let n="";if(e.socketReport){const i=Math.round(e.socketReport.score.overall*100),o=[`score:${String(i)}%`];if(e.socketReport.alerts.length>0){const s=e.socketReport.alerts.reduce((d,f)=>(d[f.severity]=(d[f.severity]??0)+1,d),{}),l=Object.entries(s).map(([d,f])=>`${String(f)} ${d}`).join(", ");o.push(`alerts: ${l}`)}o.push(`supply-chain:${String(Math.round(e.socketReport.score.supplyChain*100))}%`),o.push(`quality:${String(Math.round(e.socketReport.score.quality*100))}%`),n=` [SOCKET.DEV: ${o.join(", ")}]`}return`- ${e.packageName}: ${e.currentRange} → ${e.newRange} (${e.updateType})${r}${n}`}).join(`
|
|
16
|
+
`),"buildPackageList"),jr=`Respond ONLY with valid JSON in this exact structure:
|
|
7
17
|
{
|
|
8
18
|
"summary": "Brief overall summary",
|
|
9
19
|
"recommendations": [
|
|
@@ -17,9 +27,9 @@ const sa=oa(import.meta.url),K=typeof globalThis<"u"&&typeof globalThis.process<
|
|
|
17
27
|
}
|
|
18
28
|
],
|
|
19
29
|
"warnings": ["warning1"]
|
|
20
|
-
}`,
|
|
30
|
+
}`,Cd={compatibility:ve(t=>`Analyze the compatibility of these package updates:
|
|
21
31
|
|
|
22
|
-
${
|
|
32
|
+
${t}
|
|
23
33
|
|
|
24
34
|
For each package:
|
|
25
35
|
1. Check peer dependency compatibility
|
|
@@ -28,9 +38,9 @@ For each package:
|
|
|
28
38
|
4. Check for deprecated features being removed
|
|
29
39
|
5. Evaluate Node.js version requirements
|
|
30
40
|
|
|
31
|
-
${
|
|
41
|
+
${jr}`,"compatibility"),impact:ve(t=>`Analyze the impact of updating these npm packages:
|
|
32
42
|
|
|
33
|
-
${
|
|
43
|
+
${t}
|
|
34
44
|
|
|
35
45
|
For each package, provide:
|
|
36
46
|
1. Risk level (low/medium/high/critical)
|
|
@@ -39,9 +49,9 @@ For each package, provide:
|
|
|
39
49
|
4. Known breaking changes (if any)
|
|
40
50
|
5. Estimated migration effort (low/medium/high)
|
|
41
51
|
|
|
42
|
-
${
|
|
52
|
+
${jr}`,"impact"),recommend:ve(t=>`Provide smart recommendations for updating these packages:
|
|
43
53
|
|
|
44
|
-
${
|
|
54
|
+
${t}
|
|
45
55
|
|
|
46
56
|
Consider:
|
|
47
57
|
1. Update priority based on security, features, and stability
|
|
@@ -49,10 +59,11 @@ Consider:
|
|
|
49
59
|
3. Best practices for the specific package ecosystem
|
|
50
60
|
4. Risk vs. benefit analysis
|
|
51
61
|
5. Suggested update order
|
|
62
|
+
6. If Socket.dev scores are provided, prioritize packages with low supply chain or quality scores
|
|
52
63
|
|
|
53
|
-
${
|
|
64
|
+
${jr}`,"recommend"),security:ve(t=>`Analyze the security implications of these package updates:
|
|
54
65
|
|
|
55
|
-
${
|
|
66
|
+
${t}
|
|
56
67
|
|
|
57
68
|
For each package:
|
|
58
69
|
1. Check if the update fixes known vulnerabilities (use the vulnerability data above)
|
|
@@ -60,39 +71,670 @@ For each package:
|
|
|
60
71
|
3. Evaluate if this is a security-sensitive package (auth, crypto, session, etc.)
|
|
61
72
|
4. Recommend urgency of the update based on vulnerability severity
|
|
62
73
|
5. Flag any packages where skipping the update poses security risk
|
|
74
|
+
6. If Socket.dev scores are provided, factor in supply chain and quality scores — low scores indicate higher risk
|
|
63
75
|
|
|
64
|
-
${
|
|
65
|
-
`)),
|
|
66
|
-
|
|
67
|
-
${
|
|
68
|
-
`)
|
|
69
|
-
`),
|
|
70
|
-
`),
|
|
71
|
-
`);
|
|
72
|
-
|
|
73
|
-
`),
|
|
74
|
-
`);
|
|
75
|
-
`);return}const o=
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`)){
|
|
79
|
-
`)
|
|
80
|
-
`),"
|
|
81
|
-
${o.toString()}
|
|
82
|
-
`)}},"formatOutdatedTable"),Vt=d(e=>{const t=e.filter(i=>i.updateType==="major").length,a=e.filter(i=>i.updateType==="minor").length,n=e.filter(i=>i.updateType==="patch").length,r=e.filter(i=>i.vulnerabilities&&i.vulnerabilities.length>0).length,o=[];t&&o.push(`${String(t)} major`),a&&o.push(`${String(a)} minor`),n&&o.push(`${String(n)} patch`),r&&o.push(`${String(r)} with vulnerabilities`);const s=`Found ${String(e.length)} outdated (${o.join(", ")})`;return ct(s,{headerText:"Summary",padding:{left:1,right:1}})},"formatSummary"),Jr=d((e,t)=>{const a=e.replaceAll(Ze,String.raw`\$&`),n=t.replaceAll(Ze,String.raw`\$&`);return new RegExp(String.raw`^(?:'${a}'|"${a}"|${a}):\s*['"]?${n}['"]?`)},"buildLineMatchRegex"),Wr=d((e,t,a)=>Jr(t,a).test(e),"lineMatchesPackage"),_r=d(e=>{const t=new Map;for(const a of e){t.has(a.catalogName)||t.set(a.catalogName,new Map);const n=t.get(a.catalogName);n&&n.set(a.packageName,{newRange:a.newRange,oldRange:a.currentRange})}return t},"buildUpdateMap"),at=d((e,t,a)=>{if(!a)return e;for(const[n,{newRange:r,oldRange:o}]of a)if(Wr(t,n,o))return e.replace(o,r);return e},"applyLineUpdate"),zr=d((e,t,a,n)=>{const r=e.trimStart(),o=e.length-r.length;return r.length===0||r.startsWith("#")?e:t==="catalog"&&o>=2?at(e,r,n.get("default")):t==="catalogs"&&o>=4&&a?at(e,r,n.get(a)):e},"processYamlLineForUpdate"),Hr=d((e,t)=>{const a=u(e,"pnpm-workspace.yaml"),n=A(a).split(`
|
|
83
|
-
`),r=_r(t);let o="none",s="";const i=[];for(const c of n){const l=c.trimStart(),p=c.length-l.length;p===0&&l.length>0&&!l.startsWith("#")&&(o=Bt(l),o==="catalogs"&&(s="")),o==="catalogs"&&p===2&&l.endsWith(":")&&(s=l.slice(0,-1).trim().replaceAll(Ct,"")),i.push(zr(c,o,s,r))}te(a,i.join(`
|
|
84
|
-
`))},"applyPnpmCatalogUpdates");d(e=>{const t=rr.exec(e);if(!t)return 2;const a=t[1];return a?a.includes(" ")?a:a.length:2},"detectJsonIndent");const Gr=d((e,t)=>{const a=u(e,"package.json"),n=W(a);for(const r of t)if(r.catalogName==="default")n.workspaces?.catalog&&(n.workspaces.catalog[r.packageName]=r.newRange);else{const o=n.workspaces?.catalogs?.[r.catalogName];o&&(o[r.packageName]=r.newRange)}st(a,n,{detectIndent:!0,overwrite:!0})},"applyBunCatalogUpdates"),qr=d((e,t,a,n=!0)=>{let r;return n&&(r=Lr(e,a,t)),a==="npm"||a==="yarn"?kr(e,t):a==="bun"?Gr(e,t):Hr(e,t),r},"applyCatalogUpdates"),Kr=d(async e=>{const{createInterface:t}=await import("node:readline"),a=t({input:process.stdin,output:process.stdout}),n=d(o=>new Promise(s=>{a.question(o,i=>s(i.trim()))}),"ask");process.stdout.write(`
|
|
76
|
+
${jr}`,"security")},Ed=new Set(["compatibility","impact","recommend","security"]),Qn=ve(t=>Ed.has(t)?t:"impact","validateAnalysisType"),ls=ve((t,e="impact")=>{const r=Sd(t);return Cd[e](r)},"buildAnalysisPrompt"),jd=/```(?:json)?\s*([\s\S]*?)```/,Td=/\{[\s\S]*\}/,Ad=ve(t=>{try{return JSON.parse(t)}catch{}const e=jd.exec(t);if(e?.[1])try{return JSON.parse(e[1])}catch{}const r=Td.exec(t);if(r?.[0])try{return JSON.parse(r[0])}catch{}},"extractJson"),Id=ve(t=>({action:yd.has(t.action)?t.action:"review",breakingChanges:Array.isArray(t.breakingChanges)?t.breakingChanges:[],effort:wd.has(t.effort)?t.effort:"medium",package:typeof t.package=="string"?t.package:"",reason:typeof t.reason=="string"?t.reason:"",riskLevel:vd.has(t.riskLevel)?t.riskLevel:"medium"}),"normalizeRecommendation"),ds=ve((t,e,r)=>{const n=Ad(t);if(!n||typeof n!="object")return{analysisType:r,provider:e,recommendations:[],summary:"Failed to parse AI response.",warnings:["AI response was not valid JSON."]};const i=n,o=Array.isArray(i.recommendations)?i.recommendations:[];return{analysisType:r,provider:e,recommendations:o.map(s=>Id(s)),summary:typeof i.summary=="string"?i.summary:"",warnings:Array.isArray(i.warnings)?i.warnings:[]}},"parseAiResponse"),Rd={eslint:["ESLint 9.0: Flat config required","ESLint 8.0+: New rule formats"],next:["Next.js 13+: App router changes","Next.js 14+: Server components default"],react:["React 17 to 18: Concurrent features","React 18+: Strict mode changes"],typescript:["TypeScript 5.0: New decorators","TypeScript 4.7+: ESM changes"],vite:["Vite 5: Node.js 18+ required"],vue:["Vue 3: Composition API","Vue 3: Breaking template changes"],webpack:["Webpack 5: Node.js polyfills removed"]},Od=new Set(["bcrypt","cors","crypto-js","express-session","helmet","jose","jsonwebtoken","node-forge","oauth","passport"]),Po=ve((t,e)=>{const r=t.map(n=>{const i=n.vulnerabilities&&n.vulnerabilities.length>0,o=Od.has(n.packageName),s=Rd[n.packageName]??[];let l="low",d="update",f="low",p="Patch/minor update, safe to apply.";return n.updateType==="major"?(l="high",d=s.length>0?"review":"update",f="medium",p=s.length>0?`Major update with known breaking changes: ${s[0]}`:"Major version update, review changelog before applying."):n.updateType==="minor"&&(l="medium",p="Minor update, generally safe."),i&&(l="high",d="update",p="Security update — current version has known vulnerabilities."),o&&n.updateType==="major"&&(d="review",p="Security-sensitive package with major update, careful review needed.",f="high"),{action:d,breakingChanges:s,effort:f,package:n.packageName,reason:p,riskLevel:l}});return{analysisType:e,provider:"rule-engine",recommendations:r,summary:`Rule-based ${e} analysis for ${String(t.length)} packages.`,warnings:["No AI provider available — using built-in rule engine."]}},"ruleBasedAnalysis"),Pd=ve(t=>new Promise(e=>{setTimeout(e,t)}),"sleep"),us=ve(async(t,e,r=bd)=>{let n;for(let i=0;i<=r;i+=1)try{return(await Mi(t,e,{timeoutMs:xd})).stdout}catch(o){if(n=o instanceof Error?o:new Error(String(o)),n.message.includes("timed out"))throw n;if(i<r){const s=$d*2**i;await Pd(s)}}throw n??new Error("AI analysis failed after retries")},"runWithRetry"),Nd=ve(async(t,e,r)=>{const n=ls(e,r),i=await us(t,n);return ds(i,t.name,r)},"analyzeChunk"),Dd=ve((t,e,r)=>{const n=[],i=[],o=[];for(const s of t)n.push(...s.recommendations),i.push(...s.warnings),s.summary&&o.push(s.summary);return{analysisType:r,provider:e,recommendations:n,summary:o.length===1?o[0]??"":`Analyzed ${String(n.length)} packages in ${String(t.length)} batches.`,warnings:[...new Set(i)]}},"mergeResults"),ps={compatibility:"Compatibility",impact:"Impact",recommend:"Recommendations",security:"Security"},Br=ve(t=>{const e=`${ps[t.analysisType]??t.analysisType} Analysis (${t.provider})`,r=t.recommendations.flatMap(i=>{const o=[{action:i.action,effort:i.effort,package:i.package,reason:i.reason,risk:i.riskLevel}];return i.breakingChanges.length>0&&o.push({action:"",effort:"",package:"",reason:`Breaking: ${i.breakingChanges.join("; ")}`,risk:""}),o}),n=process.stdout.columns||80;return ge(_.createElement(g,{borderStyle:"round",flexDirection:"column",paddingLeft:1,paddingRight:1},_.createElement(a,{bold:!0},e),_.createElement(a,null,""),_.createElement(a,null,t.summary),_.createElement(a,null,""),_.createElement(Vn,{borderStyle:"none",data:r}),...t.warnings.length>0?[_.createElement(a,null,""),...t.warnings.map((i,o)=>_.createElement(a,{dimColor:!0,key:String(o)},` ${i}`))]:[]),{columns:n})},"formatAiAnalysis");ve(t=>JSON.stringify(t,void 0,2),"formatAiAnalysisJson");const Zn=ve(async(t,e,r,n="impact")=>{const i=Kn(r);if(!i)return e.info(`No AI CLI tool found, using rule-based analysis.
|
|
77
|
+
`),Po(t,n);const o=dd(i.name,n,t),s=ud(o);if(s)return e.info(`Using cached ${n} analysis from ${s.provider}.
|
|
78
|
+
`),s;const l=ps[n]??n;e.info(`Running ${l.toLowerCase()} analysis with ${i.name}...
|
|
79
|
+
`);try{let d;if(t.length>kd){e.info(`Splitting ${String(t.length)} packages into batches of ${String(mn)}...
|
|
80
|
+
`);const f=[];for(let h=0;h<t.length;h+=mn)f.push(t.slice(h,h+mn));const p=[];for(let h=0;h<f.length;h+=1){e.info(` Batch ${String(h+1)}/${String(f.length)}...`);const m=f[h];m&&p.push(await Nd(i,m,n))}d=Dd(p,i.name,n)}else{const f=await us(i,ls(t,n));d=ds(f,i.name,n)}return pd(o,d,fd(n,r?.cacheTtl)),d}catch(d){const f=d instanceof Error?d.message:String(d);return e.warn(`AI analysis failed (${f}), falling back to rule engine.
|
|
81
|
+
`),Po(t,n)}},"runAiAnalysis");var Md=Object.defineProperty,nn=$((t,e)=>Md(t,"name",{value:e,configurable:!0}),"c$g");const Bd=nn((t,e)=>{const r=gd();if(t==="json"){process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
82
|
+
`);return}e.info("AI Cache Statistics:"),e.info(` Entries: ${String(r.entries)}`),e.info(` Total size: ${String(Math.round(r.totalSizeBytes/1024))} KB`),e.info(` Oldest: ${r.oldestEntry?new Date(r.oldestEntry).toISOString():"N/A"}`),e.info(` Newest: ${r.newestEntry?new Date(r.newestEntry).toISOString():"N/A"}`)},"handleCacheStats"),Ld=nn(async(t,e)=>{const r=Kn(e);if(!r){t.error("No AI provider available to test."),process.exitCode=1;return}t.info(`Testing ${r.name}...`);try{const n=await Mi(r,"Reply with exactly: OK",{timeoutMs:3e4});t.info(`Provider ${r.name} responded: ${n.stdout.trim().slice(0,200)}`)}catch(n){const i=n instanceof Error?n.message:String(n);t.error(`Provider ${r.name} failed: ${i}`),process.exitCode=1}},"handleTest"),Fd=nn((t,e,r)=>{const n=hc(),i=Kn(r);if(t==="json"){const d=n.map(f=>({available:f.available,method:f.detectionMethod,name:f.name,path:f.path,priority:Pr[f.name]??0,selected:f.name===i?.name,version:f.version}));process.stdout.write(`${JSON.stringify(d,void 0,2)}
|
|
83
|
+
`);return}const o=n.map(d=>({method:d.detectionMethod??"-",path:d.path??"-",priority:String(Pr[d.name]??0),provider:d.name,selected:d.name===i?.name?">>>":"",status:d.available?"available":"not found",version:d.version??"-"})),s=process.stdout.columns||80,l=ge(_.createElement(Vn,{data:o}),{columns:s});e.info(l),i?e.info(`
|
|
84
|
+
Selected provider: ${i.name} (priority ${String(Pr[i.name]??0)})`):e.info(`
|
|
85
|
+
No AI provider available. Install one of the supported AI CLI tools.`)},"handleProviderStatus"),Vd={group:"System",alias:"a",description:"Show AI provider status, test connectivity, and manage cache",examples:[["vis ai","Show all AI providers and their status"],["vis ai --test","Test the best available provider"],["vis ai --cache-stats","Show AI response cache statistics"],["vis ai --clear-cache","Clear the AI response cache"],["vis ai --format json","Output as JSON"]],execute:nn(async({logger:t,options:e,visConfig:r})=>{const n=e.format??"table";if(e.cacheStats){Bd(n,t);return}if(e.clearCache){const i=hd(),o=sl();t.info(`Cleared ${String(i)} cached AI response${i===1?"":"s"}.`),o>0&&t.info(`Cleared ${String(o)} cached Socket.dev report${o===1?"":"s"}.`);return}if(e.test){await Ld(t,r?.ai);return}Fd(n,t,r?.ai)},"execute"),name:"ai",options:[{defaultValue:!1,description:"Test the best available AI provider with a quick prompt",name:"test",type:Boolean},{defaultValue:!1,description:"Show AI response cache statistics",name:"cache-stats",type:Boolean},{defaultValue:!1,description:"Clear the AI response cache",name:"clear-cache",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]};var Ud=Object.defineProperty,N=$((t,e)=>Ud(t,"name",{value:e,configurable:!0}),"c$f");const Gd=/^([\^~]|>=|<=|[><=])/,zd=/^(?:'([^']+)'|"([^"]+)"|([^:\s]+)):\s*(?:'([^']+)'|"([^"]+)"|(\S+))/,Wd=/^catalog:/m,_d=/^catalogs:/m,Hd=/^(@[^:]+):registry$/,Jd=/^\/\/(.+)\/:_authToken$/,qd=/\*+/g,Yd=/[.+^${}()|[\]\\]/g,No=/[.*+?^${}()|[\]\\]/g,fs=/^['"]|['"]$/g,Xd=/^https?:\/\//,gs=/\/$/,Kd=/\n(\s+)/,hs=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Qd=new Set([...hs,"overrides","resolutions","pnpm.overrides"]),eo=N(t=>{const e=Vi("vis",{create:!0,cwd:t});if(!e)throw new Error("Cannot resolve cache directory. Ensure node_modules exists in your workspace. Run your package manager's install command first.");return T(e,"backup")},"getBackupDir"),nt=N(t=>{const e=t.replace(/^[\^~]|^>=|^<=|^[><]/,""),r=qa(e);if(r)return{major:r.major,minor:r.minor,patch:r.patch,prerelease:Array.isArray(r.prerelease)?r.prerelease.join("."):String(r.prerelease??"")};const n=qr(t);if(n)return{major:n.major,minor:n.minor,patch:n.patch,prerelease:""}},"parseVersion"),to=N(t=>Gd.exec(t)?.[1]??"","extractPrefix"),Zd=N(t=>{const e=`${String(t.major)}.${String(t.minor)}.${String(t.patch)}`;return t.prerelease?`${e}-${t.prerelease}`:e},"versionToString"),ms=N((t,e)=>t.major!==e.major?"major":t.minor!==e.minor?"minor":t.patch!==e.patch||t.prerelease!==e.prerelease?"patch":"none","getUpdateType"),eu=N((t,e)=>t.major!==e.major?t.major-e.major:t.minor!==e.minor?t.minor-e.minor:t.patch!==e.patch?t.patch-e.patch:!t.prerelease&&e.prerelease?1:t.prerelease&&!e.prerelease?-1:t.prerelease&&e.prerelease?t.prerelease<e.prerelease?-1:t.prerelease>e.prerelease?1:0:0,"compareVersions"),ys=N((t,e)=>eu(e,t)>0,"isNewer"),ir=N((t,e)=>{const r=e.replaceAll(qd,"*").replaceAll(Yd,String.raw`\$&`);return new RegExp(`^${r.replaceAll("*",".*").replaceAll("?",".")}$`).test(t)},"matchesPattern"),tu=N((t,e,r)=>r.some(n=>ir(t,n))?!1:e.length>0?e.some(n=>ir(t,n)):!0,"matchesFilters"),vs=N(t=>{const e=zd.exec(t);if(!e)return;const r=e[1]??e[2]??e[3],n=e[4]??e[5]??e[6];if(!(!r||!n))return[r,n]},"parseYamlEntry"),ws=N((t,e,r,n)=>{t.has(e)||t.set(e,new Map);const i=t.get(e);i&&i.set(r,n)},"setCatalogEntry"),ru=N((t,e,r)=>{if(r<2)return;const n=vs(e);n&&ws(t,"default",n[0],n[1])},"parseCatalogSection"),nu=N((t,e,r,n)=>{if(r===2&&e.endsWith(":"))return e.slice(0,-1).trim().replaceAll(fs,"");if(r>=4&&n){const i=vs(e);i&&ws(t,n,i[0],i[1])}return n},"parseCatalogsSection"),ks=N(t=>t==="catalog:"||t.startsWith("catalog:")?"catalog":t==="catalogs:"||t.startsWith("catalogs:")?"catalogs":"none","detectTopLevelSection"),ou=N(t=>{const e=new Map;let r="none",n="";for(const i of t.split(`
|
|
86
|
+
`)){const o=i.trimStart(),s=i.length-o.length;if(s===0&&o.length>0&&!o.startsWith("#")){r=ks(o),r==="catalogs"&&(n="");continue}o.length===0||o.startsWith("#")||(r==="catalog"&&ru(e,o,s),r==="catalogs"&&(n=nu(e,o,s,n)))}return e},"parseCatalogsFromYaml"),iu=N(t=>{const e=T(t,"pnpm-workspace.yaml");if(!le(e))return!1;const r=Xe(e);return Wd.test(r)||_d.test(r)},"hasPnpmCatalogs"),su=N(t=>{const e=T(t,"pnpm-workspace.yaml");if(!le(e))return new Map;const r=Xe(e);return ou(r)},"readPnpmCatalogs"),bs=N(t=>{if(le(t))try{return Ue(t)}catch{return}},"readPackageJsonSafe"),au=N(t=>{const e=bs(T(t,"package.json"));return!!(e?.workspaces?.catalog||e?.workspaces?.catalogs)},"hasBunCatalogs"),cu=N(t=>{const e=new Map;if(t.workspaces?.catalog&&typeof t.workspaces.catalog=="object"&&e.set("default",new Map(Object.entries(t.workspaces.catalog))),t.workspaces?.catalogs&&typeof t.workspaces.catalogs=="object")for(const[r,n]of Object.entries(t.workspaces.catalogs))typeof n=="object"&&n!==void 0&&e.set(r,new Map(Object.entries(n)));return e},"parseBunCatalogs"),lu=N(t=>{const e=bs(T(t,"package.json"));return e?cu(e):new Map},"readBunCatalogs"),mr=N(t=>{const e=t.lastIndexOf(":");if(e===-1)return;const r=t.slice(e+1);if(Qd.has(r))return{depType:r,relativePath:t.slice(0,e)}},"parseCompositeCatalogName"),du=N(t=>t?.dev?["devDependencies"]:t?.prod?["dependencies"]:t?.depFields&&t.depFields.length>0?t.depFields:hs,"getDepTypesToInclude"),uu=N((t,e,r)=>{const n=new Set;e&&n.add(e);for(const i of r){const o=T(t,i,"package.json");if(le(o))try{const s=Ue(o);s.name&&n.add(s.name)}catch{}}return n},"collectInternalPackageNames"),$s=N((t,e)=>{const r=e.split(".");let n=t;for(const i of r)if(n&&typeof n=="object")n=n[i];else return;return typeof n=="object"&&n!==null?n:void 0},"getNestedField"),pu=N((t,e,r,n)=>{const i=e.split(".");let o=t;for(const l of i.slice(0,-1))(!o[l]||typeof o[l]!="object")&&(o[l]={}),o=o[l];const s=i.at(-1);(!o[s]||typeof o[s]!="object")&&(o[s]={}),o[s][r]=n},"setNestedField"),fu=N((t,e)=>{const r=new Map;for(const[n,i]of Object.entries(t))e.has(n)||i.startsWith("workspace:")||i.startsWith("file:")||i.startsWith("link:")||i.startsWith("catalog:")||i.startsWith("$")||r.set(n,i);return r},"filterExternalDeps"),gu=N((t,e,r,n,i,o)=>{const s=e==="."?r:T(t,e,"package.json");if(!le(s))return;let l;try{l=Ue(s)}catch{return}for(const d of n){const f=d.includes(".")?$s(l,d):l[d];if(!f||typeof f!="object")continue;const p=fu(f,i);p.size>0&&o.set(`${e}:${d}`,p)}},"scanDirectoryDeps"),hu=N((t,e)=>{const r=new Map,n=T(t,"package.json");if(!le(n))return r;const i=Ue(n);let o=[];const s=i.workspaces;if(s){const p=Array.isArray(s)?s:s.packages;p&&(o=Ct(t,p))}if(o.length===0){const p=tn(t);p&&(o=Ct(t,p))}const l=uu(t,i.name,o),d=du(e),f=[".",...o];for(const p of f)gu(t,p,n,d,l,r);return r},"readPackageJsonDeps"),yn=N(t=>{const e=T(t,"package.json");if(!le(e))return!1;try{const r=Ue(e);return!!(r.dependencies||r.devDependencies||r.peerDependencies||r.optionalDependencies||r.overrides||r.resolutions||$s(r,"pnpm.overrides"))}catch{return!1}},"hasPackageJsonDeps"),Do=N((t,e)=>{const r=new Map;for(const n of e){const i=mr(n.catalogName);if(!i)continue;const o=i.relativePath==="."?T(t,"package.json"):T(t,i.relativePath,"package.json");r.has(o)||r.set(o,[]);const s=r.get(o);s&&s.push({depType:i.depType,newRange:n.newRange,packageName:n.packageName})}for(const[n,i]of r){const o=Ue(n);for(const{depType:s,newRange:l,packageName:d}of i)s.includes(".")?pu(o,s,d,l):o[s]&&(o[s][d]=l);Bn(n,o,{detectIndent:!0,overwrite:!0})}},"applyPackageJsonUpdates"),mu=N((t,e)=>e==="bun"?au(t)||yn(t):e==="npm"||e==="yarn"?yn(t):iu(t)||yn(t),"hasCatalogs"),on=N((t,e,r)=>{let n;e==="bun"?n=lu(t):e==="npm"||e==="yarn"?n=new Map:n=su(t);const i=hu(t,r);for(const[o,s]of i)n.has(o)||n.set(o,s);return n},"readCatalogs"),Mo=N(t=>{const e=new Map,r=new Map;let n="https://registry.npmjs.org";for(const i of t.split(`
|
|
87
|
+
`)){const o=i.trim();if(!o||o.startsWith("#")||o.startsWith(";"))continue;const s=o.indexOf("=");if(s===-1)continue;const l=o.slice(0,s).trim(),d=o.slice(s+1).trim(),f=Hd.exec(l);if(f?.[1]){e.set(f[1],d);continue}if(l==="registry"){n=d;continue}const p=Jd.exec(l);p?.[1]&&r.set(p[1],d)}return{authTokens:r,defaultRegistry:n,registries:e}},"parseNpmrc"),yu=N((t,e)=>({authTokens:new Map([...t.authTokens,...e.authTokens]),defaultRegistry:e.defaultRegistry==="https://registry.npmjs.org"?t.defaultRegistry:e.defaultRegistry,registries:new Map([...t.registries,...e.registries])}),"mergeNpmrcConfigs"),ro=N(t=>{const e={authTokens:new Map,defaultRegistry:"https://registry.npmjs.org",registries:new Map},r=process.env.HOME??process.env.USERPROFILE??"",n=T(r,".npmrc");let i=r&&le(n)?Mo(Xe(n)):e;const o=T(t,".npmrc");return le(o)&&(i=yu(i,Mo(Xe(o)))),i},"loadNpmrc"),vu=N((t,e)=>{let r=e.defaultRegistry;if(t.startsWith("@")){const i=t.split("/")[0];if(i&&e.registries.has(i)){const o=e.registries.get(i);o&&(r=o)}}const n=r.replace(Xd,"").replace(gs,"");return{token:e.authTokens.get(n),url:r}},"getRegistryForPackage"),xs=15e3,Ss=N(async(t,e,r=xs,n=!1)=>{const i=`${(e?.url??"https://registry.npmjs.org").replace(gs,"")}/${t}`,o=n?{Accept:"application/json"}:{Accept:"application/vnd.npm.install-v1+json"};e?.authToken&&(o.Authorization=`Bearer ${e.authToken}`);const s=new AbortController,l=setTimeout(()=>{s.abort()},r);try{const d=await fetch(i,{headers:o,signal:s.signal});if(!d.ok)throw new Error(`Failed to fetch ${t}: ${String(d.status)} ${d.statusText}`);const f=await d.json(),p={latest:f["dist-tags"]?.latest??"",versions:Object.keys(f.versions??{})};return n&&f.time&&(p.publishTimes=new Map(Object.entries(f.time))),p}finally{clearTimeout(l)}},"fetchPackageVersions"),wu=N(t=>{const e=t.database_specific?.severity?.toUpperCase();if(e==="CRITICAL"||e==="HIGH"||e==="MODERATE"||e==="LOW")return e;const r=t.severity?.find(n=>n.type==="CVSS_V3")?.score;if(r){const n=Number.parseFloat(r);return n>=9?"CRITICAL":n>=7?"HIGH":n>=4?"MODERATE":"LOW"}return"UNKNOWN"},"mapOsvSeverity"),ku=N(t=>{const e=t.severity?.find(r=>r.type==="CVSS_V3")?.score;return e?Number.parseFloat(e):void 0},"mapOsvCvss"),bu=N(t=>{const e=[];for(const r of t.affected??[])for(const n of r.ranges??[])for(const i of n.events??[])i.fixed&&e.push(i.fixed);return e},"mapOsvFixedVersions"),$u=N(t=>({aliases:t.aliases?.length?t.aliases:void 0,cvssScore:ku(t),fixedVersions:bu(t),id:t.id,severity:wu(t),summary:t.summary??""}),"mapOsvVuln"),sn=N(async(t,e=1e4)=>{if(t.length===0)return new Map;const r=t.map(o=>({package:{ecosystem:"npm",name:o.name},version:o.version})),n=new AbortController,i=setTimeout(()=>{n.abort()},e);try{const o=await fetch("https://api.osv.dev/v1/querybatch",{body:JSON.stringify({queries:r}),headers:{"Content-Type":"application/json"},method:"POST",signal:n.signal});if(!o.ok)return new Map;const s=await o.json(),l=new Map;for(const[d,f]of t.entries()){const p=s.results[d]?.vulns;p&&p.length>0&&l.set(f.name,p.map(h=>$u(h)))}return l}catch{return new Map}finally{clearTimeout(i)}},"fetchVulnerabilities"),Bo=new Map,xu=N((t,e,r)=>{if(!r)return e;for(const[n,i]of Object.entries(r))if(n.startsWith("/")&&n.endsWith("/")){let o=Bo.get(n);if(o||(o=new RegExp(n.slice(1,-1)),Bo.set(n,o)),o.test(t))return i}else if(n===t||ir(t,n))return i;return e},"resolvePackageTarget"),Cs=N((t,e,r)=>{const n=e?.get(t);return n?Date.now()-new Date(n).getTime()<r:!1},"isTooNew"),Su=N(t=>t?.minimumReleaseAge?t.packageName&&t.minimumReleaseAgeExclude?.some(e=>ir(t.packageName,e))?0:t.minimumReleaseAge*60*1e3:0,"resolveMinAgeMs"),Lo=N((t,e,r,n,i,o)=>t.map(s=>({parsed:nt(s),raw:s})).filter(s=>!s.parsed||!r&&s.parsed.prerelease!==""||!ys(e,s.parsed)||n&&Cs(s.raw,i,n)?!1:o?o(s.parsed):!0).toSorted((s,l)=>Ja(s.raw,l.raw))[0]?.raw,"filterCandidates"),Cu=N((t,e,r,n,i,o)=>{const s=nt(r);if(!s)return;const l=Su(o);if(n==="latest"){const f=nt(e);return!f||!i&&f.prerelease!==""||!ys(s,f)?void 0:!l||!Cs(e,o?.publishTimes,l)?e:Lo(t,s,i,l,o?.publishTimes)}const d=n==="patch"?f=>f.major===s.major&&f.minor===s.minor:f=>f.major===s.major;return Lo(t,s,i,l,o?.publishTimes,d)},"findTargetVersion"),Eu=N((t,e)=>{const r=[],n=new Set;for(const[i,o]of t)for(const[s,l]of o)if(!(l.startsWith("workspace:")||l.startsWith("file:")||l.startsWith("link:")||l==="*")&&!(!e.includeLocked&&!to(l))){if(e.ignore.some(d=>ir(s,d))){n.add(s);continue}tu(s,e.include,e.exclude)&&r.push({catalogName:i,packageName:s,range:l})}return{entries:r,ignored:[...n]}},"collectEntries"),ju=N(async(t,e,r,n=!1)=>{const i=new Map,o=[],s=8;let l=0;for(let d=0;d<t.length;d+=s){const f=t.slice(d,d+s),p=await Promise.allSettled(f.map(async h=>{const m=e?vu(h,e):void 0,y=await Ss(h,m?{authToken:m.token,url:m.url}:void 0,xs,n);return i.set(h,y),h}));for(const[h,m]of p.entries())if(l+=1,m.status==="rejected"){const y=f[h];y&&o.push(y)}r&&r(l,t.length)}return{failed:o,versionCache:i}},"fetchVersionsBatched"),Fo=N((t,e,r)=>{const n=[];for(const i of t){const o=e.get(i.packageName);if(!o)continue;const s=xu(i.packageName,r.target,r.packageMode),l=Cu(o.versions,o.latest,i.range,s,r.includePrerelease,{minimumReleaseAge:r.minimumReleaseAge,minimumReleaseAgeExclude:r.minimumReleaseAgeExclude,packageName:i.packageName,publishTimes:o.publishTimes});if(!l)continue;const d=nt(i.range),f=nt(l);if(!d||!f)continue;const p=ms(d,f);if(p==="none")continue;const h=to(i.range);n.push({catalogName:i.catalogName,currentRange:i.range,newRange:`${h}${l}`,packageName:i.packageName,targetVersion:l,updateType:p})}return n},"buildOutdatedEntries"),Vo=N(t=>t?Zd(t):"","formatVersionString"),Tu=N(async(t,e,r,n)=>{const i=[...new Map(e.map(d=>{const f=nt(d.range);return[d.packageName,{name:d.packageName,version:Vo(f)}]})).values()].filter(d=>d.version),o=r?Wt(i,r):void 0,[s,l]=await Promise.all([sn(i),o]);for(const d of t){const f=s.get(d.packageName);f&&f.length>0&&(d.vulnerabilities=f);const p=nt(d.currentRange),h=Vo(p);if(l){const m=l.get(`${d.packageName}@${h}`);m&&(d.socketReport={alerts:m.alerts,license:m.license,score:m.score})}if(n){const m=Hn(d.packageName,h,n);m&&(d.acceptedRisk=m)}}},"enrichWithSecurity"),Au=6e4,Iu=N((t,e,r,n)=>{const i=[];for(const[l,d]of t)for(const[f,p]of d)i.push(`${l}:${f}=${p}`);if(i.push(`target=${e.target},pre=${String(e.includePrerelease)},sec=${String(e.security??!1)}`),i.push(`in=${e.include.join(",")},ex=${e.exclude.join(",")},ig=${e.ignore.join(",")}`),i.push(`locked=${String(e.includeLocked)}`),i.push(`mra=${String(e.minimumReleaseAge??0)}`),e.packageMode){const l=Object.entries(e.packageMode).map(([d,f])=>`${d}=${f}`).toSorted().join(",");i.push(`pkgMode=${l}`)}i.push(`socket=${String(r??!1)}`),n&&n.length>0&&i.push(`risks=${n.toSorted().join(",")}`);let o=5381;const s=i.join("|");for(let l=0;l<s.length;l++)o=(o<<5)+o+s.charCodeAt(l)|0;return String(o)},"computeCacheHash"),Es=N(t=>{const e=Vi("vis",{create:!0,cwd:t});return e?T(e,"outdated-cache.json"):void 0},"getOutdatedCachePath"),Ru=N((t,e)=>{const r=Es(t);if(!(!r||!le(r)))try{const n=Ue(r);if(n.hash===e&&Date.now()-n.timestamp<Au)return n.result}catch{}},"readOutdatedCache"),Ou=N((t,e,r)=>{const n=Es(t);if(n)try{xn(Ln(n)),Bn(n,{hash:e,result:r,timestamp:Date.now()})}catch{}},"writeOutdatedCache"),no=N(async(t,e,r,n,i,o,s)=>{const l=Iu(t,e,!!o,s?Object.keys(s):void 0);if(i){const C=Ru(i,l);if(C)return C}const{entries:d,ignored:f}=Eu(t,e),p=[...new Set(d.map(C=>C.packageName))],h=!!(e.minimumReleaseAge&&e.minimumReleaseAge>0),{failed:m,versionCache:y}=await ju(p,r,n,h),b=Fo(d,y,e);let x=[];if(e.target!=="latest"){const C=new Set(b.map(P=>P.packageName)),D={...e,packageMode:void 0,target:"latest"};x=Fo(d,y,D).filter(P=>!C.has(P.packageName))}(e.security||o)&&b.length>0&&await Tu(b,d,o,s);const S={checkedCount:p.length,failed:m,filteredByTarget:x,ignored:f,outdated:b};return i&&Ou(i,l,S),S},"checkOutdated"),oo=N((t,e)=>e==="bun"?T(t,"package.json"):T(t,"pnpm-workspace.yaml"),"getCatalogFilePath"),Uo=N((t,e)=>{const r=eo(t),n=new Set;for(const i of e){const o=mr(i.catalogName);o&&n.add(o.relativePath==="."?"package.json":T(o.relativePath,"package.json"))}if(n.size!==0){xn(r);for(const i of n){const o=T(t,i);if(le(o)){const s=T(r,i),l=Ln(s);xn(l),dr(s,Xe(o))}}return r}},"createPackageJsonBackup"),Pu=N((t,e,r)=>{if((e==="npm"||e==="yarn")&&r)return Uo(t,r);let n;const i=oo(t,e);if(le(i)&&(n=`${i}.bak`,dr(n,Xe(i))),r){const o=r.filter(s=>mr(s.catalogName));o.length>0&&Uo(t,o)}return n},"createBackup"),Nu=N(t=>{const e=eo(t);if(!le(e))return!1;for(const r of Mn(e,{includeDirs:!1})){const n=r.path.slice(e.length+1),i=T(t,n);dr(i,Xe(r.path))}return _a(e),!0},"restorePackageJsonBackup"),Du=N((t,e)=>{if(e==="npm"||e==="yarn")return Nu(t);const r=oo(t,e),n=`${r}.bak`;if(!le(n))return!1;const i=Xe(n);return dr(r,i),!0},"restoreFromBackup"),Mu=N((t,e)=>{if(e==="npm"||e==="yarn")try{const n=eo(t);return le(n)}catch{return!1}const r=oo(t,e);return le(`${r}.bak`)},"hasBackup"),Bu=N(t=>JSON.stringify(t,void 0,2),"formatOutdatedJson"),js=N(t=>t.map(e=>`${e.packageName} ${e.currentRange} → ${e.newRange}`).join(`
|
|
88
|
+
`),"formatOutdatedMinimal"),Me=N(t=>t?Array.isArray(t)?t:[t]:[],"toFilterArray"),Lu=N(t=>{const e=new Map;for(const r of t){e.has(r.catalogName)||e.set(r.catalogName,[]);const n=e.get(r.catalogName);n&&n.push(r)}return e},"groupByCatalog"),Fu=N(t=>{const e=mr(t);return e?`${e.relativePath==="."?"root":e.relativePath} (${e.depType})`:`Catalog: ${t}`},"formatCatalogDisplayName"),Ts=N((t,e)=>{const r=Lu(t),n=process.stdout.columns||80,i=t.some(o=>o.socketReport);for(const[o,s]of r){const l=s.flatMap(p=>{const h=p.vulnerabilities&&p.vulnerabilities.length>0,m=p.socketReport&&p.socketReport.alerts.length>0,y=`${h||m?"[SEC] ":""}${p.packageName}`,b=p.socketReport?`${String(Math.round(p.socketReport.score.overall*100))}%`:"",x={current:p.currentRange,package:y,target:p.newRange,type:p.updateType};i&&(x.score=b);const S=[x];if(p.vulnerabilities)for(const C of p.vulnerabilities){const D={current:C.summary,package:` ${C.severity} ${C.id}`,target:"",type:""};i&&(D.score=""),S.push(D)}if(p.socketReport)for(const C of p.socketReport.alerts){const D={current:C.category,package:` [${C.severity.toUpperCase()}] ${C.type}`,target:"",type:""};i&&(D.score=""),S.push(D)}return S}),d=Fu(o),f=ge(_.createElement(Vn,{data:l}),{columns:n});e.info(`${d}
|
|
89
|
+
${f}
|
|
90
|
+
`)}},"formatOutdatedTable"),Lr=N(t=>{let e=0,r=0,n=0,i=0,o=0,s=0;for(const h of t)h.updateType==="major"?e++:h.updateType==="minor"?r++:n++,h.vulnerabilities&&h.vulnerabilities.length>0&&i++,h.socketReport?.alerts.length&&o++,h.socketReport&&h.socketReport.score.overall<at&&s++;const l=[];e&&l.push(`${String(e)} major`),r&&l.push(`${String(r)} minor`),n&&l.push(`${String(n)} patch`),i&&l.push(`${String(i)} with vulnerabilities`),o&&l.push(`${String(o)} with Socket.dev alerts`);const d=`Found ${String(t.length)} outdated (${l.join(", ")})`,f=process.stdout.columns||80,p=[_.createElement(a,{bold:!0},"─ Summary"),_.createElement(a,null,` ${d}`)];return s>0&&p.push(_.createElement(a,{color:"yellow"},` ${String(s)} package${s===1?"":"s"} with low Socket.dev score (<${String(at*100)}%)`)),ge(_.createElement(g,{flexDirection:"column",paddingX:1},...p),{columns:f})},"formatSummary"),Vu=N((t,e)=>{const r=t.replaceAll(No,String.raw`\$&`),n=e.replaceAll(No,String.raw`\$&`);return new RegExp(String.raw`^(?:'${r}'|"${r}"|${r}):\s*['"]?${n}['"]?`)},"buildLineMatchRegex"),Uu=N((t,e,r)=>Vu(e,r).test(t),"lineMatchesPackage"),Gu=N(t=>{const e=new Map;for(const r of t){e.has(r.catalogName)||e.set(r.catalogName,new Map);const n=e.get(r.catalogName);n&&n.set(r.packageName,{newRange:r.newRange,oldRange:r.currentRange})}return e},"buildUpdateMap"),Go=N((t,e,r)=>{if(!r)return t;for(const[n,{newRange:i,oldRange:o}]of r)if(Uu(e,n,o))return t.replace(o,i);return t},"applyLineUpdate"),zu=N((t,e,r,n)=>{const i=t.trimStart(),o=t.length-i.length;return i.length===0||i.startsWith("#")?t:e==="catalog"&&o>=2?Go(t,i,n.get("default")):e==="catalogs"&&o>=4&&r?Go(t,i,n.get(r)):t},"processYamlLineForUpdate"),Wu=N((t,e)=>{const r=T(t,"pnpm-workspace.yaml"),n=Xe(r).split(`
|
|
91
|
+
`),i=Gu(e);let o="none",s="";const l=[];for(const d of n){const f=d.trimStart(),p=d.length-f.length;p===0&&f.length>0&&!f.startsWith("#")&&(o=ks(f),o==="catalogs"&&(s="")),o==="catalogs"&&p===2&&f.endsWith(":")&&(s=f.slice(0,-1).trim().replaceAll(fs,"")),l.push(zu(d,o,s,i))}dr(r,l.join(`
|
|
92
|
+
`))},"applyPnpmCatalogUpdates");N(t=>{const e=Kd.exec(t);if(!e)return 2;const r=e[1];return r?r.includes(" ")?r:r.length:2},"detectJsonIndent");const _u=N((t,e)=>{const r=T(t,"package.json"),n=Ue(r);for(const i of e)if(i.catalogName==="default")n.workspaces?.catalog&&(n.workspaces.catalog[i.packageName]=i.newRange);else{const o=n.workspaces?.catalogs?.[i.catalogName];o&&(o[i.packageName]=i.newRange)}Bn(r,n,{detectIndent:!0,overwrite:!0})},"applyBunCatalogUpdates"),Hu=N((t,e,r,n=!0)=>{let i;n&&(i=Pu(t,r,e));const o=[],s=[];for(const l of e)mr(l.catalogName)?s.push(l):o.push(l);return o.length>0&&(r==="npm"||r==="yarn"?Do(t,o):r==="bun"?_u(t,o):Wu(t,o)),s.length>0&&Do(t,s),i},"applyCatalogUpdates"),Ju=N(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stdout}),n=N(o=>new Promise(s=>{r.question(o,l=>{s(l.trim())})}),"ask");process.stdout.write(`
|
|
85
93
|
Outdated catalog dependencies:
|
|
86
|
-
`);for(const[o,s]of
|
|
94
|
+
`);for(const[o,s]of t.entries())s&&process.stdout.write(` ${String(o+1)}. ${s.packageName}: ${s.currentRange} → ${s.newRange} (${s.updateType})
|
|
87
95
|
`);process.stdout.write(`
|
|
88
|
-
`);const
|
|
89
|
-
`);const
|
|
90
|
-
`);const
|
|
91
|
-
`):
|
|
92
|
-
`)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
`);const i=await n("Apply updates? [a]ll / [n]one / [s]elect: ");if(i.toLowerCase()==="a"||i.toLowerCase()==="all")return r.close(),t;if(i.toLowerCase()==="n"||i.toLowerCase()==="none")return r.close(),[];if(i.toLowerCase()==="s"||i.toLowerCase()==="select"){const o=await n("Enter numbers to apply (comma-separated): ");return r.close(),o.split(",").map(s=>Number.parseInt(s.trim(),10)-1).filter(s=>s>=0&&s<t.length).map(s=>t[s]).filter(s=>s!==void 0)}return r.close(),[]},"promptPackageSelection"),qu=/github\.com[/:]([\w.-]+)\/([\w.-]+?)(?:\.git|\/|$)/,As=N(async(t,e=1e4)=>{const r=[],n=new AbortController,i=setTimeout(()=>{n.abort()},e);try{const o=t.map(async s=>{const l=`https://www.npmjs.com/package/${s.packageName}`;try{const d=await fetch(`https://registry.npmjs.org/${s.packageName}`,{headers:{Accept:"application/json"},signal:n.signal});if(!d.ok)return{npmUrl:l,packageName:s.packageName};const f=(await d.json()).repository?.url;if(!f)return{npmUrl:l,packageName:s.packageName};const p=qu.exec(f);if(!p)return{npmUrl:l,packageName:s.packageName,repoUrl:f};const h=p[1],m=p[2],y=`https://github.com/${h}/${m}/releases/tag/v${s.targetVersion}`;return{npmUrl:l,packageName:s.packageName,releaseUrl:y,repoUrl:`https://github.com/${h}/${m}`}}catch{return{npmUrl:l,packageName:s.packageName}}});r.push(...await Promise.all(o))}finally{clearTimeout(i)}return r},"fetchChangelogInfo");var Yu=Object.defineProperty,Xu=$((t,e)=>Yu(t,"name",{value:e,configurable:!0}),"A$6");const Ku=/^[\^~>=<]+/,Qu={group:"System",argument:{description:"Package name to analyze (e.g., react)",name:"package",required:!0,type:String},description:"Analyze a single package update with AI",examples:[["vis analyze react","Analyze updating react to latest"],["vis analyze react 19.0.0","Analyze updating react to specific version"],["vis analyze react --ai-type security","Run security-focused analysis"],["vis analyze react --format json","Output as JSON"]],execute:Xu(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=t,s=o[0];if(!s)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const l=o[1],{packageManager:d}=Jr(i);let f,p="default";const h=on(i,d);for(const[M,E]of h){const R=E.get(s);if(R){f=R,p=M;break}}if(!f)throw new Error(`Package "${s}" not found in any catalog or package.json. Make sure it exists in your workspace dependencies.`);let m;if(l)m=l;else{e.info(`Fetching latest version for ${s}...
|
|
97
|
+
`);const M=await Ss(s);if(!M.latest)throw new Error(`Could not determine latest version for "${s}".`);m=M.latest}const y=nt(f),b=nt(m);if(!y||!b)throw new Error(`Could not parse versions: current="${f}", target="${m}".`);const x=ms(y,b);if(x==="none"){e.info(`${s} is already at ${m}. Nothing to analyze.`);return}const S=to(f),C={catalogName:p,currentRange:f,newRange:`${S}${m}`,packageName:s,targetVersion:m,updateType:x},D=Qn(r.aiType??"impact");if(D==="security"||r.security){e.info(`Checking for known vulnerabilities...
|
|
98
|
+
`);const M=f.replace(Ku,""),E=(await sn([{name:s,version:M}])).get(s);E&&E.length>0&&(C.vulnerabilities=E);const R=It(n?.security?.socket);if(R){const A=(await Wt([{name:s,version:M}],R)).get(`${s}@${M}`);A&&(C.socketReport={alerts:A.alerts,license:A.license,score:A.score})}}const P=await Zn([C],e,n?.ai,D);(r.format??"table")==="json"?process.stdout.write(`${JSON.stringify(P,void 0,2)}
|
|
99
|
+
`):e.info(Br(P))},"execute"),name:"analyze",options:[{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",name:"ai-type",type:String},{defaultValue:!1,description:"Check for known security vulnerabilities",name:"security",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]};var Zu=Object.defineProperty,Fe=$((t,e)=>Zu(t,"name",{value:e,configurable:!0}),"f$e");const Is=Fe((t,e)=>{const r={errors:[],warnings:[]},{security:n}=t;if(!n)return r.warnings.push("No security settings configured. Use defineConfig() from '@visulima/vis/config' to get secure defaults automatically."),r;if((!n.allowBuilds||Object.keys(n.allowBuilds).length===0)&&r.warnings.push(e==="pnpm"?"security.allowBuilds is not configured. pnpm blocks build scripts by default since v10. Run 'vis approve-builds' to review.":"security.allowBuilds is not configured. Consider listing which packages are allowed to run install/postinstall scripts."),n.minimumReleaseAge===0&&r.warnings.push("security.minimumReleaseAge is explicitly set to 0. New packages can be installed immediately after publishing."),n.trustPolicy==="off"&&r.warnings.push("security.trustPolicy is explicitly set to 'off'. Packages whose trust level has decreased will not be blocked."),n.blockExoticSubdeps===!1&&r.warnings.push("security.blockExoticSubdeps is explicitly disabled. Transitive dependencies can pull code from git repos or tarball URLs."),n.strictDepBuilds===!1&&r.warnings.push("security.strictDepBuilds is explicitly disabled. Unapproved build scripts will only produce warnings, not errors."),n.strictDepBuilds&&(!n.allowBuilds||Object.keys(n.allowBuilds).length===0)&&r.errors.push("security.strictDepBuilds is enabled but security.allowBuilds is empty. All dependencies with build scripts will be blocked. Run 'vis approve-builds' to review and add packages."),n.socket?.acceptedRisks){const i=Date.now();for(const[o,s]of Object.entries(n.socket.acceptedRisks)){const l=new Date(s.acceptedAt).getTime();i-l>7776e6&&r.warnings.push(`Accepted risk for "${o}" is over 90 days old (accepted ${s.acceptedAt}). Consider re-evaluating with 'vis audit'.`)}}return r},"checkSecurityConfig"),ep=Fe((t,e)=>{if(Ge&&!process.env.VIS_SECURITY_WARNINGS)return;const r=Is(t,e);for(const n of r.errors)St(n);r.warnings.length>0&&ae(`${r.warnings.length} security recommendation${r.warnings.length===1?"":"s"} found. Run 'vis check --security-config' for details.`)},"emitSecurityWarnings"),tp=Fe((t,e)=>{const r=Is(t,e),{security:n}=t;if(n){if(k("Active security settings:"),k(` minimumReleaseAge: ${n.minimumReleaseAge??"not set"} minutes`),k(` trustPolicy: ${n.trustPolicy??"not set"}`),k(` trustPolicyIgnoreAfter: ${n.trustPolicyIgnoreAfter??"not set"} minutes`),k(` blockExoticSubdeps: ${n.blockExoticSubdeps??!1}`),k(` strictDepBuilds: ${n.strictDepBuilds??!1}`),k(` allowBuilds: ${n.allowBuilds?`${Object.keys(n.allowBuilds).length} entries`:"not configured"}`),k(""),k("Socket.dev integration:"),k(` socket.enabled: ${n.socket?.enabled??!1}`),k(` socket.apiToken: ${n.socket?.apiToken||process.env.VIS_SOCKET_TOKEN?"configured":"using public token"}`),k(` socket.minimumScore: ${n.socket?.minimumScore??"default (0.4)"}`),k(` socket.cacheTtlMs: ${n.socket?.cacheTtlMs??"default (1 hour)"}`),k(` socket.timeoutMs: ${n.socket?.timeoutMs??"default (15s)"}`),n.socket?.acceptedRisks){const i=Object.entries(n.socket.acceptedRisks);k(` socket.acceptedRisks: ${String(i.length)} entr${i.length===1?"y":"ies"}`);for(const[o,s]of i)k(` ${o}: ${s.reason} (accepted ${s.acceptedAt.slice(0,10)})`)}else k(" socket.acceptedRisks: none");k("")}if(r.errors.length===0&&r.warnings.length===0){k("All recommended security settings are configured.");return}for(const i of r.errors)St(i);for(const i of r.warnings)ae(i);te(""),te("Secure defaults are applied by defineConfig(). You only need to add allowBuilds:"),te(""),te(" import { defineConfig } from '@visulima/vis/config';"),te(""),te(" export default defineConfig({"),te(" security: {"),te(" allowBuilds: {"),te(" esbuild: true,"),te(" '@prisma/client': true,"),te(" },"),te(" },"),te(" });")},"printSecurityReport"),rp=Fe(t=>{const{security:e}=t;if(!e)return[];const r=[];return e.minimumReleaseAge!==void 0&&r.push(`minimumReleaseAge: ${e.minimumReleaseAge}`),e.trustPolicy&&e.trustPolicy!=="off"&&r.push(`trustPolicy: ${e.trustPolicy}`),e.blockExoticSubdeps&&r.push("blockExoticSubdeps: true"),e.allowBuilds&&r.push(`allowBuilds: ${Object.keys(e.allowBuilds).length} entries`),e.strictDepBuilds&&r.push("strictDepBuilds: true"),e.trustPolicyIgnoreAfter!==void 0&&r.push(`trustPolicyIgnoreAfter: ${e.trustPolicyIgnoreAfter}`),r},"previewPnpmSync"),Rs=Fe((t,e)=>{const r=L(t,"node_modules");if(!F(r))return[];const n=[],i=Fe((o,s="")=>{let l;try{l=require("node:fs").readdirSync(o)}catch{return}for(const d of l){const f=L(o,d);if(d.startsWith("@")){i(f,`${d}/`);continue}if(d.startsWith("."))continue;const p=s+d,h=L(f,"package.json");try{if(!require("node:fs").statSync(f).isDirectory()||!F(h))continue;const m=JSON.parse(K(h,"utf8")).scripts??{};if(!m.preinstall&&!m.install&&!m.postinstall&&!m.prepare)continue;if(!Object.entries(e).some(([y,b])=>b?y===p?!0:y.endsWith("*")?p.startsWith(y.slice(0,-1)):!1:!1)){const y=["preinstall","install","postinstall","prepare"].filter(b=>m[b]);n.push(`${p} (${y.join(", ")})`)}}catch{}}},"scanDir");return i(r),n},"scanUnapprovedBuildScripts"),Os=Fe(t=>F(L(t,".yarnrc.yml")),"isYarnBerry"),np=Fe((t,e,r)=>{const n={extraArgs:[],postInstallPackages:[],scriptsBlockedByDefault:!1,warnings:[]},i=r.security?.allowBuilds??{},o=Object.keys(i).length>0;switch(t){case"bun":{if(n.scriptsBlockedByDefault=!0,o){const s=L(e,"package.json");try{(F(s)?JSON.parse(K(s,"utf8")):{}).trustedDependencies?.length||n.warnings.push("vis security.allowBuilds is configured but trustedDependencies is empty. Run 'vis approve-builds --sync-native'.")}catch{}}break}case"npm":{n.scriptsBlockedByDefault=!1;const s=L(e,".npmrc"),l=F(s)&&/^\s*ignore-scripts\s*=\s*true\s*$/m.test(K(s,"utf8"));if(!l&&o?(n.warnings.push("npm does not block lifecycle scripts. vis will add --ignore-scripts automatically."),n.extraArgs.push("--ignore-scripts")):!l&&!o&&n.warnings.push("npm does not block lifecycle scripts. Add 'ignore-scripts=true' to .npmrc and configure security.allowBuilds."),o)for(const[d,f]of Object.entries(i))f&&n.postInstallPackages.push(d);break}case"pnpm":{n.scriptsBlockedByDefault=!0,o||n.warnings.push("pnpm blocks build scripts by default. Run 'vis approve-builds' to review packages that need scripts.");break}case"yarn":{if(n.scriptsBlockedByDefault=!1,Os(e)){const s=K(L(e,".yarnrc.yml"),"utf8");/^\s*enableScripts\s*:\s*false\s*$/m.test(s)?n.scriptsBlockedByDefault=!0:n.warnings.push("yarn berry supports enableScripts. Add 'enableScripts: false' to .yarnrc.yml.")}else if(n.warnings.push("yarn classic does not support blocking lifecycle scripts. Consider upgrading to yarn berry."),o){n.extraArgs.push("--ignore-scripts");for(const[s,l]of Object.entries(i))l&&n.postInstallPackages.push(s)}break}}return n},"enforceScriptSecurity"),io=Fe((t,e,r)=>{const n=[],i=Object.entries(r).filter(([,o])=>o).map(([o])=>o);switch(t){case"bun":{const o=L(e,"package.json");if(F(o))try{const s=JSON.parse(K(o,"utf8"));s.trustedDependencies=i,H(o,`${JSON.stringify(s,null,2)}
|
|
100
|
+
`),n.push(`Updated package.json trustedDependencies with ${i.length} packages`)}catch(s){n.push(`Failed to update package.json: ${s instanceof Error?s.message:String(s)}`)}break}case"npm":{const o=L(e,".npmrc");let s=F(o)?K(o,"utf8"):"";/^\s*ignore-scripts\s*=\s*true\s*$/m.test(s)?n.push(".npmrc already has ignore-scripts=true"):(s=`${s.trimEnd()}
|
|
101
|
+
ignore-scripts=true
|
|
102
|
+
`,H(o,s),n.push("Added ignore-scripts=true to .npmrc"));break}case"pnpm":{n.push(`pnpm manages allowBuilds natively in pnpm-workspace.yaml (${i.length} packages approved)`);break}case"yarn":{if(Os(e)){const o=L(e,".yarnrc.yml");let s=K(o,"utf8");const l=/^\s*enableScripts\s*:/m.test(s),d=/^\s*enableScripts\s*:\s*false\s*$/m.test(s);l?d?n.push(".yarnrc.yml already has enableScripts: false"):(s=s.replace(/^\s*enableScripts\s*:.+$/m,"enableScripts: false"),H(o,s),n.push("Changed enableScripts to false in .yarnrc.yml")):(s=`${s.trimEnd()}
|
|
103
|
+
enableScripts: false
|
|
104
|
+
`,H(o,s),n.push("Added enableScripts: false to .yarnrc.yml"))}else{const o=L(e,".npmrc");let s=F(o)?K(o,"utf8"):"";/^\s*ignore-scripts\s*=\s*true\s*$/m.test(s)?n.push(".npmrc already has ignore-scripts=true"):(s=`${s.trimEnd()}
|
|
105
|
+
ignore-scripts=true
|
|
106
|
+
`,H(o,s),n.push("Added ignore-scripts=true to .npmrc (yarn classic lacks enableScripts)"))}break}}return n},"syncAllowBuildsToNativeConfig"),op=Fe((t,e)=>{const{readdirSync:r,statSync:n}=require("node:fs"),i=L(t,"node_modules"),o=[];for(const s of e){if(!s.endsWith("*")){o.push(s);continue}const l=s.slice(0,-1);try{if(l.startsWith("@")&&l.endsWith("/")){const d=L(i,l.slice(0,-1));for(const f of r(d))!f.startsWith(".")&&n(L(d,f)).isDirectory()&&o.push(`${l.slice(0,-1)}/${f}`)}else for(const d of r(i))d.startsWith(l)&&n(L(i,d)).isDirectory()&&o.push(d)}catch{}}return o},"expandPatterns"),ip=Fe((t,e)=>{if(e.length===0)return;const r=op(t,e);if(r.length===0)return;const n=L(t,"node_modules");let i=!1;for(const o of r){if(o.includes("..")||o.startsWith("/")||o.startsWith("\\")){ae(`Skipping invalid package name: ${o}`);continue}const s=(o.match(/\//g)||[]).length;if(s>1||s===1&&!o.startsWith("@")){ae(`Skipping invalid package name: ${o}`);continue}const l=L(n,o),d=L(l,"package.json");if(F(d))try{const f=JSON.parse(K(d,"utf8")).scripts??{};for(const p of["preinstall","install","postinstall"])if(f[p]){k(`Running ${p} for ${o}...`);try{Xr(f[p],{cwd:l,env:{...process.env},stdio:"inherit"})}catch{St(`${p} script failed for ${o}`),i=!0}}}catch{}}i&&(process.exitCode=1)},"runApprovedScripts");var sp=Object.defineProperty,ap=$((t,e)=>sp(t,"name",{value:e,configurable:!0}),"r$h");const cp={group:"Security & Health",description:"Review and approve dependencies with build scripts",examples:[["vis approve-builds","Scan and list unapproved build scripts"],["vis approve-builds --all","Approve all pending builds (pnpm)"],["vis approve-builds --sync-native","Sync allowBuilds to native PM config"]],execute:ap(async({options:t,visConfig:e,workspaceRoot:r})=>{const n=r??process.cwd(),i=me(n);if(i.name==="pnpm"&&!t.scan){k("Delegating to pnpm approve-builds...");const o=["approve-builds"];t.all&&o.push("--all");const s=Le("pnpm",o,{cwd:n,stdio:"inherit"});if(s.error)throw new Error(`Failed to run pnpm approve-builds: ${s.error.message}`);if(s.status!==0&&s.status!==null&&(St(`pnpm approve-builds exited with code ${s.status}`),process.exitCode=s.status),!t.syncNative)return}else{const o=e?.security?.allowBuilds??{},s=Rs(n,o);if(s.length===0)Q("No unapproved build scripts found.");else{ae(`Found ${s.length} package${s.length===1?"":"s"} with unapproved build scripts:
|
|
107
|
+
`);for(const l of s)k(` ${l}`);te(""),te("To approve these packages, add them to vis.config.ts:"),te(""),te(" security: {"),te(" allowBuilds: {");for(const l of s){const d=l.split(" (")[0];te(` "${d}": true,`)}te(" },"),te(" },"),i.name==="pnpm"&&(te(""),te("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly."))}}if(t.syncNative){const o=e?.security?.allowBuilds??{};if(Object.keys(o).length===0)ae("No security.allowBuilds configured in vis.config.ts. Nothing to sync.");else{const s=io(i.name,n,o);k("");for(const l of s)Q(l)}}},"execute"),name:"approve-builds",options:[{defaultValue:!1,description:"Approve all pending builds without prompting (pnpm only)",name:"all",type:Boolean},{defaultValue:!1,description:"Force vis scanning even for pnpm (instead of delegating)",name:"scan",type:Boolean},{defaultValue:!1,description:"Sync allowBuilds to native PM config (bun: trustedDependencies, npm: .npmrc, yarn: .yarnrc.yml)",name:"sync-native",type:Boolean}]};var lp=Object.defineProperty,mt=$((t,e)=>lp(t,"name",{value:e,configurable:!0}),"o$c");const Fr=mt(t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[],"toStringArray"),jn=mt((t,e)=>{for(const r of e)if(r===t||r.endsWith("*")&&t.startsWith(r.slice(0,-1)))return!0;return!1},"matchesGlobList"),Ps=mt(t=>{const e=T(t,"pnpm-workspace.yaml");if(!le(e))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=Kr(e);return{excludedPackages:[],ignoredAdvisories:[...Fr(r?.auditConfig?.ignoreCves),...Fr(r?.auditConfig?.ignoreGhsas)]}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readPnpmAuditExclusions"),Ns=mt(t=>{const e=T(t,".yarnrc.yml");if(!le(e))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=Kr(e);return{excludedPackages:Fr(r?.npmAuditExcludePackages),ignoredAdvisories:Fr(r?.npmAuditIgnoreAdvisories)}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readYarnAuditExclusions"),dp=mt((t,e)=>{switch(e){case"pnpm":return Ps(t);case"yarn":return Ns(t);default:return{excludedPackages:[],ignoredAdvisories:[]}}},"readNativeAuditExclusions"),zo=mt((t,e,r)=>{if(jn(t,e.ignoredAdvisories))return!0;if(r){for(const n of r)if(jn(n,e.ignoredAdvisories))return!0}return!1},"isAdvisoryExcluded"),up=mt((t,e)=>jn(t,e.excludedPackages),"isPackageExcluded"),pp=mt((t,e,r)=>{if(r.length===0)return["No advisory IDs to sync."];const n=[];switch(t){case"bun":{n.push(`bun has no audit config file. Use CLI flags: bun audit ${r.map(i=>`--ignore ${i}`).join(" ")}`);break}case"npm":{n.push("npm has no native audit exclusion config. vis accepted risks are the only layer.");break}case"pnpm":{const i=T(e,"pnpm-workspace.yaml");if(!F(i)){n.push("pnpm-workspace.yaml not found. Cannot sync.");break}const o=Ps(e),s=new Set(o.ignoredAdvisories.filter(x=>x.startsWith("CVE-"))),l=new Set(o.ignoredAdvisories.filter(x=>x.startsWith("GHSA-"))),d=r.filter(x=>x.startsWith("CVE-")),f=r.filter(x=>x.startsWith("GHSA-")),p=[...new Set([...s,...d])],h=[...new Set([...l,...f])],m=d.filter(x=>!s.has(x)).length,y=f.filter(x=>!l.has(x)).length;if(m===0&&y===0){n.push("All advisory IDs already present in pnpm-workspace.yaml.");break}let b=K(i,"utf8");if(p.length>0){const x=` ignoreCves:
|
|
108
|
+
${p.map(S=>` - ${S}`).join(`
|
|
109
|
+
`)}
|
|
110
|
+
`;/auditConfig:/.test(b)?b=/ignoreCves:/.test(b)?b.replace(/ignoreCves:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,x):b.replace(/auditConfig:\s*\n/,`auditConfig:
|
|
111
|
+
${x}`):b=`${b.trimEnd()}
|
|
112
|
+
|
|
113
|
+
auditConfig:
|
|
114
|
+
${x}`,m>0&&n.push(`Added ${String(m)} new CVE${m===1?"":"s"} to pnpm-workspace.yaml (${String(p.length)} total)`)}if(h.length>0){const x=` ignoreGhsas:
|
|
115
|
+
${h.map(S=>` - ${S}`).join(`
|
|
116
|
+
`)}
|
|
117
|
+
`;/auditConfig:/.test(b)&&(b=/ignoreGhsas:/.test(b)?b.replace(/ignoreGhsas:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,x):b.replace(/(auditConfig:[\s\S]*?)(\n\S|\n?$)/m,`$1${x}$2`)),y>0&&n.push(`Added ${String(y)} new GHSA${y===1?"":"s"} to pnpm-workspace.yaml (${String(h.length)} total)`)}H(i,b);break}case"yarn":{const i=T(e,".yarnrc.yml");if(!F(i)){n.push(".yarnrc.yml not found. Cannot sync.");break}const o=Ns(e),s=new Set(o.ignoredAdvisories),l=[...new Set([...s,...r])],d=r.filter(h=>!s.has(h)).length;if(d===0){n.push("All advisory IDs already present in .yarnrc.yml.");break}let f=K(i,"utf8");const p=`npmAuditIgnoreAdvisories:
|
|
118
|
+
${l.map(h=>` - "${h}"`).join(`
|
|
119
|
+
`)}
|
|
120
|
+
`;f=/npmAuditIgnoreAdvisories:/.test(f)?f.replace(/npmAuditIgnoreAdvisories:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,p):`${f.trimEnd()}
|
|
121
|
+
|
|
122
|
+
${p}`,H(i,f),n.push(`Synced ${String(d)} advisor${d===1?"y":"ies"} to .yarnrc.yml (${String(l.length)} total)`);break}default:n.push(`Unknown package manager: ${t}`)}return n},"syncAcceptedRisksToNativeConfig");var fp=Object.defineProperty,ot=$((t,e)=>fp(t,"name",{value:e,configurable:!0}),"h$d");const Ds=ot(t=>{const e=T(t,"node_modules");if(!F(e))return[];const r=[],n=T(t,"package.json");let i=new Set;if(F(n))try{const s=JSON.parse(K(n,"utf8"));i=new Set(Object.keys(s.devDependencies??{}))}catch{}const o=ot((s,l)=>{let d;try{d=ft(s)}catch{return}for(const f of d){if(f.startsWith("."))continue;const p=T(s,f);if(f.startsWith("@")){o(p,`${f}/`);continue}const h=l+f,m=T(p,"package.json");try{if(!Yr(p).isDirectory()||!F(m))continue;const y=JSON.parse(K(m,"utf8"));y.version&&r.push({isDev:i.has(h),name:h,version:y.version});const b=T(p,"node_modules");F(b)&&o(b,"")}catch{}}},"scanDir");return o(e,""),r},"scanInstalledPackages"),gp={bun:{file:"bun.lock",type:"bun"},npm:{file:"package-lock.json",type:"npm"},pnpm:{file:"pnpm-lock.yaml",type:"pnpm"},yarn:{file:"yarn.lock",type:"yarn"}},Ms=ot(async(t,e)=>{const r=gp[e];if(!r)return[];let n,i;try{n=K(T(t,r.file),"utf8")}catch{return[]}try{i=JSON.parse(K(T(t,"package.json"),"utf8"))}catch{}let o;try{o=await mc(n,r.type,i)}catch{return[]}if(!o?.packages)return[];const s=new Map;for(const d of o.packages)!d.name||!d.version||(s.has(d.name)||s.set(d.name,new Set),s.get(d.name).add(d.version));const l=[];for(const[d,f]of s)f.size<=1||l.push({name:d,versions:[...f]});return l.sort((d,f)=>d.name.localeCompare(f.name))},"findDuplicateDependencies"),vn={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},hp={critical:ct,high:Ii,low:$t,medium:Ie},wn=ot((t,e)=>{const r=vn[e.toUpperCase()]??vn.MODERATE??2;return(vn[t.toUpperCase()]??4)<=r},"severityPassesFilter"),mp={CRITICAL:ct,HIGH:Ii,LOW:$t,MODERATE:Ie,UNKNOWN:Be},yp=ot((t,e,r,n)=>{const i=mp[r.severity]??Be,o=n?` ${Be("[acknowledged]")}`:"",s=r.fixedVersions??[],l=s.length>0?` (fix: ${s.join(", ")})`:"";return` ${i(r.severity)} ${r.id} — ${t}@${e}${o}
|
|
123
|
+
${r.summary}${l}`},"formatVulnLine"),vp=ot((t,e)=>{const r=Mt(t),n=`${String(Math.round(t.score.overall*100))}%`,i=e?` ${Be("[acknowledged]")}`:"",o=t.alerts.length>0?`, ${String(t.alerts.length)} alert${t.alerts.length===1?"":"s"}`:"";return` ${n} ${r}@${t.version} (${_n(t.score.overall)}${o})${i}`},"formatSocketLine"),wp=ot(async(t,e,r,n)=>{const i=e.severity??"low",o=e.format==="json"||!!e.json,s=!!e.fix,l=!!e.showAccepted,d=r?.security?.socket,f=d?.acceptedRisks,p=me(t),h=dp(t,p.name);(h.ignoredAdvisories.length>0||h.excludedPackages.length>0)&&k(`Loaded ${String(h.ignoredAdvisories.length)} ignored advisor${h.ignoredAdvisories.length===1?"y":"ies"} and ${String(h.excludedPackages.length)} excluded package${h.excludedPackages.length===1?"":"s"} from ${p.name} config.`),k("Scanning installed packages...");const m=Ds(t);if(m.length===0){k("No packages found in node_modules. Run your package manager's install command first.");return}k(`Found ${String(m.length)} packages.
|
|
124
|
+
`);const y=m.map(w=>({name:w.name,version:w.version})),b=It(d),[x,S,C]=await Promise.all([sn(y),b?Wt(y,b):Promise.resolve(new Map),Ms(t,p.name)]),D=[];for(const w of m){if(up(w.name,h))continue;const v=x.get(w.name)??[],j=S.get(`${w.name}@${w.version}`),U=Hn(w.name,w.version,f),z=v.length>0,Z=j?j.score.overall<at:!1,he=j?j.alerts.length>0:!1;(z||Z||he)&&D.push({acceptedRisk:U,name:w.name,socketReport:j,version:w.version,vulnerabilities:v})}const P=D.filter(w=>{const v=w.vulnerabilities.some(z=>wn(z.severity,i)),j=w.socketReport?.alerts.some(z=>wn(z.severity==="medium"?"MODERATE":z.severity.toUpperCase(),i)),U=w.socketReport&&w.socketReport.score.overall<at;return v||j||U});if(o){const w={duplicates:C.map(v=>({name:v.name,versionCount:v.versions.length,versions:v.versions})),packages:m.length,results:P.map(v=>({acceptedRisk:v.acceptedRisk??null,name:v.name,socketAlerts:v.socketReport?.alerts??[],socketScore:v.socketReport?.score.overall??null,version:v.version,vulnerabilities:v.vulnerabilities})),summary:{accepted:P.filter(v=>v.acceptedRisk).length,duplicatePackages:C.length,issues:P.filter(v=>!v.acceptedRisk).length,total:P.length}};process.stdout.write(`${JSON.stringify(w,void 0,2)}
|
|
125
|
+
`),e.exitCode&&w.summary.issues>0&&(process.exitCode=1);return}if(P.length===0){Q(`No security issues found across ${String(m.length)} packages.`);return}const M={CRITICAL:[],HIGH:[],LOW:[],MODERATE:[]};for(const w of P)for(const v of w.vulnerabilities)if(wn(v.severity,i)){const j=v.severity==="UNKNOWN"?"LOW":v.severity;M[j]?.push({entry:w,vuln:v})}let E=0,R=0;for(const w of["CRITICAL","HIGH","MODERATE","LOW"]){const v=M[w];if(!(!v||v.length===0)){k(`
|
|
126
|
+
── ${w} (${String(v.length)}) ──`);for(const{entry:j,vuln:U}of v){const z=!!j.acceptedRisk||zo(U.id,h,U.aliases);z&&(R++,!l)||(E++,k(yp(j.name,j.version,U,z)),s&&(U.fixedVersions??[]).length>0&&te(` Fix: update to ${U.fixedVersions.at(-1)}`))}}}const A=P.filter(w=>w.socketReport&&(w.socketReport.score.overall<at||w.socketReport.alerts.length>0));if(A.length>0){k(`
|
|
127
|
+
── Socket.dev Supply Chain (${String(A.length)}) ──`);for(const w of A){if(!w.socketReport)continue;const v=!!w.acceptedRisk;if(!(v&&!l)){k(vp(w.socketReport,v));for(const j of w.socketReport.alerts){const U=hp[j.severity]??Be;k(` ${U(`[${j.severity.toUpperCase()}]`)} ${j.type} — ${j.category}`)}}}}if(C.length>0){k(`
|
|
128
|
+
── Duplicate Dependencies (${String(C.length)}) ──`);for(const w of C){const v=w.versions.join(", ");k(` ${w.name} — ${String(w.versions.length)} versions: ${Ie(v)}`)}}const G=ot(w=>!!w.acceptedRisk||w.vulnerabilities.length>0&&w.vulnerabilities.every(v=>zo(v.id,h,v.aliases)),"isEntryExcluded"),B=P.filter(w=>!G(w)).length;if(k(""),k("─ Audit Summary"),k(` ${String(m.length)} packages scanned`),h.ignoredAdvisories.length>0&&k(` ${String(h.ignoredAdvisories.length)} ${p.name} audit exclusion${h.ignoredAdvisories.length===1?"":"s"} applied`),E>0){const w=M.CRITICAL?.filter(j=>!G(j.entry)).length??0,v=M.HIGH?.filter(j=>!G(j.entry)).length??0;St(` ${String(E)} vulnerabilit${E===1?"y":"ies"} found`),w>0&&St(` ${String(w)} critical`),v>0&&ae(` ${String(v)} high`)}else Q(" No vulnerabilities found");if(A.length>0){const w=A.filter(v=>!G(v)).length;ae(` ${String(w)} package${w===1?"":"s"} with Socket.dev supply chain issues`)}if(C.length>0&&(ae(` ${String(C.length)} package${C.length===1?"":"s"} with duplicate versions`),te(" Run 'vis dedupe' or your package manager's dedupe command to reduce duplicates.")),R>0&&(k(` ${String(R)} acknowledged (accepted risks)`),l||te(" Use --show-accepted to see acknowledged issues.")),B===0&&Q(`
|
|
129
|
+
All issues are acknowledged. No action required.`),e.sync&&f){const w=new Set;for(const j of D)if(j.acceptedRisk){for(const U of j.vulnerabilities)if((U.id.startsWith("CVE-")||U.id.startsWith("GHSA-"))&&w.add(U.id),U.aliases)for(const z of U.aliases)(z.startsWith("CVE-")||z.startsWith("GHSA-"))&&w.add(z)}const v=[...w];if(v.length>0){k("");const j=pp(p.name,t,v);for(const U of j)Q(` ${U}`)}else k(`
|
|
130
|
+
No advisory IDs to sync to native PM config.`)}e.exitCode&&B>0&&(process.exitCode=1)},"executeAudit"),kp={group:"Security & Health",description:"Audit installed packages for vulnerabilities and supply chain risks",examples:[["vis audit","Full audit of all installed packages"],["vis audit --severity high","Show only high/critical issues"],["vis audit --format json","Output as JSON for CI integration"],["vis audit --fix","Show fix suggestions for vulnerabilities"],["vis audit --exit-code","Exit with code 1 if issues found (for CI)"],["vis audit --show-accepted","Include acknowledged risks in output"],["vis audit --sync","Sync accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)"]],execute:ot(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");await wp(n,e,r,t)},"execute"),name:"audit",options:[{description:"Minimum severity to report: low, medium, high, critical (default: low)",name:"severity",type:String},{description:"Output format: table or json (default: table)",name:"format",type:String},{defaultValue:!1,description:"Show fix suggestions for vulnerabilities",name:"fix",type:Boolean},{defaultValue:!1,description:"Exit with code 1 if any issues found (for CI)",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Include acknowledged (accepted risk) issues in output",name:"show-accepted",type:Boolean},{defaultValue:!1,description:"Sync vis accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)",name:"sync",type:Boolean}]};var bp=Object.defineProperty,$p=$((t,e)=>bp(t,"name",{value:e,configurable:!0}),"a$9");function sr({current:t,total:e}){const{columns:r}=Ut(),n=r||80,i=e>0?t/e:0,o=`${String(Math.round(i*100))}%`,s=Math.max(10,n-4),l=Math.round(s*i),d=s-l;return u(g,{flexDirection:"column",marginTop:1,paddingX:1,children:[u(g,{children:[c(Bi,{type:"dots"}),u(a,{children:[" ","Checking"," ",String(e)," ","catalog dependencies"," "]}),u(a,{dimColor:!0,children:[String(t),"/",String(e)]})]}),u(g,{children:[c(a,{color:"cyan",children:"━".repeat(l)}),c(a,{dimColor:!0,children:"─".repeat(d)}),u(a,{children:[" ",o]})]})]})}$(sr,"T$7");$p(sr,"CheckProgressApp");var xp=Object.defineProperty,er=$((t,e)=>xp(t,"name",{value:e,configurable:!0}),"r$g");const Tr=er(t=>{const e=new Map;for(const r of t){const n=e.get(r.catalogName);n?n.push(r):e.set(r.catalogName,[r])}return e},"groupByCatalog"),Ar=er((t,e,r)=>{let n=t;if(e!=="all"&&(n=e==="security"?n.filter(i=>i.vulnerabilities&&i.vulnerabilities.length>0||i.socketReport&&i.socketReport.alerts.length>0):n.filter(i=>i.updateType===e)),r){const i=r.toLowerCase();n=n.filter(o=>o.packageName.toLowerCase().includes(i))}return n},"filterEntries");class Bs{static{$(this,"UpdateStore")}static{er(this,"UpdateStore")}#e;#t=new Set;#n;#o=null;constructor(e,r=null){this.#n=e,r&&(this.#o=new Map(r.recommendations.map(n=>[n.package,n]))),this.#e={aiResult:r,allChecked:!0,applyProgress:null,checkedEntries:new Set(e.map(n=>n.packageName)),entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",groupedByCatalog:Tr(e),phase:"browsing",selectedIndex:0}}getSnapshot=er(()=>this.#e,"getSnapshot");subscribe=er(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries(){return Ar(this.#n,this.#e.filterType,this.#e.filterText)}getRecommendation(e){return this.#o?.get(e)}getCheckedEntries(){return this.#n.filter(e=>this.#e.checkedEntries.has(e.packageName))}setSelectedIndex(e){const r=this.getFilteredEntries(),n=Math.max(0,Math.min(e,r.length-1));n!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:n})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:e})}setFilterType(e){if(e!==this.#e.filterType){const r=Ar(this.#n,e,this.#e.filterText);this.#r({...this.#e,entries:r,filterType:e,groupedByCatalog:Tr(r),selectedIndex:0})}}setFilter(e){const r=Ar(this.#n,this.#e.filterType,e);this.#r({...this.#e,entries:r,filterText:e,groupedByCatalog:Tr(r),selectedIndex:0})}setFilterActive(e){if(e!==this.#e.filterActive)if(e)this.#r({...this.#e,filterActive:!0});else{const r=Ar(this.#n,this.#e.filterType,"");this.#r({...this.#e,entries:r,filterActive:!1,filterText:"",groupedByCatalog:Tr(r),selectedIndex:0})}}toggleCheck(e){const r=new Set(this.#e.checkedEntries);r.has(e)?r.delete(e):r.add(e),this.#r({...this.#e,allChecked:r.size===this.#n.length,checkedEntries:r})}checkAll(){this.#r({...this.#e,allChecked:!0,checkedEntries:new Set(this.#n.map(e=>e.packageName))})}uncheckAll(){this.#r({...this.#e,allChecked:!1,checkedEntries:new Set})}toggleAll(){this.#e.allChecked?this.uncheckAll():this.checkAll()}startApply(){const e=this.getCheckedEntries();this.#r({...this.#e,applyProgress:{current:0,total:e.length},phase:"applying"})}updateApplyProgress(e){this.#e.applyProgress&&this.#r({...this.#e,applyProgress:{...this.#e.applyProgress,current:e}})}markDone(){this.#r({...this.#e,phase:"done"})}setError(e){this.#r({...this.#e,error:e,phase:"error"})}#r(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var Sp=Object.defineProperty,Cp=$((t,e)=>Sp(t,"name",{value:e,configurable:!0}),"f$c");const jt=Cp(({autoExitSeconds:t,onCancel:e,visible:r})=>{const{exit:n}=Gt(),[i,o]=ce(t||3),s=be(null),l=be(0);qe(()=>(r&&(o(t||3),l.current=Date.now(),s.current=setInterval(()=>{o(f=>Math.max(0,f-1))},1e3)),()=>{s.current&&(clearInterval(s.current),s.current=null)}),[r,t]),qe(()=>{i<=0&&r&&(s.current&&(clearInterval(s.current),s.current=null),n())},[i,r,n]);const d=Ye(()=>{s.current&&(clearInterval(s.current),s.current=null),e()},[e]);return De((f,p)=>{Date.now()-l.current<200||(f==="q"?n():d())},{isActive:r}),c(xt,{backgroundColor:"#1e1e1e",footer:u(a,{dimColor:!0,children:["Press"," ",c(a,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",c(a,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${i}…`,visible:r,width:50,children:c(a,{dimColor:!0,children:"Stay to explore the results interactively."})})},"QuitDialog");var Ep=Object.defineProperty,jp=$((t,e)=>Ep(t,"name",{value:e,configurable:!0}),"d$e");const Tp={major:"red",minor:"yellow",patch:"green"},Ap={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Ip={critical:"red",high:"red",low:"gray",medium:"yellow"},Rp={critical:"red",high:"red",low:"green",medium:"yellow"},Op={defer:"gray",review:"yellow",skip:"red",update:"green"},Pp=jp(({changelogUrl:t,entry:e,focused:r,recommendation:n,scrollRef:i})=>{const o=r?"white":"gray";if(!e)return c(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"No package selected"})});const s=Tp[e.updateType]??"white",l=e.vulnerabilities&&e.vulnerabilities.length>0,d=e.socketReport?.score.overall??0,f=e.socketReport?fr(d):"gray";return u(g,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c(g,{flexShrink:0,paddingTop:1,paddingX:2,children:c(a,{bold:!0,color:"white",children:e.packageName})}),u(zt,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[c(a,{}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Current:"})}),c(a,{children:e.currentRange})]}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Target:"})}),c(a,{children:e.newRange}),u(a,{bold:!0,color:s,children:[" ","(",e.updateType,")"]})]}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Version:"})}),c(a,{children:e.targetVersion})]}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Catalog:"})}),c(a,{children:e.catalogName})]}),e.acceptedRisk&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{color:"gray",children:"── "}),c(a,{bold:!0,color:"gray",children:"ACKNOWLEDGED RISK"}),u(g,{flexDirection:"column",paddingLeft:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Reason: "}),c(a,{children:e.acceptedRisk.reason})]}),u(g,{children:[c(a,{dimColor:!0,children:"Accepted: "}),c(a,{children:e.acceptedRisk.acceptedAt.slice(0,10)})]})]})]}),l&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"red",children:"SECURITY"}),c(a,{}),e.vulnerabilities.map(p=>u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{gap:1,children:[u(a,{bold:!0,color:Ap[p.severity]??"gray",children:["⚠"," ",p.severity]}),c(a,{bold:!0,children:p.id})]}),c(g,{paddingLeft:2,children:c(a,{children:p.summary})}),u(g,{gap:2,paddingLeft:2,children:[p.cvssScore!==void 0&&u(a,{dimColor:!0,children:["CVSS:",String(p.cvssScore)]}),p.fixedVersions.length>0&&u(a,{dimColor:!0,children:["Fixed in:",p.fixedVersions.join(", ")]})]})]},p.id))]}),e.socketReport&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"cyan",children:"SOCKET.DEV"}),c(a,{}),u(g,{gap:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Overall: "}),u(a,{bold:!0,color:f,children:[String(Math.round(d*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"Supply Chain: "}),u(a,{children:[String(Math.round(e.socketReport.score.supplyChain*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"Quality: "}),u(a,{children:[String(Math.round(e.socketReport.score.quality*100)),"%"]})]})]}),u(g,{gap:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Maintenance: "}),u(a,{children:[String(Math.round(e.socketReport.score.maintenance*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"Vulnerability: "}),u(a,{children:[String(Math.round(e.socketReport.score.vulnerability*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"License: "}),u(a,{children:[e.socketReport.license||"unknown"," ","(",String(Math.round(e.socketReport.score.license*100)),"%)"]})]})]}),e.socketReport.alerts.length>0&&u(g,{flexDirection:"column",marginTop:1,children:[u(a,{bold:!0,color:"yellow",children:["⚠"," ",String(e.socketReport.alerts.length)," ","alert",e.socketReport.alerts.length===1?"":"s",":"]}),e.socketReport.alerts.map(p=>u(g,{gap:1,paddingLeft:2,children:[u(a,{bold:!0,color:Ip[p.severity]??"gray",children:["[",p.severity.toUpperCase(),"]"]}),c(a,{children:p.type}),u(a,{dimColor:!0,children:["(",p.category,")"]})]},p.key))]})]}),n&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"AI ANALYSIS"}),c(a,{}),u(g,{gap:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Action: "}),c(a,{bold:!0,color:Op[n.action]??"white",children:n.action})]}),u(g,{children:[c(a,{dimColor:!0,children:"Risk: "}),c(a,{bold:!0,color:Rp[n.riskLevel]??"white",children:n.riskLevel})]}),u(g,{children:[c(a,{dimColor:!0,children:"Effort: "}),c(a,{bold:!0,children:n.effort})]})]}),n.reason&&c(g,{marginTop:1,paddingLeft:2,children:c(a,{children:n.reason})}),n.breakingChanges.length>0&&u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[c(a,{bold:!0,color:"yellow",children:"Breaking changes:"}),n.breakingChanges.map((p,h)=>u(a,{children:[" ","•"," ",p]},String(h)))]})]}),t&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"CHANGELOG"}),c(g,{marginTop:1,paddingLeft:2,children:c(a,{color:"cyan",underline:!0,children:t})})]}),u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"LINKS"}),c(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:u(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",e.packageName]})})]}),!n&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"GUIDANCE"}),u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.updateType==="major"&&u(Zt,{children:[u(a,{color:"red",children:["⚠"," ","Major update — likely contains breaking changes."]}),c(a,{dimColor:!0,children:" Review the changelog before updating."}),c(a,{dimColor:!0,children:" Use --changelog to fetch release URLs."})]}),e.updateType==="minor"&&u(Zt,{children:[u(a,{color:"yellow",children:["ℹ"," ","Minor update — new features, backward compatible."]}),c(a,{dimColor:!0,children:" Generally safe to update."})]}),e.updateType==="patch"&&u(Zt,{children:[u(a,{color:"green",children:["✓"," ","Patch update — bug fixes only."]}),c(a,{dimColor:!0,children:" Safe to update."})]}),!n&&c(a,{dimColor:!0,children:" Use --ai to get AI-powered analysis."})]})]})]})]})},"PackageDetailPanel");var Np=Object.defineProperty,so=$((t,e)=>Np(t,"name",{value:e,configurable:!0}),"b$g");const Dp={major:"red",minor:"yellow",patch:"green"},Mp=[{id:"all",label:"All"},{id:"major",label:"Major"},{id:"minor",label:"Minor"},{id:"patch",label:"Patch"},{id:"security",label:"Security"}],Bp=so(({checked:t,entry:e,isSelected:r})=>{const n=Dp[e.updateType]??"white",i=e.vulnerabilities&&e.vulnerabilities.length>0,o=e.socketReport&&e.socketReport.alerts.length>0,s=!!e.acceptedRisk,l=t?"☑":"☐",d=e.socketReport?`${String(Math.round(e.socketReport.score.overall*100))}%`:"",f=e.socketReport?fr(e.socketReport.score.overall):"gray";return u(g,{flexShrink:0,height:1,children:[c(a,{children:r?">":" "}),u(a,{color:t?"white":"gray",children:[" ",l," "]}),i||o?c(a,{color:s?"gray":"red",children:s?"✓ ":"⚠ "}):c(a,{children:" "}),c(g,{flexGrow:1,children:u(a,{bold:r,inverse:r,wrap:"truncate",children:[e.packageName,s?" [ack]":""]})}),d&&u(a,{color:f,children:[" ",d]}),u(a,{dimColor:!0,children:[" ",e.currentRange]}),u(a,{dimColor:!0,children:[" ","→"," "]}),u(a,{children:[e.newRange," "]}),c(a,{bold:!0,color:n,children:e.updateType})]})},"PackageRow"),Lp=so(({count:t,name:e})=>u(g,{flexShrink:0,height:1,marginTop:1,children:[u(a,{dimColor:!0,children:["▼"," "]}),c(a,{bold:!0,color:"white",children:e.toUpperCase()}),u(a,{dimColor:!0,children:[" ","(",t,")"]})]}),"CatalogHeader"),Fp=so(({checkedEntries:t,entries:e,filterActive:r,filterText:n,filterType:i,filteredOutCount:o,focused:s,groupedByCatalog:l,isDryRun:d,scrollOffset:f,selectedIndex:p,totalCatalogEntries:h,totalChecked:m,totalEntries:y,viewportHeight:b})=>{const x=s?"white":"gray";let S=0,C=0,D=0,P=0;for(const v of e)v.updateType==="major"?S++:v.updateType==="minor"?C++:D++,(v.vulnerabilities&&v.vulnerabilities.length>0||v.socketReport&&v.socketReport.alerts.length>0)&&P++;const M=[];S>0&&M.push(`${S} major`),C>0&&M.push(`${C} minor`),D>0&&M.push(`${D} patch`),P>0&&M.push(`${P} vulnerable`);const E=M.length>0?` (${M.join(", ")})`:"";let R=0;for(const v of e)t.has(v.packageName)&&R++;const A=[];let G=0;for(const[v,j]of l){A.push(c(Lp,{count:j.length,name:v},`hdr-${v}`));for(const U of j){const z=G;A.push(c(Bp,{checked:t.has(U.packageName),entry:U,isSelected:z===p},U.packageName)),G++}}let B=0;for(const[,v]of l)B+=2+v.length;const w=B>b&&b>0;return u(g,{borderColor:x,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),u(a,{wrap:"truncate",children:[y,m>0?`/${m}`:""," ","outdated",E,h>m?` · ${h-m} dupes`:""]}),!d&&R>0&&u(a,{dimColor:!0,children:[" ","—",R," ","selected"]})]}),c(g,{flexShrink:0,paddingX:1,paddingY:1,children:c(Li,{isFocused:s,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:$(()=>{},"onChange"),showIndex:!1,value:i,children:Mp.map(({id:v,label:j})=>c(Fi,{name:v,children:j},v))})}),r&&u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:n}),c(a,{inverse:!0,children:" "})]}),o>0&&c(g,{flexShrink:0,paddingX:1,children:u(a,{color:"yellow",children:["⚠"," ",o," ","package",o===1?"":"s"," ","filtered out by target constraint — press"," ",c(a,{bold:!0,color:"white",children:"f"})," ","to view"]})}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-f,children:A})}),w&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:B,placement:"inset",scrollOffset:f,style:"block",viewportHeight:b})})]},`list-${i}-${n}`)]})},"PackageListPanel");var Vp=Object.defineProperty,Up=$((t,e)=>Vp(t,"name",{value:e,configurable:!0}),"Y$1");const Gp=100,zp=40,Wp=10,_p=[],Ls=Up(({autoExitSeconds:t=0,changelogUrls:e,checkedCount:r=0,filteredOutEntries:n=_p,isDryRun:i,store:o,totalCatalogEntries:s=0})=>{const{exit:l}=Gt(),{columns:d,rows:f}=Ut(),p=pr(o.subscribe,o.getSnapshot),[h,m]=ce(!1),[y,b]=ce(!1),x=be(null),S=be(null),C=be(null),D=be(null),[P,M]=ce(0),[E,R]=ce(!1),[A,G]=ce(!1),B=Ke(()=>o.getFilteredEntries(),[p.entries,p.filterType,p.filterText]),w=B[p.selectedIndex]??null,v=w?o.getRecommendation(w.packageName):void 0,j=w&&e?e.get(w.packageName):void 0,U=Ye(J=>{let q=0,se=0;for(const[,je]of p.groupedByCatalog){q+=2;for(let Ot=0;Ot<je.length;Ot++){if(se===J)return q;q+=1,se++}}return q},[p.groupedByCatalog]),z=Math.max(1,f-8-(p.filterActive?1:0)),Z=Ye(J=>{const q=U(J);M(se=>q>se+z-2?Math.max(0,q-z+2):q<se+1?Math.max(0,q-1):se)},[U,z]);if(qe(()=>{C.current?.scrollToTop()},[w?.packageName]),De((J,q)=>{if(J==="c"&&q.ctrl){l();return}if(!A){if(y){q.escape||J==="f"||J==="q"?b(!1):q.downArrow||J==="j"?S.current?.scrollBy(1):(q.upArrow||J==="k")&&S.current?.scrollBy(-1);return}if(E){J==="u"||q.return?(R(!1),o.startApply(),l(o.getCheckedEntries())):q.escape||J==="q"?R(!1):q.downArrow||J==="j"?D.current?.scrollBy(1):q.upArrow||J==="k"?D.current?.scrollBy(-1):q.pageDown?D.current?.scrollBy(5):q.pageUp&&D.current?.scrollBy(-5);return}if(h){q.escape||J==="?"?m(!1):J==="q"?(m(!1),G(!0)):q.downArrow||J==="j"?x.current?.scrollBy(1):(q.upArrow||J==="k")&&x.current?.scrollBy(-1);return}if(J==="?"){m(!0);return}if(J==="q"){G(!0);return}if(q.tab){o.setFocusedPanel(p.focusedPanel==="list"?"detail":"list");return}if(p.focusedPanel==="list"&&(q.leftArrow||q.rightArrow)){const se=["all","major","minor","patch","security"],je=se.indexOf(p.filterType),Ot=q.rightArrow?(je+1)%se.length:(je-1+se.length)%se.length;M(0),C.current?.scrollToTop(),o.setFilterType(se[Ot]);return}if(J==="f"&&n.length>0){b(se=>!se);return}if(p.filterActive){if(q.escape){o.setFilterActive(!1);return}if(q.return){o.setFilterActive(!1);return}if(q.backspace){M(0),o.setFilter(p.filterText.slice(0,-1));return}if(J&&!q.ctrl&&!q.meta){M(0),o.setFilter(p.filterText+J);return}return}if(p.focusedPanel==="list"){if(q.downArrow||J==="j"){const se=Math.min(p.selectedIndex+1,B.length-1);o.setSelectedIndex(se),Z(se);return}if(q.upArrow||J==="k"){const se=Math.max(p.selectedIndex-1,0);o.setSelectedIndex(se),Z(se);return}if(q.pageDown){const se=Math.min(p.selectedIndex+10,B.length-1);o.setSelectedIndex(se),Z(se);return}if(q.pageUp){const se=Math.max(p.selectedIndex-10,0);o.setSelectedIndex(se),Z(se);return}if(q.home){o.setSelectedIndex(0),M(0);return}if(q.end){const se=B.length-1;o.setSelectedIndex(se),Z(se);return}if(J===" "||q.return){w&&o.toggleCheck(w.packageName);return}if(J==="a"){o.toggleAll();return}if(J==="/"){o.setFilterActive(!0);return}if(J==="u"&&!i&&p.checkedEntries.size>0){R(!0);return}if(q.rightArrow){o.setFocusedPanel("detail");return}return}if(p.focusedPanel==="detail"){if(q.escape||q.leftArrow){o.setFocusedPanel("list");return}if(q.downArrow||J==="j"){C.current?.scrollBy(1);return}if(q.upArrow||J==="k"){C.current?.scrollBy(-1);return}if(q.pageDown){C.current?.scrollBy(10);return}if(q.pageUp){C.current?.scrollBy(-10);return}if(q.home){C.current?.scrollToTop();return}q.end&&C.current?.scrollToBottom()}}},{isActive:!0}),d<zp||f<Wp)return c(g,{alignItems:"center",height:f,justifyContent:"center",width:d,children:u(a,{color:"yellow",children:["Terminal too small (",d,"x",f,")"]})});const he=d>=Gp,oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Space"}),c(a,{dimColor:!0,children:"CHECK"})]},"sp"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"a"}),c(a,{dimColor:!0,children:"ALL"})]},"a")];!i&&p.checkedEntries.size>0&&oe.push(u(g,{gap:1,children:[c(a,{bold:!0,color:"green",children:"u"}),c(a,{dimColor:!0,children:"APPLY"})]},"u")),n.length>0&&oe.push(u(g,{gap:1,children:[c(a,{bold:!0,color:"yellow",children:"f"}),u(a,{dimColor:!0,children:["FILTERED (",n.length,")"]})]},"fo")),oe.push(u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"←→"}),c(a,{dimColor:!0,children:"FILTER"})]},"lr"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:"SEARCH"})]},"f"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"t"));const Te=c(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:c(g,{flexWrap:"wrap",gap:2,paddingX:1,children:oe})}),ke=u(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:x,title:"KEYBOARD SHORTCUTS",visible:h,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Move up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Move down"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Tab"]}),c(a,{dimColor:!0,children:" Switch panel"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","→","/","←"]}),c(a,{dimColor:!0,children:" Focus detail/list"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"SELECTION"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Space"]}),c(a,{dimColor:!0,children:" Toggle check on package"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","a"]}),c(a,{dimColor:!0,children:" Toggle check all"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"FILTERS"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","←→"]}),c(a,{dimColor:!0,children:" Switch filter tab"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","/"]}),c(a,{dimColor:!0,children:" Text filter"})]}),n.length>0&&u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","f"]}),c(a,{dimColor:!0,children:" View filtered-out packages"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),!i&&u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","u"]}),c(a,{dimColor:!0,children:" Apply selected updates"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","q"]}),c(a,{dimColor:!0,children:" Quit"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","?"]}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]}),Se=o.getCheckedEntries(),O=Se.filter(J=>J.updateType==="major").length,I=u(g,{alignItems:"center",flexDirection:"column",children:[O>0&&c(g,{marginBottom:1,marginTop:1,children:u(a,{color:"yellow",children:["⚠"," ",O," ","major update",O===1?"":"s"," ","— review breaking changes"]})}),u(a,{dimColor:!0,children:["Press"," ",c(a,{bold:!0,color:"white",children:"u"})," ","or"," ",c(a,{bold:!0,color:"white",children:"Enter"})," ","to confirm,"," ",c(a,{bold:!0,color:"white",children:"Esc"})," ","to cancel"]})]}),Y=c(xt,{footer:I,scrollRef:D,title:`Apply ${Se.length} update${Se.length===1?"":"s"}?`,visible:E,width:70,children:Se.map(J=>u(g,{gap:1,children:[u(a,{children:[" ",J.packageName]}),u(a,{dimColor:!0,children:[J.currentRange," ","→"," ",J.newRange]}),c(a,{bold:!0,color:J.updateType==="major"?"red":J.updateType==="minor"?"yellow":"green",children:J.updateType})]},J.packageName))}),ye=n.length>0?c(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"f"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:S,title:`${n.length} PACKAGE${n.length===1?"":"S"} FILTERED BY TARGET`,visible:y,width:70,children:u(g,{flexDirection:"column",children:[c(g,{marginBottom:1,children:u(a,{dimColor:!0,children:["These packages have newer versions available but are excluded by"," ","the current target constraint. Use"," ",c(a,{bold:!0,color:"white",children:"--target latest"})," ","to include them."]})}),n.map(J=>u(g,{gap:1,children:[u(a,{children:[" ",J.packageName]}),u(a,{dimColor:!0,children:[J.currentRange," ","→"," ",J.newRange]}),c(a,{bold:!0,color:J.updateType==="major"?"red":J.updateType==="minor"?"yellow":"green",children:J.updateType})]},J.packageName))]})}):null,Ae=c(Fp,{checkedEntries:p.checkedEntries,entries:B,filterActive:p.filterActive,filterText:p.filterText,filterType:p.filterType,filteredOutCount:n.length,focused:p.focusedPanel==="list",groupedByCatalog:p.groupedByCatalog,isDryRun:i,scrollOffset:P,selectedIndex:p.selectedIndex,totalCatalogEntries:s,totalChecked:r,totalEntries:B.length,viewportHeight:z}),Ce=c(Pp,{changelogUrl:j,entry:w,focused:p.focusedPanel==="detail",recommendation:v,scrollRef:C});if(he){const J=Math.floor(d*.35);return u(g,{flexDirection:"column",height:f,width:d,children:[u(g,{flexDirection:"row",flexGrow:1,children:[c(g,{flexGrow:1,children:Ae}),c(g,{width:J,children:Ce})]}),Te,Y,ye,c(jt,{autoExitSeconds:t||3,onCancel:$(()=>{G(!1)},"onCancel"),visible:A}),ke]})}const it=Math.floor(f*.55);return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{height:it,children:Ae}),c(g,{flexGrow:1,children:Ce}),Te,Y,ye,c(jt,{autoExitSeconds:t||3,onCancel:$(()=>{G(!1)},"onCancel"),visible:A}),ke]})},"VisUpdateApp");var Hp=Object.defineProperty,Jp=$((t,e)=>Hp(t,"name",{value:e,configurable:!0}),"T$6");const qp={group:"Security & Health",alias:["c","outdated"],argument:{description:"Specific packages to check (checks all if omitted)",name:"packages",type:String},description:"Check for outdated dependencies, security vulnerabilities, and supply chain settings",examples:[["vis check","Check all catalog dependencies"],["vis check react","Check specific packages"],["vis check --target minor","Only show minor/patch updates"],["vis check --exclude '@types/*'","Exclude packages by pattern"],["vis check --no-security","Skip vulnerability scanning"],["vis check --security-config","Audit supply chain security settings"],["vis check --security-config --sync","Sync security config to pnpm-workspace.yaml"]],execute:Jp(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=i;if(r.securityConfig){const R=me(o);if(tp(n??{},R.name),r.sync&&R.name==="pnpm"){const A=rp(n??{});if(A.length>0){k(`
|
|
131
|
+
Settings that would sync to pnpm-workspace.yaml:`);for(const G of A)Q(` ${G}`)}else k("No security settings to sync.")}else r.sync&&R.name!=="pnpm"&&(k(`--sync is only available for pnpm projects. Your project uses ${R.name}.`),k("vis enforces security settings at the vis layer for non-pnpm projects."));if(!r.security&&!t?.length)return}const{packageManager:s}=Jr(o),l=ro(o),d=n?.update??{},f=on(o,s,{dev:r.dev,prod:r.prod});if(f.size===0){e.info("No catalogs found.");return}const p=r.target??d.target??"latest";if(!["latest","minor","patch"].includes(p))throw new Error(`Invalid target "${p}". Use: latest, minor, or patch.`);const h={exclude:[...Me(r.exclude),...Me(d.exclude)],ignore:Me(d.ignore),include:[...Me(r.include),...Me(d.include),...t],includePrerelease:r.prerelease||d.prerelease||!1,security:!r.noSecurity,target:p};let m=0;for(const R of f.values())m+=R.size;const y=!!process.stdout.isTTY&&!Ge;let b;const x=y?(R,A)=>{b?b.rerender(_.createElement(sr,{current:R,total:A})):b=dt(_.createElement(sr,{current:R,total:A}),{interactive:!0,patchConsole:!1})}:(R,A)=>{e.info(`Checking ${String(R)}/${String(A)} dependencies...`)};y||e.info(`Checking ${String(m)} catalog dependencies against npm registry...
|
|
132
|
+
`);const S=It(n?.security?.socket),{failed:C,outdated:D}=await no(f,h,l,x,o,S,n?.security?.socket?.acceptedRisks);if(b&&(b.clear(),b.unmount()),C.length>0&&e.warn(`Failed to fetch: ${C.join(", ")}`),D.length===0){e.info("All catalog dependencies are up to date.");return}const P=r.format??d.format??"table",M=Qn(r.aiType??"impact"),E=r.ai?await Zn(D,e,n?.ai,M):void 0;if(y&&P==="table"){const R=new Bs(D,E??null),A=n?.tui?.autoExit??!1,G=A===!0?3:typeof A=="number"?A:0;await dt(_.createElement(Ls,{autoExitSeconds:G,isDryRun:!0,store:R}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const B=process.stdout.columns||80;process.stdout.write(`
|
|
133
|
+
`);for(const w of D){const v=w.vulnerabilities?.length||w.socketReport&&w.socketReport.alerts.length>0,j=!!w.acceptedRisk,U=v?j?"✓":"⚠":"✓",z=j?"gray":w.updateType==="major"?"red":w.updateType==="minor"?"yellow":"green",Z=w.socketReport?.score.overall,he=Z===void 0?"":` [${String(Math.round(Z*100))}%]`,oe=Z===void 0?void 0:fr(Z);process.stdout.write(`${ge(_.createElement(a,null," ",_.createElement(a,{color:z},U),` ${w.packageName} ${w.currentRange} → ${w.newRange}`,_.createElement(a,{dimColor:!0},` ${w.updateType}`),oe?_.createElement(a,{color:oe},he):null),{columns:B})}
|
|
134
|
+
`)}process.stdout.write(`
|
|
135
|
+
`),e.info(Lr(D))}else if(P==="json"){const R={failed:C,outdated:D};E&&(R.aiAnalysis=E),process.stdout.write(`${JSON.stringify(R,void 0,2)}
|
|
136
|
+
`)}else P==="minimal"?process.stdout.write(`${js(D)}
|
|
137
|
+
`):(Ts(D,e),e.info(Lr(D)),E&&(e.info(""),e.info(Br(E))));r.exitCode&&D.length>0&&(process.exitCode=1)},"execute"),name:"check",options:[{alias:"t",description:"Update target: latest, minor, or patch (default: latest)",name:"target",type:String},{description:"Glob pattern to include packages (repeatable)",lazyMultiple:!0,name:"include",type:String},{description:"Glob pattern to exclude packages (repeatable)",lazyMultiple:!0,name:"exclude",type:String},{defaultValue:!1,description:"Include prerelease versions",name:"prerelease",type:Boolean},{defaultValue:!1,description:"Skip security vulnerability scanning",name:"no-security",type:Boolean},{defaultValue:!1,description:"Audit supply chain security settings",name:"security-config",type:Boolean},{defaultValue:!1,description:"Sync security settings to pnpm-workspace.yaml (pnpm only, requires --security-config)",name:"sync",type:Boolean},{description:"Output format: table, json, or minimal (default: table)",name:"format",type:String},{defaultValue:!1,description:"Exit with code 1 if outdated dependencies found (for CI)",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Run AI analysis on outdated packages",name:"ai",type:Boolean},{description:"AI analysis type: impact, security, compatibility, or recommend",name:"ai-type",type:String},{alias:"D",defaultValue:!1,description:"Check only devDependencies (npm/yarn mode)",name:"dev",type:Boolean},{alias:"P",defaultValue:!1,description:"Check only dependencies (npm/yarn mode)",name:"prod",type:Boolean}]};var Yp=Object.defineProperty,ao=$((t,e)=>Yp(t,"name",{value:e,configurable:!0}),"a$7");const Xp=ao(t=>{const e=[],r=[t];for(;r.length>0;){const n=r.pop();let i;try{i=ft(n)}catch{continue}for(const o of i){const s=L(n,o);try{const l=Ya(s);if(l.isSymbolicLink()||!l.isDirectory())continue}catch{continue}o==="node_modules"?e.push(s):o!==".git"&&o!==".hg"&&r.push(s)}}return e},"findNodeModulesDirectories"),Kp=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],Qp=ao((t,e,r)=>{let n=0,i=!1;for(const o of Kp){const s=L(t,o);if(F(s)){if(e){r.info(` ${s}`),n++;continue}try{Ri(s),Q(`Removed ${s}`),n++}catch(l){or(`${s}: ${Sn(l)}`),i=!0}}}return{hadError:i,removed:n}},"removeLockfiles"),Zp={group:"Workspace",description:"Remove node_modules from all workspace projects",examples:[["vis clean","Remove all node_modules directories"],["vis clean --lockfile","Also remove lockfiles"],["vis clean --dry-run","Preview what would be removed"]],execute:ao(async({logger:t,options:e,workspaceRoot:r})=>{const n=r??process.cwd(),i=e.lockfile||!1;if(e.dryRun){const l=Xp(n);if(l.length>0){k("Would remove:");for(const d of l)t.info(` ${d}`)}else k("No node_modules directories found.");i&&Qp(n,!0,t);return}const o=Qr();if(!o){or("Native bindings unavailable. Ensure the correct platform binary is installed."),process.exitCode=1;return}const s=o.cleanWorkspace(n,i);for(const l of s.removed)Q(`Removed ${l}`);for(const l of s.lockfilesRemoved)Q(`Removed ${l}`);for(const l of s.errors)or(l);s.removed.length===0&&s.lockfilesRemoved.length===0?k("No node_modules directories found."):k(`Cleaned ${s.removed.length} node_modules director${s.removed.length===1?"y":"ies"}`),s.errors.length>0&&(process.exitCode=1)},"execute"),name:"clean",options:[{alias:"l",defaultValue:!1,description:"Also remove lockfiles (pnpm-lock.yaml, package-lock.json, etc.)",name:"lockfile",type:Boolean},{defaultValue:!1,description:"Preview what would be removed without deleting",name:"dry-run",type:Boolean}]};var ef=Object.defineProperty,an=$((t,e)=>ef(t,"name",{value:e,configurable:!0}),"e$6");const tf={"vis:app":"builtin:app","vis:application":"builtin:app","vis:generator":"builtin:generator","vis:lib":"builtin:library","vis:library":"builtin:library","vis:monorepo":"builtin:monorepo"},rf=["https://github.com/","https://gitlab.com/","https://bitbucket.org/","https://raw.githubusercontent.com/","https://git.sr.ht/","git@github.com:","git@gitlab.com:","git@bitbucket.org:","git@git.sr.ht:","github:","gh:","gitlab:","bitbucket:","sourcehut:","git:","http://","https://"],nf=an(t=>{for(const e of rf)if(t.startsWith(e))return!0;return!!(!t.startsWith("@")&&/^[^/#@][^/#]*\/[^/#]+/.test(t))},"isGitUrl"),of=new Set(["sv"]),sf=an(t=>{if(of.has(t)||t.startsWith("create-")||t.startsWith("@")&&t.includes("/create-"))return t;if(t.startsWith("@")){const e=t.indexOf("/");if(e!==-1){const r=t.slice(0,e),n=t.slice(e+1);return`${r}/create-${n}`}return t}return`create-${t}`},"expandCreateShorthand"),af=an((t,e=[])=>{if(!t)throw new Error("No template specified.");const r=t.toLowerCase(),n=tf[r];return n?{args:e,source:r,type:n}:nf(t)?{args:e,source:t,type:"remote:git"}:{args:e,source:sf(t),type:"remote:npm"}},"discoverTemplate"),cf=an(t=>{switch(t){case"builtin:app":return"apps";case"builtin:generator":case"builtin:library":return"packages";default:return"."}},"inferParentDir");var lf=Object.defineProperty,df=$((t,e)=>lf(t,"name",{value:e,configurable:!0}),"o$a");const uf=df(()=>`${So()}-${So()}`,"randomName");var pf=Object.defineProperty,yr=$((t,e)=>pf(t,"name",{value:e,configurable:!0}),"r$f");const Fs=yr(t=>t?yc(t).validForNewPackages:!1,"isValidPackageName"),ar=yr(t=>t.toLowerCase().trim().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d\-~]/g,"-").replace(/^[._-]+/,"").replaceAll(/-{2,}/g,"-").replace(/-$/,""),"toValidPackageName"),ff=new Set([".DS_Store",".git",".gitkeep","Thumbs.db"]),Vs=yr(t=>F(t)?ft(t).every(e=>ff.has(e)):!0,"isEmptyDir"),gf=yr((t,e)=>{const r=rt(e,t);return{packageName:ar(Za(r)),targetDir:r}},"resolveTargetDir"),hf=yr(t=>Vs(t),"canSafelyOverwrite");var mf=Object.defineProperty,cn=$((t,e)=>mf(t,"name",{value:e,configurable:!0}),"l$e");const tr=cn((t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),"ask"),kn=cn(async(t,e,r=!0)=>{const n=await tr(t,` ${e} ${re(r?"[Y/n]":"[y/N]")} `);return n===""?r:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),Wo=cn(async(t,e,r)=>{process.stderr.write(` ${e}
|
|
138
|
+
`);for(const[n,i]of r.entries()){const o=pe(Pe(` ${String(n+1)}.`)),s=i.hint?re(` — ${i.hint}`):"";process.stderr.write(`${o} ${i.label}${s}
|
|
139
|
+
`)}for(;;){const n=await tr(t,`
|
|
140
|
+
${re(`Enter choice (1-${String(r.length)}):`)} `),i=Number.parseInt(n,10);if(i>=1&&i<=r.length)return r[i-1].value;const o=r.find(s=>s.value===n||s.label.toLowerCase()===n.toLowerCase());if(o)return o.value;process.stderr.write(` ${re("Invalid choice. Try again.")}
|
|
141
|
+
`)}},"select"),yf=cn(async t=>{const e=Vt({input:process.stdin,output:process.stdout});try{process.stderr.write(`
|
|
142
|
+
${pe(Pe("vis create"))} ${re("— project scaffolding")}
|
|
143
|
+
|
|
144
|
+
`);const r=t.inMonorepo?[{hint:"Scaffold via create-vite",label:"Vis Application",value:"vis:app"},{hint:"Reusable package scaffold",label:"Vis Library",value:"vis:library"},{hint:"Code generator scaffold",label:"Vis Generator",value:"vis:generator"},{hint:"Enter an npm create-* package or GitHub URL",label:"Custom template",value:"__custom__"}]:[{hint:"Full workspace setup",label:"Vis Monorepo",value:"vis:monorepo"},{hint:"Scaffold via create-vite",label:"Vis Application",value:"vis:app"},{hint:"Reusable package scaffold",label:"Vis Library",value:"vis:library"},{hint:"Code generator scaffold",label:"Vis Generator",value:"vis:generator"},{hint:"Enter an npm create-* package or GitHub URL",label:"Custom template",value:"__custom__"}];let n=await Wo(e,"Select a template:",r);if(n==="__custom__"&&(n=await tr(e,`
|
|
145
|
+
${re("Template (npm package or GitHub URL):")} `),!n))throw new Error("No template specified.");const i=uf(),o=await tr(e,`
|
|
146
|
+
${re(`Project name (${i}):`)} `)||i;if(!Fs(ar(o)))throw new Error(`Invalid project name: "${o}". Must be a valid npm package name.`);const s=ar(o),l=await tr(e,` ${re(`Target directory (${s}):`)} `)||s;let d=!1;const f=rt(t.cwd,l);if(!Vs(f)&&(d=await kn(e,`Directory "${l}" is not empty. Overwrite?`,!1),!d))throw new Error("Aborted — directory not empty.");let p;t.inMonorepo||(t.defaultPm?(p=t.defaultPm,process.stderr.write(` ${re(`Package manager: ${p} (from config)`)}
|
|
147
|
+
`)):p=await Wo(e,"Package manager:",[{label:"pnpm",value:"pnpm"},{label:"npm",value:"npm"},{label:"yarn",value:"yarn"},{label:"bun",value:"bun"}]));let h=!1;t.inMonorepo||(h=await kn(e,"Initialize a git repository?",t.defaultGitInit??!1));const m=t.defaultEditor==="vscode",y=await kn(e,"Generate VS Code configuration?",m)?"vscode":void 0;return process.stderr.write(`
|
|
148
|
+
`),{editor:y,gitInit:h,overwrite:d,pm:p,projectName:o,targetDir:l,template:n}}finally{e.close()}},"runInteractivePrompts");var vf=Object.defineProperty,Rt=$((t,e)=>vf(t,"name",{value:e,configurable:!0}),"i$7");const wf=Rt((t,e)=>{k("Scaffolding application via create-vite...");const r=[Fn(e.cwd,e.targetDir)||".",...t.args];return r.includes("--no-immediate")||r.push("--no-immediate"),Wn(e.pm,{additionalPackages:[],args:r,package:"create-vite",shellMode:!1,silent:!1},e.cwd,e.logger)},"executeApp"),kf=Rt(t=>`${JSON.stringify({devDependencies:{typescript:"^5.0.0",vitest:"^3.0.0"},exports:{".":{default:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist"],main:"./dist/index.js",name:t,scripts:{build:"tsc",dev:"tsc --watch",test:"vitest run","test:watch":"vitest"},type:"module",types:"./dist/index.d.ts",version:"0.0.1"},null,4)}
|
|
149
|
+
`,"libraryPackageJson"),bf=Rt(()=>`${JSON.stringify({compilerOptions:{declaration:!0,declarationMap:!0,esModuleInterop:!0,module:"Node16",moduleResolution:"Node16",outDir:"./dist",rootDir:"./src",skipLibCheck:!0,sourceMap:!0,strict:!0,target:"ES2022"},include:["src/**/*"]},null,4)}
|
|
150
|
+
`,"libraryTsconfig"),$f=Rt(t=>`/**
|
|
151
|
+
* ${t} — library entry point.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
export const greet = (name: string): string => \`Hello from ${t}, \${name}!\`;
|
|
155
|
+
`,"librarySrcIndex"),xf=Rt(t=>`import { describe, expect, it } from "vitest";
|
|
156
|
+
|
|
157
|
+
import { greet } from "../src/index";
|
|
158
|
+
|
|
159
|
+
describe("${t}", () => {
|
|
160
|
+
it("should greet", () => {
|
|
161
|
+
expect(greet("world")).toBe("Hello from ${t}, world!");
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
`,"libraryTestIndex"),Sf=Rt((t,e)=>{const{projectName:r,targetDir:n}=e;return k("Scaffolding library package..."),$e(n,{recursive:!0}),$e(L(n,"src"),{recursive:!0}),$e(L(n,"__tests__"),{recursive:!0}),H(L(n,"package.json"),kf(r)),Q("Created package.json"),H(L(n,"tsconfig.json"),bf()),Q("Created tsconfig.json"),H(L(n,"src","index.ts"),$f(r)),Q("Created src/index.ts"),H(L(n,"__tests__","index.test.ts"),xf(r)),Q("Created __tests__/index.test.ts"),H(L(n,".gitignore"),`node_modules/
|
|
165
|
+
dist/
|
|
166
|
+
.env
|
|
167
|
+
.DS_Store
|
|
168
|
+
`),Q("Created .gitignore"),0},"executeLibrary"),Cf=Rt((t,e)=>{switch(t.type){case"builtin:app":return wf(t,e);case"builtin:library":return Sf(t,e);default:throw new Error(`Unknown built-in template type: ${t.type}`)}},"executeBuiltin");var Ef=Object.defineProperty,vr=$((t,e)=>Ef(t,"name",{value:e,configurable:!0}),"r$e");const jf=vr((t,e)=>`${JSON.stringify({bin:{[t]:"./bin/index.js"},description:e,devDependencies:{typescript:"^5.0.0"},name:t,private:!0,scripts:{build:"tsc",dev:"tsc --watch"},type:"module",version:"0.0.1"},null,4)}
|
|
169
|
+
`,"packageJson"),Tf=vr(t=>`#!/usr/bin/env node
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* ${t} — code generator
|
|
173
|
+
*
|
|
174
|
+
* Usage: npx ${t} [options]
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
console.log("Hello from ${t}!");
|
|
178
|
+
`,"binIndex"),Af=vr(()=>`${JSON.stringify({compilerOptions:{declaration:!0,esModuleInterop:!0,module:"Node16",moduleResolution:"Node16",outDir:"./dist",rootDir:"./src",skipLibCheck:!0,strict:!0,target:"ES2022"},include:["src/**/*","bin/**/*"]},null,4)}
|
|
179
|
+
`,"tsconfigJson"),If=vr(()=>`/**
|
|
180
|
+
* Generator core logic — export functions used by the CLI entry point.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
export const generate = (): void => {
|
|
184
|
+
// TODO: Implement your generator logic here
|
|
185
|
+
};
|
|
186
|
+
`,"srcIndex"),Rf=vr((t,e="")=>{const{projectName:r,targetDir:n}=t;k("Scaffolding code generator..."),$e(n,{recursive:!0}),$e(L(n,"bin"),{recursive:!0}),$e(L(n,"src"),{recursive:!0}),H(L(n,"package.json"),jf(r,e||`Code generator: ${r}`)),Q("Created package.json");const i=L(n,"bin","index.js");return H(i,Tf(r)),Xa(i,493),Q("Created bin/index.js (executable)"),H(L(n,"tsconfig.json"),Af()),Q("Created tsconfig.json"),H(L(n,"src","index.ts"),If()),Q("Created src/index.ts"),0},"executeGeneratorTemplate");var Of=Object.defineProperty,_t=$((t,e)=>Of(t,"name",{value:e,configurable:!0}),"s$h");const Pf=_t(t=>`${JSON.stringify({devDependencies:{"@visulima/vis":"latest"},name:t,packageManager:"pnpm@latest",private:!0,scripts:{build:"vis run build",dev:"vis run dev",lint:"vis run lint",test:"vis run test"},type:"module",version:"0.0.0"},null,4)}
|
|
187
|
+
`,"rootPackageJson"),Nf=_t(()=>`packages:
|
|
188
|
+
- "apps/*"
|
|
189
|
+
- "packages/*"
|
|
190
|
+
`,"pnpmWorkspaceYaml"),Df=_t(()=>`# Dependencies
|
|
191
|
+
node_modules/
|
|
192
|
+
|
|
193
|
+
# Build output
|
|
194
|
+
dist/
|
|
195
|
+
.output/
|
|
196
|
+
|
|
197
|
+
# Environment
|
|
198
|
+
.env
|
|
199
|
+
.env.local
|
|
200
|
+
.env.*.local
|
|
201
|
+
|
|
202
|
+
# IDE
|
|
203
|
+
.vscode/*
|
|
204
|
+
!.vscode/settings.json
|
|
205
|
+
!.vscode/extensions.json
|
|
206
|
+
.idea/
|
|
207
|
+
|
|
208
|
+
# OS
|
|
209
|
+
.DS_Store
|
|
210
|
+
Thumbs.db
|
|
211
|
+
|
|
212
|
+
# Logs
|
|
213
|
+
*.log
|
|
214
|
+
npm-debug.log*
|
|
215
|
+
pnpm-debug.log*
|
|
216
|
+
|
|
217
|
+
# Cache
|
|
218
|
+
.turbo/
|
|
219
|
+
.cache/
|
|
220
|
+
`,"gitignore"),Mf=_t(()=>`root = true
|
|
221
|
+
|
|
222
|
+
[*]
|
|
223
|
+
indent_style = space
|
|
224
|
+
indent_size = 4
|
|
225
|
+
end_of_line = lf
|
|
226
|
+
charset = utf-8
|
|
227
|
+
trim_trailing_whitespace = true
|
|
228
|
+
insert_final_newline = true
|
|
229
|
+
|
|
230
|
+
[*.{yml,yaml}]
|
|
231
|
+
indent_size = 2
|
|
232
|
+
|
|
233
|
+
[*.md]
|
|
234
|
+
trim_trailing_whitespace = false
|
|
235
|
+
`,"editorconfig"),Bf=_t(t=>`# ${t}
|
|
236
|
+
|
|
237
|
+
A monorepo powered by [vis](https://visulima.com/packages/vis).
|
|
238
|
+
|
|
239
|
+
## Getting Started
|
|
240
|
+
|
|
241
|
+
\`\`\`bash
|
|
242
|
+
# Install dependencies
|
|
243
|
+
pnpm install
|
|
244
|
+
|
|
245
|
+
# Run all apps in development mode
|
|
246
|
+
pnpm dev
|
|
247
|
+
|
|
248
|
+
# Build all packages
|
|
249
|
+
pnpm build
|
|
250
|
+
|
|
251
|
+
# Run tests
|
|
252
|
+
pnpm test
|
|
253
|
+
\`\`\`
|
|
254
|
+
|
|
255
|
+
## Structure
|
|
256
|
+
|
|
257
|
+
\`\`\`
|
|
258
|
+
├── apps/ # Applications
|
|
259
|
+
├── packages/ # Shared packages & libraries
|
|
260
|
+
├── pnpm-workspace.yaml
|
|
261
|
+
└── package.json
|
|
262
|
+
\`\`\`
|
|
263
|
+
`,"readmeMd"),Lf=_t(t=>{const{projectName:e,targetDir:r}=t;return k("Scaffolding monorepo workspace..."),$e(r,{recursive:!0}),$e(L(r,"apps"),{recursive:!0}),$e(L(r,"packages"),{recursive:!0}),H(L(r,"package.json"),Pf(e)),Q("Created package.json"),H(L(r,"pnpm-workspace.yaml"),Nf()),Q("Created pnpm-workspace.yaml"),H(L(r,".gitignore"),Df()),Q("Created .gitignore"),H(L(r,".editorconfig"),Mf()),Q("Created .editorconfig"),H(L(r,"README.md"),Bf(e)),Q("Created README.md"),H(L(r,"apps",".gitkeep"),""),H(L(r,"packages",".gitkeep"),""),0},"executeMonorepoTemplate");var Ff=Object.defineProperty,co=$((t,e)=>Ff(t,"name",{value:e,configurable:!0}),"i$6");const Vf={"create-nuxt":{monoArgs:["--no-gitInit"]},"create-vite":{args:["--no-immediate"]},sv:{args:["--no-install"],prependCommand:"create"}},Uf=co((t,e,r)=>{const n=Vf[t];if(!n)return e;const i=[...e];if(n.prependCommand&&!i.includes(n.prependCommand)&&i.unshift(n.prependCommand),n.args)for(const o of n.args)i.includes(o)||i.push(o);if(r&&n.monoArgs)for(const o of n.monoArgs)i.includes(o)||i.push(o);return i},"applyAutoFixes"),Gf=co((t,e)=>{const r=Fn(e.cwd,e.targetDir)||".",n=[...t.args];n.includes(r)||n.unshift(r);const i=Uf(t.source,n,e.inMonorepo);return k(`Running ${t.source} via ${e.pm.name} dlx...`),Wn(e.pm,{additionalPackages:[],args:i,package:t.source,shellMode:!1,silent:!1},e.cwd,e.logger)},"executeRemoteNpm"),zf=co(async(t,e)=>{const{createConfig:r}=e;k(`Downloading template from ${t.source}...`);try{const n=await vc(t.source,{auth:r?.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:e.targetDir,force:!0,preferOffline:r?.preferOffline,provider:r?.defaultProvider,registry:r?.registry});return k(`Downloaded to ${n.dir}`),0}catch(n){const i=n instanceof Error?n.message:String(n);return ae(`Failed to download template: ${i}`),1}},"executeRemoteGit");var Wf=Object.defineProperty,_f=$((t,e)=>Wf(t,"name",{value:e,configurable:!0}),"r$d");const Hf=_f(async(t,e)=>{switch(t.type){case"builtin:app":case"builtin:library":return Cf(t,e);case"builtin:generator":return Rf(e);case"builtin:monorepo":return Lf(e);case"remote:git":return zf(t,e);case"remote:npm":return Gf(t,e);default:throw new Error(`Unknown template type: ${t.type}`)}},"executeTemplate");var Jf=Object.defineProperty,yt=$((t,e)=>Jf(t,"name",{value:e,configurable:!0}),"f$9");const qf=yt(t=>{const e=L(t,".vscode");F(e)||$e(e,{recursive:!0});const r=L(e,"settings.json"),n={"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnSave":!0};if(F(r))try{const s=JSON.parse(K(r,"utf8"));H(r,`${JSON.stringify({...n,...s},null,4)}
|
|
264
|
+
`),Q("Merged .vscode/settings.json")}catch{ae("Could not merge .vscode/settings.json, skipping")}else H(r,`${JSON.stringify(n,null,4)}
|
|
265
|
+
`),Q("Created .vscode/settings.json");const i=L(e,"extensions.json"),o={recommendations:["oxc.oxc-vscode"]};if(F(i))try{const s=JSON.parse(K(i,"utf8"));H(i,`${JSON.stringify({...s,recommendations:[...new Set([...s.recommendations||[],...o.recommendations])]},null,4)}
|
|
266
|
+
`),Q("Merged .vscode/extensions.json")}catch{ae("Could not merge .vscode/extensions.json, skipping")}else H(i,`${JSON.stringify(o,null,4)}
|
|
267
|
+
`),Q("Created .vscode/extensions.json")},"generateVscodeConfig"),Yf=yt((t,e)=>{const r=L(t,".ai");$e(r,{recursive:!0});const n=L(r,"instructions");if(F(n))return;const i=`# Project Instructions
|
|
268
|
+
|
|
269
|
+
This project was scaffolded with vis create.
|
|
270
|
+
|
|
271
|
+
## Development
|
|
272
|
+
|
|
273
|
+
- Package manager: ${e}
|
|
274
|
+
- Build: \`${e} run build\`
|
|
275
|
+
- Test: \`${e} run test\`
|
|
276
|
+
- Lint: \`${e} run lint\`
|
|
277
|
+
|
|
278
|
+
## Conventions
|
|
279
|
+
|
|
280
|
+
- Use TypeScript strict mode
|
|
281
|
+
- ESM modules (\`"type": "module"\`)
|
|
282
|
+
- Follow Angular-style conventional commits
|
|
283
|
+
`;H(n,i),Q("Created .ai/instructions")},"generateAiInstructions"),Xf=yt(t=>{Le("git",["init"],{cwd:t,stdio:"pipe"}).status===0?Q("Initialized git repository"):ae("Failed to initialize git repository")},"initGitRepo"),Kf=yt((t,e,r,n=!1)=>(k("Installing dependencies..."),Zr(e,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:n},t,r)===0?(Q("Dependencies installed"),!0):(ae("Dependency installation failed (you can run install manually)"),!1)),"installDependencies"),Qf=yt(t=>{const e=t.split("#")[0].split("?")[0].replace(/\/+$/,"").replace(/\.git$/,"").split("/").filter(Boolean).at(-1)??"",r=e.includes(":")?e.split(":").pop()??e:e;return ar(r)||"my-project"},"extractRepoName"),Zf=yt(t=>{if(k(""),k(" Built-in templates:"),k(` ${pe(Pe("vis:monorepo"))} ${re("Full pnpm workspace setup")}`),k(` ${pe(Pe("vis:app"))} ${re("Application scaffold via create-vite")}`),k(` ${pe(Pe("vis:library"))} ${re("Reusable TypeScript library package")}`),k(` ${pe(Pe("vis:generator"))} ${re("Code generator scaffold with bin entry")}`),t&&Object.keys(t).length>0){k(""),k(" Config aliases (vis.config.ts → create.templates):");for(const[e,r]of Object.entries(t))k(` ${pe(Pe(e))}${" ".repeat(Math.max(1,16-e.length))}${re(r)}`)}k(""),k(" Remote templates:"),k(` ${re("Any npm create-* package:")} vis create vite`),k(` ${re("GitHub repository:")} vis create user/repo`),k(` ${re("GitLab / Bitbucket:")} vis create gitlab:user/repo`),k(` ${re("Full URL:")} vis create https://github.com/user/repo`),k(""),k(` ${re("Template args after --:")} vis create vite -- --template react-ts`),k("")},"listTemplates"),eg=yt((t,e,r,n)=>{const i=rt(e)===rt(t)?"":t;process.stderr.write(`
|
|
284
|
+
`),Q("Project created successfully!"),process.stderr.write(`
|
|
285
|
+
`),te("Next steps:"),i&&k(` cd ${i}`),n||k(` ${r} install`),k(` ${r} run dev`),process.stderr.write(`
|
|
286
|
+
`)},"printNextSteps"),tg={group:"Scaffold & Config",argument:{description:"Template to use (e.g., vis:app, create-vite, user/repo) — omit for interactive mode",name:"template",type:String},description:"Create a new project from a template",examples:[["vis create","Interactive project scaffolding"],["vis create vis:monorepo my-workspace","Create a monorepo workspace"],["vis create vis:app my-app","Scaffold a Vite application"],["vis create vis:library my-lib","Create a TypeScript library"],["vis create vite my-app -- --template react-ts","Use create-vite with React TypeScript"],["vis create user/repo my-project","Clone a GitHub template"],["vis create --list","Show available templates"]],execute:yt(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{const o=Array.isArray(t)?t:t?[t]:[],s=n?.create;if(r.list){Zf(s?.templates);return}const l=r.cwd||i||process.cwd(),d=!!i,f=!!process.stdin.isTTY,p=me(l);let h,m,y,b=s?.defaultEditor,x=s?.gitInit??!1,S=[],C=p,D=!1;if(o.length===0&&f&&!r.noInteractive){const w=await yf({cwd:l,defaultEditor:s?.defaultEditor,defaultGitInit:s?.gitInit,defaultPm:s?.defaultPm,inMonorepo:d});h=w.template,m=w.projectName,y=rt(l,w.targetDir),b=w.editor??b,x=w.gitInit,D=w.overwrite,w.pm&&(C={name:w.pm,version:p.version})}else{if(o.length===0)throw new Error(`No template specified. Usage: vis create <template> [name] [-- args...]
|
|
287
|
+
Use --list to see available templates, or run interactively in a terminal.`);{const w=o.indexOf("--"),v=w===-1?o:o.slice(0,w);S=w===-1?[]:o.slice(w+1),h=v[0],m=v[1],m||(m=Qf(h)),b=r.editor==="vscode"?"vscode":b,x=!!r.gitInit||x}}if(!h)throw new Error("No template specified.");const P=s?.templates?.[h]??h,M=af(P,S);if(!y){const w=d?cf(M.type):".",v=gf(m,rt(l,w));y=v.targetDir,m=v.packageName}const E=ar(m??"");if(!Fs(E))throw new Error(`Invalid project name: "${m}". Use lowercase alphanumeric characters and hyphens.`);m=E;const R=rt(y),A=Fn(rt(l),R);if(A===".."||A.startsWith(`..${ec}`)||tc(A))throw new Error(`Target directory "${y}" is outside the working directory. Use a name without "../" path segments.`);if(!D&&!hf(y))throw new Error(`Target directory "${y}" is not empty.
|
|
288
|
+
Use a different name or clear the directory first.`);P!==h&&k(`Alias: ${pe(Pe(h))} → ${re(P)}`),k(`Template: ${pe(Pe(P))}`),k(`Project: ${pe(m)}`),k(`Target: ${re(y)}`),process.stderr.write(`
|
|
289
|
+
`);const G=await Hf(M,{createConfig:s,cwd:l,inMonorepo:d,logger:e,pm:C,projectName:m,targetDir:y});if(G!==0){process.exitCode=G;return}b==="vscode"&&qf(y),F(y)&&Yf(y,C.name),x&&!d&&Xf(y);let B=!1;s?.install!==!1&&F(L(y,"package.json"))&&(B=Kf(y,C,e,s?.preferOffline)),eg(y,l,C.name,B)},"execute"),name:"create",options:[{defaultValue:!1,description:"Show available templates",name:"list",type:Boolean},{description:"Generate editor configs (vscode)",name:"editor",type:String},{defaultValue:!1,description:"Initialize a git repository",name:"git-init",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts",name:"no-interactive",type:Boolean}]};var rg=Object.defineProperty,ng=$((t,e)=>rg(t,"name",{value:e,configurable:!0}),"i$5");const og={group:"Dependencies",description:"Deduplicate dependencies using the detected package manager",examples:[["vis dedupe","Run deduplication"],["vis dedupe --check","Preview changes without modifying (CI-friendly)"]],execute:ng(async({logger:t,options:e,workspaceRoot:r})=>{const n=r??process.cwd(),i=me(n),o=Wc(i,e.check||!1,n,t);o!==0&&(process.exitCode=o)},"execute"),name:"dedupe",options:[{defaultValue:!1,description:"Preview changes without modifying files (dry-run)",name:"check",type:Boolean}]},Lt=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}];var ig=Object.defineProperty,Us=$((t,e)=>ig(t,"name",{value:e,configurable:!0}),"s$f");const sg=Us(t=>{const e=T(t,".devcontainer","devcontainer.json");if(!F(e))return null;const r=K(e,"utf8"),n=wc(r),i=n!==r;let o;try{o=JSON.parse(n)}catch(s){const l=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse ${e}: ${l}`)}return{config:o,hadComments:i}},"readDevcontainerJson"),ag=Us((t,e,r)=>{const n=r?Ln(r):T(t,".devcontainer"),i=r??T(n,"devcontainer.json");$e(n,{recursive:!0}),H(i,JSON.stringify(e,null,2)+`
|
|
290
|
+
`,"utf8")},"writeDevcontainerJson");var cg=Object.defineProperty,lg=$((t,e)=>cg(t,"name",{value:e,configurable:!0}),"s$e");const dg={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},ug=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],_o=lg((t,e,r)=>{const n=[],i=new Set(r.map(s=>typeof s=="string"?s:s.target));if(t)for(const s of dg[t])i.has(s.target)||n.push(s);const o=Object.keys(e);for(const{featureMatch:s,mounts:l}of ug)if(o.some(d=>d.includes(s)))for(const d of l)i.has(d.target)||n.push(d);return n},"getSuggestedMounts"),bt=["general","features","ports","lifecycle","extensions","environment","mounts","compose"];var pg=Object.defineProperty,Nr=$((t,e)=>pg(t,"name",{value:e,configurable:!0}),"c$c");const Yt=Nr(t=>JSON.parse(JSON.stringify(t)),"deepClone");class fg{static{$(this,"DevcontainerStore")}static{Nr(this,"DevcontainerStore")}#e=new Set;#t;constructor(e,r,n=null){const i=e===null,o=e??{name:""},s=Yt(o);this.#t={config:s,detectedPm:n,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:r,isDirty:!1,mode:i?"create":"edit",originalConfig:i?null:Yt(o),section:"general",showTemplateSelector:i,suggestedMounts:_o(n,s.features??{},s.mounts??[]),templateIndex:0}}getSnapshot=Nr(()=>this.#t,"getSnapshot");subscribe=Nr(e=>(this.#e.add(e),()=>{this.#e.delete(e)}),"subscribe");setSection(e){e!==this.#t.section&&this.#r({...this.#t,fieldEditing:!1,fieldIndex:0,section:e})}nextSection(){const e=(bt.indexOf(this.#t.section)+1)%bt.length;this.setSection(bt[e])}previousSection(){const e=(bt.indexOf(this.#t.section)-1+bt.length)%bt.length;this.setSection(bt[e])}setFieldIndex(e){e!==this.#t.fieldIndex&&this.#r({...this.#t,fieldIndex:Math.max(0,e)})}setFieldEditing(e){e!==this.#t.fieldEditing&&this.#r({...this.#t,fieldEditing:e})}setTemplateIndex(e){const r=Math.max(0,Math.min(e,Lt.length-1));r!==this.#t.templateIndex&&this.#r({...this.#t,templateIndex:r})}applyTemplate(e){const r=Lt.find(n=>n.id===e);r&&this.#r(this.#o({...this.#t,config:Yt(r.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#r({...this.#t,showTemplateSelector:!1})}updateConfig(e){this.#r({...this.#t,config:{...this.#t.config,...e},isDirty:!0})}toggleFeature(e){const r={...this.#t.config.features};r[e]!==void 0?delete r[e]:r[e]={},this.#r(this.#o({...this.#t,config:{...this.#t.config,features:r},isDirty:!0}))}setFeatureSearch(e){this.#r({...this.#t,featureSearch:e,fieldIndex:0})}addPort(e){const r=this.#t.config.forwardPorts??[];if(r.includes(e))return;const n=[...r,e];this.#r({...this.#t,config:{...this.#t.config,forwardPorts:n},isDirty:!0})}removePort(e){const r=[...this.#t.config.forwardPorts??[]];r.splice(e,1),this.#r({...this.#t,config:{...this.#t.config,forwardPorts:r.length>0?r:void 0},isDirty:!0})}toggleExtension(e){const r={...this.#t.config.customizations},n={...r.vscode},i=[...n.extensions??[]],o=i.indexOf(e);o>=0?i.splice(o,1):i.push(e),n.extensions=i.length>0?i:void 0,r.vscode=n.extensions||n.settings?n:void 0,this.#r({...this.#t,config:{...this.#t.config,customizations:r.vscode||r.jetbrains?r:void 0},isDirty:!0})}setExtensionSearch(e){this.#r({...this.#t,extensionSearch:e,fieldIndex:0})}addEnvVar(e,r,n){const i=e==="container"?"containerEnv":"remoteEnv",o={...this.#t.config[i],[r]:n};this.#r({...this.#t,config:{...this.#t.config,[i]:o},isDirty:!0})}removeEnvVar(e,r){const n=e==="container"?"containerEnv":"remoteEnv",i={...this.#t.config[n]};delete i[r],this.#r({...this.#t,config:{...this.#t.config,[n]:Object.keys(i).length>0?i:void 0},isDirty:!0})}addMount(e){const r=[...this.#t.config.mounts??[],e];this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:r},isDirty:!0}))}removeMount(e){const r=[...this.#t.config.mounts??[]];r.splice(e,1),this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:r.length>0?r:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#t.suggestedMounts.length===0)return;const e=[...this.#t.config.mounts??[],...this.#t.suggestedMounts];this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:e},isDirty:!0}))}setLifecycleCommand(e,r){this.#r({...this.#t,config:{...this.#t.config,[e]:r||void 0},isDirty:!0})}markClean(){this.#r({...this.#t,isDirty:!1,originalConfig:Yt(this.#t.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const e=Yt(this.#t.config);for(const[r,n]of Object.entries(e))(n===""||n===void 0)&&delete e[r];return e.build&&(e.build.dockerfile===""&&delete e.build.dockerfile,e.build.context===""&&delete e.build.context,e.build.args&&Object.keys(e.build.args).length===0&&delete e.build.args,Object.keys(e.build).length===0&&delete e.build),e.forwardPorts?.length===0&&delete e.forwardPorts,e.mounts?.length===0&&delete e.mounts,e.runServices?.length===0&&delete e.runServices,e.capAdd?.length===0&&delete e.capAdd,e.securityOpt?.length===0&&delete e.securityOpt,e.features&&Object.keys(e.features).length===0&&delete e.features,e.customizations?.vscode?.extensions?.length===0&&delete e.customizations.vscode.extensions,e.customizations?.vscode&&Object.keys(e.customizations.vscode).length===0&&delete e.customizations.vscode,e.customizations&&Object.keys(e.customizations).length===0&&delete e.customizations,e.containerEnv&&Object.keys(e.containerEnv).length===0&&delete e.containerEnv,e.remoteEnv&&Object.keys(e.remoteEnv).length===0&&delete e.remoteEnv,e}#o(e){return{...e,suggestedMounts:_o(e.detectedPm,e.config.features??{},e.config.mounts??[])}}#r(e){this.#t=e;for(const r of this.#e)try{r()}catch{}}}const Ho=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],Jo=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}];var gg=Object.defineProperty,Gs=$((t,e)=>gg(t,"name",{value:e,configurable:!0}),"r$a");const lo=Gs(t=>{if(!t)return Jo;const e=t.toLowerCase();return Jo.filter(r=>r.name.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.description.toLowerCase().includes(e))},"filterFeatures"),uo=Gs(t=>{if(!t)return Ho;const e=t.toLowerCase();return Ho.filter(r=>r.name.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.description.toLowerCase().includes(e))},"filterExtensions");var hg=Object.defineProperty,mg=$((t,e)=>hg(t,"name",{value:e,configurable:!0}),"l$9");const zs=["dockerComposeFile","service"],yg={dockerComposeFile:"Compose File",service:"Service"},qo={dockerComposeFile:"docker-compose.yml",service:"app"},vg={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},wg=mg(({config:t,fieldEditing:e,fieldIndex:r,onUpdate:n})=>{const i=!!t.dockerComposeFile,o=!!(t.image||t.build);return u(g,{flexDirection:"column",paddingX:1,children:[c(g,{marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),o&&i&&c(g,{marginBottom:1,children:c(a,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),zs.map((s,l)=>{const d=l===r,f=t[s]??"",p=Array.isArray(t[s])?t[s].join(", "):f;return u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{children:[c(g,{width:20,children:u(a,{bold:d,color:d?"cyan":"white",children:[d?"❯ ":" ",yg[s],":"]})}),c(g,{flexGrow:1,children:d&&e?c(Un,{defaultValue:p,onChange:$(h=>{n({[s]:h||void 0})},"onChange"),placeholder:qo[s]}):c(a,{color:p?"white":"gray",children:p||qo[s]})})]}),c(g,{paddingLeft:4,children:c(a,{dimColor:!0,children:vg[s]})})]},s)}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," edit field"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"," ",c(a,{bold:!0,color:"white",children:"Esc"})," stop editing"]})})]})},"DockerComposeSection"),kg=zs.length;var bg=Object.defineProperty,Ws=$((t,e)=>bg(t,"name",{value:e,configurable:!0}),"h$b");const $g=Ws(({config:t,fieldIndex:e})=>{const r=t.containerEnv??{},n=t.remoteEnv??{},i=Object.keys(r),o=Object.keys(n),s=i.length,l=i.length+1,d=l+o.length,f=e<=s,p=e>s;return u(g,{flexDirection:"column",paddingX:1,children:[u(g,{borderColor:f?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[u(g,{flexShrink:0,marginBottom:i.length>0?1:0,children:[c(a,{bold:!0,color:f?"cyan":"white",children:"containerEnv"}),c(a,{dimColor:!0,children:" — baked into the container image"})]}),i.map((h,m)=>{const y=m===e;return c(g,{flexShrink:0,children:u(a,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",c(a,{bold:!0,children:h}),c(a,{dimColor:!0,children:" = "}),c(a,{children:r[h]})]})},h)}),c(g,{flexShrink:0,marginTop:i.length>0?1:0,children:u(a,{color:e===s?"cyan":"gray",inverse:e===s,children:[" ","+ Add variable..."]})})]}),u(g,{borderColor:p?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[u(g,{flexShrink:0,marginBottom:o.length>0?1:0,children:[c(a,{bold:!0,color:p?"cyan":"white",children:"remoteEnv"}),c(a,{dimColor:!0,children:" — set at runtime by the IDE"})]}),o.map((h,m)=>{const y=l+m===e;return c(g,{flexShrink:0,children:u(a,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",c(a,{bold:!0,children:h}),c(a,{dimColor:!0,children:" = "}),c(a,{children:n[h]})]})},h)}),c(g,{flexShrink:0,marginTop:o.length>0?1:0,children:u(a,{color:e===d?"cyan":"gray",inverse:e===d,children:[" ","+ Add variable..."]})})]}),c(g,{flexShrink:0,marginTop:1,children:u(a,{dimColor:!0,wrap:"truncate",children:[c(a,{bold:!0,color:"white",children:"a"}),"/",c(a,{bold:!0,color:"white",children:"Enter"})," add on + row ",c(a,{bold:!0,color:"white",children:"d"})," remove ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"]})})]})},"EnvironmentSection"),xg=Ws(t=>{const e=Object.keys(t.containerEnv??{}).length,r=Object.keys(t.remoteEnv??{}).length;return e+1+r+1},"getEnvFieldCount");var Sg=Object.defineProperty,Cg=$((t,e)=>Sg(t,"name",{value:e,configurable:!0}),"h$a");const Eg=Cg(({config:t,fieldIndex:e,scrollOffset:r,searchText:n,viewportHeight:i})=>{const o=Ke(()=>new Set(t.customizations?.vscode?.extensions??[]),[t.customizations?.vscode?.extensions]),s=Ke(()=>uo(n),[n]),l=s.length,d=l>i&&i>0;return u(g,{flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[u(a,{bold:!0,color:"cyan",children:[o.size," selected"]}),n&&u(a,{dimColor:!0,children:["— filter: ",c(a,{color:"yellow",children:n})," (",s.length," results)"]})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-r,children:s.map((f,p)=>{const h=p===e,m=o.has(f.id);return u(g,{flexShrink:0,height:1,children:[c(a,{children:h?">":" "}),u(a,{color:m?"white":"gray",children:[" ",m?"☑":"☐"," "]}),c(g,{flexGrow:1,children:u(a,{bold:h,inverse:h,wrap:"truncate",children:[f.name,u(a,{dimColor:!0,children:[" - ",f.id]})]})})]},f.id)})})}),d&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:l,placement:"inset",scrollOffset:r,style:"block",viewportHeight:i})})]}),s.length===0&&c(g,{paddingX:1,children:c(a,{dimColor:!0,children:"No extensions match the search."})})]})},"ExtensionsSection");var jg=Object.defineProperty,Tg=$((t,e)=>jg(t,"name",{value:e,configurable:!0}),"p$d");const Ag=Tg(({config:t,fieldIndex:e,scrollOffset:r,searchText:n,viewportHeight:i})=>{const o=Ke(()=>new Set(Object.keys(t.features??{})),[t.features]),s=Ke(()=>lo(n),[n]),l=s.length,d=l>i&&i>0;return u(g,{flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[u(a,{bold:!0,color:"cyan",children:[o.size," selected"]}),n&&u(a,{dimColor:!0,children:["— filter: ",c(a,{color:"yellow",children:n})," (",s.length," results)"]})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-r,children:s.map((f,p)=>{const h=p===e,m=o.has(f.id);return u(g,{flexShrink:0,height:1,children:[c(a,{children:h?">":" "}),u(a,{color:m?"white":"gray",children:[" ",m?"☑":"☐"," "]}),c(g,{flexGrow:1,children:u(a,{bold:h,inverse:h,wrap:"truncate",children:[f.name,u(a,{dimColor:!0,children:[" - ",f.description]})]})})]},f.id)})})}),d&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:l,placement:"inset",scrollOffset:r,style:"block",viewportHeight:i})})]}),s.length===0&&c(g,{paddingX:1,children:c(a,{dimColor:!0,children:"No features match the search."})})]})},"FeaturesSection");var Ig=Object.defineProperty,Rg=$((t,e)=>Ig(t,"name",{value:e,configurable:!0}),"u$b");const Tn=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],Og={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},Yo={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},Vr=["privileged","overrideCommand"],Pg={overrideCommand:"Override Command",privileged:"Privileged"},Ng=Tn.length+Vr.length,Dg=Rg(({config:t,fieldEditing:e,fieldIndex:r,onUpdate:n})=>u(g,{flexDirection:"column",paddingX:1,children:[c(g,{marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"General Configuration"})}),Tn.map((i,o)=>{const s=o===r,l=t[i]??"";return u(g,{marginBottom:1,children:[c(g,{width:20,children:u(a,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Og[i],":"]})}),c(g,{flexGrow:1,children:s&&e?c(Un,{defaultValue:l,onChange:$(d=>{n({[i]:d})},"onChange"),placeholder:Yo[i]}):c(a,{color:l?"white":"gray",children:l||Yo[i]})})]},i)}),Vr.map((i,o)=>{const s=Tn.length+o===r,l=t[i]??!1;return u(g,{marginBottom:o<Vr.length-1?1:0,children:[c(g,{width:20,children:u(a,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Pg[i],":"]})}),c(g,{flexGrow:1,children:u(a,{color:l?"green":"gray",children:[l?"yes":"no",s&&c(a,{dimColor:!0,children:" (Space to toggle)"})]})})]},i)}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," edit field"," ",c(a,{bold:!0,color:"white",children:"Space"})," toggle"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"," ",c(a,{bold:!0,color:"white",children:"Esc"})," stop editing"]})})]}),"GeneralSection"),_s=Ng,bn=Vr;var Mg=Object.defineProperty,Bg=$((t,e)=>Mg(t,"name",{value:e,configurable:!0}),"s$c");const Hs=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],Lg={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},Fg={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Vg=Bg(({config:t,fieldEditing:e,fieldIndex:r,onSetCommand:n})=>u(g,{flexDirection:"column",paddingX:1,children:[c(g,{marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Hs.map((i,o)=>{const s=o===r,l=t[i],d=Array.isArray(l)?l.join(" && "):l??"";return u(g,{flexDirection:"column",marginBottom:1,children:[c(g,{children:u(a,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Lg[i]]})}),c(g,{paddingLeft:4,children:c(a,{dimColor:!0,children:Fg[i]})}),c(g,{paddingLeft:4,children:s&&e?c(Un,{defaultValue:d,onChange:$(f=>{n(i,f)},"onChange"),placeholder:"e.g. npm install"}):c(a,{color:d?"green":"gray",children:d||"(not set)"})})]},i)}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," edit command"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"," ",c(a,{bold:!0,color:"white",children:"Esc"})," stop editing"]})})]}),"LifecycleSection"),Ug=Hs.length;var Gg=Object.defineProperty,Js=$((t,e)=>Gg(t,"name",{value:e,configurable:!0}),"s$b");const Xo=Js(t=>typeof t=="string"?t:`[${t.type}] ${t.source} → ${t.target}`,"formatMount"),zg=Js(({addingMount:t,config:e,detectedPm:r,fieldIndex:n,mountPhase:i,mountSource:o,mountTarget:s,mountType:l,suggestedMounts:d})=>{const f=e.mounts??[];return u(g,{flexDirection:"column",paddingX:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[u(a,{bold:!0,color:"cyan",children:[f.length," mounts"]}),r&&u(a,{dimColor:!0,children:["— detected: ",c(a,{color:"white",children:r})]})]}),d.length>0&&!t&&u(g,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[u(g,{flexShrink:0,children:[c(a,{bold:!0,color:"yellow",children:"Suggested mounts"}),u(a,{dimColor:!0,children:[" — press ",c(a,{bold:!0,color:"white",children:"A"})," to add all"]})]}),d.map((p,h)=>c(g,{flexShrink:0,children:u(a,{dimColor:!0,wrap:"truncate",children:[" + ",Xo(p)]})},`suggestion-${String(h)}`))]}),f.length>0&&c(g,{flexDirection:"column",marginBottom:1,children:f.map((p,h)=>{const m=h===n;return u(g,{flexShrink:0,height:1,children:[c(a,{children:m?">":" "}),c(g,{flexGrow:1,children:u(a,{bold:m,inverse:m,wrap:"truncate",children:[" ",Xo(p)]})})]},`mount-${String(h)}`)})}),!t&&c(g,{flexShrink:0,children:u(a,{color:n===f.length?"cyan":"gray",inverse:n===f.length,children:[" ","+ Add mount..."]})}),t&&u(g,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[c(g,{flexShrink:0,marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"New Mount"})}),u(g,{flexShrink:0,children:[c(g,{width:12,children:u(a,{bold:i==="source",color:i==="source"?"cyan":"white",children:[i==="source"?"❯ ":" ","Source:"]})}),c(a,{color:o?"yellow":"gray",children:o||(i==="source"?"_":"(type source, Enter to continue)")})]}),u(g,{flexShrink:0,children:[c(g,{width:12,children:u(a,{bold:i==="target",color:i==="target"?"cyan":"white",children:[i==="target"?"❯ ":" ","Target:"]})}),c(a,{color:s?"yellow":"gray",children:s||(i==="target"?"_":"/container/path")})]}),u(g,{flexShrink:0,children:[c(g,{width:12,children:u(a,{bold:i==="type",color:i==="type"?"cyan":"white",children:[i==="type"?"❯ ":" ","Type:"]})}),i==="type"?u(a,{children:[c(a,{bold:l==="volume",color:l==="volume"?"cyan":"gray",children:"[1] volume"})," ",c(a,{bold:l==="bind",color:l==="bind"?"cyan":"gray",children:"[2] bind"})," ",c(a,{bold:l==="tmpfs",color:l==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):c(a,{color:"gray",children:l})]}),c(g,{flexShrink:0,marginTop:1,children:c(a,{dimColor:!0,wrap:"truncate",children:i==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),f.length===0&&!t&&d.length===0&&c(g,{marginTop:1,children:c(a,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},"MountsSection");var Wg=Object.defineProperty,_g=$((t,e)=>Wg(t,"name",{value:e,configurable:!0}),"m$a");const Hg=_g(({addingPort:t,addPortValue:e,config:r,fieldIndex:n})=>{const i=r.forwardPorts??[],o=n===i.length;return u(g,{flexDirection:"column",paddingX:1,children:[u(g,{marginBottom:1,children:[c(a,{bold:!0,color:"cyan",children:"Forwarded Ports"}),u(a,{dimColor:!0,children:[" (",i.length," ports)"]})]}),i.map((s,l)=>{const d=l===n;return c(g,{children:u(a,{color:d?"cyan":void 0,inverse:d,children:[" ",String(s)]})},`port-${String(s)}`)}),c(g,{marginTop:i.length>0?1:0,children:u(a,{color:o?"cyan":"gray",inverse:o,children:[" ",o&&t?u(a,{children:["Enter port: ",c(a,{color:"yellow",children:e||"_"})]}):"+ Add port..."]})}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," ",o?"type port number, Enter to confirm":"select"," ",c(a,{bold:!0,color:"white",children:"d"})," remove selected"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"]})})]})},"PortsSection");var Jg=Object.defineProperty,qg=$((t,e)=>Jg(t,"name",{value:e,configurable:!0}),"a$6");const Yg=qg(({focused:t,hadComments:e,jsonPreview:r,mode:n,scrollRef:i})=>u(g,{borderColor:t?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:t?"cyan":"white",children:"Preview"}),u(a,{dimColor:!0,children:[" (",n==="create"?"new":"edit",")"]})]}),e&&n==="edit"&&c(g,{flexShrink:0,paddingX:1,children:c(a,{color:"yellow",children:"Comments will not be preserved."})}),c(zt,{flexGrow:1,ref:i,scrollbar:!0,scrollbarColor:"gray",children:r.split(`
|
|
291
|
+
`).map((o,s)=>c(a,{color:"green",children:o},`line-${String(s)}`))})]}),"PreviewPanel");var Xg=Object.defineProperty,Kg=$((t,e)=>Xg(t,"name",{value:e,configurable:!0}),"r$9");const Qg=Kg(t=>{const e=[],r=[],n=[];if(!t.image&&!t.build&&!t.dockerComposeFile&&e.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),t.build&&(t.image&&r.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),t.build.dockerfile||e.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),t.dockerComposeFile&&!t.service&&e.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),t.features!==void 0&&(typeof t.features!="object"||Array.isArray(t.features))&&e.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),t.forwardPorts)if(!Array.isArray(t.forwardPorts))e.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});else for(const[i,o]of t.forwardPorts.entries())typeof o=="number"&&(o<1||o>65535)&&e.push({field:"forwardPorts",message:`Invalid port ${String(o)} at index ${String(i)}`});return t.customizations?.vscode?.extensions&&!Array.isArray(t.customizations.vscode.extensions)&&e.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),t.customizations?.vscode?.settings&&typeof t.customizations.vscode.settings!="object"&&e.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),t.name||n.push({field:"name",message:"Consider adding a name for better identification"}),(!t.features||Object.keys(t.features).length===0)&&n.push({field:"features",message:"Consider adding features for common tools"}),(!t.customizations?.vscode?.extensions||t.customizations.vscode.extensions.length===0)&&n.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),t.privileged&&r.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:e,suggestions:n,valid:e.length===0,warnings:r}},"validateConfig");var Zg=Object.defineProperty,qs=$((t,e)=>Zg(t,"name",{value:e,configurable:!0}),"$$5");const Ko=80,Qo=15,eh=120,Zo=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],th=qs((t,e,r,n)=>{switch(t){case"general":return _s;case"features":return lo(r).length;case"ports":return(e.forwardPorts?.length??0)+1;case"lifecycle":return Ug;case"extensions":return uo(n).length;case"environment":return xg(e);case"mounts":return(e.mounts?.length??0)+1;case"compose":return kg;default:return 0}},"getFieldCount"),rh=qs(({onSave:t,store:e})=>{const{exit:r}=Gt(),{columns:n,rows:i}=Ut(),o=pr(e.subscribe,e.getSnapshot),[s,l]=ce(!1),[d,f]=ce(!1),[p,h]=ce(!1),[m,y]=ce(null),[b,x]=ce("editor"),[S,C]=ce(0),[D,P]=ce(!1),[M,E]=ce(""),[R,A]=ce(null),[G,B]=ce(""),[w,v]=ce(""),[j,U]=ce("key"),[z,Z]=ce(!1),[he,oe]=ce(""),[Te,ke]=ce(""),[Se,O]=ce("volume"),[I,Y]=ce("source"),ye=be(null),Ae=be(null),Ce=be(null),it=be(!0);qe(()=>(it.current=!0,()=>{it.current=!1,Ce.current&&clearTimeout(Ce.current)}),[]);const J=th(o.section,o.config,o.featureSearch,o.extensionSearch),q=Math.max(1,i-9);qe(()=>{o.section!=="features"&&o.section!=="extensions"||C(W=>o.fieldIndex>=W+q?o.fieldIndex-q+1:o.fieldIndex<W?o.fieldIndex:W)},[o.fieldIndex,o.section,q]),qe(()=>{C(0)},[o.section,o.featureSearch,o.extensionSearch]);const se=Ye(()=>{const W=e.cleanConfig(),X=Qg(W);if(!X.valid){const fe=X.errors[0];y(fe?`Error: ${fe.message}`:"Validation failed"),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{it.current&&y(null)},3e3);return}t(W),e.markClean();const V=X.warnings.length;y(V>0?`Saved! (${String(V)} warning${V>1?"s":""})`:"Saved!"),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{it.current&&y(null)},2e3)},[t,e]);if(De((W,X)=>{if(X.downArrow||W==="j")e.setTemplateIndex(o.templateIndex+1);else if(X.upArrow||W==="k")e.setTemplateIndex(o.templateIndex-1);else if(X.return){const V=Lt[o.templateIndex];V&&e.applyTemplate(V.id)}else X.escape&&e.dismissTemplateSelector()},{isActive:o.showTemplateSelector}),De((W,X)=>{if(X.escape){P(!1),E("");return}if(X.return){const V=Number.parseInt(M,10);!Number.isNaN(V)&&V>0&&V<=65535&&e.addPort(V),P(!1),E("");return}if(X.backspace){E(V=>V.slice(0,-1));return}W&&/^\d$/u.test(W)&&E(V=>V+W)},{isActive:D}),De((W,X)=>{if(X.escape){A(null),B(""),v(""),U("key");return}if(X.return){if(j==="key"&&G){U("value");return}if(j==="value"&&G){e.addEnvVar(R,G,w),A(null),B(""),v(""),U("key");return}}if(X.backspace){j==="key"?B(V=>V.slice(0,-1)):v(V=>V.slice(0,-1));return}W&&!X.ctrl&&!X.meta&&(j==="key"?B(V=>V+W):v(V=>V+W))},{isActive:R!==null}),De((W,X)=>{if(X.escape){Z(!1),oe(""),ke(""),Y("source");return}if(X.return){if(I==="source"&&he){Y("target");return}if(I==="target"&&Te){Y("type");return}if(I==="type"){e.addMount({source:he,target:Te,type:Se}),Z(!1),oe(""),ke(""),Y("source");return}}if(I==="type"){W==="1"?O("volume"):W==="2"?O("bind"):W==="3"&&O("tmpfs");return}if(X.backspace){I==="source"?oe(V=>V.slice(0,-1)):I==="target"&&ke(V=>V.slice(0,-1));return}W&&!X.ctrl&&!X.meta&&(I==="source"?oe(V=>V+W):I==="target"&&ke(V=>V+W))},{isActive:z}),De((W,X)=>{if(W==="c"&&X.ctrl){r();return}if(!d){if(s){X.escape||W==="?"?l(!1):X.downArrow||W==="j"?ye.current?.scrollBy(1):X.upArrow||W==="k"?ye.current?.scrollBy(-1):W==="q"&&(l(!1),f(!0));return}if(p){if(X.escape){h(!1),o.section==="features"?e.setFeatureSearch(""):e.setExtensionSearch("");return}if(X.return){h(!1);return}if(X.backspace){o.section==="features"?e.setFeatureSearch(o.featureSearch.slice(0,-1)):e.setExtensionSearch(o.extensionSearch.slice(0,-1));return}if(W&&!X.ctrl&&!X.meta){o.section==="features"?e.setFeatureSearch(o.featureSearch+W):e.setExtensionSearch(o.extensionSearch+W);return}return}if(o.fieldEditing){if(X.escape){e.setFieldEditing(!1);return}if(X.return){e.setFieldEditing(!1);return}return}if(W==="?"){l(!0);return}if(W==="q"){o.isDirty?f(!0):r();return}if(W==="s"){se();return}if(X.tab){x(V=>V==="editor"?"preview":"editor");return}if(b==="preview"){if(X.downArrow||W==="j"){Ae.current?.scrollBy(1);return}if(X.upArrow||W==="k"){Ae.current?.scrollBy(-1);return}if(X.pageDown){Ae.current?.scrollBy(10);return}if(X.pageUp){Ae.current?.scrollBy(-10);return}if(X.home){Ae.current?.scrollToTop();return}if(X.end){Ae.current?.scrollToBottom();return}X.escape&&x("editor");return}if(X.downArrow||W==="j"){J>0&&e.setFieldIndex(Math.min(o.fieldIndex+1,J-1));return}if(X.upArrow||W==="k"){e.setFieldIndex(Math.max(o.fieldIndex-1,0));return}if(X.return){if(o.section==="general"||o.section==="lifecycle"||o.section==="compose")e.setFieldEditing(!0);else if(o.section==="ports"){const V=o.config.forwardPorts??[];o.fieldIndex===V.length&&(P(!0),E(""))}else if(o.section==="environment"){const V=Object.keys(o.config.containerEnv??{}).length,fe=V,Ze=V+1+Object.keys(o.config.remoteEnv??{}).length;o.fieldIndex===fe?(A("container"),B(""),v(""),U("key")):o.fieldIndex===Ze&&(A("remote"),B(""),v(""),U("key"))}else if(o.section==="mounts"){const V=o.config.mounts??[];o.fieldIndex===V.length&&(Z(!0),oe(""),ke(""),O("volume"),Y("source"))}return}if(W===" "){if(o.section==="general"){const V=_s-bn.length,fe=o.fieldIndex-V;if(fe>=0&&fe<bn.length){const Ze=bn[fe];e.updateConfig({[Ze]:!o.config[Ze]})}}else if(o.section==="features"){const V=lo(o.featureSearch)[o.fieldIndex];V&&e.toggleFeature(V.id)}else if(o.section==="extensions"){const V=uo(o.extensionSearch)[o.fieldIndex];V&&e.toggleExtension(V.id)}return}if(W==="/"){(o.section==="features"||o.section==="extensions")&&h(!0);return}if(W==="A"&&o.section==="mounts"){e.applySuggestedMounts();return}if(W==="a"){if(o.section==="environment"){const V=Object.keys(o.config.containerEnv??{}).length,fe=o.fieldIndex<=V?"container":"remote";A(fe),B(""),v(""),U("key")}else o.section==="mounts"&&(Z(!0),oe(""),ke(""),O("volume"),Y("source"));return}if(W==="d"){if(o.section==="ports"){const V=o.config.forwardPorts??[];if(o.fieldIndex<V.length){e.removePort(o.fieldIndex);const fe=V.length-1;o.fieldIndex>=fe&&fe>0&&e.setFieldIndex(fe-1)}}else if(o.section==="mounts"){const V=o.config.mounts??[];if(o.fieldIndex<V.length){e.removeMount(o.fieldIndex);const fe=V.length-1;o.fieldIndex>=fe&&fe>0&&e.setFieldIndex(fe-1)}}else if(o.section==="environment"){const V=Object.keys(o.config.containerEnv??{}),fe=Object.keys(o.config.remoteEnv??{});if(o.fieldIndex<V.length)e.removeEnvVar("container",V[o.fieldIndex]),V.length===1||o.fieldIndex>=V.length-1&&e.setFieldIndex(V.length-2);else{const Ze=o.fieldIndex-V.length-1;Ze>=0&&Ze<fe.length&&(e.removeEnvVar("remote",fe[Ze]),fe.length===1||Ze>=fe.length-1&&e.setFieldIndex(o.fieldIndex-1))}}}}},{isActive:!o.showTemplateSelector&&!D&&R===null&&!z}),n<Ko||i<Qo)return c(g,{alignItems:"center",height:i,justifyContent:"center",width:n,children:u(a,{color:"yellow",children:["Terminal too small (",n,"x",i,"), need ",Ko,"x",Qo]})});if(o.showTemplateSelector)return c(g,{alignItems:"center",flexDirection:"column",height:i,justifyContent:"center",width:n,children:u(g,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[c(g,{justifyContent:"center",marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"Select a Template"})}),Lt.map((W,X)=>{const V=X===o.templateIndex;return c(g,{children:u(a,{color:V?"cyan":void 0,inverse:V,children:[V?" ❯ ":" ",c(a,{bold:V,children:W.name}),u(a,{dimColor:!0,children:[" - ",W.description]})]})},W.id)}),c(g,{justifyContent:"center",marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",c(a,{bold:!0,color:"white",children:"Enter"})," ","select"," ",c(a,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let je;switch(o.section){case"general":{je=c(Dg,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:$(W=>{e.updateConfig(W)},"onUpdate")});break}case"features":{je=c(Ag,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:S,searchText:o.featureSearch,viewportHeight:q});break}case"ports":{je=c(Hg,{addingPort:D,addPortValue:M,config:o.config,fieldIndex:o.fieldIndex});break}case"lifecycle":{je=c(Vg,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onSetCommand:$((W,X)=>{e.setLifecycleCommand(W,X)},"onSetCommand")});break}case"extensions":{je=c(Eg,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:S,searchText:o.extensionSearch,viewportHeight:q});break}case"environment":{je=u(g,{flexDirection:"column",children:[c($g,{config:o.config,fieldIndex:o.fieldIndex}),R!==null&&c(g,{marginTop:1,paddingX:1,children:u(a,{color:"cyan",children:["Add ",R," env:"," ",j==="key"?u(a,{children:["key=",c(a,{color:"yellow",children:G||"_"})," (Enter to set value)"]}):u(a,{children:[G,"=",c(a,{color:"yellow",children:w||"_"})," (Enter to confirm, Esc to cancel)"]})]})})]});break}case"mounts":{je=c(zg,{addingMount:z,config:o.config,detectedPm:o.detectedPm,fieldIndex:o.fieldIndex,mountPhase:I,mountSource:he,mountTarget:Te,mountType:Se,suggestedMounts:o.suggestedMounts});break}case"compose":{je=c(wg,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:$(W=>{e.updateConfig(W)},"onUpdate")});break}default:je=c(a,{children:"Unknown section"})}const Ot=u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[u(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]}),(o.section==="features"||o.section==="extensions")&&u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Space"}),c(a,{dimColor:!0,children:"CHECK"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"←→"}),c(a,{dimColor:!0,children:"TABS"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]}),(o.section==="features"||o.section==="extensions")&&u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:"FILTER"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"s"}),c(a,{dimColor:!0,children:"SAVE"})]})]}),u(g,{paddingX:1,children:[m&&u(a,{color:m.startsWith("Error")?"red":"green",children:[m," "]}),o.isDirty&&c(a,{color:"yellow",children:"[modified]"}),!o.isDirty&&!m&&c(a,{dimColor:!0,children:"[saved]"})]})]}),Na=u(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ye,title:"KEYBOARD SHORTCUTS",visible:s,width:56,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"←→"}),c(a,{dimColor:!0,children:" Switch tabs"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"↑↓"}),"/",c(a,{bold:!0,color:"white",children:"j/k"}),c(a,{dimColor:!0,children:" Navigate within section"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:" Switch editor/preview panel"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Enter"}),c(a,{dimColor:!0,children:" Edit selected field"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:" Stop editing / cancel"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Space"}),c(a,{dimColor:!0,children:" Toggle selection"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:" Search / filter"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"a"}),c(a,{dimColor:!0,children:" Add new entry"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"d"}),c(a,{dimColor:!0,children:" Delete selected entry"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"s"}),c(a,{dimColor:!0,children:" Save configuration"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:" Quit"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]}),Da=Ke(()=>e.getJsonPreview(),[o.config]),Ma=c(Yg,{focused:b==="preview",hadComments:o.hadComments,jsonPreview:Da,mode:o.mode,scrollRef:Ae}),ko=n>=eh,Ba=ko?Math.floor(n*.38):0;return u(g,{flexDirection:"column",height:i,width:n,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),u(a,{wrap:"truncate",children:[o.mode==="create"?"Create":"Edit"," devcontainer"]})]}),c(g,{flexShrink:0,paddingX:1,paddingY:1,children:c(Li,{defaultValue:o.section,keyMap:{useNumbers:!1,useTab:!1},onChange:$(W=>{e.setSection(W),x("editor")},"onChange"),showIndex:!1,children:Zo.map(({id:W,label:X})=>c(Fi,{name:W,children:X},W))})}),c(g,{flexShrink:0,paddingRight:2,children:c(a,{dimColor:!0,wrap:"truncate",children:Zo.find(W=>W.id===o.section)?.description??""})}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{borderColor:b==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:je}),ko&&c(g,{flexShrink:0,width:Ba,children:Ma})]}),Ot,c(jt,{autoExitSeconds:3,onCancel:$(()=>{f(!1)},"onCancel"),visible:d}),Na]})},"VisDevcontainerApp");var nh=Object.defineProperty,ei=$((t,e)=>nh(t,"name",{value:e,configurable:!0}),"c$b");const oh={group:"Scaffold & Config",alias:"dc",description:"Create or update .devcontainer/devcontainer.json interactively",examples:[["vis devcontainer","Launch interactive devcontainer config editor"],["vis dc","Alias for devcontainer"],["vis devcontainer --template node-pnpm","Start from Node.js + pnpm template"]],execute:ei(async({logger:t,options:e,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const n=r,i=e.template,o=e.output,s=!!process.stdout.isTTY&&!Ge;let l=null;try{l=me(n).name}catch{}const d=sg(n);let f=d?.config??null;const p=d?.hadComments??!1;if(i&&!d){const b=Lt.find(x=>x.id===i);if(!b){const x=Lt.map(S=>S.id).join(", ");throw new Error(`Unknown template "${i}". Valid templates: ${x}`)}f=b.config}if(!s){f?t.info(JSON.stringify(f,null,2)):(t.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const h=setInterval(()=>{},1e3),m=new fg(f,p,l);i&&!d&&m.dismissTemplateSelector();let y=null;if(await dt(_.createElement(rh,{onSave:ei(b=>{ag(n,b,o),y=b},"onSave"),store:m}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(h),y){const b=o??".devcontainer/devcontainer.json";t.info(`DevContainer config saved to ${b}`)}},"execute"),name:"devcontainer",options:[{alias:"t",description:"Start from a template: node, node-pnpm, node-postgres, node-dind, fullstack, python, go, rust, java, devops, minimal, custom",name:"template",type:String},{alias:"o",description:"Output path (default: .devcontainer/devcontainer.json)",name:"output",type:String}]};var ih=Object.defineProperty,sh=$((t,e)=>ih(t,"name",{value:e,configurable:!0}),"o$8");const ah={group:"Run & Execute",argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"]],execute:sh(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t;if(!i||i.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[o,...s]=i,l=n??process.cwd(),d=me(l),f=r.package?Array.isArray(r.package)?r.package:[r.package]:[],p=Wn(d,{additionalPackages:f,args:s,package:o,shellMode:r.shellMode||!1,silent:r.silent||!1},l,e);p!==0&&(process.exitCode=p)},"execute"),name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean}]};var ch=Object.defineProperty,We=$((t,e)=>ch(t,"name",{value:e,configurable:!0}),"c$a");const lh=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],dh=["overrides","pnpm","resolutions"],uh=["engines","files"],ph=We(t=>{const e=qr(t)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),fh=We(t=>{const e=T(t,"pnpm-workspace.yaml");if(!le(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Kr(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),gh=We((t,e)=>{let r={};return e==="pnpm"?r=t.pnpm?.overrides??{}:e==="yarn"||e==="bun"?r=t.resolutions??{}:r=t.overrides??{},{overrides:r,source:"package.json"}},"readPkgJsonOverrides"),hh=We((t,e,r)=>r.name==="pnpm"&&ph(r.version)?fh(t):gh(e,r.name),"readOverrides"),ti=We((t,e)=>{const r=e;for(const i of dh){const o=t.indexOf(i);if(o!==-1&&i!==r)return r==="overrides"?o:o+1}let n=-1;for(const i of lh){const o=t.indexOf(i);o>n&&(n=o)}if(n!==-1)return n+1;for(const i of uh){const o=t.indexOf(i);if(o!==-1)return o}return t.length},"findInsertIndex"),mh=We(t=>/\n(\s+)/.exec(t)?.[1]??" ","detectIndent"),yh=We((t,e)=>{const r=T(t,"pnpm-workspace.yaml");if(!F(r))throw new Error(`pnpm-workspace.yaml not found at ${r}. Cannot write overrides for pnpm v10+.`);let n=K(r,"utf8");const i=`overrides:
|
|
292
|
+
${Object.entries(e).map(([o,s])=>` '${o}': '${s}'`).join(`
|
|
293
|
+
`)}
|
|
294
|
+
`;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,i):`${n.trimEnd()}
|
|
295
|
+
|
|
296
|
+
${i}`,H(r,n)},"writePnpmWorkspaceOverrides"),vh=We((t,e,r,n)=>{const i=K(t,"utf8"),o=mh(i);if(n==="pnpm"){const s=e.pnpm??{};if(s.overrides=r,e.pnpm)e.pnpm=s,H(t,`${JSON.stringify(e,null,o)}
|
|
297
|
+
`);else{const l=Object.keys(e),d=ti(l,"pnpm"),f=Object.entries(e);f.splice(d,0,["pnpm",s]),H(t,`${JSON.stringify(Object.fromEntries(f),null,o)}
|
|
298
|
+
`)}}else{const s=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[s])e[s]=r,H(t,`${JSON.stringify(e,null,o)}
|
|
299
|
+
`);else{const l=Object.keys(e),d=ti(l,s),f=Object.entries(e);f.splice(d,0,[s,r]),H(t,`${JSON.stringify(Object.fromEntries(f),null,o)}
|
|
300
|
+
`)}}},"writePkgJsonOverrides"),Ys=We((t,e,r,n)=>{const i=K(e,"utf8"),o=JSON.parse(i),{overrides:s,source:l}=hh(t,o,n),d=[],f=[],p=new Set;if(n.name==="npm")for(const m of["dependencies","devDependencies"]){const y=o[m];if(y)for(const b of Object.keys(y))p.add(b)}for(const m of r){const y=s[m.original];if(typeof y=="object")continue;let b=m.spec;n.name==="npm"&&p.has(m.original)&&(b=`$${m.original}`),y!==b&&(y?f.push(m.original):d.push(m.original),s[m.original]=b)}if(d.length===0&&f.length===0)return{added:d,updated:f};const h=Object.fromEntries(Object.entries(s).sort(([m],[y])=>m.localeCompare(y)));return l==="pnpm-workspace.yaml"?yh(t,h):vh(e,o,h,n.name),{added:d,updated:f}},"applyOverrides"),Xs=We((t,e)=>{const r={bun:["bun.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of r[e]??[]){const i=T(t,n);try{return K(i,"utf8")}catch{continue}}return""},"readLockfileText"),wh=We((t,e,r)=>{if(!t)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(r){case"bun":return t.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(t);case"npm":return t.includes(`"${e}":`)||t.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(t);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(t);default:return!1}},"lockfileContainsPackage");var kh=Object.defineProperty,Qt=$((t,e)=>kh(t,"name",{value:e,configurable:!0}),"s$9");const bh=Qt((t,e,r)=>{let n=t;if(e!=="all"&&(n=n.filter(i=>i.category===e)),r){const i=r.toLowerCase();n=n.filter(o=>o.packageName.toLowerCase().includes(i))}return n},"filterEntries");let $h=class{static{$(this,"c")}static{Qt(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=Qt(()=>this.#e,"getSnapshot");subscribe=Qt(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=Qt(()=>bh(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#n(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const r=this.getFilteredEntries();this.#e.selectedIndex=r.length===0?-1:Math.max(0,Math.min(e,r.length-1)),this.#n()}toggleCheck(e){const r=new Set(this.#e.checkedEntries);r.has(e)?r.delete(e):r.add(e),this.#e.checkedEntries=r,this.#n()}toggleAll(){const e=this.getFilteredEntries(),r=new Set(this.#e.checkedEntries);if(e.every(n=>r.has(n.packageName)))for(const n of e)r.delete(n.packageName);else for(const n of e)r.add(n.packageName);this.#e.checkedEntries=r,this.#n()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#n()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#n()}setFilterActive(e){this.#e.filterActive=e,this.#n()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#n()}setPhase(e){this.#e.phase=e,this.#n()}setProgress(e,r){this.#e.applyProgress={current:e,total:r},this.#n()}setError(e){this.#e.error=e,this.#e.phase="error",this.#n()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}};const Ks={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},xh={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},Sh={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var Ch=Object.defineProperty,Eh=$((t,e)=>Ch(t,"name",{value:e,configurable:!0}),"a$5");const jh=Eh(({entry:t,focused:e,scrollRef:r})=>{const n=e?"white":"gray";if(!t)return c(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"No entry selected"})});const i=Ks[t.category]??"gray";return u(g,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c(g,{flexShrink:0,paddingTop:1,paddingX:2,children:c(a,{bold:!0,color:"white",children:t.packageName})}),u(zt,{flexGrow:1,flexShrink:1,paddingX:2,ref:r,scrollbar:!0,scrollbarColor:"gray",children:[c(a,{}),u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Category:"})}),c(a,{bold:!0,color:i,children:t.category})]}),u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Replace with:"})}),c(a,{children:t.replacement})]}),t.overrideSpec&&u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Override:"})}),c(a,{color:"cyan",children:t.overrideSpec})]}),u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Codemod:"})}),c(a,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available ⚙":"not available"})]}),u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"DESCRIPTION"}),c(g,{marginTop:1,paddingLeft:2,children:c(a,{children:Sh[t.category]??""})})]}),t.category==="native"&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"green",children:"ACTION"}),c(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:t.hasCodemod?u(Zt,{children:[u(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),c(a,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):u(Zt,{children:[u(a,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),c(a,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),t.category==="socket"&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"cyan",children:"ACTION"}),u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[u(a,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),c(a,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"LINKS"}),c(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:u(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",t.packageName]})})]})]})]})},"OptimizeDetailPanel");var Th=Object.defineProperty,Qs=$((t,e)=>Th(t,"name",{value:e,configurable:!0}),"b$8");const Ah=[{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"}],Ih=Qs(({checked:t,entry:e,isSelected:r})=>{const n=Ks[e.category]??"white",i=xh[e.category]??e.category,o=t?"☑":"☐",s=e.hasCodemod?"⚙":" ";return u(g,{flexShrink:0,height:1,children:[c(a,{children:r?">":" "}),u(a,{color:t?"white":"gray",children:[" ",o," "]}),c(a,{bold:!0,color:n,children:`[${i}]`.padEnd(9)}),u(a,{children:[" ",s," "]}),c(g,{flexGrow:1,children:c(a,{bold:r,inverse:r,wrap:"truncate",children:e.packageName})}),c(a,{dimColor:!0,children:" → "}),c(a,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),Rh=Qs(({checkedEntries:t,entries:e,filterActive:r,filterText:n,filterType:i,focused:o,isDryRun:s,scrollOffset:l,selectedIndex:d,totalEntries:f,viewportHeight:p})=>{const h=o?"white":"gray";let m=0,y=0,b=0,x=0;for(const R of e)switch(R.category){case"micro-utility":{b++;break}case"native":{m++;break}case"preferred":{y++;break}case"socket":{x++;break}}const S=[];m>0&&S.push(`${m} native`),y>0&&S.push(`${y} preferred`),b>0&&S.push(`${b} micro`),x>0&&S.push(`${x} socket`);const C=S.length>0?` (${S.join(", ")})`:"",D=t.size,P=[];for(const[R,A]of e.entries())P.push(c(Ih,{checked:t.has(A.packageName),entry:A,isSelected:R===d},A.packageName));const M=e.length,E=M>p&&p>0;return u(g,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),u(a,{wrap:"truncate",children:[f," ","optimizations",C]}),!s&&D>0&&u(a,{dimColor:!0,children:[" ","—",D," ","selected"]})]}),c(g,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ah.map(R=>{const A=i===R.key;return u(g,{children:[c(a,{dimColor:!A,children:"["}),c(a,{bold:A,color:A?"cyan":"gray",children:R.shortcut}),c(a,{dimColor:!A,children:"]"}),u(a,{color:A?"white":"gray",children:[" ",R.label]})]},R.key)})}),r&&u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:n}),c(a,{inverse:!0,children:" "})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-l,children:P})}),E&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:M,placement:"inset",scrollOffset:l,style:"block",viewportHeight:p})})]})]})},"OptimizeListPanel");var Oh=Object.defineProperty,Ph=$((t,e)=>Oh(t,"name",{value:e,configurable:!0}),"z$2");const Nh=100,ri=10,ni={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},Dh=Ph(({isDryRun:t,store:e})=>{const{exit:r}=Gt(),{columns:n,rows:i}=Ut(),o=pr(e.subscribe,e.getSnapshot),s=be(null),[l,d]=ce(0),[f,p]=ce(!1),h=e.getFilteredEntries(),m=h[o.selectedIndex]??null,y=n>=Nh,b=Math.max(0,i-5),x=Ye(S=>{r(S)},[r]);return De((S,C)=>{if(f){S==="y"||S==="Y"?x():p(!1);return}if(o.filterActive){C.escape?(e.setFilterActive(!1),e.setFilterText("")):C.return?e.setFilterActive(!1):C.backspace||C.delete?e.setFilterText(o.filterText.slice(0,-1)):S&&!C.ctrl&&!C.meta&&e.setFilterText(o.filterText+S);return}if(S==="q"){!t&&o.checkedEntries.size>0?p(!0):x();return}if(S==="/"){e.setFilterActive(!0);return}if(ni[S]){e.setFilter(ni[S]);return}if(C.tab){e.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list")if(C.upArrow||S==="k"){const D=Math.max(0,o.selectedIndex-1);e.select(D),D<l&&d(D)}else if(C.downArrow||S==="j"){const D=Math.min(h.length-1,o.selectedIndex+1);e.select(D),D>=l+b&&d(D-b+1)}else S===" "?m&&e.toggleCheck(m.packageName):S==="a"?e.toggleAll():C.return&&!t&&o.checkedEntries.size>0&&x(e.getCheckedEntries());else o.focusedPanel==="detail"&&(C.upArrow||S==="k"?s.current?.scrollBy(-1):(C.downArrow||S==="j")&&s.current?.scrollBy(1))},{isActive:o.phase==="browsing"}),i<ri?c(g,{alignItems:"center",justifyContent:"center",children:u(a,{color:"yellow",children:["Terminal too small. Resize to at least",ri," ","rows."]})}):u(g,{flexDirection:"column",height:i,width:n,children:[u(g,{flexDirection:y?"row":"column",flexGrow:1,children:[c(g,{flexBasis:y?"50%":void 0,flexGrow:1,children:c(Rh,{checkedEntries:o.checkedEntries,entries:h,filterActive:o.filterActive,filterText:o.filterText,filterType:o.filterType,focused:o.focusedPanel==="list",isDryRun:t,scrollOffset:l,selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:b})}),c(g,{flexBasis:y?"50%":void 0,flexGrow:1,children:c(jh,{entry:m,focused:o.focusedPanel==="detail",scrollRef:s})})]}),c(g,{flexShrink:0,paddingX:1,children:u(a,{dimColor:!0,children:[t?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),f&&c(jt,{message:`${o.checkedEntries.size} optimization${o.checkedEntries.size===1?"":"s"} selected but not applied. Quit?`})]})},"VisOptimizeApp");var Mh=Object.defineProperty,Ve=$((t,e)=>Mh(t,"name",{value:e,configurable:!0}),"g$8");const Ur=Ve((t,e)=>{const r=new Set;try{const n=JSON.parse(K(t,"utf8")),i=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const o of i)if(o)for(const s of Object.keys(o))r.add(s)}catch{}return r},"collectDepsFromPkgJson"),po=Ve(t=>{const e=tn(t);if(e)return Ct(t,e);const r=T(t,"package.json");if(!F(r))return[];try{const n=JSON.parse(K(r,"utf8")),i=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return i?Ct(t,i):[]}catch{return[]}},"discoverWorkspacePackages"),Zs=Ve(t=>{const e=[],r=Ve((n,i)=>{for(const[,o]of Object.entries(n.mappings)){if(!t.has(o.moduleName))continue;const s=[];for(const l of o.replacements){const d=n.replacements[l];d&&s.push(d.description??d.id)}e.push({category:i,hasCodemod:!1,overrideSpec:void 0,packageName:o.moduleName,replacement:s.join(", ")||o.replacements.join(", ")})}},"scanManifest");return r($c,"native"),r(xc,"preferred"),r(bc,"micro-utility"),e},"buildE18eEntries"),ea=Ve((t,e,r,n)=>{const i=kc("npm")??[],o=[];for(const[,s]of i){if(s.deprecated)continue;const l=t.has(s.package),d=e?wh(e,s.package,r.name):!1;if(!l&&!d)continue;const f=qr(s.version)?.major;if(f===void 0)continue;const p=n?`npm:${s.name}@${s.version}`:`npm:${s.name}@^${String(f)}`;o.push({category:"socket",hasCodemod:!1,overrideSpec:p,packageName:s.package,replacement:s.name})}return o},"buildSocketEntries");let Ir;const ta=Ve(async()=>{if(Ir)return Ir;try{return Ir=(await import("module-replacements-codemods")).codemods,Ir}catch{return{}}},"loadCodemods"),ra=Ve(async t=>{try{const e=await ta();for(const r of t)r.category!=="socket"&&e[r.packageName]&&(r.hasCodemod=!0)}catch{}},"markCodemodAvailability"),na=Ve(async(t,e)=>{let r=0;try{const n=(await ta())[e];if(!n)return{filesChanged:0,packageName:e};const i=n({}),o=Bh(t);for(const s of o){const l=K(s,"utf8");if(l.includes(e))try{const d=await i.transform({file:{filename:s,source:l}});d!==l&&(H(s,d,"utf8"),r++)}catch(d){process.stderr.write(`warn: codemod transform failed for ${s}: ${d instanceof Error?d.message:String(d)}
|
|
301
|
+
`)}}}catch{}return{filesChanged:r,packageName:e}},"runCodemod"),Bh=Ve(t=>{const e=[],r=new Set([".git",".next",".nuxt","coverage","dist","node_modules"]),n=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),i=Ve(o=>{try{for(const s of ft(o,{withFileTypes:!0})){if(s.name.startsWith("."))continue;const l=T(o,s.name);if(s.isDirectory())r.has(s.name)||i(l);else{const d=s.name.slice(s.name.lastIndexOf("."));n.has(d)&&e.push(l)}}}catch{}},"walk");return i(t),e},"collectSourceFiles"),Lh={group:"Workspace",description:"Analyze and optimize dependencies using e18e replacements and @socketregistry overrides",examples:[["vis optimize","Interactive TUI to select and apply optimizations"],["vis optimize --dry-run","Preview available optimizations"],["vis optimize --pin","Pin Socket.dev overrides to exact versions"],["vis optimize --prod","Only optimize production dependencies"]],execute:Ve(async({logger:t,options:e,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=me(r),i=!!e.dryRun,o=!!e.prod,s=!!e.pin;k(`Detected ${n.name} v${n.version}.`);const l=Ur(T(r,"package.json"),o),d=po(r),f=new Set(l);for(const E of d){const R=Ur(T(Ft(r,E),"package.json"),o);for(const A of R)f.add(A)}d.length>0&&k(`Scanned ${String(d.length)} workspace package${d.length===1?"":"s"}.`),k(`Scanning dependencies...
|
|
302
|
+
`);const p=Xs(r,n.name),h=Zs(f),m=ea(f,p,n,s),y=new Set(h.map(E=>E.packageName)),b=m.filter(E=>!y.has(E.packageName)),x=[...h,...b];if(await ra(x),x.length===0){k("No optimizations found for your dependencies.");return}const S=!!process.stdout.isTTY&&!Ge,C=e.format==="json"||!!e.json;if(S&&!i&&!C){const E=new $h(x),R=await dt(_.createElement(Dh,{isDryRun:!1,store:E}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),A=Array.isArray(R)?R:[];if(A.length===0){k("No optimizations selected.");return}const G=A.filter(v=>v.category!=="socket"&&v.hasCodemod),B=A.filter(v=>v.category!=="socket"&&!v.hasCodemod),w=A.filter(v=>v.category==="socket");if(G.length>0){k(`
|
|
303
|
+
Running ${String(G.length)} codemod${G.length===1?"":"s"}...
|
|
304
|
+
`);for(const v of G){const j=await na(r,v.packageName);j.filesChanged>0?Q(` ${v.packageName}: ${String(j.filesChanged)} file${j.filesChanged===1?"":"s"} updated`):k(` ${v.packageName}: no files changed`)}}if(B.length>0){ae(`
|
|
305
|
+
${String(B.length)} selected replacement${B.length===1?"":"s"} require manual migration (no codemod available):`);for(const v of B)k(` ${v.packageName} → ${v.replacement}`);te(" Replace usage in your source code, then remove from dependencies.")}if(w.length>0){const v=w.filter(U=>U.overrideSpec).map(U=>({original:U.packageName,spec:U.overrideSpec})),j=Ys(r,T(r,"package.json"),v,n);j.added.length>0&&Q(`
|
|
306
|
+
Added ${String(j.added.length)} override${j.added.length===1?"":"s"}.`),j.updated.length>0&&Q(`Updated ${String(j.updated.length)} override${j.updated.length===1?"":"s"}.`)}if(w.length>0&&!e.noInstall){k(`
|
|
307
|
+
Running ${n.name} install to update lockfile...`);const v=Zr(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},r,t);v!==0&&ae(`${n.name} install exited with code ${String(v)}. Run it manually.`)}k(""),Q("Optimization complete.");return}if(C){process.stdout.write(`${JSON.stringify({e18e:h.map(E=>({category:E.category,hasCodemod:E.hasCodemod,packageName:E.packageName,replacement:E.replacement})),packageManager:n.name,socket:b.map(E=>({overrideSpec:E.overrideSpec,packageName:E.packageName,replacement:E.replacement})),total:x.length,workspaces:d.length},void 0,2)}
|
|
308
|
+
`);return}const D=h.filter(E=>E.category==="native"),P=h.filter(E=>E.category==="preferred"),M=h.filter(E=>E.category==="micro-utility");if(D.length>0){k(`Native replacements (${String(D.length)}):`);for(const E of D)k(` ${E.hasCodemod?"⚙":" "} ${E.packageName} → ${E.replacement}`)}if(P.length>0){k(`
|
|
309
|
+
Preferred alternatives (${String(P.length)}):`);for(const E of P)k(` ${E.hasCodemod?"⚙":" "} ${E.packageName} → ${E.replacement}`)}if(M.length>0){k(`
|
|
310
|
+
Micro-utilities (${String(M.length)}):`);for(const E of M)k(` ${E.hasCodemod?"⚙":" "} ${E.packageName} → ${E.replacement}`)}if(b.length>0){k(`
|
|
311
|
+
Socket.dev overrides (${String(b.length)}):`);for(const E of b)k(` ${E.packageName} → ${E.overrideSpec}`)}k(`
|
|
312
|
+
Total: ${String(x.length)} optimizations available (⚙ = codemod available).`),i&&te("Run without --dry-run for interactive selection.")},"execute"),name:"optimize",options:[{alias:"d",defaultValue:!1,description:"Preview available optimizations without applying",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Pin Socket.dev overrides to exact versions",name:"pin",type:Boolean},{defaultValue:!1,description:"Only optimize production dependencies",name:"prod",type:Boolean},{defaultValue:!1,description:"Skip running install after applying overrides",name:"no-install",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]};var Fh=Object.defineProperty,wr=$((t,e)=>Fh(t,"name",{value:e,configurable:!0}),"b$6");const Vh=wr(async(t,e,r=!1)=>{const n=me(t),{packageManager:i}=Jr(t),o=Ur(T(t,"package.json"),!1),s=po(t),l=new Set(o);for(const B of s){const w=Ur(T(Ft(t,B),"package.json"),!1);for(const v of w)l.add(v)}const d=ro(t),f=on(t,i),p=It(e?.security?.socket),h=e?.security?.socket?.acceptedRisks,m=Xs(t,n.name),y={exclude:[],ignore:[],include:[],includePrerelease:!1,security:!0,target:"latest"},[b,x,S,C,D]=await Promise.all([f.size>0?no(f,y,d,void 0,t,p,h):Promise.resolve({failed:[],ignored:[],outdated:[]}),Promise.resolve(Ds(t)),Ms(t,n.name),Promise.resolve(Zs(l)),Promise.resolve(ea(l,m,n,!1))]),P=new Set(C.map(B=>B.packageName)),M=D.filter(B=>!P.has(B.packageName)),E=[...C,...M];r&&await ra(E);let R=0,A=0;if(p&&x.length>0){const B=await Wt(x.map(w=>({name:w.name,version:w.version})),p);for(const w of B.values())w.alerts.length>0&&(R+=w.alerts.length),w.score.overall<at&&A++}let G=0;for(const B of b.outdated)B.vulnerabilities&&B.vulnerabilities.length>0&&(G+=B.vulnerabilities.length);if(x.length>0){const B=await sn(x.map(w=>({name:w.name,version:w.version})));for(const w of B.values())G+=w.length}return{duplicates:S,installedCount:x.length,optimizations:E,outdated:b.outdated,socketIssues:{alerts:R,lowScore:A},vulnCount:G,workspaceCount:s.length}},"runAllScans"),et=wr(t=>t?Ai("✓"):ct("✗"),"icon"),st=Ie("⚠"),Uh=wr(t=>{const{duplicates:e,installedCount:r,optimizations:n,outdated:i,socketIssues:o,vulnCount:s}=t;if(k(""),k(Be("── Dependencies ────────────────────────")),k(` ${et(!0)} ${String(r)} packages installed`),i.length>0){const y=i.filter(C=>C.updateType==="major").length,b=i.filter(C=>C.updateType==="minor").length,x=i.filter(C=>C.updateType==="patch").length,S=[];y>0&&S.push(`${String(y)} major`),b>0&&S.push(`${String(b)} minor`),x>0&&S.push(`${String(x)} patch`),k(` ${st} ${String(i.length)} outdated (${S.join(", ")})`)}else k(` ${et(!0)} All dependencies up to date`);e.length>0?k(` ${st} ${String(e.length)} packages with duplicate versions`):k(` ${et(!0)} No duplicate dependencies`),k(""),k(Be("── Security ────────────────────────────")),s>0?k(` ${et(!1)} ${String(s)} vulnerabilit${s===1?"y":"ies"} found`):k(` ${et(!0)} No known vulnerabilities`),o.alerts>0&&k(` ${st} ${String(o.alerts)} Socket.dev security alert${o.alerts===1?"":"s"}`),o.lowScore>0&&k(` ${st} ${String(o.lowScore)} package${o.lowScore===1?"":"s"} with low security score`),o.alerts===0&&o.lowScore===0&&s===0&&k(` ${et(!0)} No security issues detected`),k(""),k(Be("── Optimization ────────────────────────"));let l=0,d=0,f=0,p=0;for(const y of n)switch(y.category){case"micro-utility":{f++;break}case"native":{l++;break}case"preferred":{d++;break}case"socket":{p++;break}}n.length>0?(l>0&&k(` ${st} ${String(l)} replaceable with native APIs`),d>0&&k(` ${st} ${String(d)} with lighter alternatives`),f>0&&k(` ${st} ${String(f)} trivial micro-utilities`),p>0&&k(` ${st} ${String(p)} @socketregistry overrides available`)):k(` ${et(!0)} No optimizations available`),k(""),k(Be("── Summary ─────────────────────────────"));const h=s,m=i.length+e.length+n.length;h===0&&m===0?Q(" Everything looks good!"):(h>0&&St(` ${String(h)} security issue${h===1?"":"s"}`),m>0&&k(` ${String(m)} improvement${m===1?"":"s"} available`))},"displayResults"),Gh=wr(t=>{const e=[];if(t.outdated.length>0&&e.push("vis update — update outdated dependencies"),(t.vulnCount>0||t.socketIssues.alerts>0)&&e.push("vis audit — detailed security analysis"),t.optimizations.length>0&&e.push("vis optimize — apply optimizations interactively"),t.duplicates.length>0&&e.push("vis dedupe — reduce duplicate versions"),e.length>0){k(""),te(" Next steps:");for(const r of e)te(` ${r}`)}k("")},"displayActions"),zh={group:"Security & Health",description:"Run a full project health check (outdated, security, duplicates, optimizations)",examples:[["vis doctor","Full project health check"],["vis doctor --fix","Check and auto-apply safe fixes"],["vis doctor --format json","Machine-readable output for CI"],["vis doctor --exit-code","Exit with code 1 if security issues found"],["vis doctor --exit-code --strict","Fail on any issue (outdated, duplicates, security)"]],execute:wr(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const i=me(n);k(`
|
|
313
|
+
${Be("VIS DOCTOR")} — project health check
|
|
314
|
+
`),k(` ${et(!0)} Detected ${i.name} v${i.version}`);const o=po(n);o.length>0&&k(` ${et(!0)} ${String(o.length)} workspace package${o.length===1?"":"s"}`),k(`
|
|
315
|
+
Scanning...`);const s=await Vh(n,r,!!e.fix);let l=0,d=0,f=0,p=0;for(const h of s.optimizations)switch(h.category){case"micro-utility":{f++;break}case"native":{l++;break}case"preferred":{d++;break}case"socket":{p++;break}}if(e.format==="json"||e.json){process.stdout.write(`${JSON.stringify({dependencies:{duplicates:s.duplicates.length,installed:s.installedCount,outdated:s.outdated.length},optimizations:{microUtilities:f,native:l,preferred:d,socket:p,total:s.optimizations.length},packageManager:i.name,security:{alerts:s.socketIssues.alerts,lowScorePackages:s.socketIssues.lowScore,vulnerabilities:s.vulnCount},workspaces:s.workspaceCount},void 0,2)}
|
|
316
|
+
`),e.exitCode&&(s.vulnCount>0||s.socketIssues.alerts>0)&&(process.exitCode=1);return}if(Uh(s),e.fix&&s.optimizations.length>0){k(""),k(`Applying fixes...
|
|
317
|
+
`);const h=s.optimizations.filter(y=>y.category==="socket"&&y.overrideSpec).map(y=>({original:y.packageName,spec:y.overrideSpec}));if(h.length>0){const y=Ys(n,T(n,"package.json"),h,i);y.added.length>0&&Q(` Added ${String(y.added.length)} security override${y.added.length===1?"":"s"}.`),y.updated.length>0&&Q(` Updated ${String(y.updated.length)} override${y.updated.length===1?"":"s"}.`)}const m=s.optimizations.filter(y=>y.category!=="socket"&&y.hasCodemod);for(const y of m){const b=await na(n,y.packageName);b.filesChanged>0&&Q(` ${y.packageName}: ${String(b.filesChanged)} file${b.filesChanged===1?"":"s"} updated`)}h.length>0&&(k(`
|
|
318
|
+
Running ${i.name} install to update lockfile...`),Zr(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,t)),k(""),Q("Fixes applied.")}else Gh(s);e.exitCode&&(e.strict?s.vulnCount>0||s.socketIssues.alerts>0||s.outdated.length>0||s.duplicates.length>0:s.vulnCount>0||s.socketIssues.alerts>0)&&(process.exitCode=1)},"execute"),name:"doctor",options:[{description:"Output format: table or json (default: table)",name:"format",type:String},{defaultValue:!1,description:"Exit with code 1 if issues found",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Auto-apply safe fixes (security overrides + codemods)",name:"fix",type:Boolean},{defaultValue:!1,description:"With --exit-code: also fail on outdated and duplicate deps",name:"strict",type:Boolean}]};var Wh=Object.defineProperty,_h=$((t,e)=>Wh(t,"name",{value:e,configurable:!0}),"s$8");const Hh={group:"Run & Execute",argument:{description:"Command to execute followed by arguments",name:"command",type:String},description:"Execute a local node_modules/.bin command (no remote fallback)",examples:[["vis exec eslint .","Run local eslint"],["vis exec tsc --noEmit","Run local TypeScript check"],["vis exec -r -- eslint .","Run in all workspace packages"],["vis exec -c 'echo $PATH'","Shell mode"]],execute:_h(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t;if(!i||i.length===0)throw new Error("No command specified. Usage: vis exec <command> [args...]");const[o,...s]=i,l=n??process.cwd(),d=me(l),f=qc(d,{args:s,command:o,filter:gr(r.filter),parallel:r.parallel||!1,recursive:r.recursive||!1,reverse:r.reverse||!1,shellMode:r.shellMode||!1,workspaceRoot:r.workspaceRoot||!1},l,e);f!==0&&(process.exitCode=f)},"execute"),name:"exec",options:[{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"r",defaultValue:!1,description:"Run in every workspace package",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Run on workspace root only",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter packages by name pattern",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Run concurrently without topological ordering",name:"parallel",type:Boolean},{defaultValue:!1,description:"Reverse topological execution order",name:"reverse",type:Boolean}]};var Jh=Object.defineProperty,rr=$((t,e)=>Jh(t,"name",{value:e,configurable:!0}),"n$4");const qh=rr(t=>{const e=new Map;for(const[r,n]of Object.entries(t.dependencies))for(const i of n){const o=e.get(i.target)??[];o.push(r),e.set(i.target,o)}return Object.values(t.nodes).map(r=>({deps:t.dependencies[r.name]??[],name:r.name,reverseDeps:e.get(r.name)??[],type:r.type})).sort((r,n)=>r.type!==n.type?r.type==="application"?-1:1:r.name.localeCompare(n.name))},"buildNodes"),Yh=rr((t,e,r)=>{let n=t;if(e==="app"?n=n.filter(i=>i.type==="application"):e==="lib"&&(n=n.filter(i=>i.type!=="application")),r){const i=r.toLowerCase();n=n.filter(o=>o.name.toLowerCase().includes(i))}return n},"filterNodes");class Xh{static{$(this,"GraphStore")}static{rr(this,"GraphStore")}#e;#t=new Set;#n;constructor(e){this.#n=e;const r=qh(e);this.#e={allNodes:r,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=rr(()=>this.#e,"getSnapshot");subscribe=rr(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredNodes(){return Yh(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(i=>i.type==="application").length,r=this.#e.allNodes.length,n=Object.values(this.#n.dependencies).reduce((i,o)=>i+o.length,0);return{apps:e,deps:n,libs:r-e,total:r}}setSelectedIndex(e){const r=this.getFilteredNodes(),n=r.length===0?-1:Math.max(0,Math.min(e,r.length-1));n!==this.#e.selectedIndex&&this.#o({...this.#e,selectedIndex:n})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#o({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#o({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#o({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#o({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#o(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var Kh=Object.defineProperty,Qh=$((t,e)=>Kh(t,"name",{value:e,configurable:!0}),"p$9");const Zh=Qh(({focused:t,node:e,scrollRef:r})=>{const n=t?"white":"gray";if(!e)return c(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"No project selected"})});const i=e.type==="application",o=i?"yellow":"cyan",s=i?"Application":"Library";return c(g,{borderColor:n,borderStyle:"single",borderTopRightTitle:` ${s} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:u(zt,{flexGrow:1,flexShrink:1,paddingX:2,ref:r,scrollbar:!0,scrollbarColor:"gray",children:[u(g,{flexDirection:"column",marginTop:1,children:[u(g,{children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"DEPENDS ON"}),u(a,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?c(g,{marginTop:1,paddingLeft:2,children:c(a,{dimColor:!0,children:"No dependencies"})}):c(g,{flexDirection:"column",marginTop:1,children:e.deps.map(l=>u(g,{gap:1,paddingLeft:2,children:[c(a,{color:"cyan",children:"→"}),c(a,{children:l.target}),l.type!=="static"&&u(a,{dimColor:!0,children:["(",l.type,")"]})]},l.target))})]}),u(g,{flexDirection:"column",marginTop:1,children:[u(g,{children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"REQUIRED BY"}),u(a,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?c(g,{marginTop:1,paddingLeft:2,children:c(a,{dimColor:!0,children:"No reverse dependencies"})}):c(g,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(l=>u(g,{gap:1,paddingLeft:2,children:[c(a,{color:"magenta",children:"←"}),c(a,{children:l})]},l))})]}),u(g,{flexDirection:"column",marginTop:1,children:[u(g,{children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"INFO"})]}),u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Type:"})}),c(a,{color:o,children:s})]}),u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Dependencies:"})}),c(a,{children:String(e.deps.length)})]}),u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Required by:"})}),c(a,{children:String(e.reverseDeps.length)})]}),u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Connectivity:"})}),c(a,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var em=Object.defineProperty,fo=$((t,e)=>em(t,"name",{value:e,configurable:!0}),"g$6");const tm=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],oi=fo(({isSelected:t,node:e})=>{const r=e.type==="application",n=r?"yellow":"cyan",i=r?"app":"lib";return u(g,{flexShrink:0,height:1,children:[u(a,{children:[t?"▶":" "," "]}),c(g,{flexGrow:1,children:c(a,{bold:t,inverse:t,wrap:"truncate",children:e.name})}),u(a,{color:n,children:[" ",i]}),u(a,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),ii=fo(({count:t,label:e})=>u(g,{flexShrink:0,height:1,marginTop:1,children:[u(a,{dimColor:!0,children:["▼"," "]}),c(a,{bold:!0,color:"white",children:e.toUpperCase()}),u(a,{dimColor:!0,children:[" ","(",t,")"]})]}),"TypeHeader"),rm=fo(({filterActive:t,filterText:e,filterType:r,focused:n,nodes:i,scrollOffset:o,selectedIndex:s,stats:l,viewportHeight:d})=>{const f=n?"white":"gray",p=i.filter(S=>S.type==="application"),h=i.filter(S=>S.type!=="application"),m=[];let y=0;if(p.length>0){m.push(c(ii,{count:p.length,label:"Applications"},"hdr-apps"));for(const S of p){const C=y;m.push(c(oi,{isSelected:C===s,node:S},S.name)),y++}}if(h.length>0){m.push(c(ii,{count:h.length,label:"Libraries"},"hdr-libs"));for(const S of h){const C=y;m.push(c(oi,{isSelected:C===s,node:S},S.name)),y++}}let b=0;p.length>0&&(b+=2+p.length),h.length>0&&(b+=2+h.length);const x=b>d&&d>0;return u(g,{borderColor:f,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),u(a,{wrap:"truncate",children:[l.total," ","packages"]}),u(a,{dimColor:!0,children:["(",l.apps," ","apps,"," ",l.libs," ","libs,"," ",l.deps," ","deps)"]})]}),c(g,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:tm.map(S=>{const C=r===S.key;return u(g,{children:[c(a,{dimColor:!C,children:"["}),c(a,{bold:C,color:C?"cyan":"gray",children:S.shortcut}),c(a,{dimColor:!C,children:"]"}),u(a,{color:C?"white":"gray",children:[" ",S.label]})]},S.key)})}),t&&u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:e}),c(a,{inverse:!0,children:" "})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-o,children:m})}),x&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:b,placement:"inset",scrollOffset:o,style:"block",viewportHeight:d})})]})]})},"ProjectListPanel");var nm=Object.defineProperty,om=$((t,e)=>nm(t,"name",{value:e,configurable:!0}),"M$6");const im=100,sm=40,am=10,si={1:"all",2:"app",3:"lib"},cm=om(({autoExitSeconds:t=0,store:e})=>{const{exit:r}=Gt(),{columns:n,rows:i}=Ut(),o=pr(e.subscribe,e.getSnapshot),[s,l]=ce(!1),d=be(null),f=be(null),[p,h]=ce(0),[m,y]=ce(!1),b=Ke(()=>e.getFilteredNodes(),[o.allNodes,o.filterType,o.filterText]),x=Ke(()=>e.getStats(),[o.allNodes]),S=b[o.selectedIndex]??null,C=Ye(w=>{const v=b.filter(Z=>Z.type==="application"),j=b.filter(Z=>Z.type!=="application");let U=0,z=0;if(v.length>0){U+=2;for(let Z=0;Z<v.length;Z++){if(z===w)return U;U+=1,z++}}if(j.length>0){U+=2;for(let Z=0;Z<j.length;Z++){if(z===w)return U;U+=1,z++}}return U},[b]),D=Math.max(1,i-8-(o.filterActive?1:0)),P=Ye(w=>{const v=C(w);h(j=>v>j+D-2?Math.max(0,v-D+2):v<j+1?Math.max(0,v-1):j)},[C,D]);if(qe(()=>{f.current?.scrollToTop()},[S?.name]),De((w,v)=>{if(w==="c"&&v.ctrl){r();return}if(!m){if(s){v.escape||w==="?"?l(!1):w==="q"?(l(!1),y(!0)):v.downArrow||w==="j"?d.current?.scrollBy(1):(v.upArrow||w==="k")&&d.current?.scrollBy(-1);return}if(w==="?"){l(!0);return}if(w==="q"){y(!0);return}if(v.tab){e.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(si[w]){e.setFilterType(si[w]);return}if(o.filterActive){if(v.escape){e.setFilterActive(!1);return}if(v.return){e.setFilterActive(!1);return}if(v.backspace){e.setFilter(o.filterText.slice(0,-1));return}if(w&&!v.ctrl&&!v.meta){e.setFilter(o.filterText+w);return}return}if(o.focusedPanel==="list"){if(b.length===0){w==="/"&&e.setFilterActive(!0);return}if(v.downArrow||w==="j"){const j=Math.min(o.selectedIndex+1,b.length-1);e.setSelectedIndex(j),P(j);return}if(v.upArrow||w==="k"){const j=Math.max(o.selectedIndex-1,0);e.setSelectedIndex(j),P(j);return}if(v.pageDown){const j=Math.min(o.selectedIndex+10,b.length-1);e.setSelectedIndex(j),P(j);return}if(v.pageUp){const j=Math.max(o.selectedIndex-10,0);e.setSelectedIndex(j),P(j);return}if(v.home){e.setSelectedIndex(0),h(0);return}if(v.end){const j=b.length-1;e.setSelectedIndex(j),P(j);return}if(w==="/"){e.setFilterActive(!0);return}if(v.rightArrow){e.setFocusedPanel("detail");return}return}if(o.focusedPanel==="detail"){if(v.escape||v.leftArrow){e.setFocusedPanel("list");return}if(v.downArrow||w==="j"){f.current?.scrollBy(1);return}if(v.upArrow||w==="k"){f.current?.scrollBy(-1);return}if(v.pageDown){f.current?.scrollBy(10);return}if(v.pageUp){f.current?.scrollBy(-10);return}if(v.home){f.current?.scrollToTop();return}v.end&&f.current?.scrollToBottom()}}},{isActive:!0}),n<sm||i<am)return c(g,{alignItems:"center",height:i,justifyContent:"center",width:n,children:u(a,{color:"yellow",children:["Terminal too small (",n,"x",i,")"]})});const M=n>=im,E=c(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:u(g,{flexWrap:"wrap",gap:2,paddingX:1,children:[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"1-3 /"}),c(a,{dimColor:!0,children:"FILTER"})]},"f"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"t")]})}),R=u(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:d,title:"KEYBOARD SHORTCUTS",visible:s,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Move up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Move down"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Tab"]}),c(a,{dimColor:!0,children:" Switch panel"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","→","/","←"]}),c(a,{dimColor:!0,children:" Focus detail/list"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),c(a,{dimColor:!0,children:" Jump 10 items"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Home/End"]}),c(a,{dimColor:!0,children:" Jump to start/end"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"FILTERS"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","1"]}),c(a,{dimColor:!0,children:" All"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","2"]}),c(a,{dimColor:!0,children:" Apps only"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","3"]}),c(a,{dimColor:!0,children:" Libraries only"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","/"]}),c(a,{dimColor:!0,children:" Text filter"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","q"]}),c(a,{dimColor:!0,children:" Quit"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","?"]}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]}),A=c(rm,{filterActive:o.filterActive,filterText:o.filterText,filterType:o.filterType,focused:o.focusedPanel==="list",nodes:b,scrollOffset:p,selectedIndex:o.selectedIndex,stats:x,viewportHeight:D}),G=c(Zh,{focused:o.focusedPanel==="detail",node:S,scrollRef:f});if(M){const w=Math.floor(n*.35);return u(g,{flexDirection:"column",height:i,width:n,children:[u(g,{flexDirection:"row",flexGrow:1,children:[c(g,{flexGrow:1,children:A}),c(g,{width:w,children:G})]}),E,c(jt,{autoExitSeconds:t??3,onCancel:$(()=>{y(!1)},"onCancel"),visible:m}),R]})}const B=Math.floor(i*.55);return u(g,{flexDirection:"column",height:i,width:n,children:[c(g,{height:B,children:A}),c(g,{flexGrow:1,children:G}),E,c(jt,{autoExitSeconds:t??3,onCancel:$(()=>{y(!1)},"onCancel"),visible:m}),R]})},"VisGraphApp");var ai=Object.freeze,oa=Object.defineProperty,Ht=$((t,e)=>oa(t,"name",{value:e,configurable:!0}),"y$6"),lm=$((t,e)=>ai(oa(t,"raw",{value:ai(e||t.slice())})),"k$7");const ia=Ht((t,e,r,n,i,o,s,l)=>{const d=re(r?"└── ":"├── "),f=i.has(t),p=f?re(" (*)"):"",h=n.get(t),m=h?.type==="application"?pe(t):t;if(o.push(`${e}${d}${m}${p}`),f)return;i.add(t);const y=h?.deps??[],b=r?`${e} `:`${e}${re("│")} `;if(l>=s&&y.length>0){o.push(`${b}${re(`... ${y.length} more`)}`);return}for(let x=0;x<y.length;x++){const S=y[x];S&&ia(S.target,b,x===y.length-1,n,i,o,s,l+1)}},"printDepsTree"),ci=Ht((t,e,r,n,i,o)=>{const s=e.get(t),l=s?.type==="application"?pe(t):t;n.push(`${o}${l}`),r.add(t);const d=s?.deps??[];if(d.length===0){n.push(`${o} ${re("(no dependencies)")}`);return}if(i<=0){n.push(`${o} ${re(`... ${d.length} dependencies`)}`);return}for(let f=0;f<d.length;f++){const p=d[f];p&&ia(p.target,o,f===d.length-1,e,r,n,i,1)}},"printRootProject"),li=Ht((t,e)=>{const r=new Map;for(const[h,m]of Object.entries(t.nodes))r.set(h,{deps:(t.dependencies[h]??[]).map(y=>({target:y.target,type:y.type})),name:h,type:m.type});const n=[],i=[];for(const[h,m]of r)m.type==="application"?n.push(h):i.push(h);n.sort(),i.sort();const o=n.length+i.length,s=Object.values(t.dependencies).reduce((h,m)=>h+m.length,0),l=[];if(l.push(pe("Project Dependency Graph"),""),n.length>0){l.push(` ${pe(Pe(`Applications (${n.length})`))}`,"");for(const h of n)ci(h,r,new Set,l,e," "),l.push("")}if(i.length>0){l.push(` ${pe(Pe(`Libraries (${i.length})`))}`,"");for(const h of i)ci(h,r,new Set,l,e," "),l.push("")}const d=process.stdout.columns||80;l.push(re("─".repeat(Math.min(d,60)))),l.push(`${pe(String(o))} packages ${re("·")} ${pe(String(s))} dependencies ${re("·")} ${pe(String(n.length))} apps${re(",")} ${pe(String(i.length))} libraries`);const f=new Set;let p=!1;for(const h of[...n,...i]){const m=r.get(h)?.deps??[];for(const y of m)f.has(y.target)&&(p=!0),f.add(y.target);f.add(h)}return p&&l.push(re("(*) = already shown above")),l.join(`
|
|
319
|
+
`)},"projectGraphToAscii"),dm=Ht(t=>{const e=Object.values(t.nodes).map(r=>({name:r.name,type:r.type}));return{edges:Object.values(t.dependencies).flat(),nodes:e}},"projectGraphToJson");var di;const um=Ht(t=>{const e=Object.values(t.nodes).map(s=>({name:s.name,type:s.type})),r=[];for(const s of Object.values(t.dependencies))for(const l of s)r.push({source:l.source,target:l.target,type:l.type});const n=e.filter(s=>s.type==="application"),i=e.filter(s=>s.type!=="application"),o={apps:n.length,edges:r,libs:i.length,nodes:e};return String.raw(di||(di=lm([`<!DOCTYPE html>
|
|
320
|
+
<html lang="en">
|
|
321
|
+
<head>
|
|
322
|
+
<meta charset="UTF-8">
|
|
323
|
+
<title>Project Dependency Graph</title>
|
|
324
|
+
<style>
|
|
325
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
326
|
+
body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; overflow: hidden; }
|
|
327
|
+
svg { width: 100vw; height: 100vh; }
|
|
328
|
+
.edge { fill: none; marker-end: url(#arrow); }
|
|
329
|
+
.node rect { rx: 8; ry: 8; cursor: pointer; transition: stroke-width 0.15s; }
|
|
330
|
+
.node text { font-size: 12px; font-weight: 600; pointer-events: none; }
|
|
331
|
+
.node:hover rect { stroke-width: 2.5; stroke: #fff; }
|
|
332
|
+
#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); }
|
|
333
|
+
#info b { font-variant-numeric: tabular-nums; }
|
|
334
|
+
.app-count { color: #fbbf24; }
|
|
335
|
+
.lib-count { color: #38bdf8; }
|
|
336
|
+
.dep-count { color: #a78bfa; }
|
|
337
|
+
#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; }
|
|
338
|
+
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; }
|
|
339
|
+
#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; }
|
|
340
|
+
#tooltip h3 { font-size: 14px; margin-bottom: 6px; }
|
|
341
|
+
#tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
|
|
342
|
+
#tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
|
|
343
|
+
#tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
|
|
344
|
+
#tooltip li { padding: 1px 0; color: #cbd5e1; }
|
|
345
|
+
#tooltip li::before { content: "92 "; color: #64748b; }
|
|
346
|
+
</style>
|
|
347
|
+
</head>
|
|
348
|
+
<body>
|
|
349
|
+
<div id="info">
|
|
350
|
+
<b class="app-count">`,`</b> apps ·
|
|
351
|
+
<b class="lib-count">`,`</b> libraries ·
|
|
352
|
+
<b class="dep-count">`,`</b> dependencies
|
|
353
|
+
</div>
|
|
354
|
+
<div id="legend">
|
|
355
|
+
<span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
|
|
356
|
+
<span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
|
|
357
|
+
<span style="color:#64748b">— solid = static - - - = implicit</span>
|
|
358
|
+
</div>
|
|
359
|
+
<div id="tooltip"></div>
|
|
360
|
+
<svg id="graph">
|
|
361
|
+
<defs>
|
|
362
|
+
<marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
|
|
363
|
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
|
|
364
|
+
</marker>
|
|
365
|
+
</defs>
|
|
366
|
+
</svg>
|
|
367
|
+
<script>
|
|
368
|
+
const data = `,`;
|
|
369
|
+
const svg = document.getElementById('graph');
|
|
370
|
+
const tooltip = document.getElementById('tooltip');
|
|
371
|
+
const W = window.innerWidth, H = window.innerHeight;
|
|
372
|
+
|
|
373
|
+
// Build adjacency
|
|
374
|
+
const depMap = {}, rdepMap = {};
|
|
375
|
+
data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
|
|
376
|
+
data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
|
|
377
|
+
|
|
378
|
+
// Escape text for safe DOM insertion
|
|
379
|
+
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
|
|
380
|
+
|
|
381
|
+
// Force-directed layout
|
|
382
|
+
const repulsion = 5000 + data.nodes.length * 150;
|
|
383
|
+
const nodes = data.nodes.map(n => ({
|
|
384
|
+
...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
|
|
385
|
+
y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
|
|
386
|
+
}));
|
|
387
|
+
const nodeMap = new Map(nodes.map(n => [n.name, n]));
|
|
388
|
+
const edges = data.edges.map(e => ({
|
|
389
|
+
source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
|
|
390
|
+
}));
|
|
391
|
+
|
|
392
|
+
for (let iter = 0; iter < 400; iter++) {
|
|
393
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
394
|
+
for (let j = i+1; j < nodes.length; j++) {
|
|
395
|
+
let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
|
|
396
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
397
|
+
let f = repulsion / (d * d);
|
|
398
|
+
nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
|
|
399
|
+
nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
edges.forEach(e => {
|
|
403
|
+
if (!e.source || !e.target) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
407
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
408
|
+
let f = (d - 180) * 0.008;
|
|
409
|
+
e.source.vx += dx/d * f; e.source.vy += dy/d * f;
|
|
410
|
+
e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
|
|
411
|
+
});
|
|
412
|
+
nodes.forEach(n => {
|
|
413
|
+
n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
|
|
414
|
+
n.x += n.vx * 0.3; n.y += n.vy * 0.3;
|
|
415
|
+
n.vx *= 0.75; n.vy *= 0.75;
|
|
416
|
+
n.x = Math.max(80, Math.min(W-80, n.x));
|
|
417
|
+
n.y = Math.max(40, Math.min(H-40, n.y));
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Measure text widths
|
|
422
|
+
const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
423
|
+
measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
|
|
424
|
+
measure.setAttribute('font-family','system-ui');
|
|
425
|
+
svg.appendChild(measure);
|
|
426
|
+
const widths = {};
|
|
427
|
+
nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
|
|
428
|
+
svg.removeChild(measure);
|
|
429
|
+
|
|
430
|
+
// Render edges
|
|
431
|
+
edges.forEach(e => {
|
|
432
|
+
if (!e.source || !e.target) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const sw = (widths[e.source.name]||80)/2 + 12;
|
|
436
|
+
const tw = (widths[e.target.name]||80)/2 + 12;
|
|
437
|
+
const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
438
|
+
const d = Math.sqrt(dx*dx+dy*dy)||1;
|
|
439
|
+
const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
|
|
440
|
+
const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
|
|
441
|
+
const line = document.createElementNS('http://www.w3.org/2000/svg','line');
|
|
442
|
+
line.setAttribute('x1',x1); line.setAttribute('y1',y1);
|
|
443
|
+
line.setAttribute('x2',x2); line.setAttribute('y2',y2);
|
|
444
|
+
line.setAttribute('class','edge');
|
|
445
|
+
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
446
|
+
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
447
|
+
line.setAttribute('stroke-width', '1.5');
|
|
448
|
+
if (e.type === 'implicit' || e.type === 'peerDependency') line.setAttribute('stroke-dasharray', '6,4');
|
|
449
|
+
if (e.type === 'devDependency') line.setAttribute('stroke-dasharray', '3,3');
|
|
450
|
+
svg.appendChild(line);
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// Render nodes
|
|
454
|
+
nodes.forEach(n => {
|
|
455
|
+
const w = (widths[n.name]||80) + 24;
|
|
456
|
+
const h = 32;
|
|
457
|
+
const isApp = n.type === 'application';
|
|
458
|
+
const fill = isApp ? '#fbbf24' : '#38bdf8';
|
|
459
|
+
const textFill = '#0f172a';
|
|
460
|
+
const stroke = isApp ? '#f59e0b' : '#0284c7';
|
|
461
|
+
|
|
462
|
+
const g = document.createElementNS('http://www.w3.org/2000/svg','g');
|
|
463
|
+
g.setAttribute('class','node');
|
|
464
|
+
g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
|
|
465
|
+
const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
|
|
466
|
+
rect.setAttribute('width', w); rect.setAttribute('height', h);
|
|
467
|
+
rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
|
|
468
|
+
g.appendChild(rect);
|
|
469
|
+
const text = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
470
|
+
text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
|
|
471
|
+
text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
|
|
472
|
+
text.textContent = n.name;
|
|
473
|
+
g.appendChild(text);
|
|
474
|
+
|
|
475
|
+
g.addEventListener('mouseenter', (ev) => {
|
|
476
|
+
const deps = depMap[n.name] || [];
|
|
477
|
+
const rdeps = rdepMap[n.name] || [];
|
|
478
|
+
|
|
479
|
+
// Build tooltip using safe DOM methods
|
|
480
|
+
tooltip.textContent = '';
|
|
481
|
+
|
|
482
|
+
const heading = document.createElement('h3');
|
|
483
|
+
heading.textContent = n.name;
|
|
484
|
+
const badge = document.createElement('span');
|
|
485
|
+
badge.className = 'type-badge';
|
|
486
|
+
badge.style.background = fill;
|
|
487
|
+
badge.style.color = '#0f172a';
|
|
488
|
+
badge.textContent = n.type;
|
|
489
|
+
heading.appendChild(badge);
|
|
490
|
+
tooltip.appendChild(heading);
|
|
491
|
+
|
|
492
|
+
if (deps.length) {
|
|
493
|
+
const label = document.createElement('div');
|
|
494
|
+
label.className = 'dep-section';
|
|
495
|
+
label.textContent = 'Depends on:';
|
|
496
|
+
tooltip.appendChild(label);
|
|
497
|
+
const ul = document.createElement('ul');
|
|
498
|
+
deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
499
|
+
tooltip.appendChild(ul);
|
|
500
|
+
}
|
|
501
|
+
if (rdeps.length) {
|
|
502
|
+
const label = document.createElement('div');
|
|
503
|
+
label.className = 'dep-section';
|
|
504
|
+
label.textContent = 'Required by:';
|
|
505
|
+
tooltip.appendChild(label);
|
|
506
|
+
const ul = document.createElement('ul');
|
|
507
|
+
rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
508
|
+
tooltip.appendChild(ul);
|
|
509
|
+
}
|
|
510
|
+
if (!deps.length && !rdeps.length) {
|
|
511
|
+
const empty = document.createElement('div');
|
|
512
|
+
empty.style.marginTop = '6px';
|
|
513
|
+
empty.style.color = '#64748b';
|
|
514
|
+
empty.textContent = 'No dependencies';
|
|
515
|
+
tooltip.appendChild(empty);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
tooltip.style.display = 'block';
|
|
519
|
+
const rect = tooltip.getBoundingClientRect();
|
|
520
|
+
tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
|
|
521
|
+
tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
|
|
522
|
+
});
|
|
523
|
+
g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
|
|
524
|
+
svg.appendChild(g);
|
|
525
|
+
});
|
|
526
|
+
<\/script>
|
|
527
|
+
</body>
|
|
528
|
+
</html>`],[`<!DOCTYPE html>
|
|
529
|
+
<html lang="en">
|
|
530
|
+
<head>
|
|
531
|
+
<meta charset="UTF-8">
|
|
532
|
+
<title>Project Dependency Graph</title>
|
|
533
|
+
<style>
|
|
534
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
535
|
+
body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; overflow: hidden; }
|
|
536
|
+
svg { width: 100vw; height: 100vh; }
|
|
537
|
+
.edge { fill: none; marker-end: url(#arrow); }
|
|
538
|
+
.node rect { rx: 8; ry: 8; cursor: pointer; transition: stroke-width 0.15s; }
|
|
539
|
+
.node text { font-size: 12px; font-weight: 600; pointer-events: none; }
|
|
540
|
+
.node:hover rect { stroke-width: 2.5; stroke: #fff; }
|
|
541
|
+
#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); }
|
|
542
|
+
#info b { font-variant-numeric: tabular-nums; }
|
|
543
|
+
.app-count { color: #fbbf24; }
|
|
544
|
+
.lib-count { color: #38bdf8; }
|
|
545
|
+
.dep-count { color: #a78bfa; }
|
|
546
|
+
#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; }
|
|
547
|
+
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; }
|
|
548
|
+
#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; }
|
|
549
|
+
#tooltip h3 { font-size: 14px; margin-bottom: 6px; }
|
|
550
|
+
#tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
|
|
551
|
+
#tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
|
|
552
|
+
#tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
|
|
553
|
+
#tooltip li { padding: 1px 0; color: #cbd5e1; }
|
|
554
|
+
#tooltip li::before { content: "\\2192 "; color: #64748b; }
|
|
555
|
+
</style>
|
|
556
|
+
</head>
|
|
557
|
+
<body>
|
|
558
|
+
<div id="info">
|
|
559
|
+
<b class="app-count">`,`</b> apps ·
|
|
560
|
+
<b class="lib-count">`,`</b> libraries ·
|
|
561
|
+
<b class="dep-count">`,`</b> dependencies
|
|
562
|
+
</div>
|
|
563
|
+
<div id="legend">
|
|
564
|
+
<span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
|
|
565
|
+
<span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
|
|
566
|
+
<span style="color:#64748b">— solid = static - - - = implicit</span>
|
|
567
|
+
</div>
|
|
568
|
+
<div id="tooltip"></div>
|
|
569
|
+
<svg id="graph">
|
|
570
|
+
<defs>
|
|
571
|
+
<marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
|
|
572
|
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
|
|
573
|
+
</marker>
|
|
574
|
+
</defs>
|
|
575
|
+
</svg>
|
|
576
|
+
<script>
|
|
577
|
+
const data = `,`;
|
|
578
|
+
const svg = document.getElementById('graph');
|
|
579
|
+
const tooltip = document.getElementById('tooltip');
|
|
580
|
+
const W = window.innerWidth, H = window.innerHeight;
|
|
581
|
+
|
|
582
|
+
// Build adjacency
|
|
583
|
+
const depMap = {}, rdepMap = {};
|
|
584
|
+
data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
|
|
585
|
+
data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
|
|
586
|
+
|
|
587
|
+
// Escape text for safe DOM insertion
|
|
588
|
+
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
|
|
589
|
+
|
|
590
|
+
// Force-directed layout
|
|
591
|
+
const repulsion = 5000 + data.nodes.length * 150;
|
|
592
|
+
const nodes = data.nodes.map(n => ({
|
|
593
|
+
...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
|
|
594
|
+
y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
|
|
595
|
+
}));
|
|
596
|
+
const nodeMap = new Map(nodes.map(n => [n.name, n]));
|
|
597
|
+
const edges = data.edges.map(e => ({
|
|
598
|
+
source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
|
|
599
|
+
}));
|
|
600
|
+
|
|
601
|
+
for (let iter = 0; iter < 400; iter++) {
|
|
602
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
603
|
+
for (let j = i+1; j < nodes.length; j++) {
|
|
604
|
+
let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
|
|
605
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
606
|
+
let f = repulsion / (d * d);
|
|
607
|
+
nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
|
|
608
|
+
nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
edges.forEach(e => {
|
|
612
|
+
if (!e.source || !e.target) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
616
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
617
|
+
let f = (d - 180) * 0.008;
|
|
618
|
+
e.source.vx += dx/d * f; e.source.vy += dy/d * f;
|
|
619
|
+
e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
|
|
620
|
+
});
|
|
621
|
+
nodes.forEach(n => {
|
|
622
|
+
n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
|
|
623
|
+
n.x += n.vx * 0.3; n.y += n.vy * 0.3;
|
|
624
|
+
n.vx *= 0.75; n.vy *= 0.75;
|
|
625
|
+
n.x = Math.max(80, Math.min(W-80, n.x));
|
|
626
|
+
n.y = Math.max(40, Math.min(H-40, n.y));
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Measure text widths
|
|
631
|
+
const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
632
|
+
measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
|
|
633
|
+
measure.setAttribute('font-family','system-ui');
|
|
634
|
+
svg.appendChild(measure);
|
|
635
|
+
const widths = {};
|
|
636
|
+
nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
|
|
637
|
+
svg.removeChild(measure);
|
|
638
|
+
|
|
639
|
+
// Render edges
|
|
640
|
+
edges.forEach(e => {
|
|
641
|
+
if (!e.source || !e.target) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const sw = (widths[e.source.name]||80)/2 + 12;
|
|
645
|
+
const tw = (widths[e.target.name]||80)/2 + 12;
|
|
646
|
+
const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
647
|
+
const d = Math.sqrt(dx*dx+dy*dy)||1;
|
|
648
|
+
const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
|
|
649
|
+
const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
|
|
650
|
+
const line = document.createElementNS('http://www.w3.org/2000/svg','line');
|
|
651
|
+
line.setAttribute('x1',x1); line.setAttribute('y1',y1);
|
|
652
|
+
line.setAttribute('x2',x2); line.setAttribute('y2',y2);
|
|
653
|
+
line.setAttribute('class','edge');
|
|
654
|
+
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
655
|
+
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
656
|
+
line.setAttribute('stroke-width', '1.5');
|
|
657
|
+
if (e.type === 'implicit' || e.type === 'peerDependency') line.setAttribute('stroke-dasharray', '6,4');
|
|
658
|
+
if (e.type === 'devDependency') line.setAttribute('stroke-dasharray', '3,3');
|
|
659
|
+
svg.appendChild(line);
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
// Render nodes
|
|
663
|
+
nodes.forEach(n => {
|
|
664
|
+
const w = (widths[n.name]||80) + 24;
|
|
665
|
+
const h = 32;
|
|
666
|
+
const isApp = n.type === 'application';
|
|
667
|
+
const fill = isApp ? '#fbbf24' : '#38bdf8';
|
|
668
|
+
const textFill = '#0f172a';
|
|
669
|
+
const stroke = isApp ? '#f59e0b' : '#0284c7';
|
|
670
|
+
|
|
671
|
+
const g = document.createElementNS('http://www.w3.org/2000/svg','g');
|
|
672
|
+
g.setAttribute('class','node');
|
|
673
|
+
g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
|
|
674
|
+
const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
|
|
675
|
+
rect.setAttribute('width', w); rect.setAttribute('height', h);
|
|
676
|
+
rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
|
|
677
|
+
g.appendChild(rect);
|
|
678
|
+
const text = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
679
|
+
text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
|
|
680
|
+
text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
|
|
681
|
+
text.textContent = n.name;
|
|
682
|
+
g.appendChild(text);
|
|
683
|
+
|
|
684
|
+
g.addEventListener('mouseenter', (ev) => {
|
|
685
|
+
const deps = depMap[n.name] || [];
|
|
686
|
+
const rdeps = rdepMap[n.name] || [];
|
|
687
|
+
|
|
688
|
+
// Build tooltip using safe DOM methods
|
|
689
|
+
tooltip.textContent = '';
|
|
690
|
+
|
|
691
|
+
const heading = document.createElement('h3');
|
|
692
|
+
heading.textContent = n.name;
|
|
693
|
+
const badge = document.createElement('span');
|
|
694
|
+
badge.className = 'type-badge';
|
|
695
|
+
badge.style.background = fill;
|
|
696
|
+
badge.style.color = '#0f172a';
|
|
697
|
+
badge.textContent = n.type;
|
|
698
|
+
heading.appendChild(badge);
|
|
699
|
+
tooltip.appendChild(heading);
|
|
700
|
+
|
|
701
|
+
if (deps.length) {
|
|
702
|
+
const label = document.createElement('div');
|
|
703
|
+
label.className = 'dep-section';
|
|
704
|
+
label.textContent = 'Depends on:';
|
|
705
|
+
tooltip.appendChild(label);
|
|
706
|
+
const ul = document.createElement('ul');
|
|
707
|
+
deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
708
|
+
tooltip.appendChild(ul);
|
|
709
|
+
}
|
|
710
|
+
if (rdeps.length) {
|
|
711
|
+
const label = document.createElement('div');
|
|
712
|
+
label.className = 'dep-section';
|
|
713
|
+
label.textContent = 'Required by:';
|
|
714
|
+
tooltip.appendChild(label);
|
|
715
|
+
const ul = document.createElement('ul');
|
|
716
|
+
rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
717
|
+
tooltip.appendChild(ul);
|
|
718
|
+
}
|
|
719
|
+
if (!deps.length && !rdeps.length) {
|
|
720
|
+
const empty = document.createElement('div');
|
|
721
|
+
empty.style.marginTop = '6px';
|
|
722
|
+
empty.style.color = '#64748b';
|
|
723
|
+
empty.textContent = 'No dependencies';
|
|
724
|
+
tooltip.appendChild(empty);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
tooltip.style.display = 'block';
|
|
728
|
+
const rect = tooltip.getBoundingClientRect();
|
|
729
|
+
tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
|
|
730
|
+
tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
|
|
731
|
+
});
|
|
732
|
+
g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
|
|
733
|
+
svg.appendChild(g);
|
|
734
|
+
});
|
|
735
|
+
<\/script>
|
|
736
|
+
</body>
|
|
737
|
+
</html>`])),o.apps,o.libs,o.edges.length,JSON.stringify(o).replaceAll("</",String.raw`<\/`))},"projectGraphToHtml"),pm={group:"Workspace",description:"Visualize the project dependency graph",examples:[["vis graph","Show colored dependency graph (TUI in TTY, ASCII otherwise)"],["vis graph --format=ascii","Force ASCII tree output"],["vis graph --format=dot","Output in Graphviz DOT format"],["vis graph --format=html --output=graph.html","Generate interactive HTML graph"],["vis graph --format=json --output=graph.json","Save JSON graph to file"]],execute:Ht(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=n,{workspace:o}=rn(i,r),s=Yn(i,o),l=!!process.stdout.isTTY&&!Ge,d=e.format??(l?"tui":"ascii"),f=e.output,p=e.depth??1/0;let h;switch(d){case"dot":{h=ic(s);break}case"html":{h=um(s);break}case"json":{h=JSON.stringify(dm(s),void 0,2);break}case"tui":{if(!l){h=li(s,p);break}const m=r?.tui?.autoExit===!0?3:typeof r?.tui?.autoExit=="number"?r.tui.autoExit:0;process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const y=setInterval(()=>{},1e3),b=new Xh(s);await dt(_.createElement(cm,{autoExitSeconds:m,store:b}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(y);return}default:h=li(s,p)}f?(H(f,h,"utf8"),t.info(`Graph written to ${f}`)):t.info(h)},"execute"),name:"graph",options:[{alias:"f",defaultValue:void 0,description:"Output format: tui, ascii, dot, json, html (default: tui in TTY, ascii otherwise)",name:"format",type:String},{alias:"o",description:"Write output to file instead of stdout",name:"output",type:String},{alias:"d",description:"Maximum dependency tree depth for ASCII output (default: unlimited)",name:"depth",type:Number}]},sa=["pre-commit","pre-merge-commit","prepare-commit-msg","commit-msg","post-commit","applypatch-msg","pre-applypatch","post-applypatch","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"],Gr=".vis-hooks";var fm=Object.defineProperty,zr=$((t,e)=>fm(t,"name",{value:e,configurable:!0}),"o$5");const gm=/\/$/,hm=zr(t=>{let e='"$0"';for(let r=0;r<t;r+=1)e=`"$(dirname ${e})"`;return e},"nestedDirname"),mm=zr(t=>{const e=t.split("/").filter(r=>r!==""&&r!==".").length+2;return`#!/usr/bin/env sh
|
|
96
738
|
{ [ "$VIS_GIT_HOOKS" = "2" ]; } && set -x
|
|
97
739
|
n=$(basename "$0")
|
|
98
740
|
s=$(dirname "$(dirname "$0")")/$n
|
|
@@ -101,47 +743,119 @@ s=$(dirname "$(dirname "$0")")/$n
|
|
|
101
743
|
|
|
102
744
|
{ [ "\${VIS_GIT_HOOKS-}" = "0" ]; } && exit 0
|
|
103
745
|
|
|
104
|
-
d=${
|
|
746
|
+
d=${hm(e)}
|
|
105
747
|
export PATH="$d/node_modules/.bin:$PATH"
|
|
106
748
|
sh -e "$s" "$@"
|
|
107
749
|
c=$?
|
|
108
750
|
|
|
109
751
|
[ $c != 0 ] && echo "vis - $n script failed (code $c)"
|
|
110
752
|
[ $c = 127 ] && echo "vis - command not found in PATH=$PATH"
|
|
111
|
-
exit $c`},"hookScript"),
|
|
112
|
-
. "$(dirname "$0")/h"`,{mode:493});return{isError:!1,message:""}},"installHooks");var
|
|
113
|
-
`,"utf8"),{modified:
|
|
114
|
-
`,{mode:493}),
|
|
115
|
-
|
|
116
|
-
`),{
|
|
117
|
-
|
|
118
|
-
${
|
|
753
|
+
exit $c`},"hookScript"),aa=zr((t=Gr)=>{if(process.env.VIS_GIT_HOOKS==="0")return{isError:!1,message:"skip install (git hooks disabled via VIS_GIT_HOOKS=0)"};if(t.includes(".."))return{isError:!0,message:'".." is not allowed in hooks directory path'};const e=Le("git",["rev-parse","--show-prefix"]);if(e.status===void 0||e.status===null)return{isError:!0,message:"git command not found"};if(e.status!==0)return{isError:!1,message:".git directory not found (not a git repository)"};const r=zr((f="")=>T(t,"_",f),"internal"),n=e.stdout.toString().trim().replace(gm,""),i=n?`${n}/${t}/_`:`${t}/_`,o=Le("git",["config","--local","core.hooksPath"]),s=o.status===0?o.stdout?.toString().trim():"";if(s&&s!==i)return{isError:!1,message:`core.hooksPath is already set to "${s}", skipping`};const{status:l,stderr:d}=Le("git",["config","core.hooksPath",i]);if(l==null)return{isError:!0,message:"git command not found"};if(l)return{isError:!0,message:String(d)};$e(r(),{recursive:!0}),H(r(".gitignore"),"*"),H(r("h"),mm(t),{mode:493});for(const f of sa)H(r(f),`#!/usr/bin/env sh
|
|
754
|
+
. "$(dirname "$0")/h"`,{mode:493});return{isError:!1,message:""}},"installHooks");var ym=Object.defineProperty,vm=$((t,e)=>ym(t,"name",{value:e,configurable:!0}),"t$7");const ca=[".lintstagedrc.json",".lintstagedrc"],la=[".lintstagedrc.yaml",".lintstagedrc.yml",".lintstagedrc.mjs","lint-staged.config.mjs",".lintstagedrc.cjs","lint-staged.config.cjs",".lintstagedrc.js","lint-staged.config.js",".lintstagedrc.ts","lint-staged.config.ts",".lintstagedrc.mts","lint-staged.config.mts",".lintstagedrc.cts","lint-staged.config.cts"],go=[...ca,...la],wm=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+lint-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)lint-staged\b/],km=["husky","lint-staged"],bm=/\(is-ci \|\| husky \|\| exit 0\)\s*&&\s*/g,$m=/\bhusky(?:\s+install)?\s*&&\s*/g,xm=/\s*&&\s*husky(?:\s+install)?/g,Sm=/\s*\|\|\s*husky(?:\s+install)?/g,Cm=[bm,$m,xm,Sm],da=vm(t=>{if(t==="husky"||t==="husky install")return;let e=t;for(const r of Cm)e=e.replace(r,"");return e=e.trim(),e===t?t:e||void 0},"cleanHuskyFromScript");var Em=Object.defineProperty,vt=$((t,e)=>Em(t,"name",{value:e,configurable:!0}),"a$3");const jm=[".husky",".config/husky"],Tm=/^\. "\$\(dirname "\$0"\)\/common\.sh"\s*/m,ua=vt(t=>{for(const e of jm)if(F(T(t,e))&&Yr(T(t,e)).isDirectory())return e},"detectHuskyDirectory"),Am=vt((t,e)=>{const r=new Map,n=T(t,e),i=new Set(sa);for(const o of ft(n)){if(o==="_"||o===".gitignore"||o.startsWith("."))continue;const s=T(n,o);Yr(s).isFile()&&(!i.has(o)&&o!=="common.sh"||r.set(o,K(s,"utf8")))}return r},"readHuskyHooks"),Im=vt(t=>t.replace(Tm,""),"transformHookScript"),pa=vt(t=>F(T(t,"pnpm-lock.yaml"))||F(T(t,"pnpm-workspace.yaml"))?"pnpm":F(T(t,"yarn.lock"))?"yarn":F(T(t,"bun.lockb"))||F(T(t,"bun.lock"))?"bun":"npm","detectPackageManager"),Rm=vt((t,e)=>{const r=pa(t),n={bun:["bun","remove","husky"],npm:["npm","uninstall","husky"],pnpm:["pnpm","remove","husky"],yarn:["yarn","remove","husky"]},[i,...o]=n[r];e.info(`Removing husky package via ${r}...`);const s=Le(i,o,{cwd:t,encoding:"utf8",stdio:"pipe"});return s.status!==0?(e.info(`Warning: failed to remove husky via ${r} (${s.stderr?.trim()??"unknown error"})`),!1):!0},"uninstallHuskyPackage"),Om=vt((t,e,r)=>{const n=da(r);if(n!==r)return n?(t[e]=n,`updated "${e}" script`):(delete t[e],`removed "${e}" script (was: "${r}")`)},"processScript"),Pm=vt(t=>{const e=T(t,"package.json");if(!F(e))return{modified:!1,removedScriptReferences:[]};const r=K(e,"utf8"),n=JSON.parse(r),i=[],o=n.scripts;if(o)for(const[s,l]of Object.entries(o)){if(typeof l!="string")continue;const d=Om(o,s,l);d&&i.push(d)}return i.length>0&&H(e,`${JSON.stringify(n,void 0,4)}
|
|
755
|
+
`,"utf8"),{modified:i.length>0,removedScriptReferences:i}},"cleanPackageJsonScripts"),fa=vt((t,e,r)=>{const n=ua(t);if(!n)return{isError:!0,message:"No husky installation found (.husky/ or .config/husky/)"};r.info(`Found husky at ${n}/`);const i=Am(t,n);i.size===0&&r.info("No user-defined hooks found in husky directory.");const o=Le("git",["config","--local","core.hooksPath"]),s=o.status===0?o.stdout?.toString().trim():"";s&&(s===".husky/_"||s.startsWith(".husky"))&&Le("git",["config","--local","--unset","core.hooksPath"]);const l=aa(e);if(l.isError)return l;l.message&&r.info(l.message);const d=T(t,e);$e(d,{recursive:!0});let f=0;for(const[m,y]of i){if(m==="common.sh"){H(T(d,m),y,{mode:493}),r.info(" Copied common.sh");continue}const b=Im(y);H(T(d,m),b,{mode:493}),f+=1,r.info(` Migrated ${m}`)}Rm(t,r);const p=Pm(t);if(p.modified){r.info("Updated package.json scripts:");for(const m of p.removedScriptReferences)r.info(` ${m}`)}const h=T(t,n);return lt(h,{force:!0,recursive:!0}),r.info(`Removed ${n}/`),{isError:!1,message:`Migration complete: ${f} hook${f===1?"":"s"} migrated from ${n}/ to ${e}/`}},"migrateFromHusky");var Nm=Object.defineProperty,Dm=$((t,e)=>Nm(t,"name",{value:e,configurable:!0}),"e$2");const Mm=Dm((t=Gr)=>{if(Le("git",["config","--local","core.hooksPath"]).status!==0)return{isError:!1,message:"No custom hooks path configured"};const{status:e,stderr:r}=Le("git",["config","--local","--unset","core.hooksPath"]);if(e==null)return{isError:!0,message:"git command not found"};if(e&&e!==5)return{isError:!0,message:String(r)};const n=T(t,"_");return F(n)&<(n,{force:!0,recursive:!0}),{isError:!1,message:""}},"uninstallHooks");var Bm=Object.defineProperty,kr=$((t,e)=>Bm(t,"name",{value:e,configurable:!0}),"n$3");const Lm=kr(t=>new Promise(e=>{const r=Vt({input:process.stdin,output:process.stdout});r.question(`${t} (y/N) `,n=>{r.close();const i=n.trim().toLowerCase();e(i==="y"||i==="yes")})}),"confirmPrompt"),Fm=kr(async(t,e)=>{const r=Oi(),n=ua(r);if(n){if(e.info(`Existing husky installation found at ${n}/`),await Lm("Would you like to migrate your husky hooks to vis?")){const o=fa(r,t,e);if(o.isError)throw new Error(o.message);o.message&&e.info(o.message);return}e.info("Aborting install. Remove husky first or run 'vis hook migrate' to migrate.");return}e.info(`Installing git hooks in ${t}/...`);const i=aa(t);if(i.message){if(i.isError)throw new Error(i.message);e.info(i.message);return}F(T(r,t,"pre-commit"))||H(T(r,t,"pre-commit"),`#!/usr/bin/env sh
|
|
756
|
+
`,{mode:493}),e.info("Git hooks installed successfully.")},"executeInstall"),Vm=kr((t,e)=>{const r=Oi(),n=fa(r,t,e);if(n.isError)throw new Error(n.message);n.message&&e.info(n.message)},"executeMigrate"),Um=kr((t,e)=>{e.info("Removing git hooks...");const r=Mm(t);if(r.message){if(r.isError)throw new Error(r.message);e.info(r.message);return}e.info("Git hooks removed successfully.")},"executeUninstall"),Gm={group:"Scaffold & Config",argument:{description:"Action to perform: install, uninstall, or migrate",name:"action",type:String},description:"Manage git hooks for the workspace",env:[{defaultValue:void 0,description:"Set to 0 to disable git hooks, set to 2 for debug output",name:"VIS_GIT_HOOKS",type:String}],examples:[["vis hook install","Install git hooks in .vis-hooks/"],["vis hook uninstall","Remove git hooks and reset core.hooksPath"],["vis hook migrate","Migrate from husky to vis hooks"],["vis hook install --hooks-dir=.githooks","Install hooks in a custom directory"]],execute:kr(async({argument:t,logger:e,options:r})=>{const n=t[0]??"install",i=r.hooksDir??Gr;switch(n){case"install":{await Fm(i,e);break}case"migrate":{Vm(i,e);break}case"uninstall":{Um(i,e);break}default:throw new Error(`Unknown action "${n}". Use "install", "uninstall", or "migrate".`)}},"execute"),name:"hook",options:[{defaultValue:Gr,description:"Custom hooks directory",name:"hooks-dir",type:String}]};var zm=Object.defineProperty,ga=$((t,e)=>zm(t,"name",{value:e,configurable:!0}),"f$5");const Xt=L(Oe(),".vis"),ha=[L(Oe(),".zshrc"),L(Oe(),".zshenv"),L(Oe(),".bashrc"),L(Oe(),".bash_profile"),L(Oe(),".profile"),L(Oe(),".config","fish","config.fish")],Wm=ga(t=>{const e=[];for(const r of ha)if(F(r))try{const n=K(r,"utf8").split(`
|
|
757
|
+
`),i=n.filter(o=>!o.includes(".vis/bin")&&!o.includes("VIS_HOME")&&!o.includes("# vis "));i.length!==n.length&&(H(r,i.join(`
|
|
758
|
+
`)),e.push(r))}catch{t.warn(`warning: could not clean ${r}`)}return e},"cleanShellProfiles"),_m={group:"System",description:"Remove vis from the system (self-uninstall)",examples:[["vis implode","Interactive uninstall"],["vis implode --yes","Non-interactive uninstall (CI)"]],execute:ga(async({logger:t,options:e})=>{if(!F(Xt)){t.info("vis is not installed (no ~/.vis directory found).");return}t.info("This will remove:"),t.info(` ${Xt}/`);const r=ha.filter(i=>F(i)&&K(i,"utf8").includes(".vis"));for(const i of r)t.info(` Lines in ${i}`);if(!e.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const i=Vt({input:process.stdin,output:process.stdout}),o=await new Promise(s=>{i.question(`
|
|
759
|
+
Type "uninstall" to confirm: `,s)});if(i.close(),o.trim()!=="uninstall"){t.info("Aborted.");return}}const n=Wm(t);for(const i of n)t.info(`Cleaned ${i}`);try{lt(Xt,{force:!0,recursive:!0}),t.info(`
|
|
760
|
+
✓ Removed ${Xt}`)}catch(i){throw new Error(`Failed to remove ${Xt}: ${i instanceof Error?i.message:String(i)}`)}t.info("✓ vis has been uninstalled.")},"execute"),name:"implode",options:[{alias:"y",defaultValue:!1,description:"Skip confirmation prompt",name:"yes",type:Boolean}]};var Hm=Object.defineProperty,Jt=$((t,e)=>Hm(t,"name",{value:e,configurable:!0}),"c$5");const Jm=Jt((t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),"ask"),Kt=Jt(async(t,e,r=!0)=>{const n=await Jm(t,`${e} ${r?"[Y/n]":"[y/N]"} `);return n===""?r:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),ma=Jt((t,e)=>{const r=[],n=Object.entries(e.allowBuilds).filter(([,o])=>o).map(([o])=>` "${o}": true,`).join(`
|
|
761
|
+
`);let i=` allowBuilds: ${n?`{
|
|
762
|
+
${n}
|
|
763
|
+
}`:"{}"},`;return e.enableSocket&&(i+=`
|
|
764
|
+
socket: { enabled: true },`),r.push(` security: {
|
|
765
|
+
${i}
|
|
766
|
+
},`),e.staged&&r.push(` staged: {
|
|
767
|
+
"*.{ts,tsx}": "eslint --fix",
|
|
768
|
+
"*.{ts,tsx,js,jsx,json,md}": "prettier --write",
|
|
769
|
+
},`),`import { defineConfig } from "@visulima/vis/config";
|
|
770
|
+
|
|
771
|
+
export default defineConfig({
|
|
772
|
+
${r.join(`
|
|
773
|
+
|
|
774
|
+
`)}
|
|
775
|
+
});
|
|
776
|
+
`},"generateConfigContent"),qm=Jt(async(t,e,r)=>{const n=Vt({input:process.stdin,output:process.stdout});k(`
|
|
777
|
+
vis init — interactive setup
|
|
778
|
+
`);const i=await Kt(n," Enable Socket.dev security scanning?");i&&(Q(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||te(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),k("");const o=await Kt(n," Scan for packages with build scripts?"),s={};if(o){k(" Scanning node_modules...");const p=Rs(t,{});if(p.length>0){k(` Found ${String(p.length)} package${p.length===1?"":"s"} with build scripts:
|
|
779
|
+
`);for(const h of p){const m=await Kt(n,` Allow ${h}?`,!1),y=h.split(" (")[0];s[y]=m,m&&Q(` ✓ ${y} approved`)}}else k(" No packages with build scripts found.")}k("");const l=await Kt(n," Set up pre-commit hooks (lint-staged)?",!1);let d=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(k(""),d=await Kt(n,` Sync security settings to ${e.name} config?`)),n.close(),k("");const f=ma(e.name,{allowBuilds:s,enableSocket:i,staged:l});if(H(r,f),Q(`Created ${r}`),d){const p=Object.fromEntries(Object.entries(s).filter(([,m])=>m)),h=io(e.name,t,p);for(const m of h)Q(` ${m}`)}k(""),k(" Setup complete. Your config:"),k(` Security: ${i?"Socket.dev enabled":"defaults only"}`),k(` Build scripts: ${Object.values(s).filter(Boolean).length} approved`),k(` Git hooks: ${l?"lint-staged configured":"not configured"}`),k(` PM sync: ${d?"done":"skipped"}`),k(""),te(" Run 'vis doctor' to see your project's full health status."),k("")},"runInteractiveInit"),Ym=Jt((t,e,r,n)=>{const i=ma(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if(H(n,i),Q(`Created ${n}`),k(" Secure defaults applied automatically by defineConfig()."),r.syncNative){const o=io(e.name,t,{});for(const s of o)Q(` ${s}`)}k(""),te("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),Xm={group:"Scaffold & Config",description:"Initialize vis.config.ts with best-practice security defaults",examples:[["vis init","Interactive setup wizard"],["vis init --no-interactive","Create minimal config without prompts"],["vis init --force","Overwrite existing config"],["vis init --sync-native","Also sync to native PM config files"]],execute:Jt(async({options:t,workspaceRoot:e})=>{const r=e??process.cwd(),n=me(r),i=nr(r);if(i&&!t.force){ae(`Config already exists: ${i}`),te("Use --force to overwrite, or edit the existing file.");return}const o=i??L(r,"vis.config.ts");process.stdin.isTTY&&t.interactive!==!1&&!t.noInteractive?await qm(r,n,o):Ym(r,n,t,o)},"execute"),name:"init",options:[{defaultValue:!1,description:"Overwrite existing config file",name:"force",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts",name:"no-interactive",type:Boolean},{defaultValue:!1,description:"Sync settings to native PM config files",name:"sync-native",type:Boolean}]};var Km=Object.defineProperty,Qm=$((t,e)=>Km(t,"name",{value:e,configurable:!0}),"s$6");const Zm={group:"Dependencies",alias:"i",description:"Install dependencies using the detected package manager",examples:[["vis install","Install all dependencies"],["vis i --frozen-lockfile","Install with frozen lockfile (CI mode)"],["vis install --prod","Install production dependencies only"],["vis install --filter app","Install for specific workspace package"],["vis install --ignore-scripts","Install without running lifecycle scripts"],["vis install --no-typosquat-check","Skip typosquat name check"]],execute:Qm(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{const i=n??process.cwd();if(!e.noTyposquatCheck&&!await Zi(i,r?.security?.typosquatAllowlist)){process.exitCode=1;return}const o=me(i),s=gr(e.filter),l=Zr(o,{dev:e.dev||!1,filter:s,force:e.force||!1,frozenLockfile:e.frozenLockfile||!1,ignoreScripts:e.ignoreScripts||!1,lockfileOnly:e.lockfileOnly||!1,noOptional:e.noOptional||!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},i,t);l!==0&&(process.exitCode=l)},"execute"),name:"install",options:[{alias:"P",defaultValue:!1,description:"Skip devDependencies",name:"prod",type:Boolean},{alias:"D",defaultValue:!1,description:"Install devDependencies only",name:"dev",type:Boolean},{defaultValue:!1,description:"Use frozen lockfile (CI mode, maps to npm ci)",name:"frozen-lockfile",type:Boolean},{alias:"f",defaultValue:!1,description:"Force reinstall all dependencies",name:"force",type:Boolean},{defaultValue:!1,description:"Skip lifecycle scripts",name:"ignore-scripts",type:Boolean},{defaultValue:!1,description:"Update lockfile without installing",name:"lockfile-only",type:Boolean},{defaultValue:!1,description:"Skip optional dependencies",name:"no-optional",type:Boolean},{defaultValue:!1,description:"Use only cached packages",name:"offline",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output",name:"silent",type:Boolean},{alias:"r",defaultValue:!1,description:"Install in all workspace packages",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Target workspace root",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Skip typosquat name check",name:"no-typosquat-check",type:Boolean}]};var ey=Object.defineProperty,ty=$((t,e)=>ey(t,"name",{value:e,configurable:!0}),"r$5");const ry={group:"Dependencies",alias:"ln",argument:{description:"Package name or directory path to link (omit to register current package)",name:"target",type:String},description:"Link a local package for development",examples:[["vis link","Register current package globally"],["vis link react","Link global package to current project"],["vis link ./packages/utils","Link local directory package"]],execute:ty(async({argument:t,logger:e,workspaceRoot:r})=>{const n=t?.[0]??null,i=r??process.cwd(),o=me(i),s=Hc(o,n,i,e);s!==0&&(process.exitCode=s)},"execute"),name:"link"};var ny=Object.defineProperty,ln=$((t,e)=>ny(t,"name",{value:e,configurable:!0}),"e$1");const ho=ln(t=>{try{const e=K(t,"utf8");return JSON.parse(e)}catch{return}},"readJsonFile"),ya=ln(t=>{if(!F(t))return!1;try{return JSON.parse(K(t,"utf8")),!0}catch{return!1}},"isJsonFile"),oy=/\n([ \t]+)"/,va=ln(t=>oy.exec(t)?.[1]?.length??4,"detectJsonIndent"),iy=ln((t,e)=>{if(!F(t))return!1;const r=K(t,"utf8");let n;try{n=JSON.parse(r)}catch{return!1}const i=e(n);if(i===void 0)return!1;const o=va(r);return H(t,`${JSON.stringify(i,void 0,o)}
|
|
780
|
+
`,"utf8"),!0},"editJsonFile");var sy=Object.defineProperty,wt=$((t,e)=>sy(t,"name",{value:e,configurable:!0}),"f$4");const ay=/\blint-staged\b/g,cy=wt((t,e)=>{let r=!1;const n={...t};for(const[i,o]of Object.entries(n)){if(typeof o!="string")continue;let s=da(o);s&&(s=s.replaceAll(ay,"vis staged").trim()||void 0),s!==o&&(s?n[i]=s:delete n[i],r=!0,e.rewrittenScriptCount+=1)}return{modified:r,scripts:n}},"rewriteScripts"),wa=wt((t,e,r,n)=>{const i=T(t,"package.json");F(i)&&iy(i,o=>{let s=!1;for(const d of km){const f=o.dependencies,p=o.devDependencies;f?.[d]&&(delete f[d],s=!0,n.removedPackageCount+=1),p?.[d]&&(delete p[d],s=!0,n.removedPackageCount+=1)}if(Object.keys(r).length>0)switch(e){case"bun":{const d=o.workspaces,f=d&&!Array.isArray(d)?d:void 0,p={...f?.catalog??o.catalog};for(const[m,y]of Object.entries(r))p[m]=y;f?.catalog==null?o.catalog=p:f.catalog=p;const h=o.overrides??{};for(const m of Object.keys(r))h[m]="catalog:";o.overrides=h,s=!0;break}case"npm":{const d=o.overrides??{};o.overrides={...d,...r},s=!0;break}case"pnpm":{const d=o.pnpm??{},f=d.overrides??{};d.overrides={...f,...r},o.pnpm=d,s=!0;break}case"yarn":{const d=o.resolutions??{};o.resolutions={...d,...r},s=!0;break}}const l=o.scripts;if(l){const d=cy(l,n);d.modified&&(o.scripts=d.scripts,s=!0)}return s?o:void 0})},"rewritePackageJson"),ly=wt((t,e,r,n)=>{try{const{workspace:i}=rn(t);for(const o of Object.values(i.projects)){const s=T(t,o.root);wa(s,e,r,n)}}catch{}},"migrateMonorepoPackages"),dy=wt(t=>t.startsWith("- ")||t!==""&&!t.includes(":")&&!t.startsWith("#"),"isCatalogSectionEnd"),uy=wt(t=>{let e=!1,r="";const n=new Set;for(const i of t){const o=i.trim();if(o==="catalog:"){e=!0;continue}if(!e)continue;if(dy(o))break;const s=o.includes(":")?o.split(":")[0]?.trim():void 0;s&&(n.add(s),r=r||i.slice(0,i.indexOf(o)))}return{entries:n,indent:r||" "}},"parseCatalogEntries"),py=wt((t,e,r)=>{const n=[];let i=!1,o=!1;for(let s=0;s<t.length;s+=1){const l=t[s],d=l.trim();if(n.push(l),d==="catalog:"){o=!0;continue}if(o&&!i){const f=t[s+1]?.trim()??"";(!f.includes(":")||f.startsWith("- ")||!f||f==="catalog:")&&(n.push(...e),i=!0,o=!1)}}return i||(r.includes("catalog:")||n.push("catalog:"),n.push(...e)),n},"insertCatalogEntries"),fy=wt((t,e)=>{const r=T(t,"pnpm-workspace.yaml");if(!F(r)||Object.keys(e).length===0)return;const n=K(r,"utf8"),i=n.split(`
|
|
781
|
+
`),{entries:o,indent:s}=uy(i),l=[];for(const[f,p]of Object.entries(e))o.has(f)||l.push(`${s}${f}: "${p}"`);if(l.length===0)return;const d=py(i,l,n);H(r,d.join(`
|
|
782
|
+
`),"utf8")},"updatePnpmWorkspaceCatalog"),gy=wt((t,e,r,n,i,o)=>{const s=r.overrides??{};if(n.dryRun){i.info("[dry-run] Would rewrite package.json files (remove husky/lint-staged, rewrite scripts)"),Object.keys(s).length>0&&i.info(`[dry-run] Would add overrides: ${JSON.stringify(s)}`);return}wa(t,e,s,o),i.info("Rewritten root package.json"),ly(t,e,s,o),e==="pnpm"&&fy(t,s)},"migrateDeps");var hy=Object.defineProperty,mo=$((t,e)=>hy(t,"name",{value:e,configurable:!0}),"i$2");const my=mo(()=>({gitHooksConfigured:!1,inlinedLintStagedConfigCount:0,manualSteps:[],mergedStagedConfigCount:0,removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0,warnings:[]}),"createMigrationReport"),Wr=mo((t,e)=>{!t||t.warnings.includes(e)||t.warnings.push(e)},"addMigrationWarning"),ka=mo((t,e)=>{!t||t.manualSteps.includes(e)||t.manualSteps.push(e)},"addManualStep");var yy=Object.defineProperty,Ee=$((t,e)=>yy(t,"name",{value:e,configurable:!0}),"r$3");const vy=/\bstaged\s*:/,ui=/(defineConfig\(\{)/,pi=/(export\s+default\s+\{)/;Ee(t=>go.some(e=>F(T(t,e))),"hasStandaloneLintStagedConfig");const wy=Ee(t=>{for(const r of la)if(F(T(t,r)))return!0;const e=T(t,".lintstagedrc");return F(e)&&!ya(e)},"hasUnsupportedLintStagedConfig"),ky=Ee(t=>{const e=nr(t);if(!e)return!1;const r=K(e,"utf8");return vy.test(r)},"hasStagedConfigInVisConfig"),by=Ee(t=>{const e=T(t,"package.json");if(F(e)&&ho(e)?.["lint-staged"])return"package.json";for(const r of go)if(F(T(t,r)))return r},"detectLintStagedConfig"),$y=Ee(t=>ho(T(t,"package.json"))?.["lint-staged"],"extractLintStagedFromPackageJson"),xy=Ee(t=>ho(t),"parseLintStagedJsonFile"),An=Ee(t=>` staged: {
|
|
783
|
+
${Object.entries(t).map(([e,r])=>{const n=Array.isArray(r)?`[${r.map(i=>JSON.stringify(i)).join(", ")}]`:JSON.stringify(r);return` ${JSON.stringify(e)}: ${n}`}).join(`,
|
|
119
784
|
`)},
|
|
120
|
-
}`,"generateStagedConfigSnippet"),
|
|
121
|
-
${
|
|
122
|
-
${
|
|
785
|
+
}`,"generateStagedConfigSnippet"),Sy=Ee((t,e,r)=>{const n=nr(t);if(n){const s=K(n,"utf8"),l=An(e);let d;return ui.test(s)?d=s.replace(ui,`$1
|
|
786
|
+
${l},`):pi.test(s)&&(d=s.replace(pi,`$1
|
|
787
|
+
${l},`)),d?(H(n,d,"utf8"),r.info(`Merged staged config into ${n}`),!0):(r.warn(`Could not auto-insert staged config into ${n} — please add manually`),!1)}const i=T(t,"vis.config.ts"),o=`import { defineConfig } from "@visulima/vis/config";
|
|
123
788
|
|
|
124
789
|
export default defineConfig({
|
|
125
|
-
${
|
|
790
|
+
${An(e)},
|
|
126
791
|
});
|
|
127
|
-
`;return
|
|
128
|
-
`,"utf8")}return
|
|
129
|
-
`);let o=!1;const s=[];for(const
|
|
130
|
-
`)),!0):!1},"rewritePreCommitHook"),
|
|
131
|
-
`),(o==="all"||o==="deps")&&(t.info("── Migrating dependencies and scripts ──"),Xo(i,l,c,{dryRun:s},t,p),t.info("")),(o==="all"||o==="lint-staged")&&(t.info("── Migrating lint-staged ──"),fs(i,{dryRun:s},t,p),t.info("")),hs(p,t)},"execute"),name:"migrate",options:[{defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean}]};var vs=Object.defineProperty,ea=y((e,t)=>vs(e,"name",{value:t,configurable:!0}),"f$1");const ks=ea(e=>async(t,a)=>{const n=a.cwd??t.projectRoot??e,r=n.startsWith("/")?n:`${e}/${n}`,o=t.overrides.command;if(!o)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};try{return{code:0,terminalOutput:Pe(o,{cwd:r,encoding:"utf8",env:{...process.env,...a.env},stdio:"pipe"})}}catch(s){const i=s;return{code:i.status??1,terminalOutput:(i.stdout??"")+(i.stderr??"")}}},"createShellExecutor"),$s={argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target across workspace projects",examples:[["vis run build","Run build on all projects"],["vis run test --projects=pkg-a,pkg-b","Run test on specific projects"],["vis run build --parallel=5","Run build with 5 parallel tasks"],["vis run build --no-cache","Run build without caching"]],execute:ea(async({argument:e,logger:t,options:a,visConfig:n,workspaceRoot:r})=>{const o=e[0];if(!o)throw new Error("Missing target. Usage: vis run <target>");if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=r,{config:i,workspace:c}=ye(s,n),l=Ae(s,c);let p=Object.keys(c.projects);if(a.projects){const R=new Set(a.projects.split(",").map(U=>U.trim()));if(p=p.filter(U=>R.has(U)),p.length===0)throw new Error(`No matching projects found for: ${String(a.projects)}`)}const g=p.filter(R=>c.projects[R]?.targets?.[o]!==void 0);if(g.length===0){t.info(`No projects have the "${o}" target.`);return}const f=g.map(R=>{const U=c.projects[R],re=U?.targets?.[o],aa={project:R,target:o},na=`${R}:${o}`;return{cache:re?.cache??i.targetDefaults?.[o]?.cache,id:na,outputs:re?.outputs??i.targetDefaults?.[o]?.outputs??[],overrides:{command:re?.command},parallelism:re?.parallelism??i.targetDefaults?.[o]?.parallelism,projectRoot:U?.root,target:aa}}),w=da(f,{projectGraph:l,targetDefaults:i.targetDefaults,workspace:c}),$=Object.keys(w.tasks).length,x=Date.now();t.info(`vis run ${o} (${$} task${$===1?"":"s"})`);const G={cacheDirectory:a.cacheDir,dryRun:a.dryRun,parallel:a.parallel??3,skipNxCache:!a.cache,summarize:a.summarize,...i.taskRunnerOptions},j=new ga,T=ks(s),Q=await fa(f,G,{lifeCycle:j,projectGraph:l,taskExecutor:T,taskGraph:w,workspaceRoot:s});if(a.summarize){const R=ma(Q,w,x);await ha(R,s)}let O=!1;for(const[,R]of Q)R.status==="failure"&&(O=!0);if(O)throw new Error("Some tasks failed.");t.info("All tasks completed successfully.")},"execute"),name:"run",options:[{alias:"p",description:"Comma-separated list of projects to run",name:"projects",type:String},{defaultValue:3,description:"Maximum number of parallel tasks",name:"parallel",type:Number},{defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean},{description:"Custom cache directory",name:"cache-dir",type:String},{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Generate a run summary after execution",name:"summarize",type:Boolean}]};var ws=Object.defineProperty,ta=y((e,t)=>ws(e,"name",{value:t,configurable:!0}),"s$1");const bs=ta((e,t)=>{const a=[["allow-empty","allowEmpty"],["continue-on-error","continueOnError"],["cwd","cwd"],["debug","debug"],["diff","diff"],["diff-filter","diffFilter"],["fail-on-changes","failOnChanges"],["hide-partially-staged","hidePartiallyStaged"],["hide-unstaged","hideUnstaged"],["quiet","quiet"],["relative","relative"],["revert","revert"],["stash","stash"],["verbose","verbose"]];for(const[n,r]of a)e[n]!==void 0&&(t[r]=e[n]);if(e.concurrent!==void 0){const n=e.concurrent;if(n==="true")t.concurrent=!0;else if(n==="false")t.concurrent=!1;else{const r=Number(n);t.concurrent=Number.isNaN(r)||n===""?!0:r}}},"mapOptions"),Ss={description:"Run linters on staged files using config from vis.config.ts",examples:[["vis staged","Run staged linters"],["vis staged --verbose","Run with verbose output"],["vis staged --no-stash","Run without backup stash"],["vis staged --diff HEAD~1","Run against a specific diff"]],execute:ta(async({options:e,visConfig:t})=>{const a=(t??{}).staged;if(!a)throw new Error(`No "staged" config found in vis.config.ts. Please add a staged config:
|
|
792
|
+
`;return H(i,o,"utf8"),r.info(`Created ${i} with staged config`),!0},"insertStagedIntoVisConfig"),Cy=Ee(t=>{const e=T(t,"package.json"),r={configRemoved:!1,dependencyRemoved:!1};if(!F(e))return r;const n=K(e,"utf8"),i=JSON.parse(n);let o=!1;i["lint-staged"]&&(delete i["lint-staged"],o=!0,r.configRemoved=!0);const s=i.devDependencies,l=i.dependencies;if(s?.["lint-staged"]&&(delete s["lint-staged"],o=!0,r.dependencyRemoved=!0),l?.["lint-staged"]&&(delete l["lint-staged"],o=!0,r.dependencyRemoved=!0),o){const d=va(n);H(e,`${JSON.stringify(i,void 0,d)}
|
|
793
|
+
`,"utf8")}return r},"removeLintStagedFromPackageJson"),Ey=Ee((t,e)=>{for(const r of go){const n=T(t,r);F(n)&&(Ri(n),e.removedConfigCount+=1)}},"removeLintStagedConfigFiles"),jy=Ee((t,e)=>{const r=T(t,e,"pre-commit");if(!F(r))return!1;const n=K(r,"utf8");if(n.includes("vis staged"))return!1;const i=n.split(`
|
|
794
|
+
`);let o=!1;const s=[];for(const l of i){const d=l.trim();if(!o){let f=!1;for(const p of wm){const h=p.exec(d);if(h){const m=l.slice(0,l.length-l.trimStart().length),y=h[1]?.trim()??"",b=d.slice(h[0].length).trim(),x=[y,"vis staged",b].filter(Boolean);s.push(`${m}${x.join(" ")}`),o=!0,f=!0;break}}if(f)continue}s.push(l)}return o?(H(r,s.join(`
|
|
795
|
+
`)),!0):!1},"rewritePreCommitHook"),Ty=Ee((t,e,r)=>{if(e==="package.json")return $y(t);const n=T(t,e);if(!ca.includes(e)){Wr(r,`${e} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),ka(r,`Manually convert ${e} to staged config in vis.config.ts`);return}if(e===".lintstagedrc"&&!ya(n)){Wr(r,".lintstagedrc is not JSON format — please migrate manually");return}return xy(n)},"extractConfig"),ba=Ee((t,e)=>{const{configRemoved:r,dependencyRemoved:n}=Cy(t);r&&(e.inlinedLintStagedConfigCount+=1),n&&(e.removedPackageCount+=1),Ey(t,e)},"cleanupLintStagedArtifacts"),Ay=Ee((t,e,r,n)=>{const i=[".vis-hooks",".husky"];for(const o of i)F(T(t,o))&&jy(t,o)&&(n.gitHooksConfigured=!0,e.silent||r.info(`Rewrote pre-commit hook in ${o}/ to use "vis staged"`))},"rewriteHooks"),Iy=Ee((t,e,r,n,i)=>{Sy(t,e,n)&&(i.mergedStagedConfigCount+=1),ba(t,i),Ay(t,r,n,i)},"applyMigration"),Ry=Ee((t,e,r,n)=>{const i=by(t);if(!i)return e.silent||r.info("No lint-staged configuration found — nothing to migrate."),!1;if(wy(t)&&(Wr(n,'Non-JSON lint-staged config found — please migrate to "staged" in vis.config.ts manually'),ka(n,"Convert your lint-staged config file to JSON format or add staged config to vis.config.ts manually")),ky(t))return Wr(n,'vis.config.ts already has a "staged" config — skipping lint-staged merge'),e.silent||r.warn('vis.config.ts already has a "staged" config — skipping'),e.dryRun||ba(t,n),!0;const o=Ty(t,i,n);return!o||Object.keys(o).length===0?(e.silent||r.warn("lint-staged config is empty — skipping"),!1):e.dryRun?(e.silent||(r.info("[dry-run] Would insert staged config into vis.config.ts:"),r.info(An(o))),!0):(Iy(t,o,e,r,n),!0)},"migrateLintStaged");var Oy=Object.defineProperty,$a=$((t,e)=>Oy(t,"name",{value:e,configurable:!0}),"g$3");const Py=$a((t,e)=>{e.info("── Migration Summary ──");const r=[["Staged configs merged into vis.config.ts",t.mergedStagedConfigCount],["Lint-staged configs inlined",t.inlinedLintStagedConfigCount],["Config files removed",t.removedConfigCount],["Packages removed",t.removedPackageCount],["Scripts rewritten",t.rewrittenScriptCount]];for(const[n,i]of r)i>0&&e.info(` ${n}: ${String(i)}`);if(t.gitHooksConfigured&&e.info(" Pre-commit hook updated to use vis staged"),t.warnings.length>0){e.info(""),e.warn("Warnings:");for(const n of t.warnings)e.warn(` - ${n}`)}if(t.manualSteps.length>0){e.info(""),e.info("Manual steps required:");for(const n of t.manualSteps)e.info(` - ${n}`)}},"printSummary"),Ny={group:"Scaffold & Config",argument:{description:"Migration type: all, deps, lint-staged",name:"type",type:String},description:"Migrate from other tools (husky, lint-staged) to vis",examples:[["vis migrate","Run all migrations"],["vis migrate deps","Migrate package dependencies and scripts"],["vis migrate lint-staged","Migrate lint-staged config to vis.config.ts"],["vis migrate --dry-run","Preview changes without applying"]],execute:$a(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{const o=t[0]??"all",s=!!r.dryRun,l=i??process.cwd(),d=n??{},f=pa(l),p=my();if(!["all","deps","lint-staged"].includes(o))throw new Error(`Unknown migration type "${o}". Use "all", "deps", or "lint-staged".`);s&&e.info(`Running in dry-run mode — no changes will be made.
|
|
796
|
+
`),(o==="all"||o==="deps")&&(e.info("── Migrating dependencies and scripts ──"),gy(l,f,d,{dryRun:s},e,p),e.info("")),(o==="all"||o==="lint-staged")&&(e.info("── Migrating lint-staged ──"),Ry(l,{dryRun:s},e,p),e.info("")),Py(p,e)},"execute"),name:"migrate",options:[{defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean}]};var Dy=Object.defineProperty,My=$((t,e)=>Dy(t,"name",{value:e,configurable:!0}),"a$1");const By={group:"System",argument:{description:"Subcommand and arguments (e.g., cache dir, publish --dry-run, list --depth 0)",name:"args",type:String},description:"Package manager utilities (cache, publish, audit, list, config, etc.)",examples:[["vis pm cache dir","Show cache directory"],["vis pm cache clean","Clean cache"],["vis pm publish --dry-run","Preview publishing"],["vis pm list --depth 0","List direct dependencies"],["vis pm audit","Run security audit"],["vis pm whoami","Show logged-in user"]],execute:My(async({argument:t,logger:e,workspaceRoot:r})=>{const n=t;if(!n||n.length===0)throw new Error("No subcommand specified. Available: cache, publish, audit, list, view, config, whoami, login, logout, pack, owner, dist-tag, search, fund, ping, token, deprecate, rebuild, prune");const[i,...o]=n,s=r??process.cwd(),l=me(s),d=Yc(l,i,o,s,e);d!==0&&(process.exitCode=d)},"execute"),name:"pm"};var Ly=Object.defineProperty,Fy=$((t,e)=>Ly(t,"name",{value:e,configurable:!0}),"t$5");const Vy={group:"Dependencies",alias:["rm","un","uninstall"],argument:{description:"Packages to remove",name:"packages",type:String},description:"Remove packages using the detected package manager",examples:[["vis remove lodash","Remove a package"],["vis rm old-package","Remove using alias"],["vis remove --filter app react","Remove from specific workspace"],["vis remove -g typescript","Remove global package"]],execute:Fy(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t;if(!i||i.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const o=process.cwd(),s=me(n??o),l=zc(s,{filter:gr(r.filter),global:r.global||!1,packages:i,recursive:r.recursive||!1,saveDev:r.saveDev||!1,workspaceRoot:r.workspaceRoot||!1},o,e);l!==0&&(process.exitCode=l)},"execute"),name:"remove",options:[{alias:"D",defaultValue:!1,description:"Remove from devDependencies",name:"save-dev",type:Boolean},{alias:"g",defaultValue:!1,description:"Remove global package",name:"global",type:Boolean},{alias:"r",defaultValue:!1,description:"Remove from all workspace packages",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Remove from workspace root",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String}]};var Uy=Object.defineProperty,yo=$((t,e)=>Uy(t,"name",{value:e,configurable:!0}),"i$1");const Gy=yo(t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"formatValue"),zy=yo((t,e,r)=>e==="_"?`${t}${Array.isArray(r)?r.join(" "):String(r)}`:`${t}--${e}=${Gy(r)}`,"formatFlags"),vo=yo((t,e,r)=>{const n=new Set(new Set(r.map(m=>m.target.target))),i=new Set(new Set(r.map(m=>m.target.project))),o=e.filter(m=>n.has(m)),s=t.filter(m=>i.has(m)),l=r.length-s.length*o.length,d=o.length===1?"target":"targets",f=o.join(", ");let p;p=s.length===1?`project ${s[0]}`:`${s.length} projects`;let h=`${d} ${f} for ${p}`;return l>0&&(h+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),h},"formatTargetsAndProjects");var Wy=Object.defineProperty,_y=$((t,e)=>Wy(t,"name",{value:e,configurable:!0}),"e");const Hy=_y(()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux","isUnicodeSupported"),dn=Hy(),xa=dn?"✓":"√",wo=dn?"✖":"×",Sa=dn?"…":"...",un=dn?"—":"-";var Jy=Object.defineProperty,qy=$((t,e)=>Jy(t,"name",{value:e,configurable:!0}),"c$4");const Yy={error:"red",info:"white",success:"green"},In=qy(({children:t,title:e,variant:r})=>{const n=Yy[r];return u(g,{flexDirection:"column",children:[u(g,{gap:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),c(a,{bold:!0,color:n,children:"•"}),c(a,{children:e})]}),t]})},"Header");var Xy=Object.defineProperty,Ky=$((t,e)=>Xy(t,"name",{value:e,configurable:!0}),"s$5");const Ca=Ky(({cached:t,failed:e,failedIds:r,projectNames:n,skippedIds:i,succeeded:o,targets:s,tasks:l,took:d})=>{const f=vo(n,s,l);if(e===0&&(!i||i.length===0)){const p=t>0?` (${t} read from cache)`:"";return c(xo,{children:$(()=>c(In,{title:`Successfully ran ${f}`,variant:"success",children:u(g,{flexDirection:"column",paddingLeft:2,children:[u(a,{children:[c(a,{color:"green",children:xa})," ",o+t," ","tasks completed",p?c(a,{dimColor:!0,children:p}):null]}),u(a,{dimColor:!0,children:[" ","Took",d]})]})}),"children")})}return c(xo,{children:$(()=>c(In,{title:`Ran ${f}`,variant:"error",children:u(g,{flexDirection:"column",paddingLeft:2,children:[i&&i.length>0&&u(g,{flexDirection:"column",children:[u(a,{dimColor:!0,children:[i.length," ","task",i.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),i.map(p=>u(a,{dimColor:!0,children:[" - ",p]},p)),c(a,{})]}),e>0&&u(g,{flexDirection:"column",children:[u(a,{children:[c(a,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),r.map(p=>u(a,{children:[" ",c(a,{color:"red",children:wo})," ",p]},p)),c(a,{})]}),u(a,{dimColor:!0,children:[" ","Took",d]})]})}),"children")})},"CommandSummary");var Qy=Object.defineProperty,$n=$((t,e)=>Qy(t,"name",{value:e,configurable:!0}),"u$6");class _r{static{$(this,"TaskStore")}static{$n(this,"TaskStore")}#e;#t=new Set;#n=new Map;constructor(e){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retryTaskId:null,rows:e.map(r=>({status:"pending",taskId:r.id})),selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,viewMode:"list"}}getSnapshot=$n(()=>this.#e,"getSnapshot");subscribe=$n(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");startTasks(e){const r=[...this.#e.rows];for(const n of e){const i=r.findIndex(o=>o.taskId===n.id);i!==-1&&(r[i]={...r[i],elapsed:0,status:"running"},this.#n.set(n.id,process.hrtime()))}this.#r({...this.#e,rows:r})}endTasks(e){const r=[...this.#e.rows];let{cached:n,completed:i,failed:o,succeeded:s}=this.#e;const l=new Map(this.#e.outputs);for(const f of e){const p=r.findIndex(h=>h.taskId===f.task.id);switch(p!==-1&&(r[p]={...r[p],duration:f.startTime&&f.endTime?f.endTime-f.startTime:void 0,status:f.status}),i++,f.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{n++;break}case"success":{s++;break}}f.terminalOutput&&!l.has(f.task.id)&&l.set(f.task.id,f.terminalOutput),this.#n.delete(f.task.id)}let{selectedIndex:d}=this.#e;if(o>this.#e.failed){const f=r.findIndex(p=>p.status==="failure");f!==-1&&(d=f)}this.#r({...this.#e,cached:n,completed:i,failed:o,outputs:l,rows:r,selectedIndex:d,succeeded:s})}static#o=256*1024;addOutput(e,r){if(!r.trim())return;let n=(this.#e.outputs.get(e)??"")+r;n.length>_r.#o&&(n=n.slice(-_r.#o)),this.#e.outputs.set(e,n),this.#r({...this.#e})}setOutput(e,r){this.#e.outputs.set(e,r),this.#r({...this.#e})}markDone(){this.#r({...this.#e,done:!0,endTime:Date.now()})}tick(){if(this.#n.size===0)return;let e=!1;const r=[...this.#e.rows];for(let n=0;n<r.length;n++){const i=r[n];if(i.status==="running"){const o=this.#n.get(i.taskId);if(o){const s=process.hrtime(o),l=s[0]*1e3+s[1]/1e6;r[n]={...i,elapsed:l},e=!0}}}e&&this.#r({...this.#e,rows:r})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:e})}setFilter(e){this.#r({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#r({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,r){const n=[...this.#e.pinnedTaskIds];n[e]=r,this.#r({...this.#e,pinnedTaskIds:n})}clearPins(){this.#r({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const r=[...this.#e.rows],n=r.findIndex(l=>l.taskId===e);let{completed:i,failed:o,succeeded:s}=this.#e;if(n!==-1){const l=r[n].status;l==="failure"?(o=Math.max(0,o-1),i=Math.max(0,i-1)):l==="success"&&(s=Math.max(0,s-1),i=Math.max(0,i-1)),r[n]={...r[n],elapsed:0,status:"running"},this.#n.set(e,process.hrtime())}this.#r({...this.#e,completed:i,done:!1,endTime:null,failed:o,interactiveMode:!1,retryTaskId:e,rows:r,succeeded:s})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#r({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#r({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#r({...this.#e,viewMode:e})}setStatusFilter(e){this.#r({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#n.clear(),this.#r({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,rows:this.#e.rows.map(e=>({status:"pending",taskId:e.taskId})),startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#r({...this.#e,rerunRequested:!1})}#r(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var Zy=Object.defineProperty,_e=$((t,e)=>Zy(t,"name",{value:e,configurable:!0}),"t$3");const ev={d:_e(()=>" d","d"),future:"in %s",h:_e(()=>" h","h"),m:_e(()=>" m","m"),mo:_e(()=>" mo","mo"),ms:_e(()=>" ms","ms"),past:"%s ago",s:_e(()=>" s","s"),w:_e(()=>" w","w"),y:_e(()=>" y","y")},Ea={delimiter:" ",language:ev,largest:2,round:!0,spacer:"",units:["h","m","s","ms"]};_e(t=>{const e=t[0]*1e3+t[1]/1e6;return Ui(e,Ea)},"formatHrtime");const Tt=_e(t=>Ui(t,Ea),"formatMs");var tv=Object.defineProperty,br=$((t,e)=>tv(t,"name",{value:e,configurable:!0}),"n$2");const cr=br(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus"),$r=br(t=>{switch(t){case"failure":return{color:"red",icon:wo};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:xa};case"skipped":return{color:"gray",icon:un};default:return{color:"gray",icon:"?"}}},"getStatusInfo"),ja=br(t=>{const{color:e,icon:r}=$r(t);return ge(_.createElement(a,{color:e},r),{columns:10}).trim()},"getStatusIcon"),rv=br(t=>{const{color:e,icon:r}=$r(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return ge(_.createElement(a,null,_.createElement(a,{color:e},r)," ",_.createElement(a,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return ge(_.createElement(a,null,_.createElement(a,{dimColor:!0},r)," ",_.createElement(a,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return ge(_.createElement(a,{color:e},r),{columns:10}).trim()}},"getStatusPrefix"),nv=br((t,e,r)=>{const n=r.trim();if(!n)return;const i=`
|
|
797
|
+
`;if(process.env.GITHUB_ACTIONS==="true")process.stdout.write(`::group::${ja(e)} ${t}${i}`),process.stdout.write(n+i),process.stdout.write(`::endgroup::${i}`);else{const o=process.stdout.columns||80,s=ge(_.createElement(a,{dimColor:!0},un.repeat(o)),{columns:o}).trim(),l=rv(e),d=ge(_.createElement(a,{bold:!0},t),{columns:o}).trim();process.stdout.write(`${s}${i}`),process.stdout.write(`${l} ${d}${i}`),process.stdout.write(n+i),process.stdout.write(`${s}${i}`)}},"logCommandOutputCI");var ov=Object.defineProperty,Ta=$((t,e)=>ov(t,"name",{value:e,configurable:!0}),"c$3");const iv=Ta(t=>t==="running"?{color:"white",icon:"•"}:t==="pending"?{color:"gray",icon:"·"}:$r(t),"getDisplayInfo"),fi=Ta(({duration:t,focused:e,interactiveMode:r,output:n,scrollRef:i,showFullscreenHint:o,status:s,taskId:l})=>{const d=s??"pending",{icon:f}=iv(d),p=e?"bold":"single",h=d==="failure"?"red":d==="success"||cr(d)?e?"green":"gray":d==="running"?e?"white":"cyan":e?"white":"gray",m=l?`${f} ${l}`:void 0,y=t===void 0?void 0:Tt(t),b=l?r?"Esc cancel | Enter send":e&&d==="running"&&o?"⏎ FULLSCREEN i INPUT":e&&d==="running"?"i INPUT":e&&o?"<enter> full screen":e?void 0:"<tab> or <enter> to focus":void 0;if(!l)return u(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[c(a,{dimColor:!0,children:"Select a task to view output"}),c(a,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const x=n?n.split(`
|
|
798
|
+
`).map(S=>S.replace(/\r$/,"")):[];return!n&&(d==="running"||d==="pending")?c(g,{borderBottomTitle:b,borderColor:h,borderStyle:p,borderTopRightTitle:y,borderTopTitle:m,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"Waiting for task output..."})})}):u(g,{borderBottomTitle:b,borderColor:r?"yellow":h,borderStyle:p,borderTopRightTitle:y,borderTopTitle:m,flexDirection:"column",flexGrow:1,children:[c(g,{flexGrow:1,flexShrink:1,paddingY:1,children:c(zt,{flexGrow:1,followOutput:!0,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:x.map((S,C)=>c(a,{children:S},String(C)))})}),r&&c(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:c(a,{bold:!0,color:"yellow",children:"INTERACTIVE — keystrokes forwarded to task — Esc to exit"})})]})},"OutputPanel");var sv=Object.defineProperty,pn=$((t,e)=>sv(t,"name",{value:e,configurable:!0}),"x");const Aa=6,Ia=8,Ra=10,av=pn(t=>t==="running"||t==="pending"?Sa:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":un,"getCacheLabel"),gi=pn((t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"","getPinLabel"),hi=pn(({compact:t,isSelected:e,pinLabel:r,row:n})=>{const{status:i,taskId:o}=n,s=e?">":" ";let l;if(i==="running")l=u(a,{bold:!0,color:"white",children:[" ",c(Bi,{type:"dots"})," "]});else if(i==="pending")l=c(a,{bold:!0,color:"gray",children:" · "});else{const{color:f,icon:p}=$r(i);l=u(a,{bold:!0,color:f,children:[" ",p," "]})}let d=Sa;return i!=="running"&&i!=="pending"?d=n.duration===void 0?un:Tt(n.duration):i==="running"&&n.elapsed!==void 0&&(d=Tt(n.elapsed)),u(g,{children:[c(a,{children:s}),c(g,{width:Aa,children:l}),u(g,{flexGrow:1,children:[c(a,{bold:e,inverse:e,children:o}),r?c(a,{dimColor:!0,children:` ${r}`}):null]}),!t&&c(g,{justifyContent:"flex-end",width:Ia,children:c(a,{dimColor:!cr(i),children:av(i)})}),!t&&c(g,{justifyContent:"flex-end",width:Ra,children:c(a,{dimColor:i==="pending",children:d})})]})},"TaskListRow"),mi=pn(({compact:t,filterActive:e,filterText:r,focused:n,headerStatus:i,parallelSlots:o=3,pinnedTaskIds:s,rows:l,scrollRef:d,selectedIndex:f,title:p})=>{const h=i==="error"?"red":i==="success"?"green":n?"white":"gray",m=l[f]?.taskId,y=l.filter(S=>S.status==="running"),b=y.length>0||l.some(S=>S.status==="pending"),x=[];if(b)for(let S=0;S<o;S++){const C=y[S];C?x.push(c(hi,{compact:t,isSelected:C.taskId===m,pinLabel:gi(C.taskId,s),row:C},`par-${C.taskId}`)):x.push(u(g,{children:[c(a,{children:" "}),c(g,{width:Aa,children:c(a,{bold:!0,color:"gray",children:" · "})}),c(a,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(S)}`))}return u(g,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),c(a,{children:p}),!t&&u(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c(g,{justifyContent:"flex-end",width:Ia,children:c(a,{dimColor:!0,children:"Cache"})}),c(g,{justifyContent:"flex-end",width:Ra,children:c(a,{dimColor:!0,children:"Duration"})})]})]}),c(zt,{flexGrow:1,flexShrink:1,paddingLeft:1,paddingY:1,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(S=>c(hi,{compact:t,isSelected:S.taskId===m,pinLabel:gi(S.taskId,s),row:S},S.taskId))}),b&&c(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingLeft:1,paddingY:1,children:x}),e&&u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:r}),c(a,{inverse:!0,children:" "})]})]})},"TaskListPanel");var cv=Object.defineProperty,lv=$((t,e)=>cv(t,"name",{value:e,configurable:!0}),"y$1");const yi=40,vi=10,wi=100,dv=lv(({autoExitSeconds:t,parallelSlots:e,projectNames:r,stdinRegistry:n,store:i,targets:o,tasks:s})=>{const{exit:l}=Gt(),{columns:d,rows:f}=Ut(),p=pr(i.subscribe,i.getSnapshot),[h,m]=ce(!1),y=be(null),b=be(null),x=be(null),[S,C]=ce(!1),D=be({list:0,splitList:0,splitOutput:0}),P=Ye(()=>{p.viewMode==="list"?D.current.list=b.current?.getScrollOffset()??0:p.viewMode==="split"&&(D.current.splitList=b.current?.getScrollOffset()??0,D.current.splitOutput=x.current?.getScrollOffset()??0)},[p.viewMode]),M=Ye(O=>{setTimeout(()=>{if(O==="list"){const I=D.current.list;b.current?.scrollTo(I)}else if(O==="split"){const I=D.current.splitList;I>0?b.current?.scrollTo(I):b.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),x.current?.scrollTo(D.current.splitOutput)}},0)},[i]),E=be(!1);qe(()=>{p.done&&!E.current&&(E.current=!0,t>0&&C(!0)),!p.done&&E.current&&(E.current=!1,C(!1))},[p.done,t]);const R=Ke(()=>{let O=p.rows;if(p.statusFilter!=="all"&&(O=O.filter(I=>p.statusFilter==="failed"?I.status==="failure":p.statusFilter==="running"?I.status==="running"||I.status==="pending":p.statusFilter==="passed"?I.status==="success"||cr(I.status):!0)),p.filterText){const I=p.filterText.toLowerCase();O=O.filter(Y=>Y.taskId.toLowerCase().includes(I))}return O},[p.rows,p.filterText,p.statusFilter]),A=Ke(()=>p.rows.filter(O=>O.status==="running").length,[p.rows]),G=(R[p.selectedIndex]??null)?.taskId??null,B=p.pinnedTaskIds[0]??G,w=B?p.rows.find(O=>O.taskId===B):null,v=B?p.outputs.get(B)??"":"",j=vo(r,o,s),U=p.done?`Completed ${j} (${Tt((p.endTime??Date.now())-p.startTime)})`:`Running ${j}...`,z=p.done?p.failed>0?"error":"success":"running",Z=Ye(O=>{b.current?.scrollTo(Math.max(0,O-2))},[]);if(qe(()=>{p.interactiveMode&&w?.status!=="running"&&i.setInteractiveMode(!1)},[p.interactiveMode,w?.status,i]),qe(()=>{if(!B)return;let O=d;p.viewMode==="split"&&d>=wi?O=d-Math.floor(d*.4)-2:(p.viewMode==="split"||p.viewMode==="fullscreen")&&(O=d-2);const I=Math.max(1,f-4);n.get(B)?.resize?.(O,I)},[d,f,p.viewMode,B]),De((O,I)=>{if(I.escape){i.setInteractiveMode(!1);return}if(!B)return;const Y=n.get(B);if(!Y){i.setInteractiveMode(!1);return}if(I.return)Y.write("\r");else if(I.upArrow)Y.write("\x1B[A");else if(I.downArrow)Y.write("\x1B[B");else if(I.rightArrow)Y.write("\x1B[C");else if(I.leftArrow)Y.write("\x1B[D");else if(I.backspace)Y.write("");else if(I.delete)Y.write("\x1B[3~");else if(I.tab)Y.write(" ");else if(I.home)Y.write("\x1B[H");else if(I.end)Y.write("\x1B[F");else if(I.pageUp)Y.write("\x1B[5~");else if(I.pageDown)Y.write("\x1B[6~");else if(I.ctrl&&O){const ye=O.toUpperCase().codePointAt(0);ye!==void 0&&ye>=65&&ye<=90&&Y.write(String.fromCodePoint(ye-64))}else O&&Y.write(O)},{isActive:p.interactiveMode}),De((O,I)=>{if(O==="c"&&I.ctrl){l();return}if(!S){if(h){I.escape||O==="?"?m(!1):O==="q"?(m(!1),C(!0)):I.downArrow||O==="j"?y.current?.scrollBy(1):I.upArrow||O==="k"?y.current?.scrollBy(-1):I.pageDown?y.current?.scrollBy(5):I.pageUp?y.current?.scrollBy(-5):I.home?y.current?.scrollToTop():I.end&&y.current?.scrollToBottom();return}if(O==="?"){m(!0);return}if(O==="q"){C(!0);return}if(O==="r"&&p.done){i.requestRerun();return}if(O==="R"&&p.done){const Y=R[p.selectedIndex];Y?.status==="failure"&&i.requestRetry(Y.taskId);return}if(O==="F"&&!p.filterActive){const Y=["all","failed","running","passed"],ye=Y.indexOf(p.statusFilter);i.setStatusFilter(Y[(ye+1)%Y.length]);return}if(p.filterActive){if(I.escape){i.setFilterActive(!1);return}if(I.return){i.setFilterActive(!1);return}if(I.backspace){i.setFilter(p.filterText.slice(0,-1));return}if(O&&!I.ctrl&&!I.meta){i.setFilter(p.filterText+O);return}return}if(O==="i"&&w?.status==="running"&&(p.viewMode==="fullscreen"||p.viewMode==="split"&&p.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(p.viewMode==="fullscreen"){if(I.escape){i.setViewMode("split"),M("split");return}if(I.downArrow||O==="j"){x.current?.scrollBy(1);return}if(I.upArrow||O==="k"){x.current?.scrollBy(-1);return}if(I.pageDown||I.ctrl&&O==="d"){x.current?.scrollBy(12);return}if(I.pageUp||I.ctrl&&O==="u"){x.current?.scrollBy(-12);return}if(I.home){x.current?.scrollToTop();return}if(I.end){x.current?.scrollToBottom();return}return}if(p.viewMode==="split"){if(I.tab){const Y=p.focusedPanel==="tasks"?"output":"tasks";i.setFocusedPanel(Y);return}if(p.focusedPanel==="output"){if(I.escape){i.setFocusedPanel("tasks");return}if(I.return){P(),i.setViewMode("fullscreen");return}if(I.downArrow||O==="j"){x.current?.scrollBy(1);return}if(I.upArrow||O==="k"){x.current?.scrollBy(-1);return}if(I.pageDown||I.ctrl&&O==="d"){x.current?.scrollBy(12);return}if(I.pageUp||I.ctrl&&O==="u"){x.current?.scrollBy(-12);return}if(I.home){x.current?.scrollToTop();return}if(I.end){x.current?.scrollToBottom();return}return}if(I.escape){i.setViewMode("list"),M("list");return}if(I.return){i.setFocusedPanel("output");return}}if(p.viewMode==="list"||p.viewMode==="split"&&p.focusedPanel==="tasks"){if(I.downArrow||O==="j"){const Y=Math.min(p.selectedIndex+1,Math.max(0,R.length-1));i.setSelectedIndex(Y),Z(Y);return}if(I.upArrow||O==="k"){const Y=Math.max(p.selectedIndex-1,0);i.setSelectedIndex(Y),Z(Y);return}if(I.return&&p.viewMode==="list"){P(),D.current.splitList=0,D.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),M("split");return}if(O==="/"){i.setFilterActive(!0);return}if(O==="1"&&G){i.pinTask(0,G);return}if(O==="2"&&G){i.pinTask(1,G);return}if(O==="0"){i.clearPins();return}I.escape&&p.filterText&&i.setFilter("")}}},{isActive:!p.interactiveMode}),d<yi||f<vi)return c(g,{alignItems:"center",height:f,justifyContent:"center",width:d,children:u(a,{color:"yellow",children:["Terminal too small (",d,"x",f,"). Minimum:"," ",yi,"x",vi]})});const he=u(g,{gap:1,children:[p.succeeded>0&&u(a,{bold:!0,color:"green",children:["✓"," ",p.succeeded]}),p.failed>0&&u(a,{bold:!0,color:"red",children:["✗"," ",p.failed]}),A>0&&u(a,{color:"cyan",children:["◷"," ",A]}),u(a,{dimColor:!0,children:[p.rows.length," ","total"]}),p.statusFilter!=="all"&&u(a,{color:"yellow",children:["[",p.statusFilter,"]"]})]});let oe;if(p.viewMode==="fullscreen")oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"^u ^d"}),c(a,{dimColor:!0,children:"PAGE"})]},"page"),...w?.status==="running"?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"i"}),c(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q")];else if(p.done){const O=R[p.selectedIndex]?.status==="failure";oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"r"}),c(a,{dimColor:!0,children:"RERUN"})]},"r"),...O?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"R"}),c(a,{dimColor:!0,children:"RETRY"})]},"R")]:[],u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"F"}),c(a,{dimColor:!0,children:"FILTER"})]},"F"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:p.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else p.viewMode==="split"&&p.focusedPanel==="output"?oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),...w?.status==="running"?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"i"}),c(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"tab"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?")]:oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:"FILTER"})]},"/"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"F"}),c(a,{dimColor:!0,children:"STATUS"})]},"F"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:p.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...p.viewMode==="split"?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Te=u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:oe}),c(g,{flexShrink:0,paddingX:1,children:he})]}),ke=u(xt,{backgroundColor:"#1e1e1e",footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:h,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Move up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Move down"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Tab"]}),c(a,{dimColor:!0,children:" Switch panel (split)"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Esc"]}),c(a,{dimColor:!0,children:" Back / close"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Enter"]}),c(a,{dimColor:!0,children:" Show output / fullscreen"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"VIEWS"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Enter"]}),u(a,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Esc"]}),u(a,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","/"]}),c(a,{dimColor:!0,children:" Filter by text"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","F"]}),c(a,{dimColor:!0,children:" Filter by status"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","1"]}),c(a,{dimColor:!0,children:"/"}),c(a,{bold:!0,color:"white",children:"2"}),c(a,{dimColor:!0,children:" Pin to output pane"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","0"]}),c(a,{dimColor:!0,children:" Clear pins"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","r"]}),c(a,{dimColor:!0,children:" Rerun all (done)"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","R"]}),c(a,{dimColor:!0,children:" Retry failed task"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","i"]}),c(a,{dimColor:!0,children:" Interactive input (running task)"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"SCROLLING"}),c(a,{dimColor:!0,children:" (output panel)"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Scroll up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Scroll down"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","^u"]}),c(a,{dimColor:!0,children:" Page up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","^d"]}),c(a,{dimColor:!0,children:" Page down"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Home"]}),c(a,{dimColor:!0,children:" Top"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","End"]}),c(a,{dimColor:!0,children:" Bottom"})]})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"GENERAL"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","q"]}),c(a,{dimColor:!0,children:" Quit"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","?"]}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]})]}),Se=c(jt,{autoExitSeconds:t>0?t:3,onCancel:$(()=>{C(!1)},"onCancel"),visible:S});if(p.viewMode==="fullscreen")return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{flexGrow:1,children:c(fi,{duration:w?.duration??w?.elapsed,focused:!0,interactiveMode:p.interactiveMode,output:v,scrollRef:x,status:w?.status,taskId:B})}),Te,Se,ke]});if(p.viewMode==="split"){const O=d>=wi,I=c(mi,{compact:!0,filterActive:p.filterActive,filterText:p.filterText,focused:p.focusedPanel==="tasks",headerStatus:z,parallelSlots:e,pinnedTaskIds:p.pinnedTaskIds,rows:R,scrollRef:b,selectedIndex:p.selectedIndex,title:U}),Y=c(fi,{duration:w?.duration??w?.elapsed,focused:p.focusedPanel==="output",interactiveMode:p.interactiveMode,output:v,scrollRef:x,showFullscreenHint:!0,status:w?.status,taskId:B});if(O){const Ae=Math.floor(d*.4);return u(g,{flexDirection:"column",height:f,width:d,children:[u(g,{flexDirection:"row",flexGrow:1,children:[c(g,{width:Ae,children:I}),c(g,{flexGrow:1,children:Y})]}),Te,Se,ke]})}const ye=Math.floor(f*.45);return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{height:ye,children:I}),c(g,{flexGrow:1,children:Y}),Te,Se,ke]})}return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{flexGrow:1,children:c(mi,{filterActive:p.filterActive,filterText:p.filterText,focused:!0,headerStatus:z,parallelSlots:e,pinnedTaskIds:p.pinnedTaskIds,rows:R,scrollRef:b,selectedIndex:p.selectedIndex,title:U})}),Te,Se,ke]})},"VisTaskRunnerApp");var uv=Object.defineProperty,Pt=$((t,e)=>uv(t,"name",{value:e,configurable:!0}),"n$1");const pv=Pt(t=>{const{args:e,autoExit:r=!1,projectNames:n,stdinRegistry:i,tasks:o}=t,s=new _r(o),l=typeof e.parallel=="number"?e.parallel:3,d=r===!0?3:typeof r=="number"?r:0;let f,p;const h=new Promise(P=>{p=P});let m;const y=Pt(()=>{m&&(clearInterval(m),m=void 0)},"cleanup"),b=Pt(()=>{if(i){for(const P of i.values())P.kill?.();i.clear()}},"killAllPtyProcesses"),x=Pt(()=>{y(),D(),b(),process.stdout.write("\x1B[?1049l\x1B[?25h"),f?.cleanup(),process.exit(1)},"onSignal"),S=Pt(()=>{const P=s.getSnapshot(),M=Tt(Date.now()-P.startTime),E=P.rows.filter(G=>G.status==="failure").map(G=>G.taskId),R=process.stdout.columns||80;process.stdout.write(`
|
|
799
|
+
`);for(const G of P.rows){const{status:B,taskId:w}=G,v=$r(B);let j="";switch(B){case"local-cache":case"local-cache-kept-existing":{j=" [local cache]";break}case"remote-cache":{j=" [remote cache]";break}case"skipped":{j=" [skipped]";break}}const U=ge(_.createElement(a,null," ",_.createElement(a,{color:v.color},v.icon),` vis run ${w}`,j?_.createElement(a,{dimColor:!0},` ${j}`):null),{columns:R});process.stdout.write(`${U}
|
|
800
|
+
`)}process.stdout.write(`
|
|
801
|
+
`);const A=ge(_.createElement(Ca,{cached:P.cached,failed:P.failed,failedIds:E,projectNames:n,succeeded:P.succeeded,targets:e.targets,tasks:o,took:M}),{columns:R});if(process.stdout.write(`${A}
|
|
802
|
+
`),E.length>0)for(const G of E){const B=P.outputs.get(G);if(B?.trim()){const w=ge(_.createElement(a,null,`
|
|
803
|
+
`,_.createElement(a,{bold:!0,color:"red"},` ${wo} vis run ${G}`)),{columns:R});process.stdout.write(`${w}
|
|
804
|
+
|
|
805
|
+
`);const v=B.trim().split(`
|
|
806
|
+
`).map(j=>` ${j}`).join(`
|
|
807
|
+
`);process.stdout.write(`${v}
|
|
808
|
+
`)}}},"printExitSummary");let C;const D=Pt(()=>{C&&(clearInterval(C),C=void 0)},"clearKeepAlive");return{lifeCycle:{endCommand(){y(),s.markDone(),C||(C=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume())},endTasks(P){s.endTasks(P)},printTaskTerminalOutput(P,M,E){s.getSnapshot().outputs.has(P.id)||s.addOutput(P.id,E)},startCommand(){process.on("SIGINT",x),process.on("SIGTERM",x),C||(C=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume()),f=dt(_.createElement(dv,{autoExitSeconds:d,parallelSlots:l,projectNames:n,stdinRegistry:i??new Map,store:s,targets:e.targets,tasks:o}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),f.waitUntilExit().then(()=>{D(),b(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),S(),p()},()=>{D(),b(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),p()})},startTasks(P){s.startTasks(P),m||(m=setInterval(()=>{s.tick()},100))}},renderIsDone:h,store:s}},"createDynamicOutputRenderer");var fv=Object.defineProperty,gv=$((t,e)=>fv(t,"name",{value:e,configurable:!0}),"u$5");class hv{static{$(this,"StaticOutputLifeCycle")}static{gv(this,"StaticOutputLifeCycle")}#e;#t;#n;#o=[];#r=[];#i=new Map;#s=0;constructor(e){this.#e=e.projectNames,this.#t=e.args.targets,this.#n=e.tasks}startCommand(){this.#s=Date.now();const e=process.stdout.columns||80,r=`Running ${vo(this.#e,this.#t,this.#n)}`,n=ge(_.createElement(In,{title:r,variant:"info"}),{columns:e});process.stdout.write(n);const i=this.#n[0],o=i?.overrides?Object.entries(i.overrides).filter(([s])=>s!=="command"):[];if(o.length>0){process.stdout.write(`
|
|
809
|
+
With additional flags:
|
|
810
|
+
`);for(const[s,l]of o)process.stdout.write(`${zy(" ",s,l)}
|
|
811
|
+
`)}process.stdout.write(`
|
|
812
|
+
`)}startTasks(e){const r=process.stdout.columns||80;for(const n of e){const i=ge(_.createElement(a,null,_.createElement(a,{dimColor:!0},">"),` ${n.id}`),{columns:r});process.stdout.write(`${i}
|
|
813
|
+
`)}}endTasks(e){const r=process.stdout.columns||80;for(const n of e){this.#i.set(n.task.id,n),n.status==="failure"?this.#o.push(n):cr(n.status)&&this.#r.push(n);const i=ja(n.status),o=n.startTime&&n.endTime?` (${Tt(n.endTime-n.startTime)})`:"",s=cr(n.status)?" [cache]":"",l=ge(_.createElement(a,null,i,` ${n.task.id}`,s?_.createElement(a,{color:"cyan"},s):null,o?_.createElement(a,{dimColor:!0},o):null),{columns:r});process.stdout.write(`${l}
|
|
814
|
+
`)}}printTaskTerminalOutput(e,r,n){nv(e.id,r,n)}endCommand(){const e=Tt(Date.now()-this.#s),r=this.#n.filter(o=>!this.#i.has(o.id)).map(o=>o.id);process.stdout.write(`
|
|
815
|
+
`);const n=process.stdout.columns||80,i=ge(_.createElement(Ca,{cached:this.#r.length,failed:this.#o.length,failedIds:this.#o.map(o=>o.task.id),projectNames:this.#e,skippedIds:r.length>0?r:void 0,succeeded:this.#i.size-this.#o.length-this.#r.length,targets:this.#t,tasks:this.#n,took:e}),{columns:n});process.stdout.write(`${i}
|
|
816
|
+
`)}}var mv=Object.defineProperty,lr=$((t,e)=>mv(t,"name",{value:e,configurable:!0}),"E$1");const Rn=256*1024;class yv{static{$(this,"Q")}static{lr(this,"OutputRingBuffer")}#e;#t="";#n=!1;constructor(e){this.#e=e}append(e){this.#t+=e,this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e),this.#n=!0)}toString(){return this.#n?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
817
|
+
${this.#t}`:this.#t}}const ki=lr((t,e,r,n)=>async(i,o)=>{const s=o.cwd??i.projectRoot??t,l=s.startsWith("/")?s:`${t}/${s}`,d=i.overrides.command;if(!d)return{code:0,terminalOutput:`No command configured for ${i.target.project}:${i.target.target}`};const f=!!e;f&&(i.cache=!1);const p=f?void 0:new yv(Rn),h=f?new Ni(Rn):void 0,m=lr(y=>{if(y.kind==="started"&&y.write&&e&&e.set(i.id,{kill:y.kill,resize:y.resize,write:y.write}),(y.kind==="stdout"||y.kind==="stderr")&&y.text!==void 0)if(h)h.write(y.text),n?.(i.id,h.toString());else{const b=`${y.text}
|
|
818
|
+
`;p.append(b),r?.(i.id,b)}y.kind==="close"&&e&&e.delete(i.id)},"onEvent");return{code:(await Di([{command:d,cwd:l,env:o.env,name:i.id,...e?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:m})).closeEvents[0]?.exitCode??1,terminalOutput:h?h.toString():p.toString()}},"createConcurrentExecutor"),vv={group:"Run & Execute",argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target across workspace projects",examples:[["vis run build","Run build on all projects"],["vis run test --projects=pkg-a,pkg-b","Run test on specific projects"],["vis run build --parallel=5","Run build with 5 parallel tasks"],["vis run build --no-cache","Run build without caching"]],execute:lr(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{const o=t[0];if(!o)throw new Error("Missing target. Usage: vis run <target>");if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=i,{config:l,workspace:d}=rn(s,n),f=Yn(s,d);if(l.constraints&&!r.skipConstraints){const M=sc(f,l.constraints);if(M.length>0){for(const E of M)e.error(`[${E.rule}] ${E.message}`);throw new Error(`${M.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}let p=Object.keys(d.projects);if(r.projects){const M=new Set(r.projects.split(",").map(E=>E.trim()));if(p=p.filter(E=>M.has(E)),p.length===0)throw new Error(`No matching projects found for: ${String(r.projects)}`)}const h=p.filter(M=>d.projects[M]?.targets?.[o]!==void 0);if(h.length===0){e.info(`No projects have the "${o}" target.`);return}let m=h.map(M=>{const E=d.projects[M],R=E?.targets?.[o],A={project:M,target:o},G=`${M}:${o}`;return{cache:R?.cache??l.targetDefaults?.[o]?.cache,id:G,outputs:R?.outputs??l.targetDefaults?.[o]?.outputs??[],overrides:{command:R?.command},parallelism:R?.parallelism??l.targetDefaults?.[o]?.parallelism,projectRoot:E?.root,target:A}});const y=ac(r.partition);if(y&&(m=cc.partitionTasks(m,y),e.info(`Partition ${y.index}/${y.total}: running ${m.length} task(s)`),m.length===0)){e.info("No tasks assigned to this partition.");return}const b=lc(m,{projectGraph:f,targetDefaults:l.targetDefaults,workspace:d}),x=Date.now(),S={cacheDirectory:r.cacheDir,dryRun:r.dryRun,parallel:r.parallel??3,skipNxCache:!r.cache,summarize:r.summarize,...l.taskRunnerOptions},C=process.stdout.isTTY&&!Ge,D=l.tui?.autoExit??!1,P={args:{parallel:S.parallel,targets:[o]},autoExit:D,projectNames:h,tasks:m};if(C){const M=new Map,E=pv({...P,stdinRegistry:M}),{lifeCycle:R,store:A}=E,G=ki(s,M,(v,j)=>A.addOutput(v,j),(v,j)=>A.setOutput(v,j));let B="rerun",w=null;for(;B!=="quit";){if(B==="rerun")await $o(m,S,{lifeCycle:R,projectGraph:f,taskExecutor:G,taskGraph:b,workspaceRoot:s});else if(B==="retry"&&w){const v=m.find(U=>U.id===w),j=v?.overrides.command;if(v&&j){const U=v.projectRoot??s,z=U.startsWith("/")?U:`${s}/${U}`;R.startTasks?.([v]);const Z=new Ni(Rn),he=(await Di([{command:j,cwd:z,name:v.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:lr(oe=>{oe.kind==="started"&&oe.write&&M.set(v.id,{kill:oe.kill,resize:oe.resize,write:oe.write}),(oe.kind==="stdout"||oe.kind==="stderr")&&oe.text&&(Z.write(oe.text),A.setOutput(v.id,Z.toString())),oe.kind==="close"&&M.delete(v.id)},"onEvent")})).closeEvents[0];R.endTasks?.([{code:he?.exitCode??1,status:he?.exitCode===0?"success":"failure",task:v,terminalOutput:A.getSnapshot().outputs.get(v.id)}])}else v&&R.endTasks?.([{code:1,status:"failure",task:v,terminalOutput:`No command configured for ${v.id}`}]);w=null,A.markDone()}B=await new Promise(v=>{const j=A.subscribe(()=>{const U=A.getSnapshot();U.rerunRequested&&(A.acknowledgeRerun(),j(),v("rerun")),U.retryTaskId&&(w=A.acknowledgeRetry(),j(),v("retry"))});E.renderIsDone.then(()=>{j(),v("quit")},()=>{j(),v("quit")})})}await E.renderIsDone}else{const M=ki(s),E=new hv(P),R=await $o(m,S,{lifeCycle:E,projectGraph:f,taskExecutor:M,taskGraph:b,workspaceRoot:s});if(r.summarize){const G=dc(R,b,x);await uc(G,s)}let A=!1;for(const[,G]of R)G.status==="failure"&&(A=!0);if(A)throw new Error("Some tasks failed.")}},"execute"),name:"run",options:[{alias:"p",description:"Comma-separated list of projects to run",name:"projects",type:String},{defaultValue:3,description:"Maximum number of parallel tasks",name:"parallel",type:Number},{defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean},{description:"Custom cache directory",name:"cache-dir",type:String},{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Generate a run summary after execution",name:"summarize",type:Boolean},{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',name:"partition",type:String},{defaultValue:!1,description:"Skip project constraint validation",name:"skip-constraints",type:Boolean}]};var wv=Object.defineProperty,Hr=$((t,e)=>wv(t,"name",{value:e,configurable:!0}),"d$3");const kv=Hr(t=>{const e=new Set,r=[],n=Hr(o=>{const s=Ft(o);!e.has(s)&&le(s)&&(e.add(s),r.push(s))},"addFile");n(L(t,"package.json"));const i=tn(t);if(i){const o=Ct(t,i);for(const s of o)n(L(t,s,"package.json"))}else{const o=L(t,"package.json");if(le(o)){const s=JSON.parse(K(o,"utf8")),l=Array.isArray(s.workspaces)?s.workspaces:s.workspaces?.packages;if(l){const d=Ct(t,l);for(const f of d)n(L(t,f,"package.json"))}}}return r},"findPackageJsonFiles"),bv=Hr((t,e)=>{const r=Qr();if(!r)throw new Error("Native bindings unavailable: sort-package-json requires the native addon. Ensure the correct platform binary is installed.");return r.sortPackageJsonStringWithOptions(t,{pretty:!0,sort_scripts:e})},"sortContents"),$v={group:"Workspace",description:"Sort package.json files across the workspace using the sort-package-json Rust crate",examples:[["vis sort-package-json","Sort all package.json files in the workspace"],["vis sort-package-json --check","Check if files are already sorted (exit 1 if not)"],["vis sort-package-json --sort-scripts","Also sort the scripts field alphabetically"]],execute:Hr(async({options:t,visConfig:e,workspaceRoot:r})=>{const n=r??process.cwd(),i=e?.sortPackageJson,o=t.check||!1,s=t.sortScripts||i?.sortScripts||!1,l=kv(n);if(l.length===0){k("No package.json files found.");return}let d=0,f=0,p=0;for(const h of l)try{const m=K(h,"utf8");let y;try{y=bv(m,s)}catch(S){or(`${h}: ${Sn(S)}`),p++;continue}const b=m.endsWith(`
|
|
819
|
+
`)?m:`${m}
|
|
820
|
+
`,x=y.endsWith(`
|
|
821
|
+
`)?y:`${y}
|
|
822
|
+
`;if(b===x){f++;continue}d++,o?ae(`${h} is not sorted`):(H(h,x,"utf8"),Q(`Sorted ${h}`))}catch(m){or(`${h}: ${Sn(m)}`),p++}if(o)d>0?(k(`${d} file${d===1?"":"s"} not sorted, ${f} already sorted`),process.exitCode=1):k(`All ${f} package.json file${f===1?" is":"s are"} sorted`);else{const h=[];d>0&&h.push(`sorted ${d} file${d===1?"":"s"}`),f>0&&h.push(`${f} already sorted`),p>0&&h.push(`${p} error${p===1?"":"s"}`),k(h.join(", "))}p>0&&(process.exitCode=1)},"execute"),name:"sort-package-json",options:[{alias:"c",defaultValue:!1,description:"Check if package.json files are sorted without writing (exits 1 if unsorted)",name:"check",type:Boolean},{defaultValue:!1,description:"Also sort the scripts field alphabetically",name:"sort-scripts",type:Boolean}]};var xv=Object.defineProperty,Oa=$((t,e)=>xv(t,"name",{value:e,configurable:!0}),"s$3");const Sv=Oa((t,e)=>{const r=[["allow-empty","allowEmpty"],["continue-on-error","continueOnError"],["cwd","cwd"],["debug","debug"],["diff","diff"],["diff-filter","diffFilter"],["fail-on-changes","failOnChanges"],["hide-partially-staged","hidePartiallyStaged"],["hide-unstaged","hideUnstaged"],["quiet","quiet"],["relative","relative"],["revert","revert"],["stash","stash"],["verbose","verbose"]];for(const[n,i]of r)t[n]!==void 0&&(e[i]=t[n]);if(t.concurrent!==void 0){const n=t.concurrent;if(n==="true")e.concurrent=!0;else if(n==="false")e.concurrent=!1;else{const i=Number(n);e.concurrent=Number.isNaN(i)||n===""?!0:i}}},"mapOptions"),Cv={group:"Run & Execute",description:"Run linters on staged files using config from vis.config.ts",examples:[["vis staged","Run staged linters"],["vis staged --verbose","Run with verbose output"],["vis staged --no-stash","Run without backup stash"],["vis staged --diff HEAD~1","Run against a specific diff"]],execute:Oa(async({options:t,visConfig:e})=>{const r=(e??{}).staged;if(!r)throw new Error(`No "staged" config found in vis.config.ts. Please add a staged config:
|
|
132
823
|
|
|
133
824
|
// vis.config.ts
|
|
134
825
|
import { defineConfig } from "@visulima/vis/config";
|
|
135
826
|
|
|
136
827
|
export default defineConfig({
|
|
137
828
|
staged: { '*': 'vis check --fix' },
|
|
138
|
-
});`);let n;try{n=(await import("lint-staged")).default}catch{throw new Error("lint-staged is required but not installed. Run: pnpm add -D lint-staged")}const
|
|
139
|
-
`)
|
|
140
|
-
`):
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
`);
|
|
145
|
-
`)}
|
|
146
|
-
|
|
147
|
-
|
|
829
|
+
});`);let n;try{n=(await import("lint-staged")).default}catch{throw new Error("lint-staged is required but not installed. Run: pnpm add -D lint-staged")}const i={config:r};Sv(t,i);const o=await n(i);process.exit(o?0:1)},"execute"),name:"staged",options:[{defaultValue:!1,description:"Allow empty commits when tasks revert all staged changes",name:"allow-empty",type:Boolean},{description:"Number of concurrent tasks or false for serial",name:"concurrent",type:String},{defaultValue:!1,description:"Run all tasks to completion even if one fails",name:"continue-on-error",type:Boolean},{description:"Working directory to run all tasks in",name:"cwd",type:String},{defaultValue:!1,description:"Enable debug output",name:"debug",type:Boolean},{description:"Override the default --staged flag of git diff",name:"diff",type:String},{description:"Override the default diff-filter",name:"diff-filter",type:String},{defaultValue:!1,description:"Fail with exit code 1 when tasks modify tracked files",name:"fail-on-changes",type:Boolean},{defaultValue:!1,description:"Hide unstaged changes from partially staged files",name:"hide-partially-staged",type:Boolean},{defaultValue:!1,description:"Hide all unstaged changes before running tasks",name:"hide-unstaged",type:Boolean},{defaultValue:!1,description:"Suppress console output",name:"quiet",type:Boolean},{defaultValue:!1,description:"Pass filepaths relative to cwd to tasks",name:"relative",type:Boolean},{defaultValue:!1,description:"Revert to original state in case of errors",name:"revert",type:Boolean},{defaultValue:!0,description:"Enable backup stash",name:"stash",type:Boolean},{defaultValue:!1,description:"Show task output even when tasks succeed",name:"verbose",type:Boolean}]};var Ev=Object.defineProperty,jv=$((t,e)=>Ev(t,"name",{value:e,configurable:!0}),"c$2");const Tv={group:"Dependencies",argument:{description:"Packages to unlink (omit for current package)",name:"packages",type:String},description:"Unlink a previously linked package",examples:[["vis unlink","Unlink current package"],["vis unlink react","Unlink specific package"],["vis unlink -r","Unlink in all workspace packages"]],execute:jv(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t||[],o=n??process.cwd(),s=me(o),l=Jc(s,i,r.recursive||!1,o,e);l!==0&&(process.exitCode=l)},"execute"),name:"unlink",options:[{alias:"r",defaultValue:!1,description:"Unlink in all workspace packages",name:"recursive",type:Boolean}]};var Av=Object.defineProperty,qt=$((t,e)=>Av(t,"name",{value:e,configurable:!0}),"s$2");const Iv=qt(t=>{const e=[];for(const r of t.filters)e.push("--filter",r);return t.workspaceRoot&&e.push("--filter","."),e.push("update"),t.latest&&e.push("--latest"),t.recursive&&e.push("--recursive"),t.interactive&&e.push("--interactive"),t.dev&&e.push("--dev"),t.prod&&e.push("--prod"),t.noOptional&&e.push("--no-optional"),t.noSave&&e.push("--no-save"),e.push(...t.packages),{args:e,bin:"pnpm"}},"resolvePnpm"),Rv=qt(t=>{const e=[];return t.filters.length>0&&e.push("workspace",t.filters[0]),e.push("upgrade"),t.latest&&e.push("--latest"),e.push(...t.packages),{args:e,bin:"yarn"}},"resolveYarnV1"),Ov=qt(t=>{const e=[];if(t.filters.length>0||t.recursive){e.push("workspaces","foreach","--all");for(const r of t.filters)e.push("--include",r)}return e.push("up"),t.interactive&&e.push("--interactive"),e.push(...t.packages),{args:e,bin:"yarn"}},"resolveYarnBerry"),Pv=qt((t,e)=>{const r=["update"];t.latest&&e.push("npm does not support --latest flag. Packages will be updated within their semver range."),t.interactive&&e.push("npm does not support --interactive mode.");for(const n of t.filters)r.push("--workspace",n);return t.recursive&&r.push("--workspaces"),t.workspaceRoot&&r.push("--include-workspace-root"),t.dev&&r.push("--dev"),t.prod&&r.push("--production"),t.noOptional&&r.push("--no-optional"),t.noSave&&r.push("--no-save"),r.push(...t.packages),{args:r,bin:"npm"}},"resolveNpm"),Nv=qt(t=>{const e=["update"];t.latest&&e.push("--latest");for(const r of t.filters)e.push("--filter",r);return e.push(...t.packages),{args:e,bin:"bun"}},"resolveBun"),Dv=qt((t,e,r)=>{const n=[];if(r.global)return{command:{args:["update","--global",...r.packages],bin:"npm"},warnings:n};let i;switch(t){case"bun":{i=Nv(r);break}case"npm":{i=Pv(r,n);break}case"pnpm":{i=Iv(r);break}case"yarn":{i=e.startsWith("1.")?Rv(r):Ov(r);break}default:{const o=t;throw new Error(`Unsupported package manager: ${String(o)}`)}}return{command:i,warnings:n}},"resolveUpdateCommand");var Mv=Object.defineProperty,kt=$((t,e)=>Mv(t,"name",{value:e,configurable:!0}),"w");const Bv=kt((t,e)=>{try{if(e==="pnpm"){const r=T(t,"pnpm-workspace.yaml");if(le(r)){const n=Kr(r);if(typeof n?.minimumReleaseAge=="number")return n.minimumReleaseAge}}else if(e==="bun"){const r=T(t,"package.json");if(le(r)){const n=Ue(r);if(typeof n.minimumReleaseAge=="number")return n.minimumReleaseAge}}}catch{}},"readPmNativeMinimumReleaseAge"),Lv=kt((t,e,r)=>{const n=t.latest?"latest":t.target??e.target??"latest";if(!["latest","minor","patch"].includes(n))throw new Error(`Invalid target "${n}". Use: latest, minor, or patch.`);return{exclude:[...Me(t.exclude),...Me(e.exclude)],ignore:Me(e.ignore),include:[...Me(t.include),...Me(e.include),...r],includeLocked:t.includeLocked||e.includeLocked||!1,includePrerelease:t.prerelease||e.prerelease||!1,minimumReleaseAge:e.minimumReleaseAge,minimumReleaseAgeExclude:e.minimumReleaseAgeExclude,packageMode:e.packageMode,security:t.security||t.ai||e.security||!1,target:n}},"buildCatalogCheckOptions"),bi=kt((t,e)=>{if(t.length!==0){e.info(`
|
|
830
|
+
${Ie("⚠")} ${String(t.length)} package${t.length===1?"":"s"} skipped by target constraint (use --target latest to include):`);for(const r of t)e.info(` ${r.packageName} ${r.currentRange} → ${r.newRange} (${r.updateType})`)}},"logFilteredByTarget"),$i=kt((t,e,r,n)=>{r==="json"?process.stdout.write(`${Bu({checkedCount:0,failed:e,filteredByTarget:[],ignored:[],outdated:t})}
|
|
831
|
+
`):r==="minimal"?process.stdout.write(`${js(t)}
|
|
832
|
+
`):(Ts(t,n),n.info(Lr(t)))},"writeFormattedOutput"),xi=kt(async(t,e,r,n,i)=>{const o=Hu(t,r,e),s=e==="pnpm"?"pnpm-workspace.yaml":"package.json";if(i.info(`
|
|
833
|
+
Updated ${s}`),o&&i.info(`Backup saved to ${o}`),n.changelog){i.info(`
|
|
834
|
+
Fetching changelogs...`);const l=await As(r);for(const d of l){const f=d.releaseUrl??d.repoUrl??d.npmUrl;i.info(` ${d.packageName}: ${f}`)}}if(n.install??!0){const l={bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}[e]??`${e} install`;i.info(`Running ${l}...
|
|
835
|
+
`);try{Xr(l,{cwd:t,env:process.env,stdio:"inherit"})}catch{i.warn(`${l} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),Fv=kt(async(t,e,r,n,i,o)=>{const s=r.update??{},l=[["global","--global is not supported in catalog mode"],["recursive","--recursive is not needed in catalog mode (catalogs are workspace-level)"],["filter","--filter is not supported in catalog mode (use --include/--exclude instead)"],["no-save","--no-save is not supported in catalog mode"],["workspace-root","--workspace-root is not needed in catalog mode"],["no-optional","--no-optional is not supported in catalog mode"]];for(const[z,Z]of l)n[z]&&o.warn(`${Ie("⚠")} ${Z}, ignoring.`);const d=Bv(t,e),f=s.minimumReleaseAge??d;if(s.minimumReleaseAge!==void 0&&d!==void 0&&s.minimumReleaseAge!==d){const z=e==="pnpm"?"pnpm-workspace.yaml":"package.json";o.warn(`${Ie("⚠")} minimumReleaseAge mismatch: vis config = ${String(s.minimumReleaseAge)} min, ${z} = ${String(d)} min. Consider keeping them in sync.`)}const p=ro(t),h=on(t,e,{depFields:s.depFields,dev:n.dev,prod:n.prod});if(h.size===0){o.info("No catalogs found.");return}const m={...s,minimumReleaseAge:f},y=Lv(n,m,i);let b=0;for(const z of h.values())b+=z.size;const x=!!process.stdout.isTTY&&!Ge;let S;const C=x?(z,Z)=>{S?S.rerender(_.createElement(sr,{current:z,total:Z})):S=dt(_.createElement(sr,{current:z,total:Z}),{interactive:!0,patchConsole:!1})}:(z,Z)=>{o.info(`Checking ${String(z)}/${String(Z)} dependencies...`)};x||o.info(`Checking ${String(b)} catalog dependencies...
|
|
836
|
+
`);const D=It(r.security?.socket),{checkedCount:P,failed:M,filteredByTarget:E,ignored:R,outdated:A}=await no(h,y,p,C,t,D,r.security?.socket?.acceptedRisks);S&&(S.clear(),S.unmount());const G=P-A.length-M.length;if(M.length>0&&o.warn(`Failed to fetch: ${M.join(", ")}`),R.length>0&&o.info(`Skipped ${String(R.length)} ignored package${R.length===1?"":"s"}: ${R.join(", ")}`),!x&&P>A.length){const z=[...h.values()].reduce((he,oe)=>he+oe.size,0),Z=z>P?` (${String(z)} catalog entries, ${String(z-P)} duplicates)`:"";o.info(`Checked ${String(P)} unique packages${Z}: ${String(A.length)} outdated, ${String(G)} up-to-date`+(M.length>0?`, ${String(M.length)} failed`:"")+(E.length>0?`, ${String(E.length)} skipped by target`:""))}if(A.length===0){E.length>0?o.info(`All catalog dependencies are up to date within the current target.
|
|
837
|
+
${String(E.length)} package${E.length===1?" has":"s have"} newer versions available with --target latest:
|
|
838
|
+
${E.map(z=>` ${z.packageName} ${z.currentRange} → ${z.newRange} (${z.updateType})`).join(`
|
|
839
|
+
`)}`):o.info("All catalog dependencies are up to date.");return}const B=n.format??s.format??"table";let w;if(n.ai){const z=Qn(n.aiType??"impact");w=await Zn(A,o,r.ai,z)}const v=!!n.dryRun;if(x&&B==="table"){const z=new Bs(A,w??null);let Z;if(n.changelog){o.info("Fetching changelogs...");const O=await As(A);Z=new Map;for(const I of O){const Y=I.releaseUrl??I.repoUrl??I.npmUrl;Y&&Z.set(I.packageName,Y)}}const he=r.tui?.autoExit??!1,oe=he===!0?3:typeof he=="number"?he:0,Te=await dt(_.createElement(Ls,{autoExitSeconds:oe,changelogUrls:Z,checkedCount:P,filteredOutEntries:E,isDryRun:v,store:z,totalCatalogEntries:b}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),ke=process.stdout.columns||80;process.stdout.write(`
|
|
840
|
+
`);for(const O of A){const I=O.vulnerabilities?.length||O.socketReport&&O.socketReport.alerts.length>0,Y=!!O.acceptedRisk,ye=I?Y?"✓":"⚠":"✓",Ae=Y?"gray":O.updateType==="major"?"red":O.updateType==="minor"?"yellow":"green",Ce=O.socketReport?.score.overall,it=Ce===void 0?"":` [${String(Math.round(Ce*100))}%]`,J=Ce===void 0?void 0:fr(Ce);process.stdout.write(`${ge(_.createElement(a,null," ",_.createElement(a,{color:Ae},ye),` ${O.packageName} ${O.currentRange} → ${O.newRange}`,_.createElement(a,{dimColor:!0},` ${O.updateType}`),J?_.createElement(a,{color:J},it):null),{columns:ke})}
|
|
841
|
+
`)}if(process.stdout.write(`
|
|
842
|
+
`),o.info(Lr(A)),P>A.length){const O=[...h.values()].reduce((Y,ye)=>Y+ye.size,0),I=O>P?` (${String(O)} catalog entries, ${String(O-P)} duplicates)`:"";o.info(` Checked ${String(P)} unique packages${I}: ${String(G)} up-to-date`+(M.length>0?`, ${String(M.length)} failed`:""))}if(E.length>0){process.stdout.write(`
|
|
843
|
+
`);const O=`${String(E.length)} package${E.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${ge(_.createElement(a,{color:"yellow"},` ${O}`),{columns:ke})}
|
|
844
|
+
`);for(const I of E)process.stdout.write(`${ge(_.createElement(a,null," ",_.createElement(a,{dimColor:!0},I.packageName),` ${I.currentRange} → ${I.newRange}`,_.createElement(a,{dimColor:!0},` ${I.updateType}`)),{columns:ke})}
|
|
845
|
+
`)}const Se=Array.isArray(Te)?Te:[];if(Se.length>0&&!v){o.info(`
|
|
846
|
+
Applying ${String(Se.length)} updates...
|
|
847
|
+
`);const O={...n,install:n.install??s.install};await xi(t,e,Se,O,o)}return}if(v){if(B==="json"){const z={failed:M,filteredByTarget:E,ignored:R,outdated:A};w&&(z.aiAnalysis=w),process.stdout.write(`${JSON.stringify(z,void 0,2)}
|
|
848
|
+
`)}else o.info(`Would update ${String(A.length)} dependencies:
|
|
849
|
+
`),$i(A,M,B,o),w&&(o.info(""),o.info(Br(w))),bi(E,o);return}w&&B!=="json"&&(o.info(Br(w)),o.info(""));let j=A;if(n.interactive&&(j=await Ju(A),j.length===0)){o.info("No updates selected.");return}o.info(`Updating ${String(j.length)} catalog dependencies...
|
|
850
|
+
`),$i(j,[],B,o),bi(E,o);const U={...n,install:n.install??s.install};await xi(t,e,j,U,o)},"executeCatalogUpdate"),Vv=kt((t,e,r,n,i,o)=>{const s={dev:n.dev,filters:Me(n.filter),global:n.global,interactive:n.interactive,latest:n.latest||n.target==="latest",noOptional:n.noOptional,noSave:n.noSave,packages:i,prod:n.prod,recursive:n.recursive,workspaceRoot:n.workspaceRoot},{command:l,warnings:d}=Dv(e,r,s);for(const p of d)o.warn(p);const f=`${l.bin} ${l.args.join(" ")}`.trim();if(n.dryRun){o.info(`Would run: ${f}`);return}o.info(`Running: ${f}`);try{Xr(f,{cwd:t,env:process.env,stdio:"inherit"})}catch(p){const h=p.status??1;o.error(`
|
|
851
|
+
${ct("✖")} Update failed (exit code ${String(h)})`),o.error(` Command: ${f}`),o.error(` Directory: ${t}
|
|
852
|
+
`),process.exitCode=h}},"executePmWrapper"),Uv={group:"Dependencies",alias:"up",argument:{description:"Packages to update (updates all if omitted)",name:"packages",type:String},description:"Update packages to their latest versions",examples:[["vis update react","Update react within semver range"],["vis up react -L","Update react to latest"],["vis update -i","Interactive mode"],["vis update --filter app","Update in specific workspace"],["vis update -r","Update in all workspaces"],["vis update --target minor","Only apply minor/patch updates (catalog mode)"],["vis update --dry-run","Preview changes without applying"],["vis update --exclude '@types/*'","Exclude packages by pattern"],["vis update --changelog","Show changelog links after updating"],["vis update --rollback","Restore catalog from last backup"],["vis update --ai","Run AI analysis before applying updates"]],execute:kt(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");let o=t;const s=i,{packageManager:l}=Jr(s);if(!r.noTyposquatCheck){if(o.length>0){const d=o.map(h=>qn(h)),f=n?.security?.typosquatAllowlist,p=await Qi(d.map(h=>h.name),f);if(!p.ok){process.exitCode=1;return}o=d.map((h,m)=>{const y=p.packages[m];return y!==h.name?h.versionSpec?`${y}@${h.versionSpec}`:y:o[m]})}else if(!await Zi(s,n?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(r.rollback){if(!Mu(s,l)){e.info("No backup found. Run 'vis update' first to create a backup.");return}if(Du(s,l))e.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(!r.noCatalog&&mu(s,l))await Fv(s,l,n??{},r,o,e);else{const d=Ha(l);Vv(s,l,d,r,o,e)}},"execute"),name:"update",options:[{alias:"L",defaultValue:!1,description:"Update to latest version (ignore semver range)",name:"latest",type:Boolean},{alias:"t",description:"Update target: latest, minor, or patch (default: latest, catalog mode)",name:"target",type:String},{alias:"d",defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean},{alias:"g",defaultValue:!1,description:"Update global packages",name:"global",type:Boolean},{alias:"r",defaultValue:!1,description:"Update recursively in all workspace packages",name:"recursive",type:Boolean},{description:"Filter packages in monorepo",name:"filter",type:String},{alias:"w",defaultValue:!1,description:"Include workspace root",name:"workspace-root",type:Boolean},{alias:"D",defaultValue:!1,description:"Update only devDependencies",name:"dev",type:Boolean},{alias:"P",defaultValue:!1,description:"Update only dependencies",name:"prod",type:Boolean},{alias:"i",defaultValue:!1,description:"Interactive mode",name:"interactive",type:Boolean},{defaultValue:!1,description:"Don't update optionalDependencies",name:"no-optional",type:Boolean},{alias:"l",defaultValue:!1,description:"Include packages with pinned/exact versions (no ^ or ~ prefix)",name:"include-locked",type:Boolean},{defaultValue:!1,description:"Update lockfile only",name:"no-save",type:Boolean},{description:"Glob pattern to include packages (repeatable, catalog mode)",lazyMultiple:!0,name:"include",type:String},{description:"Glob pattern to exclude packages (repeatable, catalog mode)",lazyMultiple:!0,name:"exclude",type:String},{defaultValue:!1,description:"Include prerelease versions (catalog mode)",name:"prerelease",type:Boolean},{defaultValue:!1,description:"Check for known security vulnerabilities (via OSV.dev)",name:"security",type:Boolean},{defaultValue:!1,description:"Skip catalog mode, use package manager directly",name:"no-catalog",type:Boolean},{description:"Output format: table, json, or minimal (default: table)",name:"format",type:String},{defaultValue:!1,description:"Show changelog URLs for updated packages",name:"changelog",type:Boolean},{description:"Run install after catalog update, --no-install to skip (default: true)",name:"install",type:Boolean},{defaultValue:!1,description:"Restore catalog file from the last backup",name:"rollback",type:Boolean},{defaultValue:!1,description:"Run AI analysis on outdated packages before updating (catalog mode)",name:"ai",type:Boolean},{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",name:"ai-type",type:String},{defaultValue:!1,description:"Skip typosquat name check for package arguments",name:"no-typosquat-check",type:Boolean}]};var Gv=Object.defineProperty,zv=$((t,e)=>Gv(t,"name",{value:e,configurable:!0}),"o$1");const Wv={group:"System",argument:{description:"Target version (defaults to latest)",name:"version",type:String},description:"Update vis itself to the latest version",examples:[["vis self-update","Update to latest"],["vis self-update 2.0.0","Install specific version"],["vis self-update --check","Check for updates without installing"]],execute:zv(async({argument:t,logger:e,options:r})=>{const n=t?.[0];e.info("info: checking for updates...");let i;try{i=require("../../package.json").version}catch{i="unknown"}let o;try{const s=Xr("npm view @visulima/vis version",{encoding:"utf8"}).trim();o=n??s}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(i===o&&!r.force){e.info(`
|
|
853
|
+
✓ Already up to date (${i})`);return}if(r.check){i===o?e.info(`✓ Already up to date (${i})`):e.info(`info: found @visulima/vis@${o} (current: ${i})`);return}if(e.info(`info: found @visulima/vis@${o} (current: ${i})`),e.info("info: installing..."),Le("npm",["install","-g",`@visulima/vis@${o}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
|
|
854
|
+
✓ Updated @visulima/vis from ${i} → ${o}`)},"execute"),name:"self-update",options:[{defaultValue:!1,description:"Check for updates without installing",name:"check",type:Boolean},{defaultValue:!1,description:"Reinstall even if already current",name:"force",type:Boolean},{defaultValue:!1,description:"Suppress output (CI mode)",name:"silent",type:Boolean}]};var _v=Object.defineProperty,Hv=$((t,e)=>_v(t,"name",{value:e,configurable:!0}),"t$1");const Jv={group:"Dependencies",alias:"explain",argument:{description:"Package(s) to explain",name:"packages",type:String},description:"Show why a package is installed (dependency chain)",examples:[["vis why react","Show why react is installed"],["vis why react --json","Output as JSON"],["vis why react -r","Check across all workspaces"],["vis explain react","Alias matching npm's command"]],execute:Hv(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t;if(!i||i.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const o=n??process.cwd(),s=me(o),l=_c(s,{depth:r.depth===void 0?void 0:Number(r.depth),dev:r.dev||!1,filter:gr(r.filter),global:r.global||!1,json:r.json||!1,long:r.long||!1,noOptional:r.noOptional||!1,packages:i,parseable:r.parseable||!1,prod:r.prod||!1,recursive:r.recursive||!1},o,e);l!==0&&l!==1&&(process.exitCode=l)},"execute"),name:"why",options:[{defaultValue:!1,description:"Output as JSON",name:"json",type:Boolean},{defaultValue:!1,description:"Show extended information (pnpm)",name:"long",type:Boolean},{defaultValue:!1,description:"Machine-readable output (pnpm)",name:"parseable",type:Boolean},{alias:"r",defaultValue:!1,description:"Check across all workspaces",name:"recursive",type:Boolean},{alias:"D",defaultValue:!1,description:"Filter to dev dependencies (pnpm)",name:"dev",type:Boolean},{alias:"P",defaultValue:!1,description:"Filter to production dependencies (pnpm)",name:"prod",type:Boolean},{defaultValue:!1,description:"Exclude optional dependencies (pnpm)",name:"no-optional",type:Boolean},{alias:"g",defaultValue:!1,description:"Check globally installed packages (pnpm)",name:"global",type:Boolean},{description:"Limit dependency tree depth",name:"depth",type:Number},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String}]};var qv=Object.defineProperty,Yv=$((t,e)=>qv(t,"name",{value:e,configurable:!0}),"d");const Xv={beforeCommand:Yv(async t=>{try{const e=t.options?.cwd;let r;r=e?(await import("node:path")).resolve(process.cwd(),e):Ti(process.cwd()).path,t.workspaceRoot=r;try{t.visConfig=await Co(r)}catch(i){const o=nr(r);if(o){const s=i instanceof Error?i.message:String(i);if(t.logger.error(""),t.logger.error(ct(bo(`✖ Failed to load ${o}`))),t.logger.error(` ${s}`),t.logger.error(""),s.includes("Cannot find module")){const l=/Cannot find module '([^']+)'/.exec(s)?.[1]??"unknown";t.logger.error(`${Ie("→ Hint:")} The module ${bo(l)} could not be resolved.`),l.includes("@visulima/vis")?(t.logger.error(" This usually means the package isn't installed or the export path changed."),t.logger.error(` Try: ${$t("pnpm add @visulima/vis")}`),t.logger.error(` Or regenerate: ${$t("vis init --force")}`)):t.logger.error(` Try: ${$t(`pnpm add ${l}`)}`)}else s.includes("SyntaxError")||s.includes("Unexpected token")?(t.logger.error(`${Ie("→ Hint:")} The config file has a syntax error.`),t.logger.error(" Check your config for typos or invalid syntax."),t.logger.error(` Or regenerate: ${$t("vis init --force")}`)):(t.logger.error(`${Ie("→ Hint:")} Delete the broken config and recreate it:`),t.logger.error(` ${$t(`rm ${o} && vis init`)}`));t.logger.error(""),t.logger.error(` Continuing with default settings.
|
|
855
|
+
`)}t.visConfig={}}const n=process.argv[2]??"";if(!new Set(["--help","--version","-h","-V","create","help","implode","init"]).has(n)&&!nr(r)&&!Ge)if(process.stdin.isTTY){const{createInterface:i}=await import("node:readline"),o=i({input:process.stdin,output:process.stderr}),s=await new Promise(l=>{o.question("\x1B[36;1m?\x1B[0m \x1B[1mNo vis.config.ts found. Create one with best-practice security defaults?\x1B[0m \x1B[90m(\x1B[92mY\x1B[90m/n)\x1B[0m ",l),o.on("SIGINT",()=>{o.close(),l("n")})});if(o.close(),!s.trim()||s.trim().toLowerCase()==="y"||s.trim().toLowerCase()==="yes"){const{writeFileSync:l}=await import("node:fs"),{join:d}=await import("node:path"),f=d(r,"vis.config.mjs"),p=['import { defineConfig } from "@visulima/vis/config";',"","// Secure defaults are applied automatically by defineConfig().","// You only need to add allowBuilds for packages with build scripts.","// Run 'vis check --security-config' to see all active settings.","export default defineConfig({"," security: {"," allowBuilds: {",' // "esbuild": true,'," },"," },","});",""].join(`
|
|
856
|
+
`);l(f,p),t.logger.info(`✓ Created ${f}
|
|
857
|
+
`),t.visConfig=await Co(r)}}else t.logger.warn("No vis.config.ts found. Run 'vis init' to create one with best-practice security defaults.")}catch(e){e instanceof Error&&!e.message.includes("monorepo root")&&t.logger.warn(`Failed to detect workspace: ${e.message}`),t.visConfig={}}},"beforeCommand"),name:"config-loader"};var Kv=Object.defineProperty,ie=$((t,e)=>Kv(t,"name",{value:e,configurable:!0}),"s$1");const Si=300*1e3,On=L(Oe(),".vis",".tip-state.json"),Qv=ie(()=>{try{if(F(On))return JSON.parse(K(On,"utf8"))}catch{}return{lastGlobal:0,perTip:{}}},"readState"),Zv=ie(t=>{try{const e=L(Oe(),".vis");$e(e,{recursive:!0}),H(On,JSON.stringify(t))}catch{}},"writeState"),ew=[{cooldownMs:1800*1e3,id:"short-aliases",matches:ie(t=>["install","link","remove","uninstall","update"].includes(t.command),"matches"),message:ie(t=>{const e={install:"i",link:"ln",remove:"rm",uninstall:"rm",update:"up"}[t.command];return e?`You can use 'vis ${e}' as a shorthand for 'vis ${t.command}'`:""},"message"),probability:.5},{id:"use-exec",matches:ie(t=>t.command==="dlx"&&t.success,"matches"),message:ie(()=>"Use 'vis exec' to run locally installed binaries without downloading.","message")},{id:"security-check",matches:ie(t=>(t.command==="check"||t.command==="update")&&t.success&&!t.args.includes("--security"),"matches"),message:ie(()=>"Add --security to check for known vulnerabilities via OSV.dev","message"),probability:.3},{cooldownMs:3600*1e3,id:"ai-analysis",matches:ie(t=>(t.command==="check"||t.command==="update")&&t.success&&!t.args.includes("--ai"),"matches"),message:ie(()=>"Add --ai to run AI analysis on outdated packages before updating.","message"),probability:.2},{cooldownMs:1440*60*1e3,id:"socket-security",matches:ie(t=>(t.command==="install"||t.command==="update"||t.command==="check")&&t.success,"matches"),message:ie(()=>"Enable Socket.dev in vis.config.ts for security scores and supply chain alerts: security.socket.enabled = true","message"),probability:.15},{id:"dedupe-after-install",matches:ie(t=>t.command==="install"&&t.success,"matches"),message:ie(()=>"Run 'vis dedupe' periodically to remove duplicate dependencies.","message"),probability:.15},{cooldownMs:720*60*1e3,id:"doctor-checkup",matches:ie(t=>(t.command==="install"||t.command==="add"||t.command==="update")&&t.success,"matches"),message:ie(()=>"Run 'vis doctor' for a full project health check — outdated, security, duplicates, and optimizations in one view.","message"),probability:.25},{cooldownMs:10080*60*1e3,id:"init-config",matches:ie(t=>(t.command==="install"||t.command==="run")&&t.success&&!t.hasVisConfig,"matches"),message:ie(()=>"Run 'vis init' to create a vis.config.ts with secure defaults — supply chain protection enabled automatically.","message"),probability:.4},{id:"why-command",matches:ie(t=>t.command==="outdated"&&t.success,"matches"),message:ie(()=>"Use 'vis why <package>' to understand why a dependency is installed.","message"),probability:.3},{id:"graph-command",matches:ie(t=>t.command==="run"&&t.success,"matches"),message:ie(()=>"Use 'vis graph' to visualize your project dependency graph.","message"),probability:.1},{id:"affected-command",matches:ie(t=>t.command==="run"&&t.success&&!t.args.includes("--projects"),"matches"),message:ie(()=>"Use 'vis affected <target>' to run tasks only on changed projects.","message"),probability:.2},{id:"pm-cache",matches:ie(t=>t.command==="install"&&t.success,"matches"),message:ie(()=>"Use 'vis pm cache dir' to find your package manager's cache location.","message"),probability:.1},{id:"create-editor",matches:ie(t=>t.command==="create"&&t.success,"matches"),message:ie(()=>"Add --editor vscode to generate VS Code configuration during project creation.","message"),probability:.5},{id:"env-pin",matches:ie(t=>t.command==="env"&&t.args.includes("install")&&t.success,"matches"),message:ie(()=>"Use 'vis env pin <version>' to pin the Node.js version for your project.","message"),probability:.5},{id:"upgrade-check",matches:ie(t=>t.command!=="self-update"&&t.success,"matches"),message:ie(()=>"Run 'vis self-update --check' to see if a newer version of vis is available.","message"),probability:.05}],tw=ie(t=>{if(process.env.VIS_CLI_TEST||Ge)return;const e=Date.now(),r=Qv();if(e-r.lastGlobal<Si)return;const n=ew.filter(s=>{if(!s.matches(t))return!1;const l=r.perTip[s.id]??0,d=s.cooldownMs??Si;return e-l>=d});if(n.length===0)return;const i=n.find(s=>{const l=s.probability??1;return Math.random()<l});if(!i)return;const o=i.message(t);o&&(process.stderr.write(`
|
|
858
|
+
\x1B[2mtip: ${o}\x1B[0m
|
|
859
|
+
`),r.lastGlobal=e,r.perTip[i.id]=e,Zv(r))},"showTip");var rw=Object.defineProperty,Ci=$((t,e)=>rw(t,"name",{value:e,configurable:!0}),"o");const nw=Ci(t=>({afterCommand:Ci(async e=>{const r=process.argv.slice(2),n=r[0]??"";t&&t(),tw({args:r,command:n,hasVisConfig:e.visConfig!==void 0&&Object.keys(e.visConfig).length>0,success:process.exitCode===void 0||process.exitCode===0})},"afterCommand"),name:"post-command"}),"postCommandPlugin");var ow=Object.defineProperty,Pn=$((t,e)=>ow(t,"name",{value:e,configurable:!0}),"f");const Ei=new Set(["add","install","update"]),iw=new Set(["add","dedupe","install","remove","update"]),sw=/(\d+\.\d+\.\d+)/,aw=Pn(t=>{const e=T(t,"package.json");if(!F(e))return[];const r=[];try{const n=JSON.parse(K(e,"utf8")),i={...n.dependencies,...n.devDependencies};for(const[o,s]of Object.entries(i)){const l=T(t,"node_modules",o,"package.json");if(F(l))try{const f=JSON.parse(K(l,"utf8"));if(f.version){r.push({name:o,version:f.version});continue}}catch{}const d=sw.exec(s);d&&r.push({name:o,version:d[1]})}}catch{}return r},"resolveInstalledPackages"),cw={afterCommand:Pn(async t=>{if(process.exitCode&&process.exitCode!==0)return;const e=t.scriptEnforcement;e?.postInstallPackages.length&&t.workspaceRoot&&ip(t.workspaceRoot,e.postInstallPackages);const r=process.argv[2]??"",n=It(t.visConfig?.security?.socket);if(Ei.has(r)&&n&&t.workspaceRoot)try{const i=aw(t.workspaceRoot);if(i.length>0){const o=await Wt(i,n);if(o.size>0){const s=il(o);if(s){k(""),k(s);let l=0;for(const d of o.values())for(const f of d.alerts)(f.severity==="critical"||f.severity==="high")&&l++;l>0&&ae(`${String(l)} critical/high severity alert${l===1?"":"s"} detected. Run 'vis check --security' for details.`)}}}}catch{}},"afterCommand"),beforeCommand:Pn(async t=>{const e=process.argv[2]??"";if(iw.has(e)&&t.visConfig&&t.workspaceRoot){const r=me(t.workspaceRoot);if(ep(t.visConfig,r.name),Ei.has(e)){const n=np(r.name,t.workspaceRoot,t.visConfig);for(const i of n.warnings)t.logger.warn(`security: ${i}`);t.scriptEnforcement=n}}},"beforeCommand"),name:"security-enforcement"};var lw=Object.defineProperty,pt=$((t,e)=>lw(t,"name",{value:e,configurable:!0}),"s");const Nn=L(Oe(),".vis"),Dn=L(Nn,".upgrade-check.json"),dw=1440*60*1e3,uw=1440*60*1e3,pw=500,fw=new Set(["--help","--version","-h","-V","help","implode","self-update","upgrade"]),gw=pt(()=>{try{if(F(Dn))return JSON.parse(K(Dn,"utf8"))}catch{}},"readCache"),Pa=pt(t=>{try{F(Nn)||$e(Nn,{recursive:!0}),H(Dn,JSON.stringify(t))}catch{}},"writeCache"),hw=pt(async t=>{try{const e=new AbortController,r=setTimeout(()=>{e.abort()},pw),n=await fetch(`https://registry.npmjs.org/${t}/latest`,{headers:{accept:"application/json"},signal:e.signal});return clearTimeout(r),n.ok?(await n.json()).version:void 0}catch{return}},"fetchLatestVersion"),mw=pt((t,e)=>{const r=pt(o=>o.replace(/^v/,"").split("-")[0].split(".").map(Number),"parseSemver"),n=r(t),i=r(e);for(let o=0;o<3;o++){if((i[o]??0)>(n[o]??0))return!0;if((i[o]??0)<(n[o]??0))return!1}return!1},"isNewerVersion"),ji=pt((t,e)=>{if(!mw(t,e.latestVersion))return;const r=Date.now();r-e.lastNoticeAt<uw||(process.stderr.write(`
|
|
860
|
+
${re("vis update available:")} ${_i(t)} ${re(Gn.arrow)} ${Wi(pe(e.latestVersion))}${re(", run")} ${Pe("vis upgrade")}
|
|
861
|
+
`),e.lastNoticeAt=r,Pa(e))},"showUpgradeNotice"),yw=pt(t=>{if(Ge||process.env.VIS_CLI_TEST||process.env.VIS_NO_UPDATE_CHECK==="1"||!process.stderr.isTTY||fw.has(t))return!1;const e=new Set(process.argv.slice(2));return!(e.has("--silent")||e.has("-s")||e.has("--json"))},"shouldCheck"),vw=pt((t,e)=>{if(!yw(e))return;const r=gw(),n=Date.now();if(r&&n-r.lastQueryAt<dw)return()=>{ji(t,r)};let i=r;return hw("@visulima/vis").then(o=>{o&&(i={lastNoticeAt:r?.lastNoticeAt??0,lastQueryAt:n,latestVersion:o},Pa(i))}).catch(()=>{}),()=>{i&&ji(t,i)}},"startUpgradeCheck");za();Nc();try{const t=Ti(process.cwd()).path,e=Ue(T(t,"package.json"));e.name&&Dc(e.name)}catch{}const ww=vw(Gi.version,process.argv[2]??"");Ga();const ne=Ua("vis",{packageName:"vis",packageVersion:Gi.version}),kw=process.argv.includes("--debug")||!!process.env.DEBUG;ne.addPlugin(Wa({detailed:kw,exitOnError:!1}));ne.addGlobalOption({description:"Override workspace root directory",name:"cwd",type:String});ne.addPlugin(Xv);ne.addPlugin(cw);ne.addCommand(vv);ne.addCommand(pm);ne.addCommand(Bl);ne.addCommand(Gm);ne.addCommand(Uv);ne.addCommand(qp);ne.addCommand(Vd);ne.addCommand(Qu);ne.addCommand(Ny);ne.addCommand($v);ne.addCommand(Cv);ne.addCommand(Zm);ne.addCommand(Sl);ne.addCommand(Vy);ne.addCommand(og);ne.addCommand(Jv);ne.addCommand(ry);ne.addCommand(Tv);ne.addCommand(ah);ne.addCommand(Hh);ne.addCommand(By);ne.addCommand(Xm);ne.addCommand(Zp);ne.addCommand(tg);ne.addCommand(oh);ne.addCommand(Wv);ne.addCommand(_m);ne.addCommand(cp);ne.addCommand(kp);ne.addCommand(zh);ne.addCommand(Lh);ne.addPlugin(nw(ww));try{await ne.run()}catch{process.exitCode=process.exitCode||1}
|