Skip to content

Commit

Permalink
refactor: rename id to refId + change linking command
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike committed Oct 17, 2024
1 parent c6a2aae commit 6b7b7fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions packages/core/utils/supabase/connectProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export const connectSupabaseProject = async (projectName: string, currentDir: st
const newProject = projects.find((project) => project.name === projectName);

console.log('🖇️ Getting Supabase project keys...');
const projectAPIKeys = execSync(`supabase projects api-keys --project-ref ${newProject?.id}`, { encoding: 'utf-8' });
const projectAPIKeys = execSync(`supabase projects api-keys --project-ref ${newProject?.refId}`, {
encoding: 'utf-8',
});

const SUPABASE_ANON_KEY = getSupabaseKeys(projectAPIKeys).anonKey;
const SUPABASE_SERVICE_ROLE_KEY = getSupabaseKeys(projectAPIKeys).serviceRoleKey;
const SUPABASE_URL = `https://${newProject?.id}.supabase.co/`;
const SUPABASE_URL = `https://${newProject?.refId}.supabase.co/`;

console.log(`🖇️ Saving keys to .env...`);
await updateEnvFile({
Expand All @@ -39,7 +41,7 @@ export const connectSupabaseProject = async (projectName: string, currentDir: st
});

console.log('🖇️ Linking Supabase project...');
execSync(`supabase projects link ${newProject?.id}`, {
execSync(`supabase link --project-ref ${newProject?.refId}`, {
stdio: 'inherit',
});

Expand All @@ -49,7 +51,7 @@ export const connectSupabaseProject = async (projectName: string, currentDir: st

await continueOnAnyKeypress('🖇️ When you are ready to be redirected to the Supabase page press any key');

execSync(`open https://supabase.com/dashboard/project/${newProject?.id}/settings/integrations`);
execSync(`open https://supabase.com/dashboard/project/${newProject?.refId}/settings/integrations`);

const { isIntegrationReady } = await inquirer.prompt([
{
Expand All @@ -64,7 +66,7 @@ export const connectSupabaseProject = async (projectName: string, currentDir: st
// Uncomment after CLI progress task is done.
// console.log("🖇️ Run \x1b[36mcreate-stapler-app\x1b[0m again when you've completed the integration.");
console.log(
`🖇️ You can access your project dashboard at: https://supabase.com/dashboard/project/${newProject?.id}/settings/integrations`,
`🖇️ You can access your project dashboard at: https://supabase.com/dashboard/project/${newProject?.refId}/settings/integrations`,
);
}
};
6 changes: 3 additions & 3 deletions packages/core/utils/supabase/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface SupabaseProjectInfo {
linked: boolean;
org_id: string;
id: string;
refId: string;
name: string;
region: string;
created_at: string;
Expand All @@ -12,11 +12,11 @@ export function parseProjectsList(output: string): SupabaseProjectInfo[] {
lines.splice(0, 2);

return lines.map((line) => {
const [linked, org_id, id, name, region, created_at] = line.split('│').map((item) => item.trim());
const [linked, org_id, refId, name, region, created_at] = line.split('│').map((item) => item.trim());
return {
linked: linked !== '',
org_id,
id,
refId,
name,
region,
created_at,
Expand Down

0 comments on commit 6b7b7fc

Please sign in to comment.