Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🎉 New features

- [eas-cli] Add `eas integrations:supabase:connect` command.

- [build-tools] Add `ref` input to the `eas/checkout` step to check out a different git ref (branch, tag, or commit SHA) than the one that triggered the job. ([#4035](https://github.com/expo/eas-cli/pull/4035) by [@sswrk](https://github.com/sswrk))

### 🐛 Bug fixes
Expand Down
57 changes: 57 additions & 0 deletions packages/eas-cli/src/commandUtils/supabase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import chalk from 'chalk';

import {
SupabaseConnectionData,
SupabaseOrganizationData,
SupabaseProjectData,
} from '../graphql/types/SupabaseConnection';
import Log, { link } from '../log';

export function getSupabaseProjectDashboardUrl(
project: Pick<SupabaseProjectData, 'supabaseProjectRef'>
): string {
return `https://supabase.com/dashboard/project/${encodeURIComponent(project.supabaseProjectRef)}`;
}

/** Prefer human-readable org name; Supabase slugs are often opaque ids like `ycjmzsygzfkryaazoitp`. */
export function formatSupabaseOrganization(
connection: Pick<
SupabaseConnectionData,
'supabaseOrganizationSlug' | 'supabaseOrganizationName'
>,
organizations: readonly SupabaseOrganizationData[] = []
): string {
const slug = connection.supabaseOrganizationSlug;
const storedName = connection.supabaseOrganizationName;
const liveName = organizations.find(organization => organization.slug === slug)?.name;
const name = storedName || liveName;
if (name && name !== slug) {
return `${name} (${slug})`;
}
return slug;
}

/** Prefer human-readable project name over the opaque project ref. */
export function formatSupabaseProjectLabel(
project: Pick<SupabaseProjectData, 'supabaseProjectRef' | 'supabaseProjectName'>
): string {
const { supabaseProjectRef: ref, supabaseProjectName: name } = project;
if (name && name !== ref) {
return `${name} (${ref})`;
}
return ref;
}

export function formatSupabaseProject(project: SupabaseProjectData): string {
return [
`${chalk.bold('Name')}: ${project.supabaseProjectName}`,
`${chalk.bold('Ref')}: ${project.supabaseProjectRef}`,
`${chalk.bold('URL')}: ${project.supabaseProjectUrl}`,
`${chalk.bold('Region')}: ${project.supabaseRegion}`,
`${chalk.bold('Dashboard')}: ${link(getSupabaseProjectDashboardUrl(project), { dim: false })}`,
].join('\n');
}

export function logNoSupabaseProject(projectName: string): void {
Log.warn(`No Supabase project is linked to Expo app ${chalk.bold(projectName)} on EAS.`);
}
Loading