-
-
Notifications
You must be signed in to change notification settings - Fork 283
feat: adding gh changelog/releases within npmx #1233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WilcoSp
wants to merge
56
commits into
npmx-dev:main
Choose a base branch
from
WilcoSp:feat/changelog-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,104
−97
Open
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
c0a23b4
now able to detect whether gh releases are biing used by a package.
WilcoSp 4873b1c
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp 92193b5
moved has changelog to it's own api endpoint
WilcoSp 2a397bf
added detection of a changelog file on the root of the github repo
WilcoSp 4cfbbfe
Merge branch main into feat/changelog-1
WilcoSp 42802dc
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp 9c130bd
github releases are now being show at /package-changes (rendering of …
WilcoSp a424459
Merge branch 'feat/changelog-1' of github.com:WilcoSp/npmx.dev into f…
WilcoSp e487292
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp 6c7d817
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp ba81215
fixed issue where markdown from github releases could be null
WilcoSp 8d22cf2
some refactoring
WilcoSp f8b32d4
adding a11y test for changelog card.
WilcoSp b345df1
markdown is now being rendered (settings need to be added still)
WilcoSp f4c84ec
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp bc0fa2f
added headings handling and toc (only scroll behavior needs to be cha…
WilcoSp 5e32d04
Merge branch 'feat/changelog-1' of github.com:WilcoSp/npmx.dev into f…
WilcoSp faf6b3b
fallback to tag for title if name is null
WilcoSp 14c50da
removing from toc slug and text
WilcoSp 5cd51af
adding id for navigation for when it gets implemented
WilcoSp 53cd46f
code blocks, blockquote & links are now handled by the markdown renderer
WilcoSp 30d2663
new lines rendering is now closing to how it's on github. at least fo…
WilcoSp 8d5ee71
enableling gfm for changelogs
WilcoSp 34faad0
the changelog info api endpoint will now give the info when a changel…
WilcoSp 55d45f3
now also able to render changelog markdown files
WilcoSp 9c36c60
Merge branch 'main' into feat/changelog-1
WilcoSp 95e3699
added heading links for changelog markdown
WilcoSp 9f9195d
release card header links can now also be clicked to navigate to
WilcoSp f2d5f2b
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp cab3cc6
when the latest gh release contains a link to a changelog.md the chan…
WilcoSp 342adca
Merge branch 'main' into feat/changelog-1
WilcoSp 1a8c342
re exporting slugify
WilcoSp fbbff33
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp 08717bc
adding back removing non bracking spaces, :emoji: support now also ad…
WilcoSp e07af6c
added indication that release is pre-release/draft
WilcoSp 8225654
Merge branch 'npmx-dev:main' into feat/changelog-1
WilcoSp 013654c
preventing package@version from being turned into mailto
WilcoSp 6cbe6e8
changed how content-none is applied for changelog.md
WilcoSp 1d93405
for changelog.md now resolving url
WilcoSp f6ec86e
relative/absolute resolved urls will stay within the base url
WilcoSp 6198a71
id with release id will now be applied to all elements
WilcoSp 2c057b9
Added button to view changelog/releases on the provider website.
WilcoSp ce34993
added a div which reservers the space for toc
WilcoSp fd15403
Merge branch 'main' into feat/changelog-1
WilcoSp 04b2a99
adding back .tolowercase in slugify to have test pass again
WilcoSp 746464f
Merge branch 'main' into feat/changelog-1
WilcoSp 750072c
fixing some (minor) things caught by coderabbitai
WilcoSp 6e6ee3a
..
WilcoSp 0cab1e8
improving intermediateTitleAttr
WilcoSp 4de0348
removing unneeded comment
WilcoSp 5f4520f
removing resolving explicitly ./ & ../ comment
WilcoSp 81f68b6
Merge branch 'main' into feat/changelog-1
WilcoSp 6d0edfd
[autofix.ci] apply automated fixes
autofix-ci[bot] f9c0736
adding view_on translation to kn_IN (autofix removed it)
WilcoSp d48654a
Merge branch 'main' into feat/changelog-1
WilcoSp a67f039
Merge branch 'main' into feat/changelog-1
WilcoSp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <script setup lang="ts"> | ||
| import type { ReleaseData } from '~~/shared/types/changelog' | ||
| import { useDateFormat } from '#imports' | ||
|
|
||
| const { release } = defineProps<{ | ||
| release: ReleaseData | ||
| }>() | ||
| const formattedDate = useDateFormat(() => release.publishedAt, 'YYYY-MM-DD', {}) | ||
|
|
||
| const cardId = computed(() => (release.publishedAt ? `date-${formattedDate.value}` : undefined)) | ||
|
|
||
| const navId = computed(() => `release-${encodeURIComponent(release.title)}`) | ||
|
|
||
| function navigateToTitle() { | ||
| navigateTo(`#${navId.value}`) | ||
| } | ||
| </script> | ||
| <template> | ||
| <section class="border border-border rounded-lg p-4 sm:p-6"> | ||
| <div class="flex gap-2 items-center" :id="cardId"> | ||
| <h2 class="text-1xl sm:text-2xl font-medium min-w-0 break-words py-2" :id="navId"> | ||
| <a | ||
| class="hover:decoration-accent hover:text-accent focus-visible:decoration-accent focus-visible:text-accent transition-colors duration-200" | ||
| :class="$style.linkTitle" | ||
| :href="`#${navId}`" | ||
| @click.prevent="navigateToTitle()" | ||
| > | ||
| {{ release.title }} | ||
| </a> | ||
| </h2> | ||
| <TagStatic v-if="release.prerelease" variant="default" class="h-unset"> | ||
| {{ $t('changelog.pre_release') }} | ||
| </TagStatic> | ||
| <TagStatic v-if="release.draft" variant="default" class="h-unset"> | ||
| {{ $t('changelog.draft') }} | ||
| </TagStatic> | ||
| <div class="flex-1" aria-hidden="true"></div> | ||
| <ReadmeTocDropdown | ||
| v-if="release?.toc && release.toc.length > 1" | ||
| :toc="release.toc" | ||
| class="ms-auto" | ||
| /> | ||
| <!-- :active-id="activeTocId" --> | ||
| </div> | ||
| <DateTime v-if="release.publishedAt" :datetime="release.publishedAt" date-style="medium" /> | ||
| <Readme v-if="release.html" :html="release.html"></Readme> | ||
| </section> | ||
| </template> | ||
|
|
||
| <style module> | ||
| .linkTitle::after { | ||
| content: '__'; | ||
| @apply inline i-lucide:link rtl-flip ms-1 opacity-0; | ||
| } | ||
|
|
||
| .linkTitle:hover:after { | ||
| @apply opacity-100; | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <script setup lang="ts"> | ||
| const { info, tpTarget } = defineProps<{ | ||
| info: ChangelogMarkdownInfo | ||
| tpTarget?: HTMLElement | null | ||
| }>() | ||
|
|
||
| const { data } = useLazyFetch(() => `/api/changelog/md/${info.provider}/${info.repo}/${info.path}`) | ||
| </script> | ||
| <template> | ||
| <Teleport v-if="data?.toc && data.toc.length > 1 && !!tpTarget" :to="tpTarget"> | ||
| <ReadmeTocDropdown :toc="data.toc" class="justify-self-end" /> | ||
| </Teleport> | ||
| <Readme v-if="data?.html" :html="data.html"></Readme> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <script setup lang="ts"> | ||
| const { info } = defineProps<{ info: ChangelogReleaseInfo }>() | ||
|
|
||
| const { data: releases } = useFetch<ReleaseData[]>( | ||
| () => `/api/changelog/releases/${info.provider}/${info.repo}`, | ||
| ) | ||
| </script> | ||
| <template> | ||
| <div class="flex flex-col gap-2 py-3" v-if="releases"> | ||
| <ChangelogCard v-for="release of releases" :release :key="release.id" /> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { ChangelogInfo } from '~~/shared/types/changelog' | ||
|
|
||
| export function usePackageChangelog( | ||
| packageName: MaybeRefOrGetter<string>, | ||
| version?: MaybeRefOrGetter<string | null | undefined>, | ||
| ) { | ||
| return useLazyFetch<ChangelogInfo>(() => { | ||
| const name = toValue(packageName) | ||
| const ver = toValue(version) | ||
| const base = `/api/changelog/info/${name}` | ||
| return ver ? `${base}/v/${ver}` : base | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { ProviderId } from '#imports' | ||
| import type { IconClass } from '~/types/icon' | ||
| import { computed, toValue } from 'vue' | ||
|
|
||
| const PROVIDER_ICONS: Record<ProviderId, IconClass> = { | ||
| github: 'i-simple-icons:github', | ||
| gitlab: 'i-simple-icons:gitlab', | ||
| bitbucket: 'i-simple-icons:bitbucket', | ||
| codeberg: 'i-simple-icons:codeberg', | ||
| gitea: 'i-simple-icons:gitea', | ||
| forgejo: 'i-simple-icons:forgejo', | ||
| gitee: 'i-simple-icons:gitee', | ||
| sourcehut: 'i-simple-icons:sourcehut', | ||
| tangled: 'i-custom:tangled', | ||
| radicle: 'i-lucide:network', // Radicle is a P2P network, using network icon | ||
| } | ||
|
|
||
| export function useProviderIcon(provider: MaybeRefOrGetter<ProviderId | null | undefined>) { | ||
| return computed((): IconClass => { | ||
| const uProvider = toValue(provider) | ||
| if (!uProvider) return 'i-simple-icons:github' | ||
| return PROVIDER_ICONS[uProvider] ?? 'i-lucide:code' | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| <script setup lang="ts"> | ||
| import { useProviderIcon } from '~/composables/useProviderIcon' | ||
|
|
||
| definePageMeta({ | ||
| name: 'changes', | ||
| path: '/package-changes/:path+', | ||
| alias: ['/package/changes/:path+', '/changes/:path+'], | ||
| scrollMargin: 140, | ||
| }) | ||
|
|
||
| /// routing | ||
|
|
||
| const route = useRoute('changes') | ||
| const router = useRouter() | ||
| // Parse package name, version, and file path from URL | ||
| // Patterns: | ||
| // /code/nuxt/v/4.2.0 → packageName: "nuxt", version: "4.2.0", filePath: null (show tree) | ||
| // /code/nuxt/v/4.2.0/src/index.ts → packageName: "nuxt", version: "4.2.0", filePath: "src/index.ts" | ||
| // /code/@nuxt/kit/v/1.0.0 → packageName: "@nuxt/kit", version: "1.0.0", filePath: null | ||
| const parsedRoute = computed(() => { | ||
| const segments = route.params.path | ||
|
|
||
| // Find the /v/ separator for version | ||
| const vIndex = segments.indexOf('v') | ||
| if (vIndex === -1 || vIndex >= segments.length - 1) { | ||
| // No version specified - redirect or error | ||
| return { | ||
| packageName: segments.join('/'), | ||
| version: null as string | null, | ||
| filePath: null as string | null, | ||
| } | ||
| } | ||
|
|
||
| const packageName = segments.slice(0, vIndex).join('/') | ||
| const afterVersion = segments.slice(vIndex + 1) | ||
| const version = afterVersion[0] ?? null | ||
| const filePath = afterVersion.length > 1 ? afterVersion.slice(1).join('/') : null | ||
|
|
||
| return { packageName, version, filePath } | ||
| }) | ||
|
|
||
| const packageName = computed(() => parsedRoute.value.packageName) | ||
| const version = computed(() => parsedRoute.value.version) | ||
| const filePath = computed(() => parsedRoute.value.filePath?.replace(/\/$/, '')) | ||
|
|
||
| const { data: pkg } = usePackage(packageName) | ||
|
|
||
| const versionUrlPattern = computed(() => { | ||
| const base = `/package-changes/${packageName.value}/v/{version}` | ||
| return filePath.value ? `${base}/${filePath.value}` : base | ||
| }) | ||
|
|
||
| const latestVersion = computed(() => pkg.value?.['dist-tags']?.latest ?? null) | ||
|
|
||
| watch( | ||
| [version, latestVersion, packageName], | ||
| ([v, latest, name]) => { | ||
| if (!v && latest && name) { | ||
| const pathSegments = [...name.split('/'), 'v', latest] | ||
| router.replace({ name: 'changes', params: { path: pathSegments as [string, ...string[]] } }) | ||
| } | ||
| }, | ||
| { immediate: true }, | ||
| ) | ||
|
|
||
| // getting info | ||
| const { data: changelog, pending } = usePackageChangelog(packageName, version) | ||
|
|
||
| const repoProviderIcon = useProviderIcon(() => changelog.value?.provider) | ||
| const tptoc = useTemplateRef('tptoc') | ||
| </script> | ||
| <template> | ||
| <main class="flex-1 flex flex-col"> | ||
| <header class="border-b border-border bg-bg sticky top-14 z-20"> | ||
| <div class="container pt-4 pb-3"> | ||
| <div class="flex items-center gap-3 mb-3 flex-wrap min-w-0"> | ||
| <h1 | ||
| class="font-mono text-lg sm:text-xl font-semibold text-fg hover:text-fg-muted transition-colors truncate" | ||
| > | ||
| <NuxtLink v-if="packageName" :to="packageRoute(packageName, version)"> | ||
| {{ packageName }} | ||
| </NuxtLink> | ||
| </h1> | ||
|
|
||
| <VersionSelector | ||
| v-if="version && pkg?.versions && pkg?.['dist-tags']" | ||
| :package-name="packageName" | ||
| :current-version="version" | ||
| :versions="pkg.versions" | ||
| :dist-tags="pkg['dist-tags']" | ||
| :url-pattern="versionUrlPattern" | ||
| /> | ||
| <div class="flex-1"></div> | ||
| <LinkBase | ||
| v-if="changelog?.link" | ||
| :to="changelog?.link" | ||
| :classicon="repoProviderIcon" | ||
| :title="$t('common.view_on', { site: changelog.provider })" | ||
| > | ||
| {{ changelog.provider }} | ||
| </LinkBase> | ||
|
|
||
| <div v-if="changelog?.type == 'md'" ref="tptoc" class="w-14 h-8"> | ||
| <!-- prevents layout shift while loading --> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </header> | ||
|
|
||
| <section class="container w-full" v-if="!pending"> | ||
| <LazyChangelogReleases v-if="changelog?.type == 'release'" :info="changelog" /> | ||
| <LazyChangelogMarkdown | ||
| v-else-if="changelog?.type == 'md'" | ||
| :info="changelog" | ||
| :tpTarget="tptoc" | ||
| /> | ||
| <p class="mt-5" v-else>{{ $t('changelog.no_logs') }}</p> | ||
| </section> | ||
| </main> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.