Commit 122bb0fc43

122bb0fc43355846a5b0f5677d6fc579009d40bd

parent: 11542c9372

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-02-28 17:07 UTC

Fixes web build, update github info fetch logic, adds build error log

Layout: unified · split

web/astro.config.mjs +9 −1
@@ -4,6 +4,7 @@ import { defineConfig } from 'astro/config';
4import svelte from '@astrojs/svelte'; 4import svelte from '@astrojs/svelte';
5import partytown from '@astrojs/partytown'; 5import partytown from '@astrojs/partytown';
6import sitemap from '@astrojs/sitemap'; 6import sitemap from '@astrojs/sitemap';
7import { printSummary } from './src/utils/logger.ts';
7 8
8// Adapters 9// Adapters
9import vercelAdapter from '@astrojs/vercel/serverless'; 10import vercelAdapter from '@astrojs/vercel/serverless';
@@ -21,7 +22,14 @@ const output = import.meta.env.OUTPUT || 'hybrid';
21const site = import.meta.env.SITE_URL || 'https://awesome-privacy.xyz'; 22const site = import.meta.env.SITE_URL || 'https://awesome-privacy.xyz';
22 23
23// Initialize Astro integrations 24// Initialize Astro integrations
24const integrations = [svelte(), partytown(), sitemap()]; 25const buildLogger = {
26 name: 'build-logger',
27 hooks: {
28 'astro:build:done': () => printSummary(),
29 },
30};
31
32const integrations = [svelte(), partytown(), sitemap(), buildLogger];
25 33
26// Set the appropriate adapter, based on the deploy target 34// Set the appropriate adapter, based on the deploy target
27const adapter = { 35const adapter = {
web/src/components/things/ItemGitHubMetrics.astro +3 −2
@@ -1,5 +1,6 @@
1--- 1---
2import FontAwesome from "@components/form/FontAwesome.svelte"; 2import FontAwesome from "@components/form/FontAwesome.svelte";
3import { error } from "@utils/logger";
3const { github } = Astro.props; 4const { github } = Astro.props;
4 5
5interface GitHubRepoData { 6interface GitHubRepoData {
@@ -29,7 +30,7 @@ const fetchGitHubData = async (repo: string) => {
29 const response = await fetch(`https://api.github.com/repos/${repo}`, { 30 const response = await fetch(`https://api.github.com/repos/${repo}`, {
30 headers: headers, 31 headers: headers,
31 }).catch((e) => { 32 }).catch((e) => {
32 console.error(`Network error: ${e.message}`); 33 error('GitHub API', `Network error for ${repo}: ${e.message}`);
33 // Return a placeholder response to handle this gracefully 34 // Return a placeholder response to handle this gracefully
34 return null; 35 return null;
35 }); 36 });
@@ -45,7 +46,7 @@ const fetchGitHubData = async (repo: string) => {
45 if (response.ok) { 46 if (response.ok) {
46 data = await response.json(); 47 data = await response.json();
47 } else { 48 } else {
48 console.error(`HTTP error: Received status code ${response.status}`); 49 error('GitHub API', `HTTP ${response.status} for ${repo}`);
49 } 50 }
50 51
51 return { data, statusCode }; 52 return { data, statusCode };
web/src/utils/fetch-android-info.ts +10 −3
@@ -1,3 +1,5 @@
1import { error } from './logger';
2
1const doubleCheckPackageName = (packageStr: string) => { 3const doubleCheckPackageName = (packageStr: string) => {
2 return packageStr.includes('id=') ? packageStr.split('id=')[1] : packageStr; 4 return packageStr.includes('id=') ? packageStr.split('id=')[1] : packageStr;
3}; 5};
@@ -7,9 +9,14 @@ export const fetchAndroidInfo = async (
7): Promise<AndroidInfo | null> => { 9): Promise<AndroidInfo | null> => {
8 const endpoint = `https://android-app-privacy.as93.net/${doubleCheckPackageName(androidPackage)}`; 10 const endpoint = `https://android-app-privacy.as93.net/${doubleCheckPackageName(androidPackage)}`;
9 try { 11 try {
10 return await fetch(endpoint).then((res) => res.json()); 12 const res = await fetch(endpoint);
11 } catch (error) { 13 if (!res.ok) {
12 console.error('Error fetching android data:', error); 14 error('Android', `HTTP ${res.status} for ${androidPackage} (${endpoint})`);
15 return null;
16 }
17 return await res.json();
18 } catch (err) {
19 error('Android', `Network error for ${androidPackage}: ${err}`);
13 return null; 20 return null;
14 } 21 }
15}; 22};
web/src/utils/fetch-data.ts +13 −4
@@ -1,4 +1,5 @@
1import yaml from 'js-yaml'; 1import yaml from 'js-yaml';
2import { error } from './logger';
2 3
3import type { AwesomePrivacy } from '../types/Service'; 4import type { AwesomePrivacy } from '../types/Service';
4 5
@@ -6,10 +7,18 @@ const awesomePrivacyData =
6 'https://raw.githubusercontent.com/Lissy93/awesome-privacy/main/awesome-privacy.yml'; 7 'https://raw.githubusercontent.com/Lissy93/awesome-privacy/main/awesome-privacy.yml';
7 8
8export const fetchData = async (): Promise<AwesomePrivacy> => { 9export const fetchData = async (): Promise<AwesomePrivacy> => {
9 return (await fetch(awesomePrivacyData) 10 try {
10 .then((res) => res.text()) 11 const res = await fetch(awesomePrivacyData);
11 .then((data) => yaml.load(data)) 12 if (!res.ok) {
12 .catch((err) => console.error('ah crap', err))) as AwesomePrivacy; 13 error('Data', `HTTP ${res.status} fetching awesome-privacy.yml (${awesomePrivacyData})`);
14 return {} as AwesomePrivacy;
15 }
16 const text = await res.text();
17 return yaml.load(text) as AwesomePrivacy;
18 } catch (err) {
19 error('Data', `Failed to fetch awesome-privacy.yml: ${err}`);
20 return {} as AwesomePrivacy;
21 }
13}; 22};
14 23
15export const slugify = (title: string) => { 24export const slugify = (title: string) => {
web/src/utils/fetch-discord-info.ts +10 −3
@@ -1,11 +1,18 @@
1import { error } from './logger';
2
1export const fetchDiscordInfo = async ( 3export const fetchDiscordInfo = async (
2 discordInvite: string, 4 discordInvite: string,
3): Promise<DiscordInfo | null> => { 5): Promise<DiscordInfo | null> => {
4 const endpoint = `https://discord-invite-info.as93.net/${discordInvite}`; 6 const endpoint = `https://discord-invite-info.as93.net/${discordInvite}`;
5 try { 7 try {
6 return await fetch(endpoint).then((res) => res.json()); 8 const res = await fetch(endpoint);
7 } catch (error) { 9 if (!res.ok) {
8 console.error('Error fetching discord data:', error); 10 error('Discord', `HTTP ${res.status} for ${discordInvite} (${endpoint})`);
11 return null;
12 }
13 return await res.json();
14 } catch (err) {
15 error('Discord', `Network error for ${discordInvite}: ${err}`);
9 return null; 16 return null;
10 } 17 }
11}; 18};
web/src/utils/fetch-docker-instructions.ts +10 −3
@@ -1,11 +1,18 @@
1import { error } from './logger';
2
1export const fetchDockerData = async ( 3export const fetchDockerData = async (
2 serviceName: string, 4 serviceName: string,
3): Promise<TemplateResponse | null> => { 5): Promise<TemplateResponse | null> => {
4 const endpoint = `https://docker-info.as93.workers.dev/${serviceName}`; 6 const endpoint = `https://docker-info.as93.workers.dev/${serviceName}`;
5 try { 7 try {
6 return await fetch(endpoint).then((res) => res.json()); 8 const res = await fetch(endpoint);
7 } catch (error) { 9 if (!res.ok) {
8 console.error('Error fetching docker data:', error); 10 error('Docker', `HTTP ${res.status} for ${serviceName} (${endpoint})`);
11 return null;
12 }
13 return await res.json();
14 } catch (err) {
15 error('Docker', `Network error for ${serviceName}: ${err}`);
9 return null; 16 return null;
10 } 17 }
11}; 18};
web/src/utils/fetch-ios-info.ts +10 −3
@@ -1,11 +1,18 @@
1import { error } from './logger';
2
1export const fetchIosInfo = async ( 3export const fetchIosInfo = async (
2 iosUrl: string, 4 iosUrl: string,
3): Promise<IoSApiResponse | null> => { 5): Promise<IoSApiResponse | null> => {
4 const endpoint = `https://ios-app-info.as93.net?appStoreUrl=${iosUrl}`; 6 const endpoint = `https://ios-app-info.as93.net?appStoreUrl=${iosUrl}`;
5 try { 7 try {
6 return await fetch(endpoint).then((res) => res.json()); 8 const res = await fetch(endpoint);
7 } catch (error) { 9 if (!res.ok) {
8 console.error('Error fetching ios info:', error); 10 error('iOS', `HTTP ${res.status} for ${iosUrl} (${endpoint})`);
11 return null;
12 }
13 return await res.json();
14 } catch (err) {
15 error('iOS', `Network error for ${iosUrl}: ${err}`);
9 return null; 16 return null;
10 } 17 }
11}; 18};
web/src/utils/fetch-privacy-policy.ts +10 −3
@@ -1,11 +1,18 @@
1import { error } from './logger';
2
1export const fetchTosdrPrivacy = async ( 3export const fetchTosdrPrivacy = async (
2 serviceId: string, 4 serviceId: string,
3): Promise<PrivacyPolicyResponse | null> => { 5): Promise<PrivacyPolicyResponse | null> => {
4 const endpoint = `https://privacy-policies.as93.workers.dev/${serviceId}`; 6 const endpoint = `https://privacy-policies.as93.workers.dev/${serviceId}`;
5 try { 7 try {
6 return await fetch(endpoint).then((res) => res.json()); 8 const res = await fetch(endpoint);
7 } catch (error) { 9 if (!res.ok) {
8 console.error('Error fetching privacy policy data:', error); 10 error('ToS;DR', `HTTP ${res.status} for service ${serviceId} (${endpoint})`);
11 return null;
12 }
13 return await res.json();
14 } catch (err) {
15 error('ToS;DR', `Network error for service ${serviceId}: ${err}`);
9 return null; 16 return null;
10 } 17 }
11}; 18};
web/src/utils/fetch-reddit-info.ts +10 −3
@@ -1,11 +1,18 @@
1import { error } from './logger';
2
1export const fetchRedditInfo = async ( 3export const fetchRedditInfo = async (
2 subreddit: string, 4 subreddit: string,
3): Promise<RedditData | null> => { 5): Promise<RedditData | null> => {
4 const endpoint = `https://subreddit-info.as93.net/${subreddit}`; 6 const endpoint = `https://subreddit-info.as93.net/${subreddit}`;
5 try { 7 try {
6 return await fetch(endpoint).then((res) => res.json()); 8 const res = await fetch(endpoint);
7 } catch (error) { 9 if (!res.ok) {
8 console.error('Error fetching reddit data:', error); 10 error('Reddit', `HTTP ${res.status} for r/${subreddit} (${endpoint})`);
11 return null;
12 }
13 return await res.json();
14 } catch (err) {
15 error('Reddit', `Network error for r/${subreddit}: ${err}`);
9 return null; 16 return null;
10 } 17 }
11}; 18};
web/src/utils/fetch-repo-info.ts +96 −17
@@ -1,17 +1,107 @@
1import { error } from './logger';
2
3const githubHeaders = (): Record<string, string> => {
4 const headers: Record<string, string> = {
5 'User-Agent': 'awesome-privacy',
6 'Accept': 'application/vnd.github.v3+json',
7 };
8 const token = import.meta.env.GITHUB_API_KEY;
9 if (token) headers['Authorization'] = `token ${token}`;
10 return headers;
11};
12
13const fetchFromGitHub = async (github: string): Promise<GitHubStatsResponse | null> => {
14 const base = `https://api.github.com/repos/${github}`;
15 const headers = githubHeaders();
16
17 const [infoRes, langsRes, tagsRes, contribRes, commitsRes] = await Promise.all([
18 fetch(base, { headers }),
19 fetch(`${base}/languages`, { headers }),
20 fetch(`${base}/tags`, { headers }),
21 fetch(`${base}/contributors`, { headers }),
22 fetch(`${base}/commits`, { headers }),
23 ]);
24
25 if (!infoRes.ok) {
26 error('GitHub Stats', `GitHub API returned ${infoRes.status} for ${github}`);
27 return null;
28 }
29
30 const parseJson = (r: Response) =>
31 r.ok && r.status !== 204 ? r.json() : null;
32
33 const [info, languages, tags, contributors, commits] = await Promise.all(
34 [infoRes, langsRes, tagsRes, contribRes, commitsRes].map(parseJson),
35 );
36
37 return {
38 info: {
39 ownerUsername: info.owner?.login ?? '',
40 ownerAvatar: info.owner?.avatar_url ?? '',
41 description: info.description ?? '',
42 url: info.html_url ?? '',
43 homepage: info.homepage ?? '',
44 language: info.language ?? '',
45 topics: info.topics ?? [],
46 license: info.license?.spdx_id ?? '',
47 isFork: info.fork ?? false,
48 isArchived: info.archived ?? false,
49 createdAt: info.created_at ?? '',
50 updatedAt: info.updated_at ?? '',
51 size: info.size ?? 0,
52 scarCount: info.stargazers_count ?? 0,
53 forksCount: info.forks_count ?? 0,
54 watchersCount: info.watchers_count ?? 0,
55 },
56 languages: languages ?? {},
57 versions: (tags ?? []).map((tag: any) => ({
58 name: tag.name,
59 commit: tag.commit?.sha ?? '',
60 zipball: tag.zipball_url ?? '',
61 tarball: tag.tarball_url ?? '',
62 })),
63 contributors: (contributors ?? []).map((c: any) => ({
64 username: c.login ?? '',
65 avatar: c.avatar_url ?? '',
66 contributions: c.contributions ?? 0,
67 })),
68 commits: (commits ?? []).map((c: any) => ({
69 sha: c.sha ?? '',
70 authorName: c.commit?.author?.name ?? '',
71 authorDate: c.commit?.author?.date ?? '',
72 message: c.commit?.message ?? '',
73 authorUsername: c.author?.login ?? '',
74 authorAvatar: c.author?.avatar_url ?? '',
75 })),
76 };
77};
78
79const fetchFromWorker = async (github: string): Promise<GitHubStatsResponse | null> => {
80 const res = await fetch(`https://repo-info.as93.workers.dev/${github}`);
81 if (!res.ok) return null;
82 return res.json();
83};
84
1export const fetchGitHubStats = async ( 85export const fetchGitHubStats = async (
2 github: string, 86 github: string,
3): Promise<GitHubStatsResponse | null> => { 87): Promise<GitHubStatsResponse | null> => {
4 const endpoint = `https://repo-info.as93.workers.dev/${github}`;
5 try { 88 try {
6 return await fetch(endpoint).then((res) => res.json()); 89 const result = await fetchFromGitHub(github);
7 } catch (error) { 90 if (result) return result;
8 console.error('Error fetching GitHub stats:', error); 91 const fallback = await fetchFromWorker(github);
92 if (fallback) return fallback;
93 error('GitHub Stats', `Both direct API and worker failed for ${github}`);
9 return null; 94 return null;
95 } catch (err) {
96 try {
97 return await fetchFromWorker(github);
98 } catch {
99 error('GitHub Stats', `All fetches failed for ${github}: ${err}`);
100 return null;
101 }
10 } 102 }
11}; 103};
12 104
13// fetch(`https://repo-info.as93.workers.dev/${github}`).then((res) => res.json());
14
15export interface GitHubStatsResponse { 105export interface GitHubStatsResponse {
16 info: { 106 info: {
17 ownerUsername: string; 107 ownerUsername: string;
@@ -34,17 +124,6 @@ export interface GitHubStatsResponse {
34 languages: { 124 languages: {
35 [key: string]: number; 125 [key: string]: number;
36 }; 126 };
37 updates: Array<{
38 type: string;
39 actor: {
40 username: string;
41 avatar: string;
42 };
43 repo: string;
44 action: string;
45 createdAt: string;
46 number?: number;
47 }>;
48 versions: Array<{ 127 versions: Array<{
49 name: string; 128 name: string;
50 commit: string; 129 commit: string;
web/src/utils/fetch-website-info.ts +10 −3
@@ -1,11 +1,18 @@
1import { error } from './logger';
2
1export const fetchWebsiteInfo = async ( 3export const fetchWebsiteInfo = async (
2 url: string, 4 url: string,
3): Promise<WebsiteData | null> => { 5): Promise<WebsiteData | null> => {
4 const endpoint = `https://site-info-fetch.as93.workers.dev/?url=${url}`; 6 const endpoint = `https://site-info-fetch.as93.workers.dev/?url=${url}`;
5 try { 7 try {
6 return await fetch(endpoint).then((res) => res.json()); 8 const res = await fetch(endpoint);
7 } catch (error) { 9 if (!res.ok) {
8 console.error('Error fetching website info:', error); 10 error('Website', `HTTP ${res.status} for ${url} (${endpoint})`);
11 return null;
12 }
13 return await res.json();
14 } catch (err) {
15 error('Website', `Network error for ${url}: ${err}`);
9 return null; 16 return null;
10 } 17 }
11}; 18};
web/src/utils/logger.ts added +48
@@ -0,0 +1,48 @@
1type Level = 'warn' | 'error';
2
3interface LogEntry {
4 level: Level;
5 source: string;
6 message: string;
7}
8
9const entries: LogEntry[] = [];
10
11export const warn = (source: string, message: string) => {
12 console.warn(`[${source}] ${message}`);
13 entries.push({ level: 'warn', source, message });
14};
15
16export const error = (source: string, message: string) => {
17 console.error(`[${source}] ${message}`);
18 entries.push({ level: 'error', source, message });
19};
20
21export const printSummary = () => {
22 if (entries.length === 0) return;
23
24 const grouped: Record<string, { errors: number; warnings: number; messages: string[] }> = {};
25 for (const entry of entries) {
26 if (!grouped[entry.source]) {
27 grouped[entry.source] = { errors: 0, warnings: 0, messages: [] };
28 }
29 const group = grouped[entry.source];
30 if (entry.level === 'error') group.errors++;
31 else group.warnings++;
32 group.messages.push(` ${entry.level.toUpperCase()}: ${entry.message}`);
33 }
34
35 console.log('\n───────────── Build fetch summary ──────────────');
36 for (const [source, { errors, warnings, messages }] of Object.entries(grouped)) {
37 const parts = [];
38 if (errors) parts.push(`${errors} error${errors > 1 ? 's' : ''}`);
39 if (warnings) parts.push(`${warnings} warning${warnings > 1 ? 's' : ''}`);
40 console.log(`[${source}] ${parts.join(', ')}`);
41 for (const msg of messages) {
42 console.log(msg);
43 }
44 }
45 console.log('────────────────────────────────────────────────\n');
46
47 entries.length = 0;
48};