@visulima/vis 1.0.0-alpha.15 → 1.0.0-alpha.16
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 +49 -0
- package/LICENSE.md +44 -233
- package/dist/bin.js +1 -1
- package/dist/config/index.d.ts +121 -94
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/bin.js +271 -271
- package/dist/packem_chunks/config.js +18 -0
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +4 -4
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -5
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -1
- package/dist/packem_chunks/handler21.js +18 -1
- package/dist/packem_chunks/handler22.js +1 -5
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +5 -3
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +3 -1
- package/dist/packem_chunks/handler27.js +1 -7
- package/dist/packem_chunks/handler28.js +1 -23
- package/dist/packem_chunks/handler29.js +7 -3
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +23 -18
- package/dist/packem_chunks/handler31.js +3 -1
- package/dist/packem_chunks/handler32.js +1 -2
- package/dist/packem_chunks/handler33.js +2 -25
- package/dist/packem_chunks/handler34.js +25 -2
- package/dist/packem_chunks/handler35.js +2 -2
- package/dist/packem_chunks/handler36.js +8 -8
- package/dist/packem_chunks/handler37.js +3 -3
- package/dist/packem_chunks/handler38.js +4 -4
- package/dist/packem_chunks/handler39.js +6 -6
- package/dist/packem_chunks/handler40.js +5 -5
- package/dist/packem_chunks/handler41.js +9 -9
- package/dist/packem_chunks/handler42.js +10 -10
- package/dist/packem_chunks/handler43.js +1 -1
- package/dist/packem_chunks/handler44.js +5 -5
- package/dist/packem_chunks/handler45.js +3 -3
- package/dist/packem_chunks/handler46.js +9 -9
- package/dist/packem_chunks/handler47.js +161 -36
- package/dist/packem_chunks/handler48.js +1 -1
- package/dist/packem_chunks/handler5.js +5 -5
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_shared/{ai-analysis-CGVjqwdc.js → ai-analysis-C_GpXikx.js} +3 -3
- package/dist/packem_shared/ai-cache-DrCLD4gc.js +1 -0
- package/dist/packem_shared/ai-fix-CWOz12Om.js +43 -0
- package/dist/packem_shared/applyDefaults-DLY94gWA.js +1 -0
- package/dist/packem_shared/cache-directory-C_U1qsIw.js +1 -0
- package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
- package/dist/packem_shared/dependency-scan-YdgNVvoz.js +2 -0
- package/dist/packem_shared/docker-Dl0AoVTZ.js +60 -0
- package/dist/packem_shared/failure-log-CSC6KfcO.js +2 -0
- package/dist/packem_shared/flakiness-Dzz-I3dB.js +1 -0
- package/dist/packem_shared/lifecycle-BC6Nst6i.js +2 -0
- package/dist/packem_shared/{lockfile-B7JJzxnL.js → lockfile-i-qvq_k8.js} +1 -1
- package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
- package/dist/packem_shared/{readTomlSync-1fKo0R52-DAKNI1Me.js → readTomlSync-1fKo0R52-DtxWULlF.js} +1 -1
- package/dist/packem_shared/run-summary-utils-CJv75pla.js +1 -0
- package/dist/packem_shared/runtime-check-CBU6W8qG.js +1 -0
- package/dist/packem_shared/{selectors-Sem2CTYA.js → selectors-B2ISH581.js} +1 -1
- package/dist/packem_shared/toolchain-B7dckBQ1.js +5 -0
- package/dist/packem_shared/typosquats-B3A38-qx.js +1 -0
- package/dist/packem_shared/verify-WDStBFvK.js +1 -0
- package/dist/packem_shared/vis-update-app-D0uL3eO5.js +1 -0
- package/package.json +13 -13
- package/schemas/project.schema.json +12 -2
- package/schemas/vis-config.schema.json +248 -3
- package/dist/packem_chunks/applyDefaults.js +0 -2
- package/dist/packem_shared/ai-cache-BdPgSfg2.js +0 -1
- package/dist/packem_shared/ai-fix-iHtGLkJS.js +0 -43
- package/dist/packem_shared/cache-directory-DTfMSzT9.js +0 -1
- package/dist/packem_shared/dependency-scan-SQeRzrpJ.js +0 -2
- package/dist/packem_shared/docker-D5p9mRPU.js +0 -2
- package/dist/packem_shared/failure-log-CElcbnb9.js +0 -2
- package/dist/packem_shared/flakiness-C4t4_NoA.js +0 -1
- package/dist/packem_shared/otel-CO8UEfTa.js +0 -17
- package/dist/packem_shared/otelPlugin-DTynZDWh.js +0 -1
- package/dist/packem_shared/registry-D04iOQ5H.js +0 -2
- package/dist/packem_shared/run-summary-utils-BPraMTcm.js +0 -1
- package/dist/packem_shared/runtime-check-l4qFpo08.js +0 -1
- package/dist/packem_shared/toolchain-BhZNts--.js +0 -5
- package/dist/packem_shared/typosquats-Dr7VIL2B.js +0 -1
- package/dist/packem_shared/verify-C6NNOhTA.js +0 -1
- package/dist/packem_shared/vis-update-app-DGiMc5kb.js +0 -1
|
@@ -1 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var I=Object.defineProperty;var y=(e,t)=>I(e,"name",{value:t,configurable:!0});import{createRequire as D}from"node:module";import{getAffectedProjects as G}from"@visulima/task-runner";import{y as q,m as L}from"./bin.js";const T=D(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=y(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,r]=h.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return h.getBuiltinModule(e)}return T(e)},"__cjs_getBuiltinModule"),{execFile:N}=A("node:child_process"),{promisify:U}=A("node:util");var V=Object.defineProperty,i=y((e,t)=>V(e,"name",{value:t,configurable:!0}),"t");const M=U(N),J=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],z=["[vis deploy]","[nx deploy]"],W=["vis","nx"],Z=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],K=/^[\w./~^@{}][\w.\-/~^@{}]*$/,Q=i((e=process.env)=>{for(const t of Z){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},"resolveCiBaseSha"),R=i(e=>{if(!K.test(e))throw new Error(`Invalid git ref: "${e}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`)},"validateGitRef"),X=i(async(e,t)=>{try{return await M("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},"isRefReachable"),Y=i(async e=>{try{const{stdout:t}=await M("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},"readLastCommitMessage"),B=i((e,t,r)=>W.some(a=>e.includes(`[${a} ${t} ${r}]`)),"matchesPerProjectToken"),ee=i((e,t)=>J.some(r=>e.includes(r))||B(e,"skip",t),"commitHasSkipMessage"),te=i((e,t)=>z.some(r=>e.includes(r))||B(e,"deploy",t),"commitHasForceDeployMessage"),l=i((e,t,r,a)=>({action:"build",message:r,project:e,reason:t,...a}),"decideBuild"),k=i((e,t,r,a)=>({action:"skip",message:r,project:e,reason:t,...a}),"decideSkip"),re=i(e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,"formatDecisionLine"),oe=i((e,t)=>e.action==="skip"||t?0:1,"exitCodeFor");var se=Object.defineProperty,_=y((e,t)=>se(e,"name",{value:t,configurable:!0}),"u");const S=new Set(["deep","direct","none"]),de=_(async({argument:e,logger:t,options:r,visConfig:a,workspaceRoot:p})=>{const o=e[0]??"",E=!!r.json,C=!!r.verbose,O=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),u=_(s=>{C&&!E&&t.info(`❱ ${s}`)},"debug"),n=_(s=>{E?process.stdout.write(`${JSON.stringify(s)}
|
|
2
|
+
`):t.info(re(s)),process.exit(oe(s,O))},"emit");if(!o)return n(l("","missing-project-argument","Missing project argument. Usage: vis ignore <project>"));if(!p)return n(l(o,"workspace-error","Could not determine workspace root — building defensively"));const g=await Y(p),w=g.trim().split(`
|
|
3
|
+
`)[0]??"";if(u(`commit: ${w}`),g&&te(g,o))return n(l(o,"commit-force-deploy",`Force-deploy keyword in commit: "${w}"`));if(g&&ee(g,o))return n(k(o,"commit-skip",`Skip keyword in commit: "${w}"`));let $,P;try{({packageJsons:P,workspace:$}=q(p,a))}catch(s){const d=s instanceof Error?s.message:String(s);return n(l(o,"workspace-error",`Workspace discovery failed (${d}) — building defensively`))}if(!Object.hasOwn($.projects,o))return n(l(o,"project-unknown",`Project "${o}" not found in workspace — building defensively`));try{const s=r.base?.trim(),d=Q();let c=s||d||"HEAD~1";const m=r.head?.trim()||"HEAD";R(c),R(m),u(`resolved base ref: ${c} (source: ${s?"flag":d?"ci-env":"default"})`);const x=X(p,c),F=L(p,$,P);await x||(u(`base ref ${c} not reachable — falling back to HEAD~1`),c="HEAD~1"),u(`comparing ${c}...${m}`);const j=r.downstream??"deep",b=r.upstream??"none";if(!S.has(j))throw new Error(`Invalid --downstream value: "${j}". Must be "none", "direct", or "deep".`);if(!S.has(b))throw new Error(`Invalid --upstream value: "${b}". Must be "none", "direct", or "deep".`);const H={base:c,downstream:j,head:m,projectGraph:F,projects:$.projects,upstream:b,workspaceRoot:p},f=await G(H);u(`changed files: ${f.changedFiles.length}`),u(`affected projects: ${f.affectedProjects.join(", ")||"(none)"}`);const v={base:c,head:m};return f.changedFiles.length===0?n(k(o,"no-changes",`No files changed between ${c}...${m}`,{...v,affectedProjects:[]})):f.affectedProjects.includes(o)?n(l(o,"project-affected",`Build ${o}: affected by ${f.changedFiles.length} changed file(s)`,{...v,affectedProjects:f.affectedProjects})):n(k(o,"project-not-affected",`Skip ${o}: not affected by changes between ${c}...${m}`,{...v,affectedProjects:f.affectedProjects}))}catch(s){const d=s instanceof Error?s.message:String(s);return t.error(`Affected detection failed: ${d}`),n(l(o,"workspace-error",`Affected detection failed (${d}) — building defensively`))}},"execute");export{de as default};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)},"announceDryRun"),K=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("deps",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating dependencies and scripts ──"),w(e.root,e.packageManager,e.config,{dryRun:e.dryRun},o,e.report),o.info(""),s(e.report,o)},"migrateDepsExecuteImpl"),L=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("lint-staged",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating lint-staged ──"),k(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateLintStagedExecuteImpl"),P=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("nano-staged",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating nano-staged ──"),v(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateNanoStagedExecuteImpl"),G=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("turborepo",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating turborepo ──"),x(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateTurborepoExecuteImpl"),O=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("nx",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating nx ──"),C(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateNxExecuteImpl"),Q=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("moon",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating moon ──"),b(e.root,{copyTemplates:!!r.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateMoonExecuteImpl"),V=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("gitleaks",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating gitleaks ──"),M(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateGitleaksExecuteImpl"),Y=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("kingfisher",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating Kingfisher ──"),h(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateKingfisherExecuteImpl"),A=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("secretlint",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating secretlint ──"),I(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateSecretlintExecuteImpl"),W=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("syncpack",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating syncpack ──"),_(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateSyncpackExecuteImpl"),z=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("sherif",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating sherif ──"),S(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateSherifExecuteImpl"),F=n(({logger:o,workspaceRoot:r})=>{const t=r??process.cwd();N(t,o).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),Z=K,oo=L,eo=P,ro=G,to=O,io=Q,no=V,so=Y,ao=A,go=W,co=z,uo=F;export{Z as migrateDepsExecute,no as migrateGitleaksExecute,so as migrateKingfisherExecute,oo as migrateLintStagedExecute,io as migrateMoonExecute,eo as migrateNanoStagedExecute,to as migrateNxExecute,ao as migrateSecretlintExecute,co as migrateSherifExecute,go as migrateSyncpackExecute,ro as migrateTurborepoExecute,uo as migrateVerifyExecute};
|
|
1
|
+
var C=Object.defineProperty;var T=(e,t)=>C(e,"name",{value:t,configurable:!0});import{z as S}from"./config.js";import{af as q,y as b}from"./bin.js";import{f as $}from"../packem_shared/selectors-B2ISH581.js";import{o as L}from"../packem_shared/index-DH-5hsrC.js";var M=Object.defineProperty,I=T((e,t)=>M(e,"name",{value:t,configurable:!0}),"p");const D=I((e,t)=>{for(const f of t)if(L(f,e))return!0;return!1},"matchesAny"),z=I((e,t={})=>{const{depTypes:f,excludePatterns:l,externalOnly:y,includePatterns:d,internalOnly:j}=t;if(j&&y)return[];const u=f&&f.length>0?new Set(f):void 0,N=d&&d.length>0?d:void 0,O=l&&l.length>0?l:void 0,w=[];for(const m of e)j&&!m.isInternal||y&&m.isInternal||u&&!u.has(m.depType)||N&&(!m.packageName||!D(m.packageName,N))||O&&m.packageName&&D(m.packageName,O)||w.push(m);return w},"filterDepInstances");var B=Object.defineProperty,v=T((e,t)=>B(e,"name",{value:t,configurable:!0}),"y");const F=new Set(["json","ndjson","table"]),R=v(e=>{if(e===void 0)return"table";const t=e.toLowerCase();if(!F.has(t))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return t},"resolveFormat"),x=v((e,t)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:S(t,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),"toDepRecord"),P=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),V=v(e=>{if(!e||e.length===0)return;const t=[],f=[];for(const l of e)for(const y of l.split(",")){const d=y.trim();d&&(P.has(d)?t.push(d):f.push(d))}if(f.length>0)throw new Error(`Unknown --dep-type value(s): ${f.join(", ")}. Valid: ${[...P].join(", ")}`);return t.length>0?t:void 0},"parseDepTypes"),H=v(async({logger:e,options:t,visConfig:f,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root.");const y=R(t.format);if(t.deps===!0){if(t.internalOnly&&t.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const c=V(t.depType),i=q(l);let n=z(i,{depTypes:c,excludePatterns:t.exclude,externalOnly:t.externalOnly,includePatterns:t.include,internalOnly:t.internalOnly});if(t.query){const{workspace:r}=b(l,f),p=new Set($(Object.keys(r.projects),r,t.query));n=n.filter(k=>k.packageName!==void 0&&p.has(k.packageName))}const g=[...n].sort((r,p)=>{const k=`${r.packageName??r.packageDir} ${r.depType} ${r.depName}`,J=`${p.packageName??p.packageDir} ${p.depType} ${p.depName}`;return k.localeCompare(J)});if(y==="ndjson"){for(const r of g)e.info(JSON.stringify(x(r,l)));return}if(y==="json"){const r=g.map(p=>x(p,l));e.info(JSON.stringify(r,null,t.pretty===!0?2:void 0));return}if(g.length===0){e.info("No matching dep-instances.");return}const a=["Package","Block","Dep","Specifier","Internal","Path"],o=g.map(r=>[r.packageName??r.packageDir,r.depType,r.depName,r.specifier,r.isInternal?"yes":"no",S(l,r.packageJsonPath)]),s=a.map((r,p)=>Math.max(r.length,...o.map(k=>(k[p]??"").length))),h=v((r,p)=>r.padEnd(p),"pad");e.info(a.map((r,p)=>h(r,s[p])).join(" ")),e.info(s.map(r=>"─".repeat(r)).join("──"));for(const r of o)e.info(r.map((p,k)=>h(p,s[k])).join(" "));e.info(""),e.info(`${String(g.length)} dep-instance(s)`);return}if(y==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:d,workspace:j}=b(l,f);let u=Object.keys(j.projects).sort();if(t.query&&(u=$(u,j,t.query)),u.length===0){e.info("No projects found.");return}const N=t.inferred===!0,O=t.targets===!0||N;if(y==="json"){const c=u.map(i=>{const n=j.projects[i],g=d.get(i)??{},a=Object.entries(n.targets??{}).map(([o])=>{const s=g[o],h=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...h?{inferred:!0}:{},name:o,type:s?.type}}).filter(o=>!N||o.inferred===!0);return{language:n.language,layer:n.layer,name:i,root:n.root,stack:n.stack,tags:n.tags??[],targets:a,type:n.projectType??"library"}});e.info(JSON.stringify(c,null,2));return}const w=v((c,i)=>{const n=c.map((a,o)=>{let s=0;for(const h of i)s=Math.max(s,(h[o]??"").length);return Math.max(a.length,s)}),g=v((a,o)=>a.padEnd(o),"pad");e.info(c.map((a,o)=>g(a,n[o])).join(" ")),e.info(n.map(a=>"─".repeat(a)).join("──"));for(const a of i)e.info(a.map((o,s)=>g(o,n[s])).join(" "))},"renderTable");if(O){const c=[];for(const i of u){const n=j.projects[i],g=d.get(i)??{};for(const a of Object.keys(n.targets??{}).sort()){const o=g[a],s=o?.inferred===!0;if(N&&!s)continue;const h=n.targets?.[a],r=h?.cache===!1?"no":h?.cache===!0?"yes":"default";c.push([i,a,o?.type??"—",r,s?"yes":"no",o?.description??"—"])}}if(c.length===0){e.info(N?"No inferred targets found.":"No targets found.");return}w(["Project","Target","Type","Cache","Inferred","Description"],c),e.info(""),e.info(`${String(c.length)} target(s) across ${String(u.length)} project(s)`);return}const m=["Project","Type","Layer","Tags","Targets"],E=u.map(c=>{const i=j.projects[c],n=Object.keys(i.targets??{});return[c,i.projectType??"library",i.layer??"—",(i.tags??[]).join(", ")||"—",n.length>4?`${n.slice(0,4).join(", ")}… (${String(n.length)})`:n.join(", ")||"—"]});w(m,E),e.info(""),e.info(`${String(u.length)} project(s)`)},"execute");export{H as default};
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`):n==="minimal"?process.stdout.write(`${Re(e)}
|
|
4
|
-
`):(Se(e,a),a.info(le(e)))},"writeFormattedOutput"),re=R(async(e,t,n,a,i,o,r)=>{const g=Ce(e,n,t,!0,{useEditorconfig:r}),v=t==="pnpm"?"pnpm-workspace.yaml":"package.json";if(i.info(`
|
|
5
|
-
Updated ${v}`),g&&i.info(`Backup saved to ${g}`),a.changelog){i.info(`
|
|
6
|
-
Fetching changelogs...`);const u=await ce(n,void 0,o);for(const d of u){const m=d.releaseUrl??d.repoUrl??d.npmUrl;i.info(` ${d.packageName}: ${m}`)}}if(a.install??!0){const u=t,d=["install"];i.info(`Running ${u} ${d.join(" ")}...
|
|
7
|
-
`);try{ie(u,d,{cwd:e,env:process.env,stdio:"inherit"})}catch{i.warn(`${u} ${d.join(" ")} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),rt=R(async(e,t,n,a,i,o)=>{const r=n.update??{},g=[["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[s,c]of g)a[s]&&o.warn(`${G("⚠")} ${c}, ignoring.`);const{excludes:v,minutes:u}=ot(e,t),d=r.minimumReleaseAge??u,m=r.minimumReleaseAgeExclude??v;if(r.minimumReleaseAge!==void 0&&u!==void 0&&r.minimumReleaseAge!==u){const s=t==="pnpm"?"pnpm-workspace.yaml":"bunfig.toml";o.warn(`${G("⚠")} minimumReleaseAge mismatch: vis config = ${String(r.minimumReleaseAge)} min, ${s} = ${String(u)} min. Consider keeping them in sync.`)}const S=Ae(e),E=a["include-internal"],J=a.peer,N=xe(e,t,{depFields:r.depFields,dev:a.dev,includeInternal:E,peer:J,prod:a.prod});if(N.size===0){o.info("No catalogs found.");return}const ue={...r,minimumReleaseAge:d,minimumReleaseAgeExclude:m},T=st(a,ue,i);let L=0;for(const s of N.values())L+=s.size;const _=!!process.stdout.isTTY&&!qe;let U;const de=_?(s,c)=>{U?U.rerender($.createElement(ae,{current:s,total:c})):(process.stdout.write(`
|
|
8
|
-
`),U=te($.createElement(ae,{current:s,total:c}),{interactive:!0,patchConsole:!1}))}:(s,c)=>{o.info(`Checking ${String(s)}/${String(c)} dependencies...`)};_||o.info(`Checking ${String(L)} catalog dependencies...
|
|
9
|
-
`);const pe=Ee(n.security?.socket),{checkedCount:k,failed:w,filteredByTarget:f,ignored:C,outdated:p}=await Te(N,T,S,de,e,pe,n.security?.socket?.acceptedRisks);U&&(U.clear(),U.unmount());const O=E?{ignored:[],outdated:[]}:Ue(e,{depFields:r.depFields,dev:a.dev,exclude:T.exclude,ignore:T.ignore,include:T.include,packageMode:T.packageMode,peer:J,prod:a.prod,target:T.target});if(O.outdated.length>0){const s=new Set(p.map(c=>`${c.catalogName}|${c.packageName}`));for(const c of O.outdated)s.has(`${c.catalogName}|${c.packageName}`)||p.push(c)}if(O.ignored.length>0)for(const s of O.ignored)C.includes(s)||C.push(s);const Z=k-p.length-w.length;if(w.length>0&&o.warn(`Failed to fetch: ${w.join(", ")}`),C.length>0&&o.info(`Skipped ${String(C.length)} ignored package${C.length===1?"":"s"}: ${C.join(", ")}`),!_&&k>p.length){const s=[...N.values()].reduce((B,z)=>B+z.size,0),c=s>k?` (${String(s)} catalog entries, ${String(s-k)} duplicates)`:"";o.info(`Checked ${String(k)} unique packages${c}: ${String(p.length)} outdated, ${String(Z)} up-to-date${w.length>0?`, ${String(w.length)} failed`:""}${f.length>0?`, ${String(f.length)} skipped by target`:""}`)}if(p.length===0){f.length>0?o.info(`All catalog dependencies are up to date within the current target.
|
|
10
|
-
${String(f.length)} package${f.length===1?" has":"s have"} newer versions available with --target latest:
|
|
11
|
-
${f.map(s=>` ${s.packageName} ${s.currentRange} → ${s.newRange} (${s.updateType})`).join(`
|
|
12
|
-
`)}`):o.info("All catalog dependencies are up to date.");return}const q=a.format??r.format??"table";let y;if(a.ai){const s=Ye(a.aiType??"impact");y=await ze(p,o,n.ai,s)}const Y=!!a.dryRun;if(_&&q==="table"){const s=new He(p,y??null);let c;if(a.changelog){o.info("Fetching changelogs...");const l=await ce(p,void 0,S);c=new Map;for(const h of l){const A=h.releaseUrl??h.repoUrl??h.npmUrl;A&&c.set(h.packageName,A)}}const B=n.tui?.autoExit??!1,z=B===!0?3:typeof B=="number"?B:0,K=await te($.createElement(Ve,{autoExitSeconds:z,changelogUrls:c,checkedCount:k,filteredOutEntries:f,isDryRun:Y,store:s,totalCatalogEntries:L}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),I=process.stdout.columns||80;process.stdout.write(`
|
|
13
|
-
`);for(const l of p){const h=l.vulnerabilities?.length||l.socketReport&&l.socketReport.alerts.length>0,A=!!l.acceptedRisk,H=h?A?"✓":"⚠":"✓",me=A?"gray":l.updateType==="major"?"red":l.updateType==="minor"?"yellow":"green",P=l.socketReport?.score.overall,fe=P===void 0?"":` [${String(Math.round(P*100))}%]`,Q=P===void 0?void 0:je(P);process.stdout.write(`${V($.createElement(b,null," ",$.createElement(b,{color:me},H),` ${l.packageName} ${l.currentRange} → ${l.newRange}`,$.createElement(b,{dimColor:!0},` ${l.updateType}`),Q?$.createElement(b,{color:Q},fe):null),{columns:I})}
|
|
14
|
-
`)}if(process.stdout.write(`
|
|
15
|
-
`),o.info(le(p)),k>p.length){const l=[...N.values()].reduce((A,H)=>A+H.size,0),h=l>k?` (${String(l)} catalog entries, ${String(l-k)} duplicates)`:"";o.info(` Checked ${String(k)} unique packages${h}: ${String(Z)} up-to-date${w.length>0?`, ${String(w.length)} failed`:""}`)}if(f.length>0){process.stdout.write(`
|
|
16
|
-
`);const l=`${String(f.length)} package${f.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${V($.createElement(b,{color:"yellow"},` ${l}`),{columns:I})}
|
|
17
|
-
`);for(const h of f)process.stdout.write(`${V($.createElement(b,null," ",$.createElement(b,{dimColor:!0},h.packageName),` ${h.currentRange} → ${h.newRange}`,$.createElement(b,{dimColor:!0},` ${h.updateType}`)),{columns:I})}
|
|
18
|
-
`)}const D=Array.isArray(K)?K:[];if(D.length>0&&!Y){o.info(`
|
|
19
|
-
Applying ${String(D.length)} updates...
|
|
20
|
-
`);const l={...a,install:a.install??r.install};await re(e,t,D,l,o,S,n.editorconfig??!0)}return}if(Y){if(q==="json"){const s={failed:w,filteredByTarget:f,ignored:C,outdated:p};y&&(s.aiAnalysis=y),process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
21
|
-
`)}else o.info(`Would update ${String(p.length)} dependencies:
|
|
22
|
-
`),se(p,w,q,o),y&&(o.info(""),o.info(ne(y))),oe(f,o);return}y&&q!=="json"&&(o.info(ne(y)),o.info(""));let F=p;if(a.interactive&&(F=await Ne(p),F.length===0)){o.info("No updates selected.");return}o.info(`Updating ${String(F.length)} catalog dependencies...
|
|
23
|
-
`),se(F,[],q,o),oe(f,o);const ge={...a,install:a.install??r.install};await re(e,t,F,ge,o,S)},"executeCatalogUpdate"),it=R((e,t,n,a,i,o)=>{const r={dev:a.dev,filters:j(a.filter),global:a.global,interactive:a.interactive,latest:a.latest||a.target==="latest",noOptional:a.optional===!1,noSave:a.save===!1,packages:i,prod:a.prod,recursive:a.recursive,workspaceRoot:a.workspaceRoot},{command:g,warnings:v}=nt(t,n,r);for(const d of v)o.warn(d);const u=`${g.bin} ${g.args.join(" ")}`.trim();if(a.dryRun){o.info(`Would run: ${u}`);return}o.info(`Running: ${u}`);try{ie(g.bin,g.args,{cwd:e,env:process.env,stdio:"inherit"})}catch(d){const m=d.status??1;o.error(`
|
|
24
|
-
${Fe("✖")} Update failed (exit code ${String(m)})`),o.error(` Command: ${u}`),o.error(` Directory: ${e}
|
|
25
|
-
`),process.exitCode=m}},"executePmWrapper"),kt=R(async({argument:e,logger:t,options:n,visConfig:a,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");let o=e;const r=i,{packageManager:g}=Be(r);if(n.typosquatCheck!==!1){if(o.length>0){const v=o.map(m=>Ge(m)),u=a?.security?.typosquatAllowlist,d=await Ie(v.map(m=>m.name),u);if(!d.ok){process.exitCode=1;return}o=v.map((m,S)=>{const E=d.packages[S];return E!==m.name?m.versionSpec?`${E}@${m.versionSpec}`:E??"":o[S]??""})}else if(!await De(r,a?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!Me(r,g)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(_e(r,g))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(n.catalog!==!1&&Oe(r,g))await rt(r,g,a??{},n,o,t);else{const v=Pe(r,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),u=v.name==="aube"?"":We(v.name);it(r,v.name,u,n,o,t)}},"execute");export{kt as default,ot as readPmNativeMinimumReleaseAge};
|
|
1
|
+
var d=Object.defineProperty;var u=(o,r)=>d(o,"name",{value:r,configurable:!0});import{createRequire as l}from"node:module";import{ag as R,ah as E,ai as w,aj as s,ak as k,al as v,am as x,an as C,ao as b,ap as M,aq as h,ar as I,as as _,at as S}from"./bin.js";import{v as N}from"../packem_shared/verify-WDStBFvK.js";const m=l(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=u(o=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[r,t]=p.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return p.getBuiltinModule(o)}return m(o)},"__cjs_getBuiltinModule"),{stdin:f,stdout:T}=p,{createInterface:j}=y("node:readline/promises");var $=Object.defineProperty,q=u((o,r)=>$(o,"name",{value:r,configurable:!0}),"n");const B=q(async o=>{if(!f.isTTY)return!0;const r=j({input:f,output:T});try{const t=(await r.question(`${o} [Y/n] `)).trim().toLowerCase();return t===""||t==="y"||t==="yes"}finally{r.close()}},"confirm");var D=Object.defineProperty,n=u((o,r)=>D(o,"name",{value:r,configurable:!0}),"r");const a=n(o=>{const r=o.workspaceRoot??process.cwd(),t=o.visConfig??{};return{config:t,dryRun:!!o.options.dryRun,logger:o.logger,packageManager:E(r),report:R(),root:r,useEditorconfig:typeof t.editorconfig=="boolean"?t.editorconfig:!0}},"buildContext"),g=n(async(o,r,t)=>{if(r.yes||r.dryRun)return!0;const i=await B(`This will edit files, scripts, and hooks for "${o}". Backups (.bak) will be created. Continue?`);return i||t.info("Aborted."),i},"maybeConfirm"),c=n(o=>{o.dryRun&&o.logger.info(`Running in dry-run mode — no changes will be made.
|
|
2
|
+
`)},"announceDryRun"),K=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("deps",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating dependencies and scripts ──"),w(e.root,e.packageManager,e.config,{dryRun:e.dryRun},o,e.report),o.info(""),s(e.report,o)},"migrateDepsExecuteImpl"),L=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("lint-staged",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating lint-staged ──"),k(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateLintStagedExecuteImpl"),P=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("nano-staged",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating nano-staged ──"),v(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateNanoStagedExecuteImpl"),G=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("turborepo",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating turborepo ──"),x(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateTurborepoExecuteImpl"),O=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("nx",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating nx ──"),C(e.root,{dryRun:e.dryRun,force:!!r.force,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateNxExecuteImpl"),Q=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("moon",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating moon ──"),b(e.root,{copyTemplates:!!r.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateMoonExecuteImpl"),V=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("gitleaks",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating gitleaks ──"),M(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateGitleaksExecuteImpl"),Y=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("kingfisher",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating Kingfisher ──"),h(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateKingfisherExecuteImpl"),A=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("secretlint",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating secretlint ──"),I(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateSecretlintExecuteImpl"),W=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("syncpack",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating syncpack ──"),_(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateSyncpackExecuteImpl"),z=n(async({logger:o,options:r,visConfig:t,workspaceRoot:i})=>{if(!await g("sherif",r,o))return;const e=a({logger:o,options:r,visConfig:t,workspaceRoot:i});c(e),o.info("── Migrating sherif ──"),S(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},o,e.report),o.info(""),s(e.report,o)},"migrateSherifExecuteImpl"),F=n(({logger:o,workspaceRoot:r})=>{const t=r??process.cwd();N(t,o).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),Z=K,oo=L,eo=P,ro=G,to=O,io=Q,no=V,so=Y,ao=A,go=W,co=z,po=F;export{Z as migrateDepsExecute,no as migrateGitleaksExecute,so as migrateKingfisherExecute,oo as migrateLintStagedExecute,io as migrateMoonExecute,eo as migrateNanoStagedExecute,to as migrateNxExecute,ao as migrateSecretlintExecute,co as migrateSherifExecute,go as migrateSyncpackExecute,ro as migrateTurborepoExecute,po as migrateVerifyExecute};
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
1
|
+
var he=Object.defineProperty;var W=(e,t)=>he(e,"name",{value:t,configurable:!0});import{createRequire as ve}from"node:module";import{au as we,u as ye,F as j,e as G,av as be,g as Re,G as Ce,H as le,aw as Se,ax as ce,f as Ae,R as xe,J as Ee,V as Te,ay as Ue,B as je,az as Ne,s as Fe,d as qe,U as Me,aA as _e,aB as Be,aC as Oe,h as Pe,aD as We}from"./bin.js";import{M as X,a as ee}from"./config.js";import{d as ze}from"../packem_shared/readTomlSync-1fKo0R52-DtxWULlF.js";import{render as te,renderToString as V}from"@visulima/tui";import{Text as b}from"@visulima/tui/components/text";import $ from"react";import{H as Le,e as Ye,Z as ne}from"../packem_shared/ai-analysis-C_GpXikx.js";import{r as De,s as Ie}from"../packem_shared/typosquats-B3A38-qx.js";import{U as He,C as Ve,a as ae}from"../packem_shared/vis-update-app-D0uL3eO5.js";import{d as Ge}from"../packem_shared/utils-DrNg0XTR.js";const $e=ve(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ke=W(e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,n]=_.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return _.getBuiltinModule(e)}return $e(e)},"__cjs_getBuiltinModule"),{execFileSync:ie}=ke("node:child_process");var Je=Object.defineProperty,x=W((e,t)=>Je(e,"name",{value:t,configurable:!0}),"s");const Ze=x(e=>{const t=[];for(const n of e.filters)t.push("--filter",n);return e.workspaceRoot&&t.push("--filter","."),t.push("update"),e.latest&&t.push("--latest"),e.recursive&&t.push("--recursive"),e.interactive&&t.push("--interactive"),e.dev&&t.push("--dev"),e.prod&&t.push("--prod"),e.noOptional&&t.push("--no-optional"),e.noSave&&t.push("--no-save"),t.push(...e.packages),{args:t,bin:"pnpm"}},"resolvePnpm"),Ke=x(e=>{const t=[];return e.filters.length>0&&t.push("workspace",e.filters[0]),t.push("upgrade"),e.latest&&t.push("--latest"),t.push(...e.packages),{args:t,bin:"yarn"}},"resolveYarnV1"),Qe=x(e=>{const t=[];if(e.filters.length>0||e.recursive){t.push("workspaces","foreach","--all");for(const n of e.filters)t.push("--include",n)}return t.push("up"),e.interactive&&t.push("--interactive"),t.push(...e.packages),{args:t,bin:"yarn"}},"resolveYarnBerry"),Xe=x((e,t)=>{const n=["update"];e.latest&&t.push("npm does not support --latest flag. Packages will be updated within their semver range."),e.interactive&&t.push("npm does not support --interactive mode.");for(const a of e.filters)n.push("--workspace",a);return e.recursive&&n.push("--workspaces"),e.workspaceRoot&&n.push("--include-workspace-root"),e.dev&&n.push("--dev"),e.prod&&n.push("--production"),e.noOptional&&n.push("--no-optional"),e.noSave&&n.push("--no-save"),n.push(...e.packages),{args:n,bin:"npm"}},"resolveNpm"),et=x(e=>{const t=["update"];e.latest&&t.push("--latest");for(const n of e.filters)t.push("--filter",n);return t.push(...e.packages),{args:t,bin:"bun"}},"resolveBun"),tt=x((e,t)=>{const n=["outdated","--update"];return e.latest&&n.push("--latest"),e.interactive&&n.push("--interactive"),e.filters.length>0&&t.push("deno outdated has no --filter flag; ignoring."),(e.dev||e.prod)&&t.push("deno outdated has no --dev / --prod flags; dev/prod is governed by deno.json."),e.noOptional&&t.push("deno outdated has no --no-optional flag; ignoring."),e.noSave&&t.push("deno outdated has no --no-save flag; ignoring."),n.push(...e.packages),{args:n,bin:"deno"}},"resolveDeno"),nt=x((e,t,n)=>{const a=[];if(n.global&&e!=="aube"&&e!=="deno")return{command:{args:["update","--global",...n.packages],bin:"npm"},warnings:a};let i;switch(e){case"aube":{const o=we(n);i={args:o.args,bin:o.bin},a.push(...o.warnings);break}case"bun":{i=et(n);break}case"deno":{i=tt(n,a);break}case"npm":{i=Xe(n,a);break}case"pnpm":{i=Ze(n);break}case"yarn":{i=t.startsWith("1.")?Ke(n):Qe(n);break}default:{const o=e;throw new Error(`Unsupported package manager: ${String(o)}`)}}return{command:i,warnings:a}},"resolveUpdateCommand");var at=Object.defineProperty,R=W((e,t)=>at(e,"name",{value:t,configurable:!0}),"C");const ot=R((e,t)=>{try{if(t==="pnpm"){const n=X(e,"pnpm-workspace.yaml");if(ee(n)){const a=ye(n);return{excludes:Array.isArray(a?.minimumReleaseAgeExclude)?a.minimumReleaseAgeExclude:void 0,minutes:typeof a?.minimumReleaseAge=="number"?a.minimumReleaseAge:void 0}}}else if(t==="bun"){const n=X(e,"bunfig.toml");if(ee(n)){const a=ze(n);return{excludes:Array.isArray(a?.install?.minimumReleaseAgeExcludes)?a.install.minimumReleaseAgeExcludes:void 0,minutes:typeof a?.install?.minimumReleaseAge=="number"?a.install.minimumReleaseAge:void 0}}}}catch{}return{}},"readPmNativeMinimumReleaseAge"),st=R((e,t,n)=>{const a=e.latest?"latest":e.target??t.target??"latest";if(!["latest","minor","patch"].includes(a))throw new Error(`Invalid target "${a}". Use: latest, minor, or patch.`);const i=e.maxConcurrentRequests,o=typeof i=="number"&&i>0?i:t.maxConcurrentRequests,r=typeof e.releaseChannel=="string"?e.releaseChannel.toLowerCase():void 0;if(r!==void 0&&!["any","same","stable"].includes(r))throw new Error(`Invalid --release-channel "${String(e.releaseChannel)}". Use: any, same, or stable.`);const g=r??t.releaseChannel;return{exclude:[...j(e.exclude),...j(t.exclude)],ignore:j(t.ignore),include:[...j(e.include),...j(t.include),...n],includeLocked:e.includeLocked||t.includeLocked||!1,includePrerelease:e.prerelease||t.prerelease||!1,maxConcurrentRequests:o,minimumReleaseAge:t.minimumReleaseAge,minimumReleaseAgeExclude:t.minimumReleaseAgeExclude,packageMode:t.packageMode,releaseChannel:g,security:e.security||e.ai||t.security||!1,target:a}},"buildCatalogCheckOptions"),oe=R((e,t)=>{if(e.length!==0){t.info(`
|
|
2
|
+
${G("⚠")} ${String(e.length)} package${e.length===1?"":"s"} skipped by target constraint (use --target latest to include):`);for(const n of e)t.info(` ${n.packageName} ${n.currentRange} → ${n.newRange} (${n.updateType})`)}},"logFilteredByTarget"),se=R((e,t,n,a)=>{n==="json"?process.stdout.write(`${be({checkedCount:0,failed:t,filteredByTarget:[],ignored:[],outdated:e})}
|
|
3
|
+
`):n==="minimal"?process.stdout.write(`${Re(e)}
|
|
4
|
+
`):(Ce(e,a),a.info(le(e)))},"writeFormattedOutput"),re=R(async(e,t,n,a,i,o,r)=>{const g=Se(e,n,t,!0,{useEditorconfig:r}),v=t==="pnpm"?"pnpm-workspace.yaml":"package.json";if(i.info(`
|
|
5
|
+
Updated ${v}`),g&&i.info(`Backup saved to ${g}`),a.changelog){i.info(`
|
|
6
|
+
Fetching changelogs...`);const u=await ce(n,void 0,o);for(const d of u){const m=d.releaseUrl??d.repoUrl??d.npmUrl;i.info(` ${d.packageName}: ${m}`)}}if(a.install??!0){const u=t,d=["install"];i.info(`Running ${u} ${d.join(" ")}...
|
|
7
|
+
`);try{ie(u,d,{cwd:e,env:process.env,stdio:"inherit"})}catch{i.warn(`${u} ${d.join(" ")} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),rt=R(async(e,t,n,a,i,o)=>{const r=n.update??{},g=[["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[s,c]of g)a[s]&&o.warn(`${G("⚠")} ${c}, ignoring.`);const{excludes:v,minutes:u}=ot(e,t),d=r.minimumReleaseAge??u,m=r.minimumReleaseAgeExclude??v;if(r.minimumReleaseAge!==void 0&&u!==void 0&&r.minimumReleaseAge!==u){const s=t==="pnpm"?"pnpm-workspace.yaml":"bunfig.toml";o.warn(`${G("⚠")} minimumReleaseAge mismatch: vis config = ${String(r.minimumReleaseAge)} min, ${s} = ${String(u)} min. Consider keeping them in sync.`)}const C=Ae(e),E=a["include-internal"],J=a.peer,N=xe(e,t,{depFields:r.depFields,dev:a.dev,includeInternal:E,peer:J,prod:a.prod});if(N.size===0){o.info("No catalogs found.");return}const ue={...r,minimumReleaseAge:d,minimumReleaseAgeExclude:m},T=st(a,ue,i);let z=0;for(const s of N.values())z+=s.size;const B=!!process.stdout.isTTY&&!Fe;let U;const de=B?(s,c)=>{U?U.rerender($.createElement(ae,{current:s,total:c})):(process.stdout.write(`
|
|
8
|
+
`),U=te($.createElement(ae,{current:s,total:c}),{interactive:!0,patchConsole:!1}))}:(s,c)=>{o.info(`Checking ${String(s)}/${String(c)} dependencies...`)};B||o.info(`Checking ${String(z)} catalog dependencies...
|
|
9
|
+
`);const pe=Ee(n.security?.socket),{checkedCount:k,failed:w,filteredByTarget:f,ignored:S,outdated:p}=await Te(N,T,C,de,e,pe,n.security?.socket?.acceptedRisks);U&&(U.clear(),U.unmount());const O=E?{ignored:[],outdated:[]}:Ue(e,{depFields:r.depFields,dev:a.dev,exclude:T.exclude,ignore:T.ignore,include:T.include,packageMode:T.packageMode,peer:J,prod:a.prod,target:T.target});if(O.outdated.length>0){const s=new Set(p.map(c=>`${c.catalogName}|${c.packageName}`));for(const c of O.outdated)s.has(`${c.catalogName}|${c.packageName}`)||p.push(c)}if(O.ignored.length>0)for(const s of O.ignored)S.includes(s)||S.push(s);const Z=k-p.length-w.length;if(w.length>0&&o.warn(`Failed to fetch: ${w.join(", ")}`),S.length>0&&o.info(`Skipped ${String(S.length)} ignored package${S.length===1?"":"s"}: ${S.join(", ")}`),!B&&k>p.length){const s=[...N.values()].reduce((M,Y)=>M+Y.size,0),c=s>k?` (${String(s)} catalog entries, ${String(s-k)} duplicates)`:"";o.info(`Checked ${String(k)} unique packages${c}: ${String(p.length)} outdated, ${String(Z)} up-to-date${w.length>0?`, ${String(w.length)} failed`:""}${f.length>0?`, ${String(f.length)} skipped by target`:""}`)}if(p.length===0){f.length>0?o.info(`All catalog dependencies are up to date within the current target.
|
|
10
|
+
${String(f.length)} package${f.length===1?" has":"s have"} newer versions available with --target latest:
|
|
11
|
+
${f.map(s=>` ${s.packageName} ${s.currentRange} → ${s.newRange} (${s.updateType})`).join(`
|
|
12
|
+
`)}`):o.info("All catalog dependencies are up to date.");return}const F=a.format??r.format??"table";let y;if(a.ai){const s=Le(a.aiType??"impact");y=await Ye(p,o,n.ai,s)}const L=!!a.dryRun;if(B&&F==="table"){const s=new He(p,y??null);let c;if(a.changelog){o.info("Fetching changelogs...");const l=await ce(p,void 0,C);c=new Map;for(const h of l){const A=h.releaseUrl??h.repoUrl??h.npmUrl;A&&c.set(h.packageName,A)}}const M=n.tui?.autoExit??!1,Y=M===!0?3:typeof M=="number"?M:0,K=await te($.createElement(Ve,{autoExitSeconds:Y,changelogUrls:c,checkedCount:k,filteredOutEntries:f,isDryRun:L,store:s,totalCatalogEntries:z}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),D=process.stdout.columns||80;process.stdout.write(`
|
|
13
|
+
`);for(const l of p){const h=l.vulnerabilities?.length||l.socketReport&&l.socketReport.alerts.length>0,A=!!l.acceptedRisk,H=h?A?"✓":"⚠":"✓",me=A?"gray":l.updateType==="major"?"red":l.updateType==="minor"?"yellow":"green",P=l.socketReport?.score.overall,fe=P===void 0?"":` [${String(Math.round(P*100))}%]`,Q=P===void 0?void 0:je(P);process.stdout.write(`${V($.createElement(b,null," ",$.createElement(b,{color:me},H),` ${l.packageName} ${l.currentRange} → ${l.newRange}`,$.createElement(b,{dimColor:!0},` ${l.updateType}`),Q?$.createElement(b,{color:Q},fe):null),{columns:D})}
|
|
14
|
+
`)}if(process.stdout.write(`
|
|
15
|
+
`),o.info(le(p)),k>p.length){const l=[...N.values()].reduce((A,H)=>A+H.size,0),h=l>k?` (${String(l)} catalog entries, ${String(l-k)} duplicates)`:"";o.info(` Checked ${String(k)} unique packages${h}: ${String(Z)} up-to-date${w.length>0?`, ${String(w.length)} failed`:""}`)}if(f.length>0){process.stdout.write(`
|
|
16
|
+
`);const l=`${String(f.length)} package${f.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${V($.createElement(b,{color:"yellow"},` ${l}`),{columns:D})}
|
|
17
|
+
`);for(const h of f)process.stdout.write(`${V($.createElement(b,null," ",$.createElement(b,{dimColor:!0},h.packageName),` ${h.currentRange} → ${h.newRange}`,$.createElement(b,{dimColor:!0},` ${h.updateType}`)),{columns:D})}
|
|
18
|
+
`)}const I=Array.isArray(K)?K:[];if(I.length>0&&!L){o.info(`
|
|
19
|
+
Applying ${String(I.length)} updates...
|
|
20
|
+
`);const l={...a,install:a.install??r.install};await re(e,t,I,l,o,C,n.editorconfig??!0)}return}if(L){if(F==="json"){const s={failed:w,filteredByTarget:f,ignored:S,outdated:p};y&&(s.aiAnalysis=y),process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
21
|
+
`)}else o.info(`Would update ${String(p.length)} dependencies:
|
|
22
|
+
`),se(p,w,F,o),y&&(o.info(""),o.info(ne(y))),oe(f,o);return}y&&F!=="json"&&(o.info(ne(y)),o.info(""));let q=p;if(a.interactive&&(q=await Ne(p),q.length===0)){o.info("No updates selected.");return}o.info(`Updating ${String(q.length)} catalog dependencies...
|
|
23
|
+
`),se(q,[],F,o),oe(f,o);const ge={...a,install:a.install??r.install};await re(e,t,q,ge,o,C)},"executeCatalogUpdate"),it=R((e,t,n,a,i,o)=>{const r={dev:a.dev,filters:j(a.filter),global:a.global,interactive:a.interactive,latest:a.latest||a.target==="latest",noOptional:a.optional===!1,noSave:a.save===!1,packages:i,prod:a.prod,recursive:a.recursive,workspaceRoot:a.workspaceRoot},{command:g,warnings:v}=nt(t,n,r);for(const d of v)o.warn(d);const u=`${g.bin} ${g.args.join(" ")}`.trim();if(a.dryRun){o.info(`Would run: ${u}`);return}o.info(`Running: ${u}`);try{ie(g.bin,g.args,{cwd:e,env:process.env,stdio:"inherit"})}catch(d){const m=d.status??1;o.error(`
|
|
24
|
+
${qe("✖")} Update failed (exit code ${String(m)})`),o.error(` Command: ${u}`),o.error(` Directory: ${e}
|
|
25
|
+
`),process.exitCode=m}},"executePmWrapper"),wt=R(async({argument:e,logger:t,options:n,visConfig:a,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");let o=e;const r=i,{packageManager:g}=Me(r);if(n.typosquatCheck!==!1){if(o.length>0){const v=o.map(m=>Ge(m)),u=a?.security?.typosquatAllowlist,d=await De(v.map(m=>m.name),u);if(!d.ok){process.exitCode=1;return}o=v.map((m,C)=>{const E=d.packages[C];return E!==m.name?m.versionSpec?`${E}@${m.versionSpec}`:E??"":o[C]??""})}else if(!await Ie(r,a?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!_e(r,g)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(Be(r,g))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(n.catalog!==!1&&Oe(r,g))await rt(r,g,a??{},n,o,t);else{const v=Pe(r,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),u=v.name==="aube"?"":We(v.name);it(r,v.name,u,n,o,t)}},"execute");export{wt as default,ot as readPmNativeMinimumReleaseAge};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var J=Object.defineProperty;var y=(e,o)=>J(e,"name",{value:o,configurable:!0});import{createRequire as S}from"node:module";import{M as w,B as q,z as T,w as I}from"
|
|
2
|
-
`)},"renderCodeowners");var H=Object.defineProperty,u=y((e,o)=>H(e,"name",{value:o,configurable:!0}),"s");const Q=["author","bugs","homepage","license","repository","engines"],E=u(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),b=u((e,o)=>{if(e===o)return!0;if(typeof e!=typeof o||e===null||o===null)return!1;if(Array.isArray(e)){if(!Array.isArray(o)||e.length!==o.length)return!1;for(const[t,r]of e.entries())if(!b(r,o[t]))return!1;return!0}if(typeof e=="object"&&typeof o=="object"){const t=Object.keys(e),r=Object.keys(o);if(t.length!==r.length)return!1;for(const n of t)if(!b(e[n],o[n]))return!1;return!0}return!1},"deepEqual"),N=u(e=>e===void 0?e:structuredClone(e),"cloneJson"),X=u((e,o,t)=>{if(e==="repository"&&E(o)&&E(t)){const r={};for(const[n,i]of Object.entries(o))n!=="directory"&&(r[n]=N(i));return typeof t.directory=="string"&&(r.directory=t.directory),r}return N(o)},"buildTargetValue"),Z=u((e,o,t)=>{const r=[];for(const n of t.fields){if(!Object.hasOwn(e,n))continue;const i=e[n],a=o[n],c=X(n,i,a);b(c,a)||r.push({after:c,before:a,field:n,packageJsonPath:""})}return r},"computeFieldChanges"),ee=u((e,o)=>{for(const t of o)e[t.field]=t.after},"applyFieldChanges");var oe=Object.defineProperty,m=y((e,o)=>oe(e,"name",{value:o,configurable:!0}),"p");const _=["codeowners","package-json-fields"],te=m(e=>{const o=new Set,t=[];for(const r of e??[])for(const n of r.split(",")){const i=n.trim();i.length===0||o.has(i)||(o.add(i),t.push(i))}return t.length>0?t:[...Q]},"parseFieldsOption"),re=m((e,o)=>o.some(t=>L(t,e)),"matchesAnyGlob"),ne=m(({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const{workspace:n}=U(r,t),i=
|
|
1
|
+
var J=Object.defineProperty;var y=(e,o)=>J(e,"name",{value:o,configurable:!0});import{createRequire as S}from"node:module";import{M as w,B as q,z as T,w as I}from"./config.js";import{o as L}from"../packem_shared/index-DH-5hsrC.js";import{y as U,aF as O,aG as W,a9 as B}from"./bin.js";const x=S(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=y(e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[o,t]=k.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return k.getBuiltinModule(e)}return x(e)},"__cjs_getBuiltinModule"),{readFileSync:M}=D("node:fs");var z=Object.defineProperty,C=y((e,o)=>z(e,"name",{value:o,configurable:!0}),"i");const G=C((e,o)=>{const t=o.replace(/^\.?\//,"");return t===""||t==="."?`/${e}/`:e===""||e==="."?`/${t}`:`/${e}/${t}`},"toWorkspacePath"),K=C((e,o)=>{const t=[];for(const[r,n]of Object.entries(o?.globalPaths??{}))t.push({owners:n,path:r});for(const[r,n]of Object.entries(e.projects)){const i=n.owners??[];for(const a of i)t.push({channel:a.channel,owners:a.owners,path:G(n.root??r,a.path),projectId:r})}return(o?.orderBy??"file-source")==="project-id"?t.sort((r,n)=>(r.projectId??"").localeCompare(n.projectId??"")||r.path.localeCompare(n.path)):t.sort((r,n)=>r.path.localeCompare(n.path)),t},"buildCodeownersLines"),V=["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.","# Update each project's project.json `owners` field and re-run the command.",""],Y=C((e,o="github")=>{const t=[...V];for(const r of e){const n=r.owners.join(" "),i=r.channel?` # notify: ${r.channel}`:"";t.push(`${r.path} ${n}${i}`)}return t.push(""),t.join(`
|
|
2
|
+
`)},"renderCodeowners");var H=Object.defineProperty,u=y((e,o)=>H(e,"name",{value:o,configurable:!0}),"s");const Q=["author","bugs","homepage","license","repository","engines"],E=u(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),b=u((e,o)=>{if(e===o)return!0;if(typeof e!=typeof o||e===null||o===null)return!1;if(Array.isArray(e)){if(!Array.isArray(o)||e.length!==o.length)return!1;for(const[t,r]of e.entries())if(!b(r,o[t]))return!1;return!0}if(typeof e=="object"&&typeof o=="object"){const t=Object.keys(e),r=Object.keys(o);if(t.length!==r.length)return!1;for(const n of t)if(!b(e[n],o[n]))return!1;return!0}return!1},"deepEqual"),N=u(e=>e===void 0?e:structuredClone(e),"cloneJson"),X=u((e,o,t)=>{if(e==="repository"&&E(o)&&E(t)){const r={};for(const[n,i]of Object.entries(o))n!=="directory"&&(r[n]=N(i));return typeof t.directory=="string"&&(r.directory=t.directory),r}return N(o)},"buildTargetValue"),Z=u((e,o,t)=>{const r=[];for(const n of t.fields){if(!Object.hasOwn(e,n))continue;const i=e[n],a=o[n],c=X(n,i,a);b(c,a)||r.push({after:c,before:a,field:n,packageJsonPath:""})}return r},"computeFieldChanges"),ee=u((e,o)=>{for(const t of o)e[t.field]=t.after},"applyFieldChanges");var oe=Object.defineProperty,m=y((e,o)=>oe(e,"name",{value:o,configurable:!0}),"p");const _=["codeowners","package-json-fields"],te=m(e=>{const o=new Set,t=[];for(const r of e??[])for(const n of r.split(",")){const i=n.trim();i.length===0||o.has(i)||(o.add(i),t.push(i))}return t.length>0?t:[...Q]},"parseFieldsOption"),re=m((e,o)=>o.some(t=>L(t,e)),"matchesAnyGlob"),ne=m(({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const{workspace:n}=U(r,t),i=K(n,t?.codeowners);if(i.length===0){e.info("No `owners` entries found in any project. Nothing to sync.");return}const a=Y(i,t?.codeowners?.provider??"github"),c=o.out?w(r,o.out):w(r,"CODEOWNERS");if(o.check){let g="";try{g=M(c,"utf8")}catch(d){if(d.code!=="ENOENT")throw d}if(g.trim()!==a.trim()){e.error(`${c} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}e.info(`${c} is up to date.`);return}q(c,a),e.info(`Wrote ${i.length} entries to ${c}`)},"runCodeowners"),se=m(({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=r,i=t?.editorconfig??!0,a=O(w(n,"package.json"));if(!a){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const c=te(o.fields),g=o.ignorePackageName??[],d=o.check===!0,F=(o.format??"human").toLowerCase(),v=o.quiet===!0,R=W(n).filter(s=>s!=="."),p=[];let j=0;for(const s of R){const l=w(n,s,"package.json"),h=O(l);if(!h)continue;const $=typeof h.name=="string"?h.name:void 0;if($!==void 0&&g.length>0&&re($,g))continue;j+=1;const P=Z(a,h,{fields:c});P.length!==0&&p.push({filePath:l,packageJsonPath:T(n,l),packageName:$,pkg:h,pkgChanges:P})}if(!d)for(const s of p)ee(s.pkg,s.pkgChanges),I(s.filePath,s.pkg,{indent:B(s.filePath,{useEditorconfig:i}),overwrite:!0});const f=p.flatMap(s=>s.pkgChanges.map(l=>({after:l.after,before:l.before,field:l.field,packageJsonPath:s.packageJsonPath,packageName:s.packageName}))),A={changes:f,fields:c,kind:"package-json-fields",mode:d?"check":"write",totalChanges:f.length,totalPackages:j};if(F==="json")process.stdout.write(`${JSON.stringify(A,null,4)}
|
|
3
3
|
`);else if(f.length===0)e.info(`All ${j} package${j===1?"":"s"} in sync (fields: ${c.join(", ")}).`);else if(d){if(!v)for(const s of f)e.error(`${s.packageJsonPath}: ${s.field} drifts from root`);e.error(`Found ${f.length} field drift${f.length===1?"":"s"} across ${p.length} package${p.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!v)for(const s of p)e.info(`${s.packageJsonPath}: synced ${s.pkgChanges.map(l=>l.field).join(", ")}`);e.info(`Synced ${f.length} field${f.length===1?"":"s"} across ${p.length} package${p.length===1?"":"s"}.`)}d&&f.length>0&&(process.exitCode=1)},"runPackageJsonFields"),pe=m(async e=>{const o=e.argument[0];if(!o)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${_.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(o==="codeowners"){ne(e);return}if(o==="package-json-fields"){se(e);return}throw new Error(`Unknown sync kind: "${o}". Known kinds: ${_.join(", ")}.`)},"execute");export{pe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{
|
|
1
|
+
var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{aI as Y,E as p,j as b,q as T,p as l}from"./bin.js";import{a as _,M as N,K as Q,b as L,z as X,y as pe,h as Z,B as fe,C as ue}from"./config.js";import{f as we}from"../packem_shared/giget-CcEy_Elm.js";const le=ce(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=j(t=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,r]=x.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return x.getBuiltinModule(t)}return le(t)},"__cjs_getBuiltinModule"),{fileURLToPath:de}=P("node:url"),{createInterface:me}=P("node:readline"),{mkdtempSync:he,rmSync:ge}=P("node:fs"),{tmpdir:$e}=P("node:os"),{spawnSync:ye}=P("node:child_process");var ve=Object.defineProperty,y=j((t,e)=>ve(t,"name",{value:e,configurable:!0}),"i");const ee=[".ts",".mts",".cts",".js",".mjs",".cjs"],be="template.yml",Te=[".d",".test",".spec",".config",".bench",".stories"],Se=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],te=y(t=>{for(const e of ee)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),Oe=y(t=>{if(Se.some(r=>t.endsWith(r))||!ee.some(r=>t.endsWith(r)))return!1;const e=te(t);return!Te.some(r=>e.endsWith(r))},"isNativeFile"),J=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!Oe(s.name))continue;const n=te(s.name);r.push({load:y(()=>Ne(s.path),"load"),name:n,path:s.path,source:e})}return r},"scanNativeDirectory"),I=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=N(s.path,be);_(n)&&r.push({load:y(()=>Re(s.path,s.name),"load"),name:s.name,path:s.path,source:e})}return r},"scanMoonDirectory"),je=y(()=>{try{const t=de(import.meta.url),e=N(Q(t),"..","..","templates");return _(e)?e:void 0}catch{return}},"resolveBuiltinTemplatesDirectory"),q=y(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...J(N(s,".vis","templates"),"native"),...I(N(s,".vis","templates"),"moon"),...I(N(s,".moon","templates"),"moon")];for(const o of e)n.push(...I(o,"config")),n.push(...J(o,"config"));const i=je();i&&n.push(...I(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},"discoverTemplates"),Ne=y(async t=>{const{loadNativeTemplate:e}=await import("./loader.js");return e(t)},"loadNativeFromPath"),Re=y(async(t,e)=>{const{loadMoonTemplate:r}=await import("./index.js");return r(t,e)},"loadMoonFromPath");var Ee=Object.defineProperty,v=j((t,e)=>Ee(t,"name",{value:e,configurable:!0}),"c");const M=v((t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),"ask"),ke=v(async(t,e,r)=>{const s=await M(t,` ${e} ${p(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),xe=v(async(t,e,r,s)=>{process.stderr.write(` ${e}
|
|
2
2
|
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=i===s?p(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
3
3
|
`)}for(;;){const n=await M(t,`
|
|
4
4
|
${p(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${p("Invalid choice. Try again.")}
|
|
@@ -6,17 +6,17 @@ var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0})
|
|
|
6
6
|
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=s.includes(i)?p(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
7
7
|
`)}for(;;){const n=await M(t,`
|
|
8
8
|
${p("Enter choices:")} `);if(n===""&&s.length>0)return s;const i=n.split(",").map(a=>Number.parseInt(a.trim(),10)).filter(a=>Number.isInteger(a)&&a>=1&&a<=r.length);if(i.length>0)return i.map(a=>r[a-1]);process.stderr.write(` ${p("Invalid choice. Try again.")}
|
|
9
|
-
`)}},"selectMany"),Pe=v(t=>` ${p(`${t}:`)} `,"promptText"),De=v((t,e)=>e.prompt??t,"variableLabel"),We=v(t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),"sortVariables"),H=v((t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},"parseValue"),
|
|
10
|
-
`)}}else{Z(e.destination);let o=0,c=0;for(const g of a){const{file:m,meta:$,target:S}=g,C=_(S),O=e.force||$.force===!0;if(C&&!O){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ve(S,m.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=
|
|
9
|
+
`)}},"selectMany"),Pe=v(t=>` ${p(`${t}:`)} `,"promptText"),De=v((t,e)=>e.prompt??t,"variableLabel"),We=v(t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),"sortVariables"),H=v((t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},"parseValue"),F=v((t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const n of s)if(typeof n!="string"||!e.values.includes(n))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(n)}")`)}},"validateValue"),Be=v(async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?me({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of We(n)){if(Object.hasOwn(s,o)){const $=H(c,s[o]??"");F(o,c,$),i[o]=$;continue}if(e||!r||c.internal){if(c.default!==void 0){F(o,c,c.default),i[o]=c.default;continue}if(c.required)throw new Error(`Required variable "${o}" not provided. Pass --${o}=<value> or remove --defaults.`);continue}const g=De(o,c);let m;if(c.type==="boolean")m=await ke(a,g,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const $=Array.isArray(c.default)?c.default:[];m=await _e(a,g,c.values,$)}else{const $=typeof c.default=="string"?c.default:void 0;m=await xe(a,g,c.values,$)}else{const $=c.default===void 0?"":` (${String(c.default)})`,S=await M(a,Pe(`${g}${$}`));if(S===""&&c.default!==void 0)m=c.default;else if(S===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else m=H(c,S)}F(o,c,m),i[o]=m}return i}finally{a?.close()}},"collectOptions");var Ie=Object.defineProperty,V=j((t,e)=>Ie(t,"name",{value:e,configurable:!0}),"o");const qe=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],Me=V(t=>qe.some(e=>t.startsWith(e)),"isRemoteSource"),Ce=V(async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??he(N($e(),"vis-generate-")),n=V(()=>{if(r)try{ge(s,{force:!0,recursive:!0})}catch{}},"cleanup");l.info(`Downloading ${t}…`);try{const i=await we(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:n,directory:i.dir}}catch(i){n();const a=i instanceof Error?i.message:String(i);throw l.warn(`Failed to download template: ${a}`),i}},"fetchRemoteTemplate");var Ae=Object.defineProperty,R=j((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"a");const re=R((t,e="")=>{const r=[];for(const[s,n]of Object.entries(t)){const i=e?`${e}/${s}`:s;typeof n=="string"||Buffer.isBuffer(n)?r.push({content:n,path:i}):n&&typeof n=="object"&&r.push(...re(n,i))}return r},"flattenTree"),Fe=R(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),Le=R((t,e)=>{if(L(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=N(t,e),s=X(t,r);if(s===".."||s.startsWith(`..${pe}`)||L(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),Ve=R((t,e)=>{Z(Q(t)),fe(t,e)},"writeOne"),Ke=R((t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,n=typeof t=="string"?r:t.silent??r;for(const i of s){n||l.info(`$ ${i}`);const a=ye(i,{cwd:e,shell:!0,stdio:n?"ignore":"inherit"});if(a.status!==0)return l.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},"runScript"),ze=R(t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,n=e.get(s);n?n.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},"groupByPhase"),Ue=R(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:X(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?re(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=Le(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${b(T("Plan"))} ${p("(dry-run, no files written)")}`);for(const o of a){const c=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${p("write")} ${o.file.path} ${p(`(${Fe(c)})`)}
|
|
10
|
+
`)}}else{Z(e.destination);let o=0,c=0;for(const g of a){const{file:m,meta:$,target:S}=g,C=_(S),O=e.force||$.force===!0;if(C&&!O){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ve(S,m.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=ze(s.scripts);l.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,c]of o)if((await Promise.all(c.map(g=>Promise.resolve(Ke(g,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
|
|
11
11
|
`),l.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${p("•")} ${o}
|
|
12
12
|
`)}},"runTemplate");var Ge=Object.defineProperty,w=j((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"u");const Je=w(async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},"toListEntry"),He=w((t,e)=>{const r={default:e.default,name:t,order:e.order,prompt:e.prompt,required:e.required,type:e.type};return e.type==="enum"&&(r.multiple=e.multiple,r.values=e.values),r},"summarizeVariable"),Ye=w(async t=>{const e=await t.load(),r=Object.entries(e.options??{}).sort(([s,n],[i,a])=>{const o=n.order??0,c=a.order??0;return o===c?s.localeCompare(i):o-c}).map(([s,n])=>He(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},"describeTemplate"),Qe=w(t=>{if(t.length===0){l.info("No templates found."),l.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}l.info("Available templates:");for(const e of t){const r=p(`(${e.source})`);process.stderr.write(` ${b(T(e.name))} ${r}
|
|
13
13
|
`)}},"printList"),Xe=w(t=>{const e={},r=[];for(const s of t){if(!s.startsWith("--")){r.push(s);continue}const n=s.indexOf("=");if(n===-1){const o=s.slice(2);o.startsWith("no-")?e[o.slice(3)]="false":e[o]="true";continue}const i=s.slice(2,n),a=s.slice(n+1);e[i]=a}return{overrides:e,remaining:r}},"parsePassthroughOverrides"),Ze=w(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${b(T("vis generate"))} ${p("— pick a template")}
|
|
14
14
|
|
|
15
15
|
`);for(const[s,n]of t.entries()){const i=b(T(` ${String(s+1)}.`));process.stderr.write(`${i} ${n.name} ${p(`(${n.source})`)}
|
|
16
16
|
`)}return new Promise((s,n)=>{r.question(`
|
|
17
|
-
${p(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?s(t[a-1].name):n(new Error("Invalid choice."))})})}finally{r.close()}},"pickInteractive"),nt=w(async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:n})=>{const i=e.cwd||n||process.cwd(),a=n??i,o=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const u=
|
|
18
|
-
`);return}Qe(u);return}if(e.describe){const u=c[0];if(!u)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const f=
|
|
17
|
+
${p(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?s(t[a-1].name):n(new Error("Invalid choice."))})})}finally{r.close()}},"pickInteractive"),nt=w(async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:n})=>{const i=e.cwd||n||process.cwd(),a=n??i,o=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const u=q({extraDirectories:o?.templates??[],onWarning:w(f=>{l.warn(f)},"onWarning"),workspaceRoot:a});if(e.json){const f=await Promise.all(u.map(d=>Je(d)));process.stdout.write(`${JSON.stringify(f,null,2)}
|
|
18
|
+
`);return}Qe(u);return}if(e.describe){const u=c[0];if(!u)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const f=q({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a}).find(h=>h.name===u);if(!f)throw new Error(`Template "${u}" not found. Run \`vis generate --list\` to see available templates.`);const d=await Ye(f);if(e.json){process.stdout.write(`${JSON.stringify(d,null,2)}
|
|
19
19
|
`);return}if(l.info(`Template: ${b(T(d.name))} ${p(`(${d.source})`)}`),d.description&&l.info(d.description),d.destination&&l.info(`Destination: ${p(d.destination)}`),d.variables.length===0)l.info("No variables.");else{l.info("Variables:");for(const h of d.variables){const B=[h.type];h.required&&B.push("required"),h.default!==void 0&&B.push(`default=${JSON.stringify(h.default)}`),h.values&&B.push(`values=${h.values.join("|")}`),process.stderr.write(` ${b(T(h.name))} ${p(`(${B.join(", ")})`)}
|
|
20
|
-
`)}}return}let g=[...r??[]];if(g.length===0){const u=process.argv.slice(2),f=u.indexOf("--");f!==-1&&(g=u.slice(f+1))}const m=c.indexOf("--"),$=m===-1?[]:c.slice(m+1),S=m===-1?c:c.slice(0,m),{overrides:C}=Xe([...$,...g]);let O,D,W;const k=S[0];let
|
|
21
|
-
`);const ie=await Be({defaults:U,interactive:ne,overrides:C,variables:O.options??{}});try{await Ue(O,{cwd:i,destination:G,dryRun:
|
|
22
|
-
`),l.success(`Template '${D}' applied.`))}finally{
|
|
20
|
+
`)}}return}let g=[...r??[]];if(g.length===0){const u=process.argv.slice(2),f=u.indexOf("--");f!==-1&&(g=u.slice(f+1))}const m=c.indexOf("--"),$=m===-1?[]:c.slice(m+1),S=m===-1?c:c.slice(0,m),{overrides:C}=Xe([...$,...g]);let O,D,W;const k=S[0];let A;if(k&&Me(k)){const u=await Ce(k,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});A=u.cleanup;try{const f=q({extraDirectories:[u.directory],workspaceRoot:a}).find(d=>d.path.startsWith(u.directory));if(!f)throw new Error(`Downloaded template at ${u.directory} contains no template.yml or *.ts entrypoint.`);O=await f.load(),D=f.name,W=O.destination}catch(f){throw A(),f}}else{const u=q({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a});if(u.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let f;if(k)f=k;else{if(e.interactive===!1||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");f=await Ze(u)}const d=u.find(h=>h.name===f);if(!d)throw new Error(`Template "${f}" not found. Run 'vis generate --list' to see available templates.`);O=await d.load(),D=d.name,W=O.destination}const K=e.to,z=!!e.dryRun,se=!!e.force,U=!!e.defaults,oe=!!e.skipScripts,ne=e.interactive!==!1&&!!process.stdin.isTTY&&!U;let E;K?E=K:W?E=W:E=".";const G=L(E)?E:ue(i,E);l.info(`Template: ${b(T(D))}`),l.info(`Target: ${p(G)}`),process.stderr.write(`
|
|
21
|
+
`);const ie=await Be({defaults:U,interactive:ne,overrides:C,variables:O.options??{}});try{await Ue(O,{cwd:i,destination:G,dryRun:z,force:se,options:ie,skipScripts:oe,workspaceRoot:a}),z||(process.stderr.write(`
|
|
22
|
+
`),l.success(`Template '${D}' applied.`))}finally{A?.()}},"execute");export{nt as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var oe=Object.defineProperty;var E=(o,e)=>oe(o,"name",{value:e,configurable:!0});import{createRequire as ie}from"node:module";import{aG as z,E as k,j as S,q as W,y as ce,m as ae,s as pe}from"./bin.js";import{projectGraphToDot as he}from"@visulima/task-runner";import{Box as i,Text as t,ScrollView as ue,ScrollBar as fe,useApp as ge,useWindowSize as me,useInput as xe,Dialog as be,render as ye}from"@visulima/tui";import we,{useSyncExternalStore as ve,useState as O,useRef as q,useMemo as _,useCallback as U,useEffect as Ce}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";const le=ie(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,de=E(o=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[e,l]=I.versions.node.split(".").map(Number);if(e>22||e===22&&l>=3||e===20&&l>=16)return I.getBuiltinModule(o)}return le(o)},"__cjs_getBuiltinModule"),{writeFileSync:se}=de("node:fs");var Ae=Object.defineProperty,$=E((o,e)=>Ae(o,"name",{value:e,configurable:!0}),"n");const ke=$(o=>{const e=new Map;for(const[l,d]of Object.entries(o.dependencies))for(const c of d){const s=e.get(c.target)??[];s.push(l),e.set(c.target,s)}return Object.values(o.nodes).map(l=>({deps:o.dependencies[l.name]??[],name:l.name,reverseDeps:e.get(l.name)??[],type:l.type})).sort((l,d)=>l.type!==d.type?l.type==="application"?-1:1:l.name.localeCompare(d.name))},"buildNodes"),Ee=$((o,e,l)=>{let d=o;if(e==="app"?d=d.filter(c=>c.type==="application"):e==="lib"&&(d=d.filter(c=>c.type!=="application")),l){const c=l.toLowerCase();d=d.filter(s=>s.name.toLowerCase().includes(c))}return d},"filterNodes");class Me{static{E(this,"GraphStore")}static{$(this,"GraphStore")}#e;#n=new Set;#r;constructor(e){this.#r=e;const l=ke(e);this.#e={allNodes:l,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=$(()=>this.#e,"getSnapshot");subscribe=$(e=>(this.#n.add(e),()=>{this.#n.delete(e)}),"subscribe");getFilteredNodes(){return Ee(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(c=>c.type==="application").length,l=this.#e.allNodes.length,d=Object.values(this.#r.dependencies).reduce((c,s)=>c+s.length,0);return{apps:e,deps:d,libs:l-e,total:l}}setSelectedIndex(e){const l=this.getFilteredNodes(),d=l.length===0?-1:Math.max(0,Math.min(e,l.length-1));d!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:d})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#t({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#t(e){this.#e=e;for(const l of this.#n)try{l()}catch{}}}var Te=Object.defineProperty,Se=E((o,e)=>Te(o,"name",{value:e,configurable:!0}),"p");const je=Se(({focused:o,node:e,scrollRef:l})=>{const d=o?"white":"gray";if(!e)return n(i,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(t,{dimColor:!0,children:"No project selected"})});const c=e.type==="application",s=c?"yellow":"cyan",u=c?"Application":"Library";return n(i,{borderColor:d,borderStyle:"single",borderTopRightTitle:` ${u} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:r(ue,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"DEPENDS ON"}),r(t,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.deps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"cyan",children:"→"}),n(t,{children:a.target}),a.type!=="static"&&r(t,{dimColor:!0,children:["(",a.type,")"]})]},a.target))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"REQUIRED BY"}),r(t,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No reverse dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"magenta",children:"←"}),n(t,{children:a})]},a))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"INFO"})]}),r(i,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Type:"})}),n(t,{color:s,children:u})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Dependencies:"})}),n(t,{children:String(e.deps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Required by:"})}),n(t,{children:String(e.reverseDeps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Connectivity:"})}),n(t,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var De=Object.defineProperty,B=E((o,e)=>De(o,"name",{value:e,configurable:!0}),"g");const Ne=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],Y=B(({isSelected:o,node:e})=>{const l=e.type==="application",d=l?"yellow":"cyan",c=l?"app":"lib";return r(i,{flexShrink:0,height:1,children:[r(t,{children:[o?"▶":" "," "]}),n(i,{flexGrow:1,children:n(t,{bold:o,inverse:o,wrap:"truncate",children:e.name})}),r(t,{color:d,children:[" ",c]}),r(t,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),X=B(({count:o,label:e})=>r(i,{flexShrink:0,height:1,marginTop:1,children:[r(t,{dimColor:!0,children:["▼"," "]}),n(t,{bold:!0,color:"white",children:e.toUpperCase()}),r(t,{dimColor:!0,children:[" ","(",o,")"]})]}),"TypeHeader"),Ie=B(({filterActive:o,filterText:e,filterType:l,focused:d,nodes:c,scrollOffset:s,selectedIndex:u,stats:a,viewportHeight:y})=>{const g=d?"white":"gray",v=c.filter(w=>w.type==="application"),h=c.filter(w=>w.type!=="application"),f=[];let x=0;if(v.length>0){f.push(n(X,{count:v.length,label:"Applications"},"hdr-apps"));for(const w of v){const A=x;f.push(n(Y,{isSelected:A===u,node:w},w.name)),x++}}if(h.length>0){f.push(n(X,{count:h.length,label:"Libraries"},"hdr-libs"));for(const w of h){const A=x;f.push(n(Y,{isSelected:A===u,node:w},w.name)),x++}}let C=0;v.length>0&&(C+=2+v.length),h.length>0&&(C+=2+h.length);const M=C>y&&y>0;return r(i,{borderColor:g,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[r(i,{flexShrink:0,gap:1,paddingX:1,children:[n(t,{bold:!0,inverse:!0,children:" VIS "}),r(t,{wrap:"truncate",children:[a.total," ","packages"]}),r(t,{dimColor:!0,children:["(",a.apps," ","apps,"," ",a.libs," ","libs,"," ",a.deps," ","deps)"]})]}),n(i,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ne.map(w=>{const A=l===w.key;return r(i,{children:[n(t,{dimColor:!A,children:"["}),n(t,{bold:A,color:A?"cyan":"gray",children:w.shortcut}),n(t,{dimColor:!A,children:"]"}),r(t,{color:A?"white":"gray",children:[" ",w.label]})]},w.key)})}),o&&r(i,{flexShrink:0,paddingX:1,children:[n(t,{bold:!0,color:"white",children:"/ "}),n(t,{children:e}),n(t,{inverse:!0,children:" "})]}),r(i,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(i,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(i,{flexDirection:"column",marginTop:-s,children:f})}),M&&n(i,{flexShrink:0,marginLeft:1,marginRight:1,children:n(fe,{contentHeight:C,placement:"inset",scrollOffset:s,style:"block",viewportHeight:y})})]})]})},"ProjectListPanel");var $e=Object.defineProperty,Pe=E((o,e)=>$e(o,"name",{value:e,configurable:!0}),"M$1");const Le=100,Oe=40,Be=10,J={1:"all",2:"app",3:"lib"},Re=Pe(({autoExitSeconds:o=0,store:e})=>{const{exit:l}=ge(),{columns:d,rows:c}=me(),s=ve(e.subscribe,e.getSnapshot),[u,a]=O(!1),y=q(null),g=q(null),[v,h]=O(0),[f,x]=O(!1),C=_(()=>e.getFilteredNodes(),[s.allNodes,s.filterType,s.filterText]),M=_(()=>e.getStats(),[s.allNodes]),w=C[s.selectedIndex]??null,A=U(m=>{const p=C.filter(T=>T.type==="application"),b=C.filter(T=>T.type!=="application");let j=0,L=0;if(p.length>0){j+=2;for(let T=0;T<p.length;T++){if(L===m)return j;j+=1,L++}}if(b.length>0){j+=2;for(let T=0;T<b.length;T++){if(L===m)return j;j+=1,L++}}return j},[C]),P=Math.max(1,c-8-(s.filterActive?1:0)),N=U(m=>{const p=A(m);h(b=>p>b+P-2?Math.max(0,p-P+2):p<b+1?Math.max(0,p-1):b)},[A,P]);if(Ce(()=>{g.current?.scrollToTop()},[w?.name]),xe((m,p)=>{if(m==="c"&&p.ctrl){l();return}if(!f){if(u){p.escape||m==="?"?a(!1):m==="q"?(a(!1),x(!0)):p.downArrow||m==="j"?y.current?.scrollBy(1):(p.upArrow||m==="k")&&y.current?.scrollBy(-1);return}if(m==="?"){a(!0);return}if(m==="q"){x(!0);return}if(p.tab){e.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(J[m]){e.setFilterType(J[m]);return}if(s.filterActive){if(p.escape){e.setFilterActive(!1);return}if(p.return){e.setFilterActive(!1);return}if(p.backspace){e.setFilter(s.filterText.slice(0,-1));return}if(m&&!p.ctrl&&!p.meta){e.setFilter(s.filterText+m);return}return}if(s.focusedPanel==="list"){if(C.length===0){m==="/"&&e.setFilterActive(!0);return}if(p.downArrow||m==="j"){const b=Math.min(s.selectedIndex+1,C.length-1);e.setSelectedIndex(b),N(b);return}if(p.upArrow||m==="k"){const b=Math.max(s.selectedIndex-1,0);e.setSelectedIndex(b),N(b);return}if(p.pageDown){const b=Math.min(s.selectedIndex+10,C.length-1);e.setSelectedIndex(b),N(b);return}if(p.pageUp){const b=Math.max(s.selectedIndex-10,0);e.setSelectedIndex(b),N(b);return}if(p.home){e.setSelectedIndex(0),h(0);return}if(p.end){const b=C.length-1;e.setSelectedIndex(b),N(b);return}if(m==="/"){e.setFilterActive(!0);return}if(p.rightArrow){e.setFocusedPanel("detail");return}return}if(s.focusedPanel==="detail"){if(p.escape||p.leftArrow){e.setFocusedPanel("list");return}if(p.downArrow||m==="j"){g.current?.scrollBy(1);return}if(p.upArrow||m==="k"){g.current?.scrollBy(-1);return}if(p.pageDown){g.current?.scrollBy(10);return}if(p.pageUp){g.current?.scrollBy(-10);return}if(p.home){g.current?.scrollToTop();return}p.end&&g.current?.scrollToBottom()}}},{isActive:!0}),d<Oe||c<Be)return n(i,{alignItems:"center",height:c,justifyContent:"center",width:d,children:r(t,{color:"yellow",children:["Terminal too small (",d,"x",c,")"]})});const ne=d>=Le,R=n(i,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(i,{flexWrap:"wrap",gap:2,paddingX:1,children:[r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"q"}),n(t,{dimColor:!0,children:"QUIT"})]},"q"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"?"}),n(t,{dimColor:!0,children:"HELP"})]},"?"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"↑↓"}),n(t,{dimColor:!0,children:"NAV"})]},"nav"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"1-3 /"}),n(t,{dimColor:!0,children:"FILTER"})]},"f"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"Tab"}),n(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),F=r(be,{footer:r(t,{dimColor:!0,children:[n(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n(t,{bold:!0,color:"white",children:"?"}),"/",n(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:u,width:52,children:[r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),n(t,{dimColor:!0,children:" Move up"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),n(t,{dimColor:!0,children:" Move down"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Tab"]}),n(t,{dimColor:!0,children:" Switch panel"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),n(t,{dimColor:!0,children:" Focus detail/list"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),n(t,{dimColor:!0,children:" Jump 10 items"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Home/End"]}),n(t,{dimColor:!0,children:" Jump to start/end"})]})]}),r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"FILTERS"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","1"]}),n(t,{dimColor:!0,children:" All"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","2"]}),n(t,{dimColor:!0,children:" Apps only"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","3"]}),n(t,{dimColor:!0,children:" Libraries only"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","/"]}),n(t,{dimColor:!0,children:" Text filter"})]})]}),r(i,{flexDirection:"column",children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"ACTIONS"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","q"]}),n(t,{dimColor:!0,children:" Quit"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","?"]}),n(t,{dimColor:!0,children:" Toggle help"})]})]})]}),H=n(Ie,{filterActive:s.filterActive,filterText:s.filterText,filterType:s.filterType,focused:s.focusedPanel==="list",nodes:C,scrollOffset:v,selectedIndex:s.selectedIndex,stats:M,viewportHeight:P}),G=n(je,{focused:s.focusedPanel==="detail",node:w,scrollRef:g});if(ne){const m=Math.floor(d*.35);return r(i,{flexDirection:"column",height:c,width:d,children:[r(i,{flexDirection:"row",flexGrow:1,children:[n(i,{flexGrow:1,children:H}),n(i,{width:m,children:G})]}),R,n(z,{autoExitSeconds:o??3,onCancel:E(()=>{x(!1)},"onCancel"),visible:f}),F]})}const re=Math.floor(c*.55);return r(i,{flexDirection:"column",height:c,width:d,children:[n(i,{height:re,children:H}),n(i,{flexGrow:1,children:G}),R,n(z,{autoExitSeconds:o??3,onCancel:E(()=>{x(!1)},"onCancel"),visible:f}),F]})},"VisGraphApp");var V=Object.freeze,ee=Object.defineProperty,D=E((o,e)=>ee(o,"name",{value:e,configurable:!0}),"x"),Fe=E((o,e)=>V(ee(o,"raw",{value:V(e||o.slice())})),"C");const te=D((o,e,l,d,c,s,u,a)=>{const y=l?k("└── "):k("├── "),g=c.has(o),v=g?k(" (*)"):"",h=d.get(o),f=h?.type==="application"?S(o):o;if(s.push(`${e}${y}${f}${v}`),g)return;c.add(o);const x=h?.deps??[],C=l?`${e} `:`${e}${k("│")} `;if(a>=u&&x.length>0){s.push(`${C}${k(`... ${x.length} more`)}`);return}for(let M=0;M<x.length;M++){const w=x[M];w&&te(w.target,C,M===x.length-1,d,c,s,u,a+1)}},"printDepsTree"),Q=D((o,e,l,d,c,s)=>{const u=e.get(o),a=u?.type==="application"?S(o):o;d.push(`${s}${a}`),l.add(o);const y=u?.deps??[];if(y.length===0){d.push(`${s} ${k("(no dependencies)")}`);return}if(c<=0){d.push(`${s} ${k(`... ${y.length} dependencies`)}`);return}for(let g=0;g<y.length;g++){const v=y[g];v&&te(v.target,s,g===y.length-1,e,l,d,c,1)}},"printRootProject"),K=D((o,e)=>{const l=new Map;for(const[h,f]of Object.entries(o.nodes))l.set(h,{deps:(o.dependencies[h]??[]).map(x=>({target:x.target,type:x.type})),name:h,type:f.type});const d=[],c=[];for(const[h,f]of l)f.type==="application"?d.push(h):c.push(h);d.sort(),c.sort();const s=d.length+c.length,u=Object.values(o.dependencies).reduce((h,f)=>h+f.length,0),a=[S("Project Dependency Graph"),""];if(d.length>0){a.push(` ${S(W(`Applications (${d.length})`))}`,"");for(const h of d)Q(h,l,new Set,a,e," "),a.push("")}if(c.length>0){a.push(` ${S(W(`Libraries (${c.length})`))}`,"");for(const h of c)Q(h,l,new Set,a,e," "),a.push("")}const y=process.stdout.columns||80;a.push(k("─".repeat(Math.min(y,60)))),a.push(`${S(String(s))} packages ${k("·")} ${S(String(u))} dependencies ${k("·")} ${S(String(d.length))} apps${k(",")} ${S(String(c.length))} libraries`);const g=new Set;let v=!1;for(const h of[...d,...c]){const f=l.get(h)?.deps??[];for(const x of f)g.has(x.target)&&(v=!0),g.add(x.target);g.add(h)}return v&&a.push(k("(*) = already shown above")),a.join(`
|
|
2
|
-
`)},"projectGraphToAscii"),
|
|
1
|
+
var ie=Object.defineProperty;var k=(o,e)=>ie(o,"name",{value:e,configurable:!0});import{createRequire as le}from"node:module";import{aJ as G,E,j as S,q as z,y as ae,m as pe,s as he}from"./bin.js";import{projectGraphToDot as ue}from"@visulima/task-runner";import{render as fe}from"@visulima/tui";import ge,{useSyncExternalStore as me,useState as $,useRef as W,useMemo as P,useCallback as q,useEffect as xe}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{Box as i}from"@visulima/tui/components/box";import{Dialog as be}from"@visulima/tui/components/dialog";import{Text as t}from"@visulima/tui/components/text";import{useApp as ye}from"@visulima/tui/hooks/use-app";import{useInput as we}from"@visulima/tui/hooks/use-input";import{useWindowSize as ve}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Ce}from"@visulima/tui/components/scroll-view";import{ScrollBar as Ae}from"@visulima/tui/components/scroll-bar";const de=le(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=k(o=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[e,l]=N.versions.node.split(".").map(Number);if(e>22||e===22&&l>=3||e===20&&l>=16)return N.getBuiltinModule(o)}return de(o)},"__cjs_getBuiltinModule"),{writeFileSync:ce}=se("node:fs");var Ee=Object.defineProperty,T=k((o,e)=>Ee(o,"name",{value:e,configurable:!0}),"l");const ke={application:0,service:1,tool:2,library:3},_=T(o=>ke[o]??Number.MAX_SAFE_INTEGER,"typeRank"),Me=T(o=>{const e=new Map;for(const[l,d]of Object.entries(o.dependencies))for(const c of d){const s=e.get(c.target)??[];s.push(l),e.set(c.target,s)}return Object.values(o.nodes).map(l=>({deps:o.dependencies[l.name]??[],name:l.name,reverseDeps:e.get(l.name)??[],type:l.type})).sort((l,d)=>l.type!==d.type?_(l.type)-_(d.type):l.name.localeCompare(d.name))},"buildNodes"),Se=T((o,e,l)=>{let d=o;if(e==="app"?d=d.filter(c=>c.type==="application"):e==="lib"&&(d=d.filter(c=>c.type!=="application")),l){const c=l.toLowerCase();d=d.filter(s=>s.name.toLowerCase().includes(c))}return d},"filterNodes");class Te{static{k(this,"GraphStore")}static{T(this,"GraphStore")}#e;#n=new Set;#r;constructor(e){this.#r=e;const l=Me(e);this.#e={allNodes:l,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=T(()=>this.#e,"getSnapshot");subscribe=T(e=>(this.#n.add(e),()=>{this.#n.delete(e)}),"subscribe");getFilteredNodes(){return Se(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(c=>c.type==="application").length,l=this.#e.allNodes.length,d=Object.values(this.#r.dependencies).reduce((c,s)=>c+s.length,0);return{apps:e,deps:d,libs:l-e,total:l}}setSelectedIndex(e){const l=this.getFilteredNodes(),d=l.length===0?-1:Math.max(0,Math.min(e,l.length-1));d!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:d})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#t({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#t(e){this.#e=e;for(const l of this.#n)try{l()}catch{}}}var je=Object.defineProperty,De=k((o,e)=>je(o,"name",{value:e,configurable:!0}),"p");const Ne=De(({focused:o,node:e,scrollRef:l})=>{const d=o?"white":"gray";if(!e)return n(i,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(t,{dimColor:!0,children:"No project selected"})});const c=e.type==="application",s=c?"yellow":"cyan",f=c?"Application":"Library";return n(i,{borderColor:d,borderStyle:"single",borderTopRightTitle:` ${f} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:r(Ce,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"DEPENDS ON"}),r(t,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.deps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"cyan",children:"→"}),n(t,{children:a.target}),a.type!=="static"&&r(t,{dimColor:!0,children:["(",a.type,")"]})]},a.target))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"REQUIRED BY"}),r(t,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No reverse dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"magenta",children:"←"}),n(t,{children:a})]},a))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"INFO"})]}),r(i,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Type:"})}),n(t,{color:s,children:f})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Dependencies:"})}),n(t,{children:String(e.deps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Required by:"})}),n(t,{children:String(e.reverseDeps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Connectivity:"})}),n(t,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var Ie=Object.defineProperty,L=k((o,e)=>Ie(o,"name",{value:e,configurable:!0}),"m");const $e=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],U=L(({isSelected:o,node:e})=>{const l=e.type==="application",d=l?"yellow":"cyan",c=l?"app":"lib";return r(i,{flexShrink:0,height:1,children:[r(t,{children:[o?"▶":" "," "]}),n(i,{flexGrow:1,children:n(t,{bold:o,inverse:o,wrap:"truncate",children:e.name})}),r(t,{color:d,children:[" ",c]}),r(t,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),Y=L(({count:o,label:e})=>r(i,{flexShrink:0,height:1,marginTop:1,children:[r(t,{dimColor:!0,children:["▼"," "]}),n(t,{bold:!0,color:"white",children:e.toUpperCase()}),r(t,{dimColor:!0,children:[" ","(",o,")"]})]}),"TypeHeader"),Pe=L(({filterActive:o,filterText:e,filterType:l,focused:d,nodes:c,scrollOffset:s,selectedIndex:f,stats:a,viewportHeight:y})=>{const m=d?"white":"gray",v=c.filter(w=>w.type==="application"),h=c.filter(w=>w.type!=="application"),g=[];let x=0;if(v.length>0){g.push(n(Y,{count:v.length,label:"Applications"},"hdr-apps"));for(const w of v){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}if(h.length>0){g.push(n(Y,{count:h.length,label:"Libraries"},"hdr-libs"));for(const w of h){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}let C=0;v.length>0&&(C+=2+v.length),h.length>0&&(C+=2+h.length);const M=C>y&&y>0;return r(i,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[r(i,{flexShrink:0,gap:1,paddingX:1,children:[n(t,{bold:!0,inverse:!0,children:" VIS "}),r(t,{wrap:"truncate",children:[a.total," ","packages"]}),r(t,{dimColor:!0,children:["(",a.apps," ","apps,"," ",a.libs," ","libs,"," ",a.deps," ","deps)"]})]}),n(i,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:$e.map(w=>{const A=l===w.key;return r(i,{children:[n(t,{dimColor:!A,children:"["}),n(t,{bold:A,color:A?"cyan":"gray",children:w.shortcut}),n(t,{dimColor:!A,children:"]"}),r(t,{color:A?"white":"gray",children:[" ",w.label]})]},w.key)})}),o&&r(i,{flexShrink:0,paddingX:1,children:[n(t,{bold:!0,color:"white",children:"/ "}),n(t,{children:e}),n(t,{inverse:!0,children:" "})]}),r(i,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(i,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(i,{flexDirection:"column",marginTop:-s,children:g})}),M&&n(i,{flexShrink:0,marginLeft:1,marginRight:1,children:n(Ae,{contentHeight:C,placement:"inset",scrollOffset:s,style:"block",viewportHeight:y})})]})]})},"ProjectListPanel");var Le=Object.defineProperty,Oe=k((o,e)=>Le(o,"name",{value:e,configurable:!0}),"E");const Re=100,Be=40,Fe=10,X={1:"all",2:"app",3:"lib"},He=Oe(({autoExitSeconds:o=0,store:e})=>{const{exit:l}=ye(),{columns:d,rows:c}=ve(),s=me(e.subscribe,e.getSnapshot),[f,a]=$(!1),y=W(null),m=W(null),[v,h]=$(0),[g,x]=$(!1),C=P(()=>e.getFilteredNodes(),[s.allNodes,s.filterType,s.filterText]),M=P(()=>e.getStats(),[s.allNodes]),w=C[s.selectedIndex]??null,A=P(()=>{let u=0,p=0;for(const b of C)b.type==="application"?u+=1:p+=1;return{appsCount:u,libsCount:p}},[C]),O=q(u=>{const{appsCount:p,libsCount:b}=A;if(u<p)return(p>0?2:0)+u;const re=p>0?2+p:0,oe=b>0?2:0;return re+oe+(u-p)},[A]),I=Math.max(1,c-8-(s.filterActive?1:0)),D=q(u=>{const p=O(u);h(b=>p>b+I-2?Math.max(0,p-I+2):p<b+1?Math.max(0,p-1):b)},[O,I]);if(xe(()=>{m.current?.scrollToTop()},[w?.name]),we((u,p)=>{if(u==="c"&&p.ctrl){l();return}if(!g){if(f){p.escape||u==="?"?a(!1):u==="q"?(a(!1),x(!0)):p.downArrow||u==="j"?y.current?.scrollBy(1):(p.upArrow||u==="k")&&y.current?.scrollBy(-1);return}if(u==="?"){a(!0);return}if(u==="q"){x(!0);return}if(p.tab){e.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(X[u]){e.setFilterType(X[u]);return}if(s.filterActive){if(p.escape){e.setFilterActive(!1);return}if(p.return){e.setFilterActive(!1);return}if(p.backspace){e.setFilter(s.filterText.slice(0,-1));return}if(u&&!p.ctrl&&!p.meta){e.setFilter(s.filterText+u);return}return}if(s.focusedPanel==="list"){if(C.length===0){u==="/"&&e.setFilterActive(!0);return}if(p.downArrow||u==="j"){const b=Math.min(s.selectedIndex+1,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.upArrow||u==="k"){const b=Math.max(s.selectedIndex-1,0);e.setSelectedIndex(b),D(b);return}if(p.pageDown){const b=Math.min(s.selectedIndex+10,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.pageUp){const b=Math.max(s.selectedIndex-10,0);e.setSelectedIndex(b),D(b);return}if(p.home){e.setSelectedIndex(0),h(0);return}if(p.end){const b=C.length-1;e.setSelectedIndex(b),D(b);return}if(u==="/"){e.setFilterActive(!0);return}if(p.rightArrow){e.setFocusedPanel("detail");return}return}if(s.focusedPanel==="detail"){if(p.escape||p.leftArrow){e.setFocusedPanel("list");return}if(p.downArrow||u==="j"){m.current?.scrollBy(1);return}if(p.upArrow||u==="k"){m.current?.scrollBy(-1);return}if(p.pageDown){m.current?.scrollBy(10);return}if(p.pageUp){m.current?.scrollBy(-10);return}if(p.home){m.current?.scrollToTop();return}p.end&&m.current?.scrollToBottom()}}},{isActive:!0}),d<Be||c<Fe)return n(i,{alignItems:"center",height:c,justifyContent:"center",width:d,children:r(t,{color:"yellow",children:["Terminal too small (",d,"x",c,")"]})});const te=d>=Re,R=n(i,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(i,{flexWrap:"wrap",gap:2,paddingX:1,children:[r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"q"}),n(t,{dimColor:!0,children:"QUIT"})]},"q"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"?"}),n(t,{dimColor:!0,children:"HELP"})]},"?"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"↑↓"}),n(t,{dimColor:!0,children:"NAV"})]},"nav"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"1-3 /"}),n(t,{dimColor:!0,children:"FILTER"})]},"f"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"Tab"}),n(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),B=r(be,{footer:r(t,{dimColor:!0,children:[n(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n(t,{bold:!0,color:"white",children:"?"}),"/",n(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:f,width:52,children:[r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),n(t,{dimColor:!0,children:" Move up"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),n(t,{dimColor:!0,children:" Move down"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Tab"]}),n(t,{dimColor:!0,children:" Switch panel"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),n(t,{dimColor:!0,children:" Focus detail/list"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),n(t,{dimColor:!0,children:" Jump 10 items"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Home/End"]}),n(t,{dimColor:!0,children:" Jump to start/end"})]})]}),r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"FILTERS"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","1"]}),n(t,{dimColor:!0,children:" All"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","2"]}),n(t,{dimColor:!0,children:" Apps only"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","3"]}),n(t,{dimColor:!0,children:" Libraries only"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","/"]}),n(t,{dimColor:!0,children:" Text filter"})]})]}),r(i,{flexDirection:"column",children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"ACTIONS"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","q"]}),n(t,{dimColor:!0,children:" Quit"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","?"]}),n(t,{dimColor:!0,children:" Toggle help"})]})]})]}),F=n(Pe,{filterActive:s.filterActive,filterText:s.filterText,filterType:s.filterType,focused:s.focusedPanel==="list",nodes:C,scrollOffset:v,selectedIndex:s.selectedIndex,stats:M,viewportHeight:I}),H=n(Ne,{focused:s.focusedPanel==="detail",node:w,scrollRef:m});if(te){const u=Math.floor(d*.35);return r(i,{flexDirection:"column",height:c,width:d,children:[r(i,{flexDirection:"row",flexGrow:1,children:[n(i,{flexGrow:1,children:F}),n(i,{width:u,children:H})]}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})}const ne=Math.floor(c*.55);return r(i,{flexDirection:"column",height:c,width:d,children:[n(i,{height:ne,children:F}),n(i,{flexGrow:1,children:H}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})},"VisGraphApp");var J=Object.freeze,Z=Object.defineProperty,j=k((o,e)=>Z(o,"name",{value:e,configurable:!0}),"x"),Ge=k((o,e)=>J(Z(o,"raw",{value:J(e||o.slice())})),"C");const ee=j((o,e,l,d,c,s,f,a)=>{const y=l?E("└── "):E("├── "),m=c.has(o),v=m?E(" (*)"):"",h=d.get(o),g=h?.type==="application"?S(o):o;if(s.push(`${e}${y}${g}${v}`),m)return;c.add(o);const x=h?.deps??[],C=l?`${e} `:`${e}${E("│")} `;if(a>=f&&x.length>0){s.push(`${C}${E(`... ${x.length} more`)}`);return}for(let M=0;M<x.length;M++){const w=x[M];w&&ee(w.target,C,M===x.length-1,d,c,s,f,a+1)}},"printDepsTree"),V=j((o,e,l,d,c,s)=>{const f=e.get(o),a=f?.type==="application"?S(o):o;d.push(`${s}${a}`),l.add(o);const y=f?.deps??[];if(y.length===0){d.push(`${s} ${E("(no dependencies)")}`);return}if(c<=0){d.push(`${s} ${E(`... ${y.length} dependencies`)}`);return}for(let m=0;m<y.length;m++){const v=y[m];v&&ee(v.target,s,m===y.length-1,e,l,d,c,1)}},"printRootProject"),Q=j((o,e)=>{const l=new Map;for(const[h,g]of Object.entries(o.nodes))l.set(h,{deps:(o.dependencies[h]??[]).map(x=>({target:x.target,type:x.type})),name:h,type:g.type});const d=[],c=[];for(const[h,g]of l)g.type==="application"?d.push(h):c.push(h);d.sort(),c.sort();const s=d.length+c.length,f=Object.values(o.dependencies).reduce((h,g)=>h+g.length,0),a=[S("Project Dependency Graph"),""];if(d.length>0){a.push(` ${S(z(`Applications (${d.length})`))}`,"");for(const h of d)V(h,l,new Set,a,e," "),a.push("")}if(c.length>0){a.push(` ${S(z(`Libraries (${c.length})`))}`,"");for(const h of c)V(h,l,new Set,a,e," "),a.push("")}const y=process.stdout.columns||80;a.push(E("─".repeat(Math.min(y,60)))),a.push(`${S(String(s))} packages ${E("·")} ${S(String(f))} dependencies ${E("·")} ${S(String(d.length))} apps${E(",")} ${S(String(c.length))} libraries`);const m=new Set;let v=!1;for(const h of[...d,...c]){const g=l.get(h)?.deps??[];for(const x of g)m.has(x.target)&&(v=!0),m.add(x.target);m.add(h)}return v&&a.push(E("(*) = already shown above")),a.join(`
|
|
2
|
+
`)},"projectGraphToAscii"),ze=j(o=>{const e=Object.values(o.nodes).map(l=>({name:l.name,type:l.type}));return{edges:Object.values(o.dependencies).flat(),nodes:e}},"projectGraphToJson");var K;const We=j(o=>{const e=Object.values(o.nodes).map(f=>({name:f.name,type:f.type})),l=[];for(const f of Object.values(o.dependencies))for(const a of f)l.push({source:a.source,target:a.target,type:a.type});const d=e.filter(f=>f.type==="application"),c=e.filter(f=>f.type!=="application"),s={apps:d.length,edges:l,libs:c.length,nodes:e};return String.raw(K||(K=Ge([`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -425,4 +425,4 @@ nodes.forEach(n => {
|
|
|
425
425
|
});
|
|
426
426
|
<\/script>
|
|
427
427
|
</body>
|
|
428
|
-
</html>`])),s.apps,s.libs,s.edges.length,JSON.stringify(s).replaceAll("</",String.raw`<\/`))},"projectGraphToHtml"),
|
|
428
|
+
</html>`])),s.apps,s.libs,s.edges.length,JSON.stringify(s).replaceAll("</",String.raw`<\/`))},"projectGraphToHtml"),it=j(async({logger:o,options:e,visConfig:l,workspaceRoot:d})=>{if(!d)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const c=d,{packageJsons:s,workspace:f}=ae(c,l),a=pe(c,f,s),y=!!process.stdout.isTTY&&!he,m=e.format??(y?"tui":"ascii"),v=e.output,h=e.depth??1/0;let g;switch(m){case"dot":{g=ue(a);break}case"html":{g=We(a);break}case"json":{g=JSON.stringify(ze(a),void 0,2);break}case"tui":{if(!y){g=Q(a,h);break}const x=l?.tui?.autoExit===!0?3:typeof l?.tui?.autoExit=="number"?l.tui.autoExit:0;process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const C=setInterval(()=>{},1e3),M=new Te(a);await fe(ge.createElement(He,{autoExitSeconds:x,store:M}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(C);return}default:g=Q(a,h)}v?(ce(v,g,"utf8"),o.info(`Graph written to ${v}`)):o.info(g)},"execute");export{it as default};
|