@rakay-technology/kraft 0.7.4

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 (504) hide show
  1. package/README.md +263 -0
  2. package/dist/bare-HL2GUYE2.js +27 -0
  3. package/dist/bowser-HNOTPGJO.js +2825 -0
  4. package/dist/chunk-3CJLKL6E.js +124 -0
  5. package/dist/chunk-3NQQXMDR.js +2098 -0
  6. package/dist/chunk-42WQABXM.js +439 -0
  7. package/dist/chunk-5GPXMTE4.js +25 -0
  8. package/dist/chunk-AJ4QZLZ2.js +1069 -0
  9. package/dist/chunk-AO252K7Z.js +137 -0
  10. package/dist/chunk-BQMFIXHI.js +975 -0
  11. package/dist/chunk-DM3PKWDC.js +2453 -0
  12. package/dist/chunk-DOD2BXHQ.js +1364 -0
  13. package/dist/chunk-DRK3MEDS.js +2870 -0
  14. package/dist/chunk-EW4PHKB2.js +13914 -0
  15. package/dist/chunk-HMJUFZK7.js +340 -0
  16. package/dist/chunk-I2TOOF2A.js +517 -0
  17. package/dist/chunk-I3DPMTSF.js +29 -0
  18. package/dist/chunk-JSCZT76F.js +2588 -0
  19. package/dist/chunk-MNV2QFHW.js +138 -0
  20. package/dist/chunk-MOLPYPVH.js +2529 -0
  21. package/dist/chunk-N4OALTFK.js +295 -0
  22. package/dist/chunk-OFXBNFNL.js +458 -0
  23. package/dist/chunk-ONKEYSMY.js +1388 -0
  24. package/dist/chunk-PDW4L3NV.js +17 -0
  25. package/dist/chunk-PNNXWA2A.js +1947 -0
  26. package/dist/chunk-PNRPKRJU.js +11105 -0
  27. package/dist/chunk-PVOWHIND.js +26781 -0
  28. package/dist/chunk-PXKCZB2I.js +46 -0
  29. package/dist/chunk-PZVKPCKE.js +475 -0
  30. package/dist/chunk-QWHBRY2K.js +4945 -0
  31. package/dist/chunk-RFOBMHQ7.js +338 -0
  32. package/dist/chunk-RHLNVZMS.js +28 -0
  33. package/dist/chunk-RVER2EOO.js +577 -0
  34. package/dist/chunk-S3QBGGVP.js +81 -0
  35. package/dist/chunk-TAML5WMA.js +198 -0
  36. package/dist/chunk-THTEUDBC.js +3188 -0
  37. package/dist/chunk-WYNM7L22.js +329 -0
  38. package/dist/chunk-XGCG4MD5.js +102 -0
  39. package/dist/chunk-XVKUFMIB.js +148 -0
  40. package/dist/chunk-XZYFZ6A5.js +50 -0
  41. package/dist/chunk-Y7PVJUXJ.js +2275 -0
  42. package/dist/chunk-YRSZPVMB.js +306 -0
  43. package/dist/chunk-YZUKHG3S.js +362 -0
  44. package/dist/chunk-ZVFS4LUA.js +116 -0
  45. package/dist/chunk-ZWLDLTJP.js +1417 -0
  46. package/dist/detect-676SNZK4.js +48 -0
  47. package/dist/dist-es-2YRDXMUU.js +73 -0
  48. package/dist/dist-es-CCVZEFRZ.js +91 -0
  49. package/dist/dist-es-EDUSMF6Q.js +488 -0
  50. package/dist/dist-es-IOH6G4GM.js +380 -0
  51. package/dist/dist-es-KWSMDPIP.js +26 -0
  52. package/dist/dist-es-UYDDOVZ3.js +173 -0
  53. package/dist/dist-es-XUOR4NQN.js +321 -0
  54. package/dist/docker-GOT3Q7DJ.js +41 -0
  55. package/dist/docker-edge-executor-VO6JHHW2.js +19 -0
  56. package/dist/edge-import-NFCHIW7G.js +50 -0
  57. package/dist/edge-preflight-QUJ757C6.js +45 -0
  58. package/dist/ensure-container-edge-Q7IZXHGM.js +38 -0
  59. package/dist/event-streams-TR4GAC53.js +46 -0
  60. package/dist/executor-GKXKN52K.js +42 -0
  61. package/dist/host-channel-preflight-Z6HYSPKO.js +48 -0
  62. package/dist/index.d.ts +2 -0
  63. package/dist/index.js +9469 -0
  64. package/dist/loadSso-UGF4JMRK.js +581 -0
  65. package/dist/local-executor-OMMDKXCM.js +13 -0
  66. package/dist/nginx-VITTWZZU.js +42 -0
  67. package/dist/node-bootstrap.js +277 -0
  68. package/dist/node-entry.js +55 -0
  69. package/dist/noop-CLLJHCPL.js +11 -0
  70. package/dist/openresty-lua-6I3Z6PEQ.js +90 -0
  71. package/dist/privilege-UQAI2HV4.js +20 -0
  72. package/dist/server/engine/ChangeLog +2289 -0
  73. package/dist/server/engine/Documentations +5 -0
  74. package/dist/server/engine/LICENSE +674 -0
  75. package/dist/server/engine/README.md +34 -0
  76. package/dist/server/engine/conf/amavisd +150 -0
  77. package/dist/server/engine/conf/clamav +71 -0
  78. package/dist/server/engine/conf/core +632 -0
  79. package/dist/server/engine/conf/dovecot +151 -0
  80. package/dist/server/engine/conf/fail2ban +72 -0
  81. package/dist/server/engine/conf/global +698 -0
  82. package/dist/server/engine/conf/iredapd +52 -0
  83. package/dist/server/engine/conf/logwatch +28 -0
  84. package/dist/server/engine/conf/postfix +97 -0
  85. package/dist/server/engine/conf/postgresql +93 -0
  86. package/dist/server/engine/conf/spamassassin +39 -0
  87. package/dist/server/engine/dialog/config_via_dialog.sh +258 -0
  88. package/dist/server/engine/dialog/optional_components.sh +122 -0
  89. package/dist/server/engine/dialog/pgsql_config.sh +52 -0
  90. package/dist/server/engine/dialog/virtual_domain_config.sh +94 -0
  91. package/dist/server/engine/functions/amavisd.sh +267 -0
  92. package/dist/server/engine/functions/backend.sh +85 -0
  93. package/dist/server/engine/functions/clamav.sh +100 -0
  94. package/dist/server/engine/functions/cleanup.sh +393 -0
  95. package/dist/server/engine/functions/dovecot.sh +583 -0
  96. package/dist/server/engine/functions/fail2ban.sh +209 -0
  97. package/dist/server/engine/functions/iredapd.sh +356 -0
  98. package/dist/server/engine/functions/optional_components.sh +24 -0
  99. package/dist/server/engine/functions/packages.sh +522 -0
  100. package/dist/server/engine/functions/packages_freebsd.sh +179 -0
  101. package/dist/server/engine/functions/postfix.sh +457 -0
  102. package/dist/server/engine/functions/postgresql.sh +239 -0
  103. package/dist/server/engine/functions/spamassassin.sh +49 -0
  104. package/dist/server/engine/functions/system_accounts.sh +128 -0
  105. package/dist/server/engine/iRedMail.sh +144 -0
  106. package/dist/server/engine/pkgs/get_all.sh +338 -0
  107. package/dist/server/engine/pkgs/pkgs.freebsd.sha256 +3 -0
  108. package/dist/server/engine/pkgs/pkgs.openbsd.sha256 +6 -0
  109. package/dist/server/engine/pkgs/pkgs.sha256 +1 -0
  110. package/dist/server/engine/samples/amavisd/amavisd.conf +702 -0
  111. package/dist/server/engine/samples/amavisd/amavisd.mysql +278 -0
  112. package/dist/server/engine/samples/amavisd/amavisd.pgsql +253 -0
  113. package/dist/server/engine/samples/amavisd/amavisd.schema +942 -0
  114. package/dist/server/engine/samples/amavisd/default_spam_policy.sql +46 -0
  115. package/dist/server/engine/samples/dovecot/dovecot-2.4-mariadb.conf +758 -0
  116. package/dist/server/engine/samples/dovecot/dovecot-2.4-openldap.conf +767 -0
  117. package/dist/server/engine/samples/dovecot/dovecot-2.4-pgsql.conf +762 -0
  118. package/dist/server/engine/samples/dovecot/dovecot-last-login.conf +50 -0
  119. package/dist/server/engine/samples/dovecot/dovecot-ldap.conf +21 -0
  120. package/dist/server/engine/samples/dovecot/dovecot-share-folder.conf +22 -0
  121. package/dist/server/engine/samples/dovecot/dovecot-sql.conf +28 -0
  122. package/dist/server/engine/samples/dovecot/dovecot-used-quota.conf +13 -0
  123. package/dist/server/engine/samples/dovecot/dovecot.conf +484 -0
  124. package/dist/server/engine/samples/dovecot/dovecot.sieve +7 -0
  125. package/dist/server/engine/samples/dovecot/dovecot2-quota-warning.sh +38 -0
  126. package/dist/server/engine/samples/dovecot/sql/imap_share_folder.mysql +16 -0
  127. package/dist/server/engine/samples/dovecot/sql/last_login.mysql +12 -0
  128. package/dist/server/engine/samples/dovecot/sql/used_quota.mysql +26 -0
  129. package/dist/server/engine/samples/dovecot/systemd/override.conf +3 -0
  130. package/dist/server/engine/samples/fail2ban/action.d/banned_db.conf +9 -0
  131. package/dist/server/engine/samples/fail2ban/bin/fail2ban_banned_db +268 -0
  132. package/dist/server/engine/samples/fail2ban/fail2ban.local +17 -0
  133. package/dist/server/engine/samples/fail2ban/filter.d/dovecot.iredmail.conf +5 -0
  134. package/dist/server/engine/samples/fail2ban/filter.d/postfix-pregreet.iredmail.conf +16 -0
  135. package/dist/server/engine/samples/fail2ban/filter.d/postfix.iredmail.conf +18 -0
  136. package/dist/server/engine/samples/fail2ban/filter.d/roundcube.iredmail.conf +9 -0
  137. package/dist/server/engine/samples/fail2ban/jail.d/dovecot.local +8 -0
  138. package/dist/server/engine/samples/fail2ban/jail.d/nginx-http-auth.local +8 -0
  139. package/dist/server/engine/samples/fail2ban/jail.d/postfix-pregreet.local +9 -0
  140. package/dist/server/engine/samples/fail2ban/jail.d/postfix.local +8 -0
  141. package/dist/server/engine/samples/fail2ban/jail.d/roundcube.local +9 -0
  142. package/dist/server/engine/samples/fail2ban/jail.d/sogo.local +8 -0
  143. package/dist/server/engine/samples/fail2ban/jail.d/sshd.local +11 -0
  144. package/dist/server/engine/samples/fail2ban/jail.local +6 -0
  145. package/dist/server/engine/samples/fail2ban/openbsd/rc +27 -0
  146. package/dist/server/engine/samples/fail2ban/sql/fail2ban.mysql +49 -0
  147. package/dist/server/engine/samples/fail2ban/sql/fail2ban.pgsql +48 -0
  148. package/dist/server/engine/samples/firewall/firewalld/services/ssh.xml +6 -0
  149. package/dist/server/engine/samples/firewall/firewalld/zones/iredmail.xml +15 -0
  150. package/dist/server/engine/samples/firewall/iptables/ip6tables.init.debian +362 -0
  151. package/dist/server/engine/samples/firewall/iptables/ip6tables.rules +53 -0
  152. package/dist/server/engine/samples/firewall/iptables/iptables.init.debian +363 -0
  153. package/dist/server/engine/samples/firewall/iptables/iptables.rules +54 -0
  154. package/dist/server/engine/samples/firewall/nftables.conf +58 -0
  155. package/dist/server/engine/samples/freebsd/newsyslog.conf.d/dovecot.conf +3 -0
  156. package/dist/server/engine/samples/freebsd/newsyslog.conf.d/iredapd.conf +1 -0
  157. package/dist/server/engine/samples/freebsd/newsyslog.conf.d/mlmmjadmin.conf +1 -0
  158. package/dist/server/engine/samples/freebsd/newsyslog.conf.d/php-fpm.conf +2 -0
  159. package/dist/server/engine/samples/freebsd/newsyslog.conf.d/slapd.conf +1 -0
  160. package/dist/server/engine/samples/freebsd/syslog.d/dovecot.conf +2 -0
  161. package/dist/server/engine/samples/freebsd/syslog.d/fail2ban.conf +2 -0
  162. package/dist/server/engine/samples/freebsd/syslog.d/iredapd.conf +2 -0
  163. package/dist/server/engine/samples/freebsd/syslog.d/mlmmjadmin.conf +2 -0
  164. package/dist/server/engine/samples/freebsd/syslog.d/php-fpm.conf +2 -0
  165. package/dist/server/engine/samples/freebsd/syslog.d/slapd.conf +2 -0
  166. package/dist/server/engine/samples/iredmail/iredmail.mysql +491 -0
  167. package/dist/server/engine/samples/iredmail/iredmail.pgsql +465 -0
  168. package/dist/server/engine/samples/iredmail/iredmail.schema +456 -0
  169. package/dist/server/engine/samples/iredmail/used_quota_triggers_dovecot_2.3.pgsql +40 -0
  170. package/dist/server/engine/samples/iredmail/used_quota_triggers_dovecot_2.4.pgsql +18 -0
  171. package/dist/server/engine/samples/logrotate/dovecot +13 -0
  172. package/dist/server/engine/samples/logrotate/iredapd +13 -0
  173. package/dist/server/engine/samples/logrotate/mlmmjadmin +13 -0
  174. package/dist/server/engine/samples/logrotate/openldap +19 -0
  175. package/dist/server/engine/samples/logrotate/php-fpm +13 -0
  176. package/dist/server/engine/samples/openbsd/ldapd.conf +58 -0
  177. package/dist/server/engine/samples/openbsd/pf.conf +28 -0
  178. package/dist/server/engine/samples/postfix/command_filter.pcre +3 -0
  179. package/dist/server/engine/samples/postfix/freebsd/mailer.conf +9 -0
  180. package/dist/server/engine/samples/postfix/helo_access.pcre +180 -0
  181. package/dist/server/engine/samples/postfix/ldap/catchall_maps.cf +11 -0
  182. package/dist/server/engine/samples/postfix/ldap/recipient_bcc_maps_domain.cf +11 -0
  183. package/dist/server/engine/samples/postfix/ldap/recipient_bcc_maps_user.cf +11 -0
  184. package/dist/server/engine/samples/postfix/ldap/relay_domains.cf +11 -0
  185. package/dist/server/engine/samples/postfix/ldap/sender_bcc_maps_domain.cf +11 -0
  186. package/dist/server/engine/samples/postfix/ldap/sender_bcc_maps_user.cf +11 -0
  187. package/dist/server/engine/samples/postfix/ldap/sender_dependent_relayhost_maps_domain.cf +11 -0
  188. package/dist/server/engine/samples/postfix/ldap/sender_dependent_relayhost_maps_user.cf +11 -0
  189. package/dist/server/engine/samples/postfix/ldap/sender_login_maps.cf +11 -0
  190. package/dist/server/engine/samples/postfix/ldap/transport_maps_domain.cf +11 -0
  191. package/dist/server/engine/samples/postfix/ldap/transport_maps_user.cf +11 -0
  192. package/dist/server/engine/samples/postfix/ldap/virtual_alias_maps.cf +11 -0
  193. package/dist/server/engine/samples/postfix/ldap/virtual_group_maps.cf +11 -0
  194. package/dist/server/engine/samples/postfix/ldap/virtual_group_members_maps.cf +11 -0
  195. package/dist/server/engine/samples/postfix/ldap/virtual_mailbox_domains.cf +11 -0
  196. package/dist/server/engine/samples/postfix/ldap/virtual_mailbox_maps.cf +12 -0
  197. package/dist/server/engine/samples/postfix/main.cf +282 -0
  198. package/dist/server/engine/samples/postfix/main.cf.amavisd +7 -0
  199. package/dist/server/engine/samples/postfix/main.cf.dovecot +8 -0
  200. package/dist/server/engine/samples/postfix/main.cf.ldap +39 -0
  201. package/dist/server/engine/samples/postfix/main.cf.mlmmj +5 -0
  202. package/dist/server/engine/samples/postfix/main.cf.mysql +39 -0
  203. package/dist/server/engine/samples/postfix/main.cf.pgsql +39 -0
  204. package/dist/server/engine/samples/postfix/main.cf.postscreen +30 -0
  205. package/dist/server/engine/samples/postfix/master.cf +101 -0
  206. package/dist/server/engine/samples/postfix/mysql/catchall_maps.cf +5 -0
  207. package/dist/server/engine/samples/postfix/mysql/domain_alias_catchall_maps.cf +5 -0
  208. package/dist/server/engine/samples/postfix/mysql/domain_alias_maps.cf +5 -0
  209. package/dist/server/engine/samples/postfix/mysql/recipient_bcc_maps_domain.cf +5 -0
  210. package/dist/server/engine/samples/postfix/mysql/recipient_bcc_maps_user.cf +5 -0
  211. package/dist/server/engine/samples/postfix/mysql/relay_domains.cf +5 -0
  212. package/dist/server/engine/samples/postfix/mysql/sender_bcc_maps_domain.cf +5 -0
  213. package/dist/server/engine/samples/postfix/mysql/sender_bcc_maps_user.cf +5 -0
  214. package/dist/server/engine/samples/postfix/mysql/sender_dependent_relayhost_maps.cf +6 -0
  215. package/dist/server/engine/samples/postfix/mysql/sender_login_maps.cf +5 -0
  216. package/dist/server/engine/samples/postfix/mysql/transport_maps_domain.cf +5 -0
  217. package/dist/server/engine/samples/postfix/mysql/transport_maps_maillist.cf +5 -0
  218. package/dist/server/engine/samples/postfix/mysql/transport_maps_user.cf +5 -0
  219. package/dist/server/engine/samples/postfix/mysql/virtual_alias_maps.cf +5 -0
  220. package/dist/server/engine/samples/postfix/mysql/virtual_mailbox_domains.cf +5 -0
  221. package/dist/server/engine/samples/postfix/mysql/virtual_mailbox_maps.cf +5 -0
  222. package/dist/server/engine/samples/postfix/pgsql/catchall_maps.cf +5 -0
  223. package/dist/server/engine/samples/postfix/pgsql/domain_alias_catchall_maps.cf +5 -0
  224. package/dist/server/engine/samples/postfix/pgsql/domain_alias_maps.cf +5 -0
  225. package/dist/server/engine/samples/postfix/pgsql/recipient_bcc_maps_domain.cf +5 -0
  226. package/dist/server/engine/samples/postfix/pgsql/recipient_bcc_maps_user.cf +5 -0
  227. package/dist/server/engine/samples/postfix/pgsql/relay_domains.cf +5 -0
  228. package/dist/server/engine/samples/postfix/pgsql/sender_bcc_maps_domain.cf +5 -0
  229. package/dist/server/engine/samples/postfix/pgsql/sender_bcc_maps_user.cf +5 -0
  230. package/dist/server/engine/samples/postfix/pgsql/sender_dependent_relayhost_maps.cf +6 -0
  231. package/dist/server/engine/samples/postfix/pgsql/sender_login_maps.cf +5 -0
  232. package/dist/server/engine/samples/postfix/pgsql/transport_maps_domain.cf +5 -0
  233. package/dist/server/engine/samples/postfix/pgsql/transport_maps_maillist.cf +5 -0
  234. package/dist/server/engine/samples/postfix/pgsql/transport_maps_user.cf +5 -0
  235. package/dist/server/engine/samples/postfix/pgsql/virtual_alias_maps.cf +5 -0
  236. package/dist/server/engine/samples/postfix/pgsql/virtual_mailbox_domains.cf +5 -0
  237. package/dist/server/engine/samples/postfix/pgsql/virtual_mailbox_maps.cf +5 -0
  238. package/dist/server/engine/samples/postfix/postscreen_access.cidr +6 -0
  239. package/dist/server/engine/samples/postgresql/sql/add_first_domain_and_user.sql +34 -0
  240. package/dist/server/engine/samples/postgresql/sql/grant_permissions.sql +14 -0
  241. package/dist/server/engine/samples/postgresql/sql/init_vmail_db.sql +15 -0
  242. package/dist/server/engine/samples/rsyslog.d/1-iredmail-dovecot.conf +23 -0
  243. package/dist/server/engine/samples/rsyslog.d/1-iredmail-fail2ban.conf +2 -0
  244. package/dist/server/engine/samples/rsyslog.d/1-iredmail-iredapd.conf +12 -0
  245. package/dist/server/engine/samples/rsyslog.d/1-iredmail-mlmmjadmin.conf +12 -0
  246. package/dist/server/engine/samples/rsyslog.d/1-iredmail-openldap.conf +2 -0
  247. package/dist/server/engine/samples/rsyslog.d/1-iredmail-phpfpm.conf +3 -0
  248. package/dist/server/engine/samples/spamassassin/local.cf +186 -0
  249. package/dist/server/engine/samples/spamassassin/razor.conf +1 -0
  250. package/dist/server/engine/samples/systemd/clamd.service.d/override.conf +2 -0
  251. package/dist/server/engine/samples/systemd/mariadb.service.d/override.conf +3 -0
  252. package/dist/server/engine/samples/systemd/slapd.service.d/override.conf +6 -0
  253. package/dist/server/engine/samples/yum/CentOS-Linux-AppStream.repo +6 -0
  254. package/dist/server/engine/samples/yum/CentOS-Linux-PowerTools.repo +6 -0
  255. package/dist/server/engine/samples/yum/CentOS-Stream-AppStream.repo +7 -0
  256. package/dist/server/engine/samples/yum/CentOS-Stream-PowerTools.repo +7 -0
  257. package/dist/server/engine/samples/yum/symas-openldap.repo +6 -0
  258. package/dist/server/engine/tools/add_enabled_service.py +60 -0
  259. package/dist/server/engine/tools/backup_mysql.sh +238 -0
  260. package/dist/server/engine/tools/backup_openldap.sh +230 -0
  261. package/dist/server/engine/tools/backup_pgsql.sh +217 -0
  262. package/dist/server/engine/tools/backup_sogo.sh +156 -0
  263. package/dist/server/engine/tools/create_mail_user_OpenLDAP.py +335 -0
  264. package/dist/server/engine/tools/create_mail_user_OpenLDAP.sh +287 -0
  265. package/dist/server/engine/tools/create_mail_user_SQL.sh +127 -0
  266. package/dist/server/engine/tools/enable_postscreen.sh +144 -0
  267. package/dist/server/engine/tools/fail2ban_unban_ip.sh +39 -0
  268. package/dist/server/engine/tools/find_sasl_login_ip.sh +20 -0
  269. package/dist/server/engine/tools/find_top_sasl_usernames.sh +28 -0
  270. package/dist/server/engine/tools/generate_ssl_keys.sh +85 -0
  271. package/dist/server/engine/tools/kill_high_cpu_sogo_process.sh +32 -0
  272. package/dist/server/engine/tools/ldap_assign_user_to_groups.py +151 -0
  273. package/dist/server/engine/tools/ldap_move_members_to_another_group.py +129 -0
  274. package/dist/server/engine/tools/migrate_sql_alias_table.py +177 -0
  275. package/dist/server/engine/update/0.9.8/amavisd.mysql +29 -0
  276. package/dist/server/engine/update/0.9.8/amavisd.pgsql +39 -0
  277. package/dist/server/engine/update/0.9.8/iredmail.mysql +53 -0
  278. package/dist/server/engine/update/0.9.8/iredmail.pgsql +61 -0
  279. package/dist/server/engine/update/0.9.9/iredmail.mysql +2 -0
  280. package/dist/server/engine/update/0.9.9/iredmail.pgsql +2 -0
  281. package/dist/server/engine/update/1.0/iredmail.mysql +2 -0
  282. package/dist/server/engine/update/1.0/iredmail.pgsql +2 -0
  283. package/dist/server/engine/update/1.2/last_login.mysql +16 -0
  284. package/dist/server/engine/update/1.4.0/iredmail.mysql +22 -0
  285. package/dist/server/engine/update/1.4.0/iredmail.pgsql +20 -0
  286. package/dist/server/engine/update/1.4.1/iredmail.mysql +3 -0
  287. package/dist/server/engine/update/1.4.1/iredmail.pgsql +3 -0
  288. package/dist/server/engine/update/1.4.1/sogo.mysql +11 -0
  289. package/dist/server/engine/update/1.4.1/sogo.pgsql +30 -0
  290. package/dist/server/engine/update/1.4.1/update-ldap.py +66 -0
  291. package/dist/server/engine/update/1.4.2/iredmail.mysql +9 -0
  292. package/dist/server/engine/update/1.4.2/iredmail.pgsql +9 -0
  293. package/dist/server/engine/update/1.4.2/sogo.pgsql +30 -0
  294. package/dist/server/engine/update/1.6.0/sogo_view.pgsql +27 -0
  295. package/dist/server/engine/update/1.6.3/iredmail.mysql +1 -0
  296. package/dist/server/engine/update/1.7.0/fail2ban.mysql +11 -0
  297. package/dist/server/engine/update/1.7.0/fail2ban.pgsql +12 -0
  298. package/dist/server/engine/update/1.7.1/amavisd.mysql +1 -0
  299. package/dist/server/engine/update/1.7.2/vmail.mysql +30 -0
  300. package/dist/server/engine/update/1.7.3/deleted_mailboxes.mysql +43 -0
  301. package/dist/server/engine/update/1.7.3/iredadmin.mysql +26 -0
  302. package/dist/server/engine/update/1.7.3/vmail.mysql +79 -0
  303. package/dist/server/engine/update/1.7.3/vmail.pgsql +9 -0
  304. package/dist/server/engine/update/README.md +1 -0
  305. package/dist/server/engine/update/ldap/README.md +39 -0
  306. package/dist/server/engine/update/ldap/update-ldap-dovecot-2.3.py +69 -0
  307. package/dist/server/index.js +349016 -0
  308. package/dist/server/lua/geo_country.lua +127 -0
  309. package/dist/server/lua/maxminddb.lua +403 -0
  310. package/dist/server/lua/mgmt_api.lua +654 -0
  311. package/dist/server/lua/pipe_stream.lua +103 -0
  312. package/dist/server/lua/rules_guard.lua +132 -0
  313. package/dist/server/lua/rules_lib.lua +176 -0
  314. package/dist/server/lua/site_logger.lua +405 -0
  315. package/dist/server/lua/webhook_handler.lua +126 -0
  316. package/dist/server/migrations/0000_init.sql +666 -0
  317. package/dist/server/migrations/0001_brief_tomorrow_man.sql +47 -0
  318. package/dist/server/migrations/0002_funny_dazzler.sql +2 -0
  319. package/dist/server/migrations/0003_third_killer_shrike.sql +1 -0
  320. package/dist/server/migrations/0004_session_active_org_not_null.sql +10 -0
  321. package/dist/server/migrations/0005_warm_amazoness.sql +3 -0
  322. package/dist/server/migrations/0006_lumpy_joystick.sql +1 -0
  323. package/dist/server/migrations/0007_outgoing_maginty.sql +2 -0
  324. package/dist/server/migrations/0008_frozen_cutover.sql +3 -0
  325. package/dist/server/migrations/0009_credits_billing.sql +142 -0
  326. package/dist/server/migrations/0010_credit_grant_dedupe.sql +14 -0
  327. package/dist/server/migrations/0011_remove_credit_ledger.sql +23 -0
  328. package/dist/server/migrations/0012_smart_deploys_and_git_rollback.sql +81 -0
  329. package/dist/server/migrations/0013_fix_check_run_rollup_unique.sql +38 -0
  330. package/dist/server/migrations/0014_default_rollback_git.sql +9 -0
  331. package/dist/server/migrations/0015_billing_idempotency_grants.sql +41 -0
  332. package/dist/server/migrations/0016_github_auth_high_findings.sql +30 -0
  333. package/dist/server/migrations/0017_spooky_rumiko_fujikawa.sql +6 -0
  334. package/dist/server/migrations/0018_calm_shatterstar.sql +1 -0
  335. package/dist/server/migrations/0019_rename_workspace_install_to_prepare.sql +1 -0
  336. package/dist/server/migrations/0020_uneven_the_renegades.sql +13 -0
  337. package/dist/server/migrations/0021_shiny_firestar.sql +2 -0
  338. package/dist/server/migrations/0022_version_on_success_backfill.sql +6 -0
  339. package/dist/server/migrations/0023_productive_gorilla_man.sql +17 -0
  340. package/dist/server/migrations/0024_sleepy_peter_quill.sql +2 -0
  341. package/dist/server/migrations/0025_smooth_blue_shield.sql +1 -0
  342. package/dist/server/migrations/0026_mail_backup_source.sql +11 -0
  343. package/dist/server/migrations/0027_opposite_anthem.sql +6 -0
  344. package/dist/server/migrations/0028_stale_rogue.sql +18 -0
  345. package/dist/server/migrations/0029_bouncy_loners.sql +16 -0
  346. package/dist/server/migrations/0030_bright_darkstar.sql +6 -0
  347. package/dist/server/migrations/0031_conscious_catseye.sql +13 -0
  348. package/dist/server/migrations/0032_wet_mimic.sql +51 -0
  349. package/dist/server/migrations/0033_eminent_molly_hayes.sql +2 -0
  350. package/dist/server/migrations/0034_nervous_surge.sql +1 -0
  351. package/dist/server/migrations/0035_thankful_morgan_stark.sql +1 -0
  352. package/dist/server/migrations/0036_gorgeous_scalphunter.sql +17 -0
  353. package/dist/server/migrations/0037_clever_makkari.sql +28 -0
  354. package/dist/server/migrations/0038_young_magneto.sql +1 -0
  355. package/dist/server/migrations/0039_secret_lady_ursula.sql +15 -0
  356. package/dist/server/migrations/0040_sharp_red_wolf.sql +16 -0
  357. package/dist/server/migrations/0041_round_spyke.sql +4 -0
  358. package/dist/server/migrations/0042_dapper_havok.sql +1 -0
  359. package/dist/server/migrations/0043_fast_sharon_ventura.sql +15 -0
  360. package/dist/server/migrations/0044_amused_shape.sql +8 -0
  361. package/dist/server/migrations/0045_amusing_korath.sql +1 -0
  362. package/dist/server/migrations/0046_white_harrier.sql +35 -0
  363. package/dist/server/migrations/0047_sloppy_strong_guy.sql +2 -0
  364. package/dist/server/migrations/0048_funny_emma_frost.sql +2 -0
  365. package/dist/server/migrations/0049_nappy_piledriver.sql +3 -0
  366. package/dist/server/migrations/0050_add_service_deployment_image_digest.sql +1 -0
  367. package/dist/server/migrations/0051_add_update_status.sql +19 -0
  368. package/dist/server/migrations/0052_add_notice_target.sql +2 -0
  369. package/dist/server/migrations/0053_colossal_sandman.sql +14 -0
  370. package/dist/server/migrations/0054_add_instance_smtp.sql +5 -0
  371. package/dist/server/migrations/0055_rainy_klaw.sql +22 -0
  372. package/dist/server/migrations/0056_moaning_daredevil.sql +2 -0
  373. package/dist/server/migrations/0057_complete_prism.sql +18 -0
  374. package/dist/server/migrations/0058_add_server_is_local.sql +1 -0
  375. package/dist/server/migrations/0059_legal_fixer.sql +18 -0
  376. package/dist/server/migrations/0060_add_route_strategy_host_port.sql +3 -0
  377. package/dist/server/migrations/0061_notification_default_multi_kind.sql +3 -0
  378. package/dist/server/migrations/0062_add_incoming_webhook.sql +21 -0
  379. package/dist/server/migrations/0063_add_migration_logs.sql +1 -0
  380. package/dist/server/migrations/0064_add_migration_partial.sql +2 -0
  381. package/dist/server/migrations/0065_custom_app_template.sql +14 -0
  382. package/dist/server/migrations/0066_ensure_migration_partial_columns.sql +2 -0
  383. package/dist/server/migrations/0067_webhook_delivery.sql +28 -0
  384. package/dist/server/migrations/0068_add_migration_target_volumes.sql +1 -0
  385. package/dist/server/migrations/0069_add_project_composite_routes.sql +1 -0
  386. package/dist/server/migrations/0070_forward_git_to_server.sql +1 -0
  387. package/dist/server/migrations/0071_gh_device_token.sql +3 -0
  388. package/dist/server/migrations/0072_gh_device_token_method.sql +1 -0
  389. package/dist/server/migrations/0073_project_volumes_object_storage.sql +3 -0
  390. package/dist/server/migrations/0074_project_compose_path.sql +1 -0
  391. package/dist/server/migrations/0075_service_command_argv.sql +1 -0
  392. package/dist/server/migrations/0076_rollback_retention.sql +17 -0
  393. package/dist/server/migrations/0077_domain_redirect.sql +13 -0
  394. package/dist/server/migrations/0078_grant_source_scope.sql +30 -0
  395. package/dist/server/migrations/0079_project_readiness.sql +18 -0
  396. package/dist/server/migrations/0080_deployment_error_classification.sql +26 -0
  397. package/dist/server/migrations/0081_project_readiness_repair.sql +34 -0
  398. package/dist/server/migrations/0082_edge_target_verification.sql +39 -0
  399. package/dist/server/migrations/0083_service_incident.sql +84 -0
  400. package/dist/server/migrations/0084_analytics_daily_rollup.sql +72 -0
  401. package/dist/server/migrations/0085_resource_usage.sql +68 -0
  402. package/dist/server/migrations/0086_remote_infra_updates.sql +41 -0
  403. package/dist/server/migrations/0087_server_container_version_columns.sql +17 -0
  404. package/dist/server/migrations/0088_audit_source_and_settings.sql +27 -0
  405. package/dist/server/migrations/0089_auto_scan_infra.sql +7 -0
  406. package/dist/server/migrations/0090_project_collect_paths.sql +18 -0
  407. package/dist/server/migrations/0091_project_server_id.sql +26 -0
  408. package/dist/server/migrations/0092_project_internal_alias.sql +13 -0
  409. package/dist/server/migrations/0093_service_incident_org_index.sql +13 -0
  410. package/dist/server/migrations/0094_backup_restore_meta.sql +15 -0
  411. package/dist/server/migrations/0095_backup_restore_cancel.sql +19 -0
  412. package/dist/server/migrations/0096_backup_policy_retention_defaults.sql +20 -0
  413. package/dist/server/migrations/0097_update_status_upstream_only.sql +35 -0
  414. package/dist/server/migrations/0098_instance_product_mode.sql +12 -0
  415. package/dist/server/migrations/0099_mail_webmail_project.sql +24 -0
  416. package/dist/server/migrations/0100_server_ssh_private_key.sql +11 -0
  417. package/dist/server/migrations/0101_mail_resume_step.sql +12 -0
  418. package/dist/server/migrations/0102_project_workload_axes.sql +19 -0
  419. package/dist/server/migrations/0103_dns_credential.sql +41 -0
  420. package/dist/server/migrations/0104_instance_host_control.sql +15 -0
  421. package/dist/server/migrations/0105_mail_inbound_rules.sql +80 -0
  422. package/dist/server/migrations/0106_mcp_call_tracking.sql +23 -0
  423. package/dist/server/migrations/0107_build_minute_metering_indexes.sql +20 -0
  424. package/dist/server/migrations/0108_credential.sql +68 -0
  425. package/dist/server/migrations/0109_service_build_args.sql +9 -0
  426. package/dist/server/migrations/0110_service_deployment_host_ports.sql +18 -0
  427. package/dist/server/migrations/0111_host_port_claim.sql +381 -0
  428. package/dist/server/migrations/0112_backup_run_execution_lease.sql +12 -0
  429. package/dist/server/migrations/0113_docker_migration_execution_lease.sql +11 -0
  430. package/dist/server/migrations/0114_build_session_execution_lease_index.sql +6 -0
  431. package/dist/server/migrations/0115_orphan_target_key.sql +3 -0
  432. package/dist/server/migrations/0116_domain_ssl_challenge.sql +2 -0
  433. package/dist/server/migrations/0117_github_installation_workspace_scope.sql +24 -0
  434. package/dist/server/migrations/0118_git_sources.sql +66 -0
  435. package/dist/server/migrations/0119_backup_run_batch.sql +8 -0
  436. package/dist/server/migrations/0120_domain_primary_unique.sql +24 -0
  437. package/dist/server/migrations/0121_host_port_claim_overlap.sql +14 -0
  438. package/dist/server/migrations/0122_data_transfer_staging.sql +45 -0
  439. package/dist/server/migrations/0123_drop_cloud_infra.sql +7 -0
  440. package/dist/server/migrations/0124_mail_dmarc_report.sql +23 -0
  441. package/dist/server/migrations/0125_server_security_snapshot.sql +22 -0
  442. package/dist/server/migrations/meta/0000_snapshot.json +4848 -0
  443. package/dist/server/migrations/meta/0001_snapshot.json +4991 -0
  444. package/dist/server/migrations/meta/0002_snapshot.json +5013 -0
  445. package/dist/server/migrations/meta/0003_snapshot.json +5020 -0
  446. package/dist/server/migrations/meta/0004_snapshot.json +5020 -0
  447. package/dist/server/migrations/meta/0005_snapshot.json +5039 -0
  448. package/dist/server/migrations/meta/0006_snapshot.json +5045 -0
  449. package/dist/server/migrations/meta/0007_snapshot.json +5057 -0
  450. package/dist/server/migrations/meta/0016_snapshot.json +6053 -0
  451. package/dist/server/migrations/meta/0017_snapshot.json +6091 -0
  452. package/dist/server/migrations/meta/0018_snapshot.json +6098 -0
  453. package/dist/server/migrations/meta/0019_snapshot.json +6098 -0
  454. package/dist/server/migrations/meta/0020_snapshot.json +6201 -0
  455. package/dist/server/migrations/meta/0021_snapshot.json +6213 -0
  456. package/dist/server/migrations/meta/0022_snapshot.json +6213 -0
  457. package/dist/server/migrations/meta/0023_snapshot.json +6331 -0
  458. package/dist/server/migrations/meta/0024_snapshot.json +6343 -0
  459. package/dist/server/migrations/meta/0025_snapshot.json +6350 -0
  460. package/dist/server/migrations/meta/0026_snapshot.json +6440 -0
  461. package/dist/server/migrations/meta/0027_snapshot.json +6447 -0
  462. package/dist/server/migrations/meta/0028_snapshot.json +6581 -0
  463. package/dist/server/migrations/meta/0029_snapshot.json +6710 -0
  464. package/dist/server/migrations/meta/0030_snapshot.json +6748 -0
  465. package/dist/server/migrations/meta/0031_snapshot.json +6859 -0
  466. package/dist/server/migrations/meta/0032_snapshot.json +7222 -0
  467. package/dist/server/migrations/meta/0033_snapshot.json +7249 -0
  468. package/dist/server/migrations/meta/0034_snapshot.json +7255 -0
  469. package/dist/server/migrations/meta/0035_snapshot.json +7262 -0
  470. package/dist/server/migrations/meta/0036_snapshot.json +7392 -0
  471. package/dist/server/migrations/meta/0037_snapshot.json +7602 -0
  472. package/dist/server/migrations/meta/0038_snapshot.json +7609 -0
  473. package/dist/server/migrations/meta/0039_snapshot.json +7714 -0
  474. package/dist/server/migrations/meta/0040_snapshot.json +7820 -0
  475. package/dist/server/migrations/meta/0041_snapshot.json +7833 -0
  476. package/dist/server/migrations/meta/0042_snapshot.json +7839 -0
  477. package/dist/server/migrations/meta/0043_snapshot.json +7938 -0
  478. package/dist/server/migrations/meta/0044_snapshot.json +7982 -0
  479. package/dist/server/migrations/meta/0045_snapshot.json +7989 -0
  480. package/dist/server/migrations/meta/0046_snapshot.json +8263 -0
  481. package/dist/server/migrations/meta/0047_snapshot.json +8275 -0
  482. package/dist/server/migrations/meta/0048_snapshot.json +8289 -0
  483. package/dist/server/migrations/meta/0049_snapshot.json +8308 -0
  484. package/dist/server/migrations/meta/0050_snapshot.json +8314 -0
  485. package/dist/server/migrations/meta/0051_snapshot.json +8460 -0
  486. package/dist/server/migrations/meta/0052_snapshot.json +8472 -0
  487. package/dist/server/migrations/meta/0053_snapshot.json +8556 -0
  488. package/dist/server/migrations/meta/0054_snapshot.json +8586 -0
  489. package/dist/server/migrations/meta/0055_snapshot.json +8756 -0
  490. package/dist/server/migrations/meta/0056_snapshot.json +8777 -0
  491. package/dist/server/migrations/meta/0057_snapshot.json +8904 -0
  492. package/dist/server/migrations/meta/0058_snapshot.json +8911 -0
  493. package/dist/server/migrations/meta/0059_snapshot.json +9061 -0
  494. package/dist/server/migrations/meta/0060_snapshot.json +9081 -0
  495. package/dist/server/migrations/meta/_journal.json +888 -0
  496. package/dist/server/pglite/pglite.data +0 -0
  497. package/dist/server/pglite/pglite.wasm +0 -0
  498. package/dist/setup-JWKZIECM.js +25 -0
  499. package/dist/signin-3M3UPB6K.js +667 -0
  500. package/dist/ssh-client-NWQVRCV7.js +29 -0
  501. package/dist/sso-oidc-3VDIYOEJ.js +834 -0
  502. package/dist/sts-B3WIYLXR.js +1426 -0
  503. package/dist/up-P5DMQ5YO.js +55 -0
  504. package/package.json +58 -0
@@ -0,0 +1,1069 @@
1
+ #!/usr/bin/env sh
2
+ ":" //# ; exec "$(command -v node || command -v bun)" "$0" "$@"
3
+ import { createRequire as __ospCreateRequire } from "node:module";
4
+ const require = __ospCreateRequire(import.meta.url);
5
+ import {
6
+ sq
7
+ } from "./chunk-MNV2QFHW.js";
8
+ import {
9
+ nodeBinDirs,
10
+ nodeBinPathExport,
11
+ packageManagerEnsureCommand,
12
+ safeErrorMessage,
13
+ shellQuote
14
+ } from "./chunk-PVOWHIND.js";
15
+
16
+ // ../../packages/adapters/src/runtime/git-clone.ts
17
+ var sq2 = shellQuote;
18
+ function gitCredentialPair(hostname, token) {
19
+ if (hostname === "github.com" && !token.startsWith("ghs_")) {
20
+ return { username: token, password: "x-oauth-basic" };
21
+ }
22
+ return { username: "x-access-token", password: token };
23
+ }
24
+ function injectGitToken(repoUrl, token) {
25
+ const secret = token?.trim();
26
+ if (!secret) return repoUrl;
27
+ try {
28
+ const url = new URL(repoUrl);
29
+ if (url.protocol !== "https:") return repoUrl;
30
+ const { username, password } = gitCredentialPair(url.hostname, secret);
31
+ url.username = username;
32
+ url.password = password;
33
+ return url.toString();
34
+ } catch {
35
+ return repoUrl;
36
+ }
37
+ }
38
+ function toGitHubSshUrl(repoUrl) {
39
+ try {
40
+ const url = new URL(repoUrl);
41
+ const host = url.hostname;
42
+ const repoPath = url.pathname.replace(/^\/+/, "").replace(/\.git$/, "");
43
+ return `git@${host}:${repoPath}.git`;
44
+ } catch {
45
+ return repoUrl;
46
+ }
47
+ }
48
+ var TERMINAL_PROMPT = ["GIT_TERMINAL_PROMPT", "0", false];
49
+ function invocation(cloneUrl, entries, disableHelper) {
50
+ return {
51
+ cloneUrl,
52
+ gitEnv: entries.map(([k, v, q]) => `${k}=${q ? sq2(v) : v}`).join(" "),
53
+ credFlag: disableHelper ? "-c credential.helper=" : "",
54
+ env: Object.fromEntries(entries.map(([k, v]) => [k, v])),
55
+ credArgs: disableHelper ? ["-c", "credential.helper="] : []
56
+ };
57
+ }
58
+ function assertNotOptionLike(repoUrl) {
59
+ if (repoUrl.trimStart().startsWith("-")) {
60
+ throw new Error(
61
+ `Refusing to clone from ${JSON.stringify(repoUrl)}: a repository URL must not start with "-" (git would read it as an option).`
62
+ );
63
+ }
64
+ }
65
+ function assembleGitClone(auth) {
66
+ assertNotOptionLike(auth.repoUrl);
67
+ if (auth.ssh) {
68
+ const sshCmd = `ssh -i ${sq2(auth.ssh.keyFile)} -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=${sq2(auth.ssh.knownHostsFile)}`;
69
+ return invocation(
70
+ toGitHubSshUrl(auth.repoUrl),
71
+ [TERMINAL_PROMPT, ["GIT_SSH_COMMAND", sshCmd, true]],
72
+ false
73
+ );
74
+ }
75
+ if (auth.gitCredentialHelperPath) {
76
+ const base = invocation(
77
+ auth.repoUrl,
78
+ [
79
+ TERMINAL_PROMPT,
80
+ // An empty helper value resets helpers inherited from the host before
81
+ // adding the deployment-scoped relay. Without the reset, a server's
82
+ // stale/global helper can answer first and silently override the
83
+ // forwarded identity named in the deployment log.
84
+ ["GIT_CONFIG_COUNT", "3", false],
85
+ ["GIT_CONFIG_KEY_0", "credential.helper", false],
86
+ ["GIT_CONFIG_VALUE_0", "", true],
87
+ ["GIT_CONFIG_KEY_1", "credential.helper", false],
88
+ ["GIT_CONFIG_VALUE_1", auth.gitCredentialHelperPath, true],
89
+ ["GIT_CONFIG_KEY_2", "credential.useHttpPath", false],
90
+ ["GIT_CONFIG_VALUE_2", "true", false]
91
+ ],
92
+ false
93
+ );
94
+ let url;
95
+ try {
96
+ url = new URL(auth.repoUrl);
97
+ } catch {
98
+ throw new Error(
99
+ "Git credential forwarding requires an absolute HTTPS repository URL"
100
+ );
101
+ }
102
+ if (url.protocol !== "https:") {
103
+ throw new Error(
104
+ "Git credential forwarding requires an HTTPS repository URL"
105
+ );
106
+ }
107
+ const protocol = url.protocol.slice(0, -1);
108
+ const path = url.pathname.replace(/^\/+/, "");
109
+ const headerVar = "KRAFT_GIT_AUTH_HEADER";
110
+ const headerCommand = `${sq2(auth.gitCredentialHelperPath)} auth-header ${sq2(protocol)} ${sq2(url.hostname)} ${sq2(path)}`;
111
+ return {
112
+ ...base,
113
+ // `auth-header` returns only the Basic header, never prints it to the
114
+ // build log, and keeps the token out of the command text and filesystem.
115
+ // The value exists only in the remote shell/git process for this command.
116
+ shellPrelude: `${headerVar}="$(${headerCommand})" && test -n "$${headerVar}"`,
117
+ // The argv representation above remains a valid challenge-based helper
118
+ // invocation for local spawn users. Remote shell users call
119
+ // gitShellCommand(), which adds the preemptive header as config slot 3.
120
+ gitEnv: `${base.gitEnv.replace("GIT_CONFIG_COUNT=3", "GIT_CONFIG_COUNT=4")} GIT_CONFIG_KEY_3=http.extraHeader GIT_CONFIG_VALUE_3="$${headerVar}"`
121
+ };
122
+ }
123
+ if (auth.ambient) {
124
+ if (auth.ambient.via === "ssh") {
125
+ return invocation(toGitHubSshUrl(auth.repoUrl), [TERMINAL_PROMPT], false);
126
+ }
127
+ if (auth.ambient.via === "gh") {
128
+ return invocation(
129
+ auth.repoUrl,
130
+ [
131
+ TERMINAL_PROMPT,
132
+ ["GIT_CONFIG_COUNT", "1", false],
133
+ ["GIT_CONFIG_KEY_0", "credential.helper", false],
134
+ ["GIT_CONFIG_VALUE_0", "!gh auth git-credential", true]
135
+ ],
136
+ false
137
+ );
138
+ }
139
+ return invocation(auth.repoUrl, [TERMINAL_PROMPT], false);
140
+ }
141
+ return invocation(
142
+ injectGitToken(auth.repoUrl, auth.gitToken),
143
+ [TERMINAL_PROMPT, ["GIT_ASKPASS", "/bin/echo", false]],
144
+ true
145
+ );
146
+ }
147
+ function gitShellCommand(invocation2, args) {
148
+ const env = invocation2.gitEnv ? `${invocation2.gitEnv} ` : "";
149
+ const flags = invocation2.credFlag ? `${invocation2.credFlag} ` : "";
150
+ const command = `${env}git ${flags}${args}`;
151
+ return invocation2.shellPrelude ? `${invocation2.shellPrelude} && ${command}` : command;
152
+ }
153
+
154
+ // ../../packages/adapters/src/runtime/git-ssh-material.ts
155
+ import { mkdir, rm, writeFile } from "fs/promises";
156
+ async function materializeGitSsh(writer, dir, gitSsh) {
157
+ const keyFile = `${dir}/id`;
158
+ const knownHostsFile = `${dir}/known_hosts`;
159
+ await writer.ensureDir(dir);
160
+ try {
161
+ await writer.writeSecret(keyFile, gitSsh.privateKey);
162
+ await writer.writeSecret(knownHostsFile, gitSsh.knownHosts);
163
+ } catch (err) {
164
+ await writer.remove(dir);
165
+ throw err;
166
+ }
167
+ return {
168
+ keyFile,
169
+ knownHostsFile,
170
+ cleanup: () => writer.remove(dir)
171
+ };
172
+ }
173
+ function shellGitSshWriter(io) {
174
+ return {
175
+ ensureDir: async (dir) => {
176
+ await io.exec(`mkdir -p ${sq2(dir)} && chmod 700 ${sq2(dir)}`);
177
+ },
178
+ writeSecret: async (path, content) => {
179
+ await io.writeSecret(path, content);
180
+ await io.exec(`chmod 600 ${sq2(path)}`);
181
+ },
182
+ remove: async (dir) => {
183
+ await io.exec(`rm -rf ${sq2(dir)}`).catch(() => {
184
+ });
185
+ }
186
+ };
187
+ }
188
+ function localGitSshWriter() {
189
+ return {
190
+ ensureDir: (dir) => mkdir(dir, { recursive: true, mode: 448 }).then(() => {
191
+ }),
192
+ writeSecret: (path, content) => writeFile(path, content, { mode: 384 }),
193
+ remove: (dir) => rm(dir, { recursive: true, force: true }).catch(() => {
194
+ })
195
+ };
196
+ }
197
+
198
+ // ../../packages/adapters/src/runtime/build-pipeline.ts
199
+ var BuildLogger = class {
200
+ constructor(onLog) {
201
+ this.onLog = onLog;
202
+ }
203
+ /** Emit a plain log line. */
204
+ log(message, level = "info", meta) {
205
+ this.onLog?.({
206
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
207
+ message,
208
+ level,
209
+ ...meta
210
+ });
211
+ }
212
+ /** Emit a step lifecycle event (running / completed / failed / skipped). */
213
+ step(step, status, message) {
214
+ this.onLog?.({
215
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
216
+ message,
217
+ level: status === "failed" ? "error" : "info",
218
+ step,
219
+ stepStatus: status
220
+ });
221
+ }
222
+ /**
223
+ * Run a step: emit running → execute → emit completed/failed.
224
+ * Throws on failure so the caller can handle it.
225
+ */
226
+ async runStep(step, label, fn) {
227
+ this.step(step, "running", label);
228
+ try {
229
+ await fn();
230
+ this.step(step, "completed", `${label} - done`);
231
+ } catch (err) {
232
+ const msg = safeErrorMessage(err);
233
+ this.step(step, "failed", `${label} - ${msg}`);
234
+ throw err;
235
+ }
236
+ }
237
+ /** Get the underlying callback for passing to exec / stream functions. */
238
+ get callback() {
239
+ return (entry) => this.onLog?.(entry);
240
+ }
241
+ };
242
+ var BuildCancelledError = class extends Error {
243
+ constructor(message = "Build cancelled") {
244
+ super(message);
245
+ this.name = "BuildCancelledError";
246
+ }
247
+ };
248
+ async function killProcessesUnderDir(executor, dir, opts) {
249
+ const quoted = sq2(dir);
250
+ const roots = opts?.includeSuffixed ? [quoted, `${quoted}-*`] : [quoted];
251
+ const patterns = roots.flatMap((root) => [
252
+ root,
253
+ `${root}/*`,
254
+ `${root}" (deleted)"`,
255
+ `${root}/*" (deleted)"`
256
+ ]);
257
+ const scan = (sig) => `for p in /proc/[0-9]*; do c=$(readlink "$p/cwd" 2>/dev/null); case "$c" in ${patterns.join("|")}) kill -${sig} "\${p##*/}" 2>/dev/null || true;; esac; done`;
258
+ await executor.exec(`${scan("TERM")}; sleep 2; ${scan("KILL")}`).catch(() => {
259
+ });
260
+ }
261
+ async function runBuildPipeline(env, config, logger) {
262
+ let startTime = Date.now();
263
+ let currentStep = "prepare";
264
+ const exec = (command) => env.exec(command, logger.callback);
265
+ const buildDir = resolveBuildDirectory(env.projectDir, config.rootDirectory);
266
+ if (env.hasNativeEnv) {
267
+ const { cpuCores, memoryMb, diskMb } = config.resources;
268
+ logger.log(
269
+ `Machine: ${cpuCores} CPU \xB7 ${memoryMb} MB RAM \xB7 ${diskMb} MB Disk`
270
+ );
271
+ }
272
+ try {
273
+ if (env.preflight) {
274
+ await logger.runStep("prepare", "Preparing server", async () => {
275
+ await env.preflight(config, logger);
276
+ });
277
+ }
278
+ startTime = Date.now();
279
+ currentStep = "clone";
280
+ if (config.localPath || config.sourceStaged) {
281
+ logger.step("clone", "completed", "Source ready");
282
+ } else {
283
+ await logger.runStep(
284
+ "clone",
285
+ `Cloning ${config.repoUrl} (branch: ${config.branch})`,
286
+ async () => {
287
+ let sshMaterial;
288
+ if (config.gitSsh) {
289
+ const writeSecretFile = env.writeSecretFile;
290
+ if (!writeSecretFile) {
291
+ throw new Error(
292
+ "SSH-based GitHub auth isn't supported on this build runtime \u2014 use a token or the tunnel relay."
293
+ );
294
+ }
295
+ sshMaterial = await materializeGitSsh(
296
+ shellGitSshWriter({ exec, writeSecret: writeSecretFile }),
297
+ `${env.projectDir}.gitssh`,
298
+ config.gitSsh
299
+ );
300
+ }
301
+ const gitInvocation = assembleGitClone({
302
+ repoUrl: config.repoUrl,
303
+ gitToken: config.gitToken,
304
+ gitCredentialHelperPath: config.gitCredentialHelperPath,
305
+ ssh: sshMaterial,
306
+ ambient: config.gitAmbient
307
+ });
308
+ const { cloneUrl, credFlag: CRED } = gitInvocation;
309
+ try {
310
+ if (config.commitSha) {
311
+ await exec(
312
+ gitShellCommand(
313
+ gitInvocation,
314
+ `clone --progress --depth 50 --branch ${sq2(config.branch)} ${sq2(cloneUrl)} ${sq2(env.projectDir)}`
315
+ )
316
+ );
317
+ const commitPresent = await exec(
318
+ `cd ${sq2(env.projectDir)} && git ${CRED} cat-file -e ${sq2(`${config.commitSha}^{commit}`)}`
319
+ ).then(
320
+ () => true,
321
+ () => false
322
+ );
323
+ if (!commitPresent) {
324
+ logger.log(
325
+ `Commit ${config.commitSha} is not in the depth-50 clone; fetching full history before checkout.`,
326
+ "warn"
327
+ );
328
+ await exec(
329
+ `cd ${sq2(env.projectDir)} && ${gitShellCommand(gitInvocation, "fetch --progress --unshallow")}`
330
+ );
331
+ }
332
+ await exec(
333
+ `cd ${sq2(env.projectDir)} && ${gitShellCommand(
334
+ gitInvocation,
335
+ `-c advice.detachedHead=false checkout ${sq2(config.commitSha)}`
336
+ )}`
337
+ );
338
+ } else {
339
+ await exec(
340
+ gitShellCommand(
341
+ gitInvocation,
342
+ `clone --progress --depth 1 --branch ${sq2(config.branch)} ${sq2(cloneUrl)} ${sq2(env.projectDir)}`
343
+ )
344
+ );
345
+ }
346
+ } finally {
347
+ await sshMaterial?.cleanup();
348
+ }
349
+ }
350
+ );
351
+ }
352
+ const envPrefix = env.hasNativeEnv ? "" : Object.entries(config.envVars).filter(([k]) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(k)).map(([k, v]) => `export ${k}=${sq2(v)}`).join(" && ");
353
+ const binPathExport = nodeBinPathExport(config.packageManager, [
354
+ buildDir,
355
+ env.projectDir
356
+ ]);
357
+ const inDir = (cmd) => {
358
+ const full = `cd ${sq2(buildDir)} && ${cmd}`;
359
+ const prefix = [envPrefix, binPathExport].filter(Boolean).join(" && ");
360
+ return prefix ? `${prefix} && ${full}` : full;
361
+ };
362
+ const pmEnsure = packageManagerEnsureCommand(config.packageManager);
363
+ currentStep = "install";
364
+ if (config.installCommand) {
365
+ const installCmd = pmEnsure ? `${pmEnsure} && ${config.installCommand}` : config.installCommand;
366
+ await logger.runStep(
367
+ "install",
368
+ `Installing dependencies (${config.packageManager})`,
369
+ async () => {
370
+ await exec(inDir(installCmd));
371
+ }
372
+ );
373
+ } else {
374
+ logger.step("install", "skipped", "No install command configured");
375
+ }
376
+ if (config.buildCommand) {
377
+ currentStep = "build";
378
+ const buildCmd = pmEnsure && !config.installCommand ? `${pmEnsure} && ${config.buildCommand}` : config.buildCommand;
379
+ await logger.runStep(
380
+ "build",
381
+ `Building (${config.buildCommand})`,
382
+ async () => {
383
+ await exec(inDir(buildCmd));
384
+ }
385
+ );
386
+ } else {
387
+ logger.step("build", "skipped", "No build command configured");
388
+ }
389
+ const durationMs = Date.now() - startTime;
390
+ return { status: "deploying", durationMs };
391
+ } catch (err) {
392
+ const durationMs = Date.now() - startTime;
393
+ if (err instanceof BuildCancelledError) {
394
+ return { status: "cancelled", durationMs, errorMessage: err.message };
395
+ }
396
+ const errorMessage = safeErrorMessage(err);
397
+ return {
398
+ status: "failed",
399
+ failedStep: currentStep,
400
+ durationMs,
401
+ errorMessage
402
+ };
403
+ }
404
+ }
405
+ function resolveBuildDirectory(projectDir, rootDirectory) {
406
+ const normalized = rootDirectory?.trim().replace(/^\/+|\/+$/g, "");
407
+ if (!normalized || normalized === ".") {
408
+ return projectDir;
409
+ }
410
+ return `${projectDir}/${normalized}`;
411
+ }
412
+ function parseLogLevel(message) {
413
+ if (/\b(error|fatal|panic)\b/i.test(message)) return "error";
414
+ if (/\bwarn(ing)?\b/i.test(message)) return "warn";
415
+ return "info";
416
+ }
417
+ function detectBuildKillHint(output) {
418
+ if (!output) return null;
419
+ const tail = output.slice(-4096);
420
+ if (/\bsigkill\b|\bKilled\b|out of memory|JavaScript heap out of memory|Allocation failed/i.test(
421
+ tail
422
+ )) {
423
+ return "Build process was killed - typically because the target ran out of memory during the build. Increase RAM on the target, add swap, or build locally and ship the dist.";
424
+ }
425
+ return null;
426
+ }
427
+
428
+ // ../../packages/adapters/src/runtime/managed-artifact.ts
429
+ var MANAGED_ARTIFACT_BASE = "/opt/kraft";
430
+ var PROTECTED_ROOTS = /* @__PURE__ */ new Set([
431
+ MANAGED_ARTIFACT_BASE,
432
+ // BareRuntime's own layout (workDir = MANAGED_ARTIFACT_BASE): releases/<depId>,
433
+ // .builds/<sessionId>. The parents hold every project's releases at once.
434
+ `${MANAGED_ARTIFACT_BASE}/releases`,
435
+ `${MANAGED_ARTIFACT_BASE}/.builds`,
436
+ // The static tree, whose parent is ALSO the one directory bind-mounted into the
437
+ // edge container — removing it stops the box serving every static site it hosts.
438
+ `${MANAGED_ARTIFACT_BASE}/static`,
439
+ `${MANAGED_ARTIFACT_BASE}/static/releases`,
440
+ `${MANAGED_ARTIFACT_BASE}/static/.builds`
441
+ ]);
442
+ function canonical(ref) {
443
+ const trimmed = ref.trim();
444
+ return trimmed.length > 1 ? trimmed.replace(/\/+$/, "") : trimmed;
445
+ }
446
+ function assertManagedArtifactPath(ref) {
447
+ const target = canonical(ref);
448
+ if (!target.startsWith("/") || target.includes("..")) {
449
+ throw new Error(
450
+ `Refusing to remove "${ref}": an artifact path must be absolute and free of "..".`
451
+ );
452
+ }
453
+ if (PROTECTED_ROOTS.has(target)) {
454
+ throw new Error(
455
+ `Refusing to remove "${ref}": that is a shared parent directory, not one deployment's output.`
456
+ );
457
+ }
458
+ if (target !== MANAGED_ARTIFACT_BASE && !target.startsWith(`${MANAGED_ARTIFACT_BASE}/`)) {
459
+ throw new Error(
460
+ `Refusing to remove "${ref}": outside ${MANAGED_ARTIFACT_BASE}. Kraft removes only directories it created (release dirs, static doc-roots, build dirs).`
461
+ );
462
+ }
463
+ }
464
+ async function removeManagedArtifact(executor, ref) {
465
+ assertManagedArtifactPath(ref);
466
+ const target = canonical(ref);
467
+ if (executor) {
468
+ await executor.exec(`rm -rf ${sq(target)}`);
469
+ if (await executor.exists(target)) {
470
+ throw new Error(
471
+ `Failed to remove ${target}: still present after rm -rf.`
472
+ );
473
+ }
474
+ return;
475
+ }
476
+ const { rm: rm2, access: access2 } = await import("fs/promises");
477
+ await rm2(target, { recursive: true, force: true });
478
+ const stillThere = await access2(target).then(
479
+ () => true,
480
+ () => false
481
+ );
482
+ if (stillThere)
483
+ throw new Error(`Failed to remove ${target}: still present after rm.`);
484
+ }
485
+ function isArtifactPathRef(ref) {
486
+ return ref.startsWith("/");
487
+ }
488
+
489
+ // ../../packages/adapters/src/runtime/docker-paths.ts
490
+ import { access, readdir } from "fs/promises";
491
+ import { isAbsolute, join, relative, resolve, sep } from "path";
492
+ function toPosixPath(value) {
493
+ return value.split(sep).filter(Boolean).join("/");
494
+ }
495
+ function toSafeSegments(value, label) {
496
+ const segments = value.split(/[\\/]/).filter((segment) => segment && segment !== ".");
497
+ if (segments.includes("..")) {
498
+ throw new Error(
499
+ `Invalid ${label} ${JSON.stringify(value)}: path segments must not contain "..".`
500
+ );
501
+ }
502
+ return segments;
503
+ }
504
+ function normalizeDockerRelativePath(value) {
505
+ const normalized = value?.trim().replace(/^\.\//, "").replace(/^\/+|\/+$/g, "");
506
+ if (!normalized || normalized === ".") {
507
+ return "";
508
+ }
509
+ return toSafeSegments(normalized, "path").join("/");
510
+ }
511
+ function resolveWithinDirectory(baseDir, relativePath) {
512
+ const base = resolve(baseDir);
513
+ const target = resolve(
514
+ base,
515
+ ...toSafeSegments(relativePath?.trim() ?? "", "path")
516
+ );
517
+ const escape = relative(base, target);
518
+ if (escape === ".." || escape.startsWith(`..${sep}`) || isAbsolute(escape)) {
519
+ throw new Error(
520
+ `Resolved path ${JSON.stringify(target)} escapes ${JSON.stringify(base)}.`
521
+ );
522
+ }
523
+ return target;
524
+ }
525
+ function normalizeDockerRootDirectory(rootDirectory, localPath) {
526
+ let normalized = rootDirectory?.trim() ?? "";
527
+ if (!normalized) {
528
+ return "";
529
+ }
530
+ if (localPath && isAbsolute(normalized)) {
531
+ const relativePath = relative(localPath, normalized);
532
+ if (!relativePath || relativePath === ".") {
533
+ return "";
534
+ }
535
+ if (!relativePath.startsWith("..") && !isAbsolute(relativePath)) {
536
+ normalized = relativePath;
537
+ }
538
+ }
539
+ normalized = normalized.replace(/^\.\//, "").replace(/^\/+|\/+$/g, "");
540
+ if (!normalized || normalized === ".") {
541
+ return "";
542
+ }
543
+ return toSafeSegments(normalized, "rootDirectory").join("/");
544
+ }
545
+ function resolveExplicitDockerfileCandidate(rootDirectory, dockerfilePath) {
546
+ const normalizedRootDirectory = normalizeDockerRelativePath(rootDirectory);
547
+ const normalizedDockerfilePath = normalizeDockerRelativePath(dockerfilePath);
548
+ if (!normalizedDockerfilePath) {
549
+ return "";
550
+ }
551
+ if (!normalizedRootDirectory) {
552
+ return normalizedDockerfilePath;
553
+ }
554
+ if (normalizedDockerfilePath.startsWith(`${normalizedRootDirectory}/`)) {
555
+ return normalizedDockerfilePath;
556
+ }
557
+ return `${normalizedRootDirectory}/${normalizedDockerfilePath}`;
558
+ }
559
+ function resolveDockerfileCandidates(rootDirectory, explicitDockerfilePath) {
560
+ const normalizedRootDirectory = normalizeDockerRelativePath(rootDirectory);
561
+ return [
562
+ resolveExplicitDockerfileCandidate(rootDirectory, explicitDockerfilePath),
563
+ normalizedRootDirectory ? `${normalizedRootDirectory}/Dockerfile` : "Dockerfile",
564
+ "Dockerfile"
565
+ ].filter(
566
+ (candidate, index, values) => Boolean(candidate) && values.indexOf(candidate) === index
567
+ );
568
+ }
569
+ function dockerBuildContextDirectory(config) {
570
+ return normalizeDockerRelativePath(config.buildContextDirectory);
571
+ }
572
+ function resolveContextDockerfileCandidates(contextDirectory, explicitDockerfilePath) {
573
+ const context = normalizeDockerRelativePath(contextDirectory);
574
+ const explicit = normalizeDockerRelativePath(explicitDockerfilePath);
575
+ const candidates = [];
576
+ if (explicit) {
577
+ candidates.push(explicit);
578
+ if (context && explicit.startsWith(`${context}/`)) {
579
+ candidates.push(explicit.slice(context.length + 1));
580
+ }
581
+ }
582
+ candidates.push("Dockerfile");
583
+ return candidates.filter(
584
+ (candidate, index, values) => Boolean(candidate) && values.indexOf(candidate) === index
585
+ );
586
+ }
587
+ var ROOT_MANIFESTS = [
588
+ "package.json",
589
+ "pyproject.toml",
590
+ "requirements.txt",
591
+ "Pipfile",
592
+ "go.mod",
593
+ "Cargo.toml",
594
+ "Gemfile",
595
+ "composer.json",
596
+ "pom.xml",
597
+ "build.gradle",
598
+ "build.gradle.kts",
599
+ "mix.exs",
600
+ "Dockerfile"
601
+ ];
602
+ var IGNORED_DIRS = /* @__PURE__ */ new Set([
603
+ "node_modules",
604
+ ".git",
605
+ ".next",
606
+ ".nuxt",
607
+ ".output",
608
+ ".turbo",
609
+ ".venv",
610
+ "__pycache__",
611
+ "build",
612
+ "dist",
613
+ "target",
614
+ "vendor"
615
+ ]);
616
+ async function pathExists(path) {
617
+ return access(path).then(() => true).catch(() => false);
618
+ }
619
+ async function manifestCount(dir) {
620
+ let count = 0;
621
+ for (const file of ROOT_MANIFESTS) {
622
+ if (await pathExists(join(dir, file))) {
623
+ count += 1;
624
+ }
625
+ }
626
+ return count;
627
+ }
628
+ function pathSegments(path) {
629
+ return path.toLowerCase().split("/").filter(Boolean);
630
+ }
631
+ function scorePathHints(relativePath) {
632
+ const segments = pathSegments(relativePath);
633
+ let score = 0;
634
+ for (const segment of segments) {
635
+ if ([
636
+ "app",
637
+ "apps",
638
+ "site",
639
+ "sites",
640
+ "web",
641
+ "www",
642
+ "service",
643
+ "services"
644
+ ].includes(segment)) {
645
+ score += 12;
646
+ }
647
+ if (["docs", "example", "examples", "test", "tests", "storybook"].includes(
648
+ segment
649
+ )) {
650
+ score -= 18;
651
+ }
652
+ }
653
+ return score;
654
+ }
655
+ async function scoreCandidate(dir, relativePath) {
656
+ let score = scorePathHints(relativePath);
657
+ score += await manifestCount(dir) * 20;
658
+ if (relativePath) {
659
+ score += 6;
660
+ }
661
+ return score;
662
+ }
663
+ async function collectCandidates(rootDir, currentDir, depth, candidates) {
664
+ const relativePath = toPosixPath(relative(rootDir, currentDir));
665
+ if (await manifestCount(currentDir) > 0) {
666
+ candidates.push({
667
+ path: relativePath,
668
+ score: await scoreCandidate(currentDir, relativePath)
669
+ });
670
+ }
671
+ if (depth >= 6) {
672
+ return;
673
+ }
674
+ const entries = await readdir(currentDir, { withFileTypes: true }).catch(
675
+ () => []
676
+ );
677
+ for (const entry of entries) {
678
+ if (!entry.isDirectory() || IGNORED_DIRS.has(entry.name)) {
679
+ continue;
680
+ }
681
+ await collectCandidates(
682
+ rootDir,
683
+ join(currentDir, entry.name),
684
+ depth + 1,
685
+ candidates
686
+ );
687
+ }
688
+ }
689
+ async function resolveDockerRootDirectory(contextDir, rootDirectory, localPath) {
690
+ const hasExplicitRootDirectory = typeof rootDirectory === "string";
691
+ const normalized = normalizeDockerRootDirectory(rootDirectory, localPath);
692
+ if (hasExplicitRootDirectory) {
693
+ return normalized;
694
+ }
695
+ if (normalized) {
696
+ return normalized;
697
+ }
698
+ const candidates = [];
699
+ await collectCandidates(contextDir, contextDir, 0, candidates);
700
+ if (candidates.length === 0) {
701
+ return "";
702
+ }
703
+ candidates.sort((left, right) => right.score - left.score);
704
+ const bestNonRoot = candidates.find((candidate) => candidate.path);
705
+ if (bestNonRoot && bestNonRoot.score > 0) {
706
+ return bestNonRoot.path;
707
+ }
708
+ return candidates[0]?.path ?? "";
709
+ }
710
+
711
+ // ../../packages/adapters/src/runtime/docker-build-plan.ts
712
+ var DOCKER_BUILD_EVENT_PREFIX = "[kraft-build]";
713
+ var INLINE_BUILD_ENV_EXCLUDES = /* @__PURE__ */ new Set(["FORCE_COLOR", "TERM", "PATH"]);
714
+ function formatDockerBuildEvent(step, status) {
715
+ return `${DOCKER_BUILD_EVENT_PREFIX} step=${step} status=${status}`;
716
+ }
717
+ function normalizeRelativePath(value) {
718
+ const normalized = value?.trim().replace(/^\.\//, "").replace(/^\/+|\/+$/g, "");
719
+ if (!normalized || normalized === ".") {
720
+ return "";
721
+ }
722
+ return normalized;
723
+ }
724
+ function builderSourceDir(rootDirectory) {
725
+ const normalized = normalizeDockerRootDirectory(rootDirectory);
726
+ return normalized ? `/workspace/${normalized}` : "/workspace";
727
+ }
728
+ function buildEnvPrefix(envVars) {
729
+ const assignments = Object.entries(envVars).filter(([key]) => !INLINE_BUILD_ENV_EXCLUDES.has(key)).filter(([key]) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(key)).map(([key, value]) => `${key}=${sq2(value)}`);
730
+ if (!envVars.NO_COLOR) {
731
+ assignments.push("NO_COLOR='1'");
732
+ }
733
+ if (assignments.length === 0) {
734
+ return "";
735
+ }
736
+ return `export ${assignments.join(" ")} && `;
737
+ }
738
+ function buildRunCommand(command, envPrefix) {
739
+ return `${envPrefix}${command}`;
740
+ }
741
+ function runtimeCopyDirectives(config, sourceDir) {
742
+ if (config.productionPaths && config.productionPaths.length > 0) {
743
+ return config.productionPaths.map((path) => {
744
+ const normalized = normalizeRelativePath(path);
745
+ const source = normalized ? `${sourceDir}/${normalized}` : sourceDir;
746
+ const target = normalized ? `/app/${normalized}` : "/app";
747
+ return `COPY --from=builder ${source} ${target}`;
748
+ });
749
+ }
750
+ return [`COPY --from=builder ${sourceDir} /app`];
751
+ }
752
+ function needsMultiStage(config) {
753
+ return config.buildImage !== config.runtimeImage;
754
+ }
755
+ function nodeBinPathEnvLine(packageManager, roots) {
756
+ const dirs = nodeBinDirs(packageManager, roots);
757
+ return dirs.length > 0 ? `ENV PATH="${dirs.join(":")}:$PATH"` : null;
758
+ }
759
+ function workspacePrepareRunLine(config, envPrefix, workspacePrepare) {
760
+ const pmEnsure = packageManagerEnsureCommand(config.packageManager);
761
+ const body = pmEnsure ? `${pmEnsure} && ${workspacePrepare}` : workspacePrepare;
762
+ return `RUN ${envPrefix}${body}`;
763
+ }
764
+ function stepsRunLine(config, envPrefix, opts) {
765
+ const install = opts.install ? config.installCommand : "";
766
+ const build = opts.build ? config.buildCommand : "";
767
+ const steps = [];
768
+ const pmEnsure = packageManagerEnsureCommand(
769
+ opts.packageManager ?? config.packageManager
770
+ );
771
+ if (pmEnsure && (install || build)) {
772
+ steps.push(pmEnsure);
773
+ }
774
+ if (install) {
775
+ steps.push(`printf '${formatDockerBuildEvent("install", "running")}\\n'`);
776
+ steps.push(buildRunCommand(install, envPrefix));
777
+ steps.push(`printf '${formatDockerBuildEvent("install", "completed")}\\n'`);
778
+ }
779
+ if (build) {
780
+ steps.push(`printf '${formatDockerBuildEvent("build", "running")}\\n'`);
781
+ steps.push(buildRunCommand(build, envPrefix));
782
+ steps.push(`printf '${formatDockerBuildEvent("build", "completed")}\\n'`);
783
+ }
784
+ return steps.length > 0 ? `RUN ${steps.join(" && ")}` : null;
785
+ }
786
+ function installBuildRunLine(config, envPrefix) {
787
+ return stepsRunLine(config, envPrefix, { install: true, build: true });
788
+ }
789
+ function installRunLine(config, envPrefix) {
790
+ return stepsRunLine(config, envPrefix, { install: true });
791
+ }
792
+ var JS_PACKAGE_MANAGERS = ["pnpm", "yarn", "bun", "npm"];
793
+ function assetStagePackageManager(config) {
794
+ const command = config.buildCommand?.trim() ?? "";
795
+ return JS_PACKAGE_MANAGERS.find(
796
+ (pm) => new RegExp(`(^|\\s|&&\\s*)${pm}\\s`).test(command)
797
+ ) ?? "npm";
798
+ }
799
+ function buildOnlyRunLine(config, envPrefix) {
800
+ const command = config.buildCommand?.trim() ?? "";
801
+ const packageManager = JS_PACKAGE_MANAGERS.find(
802
+ (pm) => new RegExp(`(^|\\s|&&\\s*)${pm}\\s`).test(command)
803
+ );
804
+ return stepsRunLine(config, envPrefix, { build: true, packageManager });
805
+ }
806
+ function isPhpRuntime(config) {
807
+ return /^php:/.test(config.runtimeImage) || /frankenphp/i.test(config.runtimeImage);
808
+ }
809
+ var PHP_EXTENSIONS = [
810
+ "pdo_mysql",
811
+ "pdo_pgsql",
812
+ "redis",
813
+ "pcntl",
814
+ "bcmath",
815
+ "intl",
816
+ "zip",
817
+ "gd",
818
+ "opcache"
819
+ ];
820
+ var PHP_EXT_INSTALLER_IMAGE = "mlocati/php-extension-installer:2";
821
+ var PHP_ASSET_BUILD_IMAGE = "node:22-bookworm-slim";
822
+ var PHP_EXT_INSTALL_LINE = `RUN install-php-extensions ${PHP_EXTENSIONS.join(" ")} > /dev/null`;
823
+ function generatePhpDockerfile(config) {
824
+ const sourceDir = builderSourceDir(
825
+ normalizeDockerRootDirectory(config.rootDirectory, config.localPath)
826
+ );
827
+ const envPrefix = buildEnvPrefix(config.envVars);
828
+ const installLine = installRunLine(config, envPrefix);
829
+ const assetBuildLine = buildOnlyRunLine(config, envPrefix);
830
+ const lines = [
831
+ `FROM ${config.buildImage} AS builder`,
832
+ // php:*-cli ships no Composer — pull the binary from the official image.
833
+ `COPY --from=composer:2 /usr/bin/composer /usr/bin/composer`,
834
+ `COPY --from=${PHP_EXT_INSTALLER_IMAGE} /usr/bin/install-php-extensions /usr/bin/install-php-extensions`,
835
+ PHP_EXT_INSTALL_LINE,
836
+ `WORKDIR /workspace`,
837
+ `COPY . /workspace`,
838
+ `WORKDIR ${sourceDir}`
839
+ ];
840
+ if (installLine) lines.push(installLine);
841
+ if (assetBuildLine) {
842
+ const assetBinPath = nodeBinPathEnvLine(assetStagePackageManager(config), [
843
+ sourceDir,
844
+ "/workspace"
845
+ ]);
846
+ lines.push(
847
+ `FROM ${PHP_ASSET_BUILD_IMAGE} AS assets`,
848
+ ...assetBinPath ? [assetBinPath] : [],
849
+ `WORKDIR /workspace`,
850
+ `COPY . /workspace`,
851
+ `WORKDIR ${sourceDir}`,
852
+ assetBuildLine
853
+ );
854
+ }
855
+ const docroot = normalizeRelativePath(config.outputDirectory) || "public";
856
+ lines.push(
857
+ `FROM ${config.runtimeImage} AS runtime`,
858
+ PHP_EXT_INSTALL_LINE,
859
+ // --chown on the COPY instead of a trailing `chown -R`: the recursive form
860
+ // rewrites every file into a second layer, doubling the app's size on disk.
861
+ // Ownership has to be settled HERE, before anything mounts: Docker seeds a
862
+ // fresh named volume from the image directory it covers, ownership included,
863
+ // so `/app/storage` is only writable by the runtime user if it was already
864
+ // owned by them in the image (see @repo/core volumes.ts).
865
+ `COPY --from=builder --chown=www-data:www-data ${sourceDir} /app`
866
+ );
867
+ if (assetBuildLine) {
868
+ lines.push(
869
+ `COPY --from=assets --chown=www-data:www-data ${sourceDir}/${docroot} /app/${docroot}`
870
+ );
871
+ }
872
+ lines.push(
873
+ `WORKDIR /app`,
874
+ // FrankenPHP's bundled Caddyfile reads the docroot from SERVER_ROOT (default
875
+ // `public/`, resolved against WORKDIR). Setting it keeps the project's
876
+ // outputDirectory authoritative for BOTH what gets served and where the asset
877
+ // stage's output lands — otherwise a project that renamed its docroot builds
878
+ // assets into one directory and serves another.
879
+ `ENV SERVER_ROOT=${docroot}/`,
880
+ // Caddy's config + data dirs are root-owned in the base image, and it writes
881
+ // to both on startup — without this the non-root switch below fails at boot.
882
+ `RUN mkdir -p /data/caddy /config/caddy && chown -R www-data:www-data /data/caddy /config/caddy`,
883
+ // The frankenphp binary carries cap_net_bind_service, so dropping root here
884
+ // still leaves any port bindable.
885
+ `USER www-data`,
886
+ `EXPOSE ${config.port}`
887
+ );
888
+ if (config.startCommand) {
889
+ lines.push(`CMD ["sh", "-c", ${JSON.stringify(config.startCommand)}]`);
890
+ }
891
+ return lines.join("\n");
892
+ }
893
+ function staticNginxTemplateLines(port) {
894
+ return [
895
+ "server {",
896
+ ` listen ${port} default_server;`,
897
+ " root /usr/share/nginx/html;",
898
+ " index index.html;",
899
+ " location / { try_files $uri $uri/ /index.html; }",
900
+ "}"
901
+ ];
902
+ }
903
+ function builderContextRoot(config) {
904
+ return builderSourceDir(
905
+ normalizeDockerRootDirectory(config.rootDirectory, config.localPath)
906
+ );
907
+ }
908
+ function isExcludedDocRootEntry(name) {
909
+ return name === ".dockerignore" || name === ".git" || name === "Dockerfile" || name.startsWith("Dockerfile.");
910
+ }
911
+ function staticBuilderOutputPath(config) {
912
+ const sourceDir = builderSourceDir(
913
+ normalizeDockerRootDirectory(config.rootDirectory, config.localPath)
914
+ );
915
+ const output = normalizeRelativePath(config.outputDirectory);
916
+ return output ? `${sourceDir}/${output}` : sourceDir;
917
+ }
918
+ function generateStaticDockerfile(config) {
919
+ const sourceDir = builderSourceDir(
920
+ normalizeDockerRootDirectory(config.rootDirectory, config.localPath)
921
+ );
922
+ const envPrefix = buildEnvPrefix(config.envVars);
923
+ const workspacePrepare = config.workspacePrepareCommand?.trim();
924
+ const outputPath = staticBuilderOutputPath(config);
925
+ const nginxTemplate = staticNginxTemplateLines(config.port).map((line) => `'${line}'`).join(" ");
926
+ const lines = [`FROM ${config.buildImage} AS builder`];
927
+ const buildBinPath = nodeBinPathEnvLine(config.packageManager, [
928
+ sourceDir,
929
+ "/workspace"
930
+ ]);
931
+ if (buildBinPath) lines.push(buildBinPath);
932
+ lines.push(`WORKDIR /workspace`, `COPY . /workspace`);
933
+ if (workspacePrepare) {
934
+ lines.push(workspacePrepareRunLine(config, envPrefix, workspacePrepare));
935
+ }
936
+ lines.push(`WORKDIR ${sourceDir}`);
937
+ const stepsLine = installBuildRunLine(config, envPrefix);
938
+ if (stepsLine) lines.push(stepsLine);
939
+ if (config.staticExtractOnly) return lines.join("\n");
940
+ lines.push(
941
+ `FROM nginx:alpine AS runtime`,
942
+ `RUN rm -f /etc/nginx/conf.d/default.conf`,
943
+ `COPY --from=builder ${outputPath} /usr/share/nginx/html`,
944
+ `RUN printf '%s\\n' ${nginxTemplate} > /etc/nginx/conf.d/app.conf`,
945
+ `EXPOSE ${config.port}`,
946
+ `CMD ["nginx", "-g", "daemon off;"]`
947
+ );
948
+ return lines.join("\n");
949
+ }
950
+ function generateDockerfile(config) {
951
+ if (config.isStatic) {
952
+ return generateStaticDockerfile(config);
953
+ }
954
+ if (isPhpRuntime(config) && needsMultiStage(config)) {
955
+ return generatePhpDockerfile(config);
956
+ }
957
+ const sourceDir = builderSourceDir(
958
+ normalizeDockerRootDirectory(config.rootDirectory, config.localPath)
959
+ );
960
+ const multiStage = needsMultiStage(config);
961
+ const envPrefix = buildEnvPrefix(config.envVars);
962
+ const workspacePrepare = config.workspacePrepareCommand?.trim();
963
+ const lines = [
964
+ multiStage ? `FROM ${config.buildImage} AS builder` : `FROM ${config.runtimeImage}`
965
+ ];
966
+ const buildBinPath = nodeBinPathEnvLine(config.packageManager, [
967
+ sourceDir,
968
+ "/workspace"
969
+ ]);
970
+ if (buildBinPath) lines.push(buildBinPath);
971
+ lines.push(`WORKDIR /workspace`, `COPY . /workspace`);
972
+ if (workspacePrepare) {
973
+ lines.push(workspacePrepareRunLine(config, envPrefix, workspacePrepare));
974
+ }
975
+ lines.push(`WORKDIR ${sourceDir}`);
976
+ const stepsLine = installBuildRunLine(config, envPrefix);
977
+ if (stepsLine) {
978
+ lines.push(stepsLine);
979
+ }
980
+ if (multiStage) {
981
+ lines.push(`FROM ${config.runtimeImage} AS runtime`);
982
+ lines.push(...runtimeCopyDirectives(config, sourceDir));
983
+ lines.push(`WORKDIR /app`);
984
+ const runtimeBinPath = nodeBinPathEnvLine(config.packageManager, ["/app"]);
985
+ if (runtimeBinPath) lines.push(runtimeBinPath);
986
+ }
987
+ lines.push(`EXPOSE ${config.port}`);
988
+ if (config.startCommand) {
989
+ lines.push(`CMD ["sh", "-c", ${JSON.stringify(config.startCommand)}]`);
990
+ }
991
+ return lines.join("\n");
992
+ }
993
+
994
+ // ../../packages/adapters/src/runtime/transfer.ts
995
+ async function transferLocalDirectory(localPath, target, logger, options) {
996
+ logger.log(`Transferring ${localPath} \u2192 ${target.path}...
997
+ `);
998
+ await target.executor.transferIn(localPath, target.path, logger.callback, {
999
+ excludes: options?.excludes,
1000
+ includes: options?.includes,
1001
+ alsoInclude: options?.alsoInclude
1002
+ });
1003
+ await verifyExecutorTransfer(target.executor, target.path, logger);
1004
+ }
1005
+ async function verifyExecutorTransfer(executor, targetPath, logger) {
1006
+ try {
1007
+ const countOutput = await executor.exec(
1008
+ `find ${sq2(targetPath)} -mindepth 1 -maxdepth 1 | head -5 | wc -l`
1009
+ );
1010
+ const fileCount = parseInt(countOutput.trim(), 10);
1011
+ if (fileCount === 0) {
1012
+ throw new Error(
1013
+ `Transfer target ${targetPath} is empty - files were not copied`
1014
+ );
1015
+ }
1016
+ logger.log(`Transfer verified (${fileCount}+ entries in target).
1017
+ `);
1018
+ } catch (err) {
1019
+ if (err instanceof Error && err.message.includes("is empty")) throw err;
1020
+ throw new Error(`Transfer verification failed: ${safeErrorMessage(err)}`);
1021
+ }
1022
+ }
1023
+
1024
+ // ../../packages/adapters/src/runtime/runtime-env.ts
1025
+ var RUNTIME_ENV_EXCLUDES = /* @__PURE__ */ new Set(["PATH"]);
1026
+ function splitRuntimeEnv(envVars) {
1027
+ const entries = [];
1028
+ const dropped = [];
1029
+ for (const [key, value] of Object.entries(envVars)) {
1030
+ if (RUNTIME_ENV_EXCLUDES.has(key)) dropped.push(key);
1031
+ else entries.push([key, value]);
1032
+ }
1033
+ return { entries, dropped };
1034
+ }
1035
+ function droppedRuntimeEnvMessage(dropped) {
1036
+ if (dropped.length === 0) return "";
1037
+ return `Ignoring ${dropped.join(", ")} from this project's environment: it would replace the runtime's own value and stop the start command from resolving. Remove it to silence this.
1038
+ `;
1039
+ }
1040
+
1041
+ export {
1042
+ sq2 as sq,
1043
+ assembleGitClone,
1044
+ gitShellCommand,
1045
+ materializeGitSsh,
1046
+ shellGitSshWriter,
1047
+ localGitSshWriter,
1048
+ BuildLogger,
1049
+ BuildCancelledError,
1050
+ killProcessesUnderDir,
1051
+ runBuildPipeline,
1052
+ parseLogLevel,
1053
+ detectBuildKillHint,
1054
+ removeManagedArtifact,
1055
+ isArtifactPathRef,
1056
+ normalizeDockerRelativePath,
1057
+ resolveWithinDirectory,
1058
+ resolveDockerfileCandidates,
1059
+ dockerBuildContextDirectory,
1060
+ resolveContextDockerfileCandidates,
1061
+ resolveDockerRootDirectory,
1062
+ builderContextRoot,
1063
+ isExcludedDocRootEntry,
1064
+ staticBuilderOutputPath,
1065
+ generateDockerfile,
1066
+ transferLocalDirectory,
1067
+ splitRuntimeEnv,
1068
+ droppedRuntimeEnvMessage
1069
+ };