@stacksjs/buddy 0.75.247 → 0.75.249
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/deployment-revision.d.ts +16 -3
- package/dist/deployment-revision.js +3 -2
- package/package.json +55 -55
|
@@ -17,9 +17,22 @@ export declare function automatedDeploymentRevision(environment: string, variabl
|
|
|
17
17
|
* production already runs one of those.
|
|
18
18
|
*
|
|
19
19
|
* The branch is fetched without updating any ref (FETCH_HEAD only). A shallow
|
|
20
|
-
* checkout
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* checkout cannot simply enumerate the difference: a newer merge can expose
|
|
21
|
+
* shared ancestors hidden behind the CI boundary, making an older live release
|
|
22
|
+
* look newer even when CI is a proven ancestor. It used to `--unshallow` for
|
|
23
|
+
* that, and on a large repository (hq.training: a 277 MiB pack, ~2,600
|
|
24
|
+
* commits) that outran its 60-second limit on the runner, so every deploy that
|
|
25
|
+
* raced a push failed and production stopped updating (2026-10-20). Full
|
|
26
|
+
* history is not what the question needs. `rev-list <ci>..<tip>` is exact once
|
|
27
|
+
* CI is an ancestor of the tip and every shallow boundary the tip reaches is a
|
|
28
|
+
* proper ancestor of CI: nothing that came after CI can hide below a boundary
|
|
29
|
+
* CI already descends from, and CI's own parents are present to exclude the
|
|
30
|
+
* history it shares with a merged side branch. So the branch is deepened in
|
|
31
|
+
* steps (64, 512, 4096 commits) until that holds, and only a history that
|
|
32
|
+
* still does not satisfy it falls back to `--unshallow`, with a far longer
|
|
33
|
+
* limit. Depth cuts can still hide a path from CI to an older commit a merge
|
|
34
|
+
* reaches more directly; that only lists the older commit as newer, which
|
|
35
|
+
* refuses a deploy rather than shipping backwards.
|
|
23
36
|
*/
|
|
24
37
|
export declare function assertCurrentDeploymentRevision(revision: AutomatedDeploymentRevision | undefined, cwd?: unknown): Promise<DeploymentRevisionCheck | undefined>;
|
|
25
38
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{execFile}from"node:child_process";import process from"node:process";import{promisify}from"node:util";const execute=promisify(execFile);export function automatedDeploymentRevision(environment,variables=process.env){if(environment!=="production")return;const prefix=variables.REVIEWOS==="true"?"REVIEWOS":variables.GITHUB_ACTIONS==="true"?"GITHUB":void 0;if(!prefix)return;const ref=variables[`${prefix}_REF`],sha=variables[`${prefix}_SHA`];if(!ref?.startsWith("refs/heads/")||!sha||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(sha))throw Error("Automated production deployment requires a branch ref and full commit SHA from the CI provider.");return Object.freeze({ref,sha:sha.toLowerCase()})}export async function assertCurrentDeploymentRevision(revision,cwd=process.cwd()){if(!revision)return;const git=async(operation,args,options={})=>{try{return(await execute("git",args,{cwd,timeout:
|
|
2
|
-
`).map((line)=>line.split(/\s+/));if(lines.length!==1||lines[0]?.[1]!==revision.ref||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(lines[0]?.[0]??""))throw Error("Origin did not return one authoritative branch head; production deployment stopped.");if(lines[0][0].toLowerCase()===revision.sha)return Object.freeze({revision,newer:[]});const
|
|
1
|
+
import{execFile}from"node:child_process";import{readFile}from"node:fs/promises";import{resolve}from"node:path";import process from"node:process";import{promisify}from"node:util";const execute=promisify(execFile);export function automatedDeploymentRevision(environment,variables=process.env){if(environment!=="production")return;const prefix=variables.REVIEWOS==="true"?"REVIEWOS":variables.GITHUB_ACTIONS==="true"?"GITHUB":void 0;if(!prefix)return;const ref=variables[`${prefix}_REF`],sha=variables[`${prefix}_SHA`];if(!ref?.startsWith("refs/heads/")||!sha||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(sha))throw Error("Automated production deployment requires a branch ref and full commit SHA from the CI provider.");return Object.freeze({ref,sha:sha.toLowerCase()})}export async function assertCurrentDeploymentRevision(revision,cwd=process.cwd()){if(!revision)return;const git=async(operation,args,options={})=>{const timeoutSeconds=options.timeoutSeconds??60;try{return(await execute("git",args,{cwd,timeout:timeoutSeconds*1000,maxBuffer:16777216,env:{...process.env,GIT_TERMINAL_PROMPT:"0",GCM_INTERACTIVE:"never"}})).stdout.trim()}catch(error){if(options.allowFailure)return null;let status="Git failed to execute";if(error instanceof Error){if("code"in error&&error.code==="ERR_CHILD_PROCESS_STDIO_MAXBUFFER")status="Git exceeded its output limit";else if("killed"in error&&error.killed===!0)status=`Git exceeded its ${timeoutSeconds}-second limit`;else if("code"in error&&typeof error.code==="number"&&Number.isSafeInteger(error.code)&&error.code>=0)status=`Git exited with status ${error.code}`}throw Error(`Cannot verify the automated deployment revision against origin while ${operation}: ${status}; production deployment stopped.`)}},isAncestor=async(ancestor,descendant)=>await git("checking revision ancestry",["merge-base","--is-ancestor",ancestor,descendant],{allowFailure:!0})!==null,isShallow=async()=>await git("checking repository history depth",["rev-parse","--is-shallow-repository"])==="true",fetchedTip=async()=>String(await git("reading the fetched branch head",["rev-parse","--verify","FETCH_HEAD^{commit}"])).toLowerCase();await git("validating the branch ref",["check-ref-format",revision.ref]);if((await git("reading the checkout revision",["rev-parse","--verify","HEAD"]))?.toLowerCase()!==revision.sha)throw Error("The deployment checkout does not match the CI commit; production deployment stopped.");const remote=await git("reading the origin branch head",["ls-remote","--exit-code","--refs","origin",revision.ref]),lines=String(remote).split(`
|
|
2
|
+
`).map((line)=>line.split(/\s+/));if(lines.length!==1||lines[0]?.[1]!==revision.ref||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(lines[0]?.[0]??""))throw Error("Origin did not return one authoritative branch head; production deployment stopped.");if(lines[0][0].toLowerCase()===revision.sha)return Object.freeze({revision,newer:[]});const historySuffices=async(tip)=>{if(!await isAncestor(revision.sha,tip))return!1;if(!await isShallow())return!0;const shallowFile=resolve(cwd,String(await git("locating the shallow boundary list",["rev-parse","--git-path","shallow"]))),boundaries=await readFile(shallowFile,"utf8").then((text)=>text.split(`
|
|
3
|
+
`).map((line)=>line.trim().toLowerCase()).filter(Boolean),()=>[]);for(const boundary of boundaries){if(!await isAncestor(boundary,tip))continue;if(boundary===revision.sha||!await isAncestor(boundary,revision.sha))return!1}return!0};let tip;if(!await isShallow()){await git("fetching the origin branch history",["fetch","--quiet","--no-tags","origin",revision.ref],{timeoutSeconds:180});tip=await fetchedTip()}else{let enough=!1;tip="";for(const depth of[64,512,4096]){await git("deepening the origin branch history",["fetch","--quiet","--no-tags",`--depth=${depth}`,"origin",revision.ref],{timeoutSeconds:180});tip=await fetchedTip();if(enough=await historySuffices(tip))break;if(!await isShallow())break}if(!enough&&await isShallow()){await git("fetching the origin branch history",["fetch","--quiet","--no-tags","--unshallow","origin",revision.ref],{timeoutSeconds:600});if(await isShallow())throw Error("Cannot verify complete origin history; production deployment stopped.");tip=await fetchedTip()}}if(!await isAncestor(revision.sha,tip))throw Error("This CI commit is no longer on the origin branch; production deployment stopped. Deploy the current branch head.");const newer=String(await git("listing newer branch revisions",["rev-list",`${revision.sha}..${tip}`])).split(`
|
|
3
4
|
`).map((line)=>line.trim().toLowerCase()).filter(Boolean);return Object.freeze({revision,newer})}export function assertNotBehindLiveRelease(check,liveReleases){if(!check||check.newer.length===0)return;for(const raw of liveReleases){const id=String(raw??"").trim().toLowerCase();if(!/^[a-f0-9]{7,64}$/.test(id))continue;if(check.newer.some((sha)=>sha.startsWith(id)))throw Error(`Production already runs ${id}, which is newer than this CI commit; production deployment stopped. Deploy the current branch head.`)}}export function liveReleasesCommand(slug){if(!/^[a-z0-9][a-z0-9-]*$/i.test(slug))throw Error("A project slug is letters, digits and dashes.");return`for d in /var/www/${slug}-*/current; do [ -L "$d" ] && basename "$(readlink -f "$d")"; done; true`}
|
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.249",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -96,68 +96,68 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@stacksjs/bumpx": "^0.2.25",
|
|
99
|
-
"@stacksjs/actions": "0.75.
|
|
100
|
-
"@stacksjs/ai": "0.75.
|
|
101
|
-
"@stacksjs/alias": "0.75.
|
|
102
|
-
"@stacksjs/analytics": "0.75.
|
|
103
|
-
"@stacksjs/api": "0.75.
|
|
104
|
-
"@stacksjs/arrays": "0.75.
|
|
105
|
-
"@stacksjs/auth": "0.75.
|
|
106
|
-
"@stacksjs/browser-extension": "0.75.
|
|
107
|
-
"@stacksjs/build": "0.75.
|
|
108
|
-
"@stacksjs/cache": "0.75.
|
|
109
|
-
"@stacksjs/chat": "0.75.
|
|
99
|
+
"@stacksjs/actions": "0.75.249",
|
|
100
|
+
"@stacksjs/ai": "0.75.249",
|
|
101
|
+
"@stacksjs/alias": "0.75.249",
|
|
102
|
+
"@stacksjs/analytics": "0.75.249",
|
|
103
|
+
"@stacksjs/api": "0.75.249",
|
|
104
|
+
"@stacksjs/arrays": "0.75.249",
|
|
105
|
+
"@stacksjs/auth": "0.75.249",
|
|
106
|
+
"@stacksjs/browser-extension": "0.75.249",
|
|
107
|
+
"@stacksjs/build": "0.75.249",
|
|
108
|
+
"@stacksjs/cache": "0.75.249",
|
|
109
|
+
"@stacksjs/chat": "0.75.249",
|
|
110
110
|
"@stacksjs/clapp": "^0.2.16",
|
|
111
|
-
"@stacksjs/cli": "0.75.
|
|
112
|
-
"@stacksjs/cloud": "0.75.
|
|
113
|
-
"@stacksjs/cms": "0.75.
|
|
114
|
-
"@stacksjs/collections": "0.75.
|
|
115
|
-
"@stacksjs/commerce": "0.75.
|
|
116
|
-
"@stacksjs/config": "0.75.
|
|
117
|
-
"@stacksjs/database": "0.75.
|
|
118
|
-
"@stacksjs/desktop-build": "0.75.
|
|
119
|
-
"@stacksjs/dns": "0.75.
|
|
111
|
+
"@stacksjs/cli": "0.75.249",
|
|
112
|
+
"@stacksjs/cloud": "0.75.249",
|
|
113
|
+
"@stacksjs/cms": "0.75.249",
|
|
114
|
+
"@stacksjs/collections": "0.75.249",
|
|
115
|
+
"@stacksjs/commerce": "0.75.249",
|
|
116
|
+
"@stacksjs/config": "0.75.249",
|
|
117
|
+
"@stacksjs/database": "0.75.249",
|
|
118
|
+
"@stacksjs/desktop-build": "0.75.249",
|
|
119
|
+
"@stacksjs/dns": "0.75.249",
|
|
120
120
|
"@stacksjs/dnsx": "^0.2.3",
|
|
121
|
-
"@stacksjs/email": "0.75.
|
|
122
|
-
"@stacksjs/enums": "0.75.
|
|
123
|
-
"@stacksjs/env": "0.75.
|
|
124
|
-
"@stacksjs/error-handling": "0.75.
|
|
125
|
-
"@stacksjs/events": "0.75.
|
|
126
|
-
"@stacksjs/features": "0.75.
|
|
127
|
-
"@stacksjs/git": "0.75.
|
|
121
|
+
"@stacksjs/email": "0.75.249",
|
|
122
|
+
"@stacksjs/enums": "0.75.249",
|
|
123
|
+
"@stacksjs/env": "0.75.249",
|
|
124
|
+
"@stacksjs/error-handling": "0.75.249",
|
|
125
|
+
"@stacksjs/events": "0.75.249",
|
|
126
|
+
"@stacksjs/features": "0.75.249",
|
|
127
|
+
"@stacksjs/git": "0.75.249",
|
|
128
128
|
"@stacksjs/gitit": "^0.2.5",
|
|
129
|
-
"@stacksjs/health": "0.75.
|
|
129
|
+
"@stacksjs/health": "0.75.249",
|
|
130
130
|
"@stacksjs/httx": "^0.1.10",
|
|
131
|
-
"@stacksjs/image": "0.75.
|
|
132
|
-
"@stacksjs/lint": "0.75.
|
|
133
|
-
"@stacksjs/logging": "0.75.
|
|
134
|
-
"@stacksjs/notifications": "0.75.
|
|
135
|
-
"@stacksjs/objects": "0.75.
|
|
136
|
-
"@stacksjs/orm": "0.75.
|
|
137
|
-
"@stacksjs/path": "0.75.
|
|
138
|
-
"@stacksjs/payments": "0.75.
|
|
139
|
-
"@stacksjs/realtime": "0.75.
|
|
140
|
-
"@stacksjs/router": "0.75.
|
|
131
|
+
"@stacksjs/image": "0.75.249",
|
|
132
|
+
"@stacksjs/lint": "0.75.249",
|
|
133
|
+
"@stacksjs/logging": "0.75.249",
|
|
134
|
+
"@stacksjs/notifications": "0.75.249",
|
|
135
|
+
"@stacksjs/objects": "0.75.249",
|
|
136
|
+
"@stacksjs/orm": "0.75.249",
|
|
137
|
+
"@stacksjs/path": "0.75.249",
|
|
138
|
+
"@stacksjs/payments": "0.75.249",
|
|
139
|
+
"@stacksjs/realtime": "0.75.249",
|
|
140
|
+
"@stacksjs/router": "0.75.249",
|
|
141
141
|
"@stacksjs/rpx": "^0.11.54",
|
|
142
|
-
"@stacksjs/scheduler": "0.75.
|
|
143
|
-
"@stacksjs/search-engine": "0.75.
|
|
144
|
-
"@stacksjs/security": "0.75.
|
|
145
|
-
"@stacksjs/server": "0.75.
|
|
146
|
-
"@stacksjs/sites": "0.75.
|
|
147
|
-
"@stacksjs/skills": "0.75.
|
|
148
|
-
"@stacksjs/socials": "0.75.
|
|
149
|
-
"@stacksjs/storage": "0.75.
|
|
150
|
-
"@stacksjs/strings": "0.75.
|
|
142
|
+
"@stacksjs/scheduler": "0.75.249",
|
|
143
|
+
"@stacksjs/search-engine": "0.75.249",
|
|
144
|
+
"@stacksjs/security": "0.75.249",
|
|
145
|
+
"@stacksjs/server": "0.75.249",
|
|
146
|
+
"@stacksjs/sites": "0.75.249",
|
|
147
|
+
"@stacksjs/skills": "0.75.249",
|
|
148
|
+
"@stacksjs/socials": "0.75.249",
|
|
149
|
+
"@stacksjs/storage": "0.75.249",
|
|
150
|
+
"@stacksjs/strings": "0.75.249",
|
|
151
151
|
"@stacksjs/stx": "^0.2.607",
|
|
152
|
-
"@stacksjs/testing": "0.75.
|
|
153
|
-
"@stacksjs/tinker": "0.75.
|
|
152
|
+
"@stacksjs/testing": "0.75.249",
|
|
153
|
+
"@stacksjs/tinker": "0.75.249",
|
|
154
154
|
"@stacksjs/tlsx": "^0.13.19",
|
|
155
155
|
"@stacksjs/ts-cloud": "^0.16.58",
|
|
156
|
-
"@stacksjs/tunnel": "0.75.
|
|
157
|
-
"@stacksjs/types": "0.75.
|
|
158
|
-
"@stacksjs/ui": "0.75.
|
|
159
|
-
"@stacksjs/utils": "0.75.
|
|
160
|
-
"@stacksjs/validation": "0.75.
|
|
156
|
+
"@stacksjs/tunnel": "0.75.249",
|
|
157
|
+
"@stacksjs/types": "0.75.249",
|
|
158
|
+
"@stacksjs/ui": "0.75.249",
|
|
159
|
+
"@stacksjs/utils": "0.75.249",
|
|
160
|
+
"@stacksjs/validation": "0.75.249",
|
|
161
161
|
"ajv": "^8.20.0",
|
|
162
162
|
"ajv-formats": "^3.0.1",
|
|
163
163
|
"bun-plugin-stx": "^0.2.607",
|