Files
supabase/apps/docs/components/reference/enrichments/cli/CliGlobalFlagsHandler.tsx
Chris Chinchilla d158e7142a docs: Allow for customisable CLI profiles in ref docs (#40181)
* Allow for customisable CLI profiles in ref docs

* Prettier

* Type fix

* Prettier

* Changes from review

* Set default config

* Handle empty values
2025-11-06 08:51:15 +01:00

52 lines
1.6 KiB
TypeScript

import RefSubLayout from '~/layouts/ref/RefSubLayout'
import spec from '~/spec/cli_v1_commands.yaml' with { type: 'yaml' }
import Param from '~/components/Params'
import { isFeatureEnabled } from 'common'
import { getCustomContent } from '~/lib/custom-content/getCustomContent'
const { cliDisableCustomProfiles } = isFeatureEnabled(['cli:disable_custom_profiles'])
const CliGlobalFlagsHandler = () => {
// Only fetch cliProfile when custom profiles are enabled
const cliProfile = !cliDisableCustomProfiles
? getCustomContent(['cli:profile'] as any).cliProfile
: undefined
// Transform the flags based on feature flags
const processedFlags = spec.flags.map((flag: any) => {
if (flag.id === 'profile' && !cliDisableCustomProfiles) {
return {
id: 'profile',
name: `--profile ${cliProfile}`,
description: `use ${cliProfile} profile for connecting to Supabase API`,
}
}
return flag
})
return (
<RefSubLayout.EducationRow className="not-prose">
<RefSubLayout.Details>
<h3 className="text-lg text-foreground mb-3">Flags</h3>
<ul>
{processedFlags.map((flag) => {
return (
<Param
{...flag}
key={flag.id}
id={`${spec.id}-${flag.id}`}
isOptional={flag.required === undefined ? true : !flag.required}
></Param>
)
})}
</ul>
</RefSubLayout.Details>
<RefSubLayout.Examples></RefSubLayout.Examples>
</RefSubLayout.EducationRow>
)
}
export default CliGlobalFlagsHandler