From 71407c12bbeed74aaca1906ee931c996c47af174 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Thu, 16 Jan 2025 11:17:59 +0100 Subject: [PATCH 01/11] Added script and workflows to check broken links --- .github/workflows/broken-links.yml | 67 +++++++++++++++ scripts/BrokenLinkChecker.js | 117 +++++++++++++++++++++++++ scripts/broken_links_markdown.csv | 19 ++++ scripts/package-lock.json | 134 +++++++++++++++++++++++++++++ scripts/package.json | 16 ++++ 5 files changed, 353 insertions(+) create mode 100644 .github/workflows/broken-links.yml create mode 100644 scripts/BrokenLinkChecker.js create mode 100644 scripts/broken_links_markdown.csv create mode 100644 scripts/package-lock.json create mode 100644 scripts/package.json diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml new file mode 100644 index 0000000000..b0cf0a5c1e --- /dev/null +++ b/.github/workflows/broken-links.yml @@ -0,0 +1,67 @@ +name: Check Broken Links + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +jobs: + check-broken-links: + name: Broken Link Checker + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Set Up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install Dependencies + run: | + cd scripts + npm install + + - name: Run Broken Link Checker + run: | + cd scripts + node BrokenLinkChecker.js + + - name: Parse and Comment Broken Links + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const path = './scripts/broken_links_markdown.csv'; + let body; + if (fs.existsSync(path)) { + const data = fs.readFileSync(path, 'utf8').trim(); + if (data.split('\n').length > 1) { + body = `The following broken links were found:\n\n${data + .split('\n') + .slice(1) + .map((line) => { + const [url, file, status] = line.split(','); + return `- **[${url}](${url})** in file \`${file}\` (Status: ${status})`; + }) + .join('\n')}`; + } else { + body = 'No broken links found.'; + } + } else { + body = 'Error: Broken link checker did not produce a CSV report.'; + } + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }); diff --git a/scripts/BrokenLinkChecker.js b/scripts/BrokenLinkChecker.js new file mode 100644 index 0000000000..72d5dcaeac --- /dev/null +++ b/scripts/BrokenLinkChecker.js @@ -0,0 +1,117 @@ +import fs from "fs"; +import path from "path"; +import fetch from "node-fetch"; +import pLimit from "p-limit"; + +const getMarkdownFiles = (dir) => { + const files = fs.readdirSync(dir, { withFileTypes: true }); + let markdownFiles = []; + for (const file of files) { + const fullPath = path.join(dir, file.name); + if (file.isDirectory()) { + markdownFiles = markdownFiles.concat(getMarkdownFiles(fullPath)); + } else if (file.isFile() && file.name.endsWith(".md")) { + markdownFiles.push(fullPath); + } + } + return markdownFiles; +}; + +const BASE_URL = "https://cumulocity.com/docs"; + +const shortcodeMapping = { + "product-c8y-iot": "Cumulocity IoT", + "c8y-edge-current-version-alt": "10.18", + "domain-c8y": "cumulocity.com", + "link-c8y-github": "https://github.com/Cumulocity-IoT", + "link-sag-portal": "https://empower.softwareag.com/", + "link-sag-tech-forum": "https://tech.forums.softwareag.com/", + "link-apamadoc-api": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/related/ApamaDoc/", + "link-sag-dev-community": "https://tech.forums.softwareag.com/tag/Cumulocity-IoT", + "link-apama-webhelp": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/pam-webhelp/", + "link-sag-privacy-statement": "https://www.softwareag.com/en_corporate/privacy.html", + "link-device-portal": "https://ecosystem.cumulocity.com/device-ecosystem/devices/?_gl=1*1uyml12*_gcl_au*MTI2NTExNjU3MS4xNzMzODQzODY0*_ga*NzUyNzgxNzA4LjE3MzM4NDM4NjU.*_ga_B9NM1M9Q48*MTczNDM4NDM3Ni4xNS4xLjE3MzQzODU3NDcuMjMuMC4w&filter_cumulocity_certified=yes&query_type_cumulocity_certified=and", + "c8y-support-link": "https://cumulocity.atlassian.net/servicedesk/customer/user/login?destination=portals", + "link-sag-documentation" :"https://documentation.softwareag.com/", + "link-c8y-training": "https://cumulocity.moodlecloud.com/", + "c8y-resources-server-link": "https://download.cumulocity.com/", + "c8y-tech-community-link" : "https://techcommunity.cumulocity.com/", + "c8y-support-email" : "support@cumulocity.com", + "email-c8y-info" : "info@cumulocity.com" + +}; + +const resolveHugoShortcode = (link) => { + return link.replace(/\{\{<\s*(.*?)\s*>\}\}/g, (match, shortcode) => { + const resolvedValue = shortcodeMapping[shortcode]; + return resolvedValue !== undefined && resolvedValue !== null ? resolvedValue : ""; + }); +}; + +const resolveFullUrl = (link) => { + if (link.startsWith("mailto:") || link.startsWith("tel:")) { + return null; + } + + const resolvedLink = resolveHugoShortcode(link); + if (resolvedLink.startsWith("http://") || resolvedLink.startsWith("https://")) { + return resolvedLink; + } + + return `${BASE_URL.replace(/\/$/, "")}/${resolvedLink.replace(/^\//, "")}`; +}; + +const checkLink = async (link, mdFile) => { + const fullUrl = resolveFullUrl(link); + if (!fullUrl) { + return null; + } + + try { + let response = await fetch(fullUrl, { method: "HEAD" }); + if (response.status === 405) { + response = await fetch(fullUrl, { method: "GET" }); + } + + if (!response.ok) { + return { url: fullUrl, file: mdFile, status: response.status }; + } + } catch (error) { + return { url: fullUrl, file: mdFile, status: "Error" }; + } + + return null; +}; + +(async () => { + const projectDir = ".././content"; + const markdownFiles = getMarkdownFiles(projectDir); + + const brokenLinks = []; + const limit = pLimit(10); + + + const tasks = markdownFiles.map((mdFile) => { + const content = fs.readFileSync(mdFile, "utf8"); + const links = [...content.matchAll(/(? match[1]); + + + + return links.map((link) => + limit(async () => { + const result = await checkLink(link, mdFile); + if (result) brokenLinks.push(result); + }) + ); + }); + + await Promise.all(tasks.flat()); + + const csvData = + "URL,File Path,Status Code\n" + + brokenLinks.map((link) => `${link.url},${link.file},${link.status}`).join("\n"); + + fs.writeFileSync("broken_links_markdown.csv", csvData); + console.log("Broken links in markdown files saved to broken_links_markdown.csv"); + process.exit(0); +})(); diff --git a/scripts/broken_links_markdown.csv b/scripts/broken_links_markdown.csv new file mode 100644 index 0000000000..ba11200fb9 --- /dev/null +++ b/scripts/broken_links_markdown.csv @@ -0,0 +1,19 @@ +URL,File Path,Status Code +https://github.com/Cumulocity-IoT/cumulocity-examples/snmp,..\content\change-logs\device-management\SNMP-removed-from-docs.md,404 +https://download.cumulocity.com/,..\content\about_documentation\scope.md,Error +https://download.cumulocity.com/,..\content\additional-resources\more-documentation.md,Error +https://portal.azure.com/,..\content\datahub\integrating-datahub-with-other-products-bundle\integration-powerbi.md,403 +https://github.com/eclipse/paho.mqtt.python/issues/354,..\content\device-integration\mqtt-examples-bundle\hello-mqtt-python.md,404 +https://download.cumulocity.com/,..\content\edge\edge-databroker-bundle\databroker-edge.md,Error +https://download.cumulocity.com/,..\content\edge\edge-databroker-bundle\databroker-edge.md,Error +https://download.cumulocity.com/,..\content\edge\edge-update-bundle\updating-edge-gui.md,429 +https://download.cumulocity.com/,..\content\edge\edge-installation-bundle\prerequisites.md,429 +https://www.mathworks.com/help/predmaint/ug/remaining-useful-life-estimation-using-convolutional-neural-network.html,..\content\machine-learning\AI-ML-integration-bundle\step1-create-ai-ml-model.md,403 +https://download.cumulocity.com/,..\content\glossary\y.md,429 +http://www.oracle.com/technetwork/java/javase/downloads/index.html,..\content\microservice-sdk\java-bundle\introduction.md,403 +https://www.oracle.com/technetwork/java/javase/downloads/index.html,..\content\microservice-sdk\java-bundle\ip-tracker-microservice.md,403 +https://openmobilealliance.org/iot/lightweight-m2m-lwm2m,..\content\protocol-integration\lwm2m-bundle\introduction.md,404 +https://en.wikipedia.org/wiki/Sampling_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 +https://en.wikipedia.org/wiki/Quantization_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 +https://cumulocity.com/docs/= 12" + } + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/p-limit": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.2.0.tgz", + "integrity": "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA==", + "license": "MIT", + "dependencies": { + "yocto-queue": "^1.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/yocto-queue": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", + "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==", + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 0000000000..238e77b3d3 --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,16 @@ +{ + "name": "scripts", + "version": "1.0.0", + "description": "- Node.js with version 20 and more is required to execute the scripts.", + "main": "BrokenLinkChecker.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "node-fetch": "^3.3.2", + "p-limit": "^6.2.0" + } +} From 72ef575230800899c6cda88f9ec3cd5b752e6cf4 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Thu, 23 Jan 2025 10:09:19 +0100 Subject: [PATCH 02/11] moved the scripts to broken-links-script folder and modified the script to display only 404 error status --- broken-links-script/BrokenLinkChecker.js | 119 ++++++++++++++++ broken-links-script/broken_links_markdown.csv | 7 + broken-links-script/package-lock.json | 134 ++++++++++++++++++ broken-links-script/package.json | 16 +++ 4 files changed, 276 insertions(+) create mode 100644 broken-links-script/BrokenLinkChecker.js create mode 100644 broken-links-script/broken_links_markdown.csv create mode 100644 broken-links-script/package-lock.json create mode 100644 broken-links-script/package.json diff --git a/broken-links-script/BrokenLinkChecker.js b/broken-links-script/BrokenLinkChecker.js new file mode 100644 index 0000000000..47107b0289 --- /dev/null +++ b/broken-links-script/BrokenLinkChecker.js @@ -0,0 +1,119 @@ +import fs from "fs"; +import path from "path"; +import fetch from "node-fetch"; +import pLimit from "p-limit"; + +const getMarkdownFiles = (dir) => { + const files = fs.readdirSync(dir, { withFileTypes: true }); + let markdownFiles = []; + for (const file of files) { + const fullPath = path.join(dir, file.name); + if (file.isDirectory()) { + markdownFiles = markdownFiles.concat(getMarkdownFiles(fullPath)); + } else if (file.isFile() && file.name.endsWith(".md")) { + markdownFiles.push(fullPath); + } + } + return markdownFiles; +}; + +const BASE_URL = "https://cumulocity.com/docs"; + +const shortcodeMapping = { + "product-c8y-iot": "Cumulocity IoT", + "c8y-edge-current-version-alt": "10.18", + "domain-c8y": "cumulocity.com", + "link-c8y-github": "https://github.com/Cumulocity-IoT", + "link-sag-portal": "https://empower.softwareag.com/", + "link-sag-tech-forum": "https://tech.forums.softwareag.com/", + "link-apamadoc-api": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/related/ApamaDoc/", + "link-sag-dev-community": "https://tech.forums.softwareag.com/tag/Cumulocity-IoT", + "link-apama-webhelp": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/pam-webhelp/", + "link-sag-privacy-statement": "https://www.softwareag.com/en_corporate/privacy.html", + "link-device-portal": "https://ecosystem.cumulocity.com/device-ecosystem/devices/?_gl=1*1uyml12*_gcl_au*MTI2NTExNjU3MS4xNzMzODQzODY0*_ga*NzUyNzgxNzA4LjE3MzM4NDM4NjU.*_ga_B9NM1M9Q48*MTczNDM4NDM3Ni4xNS4xLjE3MzQzODU3NDcuMjMuMC4w&filter_cumulocity_certified=yes&query_type_cumulocity_certified=and", + "c8y-support-link": "https://cumulocity.atlassian.net/servicedesk/customer/user/login?destination=portals", + "link-sag-documentation" :"https://documentation.softwareag.com/", + "link-c8y-training": "https://cumulocity.moodlecloud.com/", + "c8y-resources-server-link": "https://download.cumulocity.com/", + "c8y-tech-community-link" : "https://techcommunity.cumulocity.com/", + "c8y-support-email" : "support@cumulocity.com", + "email-c8y-info" : "info@cumulocity.com" + +}; + +const resolveHugoShortcode = (link) => { + return link.replace(/\{\{<\s*(.*?)\s*>\}\}/g, (match, shortcode) => { + const resolvedValue = shortcodeMapping[shortcode]; + return resolvedValue !== undefined && resolvedValue !== null ? resolvedValue : ""; + }); +}; + +const resolveFullUrl = (link) => { + if (link.startsWith("mailto:") || link.startsWith("tel:")) { + return null; + } + + const resolvedLink = resolveHugoShortcode(link); + if (resolvedLink.startsWith("http://") || resolvedLink.startsWith("https://")) { + return resolvedLink; + } + + return `${BASE_URL.replace(/\/$/, "")}/${resolvedLink.replace(/^\//, "")}`; +}; + +const checkLink = async (link, mdFile) => { + const fullUrl = resolveFullUrl(link); + if (!fullUrl) { + return null; + } + + try { + let response = await fetch(fullUrl, { method: "HEAD" }); + if (response.status === 405) { + response = await fetch(fullUrl, { method: "GET" }); + } + + if (!response.ok) { + return { url: fullUrl, file: mdFile, status: response.status }; + } + } catch (error) { + return { url: fullUrl, file: mdFile, status: "Error" }; + } + + return null; +}; + +(async () => { + const projectDir = ".././content"; + const markdownFiles = getMarkdownFiles(projectDir); + + const brokenLinks = []; + const limit = pLimit(10); + + + const tasks = markdownFiles.map((mdFile) => { + const content = fs.readFileSync(mdFile, "utf8"); + const links = [...content.matchAll(/(? match[1]); + + + + return links.map((link) => + limit(async () => { + const result = await checkLink(link, mdFile); + if (result) brokenLinks.push(result); + }) + ); + }); + + await Promise.all(tasks.flat()); + + const filteredBrokenLinks = brokenLinks.filter((link) => link.status === 404); + + const csvData = + "URL,File Path,Status Code\n" + + filteredBrokenLinks.map((link) => `${link.url},${link.file},${link.status}`).join("\n"); + + fs.writeFileSync("broken_links_markdown.csv", csvData); + console.log("Broken links in markdown files saved to broken_links_markdown.csv"); + process.exit(0); +})(); \ No newline at end of file diff --git a/broken-links-script/broken_links_markdown.csv b/broken-links-script/broken_links_markdown.csv new file mode 100644 index 0000000000..99530860e3 --- /dev/null +++ b/broken-links-script/broken_links_markdown.csv @@ -0,0 +1,7 @@ +URL,File Path,Status Code +https://github.com/Cumulocity-IoT/cumulocity-examples/snmp,..\content\change-logs\device-management\SNMP-removed-from-docs.md,404 +https://github.com/eclipse/paho.mqtt.python/issues/354,..\content\device-integration\mqtt-examples-bundle\hello-mqtt-python.md,404 +https://openmobilealliance.org/iot/lightweight-m2m-lwm2m,..\content\protocol-integration\lwm2m-bundle\introduction.md,404 +https://en.wikipedia.org/wiki/Sampling_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 +https://en.wikipedia.org/wiki/Quantization_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 +https://cumulocity.com/docs/= 12" + } + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/p-limit": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.2.0.tgz", + "integrity": "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA==", + "license": "MIT", + "dependencies": { + "yocto-queue": "^1.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/yocto-queue": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", + "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==", + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/broken-links-script/package.json b/broken-links-script/package.json new file mode 100644 index 0000000000..238e77b3d3 --- /dev/null +++ b/broken-links-script/package.json @@ -0,0 +1,16 @@ +{ + "name": "scripts", + "version": "1.0.0", + "description": "- Node.js with version 20 and more is required to execute the scripts.", + "main": "BrokenLinkChecker.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "node-fetch": "^3.3.2", + "p-limit": "^6.2.0" + } +} From c12000843f55befb0e8703e885005259acff0862 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Thu, 23 Jan 2025 14:34:48 +0100 Subject: [PATCH 03/11] fixed the wikipedia links and modified broken link workflow for displaying 404 error links --- .github/workflows/broken-links.yml | 19 +- broken-links-script/BrokenLinkChecker.js | 10 +- broken-links-script/broken_links_markdown.csv | 4 +- broken-links-script/package-lock.json | 861 ++++++++++++++++++ broken-links-script/package.json | 5 +- broken-links.json | Bin 0 -> 264 bytes scripts/BrokenLinkChecker.js | 117 --- scripts/broken_links_markdown.csv | 19 - scripts/package-lock.json | 134 --- scripts/package.json | 16 - 10 files changed, 885 insertions(+), 300 deletions(-) create mode 100644 broken-links.json delete mode 100644 scripts/BrokenLinkChecker.js delete mode 100644 scripts/broken_links_markdown.csv delete mode 100644 scripts/package-lock.json delete mode 100644 scripts/package.json diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index b0cf0a5c1e..21f84ab1ba 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -26,12 +26,12 @@ jobs: - name: Install Dependencies run: | - cd scripts + cd broken-links-script npm install - name: Run Broken Link Checker run: | - cd scripts + cd broken-links-script node BrokenLinkChecker.js - name: Parse and Comment Broken Links @@ -39,21 +39,22 @@ jobs: with: script: | const fs = require('fs'); - const path = './scripts/broken_links_markdown.csv'; + const path = './broken-links-script/broken_links_markdown.csv'; let body; if (fs.existsSync(path)) { const data = fs.readFileSync(path, 'utf8').trim(); - if (data.split('\n').length > 1) { - body = `The following broken links were found:\n\n${data - .split('\n') - .slice(1) + const lines = data.split('\n').slice(1); // Skip the header line + const broken404Links = lines.filter(line => line.includes(',404')); // Filter only 404 errors + + if (broken404Links.length > 0) { + body = `### :warning: The following 404 broken links were found:\n\n${broken404Links .map((line) => { const [url, file, status] = line.split(','); return `- **[${url}](${url})** in file \`${file}\` (Status: ${status})`; }) .join('\n')}`; } else { - body = 'No broken links found.'; + body = 'No broken links with 404 status found.'; } } else { body = 'Error: Broken link checker did not produce a CSV report.'; @@ -64,4 +65,4 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: body - }); + }); \ No newline at end of file diff --git a/broken-links-script/BrokenLinkChecker.js b/broken-links-script/BrokenLinkChecker.js index 47107b0289..f105da5b6d 100644 --- a/broken-links-script/BrokenLinkChecker.js +++ b/broken-links-script/BrokenLinkChecker.js @@ -93,7 +93,15 @@ const checkLink = async (link, mdFile) => { const tasks = markdownFiles.map((mdFile) => { const content = fs.readFileSync(mdFile, "utf8"); - const links = [...content.matchAll(/(? match[1]); + const links = [...content.matchAll(/(? { + let link = match[1]; + if (link.includes("(") && !link.endsWith(")")) { + link += ")"; // Add closing bracket if there's an opening bracket but no closing bracket + } + return link; + } + ); diff --git a/broken-links-script/broken_links_markdown.csv b/broken-links-script/broken_links_markdown.csv index 99530860e3..3a4a7aa4e6 100644 --- a/broken-links-script/broken_links_markdown.csv +++ b/broken-links-script/broken_links_markdown.csv @@ -2,6 +2,4 @@ URL,File Path,Status Code https://github.com/Cumulocity-IoT/cumulocity-examples/snmp,..\content\change-logs\device-management\SNMP-removed-from-docs.md,404 https://github.com/eclipse/paho.mqtt.python/issues/354,..\content\device-integration\mqtt-examples-bundle\hello-mqtt-python.md,404 https://openmobilealliance.org/iot/lightweight-m2m-lwm2m,..\content\protocol-integration\lwm2m-bundle\introduction.md,404 -https://en.wikipedia.org/wiki/Sampling_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 -https://en.wikipedia.org/wiki/Quantization_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 -https://cumulocity.com/docs/=12" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/agent-base": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/chalk": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", + "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" } }, "node_modules/data-uri-to-buffer": { @@ -22,6 +155,124 @@ "node": ">= 12" } }, + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true, + "license": "MIT" + }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", @@ -45,6 +296,23 @@ "node": "^12.20 || >= 14.13" } }, + "node_modules/foreground-child": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -57,6 +325,252 @@ "node": ">=12.20.0" } }, + "node_modules/gaxios": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.7.1.tgz", + "integrity": "sha512-LDODD4TMYx7XXdpwxAVRAIAuB0bzv0s+ywFonY46k126qzQHT9ygyoa9tncmOiQmmDrik65UYsEkv3lbfqQ3yQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "extend": "^3.0.2", + "https-proxy-agent": "^7.0.1", + "is-stream": "^2.0.0", + "node-fetch": "^2.6.9", + "uuid": "^9.0.1" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/gaxios/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/htmlparser2": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", + "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.1.0", + "entities": "^4.5.0" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/linkinator": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/linkinator/-/linkinator-6.1.2.tgz", + "integrity": "sha512-PndSrQe21Hf4sn2vZldEzJmD0EUJbIsEy4jcZLcHd6IZfQ6rC6iv+Fwo666TWM9DcXjbCrHpxnVX6xaGrcJ/eA==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^5.0.0", + "escape-html": "^1.0.3", + "gaxios": "^6.0.0", + "glob": "^10.3.10", + "htmlparser2": "^9.0.0", + "marked": "^13.0.0", + "meow": "^13.0.0", + "mime": "^4.0.0", + "server-destroy": "^1.0.1", + "srcset": "^5.0.0" + }, + "bin": { + "linkinator": "build/src/cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/marked": { + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/marked/-/marked-13.0.3.tgz", + "integrity": "sha512-rqRix3/TWzE9rIoFGIn8JmsVfhiuC8VIQ8IdX5TfzmeBucdY05/0UlzKaw0eVtpcN/OdVFpBk7CjKGo9iHJ/zA==", + "dev": true, + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/meow": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz", + "integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.6.tgz", + "integrity": "sha512-4rGt7rvQHBbaSOF9POGkk1ocRP16Md1x36Xma8sz8h8/vfCUI2OtEIeCqe4Ofes853x4xDoPiFLIT47J5fI/7A==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa" + ], + "license": "MIT", + "bin": { + "mime": "bin/cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -109,6 +623,221 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/server-destroy": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/server-destroy/-/server-destroy-1.0.1.tgz", + "integrity": "sha512-rb+9B5YBIEzYcD6x2VKidaa+cqYBJQKnU4oe4E3ANwRRN56yk/ua1YCJT1n21NTS8w6CcOclAKNP3PhdCXKYtQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/srcset": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/srcset/-/srcset-5.0.1.tgz", + "integrity": "sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/web-streams-polyfill": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", @@ -118,6 +847,138 @@ "node": ">= 8" } }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/yocto-queue": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", diff --git a/broken-links-script/package.json b/broken-links-script/package.json index 238e77b3d3..d33b278b2c 100644 --- a/broken-links-script/package.json +++ b/broken-links-script/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "- Node.js with version 20 and more is required to execute the scripts.", "main": "BrokenLinkChecker.js", - "type": "module", + "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -12,5 +12,8 @@ "dependencies": { "node-fetch": "^3.3.2", "p-limit": "^6.2.0" + }, + "devDependencies": { + "linkinator": "^6.1.2" } } diff --git a/broken-links.json b/broken-links.json new file mode 100644 index 0000000000000000000000000000000000000000..e97bdfa20bbe8506995c32c1508054426322a4c5 GIT binary patch literal 264 zcmezWubP3Efr~)_2$dLe7&0017_u3Pfov { - const files = fs.readdirSync(dir, { withFileTypes: true }); - let markdownFiles = []; - for (const file of files) { - const fullPath = path.join(dir, file.name); - if (file.isDirectory()) { - markdownFiles = markdownFiles.concat(getMarkdownFiles(fullPath)); - } else if (file.isFile() && file.name.endsWith(".md")) { - markdownFiles.push(fullPath); - } - } - return markdownFiles; -}; - -const BASE_URL = "https://cumulocity.com/docs"; - -const shortcodeMapping = { - "product-c8y-iot": "Cumulocity IoT", - "c8y-edge-current-version-alt": "10.18", - "domain-c8y": "cumulocity.com", - "link-c8y-github": "https://github.com/Cumulocity-IoT", - "link-sag-portal": "https://empower.softwareag.com/", - "link-sag-tech-forum": "https://tech.forums.softwareag.com/", - "link-apamadoc-api": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/related/ApamaDoc/", - "link-sag-dev-community": "https://tech.forums.softwareag.com/tag/Cumulocity-IoT", - "link-apama-webhelp": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/pam-webhelp/", - "link-sag-privacy-statement": "https://www.softwareag.com/en_corporate/privacy.html", - "link-device-portal": "https://ecosystem.cumulocity.com/device-ecosystem/devices/?_gl=1*1uyml12*_gcl_au*MTI2NTExNjU3MS4xNzMzODQzODY0*_ga*NzUyNzgxNzA4LjE3MzM4NDM4NjU.*_ga_B9NM1M9Q48*MTczNDM4NDM3Ni4xNS4xLjE3MzQzODU3NDcuMjMuMC4w&filter_cumulocity_certified=yes&query_type_cumulocity_certified=and", - "c8y-support-link": "https://cumulocity.atlassian.net/servicedesk/customer/user/login?destination=portals", - "link-sag-documentation" :"https://documentation.softwareag.com/", - "link-c8y-training": "https://cumulocity.moodlecloud.com/", - "c8y-resources-server-link": "https://download.cumulocity.com/", - "c8y-tech-community-link" : "https://techcommunity.cumulocity.com/", - "c8y-support-email" : "support@cumulocity.com", - "email-c8y-info" : "info@cumulocity.com" - -}; - -const resolveHugoShortcode = (link) => { - return link.replace(/\{\{<\s*(.*?)\s*>\}\}/g, (match, shortcode) => { - const resolvedValue = shortcodeMapping[shortcode]; - return resolvedValue !== undefined && resolvedValue !== null ? resolvedValue : ""; - }); -}; - -const resolveFullUrl = (link) => { - if (link.startsWith("mailto:") || link.startsWith("tel:")) { - return null; - } - - const resolvedLink = resolveHugoShortcode(link); - if (resolvedLink.startsWith("http://") || resolvedLink.startsWith("https://")) { - return resolvedLink; - } - - return `${BASE_URL.replace(/\/$/, "")}/${resolvedLink.replace(/^\//, "")}`; -}; - -const checkLink = async (link, mdFile) => { - const fullUrl = resolveFullUrl(link); - if (!fullUrl) { - return null; - } - - try { - let response = await fetch(fullUrl, { method: "HEAD" }); - if (response.status === 405) { - response = await fetch(fullUrl, { method: "GET" }); - } - - if (!response.ok) { - return { url: fullUrl, file: mdFile, status: response.status }; - } - } catch (error) { - return { url: fullUrl, file: mdFile, status: "Error" }; - } - - return null; -}; - -(async () => { - const projectDir = ".././content"; - const markdownFiles = getMarkdownFiles(projectDir); - - const brokenLinks = []; - const limit = pLimit(10); - - - const tasks = markdownFiles.map((mdFile) => { - const content = fs.readFileSync(mdFile, "utf8"); - const links = [...content.matchAll(/(? match[1]); - - - - return links.map((link) => - limit(async () => { - const result = await checkLink(link, mdFile); - if (result) brokenLinks.push(result); - }) - ); - }); - - await Promise.all(tasks.flat()); - - const csvData = - "URL,File Path,Status Code\n" + - brokenLinks.map((link) => `${link.url},${link.file},${link.status}`).join("\n"); - - fs.writeFileSync("broken_links_markdown.csv", csvData); - console.log("Broken links in markdown files saved to broken_links_markdown.csv"); - process.exit(0); -})(); diff --git a/scripts/broken_links_markdown.csv b/scripts/broken_links_markdown.csv deleted file mode 100644 index ba11200fb9..0000000000 --- a/scripts/broken_links_markdown.csv +++ /dev/null @@ -1,19 +0,0 @@ -URL,File Path,Status Code -https://github.com/Cumulocity-IoT/cumulocity-examples/snmp,..\content\change-logs\device-management\SNMP-removed-from-docs.md,404 -https://download.cumulocity.com/,..\content\about_documentation\scope.md,Error -https://download.cumulocity.com/,..\content\additional-resources\more-documentation.md,Error -https://portal.azure.com/,..\content\datahub\integrating-datahub-with-other-products-bundle\integration-powerbi.md,403 -https://github.com/eclipse/paho.mqtt.python/issues/354,..\content\device-integration\mqtt-examples-bundle\hello-mqtt-python.md,404 -https://download.cumulocity.com/,..\content\edge\edge-databroker-bundle\databroker-edge.md,Error -https://download.cumulocity.com/,..\content\edge\edge-databroker-bundle\databroker-edge.md,Error -https://download.cumulocity.com/,..\content\edge\edge-update-bundle\updating-edge-gui.md,429 -https://download.cumulocity.com/,..\content\edge\edge-installation-bundle\prerequisites.md,429 -https://www.mathworks.com/help/predmaint/ug/remaining-useful-life-estimation-using-convolutional-neural-network.html,..\content\machine-learning\AI-ML-integration-bundle\step1-create-ai-ml-model.md,403 -https://download.cumulocity.com/,..\content\glossary\y.md,429 -http://www.oracle.com/technetwork/java/javase/downloads/index.html,..\content\microservice-sdk\java-bundle\introduction.md,403 -https://www.oracle.com/technetwork/java/javase/downloads/index.html,..\content\microservice-sdk\java-bundle\ip-tracker-microservice.md,403 -https://openmobilealliance.org/iot/lightweight-m2m-lwm2m,..\content\protocol-integration\lwm2m-bundle\introduction.md,404 -https://en.wikipedia.org/wiki/Sampling_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 -https://en.wikipedia.org/wiki/Quantization_(signal_processing,..\content\streaming-analytics\analytics-builder-bundle\details-of-values-and-blocks.md,404 -https://cumulocity.com/docs/= 12" - } - }, - "node_modules/fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "paypal", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "dependencies": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - }, - "engines": { - "node": "^12.20 || >= 14.13" - } - }, - "node_modules/formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "license": "MIT", - "dependencies": { - "fetch-blob": "^3.1.2" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "engines": { - "node": ">=10.5.0" - } - }, - "node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "license": "MIT", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, - "node_modules/p-limit": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.2.0.tgz", - "integrity": "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA==", - "license": "MIT", - "dependencies": { - "yocto-queue": "^1.1.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/web-streams-polyfill": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", - "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/yocto-queue": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", - "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==", - "license": "MIT", - "engines": { - "node": ">=12.20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } -} diff --git a/scripts/package.json b/scripts/package.json deleted file mode 100644 index 238e77b3d3..0000000000 --- a/scripts/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "scripts", - "version": "1.0.0", - "description": "- Node.js with version 20 and more is required to execute the scripts.", - "main": "BrokenLinkChecker.js", - "type": "module", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "node-fetch": "^3.3.2", - "p-limit": "^6.2.0" - } -} From b00ff9cfd08af15a9de83753cb6165d0f5c1d19e Mon Sep 17 00:00:00 2001 From: logu1411 Date: Thu, 23 Jan 2025 15:05:41 +0100 Subject: [PATCH 04/11] Modified shortcode links --- broken-links-script/BrokenLinkChecker.js | 19 +++++++++---------- broken-links-script/broken_links_markdown.csv | 6 ++++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/broken-links-script/BrokenLinkChecker.js b/broken-links-script/BrokenLinkChecker.js index f105da5b6d..4870fac980 100644 --- a/broken-links-script/BrokenLinkChecker.js +++ b/broken-links-script/BrokenLinkChecker.js @@ -20,19 +20,18 @@ const getMarkdownFiles = (dir) => { const BASE_URL = "https://cumulocity.com/docs"; const shortcodeMapping = { - "product-c8y-iot": "Cumulocity IoT", + "product-c8y-iot": "Cumulocity", "c8y-edge-current-version-alt": "10.18", "domain-c8y": "cumulocity.com", - "link-c8y-github": "https://github.com/Cumulocity-IoT", - "link-sag-portal": "https://empower.softwareag.com/", - "link-sag-tech-forum": "https://tech.forums.softwareag.com/", - "link-apamadoc-api": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/related/ApamaDoc/", - "link-sag-dev-community": "https://tech.forums.softwareag.com/tag/Cumulocity-IoT", - "link-apama-webhelp": "https://documentation.softwareag.com/pam/10.15.5/en/webhelp/pam-webhelp/", - "link-sag-privacy-statement": "https://www.softwareag.com/en_corporate/privacy.html", - "link-device-portal": "https://ecosystem.cumulocity.com/device-ecosystem/devices/?_gl=1*1uyml12*_gcl_au*MTI2NTExNjU3MS4xNzMzODQzODY0*_ga*NzUyNzgxNzA4LjE3MzM4NDM4NjU.*_ga_B9NM1M9Q48*MTczNDM4NDM3Ni4xNS4xLjE3MzQzODU3NDcuMjMuMC4w&filter_cumulocity_certified=yes&query_type_cumulocity_certified=and", + "link-c8y-github": "https://github.com/Cumulocity-IoT/", + "c8y-edge-current-version-alt" : "10.18", + "c8y-edge-current-version" : "1018", + "c8y-support-link" : "https://cumulocity.com/support", + "link-apamadoc-api" : "https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.html", + "link-c8y-doc-baseurl" : ".Page.Site.BaseURL", + "link-device-portal": "https://ecosystem.cumulocity.com/devices/?filter_cumulocity_certified=yes", "c8y-support-link": "https://cumulocity.atlassian.net/servicedesk/customer/user/login?destination=portals", - "link-sag-documentation" :"https://documentation.softwareag.com/", + "link-apama-webhelp" : "https://cumulocity.com/apama/docs/latest", "link-c8y-training": "https://cumulocity.moodlecloud.com/", "c8y-resources-server-link": "https://download.cumulocity.com/", "c8y-tech-community-link" : "https://techcommunity.cumulocity.com/", diff --git a/broken-links-script/broken_links_markdown.csv b/broken-links-script/broken_links_markdown.csv index 3a4a7aa4e6..d2515ff5eb 100644 --- a/broken-links-script/broken_links_markdown.csv +++ b/broken-links-script/broken_links_markdown.csv @@ -1,5 +1,7 @@ URL,File Path,Status Code -https://github.com/Cumulocity-IoT/cumulocity-examples/snmp,..\content\change-logs\device-management\SNMP-removed-from-docs.md,404 -https://github.com/eclipse/paho.mqtt.python/issues/354,..\content\device-integration\mqtt-examples-bundle\hello-mqtt-python.md,404 +https://github.com/Cumulocity-IoT//cumulocity-examples/snmp,..\content\change-logs\device-management\SNMP-removed-from-docs.md,404 https://openmobilealliance.org/iot/lightweight-m2m-lwm2m,..\content\protocol-integration\lwm2m-bundle\introduction.md,404 +https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.htmlcom/apama/cumulocity/package-summary.html,..\content\streaming-analytics\epl-apps-bundle\basic-functionality.md,404 +https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.html/com/apama/cumulocity/package-summary.html,..\content\streaming-analytics\epl-apps-bundle\basic-functionality.md,404 +https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.htmlcom/softwareag/connectivity/httpclient/package-summary.html,..\content\streaming-analytics\epl-apps-bundle\microservices.md,404 https://cumulocity.com/docs/ Date: Thu, 23 Jan 2025 23:50:49 +0100 Subject: [PATCH 05/11] modified the broken link workflow to get the comment, fixed the short codes and removed unnecessary files --- .github/workflows/broken-links.yml | 29 +- broken-links-script/BrokenLinkChecker.js | 4 +- broken-links-script/package-lock.json | 995 ----------------------- broken-links-script/package.json | 19 - 4 files changed, 15 insertions(+), 1032 deletions(-) delete mode 100644 broken-links-script/package-lock.json delete mode 100644 broken-links-script/package.json diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index 21f84ab1ba..41c1ff8fa6 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -22,7 +22,7 @@ jobs: - name: Set Up Node.js uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - name: Install Dependencies run: | @@ -40,29 +40,28 @@ jobs: script: | const fs = require('fs'); const path = './broken-links-script/broken_links_markdown.csv'; - let body; + if (fs.existsSync(path)) { const data = fs.readFileSync(path, 'utf8').trim(); const lines = data.split('\n').slice(1); // Skip the header line - const broken404Links = lines.filter(line => line.includes(',404')); // Filter only 404 errors - if (broken404Links.length > 0) { - body = `### :warning: The following 404 broken links were found:\n\n${broken404Links + if (lines.length > 0) { + const body = `### :warning: The following 404 broken links were found:\n\n${broken404Links .map((line) => { const [url, file, status] = line.split(','); return `- **[${url}](${url})** in file \`${file}\` (Status: ${status})`; }) .join('\n')}`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }); } else { - body = 'No broken links with 404 status found.'; + console.log('No broken links with 404 status found'); } } else { - body = 'Error: Broken link checker did not produce a CSV report.'; - } - - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: body - }); \ No newline at end of file + console.log('Error: Broken link checker did not produce a CSV report.'); + } \ No newline at end of file diff --git a/broken-links-script/BrokenLinkChecker.js b/broken-links-script/BrokenLinkChecker.js index 4870fac980..b5367ef4e4 100644 --- a/broken-links-script/BrokenLinkChecker.js +++ b/broken-links-script/BrokenLinkChecker.js @@ -21,7 +21,6 @@ const BASE_URL = "https://cumulocity.com/docs"; const shortcodeMapping = { "product-c8y-iot": "Cumulocity", - "c8y-edge-current-version-alt": "10.18", "domain-c8y": "cumulocity.com", "link-c8y-github": "https://github.com/Cumulocity-IoT/", "c8y-edge-current-version-alt" : "10.18", @@ -30,7 +29,6 @@ const shortcodeMapping = { "link-apamadoc-api" : "https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.html", "link-c8y-doc-baseurl" : ".Page.Site.BaseURL", "link-device-portal": "https://ecosystem.cumulocity.com/devices/?filter_cumulocity_certified=yes", - "c8y-support-link": "https://cumulocity.atlassian.net/servicedesk/customer/user/login?destination=portals", "link-apama-webhelp" : "https://cumulocity.com/apama/docs/latest", "link-c8y-training": "https://cumulocity.moodlecloud.com/", "c8y-resources-server-link": "https://download.cumulocity.com/", @@ -83,7 +81,7 @@ const checkLink = async (link, mdFile) => { }; (async () => { - const projectDir = ".././content"; + const projectDir = "../content"; const markdownFiles = getMarkdownFiles(projectDir); const brokenLinks = []; diff --git a/broken-links-script/package-lock.json b/broken-links-script/package-lock.json deleted file mode 100644 index f118a63ea7..0000000000 --- a/broken-links-script/package-lock.json +++ /dev/null @@ -1,995 +0,0 @@ -{ - "name": "scripts", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "scripts", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "node-fetch": "^3.3.2", - "p-limit": "^6.2.0" - }, - "devDependencies": { - "linkinator": "^6.1.2" - } - }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, - "node_modules/agent-base": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", - "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, - "node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/chalk": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", - "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "license": "MIT" - }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/data-uri-to-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "dev": true, - "license": "MIT", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "BSD-2-Clause" - }, - "node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", - "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true, - "license": "MIT" - }, - "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true, - "license": "MIT" - }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "dev": true, - "license": "MIT" - }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true, - "license": "MIT" - }, - "node_modules/fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "paypal", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "dependencies": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - }, - "engines": { - "node": "^12.20 || >= 14.13" - } - }, - "node_modules/foreground-child": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", - "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", - "dev": true, - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "license": "MIT", - "dependencies": { - "fetch-blob": "^3.1.2" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/gaxios": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.7.1.tgz", - "integrity": "sha512-LDODD4TMYx7XXdpwxAVRAIAuB0bzv0s+ywFonY46k126qzQHT9ygyoa9tncmOiQmmDrik65UYsEkv3lbfqQ3yQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "extend": "^3.0.2", - "https-proxy-agent": "^7.0.1", - "is-stream": "^2.0.0", - "node-fetch": "^2.6.9", - "uuid": "^9.0.1" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/gaxios/node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dev": true, - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", - "dev": true, - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/htmlparser2": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", - "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", - "dev": true, - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "MIT", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.1.0", - "entities": "^4.5.0" - } - }, - "node_modules/https-proxy-agent": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", - "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "dev": true, - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, - "license": "ISC" - }, - "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, - "node_modules/linkinator": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/linkinator/-/linkinator-6.1.2.tgz", - "integrity": "sha512-PndSrQe21Hf4sn2vZldEzJmD0EUJbIsEy4jcZLcHd6IZfQ6rC6iv+Fwo666TWM9DcXjbCrHpxnVX6xaGrcJ/eA==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^5.0.0", - "escape-html": "^1.0.3", - "gaxios": "^6.0.0", - "glob": "^10.3.10", - "htmlparser2": "^9.0.0", - "marked": "^13.0.0", - "meow": "^13.0.0", - "mime": "^4.0.0", - "server-destroy": "^1.0.1", - "srcset": "^5.0.0" - }, - "bin": { - "linkinator": "build/src/cli.js" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/marked": { - "version": "13.0.3", - "resolved": "https://registry.npmjs.org/marked/-/marked-13.0.3.tgz", - "integrity": "sha512-rqRix3/TWzE9rIoFGIn8JmsVfhiuC8VIQ8IdX5TfzmeBucdY05/0UlzKaw0eVtpcN/OdVFpBk7CjKGo9iHJ/zA==", - "dev": true, - "license": "MIT", - "bin": { - "marked": "bin/marked.js" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/meow": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz", - "integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mime": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.6.tgz", - "integrity": "sha512-4rGt7rvQHBbaSOF9POGkk1ocRP16Md1x36Xma8sz8h8/vfCUI2OtEIeCqe4Ofes853x4xDoPiFLIT47J5fI/7A==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "engines": { - "node": ">=10.5.0" - } - }, - "node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "license": "MIT", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, - "node_modules/p-limit": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.2.0.tgz", - "integrity": "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA==", - "license": "MIT", - "dependencies": { - "yocto-queue": "^1.1.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true, - "license": "BlueOak-1.0.0" - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "engines": { - "node": ">=16 || 14 >=14.18" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/server-destroy": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/server-destroy/-/server-destroy-1.0.1.tgz", - "integrity": "sha512-rb+9B5YBIEzYcD6x2VKidaa+cqYBJQKnU4oe4E3ANwRRN56yk/ua1YCJT1n21NTS8w6CcOclAKNP3PhdCXKYtQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/srcset": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/srcset/-/srcset-5.0.1.tgz", - "integrity": "sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true, - "license": "MIT" - }, - "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/web-streams-polyfill": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", - "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true, - "license": "BSD-2-Clause" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dev": true, - "license": "MIT", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yocto-queue": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", - "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==", - "license": "MIT", - "engines": { - "node": ">=12.20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } -} diff --git a/broken-links-script/package.json b/broken-links-script/package.json deleted file mode 100644 index d33b278b2c..0000000000 --- a/broken-links-script/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "scripts", - "version": "1.0.0", - "description": "- Node.js with version 20 and more is required to execute the scripts.", - "main": "BrokenLinkChecker.js", - "type": "module", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "node-fetch": "^3.3.2", - "p-limit": "^6.2.0" - }, - "devDependencies": { - "linkinator": "^6.1.2" - } -} From 4da17b06398fc3e595c856ae84a6c06ebfbdbd7e Mon Sep 17 00:00:00 2001 From: logu1411 Date: Thu, 23 Jan 2025 23:53:49 +0100 Subject: [PATCH 06/11] checking the node version for the workflow --- .github/workflows/broken-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index 41c1ff8fa6..717bb37bc9 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -22,7 +22,7 @@ jobs: - name: Set Up Node.js uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 18 - name: Install Dependencies run: | From 5280ef6fcb97c91b957ff82bef8e81261253d37d Mon Sep 17 00:00:00 2001 From: logu1411 Date: Thu, 23 Jan 2025 23:57:18 +0100 Subject: [PATCH 07/11] Added necessary dependencies --- broken-links-script/package-lock.json | 134 ++++++++++++++++++++++++++ broken-links-script/package.json | 15 +++ 2 files changed, 149 insertions(+) create mode 100644 broken-links-script/package-lock.json create mode 100644 broken-links-script/package.json diff --git a/broken-links-script/package-lock.json b/broken-links-script/package-lock.json new file mode 100644 index 0000000000..505811e707 --- /dev/null +++ b/broken-links-script/package-lock.json @@ -0,0 +1,134 @@ +{ + "name": "broken-links-script", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "broken-links-script", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "node-fetch": "^3.3.2", + "p-limit": "^6.2.0" + } + }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/p-limit": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.2.0.tgz", + "integrity": "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA==", + "license": "MIT", + "dependencies": { + "yocto-queue": "^1.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/yocto-queue": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", + "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==", + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/broken-links-script/package.json b/broken-links-script/package.json new file mode 100644 index 0000000000..f7807106d0 --- /dev/null +++ b/broken-links-script/package.json @@ -0,0 +1,15 @@ +{ + "name": "broken-links-script", + "version": "1.0.0", + "main": "BrokenLinkChecker.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "node-fetch": "^3.3.2", + "p-limit": "^6.2.0" + } +} From 1b6cf2dffd3dd4fa49e8f38dd84af637fdbcb9a3 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Fri, 24 Jan 2025 00:00:52 +0100 Subject: [PATCH 08/11] resolve ES module syntax --- broken-links-script/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/broken-links-script/package.json b/broken-links-script/package.json index f7807106d0..690b88c32e 100644 --- a/broken-links-script/package.json +++ b/broken-links-script/package.json @@ -2,6 +2,7 @@ "name": "broken-links-script", "version": "1.0.0", "main": "BrokenLinkChecker.js", + "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, From 1bdb754031d86cf9fbb44bb0e205db20dfdff6fa Mon Sep 17 00:00:00 2001 From: logu1411 Date: Fri, 24 Jan 2025 00:05:37 +0100 Subject: [PATCH 09/11] corrected variable name --- .github/workflows/broken-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index 717bb37bc9..ce17069b75 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -46,7 +46,7 @@ jobs: const lines = data.split('\n').slice(1); // Skip the header line if (lines.length > 0) { - const body = `### :warning: The following 404 broken links were found:\n\n${broken404Links + const body = `### :warning: The following 404 broken links were found:\n\n${lines .map((line) => { const [url, file, status] = line.split(','); return `- **[${url}](${url})** in file \`${file}\` (Status: ${status})`; From b6aedf7d8ecbe463c76698c5a7d38ab437627353 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Wed, 5 Feb 2025 09:27:16 +0100 Subject: [PATCH 10/11] Optimize link checking by gathering unique links before validation --- broken-links-script/BrokenLinkChecker.js | 68 +++-- broken-links-script/broken_links_markdown.csv | 7 - broken-links-script/package-lock.json | 273 ++++++++++++++++++ broken-links-script/package.json | 3 +- 4 files changed, 308 insertions(+), 43 deletions(-) delete mode 100644 broken-links-script/broken_links_markdown.csv diff --git a/broken-links-script/BrokenLinkChecker.js b/broken-links-script/BrokenLinkChecker.js index b5367ef4e4..0c02ff4467 100644 --- a/broken-links-script/BrokenLinkChecker.js +++ b/broken-links-script/BrokenLinkChecker.js @@ -35,7 +35,6 @@ const shortcodeMapping = { "c8y-tech-community-link" : "https://techcommunity.cumulocity.com/", "c8y-support-email" : "support@cumulocity.com", "email-c8y-info" : "info@cumulocity.com" - }; const resolveHugoShortcode = (link) => { @@ -58,23 +57,18 @@ const resolveFullUrl = (link) => { return `${BASE_URL.replace(/\/$/, "")}/${resolvedLink.replace(/^\//, "")}`; }; -const checkLink = async (link, mdFile) => { - const fullUrl = resolveFullUrl(link); - if (!fullUrl) { - return null; - } - +const checkLink = async (link) => { try { - let response = await fetch(fullUrl, { method: "HEAD" }); + let response = await fetch(link, { method: "HEAD" }); if (response.status === 405) { - response = await fetch(fullUrl, { method: "GET" }); + response = await fetch(link, { method: "GET" }); } if (!response.ok) { - return { url: fullUrl, file: mdFile, status: response.status }; + return { url: link, status: response.status }; } } catch (error) { - return { url: fullUrl, file: mdFile, status: "Error" }; + return { url: link, status: "Error" }; } return null; @@ -84,41 +78,45 @@ const checkLink = async (link, mdFile) => { const projectDir = "../content"; const markdownFiles = getMarkdownFiles(projectDir); - const brokenLinks = []; - const limit = pLimit(10); - + const linkFileMap = new Map(); + const uniqueLinks = new Set(); - const tasks = markdownFiles.map((mdFile) => { + markdownFiles.forEach((mdFile) => { const content = fs.readFileSync(mdFile, "utf8"); - const links = [...content.matchAll(/(? { - let link = match[1]; - if (link.includes("(") && !link.endsWith(")")) { - link += ")"; // Add closing bracket if there's an opening bracket but no closing bracket + const links = [...content.matchAll(/(? match[1]); + + links.forEach((link) => { + const resolvedLink = resolveFullUrl(link); + if (resolvedLink) { + uniqueLinks.add(resolvedLink); + if (!linkFileMap.has(resolvedLink)) { + linkFileMap.set(resolvedLink, []); } - return link; + linkFileMap.get(resolvedLink).push(mdFile); } - ); - - - - return links.map((link) => - limit(async () => { - const result = await checkLink(link, mdFile); - if (result) brokenLinks.push(result); - }) - ); + }); }); - await Promise.all(tasks.flat()); + const brokenLinks = []; + const limit = pLimit(10); + + await Promise.all([...uniqueLinks].map((link) => + limit(async () => { + const result = await checkLink(link); + if (result) { + result.files = linkFileMap.get(link); + brokenLinks.push(result); + } + }) + )); const filteredBrokenLinks = brokenLinks.filter((link) => link.status === 404); const csvData = - "URL,File Path,Status Code\n" + - filteredBrokenLinks.map((link) => `${link.url},${link.file},${link.status}`).join("\n"); + "URL,Status Code,Files\n" + + filteredBrokenLinks.map((link) => `${link.url},${link.status},"${link.files.join("; ")}"`).join("\n"); fs.writeFileSync("broken_links_markdown.csv", csvData); - console.log("Broken links in markdown files saved to broken_links_markdown.csv"); + console.log("broken links saved to broken_links_markdown.csv"); process.exit(0); })(); \ No newline at end of file diff --git a/broken-links-script/broken_links_markdown.csv b/broken-links-script/broken_links_markdown.csv deleted file mode 100644 index d2515ff5eb..0000000000 --- a/broken-links-script/broken_links_markdown.csv +++ /dev/null @@ -1,7 +0,0 @@ -URL,File Path,Status Code -https://github.com/Cumulocity-IoT//cumulocity-examples/snmp,..\content\change-logs\device-management\SNMP-removed-from-docs.md,404 -https://openmobilealliance.org/iot/lightweight-m2m-lwm2m,..\content\protocol-integration\lwm2m-bundle\introduction.md,404 -https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.htmlcom/apama/cumulocity/package-summary.html,..\content\streaming-analytics\epl-apps-bundle\basic-functionality.md,404 -https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.html/com/apama/cumulocity/package-summary.html,..\content\streaming-analytics\epl-apps-bundle\basic-functionality.md,404 -https://cumulocity.com/apama/docs/latest/related/ApamaDoc/index.htmlcom/softwareag/connectivity/httpclient/package-summary.html,..\content\streaming-analytics\epl-apps-bundle\microservices.md,404 -https://cumulocity.com/docs/=18.17" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" + } + }, + "node_modules/cheerio-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", + "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-select": "^5.1.0", + "css-what": "^6.1.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", @@ -22,6 +99,86 @@ "node": ">= 12" } }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/encoding-sniffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.0.tgz", + "integrity": "sha512-ju7Wq1kg04I3HtiYIOrUrdfdDvkyO9s5XM8QAj/bN61Yo/Vb4vgJxy5vi4Yxk01gWHbrofpPtpxM8bKger9jhg==", + "license": "MIT", + "dependencies": { + "iconv-lite": "^0.6.3", + "whatwg-encoding": "^3.1.1" + }, + "funding": { + "url": "https://github.com/fb55/encoding-sniffer?sponsor=1" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", @@ -57,6 +214,37 @@ "node": ">=12.20.0" } }, + "node_modules/htmlparser2": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", + "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.1.0", + "entities": "^4.5.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -94,6 +282,18 @@ "url": "https://opencollective.com/node-fetch" } }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, "node_modules/p-limit": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.2.0.tgz", @@ -109,6 +309,58 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse5": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.1.tgz", + "integrity": "sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==", + "license": "MIT", + "dependencies": { + "entities": "^4.5.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.1.0.tgz", + "integrity": "sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==", + "license": "MIT", + "dependencies": { + "domhandler": "^5.0.3", + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-7.1.2.tgz", + "integrity": "sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==", + "license": "MIT", + "dependencies": { + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/undici": { + "version": "6.21.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz", + "integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, "node_modules/web-streams-polyfill": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", @@ -118,6 +370,27 @@ "node": ">= 8" } }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/yocto-queue": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", diff --git a/broken-links-script/package.json b/broken-links-script/package.json index 690b88c32e..fef2d73733 100644 --- a/broken-links-script/package.json +++ b/broken-links-script/package.json @@ -2,7 +2,7 @@ "name": "broken-links-script", "version": "1.0.0", "main": "BrokenLinkChecker.js", - "type": "module", + "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -10,6 +10,7 @@ "license": "ISC", "description": "", "dependencies": { + "cheerio": "^1.0.0", "node-fetch": "^3.3.2", "p-limit": "^6.2.0" } From 940bb16ce9c90e36523259081ab0fee4eac74aa5 Mon Sep 17 00:00:00 2001 From: logu1411 Date: Wed, 5 Feb 2025 09:39:29 +0100 Subject: [PATCH 11/11] Add validation to detect unencoded parentheses in links --- broken-links-script/BrokenLinkChecker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/broken-links-script/BrokenLinkChecker.js b/broken-links-script/BrokenLinkChecker.js index 0c02ff4467..032f4be21f 100644 --- a/broken-links-script/BrokenLinkChecker.js +++ b/broken-links-script/BrokenLinkChecker.js @@ -57,6 +57,11 @@ const resolveFullUrl = (link) => { return `${BASE_URL.replace(/\/$/, "")}/${resolvedLink.replace(/^\//, "")}`; }; +const hasUnencodedParentheses = (link) => { + const unencodedParenthesesRegex = /[()]/; + return unencodedParenthesesRegex.test(link); +}; + const checkLink = async (link) => { try { let response = await fetch(link, { method: "HEAD" }); @@ -86,6 +91,10 @@ const checkLink = async (link) => { const links = [...content.matchAll(/(? match[1]); links.forEach((link) => { + if (hasUnencodedParentheses(link)) { + throw new Error(`Unencoded parentheses detected in link: "${link}" in file: ${mdFile}`); + } + const resolvedLink = resolveFullUrl(link); if (resolvedLink) { uniqueLinks.add(resolvedLink); @@ -117,6 +126,6 @@ const checkLink = async (link) => { filteredBrokenLinks.map((link) => `${link.url},${link.status},"${link.files.join("; ")}"`).join("\n"); fs.writeFileSync("broken_links_markdown.csv", csvData); - console.log("broken links saved to broken_links_markdown.csv"); + console.log("Broken links saved to broken_links_markdown.csv"); process.exit(0); })(); \ No newline at end of file