Files
supabase/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.levels.nav-check.test.ts
T
46727fa89b docs: add guide for managing remote config as code (#50353)
## I have read the CONTRIBUTING.md file.

YES

## What kind of change does this PR introduce?

Docs. A new guide for `supabase config diff`, `config pull`, and `config
push`, written for CLI v3. Relates to MARKET-1590.

## What is the current behavior?

The CLI reference lists the three commands, but no guide explains the
workflow. The Select 2026 recap blog tells users to run `config pull`
with nothing to link to.

## What is the new behavior?

- New guide at `/docs/guides/local-development/config-as-code`, in the
nav after "Managing config and secrets".
- Covers diff (labels, `--exit-code` for CI), pull (preview, git check,
where values go), push (one consent question, `--yes` for CI and agents,
the `init` defaults risk), and what push can and cannot write.
- Links to `local-and-hosted-projects` and `migrating-to-v3` for the
shared v3 target and consent rules.

## Additional context

All behavior claims are checked against `supabase/cli` `v3.4.0`.

**Related:** #50594 by @Sweta0519 adds a `config push` section to
`managing-config.mdx`. This guide includes its `[group-write]` and
`init` defaults points, with credit. It might be good to ask if we can
shrink #50594 to a short pointer to this guide, so the two do not repeat
each other.

**Needs review:** one inline `NEEDS REVIEW` comment. "The Dashboard
stays editable" is product intent from the PRFAQ, not confirmed in
platform code.

**Verified:** MDX compiles, internal links and anchors resolve, and the
preview page returns 200 and shows in the nav.

| Before (net-new page) | [After (PR
preview)](https://docs-git-nikrichers-market-1590-launch-config-d-a8be81-supabase.vercel.app/docs/guides/local-development/config-as-code)
|
| ------------------------------ | --- |
| _No production URL, new page._ |
![config-as-code-after](https://moijyfpvgnmgoxvwcikq.supabase.co/storage/v1/object/public/pr-proof/supabase/supabase/pr50353/config-as-code-after-v3-865d0b89.png)
|

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Nik Richers <nik@validmind.ai>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 13:01:58 -06:00

97 lines
3.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { GlobalMenuItems } from '../Navigation.types'
import * as currentNavItems from './NavigationMenu.constants'
import * as option1NavItems from '@/features/IaNav/option1.constants'
const MAX_ITEMS = 9
type Level = { path: string; size: number }
type NavNode = { name?: string; enabled?: boolean; items?: NavNode[] }
// count only what renders: disabled items and their subtrees are hidden
const isRendered = (item: { enabled?: boolean }) => item.enabled !== false
function sidebarLevels(path: string, allItems: NavNode[]): Level[] {
const items = allItems.filter((item) => isRendered(item))
return [
{ path, size: items.length },
...items.flatMap((item) =>
item.items?.length ? sidebarLevels(`${path} > ${item.name}`, item.items) : []
),
]
}
function topNavLevels(allSections: GlobalMenuItems): Level[] {
const menu = allSections.filter(([item]) => isRendered(item))
return [
{ path: 'Top nav', size: menu.length },
...menu.flatMap(([item]) =>
(item.menuItems ?? []).map((column, index) => ({
path: `Top nav > ${item.label} > column ${index + 1}`,
size: column.filter((columnItem) => isRendered(columnItem)).length,
}))
),
]
}
function oversizedLevels(navItems: Record<string, unknown>): string[] {
// A sidebar shared by several URL prefixes is exported under each name.
const sidebars = new Set(
Object.values(navItems).filter(
(value): value is { title: string; items: NavNode[] } =>
typeof value === 'object' &&
value !== null &&
'title' in value &&
Array.isArray((value as { items?: unknown }).items)
)
)
return [
...topNavLevels(navItems.GLOBAL_MENU_ITEMS as GlobalMenuItems),
...[...sidebars].flatMap((sidebar) => sidebarLevels(sidebar.title, sidebar.items)),
]
.filter((level) => level.size > MAX_ITEMS)
.map((level) => level.path)
}
// Levels allowed 10 or more items, such as a list of peers like quickstarts or providers.
const ALLOWLIST = [
'Auth',
'Auth > Flows (How-tos)',
'Auth > Flows (How-tos) > Social Sign-in (OAuth)',
'Database',
'Database > Extensions',
'Database > Foreign Data Wrappers > Sources',
'Database > Working with your database (intermediate)',
'Edge Functions',
'Edge Functions > Examples',
'Edge Functions > Third-Party Tools',
'Local Dev / CLI > Guides',
'Platform > Billing > Manage your usage',
'Platform > Platform Configuration',
'Self-Hosting',
'Self-Hosting > How-to Guides',
'Start with Supabase > Framework Quickstarts',
'Start with Supabase > Web app demos',
'Storage > File Buckets',
]
const OPTION_1_ALLOWLIST = [
'Auth > Social Sign-in (OAuth)',
'Database > Foreign Data Wrappers > Apps and APIs',
'Database > Foreign Data Wrappers > Databases and warehouses',
'Start > Framework Quickstarts > JavaScript and TypeScript',
'Start > Web app demos',
]
describe('navigation level size', () => {
it.each([
["today's navigation", currentNavItems, ALLOWLIST],
['Option 1', option1NavItems, OPTION_1_ALLOWLIST],
])('%s has no level with 10 or more items outside the allowlist', (_, navItems, allowlist) => {
expect(oversizedLevels(navItems).sort()).toEqual([...allowlist].sort())
})
})