Runner: json-Typ vor eigener Erkennung (R21), Erstdeploy-Rueckfall, json-index beim Veroeffentlichen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a028ce75a
commit
c256b78dae
5 files changed
+92
-14
No files matched your search
@@ -56,14 +56,18 @@ export function detectProject(files, { mode, index, previewJson } = {}) {
|
||||
const hasDev = hasScript(scripts, 'dev');
|
||||
const m = mode === 'build' || mode === 'dev' ? mode : 'auto';
|
||||
|
||||
const base = { pm, install: installCmd(pm, files), buildCmd: hasBuild ? [pm, 'run', 'build'] : null, devCmd: hasDev ? devCmdFor(pm, devPort) : null, outputDirs, devPort };
|
||||
const base = { index: indexFile, pm, install: installCmd(pm, files), buildCmd: hasBuild ? [pm, 'run', 'build'] : null, devCmd: hasDev ? devCmdFor(pm, devPort) : null, outputDirs, devPort };
|
||||
const asBuild = () => ({ kind: 'build', ...base });
|
||||
const asDev = () => ({ kind: 'dev', ...base });
|
||||
const asStatic = (hint) => ({ kind: 'static', ...base, install: [], buildCmd: null, devCmd: null, outputDirs: [], index: indexFile, ...(hint ? { hint } : {}) });
|
||||
const asStatic = (hint) => ({ kind: 'static', ...base, install: [], buildCmd: null, devCmd: null, outputDirs: [], ...(hint ? { hint } : {}) });
|
||||
|
||||
if (m === 'build') return hasBuild ? asBuild() : { ...asBuild(), error: 'Kein build-Skript in package.json' };
|
||||
if (m === 'dev') return hasDev ? asDev() : { ...asDev(), error: 'Kein dev-Skript in package.json' };
|
||||
|
||||
// R21: .webklar-preview.json-Typ zuerst. 'static' mit index.html bleibt statisch (auch mit build-Skript),
|
||||
// 'node_build' baut ausdrücklich (kein Dev-Rückfall). Ohne Typ: eigene Erkennung.
|
||||
if (pj.type === 'static' && hasIndex) return asStatic();
|
||||
if (pj.type === 'node_build' && hasBuild) return { ...asBuild(), explicitType: true };
|
||||
if (hasIndex && !hasBuild) return asStatic();
|
||||
if (hasBuild) return asBuild();
|
||||
if (hasDev) return asDev();
|
||||
|
||||
+21
-10
@@ -294,6 +294,16 @@ export function createJobs({ config, docker, fs: fsOver = {}, git, mem = readMem
|
||||
} catch { return workDir; }
|
||||
}
|
||||
|
||||
// Erstes Deploy (noch kein <sub>-Ordner): Quellstand statisch veröffentlichen statt 403/leer (Verhalten des bisherigen Pfads).
|
||||
async function firstDeployFallback(job, workDir, d, problem, onLine) {
|
||||
if (job.mode === 'build') return false;
|
||||
const target = join(config.previewsRoot, job.sub);
|
||||
if (await fs.lstat(target).then(() => true, () => false)) return false;
|
||||
onLine(`${problem} – erstes Deploy, Quellstand wird statisch veröffentlicht (Hinweis: Build fehlgeschlagen)`);
|
||||
await publish(job, await webrootOf(workDir, job.index || d.index || ''), { skipGit: true, skipNodeModules: true, onLine });
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---- Ablauf eines Build-Laufs ----
|
||||
const execute = (run, job) => holdCache(job.repo, () => executeRun(run, job));
|
||||
async function executeRun(run, job) {
|
||||
@@ -307,10 +317,17 @@ export function createJobs({ config, docker, fs: fsOver = {}, git, mem = readMem
|
||||
const d = prep.detected;
|
||||
run.detected = d;
|
||||
if (d.error) throw new Error(d.error);
|
||||
if (prep.error) throw new Error(prep.error);
|
||||
// Build-/Installationsproblem: erstes Deploy ⇒ Quellstand statisch (wie bisher), sonst Fehler (alte Preview bleibt)
|
||||
const fallbackOr = async (problem) => {
|
||||
if (!(await firstDeployFallback(job, workDir, d, problem, onLine))) throw new Error(problem);
|
||||
run.result = 'static';
|
||||
run.hint = 'Build fehlgeschlagen – Quellstand statisch veröffentlicht';
|
||||
};
|
||||
if (prep.error) { await fallbackOr(prep.error); final = 'done'; }
|
||||
else
|
||||
if (d.kind === 'static') {
|
||||
if (d.hint) onLine(d.hint);
|
||||
await publish(job, await webrootOf(workDir, job.index || ''), { skipGit: true, onLine });
|
||||
await publish(job, await webrootOf(workDir, d.index || job.index || ''), { skipGit: true, onLine });
|
||||
run.result = 'static';
|
||||
} else if (d.kind === 'dev') {
|
||||
run.result = 'dev';
|
||||
@@ -325,14 +342,8 @@ export function createJobs({ config, docker, fs: fsOver = {}, git, mem = readMem
|
||||
if (!out) problem = `Kein Ausgabeordner gefunden (gesucht: ${d.outputDirs.join(', ')})`;
|
||||
}
|
||||
if (problem) {
|
||||
if (job.mode === 'auto' && d.devCmd) { onLine(`${problem} – Dev-Server wird verwendet`); run.result = 'dev'; }
|
||||
else if (!out && !r.code && job.mode !== 'build') {
|
||||
// Build lief, erzeugte aber keinen Ausgabeordner mit index.html: wie bisher den Quellstand statisch
|
||||
// veröffentlichen (index-Unterordner, Kandidat/Platzhalter) statt die Subdomain zu verlieren.
|
||||
onLine(`${problem} – Quellstand wird statisch veröffentlicht`);
|
||||
await publish(job, await webrootOf(workDir, job.index || ''), { skipGit: true, skipNodeModules: true, onLine });
|
||||
run.result = 'static';
|
||||
} else throw new Error(problem);
|
||||
if (job.mode === 'auto' && d.devCmd && !d.explicitType) { onLine(`${problem} – Dev-Server wird verwendet`); run.result = 'dev'; }
|
||||
else await fallbackOr(problem);
|
||||
} else {
|
||||
await publish(job, out, { skipGit: false, onLine });
|
||||
run.result = 'build';
|
||||
|
||||
Reference in new issue
Block a user