fix(preview): Status bleibt bei Runner-Builds, dev-Label, Abgleich mit dem Runner, Längenkürzung
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19cd8f90ce
commit
b7cbe3aa38
8 files changed
+396
-15
No files matched your search
@@ -84,7 +84,7 @@ export function devSubdomainsFromHostsFile(content) {
|
||||
async function getDevProjects() {
|
||||
try {
|
||||
const docs = await listDocuments(config.collections.websiteProjects, [
|
||||
Query.equal('previewState', ['sleeping', 'starting', 'online']),
|
||||
Query.equal('previewState', ['sleeping', 'starting', 'online', 'building', 'failed']),
|
||||
Query.limit(500),
|
||||
])
|
||||
return docs.filter(
|
||||
@@ -463,7 +463,7 @@ export async function waitForDevRegistration() {
|
||||
|
||||
let pendingProjects = null
|
||||
|
||||
async function registerDevRound(projects) {
|
||||
export async function registerDevRound(projects) {
|
||||
const key = envKey()
|
||||
await Promise.allSettled(
|
||||
projects.map(async (project) => {
|
||||
@@ -541,14 +541,27 @@ const SHA_RE = /^[0-9a-f]{7,40}$/
|
||||
const KEY_MISSING = 'Preview-Variablen nicht entschlüsselbar (PREVIEW_ENV_KEY fehlt)'
|
||||
const KEY_BROKEN = 'Preview-Variablen nicht entschlüsselbar'
|
||||
|
||||
/** Gibt es fuer das Repo einen laufenden Verfolger in diesem Prozess? (Abgleich, R18) */
|
||||
export const hasLiveFollower = (repoFullName) => latestRun.has(repoFullName)
|
||||
|
||||
/** Wartet auf alle laufenden Hintergrund-Verfolger (Tests, geordnetes Beenden). */
|
||||
export async function waitForRunFollowers() {
|
||||
while (followers.size) await Promise.allSettled([...followers])
|
||||
}
|
||||
|
||||
/**
|
||||
* C1: Mit aktivem Runner liefert runDeploy nur "queued"/"skipped"/Fehler des Auftrags - das ist
|
||||
* kein Deploy-Ergebnis. Aufrufer duerfen dann status/provisioningStatus NICHT anfassen
|
||||
* (sonst sperrt auth.js "not_ready" ein bereits bereites Projekt aus). Der Verfolger setzt
|
||||
* bei Erfolg 'deployed'/'ready'.
|
||||
*/
|
||||
export function deployKeepsStatus(deployResult) {
|
||||
return Boolean(config.previewRunner.enabled && deployResult && !deployResult.deployed)
|
||||
}
|
||||
|
||||
// previewDetected: static | build:<pm> | dev:<pm> (der Runner liefert kein Framework)
|
||||
export function detectedLabel(detected, result) {
|
||||
const kind = detected?.kind || result
|
||||
const kind = result || detected?.kind
|
||||
if (kind === 'static') return 'static'
|
||||
const pm = detected?.pm || 'npm'
|
||||
return kind === 'dev' ? `dev:${pm}` : `build:${pm}`
|
||||
@@ -567,7 +580,19 @@ async function findProject(repoFullName) {
|
||||
}
|
||||
}
|
||||
|
||||
// Attributgroessen (Appwrite lehnt laengere Werte ab und der Patch ginge verloren)
|
||||
const ATTR_MAX = { previewError: 500, previewDetected: 40, previewBranch: 100 }
|
||||
|
||||
function clampAttrs(data) {
|
||||
const out = { ...data }
|
||||
for (const [key, max] of Object.entries(ATTR_MAX)) {
|
||||
if (typeof out[key] === 'string' && out[key].length > max) out[key] = out[key].slice(0, max)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
async function patchProject(repoFullName, project, data) {
|
||||
data = clampAttrs(data)
|
||||
const doc = project?.$id ? project : await findProject(repoFullName)
|
||||
if (!doc?.$id) return null
|
||||
try {
|
||||
@@ -630,6 +655,9 @@ async function followRun({ repoFullName, project, token, runId, subdomain, job,
|
||||
previewError: warning || '',
|
||||
previewBranch: job.branch,
|
||||
previewBuiltSha: run.sha || job.sha,
|
||||
// Wie der Legacy-Erfolg: Projekt ist bereit (C1). Ein Fehlschlag senkt nie herab.
|
||||
status: 'deployed',
|
||||
provisioningStatus: 'ready',
|
||||
}
|
||||
if (run.result === 'dev') {
|
||||
await patchProject(repoFullName, project, { ...base, previewState: 'sleeping' })
|
||||
|
||||
Reference in new issue
Block a user