@visulima/vis 1.0.0-alpha.7 → 1.0.0-alpha.9
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 +107 -47
- package/LICENSE.md +44 -1
- package/README.md +56 -0
- package/dist/bin.js +1 -991
- package/dist/config.d.ts +1073 -68
- package/dist/config.js +1 -1
- package/dist/generate/index.d.ts +155 -30
- package/dist/packem_chunks/handler.js +1 -0
- package/dist/packem_chunks/handler10.js +1 -0
- package/dist/packem_chunks/handler11.js +1 -0
- package/dist/packem_chunks/handler12.js +153 -0
- package/dist/packem_chunks/handler13.js +1 -0
- package/dist/packem_chunks/handler14.js +3 -0
- package/dist/packem_chunks/handler15.js +1 -0
- package/dist/packem_chunks/handler16.js +2 -0
- package/dist/packem_chunks/handler17.js +7 -0
- package/dist/packem_chunks/handler18.js +1 -0
- package/dist/packem_chunks/handler19.js +19 -0
- package/dist/packem_chunks/handler2.js +1 -0
- package/dist/packem_chunks/handler20.js +428 -0
- package/dist/packem_chunks/handler21.js +22 -0
- package/dist/packem_chunks/handler22.js +3 -0
- package/dist/packem_chunks/handler23.js +5 -0
- package/dist/packem_chunks/handler24.js +1 -0
- package/dist/packem_chunks/handler25.js +20 -0
- package/dist/packem_chunks/handler26.js +1 -0
- package/dist/packem_chunks/handler27.js +1 -0
- package/dist/packem_chunks/handler28.js +1 -0
- package/dist/packem_chunks/handler29.js +2 -0
- package/dist/packem_chunks/handler3.js +2 -0
- package/dist/packem_chunks/handler30.js +22 -0
- package/dist/packem_chunks/handler31.js +1 -0
- package/dist/packem_chunks/handler32.js +1 -0
- package/dist/packem_chunks/handler33.js +37 -0
- package/dist/packem_chunks/handler34.js +3 -0
- package/dist/packem_chunks/handler35.js +23 -0
- package/dist/packem_chunks/handler36.js +5 -0
- package/dist/packem_chunks/handler37.js +27 -0
- package/dist/packem_chunks/handler38.js +1 -0
- package/dist/packem_chunks/handler39.js +2 -0
- package/dist/packem_chunks/handler4.js +5 -0
- package/dist/packem_chunks/handler40.js +1 -0
- package/dist/packem_chunks/handler41.js +5 -0
- package/dist/packem_chunks/handler42.js +1 -0
- package/dist/packem_chunks/handler43.js +24 -0
- package/dist/packem_chunks/handler44.js +3 -0
- package/dist/packem_chunks/handler45.js +1 -0
- package/dist/packem_chunks/handler5.js +4 -0
- package/dist/packem_chunks/handler6.js +2 -0
- package/dist/packem_chunks/handler7.js +24 -0
- package/dist/packem_chunks/handler8.js +6 -0
- package/dist/packem_chunks/handler9.js +8 -0
- package/dist/packem_shared/VisUpdateApp-BBx3idMI.js +1 -0
- package/dist/packem_shared/ai-analysis-DDqXRFxY.js +67 -0
- package/dist/packem_shared/bin-BaZZ32BK.js +93 -0
- package/dist/packem_shared/cache-directory-DL8hfXeG.js +1 -0
- package/dist/packem_shared/catalog-CuSpuB_R.js +12 -0
- package/dist/packem_shared/dependency-scan-BoLG2Fez.js +1 -0
- package/dist/packem_shared/docker-BcfqH4Av.js +2 -0
- package/dist/packem_shared/flakiness-DSIHZGBT.js +1 -0
- package/dist/packem_shared/otelPlugin-DxyvBcXO.js +1 -0
- package/dist/packem_shared/runtime-check-CGHal8SO.js +1 -0
- package/dist/packem_shared/selectors-CfH9ZY08.js +3 -0
- package/dist/packem_shared/symbols-CIMw60-G.js +1 -0
- package/dist/packem_shared/toolchain-C3ZG0o_X.js +5 -0
- package/dist/packem_shared/typosquats-Bpq4zcWL.js +1 -0
- package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
- package/index.js +555 -727
- package/package.json +29 -19
- package/schemas/project.schema.json +1 -1
- package/schemas/vis-config.schema.json +47 -1
- package/dist/ai-analysis.d.ts +0 -26
- package/dist/ai-cache.d.ts +0 -21
- package/dist/ai-types.d.ts +0 -16
- package/dist/audit-config.d.ts +0 -24
- package/dist/bin.d.ts +0 -1
- package/dist/cache-directory.d.ts +0 -73
- package/dist/catalog.d.ts +0 -136
- package/dist/codeowners.d.ts +0 -30
- package/dist/commands/action-graph.d.ts +0 -8
- package/dist/commands/add.d.ts +0 -3
- package/dist/commands/affected.d.ts +0 -3
- package/dist/commands/ai.d.ts +0 -3
- package/dist/commands/analyze.d.ts +0 -3
- package/dist/commands/approve-builds.d.ts +0 -3
- package/dist/commands/audit.d.ts +0 -23
- package/dist/commands/cache.d.ts +0 -86
- package/dist/commands/check.d.ts +0 -3
- package/dist/commands/ci.d.ts +0 -19
- package/dist/commands/clean.d.ts +0 -3
- package/dist/commands/create/discovery.d.ts +0 -42
- package/dist/commands/create/index.d.ts +0 -13
- package/dist/commands/create/prompts.d.ts +0 -31
- package/dist/commands/create/random-name.d.ts +0 -15
- package/dist/commands/create/templates/builtin.d.ts +0 -15
- package/dist/commands/create/templates/generator.d.ts +0 -14
- package/dist/commands/create/templates/index.d.ts +0 -13
- package/dist/commands/create/templates/monorepo.d.ts +0 -16
- package/dist/commands/create/templates/remote.d.ts +0 -41
- package/dist/commands/create/templates/types.d.ts +0 -46
- package/dist/commands/create/utils.d.ts +0 -42
- package/dist/commands/dedupe.d.ts +0 -3
- package/dist/commands/devcontainer.d.ts +0 -3
- package/dist/commands/dlx.d.ts +0 -3
- package/dist/commands/docker.d.ts +0 -22
- package/dist/commands/doctor.d.ts +0 -15
- package/dist/commands/exec.d.ts +0 -3
- package/dist/commands/generate.d.ts +0 -10
- package/dist/commands/graph.d.ts +0 -3
- package/dist/commands/hook/constants.d.ts +0 -8
- package/dist/commands/hook/index.d.ts +0 -3
- package/dist/commands/hook/install.d.ts +0 -7
- package/dist/commands/hook/migrate.d.ts +0 -27
- package/dist/commands/hook/uninstall.d.ts +0 -3
- package/dist/commands/ignore-helpers.d.ts +0 -157
- package/dist/commands/ignore.d.ts +0 -17
- package/dist/commands/implode.d.ts +0 -3
- package/dist/commands/info.d.ts +0 -3
- package/dist/commands/init.d.ts +0 -14
- package/dist/commands/install.d.ts +0 -3
- package/dist/commands/link.d.ts +0 -3
- package/dist/commands/list.d.ts +0 -3
- package/dist/commands/migrate/backup.d.ts +0 -8
- package/dist/commands/migrate/constants.d.ts +0 -16
- package/dist/commands/migrate/deps.d.ts +0 -32
- package/dist/commands/migrate/gitleaks.d.ts +0 -29
- package/dist/commands/migrate/index.d.ts +0 -3
- package/dist/commands/migrate/json.d.ts +0 -22
- package/dist/commands/migrate/kingfisher.d.ts +0 -14
- package/dist/commands/migrate/lint-staged.d.ts +0 -62
- package/dist/commands/migrate/moon.d.ts +0 -5
- package/dist/commands/migrate/nano-staged.d.ts +0 -30
- package/dist/commands/migrate/nx.d.ts +0 -12
- package/dist/commands/migrate/prompt.d.ts +0 -2
- package/dist/commands/migrate/secretlint.d.ts +0 -14
- package/dist/commands/migrate/shared.d.ts +0 -29
- package/dist/commands/migrate/turborepo.d.ts +0 -11
- package/dist/commands/migrate/types.d.ts +0 -27
- package/dist/commands/migrate/verify.d.ts +0 -12
- package/dist/commands/optimize.d.ts +0 -38
- package/dist/commands/pm.d.ts +0 -3
- package/dist/commands/remove.d.ts +0 -3
- package/dist/commands/run.d.ts +0 -16
- package/dist/commands/sbom.d.ts +0 -10
- package/dist/commands/secrets.d.ts +0 -3
- package/dist/commands/sort-package-json.d.ts +0 -3
- package/dist/commands/staged.d.ts +0 -10
- package/dist/commands/status.d.ts +0 -3
- package/dist/commands/sync.d.ts +0 -16
- package/dist/commands/task-why.d.ts +0 -3
- package/dist/commands/unlink.d.ts +0 -3
- package/dist/commands/update.d.ts +0 -3
- package/dist/commands/upgrade.d.ts +0 -3
- package/dist/commands/why.d.ts +0 -3
- package/dist/docker.d.ts +0 -73
- package/dist/flakiness.d.ts +0 -40
- package/dist/generate/discover.d.ts +0 -29
- package/dist/generate/loader.d.ts +0 -15
- package/dist/generate/moon-adapter/filename-interp.d.ts +0 -42
- package/dist/generate/moon-adapter/filters.d.ts +0 -22
- package/dist/generate/moon-adapter/frontmatter.d.ts +0 -39
- package/dist/generate/moon-adapter/index.d.ts +0 -19
- package/dist/generate/moon-adapter/tera-subset.d.ts +0 -85
- package/dist/generate/moon-adapter/util.d.ts +0 -14
- package/dist/generate/prompts.d.ts +0 -25
- package/dist/generate/remote.d.ts +0 -43
- package/dist/generate/runner.d.ts +0 -37
- package/dist/generate/types.d.ts +0 -152
- package/dist/hooks.d.ts +0 -118
- package/dist/native-binding.d.ts +0 -158
- package/dist/output.d.ts +0 -40
- package/dist/overrides.d.ts +0 -82
- package/dist/package-manager.d.ts +0 -23
- package/dist/packem_shared/otelPlugin-CJLkguJ8.js +0 -1
- package/dist/plugins/config-loader.d.ts +0 -3
- package/dist/plugins/otel.d.ts +0 -63
- package/dist/plugins/post-command.d.ts +0 -3
- package/dist/plugins/security-enforcement.d.ts +0 -3
- package/dist/pm-runner.d.ts +0 -44
- package/dist/run-report.d.ts +0 -40
- package/dist/runtime-check.d.ts +0 -27
- package/dist/sbom/cyclonedx.d.ts +0 -39
- package/dist/sbom/installed-package.d.ts +0 -49
- package/dist/sbom/license.d.ts +0 -31
- package/dist/sbom/lockfile.d.ts +0 -34
- package/dist/sbom/purl.d.ts +0 -25
- package/dist/sbom/resolve-specifier.d.ts +0 -24
- package/dist/sbom/types.d.ts +0 -196
- package/dist/secrets/baseline.d.ts +0 -20
- package/dist/secrets/format.d.ts +0 -14
- package/dist/secrets/git.d.ts +0 -6
- package/dist/secrets/spinner.d.ts +0 -9
- package/dist/security.d.ts +0 -64
- package/dist/selectors.d.ts +0 -81
- package/dist/shell-history.d.ts +0 -16
- package/dist/socket-security.d.ts +0 -129
- package/dist/staged/cli-parse.d.ts +0 -18
- package/dist/staged/config.d.ts +0 -14
- package/dist/staged/errors/apply-empty-commit-error.d.ts +0 -4
- package/dist/staged/errors/config-error.d.ts +0 -4
- package/dist/staged/errors/get-backup-stash-error.d.ts +0 -4
- package/dist/staged/errors/git-error.d.ts +0 -6
- package/dist/staged/errors/index.d.ts +0 -12
- package/dist/staged/errors/restore-original-state-error.d.ts +0 -4
- package/dist/staged/errors/staged-error.d.ts +0 -8
- package/dist/staged/errors/task-error.d.ts +0 -6
- package/dist/staged/git/diff.d.ts +0 -76
- package/dist/staged/git/exec.d.ts +0 -43
- package/dist/staged/git/index.d.ts +0 -77
- package/dist/staged/git/stash.d.ts +0 -37
- package/dist/staged/index.d.ts +0 -13
- package/dist/staged/match.d.ts +0 -12
- package/dist/staged/renderer/index.d.ts +0 -9
- package/dist/staged/renderer/ink/index.d.ts +0 -4
- package/dist/staged/renderer/plain.d.ts +0 -12
- package/dist/staged/tasks/build.d.ts +0 -13
- package/dist/staged/tasks/exec.d.ts +0 -56
- package/dist/staged/tasks/run.d.ts +0 -26
- package/dist/staged/types.d.ts +0 -173
- package/dist/target-discovery.d.ts +0 -59
- package/dist/target-options.d.ts +0 -261
- package/dist/tips.d.ts +0 -41
- package/dist/tui/components/CheckProgressApp.d.ts +0 -6
- package/dist/tui/components/CommandSummary.d.ts +0 -17
- package/dist/tui/components/Header.d.ts +0 -13
- package/dist/tui/components/OutputPanel.d.ts +0 -17
- package/dist/tui/components/QuitDialog.d.ts +0 -15
- package/dist/tui/components/TaskListPanel.d.ts +0 -19
- package/dist/tui/components/TaskRow.d.ts +0 -12
- package/dist/tui/components/TaskStore.d.ts +0 -80
- package/dist/tui/components/VisTaskRunnerApp.d.ts +0 -17
- package/dist/tui/components/devcontainer/DevcontainerStore.d.ts +0 -66
- package/dist/tui/components/devcontainer/VisDevcontainerApp.d.ts +0 -9
- package/dist/tui/components/devcontainer/catalogs/extensions.d.ts +0 -8
- package/dist/tui/components/devcontainer/catalogs/features.d.ts +0 -8
- package/dist/tui/components/devcontainer/catalogs/filters.d.ts +0 -4
- package/dist/tui/components/devcontainer/catalogs/mount-suggestions.d.ts +0 -19
- package/dist/tui/components/devcontainer/catalogs/templates.d.ts +0 -8
- package/dist/tui/components/devcontainer/devcontainer-io.d.ts +0 -14
- package/dist/tui/components/devcontainer/sections/DockerComposeSection.d.ts +0 -11
- package/dist/tui/components/devcontainer/sections/EnvironmentSection.d.ts +0 -16
- package/dist/tui/components/devcontainer/sections/ExtensionsSection.d.ts +0 -11
- package/dist/tui/components/devcontainer/sections/FeaturesSection.d.ts +0 -11
- package/dist/tui/components/devcontainer/sections/GeneralSection.d.ts +0 -12
- package/dist/tui/components/devcontainer/sections/LifecycleSection.d.ts +0 -13
- package/dist/tui/components/devcontainer/sections/MountsSection.d.ts +0 -16
- package/dist/tui/components/devcontainer/sections/PortsSection.d.ts +0 -10
- package/dist/tui/components/devcontainer/sections/PreviewPanel.d.ts +0 -11
- package/dist/tui/components/devcontainer/types.d.ts +0 -53
- package/dist/tui/components/devcontainer/validate.d.ts +0 -16
- package/dist/tui/components/graph/GraphStore.d.ts +0 -42
- package/dist/tui/components/graph/ProjectDetailPanel.d.ts +0 -10
- package/dist/tui/components/graph/ProjectListPanel.d.ts +0 -20
- package/dist/tui/components/graph/VisGraphApp.d.ts +0 -8
- package/dist/tui/components/optimize/OptimizeDetailPanel.d.ts +0 -9
- package/dist/tui/components/optimize/OptimizeListPanel.d.ts +0 -16
- package/dist/tui/components/optimize/OptimizeStore.d.ts +0 -50
- package/dist/tui/components/optimize/VisOptimizeApp.d.ts +0 -8
- package/dist/tui/components/optimize/constants.d.ts +0 -7
- package/dist/tui/components/update/PackageDetailPanel.d.ts +0 -12
- package/dist/tui/components/update/PackageListPanel.d.ts +0 -21
- package/dist/tui/components/update/UpdateStore.d.ts +0 -62
- package/dist/tui/components/update/VisUpdateApp.d.ts +0 -18
- package/dist/tui/dynamic-life-cycle.d.ts +0 -22
- package/dist/tui/formatting-utils.d.ts +0 -17
- package/dist/tui/pretty-time.d.ts +0 -8
- package/dist/tui/static-life-cycle.d.ts +0 -28
- package/dist/tui/status-utils.d.ts +0 -20
- package/dist/tui/symbols.d.ts +0 -7
- package/dist/tui/types.d.ts +0 -11
- package/dist/typosquats.d.ts +0 -70
- package/dist/upgrade-check.d.ts +0 -30
- package/dist/utils.d.ts +0 -22
- package/dist/watch.d.ts +0 -65
- package/dist/workspace.d.ts +0 -675
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
var oe=Object.defineProperty;var E=(o,e)=>oe(o,"name",{value:e,configurable:!0});import{createRequire as ie}from"node:module";import{projectGraphToDot as ce}from"@visulima/task-runner";import{Box as i,Text as t,ScrollView as ae,ScrollBar as pe,useApp as he,useWindowSize as ue,useInput as fe,Dialog as ge,render as me}from"@visulima/tui";import{C as z,f as k,o as S,R as W,Z as xe,e as be,s as ye}from"../packem_shared/bin-BaZZ32BK.js";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),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,de=E(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 le(o)},"__cjs_getBuiltinModule"),{writeFileSync:se}=de("node:fs");var Ae=Object.defineProperty,I=E((o,e)=>Ae(o,"name",{value:e,configurable:!0}),"n");const ke=I(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=I((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{I(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=I(()=>this.#e,"getSnapshot");subscribe=I(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(ae,{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,R=E((o,e)=>De(o,"name",{value:e,configurable:!0}),"g");const $e=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],Y=R(({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=R(({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"),Ne=R(({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:$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:f})}),M&&n(i,{flexShrink:0,marginLeft:1,marginRight:1,children:n(pe,{contentHeight:C,placement:"inset",scrollOffset:s,style:"block",viewportHeight:y})})]})]})},"ProjectListPanel");var Ie=Object.defineProperty,Pe=E((o,e)=>Ie(o,"name",{value:e,configurable:!0}),"M$1");const Le=100,Oe=40,Re=10,J={1:"all",2:"app",3:"lib"},Be=Pe(({autoExitSeconds:o=0,store:e})=>{const{exit:l}=he(),{columns:d,rows:c}=ue(),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)),$=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]),fe((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),$(b);return}if(p.upArrow||m==="k"){const b=Math.max(s.selectedIndex-1,0);e.setSelectedIndex(b),$(b);return}if(p.pageDown){const b=Math.min(s.selectedIndex+10,C.length-1);e.setSelectedIndex(b),$(b);return}if(p.pageUp){const b=Math.max(s.selectedIndex-10,0);e.setSelectedIndex(b),$(b);return}if(p.home){e.setSelectedIndex(0),h(0);return}if(p.end){const b=C.length-1;e.setSelectedIndex(b),$(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<Re)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,B=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(ge,{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(Ne,{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})]}),B,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}),B,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=[];if(a.push(S("Project Dependency Graph"),""),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"),He=D(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 Z;const Ge=D(o=>{const e=Object.values(o.nodes).map(u=>({name:u.name,type:u.type})),l=[];for(const u of Object.values(o.dependencies))for(const a of u)l.push({source:a.source,target:a.target,type:a.type});const d=e.filter(u=>u.type==="application"),c=e.filter(u=>u.type!=="application"),s={apps:d.length,edges:l,libs:c.length,nodes:e};return String.raw(Z||(Z=Fe([`<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>Project Dependency Graph</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; overflow: hidden; }
|
|
10
|
+
svg { width: 100vw; height: 100vh; }
|
|
11
|
+
.edge { fill: none; marker-end: url(#arrow); }
|
|
12
|
+
.node rect { rx: 8; ry: 8; cursor: pointer; transition: stroke-width 0.15s; }
|
|
13
|
+
.node text { font-size: 12px; font-weight: 600; pointer-events: none; }
|
|
14
|
+
.node:hover rect { stroke-width: 2.5; stroke: #fff; }
|
|
15
|
+
#info { position: fixed; top: 16px; right: 16px; background: #1e293b; padding: 14px 20px; border-radius: 10px; font-size: 13px; border: 1px solid #334155; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
|
|
16
|
+
#info b { font-variant-numeric: tabular-nums; }
|
|
17
|
+
.app-count { color: #fbbf24; }
|
|
18
|
+
.lib-count { color: #38bdf8; }
|
|
19
|
+
.dep-count { color: #a78bfa; }
|
|
20
|
+
#legend { position: fixed; bottom: 16px; left: 16px; background: #1e293b; padding: 12px 16px; border-radius: 10px; font-size: 12px; border: 1px solid #334155; display: flex; gap: 16px; align-items: center; }
|
|
21
|
+
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; }
|
|
22
|
+
#tooltip { position: fixed; display: none; background: #1e293b; border: 1px solid #475569; border-radius: 8px; padding: 12px 16px; font-size: 12px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 10; pointer-events: none; }
|
|
23
|
+
#tooltip h3 { font-size: 14px; margin-bottom: 6px; }
|
|
24
|
+
#tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
|
|
25
|
+
#tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
|
|
26
|
+
#tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
|
|
27
|
+
#tooltip li { padding: 1px 0; color: #cbd5e1; }
|
|
28
|
+
#tooltip li::before { content: "92 "; color: #64748b; }
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<div id="info">
|
|
33
|
+
<b class="app-count">`,`</b> apps ·
|
|
34
|
+
<b class="lib-count">`,`</b> libraries ·
|
|
35
|
+
<b class="dep-count">`,`</b> dependencies
|
|
36
|
+
</div>
|
|
37
|
+
<div id="legend">
|
|
38
|
+
<span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
|
|
39
|
+
<span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
|
|
40
|
+
<span style="color:#64748b">— solid = static - - - = implicit</span>
|
|
41
|
+
</div>
|
|
42
|
+
<div id="tooltip"></div>
|
|
43
|
+
<svg id="graph">
|
|
44
|
+
<defs>
|
|
45
|
+
<marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
|
|
46
|
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
|
|
47
|
+
</marker>
|
|
48
|
+
</defs>
|
|
49
|
+
</svg>
|
|
50
|
+
<script>
|
|
51
|
+
const data = `,`;
|
|
52
|
+
const svg = document.getElementById('graph');
|
|
53
|
+
const tooltip = document.getElementById('tooltip');
|
|
54
|
+
const W = window.innerWidth, H = window.innerHeight;
|
|
55
|
+
|
|
56
|
+
// Build adjacency
|
|
57
|
+
const depMap = {}, rdepMap = {};
|
|
58
|
+
data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
|
|
59
|
+
data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
|
|
60
|
+
|
|
61
|
+
// Escape text for safe DOM insertion
|
|
62
|
+
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
|
|
63
|
+
|
|
64
|
+
// Force-directed layout
|
|
65
|
+
const repulsion = 5000 + data.nodes.length * 150;
|
|
66
|
+
const nodes = data.nodes.map(n => ({
|
|
67
|
+
...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
|
|
68
|
+
y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
|
|
69
|
+
}));
|
|
70
|
+
const nodeMap = new Map(nodes.map(n => [n.name, n]));
|
|
71
|
+
const edges = data.edges.map(e => ({
|
|
72
|
+
source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
for (let iter = 0; iter < 400; iter++) {
|
|
76
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
77
|
+
for (let j = i+1; j < nodes.length; j++) {
|
|
78
|
+
let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
|
|
79
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
80
|
+
let f = repulsion / (d * d);
|
|
81
|
+
nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
|
|
82
|
+
nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
edges.forEach(e => {
|
|
86
|
+
if (!e.source || !e.target) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
90
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
91
|
+
let f = (d - 180) * 0.008;
|
|
92
|
+
e.source.vx += dx/d * f; e.source.vy += dy/d * f;
|
|
93
|
+
e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
|
|
94
|
+
});
|
|
95
|
+
nodes.forEach(n => {
|
|
96
|
+
n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
|
|
97
|
+
n.x += n.vx * 0.3; n.y += n.vy * 0.3;
|
|
98
|
+
n.vx *= 0.75; n.vy *= 0.75;
|
|
99
|
+
n.x = Math.max(80, Math.min(W-80, n.x));
|
|
100
|
+
n.y = Math.max(40, Math.min(H-40, n.y));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Measure text widths
|
|
105
|
+
const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
106
|
+
measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
|
|
107
|
+
measure.setAttribute('font-family','system-ui');
|
|
108
|
+
svg.appendChild(measure);
|
|
109
|
+
const widths = {};
|
|
110
|
+
nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
|
|
111
|
+
svg.removeChild(measure);
|
|
112
|
+
|
|
113
|
+
// Render edges
|
|
114
|
+
edges.forEach(e => {
|
|
115
|
+
if (!e.source || !e.target) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const sw = (widths[e.source.name]||80)/2 + 12;
|
|
119
|
+
const tw = (widths[e.target.name]||80)/2 + 12;
|
|
120
|
+
const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
121
|
+
const d = Math.sqrt(dx*dx+dy*dy)||1;
|
|
122
|
+
const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
|
|
123
|
+
const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
|
|
124
|
+
const line = document.createElementNS('http://www.w3.org/2000/svg','line');
|
|
125
|
+
line.setAttribute('x1',x1); line.setAttribute('y1',y1);
|
|
126
|
+
line.setAttribute('x2',x2); line.setAttribute('y2',y2);
|
|
127
|
+
line.setAttribute('class','edge');
|
|
128
|
+
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
129
|
+
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
130
|
+
line.setAttribute('stroke-width', '1.5');
|
|
131
|
+
if (e.type === 'implicit' || e.type === 'peerDependency') {
|
|
132
|
+
line.setAttribute('stroke-dasharray', '6,4');
|
|
133
|
+
}
|
|
134
|
+
if (e.type === 'devDependency') {
|
|
135
|
+
line.setAttribute('stroke-dasharray', '3,3');
|
|
136
|
+
}
|
|
137
|
+
svg.appendChild(line);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Render nodes
|
|
141
|
+
nodes.forEach(n => {
|
|
142
|
+
const w = (widths[n.name]||80) + 24;
|
|
143
|
+
const h = 32;
|
|
144
|
+
const isApp = n.type === 'application';
|
|
145
|
+
const fill = isApp ? '#fbbf24' : '#38bdf8';
|
|
146
|
+
const textFill = '#0f172a';
|
|
147
|
+
const stroke = isApp ? '#f59e0b' : '#0284c7';
|
|
148
|
+
|
|
149
|
+
const g = document.createElementNS('http://www.w3.org/2000/svg','g');
|
|
150
|
+
g.setAttribute('class','node');
|
|
151
|
+
g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
|
|
152
|
+
const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
|
|
153
|
+
rect.setAttribute('width', w); rect.setAttribute('height', h);
|
|
154
|
+
rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
|
|
155
|
+
g.appendChild(rect);
|
|
156
|
+
const text = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
157
|
+
text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
|
|
158
|
+
text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
|
|
159
|
+
text.textContent = n.name;
|
|
160
|
+
g.appendChild(text);
|
|
161
|
+
|
|
162
|
+
g.addEventListener('mouseenter', (ev) => {
|
|
163
|
+
const deps = depMap[n.name] || [];
|
|
164
|
+
const rdeps = rdepMap[n.name] || [];
|
|
165
|
+
|
|
166
|
+
// Build tooltip using safe DOM methods
|
|
167
|
+
tooltip.textContent = '';
|
|
168
|
+
|
|
169
|
+
const heading = document.createElement('h3');
|
|
170
|
+
heading.textContent = n.name;
|
|
171
|
+
const badge = document.createElement('span');
|
|
172
|
+
badge.className = 'type-badge';
|
|
173
|
+
badge.style.background = fill;
|
|
174
|
+
badge.style.color = '#0f172a';
|
|
175
|
+
badge.textContent = n.type;
|
|
176
|
+
heading.appendChild(badge);
|
|
177
|
+
tooltip.appendChild(heading);
|
|
178
|
+
|
|
179
|
+
if (deps.length) {
|
|
180
|
+
const label = document.createElement('div');
|
|
181
|
+
label.className = 'dep-section';
|
|
182
|
+
label.textContent = 'Depends on:';
|
|
183
|
+
tooltip.appendChild(label);
|
|
184
|
+
const ul = document.createElement('ul');
|
|
185
|
+
deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
186
|
+
tooltip.appendChild(ul);
|
|
187
|
+
}
|
|
188
|
+
if (rdeps.length) {
|
|
189
|
+
const label = document.createElement('div');
|
|
190
|
+
label.className = 'dep-section';
|
|
191
|
+
label.textContent = 'Required by:';
|
|
192
|
+
tooltip.appendChild(label);
|
|
193
|
+
const ul = document.createElement('ul');
|
|
194
|
+
rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
195
|
+
tooltip.appendChild(ul);
|
|
196
|
+
}
|
|
197
|
+
if (!deps.length && !rdeps.length) {
|
|
198
|
+
const empty = document.createElement('div');
|
|
199
|
+
empty.style.marginTop = '6px';
|
|
200
|
+
empty.style.color = '#64748b';
|
|
201
|
+
empty.textContent = 'No dependencies';
|
|
202
|
+
tooltip.appendChild(empty);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
tooltip.style.display = 'block';
|
|
206
|
+
const rect = tooltip.getBoundingClientRect();
|
|
207
|
+
tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
|
|
208
|
+
tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
|
|
209
|
+
});
|
|
210
|
+
g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
|
|
211
|
+
svg.appendChild(g);
|
|
212
|
+
});
|
|
213
|
+
<\/script>
|
|
214
|
+
</body>
|
|
215
|
+
</html>`],[`<!DOCTYPE html>
|
|
216
|
+
<html lang="en">
|
|
217
|
+
<head>
|
|
218
|
+
<meta charset="UTF-8">
|
|
219
|
+
<title>Project Dependency Graph</title>
|
|
220
|
+
<style>
|
|
221
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
222
|
+
body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; overflow: hidden; }
|
|
223
|
+
svg { width: 100vw; height: 100vh; }
|
|
224
|
+
.edge { fill: none; marker-end: url(#arrow); }
|
|
225
|
+
.node rect { rx: 8; ry: 8; cursor: pointer; transition: stroke-width 0.15s; }
|
|
226
|
+
.node text { font-size: 12px; font-weight: 600; pointer-events: none; }
|
|
227
|
+
.node:hover rect { stroke-width: 2.5; stroke: #fff; }
|
|
228
|
+
#info { position: fixed; top: 16px; right: 16px; background: #1e293b; padding: 14px 20px; border-radius: 10px; font-size: 13px; border: 1px solid #334155; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
|
|
229
|
+
#info b { font-variant-numeric: tabular-nums; }
|
|
230
|
+
.app-count { color: #fbbf24; }
|
|
231
|
+
.lib-count { color: #38bdf8; }
|
|
232
|
+
.dep-count { color: #a78bfa; }
|
|
233
|
+
#legend { position: fixed; bottom: 16px; left: 16px; background: #1e293b; padding: 12px 16px; border-radius: 10px; font-size: 12px; border: 1px solid #334155; display: flex; gap: 16px; align-items: center; }
|
|
234
|
+
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; }
|
|
235
|
+
#tooltip { position: fixed; display: none; background: #1e293b; border: 1px solid #475569; border-radius: 8px; padding: 12px 16px; font-size: 12px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 10; pointer-events: none; }
|
|
236
|
+
#tooltip h3 { font-size: 14px; margin-bottom: 6px; }
|
|
237
|
+
#tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
|
|
238
|
+
#tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
|
|
239
|
+
#tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
|
|
240
|
+
#tooltip li { padding: 1px 0; color: #cbd5e1; }
|
|
241
|
+
#tooltip li::before { content: "\\2192 "; color: #64748b; }
|
|
242
|
+
</style>
|
|
243
|
+
</head>
|
|
244
|
+
<body>
|
|
245
|
+
<div id="info">
|
|
246
|
+
<b class="app-count">`,`</b> apps ·
|
|
247
|
+
<b class="lib-count">`,`</b> libraries ·
|
|
248
|
+
<b class="dep-count">`,`</b> dependencies
|
|
249
|
+
</div>
|
|
250
|
+
<div id="legend">
|
|
251
|
+
<span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
|
|
252
|
+
<span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
|
|
253
|
+
<span style="color:#64748b">— solid = static - - - = implicit</span>
|
|
254
|
+
</div>
|
|
255
|
+
<div id="tooltip"></div>
|
|
256
|
+
<svg id="graph">
|
|
257
|
+
<defs>
|
|
258
|
+
<marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
|
|
259
|
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
|
|
260
|
+
</marker>
|
|
261
|
+
</defs>
|
|
262
|
+
</svg>
|
|
263
|
+
<script>
|
|
264
|
+
const data = `,`;
|
|
265
|
+
const svg = document.getElementById('graph');
|
|
266
|
+
const tooltip = document.getElementById('tooltip');
|
|
267
|
+
const W = window.innerWidth, H = window.innerHeight;
|
|
268
|
+
|
|
269
|
+
// Build adjacency
|
|
270
|
+
const depMap = {}, rdepMap = {};
|
|
271
|
+
data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
|
|
272
|
+
data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
|
|
273
|
+
|
|
274
|
+
// Escape text for safe DOM insertion
|
|
275
|
+
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
|
|
276
|
+
|
|
277
|
+
// Force-directed layout
|
|
278
|
+
const repulsion = 5000 + data.nodes.length * 150;
|
|
279
|
+
const nodes = data.nodes.map(n => ({
|
|
280
|
+
...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
|
|
281
|
+
y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
|
|
282
|
+
}));
|
|
283
|
+
const nodeMap = new Map(nodes.map(n => [n.name, n]));
|
|
284
|
+
const edges = data.edges.map(e => ({
|
|
285
|
+
source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
|
|
286
|
+
}));
|
|
287
|
+
|
|
288
|
+
for (let iter = 0; iter < 400; iter++) {
|
|
289
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
290
|
+
for (let j = i+1; j < nodes.length; j++) {
|
|
291
|
+
let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
|
|
292
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
293
|
+
let f = repulsion / (d * d);
|
|
294
|
+
nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
|
|
295
|
+
nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
edges.forEach(e => {
|
|
299
|
+
if (!e.source || !e.target) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
303
|
+
let d = Math.sqrt(dx*dx + dy*dy) || 1;
|
|
304
|
+
let f = (d - 180) * 0.008;
|
|
305
|
+
e.source.vx += dx/d * f; e.source.vy += dy/d * f;
|
|
306
|
+
e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
|
|
307
|
+
});
|
|
308
|
+
nodes.forEach(n => {
|
|
309
|
+
n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
|
|
310
|
+
n.x += n.vx * 0.3; n.y += n.vy * 0.3;
|
|
311
|
+
n.vx *= 0.75; n.vy *= 0.75;
|
|
312
|
+
n.x = Math.max(80, Math.min(W-80, n.x));
|
|
313
|
+
n.y = Math.max(40, Math.min(H-40, n.y));
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Measure text widths
|
|
318
|
+
const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
319
|
+
measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
|
|
320
|
+
measure.setAttribute('font-family','system-ui');
|
|
321
|
+
svg.appendChild(measure);
|
|
322
|
+
const widths = {};
|
|
323
|
+
nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
|
|
324
|
+
svg.removeChild(measure);
|
|
325
|
+
|
|
326
|
+
// Render edges
|
|
327
|
+
edges.forEach(e => {
|
|
328
|
+
if (!e.source || !e.target) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const sw = (widths[e.source.name]||80)/2 + 12;
|
|
332
|
+
const tw = (widths[e.target.name]||80)/2 + 12;
|
|
333
|
+
const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
|
|
334
|
+
const d = Math.sqrt(dx*dx+dy*dy)||1;
|
|
335
|
+
const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
|
|
336
|
+
const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
|
|
337
|
+
const line = document.createElementNS('http://www.w3.org/2000/svg','line');
|
|
338
|
+
line.setAttribute('x1',x1); line.setAttribute('y1',y1);
|
|
339
|
+
line.setAttribute('x2',x2); line.setAttribute('y2',y2);
|
|
340
|
+
line.setAttribute('class','edge');
|
|
341
|
+
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
342
|
+
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
343
|
+
line.setAttribute('stroke-width', '1.5');
|
|
344
|
+
if (e.type === 'implicit' || e.type === 'peerDependency') {
|
|
345
|
+
line.setAttribute('stroke-dasharray', '6,4');
|
|
346
|
+
}
|
|
347
|
+
if (e.type === 'devDependency') {
|
|
348
|
+
line.setAttribute('stroke-dasharray', '3,3');
|
|
349
|
+
}
|
|
350
|
+
svg.appendChild(line);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// Render nodes
|
|
354
|
+
nodes.forEach(n => {
|
|
355
|
+
const w = (widths[n.name]||80) + 24;
|
|
356
|
+
const h = 32;
|
|
357
|
+
const isApp = n.type === 'application';
|
|
358
|
+
const fill = isApp ? '#fbbf24' : '#38bdf8';
|
|
359
|
+
const textFill = '#0f172a';
|
|
360
|
+
const stroke = isApp ? '#f59e0b' : '#0284c7';
|
|
361
|
+
|
|
362
|
+
const g = document.createElementNS('http://www.w3.org/2000/svg','g');
|
|
363
|
+
g.setAttribute('class','node');
|
|
364
|
+
g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
|
|
365
|
+
const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
|
|
366
|
+
rect.setAttribute('width', w); rect.setAttribute('height', h);
|
|
367
|
+
rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
|
|
368
|
+
g.appendChild(rect);
|
|
369
|
+
const text = document.createElementNS('http://www.w3.org/2000/svg','text');
|
|
370
|
+
text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
|
|
371
|
+
text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
|
|
372
|
+
text.textContent = n.name;
|
|
373
|
+
g.appendChild(text);
|
|
374
|
+
|
|
375
|
+
g.addEventListener('mouseenter', (ev) => {
|
|
376
|
+
const deps = depMap[n.name] || [];
|
|
377
|
+
const rdeps = rdepMap[n.name] || [];
|
|
378
|
+
|
|
379
|
+
// Build tooltip using safe DOM methods
|
|
380
|
+
tooltip.textContent = '';
|
|
381
|
+
|
|
382
|
+
const heading = document.createElement('h3');
|
|
383
|
+
heading.textContent = n.name;
|
|
384
|
+
const badge = document.createElement('span');
|
|
385
|
+
badge.className = 'type-badge';
|
|
386
|
+
badge.style.background = fill;
|
|
387
|
+
badge.style.color = '#0f172a';
|
|
388
|
+
badge.textContent = n.type;
|
|
389
|
+
heading.appendChild(badge);
|
|
390
|
+
tooltip.appendChild(heading);
|
|
391
|
+
|
|
392
|
+
if (deps.length) {
|
|
393
|
+
const label = document.createElement('div');
|
|
394
|
+
label.className = 'dep-section';
|
|
395
|
+
label.textContent = 'Depends on:';
|
|
396
|
+
tooltip.appendChild(label);
|
|
397
|
+
const ul = document.createElement('ul');
|
|
398
|
+
deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
399
|
+
tooltip.appendChild(ul);
|
|
400
|
+
}
|
|
401
|
+
if (rdeps.length) {
|
|
402
|
+
const label = document.createElement('div');
|
|
403
|
+
label.className = 'dep-section';
|
|
404
|
+
label.textContent = 'Required by:';
|
|
405
|
+
tooltip.appendChild(label);
|
|
406
|
+
const ul = document.createElement('ul');
|
|
407
|
+
rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
|
|
408
|
+
tooltip.appendChild(ul);
|
|
409
|
+
}
|
|
410
|
+
if (!deps.length && !rdeps.length) {
|
|
411
|
+
const empty = document.createElement('div');
|
|
412
|
+
empty.style.marginTop = '6px';
|
|
413
|
+
empty.style.color = '#64748b';
|
|
414
|
+
empty.textContent = 'No dependencies';
|
|
415
|
+
tooltip.appendChild(empty);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
tooltip.style.display = 'block';
|
|
419
|
+
const rect = tooltip.getBoundingClientRect();
|
|
420
|
+
tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
|
|
421
|
+
tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
|
|
422
|
+
});
|
|
423
|
+
g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
|
|
424
|
+
svg.appendChild(g);
|
|
425
|
+
});
|
|
426
|
+
<\/script>
|
|
427
|
+
</body>
|
|
428
|
+
</html>`])),s.apps,s.libs,s.edges.length,JSON.stringify(s).replaceAll("</",String.raw`<\/`))},"projectGraphToHtml"),Je=D(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:u}=xe(c,l),a=be(c,u,s),y=!!process.stdout.isTTY&&!ye,g=e.format??(y?"tui":"ascii"),v=e.output,h=e.depth??1/0;let f;switch(g){case"dot":{f=ce(a);break}case"html":{f=Ge(a);break}case"json":{f=JSON.stringify(He(a),void 0,2);break}case"tui":{if(!y){f=K(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 Me(a);await me(we.createElement(Be,{autoExitSeconds:x,store:M}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(C);return}default:f=K(a,h)}v?(se(v,f,"utf8"),o.info(`Graph written to ${v}`)):o.info(f)},"execute");export{Je as default};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var ee=Object.defineProperty;var $=(e,t)=>ee(e,"name",{value:t,configurable:!0});import{createRequire as te}from"node:module";import{isAccessibleSync as y,readFileSync as A,ensureDirSync as G}from"@visulima/fs";import{join as l}from"@visulima/path";import{h as z,i as ae,j as le,k as ce,p as fe,r as ue,l as K,n as J,u as U,v as Y}from"../packem_shared/bin-BaZZ32BK.js";import{readTomlSync as de}from"@visulima/fs/toml";import{parse as pe}from"yaml";const se=te(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=$(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[t,s]=F.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return F.getBuiltinModule(e)}return se(e)},"__cjs_getBuiltinModule"),{readdirSync:q,statSync:C,writeFileSync:S,unlinkSync:ne,rmSync:re,chmodSync:ie}=L("node:fs"),{cwd:j}=F,{createInterface:oe}=L("node:readline"),{spawnSync:x}=L("node:child_process");var ge=Object.defineProperty,P=$((e,t)=>ge(e,"name",{value:t,configurable:!0}),"c$2");const he=/^# ([^:\s]\S*)(?::\s+(.+))?$/,me=P(e=>{const t=[],s=e.split(`
|
|
2
|
+
`);let n;for(const r of s){if(r.startsWith("#!")||r.startsWith("# Generated by")||r.startsWith("# NOTE:")||r==="set -e"||r==="")continue;const o=he.exec(r);if(o){n&&t.push(n),n={command:"",id:o[1]??"",...o[2]?{name:o[2]}:{}};continue}n?n.command=n.command.length>0?`${n.command}
|
|
3
|
+
${r}`:r:n={command:r,id:"(custom)"}}return n&&t.push(n),t},"parseStageScript"),ke=P((e,t)=>{const s=l(e,t),n=[],r=new Set(z);if(y(s))for(const o of q(s)){if(o.startsWith(".")||o==="_"||!r.has(o))continue;const i=l(s,o);if(!C(i).isFile())continue;const a=A(i),u=me(a);n.push({blocks:u,rawLineCount:a.split(`
|
|
4
|
+
`).length,stage:o})}return n.sort((o,i)=>o.stage.localeCompare(i.stage)),{hooksDirectory:t,stages:n}},"listHooks"),ye=P(e=>{const t=[];if(e.stages.length===0)return t.push(`No hooks installed in ${e.hooksDirectory}/.`),t;t.push(`Hooks in ${e.hooksDirectory}/:`);for(const s of e.stages)if(t.push("",`${s.stage} (${s.rawLineCount} lines)`),s.blocks.length===0)t.push(" (empty)");else for(const n of s.blocks){const r=n.name?`${n.id} — ${n.name}`:n.id;t.push(` - ${r}`);const o=n.command.split(`
|
|
5
|
+
`).find(i=>i.trim()!=="");if(o){const i=o.length>120?`${o.slice(0,117)}...`:o;t.push(` ${i}`)}}return t},"formatListResult"),be=P((e,t)=>{const s=ke(j(),e);for(const n of ye(s))t.info(n)},"runList"),E="prek-runner.mjs",xe={css:["css","scss","sass","less"],dockerfile:["dockerfile"],html:["htm","html"],javascript:["cjs","js","jsx","mjs"],json:["json"],jsx:["jsx","tsx"],makefile:["mk","makefile"],markdown:["markdown","md","mdown","mdx"],python:["py","pyi","pyw"],python3:["py","pyi","pyw"],ruby:["rb"],rust:["rs"],shell:["bash","sh","zsh"],sql:["sql"],svg:["svg"],systemd:["service","socket","timer"],toml:["toml"],tsx:["tsx"],typescript:["cts","mts","ts","tsx"],xml:["xml"],yaml:["yaml","yml"]},we=["binary","directory","executable","non-executable","symlink","text"],ve={bash:["bash","shell"],node:["javascript"],nodejs:["javascript"],perl:["perl"],python:["python"],python3:["python","python3"],ruby:["ruby"],sh:["shell"],zsh:["shell","zsh"]},$e=["check-json","check-merge-conflict","end-of-file-fixer","mixed-line-ending","trailing-whitespace"],Ee=[...Object.keys(xe),...Object.values(ve).flat(),...we],Se=["#!/usr/bin/env node","// Auto-generated by `vis hook migrate`. Do not edit by hand.","// Replicates the subset of prek / pre-commit framework semantics that a vis","// hook script needs: staged-file discovery, regex + type filters, chunked","// argv dispatch, and a handful of built-in hook implementations.","","import { spawnSync } from 'node:child_process';","import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';","import { basename, extname, join } from 'node:path';","import process from 'node:process';","","const TYPES_EXTENSION_MAP = {"," css: ['css', 'scss', 'sass', 'less'],"," dockerfile: ['dockerfile'],"," html: ['htm', 'html'],"," javascript: ['cjs', 'js', 'jsx', 'mjs'],"," json: ['json'],"," jsx: ['jsx', 'tsx'],"," makefile: ['mk', 'makefile'],"," markdown: ['markdown', 'md', 'mdown', 'mdx'],"," python: ['py', 'pyi', 'pyw'],"," python3: ['py', 'pyi', 'pyw'],"," ruby: ['rb'],"," rust: ['rs'],"," shell: ['bash', 'sh', 'zsh'],"," sql: ['sql'],"," svg: ['svg'],"," systemd: ['service', 'socket', 'timer'],"," toml: ['toml'],"," tsx: ['tsx'],"," typescript: ['cts', 'mts', 'ts', 'tsx'],"," xml: ['xml'],"," yaml: ['yaml', 'yml'],","};","","const FILENAME_TYPE_MAP = {"," dockerfile: 'dockerfile',"," makefile: 'makefile',"," 'gnumakefile': 'makefile',","};","","const SHEBANG_INTERPRETER_MAP = {"," bash: ['bash', 'shell'],"," node: ['javascript'],"," nodejs: ['javascript'],"," perl: ['perl'],"," python: ['python'],"," python3: ['python', 'python3'],"," ruby: ['ruby'],"," sh: ['shell'],"," zsh: ['shell', 'zsh'],","};","","const BUILTINS = {"," 'check-json': runCheckJson,"," 'check-merge-conflict': runCheckMergeConflict,"," 'end-of-file-fixer': runEndOfFileFixer,"," 'mixed-line-ending': runMixedLineEnding,"," 'trailing-whitespace': runTrailingWhitespace,","};","","const parseArgs = (argv) => {"," const flags = {"," allFiles: process.env.VIS_HOOK_ALL_FILES === '1',"," alwaysRun: false,"," builtin: null,"," exclude: null,"," excludeTypes: [],"," files: null,"," fromRef: process.env.VIS_HOOK_FROM_REF || null,"," passFilenames: true,"," toRef: process.env.VIS_HOOK_TO_REF || null,"," types: [],"," typesOr: [],"," };"," const rest = [];"," let seenDoubleDash = false;",""," for (let i = 0; i < argv.length; i += 1) {"," const arg = argv[i];",""," if (seenDoubleDash) {"," rest.push(arg);"," continue;"," }",""," switch (arg) {"," case '--':"," seenDoubleDash = true;"," break;"," case '--all-files':"," flags.allFiles = true;"," break;"," case '--always-run':"," flags.alwaysRun = true;"," break;"," case '--builtin':"," i += 1;"," flags.builtin = argv[i];"," break;"," case '--exclude':"," i += 1;"," flags.exclude = argv[i];"," break;"," case '--from-ref':"," i += 1;"," flags.fromRef = argv[i];"," break;"," case '--to-ref':"," i += 1;"," flags.toRef = argv[i];"," break;"," case '--exclude-types':"," i += 1;"," flags.excludeTypes = (argv[i] || '').split(',').filter(Boolean);"," break;"," case '--files':"," i += 1;"," flags.files = argv[i];"," break;"," case '--no-pass-filenames':"," flags.passFilenames = false;"," break;"," case '--types':"," i += 1;"," flags.types = (argv[i] || '').split(',').filter(Boolean);"," break;"," case '--types-or':"," i += 1;"," flags.typesOr = (argv[i] || '').split(',').filter(Boolean);"," break;"," default:"," process.stderr.write('prek-runner: unknown flag ' + arg + '\\n');"," process.exit(2);"," }"," }",""," return { flags, rest };","};","","const gitListFiles = (args, errorHint) => {"," const result = spawnSync('git', args, { encoding: 'buffer' });"," if (result.status !== 0) {"," process.stderr.write('prek-runner: git ' + errorHint + ' failed\\n');"," process.stderr.write(result.stderr ? result.stderr.toString() : '');"," process.exit(result.status === null ? 1 : result.status);"," }"," const raw = result.stdout.toString('utf8');"," if (raw.length === 0) { return []; }"," return raw.split('\\0').filter(function (f) { return f.length > 0; });","};","","const discoverFiles = (flags) => {"," if (flags.allFiles) {"," return gitListFiles(['ls-files', '-z'], 'ls-files');"," }"," if (flags.fromRef && flags.toRef) {"," return gitListFiles("," ['diff', '--name-only', '--diff-filter=ACM', '-z', flags.fromRef, flags.toRef],"," 'diff --from-ref/--to-ref'"," );"," }"," return gitListFiles(['diff', '--cached', '--name-only', '--diff-filter=ACM', '-z'], 'diff --cached');","};","","const buildRegex = (pattern) => {"," try {"," return new RegExp(pattern);"," } catch (error) {"," process.stderr.write('prek-runner: invalid regex ' + JSON.stringify(pattern) + ': ' + error.message + '\\n');"," process.exit(2);"," }","};","","const readShebang = (file) => {"," try {"," const fd = readFileSync(file, { encoding: null });"," if (fd.length < 2 || fd[0] !== 0x23 || fd[1] !== 0x21) { return null; }"," const nl = fd.indexOf(0x0a);"," const end = nl === -1 ? Math.min(fd.length, 256) : Math.min(nl, 256);"," return fd.slice(2, end).toString('utf8').trim();"," } catch (error) {"," return null;"," }","};","","const interpreterFromShebang = (shebang) => {"," if (!shebang) { return null; }"," const parts = shebang.split(/\\s+/).filter(Boolean);"," if (parts.length === 0) { return null; }"," const first = parts[0];"," let candidate = basename(first);"," if (candidate === 'env' && parts.length > 1) {"," candidate = basename(parts[1].split('=')[0] || parts[1]);"," }"," return candidate.toLowerCase();","};","","const fileMetadataTags = (file) => {"," const tags = new Set();"," let info;"," try { info = statSync(file, { throwIfNoEntry: false }); } catch (error) { info = null; }"," if (!info) { return tags; }"," if (info.isSymbolicLink()) { tags.add('symlink'); }"," if (info.isDirectory()) { tags.add('directory'); }"," if (info.isFile()) {"," if ((info.mode & 0o111) !== 0) { tags.add('executable'); } else { tags.add('non-executable'); }"," }"," return tags;","};","","const isBinaryFile = (file) => {"," try {"," const buf = readFileSync(file);"," const slice = buf.subarray(0, Math.min(buf.length, 8192));"," for (let i = 0; i < slice.length; i += 1) {"," if (slice[i] === 0) { return true; }"," }"," return false;"," } catch (error) {"," return false;"," }","};","","const typesForFile = (file) => {"," const tags = new Set();"," const baseName = basename(file).toLowerCase();"," const ext = extname(file).slice(1).toLowerCase();",""," if (baseName in FILENAME_TYPE_MAP) {"," tags.add(FILENAME_TYPE_MAP[baseName]);"," }",""," for (const [type, extensions] of Object.entries(TYPES_EXTENSION_MAP)) {"," if (extensions.includes(ext) || extensions.includes(baseName)) {"," tags.add(type);"," }"," }",""," const metaTags = fileMetadataTags(file);"," for (const tag of metaTags) { tags.add(tag); }",""," if (tags.size === 0 || tags.has('executable') || tags.has('shell')) {"," const interpreter = interpreterFromShebang(readShebang(file));"," if (interpreter) {"," const interpreterTags = SHEBANG_INTERPRETER_MAP[interpreter];"," if (interpreterTags) {"," for (const tag of interpreterTags) { tags.add(tag); }"," }"," }"," }",""," if (!tags.has('symlink') && !tags.has('directory')) {"," tags.add(isBinaryFile(file) ? 'binary' : 'text');"," }",""," return tags;","};","","const applyFilters = (files, flags) => {"," let filtered = files;",""," if (flags.files) {"," const rx = buildRegex(flags.files);"," filtered = filtered.filter(function (f) { return rx.test(f); });"," }",""," if (flags.exclude) {"," const rx = buildRegex(flags.exclude);"," filtered = filtered.filter(function (f) { return !rx.test(f); });"," }",""," if (flags.types.length > 0) {"," filtered = filtered.filter(function (f) {"," const tags = typesForFile(f);"," return flags.types.every(function (t) { return tags.has(t); });"," });"," }",""," if (flags.typesOr.length > 0) {"," filtered = filtered.filter(function (f) {"," const tags = typesForFile(f);"," return flags.typesOr.some(function (t) { return tags.has(t); });"," });"," }",""," if (flags.excludeTypes.length > 0) {"," filtered = filtered.filter(function (f) {"," const tags = typesForFile(f);"," return !flags.excludeTypes.some(function (t) { return tags.has(t); });"," });"," }",""," return filtered;","};","","// Conservative per-call argv budget. POSIX guarantees 4 KiB, Linux gives ~2 MiB","// in practice. 32 KiB keeps us well clear of Windows' 32767-char limit too.","const ARG_BUDGET = 32 * 1024;","","const chunkFiles = (files) => {"," const chunks = [];"," let current = [];"," let size = 0;",""," for (const file of files) {"," const cost = Buffer.byteLength(file, 'utf8') + 8;",""," if (size + cost > ARG_BUDGET && current.length > 0) {"," chunks.push(current);"," current = [];"," size = 0;"," }",""," current.push(file);"," size += cost;"," }",""," if (current.length > 0) {"," chunks.push(current);"," }",""," return chunks;","};","","const runCommand = (cmd, files, passFilenames) => {"," if (!cmd || cmd.length === 0) {"," process.stderr.write('prek-runner: no command specified after --\\n');"," return 2;"," }",""," const bin = cmd[0];"," const baseArgs = cmd.slice(1);",""," if (!passFilenames) {"," const result = spawnSync(bin, baseArgs, { stdio: 'inherit' });"," return result.status === null ? 1 : result.status;"," }",""," let rc = 0;"," const chunks = files.length === 0 ? [[]] : chunkFiles(files);",""," for (const chunk of chunks) {"," const result = spawnSync(bin, baseArgs.concat(chunk), { stdio: 'inherit' });"," rc = rc | (result.status === null ? 1 : result.status);"," }",""," return rc;","};","","// ─── Built-in hook implementations ──────────────────────────────────","// Each receives the already-filtered file list and returns an exit code.","","function runTrailingWhitespace(files) {"," // Mirrors pre-commit/pre-commit-hooks/trailing_whitespace_fixer.py:"," // strip trailing whitespace from each line, preserve original endings,"," // preserve markdown hard-break trailing two-spaces on non-blank lines."," const WS = new Set([0x20, 0x09, 0x0b, 0x0c, 0x0d]); // SP, TAB, VT, FF, CR"," const MD_RE = /\\.(md|markdown|mdown|mdx)$/i;"," let rc = 0;",""," for (const file of files) {"," const isMarkdown = MD_RE.test(file);"," const buf = readFileSync(file);"," const out = [];"," let i = 0;",""," while (i <= buf.length) {"," let end = i;",""," while (end < buf.length && buf[end] !== 0x0a) {"," end += 1;"," }",""," const hadLf = end < buf.length && buf[end] === 0x0a;"," let contentEnd = end;"," let hadCr = false;",""," if (hadLf && end > i && buf[end - 1] === 0x0d) {"," hadCr = true;"," contentEnd = end - 1;"," }",""," const content = buf.subarray(i, contentEnd);"," let stripEnd = content.length;",""," while (stripEnd > 0 && WS.has(content[stripEnd - 1])) {"," stripEnd -= 1;"," }",""," const nonWhitespace = content.some(function (b) { return !WS.has(b); });",""," if (isMarkdown && content.length >= 2 && content[content.length - 1] === 0x20 && content[content.length - 2] === 0x20 && nonWhitespace) {"," stripEnd = Math.min(stripEnd + 2, content.length);"," }",""," out.push(content.subarray(0, stripEnd));",""," if (hadCr) {"," out.push(Buffer.from([0x0d]));"," }",""," if (hadLf) {"," out.push(Buffer.from([0x0a]));"," }",""," if (!hadLf) {"," break;"," }",""," i = end + 1;"," }",""," const next = Buffer.concat(out);",""," if (!next.equals(buf)) {"," writeFileSync(file, next);"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," }"," }",""," return rc;","}","","function runEndOfFileFixer(files) {"," // Mirrors pre-commit/pre-commit-hooks/end_of_file_fixer.py: collapse"," // trailing \\n / \\r\\n / \\r runs to a single newline; add a newline if"," // missing; leave empty files alone."," let rc = 0;",""," for (const file of files) {"," const buf = readFileSync(file);",""," if (buf.length === 0) {"," continue;"," }",""," let end = buf.length;"," const last = buf[end - 1];",""," if (last !== 0x0a && last !== 0x0d) {"," writeFileSync(file, Buffer.concat([buf, Buffer.from([0x0a])]));"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," continue;"," }",""," while (end > 0 && (buf[end - 1] === 0x0a || buf[end - 1] === 0x0d)) {"," end -= 1;"," }",""," if (end === 0) {"," writeFileSync(file, Buffer.alloc(0));"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," continue;"," }",""," const trailing = buf.subarray(end);"," let keep;",""," if (trailing[0] === 0x0d && trailing[1] === 0x0a) {"," keep = Buffer.from([0x0d, 0x0a]);"," } else if (trailing[0] === 0x0d) {"," keep = Buffer.from([0x0d]);"," } else {"," keep = Buffer.from([0x0a]);"," }",""," if (trailing.equals(keep)) {"," continue;"," }",""," writeFileSync(file, Buffer.concat([buf.subarray(0, end), keep]));"," process.stdout.write('Fixing ' + file + '\\n');"," rc = 1;"," }",""," return rc;","}","","function isInMerge() {"," // Mirrors pre-commit/pre-commit-hooks/check_merge_conflict.py:is_in_merge."," const gitDirResult = spawnSync('git', ['rev-parse', '--git-dir'], { encoding: 'utf8' });"," if (gitDirResult.status !== 0) { return false; }"," const gitDir = gitDirResult.stdout.trim();"," if (!existsSync(join(gitDir, 'MERGE_MSG'))) { return false; }"," return existsSync(join(gitDir, 'MERGE_HEAD'))"," || existsSync(join(gitDir, 'rebase-apply'))"," || existsSync(join(gitDir, 'rebase-merge'));","}","","function runCheckMergeConflict(files, args) {"," // Mirrors pre-commit/pre-commit-hooks/check_merge_conflict.py: only"," // scans for conflict markers when git is mid-merge/rebase, unless the"," // caller passes --assume-in-merge. Skipping the guard means every"," // legit `<<<<<<<` in docs would fail the hook."," const assumeInMerge = Array.isArray(args) && args.includes('--assume-in-merge');"," if (!assumeInMerge && !isInMerge()) { return 0; }",""," const PATTERNS = ['<<<<<<< ', '======= ', '=======\\r\\n', '=======\\n', '>>>>>>> '];"," let rc = 0;",""," for (const file of files) {"," const content = readFileSync(file, 'utf8');"," const lines = content.split('\\n');",""," for (let i = 0; i < lines.length; i += 1) {"," const line = lines[i] + (i < lines.length - 1 ? '\\n' : '');",""," for (const pattern of PATTERNS) {"," if (line.startsWith(pattern)) {"," process.stdout.write(file + ':' + (i + 1) + ': Merge conflict string ' + JSON.stringify(pattern.trim()) + ' found\\n');"," rc = 1;"," }"," }"," }"," }",""," return rc;","}","","function runCheckJson(files) {"," // Mirrors pre-commit/pre-commit-hooks/check_json.py: parse each file"," // and additionally reject duplicate keys."," let rc = 0;",""," for (const file of files) {"," const content = readFileSync(file, 'utf8');",""," try {"," JSON.parse(content);"," detectDuplicateJsonKeys(content, file);"," } catch (error) {"," process.stdout.write(file + ': Failed to json decode (' + error.message + ')\\n');"," rc = 1;"," }"," }",""," return rc;","}","","function detectDuplicateJsonKeys(source, file) {"," // Minimal tokeniser that walks the already-valid JSON source and throws"," // with a message compatible with the Python hook when a duplicate key"," // appears at any object level."," let i = 0;"," const length = source.length;",""," const skipWs = function () {"," while (i < length && /\\s/.test(source[i])) {"," i += 1;"," }"," };",""," const parseString = function () {",` if (source[i] !== '"') {`," throw new Error('expected string at ' + i);"," }"," i += 1;"," let start = i;",` while (i < length && source[i] !== '"') {`," if (source[i] === '\\\\') {"," i += 2;"," } else {"," i += 1;"," }"," }"," const raw = source.slice(start, i);"," i += 1;",` return JSON.parse('"' + raw + '"');`," };",""," const parseValue = function () {"," skipWs();"," const ch = source[i];"," if (ch === '{') { parseObject(); }"," else if (ch === '[') { parseArray(); }",` else if (ch === '"') { parseString(); }`," else {"," while (i < length && ',}]'.indexOf(source[i]) === -1 && !/\\s/.test(source[i])) {"," i += 1;"," }"," }"," };",""," const parseArray = function () {"," i += 1;"," skipWs();"," if (source[i] === ']') { i += 1; return; }"," while (i < length) {"," parseValue();"," skipWs();"," if (source[i] === ',') { i += 1; skipWs(); }"," else if (source[i] === ']') { i += 1; return; }"," }"," };",""," const parseObject = function () {"," i += 1;"," skipWs();"," const seen = new Set();"," if (source[i] === '}') { i += 1; return; }"," while (i < length) {"," skipWs();"," const key = parseString();"," if (seen.has(key)) {"," throw new Error('Duplicate key: ' + key);"," }"," seen.add(key);"," skipWs();"," if (source[i] !== ':') {"," throw new Error('expected colon at ' + i);"," }"," i += 1;"," parseValue();"," skipWs();"," if (source[i] === ',') { i += 1; skipWs(); }"," else if (source[i] === '}') { i += 1; return; }"," }"," };",""," skipWs();"," parseValue();","}","","function runMixedLineEnding(files, args) {"," // Mirrors pre-commit/pre-commit-hooks/mixed_line_ending.py."," const ENDING = { cr: Buffer.from([0x0d]), crlf: Buffer.from([0x0d, 0x0a]), lf: Buffer.from([0x0a]) };"," let fixArg = 'auto';",""," for (let idx = 0; idx < args.length; idx += 1) {"," const a = args[idx];"," if (a === '-f' || a === '--fix') {"," idx += 1;"," fixArg = args[idx];"," } else if (a.indexOf('--fix=') === 0) {"," fixArg = a.slice('--fix='.length);"," }"," }",""," let rc = 0;",""," for (const file of files) {"," const buf = readFileSync(file);"," const counts = { cr: 0, crlf: 0, lf: 0 };"," const lines = [];"," let start = 0;",""," for (let i = 0; i < buf.length; i += 1) {"," const b = buf[i];",""," if (b === 0x0d && buf[i + 1] === 0x0a) {"," lines.push({ content: buf.subarray(start, i), ending: 'crlf' });"," counts.crlf += 1;"," i += 1;"," start = i + 1;"," } else if (b === 0x0d) {"," lines.push({ content: buf.subarray(start, i), ending: 'cr' });"," counts.cr += 1;"," start = i + 1;"," } else if (b === 0x0a) {"," lines.push({ content: buf.subarray(start, i), ending: 'lf' });"," counts.lf += 1;"," start = i + 1;"," }"," }",""," if (start < buf.length) {"," lines.push({ content: buf.subarray(start), ending: null });"," }",""," const distinct = Object.values(counts).filter(function (c) { return c > 0; }).length;"," const mixed = distinct > 1;",""," if (fixArg === 'no') {"," if (mixed) {"," process.stdout.write(file + ': mixed line endings\\n');"," rc = 1;"," }"," continue;"," }",""," let target;",""," if (fixArg === 'auto') {"," if (!mixed) { continue; }"," let max = -1;"," for (const key of ['cr', 'crlf', 'lf']) {"," if (counts[key] >= max) {"," max = counts[key];"," target = key;"," }"," }"," } else if (!(fixArg in ENDING)) {"," process.stderr.write('prek-runner: invalid --fix value ' + fixArg + '\\n');"," return 2;"," } else {"," target = fixArg;"," const other = Object.entries(counts).some(function (entry) { return entry[0] !== target && entry[1] > 0; });"," if (!other) { continue; }"," }",""," const ending = ENDING[target];"," const chunks = [];",""," for (const line of lines) {"," chunks.push(line.content);"," if (line.ending !== null) {"," chunks.push(ending);"," }"," }",""," writeFileSync(file, Buffer.concat(chunks));"," process.stdout.write(file + ': fixed mixed line endings\\n');"," rc = 1;"," }",""," return rc;","}","","// ─── Entry point ────────────────────────────────────────────────────","","const parsed = parseArgs(process.argv.slice(2));","const candidateFiles = discoverFiles(parsed.flags);","const filtered = applyFilters(candidateFiles, parsed.flags);","","if (filtered.length === 0 && !parsed.flags.alwaysRun) {"," process.exit(0);","}","","let code;","","if (parsed.flags.builtin) {"," const impl = BUILTINS[parsed.flags.builtin];"," if (!impl) {"," process.stderr.write('prek-runner: unknown builtin ' + parsed.flags.builtin + '\\n');"," process.exit(2);"," }"," code = impl(filtered, parsed.rest);","} else {"," code = runCommand(parsed.rest, filtered, parsed.flags.passFilenames);","}","","process.exit(code);",""],_e=Se.join(`
|
|
6
|
+
`);var Re=Object.defineProperty,d=$((e,t)=>Re(e,"name",{value:t,configurable:!0}),"a$1");const Fe=new Map([["pre-commit/pre-commit-hooks#check-json","check-json"],["pre-commit/pre-commit-hooks#check-merge-conflict","check-merge-conflict"],["pre-commit/pre-commit-hooks#end-of-file-fixer","end-of-file-fixer"],["pre-commit/pre-commit-hooks#mixed-line-ending","mixed-line-ending"],["pre-commit/pre-commit-hooks#trailing-whitespace","trailing-whitespace"]]),je=/[<>=!~]=/,Ae=/github\.com[/:]([^/\s]+\/[^/\s.]+)/i,X=`node "$(dirname "$0")/.builtins/${E}"`,Me="# Generated by `vis hook migrate` from prek",v=d(e=>`'${e.replaceAll("'",String.raw`'\''`)}'`,"shellQuote"),B=d(e=>{for(const t of ae)if(y(l(e,t)))return t},"detectPrekConfig"),Oe=d(e=>le[e]??e,"mapPrekStage"),Ie=d(e=>Ae.exec(e)?.[1]??e,"normalizeRepoKey"),De=d(e=>{if(je.test(e))return;if(e.startsWith("@")){const n=e.indexOf("@",1);if(n===-1)return{name:e,version:"latest"};const r=e.slice(n+1).trim();return{name:e.slice(0,n),version:r||"latest"}}const t=e.indexOf("@");if(t===-1)return{name:e,version:"latest"};const s=e.slice(t+1).trim();return{name:e.slice(0,t),version:s||"latest"}},"parseAdditionalDep"),Ne=new Set(Ee),Pe=d(e=>{const t=[];for(const s of[e.types,e.types_or,e.exclude_types])for(const n of s??[])Ne.has(n)||t.push(n);return t},"unknownTypes"),Te=d((e,t)=>(e.stages&&e.stages.length>0?e.stages:t??["pre-commit"]).map(s=>Oe(s)),"resolveStages"),Ce=d(e=>{const t=[];return e.files&&t.push("--files",v(e.files)),e.exclude&&t.push("--exclude",v(e.exclude)),e.types&&e.types.length>0&&t.push("--types",v(e.types.join(","))),e.types_or&&e.types_or.length>0&&t.push("--types-or",v(e.types_or.join(","))),e.exclude_types&&e.exclude_types.length>0&&t.push("--exclude-types",v(e.exclude_types.join(","))),e.always_run&&t.push("--always-run"),e.pass_filenames===!1&&t.push("--no-pass-filenames"),t},"buildRunnerFilterFlags"),H=d((e,t)=>{const s=[X,...Ce(e)];if(t)return s.push("--builtin",t),Array.isArray(e.args)&&e.args.length>0&&s.push("--",...e.args.map(n=>v(n))),s.join(" ");if(s.push("--",e.entry??""),Array.isArray(e.args))for(const n of e.args)s.push(v(n));return s.join(" ")},"buildRunnerInvocation"),We=d((e,t,s)=>{if(e.language==="fail"){const n=e.entry??e.name??e.id??"hook failed";return`echo ${v(n)}; exit 1`}if(s)return H(e,s);if(ce.has(t)){const n=[];if(e.entry&&n.push(e.entry),Array.isArray(e.args))for(const r of e.args)n.push(v(r));return(e.pass_filenames??!0)&&!e.always_run&&n.push('"$@"'),n.join(" ")}return H(e)},"buildHookCommand"),Le=d((e,t,s,n)=>{if(Array.isArray(e.additional_dependencies))for(const r of e.additional_dependencies){const o=De(r);if(!o){n.push(`"${t}": additional_dependency "${r}" uses a pip-style pin and cannot be added to package.json — install manually.`);continue}s.push({hookId:t,name:o.name,raw:r,version:o.version})}},"collectAdditionalDeps"),Be=d(e=>{const t=new Map,s=[],n=[],r=[],o=[];let i=!1;(e.files||e.exclude)&&n.push("top-level files/exclude filter dropped — apply it per hook if needed");for(const u of e.repos??[]){const c=u.repo??"<unknown>",b=c==="local",k=b?void 0:Ie(c);for(const h of u.hooks??[]){const g=h.id??"<unknown>";let M;if(b){const p=h.language??"system";if(!fe.has(p)){s.push({hookId:g,reason:`language "${p}" needs an isolated toolchain — run via prek or reimplement as a system command`,repo:c});continue}if(p!=="fail"&&!h.entry){s.push({hookId:g,reason:"missing `entry`",repo:c});continue}}else if(k&&(M=Fe.get(`${k}#${g}`)),!M){s.push({hookId:g,reason:`remote repo "${c}"@${u.rev??"?"} has no bundled equivalent — run via prek or replace with a system command`,repo:c});continue}Le(h,g,o,r);const O=Pe(h);O.length>0&&n.push(`hook "${g}": unsupported types ${O.join(", ")} — those entries are ignored by the runner`);const I=Te(h,e.default_stages);for(const p of I){if(p==="manual")continue;if(!ue.has(p)){s.push({hookId:g,reason:`unsupported stage "${p}"`,repo:c});continue}let w=We(h,p,M);w.startsWith(X)&&(i=!0),h.verbose&&(w=`(set -x; ${w})`);const D=`${`# ${g}${h.name?`: ${h.name}`:""}`}
|
|
7
|
+
${w}`,f=t.get(p);f?f.push(D):t.set(p,[D])}}}const a=new Map;for(const[u,c]of t){const b=["#!/usr/bin/env sh",Me];e.fail_fast&&b.push("set -e"),b.push("",c.join(`
|
|
8
|
+
|
|
9
|
+
`),""),a.set(u,b.join(`
|
|
10
|
+
`))}return{additionalDeps:o,droppedFilters:n,manualSteps:r,scripts:a,skippedHooks:s,usesRunner:i}},"convertPrekConfig"),He=d(e=>{const t=pe(e);if(t&&typeof t=="object")return t},"parsePrekConfig"),Ve=d(e=>{if(e.endsWith(".toml")){const s=de(e);return s&&typeof s=="object"?s:void 0}const t=A(e);return He(t)},"loadPrekConfig"),qe=d((e,t)=>{const s=l(e,"package.json"),n=[],r=[];if(!y(s)||t.length===0)return{added:n,skipped:r};const o=A(s),i=JSON.parse(o),a=i.devDependencies??{},u=i.dependencies??{};for(const k of t){if(k.name in a||k.name in u){r.push(k.name);continue}a[k.name]=k.version,n.push(k.name)}if(n.length===0)return{added:n,skipped:r};i.devDependencies=a;const c=/^(\s+)"/m.exec(o),b=c?c[1]:" ";return S(s,`${JSON.stringify(i,void 0,b)}
|
|
11
|
+
`,"utf8"),{added:n,skipped:r}},"mergeAdditionalDependencies"),Ge=d((e,t)=>{const s=l(e,t,".builtins");G(s),S(l(s,E),_e,{mode:493}),S(l(s,"README.md"),["# Vis prek runner","","Auto-generated by `vis hook migrate` from a prek/pre-commit config.","This directory is owned by the migrator — do not edit by hand.","",`Supported built-in hooks: ${$e.join(", ")}`,""].join(`
|
|
12
|
+
`),"utf8")},"writeRunnerAssets"),ze=d((e,t)=>{x("prek",["--version"],{cwd:e,encoding:"utf8"}).status===0?x("prek",["uninstall"],{cwd:e,encoding:"utf8"}).status===0?t.info("Detached prek via `prek uninstall`."):t.info("`prek uninstall` did not exit cleanly — continuing. You may need to run it manually."):t.info("prek binary not found on PATH — skipping `prek uninstall`. Run it manually if prek is installed elsewhere.")},"detachPrek"),Q=d((e,t,s,n={})=>{const r=B(e),o=n.dryRun===!0;if(!r)return{isError:!0,message:"No prek configuration found (.pre-commit-config.yaml, .pre-commit-config.yml, or prek.toml)"};s.info(`Found prek config at ${r}`);const i=l(e,r),a=A(i),u=Ve(i);if(!u)return{isError:!0,message:`Could not parse ${r}`};const{additionalDeps:c,droppedFilters:b,manualSteps:k,scripts:h,skippedHooks:g,usesRunner:M}=Be(u);if(h.size===0&&g.length===0)return{isError:!0,message:`${r} has no hooks to migrate`};if(!o){const f=x("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(f.status===0){const T=f.stdout?.toString().trim();T&&(T.includes(".prek")||T.includes("prek-hooks"))&&x("git",["config","--local","--unset","core.hooksPath"],{cwd:e})}const _=K(t);if(_.isError)return _;_.message&&s.info(_.message)}const O=l(e,t);o||G(O),M&&(o?s.info(` (would write) ${t}/.builtins/${E}`):(Ge(e,t),s.info(` Wrote ${t}/.builtins/${E}`)));let I=0;for(const[f,_]of h)o?s.info(` (would write) ${t}/${f} (${_.split(`
|
|
13
|
+
`).length} lines)`):(S(l(O,f),_,{mode:493}),s.info(` Wrote ${t}/${f}`)),I+=1;const{added:p,skipped:w}=o?{added:c.map(f=>f.name),skipped:[]}:qe(e,c);if(p.length>0){const f=o?"would add":"Added";s.info(`${f} ${p.length} package${p.length===1?"":"s"} to devDependencies: ${p.join(", ")}`),o||s.info("Run your package manager's install (e.g. `pnpm install`) to pick up the new devDependencies.")}w.length>0&&s.info(`Skipped ${w.length} already-declared package${w.length===1?"":"s"}: ${w.join(", ")}`),o||ze(e,s);const D=`${i}.bak`;if(o?s.info(` (would remove) ${r} and back it up to ${r}.bak`):(y(D)||S(D,a,"utf8"),ne(i),s.info(`Removed ${r} (backup at ${r}.bak)`)),g.length>0){s.warn(`Skipped ${g.length} hook${g.length===1?"":"s"} that cannot run without prek:`);for(const f of g)s.warn(` - ${f.repo}::${f.hookId} — ${f.reason}`)}if(b.length>0){s.warn("Partial filter translations:");for(const f of b)s.warn(` - ${f}`)}if(k.length>0){s.warn("Manual follow-up required:");for(const f of k)s.warn(` - ${f}`)}return{isError:!1,message:`${o?"would migrate":"Migration complete:"} ${I} stage script${I===1?"":"s"} ${o?"into":"written to"} ${t}/`}},"migrateFromPrek");var Ke=Object.defineProperty,Z=$((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"a");const Je="pre-commit",Ue=Z((e,t,s,n)=>{const r=s.stage??Je,o=l(e,t,r);if(!y(o))throw new Error(`No script found at ${t}/${r}. Install or migrate hooks first.`);if(s.lastCommit&&(s.fromRef||s.toRef))throw new Error("--last-commit cannot be combined with --from-ref or --to-ref");const i=s.lastCommit?"HEAD~1":s.fromRef,a=s.lastCommit?"HEAD":s.toRef;if(i&&!a)throw new Error("--from-ref requires --to-ref");if(a&&!i)throw new Error("--to-ref requires --from-ref");const u={...process.env};s.allFiles&&(u.VIS_HOOK_ALL_FILES="1"),i&&(u.VIS_HOOK_FROM_REF=i),a&&(u.VIS_HOOK_TO_REF=a),n.info(`Running ${t}/${r}${s.allFiles?" (--all-files)":""}${i?` (${i}..${a})`:""}`);const c=x("sh",["-e",o],{cwd:e,env:u,stdio:"inherit"});if(c.error)throw c.error;return c.status??1},"runHookStage"),Ye=Z((e,t,s)=>{const n=Ue(j(),e,t,s);if(n!==0)throw new Error(`Hook stage exited with code ${n}`)},"runRun");var Xe=Object.defineProperty,Qe=$((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"e");const Ze=Qe((e=J)=>{if(x("git",["config","--local","core.hooksPath"]).status!==0)return{isError:!1,message:"No custom hooks path configured"};const{status:t,stderr:s}=x("git",["config","--local","--unset","core.hooksPath"]);if(t==null)return{isError:!0,message:"git command not found"};if(t&&t!==5)return{isError:!0,message:String(s)};const n=l(e,"_");return y(n)&&re(n,{force:!0,recursive:!0}),{isError:!1,message:""}},"uninstallHooks");var et=Object.defineProperty,N=$((e,t)=>et(e,"name",{value:t,configurable:!0}),"u");const tt=new Set(z),st=N(e=>{const t=x("sh",["-n",e],{encoding:"utf8"});if(t.status===null)return`failed to run "sh -n" (${t.error?.message??"unknown error"})`;if(t.status!==0)return t.stderr.trim()||`sh -n exited with ${t.status}`},"runSyntaxCheck"),nt=N(e=>{const t=x("node",["--check",e],{encoding:"utf8"});if(t.status===null)return`failed to run "node --check" (${t.error?.message??"unknown error"})`;if(t.status!==0)return t.stderr.trim()||`node --check exited with ${t.status}`},"runNodeCheck"),rt=N((e,t)=>{const s=[],n=l(e,t),r=x("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(r.status===0){const i=r.stdout.trim(),a=`${t}/_`;i&&i!==a&&s.push({kind:"warning",message:`core.hooksPath is "${i}" — expected "${a}". Re-run \`vis hook install\` to fix.`})}else s.push({kind:"warning",message:"core.hooksPath is not set — run `vis hook install`."});if(y(l(n,"_"))||s.push({kind:"error",message:`Dispatcher directory ${t}/_ is missing. Run \`vis hook install\`.`}),!y(n))return s.push({kind:"error",message:`Hooks directory ${t}/ is missing.`}),{issues:s,ok:!1};let o=!1;for(const i of q(n)){if(i.startsWith(".")||i==="_")continue;if(!tt.has(i)){s.push({kind:"warning",message:`Unknown hook "${i}" — not a standard git hook.`,path:l(t,i)});continue}const a=l(n,i);if(!C(a).isFile())continue;const u=C(a).mode&511;(u&64)===0&&s.push({kind:"warning",message:`Script is not owner-executable (mode ${u.toString(8)}).`,path:l(t,i)});const c=st(a);c&&s.push({kind:"error",message:`Shell syntax error: ${c}`,path:l(t,i)}),A(a).includes(`/.builtins/${E}`)&&(o=!0)}if(o){const i=l(n,".builtins",E);if(y(i)){const a=nt(i);a&&s.push({kind:"error",message:`prek-runner.mjs has a syntax error: ${a}`,path:l(t,".builtins",E)})}else s.push({kind:"error",message:`Hook scripts reference ${t}/.builtins/${E} but the file is missing. Re-run \`vis hook migrate\`.`})}return{issues:s,ok:!s.some(i=>i.kind==="error")}},"validateHooks"),it=N((e,t)=>{if(e.issues.length===0)return[`Hook directory ${t}/ looks good.`];const s=[];for(const n of e.issues){const r=n.kind==="error"?"ERROR":"WARN ",o=n.path?` (${n.path})`:"";s.push(`${r} ${n.message}${o}`)}return s.push("",e.ok?"No errors — warnings only.":`${e.issues.filter(n=>n.kind==="error").length} error(s).`),s},"formatValidationResult"),ot=N((e,t)=>{const s=rt(j(),e),n=it(s,e);for(const r of n)r.startsWith("ERROR")||r.startsWith("WARN")?t.warn(r):t.info(r);if(!s.ok)throw new Error("Hook validation failed")},"runValidate");var at=Object.defineProperty,m=$((e,t)=>at(e,"name",{value:t,configurable:!0}),"i");const R=m(e=>e.hooksDir??J,"resolveHooksDirectory"),V=m(e=>new Promise(t=>{const s=oe({input:process.stdin,output:process.stdout});s.question(`${e} (y/N) `,n=>{s.close();const r=n.trim().toLowerCase();t(r==="y"||r==="yes")})}),"confirmPrompt"),lt=m(async(e,t)=>{const s=j(),n=U(s),r=B(s);if(n&&r)throw new Error(`Found both husky (${n}/) and prek (${r}). Remove or migrate one before running \`vis hook install\`.`);if(n){if(t.info(`Existing husky installation found at ${n}/`),await V("Would you like to migrate your husky hooks to vis?")){const i=Y(s,e,t);if(i.isError)throw new Error(i.message);i.message&&t.info(i.message);return}t.info("Aborting install. Remove husky first or run 'vis hook migrate' to migrate.");return}if(r){if(t.info(`Existing prek configuration found at ${r}`),await V("Would you like to migrate your prek hooks to vis?")){const i=Q(s,e,t);if(i.isError)throw new Error(i.message);i.message&&t.info(i.message);return}t.info("Aborting install. Remove the prek config first or run 'vis hook migrate' to migrate.");return}t.info(`Installing git hooks in ${e}/...`);const o=K(e);if(o.message){if(o.isError)throw new Error(o.message);t.info(o.message);return}y(l(s,e,"pre-commit"))||S(l(s,e,"pre-commit"),`#!/usr/bin/env sh
|
|
14
|
+
`,{mode:493}),t.info("Git hooks installed successfully.")},"executeInstall"),ct=m((e,t,s)=>{const n=j(),r=U(n),o=B(n);if(r&&o)throw new Error(`Found both husky (${r}/) and prek (${o}). Migrate one at a time — rename or remove one before retrying.`);if(!r&&!o)throw new Error("No husky (.husky/) or prek (.pre-commit-config.yaml / prek.toml) configuration found to migrate.");t&&s.info("(dry-run) no files will be written");const i=r?Y(n,e,s,{dryRun:t}):Q(n,e,s,{dryRun:t});if(i.isError)throw new Error(i.message);i.message&&s.info(i.message)},"executeMigrate"),W="# vis:secrets-hook",ft=`#!/usr/bin/env sh
|
|
15
|
+
${W}
|
|
16
|
+
# Scan staged files for secrets before each commit. Remove this block or the whole file to disable.
|
|
17
|
+
pnpm exec vis secrets --staged --quiet || exit 1
|
|
18
|
+
`,ut=m((e,t,s)=>{if(e!=="secrets")throw new Error(`Unknown hook add target "${String(e)}". Currently supported: "secrets".`);const n=j(),r=l(n,t,"pre-commit");if(!y(l(n,t)))throw new Error(`Hooks directory ${t}/ does not exist. Run \`vis hook install\` first.`);if(y(r)){const o=A(r);if(o.includes(W)){s.info(`Secrets hook already present in ${r}.`);return}if(/\bvis secrets\b/.test(o)){s.warn(`Found a \`vis secrets\` invocation in ${r} without the managed marker — leaving it untouched.`);return}const i=`${o.trimEnd()}
|
|
19
|
+
|
|
20
|
+
${W}
|
|
21
|
+
pnpm exec vis secrets --staged --quiet || exit 1
|
|
22
|
+
`;S(r,i),ie(r,493),s.info(`Appended secrets scan to ${r}.`);return}S(r,ft,{mode:493}),s.info(`Created ${r} with a secrets-scan pre-commit check.`)},"executeAdd"),dt=m((e,t)=>{t.info("Removing git hooks...");const s=Ze(e);if(s.message){if(s.isError)throw new Error(s.message);t.info(s.message);return}t.info("Git hooks removed successfully.")},"executeUninstall"),pt=m(async({logger:e,options:t})=>{await lt(R(t),e)},"hookInstallImpl"),gt=m(({logger:e,options:t})=>{dt(R(t),e)},"hookUninstallImpl"),ht=m(({logger:e,options:t})=>{ct(R(t),!!t.dryRun,e)},"hookMigrateImpl"),mt=m(({logger:e,options:t})=>{be(R(t),e)},"hookListImpl"),kt=m(({logger:e,options:t})=>{ot(R(t),e)},"hookValidateImpl"),yt=m(({argument:e,logger:t,options:s})=>{Ye(R(s),{allFiles:!!s.allFiles,fromRef:s.fromRef,lastCommit:!!s.lastCommit,stage:e[0],toRef:s.toRef},t)},"hookRunImpl"),bt=m(({argument:e,logger:t,options:s})=>{ut(e[0],R(s),t)},"hookAddImpl"),Rt=pt,Ft=gt,jt=ht,At=mt,Mt=kt,Ot=yt,It=bt;export{It as hookAddExecute,Rt as hookInstallExecute,At as hookListExecute,jt as hookMigrateExecute,Ot as hookRunExecute,Ft as hookUninstallExecute,Mt as hookValidateExecute};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var I=Object.defineProperty;var w=(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{Z as q,e as L}from"../packem_shared/bin-BaZZ32BK.js";const T=D(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=w(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=w((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]"],z=["vis","nx"],W=["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 W){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)=>z.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,_=w((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),y=g.trim().split(`
|
|
3
|
+
`)[0]??"";if(u(`commit: ${y}`),g&&te(g,o))return n(l(o,"commit-force-deploy",`Force-deploy keyword in commit: "${y}"`));if(g&&ee(g,o))return n(k(o,"commit-skip",`Skip keyword in commit: "${y}"`));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};
|