Skip to content

Commit afbfa11

Browse files
authored
chore: update seed.ts (calcom#25316)
* chore: update seed.ts * Revert "chore: update seed.ts" This reverts commit 2bd0c5a. * use env vars instead
1 parent a7aabc8 commit afbfa11

3 files changed

Lines changed: 25 additions & 15 deletions

File tree

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,7 @@ SALESFORCE_GRAPHQL_MAX_RETRIES=3
491491

492492
# Force Node.js to use UTC as process timezone
493493
TZ=UTC
494+
495+
# test oauth client for `packages/platform/examples/base` (optional)
496+
SEED_PLATFORM_OAUTH_CLIENT_ID=
497+
SEED_PLATFORM_OAUTH_CLIENT_SECRET=

scripts/seed.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dayjs from "@calcom/dayjs";
88
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
99
import { hashPassword } from "@calcom/lib/auth/hashPassword";
1010
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability";
11-
import prisma from "@calcom/prisma";
11+
import { prisma } from "@calcom/prisma";
1212
import type { Membership, Team, User, UserPermissionRole } from "@calcom/prisma/client";
1313
import { Prisma } from "@calcom/prisma/client";
1414
import { BookingStatus, MembershipRole, RedirectType, SchedulingType } from "@calcom/prisma/enums";
@@ -184,18 +184,22 @@ async function createPlatformAndSetupUser({
184184
},
185185
});
186186

187-
await prisma.platformOAuthClient.create({
188-
data: {
189-
name: "Acme",
190-
redirectUris: ["http://localhost:4321"],
191-
permissions: 1023,
192-
areEmailsEnabled: true,
193-
organizationId: team.id,
194-
id: "clxyyy21o0003sbk7yw5z6tzg",
195-
secret:
196-
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiQWNtZSAiLCJwZXJtaXNzaW9ucyI6MTAyMywicmVkaXJlY3RVcmlzIjpbImh0dHA6Ly9sb2NhbGhvc3Q6NDMyMSJdLCJib29raW5nUmVkaXJlY3RVcmkiOiIiLCJib29raW5nQ2FuY2VsUmVkaXJlY3RVcmkiOiIiLCJib29raW5nUmVzY2hlZHVsZVJlZGlyZWN0VXJpIjoiIiwiYXJlRW1haWxzRW5hYmxlZCI6dHJ1ZSwiaWF0IjoxNzE5NTk1ODA4fQ.L5_jSS14fcKLCD_9_DAOgtGd6lUSZlU5CEpCPaPt41I",
197-
},
198-
});
187+
const clientId = process.env.SEED_PLATFORM_OAUTH_CLIENT_ID;
188+
const secret = process.env.SEED_PLATFORM_OAUTH_CLIENT_SECRET;
189+
190+
if (clientId && secret) {
191+
await prisma.platformOAuthClient.create({
192+
data: {
193+
name: "Acme",
194+
redirectUris: ["http://localhost:4321"],
195+
permissions: 1023,
196+
areEmailsEnabled: true,
197+
organizationId: team.id,
198+
id: clientId,
199+
secret,
200+
},
201+
});
202+
}
199203
console.log(`\t👤 Added '${teamInput.name}' membership for '${username}' with role '${membershipRole}'`);
200204
}
201205
}
@@ -1535,7 +1539,7 @@ async function main() {
15351539

15361540
async function runSeed() {
15371541
await prisma.$connect();
1538-
1542+
15391543
await mainAppStore();
15401544
await main();
15411545
await mainHugeEventTypesSeed();

turbo.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@
282282
"_CAL_INTERNAL_PAST_BOOKING_RESCHEDULE_CHANGE_TEAM_IDS",
283283
"ENTERPRISE_SLUGS",
284284
"PLATFORM_ENTERPRISE_SLUGS",
285-
"USE_POOL"
285+
"USE_POOL",
286+
"SEED_PLATFORM_OAUTH_CLIENT_ID",
287+
"SEED_PLATFORM_OAUTH_CLIENT_SECRET"
286288
],
287289
"tasks": {
288290
"@calcom/web#copy-app-store-static": {

0 commit comments

Comments
 (0)