Skip to content

Commit 2c56fd4

Browse files
authored
feat: add source for linux-cachyos packages (#81)
1 parent 503a38c commit 2c56fd4

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/components/PackageDetails.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,31 @@ async function getSourceUrl(pkg: PackageDetails): Promise<null | string> {
231231
return `https://gitlab.archlinux.org/archlinux/packaging/packages/${pkg.pkg_base}/-/tree/${archPkgVersion}`;
232232
}
233233

234+
const repos = ['linux-cachyos', 'CachyOS-PKGBUILDS'];
235+
for (const repo of repos) {
236+
try {
237+
const cachyosPaths: PkgbuildMap = await fetchPkgbuilds({
238+
repo,
239+
});
240+
241+
let pkgbuildPath: string | undefined;
242+
if (repo === 'linux-cachyos') {
243+
pkgbuildPath = Object.entries(cachyosPaths)
244+
.filter(([repoPkg]) => pkg.pkg_name.startsWith(repoPkg))
245+
.map(([, path]) => path)
246+
.at(0);
247+
} else {
248+
pkgbuildPath = cachyosPaths[pkg.pkg_name];
249+
}
250+
251+
if (pkgbuildPath) {
252+
return `https://github.com/CachyOS/${repo}/tree/master/${pkgbuildPath}`;
253+
}
254+
} catch (error) {
255+
console.error(`Failed to fetch ${repo}:`, error);
256+
}
257+
}
258+
234259
try {
235260
const aurPkgNames: AurPkgNameSet = await fetchAurPkgNames();
236261
if (aurPkgNames.has(pkg.pkg_name)) {
@@ -240,15 +265,5 @@ async function getSourceUrl(pkg: PackageDetails): Promise<null | string> {
240265
console.error('Failed to fetch AUR PKGNAMES:', error);
241266
}
242267

243-
try {
244-
const cachyosPaths: PkgbuildMap = await fetchPkgbuilds();
245-
const pkgbuildPath = cachyosPaths[pkg.pkg_name];
246-
if (pkgbuildPath) {
247-
return `https://github.com/CachyOS/CachyOS-PKGBUILDS/tree/master/${pkgbuildPath}`;
248-
}
249-
} catch (error) {
250-
console.error('Failed to fetch CachyOS PKGBUILDS:', error);
251-
}
252-
253268
return null;
254269
}

0 commit comments

Comments
 (0)