@buddysh/buddy 0.11.4 → 0.11.6

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.
Files changed (163) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/bin/cli.js +19 -19
  3. package/dist/chunk-042211k4.js +2 -0
  4. package/dist/chunk-04sy4xt9.js +2 -0
  5. package/dist/chunk-0j7rmr49.js +2 -0
  6. package/dist/{chunk-yp1tgdh3.js → chunk-0t8q4880.js} +1 -1
  7. package/dist/{chunk-hsa07n7c.js → chunk-0xxqw1h6.js} +1 -1
  8. package/dist/{chunk-zgkrhymn.js → chunk-1p9hgr6z.js} +1 -1
  9. package/dist/{chunk-8hjvthz4.js → chunk-1zv0s60b.js} +2 -2
  10. package/dist/{chunk-ngh4jbgp.js → chunk-1zz8bd1c.js} +2 -2
  11. package/dist/chunk-217bhn06.js +2 -0
  12. package/dist/{chunk-428c5652.js → chunk-27jza51d.js} +1 -1
  13. package/dist/chunk-2k4gkkc6.js +2 -0
  14. package/dist/chunk-2kkwhrfz.js +2 -0
  15. package/dist/{chunk-f53y8ans.js → chunk-2r5s586j.js} +2 -2
  16. package/dist/{chunk-yr8eta7p.js → chunk-2vmaeyh3.js} +8 -8
  17. package/dist/{chunk-hd5j9e3c.js → chunk-3f34dgnn.js} +1 -1
  18. package/dist/{chunk-jnb80k2x.js → chunk-3k62kevg.js} +1 -1
  19. package/dist/{chunk-5av2vnvv.js → chunk-3nygvd78.js} +2 -2
  20. package/dist/{chunk-96ht6hwd.js → chunk-43p5vzvb.js} +2 -2
  21. package/dist/{chunk-p6qbqsyp.js → chunk-47ancrn1.js} +2 -2
  22. package/dist/{chunk-bmnx3s41.js → chunk-4m1vgh1w.js} +9 -9
  23. package/dist/{chunk-q4t568hv.js → chunk-4sqwtry6.js} +1 -1
  24. package/dist/{chunk-qd2s51gc.js → chunk-56q8k98m.js} +1 -1
  25. package/dist/{chunk-rayxmbcx.js → chunk-5bedx7s3.js} +1 -1
  26. package/dist/{chunk-pkr6905p.js → chunk-5qssa20j.js} +1 -1
  27. package/dist/{chunk-kprtsn8c.js → chunk-6qb96bg0.js} +1 -1
  28. package/dist/{chunk-ds4stft2.js → chunk-7g13yp3v.js} +1 -1
  29. package/dist/{chunk-c3es7pgf.js → chunk-86kymmen.js} +1 -1
  30. package/dist/{chunk-5044y9en.js → chunk-88k998tw.js} +2 -2
  31. package/dist/{chunk-11hdrnf6.js → chunk-8dq3gews.js} +2 -2
  32. package/dist/{chunk-phfmnnne.js → chunk-8mrbvnae.js} +2 -2
  33. package/dist/chunk-90x7e4ra.js +106 -0
  34. package/dist/{chunk-61xecp1z.js → chunk-95je030a.js} +1 -1
  35. package/dist/{chunk-05me15qw.js → chunk-9cnq8y3d.js} +1 -1
  36. package/dist/chunk-9ychha5r.js +2 -0
  37. package/dist/{chunk-3901s7h9.js → chunk-abfyz98y.js} +1 -1
  38. package/dist/{chunk-jtxcr5yw.js → chunk-ak9s0vnr.js} +2 -2
  39. package/dist/chunk-az2vad31.js +2 -0
  40. package/dist/{chunk-e68nf7cm.js → chunk-b4a5gw9c.js} +1 -1
  41. package/dist/chunk-ba1t70ph.js +2 -0
  42. package/dist/{chunk-sw2538r0.js → chunk-bjg4gxs4.js} +2 -2
  43. package/dist/{chunk-hfjywbbc.js → chunk-bprmzg0p.js} +1 -1
  44. package/dist/{chunk-rc2mk5x6.js → chunk-bxdbf2kj.js} +1 -1
  45. package/dist/{chunk-mkzmjg3f.js → chunk-c64qrkpz.js} +2 -2
  46. package/dist/{chunk-yngahb11.js → chunk-d1yhv10h.js} +2 -2
  47. package/dist/{chunk-0hc97k0t.js → chunk-d73ympxb.js} +3 -3
  48. package/dist/{chunk-g30dr44w.js → chunk-d7e6tqmr.js} +2 -2
  49. package/dist/{chunk-aa277p5r.js → chunk-d84k4mek.js} +1 -1
  50. package/dist/chunk-dbawp9kg.js +2 -0
  51. package/dist/{chunk-m4p7cnvk.js → chunk-df75rm51.js} +1 -1
  52. package/dist/chunk-dh9dw57m.js +2 -0
  53. package/dist/chunk-dkhvqxrk.js +2 -0
  54. package/dist/{chunk-cwfkm7h9.js → chunk-e1cvrjf0.js} +2 -2
  55. package/dist/{chunk-2et8yavs.js → chunk-e3wax332.js} +1 -1
  56. package/dist/{chunk-vqa6vte3.js → chunk-e4bcngja.js} +1 -1
  57. package/dist/{chunk-tjc2vgwn.js → chunk-e6wny1pp.js} +1 -1
  58. package/dist/chunk-ecs7b2kg.js +2 -0
  59. package/dist/chunk-edgg7wxb.js +2 -0
  60. package/dist/{chunk-cs066zt9.js → chunk-ej7gpg23.js} +2 -2
  61. package/dist/{chunk-patms7t8.js → chunk-erbqszzp.js} +1 -1
  62. package/dist/{chunk-cgvt98pd.js → chunk-f7aw9cr3.js} +1 -1
  63. package/dist/{chunk-08x5b93v.js → chunk-ffb50kwa.js} +1 -1
  64. package/dist/{chunk-r763e19p.js → chunk-ffp0mgf5.js} +3 -3
  65. package/dist/{chunk-b1w41hfs.js → chunk-ge2r1zmq.js} +1 -1
  66. package/dist/chunk-h82t0mnh.js +2 -0
  67. package/dist/{chunk-g24hav8e.js → chunk-j3bzf5m0.js} +7 -7
  68. package/dist/{chunk-be629jhq.js → chunk-j8era2yj.js} +2 -2
  69. package/dist/{chunk-25sz1y7j.js → chunk-jaewrjw3.js} +1 -1
  70. package/dist/{chunk-vbeeyhhe.js → chunk-jhfkzveb.js} +2 -2
  71. package/dist/chunk-k10hm62v.js +2 -0
  72. package/dist/{chunk-nrr8z2z7.js → chunk-k53ndvfv.js} +2 -2
  73. package/dist/{chunk-k26wnmzk.js → chunk-k8pnnyq1.js} +1 -1
  74. package/dist/{chunk-0w695m54.js → chunk-kbkvw42w.js} +1 -1
  75. package/dist/{chunk-b9escac0.js → chunk-kqam9qmd.js} +2 -2
  76. package/dist/{chunk-c8rzx3a1.js → chunk-kypdeb29.js} +1 -1
  77. package/dist/{chunk-wn6pbyzn.js → chunk-kzgyhhtz.js} +1 -1
  78. package/dist/{chunk-3pqra420.js → chunk-m1zp48mr.js} +1 -1
  79. package/dist/{chunk-0scz1dv5.js → chunk-mfhwcnxr.js} +1 -1
  80. package/dist/chunk-mmc8tvbb.js +2 -0
  81. package/dist/{chunk-txtrpypt.js → chunk-mtp0aygy.js} +2 -2
  82. package/dist/{chunk-xs12dtf1.js → chunk-myswpb7z.js} +1 -1
  83. package/dist/{chunk-jz5zs812.js → chunk-nf9dfx4t.js} +1 -1
  84. package/dist/{chunk-fjp3a7hp.js → chunk-nj38e2km.js} +1 -1
  85. package/dist/{chunk-68fw3ma0.js → chunk-nr1c0dny.js} +1 -1
  86. package/dist/chunk-nz0ns7ah.js +3 -0
  87. package/dist/chunk-p3qck29r.js +2 -0
  88. package/dist/{chunk-hptfq3rg.js → chunk-pkcvytq6.js} +1 -1
  89. package/dist/{chunk-hmskwy76.js → chunk-pqbzatbq.js} +1 -1
  90. package/dist/{chunk-40znfg3x.js → chunk-pwa2tt2e.js} +1 -1
  91. package/dist/chunk-qe63pqwy.js +2 -0
  92. package/dist/{chunk-4jyw358y.js → chunk-qmhd1bgx.js} +1 -1
  93. package/dist/chunk-qxc77b08.js +2 -0
  94. package/dist/{chunk-bffxf4xy.js → chunk-qzens4rg.js} +1 -1
  95. package/dist/chunk-r9k5vnrw.js +2 -0
  96. package/dist/{chunk-v1wfa758.js → chunk-rfvn4j6n.js} +1 -1
  97. package/dist/chunk-rnv477z3.js +2 -0
  98. package/dist/{chunk-3cvng2nz.js → chunk-rp3ytb19.js} +1 -1
  99. package/dist/{chunk-pskqrv5r.js → chunk-rpkwbqr8.js} +1 -1
  100. package/dist/chunk-s7da3h7c.js +2 -0
  101. package/dist/chunk-swphrsyr.js +2 -0
  102. package/dist/chunk-sx8pyc83.js +2 -0
  103. package/dist/chunk-sy3h7j1x.js +2 -0
  104. package/dist/{chunk-eseshkd0.js → chunk-t3340cv5.js} +1 -1
  105. package/dist/{chunk-1qgr52wx.js → chunk-te6etc5c.js} +1 -1
  106. package/dist/chunk-ttx1jk5b.js +2 -0
  107. package/dist/{chunk-tw047td6.js → chunk-tvrz1xp5.js} +1 -1
  108. package/dist/chunk-v5qn8kjd.js +2 -0
  109. package/dist/chunk-vj9stet1.js +2 -0
  110. package/dist/chunk-w6bd9r6p.js +2 -0
  111. package/dist/{chunk-193abzy6.js → chunk-wkq57ssc.js} +1 -1
  112. package/dist/{chunk-s4zb0fcj.js → chunk-wsxy4w86.js} +1 -1
  113. package/dist/chunk-x59yras6.js +2 -0
  114. package/dist/chunk-xfmzts7d.js +2 -0
  115. package/dist/chunk-xj99g66b.js +4 -0
  116. package/dist/{chunk-6p4qz8qv.js → chunk-y1hppm93.js} +1 -1
  117. package/dist/{chunk-1cpdz49v.js → chunk-yj6xx2b8.js} +1 -1
  118. package/dist/{chunk-3fzbvs2p.js → chunk-zc7g037n.js} +1 -1
  119. package/dist/{chunk-s6z3gm2s.js → chunk-zhfrmseh.js} +1 -1
  120. package/dist/{chunk-vgtmrd4c.js → chunk-zpxg12ep.js} +1 -1
  121. package/dist/src/git/github-provider.d.ts +12 -0
  122. package/dist/src/git/provider.d.ts +1 -0
  123. package/dist/src/index.js +1 -1
  124. package/dist/src/setup.js +1 -1
  125. package/dist/src/types.d.ts +1 -0
  126. package/dist/src/utils/github-actions-parser.d.ts +10 -0
  127. package/dist/src/utils/lock-file.d.ts +26 -2
  128. package/package.json +1 -1
  129. package/dist/chunk-0paakbpj.js +0 -2
  130. package/dist/chunk-19zyq15p.js +0 -2
  131. package/dist/chunk-24c2ab29.js +0 -2
  132. package/dist/chunk-28y7eayr.js +0 -2
  133. package/dist/chunk-2wj5xtdn.js +0 -2
  134. package/dist/chunk-49znmbh8.js +0 -2
  135. package/dist/chunk-86x1vsjw.js +0 -2
  136. package/dist/chunk-8fw0v7bv.js +0 -3
  137. package/dist/chunk-90zmqn5k.js +0 -2
  138. package/dist/chunk-97qf7mdt.js +0 -2
  139. package/dist/chunk-a4hzzn28.js +0 -2
  140. package/dist/chunk-b357cgb0.js +0 -2
  141. package/dist/chunk-brfyymhf.js +0 -2
  142. package/dist/chunk-dgfb8k0h.js +0 -2
  143. package/dist/chunk-e0gweha1.js +0 -2
  144. package/dist/chunk-e2t5jq26.js +0 -106
  145. package/dist/chunk-emb5v4wv.js +0 -2
  146. package/dist/chunk-emyvrx5t.js +0 -2
  147. package/dist/chunk-fpnjpgrb.js +0 -2
  148. package/dist/chunk-fr5c326k.js +0 -2
  149. package/dist/chunk-gkpd5nw2.js +0 -2
  150. package/dist/chunk-hns85dqw.js +0 -2
  151. package/dist/chunk-mcwxpdg9.js +0 -2
  152. package/dist/chunk-ng7px8gx.js +0 -2
  153. package/dist/chunk-ppmabn5h.js +0 -2
  154. package/dist/chunk-rwggcfgn.js +0 -2
  155. package/dist/chunk-s25rb4t2.js +0 -2
  156. package/dist/chunk-sc7emb71.js +0 -2
  157. package/dist/chunk-vdd1cghr.js +0 -2
  158. package/dist/chunk-vj1sdxpp.js +0 -2
  159. package/dist/chunk-xznnmhyt.js +0 -2
  160. package/dist/chunk-yk183r6z.js +0 -2
  161. package/dist/chunk-ys1qqcpp.js +0 -2
  162. package/dist/chunk-ytmxd5fk.js +0 -4
  163. package/dist/chunk-zxgkp71x.js +0 -2
@@ -1,106 +0,0 @@
1
- // @bun
2
- import{$c as u0}from"./chunk-phfmnnne.js";import{bd as w0,cd as T0,dd as F0,ed as l0}from"./chunk-r763e19p.js";import{fd as c0}from"./chunk-be629jhq.js";import{ld as z0,md as j0,nd as y0}from"./chunk-11hdrnf6.js";import{qd as f0,td as g0}from"./chunk-mkzmjg3f.js";import{ke as e,le as d}from"./chunk-5av2vnvv.js";import{if as m0}from"./chunk-8hjvthz4.js";import{lf as l,mf as P0,nf as O0,of as h0,pf as o}from"./chunk-yngahb11.js";import{$f as _0,ag as k0,bg as c}from"./chunk-0hc97k0t.js";import{kg as g,og as b0,pg as v0}from"./chunk-3901s7h9.js";import{ph as H0}from"./chunk-193abzy6.js";import{zh as K0}from"./chunk-e68nf7cm.js";import{Bh as x0,Ch as Z0,Dh as U0,Eh as R0}from"./chunk-hfjywbbc.js";import{Wk as D}from"./chunk-q4t568hv.js";import N0 from"fs";import{join as a}from"path";import y from"process";var d0={critical:"\uD83D\uDD34 Critical",high:"\uD83D\uDFE0 High",moderate:"\uD83D\uDFE1 Moderate",low:"\u26AA Low"};class Q0{generateDashboard($,X={}){let{showOpenPRs:Q=!0,showDetectedDependencies:K=!0,showDeprecatedDependencies:H=!0,showVulnerableDependencies:Z=!0,includePackageJson:W=!0,includeDependencyFiles:O=!0,includeGitHubActions:z=!0,bodyTemplate:L}=X,_="Dependency Dashboard";if(L)return{title:"Dependency Dashboard",body:this.applyTemplate(L,$)};let Y=this.generateDefaultHeader($);if(Z&&$.vulnerableDependencies&&$.vulnerableDependencies.length>0)Y+=this.generateVulnerableDependenciesSection($.vulnerableDependencies);if(H&&$.deprecatedDependencies&&$.deprecatedDependencies.length>0)Y+=this.generateDeprecatedDependenciesSection($.deprecatedDependencies);if(Q&&$.openPRs.length>0)Y+=this.generateOpenPRsSection($.openPRs);if($.cappedDependencies&&$.cappedDependencies.length>0)Y+=this.generateCappedDependenciesSection($.cappedDependencies);if(K)Y+=this.generateDetectedDependenciesSection({packageJson:W?$.detectedDependencies.packageJson:[],dependencyFiles:O?$.detectedDependencies.dependencyFiles:[],githubActions:z?$.detectedDependencies.githubActions:[]});return Y+=this.generateFooter(),{title:"Dependency Dashboard",body:Y}}generateDefaultHeader($){return`This issue lists Buddy updates and detected dependencies. Read the [Dependency Dashboard](https://buddy.sh/features/dependency-dashboard) docs to learn more.
3
-
4
- `}sanitizeReferences($){return $.replace(/(?<![`\w])#(\d+)(?!\d)/g,"`#$1`")}toRelativePrUrl($,X){try{let Q=new URL($);if(Q.hostname!=="github.com")return null;let K=Q.pathname.match(/^\/[^/]+\/[^/]+\/pull\/(\d+)$/);if(!K||Number(K[1])!==X)return null;return`../pull/${X}`}catch{return null}}generateCappedDependenciesSection($){let X=`## Capped dependencies
5
-
6
- The following packages are held below their latest version by a range declared elsewhere in the dependency tree. Updating this repository cannot move them \u2014 the constraint has to be widened where it is declared.
7
-
8
- | Package | Installed | Reachable | Latest | Capped by |
9
- |---|---|---|---|---|
10
- `;for(let Q of $){let K=Q.capping.map((H)=>`\`${this.sanitizeReferences(H.by)}\` (\`${H.range}\`)`).join(", ");X+=`| \`${this.sanitizeReferences(Q.name)}\` | \`${Q.installed}\` | \`${Q.reachable}\` | \`${Q.latest}\` | ${K} |
11
- `}return`${X}
12
- `}generateOpenPRsSection($){let X=`## Open
13
-
14
- The following updates have all been created. To force a retry/rebase of any, click on a checkbox below.
15
-
16
- `;for(let Q of $){let K=this.extractPackageInfo(Q),H=Q.head.replace(/[<>\s]|-->/g,""),Z=this.toRelativePrUrl(Q.url,Q.number)??Q.url,W=this.sanitizeReferences(Q.title);if(X+=` - [ ] <!-- rebase-branch=${H} -->[${W}](${Z})`,K.length>0)X+=` (\`${K.join("`, `")}\`)`;X+=`
17
- `}return X+=` - [ ] <!-- rebase-all-open-prs -->**Click on this checkbox to rebase all open PRs at once**
18
- `,X+=`
19
- `,X}generateDetectedDependenciesSection($){let X=`## Detected dependencies
20
-
21
- `;if($.packageJson.length>0)X+=this.generatePackageJsonSection($.packageJson);let Q=$.dependencyFiles.filter((W)=>W.path==="composer.json"||W.path.endsWith("/composer.json")),K=Q.filter((W)=>W.path==="composer.json"),H=Q.filter((W)=>W.path!=="composer.json");if(K.length>0)X+=this.generateComposerSection(K);if($.githubActions.length>0)X+=this.generateGitHubActionsSection($.githubActions);let Z=$.dependencyFiles.filter((W)=>!W.path.endsWith("/composer.json")&&W.path!=="composer.json");if(Z.length>0||H.length>0)X+=this.generateDependencyFilesSection([...Z,...H]);return X}generatePackageJsonSection($){let X=`<details><summary>npm</summary>
22
- <blockquote>
23
-
24
- `;for(let Q of $){let K=Q.path.split("/").pop()||Q.path;X+=`<details><summary>${K}</summary>
25
-
26
- `;let H={dependencies:Q.dependencies.filter((Z)=>Z.type==="dependencies"),devDependencies:Q.dependencies.filter((Z)=>Z.type==="devDependencies"),peerDependencies:Q.dependencies.filter((Z)=>Z.type==="peerDependencies"),optionalDependencies:Q.dependencies.filter((Z)=>Z.type==="optionalDependencies")};for(let[Z,W]of Object.entries(H))if(W.length>0)for(let O of W)X+=` - \`${O.name} ${O.currentVersion}\`
27
- `;X+=`
28
- </details>
29
-
30
- `}return X+=`</blockquote>
31
- </details>
32
-
33
- `,X}generateGitHubActionsSection($){let X=`<details><summary>github-actions</summary>
34
- <blockquote>
35
-
36
- `;for(let Q of $){X+=`<details><summary>${Q.path}</summary>
37
-
38
- `;let K=new Map;for(let H of Q.dependencies){let Z=`${H.name}@${H.currentVersion}`;if(!K.has(Z))K.set(Z,{name:H.name,currentVersion:H.currentVersion})}for(let H of K.values())X+=` - \`${H.name} ${H.currentVersion}\`
39
- `;X+=`
40
- </details>
41
-
42
- `}return X+=`</blockquote>
43
- </details>
44
-
45
- `,X}generateDependencyFilesSection($){let X=`<details><summary>dependency-files</summary>
46
- <blockquote>
47
-
48
- `;for(let Q of $){X+=`<details><summary>${Q.path}</summary>
49
-
50
- `;for(let K of Q.dependencies)X+=` - \`${K.name} ${K.currentVersion}\`
51
- `;X+=`
52
- </details>
53
-
54
- `}return X+=`</blockquote>
55
- </details>
56
-
57
- `,X}generateComposerSection($){let X=`<details><summary>composer</summary>
58
- <blockquote>
59
-
60
- `;for(let Q of $){let K=Q.path.split("/").pop()||Q.path;X+=`<details><summary>${K}</summary>
61
-
62
- `;let H={require:Q.dependencies.filter((Z)=>Z.type==="require"),"require-dev":Q.dependencies.filter((Z)=>Z.type==="require-dev")};for(let[Z,W]of Object.entries(H))if(W.length>0)for(let O of W)X+=` - \`${O.name} ${O.currentVersion}\`
63
- `;X+=`
64
- </details>
65
-
66
- `}return X+=`</blockquote>
67
- </details>
68
-
69
- `,X}generateVulnerableDependenciesSection($){let X=$.reduce((K,H)=>K+H.advisories.length,0),Q=`> [!CAUTION]
70
- > ${X} known ${X===1?"vulnerability affects":"vulnerabilities affect"} ${$.length} ${$.length===1?"dependency":"dependencies"} in this repository.
71
-
72
- | Severity | Package | Current | Advisory | Fixed in |
73
- |----------|---------|---------|----------|----------|
74
- `;for(let K of $)for(let H of K.advisories){let Z=d0[H.severity]??H.severity,W=H.url?`[${H.id}](${H.url})`:H.id;Q+=`| ${Z} | \`${K.name}\` | \`${K.currentVersion}\` | ${W} | \`${H.fixedVersion??"n/a"}\` |
75
- `}return Q+=`
76
- `,Q}generateDeprecatedDependenciesSection($){let X=`> [!WARNING]
77
- > These dependencies are deprecated and should be updated to avoid potential security risks and compatibility issues.
78
-
79
- | Datasource | Name | Replacement PR? |
80
- |------------|------|-----------------|
81
- `;for(let Q of $){let K=`\`${Q.name}\``,Z=(Q.replacementAvailable?"available":"unavailable")==="available"?"![available](https://img.shields.io/badge/available-green)":"![unavailable](https://img.shields.io/badge/unavailable-orange)";X+=`| ${Q.datasource} | ${K} | ${Z} |
82
- `}return X+=`
83
- `,X}generateFooter(){return`---
84
-
85
- - [ ] <!-- manual job -->Check this box to trigger a request for Buddy to run again on this repository
86
- `}extractPackageInfo($){let X=[],Q=[/update.*?dependency\s+(\S+)/i,/update\s+require(?:-dev)?\s+(\S+)\s+to\s+v?\d+/i,/update\s+(\S+)\s+to\s+v?\d+/i,/bump\s+(\S+)\s+from/i,/chore\(deps\):\s*update\s+dependency\s+(\S+)/i];for(let H of Q){let Z=$.title.match(H);if(Z&&Z[1]&&!X.includes(Z[1]))X.push(Z[1])}let K=[{name:"npm",pattern:/### npm Dependencies[\s\S]*?(?=###|\n\n---|z)/i},{name:"pkgx",pattern:/### Launchpad\/pkgx Dependencies[\s\S]*?(?=###|\n\n---|z)/i},{name:"actions",pattern:/### GitHub Actions[\s\S]*?(?=###|\n\n---|z)/i}];for(let H of K){let Z=$.body.match(H.pattern);if(Z){let O=Z[0].match(/\|\s*\[([^\]]+)\]\([^)]+\)\s*\|/g);if(O)for(let z of O){let L=z.match(/\|\s*\[([^\]]+)\]/);if(L&&L[1]){let _=L[1].trim();if(_.includes("`")&&_.includes("->")){let Y=z.match(/\]\(([^)]+)\)/);if(Y&&Y[1]){let j=Y[1].match(/\/diffs\/npm\/([^/]+)\//);if(j&&j[1]){let E=decodeURIComponent(j[1]);if(E&&E.length>1&&!X.includes(E))X.push(E)}}continue}if(!_.includes("://")&&!_.includes("Compare Source")&&!_.includes("badge")&&!_.includes("!")&&!_.startsWith("[![")&&!_.includes("`")&&!_.includes("->")&&!_.includes(" -> ")&&!_.match(/^\d+\.\d+/)&&!_.includes(" ")&&_.length>0&&!X.includes(_))X.push(_)}}}}if(X.length<3){let H=$.body.match(/`([^`]+)`/g);if(H)for(let Z of H){let W=Z.replace(/`/g,"").trim();if(W.includes("->")||W.includes(" -> ")||W.includes("` -> `")||W.match(/^\d+\.\d+/)||W.match(/^v\d+/)||W.match(/[\d.]+\s*->\s*[\d.]+/)||W.match(/^[\d.]+$/)||W.match(/^\d+\.\d+\.\d+/)||W.match(/^\d+\.\d+\.\d+\./)||W.match(/^\^?\d+\.\d+/)||W.match(/^~\d+\.\d+/)||W.includes("://")||W.includes("Compare Source")||W.includes("badge")||W.includes(" "))continue;if(W=W.split(",")[0].trim(),W&&W.length>1&&!X.includes(W)&&(W.startsWith("@")||W.includes("/")||W.match(/^[a-z][a-z0-9.-]*$/i)))X.push(W)}}return X}applyTemplate($,X){return $.replace(/\{\{repository\.owner\}\}/g,X.repository.owner).replace(/\{\{repository\.name\}\}/g,X.repository.name).replace(/\{\{openPRs\.count\}\}/g,X.openPRs.length.toString()).replace(/\{\{lastUpdated\}\}/g,X.lastUpdated.toISOString()).replace(/\{\{detectedDependencies\.packageJson\.count\}\}/g,X.detectedDependencies.packageJson.length.toString()).replace(/\{\{detectedDependencies\.githubActions\.count\}\}/g,X.detectedDependencies.githubActions.length.toString()).replace(/\{\{detectedDependencies\.dependencyFiles\.count\}\}/g,X.detectedDependencies.dependencyFiles.length.toString())}}var p0="buddy/",i0="no-auto-merge";function n($){let X=$.pullRequest?.autoMerge;return{enabled:X?.enabled??!1,strategy:X?.strategy??"squash",conditions:X?.conditions??[],requireGreenCI:X?.requireGreenCI??!0,optOutLabel:X?.optOutLabel??i0,securityLabel:$.security?.label??"security"}}function E0($,X,Q){let K=n(X);if(!K.enabled)return{eligible:!1,reason:"auto-merge is disabled by config"};if(K.conditions.length===0)return{eligible:!1,reason:"no auto-merge conditions configured (set conditions to at least one of patch-only, minor-only, security-only, all)"};if(!$.head.startsWith(p0))return{eligible:!1,reason:`PR #${$.number} is not a buddy PR (branch: ${$.head})`};if($.draft)return{eligible:!1,reason:`PR #${$.number} is a draft`};let H=$.labels??[];if(H.includes(K.optOutLabel))return{eligible:!1,reason:`PR #${$.number} carries the ${K.optOutLabel} label`};if(K.requireGreenCI&&Q===!1)return{eligible:!1,reason:`PR #${$.number} has failing or pending checks`};let Z=g($.body);if(!Z)return{eligible:!1,reason:`PR #${$.number} has no metadata manifest to verify update types against`};if(Z.truncated)return{eligible:!1,reason:`PR #${$.number} has a truncated manifest, so its full update set cannot be verified`};let W=I0(Z,X);if(W)return W;return A0(Z,H,K)}function I0($,X){let Q=[...o(X.packages?.groups),...X.packages?.rules??[]];if(Q.length===0||$.updates.length===0)return null;if(!$.updates.every((Z)=>Z.type&&Z.dependencyType))return null;let H=$.updates.map((Z)=>l(s0(Z),Q));if(H.some((Z)=>Z.autoMerge===!1))return{eligible:!1,reason:"a package rule holds one of these updates back from auto-merge"};if(H.every((Z)=>Z.autoMerge===!0))return{eligible:!0,reason:"every update is covered by a package rule that enables auto-merge"};return null}function s0($){return{name:$.name,currentVersion:$.current,newVersion:$.target,updateType:$.type,file:$.file,dependencyType:$.dependencyType}}function A0($,X,Q){for(let H of Q.conditions)switch(H){case"all":return{eligible:!0,reason:"all updates qualify (condition: all)"};case"patch-only":if($.updates.length>0&&$.updates.every((Z)=>W0(Z)==="patch"))return{eligible:!0,reason:"every update is a patch"};break;case"minor-only":if($.updates.length>0&&$.updates.every((Z)=>W0(Z)!=="major"))return{eligible:!0,reason:"every update is minor or patch"};break;case"security-only":if(X.includes(Q.securityLabel))return{eligible:!0,reason:"PR resolves a security advisory"};break}return{eligible:!1,reason:`update types (${[...new Set($.updates.map(W0))].join(", ")||"none"}) do not satisfy conditions (${Q.conditions.join(", ")})`}}function W0($){if($.type==="major"||$.type==="minor"||$.type==="patch")return $.type;let X=G0($.current),Q=G0($.target);if(!X||!Q)return"major";if(X[0]!==Q[0])return"major";if(X[1]!==Q[1])return"minor";return"patch"}function G0($){let X=$.trim().match(/(\d+)\.(\d+)\.(\d+)/);if(!X)return null;return[Number(X[1]),Number(X[2]),Number(X[3])]}function M0($,X,Q){let K=n(Q);if(!K.enabled)return{eligible:!1,reason:"auto-merge is disabled by config"};if(K.conditions.length===0)return{eligible:!1,reason:"no auto-merge conditions configured"};if(X.includes(K.optOutLabel))return{eligible:!1,reason:`PR carries the ${K.optOutLabel} label`};let H={schemaVersion:1,updates:$.map((W)=>({name:W.name,current:W.currentVersion,target:W.newVersion,type:W.updateType,file:W.file,dependencyType:W.dependencyType}))},Z=I0(H,Q);if(Z)return Z;return A0(H,X,K)}var S0="https://api.osv.dev",r0=1000,s={low:0,moderate:1,high:2,critical:3};function Y0($){switch($){case"dependencies":case"devDependencies":case"peerDependencies":case"optionalDependencies":return"npm";case"require":case"require-dev":return"Packagist";case"python":return"PyPI";case"rust":return"crates.io";case"go":return"Go";case"ruby":return"RubyGems";case"github-actions":return"GitHub Actions";default:return null}}function t0($){let X=$.database_specific?.severity?.toLowerCase();if(X==="low"||X==="moderate"||X==="high"||X==="critical")return X;if(X==="medium")return"moderate";let Q=$.severity?.find((K)=>K.type?.startsWith("CVSS"))?.score;if(Q){let K=a0(Q);if(K!==null){if(K>=9)return"critical";if(K>=7)return"high";if(K>=4)return"moderate";return"low"}}return"moderate"}function a0($){let X=Number($);if(Number.isFinite(X))return X;let Q=$.match(/\/([0-9](?:\.[0-9])?)$/);if(Q){let K=Number(Q[1]);return Number.isFinite(K)?K:null}return null}function e0($,X){for(let Q of $.affected??[]){if(Q.package?.name!==X)continue;for(let K of Q.ranges??[])for(let H of K.events??[])if(H.fixed)return H.fixed}return}class t{logger;concurrency;detailCache=new F0;constructor($,X=8){this.logger=$;this.concurrency=X}async findAdvisories($){let X=new Map;if($.length===0)return X;let Q=await this.queryBatch($),K=[...new Set([...Q.values()].flat())];if(K.length===0)return X;this.logger.debug(`Fetching details for ${K.length} advisory record(s)`);let H=await w0(K,(W)=>this.fetchVulnerability(W),this.concurrency),Z=new Map;for(let W of H)if(W)Z.set(W.id,W);for(let[W,O]of Q){let z=W.slice(W.indexOf(":")+1,W.lastIndexOf("@")),L=[];for(let _ of O){let Y=Z.get(_);if(!Y)continue;L.push({id:Y.id,aliases:Y.aliases??[],summary:Y.summary??Y.details?.split(`
87
- `)[0]??"No summary provided",severity:t0(Y),url:`https://osv.dev/vulnerability/${Y.id}`,fixedVersion:e0(Y,z)})}if(L.length>0)L.sort((_,Y)=>s[Y.severity]-s[_.severity]),X.set(W,L)}return X}async annotateUpdates($,X="low"){let Q=[],K=[];if($.forEach((O,z)=>{let L=Y0(O.dependencyType);if(!L)return;let _=B0(O.currentVersion);if(!_)return;let Y=L==="GitHub Actions"?_.replace(/^v/i,""):_;if(!Y)return;Q.push({name:O.name,version:Y,ecosystem:L}),K.push(z)}),Q.length===0)return $;let H=await this.findAdvisories(Q),Z=s[X],W=0;if(Q.forEach((O,z)=>{let L=H.get(r(O));if(!L?.length)return;let _=$[K[z]],Y=L.filter((J)=>{if(s[J.severity]<Z)return!1;if(!J.fixedVersion)return!1;return $1(B0(_.newVersion),J.fixedVersion)});if(Y.length>0)_.securityAdvisories=Y,W++}),W>0)this.logger.info(`\uD83D\uDD12 ${W} update(s) resolve known security advisories`);return $}async queryBatch($){let X=new Map,Q=T0($,r0);for(let K of Q)try{let H=await K0(`${S0}/v1/querybatch`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"buddy"},body:JSON.stringify({queries:K.map((W)=>({package:{name:W.name,ecosystem:W.ecosystem},version:W.version}))}),retryNonIdempotent:!0,onRetry:({delayMs:W,reason:O})=>this.logger.debug(`OSV batch retry in ${Math.round(W/1000)}s (${O})`)});if(!H.ok){this.logger.warn(`OSV advisory lookup failed: HTTP ${H.status}`);continue}(await H.json()).results?.forEach((W,O)=>{let z=W.vulns?.map((L)=>L.id)??[];if(z.length>0)X.set(r(K[O]),z)})}catch(H){this.logger.warn("OSV advisory lookup failed:",H)}return X}async fetchVulnerability($){return this.detailCache.get($,async()=>{try{let X=await K0(`${S0}/v1/vulns/${encodeURIComponent($)}`,{headers:{"User-Agent":"buddy"}});if(!X.ok)return null;return await X.json()}catch(X){return this.logger.debug(`Failed to fetch advisory ${$}:`,X),null}})}}function r($){return`${$.ecosystem}:${$.name}@${$.version}`}function B0($){return $.replace(/^[\^~>=<\s]*v?/,"").trim()}function $1($,X){if(!$||!X)return!1;try{return Bun.semver.order($,X)>=0}catch{return!1}}import X1 from"process";function Q1($){if(!$)return null;let X=$.split("/").filter(Boolean);if(X.length<2)return null;return{owner:X.slice(0,-1).join("/"),name:X[X.length-1]}}var W1=["GITHUB_REPOSITORY","CI_PROJECT_PATH","BITBUCKET_REPO_FULL_NAME"];function K1($){for(let X of W1){let Q=Q1($[X]);if(Q)return Q}return null}function C0($,X=X1.env){if(!$.repository)return{source:"unresolved",overrodeConfig:!1};let Q=$.repository,K=K1(X),H=Boolean(Q.owner&&Q.name);if(!K)return H?{owner:Q.owner,name:Q.name,source:"config",overrodeConfig:!1}:{source:"unresolved",overrodeConfig:!1};if(H&&(Q.owner!==K.owner||Q.name!==K.name)){let O=`Configured repository ${`${Q.owner}/${Q.name}`} does not match the checked-out repository ${K.owner}/${K.name}. Using ${K.owner}/${K.name} \u2014 buddy `+"operates on the checked-out repository. Update repository.owner/repository.name in your buddy config to silence this warning.";if(Q.owner=K.owner,Q.name=K.name,$.dashboard?.issueNumber!==void 0)$.dashboard.issueNumber=void 0;return{owner:K.owner,name:K.name,source:"environment",overrodeConfig:!0,warning:O}}if(!H)return Q.owner||=K.owner,Q.name||=K.name,{owner:K.owner,name:K.name,source:"environment",overrodeConfig:!1};return{owner:Q.owner,name:Q.name,source:"config",overrodeConfig:!1}}class $0{config;projectPath;logger;scanner;registryClient;eventBus=null;dashboardGenerator;constructor($,X=y.cwd()){this.config=$;this.projectPath=X;this.logger=new U0($.verbose??!1,$.logLevel),R0(this.logger),this.resolveRepositoryConfig(),this.scanner=new c0(this.projectPath,this.logger,this.config.packages?.ignorePaths),this.registryClient=new l0(this.projectPath,this.logger,this.config),this.dashboardGenerator=new Q0}async analyzeMajors($,X){if(!this.config.ai?.majorUpgrades?.enabled)return{report:"",draft:!1};let{analyzeGroupMajors:Q}=await import("./chunk-vdd1cghr.js"),{createAiClient:K}=await import("./chunk-hsa07n7c.js"),{ReleaseNotesFetcher:H}=await import("./chunk-2wj5xtdn.js"),Z=new H(this.logger),W=await Q({updates:$,config:this.config,workspace:this.projectPath,baseBranch:this.config.repository?.baseBranch||"main",files:X,ai:K(this.config,this.logger),fetchReleases:(O,z,L)=>Z.fetchSpanReleases(O,z,L),logger:this.logger});return{report:W.report,draft:W.draft}}resolveRepositoryConfig(){let $=C0(this.config);if($.warning)this.logger.warn(`\u26A0\uFE0F ${$.warning}`);else if($.source==="environment")this.logger.info(`Auto-detected repository: ${$.owner}/${$.name} from GITHUB_REPOSITORY`)}async scanForUpdates(){let $=Date.now();this.logger.info("Starting dependency update scan...");try{let X=Date.now(),Q=await this.scanner.scanProject();this.logger.info(`\u23F1\uFE0F Package file scan took ${Date.now()-X}ms`);let K=Q.reduce((N,k)=>N+k.dependencies.length,0),H=[],Z=Date.now();if(this.config.packages?.ignore&&this.config.packages.ignore.length>0)H=(await this.registryClient.getOutdatedPackages()).filter((k)=>!this.config.packages.ignore.includes(k.name));else H=await this.registryClient.getOutdatedPackages();this.logger.info(`\u23F1\uFE0F bun outdated check took ${Date.now()-Z}ms (found ${H.length} updates)`);let W=Date.now(),O=await this.checkDependencyFilesForUpdates(Q);this.logger.info(`\u23F1\uFE0F Dependency file checks took ${Date.now()-W}ms (found ${O.length} updates)`);let z=Date.now(),L=await this.checkGitHubActionsForUpdates(Q);this.logger.info(`\u23F1\uFE0F GitHub Actions checks took ${Date.now()-z}ms (found ${L.length} updates)`);let _=Date.now(),Y=await this.checkDockerfilesForUpdates(Q);this.logger.info(`\u23F1\uFE0F Docker image checks took ${Date.now()-_}ms (found ${Y.length} updates)`);let J=Date.now(),j=await this.checkZigForUpdates(Q),E=this.config.packages?.engines===!0?await this.checkEnginesForUpdates(Q):[];this.logger.info(`\u23F1\uFE0F Zig dependency checks took ${Date.now()-J}ms (found ${j.length} updates)`);let{scanCatalogs:B}=await import("./chunk-0paakbpj.js"),T=await B(this.projectPath,(N)=>this.registryClient.getLatestVersion(N),{...this.config.packages?.ignore?{ignore:this.config.packages.ignore}:{},logger:this.logger});if(T.entries.length>0)this.logger.info(`\uD83D\uDCE6 pnpm catalogs: ${T.updates.length} update(s) across ${T.entries.length} entr(ies)`);let A=Date.now(),{scanEcosystems:M}=await import("./chunk-dgfb8k0h.js"),F=await M({dir:this.projectPath,...this.config.packages?.includePrerelease!==void 0?{includePrerelease:this.config.packages.includePrerelease}:{},...this.config.packages?.ignore?{ignore:this.config.packages.ignore}:{},logger:this.logger});if(F.manifests.length>0)this.logger.info(`\u23F1\uFE0F Ecosystem checks took ${Date.now()-A}ms (found ${F.updates.length} updates across ${F.manifests.map((N)=>N.ecosystem).join(", ")})`);let q=[...H,...O,...L,...Y,...j,...E,...F.updates,...T.updates];if(this.config.packages?.ignore&&this.config.packages.ignore.length>0)q=q.filter((N)=>!this.config.packages.ignore.includes(N.name));let R=Date.now();if(this.config.packages?.strategy)q=this.filterUpdatesByStrategy(q,this.config.packages.strategy);this.logger.info(`\u23F1\uFE0F Strategy filtering took ${Date.now()-R}ms`);let x=Date.now();q=await this.filterUpdatesByMinimumReleaseAge(q),this.logger.info(`\u23F1\uFE0F Minimum release age filtering took ${Date.now()-x}ms`),q=this.applyPins(q),q=await this.dropOverriddenUpdates(q,Q),q=this.applyPackageRules(q);let m=Date.now();q=await this.annotateSecurityAdvisories(q),this.logger.info(`\u23F1\uFE0F Security advisory lookup took ${Date.now()-m}ms`);let f=this.config.security?.prioritize??!0,u=Date.now();q=k0(q,{prioritizeSecurity:f}),this.logger.info(`\u23F1\uFE0F Sorting took ${Date.now()-u}ms`);let I=Date.now(),C=this.config.packages?.groups?this.groupUpdatesByConfig(q):_0(q,{prioritizeSecurity:f});this.logger.info(`\u23F1\uFE0F Grouping took ${Date.now()-I}ms`);let X0=Date.now()-$,p={totalPackages:K,updates:q,groups:C,scannedAt:new Date,duration:X0};return this.logger.success(`Scan completed in ${X0}ms. Found ${q.length} updates.`),await this.events.emit("scan.completed",{total:q.length,major:q.filter((N)=>N.updateType==="major").length,minor:q.filter((N)=>N.updateType==="minor").length,patch:q.filter((N)=>N.updateType==="patch").length}),p}catch(X){throw this.logger.error("Failed to scan for updates:",X),X}}prTitleFor($){let X=this.config.pullRequest?.titleFormat;if(!X)return $.title;return z0(X,j0($,{title:$.title},this.config.packages?.strategy))}commitMessageFor($,X){let Q=this.config.pullRequest?.commitMessageFormat,K=Q?z0(Q,j0($,{message:$.title,title:$.title},this.config.packages?.strategy)):$.title;return X?`${K} ${X}`:K}applyPackageRules($){let X=this.config.packages?.rules??[],K=[...o(this.config.packages?.groups),...X];if(K.length===0)return $;let H=P0($,K);if(H.length<$.length)this.logger.info(`\uD83D\uDCCB Package rules dropped ${$.length-H.length} update(s)`);return H.map((Z)=>Z.update)}static mergeUnique($,X){let Q=[...new Set([...$??[],...X])];return Q.length>0?Q:void 0}labelsFor($,X){let Q=$.updates.some((K)=>(K.securityAdvisories?.length??0)>0);return[...new Set([...X.generateLabels($),...Q?[this.config.security?.label??"security"]:[],...this.config.pullRequest?.labels??[],...this.groupEffectsFor($.updates).labels])]}activeRules(){return[...o(this.config.packages?.groups),...this.config.packages?.rules??[]]}groupEffectsFor($){let X=this.activeRules();if(X.length===0)return O0([]);return O0($.map((Q)=>l(Q,X)))}orderGroupsByPriority($){if(this.activeRules().length===0)return $;return $.map((Q,K)=>({group:Q,index:K,priority:this.groupEffectsFor(Q.updates).prPriority})).sort((Q,K)=>K.priority-Q.priority||Q.index-K.index).map((Q)=>Q.group)}async dropOverriddenUpdates($,X){let Q=X.filter((W)=>W.type==="package.json");if(Q.length===0)return $;let{collectResolutionPins:K,pinBlocksUpdate:H}=await import("./chunk-pskqrv5r.js"),Z=new Map;for(let W of Q)try{for(let O of K(JSON.parse(W.content)))Z.set(O.name,{version:O.version,field:O.field})}catch{continue}if(Z.size===0)return $;return $.filter((W)=>{let O=Z.get(W.name);if(!O)return!0;if(!H({name:W.name,version:O.version,field:O.field},W.newVersion))return!0;return this.logger.info(`\uD83D\uDD12 Skipping ${W.name} \u2192 ${W.newVersion}: ${O.field} pins it to ${O.version}, which would win at install time`),!1})}applyPins($){let X=this.config.packages?.pin;if(!X||Object.keys(X).length===0)return $;let Q=[];for(let K of $){let H=X[K.name];if(!H){Q.push(K);continue}if(K.currentVersion===H){this.logger.info(`\uD83D\uDCCC ${K.name} is pinned to ${H}, skipping update to ${K.newVersion}`);continue}this.logger.info(`\uD83D\uDCCC ${K.name} is pinned to ${H}, retargeting update from ${K.newVersion}`),Q.push({...K,newVersion:H,updateType:c(K.currentVersion,H)})}return Q}async annotateSecurityAdvisories($){if(this.config.security?.enabled===!1||$.length===0)return $;try{let Q=await new t(this.logger).annotateUpdates($,this.config.security?.minimumSeverity??"low"),K=Q.filter((H)=>H.securityAdvisories?.length);if(K.length>0)await this.events.emit("security.advisories",{packages:K.map((H)=>({name:H.name,severity:H.securityAdvisories?.[0]?.severity??"unknown"}))});return Q}catch(X){return this.logger.warn("Security advisory lookup failed, continuing without it:",X),$}}async createPullRequests($){let X=Date.now();this.logger.info("Creating pull requests for updates...");try{if(!this.config.repository){this.logger.error("\u274C Repository configuration required for PR creation"),this.logger.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts");return}if(!this.config.repository.owner||!this.config.repository.name){this.logger.error("\u274C Repository owner and name are required for PR creation"),this.logger.info("Set them in buddy.config.ts or ensure GITHUB_REPOSITORY env var is available");return}let Q=y.env.GITHUB_TOKEN,K=y.env.BUDDY_TOKEN||y.env.BUDDY_BOT_TOKEN;if(!Q&&!K){this.logger.error("\u274C GITHUB_TOKEN or BUDDY_TOKEN environment variable required for PR creation");return}let H=Q||K,Z=!!K;if(K)this.logger.info("\u2705 BUDDY_TOKEN detected - workflow file permissions enabled");else this.logger.info("\u2139\uFE0F No BUDDY_TOKEN \u2014 workflow file updates will be skipped");let W=await e({provider:this.config.repository.provider,owner:this.config.repository.owner,name:this.config.repository.name,token:H,...K?{workflowToken:K}:{},...this.config.repository.apiUrl?{apiUrl:this.config.repository.apiUrl}:{}},{logger:this.logger}),O=new y0(this.config),z=this.config.maxPRsPerRun??10,L=0,_=this.orderGroupsByPriority($.groups),Y=[];for(let j of _)try{let E=Date.now();if(this.logger.info(`Creating PR for group: ${j.name} (${j.updates.length} updates)`),j.updates.length>0&&j.updates.every((V)=>V.file.includes(".github/workflows/"))&&!Z){this.logger.warn(`\u26A0\uFE0F Skipping group ${j.name} \u2014 workflow-file updates require BUDDY_TOKEN with the workflow scope`);continue}try{let{spawn:V}=await import("child_process"),w=(S,b)=>{return new Promise((U,v)=>{let h=V(S,b,{stdio:"pipe"});h.on("close",(i)=>i===0?U():v(Error(`Git command failed with code ${i}`))),h.on("error",v)})},G=this.config.repository.baseBranch||"main";await w("git",["checkout",G]),await w("git",["reset","--hard","HEAD"]),await w("git",["clean","-fd"])}catch(V){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state for early file-change check, continuing anyway:",V)}let T=await this.generateAllFileUpdates(j.updates);if(T.length===0){this.logger.info(`\u2139\uFE0F No file changes for group ${j.name}, skipping \u2014 leaving branches untouched`);continue}let A=this.prTitleFor(j),M=Date.now(),F=await O.generateBody(j),q=Date.now()-M;this.logger.info(`\u23F1\uFE0F PR body generation took ${q}ms`);let R=await this.analyzeMajors(j.updates,T.map((V)=>V.path)),x=m0(F,R.report),m=await W.getPullRequests("open"),f=this.generateBranchName(j),u=`buddy/update-${j.name.toLowerCase().replace(/\s+/g,"-")}-`,I=m.find((V)=>(V.head===f||V.title===A||V.head.startsWith(u)||this.isSimilarPRTitle(V.title,A))&&(V.author==="github-actions[bot]"||V.author.includes("buddy")||V.head.startsWith("buddy/"))&&!V.head.includes("renovate/")&&!V.head.includes("dependabot/")&&!V.author.toLowerCase().includes("renovate")&&!V.author.toLowerCase().includes("dependabot"));if(I){if(this.logger.info(`\uD83D\uDD04 Found existing PR #${I.number}: ${I.title}`),this.shouldAutoClosePR(I,j.updates)){this.logger.info(`\uD83D\uDD12 Auto-closing PR #${I.number} due to config change`);try{let G=this.generateCloseReason(I);try{await W.createComment(I.number,G)}catch(S){this.logger.warn(`\u26A0\uFE0F Could not add close reason comment to PR #${I.number}:`,S)}await W.closePullRequest(I.number),await this.events.emit("pr.closed",{number:I.number,title:I.title,reason:"no longer produced by the current configuration"});try{await W.deleteBranch(I.head),this.logger.success(`\u2705 Auto-closed PR #${I.number} and deleted branch ${I.head}`)}catch(S){this.logger.warn(`\u26A0\uFE0F Auto-closed PR #${I.number} but could not delete ${I.head}:`,S)}continue}catch(G){this.logger.error(`\u274C Failed to auto-close PR #${I.number}:`,G)}}if(this.checkIfUpdatesMatch(I.body,j.updates)){this.logger.info("\u2705 Existing PR has the same updates, skipping creation");continue}else{this.logger.info("\uD83D\uDD04 Updates differ, will update existing PR with new content");let G=I.head;try{let{spawn:U}=await import("child_process"),v=(h,i)=>{return new Promise((n0,q0)=>{let V0=U(h,i,{stdio:"pipe"});V0.on("close",(D0)=>{if(D0===0)n0();else q0(Error(`Git command failed with code ${D0}`))}),V0.on("error",q0)})};await v("git",["checkout","main"]),await v("git",["reset","--hard","HEAD"]),await v("git",["clean","-fd"]),this.logger.info(`\uD83E\uDDF9 Reset to clean main state before updating existing PR ${I.number}`)}catch(U){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state, continuing anyway:",U)}let S=await this.generateAllFileUpdates(j.updates);if(S.length===0)this.logger.warn(`\u2139\uFE0F No file changes generated for existing PR ${I.number}, updating metadata only`);else{this.logger.info(`\uD83D\uDCDD Regenerated ${S.length} file changes for existing PR ${I.number}`);try{let{hasBranchDifferences:U}=await import("./chunk-aa277p5r.js");if(!await U(S,G))this.logger.info(`\u2139\uFE0F No content differences for ${G}; recreating from ${this.config.repository.baseBranch||"main"} with same dependency changes to keep branch up-to-date`),await W.commitChanges(G,this.commitMessageFor(j,"(rebased)"),S,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated ${G} from ${this.config.repository.baseBranch||"main"} (dependency versions unchanged)`);else await W.commitChanges(G,this.commitMessageFor(j,"(updated)"),S,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated branch ${G} with latest dependency versions`)}catch(U){this.logger.warn("\u26A0\uFE0F Failed to compare branch content, proceeding with commit:",U),await W.commitChanges(G,this.commitMessageFor(j,"(updated)"),S,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated branch ${G} with latest dependency versions`)}}let b=this.labelsFor(j,O);await W.updatePullRequest(I.number,{title:A,body:x,labels:b,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:I.number,title:A,url:I.url}),this.logger.success(`\u2705 Updated existing PR #${I.number}: ${A}`),this.logger.info(`\uD83D\uDD17 ${I.url}`);continue}}if(L>=z){this.logger.warn(`\u26A0\uFE0F Rate limit reached: already created ${L} PRs this run (max: ${z}). Skipping remaining groups.`);break}let C=this.generateBranchName(j);if(await W.branchExists(C)){this.logger.info(`\uD83D\uDD04 Branch ${C} already exists, checking for associated PR...`);let V=m.find((G)=>G.head===C);if(V){this.logger.info(`\u2705 Found existing PR #${V.number} for branch ${C}, updating it...`);let G=await this.generateAllFileUpdates(j.updates);if(G.length>0)await W.commitChanges(C,this.commitMessageFor(j,"(updated)"),G,this.config.repository.baseBranch||"main");let S=this.labelsFor(j,O);await W.updatePullRequest(V.number,{title:A,body:x,labels:S,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:V.number,title:A,url:V.url}),this.logger.success(`\u2705 Updated existing PR #${V.number}: ${A}`),this.logger.info(`\uD83D\uDD17 ${V.url}`);continue}let w=!1;try{let S=(d(W,"reopenPullRequests","reopenPullRequest")?await W.getPullRequests("closed"):[]).find((b)=>{if(b.head!==C)return!1;if(b.mergedAt)return!1;return Date.now()-(b.updatedAt?.getTime()??0)<86400000});if(S){this.logger.info(`\uD83D\uDD04 Found recently-closed PR #${S.number} for branch ${C}, reopening...`);let b=await this.generateAllFileUpdates(j.updates);if(b.length>0)await W.commitChanges(C,this.commitMessageFor(j,"(reopened)"),b,this.config.repository.baseBranch||"main");await W.reopenPullRequest(S.number);let U=this.labelsFor(j,O);await W.updatePullRequest(S.number,{title:A,body:x,labels:U,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:S.number,title:A,url:S.url}),this.logger.success(`\u2705 Reopened and updated PR #${S.number}: ${A}`),this.logger.info(`\uD83D\uDD17 ${S.url}`),w=!0}}catch(G){this.logger.warn("\u26A0\uFE0F Failed to check/reopen closed PRs:",G)}if(w)continue;this.logger.info(`\uD83E\uDDF9 Branch ${C} exists but has no open PR, cleaning up...`);try{await W.deleteBranch(C)}catch(G){this.logger.warn(`\u26A0\uFE0F Failed to delete orphaned branch ${C}:`,G)}}let p=!1;try{let w=(d(W,"reopenPullRequests","reopenPullRequest")?await W.getPullRequests("closed"):[]).find((G)=>{if(G.head!==C&&!this.isSimilarPRTitle(G.title,A))return!1;if(!G.head.startsWith("buddy/")&&G.author!=="github-actions[bot]")return!1;if(G.mergedAt)return!1;return Date.now()-(G.updatedAt?.getTime()??0)<604800000});if(w){this.logger.info(`\uD83D\uDD04 Found recently-closed PR #${w.number} (branch may have been deleted), recreating branch and reopening...`),await W.createBranch(C,this.config.repository.baseBranch||"main");let G=await this.generateAllFileUpdates(j.updates);if(G.length>0)await W.commitChanges(C,this.commitMessageFor(j,"(reopened)"),G,this.config.repository.baseBranch||"main");await W.reopenPullRequest(w.number);let S=this.labelsFor(j,O);await W.updatePullRequest(w.number,{title:A,body:x,labels:S,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:w.number,title:A,url:w.url}),this.logger.success(`\u2705 Reopened and updated PR #${w.number}: ${A}`),this.logger.info(`\uD83D\uDD17 ${w.url}`),p=!0}}catch(V){this.logger.warn("\u26A0\uFE0F Failed to check/reopen closed PRs:",V)}if(p)continue;await W.createBranch(C,this.config.repository.baseBranch||"main");try{let{spawn:V}=await import("child_process"),w=(G,S)=>{return new Promise((b,U)=>{let v=V(G,S,{stdio:"pipe"});v.on("close",(h)=>{if(h===0)b();else U(Error(`Git command failed with code ${h}`))}),v.on("error",U)})};await w("git",["checkout","main"]),await w("git",["reset","--hard","HEAD"]),await w("git",["clean","-fd"]),this.logger.info(`\uD83E\uDDF9 Reset to clean main state before generating updates for ${j.name}`)}catch(V){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state, continuing anyway:",V)}let N=await this.generateAllFileUpdates(j.updates);if(N.length===0){this.logger.warn(`\u2139\uFE0F No file changes generated for group ${j.name}, skipping PR creation`);continue}let k=!1;for(let V of N)try{let w=await import("fs");if(w.existsSync(V.path)){if(w.readFileSync(V.path,"utf-8")!==V.content){k=!0;break}}else{k=!0;break}}catch{k=!0;break}if(!k){this.logger.warn(`\u2139\uFE0F No actual content changes for group ${j.name}, skipping PR creation`);continue}this.logger.info(`\uD83D\uDCDD Generated ${N.length} file changes for ${j.name}`),await W.commitChanges(C,this.commitMessageFor(j),N,this.config.repository.baseBranch||"main");let J0=this.groupEffectsFor(j.updates),L0=this.labelsFor(j,O),P=await W.createPullRequest({title:A,body:x,head:C,base:this.config.repository.baseBranch||"main",draft:R.draft,reviewers:$0.mergeUnique(this.config.pullRequest?.reviewers,J0.reviewers),teamReviewers:this.config.pullRequest?.teamReviewers,assignees:$0.mergeUnique(this.config.pullRequest?.assignees,J0.assignees),labels:L0});L++,this.logger.success(`\u2705 Created PR #${P.number}: ${P.title} (${L}/${z} this run)`),this.logger.info(`\uD83D\uDD17 ${P.url}`),await this.events.emit("pr.created",{number:P.number,title:P.title,url:P.url,packages:j.updates.map((V)=>V.name)}),await this.queueAutoMerge(W,P,j.updates,L0);let o0=Date.now()-E;this.logger.info(`\u23F1\uFE0F Total group processing took ${o0}ms`)}catch(E){this.logger.error(`\u274C Failed to create PR for group ${j.name}:`,E),Y.push({name:j.name,error:E})}let J=Date.now()-X;if(Y.length>0){let j=Y.map((E)=>`${E.name}: ${Z0(E.error)}`).join(`
88
- `);throw Error(`Could not create pull requests for ${Y.length} of ${_.length} group(s):
89
- ${j}`)}this.logger.success(`\u2705 Completed PR creation for ${$.groups.length} group(s) in ${J}ms`)}catch(Q){throw this.logger.error("Failed to create pull requests:",Q),Q}}shouldRespectVersion($){if(!(this.config.packages?.respectLatest??!0))return!1;let Q=["latest","*","main","master","develop","dev"],K=$.toLowerCase().trim();return Q.includes(K)}async checkDependencyFilesForUpdates($){let{isDependencyFile:X}=await import("./chunk-19zyq15p.js"),{resolveDependencyFile:Q}=await import("./chunk-05me15qw.js"),K=[],H=$.filter((O)=>X(O.path));this.logger.info(`\u26A1 Checking ${H.length} dependency files in parallel...`);let Z=H.map(async(O)=>{try{this.logger.info(`Checking dependency file: ${O.path}`);let z=await Q(O.path),L=[];for(let _ of z.allDependencies||[]){if(this.shouldRespectVersion(_.constraint)){this.logger.debug(`Skipping ${_.name} - version "${_.constraint}" should be respected`);continue}if(_.constraint!==_.version&&_.version){let Y=_.constraint.replace(/^[\^~>=<]+/,"");if(!this.isNewerVersion(Y,_.version)){this.logger.debug(`Skipping ${_.name} - latest (${_.version}) is not newer than constraint (${Y})`);continue}let J=c(Y,_.version),j=_.version;L.push({name:_.name,currentVersion:_.constraint,newVersion:j,updateType:J,dependencyType:"dependencies",file:O.path,metadata:void 0,releaseNotesUrl:void 0,changelogUrl:void 0,homepage:void 0})}}return L}catch(z){return this.logger.error(`Failed to check dependency file ${O.path}:`,z),[]}}),W=await Promise.all(Z);return K.push(...W.flat()),K}async checkZigForUpdates($){let{isZigManifest:X}=await import("./chunk-zxgkp71x.js"),{fetchLatestZigVersion:Q,fetchZigHash:K,isZigAvailable:H,parseZigSource:Z,zigUrlForVersion:W}=await import("./chunk-1qgr52wx.js"),O=$.filter((Y)=>X(Y.path));if(O.length===0)return[];if(!await H())return this.logger.warn("\u26A0\uFE0F Found Zig manifests but the zig toolchain is not available. "+"Skipping Zig updates: their content-addressed hashes cannot be recomputed without `zig fetch`."),[];let z=y.env.GITHUB_TOKEN||y.env.BUDDY_TOKEN||y.env.BUDDY_BOT_TOKEN,L=O.flatMap((Y)=>Y.dependencies.filter((J)=>J.type==="zig-dependencies").map((J)=>({file:Y,dep:J})));return this.logger.info(`\u26A1 Checking ${L.length} Zig dependencies...`),(await Promise.all(L.map(async({file:Y,dep:J})=>{let j=J.metadata?.url;if(!j)return this.logger.debug(`Skipping ${J.name}: no URL recorded`),null;let E=Z(j);if(!E)return this.logger.debug(`Skipping ${J.name}: only GitHub-hosted Zig dependencies can be checked`),null;let B=await Q(E,z);if(!B||B===J.currentVersion)return null;let T=W(j,B),A=await K(T);if(!A)return this.logger.warn(`\u26A0\uFE0F Skipping ${J.name} ${J.currentVersion} \u2192 ${B}: could not compute its package hash`),null;return this.logger.info(`\uD83D\uDCE6 ${J.name}: ${J.currentVersion} \u2192 ${B}`),{name:J.name,currentVersion:J.currentVersion,newVersion:B,updateType:c(J.currentVersion,B),dependencyType:"zig-dependencies",file:Y.path,resolved:{url:T,hash:A}}}))).filter((Y)=>Y!==null)}async checkGitHubActionsForUpdates($){let{isGitHubActionsFile:X}=await import("./chunk-sc7emb71.js"),{fetchLatestActionVersion:Q}=await import("./chunk-sc7emb71.js"),K=[],H=$.filter((_)=>X(_.path));this.logger.info(`\uD83D\uDD0D Found ${H.length} GitHub Actions workflow files`);let Z=[];for(let _ of H){let Y=_.dependencies.filter((J)=>J.type==="github-actions");this.logger.info(`Found ${Y.length} GitHub Actions in ${_.path}`),Y.forEach((J)=>Z.push({file:_,dep:J}))}this.logger.info(`\u26A1 Checking ${Z.length} GitHub Actions in parallel...`);let W=Z.map(async({file:_,dep:Y})=>{try{this.logger.info(`Checking action: ${Y.name}@${Y.currentVersion}`);let J=await Q(Y.name);if(J)if(this.logger.info(`Latest version for ${Y.name}: ${J}`),J!==Y.currentVersion){let j=c(Y.currentVersion,J);return this.logger.info(`Update available: ${Y.name} ${Y.currentVersion} \u2192 ${J} (${j})`),{name:Y.name,currentVersion:Y.currentVersion,newVersion:J,updateType:j,dependencyType:"github-actions",file:_.path,metadata:void 0,releaseNotesUrl:`${H0(this.config)}/${Y.name}/releases`,changelogUrl:void 0,homepage:`${H0(this.config)}/${Y.name}`}}else this.logger.info(`No update needed for ${Y.name}: already at ${J}`);else this.logger.warn(`Could not fetch latest version for ${Y.name}`);return null}catch(J){return this.logger.warn(`Failed to check version for action ${Y.name}:`,J),null}}),z=(await Promise.all(W)).filter((_)=>_!==null);K.push(...z),this.logger.info(`Generated ${K.length} GitHub Actions updates`);let L=K.reduce((_,Y)=>{if(!_.find((j)=>j.name===Y.name&&j.currentVersion===Y.currentVersion&&j.newVersion===Y.newVersion&&j.file===Y.file))_.push(Y);return _},[]);return this.logger.info(`After deduplication: ${L.length} unique GitHub Actions updates`),L}async checkEnginesForUpdates($){let{bumpEngineConstraint:X,engineUpdateType:Q,resolveEngineVersion:K}=await import("./chunk-pskqrv5r.js"),{fetchLatestActionVersion:H}=await import("./chunk-sc7emb71.js"),Z=$.flatMap((z)=>z.dependencies.filter((L)=>L.type==="engines").map((L)=>({file:z,dep:L})));if(Z.length===0)return[];this.logger.info(`\u26A1 Checking ${Z.length} engine constraint(s)...`);let W={npm:(z)=>this.registryClient.getLatestVersion(z),github:(z)=>H(z)},O=Z.map(async({file:z,dep:L})=>{try{let _=await K(L.name,W);if(!_)return null;let Y=X(L.currentVersion,_);if(!Y)return this.logger.debug(`${L.name} ${L.currentVersion} already admits ${_}`),null;return this.logger.info(`Update available: ${L.name} ${L.currentVersion} \u2192 ${Y}`),{name:L.name,currentVersion:L.currentVersion,newVersion:Y,updateType:Q(L.currentVersion,Y),dependencyType:"engines",file:z.path}}catch(_){return this.logger.warn(`Could not check engine ${L.name}:`,_),null}});return(await Promise.all(O)).filter((z)=>z!==null)}async checkDockerfilesForUpdates($){let{isDockerfile:X}=await import("./chunk-ys1qqcpp.js"),{fetchLatestDockerImageVersion:Q}=await import("./chunk-ys1qqcpp.js"),K=[],H=$.filter((_)=>X(_.path));this.logger.info(`\uD83D\uDD0D Found ${H.length} Dockerfile(s)`);let Z=[];for(let _ of H){let Y=_.dependencies.filter((J)=>J.type==="docker-image");this.logger.info(`Found ${Y.length} Docker images in ${_.path}`),Y.forEach((J)=>Z.push({file:_,dep:J}))}this.logger.info(`\u26A1 Checking ${Z.length} Docker images in parallel...`);let W=Z.map(async({file:_,dep:Y})=>{try{if(this.logger.info(`Checking Docker image: ${Y.name}:${Y.currentVersion}`),this.shouldRespectVersion(Y.currentVersion))return this.logger.debug(`Skipping ${Y.name} - version "${Y.currentVersion}" should be respected`),null;let J=await Q(Y.name,Y.currentVersion,{...this.config.registries?.docker?{registries:this.config.registries.docker}:{},...this.config.packages?.includePrerelease!==void 0?{includePrerelease:this.config.packages.includePrerelease}:{}});if(J)if(this.logger.info(`Latest version for ${Y.name}: ${J}`),J!==Y.currentVersion){let j=c(Y.currentVersion,J);return this.logger.info(`Update available: ${Y.name} ${Y.currentVersion} \u2192 ${J} (${j})`),{name:Y.name,currentVersion:Y.currentVersion,newVersion:J,updateType:j,dependencyType:"docker-image",file:_.path,metadata:void 0,releaseNotesUrl:`https://hub.docker.com/r/${Y.name}/tags`,changelogUrl:void 0,homepage:`https://hub.docker.com/r/${Y.name}`}}else this.logger.info(`No update needed for ${Y.name}: already at ${J}`);else this.logger.warn(`Could not fetch latest version for Docker image ${Y.name}`);return null}catch(J){return this.logger.warn(`Failed to check version for Docker image ${Y.name}:`,J),null}}),z=(await Promise.all(W)).filter((_)=>_!==null);K.push(...z),this.logger.info(`Generated ${K.length} Docker image updates`);let L=K.reduce((_,Y)=>{if(!_.find((j)=>j.name===Y.name&&j.currentVersion===Y.currentVersion&&j.newVersion===Y.newVersion&&j.file===Y.file))_.push(Y);return _},[]);return this.logger.info(`After deduplication: ${L.length} unique Docker image updates`),L}isNewerVersion($,X){try{return Bun.semver.order(X.replace(/^[v^~>=<@]+/,""),$.replace(/^[v^~>=<@]+/,""))>0}catch{return!1}}readDeclaredNpmVersions(){let $=new Map;try{let X=D("fs"),K=D("path").join(this.projectPath,"package.json");if(!X.existsSync(K))return $;let H=JSON.parse(X.readFileSync(K,"utf8"));for(let Z of["dependencies","devDependencies","peerDependencies","optionalDependencies"])for(let[W,O]of Object.entries(H[Z]??{}))if(typeof O==="string"&&!$.has(W))$.set(W,O)}catch(X){this.logger.debug("Could not read declared versions from package.json:",X)}return $}compareVersionsSafe($,X){try{let Q=X.replace(/^[v^~>=<@]+/,""),K=$.replace(/^[v^~>=<@]+/,"");if(!/^\d+\.\d+/.test(Q)||!/^\d+\.\d+/.test(K))return"failed";return Bun.semver.order(Q,K)>0?"behind":"at-or-beyond"}catch{return"failed"}}async generateAllFileUpdates($){let X=[],Q=$.filter((Y)=>Y.file.endsWith("package.json")&&Y.dependencyType!=="engines"&&!Y.file.includes(".yaml")&&!Y.file.includes(".yml")&&!Y.file.includes(".github/workflows/")),K=$.filter((Y)=>Y.dependencyType==="engines");if(K.length>0){let{applyEngineUpdates:Y}=await import("./chunk-pskqrv5r.js"),J=new Map;for(let j of K)J.set(j.file,[...J.get(j.file)??[],j]);for(let[j,E]of J)try{let B=N0.readFileSync(j,"utf-8"),T=Y(B,E);if(T===B){this.logger.warn(`\u26A0\uFE0F No engine changes written to ${j}`);continue}X.push({path:j,content:T,type:"update"})}catch(B){this.logger.warn(`Failed to update engines in ${j}:`,B)}}let H=new Map;for(let Y of Q){if(!H.has(Y.file))H.set(Y.file,[]);H.get(Y.file).push(Y)}for(let[Y,J]of H)try{let j=N0.readFileSync(Y,"utf-8"),E=JSON.parse(j);for(let B of J){let T=!1,A=B.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),M=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(let F of M)if(E[F]&&E[F][A]){let R=E[F][A].match(/^(\D*)/),x=R?R[1]:"",m=A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=new RegExp(`("${f}"\\s*:\\s*\\{[^}]*?)("${m}"\\s*:\\s*")([^"]+)(")([^}]*?\\})`,"gs"),I=`${x}${B.newVersion}`;j=j.replace(u,`$1$2${I}$4$5`),T=!0;break}if(!T)this.logger.warn(`Package ${A} not found in ${Y}`)}X.push({path:Y,content:j,type:"update"})}catch(j){this.logger.warn(`Failed to update ${Y}:`,j)}let Z=$.filter((Y)=>{let J=Y.file.toLowerCase();return(J.endsWith("deps.yaml")||J.endsWith("deps.yml")||J.endsWith("dependencies.yaml")||J.endsWith("dependencies.yml"))&&!Y.file.includes(".github/workflows/")});if(Z.length>0)try{let{generateDependencyFileUpdates:Y}=await import("./chunk-19zyq15p.js"),J=await Y(Z);X.push(...J)}catch(Y){this.logger.error("Failed to generate dependency file updates:",Y)}let W=$.filter((Y)=>Y.file.endsWith("composer.json")||Y.file.endsWith("composer.lock"));if(W.length>0)try{let{generateComposerUpdates:Y}=await import("./chunk-vqa6vte3.js"),J=await Y(W);X.push(...J)}catch(Y){this.logger.error("Failed to generate Composer updates:",Y)}let O=$.filter((Y)=>Y.file.includes(".github/workflows/"));if(O.length>0)try{let{generateGitHubActionsUpdates:Y}=await import("./chunk-sc7emb71.js"),J=await Y(O);X.push(...J)}catch(Y){this.logger.error("Failed to generate GitHub Actions updates:",Y)}let z=$.filter((Y)=>Y.dependencyType==="docker-image");if(z.length>0)try{let{generateDockerfileUpdates:Y}=await import("./chunk-ys1qqcpp.js"),J=await Y(z,this.config.registries?.docker);X.push(...J)}catch(Y){this.logger.error("Failed to generate Dockerfile updates:",Y)}let L=$.filter((Y)=>Y.dependencyType==="zig-dependencies");if(L.length>0)try{let{generateZigManifestUpdates:Y}=await import("./chunk-zxgkp71x.js"),J=await Y(L);X.push(...J)}catch(Y){this.logger.error("Failed to generate Zig manifest updates:",Y)}let _=$.filter((Y)=>Y.dependencyType==="catalog");if(_.length>0)try{let{applyCatalogUpdates:Y}=await import("./chunk-0paakbpj.js"),J=_[0].file,j=await Bun.file(a(this.projectPath,J)).text(),E=Y(j,_);if(E===j)this.logger.warn(`\u26A0\uFE0F No catalog changes written to ${J}`);else X.push({path:J,content:E,type:"update"})}catch(Y){this.logger.error("Failed to generate pnpm catalog updates:",Y)}return X.push(...await this.generateAdapterFileUpdates($)),X}async generateAdapterFileUpdates($){let{adapterNamed:X}=await import("./chunk-wn6pbyzn.js"),Q=new Map;for(let Z of $){if(!X(Z.dependencyType))continue;let W=Q.get(Z.file);if(W)W.push(Z);else Q.set(Z.file,[Z])}let K=[],H=new Set;for(let[Z,W]of Q){let O=X(W[0].dependencyType);if(!O)continue;H.add(O.name);try{let z=a(this.projectPath,Z),L=await Bun.file(z).text(),_=L;for(let Y of W)_=O.applyUpdate(_,{name:Y.name,currentVersion:Y.currentVersion,newVersion:Y.newVersion,section:Y.dependencyType});if(_===L){this.logger.warn(`\u26A0\uFE0F ${O.name}: no changes written to ${Z}`);continue}K.push({path:Z,content:_,type:"update"})}catch(z){this.logger.error(`Failed to write ${O.name} updates to ${Z}:`,z)}}return[...K,...await this.regenerateAdapterLockfiles(K,[...H])]}async regenerateAdapterLockfiles($,X){if($.length===0||X.length===0)return[];let{regenerateLockfiles:Q}=await import("./chunk-wn6pbyzn.js");try{for(let W of $)await Bun.write(a(this.projectPath,W.path),W.content)}catch(W){return this.logger.warn(`\u26A0\uFE0F Could not stage manifests for lockfile regeneration: ${W}`),[]}let{regenerated:K,notes:H}=await Q(this.projectPath,X);for(let W of H)this.logger.info(`\u2139\uFE0F ${W}`);let Z=[];for(let W of K)try{Z.push({path:W,content:await Bun.file(a(this.projectPath,W)).text(),type:"update"}),this.logger.info(`\uD83D\uDD12 Regenerated ${W}`)}catch(O){this.logger.warn(`\u26A0\uFE0F Could not read the regenerated ${W}: ${O}`)}return Z}async run(){let $=await this.scanForUpdates();if($.updates.length===0)return this.logger.info("No updates available!"),$;if(this.config.pullRequest)await this.createPullRequests($);return $}async checkPackages($){return this.logger.info(`Checking specific packages: ${$.join(", ")}`),this.applyStrategy(await this.registryClient.getUpdatesForPackages($))}async checkPackagesWithPattern($){return this.logger.info(`Checking packages with pattern: ${$}`),this.applyStrategy(await this.registryClient.getUpdatesWithPattern($))}applyStrategy($){let X=this.config.packages?.strategy;return X?this.filterUpdatesByStrategy($,X):$}filterUpdatesByStrategy($,X){if(X==="all")return $;return $.filter((Q)=>h0(X,Q.updateType))}async filterUpdatesByMinimumReleaseAge($){let X=this.config.packages?.minimumReleaseAge??0,Q=this.activeRules(),K=Q.some((z)=>z.minimumReleaseAge!==void 0);if(X===0&&!K)return $;this.logger.info(`Applying minimum release age filter (global ${X} minutes${K?", with per-rule overrides":""}) in parallel...`);let H=$.map(async(z)=>{try{let L=(Q.length>0?l(z,Q).minimumReleaseAge:void 0)??X;if(L===0)return z;if(await this.registryClient.meetsMinimumReleaseAge(z.name,z.newVersion,z.dependencyType,L))return z;else return this.logger.debug(`Filtered out ${z.name}@${z.newVersion} (${z.dependencyType}) \u2014 held for ${L} minutes after publication`),null}catch(L){return this.logger.warn(`Error checking release age for ${z.name}@${z.newVersion} (${z.dependencyType}), including update:`,L),z}}),W=(await Promise.all(H)).filter((z)=>z!==null),O=$.length-W.length;if(O>0)this.logger.info(`Filtered out ${O} updates due to minimum release age requirement`);return W}groupUpdatesByConfig($){let X=[],{grouped:Q,remaining:K}=this.groupByRuleNames($);X.push(...Q);let H=[...K];if(this.config.packages?.groups)for(let Z of this.config.packages.groups){let W=[],{Glob:O}=globalThis.Bun,z=new Set;for(let _ of Z.patterns){let Y;try{Y=new O(_)}catch(J){this.logger.warn(`Invalid group pattern '${_}':`,J);continue}H.forEach((J,j)=>{if(!z.has(j)&&Y.match(J.name))W.push(J),z.add(j)})}if(z.size>0){for(let _=H.length-1;_>=0;_--)if(z.has(_))H.splice(_,1)}let L=W;if(Z.strategy)L=this.filterUpdatesByStrategy(W,Z.strategy);if(L.length>0)X.push({name:Z.name,updates:L,updateType:this.getHighestUpdateType(L),title:`chore(deps): update ${Z.name}`,body:`Update ${L.length} packages in ${Z.name} group`})}if(H.length>0){let Z=_0(H);X.push(...Z)}return X}groupByRuleNames($){let X=this.config.packages?.rules??[];if(X.length===0)return{grouped:[],remaining:$};let Q=new Map,K=[];for(let Z of $){let W=l(Z,X).groupName;if(!W){K.push(Z);continue}let O=Q.get(W);if(O)O.push(Z);else Q.set(W,[Z])}return{grouped:[...Q.entries()].map(([Z,W])=>({name:Z,updates:W,updateType:this.getHighestUpdateType(W),title:`chore(deps): update ${Z}`,body:`Update ${W.length} packages in ${Z} group`})),remaining:K}}getHighestUpdateType($){if($.some((X)=>X.updateType==="major"))return"major";if($.some((X)=>X.updateType==="minor"))return"minor";return"patch"}generateBranchName($){return`buddy/update-${$.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}`}isSimilarPRTitle($,X){if($.toLowerCase()===X.toLowerCase())return!0;let Q=$.toLowerCase(),K=X.toLowerCase(),H=Q.includes("github actions"),Z=K.includes("github actions");if(H&&Z)return!0;if(H!==Z)return!1;let W=Q.includes("docker image"),O=K.includes("docker image");if(W&&O)return!0;if(W!==O)return!1;let z=[/update all non-major/i,/update \d+ dependenc(y|ies)/i,/update.*\(minor\)/i,/update.*\(patch\)/i,/update.*\(major\)/i],L=z.some((Y)=>Y.test($)),_=z.some((Y)=>Y.test(X));if(L&&_){let Y=Q.includes("(major)")||Q.includes("major update"),J=K.includes("(major)")||K.includes("major update");return Y===J}if(K.includes("update dependency ")){let Y=X.match(/update dependency (\S+)/i),J=$.match(/update dependency (\S+)/i);if(Y&&J)return Y[1]===J[1]}if(L!==_)return!1;if(Q.includes("dependency ")&&K.includes("dependency "))return!1;return!1}checkIfUpdatesMatch($,X){if(!$)return!1;let Q=this.extractPackageUpdatesFromPRBody($),K=new Map;for(let H of Q)K.set(H.name,{from:H.currentVersion,to:H.newVersion});for(let H of X){let Z=K.get(H.name);if(!Z)return!1;let W=Z.to.replace(/^[v^~>=<]+/,""),O=H.newVersion.replace(/^[v^~>=<]+/,"");if(W!==O)return!1}return K.size===X.length}shouldAutoClosePR($,X){if(this.shouldAutoCloseForRespectLatest($))return!0;if(this.shouldAutoCloseForIgnorePaths($))return!0;if(this.shouldAutoCloseForRemovedFiles($))return!0;return!1}shouldAutoCloseForRespectLatest($){if(!(this.config.packages?.respectLatest??!0))return!1;let Q=["latest","*","main","master","develop","dev"],K=this.extractPackageUpdatesFromPRBody($.body);if(K.length===0)return!1;return K.filter((Z)=>{let W=Z.currentVersion.toLowerCase().trim();return Q.includes(W)}).length>0}shouldAutoCloseForIgnorePaths($){let X=this.config.packages?.ignorePaths;if(!X||X.length===0)return!1;let Q=this.extractFilePathsFromPRBody($.body);if(Q.length===0)return!1;let{Glob:K}=globalThis.Bun,H=Q.filter((Z)=>{let W=Z.replace(/^\.\//,"");return X.some((O)=>{try{return new K(O).match(W)}catch(z){return this.logger.debug(`Failed to match path ${W} against pattern ${O}: ${z}`),!1}})});if(H.length>0)return this.logger.debug(`PR #${$.number} contains files now in ignorePaths: ${H.join(", ")}`),!0;return!1}shouldAutoCloseForRemovedFiles($){try{let X=this.extractFilePathsFromPRBody($.body);if(X.length===0)return!1;let Q=D("fs"),K=D("path"),H=X.filter((Z)=>{let W=K.join(this.projectPath,Z);return!Q.existsSync(W)});if(H.length>0){if(this.logger.info(`PR #${$.number} references removed files: ${H.join(", ")}`),this.config.packages?.ignorePaths&&this.config.packages.ignorePaths.length>0){let{Glob:_}=globalThis.Bun;if(H.filter((J)=>{return!this.config.packages.ignorePaths.some((j)=>{try{return new _(j).match(J)}catch(E){return this.logger.warn(`Invalid glob pattern '${j}':`,E),!1}})}).length>0)return this.logger.info(`Some removed files are outside ignored paths - not auto-closing PR #${$.number}`),!1}if(H.some((_)=>_.endsWith("composer.json")))return this.logger.info(`composer.json was removed - PR #${$.number} should be auto-closed`),!0;let W=$.body.toLowerCase(),O=W.includes("composer")||H.some((_)=>_.includes("composer")),z=W.includes("package.json")||H.some((_)=>_.includes("package.json")),L=H.some((_)=>_.endsWith("deps.yaml")||_.endsWith("deps.yml")||_.endsWith("dependencies.yaml")||_.endsWith("dependencies.yml"));if(O||z||L)return this.logger.info(`PR #${$.number} is about removed dependency system - should be auto-closed`),!0}return!1}catch(X){return this.logger.debug(`Failed to check for removed files in PR #${$.number}: ${X}`),!1}}get events(){if(!this.eventBus){this.eventBus=new f0(this.logger);for(let $ of g0(this.config.notifications))this.eventBus.register($)}return this.eventBus}async createGitProvider(){let $=this.config.repository;if(!$?.owner||!$.name)return this.logger.warn("\u26A0\uFE0F Repository owner and name are required for pull request operations"),null;try{return await e({provider:$.provider,owner:$.owner,name:$.name,...$.apiUrl?{apiUrl:$.apiUrl}:{}},{logger:this.logger})}catch(X){return this.logger.warn(`\u26A0\uFE0F ${Z0(X)}`),null}}async queueAutoMerge($,X,Q,K){let H=M0(Q,K,this.config);if(!H.eligible){this.logger.debug(`\uD83D\uDD00 PR #${X.number} not auto-merged: ${H.reason}`);return}let{strategy:Z}=n(this.config);if(!d($,"nativeAutoMerge","enableAutoMerge")){this.logger.info(`\uD83D\uDD00 PR #${X.number} qualifies for auto-merge but this provider has no merge queue; update-check will merge it once checks pass`);return}try{if(await $.enableAutoMerge(X.number,Z))this.logger.success(`\uD83D\uDD00 PR #${X.number} queued for auto-merge (${H.reason})`);else this.logger.info(`\uD83D\uDD00 PR #${X.number} qualifies for auto-merge but the repository cannot queue it; update-check will merge it once checks pass`)}catch(W){this.logger.warn(`\u26A0\uFE0F Failed to queue auto-merge for PR #${X.number}: ${W}`)}}async mergeEligiblePullRequests($=!1){let X=n(this.config);if(!X.enabled)return[];let Q=await this.createGitProvider();if(!Q)return[];let K=[],H=await Q.getPullRequests("open");for(let Z of H.filter((W)=>W.head.startsWith("buddy/"))){let W=X.requireGreenCI&&Q.getPullRequestChecksState?await Q.getPullRequestChecksState(Z.number):"none",O=W==="success"||W==="none",z=E0({number:Z.number,title:Z.title,body:Z.body,head:Z.head,labels:Z.labels,draft:Z.draft},this.config,O);if(!z.eligible){this.logger.debug(`\uD83D\uDD00 PR #${Z.number} not merged: ${z.reason}`);continue}if($){this.logger.info(`\uD83D\uDD00 [DRY RUN] Would merge PR #${Z.number} (${z.reason})`),K.push(Z.number);continue}try{await Q.mergePullRequest(Z.number,X.strategy),this.logger.success(`\uD83D\uDD00 Merged PR #${Z.number}: ${z.reason}`),await this.events.emit("pr.merged",{number:Z.number,title:Z.title,strategy:X.strategy}),K.push(Z.number)}catch(L){this.logger.warn(`\u26A0\uFE0F Failed to merge PR #${Z.number}: ${L}`)}}return K}isPlausibleRepoPath($){if(!$||/[\s()[\]!`]|:\/\//.test($))return!1;return/^[\w@.-]+(?:\/[\w@.-]+)*$/.test($)}extractFilePathsFromPRBody($){let X=g($);if(X)return v0(X);let Q=[],K=/\|\s*\[[^\]]+\]\([^)]*\)\s*\|[^|]*\|\s*\*\*([^*]+)\*\*\s*\|/g,H;while((H=K.exec($))!==null){let z=H[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}let Z=/\*\*([^*]+\.(?:json|yaml|yml|lock))\*\*/g;while((H=Z.exec($))!==null){let z=H[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}let W=/\|[^|]+\|[^|]+\|([^|]+)\|[^|]*\|/g;while((H=W.exec($))!==null){let z=H[1].trim();if(this.isPlausibleRepoPath(z)&&(z.includes("/")||/\.(?:json|yaml|yml|lock)$/.test(z))&&!Q.includes(z))Q.push(z)}let O=/(?:^|\s)([\w-]+(?:\/[\w.-]+)*\/[\w.-]+\.(?:json|yaml|yml|lock))(?:\s|$)/gm;while((H=O.exec($))!==null){let z=H[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}return Q}extractPackagesFromPRBody($){let X=g($);if(X)return[...new Set(X.updates.map((Z)=>Z.name))];let Q=[],K=$.match(/\|[^|]*\|[^|]*\|[^|]*\|[^|]*\|/g);if(K)for(let Z of K){let W=Z.match(/\[([^\]]+)\]\([^)]*\)/);if(W)Q.push(W[1])}let H=$.match(/<summary>([^<]+)<\/summary>/g);if(H)for(let Z of H){let W=Z.replace(/<summary>/,"").replace(/<\/summary>/,"").trim();if(W&&!Q.includes(W))Q.push(W)}return Q}extractPackageUpdatesFromPRBody($){let X=g($);if(X)return b0(X);let Q=[],K=new Set,H=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`?[v^~>=]*([^`|\s]+)`?\s*(?:->|\u2192)\s*`?[v^~>=]*([^`|\s]+)`?\]?/g,Z;while((Z=H.exec($))!==null){let[,W,O,z]=Z;if(!K.has(W))K.add(W),Q.push({name:W,currentVersion:O,newVersion:z})}return Q}getConfig(){return this.config}getProjectPath(){return this.projectPath}async checkAndCloseObsoletePRs($,X=!1){try{this.logger.info("\uD83D\uDD0D Scanning for obsolete PRs due to removed dependency files...");let K=(await $.getPullRequests("open")).filter((Z)=>Z.head.startsWith("buddy/")||Z.author==="github-actions[bot]"&&Z.labels.includes("dependencies"));this.logger.info(`Found ${K.length} dependency-related PRs to check`);let H=0;for(let Z of K)try{if(this.shouldAutoCloseForRemovedFiles(Z))if(this.logger.info(`\uD83D\uDD12 PR #${Z.number} should be auto-closed: ${Z.title}`),X)this.logger.info(`\uD83D\uDD0D [DRY RUN] Would auto-close PR #${Z.number}`),H++;else try{let O=this.generateCloseReason(Z);try{await $.createComment(Z.number,O)}catch(z){this.logger.warn(`\u26A0\uFE0F Could not add close reason comment to PR #${Z.number}:`,z)}if(await $.closePullRequest(Z.number),await this.events.emit("pr.closed",{number:Z.number,title:Z.title,reason:"obsolete \u2014 its dependency files no longer exist"}),Z.head.startsWith("buddy/"))try{await $.deleteBranch(Z.head),this.logger.success(`\u2705 Auto-closed PR #${Z.number} and deleted branch ${Z.head}`)}catch(z){this.logger.warn(`\u26A0\uFE0F Auto-closed PR #${Z.number} but failed to delete branch: ${z}`)}else this.logger.success(`\u2705 Auto-closed PR #${Z.number}`);H++}catch(O){this.logger.error(`\u274C Failed to auto-close PR #${Z.number}:`,O)}}catch(W){this.logger.warn(`\u26A0\uFE0F Error checking PR #${Z.number}:`,W)}if(H>0)this.logger.success(`\u2705 ${X?"Would auto-close":"Auto-closed"} ${H} obsolete PR(s)`);else this.logger.info("\uD83D\uDCCB No obsolete PRs found")}catch(Q){throw this.logger.error("Failed to check for obsolete PRs:",Q),Q}}async checkAndCloseSatisfiedPRs($,X=!1){try{this.logger.info("\uD83D\uDD0D Checking for PRs where dependencies are already at target version...");let K=(await $.getPullRequests("open")).filter((_)=>_.head.startsWith("buddy/")||_.author==="github-actions[bot]"&&_.labels.includes("dependencies"));if(this.logger.info(`Found ${K.length} buddy dependency PRs to validate`),K.length===0){this.logger.info("\uD83D\uDCCB No buddy PRs to check");return}let H=0,Z={...this.config,packages:{...this.config.packages,strategy:"all"}},O=await new $0(Z,this.projectPath).scanForUpdates(),z=new Map;for(let _ of O.updates)z.set(_.name,_);let L=this.readDeclaredNpmVersions();if(O.updates.length===0){this.logger.warn("\u26A0\uFE0F Scan returned 0 updates \u2014 skipping satisfied PR check to avoid false-positive closures");return}for(let _ of K)try{let Y=this.extractPackageUpdatesFromPRBody(_.body);if(Y.length===0){this.logger.debug(`PR #${_.number}: Could not extract package updates, skipping`);continue}let J=_.body.match(/\*\*Total\*\*\s*\|\s*\*\*(\d+)\*\*/),j=J?Number.parseInt(J[1],10):0;if(j>0&&Y.length<j){this.logger.debug(`PR #${_.number}: Extracted ${Y.length}/${j} updates \u2014 incomplete extraction, skipping satisfied check`);continue}let E=0,B=0,T=0;for(let M of Y){let F=z.get(M.name);if(!F){let R=L.get(M.name);if(R){let x=this.compareVersionsSafe(R,M.newVersion);if(x==="at-or-beyond"){this.logger.debug(`PR #${_.number}: ${M.name} declared at ${R}, at or beyond ${M.newVersion}`),E++;continue}if(x==="behind"){this.logger.debug(`PR #${_.number}: ${M.name} declared at ${R}, still behind ${M.newVersion} \u2014 the scan missed it`),B++;continue}}this.logger.debug(`PR #${_.number}: ${M.name} not in current scan and not declared (unverifiable)`),T++;continue}if(F.newVersion===M.newVersion){this.logger.debug(`PR #${_.number}: ${M.name} still needs update to ${M.newVersion}`),B++;continue}let q=this.compareVersionsSafe(F.currentVersion,M.newVersion);if(q==="at-or-beyond")this.logger.debug(`PR #${_.number}: ${M.name} already at or beyond ${M.newVersion}`),E++;else if(q==="behind")this.logger.debug(`PR #${_.number}: ${M.name} still behind ${M.newVersion}`),B++;else this.logger.debug(`PR #${_.number}: ${M.name} version comparison inconclusive`),T++}let A=B===0&&T===0&&E>0;if(this.logger.debug(`PR #${_.number}: verified-satisfied=${E}, still-needed=${B}, unverifiable=${T} \u2192 ${A?"CLOSE":"KEEP"}`),A)if(this.logger.info(`\u2705 PR #${_.number} is satisfied (dependencies at target version): ${_.title}`),X)this.logger.info(`\uD83D\uDD0D [DRY RUN] Would close PR #${_.number}`),H++;else try{let M=Y.filter((q)=>{let x=z.get(q.name)?.currentVersion??L.get(q.name);if(!x)return!1;return this.compareVersionsSafe(x,q.newVersion)==="at-or-beyond"}),F=`\uD83E\uDD16 **Auto-closing satisfied PR**
90
-
91
- `;if(M.length>0)F+=`The following packages are already at the target version or newer:
92
-
93
- `,M.forEach((q)=>{F+=`- **${q.name}**: ${q.currentVersion} \u2192 ${q.newVersion}
94
- `}),F+=`
95
- `;F+="If this was closed in error, please reopen and add a comment explaining why.";try{await $.createComment(_.number,F)}catch(q){this.logger.warn(`\u26A0\uFE0F Could not add comment to PR #${_.number}:`,q)}if(await $.closePullRequest(_.number),await this.events.emit("pr.closed",{number:_.number,title:_.title,reason:"satisfied \u2014 every package already at or beyond target"}),_.head.startsWith("buddy/"))try{await $.deleteBranch(_.head),this.logger.success(`\u2705 Closed PR #${_.number} and deleted branch ${_.head}`)}catch(q){this.logger.warn(`\u26A0\uFE0F Closed PR #${_.number} but failed to delete branch: ${q}`)}else this.logger.success(`\u2705 Closed PR #${_.number}`);H++}catch(M){this.logger.error(`\u274C Failed to close PR #${_.number}:`,M)}}catch(Y){this.logger.warn(`\u26A0\uFE0F Error validating PR #${_.number}:`,Y)}if(H>0)this.logger.success(`\u2705 ${X?"Would close":"Closed"} ${H} satisfied PR(s)`);else this.logger.info("\uD83D\uDCCB No satisfied PRs found")}catch(Q){throw this.logger.error("Failed to check for satisfied PRs:",Q),Q}}generateCloseReason($){let Q=this.extractFilePathsFromPRBody($.body).filter((O)=>{let z=D("fs"),_=D("path").join(this.projectPath,O);return!z.existsSync(_)}),K=Q.some((O)=>O.includes("composer")),H=Q.some((O)=>O.includes("package.json")),Z=Q.some((O)=>O.endsWith("deps.yaml")||O.endsWith("deps.yml")||O.endsWith("dependencies.yaml")||O.endsWith("dependencies.yml")),W=`\uD83E\uDD16 **Auto-closing obsolete PR**
96
-
97
- `;if(K)W+="This PR was automatically closed because `composer.json` has been removed from the project, indicating that Composer is no longer used for dependency management.\n\n";else if(H)W+="This PR was automatically closed because `package.json` has been removed from the project, indicating that npm/yarn/pnpm is no longer used for dependency management.\n\n";else if(Z)W+=`This PR was automatically closed because the dependency files it references have been removed from the project.
98
-
99
- `;else W+=`This PR was automatically closed because the dependency files it references are no longer present in the project.
100
-
101
- `;if(Q.length>0)W+=`**Removed files:**
102
- ${Q.map((O)=>`- \`${O}\``).join(`
103
- `)}
104
-
105
- `;return W+="If this was closed in error, please reopen the PR and update the dependency files accordingly.",W}async createOrUpdateDashboard(){try{if(this.logger.info("Creating or updating dependency dashboard..."),!this.config.repository)throw Error("Repository configuration is required for dashboard");if(this.config.repository.provider!=="github")throw Error("Dashboard is currently only supported for GitHub repositories");if(!this.config.repository.owner||!this.config.repository.name)throw Error("Repository owner and name are required for dashboard. Set them in buddy.config.ts or ensure GITHUB_REPOSITORY env var is available.");let $=await e({provider:this.config.repository.provider,owner:this.config.repository.owner,name:this.config.repository.name,...this.config.repository.token?{token:this.config.repository.token}:{},...this.config.repository.apiUrl?{apiUrl:this.config.repository.apiUrl}:{}},{logger:this.logger}),X=await this.collectDashboardData($),Q=this.config.dashboard||{},{title:K,body:H}=this.dashboardGenerator.generateDashboard(X,{showOpenPRs:Q.showOpenPRs??!0,showDetectedDependencies:Q.showDetectedDependencies??!0,showDeprecatedDependencies:Q.showDeprecatedDependencies??!0,includePackageJson:Q.includePackageJson??!0,includeDependencyFiles:Q.includeDependencyFiles??!0,includeGitHubActions:Q.includeGitHubActions??!0,bodyTemplate:Q.bodyTemplate}),Z={title:Q.title||K,body:H,labels:Q.labels||["dependencies","dashboard"],assignees:Q.assignees},W=await this.findExistingDashboard($,Q.issueNumber),O=null;if(W){if(this.logger.info(`Updating existing dashboard issue #${W.number}`),O=await this.updateDashboardIssue($,W.number,Z),O)this.logger.success(`\u2705 Successfully updated dashboard issue #${O.number}`)}if(!O){this.logger.info("Creating new dashboard issue"),this.logger.info("Performing final check for existing dashboards before creation...");let z=await this.findExistingDashboard($,Q.issueNumber);if(z&&z.number!==W?.number){if(this.logger.info(`Race condition detected! Found existing dashboard #${z.number} during final check`),O=await this.updateDashboardIssue($,z.number,Z),O)this.logger.success(`\u2705 Updated existing dashboard issue #${O.number} (race condition avoided)`)}if(!O)O=await $.createIssue(Z),this.logger.success(`\u2705 Successfully created new dashboard issue #${O.number}`)}if(Q.pin!==void 0)if(!Q.pin)await $.unpinIssue(O.number);else if(d($,"pinIssues","pinIssue"))await $.pinIssue(O.number);else this.logger.debug("\uD83D\uDCCC Provider does not support pinning issues; leaving the dashboard unpinned");return this.logger.success(`\u2705 Dashboard updated: ${O.url}`),await this.events.emit("dashboard.updated",{number:O.number,url:O.url}),O}catch($){throw this.logger.error("Failed to create or update dashboard:",$),$}}async collectDashboardData($){let[X,Q]=await Promise.all([this.scanner.scanProject(),$.getPullRequests("open")]),K=Q.filter((Y)=>Y.labels.includes("dependencies")||Y.labels.includes("dependency")||Y.labels.includes("deps")||Y.title.toLowerCase().includes("update")||Y.title.toLowerCase().includes("chore(deps)")||Y.title.toLowerCase().includes("bump")||Y.title.toLowerCase().includes("upgrade")||Y.title.toLowerCase().includes("renovate")||Y.head.includes("renovate/")||Y.head.includes("dependabot/")||Y.head.includes("buddy/")||Y.head.includes("update-")||Y.head.includes("bump-")),H=X.filter((Y)=>Y.type==="package.json"),Z=X.filter((Y)=>Y.path.includes(".github/workflows/")&&(Y.path.endsWith(".yml")||Y.path.endsWith(".yaml"))),W=X.filter((Y)=>!Y.path.includes(".github/workflows/")&&Y.type!=="package.json"),z=await new u0().checkDeprecatedDependencies(X),L=await this.findVulnerableDependencies(X),_=await this.findCappedDependencies(X);return{openPRs:K,detectedDependencies:{packageJson:H,dependencyFiles:W,githubActions:Z},deprecatedDependencies:z,vulnerableDependencies:L,cappedDependencies:_,repository:{owner:this.config.repository.owner,name:this.config.repository.name,provider:this.config.repository.provider},lastUpdated:new Date}}async findCappedDependencies($){if(this.config.packages?.detectResolutionDrift===!1)return[];try{let{collectDriftInputs:X}=await import("./chunk-yp1tgdh3.js"),{findDrift:Q}=await import("./chunk-3fzbvs2p.js"),K=await X($,this.registryClient,this.projectPath,this.logger),H=Q(K).filter((Z)=>Z.kind==="capped");if(H.length>0)this.logger.info(`\uD83D\uDD17 ${H.length} package(s) capped by a dependant's range`);return H}catch(X){return this.logger.warn("Resolution drift analysis failed, continuing without it:",X),[]}}async findVulnerableDependencies($){if(this.config.security?.enabled===!1)return[];let X=[],Q=new Map;for(let K of $)for(let H of K.dependencies){let Z=Y0(H.type);if(!Z)continue;let W=H.currentVersion.replace(/^[\^~>=<\s]*v?/,"").trim();if(!W)continue;let O={name:H.name,version:W,ecosystem:Z},z=r(O);if(Q.has(z))continue;Q.set(z,{name:H.name,currentVersion:H.currentVersion,ecosystem:Z,file:K.path}),X.push(O)}if(X.length===0)return[];try{let H=await new t(this.logger).findAdvisories(X),Z=this.config.security?.minimumSeverity??"low",W={low:0,moderate:1,high:2,critical:3},O=[];for(let[z,L]of H){let _=Q.get(z);if(!_)continue;let Y=L.filter((J)=>W[J.severity]>=W[Z]);if(Y.length>0)O.push({..._,advisories:Y})}return O.sort((z,L)=>W[L.advisories[0].severity]-W[z.advisories[0].severity]),O}catch(K){return this.logger.warn("Vulnerability check failed, dashboard will omit it:",K),[]}}async updateDashboardIssue($,X,Q){try{return await $.updateIssue(X,Q)}catch(K){if(K instanceof x0&&K.isNotFound)return this.logger.warn(`Dashboard issue #${X} no longer exists in ${K.repository} (${K.status}); creating a replacement dashboard instead.`),null;throw K}}async findExistingDashboard($,X){try{if(this.logger.info("Searching for existing dashboard issue..."),X){this.logger.info(`Looking for specific dashboard issue #${X}`);let O=(await $.getIssues("open")).find((z)=>z.number===X);if(O)return this.logger.info(`Found specified dashboard issue #${O.number}: ${O.title}`),O;else return this.logger.warn(`Specified dashboard issue #${X} not found`),null}let Q=await $.getIssues("open");this.logger.info(`Found ${Q.length} open issues to search through`);for(let W of Q){let O=W.labels.includes("dashboard")&&W.labels.includes("dependencies"),z=W.title.toLowerCase().includes("dependency dashboard"),L=W.body.includes("This issue lists Buddy updates and detected dependencies");if(L||O&&z)return this.logger.info(`Found existing dashboard issue #${W.number}: ${W.title}`),this.logger.info(` - Labels: ${W.labels.join(", ")}`),this.logger.info(` - Title matches: ${z}`),this.logger.info(` - Body has marker: ${L}`),W}let K=Q.filter((W)=>W.labels.includes("dashboard")),H=Q.filter((W)=>W.labels.includes("dependencies")),Z=Q.filter((W)=>W.title.toLowerCase().includes("dependency dashboard"));if(this.logger.info("Dashboard search results:"),this.logger.info(` - Issues with 'dashboard' label: ${K.length}`),this.logger.info(` - Issues with 'dependencies' label: ${H.length}`),this.logger.info(` - Issues with 'dependency dashboard' in title: ${Z.length}`),K.length>0){this.logger.info("Issues with 'dashboard' label:");for(let W of K)this.logger.info(` - #${W.number}: ${W.title} (labels: ${W.labels.join(", ")})`)}return this.logger.info("No existing dashboard issue found"),null}catch(Q){throw this.logger.error(`Failed to search for existing dashboard: ${Q}`),Q}}}
106
- export{Y0 as Vc,t0 as Wc,t as Xc,r as Yc,C0 as Zc,$0 as _c};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ea as a,Fa as b,Ga as c,Ha as d,Ia as e,Ja as f,Ka as g}from"./chunk-yr8eta7p.js";import"./chunk-cwfkm7h9.js";import"./chunk-mkzmjg3f.js";import"./chunk-5av2vnvv.js";import"./chunk-08x5b93v.js";import"./chunk-p6qbqsyp.js";import"./chunk-cgvt98pd.js";import"./chunk-c8rzx3a1.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{g as runFixCi,e as latestFailurePerWorkflow,d as failsOnBaseBranch,b as extractErrorLines,c as describeFailure,a as classifyFailure,f as attemptFix};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ad as c,Bd as d,Cd as e,Dd as f,Ed as g,Fd as h,Gd as i,Hd as j,yd as a,zd as b}from"./chunk-vgtmrd4c.js";import"./chunk-q4t568hv.js";export{j as shouldFail,h as formatReview,d as formatPretty,e as formatGithub,f as formatAgent,b as diffArgsFor,g as countBySeverity,c as collectLocalDiff,i as applySuggestion,a as REVIEW_FORMATS};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{fd as a}from"./chunk-be629jhq.js";import"./chunk-pkr6905p.js";import"./chunk-eseshkd0.js";import"./chunk-ytmxd5fk.js";import"./chunk-b9escac0.js";import"./chunk-2et8yavs.js";import"./chunk-txtrpypt.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{a as PackageScanner};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$f as g,Vf as a,Wf as b,Xf as c,Yf as d,Zf as e,_f as f,ag as h,bg as i,cg as j,dg as k,eg as l,fg as m}from"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{h as sortUpdatesByPriority,j as satisfiesRange,a as parsePackageFile,g as groupUpdates,i as getUpdateType,f as generateBranchName,d as formatPRTitle,e as formatPRBody,c as formatCommitMessage,l as extractPackageNamesFromPRBody,b as detectPackageManager,k as checkForRebaseRequests,m as checkForAutoClose};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$ as d,Y as a,Z as b,_ as c}from"./chunk-jnb80k2x.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{a as validateAgainstSchema,b as runHeadless,d as publishOutput,c as formatGithubOutput};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{th as a}from"./chunk-5044y9en.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{a as GitLabProvider};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ed as a}from"./chunk-r763e19p.js";import"./chunk-pkr6905p.js";import"./chunk-eseshkd0.js";import"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{a as RegistryClient};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Kc as a,Lc as b,Mc as c,Nc as d}from"./chunk-8fw0v7bv.js";import"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{b as regenerateLockFile,d as hasLockFile,a as getAllLockFilePaths,c as detectRequiredPackageManagers};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{gg as a,hg as b,ig as c,jg as d,kg as e,lg as f,mg as g,ng as h,og as i,pg as j}from"./chunk-3901s7h9.js";import"./chunk-q4t568hv.js";export{h as withManifest,g as stripManifest,c as serializeManifest,d as serializeGroupManifest,e as parseManifest,i as manifestUpdates,j as manifestFiles,f as hasManifest,a as MANIFEST_SCHEMA_VERSION,b as MANIFEST_MAX_LENGTH};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{_c as a}from"./chunk-e2t5jq26.js";import"./chunk-phfmnnne.js";import"./chunk-r763e19p.js";import"./chunk-be629jhq.js";import"./chunk-pkr6905p.js";import"./chunk-eseshkd0.js";import"./chunk-11hdrnf6.js";import"./chunk-mkzmjg3f.js";import"./chunk-5av2vnvv.js";import"./chunk-ytmxd5fk.js";import"./chunk-b9escac0.js";import"./chunk-g30dr44w.js";import"./chunk-2et8yavs.js";import"./chunk-txtrpypt.js";import"./chunk-8hjvthz4.js";import"./chunk-yngahb11.js";import"./chunk-08x5b93v.js";import"./chunk-p6qbqsyp.js";import"./chunk-1cpdz49v.js";import"./chunk-cgvt98pd.js";import"./chunk-c8rzx3a1.js";import"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{a as Buddy};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{W as a,X as b}from"./chunk-rayxmbcx.js";import"./chunk-tjc2vgwn.js";import"./chunk-cs066zt9.js";import"./chunk-eseshkd0.js";import"./chunk-cwfkm7h9.js";import"./chunk-mkzmjg3f.js";import"./chunk-nrr8z2z7.js";import"./chunk-xs12dtf1.js";import"./chunk-5av2vnvv.js";import"./chunk-1cpdz49v.js";import"./chunk-cgvt98pd.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{b as renderDoctorReport,a as diagnose};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ne as a,oe as b,pe as c,qe as d,re as e}from"./chunk-ytmxd5fk.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{c as updateGitHubActionsFile,b as parseGitHubActionsFile,a as isGitHubActionsFile,d as generateGitHubActionsUpdates,e as fetchLatestActionVersion};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{gf as a,hf as b,if as c}from"./chunk-8hjvthz4.js";import"./chunk-yngahb11.js";import"./chunk-08x5b93v.js";import"./chunk-p6qbqsyp.js";import"./chunk-1cpdz49v.js";import"./chunk-cgvt98pd.js";import"./chunk-c8rzx3a1.js";import"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{a as matchesGlobs,c as appendUpgradeReport,b as analyzeGroupMajors};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$c as a}from"./chunk-phfmnnne.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{a as DeprecatedDependenciesChecker};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{nd as a}from"./chunk-11hdrnf6.js";import"./chunk-g30dr44w.js";import"./chunk-0hc97k0t.js";import"./chunk-3901s7h9.js";import"./chunk-jtxcr5yw.js";import"./chunk-qd2s51gc.js";import"./chunk-193abzy6.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";export{a as PullRequestGenerator};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ae as a,be as b}from"./chunk-xs12dtf1.js";import"./chunk-q4t568hv.js";export{b as auditParsed,a as audit};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{De as a,Ee as b,Fe as c,Ge as d,He as e,Ie as f}from"./chunk-b9escac0.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{e as updateDockerfile,d as resolveDockerDigest,b as parseDockerfile,a as isDockerfile,f as generateDockerfileUpdates,c as fetchLatestDockerImageVersion};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{oh as H}from"./chunk-193abzy6.js";import{zh as M}from"./chunk-e68nf7cm.js";import{Fh as E}from"./chunk-hfjywbbc.js";import{Wk as T}from"./chunk-q4t568hv.js";import W from"process";function v(J){let q=J.replace(/\\/g,"/");return q.includes(".github/workflows/")&&(q.endsWith(".yml")||q.endsWith(".yaml"))}async function N(J,q){try{if(!v(J))return null;let I=[],j=q.split(`
3
- `);for(let Q=0;Q<j.length;Q++){let Z=j[Q].trim().match(/^-?\s*uses:\s*(.+)/);if(Z){let _=Z[1].trim().replace(/['"`]/g,"");if(_.startsWith("./")||_.startsWith("docker://"))continue;let K=_.split("@");if(K.length===2){let[X,O]=K;if(!X||!X.trim())continue;let x=O.split("#")[0].trim(),$={name:X.trim(),currentVersion:x,type:"github-actions",file:J};if(!I.find((S)=>S.name===$.name&&S.currentVersion===$.currentVersion))I.push($)}}}return{path:J,type:"github-actions",content:q,dependencies:I}}catch(I){return E().warn(`Failed to parse GitHub Actions file ${J}:`,I),null}}async function A(J,q,I){try{if(!v(J))return q;let j=q;for(let Q of I){let V=Q.name.replace(/\s*\(.*\)$/,""),Y=new RegExp(`((?:^\\s*-\\s*)?uses:\\s*["']?)(${V.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})@(${Q.currentVersion.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})(["']?)`,"gm");j=j.replace(Y,`$1$2@${Q.newVersion}$4`)}return j}catch(j){return E().warn(`Failed to update GitHub Actions file ${J}:`,j),q}}async function L(J){let q=[],I=new Map;for(let j of J)if(v(j.file)){if(!I.has(j.file))I.set(j.file,[]);I.get(j.file).push(j)}for(let[j,Q]of I)try{let V=await import("fs");if(V.existsSync(j)){let Y=V.readFileSync(j,"utf-8"),Z=await A(j,Y,Q);q.push({path:j,content:Z,type:"update"})}}catch(V){E().warn(`Failed to generate updates for GitHub Actions file ${j}:`,V)}return q}async function R(J){try{if(!J.includes("/"))return E().info(`\u26A0\uFE0F Invalid action name format: ${J}`),null;let[q,I]=J.split("/");E().info(`\uD83D\uDD0D Fetching latest version for ${q}/${I}`);let j={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"},Q=W.env.BUDDY_TOKEN||W.env.GITHUB_TOKEN||W.env.GH_TOKEN;if(Q)j.Authorization=`Bearer ${Q}`;let V=H();E().info(`\uD83D\uDCE1 Trying latest release for ${q}/${I}`);let Y=await M(`${V}/repos/${q}/${I}/releases/latest`,{headers:j});if(Y.ok){let K=await Y.json();if(K.tag_name)return E().info(`\u2705 Found latest release: ${K.tag_name}`),K.tag_name}else E().info(`\u26A0\uFE0F Latest release not found: ${Y.status} ${Y.statusText}`);E().info(`\uD83D\uDCE1 Trying all releases for ${q}/${I}`);let Z=await M(`${V}/repos/${q}/${I}/releases?per_page=10`,{headers:j});if(Z.ok){let K=await Z.json();if(!Array.isArray(K))E().info("\u26A0\uFE0F Unexpected releases response format (expected array)");else{E().info(`\uD83D\uDCCB Found ${K.length} releases`);let X=K.filter((O)=>O.tag_name&&!O.tag_name.includes("-")).sort((O,x)=>{let $=O.published_at?new Date(O.published_at).getTime():0;return(x.published_at?new Date(x.published_at).getTime():0)-$});if(X.length>0)return E().info(`\u2705 Found latest stable release: ${X[0].tag_name}`),X[0].tag_name||null}}else E().info(`\u26A0\uFE0F Releases not found: ${Z.status} ${Z.statusText}`);E().info(`\uD83D\uDCE1 Trying tags for ${q}/${I}`);let _=await M(`${V}/repos/${q}/${I}/tags?per_page=10`,{headers:j});if(_.ok){let K=await _.json();if(!Array.isArray(K))E().info("\u26A0\uFE0F Unexpected tags response format (expected array)");else{E().info(`\uD83D\uDCCB Found ${K.length} tags`);let X=K.filter((O)=>O.name&&!O.name.includes("-")).map((O)=>O.name).sort((O,x)=>{let $=O.replace(/^v/,""),z=x.replace(/^v/,""),S=$.split(".").map(Number),y=z.split(".").map(Number);for(let k=0;k<Math.max(S.length,y.length);k++){let B=S[k]||0,G=y[k]||0;if(B!==G)return G-B}return 0});if(X.length>0)return E().info(`\u2705 Found latest stable tag: ${X[0]}`),X[0]}}else E().info(`\u26A0\uFE0F Tags not found: ${_.status} ${_.statusText}`);return E().info(`\u274C No version found for ${J}`),null}catch(q){return E().warn(`Failed to fetch latest version for ${J}:`,q),null}}
4
- export{v as ne,N as oe,A as pe,L as qe,R as re};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Se as a,Te as b,Ue as c,Ve as d}from"./chunk-txtrpypt.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{c as updateZigManifest,b as parseZigManifest,a as isZigManifest,d as generateZigManifestUpdates};