diff --git a/.github/workflows/i18n-update-pull.yml b/.github/workflows/i18n-update-pull.yml index 8022b2dfe0..2e78760639 100644 --- a/.github/workflows/i18n-update-pull.yml +++ b/.github/workflows/i18n-update-pull.yml @@ -22,47 +22,47 @@ jobs: branch: ${{ steps.fetch-pr.outputs.branch }} steps: - - name: Generate Github Token for CI Bot - uses: actions/create-github-app-token@v1 - id: generate-token - with: - app-id: ${{ secrets.CI_APP_ID }} - private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - - name: Check out repository - uses: actions/checkout@v4 - with: - token: ${{ steps.generate-token.outputs.token }} - - - name: Fetch PR details - id: fetch-pr - run: | - PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "${{ github.event.issue.pull_request.url }}") - PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref') - - skip () { - echo "$1 Exiting..." - echo "skip=true" >> $GITHUB_OUTPUT - echo "skipReason=$1" >> $GITHUB_OUTPUT - } - - if [[ $PR_BRANCH == "i18n/"* ]]; then - skip "Branch \`$PR_BRANCH\` is a i18n branch." - fi - - PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.label' | sed 's/:/\//g') - NEW_BRANCH="i18n/$PR_BRANCH" - echo "newBranch=$NEW_BRANCH" >> $GITHUB_OUTPUT - echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT - - git config --global user.name "livecodes-ci[bot]" - git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" - - if [[ ! $(git ls-remote --heads origin $NEW_BRANCH) ]]; then - skip "Branch \`$NEW_BRANCH\` does not exist." - fi - env: - GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} + - name: Generate Github Token for CI Bot + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.CI_APP_ID }} + private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} + + - name: Check out repository + uses: actions/checkout@v4 + with: + token: ${{ steps.generate-token.outputs.token }} + + - name: Fetch PR details + id: fetch-pr + run: | + PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "${{ github.event.issue.pull_request.url }}") + PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref') + + skip () { + echo "$1 Exiting..." + echo "skip=true" >> $GITHUB_OUTPUT + echo "skipReason=$1" >> $GITHUB_OUTPUT + } + + if [[ $PR_BRANCH == "i18n/"* ]]; then + skip "Branch \`$PR_BRANCH\` is a i18n branch." + fi + + PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.label' | sed 's/:/\//g') + NEW_BRANCH="i18n/$PR_BRANCH" + echo "newBranch=$NEW_BRANCH" >> $GITHUB_OUTPUT + echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT + + git config --global user.name "livecodes-ci[bot]" + git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" + + if [[ ! $(git ls-remote --heads origin $NEW_BRANCH) ]]; then + skip "Branch \`$NEW_BRANCH\` does not exist." + fi + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} runner: name: Runner @@ -74,61 +74,61 @@ jobs: PR_BRANCH: ${{ needs.precheck.outputs.branch }} steps: - - name: Generate Github Token for CI Bot - uses: actions/create-github-app-token@v1 - id: generate-token - with: - app-id: ${{ secrets.CI_APP_ID }} - private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - - name: Check out repository - uses: actions/checkout@v4 - with: - ref: ${{ needs.precheck.outputs.newBranch }} - token: ${{ steps.generate-token.outputs.token }} - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - - - name: Install dependencies - run: npm ci - - - name: Import from Lokalise - run: | - mkdir -p $LOKALISE_TEMP && touch $LOKALISE_TEMP/locales.zip && npm run i18n-update-pull -- $PR_BRANCH && rm -rf $LOKALISE_TEMP - env: - LOKALISE_TEMP: lokalise_tmp - - - name: Generate Lokalise JSON files - run: npm run i18n-lokalise-json all - - - name: Linting and fixing - run: npm run fix - - - name: Commit changes - run: | - git config --global user.name "livecodes-ci[bot]" - git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" - git add . - - # Only commit if there are changes - git diff-index --quiet HEAD || git commit -m "i18n: pull translation from Lokalise" - - # Save SHA of the latest commit to locale - echo "LAST_COMMIT_SHA=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales)" >> $GITHUB_ENV - - - name: Push changes - run: git push origin $NEW_BRANCH - - - name: Create a new i18n PR, comment on source PR and reaction - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate-token.outputs.token }} - script: | + - name: Generate Github Token for CI Bot + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.CI_APP_ID }} + private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} + + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ needs.precheck.outputs.newBranch }} + token: ${{ steps.generate-token.outputs.token }} + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + + - name: Install dependencies + run: npm ci + + - name: Import from Lokalise + run: | + mkdir -p $LOKALISE_TEMP && touch $LOKALISE_TEMP/locales.zip && npm run i18n-update-pull -- $PR_BRANCH && rm -rf $LOKALISE_TEMP + env: + LOKALISE_TEMP: lokalise_tmp + + - name: Generate Lokalise JSON files + run: npm run i18n-lokalise-json all + + - name: Linting and fixing + run: npm run fix + + - name: Commit changes + run: | + git config --global user.name "livecodes-ci[bot]" + git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" + git add . + + # Only commit if there are changes + git diff-index --quiet HEAD || git commit -m "i18n: pull translation from Lokalise" + + # Save SHA of the latest commit to locale + echo "LAST_COMMIT_SHA=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales)" >> $GITHUB_ENV + + - name: Push changes + run: git push origin $NEW_BRANCH + + - name: Create a new i18n PR, comment on source PR and reaction + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate-token.outputs.token }} + script: | const repoURL = context.payload.repository.html_url; const branchURL = `${repoURL}/tree/${process.env.NEW_BRANCH}`; const prTitle = `i18n: ${{ github.event.issue.title }}`; @@ -146,7 +146,7 @@ jobs: - [ ] πŸ“¦ Chore (Release) - [ ] ⏩ Revert - [x] 🌐 Internationalization / Translation - + ## Description ### i18n Actions: \`.i18n-update-pull\` Localization pulled from Lokalise. @@ -155,7 +155,7 @@ jobs: | --- | --- | | **i18n Branch** | [\`${process.env.NEW_BRANCH}\`](${branchURL}) | | **Last Commit SHA** | ${process.env.LAST_COMMIT_SHA} | - + ## Related Tickets & Documents - **Source PR**: #${{ github.event.issue.number }} `; @@ -178,7 +178,7 @@ jobs: | **Last Commit SHA** | ${process.env.LAST_COMMIT_SHA} | | **i18n PR** | #${prInfo.data.number} | `; - + github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, @@ -192,7 +192,7 @@ jobs: comment_id: ${{ github.event.comment.id }}, content: 'rocket' }); - + exception: name: Exception runs-on: ubuntu-latest @@ -202,22 +202,22 @@ jobs: SKIP_REASON: ${{ needs.precheck.outputs.skipReason }} steps: - - name: Generate Github Token for CI Bot - uses: actions/create-github-app-token@v1 - id: generate-token - with: - app-id: ${{ secrets.CI_APP_ID }} - private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - - name: Create reaction on PR - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate-token.outputs.token }} - script: | + - name: Generate Github Token for CI Bot + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.CI_APP_ID }} + private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} + + - name: Create reaction on PR + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate-token.outputs.token }} + script: | const runURL = `${context.payload.repository.html_url}/actions/runs/${process.env.GITHUB_RUN_ID}`; const commentBody = `## i18n Actions: \`.i18n-update-pull\` Failed to perform action due to following reason: **${process.env.SKIP_REASON}** - + Please check [action logs](${runURL}) for more details. `; github.rest.issues.createComment({ diff --git a/.github/workflows/i18n-update-push.yml b/.github/workflows/i18n-update-push.yml index e2dc67c3f7..fcbf516740 100644 --- a/.github/workflows/i18n-update-push.yml +++ b/.github/workflows/i18n-update-push.yml @@ -22,48 +22,48 @@ jobs: branch: ${{ steps.fetch-pr.outputs.branch }} steps: - - name: Generate Github Token for CI Bot - uses: actions/create-github-app-token@v1 - id: generate-token - with: - app-id: ${{ secrets.CI_APP_ID }} - private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - - name: Check out repository - uses: actions/checkout@v4 - with: - token: ${{ steps.generate-token.outputs.token }} - - - name: Fetch PR details - id: fetch-pr - run: | - PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "${{ github.event.issue.pull_request.url }}") - PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref') - - if [[ $PR_BRANCH == "i18n/"* ]]; then - SKIP_REASON="Branch \`$PR_BRANCH\` is a i18n branch." - echo "$SKIP_REASON Exiting..." - echo "skip=true" >> $GITHUB_OUTPUT - echo "skipReason=$SKIP_REASON" >> $GITHUB_OUTPUT - fi - - # Use branch name prefixed with owner name - PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.label' | sed 's/:/\//g') - NEW_BRANCH="i18n/$PR_BRANCH" - echo "newBranch=$NEW_BRANCH" >> $GITHUB_OUTPUT - echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT - - git config --global user.name "livecodes-ci[bot]" - git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" - - if [[ $(git ls-remote --heads origin $NEW_BRANCH) ]]; then - SKIP_REASON="Branch \`$NEW_BRANCH\` already exists." - echo "$SKIP_REASON Exiting..." - echo "skip=true" >> $GITHUB_OUTPUT - echo "skipReason=$SKIP_REASON" >> $GITHUB_OUTPUT - fi - env: - GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} + - name: Generate Github Token for CI Bot + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.CI_APP_ID }} + private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} + + - name: Check out repository + uses: actions/checkout@v4 + with: + token: ${{ steps.generate-token.outputs.token }} + + - name: Fetch PR details + id: fetch-pr + run: | + PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "${{ github.event.issue.pull_request.url }}") + PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref') + + if [[ $PR_BRANCH == "i18n/"* ]]; then + SKIP_REASON="Branch \`$PR_BRANCH\` is a i18n branch." + echo "$SKIP_REASON Exiting..." + echo "skip=true" >> $GITHUB_OUTPUT + echo "skipReason=$SKIP_REASON" >> $GITHUB_OUTPUT + fi + + # Use branch name prefixed with owner name + PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.label' | sed 's/:/\//g') + NEW_BRANCH="i18n/$PR_BRANCH" + echo "newBranch=$NEW_BRANCH" >> $GITHUB_OUTPUT + echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT + + git config --global user.name "livecodes-ci[bot]" + git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" + + if [[ $(git ls-remote --heads origin $NEW_BRANCH) ]]; then + SKIP_REASON="Branch \`$NEW_BRANCH\` already exists." + echo "$SKIP_REASON Exiting..." + echo "skip=true" >> $GITHUB_OUTPUT + echo "skipReason=$SKIP_REASON" >> $GITHUB_OUTPUT + fi + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} runner: name: Runner @@ -75,57 +75,57 @@ jobs: PR_BRANCH: ${{ needs.precheck.outputs.branch }} steps: - - name: Generate Github Token for CI Bot - uses: actions/create-github-app-token@v1 - id: generate-token - with: - app-id: ${{ secrets.CI_APP_ID }} - private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - - name: Check out repository - uses: actions/checkout@v4 - with: - token: ${{ steps.generate-token.outputs.token }} - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - - - name: Install dependencies - run: npm ci - - - name: Create new branch - run: git checkout -b $NEW_BRANCH - - - name: Linting and fixing - run: npm run fix - - - name: Commit changes - run: | - git config --global user.name "livecodes-ci[bot]" - git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" - git add . - - # Only commit if there are changes - git diff-index --quiet HEAD || git commit -m "i18n: update source texts" - - # Save SHA of the latest commit to English locale - echo "LAST_COMMIT_SHA=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV - - - name: Push changes - run: git push origin $NEW_BRANCH - - - name: Push source texts to Lokalise - run: npm run i18n-update-push -- $PR_BRANCH - - - name: Create comment and reaction on PR - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate-token.outputs.token }} - script: | + - name: Generate Github Token for CI Bot + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.CI_APP_ID }} + private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} + + - name: Check out repository + uses: actions/checkout@v4 + with: + token: ${{ steps.generate-token.outputs.token }} + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + + - name: Install dependencies + run: npm ci + + - name: Create new branch + run: git checkout -b $NEW_BRANCH + + - name: Linting and fixing + run: npm run fix + + - name: Commit changes + run: | + git config --global user.name "livecodes-ci[bot]" + git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" + git add . + + # Only commit if there are changes + git diff-index --quiet HEAD || git commit -m "i18n: update source texts" + + # Save SHA of the latest commit to English locale + echo "LAST_COMMIT_SHA=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV + + - name: Push changes + run: git push origin $NEW_BRANCH + + - name: Push source texts to Lokalise + run: npm run i18n-update-push -- $PR_BRANCH + + - name: Create comment and reaction on PR + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate-token.outputs.token }} + script: | const repoURL = context.payload.repository.html_url; const branchURL = `${repoURL}/tree/${process.env.NEW_BRANCH}`; const commentBody = `## i18n Actions: \`.i18n-update-push\` @@ -138,7 +138,7 @@ jobs: Maintainers can comment \`.i18n-update-pull\` after translation is done to trigger the i18n pull workflow and pull the changes back to Github. `; - + github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, @@ -152,7 +152,7 @@ jobs: comment_id: ${{ github.event.comment.id }}, content: 'rocket' }); - + exception: name: Exception runs-on: ubuntu-latest @@ -162,22 +162,22 @@ jobs: SKIP_REASON: ${{ needs.precheck.outputs.skipReason }} steps: - - name: Generate Github Token for CI Bot - uses: actions/create-github-app-token@v1 - id: generate-token - with: - app-id: ${{ secrets.CI_APP_ID }} - private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - - name: Create comment and reaction on PR - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate-token.outputs.token }} - script: | + - name: Generate Github Token for CI Bot + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.CI_APP_ID }} + private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} + + - name: Create comment and reaction on PR + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate-token.outputs.token }} + script: | const runURL = `${context.payload.repository.html_url}/actions/runs/${process.env.GITHUB_RUN_ID}`; const commentBody = `## i18n Actions: \`.i18n-update-push\` Failed to perform action due to following reason: **${process.env.SKIP_REASON}** - + Please check [action logs](${runURL}) for more details. `; github.rest.issues.createComment({ @@ -186,7 +186,7 @@ jobs: repo: context.repo.repo, body: commentBody }) - + github.rest.reactions.createForIssueComment({ owner: context.repo.owner, repo: context.repo.repo, diff --git a/.github/workflows/i18n-update-scheduled.yml b/.github/workflows/i18n-update-scheduled.yml index a977fbe1cd..be2b5ac395 100644 --- a/.github/workflows/i18n-update-scheduled.yml +++ b/.github/workflows/i18n-update-scheduled.yml @@ -25,109 +25,109 @@ jobs: runs-on: ubuntu-latest steps: - - name: Generate Github Token for CI Bot - uses: actions/create-github-app-token@v1 - id: generate-token - with: - app-id: ${{ secrets.CI_APP_ID }} - private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ steps.generate-token.outputs.token }} - - - name: Switch to i18n branch - run: | - git config --global user.name "livecodes-ci[bot]" - git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" - - if [[ $(git ls-remote --heads origin $BRANCH) ]]; then - git config pull.rebase false - git fetch origin $BRANCH:$BRANCH - git checkout $BRANCH - else - git checkout -b $BRANCH - fi - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - - - name: Install dependencies - run: npm ci - - # - name: Linting and fixing - # run: npm run fix - - # - name: Commit changes - # run: | - # git add . - - # # Only commit if there are changes - # git diff-index --quiet HEAD || git commit -m "i18n: update source texts" - - # # Save SHA of the latest commit to English locale - # echo "LAST_COMMIT_SHA_PUSH=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV - - # - name: Push changes - # run: git push origin $BRANCH - - # - name: Push source texts to Lokalise - # run: npm run i18n-update-push -- $LOKALISE_BRANCH - - - name: Import from Lokalise - run: | - mkdir -p $LOKALISE_TEMP && touch $LOKALISE_TEMP/locales.zip && npm run i18n-update-pull -- $LOKALISE_BRANCH && rm -rf $LOKALISE_TEMP - env: - LOKALISE_TEMP: lokalise_tmp - - - name: Linting and fixing - run: npm run fix - - - name: Commit changes - run: | - git add . - - # Only commit if there are changes - git diff-index --quiet HEAD || git commit -m "i18n: pull translation from Lokalise" - - # Save SHA of the latest commit to locale - echo "LAST_COMMIT_SHA_PULL=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales)" >> $GITHUB_ENV - - - name: Push changes - run: | - - git pull origin ${{ github.event.repository.default_branch }} || { - echo "Failed to pull from ${{ github.event.repository.default_branch }}." - echo "Please manually pull the changes, solve potential conflicts, and re-run the workflow." - echo "::error title=Pull failed::Failed to pull from ${{ github.event.repository.default_branch }}." - exit 1 - } - - git push origin $BRANCH - - - name: Check if has differences between ${{ env.BRANCH }} and ${{ github.event.repository.default_branch }} - id: check-diff - run: | - DIFF=$(git diff --name-only $BRANCH origin/${{ github.event.repository.default_branch }}) - if [[ -z $DIFF ]]; then - echo "No difference between $BRANCH and ${{ github.event.repository.default_branch }}." - echo "SKIP=true" >> $GITHUB_OUTPUT - fi - - echo "LAST_COMMIT_SHA_PUSH=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV - - - name: Create a new i18n PR if not exists - uses: actions/github-script@v7 - if: steps.check-diff.outputs.SKIP != 'true' - with: - github-token: ${{ steps.generate-token.outputs.token }} - script: | + - name: Generate Github Token for CI Bot + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.CI_APP_ID }} + private-key: ${{ secrets.CI_APP_PRIVATE_KEY }} + + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.generate-token.outputs.token }} + + - name: Switch to i18n branch + run: | + git config --global user.name "livecodes-ci[bot]" + git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com" + + if [[ $(git ls-remote --heads origin $BRANCH) ]]; then + git config pull.rebase false + git fetch origin $BRANCH:$BRANCH + git checkout $BRANCH + else + git checkout -b $BRANCH + fi + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + + - name: Install dependencies + run: npm ci + + # - name: Linting and fixing + # run: npm run fix + + # - name: Commit changes + # run: | + # git add . + + # # Only commit if there are changes + # git diff-index --quiet HEAD || git commit -m "i18n: update source texts" + + # # Save SHA of the latest commit to English locale + # echo "LAST_COMMIT_SHA_PUSH=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV + + # - name: Push changes + # run: git push origin $BRANCH + + # - name: Push source texts to Lokalise + # run: npm run i18n-update-push -- $LOKALISE_BRANCH + + - name: Import from Lokalise + run: | + mkdir -p $LOKALISE_TEMP && touch $LOKALISE_TEMP/locales.zip && npm run i18n-update-pull -- $LOKALISE_BRANCH && rm -rf $LOKALISE_TEMP + env: + LOKALISE_TEMP: lokalise_tmp + + - name: Linting and fixing + run: npm run fix + + - name: Commit changes + run: | + git add . + + # Only commit if there are changes + git diff-index --quiet HEAD || git commit -m "i18n: pull translation from Lokalise" + + # Save SHA of the latest commit to locale + echo "LAST_COMMIT_SHA_PULL=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales)" >> $GITHUB_ENV + + - name: Push changes + run: | + + git pull origin ${{ github.event.repository.default_branch }} || { + echo "Failed to pull from ${{ github.event.repository.default_branch }}." + echo "Please manually pull the changes, solve potential conflicts, and re-run the workflow." + echo "::error title=Pull failed::Failed to pull from ${{ github.event.repository.default_branch }}." + exit 1 + } + + git push origin $BRANCH + + - name: Check if has differences between ${{ env.BRANCH }} and ${{ github.event.repository.default_branch }} + id: check-diff + run: | + DIFF=$(git diff --name-only $BRANCH origin/${{ github.event.repository.default_branch }}) + if [[ -z $DIFF ]]; then + echo "No difference between $BRANCH and ${{ github.event.repository.default_branch }}." + echo "SKIP=true" >> $GITHUB_OUTPUT + fi + + echo "LAST_COMMIT_SHA_PUSH=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV + + - name: Create a new i18n PR if not exists + uses: actions/github-script@v7 + if: steps.check-diff.outputs.SKIP != 'true' + with: + github-token: ${{ steps.generate-token.outputs.token }} + script: | const prInfo = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, @@ -158,7 +158,7 @@ jobs: - [ ] πŸ“¦ Chore (Release) - [ ] ⏩ Revert - [x] 🌐 Internationalization / Translation - + ## Description ### i18n Actions: \`.i18n-update-scheduled\` Scheduled update of source texts and translations. diff --git a/.vscode/html.html-data.json b/.vscode/html.html-data.json index c36ded006b..fab3238603 100644 --- a/.vscode/html.html-data.json +++ b/.vscode/html.html-data.json @@ -37,4 +37,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 37abf99545..d1e729a1a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. See [standa --- +## [sdk-v0.11.0](https://github.com/live-codes/livecodes/compare/sdk-v0.10.0...sdk-v0.11.0) (2025-05-24) + +- This release enables the SDK to create playgrounds and generate URLs for much bigger projects, by encoding data in URL hash instead of query params, while maintaining backwards compatibility. + +- Adds support for Jinja templating engine. + +### Credits + +- @BassemHalim did a lot of work on this release. Thank you ❀️ + +--- + ## [v45](https://github.com/live-codes/livecodes/compare/sdk-v0.10.0...v45) (2025-04-25) ### Highlights for this release diff --git a/README.md b/README.md index af3bc635c6..c9360e511e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A [feature-rich](https://livecodes.io/docs/features/), open-source, **client-sid [![LiveCodes: npm version](https://img.shields.io/npm/v/livecodes)](https://www.npmjs.com/package/livecodes) [![LiveCodes: npm downloads](https://img.shields.io/npm/dm/livecodes)](https://www.npmjs.com/package/livecodes) [![LiveCodes: jsdelivr downloads](https://data.jsdelivr.com/v1/package/npm/livecodes/badge?style=rounded)](https://www.jsdelivr.com/package/npm/livecodes) -[![LiveCodes: languages](https://img.shields.io/badge/languages-95-blue)](https://livecodes.io/docs/languages/) +[![LiveCodes: languages](https://img.shields.io/badge/languages-96-blue)](https://livecodes.io/docs/languages/) [![LiveCodes: docs](https://img.shields.io/badge/Documentation-575757?logo=gitbook&logoColor=white)](https://livecodes.io/docs/) [![LiveCodes: llms.txt](https://img.shields.io/badge/llms.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms.txt) [![LiveCodes: llms-full.txt](https://img.shields.io/badge/llms--full.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms-full.txt) diff --git a/docs/docs/features/tests.mdx b/docs/docs/features/tests.mdx index 344fc4f553..f9992d44ef 100644 --- a/docs/docs/features/tests.mdx +++ b/docs/docs/features/tests.mdx @@ -58,11 +58,16 @@ The tests panel and the test editor are always shown in the [full standalone app ## Supported Languages The testing code can be written using JavaScript, TypeScript, JSX or TSX. -However, since the tests are run against the result web page, they can test projects that use any language/framework. +However, since the tests run against the result web page, they can test projects that use any language/framework. -This is a demo for running tests against a Python project. +This is [a demo](https://livecodes.io/?x=id/xyi6usem2sf&tests) for running tests against a Ruby project. + + + +Languages may have test modules. This is [an example](https://livecodes.io/?x=id/665ar3bpqka&console=full) of running [Python doctest](https://docs.python.org/3/library/doctest.html) tests: + + - ## Importing Code diff --git a/docs/docs/languages/asciidoc.mdx b/docs/docs/languages/asciidoc.mdx index d6bce0dc2e..1cdd048746 100644 --- a/docs/docs/languages/asciidoc.mdx +++ b/docs/docs/languages/asciidoc.mdx @@ -1,3 +1,81 @@ # AsciiDoc -TODO... +import LiveCodes from '../../src/components/LiveCodes.tsx'; + +[AsciiDoc](https://asciidoc.org) is a plain text markup language for writing technical content. It’s packed with semantic elements and equipped with features to modularize and reuse content. AsciiDoc content can be composed using a text editor, managed in a version control system, and published to multiple output formats. + +In LiveCodes, AsciiDoc is compiled to HTML using [Asciidoctor](https://asciidoctor.org/). + +## Usage + +### Demo + +export const asciidocConfig = { + markup: { + language: 'asciidoc', + content: `= AsciiDoc Demo + +== Features + +* Simple +* Clean +* Dev-friendly +`, + }, +} + + + +## Language Info + +### Name + +`asciidoc` + +### Extensions + +`adoc`, `asc` + +## Editor + +`markup` + +## Compiler + +[Asciidoctor.js](https://docs.asciidoctor.org/asciidoctor.js/latest/) + +### Version + +Asciidoctor.js: `v2.2.8` + +## Code Formatting + +Not supported. + +## Custom Settings + +[Custom settings](../advanced/custom-settings.mdx) added to the property `asciidoc` are passed as a JSON object to the [`convert()`](https://docs.asciidoctor.org/asciidoctor.js/latest/setup/quick-tour/#your-first-conversion) function during compile. +Please check the [documentation](https://docs.asciidoctor.org/asciidoctor.js/latest/processor/convert-options/) and [document attributes](https://docs.asciidoctor.org/asciidoc/latest/attributes/document-attributes-ref/) for full reference. + +Please note that custom settings should be valid JSON (i.e. functions are not allowed). + +```json +{ + "asciidoc": { + "attributes": { + "source-highlighter": "highlight.js", + "icons": "font" + } + } +} +``` + +## Limitations + +- Some advanced extensions may not work (e.g. diagrams) + +## Links + +- [AsciiDoc](https://asciidoc.org) +- [Asciidoctor](https://asciidoctor.org/) +- [AsciiDoctor.js](https://docs.asciidoctor.org/asciidoctor.js/latest/) diff --git a/docs/docs/languages/html.mdx b/docs/docs/languages/html.mdx index a24796ab97..88498534b8 100644 --- a/docs/docs/languages/html.mdx +++ b/docs/docs/languages/html.mdx @@ -1,3 +1,68 @@ # HTML -TODO... +import LiveCodes from '../../src/components/LiveCodes.tsx'; + + +HTML (HyperText Markup Language) is the standard markup language for creating web pages and web applications. It defines the structure and content of web pages. + +## Usage + +HTML code in the [markup editor](../features/projects.mdx#markup-editor) is added as is without compilation or processing to the body of the [result page](../features/result.mdx). + +There is no need to add a full page structure (e.g. ``, ``, `` tags). This is already handled by LiveCodes. +(See [Result Page Structure](../features/result.mdx#result-page-structure) for more details.) + +If you need to add content to the `` section or `` attributes of the result page, you can add it in the [project info screen](https://livecodes.io/?screen=info). + +### Demo + + +export const htmlOnlyConfig = { + markup: { + language: 'html', + content: `

Hello, LiveCodes!

+

This is a paragraph in HTML.

+ +`, + }, +} + + + +### Styles and JavaScript + +Most of the time, you will want to add styles and scripts in the [respective editors](../features/projects.mdx). +However, you can of course still add them in ``, `