Skip to content

Commit a85fd1b

Browse files
committed
fix: parsing manifest file
1 parent 86ec4a3 commit a85fd1b

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/components/ModuleCard.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
import { parse } from 'yaml';
21
import { Star, Calendar } from '@phosphor-icons/react';
32

4-
import type { Repository, Manifest } from '../types';
3+
import type { Repository } from '../types';
54

6-
import { getLanguageColor, getProviderInfo, formatDate, formatNumber } from '../lib/utils';
5+
import {
6+
getLanguageColor,
7+
getProviderInfo,
8+
formatDate,
9+
formatNumber,
10+
parseManifest
11+
} from '../lib/utils';
712

813
interface ModuleCardProps {
914
module: Repository;
1015
}
1116

1217
export default function ModuleCard({ module }: ModuleCardProps) {
13-
const manifest = parse(module.manifest.text) as Manifest | undefined;
18+
const manifest = parseManifest(module.manifest.text);
1419

1520
const moduleName = manifest?.title || module.name;
1621
const moduleDescription = manifest?.summary || module.description || 'No description available';

src/components/SourcesTableViewSkeleton.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export default function SourcesTableViewSkeleton() {
2-
// Generate 5 skeleton items
32
const skeletonItems = Array.from({ length: 12 }, (_, i) => i);
43

54
return (

src/lib/utils.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { parse } from 'yaml';
2+
13
import type { ComponentType } from 'react';
24
import {
35
House,
@@ -18,6 +20,7 @@ import {
1820
import { Crates, Github, Npm, PyPi, RubyGems } from '../components/icons';
1921

2022
import { ZUPLO_API_BASE } from './config';
23+
import type { Repository, Manifest } from '../types';
2124

2225
export const DOMAIN_ICONS: Record<string, ComponentType<any>> = {
2326
'airbnb.com': House,
@@ -160,6 +163,19 @@ export const formatNumber = (num: number) => {
160163
return num.toString();
161164
};
162165

166+
export const parseManifest = (
167+
manifestText: Repository['manifest']['text'] | undefined
168+
): Manifest | undefined => {
169+
if (!manifestText) return undefined;
170+
171+
try {
172+
return parse(manifestText) as Manifest;
173+
} catch (error) {
174+
console.warn('Failed to parse manifest:', error);
175+
return undefined;
176+
}
177+
};
178+
163179
export const fetchWithFallback = async <T>(endpoint: string, fallbackData: T): Promise<T> => {
164180
try {
165181
const apiUrl = `${ZUPLO_API_BASE}/${endpoint}`;

0 commit comments

Comments
 (0)