diff --git a/viewer/scripts/link-checker.mjs b/viewer/scripts/link-checker.mjs index 7676708..8b074df 100644 --- a/viewer/scripts/link-checker.mjs +++ b/viewer/scripts/link-checker.mjs @@ -1,12 +1,13 @@ // this script checks if all the links in the json files are still reachable import { readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync, rmSync } from 'fs'; import axios from 'axios'; -import { join, dirname } from 'path'; +import { join, dirname, basename, extname } from 'path'; let counter = 0; let validFiles = 0; let invalidFiles = 0; const errorLog = {}; +const consolidatedErrors = {}; async function isLinkReachable(url, filePath, jsonPath) { try { @@ -27,6 +28,18 @@ async function isLinkReachable(url, filePath, jsonPath) { errorLog[filePath] = {}; } errorLog[filePath][jsonPath] = url; + + // Add to consolidated errors + const folderName = filePath.split('/')[1]; + const fileNameWithoutExt = basename(filePath, extname(filePath)); + if (!consolidatedErrors[folderName]) { + consolidatedErrors[folderName] = {}; + } + if (!consolidatedErrors[folderName][fileNameWithoutExt]) { + consolidatedErrors[folderName][fileNameWithoutExt] = {}; + } + consolidatedErrors[folderName][fileNameWithoutExt][jsonPath] = url; + return false; } } @@ -60,7 +73,7 @@ async function checkLinksInObject(obj, filePath, currentPath = '') { } async function validateFolder(folder) { - if(!existsSync(folder)) { + if (!existsSync(folder)) { return; } const files = readdirSync(folder); @@ -104,6 +117,7 @@ const folders = ['case-studies', 'wallets', 'dependencies']; } console.log('\nError Log:'); + console.log(errorLog); for (const [filePath, errors] of Object.entries(errorLog)) { const relativePath = filePath.replace('../', ''); const errorFilePath = join(errorsDir, relativePath); @@ -114,4 +128,7 @@ const folders = ['case-studies', 'wallets', 'dependencies']; } writeFileSync(errorFilePath, JSON.stringify(errors, null, 2)); } + + // Write all errors to a single errors.json file + writeFileSync(join(errorsDir, 'errors.json'), JSON.stringify(consolidatedErrors, null, 2)); })(); diff --git a/viewer/src/app/wallets/wallets-show/wallets-show.component.html b/viewer/src/app/wallets/wallets-show/wallets-show.component.html index 90c2de9..5de6405 100644 --- a/viewer/src/app/wallets/wallets-show/wallets-show.component.html +++ b/viewer/src/app/wallets/wallets-show/wallets-show.component.html @@ -35,6 +35,12 @@

{{ wallet.name }}

Share + @if(invalid) { +
+ warning +

Entry is not valid: {{ invalid }}

+
+ }
{{ wallet.name }}
Type
- {{ wallet.type }} + {{ wallet.type ?? 'unknown' }}
Capabilities
@@ -84,7 +90,7 @@

{{ wallet.name }}

Open Source
@if(!wallet.downloadSource) { - {{ wallet.openSource }} + {{ wallet.openSource ?? 'unknown' }} } @else {
{{ wallet.downloadSource diff --git a/viewer/src/app/wallets/wallets-show/wallets-show.component.ts b/viewer/src/app/wallets/wallets-show/wallets-show.component.ts index 397d6ba..612b615 100644 --- a/viewer/src/app/wallets/wallets-show/wallets-show.component.ts +++ b/viewer/src/app/wallets/wallets-show/wallets-show.component.ts @@ -45,6 +45,7 @@ export class WalletsShowComponent implements OnInit, OnDestroy { wallet?: Wallet; logoError = true; private routerSubscription?: Subscription; + invalid?: string; constructor( public walletsService: WalletsService, @@ -76,6 +77,7 @@ export class WalletsShowComponent implements OnInit, OnDestroy { .navigate(['/']) .then(() => this.snachBar.open(`${id} not found`)); } + this.invalid = await this.walletsService.validEntry(id); } getSupport(value?: string) { diff --git a/viewer/src/app/wallets/wallets.service.ts b/viewer/src/app/wallets/wallets.service.ts index 86c1990..402cc91 100644 --- a/viewer/src/app/wallets/wallets.service.ts +++ b/viewer/src/app/wallets/wallets.service.ts @@ -159,4 +159,22 @@ export class WalletsService { if (url.startsWith('http')) return url; return `assets/${url}`; } + + /** + * It will check the error branch of the repo where the error messages are located. + * @param id name of the wallet + */ + validEntry(id: string) { + return firstValueFrom( + this.httpClient.get>( + `https://raw.githubusercontent.com/openwallet-foundation/digital-wallet-and-agent-overviews-sig/refs/heads/errors/wallets/${id}.json` + ) + ) + .then((res) => + Object.keys(res) + .map((key) => `${key}: ${res[key]}`) + .join(', ') + ) + .catch(() => undefined); + } }