Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ src/directory/flatDirectory.json
public/ai/
src/references/raw-references.json
.yarn/*
.kiro

#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@types/url-parse": "^1.4.3",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"axios": "^1.11.0",
"cheerio": "^1.0.0-rc.12",
"classnames": "^2.3.2",
"cross-env": "^7.0.3",
Expand Down Expand Up @@ -94,7 +93,6 @@
"tough-cookie": "4.1.3",
"aws-cdk-lib": "2.189.1",
"@adobe/css-tools": "4.3.2",
"follow-redirects": "^1.15.6",
"sharp": "0.33.1",
"ejs": "3.1.10",
"braces": "^3.0.3",
Expand Down
37 changes: 14 additions & 23 deletions tasks/link-checker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const puppeteer = require('puppeteer'); // eslint-disable-line
const axios = require('axios'); // eslint-disable-line

const SITEMAP_URL = 'https://docs.amplify.aws/sitemap.xml';
const DOMAIN = 'https://docs.amplify.aws';
Expand Down Expand Up @@ -225,29 +224,21 @@ const linkChecker = async (localDomain, links) => {
console.log('Visiting urls...\n');

for (const href in urlsToVisit) {
let request = axios
.get(href, {
timeout: 5000
})
.then((response) => {
let statusCode = response.status;
if (statusCode && statusCode !== 200) {
statusCodes[statusCode] = statusCodes[statusCode] || [];
statusCodes[statusCode].push(href);
}
})
.catch((e) => {
let statusCode = e?.response?.status;
if (statusCode) {
statusCodes[statusCode] = statusCodes[statusCode] || [];
statusCodes[statusCode].push(href);
}
if (statusCode === 404) {
brokenLinks.push({ url: href, pages: urlsToVisit[href] });
}
try {
const response = await fetch(href, {
signal: AbortSignal.timeout(5000)
});

await request;
let statusCode = response.status;
if (statusCode && statusCode !== 200) {
statusCodes[statusCode] = statusCodes[statusCode] || [];
statusCodes[statusCode].push(href);
}
if (statusCode === 404) {
brokenLinks.push({ url: href, pages: urlsToVisit[href] });
}
} catch (e) {
// Network errors or timeouts won't have a status code
}
}

console.log('\n');
Expand Down
14 changes: 1 addition & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6124,17 +6124,6 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:^1.11.0":
version: 1.11.0
resolution: "axios@npm:1.11.0"
dependencies:
follow-redirects: "npm:^1.15.6"
form-data: "npm:^4.0.4"
proxy-from-env: "npm:^1.1.0"
checksum: 10c0/5de273d33d43058610e4d252f0963cc4f10714da0bfe872e8ef2cbc23c2c999acc300fd357b6bce0fc84a2ca9bd45740fa6bb28199ce2c1266c8b1a393f2b36e
languageName: node
linkType: hard

"axios@npm:^1.8.2":
version: 1.8.4
resolution: "axios@npm:1.8.4"
Expand Down Expand Up @@ -7630,7 +7619,6 @@ __metadata:
"@typescript-eslint/parser": "npm:^6.13.1"
ajv: "npm:^8.18.0"
aws-amplify: "npm:^6.16.2"
axios: "npm:^1.11.0"
cheerio: "npm:^1.0.0-rc.12"
classnames: "npm:^2.3.2"
cross-env: "npm:^7.0.3"
Expand Down Expand Up @@ -9000,7 +8988,7 @@ __metadata:
languageName: node
linkType: hard

"form-data@npm:^4.0.0, form-data@npm:^4.0.4":
"form-data@npm:^4.0.0":
version: 4.0.4
resolution: "form-data@npm:4.0.4"
dependencies:
Expand Down
Loading