mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 22:18:00 +08:00
* added packages for creating projects * updated scripts * remove ami version * cleaned up common * updated tests * refactored helpers * updated env * updated config * updated to reference env * updated global setup * updated type logic and scripts * added mocking of hcaptcha * added log statements * updated local env * update env file * updated env vars * updated logging * updated to remove check * updated print and project names * updated helpers * updated url * updated setup * updated storage helpers to account for listing files * updated setup and tests * updated timeout only for setup * updated helper to account for different api response * added ignores for tests * updated lock file * updated database spec to add exact * updated timeouts * removed check for table grid footer * updated test runner * updated is_platform * updated playwright config * updated worker settings * removed dotenvx * updated README * updated to remove comment * Update e2e/studio/scripts/common/retriedFetch.ts Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { env } from '../env.config.js'
|
|
import { PlatformClient } from './common/platform.js'
|
|
import { createProject, getProjectRef } from './helpers/project.js'
|
|
|
|
export async function setupProjectForTests() {
|
|
if (!env.IS_PLATFORM) {
|
|
console.log('Not running on platform, skipping project creation')
|
|
return 'default'
|
|
}
|
|
|
|
// Will default to e2e-test-<timestamp> if not set
|
|
const projectName = env.BRANCH_NAME
|
|
|
|
// Validate required environment variables
|
|
const orgSlug = env.ORG_SLUG
|
|
const supaRegion = env.SUPA_REGION
|
|
const apiUrl = env.API_URL
|
|
const supaPat = env.SUPA_PAT
|
|
if (!orgSlug) throw new Error('ORG_SLUG environment variable is required')
|
|
if (!supaRegion) throw new Error('SUPA_REGION environment variable is required')
|
|
if (!apiUrl) throw new Error('API_URL environment variable is required')
|
|
if (!supaPat) throw new Error('SUPA_PAT environment variable is required')
|
|
|
|
const platformClient = new PlatformClient({
|
|
url: apiUrl,
|
|
accessToken: supaPat,
|
|
})
|
|
|
|
const existingProjectRef = await getProjectRef({
|
|
platformClient,
|
|
orgSlug,
|
|
supaRegion,
|
|
projectName,
|
|
})
|
|
if (existingProjectRef) {
|
|
console.log(`\n ✅ Project found: ${existingProjectRef}, settings as environment variables`)
|
|
return existingProjectRef
|
|
} else {
|
|
console.log(`\n 🔑 Project not found, creating new project...`)
|
|
}
|
|
|
|
const ref = await createProject({
|
|
platformClient,
|
|
orgSlug,
|
|
supaRegion,
|
|
projectName,
|
|
})
|
|
|
|
console.log(`\n ✅ Project created: ${ref}, settings as environment variables`)
|
|
return ref
|
|
}
|