From 81bba4ffff58150f1e22de120fca85ece28bdbda Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Thu, 3 Jul 2025 22:15:14 +0200 Subject: [PATCH] Update "generatei18nResources" script to commit changes --- tools/scripts/weblate/generatei18nResources.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/scripts/weblate/generatei18nResources.ts b/tools/scripts/weblate/generatei18nResources.ts index acea1db7..b767ab5f 100644 --- a/tools/scripts/weblate/generatei18nResources.ts +++ b/tools/scripts/weblate/generatei18nResources.ts @@ -8,6 +8,7 @@ import path from 'path'; import fs from 'fs'; +import { execSync } from 'child_process'; import { fetchWeblateLanguageStats, getWeblateLanguageStatsFor, @@ -16,7 +17,9 @@ import { import { WeblateLanguageStatistic } from './Weblate.types.ts'; import { TRANSLATED_PERCENT_THRESHOLD } from './Weblate.constants.ts'; -const outputFilePath = path.join(import.meta.dirname, '../../../src/i18n/index.ts'); +const FILE_PATH = 'src/i18n/index.ts'; + +const outputFilePath = path.join(import.meta.dirname, `../../../${FILE_PATH}`); const resourcesDirPath = path.join(import.meta.dirname, '../../../public/locales'); const extractLanguageCode = (resourceFileNames: string): string => @@ -57,6 +60,19 @@ const generateResources = async () => { ); fs.writeFileSync(outputFilePath, updatedFileContent); + + execSync('yarn tsc', { stdio: 'inherit' }); + + execSync(`yarn eslint --fix ${FILE_PATH}`, { stdio: 'inherit' }); + + const hasFileChanged = execSync('git status --porcelain').toString().includes(FILE_PATH); + if (!hasFileChanged) { + return; + } + + execSync('git reset'); + execSync(`git add ${FILE_PATH}`); + execSync('git commit -m "Update available languages"'); }; generateResources();