mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 01:40:13 -04:00
22cfd2be14
* 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>
91 lines
2.3 KiB
TypeScript
91 lines
2.3 KiB
TypeScript
import assert from 'assert'
|
|
import { faker } from '@faker-js/faker'
|
|
|
|
import { waitForProjectStatus } from '../common/helpers.js'
|
|
import { waitForHealthyServices } from '../common/wait-healthy-services.js'
|
|
import { PlatformClient } from '../common/platform.js'
|
|
|
|
export interface CreateProjectParams {
|
|
platformClient: PlatformClient
|
|
orgSlug: string
|
|
supaRegion: string
|
|
projectName: string
|
|
}
|
|
|
|
export async function createProject({
|
|
platformClient,
|
|
orgSlug,
|
|
supaRegion,
|
|
projectName,
|
|
}: CreateProjectParams): Promise<string> {
|
|
const dbPass = faker.internet.password()
|
|
|
|
const createResp = await platformClient.send(
|
|
`/v1/projects`,
|
|
{
|
|
method: 'POST',
|
|
body: {
|
|
organization_slug: orgSlug,
|
|
name: projectName,
|
|
region_selection: {
|
|
type: 'specific',
|
|
code: supaRegion,
|
|
},
|
|
db_pass: dbPass,
|
|
desired_instance_size: 'small',
|
|
},
|
|
},
|
|
60000
|
|
)
|
|
|
|
if (createResp.status != 201) {
|
|
console.error('❌ Could not create project')
|
|
console.error(await createResp.text())
|
|
}
|
|
assert(createResp.status == 201, createResp.statusText)
|
|
const project = await createResp.json()
|
|
const ref = project.ref
|
|
console.log(`✨ Created project ${ref}`)
|
|
console.log('⏳ Waiting for healthy project...')
|
|
|
|
// wait for project to be ready
|
|
await waitForProjectStatus({ platformClient, ref, expectedStatus: 'ACTIVE_HEALTHY' })
|
|
|
|
// wait for all services to be healthy
|
|
console.log('⏳ Waiting for healthy services...')
|
|
await waitForHealthyServices(platformClient, ref)
|
|
|
|
console.log(`🎉 Project created successfully: ${ref}`)
|
|
return ref
|
|
}
|
|
|
|
export interface GetProjectRefParams {
|
|
platformClient: PlatformClient
|
|
orgSlug: string
|
|
supaRegion: string
|
|
projectName: string
|
|
}
|
|
|
|
export async function getProjectRef({
|
|
platformClient,
|
|
orgSlug,
|
|
supaRegion,
|
|
projectName,
|
|
}: GetProjectRefParams): Promise<string | undefined> {
|
|
const getResp = await platformClient.send(`/v1/projects`, { method: 'GET' }, 60000)
|
|
|
|
if (getResp.status != 200) {
|
|
console.error('❌ Could not fetch projects')
|
|
console.error(await getResp.text())
|
|
}
|
|
assert(getResp.status == 200, getResp.statusText)
|
|
|
|
const projects = await getResp.json()
|
|
|
|
const project = projects.find(
|
|
(p: any) => p.organization_slug === orgSlug && p.region === supaRegion && p.name === projectName
|
|
)
|
|
|
|
return project?.ref
|
|
}
|