feat(website): support wally dependencies

This commit is contained in:
LukaDev 2024-10-14 13:47:12 +02:00
parent 6088a2ce0d
commit b49c3844f9
2 changed files with 35 additions and 10 deletions

View file

@ -36,6 +36,10 @@ export type DependencyInfo = {
name: string name: string
target?: string target?: string
version: string version: string
} | {
index: string,
wally: string,
version: string,
} }
export type DependencyKind = "standard" | "peer" | "dev" export type DependencyKind = "standard" | "peer" | "dev"

View file

@ -16,7 +16,7 @@
<p class="py-24 text-center">This package doesn't have any dependencies.</p> <p class="py-24 text-center">This package doesn't have any dependencies.</p>
{:else} {:else}
<div class="space-y-8 py-8"> <div class="space-y-8 py-8">
{#each Object.entries(groupedDeps).sort( (a, b) => a[0].localeCompare(b[0]), ) as [dependencyKind, group]} {#each Object.entries(groupedDeps).sort( (a, b) => b[0].localeCompare(a[0]), ) as [dependencyKind, group]}
<section> <section>
<h2 class="text-heading mb-4 text-xl font-medium"> <h2 class="text-heading mb-4 text-xl font-medium">
{DEPENDENCY_KIND_DISPLAY_NAMES[dependencyKind as DependencyKind]} {DEPENDENCY_KIND_DISPLAY_NAMES[dependencyKind as DependencyKind]}
@ -24,25 +24,46 @@
<div class="space-y-4"> <div class="space-y-4">
{#each group as { dependency: [dependencyInfo] }} {#each group as { dependency: [dependencyInfo] }}
{@const [scope, name] = dependencyInfo.name.split("/")} {@const isWally = "wally" in dependencyInfo}
{@const target = {@const [scope, name] = (isWally ? dependencyInfo.wally : dependencyInfo.name).split(
dependencyInfo.target ?? $page.params.target ?? data.pkg.targets[0].kind} "/",
)}
{@const target = isWally
? undefined
: (dependencyInfo.target ?? $page.params.target ?? data.pkg.targets[0].kind)}
{@const isOfficialRegistry = isWally
? dependencyInfo.index === "https://github.com/UpliftGames/wally-index"
: dependencyInfo.index === "https://github.com/daimond113/pesde-index"}
<article <article
class="bg-card hover:bg-card-hover relative overflow-hidden rounded px-5 py-4 transition" class={`bg-card relative overflow-hidden rounded px-5 py-4 transition ${
isOfficialRegistry ? "hover:bg-card-hover" : ""
}`}
> >
<h3 class="font-semibold"> <h3 class="font-semibold">
<a <svelte:element
href={`/packages/${dependencyInfo.name}/latest/${target}`} this={isOfficialRegistry ? "a" : "svelte:fragment"}
{...isOfficialRegistry
? {
href: isWally
? `https://wally.run/package/${dependencyInfo.wally}`
: `/packages/${dependencyInfo.name}/latest/${target}`,
}
: {}}
class="after:absolute after:inset-0 after:content-['']" class="after:absolute after:inset-0 after:content-['']"
> >
<span class="text-heading">{scope}/</span><span class="text-light">{name}</span> <span class="text-heading">{scope}/</span><span class="text-light">{name}</span>
</a> {#if isWally}
<span class="text-red-400">(wally)</span>
{/if}
</svelte:element>
</h3> </h3>
<div class="text-primary text-sm font-semibold"> <div class="text-primary text-sm font-semibold">
{dependencyInfo.version} {dependencyInfo.version}
{#if !isWally}
· ·
{target} {target}
{/if}
</div> </div>
</article> </article>
{/each} {/each}