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.
This commit is contained in:
Developer committed 2026-09-13 20:50:52 +02:00
1 parent 99c5d2ad78
commit 0168d8fd7c
1 file changed
+12 -2
+12 -2
View File
@@ -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}`);
}
}