From b775d7098574d788ea4f9b8524ff287b79d495de Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 29 Oct 2022 00:33:07 +0300 Subject: [PATCH] Add check of valid translations jsons to GA --- .github/workflows/main.yml | 2 ++ package.json | 1 + scripts/check-translation-jsons.ts | 20 +++++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27f12c2fa..cf1f0794a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,3 +34,5 @@ jobs: run: npm run lint:styles - name: Typecheck run: npm run typecheck + - name: Check translations jsons + run: npm run check-translation-jsons:no-write diff --git a/package.json b/package.json index 03016a5d5..a5fc2d1a0 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "create-misc-json": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/create-misc-json.ts", "create-analyzer-json": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/create-analyzer-json.ts", "check-translation-jsons": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/check-translation-jsons.ts && npm run prettier:write-translation-progress", + "check-translation-jsons:no-write": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/check-translation-jsons.ts --no-write", "replace-img-names": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/replace-img-names.ts", "remove-bad-custom-urls": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/remove-bad-custom-urls.ts", "lint:ts": "eslint . --ext .ts,.tsx", diff --git a/scripts/check-translation-jsons.ts b/scripts/check-translation-jsons.ts index 25bfe7d15..eaa21339e 100644 --- a/scripts/check-translation-jsons.ts +++ b/scripts/check-translation-jsons.ts @@ -1,8 +1,10 @@ -// 1) create status.json - import fs from "fs"; import path from "path"; +const NO_WRITE_KEY = "--no-write"; + +const dontWrite = process.argv.includes(NO_WRITE_KEY); + const otherLanguageTranslationPath = (code?: string, fileName?: string) => path.join( ...[__dirname, "..", "public", "locales", code, fileName].filter( @@ -83,13 +85,17 @@ const markdown = createTranslationProgessMarkdown({ totalTranslationCounts, }); -fs.writeFileSync( - path.join(__dirname, "..", "translation-progress.md"), - markdown -); +if (!dontWrite) { + fs.writeFileSync( + path.join(__dirname, "..", "translation-progress.md"), + markdown + ); +} // eslint-disable-next-line no-console -console.log("translation-progress.md written"); +console.log( + dontWrite ? "translation-progress.md ok" : "translation-progress.md written" +); function validateNoExtraKeysInOther({ english,