diff --git a/.github/actions/precompute-pageinfo/action.yml b/.github/actions/precompute-pageinfo/action.yml index 0e88137540..1886f93c05 100644 --- a/.github/actions/precompute-pageinfo/action.yml +++ b/.github/actions/precompute-pageinfo/action.yml @@ -36,7 +36,7 @@ runs: - name: Run script if: ${{ inputs.restore-only == '' }} shell: bash - run: npm run precompute-pageinfo + run: npm run precompute-pageinfo -- --max-versions 2 - name: Cache .remotejson-cache (save) if: ${{ inputs.restore-only == '' }} diff --git a/.github/workflows/codeowners-legal.yml b/.github/workflows/codeowners-legal.yml index bd0842ae31..85820b3fcf 100644 --- a/.github/workflows/codeowners-legal.yml +++ b/.github/workflows/codeowners-legal.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Get files changed - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 + uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd id: filter with: # Base branch used to get changed files diff --git a/.github/workflows/delete-orphan-translation-files.yml b/.github/workflows/delete-orphan-translation-files.yml index 2ce1de12cf..7713dd6ea8 100644 --- a/.github/workflows/delete-orphan-translation-files.yml +++ b/.github/workflows/delete-orphan-translation-files.yml @@ -91,6 +91,14 @@ jobs: # Needed for gh GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} run: | + # If nothing to commit, exit now. It's fine. No orphans. + changes=$(git diff --name-only | wc -l) + untracked=$(git status --untracked-files --short | wc -l) + if [[ $changes -eq 0 ]] && [[ $untracked -eq 0 ]]; then + echo "There are no changes to commit after running src/rest/scripts/update-files.js. Exiting..." + exit 0 + fi + git status current_timestamp=$(date '+%Y-%m-%d-%H%M%S') branch_name="delete-orphan-files-$current_timestamp" diff --git a/.github/workflows/triage-unallowed-contributions.yml b/.github/workflows/triage-unallowed-contributions.yml index 8e2099b118..8ad7d08d78 100644 --- a/.github/workflows/triage-unallowed-contributions.yml +++ b/.github/workflows/triage-unallowed-contributions.yml @@ -29,7 +29,7 @@ jobs: uses: ./.github/actions/node-npm-setup - name: Get files changed - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 + uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd id: filter with: # Base branch used to get changed files diff --git a/src/content-render/unified/annotate.js b/src/content-render/unified/annotate.js index d61fd8b1d1..65fcc057b4 100644 --- a/src/content-render/unified/annotate.js +++ b/src/content-render/unified/annotate.js @@ -87,10 +87,12 @@ function createAnnotatedNode(node) { // Group groups into rows const rows = chunk(groups, 2) - for (const [, note] of rows) { - if (note === undefined) { + + // Check the rows are formatted correctly + for (const [note, code] of rows) { + if (note === undefined || code === undefined) { throw new Error( - "Unbalanced code meaning there's a comment (note) that is not followed by any code.", + "Each annotation must have a note and a code block. If you're trying to create a blank annotation, you can use a single line comment with a space after it.", ) } } diff --git a/src/pageinfo/scripts/precompute-pageinfo.ts b/src/pageinfo/scripts/precompute-pageinfo.ts index e95c027ad6..40c12583b2 100644 --- a/src/pageinfo/scripts/precompute-pageinfo.ts +++ b/src/pageinfo/scripts/precompute-pageinfo.ts @@ -40,21 +40,24 @@ program .description('Generates a JSON file with precompute pageinfo data by pathname') .addOption( new Option('-l, --language ', 'Which languages to focus on') - .choices(languageKeys) + .choices(languageKeys.concat('all')) .default(['en']), ) .option('-o, --output-file ', 'path to output file', CACHE_FILE_PATH) + .option('--max-versions ', 'max. number of permalink versions per page') .parse(process.argv) type Options = { outputFile: string languages: string[] + maxVersions: number } const opts = program.opts() main({ outputFile: opts.outputFile, languages: opts.language, + maxVersions: isNaN(opts.maxVersions) ? 1 : Number(opts.maxVersions), }) const CI = Boolean(JSON.parse(process.env.CI || 'false')) @@ -66,10 +69,16 @@ type PageInfo = { } async function main(options: Options) { - const { outputFile, languages } = options + const { outputFile, languages, maxVersions } = options if (outputFile !== CACHE_FILE_PATH) { console.warn(chalk.yellow(`Writing to ${outputFile} instead of ${CACHE_FILE_PATH}`)) } + if (languages.includes('all')) { + // This sets it to [], which when sent into loadUnversionedTree means + // it does all languages that it can find. + languages.length = 0 + } + const unversionedTree = await loadUnversionedTree(languages) const pageList = await loadPages(unversionedTree, languages) @@ -79,15 +88,25 @@ async function main(options: Options) { [pathname: string]: PageInfo } = {} for (const page of pageList) { - const pathname = page.permalinks[0].href - try { - const computed = await getPageInfo(page, pathname) - if (computed) { - pageinfos[pathname] = computed + let countVersions = 0 + for (const permalink of page.permalinks) { + const pathname = permalink.href + try { + const computed = await getPageInfo(page, pathname) + if (computed) { + pageinfos[pathname] = computed + } + } catch (error) { + console.error(`Error computing pageinfo for ${page.fullPath} (${pathname})`) + throw error + } + // By default, we only compute the first permalink href. + // But you can do more if you want. + if (++countVersions >= maxVersions) { + // This means we're content with only doing the first permalink href. + // That's 99% the free-pro-team permalink pathname. + break } - } catch (error) { - console.error(`Error computing pageinfo for ${page.fullPath} (${pathname})`) - throw error } } console.timeEnd(label)