Skip to content

Commit 1b21ead

Browse files
fix: admin wizard crash and prisma enum generator path resolution (calcom#28244)
* fix: admin wizard crash and prisma enum generator path resolution 1. Fix TypeError in WizardForm when license step is skipped: - defaultStep was set to 3 (APPS) but only 2 steps existed when hasValidLicense=true, causing steps[2] to be undefined - Removed redundant double onNext() call in AdminUser onSuccess - Extracted hasLicenseStep variable for clarity 2. Fix prisma enum generator not being directory-safe: - Created run-enum-generator.js wrapper resolved by Prisma relative to schema directory, so npx prisma commands work from any directory Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: use bin entry for prisma enum generator path resolution Changed provider from './run-enum-generator.js' (which Prisma doesn't resolve relative to schema dir) to 'prisma-enum-generator' bin registered in package.json. This ensures the generator is found via PATH regardless of CWD. Co-Authored-By: alex@cal.com <me@alexvanandel.com> * chore: Also add new bin to the lockfile --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 5b88eef commit 1b21ead

5 files changed

Lines changed: 20 additions & 12 deletions

File tree

apps/web/modules/auth/setup-view.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ export function Setup(props: PageProps) {
3030
props.hasValidLicense ? "EXISTING" : "FREE"
3131
);
3232

33+
const hasLicenseStep = !props.hasValidLicense && !hasPickedAGPLv3;
34+
3335
const defaultStep = useMemo(() => {
3436
if (props.userCount > 0) {
35-
if (!props.hasValidLicense && !hasPickedAGPLv3) {
37+
if (hasLicenseStep) {
3638
return SETUP_VIEW_SETPS.LICENSE;
3739
} else {
38-
return SETUP_VIEW_SETPS.APPS;
40+
// License step is not shown, so apps step is at position 2 instead of 3
41+
return SETUP_VIEW_SETPS.APPS - 1;
3942
}
4043
}
4144
return SETUP_VIEW_SETPS.ADMIN_USER;
42-
}, [props.userCount, props.hasValidLicense, hasPickedAGPLv3]);
45+
}, [props.userCount, hasLicenseStep]);
4346

4447
const steps: WizardStep[] = [
4548
{
@@ -52,13 +55,7 @@ export function Setup(props: PageProps) {
5255
setIsPending(true);
5356
}}
5457
onSuccess={() => {
55-
// If there's already a valid license or user picked AGPLv3, skip to apps step
56-
if (props.hasValidLicense || hasPickedAGPLv3) {
57-
nav.onNext();
58-
nav.onNext(); // Skip license step
59-
} else {
60-
nav.onNext();
61-
}
58+
nav.onNext();
6259
}}
6360
onError={() => {
6461
setIsPending(false);
@@ -71,7 +68,7 @@ export function Setup(props: PageProps) {
7168
];
7269

7370
// Only show license selection step if there's no valid license already and AGPLv3 wasn't picked
74-
if (!props.hasValidLicense && !hasPickedAGPLv3) {
71+
if (hasLicenseStep) {
7572
steps.push({
7673
title: t("choose_a_license"),
7774
description: t("choose_license_description"),

packages/prisma/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "@calcom/prisma",
33
"version": "0.0.0",
44
"private": true,
5+
"bin": {
6+
"prisma-enum-generator": "./run-enum-generator.js"
7+
},
58
"scripts": {
69
"clean": "rm -rf .turbo && rm -rf node_modules",
710
"build": "ts-node --transpile-only ./auto-migrations.ts",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
// Wrapper script for the enum generator that ensures correct path resolution
3+
// regardless of the current working directory (e.g., running prisma from repo root).
4+
// Prisma resolves providers starting with "./" relative to the schema file directory.
5+
require("ts-node").register({ transpileOnly: true });
6+
require("./enum-generator.ts");

packages/prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ generator kysely {
3636
}
3737

3838
generator enums {
39-
provider = "ts-node --transpile-only ./enum-generator.ts"
39+
provider = "prisma-enum-generator"
4040
}
4141

4242
enum SchedulingType {

yarn.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,8 @@ __metadata:
29772977
uuid: "npm:8.3.2"
29782978
zod: "npm:3.25.76"
29792979
zod-prisma-types: "npm:3.2.4"
2980+
bin:
2981+
prisma-enum-generator: ./run-enum-generator.js
29802982
languageName: unknown
29812983
linkType: soft
29822984

0 commit comments

Comments
 (0)