From 3a09e7eda75f320d0f3d5bc9cbd1f992dc50b77a Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:29:52 +0000 Subject: [PATCH 1/2] debug: rm QA message --- .../crowdin/translations/getTranslations.ts | 6 +--- src/scripts/crowdin/translations/utils.ts | 35 +------------------ 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/src/scripts/crowdin/translations/getTranslations.ts b/src/scripts/crowdin/translations/getTranslations.ts index 455750e5e67..ad6fc93f723 100644 --- a/src/scripts/crowdin/translations/getTranslations.ts +++ b/src/scripts/crowdin/translations/getTranslations.ts @@ -1,11 +1,10 @@ import fs from "fs" -import { checkMarkdown } from "../../markdownChecker" import crowdin from "../api-client/crowdinClient" import crowdinImport from "../import/main" import type { BucketsList } from "../import/types" -import { BUCKETS_PATH, DOT_CROWDIN, FILE_PATH, SUMMARY_PATH } from "./constants" +import { BUCKETS_PATH, DOT_CROWDIN, FILE_PATH } from "./constants" import getApprovedBuckets from "./getApprovedBuckets" import { decompressFile, downloadFile } from "./utils" @@ -43,9 +42,6 @@ async function main() { // Run Crowdin import script with buckets from Notion crowdinImport(buckets) - - // Check markdown - checkMarkdown(SUMMARY_PATH) } catch (error: unknown) { console.error((error as Error).message) } diff --git a/src/scripts/crowdin/translations/utils.ts b/src/scripts/crowdin/translations/utils.ts index f87beaa6947..ff318bac84d 100644 --- a/src/scripts/crowdin/translations/utils.ts +++ b/src/scripts/crowdin/translations/utils.ts @@ -1,5 +1,5 @@ import { execSync } from "child_process" -import fs, { readFileSync, unlinkSync, writeFileSync } from "fs" +import fs, { unlinkSync, writeFileSync } from "fs" import path from "path" import { Readable } from "stream" import { finished } from "stream/promises" @@ -9,9 +9,6 @@ import decompress from "decompress" import { INTL_JSON_DIR, TRANSLATIONS_DIR } from "../../../lib/constants" -import { SUMMARY_PATH } from "./constants" -import { QASummary } from "./types" - export const downloadFile = async (url: string, writePath: string) => { // Get directory from writePath and ensure it exists const dir = writePath.substring(0, writePath.lastIndexOf("/")) @@ -40,33 +37,6 @@ export const decompressFile = async (filePath: string, targetDir: string) => { console.log("✅ Decompression complete.") } -const getQAMessage = (locale: string) => { - console.log("Checking summary path:", SUMMARY_PATH) - if (!fs.existsSync(SUMMARY_PATH)) { - console.error("Could not find summary path:", SUMMARY_PATH) - throw new Error("No summary file found.") - } - - const summaryJson: QASummary = JSON.parse(readFileSync(SUMMARY_PATH, "utf-8")) - const qaResults = summaryJson[locale] - ? summaryJson[locale].map((s) => "- " + s).join("\n") - : null - - if (!qaResults) return "No QA issues found" - return ` -\`\`\`shell -yarn markdown-checker -\`\`\` - -
Unfold for ${summaryJson[locale].length} result(s) - -${qaResults} -
- -@coderabbitai review -` -} - export const createLocaleTranslationPR = ( locale: string, buckets: number[] @@ -101,9 +71,6 @@ export const createLocaleTranslationPR = ( ## Content buckets imported ${buckets.sort((a, b) => a - b).join(", ")} - - ## Markdown QA checker alerts - ${getQAMessage(locale)} ` const bodyWritePath = path.resolve(process.cwd(), "body.txt") From 517bf116405294f00048f3bd46666aca4c349d5c Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Wed, 9 Oct 2024 19:10:40 +0000 Subject: [PATCH 2/2] debug: check for paths before staging --- src/scripts/crowdin/translations/utils.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/scripts/crowdin/translations/utils.ts b/src/scripts/crowdin/translations/utils.ts index ff318bac84d..fdb59a1827d 100644 --- a/src/scripts/crowdin/translations/utils.ts +++ b/src/scripts/crowdin/translations/utils.ts @@ -58,8 +58,22 @@ export const createLocaleTranslationPR = ( }).trim() execSync(`git checkout -b ${branchName}`) execSync("git reset .") - execSync(`git add ${TRANSLATIONS_DIR}/${locale}`) - execSync(`git add ${INTL_JSON_DIR}/${locale}`) + + // Check if the translations directory exists and contains files + const translationsDir = path.join(TRANSLATIONS_DIR, locale) + if ( + fs.existsSync(translationsDir) && + fs.readdirSync(translationsDir).length > 0 + ) { + execSync(`git add ${translationsDir}`) + } + + // Check if the intl JSON directory exists and contains files + const intlJsonDir = path.join(INTL_JSON_DIR, locale) + if (fs.existsSync(intlJsonDir) && fs.readdirSync(intlJsonDir).length > 0) { + execSync(`git add ${intlJsonDir}`) + } + execSync(`git commit -m "${message}"`) execSync(`git push origin ${branchName}`)