add platform demo fam

This commit is contained in:
JCEEE
2026-09-10 18:54:38 +01:00
parent 4730ab3eb9
commit 41033914b4
10 changed files with 114 additions and 30 deletions
+10 -2
View File
@@ -1,6 +1,7 @@
import { SCHEMA_PLAN } from '@shared/pb/schema';
import { PB_ENDPOINT } from '$lib/server/pocketbase';
import { PB_EMAIL, PB_PASSWORD, MEMBER_SECRET } from '$app/env/private';
import { getPlatformFlags } from '$lib/server/platform';
let token: string | null = null;
let tokenExpiry = 0;
@@ -20,6 +21,11 @@ async function auth(): Promise<string> {
return token!;
}
async function isDemo(): Promise<boolean> {
const flags = await getPlatformFlags();
return flags.demo === true;
}
async function getCollection(name: string): Promise<any | null> {
const t = await auth();
const res = await fetch(`${PB_ENDPOINT}/api/collections?filter=name='${name}'`, {
@@ -444,8 +450,10 @@ export async function migrate(): Promise<void> {
await ensureAccessCodes();
await ensurePlatform();
await ensureDefaultSeasons();
await seedDemoFamily();
await seedDemoCompletions();
if (await isDemo()) {
await seedDemoFamily();
await seedDemoCompletions();
}
console.log('[migrate] Done');
}