From f31b294a2df9819f4504c3d511d0276acc5a60ed Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 12:25:17 +0530 Subject: [PATCH 01/25] link verify redirect --- .github/scripts/detectRedirectCycle.ts | 4 ++++ .github/scripts/verifyRedirect.sh | 19 +++++++++++++++---- .github/workflows/deployExpensifyHelp.yml | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .github/scripts/detectRedirectCycle.ts diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts new file mode 100644 index 000000000000..d0d8ed4eb923 --- /dev/null +++ b/.github/scripts/detectRedirectCycle.ts @@ -0,0 +1,4 @@ +import fs from 'fs'; + +const docsDir = `${process.cwd()}/docs`; + diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh index 737d9bffacf9..b8942cd5b23d 100644 --- a/.github/scripts/verifyRedirect.sh +++ b/.github/scripts/verifyRedirect.sh @@ -5,11 +5,22 @@ declare -r REDIRECTS_FILE="docs/redirects.csv" +declare -r RED='\033[0;31m' +declare -r GREEN='\033[0;32m' +declare -r NC='\033[0m' + duplicates=$(awk -F, 'a[$1]++{print $1}' $REDIRECTS_FILE) +if [[ -n "$duplicates" ]]; then + echo "${RED}duplicate redirects are not allowed: $duplicates ${NC}" + exit 1 +fi -if [[ -z "$duplicates" ]]; then - exit 0 +npm run detectRedirectCycle +DETECT_CYCLE_EXIT_CODE=$? +if [[ DETECT_CYCLE_EXIT_CODE -eq 1 ]]; then + echo -e "${RED}The redirects.csv has a cycle. Please remove the redirect cycle because it will cause an infinite redirect loop ${NC}" + exit 1 fi -echo "duplicate redirects are not allowed: $duplicates" -exit 1 +echo -e "${GREEN}The redirects.csv is valid!${NC}" +exit 0 diff --git a/.github/workflows/deployExpensifyHelp.yml b/.github/workflows/deployExpensifyHelp.yml index 699bd379fb77..f16aab1caaa7 100644 --- a/.github/workflows/deployExpensifyHelp.yml +++ b/.github/workflows/deployExpensifyHelp.yml @@ -36,8 +36,8 @@ jobs: - name: Create docs routes file run: ./.github/scripts/createDocsRoutes.sh - - - name: Check duplicates in redirect.csv + + - name: Check duplicates in redirects.csv run: ./.github/scripts/verifyRedirect.sh - name: Build with Jekyll From 7b8f8b9fa1bd912224fc18497ef45f19ea19a198 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 12:43:15 +0530 Subject: [PATCH 02/25] add csv-parse dev dependency --- package-lock.json | 7 +++++++ package.json | 1 + 2 files changed, 8 insertions(+) diff --git a/package-lock.json b/package-lock.json index 64dd4fb0c885..fcce92f9d2f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -201,6 +201,7 @@ "concurrently": "^8.2.2", "copy-webpack-plugin": "^10.1.0", "css-loader": "^6.7.2", + "csv-parse": "^5.5.5", "diff-so-fancy": "^1.3.0", "dotenv": "^16.0.3", "electron": "^29.2.0", @@ -17740,6 +17741,12 @@ "version": "3.1.1", "license": "MIT" }, + "node_modules/csv-parse": { + "version": "5.5.5", + "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.5.5.tgz", + "integrity": "sha512-erCk7tyU3yLWAhk6wvKxnyPtftuy/6Ak622gOO7BCJ05+TYffnPCJF905wmOQm+BpkX54OdAl8pveJwUdpnCXQ==", + "dev": true + }, "node_modules/dag-map": { "version": "1.0.2", "license": "MIT" diff --git a/package.json b/package.json index 78e1a3a13e2c..fdcf786b52b1 100644 --- a/package.json +++ b/package.json @@ -252,6 +252,7 @@ "concurrently": "^8.2.2", "copy-webpack-plugin": "^10.1.0", "css-loader": "^6.7.2", + "csv-parse": "^5.5.5", "diff-so-fancy": "^1.3.0", "dotenv": "^16.0.3", "electron": "^29.2.0", From a640d416a5e36c4fdf2ddb89557b15886d111451 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 18:16:45 +0530 Subject: [PATCH 03/25] detect cycle in redirects.csv --- .github/scripts/detectRedirectCycle.ts | 57 +++++++++++++++++++++++++- package.json | 1 + 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index d0d8ed4eb923..90191f947162 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -1,4 +1,59 @@ +import {parse} from 'csv-parse'; import fs from 'fs'; -const docsDir = `${process.cwd()}/docs`; +const parser = parse({skip_empty_lines: true}); +const adjacencyList: any = {}; +function addEdge(source: string, target: string) { + if (!adjacencyList[source]) { + adjacencyList[source] = []; + } + adjacencyList[source].push(target); +} + +function isCyclic(currentNode: string, visited: Map, backEdges: Map): boolean { + visited.set(currentNode, true); + backEdges.set(currentNode, true); + + // Do a depth first search for all the neighbours. If a node is found in backedge, a cycle is detected. + const neighbours = adjacencyList[currentNode]; + if (neighbours) { + for (const node of neighbours) { + if (!visited.has(node)) { + if (isCyclic(node, visited, backEdges)) return true; + } else if (backEdges.has(node)) return true; + } + } + + backEdges.delete(currentNode); + + return false; +} + +function detectCycle() { + const visited: Map = new Map(); + const backEdges: Map = new Map(); + + for (let node in adjacencyList) { + if (visited.has(node)) { + continue; + } + if (isCyclic(node, visited, backEdges)) { + const cycle = Array.from(backEdges.keys()); + console.log(`Infinite redirect found in cycle: ${cycle.join(' -> ')} -> ${node}`); + return true; + } + } +} + +fs.createReadStream(`${process.cwd()}/docs/redirects.csv`) + .pipe(parser) + .on('data', async (row) => { + addEdge(row[0], row[1]); + }) + .on('end', async () => { + if (detectCycle()) { + process.exit(1); + } + process.exit(0); + }); diff --git a/package.json b/package.json index fdcf786b52b1..abf4376ab683 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "desktop-build": "scripts/build-desktop.sh production", "desktop-build-staging": "scripts/build-desktop.sh staging", "createDocsRoutes": "ts-node .github/scripts/createDocsRoutes.ts", + "detectRedirectCycle": "ts-node .github/scripts/detectRedirectCycle.ts", "desktop-build-adhoc": "scripts/build-desktop.sh adhoc", "ios-build": "fastlane ios build", "android-build": "fastlane android build", From 104e9e4b6185863a9f747b9988beac6cb49670d5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 18:24:30 +0530 Subject: [PATCH 04/25] remove the found cycle in redirects.csv --- .github/scripts/detectRedirectCycle.ts | 2 +- docs/redirects.csv | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index 90191f947162..d2e13f061eee 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -40,7 +40,7 @@ function detectCycle() { } if (isCyclic(node, visited, backEdges)) { const cycle = Array.from(backEdges.keys()); - console.log(`Infinite redirect found in cycle: ${cycle.join(' -> ')} -> ${node}`); + console.log(`Infinite redirect found in the cycle: ${cycle.join(' -> ')} -> ${node}`); return true; } } diff --git a/docs/redirects.csv b/docs/redirects.csv index af595ecc5f83..3f90265b5f6b 100644 --- a/docs/redirects.csv +++ b/docs/redirects.csv @@ -123,7 +123,6 @@ https://help.expensify.com/articles/expensify-classic/billing-and-subscriptions/ https://help.expensify.com/articles/expensify-classic/billing-and-subscriptions/Tax-Exempt,https://help.expensify.com/articles/expensify-classic/expensify-billing/Tax-Exempt https://help.expensify.com/articles/expensify-classic/copilots-and-delegates/Approving-Reports,https://help.expensify.com/expensify-classic/hubs/reports/ https://help.expensify.com/articles/expensify-classic/copilots-and-delegates/Invite-Members,https://help.expensify.com/articles/expensify-classic/workspaces/Invite-members-and-assign-roles -https://help.expensify.com/articles/expensify-classic/copilots-and-delegates/Removing-Members,https://help.expensify.com/articles/expensify-classic/copilots-and-delegates/Removing-Members https://help.expensify.com/articles/expensify-classic/expense-and-report-features/Attendee-Tracking,https://help.expensify.com/articles/expensify-classic/expenses/Track-group-expenses https://help.expensify.com/articles/expensify-classic/expense-and-report-features/Currency,https://help.expensify.com/articles/expensify-classic/workspaces/Currency https://help.expensify.com/articles/expensify-classic/expense-and-report-features/Expense-Rules,https://help.expensify.com/articles/expensify-classic/expenses/Expense-Rules From 6637db8498cca22940eea69f868bc0fd52095db6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 18:43:27 +0530 Subject: [PATCH 05/25] add redirects --- docs/redirects.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/redirects.csv b/docs/redirects.csv index 3f90265b5f6b..e442bd32fea9 100644 --- a/docs/redirects.csv +++ b/docs/redirects.csv @@ -157,3 +157,5 @@ https://help.expensify.com/articles/expensify-classic/workspaces/Budgets,https:/ https://help.expensify.com/articles/expensify-classic/workspaces/Categories,https://help.expensify.com/articles/expensify-classic/workspaces/Create-categories https://help.expensify.com/articles/expensify-classic/workspaces/Tags,https://help.expensify.com/articles/expensify-classic/workspaces/Create-tags https://help.expensify.com/expensify-classic/hubs/manage-employees-and-report-approvals,https://help.expensify.com/articles/expensify-classic/copilots-and-delegates/Approval-Workflows +https://help.expensify.com/articles/expensify-classic/reports/Report-Audit-Log-and-Comments,https://help.expensify.com/articles/expensify-classic/reports/Print-or-download-a-report +https://help.expensify.com/articles/expensify-classic/reports/The-Reports-Page,https://help.expensify.com/articles/expensify-classic/reports/Report-statuses From 26d8d5e74d1b7042f0f2dbca2c149e088687254c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 18:57:50 +0530 Subject: [PATCH 06/25] rm async --- .github/scripts/detectRedirectCycle.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index d2e13f061eee..cc4d147b5b20 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -48,10 +48,10 @@ function detectCycle() { fs.createReadStream(`${process.cwd()}/docs/redirects.csv`) .pipe(parser) - .on('data', async (row) => { + .on('data', (row) => { addEdge(row[0], row[1]); }) - .on('end', async () => { + .on('end', () => { if (detectCycle()) { process.exit(1); } From 22795da4f9897f7e3b72b685aad5475a2861d521 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 18:58:11 +0530 Subject: [PATCH 07/25] fix lint --- .github/scripts/detectRedirectCycle.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index cc4d147b5b20..a02021b3be55 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -20,8 +20,12 @@ function isCyclic(currentNode: string, visited: Map, backEdges: if (neighbours) { for (const node of neighbours) { if (!visited.has(node)) { - if (isCyclic(node, visited, backEdges)) return true; - } else if (backEdges.has(node)) return true; + if (isCyclic(node, visited, backEdges)) { + return true; + } + } else if (backEdges.has(node)) { + return true; + } } } From 1972309453d77826d7de1aca81a1a5b053e9a85f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 18:59:12 +0530 Subject: [PATCH 08/25] fix lint --- .github/scripts/detectRedirectCycle.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index a02021b3be55..b4dabaac110f 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -39,13 +39,12 @@ function detectCycle() { const backEdges: Map = new Map(); for (let node in adjacencyList) { - if (visited.has(node)) { - continue; - } - if (isCyclic(node, visited, backEdges)) { - const cycle = Array.from(backEdges.keys()); - console.log(`Infinite redirect found in the cycle: ${cycle.join(' -> ')} -> ${node}`); - return true; + if (!visited.has(node)) { + if (isCyclic(node, visited, backEdges)) { + const cycle = Array.from(backEdges.keys()); + console.log(`Infinite redirect found in the cycle: ${cycle.join(' -> ')} -> ${node}`); + return true; + } } } } From 32c569cae4726fe5d7fe3aec4f159812e4e82ccc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 18:59:51 +0530 Subject: [PATCH 09/25] fix lint --- .github/scripts/detectRedirectCycle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index b4dabaac110f..fdce5b4f080a 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -38,7 +38,7 @@ function detectCycle() { const visited: Map = new Map(); const backEdges: Map = new Map(); - for (let node in adjacencyList) { + for (const node in adjacencyList) { if (!visited.has(node)) { if (isCyclic(node, visited, backEdges)) { const cycle = Array.from(backEdges.keys()); From 22075e5cbbb79852a8e522543c4c4ab9be34dd6d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:02:02 +0530 Subject: [PATCH 10/25] fix type --- .github/scripts/detectRedirectCycle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index fdce5b4f080a..28474ce21ab1 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -2,7 +2,7 @@ import {parse} from 'csv-parse'; import fs from 'fs'; const parser = parse({skip_empty_lines: true}); -const adjacencyList: any = {}; +const adjacencyList: Record> = {}; function addEdge(source: string, target: string) { if (!adjacencyList[source]) { From 033e6c0aa4d1d999b1007254833a8d33a89056a6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:03:07 +0530 Subject: [PATCH 11/25] fix type --- .github/scripts/detectRedirectCycle.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index 28474ce21ab1..97a49d131604 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -34,7 +34,7 @@ function isCyclic(currentNode: string, visited: Map, backEdges: return false; } -function detectCycle() { +function detectCycle(): boolean { const visited: Map = new Map(); const backEdges: Map = new Map(); @@ -47,6 +47,7 @@ function detectCycle() { } } } + return false; } fs.createReadStream(`${process.cwd()}/docs/redirects.csv`) From e430bb08514459e484f313cb182ca5647bf2d717 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:10:33 +0530 Subject: [PATCH 12/25] fix lint --- .github/scripts/detectRedirectCycle.ts | 5 +++-- .github/workflows/deployExpensifyHelp.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index 97a49d131604..ab526d598fef 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -2,7 +2,7 @@ import {parse} from 'csv-parse'; import fs from 'fs'; const parser = parse({skip_empty_lines: true}); -const adjacencyList: Record> = {}; +const adjacencyList: Record = {}; function addEdge(source: string, target: string) { if (!adjacencyList[source]) { @@ -38,7 +38,7 @@ function detectCycle(): boolean { const visited: Map = new Map(); const backEdges: Map = new Map(); - for (const node in adjacencyList) { + for (const [node, _] of Object.entries(adjacencyList)) { if (!visited.has(node)) { if (isCyclic(node, visited, backEdges)) { const cycle = Array.from(backEdges.keys()); @@ -53,6 +53,7 @@ function detectCycle(): boolean { fs.createReadStream(`${process.cwd()}/docs/redirects.csv`) .pipe(parser) .on('data', (row) => { + // Create a directed graph of sourceURL -> targetURL addEdge(row[0], row[1]); }) .on('end', () => { diff --git a/.github/workflows/deployExpensifyHelp.yml b/.github/workflows/deployExpensifyHelp.yml index f16aab1caaa7..f7f826d66f9b 100644 --- a/.github/workflows/deployExpensifyHelp.yml +++ b/.github/workflows/deployExpensifyHelp.yml @@ -37,7 +37,7 @@ jobs: - name: Create docs routes file run: ./.github/scripts/createDocsRoutes.sh - - name: Check duplicates in redirects.csv + - name: Check for duplicates and cycles in redirects.csv run: ./.github/scripts/verifyRedirect.sh - name: Build with Jekyll From 458bc3503cf12ae8bfea7e55e7562ff8d40080f2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:11:24 +0530 Subject: [PATCH 13/25] fix lint --- .github/scripts/detectRedirectCycle.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index ab526d598fef..d78358271261 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -1,6 +1,7 @@ import {parse} from 'csv-parse'; import fs from 'fs'; +// eslint-disable-next-line @typescript-eslint/naming-convention const parser = parse({skip_empty_lines: true}); const adjacencyList: Record = {}; From 08ee70495cbad141e2d5657c32f2ecae96c8e9cd Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:15:14 +0530 Subject: [PATCH 14/25] make script executable --- .github/scripts/verifyRedirect.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh index b8942cd5b23d..3a687391b394 100644 --- a/.github/scripts/verifyRedirect.sh +++ b/.github/scripts/verifyRedirect.sh @@ -24,3 +24,4 @@ fi echo -e "${GREEN}The redirects.csv is valid!${NC}" exit 0 + From da441105403dd6167d63216527e97f5100d0f7e3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:19:51 +0530 Subject: [PATCH 15/25] debug: --- .github/scripts/verifyRedirect.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh index 3a687391b394..79f8f25f3cac 100644 --- a/.github/scripts/verifyRedirect.sh +++ b/.github/scripts/verifyRedirect.sh @@ -9,11 +9,11 @@ declare -r RED='\033[0;31m' declare -r GREEN='\033[0;32m' declare -r NC='\033[0m' -duplicates=$(awk -F, 'a[$1]++{print $1}' $REDIRECTS_FILE) -if [[ -n "$duplicates" ]]; then - echo "${RED}duplicate redirects are not allowed: $duplicates ${NC}" - exit 1 -fi +# duplicates=$(awk -F, 'a[$1]++{print $1}' $REDIRECTS_FILE) +# if [[ -n "$duplicates" ]]; then +# echo "${RED}duplicate redirects are not allowed: $duplicates ${NC}" +# exit 1 +# fi npm run detectRedirectCycle DETECT_CYCLE_EXIT_CODE=$? @@ -24,4 +24,3 @@ fi echo -e "${GREEN}The redirects.csv is valid!${NC}" exit 0 - From bfe2096162498b6835fe8bc9181e9649c25530b1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:21:48 +0530 Subject: [PATCH 16/25] debug: --- .github/scripts/verifyRedirect.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh index 79f8f25f3cac..dfe9492b2112 100644 --- a/.github/scripts/verifyRedirect.sh +++ b/.github/scripts/verifyRedirect.sh @@ -15,12 +15,12 @@ declare -r NC='\033[0m' # exit 1 # fi -npm run detectRedirectCycle -DETECT_CYCLE_EXIT_CODE=$? -if [[ DETECT_CYCLE_EXIT_CODE -eq 1 ]]; then - echo -e "${RED}The redirects.csv has a cycle. Please remove the redirect cycle because it will cause an infinite redirect loop ${NC}" - exit 1 -fi +# npm run detectRedirectCycle +# DETECT_CYCLE_EXIT_CODE=$? +# if [[ DETECT_CYCLE_EXIT_CODE -eq 1 ]]; then +# echo -e "${RED}The redirects.csv has a cycle. Please remove the redirect cycle because it will cause an infinite redirect loop ${NC}" +# exit 1 +# fi echo -e "${GREEN}The redirects.csv is valid!${NC}" exit 0 From 0232f44c4abcf3a4843ab8c811e6ee402ea111df Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:25:51 +0530 Subject: [PATCH 17/25] provide permission --- .github/scripts/detectRedirectCycle.ts | 0 .github/scripts/verifyRedirect.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/scripts/detectRedirectCycle.ts mode change 100644 => 100755 .github/scripts/verifyRedirect.sh diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts old mode 100644 new mode 100755 diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh old mode 100644 new mode 100755 From 409b1c1c215fb1c16e5c0a075b834cccbebf1f71 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:26:27 +0530 Subject: [PATCH 18/25] provide permission --- .github/scripts/detectRedirectCycle.ts | 0 .github/scripts/verifyRedirect.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 .github/scripts/detectRedirectCycle.ts mode change 100755 => 100644 .github/scripts/verifyRedirect.sh diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts old mode 100755 new mode 100644 diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh old mode 100755 new mode 100644 From eb6c38eda2b01f3fd1704a0eaf6280639a3631bf Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:28:49 +0530 Subject: [PATCH 19/25] delete file --- .github/scripts/verifyRedirect.sh | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/scripts/verifyRedirect.sh diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh deleted file mode 100644 index dfe9492b2112..000000000000 --- a/.github/scripts/verifyRedirect.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# HelpDot - Verifies that redirects.csv does not have any duplicates -# Duplicate sourceURLs break redirection on cloudflare pages - -declare -r REDIRECTS_FILE="docs/redirects.csv" - -declare -r RED='\033[0;31m' -declare -r GREEN='\033[0;32m' -declare -r NC='\033[0m' - -# duplicates=$(awk -F, 'a[$1]++{print $1}' $REDIRECTS_FILE) -# if [[ -n "$duplicates" ]]; then -# echo "${RED}duplicate redirects are not allowed: $duplicates ${NC}" -# exit 1 -# fi - -# npm run detectRedirectCycle -# DETECT_CYCLE_EXIT_CODE=$? -# if [[ DETECT_CYCLE_EXIT_CODE -eq 1 ]]; then -# echo -e "${RED}The redirects.csv has a cycle. Please remove the redirect cycle because it will cause an infinite redirect loop ${NC}" -# exit 1 -# fi - -echo -e "${GREEN}The redirects.csv is valid!${NC}" -exit 0 From 08e2545fb1ef2008d4c2e3caf44334cfd598b12a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:30:58 +0530 Subject: [PATCH 20/25] add file as executable --- .github/scripts/verifyRedirect.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 .github/scripts/verifyRedirect.sh diff --git a/.github/scripts/verifyRedirect.sh b/.github/scripts/verifyRedirect.sh new file mode 100755 index 000000000000..b8942cd5b23d --- /dev/null +++ b/.github/scripts/verifyRedirect.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# HelpDot - Verifies that redirects.csv does not have any duplicates +# Duplicate sourceURLs break redirection on cloudflare pages + +declare -r REDIRECTS_FILE="docs/redirects.csv" + +declare -r RED='\033[0;31m' +declare -r GREEN='\033[0;32m' +declare -r NC='\033[0m' + +duplicates=$(awk -F, 'a[$1]++{print $1}' $REDIRECTS_FILE) +if [[ -n "$duplicates" ]]; then + echo "${RED}duplicate redirects are not allowed: $duplicates ${NC}" + exit 1 +fi + +npm run detectRedirectCycle +DETECT_CYCLE_EXIT_CODE=$? +if [[ DETECT_CYCLE_EXIT_CODE -eq 1 ]]; then + echo -e "${RED}The redirects.csv has a cycle. Please remove the redirect cycle because it will cause an infinite redirect loop ${NC}" + exit 1 +fi + +echo -e "${GREEN}The redirects.csv is valid!${NC}" +exit 0 From 2b5015fd36b39668a8ee15f0319e0c53bfb53eeb Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:45:06 +0530 Subject: [PATCH 21/25] fix lint --- .github/scripts/detectRedirectCycle.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index d78358271261..220f59f9c170 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -1,8 +1,10 @@ import {parse} from 'csv-parse'; import fs from 'fs'; -// eslint-disable-next-line @typescript-eslint/naming-convention -const parser = parse({skip_empty_lines: true}); +const parser = parse({ + // eslint-disable-next-line @typescript-eslint/naming-convention + skip_empty_lines: true, +}); const adjacencyList: Record = {}; function addEdge(source: string, target: string) { @@ -39,7 +41,7 @@ function detectCycle(): boolean { const visited: Map = new Map(); const backEdges: Map = new Map(); - for (const [node, _] of Object.entries(adjacencyList)) { + for (const [node] of Object.entries(adjacencyList)) { if (!visited.has(node)) { if (isCyclic(node, visited, backEdges)) { const cycle = Array.from(backEdges.keys()); From 3295539764f4c8a8b93172c02b9f1d1f19b8771f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:46:35 +0530 Subject: [PATCH 22/25] fix lint --- .github/scripts/detectRedirectCycle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index 220f59f9c170..3443ad746709 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -2,7 +2,7 @@ import {parse} from 'csv-parse'; import fs from 'fs'; const parser = parse({ - // eslint-disable-next-line @typescript-eslint/naming-convention + // eslint-disable-next-line @typescript-eslint/camelcase skip_empty_lines: true, }); const adjacencyList: Record = {}; From 1f2abbd03c82e00a6a965b2366d81103de124eb0 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 18 Apr 2024 19:56:21 +0530 Subject: [PATCH 23/25] remove: skip empty lines --- .github/scripts/detectRedirectCycle.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index 3443ad746709..9df86d28fc6f 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -1,10 +1,7 @@ import {parse} from 'csv-parse'; import fs from 'fs'; -const parser = parse({ - // eslint-disable-next-line @typescript-eslint/camelcase - skip_empty_lines: true, -}); +const parser = parse(); const adjacencyList: Record = {}; function addEdge(source: string, target: string) { From 188b68d0334dd2d2461bfd8d30e01cbf0563d2cd Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 19 Apr 2024 19:25:41 +0530 Subject: [PATCH 24/25] use global vars --- .github/scripts/detectRedirectCycle.ts | 12 ++++++------ docs/redirects.csv | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/scripts/detectRedirectCycle.ts b/.github/scripts/detectRedirectCycle.ts index 9df86d28fc6f..5aa0d1daf342 100644 --- a/.github/scripts/detectRedirectCycle.ts +++ b/.github/scripts/detectRedirectCycle.ts @@ -2,7 +2,10 @@ import {parse} from 'csv-parse'; import fs from 'fs'; const parser = parse(); + const adjacencyList: Record = {}; +const visited: Map = new Map(); +const backEdges: Map = new Map(); function addEdge(source: string, target: string) { if (!adjacencyList[source]) { @@ -11,7 +14,7 @@ function addEdge(source: string, target: string) { adjacencyList[source].push(target); } -function isCyclic(currentNode: string, visited: Map, backEdges: Map): boolean { +function isCyclic(currentNode: string): boolean { visited.set(currentNode, true); backEdges.set(currentNode, true); @@ -20,7 +23,7 @@ function isCyclic(currentNode: string, visited: Map, backEdges: if (neighbours) { for (const node of neighbours) { if (!visited.has(node)) { - if (isCyclic(node, visited, backEdges)) { + if (isCyclic(node)) { return true; } } else if (backEdges.has(node)) { @@ -35,12 +38,9 @@ function isCyclic(currentNode: string, visited: Map, backEdges: } function detectCycle(): boolean { - const visited: Map = new Map(); - const backEdges: Map = new Map(); - for (const [node] of Object.entries(adjacencyList)) { if (!visited.has(node)) { - if (isCyclic(node, visited, backEdges)) { + if (isCyclic(node)) { const cycle = Array.from(backEdges.keys()); console.log(`Infinite redirect found in the cycle: ${cycle.join(' -> ')} -> ${node}`); return true; diff --git a/docs/redirects.csv b/docs/redirects.csv index e442bd32fea9..95404c2326a0 100644 --- a/docs/redirects.csv +++ b/docs/redirects.csv @@ -87,6 +87,7 @@ https://help.expensify.com/articles/new-expensify/payments/Request-Money,https:/ https://help.expensify.com/articles/expensify-classic/workspace-and-domain-settings/tax-tracking,https://help.expensify.com/articles/expensify-classic/expenses/expenses/Apply-Tax https://help.expensify.com/articles/expensify-classic/copilots-and-delegates/User-Roles.html,https://help.expensify.com/expensify-classic/hubs/copilots-and-delegates/ https://help.expensify.com/articles/expensify-classic/expensify-billing/Billing-Owner,https://help.expensify.com/articles/expensify-classic/workspaces/Assign-billing-owner-and-payment-account +https://help.expensify.com/articles/expensify-classic/expensify-billing/Billing-Owner.html,https://help.expensify.com/articles/expensify-classic/workspaces/Assign-billing-owner-and-payment-account https://help.expensify.com/articles/expensify-classic/insights-and-custom-reporting/Other-Export-Options.html,https://help.expensify.com/articles/expensify-classic/spending-insights/Other-Export-Options https://help.expensify.com/articles/expensify-classic/bank-accounts-and-credit-cards/business-bank-accounts/Business-Bank-Accounts-AUD,https://help.expensify.com/articles/expensify-classic/connect-credit-cards/Global-Reimbursements https://help.expensify.com/expensify-classic/hubs/bank-accounts-and-credit-cards,https://help.expensify.com/expensify-classic/hubs/ From 307508e80c7da31314ed04b52096b7e56fdc07da Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 19 Apr 2024 20:03:31 +0530 Subject: [PATCH 25/25] remove .html from sitemap urls for google search --- docs/sitemap.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 8b911fa849cd..b224296ed75a 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -6,7 +6,7 @@ layout: {% assign pages = site.html_pages | where_exp:'doc','doc.sitemap != false' | where_exp:'doc','doc.url != "/404.html"' %} {% for page in pages %} - {{ page.url | replace:'/index.html','/' | absolute_url | xml_escape }} + {{ page.url | replace:'/index.html','/' | absolute_url | xml_escape | replace:'.html','' }} {% endfor %} \ No newline at end of file