Files
supabase/apps/www/lib/changelog-repo.ts
Francesco SansalvadoreandClaude 00d12c305c Include Migration steps in changelog bodySection (#48496)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Feature / refactor

## What is the current behavior?

The changelog entry parser extracts `## Migration steps` as a separate
field (`migrationSteps`), and the `bodySection` stops before it. This
requires consumers to handle migration steps separately from the main
body content.

## What is the new behavior?

The `bodySection` now includes `## Migration steps` as part of the
rendered body content. The `migrationSteps` field has been removed from
the `ChangelogEntry` type. The `bodySection` extraction now stops at
internal-only planning sections (`## Rollout timeline`, `## Comms
timeline`) instead of at migration steps, allowing migration steps to be
included in the public-facing body.

## Additional context

- Updated `parseChangelogEntryFile` to extract `bodySection` through
migration steps, excluding only internal planning tables
- Updated the `ChangelogEntry` type documentation to clarify that
`bodySection` includes migration steps
- Added a test case verifying that migration steps are included in the
rendered body while internal sections are excluded
- This simplifies the API by consolidating public body content into a
single field

https://claude.ai/code/session_01X5ikaawVPZwMT5C2dWUyJY

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Improvements**
* Changelog entries now include all public content following the Body
section, including relevant subsections and rollout information.
* Migration guidance is included directly within the main changelog body
for a clearer reading experience.
* Internal notes, communications, and planning details remain excluded
from displayed changelog content.
* Unmatched internal markers now correctly hide all subsequent content
from public changelogs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-31 16:33:48 +02:00

104 lines
3.2 KiB
TypeScript

import { createAppAuth } from '@octokit/auth-app'
import { Octokit } from '@octokit/core'
import {
fetchChangelogEntryFilesFromTarball,
getPublishedChangelogEntries,
} from './changelog-entries-core.mjs'
const CHANGELOG_REPO_OWNER = 'supabase'
const CHANGELOG_REPO_NAME = 'changelog'
const CHANGELOG_ENTRIES_PATH = 'entries'
export type ChangeType =
| 'breaking-change'
| 'deprecation'
| 'new-feature'
| 'improvement'
| 'bug-fix'
| 'security'
| 'policy'
export type ChangelogEntryFrontmatter = {
title: string
change_type: ChangeType
product_stage?: string | null
affected_products: string[]
affects_self_hosted?: boolean | null
version?: string | null
public: boolean
publish_date?: string | null
sunset_date?: string | null
learn_more_url?: string | null
rfc_url?: string | null
legacy_gh_discussion?: number | null
}
export type ChangelogEntry = {
/** URL-safe identifier. `legacy_gh_discussion-suffix` for backfilled entries, else the filename suffix. */
slug: string
filename: string
frontmatter: ChangelogEntryFrontmatter
/** Date used for sorting/display: publish_date, falling back to the filename's date prefix. */
sortDate: string
/** Contents of `## Summary` only. */
summary: string
/**
* Everything under `## Body` to the end of the public content. The
* `<!-- internal -->` block is the only boundary — content authors want kept
* off the published page goes inside that block.
*/
bodySection: string
}
function createChangelogRepoOctokit() {
return new Octokit({
authStrategy: createAppAuth,
auth: {
appId: process.env.CHANGELOG_SYNC_APP_ID,
installationId: process.env.CHANGELOG_SYNC_APP_INSTALLATION_ID,
privateKey: process.env.CHANGELOG_SYNC_APP_PRIVATE_KEY?.replace(/\\n/g, '\n'),
},
})
}
/**
* supabase/changelog is the source of truth — no fallback source. If this
* throws (outage, misconfigured App access, etc.), it propagates so the
* failure is loud and visible rather than silently degrading to a stale or
* differently-shaped data source.
*/
async function listChangelogEntries(): Promise<ChangelogEntry[]> {
const octokit = createChangelogRepoOctokit()
const files = await fetchChangelogEntryFilesFromTarball(octokit, {
owner: CHANGELOG_REPO_OWNER,
repo: CHANGELOG_REPO_NAME,
entriesPath: CHANGELOG_ENTRIES_PATH,
})
return getPublishedChangelogEntries(files) as ChangelogEntry[]
}
const CACHE_TTL_MS = 5 * 60 * 1000
let cachedEntries: Promise<ChangelogEntry[]> | null = null
let cachedAt = 0
/** All public, currently-published changelog entries, newest first. */
export async function getChangelogEntries(): Promise<ChangelogEntry[]> {
if (!cachedEntries || Date.now() - cachedAt > CACHE_TTL_MS) {
cachedAt = Date.now()
cachedEntries = listChangelogEntries().catch((error) => {
// Clear cache on failure so the next call retries instead of reusing the rejection.
cachedEntries = null
cachedAt = 0
throw error
})
}
return cachedEntries
}
export async function getChangelogEntryBySlug(slug: string): Promise<ChangelogEntry | null> {
const entries = await getChangelogEntries()
return entries.find((entry) => entry.slug === slug) ?? null
}