@stacksjs/buddy 0.75.100 → 0.75.102
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/commands/deploy.d.ts +8 -0
- package/dist/commands/deploy.js +1 -1
- package/package.json +57 -57
|
@@ -121,6 +121,14 @@ export declare function normalizeDomains(domains: readonly unknown[]): string[];
|
|
|
121
121
|
* @param retired - Domains this project used to serve and deliberately no longer does.
|
|
122
122
|
*/
|
|
123
123
|
export declare function orphanedFragmentDomains(fragment: string, ours: Iterable<string>, retired?: Iterable<string>): string[];
|
|
124
|
+
/**
|
|
125
|
+
* Every hostname this project's sites route: each site's `domain` and its
|
|
126
|
+
* `aliases` (`*.example.com` included), which ts-cloud routes exactly like
|
|
127
|
+
* the domain. Without the aliases, the second deploy after adding one found
|
|
128
|
+
* its own wildcard route in the fragment and refused, as if another project
|
|
129
|
+
* owned it.
|
|
130
|
+
*/
|
|
131
|
+
export declare function declaredSiteDomains(sites: unknown): string[];
|
|
124
132
|
/**
|
|
125
133
|
* Refuse to overwrite a gateway fragment that is serving somebody else.
|
|
126
134
|
*
|
package/dist/commands/deploy.js
CHANGED
|
@@ -3,7 +3,7 @@ import{existsSync,mkdirSync,readFileSync,readdirSync,statSync,writeFileSync}from
|
|
|
3
3
|
Last attempt: ${detail}`:"")+`
|
|
4
4
|
A connection timeout means the box is probably still booting, so raise TS_CLOUD_SSH_WAIT_SECS and retry. "Permission denied" means the key is not authorized, and a refused or reset connection (especially after earlier attempts got further) usually means fail2ban banned this IP. Waiting longer fixes neither.`}export function bunRuntimeMissingMessage(opts){const detail=pollFailureDetail(opts.lastError);return`bun runtime did not appear at /usr/local/bin/bun within ${fmtDuration(opts.waitSecs)} (waited ${opts.elapsedSecs}s).`+(detail?`
|
|
5
5
|
Last attempt: ${detail}`:"")+`
|
|
6
|
-
cloud-init may have failed: SSH in and check /var/log/cloud-init-output.log. Raise TS_CLOUD_BOOT_WAIT_SECS for slow regions.`}export async function pollUntil(opts){log.info(`${opts.label} (up to ${fmtDuration(opts.timeoutSecs)})...`);const started=Date.now(),deadline=started+opts.timeoutSecs*1000;let lastHeartbeat=0,lastError;for(;;)try{await opts.check();return}catch(err){lastError=err;const elapsedSecs=Math.floor((Date.now()-started)/1000);if(Date.now()>deadline)throw Error(opts.timeoutMessage(elapsedSecs,lastError));if(elapsedSecs-lastHeartbeat>=30){log.info(` \u2026 still waiting (${elapsedSecs}s elapsed)`);lastHeartbeat=elapsedSecs}await new Promise((r)=>setTimeout(r,opts.intervalMs??5000))}}async function waitForRemoteReady(where){const{sshExecOrThrow}=await import("@stacksjs/ts-cloud"),target=toSshTarget(where),ip=target.host,run=(remote)=>sshExecOrThrow(ip,remote,remoteExecOptions(target,10)),sshWaitSecs=readWaitSecs("TS_CLOUD_SSH_WAIT_SECS",480);await pollUntil({label:"Waiting for SSH to come up",timeoutSecs:sshWaitSecs,check:()=>run("true"),timeoutMessage:(elapsed,lastError)=>sshUnreachableMessage({ip,waitSecs:sshWaitSecs,elapsedSecs:elapsed,lastError})});log.success("SSH is up");let hasCloudInit=!0;try{await run("command -v cloud-init >/dev/null 2>&1")}catch{hasCloudInit=!1}if(hasCloudInit){log.info("Waiting for cloud-init (installing bun + caddy)...");try{await run("cloud-init status --wait || true")}catch(err){log.debug("cloud-init status --wait returned non-zero (continuing):",err)}}else log.info("No cloud-init on this host; skipping the first-boot wait.");const bootWaitSecs=readWaitSecs("TS_CLOUD_BOOT_WAIT_SECS",720);await pollUntil({label:"Waiting for the bun runtime",timeoutSecs:bootWaitSecs,check:()=>run("test -x /usr/local/bin/bun"),timeoutMessage:(elapsed,lastError)=>bunRuntimeMissingMessage({waitSecs:bootWaitSecs,elapsedSecs:elapsed,lastError})});log.success("Server is ready (bun installed)")}async function resolveDeclaredTenants(){try{const{config}=await import("@stacksjs/config"),tenants=config.cloud?.tenants;return Array.isArray(tenants)?tenants.filter((slug)=>typeof slug==="string"):[]}catch{return[]}}export function normalizeDomains(domains){return domains.map((domain)=>String(domain??"").trim().toLowerCase()).filter(Boolean)}export function orphanedFragmentDomains(fragment,ours,retired=[]){const declared=new Set(normalizeDomains([...ours])),givenUp=new Set(normalizeDomains([...retired])),accountedFor=(domain,set)=>set.has(domain)||set.has(domain.replace(/^www\./,""));return[...new Set([...fragment.matchAll(/"(?:domain|to|from)"\s*:\s*"([a-z0-9.*-]+\.[a-z]{2,})"/gi)].map((match)=>String(match[1]).toLowerCase()).filter(Boolean))].filter((domain)=>!accountedFor(domain,declared)&&!accountedFor(domain,givenUp))}export async function assertFragmentIsOurs(where,tsCloudConfig,log){const slug=tsCloudConfig.project?.slug||"app",ours=new Set(
|
|
6
|
+
cloud-init may have failed: SSH in and check /var/log/cloud-init-output.log. Raise TS_CLOUD_BOOT_WAIT_SECS for slow regions.`}export async function pollUntil(opts){log.info(`${opts.label} (up to ${fmtDuration(opts.timeoutSecs)})...`);const started=Date.now(),deadline=started+opts.timeoutSecs*1000;let lastHeartbeat=0,lastError;for(;;)try{await opts.check();return}catch(err){lastError=err;const elapsedSecs=Math.floor((Date.now()-started)/1000);if(Date.now()>deadline)throw Error(opts.timeoutMessage(elapsedSecs,lastError));if(elapsedSecs-lastHeartbeat>=30){log.info(` \u2026 still waiting (${elapsedSecs}s elapsed)`);lastHeartbeat=elapsedSecs}await new Promise((r)=>setTimeout(r,opts.intervalMs??5000))}}async function waitForRemoteReady(where){const{sshExecOrThrow}=await import("@stacksjs/ts-cloud"),target=toSshTarget(where),ip=target.host,run=(remote)=>sshExecOrThrow(ip,remote,remoteExecOptions(target,10)),sshWaitSecs=readWaitSecs("TS_CLOUD_SSH_WAIT_SECS",480);await pollUntil({label:"Waiting for SSH to come up",timeoutSecs:sshWaitSecs,check:()=>run("true"),timeoutMessage:(elapsed,lastError)=>sshUnreachableMessage({ip,waitSecs:sshWaitSecs,elapsedSecs:elapsed,lastError})});log.success("SSH is up");let hasCloudInit=!0;try{await run("command -v cloud-init >/dev/null 2>&1")}catch{hasCloudInit=!1}if(hasCloudInit){log.info("Waiting for cloud-init (installing bun + caddy)...");try{await run("cloud-init status --wait || true")}catch(err){log.debug("cloud-init status --wait returned non-zero (continuing):",err)}}else log.info("No cloud-init on this host; skipping the first-boot wait.");const bootWaitSecs=readWaitSecs("TS_CLOUD_BOOT_WAIT_SECS",720);await pollUntil({label:"Waiting for the bun runtime",timeoutSecs:bootWaitSecs,check:()=>run("test -x /usr/local/bin/bun"),timeoutMessage:(elapsed,lastError)=>bunRuntimeMissingMessage({waitSecs:bootWaitSecs,elapsedSecs:elapsed,lastError})});log.success("Server is ready (bun installed)")}async function resolveDeclaredTenants(){try{const{config}=await import("@stacksjs/config"),tenants=config.cloud?.tenants;return Array.isArray(tenants)?tenants.filter((slug)=>typeof slug==="string"):[]}catch{return[]}}export function normalizeDomains(domains){return domains.map((domain)=>String(domain??"").trim().toLowerCase()).filter(Boolean)}export function orphanedFragmentDomains(fragment,ours,retired=[]){const declared=new Set(normalizeDomains([...ours])),givenUp=new Set(normalizeDomains([...retired])),accountedFor=(domain,set)=>set.has(domain)||set.has(domain.replace(/^www\./,""));return[...new Set([...fragment.matchAll(/"(?:domain|to|from)"\s*:\s*"([a-z0-9.*-]+\.[a-z]{2,})"/gi)].map((match)=>String(match[1]).toLowerCase()).filter(Boolean))].filter((domain)=>!accountedFor(domain,declared)&&!accountedFor(domain,givenUp))}export function declaredSiteDomains(sites){const out=[];for(const site of Object.values(sites??{})){if(!site?.domain)continue;out.push(String(site.domain));if(Array.isArray(site.aliases))out.push(...site.aliases.map(String))}return normalizeDomains(out)}export async function assertFragmentIsOurs(where,tsCloudConfig,log){const slug=tsCloudConfig.project?.slug||"app",ours=new Set(declaredSiteDomains(tsCloudConfig.sites));let remote="";try{const{execSync}=await import("node:child_process"),args=sshCliArgs(toSshTarget(where));remote=execSync(`ssh ${args.map((a)=>`'${a}'`).join(" ")} bash -s`,{input:`cat /etc/rpx/sites.d/${slug}.json 2>/dev/null || true`,encoding:"utf8",stdio:["pipe","pipe","pipe"]})}catch{return}if(!remote.trim())return;const retired=normalizeDomains(Array.isArray(tsCloudConfig.cloud?.retiredDomains)?tsCloudConfig.cloud.retiredDomains:[]),orphaned=orphanedFragmentDomains(remote,ours,retired);if(orphaned.length===0){if(retired.length>0)log.info(`Retiring ${retired.length} domain(s) this project no longer serves: ${retired.join(", ")}`);return}log.error(`/etc/rpx/sites.d/${slug}.json on the box already serves ${orphaned.length} domain(s) this project does not declare:`);for(const domain of orphaned.slice(0,8))log.error(` ${domain}`);log.error("Deploying would replace that fragment and take those domains down.");log.info(`Either the slug '${slug}' belongs to another project (pick a different project.slug), or those domains belong here and should be in config/cloud.ts sites.`);log.info("If you mean to stop serving them, list them in `cloud.retiredDomains` in config/cloud.ts.");process.exit(ExitCode.FatalError)}export async function assertPortsAreFree(where,tsCloudConfig,log){const slug=tsCloudConfig.project?.slug||"app",wanted=new Map;for(const[name,site]of Object.entries(tsCloudConfig.sites??{})){const port=Number(site?.port);if(Number.isFinite(port)&&port>0)wanted.set(port,name)}if(wanted.size===0)return;let listing="";try{const{execSync}=await import("node:child_process"),args=sshCliArgs(toSshTarget(where));listing=execSync(`ssh ${args.map((a)=>`'${a}'`).join(" ")} bash -s`,{input:`for p in ${[...wanted.keys()].join(" ")}; do
|
|
7
7
|
pid=$(ss -lntpH "sport = :$p" 2>/dev/null | grep -oE 'pid=[0-9]+' | head -1 | cut -d= -f2)
|
|
8
8
|
[ -n "$pid" ] || continue
|
|
9
9
|
unit=$(systemctl status "$pid" 2>/dev/null | head -1 | grep -oE '[a-zA-Z0-9_.@-]+\\.service' | head -1)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/buddy",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.102",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,71 +95,71 @@
|
|
|
95
95
|
"prepublishOnly": "bun run build"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@stacksjs/actions": "^0.75.
|
|
99
|
-
"@stacksjs/ai": "^0.75.
|
|
100
|
-
"@stacksjs/alias": "^0.75.
|
|
101
|
-
"@stacksjs/analytics": "^0.75.
|
|
102
|
-
"@stacksjs/api": "^0.75.
|
|
103
|
-
"@stacksjs/arrays": "^0.75.
|
|
104
|
-
"@stacksjs/auth": "^0.75.
|
|
105
|
-
"@stacksjs/browser-extension": "^0.75.
|
|
106
|
-
"@stacksjs/build": "^0.75.
|
|
107
|
-
"@stacksjs/cache": "^0.75.
|
|
108
|
-
"@stacksjs/chat": "^0.75.
|
|
98
|
+
"@stacksjs/actions": "^0.75.102",
|
|
99
|
+
"@stacksjs/ai": "^0.75.102",
|
|
100
|
+
"@stacksjs/alias": "^0.75.102",
|
|
101
|
+
"@stacksjs/analytics": "^0.75.102",
|
|
102
|
+
"@stacksjs/api": "^0.75.102",
|
|
103
|
+
"@stacksjs/arrays": "^0.75.102",
|
|
104
|
+
"@stacksjs/auth": "^0.75.102",
|
|
105
|
+
"@stacksjs/browser-extension": "^0.75.102",
|
|
106
|
+
"@stacksjs/build": "^0.75.102",
|
|
107
|
+
"@stacksjs/cache": "^0.75.102",
|
|
108
|
+
"@stacksjs/chat": "^0.75.102",
|
|
109
109
|
"@stacksjs/clapp": "^0.2.16",
|
|
110
|
-
"@stacksjs/cli": "^0.75.
|
|
111
|
-
"@stacksjs/cloud": "^0.75.
|
|
112
|
-
"@stacksjs/cms": "^0.75.
|
|
113
|
-
"@stacksjs/collections": "^0.75.
|
|
114
|
-
"@stacksjs/commerce": "^0.75.
|
|
115
|
-
"@stacksjs/config": "^0.75.
|
|
116
|
-
"@stacksjs/database": "^0.75.
|
|
117
|
-
"@stacksjs/desktop-build": "^0.75.
|
|
118
|
-
"@stacksjs/dns": "^0.75.
|
|
110
|
+
"@stacksjs/cli": "^0.75.102",
|
|
111
|
+
"@stacksjs/cloud": "^0.75.102",
|
|
112
|
+
"@stacksjs/cms": "^0.75.102",
|
|
113
|
+
"@stacksjs/collections": "^0.75.102",
|
|
114
|
+
"@stacksjs/commerce": "^0.75.102",
|
|
115
|
+
"@stacksjs/config": "^0.75.102",
|
|
116
|
+
"@stacksjs/database": "^0.75.102",
|
|
117
|
+
"@stacksjs/desktop-build": "^0.75.102",
|
|
118
|
+
"@stacksjs/dns": "^0.75.102",
|
|
119
119
|
"@stacksjs/dnsx": "^0.2.3",
|
|
120
|
-
"@stacksjs/email": "^0.75.
|
|
121
|
-
"@stacksjs/enums": "^0.75.
|
|
122
|
-
"@stacksjs/env": "^0.75.
|
|
123
|
-
"@stacksjs/error-handling": "^0.75.
|
|
124
|
-
"@stacksjs/events": "^0.75.
|
|
125
|
-
"@stacksjs/features": "^0.75.
|
|
126
|
-
"@stacksjs/git": "^0.75.
|
|
120
|
+
"@stacksjs/email": "^0.75.102",
|
|
121
|
+
"@stacksjs/enums": "^0.75.102",
|
|
122
|
+
"@stacksjs/env": "^0.75.102",
|
|
123
|
+
"@stacksjs/error-handling": "^0.75.102",
|
|
124
|
+
"@stacksjs/events": "^0.75.102",
|
|
125
|
+
"@stacksjs/features": "^0.75.102",
|
|
126
|
+
"@stacksjs/git": "^0.75.102",
|
|
127
127
|
"@stacksjs/gitit": "^0.2.5",
|
|
128
|
-
"@stacksjs/health": "^0.75.
|
|
128
|
+
"@stacksjs/health": "^0.75.102",
|
|
129
129
|
"@stacksjs/httx": "^0.1.10",
|
|
130
|
-
"@stacksjs/image": "^0.75.
|
|
131
|
-
"@stacksjs/lint": "^0.75.
|
|
132
|
-
"@stacksjs/logging": "^0.75.
|
|
133
|
-
"@stacksjs/notifications": "^0.75.
|
|
134
|
-
"@stacksjs/objects": "^0.75.
|
|
135
|
-
"@stacksjs/orm": "^0.75.
|
|
136
|
-
"@stacksjs/path": "^0.75.
|
|
137
|
-
"@stacksjs/payments": "^0.75.
|
|
138
|
-
"@stacksjs/realtime": "^0.75.
|
|
139
|
-
"@stacksjs/router": "^0.75.
|
|
130
|
+
"@stacksjs/image": "^0.75.102",
|
|
131
|
+
"@stacksjs/lint": "^0.75.102",
|
|
132
|
+
"@stacksjs/logging": "^0.75.102",
|
|
133
|
+
"@stacksjs/notifications": "^0.75.102",
|
|
134
|
+
"@stacksjs/objects": "^0.75.102",
|
|
135
|
+
"@stacksjs/orm": "^0.75.102",
|
|
136
|
+
"@stacksjs/path": "^0.75.102",
|
|
137
|
+
"@stacksjs/payments": "^0.75.102",
|
|
138
|
+
"@stacksjs/realtime": "^0.75.102",
|
|
139
|
+
"@stacksjs/router": "^0.75.102",
|
|
140
140
|
"@stacksjs/rpx": "^0.11.54",
|
|
141
|
-
"@stacksjs/scheduler": "^0.75.
|
|
142
|
-
"@stacksjs/search-engine": "^0.75.
|
|
143
|
-
"@stacksjs/security": "^0.75.
|
|
144
|
-
"@stacksjs/server": "^0.75.
|
|
145
|
-
"@stacksjs/sites": "^0.75.
|
|
146
|
-
"@stacksjs/skills": "^0.75.
|
|
147
|
-
"@stacksjs/socials": "^0.75.
|
|
148
|
-
"@stacksjs/storage": "^0.75.
|
|
149
|
-
"@stacksjs/strings": "^0.75.
|
|
150
|
-
"@stacksjs/stx": "^0.2.
|
|
151
|
-
"@stacksjs/testing": "^0.75.
|
|
152
|
-
"@stacksjs/tinker": "^0.75.
|
|
141
|
+
"@stacksjs/scheduler": "^0.75.102",
|
|
142
|
+
"@stacksjs/search-engine": "^0.75.102",
|
|
143
|
+
"@stacksjs/security": "^0.75.102",
|
|
144
|
+
"@stacksjs/server": "^0.75.102",
|
|
145
|
+
"@stacksjs/sites": "^0.75.102",
|
|
146
|
+
"@stacksjs/skills": "^0.75.102",
|
|
147
|
+
"@stacksjs/socials": "^0.75.102",
|
|
148
|
+
"@stacksjs/storage": "^0.75.102",
|
|
149
|
+
"@stacksjs/strings": "^0.75.102",
|
|
150
|
+
"@stacksjs/stx": "^0.2.414",
|
|
151
|
+
"@stacksjs/testing": "^0.75.102",
|
|
152
|
+
"@stacksjs/tinker": "^0.75.102",
|
|
153
153
|
"@stacksjs/tlsx": "^0.13.19",
|
|
154
154
|
"@stacksjs/ts-cloud": "^0.16.47",
|
|
155
|
-
"@stacksjs/tunnel": "^0.75.
|
|
156
|
-
"@stacksjs/types": "^0.75.
|
|
157
|
-
"@stacksjs/ui": "^0.75.
|
|
158
|
-
"@stacksjs/utils": "^0.75.
|
|
159
|
-
"@stacksjs/validation": "^0.75.
|
|
155
|
+
"@stacksjs/tunnel": "^0.75.102",
|
|
156
|
+
"@stacksjs/types": "^0.75.102",
|
|
157
|
+
"@stacksjs/ui": "^0.75.102",
|
|
158
|
+
"@stacksjs/utils": "^0.75.102",
|
|
159
|
+
"@stacksjs/validation": "^0.75.102",
|
|
160
160
|
"ajv": "^8.20.0",
|
|
161
161
|
"ajv-formats": "^3.0.1",
|
|
162
|
-
"bun-plugin-stx": "^0.2.
|
|
162
|
+
"bun-plugin-stx": "^0.2.414",
|
|
163
163
|
"ts-pantry": "^0.11.69"
|
|
164
164
|
},
|
|
165
165
|
"devDependencies": {
|