@visulima/vis 1.0.0-alpha.26 → 1.0.0-alpha.28
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 +30 -0
- package/LICENSE.md +3213 -95
- package/README.md +24 -22
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +176 -16
- package/dist/packem_chunks/bin.js +468 -364
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/config.js +15 -15
- package/dist/packem_chunks/devtools.js +82 -0
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +8 -9
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +3 -3
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +2 -2
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +6 -6
- package/dist/packem_chunks/handler31.js +1 -1
- package/dist/packem_chunks/handler33.js +1 -1
- package/dist/packem_chunks/handler34.js +4 -4
- package/dist/packem_chunks/handler35.js +3 -22
- package/dist/packem_chunks/handler36.js +21 -60
- package/dist/packem_chunks/handler37.js +61 -6
- package/dist/packem_chunks/handler38.js +3 -24
- package/dist/packem_chunks/handler39.js +6 -153
- package/dist/packem_chunks/handler4.js +5 -5
- package/dist/packem_chunks/handler40.js +24 -10
- package/dist/packem_chunks/handler41.js +153 -25
- package/dist/packem_chunks/handler42.js +25 -708
- package/dist/packem_chunks/handler43.js +10 -24
- package/dist/packem_chunks/handler44.js +659 -273
- package/dist/packem_chunks/handler45.js +24 -46
- package/dist/packem_chunks/handler46.js +322 -3
- package/dist/packem_chunks/handler47.js +48 -27
- package/dist/packem_chunks/handler48.js +3 -187
- package/dist/packem_chunks/handler49.js +23 -30
- package/dist/packem_chunks/handler5.js +7 -7
- package/dist/packem_chunks/handler50.js +195 -0
- package/dist/packem_chunks/handler51.js +34 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +7 -17
- package/dist/packem_chunks/index.js +3 -3
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +2 -2
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/Table-CwC2kW07-EjFLNV0q.js +12 -0
- package/dist/packem_shared/_commonjsHelpers-CLblCigl.js +1 -0
- package/dist/packem_shared/{advisories-DS8JEB_g.js → advisories-BxXiKFbL.js} +1 -1
- package/dist/packem_shared/{ai-analysis-Csn82p17.js → ai-analysis-BnmDFqc8.js} +5 -5
- package/dist/packem_shared/{ai-fix-BlYyz5bI.js → ai-fix-BGbnrWCz.js} +7 -7
- package/dist/packem_shared/{cyclonedx-ja1cbU69.js → cyclonedx-C2k2HmvI.js} +1 -1
- package/dist/packem_shared/{dependency-scan-s2MD0vi-.js → dependency-scan-Bki15Yi-.js} +1 -1
- package/dist/packem_shared/{docker-Bw9gKo69.js → docker-k-Sl8b-w.js} +1 -1
- package/dist/packem_shared/{failure-log-B0Uh-65U.js → failure-log-C3bG1bCA.js} +1 -1
- package/dist/packem_shared/index-2r730kXY.js +29 -0
- package/dist/packem_shared/{index-88UK-tt_.js → index-DBq4TVu5.js} +1 -1
- package/dist/packem_shared/{lifecycle-ChCFTm5Q.js → lifecycle-B91p_ra8.js} +2 -2
- package/dist/packem_shared/{lockfile-BG1HvBzH.js → lockfile-DmDfgKaT.js} +1 -1
- package/dist/packem_shared/{min-release-age-heJgeP7o.js → min-release-age-B1Jm1_JY.js} +1 -1
- package/dist/packem_shared/{native-config-sync-BOeuyrBj.js → native-config-sync-Cnpj2xcn.js} +6 -6
- package/dist/packem_shared/{osv-bloom-QSAn2Dcw.js → osv-bloom-ep8GlDGT.js} +2 -2
- package/dist/packem_shared/pm-runner-COoPLGKi.js +1 -0
- package/dist/packem_shared/{provenance-BsBn1f5S.js → provenance-DbkJRDqt.js} +1 -1
- package/dist/packem_shared/{registry-keys-pemEkRM9.js → registry-keys-SylX07bs.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-CBPr617N.js → resolve-explicit-CJ_5wYSu.js} +1 -1
- package/dist/packem_shared/s1ngularity-DlS-4a6K.js +1 -0
- package/dist/packem_shared/scan-progress-CU4ttEHQ.js +2 -0
- package/dist/packem_shared/{signatures-CaXzNuEn.js → signatures-B-1u4t-c.js} +1 -1
- package/dist/packem_shared/spinner-B9ZPv1iT.js +1 -0
- package/dist/packem_shared/spinners-f91Rbo99-Bjf3NcO0.js +1 -0
- package/dist/packem_shared/tabs-C-qFIoUv.js +1 -0
- package/dist/packem_shared/typosquats-BxCOUvTJ.js +1 -0
- package/dist/packem_shared/use-measured-height-kIDCuc76.js +1 -0
- package/dist/packem_shared/vis-update-app-COYmjGKv.js +1 -0
- package/dist/packem_shared/watch-BSVsZ_1I.js +1 -0
- package/dist/packem_shared/watch-loop-CP318TfG.js +11 -0
- package/index.js +751 -567
- package/package.json +11 -11
- package/schemas/project.schema.json +86 -1
- package/schemas/vis-config.schema.json +255 -7
- package/dist/packem_shared/index-CS6a2wFB.js +0 -29
- package/dist/packem_shared/index.server-B7ETiT4C.js +0 -2
- package/dist/packem_shared/pm-runner-BzGZmzYs.js +0 -1
- package/dist/packem_shared/s1ngularity-j_ArCZAs.js +0 -1
- package/dist/packem_shared/scan-progress-EbvmIh4i.js +0 -2
- package/dist/packem_shared/typosquats-C1e6RNjF.js +0 -1
- package/dist/packem_shared/use-measured-height-DjYgUOKk.js +0 -1
- package/dist/packem_shared/vis-update-app-qhQPV97i.js +0 -1
|
@@ -1,46 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
`;)n+=1;continue}if(i==="/"&&e[n+1]==="*"){for(n+=2;n<s&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}if(i===","){let a=n+1;for(;a<s&&/\s/.test(e[a]??"");)a+=1;const d=e[a];if(d==="}"||d==="]"){n+=1;continue}}t+=i,n+=1}return t},"stripJsonComments"),yn=z((e,t)=>{const n=["renovate.json","renovate.json5",".renovaterc",".renovaterc.json"];for(const s of n){const r=M(e,s);if(!N(r))continue;let o;try{const a=Q(r);o=JSON.parse($n(a))}catch{continue}if(!o)continue;if(Array.isArray(o.ignoreDeps))for(const a of["actions","docker","gitlab"])Ce(t[a],o.ignoreDeps);const i=[["github-actions","actions"],["dockerfile","docker"],["docker-compose","docker"],["gitlabci","gitlab"],["gitlabci-include","gitlab"]];for(const[a,d]of i){const l=o[a];Ce(t[d],l?.ignoreDeps)}if(!Array.isArray(o.packageRules))return;for(const a of o.packageRules){if(a.enabled!==!1)continue;const d=new Set;for(const c of a.matchManagers??[]){const f=mn[c];f&&d.add(f)}for(const c of a.matchDatasources??[]){const f=hn[c];f&&d.add(f)}d.size===0&&(d.add("actions"),d.add("docker"),d.add("gitlab"));const l=[...a.matchPackageNames??[],...a.matchDepNames??[],...a.matchPackagePatterns??[]];for(const c of d)Ce(t[c],l)}return}},"loadRenovate"),vn=z(e=>{const t={actions:new Set,docker:new Set,gitlab:new Set};return gn(e,t),yn(e,t),t},"loadIgnoreRules"),je=z((e,t,n)=>{const s=n[t];if(s.size===0)return!1;if(s.has(e))return!0;for(const r of s)if(/[*?[\]/.+]/.test(r))try{const o=r.replace(/[.+^${}()|]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");if(new RegExp(`^${o}$`).test(e))return!0}catch{}return!1},"isIgnored");var kn=Object.defineProperty,ke=E((e,t)=>kn(e,"name",{value:t,configurable:!0}),"o$1");const H=ke(e=>{const t=e.trim();if(t==="")return;const n=t.startsWith("v")||t.startsWith("V")?t.slice(1):t,s=(ce.valid(n)?ce.parse(n):void 0)??ce.coerce(n,{includePrerelease:!0});if(s)return{major:s.major,minor:s.minor,patch:s.patch,prerelease:s.prerelease.length>0,raw:t,normalized:`${String(s.major)}.${String(s.minor)}.${String(s.patch)}${s.prerelease.length>0?`-${s.prerelease.join(".")}`:""}`}},"parseTag"),wn=ke((e,t)=>ce.rcompare(e.normalized,t.normalized),"compareTagsDesc"),Te=ke((e,t,n,s)=>{if(!t&&n!=="latest")return;const r=e.filter(o=>!s&&o.prerelease?!1:t?n==="patch"&&(o.major!==t.major||o.minor!==t.minor)||n==="minor"&&o.major!==t.major?!1:ce.gt(o.normalized,t.normalized):!0);if(r.length!==0)return r.toSorted(wn)[0]},"pickBestTag"),Oe=ke((e,t)=>!e||!t?"unknown":t.major!==e.major?"major":t.minor!==e.minor?"minor":t.patch!==e.patch?"patch":"unknown","classifyUpdate");var bn=Object.defineProperty,Ie=E((e,t)=>bn(e,"name",{value:t,configurable:!0}),"i$1");const Rn="GitHub Actions",_e=Ie((e,t)=>`${e}@${t}`,"keyOf"),xn=Ie(e=>({fixedVersions:e.fixedVersions,id:e.id,severity:e.severity,summary:e.summary}),"toAdvisory"),An=Ie((e,t)=>{if(t.length===0)return t;const n=en(e);if(!Qt(n))return t;const s=new Map;for(const o of t){const i=o.currentVersion??o.currentRef;i&&s.set(_e(o.name,i),{name:o.name,version:i})}if(s.size===0)return t;const r=new Map;try{for(const[o,i]of s){const a=tn([i],{ecosystem:Rn,workspaceRoot:e}).get(i.name);a&&a.length>0&&r.set(o,a)}}catch{return t}return r.size===0?t:t.map(o=>{const i=o.currentVersion??o.currentRef;if(!i)return o;const a=r.get(_e(o.name,i));return a?{...o,advisories:a.map(xn)}:o})},"decorateActionsAdvisories");var Cn=Object.defineProperty,Sn=E((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"i");const lt=Sn(e=>{if(!e)return{};const t={};for(const n of e.split(",")){const s=/^\s*<([^>]+)>\s*;\s*(.+)$/.exec(n);if(!s)continue;const r=s[1]??"",o=s[2]??"",i=/rel\s*=\s*"?([^";\s]+)"?/i.exec(o)?.[1]?.toLowerCase();i==="next"?t.next=r:i==="prev"||i==="previous"?t.previous=r:i==="last"?t.last=r:i==="first"&&(t.first=r)}return t},"parseLinkHeader");var En=Object.defineProperty,jn=E((e,t)=>En(e,"name",{value:t,configurable:!0}),"l$1");class Tn{static{E(this,"ActionsResolver")}static{jn(this,"ActionsResolver")}token;apiBase;fetchImpl;tagsCache=new Map;commitCache=new Map;constructor(t){this.token=t.token??process.env.GITHUB_TOKEN??process.env.GH_TOKEN,this.apiBase=t.apiBase??"https://api.github.com",this.fetchImpl=t.fetch??fetch}async listTags(t,n){const s=`${t}/${n}`,r=this.tagsCache.get(s);if(r)return r;const o=this.fetchTags(t,n);return this.tagsCache.set(s,o),o}async resolveRef(t,n,s){const r=`${t}/${n}@${s}`,o=this.commitCache.get(r);if(o)return o;const i=this.fetchCommit(t,n,s);return this.commitCache.set(r,i),i}buildHeaders(){const t={Accept:"application/vnd.github+json","User-Agent":"vis-update-actions","X-GitHub-Api-Version":"2022-11-28"};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}async fetchTags(t,n){const s=`${this.apiBase}/repos/${encodeURIComponent(t)}/${encodeURIComponent(n)}/tags?per_page=100`,r={tags:[],parsed:[]},o=[];let i=s,a=0;for(;i&&a<5;){const l=i;let c;try{c=await this.fetchImpl(l,{headers:this.buildHeaders()})}catch{return r}if(!c.ok)return r;let f;try{f=await c.json()}catch{return r}if(!Array.isArray(f))return r;for(const g of f){const m=typeof g.name=="string"?g.name:"",$=typeof g.commit?.sha=="string"?g.commit.sha:"";m!==""&&$!==""&&o.push({name:m,sha:$})}i=lt(c.headers.get("link")).next,a+=1}const d=[];for(const l of o){const c=H(l.name);c&&d.push({...c,sha:l.sha})}return{parsed:d,tags:o}}async fetchCommit(t,n,s){const r=`${this.apiBase}/repos/${encodeURIComponent(t)}/${encodeURIComponent(n)}/commits/${encodeURIComponent(s)}`;try{const o=await this.fetchImpl(r,{headers:this.buildHeaders()});if(!o.ok)return;const i=await o.json();return typeof i.sha!="string"?void 0:{committedAt:i.commit?.committer?.date,sha:i.sha}}catch{return}}}var On=Object.defineProperty,ue=E((e,t)=>On(e,"name",{value:t,configurable:!0}),"f$1");const In=".github/workflows",Dn=".github/actions",Un=/^(\s*-?\s*uses:\s*)(['"]?)([^'"\s#]+)\2(\s*#\s*(.+))?\s*$/,Nn=/^[a-f0-9]{40}$/i,Pn=/actions-up-ignore-next-line(?::\s*(.+))?/i,Bn=/actions-up-ignore-start/i,Vn=/actions-up-ignore-end/i,Mn=ue(e=>{const t=e.split("/");if(t.length<2)return;const[n,s,...r]=t;if(!(!n||!s))return{owner:n,repo:s,subpath:r.length>0?r.join("/"):void 0}},"splitSlug"),_n=ue((e,t)=>{const n=t.split(/\r?\n/),s=[];let r,o=!1;for(let i=0;i<n.length;i++){const a=n[i]??"";if(Bn.test(a)&&(o=!0),Vn.test(a)){o=!1;continue}const d=a.trim(),l=d===""||d.startsWith("#")?Pn.exec(a):void 0;if(l){r=l[1]??"actions-up-ignore-next-line";continue}const c=Un.exec(a);if(!c){r=void 0;continue}const f=c[2]??"",g=f==="'"||f==='"'?f:"",m=c[3]??"",$=c[5]?.trim();if(m.startsWith("./")||m.startsWith("../")||m.startsWith("docker://")){r=void 0;continue}const C=m.lastIndexOf("@");if(C<=0){r=void 0;continue}const R=m.slice(0,C),v=m.slice(C+1),k=Mn(R);if(!k){r=void 0;continue}let h=r??(o?"actions-up-ignore-block":void 0);if($){const p=/^actions-up-ignore(?:-next-line)?(?::\s*(.+))?(?:\s|$)/i.exec($);p&&(h=h??p[1]??"actions-up-ignore")}r=void 0,s.push({file:e,ignoreReason:h,isSha:Nn.test(v),line:i+1,original:`${g}${m}${g}`,owner:k.owner,quote:g,ref:v,repo:k.repo,slug:R,subpath:k.subpath,trailingComment:$&&!h?$:void 0})}return s},"extractUsesFromContent"),Fe=ue(e=>e.endsWith(".yml")||e.endsWith(".yaml"),"isWorkflowFile"),Fn=ue((e,t=[])=>{const n=[],s=new Set,r=ue(a=>{if(s.has(a))return;s.add(a);let d;try{d=Q(a)}catch{return}const l=_n(a,d);n.push(...l)},"collectFile"),o=M(e,In);if(N(o))for(const a of ne(o,{includeDirs:!1,includeSymlinks:!1,maxDepth:1}))Fe(a.name)&&r(a.path);const i=M(e,Dn);if(N(i))for(const a of ne(i,{includeDirs:!1,includeSymlinks:!1,maxDepth:3}))(a.name==="action.yml"||a.name==="action.yaml")&&r(a.path);for(const a of["action.yml","action.yaml"]){const d=M(e,a);N(d)&&r(d)}for(const a of t){const d=bt(a)?a:M(e,a);if(N(d))for(const l of ne(d,{includeDirs:!1,includeSymlinks:!1}))Fe(l.name)&&r(l.path)}return n},"scanActionsRepository");var qn=Object.defineProperty,de=E((e,t)=>qn(e,"name",{value:t,configurable:!0}),"d$3");const Wn=40,Ln=1440*60*1e3,Hn=new Set(["main","master","develop","trunk","edge","stable"]),Gn=de(e=>e.length===Wn&&/^[a-f0-9]{40}$/i.test(e)?!1:Hn.has(e.toLowerCase())?!0:H(e)===void 0,"looksLikeBranch"),qe=de((e,t)=>{for(const n of t)try{if(new RegExp(n).test(e))return!0}catch{if(e.includes(n))return!0}return!1},"matchesPattern"),zn=de((e,t,n,s)=>{const r=s==="sha"||e.isSha,{quote:o}=e;return r?`${o}${e.slug}@${t}${o} # ${n}`:`${o}${e.slug}@${n}${o}`},"buildReplacement"),Kn=de(async(e,t)=>{const{ignoreRules:n,options:s,references:r,resolverOptions:o}=t,i=[],a=[],d=[];if(r.length===0)return{failed:d,ignored:a,updates:i};const l=new Tn({apiBase:o?.apiBase,fetch:o?.fetch,token:s.githubToken??o?.token}),c=new Map;for(const v of r){const k=`${v.owner}/${v.repo}`,h=c.get(k)??[];h.push(v),c.set(k,h)}const f=Math.max(1,s.maxConcurrentRequests),g=[...c.keys()];let m=0;const $=de(async v=>{const k=c.get(v)??[],[h,p]=v.split("/");if(!h||!p)return;let y;try{y=await l.listTags(h,p)}catch{for(const u of k)d.push({file:u.file,reason:`failed to list tags for ${v}`});return}for(const u of k){const w=u.slug;let b;if(u.ignoreReason?b=u.ignoreReason:qe(w,s.exclude)?b="matched --exclude":s.include.length>0&&!qe(w,s.include)?b="not matched by --include":s.respectDependabotConfig&&n&&je(w,"actions",n)&&(b="ignored by dependabot/renovate config"),b){a.push({currentRef:u.ref,currentVersion:u.isSha?u.trailingComment?.replace(/^#\s*/,""):u.ref,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:w,newRef:u.ref,newVersion:void 0,original:u.original,reason:b,replacement:u.original,updateType:"unknown"});continue}if(!s.includeBranches&&!u.isSha&&Gn(u.ref)){a.push({currentRef:u.ref,currentVersion:u.ref,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:w,newRef:u.ref,newVersion:void 0,original:u.original,reason:"branch reference (use --include-branches)",replacement:u.original,updateType:"unknown"});continue}const j=u.isSha?u.trailingComment?.replace(/^#\s*/,"").split(/\s+/)[0]??"":u.ref,S=H(j);if(u.isSha&&!S&&s.mode!=="latest"){a.push({currentRef:u.ref,currentVersion:void 0,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:w,newRef:u.ref,newVersion:void 0,original:u.original,reason:`SHA pin has no version-hint comment; cannot apply --target=${s.mode}`,replacement:u.original,updateType:"unknown"});continue}const x=Te(y.parsed,S,s.mode,!1);if(!x)continue;if(s.minAgeDays!==void 0){const D=await l.resolveRef(h,p,x.sha),K=D?.committedAt?new Date(D.committedAt).getTime():void 0;if(K&&(Date.now()-K)/Ln<s.minAgeDays){a.push({currentRef:u.ref,currentVersion:S?.raw,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:w,newRef:u.ref,newVersion:x.raw,original:u.original,reason:`release younger than ${String(s.minAgeDays)} days`,replacement:u.original,updateType:"unknown"});continue}}const T=s.style==="sha"||u.isSha?x.sha:x.raw,B=zn(u,x.sha,x.raw,s.style);i.push({currentRef:u.ref,currentVersion:S?.raw??u.trailingComment?.replace(/^#\s*/,""),ecosystem:"actions",file:u.file,line:u.line,name:w,newRef:T,newVersion:x.raw,original:u.original,replacement:B,updateType:Oe(S,x),url:`https://github.com/${h}/${p}/releases/tag/${x.raw}`})}},"processGroup"),C=[];for(let v=0;v<Math.min(f,g.length);v++)C.push((async()=>{for(;m<g.length;){const k=g[m];m+=1,k!==void 0&&await $(k)}})());await Promise.all(C);const R=An(e,i);return{failed:d,ignored:a,updates:R}},"checkActions");var Yn=Object.defineProperty,ut=E((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"u$3");const Jn=ut(e=>e.toSorted((t,n)=>t.file!==n.file?t.file<n.file?-1:1:t.line-n.line),"orderUpdates"),Zn=ut(e=>{const t=[],n=[];if(e.length===0)return{applied:t,skipped:n};const s=Jn(e),r=new Map;for(const o of s){const i=r.get(o.file)??[];i.push(o),r.set(o.file,i)}for(const[o,i]of r){let a;try{a=Q(o)}catch(g){for(const m of i)n.push({reason:`read failed: ${g.message}`,update:m});continue}const d=a.includes(`\r
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`,l=a.split(/\r?\n/),c=[];for(const g of i){const m=g.line-1,$=l[m];if($===void 0){n.push({reason:`line ${String(g.line)} out of range`,update:g});continue}const C=$.indexOf(g.original);if(C<0){n.push({reason:"original token not found on expected line",update:g});continue}const R=$.slice(0,C),v=$.slice(C+g.original.length),k=/#\s*v?\d/.test(g.replacement)&&/^\s*#\s*v?\d[\w.+-]*\s*$/i.test(v)?"":v;l[m]=`${R}${g.replacement}${k}`,c.push(g)}if(c.length===0)continue;const f=l.join(d);try{nn(o,f),t.push(...c)}catch(g){for(const m of c)n.push({reason:`write failed: ${g.message}`,update:m})}}return{applied:t,skipped:n}},"applyEcosystemUpdates");var Xn=Object.defineProperty,me=E((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"u$2");class Qn{static{E(this,"DockerRegistry")}static{me(this,"DockerRegistry")}tokens;fetchImpl;tagCache=new Map;constructor(t={}){this.tokens=t.tokens??{},this.fetchImpl=t.fetch??fetch}async listTags(t,n,s){const r=`${t}/${n}/${s}`,o=this.tagCache.get(r);if(o)return o;const i=t==="docker.io"?this.listDockerHubTags(n,s):this.listV2Tags(t,n,s);return this.tagCache.set(r,i),i}async listDockerHubTags(t,n){const s={parsed:[],raw:[]},r=[],o=new Map;let i=`https://hub.docker.com/v2/repositories/${encodeURIComponent(t)}/${encodeURIComponent(n)}/tags?page_size=100`,a=0;for(;i&&a<5;){try{const d=await this.fetchImpl(i,{headers:{Accept:"application/json"}});if(!d.ok)break;const l=await d.json();if(Array.isArray(l.results)){for(const c of l.results)if(typeof c.name=="string"&&(r.push(c.name),typeof c.last_updated=="string")){const f=Date.parse(c.last_updated);Number.isNaN(f)||o.set(c.name,f)}}i=typeof l.next=="string"?l.next:void 0}catch{break}a+=1}return r.length===0?s:{parsed:r.map(d=>{const l=H(d);if(l)return{...l,lastUpdated:o.get(d)}}).filter(d=>d!==void 0),raw:r}}async listV2Tags(t,n,s){const r={parsed:[],raw:[]},o=n==="library"?s:`${n}/${s}`,i={Accept:"application/json"},a=this.tokens[t]??process.env[`DOCKER_REGISTRY_TOKEN_${t.toUpperCase().replaceAll(/[^A-Z0-9]/g,"_")}`];a&&(i.Authorization=`Bearer ${a}`);const d=`https://${t}`,l=[];let c=`${d}/v2/${o}/tags/list?n=100`,f=i,g=0;const m=me(()=>{const $=[];for(const C of l){const R=H(C);R&&$.push({...R,lastUpdated:void 0})}return{parsed:$,raw:l}},"buildResult");for(;c&&g<5;){try{let $=await this.fetchImpl(c,{headers:f});if($.status===401&&f===i){const v=ts($.headers.get("www-authenticate"));if(v){const k=await this.fetchBearerToken(v);k&&(f={...i,Authorization:`Bearer ${k}`},$=await this.fetchImpl(c,{headers:f}))}}if(!$.ok)return g===0?r:m();const C=await $.json();if(!Array.isArray(C.tags))return g===0?r:m();for(const v of C.tags)typeof v=="string"&&l.push(v);const R=lt($.headers.get("link"));R.next?c=new URL(R.next,d).toString():c=void 0}catch{return g===0?r:m()}g+=1}return l.length===0?r:m()}async fetchBearerToken(t){const n=new URLSearchParams({scope:t.scope,service:t.service}),s=`${t.realm}?${n.toString()}`;try{const r=await this.fetchImpl(s,{headers:{Accept:"application/json"}});if(!r.ok)return;const o=await r.json();return o.token??o.access_token}catch{return}}}const es=me(e=>{const t=[];let n=0;const s=e.length;for(;n<s;){for(;n<s&&/\s/.test(e[n]??"");)n+=1;const r=n;for(;n<s&&e[n]!=="="&&e[n]!==",";)n+=1;const o=e.slice(r,n).trim();if(e[n]!=="="){for(;n<s&&e[n]!==",";)n+=1;n+=1;continue}n+=1;let i="";if(e[n]==='"'){for(n+=1;n<s&&e[n]!=='"';){if(e[n]==="\\"&&n+1<s){i+=e[n+1]??"",n+=2;continue}i+=e[n]??"",n+=1}n+=1}else{for(;n<s&&e[n]!==",";)i+=e[n]??"",n+=1;i=i.trim()}for(o.length>0&&t.push({key:o,value:i});n<s&&(/\s/.test(e[n]??"")||e[n]===",");)n+=1}return t},"splitAuthParams"),ts=me(e=>{if(!e)return;const t=/^Bearer\s+(.*)$/i.exec(e);if(!t)return;const n=new Map;for(const{key:o,value:i}of es(t[1]??""))n.set(o.toLowerCase(),i);const s=n.get("realm"),r=n.get("service");if(s)return{realm:s,scope:n.get("scope")??"",service:r??""}},"parseAuthenticate");var ns=Object.defineProperty,G=E((e,t)=>ns(e,"name",{value:t,configurable:!0}),"d$2");const ss="docker.io",os="sha256:",he=G(e=>{const t=e.trim();if(t===""||t.startsWith("$")||t.includes("${")||t.includes("$("))return;let n=t,s;const r=n.indexOf("@"+os);r>=0&&(s=n.slice(r+1),n=n.slice(0,r));let o=ss,i=n;const a=n.indexOf("/");if(a>0){const $=n.slice(0,a);($==="localhost"||$.includes(".")||$.includes(":"))&&(o=$,i=n.slice(a+1))}let d="latest",l=i;const c=i.lastIndexOf(":");c>=0&&!i.slice(c).includes("/")&&(d=i.slice(c+1),l=i.slice(0,c));let f="library",g=l;const m=l.indexOf("/");if(m>=0&&(f=l.slice(0,m),g=l.slice(m+1)),g!=="")return{digest:s,name:g,namespace:f,original:t,registry:o,tag:d}},"parseImageReference"),$e=/vis-update-ignore-next-line/i,dt=/vis-update-ignore(?:\s|$|:)/i,pt=G(e=>{const t=e.trim();return t===""||t.startsWith("#")},"isCommentOnlyLine"),rs=/^(\s*FROM\s+(?:--\S+\s+)*)([^\s#]+)(\s+AS\s+\S+)?(\s*#.*)?$/i,is=G((e,t)=>{const n=t.split(/\r?\n/),s=[];let r=!1;for(let o=0;o<n.length;o++){const i=n[o]??"";if($e.test(i)&&pt(i)){r=!0;continue}const a=rs.exec(i);if(!a){i.trim()!==""&&!i.trim().startsWith("#")&&(r=!1);continue}const d=a[2]??"";if(d==="scratch"){r=!1;continue}const l=a[4]?.trim();let c=r?"vis-update-ignore-next-line":void 0;l&&$e.test(l)?c=c??"vis-update-ignore-next-line":l&&dt.test(l)&&(c=c??"vis-update-ignore");const f=he(d);r=!1,f&&s.push({...f,file:e,ignoreReason:c,kind:"dockerfile",line:o+1})}return s},"extractFromDockerfile"),as=/^(\s*image:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,cs=G((e,t)=>{const n=t.split(/\r?\n/),s=[];let r=!1;for(let o=0;o<n.length;o++){const i=n[o]??"";if($e.test(i)&&pt(i)){r=!0;continue}const a=as.exec(i);if(!a){i.trim()!==""&&!i.trim().startsWith("#")&&(r=!1);continue}const d=a[3]??"",l=a[4]?.trim();let c=r?"vis-update-ignore-next-line":void 0;l&&$e.test(l)?c=c??"vis-update-ignore-next-line":l&&dt.test(l)&&(c=c??"vis-update-ignore");const f=he(d);r=!1,f&&s.push({...f,file:e,ignoreReason:c,kind:"compose",line:o+1})}return s},"extractFromCompose"),We=G(e=>{const t=e.toLowerCase();return t==="dockerfile"||t.startsWith("dockerfile.")?!0:t.endsWith(".dockerfile")},"isDockerfile"),ls=G(e=>{const t=e.toLowerCase();return/^(?:docker-)?compose(?:\..+)?\.ya?ml$/.test(t)},"isComposeFile"),us=new Set([".git","node_modules",".pnpm-store",".turbo",".nx","dist","build",".cache"]),ds=/(?:^|\/)(?:\.git|node_modules|\.pnpm-store|\.turbo|\.nx|dist|build|\.cache)(?:\/|$)/,ps=G(e=>{const t=[];if(!N(e))return t;const n=G((s,r)=>{let o;try{o=Q(s)}catch{return}t.push(...r==="dockerfile"?is(s,o):cs(s,o))},"collect");for(const s of ne(e,{includeDirs:!1,includeSymlinks:!1,skip:[ds]})){const{name:r}=s;us.has(r)||(We(r)?n(s.path,"dockerfile"):ls(r)&&n(s.path,"compose"))}for(const s of["Dockerfile","dockerfile","compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"]){const r=M(e,s);N(r)&&(t.some(o=>o.file===r)||n(r,We(s)?"dockerfile":"compose"))}return t},"scanDockerRepository");var fs=Object.defineProperty,X=E((e,t)=>fs(e,"name",{value:t,configurable:!0}),"c");const gs=864e5,Le=X((e,t)=>{for(const n of t)try{if(new RegExp(n).test(e))return!0}catch{if(e.includes(n))return!0}return!1},"matchesPattern"),He=X(e=>{const t=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return e.registry==="docker.io"?t:`${e.registry}/${t}`},"displayName"),ms=X(e=>e.digest!==void 0&&e.digest.length>0,"hasDigestPin"),hs=X(e=>{if(e.registry==="docker.io")return`https://hub.docker.com/${e.namespace==="library"?`_/${e.name}`:`r/${e.namespace}/${e.name}`}/tags`;const t=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return`https://${e.registry}/${t}`},"buildRegistryUrl"),$s=X((e,t)=>{const n=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return`${e.registry==="docker.io"?n:`${e.registry}/${n}`}:${t}`},"buildReplacement"),ft=X(async(e,t)=>{const{ignoreRules:n,options:s,references:r,registryOptions:o}=t,i=[],a=[],d=[];if(r.length===0)return{failed:d,ignored:a,updates:i};const l=new Qn({fetch:o?.fetch,tokens:o?.tokens}),c=new Map;for(const R of r){const v=`${R.registry}|${R.namespace}|${R.name}`,k=c.get(v)??[];k.push(R),c.set(v,k)}const f=Math.max(1,s.maxConcurrentRequests),g=[...c.keys()];let m=0;const $=X(async R=>{const v=c.get(R)??[],k=v[0];if(!k)return;let h;try{h=await l.listTags(k.registry,k.namespace,k.name)}catch{for(const p of v)d.push({file:p.file,reason:`failed to list tags for ${He(p)}`});return}for(const p of v){const y=He(p);let u;if(p.ignoreReason?u=p.ignoreReason:Le(y,s.exclude)?u="matched --exclude":s.include.length>0&&!Le(y,s.include)?u="not matched by --include":s.respectDependabotConfig&&n&&je(y,"docker",n)&&(u="ignored by dependabot/renovate config"),u){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:y,newRef:p.tag,newVersion:void 0,original:p.original,reason:u,replacement:p.original,updateType:"unknown"});continue}if(ms(p)){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:y,newRef:p.tag,newVersion:void 0,original:p.original,reason:"digest-pinned image (refresh the pin manually to update)",replacement:p.original,updateType:"digest"});continue}const w=H(p.tag);if(!w&&!s.includeBranches){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:y,newRef:p.tag,newVersion:void 0,original:p.original,reason:"non-semver tag (use --include-branches)",replacement:p.original,updateType:"unknown"});continue}if(!w&&s.mode!=="latest"){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:y,newRef:p.tag,newVersion:void 0,original:p.original,reason:`branch ref has no version baseline for --target=${s.mode}`,replacement:p.original,updateType:"unknown"});continue}const b=Te(h.parsed,w,s.mode,!1);if(!b)continue;if(s.minAgeDays!==void 0&&b.lastUpdated!==void 0&&(Date.now()-b.lastUpdated)/gs<s.minAgeDays){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:y,newRef:b.raw,newVersion:b.raw,original:p.original,reason:`release younger than ${String(s.minAgeDays)} days`,replacement:p.original,updateType:"unknown"});continue}const j=b.raw,S=$s(p,j);i.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,line:p.line,name:y,newRef:j,newVersion:j,original:p.original,replacement:S,updateType:Oe(w,b),url:hs(p)})}},"processGroup"),C=[];for(let R=0;R<Math.min(f,g.length);R++)C.push((async()=>{for(;m<g.length;){const v=g[m];m+=1,v!==void 0&&await $(v)}})());return await Promise.all(C),{failed:d,ignored:a,updates:i}},"checkDocker");var ys=Object.defineProperty,vs=E((e,t)=>ys(e,"name",{value:t,configurable:!0}),"g$1");class ks{static{E(this,"GitlabResolver")}static{vs(this,"GitlabResolver")}token;tokenHeader;defaultApiBase;fetchImpl;tagCache=new Map;constructor(t){const n=t.token??process.env.GITLAB_TOKEN;n?(this.token=n,this.tokenHeader="PRIVATE-TOKEN"):process.env.CI_JOB_TOKEN?(this.token=process.env.CI_JOB_TOKEN,this.tokenHeader="JOB-TOKEN"):(this.token=void 0,this.tokenHeader="PRIVATE-TOKEN"),this.defaultApiBase=t.apiBase??"https://gitlab.com",this.fetchImpl=t.fetch??fetch}async listTags(t){const n=this.tagCache.get(t);if(n)return n;const s=this.fetchTags(t);return this.tagCache.set(t,s),s}resolveHostAndPath(t){const n=t.indexOf("/");if(n>0){const s=t.slice(0,n);if(s.includes("."))return{host:`https://${s}`,path:t.slice(n+1)}}return{host:this.defaultApiBase,path:t}}async fetchTags(t){const{host:n,path:s}=this.resolveHostAndPath(t),r=encodeURIComponent(s),o=`${n}/api/v4/projects/${r}/repository/tags?per_page=100`,i={Accept:"application/json","User-Agent":"vis-update-gitlab"};this.token&&(i[this.tokenHeader]=this.token);try{const a=await this.fetchImpl(o,{headers:i});if(!a.ok)return{error:`HTTP ${String(a.status)} from ${n}`,parsed:[],tags:[]};const d=await a.json();if(!Array.isArray(d))return{error:`unexpected response shape from ${n}`,parsed:[],tags:[]};const l=d.map(f=>({name:typeof f.name=="string"?f.name:"",sha:typeof f.commit?.id=="string"?f.commit.id:""})).filter(f=>f.name!==""),c=[];for(const f of l){const g=H(f.name);g&&c.push({...g,sha:f.sha})}return{parsed:c,tags:l}}catch(a){return{error:a instanceof Error?a.message:"fetch failed",parsed:[],tags:[]}}}}var ws=Object.defineProperty,ye=E((e,t)=>ws(e,"name",{value:t,configurable:!0}),"x");const bs=/vis-update-ignore-next-line/i,ae=/vis-update-ignore(?:\s|$|:)/i,Rs=new Set([".gitlab-ci.yml",".gitlab-ci.yaml"]),xs=ye(e=>Rs.has(e)||e.endsWith(".gitlab-ci.yml")||e.endsWith(".gitlab-ci.yaml"),"isGitlabCiFile"),As=/^(\s*-?\s*project:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,Cs=/^(\s*ref:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,Ss=/^(\s*-?\s*component:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,Es=/^(\s*image:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,js=/^\s*(?:-\s*)?(?:include:\s*)?\{([^}]*)\}\s*(?:#.*)?$/,Ts=/project:\s*(['"]?)([^'"\s,}]+)\1/,Os=/ref:\s*(['"]?)([^'"\s,}]+)\1/,Is=/component:\s*(['"]?)([^'"\s,}]+)\1/,Ds=/^(\s*-\s*name:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,Us=/^(\s*-\s*)(['"]?)([^'"\s#:]+:[^'"\s#]+)\2(\s*#.*)?$/,Ns=/^\s*-?\s*[a-z_][\w-]*:\s*(?:#.*)?$/i,Ps=ye((e,t)=>{const n=t.split(/\r?\n/),s=[],r=[];let o,i=!1,a=!1,d=-1;for(let l=0;l<n.length;l++){const c=n[l]??"",f=c.trim(),g=f===""||f.startsWith("#");if(bs.test(c)&&g){i=!0;continue}const m=/^(\s*)services:\s*(?:#.*)?$/.exec(c);if(m){a=!0,d=m[1]?.length??0;continue}a&&f!==""&&!f.startsWith("-")&&!f.startsWith("#")&&c.search(/\S/)<=d&&(a=!1,d=-1);const $=Es.exec(c);if($){const h=$[3]??"",p=he(h);if(p){const y=$[4]?.trim();let u=i?"vis-update-ignore-next-line":void 0;y&&ae.test(y)&&(u=u??"vis-update-ignore"),r.push({...p,file:e,ignoreReason:u,kind:"compose",line:l+1})}i=!1;continue}if(a){const h=Ds.exec(c),p=h?void 0:Us.exec(c),y=h??p;if(y){const u=y[3]??"",w=he(u);if(w){const b=y[4]?.trim();let j=i?"vis-update-ignore-next-line":void 0;b&&ae.test(b)&&(j=j??"vis-update-ignore"),r.push({...w,file:e,ignoreReason:j,kind:"compose",line:l+1})}}}const C=As.exec(c);if(C){o={line:l+1,project:C[3]??""};continue}const R=Cs.exec(c);if(R&&o){const h=R[4]?.trim();let p=i?"vis-update-ignore-next-line":void 0;h&&ae.test(h)&&(p=p??"vis-update-ignore"),s.push({file:e,ignoreReason:p,kind:"project",line:l+1,original:R[3]??"",project:o.project,ref:R[3]??""}),o=void 0,i=!1;continue}const v=Ss.exec(c);if(v){const h=v[3]??"",p=h.lastIndexOf("@");if(p>0){const y=h.slice(0,p),u=h.slice(p+1),w=y.lastIndexOf("/"),b=w>0?y.slice(0,w):y,j=w>0?y.slice(w+1):void 0,S=v[4]?.trim();let x=i?"vis-update-ignore-next-line":void 0;S&&ae.test(S)&&(x=x??"vis-update-ignore"),s.push({componentName:j,file:e,ignoreReason:x,kind:"component",line:l+1,original:h,project:b,ref:u})}i=!1;continue}const k=js.exec(c);if(k){const h=k[1]??"",p=/#(.*)$/.exec(c)?.[1]?.trim();let y=i?"vis-update-ignore-next-line":void 0;p&&ae.test(p)&&(y=y??"vis-update-ignore");const u=Is.exec(h);if(u){const w=u[2]??"",b=w.lastIndexOf("@");if(b>0){const j=w.slice(0,b),S=w.slice(b+1),x=j.lastIndexOf("/"),T=x>0?j.slice(0,x):j,B=x>0?j.slice(x+1):void 0;s.push({componentName:B,file:e,ignoreReason:y,kind:"component",line:l+1,original:w,project:T,ref:S})}}else{const w=Ts.exec(h),b=Os.exec(h);w&&b&&s.push({file:e,ignoreReason:y,kind:"project",line:l+1,original:b[2]??"",project:w[2]??"",ref:b[2]??""})}i=!1;continue}f!==""&&!f.startsWith("#")&&!Ns.test(c)&&(i=!1)}return{images:r,includes:s}},"extractFromGitlabCi"),Ge=/^(?:\.git|node_modules|\.pnpm-store|\.turbo|\.nx|dist|build|\.cache)$/,Bs=ye(e=>{const t=[],n=[];if(!N(e))return{images:n,includes:t};const s=ye(o=>{let i;try{i=Q(o)}catch{return}const{images:a,includes:d}=Ps(o,i);t.push(...d),n.push(...a)},"collect");for(const o of[".gitlab-ci.yml",".gitlab-ci.yaml"]){const i=M(e,o);N(i)&&s(i)}const r=M(e,".gitlab");if(N(r))for(const o of ne(r,{includeDirs:!1,includeSymlinks:!1,skip:[Ge]}))(o.name.endsWith(".yml")||o.name.endsWith(".yaml"))&&s(o.path);for(const o of ne(e,{includeDirs:!1,includeSymlinks:!1,maxDepth:2,skip:[Ge]}))xs(o.name)&&!n.some(i=>i.file===o.path)&&!t.some(i=>i.file===o.path)&&s(o.path);return{images:n,includes:t}},"scanGitlabRepository");var Vs=Object.defineProperty,le=E((e,t)=>Vs(e,"name",{value:t,configurable:!0}),"p$1");const ze=le((e,t)=>{for(const n of t)try{if(new RegExp(n).test(e))return!0}catch{if(e.includes(n))return!0}return!1},"matchesPattern"),Ms=le((e,t,n)=>{const s=e.indexOf("/");return s>0&&e.slice(0,s).includes(".")?`https://${e.slice(0,s)}/${e.slice(s+1)}/-/releases/${t}`:`${n}/${e}/-/releases/${t}`},"buildReleaseUrl"),_s=le(async(e,t)=>{const{ignoreRules:n,imageReferences:s,includes:r,options:o,registryOptions:i,resolverOptions:a}=t,d=[],l=[],c=[];if(s.length>0){const h=await ft(e,{ignoreRules:n,options:o,references:s,registryOptions:i});for(const p of h.updates)d.push({...p,ecosystem:"gitlab"});for(const p of h.ignored)l.push({...p,ecosystem:"gitlab"});c.push(...h.failed)}if(r.length===0)return{failed:c,ignored:l,updates:d};const f=new ks({apiBase:a?.apiBase,fetch:a?.fetch,token:o.gitlabToken??a?.token}),g=a?.apiBase??"https://gitlab.com",m=new Map;for(const h of r){const p=m.get(h.project)??[];p.push(h),m.set(h.project,p)}const $=Math.max(1,o.maxConcurrentRequests),C=[...m.keys()];let R=0;const v=le(async h=>{const p=m.get(h)??[];let y;try{y=await f.listTags(h)}catch{for(const u of p)c.push({file:u.file,reason:`failed to list tags for ${h}`});return}if(y.error){for(const u of p)c.push({file:u.file,reason:`failed to list tags for ${h}: ${y.error}`});return}for(const u of p){const w=u.kind==="component"&&u.componentName?`${u.project}/${u.componentName}`:u.project;let b;u.ignoreReason?b=u.ignoreReason:ze(w,o.exclude)?b="matched --exclude":o.include.length>0&&!ze(w,o.include)?b="not matched by --include":o.respectDependabotConfig&&n&&je(w,"gitlab",n)&&(b="ignored by dependabot/renovate config");const j=le(B=>({currentRef:u.ref,currentVersion:u.ref,ecosystem:"gitlab",file:u.file,ignored:!0,line:u.line,name:w,newRef:u.ref,newVersion:void 0,original:u.original,reason:B,replacement:u.original,updateType:"unknown"}),"buildIgnored");if(b){l.push(j(b));continue}const S=H(u.ref);if(!S&&!o.includeBranches){l.push(j("branch reference (use --include-branches)"));continue}if(!S&&o.mode!=="latest"){l.push(j(`branch ref has no version baseline for --target=${o.mode}`));continue}const x=Te(y.parsed,S,o.mode,!1);if(!x)continue;let T;u.kind==="component"?T=`${u.componentName?`${u.project}/${u.componentName}`:u.project}@${x.raw}`:T=x.raw,d.push({currentRef:u.ref,currentVersion:S?.raw??u.ref,ecosystem:"gitlab",file:u.file,line:u.line,name:w,newRef:x.raw,newVersion:x.raw,original:u.original,replacement:T,updateType:Oe(S,x),url:Ms(u.project,x.raw,g)})}},"processGroup"),k=[];for(let h=0;h<Math.min($,C.length);h++)k.push((async()=>{for(;R<C.length;){const p=C[R];R+=1,p!==void 0&&await v(p)}})());return await Promise.all(k),{failed:c,ignored:l,updates:d}},"checkGitlab");var Fs=Object.defineProperty,qs=E((e,t)=>Fs(e,"name",{value:t,configurable:!0}),"d$1");const Ws={disabled:new Set,exclude:[],githubToken:void 0,gitlabToken:void 0,include:[],includeBranches:!1,maxConcurrentRequests:8,minAgeDays:void 0,mode:"latest",respectDependabotConfig:!0,style:"sha"},Ls=qs(async e=>{const t={...Ws,...e.options,disabled:e.options?.disabled??new Set},n=t.respectDependabotConfig?vn(e.workspaceRoot):void 0,s={actions:{failed:[],ignored:[],updates:[]},docker:{failed:[],ignored:[],updates:[]},gitlab:{failed:[],ignored:[],updates:[]}},r=[];let o=0;if(!t.disabled.has("actions")){const d=Fn(e.workspaceRoot);d.length>0&&(o+=1,r.push(Kn(e.workspaceRoot,{ignoreRules:n,options:t,references:d}).then(l=>{s.actions=l})))}if(!t.disabled.has("docker")){const d=ps(e.workspaceRoot);d.length>0&&(o+=1,r.push(ft(e.workspaceRoot,{ignoreRules:n,options:t,references:d}).then(l=>{s.docker=l})))}if(!t.disabled.has("gitlab")){const{images:d,includes:l}=Bs(e.workspaceRoot);d.length+l.length>0&&(o+=1,r.push(_s(e.workspaceRoot,{ignoreRules:n,imageReferences:d,includes:l,options:t}).then(c=>{s.gitlab=c})))}await Promise.all(r);const i=[...s.actions.updates,...s.docker.updates,...s.gitlab.updates],a=[...s.actions.ignored,...s.docker.ignored,...s.gitlab.ignored];return{failed:[...s.actions.failed,...s.docker.failed,...s.gitlab.failed],ignored:a,perEcosystem:s,scanned:o,updates:i}},"checkEcosystems");var Hs=Object.defineProperty,se=E((e,t)=>Hs(e,"name",{value:t,configurable:!0}),"r");const Gs={actions:"GitHub Actions",docker:"Docker",gitlab:"GitLab CI"},Se=se(e=>e.updateType==="major","isBreakingUpdate"),zs=se(e=>{switch(e){case"major":return Z;case"minor":return P;case"patch":return nt;default:return tt}},"colorForUpdateType"),Ke=se(e=>{const t=zs(e.updateType),n=e.currentVersion??e.currentRef,s=e.newVersion??e.newRef,r=e.url?` ${F(e.url)}`:"",o=e.advisories&&e.advisories.length>0?` ${Z(`⚠ ${String(e.advisories.length)} advisor${e.advisories.length===1?"y":"ies"}`)}`:"";return` ${t(e.updateType.padEnd(7))} ${e.name} ${F(n)} → ${s}${o}${r}`},"formatUpdateLine"),Ye=se(e=>!e.advisories||e.advisories.length===0?[]:e.advisories.map(t=>` ${t.severity==="CRITICAL"||t.severity==="HIGH"?Z(t.severity):P(t.severity)} ${t.id} ${F(t.summary)}`),"formatAdvisoryLines"),Ks=se((e,t)=>{const n=[],s=e.updates.length;if(s===0&&e.scanned===0)return"";if(s===0){if(e.failed.length===0&&e.ignored.length===0)return n.push(`${nt("✓")} All ecosystem references up to date.`),n.join(`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`)}n.push(`
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`)},"formatEcosystemReport"),Ys=se(e=>JSON.stringify({ecosystems:{failed:e.failed,ignored:e.ignored,perEcosystem:e.perEcosystem,scanned:e.scanned,updates:e.updates}},void 0,2),"formatEcosystemJson");var Js=Object.defineProperty,te=E((e,t)=>Js(e,"name",{value:t,configurable:!0}),"o");const Zs=te(()=>{const e=et({input:process.stdin,output:process.stdout});return{ask:te(t=>new Promise(n=>{e.question(t,s=>{n(s.trim())})}),"ask"),close:te(()=>{e.close()},"close"),write:te(t=>{process.stdout.write(`${t}
|
|
16
|
-
|
|
17
|
-
${
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
${String(T.length)} package${T.length===1?" has":"s have"} newer versions available with --target latest:
|
|
26
|
-
${T.map(A=>` ${A.packageName} ${A.currentRange} → ${A.newRange} (${A.updateType})`).join(`
|
|
27
|
-
`)}`):o.info("All catalog dependencies are up to date."),Ee;const Y=s.format??i.format??"table";let W;if(s.ai){const A=Ft(s.aiType??"impact");W=await qt(D,o,n.ai,A)}const pe=!!s.dryRun;if(!pe&&r.length>0&&s.marshallCheck!==!1){const A=await Ht(r);if(A.length>0){const O=await Gt(A,{config:n?.security?.marshalls,workspaceRoot:e});if(!await zt(O))return process.exitCode=1,{applied:!1,canceled:!0,jsonEmitted:!1}}}if(p&&Y==="table"){const A=new Jt(D,W??null);let O;if(s.changelog){o.info("Fetching changelogs...");const I=await ot(D,void 0,m);O=new Map;for(const V of I){const J=V.releaseUrl??V.repoUrl??V.npmUrl;J&&O.set(V.packageName,J)}}const re=n.tui?.autoExit??!1,we=re===!0?3:typeof re=="number"?re:0,Ue=await Be(_.createElement(Zt,{autoExitSeconds:we,changelogUrls:O,checkedCount:S,filteredOutEntries:T,isDryRun:pe,store:A,totalCatalogEntries:h}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),be=process.stdout.columns||80;process.stdout.write(`
|
|
28
|
-
`);for(const I of D){const V=I.vulnerabilities?.length||I.socketReport&&I.socketReport.alerts.length>0,J=!!I.acceptedRisk,Re=V?J?"✓":"⚠":"✓",ht=J?"gray":I.updateType==="major"?"red":I.updateType==="minor"?"yellow":"green",ge=I.socketReport?.score.overall,$t=ge===void 0?"":` [${String(Math.round(ge*100))}%]`,Ne=ge===void 0?void 0:Ut(ge);process.stdout.write(`${Ae(_.createElement(L,null," ",_.createElement(L,{color:ht},Re),` ${I.packageName} ${I.currentRange} → ${I.newRange}`,_.createElement(L,{dimColor:!0},` ${I.updateType}`),Ne?_.createElement(L,{color:Ne},$t):null),{columns:be})}
|
|
29
|
-
`)}if(process.stdout.write(`
|
|
30
|
-
`),o.info(st(D,b)),S>D.length){const I=[...R.values()].reduce((J,Re)=>J+Re.size,0),V=I>S?` (${String(I)} catalog entries, ${String(I-S)} duplicates)`:"";o.log(),o.info(`Checked ${String(S)} unique packages${V}: ${String(De)} up-to-date${x.length>0?`, ${String(x.length)} failed`:""}`)}if(T.length>0){process.stdout.write(`
|
|
31
|
-
`);const I=`${String(T.length)} package${T.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${Ae(_.createElement(L,{color:"yellow"},` ${I}`),{columns:be})}
|
|
32
|
-
`);for(const V of T)process.stdout.write(`${Ae(_.createElement(L,null," ",_.createElement(L,{dimColor:!0},V.packageName),` ${V.currentRange} → ${V.newRange}`,_.createElement(L,{dimColor:!0},` ${V.updateType}`)),{columns:be})}
|
|
33
|
-
`)}const fe=Array.isArray(Ue)?Ue:[];if(fe.length>0&&!pe){o.info(`
|
|
34
|
-
Applying ${String(fe.length)} updates...
|
|
35
|
-
`);const I={...s,install:s.install??i.install};return await Xe(e,t,fe,I,o,m,n.editorconfig??!0),{applied:!0,canceled:!1,jsonEmitted:!1}}return{applied:!1,canceled:fe.length===0,jsonEmitted:!1}}if(pe){if(Y==="json"){const A={failed:x,filteredByTarget:T,ignored:B,outdated:D};W&&(A.aiAnalysis=W),process.stdout.write(`${JSON.stringify(A,void 0,2)}
|
|
36
|
-
`)}else o.info(`Would update ${String(D.length)} dependencies:
|
|
37
|
-
`),Ze(D,x,Y,o,b),W&&(o.info(""),o.info(Ve(W))),Je(T,o);return{applied:!1,canceled:!1,jsonEmitted:Y==="json"}}W&&Y!=="json"&&(o.info(Ve(W)),o.info(""));let oe=D;if(s.interactive&&(oe=await Nt(D),oe.length===0))return o.info("No updates selected."),{applied:!1,canceled:!0,jsonEmitted:!1};o.info(`Updating ${String(oe.length)} catalog dependencies...
|
|
38
|
-
`),Ze(oe,[],Y,o,b),Je(T,o);const mt={...s,install:s.install??i.install};return await Xe(e,t,oe,mt,o,m),{applied:!0,canceled:!1,jsonEmitted:Y==="json"}},"executeCatalogUpdate"),ro=U(async(e,t,n,s,r,o)=>{const i={dev:s.dev,filters:q(s.filter),global:s.global,interactive:s.interactive,latest:s.latest||s.target==="latest",noOptional:s.optional===!1,noSave:s.save===!1,packages:r,prod:s.prod,recursive:s.recursive,workspaceRoot:s.workspaceRoot},{command:a,warnings:d}=dn(t,n,i);for(const c of d)o.warn(c);const l=`${a.bin} ${a.args.join(" ")}`.trim();if(s.dryRun)return o.info(`Would run: ${l}`),Ee;o.info(`Running: ${l}`);try{const{code:c,output:f}=await rt(a.bin,a.args,{cwd:e,env:process.env});if(c!==0)return o.error(`
|
|
39
|
-
${Z("✖")} Update failed (exit code ${String(c)})`),o.error(` Command: ${l}`),o.error(` Directory: ${e}
|
|
40
|
-
`),process.exitCode=c,{applied:!1,canceled:!1,jsonEmitted:!1};s.peer!==!0&&it(f)&&o.info(at)}catch(c){const f=c.status??1;return o.error(`
|
|
41
|
-
${Z("✖")} Update failed (exit code ${String(f)})`),o.error(` Command: ${l}`),o.error(` Directory: ${e}
|
|
42
|
-
`),process.exitCode=f,{applied:!1,canceled:!1,jsonEmitted:!1}}return{applied:!0,canceled:!1,jsonEmitted:!1}},"executePmWrapper"),io=U(async(e,t,n)=>{const s=e.latest===!0||e.target==="latest";if(t||!s||e.dryRun===!0||e.yes===!0||e.interactive===!0)return!0;if(!(process.stdout.isTTY&&!ve))return n.error(`${Z("✖")} Refusing to run blanket --latest update in a non-interactive context.`),n.error(" Re-run with --yes to confirm, --dry-run to preview, or pass explicit package names."),process.exitCode=1,!1;const r=et({input:process.stdin,output:process.stdout});try{const o=(await new Promise(i=>{r.question(`${P("⚠")} About to upgrade ALL dependencies to their latest versions. This may include breaking changes.
|
|
43
|
-
Continue? [y/N] `,i)})).trim().toLowerCase();return o==="y"||o==="yes"?!0:(n.info("Aborted."),!1)}finally{r.close()}},"requireBlanketUpdateConfirmation"),ao=U((e,t)=>{const n=new Set;e.actions===!1&&n.add("actions"),e.docker===!1&&n.add("docker"),e.gitlab===!1&&n.add("gitlab");const s=e.style??"sha";if(s!=="sha"&&s!=="preserve")throw new Error(`Invalid --style "${s}". Use: sha or preserve.`);const r=e.latest===!0?"latest":e.target??"latest";if(r!=="latest"&&r!=="minor"&&r!=="patch")throw new Error(`Invalid target "${r}". Use: latest, minor, or patch.`);const o=r,i=t.update??{};return{disabled:n,exclude:[...q(e.exclude),...q(i.exclude)],githubToken:e.actionsToken??void 0,gitlabToken:e.gitlabToken??void 0,include:q(e.include),includeBranches:e.includeBranches===!0,maxConcurrentRequests:typeof e.maxConcurrentRequests=="number"&&e.maxConcurrentRequests>0?e.maxConcurrentRequests:8,minAgeDays:typeof i.minimumReleaseAge=="number"&&i.minimumReleaseAge>0?i.minimumReleaseAge/1440:void 0,mode:o,respectDependabotConfig:!0,style:s}},"buildEcosystemOptions"),co=U((e,t)=>e.dryRun===!0||process.exitCode!==void 0&&process.exitCode!==0||t.canceled?!1:!!(e.yes===!0||e.interactive===!0&&t.applied||t.applied&&process.stdout.isTTY&&!ve),"shouldApplyEcosystem"),lo=U(async(e,t,n,s,r)=>{const o=ao(t,n);if(o.disabled.size===3)return;let i;try{i=await Ls({options:o,workspaceRoot:e})}catch(g){s.warn(`${P("⚠")} Ecosystem update scan failed: ${g.message}`);return}if(i.scanned===0)return i;const a=t.format??"table",d=!!t.dryRun;if(a==="json")r.jsonEmitted?s.warn(`${P("⚠")} ${String(i.updates.length)} ecosystem update${i.updates.length===1?"":"s"} available but not emitted in --format=json (catalog already wrote one JSON document). Rerun with --format=table or --no-catalog to see them.`):process.stdout.write(`${Ys(i)}
|
|
44
|
-
`);else if(a!=="minimal"){const g=Ks(i,{showIgnored:t.interactive===!0});g&&s.info(g)}if(d||i.updates.length===0)return i;if(!co(t,r))return s.info(`
|
|
45
|
-
${P("ℹ")} ${String(i.updates.length)} ecosystem reference${i.updates.length===1?"":"s"} can be bumped. Re-run with \`--yes\` to apply (or \`--no-actions\` / \`--no-docker\` / \`--no-gitlab\` to silence by ecosystem).`),i;let l=i.updates;if(t.interactive===!0&&process.stdout.isTTY&&!ve&&(l=await Qs(i.updates),l.length===0))return s.info(`${P("ℹ")} No ecosystem updates selected.`),i;const{applied:c,skipped:f}=Zn(l);if(c.length>0&&s.info(`
|
|
46
|
-
${String(c.length)} ecosystem reference${c.length===1?"":"s"} updated.`),f.length>0){s.warn(`${P("⚠")} ${String(f.length)} ecosystem update${f.length===1?"":"s"} skipped:`);for(const g of f)s.warn(` ${g.update.name} (${g.update.file}:${String(g.update.line)}): ${g.reason}`)}return i},"runEcosystemUpdate"),uo=U(e=>{const t=e.style;if(t!==void 0&&t!=="sha"&&t!=="preserve")throw new Error(`Invalid --style "${t}". Use: sha or preserve.`);const n=e.target;if(n!==void 0&&n!=="latest"&&n!=="minor"&&n!=="patch")throw new Error(`Invalid --target "${n}". Use: latest, minor, or patch.`)},"validateEcosystemFlags"),To=U(async({argument:e,logger:t,options:n,visConfig:s,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");uo(n);let o=e;const i=r,{packageManager:a}=Pt(i);if(n.typosquatCheck!==!1){if(o.length>0){const c=o.map(m=>Xt(m)),f=s?.security?.typosquatAllowlist,g=await Kt(c.map(m=>m.name),f);if(!g.ok){process.exitCode=1;return}o=c.map((m,$)=>{const C=g.packages[$];return C!==m.name?m.versionSpec?`${C}@${m.versionSpec}`:C??"":o[$]??""})}else if(!await Yt(i,s?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!Bt(i,a)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(Vt(i,a))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(!await io(n,o.length>0,t))return;const d=n.catalog!==!1&&Mt(i,a);let l;if(d)l=await oo(i,a,s??{},n,o,t);else{const c=Lt(i,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),f=c.name==="aube"?"":_t(c.name);l=await ro(i,c.name,f,n,o,t)}o.length===0&&await lo(i,n,s??{},t,l)},"execute");export{To as default,jo as formatMinutesAsTimeString,to as parseNpmReleaseAgeValue,gt as parseTimeStringToMinutes,no as readPmNativeMinimumReleaseAge,io as requireBlanketUpdateConfirmation,lo as runEcosystemUpdate};
|
|
1
|
+
var Fe=Object.defineProperty;var $=(e,o)=>Fe(e,"name",{value:o,configurable:!0});import{createRequire as Ae}from"node:module";import{M as g,i as S,$ as N}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{b1 as pe,b2 as X,b3 as Me,b4 as Ne,b5 as Z,b6 as Be,b7 as He,b0 as De,b8 as We,aV as Le,b9 as he,ba as me,bb as ke}from"./bin.js";import{d as ye}from"./config.js";import{NATIVE_BINDING_VERSION as ie,allKnownTags as qe,tagsFromPath as Ge,tagsFromPaths as Je,parseShebang as Ke}from"#native";const _e=Ae(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=$(e=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[o,t]=I.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return I.getBuiltinModule(e)}return _e(e)},"__cjs_getBuiltinModule"),{readdirSync:de,statSync:z,readFileSync:B,existsSync:H,writeFileSync:x,unlinkSync:Pe,rmSync:Te,chmodSync:Ce}=V("node:fs"),{cwd:M}=I,{createInterface:Ie}=V("node:readline"),{spawnSync:R}=V("node:child_process"),{basename:Ve}=V("node:path");var Ue=Object.defineProperty,q=$((e,o)=>Ue(e,"name",{value:o,configurable:!0}),"c$5");const ze=/^# ([^:\s]\S*)(?::\s+(.+))?$/,Ye=q(e=>{const o=[],t=e.split(`
|
|
2
|
+
`);let r;for(const s of t){if(s.startsWith("#!")||s.startsWith("# Generated by")||s.startsWith("# NOTE:")||s==="set -e"||s==="")continue;const n=ze.exec(s);if(n){r&&o.push(r),r={command:"",id:n[1]??"",...n[2]?{name:n[2]}:{}};continue}r?r.command=r.command.length>0?`${r.command}
|
|
3
|
+
${s}`:s:r={command:s,id:"(custom)"}}return r&&o.push(r),o},"parseStageScript"),Qe=q((e,o)=>{const t=g(e,o),r=[],s=new Set(pe);if(S(t))for(const n of de(t)){if(n.startsWith(".")||n==="_"||!s.has(n))continue;const i=g(t,n);if(!z(i).isFile())continue;const a=N(i),c=Ye(a);r.push({blocks:c,rawLineCount:a.split(`
|
|
4
|
+
`).length,stage:n})}return r.sort((n,i)=>n.stage.localeCompare(i.stage)),{hooksDirectory:o,stages:r}},"listHooks"),Xe=q(e=>{const o=[];if(e.stages.length===0)return o.push(`No hooks installed in ${e.hooksDirectory}/.`),o;o.push(`Hooks in ${e.hooksDirectory}/:`);for(const t of e.stages)if(o.push("",`${t.stage} (${t.rawLineCount} lines)`),t.blocks.length===0)o.push(" (empty)");else for(const r of t.blocks){const s=r.name?`${r.id} — ${r.name}`:r.id;o.push(` - ${s}`);const n=r.command.split(`
|
|
5
|
+
`).find(i=>i.trim()!=="");if(n){const i=n.length>120?`${n.slice(0,117)}...`:n;o.push(` ${i}`)}}return o},"formatListResult"),Ze=q((e,o)=>{const t=Qe(M(),e);for(const r of Xe(t))o.info(r)},"runList");var eo=Object.defineProperty,j=$((e,o)=>eo(e,"name",{value:o,configurable:!0}),"o$2");const ae=5;if(ie!==ae)throw new Error(`vis native binding ABI mismatch: expected ${ae}, got ${ie}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const $e={".releaserc":["release-config","vis-config"],".releaserc.json":["release-config","vis-config"],"aube-lock.yaml":["aube-lock","lockfile"],"aube-workspace.yaml":["aube-workspace","vis-config"],"nx.json":["nx-workspace","vis-config"],"packem.config.js":["packem-config","vis-config"],"packem.config.mjs":["packem-config","vis-config"],"packem.config.ts":["packem-config","vis-config"],"pnpm-workspace.yaml":["pnpm-workspace","vis-config"],"project.json":["nx-project","vis-config"],"turbo.json":["turbo-config","vis-config"],"vis.config.js":["vis-config"],"vis.config.ts":["vis-config"]},ve=[[".releaserc.json",["release-config","vis-config"]]],we=j(e=>{const o=new Set,t=Ve(e),r=$e[t];if(r)for(const n of r)o.add(n);const s=t.toLowerCase();for(const[n,i]of ve)if(s.endsWith(n))for(const a of i)o.add(a);return o},"classifyVis"),be=new Set([...Object.values($e).flat(),...ve.flatMap(([,e])=>e)]);let K;const xe=j(()=>(K||(K=new Set(qe())),K),"getPrekUniverse");j(e=>{const o=new Set(Ge(e)),t=we(e);return{all:new Set([...o,...t]),prek:o,vis:t}},"classify");const oo=j(e=>{const o=Je([...e]),t=new Map;for(const[r,s]of e.entries()){const n=new Set(o[r]),i=we(s),a=new Set([...n,...i]);t.set(s,{all:a,prek:n,vis:i})}return t},"classifyMany");j(e=>Ke(e),"parseShebang");const to=j(e=>xe().has(e)||be.has(e),"isKnownTag");j(e=>xe().has(e),"isPrekTag");j(e=>be.has(e),"isVisTag");const ro=j((e,o)=>{const{all:t}=e;if(o.types&&o.types.length>0){for(const r of o.types)if(!t.has(r))return!1}if(o.typesOr&&o.typesOr.length>0){let r=!1;for(const s of o.typesOr)if(t.has(s)){r=!0;break}if(!r)return!1}if(o.excludeTypes&&o.excludeTypes.length>0){for(const r of o.excludeTypes)if(t.has(r))return!1}return!0},"matchesFilter");var no=Object.defineProperty,_=$((e,o)=>no(e,"name",{value:o,configurable:!0}),"i$3");const so=_(e=>{let o=0;const{length:t}=e,r=_(()=>{for(;o<t&&/\s/.test(e[o]);)o+=1},"skipWs"),s=_(()=>{if(e[o]!=='"')throw new Error(`expected string at ${o}`);o+=1;const c=o;for(;o<t&&e[o]!=='"';)o+=e[o]==="\\"?2:1;const l=e.slice(c,o);return o+=1,JSON.parse(`"${l}"`)},"parseString"),n=_(()=>{switch(r(),e[o]){case'"':{s();break}case"[":{i();break}case"{":{a();break}default:for(;o<t&&!",}]".includes(e[o])&&!/\s/.test(e[o]);)o+=1}},"parseValue"),i=_(()=>{if(o+=1,r(),e[o]==="]"){o+=1;return}for(;o<t;)if(n(),r(),e[o]===",")o+=1,r();else if(e[o]==="]"){o+=1;return}},"parseArray"),a=_(()=>{o+=1,r();const c=new Set;if(e[o]==="}"){o+=1;return}for(;o<t;){r();const l=s();if(c.has(l))throw new Error(`Duplicate key: ${l}`);if(c.add(l),r(),e[o]!==":")throw new Error(`expected colon at ${o}`);if(o+=1,n(),r(),e[o]===",")o+=1,r();else if(e[o]==="}"){o+=1;return}}},"parseObject");r(),n()},"detectDuplicateJsonKeys"),io=_((e,o,t)=>{let r=0;for(const s of e){const n=B(g(t.root,s),"utf8");try{JSON.parse(n),so(n)}catch(i){const a=i instanceof Error?i.message:String(i);t.logger.info(`${s}: Failed to json decode (${a})`),r=1}}return r},"runCheckJson");var ao=Object.defineProperty,Ee=$((e,o)=>ao(e,"name",{value:o,configurable:!0}),"c$4");const co=Ee(e=>{const o=R("git",["rev-parse","--git-dir"],{cwd:e,encoding:"utf8"});if(o.status!==0)return!1;const t=o.stdout.trim(),r=t.startsWith("/")?t:g(e,t);return H(g(r,"MERGE_MSG"))?H(g(r,"MERGE_HEAD"))||H(g(r,"rebase-apply"))||H(g(r,"rebase-merge")):!1},"isInMerge"),fo=["<<<<<<< ","======= ",`=======\r
|
|
6
|
+
`,`=======
|
|
7
|
+
`,">>>>>>> "],lo=Ee((e,o,t)=>{if(!o.includes("--assume-in-merge")&&!co(t.root))return 0;let r=0;for(const s of e){const n=B(g(t.root,s),"utf8").split(`
|
|
8
|
+
`);for(let i=0;i<n.length;i+=1){const a=n[i]+(i<n.length-1?`
|
|
9
|
+
`:"");for(const c of fo)a.startsWith(c)&&(t.logger.info(`${s}:${i+1}: Merge conflict string ${JSON.stringify(c.trim())} found`),r=1)}}return r},"runCheckMergeConflict");var uo=Object.defineProperty,go=$((e,o)=>uo(e,"name",{value:o,configurable:!0}),"c$3");const po=go((e,o,t)=>{let r=0;for(const s of e){const n=g(t.root,s),i=B(n);if(i.length===0)continue;let a=i.length;const c=i[a-1];if(c!==10&&c!==13){x(n,Buffer.concat([i,Buffer.from([10])])),t.logger.info(`Fixing ${s}`),r=1;continue}for(;a>0&&(i[a-1]===10||i[a-1]===13);)a-=1;if(a===0){x(n,Buffer.alloc(0)),t.logger.info(`Fixing ${s}`),r=1;continue}const l=i.subarray(a);let d;l[0]===13&&l[1]===10?d=Buffer.from([13,10]):l[0]===13?d=Buffer.from([13]):d=Buffer.from([10]),!l.equals(d)&&(x(n,Buffer.concat([i.subarray(0,a),d])),t.logger.info(`Fixing ${s}`),r=1)}return r},"runEndOfFileFixer");var ho=Object.defineProperty,ce=$((e,o)=>ho(e,"name",{value:o,configurable:!0}),"h$2");const mo={cr:Buffer.from([13]),crlf:Buffer.from([13,10]),lf:Buffer.from([10])},ko=new Set(["auto","cr","crlf","lf","no"]),yo=ce((e,o,t)=>{let r="auto";for(let n=0;n<o.length;n+=1){const i=o[n];if(i==="-f"||i==="--fix"){n+=1;const a=o[n];if(a===void 0)return t.logger.error(`mixed-line-ending: ${i} requires a value (auto|no|lf|crlf|cr)`),2;r=a}else i.startsWith("--fix=")&&(r=i.slice(6))}if(!ko.has(r))return t.logger.error(`mixed-line-ending: invalid --fix value ${r}`),2;let s=0;for(const n of e){const i=g(t.root,n),a=B(i),c=[],l=ce(f=>{const p=c.find(b=>b.kind===f);p?p.count+=1:c.push({count:1,kind:f})},"bumpCount"),d=[];let u=0;for(let f=0;f<a.length;f+=1){const p=a[f];p===13&&a[f+1]===10?(d.push({content:a.subarray(u,f),ending:"crlf"}),l("crlf"),f+=1,u=f+1):p===13?(d.push({content:a.subarray(u,f),ending:"cr"}),l("cr"),u=f+1):p===10&&(d.push({content:a.subarray(u,f),ending:"lf"}),l("lf"),u=f+1)}u<a.length&&d.push({content:a.subarray(u),ending:null});const m=c.length>1;if(r==="no"){m&&(t.logger.info(`${n}: mixed line endings`),s=1);continue}let k;if(r==="auto"){if(!m)continue;let f;for(const p of c)(!f||p.count>f.count)&&(f=p);k=f?.kind}else if(k=r,!c.some(f=>f.kind!==k&&f.count>0))continue;const w=mo[k],h=[];for(const f of d)h.push(f.content),f.ending!==null&&h.push(w);x(i,Buffer.concat(h)),t.logger.info(`${n}: fixed mixed line endings`),s=1}return s},"runMixedLineEnding");var $o=Object.defineProperty,vo=$((e,o)=>$o(e,"name",{value:o,configurable:!0}),"g$3");const fe=new Set([9,11,12,13,32]),wo=/\.(?:md|markdown|mdown|mdx)$/i,bo=vo((e,o,t)=>{let r=0;for(const s of e){const n=wo.test(s),i=g(t.root,s),a=B(i),c=[];let l=0;for(;l<=a.length;){let u=l;for(;u<a.length&&a[u]!==10;)u+=1;const m=u<a.length&&a[u]===10;let k=u,w=!1;m&&u>l&&a[u-1]===13&&(w=!0,k=u-1);const h=a.subarray(l,k);let f=h.length;for(;f>0&&fe.has(h[f-1]);)f-=1;const p=h.some(b=>!fe.has(b));if(n&&h.length>=2&&h[h.length-1]===32&&h[h.length-2]===32&&p&&(f=Math.min(f+2,h.length)),c.push(h.subarray(0,f)),w&&c.push(Buffer.from([13])),m&&c.push(Buffer.from([10])),!m)break;l=u+1}const d=Buffer.concat(c);d.equals(a)||(x(i,d),t.logger.info(`Fixing ${s}`),r=1)}return r},"runTrailingWhitespace");var xo=Object.defineProperty,Se=$((e,o)=>xo(e,"name",{value:o,configurable:!0}),"t");const ee={"check-json":io,"check-merge-conflict":lo,"end-of-file-fixer":po,"mixed-line-ending":yo,"trailing-whitespace":bo},Eo=Object.keys(ee).sort();Se(e=>Object.hasOwn(ee,e),"isBuiltin");const So=Se(e=>ee[e],"getBuiltin");var Ro=Object.defineProperty,O=$((e,o)=>Ro(e,"name",{value:o,configurable:!0}),"r");const F="config.json",W=1,jo=new Set(["alwaysRun","args","builtin","entry","exclude","excludeTypes","fail","files","id","name","passFilenames","types","typesOr","verbose"]),Oo=new Set(["failFast","stages","version"]),Fo=["args","exclude","excludeTypes","files","passFilenames","types","typesOr"],Re=O((e,o)=>g(e,o,F),"configPath"),Y=O(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isStringRecord"),D=O(e=>{if(!Array.isArray(e))return;const o=[];for(const t of e){if(typeof t!="string")return;o.push(t)}return o},"asStringArray"),L=O(e=>typeof e=="boolean"?e:void 0,"asBoolean"),C=O(e=>typeof e=="string"&&e.length>0?e:void 0,"asNonEmptyString"),Ao=O((e,o,t)=>{if(!Y(e))throw new TypeError("hook entry must be an object");if(typeof e.id!="string"||e.id.length===0)throw new TypeError("hook entry is missing `id`");const r={id:e.id},s=L(e.alwaysRun);s!==void 0&&(r.alwaysRun=s);const n=D(e.args);n&&(r.args=n);const i=C(e.builtin);i&&(r.builtin=i);const a=C(e.entry);a&&(r.entry=a);const c=C(e.exclude);c&&(r.exclude=c);const l=D(e.excludeTypes);l&&(r.excludeTypes=l);const d=C(e.fail);d&&(r.fail=d);const u=C(e.files);u&&(r.files=u);const m=C(e.name);m&&(r.name=m);const k=L(e.passFilenames);k!==void 0&&(r.passFilenames=k);const w=D(e.types);w&&(r.types=w);const h=D(e.typesOr);h&&(r.typesOr=h);const f=L(e.verbose);if(f!==void 0&&(r.verbose=f),[r.builtin,r.entry,r.fail].filter(p=>p!==void 0).length!==1)throw new TypeError(`hook "${r.id}" must set exactly one of \`builtin\`, \`entry\`, \`fail\``);if(r.fail!==void 0){const p=Fo.filter(b=>r[b]!==void 0);if(p.length>0)throw new TypeError(`hook "${r.id}" is a \`fail\` entry — remove ${p.join(", ")} (filters do not apply)`)}for(const p of Object.keys(e))jo.has(p)||o.push({hookId:r.id,message:`unknown field "${p}" ignored`,stage:t});return r},"parseEntry"),_o=O((e,o)=>{if(!Y(e))throw new TypeError("hook config must be an object");if(e.version!==W)throw new TypeError(`unsupported hook config version: expected ${W}, got ${String(e.version)}`);if(!Y(e.stages))throw new TypeError("hook config is missing `stages` map");const t={};for(const[n,i]of Object.entries(e.stages)){if(!Array.isArray(i))throw new TypeError(`hook config: stage "${n}" must be an array`);t[n]=i.map(a=>Ao(a,o,n))}const r={stages:t,version:W},s=L(e.failFast);s!==void 0&&(r.failFast=s);for(const n of Object.keys(e))Oo.has(n)||o.push({message:`unknown top-level field "${n}" ignored`});return r},"parseConfig"),je=O((e,o=X,t)=>{const r=Re(e,o);if(!S(r))return;const s=N(r);let n;try{n=JSON.parse(s)}catch(i){const a=i instanceof Error?i.message:String(i);throw new TypeError(`failed to parse ${r}: ${a}`,{cause:i})}return _o(n,t??[])},"loadHookConfig"),Po=O((e,o,t)=>{const r=Re(e,o);x(r,`${JSON.stringify(t,void 0,4)}
|
|
10
|
+
`,"utf8")},"writeHookConfig");var To=Object.defineProperty,v=$((e,o)=>To(e,"name",{value:o,configurable:!0}),"d");const Co=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"]]),Io=/[<>=!~]=/,Mo=/github\.com[/:]([^/\s]+\/[^/\s.]+)/i,No="# Generated by `vis hook migrate` from prek",Bo=v(e=>`#!/usr/bin/env sh
|
|
11
|
+
${No}
|
|
12
|
+
exec vis hook run ${e} "$@"
|
|
13
|
+
`,"stageScriptBody"),oe=v(e=>{for(const o of Me)if(S(g(e,o)))return o},"detectPrekConfig"),Ho=v(e=>Ne[e]??e,"mapPrekStage"),Do=v(e=>Mo.exec(e)?.[1]??e,"normalizeRepoKey"),Wo=v(e=>{if(Io.test(e))return;if(e.startsWith("@")){const r=e.indexOf("@",1);if(r===-1)return{name:e,version:"latest"};const s=e.slice(r+1).trim();return{name:e.slice(0,r),version:s||"latest"}}const o=e.indexOf("@");if(o===-1)return{name:e,version:"latest"};const t=e.slice(o+1).trim();return{name:e.slice(0,o),version:t||"latest"}},"parseAdditionalDep"),Lo=v(e=>{const o=[];for(const t of[e.types,e.types_or,e.exclude_types])for(const r of t??[])to(r)||o.push(r);return o},"unknownTypes"),Vo=v((e,o)=>(e.stages&&e.stages.length>0?e.stages:o??["pre-commit"]).map(t=>Ho(t)),"resolveStages"),qo=v((e,o,t)=>{const r=e.id??"<unknown>",s=Z.has(o),n={id:r};return e.name&&(n.name=e.name),e.language==="fail"?(n.fail=e.entry??e.name??r,n):(t?n.builtin=t:e.entry&&(n.entry=e.entry),Array.isArray(e.args)&&e.args.length>0&&(n.args=[...e.args]),s||(e.files&&(n.files=e.files),e.exclude&&(n.exclude=e.exclude),e.types&&e.types.length>0&&(n.types=[...e.types]),e.types_or&&e.types_or.length>0&&(n.typesOr=[...e.types_or]),e.exclude_types&&e.exclude_types.length>0&&(n.excludeTypes=[...e.exclude_types])),(e.pass_filenames===!1||s)&&(n.passFilenames=!1),(e.always_run||s)&&(n.alwaysRun=!0),e.verbose&&(n.verbose=!0),n)},"buildHookEntry"),Go=v((e,o,t,r)=>{if(Array.isArray(e.additional_dependencies))for(const s of e.additional_dependencies){const n=Wo(s);if(!n){r.push(`"${o}": additional_dependency "${s}" uses a pip-style pin and cannot be added to package.json — install manually.`);continue}t.push({hookId:o,name:n.name,raw:s,version:n.version})}},"collectAdditionalDeps"),Jo=v(e=>{const o={},t=[],r=[],s=[],n=[];(e.files||e.exclude)&&r.push("top-level files/exclude filter dropped — apply it per hook if needed");for(const a of e.repos??[]){const c=a.repo??"<unknown>",l=c==="local",d=l?void 0:Do(c);for(const u of a.hooks??[]){const m=u.id??"<unknown>";let k;if(l){const f=u.language??"system";if(!Be.has(f)){t.push({hookId:m,reason:`language "${f}" needs an isolated toolchain — run via prek or reimplement as a system command`,repo:c});continue}if(f!=="fail"&&!u.entry){t.push({hookId:m,reason:"missing `entry`",repo:c});continue}}else if(d&&(k=Co.get(`${d}#${m}`)),!k){t.push({hookId:m,reason:`remote repo "${c}"@${a.rev??"?"} has no bundled equivalent — run via prek or replace with a system command`,repo:c});continue}Go(u,m,n,s);const w=Lo(u);w.length>0&&r.push(`hook "${m}": unsupported types ${w.join(", ")} — those entries are ignored by the dispatcher`);const h=Vo(u,e.default_stages);for(const f of h){if(f==="manual")continue;if(!He.has(f)){t.push({hookId:m,reason:`unsupported stage "${f}"`,repo:c});continue}const p=qo(u,f,k),b=o[f];b?b.push(p):o[f]=[p]}}}const i={stages:o,version:W};return e.fail_fast&&(i.failFast=!0),{additionalDeps:n,config:i,droppedFilters:r,manualSteps:s,skippedHooks:t}},"convertPrekConfig"),Ko=v(e=>{const o=De(e);if(o&&typeof o=="object")return o},"parsePrekConfig"),Uo=v(e=>{if(e.endsWith(".toml")){const t=We(e);return t&&typeof t=="object"?t:void 0}const o=N(e);return Ko(o)},"loadPrekConfig"),zo=v((e,o,t)=>{const r=g(e,"package.json"),s=[],n=[];if(!S(r)||o.length===0)return{added:s,skipped:n};const i=N(r),a=JSON.parse(i),c=a.devDependencies??{},l=a.dependencies??{};for(const u of o){if(u.name in c||u.name in l){n.push(u.name);continue}c[u.name]=u.version,s.push(u.name)}if(s.length===0)return{added:s,skipped:n};a.devDependencies=c;const d=Le(r,i,{defaultIndent:" ",useEditorconfig:t});return x(r,`${JSON.stringify(a,void 0,d)}
|
|
14
|
+
`,"utf8"),{added:s,skipped:n}},"mergeAdditionalDependencies"),Yo=v((e,o)=>{const t=g(e,o);ye(t),x(g(t,"README.md"),["# Vis hook config","","`config.json` is the single source of truth for what each stage","script runs. Auto-generated by `vis hook migrate`. Edit by hand","or re-run the migrator after updating your prek config.","",`Bundled builtins: ${Eo.join(", ")}`,""].join(`
|
|
15
|
+
`),"utf8")},"writeConfigReadme"),Qo=v((e,o)=>{R("prek",["--version"],{cwd:e,encoding:"utf8"}).status===0?R("prek",["uninstall"],{cwd:e,encoding:"utf8"}).status===0?o.info("Detached prek via `prek uninstall`."):o.info("`prek uninstall` did not exit cleanly — continuing. You may need to run it manually."):o.info("prek binary not found on PATH — skipping `prek uninstall`. Run it manually if prek is installed elsewhere.")},"detachPrek"),Oe=v((e,o,t,r={})=>{const s=oe(e),n=r.dryRun===!0;if(!s)return{isError:!0,message:"No prek configuration found (.pre-commit-config.yaml, .pre-commit-config.yml, or prek.toml)"};t.info(`Found prek config at ${s}`);const i=g(e,s),a=N(i),c=Uo(i);if(!c)return{isError:!0,message:`Could not parse ${s}`};const{additionalDeps:l,config:d,droppedFilters:u,manualSteps:m,skippedHooks:k}=Jo(c),w=Object.keys(d.stages);if(w.length===0&&k.length===0)return{isError:!0,message:`${s} has no hooks to migrate`};if(!n){const y=R("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(y.status===0){const J=y.stdout?.toString().trim();J&&(J.includes(".prek")||J.includes("prek-hooks"))&&R("git",["config","--local","--unset","core.hooksPath"],{cwd:e})}const T=he(o);if(T.isError)return T;T.message&&t.info(T.message)}const h=g(e,o);n||ye(h),n?t.info(` (would write) ${o}/${F}`):(Po(e,o,d),Yo(e,o),t.info(` Wrote ${o}/${F}`));let f=0;for(const y of w){const T=Bo(y);n?t.info(` (would write) ${o}/${y}`):(x(g(h,y),T,{mode:493}),t.info(` Wrote ${o}/${y}`)),f+=1}const{added:p,skipped:b}=n?{added:l.map(y=>y.name),skipped:[]}:zo(e,l,r.useEditorconfig);if(p.length>0){const y=n?"would add":"Added";t.info(`${y} ${p.length} package${p.length===1?"":"s"} to devDependencies: ${p.join(", ")}`),n||t.info("Run your package manager's install (e.g. `pnpm install`) to pick up the new devDependencies.")}b.length>0&&t.info(`Skipped ${b.length} already-declared package${b.length===1?"":"s"}: ${b.join(", ")}`),n||Qo(e,t);const se=`${i}.bak`;if(n?t.info(` (would remove) ${s} and back it up to ${s}.bak`):(S(se)||x(se,a,"utf8"),Pe(i),t.info(`Removed ${s} (backup at ${s}.bak)`)),k.length>0){t.warn(`Skipped ${k.length} hook${k.length===1?"":"s"} that cannot run without prek:`);for(const y of k)t.warn(` - ${y.repo}::${y.hookId} — ${y.reason}`)}if(u.length>0){t.warn("Partial filter translations:");for(const y of u)t.warn(` - ${y}`)}if(m.length>0){t.warn("Manual follow-up required:");for(const y of m)t.warn(` - ${y}`)}return{isError:!1,message:`${n?"would migrate":"Migration complete:"} ${f} stage script${f===1?"":"s"} ${n?"into":"written to"} ${o}/`}},"migrateFromPrek");var Xo=Object.defineProperty,te=$((e,o)=>Xo(e,"name",{value:o,configurable:!0}),"i$2");const Zo=te(e=>{const o=[];let t=0;for(let r=0;r<e.length;r+=1)e[r]===0&&(r>t&&o.push(e.subarray(t,r).toString("utf8")),t=r+1);return t<e.length&&o.push(e.subarray(t).toString("utf8")),o},"splitNulBuffer"),U=te((e,o,t)=>{const r=R("git",[...e],{cwd:t,encoding:"buffer"});if(r.status!==0){const s=r.stderr?r.stderr.toString():"";throw new Error(`git ${o} failed${s?`: ${s.trim()}`:""}`)}return r.stdout.length===0?[]:Zo(r.stdout)},"gitListFiles"),et=te((e,o)=>{switch(e.kind){case"all":return U(["ls-files","-z"],"ls-files",o);case"range":return U(["diff","--name-only","--diff-filter=ACM","-z",e.fromRef,e.toRef],"diff --from-ref/--to-ref",o);case"staged":return U(["diff","--cached","--name-only","--diff-filter=ACM","-z"],"diff --cached",o);default:{const t=e;throw new Error(`unknown discover mode: ${JSON.stringify(t)}`)}}},"discoverFiles");var ot=Object.defineProperty,re=$((e,o)=>ot(e,"name",{value:o,configurable:!0}),"i$1");const le=re((e,o)=>{try{return new RegExp(e)}catch(t){const r=t instanceof Error?t.message:String(t);throw new Error(`invalid ${o} regex ${JSON.stringify(e)}: ${r}`,{cause:t})}},"compileRegex"),tt=re(e=>e.types&&e.types.length>0||e.typesOr&&e.typesOr.length>0||e.excludeTypes&&e.excludeTypes.length>0||!1,"hasTagFilters"),rt=re((e,o)=>{let t=e;if(o.files){const n=le(o.files,"files");t=t.filter(i=>n.test(i))}if(o.exclude){const n=le(o.exclude,"exclude");t=t.filter(i=>!n.test(i))}if(!tt(o))return[...t];const r=oo(t),s={excludeTypes:o.excludeTypes,types:o.types,typesOr:o.typesOr};return t.filter(n=>{const i=r.get(n);return i?ro(i,s):!1})},"applyHookFilter");var nt=Object.defineProperty,A=$((e,o)=>nt(e,"name",{value:o,configurable:!0}),"u$2");const st=32*1024,it=A((e,o)=>{const t=[],r=Math.max(1024,st-o);let s=[],n=0;for(const i of e){const a=Buffer.byteLength(i,"utf8")+8;n+a>r&&s.length>0&&(t.push(s),s=[],n=0),s.push(i),n+=a}return s.length>0&&t.push(s),t},"chunkFiles"),at=A(e=>({error:A(o=>{e.error(o)},"error"),info:A(o=>{e.info(o)},"info")}),"builtinLoggerFor"),ue=A((e,o,t)=>t?t.message:o?`terminated by signal ${o}`:`exited with status ${String(e)}`,"describeSpawnFailure"),ct=A((e,o,t,r,s)=>{const n=r?s.extraArgs:[];if(!t||o.length===0){const c=R("sh",["-c",e,"sh",...n],{cwd:s.root,stdio:"inherit"});return c.status===null?(s.logger.error(`hook command failed: ${ue(c.status,c.signal,c.error)}`),1):c.status}const i=Buffer.byteLength(e,"utf8")+Buffer.byteLength("sh","utf8")+Buffer.byteLength("-c","utf8")+n.reduce((c,l)=>c+Buffer.byteLength(l,"utf8")+8,0)+64;let a=0;for(const c of it(o,i)){const l=R("sh",["-c",`${e} "$@"`,"sh",...n,...c],{cwd:s.root,stdio:"inherit"});l.status===null?(s.logger.error(`hook command failed: ${ue(l.status,l.signal,l.error)}`),a|=1):a|=l.status}return a},"runShellCommand"),ft=A((e,o,t)=>{if(e.fail!==void 0)return t.logger.info(e.fail),1;const r=Z.has(t.stage);let s;try{s=rt(o,e)}catch(c){const l=c instanceof Error?c.message:String(c);return t.logger.error(`hook "${e.id}": ${l}`),2}if(s.length===0&&e.alwaysRun!==!0&&!r)return 0;const n=e.passFilenames!==!1;if(e.verbose){const c=e.name??e.id;t.logger.info(`+ ${c}`)}if(e.builtin){const c=So(e.builtin);if(!c)return t.logger.error(`unknown builtin "${e.builtin}" referenced by hook "${e.id}"`),2;const l={logger:at(t.logger),root:t.root};try{return c(s,e.args??[],l)}catch(d){const u=d instanceof Error?d.message:String(d);return t.logger.error(`builtin "${e.builtin}" crashed: ${u}`),1}}if(e.entry===void 0)return t.logger.error(`hook "${e.id}" has no \`entry\`, \`builtin\`, or \`fail\` to run`),2;const i=(e.args??[]).map(c=>`'${c.replaceAll("'",String.raw`'\''`)}'`).join(" "),a=i?`${e.entry} ${i}`:e.entry;return ct(a,s,n,r,t)},"runHookEntry"),lt=A((e,o,t,r)=>{const s=e.stages[o];if(!s||s.length===0)return 0;let n=0;for(const i of s){const a=ft(i,t,r);if(a!==0&&(n|=a,e.failFast))return n}return n},"runStage");var ut=Object.defineProperty,ne=$((e,o)=>ut(e,"name",{value:o,configurable:!0}),"s");const gt="pre-commit",dt=ne(e=>{if(e.lastCommit&&(e.fromRef||e.toRef))throw new Error("--last-commit cannot be combined with --from-ref or --to-ref");const o=e.lastCommit?"HEAD~1":e.fromRef,t=e.lastCommit?"HEAD":e.toRef;if(o&&!t||t&&!o)throw new Error("--from-ref and --to-ref must be specified together");return o&&t?{fromRef:o,kind:"range",toRef:t}:e.allFiles?{kind:"all"}:{kind:"staged"}},"resolveDiscoverMode"),pt=ne((e,o,t,r)=>{const s=t.stage??gt,n=je(e,o);if(!n)throw new Error(`No hook config found at ${o}/config.json. Install or migrate hooks first.`);const i=n.stages[s];if(!i||i.length===0)return r.info(`No hooks configured for stage "${s}".`),0;const a=Z.has(s)?void 0:dt(t),c=a?.kind==="all"?" (--all-files)":a?.kind==="range"?` (${a.fromRef}..${a.toRef})`:"";r.info(`Running ${s}${c}`);const l=a?et(a,e):[],d={extraArgs:t.extraArgs??[],logger:r,root:e,stage:s};return lt(n,s,l,d)},"runHookStage"),ht=ne((e,o,t)=>{const r=pt(M(),e,o,t);if(r!==0)throw new Error(`Hook stage exited with code ${r}`)},"runRun");var mt=Object.defineProperty,kt=$((e,o)=>mt(e,"name",{value:o,configurable:!0}),"e");const yt=kt((e=X)=>{if(R("git",["config","--local","core.hooksPath"]).status!==0)return{isError:!1,message:"No custom hooks path configured"};const{status:o,stderr:t}=R("git",["config","--local","--unset","core.hooksPath"]);if(o===null)return{isError:!0,message:"git command not found"};if(o&&o!==5)return{isError:!0,message:String(t)};const r=g(e,"_");return S(r)&&Te(r,{force:!0,recursive:!0}),{isError:!1,message:""}},"uninstallHooks");var $t=Object.defineProperty,G=$((e,o)=>$t(e,"name",{value:o,configurable:!0}),"u");const vt=new Set(pe),wt=G(e=>{const o=R("sh",["-n",e],{encoding:"utf8"});if(o.status===null)return`failed to run "sh -n" (${o.error?.message??"unknown error"})`;if(o.status!==0)return o.stderr.trim()||`sh -n exited with ${o.status}`},"runSyntaxCheck"),bt=G((e,o)=>{const t=[],r=g(e,o),s=R("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(s.status===0){const i=s.stdout.trim(),a=`${o}/_`;i&&i!==a&&t.push({kind:"warning",message:`core.hooksPath is "${i}" — expected "${a}". Re-run \`vis hook install\` to fix.`})}else t.push({kind:"warning",message:"core.hooksPath is not set — run `vis hook install`."});if(S(g(r,"_"))||t.push({kind:"error",message:`Dispatcher directory ${o}/_ is missing. Run \`vis hook install\`.`}),!S(r))return t.push({kind:"error",message:`Hooks directory ${o}/ is missing.`}),{issues:t,ok:!1};let n=!1;for(const i of de(r)){if(i.startsWith(".")||i==="_"||i===F||i==="README.md")continue;if(!vt.has(i)){t.push({kind:"warning",message:`Unknown hook "${i}" — not a standard git hook.`,path:g(o,i)});continue}const a=g(r,i);if(!z(a).isFile())continue;n=!0;const c=z(a).mode&511;(c&64)===0&&t.push({kind:"warning",message:`Script is not owner-executable (mode ${c.toString(8)}).`,path:g(o,i)});const l=wt(a);l&&t.push({kind:"error",message:`Shell syntax error: ${l}`,path:g(o,i)})}if(n){const i=g(r,F);if(S(i))try{je(e,o)}catch(a){t.push({kind:"error",message:`${F} is malformed: ${a instanceof Error?a.message:String(a)}`,path:g(o,F)})}else t.push({kind:"error",message:`Stage scripts are present but ${o}/${F} is missing. Re-run \`vis hook migrate\`.`})}return{issues:t,ok:!t.some(i=>i.kind==="error")}},"validateHooks"),xt=G((e,o)=>{if(e.issues.length===0)return[`Hook directory ${o}/ looks good.`];const t=[];for(const r of e.issues){const s=r.kind==="error"?"ERROR":"WARN ",n=r.path?` (${r.path})`:"";t.push(`${s} ${r.message}${n}`)}return t.push("",e.ok?"No errors — warnings only.":`${e.issues.filter(r=>r.kind==="error").length} error(s).`),t},"formatValidationResult"),Et=G((e,o)=>{const t=bt(M(),e),r=xt(t,e);for(const s of r)s.startsWith("ERROR")||s.startsWith("WARN")?o.warn(s):o.info(s);if(!t.ok)throw new Error("Hook validation failed")},"runValidate");var St=Object.defineProperty,E=$((e,o)=>St(e,"name",{value:o,configurable:!0}),"i");const P=E(e=>e.hooksDir??X,"resolveHooksDirectory"),ge=E(e=>new Promise(o=>{const t=Ie({input:process.stdin,output:process.stdout});t.question(`${e} (y/N) `,r=>{t.close();const s=r.trim().toLowerCase();o(s==="y"||s==="yes")})}),"confirmPrompt"),Rt=E(async(e,o,t)=>{const r=M(),s=me(r),n=oe(r);if(s&&n)throw new Error(`Found both husky (${s}/) and prek (${n}). Remove or migrate one before running \`vis hook install\`.`);if(s){if(o.info(`Existing husky installation found at ${s}/`),await ge("Would you like to migrate your husky hooks to vis?")){const a=ke(r,e,o,{useEditorconfig:t});if(a.isError)throw new Error(a.message);a.message&&o.info(a.message);return}o.info("Aborting install. Remove husky first or run 'vis hook migrate' to migrate.");return}if(n){if(o.info(`Existing prek configuration found at ${n}`),await ge("Would you like to migrate your prek hooks to vis?")){const a=Oe(r,e,o,{useEditorconfig:t});if(a.isError)throw new Error(a.message);a.message&&o.info(a.message);return}o.info("Aborting install. Remove the prek config first or run 'vis hook migrate' to migrate.");return}o.info(`Installing git hooks in ${e}/...`);const i=he(e);if(i.message){if(i.isError)throw new Error(i.message);o.info(i.message);return}S(g(r,e,"pre-commit"))||x(g(r,e,"pre-commit"),`#!/usr/bin/env sh
|
|
16
|
+
`,{mode:493}),o.info("Git hooks installed successfully.")},"executeInstall"),jt=E((e,o,t,r)=>{const s=M(),n=me(s),i=oe(s);if(n&&i)throw new Error(`Found both husky (${n}/) and prek (${i}). Migrate one at a time — rename or remove one before retrying.`);if(!n&&!i)throw new Error("No husky (.husky/) or prek (.pre-commit-config.yaml / prek.toml) configuration found to migrate.");o&&t.info("(dry-run) no files will be written");const a=n?ke(s,e,t,{dryRun:o,useEditorconfig:r}):Oe(s,e,t,{dryRun:o,useEditorconfig:r});if(a.isError)throw new Error(a.message);a.message&&t.info(a.message)},"executeMigrate"),Q="# vis:secrets-hook",Ot=`#!/usr/bin/env sh
|
|
17
|
+
${Q}
|
|
18
|
+
# Scan staged files for secrets before each commit. Remove this block or the whole file to disable.
|
|
19
|
+
pnpm exec vis secrets --staged --quiet || exit 1
|
|
20
|
+
`,Ft=E((e,o,t)=>{if(e!=="secrets")throw new Error(`Unknown hook add target "${String(e)}". Currently supported: "secrets".`);const r=M(),s=g(r,o,"pre-commit");if(!S(g(r,o)))throw new Error(`Hooks directory ${o}/ does not exist. Run \`vis hook install\` first.`);if(S(s)){const n=N(s);if(n.includes(Q)){t.info(`Secrets hook already present in ${s}.`);return}if(/\bvis secrets\b/.test(n)){t.warn(`Found a \`vis secrets\` invocation in ${s} without the managed marker — leaving it untouched.`);return}const i=`${n.trimEnd()}
|
|
21
|
+
|
|
22
|
+
${Q}
|
|
23
|
+
pnpm exec vis secrets --staged --quiet || exit 1
|
|
24
|
+
`;x(s,i),Ce(s,493),t.info(`Appended secrets scan to ${s}.`);return}x(s,Ot,{mode:493}),t.info(`Created ${s} with a secrets-scan pre-commit check.`)},"executeAdd"),At=E((e,o)=>{o.info("Removing git hooks...");const t=yt(e);if(t.message){if(t.isError)throw new Error(t.message);o.info(t.message);return}o.info("Git hooks removed successfully.")},"executeUninstall"),_t=E(async({logger:e,options:o,visConfig:t})=>{await Rt(P(o),e,t?.editorconfig??!0)},"hookInstallImpl"),Pt=E(({logger:e,options:o})=>{At(P(o),e)},"hookUninstallImpl"),Tt=E(({logger:e,options:o,visConfig:t})=>{jt(P(o),!!o.dryRun,e,t?.editorconfig??!0)},"hookMigrateImpl"),Ct=E(({logger:e,options:o})=>{Ze(P(o),e)},"hookListImpl"),It=E(({logger:e,options:o})=>{Et(P(o),e)},"hookValidateImpl"),Mt=E(({argument:e,logger:o,options:t})=>{ht(P(t),{allFiles:!!t.allFiles,extraArgs:e.slice(1),fromRef:t.fromRef,lastCommit:!!t.lastCommit,stage:e[0],toRef:t.toRef},o)},"hookRunImpl"),Nt=E(({argument:e,logger:o,options:t})=>{Ft(e[0],P(t),o)},"hookAddImpl"),qt=_t,Gt=Pt,Jt=Tt,Kt=Ct,Ut=It,zt=Mt,Yt=Nt;export{Yt as hookAddExecute,qt as hookInstallExecute,Kt as hookListExecute,Jt as hookMigrateExecute,zt as hookRunExecute,Gt as hookUninstallExecute,Ut as hookValidateExecute};
|