@stacksjs/ts-cloud 0.16.90 → 0.16.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aws/client.d.ts +3 -5
- package/dist/aws/credentials.d.ts +9 -4
- package/dist/aws/index.js +1 -1
- package/dist/bin/{chunk-52snxrsx.js → chunk-00arzt4m.js} +97 -97
- package/dist/bin/chunk-0b6rv9dt.js +1 -0
- package/dist/bin/chunk-0qzt0swj.js +5 -0
- package/dist/bin/chunk-0rvzy2z7.js +1 -0
- package/dist/bin/{chunk-z9g7fa1w.js → chunk-0zepgwq9.js} +2 -2
- package/dist/bin/chunk-11hc309t.js +1 -0
- package/dist/bin/{chunk-qmwqntnx.js → chunk-1p7rtk98.js} +2 -2
- package/dist/bin/{chunk-qpasspad.js → chunk-32dr1fym.js} +5 -5
- package/dist/bin/{chunk-v3trt4q1.js → chunk-3h7gmatb.js} +3 -3
- package/dist/bin/{chunk-69mejej3.js → chunk-407wz1f4.js} +1 -1
- package/dist/bin/{chunk-xycxw00z.js → chunk-42nh9ac7.js} +8 -8
- package/dist/bin/chunk-49zcdbn0.js +1 -0
- package/dist/bin/chunk-4gv5j5s1.js +1 -0
- package/dist/bin/{chunk-gn7rdyz7.js → chunk-4kka906v.js} +2 -2
- package/dist/bin/{chunk-jqs2ywj2.js → chunk-55mv5w3m.js} +2 -2
- package/dist/bin/{chunk-4mep3m41.js → chunk-57yxbyh6.js} +5 -5
- package/dist/bin/chunk-5nfhjr0h.js +1 -0
- package/dist/bin/chunk-5njr2s5x.js +1 -0
- package/dist/bin/chunk-6qhgzf9a.js +1 -0
- package/dist/bin/{chunk-bycbwddj.js → chunk-6ty1wegm.js} +2 -2
- package/dist/bin/chunk-8ctmc30y.js +14 -0
- package/dist/bin/chunk-9g4qsx30.js +1 -0
- package/dist/bin/chunk-afvk9mbs.js +1 -0
- package/dist/bin/{chunk-9bmaq8q7.js → chunk-cb0yqrpk.js} +111 -113
- package/dist/bin/{chunk-bxks81wn.js → chunk-chx779q9.js} +3 -3
- package/dist/bin/chunk-ckbv6y4c.js +1 -0
- package/dist/bin/{chunk-6b6yr784.js → chunk-drc9y2fj.js} +2 -2
- package/dist/bin/chunk-eb591jvz.js +1 -0
- package/dist/bin/{chunk-b1cb27m8.js → chunk-eqqqbsjm.js} +7 -7
- package/dist/bin/{chunk-cgyk48s5.js → chunk-fcst782q.js} +1 -1
- package/dist/bin/{chunk-19mhwmfp.js → chunk-fmgv99xw.js} +1 -1
- package/dist/bin/{chunk-0e56zmps.js → chunk-g1s5s95g.js} +2 -2
- package/dist/bin/{chunk-ye2gymsr.js → chunk-gkgqss71.js} +3 -3
- package/dist/bin/chunk-gvacnz2y.js +1 -0
- package/dist/bin/{chunk-em9swj0k.js → chunk-h99kxww0.js} +1 -1
- package/dist/bin/chunk-j1dbkpha.js +1 -0
- package/dist/bin/{chunk-zfn3a9sx.js → chunk-j34ask5s.js} +2 -2
- package/dist/bin/{chunk-f7jzs1h1.js → chunk-j7j7gffr.js} +5 -5
- package/dist/bin/chunk-jjw5d8b9.js +1 -0
- package/dist/bin/{chunk-1wgyq50e.js → chunk-kbtx3q9m.js} +29 -30
- package/dist/bin/{chunk-t0r1rdj2.js → chunk-kdjrcvr6.js} +2 -2
- package/dist/bin/{chunk-76ekkat8.js → chunk-kefwtr8r.js} +3 -3
- package/dist/bin/{chunk-v1a0b9yq.js → chunk-kp84kged.js} +16 -16
- package/dist/bin/chunk-m5tpfe3s.js +1 -0
- package/dist/bin/{chunk-83tt2t15.js → chunk-mrkrn8dk.js} +5 -5
- package/dist/bin/chunk-n6yvpj86.js +1 -0
- package/dist/bin/{chunk-bkx2kapc.js → chunk-ncj8dpdp.js} +2 -2
- package/dist/bin/{chunk-w40r35vn.js → chunk-p6swcv5y.js} +1 -1
- package/dist/bin/{chunk-ndvma07s.js → chunk-pat56kbr.js} +5 -5
- package/dist/bin/chunk-q2hg6hmg.js +1 -0
- package/dist/bin/chunk-qd1jfsam.js +1 -0
- package/dist/bin/{chunk-yf2drw7r.js → chunk-r1q343bm.js} +1 -1
- package/dist/bin/chunk-r50x03ws.js +1 -0
- package/dist/bin/chunk-rhncmffy.js +1 -0
- package/dist/bin/chunk-seh19g93.js +1 -0
- package/dist/bin/{chunk-35325988.js → chunk-sjzzx539.js} +2 -2
- package/dist/bin/chunk-sxfdxk39.js +1 -0
- package/dist/bin/chunk-ty2pdbz3.js +1 -0
- package/dist/bin/chunk-tyeessz3.js +1 -0
- package/dist/bin/{chunk-dkdgwm13.js → chunk-v72zwetk.js} +82 -82
- package/dist/bin/chunk-we82q71y.js +1 -0
- package/dist/bin/{chunk-zn9wmqd1.js → chunk-xhqfha32.js} +2 -2
- package/dist/bin/{chunk-89v3ec9n.js → chunk-xk8nrvjz.js} +1 -1
- package/dist/bin/{chunk-88s5w4yt.js → chunk-zpk7fn1s.js} +6 -6
- package/dist/bin/cli.js +216 -216
- package/dist/bin/dashboard-server.js +1 -1
- package/dist/bin/stacks-queue-worker.js +1 -1
- package/dist/bin/stacks-scheduler.js +1 -1
- package/dist/chunk-0v77443p.js +1 -0
- package/dist/{chunk-z56sccfh.js → chunk-1087xz1v.js} +2 -2
- package/dist/{chunk-c8kf2268.js → chunk-1psh3mhm.js} +29 -30
- package/dist/chunk-4khjjgd3.js +1 -0
- package/dist/{chunk-4pztf7ws.js → chunk-4m5gpp6w.js} +5 -5
- package/dist/{chunk-3bvhthfb.js → chunk-72p2tdpe.js} +115 -117
- package/dist/chunk-7d9ek8rc.js +5 -0
- package/dist/chunk-872fdms3.js +1 -0
- package/dist/{chunk-cq079p4a.js → chunk-9f18pebj.js} +6 -6
- package/dist/{chunk-vq8bejep.js → chunk-a77mhcs7.js} +3 -3
- package/dist/chunk-bazah9w0.js +1 -0
- package/dist/{chunk-tmp2ym80.js → chunk-by7hejhg.js} +1 -1
- package/dist/{chunk-ax320pn8.js → chunk-byr76jcy.js} +19 -19
- package/dist/{chunk-m35z9vyn.js → chunk-c6kb5c5v.js} +4 -4
- package/dist/{chunk-1c6rvba9.js → chunk-cjm5j58y.js} +136 -136
- package/dist/{chunk-gpgmp9dt.js → chunk-dmv3vryr.js} +10 -10
- package/dist/{chunk-5t92a838.js → chunk-fe6m7wb0.js} +45 -45
- package/dist/{chunk-py8dq1ey.js → chunk-fne338jr.js} +5 -5
- package/dist/{chunk-nftqsker.js → chunk-h6kptkce.js} +2 -2
- package/dist/{chunk-fdf181e6.js → chunk-hcbrgyfz.js} +2 -2
- package/dist/{chunk-9pwvnh3f.js → chunk-jz6dacx1.js} +2 -2
- package/dist/{chunk-fjs0wgyw.js → chunk-kcem6dzk.js} +2 -2
- package/dist/{chunk-4ccv5c4m.js → chunk-q7yf28cc.js} +1 -1
- package/dist/{chunk-jx1zz1pw.js → chunk-qra9k26f.js} +1 -1
- package/dist/chunk-qs7814ya.js +1 -0
- package/dist/chunk-sd5a61c6.js +1 -0
- package/dist/{bin/chunk-8rkfwgb4.js → chunk-sjfc9my3.js} +7 -7
- package/dist/{chunk-84z2a1xn.js → chunk-sxqe8e9c.js} +7 -7
- package/dist/{chunk-g0bh9atv.js → chunk-t1wq0ckc.js} +2 -2
- package/dist/{chunk-c71hhcsb.js → chunk-tpvmpmxj.js} +1 -1
- package/dist/{chunk-tr54e9c0.js → chunk-x7cnfn7y.js} +2 -2
- package/dist/{chunk-fpad8xw9.js → chunk-xs9m0v31.js} +4 -4
- package/dist/chunk-zft558kj.js +1 -0
- package/dist/{chunk-fdby0vq9.js → chunk-zjkxhvn0.js} +100 -100
- package/dist/{chunk-e75dvdqf.js → chunk-zwayp7fz.js} +2 -2
- package/dist/{chunk-gdw52mn4.js → chunk-zy3kr4s2.js} +3 -3
- package/dist/deploy/index.js +1 -1
- package/dist/dns/index.js +1 -1
- package/dist/drivers/index.js +1 -1
- package/dist/index.js +31 -31
- package/dist/mail/index.js +2 -2
- package/dist/operations/index.js +1 -1
- package/dist/protection/index.js +1 -1
- package/dist/spend/index.js +1 -1
- package/dist/ui/404.html +1 -1
- package/dist/ui/accept-invitation.html +1 -1
- package/dist/ui/access-denied.html +1 -1
- package/dist/ui/account/automation.html +6 -6
- package/dist/ui/account/security.html +2 -2
- package/dist/ui/applications/compose.html +6 -6
- package/dist/ui/applications/new.html +2 -2
- package/dist/ui/data/backups.html +5 -5
- package/dist/ui/data/services.html +6 -6
- package/dist/ui/data/volumes.html +6 -6
- package/dist/ui/index.html +6 -6
- package/dist/ui/infrastructure/topology.html +5 -5
- package/dist/ui/integrations.html +2 -2
- package/dist/ui/operations/alerts.html +6 -6
- package/dist/ui/operations/configuration.html +6 -6
- package/dist/ui/operations/jobs.html +6 -6
- package/dist/ui/operations/maintenance.html +5 -5
- package/dist/ui/operations/observability.html +6 -6
- package/dist/ui/operations/previews.html +6 -6
- package/dist/ui/operations/queue.html +6 -6
- package/dist/ui/operations/regions.html +5 -5
- package/dist/ui/operations/releases.html +6 -6
- package/dist/ui/operations/spend.html +6 -6
- package/dist/ui/operations/workloads.html +6 -6
- package/dist/ui/security.html +1 -1
- package/dist/ui/server/actions.html +6 -6
- package/dist/ui/server/activity.html +2 -2
- package/dist/ui/server/capacity.html +6 -6
- package/dist/ui/server/database.html +5 -5
- package/dist/ui/server/deployments.html +5 -5
- package/dist/ui/server/diagnostics.html +2 -2
- package/dist/ui/server/firewall.html +6 -6
- package/dist/ui/server/fleet.html +5 -5
- package/dist/ui/server/logs.html +6 -6
- package/dist/ui/server/metrics.html +5 -5
- package/dist/ui/server/security.html +2 -2
- package/dist/ui/server/services.html +1 -1
- package/dist/ui/server/sites.html +5 -5
- package/dist/ui/server/ssh-keys.html +6 -6
- package/dist/ui/server/team.html +6 -6
- package/dist/ui/server/terminal.html +2 -2
- package/dist/ui/serverless/alarms.html +6 -6
- package/dist/ui/serverless/assets.html +1 -1
- package/dist/ui/serverless/cost.html +2 -2
- package/dist/ui/serverless/data.html +6 -6
- package/dist/ui/serverless/deployments.html +2 -2
- package/dist/ui/serverless/firewall.html +1 -1
- package/dist/ui/serverless/functions.html +6 -6
- package/dist/ui/serverless/logs.html +6 -6
- package/dist/ui/serverless/metrics.html +2 -2
- package/dist/ui/serverless/queues.html +6 -6
- package/dist/ui/serverless/secrets.html +5 -5
- package/dist/ui/serverless/traces.html +6 -6
- package/dist/ui/serverless.html +6 -6
- package/package.json +3 -3
- package/dist/bin/chunk-1qez75tb.js +0 -1
- package/dist/bin/chunk-1rrmswhq.js +0 -1
- package/dist/bin/chunk-1vw6khps.js +0 -1
- package/dist/bin/chunk-2h1q758c.js +0 -2
- package/dist/bin/chunk-3rjer1mp.js +0 -1
- package/dist/bin/chunk-4k2x5x3k.js +0 -1
- package/dist/bin/chunk-5tzygzdy.js +0 -1
- package/dist/bin/chunk-6wvjr3ne.js +0 -1
- package/dist/bin/chunk-71fa7yed.js +0 -1
- package/dist/bin/chunk-7haewmr7.js +0 -1
- package/dist/bin/chunk-86w3vzx8.js +0 -1
- package/dist/bin/chunk-8tfqpp9m.js +0 -1
- package/dist/bin/chunk-9tt7ahdf.js +0 -1
- package/dist/bin/chunk-9zwvysdn.js +0 -1
- package/dist/bin/chunk-b9ersj22.js +0 -1
- package/dist/bin/chunk-btrxye8p.js +0 -6
- package/dist/bin/chunk-haezjam0.js +0 -1
- package/dist/bin/chunk-hp1cqk45.js +0 -1
- package/dist/bin/chunk-mwprtzxp.js +0 -1
- package/dist/bin/chunk-nemj07g1.js +0 -1
- package/dist/bin/chunk-nfxxr6g7.js +0 -1
- package/dist/bin/chunk-q3mtvtem.js +0 -1
- package/dist/bin/chunk-qpd51n1j.js +0 -1
- package/dist/bin/chunk-rtpc6djg.js +0 -1
- package/dist/bin/chunk-s9k81gq6.js +0 -1
- package/dist/bin/chunk-wrcdcg7m.js +0 -1
- package/dist/bin/chunk-ybekawxv.js +0 -1
- package/dist/bin/chunk-zrw80j07.js +0 -1
- package/dist/chunk-03gf4e58.js +0 -1
- package/dist/chunk-86qwnp25.js +0 -1
- package/dist/chunk-8kn7rszy.js +0 -1
- package/dist/chunk-928z0h9b.js +0 -14
- package/dist/chunk-crpbs450.js +0 -1
- package/dist/chunk-m9szynnf.js +0 -6
- package/dist/chunk-ncet7ba7.js +0 -1
- package/dist/chunk-nh7rcks9.js +0 -1
- package/dist/chunk-ypsfkgme.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{un,fr}from"./chunk-72p2tdpe.js";import{Wr,d}from"./chunk-x7cnfn7y.js";import{isIP as A}from"node:net";var yo="/etc/rpx/certs",N="/etc/rpx/local-ca",k="rpx-root-ca.crt";function So(e=N){return`${e.replace(/\/+$/,"")}/${k}`}function Io(e){if(e.toLowerCase().endsWith(".local"))return!1;return e.split(".").length===2}function bo(e,t={}){let r=new Set;for(let o of Object.values(e)){if(!o?.domain)continue;if(d(o)==="bucket")continue;r.add(o.domain)}let n=new Set;for(let o of Object.values(e)){if(!o?.domain||d(o)==="bucket")continue;for(let u of o.aliases??[]){let i=String(u).trim().toLowerCase();if(i&&i!==o.domain)n.add(i)}}if(t.autoWww!==!1)for(let o of[...r]){if(!Io(o))continue;r.add(`www.${o}`)}for(let o of n)r.add(o);return[...r]}var B=["1.1.1.1","8.8.8.8"],I="/var/www/acme-challenge";function W(e){if(typeof e==="string")return{to:e};let t={to:e.to};if(e.status!=null)t.status=e.status;if(e.preservePath!=null)t.preservePath=e.preservePath;return t}function G(e){let t=e.auth;if(!t||t.enabled===!1||!t.password)return;return{username:t.username||"admin",password:t.password,...t.realm?{realm:t.realm}:{}}}function yd(e){if(!e)return;return e.tls??"local-ca"}function Np(e,t){if(e.cloud?.provider!=="ssh")return;let r=e.ssh?.lan;if(!r)return;return{...r.hostname?{hostname:r.hostname}:{},tls:r.tls??"local-ca",...t?{ip:t}:{}}}function Bp(e){if(e.cloud?.provider!=="ssh")return;return e.ssh?.profile}function U(e){let t=e.trim().toLowerCase();if(!t||t.startsWith("*")||t.includes(":")||t.includes("/")||t.includes(" "))return!1;if(A(t)!==0)return!1;return t.endsWith(".local")||!t.includes(".")}function X(e,t,r){let n=[],o=new Set,u=(g,a)=>{let p=g.trim().toLowerCase();if(!p||o.has(p))return;o.add(p),n.push({host:p,source:a})},i=t.hostname?.trim(),c=(i||`${r}.local`).toLowerCase();if(u(c,i?"ssh.lan.hostname":`the ssh provider's default LAN name for project "${r}"`),Object.entries(e).some(([g,a])=>!!a&&fr(g)))u(`dashboard.${c}`,"the management dashboard site");for(let[g,a]of Object.entries(e)){if(!a?.domain)continue;if(d(a)==="bucket")continue;if(!U(a.domain))continue;u(a.domain,`site "${g}"`)}return n}function F(e,t){if(!t?.length)return;return t.find((r)=>{let n=(r.startsWith(".")?r.slice(1):r).toLowerCase();return e===n||e.endsWith(`.${n}`)})}function j(e,t){if(!t?.enabled)return;for(let{host:r,source:n}of e){let o=F(r,t.allowedSuffixes);if(!o)continue;throw Error(`The LAN certificate authority and public on-demand TLS both claim "${r}". LAN source: ${n}. Public source: the on-demand TLS allowed suffix "${o}", which is derived from the site domains. A host is either LAN-only, with a certificate signed by the box's own CA, or public, with one issued by Let's Encrypt, never both. Give the LAN a name no site domain covers (ssh.lan.hostname), or take that domain out of the sites this deploy routes.`)}}function H(e){let t=e.split(".");return t.length>=3&&t[0]==="*"&&t.slice(1).every((r)=>/^[a-z0-9-]+$/i.test(r))}function O(e,t={}){let{wildcardCerts:r,...n}=e;return JSON.stringify({...t,...n},null,2)}function lA(e){if(!e||e==="/")return;let t=`/${e}`.replace(/\/+/g,"/").replace(/\/+$/,"");if(!t.startsWith("/"))t=`/${t}`;return t===""||t==="/"?void 0:t}function Sd(e,t){let n=(t?`${e}${t}`:e).replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,128);return n.length>0?n:"rpx"}function Y(e,t){if(!t||t.length===0)return`localhost:${e}`;return t.map((r)=>`${r.privateIp??r.publicIp}:${e}`)}function M(e,t,r){let n=(t.wwwRoot??"/var/www").replace(/\/+$/,""),o=t.slug??"app",u=t.proxy.certsDir??yo,i=t.proxy.loadBalancer,c=[],f=new Set,g=new Map;for(let[l,s]of Object.entries(e)){if(!s||!s.domain)continue;let y=d(s);if(y==="bucket")continue;let E=c.length,T=[...new Set((s.aliases??[]).map((m)=>String(m).trim().toLowerCase()).filter((m)=>m&&m!==s.domain))],v=()=>{let m=c.slice(E).filter((h)=>h.to===s.domain);for(let h of T){for(let P of m)c.push({...P,to:h,id:Sd(h,P.path)});if(H(h)){if(!g.has(h))g.set(h,{domain:h,dnsEnvFile:`${n}/${o}-${l}/shared/.env`})}else f.add(h)}},S=lA(s.path),_=Sd(s.domain,S),C=G(s);if(y==="redirect"){c.push({to:s.domain,path:S,redirect:W(s.redirect),id:_,...C?{auth:C}:{}}),f.add(s.domain),v();continue}if(y==="proxy"){let m=Wr(s);if(m.length===0)continue;let h=m.length===1?m[0]:m;c.push({to:s.domain,path:S,from:h,id:_,...C?{auth:C}:{},...Array.isArray(h)&&i?{loadBalancer:i}:{}}),f.add(s.domain),v();continue}if(y==="server-app"){if(typeof s.port!=="number")continue;let m=Y(s.port,r);c.push({to:s.domain,path:S,from:m,id:_,...C?{auth:C}:{},...Array.isArray(m)&&i?{loadBalancer:i}:{}})}else c.push({to:s.domain,path:S,static:{dir:`${n}/${o}-${l}/current`,spa:s.spa??!1,pathRewriteStyle:s.pathRewriteStyle??"directory"},cleanUrls:s.pathRewriteStyle!=="flat",...C?{auth:C}:{},id:_});f.add(s.domain),v()}if(t.proxy.autoWww!==!1)for(let l of[...f]){if(!Io(l))continue;let s=`www.${l}`;if(f.has(s))continue;c.push({to:s,redirect:{to:`https://${l}`},id:Sd(s)}),f.add(s)}c.sort((l,s)=>{if(l.to!==s.to)return l.to.localeCompare(s.to);return(s.path?.length??0)-(l.path?.length??0)});let a={proxies:c,productionCerts:{certsDir:u,certsDirServerNames:[...f,...g.keys()]},https:!0,hostsManagement:!1,cleanup:{hosts:!1,certs:!1},...g.size>0?{wildcardCerts:[...g.values()]}:{}};if(t.proxy.onDemandTls&&f.size>0)a.onDemandTls={enabled:!0,allowedSuffixes:[...f],email:t.proxy.onDemandTlsEmail,certsDir:u,staging:t.proxy.onDemandTlsStaging??!1};if(t.proxy.onDemandTls)a.acmeChallengeWebroot=t.proxy.acmeWebroot??I;let p=t.proxy.cdn,w=p?.frontedHosts?.length?p.frontedHosts:[...f];if(p?.secret&&w.length>0)a.originGuard={header:p.secretHeader??"X-Origin-Verify",value:p.secret,hosts:w};if(t.lan)if(yd(t.lan)==="off")a.https=!1;else{let l=X(e,t.lan,o);j(l,a.onDemandTls);let s=t.lan.ip&&A(t.lan.ip)!==0?[t.lan.ip]:[];a.localCa={dir:N,hosts:l.map((y)=>y.host),...s.length>0?{ips:s}:{},installTrust:!0}}return a}function x(e,t){return M({...e,...t.mail?un(t.mail):{}},t)}function nr(e,t,r){return M({...e,...r.mail?un(r.mail):{}},r,t)}function HI(e){return`// Generated by ts-cloud — rpx reverse-proxy gateway.
|
|
2
2
|
// Routes are derived from the \`sites\` model on every \`buddy deploy\`.
|
|
3
3
|
import { startProxies } from '@stacksjs/rpx'
|
|
4
4
|
|
|
5
|
-
const config = ${
|
|
5
|
+
const config = ${O(e)} as const
|
|
6
6
|
|
|
7
7
|
// Verbose is the hard default for ts-cloud-installed gateways (RPX_VERBOSE=false
|
|
8
8
|
// opts out) — without it rpx's TLS/routing diagnostics never reach the journal.
|
|
9
9
|
await startProxies({ verbose: process.env.RPX_VERBOSE !== 'false', ...config } as any)
|
|
10
|
-
`}function
|
|
10
|
+
`}function z(e){return e?.webServer==="rpx"||e?.proxy?.engine==="rpx"}var Co="/etc/rpx",R="/opt/rpx-gateway",xp="/etc/rpx/gateway.ts",vt="/etc/rpx/gateway",Je="rpx-gateway.service",K="/etc/rpx/sites.d";function J(e=K,t=yo){return`// Generated by ts-cloud — rpx gateway assembler.
|
|
11
11
|
// Merges every app's fragment in ${e} so independent deploys compose
|
|
12
12
|
// without clobbering each other. Each deploy writes only its own <slug>.json.
|
|
13
13
|
import { startProxies } from '@stacksjs/rpx'
|
|
@@ -119,7 +119,7 @@ const config = {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
await startProxies(config)
|
|
122
|
-
`}function
|
|
122
|
+
`}function b(e,t,r,n="0644"){return[`__tsc_tmp="$(mktemp "${e}.XXXXXX")"`,`cat > "$__tsc_tmp" <<'${r}'`,t,r,`mv -f "$__tsc_tmp" ${e}`,`chmod ${n} ${e}`]}function q(e){return`'${e.replaceAll("'","'\\''")}'`}function D(e,t,r,n){if(!n.preserveManagementDashboardRoutes)return b(e,t,r,"0600");let o=`
|
|
123
123
|
const { readFileSync, writeFileSync } = require('node:fs')
|
|
124
124
|
const currentPath = process.env.TS_CLOUD_RPX_CURRENT_FRAGMENT
|
|
125
125
|
const candidatePath = process.env.TS_CLOUD_RPX_CANDIDATE_FRAGMENT
|
|
@@ -130,9 +130,9 @@ const retained = Array.isArray(current.proxies) ? current.proxies.filter(isDashb
|
|
|
130
130
|
const next = Array.isArray(candidate.proxies) ? candidate.proxies.filter(route => !isDashboard(route)) : []
|
|
131
131
|
candidate.proxies = [...next, ...retained]
|
|
132
132
|
writeFileSync(candidatePath, JSON.stringify(candidate, null, 2) + '\\n', { mode: 0o600 })
|
|
133
|
-
`.trim();return[`__tsc_fragment_candidate="$(mktemp "${e}.candidate.XXXXXX")"`,`cat > "$__tsc_fragment_candidate" <<'${r}'`,t,r,'chmod 0600 "$__tsc_fragment_candidate"',`if [ -f ${e} ]; then TS_CLOUD_RPX_CURRENT_FRAGMENT=${e} TS_CLOUD_RPX_CANDIDATE_FRAGMENT="$__tsc_fragment_candidate" ${n.bunBin} -e ${q(o)}; fi`,`mv -f "$__tsc_fragment_candidate" ${e}`,`chmod 0600 ${e}`]}var Q={high:"256M",max:"384M"},Z={high:"512M",max:"768M"};function
|
|
134
|
-
`),
|
|
135
|
-
`),
|
|
136
|
-
`);return[`mkdir -p ${n}`,...e.tenant?[]:[`(cd ${R} && ${u} add @stacksjs/tlsx@${i}) || true`],...
|
|
137
|
-
`),"TS_CLOUD_RPX_UNIT_EOF"),"systemctl daemon-reload","systemctl disable --now bun-gateway.service 2>/dev/null || true","systemctl disable --now bun-gateway-renew.timer bun-gateway-renew.service 2>/dev/null || true","rm -f /etc/systemd/system/bun-gateway-renew.timer /etc/systemd/system/bun-gateway-renew.service","systemctl disable --now ts-cloud-nginx.service 2>/dev/null || true",`for timer in /etc/systemd/system/rpx-cert-renew-*.timer; do [ -e "$timer" ] || continue; unit="$(basename "$timer")"; tenant="\${unit#rpx-cert-renew-}"; tenant="\${tenant%.timer}"; [ -f "${
|
|
138
|
-
export{
|
|
133
|
+
`.trim();return[`__tsc_fragment_candidate="$(mktemp "${e}.candidate.XXXXXX")"`,`cat > "$__tsc_fragment_candidate" <<'${r}'`,t,r,'chmod 0600 "$__tsc_fragment_candidate"',`if [ -f ${e} ]; then TS_CLOUD_RPX_CURRENT_FRAGMENT=${e} TS_CLOUD_RPX_CANDIDATE_FRAGMENT="$__tsc_fragment_candidate" ${n.bunBin} -e ${q(o)}; fi`,`mv -f "$__tsc_fragment_candidate" ${e}`,`chmod 0600 ${e}`]}var Q={high:"256M",max:"384M"},Z={high:"512M",max:"768M"};function Id(e){return`rpx-cert-renew-${(e||"app").replace(/[^a-z0-9._-]+/gi,"-")}.service`}function bd(e){let t=new Set;for(let r of e.proxies){let n=r.to;if(!n||n.startsWith("*")||n.includes(":")||!n.includes("."))continue;t.add(n)}return[...t]}function ee(e){if(e.length===0)return[];let t=["# Wildcards: dns-01 (Porkbun), keys read from the site's env file for tlsx alone.","dns_env() {",' [ -r "$1" ] || return 0',` sed -n "s/^$2=//p" "$1" | tail -n 1 | sed -e 's/^"\\(.*\\)"$/\\1/' -e "s/^'\\(.*\\)'$/\\1/"`,"}","wildcard() {",' apex="$1"',' envfile="$2"',' name="*.$apex"',' key=$(dns_env "$envfile" PORKBUN_API_KEY)',' secret=$(dns_env "$envfile" PORKBUN_SECRET_KEY)',' if [ -z "$key" ] || [ -z "$secret" ]; then',' echo "wildcard $name skipped: no PORKBUN_API_KEY / PORKBUN_SECRET_KEY in $envfile (non-fatal)"'," return 0"," fi",' if [ ! -s "$CERTS/_wildcard.$apex.crt" ]; then',' PORKBUN_API_KEY="$key" PORKBUN_SECRET_KEY="$secret" $TLSX acme:issue -d "$name" --method dns-01 --dns-provider porkbun --dir "$CERTS" --prod --email "$EMAIL" || echo "issue $name failed (non-fatal)"'," else",' PORKBUN_API_KEY="$key" PORKBUN_SECRET_KEY="$secret" $TLSX acme:renew --domains "$name" --method dns-01 --dir "$CERTS" --days 30 --prod --email "$EMAIL" || echo "renew $name failed (non-fatal)"'," fi","}"];for(let r of e){let n=r.domain.replace(/^\*\./,"");t.push(`wildcard '${n}' '${r.dnsEnvFile.replace(/'/g,"")}'`)}return t}function L(e){let{config:t,proxy:r}=e,n=t.acmeChallengeWebroot,o=bd(t);if(!r.onDemandTls||!n||o.length===0)return[];let u=e.bunBin??"/usr/local/bin/bun",i=r.tlsxVersion??"latest",c=t.productionCerts.certsDir,f=r.onDemandTlsEmail??`webmaster@${o[0]}`,g=`${u} ${R}/node_modules/@stacksjs/tlsx/dist/bin/cli.js`,a=o.join(","),p=o.join(" "),w=(e.slug||"app").replace(/[^a-z0-9._-]+/gi,"-"),l=`${Co}/renew-certs-${w}.sh`,s=Id(w),y=`rpx-cert-renew-${w}.timer`,E=t.wildcardCerts??[],T=E.length>0?"tlsx http-01 + dns-01 wildcard":"tlsx http-01",v=["#!/bin/sh",`# Generated by ts-cloud — issue/renew rpx gateway TLS certs via ${T}.`,"# The running gateway serves the challenge from $WEBROOT on :80, so this needs","# no downtime and no DNS credentials. Reloads the gateway only if a cert changed.","set -u",`CERTS='${c}'`,`WEBROOT='${n}'`,`EMAIL='${f}'`,`TLSX="${g}"`,`BUN='${u}'`,`DOMAINS='${a}'`,"DNS_ATTEMPTS='24'","DNS_DELAY_SECONDS='5'",`DNS_RESOLVERS='${B.join(" ")}'`,"dns_resolves() {",' d="$1"'," for ns in $DNS_RESOLVERS; do",` if $BUN --eval "const{Resolver}=require('node:dns');const r=new Resolver();r.setServers([process.argv[1]]);r.resolve4(process.argv[2],e=>process.exit(e?1:0))" "$ns" "$d" >/dev/null 2>&1; then`," return 0"," fi"," done",' getent ahosts "$d" >/dev/null 2>&1',"}","wait_for_dns() {",' d="$1"'," attempt=1",' while ! dns_resolves "$d"; do',' if [ "$attempt" -ge "$DNS_ATTEMPTS" ]; then',' echo "DNS for $d did not become resolvable after $DNS_ATTEMPTS attempts" >&2'," return 1"," fi",' echo "Waiting for public DNS before ACME: $d (attempt $attempt/$DNS_ATTEMPTS)"',' sleep "$DNS_DELAY_SECONDS"'," attempt=$((attempt + 1))"," done","}",'before=$(cat "$CERTS"/*.crt 2>/dev/null | sha256sum)',`for d in ${p}; do`,' if [ ! -s "$CERTS/$d.crt" ]; then',' if wait_for_dns "$d"; then',' $TLSX acme:issue -d "$d" --method http-01 --webroot "$WEBROOT" --dir "$CERTS" --prod --email "$EMAIL" || echo "issue $d failed (non-fatal)"'," else",' echo "issue $d skipped until DNS resolves (non-fatal)"'," fi"," # rpx reloads its SNI set when a PEM appears. Complete that reload"," # before the next hostname starts http-01, or :80 can disappear in"," # the middle of the following challenge on a multi-domain deploy.",` [ -s "$CERTS/$d.crt" ] && systemctl restart ${Je}`," fi","done",'$TLSX acme:renew --domains "$DOMAINS" --method http-01 --webroot "$WEBROOT" --dir "$CERTS" --days 30 --prod --email "$EMAIL" || echo "renew: some domains failed (non-fatal)"',...ee(E),'rm -f "$CERTS"/*.chain.crt','after=$(cat "$CERTS"/*.crt 2>/dev/null | sha256sum)',`[ "$before" = "$after" ] || systemctl restart ${Je}`].join(`
|
|
134
|
+
`),S=["[Unit]",`Description=Issue/renew rpx gateway TLS certs for ${w} (${T})`,`After=network-online.target ${Je}`,"Wants=network-online.target","","[Service]","Type=oneshot",`ExecStart=${l}`].join(`
|
|
135
|
+
`),_=["[Unit]",`Description=Daily rpx gateway TLS cert issuance/renewal for ${w}`,"","[Timer]","OnCalendar=*-*-* 03:30:00","RandomizedDelaySec=1h","Persistent=true","","[Install]","WantedBy=timers.target"].join(`
|
|
136
|
+
`);return[`mkdir -p ${n}`,...e.tenant?[]:[`(cd ${R} && ${u} add @stacksjs/tlsx@${i}) || true`],...b(l,v,"TS_CLOUD_RENEW_EOF"),`chmod +x ${l}`,...b(`/etc/systemd/system/${s}`,S,"TS_CLOUD_RENEW_SVC_EOF"),...b(`/etc/systemd/system/${y}`,_,"TS_CLOUD_RENEW_TIMER_EOF"),"systemctl daemon-reload",`systemctl enable --now ${y} || true`,`${l} || true`]}function V(e){let{config:t,proxy:r}=e,n=e.bunBin??"/usr/local/bin/bun",o=r.version??"latest",u=t.productionCerts.certsDir,i=(e.slug||"app").replace(/[^a-z0-9._-]+/gi,"-"),c=O(t,{slug:i}),f=J(K,u);if(e.tenant)return["set -euo pipefail",`if [ ! -x ${vt} ] || [ ! -d ${R}/node_modules/@stacksjs/rpx ]; then`,` echo "ts-cloud: no rpx gateway on this box. This project attaches to another project's compute, so it does not provision one - deploy the owning project first." >&2`," exit 1","fi",`mkdir -p ${K} ${u}`,`__tsc_rpx_before="$(sha256sum ${K}/${i}.json 2>/dev/null | cut -d' ' -f1 || true)"`,...D(`${K}/${i}.json`,c,"TS_CLOUD_RPX_FRAGMENT_EOF",{bunBin:n,preserveManagementDashboardRoutes:e.preserveManagementDashboardRoutes}),`__tsc_rpx_after="$(sha256sum ${K}/${i}.json 2>/dev/null | cut -d' ' -f1 || true)"`,`if [ "$__tsc_rpx_before" != "$__tsc_rpx_after" ] || ! systemctl is-active --quiet ${Je}; then`,` systemctl restart ${Je}`,"else",` echo "[ts-cloud] rpx routes for ${i} unchanged - leaving the shared gateway alone"`,"fi",...L(e)];let a=[`Environment=RPX_UPSTREAM_TIMEOUT=${r.upstreamTimeout??60}`];if(typeof r.maxUpstreamConns==="number")a.push(`Environment=RPX_MAX_UPSTREAM_CONNS=${r.maxUpstreamConns}`);let p=e.profile==="raspberry-pi"?Q:Z,w=r.memoryHigh??p.high,l=r.memoryMax??p.max;return["set -euo pipefail",`mkdir -p ${Co} ${K} ${u} ${R}`,`rm -rf ${R}.next ${R}.prev`,`mkdir -p ${R}.next`,`(cd ${R}.next && ${n} add @stacksjs/rpx@${o})`,`mv ${R} ${R}.prev`,`mv ${R}.next ${R}`,`rm -rf ${R}.prev`,`ln -sfn ${R}/node_modules ${Co}/node_modules`,...D(`${K}/${i}.json`,c,"TS_CLOUD_RPX_FRAGMENT_EOF",{bunBin:n,preserveManagementDashboardRoutes:e.preserveManagementDashboardRoutes}),...b(xp,f,"TS_CLOUD_RPX_EOF"),`${n} build --production --compile --outfile ${vt}.next ${xp}`,`chmod 0755 ${vt}.next`,`mv -f ${vt}.next ${vt}`,...b(`/etc/systemd/system/${Je}`,["[Unit]","Description=rpx reverse-proxy gateway (managed by ts-cloud)","After=network.target network-online.target","Wants=network-online.target","","[Service]","Type=simple",`ExecStart=${vt}`,`WorkingDirectory=${R}`,"Environment=BUN_INSTALL=/root/.bun","Environment=APP_ENV=production","Environment=NODE_ENV=production",...a,"MemoryAccounting=true",`MemoryHigh=${w}`,`MemoryMax=${l}`,"CPUWeight=500","IOWeight=500","OOMPolicy=stop","Restart=always","RestartSec=5","StartLimitIntervalSec=120","StartLimitBurst=5",`ExecStartPre=/bin/sh -c 'for p in 80 443; do fuser -k -n tcp "$p" 2>/dev/null || true; done; sleep 1'`,"LimitNOFILE=1048576","AmbientCapabilities=CAP_NET_BIND_SERVICE","","[Install]","WantedBy=multi-user.target"].join(`
|
|
137
|
+
`),"TS_CLOUD_RPX_UNIT_EOF"),"systemctl daemon-reload","systemctl disable --now bun-gateway.service 2>/dev/null || true","systemctl disable --now bun-gateway-renew.timer bun-gateway-renew.service 2>/dev/null || true","rm -f /etc/systemd/system/bun-gateway-renew.timer /etc/systemd/system/bun-gateway-renew.service","systemctl disable --now ts-cloud-nginx.service 2>/dev/null || true",`for timer in /etc/systemd/system/rpx-cert-renew-*.timer; do [ -e "$timer" ] || continue; unit="$(basename "$timer")"; tenant="\${unit#rpx-cert-renew-}"; tenant="\${tenant%.timer}"; [ -f "${K}/$tenant.json" ] && continue; systemctl disable --now "$unit" 2>/dev/null || true; rm -f "$timer" "/etc/systemd/system/rpx-cert-renew-$tenant.service" "${Co}/renew-certs-$tenant.sh"; done`,`systemctl enable ${Je}`,`systemctl restart ${Je}`,...L(e)]}function xe(e){let t=(e.slug||"app").replace(/[^a-z0-9._-]+/gi,"-"),r=O(e.config,{slug:t});return["set -euo pipefail",`mkdir -p ${K}`,...D(`${K}/${t}.json`,r,"TS_CLOUD_RPX_FRAGMENT_EOF",{bunBin:"/usr/local/bin/bun",preserveManagementDashboardRoutes:e.preserveManagementDashboardRoutes}),`systemctl restart ${Je}`]}
|
|
138
|
+
export{yo,So,Io,bo,yd,Np,Bp,lA,Sd,x,nr,HI,z,Co,R,xp,vt,Je,K,Id,bd,V,xe};
|