From b035fc4dc545638539b30e6de24f2eb0af66ab29 Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Tue, 14 Jan 2025 14:43:56 +0000 Subject: [PATCH] fix comments --- .github/workflows/check-edit-links.yml | 6 ++--- package.json | 2 +- scripts/dashboard/build-dashboard.js | 2 +- ...check-editlinks.js => check-edit-links.js} | 11 +--------- tests/fixtures/markdown/edit-page-config.json | 22 ------------------- ...links.test.js => check-edit-links.test.js} | 4 ++-- 6 files changed, 8 insertions(+), 39 deletions(-) rename scripts/markdown/{check-editlinks.js => check-edit-links.js} (96%) delete mode 100644 tests/fixtures/markdown/edit-page-config.json rename tests/markdown/{check-editlinks.test.js => check-edit-links.test.js} (97%) diff --git a/.github/workflows/check-edit-links.yml b/.github/workflows/check-edit-links.yml index 7ccca35199ac..26483f025b08 100644 --- a/.github/workflows/check-edit-links.yml +++ b/.github/workflows/check-edit-links.yml @@ -1,4 +1,4 @@ -name: Weekly Link Checker +name: Weekly Docs Link Checker on: schedule: @@ -17,7 +17,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: '.nvmrc' - name: Install dependencies run: npm install @@ -40,7 +40,7 @@ jobs: uses: rtCamp/action-slack-notify@v2 env: SLACK_WEBHOOK: ${{ secrets.WEBSITE_SLACK_WEBHOOK }} - SLACK_TITLE: 'Edit Links Checker Errors Report' + SLACK_TITLE: 'Docs Edit Link Checker Errors Report' SLACK_MESSAGE: | 🚨 The following URLs returned 404 during the link check: ``` diff --git a/package.json b/package.json index a34585322891..22c6192d66fa 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "generate:tools": "node scripts/build-tools.js", "test:netlify": "deno test --allow-env --trace-ops netlify/**/*.test.ts", "test:md": "node scripts/markdown/check-markdown.js", - "test:editlinks": "node scripts/markdown/check-editlinks.js", + "test:editlinks": "node scripts/markdown/check-edit-links.js", "dev:storybook": "storybook dev -p 6006", "build:storybook": "storybook build" }, diff --git a/scripts/dashboard/build-dashboard.js b/scripts/dashboard/build-dashboard.js index c20be204e87b..066cf8b84c94 100644 --- a/scripts/dashboard/build-dashboard.js +++ b/scripts/dashboard/build-dashboard.js @@ -181,4 +181,4 @@ if (require.main === module) { start(resolve(__dirname, '..', '..', 'dashboard.json')); } -module.exports = { getLabel, monthsSince, mapGoodFirstIssues, getHotDiscussions, getDiscussionByID, getDiscussions, writeToFile, start, processHotDiscussions }; +module.exports = { getLabel, monthsSince, mapGoodFirstIssues, getHotDiscussions, getDiscussionByID, getDiscussions, writeToFile, start, processHotDiscussions, pause }; diff --git a/scripts/markdown/check-editlinks.js b/scripts/markdown/check-edit-links.js similarity index 96% rename from scripts/markdown/check-editlinks.js rename to scripts/markdown/check-edit-links.js index 7f5de4449f46..cf40dfb9ee38 100644 --- a/scripts/markdown/check-editlinks.js +++ b/scripts/markdown/check-edit-links.js @@ -2,6 +2,7 @@ const fs = require('fs').promises; const path = require('path'); const fetch = require('node-fetch-2'); const editUrls = require('../../config/edit-page-config.json'); +const { pause } = require('../dashboard/build-dashboard'); const ignoreFiles = [ 'reference/specification/v2.x.md', @@ -9,16 +10,6 @@ const ignoreFiles = [ 'reference/specification/v3.0.0.md' ]; -/** - * Introduces a delay in the execution flow - * @param {number} ms - The number of milliseconds to pause - */ -async function pause(ms) { - return new Promise((res) => { - setTimeout(res, ms); - }); -} - /** * Process a batch of URLs to check for 404s * @param {object[]} batch - Array of path objects to check diff --git a/tests/fixtures/markdown/edit-page-config.json b/tests/fixtures/markdown/edit-page-config.json deleted file mode 100644 index 9a66d9cd3f9f..000000000000 --- a/tests/fixtures/markdown/edit-page-config.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "value": "/tools/generator", - "href": "https://github.com/asyncapi/generator/tree/master/apps/generator/docs" - }, - { - "value": "reference/specification/", - "href": "https://github.com/asyncapi/spec/blob/master/spec/asyncapi.md" - }, - { - "value": "/tools/cli", - "href": "https://github.com/asyncapi/cli/tree/master/docs" - }, - { - "value": "", - "href": "https://github.com/asyncapi/website/blob/master/markdown" - }, - { - "value": "reference/extensions/", - "href": "https://github.com/asyncapi/extensions-catalog/tree/master/extensions" - } -] diff --git a/tests/markdown/check-editlinks.test.js b/tests/markdown/check-edit-links.test.js similarity index 97% rename from tests/markdown/check-editlinks.test.js rename to tests/markdown/check-edit-links.test.js index c0e1431337e1..6de5be05df4c 100644 --- a/tests/markdown/check-editlinks.test.js +++ b/tests/markdown/check-edit-links.test.js @@ -1,13 +1,13 @@ const path = require('path'); const fetch = require('node-fetch-2'); -const editOptions = require('../fixtures/markdown/edit-page-config.json'); +const editOptions = require('../../config/edit-page-config.json'); const { generatePaths, processBatch, checkUrls, determineEditLink, main -} = require('../../scripts/markdown/check-editlinks'); +} = require('../../scripts/markdown/check-edit-links'); const { determineEditLinkData, processBatchData, testPaths } = require('../fixtures/markdown/check-editlinks-data'); jest.mock('node-fetch-2', () => jest.fn());