From 0168d8fd7c105feb6027eb6a6eca6939921efb9a Mon Sep 17 00:00:00 2001 From: Developer Date: Sun, 13 Sep 2026 20:50:52 +0200 Subject: [PATCH] CI shells: keep a project file that is already there game_maker_serve runs project-shells.mjs unconditionally, so running the CI smoke runner on a development machine overwrote the four project documents with empty shells: revision 1301 became 1, and the name became the key from PROJECTS, because the seeders keep whatever name the server already holds. "Jump and Run" came back as "jumpRun". The shells are only ever needed on a fresh checkout, where the directory is empty, so an existing file is kept. --- tools/ci/project-shells.mjs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/ci/project-shells.mjs b/tools/ci/project-shells.mjs index 635c3c09..6dcdb972 100755 --- a/tools/ci/project-shells.mjs +++ b/tools/ci/project-shells.mjs @@ -4,6 +4,11 @@ * a project and `POST` hands out a random id, so a fresh CI checkout has to put the shells with * the known ids in place itself. The playground is left out – no tool may touch it. * + * A file that is already there is left alone. Overwriting it used to cost a development machine + * the project's whole revision history and its name: the shell carries the key from PROJECTS as + * its name, and the seeders keep whatever name they find, so "Jump and Run" came back as + * "jumpRun". Only CI ever needs the shells, and there the directory is empty. + * * Usage: node tools/ci/project-shells.mjs [dataDir] */ import { mkdir, writeFile } from 'node:fs/promises'; @@ -24,6 +29,11 @@ for (const [name, id] of Object.entries(PROJECTS)) { updatedAt: '1970-01-01T00:00:00Z', project: {}, }; - await writeFile(resolve(dir, `${id}.json`), `${JSON.stringify(doc)}\n`); - console.log(`shell ${name} ${id}`); + try { + await writeFile(resolve(dir, `${id}.json`), `${JSON.stringify(doc)}\n`, { flag: 'wx' }); + console.log(`shell ${name} ${id}`); + } catch (err) { + if (err.code !== 'EEXIST') throw err; + console.log(`kept ${name} ${id}`); + } }