@stelstone/server 0.26.0 → 0.26.1
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/package.json +1 -1
- package/src/adapters/github-content.mjs +21 -1
- package/src/version.mjs +1 -1
package/package.json
CHANGED
|
@@ -78,8 +78,28 @@ export function createGitHubContent({ token, owner, repo, branch, draftBranch, p
|
|
|
78
78
|
const ref = await apiGet(`/git/ref/heads/${draftBranch}`);
|
|
79
79
|
if (!ref) {
|
|
80
80
|
const base = await apiGet(`/git/ref/heads/${branch}`);
|
|
81
|
-
if (!base) throw new Error(`Published branch "${branch}" does not exist`);
|
|
81
|
+
if (!base) throw new Error(`Published branch \"${branch}\" does not exist`);
|
|
82
82
|
await apiPost(`/git/refs`, { ref: `refs/heads/${draftBranch}`, sha: base.object.sha });
|
|
83
|
+
} else {
|
|
84
|
+
// The draft branch was a snapshot of `branch` at creation — content
|
|
85
|
+
// pushed to the published branch OUTSIDE the CMS (a code deploy adding
|
|
86
|
+
// records) never reached it, so the admin could not even see those
|
|
87
|
+
// files. Found by dogfooding: stelstone.com's landing records landed
|
|
88
|
+
// on main from code and the admin listed an empty collection. Keep the
|
|
89
|
+
// draft current by merging the published branch in once per process.
|
|
90
|
+
try {
|
|
91
|
+
await apiPost(`/merges`, { base: draftBranch, head: branch });
|
|
92
|
+
} catch (err) {
|
|
93
|
+
if (err?.upstreamStatus === 409) {
|
|
94
|
+
// Same record edited on both branches: the draft (the editor's
|
|
95
|
+
// in-progress work) wins by default. Say so; don't fail reads.
|
|
96
|
+
console.warn(
|
|
97
|
+
`[github-content] draft branch \"${draftBranch}\" conflicts with \"${branch}\" — keeping draft state`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
// 204 \"nothing to merge\" parses as empty JSON and lands here too —
|
|
101
|
+
// in every case reads must proceed.
|
|
102
|
+
}
|
|
83
103
|
}
|
|
84
104
|
draftBranchReady = true;
|
|
85
105
|
}
|
package/src/version.mjs
CHANGED