From b531223c04c48b3c9f90b5d62a4e791bdef559ac Mon Sep 17 00:00:00 2001 From: Rin <58572875+TurtIeSocks@users.noreply.github.com> Date: Sun, 23 Aug 2026 21:37:26 -0400 Subject: [PATCH] fix(build): write a trailing newline from the JSON generators The config sync job on v2 failed because `bun run config:env` rewrites config/custom-environment-variables.json without a trailing newline, and the pre-commit hook now runs Biome, which wants one. The committed file only had that newline because Prettier used to add it on the way past, so nothing noticed until Prettier went away. Fixing it in the generators rather than teaching Biome to ignore the file: these are text files and should end with a newline regardless of who is checking them. The same bug was sitting in three other generators, including the locales one, whose job also commits its output and would have failed the same way the first time it ran. Co-Authored-By: Claude Opus 5 --- packages/config/lib/scripts/genEnvConfig.js | 2 +- packages/locales/lib/missing.js | 2 +- packages/locales/lib/utils.js | 3 ++- packages/masterfile/lib/index.js | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/config/lib/scripts/genEnvConfig.js b/packages/config/lib/scripts/genEnvConfig.js index eb7669056..9c919e03e 100644 --- a/packages/config/lib/scripts/genEnvConfig.js +++ b/packages/config/lib/scripts/genEnvConfig.js @@ -31,7 +31,7 @@ const generateEnvConfig = async () => { resolve( `${__dirname}/../../../../config/custom-environment-variables.json`, ), - JSON.stringify(recursiveObjCheck(sourceConfig), null, 2), + `${JSON.stringify(recursiveObjCheck(sourceConfig), null, 2)}\n`, ) } diff --git a/packages/locales/lib/missing.js b/packages/locales/lib/missing.js index 3e26edc9e..5f68b7a52 100644 --- a/packages/locales/lib/missing.js +++ b/packages/locales/lib/missing.js @@ -41,7 +41,7 @@ async function missingAll() { ? fileName.replace('.json', '.js') : fileName, ), - JSON.stringify(missingKeys, null, 2), + `${JSON.stringify(missingKeys, null, 2)}\n`, ) log.info(TAGS.locales, fileName, 'file saved.') }), diff --git a/packages/locales/lib/utils.js b/packages/locales/lib/utils.js index d20bfa01f..7a258eb6b 100644 --- a/packages/locales/lib/utils.js +++ b/packages/locales/lib/utils.js @@ -67,10 +67,11 @@ function readLocaleDirectory(human = false) { async function writeJson(translations, ...directories) { try { const resolved = resolve(...directories) - const file = + const contents = typeof translations === 'string' ? translations : JSON.stringify(translations, null, 2) + const file = contents.endsWith('\n') ? contents : `${contents}\n` await fs.writeFile(resolved, file, 'utf8') log.info(TAGS.locales, 'wrote file', `${resolved.split('/').pop()}`) diff --git a/packages/masterfile/lib/index.js b/packages/masterfile/lib/index.js index 920d076ec..3ad7b8f22 100644 --- a/packages/masterfile/lib/index.js +++ b/packages/masterfile/lib/index.js @@ -69,7 +69,7 @@ const generate = async (save = false, historicRarity = {}, dbRarity = {}) => { if (save) { await fs.promises.writeFile( resolve(`${__dirname}/data/masterfile.json`), - JSON.stringify(newMf, null, 2), + `${JSON.stringify(newMf, null, 2)}\n`, 'utf8', ) }