Skip to content

Commit 8dcea70

Browse files
committed
Merge branch 'main' into feat/suggest-pkg-comparisons-and-no-dep
2 parents fb0e360 + 0b55ca4 commit 8dcea70

34 files changed

Lines changed: 1382 additions & 349 deletions

app/components/OgImage/Package.vue

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const repositoryUrl = computed(() => {
4646
return url
4747
})
4848
49+
const { data: likes, refresh: refreshLikes } = useFetch(() => `/api/social/likes/${name.value}`, {
50+
default: () => ({ totalLikes: 0, userHasLiked: false }),
51+
})
52+
4953
const { stars, refresh: refreshRepoMeta } = useRepoMeta(repositoryUrl)
5054
5155
const formattedStars = computed(() =>
@@ -57,7 +61,7 @@ const formattedStars = computed(() =>
5761
5862
try {
5963
await refreshPkg()
60-
await Promise.all([refreshRepoMeta(), refreshDownloads()])
64+
await Promise.all([refreshRepoMeta(), refreshDownloads(), refreshLikes()])
6165
} catch (err) {
6266
console.warn('[og-image-package] Failed to load data server-side:', err)
6367
throw createError({
@@ -73,7 +77,7 @@ try {
7377
<div class="relative z-10 flex flex-col gap-6">
7478
<div class="flex items-start gap-4">
7579
<div
76-
class="flex items-start justify-center w-16 h-16 rounded-xl shadow-lg bg-gradient-to-tr from-[#3b82f6]"
80+
class="flex items-center justify-center w-16 h-16 p-4 rounded-xl shadow-lg bg-gradient-to-tr from-[#3b82f6]"
7781
:style="{ backgroundColor: primaryColor }"
7882
>
7983
<svg
@@ -104,11 +108,11 @@ try {
104108
</div>
105109

106110
<div
107-
class="flex items-center gap-3 text-4xl font-light text-[#a3a3a3]"
111+
class="flex items-center gap-5 text-4xl font-light text-[#a3a3a3]"
108112
style="font-family: 'Geist Sans', sans-serif"
109113
>
110114
<span
111-
class="px-3 py-1 rounded-lg border"
115+
class="px-3 py-1 mr-2 rounded-lg border font-bold opacity-90"
112116
:style="{
113117
color: primaryColor,
114118
backgroundColor: primaryColor + '10',
@@ -118,39 +122,92 @@ try {
118122
>
119123
{{ resolvedVersion }}
120124
</span>
121-
<span v-if="downloads">
122-
<span>• {{ $n(downloads.downloads) }} </span>
123-
<span class="flex items-center gap-0">
124-
<svg
125-
width="30"
126-
height="30"
127-
viewBox="0 0 24 24"
128-
fill="none"
129-
stroke="currentColor"
130-
stroke-width="2"
131-
stroke-linecap="round"
132-
stroke-linejoin="round"
133-
class="text-white/70"
134-
>
135-
<circle cx="12" cy="12" r="10" class="opacity-40" />
136-
<path d="M12 8v8m-3-3l3 3 3-3" />
137-
</svg>
138-
<span>/wk</span>
125+
<span v-if="downloads" class="flex items-center gap-2">
126+
<svg
127+
width="30"
128+
height="30"
129+
viewBox="0 0 24 24"
130+
fill="none"
131+
:stroke="primaryColor"
132+
stroke-width="2"
133+
stroke-linecap="round"
134+
stroke-linejoin="round"
135+
class="opacity-90"
136+
>
137+
<circle cx="12" cy="12" r="10" class="opacity-60" />
138+
<path d="M12 8v8m-3-3l3 3 3-3" />
139+
</svg>
140+
<span>{{ $n(downloads.downloads) }}/wk</span>
141+
</span>
142+
<span v-if="pkg?.license" class="flex items-center gap-2">
143+
<svg
144+
viewBox="0 0 32 32"
145+
:fill="primaryColor"
146+
xmlns="http://www.w3.org/2000/svg"
147+
height="32"
148+
width="32"
149+
class="opacity-90"
150+
>
151+
<path
152+
d="M21.7166 12.57C20.5503 10.631 18.4257 9.33301 15.9997 9.33301C12.3197 9.33301 9.33301 12.3197 9.33301 15.9997C9.33301 19.6797 12.3197 22.6663 15.9997 22.6663C18.4257 22.6663 20.5503 21.3683 21.7166 19.4294L19.4302 18.0586C18.7307 19.2218 17.4566 19.9997 15.9997 19.9997C13.7897 19.9997 11.9997 18.2097 11.9997 15.9997C11.9997 13.7897 13.7897 11.9997 15.9997 11.9997C17.457 11.9997 18.7318 12.7782 19.431 13.9421L21.7166 12.57Z"
153+
/>
154+
<path
155+
fill-rule="evenodd"
156+
clip-rule="evenodd"
157+
d="M15.5247 2.66602C22.8847 2.66602 28.8581 8.63932 28.8581 15.9993C28.8581 23.3593 22.8847 29.3327 15.5247 29.3327C8.16471 29.3327 2.19141 23.3593 2.19141 15.9993C2.19141 8.63932 8.16471 2.66602 15.5247 2.66602ZM4.85807 15.9993C4.85807 10.106 9.63135 5.33268 15.5247 5.33268C21.4181 5.33268 26.1914 10.106 26.1914 15.9993C26.1914 21.8927 21.4181 26.666 15.5247 26.666C9.63135 26.666 4.85807 21.8927 4.85807 15.9993Z"
158+
class="opacity-60"
159+
/>
160+
</svg>
161+
<span>
162+
{{ pkg.license }}
139163
</span>
140164
</span>
141-
<span v-if="pkg?.license"> • {{ pkg.license }}</span>
142165
<span class="flex items-center gap-2">
143-
<span>•</span>
144-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32px" height="32px">
166+
<svg
167+
xmlns="http://www.w3.org/2000/svg"
168+
viewBox="0 0 32 32"
169+
width="32px"
170+
height="32px"
171+
class="opacity-60"
172+
>
145173
<path
146-
fill="currentColor"
174+
:fill="primaryColor"
147175
d="m16 6.52l2.76 5.58l.46 1l1 .15l6.16.89l-4.38 4.3l-.75.73l.18 1l1.05 6.13l-5.51-2.89L16 23l-.93.49l-5.51 2.85l1-6.13l.18-1l-.74-.77l-4.42-4.35l6.16-.89l1-.15l.46-1zM16 2l-4.55 9.22l-10.17 1.47l7.36 7.18L6.9 30l9.1-4.78L25.1 30l-1.74-10.13l7.36-7.17l-10.17-1.48Z"
148176
/>
149177
</svg>
150178
<span>
151179
{{ formattedStars }}
152180
</span>
153181
</span>
182+
<span class="flex items-center gap-2">
183+
<svg
184+
width="32"
185+
height="32"
186+
viewBox="0 0 32 32"
187+
fill="none"
188+
xmlns="http://www.w3.org/2000/svg"
189+
class="opacity-90"
190+
>
191+
<path
192+
d="M19.3057 25.8317L18.011 27.0837C17.7626 27.3691 17.4562 27.5983 17.1124 27.7561C16.7685 27.914 16.3951 27.9969 16.0167 27.9993C15.6384 28.0017 15.2639 27.9235 14.918 27.77C14.5722 27.6165 14.263 27.3912 14.011 27.1091L6.66699 19.9997C4.66699 17.9997 2.66699 15.7331 2.66699 12.6664C2.66702 11.1827 3.11712 9.73384 3.95784 8.51128C4.79856 7.28872 5.99035 6.34994 7.3758 5.81893C8.76126 5.28792 10.2752 5.18965 11.7177 5.53712C13.1602 5.88459 14.4633 6.66143 15.455 7.76506C15.5248 7.83975 15.6093 7.89929 15.7031 7.93999C15.7969 7.9807 15.8981 8.00171 16.0003 8.00171C16.1026 8.00171 16.2038 7.9807 16.2976 7.93999C16.3914 7.89929 16.4758 7.83975 16.5457 7.76506C17.5342 6.65426 18.8377 5.87088 20.2825 5.5192C21.7273 5.16751 23.245 5.26419 24.6335 5.79637C26.022 6.32856 27.2155 7.271 28.0551 8.49826C28.8948 9.72553 29.3407 11.1794 29.3337 12.6664C29.3332 13.3393 29.2349 14.0085 29.0417 14.6531"
193+
:stroke="primaryColor"
194+
stroke-width="2.66667"
195+
stroke-linecap="round"
196+
stroke-linejoin="round"
197+
class="opacity-60"
198+
/>
199+
<path
200+
d="M20 20H24M28 20H24M24 16L24 20M24 24L24 20"
201+
:stroke="primaryColor"
202+
stroke-width="2.66667"
203+
stroke-linecap="round"
204+
stroke-linejoin="round"
205+
/>
206+
</svg>
207+
<span>
208+
{{ likes.totalLikes }}
209+
</span>
210+
</span>
154211
</div>
155212
</div>
156213

app/components/PackageProvenanceSection.vue

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defineProps<{
77
</script>
88

99
<template>
10-
<section aria-labelledby="provenance-heading" class="scroll-mt-20">
10+
<section id="provenance" aria-labelledby="provenance-heading" class="scroll-mt-20">
1111
<h2 id="provenance-heading" class="group text-xs text-fg-subtle uppercase tracking-wider mb-3">
1212
<a
1313
href="#provenance"
@@ -21,36 +21,43 @@ defineProps<{
2121
</a>
2222
</h2>
2323

24-
<div class="space-y-3 border border-border rounded-lg p-5">
25-
<p class="flex items-center gap-2 text-sm text-fg m-0">
26-
<span class="i-lucide-shield-check w-4 h-4 shrink-0 text-emerald-500" aria-hidden="true" />
27-
<i18n-t keypath="package.provenance_section.built_and_signed_on" tag="span">
28-
<template #provider>
29-
<strong>{{ details.providerLabel }}</strong>
30-
</template>
31-
</i18n-t>
32-
</p>
33-
<a
34-
v-if="details.buildSummaryUrl"
35-
:href="details.buildSummaryUrl"
36-
target="_blank"
37-
rel="noopener noreferrer"
38-
class="link text-sm text-fg-muted block mt-1"
39-
>
40-
{{ $t('package.provenance_section.view_build_summary') }}
41-
</a>
24+
<div class="space-y-3 border border-border rounded-lg p-4 sm:p-5">
25+
<div class="space-y-1">
26+
<p class="flex items-start gap-2 text-sm text-fg m-0">
27+
<span
28+
class="i-lucide-shield-check w-4 h-4 shrink-0 text-emerald-500 mt-0.5"
29+
aria-hidden="true"
30+
/>
31+
<i18n-t keypath="package.provenance_section.built_and_signed_on" tag="span">
32+
<template #provider>
33+
<strong>{{ details.providerLabel }}</strong>
34+
</template>
35+
</i18n-t>
36+
</p>
4237

43-
<dl class="m-0 mt-4 flex justify-between">
44-
<div v-if="details.sourceCommitUrl" class="flex flex-col gap-0.5">
38+
<a
39+
v-if="details.buildSummaryUrl"
40+
:href="details.buildSummaryUrl"
41+
target="_blank"
42+
rel="noopener noreferrer"
43+
class="link text-sm text-fg-muted inline-flex"
44+
>
45+
{{ $t('package.provenance_section.view_build_summary') }}
46+
</a>
47+
</div>
48+
49+
<dl class="m-0 mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
50+
<div v-if="details.sourceCommitUrl" class="min-w-0 flex flex-col gap-0.5">
4551
<dt class="font-mono text-xs text-fg-muted m-0">
4652
{{ $t('package.provenance_section.source_commit') }}
4753
</dt>
48-
<dd class="m-0">
54+
<dd class="m-0 min-w-0">
4955
<a
5056
:href="details.sourceCommitUrl"
5157
target="_blank"
5258
rel="noopener noreferrer"
53-
class="link font-mono text-sm break-all"
59+
class="link font-mono text-sm block min-w-0 truncate"
60+
:title="details.sourceCommitSha ?? details.sourceCommitUrl"
5461
>
5562
{{
5663
details.sourceCommitSha
@@ -60,31 +67,34 @@ defineProps<{
6067
</a>
6168
</dd>
6269
</div>
63-
<div v-if="details.buildFileUrl" class="flex flex-col gap-0.5">
70+
71+
<div v-if="details.buildFileUrl" class="min-w-0 flex flex-col gap-0.5">
6472
<dt class="font-mono text-xs text-fg-muted m-0">
6573
{{ $t('package.provenance_section.build_file') }}
6674
</dt>
67-
<dd class="m-0">
75+
<dd class="m-0 min-w-0">
6876
<a
6977
:href="details.buildFileUrl"
7078
target="_blank"
7179
rel="noopener noreferrer"
72-
class="link font-mono text-sm break-all"
80+
class="link font-mono text-sm block min-w-0 break-words"
81+
:title="details.buildFilePath ?? details.buildFileUrl"
7382
>
7483
{{ details.buildFilePath ?? details.buildFileUrl }}
7584
</a>
7685
</dd>
7786
</div>
78-
<div v-if="details.publicLedgerUrl" class="flex flex-col gap-0.5">
87+
88+
<div v-if="details.publicLedgerUrl" class="min-w-0 flex flex-col gap-0.5">
7989
<dt class="font-mono text-xs text-fg-muted m-0">
8090
{{ $t('package.provenance_section.public_ledger') }}
8191
</dt>
82-
<dd class="m-0">
92+
<dd class="m-0 min-w-0">
8393
<a
8494
:href="details.publicLedgerUrl"
8595
target="_blank"
8696
rel="noopener noreferrer"
87-
class="link text-sm"
97+
class="link text-sm inline-flex"
8898
>
8999
{{ $t('package.provenance_section.transparency_log_entry') }}
90100
</a>

app/components/Terminal/Install.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const copyCreateCommand = () => copyCreate(getFullCreateCommand())
123123
>
124124
<button
125125
type="button"
126-
class="px-2 py-0.5 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-colors duration-200 opacity-0 group-hover/installcmd:opacity-100 hover:(text-fg border-border-hover) active:scale-95 focus-visible:opacity-100 focus-visible:outline-accent/70"
126+
class="px-2 py-0.5 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-colors duration-200 opacity-0 group-hover/installcmd:opacity-100 hover:(text-fg border-border-hover) active:scale-95 focus-visible:opacity-100 focus-visible:outline-accent/70 select-none"
127127
:aria-label="$t('package.get_started.copy_command')"
128128
@click.stop="copyInstallCommand"
129129
>
@@ -150,7 +150,7 @@ const copyCreateCommand = () => copyCreate(getFullCreateCommand())
150150
>
151151
<NuxtLink
152152
:to="`/package/${typesPackageName}`"
153-
class="text-fg-subtle hover:text-fg-muted text-xs transition-colors focus-visible:outline-accent/70 rounded"
153+
class="text-fg-subtle hover:text-fg-muted text-xs transition-colors focus-visible:outline-accent/70 rounded select-none"
154154
:title="$t('package.get_started.view_types', { package: typesPackageName })"
155155
>
156156
<span class="i-carbon:arrow-right rtl-flip w-3 h-3 align-middle" aria-hidden="true" />
@@ -185,7 +185,7 @@ const copyCreateCommand = () => copyCreate(getFullCreateCommand())
185185
>
186186
<button
187187
type="button"
188-
class="px-2 py-0.5 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-colors duration-200 opacity-0 group-hover/runcmd:opacity-100 hover:(text-fg border-border-hover) active:scale-95 focus-visible:opacity-100 focus-visible:outline-accent/70"
188+
class="px-2 py-0.5 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-colors duration-200 opacity-0 group-hover/runcmd:opacity-100 hover:(text-fg border-border-hover) active:scale-95 focus-visible:opacity-100 focus-visible:outline-accent/70 select-none"
189189
@click.stop="copyRunCommand(executableInfo?.primaryCommand)"
190190
>
191191
{{ runCopied ? $t('common.copied') : $t('common.copy') }}
@@ -196,10 +196,8 @@ const copyCreateCommand = () => copyCreate(getFullCreateCommand())
196196
<!-- Create command (for packages with associated create-* package) - render all PM variants -->
197197
<template v-if="createPackageInfo">
198198
<!-- Comment line -->
199-
<div class="flex items-center gap-2 pt-1">
200-
<span class="text-fg-subtle font-mono text-sm select-none"
201-
># {{ $t('package.create.title') }}</span
202-
>
199+
<div class="flex items-center gap-2 pt-1 select-none">
200+
<span class="text-fg-subtle font-mono text-sm"># {{ $t('package.create.title') }}</span>
203201
<TooltipApp
204202
:text="$t('package.create.view', { packageName: createPackageInfo.packageName })"
205203
>
@@ -232,7 +230,7 @@ const copyCreateCommand = () => copyCreate(getFullCreateCommand())
232230
>
233231
<button
234232
type="button"
235-
class="px-2 py-0.5 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-colors duration-200 opacity-0 group-hover/createcmd:opacity-100 hover:(text-fg border-border-hover) active:scale-95 focus-visible:opacity-100 focus-visible:outline-accent/70"
233+
class="px-2 py-0.5 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-colors duration-200 opacity-0 group-hover/createcmd:opacity-100 hover:(text-fg border-border-hover) active:scale-95 focus-visible:opacity-100 focus-visible:outline-accent/70 select-none"
236234
:aria-label="$t('package.create.copy_command')"
237235
@click.stop="copyCreateCommand"
238236
>

app/composables/npm/usePackage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ function transformPackument(pkg: Packument, requestedVersion?: string | null): S
6969
if (pkg.time[v]) filteredTime[v] = pkg.time[v]
7070
}
7171

72+
// Normalize license field
73+
let license = pkg.license
74+
if (license && typeof license === 'object' && 'type' in license) {
75+
license = license.type
76+
}
77+
7278
return {
7379
'_id': pkg._id,
7480
'_rev': pkg._rev,
@@ -78,7 +84,7 @@ function transformPackument(pkg: Packument, requestedVersion?: string | null): S
7884
'time': filteredTime,
7985
'maintainers': pkg.maintainers,
8086
'author': pkg.author,
81-
'license': pkg.license,
87+
'license': license,
8288
'homepage': pkg.homepage,
8389
'keywords': pkg.keywords,
8490
'repository': pkg.repository,

app/composables/usePackageComparison.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
177177
severity: vulnsSeverity,
178178
},
179179
metadata: {
180-
license: pkgData.license,
180+
license:
181+
typeof pkgData.license === 'object' && 'type' in pkgData.license
182+
? pkgData.license.type
183+
: pkgData.license,
181184
// Use version-specific publish time, NOT time.modified (which can be
182185
// updated by metadata changes like maintainer additions)
183186
lastUpdated: pkgData.time?.[latestVersion],

0 commit comments

Comments
 (0)