Skip to content

Commit d158e71

Browse files
docs: Allow for customisable CLI profiles in ref docs (supabase#40181)
* Allow for customisable CLI profiles in ref docs * Prettier * Type fix * Prettier * Changes from review * Set default config * Handle empty values
1 parent 7682bac commit d158e71

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

apps/docs/components/reference/enrichments/cli/CliGlobalFlagsHandler.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,35 @@ import RefSubLayout from '~/layouts/ref/RefSubLayout'
22

33
import spec from '~/spec/cli_v1_commands.yaml' with { type: 'yaml' }
44
import Param from '~/components/Params'
5+
import { isFeatureEnabled } from 'common'
6+
import { getCustomContent } from '~/lib/custom-content/getCustomContent'
7+
8+
const { cliDisableCustomProfiles } = isFeatureEnabled(['cli:disable_custom_profiles'])
59

610
const CliGlobalFlagsHandler = () => {
11+
// Only fetch cliProfile when custom profiles are enabled
12+
const cliProfile = !cliDisableCustomProfiles
13+
? getCustomContent(['cli:profile'] as any).cliProfile
14+
: undefined
15+
16+
// Transform the flags based on feature flags
17+
const processedFlags = spec.flags.map((flag: any) => {
18+
if (flag.id === 'profile' && !cliDisableCustomProfiles) {
19+
return {
20+
id: 'profile',
21+
name: `--profile ${cliProfile}`,
22+
description: `use ${cliProfile} profile for connecting to Supabase API`,
23+
}
24+
}
25+
return flag
26+
})
27+
728
return (
829
<RefSubLayout.EducationRow className="not-prose">
930
<RefSubLayout.Details>
1031
<h3 className="text-lg text-foreground mb-3">Flags</h3>
1132
<ul>
12-
{spec.flags.map((flag) => {
33+
{processedFlags.map((flag) => {
1334
return (
1435
<Param
1536
{...flag}

apps/docs/lib/custom-content/CustomContent.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type CustomContentTypes = {
22
homepageHeading: string
33
metadataApplicationName: string
44
metadataTitle: string
5+
cliProfile: string
56
navigationLogo: {
67
light: string
78
dark: string

apps/docs/lib/custom-content/getCustomContent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function contentToCamelCase(feature: CustomContent) {
2121
}
2222

2323
type CustomContentResult<T extends CustomContent[]> = {
24-
[key in CustomContentToCamelCase<T[number]>]:
25-
| CustomContentTypes[CustomContentToCamelCase<T[number]>]
26-
| null
24+
[key in CustomContentToCamelCase<T[number]> extends keyof CustomContentTypes
25+
? CustomContentToCamelCase<T[number]>
26+
: never]: CustomContentTypes[key] | null
2727
}
2828

2929
export const getCustomContent = <T extends CustomContent[]>(

packages/common/enabled-features/enabled-features.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
"branding:large_logo": false,
3131

32+
"cli:disable_custom_profiles": true,
33+
3234
"dashboard_auth:sign_up": true,
3335
"dashboard_auth:sign_in_with_github": true,
3436
"dashboard_auth:sign_in_with_sso": true,

packages/common/enabled-features/enabled-features.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@
9999
"type": "boolean",
100100
"description": "Show larger logo sizes throughout the apps"
101101
},
102-
102+
"cli:disable_custom_profiles": {
103+
"type": "boolean",
104+
"description": "Disable custom CLI profiles feature"
105+
},
103106
"dashboard_auth:sign_up": {
104107
"type": "boolean",
105108
"description": "Enable the sign up page in the dashboard"

0 commit comments

Comments
 (0)