From 6aca32d74b4d73209bd7f91743d258dea9a62298 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Tue, 7 Jan 2025 17:12:46 -0600 Subject: [PATCH] Various fixes --- .github/workflows/download-translations.yml | 8 ++++++-- development/download-translations.js | 16 ++++++---------- package.json | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/download-translations.yml b/.github/workflows/download-translations.yml index 645fd90d02..88d8fa95d9 100644 --- a/.github/workflows/download-translations.yml +++ b/.github/workflows/download-translations.yml @@ -57,7 +57,7 @@ jobs: for branch in $all_branches; do if [[ $branch == update-translations-* ]]; then echo "Deleting branch: $branch" - GH_TOKEN="$FORK_GH_TOKEN" gh api "repos/$FORK_REPO/git/refs/heads/$branch" -X DELETE + git branch -d origin "$branch" else echo "Keeping branch: $branch" fi @@ -75,7 +75,11 @@ jobs: git push origin "$new_branch" # Create pull request - gh pr create --head --fill --repo "$UPSTREAM_REPO" + GH_TOKEN="$UPSTREAM_GH_TOKEN" gh pr create \ + --head "$new_branch" \ + --repo "$UPSTREAM_REPO" \ + --title "[Automated] Update translations $(date -u "+%Y-%m-%d")" \ + --body "This pull request was made by a robot." env: FORK_REPO: "DangoCat/extensions" # This token has contents write permissions on fork repository diff --git a/development/download-translations.js b/development/download-translations.js index 7877153248..6c3e09244e 100644 --- a/development/download-translations.js +++ b/development/download-translations.js @@ -138,9 +138,7 @@ const downloadTranslatedResource = async (resource, locale) => { }); } - const translationsResponse = await fetch(urlToDownload, { - signal: AbortSignal.timeout(10000 * 60), - }); + const translationsResponse = await fetch(urlToDownload); const rawTranslations = await translationsResponse.json(); const withoutDeveloperComments = removeDeveloperComments(rawTranslations); const withoutEmptyTranslations = removeEmptyTranslations( @@ -193,18 +191,16 @@ const downloadAllResourceTranslations = async (resource) => { const run = async () => { console.log("This is going to take a while."); - const [runtimeStrings, metadataStrings] = await Promise.all([ - downloadAllResourceTranslations(RUNTIME_RESOURCE), - downloadAllResourceTranslations(METADATA_RESOURCE), - ]); - + console.log('Downloading runtime...'); fs.writeFileSync( pathUtil.join(__dirname, "../translations/extension-runtime.json"), - JSON.stringify(runtimeStrings, null, 4) + JSON.stringify(await downloadAllResourceTranslations(RUNTIME_RESOURCE), null, 4) ); + + console.log('Downloading metadata...'); fs.writeFileSync( pathUtil.join(__dirname, "../translations/extension-metadata.json"), - JSON.stringify(metadataStrings, null, 4) + JSON.stringify(await downloadAllResourceTranslations(METADATA_RESOURCE), null, 4) ); }; diff --git a/package.json b/package.json index 7f65e8a386..1a84b5bd41 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "lint": "eslint development extensions --max-warnings=0", "format": "prettier . --write", "check-format": "prettier . --check", - "upload-translations": "node development/upload-translations.js" + "upload-translations": "node development/upload-translations.js", + "download-translations": "node development/download-translations.js" }, "repository": { "type": "git",