From 3ed507a8172842fd503e191b252596f5a3651b9f Mon Sep 17 00:00:00 2001 From: "Nicholas Carrigan (he/him)" Date: Wed, 25 Aug 2021 20:02:10 -0700 Subject: [PATCH] fix: unhide this string (#43292) Co-authored-by: Oliver Eyton-Williams --- .../crowdin-i18n-curriculum-upload.yml | 10 ++++++ .../actions/unhide-specific-string/action.yml | 12 +++++++ .../actions/unhide-specific-string/index.js | 33 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tools/crowdin/actions/unhide-specific-string/action.yml create mode 100644 tools/crowdin/actions/unhide-specific-string/index.js diff --git a/.github/workflows/crowdin-i18n-curriculum-upload.yml b/.github/workflows/crowdin-i18n-curriculum-upload.yml index f6aeb0cf72..cb1b165e99 100644 --- a/.github/workflows/crowdin-i18n-curriculum-upload.yml +++ b/.github/workflows/crowdin-i18n-curriculum-upload.yml @@ -71,3 +71,13 @@ jobs: CROWDIN_API_URL: 'https://freecodecamp.crowdin.com/api/v2/' CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CURRICULUM }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }} + + - name: Unhide Title of Use && For a More Concise Conditional + uses: ./tools/crowdin/actions/unhide-specific-string + with: + filename: 'react/use--for-a-more-concise-conditional.md' + string-content: 'Use && for a More Concise Conditional' + env: + CROWDIN_API_URL: 'https://freecodecamp.crowdin.com/api/v2/' + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CURRICULUM }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }} diff --git a/tools/crowdin/actions/unhide-specific-string/action.yml b/tools/crowdin/actions/unhide-specific-string/action.yml new file mode 100644 index 0000000000..5ce7b9952a --- /dev/null +++ b/tools/crowdin/actions/unhide-specific-string/action.yml @@ -0,0 +1,12 @@ +name: 'Unhide Specific String' +description: "Updates a specific string to be not hidden" +runs: + using: 'node12' + main: './index.js' +inputs: + filename: + description: 'name of file with specific string to hide' + required: true + string-content: + description: 'text content of string to unhide' + required: true diff --git a/tools/crowdin/actions/unhide-specific-string/index.js b/tools/crowdin/actions/unhide-specific-string/index.js new file mode 100644 index 0000000000..1c87883a05 --- /dev/null +++ b/tools/crowdin/actions/unhide-specific-string/index.js @@ -0,0 +1,33 @@ +require('dotenv').config({ path: `${__dirname}/../../.env` }); +const core = require('@actions/core'); +const { getFiles } = require('../../utils/files'); +const { getStrings, changeHiddenStatus } = require('../../utils/strings'); + +const filename = core.getInput('filename'); +const stringContent = core.getInput('string-content'); + +const hideString = async (projectId, fileName, string) => { + const fileResponse = await getFiles(projectId); + const targetFile = fileResponse.find(el => el.path.endsWith(filename)); + if (!targetFile) { + core.setFailed(`${fileName} was not found.`); + return; + } + + const stringResponse = await getStrings({ + projectId, + fileId: targetFile.fileId + }); + + const targetString = stringResponse.find(el => el.data.text === string); + if (!targetString) { + core.setFailed(`${string} was not found.`); + return; + } + + await changeHiddenStatus(projectId, targetString.data.id, false); + console.log('string unhidden!'); +}; + +const projectId = process.env.CROWDIN_PROJECT_ID; +hideString(projectId, filename, stringContent);