@visulima/vis 1.0.0-alpha.37 → 1.0.0-alpha.39

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 (176) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +1 -503
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/config/index.d.ts +7 -0
  6. package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -0
  7. package/dist/packem_chunks/bin.js +302 -515
  8. package/dist/packem_chunks/bloom-sync.js +1 -1
  9. package/dist/packem_chunks/catalog-detector.js +1 -0
  10. package/dist/packem_chunks/detect.js +3 -0
  11. package/dist/packem_chunks/detect2.js +8 -0
  12. package/dist/packem_chunks/discord.js +4 -0
  13. package/dist/packem_chunks/dynamic-import.js +1 -0
  14. package/dist/packem_chunks/extra-files.js +3 -0
  15. package/dist/packem_chunks/fix.js +1 -1
  16. package/dist/packem_chunks/git.js +3 -0
  17. package/dist/packem_chunks/handler10.js +1 -1
  18. package/dist/packem_chunks/handler12.js +1 -1
  19. package/dist/packem_chunks/handler13.js +1 -1
  20. package/dist/packem_chunks/handler14.js +1 -1
  21. package/dist/packem_chunks/handler15.js +1 -1
  22. package/dist/packem_chunks/handler16.js +1 -1
  23. package/dist/packem_chunks/handler17.js +1 -1
  24. package/dist/packem_chunks/handler18.js +1 -1
  25. package/dist/packem_chunks/handler19.js +1 -1
  26. package/dist/packem_chunks/handler21.js +1 -1
  27. package/dist/packem_chunks/handler27.js +1 -1
  28. package/dist/packem_chunks/handler28.js +1 -1
  29. package/dist/packem_chunks/handler29.js +1 -1
  30. package/dist/packem_chunks/handler3.js +4 -4
  31. package/dist/packem_chunks/handler30.js +2 -7
  32. package/dist/packem_chunks/handler31.js +2 -33
  33. package/dist/packem_chunks/handler32.js +2 -3
  34. package/dist/packem_chunks/handler33.js +3 -8
  35. package/dist/packem_chunks/handler34.js +6 -4
  36. package/dist/packem_chunks/handler35.js +1 -1
  37. package/dist/packem_chunks/handler36.js +42 -5
  38. package/dist/packem_chunks/handler37.js +8 -11
  39. package/dist/packem_chunks/handler38.js +9 -3
  40. package/dist/packem_chunks/handler39.js +74 -21
  41. package/dist/packem_chunks/handler4.js +1 -1
  42. package/dist/packem_chunks/handler40.js +5 -61
  43. package/dist/packem_chunks/handler41.js +4 -3
  44. package/dist/packem_chunks/handler42.js +3 -6
  45. package/dist/packem_chunks/handler43.js +2 -24
  46. package/dist/packem_chunks/handler44.js +1 -25
  47. package/dist/packem_chunks/handler45.js +1 -153
  48. package/dist/packem_chunks/handler46.js +1 -10
  49. package/dist/packem_chunks/handler47.js +3 -24
  50. package/dist/packem_chunks/handler48.js +1 -322
  51. package/dist/packem_chunks/handler49.js +7 -708
  52. package/dist/packem_chunks/handler5.js +6 -6
  53. package/dist/packem_chunks/handler50.js +33 -48
  54. package/dist/packem_chunks/handler51.js +3 -27
  55. package/dist/packem_chunks/handler52.js +8 -3
  56. package/dist/packem_chunks/handler53.js +4 -200
  57. package/dist/packem_chunks/handler54.js +1 -38
  58. package/dist/packem_chunks/handler55.js +12 -0
  59. package/dist/packem_chunks/handler56.js +7 -0
  60. package/dist/packem_chunks/handler57.js +5 -0
  61. package/dist/packem_chunks/handler58.js +11 -0
  62. package/dist/packem_chunks/handler59.js +3 -0
  63. package/dist/packem_chunks/handler60.js +22 -0
  64. package/dist/packem_chunks/handler61.js +61 -0
  65. package/dist/packem_chunks/handler62.js +3 -0
  66. package/dist/packem_chunks/handler63.js +6 -0
  67. package/dist/packem_chunks/handler64.js +708 -0
  68. package/dist/packem_chunks/handler65.js +24 -0
  69. package/dist/packem_chunks/handler66.js +25 -0
  70. package/dist/packem_chunks/handler67.js +153 -0
  71. package/dist/packem_chunks/handler68.js +10 -0
  72. package/dist/packem_chunks/handler69.js +24 -0
  73. package/dist/packem_chunks/handler7.js +1 -1
  74. package/dist/packem_chunks/handler70.js +322 -0
  75. package/dist/packem_chunks/handler71.js +48 -0
  76. package/dist/packem_chunks/handler72.js +27 -0
  77. package/dist/packem_chunks/handler73.js +3 -0
  78. package/dist/packem_chunks/handler74.js +190 -0
  79. package/dist/packem_chunks/handler75.js +38 -0
  80. package/dist/packem_chunks/handler8.js +1 -1
  81. package/dist/packem_chunks/handler9.js +1 -1
  82. package/dist/packem_chunks/heal-accept.js +1 -1
  83. package/dist/packem_chunks/heal.js +1 -1
  84. package/dist/packem_chunks/help-command.js +1 -1
  85. package/dist/packem_chunks/index.js +1 -7
  86. package/dist/packem_chunks/index2.js +7 -0
  87. package/dist/packem_chunks/interface.js +2 -0
  88. package/dist/packem_chunks/keys-refresh.js +1 -1
  89. package/dist/packem_chunks/list.js +1 -1
  90. package/dist/packem_chunks/loader.js +1 -1
  91. package/dist/packem_chunks/orchestrator.js +39 -0
  92. package/dist/packem_chunks/pre-mode.js +2 -0
  93. package/dist/packem_chunks/print-config.js +2 -0
  94. package/dist/packem_chunks/prompts.js +7 -0
  95. package/dist/packem_chunks/publish-guards.js +1 -0
  96. package/dist/packem_chunks/registry.js +48 -0
  97. package/dist/packem_chunks/resolveFormatter.js +9 -0
  98. package/dist/packem_chunks/security.js +1 -0
  99. package/dist/packem_chunks/shell-runner.js +1 -0
  100. package/dist/packem_chunks/slack.js +2 -0
  101. package/dist/packem_chunks/snapshot.js +2 -0
  102. package/dist/packem_chunks/stage-publisher.js +1 -0
  103. package/dist/packem_chunks/staged-registry.js +2 -0
  104. package/dist/packem_chunks/state.js +3 -0
  105. package/dist/packem_chunks/success-walk.js +8 -0
  106. package/dist/packem_chunks/sync.js +1 -1
  107. package/dist/packem_chunks/sync2.js +1 -1
  108. package/dist/packem_chunks/tripwire.js +1 -1
  109. package/dist/packem_chunks/verify-lockfile.js +2 -2
  110. package/dist/packem_chunks/version-resolver.js +2 -0
  111. package/dist/packem_chunks/webhook.js +1 -0
  112. package/dist/packem_chunks/workflow-templates.js +167 -0
  113. package/dist/packem_chunks/workspace.js +2 -0
  114. package/dist/packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js +1 -0
  115. package/dist/packem_shared/ReleaseClient-YHzBIxYS.js +1 -0
  116. package/dist/packem_shared/VisReleaseError-DMGRBTNO.js +1 -0
  117. package/dist/packem_shared/{ai-analysis-DT3bU-_M.js → ai-analysis-K-DKU3ZA.js} +1 -1
  118. package/dist/packem_shared/{ai-fix-BkNqd5nP.js → ai-fix-BPrYoCk8.js} +1 -1
  119. package/dist/packem_shared/api.d-BPftyU9r.d.ts +27 -0
  120. package/dist/packem_shared/createAdapter-bU4DIP3F.js +1 -0
  121. package/dist/packem_shared/createVersionActions-BK43SNDH.js +1 -0
  122. package/dist/packem_shared/{cyclonedx-86-DbHtf.js → cyclonedx-kYozDyxp.js} +3 -3
  123. package/dist/packem_shared/defineFormatter-D5dCp6Kv.js +1 -0
  124. package/dist/packem_shared/dependency-scan-anTuZB1t.js +1 -0
  125. package/dist/packem_shared/{docker-tNrDU3oK.js → docker-BMLrNtWm.js} +1 -1
  126. package/dist/packem_shared/{failure-log-Dwqt6_Ga.js → failure-log-CEWP3bP0.js} +1 -1
  127. package/dist/packem_shared/{index-dQ37x8_P.js → index-B4RYu87L.js} +1 -1
  128. package/dist/packem_shared/index-BJbpNthk.js +1 -0
  129. package/dist/packem_shared/index-CgcF6_wo.js +1 -0
  130. package/dist/packem_shared/interface.d-B7VK2rcH.d.ts +148 -0
  131. package/dist/packem_shared/interface.d-Cezzifoh.d.ts +106 -0
  132. package/dist/packem_shared/{missing-package-json-41VUWFBY.js → missing-package-json-BfWUxTGv.js} +1 -1
  133. package/dist/packem_shared/{native-config-sync-BKAZ0NIs.js → native-config-sync-BEkJW7g3.js} +8 -8
  134. package/dist/packem_shared/pm-runner-OGResYrA.js +1 -0
  135. package/dist/packem_shared/provenance-_CJjMKwu.js +1 -0
  136. package/dist/packem_shared/public-api-WqUCiyIe.js +131 -0
  137. package/dist/packem_shared/{registry-keys-Bf2zzlcZ.js → registry-keys-BfFto6vI.js} +1 -1
  138. package/dist/packem_shared/{resolve-explicit-jH0RKyMJ.js → resolve-explicit-CMDl55Nz.js} +2 -2
  139. package/dist/packem_shared/s1ngularity-Dhr3bPk0.js +1 -0
  140. package/dist/packem_shared/{scan-progress-JBbd9QeT.js → scan-progress-DG7_JmTV.js} +1 -1
  141. package/dist/packem_shared/{signatures-D1H6h6GH.js → signatures-C730vkyK.js} +2 -2
  142. package/dist/packem_shared/slug-DoueYuLo.js +1 -0
  143. package/dist/packem_shared/spinner-CV3WVJLv.js +1 -0
  144. package/dist/packem_shared/sticky-comment-D6_7-w8T.js +1 -0
  145. package/dist/packem_shared/{tabs-BqUepRaD.js → tabs-BuTy5gPV.js} +1 -1
  146. package/dist/packem_shared/{typosquats-C8qg1neE.js → typosquats-DN78xx1x.js} +1 -1
  147. package/dist/packem_shared/use-measured-height-_eVGWtWt.js +1 -0
  148. package/dist/packem_shared/verify-6WCmFmy8.js +1 -0
  149. package/dist/packem_shared/{vis-update-app-CTwRkNgj.js → vis-update-app-k3fDxech.js} +1 -1
  150. package/dist/release/core/changelog/index.d.ts +5 -0
  151. package/dist/release/core/changelog/index.js +1 -0
  152. package/dist/release/core/package-managers/index.d.ts +6 -0
  153. package/dist/release/core/package-managers/index.js +1 -0
  154. package/dist/release/core/version-actions/index.d.ts +14 -0
  155. package/dist/release/core/version-actions/index.js +1 -0
  156. package/dist/release/index.d.ts +196 -0
  157. package/dist/release/index.js +1 -0
  158. package/dist/release/plugin-sdk.d.ts +127 -0
  159. package/dist/release/plugin-sdk.js +1 -0
  160. package/dist/release/presets.d.ts +225 -0
  161. package/dist/release/presets.js +1 -0
  162. package/dist/release/types.d.ts +1377 -0
  163. package/dist/release/types.js +1 -0
  164. package/index.js +578 -752
  165. package/package.json +52 -10
  166. package/schemas/vis-config.schema.json +1394 -6
  167. package/schemas/vis-release-config.schema.json +1390 -0
  168. package/dist/packem_shared/dependency-scan-BDTH898x.js +0 -1
  169. package/dist/packem_shared/index-CB4p298r.js +0 -1
  170. package/dist/packem_shared/index-DMefdF51.js +0 -1
  171. package/dist/packem_shared/pm-runner-pVihAfxV.js +0 -1
  172. package/dist/packem_shared/provenance-DMuEftgc.js +0 -1
  173. package/dist/packem_shared/s1ngularity-BkfgC6NO.js +0 -1
  174. package/dist/packem_shared/spinner-BXSl864p.js +0 -1
  175. package/dist/packem_shared/use-measured-height-BBJ9intr.js +0 -1
  176. package/dist/packem_shared/verify-Du7xZ2BJ.js +0 -1
@@ -1,8 +1,8 @@
1
- import{createRequire as Y}from"node:module";import{w as A,d as G,p,P as H,e as J,R as V,i as S,a as K,V as Z,$ as T,k as a,h as Q,g,H as M,W as X,G as ee,j as te,B as oe,F as f}from"./bin.js";import"../packem_shared/index-BDmTbWX1.js";import{K as se,Z as re,W as ne}from"../packem_shared/ai-analysis-DT3bU-_M.js";import{w as ie}from"../packem_shared/pm-runner-pVihAfxV.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-CTwRkNgj.js";const de=Y(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const he=async({argument:E,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.securityConfig){const t=ie(d);if(A(i??{},t.name),e.sync&&t.name==="pnpm"){const s=G(i??{});if(s.length>0){p.info(`
2
- Settings that would sync to pnpm-workspace.yaml:`);for(const R of s)p.success(` ${R}`)}else p.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(p.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),p.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!E?.length)return}const{packageManager:U}=H(d),B=J(d),c=i?.update??{},y=V(d,U,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(y.size===0){o.info("No catalogs found.");return}const h=e.target??c.target??"latest";if(!["latest","minor","patch"].includes(h))throw new Error(`Invalid target "${h}". Use: latest, minor, or patch.`);const D={exclude:[...f(e.exclude),...f(c.exclude)],ignore:f(c.ignore),include:[...f(e.include),...f(c.include),...E],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||c.prerelease||!1,security:e.security!==!1,target:h};let j=0;for(const t of y.values())j+=t.size;const $=!!process.stdout.isTTY&&!te;let l;const F=$?(t,s)=>{l?l.rerender(a.createElement(N,{current:t,total:s})):l=T(a.createElement(N,{current:t,total:s}),{interactive:!0,patchConsole:!1})}:(t,s)=>{o.info(`Checking ${String(t)}/${String(s)} dependencies...`)};$||o.info(`Checking ${String(j)} catalog dependencies against npm registry...
3
- `);const w=new Set;S("socket")&&w.add("socket"),S("depsDev")&&w.add("deps-dev");const v=i?.security?.policies?.score?.minimum,I=K(i?.security,{disabled:w,minimumScore:v}),{failed:k,outdated:n}=await Z(y,D,B,F,d,I,i?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),k.length>0&&o.warn(`Failed to fetch: ${k.join(", ")}`),n.length===0){o.info("All catalog dependencies are up to date.");return}const b=e.format??c.format??"table",P=se(e.aiType??"impact"),u=e.ai?await re(n,o,i?.ai,P):void 0;if($&&b==="table"){const t=new ae(n,u??null),s=i?.tui?.autoExit??!1,R=s===!0?3:typeof s=="number"?s:0;await T(a.createElement(ce,{autoExitSeconds:R,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
- `);for(const r of n){const z=r.vulnerabilities?.length||r.socketReport&&r.socketReport.alerts.length>0,_=!!r.acceptedRisk,L=z?_?"✓":"⚠":"✓",O=_?"gray":r.updateType==="major"?"red":r.updateType==="minor"?"yellow":"green",m=r.socketReport?.score.overall,W=m===void 0?"":` [${String(Math.round(m*100))}%]`,x=m===void 0?void 0:oe(m);process.stdout.write(`${Q(a.createElement(g,null," ",a.createElement(g,{color:O},L),` ${r.packageName} ${r.currentRange} → ${r.newRange}`,a.createElement(g,{dimColor:!0},` ${r.updateType}`),x?a.createElement(g,{color:x},W):null),{columns:q})}
1
+ import{createRequire as A}from"node:module";import{w as G,i as H,p,P as J,j as V,R as W,l as S,c as K,V as Z,$ as T,k as a,h as Q,m as g,H as M,o as X,G as ee,r as te,B as oe,F as m}from"./bin.js";import"../packem_shared/index-BDmTbWX1.js";import"../packem_shared/public-api-WqUCiyIe.js";import{K as se,Z as re,W as ne}from"../packem_shared/ai-analysis-K-DKU3ZA.js";import{w as ie}from"../packem_shared/pm-runner-OGResYrA.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-k3fDxech.js";const ue=A(import.meta.url),de=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const $e=async({argument:E,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const u=C;if(e.securityConfig){const t=ie(u);if(G(i??{},t.name),e.sync&&t.name==="pnpm"){const s=H(i??{});if(s.length>0){p.info(`
2
+ Settings that would sync to pnpm-workspace.yaml:`);for(const R of s)p.success(` ${R}`)}else p.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(p.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),p.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!E?.length)return}const{packageManager:U}=J(u),B=V(u),c=i?.update??{},y=W(u,U,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(y.size===0){o.info("No catalogs found.");return}const h=e.target??c.target??"latest";if(!["latest","minor","patch"].includes(h))throw new Error(`Invalid target "${h}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(c.exclude)],ignore:m(c.ignore),include:[...m(e.include),...m(c.include),...E],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||c.prerelease||!1,security:e.security!==!1,target:h};let j=0;for(const t of y.values())j+=t.size;const $=!!process.stdout.isTTY&&!te;let l;const F=$?(t,s)=>{l?l.rerender(a.createElement(N,{current:t,total:s})):l=T(a.createElement(N,{current:t,total:s}),{interactive:!0,patchConsole:!1})}:(t,s)=>{o.info(`Checking ${String(t)}/${String(s)} dependencies...`)};$||o.info(`Checking ${String(j)} catalog dependencies against npm registry...
3
+ `);const w=new Set;S("socket")&&w.add("socket"),S("depsDev")&&w.add("deps-dev");const v=i?.security?.policies?.score?.minimum,I=K(i?.security,{disabled:w,minimumScore:v}),{failed:k,outdated:n}=await Z(y,D,B,F,u,I,i?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),k.length>0&&o.warn(`Failed to fetch: ${k.join(", ")}`),n.length===0){o.info("All catalog dependencies are up to date.");return}const b=e.format??c.format??"table",P=se(e.aiType??"impact"),d=e.ai?await re(n,o,i?.ai,P):void 0;if($&&b==="table"){const t=new ae(n,d??null),s=i?.tui?.autoExit??!1,R=s===!0?3:typeof s=="number"?s:0;await T(a.createElement(ce,{autoExitSeconds:R,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
+ `);for(const r of n){const z=r.vulnerabilities?.length||r.socketReport&&r.socketReport.alerts.length>0,_=!!r.acceptedRisk,L=z?_?"✓":"⚠":"✓",O=_?"gray":r.updateType==="major"?"red":r.updateType==="minor"?"yellow":"green",f=r.socketReport?.score.overall,Y=f===void 0?"":` [${String(Math.round(f*100))}%]`,x=f===void 0?void 0:oe(f);process.stdout.write(`${Q(a.createElement(g,null," ",a.createElement(g,{color:O},L),` ${r.packageName} ${r.currentRange} → ${r.newRange}`,a.createElement(g,{dimColor:!0},` ${r.updateType}`),x?a.createElement(g,{color:x},Y):null),{columns:q})}
5
5
  `)}process.stdout.write(`
6
- `),o.info(M(n,v))}else if(b==="json"){const t={failed:k,outdated:n};u&&(t.aiAnalysis=u),process.stdout.write(`${JSON.stringify(t,void 0,2)}
6
+ `),o.info(M(n,v))}else if(b==="json"){const t={failed:k,outdated:n};d&&(t.aiAnalysis=d),process.stdout.write(`${JSON.stringify(t,void 0,2)}
7
7
  `)}else b==="minimal"?process.stdout.write(`${X(n)}
8
- `):(ee(n,o),o.info(M(n,v)),u&&(o.info(""),o.info(ne(u))));e.exitCode&&n.length>0&&(process.exitCode=1)};export{he as default};
8
+ `):(ee(n,o),o.info(M(n,v)),d&&(o.info(""),o.info(ne(d))));e.exitCode&&n.length>0&&(process.exitCode=1)};export{$e as default};
@@ -1,48 +1,33 @@
1
- import{createRequire as nt}from"node:module";import{I as Pe,s as D,E as M,q as We,V as G,j as ot}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{m as B,f as O,v as K,I as J,A as rt,T as it}from"../packem_shared/index-BDmTbWX1.js";import{aY as at,P as ct,bb as lt,bc as ut,bd as dt,be as pt,u as ve,b1 as ft,j as ie,i as ue,e as gt,R as mt,a as ht,V as $t,bf as yt,bg as qe,$ as be,k as _,h as de,g as q,H as He,bh as wt,F as P,B as kt,bi as vt,bj as bt,W as Rt,G as xt}from"./bin.js";import{K as Ct,Z as Et,W as Re}from"../packem_shared/ai-analysis-DT3bU-_M.js";import{v as Tt,s as ee,I as jt,a as Le}from"../packem_shared/pm-runner-pVihAfxV.js";import{r as It,a as Nt,p as Dt}from"../packem_shared/resolve-explicit-jH0RKyMJ.js";import{r as Ot,s as Ut}from"../packem_shared/typosquats-C8qg1neE.js";import{U as Vt,b as Bt,u as xe}from"../packem_shared/vis-update-app-CTwRkNgj.js";import{h as Fe,P as ze}from"../packem_shared/peer-warnings-BXAzXqY3.js";import{f as _t}from"../packem_shared/utils-Cxree603.js";import{r as Mt,q as Pt}from"../packem_shared/advisories-DLeO5KMN.js";const st=nt(import.meta.url),X=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_e=e=>{if(typeof X<"u"&&X.versions&&X.versions.node){const[n,t]=X.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return X.getBuiltinModule(e)}return st(e)},{createInterface:Me}=_e("node:readline"),{existsSync:At,realpathSync:St}=_e("node:fs"),Wt=e=>{const n=[];for(const t of e.filters)n.push("--filter",t);return e.workspaceRoot&&n.push("--filter","."),n.push("update"),e.latest&&n.push("--latest"),e.recursive&&n.push("--recursive"),e.interactive&&n.push("--interactive"),e.dev&&n.push("--dev"),e.prod&&n.push("--prod"),e.noOptional&&n.push("--no-optional"),e.noSave&&n.push("--no-save"),n.push(...e.packages),{args:n,bin:"pnpm"}},qt=e=>{const n=[];return e.filters.length>0&&n.push("workspace",e.filters[0]),n.push("upgrade"),e.latest&&n.push("--latest"),n.push(...e.packages),{args:n,bin:"yarn"}},Ht=e=>{const n=[];if(e.filters.length>0||e.recursive){n.push("workspaces","foreach","--all");for(const t of e.filters)n.push("--include",t)}return n.push("up"),e.interactive&&n.push("--interactive"),n.push(...e.packages),{args:n,bin:"yarn"}},Lt=(e,n)=>{const t=["update"];e.latest&&n.push("npm does not support --latest flag. Packages will be updated within their semver range."),e.interactive&&n.push("npm does not support --interactive mode.");for(const s of e.filters)t.push("--workspace",s);return e.recursive&&t.push("--workspaces"),e.workspaceRoot&&t.push("--include-workspace-root"),e.dev&&t.push("--dev"),e.prod&&t.push("--production"),e.noOptional&&t.push("--no-optional"),e.noSave&&t.push("--no-save"),t.push(...e.packages),{args:t,bin:"npm"}},Ft=e=>{const n=["update"];e.latest&&n.push("--latest");for(const t of e.filters)n.push("--filter",t);return n.push(...e.packages),{args:n,bin:"bun"}},zt=(e,n)=>{const t=["outdated","--update"];return e.latest&&t.push("--latest"),e.interactive&&t.push("--interactive"),e.filters.length>0&&n.push("deno outdated has no --filter flag; ignoring."),(e.dev||e.prod)&&n.push("deno outdated has no --dev / --prod flags; dev/prod is governed by deno.json."),e.noOptional&&n.push("deno outdated has no --no-optional flag; ignoring."),e.noSave&&n.push("deno outdated has no --no-save flag; ignoring."),t.push(...e.packages),{args:t,bin:"deno"}},Gt=(e,n,t)=>{const s=[];if(t.global&&e!=="aube"&&e!=="deno")return{command:{args:["update","--global",...t.packages],bin:"npm"},warnings:s};let r;switch(e){case"aube":{const o=Tt(t);r={args:o.args,bin:o.bin},s.push(...o.warnings);break}case"bun":{r=Ft(t);break}case"deno":{r=zt(t,s);break}case"npm":{r=Lt(t,s);break}case"pnpm":{r=Wt(t);break}case"yarn":{r=n.startsWith("1.")?qt(t):Ht(t);break}default:{const o=e;throw new Error(`Unsupported package manager: ${String(o)}`)}}return{command:r,warnings:s}},Ge=e=>{const n=e.indexOf("@");return n<=0?e:e.slice(0,n)},Kt=e=>{switch(e){case"docker":case"docker-compose":return"docker";case"github-actions":return"actions";case"gitlab-ci":return"gitlab";default:return}},Jt=(e,n)=>{const t=[".github/dependabot.yml",".github/dependabot.yaml"];for(const s of t){const r=B(e,s);if(!O(r))continue;let o;try{o=at(K(r))}catch{continue}if(o?.updates){for(const i of o.updates){const a=Kt(i["package-ecosystem"]);if(!(!a||!Array.isArray(i.ignore)))for(const d of i.ignore){const l=d["dependency-name"];typeof l=="string"&&l.length>0&&n[a].add(Ge(l))}}return}}},Yt=Object.freeze({"docker-compose":"docker",dockerfile:"docker","github-actions":"actions",gitlabci:"gitlab","gitlabci-include":"gitlab"}),Zt=Object.freeze({docker:"docker","github-tags":"actions"}),pe=(e,n)=>{if(n)for(const t of n)typeof t=="string"&&t.length>0&&e.add(Ge(t))},Xt=e=>{let n="",t=0;const{length:s}=e;let r=!1,o="";for(;t<s;){const i=e[t]??"";if(r){if(n+=i,i==="\\"&&t+1<s){n+=e[t+1]??"",t+=2;continue}i===o&&(r=!1),t+=1;continue}if(i==='"'||i==="'"){r=!0,o=i,n+=i,t+=1;continue}if(i==="/"&&e[t+1]==="/"){for(;t<s&&e[t]!==`
2
- `;)t+=1;continue}if(i==="/"&&e[t+1]==="*"){for(t+=2;t<s&&!(e[t]==="*"&&e[t+1]==="/");)t+=1;t+=2;continue}if(i===","){let a=t+1;for(;a<s&&/\s/.test(e[a]??"");)a+=1;const d=e[a];if(d==="}"||d==="]"){t+=1;continue}}n+=i,t+=1}return n},Qt=(e,n)=>{const t=["renovate.json","renovate.json5",".renovaterc",".renovaterc.json"];for(const s of t){const r=B(e,s);if(!O(r))continue;let o;try{const a=K(r);o=JSON.parse(Xt(a))}catch{continue}if(!o)continue;if(Array.isArray(o.ignoreDeps))for(const a of["actions","docker","gitlab"])pe(n[a],o.ignoreDeps);const i=[["github-actions","actions"],["dockerfile","docker"],["docker-compose","docker"],["gitlabci","gitlab"],["gitlabci-include","gitlab"]];for(const[a,d]of i){const l=o[a];pe(n[d],l?.ignoreDeps)}if(!Array.isArray(o.packageRules))return;for(const a of o.packageRules){if(a.enabled!==!1)continue;const d=new Set;for(const c of a.matchManagers??[]){const f=Yt[c];f&&d.add(f)}for(const c of a.matchDatasources??[]){const f=Zt[c];f&&d.add(f)}d.size===0&&(d.add("actions"),d.add("docker"),d.add("gitlab"));const l=[...a.matchPackageNames??[],...a.matchDepNames??[],...a.matchPackagePatterns??[]];for(const c of d)pe(n[c],l)}return}},en=e=>{const n={actions:new Set,docker:new Set,gitlab:new Set};return Jt(e,n),Qt(e,n),n},me=(e,n,t)=>{const s=t[n];if(s.size===0)return!1;if(s.has(e))return!0;for(const r of s)if(/[*?[\]/.+]/.test(r))try{const o=r.replaceAll(/[.+^${}()|]/g,String.raw`\$&`).replaceAll("*",".*").replaceAll("?",".");if(new RegExp(`^${o}$`).test(e))return!0}catch{}return!1},H=e=>{const n=e.trim();if(n==="")return;const t=n.startsWith("v")||n.startsWith("V")?n.slice(1):n,s=(ee.valid(t)?ee.parse(t):void 0)??ee.coerce(t,{includePrerelease:!0});if(s)return{major:s.major,minor:s.minor,normalized:`${String(s.major)}.${String(s.minor)}.${String(s.patch)}${s.prerelease.length>0?`-${s.prerelease.join(".")}`:""}`,patch:s.patch,prerelease:s.prerelease.length>0,raw:n}},tn=(e,n)=>ee.rcompare(e.normalized,n.normalized),he=(e,n,t,s)=>{if(!n&&t!=="latest")return;const r=e.filter(o=>o.prerelease?!1:n?t==="patch"&&(o.major!==n.major||o.minor!==n.minor)||t==="minor"&&o.major!==n.major?!1:ee.gt(o.normalized,n.normalized):!0);if(r.length!==0)return r.toSorted(tn)[0]},$e=(e,n)=>!e||!n?"unknown":n.major!==e.major?"major":n.minor!==e.minor?"minor":n.patch!==e.patch?"patch":"unknown",nn="GitHub Actions",Ae=(e,n)=>`${e}@${n}`,sn=e=>({fixedVersions:e.fixedVersions,id:e.id,severity:e.severity,summary:e.summary}),on=(e,n)=>{if(n.length===0)return n;const t=Mt(e);if(!At(t))return n;const s=new Map;for(const o of n){const i=o.currentVersion??o.currentRef;i&&s.set(Ae(o.name,i),{name:o.name,version:i})}if(s.size===0)return n;const r=new Map;try{for(const[o,i]of s){const a=Pt([i],{ecosystem:nn,workspaceRoot:e}).get(i.name);a&&a.length>0&&r.set(o,a)}}catch{return n}return r.size===0?n:n.map(o=>{const i=o.currentVersion??o.currentRef;if(!i)return o;const a=r.get(Ae(o.name,i));return a?{...o,advisories:a.map(d=>sn(d))}:o})},Ke=e=>{if(!e)return{};const n={};for(const t of e.split(",")){const s=/^\s*<([^>]+)>\s*;\s*(.+)$/.exec(t);if(!s)continue;const r=s[1]??"",o=s[2]??"";switch(/rel\s*=\s*"?([^";\s]+)"?/i.exec(o)?.[1]?.toLowerCase()){case"first":{n.first=r;break}case"last":{n.last=r;break}case"next":{n.next=r;break}case"prev":case"previous":{n.previous=r;break}}}return n};class rn{token;apiBase;fetchImpl;tagsCache=new Map;commitCache=new Map;constructor(n){this.token=n.token??process.env.GITHUB_TOKEN??process.env.GH_TOKEN,this.apiBase=n.apiBase??"https://api.github.com",this.fetchImpl=n.fetch??fetch}async listTags(n,t){const s=`${n}/${t}`,r=this.tagsCache.get(s);if(r)return r;const o=this.fetchTags(n,t);return this.tagsCache.set(s,o),o}async resolveRef(n,t,s){const r=`${n}/${t}@${s}`,o=this.commitCache.get(r);if(o)return o;const i=this.fetchCommit(n,t,s);return this.commitCache.set(r,i),i}buildHeaders(){const n={Accept:"application/vnd.github+json","User-Agent":"vis-update-actions","X-GitHub-Api-Version":"2022-11-28"};return this.token&&(n.Authorization=`Bearer ${this.token}`),n}async fetchTags(n,t){const s=`${this.apiBase}/repos/${encodeURIComponent(n)}/${encodeURIComponent(t)}/tags?per_page=100`,r={parsed:[],tags:[]},o=[];let i=s,a=0;for(;i&&a<5;){const l=i;let c;try{c=await this.fetchImpl(l,{headers:this.buildHeaders()})}catch{return r}if(!c.ok)return r;let f;try{f=await c.json()}catch{return r}if(!Array.isArray(f))return r;for(const g of f){const m=typeof g.name=="string"?g.name:"",h=typeof g.commit?.sha=="string"?g.commit.sha:"";m!==""&&h!==""&&o.push({name:m,sha:h})}i=Ke(c.headers.get("link")).next,a+=1}const d=[];for(const l of o){const c=H(l.name);c&&d.push({...c,sha:l.sha})}return{parsed:d,tags:o}}async fetchCommit(n,t,s){const r=`${this.apiBase}/repos/${encodeURIComponent(n)}/${encodeURIComponent(t)}/commits/${encodeURIComponent(s)}`;try{const o=await this.fetchImpl(r,{headers:this.buildHeaders()});if(!o.ok)return;const i=await o.json();return typeof i.sha!="string"?void 0:{committedAt:i.commit?.committer?.date,sha:i.sha}}catch{return}}}const an=".github/workflows",cn=".github/actions",ln=/^\s*-?\s*uses:\s*(['"]?)([^'"\s#]+)\1(?:\s*#\s*(.+))?\s*$/,un=/^[a-f0-9]{40}$/i,dn=/actions-up-ignore-next-line(?::\s*(.+))?/i,pn=/actions-up-ignore-start/i,fn=/actions-up-ignore-end/i,gn=e=>{const n=e.split("/");if(n.length<2)return;const[t,s,...r]=n;if(!(!t||!s))return{owner:t,repo:s,subpath:r.length>0?r.join("/"):void 0}},mn=(e,n)=>{const t=n.split(/\r?\n/),s=[];let r,o=!1;for(const[i,a]of t.entries()){const d=a??"";if(pn.test(d)&&(o=!0),fn.test(d)){o=!1;continue}const l=d.trim(),c=l===""||l.startsWith("#")?dn.exec(d):void 0;if(c){r=c[1]??"actions-up-ignore-next-line";continue}const f=ln.exec(d);if(!f){r=void 0;continue}const g=f[1]??"",m=g==="'"||g==='"'?g:"",h=f[2]??"",x=f[3]?.trim();if(h.startsWith("./")||h.startsWith("../")||h.startsWith("docker://")){r=void 0;continue}const b=h.lastIndexOf("@");if(b<=0){r=void 0;continue}const w=h.slice(0,b),k=h.slice(b+1),v=gn(w);if(!v){r=void 0;continue}let p=r??(o?"actions-up-ignore-block":void 0);if(x){const $=/^actions-up-ignore(?:-next-line)?(?::\s*(.+))?(?:\s|$)/i.exec(x);$&&(p=p??$[1]??"actions-up-ignore")}r=void 0,s.push({file:e,ignoreReason:p,isSha:un.test(k),line:i+1,original:`${m}${h}${m}`,owner:v.owner,quote:m,ref:k,repo:v.repo,slug:w,subpath:v.subpath,trailingComment:x&&!p?x:void 0})}return s},Se=e=>e.endsWith(".yml")||e.endsWith(".yaml"),hn=(e,n=[])=>{const t=[],s=new Set,r=a=>{if(s.has(a))return;s.add(a);let d;try{d=K(a)}catch{return}const l=mn(a,d);t.push(...l)},o=B(e,an);if(O(o))for(const a of J(o,{includeDirs:!1,includeSymlinks:!1,maxDepth:1}))Se(a.name)&&r(a.path);const i=B(e,cn);if(O(i))for(const a of J(i,{includeDirs:!1,includeSymlinks:!1,maxDepth:3}))(a.name==="action.yml"||a.name==="action.yaml")&&r(a.path);for(const a of["action.yml","action.yaml"]){const d=B(e,a);O(d)&&r(d)}for(const a of n){const d=rt(a)?a:B(e,a);if(O(d))for(const l of J(d,{includeDirs:!1,includeSymlinks:!1}))Se(l.name)&&r(l.path)}return t},$n=40,yn=1440*60*1e3,wn=new Set(["develop","edge","main","master","stable","trunk"]),kn=e=>e.length===$n&&/^[a-f0-9]{40}$/i.test(e)?!1:wn.has(e.toLowerCase())?!0:H(e)===void 0,Ce=(e,n)=>{for(const t of n)try{if(new RegExp(t).test(e))return!0}catch{if(e.includes(t))return!0}return!1},vn=(e,n,t,s)=>{const r=s==="sha"||e.isSha,{quote:o}=e;return r?`${o}${e.slug}@${n}${o} # ${t}`:`${o}${e.slug}@${t}${o}`},bn=async(e,n)=>{const{ignoreRules:t,options:s,references:r,resolverOptions:o}=n,i=[],a=[],d=[];if(r.length===0)return{failed:d,ignored:a,updates:i};const l=new rn({apiBase:o?.apiBase,fetch:o?.fetch,token:s.githubToken??o?.token}),c=new Map;for(const w of r){const k=`${w.owner}/${w.repo}`,v=c.get(k)??[];v.push(w),c.set(k,v)}const f=Math.max(1,s.maxConcurrentRequests),g=[...c.keys()];let m=0;const h=async w=>{const k=c.get(w)??[],[v,p]=w.split("/");if(!v||!p)return;let $;try{$=await l.listTags(v,p)}catch{for(const u of k)d.push({file:u.file,reason:`failed to list tags for ${w}`});return}for(const u of k){const A=u.slug;let y;if(u.ignoreReason?y=u.ignoreReason:Ce(A,s.exclude)?y="matched --exclude":s.include.length>0&&!Ce(A,s.include)?y="not matched by --include":s.respectDependabotConfig&&t&&me(A,"actions",t)&&(y="ignored by dependabot/renovate config"),y){a.push({currentRef:u.ref,currentVersion:u.isSha?u.trailingComment?.replace(/^#\s*/,""):u.ref,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:A,newRef:u.ref,newVersion:void 0,original:u.original,reason:y,replacement:u.original,updateType:"unknown"});continue}if(!s.includeBranches&&!u.isSha&&kn(u.ref)){a.push({currentRef:u.ref,currentVersion:u.ref,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:A,newRef:u.ref,newVersion:void 0,original:u.original,reason:"branch reference (use --include-branches)",replacement:u.original,updateType:"unknown"});continue}const T=u.isSha?u.trailingComment?.replace(/^#\s*/,"").split(/\s+/)[0]??"":u.ref,R=H(T);if(u.isSha&&!R&&s.mode!=="latest"){a.push({currentRef:u.ref,currentVersion:void 0,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:A,newRef:u.ref,newVersion:void 0,original:u.original,reason:`SHA pin has no version-hint comment; cannot apply --target=${s.mode}`,replacement:u.original,updateType:"unknown"});continue}const C=he($.parsed,R,s.mode);if(!C)continue;if(s.minAgeDays!==void 0){const j=await l.resolveRef(v,p,C.sha),L=j?.committedAt?new Date(j.committedAt).getTime():void 0;if(L&&(Date.now()-L)/yn<s.minAgeDays){a.push({currentRef:u.ref,currentVersion:R?.raw,ecosystem:"actions",file:u.file,ignored:!0,line:u.line,name:A,newRef:u.ref,newVersion:C.raw,original:u.original,reason:`release younger than ${String(s.minAgeDays)} days`,replacement:u.original,updateType:"unknown"});continue}}const E=s.style==="sha"||u.isSha?C.sha:C.raw,U=vn(u,C.sha,C.raw,s.style);i.push({currentRef:u.ref,currentVersion:R?.raw??u.trailingComment?.replace(/^#\s*/,""),ecosystem:"actions",file:u.file,line:u.line,name:A,newRef:E,newVersion:C.raw,original:u.original,replacement:U,updateType:$e(R,C),url:`https://github.com/${v}/${p}/releases/tag/${C.raw}`})}},x=[];for(let w=0;w<Math.min(f,g.length);w++)x.push((async()=>{for(;m<g.length;){const k=g[m];m+=1,k!==void 0&&await h(k)}})());await Promise.all(x);const b=on(e,i);return{failed:d,ignored:a,updates:b}},Rn=e=>e.toSorted((n,t)=>n.file!==t.file?n.file<t.file?-1:1:n.line-t.line),xn=e=>{const n=[],t=[];if(e.length===0)return{applied:n,skipped:t};const s=Rn(e),r=new Map;for(const o of s){const i=r.get(o.file)??[];i.push(o),r.set(o.file,i)}for(const[o,i]of r){let a;try{a=K(o)}catch(g){for(const m of i)t.push({reason:`read failed: ${g.message}`,update:m});continue}const d=a.includes(`\r
3
- `)?`\r
4
- `:`
5
- `,l=a.split(/\r?\n/),c=[];for(const g of i){const m=g.line-1,h=l[m];if(h===void 0){t.push({reason:`line ${String(g.line)} out of range`,update:g});continue}const x=h.indexOf(g.original);if(x===-1){t.push({reason:"original token not found on expected line",update:g});continue}const b=h.slice(0,x),w=h.slice(x+g.original.length),k=/#\s*v?\d/.test(g.replacement)&&/^\s*#\s*v?\d[\w.+-]*\s*$/i.test(w)?"":w;l[m]=`${b}${g.replacement}${k}`,c.push(g)}if(c.length===0)continue;const f=l.join(d);try{it(o,f),n.push(...c)}catch(g){for(const m of c)t.push({reason:`write failed: ${g.message}`,update:m})}}return{applied:n,skipped:t}};class An{tokens;fetchImpl;tagCache=new Map;constructor(n={}){this.tokens=n.tokens??{},this.fetchImpl=n.fetch??fetch}async listTags(n,t,s){const r=`${n}/${t}/${s}`,o=this.tagCache.get(r);if(o)return o;const i=n==="docker.io"?this.listDockerHubTags(t,s):this.listV2Tags(n,t,s);return this.tagCache.set(r,i),i}async listDockerHubTags(n,t){const s={parsed:[],raw:[]},r=[],o=new Map;let i=`https://hub.docker.com/v2/repositories/${encodeURIComponent(n)}/${encodeURIComponent(t)}/tags?page_size=100`,a=0;for(;i&&a<5;){try{const d=await this.fetchImpl(i,{headers:{Accept:"application/json"}});if(!d.ok)break;const l=await d.json();if(Array.isArray(l.results)){for(const c of l.results)if(typeof c.name=="string"&&(r.push(c.name),typeof c.last_updated=="string")){const f=Date.parse(c.last_updated);Number.isNaN(f)||o.set(c.name,f)}}i=typeof l.next=="string"?l.next:void 0}catch{break}a+=1}return r.length===0?s:{parsed:r.map(d=>{const l=H(d);if(l)return{...l,lastUpdated:o.get(d)}}).filter(d=>d!==void 0),raw:r}}async listV2Tags(n,t,s){const r={parsed:[],raw:[]},o=t==="library"?s:`${t}/${s}`,i={Accept:"application/json"},a=this.tokens[n]??process.env[`DOCKER_REGISTRY_TOKEN_${n.toUpperCase().replaceAll(/[^A-Z0-9]/g,"_")}`];a&&(i.Authorization=`Bearer ${a}`);const d=`https://${n}`,l=[];let c=`${d}/v2/${o}/tags/list?n=100`,f=i,g=0;const m=()=>{const h=[];for(const x of l){const b=H(x);b&&h.push({...b,lastUpdated:void 0})}return{parsed:h,raw:l}};for(;c&&g<5;){try{let h=await this.fetchImpl(c,{headers:f});if(h.status===401&&f===i){const w=Cn(h.headers.get("www-authenticate"));if(w){const k=await this.fetchBearerToken(w);k&&(f={...i,Authorization:`Bearer ${k}`},h=await this.fetchImpl(c,{headers:f}))}}if(!h.ok)return g===0?r:m();const x=await h.json();if(!Array.isArray(x.tags))return g===0?r:m();for(const w of x.tags)typeof w=="string"&&l.push(w);const b=Ke(h.headers.get("link"));c=b.next?new URL(b.next,d).toString():void 0}catch{return g===0?r:m()}g+=1}return l.length===0?r:m()}async fetchBearerToken(n){const t=new URLSearchParams({scope:n.scope,service:n.service}),s=`${n.realm}?${t.toString()}`;try{const r=await this.fetchImpl(s,{headers:{Accept:"application/json"}});if(!r.ok)return;const o=await r.json();return o.token??o.access_token}catch{return}}}const Sn=e=>{const n=[];let t=0;const{length:s}=e;for(;t<s;){for(;t<s&&/\s/.test(e[t]??"");)t+=1;const r=t;for(;t<s&&e[t]!=="="&&e[t]!==",";)t+=1;const o=e.slice(r,t).trim();if(e[t]!=="="){for(;t<s&&e[t]!==",";)t+=1;t+=1;continue}t+=1;let i="";if(e[t]==='"'){for(t+=1;t<s&&e[t]!=='"';){if(e[t]==="\\"&&t+1<s){i+=e[t+1]??"",t+=2;continue}i+=e[t]??"",t+=1}t+=1}else{for(;t<s&&e[t]!==",";)i+=e[t]??"",t+=1;i=i.trim()}for(o.length>0&&n.push({key:o,value:i});t<s&&(/\s/.test(e[t]??"")||e[t]===",");)t+=1}return n},Cn=e=>{if(!e)return;const n=/^Bearer\s+(.*)$/i.exec(e);if(!n)return;const t=new Map;for(const{key:o,value:i}of Sn(n[1]??""))t.set(o.toLowerCase(),i);const s=t.get("realm"),r=t.get("service");if(s)return{realm:s,scope:t.get("scope")??"",service:r??""}},En="docker.io",Tn="sha256:",oe=e=>{const n=e.trim();if(n===""||n.startsWith("$")||n.includes("${")||n.includes("$("))return;let t=n,s;const r=t.indexOf(`@${Tn}`);r!==-1&&(s=t.slice(r+1),t=t.slice(0,r));let o=En,i=t;const a=t.indexOf("/");if(a>0){const h=t.slice(0,a);(h==="localhost"||h.includes(".")||h.includes(":"))&&(o=h,i=t.slice(a+1))}let d="latest",l=i;const c=i.lastIndexOf(":");c!==-1&&!i.slice(c).includes("/")&&(d=i.slice(c+1),l=i.slice(0,c));let f="library",g=l;const m=l.indexOf("/");if(m!==-1&&(f=l.slice(0,m),g=l.slice(m+1)),g!=="")return{digest:s,name:g,namespace:f,original:n,registry:o,tag:d}},re=/vis-update-ignore-next-line/i,Je=/vis-update-ignore(?:\s|$|:)/i,Ye=e=>{const n=e.trim();return n===""||n.startsWith("#")},jn=/^\s*FROM\s+(?:--\S+\s+)*([^\s#]+)(?:\s[^#]*)?(#.*)?$/i,In=(e,n)=>{const t=n.split(/\r?\n/),s=[];let r=!1;for(const[o,i]of t.entries()){if(re.test(i)&&Ye(i)){r=!0;continue}const a=jn.exec(i);if(!a){i.trim()!==""&&!i.trim().startsWith("#")&&(r=!1);continue}const d=a[1]??"";if(d==="scratch"){r=!1;continue}const l=a[2]?.trim();let c=r?"vis-update-ignore-next-line":void 0;l&&re.test(l)?c=c??"vis-update-ignore-next-line":l&&Je.test(l)&&(c=c??"vis-update-ignore");const f=oe(d);r=!1,f&&s.push({...f,file:e,ignoreReason:c,kind:"dockerfile",line:o+1})}return s},Nn=/^\s*image:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,Dn=(e,n)=>{const t=n.split(/\r?\n/),s=[];let r=!1;for(const[o,i]of t.entries()){if(re.test(i)&&Ye(i)){r=!0;continue}const a=Nn.exec(i);if(!a){i.trim()!==""&&!i.trim().startsWith("#")&&(r=!1);continue}const d=a[2]??"",l=a[3]?.trim();let c=r?"vis-update-ignore-next-line":void 0;l&&re.test(l)?c=c??"vis-update-ignore-next-line":l&&Je.test(l)&&(c=c??"vis-update-ignore");const f=oe(d);r=!1,f&&s.push({...f,file:e,ignoreReason:c,kind:"compose",line:o+1})}return s},Ee=e=>{const n=e.toLowerCase();return n==="dockerfile"||n.startsWith("dockerfile.")?!0:n.endsWith(".dockerfile")},On=e=>{const n=e.toLowerCase();return/^(?:docker-)?compose(?:\..+)?\.ya?ml$/.test(n)},Un=new Set([".cache",".git",".nx",".pnpm-store",".turbo","build","dist","node_modules"]),Vn=/(?:^|\/)(?:\.git|node_modules|\.pnpm-store|\.turbo|\.nx|dist|build|\.cache)(?:\/|$)/,Bn=e=>{const n=[];if(!O(e))return n;const t=new Set,s=(r,o)=>{let i;try{i=St.native(r)}catch{i=r}if(t.has(i))return;t.add(i);let a;try{a=K(r)}catch{return}n.push(...o==="dockerfile"?In(r,a):Dn(r,a))};for(const r of J(e,{includeDirs:!1,includeSymlinks:!1,skip:[Vn]})){const{name:o}=r;Un.has(o)||(Ee(o)?s(r.path,"dockerfile"):On(o)&&s(r.path,"compose"))}for(const r of["Dockerfile","dockerfile","compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"]){const o=B(e,r);O(o)&&s(o,Ee(r)?"dockerfile":"compose")}return n},_n=864e5,Te=(e,n)=>{for(const t of n)try{if(new RegExp(t).test(e))return!0}catch{if(e.includes(t))return!0}return!1},je=e=>{const n=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return e.registry==="docker.io"?n:`${e.registry}/${n}`},Mn=e=>e.digest!==void 0&&e.digest.length>0,Pn=e=>{if(e.registry==="docker.io")return`https://hub.docker.com/${e.namespace==="library"?`_/${e.name}`:`r/${e.namespace}/${e.name}`}/tags`;const n=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return`https://${e.registry}/${n}`},Wn=(e,n)=>{const t=e.namespace==="library"?e.name:`${e.namespace}/${e.name}`;return`${e.registry==="docker.io"?t:`${e.registry}/${t}`}:${n}`},Ze=async(e,n)=>{const{ignoreRules:t,options:s,references:r,registryOptions:o}=n,i=[],a=[],d=[];if(r.length===0)return{failed:d,ignored:a,updates:i};const l=new An({fetch:o?.fetch,tokens:o?.tokens}),c=new Map;for(const b of r){const w=`${b.registry}|${b.namespace}|${b.name}`,k=c.get(w)??[];k.push(b),c.set(w,k)}const f=Math.max(1,s.maxConcurrentRequests),g=[...c.keys()];let m=0;const h=async b=>{const w=c.get(b)??[],k=w[0];if(!k)return;let v;try{v=await l.listTags(k.registry,k.namespace,k.name)}catch{for(const p of w)d.push({file:p.file,reason:`failed to list tags for ${je(p)}`});return}for(const p of w){const $=je(p);let u;if(p.ignoreReason?u=p.ignoreReason:Te($,s.exclude)?u="matched --exclude":s.include.length>0&&!Te($,s.include)?u="not matched by --include":s.respectDependabotConfig&&t&&me($,"docker",t)&&(u="ignored by dependabot/renovate config"),u){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:$,newRef:p.tag,newVersion:void 0,original:p.original,reason:u,replacement:p.original,updateType:"unknown"});continue}if(Mn(p)){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:$,newRef:p.tag,newVersion:void 0,original:p.original,reason:"digest-pinned image (refresh the pin manually to update)",replacement:p.original,updateType:"digest"});continue}const A=H(p.tag);if(!A&&!s.includeBranches){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:$,newRef:p.tag,newVersion:void 0,original:p.original,reason:"non-semver tag (use --include-branches)",replacement:p.original,updateType:"unknown"});continue}if(!A&&s.mode!=="latest"){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:$,newRef:p.tag,newVersion:void 0,original:p.original,reason:`branch ref has no version baseline for --target=${s.mode}`,replacement:p.original,updateType:"unknown"});continue}const y=he(v.parsed,A,s.mode);if(!y)continue;if(s.minAgeDays!==void 0&&y.lastUpdated!==void 0&&(Date.now()-y.lastUpdated)/_n<s.minAgeDays){a.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,ignored:!0,line:p.line,name:$,newRef:y.raw,newVersion:y.raw,original:p.original,reason:`release younger than ${String(s.minAgeDays)} days`,replacement:p.original,updateType:"unknown"});continue}const T=y.raw,R=Wn(p,T);i.push({currentRef:p.tag,currentVersion:p.tag,ecosystem:"docker",file:p.file,line:p.line,name:$,newRef:T,newVersion:T,original:p.original,replacement:R,updateType:$e(A,y),url:Pn(p)})}},x=[];for(let b=0;b<Math.min(f,g.length);b++)x.push((async()=>{for(;m<g.length;){const w=g[m];m+=1,w!==void 0&&await h(w)}})());return await Promise.all(x),{failed:d,ignored:a,updates:i}};class qn{token;tokenHeader;defaultApiBase;fetchImpl;tagCache=new Map;constructor(n){const t=n.token??process.env.GITLAB_TOKEN;t?(this.token=t,this.tokenHeader="PRIVATE-TOKEN"):process.env.CI_JOB_TOKEN?(this.token=process.env.CI_JOB_TOKEN,this.tokenHeader="JOB-TOKEN"):(this.token=void 0,this.tokenHeader="PRIVATE-TOKEN"),this.defaultApiBase=n.apiBase??"https://gitlab.com",this.fetchImpl=n.fetch??fetch}async listTags(n){const t=this.tagCache.get(n);if(t)return t;const s=this.fetchTags(n);return this.tagCache.set(n,s),s}resolveHostAndPath(n){const t=n.indexOf("/");if(t>0){const s=n.slice(0,t);if(s.includes("."))return{host:`https://${s}`,path:n.slice(t+1)}}return{host:this.defaultApiBase,path:n}}async fetchTags(n){const{host:t,path:s}=this.resolveHostAndPath(n),r=encodeURIComponent(s),o=`${t}/api/v4/projects/${r}/repository/tags?per_page=100`,i={Accept:"application/json","User-Agent":"vis-update-gitlab"};this.token&&(i[this.tokenHeader]=this.token);try{const a=await this.fetchImpl(o,{headers:i});if(!a.ok)return{error:`HTTP ${String(a.status)} from ${t}`,parsed:[],tags:[]};const d=await a.json();if(!Array.isArray(d))return{error:`unexpected response shape from ${t}`,parsed:[],tags:[]};const l=d.map(f=>({name:typeof f.name=="string"?f.name:"",sha:typeof f.commit?.id=="string"?f.commit.id:""})).filter(f=>f.name!==""),c=[];for(const f of l){const g=H(f.name);g&&c.push({...g,sha:f.sha})}return{parsed:c,tags:l}}catch(a){return{error:a instanceof Error?a.message:"fetch failed",parsed:[],tags:[]}}}}const Hn=/vis-update-ignore-next-line/i,Q=/vis-update-ignore(?:\s|$|:)/i,Ln=new Set([".gitlab-ci.yaml",".gitlab-ci.yml"]),Fn=e=>Ln.has(e)||e.endsWith(".gitlab-ci.yml")||e.endsWith(".gitlab-ci.yaml"),zn=/^\s*-?\s*project:\s*(['"]?)([^'"\s#]+)\1(?:\s*#.*)?$/,Gn=/^\s*ref:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,Kn=/^\s*-?\s*component:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,Jn=/^\s*image:\s*(['"]?)([^'"\s#]+)\1(\s*#.*)?$/,Yn=/^\s*(?:-\s*)?(?:include:\s*)?\{([^}]*)\}\s*(?:#.*)?$/,Zn=/project:\s*(['"]?)([^'"\s,}]+)\1/,Xn=/ref:\s*(['"]?)([^'"\s,}]+)\1/,Qn=/component:\s*(['"]?)([^'"\s,}]+)\1/,es=/^(\s*-\s*name:\s*)(['"]?)([^'"\s#]+)\2(\s*#.*)?$/,ts=/^(\s*-\s*)(['"]?)([^'"\s#:]+:[^'"\s#]+)\2(\s*#.*)?$/,ns=/^\s*-?\s*[a-z_][\w-]*:\s*(?:#.*)?$/i,ss=(e,n)=>{const t=n.split(/\r?\n/),s=[],r=[];let o,i=!1,a=!1,d=-1;for(const[l,c]of t.entries()){const f=c??"",g=f.trim(),m=g===""||g.startsWith("#");if(Hn.test(f)&&m){i=!0;continue}const h=/^(\s*)services:\s*(?:#.*)?$/.exec(f);if(h){a=!0,d=h[1]?.length??0;continue}a&&g!==""&&!g.startsWith("-")&&!g.startsWith("#")&&f.search(/\S/)<=d&&(a=!1,d=-1);const x=Jn.exec(f);if(x){const p=x[2]??"",$=oe(p);if($){const u=x[3]?.trim();let A=i?"vis-update-ignore-next-line":void 0;u&&Q.test(u)&&(A=A??"vis-update-ignore"),r.push({...$,file:e,ignoreReason:A,kind:"compose",line:l+1})}i=!1;continue}if(a){const p=es.exec(f),$=p?void 0:ts.exec(f),u=p??$;if(u){const A=u[3]??"",y=oe(A);if(y){const T=u[4]?.trim();let R=i?"vis-update-ignore-next-line":void 0;T&&Q.test(T)&&(R=R??"vis-update-ignore"),r.push({...y,file:e,ignoreReason:R,kind:"compose",line:l+1})}}}const b=zn.exec(f);if(b){o={line:l+1,project:b[2]??""};continue}const w=Gn.exec(f);if(w&&o){const p=w[3]?.trim();let $=i?"vis-update-ignore-next-line":void 0;p&&Q.test(p)&&($=$??"vis-update-ignore"),s.push({file:e,ignoreReason:$,kind:"project",line:l+1,original:w[2]??"",project:o.project,ref:w[2]??""}),o=void 0,i=!1;continue}const k=Kn.exec(f);if(k){const p=k[2]??"",$=p.lastIndexOf("@");if($>0){const u=p.slice(0,$),A=p.slice($+1),y=u.lastIndexOf("/"),T=y>0?u.slice(0,y):u,R=y>0?u.slice(y+1):void 0,C=k[3]?.trim();let E=i?"vis-update-ignore-next-line":void 0;C&&Q.test(C)&&(E=E??"vis-update-ignore"),s.push({componentName:R,file:e,ignoreReason:E,kind:"component",line:l+1,original:p,project:T,ref:A})}i=!1;continue}const v=Yn.exec(f);if(v){const p=v[1]??"",$=/#(.*)$/.exec(f)?.[1]?.trim();let u=i?"vis-update-ignore-next-line":void 0;$&&Q.test($)&&(u=u??"vis-update-ignore");const A=Qn.exec(p);if(A){const y=A[2]??"",T=y.lastIndexOf("@");if(T>0){const R=y.slice(0,T),C=y.slice(T+1),E=R.lastIndexOf("/"),U=E>0?R.slice(0,E):R,j=E>0?R.slice(E+1):void 0;s.push({componentName:j,file:e,ignoreReason:u,kind:"component",line:l+1,original:y,project:U,ref:C})}}else{const y=Zn.exec(p),T=Xn.exec(p);y&&T&&s.push({file:e,ignoreReason:u,kind:"project",line:l+1,original:T[2]??"",project:y[2]??"",ref:T[2]??""})}i=!1;continue}g!==""&&!g.startsWith("#")&&!ns.test(f)&&(i=!1)}return{images:r,includes:s}},Ie=/^(?:\.git|node_modules|\.pnpm-store|\.turbo|\.nx|dist|build|\.cache)$/,os=e=>{const n=[],t=[];if(!O(e))return{images:t,includes:n};const s=o=>{let i;try{i=K(o)}catch{return}const{images:a,includes:d}=ss(o,i);n.push(...d),t.push(...a)};for(const o of[".gitlab-ci.yml",".gitlab-ci.yaml"]){const i=B(e,o);O(i)&&s(i)}const r=B(e,".gitlab");if(O(r))for(const o of J(r,{includeDirs:!1,includeSymlinks:!1,skip:[Ie]}))(o.name.endsWith(".yml")||o.name.endsWith(".yaml"))&&s(o.path);for(const o of J(e,{includeDirs:!1,includeSymlinks:!1,maxDepth:2,skip:[Ie]}))Fn(o.name)&&!t.some(i=>i.file===o.path)&&!n.some(i=>i.file===o.path)&&s(o.path);return{images:t,includes:n}},Ne=(e,n)=>{for(const t of n)try{if(new RegExp(t).test(e))return!0}catch{if(e.includes(t))return!0}return!1},rs=(e,n,t)=>{const s=e.indexOf("/");return s>0&&e.slice(0,s).includes(".")?`https://${e.slice(0,s)}/${e.slice(s+1)}/-/releases/${n}`:`${t}/${e}/-/releases/${n}`},is=async(e,n)=>{const{ignoreRules:t,imageReferences:s,includes:r,options:o,registryOptions:i,resolverOptions:a}=n,d=[],l=[],c=[];if(s.length>0){const v=await Ze(e,{ignoreRules:t,options:o,references:s,registryOptions:i});for(const p of v.updates)d.push({...p,ecosystem:"gitlab"});for(const p of v.ignored)l.push({...p,ecosystem:"gitlab"});c.push(...v.failed)}if(r.length===0)return{failed:c,ignored:l,updates:d};const f=new qn({apiBase:a?.apiBase,fetch:a?.fetch,token:o.gitlabToken??a?.token}),g=a?.apiBase??"https://gitlab.com",m=new Map;for(const v of r){const p=m.get(v.project)??[];p.push(v),m.set(v.project,p)}const h=Math.max(1,o.maxConcurrentRequests),x=[...m.keys()];let b=0;const w=async v=>{const p=m.get(v)??[];let $;try{$=await f.listTags(v)}catch{for(const u of p)c.push({file:u.file,reason:`failed to list tags for ${v}`});return}if($.error){for(const u of p)c.push({file:u.file,reason:`failed to list tags for ${v}: ${$.error}`});return}for(const u of p){const A=u.kind==="component"&&u.componentName?`${u.project}/${u.componentName}`:u.project;let y;u.ignoreReason?y=u.ignoreReason:Ne(A,o.exclude)?y="matched --exclude":o.include.length>0&&!Ne(A,o.include)?y="not matched by --include":o.respectDependabotConfig&&t&&me(A,"gitlab",t)&&(y="ignored by dependabot/renovate config");const T=U=>({currentRef:u.ref,currentVersion:u.ref,ecosystem:"gitlab",file:u.file,ignored:!0,line:u.line,name:A,newRef:u.ref,newVersion:void 0,original:u.original,reason:U,replacement:u.original,updateType:"unknown"});if(y){l.push(T(y));continue}const R=H(u.ref);if(!R&&!o.includeBranches){l.push(T("branch reference (use --include-branches)"));continue}if(!R&&o.mode!=="latest"){l.push(T(`branch ref has no version baseline for --target=${o.mode}`));continue}const C=he($.parsed,R,o.mode);if(!C)continue;let E;u.kind==="component"?E=`${u.componentName?`${u.project}/${u.componentName}`:u.project}@${C.raw}`:E=C.raw,d.push({currentRef:u.ref,currentVersion:R?.raw??u.ref,ecosystem:"gitlab",file:u.file,line:u.line,name:A,newRef:C.raw,newVersion:C.raw,original:u.original,replacement:E,updateType:$e(R,C),url:rs(u.project,C.raw,g)})}},k=[];for(let v=0;v<Math.min(h,x.length);v++)k.push((async()=>{for(;b<x.length;){const p=x[b];b+=1,p!==void 0&&await w(p)}})());return await Promise.all(k),{failed:c,ignored:l,updates:d}},as={disabled:new Set,exclude:[],githubToken:void 0,gitlabToken:void 0,include:[],includeBranches:!1,maxConcurrentRequests:8,minAgeDays:void 0,mode:"latest",respectDependabotConfig:!0,style:"sha"},cs=async e=>{const n={...as,...e.options,disabled:e.options?.disabled??new Set},t=n.respectDependabotConfig?en(e.workspaceRoot):void 0,s={actions:{failed:[],ignored:[],updates:[]},docker:{failed:[],ignored:[],updates:[]},gitlab:{failed:[],ignored:[],updates:[]}},r=[];let o=0;if(!n.disabled.has("actions")){const d=hn(e.workspaceRoot);d.length>0&&(o+=1,r.push(bn(e.workspaceRoot,{ignoreRules:t,options:n,references:d}).then(l=>{s.actions=l})))}if(!n.disabled.has("docker")){const d=Bn(e.workspaceRoot);d.length>0&&(o+=1,r.push(Ze(e.workspaceRoot,{ignoreRules:t,options:n,references:d}).then(l=>{s.docker=l})))}if(!n.disabled.has("gitlab")){const{images:d,includes:l}=os(e.workspaceRoot);d.length+l.length>0&&(o+=1,r.push(is(e.workspaceRoot,{ignoreRules:t,imageReferences:d,includes:l,options:n}).then(c=>{s.gitlab=c})))}await Promise.all(r);const i=[...s.actions.updates,...s.docker.updates,...s.gitlab.updates],a=[...s.actions.ignored,...s.docker.ignored,...s.gitlab.ignored];return{failed:[...s.actions.failed,...s.docker.failed,...s.gitlab.failed],ignored:a,perEcosystem:s,scanned:o,updates:i}},ls={actions:"GitHub Actions",docker:"Docker",gitlab:"GitLab CI"},fe=e=>e.updateType==="major",us=e=>{switch(e){case"major":return G;case"minor":return D;case"patch":return Pe;default:return We}},De=e=>{const n=us(e.updateType),t=e.currentVersion??e.currentRef,s=e.newVersion??e.newRef,r=e.url?` ${M(e.url)}`:"",o=e.advisories&&e.advisories.length>0?` ${G(`⚠ ${String(e.advisories.length)} advisor${e.advisories.length===1?"y":"ies"}`)}`:"";return` ${n(e.updateType.padEnd(7))} ${e.name} ${M(t)} → ${s}${o}${r}`},Oe=e=>!e.advisories||e.advisories.length===0?[]:e.advisories.map(n=>` ${n.severity==="CRITICAL"||n.severity==="HIGH"?G(n.severity):D(n.severity)} ${n.id} ${M(n.summary)}`),ds=(e,n)=>{const t=[],s=e.updates.length;if(s===0&&e.scanned===0)return"";if(s===0){if(e.failed.length===0&&e.ignored.length===0)return t.push(`${Pe("✓")} All ecosystem references up to date.`),t.join(`
6
- `);if(t.push(`${D("")} No actionable updates found.`),e.failed.length>0){t.push(`
7
- ${D("Failed lookups:")}`);for(const o of e.failed)t.push(` ${o.file}: ${o.reason}`)}if(n.showIgnored&&e.ignored.length>0){t.push(`
8
- ${M("Ignored:")}`);for(const o of e.ignored)t.push(` ${M(o.name)} ${M(o.reason??"")}`)}return t.join(`
9
- `)}t.push(`
10
- ${We("Ecosystem updates")} — ${String(s)} reference${s===1?"":"s"} can be bumped:`);const r=e.updates.filter(o=>fe(o));if(r.length>0){t.push(`
11
- ${G(ot(`⚠ Breaking changes (${String(r.length)})`))}`),t.push(` ${M("Review release notes before applying — these cross a major-version boundary.")}`);for(const o of r)t.push(De(o)),t.push(...Oe(o))}for(const o of Object.keys(e.perEcosystem)){const i=e.perEcosystem[o];if(i.updates.length!==0){t.push(`
12
- ${ls[o]} (${String(i.updates.length)})`);for(const a of i.updates)t.push(De(a)),t.push(...Oe(a))}}if(n.showIgnored&&e.ignored.length>0){t.push(`
13
- ${M("Ignored:")}`);for(const o of e.ignored)t.push(` ${M(o.name)} ${M(o.reason??"")}`)}if(e.failed.length>0){t.push(`
14
- ${D("Failed lookups:")}`);for(const o of e.failed)t.push(` ${o.file}: ${o.reason}`)}return n.previewOnly&&t.push(`
15
- ${D("ℹ")} ${M("Not applied automatically — re-run with `--interactive` to choose which to apply, or `--yes` to apply all.")}`),t.join(`
16
- `)},ps=e=>JSON.stringify({ecosystems:{failed:e.failed,ignored:e.ignored,perEcosystem:e.perEcosystem,scanned:e.scanned,updates:e.updates}},void 0,2),fs=()=>{const e=Me({input:process.stdin,output:process.stdout});return{ask:n=>new Promise(t=>{e.question(n,s=>{t(s.trim())})}),close:()=>{e.close()},write:n=>{process.stdout.write(`${n}
17
- `)}}},gs=(e,n)=>e.split(",").map(t=>Number.parseInt(t.trim(),10)-1).filter(t=>Number.isInteger(t)&&t>=0&&t<n),ms=async(e,n=fs())=>{if(e.length===0)return n.close(),[];n.write(""),n.write("Outdated ecosystem references:");for(const[s,r]of e.entries()){const o=r.currentVersion??r.currentRef,i=r.newVersion??r.newRef,a=fe(r)?" [BREAKING]":"";n.write(` ${String(s+1)}. [${r.ecosystem}] ${r.name}: ${o} → ${i} (${r.updateType})${a}`)}n.write("");const t=(await n.ask("Apply updates? [a]ll / [s]afe / [n]one / numbers: ")).toLowerCase();if(t==="a"||t==="all")return n.close(),e;if(t==="s"||t==="safe")return n.close(),e.filter(s=>!fe(s));if(t==="n"||t==="none"||t==="")return n.close(),[];if(/^[\d ,]+$/.test(t)){const s=gs(t,e.length);return n.close(),s.map(r=>e[r]).filter(r=>r!==void 0)}return n.close(),[]},Xe=e=>{const n=e.trim();if(n==="")return;const t=/^(\d+(?:\.\d+)?)\s*([mhdw])?$/i.exec(n);if(!t)return;const s=Number.parseFloat(t[1]);if(!(!Number.isFinite(s)||s<0))switch((t[2]??"m").toLowerCase()){case"d":return s*60*24;case"h":return s*60;case"m":return s;case"w":return s*60*24*7;default:return}},hs=e=>{const n=e.trim();return/^\d+(?:\.\d+)?$/.test(n)?Number.parseFloat(n)*1440:Xe(n)},_s=e=>!Number.isFinite(e)||e<=0?"0m":e%1440===0?`${String(e/1440)}d`:e%60===0?`${String(e/60)}h`:`${String(e)}m`,$s=(e,n)=>{try{switch(n){case"bun":{const t=B(e,"bunfig.toml");if(O(t)){const s=ft(t),r=s?.install?.minimumReleaseAge;return{excludes:Array.isArray(s?.install?.minimumReleaseAgeExcludes)?s.install.minimumReleaseAgeExcludes:void 0,minutes:typeof r=="number"?Math.round(r/60):void 0}}break}case"npm":{const t=B(e,".npmrc");if(O(t)){const s=K(t),r=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(s);return{minutes:r?hs(r[1]):void 0}}break}case"pnpm":{const t=B(e,"pnpm-workspace.yaml");if(O(t)){const s=ve(t);return{excludes:Array.isArray(s?.minimumReleaseAgeExclude)?s.minimumReleaseAgeExclude:void 0,minutes:typeof s?.minimumReleaseAge=="number"?s.minimumReleaseAge:void 0}}break}case"yarn":{const t=B(e,".yarnrc.yml");if(O(t)){const s=ve(t)?.npmMinimalAgeGate;if(typeof s=="string")return{minutes:Xe(s)};if(typeof s=="number")return{minutes:s}}break}}}catch{}return{}},ys=(e,n,t)=>{const s=e.latest?"latest":e.target??n.target??"latest";if(!["latest","minor","patch"].includes(s))throw new Error(`Invalid target "${s}". Use: latest, minor, or patch.`);const r=e.maxConcurrentRequests,o=typeof r=="number"&&r>0?r:n.maxConcurrentRequests,i=typeof e.releaseChannel=="string"?e.releaseChannel.toLowerCase():void 0;if(i!==void 0&&!["any","same","stable"].includes(i))throw new Error(`Invalid --release-channel "${String(e.releaseChannel)}". Use: any, same, or stable.`);const a=i??n.releaseChannel;return{exclude:[...P(e.exclude),...P(n.exclude)],ignore:P(n.ignore),include:[...P(e.include),...P(n.include),...t],includeLocked:e.includeLocked||n.includeLocked||!1,includePrerelease:e.prerelease||n.prerelease||!1,maxConcurrentRequests:o,minimumReleaseAge:n.minimumReleaseAge,minimumReleaseAgeExclude:n.minimumReleaseAgeExclude,packageMode:n.packageMode,releaseChannel:a,security:e.security===!1?!1:e.ai||(n.security??!0),target:s}},Ue=(e,n)=>{if(e.length!==0){n.info(`
18
- ${D("⚠")} ${String(e.length)} package${e.length===1?"":"s"} skipped by target constraint (use --target latest to include):`);for(const t of e)n.info(` ${t.packageName} ${t.currentRange} → ${t.newRange} (${t.updateType})`)}},Ve=(e,n,t,s,r)=>{t==="json"?process.stdout.write(`${bt({checkedCount:0,failed:n,filteredByTarget:[],ignored:[],outdated:e})}
19
- `):t==="minimal"?process.stdout.write(`${Rt(e)}
20
- `):(xt(e,s),s.info(He(e,r)))},Be=async(e,n,t,s,r,o,i)=>{const a=vt(e,t,n,!0,{useEditorconfig:i}),d=n==="pnpm"?"pnpm-workspace.yaml":"package.json";if(r.info(`
21
- Updated ${d}`),a&&r.info(`Backup saved to ${a}`),s.changelog){r.info(`
22
- Fetching changelogs...`);const l=await qe(t,void 0,o);for(const c of l){const f=c.releaseUrl??c.repoUrl??c.npmUrl;r.info(` ${c.packageName}: ${f}`)}}if(s.install??!0){const l=n,c=["install"];r.info(`Running ${l} ${c.join(" ")}...
23
- `);try{const{code:f,output:g}=await Le(l,c,{cwd:e,env:process.env});f!==0?r.warn(`${l} ${c.join(" ")} failed. You may need to run it manually.`):s.peer!==!0&&Fe(g)&&r.info(ze)}catch{r.warn(`${l} ${c.join(" ")} failed. You may need to run it manually.`)}}},ge={applied:!1,canceled:!1,jsonEmitted:!1},ws=async(e,n,t,s,r,o)=>{const i=t.update??{},a=[["global","--global is not supported in catalog mode"],["recursive","--recursive is not needed in catalog mode (catalogs are workspace-level)"],["filter","--filter is not supported in catalog mode (use --include/--exclude instead)"],["no-save","--no-save is not supported in catalog mode"],["workspace-root","--workspace-root is not needed in catalog mode"],["no-optional","--no-optional is not supported in catalog mode"]];for(const[S,I]of a)s[S]&&o.warn(`${D("⚠")} ${I}, ignoring.`);const d=ue("minReleaseAge"),{excludes:l,minutes:c}=d?{excludes:void 0,minutes:void 0}:$s(e,n),f=d?void 0:i.minimumReleaseAge??c,g=d?void 0:i.minimumReleaseAgeExclude??l;if(d&&(i.minimumReleaseAge!==void 0||c!==void 0)&&o.info("minimumReleaseAge gate disabled via MARSHALL_DISABLE_MIN_RELEASE_AGE."),!d&&i.minimumReleaseAge!==void 0&&c!==void 0&&i.minimumReleaseAge!==c){const S=n==="pnpm"?"pnpm-workspace.yaml":"bunfig.toml";o.warn(`${D("⚠")} minimumReleaseAge mismatch: vis config = ${String(i.minimumReleaseAge)} min, ${S} = ${String(c)} min. Consider keeping them in sync.`)}const m=gt(e),h=s["include-internal"],x=s.peer,b=mt(e,n,{depFields:i.depFields,dev:s.dev,includeInternal:h,peer:x,prod:s.prod});if(b.size===0)return o.info("No catalogs found."),ge;const w={...i,minimumReleaseAge:f,minimumReleaseAgeExclude:g},k=ys(s,w,r);let v=0;for(const S of b.values())v+=S.size;const p=!!process.stdout.isTTY&&!ie;let $;const u=p?(S,I)=>{$?$.rerender(_.createElement(xe,{current:S,total:I})):(process.stdout.write(`
24
- `),$=be(_.createElement(xe,{current:S,total:I}),{interactive:!0,patchConsole:!1}))}:(S,I)=>{o.info(`Checking ${String(S)}/${String(I)} dependencies...`)};p||o.info(`Checking ${String(v)} catalog dependencies...
25
- `);const A=new Set;ue("socket")&&A.add("socket"),ue("depsDev")&&A.add("deps-dev");const y=t.security?.policies?.score?.minimum,T=ht(t.security,{disabled:A,minimumScore:y}),{checkedCount:R,failed:C,filteredByTarget:E,ignored:U,outdated:j}=await $t(b,k,m,u,e,T,t.security?.acceptedRisks);$&&($.clear(),$.unmount());const L=h?{ignored:[],outdated:[]}:yt(e,{depFields:i.depFields,dev:s.dev,exclude:k.exclude,ignore:k.ignore,include:k.include,packageMode:k.packageMode,peer:x,prod:s.prod,target:k.target});if(L.outdated.length>0){const S=new Set(j.map(I=>`${I.catalogName}|${I.packageName}`));for(const I of L.outdated)S.has(`${I.catalogName}|${I.packageName}`)||j.push(I)}if(L.ignored.length>0)for(const S of L.ignored)U.includes(S)||U.push(S);const ye=R-j.length-C.length;if(C.length>0&&o.warn(`Failed to fetch: ${C.join(", ")}`),U.length>0&&o.info(`Skipped ${String(U.length)} ignored package${U.length===1?"":"s"}: ${U.join(", ")}`),!p&&R>j.length){const S=[...b.values()].reduce((Z,ae)=>Z+ae.size,0),I=S>R?` (${String(S)} catalog entries, ${String(S-R)} duplicates)`:"";o.info(`Checked ${String(R)} unique packages${I}: ${String(j.length)} outdated, ${String(ye)} up-to-date${C.length>0?`, ${String(C.length)} failed`:""}${E.length>0?`, ${String(E.length)} skipped by target`:""}`)}if(j.length===0)return E.length>0?o.info(`All catalog dependencies are up to date within the current target.
26
- ${String(E.length)} package${E.length===1?" has":"s have"} newer versions available with --target latest:
27
- ${E.map(S=>` ${S.packageName} ${S.currentRange} → ${S.newRange} (${S.updateType})`).join(`
28
- `)}`):o.info("All catalog dependencies are up to date."),ge;const F=s.format??i.format??"table";let W;if(s.ai){const S=Ct(s.aiType??"impact");W=await Et(j,o,t.ai,S)}const te=!!s.dryRun;if(!te&&r.length>0&&s.marshallCheck!==!1){const S=await It(r);if(S.length>0){const I=await Nt(S,{config:t?.security?.marshalls,workspaceRoot:e});if(!await Dt(I))return process.exitCode=1,{applied:!1,canceled:!0,jsonEmitted:!1}}}if(p&&F==="table"){const S=new Vt(j,W??null);let I;if(s.changelog){o.info("Fetching changelogs...");const N=await qe(j,void 0,m);I=new Map;for(const V of N){const z=V.releaseUrl??V.repoUrl??V.npmUrl;z&&I.set(V.packageName,z)}}const Z=t.tui?.autoExit??!1,ae=Z===!0?3:typeof Z=="number"?Z:0,we=await be(_.createElement(Bt,{autoExitSeconds:ae,changelogUrls:I,checkedCount:R,filteredOutEntries:E,isDryRun:te,store:S,totalCatalogEntries:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),ce=process.stdout.columns||80;process.stdout.write(`
29
- `);for(const N of j){const V=N.vulnerabilities?.length||N.socketReport&&N.socketReport.alerts.length>0,z=!!N.acceptedRisk,le=V?z?"✓":"⚠":"✓",et=z?"gray":N.updateType==="major"?"red":N.updateType==="minor"?"yellow":"green",se=N.socketReport?.score.overall,tt=se===void 0?"":` [${String(Math.round(se*100))}%]`,ke=se===void 0?void 0:kt(se);process.stdout.write(`${de(_.createElement(q,null," ",_.createElement(q,{color:et},le),` ${N.packageName} ${N.currentRange} → ${N.newRange}`,_.createElement(q,{dimColor:!0},` ${N.updateType}`),ke?_.createElement(q,{color:ke},tt):null),{columns:ce})}
30
- `)}if(process.stdout.write(`
31
- `),o.info(He(j,y)),R>j.length){const N=[...b.values()].reduce((z,le)=>z+le.size,0),V=N>R?` (${String(N)} catalog entries, ${String(N-R)} duplicates)`:"";o.log(),o.info(`Checked ${String(R)} unique packages${V}: ${String(ye)} up-to-date${C.length>0?`, ${String(C.length)} failed`:""}`)}if(E.length>0){process.stdout.write(`
32
- `);const N=`${String(E.length)} package${E.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${de(_.createElement(q,{color:"yellow"},` ${N}`),{columns:ce})}
33
- `);for(const V of E)process.stdout.write(`${de(_.createElement(q,null," ",_.createElement(q,{dimColor:!0},V.packageName),` ${V.currentRange} ${V.newRange}`,_.createElement(q,{dimColor:!0},` ${V.updateType}`)),{columns:ce})}
34
- `)}const ne=Array.isArray(we)?we:[];if(ne.length>0&&!te){o.info(`
35
- Applying ${String(ne.length)} updates...
36
- `);const N={...s,install:s.install??i.install};return await Be(e,n,ne,N,o,m,t.editorconfig??!0),{applied:!0,canceled:!1,jsonEmitted:!1}}return{applied:!1,canceled:ne.length===0,jsonEmitted:!1}}if(te){if(F==="json"){const S={failed:C,filteredByTarget:E,ignored:U,outdated:j};W&&(S.aiAnalysis=W),process.stdout.write(`${JSON.stringify(S,void 0,2)}
37
- `)}else o.info(`Would update ${String(j.length)} dependencies:
38
- `),Ve(j,C,F,o,y),W&&(o.info(""),o.info(Re(W))),Ue(E,o);return{applied:!1,canceled:!1,jsonEmitted:F==="json"}}W&&F!=="json"&&(o.info(Re(W)),o.info(""));let Y=j;if(s.interactive&&(Y=await wt(j),Y.length===0))return o.info("No updates selected."),{applied:!1,canceled:!0,jsonEmitted:!1};o.info(`Updating ${String(Y.length)} catalog dependencies...
39
- `),Ve(Y,[],F,o,y),Ue(E,o);const Qe={...s,install:s.install??i.install};return await Be(e,n,Y,Qe,o,m),{applied:!0,canceled:!1,jsonEmitted:F==="json"}},ks=async(e,n,t,s,r,o)=>{const i={dev:s.dev,filters:P(s.filter),global:s.global,interactive:s.interactive,latest:s.latest||s.target==="latest",noOptional:s.optional===!1,noSave:s.save===!1,packages:r,prod:s.prod,recursive:s.recursive,workspaceRoot:s.workspaceRoot},{command:a,warnings:d}=Gt(n,t,i);for(const c of d)o.warn(c);const l=`${a.bin} ${a.args.join(" ")}`.trim();if(s.dryRun)return o.info(`Would run: ${l}`),ge;o.info(`Running: ${l}`);try{const{code:c,output:f}=await Le(a.bin,a.args,{cwd:e,env:process.env});if(c!==0)return o.error(`
40
- ${G("✖")} Update failed (exit code ${String(c)})`),o.error(` Command: ${l}`),o.error(` Directory: ${e}
41
- `),process.exitCode=c,{applied:!1,canceled:!1,jsonEmitted:!1};s.peer!==!0&&Fe(f)&&o.info(ze)}catch(c){const f=c.status??1;return o.error(`
42
- ${G("✖")} Update failed (exit code ${String(f)})`),o.error(` Command: ${l}`),o.error(` Directory: ${e}
43
- `),process.exitCode=f,{applied:!1,canceled:!1,jsonEmitted:!1}}return{applied:!0,canceled:!1,jsonEmitted:!1}},vs=async(e,n,t)=>{const s=e.latest===!0||e.target==="latest";if(n||!s||e.dryRun===!0||e.yes===!0||e.interactive===!0)return!0;if(!(process.stdout.isTTY&&!ie))return t.error(`${G("✖")} Refusing to run blanket --latest update in a non-interactive context.`),t.error(" Re-run with --yes to confirm, --dry-run to preview, or pass explicit package names."),process.exitCode=1,!1;const r=Me({input:process.stdin,output:process.stdout});try{const o=(await new Promise(i=>{r.question(`${D("⚠")} About to upgrade ALL dependencies to their latest versions. This may include breaking changes.
44
- Continue? [y/N] `,i)})).trim().toLowerCase();return o==="y"||o==="yes"?!0:(t.info("Aborted."),!1)}finally{r.close()}},bs=(e,n)=>{const t=new Set;e.actions===!1&&t.add("actions"),e.docker===!1&&t.add("docker"),e.gitlab===!1&&t.add("gitlab");const s=e.style??"sha";if(s!=="sha"&&s!=="preserve")throw new Error(`Invalid --style "${s}". Use: sha or preserve.`);const r=e.latest===!0?"latest":e.target??"latest";if(r!=="latest"&&r!=="minor"&&r!=="patch")throw new Error(`Invalid target "${r}". Use: latest, minor, or patch.`);const o=r,i=n.update??{};return{disabled:t,exclude:[...P(e.exclude),...P(i.exclude)],githubToken:e.actionsToken??void 0,gitlabToken:e.gitlabToken??void 0,include:P(e.include),includeBranches:e.includeBranches===!0,maxConcurrentRequests:typeof e.maxConcurrentRequests=="number"&&e.maxConcurrentRequests>0?e.maxConcurrentRequests:8,minAgeDays:typeof i.minimumReleaseAge=="number"&&i.minimumReleaseAge>0?i.minimumReleaseAge/1440:void 0,mode:o,respectDependabotConfig:!0,style:s}},Rs=(e,n)=>e.dryRun===!0||process.exitCode!==void 0&&process.exitCode!==0||n.canceled?!1:e.yes===!0?!0:e.interactive===!0&&!!process.stdout.isTTY&&!ie,xs=async(e,n,t,s,r)=>{const o=bs(n,t);if(o.disabled.size===3)return;let i;try{i=await cs({options:o,workspaceRoot:e})}catch(m){s.warn(`${D("⚠")} Ecosystem update scan failed: ${m.message}`);return}if(i.scanned===0)return i;const a=n.format??"table",d=!!n.dryRun,l=Rs(n,r);if(a==="json")r.jsonEmitted?s.warn(`${D("⚠")} ${String(i.updates.length)} ecosystem update${i.updates.length===1?"":"s"} available but not emitted in --format=json (catalog already wrote one JSON document). Rerun with --format=table or --no-catalog to see them.`):process.stdout.write(`${ps(i)}
45
- `);else if(a!=="minimal"){const m=ds(i,{previewOnly:!l&&!d,showIgnored:n.interactive===!0});m&&s.info(m)}if(i.updates.length===0)return i;if(d)return a==="minimal"&&s.info(`
46
- ${D("ℹ")} ${String(i.updates.length)} ecosystem reference${i.updates.length===1?"":"s"} can be bumped — not applied (--dry-run). Re-run without --dry-run and with \`--interactive\` or \`--yes\` to apply.`),i;if(!l)return a==="minimal"&&s.info(`
47
- ${D("ℹ")} ${String(i.updates.length)} ecosystem reference${i.updates.length===1?"":"s"} can be bumped — not applied automatically. Re-run with \`--interactive\` to choose, or \`--yes\` to apply all (or \`--no-actions\` / \`--no-docker\` / \`--no-gitlab\` to silence by ecosystem).`),i;let c=i.updates;if(n.interactive===!0&&process.stdout.isTTY&&!ie&&(c=await ms(i.updates),c.length===0))return s.info(`${D("ℹ")} No ecosystem updates selected.`),i;const{applied:f,skipped:g}=xn(c);if(f.length>0&&s.info(`
48
- ${String(f.length)} ecosystem reference${f.length===1?"":"s"} updated.`),g.length>0){s.warn(`${D("⚠")} ${String(g.length)} ecosystem update${g.length===1?"":"s"} skipped:`);for(const m of g)s.warn(` ${m.update.name} (${m.update.file}:${String(m.update.line)}): ${m.reason}`)}return i},As=e=>{const n=e.style;if(n!==void 0&&n!=="sha"&&n!=="preserve")throw new Error(`Invalid --style "${n}". Use: sha or preserve.`);const t=e.target;if(t!==void 0&&t!=="latest"&&t!=="minor"&&t!=="patch")throw new Error(`Invalid --target "${t}". Use: latest, minor, or patch.`)},Ms=async({argument:e,logger:n,options:t,visConfig:s,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");As(t);let o=e;const i=r,{packageManager:a}=ct(i);if(t.typosquatCheck!==!1){if(o.length>0){const c=o.map(m=>_t(m)),f=s?.security?.typosquatAllowlist,g=await Ot(c.map(m=>m.name),f);if(!g.ok){process.exitCode=1;return}o=c.map((m,h)=>{const x=g.packages[h];return x!==m.name?m.versionSpec?`${x}@${m.versionSpec}`:x??"":o[h]??""})}else if(!await Ut(i,s?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(t.rollback){if(!lt(i,a)){n.info("No backup found. Run 'vis update' first to create a backup.");return}if(ut(i,a))n.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(!await vs(t,o.length>0,n))return;const d=t.catalog!==!1&&dt(i,a);let l;if(d)l=await ws(i,a,s??{},t,o,n);else{const c=jt(i,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),f=c.name==="aube"?"":pt(c.name);l=await ks(i,c.name,f,t,o,n)}o.length===0&&await xs(i,t,s??{},n,l)};export{Ms as default,_s as formatMinutesAsTimeString,hs as parseNpmReleaseAgeValue,Xe as parseTimeStringToMinutes,$s as readPmNativeMinimumReleaseAge,vs as requireBlanketUpdateConfirmation,xs as runEcosystemUpdate,Rs as shouldApplyEcosystem};
1
+ import{createRequire as N}from"node:module";import{f as D,v as O,T as w}from"../packem_shared/index-BDmTbWX1.js";import{b as V}from"./config.js";import{p as e}from"./bin.js";import{w as q}from"../packem_shared/pm-runner-OGResYrA.js";import{W as A}from"../packem_shared/build-scripts-CCCi8U66.js";import{O as F}from"../packem_shared/native-config-sync-BEkJW7g3.js";const R=N(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=l=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(l)}return R(l)},{spawnSync:T}=C("node:child_process"),M=/(defineConfig\s*\(\s*\{)/,W=/(export\s+default\s+\{)/,v=(l,t)=>`${t}${JSON.stringify(l)}: true,`,B=(l,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=V(l);if(!s)return{added:[],skipped:t,status:"no-config"};if(!D(s))return{added:[],skipped:t,status:"no-config"};const i=O(s),h=i.search(/installScripts\s*:\s*\{/);let a=null,r=0;if(h!==-1){const c=i.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(c);d?.index!==void 0&&(a=d,r=h+d.index)}if(a){const c=a[2]??"",d=new Set;for(const g of c.matchAll(/["']([^"']+)["']\s*:/g))d.add(g[1]);for(const g of c.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))d.add(g[1]);const u=[],k=[];for(const g of t)d.has(g)?k.push(g):u.push(g);if(u.length===0)return{added:[],configPath:s,skipped:k,status:"noop"};const x=/\n([ \t]+)\S/.exec(c)?.[1]??" ",_=`
2
+ ${u.map(g=>v(g,x)).join(`
3
+ `)}`,y=c.replace(/\s+$/,""),S=c.slice(y.length),j=`${y}${y.endsWith(",")||y===""?"":","}${_}${S.length>0?S:`
4
+ `}`,P=`${i.slice(0,r)}${a[1]}${j}${a[3]}${i.slice(r+a[0].length)}`;return w(s,P),{added:u,configPath:s,skipped:k,status:"updated"}}const n=/(installScripts\s*:\s*\{)/;if(n.test(i)){const c=`
5
+ allow: {
6
+ ${t.map(u=>v(u," ")).join(`
7
+ `)}
8
+ },`,d=i.replace(n,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const o=/(policies\s*:\s*\{)/;if(o.test(i)){const c=`
9
+ installScripts: {
10
+ allow: {
11
+ ${t.map(u=>v(u," ")).join(`
12
+ `)}
13
+ },
14
+ },`,d=i.replace(o,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const f=/(security\s*:\s*\{)/;if(f.test(i)){const c=`
15
+ policies: {
16
+ installScripts: {
17
+ allow: {
18
+ ${t.map(u=>v(u," ")).join(`
19
+ `)}
20
+ },
21
+ },
22
+ },`,d=i.replace(f,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const p=M.exec(i)??W.exec(i);if(!p)return{added:[],configPath:s,skipped:t,status:"missing-anchor"};const m=`
23
+ security: {
24
+ policies: {
25
+ installScripts: {
26
+ allow: {
27
+ ${t.map(c=>v(c," ")).join(`
28
+ `)}
29
+ },
30
+ },
31
+ },
32
+ },`,b=`${i.slice(0,p.index+p[0].length)}${m}${i.slice(p.index+p[0].length)}`;return w(s,b),{added:t,configPath:s,skipped:[],status:"updated"}},L=async({options:l,visConfig:t,workspaceRoot:s})=>{const i=s??process.cwd(),h=q(i);if(h.name==="pnpm"&&!l.scan){e.info("Delegating to pnpm approve-builds...");const a=["approve-builds"];l.all&&a.push("--all");const r=T("pnpm",a,{cwd:i,stdio:"inherit"});if(r.error)throw new Error(`Failed to run pnpm approve-builds: ${r.error.message}`);if(r.status!==0&&r.status!==null&&(e.error(`pnpm approve-builds exited with code ${r.status}`),process.exitCode=r.status),!l.syncNative){e.notice(""),e.notice("Tip: vis.config.ts security.policies.installScripts.allow may now be out of sync with pnpm-workspace.yaml."),e.notice("Run 'vis check --security-config' to compare, or copy the new entries into vis.config.ts.");return}}else{const a=t?.security?.policies?.installScripts?.allow??{},r=t?.security?.pinVersions===!0,n=A(i,a,{pinVersions:r});if(n.unapproved.length===0)e.success("No unapproved build scripts found."),l.write&&(e.info(""),e.info("Nothing to write — there are no unapproved build scripts."));else{e.warn(`Found ${n.unapproved.length} package${n.unapproved.length===1?"":"s"} with unapproved build scripts:
33
+ `);for(const o of n.unapproved)e.info(` ${o.name} (${o.hooks.join(", ")})`);e.notice(""),e.notice("To approve these packages, add them to vis.config.ts:"),e.notice(""),e.notice(" security: {"),e.notice(" policies: {"),e.notice(" installScripts: {"),e.notice(" allow: {");for(const o of n.unapproved){const f=r&&o.version?`${o.name}@${o.version}`:o.name;e.notice(` "${f}": true,`)}if(e.notice(" },"),e.notice(" },"),e.notice(" },"),e.notice(" },"),h.name==="pnpm"&&(e.notice(""),e.notice("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly.")),l.write){const o=t?.security?.pinVersions===!0,f=n.unapproved.map(m=>o&&m.version?`${m.name}@${m.version}`:m.name),p=B(i,f);switch(e.info(""),p.status){case"missing-anchor":{e.warn(`Could not locate 'defineConfig({' or 'export default {' in ${String(p.configPath)} please add entries manually.`);break}case"no-config":{e.warn("No vis.config.ts found. Run 'vis init' first, then re-run with --write.");break}case"noop":{e.info(`All ${String(f.length)} entr${f.length===1?"y":"ies"} were already present in vis.config.ts security.policies.installScripts.allow.`);break}default:e.success(`Wrote ${String(p.added.length)} entr${p.added.length===1?"y":"ies"} to ${String(p.configPath)}.`),p.skipped.length>0&&e.info(`Skipped ${String(p.skipped.length)} already-present entr${p.skipped.length===1?"y":"ies"}.`)}}}if(n.excess.length>0){e.notice(""),e.warn(`Stale installScripts.allow entries — ${String(n.excess.length)} pattern${n.excess.length===1?"":"s"} no longer match any installed package:`);for(const o of n.excess)e.info(` ${o}`);e.notice("Consider removing these entries from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){e.notice(""),e.warn(`Version drift — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} pinned to an outdated version:`);for(const{from:o,to:f}of n.versionDrift)e.info(` ${o} → ${f}`);e.notice("Rename the keys in vis.config.ts security.policies.installScripts.allow to migrate.")}}if(l.syncNative){const a=t?.security?.policies?.installScripts?.allow??{};if(Object.keys(a).length===0)e.warn("No security.policies.installScripts.allow configured in vis.config.ts. Nothing to sync.");else{const r=F(h.name,i,a);e.info("");for(const n of r)e.success(n)}}};export{L as default};
@@ -1,27 +1,3 @@
1
- import{createRequire as mt}from"node:module";import{y as b,J as at,B as yt,A as it,m as O,f as B,k as kt}from"../packem_shared/index-BDmTbWX1.js";import{$ as vt,a4 as w,a5 as C,g as x,m as Tt,s as St}from"./bin.js";import{o as ot}from"../packem_shared/index-CB4p298r.js";import{x as ct}from"tinyexec";import{o as It}from"../packem_shared/spinner-BXSl864p.js";import{C as dt,D as _,T as lt}from"../packem_shared/symbols-DPTlrJ3B.js";import{s as V,E as $,q as P,V as G,I as Et}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{withEnhancedPath as Mt}from"@visulima/task-runner";const wt=mt(import.meta.url),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,H=t=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[e,s]=A.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return A.getBuiltinModule(t)}return wt(t)},{readFileSync:xt,writeFileSync:bt,unlinkSync:$t}=H("node:fs"),{randomBytes:Ct}=H("node:crypto"),{availableParallelism:z}=H("node:os");class E extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class At extends E{}class v extends E{}class W extends E{}class R extends E{stderr;constructor(e,s,r){super(e,r),this.stderr=s}}class K extends E{}class I extends E{commandTitle;constructor(e,s,r){super(s,r),this.commandTitle=e}}const ut=t=>t.includes("/"),D=(t,e)=>e?t.toLowerCase():t,jt=(t,e,s,r={})=>{const n=ut(t),i=r.caseInsensitive===!0,c=D(t,i),a=[];for(const o of e){const l=n?b(s,o):at(o);ot(c,D(l,i))&&a.push(o)}return a},Rt=(t,e,s,r={})=>{if(!e||e.length===0)return[...t];const n=r.caseInsensitive===!0;return t.filter(i=>{for(const c of e){const a=ut(c)?b(s,i):at(i),o=D(c,n);if(ot(o,D(a,n)))return!1}return!0})},L=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",N=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",Nt=(t,e)=>{const s=b(t,e);return s===""||!s.startsWith("..")&&!it(s)},Ot=(t,e)=>{let s;for(const r of e)Nt(r,t)&&(s===void 0||r.length>s.length)&&(s=r);return s},_t=async t=>{let e=0,s=0;const r=()=>(e+=1,`pattern-${e}`),n=()=>(s+=1,`cmd-${s}`),i=(o,l,h,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],p=new Map;for(const f of h){const g=Ot(f,u)??t.cwd,y=p.get(g)??[];y.push(b(g,f)),p.set(g,y)}for(const f of[...p.keys()].sort()){const g=b(t.cwd,f)||".";d.push({command:o.command,cwd:f,files:p.get(f)??[],id:n(),source:"string",title:`${o.command} — ${g}`})}return}if(o.cwd!==void 0){const u=yt(t.cwd,o.cwd);d.push({command:o.command,cwd:u,files:h,id:n(),source:"string",title:`${o.command} — ${b(t.cwd,u)||"."}`});return}d.push({command:o.command,files:l,id:n(),source:"string",title:o.command})},c=async(o,l,h,d)=>{if(typeof o=="string"){d.push({command:o,files:l,id:n(),source:"string",title:o});return}if(Array.isArray(o)){for(const u of o)await c(u,l,h,d);return}if(N(o)){i(o,l,h,d);return}if(typeof o=="function"){const u=await o([...l]);if(typeof u=="string"){d.push({command:u,files:l,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const p of u)if(typeof p=="string")d.push({command:p,files:l,id:n(),source:"function",title:p});else if(N(p))i(p,l,h,d);else if(L(p))d.push({files:l,id:n(),run:p.task,source:"custom",title:p.title});else throw new v("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(N(u)){i(u,l,h,d);return}if(L(u)){d.push({files:l,id:n(),run:u.task,source:"custom",title:u.title});return}throw new v("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(L(o)){d.push({files:l,id:n(),run:o.task,source:"custom",title:o.title});return}throw new v("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},a=[];for(const[o,l]of Object.entries(t.config)){const h=jt(o,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(h.length===0)continue;const d=t.relative?h.map(p=>b(t.cwd,p)):h,u=[];await c(l,d,h,u),u.length!==0&&a.push({commands:u,files:d,id:r(),pattern:o,title:`${o} — ${h.length} file${h.length===1?"":"s"}`})}return a},Dt=async t=>{if(t.config!==void 0)return t.config;throw new v(`No staged config provided. Add \`staged\` to your vis.config.ts:
2
-
3
- import { defineConfig } from "@visulima/vis/config";
4
-
5
- export default defineConfig({
6
- staged: { "*.ts": "eslint --fix" },
7
- });
8
-
9
- Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},Y=t=>{if(typeof t!="object"||t===null)throw new v("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new v("Staged config is empty — at least one glob pattern is required.");for(const[s,r]of e){if(!s||s.trim()==="")throw new v("Staged config keys must be non-empty glob patterns.");ht(s,r)}return t},ht=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new v(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new v(`Task array for "${t}" is empty.`);for(const s of e)ht(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new v(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(N(e)){if(e.command.trim()==="")throw new v(`Command task for "${t}" has an empty \`command\`.`);return}if(!Ft(e))throw new v(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Ft=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",J=2048,m=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),r=await ct("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!e.lenient){const{stderr:i}=r,c=i.length>J?`${i.slice(0,J)}…`:i;throw new R(`git ${t.join(" ")} failed with exit code ${n}: ${c.trim()}`,i)}return{exitCode:n,stderr:r.stderr,stdout:r.stdout}},M=async(t,e)=>{const{stdout:s}=await m(t,e);return s.trim()},Pt=async t=>{const e=await m(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},Gt=async t=>M(["rev-parse","--absolute-git-dir"],{cwd:t}),ft=async t=>M(["rev-parse","--show-toplevel"],{cwd:t}),Q=async t=>M(["write-tree"],{cwd:t}),Lt=async t=>{const e=await m(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},j={major:2,minor:32},Ht=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),r=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(r)?null:{major:s,minor:r}},qt=async t=>{const e=Ht(await M(["--version"],{cwd:t}));if(e!==null&&(e.major<j.major||e.major===j.major&&e.minor<j.minor))throw new R(`Git ${j.major}.${j.minor} or newer is required; found ${e.major}.${e.minor}.`)},Ut="ACMR",X=500,Bt=async t=>{const{stdout:e}=await m(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(n=>n.length>0),r=[];for(let n=0;n<s.length;n+=1){const i=s[n];if(!i?.startsWith(":"))continue;const c=i.slice(1).split(" "),a=c[3],o=c[4],l=s[n+1];n+=1,o==="A"&&a!==void 0&&/^0+$/.test(a)&&l!==void 0&&r.push(l)}return r},Z=async t=>{const{stdout:e}=await m(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},Vt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},zt=async t=>{const e=t.diffFilter??Ut,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:r}=await m(s,{cwd:t.cwd}),n=r.split("\0").filter(c=>c.length>0);if(n.length===0)return[];const i=t.workTree??await ft(t.cwd);return n.map(c=>it(c)?c:O(i,c))},Wt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let i=0;i<t.length;i+=X){const c=t.slice(i,i+X),{stdout:a}=await m(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});a.length>0&&s.push(a)}if(s.length===0)return null;const r=s.join(""),n=r.endsWith(`
10
- `)?r:`${r}
11
- `;return Buffer.from(n,"utf8")},Kt=async t=>{const{stdout:e}=await m(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),r=[];for(let n=0;n<s.length;n+=1){const i=s[n];if(i===void 0||i.length<4)continue;const c=i.charAt(0),a=i.charAt(1),o=i.slice(3),l=c==="R"||c==="C"||a==="R"||a==="C";c!==" "&&c!=="?"&&a!==" "&&a!=="?"&&r.push(o),l&&(n+=1)}return r},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await m(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await m(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Qt="vis_staged_automatic_backup",pt=()=>`${Qt}-${process.pid}-${Date.now()}-${Ct(3).toString("hex")}`,Xt=async t=>{const e=await M(["stash","create"],{cwd:t});return e.length===0?null:(await m(["stash","store","-m",pt(),e],{cwd:t}),e)},Zt=async t=>{const e=pt(),{exitCode:s,stdout:r}=await m(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const n=r.trim();return n.length>0&&/no local changes/i.test(n)?null:M(["rev-parse","stash@{0}"],{cwd:t})},q=async(t,e)=>{const{exitCode:s,stdout:r}=await m(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const[i,c]=n.split(/\s+/,2);if(i===e&&c!==void 0)return c}return null},tt=async(t,e)=>{if(e===null)return;const s=await q(t,e);s!==null&&await m(["stash","drop","--quiet",s],{cwd:t})},te=async(t,e)=>{if(e===null)throw new W("Backup stash was not found — can't revert working tree.");const s=await q(t,e);if(s===null)throw new W(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await m(["reset","--hard","HEAD"],{cwd:t}),await m(["stash","apply","--index","--quiet",s],{cwd:t})},ee=async(t,e)=>{if(e===null)return;const s=await q(t,e);s!==null&&await m(["stash","pop","--quiet",s],{cwd:t})};class se{stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Pt(this.cwd))throw new R(`Not a git repository: ${this.cwd}`);await qt(this.cwd),this.workTree=await ft(this.cwd),this.gitDir=await Gt(this.cwd),this.stagedFiles=await zt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Kt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await Bt(this.workTree),this.intentToAddPaths.length>0&&await Vt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Xt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await Zt(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await Q(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await Lt(this.workTree),this.preTaskUntracked=new Set(await Z(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(r=>b(this.workTree,r));if(await Jt(s,{cwd:this.workTree}),e){const r=(await Z(this.workTree)).filter(n=>!this.preTaskUntracked.has(n));if(r.length>0){const n=`${r.join("\0")}\0`;await m(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:n})}}if(this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await Q(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const e=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let s;try{await m(e,{cwd:this.workTree,input:this.patch});return}catch(r){s=r instanceof R?r.stderr:String(r)}try{await m([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(r){const n=r instanceof R&&r.stderr?r.stderr:String(r);throw new K(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
12
- First attempt: ${s??"(no stderr)"}
13
- Second attempt: ${n}`,{cause:r})}}async revert(){if(this.backupStashSha!==null){try{await te(this.workTree,this.backupStashSha)}catch(e){throw new K("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await tt(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await ee(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await tt(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(r=>b(this.workTree,r))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(r=>e.has(r)):[];s.length!==0&&(this.patch=await Wt(s,{cwd:this.workTree}),this.patch!==null&&await Yt(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=O(this.gitDir,e);return B(s)?{body:xt(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=O(this.gitDir,e.name);try{e.existed&&e.body!==null?bt(s,e.body):B(s)&&$t(s)}catch{}}}}const re=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},et=t=>{if(t==="running")return w.jsx(It,{type:"dots"});const e=t==="failed"?dt:t==="skipped"?_:t==="success"?lt:_;return w.jsx(x,{color:re(t),children:e})},st=({state:t,tick:e,verbose:s})=>w.jsxs(C,{flexDirection:"column",children:[[...t.patterns.values()].map(r=>w.jsxs(C,{flexDirection:"column",children:[w.jsxs(C,{children:[et(r.status),w.jsxs(x,{children:[" ",r.title]})]}),[...r.commands.values()].map(n=>w.jsxs(C,{flexDirection:"column",marginLeft:2,children:[w.jsxs(C,{children:[et(n.status),w.jsxs(x,{children:[" ",n.title," "]}),n.status!=="pending"&&n.status!=="running"?w.jsxs(x,{color:"gray",children:["(",n.durationMs,"ms)"]}):null]}),s&&n.output?w.jsx(C,{flexDirection:"column",marginLeft:2,children:n.output.split(/\r?\n/).slice(0,20).map((i,c)=>w.jsx(x,{color:"gray",children:i},`${n.id}-line-${c}`))}):null,n.status==="failed"&&n.error?w.jsx(C,{marginLeft:2,children:w.jsx(x,{color:"red",children:n.error.message})}):null]},n.id))]},r.id)),t.infoMessages.map((r,n)=>w.jsx(x,{color:"gray",children:r},`info-${n}`)),t.warnMessages.map((r,n)=>w.jsx(x,{color:"yellow",children:r},`warn-${n}`)),t.errorMessages.map(({message:r},n)=>w.jsx(x,{color:"red",children:r},`err-${n}`))]}),ne=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let r=0;const n=vt(w.jsx(st,{state:s,tick:r,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),i=()=>{r+=1,n.rerender(w.jsx(st,{state:s,tick:r,verbose:e}))};return{commandEnd({commandId:c,durationMs:a,error:o,output:l,patternId:h,status:d}){const u=s.patterns.get(h)?.commands.get(c);u&&(u.status=d,u.durationMs=a,u.output=l,u.error=o,i())},commandStart({commandId:c,patternId:a}){const o=s.patterns.get(a)?.commands.get(c);o&&(o.status="running",i())},error({error:c,message:a}){s.errorMessages.push({error:c,message:a}),i()},info({message:c}){s.infoMessages.push(c),i()},patternEnd({patternId:c,status:a}){const o=s.patterns.get(c);o&&(o.status=a,i())},patternStart({patternId:c}){const a=s.patterns.get(c);a&&(a.status="running",i())},start({patterns:c}){s.started=!0;for(const a of c){const o=new Map;for(const l of a.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(a.id,{commands:o,id:a.id,status:"pending",title:a.title})}i()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),i()}}},rt=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,r=new Map,n=new Map,i=a=>{e||process.stderr.write(`${a}
14
- `)},c=a=>{switch(a){case"failed":return G(dt);case"running":return P(">");case"skipped":return V(_);case"success":return Et(lt);default:return $(_)}};return{commandEnd({commandId:a,durationMs:o,error:l,output:h,status:d}){const u=n.get(a)??a,p=$(`(${o}ms)`);if(i(` ${c(d)} ${u} ${p}`),d==="failed"&&l&&i($(l.message)),(d==="failed"||s)&&h&&h.trim().length>0)for(const f of h.split(/\r?\n/))i(` ${$(f)}`)},commandStart({commandId:a}){if(!s)return;const o=n.get(a)??a;i(` ${$("…")} ${o}`)},error({error:a,message:o}){e?process.stderr.write(`${G(o)}
15
- `):i(G(o)),a?.stack&&(s||!e)&&process.stderr.write(`${$(a.stack)}
16
- `)},info({message:a}){i($(a))},patternEnd({patternId:a,status:o}){const l=r.get(a)??a;i(`${c(o)} ${l}`)},patternStart({patternId:a}){const o=r.get(a)??a;i(`${P(">")} ${o}`)},start({patterns:a}){if(a.length===0){i($("No staged files matched any pattern."));return}const o=new Set(a.flatMap(l=>l.files)).size;i(`${P(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const l of a){r.set(l.id,l.title);for(const h of l.commands)n.set(h.id,h.title)}},stop(){},warn({message:a}){i(V(a))}}},ae=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return rt({quiet:t.quiet,verbose:t.verbose});try{return ne({verbose:t.verbose})}catch{return rt({quiet:t.quiet,verbose:t.verbose})}},ie=t=>{const e=[];let s="",r=!1,n=!1;for(let i=0;i<t.length;i+=1){const c=t[i];if(c===void 0)break;if(c==="\\"&&!r&&i+1<t.length){const a=t[i+1];if(a!==void 0){n&&a!=='"'&&a!=="\\"&&(s+=c),s+=a,i+=1;continue}}if(c==='"'&&!r){n=!n;continue}if(c==="'"&&!n){r=!r;continue}if(!r&&!n&&/\s/.test(c)){s.length>0&&(e.push(s),s="");continue}s+=c}if(r||n)throw new v(`Unterminated ${r?"single":"double"} quote in command: ${t}`);return s.length>0&&e.push(s),e},gt=process.platform==="win32"?28e3:131072,oe=(t,e,s)=>{const r=[];let n=[],i=e;const c=s<=0?gt:s;for(const a of t){const o=Buffer.byteLength(a)+1;n.length>0&&i+o>c&&(r.push(n),n=[],i=e),n.push(a),i+=o}return n.length>0&&r.push(n),r},ce=async(t,e,s)=>{const r=ie(t);if(r.length===0)throw new I(t,"Empty command for staged task.");const[n,...i]=r;if(n===void 0)throw new I(t,"Empty command for staged task.");const c=Buffer.byteLength(n)+i.reduce((h,d)=>h+Buffer.byteLength(d)+1,0),a=oe(e,c,s.maxArgLength??gt),o=Date.now(),l=[];for(const h of a){if(s.signal?.aborted===!0)throw new I(t,"Task aborted by earlier failure.");const d=ct(n,[...i,...h],{nodeOptions:{cwd:s.cwd,env:de(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),u=await d,p=[u.stdout,u.stderr].filter(g=>g.length>0).join(`
17
- `);p.length>0&&l.push(p);const f=d.process?.signalCode??null;if(d.aborted||f!==null||u.exitCode===void 0){const g=d.aborted?"Task aborted by earlier failure.":f===null?p.trim()||"Task exited without a numeric status code.":`Task killed by signal ${f}.`;throw new I(t,g)}if(u.exitCode!==0)throw new I(t,p.trim()||`Exit code ${u.exitCode} from ${n}`)}return{durationMs:Date.now()-o,output:l.join(`
18
- `)}},de=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const r=t?{...s,...t}:s;return Mt(r,e)},le=async(t,e,s)=>{const r=he(s.concurrent,t.length),n=[],i=new AbortController;let c=!1,a=0;const o=()=>{c||(c=!0,s.continueOnError||i.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=f=>{for(const g of f.commands)e.commandEnd({commandId:g.id,durationMs:0,patternId:f.id,status:"skipped"})},h=async f=>{if(c){l(f),e.patternEnd({patternId:f.id,status:"skipped"});return}e.patternStart({patternId:f.id});let g="success";for(const y of f.commands){if(c){e.commandEnd({commandId:y.id,durationMs:0,patternId:f.id,status:"skipped"}),g=g==="success"?"skipped":g;continue}e.commandStart({commandId:y.id,patternId:f.id});const T=await ue(y,s,i.signal),S=T.status==="failed"&&i.signal.aborted?{...T,status:"skipped"}:T;if(e.commandEnd({commandId:y.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:f.id,status:S.status}),S.status==="failed"){n.push(y.title),g="failed",o();break}if(S.status==="skipped"){g=g==="success"?"skipped":g;break}}e.patternEnd({patternId:f.id,status:g})},d=async()=>{for(;a<t.length;){const f=t[a];a+=1,f&&await h(f)}},u=[];for(let f=0;f<Math.min(r,t.length);f+=1)u.push(d());await Promise.all(u);const p=s.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!p}},ue=async(t,e,s)=>{const r=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-r,status:"success"};if(t.command){const n=await ce(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s});return{durationMs:n.durationMs,output:e.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-r,error:new I(t.title,"Command has no invocation target."),status:"failed"}}catch(n){const i=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:i,output:i instanceof I?i.message:void 0,status:"failed"}}},he=(t,e)=>{if(t===!1)return 1;if(t===!0){const r=Math.max(1,typeof z=="function"?z():4);return Math.min(Math.max(1,e),r)}const s=Math.floor(t);return s>0?s:1},fe=!0,pe=t=>{try{return!kt(t)}catch{return!1}},ge=t=>{try{const e=Tt(t);return e?St(t,e).map(s=>O(t,s)):[]}catch{return[]}},me=async(t={})=>{const e=t.cwd??process.cwd(),s=await ae(t),r=await Dt(t);typeof r!="function"&&Y(r);const n=new se({...t,cwd:e}),i=new AbortController;let c=!1;const a=d=>{if(c){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),process.kill(process.pid,d);return}c=!0,s.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),i.abort()};process.on("SIGINT",a),process.on("SIGTERM",a);let o={failedCommands:[],ranTasks:!1,success:!0},l=!1,h=!1;try{await n.prepare(),l=!0;for(const T of n.warnings)s.warn({message:T});if(n.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=pe(e),u=Rt(n.stagedFiles,t.ignore,e,{caseInsensitive:d});if(u.length===0&&n.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const p=typeof r=="function"?Y(await r([...u])):r,f=await _t({caseInsensitive:d,config:p,cwd:e,files:u,relative:t.relative,workspacePackages:ge(e)});if(s.start({patterns:f}),f.length===0)return s.info({message:"No staged files matched any pattern."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:g,success:y}=await le(f,s,{concurrent:t.concurrent??fe,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:i.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:g,ranTasks:!0,success:y},y){if(t.diff===void 0&&(await n.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&n.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),o={failedCommands:[...g],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new At("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(t.revert===!0)s.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const T=n.recoveryHint();T&&s.warn({message:T})}return await n.restoreUnstagedChanges(),h=o.success,o}catch(d){const u=d instanceof Error?d.message:String(d),p=d instanceof Error?d:new Error(u);if(s.error({error:p,message:u}),d instanceof E)return{failedCommands:o.failedCommands,ranTasks:o.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),l)try{await n.cleanup(h)}catch(d){s.error({error:d,message:"Cleanup failed."})}await s.stop()}},we="VIS_STAGED_CONCURRENT",nt=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},ye=(t,e)=>{const s={};e!==void 0&&(s.config=e);const r=k=>t[k]===void 0?void 0:!!t[k],n=k=>{const F=t[k];return typeof F=="string"&&F.length>0?F:void 0},i=r("allow-empty");i!==void 0&&(s.allowEmpty=i);const c=r("auto-stage");c!==void 0&&(s.autoStage=c);const a=r("continue-on-error");a!==void 0&&(s.continueOnError=a);const o=r("debug");o!==void 0&&(s.debug=o);const l=r("fail-on-changes");l!==void 0&&(s.failOnChanges=l);const h=r("hide-partially-staged");h!==void 0&&(s.hidePartiallyStaged=h);const d=r("hide-unstaged");d!==void 0&&(s.hideUnstaged=d);const u=r("quiet");u!==void 0&&(s.quiet=u);const p=r("relative");p!==void 0&&(s.relative=p);const f=r("revert");f!==void 0&&(s.revert=f);const g=r("stash");g!==void 0&&(s.stash=g);const y=r("verbose");y!==void 0&&(s.verbose=y);const T=n("cwd");T!==void 0&&(s.cwd=T);const S=n("diff");S!==void 0&&(s.diff=S);const U=n("diff-filter");if(U!==void 0&&(s.diffFilter=U),r("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const k=process.env[we];k!==void 0&&(s.concurrent=nt(k.trim()))}else{const{concurrent:k}=t;s.concurrent=nt(typeof k=="string"?k:typeof k=="number"||typeof k=="boolean"?String(k):"")}return s},Ee=async({options:t,visConfig:e})=>{const s=(e??{}).staged;if(!s)throw new Error(`No "staged" config found in vis.config.ts. Add one:
19
-
20
- // vis.config.ts
21
- import { defineConfig } from "@visulima/vis/config";
22
-
23
- export default defineConfig({
24
- staged: { '*': 'vis check --fix' },
25
- });
26
-
27
- Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await me(ye(t,s))).success||(process.exitCode=1)};export{ye as buildRunOptions,Ee as default};
1
+ import{createRequire as B}from"node:module";import{getAffectedProjects as F}from"@visulima/task-runner";import{b as H,O as T}from"./bin.js";const C=B(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return C(e)},{execFile:D}=A("node:child_process"),{promisify:q}=A("node:util"),P=q(D),G=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],N=["[vis deploy]","[nx deploy]"],U=["vis","nx"],J=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],V=/^[\w./~^@{}][\w.\-/~^@{}]*$/,z=(e=process.env)=>{for(const t of J){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},_=e=>{if(!V.test(e))throw new Error(`Invalid git ref: "${e}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`)},L=async(e,t)=>{try{return await P("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},W=async e=>{try{const{stdout:t}=await P("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},O=(e,t,r)=>U.some(c=>e.includes(`[${c} ${t} ${r}]`)),Z=(e,t)=>G.some(r=>e.includes(r))||O(e,"skip",t),K=(e,t)=>N.some(r=>e.includes(r))||O(e,"deploy",t),f=(e,t,r,c)=>({action:"build",message:r,project:e,reason:t,...c}),b=(e,t,r,c)=>({action:"skip",message:r,project:e,reason:t,...c}),Q=e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,X=(e,t)=>e.action==="skip"||t?0:1,E=new Set(["deep","direct","none"]),re=async({argument:e,logger:t,options:r,visConfig:c,workspaceRoot:l})=>{const o=e[0]??"",k=!!r.json,R=!!r.verbose,I=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),p=s=>{R&&!k&&t.info(`❱ ${s}`)},n=s=>{k?process.stdout.write(`${JSON.stringify(s)}
2
+ `):t.info(Q(s)),process.exit(X(s,I))};if(!o)return n(f("","missing-project-argument","Missing project argument. Usage: vis ci ignore <project>"));if(!l)return n(f(o,"workspace-error","Could not determine workspace root — building defensively"));const m=await W(l),$=m.trim().split(`
3
+ `)[0]??"";if(p(`commit: ${$}`),m&&K(m,o))return n(f(o,"commit-force-deploy",`Force-deploy keyword in commit: "${$}"`));if(m&&Z(m,o))return n(b(o,"commit-skip",`Skip keyword in commit: "${$}"`));let h,v;try{({packageJsons:v,workspace:h}=H(l,c))}catch(s){const a=s instanceof Error?s.message:String(s);return n(f(o,"workspace-error",`Workspace discovery failed (${a}) — building defensively`))}if(!Object.hasOwn(h.projects,o))return n(f(o,"project-unknown",`Project "${o}" not found in workspace — building defensively`));try{const s=r.base?.trim(),a=z();let i=s||a||"HEAD~1";const u=r.head?.trim()||"HEAD";_(i),_(u),p(`resolved base ref: ${i} (source: ${s?"flag":a?"ci-env":"default"})`);const S=L(l,i),x=T(l,h,v);await S||(p(`base ref ${i} not reachable — falling back to HEAD~1`),i="HEAD~1"),p(`comparing ${i}...${u}`);const w=r.downstream??"deep",y=r.upstream??"none";if(!E.has(w))throw new Error(`Invalid --downstream value: "${w}". Must be "none", "direct", or "deep".`);if(!E.has(y))throw new Error(`Invalid --upstream value: "${y}". Must be "none", "direct", or "deep".`);const M={base:i,downstream:w,head:u,projectGraph:x,projects:h.projects,upstream:y,workspaceRoot:l},d=await F(M);p(`changed files: ${d.changedFiles.length}`),p(`affected projects: ${d.affectedProjects.join(", ")||"(none)"}`);const j={base:i,head:u};return d.changedFiles.length===0?n(b(o,"no-changes",`No files changed between ${i}...${u}`,{...j,affectedProjects:[]})):d.affectedProjects.includes(o)?n(f(o,"project-affected",`Build ${o}: affected by ${d.changedFiles.length} changed file(s)`,{...j,affectedProjects:d.affectedProjects})):n(b(o,"project-not-affected",`Skip ${o}: not affected by changes between ${i}...${u}`,{...j,affectedProjects:d.affectedProjects}))}catch(s){const a=s instanceof Error?s.message:String(s);return t.error(`Affected detection failed: ${a}`),n(f(o,"workspace-error",`Affected detection failed (${a}) — building defensively`))}};export{re as default};
@@ -1,3 +1,8 @@
1
- import{createRequire as Be}from"node:module";import{t as p,ae as U,a4 as e,a5 as s,g as r,aF as Ce,aE as ze,aG as Ge,aD as _e,aH as $e,aI as Ue,$ as We,k as Xe,j as Ve}from"./bin.js";import{w as Je}from"../packem_shared/pm-runner-pVihAfxV.js";import{e as qe,m as le,f as Ye,v as Ke,H as Qe,a as Ze}from"../packem_shared/index-BDmTbWX1.js";import{F as et,a as tt}from"../packem_shared/tabs-BqUepRaD.js";const Ne=Be(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Re=i=>{if(typeof Y<"u"&&Y.versions&&Y.versions.node){const[t,n]=Y.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Y.getBuiltinModule(i)}return Ne(i)},{writeFileSync:He}=Re("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(qe,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),W=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],ot=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Ye(t))return null;const n=Ke(t),c=rt(n),l=c!==n;let o;try{o=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:o,hadComments:l}},nt=(i,t,n)=>{const c=n?Qe(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");Ze(c),He(l,`${JSON.stringify(t,null,2)}
2
- `,"utf8")},it={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],deno:[{source:"${localWorkspaceFolderBasename}-deno-cache",target:"/home/node/.cache/deno",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},st=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],pe=(i,t,n)=>{const c=[],l=new Set(n.map(a=>typeof a=="string"?a:a.target));if(i)for(const a of it[i])l.has(a.target)||c.push(a);const o=Object.keys(t);for(const{featureMatch:a,mounts:m}of st)if(o.some(g=>g.includes(a)))for(const g of m)l.has(g.target)||c.push(g);return c},N=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],K=i=>structuredClone(i);class ct{#o=new Set;#e;constructor(t,n,c=null){const l=t===null,o=t??{name:""},a=K(o);this.#e={config:a,detectedPm:c,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:n,isDirty:!1,mode:l?"create":"edit",originalConfig:l?null:K(o),section:"general",showTemplateSelector:l,suggestedMounts:pe(c,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#o.add(t),()=>{this.#o.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const t=(N.indexOf(this.#e.section)+1)%N.length;this.setSection(N[t])}previousSection(){const t=(N.indexOf(this.#e.section)-1+N.length)%N.length;this.setSection(N[t])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const n=Math.max(0,Math.min(t,W.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=W.find(c=>c.id===t);n&&this.#t(this.#r({...this.#e,config:K(n.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const n={...this.#e.config.features};n[t]===void 0?n[t]={}:delete n[t],this.#t(this.#r({...this.#e,config:{...this.#e.config,features:n},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const n=this.#e.config.forwardPorts??[];if(n.includes(t))return;const c=[...n,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:c},isDirty:!0})}removePort(t){const n=[...this.#e.config.forwardPorts??[]];n.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:n.length>0?n:void 0},isDirty:!0})}toggleExtension(t){const n={...this.#e.config.customizations},c={...n.vscode},l=[...c.extensions??[]],o=l.indexOf(t);o===-1?l.push(t):l.splice(o,1),c.extensions=l.length>0?l:void 0,n.vscode=c.extensions||c.settings?c:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:n.vscode||n.jetbrains?n:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,n,c){const l=t==="container"?"containerEnv":"remoteEnv",o={...this.#e.config[l],[n]:c};this.#t({...this.#e,config:{...this.#e.config,[l]:o},isDirty:!0})}removeEnvVar(t,n){const c=t==="container"?"containerEnv":"remoteEnv",l={...this.#e.config[c]};delete l[n],this.#t({...this.#e,config:{...this.#e.config,[c]:Object.keys(l).length>0?l:void 0},isDirty:!0})}addMount(t){const n=[...this.#e.config.mounts??[],t];this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:n},isDirty:!0}))}removeMount(t){const n=[...this.#e.config.mounts??[]];n.splice(t,1),this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:n.length>0?n:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#r({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,n){this.#t({...this.#e,config:{...this.#e.config,[t]:n||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:K(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=K(this.#e.config);for(const[n,c]of Object.entries(t))(c===""||c===void 0)&&delete t[n];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#r(t){return{...t,suggestedMounts:pe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const n of this.#o)try{n()}catch{}}}const xe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],je=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],de=i=>{if(!i)return je;const t=i.toLowerCase();return je.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},ue=i=>{if(!i)return xe;const t=i.toLowerCase();return xe.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},lt=/^[a-z]$/i,at=i=>{const t=i.codePointAt(0);return t!==void 0&&(t<32||t===127)},dt=(i,t)=>i.length===0||at(i)?!1:t.ctrl&&t.meta?!lt.test(i):!(t.ctrl||t.meta),ut=/\S+\s*$/,se=(i,t)=>i.length===0||!t?void 0:t.find(n=>n.startsWith(i))?.slice(i.length)??void 0,Se=-1,ht=(i,t,n,c)=>t.leftArrow?Math.max(0,n-1):t.home||t.ctrl&&i==="a"?0:t.end||t.ctrl&&i==="e"?c:Se,mt=(i,t,n,c)=>{if(t.backspace&&c>0)return[n.slice(0,c-1)+n.slice(c),c-1];if(t.delete&&c<n.length)return[n.slice(0,c)+n.slice(c+1),c];if(t.ctrl&&i==="u")return[n.slice(c),0];if(t.ctrl&&i==="k")return[n.slice(0,c),c];if(t.ctrl&&i==="w"){const l=n.slice(0,c).replace(ut,"");return[l+n.slice(c),l.length]}};function he({defaultValue:i="",isDisabled:t=!1,mask:n=!1,onChange:c,onSubmit:l,placeholder:o,suggestions:a}){const[m,g]=p.useState(i),[f,j]=p.useState(i.length),x=p.useRef(m);x.current=m;const v=p.useRef(f);v.current=f;const b=p.useRef(c);b.current=c;const S=p.useRef(l);S.current=l;const D=se(m,a),R=p.useCallback((T,I)=>{const{current:E}=v,k=x.current;if(I.return){const w=se(k,a),C=w?k+w:k;w&&(g(C),j(C.length),b.current?.(C)),S.current?.(C);return}if(I.escape)return;if(I.rightArrow){const w=se(k,a);if(E===k.length&&w){const C=k+w;g(C),j(C.length),b.current?.(C);return}j(Math.min(k.length,E+1));return}const P=ht(T,I,E,k.length);if(P!==Se){j(P);return}const H=mt(T,I,k,E);if(H){const[w,C]=H;g(w),j(C),b.current?.(w);return}if(dt(T,I)){const w=k.slice(0,E)+T+k.slice(E);g(w),j(E+T.length),b.current?.(w)}},[a]);U(R,{isActive:!t});const L=n?"*".repeat(m.length):m,X=L.slice(0,f),V=L[f],Q=L.slice(f+1);return t?e.jsx(s,{children:e.jsx(r,{dimColor:!0,children:L||o||""})}):m.length===0&&o?e.jsxs(s,{children:[e.jsx(r,{dimColor:!0,inverse:!0,children:o[0]}),e.jsx(r,{dimColor:!0,children:o.slice(1)})]}):e.jsxs(s,{children:[e.jsxs(r,{children:[X,e.jsx(r,{inverse:!0,children:V??" "}),Q]}),D?e.jsx(r,{dimColor:!0,children:D}):void 0]})}const Ee=["dockerComposeFile","service"],gt={dockerComposeFile:"Compose File",service:"Service"},ve={dockerComposeFile:"docker-compose.yml",service:"app"},ft={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},pt=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>{const l=!!i.dockerComposeFile,o=!!(i.image||i.build);return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),o&&l&&e.jsx(s,{marginBottom:1,children:e.jsx(r,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ee.map((a,m)=>{const g=m===n,f=i[a]??"",j=Array.isArray(i[a])?i[a].join(", "):f;return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:g,color:g?"cyan":"white",children:[g?"❯ ":" ",gt[a],":"]})}),e.jsx(s,{flexGrow:1,children:g&&t?e.jsx(he,{defaultValue:j,onChange:x=>{c({[a]:x||void 0})},placeholder:ve[a]}):e.jsx(r,{color:j?"white":"gray",children:j||ve[a]})})]}),e.jsx(s,{paddingLeft:4,children:e.jsx(r,{dimColor:!0,children:ft[a]})})]},a)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},xt=Ee.length,jt=({config:i,fieldIndex:t})=>{const n=i.containerEnv??{},c=i.remoteEnv??{},l=Object.keys(n),o=Object.keys(c),a=l.length,m=l.length+1,g=m+o.length,f=t<=a,j=t>a;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{borderColor:f?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:l.length>0?1:0,children:[e.jsx(r,{bold:!0,color:f?"cyan":"white",children:"containerEnv"}),e.jsx(r,{dimColor:!0,children:" — baked into the container image"})]}),l.map((x,v)=>{const b=v===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(r,{bold:!0,children:x}),e.jsx(r,{dimColor:!0,children:" = "}),e.jsx(r,{children:n[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:l.length>0?1:0,children:e.jsxs(r,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(s,{borderColor:j?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:o.length>0?1:0,children:[e.jsx(r,{bold:!0,color:j?"cyan":"white",children:"remoteEnv"}),e.jsx(r,{dimColor:!0,children:" — set at runtime by the IDE"})]}),o.map((x,v)=>{const b=m+v===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(r,{bold:!0,children:x}),e.jsx(r,{dimColor:!0,children:" = "}),e.jsx(r,{children:c[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:o.length>0?1:0,children:e.jsxs(r,{color:t===g?"cyan":"gray",inverse:t===g,children:[" ","+ Add variable..."]})})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsxs(r,{dimColor:!0,wrap:"truncate",children:[e.jsx(r,{bold:!0,color:"white",children:"a"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(r,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},vt=i=>{const t=Object.keys(i.containerEnv??{}).length,n=Object.keys(i.remoteEnv??{}).length;return t+1+n+1},yt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const o=p.useMemo(()=>new Set(i.customizations?.vscode?.extensions),[i.customizations?.vscode?.extensions]),a=p.useMemo(()=>ue(c),[c]),m=a.length,g=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),c&&e.jsxs(r,{dimColor:!0,children:["— filter:"," ",e.jsx(r,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((f,j)=>{const x=j===t,v=o.has(f.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:x?">":" "}),e.jsxs(r,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(r,{dimColor:!0,children:[" ","-",f.id]})]})})]},f.id)})})}),g&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(r,{dimColor:!0,children:"No extensions match the search."})})]})},bt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const o=p.useMemo(()=>new Set(Object.keys(i.features??{})),[i.features]),a=p.useMemo(()=>de(c),[c]),m=a.length,g=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),c&&e.jsxs(r,{dimColor:!0,children:["— filter:"," ",e.jsx(r,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((f,j)=>{const x=j===t,v=o.has(f.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:x?">":" "}),e.jsxs(r,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(r,{dimColor:!0,children:[" ","-",f.description]})]})})]},f.id)})})}),g&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(r,{dimColor:!0,children:"No features match the search."})})]})},ae=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],wt={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},ye={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},te=["privileged","overrideCommand"],kt={overrideCommand:"Override Command",privileged:"Privileged"},Ct=ae.length+te.length,St=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"General Configuration"})}),ae.map((l,o)=>{const a=o===n,m=i[l]??"";return e.jsxs(s,{marginBottom:1,children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",wt[l],":"]})}),e.jsx(s,{flexGrow:1,children:a&&t?e.jsx(he,{defaultValue:m,onChange:g=>{c({[l]:g})},placeholder:ye[l]}):e.jsx(r,{color:m?"white":"gray",children:m||ye[l]})})]},l)}),te.map((l,o)=>{const a=ae.length+o===n,m=i[l]??!1;return e.jsxs(s,{marginBottom:o<te.length-1?1:0,children:[e.jsx(s,{width:20,children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",kt[l],":"]})}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{color:m?"green":"gray",children:[m?"yes":"no",a&&e.jsx(r,{dimColor:!0,children:" (Space to toggle)"})]})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(r,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Ie=Ct,ce=te,Te=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],Et={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},It={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Tt=({config:i,fieldEditing:t,fieldIndex:n,onSetCommand:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Te.map((l,o)=>{const a=o===n,m=i[l],g=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsx(s,{children:e.jsxs(r,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",Et[l]]})}),e.jsx(s,{paddingLeft:4,children:e.jsx(r,{dimColor:!0,children:It[l]})}),e.jsx(s,{paddingLeft:4,children:a&&t?e.jsx(he,{defaultValue:g,onChange:f=>{c(l,f)},placeholder:"e.g. npm install"}):e.jsx(r,{color:g?"green":"gray",children:g||"(not set)"})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Dt=Te.length,be=i=>typeof i=="string"?i:`[${i.type}] ${i.source} → ${i.target}`,Pt=({addingMount:i,config:t,detectedPm:n,fieldIndex:c,mountPhase:l,mountSource:o,mountTarget:a,mountType:m,suggestedMounts:g})=>{const f=t.mounts??[];return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(r,{bold:!0,color:"cyan",children:[f.length," ","mounts"]}),n&&e.jsxs(r,{dimColor:!0,children:["— detected:"," ",e.jsx(r,{color:"white",children:n})]})]}),g.length>0&&!i&&e.jsxs(s,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(s,{flexShrink:0,children:[e.jsx(r,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(r,{dimColor:!0,children:[" ","— press"," ",e.jsx(r,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),g.map((j,x)=>e.jsx(s,{flexShrink:0,children:e.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" + ",be(j)]})},`suggestion-${String(x)}`))]}),f.length>0&&e.jsx(s,{flexDirection:"column",marginBottom:1,children:f.map((j,x)=>{const v=x===c;return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(r,{children:v?">":" "}),e.jsx(s,{flexGrow:1,children:e.jsxs(r,{bold:v,inverse:v,wrap:"truncate",children:[" ",be(j)]})})]},`mount-${String(x)}`)})}),!i&&e.jsx(s,{flexShrink:0,children:e.jsxs(r,{color:c===f.length?"cyan":"gray",inverse:c===f.length,children:[" ","+ Add mount..."]})}),i&&e.jsxs(s,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(s,{flexShrink:0,marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="source",color:l==="source"?"cyan":"white",children:[l==="source"?"❯ ":" ","Source:"]})}),e.jsx(r,{color:o?"yellow":"gray",children:o||(l==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="target",color:l==="target"?"cyan":"white",children:[l==="target"?"❯ ":" ","Target:"]})}),e.jsx(r,{color:a?"yellow":"gray",children:a||(l==="target"?"_":"/container/path")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(r,{bold:l==="type",color:l==="type"?"cyan":"white",children:[l==="type"?"❯ ":" ","Type:"]})}),l==="type"?e.jsxs(r,{children:[e.jsx(r,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(r,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(r,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(r,{color:"gray",children:m})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsx(r,{dimColor:!0,wrap:"truncate",children:l==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),f.length===0&&!i&&g.length===0&&e.jsx(s,{marginTop:1,children:e.jsx(r,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Ft=({addingPort:i,addPortValue:t,config:n,fieldIndex:c})=>{const l=n.forwardPorts??[],o=c===l.length;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(r,{dimColor:!0,children:[" ","(",l.length," ","ports)"]})]}),l.map((a,m)=>{const g=m===c;return e.jsx(s,{children:e.jsxs(r,{color:g?"cyan":void 0,inverse:g,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(s,{marginTop:l.length>0?1:0,children:e.jsxs(r,{color:o?"cyan":"gray",inverse:o,children:[" ",o&&i?e.jsxs(r,{children:["Enter port:"," ",e.jsx(r,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(s,{marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ",o?"type port number, Enter to confirm":"select"," ",e.jsx(r,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},At=({focused:i,hadComments:t,jsonPreview:n,mode:c,scrollRef:l})=>e.jsxs(s,{borderColor:i?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,paddingX:1,children:[e.jsx(r,{bold:!0,color:i?"cyan":"white",children:"Preview"}),e.jsxs(r,{dimColor:!0,children:[" ","(",c==="create"?"new":"edit",")"]})]}),t&&c==="edit"&&e.jsx(s,{flexShrink:0,paddingX:1,children:e.jsx(r,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(ze,{flexGrow:1,ref:l,scrollbar:!0,scrollbarColor:"gray",children:n.split(`
3
- `).map((o,a)=>e.jsx(r,{color:"green",children:o},`line-${String(a)}`))})]}),Ot=i=>{const t=[],n=[],c=[];if(!i.image&&!i.build&&!i.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),i.build&&(i.image&&n.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),i.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),i.dockerComposeFile&&!i.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),i.features!==void 0&&(typeof i.features!="object"||Array.isArray(i.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),i.forwardPorts)if(Array.isArray(i.forwardPorts))for(const[l,o]of i.forwardPorts.entries())typeof o=="number"&&(o<1||o>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(o)} at index ${String(l)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return i.customizations?.vscode?.extensions&&!Array.isArray(i.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),i.customizations?.vscode?.settings&&typeof i.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),i.name||c.push({field:"name",message:"Consider adding a name for better identification"}),(!i.features||Object.keys(i.features).length===0)&&c.push({field:"features",message:"Consider adding features for common tools"}),(!i.customizations?.vscode?.extensions||i.customizations.vscode.extensions.length===0)&&c.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),i.privileged&&n.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:c,valid:t.length===0,warnings:n}},we=80,ke=15,Mt=120,De=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Lt=new Map(De.map(i=>[i.id,i.description])),Bt=(i,t,n,c)=>{switch(i){case"compose":return xt;case"environment":return vt(t);case"extensions":return ue(c).length;case"features":return de(n).length;case"general":return Ie;case"lifecycle":return Dt;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Nt=({onSave:i,store:t})=>{const{exit:n}=Ge(),{columns:c,rows:l}=_e(),o=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[g,f]=p.useState(!1),[j,x]=p.useState(!1),[v,b]=p.useState(null),[S,D]=p.useState("editor"),[R,L]=p.useState(0),[X,V]=p.useState(!1),[Q,T]=p.useState(""),[I,E]=p.useState(null),[k,P]=p.useState(""),[H,w]=p.useState(""),[C,z]=p.useState("key"),[re,Z]=p.useState(!1),[oe,G]=p.useState(""),[ne,_]=p.useState(""),[me,J]=p.useState("volume"),[A,$]=p.useState("source"),ie=p.useRef(null),B=p.useRef(null),M=p.useRef(null),ee=p.useRef(!0);p.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,M.current&&clearTimeout(M.current)}),[]);const ge=Bt(o.section,o.config,o.featureSearch,o.extensionSearch),q=Math.max(1,l-9);p.useEffect(()=>{o.section!=="features"&&o.section!=="extensions"||L(u=>o.fieldIndex>=u+q?o.fieldIndex-q+1:o.fieldIndex<u?o.fieldIndex:u)},[o.fieldIndex,o.section,q]),p.useEffect(()=>{L(0)},[o.section,o.featureSearch,o.extensionSearch]);const Pe=p.useCallback(()=>{const u=t.cleanConfig(),h=Ot(u);if(!h.valid){const y=h.errors[0];b(y?`Error: ${y.message}`:"Validation failed"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{ee.current&&b(null)},3e3);return}i(u),t.markClean();const d=h.warnings.length;b(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{ee.current&&b(null)},2e3)},[i,t]);U((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(o.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(o.templateIndex-1);else if(h.return){const d=W[o.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:o.showTemplateSelector}),U((u,h)=>{if(h.escape){V(!1),T("");return}if(h.return){const d=Number.parseInt(Q,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),V(!1),T("");return}if(h.backspace){T(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&T(d=>d+u)},{isActive:X}),U((u,h)=>{if(h.escape){E(null),P(""),w(""),z("key");return}if(h.return){if(C==="key"&&k){z("value");return}if(C==="value"&&k){t.addEnvVar(I,k,H),E(null),P(""),w(""),z("key");return}}if(h.backspace){C==="key"?P(d=>d.slice(0,-1)):w(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="key"?P(d=>d+u):w(d=>d+u))},{isActive:I!==null}),U((u,h)=>{if(h.escape){Z(!1),G(""),_(""),$("source");return}if(h.return){if(A==="source"&&oe){$("target");return}if(A==="target"&&ne){$("type");return}if(A==="type"){t.addMount({source:oe,target:ne,type:me}),Z(!1),G(""),_(""),$("source");return}}if(A==="type"){switch(u){case"1":{J("volume");break}case"2":{J("bind");break}case"3":{J("tmpfs");break}}return}if(h.backspace){A==="source"?G(d=>d.slice(0,-1)):A==="target"&&_(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(A==="source"?G(d=>d+u):A==="target"&&_(d=>d+u))},{isActive:re}),U((u,h)=>{if(u==="c"&&h.ctrl){n();return}if(!g){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?ie.current?.scrollBy(1):h.upArrow||u==="k"?ie.current?.scrollBy(-1):u==="q"&&(m(!1),f(!0));return}if(j){if(h.escape){x(!1),o.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){o.section==="features"?t.setFeatureSearch(o.featureSearch.slice(0,-1)):t.setExtensionSearch(o.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){o.section==="features"?t.setFeatureSearch(o.featureSearch+u):t.setExtensionSearch(o.extensionSearch+u);return}return}if(o.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){o.isDirty?f(!0):n();return}if(u==="s"){Pe();return}if(h.tab){D(d=>d==="editor"?"preview":"editor");return}if(S==="preview"){if(h.downArrow||u==="j"){B.current?.scrollBy(1);return}if(h.upArrow||u==="k"){B.current?.scrollBy(-1);return}if(h.pageDown){B.current?.scrollBy(10);return}if(h.pageUp){B.current?.scrollBy(-10);return}if(h.home){B.current?.scrollToTop();return}if(h.end){B.current?.scrollToBottom();return}h.escape&&D("editor");return}if(h.downArrow||u==="j"){ge>0&&t.setFieldIndex(Math.min(o.fieldIndex+1,ge-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(o.fieldIndex-1,0));return}if(h.return){switch(o.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(o.config.containerEnv??{}).length,y=d,O=d+1+Object.keys(o.config.remoteEnv??{}).length;o.fieldIndex===y?(E("container"),P(""),w(""),z("key")):o.fieldIndex===O&&(E("remote"),P(""),w(""),z("key"));break}case"mounts":{const d=o.config.mounts??[];o.fieldIndex===d.length&&(Z(!0),G(""),_(""),J("volume"),$("source"));break}case"ports":{const d=o.config.forwardPorts??[];o.fieldIndex===d.length&&(V(!0),T(""));break}}return}if(u===" "){switch(o.section){case"extensions":{const d=ue(o.extensionSearch)[o.fieldIndex];d&&t.toggleExtension(d.id);break}case"features":{const d=de(o.featureSearch)[o.fieldIndex];d&&t.toggleFeature(d.id);break}case"general":{const d=Ie-ce.length,y=o.fieldIndex-d;if(y>=0&&y<ce.length){const O=ce[y];t.updateConfig({[O]:!o.config[O]})}break}}return}if(u==="/"){(o.section==="features"||o.section==="extensions")&&x(!0);return}if(u==="A"&&o.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(o.section==="environment"){const d=Object.keys(o.config.containerEnv??{}).length,y=o.fieldIndex<=d?"container":"remote";E(y),P(""),w(""),z("key")}else o.section==="mounts"&&(Z(!0),G(""),_(""),J("volume"),$("source"));return}if(u==="d")switch(o.section){case"environment":{const d=Object.keys(o.config.containerEnv??{}),y=Object.keys(o.config.remoteEnv??{});if(o.fieldIndex<d.length)t.removeEnvVar("container",d[o.fieldIndex]),d.length===1||o.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const O=o.fieldIndex-d.length-1;O>=0&&O<y.length&&(t.removeEnvVar("remote",y[O]),y.length===1||O>=y.length-1&&t.setFieldIndex(o.fieldIndex-1))}break}case"mounts":{const d=o.config.mounts??[];if(o.fieldIndex<d.length){t.removeMount(o.fieldIndex);const y=d.length-1;o.fieldIndex>=y&&y>0&&t.setFieldIndex(y-1)}break}case"ports":{const d=o.config.forwardPorts??[];if(o.fieldIndex<d.length){t.removePort(o.fieldIndex);const y=d.length-1;o.fieldIndex>=y&&y>0&&t.setFieldIndex(y-1)}break}}}},{isActive:!o.showTemplateSelector&&!X&&I===null&&!re});const Fe=p.useMemo(()=>t.getJsonPreview(),[o.config]);if(c<we||l<ke)return e.jsx(s,{alignItems:"center",height:l,justifyContent:"center",width:c,children:e.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",l,"), need"," ",we,"x",ke]})});if(o.showTemplateSelector)return e.jsx(s,{alignItems:"center",flexDirection:"column",height:l,justifyContent:"center",width:c,children:e.jsxs(s,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(s,{justifyContent:"center",marginBottom:1,children:e.jsx(r,{bold:!0,color:"cyan",children:"Select a Template"})}),W.map((u,h)=>{const d=h===o.templateIndex;return e.jsx(s,{children:e.jsxs(r,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(r,{bold:d,children:u.name}),e.jsxs(r,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(s,{justifyContent:"center",marginTop:1,children:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let F;switch(o.section){case"compose":{F=e.jsx(pt,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{F=e.jsxs(s,{flexDirection:"column",children:[e.jsx(jt,{config:o.config,fieldIndex:o.fieldIndex}),I!==null&&e.jsx(s,{marginTop:1,paddingX:1,children:e.jsxs(r,{color:"cyan",children:["Add"," ",I," ","env:"," ",C==="key"?e.jsxs(r,{children:["key=",e.jsx(r,{color:"yellow",children:k||"_"})," ","(Enter to set value)"]}):e.jsxs(r,{children:[k,"=",e.jsx(r,{color:"yellow",children:H||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{F=e.jsx(yt,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:R,searchText:o.extensionSearch,viewportHeight:q});break}case"features":{F=e.jsx(bt,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:R,searchText:o.featureSearch,viewportHeight:q});break}case"general":{F=e.jsx(St,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{F=e.jsx(Tt,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{F=e.jsx(Pt,{addingMount:re,config:o.config,detectedPm:o.detectedPm,fieldIndex:o.fieldIndex,mountPhase:A,mountSource:oe,mountTarget:ne,mountType:me,suggestedMounts:o.suggestedMounts});break}case"ports":{F=e.jsx(Ft,{addingPort:X,addPortValue:Q,config:o.config,fieldIndex:o.fieldIndex});break}default:F=e.jsx(r,{children:"Unknown section"})}const Ae=e.jsxs(s,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(s,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:"QUIT"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:"HELP"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),e.jsx(r,{dimColor:!0,children:"NAV"})]}),(o.section==="features"||o.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:"CHECK"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:"TABS"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:"PANEL"})]}),(o.section==="features"||o.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:"FILTER"})]}),e.jsxs(s,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"s"}),e.jsx(r,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(s,{paddingX:1,children:[v&&e.jsxs(r,{color:v.startsWith("Error")?"red":"green",children:[v," "]}),o.isDirty&&e.jsx(r,{color:"yellow",children:"[modified]"}),!o.isDirty&&!v&&e.jsx(r,{dimColor:!0,children:"[saved]"})]})]}),Oe=e.jsxs($e,{footer:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(r,{bold:!0,color:"white",children:"?"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ie,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(r,{bold:!0,color:"white",children:"j/k"}),e.jsx(r,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Enter"}),e.jsx(r,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Esc"}),e.jsx(r,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"a"}),e.jsx(r,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"d"}),e.jsx(r,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"s"}),e.jsx(r,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:" Quit"})]}),e.jsxs(r,{children:[" ",e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:" Toggle help"})]})]})]}),Me=e.jsx(At,{focused:S==="preview",hadComments:o.hadComments,jsonPreview:Fe,mode:o.mode,scrollRef:B}),fe=c>=Mt,Le=fe?Math.floor(c*.38):0;return e.jsxs(s,{flexDirection:"column",height:l,width:c,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(r,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(r,{wrap:"truncate",children:[o.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(s,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(et,{defaultValue:o.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),D("editor")},showIndex:!1,children:De.map(({id:u,label:h})=>e.jsx(tt,{name:u,children:h},u))})}),e.jsx(s,{flexShrink:0,paddingRight:2,children:e.jsx(r,{dimColor:!0,wrap:"truncate",children:Lt.get(o.section)??""})}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{borderColor:S==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:F}),fe&&e.jsx(s,{flexShrink:0,width:Le,children:Me})]}),Ae,e.jsx(Ue,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Oe]})},Ut=async({logger:i,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const c=n,l=t.template,o=t.output,a=!!process.stdout.isTTY&&!Ve;let m=null;try{m=Je(c).name}catch{}const g=ot(c);let f=g?.config??null;const j=g?.hadComments??!1;if(l&&!g){const S=W.find(D=>D.id===l);if(!S){const D=W.map(R=>R.id).join(", ");throw new Error(`Unknown template "${l}". Valid templates: ${D}`)}f=S.config}if(!a){f?i.info(JSON.stringify(f,null,2)):(i.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),v=new ct(f,j,m);l&&!g&&v.dismissTemplateSelector();let b=null;if(await We(Xe.createElement(Nt,{onSave:S=>{nt(c,S,o),b=S},store:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),b){const S=o??".devcontainer/devcontainer.json";i.info(`DevContainer config saved to ${S}`)}};export{Ut as default};
1
+ import{E as u}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{m as p}from"../packem_shared/index-BDmTbWX1.js";const f={docker:".dockerignore",npm:".npmignore",slug:".slugignore",vercel:".vercelignore"},m=[".git",".gitattributes",".gitignore",".editorconfig",".vscode/",".idea/",".DS_Store","*.md","LICENSE*","LICENCE*","CHANGELOG*","CONTRIBUTING*","AUTHORS*","docs/","doc/","examples/","example/",".github/",".gitlab-ci.yml",".circleci/","appveyor.yml",".eslintrc*","eslint.config.*",".prettierrc*","prettier.config.*","*.log","npm-debug.log*","*.d.ts","*.map","*.flow","tsconfig*.json","__tests__/","__mocks__/","test/","tests/","*.test.*","*.spec.*","coverage/",".nyc_output/"],w={docker:["node_modules",".vis/","Dockerfile*",".dockerignore"],npm:[],slug:["node_modules"],vercel:["node_modules",".vercel/"]},$=e=>{const r=new Set,n=[];for(const t of[...m,...w[e]])r.has(t)||(r.add(t),n.push(t));return n},h=e=>e.trim(),_="# Added by vis ignore",v=(e,r)=>{const n=new Set;for(const o of e.split(/\r?\n/u)){const c=h(o);c!==""&&!c.startsWith("#")&&n.add(c)}const t=[];for(const o of r)n.has(o)||(n.add(o),t.push(o));if(t.length===0)return{added:t,content:e};const s=e.includes(`\r
2
+ `)?`\r
3
+ `:`
4
+ `,d=[_,...t].join(s);if(e.trim()==="")return{added:t,content:`${d}${s}`};const i=e.endsWith(`
5
+ `)?s:`${s}${s}`;return{added:t,content:`${e}${i}${d}${s}`}},E=e=>e==="docker"||e==="npm"||e==="slug"||e==="vercel",k=async(e,r)=>{try{return await e.readFile(r,"utf8")}catch{return""}},N=async({fs:e,logger:r,options:n,process:t,workspaceRoot:s})=>{const d=s??t.cwd,i=n.target??"docker";if(!E(i))throw new Error(`Invalid --target "${i}". Expected one of: docker, vercel, npm, slug.`);const o=f[i],c=p(d,o),g=await k(e,c),{added:a,content:l}=v(g,$(i));if(n.json){process.stdout.write(`${JSON.stringify({added:a,file:o,target:i},null,2)}
6
+ `);return}if(n.write){if(a.length===0){r.info(`${o} is already up to date (no new patterns).`);return}await e.writeFile(c,l),r.info(`Added ${a.length} pattern(s) to ${o}.`);return}process.stdout.write(l.endsWith(`
7
+ `)?l:`${l}
8
+ `),r.info(u(`(${a.length} new pattern(s); re-run with --write to save ${o})`))};export{N as default};